@file-viewer/assets-design 3.3.4 → 3.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,12 @@
1
- var bd=Object.create;var rs=Object.defineProperty;var yd=Object.getOwnPropertyDescriptor;var wd=Object.getOwnPropertyNames;var Sd=Object.getPrototypeOf,vd=Object.prototype.hasOwnProperty;var oe=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var xd=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of wd(t))!vd.call(e,o)&&o!==n&&rs(e,o,{get:()=>t[o],enumerable:!(i=yd(t,o))||i.enumerable});return e};var _d=(e,t,n)=>(n=e!=null?bd(Sd(e)):{},xd(t||!e||!e.__esModule?rs(n,"default",{value:e,enumerable:!0}):n,e));var Is=oe((Gp,mn)=>{"use strict";function pn(e){let t=e.length;for(;--t>=0;)e[t]=0}var Ad=0,fs=1,kd=2,Id=3,Dd=258,Eo=29,Vn=256,jn=Vn+1+Eo,hn=30,Fo=19,us=2*jn+1,Xt=15,Ao=16,Cd=7,Oo=256,hs=16,ps=17,ms=18,Co=new Uint8Array([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]),wi=new Uint8Array([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]),Pd=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),gs=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ed=512,vt=new Array((jn+2)*2);pn(vt);var Tn=new Array(hn*2);pn(Tn);var zn=new Array(Ed);pn(zn);var $n=new Array(Dd-Id+1);pn($n);var Lo=new Array(Eo);pn(Lo);var Si=new Array(hn);pn(Si);function ko(e,t,n,i,o){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=o,this.has_stree=e&&e.length}var bs,ys,ws;function Io(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}var Ss=e=>e<256?zn[e]:zn[256+(e>>>7)],Nn=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},je=(e,t,n)=>{e.bi_valid>Ao-n?(e.bi_buf|=t<<e.bi_valid&65535,Nn(e,e.bi_buf),e.bi_buf=t>>Ao-e.bi_valid,e.bi_valid+=n-Ao):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},lt=(e,t,n)=>{je(e,n[t*2],n[t*2+1])},vs=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},Fd=e=>{e.bi_valid===16?(Nn(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},Od=(e,t)=>{let n=t.dyn_tree,i=t.max_code,o=t.stat_desc.static_tree,r=t.stat_desc.has_stree,s=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length,c,d,u,f,h,p,S=0;for(f=0;f<=Xt;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<us;c++)d=e.heap[c],f=n[n[d*2+1]*2+1]+1,f>l&&(f=l,S++),n[d*2+1]=f,!(d>i)&&(e.bl_count[f]++,h=0,d>=a&&(h=s[d-a]),p=n[d*2],e.opt_len+=p*(f+h),r&&(e.static_len+=p*(o[d*2+1]+h)));if(S!==0){do{for(f=l-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[l]--,S-=2}while(S>0);for(f=l;f!==0;f--)for(d=e.bl_count[f];d!==0;)u=e.heap[--c],!(u>i)&&(n[u*2+1]!==f&&(e.opt_len+=(f-n[u*2+1])*n[u*2],n[u*2+1]=f),d--)}},xs=(e,t,n)=>{let i=new Array(Xt+1),o=0,r,s;for(r=1;r<=Xt;r++)o=o+n[r-1]<<1,i[r]=o;for(s=0;s<=t;s++){let a=e[s*2+1];a!==0&&(e[s*2]=vs(i[a]++,a))}},Ld=()=>{let e,t,n,i,o,r=new Array(Xt+1);for(n=0,i=0;i<Eo-1;i++)for(Lo[i]=n,e=0;e<1<<Co[i];e++)$n[n++]=i;for($n[n-1]=i,o=0,i=0;i<16;i++)for(Si[i]=o,e=0;e<1<<wi[i];e++)zn[o++]=i;for(o>>=7;i<hn;i++)for(Si[i]=o<<7,e=0;e<1<<wi[i]-7;e++)zn[256+o++]=i;for(t=0;t<=Xt;t++)r[t]=0;for(e=0;e<=143;)vt[e*2+1]=8,e++,r[8]++;for(;e<=255;)vt[e*2+1]=9,e++,r[9]++;for(;e<=279;)vt[e*2+1]=7,e++,r[7]++;for(;e<=287;)vt[e*2+1]=8,e++,r[8]++;for(xs(vt,jn+1,r),e=0;e<hn;e++)Tn[e*2+1]=5,Tn[e*2]=vs(e,5);bs=new ko(vt,Co,Vn+1,jn,Xt),ys=new ko(Tn,wi,0,hn,Xt),ws=new ko(new Array(0),Pd,0,Fo,Cd)},_s=e=>{let t;for(t=0;t<jn;t++)e.dyn_ltree[t*2]=0;for(t=0;t<hn;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Fo;t++)e.bl_tree[t*2]=0;e.dyn_ltree[Oo*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},As=e=>{e.bi_valid>8?Nn(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},ss=(e,t,n,i)=>{let o=t*2,r=n*2;return e[o]<e[r]||e[o]===e[r]&&i[t]<=i[n]},Do=(e,t,n)=>{let i=e.heap[n],o=n<<1;for(;o<=e.heap_len&&(o<e.heap_len&&ss(t,e.heap[o+1],e.heap[o],e.depth)&&o++,!ss(t,i,e.heap[o],e.depth));)e.heap[n]=e.heap[o],n=o,o<<=1;e.heap[n]=i},as=(e,t,n)=>{let i,o,r=0,s,a;if(e.sym_next!==0)do i=e.pending_buf[e.sym_buf+r++]&255,i+=(e.pending_buf[e.sym_buf+r++]&255)<<8,o=e.pending_buf[e.sym_buf+r++],i===0?lt(e,o,t):(s=$n[o],lt(e,s+Vn+1,t),a=Co[s],a!==0&&(o-=Lo[s],je(e,o,a)),i--,s=Ss(i),lt(e,s,n),a=wi[s],a!==0&&(i-=Si[s],je(e,i,a)));while(r<e.sym_next);lt(e,Oo,t)},Po=(e,t)=>{let n=t.dyn_tree,i=t.stat_desc.static_tree,o=t.stat_desc.has_stree,r=t.stat_desc.elems,s,a,l=-1,c;for(e.heap_len=0,e.heap_max=us,s=0;s<r;s++)n[s*2]!==0?(e.heap[++e.heap_len]=l=s,e.depth[s]=0):n[s*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=l<2?++l:0,n[c*2]=1,e.depth[c]=0,e.opt_len--,o&&(e.static_len-=i[c*2+1]);for(t.max_code=l,s=e.heap_len>>1;s>=1;s--)Do(e,n,s);c=r;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Do(e,n,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,n[c*2]=n[s*2]+n[a*2],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,n[s*2+1]=n[a*2+1]=c,e.heap[1]=c++,Do(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Od(e,t),xs(n,l,e.bl_count)},ls=(e,t,n)=>{let i,o=-1,r,s=t[1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),t[(n+1)*2+1]=65535,i=0;i<=n;i++)r=s,s=t[(i+1)*2+1],!(++a<l&&r===s)&&(a<c?e.bl_tree[r*2]+=a:r!==0?(r!==o&&e.bl_tree[r*2]++,e.bl_tree[hs*2]++):a<=10?e.bl_tree[ps*2]++:e.bl_tree[ms*2]++,a=0,o=r,s===0?(l=138,c=3):r===s?(l=6,c=3):(l=7,c=4))},cs=(e,t,n)=>{let i,o=-1,r,s=t[1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),i=0;i<=n;i++)if(r=s,s=t[(i+1)*2+1],!(++a<l&&r===s)){if(a<c)do lt(e,r,e.bl_tree);while(--a!==0);else r!==0?(r!==o&&(lt(e,r,e.bl_tree),a--),lt(e,hs,e.bl_tree),je(e,a-3,2)):a<=10?(lt(e,ps,e.bl_tree),je(e,a-3,3)):(lt(e,ms,e.bl_tree),je(e,a-11,7));a=0,o=r,s===0?(l=138,c=3):r===s?(l=6,c=3):(l=7,c=4)}},Bd=e=>{let t;for(ls(e,e.dyn_ltree,e.l_desc.max_code),ls(e,e.dyn_dtree,e.d_desc.max_code),Po(e,e.bl_desc),t=Fo-1;t>=3&&e.bl_tree[gs[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},Ud=(e,t,n,i)=>{let o;for(je(e,t-257,5),je(e,n-1,5),je(e,i-4,4),o=0;o<i;o++)je(e,e.bl_tree[gs[o]*2+1],3);cs(e,e.dyn_ltree,t-1),cs(e,e.dyn_dtree,n-1)},Rd=e=>{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return 0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return 1;for(n=32;n<Vn;n++)if(e.dyn_ltree[n*2]!==0)return 1;return 0},ds=!1,Md=e=>{ds||(Ld(),ds=!0),e.l_desc=new Io(e.dyn_ltree,bs),e.d_desc=new Io(e.dyn_dtree,ys),e.bl_desc=new Io(e.bl_tree,ws),e.bi_buf=0,e.bi_valid=0,_s(e)},ks=(e,t,n,i)=>{je(e,(Ad<<1)+(i?1:0),3),As(e),Nn(e,n),Nn(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},Td=e=>{je(e,fs<<1,3),lt(e,Oo,vt),Fd(e)},jd=(e,t,n,i)=>{let o,r,s=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=Rd(e)),Po(e,e.l_desc),Po(e,e.d_desc),s=Bd(e),o=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=o&&(o=r)):o=r=n+5,n+4<=o&&t!==-1?ks(e,t,n,i):e.strategy===4||r===o?(je(e,(fs<<1)+(i?1:0),3),as(e,vt,Tn)):(je(e,(kd<<1)+(i?1:0),3),Ud(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),as(e,e.dyn_ltree,e.dyn_dtree)),_s(e),i&&As(e)},zd=(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[($n[n]+Vn+1)*2]++,e.dyn_dtree[Ss(t)*2]++),e.sym_next===e.sym_end);mn.exports._tr_init=Md;mn.exports._tr_stored_block=ks;mn.exports._tr_flush_block=jd;mn.exports._tr_tally=zd;mn.exports._tr_align=Td});var Bo=oe((Hp,Ds)=>{"use strict";var $d=(e,t,n,i)=>{let o=e&65535|0,r=e>>>16&65535|0,s=0;for(;n!==0;){s=n>2e3?2e3:n,n-=s;do o=o+t[i++]|0,r=r+o|0;while(--s);o%=65521,r%=65521}return o|r<<16|0};Ds.exports=$d});var Uo=oe((Wp,Cs)=>{"use strict";var Nd=()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t},Vd=new Uint32Array(Nd()),Gd=(e,t,n,i)=>{let o=Vd,r=i+n;e^=-1;for(let s=i;s<r;s++)e=e>>>8^o[(e^t[s])&255];return e^-1};Cs.exports=Gd});var vi=oe((Xp,Ps)=>{"use strict";Ps.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 Ft=oe((Zp,Es)=>{"use strict";Es.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_MEM_ERROR:-4,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 zs=oe((qp,ut)=>{"use strict";var{_tr_init:Hd,_tr_stored_block:To,_tr_flush_block:Wd,_tr_tally:Ut,_tr_align:Xd}=Is(),Bs=Bo(),Ot=Uo(),Zd=vi(),{Z_NO_FLUSH:Rt,Z_PARTIAL_FLUSH:qd,Z_FULL_FLUSH:Kd,Z_FINISH:qe,Z_BLOCK:Fs,Z_OK:Ae,Z_STREAM_END:Os,Z_STREAM_ERROR:dt,Z_DATA_ERROR:Yd,Z_BUF_ERROR:Ro,Z_DEFAULT_COMPRESSION:Jd,Z_FILTERED:Qd,Z_HUFFMAN_ONLY:xi,Z_RLE:ef,Z_FIXED:tf,Z_DEFAULT_STRATEGY:nf,Z_UNKNOWN:of,Z_DEFLATED:_i}=Ft(),rf=9,sf=15,af=8,lf=29,cf=256,jo=cf+1+lf,df=30,ff=19,uf=2*jo+1,hf=15,Q=3,Bt=258,ft=Bt+Q+1,pf=32,bn=42,Ho=57,zo=69,$o=73,No=91,Vo=103,Zt=113,Hn=666,Ue=1,wn=2,Kt=3,Sn=4,mf=3,qt=(e,t)=>(e.msg=Zd[t],t),Ls=e=>e*2-(e>4?9:0),Lt=e=>{let t=e.length;for(;--t>=0;)e[t]=0},gf=e=>{let t,n,i,o=e.w_size;t=e.hash_size,i=t;do n=e.head[--i],e.head[i]=n>=o?n-o:0;while(--t);t=o,i=t;do n=e.prev[--i],e.prev[i]=n>=o?n-o:0;while(--t)},bf=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask,Mt=bf,Ne=e=>{let t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},Ve=(e,t)=>{Wd(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Ne(e.strm)},se=(e,t)=>{e.pending_buf[e.pending++]=t},Gn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Go=(e,t,n,i)=>{let o=e.avail_in;return o>i&&(o=i),o===0?0:(e.avail_in-=o,t.set(e.input.subarray(e.next_in,e.next_in+o),n),e.state.wrap===1?e.adler=Bs(e.adler,t,o,n):e.state.wrap===2&&(e.adler=Ot(e.adler,t,o,n)),e.next_in+=o,e.total_in+=o,o)},Us=(e,t)=>{let n=e.max_chain_length,i=e.strstart,o,r,s=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-ft?e.strstart-(e.w_size-ft):0,c=e.window,d=e.w_mask,u=e.prev,f=e.strstart+Bt,h=c[i+s-1],p=c[i+s];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do if(o=t,!(c[o+s]!==p||c[o+s-1]!==h||c[o]!==c[i]||c[++o]!==c[i+1])){i+=2,o++;do;while(c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&i<f);if(r=Bt-(f-i),i=f-Bt,r>s){if(e.match_start=t,s=r,r>=a)break;h=c[i+s-1],p=c[i+s]}}while((t=u[t&d])>l&&--n!==0);return s<=e.lookahead?s:e.lookahead},yn=e=>{let t=e.w_size,n,i,o;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-ft)&&(e.window.set(e.window.subarray(t,t+t-i),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),gf(e),i+=t),e.strm.avail_in===0)break;if(n=Go(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=n,e.lookahead+e.insert>=Q)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=Mt(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=Mt(e,e.ins_h,e.window[o+Q-1]),e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<Q)););}while(e.lookahead<ft&&e.strm.avail_in!==0)},Rs=(e,t)=>{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i,o,r,s=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_out<r||(r=e.strm.avail_out-r,o=e.strstart-e.block_start,i>o+e.strm.avail_in&&(i=o+e.strm.avail_in),i>r&&(i=r),i<n&&(i===0&&t!==qe||t===Rt||i!==o+e.strm.avail_in)))break;s=t===qe&&i===o+e.strm.avail_in?1:0,To(e,0,0,s),e.pending_buf[e.pending-4]=i,e.pending_buf[e.pending-3]=i>>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,Ne(e.strm),o&&(o>i&&(o=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+o),e.strm.next_out),e.strm.next_out+=o,e.strm.avail_out-=o,e.strm.total_out+=o,e.block_start+=o,i-=o),i&&(Go(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(s===0);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),s?Sn:t!==Rt&&t!==qe&&e.strm.avail_in===0&&e.strstart===e.block_start?wn:(r=e.window_size-e.strstart,e.strm.avail_in>r&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(Go(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water<e.strstart&&(e.high_water=e.strstart),r=e.bi_valid+42>>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,n=r>e.w_size?e.w_size:r,o=e.strstart-e.block_start,(o>=n||(o||t===qe)&&t!==Rt&&e.strm.avail_in===0&&o<=r)&&(i=o>r?r:o,s=t===qe&&e.strm.avail_in===0&&i===o?1:0,To(e,e.block_start,i,s),e.block_start+=i,Ne(e.strm)),s?Kt:Ue)},Mo=(e,t)=>{let n,i;for(;;){if(e.lookahead<ft){if(yn(e),e.lookahead<ft&&t===Rt)return Ue;if(e.lookahead===0)break}if(n=0,e.lookahead>=Q&&(e.ins_h=Mt(e,e.ins_h,e.window[e.strstart+Q-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-ft&&(e.match_length=Us(e,n)),e.match_length>=Q)if(i=Ut(e,e.strstart-e.match_start,e.match_length-Q),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Q){e.match_length--;do e.strstart++,e.ins_h=Mt(e,e.ins_h,e.window[e.strstart+Q-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Mt(e,e.ins_h,e.window[e.strstart+1]);else i=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(Ve(e,!1),e.strm.avail_out===0))return Ue}return e.insert=e.strstart<Q-1?e.strstart:Q-1,t===qe?(Ve(e,!0),e.strm.avail_out===0?Kt:Sn):e.sym_next&&(Ve(e,!1),e.strm.avail_out===0)?Ue:wn},gn=(e,t)=>{let n,i,o;for(;;){if(e.lookahead<ft){if(yn(e),e.lookahead<ft&&t===Rt)return Ue;if(e.lookahead===0)break}if(n=0,e.lookahead>=Q&&(e.ins_h=Mt(e,e.ins_h,e.window[e.strstart+Q-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Q-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-ft&&(e.match_length=Us(e,n),e.match_length<=5&&(e.strategy===Qd||e.match_length===Q&&e.strstart-e.match_start>4096)&&(e.match_length=Q-1)),e.prev_length>=Q&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-Q,i=Ut(e,e.strstart-1-e.prev_match,e.prev_length-Q),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=o&&(e.ins_h=Mt(e,e.ins_h,e.window[e.strstart+Q-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Q-1,e.strstart++,i&&(Ve(e,!1),e.strm.avail_out===0))return Ue}else if(e.match_available){if(i=Ut(e,0,e.window[e.strstart-1]),i&&Ve(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Ue}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=Ut(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<Q-1?e.strstart:Q-1,t===qe?(Ve(e,!0),e.strm.avail_out===0?Kt:Sn):e.sym_next&&(Ve(e,!1),e.strm.avail_out===0)?Ue:wn},yf=(e,t)=>{let n,i,o,r,s=e.window;for(;;){if(e.lookahead<=Bt){if(yn(e),e.lookahead<=Bt&&t===Rt)return Ue;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Q&&e.strstart>0&&(o=e.strstart-1,i=s[o],i===s[++o]&&i===s[++o]&&i===s[++o])){r=e.strstart+Bt;do;while(i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&o<r);e.match_length=Bt-(r-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Q?(n=Ut(e,1,e.match_length-Q),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Ve(e,!1),e.strm.avail_out===0))return Ue}return e.insert=0,t===qe?(Ve(e,!0),e.strm.avail_out===0?Kt:Sn):e.sym_next&&(Ve(e,!1),e.strm.avail_out===0)?Ue:wn},wf=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(yn(e),e.lookahead===0)){if(t===Rt)return Ue;break}if(e.match_length=0,n=Ut(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Ve(e,!1),e.strm.avail_out===0))return Ue}return e.insert=0,t===qe?(Ve(e,!0),e.strm.avail_out===0?Kt:Sn):e.sym_next&&(Ve(e,!1),e.strm.avail_out===0)?Ue:wn};function ct(e,t,n,i,o){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=o}var Wn=[new ct(0,0,0,0,Rs),new ct(4,4,8,4,Mo),new ct(4,5,16,8,Mo),new ct(4,6,32,32,Mo),new ct(4,4,16,16,gn),new ct(8,16,32,32,gn),new ct(8,16,128,128,gn),new ct(8,32,128,256,gn),new ct(32,128,258,1024,gn),new ct(32,258,258,4096,gn)],Sf=e=>{e.window_size=2*e.w_size,Lt(e.head),e.max_lazy_match=Wn[e.level].max_lazy,e.good_match=Wn[e.level].good_length,e.nice_match=Wn[e.level].nice_length,e.max_chain_length=Wn[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Q-1,e.match_available=0,e.ins_h=0};function vf(){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=_i,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 Uint16Array(uf*2),this.dyn_dtree=new Uint16Array((2*df+1)*2),this.bl_tree=new Uint16Array((2*ff+1)*2),Lt(this.dyn_ltree),Lt(this.dyn_dtree),Lt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(hf+1),this.heap=new Uint16Array(2*jo+1),Lt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*jo+1),Lt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Xn=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.status!==bn&&t.status!==Ho&&t.status!==zo&&t.status!==$o&&t.status!==No&&t.status!==Vo&&t.status!==Zt&&t.status!==Hn?1:0},Ms=e=>{if(Xn(e))return qt(e,dt);e.total_in=e.total_out=0,e.data_type=of;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Ho:t.wrap?bn:Zt,e.adler=t.wrap===2?0:1,t.last_flush=-2,Hd(t),Ae},Ts=e=>{let t=Ms(e);return t===Ae&&Sf(e.state),t},xf=(e,t)=>Xn(e)||e.state.wrap!==2?dt:(e.state.gzhead=t,Ae),js=(e,t,n,i,o,r)=>{if(!e)return dt;let s=1;if(t===Jd&&(t=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),o<1||o>rf||n!==_i||i<8||i>15||t<0||t>9||r<0||r>tf||i===8&&s!==1)return qt(e,dt);i===8&&(i=9);let a=new vf;return e.state=a,a.strm=e,a.status=bn,a.wrap=s,a.gzhead=null,a.w_bits=i,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=o+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+Q-1)/Q),a.window=new Uint8Array(a.w_size*2),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<o+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=(a.lit_bufsize-1)*3,a.level=t,a.strategy=r,a.method=n,Ts(e)},_f=(e,t)=>js(e,t,_i,sf,af,nf),Af=(e,t)=>{if(Xn(e)||t>Fs||t<0)return e?qt(e,dt):dt;let n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===Hn&&t!==qe)return qt(e,e.avail_out===0?Ro:dt);let i=n.last_flush;if(n.last_flush=t,n.pending!==0){if(Ne(e),e.avail_out===0)return n.last_flush=-1,Ae}else if(e.avail_in===0&&Ls(t)<=Ls(i)&&t!==qe)return qt(e,Ro);if(n.status===Hn&&e.avail_in!==0)return qt(e,Ro);if(n.status===bn&&n.wrap===0&&(n.status=Zt),n.status===bn){let o=_i+(n.w_bits-8<<4)<<8,r=-1;if(n.strategy>=xi||n.level<2?r=0:n.level<6?r=1:n.level===6?r=2:r=3,o|=r<<6,n.strstart!==0&&(o|=pf),o+=31-o%31,Gn(n,o),n.strstart!==0&&(Gn(n,e.adler>>>16),Gn(n,e.adler&65535)),e.adler=1,n.status=Zt,Ne(e),n.pending!==0)return n.last_flush=-1,Ae}if(n.status===Ho){if(e.adler=0,se(n,31),se(n,139),se(n,8),n.gzhead)se(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),se(n,n.gzhead.time&255),se(n,n.gzhead.time>>8&255),se(n,n.gzhead.time>>16&255),se(n,n.gzhead.time>>24&255),se(n,n.level===9?2:n.strategy>=xi||n.level<2?4:0),se(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(se(n,n.gzhead.extra.length&255),se(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=Ot(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=zo;else if(se(n,0),se(n,0),se(n,0),se(n,0),se(n,0),se(n,n.level===9?2:n.strategy>=xi||n.level<2?4:0),se(n,mf),n.status=Zt,Ne(e),n.pending!==0)return n.last_flush=-1,Ae}if(n.status===zo){if(n.gzhead.extra){let o=n.pending,r=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let a=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>o&&(e.adler=Ot(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex+=a,Ne(e),n.pending!==0)return n.last_flush=-1,Ae;o=0,r-=a}let s=new Uint8Array(n.gzhead.extra);n.pending_buf.set(s.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>o&&(e.adler=Ot(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex=0}n.status=$o}if(n.status===$o){if(n.gzhead.name){let o=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>o&&(e.adler=Ot(e.adler,n.pending_buf,n.pending-o,o)),Ne(e),n.pending!==0)return n.last_flush=-1,Ae;o=0}n.gzindex<n.gzhead.name.length?r=n.gzhead.name.charCodeAt(n.gzindex++)&255:r=0,se(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>o&&(e.adler=Ot(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex=0}n.status=No}if(n.status===No){if(n.gzhead.comment){let o=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>o&&(e.adler=Ot(e.adler,n.pending_buf,n.pending-o,o)),Ne(e),n.pending!==0)return n.last_flush=-1,Ae;o=0}n.gzindex<n.gzhead.comment.length?r=n.gzhead.comment.charCodeAt(n.gzindex++)&255:r=0,se(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>o&&(e.adler=Ot(e.adler,n.pending_buf,n.pending-o,o))}n.status=Vo}if(n.status===Vo){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Ne(e),n.pending!==0))return n.last_flush=-1,Ae;se(n,e.adler&255),se(n,e.adler>>8&255),e.adler=0}if(n.status=Zt,Ne(e),n.pending!==0)return n.last_flush=-1,Ae}if(e.avail_in!==0||n.lookahead!==0||t!==Rt&&n.status!==Hn){let o=n.level===0?Rs(n,t):n.strategy===xi?wf(n,t):n.strategy===ef?yf(n,t):Wn[n.level].func(n,t);if((o===Kt||o===Sn)&&(n.status=Hn),o===Ue||o===Kt)return e.avail_out===0&&(n.last_flush=-1),Ae;if(o===wn&&(t===qd?Xd(n):t!==Fs&&(To(n,0,0,!1),t===Kd&&(Lt(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),Ne(e),e.avail_out===0))return n.last_flush=-1,Ae}return t!==qe?Ae:n.wrap<=0?Os:(n.wrap===2?(se(n,e.adler&255),se(n,e.adler>>8&255),se(n,e.adler>>16&255),se(n,e.adler>>24&255),se(n,e.total_in&255),se(n,e.total_in>>8&255),se(n,e.total_in>>16&255),se(n,e.total_in>>24&255)):(Gn(n,e.adler>>>16),Gn(n,e.adler&65535)),Ne(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending!==0?Ae:Os)},kf=e=>{if(Xn(e))return dt;let t=e.state.status;return e.state=null,t===Zt?qt(e,Yd):Ae},If=(e,t)=>{let n=t.length;if(Xn(e))return dt;let i=e.state,o=i.wrap;if(o===2||o===1&&i.status!==bn||i.lookahead)return dt;if(o===1&&(e.adler=Bs(e.adler,t,n,0)),i.wrap=0,n>=i.w_size){o===0&&(Lt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let l=new Uint8Array(i.w_size);l.set(t.subarray(n-i.w_size,n),0),t=l,n=i.w_size}let r=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,yn(i);i.lookahead>=Q;){let l=i.strstart,c=i.lookahead-(Q-1);do i.ins_h=Mt(i,i.ins_h,i.window[l+Q-1]),i.prev[l&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=l,l++;while(--c);i.strstart=l,i.lookahead=Q-1,yn(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=Q-1,i.match_available=0,e.next_in=s,e.input=a,e.avail_in=r,i.wrap=o,Ae};ut.exports.deflateInit=_f;ut.exports.deflateInit2=js;ut.exports.deflateReset=Ts;ut.exports.deflateResetKeep=Ms;ut.exports.deflateSetHeader=xf;ut.exports.deflate=Af;ut.exports.deflateEnd=kf;ut.exports.deflateSetDictionary=If;ut.exports.deflateInfo="pako deflate (from Nodeca project)"});var Xo=oe((Kp,Wo)=>{"use strict";var Df=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);Wo.exports.assign=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let n=t.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(let i in n)Df(n,i)&&(e[i]=n[i])}}return e};Wo.exports.flattenChunks=e=>{let t=0;for(let i=0,o=e.length;i<o;i++)t+=e[i].length;let n=new Uint8Array(t);for(let i=0,o=0,r=e.length;i<r;i++){let s=e[i];n.set(s,o),o+=s.length}return n}});var Zo=oe((Yp,Ai)=>{"use strict";var $s=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{$s=!1}var Zn=new Uint8Array(256);for(let e=0;e<256;e++)Zn[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Zn[254]=Zn[254]=1;Ai.exports.string2buf=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,i,o,r,s=e.length,a=0;for(o=0;o<s;o++)n=e.charCodeAt(o),(n&64512)===55296&&o+1<s&&(i=e.charCodeAt(o+1),(i&64512)===56320&&(n=65536+(n-55296<<10)+(i-56320),o++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(a),r=0,o=0;r<a;o++)n=e.charCodeAt(o),(n&64512)===55296&&o+1<s&&(i=e.charCodeAt(o+1),(i&64512)===56320&&(n=65536+(n-55296<<10)+(i-56320),o++)),n<128?t[r++]=n:n<2048?(t[r++]=192|n>>>6,t[r++]=128|n&63):n<65536?(t[r++]=224|n>>>12,t[r++]=128|n>>>6&63,t[r++]=128|n&63):(t[r++]=240|n>>>18,t[r++]=128|n>>>12&63,t[r++]=128|n>>>6&63,t[r++]=128|n&63);return t};var Cf=(e,t)=>{if(t<65534&&e.subarray&&$s)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let i=0;i<t;i++)n+=String.fromCharCode(e[i]);return n};Ai.exports.buf2string=(e,t)=>{let n=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let i,o,r=new Array(n*2);for(o=0,i=0;i<n;){let s=e[i++];if(s<128){r[o++]=s;continue}let a=Zn[s];if(a>4){r[o++]=65533,i+=a-1;continue}for(s&=a===2?31:a===3?15:7;a>1&&i<n;)s=s<<6|e[i++]&63,a--;if(a>1){r[o++]=65533;continue}s<65536?r[o++]=s:(s-=65536,r[o++]=55296|s>>10&1023,r[o++]=56320|s&1023)}return Cf(r,o)};Ai.exports.utf8border=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+Zn[e[n]]>t?n:t}});var qo=oe((Jp,Ns)=>{"use strict";function Pf(){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}Ns.exports=Pf});var Ws=oe((Qp,vn)=>{"use strict";var qn=zs(),Vs=Xo(),Gs=Zo(),Ko=vi(),Ef=qo(),Hs=Object.prototype.toString,{Z_NO_FLUSH:Ff,Z_SYNC_FLUSH:Of,Z_FULL_FLUSH:Lf,Z_FINISH:Bf,Z_OK:ki,Z_STREAM_END:Uf,Z_DEFAULT_COMPRESSION:Rf,Z_DEFAULT_STRATEGY:Mf,Z_DEFLATED:Tf}=Ft();function Kn(e){this.options=Vs.assign({level:Rf,method:Tf,chunkSize:16384,windowBits:15,memLevel:8,strategy:Mf},e||{});let 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 Ef,this.strm.avail_out=0;let n=qn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==ki)throw new Error(Ko[n]);if(t.header&&qn.deflateSetHeader(this.strm,t.header),t.dictionary){let i;if(typeof t.dictionary=="string"?i=Gs.string2buf(t.dictionary):Hs.call(t.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(t.dictionary):i=t.dictionary,n=qn.deflateSetDictionary(this.strm,i),n!==ki)throw new Error(Ko[n]);this._dict_set=!0}}Kn.prototype.push=function(e,t){let n=this.strm,i=this.options.chunkSize,o,r;if(this.ended)return!1;for(t===~~t?r=t:r=t===!0?Bf:Ff,typeof e=="string"?n.input=Gs.string2buf(e):Hs.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),(r===Of||r===Lf)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(o=qn.deflate(n,r),o===Uf)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),o=qn.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===ki;if(n.avail_out===0){this.onData(n.output);continue}if(r>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0};Kn.prototype.onData=function(e){this.chunks.push(e)};Kn.prototype.onEnd=function(e){e===ki&&(this.result=Vs.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Yo(e,t){let n=new Kn(t);if(n.push(e,!0),n.err)throw n.msg||Ko[n.err];return n.result}function jf(e,t){return t=t||{},t.raw=!0,Yo(e,t)}function zf(e,t){return t=t||{},t.gzip=!0,Yo(e,t)}vn.exports.Deflate=Kn;vn.exports.deflate=Yo;vn.exports.deflateRaw=jf;vn.exports.gzip=zf;vn.exports.constants=Ft()});var Zs=oe((em,Xs)=>{"use strict";Xs.exports=function(t,n){let i,o,r,s,a,l,c,d,u,f,h,p,S,m,b,v,x,_,I,P,k,E,O,U,M=t.state;i=t.next_in,O=t.input,o=i+(t.avail_in-5),r=t.next_out,U=t.output,s=r-(n-t.avail_out),a=r+(t.avail_out-257),l=M.dmax,c=M.wsize,d=M.whave,u=M.wnext,f=M.window,h=M.hold,p=M.bits,S=M.lencode,m=M.distcode,b=(1<<M.lenbits)-1,v=(1<<M.distbits)-1;e:do{p<15&&(h+=O[i++]<<p,p+=8,h+=O[i++]<<p,p+=8),x=S[h&b];t:for(;;){if(_=x>>>24,h>>>=_,p-=_,_=x>>>16&255,_===0)U[r++]=x&65535;else if(_&16){I=x&65535,_&=15,_&&(p<_&&(h+=O[i++]<<p,p+=8),I+=h&(1<<_)-1,h>>>=_,p-=_),p<15&&(h+=O[i++]<<p,p+=8,h+=O[i++]<<p,p+=8),x=m[h&v];n:for(;;){if(_=x>>>24,h>>>=_,p-=_,_=x>>>16&255,_&16){if(P=x&65535,_&=15,p<_&&(h+=O[i++]<<p,p+=8,p<_&&(h+=O[i++]<<p,p+=8)),P+=h&(1<<_)-1,P>l){t.msg="invalid distance too far back",M.mode=16209;break e}if(h>>>=_,p-=_,_=r-s,P>_){if(_=P-_,_>d&&M.sane){t.msg="invalid distance too far back",M.mode=16209;break e}if(k=0,E=f,u===0){if(k+=c-_,_<I){I-=_;do U[r++]=f[k++];while(--_);k=r-P,E=U}}else if(u<_){if(k+=c+u-_,_-=u,_<I){I-=_;do U[r++]=f[k++];while(--_);if(k=0,u<I){_=u,I-=_;do U[r++]=f[k++];while(--_);k=r-P,E=U}}}else if(k+=u-_,_<I){I-=_;do U[r++]=f[k++];while(--_);k=r-P,E=U}for(;I>2;)U[r++]=E[k++],U[r++]=E[k++],U[r++]=E[k++],I-=3;I&&(U[r++]=E[k++],I>1&&(U[r++]=E[k++]))}else{k=r-P;do U[r++]=U[k++],U[r++]=U[k++],U[r++]=U[k++],I-=3;while(I>2);I&&(U[r++]=U[k++],I>1&&(U[r++]=U[k++]))}}else if((_&64)===0){x=m[(x&65535)+(h&(1<<_)-1)];continue n}else{t.msg="invalid distance code",M.mode=16209;break e}break}}else if((_&64)===0){x=S[(x&65535)+(h&(1<<_)-1)];continue t}else if(_&32){M.mode=16191;break e}else{t.msg="invalid literal/length code",M.mode=16209;break e}break}}while(i<o&&r<a);I=p>>3,i-=I,p-=I<<3,h&=(1<<p)-1,t.next_in=i,t.next_out=r,t.avail_in=i<o?5+(o-i):5-(i-o),t.avail_out=r<a?257+(a-r):257-(r-a),M.hold=h,M.bits=p}});var Ks=oe((tm,qs)=>{"use strict";var $f=new Uint16Array([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]),Nf=new Uint8Array([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]),Vf=new Uint16Array([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]),Gf=new Uint8Array([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]),Hf=(e,t,n,i,o,r,s,a)=>{let l=a.bits,c=0,d=0,u=0,f=0,h=0,p=0,S=0,m=0,b=0,v=0,x,_,I,P,k,E=null,O,U=new Uint16Array(16),M=new Uint16Array(16),le=null,me,T,W;for(c=0;c<=15;c++)U[c]=0;for(d=0;d<i;d++)U[t[n+d]]++;for(h=l,f=15;f>=1&&U[f]===0;f--);if(h>f&&(h=f),f===0)return o[r++]=1<<24|64<<16|0,o[r++]=1<<24|64<<16|0,a.bits=1,0;for(u=1;u<f&&U[u]===0;u++);for(h<u&&(h=u),m=1,c=1;c<=15;c++)if(m<<=1,m-=U[c],m<0)return-1;if(m>0&&(e===0||f!==1))return-1;for(M[1]=0,c=1;c<15;c++)M[c+1]=M[c]+U[c];for(d=0;d<i;d++)t[n+d]!==0&&(s[M[t[n+d]]++]=d);if(e===0?(E=le=s,O=20):e===1?(E=$f,le=Nf,O=257):(E=Vf,le=Gf,O=0),v=0,d=0,c=u,k=r,p=h,S=0,I=-1,b=1<<h,P=b-1,e===1&&b>852||e===2&&b>592)return 1;for(;;){me=c-S,s[d]+1<O?(T=0,W=s[d]):s[d]>=O?(T=le[s[d]-O],W=E[s[d]-O]):(T=96,W=0),x=1<<c-S,_=1<<p,u=_;do _-=x,o[k+(v>>S)+_]=me<<24|T<<16|W|0;while(_!==0);for(x=1<<c-1;v&x;)x>>=1;if(x!==0?(v&=x-1,v+=x):v=0,d++,--U[c]===0){if(c===f)break;c=t[n+s[d]]}if(c>h&&(v&P)!==I){for(S===0&&(S=h),k+=u,p=c-S,m=1<<p;p+S<f&&(m-=U[p+S],!(m<=0));)p++,m<<=1;if(b+=1<<p,e===1&&b>852||e===2&&b>592)return 1;I=v&P,o[I]=h<<24|p<<16|k-r|0}}return v!==0&&(o[k+v]=c-S<<24|64<<16|0),a.bits=h,0};qs.exports=Hf});var Fa=oe((nm,nt)=>{"use strict";var ir=Bo(),ht=Uo(),Wf=Zs(),Yn=Ks(),Xf=0,xa=1,_a=2,{Z_FINISH:Ys,Z_BLOCK:Zf,Z_TREES:Ii,Z_OK:Yt,Z_STREAM_END:qf,Z_NEED_DICT:Kf,Z_STREAM_ERROR:Ke,Z_DATA_ERROR:Aa,Z_MEM_ERROR:or,Z_BUF_ERROR:Yf,Z_DEFLATED:Js}=Ft(),Ei=16180,Qs=16181,ea=16182,ta=16183,na=16184,ia=16185,oa=16186,ra=16187,sa=16188,aa=16189,Pi=16190,xt=16191,Jo=16192,la=16193,Qo=16194,ca=16195,da=16196,fa=16197,ua=16198,Di=16199,Ci=16200,ha=16201,pa=16202,ma=16203,ga=16204,ba=16205,er=16206,ya=16207,wa=16208,be=16209,rr=16210,ka=16211,Jf=852,Qf=592,eu=15,tu=eu,Sa=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function nu(){this.strm=null,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 Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var Jt=e=>{if(!e)return 1;let t=e.state;return!t||t.strm!==e||t.mode<Ei||t.mode>ka?1:0},Ia=e=>{if(Jt(e))return Ke;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Ei,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Jf),t.distcode=t.distdyn=new Int32Array(Qf),t.sane=1,t.back=-1,Yt},Da=e=>{if(Jt(e))return Ke;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ia(e)},Ca=(e,t)=>{let n;if(Jt(e))return Ke;let i=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?Ke:(i.window!==null&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,Da(e))},Pa=(e,t)=>{if(!e)return Ke;let n=new nu;e.state=n,n.strm=e,n.window=null,n.mode=Ei;let i=Ca(e,t);return i!==Yt&&(e.state=null),i},iu=e=>Pa(e,tu),va=!0,tr,nr,ou=e=>{if(va){tr=new Int32Array(512),nr=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Yn(xa,e.lens,0,288,tr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Yn(_a,e.lens,0,32,nr,0,e.work,{bits:5}),va=!1}e.lencode=tr,e.lenbits=9,e.distcode=nr,e.distbits=5},Ea=(e,t,n,i)=>{let o,r=e.state;return r.window===null&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Uint8Array(r.wsize)),i>=r.wsize?(r.window.set(t.subarray(n-r.wsize,n),0),r.wnext=0,r.whave=r.wsize):(o=r.wsize-r.wnext,o>i&&(o=i),r.window.set(t.subarray(n-i,n-i+o),r.wnext),i-=o,i?(r.window.set(t.subarray(n-i,n),0),r.wnext=i,r.whave=r.wsize):(r.wnext+=o,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=o))),0},ru=(e,t)=>{let n,i,o,r,s,a,l,c,d,u,f,h,p,S,m=0,b,v,x,_,I,P,k,E,O=new Uint8Array(4),U,M,le=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Jt(e)||!e.output||!e.input&&e.avail_in!==0)return Ke;n=e.state,n.mode===xt&&(n.mode=Jo),s=e.next_out,o=e.output,l=e.avail_out,r=e.next_in,i=e.input,a=e.avail_in,c=n.hold,d=n.bits,u=a,f=l,E=Yt;e:for(;;)switch(n.mode){case Ei:if(n.wrap===0){n.mode=Jo;break}for(;d<16;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(n.wrap&2&&c===35615){n.wbits===0&&(n.wbits=15),n.check=0,O[0]=c&255,O[1]=c>>>8&255,n.check=ht(n.check,O,2,0),c=0,d=0,n.mode=Qs;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=be;break}if((c&15)!==Js){e.msg="unknown compression method",n.mode=be;break}if(c>>>=4,d-=4,k=(c&15)+8,n.wbits===0&&(n.wbits=k),k>15||k>n.wbits){e.msg="invalid window size",n.mode=be;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=c&512?aa:xt,c=0,d=0;break;case Qs:for(;d<16;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(n.flags=c,(n.flags&255)!==Js){e.msg="unknown compression method",n.mode=be;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=be;break}n.head&&(n.head.text=c>>8&1),n.flags&512&&n.wrap&4&&(O[0]=c&255,O[1]=c>>>8&255,n.check=ht(n.check,O,2,0)),c=0,d=0,n.mode=ea;case ea:for(;d<32;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}n.head&&(n.head.time=c),n.flags&512&&n.wrap&4&&(O[0]=c&255,O[1]=c>>>8&255,O[2]=c>>>16&255,O[3]=c>>>24&255,n.check=ht(n.check,O,4,0)),c=0,d=0,n.mode=ta;case ta:for(;d<16;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}n.head&&(n.head.xflags=c&255,n.head.os=c>>8),n.flags&512&&n.wrap&4&&(O[0]=c&255,O[1]=c>>>8&255,n.check=ht(n.check,O,2,0)),c=0,d=0,n.mode=na;case na:if(n.flags&1024){for(;d<16;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}n.length=c,n.head&&(n.head.extra_len=c),n.flags&512&&n.wrap&4&&(O[0]=c&255,O[1]=c>>>8&255,n.check=ht(n.check,O,2,0)),c=0,d=0}else n.head&&(n.head.extra=null);n.mode=ia;case ia:if(n.flags&1024&&(h=n.length,h>a&&(h=a),h&&(n.head&&(k=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(i.subarray(r,r+h),k)),n.flags&512&&n.wrap&4&&(n.check=ht(n.check,i,h,r)),a-=h,r+=h,n.length-=h),n.length))break e;n.length=0,n.mode=oa;case oa:if(n.flags&2048){if(a===0)break e;h=0;do k=i[r+h++],n.head&&k&&n.length<65536&&(n.head.name+=String.fromCharCode(k));while(k&&h<a);if(n.flags&512&&n.wrap&4&&(n.check=ht(n.check,i,h,r)),a-=h,r+=h,k)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=ra;case ra:if(n.flags&4096){if(a===0)break e;h=0;do k=i[r+h++],n.head&&k&&n.length<65536&&(n.head.comment+=String.fromCharCode(k));while(k&&h<a);if(n.flags&512&&n.wrap&4&&(n.check=ht(n.check,i,h,r)),a-=h,r+=h,k)break e}else n.head&&(n.head.comment=null);n.mode=sa;case sa:if(n.flags&512){for(;d<16;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(n.wrap&4&&c!==(n.check&65535)){e.msg="header crc mismatch",n.mode=be;break}c=0,d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=xt;break;case aa:for(;d<32;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}e.adler=n.check=Sa(c),c=0,d=0,n.mode=Pi;case Pi:if(n.havedict===0)return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,n.hold=c,n.bits=d,Kf;e.adler=n.check=1,n.mode=xt;case xt:if(t===Zf||t===Ii)break e;case Jo:if(n.last){c>>>=d&7,d-=d&7,n.mode=er;break}for(;d<3;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}switch(n.last=c&1,c>>>=1,d-=1,c&3){case 0:n.mode=la;break;case 1:if(ou(n),n.mode=Di,t===Ii){c>>>=2,d-=2;break e}break;case 2:n.mode=da;break;case 3:e.msg="invalid block type",n.mode=be}c>>>=2,d-=2;break;case la:for(c>>>=d&7,d-=d&7;d<32;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",n.mode=be;break}if(n.length=c&65535,c=0,d=0,n.mode=Qo,t===Ii)break e;case Qo:n.mode=ca;case ca:if(h=n.length,h){if(h>a&&(h=a),h>l&&(h=l),h===0)break e;o.set(i.subarray(r,r+h),s),a-=h,r+=h,l-=h,s+=h,n.length-=h;break}n.mode=xt;break;case da:for(;d<14;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(n.nlen=(c&31)+257,c>>>=5,d-=5,n.ndist=(c&31)+1,c>>>=5,d-=5,n.ncode=(c&15)+4,c>>>=4,d-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=be;break}n.have=0,n.mode=fa;case fa:for(;n.have<n.ncode;){for(;d<3;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}n.lens[le[n.have++]]=c&7,c>>>=3,d-=3}for(;n.have<19;)n.lens[le[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,U={bits:n.lenbits},E=Yn(Xf,n.lens,0,19,n.lencode,0,n.work,U),n.lenbits=U.bits,E){e.msg="invalid code lengths set",n.mode=be;break}n.have=0,n.mode=ua;case ua:for(;n.have<n.nlen+n.ndist;){for(;m=n.lencode[c&(1<<n.lenbits)-1],b=m>>>24,v=m>>>16&255,x=m&65535,!(b<=d);){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(x<16)c>>>=b,d-=b,n.lens[n.have++]=x;else{if(x===16){for(M=b+2;d<M;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(c>>>=b,d-=b,n.have===0){e.msg="invalid bit length repeat",n.mode=be;break}k=n.lens[n.have-1],h=3+(c&3),c>>>=2,d-=2}else if(x===17){for(M=b+3;d<M;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}c>>>=b,d-=b,k=0,h=3+(c&7),c>>>=3,d-=3}else{for(M=b+7;d<M;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}c>>>=b,d-=b,k=0,h=11+(c&127),c>>>=7,d-=7}if(n.have+h>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=be;break}for(;h--;)n.lens[n.have++]=k}}if(n.mode===be)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=be;break}if(n.lenbits=9,U={bits:n.lenbits},E=Yn(xa,n.lens,0,n.nlen,n.lencode,0,n.work,U),n.lenbits=U.bits,E){e.msg="invalid literal/lengths set",n.mode=be;break}if(n.distbits=6,n.distcode=n.distdyn,U={bits:n.distbits},E=Yn(_a,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,U),n.distbits=U.bits,E){e.msg="invalid distances set",n.mode=be;break}if(n.mode=Di,t===Ii)break e;case Di:n.mode=Ci;case Ci:if(a>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,n.hold=c,n.bits=d,Wf(e,f),s=e.next_out,o=e.output,l=e.avail_out,r=e.next_in,i=e.input,a=e.avail_in,c=n.hold,d=n.bits,n.mode===xt&&(n.back=-1);break}for(n.back=0;m=n.lencode[c&(1<<n.lenbits)-1],b=m>>>24,v=m>>>16&255,x=m&65535,!(b<=d);){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(v&&(v&240)===0){for(_=b,I=v,P=x;m=n.lencode[P+((c&(1<<_+I)-1)>>_)],b=m>>>24,v=m>>>16&255,x=m&65535,!(_+b<=d);){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}c>>>=_,d-=_,n.back+=_}if(c>>>=b,d-=b,n.back+=b,n.length=x,v===0){n.mode=ba;break}if(v&32){n.back=-1,n.mode=xt;break}if(v&64){e.msg="invalid literal/length code",n.mode=be;break}n.extra=v&15,n.mode=ha;case ha:if(n.extra){for(M=n.extra;d<M;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=pa;case pa:for(;m=n.distcode[c&(1<<n.distbits)-1],b=m>>>24,v=m>>>16&255,x=m&65535,!(b<=d);){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if((v&240)===0){for(_=b,I=v,P=x;m=n.distcode[P+((c&(1<<_+I)-1)>>_)],b=m>>>24,v=m>>>16&255,x=m&65535,!(_+b<=d);){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}c>>>=_,d-=_,n.back+=_}if(c>>>=b,d-=b,n.back+=b,v&64){e.msg="invalid distance code",n.mode=be;break}n.offset=x,n.extra=v&15,n.mode=ma;case ma:if(n.extra){for(M=n.extra;d<M;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=be;break}n.mode=ga;case ga:if(l===0)break e;if(h=f-l,n.offset>h){if(h=n.offset-h,h>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=be;break}h>n.wnext?(h-=n.wnext,p=n.wsize-h):p=n.wnext-h,h>n.length&&(h=n.length),S=n.window}else S=o,p=s-n.offset,h=n.length;h>l&&(h=l),l-=h,n.length-=h;do o[s++]=S[p++];while(--h);n.length===0&&(n.mode=Ci);break;case ba:if(l===0)break e;o[s++]=n.length,l--,n.mode=Ci;break;case er:if(n.wrap){for(;d<32;){if(a===0)break e;a--,c|=i[r++]<<d,d+=8}if(f-=l,e.total_out+=f,n.total+=f,n.wrap&4&&f&&(e.adler=n.check=n.flags?ht(n.check,o,f,s-f):ir(n.check,o,f,s-f)),f=l,n.wrap&4&&(n.flags?c:Sa(c))!==n.check){e.msg="incorrect data check",n.mode=be;break}c=0,d=0}n.mode=ya;case ya:if(n.wrap&&n.flags){for(;d<32;){if(a===0)break e;a--,c+=i[r++]<<d,d+=8}if(n.wrap&4&&c!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=be;break}c=0,d=0}n.mode=wa;case wa:E=qf;break e;case be:E=Aa;break e;case rr:return or;case ka:default:return Ke}return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,n.hold=c,n.bits=d,(n.wsize||f!==e.avail_out&&n.mode<be&&(n.mode<er||t!==Ys))&&Ea(e,e.output,e.next_out,f-e.avail_out)?(n.mode=rr,or):(u-=e.avail_in,f-=e.avail_out,e.total_in+=u,e.total_out+=f,n.total+=f,n.wrap&4&&f&&(e.adler=n.check=n.flags?ht(n.check,o,f,e.next_out-f):ir(n.check,o,f,e.next_out-f)),e.data_type=n.bits+(n.last?64:0)+(n.mode===xt?128:0)+(n.mode===Di||n.mode===Qo?256:0),(u===0&&f===0||t===Ys)&&E===Yt&&(E=Yf),E)},su=e=>{if(Jt(e))return Ke;let t=e.state;return t.window&&(t.window=null),e.state=null,Yt},au=(e,t)=>{if(Jt(e))return Ke;let n=e.state;return(n.wrap&2)===0?Ke:(n.head=t,t.done=!1,Yt)},lu=(e,t)=>{let n=t.length,i,o,r;return Jt(e)||(i=e.state,i.wrap!==0&&i.mode!==Pi)?Ke:i.mode===Pi&&(o=1,o=ir(o,t,n,0),o!==i.check)?Aa:(r=Ea(e,t,n,n),r?(i.mode=rr,or):(i.havedict=1,Yt))};nt.exports.inflateReset=Da;nt.exports.inflateReset2=Ca;nt.exports.inflateResetKeep=Ia;nt.exports.inflateInit=iu;nt.exports.inflateInit2=Pa;nt.exports.inflate=ru;nt.exports.inflateEnd=su;nt.exports.inflateGetHeader=au;nt.exports.inflateSetDictionary=lu;nt.exports.inflateInfo="pako inflate (from Nodeca project)"});var La=oe((im,Oa)=>{"use strict";function cu(){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}Oa.exports=cu});var Ma=oe((om,xn)=>{"use strict";var _t=Fa(),Ua=Xo(),lr=Zo(),cr=vi(),du=qo(),fu=La(),Ra=Object.prototype.toString,{Z_NO_FLUSH:uu,Z_FINISH:hu,Z_OK:Jn,Z_STREAM_END:sr,Z_NEED_DICT:ar,Z_STREAM_ERROR:pu,Z_DATA_ERROR:Ba,Z_MEM_ERROR:mu}=Ft();function Qn(e){this.options=Ua.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});let 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&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new du,this.strm.avail_out=0;let n=_t.inflateInit2(this.strm,t.windowBits);if(n!==Jn)throw new Error(cr[n]);if(this.header=new fu,_t.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=lr.string2buf(t.dictionary):Ra.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=_t.inflateSetDictionary(this.strm,t.dictionary),n!==Jn)))throw new Error(cr[n])}Qn.prototype.push=function(e,t){let n=this.strm,i=this.options.chunkSize,o=this.options.dictionary,r,s,a;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?hu:uu,Ra.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),r=_t.inflate(n,s),r===ar&&o&&(r=_t.inflateSetDictionary(n,o),r===Jn?r=_t.inflate(n,s):r===Ba&&(r=ar));n.avail_in>0&&r===sr&&n.state.wrap>0&&e[n.next_in]!==0;)_t.inflateReset(n),r=_t.inflate(n,s);switch(r){case pu:case Ba:case ar:case mu:return this.onEnd(r),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(n.avail_out===0||r===sr))if(this.options.to==="string"){let l=lr.utf8border(n.output,n.next_out),c=n.next_out-l,d=lr.buf2string(n.output,l);n.next_out=c,n.avail_out=i-c,c&&n.output.set(n.output.subarray(l,l+c),0),this.onData(d)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(r===Jn&&a===0)){if(r===sr)return r=_t.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(n.avail_in===0)break}}return!0};Qn.prototype.onData=function(e){this.chunks.push(e)};Qn.prototype.onEnd=function(e){e===Jn&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ua.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function dr(e,t){let n=new Qn(t);if(n.push(e),n.err)throw n.msg||cr[n.err];return n.result}function gu(e,t){return t=t||{},t.raw=!0,dr(e,t)}xn.exports.Inflate=Qn;xn.exports.inflate=dr;xn.exports.inflateRaw=gu;xn.exports.ungzip=dr;xn.exports.constants=Ft()});var fr=oe((rm,pt)=>{"use strict";var{Deflate:bu,deflate:yu,deflateRaw:wu,gzip:Su}=Ws(),{Inflate:vu,inflate:xu,inflateRaw:_u,ungzip:Au}=Ma(),ku=Ft();pt.exports.Deflate=bu;pt.exports.deflate=yu;pt.exports.deflateRaw=wu;pt.exports.gzip=Su;pt.exports.Inflate=vu;pt.exports.inflate=xu;pt.exports.inflateRaw=_u;pt.exports.ungzip=Au;pt.exports.constants=ku});var ja=oe(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.decodeJpeg=Ou;var ei=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),Fi=4017,Oi=799,Li=3406,Bi=2276,Ui=1567,Ri=3784,_n=5793,Mi=2896,Iu=100,Ta=64*1024*1024,ur=0;function An(e){let t=ur+e;if(t>Ta){let n=Math.ceil((t-Ta)/1024/1024);throw new Error(`Max memory limit exceeded by at least ${n}MB`)}ur=t}function Du(e,t){let n=16;for(;n>0&&!e[n-1];)n--;let i=[{children:[],index:0}],o=0,r=i[0];for(let s=0;s<n;s++){for(let a=0;a<e[s];a++){for(r=i.pop(),r.children[r.index]=t[o];r.index>0;){if(i.length===0)throw new Error("Could not recreate Huffman Table");r=i.pop()}for(r.index++,i.push(r);i.length<=s;){let l={children:[],index:0};i.push(l),r.children[r.index]=l.children,r=l}o++}if(s+1<n){let a={children:[],index:0};i.push(a),r.children[r.index]=a.children,r=a}}return i[0].children}function Cu(e,t,n,i,o,r,s,a,l){let c=n.mcusPerLine,d=n.progressive,u=t,f=0,h=0;function p(){if(h>0)return h--,f>>h&1;if(f=e[t++],f==255){let j=e[t++];if(j)throw new Error(`unexpected marker: ${(f<<8|j).toString(16)}`)}return h=7,f>>>7}function S(j){let R=j;for(;;){if(R=R[p()],typeof R=="number")return R;if(R===void 0)throw new Error("invalid huffman sequence")}}function m(j){let R=0;for(;j>0;)R=R<<1|p(),j--;return R}function b(j){let R=m(j);return R>=1<<j-1?R:R+(-1<<j)+1}function v(j,R){let V=S(j.huffmanTableDC),fe=V===0?0:b(V);R[0]=j.pred+=fe;let ie=1;for(;ie<64;){let he=S(j.huffmanTableAC),we=he&15,$e=he>>4;if(we===0){if($e<15)break;ie+=16;continue}ie+=$e;let at=ei[ie];R[at]=b(we),ie++}}function x(j,R){let V=S(j.huffmanTableDC),fe=V===0?0:b(V)<<l;R[0]=j.pred+=fe}function _(j,R){R[0]|=p()<<l}let I=0;function P(j,R){if(I>0){I--;return}let V=r,fe=s;for(;V<=fe;){let ie=S(j.huffmanTableAC),he=ie&15,we=ie>>4;if(he===0){if(we<15){I=m(we)+(1<<we)-1;break}V+=16;continue}V+=we;let $e=ei[V];R[$e]=b(he)*(1<<l),V++}}let k=0,E=0;function O(j,R){let V=r,fe=s,ie=0;for(;V<=fe;){let he=ei[V],we=R[he]<0?-1:1;switch(k){case 0:let $e=S(j.huffmanTableAC),at=$e&15;if(ie=$e>>4,at===0)ie<15?(I=m(ie)+(1<<ie),k=4):(ie=16,k=1);else{if(at!==1)throw new Error("invalid ACn encoding");E=b(at),k=ie?2:3}continue;case 1:case 2:R[he]?R[he]+=(p()<<l)*we:(ie--,ie===0&&(k=k==2?3:0));break;case 3:R[he]?R[he]+=(p()<<l)*we:(R[he]=E<<l,k=0);break;case 4:R[he]&&(R[he]+=(p()<<l)*we);break}V++}k===4&&(I--,I===0&&(k=0))}function U(j,R,V,fe,ie){let he=V/c|0,we=V%c,$e=he*j.v+fe,at=we*j.h+ie;j.blocks[$e]!==void 0&&R(j,j.blocks[$e][at])}function M(j,R,V){let fe=V/j.blocksPerLine|0,ie=V%j.blocksPerLine;j.blocks[fe]!==void 0&&R(j,j.blocks[fe][ie])}let le=i.length,me,T;d?r===0?T=a===0?x:_:T=a===0?P:O:T=v;let W=0,te;le==1?te=i[0].blocksPerLine*i[0].blocksPerColumn:te=c*n.mcusPerColumn,o||(o=te);let ne,Pe,Ee;for(;W<te;){for(let j=0;j<le;j++)i[j].pred=0;if(I=0,le==1){me=i[0];for(let j=0;j<o;j++)M(me,T,W),W++}else for(let j=0;j<o;j++){for(let R=0;R<le;R++){me=i[R],ne=me.h,Pe=me.v;for(let V=0;V<Pe;V++)for(let fe=0;fe<ne;fe++)U(me,T,W,V,fe)}if(W++,W===te)break}if(W===te)do{if(e[t]===255&&e[t+1]!==0)break;t+=1}while(t<e.length-2);if(h=0,Ee=e[t]<<8|e[t+1],Ee<65280)throw new Error("marker was not found");if(Ee>=65488&&Ee<=65495)t+=2;else break}return t-u}function Pu(e){let t=[],n=e.blocksPerLine,i=e.blocksPerColumn,o=n<<3,r=new Int32Array(64),s=new Uint8Array(64);function a(l,c,d){let u=e.quantizationTable,f=d;for(let h=0;h<64;h++)f[h]=l[h]*u[h];for(let h=0;h<8;++h){let p=8*h;if(f[1+p]==0&&f[2+p]==0&&f[3+p]==0&&f[4+p]==0&&f[5+p]==0&&f[6+p]==0&&f[7+p]==0){let E=_n*f[0+p]+512>>10;f[0+p]=E,f[1+p]=E,f[2+p]=E,f[3+p]=E,f[4+p]=E,f[5+p]=E,f[6+p]=E,f[7+p]=E;continue}let S=_n*f[0+p]+128>>8,m=_n*f[4+p]+128>>8,b=f[2+p],v=f[6+p],x=Mi*(f[1+p]-f[7+p])+128>>8,_=Mi*(f[1+p]+f[7+p])+128>>8,I=f[3+p]<<4,P=f[5+p]<<4,k=S-m+1>>1;S=S+m+1>>1,m=k,k=b*Ri+v*Ui+128>>8,b=b*Ui-v*Ri+128>>8,v=k,k=x-P+1>>1,x=x+P+1>>1,P=k,k=_+I+1>>1,I=_-I+1>>1,_=k,k=S-v+1>>1,S=S+v+1>>1,v=k,k=m-b+1>>1,m=m+b+1>>1,b=k,k=x*Bi+_*Li+2048>>12,x=x*Li-_*Bi+2048>>12,_=k,k=I*Oi+P*Fi+2048>>12,I=I*Fi-P*Oi+2048>>12,P=k,f[0+p]=S+_,f[7+p]=S-_,f[1+p]=m+P,f[6+p]=m-P,f[2+p]=b+I,f[5+p]=b-I,f[3+p]=v+x,f[4+p]=v-x}for(let h=0;h<8;++h){let p=h;if(f[8+p]==0&&f[16+p]==0&&f[24+p]==0&&f[32+p]==0&&f[40+p]==0&&f[48+p]==0&&f[56+p]==0){let E=_n*d[h+0]+8192>>14;f[0+p]=E,f[8+p]=E,f[16+p]=E,f[24+p]=E,f[32+p]=E,f[40+p]=E,f[48+p]=E,f[56+p]=E;continue}let S=_n*f[0+p]+2048>>12,m=_n*f[32+p]+2048>>12,b=f[16+p],v=f[48+p],x=Mi*(f[8+p]-f[56+p])+2048>>12,_=Mi*(f[8+p]+f[56+p])+2048>>12,I=f[24+p],P=f[40+p],k=S-m+1>>1;S=S+m+1>>1,m=k,k=b*Ri+v*Ui+2048>>12,b=b*Ui-v*Ri+2048>>12,v=k,k=x-P+1>>1,x=x+P+1>>1,P=k,k=_+I+1>>1,I=_-I+1>>1,_=k,k=S-v+1>>1,S=S+v+1>>1,v=k,k=m-b+1>>1,m=m+b+1>>1,b=k,k=x*Bi+_*Li+2048>>12,x=x*Li-_*Bi+2048>>12,_=k,k=I*Oi+P*Fi+2048>>12,I=I*Fi-P*Oi+2048>>12,P=k,f[0+p]=S+_,f[56+p]=S-_,f[8+p]=m+P,f[48+p]=m-P,f[16+p]=b+I,f[40+p]=b-I,f[24+p]=v+x,f[32+p]=v-x}for(let h=0;h<64;++h){let p=128+(f[h]+8>>4);c[h]=p<0?0:p>255?255:p}}An(o*i*8);for(let l=0;l<i;l++){let c=l<<3;for(let d=0;d<8;d++)t.push(new Uint8Array(o));for(let d=0;d<n;d++){a(e.blocks[l][d],s,r);let u=0,f=d<<3;for(let h=0;h<8;h++){let p=t[c+h];for(let S=0;S<8;S++)p[f+S]=s[u++]}}}return t}function At(e){return e<0?0:e>255?255:e}function Eu(e){let t={width:0,height:0,adobe:void 0,components:[],exifBuffer:void 0,jfif:void 0},n=Iu*1e3*1e3,i=0;function o(){let b=e[i]<<8|e[i+1];return i+=2,b}function r(){let b=o(),v=e.subarray(i,i+b-2);return i+=v.length,v}function s(b){let v=0,x=0;for(let P in b.components)if(b.components.hasOwnProperty(P)){let k=b.components[P];v<k.h&&(v=k.h),x<k.v&&(x=k.v)}let _=Math.ceil(b.samplesPerLine/8/v),I=Math.ceil(b.scanLines/8/x);for(let P in b.components)if(b.components.hasOwnProperty(P)){let k=b.components[P],E=Math.ceil(Math.ceil(b.samplesPerLine/8)*k.h/v),O=Math.ceil(Math.ceil(b.scanLines/8)*k.v/x),U=_*k.h,M=I*k.v,le=M*U,me=[];An(le*256);for(let T=0;T<M;T++){let W=[];for(let te=0;te<U;te++)W.push(new Int32Array(64));me.push(W)}k.blocksPerLine=E,k.blocksPerColumn=O,k.blocks=me}b.maxH=v,b.maxV=x,b.mcusPerLine=_,b.mcusPerColumn=I}let a=null,l=null,c,d=0,u=[],f=[],h=[],p=[],S=o(),m=-1;if(S!=65496)throw new Error("SOI not found");for(S=o();S!=65497;){switch(S){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:{let b=r();S===65504&&b[0]===74&&b[1]===70&&b[2]===73&&b[3]===70&&b[4]===0&&(a={version:{major:b[5],minor:b[6]},densityUnits:b[7],xDensity:b[8]<<8|b[9],yDensity:b[10]<<8|b[11],thumbWidth:b[12],thumbHeight:b[13],thumbData:b.subarray(14,14+3*b[12]*b[13])}),S===65505&&b[0]===69&&b[1]===120&&b[2]===105&&b[3]===102&&b[4]===0&&(t.exifBuffer=b.subarray(5,b.length)),S===65518&&b[0]===65&&b[1]===100&&b[2]===111&&b[3]===98&&b[4]===101&&b[5]===0&&(l={version:b[6],flags0:b[7]<<8|b[8],flags1:b[9]<<8|b[10],transformCode:b[11]});break}case 65499:{let v=o()+i-2;for(;i<v;){let x=e[i++];An(256);let _=new Int32Array(64);if(x>>4===0)for(let I=0;I<64;I++){let P=ei[I];_[P]=e[i++]}else if(x>>4===1)for(let I=0;I<64;I++){let P=ei[I];_[P]=o()}else throw new Error("DQT: invalid table spec");u[x&15]=_}break}case 65472:case 65473:case 65474:{o(),c={extended:S===65473,progressive:S===65474,precision:e[i++],scanLines:o(),samplesPerLine:o(),components:{},componentsOrder:[],maxH:0,maxV:0,mcusPerLine:0,mcusPerColumn:0};let b=c.scanLines*c.samplesPerLine;if(b>n){let x=Math.ceil((b-n)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${x}MP`)}let v=e[i++];for(let x=0;x<v;x++){let _=e[i],I=e[i+1]>>4,P=e[i+1]&15,k=e[i+2];c.componentsOrder.push(_),c.components[_]={h:I,v:P,quantizationIdx:k,blocksPerColumn:0,blocksPerLine:0,blocks:[],pred:0},i+=3}s(c),f.push(c);break}case 65476:{let b=o();for(let v=2;v<b;){let x=e[i++],_=new Uint8Array(16),I=0;for(let O=0;O<16;O++,i++)I+=_[O]=e[i];An(16+I);let P=new Uint8Array(I);for(let O=0;O<I;O++,i++)P[O]=e[i];v+=17+I;let k=x&15,E=x>>4===0?p:h;E[k]=Du(_,P)}break}case 65501:o(),d=o();break;case 65500:o(),o();break;case 65498:{o();let b=e[i++],v=[];for(let k=0;k<b;k++){let E=c.components[e[i++]],O=e[i++];E.huffmanTableDC=p[O>>4],E.huffmanTableAC=h[O&15],v.push(E)}let x=e[i++],_=e[i++],I=e[i++],P=Cu(e,i,c,v,d,x,_,I>>4,I&15);i+=P;break}case 65535:e[i]!==255&&i--;break;default:{if(e[i-3]==255&&e[i-2]>=192&&e[i-2]<=254){i-=3;break}else if(S===224||S==225){if(m!==-1)throw new Error(`first unknown JPEG marker at offset ${m.toString(16)}, second unknown JPEG marker ${S.toString(16)} at offset ${(i-1).toString(16)}`);m=i-1;let b=o();if(e[i+b-2]===255){i+=b-2;break}}throw new Error("unknown JPEG marker "+S.toString(16))}}S=o()}if(f.length!=1)throw new Error("only single frame JPEGs supported");for(let b=0;b<f.length;b++){let v=f[b].components;for(let x in v)v[x].quantizationTable=u[v[x].quantizationIdx],delete v[x].quantizationIdx}t.width=c.samplesPerLine,t.height=c.scanLines,t.jfif=a,t.adobe=l,t.components=[];for(let b=0;b<c.componentsOrder.length;b++){let v=c.components[c.componentsOrder[b]];t.components.push({lines:Pu(v),scaleX:v.h/c.maxH,scaleY:v.v/c.maxV})}return t}function Fu(e){let t=0,n=!1,i=e.width,o=e.height,r=i*o*e.components.length;An(r);let s=new Uint8Array(r);switch(e.components.length){case 1:{let a=e.components[0];for(let l=0;l<o;l++){let c=a.lines[0|l*a.scaleY];for(let d=0;d<i;d++){let u=c[0|d*a.scaleX];s[t++]=u}}break}case 2:{let a=e.components[0],l=e.components[1];for(let c=0;c<o;c++){let d=a.lines[0|c*a.scaleY],u=l.lines[0|c*l.scaleY];for(let f=0;f<i;f++){let h=d[0|f*a.scaleX];s[t++]=h;let p=u[0|f*l.scaleX];s[t++]=p}}break}case 3:{n=!0,e.adobe&&e.adobe.transformCode&&(n=!0);let a=e.components[0],l=e.components[1],c=e.components[2];for(let d=0;d<o;d++){let u=a.lines[0|d*a.scaleY],f=l.lines[0|d*l.scaleY],h=c.lines[0|d*c.scaleY];for(let p=0;p<i;p++){let S,m,b,v,x,_;n?(S=u[0|p*a.scaleX],m=f[0|p*l.scaleX],b=h[0|p*c.scaleX],v=At(S+1.402*(b-128)),x=At(S-.3441363*(m-128)-.71413636*(b-128)),_=At(S+1.772*(m-128))):(v=u[0|p*a.scaleX],x=f[0|p*l.scaleX],_=h[0|p*c.scaleX]),s[t++]=v,s[t++]=x,s[t++]=_}}break}case 4:{if(!e.adobe)throw new Error("Unsupported color mode (4 components)");n=!1,e.adobe&&e.adobe.transformCode&&(n=!0);let a=e.components[0],l=e.components[1],c=e.components[2],d=e.components[3];for(let u=0;u<o;u++){let f=a.lines[0|u*a.scaleY],h=l.lines[0|u*l.scaleY],p=c.lines[0|u*c.scaleY],S=d.lines[0|u*d.scaleY];for(let m=0;m<i;m++){let b,v,x,_,I,P,k;n?(b=f[0|m*a.scaleX],v=h[0|m*l.scaleX],x=p[0|m*c.scaleX],_=S[0|m*d.scaleX],I=255-At(b+1.402*(x-128)),P=255-At(b-.3441363*(v-128)-.71413636*(x-128)),k=255-At(b+1.772*(v-128))):(I=f[0|m*a.scaleX],P=h[0|m*l.scaleX],k=p[0|m*c.scaleX],_=S[0|m*d.scaleX]),s[t++]=255-I,s[t++]=255-P,s[t++]=255-k,s[t++]=255-_}}break}default:throw new Error("Unsupported color mode")}return s}function Ou(e,t){if(ur=0,e.length===0)throw new Error("Empty jpeg buffer");let n=Eu(e);An(n.width*n.height*4);let i=Fu(n),o=t(n.width,n.height),r=o.width,s=o.height,a=o.data,l=0,c=0;switch(n.components.length){case 1:for(let d=0;d<s;d++)for(let u=0;u<r;u++){let f=i[l++];a[c++]=f,a[c++]=f,a[c++]=f,a[c++]=255}break;case 2:for(let d=0;d<s;d++)for(let u=0;u<r;u++){let f=i[l++],h=i[l++];a[c++]=f,a[c++]=f,a[c++]=f,a[c++]=h}break;case 3:for(let d=0;d<s;d++)for(let u=0;u<r;u++){let f=i[l++],h=i[l++],p=i[l++];a[c++]=f,a[c++]=h,a[c++]=p,a[c++]=255}break;case 4:for(let d=0;d<s;d++)for(let u=0;u<r;u++){let f=i[l++],h=i[l++],p=i[l++],S=i[l++],m=255-At(f*(1-S/255)+S),b=255-At(h*(1-S/255)+S),v=255-At(p*(1-S/255)+S);a[c++]=m,a[c++]=b,a[c++]=v,a[c++]=255}break;default:throw new Error("Unsupported color mode")}return o}});var Tt=oe(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.createImageData=G.createCanvas=G.MaskParams=G.LayerMaskFlags=G.ColorSpace=G.largeAdditionalInfoKeys=G.layerColors=G.toBlendMode=G.fromBlendMode=G.RAW_IMAGE_DATA=G.MOCK_HANDLERS=void 0;G.revMap=Va;G.createEnum=Uu;G.offsetForChannel=Ru;G.clamp=Mu;G.hasAlpha=Tu;G.resetImageData=ju;G.imageDataToCanvas=zu;G.decodeBitmap=$u;G.writeDataRaw=Nu;G.writeDataRLE=Vu;G.writeDataZipWithoutPrediction=Gu;G.createCanvasFromData=Hu;G.initializeCanvas=Zu;var Lu=fr(),Bu=ja();G.MOCK_HANDLERS=!1;G.RAW_IMAGE_DATA=!1;G.fromBlendMode={};G.toBlendMode={pass:"pass through",norm:"normal",diss:"dissolve",dark:"darken","mul ":"multiply",idiv:"color burn",lbrn:"linear burn",dkCl:"darker color",lite:"lighten",scrn:"screen","div ":"color dodge",lddg:"linear dodge",lgCl:"lighter color",over:"overlay",sLit:"soft light",hLit:"hard light",vLit:"vivid light",lLit:"linear light",pLit:"pin light",hMix:"hard mix",diff:"difference",smud:"exclusion",fsub:"subtract",fdiv:"divide","hue ":"hue","sat ":"saturation",colr:"color","lum ":"luminosity"};Object.keys(G.toBlendMode).forEach(e=>G.fromBlendMode[G.toBlendMode[e]]=e);G.layerColors=["none","red","orange","yellow","green","blue","violet","gray"];G.largeAdditionalInfoKeys=["LMsk","Lr16","Lr32","Layr","Mt16","Mt32","Mtrn","Alph","FMsk","lnk2","FEid","FXid","PxSD","cinf"];function Va(e){let t={};return Object.keys(e).forEach(n=>t[e[n]]=n),t}function Uu(e,t,n){let i=Va(n);return{decode:s=>{let a=s.split(".")[1];if(a&&!i[a]){if(Object.prototype.hasOwnProperty.call(n,a))return a;let l=a.replace(/([A-Z])/g," $1").toLowerCase();if(Object.prototype.hasOwnProperty.call(n,l))return l;throw new Error(`Unrecognized value for enum: '${s}'`)}return i[a]||t},encode:s=>{if(s&&!n[s])throw new Error(`Invalid value for enum: '${s}'`);return`${e}.${s?n[s]:n[t]}`}}}var za;(function(e){e[e.RGB=0]="RGB",e[e.HSB=1]="HSB",e[e.CMYK=2]="CMYK",e[e.Lab=7]="Lab",e[e.Grayscale=8]="Grayscale"})(za||(G.ColorSpace=za={}));var $a;(function(e){e[e.PositionRelativeToLayer=1]="PositionRelativeToLayer",e[e.LayerMaskDisabled=2]="LayerMaskDisabled",e[e.InvertLayerMaskWhenBlending=4]="InvertLayerMaskWhenBlending",e[e.LayerMaskFromRenderingOtherData=8]="LayerMaskFromRenderingOtherData",e[e.MaskHasParametersAppliedToIt=16]="MaskHasParametersAppliedToIt"})($a||(G.LayerMaskFlags=$a={}));var Na;(function(e){e[e.UserMaskDensity=1]="UserMaskDensity",e[e.UserMaskFeather=2]="UserMaskFeather",e[e.VectorMaskDensity=4]="VectorMaskDensity",e[e.VectorMaskFeather=8]="VectorMaskFeather"})(Na||(G.MaskParams=Na={}));function Ru(e,t){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return t?3:e+1;case-1:return t?4:3;default:return e+1}}function Mu(e,t,n){return e<t?t:e>n?n:e}function Tu(e){let t=e.width*e.height*4;for(let n=3;n<t;n+=4)if(e.data[n]!==255)return!0;return!1}function ju({data:e}){let t=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255;for(let n=0,i=e.length|0;n<i;n=n+4|0)e[n+0]=0,e[n+1]=0,e[n+2]=0,e[n+3]=t}function zu(e){let t=(0,G.createCanvas)(e.width,e.height),n;if(e.data instanceof Uint8ClampedArray)n=e;else{n=(0,G.createImageData)(e.width,e.height);let i=e.data,o=n.data;if(i instanceof Float32Array)for(let r=0,s=i.length;r<s;r+=4)o[r+0]=Math.round(Math.pow(i[r+0],1/2.2)*255),o[r+1]=Math.round(Math.pow(i[r+1],1/2.2)*255),o[r+2]=Math.round(Math.pow(i[r+2],1/2.2)*255),o[r+3]=Math.round(i[r+3]*255);else{let r=i instanceof Uint16Array?8:0;for(let s=0,a=i.length;s<a;s++)o[s]=i[s]>>>r}}return t.getContext("2d").putImageData(n,0,0),t}function $u(e,t,n,i){if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray))throw new Error("Invalid bit depth");for(let o=0,r=0,s=0;o<i;o++)for(let a=0;a<n;){let l=e[s++];for(let c=0;c<8&&a<n;c++,a++,r+=4){let d=l&128?0:255;l=l<<1,t[r+0]=d,t[r+1]=d,t[r+2]=d,t[r+3]=255}}}function Nu(e,t,n,i){if(!n||!i)return;let o=new Uint8Array(n*i);for(let r=0;r<o.length;r++)o[r]=e.data[r*4+t];return o}function Vu(e,{data:t,width:n,height:i},o,r){if(!n||!i)return;let s=4*n|0,a=0,l=o.length*(r?4:2)*i|0;for(let c of o)for(let d=0,u=c|0;d<i;d++){let f=d*s|0,h=f+s|0,p=h+c-4|0,S=p-4|0,m=l;for(u=f+c|0;u<h;u=u+4|0)if(u<S){let v=t[u];u=u+4|0;let x=t[u];u=u+4|0;let _=t[u];if(v===x&&v===_){let I=3;for(;I<128&&u<p&&t[u+4|0]===v;)I=I+1|0,u=u+4|0;e[l++]=1-I,e[l++]=v}else{let I=l,P=!0,k=1;for(e[l++]=0,e[l++]=v;u<p&&k<128;)if(u=u+4|0,v=x,x=_,_=t[u],v===x&&v===_){u=u-12|0,P=!1;break}else k++,e[l++]=v;P&&(k<127?(e[l++]=x,e[l++]=_,k+=2):k<128?(e[l++]=x,k++,u=u-4|0):u=u-8|0),e[I]=k-1}}else u===p?(e[l++]=0,e[l++]=t[u]):(e[l++]=1,e[l++]=t[u],u=u+4|0,e[l++]=t[u]);let b=l-m;r&&(e[a++]=b>>24&255,e[a++]=b>>16&255),e[a++]=b>>8&255,e[a++]=b&255}return e.slice(0,l)}function Gu({data:e,width:t,height:n},i){let o=t*n,r=new Uint8Array(o),s=[],a=0;for(let l of i){for(let d=0,u=l;d<o;d++,u+=4)r[d]=e[u];let c=(0,Lu.deflate)(r);s.push(c),a+=c.byteLength}if(s.length>0){let l=new Uint8Array(a),c=0;for(let d of s)l.set(d,c),c+=d.byteLength;return l}else return s[0]}function Hu(e){let t=(0,G.createCanvas)(100,100);try{let n=t.getContext("2d"),i=(0,Bu.decodeJpeg)(e,(o,r)=>n.createImageData(o,r));t.width=i.width,t.height=i.height,n.putImageData(i,0,0)}catch(n){console.error("JPEG decompression error",n.message)}return t}var Wu=()=>{throw new Error("Canvas not initialized, use initializeCanvas method to set up createCanvas method")};G.createCanvas=Wu;var pr,Xu=(e,t)=>(pr||(pr=(0,G.createCanvas)(1,1)),pr.getContext("2d").createImageData(e,t));G.createImageData=Xu;typeof document<"u"&&(G.createCanvas=(e,t)=>{let n=document.createElement("canvas");return n.width=e,n.height=t,n});function Zu(e,t){G.createCanvas=e,G.createImageData=t||G.createImageData}});var ji=oe(Ti=>{"use strict";Ti.byteLength=Ku;Ti.toByteArray=Ju;Ti.fromByteArray=th;var mt=[],Ye=[],qu=typeof Uint8Array<"u"?Uint8Array:Array,mr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Qt=0,Ga=mr.length;Qt<Ga;++Qt)mt[Qt]=mr[Qt],Ye[mr.charCodeAt(Qt)]=Qt;var Qt,Ga;Ye[45]=62;Ye[95]=63;function Ha(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");n===-1&&(n=t);var i=n===t?0:4-n%4;return[n,i]}function Ku(e){var t=Ha(e),n=t[0],i=t[1];return(n+i)*3/4-i}function Yu(e,t,n){return(t+n)*3/4-n}function Ju(e){var t,n=Ha(e),i=n[0],o=n[1],r=new qu(Yu(e,i,o)),s=0,a=o>0?i-4:i,l;for(l=0;l<a;l+=4)t=Ye[e.charCodeAt(l)]<<18|Ye[e.charCodeAt(l+1)]<<12|Ye[e.charCodeAt(l+2)]<<6|Ye[e.charCodeAt(l+3)],r[s++]=t>>16&255,r[s++]=t>>8&255,r[s++]=t&255;return o===2&&(t=Ye[e.charCodeAt(l)]<<2|Ye[e.charCodeAt(l+1)]>>4,r[s++]=t&255),o===1&&(t=Ye[e.charCodeAt(l)]<<10|Ye[e.charCodeAt(l+1)]<<4|Ye[e.charCodeAt(l+2)]>>2,r[s++]=t>>8&255,r[s++]=t&255),r}function Qu(e){return mt[e>>18&63]+mt[e>>12&63]+mt[e>>6&63]+mt[e&63]}function eh(e,t,n){for(var i,o=[],r=t;r<n;r+=3)i=(e[r]<<16&16711680)+(e[r+1]<<8&65280)+(e[r+2]&255),o.push(Qu(i));return o.join("")}function th(e){for(var t,n=e.length,i=n%3,o=[],r=16383,s=0,a=n-i;s<a;s+=r)o.push(eh(e,s,s+r>a?a:s+r));return i===1?(t=e[n-1],o.push(mt[t>>2]+mt[t<<4&63]+"==")):i===2&&(t=(e[n-2]<<8)+e[n-1],o.push(mt[t>>10]+mt[t>>4&63]+mt[t<<2&63]+"=")),o.join("")}});var Ka=oe(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.stringLengthInBytes=Za;kn.encodeStringTo=qa;kn.encodeString=ih;kn.decodeString=oh;function Wa(e){return(e&4294967168)===0?1:(e&4294965248)===0?2:(e&4294901760)===0?3:4}function Xa(e,t){let n=e.charCodeAt(t);if(n>=55296&&n<=56319&&t+1<e.length){let i=e.charCodeAt(t+1);if(i>=56320&&i<=57343)return{code:((n&1023)<<10)+(i&1023)+65536,size:2}}return n>=55296&&n<=57343?{code:65533,size:1}:{code:n,size:1}}function Za(e){let t=0;for(let n=0;n<e.length;){let{code:i,size:o}=Xa(e,n);t+=Wa(i),n+=o}return t}function nh(e,t,n){let i=Wa(n);switch(i){case 1:e[t]=n;break;case 2:e[t]=n>>6&31|192,e[t+1]=n&63|128;break;case 3:e[t]=n>>12&15|224,e[t+1]=n>>6&63|128,e[t+2]=n&63|128;break;default:e[t]=n>>18&7|240,e[t+1]=n>>12&63|128,e[t+2]=n>>6&63|128,e[t+3]=n&63|128;break}return i}function qa(e,t,n){for(let i=0;i<n.length;){let{code:o,size:r}=Xa(n,i);t+=nh(e,t,o),i+=r}return t}function ih(e){if(e.length>1e3&&typeof TextEncoder<"u")return new TextEncoder().encode(e);let t=new Uint8Array(Za(e));return qa(t,0,e),t}function oh(e){if(e.byteLength>1e3&&typeof TextDecoder<"u")return new TextDecoder().decode(e);let t=[];function n(l){l>65535&&(l-=65536,t.push(String.fromCharCode(l>>>10&1023|55296)),l=56320|l&1023),t.push(String.fromCharCode(l))}let i=0,o=0,r=0,s=128,a=191;for(let l=0;l<e.length;l++){let c=e[l];if(r===0){c<=127?n(c):c>=194&&c<=223?(r=1,i=c&31):c>=224&&c<=239?(c===224&&(s=160),c===237&&(a=159),r=2,i=c&15):c>=240&&c<=244?(c===240&&(s=144),c===244&&(a=143),r=3,i=c&7):n(65533);continue}if(c<s||c>a){i=0,r=0,o=0,s=128,a=191,n(65533),l--;continue}s=128,a=191,i=i<<6|c&63,o++,o===r&&(n(i),i=0,r=0,o=0)}return r!==0&&n(65533),t.join("")}});var Gi=oe(A=>{"use strict";var rh=A&&A.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]]);return n};Object.defineProperty(A,"__esModule",{value:!0});A.IntC=A.IntE=A.Drct=A.WndM=A.CntE=A.FlCl=A.ExtR=A.ExtT=A.DfsM=A.blurType=A.Lns=A.MztT=A.Chnl=A.Dstr=A.ZZTy=A.Wvtp=A.SphM=A.RplS=A.Cnvr=A.UndA=A.DspM=A.SmBQ=A.SmBM=A.BlrQ=A.BlrM=A.strokeStyleLineAlignment=A.strokeStyleLineJoinType=A.strokeStyleLineCapType=A.ESliceBGColorType=A.ESliceOrigin=A.ESliceVertAlign=A.ESliceHorzAlign=A.ESliceType=A.FrFl=A.FStl=A.ClrS=A.gradientInterpolationMethodType=A.stdTrackID=A.animInterpStyleEnum=A.GrdT=A.IGSr=A.BETE=A.BESs=A.bvlT=A.BESl=A.BlnM=A.warpStyle=A.Annt=A.Ornt=A.textGridding=void 0;A.presetKindType=A.prjM=A.FlMd=void 0;A.setLogErrors=ah;A.readAsciiStringOrClassId=gt;A.readDescriptorStructure=yr;A.writeDescriptorStructure=wr;A.readVersionAndDescriptor=hh;A.writeVersionAndDescriptor=ph;A.horzVrtcToXY=$i;A.xyToHorzVrtc=Ni;A.descBoundsToBounds=mh;A.boundsToDescBounds=gh;A.serializeEffects=ll;A.parseEffects=cl;A.parseTrackList=bh;A.serializeTrackList=yh;A.parseVectorContent=wh;A.serializeVectorContent=Sh;A.parseColor=tn;A.serializeColor=nn;A.parseAngle=ii;A.parsePercent=_e;A.parsePercentOrAngle=gl;A.parseUnits=it;A.parseUnitsOrNumber=vh;A.parseUnitsToNumber=xh;A.unitsAngle=In;A.unitsPercent=ke;A.unitsPercentF=br;A.unitsValue=bt;A.frac=_h;var $=Tt(),K=jt(),J=Dn();function sh(e){let t={};return Object.keys(e).forEach(n=>t[e[n]]=n),t}var ti={"#Ang":"Angle","#Rsl":"Density","#Rlt":"Distance","#Nne":"None","#Prc":"Percent","#Pxl":"Pixels","#Mlm":"Millimeters","#Pnt":"Points",RrPi:"Picas",RrIn:"Inches",RrCm:"Centimeters"},zi=sh(ti),ni=!1;function ah(e){ni=e}function F(e,t){return{name:e,classID:t}}var Y=F("","null"),gr=!1,il={strokeStyleContent:F("","solidColorLayer"),printProofSetup:F(gr?"\u6821\u6837\u8BBE\u7F6E":"Proof Setup","proofSetup"),Grad:F(gr?"\u6E10\u53D8":"Gradient","Grdn"),Trnf:F(gr?"\u53D8\u6362":"Transform","Trnf"),patternFill:F("","patternFill"),ebbl:F("","ebbl"),SoFi:F("","SoFi"),GrFl:F("","GrFl"),sdwC:F("","RGBC"),hglC:F("","RGBC"),"Clr ":F("","RGBC"),tintColor:F("","RGBC"),Ofst:F("","Pnt "),ChFX:F("","ChFX"),MpgS:F("","ShpC"),DrSh:F("","DrSh"),IrSh:F("","IrSh"),OrGl:F("","OrGl"),IrGl:F("","IrGl"),TrnS:F("","ShpC"),Ptrn:F("","Ptrn"),FrFX:F("","FrFX"),phase:F("","Pnt "),frameStep:Y,duration:Y,workInTime:Y,workOutTime:Y,audioClipGroupList:Y,bounds:F("","Rctn"),customEnvelopeWarp:F("","customEnvelopeWarp"),warp:F("","warp"),"Sz ":F("","Pnt "),origin:F("","Pnt "),autoExpandOffset:F("","Pnt "),keyOriginShapeBBox:F("","unitRect"),Vrsn:Y,psVersion:Y,docDefaultNewArtboardBackgroundColor:F("","RGBC"),artboardRect:F("","classFloatRect"),keyOriginRRectRadii:F("","radii"),keyOriginBoxCorners:Y,rectangleCornerA:F("","Pnt "),rectangleCornerB:F("","Pnt "),rectangleCornerC:F("","Pnt "),rectangleCornerD:F("","Pnt "),compInfo:Y,quiltWarp:F("","quiltWarp"),generatorSettings:Y,crema:Y,FrIn:Y,blendOptions:Y,FXRf:Y,Lefx:Y,time:Y,animKey:Y,timeScope:Y,inTime:Y,outTime:Y,sheetStyle:Y,translation:Y,Skew:Y,boundingBox:F("","boundingBox"),"Lnk ":F("","ExternalFileLink"),frameReader:F("","FrameReader"),effectParams:F("","motionTrackEffectParams"),Impr:F("None","none"),Anch:F("","Pnt "),"Fwd ":F("","Pnt "),"Bwd ":F("","Pnt "),FlrC:F("","Pnt "),meshBoundaryPath:F("","pathClass"),filterFX:F("","filterFXStyle"),Fltr:F("","rigidTransform"),FrgC:F("","RGBC"),BckC:F("","RGBC"),sdwM:F("Parameters","adaptCorrectTones"),hglM:F("Parameters","adaptCorrectTones"),customShape:F("","customShape"),origFXRefPoint:Y,FXRefPoint:Y,ClMg:F("","ClMg")},ol={"Crv ":F("","CrPt"),Clrs:F("","Clrt"),Trns:F("","TrnS"),keyDescriptorList:Y,solidFillMulti:F("","SoFi"),gradientFillMulti:F("","GrFl"),dropShadowMulti:F("","DrSh"),innerShadowMulti:F("","IrSh"),frameFXMulti:F("","FrFX"),FrIn:Y,FSts:Y,LaSt:Y,sheetTimelineOptions:Y,trackList:F("","animationTrack"),globalTrackList:F("","animationTrack"),keyList:Y,audioClipGroupList:Y,audioClipList:Y,countObjectList:F("","countObject"),countGroupList:F("","countGroup"),slices:F("","slice"),"Pts ":F("","Pthp"),SbpL:F("","SbpL"),pathComponents:F("","PaCm"),filterFXList:F("","filterFX"),puppetShapeList:F("","puppetShape"),channelDenoise:F("","channelDenoiseParams"),ShrP:F("","Pnt "),layerSettings:Y,list:Y,Adjs:F("","CrvA")},Ya={TEXT:["Txt ","printerName","Nm ","Idnt","blackAndWhitePresetFileName","LUT3DFileName","presetFileName","curvesPresetFileName","mixerPresetFileName","placed","description","reason","artboardPresetName","json","clipID","relPath","fullPath","mediaDescriptor","Msge","altTag","url","cellText","preset","KnNm","FPth","comment","originalPath"],tdta:["EngineData","LUT3DFileData","indexArray","originalVertexArray","deformedVertexArray","LqMe"],long:["TextIndex","RndS","Mdpn","Smth","Lctn","strokeStyleVersion","LaID","Vrsn","Cnt ","Brgh","Cntr","means","vibrance","Strt","bwPresetKind","comp","compID","originalCompID","curvesPresetKind","mixerPresetKind","uOrder","vOrder","PgNm","totalPages","Crop","numerator","denominator","frameCount","Annt","keyOriginType","unitValueQuadVersion","keyOriginIndex","major","minor","fix","docDefaultNewArtboardBackgroundType","artboardBackgroundType","numModifyingFX","deformNumRows","deformNumCols","FrID","FrDl","FsID","LCnt","AFrm","AFSt","numBefore","numAfter","Spcn","minOpacity","maxOpacity","BlnM","sheetID","gblA","globalAltitude","descVersion","frameReaderType","LyrI","zoomOrigin","fontSize","Rds ","sliceID","topOutset","leftOutset","bottomOutset","rightOutset","filterID","meshQuality","meshExpansion","meshRigidity","VrsM","VrsN","NmbG","WLMn","WLMx","AmMn","AmMx","SclH","SclV","Lvl ","TlNm","TlOf","FlRs","Thsh","ShrS","ShrE","FlRs","Vrnc","Strg","ExtS","ExtD","HrzS","VrtS","NmbR","EdgF","Ang1","Ang2","Ang3","Ang4","lastAppliedComp","capturedInfo"],enum:["textGridding","Ornt","warpStyle","warpRotate","Inte","Bltn","ClrS","BlrQ","bvlT","bvlS","bvlD","Md ","glwS","GrdF","GlwT","RplS","BlrM","SmBM","strokeStyleLineCapType","strokeStyleLineJoinType","strokeStyleLineAlignment","strokeStyleBlendMode","PntT","Styl","lookupType","LUTFormat","dataOrder","tableOrder","enableCompCore","enableCompCoreGPU","compCoreSupport","compCoreGPUSupport","Engn","enableCompCoreThreads","gs99","FrDs","trackID","animInterpStyle","horzAlign","vertAlign","bgColorType","shapeOperation","UndA","Wvtp","Drct","WndM","Edg ","FlCl","IntE","IntC","Cnvr","Fl ","Dstr","MztT","Lns ","ExtT","DspM","ExtR","ZZTy","SphM","SmBQ","placedLayerOCIOConversion","gradientsInterpolationMethod"],bool:["PstS","printSixteenBit","masterFXSwitch","enab","uglg","antialiasGloss","useShape","useTexture","uglg","antialiasGloss","useShape","Vsbl","useTexture","Algn","Rvrs","Dthr","Invr","VctC","ShTr","layerConceals","strokeEnabled","fillEnabled","strokeStyleScaleLock","strokeStyleStrokeAdjust","hardProof","MpBl","paperWhite","useLegacy","Auto","Lab ","useTint","keyShapeInvalidated","autoExpandEnabled","autoNestEnabled","autoPositionEnabled","shrinkwrapOnSaveEnabled","present","showInDialog","overprint","sheetDisclosed","lightsDisclosed","meshesDisclosed","materialsDisclosed","hasMotion","muted","Effc","selected","autoScope","fillCanvas","cellTextIsHTML","Smoo","Clsp","validAtPosition","rigidType","hasoptions","filterMaskEnable","filterMaskLinked","filterMaskExtendWithWhite","removeJPEGArtifact","Mnch","ExtF","ExtM","moreAccurate","GpuY","LIWy","Cnty"],doub:["warpValue","warpPerspective","warpPerspectiveOther","Intr","Wdth","Hght","strokeStyleMiterLimit","strokeStyleResolution","layerTime","keyOriginResolution","xx","xy","yx","yy","tx","ty","FrGA","frameRate","audioLevel","rotation","X ","Y ","redFloat","greenFloat","blueFloat","imageResolution","PuX0","PuX1","PuX2","PuX3","PuY0","PuY1","PuY2","PuY3"],UntF:["sdwO","hglO","lagl","Lald","srgR","blur","Sftn","Opct","Dstn","Angl","Ckmt","Nose","Inpr","ShdN","strokeStyleLineWidth","strokeStyleLineDashOffset","strokeStyleOpacity","H ","Top ","Left","Btom","Rght","Rslt","topRight","topLeft","bottomLeft","bottomRight","ClNs","Shrp"],VlLs:["Crv ","Clrs","Mnm ","Mxm ","Trns","pathList","strokeStyleLineDashSet","FrLs","slices","LaSt","Trnf","nonAffineTransform","keyDescriptorList","guideIndeces","gradientFillMulti","solidFillMulti","frameFXMulti","innerShadowMulti","dropShadowMulti","FrIn","FSts","FsFr","sheetTimelineOptions","audioClipList","trackList","globalTrackList","keyList","audioClipList","warpValues","selectedPin","Pts ","SbpL","pathComponents","pinOffsets","posFinalPins","pinVertexIndices","PinP","PnRt","PnOv","PnDp","filterFXList","puppetShapeList","ShrP","channelDenoise","Mtrx","layerSettings","list","compList","Adjs"],ObAr:["meshPoints","quiltSliceX","quiltSliceY"],"obj ":["null","Chnl"],"Pth ":["DspF"]},lh=["Rd ","Grn ","Bl ","Yllw","Ylw ","Cyn ","Mgnt","Blck","Gry ","Lmnc","A ","B "],rl={"Mnm ":"long","Mxm ":"long",FrLs:"long",strokeStyleLineDashSet:"UntF",Trnf:"doub",nonAffineTransform:"doub",keyDescriptorList:"Objc",gradientFillMulti:"Objc",solidFillMulti:"Objc",frameFXMulti:"Objc",innerShadowMulti:"Objc",dropShadowMulti:"Objc",LaSt:"Objc",FrIn:"Objc",FSts:"Objc",FsFr:"long",blendOptions:"Objc",sheetTimelineOptions:"Objc",keyList:"Objc",warpValues:"doub",selectedPin:"long","Pts ":"Objc",SbpL:"Objc",pathComponents:"Objc",pinOffsets:"doub",posFinalPins:"doub",pinVertexIndices:"long",PinP:"doub",PnRt:"long",PnOv:"bool",PnDp:"doub",filterFXList:"Objc",puppetShapeList:"Objc",ShrP:"Objc",channelDenoise:"Objc",Mtrx:"long",compList:"long",Chnl:"enum"},Vi={};for(let e of Object.keys(Ya))for(let t of Ya[e])Vi[t]=e;for(let e of Object.keys(il))Vi[e]||(Vi[e]="Objc");for(let e of Object.keys(ol))rl[e]="Objc";function ch(e,t,n,i){return e==="presetKind"?typeof t=="string"?"enum":"long":e==="null"&&n==="slices"?"TEXT":e==="groupID"?n==="slices"?"long":"TEXT":e==="Sz "?"Wdth"in t?"Objc":"units"in t?"UntF":"doub":e==="Type"?typeof t=="string"?"enum":"long":e==="AntA"?typeof t=="string"?"enum":"bool":(e==="Hrzn"||e==="Vrtc")&&(i.Type==="keyType.Pstn"||i._classID==="Ofst")?"long":e==="Hrzn"||e==="Vrtc"||e==="Top "||e==="Left"||e==="Btom"||e==="Rght"?n==="slices"?"long":typeof t=="number"?"doub":"UntF":e==="Vrsn"?typeof t=="number"?"long":"Objc":e==="Rd "||e==="Grn "||e==="Bl "?n==="artd"?"long":"doub":e==="Trnf"?Array.isArray(t)?"VlLs":"Objc":Vi[e]}function gt(e){let t=(0,K.readInt32)(e);return(0,K.readAsciiString)(e,t||4)}function kt(e,t){if(t.length===4&&t!=="warp"&&t!=="time"&&t!=="hold"&&t!=="list")(0,J.writeInt32)(e,0),(0,J.writeSignature)(e,t);else{(0,J.writeInt32)(e,t.length);for(let n=0;n<t.length;n++)(0,J.writeUint8)(e,t.charCodeAt(n))}}function yr(e,t){let n=en(e),i=t?{_name:n.name,_classID:n.classID}:{},o=(0,K.readUint32)(e);for(let r=0;r<o;r++){let s=gt(e),a=(0,K.readSignature)(e),l=sl(e,a,t);i[s]=l}return i}function wr(e,t,n,i,o){ni&&!n&&console.log("Missing classId for: ",t,n,i),(0,J.writeUnicodeStringWithPadding)(e,t),kt(e,n);let r=Object.keys(i),s=r.length;"_name"in i&&s--,"_classID"in i&&s--,(0,J.writeUint32)(e,s);for(let a of r){if(a==="_name"||a==="_classID")continue;let l=ch(a,i[a],o,i),c=il[a];a==="bounds"&&o==="text"?c=F("","bounds"):a==="origin"?l=o==="slices"?"enum":"Objc":(a==="Cyn "||a==="Mgnt"||a==="Ylw "||a==="Blck")&&i._classID==="CMYC"?l="doub":/^PN[a-z][a-z]$/.test(a)?l="TEXT":/^PT[a-z][a-z]$/.test(a)?l="long":/^PF[a-z][a-z]$/.test(a)||(a==="Rds "||a==="Thsh")&&typeof i[a]=="number"&&i._classID==="SmrB"?l="doub":a==="ClSz"||a==="Rds "||a==="Amnt"?l=typeof i[a]=="number"?"long":"UntF":(a==="sdwM"||a==="hglM")&&typeof i[a]=="string"||a==="blur"&&typeof i[a]=="string"?l="enum":a==="Hght"&&typeof i[a]=="number"&&i._classID==="Embs"||a==="Angl"&&typeof i[a]=="number"&&(i._classID==="Embs"||i._classID==="smartSharpen"||i._classID==="Twrl"||i._classID==="MtnB")?l="long":a==="Angl"&&typeof i[a]=="number"?l="doub":a==="bounds"&&o==="slices"?(l="Objc",c=F("","Rct1")):a==="Scl "?typeof i[a]=="object"&&"Hrzn"in i[a]?(l="Objc",c=Y):typeof i[a]=="number"?l="long":l="UntF":a==="audioClipGroupList"&&r.length===1?l="VlLs":(a==="Strt"||a==="Brgh")&&"H "in i?l="doub":a==="Wdth"&&typeof i[a]=="object"?l="UntF":a==="Ofst"&&typeof i[a]=="number"?l="long":a==="Strt"&&typeof i[a]=="object"?(l="Objc",c=Y):lh.indexOf(a)!==-1?l=n==="RGBC"&&o!=="artd"?"doub":"long":a==="profile"?l=n==="printOutput"?"TEXT":"tdta":a==="strokeStyleContent"?i[a]["Clr "]?c=F("","solidColorLayer"):i[a].Grad?c=F("","gradientLayer"):i[a].Ptrn?c=F("","patternLayer"):ni&&console.log("Invalid strokeStyleContent value",i[a]):a==="bounds"&&o==="quiltWarp"&&(c=F("","classFloatRect")),c&&c.classID==="RGBC"&&"H "in i[a]&&(c={classID:"HSBC",name:""}),kt(e,a),(0,J.writeSignature)(e,l||"long"),al(e,l||"long",i[a],a,c,o),ni&&!l&&console.log(`Missing descriptor field type for: '${a}' in`,i)}}function sl(e,t,n){switch(t){case"obj ":return fh(e);case"Objc":case"GlbO":return yr(e,n);case"VlLs":{let i=(0,K.readInt32)(e),o=[];for(let r=0;r<i;r++){let s=(0,K.readSignature)(e);o.push(sl(e,s,n))}return o}case"doub":return(0,K.readFloat64)(e);case"UntF":{let i=(0,K.readSignature)(e),o=(0,K.readFloat64)(e);if(!ti[i])throw new Error(`Invalid units: ${i}`);return{units:ti[i],value:o}}case"UnFl":{let i=(0,K.readSignature)(e),o=(0,K.readFloat32)(e);if(!ti[i])throw new Error(`Invalid units: ${i}`);return{units:ti[i],value:o}}case"TEXT":return(0,K.readUnicodeString)(e);case"enum":{let i=gt(e),o=gt(e);return`${i}.${o}`}case"long":return(0,K.readInt32)(e);case"comp":{let i=(0,K.readUint32)(e),o=(0,K.readUint32)(e);return{low:i,high:o}}case"bool":return!!(0,K.readUint8)(e);case"type":case"GlbC":return en(e);case"alis":{let i=(0,K.readInt32)(e);return(0,K.readAsciiString)(e,i)}case"tdta":{let i=(0,K.readInt32)(e);return(0,K.readBytes)(e,i)}case"ObAr":{(0,K.readInt32)(e),(0,K.readUnicodeString)(e),gt(e);let i=(0,K.readInt32)(e),o=[];for(let r=0;r<i;r++){let s=gt(e);(0,K.readSignature)(e),(0,K.readSignature)(e);let a=(0,K.readInt32)(e),l=[];for(let c=0;c<a;c++)l.push((0,K.readFloat64)(e));o.push({type:s,values:l})}return o}case"Pth ":{(0,K.readInt32)(e);let i=(0,K.readSignature)(e);(0,K.readInt32LE)(e);let o=(0,K.readInt32LE)(e),r=(0,K.readUnicodeStringWithLengthLE)(e,o);return{sig:i,path:r}}default:throw new Error(`Invalid TySh descriptor OSType: ${t} at ${e.offset.toString(16)}`)}}var dh={meshPoints:"rationalPoint",quiltSliceX:"UntF",quiltSliceY:"UntF"};function al(e,t,n,i,o,r){switch(t){case"obj ":uh(e,i,n);break;case"Objc":case"GlbO":{if(typeof n!="object")throw new Error(`Invalid struct value: ${JSON.stringify(n)}, key: ${i}`);if(!o)throw new Error(`Missing ext type for: '${i}' (${JSON.stringify(n)})`);let s=n._name||o.name,a=n._classID||o.classID;wr(e,s,a,n,r);break}case"VlLs":if(!Array.isArray(n))throw new Error(`Invalid list value: ${JSON.stringify(n)}, key: ${i}`);(0,J.writeInt32)(e,n.length);for(let s=0;s<n.length;s++){let a=rl[i];(0,J.writeSignature)(e,a||"long"),al(e,a||"long",n[s],`${i}[]`,ol[i],r),ni&&!a&&console.log(`Missing descriptor array type for: '${i}' in`,n)}break;case"doub":if(typeof n!="number")throw new Error(`Invalid number value: ${JSON.stringify(n)}, key: ${i}`);(0,J.writeFloat64)(e,n);break;case"UntF":if(!zi[n.units])throw new Error(`Invalid units: ${n.units} in ${i}`);(0,J.writeSignature)(e,zi[n.units]),(0,J.writeFloat64)(e,n.value);break;case"UnFl":if(!zi[n.units])throw new Error(`Invalid units: ${n.units} in ${i}`);(0,J.writeSignature)(e,zi[n.units]),(0,J.writeFloat32)(e,n.value);break;case"TEXT":(0,J.writeUnicodeStringWithPadding)(e,n);break;case"enum":{if(typeof n!="string")throw new Error(`Invalid enum value: ${JSON.stringify(n)}, key: ${i}`);let[s,a]=n.split(".");kt(e,s),kt(e,a);break}case"long":if(typeof n!="number")throw new Error(`Invalid integer value: ${JSON.stringify(n)}, key: ${i}`);(0,J.writeInt32)(e,n);break;case"bool":if(typeof n!="boolean")throw new Error(`Invalid boolean value: ${JSON.stringify(n)}, key: ${i}`);(0,J.writeUint8)(e,n?1:0);break;case"tdta":(0,J.writeInt32)(e,n.byteLength),(0,J.writeBytes)(e,n);break;case"ObAr":{(0,J.writeInt32)(e,16),(0,J.writeUnicodeStringWithPadding)(e,"");let s=dh[i];if(!s)throw new Error(`Not implemented ObArType for: ${i}`);kt(e,s),(0,J.writeInt32)(e,n.length);for(let a=0;a<n.length;a++){kt(e,n[a].type),(0,J.writeSignature)(e,"UnFl"),(0,J.writeSignature)(e,"#Pxl"),(0,J.writeInt32)(e,n[a].values.length);for(let l=0;l<n[a].values.length;l++)(0,J.writeFloat64)(e,n[a].values[l])}break}case"Pth ":{let s=12+n.path.length*2;(0,J.writeInt32)(e,s),(0,J.writeSignature)(e,n.sig),(0,J.writeInt32LE)(e,s),(0,J.writeInt32LE)(e,n.path.length),(0,J.writeUnicodeStringWithoutLengthLE)(e,n.path);break}default:throw new Error(`Not implemented descriptor OSType: ${t}`)}}function fh(e){let t=(0,K.readInt32)(e),n=[];for(let i=0;i<t;i++){let o=(0,K.readSignature)(e);switch(o){case"prop":{en(e);let r=gt(e);n.push(r);break}case"Clss":n.push(en(e));break;case"Enmr":{en(e);let r=gt(e),s=gt(e);n.push(`${r}.${s}`);break}case"rele":{en(e),n.push((0,K.readUint32)(e));break}case"Idnt":n.push((0,K.readInt32)(e));break;case"indx":n.push((0,K.readInt32)(e));break;case"name":{en(e),n.push((0,K.readUnicodeString)(e));break}default:throw new Error(`Invalid descriptor reference type: ${o}`)}}return n}function uh(e,t,n){(0,J.writeInt32)(e,n.length);for(let i=0;i<n.length;i++){let o=n[i],r="unknown";switch(typeof o=="string"&&(/^[a-z ]+\.[a-z ]+$/i.test(o)?r="Enmr":r="name"),(0,J.writeSignature)(e,r),r){case"Enmr":{let[s,a]=o.split(".");Ja(e,"\0",s),kt(e,s),kt(e,a);break}case"name":{Ja(e,"\0","Lyr "),(0,J.writeUnicodeString)(e,o+"\0");break}default:throw new Error(`Invalid descriptor reference type: ${r}`)}}return n}function en(e){let t=(0,K.readUnicodeString)(e),n=gt(e);return{name:t,classID:n}}function Ja(e,t,n){(0,J.writeUnicodeString)(e,t),kt(e,n)}function hh(e,t=!1){let n=(0,K.readUint32)(e);if(n!==16)throw new Error(`Invalid descriptor version: ${n}`);return yr(e,t)}function ph(e,t,n,i,o=""){(0,J.writeUint32)(e,16),wr(e,t,n,i,o)}function $i(e){return{x:e.Hrzn,y:e.Vrtc}}function Ni(e){return{Hrzn:e.x,Vrtc:e.y}}function mh(e){return{top:it(e["Top "]),left:it(e.Left),right:it(e.Rght),bottom:it(e.Btom)}}function gh(e){return{Left:bt(e.left,"bounds.left"),"Top ":bt(e.top,"bounds.top"),Rght:bt(e.right,"bounds.right"),Btom:bt(e.bottom,"bounds.bottom")}}function Qa(e){let t={enabled:!!e.enab,position:A.FStl.decode(e.Styl),fillType:A.FrFl.decode(e.PntT),blendMode:A.BlnM.decode(e["Md "]),opacity:_e(e.Opct),size:it(e["Sz "])};return e.present!==void 0&&(t.present=e.present),e.showInDialog!==void 0&&(t.showInDialog=e.showInDialog),e.overprint!==void 0&&(t.overprint=e.overprint),e["Clr "]&&(t.color=tn(e["Clr "])),e.Grad&&(t.gradient=ul(e)),e.Ptrn&&(t.pattern=hl(e)),t}function el(e){let t={};return t.enab=!!e.enabled,e.present!==void 0&&(t.present=!!e.present),e.showInDialog!==void 0&&(t.showInDialog=!!e.showInDialog),t.Styl=A.FStl.encode(e.position),t.PntT=A.FrFl.encode(e.fillType),t["Md "]=A.BlnM.encode(e.blendMode),t.Opct=ke(e.opacity),t["Sz "]=bt(e.size,"size"),e.color&&(t["Clr "]=nn(e.color)),e.gradient&&(t=Object.assign(Object.assign({},t),pl(e.gradient))),e.pattern&&(t=Object.assign(Object.assign({},t),ml(e.pattern))),e.overprint!==void 0&&(t.overprint=!!e.overprint),t}function ll(e,t,n){var i,o,r;let s=n?{"Scl ":br((i=e.scale)!==null&&i!==void 0?i:1),masterFXSwitch:!e.disabled}:{masterFXSwitch:!e.disabled,"Scl ":br((o=e.scale)!==null&&o!==void 0?o:1)},a=["dropShadow","innerShadow","solidFill","gradientOverlay","stroke"];for(let d of a)if(e[d]&&!Array.isArray(e[d]))throw new Error(`${d} should be an array`);let l=d=>!!d&&d.length>1&&n,c=d=>!!d&&d.length>=1&&(!n||d.length===1);if(c(e.dropShadow)&&(s.DrSh=He(e.dropShadow[0],"dropShadow",t)),l(e.dropShadow)&&(s.dropShadowMulti=e.dropShadow.map(d=>He(d,"dropShadow",t))),c(e.innerShadow)&&(s.IrSh=He(e.innerShadow[0],"innerShadow",t)),l(e.innerShadow)&&(s.innerShadowMulti=e.innerShadow.map(d=>He(d,"innerShadow",t))),e.outerGlow&&(s.OrGl=He(e.outerGlow,"outerGlow",t)),l(e.solidFill)&&(s.solidFillMulti=e.solidFill.map(d=>He(d,"solidFill",t))),l(e.gradientOverlay)&&(s.gradientFillMulti=e.gradientOverlay.map(d=>He(d,"gradientOverlay",t))),l(e.stroke)&&(s.frameFXMulti=e.stroke.map(d=>el(d))),e.innerGlow&&(s.IrGl=He(e.innerGlow,"innerGlow",t)),e.bevel&&(s.ebbl=He(e.bevel,"bevel",t)),c(e.solidFill)&&(s.SoFi=He(e.solidFill[0],"solidFill",t)),e.patternOverlay&&(s.patternFill=He(e.patternOverlay,"patternOverlay",t)),c(e.gradientOverlay)&&(s.GrFl=He(e.gradientOverlay[0],"gradientOverlay",t)),e.satin&&(s.ChFX=He(e.satin,"satin",t)),c(e.stroke)&&(s.FrFX=el((r=e.stroke)===null||r===void 0?void 0:r[0])),n){s.numModifyingFX=0;for(let d of Object.keys(e)){let u=e[d];if(Array.isArray(u))for(let f of u)f.enabled&&s.numModifyingFX++;else u.enabled&&s.numModifyingFX++}}return s}function cl(e,t){let n={},{masterFXSwitch:i,DrSh:o,dropShadowMulti:r,IrSh:s,innerShadowMulti:a,OrGl:l,IrGl:c,ebbl:d,SoFi:u,solidFillMulti:f,patternFill:h,GrFl:p,gradientFillMulti:S,ChFX:m,FrFX:b,frameFXMulti:v,numModifyingFX:x}=e,_=rh(e,["masterFXSwitch","DrSh","dropShadowMulti","IrSh","innerShadowMulti","OrGl","IrGl","ebbl","SoFi","solidFillMulti","patternFill","GrFl","gradientFillMulti","ChFX","FrFX","frameFXMulti","numModifyingFX"]);return i||(n.disabled=!0),e["Scl "]&&(n.scale=_e(e["Scl "])),o&&(n.dropShadow=[Ge(o,t)]),r&&(n.dropShadow=r.map(I=>Ge(I,t))),s&&(n.innerShadow=[Ge(s,t)]),a&&(n.innerShadow=a.map(I=>Ge(I,t))),l&&(n.outerGlow=Ge(l,t)),c&&(n.innerGlow=Ge(c,t)),d&&(n.bevel=Ge(d,t)),u&&(n.solidFill=[Ge(u,t)]),f&&(n.solidFill=f.map(I=>Ge(I,t))),h&&(n.patternOverlay=Ge(h,t)),p&&(n.gradientOverlay=[Ge(p,t)]),S&&(n.gradientOverlay=S.map(I=>Ge(I,t))),m&&(n.satin=Ge(m,t)),b&&(n.stroke=[Qa(b)]),v&&(n.stroke=v.map(I=>Qa(I))),t&&Object.keys(_).length>1&&console.log("Unhandled effect keys:",_),n}function tl(e,t){let n=[];for(let i=0;i<e.length;i++){let o=e[i],{time:{denominator:r,numerator:s},selected:a,animKey:l}=o,c={numerator:s,denominator:r},d=A.animInterpStyleEnum.decode(o.animInterpStyle);switch(l.Type){case"keyType.Opct":n.push({interpolation:d,time:c,selected:a,type:"opacity",value:_e(l.Opct)});break;case"keyType.Pstn":n.push({interpolation:d,time:c,selected:a,type:"position",x:l.Hrzn,y:l.Vrtc});break;case"keyType.Trnf":n.push({interpolation:d,time:c,selected:a,type:"transform",scale:$i(l["Scl "]),skew:$i(l.Skew),rotation:l.rotation,translation:$i(l.translation)});break;case"keyType.sheetStyle":{let u={interpolation:d,time:c,selected:a,type:"style"};l.sheetStyle.Lefx&&(u.style=cl(l.sheetStyle.Lefx,t)),n.push(u);break}case"keyType.globalLighting":{n.push({interpolation:d,time:c,selected:a,type:"globalLighting",globalAngle:l.gblA,globalAltitude:l.globalAltitude});break}default:throw new Error("Unsupported keyType value")}}return n}function nl(e){let t=[];for(let n=0;n<e.length;n++){let i=e[n],{time:o,selected:r=!1,interpolation:s}=i,a=A.animInterpStyleEnum.encode(s),l;switch(i.type){case"opacity":l={Type:"keyType.Opct",Opct:ke(i.value)};break;case"position":l={Type:"keyType.Pstn",Hrzn:i.x,Vrtc:i.y};break;case"transform":l={Type:"keyType.Trnf","Scl ":Ni(i.scale),Skew:Ni(i.skew),rotation:i.rotation,translation:Ni(i.translation)};break;case"style":l={Type:"keyType.sheetStyle",sheetStyle:{Vrsn:1,blendOptions:{}}},i.style&&(l.sheetStyle={Vrsn:1,Lefx:ll(i.style,!1,!1),blendOptions:{}});break;case"globalLighting":{l={Type:"keyType.globalLighting",gblA:i.globalAngle,globalAltitude:i.globalAltitude};break}default:throw new Error("Unsupported keyType value")}t.push({Vrsn:1,animInterpStyle:a,time:o,animKey:l,selected:r})}return t}function bh(e,t){let n=[];for(let i=0;i<e.length;i++){let o=e[i],r={type:A.stdTrackID.decode(o.trackID),enabled:o.enab,keys:tl(o.keyList,t)};o.effectParams&&(r.effectParams={fillCanvas:o.effectParams.fillCanvas,zoomOrigin:o.effectParams.zoomOrigin,keys:tl(o.effectParams.keyList,t)}),n.push(r)}return n}function yh(e){let t=[];for(let n=0;n<e.length;n++){let i=e[n];t.push(Object.assign(Object.assign({trackID:A.stdTrackID.encode(i.type),Vrsn:1,enab:!!i.enabled,Effc:!!i.effectParams},i.effectParams?{effectParams:{keyList:nl(i.keys),fillCanvas:i.effectParams.fillCanvas,zoomOrigin:i.effectParams.zoomOrigin}}:{}),{keyList:nl(i.keys)}))}return t}function Ge(e,t){let n={};for(let i of Object.keys(e)){let o=e[i];switch(i){case"enab":n.enabled=!!o;break;case"uglg":n.useGlobalLight=!!o;break;case"AntA":n.antialiased=!!o;break;case"Algn":n.align=!!o;break;case"Dthr":n.dither=!!o;break;case"Invr":n.invert=!!o;break;case"Rvrs":n.reverse=!!o;break;case"Clr ":n.color=tn(o);break;case"hglC":n.highlightColor=tn(o);break;case"sdwC":n.shadowColor=tn(o);break;case"Styl":n.position=A.FStl.decode(o);break;case"Md ":n.blendMode=A.BlnM.decode(o);break;case"hglM":n.highlightBlendMode=A.BlnM.decode(o);break;case"sdwM":n.shadowBlendMode=A.BlnM.decode(o);break;case"bvlS":n.style=A.BESl.decode(o);break;case"bvlD":n.direction=A.BESs.decode(o);break;case"bvlT":n.technique=A.bvlT.decode(o);break;case"GlwT":n.technique=A.BETE.decode(o);break;case"glwS":n.source=A.IGSr.decode(o);break;case"Type":n.type=A.GrdT.decode(o);break;case"gs99":n.interpolationMethod=A.gradientInterpolationMethodType.decode(o);break;case"Opct":n.opacity=_e(o);break;case"hglO":n.highlightOpacity=_e(o);break;case"sdwO":n.shadowOpacity=_e(o);break;case"lagl":n.angle=ii(o);break;case"Angl":n.angle=ii(o);break;case"Lald":n.altitude=ii(o);break;case"Sftn":n.soften=it(o);break;case"srgR":n.strength=_e(o);break;case"blur":n.size=it(o);break;case"Nose":n.noise=_e(o);break;case"Inpr":n.range=_e(o);break;case"Ckmt":n.choke=it(o);break;case"ShdN":n.jitter=_e(o);break;case"Dstn":n.distance=it(o);break;case"Scl ":n.scale=_e(o);break;case"Ptrn":n.pattern={name:o["Nm "],id:o.Idnt};break;case"phase":n.phase={x:o.Hrzn,y:o.Vrtc};break;case"Ofst":n.offset={x:_e(o.Hrzn),y:_e(o.Vrtc)};break;case"MpgS":case"TrnS":n.contour={name:o["Nm "],curve:o["Crv "].map(r=>({x:r.Hrzn,y:r.Vrtc}))};break;case"Grad":n.gradient=dl(o);break;case"useTexture":case"useShape":case"layerConceals":case"present":case"showInDialog":case"antialiasGloss":n[i]=o;break;case"_name":case"_classID":break;default:t&&console.log(`Invalid effect key: '${i}', value:`,o)}}return n}function He(e,t,n){let i={enab:!1};t==="dropShadow"&&(i.TrnS={"Nm ":"","Crv ":[]});for(let o of Object.keys(e)){let r=o,s=e[r];switch(r){case"enabled":i.enab=!!s;break;case"useGlobalLight":i.uglg=!!s;break;case"antialiased":i.AntA=!!s;break;case"align":i.Algn=!!s;break;case"dither":i.Dthr=!!s;break;case"invert":i.Invr=!!s;break;case"reverse":i.Rvrs=!!s;break;case"color":i["Clr "]=nn(s);break;case"highlightColor":i.hglC=nn(s);break;case"shadowColor":i.sdwC=nn(s);break;case"position":i.Styl=A.FStl.encode(s);break;case"blendMode":i["Md "]=A.BlnM.encode(s);break;case"highlightBlendMode":i.hglM=A.BlnM.encode(s);break;case"shadowBlendMode":i.sdwM=A.BlnM.encode(s);break;case"style":i.bvlS=A.BESl.encode(s);break;case"direction":i.bvlD=A.BESs.encode(s);break;case"technique":t==="bevel"?i.bvlT=A.bvlT.encode(s):i.GlwT=A.BETE.encode(s);break;case"source":i.glwS=A.IGSr.encode(s);break;case"type":i.Type=A.GrdT.encode(s);break;case"interpolationMethod":i.gs99=A.gradientInterpolationMethodType.encode(s);break;case"opacity":i.Opct=ke(s);break;case"highlightOpacity":i.hglO=ke(s);break;case"shadowOpacity":i.sdwO=ke(s);break;case"angle":t==="gradientOverlay"||t==="patternFill"?i.Angl=In(s):i.lagl=In(s);break;case"altitude":i.Lald=In(s);break;case"soften":i.Sftn=bt(s,r);break;case"strength":i.srgR=ke(s);break;case"size":i.blur=bt(s,r);break;case"noise":i.Nose=ke(s);break;case"range":i.Inpr=ke(s);break;case"choke":i.Ckmt=bt(s,r);break;case"jitter":i.ShdN=ke(s);break;case"distance":i.Dstn=bt(s,r);break;case"scale":i["Scl "]=ke(s);break;case"pattern":i.Ptrn={"Nm ":s.name,Idnt:s.id};break;case"phase":i.phase={Hrzn:s.x,Vrtc:s.y};break;case"offset":i.Ofst={Hrzn:ke(s.x),Vrtc:ke(s.y)};break;case"contour":{i[t==="satin"?"MpgS":"TrnS"]={"Nm ":s.name,"Crv ":s.curve.map(a=>({Hrzn:a.x,Vrtc:a.y}))};break}case"gradient":i.Grad=fl(s);break;case"useTexture":case"useShape":case"layerConceals":case"present":case"showInDialog":case"antialiasGloss":i[r]=s;break;default:n&&console.log(`Invalid effect key: '${r}', value:`,s)}}return i}function dl(e){if(e.GrdF==="GrdF.CstS"){let t=e.Intr||4096;return{type:"solid",name:e["Nm "],smoothness:e.Intr/4096,colorStops:e.Clrs.map(n=>({color:tn(n["Clr "]),location:n.Lctn/t,midpoint:n.Mdpn/100})),opacityStops:e.Trns.map(n=>({opacity:_e(n.Opct),location:n.Lctn/t,midpoint:n.Mdpn/100}))}}else return{type:"noise",name:e["Nm "],roughness:e.Smth/4096,colorModel:A.ClrS.decode(e.ClrS),randomSeed:e.RndS,restrictColors:!!e.VctC,addTransparency:!!e.ShTr,min:e["Mnm "].map(t=>t/100),max:e["Mxm "].map(t=>t/100)}}function fl(e){var t,n;if(e.type==="solid"){let i=Math.round(((t=e.smoothness)!==null&&t!==void 0?t:1)*4096);return{"Nm ":e.name||"",GrdF:"GrdF.CstS",Intr:i,Clrs:e.colorStops.map(o=>{var r;return{"Clr ":nn(o.color),Type:"Clry.UsrS",Lctn:Math.round(o.location*i),Mdpn:Math.round(((r=o.midpoint)!==null&&r!==void 0?r:.5)*100)}}),Trns:e.opacityStops.map(o=>{var r;return{Opct:ke(o.opacity),Lctn:Math.round(o.location*i),Mdpn:Math.round(((r=o.midpoint)!==null&&r!==void 0?r:.5)*100)}})}}else return{GrdF:"GrdF.ClNs","Nm ":e.name||"",ShTr:!!e.addTransparency,VctC:!!e.restrictColors,ClrS:A.ClrS.encode(e.colorModel),RndS:e.randomSeed||0,Smth:Math.round(((n=e.roughness)!==null&&n!==void 0?n:1)*4096),"Mnm ":(e.min||[0,0,0,0]).map(i=>i*100),"Mxm ":(e.max||[1,1,1,1]).map(i=>i*100)}}function ul(e){let t=dl(e.Grad);return t.style=A.GrdT.decode(e.Type),e.Dthr!==void 0&&(t.dither=e.Dthr),e.gradientsInterpolationMethod!==void 0&&(t.interpolationMethod=A.gradientInterpolationMethodType.decode(e.gradientsInterpolationMethod)),e.Rvrs!==void 0&&(t.reverse=e.Rvrs),e.Angl!==void 0&&(t.angle=ii(e.Angl)),e["Scl "]!==void 0&&(t.scale=_e(e["Scl "])),e.Algn!==void 0&&(t.align=e.Algn),e.Ofst!==void 0&&(t.offset={x:_e(e.Ofst.Hrzn),y:_e(e.Ofst.Vrtc)}),t}function hl(e){let t={name:e.Ptrn["Nm "],id:e.Ptrn.Idnt};return e.Lnkd!==void 0&&(t.linked=e.Lnkd),e.phase!==void 0&&(t.phase={x:e.phase.Hrzn,y:e.phase.Vrtc}),t}function wh(e){if("Grad"in e)return ul(e);if("Ptrn"in e)return Object.assign({type:"pattern"},hl(e));if("Clr "in e)return{type:"color",color:tn(e["Clr "])};throw new Error("Invalid vector content")}function pl(e){let t={};return e.dither!==void 0&&(t.Dthr=e.dither),e.interpolationMethod!==void 0&&(t.gradientsInterpolationMethod=A.gradientInterpolationMethodType.encode(e.interpolationMethod)),e.reverse!==void 0&&(t.Rvrs=e.reverse),e.angle!==void 0&&(t.Angl=In(e.angle)),t.Type=A.GrdT.encode(e.style),e.align!==void 0&&(t.Algn=e.align),e.scale!==void 0&&(t["Scl "]=ke(e.scale)),e.offset&&(t.Ofst={Hrzn:ke(e.offset.x),Vrtc:ke(e.offset.y)}),t.Grad=fl(e),t}function ml(e){let t={Ptrn:{"Nm ":e.name||"",Idnt:e.id||""}};return e.linked!==void 0&&(t.Lnkd=!!e.linked),e.phase!==void 0&&(t.phase={Hrzn:e.phase.x,Vrtc:e.phase.y}),t}function Sh(e){return e.type==="color"?{key:"SoCo",descriptor:{"Clr ":nn(e.color)}}:e.type==="pattern"?{key:"PtFl",descriptor:ml(e)}:{key:"GdFl",descriptor:pl(e)}}function tn(e){if("H "in e)return{h:gl(e["H "]),s:e.Strt,b:e.Brgh};if("Rd "in e)return{r:e["Rd "],g:e["Grn "],b:e["Bl "]};if("Cyn "in e)return{c:e["Cyn "],m:e.Mgnt,y:e["Ylw "],k:e.Blck};if("Gry "in e)return{k:e["Gry "]};if("Lmnc"in e)return{l:e.Lmnc,a:e["A "],b:e["B "]};if("redFloat"in e)return{fr:e.redFloat,fg:e.greenFloat,fb:e.blueFloat};throw new Error("Unsupported color descriptor")}function nn(e){if(e){if("r"in e)return{_name:"",_classID:"RGBC","Rd ":e.r||0,"Grn ":e.g||0,"Bl ":e.b||0};if("fr"in e)return{_name:"",_classID:"RGBC",redFloat:e.fr,greenFloat:e.fg,blueFloat:e.fb};if("h"in e)return{_name:"",_classID:"HSBC","H ":In(e.h*360),Strt:e.s||0,Brgh:e.b||0};if("c"in e)return{_name:"",_classID:"CMYC","Cyn ":e.c||0,Mgnt:e.m||0,"Ylw ":e.y||0,Blck:e.k||0};if("l"in e)return{_name:"",_classID:"LABC",Lmnc:e.l||0,"A ":e.a||0,"B ":e.b||0};if("k"in e)return{_name:"",_classID:"GRYC","Gry ":e.k};throw new Error("Invalid color value")}else return{_name:"",_classID:"RGBC","Rd ":0,"Grn ":0,"Bl ":0}}function ii(e){if(e===void 0)return 0;if(e.units!=="Angle")throw new Error(`Invalid units: ${e.units}`);return e.value}function _e(e){if(e===void 0)return 1;if(e.units!=="Percent")throw new Error(`Invalid units: ${e.units}`);return e.value/100}function gl(e){if(e===void 0)return 1;if(e.units==="Percent")return e.value/100;if(e.units==="Angle")return e.value/360;throw new Error(`Invalid units: ${e.units}`)}function it({units:e,value:t}){if(e!=="Pixels"&&e!=="Millimeters"&&e!=="Points"&&e!=="None"&&e!=="Picas"&&e!=="Inches"&&e!=="Centimeters"&&e!=="Density")throw new Error(`Invalid units: ${JSON.stringify({units:e,value:t})}`);return{value:t,units:e}}function vh(e,t="Pixels"){return typeof e=="number"?{value:e,units:t}:it(e)}function xh({units:e,value:t},n){if(e!==n)throw new Error(`Invalid units: ${JSON.stringify({units:e,value:t})}`);return t}function In(e){return{units:"Angle",value:e||0}}function ke(e){return{units:"Percent",value:Math.round((e||0)*100)}}function br(e){return{units:"Percent",value:(e||0)*100}}function bt(e,t){if(e==null)return{units:"Pixels",value:0};if(typeof e!="object")throw new Error(`Invalid value: ${JSON.stringify(e)} (key: ${t}) (should have value and units)`);let{units:n,value:i}=e;if(typeof i!="number")throw new Error(`Invalid value in ${JSON.stringify(e)} (key: ${t})`);if(n!=="Pixels"&&n!=="Millimeters"&&n!=="Points"&&n!=="None"&&n!=="Picas"&&n!=="Inches"&&n!=="Centimeters"&&n!=="Density")throw new Error(`Invalid units in ${JSON.stringify(e)} (key: ${t})`);return{units:n,value:i}}function _h({numerator:e,denominator:t}){return{numerator:e,denominator:t}}A.textGridding=(0,$.createEnum)("textGridding","none",{none:"None",round:"Rnd "});A.Ornt=(0,$.createEnum)("Ornt","horizontal",{horizontal:"Hrzn",vertical:"Vrtc"});A.Annt=(0,$.createEnum)("Annt","sharp",{none:"Anno",sharp:"antiAliasSharp",crisp:"AnCr",strong:"AnSt",smooth:"AnSm",platform:"antiAliasPlatformGray",platformLCD:"antiAliasPlatformLCD"});A.warpStyle=(0,$.createEnum)("warpStyle","none",{none:"warpNone",arc:"warpArc",arcLower:"warpArcLower",arcUpper:"warpArcUpper",arch:"warpArch",bulge:"warpBulge",shellLower:"warpShellLower",shellUpper:"warpShellUpper",flag:"warpFlag",wave:"warpWave",fish:"warpFish",rise:"warpRise",fisheye:"warpFisheye",inflate:"warpInflate",squeeze:"warpSqueeze",twist:"warpTwist",cylinder:"warpCylinder",custom:"warpCustom"});A.BlnM=(0,$.createEnum)("BlnM","normal",{normal:"Nrml",dissolve:"Dslv",darken:"Drkn",multiply:"Mltp","color burn":"CBrn","linear burn":"linearBurn","darker color":"darkerColor",lighten:"Lghn",screen:"Scrn","color dodge":"CDdg","linear dodge":"linearDodge","lighter color":"lighterColor",overlay:"Ovrl","soft light":"SftL","hard light":"HrdL","vivid light":"vividLight","linear light":"linearLight","pin light":"pinLight","hard mix":"hardMix",difference:"Dfrn",exclusion:"Xclu",subtract:"blendSubtraction",divide:"blendDivide",hue:"H ",saturation:"Strt",color:"Clr ",luminosity:"Lmns","linear height":"linearHeight",height:"Hght",subtraction:"Sbtr","pass through":"????"});A.BESl=(0,$.createEnum)("BESl","inner bevel",{"inner bevel":"InrB","outer bevel":"OtrB",emboss:"Embs","pillow emboss":"PlEb","stroke emboss":"strokeEmboss"});A.bvlT=(0,$.createEnum)("bvlT","smooth",{smooth:"SfBL","chisel hard":"PrBL","chisel soft":"Slmt"});A.BESs=(0,$.createEnum)("BESs","up",{up:"In ",down:"Out "});A.BETE=(0,$.createEnum)("BETE","softer",{softer:"SfBL",precise:"PrBL"});A.IGSr=(0,$.createEnum)("IGSr","edge",{edge:"SrcE",center:"SrcC"});A.GrdT=(0,$.createEnum)("GrdT","linear",{linear:"Lnr ",radial:"Rdl ",angle:"Angl",reflected:"Rflc",diamond:"Dmnd"});A.animInterpStyleEnum=(0,$.createEnum)("animInterpStyle","linear",{linear:"Lnr ",hold:"hold"});A.stdTrackID=(0,$.createEnum)("stdTrackID","opacity",{opacity:"opacityTrack",style:"styleTrack",sheetTransform:"sheetTransformTrack",sheetPosition:"sheetPositionTrack",globalLighting:"globalLightingTrack"});A.gradientInterpolationMethodType=(0,$.createEnum)("gradientInterpolationMethodType","perceptual",{perceptual:"Perc",linear:"Lnr ",classic:"Gcls",smooth:"Smoo"});A.ClrS=(0,$.createEnum)("ClrS","rgb",{rgb:"RGBC",hsb:"HSBl",lab:"LbCl",hsl:"HSLC"});A.FStl=(0,$.createEnum)("FStl","outside",{outside:"OutF",center:"CtrF",inside:"InsF"});A.FrFl=(0,$.createEnum)("FrFl","color",{color:"SClr",gradient:"GrFl",pattern:"Ptrn"});A.ESliceType=(0,$.createEnum)("ESliceType","image",{image:"Img ",noImage:"noImage"});A.ESliceHorzAlign=(0,$.createEnum)("ESliceHorzAlign","default",{default:"default"});A.ESliceVertAlign=(0,$.createEnum)("ESliceVertAlign","default",{default:"default"});A.ESliceOrigin=(0,$.createEnum)("ESliceOrigin","userGenerated",{userGenerated:"userGenerated",autoGenerated:"autoGenerated",layer:"layer"});A.ESliceBGColorType=(0,$.createEnum)("ESliceBGColorType","none",{none:"None",matte:"matte",color:"Clr "});A.strokeStyleLineCapType=(0,$.createEnum)("strokeStyleLineCapType","butt",{butt:"strokeStyleButtCap",round:"strokeStyleRoundCap",square:"strokeStyleSquareCap"});A.strokeStyleLineJoinType=(0,$.createEnum)("strokeStyleLineJoinType","miter",{miter:"strokeStyleMiterJoin",round:"strokeStyleRoundJoin",bevel:"strokeStyleBevelJoin"});A.strokeStyleLineAlignment=(0,$.createEnum)("strokeStyleLineAlignment","inside",{inside:"strokeStyleAlignInside",center:"strokeStyleAlignCenter",outside:"strokeStyleAlignOutside"});A.BlrM=(0,$.createEnum)("BlrM","spin",{spin:"Spn ",zoom:"Zm "});A.BlrQ=(0,$.createEnum)("BlrQ","good",{draft:"Drft",good:"Gd ",best:"Bst "});A.SmBM=(0,$.createEnum)("SmBM","normal",{normal:"SBMN","edge only":"SBME","overlay edge":"SBMO"});A.SmBQ=(0,$.createEnum)("SmBQ","medium",{low:"SBQL",medium:"SBQM",high:"SBQH"});A.DspM=(0,$.createEnum)("DspM","stretch to fit",{"stretch to fit":"StrF",tile:"Tile"});A.UndA=(0,$.createEnum)("UndA","repeat edge pixels",{"wrap around":"WrpA","repeat edge pixels":"RptE"});A.Cnvr=(0,$.createEnum)("Cnvr","rectangular to polar",{"rectangular to polar":"RctP","polar to rectangular":"PlrR"});A.RplS=(0,$.createEnum)("RplS","medium",{small:"Sml ",medium:"Mdm ",large:"Lrg "});A.SphM=(0,$.createEnum)("SphM","normal",{normal:"Nrml","horizontal only":"HrzO","vertical only":"VrtO"});A.Wvtp=(0,$.createEnum)("Wvtp","sine",{sine:"WvSn",triangle:"WvTr",square:"WvSq"});A.ZZTy=(0,$.createEnum)("ZZTy","pond ripples",{"around center":"ArnC","out from center":"OtFr","pond ripples":"PndR"});A.Dstr=(0,$.createEnum)("Dstr","uniform",{uniform:"Unfr",gaussian:"Gsn "});A.Chnl=(0,$.createEnum)("Chnl","composite",{red:"Rd ",green:"Grn ",blue:"Bl ",composite:"Cmps"});A.MztT=(0,$.createEnum)("MztT","fine dots",{"fine dots":"FnDt","medium dots":"MdmD","grainy dots":"GrnD","coarse dots":"CrsD","short lines":"ShrL","medium lines":"MdmL","long lines":"LngL","short strokes":"ShSt","medium strokes":"MdmS","long strokes":"LngS"});A.Lns=(0,$.createEnum)("Lns ","50-300mm zoom",{"50-300mm zoom":"Zm ","32mm prime":"Nkn ","105mm prime":"Nkn1","movie prime":"PnVs"});A.blurType=(0,$.createEnum)("blurType","gaussian blur",{"gaussian blur":"GsnB","lens blur":"lensBlur","motion blur":"MtnB"});A.DfsM=(0,$.createEnum)("DfsM","normal",{normal:"Nrml","darken only":"DrkO","lighten only":"LghO",anisotropic:"anisotropic"});A.ExtT=(0,$.createEnum)("ExtT","blocks",{blocks:"Blks",pyramids:"Pyrm"});A.ExtR=(0,$.createEnum)("ExtR","random",{random:"Rndm","level-based":"LvlB"});A.FlCl=(0,$.createEnum)("FlCl","background color",{"background color":"FlBc","foreground color":"FlFr","inverse image":"FlIn","unaltered image":"FlSm"});A.CntE=(0,$.createEnum)("CntE","upper",{lower:"Lwr ",upper:"Upr "});A.WndM=(0,$.createEnum)("WndM","wind",{wind:"Wnd ",blast:"Blst",stagger:"Stgr"});A.Drct=(0,$.createEnum)("Drct","right",{left:"Left",right:"Rght"});A.IntE=(0,$.createEnum)("IntE","odd lines",{"odd lines":"ElmO","even lines":"ElmE"});A.IntC=(0,$.createEnum)("IntC","interpolation",{duplication:"CrtD",interpolation:"CrtI"});A.FlMd=(0,$.createEnum)("FlMd","wrap around",{"set to transparent":"Bckg","repeat edge pixels":"Rpt ","wrap around":"Wrp "});A.prjM=(0,$.createEnum)("prjM","fisheye",{fisheye:"fisP",perspective:"perP",auto:"auto","full spherical":"fusP"});A.presetKindType=(0,$.createEnum)("presetKindType","custom",{custom:"presetKindCustom",default:"presetKindDefault"})});var xr=oe(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.resourceHandlersMap=zt.resourceHandlers=void 0;var Ah=ji(),D=jt(),C=Dn(),Ie=Tt(),Ki=Ka(),q=Gi();zt.resourceHandlers=[];zt.resourceHandlersMap={};function H(e,t,n,i){let o={key:e,has:t,read:n,write:i};zt.resourceHandlers.push(o),zt.resourceHandlersMap[o.key]=o}var Je=!1,Hi=[void 0,"PPI","PPCM"],Wi=[void 0,"Inches","Centimeters","Points","Picas","Columns"],bl="0123456789abcdef";function yl(e){return e<=57?e-48:e>=97?e-87:e-55}function kh(e,t){return yl(e.charCodeAt(t))<<4|yl(e.charCodeAt(t+1))}function Sr(e,t){let n=(0,D.readBytes)(e,t);return(0,Ki.decodeString)(n)}function vr(e,t){let n=(0,Ki.encodeString)(t);(0,C.writeBytes)(e,n)}function Ih(e){let t=(0,D.readUint8)(e),n=(0,D.readBytes)(e,t),i=!1;for(let o=0;o<n.byteLength;o++)if(n[o]&128){i=!0;break}if(i)try{return new TextDecoder("gbk").decode(n)}catch{}return(0,Ki.decodeString)(n)}function Dh(e,t){let n="";for(let o=0,r=t.codePointAt(o++);r!==void 0;r=t.codePointAt(o++))n+=r>127?"?":String.fromCodePoint(r);let i=(0,Ki.encodeString)(n);(0,C.writeUint8)(e,i.byteLength),(0,C.writeBytes)(e,i)}Ie.MOCK_HANDLERS&&H(1028,e=>e._ir1028!==void 0,(e,t,n)=>{Je&&console.log("image resource 1028",n()),t._ir1028=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1028)});H(1061,e=>e.captionDigest!==void 0,(e,t)=>{let n="";for(let i=0;i<16;i++){let o=(0,D.readUint8)(e);n+=bl[o>>4],n+=bl[o&15]}t.captionDigest=n},(e,t)=>{for(let n=0;n<16;n++)(0,C.writeUint8)(e,kh(t.captionDigest,n*2))});H(1060,e=>e.xmpMetadata!==void 0,(e,t,n)=>{t.xmpMetadata=Sr(e,n())},(e,t)=>{vr(e,t.xmpMetadata)});var Xi=(0,Ie.createEnum)("Inte","perceptual",{perceptual:"Img ",saturation:"Grp ","relative colorimetric":"Clrm","absolute colorimetric":"AClr"});Ie.MOCK_HANDLERS&&H(1085,e=>e._ir1085!==void 0,(e,t,n)=>{t._ir1085=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1085)});H(1082,e=>e.printInformation!==void 0,(e,t)=>{var n,i;let o=(0,q.readVersionAndDescriptor)(e);t.printInformation={printerName:o.printerName||"",renderingIntent:Xi.decode((n=o.Inte)!==null&&n!==void 0?n:"Inte.Img ")};let r=t.printInformation;o.PstS!==void 0&&(r.printerManagesColors=o.PstS),o["Nm "]!==void 0&&(r.printerProfile=o["Nm "]),o.MpBl!==void 0&&(r.blackPointCompensation=o.MpBl),o.printSixteenBit!==void 0&&(r.printSixteenBit=o.printSixteenBit),o.hardProof!==void 0&&(r.hardProof=o.hardProof),o.printProofSetup&&("Bltn"in o.printProofSetup?r.proofSetup={builtin:o.printProofSetup.Bltn.split(".")[1]}:r.proofSetup={profile:o.printProofSetup.profile,renderingIntent:Xi.decode((i=o.printProofSetup.Inte)!==null&&i!==void 0?i:"Inte.Img "),blackPointCompensation:!!o.printProofSetup.MpBl,paperWhite:!!o.printProofSetup.paperWhite})},(e,t)=>{var n,i;let o=t.printInformation,r={};o.printerManagesColors?r.PstS=!0:(o.hardProof!==void 0&&(r.hardProof=!!o.hardProof),r.ClrS="ClrS.RGBC",r["Nm "]=(n=o.printerProfile)!==null&&n!==void 0?n:"CIE RGB"),r.Inte=Xi.encode(o.renderingIntent),o.printerManagesColors||(r.MpBl=!!o.blackPointCompensation),r.printSixteenBit=!!o.printSixteenBit,r.printerName=o.printerName||"",o.proofSetup&&"profile"in o.proofSetup?r.printProofSetup={profile:o.proofSetup.profile||"",Inte:Xi.encode(o.proofSetup.renderingIntent),MpBl:!!o.proofSetup.blackPointCompensation,paperWhite:!!o.proofSetup.paperWhite}:r.printProofSetup={Bltn:!((i=o.proofSetup)===null||i===void 0)&&i.builtin?`builtinProof.${o.proofSetup.builtin}`:"builtinProof.proofCMYK"},(0,q.writeVersionAndDescriptor)(e,"","printOutput",r)});Ie.MOCK_HANDLERS&&H(1083,e=>e._ir1083!==void 0,(e,t,n)=>{Je&&console.log("image resource 1083",n()),t._ir1083=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1083)});H(1005,e=>e.resolutionInfo!==void 0,(e,t)=>{let n=(0,D.readFixedPoint32)(e),i=(0,D.readUint16)(e),o=(0,D.readUint16)(e),r=(0,D.readFixedPoint32)(e),s=(0,D.readUint16)(e),a=(0,D.readUint16)(e);t.resolutionInfo={horizontalResolution:n,horizontalResolutionUnit:Hi[i]||"PPI",widthUnit:Wi[o]||"Inches",verticalResolution:r,verticalResolutionUnit:Hi[s]||"PPI",heightUnit:Wi[a]||"Inches"}},(e,t)=>{let n=t.resolutionInfo;(0,C.writeFixedPoint32)(e,n.horizontalResolution||0),(0,C.writeUint16)(e,Math.max(1,Hi.indexOf(n.horizontalResolutionUnit))),(0,C.writeUint16)(e,Math.max(1,Wi.indexOf(n.widthUnit))),(0,C.writeFixedPoint32)(e,n.verticalResolution||0),(0,C.writeUint16)(e,Math.max(1,Hi.indexOf(n.verticalResolutionUnit))),(0,C.writeUint16)(e,Math.max(1,Wi.indexOf(n.heightUnit)))});var wl=["centered","size to fit","user defined"];H(1062,e=>e.printScale!==void 0,(e,t)=>{t.printScale={style:wl[(0,D.readInt16)(e)],x:(0,D.readFloat32)(e),y:(0,D.readFloat32)(e),scale:(0,D.readFloat32)(e)}},(e,t)=>{let{style:n,x:i,y:o,scale:r}=t.printScale;(0,C.writeInt16)(e,Math.max(0,wl.indexOf(n))),(0,C.writeFloat32)(e,i||0),(0,C.writeFloat32)(e,o||0),(0,C.writeFloat32)(e,r||0)});H(1006,e=>e.alphaChannelNames!==void 0,(e,t,n)=>{if(t.alphaChannelNames)(0,D.skipBytes)(e,n());else for(t.alphaChannelNames=[];n()>0;){let i=Ih(e);t.alphaChannelNames.push(i)}},(e,t)=>{for(let n of t.alphaChannelNames)Dh(e,n)});H(1045,e=>e.alphaChannelNames!==void 0,(e,t,n)=>{for(t.alphaChannelNames=[];n()>0;)t.alphaChannelNames.push((0,D.readUnicodeString)(e))},(e,t)=>{for(let n of t.alphaChannelNames)(0,C.writeUnicodeStringWithPadding)(e,n)});Ie.MOCK_HANDLERS&&H(1077,e=>e._ir1077!==void 0,(e,t,n)=>{Je&&console.log("image resource 1077",n()),t._ir1077=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1077)});H(1053,e=>e.alphaIdentifiers!==void 0,(e,t,n)=>{for(t.alphaIdentifiers=[];n()>=4;)t.alphaIdentifiers.push((0,D.readUint32)(e))},(e,t)=>{for(let n of t.alphaIdentifiers)(0,C.writeUint32)(e,n)});H(1010,e=>e.backgroundColor!==void 0,(e,t)=>t.backgroundColor=(0,D.readColor)(e),(e,t)=>(0,C.writeColor)(e,t.backgroundColor));H(1037,e=>e.globalAngle!==void 0,(e,t)=>t.globalAngle=(0,D.readInt32)(e),(e,t)=>(0,C.writeInt32)(e,t.globalAngle));H(1049,e=>e.globalAltitude!==void 0,(e,t)=>t.globalAltitude=(0,D.readUint32)(e),(e,t)=>(0,C.writeUint32)(e,t.globalAltitude));H(1011,e=>e.printFlags!==void 0,(e,t,n)=>{t.printFlags={labels:!!(0,D.readUint8)(e),cropMarks:!!(0,D.readUint8)(e),colorBars:!!(0,D.readUint8)(e),registrationMarks:!!(0,D.readUint8)(e),negative:!!(0,D.readUint8)(e),flip:!!(0,D.readUint8)(e),interpolate:!!(0,D.readUint8)(e),caption:!!(0,D.readUint8)(e),printFlags:n()?!!(0,D.readUint8)(e):!1}},(e,t)=>{let n=t.printFlags;(0,C.writeUint8)(e,n.labels?1:0),(0,C.writeUint8)(e,n.cropMarks?1:0),(0,C.writeUint8)(e,n.colorBars?1:0),(0,C.writeUint8)(e,n.registrationMarks?1:0),(0,C.writeUint8)(e,n.negative?1:0),(0,C.writeUint8)(e,n.flip?1:0),(0,C.writeUint8)(e,n.interpolate?1:0),(0,C.writeUint8)(e,n.caption?1:0),(0,C.writeUint8)(e,n.printFlags?1:0)});H(1034,e=>e.copyrighted!==void 0,(e,t)=>{t.copyrighted=!!(0,D.readUint8)(e)},(e,t)=>{(0,C.writeUint8)(e,t.copyrighted?1:0)});H(1035,e=>e.url!==void 0,(e,t,n)=>{t.url=(0,D.readAsciiString)(e,n())},(e,t)=>{(0,C.writeAsciiString)(e,t.url)});Ie.MOCK_HANDLERS&&H(1e4,e=>e._ir10000!==void 0,(e,t,n)=>{Je&&console.log("image resource 10000",n()),t._ir10000=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir10000)});Ie.MOCK_HANDLERS&&H(1013,e=>e._ir1013!==void 0,(e,t,n)=>{Je&&console.log("image resource 1013",n()),t._ir1013=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1013)});Ie.MOCK_HANDLERS&&H(1016,e=>e._ir1016!==void 0,(e,t,n)=>{Je&&console.log("image resource 1016",n()),t._ir1016=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1016)});H(1080,e=>e.countInformation!==void 0,(e,t)=>{let n=(0,q.readVersionAndDescriptor)(e);t.countInformation=n.countGroupList.map(i=>({color:{r:i["Rd "],g:i["Grn "],b:i["Bl "]},name:i["Nm "],size:i["Rds "],fontSize:i.fontSize,visible:i.Vsbl,points:i.countObjectList.map(o=>({x:o["X "],y:o["Y "]}))}))},(e,t)=>{let n={Vrsn:1,countGroupList:t.countInformation.map(i=>({"Rd ":i.color.r,"Grn ":i.color.g,"Bl ":i.color.b,"Nm ":i.name,"Rds ":i.size,fontSize:i.fontSize,Vsbl:i.visible,countObjectList:i.points.map(o=>({"X ":o.x,"Y ":o.y}))}))};(0,q.writeVersionAndDescriptor)(e,"","Cnt ",n)});H(1024,e=>e.layerState!==void 0,(e,t)=>t.layerState=(0,D.readUint16)(e),(e,t)=>(0,C.writeUint16)(e,t.layerState));H(1026,e=>e.layersGroup!==void 0,(e,t,n)=>{for(t.layersGroup=[];n()>0;)t.layersGroup.push((0,D.readUint16)(e))},(e,t)=>{for(let n of t.layersGroup)(0,C.writeUint16)(e,n)});H(1072,e=>e.layerGroupsEnabledId!==void 0,(e,t,n)=>{for(t.layerGroupsEnabledId=[];n()>0;)t.layerGroupsEnabledId.push((0,D.readUint8)(e))},(e,t)=>{for(let n of t.layerGroupsEnabledId)(0,C.writeUint8)(e,n)});H(1069,e=>e.layerSelectionIds!==void 0,(e,t)=>{let n=(0,D.readUint16)(e);for(t.layerSelectionIds=[];n--;)t.layerSelectionIds.push((0,D.readUint32)(e))},(e,t)=>{(0,C.writeUint16)(e,t.layerSelectionIds.length);for(let n of t.layerSelectionIds)(0,C.writeUint32)(e,n)});H(1032,e=>e.gridAndGuidesInformation!==void 0,(e,t)=>{let n=(0,D.readUint32)(e),i=(0,D.readUint32)(e),o=(0,D.readUint32)(e),r=(0,D.readUint32)(e);if(n!==1)throw new Error(`Invalid 1032 resource version: ${n}`);t.gridAndGuidesInformation={grid:{horizontal:i,vertical:o},guides:[]};for(let s=0;s<r;s++)t.gridAndGuidesInformation.guides.push({location:(0,D.readUint32)(e)/32,direction:(0,D.readUint8)(e)?"horizontal":"vertical"})},(e,t)=>{let n=t.gridAndGuidesInformation,i=n.grid||{horizontal:576,vertical:576},o=n.guides||[];(0,C.writeUint32)(e,1),(0,C.writeUint32)(e,i.horizontal),(0,C.writeUint32)(e,i.vertical),(0,C.writeUint32)(e,o.length);for(let r of o)(0,C.writeUint32)(e,r.location*32),(0,C.writeUint8)(e,r.direction==="horizontal"?1:0)});H(1065,e=>e.layerComps!==void 0,(e,t)=>{let n=(0,q.readVersionAndDescriptor)(e,!0);t.layerComps={list:[]};for(let i of n.list)t.layerComps.list.push({id:i.compID,name:i["Nm "],capturedInfo:i.capturedInfo}),"comment"in i&&(t.layerComps.list[t.layerComps.list.length-1].comment=i.comment);"lastAppliedComp"in n&&(t.layerComps.lastApplied=n.lastAppliedComp)},(e,t)=>{let n=t.layerComps,i={list:[]};for(let o of n.list){let r={};r._classID="Comp",r["Nm "]=o.name,"comment"in o&&(r.comment=o.comment),r.compID=o.id,r.capturedInfo=o.capturedInfo,i.list.push(r)}"lastApplied"in n&&(i.lastAppliedComp=n.lastApplied),(0,q.writeVersionAndDescriptor)(e,"","CompList",i)});Ie.MOCK_HANDLERS&&H(1092,e=>e._ir1092!==void 0,(e,t,n)=>{Je&&console.log("image resource 1092",n()),t._ir1092=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1092)});var Sl=["normal",void 0,void 0,void 0,void 0,void 0,void 0,"multiply","screen",void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,"difference"];H(1078,e=>e.onionSkins!==void 0,(e,t)=>{let n=(0,q.readVersionAndDescriptor)(e);t.onionSkins={enabled:n.enab,framesBefore:n.numBefore,framesAfter:n.numAfter,frameSpacing:n.Spcn,minOpacity:n.minOpacity/100,maxOpacity:n.maxOpacity/100,blendMode:Sl[n.BlnM]||"normal"}},(e,t)=>{let n=t.onionSkins,i={Vrsn:1,enab:n.enabled,numBefore:n.framesBefore,numAfter:n.framesAfter,Spcn:n.frameSpacing,minOpacity:n.minOpacity*100|0,maxOpacity:n.maxOpacity*100|0,BlnM:Math.max(0,Sl.indexOf(n.blendMode))};(0,q.writeVersionAndDescriptor)(e,"","null",i)});H(1075,e=>e.timelineInformation!==void 0,(e,t)=>{var n,i;let o=(0,q.readVersionAndDescriptor)(e);t.timelineInformation={enabled:o.enab,frameStep:(0,q.frac)(o.frameStep),frameRate:o.frameRate,time:(0,q.frac)(o.time),duration:(0,q.frac)(o.duration),workInTime:(0,q.frac)(o.workInTime),workOutTime:(0,q.frac)(o.workOutTime),repeats:o.LCnt,hasMotion:o.hasMotion,globalTracks:(0,q.parseTrackList)(o.globalTrackList,!!e.logMissingFeatures)},!((i=(n=o.audioClipGroupList)===null||n===void 0?void 0:n.audioClipGroupList)===null||i===void 0)&&i.length&&(t.timelineInformation.audioClipGroups=o.audioClipGroupList.audioClipGroupList.map(r=>({id:r.groupID,muted:r.muted,audioClips:r.audioClipList.map(({clipID:s,timeScope:a,muted:l,audioLevel:c,frameReader:d})=>({id:s,start:(0,q.frac)(a.Strt),duration:(0,q.frac)(a.duration),inTime:(0,q.frac)(a.inTime),outTime:(0,q.frac)(a.outTime),muted:l,audioLevel:c,frameReader:{type:d.frameReaderType,mediaDescriptor:d.mediaDescriptor,link:{name:d["Lnk "]["Nm "],fullPath:d["Lnk "].fullPath,relativePath:d["Lnk "].relPath}}}))})))},(e,t)=>{var n;let i=t.timelineInformation,o={Vrsn:1,enab:i.enabled,frameStep:i.frameStep,frameRate:i.frameRate,time:i.time,duration:i.duration,workInTime:i.workInTime,workOutTime:i.workOutTime,LCnt:i.repeats,globalTrackList:(0,q.serializeTrackList)(i.globalTracks),audioClipGroupList:{audioClipGroupList:(n=i.audioClipGroups)===null||n===void 0?void 0:n.map(r=>({groupID:r.id,muted:r.muted,audioClipList:r.audioClips.map(s=>({clipID:s.id,timeScope:{Vrsn:1,Strt:s.start,duration:s.duration,inTime:s.inTime,outTime:s.outTime},frameReader:{frameReaderType:s.frameReader.type,descVersion:1,"Lnk ":{descVersion:1,"Nm ":s.frameReader.link.name,fullPath:s.frameReader.link.fullPath,relPath:s.frameReader.link.relativePath},mediaDescriptor:s.frameReader.mediaDescriptor},muted:s.muted,audioLevel:s.audioLevel}))}))},hasMotion:i.hasMotion};(0,q.writeVersionAndDescriptor)(e,"","null",o,"anim")});H(1076,e=>e.sheetDisclosure!==void 0,(e,t)=>{let n=(0,q.readVersionAndDescriptor)(e);t.sheetDisclosure={},n.sheetTimelineOptions&&(t.sheetDisclosure.sheetTimelineOptions=n.sheetTimelineOptions.map(i=>({sheetID:i.sheetID,sheetDisclosed:i.sheetDisclosed,lightsDisclosed:i.lightsDisclosed,meshesDisclosed:i.meshesDisclosed,materialsDisclosed:i.materialsDisclosed})))},(e,t)=>{let n=t.sheetDisclosure,i={Vrsn:1};n.sheetTimelineOptions&&(i.sheetTimelineOptions=n.sheetTimelineOptions.map(o=>({Vrsn:2,sheetID:o.sheetID,sheetDisclosed:o.sheetDisclosed,lightsDisclosed:o.lightsDisclosed,meshesDisclosed:o.meshesDisclosed,materialsDisclosed:o.materialsDisclosed}))),(0,q.writeVersionAndDescriptor)(e,"","null",i)});H(1054,e=>e.urlsList!==void 0,(e,t)=>{let n=(0,D.readUint32)(e);t.urlsList=[];for(let i=0;i<n;i++){if((0,D.readSignature)(e)!=="slic"&&e.throwForMissingFeatures)throw new Error("Unknown long");let r=(0,D.readUint32)(e),s=(0,D.readUnicodeString)(e);t.urlsList.push({id:r,url:s,ref:"slice"})}},(e,t)=>{let n=t.urlsList;(0,C.writeUint32)(e,n.length);for(let i=0;i<n.length;i++)(0,C.writeSignature)(e,"slic"),(0,C.writeUint32)(e,n[i].id),(0,C.writeUnicodeString)(e,n[i].url)});function vl(e){return{"Top ":e.top,Left:e.left,Btom:e.bottom,Rght:e.right}}function xl(e){return{top:e["Top "],left:e.Left,bottom:e.Btom,right:e.Rght}}function Zi(e,t){return e[Math.max(0,Math.min(e.length-1,t))]}var _l=["autoGenerated","layer","userGenerated"],Al=["noImage","image"],qi=["default"];H(1050,e=>e.slices?e.slices.length:0,(e,t,n)=>{let i=(0,D.readUint32)(e);if(i===6){t.slices||(t.slices=[]);let o=(0,D.readInt32)(e),r=(0,D.readInt32)(e),s=(0,D.readInt32)(e),a=(0,D.readInt32)(e),l=(0,D.readUnicodeString)(e),c=(0,D.readUint32)(e);t.slices.push({bounds:{top:o,left:r,bottom:s,right:a},groupName:l,slices:[]});let d=t.slices[t.slices.length-1].slices;for(let u=0;u<c;u++){let f=(0,D.readUint32)(e),h=(0,D.readUint32)(e),p=Zi(_l,(0,D.readUint32)(e)),S=p=="layer"?(0,D.readUint32)(e):0,m=(0,D.readUnicodeString)(e),b=Zi(Al,(0,D.readUint32)(e)),v=(0,D.readInt32)(e),x=(0,D.readInt32)(e),_=(0,D.readInt32)(e),I=(0,D.readInt32)(e),P=(0,D.readUnicodeString)(e),k=(0,D.readUnicodeString)(e),E=(0,D.readUnicodeString)(e),O=(0,D.readUnicodeString)(e),U=!!(0,D.readUint8)(e),M=(0,D.readUnicodeString)(e),le=Zi(qi,(0,D.readUint32)(e)),me=Zi(qi,(0,D.readUint32)(e)),T=(0,D.readUint8)(e),W=(0,D.readUint8)(e),te=(0,D.readUint8)(e),ne=(0,D.readUint8)(e),Pe=T+W+te+ne===0?"none":T===0?"matte":"color";d.push({id:f,groupId:h,origin:p,associatedLayerId:S,name:m,target:k,message:E,altTag:O,cellTextIsHTML:U,cellText:M,horizontalAlignment:le,verticalAlignment:me,type:b,url:P,bounds:{top:x,left:v,bottom:I,right:_},backgroundColorType:Pe,backgroundColor:{r:W,g:te,b:ne,a:T}})}n()&&(0,q.readVersionAndDescriptor)(e).slices.forEach(f=>{let h=d.find(p=>f.sliceID==p.id);h&&(h.topOutset=f.topOutset,h.leftOutset=f.leftOutset,h.bottomOutset=f.bottomOutset,h.rightOutset=f.rightOutset)})}else if(i===7||i===8){let o=(0,q.readVersionAndDescriptor)(e);t.slices||(t.slices=[]),t.slices.push({groupName:o.baseName,bounds:xl(o.bounds),slices:o.slices.map(r=>Object.assign(Object.assign({},r["Nm "]?{name:r["Nm "]}:{}),{id:r.sliceID,groupId:r.groupID,associatedLayerId:0,origin:q.ESliceOrigin.decode(r.origin),type:q.ESliceType.decode(r.Type),bounds:xl(r.bounds),url:r.url,target:r.null,message:r.Msge,altTag:r.altTag,cellTextIsHTML:r.cellTextIsHTML,cellText:r.cellText,horizontalAlignment:q.ESliceHorzAlign.decode(r.horzAlign),verticalAlignment:q.ESliceVertAlign.decode(r.vertAlign),backgroundColorType:q.ESliceBGColorType.decode(r.bgColorType),backgroundColor:r.bgColor?{r:r.bgColor["Rd "],g:r.bgColor["Grn "],b:r.bgColor["Bl "],a:r.bgColor.alpha}:{r:0,g:0,b:0,a:0},topOutset:r.topOutset||0,leftOutset:r.leftOutset||0,bottomOutset:r.bottomOutset||0,rightOutset:r.rightOutset||0}))})}else throw new Error(`Invalid slices version (${i})`)},(e,t,n)=>{let{bounds:i,groupName:o,slices:r}=t.slices[n];(0,C.writeUint32)(e,6),(0,C.writeInt32)(e,i.top),(0,C.writeInt32)(e,i.left),(0,C.writeInt32)(e,i.bottom),(0,C.writeInt32)(e,i.right),(0,C.writeUnicodeString)(e,o),(0,C.writeUint32)(e,r.length);for(let a=0;a<r.length;a++){let l=r[a],{a:c,r:d,g:u,b:f}=l.backgroundColor;l.backgroundColorType==="none"?c=d=u=f=0:l.backgroundColorType==="matte"&&(c=0,d=u=f=255),(0,C.writeUint32)(e,l.id),(0,C.writeUint32)(e,l.groupId),(0,C.writeUint32)(e,_l.indexOf(l.origin)),l.origin==="layer"&&(0,C.writeUint32)(e,l.associatedLayerId),(0,C.writeUnicodeString)(e,l.name||""),(0,C.writeUint32)(e,Al.indexOf(l.type)),(0,C.writeInt32)(e,l.bounds.left),(0,C.writeInt32)(e,l.bounds.top),(0,C.writeInt32)(e,l.bounds.right),(0,C.writeInt32)(e,l.bounds.bottom),(0,C.writeUnicodeString)(e,l.url),(0,C.writeUnicodeString)(e,l.target),(0,C.writeUnicodeString)(e,l.message),(0,C.writeUnicodeString)(e,l.altTag),(0,C.writeUint8)(e,l.cellTextIsHTML?1:0),(0,C.writeUnicodeString)(e,l.cellText),(0,C.writeUint32)(e,qi.indexOf(l.horizontalAlignment)),(0,C.writeUint32)(e,qi.indexOf(l.verticalAlignment)),(0,C.writeUint8)(e,c),(0,C.writeUint8)(e,d),(0,C.writeUint8)(e,u),(0,C.writeUint8)(e,f)}let s={bounds:vl(i),slices:[]};r.forEach(a=>{let l=Object.assign(Object.assign({sliceID:a.id,groupID:a.groupId,origin:q.ESliceOrigin.encode(a.origin),Type:q.ESliceType.encode(a.type),bounds:vl(a.bounds)},a.name?{"Nm ":a.name}:{}),{url:a.url,null:a.target,Msge:a.message,altTag:a.altTag,cellTextIsHTML:a.cellTextIsHTML,cellText:a.cellText,horzAlign:q.ESliceHorzAlign.encode(a.horizontalAlignment),vertAlign:q.ESliceVertAlign.encode(a.verticalAlignment),bgColorType:q.ESliceBGColorType.encode(a.backgroundColorType)});if(a.backgroundColorType==="color"){let{r:c,g:d,b:u,a:f}=a.backgroundColor;l.bgColor={"Rd ":c,"Grn ":d,"Bl ":u,alpha:f}}l.topOutset=a.topOutset||0,l.leftOutset=a.leftOutset||0,l.bottomOutset=a.bottomOutset||0,l.rightOutset=a.rightOutset||0,s.slices.push(l)}),(0,q.writeVersionAndDescriptor)(e,"","null",s,"slices")});H(1064,e=>e.pixelAspectRatio!==void 0,(e,t)=>{if((0,D.readUint32)(e)>2)throw new Error("Invalid pixelAspectRatio version");t.pixelAspectRatio={aspect:(0,D.readFloat64)(e)}},(e,t)=>{(0,C.writeUint32)(e,2),(0,C.writeFloat64)(e,t.pixelAspectRatio.aspect)});H(1041,e=>e.iccUntaggedProfile!==void 0,(e,t)=>{t.iccUntaggedProfile=!!(0,D.readUint8)(e)},(e,t)=>{(0,C.writeUint8)(e,t.iccUntaggedProfile?1:0)});Ie.MOCK_HANDLERS&&H(1039,e=>e._ir1039!==void 0,(e,t,n)=>{Je&&console.log("image resource 1039",n()),t._ir1039=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1039)});H(1044,e=>e.idsSeedNumber!==void 0,(e,t)=>t.idsSeedNumber=(0,D.readUint32)(e),(e,t)=>(0,C.writeUint32)(e,t.idsSeedNumber));H(1036,e=>e.thumbnail!==void 0||e.thumbnailRaw!==void 0,(e,t,n)=>{let i=(0,D.readUint32)(e),o=(0,D.readUint32)(e),r=(0,D.readUint32)(e);(0,D.readUint32)(e),(0,D.readUint32)(e),(0,D.readUint32)(e);let s=(0,D.readUint16)(e),a=(0,D.readUint16)(e);if(i!==1||s!==24||a!==1){e.logMissingFeatures&&e.log(`Invalid thumbnail data (format: ${i}, bitsPerPixel: ${s}, planes: ${a})`),(0,D.skipBytes)(e,n());return}let l=n(),c=(0,D.readBytes)(e,l);e.useRawThumbnail?t.thumbnailRaw={width:o,height:r,data:c}:c.byteLength&&(t.thumbnail=(0,Ie.createCanvasFromData)(c))},(e,t)=>{var n;let i=0,o=0,r=new Uint8Array(0);if(t.thumbnailRaw)i=t.thumbnailRaw.width,o=t.thumbnailRaw.height,r=t.thumbnailRaw.data;else try{let u=(n=t.thumbnail.toDataURL("image/jpeg",1))===null||n===void 0?void 0:n.substring(23);u&&(r=(0,Ah.toByteArray)(u),i=t.thumbnail.width,o=t.thumbnail.height)}catch{}let s=24,a=Math.floor((i*s+31)/32)*4,l=1,c=a*o*l,d=r.length;(0,C.writeUint32)(e,1),(0,C.writeUint32)(e,i),(0,C.writeUint32)(e,o),(0,C.writeUint32)(e,a),(0,C.writeUint32)(e,c),(0,C.writeUint32)(e,d),(0,C.writeUint16)(e,s),(0,C.writeUint16)(e,l),(0,C.writeBytes)(e,r)});H(1057,e=>e.versionInfo!==void 0,(e,t,n)=>{if((0,D.readUint32)(e)!==1)throw new Error("Invalid versionInfo version");t.versionInfo={hasRealMergedData:!!(0,D.readUint8)(e),writerName:(0,D.readUnicodeString)(e),readerName:(0,D.readUnicodeString)(e),fileVersion:(0,D.readUint32)(e)},(0,D.skipBytes)(e,n())},(e,t)=>{let n=t.versionInfo;(0,C.writeUint32)(e,1),(0,C.writeUint8)(e,n.hasRealMergedData?1:0),(0,C.writeUnicodeString)(e,n.writerName),(0,C.writeUnicodeString)(e,n.readerName),(0,C.writeUint32)(e,n.fileVersion)});Ie.MOCK_HANDLERS&&H(1058,e=>e._ir1058!==void 0,(e,t,n)=>{Je&&console.log("image resource 1058",n()),t._ir1058=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1058)});H(7e3,e=>e.imageReadyVariables!==void 0,(e,t,n)=>{t.imageReadyVariables=Sr(e,n())},(e,t)=>{vr(e,t.imageReadyVariables)});H(7001,e=>e.imageReadyDataSets!==void 0,(e,t,n)=>{t.imageReadyDataSets=Sr(e,n())},(e,t)=>{vr(e,t.imageReadyDataSets)});H(1088,e=>e.pathSelectionState!==void 0,(e,t,n)=>{let i=(0,q.readVersionAndDescriptor)(e);t.pathSelectionState=i.null},(e,t)=>{let n={null:t.pathSelectionState};(0,q.writeVersionAndDescriptor)(e,"","null",n)});Ie.MOCK_HANDLERS&&H(1025,e=>e._ir1025!==void 0,(e,t,n)=>{Je&&console.log("image resource 1025",n()),t._ir1025=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir1025)});var kl=(0,Ie.createEnum)("FrmD","auto",{auto:"Auto",none:"None",dispose:"Disp"});H(4e3,e=>e.animations!==void 0,(e,t,n)=>{let i=(0,D.readSignature)(e);if(i==="mani")(0,D.checkSignature)(e,"IRFR"),(0,D.readSection)(e,1,o=>{for(;o()>0;){(0,D.checkSignature)(e,"8BIM");let r=(0,D.readSignature)(e);(0,D.readSection)(e,1,s=>{if(r==="AnDs"){let a=(0,q.readVersionAndDescriptor)(e);t.animations={frames:a.FrIn.map(l=>({id:l.FrID,delay:(l.FrDl||0)/100,dispose:l.FrDs?kl.decode(l.FrDs):"auto"})),animations:a.FSts.map(l=>({id:l.FsID,frames:l.FsFr,repeats:l.LCnt,activeFrame:l.AFrm||0}))}}else if(r==="Roll"){let a=(0,D.readBytes)(e,s());e.logDevFeatures&&e.log("#4000 Roll",a)}else e.logMissingFeatures&&e.log("Unhandled subsection in #4000",r)})}});else if(i==="mopt"){let o=(0,D.readBytes)(e,n());e.logDevFeatures&&e.log("#4000 mopt",o)}else e.logMissingFeatures&&e.log("Unhandled key in #4000:",i)},(e,t)=>{t.animations&&((0,C.writeSignature)(e,"mani"),(0,C.writeSignature)(e,"IRFR"),(0,C.writeSection)(e,1,()=>{(0,C.writeSignature)(e,"8BIM"),(0,C.writeSignature)(e,"AnDs"),(0,C.writeSection)(e,1,()=>{let n={FrIn:[],FSts:[]};for(let i=0;i<t.animations.frames.length;i++){let o=t.animations.frames[i],r={FrID:o.id};o.delay&&(r.FrDl=o.delay*100|0),r.FrDs=kl.encode(o.dispose),n.FrIn.push(r)}for(let i=0;i<t.animations.animations.length;i++){let o=t.animations.animations[i],r={FsID:o.id,AFrm:o.activeFrame|0,FsFr:o.frames,LCnt:o.repeats|0};n.FSts.push(r)}(0,q.writeVersionAndDescriptor)(e,"","null",n)})}))});Ie.MOCK_HANDLERS&&H(4001,e=>e._ir4001!==void 0,(e,t,n)=>{if(Ie.MOCK_HANDLERS){Je&&console.log("image resource 4001",n()),t._ir4001=(0,D.readBytes)(e,n());return}let i=(0,D.readSignature)(e);if(i==="mfri"){if((0,D.readUint32)(e)!==2)throw new Error("Invalid mfri version");let r=(0,D.readUint32)(e),s=(0,D.readBytes)(e,r);e.logDevFeatures&&e.log("mfri",s)}else if(i==="mset"){let o=(0,q.readVersionAndDescriptor)(e);e.logDevFeatures&&e.log("mset",o)}else e.logMissingFeatures&&e.log("Unhandled key in #4001",i)},(e,t)=>{(0,C.writeBytes)(e,t._ir4001)});Ie.MOCK_HANDLERS&&H(4002,e=>e._ir4002!==void 0,(e,t,n)=>{Je&&console.log("image resource 4002",n()),t._ir4002=(0,D.readBytes)(e,n())},(e,t)=>{(0,C.writeBytes)(e,t._ir4002)})});var jt=oe(N=>{"use strict";var Ch=N&&N.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(n[i[o]]=e[i[o]]);return n};Object.defineProperty(N,"__esModule",{value:!0});N.supportedColorModes=void 0;N.createReader=to;N.warnOrThrow=Qi;N.readUint8=ge;N.peekUint8=Pl;N.readInt16=Nt;N.readUint16=re;N.readUint16LE=El;N.readInt32=Re;N.readInt32LE=Lh;N.readUint32=pe;N.readFloat32=Bh;N.readFloat64=kr;N.readFixedPoint32=Uh;N.readFixedPointPath32=Rh;N.readBytes=yt;N.readSignature=oi;N.validSignatureAt=Fl;N.readPascalString=no;N.readUnicodeString=Ol;N.readUnicodeStringWithLength=Ll;N.readUnicodeStringWithLengthLE=Mh;N.readAsciiString=Th;N.skipBytes=Se;N.checkSignature=Er;N.readPsd=zh;N.readLayerInfo=Ul;N.getCompositeImageData=Rl;N.getCompositeCanvas=Hh;N.getLayerImageData=Ml;N.getLayerMaskImageData=Tl;N.getLayerRealMaskImageData=jl;N.getLayerCanvas=Wh;N.getLayerMaskCanvas=Xh;N.getLayerRealMaskCanvas=Zh;N.decodeLayerPixels=qh;N.readGlobalLayerMaskInfo=$l;N.readAdditionalLayerInfo=Fr;N.readDataZip=Pr;N.readDataRLE=$t;N.readSection=ot;N.readColor=e0;N.readPattern=t0;var Ph=fr(),De=Tt(),Eh=oo(),Fh=xr();N.supportedColorModes=[0,1,3,2];var Oh=["bitmap","grayscale","indexed","RGB","CMYK","","","multichannel","duotone","lab"];function Ji(e){let t=e.width*e.height*4;for(let n=0;n<t;n+=4){let i=e.data[n];e.data[n+1]=i,e.data[n+2]=i}}function to(e,t,n){return{view:new DataView(e,t,n),offset:0,strict:!1,debug:!1,large:!1,globalAlpha:!1,log:console.log}}function Qi(e,t){if(e.strict)throw new Error(t);e.debug&&e.log(t)}function ge(e){return e.offset+=1,e.view.getUint8(e.offset-1)}function Pl(e){return e.view.getUint8(e.offset)}function Nt(e){return e.offset+=2,e.view.getInt16(e.offset-2,!1)}function re(e){return e.offset+=2,e.view.getUint16(e.offset-2,!1)}function El(e){return e.offset+=2,e.view.getUint16(e.offset-2,!0)}function Re(e){return e.offset+=4,e.view.getInt32(e.offset-4,!1)}function Lh(e){return e.offset+=4,e.view.getInt32(e.offset-4,!0)}function pe(e){return e.offset+=4,e.view.getUint32(e.offset-4,!1)}function Bh(e){return e.offset+=4,e.view.getFloat32(e.offset-4,!1)}function kr(e){return e.offset+=8,e.view.getFloat64(e.offset-8,!1)}function Uh(e){return Re(e)/65536}function Rh(e){return Re(e)/(1<<24)}function yt(e,t){let n=e.view.byteOffset+e.offset;if(e.offset+=t,n+t>e.view.buffer.byteLength){if(Qi(e,"Reading bytes exceeding buffer length"),t>100*1024*1024)throw new Error("Reading past end of file");let i=new Uint8Array(t),o=Math.min(t,e.view.byteLength-n);return o>0&&i.set(new Uint8Array(e.view.buffer,n,o)),i}else return new Uint8Array(e.view.buffer,n,t)}function oi(e){return Bl(e,4)}function Fl(e,t){let n=String.fromCharCode(e.view.getUint8(t))+String.fromCharCode(e.view.getUint8(t+1))+String.fromCharCode(e.view.getUint8(t+2))+String.fromCharCode(e.view.getUint8(t+3));return n=="8BIM"||n=="8B64"}function no(e,t){let n=ge(e),i=n?Bl(e,n):"";for(;++n%t;)e.offset++;return i}function Ol(e){let t=pe(e);return Ll(e,t)}function Ll(e,t){let n="";for(;t--;){let i=re(e);(i||t>0)&&(n+=String.fromCharCode(i))}return n}function Mh(e,t){let n="";for(;t--;){let i=El(e);(i||t>0)&&(n+=String.fromCharCode(i))}return n}function Th(e,t){let n="";for(;t--;)n+=String.fromCharCode(ge(e));return n}function Se(e,t){e.offset+=t}function Er(e,t,n){let i=e.offset,o=oi(e);if(o!==t&&o!==n)throw new Error(`Invalid signature: '${o}' at 0x${i.toString(16)}`)}function Bl(e,t){let n=yt(e,t),i="";for(let o=0;o<n.length;o++)i+=String.fromCharCode(n[o]);return i}function jh(e){return e==="8BIM"||e==="MeSa"||e==="AgHg"||e==="PHUT"||e==="DCSR"}function zh(e,t={}){var n;Er(e,"8BPS");let i=re(e);if(i!==1&&i!==2)throw new Error(`Invalid PSD file version: ${i}`);Se(e,6);let o=re(e),r=pe(e),s=pe(e),a=re(e),l=re(e),c=i===1?3e4:3e5;if(s>c||r>c)throw new Error(`Invalid size: ${s}x${r}`);if(o>16)throw new Error(`Invalid channel count: ${o}`);if(![1,8,16,32].includes(a))throw new Error(`Invalid bitsPerChannel: ${a}`);if(N.supportedColorModes.indexOf(l)===-1)throw new Error(`Color mode not supported: ${(n=Oh[l])!==null&&n!==void 0?n:l}`);let d={width:s,height:r,channels:o,bitsPerChannel:a,colorMode:l};Object.assign(e,t),e.large=i===2,e.globalAlpha=!1,"totalMemoryLimit"in e||(e.totalMemoryLimit=2*1024*1024*1024),ot(e,1,b=>{if(b()){if(l===2){if(b()!=768)throw new Error("Invalid color palette size");d.palette=[];for(let v=0;v<256;v++)d.palette.push({r:ge(e),g:0,b:0});for(let v=0;v<256;v++)d.palette[v].g=ge(e);for(let v=0;v<256;v++)d.palette[v].b=ge(e)}Se(e,b())}});let u={};ot(e,1,b=>{for(;b()>0;){Nl(e,jh);let v=re(e);no(e,2),ot(e,2,x=>{let _=Fh.resourceHandlersMap[v],I=v===1036&&!!e.skipThumbnail;if(_&&!I)try{_.read(e,u,x)}catch(P){if(e.throwForMissingFeatures)throw P;Se(e,x())}else Se(e,x())})}});let{layersGroup:f,layerGroupsEnabledId:h}=u,p=Ch(u,["layersGroup","layerGroupsEnabledId"]);Object.keys(p).length&&(d.imageResources=p),ot(e,1,b=>{if(ot(e,2,v=>{Ul(e,d,u),Se(e,v())},void 0,e.large),b()>0){let v=$l(e);v&&(d.globalLayerMaskInfo=v)}else Se(e,b());for(;b()>0;){for(;b()&&Pl(e)===0;)Se(e,1);b()>=12?Fr(e,d,d,u):Se(e,b())}},void 0,e.large);let S=d.children&&d.children.length;if(!(e.skipCompositeImageData&&(e.skipLayerImageData||S)))if(e.useRawData)d.rawCompositeData=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset);else{let b=Vl(e,d);e.useImageData?d.imageData=b:d.canvas=(0,De.imageDataToCanvas)(b)}return d}function Ul(e,t,n){var i,o;let{layersGroup:r=[],layerGroupsEnabledId:s=[]}=n,a=Nt(e);a<0&&(e.globalAlpha=!0,a=-a);let l=[],c=[];for(let u=0;u<a;u++){let{layer:f,channels:h}=$h(e,t,n);r[u]!==void 0&&(f.linkGroup=r[u]),s[u]!==void 0&&(f.linkGroupEnabled=!!s[u]),l.push(f),c.push(h)}for(let u=0;u<a;u++)Gh(e,t,l[u],c[u]);t.children||(t.children=[]);let d=[t];for(let u=l.length-1;u>=0;u--){let f=l[u],h=f.sectionDivider?f.sectionDivider.type:0;h===1||h===2?(f.opened=h===1,f.children=[],!((i=f.sectionDivider)===null||i===void 0)&&i.key&&(f.blendMode=(o=De.toBlendMode[f.sectionDivider.key])!==null&&o!==void 0?o:f.blendMode),d[d.length-1].children.unshift(f),d.push(f)):h===3?d.pop():d[d.length-1].children.unshift(f)}}function $h(e,t,n){let i={};if(i.top=Re(e),i.left=Re(e),i.bottom=Re(e),i.right=Re(e),!Ir(i,e))throw new Error("Invalid layer size");let o=re(e),r=[];for(let l=0;l<o;l++){let c=Nt(e),d=pe(e);if(e.large){if(d!==0)throw new Error("Sizes larger than 4GB are not supported");d=pe(e)}r.push({id:c,length:d})}Er(e,"8BIM");let s=oi(e);if(!De.toBlendMode[s])throw new Error(`Invalid blend mode: '${s}'`);i.blendMode=De.toBlendMode[s],i.opacity=ge(e)/255,i.clipping=ge(e)===1;let a=ge(e);return i.transparencyProtected=(a&1)!==0,i.hidden=(a&2)!==0,a&32&&(i.effectsOpen=!0),Se(e,1),ot(e,1,l=>{Nh(e,i);let c=Vh(e);for(c&&(i.blendingRanges=c),i.name=no(e,1);l()>4&&!Fl(e,e.offset);)e.offset++;for(;l()>=12;)Fr(e,i,t,n);Se(e,l())}),{layer:i,channels:r}}function Ir(e,t){let n=(e.right||0)-(e.left||0),i=(e.bottom||0)-(e.top||0),o=t.large?3e5:3e4;return n>=0&&i>=0&&n<=o&&i<=o}function Nh(e,t){return ot(e,1,n=>{if(!n())return;let i={};if(t.mask=i,i.top=Re(e),i.left=Re(e),i.bottom=Re(e),i.right=Re(e),!Ir(i,e))throw new Error("Invalid mask size");i.defaultColor=ge(e);let o=ge(e);if(i.positionRelativeToLayer=(o&1)!==0,i.disabled=(o&2)!==0,i.fromVectorData=(o&8)!==0,n()>=18){let r={};t.realMask=r;let s=ge(e);if(r.positionRelativeToLayer=(s&1)!==0,r.disabled=(s&2)!==0,r.fromVectorData=(s&8)!==0,r.defaultColor=ge(e),r.top=Re(e),r.left=Re(e),r.bottom=Re(e),r.right=Re(e),!Ir(r,e))throw new Error("Invalid realMask size")}if(o&16){let r=ge(e);r&1&&(i.userMaskDensity=ge(e)/255),r&2&&(i.userMaskFeather=kr(e)),r&4&&(i.vectorMaskDensity=ge(e)/255),r&8&&(i.vectorMaskFeather=kr(e))}Se(e,n())})}function Yi(e){return[ge(e),ge(e),ge(e),ge(e)]}function Vh(e){return ot(e,1,t=>{let n=Yi(e),i=Yi(e),o=[];for(;t()>0;){let r=Yi(e),s=Yi(e);o.push({sourceRange:r,destRange:s})}return{compositeGrayBlendSource:n,compositeGraphBlendDestinationRange:i,ranges:o}})}function Gh(e,t,n,i){if(e.skipLayerImageData)return;let{colorMode:o=3,bitsPerChannel:r=8}=t;n.rawData={colorMode:o,bitsPerChannel:r,channels:[],large:e.large};for(let s of i){let a=e.offset,l=0,c;if(s.length===1)throw new Error("Invalid channel length");if(s.length){if(l=re(e),l>3&&(e.offset-=1,l=re(e)),l>3&&(e.offset-=3,l=re(e)),l>3)throw new Error(`Invalid compression: ${l}`);s.length>2&&(c=yt(e,s.length-2))}e.offset=a+s.length,n.rawData.channels.push({id:s.id,compression:l,data:c})}e.useRawData||zl(n,e)}function Il({data:e},t){let n=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255,i=(t?4:3)|0,o=e.length|0,r=(t?5:4)|0;for(let s=i;s<o;s=s+r|0)e[s]=n}function Rl(e){let t=e.rawCompositeData;if(!t)return;let n=to(t.buffer,t.byteOffset,t.byteLength);return Vl(n,e)}function Hh(e){return io(Rl(e))}function Ml(e){return Cn(e,We.Layer,!1,void 0)}function Tl(e){return Cn(e,We.Mask,!1,void 0)}function jl(e){return Cn(e,We.RealMask,!1,void 0)}function Wh(e){return io(Ml(e))}function Xh(e){return io(Tl(e))}function Zh(e){return io(jl(e))}function io(e){return e&&(0,De.imageDataToCanvas)(e)}function _r(e,t,n){t&&(n?e.imageData=t:e.canvas=(0,De.imageDataToCanvas)(t))}function qh(e,t){zl(e,{useImageData:t})}function zl(e,t){var n,i,o;let{throwForMissingFeatures:r,useImageData:s}=t,a=Cn(e,We.Layer,r,t.totalMemoryLimit);if(_r(e,a,s),t.totalMemoryLimit!==void 0&&(t.totalMemoryLimit-=(n=a?.data.byteLength)!==null&&n!==void 0?n:0),e.mask){let l=Cn(e,We.Mask,r,t.totalMemoryLimit);_r(e.mask,l,s),t.totalMemoryLimit!==void 0&&(t.totalMemoryLimit-=(i=l?.data.byteLength)!==null&&i!==void 0?i:0)}if(e.realMask){let l=Cn(e,We.RealMask,r,t.totalMemoryLimit);_r(e.realMask,l,s),t.totalMemoryLimit!==void 0&&(t.totalMemoryLimit-=(o=l?.data.byteLength)!==null&&o!==void 0?o:0)}delete e.rawData}var We;(function(e){e[e.Layer=0]="Layer",e[e.Mask=1]="Mask",e[e.RealMask=2]="RealMask"})(We||(We={}));function Cn(e,t,n,i){if(!e.rawData)return;let{colorMode:o,bitsPerChannel:r,channels:s,large:a}=e.rawData,l=Math.max(0,(e.right||0)-(e.left||0)),c=Math.max(0,(e.bottom||0)-(e.top||0)),d=o===4,u,f,h=!1;if(l&&c&&t===We.Layer)if(d){if(r!==8)throw new Error("bitsPerChannel Not supproted");u={width:l,height:c,data:new Uint8ClampedArray(l*c*5)}}else u=Dr(l,c,r,4,i);De.RAW_IMAGE_DATA&&(e.imageDataRaw=[],e.imageDataRawCompression=[]);for(let{id:p,compression:S,data:m}of s){if(!m)continue;let b=to(m.buffer,m.byteOffset,m.byteLength);if(p===-2||p===-3){if(p===-2&&t!==We.Mask||p===-3&&t!==We.RealMask)continue;let v=p===-2?e.mask:e.realMask;if(!v)throw new Error(`Missing layer ${p===-2?"mask":"real mask"} data`);let x=Math.max(0,(v.right||0)-(v.left||0)),_=Math.max(0,(v.bottom||0)-(v.top||0));x&&_&&(f=Dr(x,_,r,4,i),Dl(b,m.byteLength,f,S,x,_,r,0,a,4),De.RAW_IMAGE_DATA&&(p===-2?(e.maskDataRawCompression=S,e.maskDataRaw=m):(e.realMaskDataRawCompression=S,e.realMaskDataRaw=m)),Ji(f),Il(f,!1))}else{if(t!==We.Layer)continue;let v=(0,De.offsetForChannel)(p,d),x=u;if(v<0&&(x=void 0,n))throw new Error(`Channel not supported: ${p}`);Dl(b,m.byteLength,x,S,l,c,r,v,a,d?5:4),De.RAW_IMAGE_DATA&&(e.imageDataRawCompression[p]=S,e.imageDataRaw[p]=m),x&&o===1&&Ji(x)}p===-1&&(h=!0)}if(u&&(h||Il(u,d),d)){let p=u;u=(0,De.createImageData)(p.width,p.height),Gl(p,u,!1)}return t===We.Layer?u:f}function Dl(e,t,n,i,o,r,s,a,l,c){if(t)if(i===0){t!==o*r*Math.floor(s/8)&&e.log(`Invalid length (${t}, ${o*r*Math.floor(s/8)})`);let d=yt(e,t);Wl(d,n,s,c,a)}else if(i===1)$t(e,n,o,r,s,c,[a],l);else if(i===2){let d=yt(e,t);Pr(d,n,o,r,s,c,a,!1)}else if(i===3){let d=yt(e,t);Pr(d,n,o,r,s,c,a,!0)}else throw new Error(`Invalid Compression type: ${i}`)}function $l(e){return ot(e,1,t=>{if(!t())return;let n=re(e),i=re(e),o=re(e),r=re(e),s=re(e),a=re(e)/255,l=ge(e);return Se(e,t()),{overlayColorSpace:n,colorSpace1:i,colorSpace2:o,colorSpace3:r,colorSpace4:s,opacity:a,kind:l}})}var Kh=[0,1,-1,2,-2,3,-3,4,-4];function Nl(e,t){let n=e.offset,i="";for(let o of Kh){try{e.offset=n+o,i=oi(e)}catch{}if(t(i))break}if(!t(i))throw new Error(`Invalid signature: '${i}' at 0x${n.toString(16)}`);return i}function Yh(e){return e==="8BIM"||e==="8B64"}function Fr(e,t,n,i){let o=Nl(e,Yh),r=oi(e),s=o==="8B64"||e.large&&De.largeAdditionalInfoKeys.indexOf(r)!==-1;ot(e,2,a=>{let l=Eh.infoHandlersMap[r];if(l)try{l.read(e,t,a,n,i)}catch(c){if(e.throwForMissingFeatures)throw c}else e.logMissingFeatures&&e.log(`Unhandled additional info: ${r}`),Se(e,a());a()&&(e.logMissingFeatures&&e.log(`Unread ${a()} bytes left for additional info: ${r}`),Se(e,a()))},!1,s)}function Dr(e,t,n,i,o){let r=e*t*i*Math.max(1,n/8);if(o!==void 0&&r>o)throw new Error("Exceeded memory limit");if(n===1||n===8)return i===4?(0,De.createImageData)(e,t):{width:e,height:t,data:new Uint8ClampedArray(e*t*i)};if(n===16)return{width:e,height:t,data:new Uint16Array(e*t*i)};if(n===32)return{width:e,height:t,data:new Float32Array(e*t*i)};throw new Error(`Invalid bitDepth (${n})`)}function Vl(e,t){var n;let i=re(e),o=(n=t.bitsPerChannel)!==null&&n!==void 0?n:8;if(N.supportedColorModes.indexOf(t.colorMode)===-1)throw new Error(`Color mode not supported: ${t.colorMode}`);if(i!==0&&i!==1)throw new Error(`Compression type not supported: ${i}`);let r=Dr(t.width,t.height,o,4,e.totalMemoryLimit);switch(e.totalMemoryLimit!==void 0&&(e.totalMemoryLimit-=r.data.byteLength),(0,De.resetImageData)(r),t.colorMode){case 0:{if(o!==1)throw new Error("Invalid bitsPerChannel for bitmap color mode");let s;if(i===0)s=yt(e,Math.ceil(t.width/8)*t.height);else if(i===1)s=new Uint8Array(t.width*t.height),$t(e,{data:s,width:t.width,height:t.height},t.width,t.height,8,1,[0],e.large);else throw new Error(`Compression not supported: ${i}`);(0,De.decodeBitmap)(s,r.data,t.width,t.height);break}case 3:case 1:{let s=t.colorMode===1?[0]:[0,1,2];if(t.channels&&t.channels>3)for(let a=3;a<t.channels;a++)s.push(a);else e.globalAlpha&&s.push(3);if(i===0)for(let a=0;a<s.length;a++){let l=yt(e,t.width*t.height*Math.floor(o/8));Wl(l,r,o,4,s[a])}else if(i===1){let a=e.offset;$t(e,r,t.width,t.height,o,4,s,e.large),De.RAW_IMAGE_DATA&&(t.imageDataRaw=new Uint8Array(e.view.buffer,e.view.byteOffset+a,e.offset-a))}else throw new Error(`Compression not supported: ${i}`);t.colorMode===1&&Ji(r);break}case 2:{if(o!==8)throw new Error("bitsPerChannel Not supproted");if(t.channels!==1)throw new Error("Invalid channel count");if(!t.palette)throw new Error("Missing color palette");if(i===0)throw new Error(`Compression not supported: ${i}`);if(i===1){let s={width:r.width,height:r.height,data:new Uint8Array(r.width*r.height)};$t(e,s,t.width,t.height,o,1,[0],e.large),Jh(s,r,t.palette)}else throw new Error(`Compression not supported: ${i}`);break}case 4:{if(o!==8)throw new Error("bitsPerChannel Not supproted");if(t.channels!==4)throw new Error("Invalid channel count");let s=[0,1,2,3];if(e.globalAlpha&&s.push(4),i===0)throw new Error(`Compression not supported: ${i}`);if(i===1){let a={width:r.width,height:r.height,data:new Uint8Array(r.width*r.height*5)},l=e.offset;$t(e,a,t.width,t.height,o,5,s,e.large),Gl(a,r,!0),De.RAW_IMAGE_DATA&&(t.imageDataRaw=new Uint8Array(e.view.buffer,e.view.byteOffset+l,e.offset-l))}else throw new Error(`Compression not supported: ${i}`);break}default:throw new Error(`Color mode not supported: ${t.colorMode}`)}if(e.globalAlpha){if(t.bitsPerChannel!==8)throw new Error("bitsPerChannel Not supproted");let s=r.data,a=r.width*r.height*4;for(let l=0;l<a;l+=4){let c=s[l+3];if(c!=0&&c!=255){let u=1/(c/255),f=255*(1-u);s[l+0]=s[l+0]*u+f,s[l+1]=s[l+1]*u+f,s[l+2]=s[l+2]*u+f}}}return r}function Gl(e,t,n){let i=t.width*t.height*4,o=e.data,r=t.data;for(let s=0,a=0;a<i;s+=5,a+=4){let l=o[s],c=o[s+1],d=o[s+2],u=o[s+3];r[a]=(l*u|0)/255|0,r[a+1]=(c*u|0)/255|0,r[a+2]=(d*u|0)/255|0,r[a+3]=n?255-o[s+4]:o[s+4]}}function Jh(e,t,n){let i=e.width*e.height,o=e.data,r=t.data;for(let s=0,a=0;s<i;s++,a+=4){let l=n[o[s]];r[a+0]=l.r,r[a+1]=l.g,r[a+2]=l.b,r[a+3]=255}}function Qh(e,t){if(e.byteLength/e.length!==t.byteLength/t.length)throw new Error("Invalid array types")}function Hl(e,t){if(t===8)return e;if(t===16){for(let n=0;n<e.byteLength;n+=2){let i=e[n];e[n]=e[n+1],e[n+1]=i}if(e.byteOffset%2){let n=new Uint16Array(e.byteLength/2);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength).set(e),n}else return new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2)}else if(t===32)if(e.byteOffset%4){let n=new Float32Array(e.byteLength/4);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength).set(e),n}else return new Float32Array(e.buffer,e.byteOffset,e.byteLength/4);else throw new Error(`Invalid bitDepth (${t})`)}function Cr(e,t,n,i){Qh(e.data,t);let o=e.width*e.height,r=e.data;for(let s=0,a=n|0;s<o;s++,a=a+i|0)r[a]=t[s]}function Wl(e,t,n,i,o){if(n==32)for(let s=0;s<e.byteLength;s+=4){let a=e[s+0],l=e[s+1],c=e[s+2],d=e[s+3];e[s+0]=d,e[s+1]=c,e[s+2]=l,e[s+3]=a}let r=Hl(e,n);t&&o<i&&Cr(t,r,o,i)}function Ar(e,t,n,i){for(let o=0;o<n;o++){let r=o*t;for(let s=1,a=r+1;s<t;s++,a++)e[a]=(e[a-1]+e[a])%i}}function Pr(e,t,n,i,o,r,s,a){let l=(0,Ph.inflate)(e);if(t&&s<r){let c=Hl(l,o);if(o===8)a&&Ar(l,n,i,256),Cr(t,l,s,r);else if(o===16)a&&Ar(c,n,i,65536),Cr(t,c,s,r);else if(o===32){a&&Ar(l,n*4,i,256);let d=s,u=new Uint32Array(t.data.buffer,t.data.byteOffset,t.data.length);for(let f=0;f<i;f++){let h=n*4*f;for(let p=0;p<n;p++,h++,d+=r){let S=h+n,m=S+n,b=m+n;u[d]=(l[h]<<24|l[S]<<16|l[m]<<8|l[b])>>>0}}}else throw new Error("Invalid bitDepth")}}function $t(e,t,n,i,o,r,s,a){let l=t&&t.data,c;if(a){eo(e,s.length*i*4),c=new Uint32Array(s.length*i);for(let u=0,f=0;u<s.length;u++)for(let h=0;h<i;h++,f++)c[f]=pe(e)}else{eo(e,s.length*i*2),c=new Uint16Array(s.length*i);for(let u=0,f=0;u<s.length;u++)for(let h=0;h<i;h++,f++)c[f]=re(e)}let d=r-1|0;for(let u=0,f=0;u<s.length;u++){let h=s[u]|0,p=u>d||h>d;if(!l||p)for(let S=0;S<i;S++,f++)Se(e,c[f]);else for(let S=0,m=h|0;S<i;S++,f++){let b=c[f],v=yt(e,b);for(let x=0,_=0;x<b;x++){let I=v[x];if(I>128){let P=v[++x];I=256-I|0;for(let k=0;k<=I&&_<n;k=k+1|0,_=_+1|0)l[m]=P,m=m+r|0}else if(I<128)for(let P=0;P<=I&&_<n;P=P+1|0,_=_+1|0)l[m]=v[++x],m=m+r|0}}}Xl(e,c.byteLength)}function ot(e,t,n,i=!0,o=!1){let r=pe(e);if(o){if(r!==0)throw new Error("Sizes larger than 4GB are not supported");r=pe(e)}if(r<=0&&i)return;let s=e.offset+r;if(s>e.view.byteLength)throw new Error("Section exceeds file size");let a=n(()=>s-e.offset);for(e.offset!==s&&(e.offset>s?Qi(e,"Exceeded section limits"):Qi(e,"Unread section data"));r%t;)r++,s++;return e.offset=s,a}function e0(e){switch(re(e)){case 0:{let n=re(e)/257,i=re(e)/257,o=re(e)/257;return Se(e,2),{r:n,g:i,b:o}}case 1:{let n=re(e)/65535,i=re(e)/65535,o=re(e)/65535;return Se(e,2),{h:n,s:i,b:o}}case 2:{let n=re(e)/257,i=re(e)/257,o=re(e)/257,r=re(e)/257;return{c:n,m:i,y:o,k:r}}case 7:{let n=Nt(e)/1e4,i=Nt(e),o=Nt(e),r=i<0?i/12800:i/12700,s=o<0?o/12800:o/12700;return Se(e,2),{l:n,a:r,b:s}}case 8:{let n=re(e)*255/1e4;return Se(e,6),{k:n}}default:throw new Error("Invalid color space")}}function t0(e){let t=pe(e);for(;t%4;)t++;let n=e.offset+t,i=pe(e);if(i!==1)throw new Error(`Invalid pattern version: ${i}`);let o=pe(e),r=Nt(e),s=Nt(e);if(o!==3&&o!==1&&o!==2)throw new Error(`Unsupported pattern color mode: ${o}`);let a=Ol(e),l=no(e,1),c=[];if(o===2){for(let _=0;_<256;_++)c.push({r:ge(e),g:ge(e),b:ge(e)});Se(e,4)}let d=pe(e);if(d!==3)throw new Error(`Invalid pattern VMAL version: ${d}`);pe(e);let u=pe(e),f=pe(e),h=pe(e),p=pe(e),S=pe(e),m=p-f,b=h-u,v=m*b*4;eo(e,v);let x=new Uint8Array(v);for(let _=3;_<x.byteLength;_+=4)x[_]=255;for(let _=0,I=0;_<S+2;_++){if(!pe(e))continue;let k=pe(e),E=pe(e),O=pe(e),U=pe(e),M=pe(e),le=pe(e),me=re(e),T=ge(e),W=k-23,te=yt(e,W);if(E!==8||me!==8)throw new Error("16bit pixel depth not supported for patterns");let ne=le-U,Pe=M-O,Ee=U-f,j=O-u;if(T===0){if(o===3&&I<3)for(let R=0;R<Pe;R++)for(let V=0;V<ne;V++){let fe=V+R*ne,ie=(Ee+V+(R+j)*m)*4;x[ie+I]=te[fe]}else if(o===1&&I<1)for(let R=0;R<Pe;R++)for(let V=0;V<ne;V++){let fe=V+R*ne,ie=(Ee+V+(R+j)*m)*4,he=te[fe];x[ie+0]=he,x[ie+1]=he,x[ie+2]=he}else if(o===2)for(let R=0;R<Pe;R++)for(let V=0;V<ne;V++){let fe=V+R*ne,ie=(Ee+V+(R+j)*m)*4,he=te[fe],we=c[he];x[ie+0]=we.r,x[ie+1]=we.g,x[ie+2]=we.b}else if(e.throwForMissingFeatures)throw new Error("Invalid color pattern")}else if(T===1){eo(e,ne*Pe);let R={data:x,width:m,height:b},V={data:new Uint8Array(ne*Pe),width:ne,height:Pe},fe=to(te.buffer,te.byteOffset,te.byteLength);if(o===3&&I<3&&($t(fe,V,ne,Pe,8,1,[0],!1),Cl(V,R,Ee,j,I)),o===1&&I<1&&($t(fe,V,ne,Pe,8,1,[0],!1),Cl(V,R,Ee,j,0),Ji(R)),o===2)throw new Error("Indexed pattern color mode not implemented");Xl(e,ne*Pe)}else throw new Error("Invalid pattern compression mode");I++}return e.offset=n,{id:l,name:a,x:r,y:s,bounds:{x:f,y:u,w:m,h:b},data:x}}function Cl(e,t,n,i,o){let r=e.width,s=e.height,a=t.width;for(let l=0;l<s;l++)for(let c=0;c<r;c++){let d=c+l*r,u=(n+c+(l+i)*a)*4,f=e.data[d];t.data[u+o]=f}}function eo(e,t){if(e.totalMemoryLimit!==void 0){if(e.totalMemoryLimit<t)throw new Error("Exceeded memory limit");e.totalMemoryLimit-=t}}function Xl(e,t){e.totalMemoryLimit!==void 0&&(e.totalMemoryLimit+=t)}});var Yl=oe(ro=>{"use strict";Object.defineProperty(ro,"__esModule",{value:!0});ro.readEffects=n0;ro.writeEffects=i0;var ql=Tt(),z=jt(),B=Dn(),Kl=[void 0,"outer bevel","inner bevel","emboss","pillow emboss","stroke emboss"];function Pn(e){return(0,z.checkSignature)(e,"8BIM"),ql.toBlendMode[(0,z.readSignature)(e)]||"normal"}function Fn(e,t){(0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,ql.fromBlendMode[t]||"norm")}function En(e){return(0,z.readUint8)(e)/255}function On(e,t){(0,B.writeUint8)(e,Math.round(t*255)|0)}function n0(e){let t=(0,z.readUint16)(e);if(t!==0)throw new Error(`Invalid effects layer version: ${t}`);let n=(0,z.readUint16)(e),i={};for(let o=0;o<n;o++){(0,z.checkSignature)(e,"8BIM");let r=(0,z.readSignature)(e);switch(r){case"cmnS":{let s=(0,z.readUint32)(e),a=(0,z.readUint32)(e),l=!!(0,z.readUint8)(e);if((0,z.skipBytes)(e,2),s!==7||a!==0||!l)throw new Error("Invalid effects common state");break}case"dsdw":case"isdw":{let s=(0,z.readUint32)(e),a=(0,z.readUint32)(e);if(s!==41&&s!==51)throw new Error(`Invalid shadow size: ${s}`);if(a!==0&&a!==2)throw new Error(`Invalid shadow version: ${a}`);let l=(0,z.readFixedPoint32)(e);(0,z.readFixedPoint32)(e);let c=(0,z.readFixedPoint32)(e),d=(0,z.readFixedPoint32)(e),u=(0,z.readColor)(e),f=Pn(e),h=!!(0,z.readUint8)(e),p=!!(0,z.readUint8)(e),S=En(e);s>=51&&(0,z.readColor)(e);let m={size:{units:"Pixels",value:l},distance:{units:"Pixels",value:d},angle:c,color:u,blendMode:f,enabled:h,useGlobalLight:p,opacity:S};r==="dsdw"?i.dropShadow=[m]:i.innerShadow=[m];break}case"oglw":{let s=(0,z.readUint32)(e),a=(0,z.readUint32)(e);if(s!==32&&s!==42)throw new Error(`Invalid outer glow size: ${s}`);if(a!==0&&a!==2)throw new Error(`Invalid outer glow version: ${a}`);let l=(0,z.readFixedPoint32)(e);(0,z.readFixedPoint32)(e);let c=(0,z.readColor)(e),d=Pn(e),u=!!(0,z.readUint8)(e),f=En(e);s>=42&&(0,z.readColor)(e),i.outerGlow={size:{units:"Pixels",value:l},color:c,blendMode:d,enabled:u,opacity:f};break}case"iglw":{let s=(0,z.readUint32)(e),a=(0,z.readUint32)(e);if(s!==32&&s!==43)throw new Error(`Invalid inner glow size: ${s}`);if(a!==0&&a!==2)throw new Error(`Invalid inner glow version: ${a}`);let l=(0,z.readFixedPoint32)(e);(0,z.readFixedPoint32)(e);let c=(0,z.readColor)(e),d=Pn(e),u=!!(0,z.readUint8)(e),f=En(e);s>=43&&((0,z.readUint8)(e),(0,z.readColor)(e)),i.innerGlow={size:{units:"Pixels",value:l},color:c,blendMode:d,enabled:u,opacity:f};break}case"bevl":{let s=(0,z.readUint32)(e),a=(0,z.readUint32)(e);if(s!==58&&s!==78)throw new Error(`Invalid bevel size: ${s}`);if(a!==0&&a!==2)throw new Error(`Invalid bevel version: ${a}`);let l=(0,z.readFixedPoint32)(e),c=(0,z.readFixedPoint32)(e),d=(0,z.readFixedPoint32)(e),u=Pn(e),f=Pn(e),h=(0,z.readColor)(e),p=(0,z.readColor)(e),S=Kl[(0,z.readUint8)(e)]||"inner bevel",m=En(e),b=En(e),v=!!(0,z.readUint8)(e),x=!!(0,z.readUint8)(e),_=(0,z.readUint8)(e)?"down":"up";s>=78&&((0,z.readColor)(e),(0,z.readColor)(e)),i.bevel={size:{units:"Pixels",value:d},angle:l,strength:c,highlightBlendMode:u,shadowBlendMode:f,highlightColor:h,shadowColor:p,style:S,highlightOpacity:m,shadowOpacity:b,enabled:v,useGlobalLight:x,direction:_};break}case"sofi":{let s=(0,z.readUint32)(e),a=(0,z.readUint32)(e);if(s!==34)throw new Error(`Invalid effects solid fill info size: ${s}`);if(a!==2)throw new Error(`Invalid effects solid fill info version: ${a}`);let l=Pn(e),c=(0,z.readColor)(e),d=En(e),u=!!(0,z.readUint8)(e);(0,z.readColor)(e),i.solidFill=[{blendMode:l,color:c,opacity:d,enabled:u}];break}default:throw new Error(`Invalid effect type: '${r}'`)}}return i}function Zl(e,t){var n;(0,B.writeUint32)(e,51),(0,B.writeUint32)(e,2),(0,B.writeFixedPoint32)(e,t.size&&t.size.value||0),(0,B.writeFixedPoint32)(e,0),(0,B.writeFixedPoint32)(e,t.angle||0),(0,B.writeFixedPoint32)(e,t.distance&&t.distance.value||0),(0,B.writeColor)(e,t.color),Fn(e,t.blendMode),(0,B.writeUint8)(e,t.enabled?1:0),(0,B.writeUint8)(e,t.useGlobalLight?1:0),On(e,(n=t.opacity)!==null&&n!==void 0?n:1),(0,B.writeColor)(e,t.color)}function i0(e,t){var n,i,o,r,s,a;let l=(n=t.dropShadow)===null||n===void 0?void 0:n[0],c=(i=t.innerShadow)===null||i===void 0?void 0:i[0],d=t.outerGlow,u=t.innerGlow,f=t.bevel,h=(o=t.solidFill)===null||o===void 0?void 0:o[0],p=1;if(l&&p++,c&&p++,d&&p++,u&&p++,f&&p++,h&&p++,(0,B.writeUint16)(e,0),(0,B.writeUint16)(e,p),(0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"cmnS"),(0,B.writeUint32)(e,7),(0,B.writeUint32)(e,0),(0,B.writeUint8)(e,1),(0,B.writeZeros)(e,2),l&&((0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"dsdw"),Zl(e,l)),c&&((0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"isdw"),Zl(e,c)),d&&((0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"oglw"),(0,B.writeUint32)(e,42),(0,B.writeUint32)(e,2),(0,B.writeFixedPoint32)(e,((r=d.size)===null||r===void 0?void 0:r.value)||0),(0,B.writeFixedPoint32)(e,0),(0,B.writeColor)(e,d.color),Fn(e,d.blendMode),(0,B.writeUint8)(e,d.enabled?1:0),On(e,d.opacity||0),(0,B.writeColor)(e,d.color)),u&&((0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"iglw"),(0,B.writeUint32)(e,43),(0,B.writeUint32)(e,2),(0,B.writeFixedPoint32)(e,((s=u.size)===null||s===void 0?void 0:s.value)||0),(0,B.writeFixedPoint32)(e,0),(0,B.writeColor)(e,u.color),Fn(e,u.blendMode),(0,B.writeUint8)(e,u.enabled?1:0),On(e,u.opacity||0),(0,B.writeUint8)(e,0),(0,B.writeColor)(e,u.color)),f){(0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"bevl"),(0,B.writeUint32)(e,78),(0,B.writeUint32)(e,2),(0,B.writeFixedPoint32)(e,f.angle||0),(0,B.writeFixedPoint32)(e,f.strength||0),(0,B.writeFixedPoint32)(e,((a=f.size)===null||a===void 0?void 0:a.value)||0),Fn(e,f.highlightBlendMode),Fn(e,f.shadowBlendMode),(0,B.writeColor)(e,f.highlightColor),(0,B.writeColor)(e,f.shadowColor);let S=Kl.indexOf(f.style);(0,B.writeUint8)(e,S<=0?1:S),On(e,f.highlightOpacity||0),On(e,f.shadowOpacity||0),(0,B.writeUint8)(e,f.enabled?1:0),(0,B.writeUint8)(e,f.useGlobalLight?1:0),(0,B.writeUint8)(e,f.direction==="down"?1:0),(0,B.writeColor)(e,f.highlightColor),(0,B.writeColor)(e,f.shadowColor)}h&&((0,B.writeSignature)(e,"8BIM"),(0,B.writeSignature)(e,"sofi"),(0,B.writeUint32)(e,34),(0,B.writeUint32)(e,2),Fn(e,h.blendMode),(0,B.writeColor)(e,h.color),On(e,h.opacity||0),(0,B.writeUint8)(e,h.enabled?1:0),(0,B.writeColor)(e,h.color))}});var ec=oe(so=>{"use strict";Object.defineProperty(so,"__esModule",{value:!0});so.parseEngineData=o0;so.serializeEngineData=a0;function Jl(e){return e===32||e===10||e===13||e===9}function Ql(e){return e>=48&&e<=57||e===46||e===45}function o0(e){let t=0;function n(){for(;t<e.length&&Jl(e[t]);)t++}function i(){let f=e[t];return t++,f===92&&(f=e[t],t++),f}function o(){let f="";if(e[t]===41)return t++,f;if(e[t]!==254||e[t+1]!==255){for(;t<e.length&&e[t]!==41;)f+=String.fromCharCode(i());return t++,f}for(t+=2;t<e.length&&e[t]!==41;){let h=i(),p=i(),S=h<<8|p;f+=String.fromCharCode(S)}return t++,f}let r=null,s=[];function a(f){s.length?(l(f),s.push(f)):(s.push(f),r=f)}function l(f){if(!s.length)throw new Error("Invalid data");let h=s[s.length-1];if(typeof h=="string")s[s.length-2][h]=f,d();else if(Array.isArray(h))h.push(f);else throw new Error("Invalid data")}function c(f){s.length||a({});let h=s[s.length-1];if(h&&typeof h=="string")l(f==="nil"?null:`/${f}`);else if(h&&typeof h=="object")s.push(f);else throw new Error("Invalid data")}function d(){if(!s.length)throw new Error("Invalid data");s.pop()}n();let u=e.length;for(;u>0&&e[u-1]===0;)u--;for(;t<u;){let f=t,h=e[f];if(h===60&&e[f+1]===60)t+=2,a({});else if(h===62&&e[f+1]===62)t+=2,d();else if(h===47){t+=1;let p=t;for(;t<e.length&&!Jl(e[t]);)t++;let S="";for(let m=p;m<t;m++)S+=String.fromCharCode(e[m]);c(S)}else if(h===40)t+=1,l(o());else if(h===91)t+=1,a([]);else if(h===93)t+=1,d();else if(h===110&&e[f+1]===117&&e[f+2]===108&&e[f+3]===108)t+=4,l(null);else if(h===116&&e[f+1]===114&&e[f+2]===117&&e[f+3]===101)t+=4,l(!0);else if(h===102&&e[f+1]===97&&e[f+2]===108&&e[f+3]===115&&e[f+4]===101)t+=5,l(!1);else if(Ql(h)){let p="";for(;t<e.length&&Ql(e[t]);)p+=String.fromCharCode(e[t]),t++;l(parseFloat(p))}else t+=1,console.log(`Invalid token '${String.fromCharCode(h)}' (${h}) at ${t}`);n()}return r}var r0=["Axis","XY","Zone","WordSpacing","FirstLineIndent","GlyphSpacing","StartIndent","EndIndent","SpaceBefore","SpaceAfter","LetterSpacing","Values","GridSize","GridLeading","PointBase","BoxBounds","TransformPoint0","TransformPoint1","TransformPoint2","FontSize","Leading","HorizontalScale","VerticalScale","BaselineShift","Tsume","OutlineWidth","AutoLeading"],s0=["RunLengthArray"];function a0(e,t=!1){let n=new Uint8Array(1024),i=0,o=0;function r(S){if(i>=n.length){let m=new Uint8Array(n.length*2);m.set(n),n=m}n[i]=S,i++}function s(S){for(let m=0;m<S.length;m++)r(S.charCodeAt(m))}function a(){if(t)s(" ");else for(let S=0;S<o;S++)s(" ")}function l(S,m){a(),s(`/${S}`),p(m,S,!0),t||s(`
2
- `)}function c(S){return S.toString()}function d(S){return S.toFixed(5).replace(/(\d)0+$/g,"$1").replace(/^0+\.([1-9])/g,".$1").replace(/^-0+\.0(\d)/g,"-.0$1")}function u(S,m){return m&&r0.indexOf(m)!==-1||(S|0)!==S?d(S):c(S)}function f(S){let m=Object.keys(S);return m.indexOf("98")!==-1&&m.unshift(...m.splice(m.indexOf("98"),1)),m.indexOf("99")!==-1&&m.unshift(...m.splice(m.indexOf("99"),1)),m}function h(S){(S===40||S===41||S===92)&&r(92),r(S)}function p(S,m,b=!1){function v(){b?s(" "):a()}if(S===null)v(),s(t?"/nil":"null");else if(typeof S=="number")v(),s(u(S,m));else if(typeof S=="boolean")v(),s(S?"true":"false");else if(typeof S=="string")if(v(),(m==="99"||m==="98")&&S.charAt(0)==="/")s(S);else{s("("),r(254),r(255);for(let x=0;x<S.length;x++){let _=S.charCodeAt(x);h(_>>8&255),h(_&255)}s(")")}else if(Array.isArray(S))if(v(),S.every(x=>typeof x=="number")){s("[");let x=s0.indexOf(m)!==-1;for(let _ of S)s(" "),s(x?u(_):d(_));s(" ]")}else{s("["),t||s(`
3
- `);for(let x of S)p(x,m),t||s(`
4
- `);a(),s("]")}else if(typeof S=="object"){b&&!t&&s(`
5
- `),a(),s("<<"),t||s(`
6
- `),o++;for(let x of f(S))l(x,S[x]);o--,a(),s(">>")}}if(t){if(typeof e=="object")for(let S of f(e))l(S,e[S])}else s(`
1
+ var fu=Object.create;var ia=Object.defineProperty;var du=Object.getOwnPropertyDescriptor;var uu=Object.getOwnPropertyNames;var pu=Object.getPrototypeOf,hu=Object.prototype.hasOwnProperty;var ae=(e,n)=>()=>{try{return n||e((n={exports:{}}).exports,n),n.exports}catch(t){throw n=0,t}};var gu=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of uu(n))!hu.call(e,o)&&o!==t&&ia(e,o,{get:()=>n[o],enumerable:!(i=du(n,o))||i.enumerable});return e};var mu=(e,n,t)=>(t=e!=null?fu(pu(e)):{},gu(n||!e||!e.__esModule?ia(t,"default",{value:e,enumerable:!0}):t,e));var _a=ae((By,bn)=>{"use strict";function yn(e){let n=e.length;for(;--n>=0;)e[n]=0}var yu=0,ca=1,bu=2,wu=3,vu=258,qo=29,Qn=256,Zn=Qn+1+qo,mn=30,Zo=19,fa=2*Zn+1,Yt=15,Vo=16,Su=7,Ko=256,da=16,ua=17,pa=18,Wo=new Uint8Array([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]),Li=new Uint8Array([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]),xu=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),ha=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ku=512,At=new Array((Zn+2)*2);yn(At);var qn=new Array(mn*2);yn(qn);var Kn=new Array(ku);yn(Kn);var Yn=new Array(vu-wu+1);yn(Yn);var Yo=new Array(qo);yn(Yo);var Mi=new Array(mn);yn(Mi);function No(e,n,t,i,o){this.static_tree=e,this.extra_bits=n,this.extra_base=t,this.elems=i,this.max_length=o,this.has_stree=e&&e.length}var ga,ma,ya;function Go(e,n){this.dyn_tree=e,this.max_code=0,this.stat_desc=n}var ba=e=>e<256?Kn[e]:Kn[256+(e>>>7)],Jn=(e,n)=>{e.pending_buf[e.pending++]=n&255,e.pending_buf[e.pending++]=n>>>8&255},Ve=(e,n,t)=>{e.bi_valid>Vo-t?(e.bi_buf|=n<<e.bi_valid&65535,Jn(e,e.bi_buf),e.bi_buf=n>>Vo-e.bi_valid,e.bi_valid+=t-Vo):(e.bi_buf|=n<<e.bi_valid&65535,e.bi_valid+=t)},ft=(e,n,t)=>{Ve(e,t[n*2],t[n*2+1])},wa=(e,n)=>{let t=0;do t|=e&1,e>>>=1,t<<=1;while(--n>0);return t>>>1},_u=e=>{e.bi_valid===16?(Jn(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},Au=(e,n)=>{let t=n.dyn_tree,i=n.max_code,o=n.stat_desc.static_tree,r=n.stat_desc.has_stree,s=n.stat_desc.extra_bits,a=n.stat_desc.extra_base,l=n.stat_desc.max_length,c,f,u,d,p,h,m=0;for(d=0;d<=Yt;d++)e.bl_count[d]=0;for(t[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;c<fa;c++)f=e.heap[c],d=t[t[f*2+1]*2+1]+1,d>l&&(d=l,m++),t[f*2+1]=d,!(f>i)&&(e.bl_count[d]++,p=0,f>=a&&(p=s[f-a]),h=t[f*2],e.opt_len+=h*(d+p),r&&(e.static_len+=h*(o[f*2+1]+p)));if(m!==0){do{for(d=l-1;e.bl_count[d]===0;)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[l]--,m-=2}while(m>0);for(d=l;d!==0;d--)for(f=e.bl_count[d];f!==0;)u=e.heap[--c],!(u>i)&&(t[u*2+1]!==d&&(e.opt_len+=(d-t[u*2+1])*t[u*2],t[u*2+1]=d),f--)}},va=(e,n,t)=>{let i=new Array(Yt+1),o=0,r,s;for(r=1;r<=Yt;r++)o=o+t[r-1]<<1,i[r]=o;for(s=0;s<=n;s++){let a=e[s*2+1];a!==0&&(e[s*2]=wa(i[a]++,a))}},Iu=()=>{let e,n,t,i,o,r=new Array(Yt+1);for(t=0,i=0;i<qo-1;i++)for(Yo[i]=t,e=0;e<1<<Wo[i];e++)Yn[t++]=i;for(Yn[t-1]=i,o=0,i=0;i<16;i++)for(Mi[i]=o,e=0;e<1<<Li[i];e++)Kn[o++]=i;for(o>>=7;i<mn;i++)for(Mi[i]=o<<7,e=0;e<1<<Li[i]-7;e++)Kn[256+o++]=i;for(n=0;n<=Yt;n++)r[n]=0;for(e=0;e<=143;)At[e*2+1]=8,e++,r[8]++;for(;e<=255;)At[e*2+1]=9,e++,r[9]++;for(;e<=279;)At[e*2+1]=7,e++,r[7]++;for(;e<=287;)At[e*2+1]=8,e++,r[8]++;for(va(At,Zn+1,r),e=0;e<mn;e++)qn[e*2+1]=5,qn[e*2]=wa(e,5);ga=new No(At,Wo,Qn+1,Zn,Yt),ma=new No(qn,Li,0,mn,Yt),ya=new No(new Array(0),xu,0,Zo,Su)},Sa=e=>{let n;for(n=0;n<Zn;n++)e.dyn_ltree[n*2]=0;for(n=0;n<mn;n++)e.dyn_dtree[n*2]=0;for(n=0;n<Zo;n++)e.bl_tree[n*2]=0;e.dyn_ltree[Ko*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},xa=e=>{e.bi_valid>8?Jn(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},oa=(e,n,t,i)=>{let o=n*2,r=t*2;return e[o]<e[r]||e[o]===e[r]&&i[n]<=i[t]},Ho=(e,n,t)=>{let i=e.heap[t],o=t<<1;for(;o<=e.heap_len&&(o<e.heap_len&&oa(n,e.heap[o+1],e.heap[o],e.depth)&&o++,!oa(n,i,e.heap[o],e.depth));)e.heap[t]=e.heap[o],t=o,o<<=1;e.heap[t]=i},ra=(e,n,t)=>{let i,o,r=0,s,a;if(e.sym_next!==0)do i=e.pending_buf[e.sym_buf+r++]&255,i+=(e.pending_buf[e.sym_buf+r++]&255)<<8,o=e.pending_buf[e.sym_buf+r++],i===0?ft(e,o,n):(s=Yn[o],ft(e,s+Qn+1,n),a=Wo[s],a!==0&&(o-=Yo[s],Ve(e,o,a)),i--,s=ba(i),ft(e,s,t),a=Li[s],a!==0&&(i-=Mi[s],Ve(e,i,a)));while(r<e.sym_next);ft(e,Ko,n)},Xo=(e,n)=>{let t=n.dyn_tree,i=n.stat_desc.static_tree,o=n.stat_desc.has_stree,r=n.stat_desc.elems,s,a,l=-1,c;for(e.heap_len=0,e.heap_max=fa,s=0;s<r;s++)t[s*2]!==0?(e.heap[++e.heap_len]=l=s,e.depth[s]=0):t[s*2+1]=0;for(;e.heap_len<2;)c=e.heap[++e.heap_len]=l<2?++l:0,t[c*2]=1,e.depth[c]=0,e.opt_len--,o&&(e.static_len-=i[c*2+1]);for(n.max_code=l,s=e.heap_len>>1;s>=1;s--)Ho(e,t,s);c=r;do s=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ho(e,t,1),a=e.heap[1],e.heap[--e.heap_max]=s,e.heap[--e.heap_max]=a,t[c*2]=t[s*2]+t[a*2],e.depth[c]=(e.depth[s]>=e.depth[a]?e.depth[s]:e.depth[a])+1,t[s*2+1]=t[a*2+1]=c,e.heap[1]=c++,Ho(e,t,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],Au(e,n),va(t,l,e.bl_count)},sa=(e,n,t)=>{let i,o=-1,r,s=n[1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),n[(t+1)*2+1]=65535,i=0;i<=t;i++)r=s,s=n[(i+1)*2+1],!(++a<l&&r===s)&&(a<c?e.bl_tree[r*2]+=a:r!==0?(r!==o&&e.bl_tree[r*2]++,e.bl_tree[da*2]++):a<=10?e.bl_tree[ua*2]++:e.bl_tree[pa*2]++,a=0,o=r,s===0?(l=138,c=3):r===s?(l=6,c=3):(l=7,c=4))},aa=(e,n,t)=>{let i,o=-1,r,s=n[1],a=0,l=7,c=4;for(s===0&&(l=138,c=3),i=0;i<=t;i++)if(r=s,s=n[(i+1)*2+1],!(++a<l&&r===s)){if(a<c)do ft(e,r,e.bl_tree);while(--a!==0);else r!==0?(r!==o&&(ft(e,r,e.bl_tree),a--),ft(e,da,e.bl_tree),Ve(e,a-3,2)):a<=10?(ft(e,ua,e.bl_tree),Ve(e,a-3,3)):(ft(e,pa,e.bl_tree),Ve(e,a-11,7));a=0,o=r,s===0?(l=138,c=3):r===s?(l=6,c=3):(l=7,c=4)}},Cu=e=>{let n;for(sa(e,e.dyn_ltree,e.l_desc.max_code),sa(e,e.dyn_dtree,e.d_desc.max_code),Xo(e,e.bl_desc),n=Zo-1;n>=3&&e.bl_tree[ha[n]*2+1]===0;n--);return e.opt_len+=3*(n+1)+5+5+4,n},Pu=(e,n,t,i)=>{let o;for(Ve(e,n-257,5),Ve(e,t-1,5),Ve(e,i-4,4),o=0;o<i;o++)Ve(e,e.bl_tree[ha[o]*2+1],3);aa(e,e.dyn_ltree,n-1),aa(e,e.dyn_dtree,t-1)},Du=e=>{let n=4093624447,t;for(t=0;t<=31;t++,n>>>=1)if(n&1&&e.dyn_ltree[t*2]!==0)return 0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return 1;for(t=32;t<Qn;t++)if(e.dyn_ltree[t*2]!==0)return 1;return 0},la=!1,Ou=e=>{la||(Iu(),la=!0),e.l_desc=new Go(e.dyn_ltree,ga),e.d_desc=new Go(e.dyn_dtree,ma),e.bl_desc=new Go(e.bl_tree,ya),e.bi_buf=0,e.bi_valid=0,Sa(e)},ka=(e,n,t,i)=>{Ve(e,(yu<<1)+(i?1:0),3),xa(e),Jn(e,t),Jn(e,~t),t&&e.pending_buf.set(e.window.subarray(n,n+t),e.pending),e.pending+=t},Eu=e=>{Ve(e,ca<<1,3),ft(e,Ko,At),_u(e)},Fu=(e,n,t,i)=>{let o,r,s=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=Du(e)),Xo(e,e.l_desc),Xo(e,e.d_desc),s=Cu(e),o=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=o&&(o=r)):o=r=t+5,t+4<=o&&n!==-1?ka(e,n,t,i):e.strategy===4||r===o?(Ve(e,(ca<<1)+(i?1:0),3),ra(e,At,qn)):(Ve(e,(bu<<1)+(i?1:0),3),Pu(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),ra(e,e.dyn_ltree,e.dyn_dtree)),Sa(e),i&&xa(e)},Lu=(e,n,t)=>(e.pending_buf[e.sym_buf+e.sym_next++]=n,e.pending_buf[e.sym_buf+e.sym_next++]=n>>8,e.pending_buf[e.sym_buf+e.sym_next++]=t,n===0?e.dyn_ltree[t*2]++:(e.matches++,n--,e.dyn_ltree[(Yn[t]+Qn+1)*2]++,e.dyn_dtree[ba(n)*2]++),e.sym_next===e.sym_end);bn.exports._tr_init=Ou;bn.exports._tr_stored_block=ka;bn.exports._tr_flush_block=Fu;bn.exports._tr_tally=Lu;bn.exports._tr_align=Eu});var Jo=ae((Ry,Aa)=>{"use strict";var Mu=(e,n,t,i)=>{let o=e&65535|0,r=e>>>16&65535|0,s=0;for(;t!==0;){s=t>2e3?2e3:t,t-=s;do o=o+n[i++]|0,r=r+o|0;while(--s);o%=65521,r%=65521}return o|r<<16|0};Aa.exports=Mu});var Qo=ae((Ty,Ia)=>{"use strict";var Uu=()=>{let e,n=[];for(var t=0;t<256;t++){e=t;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;n[t]=e}return n},Bu=new Uint32Array(Uu()),Ru=(e,n,t,i)=>{let o=Bu,r=i+t;e^=-1;for(let s=i;s<r;s++)e=e>>>8^o[(e^n[s])&255];return e^-1};Ia.exports=Ru});var Ui=ae((jy,Ca)=>{"use strict";Ca.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 zt=ae((zy,Pa)=>{"use strict";Pa.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_MEM_ERROR:-4,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 Ta=ae(($y,ht)=>{"use strict";var{_tr_init:Tu,_tr_stored_block:nr,_tr_flush_block:ju,_tr_tally:Gt,_tr_align:zu}=_a(),Fa=Jo(),$t=Qo(),$u=Ui(),{Z_NO_FLUSH:Ht,Z_PARTIAL_FLUSH:Vu,Z_FULL_FLUSH:Nu,Z_FINISH:Ye,Z_BLOCK:Da,Z_OK:Oe,Z_STREAM_END:Oa,Z_STREAM_ERROR:ut,Z_DATA_ERROR:Gu,Z_BUF_ERROR:er,Z_DEFAULT_COMPRESSION:Hu,Z_FILTERED:Wu,Z_HUFFMAN_ONLY:Bi,Z_RLE:Xu,Z_FIXED:qu,Z_DEFAULT_STRATEGY:Zu,Z_UNKNOWN:Ku,Z_DEFLATED:Ri}=zt(),Yu=9,Ju=15,Qu=8,e0=29,t0=256,ir=t0+1+e0,n0=30,i0=19,o0=2*ir+1,r0=15,oe=3,Nt=258,pt=Nt+oe+1,s0=32,vn=42,cr=57,or=69,rr=73,sr=91,ar=103,Jt=113,ti=666,Be=1,xn=2,en=3,kn=4,a0=3,Qt=(e,n)=>(e.msg=$u[n],n),Ea=e=>e*2-(e>4?9:0),Vt=e=>{let n=e.length;for(;--n>=0;)e[n]=0},l0=e=>{let n,t,i,o=e.w_size;n=e.hash_size,i=n;do t=e.head[--i],e.head[i]=t>=o?t-o:0;while(--n);n=o,i=n;do t=e.prev[--i],e.prev[i]=t>=o?t-o:0;while(--n)},c0=(e,n,t)=>(n<<e.hash_shift^t)&e.hash_mask,Wt=c0,Ge=e=>{let n=e.state,t=n.pending;t>e.avail_out&&(t=e.avail_out),t!==0&&(e.output.set(n.pending_buf.subarray(n.pending_out,n.pending_out+t),e.next_out),e.next_out+=t,n.pending_out+=t,e.total_out+=t,e.avail_out-=t,n.pending-=t,n.pending===0&&(n.pending_out=0))},He=(e,n)=>{ju(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,n),e.block_start=e.strstart,Ge(e.strm)},fe=(e,n)=>{e.pending_buf[e.pending++]=n},ei=(e,n)=>{e.pending_buf[e.pending++]=n>>>8&255,e.pending_buf[e.pending++]=n&255},lr=(e,n,t,i)=>{let o=e.avail_in;return o>i&&(o=i),o===0?0:(e.avail_in-=o,n.set(e.input.subarray(e.next_in,e.next_in+o),t),e.state.wrap===1?e.adler=Fa(e.adler,n,o,t):e.state.wrap===2&&(e.adler=$t(e.adler,n,o,t)),e.next_in+=o,e.total_in+=o,o)},La=(e,n)=>{let t=e.max_chain_length,i=e.strstart,o,r,s=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-pt?e.strstart-(e.w_size-pt):0,c=e.window,f=e.w_mask,u=e.prev,d=e.strstart+Nt,p=c[i+s-1],h=c[i+s];e.prev_length>=e.good_match&&(t>>=2),a>e.lookahead&&(a=e.lookahead);do if(o=n,!(c[o+s]!==h||c[o+s-1]!==p||c[o]!==c[i]||c[++o]!==c[i+1])){i+=2,o++;do;while(c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&c[++i]===c[++o]&&i<d);if(r=Nt-(d-i),i=d-Nt,r>s){if(e.match_start=n,s=r,r>=a)break;p=c[i+s-1],h=c[i+s]}}while((n=u[n&f])>l&&--t!==0);return s<=e.lookahead?s:e.lookahead},Sn=e=>{let n=e.w_size,t,i,o;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=n+(n-pt)&&(e.window.set(e.window.subarray(n,n+n-i),0),e.match_start-=n,e.strstart-=n,e.block_start-=n,e.insert>e.strstart&&(e.insert=e.strstart),l0(e),i+=n),e.strm.avail_in===0)break;if(t=lr(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=t,e.lookahead+e.insert>=oe)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=Wt(e,e.ins_h,e.window[o+1]);e.insert&&(e.ins_h=Wt(e,e.ins_h,e.window[o+oe-1]),e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<oe)););}while(e.lookahead<pt&&e.strm.avail_in!==0)},Ma=(e,n)=>{let t=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i,o,r,s=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_out<r||(r=e.strm.avail_out-r,o=e.strstart-e.block_start,i>o+e.strm.avail_in&&(i=o+e.strm.avail_in),i>r&&(i=r),i<t&&(i===0&&n!==Ye||n===Ht||i!==o+e.strm.avail_in)))break;s=n===Ye&&i===o+e.strm.avail_in?1:0,nr(e,0,0,s),e.pending_buf[e.pending-4]=i,e.pending_buf[e.pending-3]=i>>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,Ge(e.strm),o&&(o>i&&(o=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+o),e.strm.next_out),e.strm.next_out+=o,e.strm.avail_out-=o,e.strm.total_out+=o,e.block_start+=o,i-=o),i&&(lr(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(s===0);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),s?kn:n!==Ht&&n!==Ye&&e.strm.avail_in===0&&e.strstart===e.block_start?xn:(r=e.window_size-e.strstart,e.strm.avail_in>r&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(lr(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water<e.strstart&&(e.high_water=e.strstart),r=e.bi_valid+42>>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,t=r>e.w_size?e.w_size:r,o=e.strstart-e.block_start,(o>=t||(o||n===Ye)&&n!==Ht&&e.strm.avail_in===0&&o<=r)&&(i=o>r?r:o,s=n===Ye&&e.strm.avail_in===0&&i===o?1:0,nr(e,e.block_start,i,s),e.block_start+=i,Ge(e.strm)),s?en:Be)},tr=(e,n)=>{let t,i;for(;;){if(e.lookahead<pt){if(Sn(e),e.lookahead<pt&&n===Ht)return Be;if(e.lookahead===0)break}if(t=0,e.lookahead>=oe&&(e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+oe-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),t!==0&&e.strstart-t<=e.w_size-pt&&(e.match_length=La(e,t)),e.match_length>=oe)if(i=Gt(e,e.strstart-e.match_start,e.match_length-oe),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=oe){e.match_length--;do e.strstart++,e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+oe-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+1]);else i=Gt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(He(e,!1),e.strm.avail_out===0))return Be}return e.insert=e.strstart<oe-1?e.strstart:oe-1,n===Ye?(He(e,!0),e.strm.avail_out===0?en:kn):e.sym_next&&(He(e,!1),e.strm.avail_out===0)?Be:xn},wn=(e,n)=>{let t,i,o;for(;;){if(e.lookahead<pt){if(Sn(e),e.lookahead<pt&&n===Ht)return Be;if(e.lookahead===0)break}if(t=0,e.lookahead>=oe&&(e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+oe-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=oe-1,t!==0&&e.prev_length<e.max_lazy_match&&e.strstart-t<=e.w_size-pt&&(e.match_length=La(e,t),e.match_length<=5&&(e.strategy===Wu||e.match_length===oe&&e.strstart-e.match_start>4096)&&(e.match_length=oe-1)),e.prev_length>=oe&&e.match_length<=e.prev_length){o=e.strstart+e.lookahead-oe,i=Gt(e,e.strstart-1-e.prev_match,e.prev_length-oe),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=o&&(e.ins_h=Wt(e,e.ins_h,e.window[e.strstart+oe-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=oe-1,e.strstart++,i&&(He(e,!1),e.strm.avail_out===0))return Be}else if(e.match_available){if(i=Gt(e,0,e.window[e.strstart-1]),i&&He(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Be}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=Gt(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<oe-1?e.strstart:oe-1,n===Ye?(He(e,!0),e.strm.avail_out===0?en:kn):e.sym_next&&(He(e,!1),e.strm.avail_out===0)?Be:xn},f0=(e,n)=>{let t,i,o,r,s=e.window;for(;;){if(e.lookahead<=Nt){if(Sn(e),e.lookahead<=Nt&&n===Ht)return Be;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=oe&&e.strstart>0&&(o=e.strstart-1,i=s[o],i===s[++o]&&i===s[++o]&&i===s[++o])){r=e.strstart+Nt;do;while(i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&i===s[++o]&&o<r);e.match_length=Nt-(r-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=oe?(t=Gt(e,1,e.match_length-oe),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(t=Gt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),t&&(He(e,!1),e.strm.avail_out===0))return Be}return e.insert=0,n===Ye?(He(e,!0),e.strm.avail_out===0?en:kn):e.sym_next&&(He(e,!1),e.strm.avail_out===0)?Be:xn},d0=(e,n)=>{let t;for(;;){if(e.lookahead===0&&(Sn(e),e.lookahead===0)){if(n===Ht)return Be;break}if(e.match_length=0,t=Gt(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,t&&(He(e,!1),e.strm.avail_out===0))return Be}return e.insert=0,n===Ye?(He(e,!0),e.strm.avail_out===0?en:kn):e.sym_next&&(He(e,!1),e.strm.avail_out===0)?Be:xn};function dt(e,n,t,i,o){this.good_length=e,this.max_lazy=n,this.nice_length=t,this.max_chain=i,this.func=o}var ni=[new dt(0,0,0,0,Ma),new dt(4,4,8,4,tr),new dt(4,5,16,8,tr),new dt(4,6,32,32,tr),new dt(4,4,16,16,wn),new dt(8,16,32,32,wn),new dt(8,16,128,128,wn),new dt(8,32,128,256,wn),new dt(32,128,258,1024,wn),new dt(32,258,258,4096,wn)],u0=e=>{e.window_size=2*e.w_size,Vt(e.head),e.max_lazy_match=ni[e.level].max_lazy,e.good_match=ni[e.level].good_length,e.nice_match=ni[e.level].nice_length,e.max_chain_length=ni[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=oe-1,e.match_available=0,e.ins_h=0};function p0(){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=Ri,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 Uint16Array(o0*2),this.dyn_dtree=new Uint16Array((2*n0+1)*2),this.bl_tree=new Uint16Array((2*i0+1)*2),Vt(this.dyn_ltree),Vt(this.dyn_dtree),Vt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(r0+1),this.heap=new Uint16Array(2*ir+1),Vt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*ir+1),Vt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var ii=e=>{if(!e)return 1;let n=e.state;return!n||n.strm!==e||n.status!==vn&&n.status!==cr&&n.status!==or&&n.status!==rr&&n.status!==sr&&n.status!==ar&&n.status!==Jt&&n.status!==ti?1:0},Ua=e=>{if(ii(e))return Qt(e,ut);e.total_in=e.total_out=0,e.data_type=Ku;let n=e.state;return n.pending=0,n.pending_out=0,n.wrap<0&&(n.wrap=-n.wrap),n.status=n.wrap===2?cr:n.wrap?vn:Jt,e.adler=n.wrap===2?0:1,n.last_flush=-2,Tu(n),Oe},Ba=e=>{let n=Ua(e);return n===Oe&&u0(e.state),n},h0=(e,n)=>ii(e)||e.state.wrap!==2?ut:(e.state.gzhead=n,Oe),Ra=(e,n,t,i,o,r)=>{if(!e)return ut;let s=1;if(n===Hu&&(n=6),i<0?(s=0,i=-i):i>15&&(s=2,i-=16),o<1||o>Yu||t!==Ri||i<8||i>15||n<0||n>9||r<0||r>qu||i===8&&s!==1)return Qt(e,ut);i===8&&(i=9);let a=new p0;return e.state=a,a.strm=e,a.status=vn,a.wrap=s,a.gzhead=null,a.w_bits=i,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=o+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+oe-1)/oe),a.window=new Uint8Array(a.w_size*2),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<o+6,a.pending_buf_size=a.lit_bufsize*4,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=(a.lit_bufsize-1)*3,a.level=n,a.strategy=r,a.method=t,Ba(e)},g0=(e,n)=>Ra(e,n,Ri,Ju,Qu,Zu),m0=(e,n)=>{if(ii(e)||n>Da||n<0)return e?Qt(e,ut):ut;let t=e.state;if(!e.output||e.avail_in!==0&&!e.input||t.status===ti&&n!==Ye)return Qt(e,e.avail_out===0?er:ut);let i=t.last_flush;if(t.last_flush=n,t.pending!==0){if(Ge(e),e.avail_out===0)return t.last_flush=-1,Oe}else if(e.avail_in===0&&Ea(n)<=Ea(i)&&n!==Ye)return Qt(e,er);if(t.status===ti&&e.avail_in!==0)return Qt(e,er);if(t.status===vn&&t.wrap===0&&(t.status=Jt),t.status===vn){let o=Ri+(t.w_bits-8<<4)<<8,r=-1;if(t.strategy>=Bi||t.level<2?r=0:t.level<6?r=1:t.level===6?r=2:r=3,o|=r<<6,t.strstart!==0&&(o|=s0),o+=31-o%31,ei(t,o),t.strstart!==0&&(ei(t,e.adler>>>16),ei(t,e.adler&65535)),e.adler=1,t.status=Jt,Ge(e),t.pending!==0)return t.last_flush=-1,Oe}if(t.status===cr){if(e.adler=0,fe(t,31),fe(t,139),fe(t,8),t.gzhead)fe(t,(t.gzhead.text?1:0)+(t.gzhead.hcrc?2:0)+(t.gzhead.extra?4:0)+(t.gzhead.name?8:0)+(t.gzhead.comment?16:0)),fe(t,t.gzhead.time&255),fe(t,t.gzhead.time>>8&255),fe(t,t.gzhead.time>>16&255),fe(t,t.gzhead.time>>24&255),fe(t,t.level===9?2:t.strategy>=Bi||t.level<2?4:0),fe(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(fe(t,t.gzhead.extra.length&255),fe(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(e.adler=$t(e.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=or;else if(fe(t,0),fe(t,0),fe(t,0),fe(t,0),fe(t,0),fe(t,t.level===9?2:t.strategy>=Bi||t.level<2?4:0),fe(t,a0),t.status=Jt,Ge(e),t.pending!==0)return t.last_flush=-1,Oe}if(t.status===or){if(t.gzhead.extra){let o=t.pending,r=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+r>t.pending_buf_size;){let a=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+a),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),t.gzindex+=a,Ge(e),t.pending!==0)return t.last_flush=-1,Oe;o=0,r-=a}let s=new Uint8Array(t.gzhead.extra);t.pending_buf.set(s.subarray(t.gzindex,t.gzindex+r),t.pending),t.pending+=r,t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),t.gzindex=0}t.status=rr}if(t.status===rr){if(t.gzhead.name){let o=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),Ge(e),t.pending!==0)return t.last_flush=-1,Oe;o=0}t.gzindex<t.gzhead.name.length?r=t.gzhead.name.charCodeAt(t.gzindex++)&255:r=0,fe(t,r)}while(r!==0);t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),t.gzindex=0}t.status=sr}if(t.status===sr){if(t.gzhead.comment){let o=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o)),Ge(e),t.pending!==0)return t.last_flush=-1,Oe;o=0}t.gzindex<t.gzhead.comment.length?r=t.gzhead.comment.charCodeAt(t.gzindex++)&255:r=0,fe(t,r)}while(r!==0);t.gzhead.hcrc&&t.pending>o&&(e.adler=$t(e.adler,t.pending_buf,t.pending-o,o))}t.status=ar}if(t.status===ar){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(Ge(e),t.pending!==0))return t.last_flush=-1,Oe;fe(t,e.adler&255),fe(t,e.adler>>8&255),e.adler=0}if(t.status=Jt,Ge(e),t.pending!==0)return t.last_flush=-1,Oe}if(e.avail_in!==0||t.lookahead!==0||n!==Ht&&t.status!==ti){let o=t.level===0?Ma(t,n):t.strategy===Bi?d0(t,n):t.strategy===Xu?f0(t,n):ni[t.level].func(t,n);if((o===en||o===kn)&&(t.status=ti),o===Be||o===en)return e.avail_out===0&&(t.last_flush=-1),Oe;if(o===xn&&(n===Vu?zu(t):n!==Da&&(nr(t,0,0,!1),n===Nu&&(Vt(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),Ge(e),e.avail_out===0))return t.last_flush=-1,Oe}return n!==Ye?Oe:t.wrap<=0?Oa:(t.wrap===2?(fe(t,e.adler&255),fe(t,e.adler>>8&255),fe(t,e.adler>>16&255),fe(t,e.adler>>24&255),fe(t,e.total_in&255),fe(t,e.total_in>>8&255),fe(t,e.total_in>>16&255),fe(t,e.total_in>>24&255)):(ei(t,e.adler>>>16),ei(t,e.adler&65535)),Ge(e),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?Oe:Oa)},y0=e=>{if(ii(e))return ut;let n=e.state.status;return e.state=null,n===Jt?Qt(e,Gu):Oe},b0=(e,n)=>{let t=n.length;if(ii(e))return ut;let i=e.state,o=i.wrap;if(o===2||o===1&&i.status!==vn||i.lookahead)return ut;if(o===1&&(e.adler=Fa(e.adler,n,t,0)),i.wrap=0,t>=i.w_size){o===0&&(Vt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let l=new Uint8Array(i.w_size);l.set(n.subarray(t-i.w_size,t),0),n=l,t=i.w_size}let r=e.avail_in,s=e.next_in,a=e.input;for(e.avail_in=t,e.next_in=0,e.input=n,Sn(i);i.lookahead>=oe;){let l=i.strstart,c=i.lookahead-(oe-1);do i.ins_h=Wt(i,i.ins_h,i.window[l+oe-1]),i.prev[l&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=l,l++;while(--c);i.strstart=l,i.lookahead=oe-1,Sn(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=oe-1,i.match_available=0,e.next_in=s,e.input=a,e.avail_in=r,i.wrap=o,Oe};ht.exports.deflateInit=g0;ht.exports.deflateInit2=Ra;ht.exports.deflateReset=Ba;ht.exports.deflateResetKeep=Ua;ht.exports.deflateSetHeader=h0;ht.exports.deflate=m0;ht.exports.deflateEnd=y0;ht.exports.deflateSetDictionary=b0;ht.exports.deflateInfo="pako deflate (from Nodeca project)"});var dr=ae((Vy,fr)=>{"use strict";var w0=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);fr.exports.assign=function(e){let n=Array.prototype.slice.call(arguments,1);for(;n.length;){let t=n.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(let i in t)w0(t,i)&&(e[i]=t[i])}}return e};fr.exports.flattenChunks=e=>{let n=0;for(let i=0,o=e.length;i<o;i++)n+=e[i].length;let t=new Uint8Array(n);for(let i=0,o=0,r=e.length;i<r;i++){let s=e[i];t.set(s,o),o+=s.length}return t}});var ur=ae((Ny,Ti)=>{"use strict";var ja=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{ja=!1}var oi=new Uint8Array(256);for(let e=0;e<256;e++)oi[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;oi[254]=oi[254]=1;Ti.exports.string2buf=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let n,t,i,o,r,s=e.length,a=0;for(o=0;o<s;o++)t=e.charCodeAt(o),(t&64512)===55296&&o+1<s&&(i=e.charCodeAt(o+1),(i&64512)===56320&&(t=65536+(t-55296<<10)+(i-56320),o++)),a+=t<128?1:t<2048?2:t<65536?3:4;for(n=new Uint8Array(a),r=0,o=0;r<a;o++)t=e.charCodeAt(o),(t&64512)===55296&&o+1<s&&(i=e.charCodeAt(o+1),(i&64512)===56320&&(t=65536+(t-55296<<10)+(i-56320),o++)),t<128?n[r++]=t:t<2048?(n[r++]=192|t>>>6,n[r++]=128|t&63):t<65536?(n[r++]=224|t>>>12,n[r++]=128|t>>>6&63,n[r++]=128|t&63):(n[r++]=240|t>>>18,n[r++]=128|t>>>12&63,n[r++]=128|t>>>6&63,n[r++]=128|t&63);return n};var v0=(e,n)=>{if(n<65534&&e.subarray&&ja)return String.fromCharCode.apply(null,e.length===n?e:e.subarray(0,n));let t="";for(let i=0;i<n;i++)t+=String.fromCharCode(e[i]);return t};Ti.exports.buf2string=(e,n)=>{let t=n||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,n));let i,o,r=new Array(t*2);for(o=0,i=0;i<t;){let s=e[i++];if(s<128){r[o++]=s;continue}let a=oi[s];if(a>4){r[o++]=65533,i+=a-1;continue}for(s&=a===2?31:a===3?15:7;a>1&&i<t;)s=s<<6|e[i++]&63,a--;if(a>1){r[o++]=65533;continue}s<65536?r[o++]=s:(s-=65536,r[o++]=55296|s>>10&1023,r[o++]=56320|s&1023)}return v0(r,o)};Ti.exports.utf8border=(e,n)=>{n=n||e.length,n>e.length&&(n=e.length);let t=n-1;for(;t>=0&&(e[t]&192)===128;)t--;return t<0||t===0?n:t+oi[e[t]]>n?t:n}});var pr=ae((Gy,za)=>{"use strict";function S0(){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}za.exports=S0});var Ga=ae((Hy,_n)=>{"use strict";var ri=Ta(),$a=dr(),Va=ur(),hr=Ui(),x0=pr(),Na=Object.prototype.toString,{Z_NO_FLUSH:k0,Z_SYNC_FLUSH:_0,Z_FULL_FLUSH:A0,Z_FINISH:I0,Z_OK:ji,Z_STREAM_END:C0,Z_DEFAULT_COMPRESSION:P0,Z_DEFAULT_STRATEGY:D0,Z_DEFLATED:O0}=zt();function si(e){this.options=$a.assign({level:P0,method:O0,chunkSize:16384,windowBits:15,memLevel:8,strategy:D0},e||{});let n=this.options;n.raw&&n.windowBits>0?n.windowBits=-n.windowBits:n.gzip&&n.windowBits>0&&n.windowBits<16&&(n.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new x0,this.strm.avail_out=0;let t=ri.deflateInit2(this.strm,n.level,n.method,n.windowBits,n.memLevel,n.strategy);if(t!==ji)throw new Error(hr[t]);if(n.header&&ri.deflateSetHeader(this.strm,n.header),n.dictionary){let i;if(typeof n.dictionary=="string"?i=Va.string2buf(n.dictionary):Na.call(n.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(n.dictionary):i=n.dictionary,t=ri.deflateSetDictionary(this.strm,i),t!==ji)throw new Error(hr[t]);this._dict_set=!0}}si.prototype.push=function(e,n){let t=this.strm,i=this.options.chunkSize,o,r;if(this.ended)return!1;for(n===~~n?r=n:r=n===!0?I0:k0,typeof e=="string"?t.input=Va.string2buf(e):Na.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),(r===_0||r===A0)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(o=ri.deflate(t,r),o===C0)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),o=ri.deflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===ji;if(t.avail_out===0){this.onData(t.output);continue}if(r>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0};si.prototype.onData=function(e){this.chunks.push(e)};si.prototype.onEnd=function(e){e===ji&&(this.result=$a.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function gr(e,n){let t=new si(n);if(t.push(e,!0),t.err)throw t.msg||hr[t.err];return t.result}function E0(e,n){return n=n||{},n.raw=!0,gr(e,n)}function F0(e,n){return n=n||{},n.gzip=!0,gr(e,n)}_n.exports.Deflate=si;_n.exports.deflate=gr;_n.exports.deflateRaw=E0;_n.exports.gzip=F0;_n.exports.constants=zt()});var Wa=ae((Wy,Ha)=>{"use strict";Ha.exports=function(n,t){let i,o,r,s,a,l,c,f,u,d,p,h,m,y,g,k,x,S,A,D,C,O,E,L,M=n.state;i=n.next_in,E=n.input,o=i+(n.avail_in-5),r=n.next_out,L=n.output,s=r-(t-n.avail_out),a=r+(n.avail_out-257),l=M.dmax,c=M.wsize,f=M.whave,u=M.wnext,d=M.window,p=M.hold,h=M.bits,m=M.lencode,y=M.distcode,g=(1<<M.lenbits)-1,k=(1<<M.distbits)-1;e:do{h<15&&(p+=E[i++]<<h,h+=8,p+=E[i++]<<h,h+=8),x=m[p&g];t:for(;;){if(S=x>>>24,p>>>=S,h-=S,S=x>>>16&255,S===0)L[r++]=x&65535;else if(S&16){A=x&65535,S&=15,S&&(h<S&&(p+=E[i++]<<h,h+=8),A+=p&(1<<S)-1,p>>>=S,h-=S),h<15&&(p+=E[i++]<<h,h+=8,p+=E[i++]<<h,h+=8),x=y[p&k];n:for(;;){if(S=x>>>24,p>>>=S,h-=S,S=x>>>16&255,S&16){if(D=x&65535,S&=15,h<S&&(p+=E[i++]<<h,h+=8,h<S&&(p+=E[i++]<<h,h+=8)),D+=p&(1<<S)-1,D>l){n.msg="invalid distance too far back",M.mode=16209;break e}if(p>>>=S,h-=S,S=r-s,D>S){if(S=D-S,S>f&&M.sane){n.msg="invalid distance too far back",M.mode=16209;break e}if(C=0,O=d,u===0){if(C+=c-S,S<A){A-=S;do L[r++]=d[C++];while(--S);C=r-D,O=L}}else if(u<S){if(C+=c+u-S,S-=u,S<A){A-=S;do L[r++]=d[C++];while(--S);if(C=0,u<A){S=u,A-=S;do L[r++]=d[C++];while(--S);C=r-D,O=L}}}else if(C+=u-S,S<A){A-=S;do L[r++]=d[C++];while(--S);C=r-D,O=L}for(;A>2;)L[r++]=O[C++],L[r++]=O[C++],L[r++]=O[C++],A-=3;A&&(L[r++]=O[C++],A>1&&(L[r++]=O[C++]))}else{C=r-D;do L[r++]=L[C++],L[r++]=L[C++],L[r++]=L[C++],A-=3;while(A>2);A&&(L[r++]=L[C++],A>1&&(L[r++]=L[C++]))}}else if((S&64)===0){x=y[(x&65535)+(p&(1<<S)-1)];continue n}else{n.msg="invalid distance code",M.mode=16209;break e}break}}else if((S&64)===0){x=m[(x&65535)+(p&(1<<S)-1)];continue t}else if(S&32){M.mode=16191;break e}else{n.msg="invalid literal/length code",M.mode=16209;break e}break}}while(i<o&&r<a);A=h>>3,i-=A,h-=A<<3,p&=(1<<h)-1,n.next_in=i,n.next_out=r,n.avail_in=i<o?5+(o-i):5-(i-o),n.avail_out=r<a?257+(a-r):257-(r-a),M.hold=p,M.bits=h}});var qa=ae((Xy,Xa)=>{"use strict";var L0=new Uint16Array([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]),M0=new Uint8Array([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]),U0=new Uint16Array([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]),B0=new Uint8Array([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]),R0=(e,n,t,i,o,r,s,a)=>{let l=a.bits,c=0,f=0,u=0,d=0,p=0,h=0,m=0,y=0,g=0,k=0,x,S,A,D,C,O=null,E,L=new Uint16Array(16),M=new Uint16Array(16),J=null,pe,R,ie;for(c=0;c<=15;c++)L[c]=0;for(f=0;f<i;f++)L[n[t+f]]++;for(p=l,d=15;d>=1&&L[d]===0;d--);if(p>d&&(p=d),d===0)return o[r++]=1<<24|64<<16|0,o[r++]=1<<24|64<<16|0,a.bits=1,0;for(u=1;u<d&&L[u]===0;u++);for(p<u&&(p=u),y=1,c=1;c<=15;c++)if(y<<=1,y-=L[c],y<0)return-1;if(y>0&&(e===0||d!==1))return-1;for(M[1]=0,c=1;c<15;c++)M[c+1]=M[c]+L[c];for(f=0;f<i;f++)n[t+f]!==0&&(s[M[n[t+f]]++]=f);if(e===0?(O=J=s,E=20):e===1?(O=L0,J=M0,E=257):(O=U0,J=B0,E=0),k=0,f=0,c=u,C=r,h=p,m=0,A=-1,g=1<<p,D=g-1,e===1&&g>852||e===2&&g>592)return 1;for(;;){pe=c-m,s[f]+1<E?(R=0,ie=s[f]):s[f]>=E?(R=J[s[f]-E],ie=O[s[f]-E]):(R=96,ie=0),x=1<<c-m,S=1<<h,u=S;do S-=x,o[C+(k>>m)+S]=pe<<24|R<<16|ie|0;while(S!==0);for(x=1<<c-1;k&x;)x>>=1;if(x!==0?(k&=x-1,k+=x):k=0,f++,--L[c]===0){if(c===d)break;c=n[t+s[f]]}if(c>p&&(k&D)!==A){for(m===0&&(m=p),C+=u,h=c-m,y=1<<h;h+m<d&&(y-=L[h+m],!(y<=0));)h++,y<<=1;if(g+=1<<h,e===1&&g>852||e===2&&g>592)return 1;A=k&D,o[A]=p<<24|h<<16|C-r|0}}return k!==0&&(o[C+k]=c-m<<24|64<<16|0),a.bits=p,0};Xa.exports=R0});var Dl=ae((qy,it)=>{"use strict";var Sr=Jo(),gt=Qo(),T0=Wa(),ai=qa(),j0=0,vl=1,Sl=2,{Z_FINISH:Za,Z_BLOCK:z0,Z_TREES:zi,Z_OK:tn,Z_STREAM_END:$0,Z_NEED_DICT:V0,Z_STREAM_ERROR:Je,Z_DATA_ERROR:xl,Z_MEM_ERROR:xr,Z_BUF_ERROR:N0,Z_DEFLATED:Ka}=zt(),Gi=16180,Ya=16181,Ja=16182,Qa=16183,el=16184,tl=16185,nl=16186,il=16187,ol=16188,rl=16189,Ni=16190,It=16191,mr=16192,sl=16193,yr=16194,al=16195,ll=16196,cl=16197,fl=16198,$i=16199,Vi=16200,dl=16201,ul=16202,pl=16203,hl=16204,gl=16205,br=16206,ml=16207,yl=16208,ke=16209,kr=16210,kl=16211,G0=852,H0=592,W0=15,X0=W0,bl=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function q0(){this.strm=null,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 Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var nn=e=>{if(!e)return 1;let n=e.state;return!n||n.strm!==e||n.mode<Gi||n.mode>kl?1:0},_l=e=>{if(nn(e))return Je;let n=e.state;return e.total_in=e.total_out=n.total=0,e.msg="",n.wrap&&(e.adler=n.wrap&1),n.mode=Gi,n.last=0,n.havedict=0,n.flags=-1,n.dmax=32768,n.head=null,n.hold=0,n.bits=0,n.lencode=n.lendyn=new Int32Array(G0),n.distcode=n.distdyn=new Int32Array(H0),n.sane=1,n.back=-1,tn},Al=e=>{if(nn(e))return Je;let n=e.state;return n.wsize=0,n.whave=0,n.wnext=0,_l(e)},Il=(e,n)=>{let t;if(nn(e))return Je;let i=e.state;return n<0?(t=0,n=-n):(t=(n>>4)+5,n<48&&(n&=15)),n&&(n<8||n>15)?Je:(i.window!==null&&i.wbits!==n&&(i.window=null),i.wrap=t,i.wbits=n,Al(e))},Cl=(e,n)=>{if(!e)return Je;let t=new q0;e.state=t,t.strm=e,t.window=null,t.mode=Gi;let i=Il(e,n);return i!==tn&&(e.state=null),i},Z0=e=>Cl(e,X0),wl=!0,wr,vr,K0=e=>{if(wl){wr=new Int32Array(512),vr=new Int32Array(32);let n=0;for(;n<144;)e.lens[n++]=8;for(;n<256;)e.lens[n++]=9;for(;n<280;)e.lens[n++]=7;for(;n<288;)e.lens[n++]=8;for(ai(vl,e.lens,0,288,wr,0,e.work,{bits:9}),n=0;n<32;)e.lens[n++]=5;ai(Sl,e.lens,0,32,vr,0,e.work,{bits:5}),wl=!1}e.lencode=wr,e.lenbits=9,e.distcode=vr,e.distbits=5},Pl=(e,n,t,i)=>{let o,r=e.state;return r.window===null&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Uint8Array(r.wsize)),i>=r.wsize?(r.window.set(n.subarray(t-r.wsize,t),0),r.wnext=0,r.whave=r.wsize):(o=r.wsize-r.wnext,o>i&&(o=i),r.window.set(n.subarray(t-i,t-i+o),r.wnext),i-=o,i?(r.window.set(n.subarray(t-i,t),0),r.wnext=i,r.whave=r.wsize):(r.wnext+=o,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=o))),0},Y0=(e,n)=>{let t,i,o,r,s,a,l,c,f,u,d,p,h,m,y=0,g,k,x,S,A,D,C,O,E=new Uint8Array(4),L,M,J=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(nn(e)||!e.output||!e.input&&e.avail_in!==0)return Je;t=e.state,t.mode===It&&(t.mode=mr),s=e.next_out,o=e.output,l=e.avail_out,r=e.next_in,i=e.input,a=e.avail_in,c=t.hold,f=t.bits,u=a,d=l,O=tn;e:for(;;)switch(t.mode){case Gi:if(t.wrap===0){t.mode=mr;break}for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.wrap&2&&c===35615){t.wbits===0&&(t.wbits=15),t.check=0,E[0]=c&255,E[1]=c>>>8&255,t.check=gt(t.check,E,2,0),c=0,f=0,t.mode=Ya;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",t.mode=ke;break}if((c&15)!==Ka){e.msg="unknown compression method",t.mode=ke;break}if(c>>>=4,f-=4,C=(c&15)+8,t.wbits===0&&(t.wbits=C),C>15||C>t.wbits){e.msg="invalid window size",t.mode=ke;break}t.dmax=1<<t.wbits,t.flags=0,e.adler=t.check=1,t.mode=c&512?rl:It,c=0,f=0;break;case Ya:for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.flags=c,(t.flags&255)!==Ka){e.msg="unknown compression method",t.mode=ke;break}if(t.flags&57344){e.msg="unknown header flags set",t.mode=ke;break}t.head&&(t.head.text=c>>8&1),t.flags&512&&t.wrap&4&&(E[0]=c&255,E[1]=c>>>8&255,t.check=gt(t.check,E,2,0)),c=0,f=0,t.mode=Ja;case Ja:for(;f<32;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.head&&(t.head.time=c),t.flags&512&&t.wrap&4&&(E[0]=c&255,E[1]=c>>>8&255,E[2]=c>>>16&255,E[3]=c>>>24&255,t.check=gt(t.check,E,4,0)),c=0,f=0,t.mode=Qa;case Qa:for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.head&&(t.head.xflags=c&255,t.head.os=c>>8),t.flags&512&&t.wrap&4&&(E[0]=c&255,E[1]=c>>>8&255,t.check=gt(t.check,E,2,0)),c=0,f=0,t.mode=el;case el:if(t.flags&1024){for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.length=c,t.head&&(t.head.extra_len=c),t.flags&512&&t.wrap&4&&(E[0]=c&255,E[1]=c>>>8&255,t.check=gt(t.check,E,2,0)),c=0,f=0}else t.head&&(t.head.extra=null);t.mode=tl;case tl:if(t.flags&1024&&(p=t.length,p>a&&(p=a),p&&(t.head&&(C=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(i.subarray(r,r+p),C)),t.flags&512&&t.wrap&4&&(t.check=gt(t.check,i,p,r)),a-=p,r+=p,t.length-=p),t.length))break e;t.length=0,t.mode=nl;case nl:if(t.flags&2048){if(a===0)break e;p=0;do C=i[r+p++],t.head&&C&&t.length<65536&&(t.head.name+=String.fromCharCode(C));while(C&&p<a);if(t.flags&512&&t.wrap&4&&(t.check=gt(t.check,i,p,r)),a-=p,r+=p,C)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=il;case il:if(t.flags&4096){if(a===0)break e;p=0;do C=i[r+p++],t.head&&C&&t.length<65536&&(t.head.comment+=String.fromCharCode(C));while(C&&p<a);if(t.flags&512&&t.wrap&4&&(t.check=gt(t.check,i,p,r)),a-=p,r+=p,C)break e}else t.head&&(t.head.comment=null);t.mode=ol;case ol:if(t.flags&512){for(;f<16;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.wrap&4&&c!==(t.check&65535)){e.msg="header crc mismatch",t.mode=ke;break}c=0,f=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),e.adler=t.check=0,t.mode=It;break;case rl:for(;f<32;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}e.adler=t.check=bl(c),c=0,f=0,t.mode=Ni;case Ni:if(t.havedict===0)return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,t.hold=c,t.bits=f,V0;e.adler=t.check=1,t.mode=It;case It:if(n===z0||n===zi)break e;case mr:if(t.last){c>>>=f&7,f-=f&7,t.mode=br;break}for(;f<3;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}switch(t.last=c&1,c>>>=1,f-=1,c&3){case 0:t.mode=sl;break;case 1:if(K0(t),t.mode=$i,n===zi){c>>>=2,f-=2;break e}break;case 2:t.mode=ll;break;case 3:e.msg="invalid block type",t.mode=ke}c>>>=2,f-=2;break;case sl:for(c>>>=f&7,f-=f&7;f<32;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if((c&65535)!==(c>>>16^65535)){e.msg="invalid stored block lengths",t.mode=ke;break}if(t.length=c&65535,c=0,f=0,t.mode=yr,n===zi)break e;case yr:t.mode=al;case al:if(p=t.length,p){if(p>a&&(p=a),p>l&&(p=l),p===0)break e;o.set(i.subarray(r,r+p),s),a-=p,r+=p,l-=p,s+=p,t.length-=p;break}t.mode=It;break;case ll:for(;f<14;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.nlen=(c&31)+257,c>>>=5,f-=5,t.ndist=(c&31)+1,c>>>=5,f-=5,t.ncode=(c&15)+4,c>>>=4,f-=4,t.nlen>286||t.ndist>30){e.msg="too many length or distance symbols",t.mode=ke;break}t.have=0,t.mode=cl;case cl:for(;t.have<t.ncode;){for(;f<3;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.lens[J[t.have++]]=c&7,c>>>=3,f-=3}for(;t.have<19;)t.lens[J[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,L={bits:t.lenbits},O=ai(j0,t.lens,0,19,t.lencode,0,t.work,L),t.lenbits=L.bits,O){e.msg="invalid code lengths set",t.mode=ke;break}t.have=0,t.mode=fl;case fl:for(;t.have<t.nlen+t.ndist;){for(;y=t.lencode[c&(1<<t.lenbits)-1],g=y>>>24,k=y>>>16&255,x=y&65535,!(g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(x<16)c>>>=g,f-=g,t.lens[t.have++]=x;else{if(x===16){for(M=g+2;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(c>>>=g,f-=g,t.have===0){e.msg="invalid bit length repeat",t.mode=ke;break}C=t.lens[t.have-1],p=3+(c&3),c>>>=2,f-=2}else if(x===17){for(M=g+3;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}c>>>=g,f-=g,C=0,p=3+(c&7),c>>>=3,f-=3}else{for(M=g+7;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}c>>>=g,f-=g,C=0,p=11+(c&127),c>>>=7,f-=7}if(t.have+p>t.nlen+t.ndist){e.msg="invalid bit length repeat",t.mode=ke;break}for(;p--;)t.lens[t.have++]=C}}if(t.mode===ke)break;if(t.lens[256]===0){e.msg="invalid code -- missing end-of-block",t.mode=ke;break}if(t.lenbits=9,L={bits:t.lenbits},O=ai(vl,t.lens,0,t.nlen,t.lencode,0,t.work,L),t.lenbits=L.bits,O){e.msg="invalid literal/lengths set",t.mode=ke;break}if(t.distbits=6,t.distcode=t.distdyn,L={bits:t.distbits},O=ai(Sl,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,L),t.distbits=L.bits,O){e.msg="invalid distances set",t.mode=ke;break}if(t.mode=$i,n===zi)break e;case $i:t.mode=Vi;case Vi:if(a>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,t.hold=c,t.bits=f,T0(e,d),s=e.next_out,o=e.output,l=e.avail_out,r=e.next_in,i=e.input,a=e.avail_in,c=t.hold,f=t.bits,t.mode===It&&(t.back=-1);break}for(t.back=0;y=t.lencode[c&(1<<t.lenbits)-1],g=y>>>24,k=y>>>16&255,x=y&65535,!(g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(k&&(k&240)===0){for(S=g,A=k,D=x;y=t.lencode[D+((c&(1<<S+A)-1)>>S)],g=y>>>24,k=y>>>16&255,x=y&65535,!(S+g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}c>>>=S,f-=S,t.back+=S}if(c>>>=g,f-=g,t.back+=g,t.length=x,k===0){t.mode=gl;break}if(k&32){t.back=-1,t.mode=It;break}if(k&64){e.msg="invalid literal/length code",t.mode=ke;break}t.extra=k&15,t.mode=dl;case dl:if(t.extra){for(M=t.extra;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.length+=c&(1<<t.extra)-1,c>>>=t.extra,f-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=ul;case ul:for(;y=t.distcode[c&(1<<t.distbits)-1],g=y>>>24,k=y>>>16&255,x=y&65535,!(g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if((k&240)===0){for(S=g,A=k,D=x;y=t.distcode[D+((c&(1<<S+A)-1)>>S)],g=y>>>24,k=y>>>16&255,x=y&65535,!(S+g<=f);){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}c>>>=S,f-=S,t.back+=S}if(c>>>=g,f-=g,t.back+=g,k&64){e.msg="invalid distance code",t.mode=ke;break}t.offset=x,t.extra=k&15,t.mode=pl;case pl:if(t.extra){for(M=t.extra;f<M;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}t.offset+=c&(1<<t.extra)-1,c>>>=t.extra,f-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){e.msg="invalid distance too far back",t.mode=ke;break}t.mode=hl;case hl:if(l===0)break e;if(p=d-l,t.offset>p){if(p=t.offset-p,p>t.whave&&t.sane){e.msg="invalid distance too far back",t.mode=ke;break}p>t.wnext?(p-=t.wnext,h=t.wsize-p):h=t.wnext-p,p>t.length&&(p=t.length),m=t.window}else m=o,h=s-t.offset,p=t.length;p>l&&(p=l),l-=p,t.length-=p;do o[s++]=m[h++];while(--p);t.length===0&&(t.mode=Vi);break;case gl:if(l===0)break e;o[s++]=t.length,l--,t.mode=Vi;break;case br:if(t.wrap){for(;f<32;){if(a===0)break e;a--,c|=i[r++]<<f,f+=8}if(d-=l,e.total_out+=d,t.total+=d,t.wrap&4&&d&&(e.adler=t.check=t.flags?gt(t.check,o,d,s-d):Sr(t.check,o,d,s-d)),d=l,t.wrap&4&&(t.flags?c:bl(c))!==t.check){e.msg="incorrect data check",t.mode=ke;break}c=0,f=0}t.mode=ml;case ml:if(t.wrap&&t.flags){for(;f<32;){if(a===0)break e;a--,c+=i[r++]<<f,f+=8}if(t.wrap&4&&c!==(t.total&4294967295)){e.msg="incorrect length check",t.mode=ke;break}c=0,f=0}t.mode=yl;case yl:O=$0;break e;case ke:O=xl;break e;case kr:return xr;case kl:default:return Je}return e.next_out=s,e.avail_out=l,e.next_in=r,e.avail_in=a,t.hold=c,t.bits=f,(t.wsize||d!==e.avail_out&&t.mode<ke&&(t.mode<br||n!==Za))&&Pl(e,e.output,e.next_out,d-e.avail_out)?(t.mode=kr,xr):(u-=e.avail_in,d-=e.avail_out,e.total_in+=u,e.total_out+=d,t.total+=d,t.wrap&4&&d&&(e.adler=t.check=t.flags?gt(t.check,o,d,e.next_out-d):Sr(t.check,o,d,e.next_out-d)),e.data_type=t.bits+(t.last?64:0)+(t.mode===It?128:0)+(t.mode===$i||t.mode===yr?256:0),(u===0&&d===0||n===Za)&&O===tn&&(O=N0),O)},J0=e=>{if(nn(e))return Je;let n=e.state;return n.window&&(n.window=null),e.state=null,tn},Q0=(e,n)=>{if(nn(e))return Je;let t=e.state;return(t.wrap&2)===0?Je:(t.head=n,n.done=!1,tn)},ep=(e,n)=>{let t=n.length,i,o,r;return nn(e)||(i=e.state,i.wrap!==0&&i.mode!==Ni)?Je:i.mode===Ni&&(o=1,o=Sr(o,n,t,0),o!==i.check)?xl:(r=Pl(e,n,t,t),r?(i.mode=kr,xr):(i.havedict=1,tn))};it.exports.inflateReset=Al;it.exports.inflateReset2=Il;it.exports.inflateResetKeep=_l;it.exports.inflateInit=Z0;it.exports.inflateInit2=Cl;it.exports.inflate=Y0;it.exports.inflateEnd=J0;it.exports.inflateGetHeader=Q0;it.exports.inflateSetDictionary=ep;it.exports.inflateInfo="pako inflate (from Nodeca project)"});var El=ae((Zy,Ol)=>{"use strict";function tp(){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}Ol.exports=tp});var Ul=ae((Ky,An)=>{"use strict";var Ct=Dl(),Ll=dr(),Ir=ur(),Cr=Ui(),np=pr(),ip=El(),Ml=Object.prototype.toString,{Z_NO_FLUSH:op,Z_FINISH:rp,Z_OK:li,Z_STREAM_END:_r,Z_NEED_DICT:Ar,Z_STREAM_ERROR:sp,Z_DATA_ERROR:Fl,Z_MEM_ERROR:ap}=zt();function ci(e){this.options=Ll.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});let n=this.options;n.raw&&n.windowBits>=0&&n.windowBits<16&&(n.windowBits=-n.windowBits,n.windowBits===0&&(n.windowBits=-15)),n.windowBits>=0&&n.windowBits<16&&!(e&&e.windowBits)&&(n.windowBits+=32),n.windowBits>15&&n.windowBits<48&&(n.windowBits&15)===0&&(n.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new np,this.strm.avail_out=0;let t=Ct.inflateInit2(this.strm,n.windowBits);if(t!==li)throw new Error(Cr[t]);if(this.header=new ip,Ct.inflateGetHeader(this.strm,this.header),n.dictionary&&(typeof n.dictionary=="string"?n.dictionary=Ir.string2buf(n.dictionary):Ml.call(n.dictionary)==="[object ArrayBuffer]"&&(n.dictionary=new Uint8Array(n.dictionary)),n.raw&&(t=Ct.inflateSetDictionary(this.strm,n.dictionary),t!==li)))throw new Error(Cr[t])}ci.prototype.push=function(e,n){let t=this.strm,i=this.options.chunkSize,o=this.options.dictionary,r,s,a;if(this.ended)return!1;for(n===~~n?s=n:s=n===!0?rp:op,Ml.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),r=Ct.inflate(t,s),r===Ar&&o&&(r=Ct.inflateSetDictionary(t,o),r===li?r=Ct.inflate(t,s):r===Fl&&(r=Ar));t.avail_in>0&&r===_r&&t.state.wrap>0&&e[t.next_in]!==0;)Ct.inflateReset(t),r=Ct.inflate(t,s);switch(r){case sp:case Fl:case Ar:case ap:return this.onEnd(r),this.ended=!0,!1}if(a=t.avail_out,t.next_out&&(t.avail_out===0||r===_r))if(this.options.to==="string"){let l=Ir.utf8border(t.output,t.next_out),c=t.next_out-l,f=Ir.buf2string(t.output,l);t.next_out=c,t.avail_out=i-c,c&&t.output.set(t.output.subarray(l,l+c),0),this.onData(f)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(r===li&&a===0)){if(r===_r)return r=Ct.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};ci.prototype.onData=function(e){this.chunks.push(e)};ci.prototype.onEnd=function(e){e===li&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Ll.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Pr(e,n){let t=new ci(n);if(t.push(e),t.err)throw t.msg||Cr[t.err];return t.result}function lp(e,n){return n=n||{},n.raw=!0,Pr(e,n)}An.exports.Inflate=ci;An.exports.inflate=Pr;An.exports.inflateRaw=lp;An.exports.ungzip=Pr;An.exports.constants=zt()});var Hi=ae((Yy,mt)=>{"use strict";var{Deflate:cp,deflate:fp,deflateRaw:dp,gzip:up}=Ga(),{Inflate:pp,inflate:hp,inflateRaw:gp,ungzip:mp}=Ul(),yp=zt();mt.exports.Deflate=cp;mt.exports.deflate=fp;mt.exports.deflateRaw=dp;mt.exports.gzip=up;mt.exports.Inflate=pp;mt.exports.inflate=hp;mt.exports.inflateRaw=gp;mt.exports.ungzip=mp;mt.exports.constants=yp});var Bl=ae(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});Fr.decodeJpeg=_p;var fi=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),Wi=4017,Xi=799,qi=3406,Zi=2276,Ki=1567,Yi=3784,In=5793,Ji=2896,bp=100,Dr=64*1024*1024,Or=0,Er=Dr;function Cn(e){if(!isFinite(e)||e<0)throw new Error(`Invalid memory allocation size (${e})`);let n=Or+e;if(n>Er){let t=Math.ceil((n-Er)/1024/1024);throw new Error(`Max memory limit exceeded by at least ${t}MB`)}Or=n}function wp(e,n){let t=16;for(;t>0&&!e[t-1];)t--;let i=[{children:[],index:0}],o=0,r=i[0];for(let s=0;s<t;s++){for(let a=0;a<e[s];a++){for(r=i.pop(),r.children[r.index]=n[o];r.index>0;){if(i.length===0)throw new Error("Could not recreate Huffman Table");r=i.pop()}for(r.index++,i.push(r);i.length<=s;){let l={children:[],index:0};i.push(l),r.children[r.index]=l.children,r=l}o++}if(s+1<t){let a={children:[],index:0};i.push(a),r.children[r.index]=a.children,r=a}}return i[0].children}function vp(e,n,t,i,o,r,s,a,l){let c=t.mcusPerLine,f=t.progressive,u=n,d=0,p=0;function h(){if(p>0)return p--,d>>p&1;if(d=e[n++],d==255){let B=e[n++];if(B)throw new Error(`unexpected marker: ${(d<<8|B).toString(16)}`)}return p=7,d>>>7}function m(B){if(!B)throw new Error("Missing Huffman table");let $=B;for(;;){if($=$[h()],typeof $=="number")return $;if($===void 0)throw new Error("invalid huffman sequence")}}function y(B){let $=0;for(;B>0;)$=$<<1|h(),B--;return $}function g(B){let $=y(B);return $>=1<<B-1?$:$+(-1<<B)+1}function k(B,$){let ne=m(B.huffmanTableDC),ge=ne===0?0:g(ne);$[0]=B.pred+=ge;let Q=1;for(;Q<64;){let ee=m(B.huffmanTableAC),be=ee&15,Se=ee>>4;if(be===0){if(Se<15)break;Q+=16;continue}Q+=Se;let xe=fi[Q];$[xe]=g(be),Q++}}function x(B,$){let ne=m(B.huffmanTableDC),ge=ne===0?0:g(ne)<<l;$[0]=B.pred+=ge}function S(B,$){$[0]|=h()<<l}let A=0;function D(B,$){if(A>0){A--;return}let ne=r,ge=s;for(;ne<=ge;){let Q=m(B.huffmanTableAC),ee=Q&15,be=Q>>4;if(ee===0){if(be<15){A=y(be)+(1<<be)-1;break}ne+=16;continue}ne+=be;let Se=fi[ne];$[Se]=g(ee)*(1<<l),ne++}}let C=0,O=0;function E(B,$){let ne=r,ge=s,Q=0;for(;ne<=ge;){let ee=fi[ne],be=$[ee]<0?-1:1;switch(C){case 0:let Se=m(B.huffmanTableAC),xe=Se&15;if(Q=Se>>4,xe===0)Q<15?(A=y(Q)+(1<<Q),C=4):(Q=16,C=1);else{if(xe!==1)throw new Error("invalid ACn encoding");O=g(xe),C=Q?2:3}continue;case 1:case 2:$[ee]?$[ee]+=(h()<<l)*be:(Q--,Q===0&&(C=C==2?3:0));break;case 3:$[ee]?$[ee]+=(h()<<l)*be:($[ee]=O<<l,C=0);break;case 4:$[ee]&&($[ee]+=(h()<<l)*be);break}ne++}C===4&&(A--,A===0&&(C=0))}function L(B,$,ne,ge,Q){let ee=ne/c|0,be=ne%c,Se=ee*B.v+ge,xe=be*B.h+Q;B.blocks[Se]!==void 0&&$(B,B.blocks[Se][xe])}function M(B,$,ne){let ge=ne/B.blocksPerLine|0,Q=ne%B.blocksPerLine;B.blocks[ge]!==void 0&&$(B,B.blocks[ge][Q])}let J=i.length,pe,R;f?r===0?R=a===0?x:S:R=a===0?D:E:R=k;let ie=0,he;if(J==1?he=i[0].blocksPerLine*i[0].blocksPerColumn:he=c*t.mcusPerColumn,!isFinite(he)||he<0)throw new Error("Invalid number of MCUs");o||(o=he);let ce,Ce,W;for(;ie<he;){for(let B=0;B<J;B++)i[B].pred=0;if(A=0,J==1){pe=i[0];for(let B=0;B<o&&(M(pe,R,ie),ie++,ie!==he);B++);}else for(let B=0;B<o;B++){for(let $=0;$<J;$++){pe=i[$],ce=pe.h,Ce=pe.v;for(let ne=0;ne<Ce;ne++)for(let ge=0;ge<ce;ge++)L(pe,R,ie,ne,ge)}if(ie++,ie===he)break}if(ie===he)do{if(e[n]===255&&e[n+1]!==0)break;n+=1}while(n<e.length-2);if(p=0,W=e[n]<<8|e[n+1],W<65280)throw new Error("marker was not found");if(W>=65488&&W<=65495)n+=2;else break}return n-u}function Sp(e){let n=[],t=e.blocksPerLine,i=e.blocksPerColumn,o=t<<3,r=new Int32Array(64),s=new Uint8Array(64);function a(l,c,f){let u=e.quantizationTable;if(!u)throw new Error("Missing quantization table");let d=f;for(let p=0;p<64;p++)d[p]=l[p]*u[p];for(let p=0;p<8;++p){let h=8*p;if(d[1+h]==0&&d[2+h]==0&&d[3+h]==0&&d[4+h]==0&&d[5+h]==0&&d[6+h]==0&&d[7+h]==0){let O=In*d[0+h]+512>>10;d[0+h]=O,d[1+h]=O,d[2+h]=O,d[3+h]=O,d[4+h]=O,d[5+h]=O,d[6+h]=O,d[7+h]=O;continue}let m=In*d[0+h]+128>>8,y=In*d[4+h]+128>>8,g=d[2+h],k=d[6+h],x=Ji*(d[1+h]-d[7+h])+128>>8,S=Ji*(d[1+h]+d[7+h])+128>>8,A=d[3+h]<<4,D=d[5+h]<<4,C=m-y+1>>1;m=m+y+1>>1,y=C,C=g*Yi+k*Ki+128>>8,g=g*Ki-k*Yi+128>>8,k=C,C=x-D+1>>1,x=x+D+1>>1,D=C,C=S+A+1>>1,A=S-A+1>>1,S=C,C=m-k+1>>1,m=m+k+1>>1,k=C,C=y-g+1>>1,y=y+g+1>>1,g=C,C=x*Zi+S*qi+2048>>12,x=x*qi-S*Zi+2048>>12,S=C,C=A*Xi+D*Wi+2048>>12,A=A*Wi-D*Xi+2048>>12,D=C,d[0+h]=m+S,d[7+h]=m-S,d[1+h]=y+D,d[6+h]=y-D,d[2+h]=g+A,d[5+h]=g-A,d[3+h]=k+x,d[4+h]=k-x}for(let p=0;p<8;++p){let h=p;if(d[8+h]==0&&d[16+h]==0&&d[24+h]==0&&d[32+h]==0&&d[40+h]==0&&d[48+h]==0&&d[56+h]==0){let O=In*f[p+0]+8192>>14;d[0+h]=O,d[8+h]=O,d[16+h]=O,d[24+h]=O,d[32+h]=O,d[40+h]=O,d[48+h]=O,d[56+h]=O;continue}let m=In*d[0+h]+2048>>12,y=In*d[32+h]+2048>>12,g=d[16+h],k=d[48+h],x=Ji*(d[8+h]-d[56+h])+2048>>12,S=Ji*(d[8+h]+d[56+h])+2048>>12,A=d[24+h],D=d[40+h],C=m-y+1>>1;m=m+y+1>>1,y=C,C=g*Yi+k*Ki+2048>>12,g=g*Ki-k*Yi+2048>>12,k=C,C=x-D+1>>1,x=x+D+1>>1,D=C,C=S+A+1>>1,A=S-A+1>>1,S=C,C=m-k+1>>1,m=m+k+1>>1,k=C,C=y-g+1>>1,y=y+g+1>>1,g=C,C=x*Zi+S*qi+2048>>12,x=x*qi-S*Zi+2048>>12,S=C,C=A*Xi+D*Wi+2048>>12,A=A*Wi-D*Xi+2048>>12,D=C,d[0+h]=m+S,d[56+h]=m-S,d[8+h]=y+D,d[48+h]=y-D,d[16+h]=g+A,d[40+h]=g-A,d[24+h]=k+x,d[32+h]=k-x}for(let p=0;p<64;++p){let h=128+(d[p]+8>>4);c[p]=h<0?0:h>255?255:h}}Cn(o*i*8);for(let l=0;l<i;l++){let c=l<<3;for(let f=0;f<8;f++)n.push(new Uint8Array(o));for(let f=0;f<t;f++){a(e.blocks[l][f],s,r);let u=0,d=f<<3;for(let p=0;p<8;p++){let h=n[c+p];for(let m=0;m<8;m++)h[d+m]=s[u++]}}}return n}function Pt(e){return e<0?0:e>255?255:e}function xp(e){let n={width:0,height:0,adobe:void 0,components:[],exifBuffer:void 0,jfif:void 0},t=bp*1e3*1e3,i=0;function o(){let g=e[i]<<8|e[i+1];return i+=2,g}function r(){let g=o(),k=e.subarray(i,i+g-2);return i+=k.length,k}function s(g){let k=0,x=0;for(let D in g.components)if(g.components.hasOwnProperty(D)){let C=g.components[D];k<C.h&&(k=C.h),x<C.v&&(x=C.v)}let S=Math.ceil(g.samplesPerLine/8/k),A=Math.ceil(g.scanLines/8/x);for(let D in g.components)if(g.components.hasOwnProperty(D)){let C=g.components[D],O=Math.ceil(Math.ceil(g.samplesPerLine/8)*C.h/k),E=Math.ceil(Math.ceil(g.scanLines/8)*C.v/x),L=S*C.h,M=A*C.v,J=M*L,pe=[];Cn(J*256);for(let R=0;R<M;R++){let ie=[];for(let he=0;he<L;he++)ie.push(new Int32Array(64));pe.push(ie)}C.blocksPerLine=O,C.blocksPerColumn=E,C.blocks=pe}g.maxH=k,g.maxV=x,g.mcusPerLine=S,g.mcusPerColumn=A}let a=null,l=null,c,f=0,u=[],d=[],p=[],h=[],m=o(),y=-1;if(m!=65496)throw new Error("SOI not found");for(m=o();m!=65497;){switch(m){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:{let g=r();m===65504&&g[0]===74&&g[1]===70&&g[2]===73&&g[3]===70&&g[4]===0&&(a={version:{major:g[5],minor:g[6]},densityUnits:g[7],xDensity:g[8]<<8|g[9],yDensity:g[10]<<8|g[11],thumbWidth:g[12],thumbHeight:g[13],thumbData:g.subarray(14,14+3*g[12]*g[13])}),m===65505&&g[0]===69&&g[1]===120&&g[2]===105&&g[3]===102&&g[4]===0&&(n.exifBuffer=g.subarray(5,g.length)),m===65518&&g[0]===65&&g[1]===100&&g[2]===111&&g[3]===98&&g[4]===101&&g[5]===0&&(l={version:g[6],flags0:g[7]<<8|g[8],flags1:g[9]<<8|g[10],transformCode:g[11]});break}case 65499:{let k=o()+i-2;for(;i<k;){let x=e[i++];Cn(256);let S=new Int32Array(64);if(x>>4===0)for(let A=0;A<64;A++){let D=fi[A];S[D]=e[i++]}else if(x>>4===1)for(let A=0;A<64;A++){let D=fi[A];S[D]=o()}else throw new Error("DQT: invalid table spec");u[x&15]=S}break}case 65472:case 65473:case 65474:{o(),c={extended:m===65473,progressive:m===65474,precision:e[i++],scanLines:o(),samplesPerLine:o(),components:{},componentsOrder:[],maxH:0,maxV:0,mcusPerLine:0,mcusPerColumn:0};let g=c.scanLines*c.samplesPerLine;if(g>t){let x=Math.ceil((g-t)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${x}MP`)}let k=e[i++];if(!k)throw new Error("SOF: no components in frame");for(let x=0;x<k;x++){let S=e[i],A=e[i+1]>>4,D=e[i+1]&15;if(A<1||A>4||D<1||D>4)throw new Error(`SOF: invalid sampling factors (${A}x${D})`);let C=e[i+2];c.componentsOrder.push(S),c.components[S]={h:A,v:D,quantizationIdx:C,blocksPerColumn:0,blocksPerLine:0,blocks:[],pred:0},i+=3}s(c),d.push(c);break}case 65476:{let g=o();for(let k=2;k<g;){let x=e[i++],S=new Uint8Array(16),A=0;for(let E=0;E<16;E++,i++)A+=S[E]=e[i];Cn(16+A);let D=new Uint8Array(A);for(let E=0;E<A;E++,i++)D[E]=e[i];k+=17+A;let C=x&15,O=x>>4===0?h:p;O[C]=wp(S,D)}break}case 65501:o(),f=o();break;case 65500:o(),o();break;case 65498:{if(!c)throw new Error("SOS: scan before frame header (SOF)");o();let g=e[i++],k=[];for(let C=0;C<g;C++){let O=e[i++],E=c.components[O];if(!E)throw new Error(`SOS: component ${O} not found in frame`);let L=e[i++];E.huffmanTableDC=h[L>>4],E.huffmanTableAC=p[L&15],k.push(E)}let x=e[i++],S=e[i++],A=e[i++],D=vp(e,i,c,k,f,x,S,A>>4,A&15);i+=D;break}case 65535:e[i]!==255&&i--;break;default:{if(e[i-3]==255&&e[i-2]>=192&&e[i-2]<=254){i-=3;break}else if(m===224||m==225){if(y!==-1)throw new Error(`first unknown JPEG marker at offset ${y.toString(16)}, second unknown JPEG marker ${m.toString(16)} at offset ${(i-1).toString(16)}`);y=i-1;let g=o();if(e[i+g-2]===255){i+=g-2;break}}throw new Error("unknown JPEG marker "+m.toString(16))}}m=o()}if(d.length!=1)throw new Error("only single frame JPEGs supported");for(let g=0;g<d.length;g++){let k=d[g].components;for(let x of Object.keys(k)){let S=k[+x],A=u[S.quantizationIdx];if(!A)throw new Error(`Missing quantization table ${S.quantizationIdx}`);S.quantizationTable=A}}n.width=c.samplesPerLine,n.height=c.scanLines,n.jfif=a,n.adobe=l,n.components=[];for(let g=0;g<c.componentsOrder.length;g++){let k=c.components[c.componentsOrder[g]];n.components.push({lines:Sp(k),scaleX:k.h/c.maxH,scaleY:k.v/c.maxV})}return n}function kp(e){let n=0,t=!1,i=e.width,o=e.height,r=i*o*e.components.length;Cn(r);let s=new Uint8Array(r);switch(e.components.length){case 1:{let a=e.components[0];for(let l=0;l<o;l++){let c=a.lines[0|l*a.scaleY];for(let f=0;f<i;f++){let u=c[0|f*a.scaleX];s[n++]=u}}break}case 2:{let a=e.components[0],l=e.components[1];for(let c=0;c<o;c++){let f=a.lines[0|c*a.scaleY],u=l.lines[0|c*l.scaleY];for(let d=0;d<i;d++){let p=f[0|d*a.scaleX];s[n++]=p;let h=u[0|d*l.scaleX];s[n++]=h}}break}case 3:{t=e.jfif?!0:e.adobe?!!e.adobe.transformCode:!0;let a=e.components[0],l=e.components[1],c=e.components[2];for(let f=0;f<o;f++){let u=a.lines[0|f*a.scaleY],d=l.lines[0|f*l.scaleY],p=c.lines[0|f*c.scaleY];for(let h=0;h<i;h++){let m,y,g,k,x,S;t?(m=u[0|h*a.scaleX],y=d[0|h*l.scaleX],g=p[0|h*c.scaleX],k=Pt(m+1.402*(g-128)),x=Pt(m-.3441363*(y-128)-.71413636*(g-128)),S=Pt(m+1.772*(y-128))):(k=u[0|h*a.scaleX],x=d[0|h*l.scaleX],S=p[0|h*c.scaleX]),s[n++]=k,s[n++]=x,s[n++]=S}}break}case 4:{if(!e.adobe)throw new Error("Unsupported color mode (4 components)");t=!1,e.adobe&&e.adobe.transformCode&&(t=!0);let a=e.components[0],l=e.components[1],c=e.components[2],f=e.components[3];for(let u=0;u<o;u++){let d=a.lines[0|u*a.scaleY],p=l.lines[0|u*l.scaleY],h=c.lines[0|u*c.scaleY],m=f.lines[0|u*f.scaleY];for(let y=0;y<i;y++){let g,k,x,S,A,D,C;t?(g=d[0|y*a.scaleX],k=p[0|y*l.scaleX],x=h[0|y*c.scaleX],S=m[0|y*f.scaleX],A=255-Pt(g+1.402*(x-128)),D=255-Pt(g-.3441363*(k-128)-.71413636*(x-128)),C=255-Pt(g+1.772*(k-128))):(A=d[0|y*a.scaleX],D=p[0|y*l.scaleX],C=h[0|y*c.scaleX],S=m[0|y*f.scaleX]),s[n++]=255-A,s[n++]=255-D,s[n++]=255-C,s[n++]=255-S}}break}default:throw new Error("Unsupported color mode")}return s}function _p(e,n,t){if(Or=0,Er=t===void 0?Dr:Math.min(Dr,Math.max(0,t)),e.length===0)throw new Error("Empty jpeg buffer");let i=xp(e);Cn(i.width*i.height*4);let o=kp(i),r=n(i.width,i.height),s=r.width,a=r.height,l=r.data,c=0,f=0;switch(i.components.length){case 1:for(let u=0;u<a;u++)for(let d=0;d<s;d++){let p=o[c++];l[f++]=p,l[f++]=p,l[f++]=p,l[f++]=255}break;case 2:for(let u=0;u<a;u++)for(let d=0;d<s;d++){let p=o[c++],h=o[c++];l[f++]=p,l[f++]=p,l[f++]=p,l[f++]=h}break;case 3:for(let u=0;u<a;u++)for(let d=0;d<s;d++){let p=o[c++],h=o[c++],m=o[c++];l[f++]=p,l[f++]=h,l[f++]=m,l[f++]=255}break;case 4:for(let u=0;u<a;u++)for(let d=0;d<s;d++){let p=o[c++],h=o[c++],m=o[c++],y=o[c++],g=255-Pt(p*(1-y/255)+y),k=255-Pt(h*(1-y/255)+y),x=255-Pt(m*(1-y/255)+y);l[f++]=g,l[f++]=k,l[f++]=x,l[f++]=255}break;default:throw new Error("Unsupported color mode")}return r}});var Ot=ae(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.createImageData=G.createCanvas=G.MaskParams=G.LayerMaskFlags=G.ColorSpace=G.largeAdditionalInfoKeys=G.largeAdditionalInfoKeysObserved=G.layerColors=G.toBlendMode=G.fromBlendMode=G.MOCK_HANDLERS=void 0;G.revMap=$l;G.createEnum=Ip;G.offsetForChannel=Cp;G.normalizeLabAB=Pp;G.denormalizeLabAB=Dp;G.clamp=Op;G.hasAlpha=Ep;G.cmykToRgbValues=Qi;G.rgbToCmykValues=Up;G.resetImageData=Bp;G.imageDataToCanvas=Rp;G.decodeBitmap=Tp;G.writeDataRaw=jp;G.writeDataRLE=zp;G.planarToBytes=Vl;G.writeDataRLEBytes=$p;G.writeDataZipWithPrediction=Vp;G.writeDataZipWithoutPrediction=Np;G.createCanvasFromData=Gp;G.initializeCanvas=Xp;var zl=Hi(),Ap=Bl();G.MOCK_HANDLERS=!1;G.fromBlendMode={};G.toBlendMode={pass:"pass through",norm:"normal",diss:"dissolve",dark:"darken","mul ":"multiply",idiv:"color burn",lbrn:"linear burn",dkCl:"darker color",lite:"lighten",scrn:"screen","div ":"color dodge",lddg:"linear dodge",lgCl:"lighter color",over:"overlay",sLit:"soft light",hLit:"hard light",vLit:"vivid light",lLit:"linear light",pLit:"pin light",hMix:"hard mix",diff:"difference",smud:"exclusion",fsub:"subtract",fdiv:"divide","hue ":"hue","sat ":"saturation",colr:"color","lum ":"luminosity"};Object.keys(G.toBlendMode).forEach(e=>G.fromBlendMode[G.toBlendMode[e]]=e);G.layerColors=["none","red","orange","yellow","green","blue","violet","gray","seafoam","indigo","magenta","fuchsia"];G.largeAdditionalInfoKeysObserved=["lnk3","lnkE","pths","extd","extn","FELS","artd"];G.largeAdditionalInfoKeys=["LMsk","Lr16","Lr32","Layr","Mt16","Mt32","Mtrn","Alph","FMsk","lnk2","FEid","FXid","PxSD","cinf",...G.largeAdditionalInfoKeysObserved];function $l(e){let n={};return Object.keys(e).forEach(t=>n[e[t]]=t),n}function Ip(e,n,t){let i=$l(t);return{decode:s=>{let a=s.split(".")[1];if(a&&!i[a]){if(Object.prototype.hasOwnProperty.call(t,a))return a;let l=a.replace(/([A-Z])/g," $1").toLowerCase();if(Object.prototype.hasOwnProperty.call(t,l))return l;throw new Error(`Unrecognized value for enum: '${s}'`)}return i[a]||n},encode:s=>{if(s&&!t[s])throw new Error(`Invalid value for enum: '${s}'`);return`${e}.${s?t[s]:t[n]}`}}}var Rl;(function(e){e[e.RGB=0]="RGB",e[e.HSB=1]="HSB",e[e.CMYK=2]="CMYK",e[e.Lab=7]="Lab",e[e.Grayscale=8]="Grayscale"})(Rl||(G.ColorSpace=Rl={}));var Tl;(function(e){e[e.PositionRelativeToLayer=1]="PositionRelativeToLayer",e[e.LayerMaskDisabled=2]="LayerMaskDisabled",e[e.InvertLayerMaskWhenBlending=4]="InvertLayerMaskWhenBlending",e[e.LayerMaskFromRenderingOtherData=8]="LayerMaskFromRenderingOtherData",e[e.MaskHasParametersAppliedToIt=16]="MaskHasParametersAppliedToIt"})(Tl||(G.LayerMaskFlags=Tl={}));var jl;(function(e){e[e.UserMaskDensity=1]="UserMaskDensity",e[e.UserMaskFeather=2]="UserMaskFeather",e[e.VectorMaskDensity=4]="VectorMaskDensity",e[e.VectorMaskFeather=8]="VectorMaskFeather"})(jl||(G.MaskParams=jl={}));function Cp(e,n){switch(e){case 0:return 0;case 1:return 1;case 2:return 2;case 3:return n?3:e+1;case-1:return n?4:3;default:return e+1}}function Pp(e,n=1){return e<0?e/(128*n):e/(127*n)}function Dp(e,n=1){return e<0?e*(128*n):e*(127*n)}function Op(e,n,t){return e<n?n:e>t?t:e}function Ep(e){let n=e.width*e.height*4,t=e.data instanceof Float32Array?1:e.data instanceof Uint16Array?65535:255;for(let i=3;i<n;i+=4)if(e.data[i]!==t)return!0;return!1}function Qi(e,n,t,i,o){o[0]=255+e*(-4.387332384609988*e+54.48615194189176*n+18.82290502165302*t+212.25662451639585*i-285.2331026137004)+n*(1.7149763477362134*n-5.6096736904047315*t-17.873870861415444*i-5.497006427196366)+t*(-2.5217340131683033*t-21.248923337353073*i+17.5119270841813)+i*(-21.86122147463605*i-189.48180835922747),o[1]=255+e*(8.841041422036149*e+60.118027045597366*n+6.871425592049007*t+31.159100130055922*i-79.2970844816548)+n*(-15.310361306967817*n+17.575251261109482*t+131.35250912493976*i-190.9453302588951)+t*(4.444339102852739*t+9.8632861493405*i-24.86741582555878)+i*(-20.737325471181034*i-187.80453709719578),o[2]=255+e*(.8842522430003296*e+8.078677503112928*n+30.89978309703729*t-.23883238689178934*i-14.183576799673286)+n*(10.49593273432072*n+63.02378494754052*t+50.606957656360734*i-112.23884253719248)+t*(.03296041114873217*t+115.60384449646641*i-193.58209356861505)+i*(-22.33816807309886*i-180.12613974708367)}var Dt=e=>e<0?0:e>1?1:e;function Fp(e,n,t,i,o){let r=[0,0,0],s=[0,0,0],a=[0,0,0],l=[[0,0,0],[0,0,0],[0,0,0]],c=1e-4;for(let f=0;f<20&&(Qi(o[0],o[1],o[2],i,r),a[0]=r[0]-e,a[1]=r[1]-n,a[2]=r[2]-t,!(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]<1e-6));f++){for(let C=0;C<3;C++){let O=o[C];o[C]=O+c,Qi(o[0],o[1],o[2],i,s),o[C]=O;for(let E=0;E<3;E++)l[E][C]=(s[E]-r[E])/c}let[[u,d,p],[h,m,y],[g,k,x]]=l,S=u*(m*x-y*k)-d*(h*x-y*g)+p*(h*k-m*g);if(Math.abs(S)<1e-12)break;let A=[[m*x-y*k,p*k-d*x,d*y-p*m],[y*g-h*x,u*x-p*g,p*h-u*y],[h*k-m*g,d*g-u*k,u*m-d*h]],D=0;for(let C=0;C<3;C++){let O=-(A[C][0]*a[0]+A[C][1]*a[1]+A[C][2]*a[2])/S,E=Dt(o[C]+O);D+=Math.abs(E-o[C]),o[C]=E}if(D<1e-9)break}return Qi(o[0],o[1],o[2],i,r),(r[0]-e)*(r[0]-e)+(r[1]-n)*(r[1]-n)+(r[2]-t)*(r[2]-t)}function Lp(e,n,t,i){let o=Math.max(e,n,t)/255,r=Math.pow(Dt((1-o-.2)/.8),1.3),s=[0,0,0],a=1/0,l=1/0,c=f=>{s[0]=Dt(1-e/255-f),s[1]=Dt(1-n/255-f),s[2]=Dt(1-t/255-f);let u=Fp(e,n,t,f,s),d=Math.max(u,.1)+Math.abs(f-r)*.01;d<a&&(a=d,l=u,i[0]=s[0],i[1]=s[1],i[2]=s[2],i[3]=f)};if(c(r),l>.1)for(let f=0;f<=10;f++)c(f/10);if(l>.1){let f=i[3];for(let u=-5;u<=5;u++)c(Dt(f+u/100))}}var eo=33,Lr;function Mp(){if(!Lr){let e=eo,n=new Float32Array(e*e*e*4),t=[0,0,0,0];for(let i=0,o=0;i<e;i++)for(let r=0;r<e;r++)for(let s=0;s<e;s++,o+=4)Lp(i*255/(e-1),r*255/(e-1),s*255/(e-1),t),n[o]=t[0],n[o+1]=t[1],n[o+2]=t[2],n[o+3]=t[3];Lr=n}return Lr}function Up(e,n,t,i){let o=Mp(),r=eo-1,s=Dt(e)*r,a=Dt(n)*r,l=Dt(t)*r,c=Math.min(r-1,Math.floor(s)),f=Math.min(r-1,Math.floor(a)),u=Math.min(r-1,Math.floor(l)),d=s-c,p=a-f,h=l-u;i[0]=i[1]=i[2]=i[3]=0;for(let m=0;m<8;m++){let y=m>>2,g=m>>1&1,k=m&1,x=(y?d:1-d)*(g?p:1-p)*(k?h:1-h),S=(((c+y)*eo+f+g)*eo+u+k)*4;i[0]+=x*o[S],i[1]+=x*o[S+1],i[2]+=x*o[S+2],i[3]+=x*o[S+3]}}function Bp({data:e}){let n=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255;for(let t=0,i=e.length|0;t<i;t=t+4|0)e[t+0]=0,e[t+1]=0,e[t+2]=0,e[t+3]=n}function Rp(e){let n=(0,G.createCanvas)(e.width,e.height),t;if(e.data instanceof Uint8ClampedArray)t=e;else{t=(0,G.createImageData)(e.width,e.height);let i=e.data,o=t.data;if(i instanceof Float32Array)for(let r=0,s=i.length;r<s;r+=4)o[r+0]=Math.round(Math.pow(i[r+0],1/2.2)*255),o[r+1]=Math.round(Math.pow(i[r+1],1/2.2)*255),o[r+2]=Math.round(Math.pow(i[r+2],1/2.2)*255),o[r+3]=Math.round(i[r+3]*255);else{let r=i instanceof Uint16Array?8:0;for(let s=0,a=i.length;s<a;s++)o[s]=i[s]>>>r}}return n.getContext("2d").putImageData(t,0,0),n}function Tp(e,n,t,i){if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray))throw new Error("Invalid bit depth");for(let o=0,r=0,s=0;o<i;o++)for(let a=0;a<t;){let l=e[s++];for(let c=0;c<8&&a<t;c++,a++,r+=4){let f=l&128?0:255;l=l<<1,n[r+0]=f,n[r+1]=f,n[r+2]=f,n[r+3]=255}}}function jp(e,n,t,i){if(!t||!i)return;let o=new Uint8Array(t*i);for(let r=0;r<o.length;r++)o[r]=e.data[r*4+n];return o}function zp(e,{data:n,width:t,height:i},o,r){if(!t||!i)return e.subarray(0,0);let s=4*t|0,a=0,l=o.length*(r?4:2)*i|0;for(let c of o)for(let f=0,u=c|0;f<i;f++){let d=f*s|0,p=d+s|0,h=p+c-4|0,m=h-4|0,y=l;for(u=d+c|0;u<p;u=u+4|0)if(u<m){let k=n[u];u=u+4|0;let x=n[u];u=u+4|0;let S=n[u];if(k===x&&k===S){let A=3;for(;A<128&&u<h&&n[u+4|0]===k;)A=A+1|0,u=u+4|0;e[l++]=1-A,e[l++]=k}else{let A=l,D=!0,C=1;for(e[l++]=0,e[l++]=k;u<h&&C<128;)if(u=u+4|0,k=x,x=S,S=n[u],k===x&&k===S){u=u-12|0,D=!1;break}else C++,e[l++]=k;D&&(C<127?(e[l++]=x,e[l++]=S,C+=2):C<128?(e[l++]=x,C++,u=u-4|0):u=u-8|0),e[A]=C-1}}else u===h?(e[l++]=0,e[l++]=n[u]):(e[l++]=1,e[l++]=n[u],u=u+4|0,e[l++]=n[u]);if(l>e.length)throw new Error(`RLE buffer too small (${e.length})`);let g=l-y;r&&(e[a++]=g>>24&255,e[a++]=g>>16&255),e[a++]=g>>8&255,e[a++]=g&255}return e.subarray(0,l)}function Vl(e){if(e instanceof Uint8Array)return e;let n=new Uint8Array(e.byteLength),t=new DataView(n.buffer);if(e instanceof Uint16Array)for(let i=0;i<e.length;i++)t.setUint16(i*2,e[i],!1);else for(let i=0;i<e.length;i++)t.setFloat32(i*4,e[i],!1);return n}function $p(e,n,t,i){let o=i?4:2,r=new Uint8Array(t*(o+n+Math.ceil(n/128))),s=o*t;for(let a=0;a<t;a++){let l=s,c=a*n,f=c+n,u=c;for(;u<f;){let p=1;for(;u+p<f&&p<128&&e[u+p]===e[u];)p++;if(p>1)r[s++]=257-p,r[s++]=e[u],u+=p;else{let h=s++,m=0;for(;u<f&&m<128&&!(u+2<f&&e[u]===e[u+1]&&e[u]===e[u+2]);)r[s++]=e[u++],m++;r[h]=m-1}}let d=s-l;for(let p=0;p<o;p++)r[a*o+p]=d>>>(o-p-1)*8&255}return r.subarray(0,s)}function Vp(e,n,t){let i;if(e instanceof Uint8Array){i=new Uint8Array(n*t);for(let o=0,r=0;o<t;o++)for(let s=0,a=0;s<n;s++,r++)i[r]=e[r]-a,a=e[r]}else if(e instanceof Uint16Array){i=new Uint8Array(n*t*2);for(let o=0,r=0;o<t;o++)for(let s=0,a=0;s<n;s++,r++){let l=e[r]-a&65535;i[r*2]=l>>8,i[r*2+1]=l&255,a=e[r]}}else{let o=n*4,r=Vl(e);i=new Uint8Array(o*t);for(let s=0;s<t;s++){let a=s*o;for(let l=0;l<n;l++)for(let c=0;c<4;c++)i[a+c*n+l]=r[a+l*4+c];for(let l=o-1;l>0;l--)i[a+l]-=i[a+l-1]}}return(0,zl.deflate)(i)}function Np({data:e,width:n,height:t},i){let o=n*t,r=new Uint8Array(o),s=[],a=0;for(let l of i){for(let f=0,u=l;f<o;f++,u+=4)r[f]=e[u];let c=(0,zl.deflate)(r);s.push(c),a+=c.byteLength}if(s.length>0){let l=new Uint8Array(a),c=0;for(let f of s)l.set(f,c),c+=f.byteLength;return l}else return s[0]}function Gp(e,n){let t=(0,G.createCanvas)(100,100);try{let i=t.getContext("2d"),o=(0,Ap.decodeJpeg)(e,(r,s)=>i.createImageData(r,s),n.totalMemoryLimit);t.width=o.width,t.height=o.height,i.putImageData(o,0,0),n.totalMemoryLimit!==void 0&&(n.totalMemoryLimit-=o.width*o.height*4)}catch(i){n.log("JPEG decompression error",i.message)}return t}var Hp=()=>{throw new Error("Canvas not initialized, use initializeCanvas method to set up createCanvas method")};G.createCanvas=Hp;var Mr,Wp=(e,n)=>(Mr||(Mr=(0,G.createCanvas)(1,1)),Mr.getContext("2d").createImageData(e,n));G.createImageData=Wp;typeof document<"u"&&(G.createCanvas=(e,n)=>{let t=document.createElement("canvas");return t.width=e,t.height=n,t});function Xp(e,n){G.createCanvas=e,G.createImageData=n||G.createImageData}});var no=ae(to=>{"use strict";to.byteLength=Zp;to.toByteArray=Yp;to.fromByteArray=eh;var yt=[],Qe=[],qp=typeof Uint8Array<"u"?Uint8Array:Array,Ur="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(on=0,Nl=Ur.length;on<Nl;++on)yt[on]=Ur[on],Qe[Ur.charCodeAt(on)]=on;var on,Nl;Qe[45]=62;Qe[95]=63;function Gl(e){var n=e.length;if(n%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=n);var i=t===n?0:4-t%4;return[t,i]}function Zp(e){var n=Gl(e),t=n[0],i=n[1];return(t+i)*3/4-i}function Kp(e,n,t){return(n+t)*3/4-t}function Yp(e){var n,t=Gl(e),i=t[0],o=t[1],r=new qp(Kp(e,i,o)),s=0,a=o>0?i-4:i,l;for(l=0;l<a;l+=4)n=Qe[e.charCodeAt(l)]<<18|Qe[e.charCodeAt(l+1)]<<12|Qe[e.charCodeAt(l+2)]<<6|Qe[e.charCodeAt(l+3)],r[s++]=n>>16&255,r[s++]=n>>8&255,r[s++]=n&255;return o===2&&(n=Qe[e.charCodeAt(l)]<<2|Qe[e.charCodeAt(l+1)]>>4,r[s++]=n&255),o===1&&(n=Qe[e.charCodeAt(l)]<<10|Qe[e.charCodeAt(l+1)]<<4|Qe[e.charCodeAt(l+2)]>>2,r[s++]=n>>8&255,r[s++]=n&255),r}function Jp(e){return yt[e>>18&63]+yt[e>>12&63]+yt[e>>6&63]+yt[e&63]}function Qp(e,n,t){for(var i,o=[],r=n;r<t;r+=3)i=(e[r]<<16&16711680)+(e[r+1]<<8&65280)+(e[r+2]&255),o.push(Jp(i));return o.join("")}function eh(e){for(var n,t=e.length,i=t%3,o=[],r=16383,s=0,a=t-i;s<a;s+=r)o.push(Qp(e,s,s+r>a?a:s+r));return i===1?(n=e[t-1],o.push(yt[n>>2]+yt[n<<4&63]+"==")):i===2&&(n=(e[t-2]<<8)+e[t-1],o.push(yt[n>>10]+yt[n>>4&63]+yt[n<<2&63]+"=")),o.join("")}});var Br=ae(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.stringLengthInBytes=Wl;Pn.encodeStringTo=Xl;Pn.encodeString=ih;Pn.decodeString=oh;function th(e){return(e&4294967168)===0?1:(e&4294965248)===0?2:(e&4294901760)===0?3:4}function Hl(e,n){let t=e.charCodeAt(n);if(t<55296||t>57343)return t;if(t<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);if(i>=56320&&i<=57343)return((t&1023)<<10)+(i&1023)+65536}return 65533}function Wl(e){let n=0;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);i<128?n+=1:i<2048?n+=2:Hl(e,t)>65535?(n+=4,t++):n+=3}return n}function nh(e,n,t){let i=th(t);switch(i){case 1:e[n]=t;break;case 2:e[n]=t>>6&31|192,e[n+1]=t&63|128;break;case 3:e[n]=t>>12&15|224,e[n+1]=t>>6&63|128,e[n+2]=t&63|128;break;default:e[n]=t>>18&7|240,e[n+1]=t>>12&63|128,e[n+2]=t>>6&63|128,e[n+3]=t&63|128;break}return i}function Xl(e,n,t){for(let i=0;i<t.length;i++){let o=t.charCodeAt(i);if(o<128)e[n++]=o;else{let r=Hl(t,i);r>65535&&i++,n+=nh(e,n,r)}}return n}function ih(e){if(e.length>1e3&&typeof TextEncoder<"u")return new TextEncoder().encode(e);let n=new Uint8Array(Wl(e));return Xl(n,0,e),n}function oh(e){let n=[];function t(l){l>65535&&(l-=65536,n.push(String.fromCharCode(l>>>10&1023|55296)),l=56320|l&1023),n.push(String.fromCharCode(l))}let i=0,o=0,r=0,s=128,a=191;for(let l=0;l<e.length;l++){let c=e[l];if(r===0){c<=127?t(c):c>=194&&c<=223?(r=1,i=c&31):c>=224&&c<=239?(c===224&&(s=160),c===237&&(a=159),r=2,i=c&15):c>=240&&c<=244?(c===240&&(s=144),c===244&&(a=143),r=3,i=c&7):t(65533);continue}if(c<s||c>a){i=0,r=0,o=0,s=128,a=191,t(65533),l--;continue}s=128,a=191,i=i<<6|c&63,o++,o===r&&(t(i),i=0,r=0,o=0)}return r!==0&&t(65533),n.join("")}});var ao=ae(_=>{"use strict";var rh=_&&_.__rest||function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]]);return t};Object.defineProperty(_,"__esModule",{value:!0});_.FlCl=_.ExtR=_.ExtT=_.DfsM=_.blurType=_.Lns=_.MztT=_.Chnl=_.Dstr=_.ZZTy=_.Wvtp=_.SphM=_.RplS=_.Cnvr=_.UndA=_.DspM=_.SmBQ=_.SmBM=_.BlrQ=_.BlrM=_.strokeStyleLineAlignment=_.strokeStyleLineJoinType=_.strokeStyleLineCapType=_.ESliceBGColorType=_.ESliceOrigin=_.ESliceVertAlign=_.ESliceHorzAlign=_.ESliceType=_.FrFl=_.FStl=_.ClrS=_.Clry=_.gradientInterpolationMethodType=_.stdTrackID=_.animInterpStyleEnum=_.GrdT=_.IGSr=_.BETE=_.BESs=_.bvlT=_.BESl=_.BlnM=_.warpStyle=_.Annt=_.Ornt=_.textGridding=_.outputSettingsRoot=_.layerStateRoot=_.cameraRawFilterKeyTypes=_.cameraRawFilterClassID=void 0;_.patternColorHandling=_.presetKindType=_.prjM=_.FlMd=_.IntC=_.IntE=_.Drct=_.WndM=_.CntE=void 0;_.readAsciiStringOrClassId=bt;_.writeAsciiStringOrClassId=et;_.readDescriptorStructure=jr;_.writeDescriptorStructure=zr;_.pathSelectionStateToReference=hh;_.writeClassStructure=Dn;_.readVersionAndDescriptor=mh;_.writeVersionAndDescriptor=yh;_.horzVrtcToXY=oo;_.xyToHorzVrtc=ro;_.descBoundsToBounds=bh;_.boundsToDescBounds=wh;_.serializeEffects=ac;_.parseEffects=lc;_.parseTrackList=vh;_.serializeTrackList=Sh;_.parseVectorContent=xh;_.serializeVectorContent=kh;_.parseColor=sn;_.serializeColor=an;_.parseAngle=On;_.parsePercent=Pe;_.parsePercentOrAngle=yc;_.parseUnits=wt;_.parseUnitsOrNumber=bc;_.parseUnitsToNumber=Ch;_.unitsAngle=ln;_.unitsPercent=rt;_.unitsPercentF=St;_.unitsValue=vt;_.frac=Ph;var V=Ot(),te=st(),Z=En();function sh(e){let n={};return Object.keys(e).forEach(t=>n[e[t]]=t),n}var di={"#Ang":"Angle","#Rsl":"Density","#Rlt":"Distance","#Nne":"None","#Prc":"Percent","#Pxl":"Pixels","#Mlm":"Millimeters","#Pnt":"Points",RrPi:"Picas",RrIn:"Inches",RrCm:"Centimeters"},io=sh(di);function F(e,n){return{name:e,classID:n}}var X=F("","null"),Rr=!1,ec={strokeStyleContent:F("","solidColorLayer"),printProofSetup:F(Rr?"\u6821\u6837\u8BBE\u7F6E":"Proof Setup","proofSetup"),Grad:F(Rr?"\u6E10\u53D8":"Gradient","Grdn"),Trnf:F(Rr?"\u53D8\u6362":"Transform","Trnf"),patternFill:F("","patternFill"),ebbl:F("","ebbl"),SoFi:F("","SoFi"),GrFl:F("","GrFl"),sdwC:F("","RGBC"),hglC:F("","RGBC"),"Clr ":F("","RGBC"),tintColor:F("","RGBC"),Ofst:F("","Pnt "),ChFX:F("","ChFX"),MpgS:F("","ShpC"),DrSh:F("","DrSh"),IrSh:F("","IrSh"),OrGl:F("","OrGl"),IrGl:F("","IrGl"),TrnS:F("","ShpC"),Ptrn:F("","Ptrn"),FrFX:F("","FrFX"),phase:F("","Pnt "),frameStep:X,duration:X,workInTime:X,workOutTime:X,audioClipGroupList:X,bounds:F("","Rctn"),customEnvelopeWarp:F("","customEnvelopeWarp"),warp:F("","warp"),"Sz ":F("","Pnt "),origin:F("","Pnt "),autoExpandOffset:F("","Pnt "),keyOriginShapeBBox:F("","unitRect"),Vrsn:X,psVersion:X,docDefaultNewArtboardBackgroundColor:F("","RGBC"),artboardRect:F("","classFloatRect"),framedGroupRect:F("","classFloatRect"),keyOriginRRectRadii:F("","radii"),keyOriginBoxCorners:X,rectangleCornerA:F("","Pnt "),rectangleCornerB:F("","Pnt "),rectangleCornerC:F("","Pnt "),rectangleCornerD:F("","Pnt "),keyOriginPolyPreviousTightBoxCorners:X,keyOriginPolyTrueRectCorners:X,keyOriginLineStart:F("","Pnt "),keyOriginLineEnd:F("","Pnt "),compInfo:X,quiltWarp:F("","quiltWarp"),generatorSettings:X,crema:X,FrIn:X,blendOptions:X,FXRf:X,Lefx:X,time:X,animKey:X,timeScope:X,inTime:X,outTime:X,sheetStyle:X,translation:X,Skew:X,boundingBox:F("","boundingBox"),"Lnk ":F("","ExternalFileLink"),frameReader:F("","FrameReader"),effectParams:F("","motionTrackEffectParams"),Impr:F("None","none"),Anch:F("","Pnt "),"Fwd ":F("","Pnt "),"Bwd ":F("","Pnt "),FlrC:F("","Pnt "),meshBoundaryPath:F("","pathClass"),filterFX:F("","filterFXStyle"),Fltr:F("","rigidTransform"),FrgC:F("","RGBC"),BckC:F("","RGBC"),sdwM:F("Parameters","adaptCorrectTones"),hglM:F("Parameters","adaptCorrectTones"),customShape:F("","customShape"),origFXRefPoint:X,FXRefPoint:X,vectorMask:X,layerSpecific:X,LSpc:X,textLayerSettings:F("","warp"),placedLayerSettings:X,IMsk:X,VMsk:X,TxtC:X,ClMg:F("","ClMg"),interpretation:F("","footageInterpretation"),bgColor:F("","NativeQuad")},tc={"Crv ":F("","CrPt"),Clrs:F("","Clrt"),Trns:F("","TrnS"),keyDescriptorList:X,keyRootDescriptorList:X,solidFillMulti:F("","SoFi"),gradientFillMulti:F("","GrFl"),dropShadowMulti:F("","DrSh"),innerShadowMulti:F("","IrSh"),frameFXMulti:F("","FrFX"),FrIn:X,FSts:X,LaSt:X,sheetTimelineOptions:X,trackList:F("","animationTrack"),globalTrackList:F("","animationTrack"),keyList:X,audioClipGroupList:X,audioClipList:X,countObjectList:F("","countObject"),countGroupList:F("","countGroup"),slices:F("","slice"),"Pts ":F("","Pthp"),SbpL:F("","SbpL"),pathComponents:F("","PaCm"),filterFXList:F("","filterFX"),puppetShapeList:F("","puppetShape"),channelDenoise:F("","channelDenoiseParams"),ShrP:F("","Pnt "),layerSettings:X,list:X,Adjs:F("","CrvA"),vertices:F("","Pnt "),warpedVertices:F("","Pnt "),quads:F("","quadIndices")},ql={TEXT:["Txt ","printerName","Nm ","Idnt","blackAndWhitePresetFileName","LUT3DFileName","exportOption","scaleSettings","BackgroundImagePath","ImageSubfolderName","SavedIteratedName","presetFileName","curvesPresetFileName","mixerPresetFileName","placed","description","reason","artboardPresetName","json","clipID","relPath","fullPath","mediaDescriptor","Msge","altTag","url","cellText","preset","KnNm","FPth","comment","originalPath","Bk ","pathUnicodeName"],tdta:["EngineData","LUT3DFileData","indexArray","originalVertexArray","deformedVertexArray","LqMe","bookKey"],long:["TextIndex","RndS","Mdpn","Smth","Lctn","strokeStyleVersion","LaID","Vrsn","Cnt ","bookID","cropRectBottom","cropRectLeft","cropRectRight","cropRectTop","Version","BackgroundColorBlue","BackgroundColorGreen","BackgroundColorRed","BackgroundColorState","AttributeCase","Encoding","DuplicateFileNameBehavior","ImageMapLocation","ImageMapType","Indent","LineEndings","SpacersEmptyCells","SpacersHorizontal","SpacersVertical","StylesFormat","TDWidthHeight","TagCase","ColorPolicy","MetadataPolicy","Brgh","Cntr","means","vibrance","Strt","bwPresetKind","comp","compID","originalCompID","curvesPresetKind","mixerPresetKind","uOrder","vOrder","PgNm","totalPages","Crop","numerator","denominator","frameCount","Annt","keyOriginType","unitValueQuadVersion","keyOriginIndex","major","minor","fix","docDefaultNewArtboardBackgroundType","artboardBackgroundType","numModifyingFX","deformNumRows","deformNumCols","FrID","FrDl","FsID","LCnt","AFrm","AFSt","numBefore","numAfter","Spcn","minOpacity","maxOpacity","BlnM","sheetID","gblA","globalAltitude","descVersion","frameReaderType","LyrI","zoomOrigin","fontSize","Rds ","sliceID","topOutset","leftOutset","bottomOutset","rightOutset","filterID","meshQuality","meshExpansion","meshRigidity","VrsM","VrsN","NmbG","WLMn","WLMx","AmMn","AmMx","SclH","SclV","Lvl ","TlNm","TlOf","FlRs","Thsh","ShrS","ShrE","FlRs","Vrnc","Strg","ExtS","ExtD","HrzS","VrtS","NmbR","EdgF","Ang1","Ang2","Ang3","Ang4","lastAppliedComp","capturedInfo","pixelSourceType","framedGroupType","keyOriginPolySides","keyOriginLineArrConc","noisePreSeed","associatedLayer","placedLayerCompID","VAlign"],enum:["textGridding","Ornt","warpStyle","warpRotate","Inte","Bltn","ClrS","BlrQ","bvlT","bvlS","bvlD","Md ","glwS","GrdF","GlwT","RplS","BlrM","SmBM","strokeStyleLineCapType","strokeStyleLineJoinType","strokeStyleLineAlignment","strokeStyleBlendMode","PntT","Styl","lookupType","LUTFormat","dataOrder","tableOrder","enableCompCore","enableCompCoreGPU","compCoreSupport","compCoreGPUSupport","Engn","enableCompCoreThreads","gs99","FrDs","trackID","animInterpStyle","horzAlign","vertAlign","bgColorType","shapeOperation","UndA","Wvtp","Drct","WndM","Edg ","FlCl","IntE","IntC","Cnvr","Fl ","Dstr","MztT","Lns ","ExtT","DspM","ExtR","ZZTy","SphM","SmBQ","placedLayerOCIOConversion","gradientsInterpolationMethod","pathSymmetryMode","interpretAlpha","knockout","TxPT","TxPR"],bool:["PstS","printSixteenBit","masterFXSwitch","enab","uglg","antialiasGloss","useShape","useTexture","uglg","antialiasGloss","useShape","Vsbl","useTexture","Algn","Rvrs","Dthr","Invr","VctC","ShTr","layerConceals","strokeEnabled","fillEnabled","strokeStyleScaleLock","strokeStyleStrokeAdjust","hardProof","MpBl","paperWhite","useLegacy","Auto","Lab ","useTint","keyShapeInvalidated","autoExpandEnabled","autoNestEnabled","autoPositionEnabled","shrinkwrapOnSaveEnabled","present","showInDialog","overprint","sheetDisclosed","lightsDisclosed","meshesDisclosed","materialsDisclosed","hasMotion","muted","Effc","selected","autoScope","fillCanvas","cellTextIsHTML","Smoo","Clsp","validAtPosition","rigidType","hasoptions","filterMaskEnable","filterMaskLinked","filterMaskExtendWithWhite","removeJPEGArtifact","Mnch","ExtF","ExtM","moreAccurate","GpuY","LIWy","Cnty","Lnkd","showAlteredVideo","lightingOn","LockPPI","keyOriginLineArrowSt","keyOriginLineArrowEnd","Expn","substitutesUsed","blendClipped","blendInterior","TxMP"],doub:["warpValue","warpPerspective","warpPerspectiveOther","Intr","Wdth","Hght","Gmm ","strokeStyleMiterLimit","strokeStyleResolution","layerTime","keyOriginResolution","xx","xy","yx","yy","tx","ty","FrGA","frameRate","audioLevel","rotation","X ","Y ","redFloat","greenFloat","blueFloat","imageResolution","PuX0","PuX1","PuX2","PuX3","PuY0","PuY1","PuY2","PuY3","stylization","cleanliness","brushScale","microBrush","specularity","PreferredResolution","FrGL","keyOriginLineWeight","keyOriginLineArrWdth","keyOriginLineArrLngth","keyOriginPolyPixelHSF","keyOriginPolyCornerRadius","gradientAspectRatio"],UntF:["sdwO","hglO","lagl","Lald","srgR","blur","Sftn","Opct","Dstn","Angl","Ckmt","Nose","Inpr","ShdN","strokeStyleLineWidth","strokeStyleLineDashOffset","strokeStyleOpacity","H ","Top ","Left","Btom","Rght","Rslt","topRight","topLeft","bottomLeft","bottomRight","ClNs","Shrp","fillOpacity","keyOriginPolyStarRatio"],VlLs:["Crv ","Clrs","Mnm ","Mxm ","Trns","pathList","keyRootDescriptorList","strokeStyleLineDashSet","FrLs","slices","LaSt","Trnf","nonAffineTransform","keyDescriptorList","guideIndeces","gradientFillMulti","solidFillMulti","frameFXMulti","innerShadowMulti","dropShadowMulti","FrIn","FSts","FsFr","sheetTimelineOptions","audioClipList","trackList","globalTrackList","keyList","audioClipList","warpValues","selectedPin","Pts ","SbpL","pathComponents","pinOffsets","posFinalPins","pinVertexIndices","PinP","PnRt","PnOv","PnDp","filterFXList","puppetShapeList","ShrP","channelDenoise","Mtrx","layerSettings","list","compList","Adjs","vertices","warpedVertices","quads","indices","Mpng","textLayerSettingsWarpRect"],ObAr:["meshPoints","quiltSliceX","quiltSliceY"],"obj ":["null","Chnl"],"Pth ":["DspF"],alis:["alis"]},ah=["Rd ","Grn ","Bl ","Yllw","Ylw ","Cyn ","Mgnt","Blck","Gry ","Lmnc","A ","B "],lh=["Grsc","LbCl","GRYC","LABC"];_.cameraRawFilterClassID="Adobe Camera Raw Filter";_.cameraRawFilterKeyTypes={CrVe:"TEXT",PrVN:"long",PrVe:"long",WBal:"enum",Ex12:"doub",ShpR:"doub","Crv ":"VlLs",CrvR:"VlLs",CrvG:"VlLs",CrvB:"VlLs"};function nc(e){if(typeof e=="boolean")return"bool";if(typeof e=="number"&&!Number.isInteger(e))return"doub";if(Array.isArray(e))return"VlLs";if(e&&typeof e=="object"){if(typeof e._classID=="string")return"Objc";if(typeof e.classID=="string")return"type";if(typeof e.low=="number"&&typeof e.high=="number")return"comp";if(typeof e.units=="string"&&typeof e.value=="number")return"UntF"}}var ic={"Mnm ":"long","Mxm ":"long",HtmlFileNameComponents:"long",SavingFileNameComponents:"long",SliceFileNameComponents:"long",Inpt:"long",Otpt:"long",FrLs:"long",strokeStyleLineDashSet:"UntF",Trnf:"doub",nonAffineTransform:"doub",keyDescriptorList:"Objc",keyRootDescriptorList:"Objc",pathList:"Objc",gradientFillMulti:"Objc",solidFillMulti:"Objc",frameFXMulti:"Objc",innerShadowMulti:"Objc",dropShadowMulti:"Objc",LaSt:"Objc",FrIn:"Objc",FSts:"Objc",FsFr:"long",blendOptions:"Objc",sheetTimelineOptions:"Objc",keyList:"Objc",warpValues:"doub",selectedPin:"long","Pts ":"Objc",SbpL:"Objc",pathComponents:"Objc",pinOffsets:"doub",posFinalPins:"doub",pinVertexIndices:"long",PinP:"doub",PnRt:"long",PnOv:"bool",PnDp:"doub",filterFXList:"Objc",puppetShapeList:"Objc",ShrP:"Objc",channelDenoise:"Objc",Mtrx:"long",compList:"long",textLayerSettingsWarpRect:"doub",Chnl:"enum",indices:"long",Mpng:"long"},so={};for(let e of Object.keys(ql))for(let n of ql[e])so[n]=e;for(let e of Object.keys(ec))so[e]||(so[e]="Objc");for(let e of Object.keys(tc))ic[e]="Objc";var Tr="PixelSource.origin";_.layerStateRoot="layerState";function ch(e,n,t,i){return e==="presetKind"?typeof n=="string"?"enum":"long":e==="null"&&t==="slices"?"TEXT":e==="groupID"?t==="slices"?"long":"TEXT":e==="Sz "?"Wdth"in n?"Objc":"units"in n?"UntF":"doub":e==="Type"?typeof n=="string"?"enum":"long":e==="AntA"?typeof n=="string"?"enum":"bool":(e==="Hrzn"||e==="Vrtc")&&(i.Type==="keyType.Pstn"||i._classID==="Ofst"||t===Tr)?"long":e==="Hrzn"||e==="Vrtc"||e==="Top "||e==="Left"||e==="Btom"||e==="Rght"?t==="slices"?"long":typeof n=="number"?"doub":"UntF":e==="Vrsn"?typeof n=="number"?"long":"Objc":e==="Rd "||e==="Grn "||e==="Bl "?t==="artd"?"long":"doub":e==="Trnf"?Array.isArray(n)?"VlLs":"Objc":e==="alpha"&&t==="slices"?"long":(e==="Inpt"||e==="Otpt")&&i._classID==="HsbP"?"enum":(e==="Inpt"||e==="Otpt")&&i._classID==="LvlA"?"VlLs":e==="Intr"&&typeof n=="boolean"?"bool":e==="PgPs"?"enum":e==="LghD"&&i._classID==="oilPaint"?"long":so[e]}function bt(e){let n=(0,te.readInt32)(e);return(0,te.readAsciiString)(e,n||4)}function et(e,n){if(n.length===4&&n!=="warp"&&n!=="time"&&n!=="hold"&&n!=="list"&&n!=="json")(0,Z.writeInt32)(e,0),(0,Z.writeSignature)(e,n);else{(0,Z.writeInt32)(e,n.length);for(let t=0;t<n.length;t++)(0,Z.writeUint8)(e,n.charCodeAt(t))}}function jr(e,n){let t=rn(e),i=n?{_name:t.name,_classID:t.classID}:{},o=(0,te.readUint32)(e);for(let r=0;r<o;r++){let s=bt(e),a=(0,te.readSignature)(e),l=oc(e,a,n);i[s]=l}return i}_.outputSettingsRoot="outputSettings";function zr(e,n,t,i,o){var r;e.logMissingFeatures&&!t&&e.log("Missing classId for: ",n,t,i),(0,Z.writeUnicodeStringWithPadding)(e,n),o===_.outputSettingsRoot&&t==="null"?((0,Z.writeInt32)(e,4),(0,Z.writeSignature)(e,t)):et(e,t);let a=Object.keys(i).filter(l=>l!=="_name"&&l!=="_classID"&&i[l]!==void 0);(0,Z.writeUint32)(e,a.length);for(let l of a){let c=ch(l,i[l],o,i),f=o,u=ec[l];t===_.cameraRawFilterClassID&&(c=(r=_.cameraRawFilterKeyTypes[l])!==null&&r!==void 0?r:"long",f=_.cameraRawFilterClassID),l==="bounds"&&o==="text"?u=F("","bounds"):l==="origin"?(c=o==="slices"?"enum":"Objc",t==="PixelSource"&&(u=X,f=Tr)):l==="Ofst"&&o===_.layerStateRoot&&typeof i[l].Hrzn=="number"?(u=X,f=Tr):(l==="Cyn "||l==="Mgnt"||l==="Ylw "||l==="Blck")&&i._classID==="CMYC"?c="doub":/^PN[a-z][a-z]$/.test(l)?c="TEXT":/^PT[a-z][a-z]$/.test(l)?c="long":/^PF[a-z][a-z]$/.test(l)||(l==="Rds "||l==="Thsh")&&typeof i[l]=="number"&&i._classID==="SmrB"?c="doub":l==="ClSz"||l==="Rds "||l==="Amnt"?c=typeof i[l]=="number"?"long":"UntF":(l==="sdwM"||l==="hglM")&&typeof i[l]=="string"||l==="blur"&&typeof i[l]=="string"?c="enum":l==="Hght"&&typeof i[l]=="number"&&i._classID==="Embs"||l==="Angl"&&typeof i[l]=="number"&&(i._classID==="Embs"||i._classID==="smartSharpen"||i._classID==="Twrl"||i._classID==="MtnB")?c="long":l==="Angl"&&typeof i[l]=="number"?c="doub":l==="bounds"&&o==="slices"?(c="Objc",u=F("","Rct1")):l==="Scl "?typeof i[l]=="object"&&"Hrzn"in i[l]?(c="Objc",u=X):typeof i[l]=="number"?c="long":c="UntF":l==="audioClipGroupList"&&a.length===1?c="VlLs":(l==="Strt"||l==="Brgh")&&"H "in i?c="doub":l==="Wdth"&&typeof i[l]=="object"?c="UntF":l==="Ofst"&&typeof i[l]=="number"?c="long":l==="Strt"&&typeof i[l]=="object"?(c="Objc",u=X):ah.indexOf(l)!==-1?c=t==="RGBC"&&o!=="artd"||lh.indexOf(t)!==-1?"doub":"long":l==="profile"?c=t==="printOutput"||t==="proofSetup"?"TEXT":"tdta":l==="alis"&&typeof i[l]=="string"?c=/[^\x00-\xff]/.test(i[l])?"TEXT":"alis":l==="strokeStyleContent"?i[l]["Clr "]?u=F("","solidColorLayer"):i[l].Grad?u=F("","gradientLayer"):i[l].Ptrn?u=F("","patternLayer"):e.logMissingFeatures&&e.log("Invalid strokeStyleContent value",i[l]):l==="bounds"&&o==="quiltWarp"&&(u=F("","classFloatRect")),u&&u.classID==="RGBC"&&("H "in i[l]?u={classID:"HSBC",name:""}:"Cyn "in i[l]?u={classID:"CMYC",name:""}:"Lmnc"in i[l]?u={classID:"LbCl",name:""}:"Gry "in i[l]&&(u={classID:"Grsc",name:""})),c||(c=nc(i[l])),et(e,l),(0,Z.writeSignature)(e,c||"long"),rc(e,c||"long",i[l],l,u,f),e.logMissingFeatures&&!c&&e.log(`Missing descriptor field type for: '${l}' in`,i)}}function oc(e,n,t){switch(n){case"obj ":return ph(e);case"Objc":case"GlbO":return jr(e,t);case"VlLs":{let i=(0,te.readInt32)(e),o=[];for(let r=0;r<i;r++){let s=(0,te.readSignature)(e);o.push(oc(e,s,t))}return o}case"doub":return(0,te.readFloat64)(e);case"UntF":{let i=(0,te.readSignature)(e),o=(0,te.readFloat64)(e);if(!di[i])throw new Error(`Invalid units: ${i}`);return{units:di[i],value:o}}case"UnFl":{let i=(0,te.readSignature)(e),o=(0,te.readFloat32)(e);if(!di[i])throw new Error(`Invalid units: ${i}`);return{units:di[i],value:o}}case"TEXT":return(0,te.readUnicodeString)(e);case"enum":{let i=bt(e),o=bt(e);return`${i}.${o}`}case"long":return(0,te.readInt32)(e);case"comp":{let i=(0,te.readUint32)(e);return{low:(0,te.readUint32)(e),high:i}}case"bool":return!!(0,te.readUint8)(e);case"type":case"GlbC":return rn(e);case"alis":{let i=(0,te.readInt32)(e);return(0,te.readAsciiString)(e,i)}case"tdta":{let i=(0,te.readInt32)(e);if(i>e.view.byteLength-e.offset)throw new Error(`Invalid tdta length: ${i}`);return(0,te.readBytes)(e,i)}case"ObAr":{(0,te.readInt32)(e),(0,te.readUnicodeString)(e),bt(e);let i=(0,te.readInt32)(e),o=[];for(let r=0;r<i;r++){let s=bt(e);(0,te.readSignature)(e),(0,te.readSignature)(e);let a=(0,te.readInt32)(e),l=[];for(let c=0;c<a;c++)l.push((0,te.readFloat64)(e));o.push({type:s,values:l})}return o}case"Pth ":{(0,te.readInt32)(e);let i=(0,te.readSignature)(e);(0,te.readInt32LE)(e);let o=(0,te.readInt32LE)(e),r=(0,te.readUnicodeStringWithLengthLE)(e,o);return{sig:i,path:r}}default:throw new Error(`Invalid TySh descriptor OSType: ${n} at ${e.offset.toString(16)}`)}}var fh={meshPoints:"rationalPoint",quiltSliceX:"UntF",quiltSliceY:"UntF"};function rc(e,n,t,i,o,r){var s;switch(n){case"obj ":gh(e,i,t);break;case"Objc":case"GlbO":{if(typeof t!="object")throw new Error(`Invalid struct value: ${JSON.stringify(t)}, key: ${i}`);if(!o&&!t._classID)throw new Error(`Missing ext type for: '${i}' (${JSON.stringify(t)})`);let a=t._name||o?.name||"",l=t._classID||o.classID;zr(e,a,l,t,r);break}case"VlLs":if(!Array.isArray(t))throw new Error(`Invalid list value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeInt32)(e,t.length);for(let a=0;a<t.length;a++){let l=r===_.cameraRawFilterClassID?"long":(s=ic[i])!==null&&s!==void 0?s:nc(t[a]);(0,Z.writeSignature)(e,l||"long"),rc(e,l||"long",t[a],`${i}[]`,tc[i],r),e.logMissingFeatures&&!l&&e.log(`Missing descriptor array type for: '${i}' in`,t)}break;case"doub":if(typeof t!="number")throw new Error(`Invalid number value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeFloat64)(e,t);break;case"UntF":if(!io[t.units])throw new Error(`Invalid units: ${t.units} in ${i}`);(0,Z.writeSignature)(e,io[t.units]),(0,Z.writeFloat64)(e,t.value);break;case"UnFl":if(!io[t.units])throw new Error(`Invalid units: ${t.units} in ${i}`);(0,Z.writeSignature)(e,io[t.units]),(0,Z.writeFloat32)(e,t.value);break;case"TEXT":(0,Z.writeUnicodeStringWithPadding)(e,t);break;case"enum":{if(typeof t!="string")throw new Error(`Invalid enum value: ${JSON.stringify(t)}, key: ${i}`);let[a,l]=t.split(".");et(e,a),et(e,l);break}case"long":if(typeof t!="number")throw new Error(`Invalid integer value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeInt32)(e,Math.round(t));break;case"comp":if(!t||typeof t!="object")throw new Error(`Invalid large integer value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeUint32)(e,t.high>>>0),(0,Z.writeUint32)(e,t.low>>>0);break;case"bool":if(typeof t!="boolean")throw new Error(`Invalid boolean value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeUint8)(e,t?1:0);break;case"type":case"GlbC":if(!t||typeof t!="object")throw new Error(`Invalid class value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeUnicodeStringWithPadding)(e,t.name||""),et(e,t.classID);break;case"alis":{if(typeof t!="string")throw new Error(`Invalid alias value: ${JSON.stringify(t)}, key: ${i}`);(0,Z.writeInt32)(e,t.length);for(let a=0;a<t.length;a++)(0,Z.writeUint8)(e,t.charCodeAt(a)&255);break}case"tdta":(0,Z.writeInt32)(e,t.byteLength),(0,Z.writeBytes)(e,t);break;case"ObAr":{(0,Z.writeInt32)(e,16),(0,Z.writeUnicodeStringWithPadding)(e,"");let a=fh[i];if(!a)throw new Error(`Not implemented ObArType for: ${i}`);et(e,a),(0,Z.writeInt32)(e,t.length);for(let l=0;l<t.length;l++){et(e,t[l].type),(0,Z.writeSignature)(e,"UnFl"),(0,Z.writeSignature)(e,"#Pxl"),(0,Z.writeInt32)(e,t[l].values.length);for(let c=0;c<t[l].values.length;c++)(0,Z.writeFloat64)(e,t[l].values[c])}break}case"Pth ":{let a=t.path+"\0",l=12+a.length*2;(0,Z.writeInt32)(e,l),(0,Z.writeSignature)(e,t.sig),(0,Z.writeInt32LE)(e,l),(0,Z.writeInt32LE)(e,a.length),(0,Z.writeUnicodeStringWithoutLengthLE)(e,a);break}default:throw new Error(`Not implemented descriptor OSType: ${n}`)}}var dh=["prop","Clss","Enmr","rele","Idnt","indx","name"];function uh(e){return!!e&&typeof e=="object"&&dh.indexOf(e.type)!==-1}function ph(e){let n=(0,te.readInt32)(e),t=[];for(let i=0;i<n;i++){let o=(0,te.readSignature)(e);switch(o){case"prop":rn(e),t.push(bt(e));break;case"Clss":t.push(rn(e));break;case"Enmr":{rn(e);let r=bt(e),s=bt(e);t.push(`${r}.${s}`);break}case"rele":rn(e),t.push((0,te.readUint32)(e));break;case"Idnt":case"indx":t.push((0,te.readInt32)(e));break;case"name":rn(e),t.push((0,te.readUnicodeString)(e));break;default:throw new Error(`Invalid descriptor reference type: ${o}`)}}return t}function sc(e){if(typeof e=="string"){let n=/^([a-z ]{4}|[a-z]{5,})\.([a-z ]+)$/i.exec(e);return n?{type:"Enmr",_name:"",_classID:n[1],typeID:n[1],enumValue:n[2]}:{type:"name",_name:"",_classID:"Lyr ",value:e}}else{if(typeof e=="number")return{type:"Idnt",value:e};if(e&&typeof e=="object"&&typeof e.classID=="string")return{type:"Clss",_name:e.name||"",_classID:e.classID};throw new Error(`Invalid descriptor reference value: ${JSON.stringify(e)}`)}}function hh(e){return e.map(n=>{let t=sc(n);return t.type==="Enmr"&&(t._classID="Path"),t})}function gh(e,n,t){if(!Array.isArray(t))throw new Error(`Invalid reference value: ${JSON.stringify(t)}, key: ${n}`);(0,Z.writeInt32)(e,t.length);for(let i of t){let o=uh(i)?i:sc(i);switch((0,Z.writeSignature)(e,o.type),o.type){case"prop":Dn(e,o._name||"",o._classID),et(e,o.keyID);break;case"Clss":Dn(e,o._name||"",o._classID);break;case"Enmr":Dn(e,o._name||"",o._classID),et(e,o.typeID),et(e,o.enumValue);break;case"rele":Dn(e,o._name||"",o._classID),(0,Z.writeUint32)(e,o.value);break;case"Idnt":case"indx":(0,Z.writeInt32)(e,o.value);break;case"name":Dn(e,o._name||"",o._classID),(0,Z.writeUnicodeStringWithPadding)(e,`${o.value}`);break;default:throw new Error(`Invalid descriptor reference type: ${o.type}`)}}return t}function rn(e){let n=(0,te.readUnicodeString)(e),t=bt(e);return{name:n,classID:t}}function Dn(e,n,t){(0,Z.writeUnicodeStringWithPadding)(e,n),et(e,t)}function mh(e,n=!1){let t=(0,te.readUint32)(e);if(t!==16)throw new Error(`Invalid descriptor version: ${t}`);return jr(e,n)}function yh(e,n,t,i,o=""){(0,Z.writeUint32)(e,16),zr(e,n,t,i,o)}function oo(e){return{x:e.Hrzn,y:e.Vrtc}}function ro(e){return{Hrzn:e.x,Vrtc:e.y}}function bh(e){return{top:wt(e["Top "]),left:wt(e.Left),right:wt(e.Rght),bottom:wt(e.Btom)}}function wh(e){return{Left:vt(e.left,"bounds.left"),"Top ":vt(e.top,"bounds.top"),Rght:vt(e.right,"bounds.right"),Btom:vt(e.bottom,"bounds.bottom")}}function Zl(e){let n={enabled:!!e.enab,position:_.FStl.decode(e.Styl),fillType:_.FrFl.decode(e.PntT),blendMode:_.BlnM.decode(e["Md "]),opacity:Pe(e.Opct),size:bc(e["Sz "])};return e.present!==void 0&&(n.present=e.present),e.showInDialog!==void 0&&(n.showInDialog=e.showInDialog),e.overprint!==void 0&&(n.overprint=e.overprint),e["Clr "]&&(n.color=sn(e["Clr "])),e.Grad&&(n.gradient=dc(e)),e.Ptrn&&(n.pattern=pc(e)),n}function Kl(e){let n={};return n.enab=!!e.enabled,e.present!==void 0&&(n.present=!!e.present),e.showInDialog!==void 0&&(n.showInDialog=!!e.showInDialog),n.Styl=_.FStl.encode(e.position),n.PntT=_.FrFl.encode(e.fillType),n["Md "]=_.BlnM.encode(e.blendMode),n.Opct=rt(e.opacity),n["Sz "]=vt(e.size,"size"),e.color&&(n["Clr "]=an(e.color)),e.gradient&&(n=Object.assign(Object.assign({},n),hc(e.gradient))),e.pattern&&(n=Object.assign(Object.assign({},n),gc(e.pattern))),e.overprint!==void 0&&(n.overprint=!!e.overprint),n}function ac(e,n,t){var i,o,r;let s=t?{"Scl ":St((i=e.scale)!==null&&i!==void 0?i:1),masterFXSwitch:!e.disabled}:{masterFXSwitch:!e.disabled,"Scl ":St((o=e.scale)!==null&&o!==void 0?o:1)},a=["dropShadow","innerShadow","solidFill","gradientOverlay","stroke"];for(let f of a)if(e[f]&&!Array.isArray(e[f]))throw new Error(`${f} should be an array`);let l=f=>!!f&&f.length>1&&t,c=f=>!!f&&f.length>=1&&(!t||f.length===1);if(c(e.dropShadow)&&(s.DrSh=Xe(e.dropShadow[0],"dropShadow",n)),l(e.dropShadow)&&(s.dropShadowMulti=e.dropShadow.map(f=>Xe(f,"dropShadow",n))),c(e.innerShadow)&&(s.IrSh=Xe(e.innerShadow[0],"innerShadow",n)),l(e.innerShadow)&&(s.innerShadowMulti=e.innerShadow.map(f=>Xe(f,"innerShadow",n))),e.outerGlow&&(s.OrGl=Xe(e.outerGlow,"outerGlow",n)),l(e.solidFill)&&(s.solidFillMulti=e.solidFill.map(f=>Xe(f,"solidFill",n))),l(e.gradientOverlay)&&(s.gradientFillMulti=e.gradientOverlay.map(f=>Xe(f,"gradientOverlay",n))),l(e.stroke)&&(s.frameFXMulti=e.stroke.map(f=>Kl(f))),e.innerGlow&&(s.IrGl=Xe(e.innerGlow,"innerGlow",n)),e.bevel&&(s.ebbl=Xe(e.bevel,"bevel",n)),c(e.solidFill)&&(s.SoFi=Xe(e.solidFill[0],"solidFill",n)),e.patternOverlay&&(s.patternFill=Xe(e.patternOverlay,"patternOverlay",n)),c(e.gradientOverlay)&&(s.GrFl=Xe(e.gradientOverlay[0],"gradientOverlay",n)),e.satin&&(s.ChFX=Xe(e.satin,"satin",n)),c(e.stroke)&&(s.FrFX=Kl((r=e.stroke)===null||r===void 0?void 0:r[0])),t){s.numModifyingFX=0;for(let f of Object.keys(e)){let u=e[f];if(!(u==null||typeof u!="object"))if(Array.isArray(u))for(let d of u)d?.enabled&&s.numModifyingFX++;else u.enabled&&s.numModifyingFX++}}return s}function lc(e,n){let t={},i=e,{_name:o,_classID:r,"Scl ":s,masterFXSwitch:a,DrSh:l,dropShadowMulti:c,IrSh:f,innerShadowMulti:u,OrGl:d,IrGl:p,ebbl:h,SoFi:m,solidFillMulti:y,patternFill:g,GrFl:k,gradientFillMulti:x,ChFX:S,FrFX:A,frameFXMulti:D,numModifyingFX:C}=i,O=rh(i,["_name","_classID","Scl ","masterFXSwitch","DrSh","dropShadowMulti","IrSh","innerShadowMulti","OrGl","IrGl","ebbl","SoFi","solidFillMulti","patternFill","GrFl","gradientFillMulti","ChFX","FrFX","frameFXMulti","numModifyingFX"]);return a||(t.disabled=!0),s&&(t.scale=Pe(s)),l&&(t.dropShadow=[We(l,n)]),c&&(t.dropShadow=c.map(E=>We(E,n))),f&&(t.innerShadow=[We(f,n)]),u&&(t.innerShadow=u.map(E=>We(E,n))),d&&(t.outerGlow=We(d,n)),p&&(t.innerGlow=We(p,n)),h&&(t.bevel=We(h,n,"bevel")),m&&(t.solidFill=[We(m,n)]),y&&(t.solidFill=y.map(E=>We(E,n))),g&&(t.patternOverlay=We(g,n)),k&&(t.gradientOverlay=[We(k,n)]),x&&(t.gradientOverlay=x.map(E=>We(E,n))),S&&(t.satin=We(S,n)),A&&(t.stroke=[Zl(A)]),D&&(t.stroke=D.map(E=>Zl(E))),n.logMissingFeatures&&Object.keys(O).length&&n.log("Unhandled effect keys:",O),t}function Yl(e,n){let t=[];for(let i=0;i<e.length;i++){let o=e[i],{time:{denominator:r,numerator:s},selected:a,animKey:l}=o,c={numerator:s,denominator:r},f=_.animInterpStyleEnum.decode(o.animInterpStyle);switch(l.Type){case"keyType.Opct":t.push({interpolation:f,time:c,selected:a,type:"opacity",value:Pe(l.Opct)});break;case"keyType.Pstn":t.push({interpolation:f,time:c,selected:a,type:"position",x:l.Hrzn,y:l.Vrtc});break;case"keyType.Trnf":t.push({interpolation:f,time:c,selected:a,type:"transform",scale:oo(l["Scl "]),skew:oo(l.Skew),rotation:l.rotation,translation:oo(l.translation)});break;case"keyType.sheetStyle":{let u={interpolation:f,time:c,selected:a,type:"style"};l.sheetStyle.Lefx&&(u.style=lc(l.sheetStyle.Lefx,n)),t.push(u);break}case"keyType.globalLighting":{t.push({interpolation:f,time:c,selected:a,type:"globalLighting",globalAngle:l.gblA,globalAltitude:l.globalAltitude});break}default:throw new Error("Unsupported keyType value")}}return t}function Jl(e,n){let t=[];for(let i=0;i<e.length;i++){let o=e[i],{time:r,selected:s=!1,interpolation:a}=o,l=_.animInterpStyleEnum.encode(a),c;switch(o.type){case"opacity":c={Type:"keyType.Opct",Opct:rt(o.value)};break;case"position":c={Type:"keyType.Pstn",Hrzn:o.x,Vrtc:o.y};break;case"transform":c={Type:"keyType.Trnf","Scl ":ro(o.scale),Skew:ro(o.skew),rotation:o.rotation,translation:ro(o.translation)};break;case"style":c={Type:"keyType.sheetStyle",sheetStyle:{Vrsn:1,blendOptions:{}}},o.style&&(c.sheetStyle={Vrsn:1,Lefx:ac(o.style,n,!1),blendOptions:{}});break;case"globalLighting":{c={Type:"keyType.globalLighting",gblA:o.globalAngle,globalAltitude:o.globalAltitude};break}default:throw new Error("Unsupported keyType value")}t.push({Vrsn:1,animInterpStyle:l,time:r,animKey:c,selected:s})}return t}function vh(e,n){let t=[];for(let i=0;i<e.length;i++){let o=e[i],r={type:_.stdTrackID.decode(o.trackID),enabled:o.enab,keys:Yl(o.keyList,n)};o.effectParams&&(r.effectParams={fillCanvas:o.effectParams.fillCanvas,zoomOrigin:o.effectParams.zoomOrigin,keys:Yl(o.effectParams.keyList,n)}),t.push(r)}return t}function Sh(e,n){let t=[];for(let i=0;i<e.length;i++){let o=e[i];t.push(Object.assign(Object.assign({trackID:_.stdTrackID.encode(o.type),Vrsn:1,enab:!!o.enabled,Effc:!!o.effectParams},o.effectParams?{effectParams:{keyList:Jl(o.effectParams.keys,n),fillCanvas:o.effectParams.fillCanvas,zoomOrigin:o.effectParams.zoomOrigin}}:{}),{keyList:Jl(o.keys,n)}))}return t}function We(e,n,t){let i={};for(let o of Object.keys(e)){let r=e[o];switch(o){case"enab":i.enabled=!!r;break;case"uglg":i.useGlobalLight=!!r;break;case"AntA":i.antialiased=!!r;break;case"Algn":i.align=!!r;break;case"Dthr":i.dither=!!r;break;case"Invr":i.invert=!!r;break;case"Rvrs":i.reverse=!!r;break;case"Clr ":i.color=sn(r);break;case"hglC":i.highlightColor=sn(r);break;case"sdwC":i.shadowColor=sn(r);break;case"Styl":i.position=_.FStl.decode(r);break;case"Md ":i.blendMode=_.BlnM.decode(r);break;case"hglM":i.highlightBlendMode=_.BlnM.decode(r);break;case"sdwM":i.shadowBlendMode=_.BlnM.decode(r);break;case"bvlS":i.style=_.BESl.decode(r);break;case"bvlD":i.direction=_.BESs.decode(r);break;case"bvlT":i.technique=_.bvlT.decode(r);break;case"GlwT":i.technique=_.BETE.decode(r);break;case"glwS":i.source=_.IGSr.decode(r);break;case"Type":i.type=_.GrdT.decode(r);break;case"gs99":case"gradientsInterpolationMethod":i.interpolationMethod=_.gradientInterpolationMethodType.decode(r);break;case"Opct":i.opacity=Pe(r);break;case"hglO":i.highlightOpacity=Pe(r);break;case"sdwO":i.shadowOpacity=Pe(r);break;case"lagl":i.angle=On(r);break;case"Angl":i.angle=On(r);break;case"Lald":i.altitude=On(r);break;case"Sftn":i.soften=wt(r);break;case"srgR":i.strength=Pe(r);break;case"blur":i.size=wt(r);break;case"Nose":i.noise=Pe(r);break;case"Inpr":i.range=Pe(r);break;case"Ckmt":i.choke=wt(r);break;case"ShdN":i.jitter=Pe(r);break;case"Dstn":i.distance=wt(r);break;case"Scl ":i.scale=Pe(r);break;case"Ptrn":i.pattern={name:r["Nm "],id:r.Idnt};break;case"phase":i.phase=uc(r);break;case"Ofst":i.offset={x:Pe(r.Hrzn),y:Pe(r.Vrtc)};break;case"MpgS":case"TrnS":{let s={name:r["Nm "],curve:r["Crv "].map(a=>a.Cnty!==void 0?{x:a.Hrzn,y:a.Vrtc,curved:a.Cnty}:{x:a.Hrzn,y:a.Vrtc})};t==="bevel"&&o==="MpgS"?i.shapeContour=s:i.contour=s;break}case"Grad":i.gradient=cc(r);break;case"useTexture":case"useShape":case"layerConceals":case"present":case"showInDialog":case"antialiasGloss":i[o]=r;break;case"_name":case"_classID":break;default:n.logMissingFeatures&&n.log(`Invalid effect key: '${o}', value:`,r)}}return i}function Xe(e,n,t){let i={enab:!1};n==="dropShadow"&&(i.TrnS={"Nm ":"","Crv ":[]});for(let o of Object.keys(e)){let r=o,s=e[r];switch(r){case"enabled":i.enab=!!s;break;case"useGlobalLight":i.uglg=!!s;break;case"antialiased":i.AntA=!!s;break;case"align":i.Algn=!!s;break;case"dither":i.Dthr=!!s;break;case"invert":i.Invr=!!s;break;case"reverse":i.Rvrs=!!s;break;case"color":i["Clr "]=an(s);break;case"highlightColor":i.hglC=an(s);break;case"shadowColor":i.sdwC=an(s);break;case"position":i.Styl=_.FStl.encode(s);break;case"blendMode":i["Md "]=_.BlnM.encode(s);break;case"highlightBlendMode":i.hglM=_.BlnM.encode(s);break;case"shadowBlendMode":i.sdwM=_.BlnM.encode(s);break;case"style":i.bvlS=_.BESl.encode(s);break;case"direction":i.bvlD=_.BESs.encode(s);break;case"technique":n==="bevel"?i.bvlT=_.bvlT.encode(s):i.GlwT=_.BETE.encode(s);break;case"source":i.glwS=_.IGSr.encode(s);break;case"type":i.Type=_.GrdT.encode(s);break;case"interpolationMethod":i[n==="outerGlow"||n==="innerGlow"?"gradientsInterpolationMethod":"gs99"]=_.gradientInterpolationMethodType.encode(s);break;case"opacity":i.Opct=rt(s);break;case"highlightOpacity":i.hglO=rt(s);break;case"shadowOpacity":i.sdwO=rt(s);break;case"angle":n==="gradientOverlay"||n==="patternOverlay"?i.Angl=ln(s):i.lagl=ln(s);break;case"altitude":i.Lald=ln(s);break;case"soften":i.Sftn=vt(s,r);break;case"strength":i.srgR=rt(s);break;case"size":i.blur=vt(s,r);break;case"noise":i.Nose=rt(s);break;case"range":i.Inpr=rt(s);break;case"choke":i.Ckmt=vt(s,r);break;case"jitter":i.ShdN=rt(s);break;case"distance":i.Dstn=vt(s,r);break;case"scale":i["Scl "]=rt(s);break;case"pattern":i.Ptrn={"Nm ":s.name,Idnt:s.id};break;case"phase":i.phase={Hrzn:s.x,Vrtc:s.y};break;case"offset":i.Ofst={Hrzn:St(s.x),Vrtc:St(s.y)};break;case"contour":i[n==="satin"?"MpgS":"TrnS"]=Ql(s);break;case"shapeContour":i.MpgS=Ql(s);break;case"gradient":i.Grad=fc(s);break;case"useTexture":case"useShape":case"layerConceals":case"present":case"showInDialog":case"antialiasGloss":i[r]=s;break;default:t.logMissingFeatures&&t.log(`Invalid effect key: '${r}', value:`,s)}}return i}function Ql(e){return{"Nm ":e.name,"Crv ":e.curve.map(n=>n.curved!==void 0?{Hrzn:n.x,Vrtc:n.y,Cnty:!!n.curved}:{Hrzn:n.x,Vrtc:n.y})}}function cc(e){return e.GrdF==="GrdF.CstS"?{type:"solid",name:e["Nm "],smoothness:e.Intr/4096,colorStops:e.Clrs.map(t=>{let i={color:t["Clr "]?sn(t["Clr "]):{r:0,g:0,b:0},location:t.Lctn/4096,midpoint:t.Mdpn/100};if(t.Type)try{let o=_.Clry.decode(t.Type);o!=="user"&&(i.type=o)}catch{}return i}),opacityStops:e.Trns.map(t=>({opacity:Pe(t.Opct),location:t.Lctn/4096,midpoint:t.Mdpn/100}))}:{type:"noise",name:e["Nm "],roughness:e.Smth/4096,colorModel:_.ClrS.decode(e.ClrS),randomSeed:e.RndS,restrictColors:!!e.VctC,addTransparency:!!e.ShTr,min:e["Mnm "].map(n=>n/100),max:e["Mxm "].map(n=>n/100)}}function fc(e){var n,t;return e.type==="solid"?{"Nm ":e.name||"",GrdF:"GrdF.CstS",Intr:Math.round(((n=e.smoothness)!==null&&n!==void 0?n:1)*4096),Clrs:e.colorStops.map(o=>{var r,s;return{"Clr ":an(o.color),Type:_.Clry.encode((r=o.type)!==null&&r!==void 0?r:"user"),Lctn:Math.round(o.location*4096),Mdpn:Math.round(((s=o.midpoint)!==null&&s!==void 0?s:.5)*100)}}),Trns:e.opacityStops.map(o=>{var r;return{Opct:St(o.opacity),Lctn:Math.round(o.location*4096),Mdpn:Math.round(((r=o.midpoint)!==null&&r!==void 0?r:.5)*100)}})}:{GrdF:"GrdF.ClNs","Nm ":e.name||"",ShTr:!!e.addTransparency,VctC:!!e.restrictColors,ClrS:_.ClrS.encode(e.colorModel),RndS:e.randomSeed||0,Smth:Math.round(((t=e.roughness)!==null&&t!==void 0?t:1)*4096),"Mnm ":(e.min||[0,0,0,0]).map(i=>Math.round(i*100)),"Mxm ":(e.max||[1,1,1,1]).map(i=>Math.round(i*100))}}function dc(e){let n=cc(e.Grad);return n.style=_.GrdT.decode(e.Type),e.Dthr!==void 0&&(n.dither=e.Dthr),e.gradientsInterpolationMethod!==void 0&&(n.interpolationMethod=_.gradientInterpolationMethodType.decode(e.gradientsInterpolationMethod)),e.Rvrs!==void 0&&(n.reverse=e.Rvrs),e.Angl!==void 0&&(n.angle=On(e.Angl)),e["Scl "]!==void 0&&(n.scale=Pe(e["Scl "])),e.Algn!==void 0&&(n.align=e.Algn),e.Ofst!==void 0&&(n.offset={x:Pe(e.Ofst.Hrzn),y:Pe(e.Ofst.Vrtc)}),e.gradientAspectRatio!==void 0&&(n.aspectRatio=e.gradientAspectRatio),e.noisePreSeed!==void 0&&(n.noisePreSeed=e.noisePreSeed),n}function uc({Hrzn:e,Vrtc:n}){return{x:typeof e=="number"?e:e.value,y:typeof n=="number"?n:n.value}}function pc(e){let n={name:e.Ptrn["Nm "],id:e.Ptrn.Idnt};return e.Algn!==void 0&&(n.align=e.Algn),e.Lnkd!==void 0&&(n.linked=e.Lnkd),e.phase!==void 0&&(n.phase=uc(e.phase)),e["Scl "]!==void 0&&(n.scale=Pe(e["Scl "])),e.Angl!==void 0&&(n.angle=On(e.Angl)),n}function xh(e){if("Grad"in e)return dc(e);if("Ptrn"in e)return Object.assign({type:"pattern"},pc(e));if("Clr "in e)return{type:"color",color:sn(e["Clr "])};throw new Error("Invalid vector content")}function hc(e){let n={};return e.dither!==void 0&&(n.Dthr=e.dither),e.interpolationMethod!==void 0&&(n.gradientsInterpolationMethod=_.gradientInterpolationMethodType.encode(e.interpolationMethod)),e.reverse!==void 0&&(n.Rvrs=e.reverse),e.aspectRatio!==void 0&&(n.gradientAspectRatio=e.aspectRatio),e.angle!==void 0&&(n.Angl=ln(e.angle)),n.Type=_.GrdT.encode(e.style),e.align!==void 0&&(n.Algn=e.align),e.scale!==void 0&&(n["Scl "]=St(e.scale)),e.offset&&(n.Ofst={Hrzn:St(e.offset.x),Vrtc:St(e.offset.y)}),e.noisePreSeed!==void 0&&(n.noisePreSeed=e.noisePreSeed),n.Grad=fc(e),n}function gc(e){let n={Ptrn:{"Nm ":e.name||"",Idnt:e.id||""}};return e.align!==void 0&&(n.Algn=!!e.align),e.linked!==void 0&&(n.Lnkd=!!e.linked),e.phase!==void 0&&(n.phase={Hrzn:e.phase.x,Vrtc:e.phase.y}),e.scale!==void 0&&(n["Scl "]=St(e.scale)),e.angle!==void 0&&(n.Angl=ln(e.angle)),n}function kh(e){return e.type==="color"?{key:"SoCo",descriptor:{"Clr ":an(e.color)}}:e.type==="pattern"?{key:"PtFl",descriptor:gc(e)}:{key:"GdFl",descriptor:hc(e)}}var _h={"H ":[e=>e/360,e=>e*360],Strt:[e=>e/100,e=>e*100],Brgh:[e=>e/100,e=>e*100],"Cyn ":[e=>e*255/100,e=>e*100/255],Mgnt:[e=>e*255/100,e=>e*100/255],"Ylw ":[e=>e*255/100,e=>e*100/255],Blck:[e=>e*255/100,e=>e*100/255],"Gry ":[e=>e*255/100,e=>e*100/255],Lmnc:[e=>e/100,e=>e*100],"A ":[V.normalizeLabAB,V.denormalizeLabAB],"B ":[V.normalizeLabAB,V.denormalizeLabAB]};function ot(e,n){let t=_h[e];if(!t)return n;let[i,o]=t,r=o(n);if(!isFinite(r))return r;for(let s=1;s<17;s++){let a=+r.toPrecision(s);if(i(a)===n)return a}return r}function mc(e){return e._classID==="BkCl"||"Bk "in e||"bookID"in e}function sn(e){var n,t,i;let o=Ah(e);if(mc(e)){let r=e,s=r.bookKey;o.book={book:(n=r["Bk "])!==null&&n!==void 0?n:"",name:(t=r["Nm "])!==null&&t!==void 0?t:"",bookID:(i=r.bookID)!==null&&i!==void 0?i:0,bookKey:typeof s=="string"?s:s?String.fromCharCode(...Array.from(s)):""}}return o}function Ah(e){if("H "in e)return{h:yc(e["H "]),s:e.Strt/100,b:e.Brgh/100};if("Rd "in e)return{r:e["Rd "],g:e["Grn "],b:e["Bl "]};if("Cyn "in e)return{c:e["Cyn "]*255/100,m:e.Mgnt*255/100,y:e["Ylw "]*255/100,k:e.Blck*255/100};if("Gry "in e)return{k:e["Gry "]*255/100};if("Lmnc"in e)return{l:e.Lmnc/100,a:(0,V.normalizeLabAB)(e["A "]),b:(0,V.normalizeLabAB)(e["B "])};if("redFloat"in e)return{fr:e.redFloat,fg:e.greenFloat,fb:e.blueFloat};if(mc(e))return{r:0,g:0,b:0};throw new Error("Unsupported color descriptor")}function an(e){let n=Ih(e);if(e?.book){let{book:t,name:i,bookID:o,bookKey:r}=e.book,s=new Uint8Array(r.length);for(let a=0;a<s.length;a++)s[a]=r.charCodeAt(a)&255;Object.assign(n,{"Bk ":t,"Nm ":i,bookID:o,bookKey:s})}return n}function Ih(e){if(e){if("r"in e)return{_name:"",_classID:"RGBC","Rd ":e.r||0,"Grn ":e.g||0,"Bl ":e.b||0};if("fr"in e)return{_name:"",_classID:"RGBC",redFloat:e.fr,greenFloat:e.fg,blueFloat:e.fb};if("h"in e)return{_name:"",_classID:"HSBC","H ":ln(ot("H ",e.h||0)),Strt:ot("Strt",e.s||0),Brgh:ot("Brgh",e.b||0)};if("c"in e)return{_name:"",_classID:"CMYC","Cyn ":ot("Cyn ",e.c||0),Mgnt:ot("Mgnt",e.m||0),"Ylw ":ot("Ylw ",e.y||0),Blck:ot("Blck",e.k||0)};if("l"in e)return{_name:"",_classID:"LbCl",Lmnc:ot("Lmnc",e.l||0),"A ":ot("A ",e.a||0),"B ":ot("B ",e.b||0)};if("k"in e)return{_name:"",_classID:"Grsc","Gry ":ot("Gry ",e.k||0)};throw new Error("Invalid color value")}else return{_name:"",_classID:"RGBC","Rd ":0,"Grn ":0,"Bl ":0}}function On(e){if(e===void 0)return 0;if(e.units!=="Angle")throw new Error(`Invalid units: ${e.units}`);return e.value}function Pe(e){if(e===void 0)return 1;if(e.units!=="Percent")throw new Error(`Invalid units: ${e.units}`);return e.value/100}function yc(e){if(e===void 0)return 1;if(e.units==="Percent")return e.value/100;if(e.units==="Angle")return e.value/360;throw new Error(`Invalid units: ${e.units}`)}function wt({units:e,value:n}){if(e!=="Pixels"&&e!=="Millimeters"&&e!=="Points"&&e!=="None"&&e!=="Picas"&&e!=="Inches"&&e!=="Centimeters"&&e!=="Density"&&e!=="Distance")throw new Error(`Invalid units: ${JSON.stringify({units:e,value:n})}`);return{value:n,units:e}}function bc(e,n="Pixels"){return typeof e=="number"?{value:e,units:n}:wt(e)}function Ch({units:e,value:n},t){if(e!==t)throw new Error(`Invalid units: ${JSON.stringify({units:e,value:n})}`);return n}function ln(e){return{units:"Angle",value:e||0}}function rt(e){return{units:"Percent",value:Math.round((e||0)*100)}}function St(e){return{units:"Percent",value:(e||0)*100}}function vt(e,n){if(e==null)return{units:"Pixels",value:0};if(typeof e!="object")throw new Error(`Invalid value: ${JSON.stringify(e)} (key: ${n}) (should have value and units)`);let{units:t,value:i}=e;if(typeof i!="number")throw new Error(`Invalid value in ${JSON.stringify(e)} (key: ${n})`);if(t!=="Pixels"&&t!=="Millimeters"&&t!=="Points"&&t!=="None"&&t!=="Picas"&&t!=="Inches"&&t!=="Centimeters"&&t!=="Density"&&t!=="Distance")throw new Error(`Invalid units in ${JSON.stringify(e)} (key: ${n})`);return{units:t,value:i}}function Ph({numerator:e,denominator:n}){return{numerator:e,denominator:n}}_.textGridding=(0,V.createEnum)("textGridding","none",{none:"None",round:"Rnd "});_.Ornt=(0,V.createEnum)("Ornt","horizontal",{horizontal:"Hrzn",vertical:"Vrtc"});_.Annt=(0,V.createEnum)("Annt","sharp",{none:"Anno",sharp:"antiAliasSharp",crisp:"AnCr",strong:"AnSt",smooth:"AnSm",platform:"antiAliasPlatformGray",platformLCD:"antiAliasPlatformLCD"});_.warpStyle=(0,V.createEnum)("warpStyle","none",{none:"warpNone",arc:"warpArc",arcLower:"warpArcLower",arcUpper:"warpArcUpper",arch:"warpArch",bulge:"warpBulge",shellLower:"warpShellLower",shellUpper:"warpShellUpper",flag:"warpFlag",wave:"warpWave",fish:"warpFish",rise:"warpRise",fisheye:"warpFisheye",inflate:"warpInflate",squeeze:"warpSqueeze",twist:"warpTwist",cylinder:"warpCylinder",custom:"warpCustom"});_.BlnM=(0,V.createEnum)("BlnM","normal",{normal:"Nrml",dissolve:"Dslv",darken:"Drkn",multiply:"Mltp","color burn":"CBrn","linear burn":"linearBurn","darker color":"darkerColor",lighten:"Lghn",screen:"Scrn","color dodge":"CDdg","linear dodge":"linearDodge","lighter color":"lighterColor",overlay:"Ovrl","soft light":"SftL","hard light":"HrdL","vivid light":"vividLight","linear light":"linearLight","pin light":"pinLight","hard mix":"hardMix",difference:"Dfrn",exclusion:"Xclu",subtract:"blendSubtraction",divide:"blendDivide",hue:"H ",saturation:"Strt",color:"Clr ",luminosity:"Lmns","linear height":"linearHeight",height:"Hght",subtraction:"Sbtr","pass through":"passThrough"});_.BESl=(0,V.createEnum)("BESl","inner bevel",{"inner bevel":"InrB","outer bevel":"OtrB",emboss:"Embs","pillow emboss":"PlEb","stroke emboss":"strokeEmboss"});_.bvlT=(0,V.createEnum)("bvlT","smooth",{smooth:"SfBL","chisel hard":"PrBL","chisel soft":"Slmt"});_.BESs=(0,V.createEnum)("BESs","up",{up:"In ",down:"Out "});_.BETE=(0,V.createEnum)("BETE","softer",{softer:"SfBL",precise:"PrBL"});_.IGSr=(0,V.createEnum)("IGSr","edge",{edge:"SrcE",center:"SrcC"});_.GrdT=(0,V.createEnum)("GrdT","linear",{linear:"Lnr ",radial:"Rdl ",angle:"Angl",reflected:"Rflc",diamond:"Dmnd"});_.animInterpStyleEnum=(0,V.createEnum)("animInterpStyle","linear",{linear:"Lnr ",hold:"hold"});_.stdTrackID=(0,V.createEnum)("stdTrackID","opacity",{opacity:"opacityTrack",style:"styleTrack",sheetTransform:"sheetTransformTrack",sheetPosition:"sheetPositionTrack",globalLighting:"globalLightingTrack"});_.gradientInterpolationMethodType=(0,V.createEnum)("gradientInterpolationMethodType","perceptual",{perceptual:"Perc",linear:"Lnr ",classic:"Gcls",smooth:"Smoo"});_.Clry=(0,V.createEnum)("Clry","user",{user:"UsrS",foreground:"FrgC",background:"BckC"});_.ClrS=(0,V.createEnum)("ClrS","rgb",{rgb:"RGBC",hsb:"HSBl",lab:"LbCl",hsl:"HSLC"});_.FStl=(0,V.createEnum)("FStl","outside",{outside:"OutF",center:"CtrF",inside:"InsF"});_.FrFl=(0,V.createEnum)("FrFl","color",{color:"SClr",gradient:"GrFl",pattern:"Ptrn"});_.ESliceType=(0,V.createEnum)("ESliceType","image",{image:"Img ",noImage:"noImage"});_.ESliceHorzAlign=(0,V.createEnum)("ESliceHorzAlign","default",{default:"default"});_.ESliceVertAlign=(0,V.createEnum)("ESliceVertAlign","default",{default:"default"});_.ESliceOrigin=(0,V.createEnum)("ESliceOrigin","userGenerated",{userGenerated:"userGenerated",autoGenerated:"autoGenerated",layer:"layer"});_.ESliceBGColorType=(0,V.createEnum)("ESliceBGColorType","none",{none:"None",matte:"matte",color:"Clr "});_.strokeStyleLineCapType=(0,V.createEnum)("strokeStyleLineCapType","butt",{butt:"strokeStyleButtCap",round:"strokeStyleRoundCap",square:"strokeStyleSquareCap"});_.strokeStyleLineJoinType=(0,V.createEnum)("strokeStyleLineJoinType","miter",{miter:"strokeStyleMiterJoin",round:"strokeStyleRoundJoin",bevel:"strokeStyleBevelJoin"});_.strokeStyleLineAlignment=(0,V.createEnum)("strokeStyleLineAlignment","inside",{inside:"strokeStyleAlignInside",center:"strokeStyleAlignCenter",outside:"strokeStyleAlignOutside"});_.BlrM=(0,V.createEnum)("BlrM","spin",{spin:"Spn ",zoom:"Zm "});_.BlrQ=(0,V.createEnum)("BlrQ","good",{draft:"Drft",good:"Gd ",best:"Bst "});_.SmBM=(0,V.createEnum)("SmBM","normal",{normal:"SBMN","edge only":"SBME","overlay edge":"SBMO"});_.SmBQ=(0,V.createEnum)("SmBQ","medium",{low:"SBQL",medium:"SBQM",high:"SBQH"});_.DspM=(0,V.createEnum)("DspM","stretch to fit",{"stretch to fit":"StrF",tile:"Tile"});_.UndA=(0,V.createEnum)("UndA","repeat edge pixels",{"wrap around":"WrpA","repeat edge pixels":"RptE"});_.Cnvr=(0,V.createEnum)("Cnvr","rectangular to polar",{"rectangular to polar":"RctP","polar to rectangular":"PlrR"});_.RplS=(0,V.createEnum)("RplS","medium",{small:"Sml ",medium:"Mdm ",large:"Lrg "});_.SphM=(0,V.createEnum)("SphM","normal",{normal:"Nrml","horizontal only":"HrzO","vertical only":"VrtO"});_.Wvtp=(0,V.createEnum)("Wvtp","sine",{sine:"WvSn",triangle:"WvTr",square:"WvSq"});_.ZZTy=(0,V.createEnum)("ZZTy","pond ripples",{"around center":"ArnC","out from center":"OtFr","pond ripples":"PndR"});_.Dstr=(0,V.createEnum)("Dstr","uniform",{uniform:"Unfr",gaussian:"Gsn "});_.Chnl=(0,V.createEnum)("Chnl","composite",{red:"Rd ",green:"Grn ",blue:"Bl ",composite:"Cmps"});_.MztT=(0,V.createEnum)("MztT","fine dots",{"fine dots":"FnDt","medium dots":"MdmD","grainy dots":"GrnD","coarse dots":"CrsD","short lines":"ShrL","medium lines":"MdmL","long lines":"LngL","short strokes":"ShSt","medium strokes":"MdmS","long strokes":"LngS"});_.Lns=(0,V.createEnum)("Lns ","50-300mm zoom",{"50-300mm zoom":"Zm ","32mm prime":"Nkn ","105mm prime":"Nkn1","movie prime":"PnVs"});_.blurType=(0,V.createEnum)("blurType","gaussian blur",{"gaussian blur":"GsnB","lens blur":"lensBlur","motion blur":"MtnB"});_.DfsM=(0,V.createEnum)("DfsM","normal",{normal:"Nrml","darken only":"DrkO","lighten only":"LghO",anisotropic:"anisotropic"});_.ExtT=(0,V.createEnum)("ExtT","blocks",{blocks:"Blks",pyramids:"Pyrm"});_.ExtR=(0,V.createEnum)("ExtR","random",{random:"Rndm","level-based":"LvlB"});_.FlCl=(0,V.createEnum)("FlCl","background color",{"background color":"FlBc","foreground color":"FlFr","inverse image":"FlIn","unaltered image":"FlSm"});_.CntE=(0,V.createEnum)("CntE","upper",{lower:"Lwr ",upper:"Upr "});_.WndM=(0,V.createEnum)("WndM","wind",{wind:"Wnd ",blast:"Blst",stagger:"Stgr"});_.Drct=(0,V.createEnum)("Drct","right",{left:"Left",right:"Rght"});_.IntE=(0,V.createEnum)("IntE","odd lines",{"odd lines":"ElmO","even lines":"ElmE"});_.IntC=(0,V.createEnum)("IntC","interpolation",{duplication:"CrtD",interpolation:"CrtI"});_.FlMd=(0,V.createEnum)("FlMd","wrap around",{"set to transparent":"Bckg","repeat edge pixels":"Rpt ","wrap around":"Wrp "});_.prjM=(0,V.createEnum)("prjM","fisheye",{fisheye:"fisP",perspective:"perP",auto:"auto","full spherical":"fusP"});_.presetKindType=(0,V.createEnum)("presetKindType","custom",{custom:"presetKindCustom",default:"presetKindDefault"});_.patternColorHandling=(0,V.createEnum)("","convert",{convert:"conv","avoid conversion":"avod","luminance only":"lumi"})});var qr=ae(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.resourceHandlersMap=Et.resourceHandlers=void 0;Et.shouldReadResource=Fh;var Dh=no(),Fn=ui(),I=st(),P=En(),cn=Ot(),Oc=Br(),z=ao();Et.resourceHandlers=[];Et.resourceHandlersMap={};function Oh(e){let n=[],t=new Proxy({},{get(i,o){typeof o=="string"&&!n.includes(o)&&n.push(o)}});try{e(t)}catch{}return n}var Eh=new Set(["layersGroup","layerGroupsEnabledId","alphaChannelNames","transparencyIndex"]);function j(e,n,t,i,o={}){var r,s;let a=(r=o.fields)!==null&&r!==void 0?r:Oh(n),l=a.some(f=>Eh.has(f)),c={key:e,keyCount:(s=o.keyCount)!==null&&s!==void 0?s:1,has:n,read:t,write:i,name:o.name,fields:a,required:l};Et.resourceHandlers.push(c);for(let f=0;f<c.keyCount;f++)Et.resourceHandlersMap[c.key+f]=c}function Fh(e,n){return!n||e.required||n.size>0&&e.fields.some(t=>n.has(t))}var Lh=!1,lo=[void 0,"PPI","PPCM"],co=[void 0,"Inches","Centimeters","Points","Picas","Columns"],wc="0123456789abcdef";function vc(e){return e<=57?e-48:e>=97?e-87:e-55}function Mh(e,n){return vc(e.charCodeAt(n))<<4|vc(e.charCodeAt(n+1))}function Vr(e,n){let t=(0,I.readBytes)(e,n);return(0,I.decodeUtf8)(e,t)}function Nr(e,n){let t=(0,Oc.encodeString)(n);(0,P.writeBytes)(e,t)}function Ec(e){let n=(0,I.readUint8)(e),t=(0,I.readBytes)(e,n);return Fc(e,t)}function Fc(e,n){let t=!1;for(let i=0;i<n.byteLength;i++)if(n[i]&128){t=!0;break}if(t){for(let i of[(0,I.getGbkStrictDecoder)(e),(0,I.getUtf8StrictDecoder)(e)])if(i)try{return i.decode(n)}catch{}}return(0,I.decodeUtf8)(e,n)}function Lc(e){let n="";for(let t=0;t<e.length;){let i=e.codePointAt(t);n+=i>127?"?":String.fromCharCode(i),t+=i>65535?2:1}return n.length>255?n.substring(0,255):n}function Mc(e,n){let t=(0,Oc.encodeString)(Lc(n));(0,P.writeUint8)(e,t.byteLength),(0,P.writeBytes)(e,t)}j(1028,e=>e.iptcData!==void 0,(e,n,t)=>{n.iptcData=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.iptcData)});j(1061,e=>e.captionDigest!==void 0,(e,n)=>{let t="";for(let i=0;i<16;i++){let o=(0,I.readUint8)(e);t+=wc[o>>4],t+=wc[o&15]}n.captionDigest=t},(e,n)=>{for(let t=0;t<16;t++)(0,P.writeUint8)(e,Mh(n.captionDigest,t*2))});j(1060,e=>e.xmpMetadata!==void 0,(e,n,t)=>{n.xmpMetadata=Vr(e,t())},(e,n)=>{Nr(e,n.xmpMetadata)});var fo=(0,cn.createEnum)("Inte","perceptual",{perceptual:"Img ",saturation:"Grp ","relative colorimetric":"Clrm","absolute colorimetric":"AClr"});j(1085,e=>e.windowsDevMode!==void 0,(e,n,t)=>{n.windowsDevMode=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.windowsDevMode)});j(1082,e=>e.printInformation!==void 0,(e,n)=>{var t,i;let o=(0,z.readVersionAndDescriptor)(e);n.printInformation={printerName:o.printerName||"",renderingIntent:fo.decode((t=o.Inte)!==null&&t!==void 0?t:"Inte.Img ")};let r=n.printInformation;o.PstS!==void 0&&(r.printerManagesColors=o.PstS),o.ClrS==="ClrS.Grys"&&(r.printerProfileColorSpace="grayscale"),o["Nm "]!==void 0&&(r.printerProfile=o["Nm "]),o.MpBl!==void 0&&(r.blackPointCompensation=o.MpBl),o.printSixteenBit!==void 0&&(r.printSixteenBit=o.printSixteenBit),o.hardProof!==void 0&&(r.hardProof=o.hardProof),o.printProofSetup&&("Bltn"in o.printProofSetup?r.proofSetup={builtin:o.printProofSetup.Bltn.split(".")[1]}:r.proofSetup={profile:o.printProofSetup.profile,renderingIntent:fo.decode((i=o.printProofSetup.Inte)!==null&&i!==void 0?i:"Inte.Img "),blackPointCompensation:!!o.printProofSetup.MpBl,paperWhite:!!o.printProofSetup.paperWhite})},(e,n)=>{let t=n.printInformation,i={};t.printerManagesColors?i.PstS=!0:(t.hardProof!==void 0&&(i.hardProof=!!t.hardProof),i.ClrS=t.printerProfileColorSpace==="grayscale"?"ClrS.Grys":"ClrS.RGBC",t.printerProfile!==void 0&&(i["Nm "]=t.printerProfile)),i.Inte=fo.encode(t.renderingIntent),!t.printerManagesColors&&t.blackPointCompensation!==void 0&&(i.MpBl=!!t.blackPointCompensation),i.printSixteenBit=!!t.printSixteenBit,i.printerName=t.printerName||"",t.proofSetup&&"profile"in t.proofSetup?i.printProofSetup={profile:t.proofSetup.profile||"",Inte:fo.encode(t.proofSetup.renderingIntent),MpBl:!!t.proofSetup.blackPointCompensation,paperWhite:!!t.proofSetup.paperWhite}:t.proofSetup&&(i.printProofSetup={Bltn:`builtinProof.${t.proofSetup.builtin||"proofCMYK"}`}),(0,z.writeVersionAndDescriptor)(e,"","printOutput",i)});j(1083,e=>e.printStyle!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e);n.printStyle={caption:t.Cptn,calibrationBars:t.Clbr,registrationMarks:t.RgsM,cornerCropMarks:t.CrnC,centerCropMarks:t.CntC,labels:t.Lbls,negative:t.Ngtv,emulsionDown:t.EmlD,interpolate:t.Intr,backgroundColor:(0,z.parseColor)(t.Bckg),border:(0,z.parseUnits)(t.BrdT),bleed:(0,z.parseUnits)(t["Bld "]),resolution:(0,z.parseUnits)(t.Rslt),vectorData:t.vectorData,pagePosition:t.PgPs==="PgPs.PgPC"?"centered":t.PgPs,left:(0,z.parseUnits)(t.Left),top:(0,z.parseUnits)(t["Top "]),scale:(0,z.parsePercent)(t["Scl "])},t.cropWhenPrinting!==void 0&&(n.printStyle.cropWhenPrinting=t.cropWhenPrinting,n.printStyle.cropRect={top:t.cropRectTop||0,left:t.cropRectLeft||0,bottom:t.cropRectBottom||0,right:t.cropRectRight||0})},(e,n)=>{var t,i,o,r,s,a,l,c,f,u;let d=n.printStyle,p={Cptn:!!d.caption,Clbr:!!d.calibrationBars,RgsM:!!d.registrationMarks,CrnC:!!d.cornerCropMarks,CntC:!!d.centerCropMarks,Lbls:!!d.labels,Ngtv:!!d.negative,EmlD:!!d.emulsionDown,Intr:!!d.interpolate,Bckg:(0,z.serializeColor)(d.backgroundColor||{r:255,g:255,b:255}),BrdT:(0,z.unitsValue)(d.border||{units:"Distance",value:0},"border"),"Bld ":(0,z.unitsValue)(d.bleed||{units:"Distance",value:0},"bleed"),Rslt:(0,z.unitsValue)(d.resolution||{units:"Pixels",value:72},"resolution"),vectorData:(t=d.vectorData)!==null&&t!==void 0?t:!0,PgPs:!d.pagePosition||d.pagePosition==="centered"?"PgPs.PgPC":d.pagePosition,Left:(0,z.unitsValue)(d.left||{units:"Distance",value:0},"left"),"Top ":(0,z.unitsValue)(d.top||{units:"Distance",value:0},"top"),"Scl ":(0,z.unitsPercentF)((i=d.scale)!==null&&i!==void 0?i:1)};(d.cropWhenPrinting!==void 0||d.cropRect)&&(p.cropWhenPrinting=!!d.cropWhenPrinting,p.cropRectBottom=(r=(o=d.cropRect)===null||o===void 0?void 0:o.bottom)!==null&&r!==void 0?r:0,p.cropRectLeft=(a=(s=d.cropRect)===null||s===void 0?void 0:s.left)!==null&&a!==void 0?a:0,p.cropRectRight=(c=(l=d.cropRect)===null||l===void 0?void 0:l.right)!==null&&c!==void 0?c:0,p.cropRectTop=(u=(f=d.cropRect)===null||f===void 0?void 0:f.top)!==null&&u!==void 0?u:0),(0,z.writeVersionAndDescriptor)(e,"","printOutputOptions",p)});j(1005,e=>e.resolutionInfo!==void 0,(e,n)=>{let t=(0,I.readFixedPoint32)(e),i=(0,I.readUint16)(e),o=(0,I.readUint16)(e),r=(0,I.readFixedPoint32)(e),s=(0,I.readUint16)(e),a=(0,I.readUint16)(e);n.resolutionInfo={horizontalResolution:t,horizontalResolutionUnit:lo[i]||"PPI",widthUnit:co[o]||"Inches",verticalResolution:r,verticalResolutionUnit:lo[s]||"PPI",heightUnit:co[a]||"Inches"}},(e,n)=>{let t=n.resolutionInfo;(0,P.writeFixedPoint32)(e,t.horizontalResolution||0),(0,P.writeUint16)(e,Math.max(1,lo.indexOf(t.horizontalResolutionUnit))),(0,P.writeUint16)(e,Math.max(1,co.indexOf(t.widthUnit))),(0,P.writeFixedPoint32)(e,t.verticalResolution||0),(0,P.writeUint16)(e,Math.max(1,lo.indexOf(t.verticalResolutionUnit))),(0,P.writeUint16)(e,Math.max(1,co.indexOf(t.heightUnit)))});var Sc=["centered","size to fit","user defined"];j(1062,e=>e.printScale!==void 0,(e,n)=>{n.printScale={style:Sc[(0,I.readInt16)(e)],x:(0,I.readFloat32)(e),y:(0,I.readFloat32)(e),scale:(0,I.readFloat32)(e)}},(e,n)=>{let{style:t,x:i,y:o,scale:r}=n.printScale;(0,P.writeInt16)(e,Math.max(0,Sc.indexOf(t))),(0,P.writeFloat32)(e,i||0),(0,P.writeFloat32)(e,o||0),(0,P.writeFloat32)(e,r||0)});j(1006,e=>e.alphaChannelNames!==void 0,(e,n,t)=>{if(n.alphaChannelNames)(0,I.skipBytes)(e,t());else for(n.alphaChannelNames=[];t()>0;){let i=Ec(e);n.alphaChannelNames.push(i)}},(e,n)=>{for(let t of n.alphaChannelNames)Mc(e,t)});j(1045,e=>e.alphaChannelNames!==void 0,(e,n,t)=>{for(n.alphaChannelNames=[];t()>0;)n.alphaChannelNames.push((0,I.readUnicodeString)(e))},(e,n)=>{for(let t of n.alphaChannelNames)(0,P.writeUnicodeStringWithPadding)(e,t)});var Uc=["selected","protected","spot"],Uh=[0,1,2,7,8];function Bc(e){let n={opacity:0,kind:"selected"},t=e.view.getUint16(e.offset);Uh.indexOf(t)!==-1?n.color=(0,I.readColor)(e):((0,I.skipBytes)(e,2),n.rawColor={colorSpace:t,values:[(0,I.readUint16)(e),(0,I.readUint16)(e),(0,I.readUint16)(e),(0,I.readUint16)(e)]}),n.opacity=(0,I.readUint16)(e)/100;let i=Uc[(0,I.readUint8)(e)];if(!i)throw new Error("Invalid display info kind");return n.kind=i,n}j(1007,()=>!1,(e,n,t)=>{let i=[];for(;t()>=14;)i.push(Bc(e)),(0,I.skipBytes)(e,1);n.alphaChannelDisplayInfo||(n.alphaChannelDisplayInfo=i)},()=>{},{fields:["alphaChannelDisplayInfo"]});j(1077,e=>e.alphaChannelDisplayInfo!==void 0,(e,n,t)=>{let i=(0,I.readUint32)(e);if(i!==1)throw new Error(`Invalid display info version: ${i}`);for(n.alphaChannelDisplayInfo=[];t()>=13;)n.alphaChannelDisplayInfo.push(Bc(e))},(e,n)=>{(0,P.writeUint32)(e,1);for(let t of n.alphaChannelDisplayInfo){if(!t.color&&t.rawColor){(0,P.writeUint16)(e,t.rawColor.colorSpace);for(let i=0;i<4;i++)(0,P.writeUint16)(e,t.rawColor.values[i]|0)}else(0,P.writeColor)(e,t.color||{r:255,g:0,b:0});(0,P.writeUint16)(e,Math.round((0,cn.clamp)(t.opacity,0,1)*100)),(0,P.writeUint8)(e,Math.max(0,Uc.indexOf(t.kind)))}});j(1053,e=>e.alphaIdentifiers!==void 0,(e,n,t)=>{for(n.alphaIdentifiers=[];t()>=4;)n.alphaIdentifiers.push((0,I.readUint32)(e))},(e,n)=>{for(let t of n.alphaIdentifiers)(0,P.writeUint32)(e,t)});j(1010,e=>e.backgroundColor!==void 0,(e,n)=>n.backgroundColor=(0,I.readColor)(e),(e,n)=>(0,P.writeColor)(e,n.backgroundColor));j(1037,e=>e.globalAngle!==void 0,(e,n)=>n.globalAngle=(0,I.readInt32)(e),(e,n)=>(0,P.writeInt32)(e,n.globalAngle));j(1049,e=>e.globalAltitude!==void 0,(e,n)=>n.globalAltitude=(0,I.readUint32)(e),(e,n)=>(0,P.writeUint32)(e,n.globalAltitude));j(1011,e=>e.printFlags!==void 0,(e,n,t)=>{n.printFlags={labels:!!(0,I.readUint8)(e),cropMarks:!!(0,I.readUint8)(e),colorBars:!!(0,I.readUint8)(e),registrationMarks:!!(0,I.readUint8)(e),negative:!!(0,I.readUint8)(e),flip:!!(0,I.readUint8)(e),interpolate:!!(0,I.readUint8)(e),caption:!!(0,I.readUint8)(e),printFlags:t()?!!(0,I.readUint8)(e):!1}},(e,n)=>{let t=n.printFlags;(0,P.writeUint8)(e,t.labels?1:0),(0,P.writeUint8)(e,t.cropMarks?1:0),(0,P.writeUint8)(e,t.colorBars?1:0),(0,P.writeUint8)(e,t.registrationMarks?1:0),(0,P.writeUint8)(e,t.negative?1:0),(0,P.writeUint8)(e,t.flip?1:0),(0,P.writeUint8)(e,t.interpolate?1:0),(0,P.writeUint8)(e,t.caption?1:0),(0,P.writeUint8)(e,t.printFlags?1:0)});j(1034,e=>e.copyrighted!==void 0,(e,n)=>{n.copyrighted=!!(0,I.readUint8)(e)},(e,n)=>{(0,P.writeUint8)(e,n.copyrighted?1:0)});j(1035,e=>e.url!==void 0,(e,n,t)=>{n.url=(0,I.readAsciiString)(e,t())},(e,n)=>{(0,P.writeAsciiString)(e,n.url)});j(1e4,e=>e.printFlagsInfo!==void 0,(e,n)=>{let t=(0,I.readUint16)(e);if(t!==1)throw new Error(`Invalid print flags information version: ${t}`);let i=!!(0,I.readUint8)(e);(0,I.skipBytes)(e,1);let o=(0,I.readUint32)(e),r=(0,I.readUint16)(e);n.printFlagsInfo={centerCropMarks:i,bleedWidth:o,bleedWidthScale:r}},(e,n)=>{let t=n.printFlagsInfo;(0,P.writeUint16)(e,1),(0,P.writeUint8)(e,t.centerCropMarks?1:0),(0,P.writeUint8)(e,0),(0,P.writeUint32)(e,t.bleedWidth|0),(0,P.writeUint16)(e,t.bleedWidthScale|0)});j(1046,e=>e.indexedColorCount!==void 0,(e,n)=>{n.indexedColorCount=(0,I.readUint16)(e)},(e,n)=>{(0,P.writeUint16)(e,n.indexedColorCount)});j(1047,e=>e.transparencyIndex!==void 0,(e,n)=>{n.transparencyIndex=(0,I.readUint16)(e)},(e,n)=>{(0,P.writeUint16)(e,n.transparencyIndex)});var Rc=["lines/inch","lines/cm"],Tc=["round","ellipse","line","square","cross",void 0,"diamond"];function Gr(e,n){let t=[];for(;n()>=18;){let i=(0,I.readFixedPoint32)(e),o=Rc[(0,I.readUint16)(e)-1];if(!o)throw new Error("Invalid halftone screen frequency units");let r=(0,I.readFixedPoint32)(e),s=Tc[(0,I.readInt16)(e)];if(!s)throw new Error("Invalid halftone screen shape");(0,I.skipBytes)(e,4);let a=!!(0,I.readUint8)(e),l=!!(0,I.readUint8)(e);t.push({frequency:i,frequencyUnits:o,angle:r,shape:s,accurateScreens:a,printerDefaultScreens:l})}return t}function Hr(e,n){for(let t of n)(0,P.writeFixedPoint32)(e,t.frequency),(0,P.writeUint16)(e,Math.max(0,Rc.indexOf(t.frequencyUnits))+1),(0,P.writeFixedPoint32)(e,t.angle),(0,P.writeInt16)(e,Math.max(0,Tc.indexOf(t.shape))),(0,P.writeZeros)(e,4),(0,P.writeUint8)(e,t.accurateScreens?1:0),(0,P.writeUint8)(e,t.printerDefaultScreens?1:0)}j(1012,e=>e.grayscaleHalftoneScreens!==void 0,(e,n,t)=>n.grayscaleHalftoneScreens=Gr(e,t),(e,n)=>Hr(e,n.grayscaleHalftoneScreens));j(1013,e=>e.colorHalftoneScreens!==void 0,(e,n,t)=>n.colorHalftoneScreens=Gr(e,t),(e,n)=>Hr(e,n.colorHalftoneScreens));function Wr(e,n){let t=[];for(;n()>=28;){let i=[];for(let r=0;r<13;r++)i.push((0,I.readInt16)(e));let o=!!(0,I.readUint16)(e);t.push({curve:i,override:o})}return t}function Xr(e,n){var t;for(let i of n){for(let o=0;o<13;o++)(0,P.writeInt16)(e,(t=i.curve[o])!==null&&t!==void 0?t:-1);(0,P.writeUint16)(e,i.override?1:0)}}j(1014,e=>e.duotoneHalftoneScreens!==void 0,(e,n,t)=>n.duotoneHalftoneScreens=Gr(e,t),(e,n)=>Hr(e,n.duotoneHalftoneScreens));j(1017,e=>e.duotoneTransferFunctions!==void 0,(e,n,t)=>n.duotoneTransferFunctions=Wr(e,t),(e,n)=>Xr(e,n.duotoneTransferFunctions));j(1018,e=>e.duotoneImageInformation!==void 0,(e,n,t)=>n.duotoneImageInformation=(0,I.readBytes)(e,t()),(e,n)=>(0,P.writeBytes)(e,n.duotoneImageInformation));j(1066,e=>e.alternateDuotoneColors!==void 0,(e,n,t)=>{if((0,I.readUint16)(e)!==1)throw new Error("Invalid alternate duotone colors version");let i=[],o=(0,I.readUint16)(e);for(let a=0;a<o&&t()>=10;a++)i.push((0,I.readColor)(e));let r=(0,I.readUint16)(e);if(r*3>t())throw new Error("Invalid alternate duotone colors Lab table size");let s=(0,I.readBytes)(e,r*3);n.alternateDuotoneColors={colors:i,labColors:s}},(e,n)=>{let{colors:t,labColors:i}=n.alternateDuotoneColors;(0,P.writeUint16)(e,1),(0,P.writeUint16)(e,t.length);for(let o of t)(0,P.writeColor)(e,o);(0,P.writeUint16)(e,Math.floor(i.byteLength/3)),(0,P.writeBytes)(e,i.subarray(0,Math.floor(i.byteLength/3)*3))});j(1015,e=>e.grayscaleTransferFunctions!==void 0,(e,n,t)=>n.grayscaleTransferFunctions=Wr(e,t),(e,n)=>Xr(e,n.grayscaleTransferFunctions));j(1016,e=>e.colorTransferFunctions!==void 0,(e,n,t)=>n.colorTransferFunctions=Wr(e,t),(e,n)=>Xr(e,n.colorTransferFunctions));j(1080,e=>e.countInformation!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e);n.countInformation=t.countGroupList.map(i=>({color:{r:i["Rd "],g:i["Grn "],b:i["Bl "]},name:i["Nm "],size:i["Rds "],fontSize:i.fontSize,visible:i.Vsbl,points:i.countObjectList.map(o=>({x:o["X "],y:o["Y "]}))}))},(e,n)=>{let t={Vrsn:1,countGroupList:n.countInformation.map(i=>({"Rd ":i.color.r,"Grn ":i.color.g,"Bl ":i.color.b,"Nm ":i.name,"Rds ":i.size,fontSize:i.fontSize,Vsbl:i.visible,countObjectList:i.points.map(o=>({"X ":o.x,"Y ":o.y}))}))};(0,z.writeVersionAndDescriptor)(e,"","Cnt ",t)});j(1024,e=>e.layerState!==void 0,(e,n)=>n.layerState=(0,I.readUint16)(e),(e,n)=>(0,P.writeUint16)(e,n.layerState));j(1026,e=>e.layersGroup!==void 0,(e,n,t)=>{for(n.layersGroup=[];t()>0;)n.layersGroup.push((0,I.readUint16)(e))},(e,n)=>{for(let t of n.layersGroup)(0,P.writeUint16)(e,t)});j(1072,e=>e.layerGroupsEnabledId!==void 0,(e,n,t)=>{for(n.layerGroupsEnabledId=[];t()>0;)n.layerGroupsEnabledId.push((0,I.readUint8)(e))},(e,n)=>{for(let t of n.layerGroupsEnabledId)(0,P.writeUint8)(e,t)});j(1069,e=>e.layerSelectionIds!==void 0,(e,n)=>{let t=(0,I.readUint16)(e);for(n.layerSelectionIds=[];t--;)n.layerSelectionIds.push((0,I.readUint32)(e))},(e,n)=>{(0,P.writeUint16)(e,n.layerSelectionIds.length);for(let t of n.layerSelectionIds)(0,P.writeUint32)(e,t)});j(1032,e=>e.gridAndGuidesInformation!==void 0,(e,n)=>{var t;let i=(0,I.readUint32)(e),o=(0,I.readUint32)(e),r=(0,I.readUint32)(e),s=(0,I.readUint32)(e);if(i!==1)throw new Error(`Invalid 1032 resource version: ${i}`);let a=(t=n.gridAndGuidesInformation)===null||t===void 0?void 0:t.guides,l=[];for(let c=0;c<s;c++){let f={location:(0,I.readInt32)(e)/32,direction:(0,I.readUint8)(e)?"horizontal":"vertical"};a?.length===s&&a[c].color&&(f.color=a[c].color),a?.length===s&&a[c].id&&(f.id=a[c].id),l.push(f)}n.gridAndGuidesInformation={grid:{horizontal:o,vertical:r},guides:l}},(e,n)=>{let t=n.gridAndGuidesInformation,i=t.grid||{horizontal:576,vertical:576},o=t.guides||[];(0,P.writeUint32)(e,1),(0,P.writeUint32)(e,Math.round(i.horizontal)),(0,P.writeUint32)(e,Math.round(i.vertical)),(0,P.writeUint32)(e,o.length);for(let r of o)(0,P.writeInt32)(e,Math.round(r.location*32)),(0,P.writeUint8)(e,r.direction==="horizontal"?1:0)});var Bh={r:74,g:255,b:255};j(1092,e=>e.gridAndGuidesInformation!==void 0,(e,n)=>{var t;let i=(0,I.readUint32)(e);if(i!==2)throw new Error(`Invalid 1092 resource version: ${i}`);let o=(0,I.readUint32)(e),r=(0,I.readUint32)(e),s=(0,I.readUint32)(e),a=[];for(let c=0;c<s;c++){let f=(0,I.readInt32)(e)/32,u=(0,I.readUint8)(e)?"horizontal":"vertical";(0,I.skipBytes)(e,1);let d={r:(0,I.readUint8)(e),g:(0,I.readUint8)(e),b:(0,I.readUint8)(e)};a.push({location:f,direction:u,color:d})}let l=(t=n.gridAndGuidesInformation)===null||t===void 0?void 0:t.guides;l&&l.length===s?l.forEach((c,f)=>c.color=a[f].color):n.gridAndGuidesInformation={grid:{horizontal:o,vertical:r},guides:a}},(e,n)=>{let t=n.gridAndGuidesInformation,i=t.grid||{horizontal:576,vertical:576},o=t.guides||[];(0,P.writeUint32)(e,2),(0,P.writeUint32)(e,Math.round(i.horizontal)),(0,P.writeUint32)(e,Math.round(i.vertical)),(0,P.writeUint32)(e,o.length);for(let r of o){let s=r.color||Bh;(0,P.writeInt32)(e,Math.round(r.location*32)),(0,P.writeUint8)(e,r.direction==="horizontal"?1:0),(0,P.writeUint8)(e,0),(0,P.writeUint8)(e,Math.round(s.r)),(0,P.writeUint8)(e,Math.round(s.g)),(0,P.writeUint8)(e,Math.round(s.b))}});var xc="00000000-0000-0000-0000-000000000000";j(1097,e=>!!e.gridAndGuidesInformation&&(e.gridAndGuidesInformation.guides||[]).every(n=>n.id),(e,n)=>{var t;let i=(0,I.readUint32)(e),o=[];for(let s=0;s<i;s++)o.push((0,I.readAsciiString)(e,(0,I.readUint32)(e))),(0,I.readUint32)(e),(0,I.readAsciiString)(e,(0,I.readUint32)(e));let r=(t=n.gridAndGuidesInformation)===null||t===void 0?void 0:t.guides;r&&r.length===i&&r.forEach((s,a)=>s.id=o[a])},(e,n)=>{let t=n.gridAndGuidesInformation.guides||[];(0,P.writeUint32)(e,t.length);for(let i of t)(0,P.writeUint32)(e,i.id.length),(0,P.writeAsciiString)(e,i.id),(0,P.writeUint32)(e,0),(0,P.writeUint32)(e,xc.length),(0,P.writeAsciiString)(e,xc)});j(1065,e=>e.layerComps!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e,!0);n.layerComps={list:[]};for(let i of t.list)n.layerComps.list.push({id:i.compID,name:i["Nm "],capturedInfo:i.capturedInfo}),i.comment!==void 0&&(n.layerComps.list[n.layerComps.list.length-1].comment=i.comment),i.Expn!==void 0&&(n.layerComps.list[n.layerComps.list.length-1].expanded=i.Expn);t.lastAppliedComp!==void 0&&(n.layerComps.lastApplied=t.lastAppliedComp)},(e,n)=>{let t=n.layerComps,i={list:[]};for(let o of t.list){let r={};r._classID="Comp",r["Nm "]=o.name,o.comment!==void 0&&(r.comment=o.comment),r.compID=o.id,r.capturedInfo=o.capturedInfo,o.expanded!==void 0&&(r.Expn=!!o.expanded),i.list.push(r)}t.lastApplied!==void 0&&(i.lastAppliedComp=t.lastApplied),(0,z.writeVersionAndDescriptor)(e,"","CompList",i)});cn.MOCK_HANDLERS&&j(1092,e=>e._ir1092!==void 0,(e,n,t)=>{Lh&&console.log("image resource 1092",t()),n._ir1092=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n._ir1092)});var kc=["normal",void 0,void 0,void 0,void 0,void 0,void 0,"multiply","screen",void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,"difference"];j(1078,e=>e.onionSkins!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e);n.onionSkins={enabled:t.enab,framesBefore:t.numBefore,framesAfter:t.numAfter,frameSpacing:t.Spcn,minOpacity:t.minOpacity/100,maxOpacity:t.maxOpacity/100,blendMode:kc[t.BlnM]||"normal"}},(e,n)=>{let t=n.onionSkins,i={Vrsn:1,enab:t.enabled,numBefore:t.framesBefore,numAfter:t.framesAfter,Spcn:t.frameSpacing,minOpacity:Math.round(t.minOpacity*100),maxOpacity:Math.round(t.maxOpacity*100),BlnM:Math.max(0,kc.indexOf(t.blendMode))};(0,z.writeVersionAndDescriptor)(e,"","null",i)});j(1075,e=>e.timelineInformation!==void 0,(e,n)=>{var t,i;let o=(0,z.readVersionAndDescriptor)(e);n.timelineInformation={enabled:o.enab,frameStep:(0,z.frac)(o.frameStep),frameRate:o.frameRate,time:(0,z.frac)(o.time),duration:(0,z.frac)(o.duration),workInTime:(0,z.frac)(o.workInTime),workOutTime:(0,z.frac)(o.workOutTime),repeats:o.LCnt,hasMotion:o.hasMotion,globalTracks:(0,z.parseTrackList)(o.globalTrackList,e)},!((i=(t=o.audioClipGroupList)===null||t===void 0?void 0:t.audioClipGroupList)===null||i===void 0)&&i.length&&(n.timelineInformation.audioClipGroups=o.audioClipGroupList.audioClipGroupList.map(r=>({id:r.groupID,muted:r.muted,audioClips:r.audioClipList.map(({clipID:s,timeScope:a,muted:l,audioLevel:c,frameReader:f})=>({id:s,start:(0,z.frac)(a.Strt),duration:(0,z.frac)(a.duration),inTime:(0,z.frac)(a.inTime),outTime:(0,z.frac)(a.outTime),muted:l,audioLevel:c,frameReader:{type:f.frameReaderType,mediaDescriptor:f.mediaDescriptor,link:{name:f["Lnk "]["Nm "],fullPath:f["Lnk "].fullPath,relativePath:f["Lnk "].relPath}}}))})))},(e,n)=>{var t;let i=n.timelineInformation,o={Vrsn:1,enab:i.enabled,frameStep:i.frameStep,frameRate:i.frameRate,time:i.time,duration:i.duration,workInTime:i.workInTime,workOutTime:i.workOutTime,LCnt:i.repeats,globalTrackList:(0,z.serializeTrackList)(i.globalTracks,e),audioClipGroupList:{audioClipGroupList:((t=i.audioClipGroups)!==null&&t!==void 0?t:[]).map(r=>({groupID:r.id,muted:r.muted,audioClipList:r.audioClips.map(s=>({clipID:s.id,timeScope:{Vrsn:1,Strt:s.start,duration:s.duration,inTime:s.inTime,outTime:s.outTime},frameReader:{frameReaderType:s.frameReader.type,descVersion:1,"Lnk ":{descVersion:1,"Nm ":s.frameReader.link.name,fullPath:s.frameReader.link.fullPath,relPath:s.frameReader.link.relativePath},mediaDescriptor:s.frameReader.mediaDescriptor},muted:s.muted,audioLevel:s.audioLevel}))}))},hasMotion:i.hasMotion};(0,z.writeVersionAndDescriptor)(e,"","null",o,"anim")});j(1076,e=>e.sheetDisclosure!==void 0,(e,n)=>{let t=(0,z.readVersionAndDescriptor)(e);n.sheetDisclosure={},t.sheetTimelineOptions&&(n.sheetDisclosure.sheetTimelineOptions=t.sheetTimelineOptions.map(i=>({sheetID:i.sheetID,sheetDisclosed:i.sheetDisclosed,lightsDisclosed:i.lightsDisclosed,meshesDisclosed:i.meshesDisclosed,materialsDisclosed:i.materialsDisclosed})))},(e,n)=>{let t=n.sheetDisclosure,i={Vrsn:1};t.sheetTimelineOptions&&(i.sheetTimelineOptions=t.sheetTimelineOptions.map(o=>({Vrsn:2,sheetID:o.sheetID,sheetDisclosed:o.sheetDisclosed,lightsDisclosed:o.lightsDisclosed,meshesDisclosed:o.meshesDisclosed,materialsDisclosed:o.materialsDisclosed}))),(0,z.writeVersionAndDescriptor)(e,"","null",i)});j(1054,e=>e.urlsList!==void 0,(e,n)=>{let t=(0,I.readUint32)(e);n.urlsList=[];for(let i=0;i<t;i++){if((0,I.readSignature)(e)!=="slic"&&e.throwForMissingFeatures)throw new Error("Unknown long");let r=(0,I.readUint32)(e),s=(0,I.readUnicodeString)(e);n.urlsList.push({id:r,url:s,ref:"slice"})}},(e,n)=>{let t=n.urlsList;(0,P.writeUint32)(e,t.length);for(let i=0;i<t.length;i++)(0,P.writeSignature)(e,"slic"),(0,P.writeUint32)(e,t[i].id),(0,P.writeUnicodeString)(e,t[i].url)});function _c(e){return{"Top ":e.top,Left:e.left,Btom:e.bottom,Rght:e.right}}function Ac(e){return{top:e["Top "],left:e.Left,bottom:e.Btom,right:e.Rght}}function uo(e,n){return e[Math.max(0,Math.min(e.length-1,n))]}var Ic=["autoGenerated","layer","userGenerated"],Cc=["noImage","image"],po=["default"];j(1050,e=>e.slices?e.slices.length:0,(e,n,t)=>{var i;let o=(0,I.readUint32)(e);if(o===6){n.slices||(n.slices=[]);let r=(0,I.readInt32)(e),s=(0,I.readInt32)(e),a=(0,I.readInt32)(e),l=(0,I.readInt32)(e),c=(0,I.readUnicodeString)(e),f=(0,I.readUint32)(e);n.slices.push({bounds:{top:r,left:s,bottom:a,right:l},groupName:c,slices:[]});let u=n.slices[n.slices.length-1].slices;for(let d=0;d<f;d++){let p=(0,I.readUint32)(e),h=(0,I.readUint32)(e),m=uo(Ic,(0,I.readUint32)(e)),y=m=="layer"?(0,I.readUint32)(e):0,g=(0,I.readUnicodeString)(e),k=uo(Cc,(0,I.readUint32)(e)),x=(0,I.readInt32)(e),S=(0,I.readInt32)(e),A=(0,I.readInt32)(e),D=(0,I.readInt32)(e),C=(0,I.readUnicodeString)(e),O=(0,I.readUnicodeString)(e),E=(0,I.readUnicodeString)(e),L=(0,I.readUnicodeString)(e),M=!!(0,I.readUint8)(e),J=(0,I.readUnicodeString)(e),pe=uo(po,(0,I.readUint32)(e)),R=uo(po,(0,I.readUint32)(e)),ie=(0,I.readUint8)(e),he=(0,I.readUint8)(e),ce=(0,I.readUint8)(e),Ce=(0,I.readUint8)(e),W=ie+he+ce+Ce===0?"none":ie===0?"matte":"color";u.push({id:p,groupId:h,origin:m,associatedLayerId:y,name:g,target:O,message:E,altTag:L,cellTextIsHTML:M,cellText:J,horizontalAlignment:pe,verticalAlignment:R,type:k,url:C,bounds:{top:S,left:x,bottom:D,right:A},backgroundColorType:W,backgroundColor:{r:he,g:ce,b:Ce,a:ie}})}if(t()){let d=(0,z.readVersionAndDescriptor)(e),p=new Map;for(let h of u)p.has(h.id)||p.set(h.id,h);d.slices.forEach(h=>{let m=p.get(h.sliceID);m&&(m.topOutset=h.topOutset,m.leftOutset=h.leftOutset,m.bottomOutset=h.bottomOutset,m.rightOutset=h.rightOutset)})}}else if(o===7||o===8){let r=(0,z.readVersionAndDescriptor)(e);n.slices||(n.slices=[]),n.slices.push({groupName:(i=r.baseName)!==null&&i!==void 0?i:"",bounds:Ac(r.bounds),slices:r.slices.map(s=>{var a;return Object.assign(Object.assign({},s["Nm "]?{name:s["Nm "]}:{}),{id:s.sliceID,groupId:s.groupID,associatedLayerId:(a=s.associatedLayer)!==null&&a!==void 0?a:0,origin:z.ESliceOrigin.decode(s.origin),type:z.ESliceType.decode(s.Type),bounds:Ac(s.bounds),url:s.url,target:s.null,message:s.Msge,altTag:s.altTag,cellTextIsHTML:s.cellTextIsHTML,cellText:s.cellText,horizontalAlignment:z.ESliceHorzAlign.decode(s.horzAlign),verticalAlignment:z.ESliceVertAlign.decode(s.vertAlign),backgroundColorType:z.ESliceBGColorType.decode(s.bgColorType),backgroundColor:s.bgColor?{r:s.bgColor["Rd "],g:s.bgColor["Grn "],b:s.bgColor["Bl "],a:s.bgColor.alpha}:{r:0,g:0,b:0,a:0},topOutset:s.topOutset||0,leftOutset:s.leftOutset||0,bottomOutset:s.bottomOutset||0,rightOutset:s.rightOutset||0})})})}else throw new Error(`Invalid slices version (${o})`)},(e,n,t)=>{let{bounds:i,groupName:o,slices:r}=n.slices[t];(0,P.writeUint32)(e,6),(0,P.writeInt32)(e,i.top),(0,P.writeInt32)(e,i.left),(0,P.writeInt32)(e,i.bottom),(0,P.writeInt32)(e,i.right),(0,P.writeUnicodeString)(e,o),(0,P.writeUint32)(e,r.length);for(let a=0;a<r.length;a++){let l=r[a],{a:c,r:f,g:u,b:d}=l.backgroundColor;l.backgroundColorType==="none"?c=f=u=d=0:l.backgroundColorType==="matte"&&(c=0,f=u=d=255),(0,P.writeUint32)(e,l.id),(0,P.writeUint32)(e,l.groupId),(0,P.writeUint32)(e,Ic.indexOf(l.origin)),l.origin==="layer"&&(0,P.writeUint32)(e,l.associatedLayerId),(0,P.writeUnicodeString)(e,l.name||""),(0,P.writeUint32)(e,Cc.indexOf(l.type)),(0,P.writeInt32)(e,l.bounds.left),(0,P.writeInt32)(e,l.bounds.top),(0,P.writeInt32)(e,l.bounds.right),(0,P.writeInt32)(e,l.bounds.bottom),(0,P.writeUnicodeString)(e,l.url),(0,P.writeUnicodeString)(e,l.target),(0,P.writeUnicodeString)(e,l.message),(0,P.writeUnicodeString)(e,l.altTag),(0,P.writeUint8)(e,l.cellTextIsHTML?1:0),(0,P.writeUnicodeString)(e,l.cellText),(0,P.writeUint32)(e,po.indexOf(l.horizontalAlignment)),(0,P.writeUint32)(e,po.indexOf(l.verticalAlignment)),(0,P.writeUint8)(e,c),(0,P.writeUint8)(e,f),(0,P.writeUint8)(e,u),(0,P.writeUint8)(e,d)}let s={bounds:_c(i),slices:[]};r.forEach(a=>{let l=Object.assign(Object.assign({sliceID:a.id,groupID:a.groupId,origin:z.ESliceOrigin.encode(a.origin),Type:z.ESliceType.encode(a.type),bounds:_c(a.bounds)},a.name?{"Nm ":a.name}:{}),{url:a.url,null:a.target,Msge:a.message,altTag:a.altTag,cellTextIsHTML:a.cellTextIsHTML,cellText:a.cellText,horzAlign:z.ESliceHorzAlign.encode(a.horizontalAlignment),vertAlign:z.ESliceVertAlign.encode(a.verticalAlignment),bgColorType:z.ESliceBGColorType.encode(a.backgroundColorType)});if(a.backgroundColorType==="color"){let{r:c,g:f,b:u,a:d}=a.backgroundColor;l.bgColor={"Rd ":c,"Grn ":f,"Bl ":u,alpha:d}}l.topOutset=a.topOutset||0,l.leftOutset=a.leftOutset||0,l.bottomOutset=a.bottomOutset||0,l.rightOutset=a.rightOutset||0,s.slices.push(l)}),(0,z.writeVersionAndDescriptor)(e,"","null",s,"slices")});j(1064,e=>e.pixelAspectRatio!==void 0,(e,n)=>{if((0,I.readUint32)(e)>2)throw new Error("Invalid pixelAspectRatio version");n.pixelAspectRatio={aspect:(0,I.readFloat64)(e)}},(e,n)=>{(0,P.writeUint32)(e,2),(0,P.writeFloat64)(e,n.pixelAspectRatio.aspect)});j(1041,e=>e.iccUntaggedProfile!==void 0,(e,n)=>{n.iccUntaggedProfile=!!(0,I.readUint8)(e)},(e,n)=>{(0,P.writeUint8)(e,n.iccUntaggedProfile?1:0)});j(1039,e=>e.iccProfile!==void 0,(e,n,t)=>{n.iccProfile=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.iccProfile)});j(1044,e=>e.idsSeedNumber!==void 0,(e,n)=>n.idsSeedNumber=(0,I.readUint32)(e),(e,n)=>(0,P.writeUint32)(e,n.idsSeedNumber));j(1038,e=>e.colorSamplers!==void 0&&!e.colorSamplers.some(n=>n.depth!==void 0),(e,n,t)=>{var i;let o=(0,I.readUint32)(e);if(o!==1)throw new Error(`Invalid color samplers version: ${o}`);if(!((i=n.colorSamplers)===null||i===void 0)&&i.some(s=>s.depth!==void 0))return(0,I.skipBytes)(e,t());let r=(0,I.readUint32)(e);n.colorSamplers=[];for(let s=0;s<r&&t()>=10;s++){let a=(0,I.readInt32)(e)/16,l=(0,I.readInt32)(e)/16,c=(0,I.readInt16)(e);n.colorSamplers.push({x:l,y:a,colorSpace:c})}},(e,n)=>{(0,P.writeUint32)(e,1),(0,P.writeUint32)(e,n.colorSamplers.length);for(let t of n.colorSamplers)(0,P.writeInt32)(e,Math.round(t.y*16)),(0,P.writeInt32)(e,Math.round(t.x*16)),(0,P.writeInt16)(e,t.colorSpace)});j(1073,e=>e.colorSamplers!==void 0&&e.colorSamplers.some(n=>n.depth!==void 0),(e,n,t)=>{let i=(0,I.readUint32)(e);if(i<1||i>3)throw new Error(`Invalid color samplers version: ${i}`);let o=(0,I.readUint32)(e);n.colorSamplers=[];for(let r=0;r<o&&t()>=10;r++){let s=i===3?(0,I.readUint32)(e):i,a=s===1?(0,I.readInt32)(e)/16:(0,I.readFloat32)(e),l=s===1?(0,I.readInt32)(e)/16:(0,I.readFloat32)(e),c=(0,I.readInt16)(e),f=i>=2?(0,I.readInt16)(e):1;n.colorSamplers.push({x:l,y:a,colorSpace:c,depth:f})}},(e,n)=>{var t;(0,P.writeUint32)(e,3),(0,P.writeUint32)(e,n.colorSamplers.length);for(let i of n.colorSamplers)(0,P.writeUint32)(e,1),(0,P.writeInt32)(e,Math.round(i.y*16)),(0,P.writeInt32)(e,Math.round(i.x*16)),(0,P.writeInt16)(e,i.colorSpace),(0,P.writeInt16)(e,(t=i.depth)!==null&&t!==void 0?t:1)});j(1022,e=>e.quickMaskInfo!==void 0,(e,n)=>{let t=(0,I.readUint16)(e),i=!!(0,I.readUint8)(e);n.quickMaskInfo={channelId:t,initiallyEmpty:i}},(e,n)=>{(0,P.writeUint16)(e,n.quickMaskInfo.channelId),(0,P.writeUint8)(e,n.quickMaskInfo.initiallyEmpty?1:0)});j(1074,e=>e.measurementScale!==void 0,(e,n,t)=>{n.measurementScale=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.measurementScale)});j(1042,e=>e.effectsVisible!==void 0,(e,n)=>{n.effectsVisible=!!(0,I.readUint8)(e)},(e,n)=>{(0,P.writeUint8)(e,n.effectsVisible?1:0)});j(1036,e=>e.thumbnail!==void 0||e.thumbnailRaw!==void 0,(e,n,t)=>{let i=(0,I.readUint32)(e),o=(0,I.readUint32)(e),r=(0,I.readUint32)(e),s=(0,I.readUint32)(e);(0,I.readUint32)(e),(0,I.readUint32)(e);let a=(0,I.readUint16)(e);if((0,I.readUint16)(e),i===0&&a===24&&s>=o*3&&s*r<=t()){if(e.useRawThumbnail){e.logMissingFeatures&&e.log("Raw thumbnail data is not supported with useRawThumbnail option"),(0,I.skipBytes)(e,t());return}let f=(0,I.readBytes)(e,s*r),u=(0,cn.createImageData)(o,r);for(let d=0,p=0;d<r;d++)for(let h=0,m=d*s;h<o;h++,m+=3,p+=4)u.data[p+0]=f[m+0],u.data[p+1]=f[m+1],u.data[p+2]=f[m+2],u.data[p+3]=255;n.thumbnail=(0,cn.imageDataToCanvas)(u),(0,I.skipBytes)(e,t());return}if(i!==1||a!==24){e.logMissingFeatures&&e.log(`Invalid thumbnail data (format: ${i}, bitsPerPixel: ${a})`),(0,I.skipBytes)(e,t());return}let l=t(),c=(0,I.readBytes)(e,l);e.useRawThumbnail?n.thumbnailRaw={width:o,height:r,data:c}:c.byteLength&&(n.thumbnail=(0,cn.createCanvasFromData)(c,e))},(e,n)=>{var t;let i=0,o=0,r=new Uint8Array(0);if(n.thumbnailRaw)i=n.thumbnailRaw.width,o=n.thumbnailRaw.height,r=n.thumbnailRaw.data;else try{let u=(t=n.thumbnail.toDataURL("image/jpeg",1))===null||t===void 0?void 0:t.substring(23);u&&(r=(0,Dh.toByteArray)(u),i=n.thumbnail.width,o=n.thumbnail.height)}catch{}let s=24,a=Math.floor((i*s+31)/32)*4,l=1,c=a*o*l,f=r.length;(0,P.writeUint32)(e,1),(0,P.writeUint32)(e,i),(0,P.writeUint32)(e,o),(0,P.writeUint32)(e,a),(0,P.writeUint32)(e,c),(0,P.writeUint32)(e,f),(0,P.writeUint16)(e,s),(0,P.writeUint16)(e,l),(0,P.writeBytes)(e,r)});j(1057,e=>e.versionInfo!==void 0,(e,n,t)=>{if((0,I.readUint32)(e)!==1)throw new Error("Invalid versionInfo version");n.versionInfo={hasRealMergedData:!!(0,I.readUint8)(e),writerName:(0,I.readUnicodeString)(e),readerName:(0,I.readUnicodeString)(e),fileVersion:(0,I.readUint32)(e)},(0,I.skipBytes)(e,t())},(e,n)=>{let t=n.versionInfo;(0,P.writeUint32)(e,1),(0,P.writeUint8)(e,t.hasRealMergedData?1:0),(0,P.writeUnicodeString)(e,t.writerName),(0,P.writeUnicodeString)(e,t.readerName),(0,P.writeUint32)(e,t.fileVersion)});j(1058,e=>e.exifData!==void 0,(e,n,t)=>{n.exifData=(0,I.readBytes)(e,t())},(e,n)=>{(0,P.writeBytes)(e,n.exifData)});j(7e3,e=>e.imageReadyVariables!==void 0,(e,n,t)=>{n.imageReadyVariables=Vr(e,t())},(e,n)=>{Nr(e,n.imageReadyVariables)});j(7001,e=>e.imageReadyDataSets!==void 0,(e,n,t)=>{n.imageReadyDataSets=Vr(e,t())},(e,n)=>{Nr(e,n.imageReadyDataSets)});j(1088,e=>e.pathSelectionState!==void 0,(e,n,t)=>{let i=(0,z.readVersionAndDescriptor)(e);n.pathSelectionState=i.null},(e,n)=>{let t={null:(0,z.pathSelectionStateToReference)(n.pathSelectionState)};(0,z.writeVersionAndDescriptor)(e,"","null",t)});j(1025,e=>e.workPath!==void 0,(e,n,t,{width:i,height:o})=>{n.workPath={paths:[]},(0,Fn.readVectorMask)(e,n.workPath,i,o,t()),(0,I.skipBytes)(e,t())},(e,n,t,{width:i,height:o})=>{(0,Fn.writeVectorMask)(e,n.workPath,i,o)});var $r=999;j(2e3,e=>e.savedPaths?Math.min(e.savedPaths.length,$r):0,(e,n,t,{signature:i,id:o,name:r,width:s,height:a})=>{var l,c;if(i!=="8BIM"){e.logMissingFeatures&&e.log(`Unhandled image resource: ${i} ${o}`),(0,I.skipBytes)(e,t());return}let f=(l=n.savedPaths)!==null&&l!==void 0?l:n.savedPaths=[],u={name:Fc(e,r),paths:[]};(0,Fn.readVectorMask)(e,u,s,a,t()),(0,I.skipBytes)(e,t());let d=(c=n.savedPathsOrigination)===null||c===void 0?void 0:c[f.length];d&&(u.vectorOrigination={keyDescriptorList:d}),f.push(u)},(e,n,t,{width:i,height:o})=>{(0,Fn.writeVectorMask)(e,n.savedPaths[t],i,o)},{keyCount:$r,name:(e,n)=>Lc(e.savedPaths[n].name)});j(3e3,e=>{var n;return!!(!((n=e.savedPaths)===null||n===void 0)&&n.some(t=>t.vectorOrigination))},(e,n,t)=>{(0,z.readVersionAndDescriptor)(e).keyRootDescriptorList.forEach((o,r)=>{var s,a;let l=(0,Fn.parseKeyDescriptorList)(o);if(!l.length)return;let c=(s=n.savedPaths)===null||s===void 0?void 0:s[r];c?c.vectorOrigination={keyDescriptorList:l}:((a=n.savedPathsOrigination)!==null&&a!==void 0?a:n.savedPathsOrigination=[])[r]=l}),(0,I.skipBytes)(e,t())},(e,n)=>{let t={keyRootDescriptorList:n.savedPaths.slice(0,$r).map(i=>{var o,r;return(0,Fn.serializeKeyDescriptorList)((r=(o=i.vectorOrigination)===null||o===void 0?void 0:o.keyDescriptorList)!==null&&r!==void 0?r:[])})};(0,z.writeVersionAndDescriptor)(e,"","null",t)},{name:()=>"OriginDataIRB"});j(2999,e=>e.clippingPath!==void 0,(e,n,t)=>{let i=Ec(e),o=(0,I.readFixedPoint32)(e);(0,I.skipBytes)(e,t()),n.clippingPath={name:i,flatness:o}},(e,n)=>{Mc(e,n.clippingPath.name),(0,P.writeFixedPoint32)(e,n.clippingPath.flatness),(0,P.writeUint16)(e,1)});var Pc=(0,cn.createEnum)("FrmD","auto",{auto:"Auto",none:"None",dispose:"Disp"});function Dc(e){let n=[];return e.outputSettings!==void 0&&n.push("mset"),e.animations!==void 0&&n.push("mani","mfri"),n}j(4e3,e=>Dc(e).length,(e,n,t)=>{let i=(0,I.readSignature)(e);if(i==="mset")n.outputSettings=(0,z.readVersionAndDescriptor)(e,!0),(0,I.skipBytes)(e,t());else if(i==="mfri")(0,I.skipBytes)(e,t());else if(i==="mani")(0,I.checkSignature)(e,"IRFR"),(0,I.readSection)(e,1,o=>{for(;o()>0;){(0,I.checkSignature)(e,"8BIM");let r=(0,I.readSignature)(e);(0,I.readSection)(e,1,s=>{if(r==="AnDs"){let a=(0,z.readVersionAndDescriptor)(e);n.animations={frames:a.FrIn.map(l=>{let c={id:l.FrID,delay:(l.FrDl||0)/100,dispose:l.FrDs?Pc.decode(l.FrDs):"auto"};return l.FrGA!==void 0&&(c.globalAngle=l.FrGA),l.FrGL!==void 0&&(c.globalAltitude=l.FrGL),c}),animations:a.FSts.map(l=>({id:l.FsID,frames:l.FsFr,repeats:l.LCnt,activeFrame:l.AFrm||0}))},a.AFSt!==void 0&&(n.animations.activeAnimation=a.AFSt),(0,I.skipBytes)(e,s())}else if(r==="Roll"){let a=(0,I.readBytes)(e,s());e.logDevFeatures&&e.log("#4000 Roll",a)}else e.logMissingFeatures&&e.log("Unhandled subsection in #4000",r),(0,I.skipBytes)(e,s())})}}),(0,I.skipBytes)(e,t());else if(i==="mopt"){let o=(0,I.readBytes)(e,t());e.logDevFeatures&&e.log("#4000 mopt",o)}else e.logMissingFeatures&&e.log(`Unhandled plug-in resource key: ${i}`),(0,I.skipBytes)(e,t())},(e,n,t)=>{var i,o;let r=Dc(n)[t];if(r==="mset")(0,P.writeSignature)(e,"mset"),(0,z.writeVersionAndDescriptor)(e,"","null",n.outputSettings,z.outputSettingsRoot);else if(r==="mfri"){let s=n.animations;(0,P.writeSignature)(e,"mfri"),(0,P.writeUint32)(e,2),(0,P.writeUint32)(e,16),(0,P.writeUint32)(e,s.frames.length),(0,P.writeUint32)(e,(o=(i=s.animations[0])===null||i===void 0?void 0:i.activeFrame)!==null&&o!==void 0?o:0),(0,P.writeUint32)(e,s.animations.length),(0,P.writeUint32)(e,0)}else r==="mani"&&((0,P.writeSignature)(e,"mani"),(0,P.writeSignature)(e,"IRFR"),(0,P.writeSection)(e,1,()=>{(0,P.writeSignature)(e,"8BIM"),(0,P.writeSignature)(e,"AnDs"),(0,P.writeSection)(e,1,()=>{let s=Object.assign(Object.assign({},n.animations.activeAnimation!==void 0?{AFSt:n.animations.activeAnimation}:{}),{FrIn:[],FSts:[]});for(let a=0;a<n.animations.frames.length;a++){let l=n.animations.frames[a],c={FrID:l.id};l.delay&&(c.FrDl=Math.round(l.delay*100)),c.FrDs=Pc.encode(l.dispose),l.globalAngle!==void 0&&(c.FrGA=l.globalAngle),l.globalAltitude!==void 0&&(c.FrGL=l.globalAltitude),s.FrIn.push(c)}for(let a=0;a<n.animations.animations.length;a++){let l=n.animations.animations[a],c={FsID:l.id,AFrm:l.activeFrame|0,FsFr:l.frames,LCnt:l.repeats|0};s.FSts.push(c)}(0,z.writeVersionAndDescriptor)(e,"","null",s)}),(0,P.writeSignature)(e,"8BIM"),(0,P.writeSignature)(e,"Roll"),(0,P.writeSection)(e,1,()=>{(0,P.writeZeros)(e,8)})}))},{keyCount:1e3})});var st=ae(N=>{"use strict";var Rh=N&&N.__rest||function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]]);return t};Object.defineProperty(N,"__esModule",{value:!0});N.supportedColorModes=void 0;N.getUtf8Decoder=Gc;N.getUtf8StrictDecoder=Vh;N.getGbkStrictDecoder=Nh;N.decodeUtf8=Gh;N.createReader=mi;N.warnOrThrow=qt;N.readUint8=ve;N.peekUint8=Hc;N.readInt16=Xt;N.readUint16=de;N.readUint16LE=Hh;N.readInt32=Re;N.readInt32LE=Wh;N.readUint32=we;N.readFloat32=Xh;N.readFloat64=es;N.readFixedPoint32=qh;N.readFixedPointPath32=Zh;N.readBytes=xt;N.readSignature=yi;N.validSignatureAt=Wc;N.readPascalString=ss;N.readUnicodeString=Xc;N.readUnicodeStringWithLength=Yc;N.readUnicodeStringWithLengthLE=Kh;N.readAsciiString=Yh;N.skipBytes=_e;N.checkSignature=ls;N.readPsd=Qh;N.readLayerInfo=Qc;N.getCompositeImageData=tf;N.getCompositeCanvas=rg;N.getLayerImageData=nf;N.getLayerMaskImageData=of;N.getLayerRealMaskImageData=rf;N.getLayerCanvas=sg;N.getLayerMaskCanvas=ag;N.getLayerRealMaskCanvas=lg;N.getFilterEffectsMaskImageData=sf;N.getFilterEffectsMaskExtraImageData=af;N.getFilterEffectsMaskCanvas=cg;N.getFilterEffectsMaskExtraCanvas=fg;N.decodeLayerPixels=dg;N.readGlobalLayerMaskInfo=cf;N.readAdditionalLayerInfo=cs;N.readDataZip=os;N.readDataRLE=bi;N.readSection=at;N.readColor=Sg;N.readPatternSafe=xg;N.readPattern=hf;N.consumeMemory=Mn;var Th=Hi(),Te=Ot(),jh=ui(),zh=Br(),jc=qr();N.supportedColorModes=[0,1,3,2,4];var $h=["bitmap","grayscale","indexed","RGB","CMYK","","","multichannel","duotone","lab"];function hi(e){let n=e.width*e.height*4;for(let t=0;t<n;t+=4){let i=e.data[t];e.data[t+1]=i,e.data[t+2]=i}}function rs(e,n){try{return typeof TextDecoder<"u"?new TextDecoder(e,n):null}catch{return null}}function Gc(e){return e.utf8Decoder===void 0&&(e.utf8Decoder=rs("utf-8",{ignoreBOM:!0})),e.utf8Decoder}function Vh(e){return e.utf8StrictDecoder===void 0&&(e.utf8StrictDecoder=rs("utf-8",{ignoreBOM:!0,fatal:!0})),e.utf8StrictDecoder}function Nh(e){return e.gbkDecoder===void 0&&(e.gbkDecoder=rs("gbk",{fatal:!0})),e.gbkDecoder}function Gh(e,n){let t=n.byteLength>1e3?Gc(e):null;return t?t.decode(n):(0,zh.decodeString)(n)}function mi(e,n,t){return{view:new DataView(e,n,t),offset:0,strict:!1,debug:!1,large:!1,globalAlpha:!1,log:console.log}}function qt(e,n){if(e.strict)throw new Error(n);e.debug&&e.log(n)}function ve(e){return e.offset+=1,e.view.getUint8(e.offset-1)}function Hc(e){return e.view.getUint8(e.offset)}function Xt(e){return e.offset+=2,e.view.getInt16(e.offset-2,!1)}function de(e){return e.offset+=2,e.view.getUint16(e.offset-2,!1)}function Hh(e){return e.offset+=2,e.view.getUint16(e.offset-2,!0)}function Re(e){return e.offset+=4,e.view.getInt32(e.offset-4,!1)}function Wh(e){return e.offset+=4,e.view.getInt32(e.offset-4,!0)}function we(e){return e.offset+=4,e.view.getUint32(e.offset-4,!1)}function Xh(e){return e.offset+=4,e.view.getFloat32(e.offset-4,!1)}function es(e){return e.offset+=8,e.view.getFloat64(e.offset-8,!1)}function qh(e){return Re(e)/65536}function Zh(e){return Re(e)/(1<<24)}function xt(e,n){if(!(n>=0))throw new Error(`Invalid length: ${n}`);let t=e.offset,i=e.view.byteLength;if(e.offset+=n,t+n>i){if(qt(e,"Reading bytes exceeding buffer length"),n>100*1024*1024)throw new Error("Reading past end of file");Mn(e,n);let o=new Uint8Array(n),r=Math.min(n,i-t);return r>0&&o.set(new Uint8Array(e.view.buffer,e.view.byteOffset+t,r)),o}else return new Uint8Array(e.view.buffer,e.view.byteOffset+t,n)}function yi(e){return Jc(e,4)}function Wc(e,n){let t=String.fromCharCode(e.view.getUint8(n))+String.fromCharCode(e.view.getUint8(n+1))+String.fromCharCode(e.view.getUint8(n+2))+String.fromCharCode(e.view.getUint8(n+3));return t=="8BIM"||t=="8B64"}function ss(e,n){let t=ve(e),i=t?Jc(e,t):"";for(;++t%n;)e.offset++;return i}function Xc(e){let n=we(e);return Yc(e,n)}var pi=8192,as=64;function qc(e,n){if(e.offset<0||e.offset+n>e.view.byteLength)throw new RangeError("Offset is outside the bounds of the DataView")}function Zc(e,n,t){if(!(n>0))return"";qc(e,n*2);let i=e.view,o=e.offset,r="";if(n<=as){for(let a=0;a<n;a++,o+=2)r+=String.fromCharCode(i.getUint16(o,t));return e.offset=o,r.charCodeAt(r.length-1)===0&&(r=r.substring(0,r.length-1)),r}let s=new Uint16Array(Math.min(n,pi));for(let a=0;a<n;a+=pi){let l=Math.min(pi,n-a);for(let c=0;c<l;c++,o+=2)s[c]=i.getUint16(o,t);r+=String.fromCharCode.apply(null,l===s.length?s:s.subarray(0,l))}return e.offset=o,r.charCodeAt(r.length-1)===0&&(r=r.substring(0,r.length-1)),r}function Kc(e){let n="";for(let t=0;t<e.length;t+=pi)n+=String.fromCharCode.apply(null,e.subarray(t,t+pi));return n}function Yc(e,n){return Zc(e,n,!1)}function Kh(e,n){return Zc(e,n,!0)}function Yh(e,n){if(!(n>0))return"";if(qc(e,n),n<=as){let i=e.view,o="";for(let r=0,s=e.offset;r<n;r++,s++)o+=String.fromCharCode(i.getUint8(s));return e.offset+=n,o}let t=Kc(new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,n));return e.offset+=n,t}function _e(e,n){e.offset+=n}function ls(e,n,t){let i=e.offset,o=yi(e);if(o!==n&&o!==t)throw new Error(`Invalid signature: '${o}' at 0x${i.toString(16)}`)}function Jc(e,n){let t=xt(e,n);if(n>as)return Kc(t);let i="";for(let o=0;o<t.length;o++)i+=String.fromCharCode(t[o]);return i}function Jh(e){return e==="8BIM"||e==="MeSa"||e==="AgHg"||e==="PHUT"||e==="DCSR"}function Qh(e,n={}){var t;ls(e,"8BPS");let i=de(e);if(i!==1&&i!==2)throw new Error(`Invalid PSD file version: ${i}`);_e(e,6);let o=de(e),r=we(e),s=we(e),a=de(e),l=de(e),c=i===1?3e4:3e5;if(s>c||r>c)throw new Error(`Invalid size: ${s}x${r}`);if(o<1||o>57)throw new Error(`Invalid channel count: ${o}`);if(![1,8,16,32].includes(a))throw new Error(`Invalid bitsPerChannel: ${a}`);if(N.supportedColorModes.indexOf(l)===-1)throw new Error(`Color mode not supported: ${(t=$h[l])!==null&&t!==void 0?t:l}`);let f={width:s,height:r,channels:o,bitsPerChannel:a,colorMode:l};Object.assign(e,n),e.large=i===2,e.globalAlpha=!1,e.layersInGlobalInfo=!1;let u=e.imageResourcesWhitelist;e.imageResourcesWhitelistSet=u?u instanceof Set?u:new Set(u):void 0,"totalMemoryLimit"in e||(e.totalMemoryLimit=2*1024*1024*1024),at(e,1,S=>{if(S()){if(l===2){if(S()!=768)throw new Error("Invalid color palette size");f.palette=[];for(let A=0;A<256;A++)f.palette.push({r:ve(e),g:0,b:0});for(let A=0;A<256;A++)f.palette[A].g=ve(e);for(let A=0;A<256;A++)f.palette[A].b=ve(e)}_e(e,S())}});let d={},p=0;at(e,1,S=>{for(;S()>=12;){let A=ff(e,Jh),D=de(e),C=ve(e),O=xt(e,C);_e(e,(C+1)%2),at(e,2,E=>{let L=jc.resourceHandlersMap[D];if(L)if(D===1036&&!!e.skipThumbnail||!(0,jc.shouldReadResource)(L,e.imageResourcesWhitelistSet))_e(e,E());else try{L.read(e,d,E,{signature:A,id:D,name:O,width:s,height:r})}catch(J){if(e.throwForMissingFeatures)throw J;_e(e,E())}else e.logMissingFeatures&&e.log(`Unhandled image resource: ${D} (${E()})`),_e(e,E())})}p=S(),_e(e,S())}),p&&!zc(e,e.offset)&&zc(e,e.offset-p)&&(e.offset-=p);let{layersGroup:h,layerGroupsEnabledId:m,savedPathsOrigination:y}=d,g=Rh(d,["layersGroup","layerGroupsEnabledId","savedPathsOrigination"]);Object.keys(g).length&&(f.imageResources=g),at(e,1,S=>{if(at(e,2,A=>{Qc(e,f,d),_e(e,A())},void 0,e.large),S()>0){let A=cf(e);A&&(f.globalLayerMaskInfo=A)}else _e(e,S());for(;S()>0;){for(;S()&&Hc(e)===0;)_e(e,1);S()>=12?cs(e,f,f,d):_e(e,S())}},void 0,e.large);let k=f.children&&f.children.length;if(!(e.skipCompositeImageData&&(e.skipLayerImageData||k)))if(e.useRawData){let S=Math.min(e.offset,e.view.byteLength),A=new Uint8Array(e.view.buffer,e.view.byteOffset+S,e.view.byteLength-S);f.rawCompositeData=A,f.rawCompositeDataInfo={large:e.large,globalAlpha:e.globalAlpha},e.layersInGlobalInfo&&(f.rawCompositeDataInfo.layersInGlobalInfo=!0)}else{let S=df(e,f);e.useImageData?f.imageData=S:f.canvas=(0,Te.imageDataToCanvas)(S)}return f}function Qc(e,n,t){var i,o;let{layersGroup:r=[],layerGroupsEnabledId:s=[]}=t,a=Xt(e);a<0&&(e.globalAlpha=!0,a=-a);let l=[],c=[];for(let u=0;u<a;u++){let{layer:d,channels:p}=eg(e,n,t);r[u]!==void 0&&(d.linkGroup=r[u]),s[u]!==void 0&&(d.linkGroupEnabled=!!s[u]),l.push(d),c.push(p)}for(let u=0;u<a;u++)og(e,n,l[u],c[u]);n.children||(n.children=[]);let f=[n];for(let u=l.length-1;u>=0;u--){let d=l[u],p=d.sectionDivider?d.sectionDivider.type:0;p===1||p===2?(d.opened=p===1,d.children=[],delete d.canvas,delete d.imageData,!((i=d.sectionDivider)===null||i===void 0)&&i.key&&(d.blendMode=(o=Te.toBlendMode[d.sectionDivider.key])!==null&&o!==void 0?o:d.blendMode),f[f.length-1].children.unshift(d),f.push(d)):p===3?f.length>1&&f.pop():f[f.length-1].children.unshift(d)}}function eg(e,n,t){let i={};if(i.top=Re(e),i.left=Re(e),i.bottom=Re(e),i.right=Re(e),!ts(i,e))throw new Error("Invalid layer size");let o=de(e),r=[];for(let l=0;l<o;l++){let c=Xt(e),f=we(e);if(e.large){if(f!==0)throw new Error("Sizes larger than 4GB are not supported");f=we(e)}r.push({id:c,length:f})}ls(e,"8BIM");let s=yi(e);if(!Te.toBlendMode[s]){if(e.throwForMissingFeatures)throw new Error(`Invalid blend mode: '${s}'`);e.logMissingFeatures&&e.log(`Unknown blend mode: '${s}', using normal blend mode`)}i.blendMode=Te.toBlendMode[s]||"normal",i.opacity=ve(e)/255,i.clipping=ve(e)===1;let a=ve(e);return i.transparencyProtected=(a&1)!==0,i.hidden=(a&2)!==0,a&32&&(i.effectsOpen=!0),_e(e,1),at(e,1,l=>{tg(e,i);let c=ig(e);for(c&&(i.blendingRanges=c),i.name=ss(e,1);l()>4&&!Wc(e,e.offset);)e.offset++;for(;l()>=12;)cs(e,i,n,t);_e(e,l())}),{layer:i,channels:r}}function zc(e,n){let t=e.large?8:4;if(n<0||n+t>e.view.byteLength)return!1;let i=e.large?e.view.getUint32(n)*4294967296+e.view.getUint32(n+4):e.view.getUint32(n);return n+t+i<=e.view.byteLength}function ts(e,n){let t=(e.right||0)-(e.left||0),i=(e.bottom||0)-(e.top||0),o=n.large?3e5:3e4;return t<=o&&i<=o}function tg(e,n){return at(e,1,t=>{if(!t())return;let i={};if(n.mask=i,i.top=Re(e),i.left=Re(e),i.bottom=Re(e),i.right=Re(e),!ts(i,e))throw new Error("Invalid mask size");i.defaultColor=ve(e);let o=ve(e);if(i.positionRelativeToLayer=(o&1)!==0,i.disabled=(o&2)!==0,i.fromVectorData=(o&8)!==0,ng(e,o,t())){let r={};n.realMask=r;let s=ve(e);if(r.positionRelativeToLayer=(s&1)!==0,r.disabled=(s&2)!==0,r.fromVectorData=(s&8)!==0,r.defaultColor=ve(e),r.top=Re(e),r.left=Re(e),r.bottom=Re(e),r.right=Re(e),!ts(r,e))throw new Error("Invalid realMask size")}if(o&16){let r=ve(e);r&1&&(i.userMaskDensity=ve(e)/255),r&2&&(i.userMaskFeather=es(e)),r&4&&(i.vectorMaskDensity=ve(e)/255),r&8&&(i.vectorMaskFeather=es(e))}_e(e,t())})}function ef(e){return 1+(e&1?1:0)+(e&2?8:0)+(e&4?1:0)+(e&8?8:0)}function $c(e,n,t){if(t<1)return!1;let i=e.getUint8(n);if(i===0||i&-16)return!1;let o=ef(i);if(t<o||t-o>3)return!1;for(let r=o;r<t;r++)if(e.getUint8(n+r)!==0)return!1;return!0}function ng(e,n,t){if(t<18)return!1;if(!(n&16))return!0;let{view:i,offset:o}=e;return $c(i,o,t)?!1:$c(i,o+18,t-18)?!0:t===18||t-18>=ef(i.getUint8(o+18))}function ho(e){return[ve(e),ve(e),ve(e),ve(e)]}function ig(e){return at(e,1,n=>{let t=ho(e),i=ho(e),o=[];for(;n()>0;){let r=ho(e),s=ho(e);o.push({sourceRange:r,destRange:s})}return{compositeGrayBlendSource:t,compositeGraphBlendDestinationRange:i,ranges:o}})}function og(e,n,t,i){if(e.skipLayerImageData)return;let{colorMode:o=3,bitsPerChannel:r=8}=n;t.rawData={colorMode:o,bitsPerChannel:r,channels:[],large:e.large};for(let s of i){let a=e.offset,l=0,c;if(s.length>=2){if(l=de(e),l>3&&(e.offset-=1,l=de(e)),l>3&&(e.offset-=4,l=de(e)),l>3)throw new Error(`Invalid compression: ${l}`);s.length>2&&(c=xt(e,s.length-2))}e.offset=a+s.length,t.rawData.channels.push({id:s.id,compression:l,data:c})}if(!e.useRawData)try{lf(t,e)}catch(s){if(e.throwForMissingFeatures||s.message==="Exceeded memory limit")throw s;e.logMissingFeatures&&e.log(`Failed to decode layer image data: ${s.message}`),delete t.rawData}}function gi({data:e},n){let t=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255,i=(n?4:3)|0,o=e.length|0,r=(n?5:4)|0;for(let s=i;s<o;s=s+r|0)e[s]=t}function tf(e){let n=e.rawCompositeData;if(!n)return;let t=mi(n.buffer,n.byteOffset,n.byteLength),i=e.rawCompositeDataInfo;return i&&(t.large=i.large,t.globalAlpha=i.globalAlpha,t.layersInGlobalInfo=!!i.layersInGlobalInfo),df(t,e)}function rg(e){return Un(tf(e))}function nf(e){return Ln(e,qe.Layer,!1,void 0)}function of(e){return Ln(e,qe.Mask,!1,void 0)}function rf(e){return Ln(e,qe.RealMask,!1,void 0)}function sg(e){return Un(nf(e))}function ag(e){return Un(of(e))}function lg(e){return Un(rf(e))}function sf(e){let{depth:n,channels:t,colorMode:i=3}=e,o=Math.max(0,e.right-e.left),r=Math.max(0,e.bottom-e.top);if(!o||!r)return;let s=i===4;if(s&&n!==8&&n!==16)throw new Error("bitsPerChannel not supported");let a=s?5:4,l=t.length-1,c=Math.min(s?4:i===1?1:3,t.length-2),f=Ft(o,r,n,a,void 0);for(let u=0;u<t.length;u++){let d=t[u];d&&(u<c?ns(d,f,o,r,n,u,a):u===l&&ns(d,f,o,r,n,a-1,a))}if(i===1&&hi(f),t[l]||gi(f,s),s){let u=f;f=Ft(u.width,u.height,n,4,void 0),mo(u,f,!1)}return f}function af(e){let{extra:n,depth:t}=e;if(!n)return;let i=Math.max(0,n.right-n.left),o=Math.max(0,n.bottom-n.top);if(!i||!o)return;let r=Ft(i,o,t,4,void 0);return ns(n,r,i,o,t,0,4),hi(r),gi(r,!1),r}function cg(e){return Un(sf(e))}function fg(e){return Un(af(e))}function ns({compressionMode:e,data:n},t,i,o,r,s,a){let l=mi(n.buffer,n.byteOffset,n.byteLength);is(l,n.byteLength,t,e,i,o,r,s,!0,a)}function Un(e){return e&&(0,Te.imageDataToCanvas)(e)}function Zr(e,n,t){n&&(t?e.imageData=n:e.canvas=(0,Te.imageDataToCanvas)(n))}function dg(e,n){lf(e,{useImageData:n})}function lf(e,n){var t,i,o;let{throwForMissingFeatures:r,useImageData:s}=n,a=Ln(e,qe.Layer,r,n.totalMemoryLimit,n);if(Zr(e,a,s),n.totalMemoryLimit!==void 0&&(n.totalMemoryLimit-=(t=a?.data.byteLength)!==null&&t!==void 0?t:0),e.mask){let l=Ln(e,qe.Mask,r,n.totalMemoryLimit,n);Zr(e.mask,l,s),n.totalMemoryLimit!==void 0&&(n.totalMemoryLimit-=(i=l?.data.byteLength)!==null&&i!==void 0?i:0)}if(e.realMask){let l=Ln(e,qe.RealMask,r,n.totalMemoryLimit,n);Zr(e.realMask,l,s),n.totalMemoryLimit!==void 0&&(n.totalMemoryLimit-=(o=l?.data.byteLength)!==null&&o!==void 0?o:0)}delete e.rawData}var qe;(function(e){e[e.Layer=0]="Layer",e[e.Mask=1]="Mask",e[e.RealMask=2]="RealMask"})(qe||(qe={}));function Ln(e,n,t,i,o){var r;if(!e.rawData)return;let{colorMode:s,bitsPerChannel:a,channels:l,large:c}=e.rawData,f=Math.max(0,(e.right||0)-(e.left||0)),u=Math.max(0,(e.bottom||0)-(e.top||0)),d=s===4,p,h,m=!1;if(f&&u&&n===qe.Layer)if(d){if(a!==8&&a!==16)throw new Error("bitsPerChannel not supported");p=Ft(f,u,a,5,i)}else p=Ft(f,u,a,4,i);for(let{id:y,compression:g,data:k}of l){if(!k)continue;let x=mi(k.buffer,k.byteOffset,k.byteLength);if(x.debug=!!o?.debug,o?.log&&(x.log=o.log),i!==void 0&&(x.totalMemoryLimit=Math.max(0,i-((r=p?.data.byteLength)!==null&&r!==void 0?r:0))),y===-2||y===-3){if(y===-2&&n!==qe.Mask||y===-3&&n!==qe.RealMask)continue;let S=y===-2?e.mask:e.realMask;if(!S)throw new Error(`Missing layer ${y===-2?"mask":"real mask"} data`);let A=Math.max(0,(S.right||0)-(S.left||0)),D=Math.max(0,(S.bottom||0)-(S.top||0));A&&D&&(h=Ft(A,D,a,4,i),i!==void 0&&(x.totalMemoryLimit=Math.max(0,x.totalMemoryLimit-h.data.byteLength)),is(x,k.byteLength,h,g,A,D,a,0,c,4),hi(h),gi(h,!1))}else{if(n!==qe.Layer)continue;let S=(0,Te.offsetForChannel)(y,d),A=p;if(S<0&&(A=void 0,t))throw new Error(`Channel not supported: ${y}`);is(x,k.byteLength,A,g,f,u,a,S,c,d?5:4)}y===-1&&(m=!0)}if(p&&(s===1&&hi(p),m||gi(p,d),d)){let y=p,g=i===void 0?void 0:Math.max(0,i-y.data.byteLength);p=Ft(y.width,y.height,a,4,g),mo(y,p,!1)}return n===qe.Layer?p:h}function is(e,n,t,i,o,r,s,a,l,c){if(n)if(i===0){n!==o*r*Math.floor(s/8)&&qt(e,`Invalid length (${n}, ${o*r*Math.floor(s/8)})`);let f=xt(e,n);uf(f,t,s,c,a)}else if(i===1)bi(e,t,o,r,s,c,[a],l);else if(i===2){let f=xt(e,n);os(f,t,o,r,s,c,a,!1,e)}else if(i===3){let f=xt(e,n);os(f,t,o,r,s,c,a,!0,e)}else throw new Error(`Invalid Compression type: ${i}`)}function cf(e){return at(e,1,n=>{if(!n())return;let t=de(e),i=de(e),o=de(e),r=de(e),s=de(e),a=Math.min(de(e),100)/100,l=ve(e);return _e(e,n()),{overlayColorSpace:t,colorSpace1:i,colorSpace2:o,colorSpace3:r,colorSpace4:s,opacity:a,kind:l}})}var ug=[0,1,-1,2,-2,3,-3,4,-4];function ff(e,n){let t=e.offset,i="";for(let o of ug){try{e.offset=t+o,i=yi(e)}catch{}if(n(i))break}if(!n(i))throw new Error(`Invalid signature: '${i}' at 0x${t.toString(16)}`);return i}function pg(e){return e==="8BIM"||e==="8B64"}function cs(e,n,t,i){let o=ff(e,pg),r=yi(e),s=o==="8B64"||e.large&&Te.largeAdditionalInfoKeys.indexOf(r)!==-1;if(e.large&&o==="8BIM"&&Te.largeAdditionalInfoKeysObserved.indexOf(r)!==-1){let a=e.offset+8<=e.view.byteLength?e.view.getUint32(e.offset+4):0,l=a===943868237||a===943863348;s=e.view.getUint32(e.offset)===0&&!l}at(e,2,a=>{let l=jh.infoHandlersMap[r];l?l.read(e,n,a,t,i):(e.logMissingFeatures&&r!=="GenI"&&r!=="OCIO"&&r!=="CAI "&&e.log(`Unhandled additional info: ${r}`),_e(e,a())),a()&&(e.logMissingFeatures&&e.log(`Unread ${a()} bytes left for additional info: ${r}`),_e(e,a()))},!1,s)}function Ft(e,n,t,i,o){let r=e*n*i*Math.max(1,t/8);if(o!==void 0&&r>o)throw new Error("Exceeded memory limit");if(t===1||t===8)return i===4?(0,Te.createImageData)(e,n):{width:e,height:n,data:new Uint8ClampedArray(e*n*i)};if(t===16)return{width:e,height:n,data:new Uint16Array(e*n*i)};if(t===32)return{width:e,height:n,data:new Float32Array(e*n*i)};throw new Error(`Invalid bitDepth (${t})`)}function df(e,n){var t,i,o;let r=de(e),s=(t=n.bitsPerChannel)!==null&&t!==void 0?t:8,{width:a,height:l}=n;if(N.supportedColorModes.indexOf(n.colorMode)===-1)throw new Error(`Color mode not supported: ${n.colorMode}`);if(r!==0&&r!==1)throw new Error(`Compression type not supported: ${r}`);let c=Ft(a,l,s,4,e.totalMemoryLimit);switch(e.totalMemoryLimit!==void 0&&(e.totalMemoryLimit-=c.data.byteLength),(0,Te.resetImageData)(c),n.colorMode){case 0:{if(s!==1)throw new Error("Invalid bitsPerChannel for bitmap color mode");let f=Math.ceil(a/8),u;r===0?u=xt(e,f*l):(u=new Uint8Array(f*l),bi(e,{data:u,width:f,height:l},f,l,8,1,[0],e.large)),(0,Te.decodeBitmap)(u,c.data,a,l);break}case 3:case 1:{let f=n.colorMode===1?1:3,u=Kr(e,n,f,3);Yr(e,r,c,s,4,u),n.colorMode===1&&hi(c);break}case 2:{if(s!==8)throw new Error("bitsPerChannel not supported");if(!n.palette)throw new Error("Missing color palette");let f=Kr(e,n,1,-1),u={width:a,height:l,data:new Uint8Array(a*l)};Yr(e,r,u,8,1,f),gg(u,c,n.palette,(o=(i=n.imageResources)===null||i===void 0?void 0:i.transparencyIndex)!==null&&o!==void 0?o:-1);break}case 4:{if(s!==8&&s!==16)throw new Error("bitsPerChannel not supported");let f=Kr(e,n,4,4),u=Ft(a,l,s,5,e.totalMemoryLimit);gi(u,!0),Yr(e,r,u,s,5,f),mo(u,c,!!e.globalAlpha);break}default:throw new Error(`Color mode not supported: ${n.colorMode}`)}return e.globalAlpha&&n.colorMode!==4&&hg(c),c}function Kr(e,n,t,i){var o,r,s;let a=(o=n.channels)!==null&&o!==void 0?o:t+(e.globalAlpha?1:0);if(a<t)throw new Error(`Invalid channel count: ${a}`);let l=(s=(r=n.imageResources)===null||r===void 0?void 0:r.alphaChannelNames)!==null&&s!==void 0?s:[],c=l.length,f=!!e.layersInGlobalInfo&&l[0]==="Transparency"&&c===a-t,u=e.globalAlpha||f||a-t>c,d=[];for(let p=0;p<a;p++)p<t?d.push(p):p===t&&u&&i>=0?d.push(i):d.push(-1);return d}function Yr(e,n,t,i,o,r){if(n===0){let s=t.width*t.height*yo(i);for(let a of r)a<0?_e(e,s):uf(xt(e,s),t,i,o,a)}else if(n===1)bi(e,t,t.width,t.height,i,o,r,e.large);else throw new Error(`Compression not supported: ${n}`)}function hg({data:e,width:n,height:t}){let i=n*t*4;if(e instanceof Float32Array)for(let o=0;o<i;o+=4){let r=e[o+3];if(r>0&&r<1){let s=1/r,a=1-s;for(let l=0;l<3;l++){let c=e[o+l]*s+a;e[o+l]=c<0?0:c}}}else if(e instanceof Uint16Array)for(let o=0;o<i;o+=4){let r=e[o+3];if(r!==0&&r!==65535){let s=65535/r,a=65535*(1-s);for(let l=0;l<3;l++){let c=Math.round(e[o+l]*s+a);e[o+l]=c<0?0:c>65535?65535:c}}}else for(let o=0;o<i;o+=4){let r=e[o+3];if(r!=0&&r!=255){let a=1/(r/255),l=255*(1-a);e[o+0]=e[o+0]*a+l,e[o+1]=e[o+1]*a+l,e[o+2]=e[o+2]*a+l}}}function Jr(e,n){return e=Math.round(e*(n/255)),e<=0?0:e>=n?n:e}function mo(e,n,t){let i=n.width*n.height*4,o=e.data,r=n.data,s=o instanceof Uint16Array?65535:255,a=r instanceof Uint16Array?65535:255,l=[0,0,0];for(let c=0,f=0;f<i;c+=5,f+=4){let u=o[c+4],d=1-o[c]/s,p=1-o[c+1]/s,h=1-o[c+2]/s,m=1-o[c+3]/s;if(t&&u>0&&u<s){let y=s/u;d=Math.min(1,d*y),p=Math.min(1,p*y),h=Math.min(1,h*y),m=Math.min(1,m*y)}(0,Te.cmykToRgbValues)(d,p,h,m,l),r[f]=Jr(l[0],a),r[f+1]=Jr(l[1],a),r[f+2]=Jr(l[2],a),r[f+3]=s===a?u:Math.round(u*a/s)}}function gg(e,n,t,i){let o=e.width*e.height,r=e.data,s=n.data;for(let a=0,l=0;a<o;a++,l+=4){let c=r[a],f=t[c];s[l+0]=f.r,s[l+1]=f.g,s[l+2]=f.b,s[l+3]=c===i?0:255}}function yo(e){switch(e){case 1:case 8:return 1;case 16:return 2;case 32:return 4;default:throw new Error(`Invalid bitDepth (${e})`)}}function fs(e,n){if(e.BYTES_PER_ELEMENT!==n)throw new Error("Invalid array types")}function uf(e,n,t,i,o){let r=yo(t);if(!n||o<0||o>=i)return;let s=n.data;fs(s,r);let a=Math.min(n.width*n.height,Math.floor(e.byteLength/r))|0;if(r===1)for(let l=0,c=o|0;l<a;l++,c=c+i|0)s[c]=e[l];else if(r===2)for(let l=0,c=0,f=o|0;l<a;l++,c+=2,f=f+i|0)s[f]=e[c]<<8|e[c+1];else{let l=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let c=0,f=0,u=o|0;c<a;c++,f+=4,u=u+i|0)s[u]=l.getFloat32(f,!1)}}function mg(e,n,t){for(let i=0;i<t;i++){let o=i*n;for(let r=1,s=o+1;r<n;r++,s++)e[s]=e[s-1]+e[s]}}var Qr=new Error("Decompressed data exceeds expected size");function pf(e,n,t,i=!1){let o=new Uint8Array(n),r=0,s=!1,a=new Th.Inflate({chunkSize:Math.max(1024,Math.min(n,65536)),raw:i});a.onData=l=>{let c=l,f=Math.min(c.length,n-r);if(f>0&&o.set(f===c.length?c:c.subarray(0,f),r),r+=f,f<c.length)throw s=!0,Qr},a.onEnd=l=>{var c;a.err=l,a.msg=((c=a.strm)===null||c===void 0?void 0:c.msg)||""};try{a.push(e,!0)}catch(l){if(l!==Qr)throw l}if(s)t&&qt(t,Qr.message);else{if(a.err&&a.msg==="incorrect data check"&&!i)return t&&qt(t,`Invalid zip data: ${a.msg}`),pf(e.subarray(2),n,t,!0);if(a.err)throw new Error(`Invalid zip data: ${a.msg}`)}return o}function os(e,n,t,i,o,r,s,a,l){let c=yo(o);if(!n||s<0||s>=r)return;let f=n.data;fs(f,c);let u=t*i*c;l&&Mn(l,u);try{let d=pf(e,u,l);if(c===1)for(let p=0,h=0;p<i;p++){let m=0;for(let y=0,g=s+p*t*r;y<t;y++,h++,g+=r){let k=d[h];a&&(k=m=m+k&255),f[g]=k}}else if(c===2)for(let p=0,h=0;p<i;p++){let m=0;for(let y=0,g=s+p*t*r;y<t;y++,h+=2,g+=r){let k=d[h]<<8|d[h+1];a&&(k=m=m+k&65535),f[g]=k}}else{let p=new Uint32Array(f.buffer,f.byteOffset,f.length);if(a){mg(d,t*4,i);for(let h=0,m=s;h<i;h++){let y=t*4*h;for(let g=0;g<t;g++,y++,m+=r){let k=y+t,x=k+t,S=x+t;p[m]=(d[y]<<24|d[k]<<16|d[x]<<8|d[S])>>>0}}}else{let h=new DataView(d.buffer,d.byteOffset,d.byteLength);for(let m=0,y=0,g=s,k=t*i;m<k;m++,y+=4,g+=r)p[g]=h.getUint32(y,!1)}}}finally{l&&go(l,u)}}function yg(e,n,t,i,o){let r=0;for(;n<t&&r<o;){let s=e[n++];if(s>128){if(n>=t)break;let a=e[n++],l=257-s;l>o-r&&(l=o-r),i.fill(a,r,r+l),r+=l}else if(s<128){let a=s+1;for(a>o-r&&(a=o-r),a>t-n&&(a=t-n);a>0;a--)i[r++]=e[n++]}}return r}function bg(e,n,t,i,o,r,s,a,l){let c=e.length|0;for(let f=0;f<r;f++,t++){let u=(i<c?i:c)|0;i+=n[t];let d=(i<c?i:c)|0,p=a+f*o*l|0,h=0;for(;u<d&&h<o;){let m=e[u++]|0;if(m>128){if(u>=d)break;let y=e[u++]|0,g=257-m|0;g>o-h&&(g=o-h|0),h=h+g|0;for(let k=p+g*l|0;p<k;p=p+l|0)s[p]=y}else if(m<128){let y=m+1|0;y>o-h&&(y=o-h|0),y>d-u&&(y=d-u|0),h=h+y|0;for(let g=u+y|0;u<g;u=u+1|0,p=p+l|0)s[p]=e[u]}}}}function wg(e,n,t,i,o,r){if(t===2)for(let s=0,a=0;s<n;s++,a+=2,o+=r)i[o]=e[a]<<8|e[a+1];else{let s=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let a=0,l=0;a<n;a++,l+=4,o+=r)i[o]=s.getFloat32(l,!1)}}function vg(e,n,t,i,o,r,s,a,l,c,f){let u=e.length,d=o*c;for(let p=0;p<r;p++,t++){let h=i<u?i:u;i+=n[t];let m=i<u?i:u;if(h>=m)continue;let y=yg(e,h,m,f,d);wg(f,Math.floor(y/c),c,s,a+p*o*l,l)}}function bi(e,n,t,i,o,r,s,a){let l=n&&n.data,c=s.length*i,u=c*(a?4:2),d=e.view.byteLength,p=yo(o),h;Mn(e,u);try{if(e.offset+u>d)throw new Error("RLE row lengths exceed buffer length");h=a?new Uint32Array(c):new Uint16Array(c);let k=0;if(a)for(let x=0;x<c;x++)k+=h[x]=we(e);else for(let x=0;x<c;x++)k+=h[x]=de(e);k>d-e.offset&&qt(e,"RLE data exceeds buffer length"),l&&fs(l,p)}catch(k){throw go(e,u),k}let m=new Uint8Array(e.view.buffer,e.view.byteOffset,d),y=l&&p>1?new Uint8Array(t*p):void 0,g=e.offset;for(let k=0,x=0;k<s.length;k++,x+=i){let S=s[k]|0,A=g;for(let D=0;D<i;D++)g+=h[x+D];l&&S>=0&&S<r&&(p===1?bg(m,h,x,A,t,i,l,S,r):vg(m,h,x,A,t,i,l,S,r,p,y))}e.offset=g,go(e,u)}function at(e,n,t,i=!0,o=!1){let r=we(e);if(o){if(r!==0)throw new Error("Sizes larger than 4GB are not supported");r=we(e)}if(r<=0&&i)return;let s=e.offset+r;if(s>e.view.byteLength)throw new Error("Section exceeds file size");let a=t(()=>s-e.offset);for(e.offset!==s&&(e.offset>s?qt(e,"Exceeded section limits"):qt(e,"Unread section data"));r%n;)r++,s++;return e.offset=s,a}function Sg(e){switch(de(e)){case 0:{let t=de(e)/257,i=de(e)/257,o=de(e)/257;return _e(e,2),{r:t,g:i,b:o}}case 1:{let t=de(e)/65535,i=de(e)/65535,o=de(e)/65535;return _e(e,2),{h:t,s:i,b:o}}case 2:{let t=(65535-de(e))/257,i=(65535-de(e))/257,o=(65535-de(e))/257,r=(65535-de(e))/257;return{c:t,m:i,y:o,k:r}}case 7:{let t=Xt(e)/1e4,i=Xt(e),o=Xt(e),r=(0,Te.normalizeLabAB)(i,100),s=(0,Te.normalizeLabAB)(o,100);return _e(e,2),{l:t,a:r,b:s}}case 8:{let t=de(e)*255/1e4;return _e(e,6),{k:t}}default:throw new Error("Invalid color space")}}var Vc=3e4;function xg(e){let n=e.view.getUint32(e.offset);for(;n%4;)n++;let t=e.offset+4+n;try{return hf(e)}catch(i){if(e.throwForMissingFeatures)throw i;e.logMissingFeatures&&e.log(`Skipped pattern: ${i.message}`),e.offset=t;return}}function hf(e){let n=we(e);for(;n%4;)n++;let t=e.offset+n,i=we(e);if(i!==1)throw new Error(`Invalid pattern version: ${i}`);let o=we(e),r=Xt(e),s=Xt(e);if(o!==3&&o!==1&&o!==2&&o!==4)throw new Error(`Unsupported pattern color mode: ${o}`);let a=Xc(e),l=ss(e,1),c=[];if(o===2){for(let M=0;M<256;M++)c.push({r:ve(e),g:ve(e),b:ve(e)});e.view.getUint32(e.offset)!==3&&_e(e,4)}let f=we(e);if(f!==3)throw new Error(`Invalid pattern VMAL version: ${f}`);we(e);let u=we(e),d=we(e),p=we(e),h=we(e),m=we(e),y=h-d,g=p-u;if(y<0||g<0)throw new Error("Invalid pattern bounds");if(y>Vc||g>Vc)throw new Error(`Pattern too large (${y}x${g})`);if(m>64)throw new Error(`Invalid pattern channel count: ${m}`);if(y*g>(Math.min(t,e.view.byteLength)-e.offset)*64)throw new Error("Pattern data out of bounds");let k=o===3?3:o===4?4:1,x=o===4,S=x?4:3,A=[],D=0;for(let M=0,J=0;M<m+2&&e.offset+4<=t;M++){if(!we(e))continue;let R=we(e);if(!R)continue;if(R<23)throw new Error("Invalid pattern channel length");let ie=we(e),he=we(e),ce=we(e),Ce=we(e),W=we(e),B=de(e),$=ve(e),ne=xt(e,R-23),ge=B===8||B===16||B===32?B:ie;if(ge!==8&&ge!==16&&ge!==32)throw new Error(`Unsupported pattern pixel depth: ${ge}`);if(he<u||ce<d||Ce>p||W>h||Ce<he||W<ce)throw new Error("Pattern channel bounds outside of pattern bounds");let Q=J<k?J:J===k?S:-1;if(J++,Q===-1)continue;let ee=W-ce,be=Ce-he,Se=ee*(ge/8),xe=Se*be;if($===0){if(ne.byteLength<xe)throw new Error("Pattern channel data out of bounds")}else if($===1){if(xe>ne.byteLength*64)throw new Error("Pattern channel data out of bounds");D=Math.max(D,xe)}else throw new Error("Invalid pattern compression mode");A.push({target:Q,depth:ge,compressionMode:$,cdata:ne,ctop:he,cleft:ce,w:ee,h:be,rowBytes:Se,channelSize:xe})}let C=y*g*4,O=x?y*g*5:0;Mn(e,C+O+D),go(e,C+O+D);let E=new Uint8Array(C);for(let M=3;M<E.byteLength;M+=4)E[M]=255;let L=x?new Uint8Array(O).fill(255):void 0;for(let{target:M,depth:J,compressionMode:pe,cdata:R,ctop:ie,cleft:he,w:ce,h:Ce,rowBytes:W,channelSize:B}of A){let $=R;if(pe===1){$=new Uint8Array(B);let Q=mi(R.buffer,R.byteOffset,R.byteLength);bi(Q,{data:$,width:W,height:Ce},W,Ce,8,1,[0],!1)}J!==8&&($=kg($,ce*Ce,J));let ne=he-d,ge=ie-u;if(L)Nc($,L,ce,Ce,(ne+ge*y)*5+M,y*5,5);else if(M===3||o===3)Nc($,E,ce,Ce,(ne+ge*y)*4+M,y*4,4);else if(o===2){let Q=new Uint8Array(768);for(let ee=0;ee<256;ee++)Q[ee*3+0]=c[ee].r,Q[ee*3+1]=c[ee].g,Q[ee*3+2]=c[ee].b;for(let ee=0;ee<Ce;ee++)for(let be=0,Se=ee*ce,xe=(ne+(ee+ge)*y)*4;be<ce;be++,Se++,xe+=4){let jt=$[Se]*3;E[xe+0]=Q[jt+0],E[xe+1]=Q[jt+1],E[xe+2]=Q[jt+2]}}else for(let Q=0;Q<Ce;Q++)for(let ee=0,be=Q*ce,Se=(ne+(Q+ge)*y)*4;ee<ce;ee++,be++,Se+=4){let xe=$[be];E[Se+0]=xe,E[Se+1]=xe,E[Se+2]=xe}}return L&&mo({width:y,height:g,data:L},{width:y,height:g,data:E},!1),Mn(e,C),e.offset=t,{id:l,name:a,x:r,y:s,bounds:{x:d,y:u,w:y,h:g},data:E}}function kg(e,n,t){let i=new Uint8Array(n);if(t===16)for(let o=0;o<n;o++)i[o]=Math.round((e[o*2]<<8|e[o*2+1])/257);else{let o=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let r=0;r<n;r++){let s=o.getFloat32(r*4,!1);i[r]=s>0?s<1?Math.round(s*255):255:0}}return i}function Nc(e,n,t,i,o,r,s){for(let a=0,l=0;a<i;a++)for(let c=0,f=o+a*r;c<t;c++,l++,f+=s)n[f]=e[l]}function Mn(e,n){if(!(n>=0))throw new Error("Invalid size");if(e.totalMemoryLimit!==void 0){if(e.totalMemoryLimit<n)throw new Error("Exceeded memory limit");e.totalMemoryLimit-=n}}function go(e,n){e.totalMemoryLimit!==void 0&&(e.totalMemoryLimit+=n)}});var yf=ae(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});bo.readEffects=_g;bo.writeEffects=Ag;var mf=Ot(),H=st(),T=En(),ds=[void 0,"outer bevel","inner bevel","emboss","pillow emboss","stroke emboss"];function Bn(e){return(0,H.checkSignature)(e,"8BIM"),mf.toBlendMode[(0,H.readSignature)(e)]||"normal"}function Tn(e,n){(0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,mf.fromBlendMode[n]||"norm")}function Rn(e){return(0,H.readUint8)(e)/255}function jn(e,n){(0,T.writeUint8)(e,Math.round(n*255)|0)}function _g(e){let n=(0,H.readUint16)(e);if(n!==0)throw new Error(`Invalid effects layer version: ${n}`);let t=(0,H.readUint16)(e),i={};for(let o=0;o<t;o++){(0,H.checkSignature)(e,"8BIM");let r=(0,H.readSignature)(e);switch(r){case"cmnS":{let s=(0,H.readUint32)(e),a=(0,H.readUint32)(e);if((0,H.readUint8)(e),(0,H.skipBytes)(e,2),s!==7||a!==0)throw new Error("Invalid effects common state");break}case"dsdw":case"isdw":{let s=(0,H.readUint32)(e),a=(0,H.readUint32)(e);if(s!==41&&s!==51)throw new Error(`Invalid shadow size: ${s}`);if(a!==0&&a!==2)throw new Error(`Invalid shadow version: ${a}`);let l=(0,H.readFixedPoint32)(e);(0,H.readFixedPoint32)(e);let c=(0,H.readFixedPoint32)(e),f=(0,H.readFixedPoint32)(e),u=(0,H.readColor)(e),d=Bn(e),p=!!(0,H.readUint8)(e),h=!!(0,H.readUint8)(e),m=Rn(e);s>=51&&(0,H.readColor)(e);let y={size:{units:"Pixels",value:l},distance:{units:"Pixels",value:f},angle:c,color:u,blendMode:d,enabled:p,useGlobalLight:h,opacity:m};r==="dsdw"?i.dropShadow=[y]:i.innerShadow=[y];break}case"oglw":{let s=(0,H.readUint32)(e),a=(0,H.readUint32)(e);if(s!==32&&s!==42)throw new Error(`Invalid outer glow size: ${s}`);if(a!==0&&a!==2)throw new Error(`Invalid outer glow version: ${a}`);let l=(0,H.readFixedPoint32)(e);(0,H.readFixedPoint32)(e);let c=(0,H.readColor)(e),f=Bn(e),u=!!(0,H.readUint8)(e),d=Rn(e);s>=42&&(0,H.readColor)(e),i.outerGlow={size:{units:"Pixels",value:l},color:c,blendMode:f,enabled:u,opacity:d};break}case"iglw":{let s=(0,H.readUint32)(e),a=(0,H.readUint32)(e);if(s!==32&&s!==43)throw new Error(`Invalid inner glow size: ${s}`);if(a!==0&&a!==2)throw new Error(`Invalid inner glow version: ${a}`);let l=(0,H.readFixedPoint32)(e);(0,H.readFixedPoint32)(e);let c=(0,H.readColor)(e),f=Bn(e),u=!!(0,H.readUint8)(e),d=Rn(e);s>=43&&((0,H.readUint8)(e),(0,H.readColor)(e)),i.innerGlow={size:{units:"Pixels",value:l},color:c,blendMode:f,enabled:u,opacity:d};break}case"bevl":{let s=(0,H.readUint32)(e),a=(0,H.readUint32)(e);if(s!==58&&s!==78)throw new Error(`Invalid bevel size: ${s}`);if(a!==0&&a!==2)throw new Error(`Invalid bevel version: ${a}`);let l=(0,H.readFixedPoint32)(e),c=(0,H.readFixedPoint32)(e),f=(0,H.readFixedPoint32)(e),u=Bn(e),d=Bn(e),p=(0,H.readColor)(e),h=(0,H.readColor)(e),m=ds[(0,H.readUint8)(e)]||"inner bevel",y=Rn(e),g=Rn(e),k=!!(0,H.readUint8)(e),x=!!(0,H.readUint8)(e),S=(0,H.readUint8)(e)?"down":"up";s>=78&&((0,H.readColor)(e),(0,H.readColor)(e)),i.bevel={size:{units:"Pixels",value:f},angle:l,strength:c,highlightBlendMode:u,shadowBlendMode:d,highlightColor:p,shadowColor:h,style:m,highlightOpacity:y,shadowOpacity:g,enabled:k,useGlobalLight:x,direction:S};break}case"sofi":{let s=(0,H.readUint32)(e),a=(0,H.readUint32)(e);if(s!==34)throw new Error(`Invalid effects solid fill info size: ${s}`);if(a!==2)throw new Error(`Invalid effects solid fill info version: ${a}`);let l=Bn(e),c=(0,H.readColor)(e),f=Rn(e),u=!!(0,H.readUint8)(e);(0,H.readColor)(e),i.solidFill=[{blendMode:l,color:c,opacity:f,enabled:u}];break}default:throw new Error(`Invalid effect type: '${r}'`)}}return i}function gf(e,n){var t;(0,T.writeUint32)(e,51),(0,T.writeUint32)(e,2),(0,T.writeFixedPoint32)(e,n.size&&n.size.value||0),(0,T.writeFixedPoint32)(e,0),(0,T.writeFixedPoint32)(e,n.angle||0),(0,T.writeFixedPoint32)(e,n.distance&&n.distance.value||0),(0,T.writeColor)(e,n.color),Tn(e,n.blendMode),(0,T.writeUint8)(e,n.enabled?1:0),(0,T.writeUint8)(e,n.useGlobalLight?1:0),jn(e,(t=n.opacity)!==null&&t!==void 0?t:1),(0,T.writeColor)(e,n.color)}function Ag(e,n){var t,i,o,r,s,a,l,c,f,u,d;let p=(t=n.dropShadow)===null||t===void 0?void 0:t[0],h=(i=n.innerShadow)===null||i===void 0?void 0:i[0],m=n.outerGlow,y=n.innerGlow,g=n.bevel,k=(o=n.solidFill)===null||o===void 0?void 0:o[0],x=1;if(p&&x++,h&&x++,m&&x++,y&&x++,g&&x++,k&&x++,(0,T.writeUint16)(e,0),(0,T.writeUint16)(e,x),(0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"cmnS"),(0,T.writeUint32)(e,7),(0,T.writeUint32)(e,0),(0,T.writeUint8)(e,1),(0,T.writeZeros)(e,2),p&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"dsdw"),gf(e,p)),h&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"isdw"),gf(e,h)),m&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"oglw"),(0,T.writeUint32)(e,42),(0,T.writeUint32)(e,2),(0,T.writeFixedPoint32)(e,((r=m.size)===null||r===void 0?void 0:r.value)||0),(0,T.writeFixedPoint32)(e,0),(0,T.writeColor)(e,m.color),Tn(e,m.blendMode),(0,T.writeUint8)(e,m.enabled?1:0),jn(e,(s=m.opacity)!==null&&s!==void 0?s:1),(0,T.writeColor)(e,m.color)),y&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"iglw"),(0,T.writeUint32)(e,43),(0,T.writeUint32)(e,2),(0,T.writeFixedPoint32)(e,((a=y.size)===null||a===void 0?void 0:a.value)||0),(0,T.writeFixedPoint32)(e,0),(0,T.writeColor)(e,y.color),Tn(e,y.blendMode),(0,T.writeUint8)(e,y.enabled?1:0),jn(e,(l=y.opacity)!==null&&l!==void 0?l:1),(0,T.writeUint8)(e,0),(0,T.writeColor)(e,y.color)),g){(0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"bevl"),(0,T.writeUint32)(e,78),(0,T.writeUint32)(e,2),(0,T.writeFixedPoint32)(e,g.angle||0),(0,T.writeFixedPoint32)(e,g.strength||0),(0,T.writeFixedPoint32)(e,((c=g.size)===null||c===void 0?void 0:c.value)||0),Tn(e,g.highlightBlendMode),Tn(e,g.shadowBlendMode),(0,T.writeColor)(e,g.highlightColor),(0,T.writeColor)(e,g.shadowColor);let S=ds.indexOf(g.style);(0,T.writeUint8)(e,S<=0?ds.indexOf("inner bevel"):S),jn(e,(f=g.highlightOpacity)!==null&&f!==void 0?f:1),jn(e,(u=g.shadowOpacity)!==null&&u!==void 0?u:1),(0,T.writeUint8)(e,g.enabled?1:0),(0,T.writeUint8)(e,g.useGlobalLight?1:0),(0,T.writeUint8)(e,g.direction==="down"?1:0),(0,T.writeColor)(e,g.highlightColor),(0,T.writeColor)(e,g.shadowColor)}k&&((0,T.writeSignature)(e,"8BIM"),(0,T.writeSignature)(e,"sofi"),(0,T.writeUint32)(e,34),(0,T.writeUint32)(e,2),Tn(e,k.blendMode),(0,T.writeColor)(e,k.color),jn(e,(d=k.opacity)!==null&&d!==void 0?d:1),(0,T.writeUint8)(e,k.enabled?1:0),(0,T.writeColor)(e,k.color))}});var us=ae(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});wi.setProperty=Sf;wi.parseEngineData=Ig;wi.serializeEngineData=Dg;var wo=st();function bf(e){return e===32||e===10||e===13||e===9}function wf(e){return e>=48&&e<=57||e===46||e===45}function Sf(e,n,t){n==="__proto__"?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t}var vf=64;function Ig(e,n){let t=0;function i(){for(;t<e.length&&bf(e[t]);)t++}function o(){let m=e[t];return t++,m===92&&(m=e[t],t++),m}function r(){let m="";if(e[t]===41)return t++,m;if(e[t]!==254||e[t+1]!==255){for(;t<e.length&&e[t]!==41;)m+=String.fromCharCode(o());return(0,wo.consumeMemory)(n,m.length*2),t++,m}for(t+=2;t<e.length&&e[t]!==41;){let y=o(),g=o(),k=y<<8|g;m+=String.fromCharCode(k)}return(0,wo.consumeMemory)(n,m.length*2),t++,m}let s=null,a=[];function l(m){a.length?(c(m),a.push(m)):(a.push(m),s=m)}function c(m){if(!a.length)throw new Error("Invalid data");(0,wo.consumeMemory)(n,vf);let y=a[a.length-1];if(typeof y=="string"){let g=a[a.length-2];Sf(g,y,m),u()}else if(Array.isArray(y))y.push(m);else throw new Error("Invalid data")}function f(m){a.length||l({});let y=a[a.length-1];if(typeof y=="string"||Array.isArray(y))c(m==="nil"?null:`/${m}`);else if(y&&typeof y=="object")(0,wo.consumeMemory)(n,vf+m.length*2),a.push(m);else throw new Error("Invalid data")}function u(){if(!a.length)throw new Error("Invalid data");a.pop()}i();let d=e.length,p=0,h="";for(;d>0&&e[d-1]===0;)d--;for(;t<d;){let m=t,y=e[m];if(y===60&&e[m+1]===60)t+=2,l({});else if(y===62&&e[m+1]===62)t+=2,u();else if(y===47){t+=1;let g=t;for(;t<e.length&&!bf(e[t]);)t++;let k="";for(let x=g;x<t;x++)k+=String.fromCharCode(e[x]);f(k)}else if(y===40)t+=1,c(r());else if(y===91)t+=1,l([]);else if(y===93)t+=1,u();else if(y===110&&e[m+1]===117&&e[m+2]===108&&e[m+3]===108)t+=4,c(null);else if(y===116&&e[m+1]===114&&e[m+2]===117&&e[m+3]===101)t+=4,c(!0);else if(y===102&&e[m+1]===97&&e[m+2]===108&&e[m+3]===115&&e[m+4]===101)t+=5,c(!1);else if(wf(y)){let g="";for(;t<e.length&&wf(e[t]);)g+=String.fromCharCode(e[t]),t++;c(parseFloat(g))}else t+=1,p||(h=`'${String.fromCharCode(y)}' (${y}) at ${t}`),p++;i()}return p&&n.log(`Invalid tokens in engine data (${p} in total, first: ${h})`),s}var Cg=["Axis","XY","Zone","WordSpacing","FirstLineIndent","GlyphSpacing","StartIndent","EndIndent","SpaceBefore","SpaceAfter","LetterSpacing","Values","GridSize","GridLeading","PointBase","BoxBounds","TransformPoint0","TransformPoint1","TransformPoint2","FontSize","Leading","HorizontalScale","VerticalScale","BaselineShift","Tsume","OutlineWidth","AutoLeading"],Pg=["RunLengthArray"];function Dg(e,n=!1){let t=new Uint8Array(1024),i=0,o=0;function r(y){if(i>=t.length){let g=new Uint8Array(t.length*2);g.set(t),t=g}t[i]=y,i++}function s(y){for(let g=0;g<y.length;g++)r(y.charCodeAt(g))}function a(){if(n)s(" ");else for(let y=0;y<o;y++)s(" ")}function l(y,g){a(),s(`/${y}`),m(g,y,!0),n||s(`
2
+ `)}function c(y){return Number.isFinite(y)?y:0}function f(y){return c(y).toString()}function u(y){return c(y).toFixed(5).replace(/(\d)0+$/g,"$1").replace(/^0+\.([1-9])/g,".$1").replace(/^-0+\.0(\d)/g,"-.0$1")}function d(y,g){return y=c(y),g&&Cg.indexOf(g)!==-1||(y|0)!==y?u(y):f(y)}function p(y){let g=Object.keys(y);return g.indexOf("98")!==-1&&g.unshift(...g.splice(g.indexOf("98"),1)),g.indexOf("99")!==-1&&g.unshift(...g.splice(g.indexOf("99"),1)),g}function h(y){(y===40||y===41||y===92)&&r(92),r(y)}function m(y,g,k=!1){function x(){k?s(" "):a()}if(y==null)x(),s(n?"/nil":"null");else if(typeof y=="number")x(),s(d(y,g));else if(typeof y=="boolean")x(),s(y?"true":"false");else if(typeof y=="string")if(x(),(g==="99"||g==="98")&&y.charAt(0)==="/")s(y);else{s("("),r(254),r(255);for(let S=0;S<y.length;S++){let A=y.charCodeAt(S);h(A>>8&255),h(A&255)}s(")")}else if(Array.isArray(y))if(x(),y.every(S=>typeof S=="number")){s("[");let S=Pg.indexOf(g)!==-1;for(let A of y)s(" "),s(S?d(A):u(A));s(" ]")}else{s("["),n||s(`
3
+ `);for(let S of y)m(S,g),n||s(`
4
+ `);a(),s("]")}else if(typeof y=="object"){k&&!n&&s(`
5
+ `),a(),s("<<"),n||s(`
6
+ `),o++;for(let S of p(y))y[S]!==void 0&&l(S,y[S]);o--,a(),s(">>")}}if(n){if(typeof e=="object")for(let y of p(e))e[y]!==void 0&&l(y,e[y])}else s(`
7
7
 
8
- `),p(e);return n.slice(0,i)}});var dc=oe(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.decodeEngineData=p0;co.encodeEngineData=m0;var oc={name:"MyriadPro-Regular",script:0,type:0,synthetic:0},ao={justification:"left",firstLineIndent:0,startIndent:0,endIndent:0,spaceBefore:0,spaceAfter:0,autoHyphenate:!0,hyphenatedWordSize:6,preHyphen:2,postHyphen:2,consecutiveHyphens:8,zone:36,wordSpacing:[.8,1,1.33],letterSpacing:[0,0,0],glyphSpacing:[1,1,1],autoLeading:1.2,leadingType:0,hanging:!1,burasagari:!1,kinsokuOrder:0,everyLineComposer:!1},l0={font:oc,fontSize:12,fauxBold:!1,fauxItalic:!1,autoLeading:!0,leading:0,horizontalScale:1,verticalScale:1,tracking:0,autoKerning:!0,kerning:0,baselineShift:0,fontCaps:0,fontBaseline:0,underline:!1,strikethrough:!1,ligatures:!0,dLigatures:!1,baselineDirection:2,tsume:0,styleRunAlignment:2,language:0,noBreak:!1,fillColor:{r:0,g:0,b:0},strokeColor:{r:0,g:0,b:0},fillFlag:!0,strokeFlag:!1,fillFirst:!0,yUnderline:1,outlineWidth:1,characterDirection:0,hindiNumbers:!1,kashida:1,diacriticPos:2},c0={isOn:!1,show:!1,size:18,leading:22,color:{r:0,g:0,b:255},leadingFillColor:{r:0,g:0,b:255},alignLineHeightToGridFlags:!1},Br=["justification","firstLineIndent","startIndent","endIndent","spaceBefore","spaceAfter","autoHyphenate","hyphenatedWordSize","preHyphen","postHyphen","consecutiveHyphens","zone","wordSpacing","letterSpacing","glyphSpacing","autoLeading","leadingType","hanging","burasagari","kinsokuOrder","everyLineComposer"],Ur=["font","fontSize","fauxBold","fauxItalic","autoLeading","leading","horizontalScale","verticalScale","tracking","autoKerning","kerning","baselineShift","fontCaps","fontBaseline","underline","strikethrough","ligatures","dLigatures","baselineDirection","tsume","styleRunAlignment","language","noBreak","fillColor","strokeColor","fillFlag","strokeFlag","fillFirst","yUnderline","outlineWidth","characterDirection","hindiNumbers","kashida","diacriticPos"],rc=["none","crisp","strong","smooth","sharp"],sc=["left","right","center","justify-left","justify-right","justify-center","justify-all"];function ac(e){return e.substring(0,1).toUpperCase()+e.substring(1)}function d0(e){let t=e.Values;switch(e.Type){case 0:return{k:t[1]*255};case 1:return t[0]===1?{r:t[1]*255,g:t[2]*255,b:t[3]*255}:{r:t[1]*255,g:t[2]*255,b:t[3]*255,a:t[0]*255};case 2:return{c:t[1]*255,m:t[2]*255,y:t[3]*255,k:t[4]*255};default:throw new Error("Unknown color type in text layer")}}function Lr(e){if(e){if("r"in e)return{Type:1,Values:["a"in e?e.a/255:1,e.r/255,e.g/255,e.b/255]};if("c"in e)return{Type:2,Values:[1,e.c/255,e.m/255,e.y/255,e.k/255]};if("k"in e)return{Type:0,Values:[1,e.k/255]};throw new Error("Invalid color type in text layer")}else return{Type:1,Values:[0,0,0,0]}}function tc(e,t){if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function nc(e,t){if(!e||!t)return!1;for(let n of Object.keys(e))if(e[n]!==t[n])return!1;for(let n of Object.keys(t))if(e[n]!==t[n])return!1;return!0}function f0(e,t){for(let n=0;n<e.length;n++)if(e[n].name===t.name)return n;return e.push(t),e.length-1}function lc(e,t,n){let i={};for(let o of t){let r=ac(o);e[r]!==void 0&&(o==="justification"?i[o]=sc[e[r]]:o==="font"?i[o]=n[e[r]]:o==="fillColor"||o==="strokeColor"?i[o]=d0(e[r]):i[o]=e[r])}return i}function cc(e,t,n){var i;let o={};for(let r of t){let s=ac(r);e[r]!==void 0&&(r==="justification"?o[s]=sc.indexOf((i=e[r])!==null&&i!==void 0?i:"left"):r==="font"?o[s]=f0(n,e[r]):r==="fillColor"||r==="strokeColor"?o[s]=Lr(e[r]):o[s]=e[r])}return o}function u0(e,t){return lc(e,Br,t)}function h0(e,t){return lc(e,Ur,t)}function lo(e,t){return cc(e,Br,t)}function Or(e,t){return cc(e,Ur,t)}function ic(e,t,n){if(t.length){for(let i of n){let o=t[0].style[i];if(o!==void 0){let s=!1;Array.isArray(o)?s=t.every(a=>tc(a.style[i],o)):typeof o=="object"?s=t.every(a=>nc(a.style[i],o)):s=t.every(a=>a.style[i]===o),s&&(e[i]=o)}if(e[i]!==void 0)for(let s of t){let a=!1;Array.isArray(o)?a=tc(s.style[i],o):typeof o=="object"?a=nc(s.style[i],o):a=s.style[i]===o,a&&delete s.style[i]}}t.every(i=>Object.keys(i.style).length===0)&&(t.length=0)}}function p0(e){var t,n,i,o,r,s;let a=e.EngineDict,l=e.ResourceDict,c=l.FontSet.map(m=>({name:m.Name,script:m.Script,type:m.FontType,synthetic:m.Synthetic})),d=a.Editor.Text.replace(/\r/g,`
9
- `),u=0;for(;/\n$/.test(d);)d=d.substring(0,d.length-1),u++;let f={text:d,antiAlias:(t=rc[a.AntiAlias])!==null&&t!==void 0?t:"smooth",useFractionalGlyphWidths:!!a.UseFractionalGlyphWidths,superscriptSize:l.SuperscriptSize,superscriptPosition:l.SuperscriptPosition,subscriptSize:l.SubscriptSize,subscriptPosition:l.SubscriptPosition,smallCapSize:l.SmallCapSize},h=(s=(r=(o=(i=(n=a.Rendered)===null||n===void 0?void 0:n.Shapes)===null||i===void 0?void 0:i.Children)===null||o===void 0?void 0:o[0])===null||r===void 0?void 0:r.Cookie)===null||s===void 0?void 0:s.Photoshop;h&&(f.shapeType=h.ShapeType===1?"box":"point",h.PointBase&&(f.pointBase=h.PointBase),h.BoxBounds&&(f.boxBounds=h.BoxBounds));let p=a.ParagraphRun;f.paragraphStyle={},f.paragraphStyleRuns=[];for(let m=0;m<p.RunArray.length;m++){let b=p.RunArray[m],v=p.RunLengthArray[m],x=u0(b.ParagraphSheet.Properties,c);f.paragraphStyleRuns.push({length:v,style:x})}for(let m=u;f.paragraphStyleRuns.length&&m>0;m--)--f.paragraphStyleRuns[f.paragraphStyleRuns.length-1].length===0&&f.paragraphStyleRuns.pop();ic(f.paragraphStyle,f.paragraphStyleRuns,Br),f.paragraphStyleRuns.length||delete f.paragraphStyleRuns;let S=a.StyleRun;f.style={},f.styleRuns=[];for(let m=0;m<S.RunArray.length;m++){let b=S.RunLengthArray[m],v=h0(S.RunArray[m].StyleSheet.StyleSheetData,c);v.font||(v.font=c[0]),f.styleRuns.push({length:b,style:v})}for(let m=u;f.styleRuns.length&&m>0;m--)--f.styleRuns[f.styleRuns.length-1].length===0&&f.styleRuns.pop();return ic(f.style,f.styleRuns,Ur),f.styleRuns.length||delete f.styleRuns,f}function m0(e){var t,n,i,o,r,s,a,l,c,d,u,f;let h=`${(e.text||"").replace(/\r?\n/g,"\r")}\r`,p=[{name:"AdobeInvisFont",script:0,type:0,synthetic:0}],S=((t=e.style)===null||t===void 0?void 0:t.font)||((i=(n=e.styleRuns)===null||n===void 0?void 0:n.find(W=>W.style.font))===null||i===void 0?void 0:i.style.font)||oc,m=[],b=[],v=e.paragraphStyleRuns;if(v&&v.length){let W=h.length;for(let te of v){let ne=Math.min(te.length,W);W-=ne,ne&&(W===1&&te===v[v.length-1]&&(ne++,W--),b.push(ne),m.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:lo(Object.assign(Object.assign(Object.assign({},ao),e.paragraphStyle),te.style),p)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}))}W&&(b.push(W),m.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:lo(Object.assign(Object.assign({},ao),e.paragraphStyle),p)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}))}else for(let W=0,te=0;W<h.length;W++)h.charCodeAt(W)===13&&(b.push(W-te+1),m.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:lo(Object.assign(Object.assign({},ao),e.paragraphStyle),p)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}),te=W+1);let x=Or(Object.assign(Object.assign({},l0),{font:S}),p),_=e.styleRuns||[{length:h.length,style:e.style||{}}],I=[],P=[],k=h.length;for(let W of _){let te=Math.min(W.length,k);k-=te,te&&(k===1&&W===_[_.length-1]&&(te++,k--),P.push(te),I.push({StyleSheet:{StyleSheetData:Or(Object.assign(Object.assign({kerning:0,autoKerning:!0,fillColor:{r:0,g:0,b:0}},e.style),W.style),p)}}))}k&&_.length&&(P.push(k),I.push({StyleSheet:{StyleSheetData:Or(Object.assign({kerning:0,autoKerning:!0,fillColor:{r:0,g:0,b:0}},e.style),p)}}));let E=Object.assign(Object.assign({},c0),e.gridInfo),O=e.orientation==="vertical"?2:0,U=e.orientation==="vertical"?1:0,M=e.shapeType==="box"?1:0,le={ShapeType:M};M===0?le.PointBase=e.pointBase||[0,0]:le.BoxBounds=e.boxBounds||[0,0,0,0],le.Base={ShapeType:M,TransformPoint0:[1,0],TransformPoint1:[0,1],TransformPoint2:[0,0]};let me={KinsokuSet:[{Name:"PhotoshopKinsokuHard",NoStart:"\u3001\u3002\uFF0C\uFF0E\u30FB\uFF1A\uFF1B\uFF1F\uFF01\u30FC\u2015\u2019\u201D\uFF09\u3015\uFF3D\uFF5D\u3009\u300B\u300D\u300F\u3011\u30FD\u30FE\u309D\u309E\u3005\u3041\u3043\u3045\u3047\u3049\u3063\u3083\u3085\u3087\u308E\u30A1\u30A3\u30A5\u30A7\u30A9\u30C3\u30E3\u30E5\u30E7\u30EE\u30F5\u30F6\u309B\u309C?!)]},.:;\u2103\u2109\xA2\uFF05\u2030",NoEnd:"\u2018\u201C\uFF08\u3014\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010([{\uFFE5\uFF04\xA3\uFF20\xA7\u3012\uFF03",Keep:"\u2015\u2025",Hanging:"\u3001\u3002.,"},{Name:"PhotoshopKinsokuSoft",NoStart:"\u3001\u3002\uFF0C\uFF0E\u30FB\uFF1A\uFF1B\uFF1F\uFF01\u2019\u201D\uFF09\u3015\uFF3D\uFF5D\u3009\u300B\u300D\u300F\u3011\u30FD\u30FE\u309D\u309E\u3005",NoEnd:"\u2018\u201C\uFF08\u3014\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010",Keep:"\u2015\u2025",Hanging:"\u3001\u3002.,"}],MojiKumiSet:[{InternalName:"Photoshop6MojiKumiSet1"},{InternalName:"Photoshop6MojiKumiSet2"},{InternalName:"Photoshop6MojiKumiSet3"},{InternalName:"Photoshop6MojiKumiSet4"}],TheNormalStyleSheet:0,TheNormalParagraphSheet:0,ParagraphSheetSet:[{Name:"Normal RGB",DefaultStyleSheet:0,Properties:lo(Object.assign(Object.assign({},ao),e.paragraphStyle),p)}],StyleSheetSet:[{Name:"Normal RGB",StyleSheetData:x}],FontSet:p.map(W=>({Name:W.name,Script:W.script||0,FontType:W.type||0,Synthetic:W.synthetic||0})),SuperscriptSize:(o=e.superscriptSize)!==null&&o!==void 0?o:.583,SuperscriptPosition:(r=e.superscriptPosition)!==null&&r!==void 0?r:.333,SubscriptSize:(s=e.subscriptSize)!==null&&s!==void 0?s:.583,SubscriptPosition:(a=e.subscriptPosition)!==null&&a!==void 0?a:.333,SmallCapSize:(l=e.smallCapSize)!==null&&l!==void 0?l:.7};return{EngineDict:{Editor:{Text:h},ParagraphRun:{DefaultRunData:{ParagraphSheet:{DefaultStyleSheet:0,Properties:{}},Adjustments:{Axis:[1,0,1],XY:[0,0]}},RunArray:m,RunLengthArray:b,IsJoinable:1},StyleRun:{DefaultRunData:{StyleSheet:{StyleSheetData:{}}},RunArray:I,RunLengthArray:P,IsJoinable:2},GridInfo:{GridIsOn:!!E.isOn,ShowGrid:!!E.show,GridSize:(c=E.size)!==null&&c!==void 0?c:18,GridLeading:(d=E.leading)!==null&&d!==void 0?d:22,GridColor:Lr(E.color),GridLeadingFillColor:Lr(E.color),AlignLineHeightToGridFlags:!!E.alignLineHeightToGridFlags},AntiAlias:rc.indexOf((u=e.antiAlias)!==null&&u!==void 0?u:"sharp"),UseFractionalGlyphWidths:(f=e.useFractionalGlyphWidths)!==null&&f!==void 0?f:!0,Rendered:{Version:1,Shapes:{WritingDirection:O,Children:[{ShapeType:M,Procession:U,Lines:{WritingDirection:O,Children:[]},Cookie:{Photoshop:le}}]}}},ResourceDict:Object.assign({},me),DocumentResources:Object.assign({},me)}}});var uc=oe(jr=>{"use strict";Object.defineProperty(jr,"__esModule",{value:!0});jr.decodeEngineData2=b0;var Rr={0:{uproot:!0,children:{0:{name:"Type"},1:{name:"Values"}}}},Tr={0:{name:"Font"},1:{name:"FontSize"},2:{name:"FauxBold"},3:{name:"FauxItalic"},4:{name:"AutoLeading"},5:{name:"Leading"},6:{name:"HorizontalScale"},7:{name:"VerticalScale"},8:{name:"Tracking"},9:{name:"BaselineShift"},11:{name:"Kerning?"},12:{name:"FontCaps"},13:{name:"FontBaseline"},15:{name:"Strikethrough?"},16:{name:"Underline?"},18:{name:"Ligatures"},19:{name:"DLigatures"},23:{name:"Fractions"},24:{name:"Ordinals"},28:{name:"StylisticAlternates"},30:{name:"OldStyle?"},35:{name:"BaselineDirection"},38:{name:"Language"},52:{name:"NoBreak"},53:{name:"FillColor",children:Rr},54:{name:"StrokeColor",children:Rr},55:{children:{99:{uproot:!0}}},79:{children:Rr}},Mr={0:{name:"Justification"},1:{name:"FirstLineIndent"},2:{name:"StartIndent"},3:{name:"EndIndent"},4:{name:"SpaceBefore"},5:{name:"SpaceAfter"},7:{name:"AutoLeading"},9:{name:"AutoHyphenate"},10:{name:"HyphenatedWordSize"},11:{name:"PreHyphen"},12:{name:"PostHyphen"},13:{name:"ConsecutiveHyphens?"},14:{name:"Zone"},15:{name:"HypenateCapitalizedWords"},17:{name:"WordSpacing"},18:{name:"LetterSpacing"},19:{name:"GlyphSpacing"},32:{name:"StyleSheet",children:Tr}},fc={name:"StyleSheetData",children:Tr},g0={0:{name:"ResourceDict",children:{1:{name:"FontSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},2:{name:"FontType"}}}}}}}}},2:{name:"2",children:{}},3:{name:"MojiKumiSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"InternalName"}}}}}}},4:{name:"KinsokuSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},5:{uproot:!0,children:{0:{name:"NoStart"},1:{name:"NoEnd"},2:{name:"Keep"},3:{name:"Hanging"},4:{name:"Name"}}}}}}}}},5:{name:"StyleSheetSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},6:fc}}}}}},6:{name:"ParagraphSheetSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},5:{name:"Properties",children:Mr},6:{name:"DefaultStyleSheet"}}}}}}},8:{name:"TextFrameSet",children:{0:{uproot:!0,children:{0:{name:"path",children:{0:{name:"name"},1:{name:"bezierCurve",children:{0:{name:"controlPoints"}}},2:{name:"data",children:{0:{name:"type"},1:{name:"orientation"},2:{name:"frameMatrix"},4:{name:"4"},6:{name:"textRange"},7:{name:"rowGutter"},8:{name:"columnGutter"},9:{name:"9"},10:{name:"baselineAlignment",children:{0:{name:"flag"},1:{name:"min"}}},11:{name:"pathData",children:{1:{name:"1"},0:{name:"reversed"},2:{name:"2"},3:{name:"3"},4:{name:"spacing"},5:{name:"5"},6:{name:"6"},7:{name:"7"},18:{name:"18"}}},12:{name:"12"},13:{name:"13"}}},3:{name:"3"},97:{name:"uuid"}}}}}}},9:{name:"Predefined",children:{0:{children:{0:{uproot:!0}}},1:{children:{0:{uproot:!0}}}}}}},1:{name:"EngineDict",children:{0:{name:"0",children:{3:{name:"SuperscriptSize"},4:{name:"SuperscriptPosition"},5:{name:"SubscriptSize"},6:{name:"SubscriptPosition"},7:{name:"SmallCapSize"},8:{name:"UseFractionalGlyphWidths"},15:{children:{0:{uproot:!0}}}}},1:{name:"Editors?",children:{0:{name:"Editor",children:{0:{name:"Text"},5:{name:"ParagraphRun",children:{0:{name:"RunArray",children:{0:{name:"ParagraphSheet",children:{0:{uproot:!0,children:{0:{name:"0"},5:{name:"5",children:Mr},6:{name:"6"}}}}},1:{name:"RunLength"}}}}},6:{name:"StyleRun",children:{0:{name:"RunArray",children:{0:{name:"StyleSheet",children:{0:{uproot:!0,children:{6:fc}}}},1:{name:"RunLength"}}}}}}},1:{name:"FontVectorData ???"}}},2:{name:"StyleSheet",children:Tr},3:{name:"ParagraphSheet",children:Mr}}}};function ri(e,t){var n,i;if(e===null)return e;if(Array.isArray(e))return e.map(r=>ri(r,t));if(typeof e!="object")return e;let o={};for(let r of Object.keys(e))if(t[r])if(t[r].uproot){r!=="99"&&(o=ri(e[r],(n=t[r].children)!==null&&n!==void 0?n:{})),e[99]&&(o._type=e[99]);break}else o[t[r].name||r]=ri(e[r],(i=t[r].children)!==null&&i!==void 0?i:{});else r==="99"?o._type=e[r]:o[r]=ri(e[r],{});return o}function b0(e){return ri(e,g0)}});var oo=oe(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.booleanOperations=Ce.infoHandlersMap=Ce.infoHandlers=void 0;Ce.readBezierKnot=_c;Ce.readVectorMask=Ac;Ce.hasMultiEffects=Xr;var hc=ji(),pc=Yl(),Ze=Tt(),g=jt(),y=Dn(),w=Gi(),Hr=ec(),mc=dc(),y0=uc(),Xe="abcdefghijklmnopqrstuvwxyz";Ce.infoHandlers=[];Ce.infoHandlersMap={};function L(e,t,n,i){let o={key:e,has:t,read:n,write:i};Ce.infoHandlers.push(o),Ce.infoHandlersMap[o.key]=o}function Gt(e,t){Ce.infoHandlersMap[e]=Ce.infoHandlersMap[t]}function ae(e){return t=>t[e]!==void 0}function zr(e){if((0,g.readUint32)(e))throw new Error(`Resource size above 4 GB limit at ${e.offset.toString(16)}`);return(0,g.readUint32)(e)}function $r(e,t){(0,y.writeUint32)(e,0),(0,y.writeUint32)(e,t)}L("TySh",ae("text"),(e,t,n)=>{if((0,g.readInt16)(e)!==1)throw new Error("Invalid TySh version");let i=[];for(let s=0;s<6;s++)i.push((0,g.readFloat64)(e));if((0,g.readInt16)(e)!==50)throw new Error("Invalid TySh text version");let o=(0,w.readVersionAndDescriptor)(e);if((0,g.readInt16)(e)!==1)throw new Error("Invalid TySh warp version");let r=(0,w.readVersionAndDescriptor)(e);if(t.text={transform:i,left:(0,g.readFloat32)(e),top:(0,g.readFloat32)(e),right:(0,g.readFloat32)(e),bottom:(0,g.readFloat32)(e),text:o["Txt "].replace(/\r/g,`
10
- `),index:o.TextIndex||0,gridding:w.textGridding.decode(o.textGridding),antiAlias:w.Annt.decode(o.AntA),orientation:w.Ornt.decode(o.Ornt),warp:{style:w.warpStyle.decode(r.warpStyle),value:r.warpValue||0,perspective:r.warpPerspective||0,perspectiveOther:r.warpPerspectiveOther||0,rotate:w.Ornt.decode(r.warpRotate)}},o.bounds&&(t.text.bounds=(0,w.descBoundsToBounds)(o.bounds)),o.boundingBox&&(t.text.boundingBox=(0,w.descBoundsToBounds)(o.boundingBox)),o.EngineData){let s=(0,Hr.parseEngineData)(o.EngineData),a=(0,mc.decodeEngineData)(s);t.text=Object.assign(Object.assign({},t.text),a)}(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.text,i=n.warp||{},o=n.transform||[1,0,0,1,0,0],r=Object.assign(Object.assign(Object.assign({"Txt ":(n.text||"").replace(/\r?\n/g,"\r"),textGridding:w.textGridding.encode(n.gridding),Ornt:w.Ornt.encode(n.orientation),AntA:w.Annt.encode(n.antiAlias)},n.bounds?{bounds:(0,w.boundsToDescBounds)(n.bounds)}:{}),n.boundingBox?{boundingBox:(0,w.boundsToDescBounds)(n.boundingBox)}:{}),{TextIndex:n.index||0,EngineData:(0,Hr.serializeEngineData)((0,mc.encodeEngineData)(n))});(0,y.writeInt16)(e,1);for(let s=0;s<6;s++)(0,y.writeFloat64)(e,o[s]);(0,y.writeInt16)(e,50),(0,w.writeVersionAndDescriptor)(e,"","TxLr",r,"text"),(0,y.writeInt16)(e,1),(0,w.writeVersionAndDescriptor)(e,"","warp",mo(i)),(0,y.writeFloat32)(e,n.left),(0,y.writeFloat32)(e,n.top),(0,y.writeFloat32)(e,n.right),(0,y.writeFloat32)(e,n.bottom)});L("SoCo",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&e.vectorFill.type==="color",(e,t)=>{let n=(0,w.readVersionAndDescriptor)(e);t.vectorFill=(0,w.parseVectorContent)(n)},(e,t)=>{let{descriptor:n}=(0,w.serializeVectorContent)(t.vectorFill);(0,w.writeVersionAndDescriptor)(e,"","null",n)});L("GdFl",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&(e.vectorFill.type==="solid"||e.vectorFill.type==="noise"),(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);t.vectorFill=(0,w.parseVectorContent)(i),(0,g.skipBytes)(e,n())},(e,t)=>{let{descriptor:n}=(0,w.serializeVectorContent)(t.vectorFill);(0,w.writeVersionAndDescriptor)(e,"","null",n)});L("PtFl",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&e.vectorFill.type==="pattern",(e,t)=>{let n=(0,w.readVersionAndDescriptor)(e);t.vectorFill=(0,w.parseVectorContent)(n)},(e,t)=>{let{descriptor:n}=(0,w.serializeVectorContent)(t.vectorFill);(0,w.writeVersionAndDescriptor)(e,"","null",n)});L("vscg",e=>e.vectorFill!==void 0&&e.vectorStroke!==void 0,(e,t,n)=>{(0,g.readSignature)(e);let i=(0,w.readVersionAndDescriptor)(e);t.vectorFill=(0,w.parseVectorContent)(i),(0,g.skipBytes)(e,n())},(e,t)=>{let{descriptor:n,key:i}=(0,w.serializeVectorContent)(t.vectorFill);(0,y.writeSignature)(e,i),(0,w.writeVersionAndDescriptor)(e,"","null",n)});function _c(e,t,n){let i=(0,g.readFixedPointPath32)(e)*n,o=(0,g.readFixedPointPath32)(e)*t,r=(0,g.readFixedPointPath32)(e)*n,s=(0,g.readFixedPointPath32)(e)*t,a=(0,g.readFixedPointPath32)(e)*n,l=(0,g.readFixedPointPath32)(e)*t;return[o,i,s,r,l,a]}function w0(e,t,n,i){(0,y.writeFixedPointPath32)(e,t[1]/i),(0,y.writeFixedPointPath32)(e,t[0]/n),(0,y.writeFixedPointPath32)(e,t[3]/i),(0,y.writeFixedPointPath32)(e,t[2]/n),(0,y.writeFixedPointPath32)(e,t[5]/i),(0,y.writeFixedPointPath32)(e,t[4]/n)}Ce.booleanOperations=["exclude","combine","subtract","intersect"];function Ac(e,t,n,i,o){let r=e.offset+o,s=t.paths,a;for(;r-e.offset>=26;){let l=(0,g.readUint16)(e);switch(l){case 0:case 3:{(0,g.readUint16)(e);let c=(0,g.readInt16)(e),d=(0,g.readUint16)(e);(0,g.skipBytes)(e,18),a={open:l===3,knots:[],fillRule:d===2?"non-zero":"even-odd"},c!==-1&&(a.operation=Ce.booleanOperations[c]),s.push(a);break}case 1:case 2:case 4:case 5:a.knots.push({linked:l===1||l===4,points:_c(e,n,i)});break;case 6:(0,g.skipBytes)(e,24);break;case 7:{let c=(0,g.readFixedPointPath32)(e),d=(0,g.readFixedPointPath32)(e),u=(0,g.readFixedPointPath32)(e),f=(0,g.readFixedPointPath32)(e),h=(0,g.readFixedPointPath32)(e);(0,g.skipBytes)(e,4),t.clipboard={top:c,left:d,bottom:u,right:f,resolution:h};break}case 8:t.fillStartsWithAllPixels=!!(0,g.readUint16)(e),(0,g.skipBytes)(e,22);break;default:throw new Error("Invalid vmsk section")}}return s}L("vmsk",ae("vectorMask"),(e,t,n,{width:i,height:o})=>{if((0,g.readUint32)(e)!==3)throw new Error("Invalid vmsk version");t.vectorMask={paths:[]};let r=t.vectorMask,s=(0,g.readUint32)(e);r.invert=(s&1)!==0,r.notLink=(s&2)!==0,r.disable=(s&4)!==0,Ac(e,r,i,o,n()),(0,g.skipBytes)(e,n())},(e,t,{width:n,height:i})=>{let o=t.vectorMask,r=(o.invert?1:0)|(o.notLink?2:0)|(o.disable?4:0);(0,y.writeUint32)(e,3),(0,y.writeUint32)(e,r),(0,y.writeUint16)(e,6),(0,y.writeZeros)(e,24);let s=o.clipboard;s&&((0,y.writeUint16)(e,7),(0,y.writeFixedPointPath32)(e,s.top),(0,y.writeFixedPointPath32)(e,s.left),(0,y.writeFixedPointPath32)(e,s.bottom),(0,y.writeFixedPointPath32)(e,s.right),(0,y.writeFixedPointPath32)(e,s.resolution),(0,y.writeZeros)(e,4)),(0,y.writeUint16)(e,8),(0,y.writeUint16)(e,o.fillStartsWithAllPixels?1:0),(0,y.writeZeros)(e,22);for(let a of o.paths){(0,y.writeUint16)(e,a.open?3:0),(0,y.writeUint16)(e,a.knots.length),(0,y.writeUint16)(e,a.operation?Ce.booleanOperations.indexOf(a.operation):-1),(0,y.writeUint16)(e,a.fillRule==="non-zero"?2:1),(0,y.writeZeros)(e,18);let l=a.open?4:1,c=a.open?5:2;for(let{linked:d,points:u}of a.knots)(0,y.writeUint16)(e,d?l:c),w0(e,u,n,i)}});Gt("vsms","vmsk");L("vowv",ae("vowv"),(e,t)=>{t.vowv=(0,g.readUint32)(e)},(e,t)=>{(0,y.writeUint32)(e,t.vowv)});L("vogk",ae("vectorOrigination"),(e,t,n)=>{if((0,g.readInt32)(e)!==1)throw new Error("Invalid vogk version");let i=(0,w.readVersionAndDescriptor)(e);t.vectorOrigination={keyDescriptorList:[]};for(let o of i.keyDescriptorList){let r={};o.keyShapeInvalidated!=null&&(r.keyShapeInvalidated=o.keyShapeInvalidated),o.keyOriginType!=null&&(r.keyOriginType=o.keyOriginType),o.keyOriginResolution!=null&&(r.keyOriginResolution=o.keyOriginResolution),o.keyOriginShapeBBox&&(r.keyOriginShapeBoundingBox={top:(0,w.parseUnitsOrNumber)(o.keyOriginShapeBBox["Top "]),left:(0,w.parseUnitsOrNumber)(o.keyOriginShapeBBox.Left),bottom:(0,w.parseUnitsOrNumber)(o.keyOriginShapeBBox.Btom),right:(0,w.parseUnitsOrNumber)(o.keyOriginShapeBBox.Rght)});let s=o.keyOriginRRectRadii;s&&(r.keyOriginRRectRadii={topRight:(0,w.parseUnits)(s.topRight),topLeft:(0,w.parseUnits)(s.topLeft),bottomLeft:(0,w.parseUnits)(s.bottomLeft),bottomRight:(0,w.parseUnits)(s.bottomRight)});let a=o.keyOriginBoxCorners;a&&(r.keyOriginBoxCorners=[{x:a.rectangleCornerA.Hrzn,y:a.rectangleCornerA.Vrtc},{x:a.rectangleCornerB.Hrzn,y:a.rectangleCornerB.Vrtc},{x:a.rectangleCornerC.Hrzn,y:a.rectangleCornerC.Vrtc},{x:a.rectangleCornerD.Hrzn,y:a.rectangleCornerD.Vrtc}]);let l=o.Trnf;l&&(r.transform=[l.xx,l.xy,l.yx,l.yy,l.tx,l.ty]),t.vectorOrigination.keyDescriptorList.push(r)}(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.vectorOrigination,i={keyDescriptorList:[]};for(let o=0;o<n.keyDescriptorList.length;o++){let r=n.keyDescriptorList[o];i.keyDescriptorList.push({});let s=i.keyDescriptorList[i.keyDescriptorList.length-1];r.keyOriginType!=null&&(s.keyOriginType=r.keyOriginType),r.keyOriginResolution!=null&&(s.keyOriginResolution=r.keyOriginResolution);let a=r.keyOriginRRectRadii;a&&(s.keyOriginRRectRadii={unitValueQuadVersion:1,topRight:(0,w.unitsValue)(a.topRight,"topRight"),topLeft:(0,w.unitsValue)(a.topLeft,"topLeft"),bottomLeft:(0,w.unitsValue)(a.bottomLeft,"bottomLeft"),bottomRight:(0,w.unitsValue)(a.bottomRight,"bottomRight")});let l=r.keyOriginShapeBoundingBox;l&&(s.keyOriginShapeBBox={unitValueQuadVersion:1,"Top ":(0,w.unitsValue)(l.top,"top"),Left:(0,w.unitsValue)(l.left,"left"),Btom:(0,w.unitsValue)(l.bottom,"bottom"),Rght:(0,w.unitsValue)(l.right,"right")});let c=r.keyOriginBoxCorners;c&&c.length===4&&(s.keyOriginBoxCorners={rectangleCornerA:{Hrzn:c[0].x,Vrtc:c[0].y},rectangleCornerB:{Hrzn:c[1].x,Vrtc:c[1].y},rectangleCornerC:{Hrzn:c[2].x,Vrtc:c[2].y},rectangleCornerD:{Hrzn:c[3].x,Vrtc:c[3].y}});let d=r.transform;d&&d.length===6&&(s.Trnf={xx:d[0],xy:d[1],yx:d[2],yy:d[3],tx:d[4],ty:d[5]}),r.keyShapeInvalidated!=null&&(s.keyShapeInvalidated=r.keyShapeInvalidated),s.keyOriginIndex=o}(0,y.writeInt32)(e,1),(0,w.writeVersionAndDescriptor)(e,"","null",i)});L("lmfx",e=>e.effects!==void 0&&Xr(e.effects),(e,t,n)=>{if((0,g.readUint32)(e)!==0)throw new Error("Invalid lmfx version");let o=(0,w.readVersionAndDescriptor)(e);t.effects=(0,w.parseEffects)(o,!!e.logMissingFeatures),(0,g.skipBytes)(e,n())},(e,t,n,i)=>{let o=(0,w.serializeEffects)(t.effects,!!i.logMissingFeatures,!0);(0,y.writeUint32)(e,0),(0,w.writeVersionAndDescriptor)(e,"","null",o)});L("lrFX",ae("effects"),(e,t,n)=>{t.effects||(t.effects=(0,pc.readEffects)(e)),(0,g.skipBytes)(e,n())},(e,t)=>{(0,pc.writeEffects)(e,t.effects)});L("luni",ae("name"),(e,t,n)=>{if(n()>4){let i=(0,g.readUint32)(e);n()>=i*2?t.name=(0,g.readUnicodeStringWithLength)(e,i):e.logDevFeatures&&e.log("name in luni section is too long")}else e.logDevFeatures&&e.log("empty luni section");(0,g.skipBytes)(e,n())},(e,t)=>{(0,y.writeUnicodeString)(e,t.name)});L("lnsr",ae("nameSource"),(e,t)=>t.nameSource=(0,g.readSignature)(e),(e,t)=>(0,y.writeSignature)(e,t.nameSource));L("lyid",ae("id"),(e,t)=>{t.id=(0,g.readUint32)(e)},(e,t,n,i)=>{let o=t.id;for(;i.layerIds.has(o);)o+=100;(0,y.writeUint32)(e,o),i.layerIds.add(o),i.layerToId.set(t,o)});L("lsct",ae("sectionDivider"),(e,t,n)=>{t.sectionDivider={type:(0,g.readUint32)(e)},n()&&((0,g.checkSignature)(e,"8BIM"),t.sectionDivider.key=(0,g.readSignature)(e)),n()&&(t.sectionDivider.subType=(0,g.readUint32)(e))},(e,t)=>{(0,y.writeUint32)(e,t.sectionDivider.type),t.sectionDivider.key&&((0,y.writeSignature)(e,"8BIM"),(0,y.writeSignature)(e,t.sectionDivider.key),t.sectionDivider.subType!==void 0&&(0,y.writeUint32)(e,t.sectionDivider.subType))});Gt("lsdk","lsct");L("clbl",ae("blendClippendElements"),(e,t)=>{t.blendClippendElements=!!(0,g.readUint8)(e),(0,g.skipBytes)(e,3)},(e,t)=>{(0,y.writeUint8)(e,t.blendClippendElements?1:0),(0,y.writeZeros)(e,3)});L("infx",ae("blendInteriorElements"),(e,t)=>{t.blendInteriorElements=!!(0,g.readUint8)(e),(0,g.skipBytes)(e,3)},(e,t)=>{(0,y.writeUint8)(e,t.blendInteriorElements?1:0),(0,y.writeZeros)(e,3)});L("knko",ae("knockout"),(e,t)=>{t.knockout=!!(0,g.readUint8)(e),(0,g.skipBytes)(e,3)},(e,t)=>{(0,y.writeUint8)(e,t.knockout?1:0),(0,y.writeZeros)(e,3)});L("lmgm",ae("layerMaskAsGlobalMask"),(e,t)=>{t.layerMaskAsGlobalMask=!!(0,g.readUint8)(e),(0,g.skipBytes)(e,3)},(e,t)=>{(0,y.writeUint8)(e,t.layerMaskAsGlobalMask?1:0),(0,y.writeZeros)(e,3)});L("lspf",ae("protected"),(e,t)=>{let n=(0,g.readUint32)(e);t.protected={transparency:(n&1)!==0,composite:(n&2)!==0,position:(n&4)!==0},n&8&&(t.protected.artboards=!0)},(e,t)=>{let n=(t.protected.transparency?1:0)|(t.protected.composite?2:0)|(t.protected.position?4:0)|(t.protected.artboards?8:0);(0,y.writeUint32)(e,n)});L("lclr",ae("layerColor"),(e,t)=>{let n=(0,g.readUint16)(e);(0,g.skipBytes)(e,6),t.layerColor=Ze.layerColors[n]},(e,t)=>{let n=Ze.layerColors.indexOf(t.layerColor);(0,y.writeUint16)(e,n===-1?0:n),(0,y.writeZeros)(e,6)});L("shmd",e=>e.timestamp!==void 0||e.animationFrames!==void 0||e.animationFrameFlags!==void 0||e.timeline!==void 0||e.comps!==void 0,(e,t,n)=>{let i=(0,g.readUint32)(e);for(let o=0;o<i;o++){(0,g.checkSignature)(e,"8BIM");let r=(0,g.readSignature)(e);(0,g.readUint8)(e),(0,g.skipBytes)(e,3),(0,g.readSection)(e,1,s=>{if(r==="cust"){let a=(0,w.readVersionAndDescriptor)(e);a.layerTime!==void 0&&(t.timestamp=a.layerTime)}else if(r==="mlst"){let a=(0,w.readVersionAndDescriptor)(e);t.animationFrames=[];for(let l=0;l<a.LaSt.length;l++){let c=a.LaSt[l],d={frames:c.FrLs};c.enab!==void 0&&(d.enable=c.enab),c.Ofst&&(d.offset=(0,w.horzVrtcToXY)(c.Ofst)),c.FXRf&&(d.referencePoint=(0,w.horzVrtcToXY)(c.FXRf)),c.Lefx&&(d.effects=(0,w.parseEffects)(c.Lefx,!!e.logMissingFeatures)),c.blendOptions&&c.blendOptions.Opct&&(d.opacity=(0,w.parsePercent)(c.blendOptions.Opct)),t.animationFrames.push(d)}}else if(r==="mdyn"){(0,g.readUint16)(e);let a=(0,g.readUint8)(e),l=(0,g.readUint8)(e);t.animationFrameFlags={propagateFrameOne:!a,unifyLayerPosition:(l&1)!==0,unifyLayerStyle:(l&2)!==0,unifyLayerVisibility:(l&4)!==0}}else if(r==="tmln"){let a=(0,w.readVersionAndDescriptor)(e),l=a.timeScope,c={start:(0,w.frac)(l.Strt),duration:(0,w.frac)(l.duration),inTime:(0,w.frac)(l.inTime),outTime:(0,w.frac)(l.outTime),autoScope:a.autoScope,audioLevel:a.audioLevel};a.trackList&&(c.tracks=(0,w.parseTrackList)(a.trackList,!!e.logMissingFeatures)),t.timeline=c}else if(r==="cmls"){let a=(0,w.readVersionAndDescriptor)(e);t.comps={settings:[]},a.origFXRefPoint&&(t.comps.originalEffectsReferencePoint={x:a.origFXRefPoint.Hrzn,y:a.origFXRefPoint.Vrtc});for(let l of a.layerSettings){t.comps.settings.push({compList:l.compList});let c=t.comps.settings[t.comps.settings.length-1];"enab"in l&&(c.enabled=l.enab),l.Ofst&&(c.offset={x:l.Ofst.Hrzn,y:l.Ofst.Vrtc}),l.FXRefPoint&&(c.effectsReferencePoint={x:l.FXRefPoint.Hrzn,y:l.FXRefPoint.Vrtc})}}else r==="extn"&&(0,w.readVersionAndDescriptor)(e),e.logMissingFeatures&&e.log('Unhandled "shmd" section key',r);(0,g.skipBytes)(e,s())})}(0,g.skipBytes)(e,n())},(e,t,n,i)=>{let{animationFrames:o,animationFrameFlags:r,timestamp:s,timeline:a,comps:l}=t,c=0;o&&c++,r&&c++,a&&c++,s!==void 0&&c++,l&&c++,(0,y.writeUint32)(e,c),o&&((0,y.writeSignature)(e,"8BIM"),(0,y.writeSignature)(e,"mlst"),(0,y.writeUint8)(e,0),(0,y.writeZeros)(e,3),(0,y.writeSection)(e,2,()=>{var d;let u={LaID:(d=t.id)!==null&&d!==void 0?d:0,LaSt:[]};for(let f=0;f<o.length;f++){let h=o[f],p={};h.enable!==void 0&&(p.enab=h.enable),p.FrLs=h.frames,h.offset&&(p.Ofst=(0,w.xyToHorzVrtc)(h.offset)),h.referencePoint&&(p.FXRf=(0,w.xyToHorzVrtc)(h.referencePoint)),h.effects&&(p.Lefx=(0,w.serializeEffects)(h.effects,!1,!1)),h.opacity!==void 0&&(p.blendOptions={Opct:(0,w.unitsPercent)(h.opacity)}),u.LaSt.push(p)}(0,w.writeVersionAndDescriptor)(e,"","null",u)},!0)),r&&((0,y.writeSignature)(e,"8BIM"),(0,y.writeSignature)(e,"mdyn"),(0,y.writeUint8)(e,0),(0,y.writeZeros)(e,3),(0,y.writeSection)(e,2,()=>{(0,y.writeUint16)(e,0),(0,y.writeUint8)(e,r.propagateFrameOne?0:15),(0,y.writeUint8)(e,(r.unifyLayerPosition?1:0)|(r.unifyLayerStyle?2:0)|(r.unifyLayerVisibility?4:0))})),a&&((0,y.writeSignature)(e,"8BIM"),(0,y.writeSignature)(e,"tmln"),(0,y.writeUint8)(e,0),(0,y.writeZeros)(e,3),(0,y.writeSection)(e,2,()=>{let d={Vrsn:1,timeScope:{Vrsn:1,Strt:a.start,duration:a.duration,inTime:a.inTime,outTime:a.outTime},autoScope:a.autoScope,audioLevel:a.audioLevel};a.tracks&&(d.trackList=(0,w.serializeTrackList)(a.tracks));let u=i.layerToId.get(t)||t.id;if(!u)throw new Error("You need to provide layer.id value whan writing document with animations");d.LyrI=u,(0,w.writeVersionAndDescriptor)(e,"","null",d,"anim")},!0)),s!==void 0&&((0,y.writeSignature)(e,"8BIM"),(0,y.writeSignature)(e,"cust"),(0,y.writeUint8)(e,0),(0,y.writeZeros)(e,3),(0,y.writeSection)(e,2,()=>{let d={layerTime:s};(0,w.writeVersionAndDescriptor)(e,"","metadata",d)},!0)),l&&((0,y.writeSignature)(e,"8BIM"),(0,y.writeSignature)(e,"cmls"),(0,y.writeUint8)(e,0),(0,y.writeZeros)(e,3),(0,y.writeSection)(e,2,()=>{let d=i.layerToId.get(t)||t.id;if(!d)throw new Error("You need to provide layer.id value whan writing document with layer comps");let u={};l.originalEffectsReferencePoint&&(u.origFXRefPoint={Hrzn:l.originalEffectsReferencePoint.x,Vrtc:l.originalEffectsReferencePoint.y}),u.LyrI=d,u.layerSettings=[];for(let f of l.settings){let h={};f.enabled!==void 0&&(h.enab=f.enabled),f.offset&&(h.Ofst={Hrzn:f.offset.x,Vrtc:f.offset.y}),f.effectsReferencePoint&&(h.FXRefPoint={Hrzn:f.effectsReferencePoint.x,Vrtc:f.effectsReferencePoint.y}),h.compList=f.compList,u.layerSettings.push(h)}(0,w.writeVersionAndDescriptor)(e,"","null",u)},!0))});L("PxSc",()=>!1,(e,t)=>{let n=(0,w.readVersionAndDescriptor)(e,!0);n.pixelSourceType===1986285651?t.pixelSource={type:"vdPS",origin:{x:n.origin.Hrzn,y:n.origin.Vrtc},interpretation:{interpretAlpha:n.interpretation.interpretAlpha.split(".")[1],profile:n.interpretation.profile},frameReader:{type:"QTFR",link:{name:n.frameReader["Lnk "]["Nm "],fullPath:n.frameReader["Lnk "].fullPath,originalPath:n.frameReader["Lnk "].originalPath,relativePath:n.frameReader["Lnk "].relPath,alias:n.frameReader["Lnk "].alis},mediaDescriptor:n.frameReader.mediaDescriptor},showAlteredVideo:n.showAlteredVideo}:e.log("Unknown pixelSourceType")},(e,t)=>{let n=t.pixelSource,i={_name:"",_classID:"PixelSource",pixelSourceType:1986285651,descVersion:1,origin:{Hrzn:n.origin.x,Vrtc:n.origin.y},interpretation:{_name:"",_classID:"footageInterpretation",Vrsn:1,interpretAlpha:`alphaInterpretation.${n.interpretation.interpretAlpha}`,profile:n.interpretation.profile},frameReader:{_name:"",_classID:"FrameReader",frameReaderType:1364477522,descVersion:1,"Lnk ":{_name:"",_classID:"ExternalFileLink",descVersion:2,"Nm ":n.frameReader.link.name,fullPath:n.frameReader.link.fullPath,originalPath:n.frameReader.link.originalPath,alis:n.frameReader.link.alias,relPath:n.frameReader.link.relativePath},mediaDescriptor:n.frameReader.mediaDescriptor},showAlteredVideo:n.showAlteredVideo};(0,w.writeVersionAndDescriptor)(e,"","PixelSource",i)});L("vstk",ae("vectorStroke"),(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);t.vectorStroke={strokeEnabled:i.strokeEnabled,fillEnabled:i.fillEnabled,lineWidth:(0,w.parseUnits)(i.strokeStyleLineWidth),lineDashOffset:(0,w.parseUnits)(i.strokeStyleLineDashOffset),miterLimit:i.strokeStyleMiterLimit,lineCapType:w.strokeStyleLineCapType.decode(i.strokeStyleLineCapType),lineJoinType:w.strokeStyleLineJoinType.decode(i.strokeStyleLineJoinType),lineAlignment:w.strokeStyleLineAlignment.decode(i.strokeStyleLineAlignment),scaleLock:i.strokeStyleScaleLock,strokeAdjust:i.strokeStyleStrokeAdjust,lineDashSet:i.strokeStyleLineDashSet.map(w.parseUnits),blendMode:w.BlnM.decode(i.strokeStyleBlendMode),opacity:(0,w.parsePercent)(i.strokeStyleOpacity),content:(0,w.parseVectorContent)(i.strokeStyleContent),resolution:i.strokeStyleResolution},(0,g.skipBytes)(e,n())},(e,t)=>{var n,i,o;let r=t.vectorStroke,s={strokeStyleVersion:2,strokeEnabled:!!r.strokeEnabled,fillEnabled:!!r.fillEnabled,strokeStyleLineWidth:r.lineWidth||{value:3,units:"Points"},strokeStyleLineDashOffset:r.lineDashOffset||{value:0,units:"Points"},strokeStyleMiterLimit:(n=r.miterLimit)!==null&&n!==void 0?n:100,strokeStyleLineCapType:w.strokeStyleLineCapType.encode(r.lineCapType),strokeStyleLineJoinType:w.strokeStyleLineJoinType.encode(r.lineJoinType),strokeStyleLineAlignment:w.strokeStyleLineAlignment.encode(r.lineAlignment),strokeStyleScaleLock:!!r.scaleLock,strokeStyleStrokeAdjust:!!r.strokeAdjust,strokeStyleLineDashSet:r.lineDashSet||[],strokeStyleBlendMode:w.BlnM.encode(r.blendMode),strokeStyleOpacity:(0,w.unitsPercent)((i=r.opacity)!==null&&i!==void 0?i:1),strokeStyleContent:(0,w.serializeVectorContent)(r.content||{type:"color",color:{r:0,g:0,b:0}}).descriptor,strokeStyleResolution:(o=r.resolution)!==null&&o!==void 0?o:72};(0,w.writeVersionAndDescriptor)(e,"","strokeStyle",s)});L("artb",ae("artboard"),(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e),o=i.artboardRect;t.artboard={rect:{top:o["Top "],left:o.Left,bottom:o.Btom,right:o.Rght},guideIndices:i.guideIndeces,presetName:i.artboardPresetName,color:(0,w.parseColor)(i["Clr "]),backgroundType:i.artboardBackgroundType},(0,g.skipBytes)(e,n())},(e,t)=>{var n;let i=t.artboard,o=i.rect,r={artboardRect:{"Top ":o.top,Left:o.left,Btom:o.bottom,Rght:o.right},guideIndeces:i.guideIndices||[],artboardPresetName:i.presetName||"","Clr ":(0,w.serializeColor)(i.color),artboardBackgroundType:(n=i.backgroundType)!==null&&n!==void 0?n:1};(0,w.writeVersionAndDescriptor)(e,"","artboard",r)});L("sn2P",ae("usingAlignedRendering"),(e,t)=>t.usingAlignedRendering=!!(0,g.readUint32)(e),(e,t)=>(0,y.writeUint32)(e,t.usingAlignedRendering?1:0));var Bn=["unknown","vector","raster","image stack"];function kc(e){var t,n,i,o,r,s;let a=Object.assign(Object.assign({style:w.warpStyle.decode(e.warpStyle)},e.warpValues?{values:e.warpValues}:{value:e.warpValue||0}),{perspective:e.warpPerspective||0,perspectiveOther:e.warpPerspectiveOther||0,rotate:w.Ornt.decode(e.warpRotate),bounds:e.bounds&&{top:(0,w.parseUnitsOrNumber)(e.bounds["Top "]),left:(0,w.parseUnitsOrNumber)(e.bounds.Left),bottom:(0,w.parseUnitsOrNumber)(e.bounds.Btom),right:(0,w.parseUnitsOrNumber)(e.bounds.Rght)},uOrder:e.uOrder,vOrder:e.vOrder});(e.deformNumRows!=null||e.deformNumCols!=null)&&(a.deformNumRows=e.deformNumRows,a.deformNumCols=e.deformNumCols);let l=e.customEnvelopeWarp;if(l){a.customEnvelopeWarp={meshPoints:[]};let c=((t=l.meshPoints.find(u=>u.type==="Hrzn"))===null||t===void 0?void 0:t.values)||[],d=((n=l.meshPoints.find(u=>u.type==="Vrtc"))===null||n===void 0?void 0:n.values)||[];for(let u=0;u<c.length;u++)a.customEnvelopeWarp.meshPoints.push({x:c[u],y:d[u]});(l.quiltSliceX||l.quiltSliceY)&&(a.customEnvelopeWarp.quiltSliceX=((o=(i=l.quiltSliceX)===null||i===void 0?void 0:i[0])===null||o===void 0?void 0:o.values)||[],a.customEnvelopeWarp.quiltSliceY=((s=(r=l.quiltSliceY)===null||r===void 0?void 0:r[0])===null||s===void 0?void 0:s.values)||[])}return a}function Wr(e){var t,n;return e.deformNumCols!=null||e.deformNumRows!=null||((t=e.customEnvelopeWarp)===null||t===void 0?void 0:t.quiltSliceX)||((n=e.customEnvelopeWarp)===null||n===void 0?void 0:n.quiltSliceY)}function mo(e){let t=e.bounds,n=Object.assign(Object.assign({warpStyle:w.warpStyle.encode(e.style)},e.values?{warpValues:e.values}:{warpValue:e.value||0}),{warpPerspective:e.perspective||0,warpPerspectiveOther:e.perspectiveOther||0,warpRotate:w.Ornt.encode(e.rotate),bounds:{"Top ":(0,w.unitsValue)(t&&t.top||{units:"Pixels",value:0},"bounds.top"),Left:(0,w.unitsValue)(t&&t.left||{units:"Pixels",value:0},"bounds.left"),Btom:(0,w.unitsValue)(t&&t.bottom||{units:"Pixels",value:0},"bounds.bottom"),Rght:(0,w.unitsValue)(t&&t.right||{units:"Pixels",value:0},"bounds.right")},uOrder:e.uOrder||0,vOrder:e.vOrder||0}),i=Wr(e);if(i){let r=n;r.deformNumRows=e.deformNumRows||0,r.deformNumCols=e.deformNumCols||0}let o=e.customEnvelopeWarp;if(o){let r=o.meshPoints||[];if(i){let s=n;s.customEnvelopeWarp={_name:"",_classID:"customEnvelopeWarp",quiltSliceX:[{type:"quiltSliceX",values:o.quiltSliceX||[]}],quiltSliceY:[{type:"quiltSliceY",values:o.quiltSliceY||[]}],meshPoints:[{type:"Hrzn",values:r.map(a=>a.x)},{type:"Vrtc",values:r.map(a=>a.y)}]}}else n.customEnvelopeWarp={_name:"",_classID:"customEnvelopeWarp",meshPoints:[{type:"Hrzn",values:r.map(s=>s.x)},{type:"Vrtc",values:r.map(s=>s.y)}]}}return n}L("PlLd",ae("placedLayer"),(e,t,n)=>{if((0,g.readSignature)(e)!=="plcL")throw new Error("Invalid PlLd signature");if((0,g.readInt32)(e)!==3)throw new Error("Invalid PlLd version");let i=(0,g.readPascalString)(e,1),o=(0,g.readInt32)(e),r=(0,g.readInt32)(e);(0,g.readInt32)(e);let s=(0,g.readInt32)(e);if(!Bn[s])throw new Error("Invalid PlLd type");let a=[];for(let d=0;d<8;d++)a.push((0,g.readFloat64)(e));let l=(0,g.readInt32)(e);if(l!==0)throw new Error(`Invalid Warp version ${l}`);let c=(0,w.readVersionAndDescriptor)(e);t.placedLayer=t.placedLayer||{id:i,type:Bn[s],pageNumber:o,totalPages:r,transform:a,warp:kc(c)},(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.placedLayer;if((0,y.writeSignature)(e,"plcL"),(0,y.writeInt32)(e,3),!n.id||typeof n.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(n.id))throw new Error("Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");if((0,y.writePascalString)(e,n.id,1),(0,y.writeInt32)(e,n.pageNumber||1),(0,y.writeInt32)(e,n.totalPages||1),(0,y.writeInt32)(e,16),Bn.indexOf(n.type)===-1)throw new Error("Invalid placedLayer type");(0,y.writeInt32)(e,Bn.indexOf(n.type));for(let s=0;s<8;s++)(0,y.writeFloat64)(e,n.transform[s]);(0,y.writeInt32)(e,0);let i=Ic(n),r=Wr(i)?"quiltWarp":"warp";(0,w.writeVersionAndDescriptor)(e,"",r,mo(i),r)});function S0(e){return new Float32Array(e.buffer.slice(e.byteOffset),0,e.byteLength/4)}function v0(e){return new Uint32Array(e.buffer.slice(e.byteOffset),0,e.byteLength/4)}function Nr(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function po(e){let t=[];for(let n=0;n<e.length;n+=2)t.push({x:e[n],y:e[n+1]});return t}function si(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].x,e[n].y);return t}function gc(e){return po(S0(e))}function ai(e){return{x:(0,w.parseUnits)(e.Hrzn),y:(0,w.parseUnits)(e.Vrtc)}}function li(e){return{_name:"",_classID:"Pnt ",Hrzn:(0,w.unitsValue)(e.x,"x"),Vrtc:(0,w.unitsValue)(e.y,"y")}}function x0(e,t){let n={name:e["Nm "],opacity:(0,w.parsePercent)(e.blendOptions.Opct),blendMode:w.BlnM.decode(e.blendOptions["Md "]),enabled:e.enab,hasOptions:e.hasoptions,foregroundColor:(0,w.parseColor)(e.FrgC),backgroundColor:(0,w.parseColor)(e.BckC)};if("Fltr"in e)switch(e.Fltr._classID){case"boxblur":return Object.assign(Object.assign({},n),{type:"box blur",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "])}});case"GsnB":return Object.assign(Object.assign({},n),{type:"gaussian blur",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "])}});case"MtnB":return Object.assign(Object.assign({},n),{type:"motion blur",filter:{angle:e.Fltr.Angl,distance:(0,w.parseUnits)(e.Fltr.Dstn)}});case"RdlB":return Object.assign(Object.assign({},n),{type:"radial blur",filter:{amount:e.Fltr.Amnt,method:w.BlrM.decode(e.Fltr.BlrM),quality:w.BlrQ.decode(e.Fltr.BlrQ)}});case"shapeBlur":return Object.assign(Object.assign({},n),{type:"shape blur",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "]),customShape:{name:e.Fltr.customShape["Nm "],id:e.Fltr.customShape.Idnt}}});case"SmrB":return Object.assign(Object.assign({},n),{type:"smart blur",filter:{radius:e.Fltr["Rds "],threshold:e.Fltr.Thsh,quality:w.SmBQ.decode(e.Fltr.SmBQ),mode:w.SmBM.decode(e.Fltr.SmBM)}});case"surfaceBlur":return Object.assign(Object.assign({},n),{type:"surface blur",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh}});case"Dspl":return Object.assign(Object.assign({},n),{type:"displace",filter:{horizontalScale:e.Fltr.HrzS,verticalScale:e.Fltr.VrtS,displacementMap:w.DspM.decode(e.Fltr.DspM),undefinedAreas:w.UndA.decode(e.Fltr.UndA),displacementFile:{signature:e.Fltr.DspF.sig,path:e.Fltr.DspF.path}}});case"Pnch":return Object.assign(Object.assign({},n),{type:"pinch",filter:{amount:e.Fltr.Amnt}});case"Plr ":return Object.assign(Object.assign({},n),{type:"polar coordinates",filter:{conversion:w.Cnvr.decode(e.Fltr.Cnvr)}});case"Rple":return Object.assign(Object.assign({},n),{type:"ripple",filter:{amount:e.Fltr.Amnt,size:w.RplS.decode(e.Fltr.RplS)}});case"Shr ":return Object.assign(Object.assign({},n),{type:"shear",filter:{shearPoints:e.Fltr.ShrP.map(i=>({x:i.Hrzn,y:i.Vrtc})),shearStart:e.Fltr.ShrS,shearEnd:e.Fltr.ShrE,undefinedAreas:w.UndA.decode(e.Fltr.UndA)}});case"Sphr":return Object.assign(Object.assign({},n),{type:"spherize",filter:{amount:e.Fltr.Amnt,mode:w.SphM.decode(e.Fltr.SphM)}});case"Twrl":return Object.assign(Object.assign({},n),{type:"twirl",filter:{angle:e.Fltr.Angl}});case"Wave":return Object.assign(Object.assign({},n),{type:"wave",filter:{numberOfGenerators:e.Fltr.NmbG,type:w.Wvtp.decode(e.Fltr.Wvtp),wavelength:{min:e.Fltr.WLMn,max:e.Fltr.WLMx},amplitude:{min:e.Fltr.AmMn,max:e.Fltr.AmMx},scale:{x:e.Fltr.SclH,y:e.Fltr.SclV},randomSeed:e.Fltr.RndS,undefinedAreas:w.UndA.decode(e.Fltr.UndA)}});case"ZgZg":return Object.assign(Object.assign({},n),{type:"zigzag",filter:{amount:e.Fltr.Amnt,ridges:e.Fltr.NmbR,style:w.ZZTy.decode(e.Fltr.ZZTy)}});case"AdNs":return Object.assign(Object.assign({},n),{type:"add noise",filter:{amount:(0,w.parsePercent)(e.Fltr.Nose),distribution:w.Dstr.decode(e.Fltr.Dstr),monochromatic:e.Fltr.Mnch,randomSeed:e.Fltr.FlRs}});case"DstS":return Object.assign(Object.assign({},n),{type:"dust and scratches",filter:{radius:e.Fltr["Rds "],threshold:e.Fltr.Thsh}});case"Mdn ":return Object.assign(Object.assign({},n),{type:"median",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "])}});case"denoise":return Object.assign(Object.assign({},n),{type:"reduce noise",filter:{preset:e.Fltr.preset,removeJpegArtifact:e.Fltr.removeJPEGArtifact,reduceColorNoise:(0,w.parsePercent)(e.Fltr.ClNs),sharpenDetails:(0,w.parsePercent)(e.Fltr.Shrp),channelDenoise:e.Fltr.channelDenoise.map(i=>Object.assign({channels:i.Chnl.map(w.Chnl.decode),amount:i.Amnt},i.EdgF?{preserveDetails:i.EdgF}:{}))}});case"ClrH":return Object.assign(Object.assign({},n),{type:"color halftone",filter:{radius:e.Fltr["Rds "],angle1:e.Fltr.Ang1,angle2:e.Fltr.Ang2,angle3:e.Fltr.Ang3,angle4:e.Fltr.Ang4}});case"Crst":return Object.assign(Object.assign({},n),{type:"crystallize",filter:{cellSize:e.Fltr.ClSz,randomSeed:e.Fltr.FlRs}});case"Mztn":return Object.assign(Object.assign({},n),{type:"mezzotint",filter:{type:w.MztT.decode(e.Fltr.MztT),randomSeed:e.Fltr.FlRs}});case"Msc ":return Object.assign(Object.assign({},n),{type:"mosaic",filter:{cellSize:(0,w.parseUnits)(e.Fltr.ClSz)}});case"Pntl":return Object.assign(Object.assign({},n),{type:"pointillize",filter:{cellSize:e.Fltr.ClSz,randomSeed:e.Fltr.FlRs}});case"Clds":return Object.assign(Object.assign({},n),{type:"clouds",filter:{randomSeed:e.Fltr.FlRs}});case"DfrC":return Object.assign(Object.assign({},n),{type:"difference clouds",filter:{randomSeed:e.Fltr.FlRs}});case"Fbrs":return Object.assign(Object.assign({},n),{type:"fibers",filter:{variance:e.Fltr.Vrnc,strength:e.Fltr.Strg,randomSeed:e.Fltr.RndS}});case"LnsF":return Object.assign(Object.assign({},n),{type:"lens flare",filter:{brightness:e.Fltr.Brgh,position:{x:e.Fltr.FlrC.Hrzn,y:e.Fltr.FlrC.Vrtc},lensType:w.Lns.decode(e.Fltr["Lns "])}});case"smartSharpen":return Object.assign(Object.assign({},n),{type:"smart sharpen",filter:{amount:(0,w.parsePercent)(e.Fltr.Amnt),radius:(0,w.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh,angle:e.Fltr.Angl,moreAccurate:e.Fltr.moreAccurate,blur:w.blurType.decode(e.Fltr.blur),preset:e.Fltr.preset,shadow:{fadeAmount:(0,w.parsePercent)(e.Fltr.sdwM.Amnt),tonalWidth:(0,w.parsePercent)(e.Fltr.sdwM.Wdth),radius:e.Fltr.sdwM["Rds "]},highlight:{fadeAmount:(0,w.parsePercent)(e.Fltr.hglM.Amnt),tonalWidth:(0,w.parsePercent)(e.Fltr.hglM.Wdth),radius:e.Fltr.hglM["Rds "]}}});case"UnsM":return Object.assign(Object.assign({},n),{type:"unsharp mask",filter:{amount:(0,w.parsePercent)(e.Fltr.Amnt),radius:(0,w.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh}});case"Dfs ":return Object.assign(Object.assign({},n),{type:"diffuse",filter:{mode:w.DfsM.decode(e.Fltr["Md "]),randomSeed:e.Fltr.FlRs}});case"Embs":return Object.assign(Object.assign({},n),{type:"emboss",filter:{angle:e.Fltr.Angl,height:e.Fltr.Hght,amount:e.Fltr.Amnt}});case"Extr":return Object.assign(Object.assign({},n),{type:"extrude",filter:{type:w.ExtT.decode(e.Fltr.ExtT),size:e.Fltr.ExtS,depth:e.Fltr.ExtD,depthMode:w.ExtR.decode(e.Fltr.ExtR),randomSeed:e.Fltr.FlRs,solidFrontFaces:e.Fltr.ExtF,maskIncompleteBlocks:e.Fltr.ExtM}});case"Tls ":return Object.assign(Object.assign({},n),{type:"tiles",filter:{numberOfTiles:e.Fltr.TlNm,maximumOffset:e.Fltr.TlOf,fillEmptyAreaWith:w.FlCl.decode(e.Fltr.FlCl),randomSeed:e.Fltr.FlRs}});case"TrcC":return Object.assign(Object.assign({},n),{type:"trace contour",filter:{level:e.Fltr["Lvl "],edge:w.CntE.decode(e.Fltr["Edg "])}});case"Wnd ":return Object.assign(Object.assign({},n),{type:"wind",filter:{method:w.WndM.decode(e.Fltr.WndM),direction:w.Drct.decode(e.Fltr.Drct)}});case"Dntr":return Object.assign(Object.assign({},n),{type:"de-interlace",filter:{eliminate:w.IntE.decode(e.Fltr.IntE),newFieldsBy:w.IntC.decode(e.Fltr.IntC)}});case"Cstm":return Object.assign(Object.assign({},n),{type:"custom",filter:{scale:e.Fltr["Scl "],offset:e.Fltr.Ofst,matrix:e.Fltr.Mtrx}});case"HghP":return Object.assign(Object.assign({},n),{type:"high pass",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "])}});case"Mxm ":return Object.assign(Object.assign({},n),{type:"maximum",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "])}});case"Mnm ":return Object.assign(Object.assign({},n),{type:"minimum",filter:{radius:(0,w.parseUnits)(e.Fltr["Rds "])}});case"Ofst":return Object.assign(Object.assign({},n),{type:"offset",filter:{horizontal:e.Fltr.Hrzn,vertical:e.Fltr.Vrtc,undefinedAreas:w.FlMd.decode(e.Fltr["Fl "])}});case"rigidTransform":return Object.assign(Object.assign({},n),{type:"puppet",filter:{rigidType:e.Fltr.rigidType,bounds:[{x:e.Fltr.PuX0,y:e.Fltr.PuY0},{x:e.Fltr.PuX1,y:e.Fltr.PuY1},{x:e.Fltr.PuX2,y:e.Fltr.PuY2},{x:e.Fltr.PuX3,y:e.Fltr.PuY3}],puppetShapeList:e.Fltr.puppetShapeList.map(i=>({rigidType:i.rigidType,originalVertexArray:gc(i.originalVertexArray),deformedVertexArray:gc(i.deformedVertexArray),indexArray:Array.from(v0(i.indexArray)),pinOffsets:po(i.pinOffsets),posFinalPins:po(i.posFinalPins),pinVertexIndices:i.pinVertexIndices,selectedPin:i.selectedPin,pinPosition:po(i.PinP),pinRotation:i.PnRt,pinOverlay:i.PnOv,pinDepth:i.PnDp,meshQuality:i.meshQuality,meshExpansion:i.meshExpansion,meshRigidity:i.meshRigidity,imageResolution:i.imageResolution,meshBoundaryPath:{pathComponents:i.meshBoundaryPath.pathComponents.map(o=>({shapeOperation:o.shapeOperation.split(".")[1],paths:o.SbpL.map(r=>({closed:r.Clsp,points:r["Pts "].map(s=>({anchor:ai(s.Anch),forward:ai(s["Fwd "]),backward:ai(s["Bwd "]),smooth:s.Smoo}))}))}))}}))}});case"PbPl":{let i=[],o=e.Fltr;for(let r=0;r<Xe.length&&o[`PN${Xe[r]}a`];r++)for(let s=0;s<Xe.length&&o[`PN${Xe[r]}${Xe[s]}`];s++)i.push({name:o[`PN${Xe[r]}${Xe[s]}`],value:o[`PF${Xe[r]}${Xe[s]}`]});return Object.assign(Object.assign({},n),{type:"oil paint plugin",filter:{name:e.Fltr.KnNm,gpu:e.Fltr.GpuY,lighting:e.Fltr.LIWy,parameters:i}})}case"HsbP":return Object.assign(Object.assign({},n),{type:"hsb/hsl",filter:{inputMode:w.ClrS.decode(e.Fltr.Inpt),rowOrder:w.ClrS.decode(e.Fltr.Otpt)}});case"oilPaint":return Object.assign(Object.assign({},n),{type:"oil paint",filter:{lightingOn:e.Fltr.lightingOn,stylization:e.Fltr.stylization,cleanliness:e.Fltr.cleanliness,brushScale:e.Fltr.brushScale,microBrush:e.Fltr.microBrush,lightDirection:e.Fltr.LghD,specularity:e.Fltr.specularity}});case"LqFy":return Object.assign(Object.assign({},n),{type:"liquify",filter:{liquifyMesh:e.Fltr.LqMe}});case"perspectiveWarpTransform":return Object.assign(Object.assign({},n),{type:"perspective warp",filter:{vertices:e.Fltr.vertices.map(ai),warpedVertices:e.Fltr.warpedVertices.map(ai),quads:e.Fltr.quads.map(i=>i.indices)}});case"Crvs":return Object.assign(Object.assign({},n),{type:"curves",filter:Object.assign({presetKind:w.presetKindType.decode(e.Fltr.presetKind)},e.Fltr.Adjs?{adjustments:e.Fltr.Adjs.map(i=>{let o=i.Chnl.map(w.Chnl.decode);if(i["Crv "])return{channels:o,curve:i["Crv "].map(r=>{let s={x:r.Hrzn,y:r.Vrtc};return r.Cnty&&(s.curved=!0),s})};if(i.Mpng)return{channels:o,values:i.Mpng};throw new Error("Unknown curve adjustment")})}:{})});case"BrgC":return Object.assign(Object.assign({},n),{type:"brightness/contrast",filter:{brightness:e.Fltr.Brgh,contrast:e.Fltr.Cntr,useLegacy:!!e.Fltr.useLegacy}});default:if(t.throwForMissingFeatures)throw new Error(`Unknown filter classId: ${e.Fltr._classID}`);return}else switch(e.filterID){case 1098281575:return Object.assign(Object.assign({},n),{type:"average"});case 1114403360:return Object.assign(Object.assign({},n),{type:"blur"});case 1114403405:return Object.assign(Object.assign({},n),{type:"blur more"});case 1148416099:return Object.assign(Object.assign({},n),{type:"despeckle"});case 1180922912:return Object.assign(Object.assign({},n),{type:"facet"});case 1181902701:return Object.assign(Object.assign({},n),{type:"fragment"});case 1399353968:return Object.assign(Object.assign({},n),{type:"sharpen"});case 1399353925:return Object.assign(Object.assign({},n),{type:"sharpen edges"});case 1399353933:return Object.assign(Object.assign({},n),{type:"sharpen more"});case 1181639749:return Object.assign(Object.assign({},n),{type:"find edges"});case 1399616122:return Object.assign(Object.assign({},n),{type:"solarize"});case 1314149187:return Object.assign(Object.assign({},n),{type:"ntsc colors"});case 1231976050:return Object.assign(Object.assign({},n),{type:"invert"});default:if(t.throwForMissingFeatures)throw new Error(`Unknown filterID: ${e.filterID}`)}}function _0(e,t){return{enabled:e.enab,validAtPosition:e.validAtPosition,maskEnabled:e.filterMaskEnable,maskLinked:e.filterMaskLinked,maskExtendWithWhite:e.filterMaskExtendWithWhite,list:e.filterFXList.map(n=>x0(n,t)).filter(n=>!!n)}}function wt(e){return(0,w.unitsValue)(e.radius,"radius")}function A0(e){let t={_name:"",_classID:"filterFX","Nm ":e.name,blendOptions:{_name:"",_classID:"blendOptions",Opct:(0,w.unitsPercentF)(e.opacity),"Md ":w.BlnM.encode(e.blendMode)},enab:e.enabled,hasoptions:e.hasOptions,FrgC:(0,w.serializeColor)(e.foregroundColor),BckC:(0,w.serializeColor)(e.backgroundColor)};switch(e.type){case"average":return Object.assign(Object.assign({},t),{filterID:1098281575});case"blur":return Object.assign(Object.assign({},t),{filterID:1114403360});case"blur more":return Object.assign(Object.assign({},t),{filterID:1114403405});case"box blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Box Blur",_classID:"boxblur","Rds ":wt(e.filter)},filterID:697});case"gaussian blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Gaussian Blur",_classID:"GsnB","Rds ":wt(e.filter)},filterID:1198747202});case"motion blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Motion Blur",_classID:"MtnB",Angl:e.filter.angle,Dstn:(0,w.unitsValue)(e.filter.distance,"distance")},filterID:1299476034});case"radial blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Radial Blur",_classID:"RdlB",Amnt:e.filter.amount,BlrM:w.BlrM.encode(e.filter.method),BlrQ:w.BlrQ.encode(e.filter.quality)},filterID:1382313026});case"shape blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Shape Blur",_classID:"shapeBlur","Rds ":wt(e.filter),customShape:{_name:"",_classID:"customShape","Nm ":e.filter.customShape.name,Idnt:e.filter.customShape.id}},filterID:702});case"smart blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Smart Blur",_classID:"SmrB","Rds ":e.filter.radius,Thsh:e.filter.threshold,SmBQ:w.SmBQ.encode(e.filter.quality),SmBM:w.SmBM.encode(e.filter.mode)},filterID:1399681602});case"surface blur":return Object.assign(Object.assign({},t),{Fltr:{_name:"Surface Blur",_classID:"surfaceBlur","Rds ":wt(e.filter),Thsh:e.filter.threshold},filterID:701});case"displace":return Object.assign(Object.assign({},t),{Fltr:{_name:"Displace",_classID:"Dspl",HrzS:e.filter.horizontalScale,VrtS:e.filter.verticalScale,DspM:w.DspM.encode(e.filter.displacementMap),UndA:w.UndA.encode(e.filter.undefinedAreas),DspF:{sig:e.filter.displacementFile.signature,path:e.filter.displacementFile.path}},filterID:1148416108});case"pinch":return Object.assign(Object.assign({},t),{Fltr:{_name:"Pinch",_classID:"Pnch",Amnt:e.filter.amount},filterID:1349411688});case"polar coordinates":return Object.assign(Object.assign({},t),{Fltr:{_name:"Polar Coordinates",_classID:"Plr ",Cnvr:w.Cnvr.encode(e.filter.conversion)},filterID:1349284384});case"ripple":return Object.assign(Object.assign({},t),{Fltr:{_name:"Ripple",_classID:"Rple",Amnt:e.filter.amount,RplS:w.RplS.encode(e.filter.size)},filterID:1383099493});case"shear":return Object.assign(Object.assign({},t),{Fltr:{_name:"Shear",_classID:"Shr ",ShrP:e.filter.shearPoints.map(n=>({_name:"",_classID:"Pnt ",Hrzn:n.x,Vrtc:n.y})),UndA:w.UndA.encode(e.filter.undefinedAreas),ShrS:e.filter.shearStart,ShrE:e.filter.shearEnd},filterID:1399353888});case"spherize":return Object.assign(Object.assign({},t),{Fltr:{_name:"Spherize",_classID:"Sphr",Amnt:e.filter.amount,SphM:w.SphM.encode(e.filter.mode)},filterID:1399875698});case"twirl":return Object.assign(Object.assign({},t),{Fltr:{_name:"Twirl",_classID:"Twrl",Angl:e.filter.angle},filterID:1417114220});case"wave":return Object.assign(Object.assign({},t),{Fltr:{_name:"Wave",_classID:"Wave",Wvtp:w.Wvtp.encode(e.filter.type),NmbG:e.filter.numberOfGenerators,WLMn:e.filter.wavelength.min,WLMx:e.filter.wavelength.max,AmMn:e.filter.amplitude.min,AmMx:e.filter.amplitude.max,SclH:e.filter.scale.x,SclV:e.filter.scale.y,UndA:w.UndA.encode(e.filter.undefinedAreas),RndS:e.filter.randomSeed},filterID:1466005093});case"zigzag":return Object.assign(Object.assign({},t),{Fltr:{_name:"ZigZag",_classID:"ZgZg",Amnt:e.filter.amount,NmbR:e.filter.ridges,ZZTy:w.ZZTy.encode(e.filter.style)},filterID:1516722791});case"add noise":return Object.assign(Object.assign({},t),{Fltr:{_name:"Add Noise",_classID:"AdNs",Dstr:w.Dstr.encode(e.filter.distribution),Nose:(0,w.unitsPercentF)(e.filter.amount),Mnch:e.filter.monochromatic,FlRs:e.filter.randomSeed},filterID:1097092723});case"despeckle":return Object.assign(Object.assign({},t),{filterID:1148416099});case"dust and scratches":return Object.assign(Object.assign({},t),{Fltr:{_name:"Dust & Scratches",_classID:"DstS","Rds ":e.filter.radius,Thsh:e.filter.threshold},filterID:1148417107});case"median":return Object.assign(Object.assign({},t),{Fltr:{_name:"Median",_classID:"Mdn ","Rds ":wt(e.filter)},filterID:1298427424});case"reduce noise":return Object.assign(Object.assign({},t),{Fltr:{_name:"Reduce Noise",_classID:"denoise",ClNs:(0,w.unitsPercentF)(e.filter.reduceColorNoise),Shrp:(0,w.unitsPercentF)(e.filter.sharpenDetails),removeJPEGArtifact:e.filter.removeJpegArtifact,channelDenoise:e.filter.channelDenoise.map(n=>Object.assign({_name:"",_classID:"channelDenoiseParams",Chnl:n.channels.map(i=>w.Chnl.encode(i)),Amnt:n.amount},n.preserveDetails?{EdgF:n.preserveDetails}:{})),preset:e.filter.preset},filterID:633});case"color halftone":return Object.assign(Object.assign({},t),{Fltr:{_name:"Color Halftone",_classID:"ClrH","Rds ":e.filter.radius,Ang1:e.filter.angle1,Ang2:e.filter.angle2,Ang3:e.filter.angle3,Ang4:e.filter.angle4},filterID:1131180616});case"crystallize":return Object.assign(Object.assign({},t),{Fltr:{_name:"Crystallize",_classID:"Crst",ClSz:e.filter.cellSize,FlRs:e.filter.randomSeed},filterID:1131574132});case"facet":return Object.assign(Object.assign({},t),{filterID:1180922912});case"fragment":return Object.assign(Object.assign({},t),{filterID:1181902701});case"mezzotint":return Object.assign(Object.assign({},t),{Fltr:{_name:"Mezzotint",_classID:"Mztn",MztT:w.MztT.encode(e.filter.type),FlRs:e.filter.randomSeed},filterID:1299870830});case"mosaic":return Object.assign(Object.assign({},t),{Fltr:{_name:"Mosaic",_classID:"Msc ",ClSz:(0,w.unitsValue)(e.filter.cellSize,"cellSize")},filterID:1299407648});case"pointillize":return Object.assign(Object.assign({},t),{Fltr:{_name:"Pointillize",_classID:"Pntl",ClSz:e.filter.cellSize,FlRs:e.filter.randomSeed},filterID:1349416044});case"clouds":return Object.assign(Object.assign({},t),{Fltr:{_name:"Clouds",_classID:"Clds",FlRs:e.filter.randomSeed},filterID:1131177075});case"difference clouds":return Object.assign(Object.assign({},t),{Fltr:{_name:"Difference Clouds",_classID:"DfrC",FlRs:e.filter.randomSeed},filterID:1147564611});case"fibers":return Object.assign(Object.assign({},t),{Fltr:{_name:"Fibers",_classID:"Fbrs",Vrnc:e.filter.variance,Strg:e.filter.strength,RndS:e.filter.randomSeed},filterID:1180856947});case"lens flare":return Object.assign(Object.assign({},t),{Fltr:{_name:"Lens Flare",_classID:"LnsF",Brgh:e.filter.brightness,FlrC:{_name:"",_classID:"Pnt ",Hrzn:e.filter.position.x,Vrtc:e.filter.position.y},"Lns ":w.Lns.encode(e.filter.lensType)},filterID:1282306886});case"sharpen":return Object.assign(Object.assign({},t),{filterID:1399353968});case"sharpen edges":return Object.assign(Object.assign({},t),{filterID:1399353925});case"sharpen more":return Object.assign(Object.assign({},t),{filterID:1399353933});case"smart sharpen":return Object.assign(Object.assign({},t),{Fltr:{_name:"Smart Sharpen",_classID:"smartSharpen",Amnt:(0,w.unitsPercentF)(e.filter.amount),"Rds ":wt(e.filter),Thsh:e.filter.threshold,Angl:e.filter.angle,moreAccurate:e.filter.moreAccurate,blur:w.blurType.encode(e.filter.blur),preset:e.filter.preset,sdwM:{_name:"Parameters",_classID:"adaptCorrectTones",Amnt:(0,w.unitsPercentF)(e.filter.shadow.fadeAmount),Wdth:(0,w.unitsPercentF)(e.filter.shadow.tonalWidth),"Rds ":e.filter.shadow.radius},hglM:{_name:"Parameters",_classID:"adaptCorrectTones",Amnt:(0,w.unitsPercentF)(e.filter.highlight.fadeAmount),Wdth:(0,w.unitsPercentF)(e.filter.highlight.tonalWidth),"Rds ":e.filter.highlight.radius}},filterID:698});case"unsharp mask":return Object.assign(Object.assign({},t),{Fltr:{_name:"Unsharp Mask",_classID:"UnsM",Amnt:(0,w.unitsPercentF)(e.filter.amount),"Rds ":wt(e.filter),Thsh:e.filter.threshold},filterID:1433301837});case"diffuse":return Object.assign(Object.assign({},t),{Fltr:{_name:"Diffuse",_classID:"Dfs ","Md ":w.DfsM.encode(e.filter.mode),FlRs:e.filter.randomSeed},filterID:1147564832});case"emboss":return Object.assign(Object.assign({},t),{Fltr:{_name:"Emboss",_classID:"Embs",Angl:e.filter.angle,Hght:e.filter.height,Amnt:e.filter.amount},filterID:1164796531});case"extrude":return Object.assign(Object.assign({},t),{Fltr:{_name:"Extrude",_classID:"Extr",ExtS:e.filter.size,ExtD:e.filter.depth,ExtF:e.filter.solidFrontFaces,ExtM:e.filter.maskIncompleteBlocks,ExtT:w.ExtT.encode(e.filter.type),ExtR:w.ExtR.encode(e.filter.depthMode),FlRs:e.filter.randomSeed},filterID:1165522034});case"find edges":return Object.assign(Object.assign({},t),{filterID:1181639749});case"solarize":return Object.assign(Object.assign({},t),{filterID:1399616122});case"tiles":return Object.assign(Object.assign({},t),{Fltr:{_name:"Tiles",_classID:"Tls ",TlNm:e.filter.numberOfTiles,TlOf:e.filter.maximumOffset,FlCl:w.FlCl.encode(e.filter.fillEmptyAreaWith),FlRs:e.filter.randomSeed},filterID:1416393504});case"trace contour":return Object.assign(Object.assign({},t),{Fltr:{_name:"Trace Contour",_classID:"TrcC","Lvl ":e.filter.level,"Edg ":w.CntE.encode(e.filter.edge)},filterID:1416782659});case"wind":return Object.assign(Object.assign({},t),{Fltr:{_name:"Wind",_classID:"Wnd ",WndM:w.WndM.encode(e.filter.method),Drct:w.Drct.encode(e.filter.direction)},filterID:1466852384});case"de-interlace":return Object.assign(Object.assign({},t),{Fltr:{_name:"De-Interlace",_classID:"Dntr",IntE:w.IntE.encode(e.filter.eliminate),IntC:w.IntC.encode(e.filter.newFieldsBy)},filterID:1148089458});case"ntsc colors":return Object.assign(Object.assign({},t),{filterID:1314149187});case"invert":return Object.assign(Object.assign({},t),{filterID:1231976050});case"custom":return Object.assign(Object.assign({},t),{Fltr:{_name:"Custom",_classID:"Cstm","Scl ":e.filter.scale,Ofst:e.filter.offset,Mtrx:e.filter.matrix},filterID:1131639917});case"high pass":return Object.assign(Object.assign({},t),{Fltr:{_name:"High Pass",_classID:"HghP","Rds ":wt(e.filter)},filterID:1214736464});case"maximum":return Object.assign(Object.assign({},t),{Fltr:{_name:"Maximum",_classID:"Mxm ","Rds ":wt(e.filter)},filterID:1299737888});case"minimum":return Object.assign(Object.assign({},t),{Fltr:{_name:"Minimum",_classID:"Mnm ","Rds ":wt(e.filter)},filterID:1299082528});case"offset":return Object.assign(Object.assign({},t),{Fltr:{_name:"Offset",_classID:"Ofst",Hrzn:e.filter.horizontal,Vrtc:e.filter.vertical,"Fl ":w.FlMd.encode(e.filter.undefinedAreas)},filterID:1332114292});case"puppet":return Object.assign(Object.assign({},t),{Fltr:{_name:"Rigid Transform",_classID:"rigidTransform",null:["Ordn.Trgt"],rigidType:e.filter.rigidType,puppetShapeList:e.filter.puppetShapeList.map(n=>({_name:"",_classID:"puppetShape",rigidType:n.rigidType,VrsM:1,VrsN:0,originalVertexArray:Nr(new Float32Array(si(n.originalVertexArray))),deformedVertexArray:Nr(new Float32Array(si(n.deformedVertexArray))),indexArray:Nr(new Uint32Array(n.indexArray)),pinOffsets:si(n.pinOffsets),posFinalPins:si(n.posFinalPins),pinVertexIndices:n.pinVertexIndices,PinP:si(n.pinPosition),PnRt:n.pinRotation,PnOv:n.pinOverlay,PnDp:n.pinDepth,meshQuality:n.meshQuality,meshExpansion:n.meshExpansion,meshRigidity:n.meshRigidity,imageResolution:n.imageResolution,meshBoundaryPath:{_name:"",_classID:"pathClass",pathComponents:n.meshBoundaryPath.pathComponents.map(i=>({_name:"",_classID:"PaCm",shapeOperation:`shapeOperation.${i.shapeOperation}`,SbpL:i.paths.map(o=>({_name:"",_classID:"Sbpl",Clsp:o.closed,"Pts ":o.points.map(r=>({_name:"",_classID:"Pthp",Anch:li(r.anchor),"Fwd ":li(r.forward),"Bwd ":li(r.backward),Smoo:r.smooth}))}))}))},selectedPin:n.selectedPin})),PuX0:e.filter.bounds[0].x,PuX1:e.filter.bounds[1].x,PuX2:e.filter.bounds[2].x,PuX3:e.filter.bounds[3].x,PuY0:e.filter.bounds[0].y,PuY1:e.filter.bounds[1].y,PuY2:e.filter.bounds[2].y,PuY3:e.filter.bounds[3].y},filterID:991});case"oil paint plugin":{let n={};for(let i=0;i<e.filter.parameters.length;i++){let{name:o,value:r}=e.filter.parameters[i],s=`${Xe[Math.floor(i/Xe.length)]}${Xe[i%Xe.length]}`;n[`PN${s}`]=o,n[`PT${s}`]=0,n[`PF${s}`]=r}return Object.assign(Object.assign({},t),{Fltr:Object.assign({_name:"Oil Paint Plugin",_classID:"PbPl",KnNm:e.filter.name,GpuY:e.filter.gpu,LIWy:e.filter.lighting,FPth:"1"},n),filterID:1348620396})}case"oil paint":return Object.assign(Object.assign({},t),{Fltr:{_name:"Oil Paint",_classID:"oilPaint",lightingOn:e.filter.lightingOn,stylization:e.filter.stylization,cleanliness:e.filter.cleanliness,brushScale:e.filter.brushScale,microBrush:e.filter.microBrush,LghD:e.filter.lightDirection,specularity:e.filter.specularity},filterID:1122});case"liquify":return Object.assign(Object.assign({},t),{Fltr:{_name:"Liquify",_classID:"LqFy",LqMe:e.filter.liquifyMesh},filterID:1282492025});case"perspective warp":return Object.assign(Object.assign({},t),{Fltr:{_name:"Perspective Warp",_classID:"perspectiveWarpTransform",vertices:e.filter.vertices.map(li),warpedVertices:e.filter.warpedVertices.map(li),quads:e.filter.quads.map(n=>({indices:n}))},filterID:442});case"curves":return Object.assign(Object.assign({},t),{Fltr:Object.assign({_name:"Curves",_classID:"Crvs",presetKind:w.presetKindType.encode(e.filter.presetKind)},e.filter.adjustments?{Adjs:e.filter.adjustments.map(n=>"curve"in n?{_name:"",_classID:"CrvA",Chnl:n.channels.map(w.Chnl.encode),"Crv ":n.curve.map(i=>Object.assign({_name:"",_classID:"Pnt ",Hrzn:i.x,Vrtc:i.y},i.curved?{Cnty:!0}:{}))}:{_name:"",_classID:"CrvA",Chnl:n.channels.map(w.Chnl.encode),Mpng:n.values})}:{}),filterID:1131574899});case"brightness/contrast":return Object.assign(Object.assign({},t),{Fltr:{_name:"Brightness/Contrast",_classID:"BrgC",Brgh:e.filter.brightness,Cntr:e.filter.contrast,useLegacy:!!e.filter.useLegacy},filterID:1114793795});default:throw new Error(`Unknow filter type: ${e.type}`)}}function Ic(e){if(e.warp)return e.warp;if(!e.width||!e.height)throw new Error("You must provide width and height of the linked image in placedLayer");let t=e.width,n=e.height,i=0,o=t/3,r=t*2/3,s=t,a=0,l=n/3,c=n*2/3,d=n;return{style:"custom",value:0,perspective:0,perspectiveOther:0,rotate:"horizontal",bounds:{top:{value:0,units:"Pixels"},left:{value:0,units:"Pixels"},bottom:{value:n,units:"Pixels"},right:{value:t,units:"Pixels"}},uOrder:4,vOrder:4,customEnvelopeWarp:{meshPoints:[{x:i,y:a},{x:o,y:a},{x:r,y:a},{x:s,y:a},{x:i,y:l},{x:o,y:l},{x:r,y:l},{x:s,y:l},{x:i,y:c},{x:o,y:c},{x:r,y:c},{x:s,y:c},{x:i,y:d},{x:o,y:d},{x:r,y:d},{x:s,y:d}]}}}L("SoLd",ae("placedLayer"),(e,t,n)=>{if((0,g.readSignature)(e)!=="soLD")throw new Error("Invalid SoLd type");let i=(0,g.readInt32)(e);if(i!==4&&i!==5)throw new Error("Invalid SoLd version");let o=(0,w.readVersionAndDescriptor)(e,!0);t.placedLayer={id:o.Idnt,placed:o.placed,type:Bn[o.Type],pageNumber:o.PgNm,totalPages:o.totalPages,frameStep:(0,w.frac)(o.frameStep),duration:(0,w.frac)(o.duration),frameCount:o.frameCount,transform:o.Trnf,width:o["Sz "].Wdth,height:o["Sz "].Hght,resolution:(0,w.parseUnits)(o.Rslt),warp:kc(o.quiltWarp||o.warp)},o.nonAffineTransform&&o.nonAffineTransform.some((r,s)=>r!==o.Trnf[s])&&(t.placedLayer.nonAffineTransform=o.nonAffineTransform),o.Crop&&(t.placedLayer.crop=o.Crop),o.comp&&(t.placedLayer.comp=o.comp),o.compInfo&&(t.placedLayer.compInfo={compID:o.compInfo.compID,originalCompID:o.compInfo.originalCompID}),o.filterFX&&(t.placedLayer.filter=_0(o.filterFX,e)),(0,g.skipBytes)(e,n())},(e,t)=>{var n,i;(0,y.writeSignature)(e,"soLD"),(0,y.writeInt32)(e,4);let o=t.placedLayer;if(!o.id||typeof o.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(o.id))throw new Error("Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");let r=Object.assign(Object.assign({Idnt:o.id,placed:(n=o.placed)!==null&&n!==void 0?n:o.id,PgNm:o.pageNumber||1,totalPages:o.totalPages||1},o.crop?{Crop:o.crop}:{}),{frameStep:o.frameStep||{numerator:0,denominator:600},duration:o.duration||{numerator:0,denominator:600},frameCount:o.frameCount||0,Annt:16,Type:Bn.indexOf(o.type),Trnf:o.transform,nonAffineTransform:(i=o.nonAffineTransform)!==null&&i!==void 0?i:o.transform,warp:mo(Ic(o)),"Sz ":{_name:"",_classID:"Pnt ",Wdth:o.width||0,Hght:o.height||0},Rslt:o.resolution?(0,w.unitsValue)(o.resolution,"resolution"):{units:"Density",value:72}});if(o.filter&&(r.filterFX={_name:"",_classID:"filterFXStyle",enab:o.filter.enabled,validAtPosition:o.filter.validAtPosition,filterMaskEnable:o.filter.maskEnabled,filterMaskLinked:o.filter.maskLinked,filterMaskExtendWithWhite:o.filter.maskExtendWithWhite,filterFXList:o.filter.list.map(s=>A0(s))}),o.warp&&Wr(o.warp)){let s=mo(o.warp);r.quiltWarp=s,r.warp={warpStyle:"warpStyle.warpNone",warpValue:s.warpValue,warpPerspective:s.warpPerspective,warpPerspectiveOther:s.warpPerspectiveOther,warpRotate:s.warpRotate,bounds:s.bounds,uOrder:s.uOrder,vOrder:s.vOrder}}else delete r.quiltWarp;o.comp&&(r.comp=o.comp),o.compInfo&&(r.compInfo=o.compInfo),(0,w.writeVersionAndDescriptor)(e,"","null",r,r.quiltWarp?"quiltWarp":"warp")});Gt("SoLE","SoLd");L("fxrp",ae("referencePoint"),(e,t)=>{t.referencePoint={x:(0,g.readFloat64)(e),y:(0,g.readFloat64)(e)}},(e,t)=>{(0,y.writeFloat64)(e,t.referencePoint.x),(0,y.writeFloat64)(e,t.referencePoint.y)});L("Lr16",()=>!1,(e,t,n,i,o)=>{(0,g.readLayerInfo)(e,i,o)},(e,t)=>{});L("Lr32",()=>!1,(e,t,n,i,o)=>{(0,g.readLayerInfo)(e,i,o)},(e,t)=>{});L("LMsk",ae("userMask"),(e,t)=>{if(t.userMask={colorSpace:(0,g.readColor)(e),opacity:(0,g.readUint16)(e)/255},(0,g.readUint8)(e)!==128)throw new Error("Invalid flag value");(0,g.skipBytes)(e,1)},(e,t)=>{let n=t.userMask;(0,y.writeColor)(e,n.colorSpace),(0,y.writeUint16)(e,(0,Ze.clamp)(n.opacity,0,1)*255),(0,y.writeUint8)(e,128),(0,y.writeZeros)(e,1)});Ze.MOCK_HANDLERS?L("Patt",e=>e._Patt!==void 0,(e,t,n)=>{t._Patt=(0,g.readBytes)(e,n())},(e,t)=>!1):L("Patt",e=>!!(e.patterns&&e.patterns.length>0),(e,t,n)=>{for(;n()>0;){let i=(0,g.readPattern)(e);t.patterns===void 0&&(t.patterns=[]),t.patterns.push(i)}},(e,t,n,i)=>{let o=t.patterns||[];for(let r of o)(0,y.writePattern)(e,r)});Gt("Pat2","Patt");Gt("Pat3","Patt");Ze.MOCK_HANDLERS&&L("CAI ",e=>e._CAI_!==void 0,(e,t,n)=>{t._CAI_=(0,g.readBytes)(e,n())},(e,t)=>{(0,y.writeBytes)(e,t._CAI_)});Ze.MOCK_HANDLERS&&L("OCIO",e=>e._OCIO!==void 0,(e,t,n)=>{t._OCIO=(0,g.readBytes)(e,n())},(e,t)=>{(0,y.writeBytes)(e,t._OCIO)});Ze.MOCK_HANDLERS&&L("GenI",e=>e._GenI!==void 0,(e,t,n)=>{t._GenI=(0,g.readBytes)(e,n())},(e,t)=>{(0,y.writeBytes)(e,t._GenI)});function bc(e){let t=(0,g.readInt32)(e),n=(0,g.readInt32)(e),i=(0,g.readInt32)(e),o=(0,g.readInt32)(e);return{top:t,left:n,bottom:i,right:o}}function yc(e,t){(0,y.writeInt32)(e,t.top),(0,y.writeInt32)(e,t.left),(0,y.writeInt32)(e,t.bottom),(0,y.writeInt32)(e,t.right)}L("Anno",e=>e.annotations!==void 0,(e,t,n)=>{let i=(0,g.readUint16)(e),o=(0,g.readUint16)(e);if(i!==2||o!==1)throw new Error("Invalid Anno version");let r=(0,g.readUint32)(e),s=[];for(let a=0;a<r;a++){(0,g.readUint32)(e);let l=(0,g.readSignature)(e),c=!!(0,g.readUint8)(e);(0,g.readUint8)(e),(0,g.readUint16)(e);let d=bc(e),u=bc(e),f=(0,g.readColor)(e),h=(0,g.readPascalString)(e,2),p=(0,g.readPascalString)(e,2),S=(0,g.readPascalString)(e,2);(0,g.readUint32)(e),(0,g.readSignature)(e);let m=(0,g.readUint32)(e),b;if(l==="txtA")m>=2&&(0,g.readUint16)(e)===65279?b=(0,g.readUnicodeStringWithLength)(e,(m-2)/2):(e.offset-=2,b=(0,g.readAsciiString)(e,m)),b=b.replace(/\r/g,`
11
- `);else if(l==="sndA")b=(0,g.readBytes)(e,m);else throw new Error("Unknown annotation type");s.push({type:l==="txtA"?"text":"sound",open:c,iconLocation:d,popupLocation:u,color:f,author:h,name:p,date:S,data:b})}t.annotations=s,(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.annotations;(0,y.writeUint16)(e,2),(0,y.writeUint16)(e,1),(0,y.writeUint32)(e,n.length);for(let i of n){let o=i.type==="sound";if(o&&!(i.data instanceof Uint8Array))throw new Error("Sound annotation data should be Uint8Array");if(!o&&typeof i.data!="string")throw new Error("Text annotation data should be string");let r=e.offset;(0,y.writeUint32)(e,0),(0,y.writeSignature)(e,o?"sndA":"txtA"),(0,y.writeUint8)(e,i.open?1:0),(0,y.writeUint8)(e,28),(0,y.writeUint16)(e,1),yc(e,i.iconLocation),yc(e,i.popupLocation),(0,y.writeColor)(e,i.color),(0,y.writePascalString)(e,i.author||"",2),(0,y.writePascalString)(e,i.name||"",2),(0,y.writePascalString)(e,i.date||"",2);let s=e.offset;(0,y.writeUint32)(e,0),(0,y.writeSignature)(e,o?"sndM":"txtC"),(0,y.writeUint32)(e,0);let a=e.offset;if(o)(0,y.writeBytes)(e,i.data);else{(0,y.writeUint16)(e,65279);let l=i.data.replace(/\n/g,"\r");for(let c=0;c<l.length;c++)(0,y.writeUint16)(e,l.charCodeAt(c))}e.view.setUint32(r,e.offset-r,!1),e.view.setUint32(s,e.offset-s,!1),e.view.setUint32(a-4,e.offset-a,!1)}});function Dc(e){L(e,t=>{let n=t;return!(!n.linkedFiles||!n.linkedFiles.length||e==="lnkE"&&!n.linkedFiles.some(i=>i.linkedFile))},(t,n,i,o)=>{let r=n;for(r.linkedFiles=r.linkedFiles||[];i()>8;){let s=zr(t),a=t.offset,l=(0,g.readSignature)(t),c=(0,g.readInt32)(t),d=(0,g.readPascalString)(t,1),u=(0,g.readUnicodeString)(t),f=(0,g.readSignature)(t).trim(),h=(0,g.readSignature)(t).trim(),p=zr(t),m=(0,g.readUint8)(t)?(0,w.readVersionAndDescriptor)(t):void 0,b=l==="liFE"?(0,w.readVersionAndDescriptor)(t):void 0,v={id:d,name:u};if(f&&(v.type=f),h&&(v.creator=h),m&&(v.descriptor={compInfo:{compID:m.compInfo.compID,originalCompID:m.compInfo.originalCompID}}),l==="liFE"&&c>3){let _=(0,g.readInt32)(t),I=(0,g.readUint8)(t),P=(0,g.readUint8)(t),k=(0,g.readUint8)(t),E=(0,g.readUint8)(t),O=(0,g.readFloat64)(t),U=Math.floor(O),M=(O-U)*1e3;v.time=new Date(Date.UTC(_,I,P,k,E,U,M)).toISOString()}let x=l==="liFE"?zr(t):0;for(l==="liFA"&&(0,g.skipBytes)(t,8),l==="liFD"&&(v.data=(0,g.readBytes)(t,p)),c>=5&&(v.childDocumentID=(0,g.readUnicodeString)(t)),c>=6&&(v.assetModTime=(0,g.readFloat64)(t)),c>=7&&(v.assetLockedState=(0,g.readUint8)(t)),l==="liFE"&&c===2&&(v.data=(0,g.readBytes)(t,x)),t.skipLinkedFilesData&&(v.data=void 0),e==="lnkE"&&(v.linkedFile={fileSize:x,name:b?.["Nm "]||"",fullPath:b?.fullPath||"",originalPath:b?.originalPath||"",relativePath:b?.relPath||""}),r.linkedFiles.push(v);s%4;)s++;t.offset=a+s}(0,g.skipBytes)(t,i())},(t,n)=>{var i,o,r,s,a,l,c,d,u;let f=n;for(let h of f.linkedFiles){if(e==="lnkE"!=!!h.linkedFile)continue;let p=2;h.assetLockedState!=null?p=7:h.assetModTime!=null?p=6:h.childDocumentID!=null?p=5:e==="lnkE"&&(p=3),$r(t,0);let S=t.offset;if((0,y.writeSignature)(t,e==="lnkE"?"liFE":h.data?"liFD":"liFA"),(0,y.writeInt32)(t,p),!h.id||typeof h.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(h.id))throw new Error("Linked file ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");if((0,y.writePascalString)(t,h.id,1),(0,y.writeUnicodeStringWithPadding)(t,h.name||""),(0,y.writeSignature)(t,h.type?`${h.type} `.substring(0,4):" "),(0,y.writeSignature)(t,h.creator?`${h.creator} `.substring(0,4):"\0\0\0\0"),$r(t,h.data?h.data.byteLength:0),h.descriptor&&h.descriptor.compInfo){let b={compInfo:{compID:h.descriptor.compInfo.compID,originalCompID:h.descriptor.compInfo.originalCompID}};(0,y.writeUint8)(t,1),(0,w.writeVersionAndDescriptor)(t,"","null",b)}else(0,y.writeUint8)(t,0);if(e==="lnkE"){let b={descVersion:2,"Nm ":(o=(i=h.linkedFile)===null||i===void 0?void 0:i.name)!==null&&o!==void 0?o:"",fullPath:(s=(r=h.linkedFile)===null||r===void 0?void 0:r.fullPath)!==null&&s!==void 0?s:"",originalPath:(l=(a=h.linkedFile)===null||a===void 0?void 0:a.originalPath)!==null&&l!==void 0?l:"",relPath:(d=(c=h.linkedFile)===null||c===void 0?void 0:c.relativePath)!==null&&d!==void 0?d:""};(0,w.writeVersionAndDescriptor)(t,"","ExternalFileLink",b);let v=h.time?new Date(h.time):new Date;(0,y.writeInt32)(t,v.getUTCFullYear()),(0,y.writeUint8)(t,v.getUTCMonth()),(0,y.writeUint8)(t,v.getUTCDate()),(0,y.writeUint8)(t,v.getUTCHours()),(0,y.writeUint8)(t,v.getUTCMinutes()),(0,y.writeFloat64)(t,v.getUTCSeconds()+v.getUTCMilliseconds()/1e3)}h.data?(0,y.writeBytes)(t,h.data):$r(t,((u=h.linkedFile)===null||u===void 0?void 0:u.fileSize)||0),p>=5&&(0,y.writeUnicodeStringWithPadding)(t,h.childDocumentID||""),p>=6&&(0,y.writeFloat64)(t,h.assetModTime||0),p>=7&&(0,y.writeUint8)(t,h.assetLockedState||0);let m=t.offset-S;for(t.view.setUint32(S-4,m,!1);m%4;)m++,(0,y.writeUint8)(t,0)}})}Dc("lnk2");Dc("lnkE");Gt("lnkD","lnk2");Gt("lnk3","lnk2");L("pths",ae("pathList"),(e,t)=>{(0,w.readVersionAndDescriptor)(e,!0),t.pathList=[]},(e,t)=>{let n={pathList:[]};(0,w.writeVersionAndDescriptor)(e,"","pathsDataClass",n)});L("lyvr",ae("version"),(e,t)=>t.version=(0,g.readUint32)(e),(e,t)=>(0,y.writeUint32)(e,t.version));L("lfxs",()=>!1,(e,t,n)=>{if((0,g.readUint32)(e)!==0)throw new Error("Invalid lfxs version");let o=(0,w.readVersionAndDescriptor)(e);t.effects=(0,w.parseEffects)(o,!!e.logMissingFeatures),(0,g.skipBytes)(e,n())},(e,t,n,i)=>{let o=(0,w.serializeEffects)(t.effects,!!i.logMissingFeatures,!0);(0,y.writeUint32)(e,0),(0,w.writeVersionAndDescriptor)(e,"","null",o)});function Fe(e){return t=>!!t.adjustment&&t.adjustment.type===e}L("brit",Fe("brightness/contrast"),(e,t,n)=>{t.adjustment||(t.adjustment={type:"brightness/contrast",brightness:(0,g.readInt16)(e),contrast:(0,g.readInt16)(e),meanValue:(0,g.readInt16)(e),labColorOnly:!!(0,g.readUint8)(e),useLegacy:!0}),(0,g.skipBytes)(e,n())},(e,t)=>{var n;let i=t.adjustment;(0,y.writeInt16)(e,i.brightness||0),(0,y.writeInt16)(e,i.contrast||0),(0,y.writeInt16)(e,(n=i.meanValue)!==null&&n!==void 0?n:127),(0,y.writeUint8)(e,i.labColorOnly?1:0),(0,y.writeZeros)(e,1)});function wc(e){let t=(0,g.readInt16)(e),n=(0,g.readInt16)(e),i=(0,g.readInt16)(e),o=(0,g.readInt16)(e),r=(0,g.readInt16)(e)/100;return{shadowInput:t,highlightInput:n,shadowOutput:i,highlightOutput:o,midtoneInput:r}}function Ln(e,t){(0,y.writeInt16)(e,t.shadowInput),(0,y.writeInt16)(e,t.highlightInput),(0,y.writeInt16)(e,t.shadowOutput),(0,y.writeInt16)(e,t.highlightOutput),(0,y.writeInt16)(e,Math.round(t.midtoneInput*100))}L("levl",Fe("levels"),(e,t,n)=>{if((0,g.readUint16)(e)!==2)throw new Error("Invalid levl version");let i=[];for(let l=0;l<29&&n();l++)i.push(wc(e));let[o,r,s,a]=i;if(t.adjustment=Object.assign(Object.assign({},t.adjustment),{type:"levels",rgb:o,red:r,green:s,blue:a}),n()){if((0,g.readSignature)(e)!=="Lvls")throw new Error("Invalid levl signature");if((0,g.readUint16)(e)!==3)throw new Error("Invalid levl version");let l=(0,g.readUint16)(e);for(let c=0;c<l-i.length&&n();c++)i.push(wc(e))}(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,i={shadowInput:0,highlightInput:255,shadowOutput:0,highlightOutput:255,midtoneInput:1};(0,y.writeUint16)(e,2),Ln(e,n.rgb||i),Ln(e,n.red||i),Ln(e,n.green||i),Ln(e,n.blue||i);for(let o=0;o<25;o++)Ln(e,i);(0,y.writeSignature)(e,"Lvls"),(0,y.writeUint16)(e,3),(0,y.writeUint16)(e,62);for(let o=0;o<33;o++)Ln(e,i)});function fo(e){let t=(0,g.readUint16)(e),n=[];for(let i=0;i<t;i++){let o=(0,g.readInt16)(e),r=(0,g.readInt16)(e);n.push({input:r,output:o})}return n}function Vt(e,t){(0,y.writeUint16)(e,t.length);for(let n of t)(0,y.writeUint16)(e,n.output),(0,y.writeUint16)(e,n.input)}L("curv",Fe("curves"),(e,t,n)=>{if((0,g.readUint8)(e),(0,g.readUint16)(e)!==1)throw new Error("Invalid curv version");(0,g.readUint16)(e);let i=(0,g.readUint16)(e),o={type:"curves"};i&1&&(o.rgb=fo(e)),i&2&&(o.red=fo(e)),i&4&&(o.green=fo(e)),i&8&&(o.blue=fo(e)),t.adjustment=Object.assign(Object.assign({},t.adjustment),o),(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,{rgb:i,red:o,green:r,blue:s}=n,a=0,l=0;i&&i.length&&(a|=1,l++),o&&o.length&&(a|=2,l++),r&&r.length&&(a|=4,l++),s&&s.length&&(a|=8,l++),(0,y.writeUint8)(e,0),(0,y.writeUint16)(e,1),(0,y.writeUint16)(e,0),(0,y.writeUint16)(e,a),i&&i.length&&Vt(e,i),o&&o.length&&Vt(e,o),r&&r.length&&Vt(e,r),s&&s.length&&Vt(e,s),(0,y.writeSignature)(e,"Crv "),(0,y.writeUint16)(e,4),(0,y.writeUint16)(e,0),(0,y.writeUint16)(e,l),i&&i.length&&((0,y.writeUint16)(e,0),Vt(e,i)),o&&o.length&&((0,y.writeUint16)(e,1),Vt(e,o)),r&&r.length&&((0,y.writeUint16)(e,2),Vt(e,r)),s&&s.length&&((0,y.writeUint16)(e,3),Vt(e,s))});L("expA",Fe("exposure"),(e,t,n)=>{if((0,g.readUint16)(e)!==1)throw new Error("Invalid expA version");t.adjustment=Object.assign(Object.assign({},t.adjustment),{type:"exposure",exposure:(0,g.readFloat32)(e),offset:(0,g.readFloat32)(e),gamma:(0,g.readFloat32)(e)}),(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,y.writeUint16)(e,1),(0,y.writeFloat32)(e,n.exposure),(0,y.writeFloat32)(e,n.offset),(0,y.writeFloat32)(e,n.gamma),(0,y.writeZeros)(e,2)});L("vibA",Fe("vibrance"),(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);t.adjustment={type:"vibrance"},i.vibrance!==void 0&&(t.adjustment.vibrance=i.vibrance),i.Strt!==void 0&&(t.adjustment.saturation=i.Strt),(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,i={};n.vibrance!==void 0&&(i.vibrance=n.vibrance),n.saturation!==void 0&&(i.Strt=n.saturation),(0,w.writeVersionAndDescriptor)(e,"","null",i)});function on(e){return{a:(0,g.readInt16)(e),b:(0,g.readInt16)(e),c:(0,g.readInt16)(e),d:(0,g.readInt16)(e),hue:(0,g.readInt16)(e),saturation:(0,g.readInt16)(e),lightness:(0,g.readInt16)(e)}}function rn(e,t){let n=t||{};(0,y.writeInt16)(e,n.a||0),(0,y.writeInt16)(e,n.b||0),(0,y.writeInt16)(e,n.c||0),(0,y.writeInt16)(e,n.d||0),(0,y.writeInt16)(e,n.hue||0),(0,y.writeInt16)(e,n.saturation||0),(0,y.writeInt16)(e,n.lightness||0)}L("hue2",Fe("hue/saturation"),(e,t,n)=>{if((0,g.readUint16)(e)!==2)throw new Error("Invalid hue2 version");t.adjustment=Object.assign(Object.assign({},t.adjustment),{type:"hue/saturation",master:on(e),reds:on(e),yellows:on(e),greens:on(e),cyans:on(e),blues:on(e),magentas:on(e)}),(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,y.writeUint16)(e,2),rn(e,n.master),rn(e,n.reds),rn(e,n.yellows),rn(e,n.greens),rn(e,n.cyans),rn(e,n.blues),rn(e,n.magentas)});function Vr(e){return{cyanRed:(0,g.readInt16)(e),magentaGreen:(0,g.readInt16)(e),yellowBlue:(0,g.readInt16)(e)}}function Gr(e,t){(0,y.writeInt16)(e,t.cyanRed||0),(0,y.writeInt16)(e,t.magentaGreen||0),(0,y.writeInt16)(e,t.yellowBlue||0)}L("blnc",Fe("color balance"),(e,t,n)=>{t.adjustment={type:"color balance",shadows:Vr(e),midtones:Vr(e),highlights:Vr(e),preserveLuminosity:!!(0,g.readUint8)(e)},(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;Gr(e,n.shadows||{}),Gr(e,n.midtones||{}),Gr(e,n.highlights||{}),(0,y.writeUint8)(e,n.preserveLuminosity?1:0),(0,y.writeZeros)(e,1)});L("blwh",Fe("black & white"),(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);t.adjustment={type:"black & white",reds:i["Rd "],yellows:i.Yllw,greens:i["Grn "],cyans:i["Cyn "],blues:i["Bl "],magentas:i.Mgnt,useTint:!!i.useTint,presetKind:i.bwPresetKind,presetFileName:i.blackAndWhitePresetFileName},i.tintColor!==void 0&&(t.adjustment.tintColor=(0,w.parseColor)(i.tintColor)),(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,i={"Rd ":n.reds||0,Yllw:n.yellows||0,"Grn ":n.greens||0,"Cyn ":n.cyans||0,"Bl ":n.blues||0,Mgnt:n.magentas||0,useTint:!!n.useTint,tintColor:(0,w.serializeColor)(n.tintColor),bwPresetKind:n.presetKind||0,blackAndWhitePresetFileName:n.presetFileName||""};(0,w.writeVersionAndDescriptor)(e,"","null",i)});L("phfl",Fe("photo filter"),(e,t,n)=>{let i=(0,g.readUint16)(e);if(i!==2&&i!==3)throw new Error("Invalid phfl version");let o;i===2?o=(0,g.readColor)(e):o={l:(0,g.readInt32)(e)/100,a:(0,g.readInt32)(e)/100,b:(0,g.readInt32)(e)/100},t.adjustment={type:"photo filter",color:o,density:(0,g.readUint32)(e)/100,preserveLuminosity:!!(0,g.readUint8)(e)},(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,y.writeUint16)(e,2),(0,y.writeColor)(e,n.color||{l:0,a:0,b:0}),(0,y.writeUint32)(e,(n.density||0)*100),(0,y.writeUint8)(e,n.preserveLuminosity?1:0),(0,y.writeZeros)(e,3)});function uo(e){let t=(0,g.readInt16)(e),n=(0,g.readInt16)(e),i=(0,g.readInt16)(e);(0,g.skipBytes)(e,2);let o=(0,g.readInt16)(e);return{red:t,green:n,blue:i,constant:o}}function ci(e,t){let n=t||{};(0,y.writeInt16)(e,n.red),(0,y.writeInt16)(e,n.green),(0,y.writeInt16)(e,n.blue),(0,y.writeZeros)(e,2),(0,y.writeInt16)(e,n.constant)}L("mixr",Fe("channel mixer"),(e,t,n)=>{if((0,g.readUint16)(e)!==1)throw new Error("Invalid mixr version");let i=t.adjustment=Object.assign(Object.assign({},t.adjustment),{type:"channel mixer",monochrome:!!(0,g.readUint16)(e)});i.monochrome||(i.red=uo(e),i.green=uo(e),i.blue=uo(e)),i.gray=uo(e),(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,y.writeUint16)(e,1),(0,y.writeUint16)(e,n.monochrome?1:0),n.monochrome?(ci(e,n.gray),(0,y.writeZeros)(e,30)):(ci(e,n.red),ci(e,n.green),ci(e,n.blue),ci(e,n.gray))});var Sc=(0,Ze.createEnum)("colorLookupType","3dlut",{"3dlut":"3DLUT",abstractProfile:"abstractProfile",deviceLinkProfile:"deviceLinkProfile"}),vc=(0,Ze.createEnum)("LUTFormatType","look",{look:"LUTFormatLOOK",cube:"LUTFormatCUBE","3dl":"LUTFormat3DL"}),ho=(0,Ze.createEnum)("colorLookupOrder","rgb",{rgb:"rgbOrder",bgr:"bgrOrder"});L("clrL",Fe("color lookup"),(e,t,n)=>{if((0,g.readUint16)(e)!==1)throw new Error("Invalid clrL version");let i=(0,w.readVersionAndDescriptor)(e);t.adjustment={type:"color lookup"};let o=t.adjustment;i.lookupType!==void 0&&(o.lookupType=Sc.decode(i.lookupType)),i["Nm "]!==void 0&&(o.name=i["Nm "]),i.Dthr!==void 0&&(o.dither=i.Dthr),i.profile!==void 0&&(o.profile=i.profile),i.LUTFormat!==void 0&&(o.lutFormat=vc.decode(i.LUTFormat)),i.dataOrder!==void 0&&(o.dataOrder=ho.decode(i.dataOrder)),i.tableOrder!==void 0&&(o.tableOrder=ho.decode(i.tableOrder)),i.LUT3DFileData!==void 0&&(o.lut3DFileData=i.LUT3DFileData),i.LUT3DFileName!==void 0&&(o.lut3DFileName=i.LUT3DFileName),(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,i={};n.lookupType!==void 0&&(i.lookupType=Sc.encode(n.lookupType)),n.name!==void 0&&(i["Nm "]=n.name),n.dither!==void 0&&(i.Dthr=n.dither),n.profile!==void 0&&(i.profile=n.profile),n.lutFormat!==void 0&&(i.LUTFormat=vc.encode(n.lutFormat)),n.dataOrder!==void 0&&(i.dataOrder=ho.encode(n.dataOrder)),n.tableOrder!==void 0&&(i.tableOrder=ho.encode(n.tableOrder)),n.lut3DFileData!==void 0&&(i.LUT3DFileData=n.lut3DFileData),n.lut3DFileName!==void 0&&(i.LUT3DFileName=n.lut3DFileName),(0,y.writeUint16)(e,1),(0,w.writeVersionAndDescriptor)(e,"","null",i)});L("nvrt",Fe("invert"),(e,t,n)=>{t.adjustment={type:"invert"},(0,g.skipBytes)(e,n())},()=>{});L("post",Fe("posterize"),(e,t,n)=>{t.adjustment={type:"posterize",levels:(0,g.readUint16)(e)},(0,g.skipBytes)(e,n())},(e,t)=>{var n;let i=t.adjustment;(0,y.writeUint16)(e,(n=i.levels)!==null&&n!==void 0?n:4),(0,y.writeZeros)(e,2)});L("thrs",Fe("threshold"),(e,t,n)=>{t.adjustment={type:"threshold",level:(0,g.readUint16)(e)},(0,g.skipBytes)(e,n())},(e,t)=>{var n;let i=t.adjustment;(0,y.writeUint16)(e,(n=i.level)!==null&&n!==void 0?n:128),(0,y.writeZeros)(e,2)});var xc=["","","","rgb","hsb","","lab"];L("grdm",Fe("gradient map"),(e,t,n)=>{let i=(0,g.readUint16)(e);if(i!==1&&i!==3)throw new Error("Invalid grdm version");let o={type:"gradient map",gradientType:"solid"};o.reverse=!!(0,g.readUint8)(e),o.dither=!!(0,g.readUint8)(e);let r=!!(0,g.readUint8)(e);if(e.offset--,r){let u=(0,g.readSignature)(e);o.method=w.gradientInterpolationMethodType.decode(u)}o.name=(0,g.readUnicodeString)(e),o.colorStops=[],o.opacityStops=[];let s=(0,g.readUint16)(e);for(let u=0;u<s;u++)o.colorStops.push({location:(0,g.readUint32)(e),midpoint:(0,g.readUint32)(e)/100,color:(0,g.readColor)(e)}),(0,g.skipBytes)(e,2);let a=(0,g.readUint16)(e);for(let u=0;u<a;u++)o.opacityStops.push({location:(0,g.readUint32)(e),midpoint:(0,g.readUint32)(e)/100,opacity:(0,g.readUint16)(e)/255});if((0,g.readUint16)(e)!==2)throw new Error("Invalid grdm expansion count");let c=(0,g.readUint16)(e);if(o.smoothness=c/4096,(0,g.readUint16)(e)!==32)throw new Error("Invalid grdm length");o.gradientType=(0,g.readUint16)(e)?"noise":"solid",o.randomSeed=(0,g.readUint32)(e),o.addTransparency=!!(0,g.readUint16)(e),o.restrictColors=!!(0,g.readUint16)(e),o.roughness=(0,g.readUint32)(e)/4096,o.colorModel=xc[(0,g.readUint16)(e)]||"rgb",o.min=[(0,g.readUint16)(e)/32768,(0,g.readUint16)(e)/32768,(0,g.readUint16)(e)/32768,(0,g.readUint16)(e)/32768],o.max=[(0,g.readUint16)(e)/32768,(0,g.readUint16)(e)/32768,(0,g.readUint16)(e)/32768,(0,g.readUint16)(e)/32768],(0,g.skipBytes)(e,n());for(let u of o.colorStops)u.location/=c;for(let u of o.opacityStops)u.location/=c;t.adjustment=o},(e,t)=>{var n,i,o;let r=t.adjustment;(0,y.writeUint16)(e,r.method!==void 0?3:1),(0,y.writeUint8)(e,r.reverse?1:0),(0,y.writeUint8)(e,r.dither?1:0),r.method!==void 0&&(0,y.writeSignature)(e,w.gradientInterpolationMethodType.encode(r.method)),(0,y.writeUnicodeStringWithPadding)(e,r.name||""),(0,y.writeUint16)(e,r.colorStops&&r.colorStops.length||0);let s=Math.round(((n=r.smoothness)!==null&&n!==void 0?n:1)*4096);for(let l of r.colorStops||[])(0,y.writeUint32)(e,Math.round(l.location*s)),(0,y.writeUint32)(e,Math.round(l.midpoint*100)),(0,y.writeColor)(e,l.color),(0,y.writeZeros)(e,2);(0,y.writeUint16)(e,r.opacityStops&&r.opacityStops.length||0);for(let l of r.opacityStops||[])(0,y.writeUint32)(e,Math.round(l.location*s)),(0,y.writeUint32)(e,Math.round(l.midpoint*100)),(0,y.writeUint16)(e,Math.round(l.opacity*255));(0,y.writeUint16)(e,2),(0,y.writeUint16)(e,s),(0,y.writeUint16)(e,32),(0,y.writeUint16)(e,r.gradientType==="noise"?1:0),(0,y.writeUint32)(e,r.randomSeed||0),(0,y.writeUint16)(e,r.addTransparency?1:0),(0,y.writeUint16)(e,r.restrictColors?1:0),(0,y.writeUint32)(e,Math.round(((i=r.roughness)!==null&&i!==void 0?i:1)*4096));let a=xc.indexOf((o=r.colorModel)!==null&&o!==void 0?o:"rgb");(0,y.writeUint16)(e,a===-1?3:a);for(let l=0;l<4;l++)(0,y.writeUint16)(e,Math.round((r.min&&r.min[l]||0)*32768));for(let l=0;l<4;l++)(0,y.writeUint16)(e,Math.round((r.max&&r.max[l]||0)*32768));(0,y.writeZeros)(e,4)});function It(e){return{c:(0,g.readInt16)(e),m:(0,g.readInt16)(e),y:(0,g.readInt16)(e),k:(0,g.readInt16)(e)}}function Dt(e,t){let n=t||{};(0,y.writeInt16)(e,n.c),(0,y.writeInt16)(e,n.m),(0,y.writeInt16)(e,n.y),(0,y.writeInt16)(e,n.k)}L("selc",Fe("selective color"),(e,t)=>{if((0,g.readUint16)(e)!==1)throw new Error("Invalid selc version");let n=(0,g.readUint16)(e)?"absolute":"relative";(0,g.skipBytes)(e,8),t.adjustment={type:"selective color",mode:n,reds:It(e),yellows:It(e),greens:It(e),cyans:It(e),blues:It(e),magentas:It(e),whites:It(e),neutrals:It(e),blacks:It(e)}},(e,t)=>{let n=t.adjustment;(0,y.writeUint16)(e,1),(0,y.writeUint16)(e,n.mode==="absolute"?1:0),(0,y.writeZeros)(e,8),Dt(e,n.reds),Dt(e,n.yellows),Dt(e,n.greens),Dt(e,n.cyans),Dt(e,n.blues),Dt(e,n.magentas),Dt(e,n.whites),Dt(e,n.neutrals),Dt(e,n.blacks)});L("CgEd",e=>{let t=e.adjustment;return t?t.type==="brightness/contrast"&&!t.useLegacy||(t.type==="levels"||t.type==="curves"||t.type==="exposure"||t.type==="channel mixer"||t.type==="hue/saturation")&&t.presetFileName!==void 0:!1},(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);if(i.Vrsn!==1)throw new Error("Invalid CgEd version");"presetFileName"in i?t.adjustment=Object.assign(Object.assign({},t.adjustment),{presetKind:i.presetKind,presetFileName:i.presetFileName}):"curvesPresetFileName"in i?t.adjustment=Object.assign(Object.assign({},t.adjustment),{presetKind:i.curvesPresetKind,presetFileName:i.curvesPresetFileName}):"mixerPresetFileName"in i?t.adjustment=Object.assign(Object.assign({},t.adjustment),{presetKind:i.mixerPresetKind,presetFileName:i.mixerPresetFileName}):t.adjustment={type:"brightness/contrast",brightness:i.Brgh,contrast:i.Cntr,meanValue:i.means,useLegacy:!!i.useLegacy,labColorOnly:!!i["Lab "],auto:!!i.Auto},(0,g.skipBytes)(e,n())},(e,t)=>{var n,i,o,r;let s=t.adjustment;if(s.type==="levels"||s.type==="exposure"||s.type==="hue/saturation"){let a={Vrsn:1,presetKind:(n=s.presetKind)!==null&&n!==void 0?n:1,presetFileName:s.presetFileName||""};(0,w.writeVersionAndDescriptor)(e,"","null",a)}else if(s.type==="curves"){let a={Vrsn:1,curvesPresetKind:(i=s.presetKind)!==null&&i!==void 0?i:1,curvesPresetFileName:s.presetFileName||""};(0,w.writeVersionAndDescriptor)(e,"","null",a)}else if(s.type==="channel mixer"){let a={Vrsn:1,mixerPresetKind:(o=s.presetKind)!==null&&o!==void 0?o:1,mixerPresetFileName:s.presetFileName||""};(0,w.writeVersionAndDescriptor)(e,"","null",a)}else if(s.type==="brightness/contrast"){let a={Vrsn:1,Brgh:s.brightness||0,Cntr:s.contrast||0,means:(r=s.meanValue)!==null&&r!==void 0?r:127,"Lab ":!!s.labColorOnly,useLegacy:!!s.useLegacy,Auto:!!s.auto};(0,w.writeVersionAndDescriptor)(e,"","null",a)}else throw new Error("Unhandled CgEd case")});function k0(e){let t=[];function n(i){var o;if(i.children)for(let r of i.children)((o=r.text)===null||o===void 0?void 0:o.index)!==void 0&&(t[r.text.index]=r),n(r)}return n(e),t}L("Txt2",ae("engineData"),(e,t,n,i)=>{let o=(0,g.readBytes)(e,n());t.engineData=(0,hc.fromByteArray)(o);let r=k0(i),s=(0,Hr.parseEngineData)(o),l=(0,y0.decodeEngineData2)(s).ResourceDict.TextFrameSet;if(l)for(let c=0;c<l.length;c++){let d=r[c];l[c].path&&d?.text&&(d.text.textPath=l[c].path)}},(e,t)=>{let n=(0,hc.toByteArray)(t.engineData);(0,y.writeBytes)(e,n)});L("FEid",ae("filterEffectsMasks"),(e,t,n)=>{let i=(0,g.readInt32)(e);if(i<1||i>3)throw new Error(`Invalid filterEffects version ${i}`);for(t.filterEffectsMasks=[];n()>8;){if((0,g.readUint32)(e))throw new Error("filterEffects: 64 bit length is not supported");let o=(0,g.readUint32)(e),r=e.offset+o,s=(0,g.readPascalString)(e,1),a=(0,g.readInt32)(e);if(a!==1)throw new Error(`Invalid filterEffect version ${a}`);if((0,g.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");(0,g.readUint32)(e);let l=(0,g.readInt32)(e),c=(0,g.readInt32)(e),d=(0,g.readInt32)(e),u=(0,g.readInt32)(e),f=(0,g.readInt32)(e),h=(0,g.readInt32)(e),p=[];for(let m=0;m<h+2;m++)if((0,g.readInt32)(e)){if((0,g.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");let v=(0,g.readUint32)(e);if(!v)throw new Error("filterEffect: Empty channel");let x=(0,g.readUint16)(e),_=(0,g.readBytes)(e,v-2);p.push({compressionMode:x,data:_})}else p.push(void 0);if(t.filterEffectsMasks.push({id:s,top:l,left:c,bottom:d,right:u,depth:f,channels:p}),e.offset<r&&(0,g.readUint8)(e)){let m=(0,g.readInt32)(e),b=(0,g.readInt32)(e),v=(0,g.readInt32)(e),x=(0,g.readInt32)(e);if((0,g.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");let _=(0,g.readUint32)(e),I=(0,g.readUint16)(e),P=(0,g.readBytes)(e,_-2);t.filterEffectsMasks[t.filterEffectsMasks.length-1].extra={top:m,left:b,bottom:v,right:x,compressionMode:I,data:P}}e.offset=r;let S=o;for(;S%4;)e.offset++,S++}},(e,t)=>{var n;(0,y.writeInt32)(e,3);for(let i of t.filterEffectsMasks){(0,y.writeUint32)(e,0),(0,y.writeUint32)(e,0);let o=e.offset;(0,y.writePascalString)(e,i.id,1),(0,y.writeInt32)(e,1),(0,y.writeUint32)(e,0),(0,y.writeUint32)(e,0);let r=e.offset;(0,y.writeInt32)(e,i.top),(0,y.writeInt32)(e,i.left),(0,y.writeInt32)(e,i.bottom),(0,y.writeInt32)(e,i.right),(0,y.writeInt32)(e,i.depth);let s=Math.max(0,i.channels.length-2);(0,y.writeInt32)(e,s);for(let c=0;c<s+2;c++){let d=i.channels[c];(0,y.writeInt32)(e,d?1:0),d&&((0,y.writeUint32)(e,0),(0,y.writeUint32)(e,d.data.length+2),(0,y.writeUint16)(e,d.compressionMode),(0,y.writeBytes)(e,d.data))}e.view.setUint32(r-4,e.offset-r,!1);let a=(n=t.filterEffectsMasks[t.filterEffectsMasks.length-1])===null||n===void 0?void 0:n.extra;a&&((0,y.writeUint8)(e,1),(0,y.writeInt32)(e,a.top),(0,y.writeInt32)(e,a.left),(0,y.writeInt32)(e,a.bottom),(0,y.writeInt32)(e,a.right),(0,y.writeUint32)(e,0),(0,y.writeUint32)(e,a.data.byteLength+2),(0,y.writeUint16)(e,a.compressionMode),(0,y.writeBytes)(e,a.data));let l=e.offset-o;for(e.view.setUint32(o-4,l,!1);l%4;)(0,y.writeZeros)(e,1),l++}});Gt("FXid","FEid");L("FMsk",ae("filterMask"),(e,t)=>{t.filterMask={colorSpace:(0,g.readColor)(e),opacity:(0,g.readUint16)(e)/255}},(e,t)=>{var n;(0,y.writeColor)(e,t.filterMask.colorSpace),(0,y.writeUint16)(e,(0,Ze.clamp)((n=t.filterMask.opacity)!==null&&n!==void 0?n:1,0,1)*255)});L("artd",e=>e.artboards!==void 0,(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);t.artboards={count:i["Cnt "],autoExpandOffset:{horizontal:i.autoExpandOffset.Hrzn,vertical:i.autoExpandOffset.Vrtc},origin:{horizontal:i.origin.Hrzn,vertical:i.origin.Vrtc},autoExpandEnabled:i.autoExpandEnabled,autoNestEnabled:i.autoNestEnabled,autoPositionEnabled:i.autoPositionEnabled,shrinkwrapOnSaveEnabled:!!i.shrinkwrapOnSaveEnabled,docDefaultNewArtboardBackgroundColor:(0,w.parseColor)(i.docDefaultNewArtboardBackgroundColor),docDefaultNewArtboardBackgroundType:i.docDefaultNewArtboardBackgroundType},(0,g.skipBytes)(e,n())},(e,t)=>{var n,i,o,r,s;let a=t.artboards,l={"Cnt ":a.count,autoExpandOffset:a.autoExpandOffset?{Hrzn:a.autoExpandOffset.horizontal,Vrtc:a.autoExpandOffset.vertical}:{Hrzn:0,Vrtc:0},origin:a.origin?{Hrzn:a.origin.horizontal,Vrtc:a.origin.vertical}:{Hrzn:0,Vrtc:0},autoExpandEnabled:(n=a.autoExpandEnabled)!==null&&n!==void 0?n:!0,autoNestEnabled:(i=a.autoNestEnabled)!==null&&i!==void 0?i:!0,autoPositionEnabled:(o=a.autoPositionEnabled)!==null&&o!==void 0?o:!0,shrinkwrapOnSaveEnabled:(r=a.shrinkwrapOnSaveEnabled)!==null&&r!==void 0?r:!0,docDefaultNewArtboardBackgroundColor:(0,w.serializeColor)(a.docDefaultNewArtboardBackgroundColor),docDefaultNewArtboardBackgroundType:(s=a.docDefaultNewArtboardBackgroundType)!==null&&s!==void 0?s:1};(0,w.writeVersionAndDescriptor)(e,"","null",l,"artd")});function Xr(e){return Object.keys(e).map(t=>e[t]).some(t=>Array.isArray(t)&&t.length>1)}L("lfx2",e=>e.effects!==void 0&&!Xr(e.effects),(e,t,n)=>{if((0,g.readUint32)(e)!==0)throw new Error("Invalid lfx2 version");let o=(0,w.readVersionAndDescriptor)(e);t.effects=(0,w.parseEffects)(o,!!e.logMissingFeatures),(0,g.skipBytes)(e,n())},(e,t,n,i)=>{let o=(0,w.serializeEffects)(t.effects,!!i.logMissingFeatures,!0);(0,y.writeUint32)(e,0),(0,w.writeVersionAndDescriptor)(e,"","null",o)});L("cinf",ae("compositorUsed"),(e,t,n)=>{let i=(0,w.readVersionAndDescriptor)(e);function o(r){return r.split(".")[1]}t.compositorUsed={description:i.description,reason:i.reason,engine:o(i.Engn)},i.Vrsn&&(t.compositorUsed.version=i.Vrsn),i.psVersion&&(t.compositorUsed.photoshopVersion=i.psVersion),i.enableCompCore&&(t.compositorUsed.enableCompCore=o(i.enableCompCore)),i.enableCompCoreGPU&&(t.compositorUsed.enableCompCoreGPU=o(i.enableCompCoreGPU)),i.enableCompCoreThreads&&(t.compositorUsed.enableCompCoreThreads=o(i.enableCompCoreThreads)),i.compCoreSupport&&(t.compositorUsed.compCoreSupport=o(i.compCoreSupport)),i.compCoreGPUSupport&&(t.compositorUsed.compCoreGPUSupport=o(i.compCoreGPUSupport)),(0,g.skipBytes)(e,n())},(e,t)=>{let n=t.compositorUsed,i={Vrsn:n.version||{major:1,minor:0,fix:0}};n.photoshopVersion&&(i.psVersion=n.photoshopVersion),i.description=n.description,i.reason=n.reason,i.Engn=`Engn.${n.engine}`,n.enableCompCore&&(i.enableCompCore=`enable.${n.enableCompCore}`),n.enableCompCoreGPU&&(i.enableCompCoreGPU=`enable.${n.enableCompCoreGPU}`),n.enableCompCoreThreads&&(i.enableCompCoreThreads=`enable.${n.enableCompCoreThreads}`),n.compCoreSupport&&(i.compCoreSupport=`reason.${n.compCoreSupport}`),n.compCoreGPUSupport&&(i.compCoreGPUSupport=`reason.${n.compCoreGPUSupport}`),(0,w.writeVersionAndDescriptor)(e,"","null",i)});L("extn",e=>e._extn!==void 0,(e,t)=>{let n=(0,w.readVersionAndDescriptor)(e);Ze.MOCK_HANDLERS&&(t._extn=n)},(e,t)=>{Ze.MOCK_HANDLERS&&(0,w.writeVersionAndDescriptor)(e,"","null",t._extn)});L("iOpa",ae("fillOpacity"),(e,t)=>{t.fillOpacity=(0,g.readUint8)(e)/255,(0,g.skipBytes)(e,3)},(e,t)=>{(0,y.writeUint8)(e,t.fillOpacity*255),(0,y.writeZeros)(e,3)});L("brst",ae("channelBlendingRestrictions"),(e,t,n)=>{for(t.channelBlendingRestrictions=[];n()>4;)t.channelBlendingRestrictions.push((0,g.readInt32)(e))},(e,t)=>{for(let n of t.channelBlendingRestrictions)(0,y.writeInt32)(e,n)});L("tsly",ae("transparencyShapesLayer"),(e,t)=>{t.transparencyShapesLayer=!!(0,g.readUint8)(e),(0,g.skipBytes)(e,3)},(e,t)=>{(0,y.writeUint8)(e,t.transparencyShapesLayer?1:0),(0,y.writeZeros)(e,3)})});var Dn=oe(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.createWriter=C0;ce.getWriterBuffer=P0;ce.getWriterBufferNoCopy=E0;ce.writeUint8=de;ce.writeInt16=Ht;ce.writeUint16=Z;ce.writeUint16LE=Fc;ce.writeInt32=Me;ce.writeInt32LE=F0;ce.writeUint32=ue;ce.writeFloat32=O0;ce.writeFloat64=qr;ce.writeFixedPoint32=L0;ce.writeFixedPointPath32=B0;ce.writeBytes=fi;ce.writeZeros=sn;ce.writeSignature=an;ce.writeAsciiString=U0;ce.writePascalString=bo;ce.writeUnicodeStringWithoutLength=Oc;ce.writeUnicodeStringWithoutLengthLE=R0;ce.writeUnicodeString=Lc;ce.writeUnicodeStringWithPadding=M0;ce.writeSection=rt;ce.writePsd=T0;ce.writeColor=q0;ce.writePattern=K0;var ve=Tt(),I0=oo(),D0=xr();function C0(e=4096){let t=new ArrayBuffer(e),n=new DataView(t);return{buffer:t,view:n,offset:0,tempBuffer:void 0}}function P0(e){return e.buffer.slice(0,e.offset)}function E0(e){return new Uint8Array(e.buffer,0,e.offset)}function de(e,t){let n=Ct(e,1);e.view.setUint8(n,t)}function Ht(e,t){let n=Ct(e,2);e.view.setInt16(n,t,!1)}function Z(e,t){let n=Ct(e,2);e.view.setUint16(n,t,!1)}function Fc(e,t){let n=Ct(e,2);e.view.setUint16(n,t,!0)}function Me(e,t){let n=Ct(e,4);e.view.setInt32(n,t,!1)}function F0(e,t){let n=Ct(e,4);e.view.setInt32(n,t,!0)}function ue(e,t){let n=Ct(e,4);e.view.setUint32(n,t,!1)}function O0(e,t){let n=Ct(e,4);e.view.setFloat32(n,t,!1)}function qr(e,t){let n=Ct(e,8);e.view.setFloat64(n,t,!1)}function L0(e,t){Me(e,t*65536)}function B0(e,t){Me(e,t*(1<<24))}function fi(e,t){t&&(Tc(e,e.offset+t.length),new Uint8Array(e.buffer).set(t,e.offset),e.offset+=t.length)}function sn(e,t){for(let n=0;n<t;n++)de(e,0)}function an(e,t){if(t.length!==4)throw new Error(`Invalid signature: '${t}'`);for(let n=0;n<4;n++)de(e,t.charCodeAt(n))}function U0(e,t){for(let n=0;n<t.length;n++)de(e,t.charCodeAt(n))}function bo(e,t,n){let i=t.length;if(i>255)throw new Error("String too long");de(e,i);for(let o=0;o<i;o++){let r=t.charCodeAt(o);de(e,r<128?r:63)}for(;++i%n;)de(e,0)}function Oc(e,t){for(let n=0;n<t.length;n++)Z(e,t.charCodeAt(n))}function R0(e,t){for(let n=0;n<t.length;n++)Fc(e,t.charCodeAt(n))}function Lc(e,t){ue(e,t.length),Oc(e,t)}function M0(e,t){ue(e,t.length+1);for(let n=0;n<t.length;n++)Z(e,t.charCodeAt(n));Z(e,0)}function Bc(e=[]){let t=0;for(let n of e){let{width:i,height:o}=di(n);if(t=Math.max(t,2*o+2*i*o),n.mask){let{width:r,height:s}=di(n.mask);t=Math.max(t,2*s+2*r*s)}if(n.realMask){let{width:r,height:s}=di(n.realMask);t=Math.max(t,2*s+2*r*s)}n.children&&(t=Math.max(t,Bc(n.children)))}return t}function rt(e,t,n,i=!1,o=!1){o&&ue(e,0);let r=e.offset;ue(e,0),n();let s=e.offset-r-4,a=s;for(;a%t;)de(e,0),a++;i&&(s=a),e.view.setUint32(r,s,!1)}function Uc(e){var t;(t=e.children)===null||t===void 0||t.forEach(Uc);let n=e.imageData;if(n&&(n.data instanceof Uint32Array||n.data instanceof Uint16Array))throw new Error("imageData has incorrect bitDepth");if("mask"in e&&e.mask){let i=e.mask.imageData;if(i&&(i.data instanceof Uint32Array||i.data instanceof Uint16Array))throw new Error("mask imageData has incorrect bitDepth")}}function T0(e,t,n={}){var i;if(!(+t.width>0&&+t.height>0))throw new Error("Invalid document size");if((t.width>3e4||t.height>3e4)&&!n.psb)throw new Error("Document size is too large (max is 30000x30000, use PSB format instead)");let o=(i=t.bitsPerChannel)!==null&&i!==void 0?i:8;if(o!==8)throw new Error("bitsPerChannel other than 8 are not supported for writing");Uc(t);let r=Object.assign({},t.imageResources),s=Object.assign(Object.assign({},n),{layerIds:new Set,layerToId:new Map});s.generateThumbnail&&(r.thumbnail=G0(t));let a=t.imageData;if(!a&&t.canvas&&(a=t.canvas.getContext("2d").getImageData(0,0,t.canvas.width,t.canvas.height)),a&&(t.width!==a.width||t.height!==a.height))throw new Error("Document canvas must have the same size as document");let l=!!a&&(0,ve.hasAlpha)(a),c=Math.max(Bc(t.children),8*t.width*t.height+2*t.height);e.tempBuffer=new Uint8Array(c),an(e,"8BPS"),Z(e,n.psb?2:1),sn(e,6),Z(e,l?4:3),ue(e,t.height),ue(e,t.width),Z(e,o),Z(e,3),rt(e,1,()=>{var S,m,b;if(t.palette){for(let v=0;v<256;v++)de(e,((S=t.palette[v])===null||S===void 0?void 0:S.r)||0);for(let v=0;v<256;v++)de(e,((m=t.palette[v])===null||m===void 0?void 0:m.g)||0);for(let v=0;v<256;v++)de(e,((b=t.palette[v])===null||b===void 0?void 0:b.b)||0)}});let d=[];Mc(d,t.children),d.length||d.push({}),r.layersGroup=d.map(S=>S.linkGroup||0),r.layerGroupsEnabledId=d.map(S=>S.linkGroupEnabled==!1?0:1),rt(e,1,()=>{for(let S of D0.resourceHandlers){let m=S.has(r),b=m===!1?0:m===!0?1:m;for(let v=0;v<b;v++)an(e,"8BIM"),Z(e,S.key),bo(e,"",2),rt(e,2,()=>S.write(e,r,v))}}),rt(e,2,()=>{j0(e,d,t,l,s),N0(e,t.globalLayerMaskInfo),Rc(e,t,t,s)},void 0,!!s.psb);let u=l?[0,1,2,3]:[0,1,2],f=a?a.width:t.width,h=a?a.height:t.height,p={data:new Uint8Array(f*h*4),width:f,height:h};if(Z(e,1),ve.RAW_IMAGE_DATA&&t.imageDataRaw)console.log("writing raw image data"),fi(e,t.imageDataRaw);else{if(a&&p.data.set(new Uint8Array(a.data.buffer,a.data.byteOffset,a.data.byteLength)),l){let S=p.width*p.height*4,m=p.data;for(let b=0;b<S;b+=4){let v=m[b+3];if(v!=0&&v!=255){let x=v/255,_=255*(1-x);m[b+0]=m[b+0]*x+_,m[b+1]=m[b+1]*x+_,m[b+2]=m[b+2]*x+_}}}fi(e,(0,ve.writeDataRLE)(e.tempBuffer,p,u,!!n.psb))}}function j0(e,t,n,i,o){rt(e,4,()=>{var r;Ht(e,i?-t.length:t.length);let s=t.map((a,l)=>H0(e.tempBuffer,a,l===0,o));for(let a of s){let{layer:l,top:c,left:d,bottom:u,right:f,channels:h}=a;Me(e,c),Me(e,d),Me(e,u),Me(e,f),Z(e,h.length);for(let S of h)Ht(e,S.id),o.psb&&ue(e,0),ue(e,S.length);an(e,"8BIM"),an(e,ve.fromBlendMode[l.blendMode]||"norm"),de(e,Math.round((0,ve.clamp)((r=l.opacity)!==null&&r!==void 0?r:1,0,1)*255)),de(e,l.clipping?1:0);let p=8;l.transparencyProtected&&(p|=1),l.hidden&&(p|=2),(l.vectorMask||l.sectionDivider&&l.sectionDivider.type!==0||l.adjustment)&&(p|=16),l.effectsOpen&&(p|=32),de(e,p),de(e,0),rt(e,1,()=>{z0(e,l,a),$0(e,l),bo(e,(l.name||"").substring(0,255),4),Rc(e,l,n,o)})}for(let a of s)for(let l of a.channels)Z(e,l.compression),l.data&&fi(e,l.data)},!0,o.psb)}function z0(e,{mask:t,realMask:n},i){rt(e,1,()=>{if(!t&&!n)return;let o=0,r=0,s=0;t&&(t.userMaskDensity!==void 0&&(o|=1),t.userMaskFeather!==void 0&&(o|=2),t.vectorMaskDensity!==void 0&&(o|=4),t.vectorMaskFeather!==void 0&&(o|=8),t.disabled&&(r|=2),t.positionRelativeToLayer&&(r|=1),t.fromVectorData&&(r|=8),o&&(r|=16));let a=i.mask||{};if(Me(e,a.top||0),Me(e,a.left||0),Me(e,a.bottom||0),Me(e,a.right||0),de(e,t&&t.defaultColor||0),de(e,r),n){n.disabled&&(s|=2),n.positionRelativeToLayer&&(s|=1),n.fromVectorData&&(s|=8);let l=i.realMask||{};de(e,s),de(e,n.defaultColor||0),Me(e,l.top||0),Me(e,l.left||0),Me(e,l.bottom||0),Me(e,l.right||0)}o&&t&&(de(e,o),t.userMaskDensity!==void 0&&de(e,Math.round(t.userMaskDensity*255)),t.userMaskFeather!==void 0&&qr(e,t.userMaskFeather),t.vectorMaskDensity!==void 0&&de(e,Math.round(t.vectorMaskDensity*255)),t.vectorMaskFeather!==void 0&&qr(e,t.vectorMaskFeather)),sn(e,2)})}function go(e,t){de(e,t[0]),de(e,t[1]),de(e,t[2]),de(e,t[3])}function $0(e,t){rt(e,1,()=>{let n=t.blendingRanges;if(n){go(e,n.compositeGrayBlendSource),go(e,n.compositeGraphBlendDestinationRange);for(let i of n.ranges)go(e,i.sourceRange),go(e,i.destRange)}})}function N0(e,t){rt(e,1,()=>{t&&(Z(e,t.overlayColorSpace),Z(e,t.colorSpace1),Z(e,t.colorSpace2),Z(e,t.colorSpace3),Z(e,t.colorSpace4),Z(e,Math.round(t.opacity*255)),de(e,t.kind),sn(e,3))})}function Rc(e,t,n,i){for(let o of I0.infoHandlers){let r=o.key;if(!(r==="Txt2"&&i.invalidateTextLayers)&&(r==="vmsk"&&i.psb&&(r="vsms"),o.has(t))){let s=i.psb&&ve.largeAdditionalInfoKeys.indexOf(r)!==-1,a=r!=="Txt2"&&r!=="cinf"&&r!=="extn"&&r!=="CAI "&&r!=="OCIO",l=r==="levl"||r==="Txt2"||r==="luni"||r==="vmsk"||r==="artb"||r==="artd"||r==="vogk"||r==="SoLd"||r==="lnk2"||r==="vscg"||r==="vsms"||r==="GdFl"||r==="lmfx"||r==="lrFX"||r==="cinf"||r==="PlLd"||r==="Anno"||r==="CAI "||r==="OCIO"||r==="GenI"||r==="FEid"||r==="curv"||r==="CgEd"||r==="vibA"||r==="blwh"||r==="grdm";an(e,s?"8B64":"8BIM"),an(e,r),rt(e,l?4:2,()=>{o.write(e,t,n,i)},a,s)}}}function Mc(e,t){if(t)for(let n of t){if(n.children&&n.canvas)throw new Error("Invalid layer, cannot have both 'canvas' and 'children' properties");if(n.children&&n.imageData)throw new Error("Invalid layer, cannot have both 'imageData' and 'children' properties");n.children?(e.push({name:"</Layer group>",sectionDivider:{type:3}}),Mc(e,n.children),e.push(Object.assign(Object.assign({},n),{blendMode:n.blendMode==="pass through"?"normal":n.blendMode,sectionDivider:{type:n.opened===!1?2:1,key:ve.fromBlendMode[n.blendMode]||"pass",subType:0}}))):e.push(Object.assign({},n))}}function V0(e,t){let n=e.buffer.byteLength;do n*=2;while(t>n);let i=new ArrayBuffer(n),o=new Uint8Array(i),r=new Uint8Array(e.buffer);o.set(r),e.buffer=i,e.view=new DataView(e.buffer)}function Tc(e,t){t>e.buffer.byteLength&&V0(e,t)}function Ct(e,t){let n=e.offset;return Tc(e,e.offset+=t),n}function G0(e){let t=(0,ve.createCanvas)(10,10),n=1;e.width>e.height?(t.width=160,t.height=Math.floor(e.height*(t.width/e.width)),n=t.width/e.width):(t.height=160,t.width=Math.floor(e.width*(t.height/e.height)),n=t.height/e.height);let i=t.getContext("2d");return i.scale(n,n),e.imageData?i.drawImage((0,ve.imageDataToCanvas)(e.imageData),0,0):e.canvas&&i.drawImage(e.canvas,0,0),t}function Cc(e,t,n,i,o,r){let s=i.top|0,a=i.left|0,l=i.right|0,c=i.bottom|0,{width:d,height:u}=di(i),f=i.imageData;if(!f&&i.canvas&&d&&u&&(f=i.canvas.getContext("2d").getImageData(0,0,d,u)),f&&(f.width!==d||f.height!==u))throw new Error("Invalid imageData dimentions");l=a+d,c=s+u;let h,p;ve.RAW_IMAGE_DATA&&n[r?"realMaskDataRaw":"maskDataRaw"]?(h=n[r?"realMaskDataRaw":"maskDataRaw"],p=n[r?"realMaskDataRawCompression":"maskDataRawCompression"]):f?o.compress?(h=(0,ve.writeDataZipWithoutPrediction)(f,[0]),p=2):(h=(0,ve.writeDataRLE)(e,f,[0],!!o.psb),p=1):(h=new Uint8Array(0),p=1),t.channels.push({id:r?-3:-2,compression:p,data:h,length:2+h.length}),t[r?"realMask":"mask"]={top:s,left:a,right:l,bottom:c}}function Zr(e){return e?{top:e.top||0,left:e.left||0,right:e.right||0,bottom:e.bottom||0}:void 0}function H0(e,t,n,i){if(t.rawData)return Object.assign(Object.assign({layer:t,channels:t.rawData.channels.map(r=>{var s,a;return Object.assign(Object.assign({},r),{length:2+((a=(s=r.data)===null||s===void 0?void 0:s.byteLength)!==null&&a!==void 0?a:0)})})},Zr(t)),{mask:Zr(t.mask),realMask:Zr(t.realMask)});let o=X0(e,t,n,i);return t.mask&&Cc(e,o,t,t.mask,i,!1),t.realMask&&Cc(e,o,t,t.realMask,i,!0),o}function di({canvas:e,imageData:t}){var n,i,o,r;let s=(i=(n=t?.width)!==null&&n!==void 0?n:e?.width)!==null&&i!==void 0?i:0,a=(r=(o=t?.height)!==null&&o!==void 0?o:e?.height)!==null&&r!==void 0?r:0;return{width:s,height:a}}function W0(e,t,n,i,o){if(e.data instanceof Uint32Array||e.data instanceof Uint16Array)throw new Error("imageData has incorrect bit depth");let r=(0,ve.createImageData)(i,o),s=e.data,a=r.data;for(let l=0;l<o;l++)for(let c=0;c<i;c++){let d=(c+t+(l+n)*e.width)*4,u=(c+l*i)*4;a[u]=s[d],a[u+1]=s[d+1],a[u+2]=s[d+2],a[u+3]=s[d+3]}return r}function X0(e,t,n,i){var o;let r=t.top|0,s=t.left|0,a=t.right|0,l=t.bottom|0,c=[{id:-1,compression:0,data:void 0,length:2},{id:0,compression:0,data:void 0,length:2},{id:1,compression:0,data:void 0,length:2},{id:2,compression:0,data:void 0,length:2}],{width:d,height:u}=di(t);if(!(t.canvas||t.imageData)||!d||!u)return a=s,l=r,{layer:t,top:r,left:s,right:a,bottom:l,channels:c};a=s+d,l=r+u;let f=t.imageData||t.canvas.getContext("2d").getImageData(0,0,d,u);if(i.trimImageData){let p=Z0(f);if(p.left!==0||p.top!==0||p.right!==f.width||p.bottom!==f.height){if(s+=p.left,r+=p.top,a-=f.width-p.right,l-=f.height-p.bottom,d=a-s,u=l-r,!d||!u)return{layer:t,top:r,left:s,right:a,bottom:l,channels:c};f=W0(f,p.left,p.top,d,u)}}let h=[0,1,2];return(!n||i.noBackground||t.mask||(0,ve.hasAlpha)(f)||ve.RAW_IMAGE_DATA&&(!((o=t.imageDataRaw)===null||o===void 0)&&o[-1]))&&h.unshift(-1),c=h.map(p=>{let S=(0,ve.offsetForChannel)(p,!1),m,b;return ve.RAW_IMAGE_DATA&&t.imageDataRaw?(m=t.imageDataRaw[p],b=t.imageDataRawCompression[p]):i.compress?(m=(0,ve.writeDataZipWithoutPrediction)(f,[S]),b=2):(m=(0,ve.writeDataRLE)(e,f,[S],!!i.psb),b=1),{id:p,compression:b,data:m,length:2+m.length}}),{layer:t,top:r,left:s,right:a,bottom:l,channels:c}}function Pc({data:e,width:t},n,i,o){let r=(n*t+i)*4+3|0,s=r+(o-i)*4|0;for(let a=r;a<s;a=a+4|0)if(e[a]!==0)return!1;return!0}function Ec({data:e,width:t},n,i,o){let r=t*4|0,s=i*r+n*4+3|0;for(let a=i,l=s;a<o;a++,l=l+r|0)if(e[l]!==0)return!1;return!0}function Z0(e){let t=0,n=0,i=e.width,o=e.height;for(;t<o&&Pc(e,t,n,i);)t++;for(;o>t&&Pc(e,o-1,n,i);)o--;for(;n<i&&Ec(e,n,t,o);)n++;for(;i>n&&Ec(e,i-1,t,o);)i--;return{top:t,left:n,right:i,bottom:o}}function q0(e,t){t?"r"in t?(Z(e,0),Z(e,Math.round(t.r*257)),Z(e,Math.round(t.g*257)),Z(e,Math.round(t.b*257)),Z(e,0)):"fr"in t?(Z(e,0),Z(e,Math.round(t.fr*255*257)),Z(e,Math.round(t.fg*255*257)),Z(e,Math.round(t.fb*255*257)),Z(e,0)):"l"in t?(Z(e,7),Ht(e,Math.round(t.l*1e4)),Ht(e,Math.round(t.a<0?t.a*12800:t.a*12700)),Ht(e,Math.round(t.b<0?t.b*12800:t.b*12700)),Z(e,0)):"h"in t?(Z(e,1),Z(e,Math.round(t.h*65535)),Z(e,Math.round(t.s*65535)),Z(e,Math.round(t.b*65535)),Z(e,0)):"c"in t?(Z(e,2),Z(e,Math.round(t.c*257)),Z(e,Math.round(t.m*257)),Z(e,Math.round(t.y*257)),Z(e,Math.round(t.k*257))):(Z(e,8),Z(e,Math.round(t.k*1e4/255)),sn(e,6)):(Z(e,0),sn(e,8))}function K0(e,t){let n=t.bounds.w,i=t.bounds.h,o={width:n,height:i,data:t.data};ue(e,0);let r=e.offset;ue(e,1),ue(e,3),Ht(e,t.x),Ht(e,t.y),Lc(e,t.name+"\0"),bo(e,t.id,1),ue(e,3),ue(e,0);let s=e.offset,a=t.bounds.y,l=t.bounds.x,c=a+i,d=l+n;ue(e,a),ue(e,l),ue(e,c),ue(e,d),ue(e,24);for(let h=0;h<26;h++){let p=h<3?h:h===25?3:-1;if(p<0){ue(e,0);continue}let S=new Uint8Array(n*i+2*i+2*n+16),m=(0,ve.writeDataRLE)(S,o,[p],!1);ue(e,1),ue(e,m.length+4+16+2+1),ue(e,8),ue(e,a),ue(e,l),ue(e,c),ue(e,d),Z(e,8),de(e,1),fi(e,m)}let u=e.offset-s,f=e.offset-r;for(;f%4;)sn(e,1),f++;e.view.setUint32(s-4,u,!1),e.view.setUint32(r-4,f,!1)}});var $c=oe(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.readAbr=tp;var X=Gi(),xe=jt(),Y0=["off","fade","pen pressure","pen tilt","stylus wheel","initial direction","direction","initial rotation","rotation"],jc=["round point","round blunt","round curve","round angle","round fan","flat point","flat blunt","flat curve","flat angle","flat fan"],J0=["erodible point","erodible flat","erodible round","erodible square","erodible triangle","custom"],Q0={_:"brush",MixB:"mixer brush",SmTl:"smudge brush"};function Oe(e){return{control:Y0[e.bVTy],steps:e.fStp,jitter:(0,X.parsePercent)(e.jitter),minimum:(0,X.parsePercent)(e["Mnm "])}}function zc(e){switch(e._classID){case"computedBrush":return{type:"computed",size:(0,X.parseUnitsToNumber)(e.Dmtr,"Pixels"),angle:(0,X.parseAngle)(e.Angl),roundness:(0,X.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,X.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY,hardness:(0,X.parsePercent)(e.Hrdn)};case"sampledBrush":return{type:"sampled",size:(0,X.parseUnitsToNumber)(e.Dmtr,"Pixels"),angle:(0,X.parseAngle)(e.Angl),roundness:(0,X.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,X.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY,name:e["Nm "],sampledData:e.sampledData};case"dBrush":return{type:"dynamic",shape:jc[e["Shp "]],angle:(0,X.parseAngle)(e.Angl),size:(0,X.parseUnitsToNumber)(e.Dmtr,"Pixels"),density:(0,X.parsePercent)(e.Dnst),length:(0,X.parsePercent)(e.Lngt),clumping:(0,X.parsePercent)(e.clumping),thickness:(0,X.parsePercent)(e.thickness),stiffness:(0,X.parsePercent)(e.stiffness),physics:e.physics,spacing:(0,X.parsePercent)(e.Spcn),spacingOn:e.Intr,flipX:e.flipX,flipY:e.flipY};case"dTips":return Object.assign(Object.assign({type:"tips",angle:(0,X.parseAngle)(e.Angl),size:(0,X.parseUnitsToNumber)(e.Dmtr,"Pixels"),shape:jc[e["Shp "]],physics:e.physics,spacing:(0,X.parsePercent)(e.Spcn),spacingOn:e.Intr,flipX:e.flipX,flipY:e.flipY,tipsType:J0[e.dtipsType],tipsLengthRatio:(0,X.parsePercent)(e.dtipsLengthRatio),tipsHardness:(0,X.parsePercent)(e.dtipsHardness)},e.dtipsGridSize&&e.dtipsErodibleTipHeightMap?{tipsGridSize:e.dtipsGridSize,tipsErodibleTipHeightMap:ep(e.dtipsErodibleTipHeightMap)}:{}),{tipsAirbrushCutoffAngle:e.dtipsAirbrushCutoffAngle,tipsAirbrushGranularity:(0,X.parsePercent)(e.dtipsAirbrushGranularity),tipsAirbrushStreakiness:(0,X.parsePercent)(e.dtipsAirbrushStreakiness),tipsAirbrushSplatSize:(0,X.parsePercent)(e.dtipsAirbrushSplatSize),tipsAirbrushSplatCount:e.dtipsAirbrushSplatCount});default:throw new Error(`Unknown brush classId: ${e._classID}`)}}function ep(e){let t=[];for(let n=0;n<e.byteLength;n++)t.push(e[n]);return t}function tp(e,t={}){var n,i,o,r;let s=(0,xe.createReader)(e.buffer,e.byteOffset,e.byteLength),a=(0,xe.readInt16)(s),l=[],c=[],d=[];if(a===1||a===2)throw new Error(`Unsupported ABR version (${a})`);if(a===6||a===7||a===9||a===10){let u=(0,xe.readInt16)(s);if(u!==1&&u!==2)throw new Error("Unsupported ABR minor version");for(;s.offset<s.view.byteLength;){(0,xe.checkSignature)(s,"8BIM");let f=(0,xe.readSignature)(s),h=(0,xe.readUint32)(s),p=s.offset+h;switch(f){case"samp":{for(;s.offset<p;){let S=(0,xe.readUint32)(s);for(;S&3;)S++;let m=s.offset+S,b=(0,xe.readPascalString)(s,1);(0,xe.skipBytes)(s,u===1?10:264);let v=(0,xe.readInt32)(s),x=(0,xe.readInt32)(s),_=(0,xe.readInt32)(s)-v,I=(0,xe.readInt32)(s)-x;if(I<=0||_<=0)throw new Error("Invalid bounds");let P=(0,xe.readInt16)(s),k=(0,xe.readUint8)(s),E=new Uint8Array(I*_);if(P===8)if(k===0)E.set((0,xe.readBytes)(s,E.byteLength));else if(k===1)(0,xe.readDataRLE)(s,{width:I,height:_,data:E},I,_,P,1,[0],!1);else throw new Error("Invalid compression");else if(P===16)if(k===0)for(let O=0;O<E.byteLength;O++)E[O]=(0,xe.readUint16)(s)>>8;else throw k===1?new Error("not implemented (16bit RLE)"):new Error("Invalid compression");else throw new Error("Invalid depth");l.push({id:b,bounds:{x,y:v,w:I,h:_},alpha:E}),s.offset=m}break}case"desc":{let S=(0,X.readVersionAndDescriptor)(s,!0);for(let m of S.Brsh){let b={name:m["Nm "],shape:zc(m.Brsh),spacing:(0,X.parsePercent)(m.Spcn),wetEdges:m.Wtdg,noise:m.Nose,useBrushSize:m.useBrushSize};m.interpretation!=null&&(b.interpretation=m.interpretation),m.protectTexture!=null&&(b.protectTexture=m.protectTexture),m.useTipDynamics&&(b.shapeDynamics={tiltScale:(0,X.parsePercent)(m.tiltScale),sizeDynamics:Oe(m.szVr),angleDynamics:Oe(m.angleDynamics),roundnessDynamics:Oe(m.roundnessDynamics),flipX:m.flipX,flipY:m.flipY,brushProjection:m.brushProjection,minimumDiameter:(0,X.parsePercent)(m.minimumDiameter),minimumRoundness:(0,X.parsePercent)(m.minimumRoundness)}),m.useScatter&&(b.scatter={count:m["Cnt "],bothAxes:m.bothAxes,countDynamics:Oe(m.countDynamics),scatterDynamics:Oe(m.scatterDynamics)}),m.useTexture&&m.Txtr&&(b.texture={id:m.Txtr.Idnt,name:m.Txtr["Nm "],blendMode:X.BlnM.decode(m.textureBlendMode),depth:(0,X.parsePercent)(m.textureDepth),depthMinimum:(0,X.parsePercent)(m.minimumDepth),depthDynamics:Oe(m.textureDepthDynamics),scale:(0,X.parsePercent)(m.textureScale),invert:m.InvT,brightness:m.textureBrightness,contrast:m.textureContrast,textureEachTip:!!m.TxtC});let v=m.dualBrush;v&&v.useDualBrush&&(b.dualBrush={flip:v.Flip,shape:zc(v.Brsh),blendMode:X.BlnM.decode(v.BlnM),useScatter:v.useScatter,spacing:(0,X.parsePercent)(v.Spcn),count:v["Cnt "],bothAxes:v.bothAxes,countDynamics:Oe(v.countDynamics),scatterDynamics:Oe(v.scatterDynamics)}),m.useColorDynamics&&(b.colorDynamics={foregroundBackground:Oe(m.clVr),hue:(0,X.parsePercent)(m["H "]),saturation:(0,X.parsePercent)(m.Strt),brightness:(0,X.parsePercent)(m.Brgh),purity:(0,X.parsePercent)(m.purity),perTip:m.colorDynamicsPerTip}),m.usePaintDynamics&&(b.transfer={flowDynamics:Oe(m.prVr),opacityDynamics:Oe(m.opVr),wetnessDynamics:Oe(m.wtVr),mixDynamics:Oe(m.mxVr)}),m.useBrushPose&&(b.brushPose={overrideAngle:m.overridePoseAngle,overrideTiltX:m.overridePoseTiltX,overrideTiltY:m.overridePoseTiltY,overridePressure:m.overridePosePressure,pressure:(0,X.parsePercent)(m.brushPosePressure),tiltX:m.brushPoseTiltX,tiltY:m.brushPoseTiltY,angle:m.brushPoseAngle});let x=m.toolOptions;x&&(b.toolOptions={type:Q0[x._classID]||"brush",brushPreset:x.brushPreset,flow:(n=x.flow)!==null&&n!==void 0?n:100,smooth:(i=x.Smoo)!==null&&i!==void 0?i:0,mode:X.BlnM.decode(x["Md "]||"BlnM.Nrml"),opacity:(o=x.Opct)!==null&&o!==void 0?o:100,smoothing:!!x.smoothing,smoothingValue:x.smoothingValue||0,smoothingRadiusMode:!!x.smoothingRadiusMode,smoothingCatchup:!!x.smoothingCatchup,smoothingCatchupAtEnd:!!x.smoothingCatchupAtEnd,smoothingZoomCompensation:!!x.smoothingZoomCompensation,pressureSmoothing:!!x.pressureSmoothing,usePressureOverridesSize:!!x.usePressureOverridesSize,usePressureOverridesOpacity:!!x.usePressureOverridesOpacity,useLegacy:!!x.useLegacy},x.prVr&&(b.toolOptions.flowDynamics=Oe(x.prVr)),x.opVr&&(b.toolOptions.opacityDynamics=Oe(x.opVr)),x.szVr&&(b.toolOptions.sizeDynamics=Oe(x.szVr)),"wetness"in x&&(b.toolOptions.wetness=x.wetness),"dryness"in x&&(b.toolOptions.dryness=x.dryness),"mix"in x&&(b.toolOptions.mix=x.mix),"autoFill"in x&&(b.toolOptions.autoFill=x.autoFill),"autoClean"in x&&(b.toolOptions.autoClean=x.autoClean),"loadSolidColorOnly"in x&&(b.toolOptions.loadSolidColorOnly=x.loadSolidColorOnly),"sampleAllLayers"in x&&(b.toolOptions.sampleAllLayers=x.sampleAllLayers),"SmdF"in x&&(b.toolOptions.smudgeFingerPainting=x.SmdF),"SmdS"in x&&(b.toolOptions.smudgeSampleAllLayers=x.SmdS),"Prs "in x&&(b.toolOptions.strength=x["Prs "])),c.push(b)}break}case"patt":{for(;s.offset<p;)d.push((0,xe.readPattern)(s));s.offset=p;break}case"phry":{let S=(0,X.readVersionAndDescriptor)(s);t.logMissingFeatures&&!((r=S.hierarchy)===null||r===void 0)&&r.length;break}default:throw new Error(`Invalid brush type: ${f}`)}for(;h%4;)s.offset++,h++}}else throw new Error(`Unsupported ABR version (${a})`);return{samples:l,patterns:d,brushes:c}}});var Nc=oe(Yr=>{"use strict";Object.defineProperty(Yr,"__esModule",{value:!0});Yr.readCsh=ip;var np=oo(),Qe=jt();function ip(e){let t=(0,Qe.createReader)(e.buffer,e.byteOffset,e.byteLength),n={shapes:[]};if((0,Qe.checkSignature)(t,"cush"),(0,Qe.readUint32)(t)!==2)throw new Error("Invalid version");let i=(0,Qe.readUint32)(t);for(let o=0;o<i;o++){let r=(0,Qe.readUnicodeString)(t);for(;t.offset%4;)t.offset++;if((0,Qe.readUint32)(t)!==1)throw new Error("Invalid shape version");let s=(0,Qe.readUint32)(t),a=t.offset+s,l=(0,Qe.readPascalString)(t,1),c=(0,Qe.readUint32)(t),d=(0,Qe.readUint32)(t),u=(0,Qe.readUint32)(t),h=(0,Qe.readUint32)(t)-d,p=u-c,S={paths:[]};(0,np.readVectorMask)(t,S,h,p,a-t.offset),n.shapes.push(Object.assign({name:r,id:l,width:h,height:p},S)),t.offset=a}return n}});var Zc=oe(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.Compression=et.ChannelID=et.LayerCompCapturedInfo=et.SectionDividerType=et.ColorMode=void 0;var Vc;(function(e){e[e.Bitmap=0]="Bitmap",e[e.Grayscale=1]="Grayscale",e[e.Indexed=2]="Indexed",e[e.RGB=3]="RGB",e[e.CMYK=4]="CMYK",e[e.Multichannel=7]="Multichannel",e[e.Duotone=8]="Duotone",e[e.Lab=9]="Lab"})(Vc||(et.ColorMode=Vc={}));var Gc;(function(e){e[e.Other=0]="Other",e[e.OpenFolder=1]="OpenFolder",e[e.ClosedFolder=2]="ClosedFolder",e[e.BoundingSectionDivider=3]="BoundingSectionDivider"})(Gc||(et.SectionDividerType=Gc={}));var Hc;(function(e){e[e.None=0]="None",e[e.Visibility=1]="Visibility",e[e.Position=2]="Position",e[e.Appearance=4]="Appearance"})(Hc||(et.LayerCompCapturedInfo=Hc={}));var Wc;(function(e){e[e.Color0=0]="Color0",e[e.Color1=1]="Color1",e[e.Color2=2]="Color2",e[e.Color3=3]="Color3",e[e.Transparency=-1]="Transparency",e[e.UserMask=-2]="UserMask",e[e.RealUserMask=-3]="RealUserMask"})(Wc||(et.ChannelID=Wc={}));var Xc;(function(e){e[e.RawData=0]="RawData",e[e.RleCompressed=1]="RleCompressed",e[e.ZipWithoutPrediction=2]="ZipWithoutPrediction",e[e.ZipWithPrediction=3]="ZipWithPrediction"})(Xc||(et.Compression=Xc={}))});var Kc=oe(ee=>{"use strict";var op=ee&&ee.__createBinding||(Object.create?(function(e,t,n,i){i===void 0&&(i=n);var o=Object.getOwnPropertyDescriptor(t,n);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,o)}):(function(e,t,n,i){i===void 0&&(i=n),e[i]=t[n]})),Jr=ee&&ee.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&op(t,e,n)};Object.defineProperty(ee,"__esModule",{value:!0});ee.getCompositeCanvas=ee.getCompositeImageData=ee.getLayerRealMaskCanvas=ee.getLayerMaskCanvas=ee.getLayerCanvas=ee.getLayerRealMaskImageData=ee.getLayerMaskImageData=ee.getLayerImageData=ee.decodeLayerPixels=ee.byteArrayToBase64=ee.initializeCanvas=void 0;ee.readPsd=ap;ee.writePsd=lp;ee.writePsdUint8Array=qc;ee.writePsdBuffer=cp;var Un=Dn(),tt=jt();Object.defineProperty(ee,"decodeLayerPixels",{enumerable:!0,get:function(){return tt.decodeLayerPixels}});Object.defineProperty(ee,"getLayerImageData",{enumerable:!0,get:function(){return tt.getLayerImageData}});Object.defineProperty(ee,"getLayerMaskImageData",{enumerable:!0,get:function(){return tt.getLayerMaskImageData}});Object.defineProperty(ee,"getLayerRealMaskImageData",{enumerable:!0,get:function(){return tt.getLayerRealMaskImageData}});Object.defineProperty(ee,"getLayerCanvas",{enumerable:!0,get:function(){return tt.getLayerCanvas}});Object.defineProperty(ee,"getLayerMaskCanvas",{enumerable:!0,get:function(){return tt.getLayerMaskCanvas}});Object.defineProperty(ee,"getLayerRealMaskCanvas",{enumerable:!0,get:function(){return tt.getLayerRealMaskCanvas}});Object.defineProperty(ee,"getCompositeImageData",{enumerable:!0,get:function(){return tt.getCompositeImageData}});Object.defineProperty(ee,"getCompositeCanvas",{enumerable:!0,get:function(){return tt.getCompositeCanvas}});var rp=ji();Jr($c(),ee);Jr(Nc(),ee);var sp=Tt();Object.defineProperty(ee,"initializeCanvas",{enumerable:!0,get:function(){return sp.initializeCanvas}});Jr(Zc(),ee);ee.byteArrayToBase64=rp.fromByteArray;function ap(e,t){let n="buffer"in e?(0,tt.createReader)(e.buffer,e.byteOffset,e.byteLength):(0,tt.createReader)(e);return(0,tt.readPsd)(n,t)}function lp(e,t){let n=(0,Un.createWriter)();return(0,Un.writePsd)(n,e,t),(0,Un.getWriterBuffer)(n)}function qc(e,t){let n=(0,Un.createWriter)();return(0,Un.writePsd)(n,e,t),(0,Un.getWriterBufferNoCopy)(n)}function cp(e,t){if(typeof Buffer>"u")throw new Error("Buffer not supported on this platform");return Buffer.from(qc(e,t))}});var So=_d(Kc(),1);var wo=class{view;offset=0;constructor(t){this.view=new DataView(t)}get length(){return this.view.byteLength}ensure(t,n=this.length,i="Adobe resource"){if(!Number.isSafeInteger(t)||t<0||this.offset+t>n||n>this.length)throw new Error(`${i} is truncated or has an invalid length.`)}u8(t,n){return this.ensure(1,t,n),this.view.getUint8(this.offset++)}i16(t,n){this.ensure(2,t,n);let i=this.view.getInt16(this.offset,!1);return this.offset+=2,i}u16(t,n){this.ensure(2,t,n);let i=this.view.getUint16(this.offset,!1);return this.offset+=2,i}i32(t,n){this.ensure(4,t,n);let i=this.view.getInt32(this.offset,!1);return this.offset+=4,i}u32(t,n){this.ensure(4,t,n);let i=this.view.getUint32(this.offset,!1);return this.offset+=4,i}i32le(t,n){this.ensure(4,t,n);let i=this.view.getInt32(this.offset,!0);return this.offset+=4,i}ascii(t,n,i){this.ensure(t,n,i);let o="";for(let r=0;r<t;r+=1)o+=String.fromCharCode(this.view.getUint8(this.offset++));return o}skip(t,n,i){this.ensure(t,n,i),this.offset+=t}},Qr=e=>{let t=e+3&-4;if(!Number.isSafeInteger(t)||t<e)throw new Error("Adobe resource alignment overflowed.");return t},St=(e,t,n)=>{let i=e*t;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${n} overflows the safe integer range.`);return i},Yc=(e,t,n)=>{if(e.byteLength>t.maxFileBytes)throw new Error(`${n.toUpperCase()} source exceeds the ${t.maxFileBytes}-byte safety limit.`)},cn=(e,t,n)=>{if(!Number.isSafeInteger(e)||e<0||e>t.maxResourceItems)throw new Error(`${n} exceeds the ${t.maxResourceItems}-item safety limit.`)},Jc=(e,t,n,i)=>{cn(t,n,i),e.descriptorItems+=t;let o=Math.min(1e6,n.maxResourceItems*64);if(e.descriptorItems>o)throw new Error(`Adobe descriptor complexity exceeds the ${o}-record safety limit.`)},Qc=(e,t,n,i,o)=>{if(t<=0||t>i.maxResourcePreviewPixels)throw new Error(`${o} exceeds the ${i.maxResourcePreviewPixels}-pixel preview limit.`);if(e.previewPixels+=t,e.decodedBytes+=n,e.previewPixels>i.maxResourcePreviewPixels)throw new Error(`Adobe resource previews exceed the ${i.maxResourcePreviewPixels}-pixel collection limit.`);if(e.decodedBytes>i.maxDecodedBytes)throw new Error(`Adobe resource decoding exceeds the ${i.maxDecodedBytes}-byte safety limit.`)},Rn=(e,t,n,i)=>{let o=e.u32(t,i);if(o>n.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-code-unit name limit.`);e.skip(St(o,2,`${i} length`),t,i)},es=(e,t,n,i)=>{let o=e.u8(t,i);if(o>n.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-code-unit name limit.`);e.skip(o,t,i)},Pt=(e,t,n,i)=>{let o=e.i32(t,i);if(o<0)throw new Error(`${i} has a negative string length.`);let r=o||4;if(r>n.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-character identifier limit.`);e.skip(r,t,i)},ln=(e,t,n,i)=>{Rn(e,t,n,`${i} name`),Pt(e,t,n,`${i} class id`)},yo=(e,t,n,i,o)=>{let r=e.i32(t,o);if(r<0)throw new Error(`${o} has a negative item count.`);return Jc(n,r,i,o),r},ed=(e,t,n,i,o,r)=>{if(i>r.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${r.maxNestingDepth}-level safety limit.`);switch(n){case"obj ":{let s=yo(e,t,o,r,"Adobe descriptor reference");for(let a=0;a<s;a+=1){let l=e.ascii(4,t,"Adobe descriptor reference type");if(l==="prop")ln(e,t,r,"Adobe property reference"),Pt(e,t,r,"Adobe property key");else if(l==="Clss")ln(e,t,r,"Adobe class reference");else if(l==="Enmr")ln(e,t,r,"Adobe enum reference"),Pt(e,t,r,"Adobe enum type"),Pt(e,t,r,"Adobe enum value");else if(l==="rele")ln(e,t,r,"Adobe offset reference"),e.skip(4,t,"Adobe offset reference");else if(l==="Idnt"||l==="indx")e.skip(4,t,"Adobe integer reference");else if(l==="name")ln(e,t,r,"Adobe name reference"),Rn(e,t,r,"Adobe reference name");else throw new Error(`Unsupported Adobe descriptor reference type ${JSON.stringify(l)}.`)}return}case"Objc":case"GlbO":td(e,t,i+1,o,r);return;case"VlLs":{let s=yo(e,t,o,r,"Adobe descriptor list");for(let a=0;a<s;a+=1){let l=e.ascii(4,t,"Adobe descriptor list type");ed(e,t,l,i+1,o,r)}return}case"doub":e.skip(8,t,"Adobe double");return;case"UntF":e.skip(12,t,"Adobe unit double");return;case"UnFl":e.skip(8,t,"Adobe unit float");return;case"TEXT":Rn(e,t,r,"Adobe descriptor text");return;case"enum":Pt(e,t,r,"Adobe enum type"),Pt(e,t,r,"Adobe enum value");return;case"long":e.skip(4,t,"Adobe integer");return;case"comp":e.skip(8,t,"Adobe large integer");return;case"bool":e.skip(1,t,"Adobe boolean");return;case"type":case"GlbC":ln(e,t,r,"Adobe descriptor class");return;case"alis":case"tdta":{let s=e.i32(t,"Adobe descriptor data length");if(s<0||s>r.maxDecodedBytes)throw new Error(`Adobe descriptor data exceeds the ${r.maxDecodedBytes}-byte safety limit.`);e.skip(s,t,"Adobe descriptor data");return}case"ObAr":{e.skip(4,t,"Adobe object-array version"),Rn(e,t,r,"Adobe object-array name"),Pt(e,t,r,"Adobe object-array class");let s=yo(e,t,o,r,"Adobe object array");for(let a=0;a<s;a+=1){Pt(e,t,r,"Adobe object-array item type");let l=e.ascii(4,t,"Adobe object-array value type");if(l!=="UnFl")throw new Error(`Unsupported Adobe object-array value type ${JSON.stringify(l)}.`);e.skip(4,t,"Adobe object-array units");let c=yo(e,t,o,r,"Adobe object-array values");e.skip(St(c,8,"Adobe object-array values"),t,"Adobe object-array values")}return}case"Pth ":{let s=e.i32(t,"Adobe path length");if(s<0||s>r.maxDecodedBytes)throw new Error("Adobe descriptor path length is invalid.");e.skip(4,t,"Adobe path signature");let a=e.i32le(t,"Adobe path size"),l=e.i32le(t,"Adobe path character count");if(a<0||l<0||l>r.maxResourceNameCodeUnits)throw new Error("Adobe descriptor path exceeds its bounded string limits.");e.skip(St(l,2,"Adobe path characters"),t,"Adobe descriptor path");return}default:throw new Error(`Unsupported Adobe descriptor value type ${JSON.stringify(n)}.`)}},td=(e,t,n,i,o)=>{if(n>o.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${o.maxNestingDepth}-level safety limit.`);ln(e,t,o,"Adobe descriptor");let r=e.u32(t,"Adobe descriptor item count");Jc(i,r,o,"Adobe descriptor item count");for(let s=0;s<r;s+=1){Pt(e,t,o,"Adobe descriptor key");let a=e.ascii(4,t,"Adobe descriptor value type");ed(e,t,a,n+1,i,o)}},dp=(e,t,n,i)=>{let o=e.u32(t,"Adobe descriptor version");if(o!==16)throw new Error(`Unsupported Adobe descriptor version ${o}.`);td(e,t,0,n,i)},nd=(e,t,n,i,o)=>{let r=St(i,2,`${o} row table`);e.ensure(r,t,o);let s=Array.from({length:i},()=>e.u16(t,`${o} row length`));for(let a=0;a<i;a+=1){let l=e.offset+s[a];if(l>t)throw new Error(`${o} compressed row ${a} is truncated.`);let c=0;for(;e.offset<l;){let d=e.u8(l,`${o} PackBits header`);if(d<=127){let u=d+1;e.skip(u,l,`${o} PackBits literal`),c+=u}else d>=129&&(e.skip(1,l,`${o} PackBits repeat value`),c+=257-d);if(c>n)throw new Error(`${o} PackBits row ${a} expands beyond its declared width.`)}if(c!==n)throw new Error(`${o} PackBits row ${a} does not expand to its declared width.`)}},fp=(e,t,n,i,o)=>{let r=0;for(;e.offset<t;){cn(++r,o,"ABR sample count");let s=e.u32(t,"ABR sample length"),a=e.offset,l=a+s,c=a+Qr(s);if(l>t||c>t)throw new Error("ABR sample record is truncated.");es(e,l,o,"ABR sample id"),e.skip(n===1?10:264,l,"ABR sample header");let d=e.i32(l,"ABR sample top"),u=e.i32(l,"ABR sample left"),f=e.i32(l,"ABR sample bottom"),p=e.i32(l,"ABR sample right")-u,S=f-d;if(p<=0||S<=0||p>o.maxCanvasDimension||S>o.maxCanvasDimension)throw new Error(`ABR sample dimensions exceed the ${o.maxCanvasDimension}-pixel side limit.`);let m=St(p,S,"ABR sample pixels"),b=e.i16(l,"ABR sample depth"),v=e.u8(l,"ABR sample compression");if(b!==8&&b!==16)throw new Error(`Unsupported ABR sample depth ${b}.`);if(v!==0&&v!==1)throw new Error(`Unsupported ABR sample compression ${v}.`);if(b===16&&v===1)throw new Error("ABR 16-bit RLE samples are not supported by the decoding engine.");if(Qc(i,m,m,o,"ABR sample"),v===0?e.skip(St(m,b/8,"ABR raw sample bytes"),l,"ABR raw sample"):nd(e,l,p,S,"ABR sample"),e.offset>l)throw new Error("ABR sample payload exceeded its declared record boundary.");e.offset=l,e.offset=c}return r},up=(e,t,n,i)=>{let o=e.u32(t,"ABR pattern length"),s=e.offset+Qr(o);if(s>t)throw new Error("ABR pattern record is truncated.");if(e.u32(s,"ABR pattern version")!==1)throw new Error("Unsupported ABR pattern version.");let a=e.u32(s,"ABR pattern color mode");if(a!==1&&a!==2&&a!==3)throw new Error(`Unsupported ABR pattern color mode ${a}.`);if(e.skip(4,s,"ABR pattern origin"),Rn(e,s,i,"ABR pattern name"),es(e,s,i,"ABR pattern id"),a===2&&e.skip(772,s,"ABR indexed palette"),e.u32(s,"ABR pattern VMAL version")!==3)throw new Error("Unsupported ABR pattern VMAL version.");e.u32(s,"ABR pattern VMAL length");let l=e.u32(s,"ABR pattern top"),c=e.u32(s,"ABR pattern left"),d=e.u32(s,"ABR pattern bottom"),u=e.u32(s,"ABR pattern right"),f=e.u32(s,"ABR pattern channel count");if(d<=l||u<=c||f>16)throw new Error("ABR pattern bounds or channel count is invalid.");let h=u-c,p=d-l;if(h>i.maxCanvasDimension||p>i.maxCanvasDimension)throw new Error(`ABR pattern dimensions exceed the ${i.maxCanvasDimension}-pixel side limit.`);let S=St(h,p,"ABR pattern pixels");Qc(n,S,St(S,4,"ABR pattern RGBA bytes"),i,"ABR pattern");for(let m=0;m<f+2;m+=1){if(!e.u32(s,"ABR pattern channel presence"))continue;let v=e.u32(s,"ABR pattern channel length");if(v<23)throw new Error("ABR pattern channel length is invalid.");let x=e.offset+v;if(x>s)throw new Error("ABR pattern channel is truncated.");let _=e.u32(x,"ABR pattern channel depth"),I=e.u32(x,"ABR pattern channel top"),P=e.u32(x,"ABR pattern channel left"),k=e.u32(x,"ABR pattern channel bottom"),E=e.u32(x,"ABR pattern channel right"),O=e.u16(x,"ABR pattern channel depth duplicate"),U=e.u8(x,"ABR pattern channel compression");if(_!==8||O!==8||U!==0&&U!==1)throw new Error("ABR pattern channel uses an unsupported depth or compression mode.");if(k<I||E<P||I<l||P<c||k>d||E>u)throw new Error("ABR pattern channel bounds are invalid.");let M=E-P,le=k-I,me=St(M,le,"ABR pattern channel pixels");if(U===0){if(x-e.offset!==me)throw new Error("ABR raw pattern channel length does not match its dimensions.");e.skip(me,x,"ABR raw pattern channel")}else if(nd(e,x,M,le,"ABR pattern channel"),e.offset!==x)throw new Error("ABR RLE pattern channel has trailing bytes.")}e.offset=s},id=(e,t)=>{Yc(e,t,"ABR");let n=new wo(e),i=n.i16(void 0,"ABR version");if(i!==6&&i!==7&&i!==9&&i!==10)throw new Error(`Unsupported ABR version ${i}; the browser engine supports modern ABR versions 6, 7, 9, and 10.`);let o=n.i16(void 0,"ABR minor version");if(o!==1&&o!==2)throw new Error(`Unsupported ABR minor version ${o}.`);let r={descriptorItems:0,previewPixels:0,decodedBytes:0},s=0,a=0,l=0;for(;n.offset<n.length;){if(cn(++s,t,"ABR section count"),n.ascii(4,void 0,"ABR section signature")!=="8BIM")throw new Error("Invalid ABR section signature.");let c=n.ascii(4,void 0,"ABR section type"),d=n.u32(void 0,"ABR section length"),u=n.offset,f=u+d,h=u+Qr(d);if(f>n.length||h>n.length)throw new Error("ABR section is truncated.");if(c==="samp")a+=fp(n,f,o,r,t);else if(c==="desc"||c==="phry"){if(dp(n,f,r,t),n.offset!==f)throw new Error(`ABR ${c} descriptor does not consume its declared section.`)}else if(c==="patt")for(;n.offset<f;)cn(++l,t,"ABR pattern count"),up(n,f,r,t);else throw new Error(`Unsupported ABR section type ${JSON.stringify(c)}.`);if(n.offset>f)throw new Error(`ABR ${c} section exceeded its declared boundary.`);n.offset=h}return cn(a+l,t,"ABR decoded resource count"),{format:"abr",majorVersion:i,minorVersion:o,sections:s,samples:a,patterns:l,previewPixels:r.previewPixels,decodedBytes:r.decodedBytes}},od=(e,t)=>{Yc(e,t,"CSH");let n=new wo(e);if(n.ascii(4,void 0,"CSH signature")!=="cush")throw new Error("Invalid CSH signature.");let i=n.u32(void 0,"CSH version");if(i!==2)throw new Error(`Unsupported CSH version ${i}; version 2 is required.`);let o=n.u32(void 0,"CSH shape count");cn(o,t,"CSH shape count");let r=0,s=0,a=Math.min(1e6,t.maxResourceItems*64);for(let l=0;l<o;l+=1){for(Rn(n,n.length,t,`CSH shape ${l} name`);n.offset%4;)n.skip(1,n.length,"CSH name padding");if(n.u32(void 0,"CSH shape version")!==1)throw new Error("Unsupported CSH shape record version.");let c=n.u32(void 0,"CSH shape record length"),d=n.offset+c;if(d>n.length)throw new Error("CSH shape record is truncated.");es(n,d,t,`CSH shape ${l} id`);let u=n.u32(d,"CSH shape top"),f=n.u32(d,"CSH shape left"),h=n.u32(d,"CSH shape bottom"),p=n.u32(d,"CSH shape right");if(h<=u||p<=f)throw new Error("CSH shape bounds are invalid.");let S=p-f,m=h-u;if(S>t.maxCanvasDimension||m>t.maxCanvasDimension)throw new Error(`CSH shape dimensions exceed the ${t.maxCanvasDimension}-pixel side limit.`);let b=St(S,m,"CSH shape preview pixels");if(s+=b,s>t.maxResourcePreviewPixels)throw new Error(`CSH previews exceed the ${t.maxResourcePreviewPixels}-pixel collection limit.`);if((d-n.offset)%26!==0)throw new Error("CSH vector record section is not aligned to 26-byte path records.");let v=0,x=0,_=!1;for(;n.offset<d;){if(r+=1,r>a)throw new Error(`CSH path complexity exceeds the ${a}-record safety limit.`);let I=n.u16(d,"CSH vector selector");if(I===0||I===3){if(_&&x!==v)throw new Error("CSH path knot count does not match its declared count.");v=n.u16(d,"CSH path knot count"),cn(v,t,"CSH path knot count");let P=n.i16(d,"CSH path boolean operation");if(P<-1||P>3)throw new Error("CSH path boolean operation is invalid.");n.skip(20,d,"CSH path header"),x=0,_=!0}else if(I===1||I===2||I===4||I===5){if(!_)throw new Error("CSH knot appears before a path header.");if(n.skip(24,d,"CSH Bezier knot"),x+=1,x>v)throw new Error("CSH path contains more knots than declared.")}else if(I===6||I===7||I===8)n.skip(24,d,"CSH vector metadata record");else throw new Error(`Unsupported CSH vector selector ${I}.`)}if(_&&x!==v)throw new Error("CSH path knot count does not match its declared count.")}if(n.offset!==n.length)throw new Error("CSH file has trailing bytes outside its declared shapes.");return{format:"csh",version:2,shapes:o,pathRecords:r,previewPixels:s}};var Et=(e,t)=>{if(!Number.isFinite(e))throw new Error(`${t} is not finite.`);return e},dn=(e,t,n)=>{if(e.length>t.maxResourceNameCodeUnits)throw new Error(`${n} exceeds the ${t.maxResourceNameCodeUnits}-code-unit name limit.`);return e},hp=(e,t,n)=>{let i=Et(e.size,`${n} size`),o=Et(e.angle,`${n} angle`);if(i<0||i>t.maxCanvasDimension)throw new Error(`${n} size exceeds the ${t.maxCanvasDimension}-pixel side limit.`);let r={type:e.type,size:i,angle:o};return"roundness"in e&&(r.roundness=Et(e.roundness,`${n} roundness`)),"hardness"in e&&(r.hardness=Et(e.hardness,`${n} hardness`)),"spacing"in e&&(r.spacing=Et(e.spacing,`${n} spacing`)),e.type==="sampled"&&(r.sampledDataId=dn(e.sampledData,t,`${n} sampled-data id`)),r},pp=(e,t)=>({name:dn(e.name,t,"ABR brush name"),shape:hp(e.shape,t,`ABR brush ${JSON.stringify(e.name)}`),hasDynamics:!!(e.shapeDynamics||e.scatter||e.colorDynamics||e.transfer||e.brushPose),hasTexture:!!e.texture,hasDualBrush:!!e.dualBrush,...e.toolOptions?.type?{toolType:e.toolOptions.type}:{}}),mp=(e,t)=>{let n=id(e,t),i=(0,So.readAbr)(new Uint8Array(e),{logMissingFeatures:!1});if(i.brushes.length+i.samples.length+i.patterns.length>t.maxResourceItems)throw new Error(`ABR decoded resources exceed the ${t.maxResourceItems}-item safety limit.`);let r=0,s=0,a=i.samples.map((c,d)=>{let{w:u,h:f,x:h,y:p}=c.bounds,S=u*f;if(!Number.isSafeInteger(S)||S<=0||c.alpha.byteLength!==S)throw new Error(`ABR sample ${d} returned inconsistent decoded pixels.`);return s+=S,r+=c.alpha.byteLength,{id:dn(c.id,t,`ABR sample ${d} id`),x:Et(h,`ABR sample ${d} x`),y:Et(p,`ABR sample ${d} y`),width:u,height:f,alpha:c.alpha}}),l=i.patterns.map((c,d)=>{let{w:u,h:f,x:h,y:p}=c.bounds,S=u*f;if(!Number.isSafeInteger(S)||S<=0||c.data.byteLength!==S*4)throw new Error(`ABR pattern ${d} returned inconsistent decoded pixels.`);return s+=S,r+=c.data.byteLength,{id:dn(c.id,t,`ABR pattern ${d} id`),name:dn(c.name,t,`ABR pattern ${d} name`),x:Et(h,`ABR pattern ${d} x`),y:Et(p,`ABR pattern ${d} y`),width:u,height:f,rgba:c.data}});if(s!==n.previewPixels||s>t.maxResourcePreviewPixels)throw new Error("ABR decoded preview pixels do not match the bounded preflight result.");if(r!==n.decodedBytes||r>t.maxDecodedBytes)throw new Error("ABR decoded byte count does not match the bounded preflight result.");return{format:"abr",version:`${n.majorVersion}.${n.minorVersion}`,engine:"ag-psd",fidelity:"decoded-tip-and-metadata-preview",brushes:i.brushes.map(c=>pp(c,t)),samples:a,patterns:l,limitations:["The preview shows decoded tip alpha, embedded pattern pixels, and preset metadata; it does not simulate a painted stroke.","Legacy ABR versions 1 and 2 and 16-bit RLE brush samples are rejected because the decoding engine does not implement them."]}},ze=e=>{let t=Math.abs(e)<1e-9?0:e;return Number(t.toFixed(4)).toString()},gp=(e,t)=>{if(!e.knots.length)return{d:"",fillRule:e.fillRule,...e.operation?{operation:e.operation}:{}};let n=e.knots.map((r,s)=>{if(r.points.length!==6||r.points.some(a=>!Number.isFinite(a)))throw new Error(`${t} knot ${s} has invalid Bezier coordinates.`);return r.points}),i=n[0],o=`M ${ze(i[2])} ${ze(i[3])}`;for(let r=1;r<n.length;r+=1){let s=n[r-1],a=n[r];o+=` C ${ze(s[4])} ${ze(s[5])} ${ze(a[0])} ${ze(a[1])} ${ze(a[2])} ${ze(a[3])}`}if(!e.open){let r=n.at(-1);o+=` C ${ze(r[4])} ${ze(r[5])} ${ze(i[0])} ${ze(i[1])} ${ze(i[2])} ${ze(i[3])} Z`}return{d:o,fillRule:e.fillRule,...e.operation?{operation:e.operation}:{}}},bp=(e,t)=>{let n=od(e,t),i=(0,So.readCsh)(new Uint8Array(e));if(i.shapes.length!==n.shapes)throw new Error("CSH decoded shape count does not match its bounded preflight result.");let o=0,r=0,s=Math.min(1e6,t.maxResourceItems*64);return{format:"csh",version:"2",engine:"ag-psd",fidelity:"vector-path-preview",shapes:i.shapes.map((l,c)=>{if(!Number.isSafeInteger(l.width)||!Number.isSafeInteger(l.height)||l.width<=0||l.height<=0)throw new Error(`CSH shape ${c} has invalid dimensions.`);o+=l.paths.length;let d=l.paths.map((u,f)=>(r+=u.knots.length,gp(u,`CSH shape ${c} path ${f}`)));if(o+r>s)throw new Error(`CSH decoded path complexity exceeds the ${s}-record safety limit.`);return{id:dn(l.id,t,`CSH shape ${c} id`),name:dn(l.name,t,`CSH shape ${c} name`),width:l.width,height:l.height,paths:d,hasUnsupportedBooleanComposition:l.paths.some(u=>u.operation&&u.operation!=="combine")}}),limitations:["Bezier geometry is preserved, but Photoshop exclude/subtract/intersect path operations are exposed as metadata rather than rasterized with Photoshop composition semantics.","The preview does not include Photoshop tool presets, fills, strokes, or effects because CSH stores custom-shape paths rather than a styled document."]}},rd=(e,t,n)=>t==="abr"?mp(e,n):bp(e,n);var yp=(e,t,n)=>{let i=e*t;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${n} exceeds the safe integer range.`);return i},wp=(e,t)=>{if(!Number.isFinite(e))throw new Error(`${t} is not finite.`);return e},Mn=class{bytes;view;offset=0;constructor(t){this.bytes=t instanceof Uint8Array?t:new Uint8Array(t),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength)}get length(){return this.bytes.byteLength}get remaining(){return this.length-this.offset}ensure(t,n=this.length,i="Adobe binary data"){if(!Number.isSafeInteger(t)||t<0||this.offset>n||t>n-this.offset)throw new Error(`${i} is truncated.`)}u8(t=this.length,n){return this.ensure(1,t,n),this.view.getUint8(this.offset++)}u16(t=this.length,n){this.ensure(2,t,n);let i=this.view.getUint16(this.offset,!1);return this.offset+=2,i}i16(t=this.length,n){this.ensure(2,t,n);let i=this.view.getInt16(this.offset,!1);return this.offset+=2,i}u32(t=this.length,n){this.ensure(4,t,n);let i=this.view.getUint32(this.offset,!1);return this.offset+=4,i}i32(t=this.length,n){this.ensure(4,t,n);let i=this.view.getInt32(this.offset,!1);return this.offset+=4,i}i64(t=this.length,n){this.ensure(8,t,n);let i=this.view.getBigInt64(this.offset,!1);return this.offset+=8,i}f64(t=this.length,n){this.ensure(8,t,n);let i=this.view.getFloat64(this.offset,!1);return this.offset+=8,wp(i,n||"Adobe double")}ascii(t,n=this.length,i="Adobe ASCII data"){this.ensure(t,n,i);let o="";for(let r=0;r<t;r+=1)o+=String.fromCharCode(this.bytes[this.offset+r]);return this.offset+=t,o}slice(t,n=this.length,i="Adobe binary data"){this.ensure(t,n,i);let o=this.bytes.subarray(this.offset,this.offset+t);return this.offset+=t,o}skip(t,n=this.length,i="Adobe binary data"){this.ensure(t,n,i),this.offset+=t}},hi=(e,t,n,i)=>{let o=e.u32(t,`${i} length`);if(o>n.maxResourceNameCodeUnits+1)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-code-unit safety limit.`);let r=e.slice(yp(o,2,`${i} bytes`),t,i),s="";for(let a=0;a<o;a+=1){let l=r[a*2]<<8|r[a*2+1];if(!(l===0&&a===o-1))if(l>=55296&&l<=56319){if(a+1>=o)throw new Error(`${i} ends with an unpaired UTF-16 surrogate.`);let c=r[(a+1)*2]<<8|r[(a+1)*2+1];if(c<56320||c>57343)throw new Error(`${i} contains an invalid UTF-16 surrogate pair.`);s+=String.fromCodePoint(65536+(l-55296<<10)+(c-56320)),a+=1}else{if(l>=56320&&l<=57343)throw new Error(`${i} contains an unpaired UTF-16 surrogate.`);s+=String.fromCharCode(l)}}if(s.length>n.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-code-unit safety limit.`);return s},Wt=(e,t,n,i)=>{let o=e.u32(t,`${i} length`),r=o===0?4:o;if(r===0||r>n.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-byte safety limit.`);return e.ascii(r,t,i)},ui=(e,t,n)=>{if(!Number.isSafeInteger(t)||t<0||t>e.maximum-e.values)throw new Error(`${n} exceeds the ${e.maximum}-value descriptor safety limit.`);e.values+=t},sd=(e,t,n,i)=>({name:hi(e,t,n,`${i} name`),classId:Wt(e,t,n,`${i} id`)}),Sp=(e,t,n,i)=>{let o=e.u32(t,"Adobe reference count");ui(i,o,"Adobe reference count");let r=[];for(let s=0;s<o;s+=1){let a=e.ascii(4,t,"Adobe reference form"),{name:l,classId:c}=sd(e,t,n,"Adobe reference class"),d={form:a,className:l,classId:c};if(a==="prop")d.property=Wt(e,t,n,"Adobe reference property");else if(a==="Enmr")d.enumType=Wt(e,t,n,"Adobe reference enum type"),d.enumValue=Wt(e,t,n,"Adobe reference enum value");else if(a==="rele"||a==="Idnt"||a==="indx")d.index=e.i32(t,"Adobe reference index");else if(a==="name")d.name=hi(e,t,n,"Adobe reference name");else if(a!=="Clss")throw new Error(`Unsupported Adobe reference form ${JSON.stringify(a)}.`);r.push(d)}return r},vp=(e,t,n)=>{let i=e.u32(t,"Adobe descriptor path length");if(i>n.maxDecodedBytes)throw new Error(`Adobe descriptor path exceeds the ${n.maxDecodedBytes}-byte safety limit.`);return e.skip(i,t,"Adobe descriptor path"),{type:"path",length:i}},ad=(e,t,n,i,o,r)=>{if(r>i.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${i.maxNestingDepth}-level safety limit.`);switch(n){case"bool":return{type:"boolean",value:e.u8(t,"Adobe boolean")!==0};case"long":return{type:"integer",value:e.i32(t,"Adobe integer")};case"comp":return{type:"large-integer",value:e.i64(t,"Adobe large integer")};case"doub":return{type:"double",value:e.f64(t,"Adobe double")};case"UntF":return{type:"unit-double",unit:e.ascii(4,t,"Adobe unit"),value:e.f64(t,"Adobe unit double")};case"TEXT":return{type:"text",value:hi(e,t,i,"Adobe descriptor text")};case"enum":return{type:"enum",enumType:Wt(e,t,i,"Adobe enum type"),value:Wt(e,t,i,"Adobe enum value")};case"Objc":case"GlbO":return{type:"object",value:fn(e,t,i,o,r+1)};case"VlLs":{let s=e.u32(t,"Adobe list count");ui(o,s,"Adobe list count");let a=[];for(let l=0;l<s;l+=1)a.push(ad(e,t,e.ascii(4,t,"Adobe list value type"),i,o,r+1));return{type:"list",value:a}}case"alis":case"tdta":{let s=e.u32(t,"Adobe raw data length");if(s>i.maxDecodedBytes)throw new Error(`Adobe raw data exceeds the ${i.maxDecodedBytes}-byte safety limit.`);return e.skip(s,t,"Adobe raw data"),{type:"raw",length:s,alias:n==="alis"}}case"type":case"GlbC":{let s=sd(e,t,i,"Adobe class reference");return{type:"class",name:s.name,classId:s.classId}}case"UnFl":{let s=e.ascii(4,t,"Adobe unit-float-array unit"),a=e.u32(t,"Adobe unit-float-array count");ui(o,a,"Adobe unit-float-array count");let l=Array.from({length:a},()=>e.f64(t,"Adobe unit-float-array value"));return{type:"unit-double-array",unit:s,value:l}}case"ObAr":{let s=e.u32(t,"Adobe object-array count");return ui(o,s,"Adobe object-array count"),{type:"object-array",count:s,value:fn(e,t,i,o,r+1)}}case"obj ":return{type:"reference",value:Sp(e,t,i,o)};case"Pth ":return vp(e,t,i);default:throw new Error(`Unsupported Adobe descriptor value type ${JSON.stringify(n)}.`)}},pi=e=>{let t=Number.isSafeInteger(e.maxResourceItems)&&e.maxResourceItems>0?Math.min(1e6,e.maxResourceItems):1;return{values:0,maximum:t>3906?1e6:t*256}},fn=(e,t,n,i=pi(n),o=0)=>{if(o>n.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${n.maxNestingDepth}-level safety limit.`);let r=hi(e,t,n,"Adobe descriptor name"),s=Wt(e,t,n,"Adobe descriptor class"),a=e.u32(t,"Adobe descriptor item count");ui(i,a,"Adobe descriptor item count");let l=new Map,c=[];for(let d=0;d<a;d+=1){let u=Wt(e,t,n,"Adobe descriptor key");if(l.has(u))throw new Error(`Adobe descriptor contains duplicate key ${JSON.stringify(u)}.`);let f=e.ascii(4,t,"Adobe descriptor value type");l.set(u,ad(e,t,f,n,i,o+1)),c.push(u)}return{name:r,classId:s,entries:l,keys:c}},Le=(e,t)=>e?.entries.get(t),mi=(e,t)=>{let n=Le(e,t);return n?.type==="object"?n.value:void 0},un=(e,t)=>{let n=Le(e,t);return n?.type==="text"?n.value:void 0},gi=(e,t)=>{let n=Le(e,t);return n?.type==="enum"?n.value:void 0},bi=(e,t,n=!1)=>{let i=Le(e,t);return i?.type==="boolean"?i.value:n},ye=(e,t,n=0)=>{let i=Le(e,t);return i?i.type==="integer"||i.type==="double"||i.type==="unit-double"?i.value:i.type==="large-integer"?Number(i.value):n:n},ld=hi;var xp=["maxFileBytes","maxCanvasPixels","maxCanvasDimension","maxLayers","maxNestingDepth","maxLayerPixels","maxDecodedBytes","maxLayerCacheBytes","maxResourceItems","maxResourceNameCodeUnits","maxResourcePreviewPixels"],_p=e=>{for(let t of xp){let n=e[t];if(!Number.isSafeInteger(n)||n<=0)throw new Error(`Invalid Adobe preset safety limit ${t}.`)}},ud=e=>e+3&-4,st=(e,t,n)=>{let i=e+t;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${n} exceeds the safe integer range.`);return i},xo=(e,t,n)=>{let i=e*t;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${n} exceeds the safe integer range.`);return i},ns=(e,t,n)=>{if(e.byteLength>t.maxFileBytes)throw new Error(`${n} source exceeds the ${t.maxFileBytes}-byte safety limit.`);if(!e.byteLength)throw new Error(`${n} source is empty.`)},hd=(e,t,n,i,o)=>{if(e.previewPixels=st(e.previewPixels,t,`${o} preview pixels`),e.decodedBytes=st(e.decodedBytes,n,`${o} decoded bytes`),e.previewPixels>i.maxResourcePreviewPixels)throw new Error(`${o} exceeds the ${i.maxResourcePreviewPixels}-pixel preview safety limit.`);if(e.decodedBytes>i.maxDecodedBytes)throw new Error(`${o} exceeds the ${i.maxDecodedBytes}-byte decoded-data safety limit.`)},Ap=(e,t,n,i)=>{let o=e.u8(t,`${i} length`);if(o>n.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${n.maxResourceNameCodeUnits}-byte safety limit.`);let r=e.ascii(o,t,i),s=r.length;for(;s>0&&r.charCodeAt(s-1)===0;)s-=1;return r.slice(0,s)},kp=(e,t,n,i,o,r)=>{let s=Array.from({length:i},(l,c)=>e.u16(t,`${r} row ${c} length`)),a=o?new Uint8Array(xo(n,i,`${r} pixels`)):void 0;for(let l=0;l<i;l+=1){let c=st(e.offset,s[l],`${r} row ${l} end`);if(c>t)throw new Error(`${r} compressed row ${l} is truncated.`);let d=0;for(;e.offset<c;){let u=e.u8(c,`${r} PackBits header`);if(u<=127){let f=u+1,h=e.slice(f,c,`${r} PackBits literal`);if(d+f>n)throw new Error(`${r} row ${l} expands beyond its declared width.`);a&&a.set(h,l*n+d),d+=f}else if(u>=129){let f=257-u,h=e.u8(c,`${r} PackBits repeat value`);if(d+f>n)throw new Error(`${r} row ${l} expands beyond its declared width.`);a?.fill(h,l*n+d,l*n+d+f),d+=f}}if(d!==n)throw new Error(`${r} row ${l} expands to ${d} instead of ${n} pixels.`)}if(e.offset!==t)throw new Error(`${r} has trailing compressed bytes.`);return a},Ip=(e,t,n,i,o,r,s)=>{let a=xo(n,i,`${s} pixels`);if(o===0){if(e.offset+a!==t)throw new Error(`${s} raw byte length does not match its dimensions.`);return r?Uint8Array.from(e.slice(a,t,s)):(e.skip(a,t,s),void 0)}if(o===1)return kp(e,t,n,i,r,s);throw new Error(`${s} uses unsupported compression mode ${o}.`)},cd=(e,t,n,i,o,r,s,a)=>{for(let l=0;l<i.height;l+=1)for(let c=0;c<i.width;c+=1){let d=l*i.width+c,u=((i.top-t.top+l)*t.width+i.left-t.left+c)*4,f=n[d];r===1&&o===0?(e[u]=f,e[u+1]=f,e[u+2]=f):r===2&&o===0&&s?(e[u]=s[f*3],e[u+1]=s[f*3+1],e[u+2]=s[f*3+2],a&&(a[(i.top-t.top+l)*t.width+i.left-t.left+c]=f)):e[u+o]=f}},pd=(e,t,n,i,o,r)=>{if(e.u32(t,`PAT pattern ${r} version`)!==1)throw new Error(`PAT pattern ${r} uses an unsupported record version.`);let s=e.u32(t,`PAT pattern ${r} color mode`);if(s!==1&&s!==2&&s!==3)throw new Error(`PAT pattern ${r} uses unsupported color mode ${s}; only 8-bit grayscale, indexed, and RGB tiles are decoded.`);let a=e.i16(t,`PAT pattern ${r} vertical value`),l=e.i16(t,`PAT pattern ${r} horizontal value`),c=ld(e,t,n,`PAT pattern ${r} name`),d=Ap(e,t,n,`PAT pattern ${r} id`);if(!d)throw new Error(`PAT pattern ${r} has an empty unique id.`);let u,f=65535;if(s===2&&(u=Uint8Array.from(e.slice(768,t,`PAT pattern ${r} indexed palette`)),o?(e.u16(t,`PAT pattern ${r} indexed color count`),f=e.u16(t,`PAT pattern ${r} transparent palette index`)):e.skip(4,t,`PAT pattern ${r} indexed footer`)),e.u32(t,`PAT pattern ${r} VMAL version`)!==3)throw new Error(`PAT pattern ${r} uses an unsupported VMAL version.`);let h=e.u32(t,`PAT pattern ${r} VMAL length`),p=st(e.offset,h,`PAT pattern ${r} VMAL end`);if(p>t)throw new Error(`PAT pattern ${r} VMAL is truncated.`);let S=e.i32(p,`PAT pattern ${r} top`),m=e.i32(p,`PAT pattern ${r} left`),b=e.i32(p,`PAT pattern ${r} bottom`),v=e.i32(p,`PAT pattern ${r} right`),x=v-m,_=b-S,I=e.u32(p,`PAT pattern ${r} channel count`);if(x<=0||_<=0||x>n.maxCanvasDimension||_>n.maxCanvasDimension)throw new Error(`PAT pattern ${r} dimensions exceed the ${n.maxCanvasDimension}-pixel side safety limit.`);if(o&&(l!==x||a!==_))throw new Error(`PAT pattern ${r} header dimensions disagree with its decoded VMAL bounds.`);if(I>64)throw new Error(`PAT pattern ${r} channel count exceeds the 64-channel safety limit.`);let P=xo(x,_,`PAT pattern ${r} pixels`);hd(i,P,xo(P,4,`PAT pattern ${r} RGBA bytes`),n,`PAT pattern ${r}`);let k=new Uint8Array(P*4);for(let T=3;T<k.length;T+=4)k[T]=255;let E=s===2?new Uint8Array(P):void 0,O=s===3?3:1,U=new Set,M=!1,le={top:S,left:m,width:x,height:_};for(let T=0;T<I+2;T+=1){let W=e.u32(p,`PAT pattern ${r} channel ${T} presence`);if(!W)continue;if(W!==1)throw new Error(`PAT pattern ${r} channel ${T} has an invalid presence marker.`);let te=e.u32(p,`PAT pattern ${r} channel ${T} length`);if(te<23)throw new Error(`PAT pattern ${r} channel ${T} is shorter than its header.`);let ne=st(e.offset,te,`PAT pattern ${r} channel ${T} end`);if(ne>p)throw new Error(`PAT pattern ${r} channel ${T} is truncated.`);let Pe=e.u32(ne,`PAT pattern ${r} channel ${T} depth`),Ee=e.i32(ne,`PAT pattern ${r} channel ${T} top`),j=e.i32(ne,`PAT pattern ${r} channel ${T} left`),R=e.i32(ne,`PAT pattern ${r} channel ${T} bottom`),V=e.i32(ne,`PAT pattern ${r} channel ${T} right`),fe=e.u16(ne,`PAT pattern ${r} channel ${T} depth copy`),ie=e.u8(ne,`PAT pattern ${r} channel ${T} compression`);if(Pe!==8||fe!==8)throw new Error(`PAT pattern ${r} channel ${T} is not 8-bit.`);if(Ee<S||j<m||R>b||V>v||R<=Ee||V<=j)throw new Error(`PAT pattern ${r} channel ${T} bounds are outside the tile.`);let he=V-j,we=R-Ee,$e=T<O,at=T===I+1,yi=Ip(e,ne,he,we,ie,$e||at,`PAT pattern ${r} channel ${T}`);yi&&$e?(U.add(T),cd(k,le,yi,{top:Ee,left:j,width:he,height:we},T,s,u,E)):yi&&at&&(M=!0,cd(k,le,yi,{top:Ee,left:j,width:he,height:we},3,s))}if(e.offset!==p)throw new Error(`PAT pattern ${r} VMAL has trailing or unparsed bytes.`);if(U.size!==O)throw new Error(`PAT pattern ${r} is missing one or more required color planes.`);if(s===2&&!M&&f<256&&E)for(let T=0;T<E.length;T+=1)E[T]===f&&(k[T*4+3]=0);let me=!1;for(let T=0;T<P;T+=1)if(k[T*4+3]!==255){me=!0;break}return{name:c||`Pattern ${r}`,id:d,width:x,height:_,colorMode:s===1?"grayscale":s===2?"indexed":"rgb",rgba:k,hasTransparency:me}},Dp=(e,t,n,i)=>{let o=[];for(;e.offset<t;){if(o.length>=n.maxResourceItems)throw new Error(`Embedded pattern count exceeds the ${n.maxResourceItems}-item safety limit.`);let r=e.u32(t,"Embedded PAT record length"),s=st(e.offset,r,"Embedded PAT record end"),a=st(e.offset,ud(r),"Embedded PAT padded end");if(!r||s>t||a>t)throw new Error("Embedded PAT record is truncated.");if(o.push(pd(e,s,n,i,!1,o.length+1)),e.offset!==s)throw new Error(`Embedded PAT pattern ${o.length} length does not match its decoded payload.`);for(let l of e.slice(a-s,a,"Embedded PAT padding"))if(l!==0)throw new Error(`Embedded PAT pattern ${o.length} has non-zero alignment bytes.`)}if(e.offset!==t)throw new Error("Embedded PAT block length is invalid.");return o},Cp=(e,t)=>{ns(e,t,"PAT");let n=new Mn(e);if(n.ascii(4,n.length,"PAT signature")!=="8BPT")throw new Error("Invalid Photoshop PAT signature.");if(n.u16(n.length,"PAT version")!==1)throw new Error("Unsupported Photoshop PAT version; expected version 1.");let i=n.u32(n.length,"PAT pattern count");if(!i||i>t.maxResourceItems)throw new Error(`PAT pattern count must be between 1 and ${t.maxResourceItems}.`);let o={previewPixels:0,decodedBytes:0},r=Array.from({length:i},(s,a)=>pd(n,n.length,t,o,!0,a+1));return os(n,t,pi(t),r.length),{format:"pat",version:"1",engine:"file-viewer-native",fidelity:"decoded-pattern-tile",patterns:r,limitations:["The renderer decodes Photoshop PAT v1 grayscale, indexed, and RGB tiles with 8-bit raw or PackBits planes; CMYK, Lab, multichannel, 16-bit, and 32-bit pattern records are rejected.","Tile pixels and transparency are preserved. Photoshop pattern transforms, fills, layer blending, and color-management behavior are outside a standalone PAT library."]}},Be=(e,t,n,i)=>{if(!Number.isFinite(e)||e<t||e>n)throw new Error(`${i} is outside ${t}\u2026${n}.`);return e},Te=e=>Math.max(0,Math.min(255,Math.round(e))),Pp=(e,t,n)=>{let i=(e%360+360)%360/60,o=Math.max(0,Math.min(1,t/100)),r=Math.max(0,Math.min(1,n/100)),s=r*o,a=s*(1-Math.abs(i%2-1)),l=r-s;return(i<1?[s,a,0]:i<2?[a,s,0]:i<3?[0,s,a]:i<4?[0,a,s]:i<5?[a,0,s]:[s,0,a]).map(d=>Te((d+l)*255))},Ep=(e,t,n)=>{let i=.20689655172413793,o=h=>h>i?h**3:3*i*i*(h-4/29),r=(e+16)/116,s=.96422*o(r+t/500),a=o(r),l=.82521*o(r-n/200),c=.9555766*s-.0230393*a+.0631636*l,d=-.0282895*s+1.0099416*a+.0210077*l,u=.0122982*s-.020483*a+1.3299098*l;return[3.2404542*c-1.5371385*d-.4985314*u,-.969266*c+1.8760108*d+.041556*u,.0556434*c-.2040259*d+1.0572252*u].map(h=>Te((h<=.0031308?12.92*h:1.055*Math.max(0,h)**(1/2.4)-.055)*255))},Fp=e=>{if(!e)return{rgb:[0,0,0],colorSpace:"unknown"};if(e.classId==="RGBC")return{rgb:[Te(ye(e,"Rd ")),Te(ye(e,"Grn ")),Te(ye(e,"Bl "))],colorSpace:"rgb"};if(e.classId==="Grsc"){let t=Te(Be(ye(e,"Gry "),0,100,"GRD gray")*2.55);return{rgb:[t,t,t],colorSpace:"gray"}}if(e.classId==="HSBC"||e.classId==="HSBl")return{rgb:Pp(ye(e,"H "),ye(e,"Strt"),ye(e,"Brgh")),colorSpace:"hsb"};if(e.classId==="LbCl")return{rgb:Ep(ye(e,"Lmnc"),ye(e,"A "),ye(e,"B ")),colorSpace:"lab"};if(e.classId==="CMYC"){let t=Be(ye(e,"Cyn "),0,100,"GRD cyan")/100,n=Be(ye(e,"Mgnt"),0,100,"GRD magenta")/100,i=Be(ye(e,"Ylw "),0,100,"GRD yellow")/100,o=Be(ye(e,"Blck"),0,100,"GRD black")/100;return{rgb:[Te((1-t)*(1-o)*255),Te((1-n)*(1-o)*255),Te((1-i)*(1-o)*255)],colorSpace:"cmyk"}}return{rgb:[0,0,0],colorSpace:"unknown"}},ts=(e,t,n)=>{if(!e||e.type!=="list")throw new Error(`${t} list is missing.`);if(e.value.length>n)throw new Error(`${t} exceeds the ${n}-item safety limit.`);return e.value.map((i,o)=>{if(i.type!=="object")throw new Error(`${t} item ${o+1} is not an object.`);return i.value})},Op=(e,t)=>e<=t?t<=0?.5:.5*e/t:t>=1?.5:.5+.5*(e-t)/(1-t),dd=(e,t,n)=>{if(t<=e[0].location)return e[0].value;if(t>=e.at(-1).location)return e.at(-1).value;let i=e.findIndex(l=>l.location>=t),o=e[i-1],r=e[i],s=Math.max(1e-9,r.location-o.location),a=Op((t-o.location)/s,Math.max(.001,Math.min(.999,o.midpoint)));return Array.from({length:n},(l,c)=>o.value[c]+(r.value[c]-o.value[c])*a)},Lp=(e,t)=>{let n=new Uint8Array(1024),i=e.map(r=>({location:r.location,midpoint:r.midpoint,value:r.rgb})),o=t.map(r=>({location:r.location,midpoint:r.midpoint,value:[r.opacity]}));for(let r=0;r<256;r+=1){let s=r/255,a=dd(i,s,3),l=dd(o,s,1)[0];n.set([Te(a[0]),Te(a[1]),Te(a[2]),Te(l*255)],r*4)}return n},fd=(e,t,n)=>{let i=Le(e,t),o=i?.type==="list"?i.value:[];return[0,1,2,3].map(r=>{let s=o[r];return s?.type==="integer"?Be(s.value,0,100,`GRD ${t} range`):n})},Bp=(e,t,n,i)=>{let o=new Uint8Array(1024),r=e>>>0||2654435769,s=()=>(r^=r<<13,r^=r>>>17,r^=r<<5,(r>>>0)/4294967295);for(let a=0;a<256;a+=1){for(let l=0;l<3;l+=1)o[a*4+l]=Te((t[l]+s()*(n[l]-t[l]))*2.55);o[a*4+3]=i?Te((t[3]+s()*(n[3]-t[3]))*2.55):255}return o},is=e=>{if(!e.startsWith("$$$/"))return e;let t=e.lastIndexOf("=");if(t>=0&&t+1<e.length)return e.slice(t+1);let n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e},Up=(e,t,n,i)=>{hd(i,256,1024,n,`GRD gradient ${t}`);let o=mi(e,"Grad")||e,r=is(un(o,"Nm ")||`Gradient ${t}`),s=gi(o,"GrdF")||"CstS";if(s==="ClNs"){let u=fd(o,"Mnm ",0),f=fd(o,"Mxm ",100);f.forEach((v,x)=>{if(v<u[x])throw new Error(`${r}: noise maximum is below its minimum.`)});let h=Be(ye(o,"RndS",0),0,4294967295,`${r} random seed`),p=Be(ye(o,"Smth",2048),0,4096,`${r} roughness`),S=gi(o,"ClrS")||"RGBC",m=S==="HSBl"||S==="HSBC"?"hsb":S==="LbCl"||S==="LABC"?"lab":"rgb",b=bi(o,"ShTr",!1);return{name:r,definition:{form:"noise",seed:h,roughness:p,colorModel:m,restrictColors:bi(o,"VctC",!0),addTransparency:b,minimum:u,maximum:f},previewRgba:Bp(h,u,f,b)}}if(s!=="CstS")throw new Error(`${r}: unsupported GRD gradient form ${JSON.stringify(s)}.`);let l=ts(Le(o,"Clrs"),`${r} color stops`,Math.min(256,n.maxResourceItems)).map((u,f)=>{let h=Be(ye(u,"Lctn")/4096,0,1,`${r} color stop ${f+1} location`),p=Be(ye(u,"Mdpn",50)/100,0,1,`${r} color stop ${f+1} midpoint`),S=gi(u,"Type")||"UsrS",m=S==="FrgC"?"foreground":S==="BckC"?"background":"user",b=m==="foreground"?{rgb:[0,0,0],colorSpace:"unknown"}:m==="background"?{rgb:[255,255,255],colorSpace:"unknown"}:Fp(mi(u,"Clr "));if(m==="user"&&b.colorSpace==="unknown")throw new Error(`${r} color stop ${f+1} uses an unsupported color object.`);return{location:h,midpoint:p,kind:m,...b}}).sort((u,f)=>u.location-f.location);if(l.length<2)throw new Error(`${r} has fewer than two usable color stops.`);let c=Le(o,"Trns"),d=c?ts(c,`${r} transparency stops`,Math.min(256,n.maxResourceItems)).map((u,f)=>({location:Be(ye(u,"Lctn")/4096,0,1,`${r} alpha stop ${f+1} location`),midpoint:Be(ye(u,"Mdpn",50)/100,0,1,`${r} alpha stop ${f+1} midpoint`),opacity:Be(ye(u,"Opct",100)/100,0,1,`${r} alpha stop ${f+1} opacity`)})).sort((u,f)=>u.location-f.location):[{location:0,midpoint:.5,opacity:1},{location:1,midpoint:.5,opacity:1}];if(!d.length)throw new Error(`${r} declares an empty transparency-stop list.`);return{name:r,definition:{form:"solid",smoothness:Be(ye(o,"Intr",4096),0,4096,`${r} smoothness`),colorStops:l,alphaStops:d},previewRgba:Lp(l,d)}},Rp=(e,t)=>{let n=Le(e,"hierarchy");if(!n||n.type!=="list")return Array.from({length:t},()=>"");let i=Array.from({length:t},()=>""),o=[],r=0;for(let s of n.value)s.type==="object"&&(s.value.classId==="Grup"?o.push(is(un(s.value,"Nm ")||"")):s.value.classId==="groupEnd"?o.pop():s.value.classId==="preset"&&r<i.length&&(i[r++]=o.filter(Boolean).join(" / ")));return i},os=(e,t,n,i)=>{if(!e.remaining)return Array.from({length:i},()=>"");if(e.remaining<12||e.ascii(4,e.length,"Adobe hierarchy signature")!=="8BIM"||e.ascii(4,e.length,"Adobe hierarchy key")!=="phry")throw new Error("Adobe preset file has unrecognized trailing data.");let o=e.u32(e.length,"Adobe hierarchy length"),r=st(e.offset,o,"Adobe hierarchy end");if(r>e.length)throw new Error("Adobe hierarchy data is truncated.");if(e.u32(r,"Adobe hierarchy descriptor version")!==16)throw new Error("Unsupported Adobe hierarchy descriptor version.");let s=fn(e,r,t,n);if(e.offset!==r)throw new Error("Adobe hierarchy descriptor has trailing bytes.");if(e.remaining)throw new Error("Adobe preset file has bytes after its hierarchy data.");return Rp(s,i)},Mp=(e,t)=>{ns(e,t,"GRD");let n=new Mn(e);if(n.ascii(4,n.length,"GRD signature")!=="8BGR")throw new Error("Invalid Photoshop GRD signature.");if(n.u16(n.length,"GRD version")!==5)throw new Error("Unsupported Photoshop GRD version; only descriptor-based version 5 is decoded.");if(n.u32(n.length,"GRD descriptor version")!==16)throw new Error("Unsupported GRD Action Descriptor version.");let i=pi(t),o=fn(n,n.length,t,i),r={previewPixels:0,decodedBytes:0},s=ts(Le(o,"GrdL"),"GRD gradients",t.maxResourceItems).map((l,c)=>Up(l,c+1,t,r));if(!s.length)throw new Error("GRD file contains no gradients.");let a=os(n,t,i,s.length);return s.forEach((l,c)=>{a[c]&&(l.folder=a[c])}),{format:"grd",version:"5",engine:"file-viewer-native",fidelity:"solid-stop-preview-noise-approximation",gradients:s,limitations:["Solid-gradient stops, midpoint positions, transparency, names, and folders are preserved. Foreground/background stops use black/white because their final colors depend on Photoshop application state.","Noise-gradient metadata is preserved, but the thumbnail is a deterministic approximation; Photoshop does not publish its exact noise synthesis and color-management pipeline."]}},Tp=[{single:"DrSh",multi:"dropShadowMulti",kind:"drop-shadow"},{single:"IrSh",multi:"innerShadowMulti",kind:"inner-shadow"},{single:"OrGl",multi:"outerGlowMulti",kind:"outer-glow"},{single:"IrGl",multi:"innerGlowMulti",kind:"inner-glow"},{single:"ChFX",multi:"chromeFXMulti",kind:"satin"},{single:"ebbl",multi:"bevelEmbossMulti",kind:"bevel-emboss"},{single:"SoFi",multi:"solidFillMulti",kind:"color-overlay"},{single:"GrFl",multi:"gradientFillMulti",kind:"gradient-overlay"},{single:"patternFill",multi:"patternFillMulti",kind:"pattern-overlay"},{single:"FrFX",multi:"frameFXMulti",kind:"stroke"}],jp=e=>{if(!e)return[];let t=[];for(let n of Tp){let i=Le(e,n.single),o=Le(e,n.multi),r=[];if(i?.type==="object"&&r.push(i.value),o?.type==="list")for(let s of o.value)s.type==="object"&&r.push(s.value);r.length&&t.push({kind:n.kind,enabled:r.some(s=>bi(s,"enab",!0)),instances:r.length})}return t},vo=(e,t)=>{if(e.type==="object"){t(e.value);for(let n of e.value.entries.values())vo(n,t)}else if(e.type==="list")e.value.forEach(n=>vo(n,t));else if(e.type==="object-array"){t(e.value);for(let n of e.value.entries.values())vo(n,t)}},zp=e=>{let t=new Map;if(!e)return[];let n=i=>{if(i.classId!=="Ptrn"&&!i.entries.has("Idnt"))return;let o=un(i,"Idnt")||"",r=un(i,"Nm ")||"";o&&t.set(o,{name:r,id:o})};n(e);for(let i of e.entries.values())vo(i,n);return[...t.values()]},$p=(e,t,n,i,o)=>{if(e.u32(t,`ASL style ${o} identity descriptor version`)!==16)throw new Error(`ASL style ${o} uses an unsupported identity descriptor version.`);let r=fn(e,t,n,i),s=is(un(r,"Nm ")||""),a=un(r,"Idnt")||"";if(!s||!a)throw new Error(`ASL style ${o} is missing its name or unique id.`);if(e.u32(t,`ASL style ${o} effect descriptor version`)!==16)throw new Error(`ASL style ${o} uses an unsupported effect descriptor version.`);let l=fn(e,t,n,i),c=mi(l,"Lefx"),d=mi(l,"blendOptions"),u=Le(d,"Blnd"),f={name:s,id:a,effectsVisible:bi(c,"masterFXSwitch",!0),effects:jp(c),blendIfChannels:u?.type==="list"?u.value.length:0,referencedPatterns:zp(c)},h=gi(d,"Md ");h&&(f.blendMode=h);let p=Le(d,"Opct");(p?.type==="unit-double"||p?.type==="double"||p?.type==="integer")&&(f.opacity=Be(p.value,0,100,`${s} opacity`));let S=Le(d,"fillOpacity");if((S?.type==="unit-double"||S?.type==="double"||S?.type==="integer")&&(f.fillOpacity=Be(S.value,0,100,`${s} fill opacity`)),!f.effects.length&&!d)throw new Error(`${s} contains no supported effect graph or blending options.`);return f},Np=(e,t)=>{ns(e,t,"ASL");let n=new Mn(e);if(n.u16(n.length,"ASL version")!==2)throw new Error("Unsupported Photoshop ASL version; expected version 2.");if(n.ascii(4,n.length,"ASL signature")!=="8BSL")throw new Error("Invalid Photoshop ASL signature.");if(n.u16(n.length,"ASL pattern section version")!==3)throw new Error("Unsupported ASL embedded-pattern section version.");let i=n.u32(n.length,"ASL embedded-pattern section length"),o=st(n.offset,i,"ASL embedded-pattern section end");if(o>n.length)throw new Error("ASL embedded-pattern section is truncated.");let s=i?Dp(n,o,t,{previewPixels:0,decodedBytes:0}):[],a=n.u32(n.length,"ASL style count");if(!a||a>t.maxResourceItems)throw new Error(`ASL style count must be between 1 and ${t.maxResourceItems}.`);let l=pi(t),c=[];for(let d=0;d<a;d+=1){let u=n.u32(n.length,`ASL style ${d+1} length`),f=st(n.offset,u,`ASL style ${d+1} end`),h=st(n.offset,ud(u),`ASL style ${d+1} padded end`);if(!u||f>n.length||h>n.length)throw new Error(`ASL style ${d+1} record is truncated.`);c.push($p(n,f,t,l,d+1));for(let p of n.slice(f-n.offset,f,`ASL style ${d+1} padding`))if(p!==0)throw new Error(`ASL style ${d+1} has unparsed non-zero bytes.`);for(let p of n.slice(h-f,h,`ASL style ${d+1} alignment`))if(p!==0)throw new Error(`ASL style ${d+1} has non-zero alignment bytes.`)}return os(n,t,l,c.length),{format:"asl",version:"2",engine:"file-viewer-native",fidelity:"effect-graph-metadata-preview",styles:c,patterns:s,limitations:["Names, ids, effect graph presence, multi-effect counts, blending options, pattern references, and embedded pattern tiles are decoded. The preview does not claim Photoshop layer rasterization.","Exact layer-style appearance depends on Photoshop contours, blend modes, global light, color management, target-layer pixels, and undocumented renderer behavior; unsupported descriptor value types are rejected rather than ignored."]}},md=(e,t,n)=>{if(_p(n),t==="pat")return Cp(e,n);if(t==="grd")return Mp(e,n);if(t==="asl")return Np(e,n);throw new Error(`Unsupported Adobe preset format ${JSON.stringify(t)}.`)};var _o=self,gd=e=>e.format==="abr"?[...e.samples.map(t=>t.alpha.buffer),...e.patterns.map(t=>t.rgba.buffer)].filter(t=>t instanceof ArrayBuffer):e.format==="pat"?e.patterns.map(t=>t.rgba.buffer).filter(t=>t instanceof ArrayBuffer):e.format==="grd"?e.gradients.map(t=>t.previewRgba.buffer).filter(t=>t instanceof ArrayBuffer):e.format==="asl"?e.patterns.map(t=>t.rgba.buffer).filter(t=>t instanceof ArrayBuffer):[];_o.addEventListener("message",e=>{let t=e.data;try{if(!t||t.type!=="parse"&&t.type!=="parse-preset")throw new Error("Invalid Adobe resource Worker request.");if(t.type==="parse-preset"){let n=md(t.buffer,t.format,t.limits),i={id:t.id,ok:!0,result:n};_o.postMessage(i,gd(n))}else{let n=rd(t.buffer,t.format,t.limits),i={id:t.id,ok:!0,result:n};_o.postMessage(i,gd(n))}}catch(n){let i={id:t?.id??0,ok:!1,error:{name:n instanceof Error?n.name:"Error",message:n instanceof Error?n.message:String(n)}};_o.postMessage(i)}});
8
+ `),m(e);return t.slice(0,i)}});var Ff=ae(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.decodeEngineData=Bg;Si.decodeLegacyTextData=Rg;Si.encodeEngineData=Tg;var zn=Ot(),Cf={name:"MyriadPro-Regular",script:0,type:0,synthetic:0},vo={justification:"left",firstLineIndent:0,startIndent:0,endIndent:0,spaceBefore:0,spaceAfter:0,autoHyphenate:!0,hyphenatedWordSize:6,preHyphen:2,postHyphen:2,consecutiveHyphens:8,zone:36,wordSpacing:[.8,1,1.33],letterSpacing:[0,0,0],glyphSpacing:[1,1,1],autoLeading:1.2,leadingType:0,hanging:!1,burasagari:!1,kinsokuOrder:0,everyLineComposer:!1},Og={font:Cf,fontSize:12,fauxBold:!1,fauxItalic:!1,autoLeading:!0,leading:0,horizontalScale:1,verticalScale:1,tracking:0,autoKerning:!0,kerning:0,baselineShift:0,fontCaps:0,fontBaseline:0,underline:!1,strikethrough:!1,ligatures:!0,dLigatures:!1,baselineDirection:2,tsume:0,styleRunAlignment:2,language:0,noBreak:!1,fillColor:{r:0,g:0,b:0},strokeColor:{r:0,g:0,b:0},fillFlag:!0,strokeFlag:!1,fillFirst:!0,yUnderline:1,outlineWidth:1,characterDirection:0,hindiNumbers:!1,kashida:1,diacriticPos:2},fn={isOn:!1,show:!1,size:18,leading:22,color:{r:0,g:0,b:255},leadingFillColor:{r:0,g:0,b:255},alignLineHeightToGridFlags:!1},ys=["justification","firstLineIndent","startIndent","endIndent","spaceBefore","spaceAfter","autoHyphenate","hyphenatedWordSize","preHyphen","postHyphen","consecutiveHyphens","zone","wordSpacing","letterSpacing","glyphSpacing","autoLeading","leadingType","hanging","burasagari","kinsokuOrder","everyLineComposer"],xo=["font","fontSize","fauxBold","fauxItalic","autoLeading","leading","horizontalScale","verticalScale","tracking","autoKerning","kerning","baselineShift","fontCaps","fontBaseline","underline","strikethrough","ligatures","dLigatures","baselineDirection","tsume","styleRunAlignment","language","noBreak","fillColor","strokeColor","fillFlag","strokeFlag","fillFirst","yUnderline","outlineWidth","characterDirection","hindiNumbers","kashida","diacriticPos"],hs=["none","crisp","strong","smooth","sharp",void 0,"platformLCD","platform"],bs=["left","right","center","justify-left","justify-right","justify-center","justify-all"];function Pf(e){return e.substring(0,1).toUpperCase()+e.substring(1)}function Df(e){let n=e.Values;switch(e.Type){case 0:return{k:n[1]*255};case 1:return n[0]===1?{r:n[1]*255,g:n[2]*255,b:n[3]*255}:{r:n[1]*255,g:n[2]*255,b:n[3]*255,a:n[0]*255};case 2:return{c:n[1]*255,m:n[2]*255,y:n[3]*255,k:n[4]*255};default:throw new Error("Unknown color type in text layer")}}function Eg(e,n,t){e=(0,zn.clamp)(e||0,0,1),n=(0,zn.clamp)(n||0,0,1),t=(0,zn.clamp)(t||0,0,1);let i=e*6%6,o=Math.floor(i),r=i-o,s=t*(1-n),a=t*(1-n*r),l=t*(1-n*(1-r));switch(o){case 0:return[t,l,s];case 1:return[a,t,s];case 2:return[s,t,l];case 3:return[s,a,t];case 4:return[l,s,t];default:return[t,s,a]}}function gs(e){if(e){if("r"in e)return{Type:1,Values:["a"in e?e.a/255:1,e.r/255,e.g/255,e.b/255]};if("fr"in e)return{Type:1,Values:[1,(0,zn.clamp)(e.fr||0,0,1),(0,zn.clamp)(e.fg||0,0,1),(0,zn.clamp)(e.fb||0,0,1)]};if("h"in e){let[n,t,i]=Eg(e.h,e.s,e.b);return{Type:1,Values:[1,n,t,i]}}else{if("c"in e)return{Type:2,Values:[1,e.c/255,e.m/255,e.y/255,e.k/255]};if("l"in e)throw new Error("LAB colors are not supported in text layers, use RGB, CMYK or grayscale color instead");if("k"in e)return{Type:0,Values:[1,e.k/255]};throw new Error("Invalid color type in text layer")}}else return{Type:1,Values:[0,0,0,0]}}function xf(e,n){if(!e||!n||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function kf(e,n){if(!e||!n)return!1;for(let t of Object.keys(e))if(e[t]!==n[t])return!1;for(let t of Object.keys(n))if(e[t]!==n[t])return!1;return!0}function Fg(e,n){for(let t=0;t<e.length;t++)if(e[t].name===n.name&&(e[t].synthetic||0)===(n.synthetic||0))return t;return e.push(n),e.length-1}function Of(e,n,t){var i;let o={};for(let r of n){let s=Pf(r);if(e[s]!==void 0)if(r==="justification")o[r]=(i=bs[e[s]])!==null&&i!==void 0?i:"left";else if(r==="font"){let a=t[e[s]];a&&(o[r]=a)}else r==="fillColor"||r==="strokeColor"?o[r]=Df(e[s]):o[r]=e[s]}return o}function Ef(e,n,t){var i;let o={};for(let r of n){let s=Pf(r);e[r]!==void 0&&(r==="justification"?o[s]=Math.max(0,bs.indexOf((i=e[r])!==null&&i!==void 0?i:"left")):r==="font"?o[s]=Fg(t,e[r]):r==="fillColor"||r==="strokeColor"?o[s]=gs(e[r]):o[s]=e[r])}return o}function Lg(e,n){return Of(e,ys,n)}function Mg(e,n){return Of(e,xo,n)}function So(e,n){return Ef(e,ys,n)}function ps(e,n){return Ef(e,xo,n)}function ms(e,n,t){if(n.length){for(let i of t){let o=n[0].style[i];if(o!==void 0){let s=!1;Array.isArray(o)?s=n.every(a=>xf(a.style[i],o)):typeof o=="object"?s=n.every(a=>kf(a.style[i],o)):s=n.every(a=>a.style[i]===o),s&&(e[i]=o)}if(e[i]!==void 0)for(let s of n){let a=!1;Array.isArray(o)?a=xf(s.style[i],o):typeof o=="object"?a=kf(s.style[i],o):a=s.style[i]===o,a&&delete s.style[i]}}n.every(i=>Object.keys(i.style).length===0)&&(n.length=0)}}function _f(e){return!!e&&"r"in e&&e.r===0&&e.g===0&&e.b===255}function Af(e,n){try{return e?Df(e):n}catch{return n}}function Ug(e){var n,t;if(!e||typeof e!="object")return;let i={isOn:!!e.GridIsOn,show:!!e.ShowGrid,size:(n=e.GridSize)!==null&&n!==void 0?n:fn.size,leading:(t=e.GridLeading)!==null&&t!==void 0?t:fn.leading,color:Af(e.GridColor,fn.color),leadingFillColor:Af(e.GridLeadingFillColor,fn.leadingFillColor),alignLineHeightToGridFlags:!!e.AlignLineHeightToGridFlags};return!i.isOn&&!i.show&&i.size===fn.size&&i.leading===fn.leading&&!i.alignLineHeightToGridFlags&&_f(i.color)&&_f(i.leadingFillColor)?void 0:i}function Bg(e){var n,t,i,o,r,s,a,l,c,f;let u=e.EngineDict,d=e.ResourceDict,p=d.FontSet.map(O=>({name:O.Name,script:O.Script,type:O.FontType,synthetic:O.Synthetic})),h=u.Editor.Text.replace(/\r/g,`
9
+ `),m=0;/\n$/.test(h)&&(h=h.substring(0,h.length-1),m=1);let y={text:h,antiAlias:(n=hs[u.AntiAlias])!==null&&n!==void 0?n:"smooth",useFractionalGlyphWidths:!!u.UseFractionalGlyphWidths,superscriptSize:d.SuperscriptSize,superscriptPosition:d.SuperscriptPosition,subscriptSize:d.SubscriptSize,subscriptPosition:d.SubscriptPosition,smallCapSize:d.SmallCapSize},g=(s=(r=(o=(i=(t=u.Rendered)===null||t===void 0?void 0:t.Shapes)===null||i===void 0?void 0:i.Children)===null||o===void 0?void 0:o[0])===null||r===void 0?void 0:r.Cookie)===null||s===void 0?void 0:s.Photoshop;g&&(y.shapeType=g.ShapeType===1?"box":"point",g.PointBase&&(y.pointBase=g.PointBase),g.BoxBounds&&(y.boxBounds=g.BoxBounds));let k=Ug(u.GridInfo);k&&(y.gridInfo=k);let x=u.ParagraphRun;y.paragraphStyle={},y.paragraphStyleRuns=[];for(let O=0;O<x.RunArray.length;O++){let E=x.RunArray[O],L=x.RunLengthArray[O],M=Lg(E.ParagraphSheet.Properties,p);y.paragraphStyleRuns.push({length:L,style:M})}for(let O=m;y.paragraphStyleRuns.length&&O>0;O--)--y.paragraphStyleRuns[y.paragraphStyleRuns.length-1].length===0&&y.paragraphStyleRuns.length===1&&y.paragraphStyleRuns.pop();ms(y.paragraphStyle,y.paragraphStyleRuns,ys),y.paragraphStyleRuns.length||delete y.paragraphStyleRuns;let S=u.StyleRun,A=(c=(a=d.StyleSheetSet)===null||a===void 0?void 0:a[(l=d.TheNormalStyleSheet)!==null&&l!==void 0?l:0])===null||c===void 0?void 0:c.StyleSheetData,D=A?.Font,C=(f=D!==void 0?p[D]:void 0)!==null&&f!==void 0?f:p[0];y.style={},y.styleRuns=[];for(let O=0;O<S.RunArray.length;O++){let E=S.RunLengthArray[O],L=Mg(S.RunArray[O].StyleSheet.StyleSheetData,p);!L.font&&C&&(L.font=C),y.styleRuns.push({length:E,style:L})}for(let O=m;y.styleRuns.length&&O>0;O--)--y.styleRuns[y.styleRuns.length-1].length===0&&y.styleRuns.pop();return ms(y.style,y.styleRuns,xo),y.styleRuns.length||delete y.styleRuns,y}var vi=e=>e/65536;function Rg(e){var n,t,i,o;let r=[],s="";for(let c of e.lines)for(let{code:f,style:u}of c.chars){s+=String.fromCharCode(f);let d=r[r.length-1];d&&d.mark===u?d.length++:r.push({length:1,mark:u})}s.endsWith("\r")&&(s=s.slice(0,-1),--r[r.length-1].length===0&&r.pop());let a=r.map(({length:c,mark:f})=>{var u,d;let p=(u=e.styles.find(y=>y.mark===f))!==null&&u!==void 0?u:e.styles[0],h=p&&((d=e.faces.find(y=>y.mark===p.faceMark))!==null&&d!==void 0?d:e.faces[0]),m={};return h&&(m.font={name:h.name,script:h.script}),p&&(m.fontSize=vi(p.size),m.autoLeading=p.leading===0,p.leading&&(m.leading=vi(p.leading)),m.tracking=Math.round(vi(p.tracking)*1e3),m.autoKerning=p.autoKerning,m.kerning=Math.round(vi(p.kerning)*1e3),m.baselineShift=vi(p.baselineShift)),m.fillColor=e.color,{length:c,style:m}}),l={text:s.replace(/\r/g,`
10
+ `),transform:e.transform,antiAlias:e.antiAlias?"smooth":"none",orientation:((n=e.lines[0])===null||n===void 0?void 0:n.orientation)===1?"vertical":"horizontal",paragraphStyle:{justification:(o=bs[(i=(t=e.lines[0])===null||t===void 0?void 0:t.alignment)!==null&&i!==void 0?i:0])!==null&&o!==void 0?o:"left"},style:{},styleRuns:a};return ms(l.style,l.styleRuns,xo),l.styleRuns.length||delete l.styleRuns,l}function If(e,n){if(!e||!n.length)return e;let t=0,i=0;return e.map(o=>{let r=Math.max(0,o.length||0),s=t+r,a=0;for(;i<n.length&&n[i]<s;)n[i]>=t&&a++,i++;return t=s,Object.assign(Object.assign({},o),{length:r-a})})}function Tg(e){var n,t,i,o,r,s,a,l,c,f,u,d,p;let h=e.text||"",m=[];for(let W=0;W<h.length-1;W++)h.charCodeAt(W)===13&&h.charCodeAt(W+1)===10&&m.push(W);let y=`${h.replace(/\r?\n/g,"\r")}\r`,g=[{name:"AdobeInvisFont",script:0,type:0,synthetic:0}],k=((n=e.style)===null||n===void 0?void 0:n.font)||((i=(t=e.styleRuns)===null||t===void 0?void 0:t.find(W=>W.style.font))===null||i===void 0?void 0:i.style.font)||Cf,x=[],S=[],A=If(e.paragraphStyleRuns,m);if(A&&A.length){let W=y.length;for(let B of A){let $=Math.min(B.length,W);W-=$,W===1&&B===A[A.length-1]&&($++,W--),$&&(S.push($),x.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:So(Object.assign(Object.assign(Object.assign({},vo),e.paragraphStyle),B.style),g)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}))}W&&(S.push(W),x.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:So(Object.assign(Object.assign({},vo),e.paragraphStyle),g)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}))}else for(let W=0,B=0;W<y.length;W++)y.charCodeAt(W)===13&&(S.push(W-B+1),x.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:So(Object.assign(Object.assign({},vo),e.paragraphStyle),g)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}),B=W+1);let D=ps(Object.assign(Object.assign({},Og),{font:k}),g),C=!((o=e.styleRuns)===null||o===void 0)&&o.length?If(e.styleRuns,m):[{length:y.length,style:e.style||{}}],O=[],E=[],L=y.length;for(let W of C){let B=Math.min(W.length,L);L-=B,B&&(L===1&&W===C[C.length-1]&&(B++,L--),E.push(B),O.push({StyleSheet:{StyleSheetData:ps(Object.assign(Object.assign({kerning:0,autoKerning:!0,fillColor:{r:0,g:0,b:0}},e.style),W.style),g)}}))}L&&(E.push(L),O.push({StyleSheet:{StyleSheetData:ps(Object.assign({kerning:0,autoKerning:!0,fillColor:{r:0,g:0,b:0}},e.style),g)}}));let M=Object.assign(Object.assign({},fn),e.gridInfo),J=hs.indexOf((r=e.antiAlias)!==null&&r!==void 0?r:"sharp"),pe=e.orientation==="vertical"?2:0,R=e.orientation==="vertical"?1:0,ie=e.shapeType==="box"?1:0,he={ShapeType:ie};ie===0?he.PointBase=e.pointBase||[0,0]:he.BoxBounds=e.boxBounds||[0,0,0,0],he.Base={ShapeType:ie,TransformPoint0:[1,0],TransformPoint1:[0,1],TransformPoint2:[0,0]};let ce={KinsokuSet:[{Name:"PhotoshopKinsokuHard",NoStart:"\u3001\u3002\uFF0C\uFF0E\u30FB\uFF1A\uFF1B\uFF1F\uFF01\u30FC\u2015\u2019\u201D\uFF09\u3015\uFF3D\uFF5D\u3009\u300B\u300D\u300F\u3011\u30FD\u30FE\u309D\u309E\u3005\u3041\u3043\u3045\u3047\u3049\u3063\u3083\u3085\u3087\u308E\u30A1\u30A3\u30A5\u30A7\u30A9\u30C3\u30E3\u30E5\u30E7\u30EE\u30F5\u30F6\u309B\u309C?!)]},.:;\u2103\u2109\xA2\uFF05\u2030",NoEnd:"\u2018\u201C\uFF08\u3014\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010([{\uFFE5\uFF04\xA3\uFF20\xA7\u3012\uFF03",Keep:"\u2015\u2025",Hanging:"\u3001\u3002.,"},{Name:"PhotoshopKinsokuSoft",NoStart:"\u3001\u3002\uFF0C\uFF0E\u30FB\uFF1A\uFF1B\uFF1F\uFF01\u2019\u201D\uFF09\u3015\uFF3D\uFF5D\u3009\u300B\u300D\u300F\u3011\u30FD\u30FE\u309D\u309E\u3005",NoEnd:"\u2018\u201C\uFF08\u3014\uFF3B\uFF5B\u3008\u300A\u300C\u300E\u3010",Keep:"\u2015\u2025",Hanging:"\u3001\u3002.,"}],MojiKumiSet:[{InternalName:"Photoshop6MojiKumiSet1"},{InternalName:"Photoshop6MojiKumiSet2"},{InternalName:"Photoshop6MojiKumiSet3"},{InternalName:"Photoshop6MojiKumiSet4"}],TheNormalStyleSheet:0,TheNormalParagraphSheet:0,ParagraphSheetSet:[{Name:"Normal RGB",DefaultStyleSheet:0,Properties:So(Object.assign(Object.assign({},vo),e.paragraphStyle),g)}],StyleSheetSet:[{Name:"Normal RGB",StyleSheetData:D}],FontSet:g.map(W=>({Name:W.name,Script:W.script||0,FontType:W.type||0,Synthetic:W.synthetic||0})),SuperscriptSize:(s=e.superscriptSize)!==null&&s!==void 0?s:.583,SuperscriptPosition:(a=e.superscriptPosition)!==null&&a!==void 0?a:.333,SubscriptSize:(l=e.subscriptSize)!==null&&l!==void 0?l:.583,SubscriptPosition:(c=e.subscriptPosition)!==null&&c!==void 0?c:.333,SmallCapSize:(f=e.smallCapSize)!==null&&f!==void 0?f:.7};return{EngineDict:{Editor:{Text:y},ParagraphRun:{DefaultRunData:{ParagraphSheet:{DefaultStyleSheet:0,Properties:{}},Adjustments:{Axis:[1,0,1],XY:[0,0]}},RunArray:x,RunLengthArray:S,IsJoinable:1},StyleRun:{DefaultRunData:{StyleSheet:{StyleSheetData:{}}},RunArray:O,RunLengthArray:E,IsJoinable:2},GridInfo:{GridIsOn:!!M.isOn,ShowGrid:!!M.show,GridSize:(u=M.size)!==null&&u!==void 0?u:18,GridLeading:(d=M.leading)!==null&&d!==void 0?d:22,GridColor:gs(M.color),GridLeadingFillColor:gs(M.leadingFillColor),AlignLineHeightToGridFlags:!!M.alignLineHeightToGridFlags},AntiAlias:J===-1?hs.indexOf("sharp"):J,UseFractionalGlyphWidths:(p=e.useFractionalGlyphWidths)!==null&&p!==void 0?p:!0,Rendered:{Version:1,Shapes:{WritingDirection:pe,Children:[{ShapeType:ie,Procession:R,Lines:{WritingDirection:pe,Children:[]},Cookie:{Photoshop:he}}]}}},ResourceDict:Object.assign({},ce),DocumentResources:Object.assign({},ce)}}});var Bf=ae(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.decodeEngineData2=$g;var jg=us(),ws={0:{uproot:!0,children:{0:{name:"Type"},1:{name:"Values"}}}},xs={0:{name:"Font"},1:{name:"FontSize"},2:{name:"FauxBold"},3:{name:"FauxItalic"},4:{name:"AutoLeading"},5:{name:"Leading"},6:{name:"HorizontalScale"},7:{name:"VerticalScale"},8:{name:"Tracking"},9:{name:"BaselineShift"},11:{name:"Kerning?"},12:{name:"FontCaps"},13:{name:"FontBaseline"},15:{name:"Strikethrough?"},16:{name:"Underline?"},18:{name:"Ligatures"},19:{name:"DLigatures"},23:{name:"Fractions"},24:{name:"Ordinals"},28:{name:"StylisticAlternates"},30:{name:"OldStyle?"},35:{name:"BaselineDirection"},38:{name:"Language"},52:{name:"NoBreak"},53:{name:"FillColor",children:ws},54:{name:"StrokeColor",children:ws},55:{children:{99:{uproot:!0}}},79:{children:ws}},vs={0:{name:"Justification"},1:{name:"FirstLineIndent"},2:{name:"StartIndent"},3:{name:"EndIndent"},4:{name:"SpaceBefore"},5:{name:"SpaceAfter"},7:{name:"AutoLeading"},9:{name:"AutoHyphenate"},10:{name:"HyphenatedWordSize"},11:{name:"PreHyphen"},12:{name:"PostHyphen"},13:{name:"ConsecutiveHyphens?"},14:{name:"Zone"},15:{name:"HypenateCapitalizedWords"},17:{name:"WordSpacing"},18:{name:"LetterSpacing"},19:{name:"GlyphSpacing"},32:{name:"StyleSheet",children:xs}},Lf={name:"StyleSheetData",children:xs},zg={0:{name:"ResourceDict",children:{1:{name:"FontSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},2:{name:"FontType"}}}}}}}}},2:{name:"2",children:{}},3:{name:"MojiKumiSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"InternalName"}}}}}}},4:{name:"KinsokuSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},5:{uproot:!0,children:{0:{name:"NoStart"},1:{name:"NoEnd"},2:{name:"Keep"},3:{name:"Hanging"},4:{name:"Name"}}}}}}}}},5:{name:"StyleSheetSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},6:Lf}}}}}},6:{name:"ParagraphSheetSet",children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:"Name"},5:{name:"Properties",children:vs},6:{name:"DefaultStyleSheet"}}}}}}},8:{name:"TextFrameSet",children:{0:{uproot:!0,children:{0:{name:"path",children:{0:{name:"name"},1:{name:"bezierCurve",children:{0:{name:"controlPoints"}}},2:{name:"data",children:{0:{name:"type"},1:{name:"orientation"},2:{name:"frameMatrix"},4:{name:"4"},6:{name:"textRange"},7:{name:"rowGutter"},8:{name:"columnGutter"},9:{name:"9"},10:{name:"baselineAlignment",children:{0:{name:"flag"},1:{name:"min"}}},11:{name:"pathData",children:{1:{name:"1"},0:{name:"reversed"},2:{name:"2"},3:{name:"3"},4:{name:"spacing"},5:{name:"5"},6:{name:"6"},7:{name:"7"},18:{name:"18"}}},12:{name:"12"},13:{name:"13"}}},3:{name:"3"},97:{name:"uuid"}}}}}}},9:{name:"Predefined",children:{0:{children:{0:{uproot:!0}}},1:{children:{0:{uproot:!0}}}}}}},1:{name:"EngineDict",children:{0:{name:"0",children:{3:{name:"SuperscriptSize"},4:{name:"SuperscriptPosition"},5:{name:"SubscriptSize"},6:{name:"SubscriptPosition"},7:{name:"SmallCapSize"},8:{name:"UseFractionalGlyphWidths"},15:{children:{0:{uproot:!0}}}}},1:{name:"Editors?",children:{0:{name:"Editor",children:{0:{name:"Text"},5:{name:"ParagraphRun",children:{0:{name:"RunArray",children:{0:{name:"ParagraphSheet",children:{0:{uproot:!0,children:{0:{name:"0"},5:{name:"5",children:vs},6:{name:"6"}}}}},1:{name:"RunLength"}}}}},6:{name:"StyleRun",children:{0:{name:"RunArray",children:{0:{name:"StyleSheet",children:{0:{uproot:!0,children:{6:Lf}}}},1:{name:"RunLength"}}}}}}},1:{name:"FontVectorData ???"}}},2:{name:"StyleSheet",children:xs},3:{name:"ParagraphSheet",children:vs}}}},Mf=256;function Ss(e,n){return Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0}function ko(e,n,t){var i,o;if(t>Mf)throw new Error(`Engine data is nested too deeply (more than ${Mf} levels)`);if(e==null)return e;if(Array.isArray(e))return e.map(l=>ko(l,n,t+1));if(typeof e!="object")return e;let r=Object.keys(e),s=r.find(l=>{var c;return l!=="99"&&((c=Ss(n,l))===null||c===void 0?void 0:c.uproot)}),a;if(s!==void 0){if(a=ko(e[s],(i=Ss(n,s).children)!==null&&i!==void 0?i:{},t+1),a===null||typeof a!="object"||(e[99]&&(a._type=e[99]),Array.isArray(a)))return a}else a={};for(let l of r){if(l===s)continue;let c=Ss(n,l);if(l==="99")s===void 0&&(a._type=e[l]);else{let f=c?.name||l;(s===void 0||!(f in a))&&(0,jg.setProperty)(a,f,ko(e[l],(o=c?.children)!==null&&o!==void 0?o:{},t+1))}}return a}function Uf(){return{FontSet:[],StyleSheetSet:[],ParagraphSheetSet:[]}}function $g(e){let n=ko(e,zg,0);return!n||typeof n!="object"||Array.isArray(n)?{ResourceDict:Uf(),EngineDict:{}}:((!n.ResourceDict||typeof n.ResourceDict!="object")&&(n.ResourceDict=Uf()),n)}});var ui=ae(Ae=>{"use strict";var Vg=Ae&&Ae.__rest||function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,i=Object.getOwnPropertySymbols(e);o<i.length;o++)n.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(t[i[o]]=e[i[o]]);return t};Object.defineProperty(Ae,"__esModule",{value:!0});Ae.booleanOperations=Ae.infoHandlersMap=Ae.infoHandlers=void 0;Ae.readBezierKnot=td;Ae.readVectorMask=nd;Ae.writeVectorMask=id;Ae.parseKeyDescriptorList=od;Ae.serializeKeyDescriptorList=rd;Ae.hasMultiEffects=Do;var Rf=no(),Tf=yf(),De=Ot(),b=st(),w=En(),v=ao(),Es=us(),Fs=Ff(),Ng=Bf(),Ze="abcdefghijklmnopqrstuvwxyz";Ae.infoHandlers=[];Ae.infoHandlersMap={};function U(e,n,t,i){let o={key:e,has:n,read:t,write:i};Ae.infoHandlers.push(o),Ae.infoHandlersMap[o.key]=o}function lt(e,n){Ae.infoHandlersMap[e]=Ae.infoHandlersMap[n]}function le(e){return n=>n[e]!==void 0}function Io(e){if((0,b.readUint32)(e))throw new Error(`Resource size above 4 GB limit at ${e.offset.toString(16)}`);return(0,b.readUint32)(e)}U("TySh",le("text"),(e,n,t)=>{var i;if((0,b.readInt16)(e)!==1)throw new Error("Invalid TySh version");let o=[];for(let a=0;a<6;a++)o.push((0,b.readFloat64)(e));if((0,b.readInt16)(e)!==50)throw new Error("Invalid TySh text version");let r=(0,v.readVersionAndDescriptor)(e);if((0,b.readInt16)(e)!==1)throw new Error("Invalid TySh warp version");let s=(0,v.readVersionAndDescriptor)(e);if(n.text={transform:o,left:(0,b.readFloat32)(e),top:(0,b.readFloat32)(e),right:(0,b.readFloat32)(e),bottom:(0,b.readFloat32)(e),text:r["Txt "].replace(/\r/g,`
11
+ `),index:r.TextIndex||0,gridding:v.textGridding.decode(r.textGridding),antiAlias:v.Annt.decode(r.AntA),orientation:v.Ornt.decode(r.Ornt),warp:{style:v.warpStyle.decode(s.warpStyle),value:s.warpValue||0,perspective:s.warpPerspective||0,perspectiveOther:s.warpPerspectiveOther||0,rotate:v.Ornt.decode(s.warpRotate)}},r.bounds&&(n.text.bounds=(0,v.descBoundsToBounds)(r.bounds)),r.boundingBox&&(n.text.boundingBox=(0,v.descBoundsToBounds)(r.boundingBox)),r.substitutesUsed!==void 0&&(n.text.substitutesUsed=r.substitutesUsed),r.TxtC&&(n.text.clickPoint=(0,v.horzVrtcToXY)(r.TxtC)),(r.TxPT!==void 0||r.TxPR!==void 0||r.TxMP!==void 0)&&(n.text.textOnPath={},r.TxPT!==void 0&&(n.text.textOnPath.type=r.TxPT.split(".")[1]),r.TxPR!==void 0&&(n.text.textOnPath.direction=r.TxPR.split(".")[1]),r.TxMP!==void 0&&(n.text.textOnPath.mirror=r.TxMP)),r.VAlign!==void 0&&(n.text.verticalAlignment=r.VAlign),r.EngineData){let a=(0,Es.parseEngineData)(r.EngineData,e),l=(0,Fs.decodeEngineData)(a);n.text=Object.assign(Object.assign(Object.assign({},n.text),l),{antiAlias:(i=n.text.antiAlias)!==null&&i!==void 0?i:l.antiAlias})}(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o,r,s,a,l;let c=n.text,f=c.warp||{},u=c.transform||[1,0,0,1,0,0],d=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({"Txt ":(c.text||"").replace(/\r?\n/g,"\r")},c.clickPoint?{TxtC:(0,v.xyToHorzVrtc)(c.clickPoint)}:{}),c.substitutesUsed!==void 0?{substitutesUsed:!!c.substitutesUsed}:{}),{textGridding:v.textGridding.encode(c.gridding),Ornt:v.Ornt.encode(c.orientation),AntA:v.Annt.encode(c.antiAlias)}),((t=c.textOnPath)===null||t===void 0?void 0:t.type)!==void 0?{TxPT:`TxPT.${c.textOnPath.type}`}:{}),((i=c.textOnPath)===null||i===void 0?void 0:i.direction)!==void 0?{TxPR:`TxPR.${c.textOnPath.direction}`}:{}),((o=c.textOnPath)===null||o===void 0?void 0:o.mirror)!==void 0?{TxMP:!!c.textOnPath.mirror}:{}),c.bounds?{bounds:(0,v.boundsToDescBounds)(c.bounds)}:{}),c.boundingBox?{boundingBox:(0,v.boundsToDescBounds)(c.boundingBox)}:{}),{TextIndex:c.index||0}),c.verticalAlignment!==void 0?{VAlign:c.verticalAlignment}:{}),{EngineData:(0,Es.serializeEngineData)((0,Fs.encodeEngineData)(c))});(0,w.writeInt16)(e,1);for(let p=0;p<6;p++)(0,w.writeFloat64)(e,u[p]);(0,w.writeInt16)(e,50),(0,v.writeVersionAndDescriptor)(e,"","TxLr",d,"text"),(0,w.writeInt16)(e,1),(0,v.writeVersionAndDescriptor)(e,"","warp",Po(f)),(0,w.writeFloat32)(e,(r=c.left)!==null&&r!==void 0?r:0),(0,w.writeFloat32)(e,(s=c.top)!==null&&s!==void 0?s:0),(0,w.writeFloat32)(e,(a=c.right)!==null&&a!==void 0?a:0),(0,w.writeFloat32)(e,(l=c.bottom)!==null&&l!==void 0?l:0)});U("tySh",()=>!1,(e,n,t)=>{if((0,b.readInt16)(e)!==1)throw new Error("Invalid tySh version");let i=[];for(let l=0;l<6;l++)i.push((0,b.readFloat64)(e));if((0,b.readInt16)(e)!==6)throw new Error("Invalid tySh font version");let o={transform:i,faces:[],styles:[],lines:[],color:{r:0,g:0,b:0},antiAlias:!1},r=(0,b.readInt16)(e);for(let l=0;l<r;l++){let c=(0,b.readInt16)(e);(0,b.readInt32)(e);let f=(0,b.readPascalString)(e,1),u=(0,b.readPascalString)(e,1),d=(0,b.readPascalString)(e,1),p=(0,b.readInt16)(e),h=(0,b.readInt32)(e);if(h<0||h*4>t())throw new Error("Invalid tySh design axes count");(0,b.skipBytes)(e,h*4),o.faces.push({mark:c,name:f,familyName:u,styleName:d,script:p})}let s=(0,b.readInt16)(e);for(let l=0;l<s;l++){let c=(0,b.readInt16)(e),f=(0,b.readInt16)(e),u=(0,b.readInt32)(e),d=(0,b.readInt32)(e),p=(0,b.readInt32)(e),h=(0,b.readInt32)(e),m=(0,b.readInt32)(e),y=!!(0,b.readUint8)(e);(0,b.readUint8)(e),o.styles.push({mark:c,faceMark:f,size:u,tracking:d,kerning:p,leading:h,baselineShift:m,autoKerning:y})}(0,b.readInt16)(e),(0,b.readInt32)(e),(0,b.readInt32)(e),(0,b.readInt32)(e),(0,b.readInt32)(e),(0,b.readInt32)(e),(0,b.readInt32)(e);let a=(0,b.readInt16)(e);for(let l=0;l<a;l++){let c=(0,b.readInt32)(e),f=(0,b.readInt16)(e),u=(0,b.readInt16)(e);if(c<0||c*4>t())throw new Error("Invalid tySh character count");let d=[];for(let p=0;p<c;p++){let h=(0,b.readUint16)(e),m=(0,b.readInt16)(e);d.push({code:h,style:m})}o.lines.push({orientation:f,alignment:u,chars:d})}o.color=(0,b.readColor)(e),o.antiAlias=!!(0,b.readUint8)(e),n.text||(n.text=(0,Fs.decodeLegacyTextData)(o)),(0,b.skipBytes)(e,t())},()=>{});U("SoCo",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&e.vectorFill.type==="color",(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.vectorFill=(0,v.parseVectorContent)(i),(0,b.skipBytes)(e,t())},(e,n)=>{let{descriptor:t}=(0,v.serializeVectorContent)(n.vectorFill);(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("GdFl",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&(e.vectorFill.type==="solid"||e.vectorFill.type==="noise"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.vectorFill=(0,v.parseVectorContent)(i),(0,b.skipBytes)(e,t())},(e,n)=>{let{descriptor:t}=(0,v.serializeVectorContent)(n.vectorFill);(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("PtFl",e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&e.vectorFill.type==="pattern",(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.vectorFill=(0,v.parseVectorContent)(i),(0,b.skipBytes)(e,t())},(e,n)=>{let{descriptor:t}=(0,v.serializeVectorContent)(n.vectorFill);(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("vscg",e=>e.vectorFill!==void 0&&e.vectorStroke!==void 0,(e,n,t)=>{(0,b.readSignature)(e);let i=(0,v.readVersionAndDescriptor)(e);n.vectorFill=(0,v.parseVectorContent)(i),(0,b.skipBytes)(e,t())},(e,n)=>{let{descriptor:t,key:i}=(0,v.serializeVectorContent)(n.vectorFill);(0,w.writeSignature)(e,i),(0,v.writeVersionAndDescriptor)(e,"","null",t)});function td(e,n,t){let i=(0,b.readFixedPointPath32)(e)*t,o=(0,b.readFixedPointPath32)(e)*n,r=(0,b.readFixedPointPath32)(e)*t,s=(0,b.readFixedPointPath32)(e)*n,a=(0,b.readFixedPointPath32)(e)*t,l=(0,b.readFixedPointPath32)(e)*n;return[o,i,s,r,l,a]}function Gg(e,n,t,i){(0,w.writeFixedPointPath32)(e,n[1]/i),(0,w.writeFixedPointPath32)(e,n[0]/t),(0,w.writeFixedPointPath32)(e,n[3]/i),(0,w.writeFixedPointPath32)(e,n[2]/t),(0,w.writeFixedPointPath32)(e,n[5]/i),(0,w.writeFixedPointPath32)(e,n[4]/t)}Ae.booleanOperations=["exclude","combine","subtract","intersect"];function nd(e,n,t,i,o){let r=e.offset+o,s=n.paths,a;for(;r-e.offset>=26;){let l=(0,b.readUint16)(e);switch(l){case 0:case 3:{(0,b.readUint16)(e);let c=(0,b.readInt16)(e),f=(0,b.readUint16)(e);(0,b.skipBytes)(e,18),a={open:l===3,knots:[],fillRule:f===2?"non-zero":"even-odd"},c!==-1&&(a.operation=Ae.booleanOperations[c]),s.push(a);break}case 1:case 2:case 4:case 5:if(!a)throw new Error("Bezier knot record without subpath length record");a.knots.push({linked:l===1||l===4,points:td(e,t,i)});break;case 6:(0,b.skipBytes)(e,24);break;case 7:{let c=(0,b.readFixedPointPath32)(e),f=(0,b.readFixedPointPath32)(e),u=(0,b.readFixedPointPath32)(e),d=(0,b.readFixedPointPath32)(e),p=(0,b.readFixedPointPath32)(e);(0,b.skipBytes)(e,4),n.clipboard={top:c,left:f,bottom:u,right:d,resolution:p};break}case 8:n.fillStartsWithAllPixels=!!(0,b.readUint16)(e),(0,b.skipBytes)(e,22);break;default:throw new Error("Invalid vmsk section")}}return s}function id(e,n,t,i,o=!1){(0,w.writeUint16)(e,6),(0,w.writeZeros)(e,24);let r=n.clipboard;r&&((0,w.writeUint16)(e,7),(0,w.writeFixedPointPath32)(e,r.top),(0,w.writeFixedPointPath32)(e,r.left),(0,w.writeFixedPointPath32)(e,r.bottom),(0,w.writeFixedPointPath32)(e,r.right),(0,w.writeFixedPointPath32)(e,r.resolution),(0,w.writeZeros)(e,4)),(0,w.writeUint16)(e,8),(0,w.writeUint16)(e,n.fillStartsWithAllPixels?1:0),(0,w.writeZeros)(e,22);let s=-1;for(let a of n.paths){(a.operation||s<0)&&s++,(0,w.writeUint16)(e,a.open?3:0),(0,w.writeUint16)(e,a.knots.length),(0,w.writeUint16)(e,a.operation?Ae.booleanOperations.indexOf(a.operation):-1),(0,w.writeUint16)(e,a.fillRule==="non-zero"?2:1),(0,w.writeZeros)(e,4),(0,w.writeUint32)(e,o?s:0),(0,w.writeZeros)(e,10);let l=a.open?4:1,c=a.open?5:2;for(let{linked:f,points:u}of a.knots)(0,w.writeUint16)(e,f?l:c),Gg(e,u,t,i)}}U("vmsk",le("vectorMask"),(e,n,t,{width:i,height:o})=>{if((0,b.readUint32)(e)!==3)throw new Error("Invalid vmsk version");n.vectorMask={paths:[]};let r=n.vectorMask,s=(0,b.readUint32)(e);r.invert=(s&1)!==0,r.notLink=(s&2)!==0,r.disable=(s&4)!==0,nd(e,r,i,o,t()),(0,b.skipBytes)(e,t())},(e,n,{width:t,height:i})=>{let o=n.vectorMask,r=(o.invert?1:0)|(o.notLink?2:0)|(o.disable?4:0);(0,w.writeUint32)(e,3),(0,w.writeUint32)(e,r),id(e,o,t,i,!0)});lt("vsms","vmsk");U("vowv",le("vowv"),(e,n)=>{n.vowv=(0,b.readUint32)(e)},(e,n)=>{(0,w.writeUint32)(e,n.vowv)});function _s(e){return[(0,v.horzVrtcToXY)(e.rectangleCornerA),(0,v.horzVrtcToXY)(e.rectangleCornerB),(0,v.horzVrtcToXY)(e.rectangleCornerC),(0,v.horzVrtcToXY)(e.rectangleCornerD)]}function As(e){return{rectangleCornerA:(0,v.xyToHorzVrtc)(e[0]),rectangleCornerB:(0,v.xyToHorzVrtc)(e[1]),rectangleCornerC:(0,v.xyToHorzVrtc)(e[2]),rectangleCornerD:(0,v.xyToHorzVrtc)(e[3])}}function od(e){let n=[];for(let t of e.keyDescriptorList){let i={};t.keyShapeInvalidated!=null&&(i.keyShapeInvalidated=t.keyShapeInvalidated),t.keyOriginType!=null&&(i.keyOriginType=t.keyOriginType),t.keyOriginResolution!=null&&(i.keyOriginResolution=t.keyOriginResolution),t.keyOriginShapeBBox&&(i.keyOriginShapeBoundingBox={top:(0,v.parseUnitsOrNumber)(t.keyOriginShapeBBox["Top "]),left:(0,v.parseUnitsOrNumber)(t.keyOriginShapeBBox.Left),bottom:(0,v.parseUnitsOrNumber)(t.keyOriginShapeBBox.Btom),right:(0,v.parseUnitsOrNumber)(t.keyOriginShapeBBox.Rght)});let o=t.keyOriginRRectRadii;o&&(i.keyOriginRRectRadii={topRight:(0,v.parseUnits)(o.topRight),topLeft:(0,v.parseUnits)(o.topLeft),bottomLeft:(0,v.parseUnits)(o.bottomLeft),bottomRight:(0,v.parseUnits)(o.bottomRight)}),t.keyOriginBoxCorners&&(i.keyOriginBoxCorners=_s(t.keyOriginBoxCorners)),t.keyOriginPolySides!=null&&(i.keyOriginPolySides=t.keyOriginPolySides),t.keyOriginPolyCornerRadius!=null&&(i.keyOriginPolyCornerRadius=t.keyOriginPolyCornerRadius),t.keyOriginPolyStarRatio&&(i.keyOriginPolyStarRatio=(0,v.parsePercent)(t.keyOriginPolyStarRatio)),t.keyOriginPolyPreviousTightBoxCorners&&(i.keyOriginPolyPreviousTightBoxCorners=_s(t.keyOriginPolyPreviousTightBoxCorners)),t.keyOriginPolyTrueRectCorners&&(i.keyOriginPolyTrueRectCorners=_s(t.keyOriginPolyTrueRectCorners)),t.keyOriginPolyPixelHSF!=null&&(i.keyOriginPolyPixelHSF=t.keyOriginPolyPixelHSF),t.keyOriginLineStart&&(i.keyOriginLineStart=(0,v.horzVrtcToXY)(t.keyOriginLineStart)),t.keyOriginLineEnd&&(i.keyOriginLineEnd=(0,v.horzVrtcToXY)(t.keyOriginLineEnd)),t.keyOriginLineWeight!=null&&(i.keyOriginLineWeight=t.keyOriginLineWeight),t.keyOriginLineArrowSt!=null&&(i.keyOriginLineArrowStart=t.keyOriginLineArrowSt),t.keyOriginLineArrowEnd!=null&&(i.keyOriginLineArrowEnd=t.keyOriginLineArrowEnd),t.keyOriginLineArrWdth!=null&&(i.keyOriginLineArrowWidth=t.keyOriginLineArrWdth),t.keyOriginLineArrLngth!=null&&(i.keyOriginLineArrowLength=t.keyOriginLineArrLngth),t.keyOriginLineArrConc!=null&&(i.keyOriginLineArrowConcavity=t.keyOriginLineArrConc);let r=t.Trnf;r&&(i.transform=[r.xx,r.xy,r.yx,r.yy,r.tx,r.ty]),n.push(i)}return n}function rd(e){let n={keyDescriptorList:[]};for(let t=0;t<e.length;t++){let i=e[t];n.keyDescriptorList.push({});let o=n.keyDescriptorList[n.keyDescriptorList.length-1];i.keyOriginType!=null&&(o.keyOriginType=i.keyOriginType),i.keyOriginResolution!=null&&(o.keyOriginResolution=i.keyOriginResolution);let r=i.keyOriginRRectRadii;r&&(o.keyOriginRRectRadii={unitValueQuadVersion:1,topRight:(0,v.unitsValue)(r.topRight,"topRight"),topLeft:(0,v.unitsValue)(r.topLeft,"topLeft"),bottomLeft:(0,v.unitsValue)(r.bottomLeft,"bottomLeft"),bottomRight:(0,v.unitsValue)(r.bottomRight,"bottomRight")});let s=i.keyOriginShapeBoundingBox;s&&(o.keyOriginShapeBBox={unitValueQuadVersion:1,"Top ":(0,v.unitsValue)(s.top,"top"),Left:(0,v.unitsValue)(s.left,"left"),Btom:(0,v.unitsValue)(s.bottom,"bottom"),Rght:(0,v.unitsValue)(s.right,"right")});let a=i.keyOriginBoxCorners;a&&a.length===4&&(o.keyOriginBoxCorners=As(a)),i.keyOriginPolySides!=null&&(o.keyOriginPolySides=i.keyOriginPolySides),i.keyOriginPolyCornerRadius!=null&&(o.keyOriginPolyCornerRadius=i.keyOriginPolyCornerRadius),i.keyOriginPolyStarRatio!=null&&(o.keyOriginPolyStarRatio=(0,v.unitsPercentF)(i.keyOriginPolyStarRatio));let l=i.keyOriginPolyPreviousTightBoxCorners;l&&l.length===4&&(o.keyOriginPolyPreviousTightBoxCorners=As(l));let c=i.keyOriginPolyTrueRectCorners;c&&c.length===4&&(o.keyOriginPolyTrueRectCorners=As(c)),i.keyOriginPolyPixelHSF!=null&&(o.keyOriginPolyPixelHSF=i.keyOriginPolyPixelHSF),i.keyOriginLineEnd&&(o.keyOriginLineEnd=(0,v.xyToHorzVrtc)(i.keyOriginLineEnd)),i.keyOriginLineStart&&(o.keyOriginLineStart=(0,v.xyToHorzVrtc)(i.keyOriginLineStart)),i.keyOriginLineWeight!=null&&(o.keyOriginLineWeight=i.keyOriginLineWeight),i.keyOriginLineArrowStart!=null&&(o.keyOriginLineArrowSt=!!i.keyOriginLineArrowStart),i.keyOriginLineArrowEnd!=null&&(o.keyOriginLineArrowEnd=!!i.keyOriginLineArrowEnd),i.keyOriginLineArrowWidth!=null&&(o.keyOriginLineArrWdth=i.keyOriginLineArrowWidth),i.keyOriginLineArrowLength!=null&&(o.keyOriginLineArrLngth=i.keyOriginLineArrowLength),i.keyOriginLineArrowConcavity!=null&&(o.keyOriginLineArrConc=i.keyOriginLineArrowConcavity);let f=i.transform;f&&f.length===6&&(o.Trnf={xx:f[0],xy:f[1],yx:f[2],yy:f[3],tx:f[4],ty:f[5]}),i.keyShapeInvalidated!=null&&(o.keyShapeInvalidated=i.keyShapeInvalidated),o.keyOriginIndex=t}return n}U("vogk",le("vectorOrigination"),(e,n,t)=>{if((0,b.readInt32)(e)!==1)throw new Error("Invalid vogk version");let i=(0,v.readVersionAndDescriptor)(e);n.vectorOrigination={keyDescriptorList:od(i)},(0,b.skipBytes)(e,t())},(e,n)=>{let t=rd(n.vectorOrigination.keyDescriptorList);(0,w.writeInt32)(e,1),(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("lmfx",e=>e.effects!==void 0&&!Ts(e)&&Do(e.effects),(e,n,t)=>{if((0,b.readUint32)(e)!==0)throw new Error("Invalid lmfx version");let o=(0,v.readVersionAndDescriptor)(e);n.effects=(0,v.parseEffects)(o,e),(0,b.skipBytes)(e,t())},(e,n)=>{let t=(0,v.serializeEffects)(n.effects,e,!0);(0,w.writeUint32)(e,0),(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("lrFX",le("effects"),(e,n,t)=>{n.effects||(n.effects=(0,Tf.readEffects)(e)),(0,b.skipBytes)(e,t())},(e,n)=>{(0,Tf.writeEffects)(e,n.effects)});U("luni",le("name"),(e,n,t)=>{if(t()>4){let i=(0,b.readUint32)(e);t()>=i*2?n.name=(0,b.readUnicodeStringWithLength)(e,i):e.logDevFeatures&&e.log("name in luni section is too long")}else e.logDevFeatures&&e.log("empty luni section");(0,b.skipBytes)(e,t())},(e,n)=>{(0,w.writeUnicodeString)(e,n.name)});U("lnsr",le("nameSource"),(e,n)=>n.nameSource=(0,b.readSignature)(e),(e,n)=>(0,w.writeSignature)(e,n.nameSource));function Hg(e){return!!(e.animationFrames||e.timeline||e.comps)}function jf(e,n){if(!n.explicitLayerIds){let t=new Set,i=o=>{for(let r of o??[])r.id!==void 0&&t.add(r.id),i(r.children)};i(e.children),n.explicitLayerIds=t}return n.explicitLayerIds}function Is(e,n){var t;let i=(t=n.layerToId.get(e))!==null&&t!==void 0?t:e.id;if(i===void 0)throw new Error("Missing layer id");return i}U("lyid",e=>e.id!==void 0||Hg(e),(e,n)=>{n.id=(0,b.readUint32)(e)},(e,n,t,i)=>{var o;let r;if(n.id!==void 0){if(r=n.id,i.layerIds.has(r)){let s=jf(t,i);for(;i.layerIds.has(r)||s.has(r);)r+=100}}else{let s=jf(t,i);for(r=(o=i.nextGeneratedLayerId)!==null&&o!==void 0?o:1;i.layerIds.has(r)||s.has(r);)r++;i.nextGeneratedLayerId=r+1}(0,w.writeUint32)(e,r),i.layerIds.add(r),i.layerToId.set(n,r)});U("lsct",le("sectionDivider"),(e,n,t)=>{n.sectionDivider={type:(0,b.readUint32)(e)},t()&&((0,b.checkSignature)(e,"8BIM"),n.sectionDivider.key=(0,b.readSignature)(e)),t()&&(n.sectionDivider.subType=(0,b.readUint32)(e))},(e,n)=>{(0,w.writeUint32)(e,n.sectionDivider.type),n.sectionDivider.key&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,n.sectionDivider.key),n.sectionDivider.subType!==void 0&&(0,w.writeUint32)(e,n.sectionDivider.subType))});lt("lsdk","lsct");U("clbl",le("blendClippendElements"),(e,n)=>{n.blendClippendElements=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.blendClippendElements?1:0),(0,w.writeZeros)(e,3)});U("infx",le("blendInteriorElements"),(e,n)=>{n.blendInteriorElements=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.blendInteriorElements?1:0),(0,w.writeZeros)(e,3)});U("knko",le("knockout"),(e,n)=>{n.knockout=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.knockout?1:0),(0,w.writeZeros)(e,3)});U("lmgm",le("layerMaskAsGlobalMask"),(e,n)=>{n.layerMaskAsGlobalMask=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.layerMaskAsGlobalMask?1:0),(0,w.writeZeros)(e,3)});U("vmgm",le("vectorMaskAsGlobalMask"),(e,n)=>{n.vectorMaskAsGlobalMask=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.vectorMaskAsGlobalMask?1:0),(0,w.writeZeros)(e,3)});U("ffxi",le("foreignEffectId"),(e,n)=>{n.foreignEffectId=(0,b.readInt32)(e)},(e,n)=>{(0,w.writeInt32)(e,n.foreignEffectId)});U("shpa",le("patternData"),(e,n,t)=>{if((0,b.readInt32)(e)!==0)throw new Error("Invalid shpa version");let i=(0,b.readInt32)(e);n.patternData=[];for(let o=0;o<i&&t()>0;o++){let r=(0,b.readSignature)(e),s=(0,b.readSignature)(e),a=(0,b.readInt32)(e),l=!!(0,b.readUint8)(e);(0,b.skipBytes)(e,3);let c=[];for(let f=0;f<a&&t()>0;f++){let u=v.patternColorHandling.decode("."+(0,b.readSignature)(e));(0,b.readPascalString)(e,1);let d=(0,b.readUnicodeString)(e),p=(0,b.readPascalString)(e,1);c.push({colorHandling:u,name:d,id:p})}n.patternData.push({signature:r,key:s,copyOnSheetDuplication:l,patterns:c})}(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.patternData;(0,w.writeInt32)(e,0),(0,w.writeInt32)(e,t.length);for(let i of t){(0,w.writeSignature)(e,i.signature),(0,w.writeSignature)(e,i.key),(0,w.writeInt32)(e,i.patterns.length),(0,w.writeUint8)(e,i.copyOnSheetDuplication?1:0),(0,w.writeZeros)(e,3);for(let o of i.patterns)(0,w.writeSignature)(e,v.patternColorHandling.encode(o.colorHandling).split(".")[1]),(0,w.writePascalString)(e,o.name.replace(/[^\x20-\x7e]/g,"?"),1),(0,w.writeUnicodeString)(e,o.name),(0,w.writePascalString)(e,o.id,1)}});U("lspf",le("protected"),(e,n)=>{let t=(0,b.readUint32)(e);n.protected={transparency:(t&1)!==0,composite:(t&2)!==0,position:(t&4)!==0},t&8&&(n.protected.artboards=!0),t&2147483648&&(n.protected.all=!0)},(e,n)=>{let t=(n.protected.transparency?1:0)|(n.protected.composite?2:0)|(n.protected.position?4:0)|(n.protected.artboards?8:0)|(n.protected.all?2147483648:0);(0,w.writeUint32)(e,t>>>0)});U("lclr",le("layerColor"),(e,n)=>{let t=(0,b.readUint16)(e);(0,b.skipBytes)(e,6),n.layerColor=De.layerColors[t]},(e,n)=>{let t=De.layerColors.indexOf(n.layerColor);(0,w.writeUint16)(e,t===-1?0:t),(0,w.writeZeros)(e,6)});function Us(e){let n={};return e.exportAs&&(n.exportAs={},e.exportAs.exportOption!==void 0&&(n.exportAs.exportOption=e.exportAs.exportOption),e.exportAs.scaleSettings!==void 0&&(n.exportAs.scaleSettings=e.exportAs.scaleSettings)),e.generator_45_assets&&(n.assets=e.generator_45_assets.json),e.layerTime!==void 0&&(n.layerTime=e.layerTime),e.crema&&(n.crema=e.crema.json),n}function sd(e){let n={_name:"",_classID:e.assets!==void 0?"generatorSettings":"null"};return e.exportAs&&(n.exportAs={_name:"",_classID:"null"},e.exportAs.exportOption!==void 0&&(n.exportAs.exportOption=e.exportAs.exportOption),e.exportAs.scaleSettings!==void 0&&(n.exportAs.scaleSettings=e.exportAs.scaleSettings)),e.assets!==void 0&&(n.generator_45_assets={_name:"",_classID:"generatorSettings",json:e.assets}),e.layerTime!==void 0&&(n.layerTime=e.layerTime),e.crema!==void 0&&(n.crema={_name:"",_classID:"null",json:e.crema}),{generatorSettings:n}}function Ls(e){return e.width!==void 0}var ad=(0,De.createEnum)("knockout","none",{none:"none",shallow:"shallow",deep:"deep"});function zf(e,n){e["Md "]!==void 0&&(n.blendMode=v.BlnM.decode(e["Md "])),e.Opct!==void 0&&(n.opacity=(0,v.parsePercent)(e.Opct)),e.fillOpacity!==void 0&&(n.fillOpacity=(0,v.parsePercent)(e.fillOpacity)),e.blendInterior!==void 0&&(n.blendInteriorElements=e.blendInterior),e.blendClipped!==void 0&&(n.blendClippedElements=e.blendClipped),e.knockout!==void 0&&(n.knockout=ad.decode(e.knockout))}function $f(e){let n={};return e.blendMode!==void 0&&(n["Md "]=v.BlnM.encode(e.blendMode)),e.opacity!==void 0&&(n.Opct=(0,v.unitsPercentF)(e.opacity)),e.fillOpacity!==void 0&&(n.fillOpacity=(0,v.unitsPercentF)(e.fillOpacity)),e.blendInteriorElements!==void 0&&(n.blendInterior=!!e.blendInteriorElements),e.blendClippedElements!==void 0&&(n.blendClipped=!!e.blendClippedElements),e.knockout!==void 0&&(n.knockout=ad.encode(e.knockout)),Object.keys(n).length?n:void 0}function Vf(e,n){let t=e.textLayerSettings;t&&(n.text={warp:{style:v.warpStyle.decode(t.warpStyle),value:t.warpValue||0,perspective:t.warpPerspective||0,perspectiveOther:t.warpPerspectiveOther||0,rotate:v.Ornt.decode(t.warpRotate)},warpRect:t.textLayerSettingsWarpRect||[0,0,0,0]}),e.placedLayerSettings&&(n.placedLayerCompId=e.placedLayerSettings.placedLayerCompID)}function Nf(e){let n={},t=e.text;return t&&(n.textLayerSettings={warpStyle:v.warpStyle.encode(t.warp.style),warpValue:t.warp.value||0,warpPerspective:t.warp.perspective||0,warpPerspectiveOther:t.warp.perspectiveOther||0,warpRotate:v.Ornt.encode(t.warp.rotate),textLayerSettingsWarpRect:t.warpRect||[0,0,0,0]}),e.placedLayerCompId!==void 0&&(n.placedLayerSettings={placedLayerCompID:e.placedLayerCompId}),Object.keys(n).length?n:void 0}U("shmd",e=>e.timestamp!==void 0||e.animationFrames!==void 0||e.animationFrameFlags!==void 0||e.timeline!==void 0||e.comps!==void 0||e.generatorSettings!==void 0&&!Ls(e),(e,n,t)=>{let i=(0,b.readUint32)(e);for(let o=0;o<i;o++){let r=(0,b.readSignature)(e);if(r!=="8BIM"&&r!=="8ELE")throw new Error(`Invalid shmd signature: '${r}'`);let s=(0,b.readSignature)(e);(0,b.readUint8)(e),(0,b.skipBytes)(e,3);let a=e.offset+4+e.view.getUint32(e.offset);try{(0,b.readSection)(e,1,l=>{var c,f,u;if(s==="cust"){let d=(0,v.readVersionAndDescriptor)(e);d.layerTime!==void 0&&(n.timestamp=d.layerTime)}else if(s==="mlst"){let d=(0,v.readVersionAndDescriptor)(e);n.animationFrames=[];for(let p=0;p<d.LaSt.length;p++){let h=d.LaSt[p],m={frames:h.FrLs};h.enab!==void 0&&(m.enable=h.enab),h.Ofst&&(m.offset=(0,v.horzVrtcToXY)(h.Ofst)),!((c=h.IMsk)===null||c===void 0)&&c.Ofst&&(m.maskOffset=(0,v.horzVrtcToXY)(h.IMsk.Ofst)),!((f=h.VMsk)===null||f===void 0)&&f.Ofst&&(m.vectorMaskOffset=(0,v.horzVrtcToXY)(h.VMsk.Ofst)),h.FXRf&&(m.referencePoint=(0,v.horzVrtcToXY)(h.FXRf)),h.Lefx&&(m.effects=(0,v.parseEffects)(h.Lefx,e)),h.blendOptions&&zf(h.blendOptions,m),h.LSpc&&Vf(h.LSpc,m),n.animationFrames.push(m)}}else if(s==="mdyn"){(0,b.readUint16)(e);let d=(0,b.readUint8)(e),p=(0,b.readUint8)(e);n.animationFrameFlags={propagateFrameOne:!d,unifyLayerPosition:(p&1)!==0,unifyLayerStyle:(p&2)!==0,unifyLayerVisibility:(p&4)!==0}}else if(s==="tmln"){let d=(0,v.readVersionAndDescriptor)(e),p=d.timeScope,h={start:(0,v.frac)(p.Strt),duration:(0,v.frac)(p.duration),inTime:(0,v.frac)(p.inTime),outTime:(0,v.frac)(p.outTime),autoScope:d.autoScope,audioLevel:d.audioLevel};d.trackList&&(h.tracks=(0,v.parseTrackList)(d.trackList,e)),n.timeline=h}else if(s==="cmls"){let d=(0,v.readVersionAndDescriptor)(e);n.comps={settings:[]},d.origFXRefPoint&&(n.comps.originalEffectsReferencePoint={x:d.origFXRefPoint.Hrzn,y:d.origFXRefPoint.Vrtc});for(let p of d.layerSettings){n.comps.settings.push({compList:p.compList});let h=n.comps.settings[n.comps.settings.length-1];"enab"in p&&(h.enabled=p.enab),p.Ofst&&(h.offset={x:p.Ofst.Hrzn,y:p.Ofst.Vrtc}),!((u=p.vectorMask)===null||u===void 0)&&u.Ofst&&(h.vectorMaskOffset=(0,v.horzVrtcToXY)(p.vectorMask.Ofst)),p.Lefx&&(h.effects=(0,v.parseEffects)(p.Lefx,e)),p.blendOptions&&zf(p.blendOptions,h),p.FXRefPoint&&(h.effectsReferencePoint={x:p.FXRefPoint.Hrzn,y:p.FXRefPoint.Vrtc}),p.layerSpecific&&Vf(p.layerSpecific,h)}}else if(s==="extn"){let d=(0,v.readVersionAndDescriptor)(e);d.generatorSettings&&(n.generatorSettings=Us(d.generatorSettings))}else e.logMissingFeatures&&e.log('Unhandled "shmd" section key',s);(0,b.skipBytes)(e,l())})}catch(l){if(e.throwForMissingFeatures)throw l;e.logMissingFeatures&&e.log(`Failed to read "shmd" section key ${s}: ${l.message}`),e.offset=a}}(0,b.skipBytes)(e,t())},(e,n,t,i)=>{let{animationFrames:o,animationFrameFlags:r,timestamp:s,timeline:a,comps:l}=n,c=Ls(n)?void 0:n.generatorSettings,f=0;o&&f++,r&&f++,a&&f++,s!==void 0&&f++,l&&f++,c&&f++,(0,w.writeUint32)(e,f),o&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"mlst"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{let u={LaID:Is(n,i),LaSt:[]};for(let d=0;d<o.length;d++){let p=o[d],h={};p.enable!==void 0&&(h.enab=p.enable),h.FrLs=p.frames,p.offset&&(h.Ofst=(0,v.xyToHorzVrtc)(p.offset)),p.maskOffset&&(h.IMsk={Ofst:(0,v.xyToHorzVrtc)(p.maskOffset)}),p.vectorMaskOffset&&(h.VMsk={Ofst:(0,v.xyToHorzVrtc)(p.vectorMaskOffset)}),p.referencePoint&&(h.FXRf=(0,v.xyToHorzVrtc)(p.referencePoint));let m=Nf(p);m&&(h.LSpc=m),p.effects&&(h.Lefx=(0,v.serializeEffects)(p.effects,e,Do(p.effects)));let y=$f(p);y&&(h.blendOptions=y),u.LaSt.push(h)}(0,v.writeVersionAndDescriptor)(e,"","null",u,v.layerStateRoot)},!0)),r&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"mdyn"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{(0,w.writeUint16)(e,0),(0,w.writeUint8)(e,r.propagateFrameOne?0:15),(0,w.writeUint8)(e,(r.unifyLayerPosition?1:0)|(r.unifyLayerStyle?2:0)|(r.unifyLayerVisibility?4:0))})),a&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"tmln"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{let u={Vrsn:1,timeScope:{Vrsn:1,Strt:a.start,duration:a.duration,inTime:a.inTime,outTime:a.outTime},autoScope:a.autoScope,audioLevel:a.audioLevel};a.tracks&&(u.trackList=(0,v.serializeTrackList)(a.tracks,e)),u.LyrI=Is(n,i),(0,v.writeVersionAndDescriptor)(e,"","null",u,"anim")},!0)),s!==void 0&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"cust"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{let u={layerTime:s};(0,v.writeVersionAndDescriptor)(e,"","metadata",u)},!0)),l&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"cmls"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{let u={};l.originalEffectsReferencePoint&&(u.origFXRefPoint={Hrzn:l.originalEffectsReferencePoint.x,Vrtc:l.originalEffectsReferencePoint.y}),u.LyrI=Is(n,i),u.layerSettings=[];for(let d of l.settings){let p={};if(d.enabled!==void 0&&(p.enab=d.enabled),d.offset&&(p.Ofst=(0,v.xyToHorzVrtc)(d.offset)),d.vectorMaskOffset&&(p.vectorMask={Ofst:(0,v.xyToHorzVrtc)(d.vectorMaskOffset)}),d.effects){let y=(0,v.serializeEffects)(d.effects,e,!0),{numModifyingFX:g}=y,k=Vg(y,["numModifyingFX"]);p.Lefx=k}let h=$f(d);h&&(p.blendOptions=h),d.effectsReferencePoint&&(p.FXRefPoint={Hrzn:d.effectsReferencePoint.x,Vrtc:d.effectsReferencePoint.y});let m=Nf(d);m&&(p.layerSpecific=m),p.compList=d.compList,u.layerSettings.push(p)}(0,v.writeVersionAndDescriptor)(e,"","null",u,v.layerStateRoot)},!0)),c&&((0,w.writeSignature)(e,"8BIM"),(0,w.writeSignature)(e,"extn"),(0,w.writeUint8)(e,0),(0,w.writeZeros)(e,3),(0,w.writeSection)(e,2,()=>{(0,v.writeVersionAndDescriptor)(e,"","null",sd(c))},!0))});U("PxSc",le("pixelSource"),(e,n)=>{let t=(0,v.readVersionAndDescriptor)(e,!0);t.pixelSourceType===1986285651?n.pixelSource={type:"vdPS",origin:{x:t.origin.Hrzn,y:t.origin.Vrtc},interpretation:{interpretAlpha:t.interpretation.interpretAlpha.split(".")[1],profile:t.interpretation.profile},frameReader:{type:"QTFR",link:{name:t.frameReader["Lnk "]["Nm "],fullPath:t.frameReader["Lnk "].fullPath,originalPath:t.frameReader["Lnk "].originalPath,relativePath:t.frameReader["Lnk "].relPath,alias:t.frameReader["Lnk "].alis},mediaDescriptor:t.frameReader.mediaDescriptor},showAlteredVideo:t.showAlteredVideo}:e.log("Unknown pixelSourceType")},(e,n)=>{let t=n.pixelSource,i={_name:"",_classID:"PixelSource",pixelSourceType:1986285651,descVersion:1,origin:{Hrzn:t.origin.x,Vrtc:t.origin.y},interpretation:{_name:"",_classID:"footageInterpretation",Vrsn:1,interpretAlpha:`alphaInterpretation.${t.interpretation.interpretAlpha}`,profile:t.interpretation.profile},frameReader:{_name:"",_classID:"FrameReader",frameReaderType:1364477522,descVersion:1,"Lnk ":{_name:"",_classID:"ExternalFileLink",descVersion:2,"Nm ":t.frameReader.link.name,fullPath:t.frameReader.link.fullPath,originalPath:t.frameReader.link.originalPath,alis:t.frameReader.link.alias,relPath:t.frameReader.link.relativePath},mediaDescriptor:t.frameReader.mediaDescriptor},showAlteredVideo:t.showAlteredVideo};(0,v.writeVersionAndDescriptor)(e,"","PixelSource",i)});U("vstk",le("vectorStroke"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.vectorStroke={strokeEnabled:i.strokeEnabled,fillEnabled:i.fillEnabled,lineWidth:(0,v.parseUnits)(i.strokeStyleLineWidth),lineDashOffset:(0,v.parseUnits)(i.strokeStyleLineDashOffset),miterLimit:i.strokeStyleMiterLimit,lineCapType:v.strokeStyleLineCapType.decode(i.strokeStyleLineCapType),lineJoinType:v.strokeStyleLineJoinType.decode(i.strokeStyleLineJoinType),lineAlignment:v.strokeStyleLineAlignment.decode(i.strokeStyleLineAlignment),scaleLock:i.strokeStyleScaleLock,strokeAdjust:i.strokeStyleStrokeAdjust,lineDashSet:(i.strokeStyleLineDashSet||[]).map(v.parseUnits),blendMode:v.BlnM.decode(i.strokeStyleBlendMode),opacity:(0,v.parsePercent)(i.strokeStyleOpacity),content:(0,v.parseVectorContent)(i.strokeStyleContent),resolution:i.strokeStyleResolution},(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o;let r=n.vectorStroke,s={strokeStyleVersion:2,strokeEnabled:!!r.strokeEnabled,fillEnabled:!!r.fillEnabled,strokeStyleLineWidth:r.lineWidth||{value:3,units:"Points"},strokeStyleLineDashOffset:r.lineDashOffset||{value:0,units:"Points"},strokeStyleMiterLimit:(t=r.miterLimit)!==null&&t!==void 0?t:100,strokeStyleLineCapType:v.strokeStyleLineCapType.encode(r.lineCapType),strokeStyleLineJoinType:v.strokeStyleLineJoinType.encode(r.lineJoinType),strokeStyleLineAlignment:v.strokeStyleLineAlignment.encode(r.lineAlignment),strokeStyleScaleLock:!!r.scaleLock,strokeStyleStrokeAdjust:!!r.strokeAdjust,strokeStyleLineDashSet:r.lineDashSet||[],strokeStyleBlendMode:v.BlnM.encode(r.blendMode),strokeStyleOpacity:(0,v.unitsPercent)((i=r.opacity)!==null&&i!==void 0?i:1),strokeStyleContent:(0,v.serializeVectorContent)(r.content||{type:"color",color:{r:0,g:0,b:0}}).descriptor,strokeStyleResolution:(o=r.resolution)!==null&&o!==void 0?o:72};(0,v.writeVersionAndDescriptor)(e,"","strokeStyle",s)});U("artb",le("artboard"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e),o=i.artboardRect;n.artboard={rect:{top:o["Top "],left:o.Left,bottom:o.Btom,right:o.Rght},guideIndices:i.guideIndeces,presetName:i.artboardPresetName},i["Clr "]&&(n.artboard.color=(0,v.parseColor)(i["Clr "])),i.artboardBackgroundType!==void 0&&(n.artboard.backgroundType=i.artboardBackgroundType),(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.artboard,o=i.rect,r={artboardRect:{"Top ":o.top,Left:o.left,Btom:o.bottom,Rght:o.right},guideIndeces:i.guideIndices||[],artboardPresetName:i.presetName||"","Clr ":(0,v.serializeColor)(i.color),artboardBackgroundType:(t=i.backgroundType)!==null&&t!==void 0?t:1};(0,v.writeVersionAndDescriptor)(e,"","artboard",r)});U("sn2P",le("usingAlignedRendering"),(e,n)=>n.usingAlignedRendering=!!(0,b.readUint32)(e),(e,n)=>(0,w.writeUint32)(e,n.usingAlignedRendering?1:0));var Nn=["unknown","vector","raster","image stack"];function ld(e){var n,t,i,o,r,s;let a=Object.assign(Object.assign({style:v.warpStyle.decode(e.warpStyle)},e.warpValues?{values:e.warpValues}:{value:e.warpValue||0}),{perspective:e.warpPerspective||0,perspectiveOther:e.warpPerspectiveOther||0,rotate:v.Ornt.decode(e.warpRotate),bounds:e.bounds&&{top:(0,v.parseUnitsOrNumber)(e.bounds["Top "]),left:(0,v.parseUnitsOrNumber)(e.bounds.Left),bottom:(0,v.parseUnitsOrNumber)(e.bounds.Btom),right:(0,v.parseUnitsOrNumber)(e.bounds.Rght)},uOrder:e.uOrder,vOrder:e.vOrder});(e.deformNumRows!=null||e.deformNumCols!=null)&&(a.deformNumRows=e.deformNumRows,a.deformNumCols=e.deformNumCols);let l=e.customEnvelopeWarp;if(l){a.customEnvelopeWarp={meshPoints:[]};let c=((n=l.meshPoints.find(u=>u.type==="Hrzn"))===null||n===void 0?void 0:n.values)||[],f=((t=l.meshPoints.find(u=>u.type==="Vrtc"))===null||t===void 0?void 0:t.values)||[];for(let u=0;u<c.length;u++)a.customEnvelopeWarp.meshPoints.push({x:c[u],y:f[u]});(l.quiltSliceX||l.quiltSliceY)&&(a.customEnvelopeWarp.quiltSliceX=((o=(i=l.quiltSliceX)===null||i===void 0?void 0:i[0])===null||o===void 0?void 0:o.values)||[],a.customEnvelopeWarp.quiltSliceY=((s=(r=l.quiltSliceY)===null||r===void 0?void 0:r[0])===null||s===void 0?void 0:s.values)||[])}return a}function Bs(e){var n,t;return e.deformNumCols!=null||e.deformNumRows!=null||((n=e.customEnvelopeWarp)===null||n===void 0?void 0:n.quiltSliceX)||((t=e.customEnvelopeWarp)===null||t===void 0?void 0:t.quiltSliceY)}function Po(e){let n=e.bounds,t=Object.assign(Object.assign({warpStyle:v.warpStyle.encode(e.style)},e.values?{warpValues:e.values}:{warpValue:e.value||0}),{warpPerspective:e.perspective||0,warpPerspectiveOther:e.perspectiveOther||0,warpRotate:v.Ornt.encode(e.rotate),bounds:{"Top ":(0,v.unitsValue)(n&&n.top||{units:"Pixels",value:0},"bounds.top"),Left:(0,v.unitsValue)(n&&n.left||{units:"Pixels",value:0},"bounds.left"),Btom:(0,v.unitsValue)(n&&n.bottom||{units:"Pixels",value:0},"bounds.bottom"),Rght:(0,v.unitsValue)(n&&n.right||{units:"Pixels",value:0},"bounds.right")},uOrder:e.uOrder||0,vOrder:e.vOrder||0}),i=Bs(e);if(i){let r=t;r.deformNumRows=e.deformNumRows||0,r.deformNumCols=e.deformNumCols||0}let o=e.customEnvelopeWarp;if(o){let r=o.meshPoints||[];if(i){let s=t;s.customEnvelopeWarp={_name:"",_classID:"customEnvelopeWarp",quiltSliceX:[{type:"quiltSliceX",values:o.quiltSliceX||[]}],quiltSliceY:[{type:"quiltSliceY",values:o.quiltSliceY||[]}],meshPoints:[{type:"Hrzn",values:r.map(a=>a.x)},{type:"Vrtc",values:r.map(a=>a.y)}]}}else t.customEnvelopeWarp={_name:"",_classID:"customEnvelopeWarp",meshPoints:[{type:"Hrzn",values:r.map(s=>s.x)},{type:"Vrtc",values:r.map(s=>s.y)}]}}return t}U("PlLd",e=>!!e.placedLayer&&!e.placedLayer.external,(e,n,t)=>{if((0,b.readSignature)(e)!=="plcL")throw new Error("Invalid PlLd signature");if((0,b.readInt32)(e)!==3)throw new Error("Invalid PlLd version");let i=(0,b.readPascalString)(e,1),o=(0,b.readInt32)(e),r=(0,b.readInt32)(e);(0,b.readInt32)(e);let s=(0,b.readInt32)(e);if(!Nn[s])throw new Error("Invalid PlLd type");let a=[];for(let f=0;f<8;f++)a.push((0,b.readFloat64)(e));let l=(0,b.readInt32)(e);if(l!==0)throw new Error(`Invalid Warp version ${l}`);let c=(0,v.readVersionAndDescriptor)(e);n.placedLayer=n.placedLayer||{id:i,type:Nn[s],pageNumber:o,totalPages:r,transform:a,warp:ld(c)},(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.placedLayer;if((0,w.writeSignature)(e,"plcL"),(0,w.writeInt32)(e,3),!t.id||typeof t.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(t.id))throw new Error("Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");if((0,w.writePascalString)(e,t.id,1),(0,w.writeInt32)(e,t.pageNumber||1),(0,w.writeInt32)(e,t.totalPages||1),(0,w.writeInt32)(e,16),Nn.indexOf(t.type)===-1)throw new Error("Invalid placedLayer type");(0,w.writeInt32)(e,Nn.indexOf(t.type));for(let s=0;s<8;s++)(0,w.writeFloat64)(e,t.transform[s]);(0,w.writeInt32)(e,0);let i=fd(t),r=Bs(i)?"quiltWarp":"warp";(0,v.writeVersionAndDescriptor)(e,"",r,Po(i),r)});var Wg=["_name","_classID","presetKind","Adjs"],Xg=["_name","_classID","Chnl","Inpt","Otpt","Gmm "];function qg(e){let n=Math.floor(e.byteLength/4);return new Float32Array(e.buffer.slice(e.byteOffset,e.byteOffset+n*4),0,n)}function Zg(e){let n=Math.floor(e.byteLength/4);return new Uint32Array(e.buffer.slice(e.byteOffset,e.byteOffset+n*4),0,n)}function Cs(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Co(e){let n=[];for(let t=0;t<e.length;t+=2)n.push({x:e[t],y:e[t+1]});return n}function xi(e){let n=[];for(let t=0;t<e.length;t++)n.push(e[t].x,e[t].y);return n}function Gf(e){return Co(qg(e))}function ki(e){return{x:(0,v.parseUnits)(e.Hrzn),y:(0,v.parseUnits)(e.Vrtc)}}function _i(e){return{_name:"",_classID:"Pnt ",Hrzn:(0,v.unitsValue)(e.x,"x"),Vrtc:(0,v.unitsValue)(e.y,"y")}}var Ps=[["red","R"],["orange","O"],["yellow","Y"],["green","G"],["aqua","A"],["blue","B"],["purple","P"],["magenta","M"]],Ms=[["version","CrVe"],["processVersion","PrVN"],["processVersionCode","PrVe"],["whiteBalance","WBal"],["temperature","Temp"],["tint","Tint"],["exposure","Ex12"],["contrast","Cr12"],["highlights","Hi12"],["shadows","Sh12"],["whites","Wh12"],["blacks","Bk12"],["texture","CrTx"],["clarity","Cl12"],["dehaze","Dhze"],["vibrance","Vibr"],["saturation","Strt"],["parametricCurve.shadows","PC_S"],["parametricCurve.darks","PC_D"],["parametricCurve.lights","PC_L"],["parametricCurve.highlights","PC_H"],["parametricCurve.shadowSplit","PC_1"],["parametricCurve.midtoneSplit","PC_2"],["parametricCurve.highlightSplit","PC_3"],["pointCurve.composite","Crv "],["pointCurve.red","CrvR"],["pointCurve.green","CrvG"],["pointCurve.blue","CrvB"],...Ps.map(([e,n])=>[`hsl.hue.${e}`,`HA_${n}`]),...Ps.map(([e,n])=>[`hsl.saturation.${e}`,`SA_${n}`]),...Ps.map(([e,n])=>[`hsl.luminance.${e}`,`LA_${n}`]),["colorGrading.shadows.hue","STSH"],["colorGrading.shadows.saturation","STSS"],["colorGrading.shadows.luminance","CgSL"],["colorGrading.midtones.hue","CgMH"],["colorGrading.midtones.saturation","CgMS"],["colorGrading.midtones.luminance","CgML"],["colorGrading.highlights.hue","STHH"],["colorGrading.highlights.saturation","STHS"],["colorGrading.highlights.luminance","CgHL"],["colorGrading.global.hue","CgGH"],["colorGrading.global.saturation","CgGS"],["colorGrading.global.luminance","CgGL"],["colorGrading.blending","CgBl"],["colorGrading.balance","STB "],["sharpening.amount","Shrp"],["sharpening.radius","ShpR"],["sharpening.detail","ShpD"],["sharpening.masking","ShpM"],["noiseReduction.luminance","LNR "],["noiseReduction.luminanceDetail","LNRD"],["noiseReduction.luminanceContrast","LNRC"],["noiseReduction.color","CNR "],["noiseReduction.colorDetail","CNRD"],["noiseReduction.colorSmoothness","CNRS"],["grain.amount","GRNA"],["grain.size","GRNS"],["grain.roughness","GRNF"],["postCropVignette.amount","PCVA"],["postCropVignette.midpoint","PCVM"],["postCropVignette.feather","PCVF"],["postCropVignette.roundness","PCVR"]],cd=["Crv ","CrvR","CrvG","CrvB"],Kg=2783;function Yg(e,n){var t;let i={};for(let[o,r]of Ms){let s=e[r];if(s===void 0)continue;if(r==="WBal")s=s.split(".")[1];else if(cd.includes(r)){let c=s;s=[];for(let f=0;f+1<c.length;f+=2)s.push({input:c[f],output:c[f+1]})}let a=o.split("."),l=i;for(let c=0;c<a.length-1;c++)l=l[a[c]]=(t=l[a[c]])!==null&&t!==void 0?t:{};l[a[a.length-1]]=s}for(let o of Object.keys(e))o!=="_name"&&o!=="_classID"&&!Ms.some(r=>r[1]===o)&&n.logMissingFeatures&&n.log(`Unhandled Camera Raw Filter setting: ${o}`);return i}function Jg(e){let n={_name:"",_classID:v.cameraRawFilterClassID};for(let[t,i]of Ms){let o=e;for(let r of t.split("."))o=o?.[r];o!==void 0&&(i==="WBal"?o=`WBal.${o}`:cd.includes(i)?o=o.flatMap(r=>[Math.round(r.input),Math.round(r.output)]):typeof o=="number"&&i!=="Ex12"&&i!=="ShpR"&&(o=Math.round(o)),n[i]=o)}return n}function Qg(e,n){let t={name:e["Nm "],opacity:(0,v.parsePercent)(e.blendOptions.Opct),blendMode:v.BlnM.decode(e.blendOptions["Md "]),enabled:e.enab,hasOptions:e.hasoptions,foregroundColor:(0,v.parseColor)(e.FrgC),backgroundColor:(0,v.parseColor)(e.BckC)};if("Fltr"in e&&e.Fltr._classID===v.cameraRawFilterClassID)return Object.assign(Object.assign({},t),{type:"camera raw",filter:Yg(e.Fltr,n)});if("Fltr"in e)switch(e.Fltr._classID){case"boxblur":return Object.assign(Object.assign({},t),{type:"box blur",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"GsnB":return Object.assign(Object.assign({},t),{type:"gaussian blur",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"MtnB":return Object.assign(Object.assign({},t),{type:"motion blur",filter:{angle:e.Fltr.Angl,distance:(0,v.parseUnits)(e.Fltr.Dstn)}});case"RdlB":return Object.assign(Object.assign({},t),{type:"radial blur",filter:{amount:e.Fltr.Amnt,method:v.BlrM.decode(e.Fltr.BlrM),quality:v.BlrQ.decode(e.Fltr.BlrQ)}});case"shapeBlur":return Object.assign(Object.assign({},t),{type:"shape blur",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "]),customShape:{name:e.Fltr.customShape["Nm "],id:e.Fltr.customShape.Idnt}}});case"SmrB":return Object.assign(Object.assign({},t),{type:"smart blur",filter:{radius:e.Fltr["Rds "],threshold:e.Fltr.Thsh,quality:v.SmBQ.decode(e.Fltr.SmBQ),mode:v.SmBM.decode(e.Fltr.SmBM)}});case"surfaceBlur":return Object.assign(Object.assign({},t),{type:"surface blur",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh}});case"Dspl":return Object.assign(Object.assign({},t),{type:"displace",filter:{horizontalScale:e.Fltr.HrzS,verticalScale:e.Fltr.VrtS,displacementMap:v.DspM.decode(e.Fltr.DspM),undefinedAreas:v.UndA.decode(e.Fltr.UndA),displacementFile:{signature:e.Fltr.DspF.sig,path:e.Fltr.DspF.path}}});case"Pnch":return Object.assign(Object.assign({},t),{type:"pinch",filter:{amount:e.Fltr.Amnt}});case"Plr ":return Object.assign(Object.assign({},t),{type:"polar coordinates",filter:{conversion:v.Cnvr.decode(e.Fltr.Cnvr)}});case"Rple":return Object.assign(Object.assign({},t),{type:"ripple",filter:{amount:e.Fltr.Amnt,size:v.RplS.decode(e.Fltr.RplS)}});case"Shr ":return Object.assign(Object.assign({},t),{type:"shear",filter:{shearPoints:e.Fltr.ShrP.map(i=>({x:i.Hrzn,y:i.Vrtc})),shearStart:e.Fltr.ShrS,shearEnd:e.Fltr.ShrE,undefinedAreas:v.UndA.decode(e.Fltr.UndA)}});case"Sphr":return Object.assign(Object.assign({},t),{type:"spherize",filter:{amount:e.Fltr.Amnt,mode:v.SphM.decode(e.Fltr.SphM)}});case"Twrl":return Object.assign(Object.assign({},t),{type:"twirl",filter:{angle:e.Fltr.Angl}});case"Wave":return Object.assign(Object.assign({},t),{type:"wave",filter:{numberOfGenerators:e.Fltr.NmbG,type:v.Wvtp.decode(e.Fltr.Wvtp),wavelength:{min:e.Fltr.WLMn,max:e.Fltr.WLMx},amplitude:{min:e.Fltr.AmMn,max:e.Fltr.AmMx},scale:{x:e.Fltr.SclH,y:e.Fltr.SclV},randomSeed:e.Fltr.RndS,undefinedAreas:v.UndA.decode(e.Fltr.UndA)}});case"ZgZg":return Object.assign(Object.assign({},t),{type:"zigzag",filter:{amount:e.Fltr.Amnt,ridges:e.Fltr.NmbR,style:v.ZZTy.decode(e.Fltr.ZZTy)}});case"AdNs":return Object.assign(Object.assign({},t),{type:"add noise",filter:{amount:(0,v.parsePercent)(e.Fltr.Nose),distribution:v.Dstr.decode(e.Fltr.Dstr),monochromatic:e.Fltr.Mnch,randomSeed:e.Fltr.FlRs}});case"DstS":return Object.assign(Object.assign({},t),{type:"dust and scratches",filter:{radius:e.Fltr["Rds "],threshold:e.Fltr.Thsh}});case"Mdn ":return Object.assign(Object.assign({},t),{type:"median",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"denoise":return Object.assign(Object.assign({},t),{type:"reduce noise",filter:{preset:e.Fltr.preset,removeJpegArtifact:e.Fltr.removeJPEGArtifact,reduceColorNoise:(0,v.parsePercent)(e.Fltr.ClNs),sharpenDetails:(0,v.parsePercent)(e.Fltr.Shrp),channelDenoise:e.Fltr.channelDenoise.map(i=>Object.assign({channels:i.Chnl.map(v.Chnl.decode),amount:i.Amnt},i.EdgF?{preserveDetails:i.EdgF}:{}))}});case"ClrH":return Object.assign(Object.assign({},t),{type:"color halftone",filter:{radius:e.Fltr["Rds "],angle1:e.Fltr.Ang1,angle2:e.Fltr.Ang2,angle3:e.Fltr.Ang3,angle4:e.Fltr.Ang4}});case"Crst":return Object.assign(Object.assign({},t),{type:"crystallize",filter:{cellSize:e.Fltr.ClSz,randomSeed:e.Fltr.FlRs}});case"Mztn":return Object.assign(Object.assign({},t),{type:"mezzotint",filter:{type:v.MztT.decode(e.Fltr.MztT),randomSeed:e.Fltr.FlRs}});case"Msc ":return Object.assign(Object.assign({},t),{type:"mosaic",filter:{cellSize:(0,v.parseUnits)(e.Fltr.ClSz)}});case"Pntl":return Object.assign(Object.assign({},t),{type:"pointillize",filter:{cellSize:e.Fltr.ClSz,randomSeed:e.Fltr.FlRs}});case"Clds":return Object.assign(Object.assign({},t),{type:"clouds",filter:{randomSeed:e.Fltr.FlRs}});case"DfrC":return Object.assign(Object.assign({},t),{type:"difference clouds",filter:{randomSeed:e.Fltr.FlRs}});case"Fbrs":return Object.assign(Object.assign({},t),{type:"fibers",filter:{variance:e.Fltr.Vrnc,strength:e.Fltr.Strg,randomSeed:e.Fltr.RndS}});case"LnsF":return Object.assign(Object.assign({},t),{type:"lens flare",filter:{brightness:e.Fltr.Brgh,position:{x:e.Fltr.FlrC.Hrzn,y:e.Fltr.FlrC.Vrtc},lensType:v.Lns.decode(e.Fltr["Lns "])}});case"smartSharpen":return Object.assign(Object.assign({},t),{type:"smart sharpen",filter:{amount:(0,v.parsePercent)(e.Fltr.Amnt),radius:(0,v.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh,angle:e.Fltr.Angl,moreAccurate:e.Fltr.moreAccurate,blur:v.blurType.decode(e.Fltr.blur),preset:e.Fltr.preset,shadow:{fadeAmount:(0,v.parsePercent)(e.Fltr.sdwM.Amnt),tonalWidth:(0,v.parsePercent)(e.Fltr.sdwM.Wdth),radius:e.Fltr.sdwM["Rds "]},highlight:{fadeAmount:(0,v.parsePercent)(e.Fltr.hglM.Amnt),tonalWidth:(0,v.parsePercent)(e.Fltr.hglM.Wdth),radius:e.Fltr.hglM["Rds "]}}});case"UnsM":return Object.assign(Object.assign({},t),{type:"unsharp mask",filter:{amount:(0,v.parsePercent)(e.Fltr.Amnt),radius:(0,v.parseUnits)(e.Fltr["Rds "]),threshold:e.Fltr.Thsh}});case"Dfs ":return Object.assign(Object.assign({},t),{type:"diffuse",filter:{mode:v.DfsM.decode(e.Fltr["Md "]),randomSeed:e.Fltr.FlRs}});case"Embs":return Object.assign(Object.assign({},t),{type:"emboss",filter:{angle:e.Fltr.Angl,height:e.Fltr.Hght,amount:e.Fltr.Amnt}});case"Extr":return Object.assign(Object.assign({},t),{type:"extrude",filter:{type:v.ExtT.decode(e.Fltr.ExtT),size:e.Fltr.ExtS,depth:e.Fltr.ExtD,depthMode:v.ExtR.decode(e.Fltr.ExtR),randomSeed:e.Fltr.FlRs,solidFrontFaces:e.Fltr.ExtF,maskIncompleteBlocks:e.Fltr.ExtM}});case"Tls ":return Object.assign(Object.assign({},t),{type:"tiles",filter:{numberOfTiles:e.Fltr.TlNm,maximumOffset:e.Fltr.TlOf,fillEmptyAreaWith:v.FlCl.decode(e.Fltr.FlCl),randomSeed:e.Fltr.FlRs}});case"TrcC":return Object.assign(Object.assign({},t),{type:"trace contour",filter:{level:e.Fltr["Lvl "],edge:v.CntE.decode(e.Fltr["Edg "])}});case"Wnd ":return Object.assign(Object.assign({},t),{type:"wind",filter:{method:v.WndM.decode(e.Fltr.WndM),direction:v.Drct.decode(e.Fltr.Drct)}});case"Dntr":return Object.assign(Object.assign({},t),{type:"de-interlace",filter:{eliminate:v.IntE.decode(e.Fltr.IntE),newFieldsBy:v.IntC.decode(e.Fltr.IntC)}});case"Cstm":return Object.assign(Object.assign({},t),{type:"custom",filter:{scale:e.Fltr["Scl "],offset:e.Fltr.Ofst,matrix:e.Fltr.Mtrx}});case"HghP":return Object.assign(Object.assign({},t),{type:"high pass",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"Mxm ":return Object.assign(Object.assign({},t),{type:"maximum",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"Mnm ":return Object.assign(Object.assign({},t),{type:"minimum",filter:{radius:(0,v.parseUnits)(e.Fltr["Rds "])}});case"Ofst":return Object.assign(Object.assign({},t),{type:"offset",filter:{horizontal:e.Fltr.Hrzn,vertical:e.Fltr.Vrtc,undefinedAreas:v.FlMd.decode(e.Fltr["Fl "])}});case"rigidTransform":return Object.assign(Object.assign({},t),{type:"puppet",filter:{rigidType:e.Fltr.rigidType,bounds:[{x:e.Fltr.PuX0,y:e.Fltr.PuY0},{x:e.Fltr.PuX1,y:e.Fltr.PuY1},{x:e.Fltr.PuX2,y:e.Fltr.PuY2},{x:e.Fltr.PuX3,y:e.Fltr.PuY3}],puppetShapeList:(e.Fltr.puppetShapeList||[]).map(i=>({rigidType:i.rigidType,originalVertexArray:Gf(i.originalVertexArray),deformedVertexArray:Gf(i.deformedVertexArray),indexArray:Array.from(Zg(i.indexArray)),pinOffsets:Co(i.pinOffsets),posFinalPins:Co(i.posFinalPins),pinVertexIndices:i.pinVertexIndices,selectedPin:i.selectedPin,pinPosition:Co(i.PinP),pinRotation:i.PnRt,pinOverlay:i.PnOv,pinDepth:i.PnDp,meshQuality:i.meshQuality,meshExpansion:i.meshExpansion,meshRigidity:i.meshRigidity,imageResolution:i.imageResolution,meshBoundaryPath:{pathComponents:i.meshBoundaryPath.pathComponents.map(o=>({shapeOperation:o.shapeOperation.split(".")[1],paths:o.SbpL.map(r=>({closed:r.Clsp,points:r["Pts "].map(s=>({anchor:ki(s.Anch),forward:ki(s["Fwd "]),backward:ki(s["Bwd "]),smooth:s.Smoo}))}))}))}}))}});case"PbPl":{let i=[],o=e.Fltr;for(let r=0;r<Ze.length&&o[`PN${Ze[r]}a`];r++)for(let s=0;s<Ze.length&&o[`PN${Ze[r]}${Ze[s]}`];s++)i.push({name:o[`PN${Ze[r]}${Ze[s]}`],value:o[`PF${Ze[r]}${Ze[s]}`]});return Object.assign(Object.assign({},t),{type:"oil paint plugin",filter:{name:e.Fltr.KnNm,gpu:e.Fltr.GpuY,lighting:e.Fltr.LIWy,parameters:i}})}case"HsbP":return Object.assign(Object.assign({},t),{type:"hsb/hsl",filter:{inputMode:v.ClrS.decode(e.Fltr.Inpt),rowOrder:v.ClrS.decode(e.Fltr.Otpt)}});case"oilPaint":return Object.assign(Object.assign({},t),{type:"oil paint",filter:{lightingOn:e.Fltr.lightingOn,stylization:e.Fltr.stylization,cleanliness:e.Fltr.cleanliness,brushScale:e.Fltr.brushScale,microBrush:e.Fltr.microBrush,lightDirection:e.Fltr.LghD,specularity:e.Fltr.specularity}});case"LqFy":return Object.assign(Object.assign({},t),{type:"liquify",filter:{liquifyMesh:e.Fltr.LqMe}});case"perspectiveWarpTransform":return Object.assign(Object.assign({},t),{type:"perspective warp",filter:{vertices:e.Fltr.vertices.map(ki),warpedVertices:e.Fltr.warpedVertices.map(ki),quads:e.Fltr.quads.map(i=>i.indices)}});case"Crvs":return Object.assign(Object.assign({},t),{type:"curves",filter:Object.assign(Object.assign({},e.Fltr.presetKind!==void 0?{presetKind:v.presetKindType.decode(e.Fltr.presetKind)}:{}),e.Fltr.Adjs?{adjustments:e.Fltr.Adjs.map(i=>{let o=i.Chnl.map(v.Chnl.decode);if(i["Crv "])return{channels:o,curve:i["Crv "].map(r=>{let s={x:r.Hrzn,y:r.Vrtc};return r.Cnty&&(s.curved=!0),s})};if(i.Mpng)return{channels:o,values:i.Mpng};throw new Error("Unknown curve adjustment")})}:{})});case"Lvls":{let i=e.Fltr.Adjs,o=(r,s)=>Object.keys(r).every(a=>s.indexOf(a)!==-1);if(!o(e.Fltr,Wg)||i&&!i.every(r=>o(r,Xg))){if(n.throwForMissingFeatures)throw new Error("Unknown levels filter settings");n.logMissingFeatures&&n.log("Skipped levels smart filter with unknown settings");return}return Object.assign(Object.assign({},t),{type:"levels",filter:Object.assign(Object.assign({},e.Fltr.presetKind!==void 0?{presetKind:v.presetKindType.decode(e.Fltr.presetKind)}:{}),i?{adjustments:i.map(r=>{let s={channels:r.Chnl.map(v.Chnl.decode)};return r.Inpt&&(s.shadowInput=r.Inpt[0],s.highlightInput=r.Inpt[1]),r.Otpt&&(s.shadowOutput=r.Otpt[0],s.highlightOutput=r.Otpt[1]),r["Gmm "]!==void 0&&(s.midtoneInput=r["Gmm "]),s})}:{})})}case"BrgC":return Object.assign(Object.assign({},t),{type:"brightness/contrast",filter:{brightness:e.Fltr.Brgh,contrast:e.Fltr.Cntr,useLegacy:!!e.Fltr.useLegacy}});default:if(n.throwForMissingFeatures)throw new Error(`Unknown filter classId: ${e.Fltr._classID}`);n.logMissingFeatures&&n.log(`Unhandled smart filter: ${e.Fltr._classID} (${e["Nm "]})`);return}else switch(e.filterID){case 1098281575:return Object.assign(Object.assign({},t),{type:"average"});case 1114403360:return Object.assign(Object.assign({},t),{type:"blur"});case 1114403405:return Object.assign(Object.assign({},t),{type:"blur more"});case 1148416099:return Object.assign(Object.assign({},t),{type:"despeckle"});case 1180922912:return Object.assign(Object.assign({},t),{type:"facet"});case 1181902701:return Object.assign(Object.assign({},t),{type:"fragment"});case 1399353968:return Object.assign(Object.assign({},t),{type:"sharpen"});case 1399353925:return Object.assign(Object.assign({},t),{type:"sharpen edges"});case 1399353933:return Object.assign(Object.assign({},t),{type:"sharpen more"});case 1181639749:return Object.assign(Object.assign({},t),{type:"find edges"});case 1399616122:return Object.assign(Object.assign({},t),{type:"solarize"});case 1314149187:return Object.assign(Object.assign({},t),{type:"ntsc colors"});case 1231976050:return Object.assign(Object.assign({},t),{type:"invert"});default:if(n.throwForMissingFeatures)throw new Error(`Unknown filterID: ${e.filterID}`);n.logMissingFeatures&&n.log(`Unhandled smart filter: ${e.filterID} (${e["Nm "]})`);return}}function em(e,n){return{enabled:e.enab,validAtPosition:e.validAtPosition,maskEnabled:e.filterMaskEnable,maskLinked:e.filterMaskLinked,maskExtendWithWhite:e.filterMaskExtendWithWhite,list:e.filterFXList.map(t=>Qg(t,n)).filter(t=>!!t)}}function kt(e){return(0,v.unitsValue)(e.radius,"radius")}function tm(e){let n={_name:"",_classID:"filterFX","Nm ":e.name,blendOptions:{_name:"",_classID:"blendOptions",Opct:(0,v.unitsPercentF)(e.opacity),"Md ":v.BlnM.encode(e.blendMode)},enab:e.enabled,hasoptions:e.hasOptions,FrgC:(0,v.serializeColor)(e.foregroundColor),BckC:(0,v.serializeColor)(e.backgroundColor)};switch(e.type){case"average":return Object.assign(Object.assign({},n),{filterID:1098281575});case"blur":return Object.assign(Object.assign({},n),{filterID:1114403360});case"blur more":return Object.assign(Object.assign({},n),{filterID:1114403405});case"box blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Box Blur",_classID:"boxblur","Rds ":kt(e.filter)},filterID:697});case"gaussian blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Gaussian Blur",_classID:"GsnB","Rds ":kt(e.filter)},filterID:1198747202});case"motion blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Motion Blur",_classID:"MtnB",Angl:e.filter.angle,Dstn:(0,v.unitsValue)(e.filter.distance,"distance")},filterID:1299476034});case"radial blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Radial Blur",_classID:"RdlB",Amnt:e.filter.amount,BlrM:v.BlrM.encode(e.filter.method),BlrQ:v.BlrQ.encode(e.filter.quality)},filterID:1382313026});case"shape blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Shape Blur",_classID:"shapeBlur","Rds ":kt(e.filter),customShape:{_name:"",_classID:"customShape","Nm ":e.filter.customShape.name,Idnt:e.filter.customShape.id}},filterID:702});case"smart blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Smart Blur",_classID:"SmrB","Rds ":e.filter.radius,Thsh:e.filter.threshold,SmBQ:v.SmBQ.encode(e.filter.quality),SmBM:v.SmBM.encode(e.filter.mode)},filterID:1399681602});case"surface blur":return Object.assign(Object.assign({},n),{Fltr:{_name:"Surface Blur",_classID:"surfaceBlur","Rds ":kt(e.filter),Thsh:e.filter.threshold},filterID:701});case"displace":return Object.assign(Object.assign({},n),{Fltr:{_name:"Displace",_classID:"Dspl",HrzS:e.filter.horizontalScale,VrtS:e.filter.verticalScale,DspM:v.DspM.encode(e.filter.displacementMap),UndA:v.UndA.encode(e.filter.undefinedAreas),DspF:{sig:e.filter.displacementFile.signature,path:e.filter.displacementFile.path}},filterID:1148416108});case"pinch":return Object.assign(Object.assign({},n),{Fltr:{_name:"Pinch",_classID:"Pnch",Amnt:e.filter.amount},filterID:1349411688});case"polar coordinates":return Object.assign(Object.assign({},n),{Fltr:{_name:"Polar Coordinates",_classID:"Plr ",Cnvr:v.Cnvr.encode(e.filter.conversion)},filterID:1349284384});case"ripple":return Object.assign(Object.assign({},n),{Fltr:{_name:"Ripple",_classID:"Rple",Amnt:e.filter.amount,RplS:v.RplS.encode(e.filter.size)},filterID:1383099493});case"shear":return Object.assign(Object.assign({},n),{Fltr:{_name:"Shear",_classID:"Shr ",ShrP:e.filter.shearPoints.map(t=>({_name:"",_classID:"Pnt ",Hrzn:t.x,Vrtc:t.y})),UndA:v.UndA.encode(e.filter.undefinedAreas),ShrS:e.filter.shearStart,ShrE:e.filter.shearEnd},filterID:1399353888});case"spherize":return Object.assign(Object.assign({},n),{Fltr:{_name:"Spherize",_classID:"Sphr",Amnt:e.filter.amount,SphM:v.SphM.encode(e.filter.mode)},filterID:1399875698});case"twirl":return Object.assign(Object.assign({},n),{Fltr:{_name:"Twirl",_classID:"Twrl",Angl:e.filter.angle},filterID:1417114220});case"wave":return Object.assign(Object.assign({},n),{Fltr:{_name:"Wave",_classID:"Wave",Wvtp:v.Wvtp.encode(e.filter.type),NmbG:e.filter.numberOfGenerators,WLMn:e.filter.wavelength.min,WLMx:e.filter.wavelength.max,AmMn:e.filter.amplitude.min,AmMx:e.filter.amplitude.max,SclH:e.filter.scale.x,SclV:e.filter.scale.y,UndA:v.UndA.encode(e.filter.undefinedAreas),RndS:e.filter.randomSeed},filterID:1466005093});case"zigzag":return Object.assign(Object.assign({},n),{Fltr:{_name:"ZigZag",_classID:"ZgZg",Amnt:e.filter.amount,NmbR:e.filter.ridges,ZZTy:v.ZZTy.encode(e.filter.style)},filterID:1516722791});case"add noise":return Object.assign(Object.assign({},n),{Fltr:{_name:"Add Noise",_classID:"AdNs",Dstr:v.Dstr.encode(e.filter.distribution),Nose:(0,v.unitsPercentF)(e.filter.amount),Mnch:e.filter.monochromatic,FlRs:e.filter.randomSeed},filterID:1097092723});case"despeckle":return Object.assign(Object.assign({},n),{filterID:1148416099});case"dust and scratches":return Object.assign(Object.assign({},n),{Fltr:{_name:"Dust & Scratches",_classID:"DstS","Rds ":e.filter.radius,Thsh:e.filter.threshold},filterID:1148417107});case"median":return Object.assign(Object.assign({},n),{Fltr:{_name:"Median",_classID:"Mdn ","Rds ":kt(e.filter)},filterID:1298427424});case"reduce noise":return Object.assign(Object.assign({},n),{Fltr:{_name:"Reduce Noise",_classID:"denoise",ClNs:(0,v.unitsPercentF)(e.filter.reduceColorNoise),Shrp:(0,v.unitsPercentF)(e.filter.sharpenDetails),removeJPEGArtifact:e.filter.removeJpegArtifact,channelDenoise:e.filter.channelDenoise.map(t=>Object.assign({_name:"",_classID:"channelDenoiseParams",Chnl:t.channels.map(i=>v.Chnl.encode(i)),Amnt:t.amount},t.preserveDetails?{EdgF:t.preserveDetails}:{})),preset:e.filter.preset},filterID:633});case"color halftone":return Object.assign(Object.assign({},n),{Fltr:{_name:"Color Halftone",_classID:"ClrH","Rds ":e.filter.radius,Ang1:e.filter.angle1,Ang2:e.filter.angle2,Ang3:e.filter.angle3,Ang4:e.filter.angle4},filterID:1131180616});case"crystallize":return Object.assign(Object.assign({},n),{Fltr:{_name:"Crystallize",_classID:"Crst",ClSz:e.filter.cellSize,FlRs:e.filter.randomSeed},filterID:1131574132});case"facet":return Object.assign(Object.assign({},n),{filterID:1180922912});case"fragment":return Object.assign(Object.assign({},n),{filterID:1181902701});case"mezzotint":return Object.assign(Object.assign({},n),{Fltr:{_name:"Mezzotint",_classID:"Mztn",MztT:v.MztT.encode(e.filter.type),FlRs:e.filter.randomSeed},filterID:1299870830});case"mosaic":return Object.assign(Object.assign({},n),{Fltr:{_name:"Mosaic",_classID:"Msc ",ClSz:(0,v.unitsValue)(e.filter.cellSize,"cellSize")},filterID:1299407648});case"pointillize":return Object.assign(Object.assign({},n),{Fltr:{_name:"Pointillize",_classID:"Pntl",ClSz:e.filter.cellSize,FlRs:e.filter.randomSeed},filterID:1349416044});case"clouds":return Object.assign(Object.assign({},n),{Fltr:{_name:"Clouds",_classID:"Clds",FlRs:e.filter.randomSeed},filterID:1131177075});case"difference clouds":return Object.assign(Object.assign({},n),{Fltr:{_name:"Difference Clouds",_classID:"DfrC",FlRs:e.filter.randomSeed},filterID:1147564611});case"fibers":return Object.assign(Object.assign({},n),{Fltr:{_name:"Fibers",_classID:"Fbrs",Vrnc:e.filter.variance,Strg:e.filter.strength,RndS:e.filter.randomSeed},filterID:1180856947});case"lens flare":return Object.assign(Object.assign({},n),{Fltr:{_name:"Lens Flare",_classID:"LnsF",Brgh:e.filter.brightness,FlrC:{_name:"",_classID:"Pnt ",Hrzn:e.filter.position.x,Vrtc:e.filter.position.y},"Lns ":v.Lns.encode(e.filter.lensType)},filterID:1282306886});case"sharpen":return Object.assign(Object.assign({},n),{filterID:1399353968});case"sharpen edges":return Object.assign(Object.assign({},n),{filterID:1399353925});case"sharpen more":return Object.assign(Object.assign({},n),{filterID:1399353933});case"smart sharpen":return Object.assign(Object.assign({},n),{Fltr:{_name:"Smart Sharpen",_classID:"smartSharpen",Amnt:(0,v.unitsPercentF)(e.filter.amount),"Rds ":kt(e.filter),Thsh:e.filter.threshold,Angl:e.filter.angle,moreAccurate:e.filter.moreAccurate,blur:v.blurType.encode(e.filter.blur),preset:e.filter.preset,sdwM:{_name:"Parameters",_classID:"adaptCorrectTones",Amnt:(0,v.unitsPercentF)(e.filter.shadow.fadeAmount),Wdth:(0,v.unitsPercentF)(e.filter.shadow.tonalWidth),"Rds ":e.filter.shadow.radius},hglM:{_name:"Parameters",_classID:"adaptCorrectTones",Amnt:(0,v.unitsPercentF)(e.filter.highlight.fadeAmount),Wdth:(0,v.unitsPercentF)(e.filter.highlight.tonalWidth),"Rds ":e.filter.highlight.radius}},filterID:698});case"unsharp mask":return Object.assign(Object.assign({},n),{Fltr:{_name:"Unsharp Mask",_classID:"UnsM",Amnt:(0,v.unitsPercentF)(e.filter.amount),"Rds ":kt(e.filter),Thsh:e.filter.threshold},filterID:1433301837});case"diffuse":return Object.assign(Object.assign({},n),{Fltr:{_name:"Diffuse",_classID:"Dfs ","Md ":v.DfsM.encode(e.filter.mode),FlRs:e.filter.randomSeed},filterID:1147564832});case"emboss":return Object.assign(Object.assign({},n),{Fltr:{_name:"Emboss",_classID:"Embs",Angl:e.filter.angle,Hght:e.filter.height,Amnt:e.filter.amount},filterID:1164796531});case"extrude":return Object.assign(Object.assign({},n),{Fltr:{_name:"Extrude",_classID:"Extr",ExtS:e.filter.size,ExtD:e.filter.depth,ExtF:e.filter.solidFrontFaces,ExtM:e.filter.maskIncompleteBlocks,ExtT:v.ExtT.encode(e.filter.type),ExtR:v.ExtR.encode(e.filter.depthMode),FlRs:e.filter.randomSeed},filterID:1165522034});case"find edges":return Object.assign(Object.assign({},n),{filterID:1181639749});case"solarize":return Object.assign(Object.assign({},n),{filterID:1399616122});case"tiles":return Object.assign(Object.assign({},n),{Fltr:{_name:"Tiles",_classID:"Tls ",TlNm:e.filter.numberOfTiles,TlOf:e.filter.maximumOffset,FlCl:v.FlCl.encode(e.filter.fillEmptyAreaWith),FlRs:e.filter.randomSeed},filterID:1416393504});case"trace contour":return Object.assign(Object.assign({},n),{Fltr:{_name:"Trace Contour",_classID:"TrcC","Lvl ":e.filter.level,"Edg ":v.CntE.encode(e.filter.edge)},filterID:1416782659});case"wind":return Object.assign(Object.assign({},n),{Fltr:{_name:"Wind",_classID:"Wnd ",WndM:v.WndM.encode(e.filter.method),Drct:v.Drct.encode(e.filter.direction)},filterID:1466852384});case"de-interlace":return Object.assign(Object.assign({},n),{Fltr:{_name:"De-Interlace",_classID:"Dntr",IntE:v.IntE.encode(e.filter.eliminate),IntC:v.IntC.encode(e.filter.newFieldsBy)},filterID:1148089458});case"ntsc colors":return Object.assign(Object.assign({},n),{filterID:1314149187});case"invert":return Object.assign(Object.assign({},n),{filterID:1231976050});case"custom":return Object.assign(Object.assign({},n),{Fltr:{_name:"Custom",_classID:"Cstm","Scl ":e.filter.scale,Ofst:e.filter.offset,Mtrx:e.filter.matrix},filterID:1131639917});case"high pass":return Object.assign(Object.assign({},n),{Fltr:{_name:"High Pass",_classID:"HghP","Rds ":kt(e.filter)},filterID:1214736464});case"maximum":return Object.assign(Object.assign({},n),{Fltr:{_name:"Maximum",_classID:"Mxm ","Rds ":kt(e.filter)},filterID:1299737888});case"minimum":return Object.assign(Object.assign({},n),{Fltr:{_name:"Minimum",_classID:"Mnm ","Rds ":kt(e.filter)},filterID:1299082528});case"offset":return Object.assign(Object.assign({},n),{Fltr:{_name:"Offset",_classID:"Ofst",Hrzn:e.filter.horizontal,Vrtc:e.filter.vertical,"Fl ":v.FlMd.encode(e.filter.undefinedAreas)},filterID:1332114292});case"puppet":return Object.assign(Object.assign({},n),{Fltr:{_name:"Rigid Transform",_classID:"rigidTransform",null:["Ordn.Trgt"],rigidType:e.filter.rigidType,puppetShapeList:(e.filter.puppetShapeList||[]).map(t=>({_name:"",_classID:"puppetShape",rigidType:t.rigidType,VrsM:1,VrsN:0,originalVertexArray:Cs(new Float32Array(xi(t.originalVertexArray))),deformedVertexArray:Cs(new Float32Array(xi(t.deformedVertexArray))),indexArray:Cs(new Uint32Array(t.indexArray)),pinOffsets:xi(t.pinOffsets),posFinalPins:xi(t.posFinalPins),pinVertexIndices:t.pinVertexIndices,PinP:xi(t.pinPosition),PnRt:t.pinRotation,PnOv:t.pinOverlay,PnDp:t.pinDepth,meshQuality:t.meshQuality,meshExpansion:t.meshExpansion,meshRigidity:t.meshRigidity,imageResolution:t.imageResolution,meshBoundaryPath:{_name:"",_classID:"pathClass",pathComponents:t.meshBoundaryPath.pathComponents.map(i=>({_name:"",_classID:"PaCm",shapeOperation:`shapeOperation.${i.shapeOperation}`,SbpL:i.paths.map(o=>({_name:"",_classID:"Sbpl",Clsp:o.closed,"Pts ":o.points.map(r=>({_name:"",_classID:"Pthp",Anch:_i(r.anchor),"Fwd ":_i(r.forward),"Bwd ":_i(r.backward),Smoo:r.smooth}))}))}))},selectedPin:t.selectedPin})),PuX0:e.filter.bounds[0].x,PuX1:e.filter.bounds[1].x,PuX2:e.filter.bounds[2].x,PuX3:e.filter.bounds[3].x,PuY0:e.filter.bounds[0].y,PuY1:e.filter.bounds[1].y,PuY2:e.filter.bounds[2].y,PuY3:e.filter.bounds[3].y},filterID:991});case"oil paint plugin":{let t={};for(let i=0;i<e.filter.parameters.length;i++){let{name:o,value:r}=e.filter.parameters[i],s=`${Ze[Math.floor(i/Ze.length)]}${Ze[i%Ze.length]}`;t[`PN${s}`]=o,t[`PT${s}`]=0,t[`PF${s}`]=r}return Object.assign(Object.assign({},n),{Fltr:Object.assign({_name:"Oil Paint Plugin",_classID:"PbPl",KnNm:e.filter.name,GpuY:e.filter.gpu,LIWy:e.filter.lighting,FPth:"1"},t),filterID:1348620396})}case"oil paint":return Object.assign(Object.assign({},n),{Fltr:{_name:"Oil Paint",_classID:"oilPaint",lightingOn:e.filter.lightingOn,stylization:e.filter.stylization,cleanliness:e.filter.cleanliness,brushScale:e.filter.brushScale,microBrush:e.filter.microBrush,LghD:e.filter.lightDirection,specularity:e.filter.specularity},filterID:1122});case"liquify":return Object.assign(Object.assign({},n),{Fltr:{_name:"Liquify",_classID:"LqFy",LqMe:e.filter.liquifyMesh},filterID:1282492025});case"perspective warp":return Object.assign(Object.assign({},n),{Fltr:{_name:"Perspective Warp",_classID:"perspectiveWarpTransform",vertices:e.filter.vertices.map(_i),warpedVertices:e.filter.warpedVertices.map(_i),quads:e.filter.quads.map(t=>({_name:"",_classID:"quadIndices",indices:t}))},filterID:442});case"curves":return Object.assign(Object.assign({},n),{Fltr:Object.assign(Object.assign({_name:"Curves",_classID:"Crvs"},e.filter.presetKind!==void 0?{presetKind:v.presetKindType.encode(e.filter.presetKind)}:{}),e.filter.adjustments?{Adjs:e.filter.adjustments.map(t=>"curve"in t?{_name:"",_classID:"CrvA",Chnl:t.channels.map(v.Chnl.encode),"Crv ":t.curve.map(i=>Object.assign({_name:"",_classID:"Pnt ",Hrzn:i.x,Vrtc:i.y},i.curved?{Cnty:!0}:{}))}:{_name:"",_classID:"CrvA",Chnl:t.channels.map(v.Chnl.encode),Mpng:t.values})}:{}),filterID:1131574899});case"levels":return Object.assign(Object.assign({},n),{Fltr:Object.assign(Object.assign({_name:"Levels",_classID:"Lvls"},e.filter.presetKind!==void 0?{presetKind:v.presetKindType.encode(e.filter.presetKind)}:{}),e.filter.adjustments?{Adjs:e.filter.adjustments.map(t=>{var i,o,r,s;let a={_name:"",_classID:"LvlA",Chnl:t.channels.map(v.Chnl.encode)};return(t.shadowInput!==void 0||t.highlightInput!==void 0)&&(a.Inpt=[Math.round((i=t.shadowInput)!==null&&i!==void 0?i:0),Math.round((o=t.highlightInput)!==null&&o!==void 0?o:255)]),(t.shadowOutput!==void 0||t.highlightOutput!==void 0)&&(a.Otpt=[Math.round((r=t.shadowOutput)!==null&&r!==void 0?r:0),Math.round((s=t.highlightOutput)!==null&&s!==void 0?s:255)]),t.midtoneInput!==void 0&&(a["Gmm "]=t.midtoneInput),a})}:{}),filterID:1282829427});case"camera raw":return Object.assign(Object.assign({},n),{Fltr:Jg(e.filter),filterID:Kg});case"brightness/contrast":return Object.assign(Object.assign({},n),{Fltr:{_name:"Brightness/Contrast",_classID:"BrgC",Brgh:e.filter.brightness,Cntr:e.filter.contrast,useLegacy:!!e.filter.useLegacy},filterID:1114793795});case"hsb/hsl":return Object.assign(Object.assign({},n),{Fltr:{_name:"HSB/HSL",_classID:"HsbP",Inpt:v.ClrS.encode(e.filter.inputMode),Otpt:v.ClrS.encode(e.filter.rowOrder)},filterID:1215521360});default:throw new Error(`Unknown filter type: ${e.type}`)}}function fd(e){if(e.warp)return e.warp;if(!e.width||!e.height)throw new Error("You must provide width and height of the linked image in placedLayer");let n=e.width,t=e.height,i=0,o=n/3,r=n*2/3,s=n,a=0,l=t/3,c=t*2/3,f=t;return{style:"custom",value:0,perspective:0,perspectiveOther:0,rotate:"horizontal",bounds:{top:{value:0,units:"Pixels"},left:{value:0,units:"Pixels"},bottom:{value:t,units:"Pixels"},right:{value:n,units:"Pixels"}},uOrder:4,vOrder:4,customEnvelopeWarp:{meshPoints:[{x:i,y:a},{x:o,y:a},{x:r,y:a},{x:s,y:a},{x:i,y:l},{x:o,y:l},{x:r,y:l},{x:s,y:l},{x:i,y:c},{x:o,y:c},{x:r,y:c},{x:s,y:c},{x:i,y:f},{x:o,y:f},{x:r,y:f},{x:s,y:f}]}}}U("SoLd",e=>!!e.placedLayer&&!e.placedLayer.external,(e,n,t)=>{if((0,b.readSignature)(e)!=="soLD")throw new Error("Invalid SoLd type");let i=(0,b.readInt32)(e);if(i!==4&&i!==5)throw new Error("Invalid SoLd version");let o=(0,v.readVersionAndDescriptor)(e,!0);n.placedLayer={id:o.Idnt,placed:o.placed,type:Nn[o.Type],pageNumber:o.PgNm,totalPages:o.totalPages,frameStep:(0,v.frac)(o.frameStep),duration:(0,v.frac)(o.duration),frameCount:o.frameCount,transform:o.Trnf,width:o["Sz "].Wdth,height:o["Sz "].Hght,resolution:(0,v.parseUnits)(o.Rslt),warp:ld(o.quiltWarp||o.warp)},o.nonAffineTransform&&o.nonAffineTransform.some((r,s)=>r!==o.Trnf[s])&&(n.placedLayer.nonAffineTransform=o.nonAffineTransform),o.Crop&&(n.placedLayer.crop=o.Crop),o.comp&&(n.placedLayer.comp=o.comp),o.compInfo&&(n.placedLayer.compInfo={compID:o.compInfo.compID,originalCompID:o.compInfo.originalCompID}),o.filterFX&&(n.placedLayer.filter=em(o.filterFX,e)),o.Impr&&(n.placedLayer.imported=!0),(0,b.skipBytes)(e,t())},(e,n)=>{var t,i;(0,w.writeSignature)(e,"soLD"),(0,w.writeInt32)(e,4);let o=n.placedLayer;if(!o.id||typeof o.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(o.id))throw new Error("Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");let r=Nn.indexOf(o.type);if(r===-1)throw new Error("Invalid placedLayer type");let s=fd(o),a=s.bounds,l=o.width||(a?a.right.value-a.left.value:0),c=o.height||(a?a.bottom.value-a.top.value:0),f=Object.assign(Object.assign({Idnt:o.id,placed:(t=o.placed)!==null&&t!==void 0?t:o.id,PgNm:o.pageNumber||1,totalPages:o.totalPages||1},o.crop?{Crop:o.crop}:{}),{frameStep:o.frameStep||{numerator:0,denominator:600},duration:o.duration||{numerator:0,denominator:600},frameCount:o.frameCount||0,Annt:16,Type:r,Trnf:o.transform,nonAffineTransform:(i=o.nonAffineTransform)!==null&&i!==void 0?i:o.transform,warp:Po(s),"Sz ":{_name:"",_classID:"Pnt ",Wdth:l,Hght:c},Rslt:o.resolution?(0,v.unitsValue)(o.resolution,"resolution"):{units:"Density",value:72}});if(o.filter&&(f.filterFX={_name:"",_classID:"filterFXStyle",enab:o.filter.enabled,validAtPosition:o.filter.validAtPosition,filterMaskEnable:o.filter.maskEnabled,filterMaskLinked:o.filter.maskLinked,filterMaskExtendWithWhite:o.filter.maskExtendWithWhite,filterFXList:o.filter.list.map(u=>tm(u))}),o.warp&&Bs(o.warp)){let u=Po(o.warp);f.quiltWarp=u,f.warp={warpStyle:"warpStyle.warpNone",warpValue:u.warpValue,warpPerspective:u.warpPerspective,warpPerspectiveOther:u.warpPerspectiveOther,warpRotate:u.warpRotate,bounds:u.bounds,uOrder:u.uOrder,vOrder:u.vOrder}}else delete f.quiltWarp;o.comp&&(f.comp=o.comp),o.compInfo&&(f.compInfo=o.compInfo),o.imported&&(f.Impr={}),(0,v.writeVersionAndDescriptor)(e,"","null",f,f.quiltWarp?"quiltWarp":"warp")});var Hf=Ae.infoHandlersMap.SoLd;U("SoLE",e=>{var n;return!!(!((n=e.placedLayer)===null||n===void 0)&&n.external)},(e,n,t,i,o)=>{Hf.read(e,n,t,i,o),n.placedLayer.external=!0},Hf.write);U("fxrp",le("referencePoint"),(e,n)=>{n.referencePoint={x:(0,b.readFloat64)(e),y:(0,b.readFloat64)(e)}},(e,n)=>{(0,w.writeFloat64)(e,n.referencePoint.x),(0,w.writeFloat64)(e,n.referencePoint.y)});function Rs(e,n){U(e,()=>!1,(t,i,o,r,s)=>{var a;if(!t.layersInGlobalInfo&&(r.bitsPerChannel===n||!(!((a=r.children)===null||a===void 0)&&a.length))){let l=r.children;r.children=[];try{(0,b.readLayerInfo)(t,r,s)}catch(c){throw r.children=l,c}t.layersInGlobalInfo=!0}(0,b.skipBytes)(t,o())},()=>{})}Rs("Lr16",16);Rs("Lr32",32);Rs("Layr",void 0);for(let e of["Mtrn","Mt16","Mt32"])U(e,()=>!1,(n,t,i)=>{n.globalAlpha=!0,(0,b.skipBytes)(n,i())},()=>{});U("LMsk",le("userMask"),(e,n)=>{if(n.userMask={colorSpace:(0,b.readColor)(e),opacity:(0,b.readUint16)(e)/100},(0,b.readUint8)(e)!==128)throw new Error("Invalid flag value");(0,b.skipBytes)(e,1)},(e,n)=>{let t=n.userMask;(0,w.writeColor)(e,t.colorSpace),(0,w.writeUint16)(e,Math.round((0,De.clamp)(t.opacity,0,1)*100)),(0,w.writeUint8)(e,128),(0,w.writeZeros)(e,1)});U("Patt",e=>!!(e.patterns&&e.patterns.length>0),(e,n,t)=>{for(;t()>0;){let i=(0,b.readPatternSafe)(e);i&&(n.patterns===void 0&&(n.patterns=[]),n.patterns.push(i))}},(e,n,t,i)=>{let o=n.patterns||[];for(let r of o)(0,w.writePattern)(e,r)});lt("Pat2","Patt");lt("Pat3","Patt");De.MOCK_HANDLERS&&U("CAI ",e=>e._CAI_!==void 0,(e,n,t)=>{n._CAI_=(0,b.readBytes)(e,t())},(e,n)=>{(0,w.writeBytes)(e,n._CAI_)});De.MOCK_HANDLERS&&U("OCIO",e=>e._OCIO!==void 0,(e,n,t)=>{n._OCIO=(0,b.readBytes)(e,t())},(e,n)=>{(0,w.writeBytes)(e,n._OCIO)});De.MOCK_HANDLERS&&U("GenI",e=>e._GenI!==void 0,(e,n,t)=>{n._GenI=(0,b.readBytes)(e,t())},(e,n)=>{(0,w.writeBytes)(e,n._GenI)});function Wf(e){let n=(0,b.readInt32)(e),t=(0,b.readInt32)(e),i=(0,b.readInt32)(e),o=(0,b.readInt32)(e);return{top:n,left:t,bottom:i,right:o}}function Xf(e,n){(0,w.writeInt32)(e,n.top),(0,w.writeInt32)(e,n.left),(0,w.writeInt32)(e,n.bottom),(0,w.writeInt32)(e,n.right)}U("Anno",e=>e.annotations!==void 0,(e,n,t)=>{let i=(0,b.readUint16)(e),o=(0,b.readUint16)(e);if(i!==2||o!==1)throw new Error("Invalid Anno version");let r=(0,b.readUint32)(e),s=[];for(let a=0;a<r;a++){let l=e.offset,c=(0,b.readUint32)(e),f=(0,b.readSignature)(e),u=!!(0,b.readUint8)(e);(0,b.readUint8)(e),(0,b.readUint16)(e);let d=Wf(e),p=Wf(e),h=(0,b.readColor)(e),m=(0,b.readPascalString)(e,2),y=(0,b.readPascalString)(e,2),g=(0,b.readPascalString)(e,2);(0,b.readUint32)(e),(0,b.readSignature)(e);let k=(0,b.readUint32)(e),x;if(f==="txtA"){let S=e.offset;k>=2&&(0,b.readUint16)(e)===65279?x=(0,b.readUnicodeStringWithLength)(e,Math.floor((k-2)/2)):(e.offset=S,x=(0,b.readAsciiString)(e,k)),x=x.replace(/\r/g,`
12
+ `)}else if(f==="sndA")x=(0,b.readBytes)(e,k);else throw new Error("Unknown annotation type");s.push({type:f==="txtA"?"text":"sound",open:u,iconLocation:d,popupLocation:p,color:h,author:m,name:y,date:g,data:x}),c>=e.offset-l&&(e.offset=l+c)}n.annotations=s,(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.annotations;(0,w.writeUint16)(e,2),(0,w.writeUint16)(e,1),(0,w.writeUint32)(e,t.length);for(let i of t){let o=i.type==="sound";if(o&&!(i.data instanceof Uint8Array))throw new Error("Sound annotation data should be Uint8Array");if(!o&&typeof i.data!="string")throw new Error("Text annotation data should be string");let r=e.offset;(0,w.writeUint32)(e,0),(0,w.writeSignature)(e,o?"sndA":"txtA"),(0,w.writeUint8)(e,i.open?1:0),(0,w.writeUint8)(e,28),(0,w.writeUint16)(e,1),Xf(e,i.iconLocation),Xf(e,i.popupLocation),(0,w.writeColor)(e,i.color),(0,w.writePascalString)(e,i.author||"",2),(0,w.writePascalString)(e,i.name||"",2),(0,w.writePascalString)(e,i.date||"",2);let s=e.offset;(0,w.writeUint32)(e,0),(0,w.writeSignature)(e,o?"sndM":"txtC"),(0,w.writeUint32)(e,0);let a=e.offset;if(o)(0,w.writeBytes)(e,i.data);else{(0,w.writeUint16)(e,65279);let l=i.data.replace(/\n/g,"\r");for(let c=0;c<l.length;c++)(0,w.writeUint16)(e,l.charCodeAt(c))}e.view.setUint32(r,e.offset-r,!1),e.view.setUint32(s,e.offset-s,!1),e.view.setUint32(a-4,e.offset-a,!1)}});function qf(e){let n=(0,b.readSignature)(e);return/^[\0 ]*$/.test(n)?"":n.trim()}function dd(e){U(e,n=>{let t=n;return!(!t.linkedFiles||!t.linkedFiles.length||e==="lnkE"&&!t.linkedFiles.some(i=>i.linkedFile))},(n,t,i,o)=>{let r=t;for(r.linkedFiles=r.linkedFiles||[];i()>8;){let s=Io(n),a=n.offset,l=(0,b.readSignature)(n),c=(0,b.readInt32)(n),f=(0,b.readPascalString)(n,1),u=(0,b.readUnicodeString)(n),d=qf(n),p=qf(n),h=Io(n),y=(0,b.readUint8)(n)?(0,v.readVersionAndDescriptor)(n):void 0,g=l==="liFE"?(0,v.readVersionAndDescriptor)(n):void 0,k={id:f,name:u};if(d&&(k.type=d),p&&(k.creator=p),y&&(k.descriptor={compInfo:{compID:y.compInfo.compID,originalCompID:y.compInfo.originalCompID}}),l==="liFE"&&c>3){let S=(0,b.readInt32)(n),A=(0,b.readUint8)(n),D=(0,b.readUint8)(n),C=(0,b.readUint8)(n),O=(0,b.readUint8)(n),E=(0,b.readFloat64)(n),L=Math.floor(E),M=(E-L)*1e3;try{k.time=new Date(Date.UTC(S,A,D,C,O,L,M)).toISOString()}catch{k.time=new Date(0).toISOString()}}let x=l==="liFE"?Io(n):0;if(l==="liFD"&&h>i())throw new Error("Invalid linked file data size");if(l==="liFA"&&(0,b.skipBytes)(n,8),l==="liFD"&&(k.data=(0,b.readBytes)(n,h)),c>=5&&(k.childDocumentID=(0,b.readUnicodeString)(n)),c>=6&&(k.assetModTime=(0,b.readFloat64)(n)),c>=7&&(k.assetLockedState=(0,b.readUint8)(n)),l==="liFE"&&c===2){if(x>i())throw new Error("Invalid linked file size");k.data=(0,b.readBytes)(n,x)}for(n.skipLinkedFilesData&&(k.data=void 0),e==="lnkE"&&(k.linkedFile={fileSize:x,name:g?.["Nm "]||"",fullPath:g?.fullPath||"",originalPath:g?.originalPath||"",relativePath:g?.relPath||""},g?.alis!==void 0&&(k.linkedFile.alias=g.alis)),r.linkedFiles.push(k);s%4;)s++;n.offset=a+s}(0,b.skipBytes)(n,i())},(n,t)=>{var i,o,r,s,a,l,c,f,u,d,p;let h=t;for(let m of h.linkedFiles){if(e==="lnkE"!=!!m.linkedFile)continue;let y=e==="lnkE",g=2;m.assetLockedState!=null?g=7:m.assetModTime!=null?g=6:m.childDocumentID!=null?g=5:y&&!m.data&&(g=4),(0,w.writeUint64)(n,0);let k=n.offset;if((0,w.writeSignature)(n,y?"liFE":m.data?"liFD":"liFA"),(0,w.writeInt32)(n,g),!m.id||typeof m.id!="string"||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(m.id))throw new Error("Linked file ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)");if((0,w.writePascalString)(n,m.id,1),(0,w.writeUnicodeStringWithPadding)(n,m.name||""),(0,w.writeSignature)(n,m.type?`${m.type} `.substring(0,4):" "),(0,w.writeSignature)(n,m.creator?`${m.creator} `.substring(0,4):"\0\0\0\0"),(0,w.writeUint64)(n,!y&&m.data?m.data.byteLength:0),m.descriptor&&m.descriptor.compInfo){let S={compInfo:{compID:m.descriptor.compInfo.compID,originalCompID:m.descriptor.compInfo.originalCompID}};(0,w.writeUint8)(n,1),(0,v.writeVersionAndDescriptor)(n,"","null",S)}else(0,w.writeUint8)(n,0);if(y){let S=Object.assign(Object.assign({descVersion:2,"Nm ":(o=(i=m.linkedFile)===null||i===void 0?void 0:i.name)!==null&&o!==void 0?o:"",fullPath:(s=(r=m.linkedFile)===null||r===void 0?void 0:r.fullPath)!==null&&s!==void 0?s:""},((a=m.linkedFile)===null||a===void 0?void 0:a.alias)!==void 0?{alis:m.linkedFile.alias}:{}),{originalPath:(c=(l=m.linkedFile)===null||l===void 0?void 0:l.originalPath)!==null&&c!==void 0?c:"",relPath:(u=(f=m.linkedFile)===null||f===void 0?void 0:f.relativePath)!==null&&u!==void 0?u:""});(0,v.writeVersionAndDescriptor)(n,"","ExternalFileLink",S)}if(y&&g>3){let S=m.time?new Date(m.time):new Date;(0,w.writeInt32)(n,S.getUTCFullYear()),(0,w.writeUint8)(n,S.getUTCMonth()),(0,w.writeUint8)(n,S.getUTCDate()),(0,w.writeUint8)(n,S.getUTCHours()),(0,w.writeUint8)(n,S.getUTCMinutes()),(0,w.writeFloat64)(n,S.getUTCSeconds()+S.getUTCMilliseconds()/1e3)}y?(0,w.writeUint64)(n,(g===2?(d=m.data)===null||d===void 0?void 0:d.byteLength:(p=m.linkedFile)===null||p===void 0?void 0:p.fileSize)||0):m.data?(0,w.writeBytes)(n,m.data):(0,w.writeZeros)(n,8),g>=5&&(0,w.writeUnicodeStringWithPadding)(n,m.childDocumentID||""),g>=6&&(0,w.writeFloat64)(n,m.assetModTime||0),g>=7&&(0,w.writeUint8)(n,m.assetLockedState||0),y&&g===2&&m.data&&(0,w.writeBytes)(n,m.data);let x=n.offset-k;for(n.view.setUint32(k-4,x,!1);x%4;)x++,(0,w.writeUint8)(n,0)}})}dd("lnk2");dd("lnkE");lt("lnkD","lnk2");lt("lnk3","lnk2");U("pths",e=>{var n;return((n=e.imageResources)===null||n===void 0?void 0:n.savedPaths)!==void 0},(e,n,t,i)=>{var o,r;if(!t())return;if(e.imageResourcesWhitelistSet&&!e.imageResourcesWhitelistSet.has("savedPaths")){(0,b.skipBytes)(e,t());return}let s=(0,v.readVersionAndDescriptor)(e,!0),a=(o=i.imageResources)!==null&&o!==void 0?o:i.imageResources={},l=(r=a.savedPaths)!==null&&r!==void 0?r:a.savedPaths=[];for(let c=0;c<s.pathList.length&&c<l.length;c++){let{pathUnicodeName:f,pathSymmetryClass:u}=s.pathList[c],d=l[c];a.clippingPath&&a.clippingPath.name===d.name&&(a.clippingPath.name=f),d.name=f,u&&(d.symmetryMode=u.pathSymmetryMode.split(".")[1])}(0,b.skipBytes)(e,t())},(e,n,t)=>{let i={pathList:t.imageResources.savedPaths.map(o=>Object.assign({_name:"",_classID:"pathInfoClass",pathUnicodeName:o.name},o.symmetryMode?{pathSymmetryClass:{_name:"",_classID:"pathSymmetryClass",pathSymmetryMode:`pathSymmetryModeEnum.${o.symmetryMode}`}}:{}))};(0,v.writeVersionAndDescriptor)(e,"","pathsDataClass",i)});U("lyvr",le("version"),(e,n)=>n.version=(0,b.readUint32)(e),(e,n)=>(0,w.writeUint32)(e,n.version));U("lfxs",e=>e.effects!==void 0&&Ts(e),(e,n,t)=>{if((0,b.readUint32)(e)!==0)throw new Error("Invalid lfxs version");let o=(0,v.readVersionAndDescriptor)(e);n.effects=(0,v.parseEffects)(o,e),(0,b.skipBytes)(e,t())},(e,n)=>{let t=(0,v.serializeEffects)(n.effects,e,!0);(0,w.writeUint32)(e,0),(0,v.writeVersionAndDescriptor)(e,"","null",t)});function Ee(e){return n=>!!n.adjustment&&n.adjustment.type===e}U("brit",Ee("brightness/contrast"),(e,n,t)=>{n.adjustment||(n.adjustment={type:"brightness/contrast",brightness:(0,b.readInt16)(e),contrast:(0,b.readInt16)(e),meanValue:(0,b.readInt16)(e),labColorOnly:!!(0,b.readUint8)(e),useLegacy:!0}),(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.adjustment;(0,w.writeInt16)(e,i.brightness||0),(0,w.writeInt16)(e,i.contrast||0),(0,w.writeInt16)(e,(t=i.meanValue)!==null&&t!==void 0?t:127),(0,w.writeUint8)(e,i.labColorOnly?1:0),(0,w.writeZeros)(e,1)});function Zf(e){let n=(0,b.readInt16)(e),t=(0,b.readInt16)(e),i=(0,b.readInt16)(e),o=(0,b.readInt16)(e),r=(0,b.readInt16)(e)/100;return{shadowInput:n,highlightInput:t,shadowOutput:i,highlightOutput:o,midtoneInput:r}}var Kf={shadowInput:0,highlightInput:255,shadowOutput:0,highlightOutput:255,midtoneInput:1};function nm(e){return e.shadowInput===0&&e.highlightInput===255&&e.shadowOutput===0&&e.highlightOutput===255&&e.midtoneInput===1}function Yf(e,n){(0,w.writeInt16)(e,n.shadowInput),(0,w.writeInt16)(e,n.highlightInput),(0,w.writeInt16)(e,n.shadowOutput),(0,w.writeInt16)(e,n.highlightOutput),(0,w.writeInt16)(e,Math.round(n.midtoneInput*100))}U("levl",Ee("levels"),(e,n,t)=>{if((0,b.readUint16)(e)!==2)throw new Error("Invalid levl version");let i=[];for(let o=0;o<29&&t()>=10;o++)i.push(Zf(e));if(t()>=8){let o=(0,b.readSignature)(e),r;if(o==="ls\0")r=(0,b.readUint16)(e);else{if(o!=="Lvls")throw new Error("Invalid levl signature");if((0,b.readUint16)(e)!==3)throw new Error("Invalid levl version");r=(0,b.readUint16)(e)}for(;i.length<r&&t()>=10;)i.push(Zf(e))}for(;i.length&&nm(i[i.length-1]);)i.pop();n.adjustment=Object.assign(Object.assign({},n.adjustment),{type:"levels",channels:i}),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment.channels||[];(0,w.writeUint16)(e,2);for(let i=0;i<29;i++)Yf(e,t[i]||Kf);(0,w.writeSignature)(e,"Lvls"),(0,w.writeUint16)(e,3),(0,w.writeUint16)(e,62);for(let i=29;i<62;i++)Yf(e,t[i]||Kf)});function im(e){let n=(0,b.readUint16)(e),t=[];for(let i=0;i<n;i++){let o=(0,b.readInt16)(e),r=(0,b.readInt16)(e);t.push({input:r,output:o})}return t}function om(e,n){(0,w.writeUint16)(e,n.length);for(let t of n)(0,w.writeUint16)(e,t.output),(0,w.writeUint16)(e,t.input)}U("curv",Ee("curves"),(e,n,t)=>{let i=!!(0,b.readUint8)(e),o=(0,b.readUint16)(e);if(o!==1&&o!==4)throw new Error("Invalid curv version");let r=(0,b.readUint32)(e),s=[],a=()=>i?Array.from((0,b.readBytes)(e,256)):im(e);if(o===1){for(let l=0;l<32;l++)if(r&1<<l){for(;s.length<l;)s.push([]);s.push(a())}}else{if(r>64)throw new Error("Invalid curv channel count");for(let l=0;l<r;l++)s.push(a())}if(o===1&&t()>=10&&(0,b.readSignature)(e)==="Crv "){(0,b.readUint16)(e);let l=(0,b.readUint32)(e);for(let c=0;c<l&&t()>=2;c++){let f=(0,b.readUint16)(e),u=a();for(;s.length<f;)s.push([]);s[f]=u}}n.adjustment=Object.assign(Object.assign(Object.assign({},n.adjustment),{type:"curves"}),i?{values:s}:{channels:s}),(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.adjustment,o=!!i.values,r=(o?i.values:i.channels)||[],s=[],a=0;for(let c=0;c<r.length;c++)!((t=r[c])===null||t===void 0)&&t.length&&(c<32&&(a|=1<<c),s.push(c));let l=c=>{var f;if(o)for(let u=0;u<256;u++)(0,w.writeUint8)(e,(0,De.clamp)(Math.round((f=c[u])!==null&&f!==void 0?f:u),0,255));else om(e,c)};(0,w.writeUint8)(e,o?1:0),(0,w.writeUint16)(e,1),(0,w.writeUint32)(e,a>>>0);for(let c of s)c<32&&l(r[c]);(0,w.writeSignature)(e,"Crv "),(0,w.writeUint16)(e,4),(0,w.writeUint32)(e,s.length);for(let c of s)(0,w.writeUint16)(e,c),l(r[c])});U("expA",Ee("exposure"),(e,n,t)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid expA version");n.adjustment=Object.assign(Object.assign({},n.adjustment),{type:"exposure",exposure:(0,b.readFloat32)(e),offset:(0,b.readFloat32)(e),gamma:(0,b.readFloat32)(e)}),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment;(0,w.writeUint16)(e,1),(0,w.writeFloat32)(e,t.exposure),(0,w.writeFloat32)(e,t.offset),(0,w.writeFloat32)(e,t.gamma),(0,w.writeZeros)(e,2)});U("vibA",Ee("vibrance"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.adjustment={type:"vibrance"},i.vibrance!==void 0&&(n.adjustment.vibrance=i.vibrance),i.Strt!==void 0&&(n.adjustment.saturation=i.Strt),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment,i={};t.vibrance!==void 0&&(i.vibrance=t.vibrance),t.saturation!==void 0&&(i.Strt=t.saturation),(0,v.writeVersionAndDescriptor)(e,"","null",i)});function $n(e){return{a:(0,b.readInt16)(e),b:(0,b.readInt16)(e),c:(0,b.readInt16)(e),d:(0,b.readInt16)(e),hue:(0,b.readInt16)(e),saturation:(0,b.readInt16)(e),lightness:(0,b.readInt16)(e)}}function Vn(e,n){let t=n||{};(0,w.writeInt16)(e,t.a||0),(0,w.writeInt16)(e,t.b||0),(0,w.writeInt16)(e,t.c||0),(0,w.writeInt16)(e,t.d||0),(0,w.writeInt16)(e,t.hue||0),(0,w.writeInt16)(e,t.saturation||0),(0,w.writeInt16)(e,t.lightness||0)}U("hue2",Ee("hue/saturation"),(e,n,t)=>{if((0,b.readUint16)(e)!==2)throw new Error("Invalid hue2 version");let i=!!(0,b.readUint8)(e);(0,b.skipBytes)(e,1);let o=(0,b.readInt16)(e),r=(0,b.readInt16)(e),s=(0,b.readInt16)(e);n.adjustment=Object.assign(Object.assign({},n.adjustment),{type:"hue/saturation",colorize:i,colorization:{hue:o<0?o+360:o,saturation:r,lightness:s},master:{hue:(0,b.readInt16)(e),saturation:(0,b.readInt16)(e),lightness:(0,b.readInt16)(e)},reds:$n(e),yellows:$n(e),greens:$n(e),cyans:$n(e),blues:$n(e),magentas:$n(e)}),(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o,r,s,a,l,c,f,u,d,p;let h=n.adjustment;(0,w.writeUint16)(e,2),(0,w.writeUint8)(e,h.colorize?1:0),(0,w.writeUint8)(e,0);let m=Math.round((i=(t=h.colorization)===null||t===void 0?void 0:t.hue)!==null&&i!==void 0?i:0);(0,w.writeInt16)(e,m>180?m-360:m),(0,w.writeInt16)(e,Math.round((r=(o=h.colorization)===null||o===void 0?void 0:o.saturation)!==null&&r!==void 0?r:0)),(0,w.writeInt16)(e,Math.round((a=(s=h.colorization)===null||s===void 0?void 0:s.lightness)!==null&&a!==void 0?a:0)),(0,w.writeInt16)(e,Math.round((c=(l=h.master)===null||l===void 0?void 0:l.hue)!==null&&c!==void 0?c:0)),(0,w.writeInt16)(e,Math.round((u=(f=h.master)===null||f===void 0?void 0:f.saturation)!==null&&u!==void 0?u:0)),(0,w.writeInt16)(e,Math.round((p=(d=h.master)===null||d===void 0?void 0:d.lightness)!==null&&p!==void 0?p:0)),Vn(e,h.reds),Vn(e,h.yellows),Vn(e,h.greens),Vn(e,h.cyans),Vn(e,h.blues),Vn(e,h.magentas)});function Ds(e){return{cyanRed:(0,b.readInt16)(e),magentaGreen:(0,b.readInt16)(e),yellowBlue:(0,b.readInt16)(e)}}function Os(e,n){(0,w.writeInt16)(e,n.cyanRed||0),(0,w.writeInt16)(e,n.magentaGreen||0),(0,w.writeInt16)(e,n.yellowBlue||0)}U("blnc",Ee("color balance"),(e,n,t)=>{n.adjustment={type:"color balance",shadows:Ds(e),midtones:Ds(e),highlights:Ds(e),preserveLuminosity:!!(0,b.readUint8)(e)},(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment;Os(e,t.shadows||{}),Os(e,t.midtones||{}),Os(e,t.highlights||{}),(0,w.writeUint8)(e,t.preserveLuminosity?1:0),(0,w.writeZeros)(e,1)});U("blwh",Ee("black & white"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);n.adjustment={type:"black & white",reds:i["Rd "],yellows:i.Yllw,greens:i["Grn "],cyans:i["Cyn "],blues:i["Bl "],magentas:i.Mgnt,useTint:!!i.useTint,presetKind:i.bwPresetKind,presetFileName:i.blackAndWhitePresetFileName},i.tintColor!==void 0&&(n.adjustment.tintColor=(0,v.parseColor)(i.tintColor)),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment,i={"Rd ":t.reds||0,Yllw:t.yellows||0,"Grn ":t.greens||0,"Cyn ":t.cyans||0,"Bl ":t.blues||0,Mgnt:t.magentas||0,useTint:!!t.useTint,tintColor:(0,v.serializeColor)(t.tintColor),bwPresetKind:t.presetKind||0,blackAndWhitePresetFileName:t.presetFileName||""};(0,v.writeVersionAndDescriptor)(e,"","null",i)});U("phfl",Ee("photo filter"),(e,n,t)=>{let i=(0,b.readUint16)(e);if(i!==2&&i!==3)throw new Error("Invalid phfl version");let o;if(i===2)o=(0,b.readColor)(e);else{let r=(0,b.readInt32)(e)/32768,s=(0,b.readInt32)(e)/32768,a=(0,b.readInt32)(e)/32768;if(!(r>=0&&s>=0&&a>=0&&r<=2&&s<=2&&a<=2))throw new Error("Invalid phfl XYZ color");let l=c=>c>216/24389?Math.cbrt(c):(24389/27*c+16)/116;o={l:Math.max(0,116*l(s)-16)/100,a:(0,De.normalizeLabAB)(500*(l(r)-l(s))),b:(0,De.normalizeLabAB)(200*(l(s)-l(a)))}}n.adjustment={type:"photo filter",color:o,density:(0,b.readUint32)(e)/100,preserveLuminosity:!!(0,b.readUint8)(e)},(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment;(0,w.writeUint16)(e,2),(0,w.writeColor)(e,t.color||{l:0,a:0,b:0}),(0,w.writeUint32)(e,Math.round(Math.max(0,t.density||0)*100)),(0,w.writeUint8)(e,t.preserveLuminosity?1:0),(0,w.writeZeros)(e,3)});function _o(e){let n=(0,b.readInt16)(e),t=(0,b.readInt16)(e),i=(0,b.readInt16)(e);(0,b.skipBytes)(e,2);let o=(0,b.readInt16)(e);return{red:n,green:t,blue:i,constant:o}}function Ai(e,n){let t=n||{};(0,w.writeInt16)(e,t.red),(0,w.writeInt16)(e,t.green),(0,w.writeInt16)(e,t.blue),(0,w.writeZeros)(e,2),(0,w.writeInt16)(e,t.constant)}U("mixr",Ee("channel mixer"),(e,n,t)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid mixr version");let i=n.adjustment=Object.assign(Object.assign({},n.adjustment),{type:"channel mixer",monochrome:!!(0,b.readUint16)(e)});i.monochrome||(i.red=_o(e),i.green=_o(e),i.blue=_o(e)),i.gray=_o(e),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment;(0,w.writeUint16)(e,1),(0,w.writeUint16)(e,t.monochrome?1:0),t.monochrome?(Ai(e,t.gray),(0,w.writeZeros)(e,30)):(Ai(e,t.red),Ai(e,t.green),Ai(e,t.blue),Ai(e,t.gray))});var Jf=(0,De.createEnum)("colorLookupType","3dlut",{"3dlut":"3DLUT",abstractProfile:"abstractProfile",deviceLinkProfile:"deviceLinkProfile"}),Qf=(0,De.createEnum)("LUTFormatType","look",{look:"LUTFormatLOOK",cube:"LUTFormatCUBE","3dl":"LUTFormat3DL"}),Ao=(0,De.createEnum)("colorLookupOrder","rgb",{rgb:"rgbOrder",bgr:"bgrOrder"});U("clrL",Ee("color lookup"),(e,n,t)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid clrL version");let i=(0,v.readVersionAndDescriptor)(e);n.adjustment={type:"color lookup"};let o=n.adjustment;i.lookupType!==void 0&&(o.lookupType=Jf.decode(i.lookupType)),i["Nm "]!==void 0&&(o.name=i["Nm "]),i.Dthr!==void 0&&(o.dither=i.Dthr),i.profile!==void 0&&(o.profile=i.profile),i.LUTFormat!==void 0&&(o.lutFormat=Qf.decode(i.LUTFormat)),i.dataOrder!==void 0&&(o.dataOrder=Ao.decode(i.dataOrder)),i.tableOrder!==void 0&&(o.tableOrder=Ao.decode(i.tableOrder)),i.LUT3DFileData!==void 0&&(o.lut3DFileData=i.LUT3DFileData),i.LUT3DFileName!==void 0&&(o.lut3DFileName=i.LUT3DFileName),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.adjustment,i={};t.lookupType!==void 0&&(i.lookupType=Jf.encode(t.lookupType)),t.name!==void 0&&(i["Nm "]=t.name),t.dither!==void 0&&(i.Dthr=t.dither),t.profile!==void 0&&(i.profile=t.profile),t.lutFormat!==void 0&&(i.LUTFormat=Qf.encode(t.lutFormat)),t.dataOrder!==void 0&&(i.dataOrder=Ao.encode(t.dataOrder)),t.tableOrder!==void 0&&(i.tableOrder=Ao.encode(t.tableOrder)),t.lut3DFileData!==void 0&&(i.LUT3DFileData=t.lut3DFileData),t.lut3DFileName!==void 0&&(i.LUT3DFileName=t.lut3DFileName),(0,w.writeUint16)(e,1),(0,v.writeVersionAndDescriptor)(e,"","null",i)});U("nvrt",Ee("invert"),(e,n,t)=>{n.adjustment={type:"invert"},(0,b.skipBytes)(e,t())},()=>{});U("post",Ee("posterize"),(e,n,t)=>{n.adjustment={type:"posterize",levels:(0,b.readUint16)(e)},(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.adjustment;(0,w.writeUint16)(e,(t=i.levels)!==null&&t!==void 0?t:4),(0,w.writeZeros)(e,2)});U("thrs",Ee("threshold"),(e,n,t)=>{n.adjustment={type:"threshold",level:(0,b.readUint16)(e)},(0,b.skipBytes)(e,t())},(e,n)=>{var t;let i=n.adjustment;(0,w.writeUint16)(e,(t=i.level)!==null&&t!==void 0?t:128),(0,w.writeZeros)(e,2)});var ed=["","","","rgb","hsb","","lab"];U("grdm",Ee("gradient map"),(e,n,t)=>{let i=(0,b.readUint16)(e);if(i!==1&&i!==3)throw new Error("Invalid grdm version");let o={type:"gradient map",gradientType:"solid"};o.reverse=!!(0,b.readUint8)(e),o.dither=!!(0,b.readUint8)(e);let r=!!(0,b.readUint8)(e);if(e.offset--,r){let u=(0,b.readSignature)(e);o.method=v.gradientInterpolationMethodType.decode(`gradientInterpolationMethodType.${u}`)}o.name=(0,b.readUnicodeString)(e),o.colorStops=[],o.opacityStops=[];let s=(0,b.readUint16)(e);for(let u=0;u<s;u++)o.colorStops.push({location:(0,b.readUint32)(e),midpoint:(0,b.readUint32)(e)/100,color:(0,b.readColor)(e)}),(0,b.skipBytes)(e,2);let a=(0,b.readUint16)(e);for(let u=0;u<a;u++)o.opacityStops.push({location:(0,b.readUint32)(e),midpoint:(0,b.readUint32)(e)/100,opacity:(0,b.readUint16)(e)/255});if((0,b.readUint16)(e)!==2)throw new Error("Invalid grdm expansion count");let c=(0,b.readUint16)(e);if(o.smoothness=c/4096,(0,b.readUint16)(e)!==32)throw new Error("Invalid grdm length");o.gradientType=(0,b.readUint16)(e)?"noise":"solid",o.randomSeed=(0,b.readUint32)(e),o.addTransparency=!!(0,b.readUint16)(e),o.restrictColors=!!(0,b.readUint16)(e),o.roughness=(0,b.readUint32)(e)/4096,o.colorModel=ed[(0,b.readUint16)(e)]||"rgb",o.min=[(0,b.readUint16)(e)/32768,(0,b.readUint16)(e)/32768,(0,b.readUint16)(e)/32768,(0,b.readUint16)(e)/32768],o.max=[(0,b.readUint16)(e)/32768,(0,b.readUint16)(e)/32768,(0,b.readUint16)(e)/32768,(0,b.readUint16)(e)/32768],(0,b.skipBytes)(e,t());for(let u of o.colorStops)u.location/=4096;for(let u of o.opacityStops)u.location/=4096;n.adjustment=o},(e,n)=>{var t,i,o;let r=n.adjustment;(0,w.writeUint16)(e,r.method!==void 0?3:1),(0,w.writeUint8)(e,r.reverse?1:0),(0,w.writeUint8)(e,r.dither?1:0),r.method!==void 0&&(0,w.writeSignature)(e,v.gradientInterpolationMethodType.encode(r.method).split(".")[1]),(0,w.writeUnicodeStringWithPadding)(e,r.name||""),(0,w.writeUint16)(e,r.colorStops&&r.colorStops.length||0);let s=Math.round((0,De.clamp)((t=r.smoothness)!==null&&t!==void 0?t:1,0,1)*4096);for(let l of r.colorStops||[])(0,w.writeUint32)(e,Math.round((0,De.clamp)(l.location,0,1)*4096)),(0,w.writeUint32)(e,Math.round(l.midpoint*100)),(0,w.writeColor)(e,l.color),(0,w.writeZeros)(e,2);(0,w.writeUint16)(e,r.opacityStops&&r.opacityStops.length||0);for(let l of r.opacityStops||[])(0,w.writeUint32)(e,Math.round((0,De.clamp)(l.location,0,1)*4096)),(0,w.writeUint32)(e,Math.round(l.midpoint*100)),(0,w.writeUint16)(e,Math.round((0,De.clamp)(l.opacity,0,1)*255));(0,w.writeUint16)(e,2),(0,w.writeUint16)(e,s),(0,w.writeUint16)(e,32),(0,w.writeUint16)(e,r.gradientType==="noise"?1:0),(0,w.writeUint32)(e,r.randomSeed||0),(0,w.writeUint16)(e,r.addTransparency?1:0),(0,w.writeUint16)(e,r.restrictColors?1:0),(0,w.writeUint32)(e,Math.round(((i=r.roughness)!==null&&i!==void 0?i:1)*4096));let a=ed.indexOf((o=r.colorModel)!==null&&o!==void 0?o:"rgb");(0,w.writeUint16)(e,a===-1?3:a);for(let l=0;l<4;l++)(0,w.writeUint16)(e,Math.round((r.min&&r.min[l]||0)*32768));for(let l=0;l<4;l++)(0,w.writeUint16)(e,Math.round((r.max&&r.max[l]||0)*32768));(0,w.writeZeros)(e,4)});function Lt(e){return{c:(0,b.readInt16)(e),m:(0,b.readInt16)(e),y:(0,b.readInt16)(e),k:(0,b.readInt16)(e)}}function Mt(e,n){let t=n||{};(0,w.writeInt16)(e,t.c),(0,w.writeInt16)(e,t.m),(0,w.writeInt16)(e,t.y),(0,w.writeInt16)(e,t.k)}U("selc",Ee("selective color"),(e,n)=>{if((0,b.readUint16)(e)!==1)throw new Error("Invalid selc version");let t=(0,b.readUint16)(e)?"absolute":"relative";(0,b.skipBytes)(e,8),n.adjustment={type:"selective color",mode:t,reds:Lt(e),yellows:Lt(e),greens:Lt(e),cyans:Lt(e),blues:Lt(e),magentas:Lt(e),whites:Lt(e),neutrals:Lt(e),blacks:Lt(e)}},(e,n)=>{let t=n.adjustment;(0,w.writeUint16)(e,1),(0,w.writeUint16)(e,t.mode==="absolute"?1:0),(0,w.writeZeros)(e,8),Mt(e,t.reds),Mt(e,t.yellows),Mt(e,t.greens),Mt(e,t.cyans),Mt(e,t.blues),Mt(e,t.magentas),Mt(e,t.whites),Mt(e,t.neutrals),Mt(e,t.blacks)});U("CgEd",e=>{let n=e.adjustment;return n?n.type==="brightness/contrast"&&!n.useLegacy||(n.type==="levels"||n.type==="curves"||n.type==="exposure"||n.type==="channel mixer"||n.type==="hue/saturation")&&n.presetFileName!==void 0:!1},(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);if(i.Vrsn!==1)throw new Error("Invalid CgEd version");"presetFileName"in i?n.adjustment=Object.assign(Object.assign({},n.adjustment),{presetKind:i.presetKind,presetFileName:i.presetFileName}):"curvesPresetFileName"in i?n.adjustment=Object.assign(Object.assign({},n.adjustment),{presetKind:i.curvesPresetKind,presetFileName:i.curvesPresetFileName}):"mixerPresetFileName"in i?n.adjustment=Object.assign(Object.assign({},n.adjustment),{presetKind:i.mixerPresetKind,presetFileName:i.mixerPresetFileName}):n.adjustment={type:"brightness/contrast",brightness:i.Brgh,contrast:i.Cntr,meanValue:i.means,useLegacy:!!i.useLegacy,labColorOnly:!!i["Lab "],auto:!!i.Auto},(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o,r;let s=n.adjustment;if(s.type==="levels"||s.type==="exposure"||s.type==="hue/saturation"){let a={Vrsn:1,presetKind:(t=s.presetKind)!==null&&t!==void 0?t:1,presetFileName:s.presetFileName||""};(0,v.writeVersionAndDescriptor)(e,"","null",a)}else if(s.type==="curves"){let a={Vrsn:1,curvesPresetKind:(i=s.presetKind)!==null&&i!==void 0?i:1,curvesPresetFileName:s.presetFileName||""};(0,v.writeVersionAndDescriptor)(e,"","null",a)}else if(s.type==="channel mixer"){let a={Vrsn:1,mixerPresetKind:(o=s.presetKind)!==null&&o!==void 0?o:1,mixerPresetFileName:s.presetFileName||""};(0,v.writeVersionAndDescriptor)(e,"","null",a)}else if(s.type==="brightness/contrast"){let a={Vrsn:1,Brgh:s.brightness||0,Cntr:s.contrast||0,means:(r=s.meanValue)!==null&&r!==void 0?r:127,"Lab ":!!s.labColorOnly,useLegacy:!!s.useLegacy,Auto:!!s.auto};(0,v.writeVersionAndDescriptor)(e,"","null",a)}else throw new Error("Unhandled CgEd case")});function rm(e){let n=[];function t(i){var o;if(i.children)for(let r of i.children)((o=r.text)===null||o===void 0?void 0:o.index)!==void 0&&(n[r.text.index]=r),t(r)}return t(e),n}U("Txt2",le("engineData"),(e,n,t,i)=>{let o=(0,b.readBytes)(e,t());n.engineData=(0,Rf.fromByteArray)(o);let r=rm(i),s=(0,Es.parseEngineData)(o,e),l=(0,Ng.decodeEngineData2)(s).ResourceDict.TextFrameSet;if(l)for(let c=0;c<l.length;c++){let f=r[c];l[c].path&&f?.text&&(f.text.textPath=l[c].path)}},(e,n)=>{let t=(0,Rf.toByteArray)(n.engineData);(0,w.writeBytes)(e,t)});U("FEid",le("filterEffectsMasks"),(e,n,t,i)=>{let o=(0,b.readInt32)(e);if(o<1||o>3)throw new Error(`Invalid filterEffects version ${o}`);for(n.filterEffectsMasks=[];t()>8;){if((0,b.readUint32)(e))throw new Error("filterEffects: 64 bit length is not supported");let r=(0,b.readUint32)(e),s=e.offset+r,a=(0,b.readPascalString)(e,1),l=(0,b.readInt32)(e);if(l!==1)throw new Error(`Invalid filterEffect version ${l}`);if((0,b.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");(0,b.readUint32)(e);let c=(0,b.readInt32)(e),f=(0,b.readInt32)(e),u=(0,b.readInt32)(e),d=(0,b.readInt32)(e),p=(0,b.readInt32)(e),h=(0,b.readInt32)(e),m=[];for(let g=0;g<h+2;g++)if((0,b.readInt32)(e)){if((0,b.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");let x=(0,b.readUint32)(e);if(!x)throw new Error("filterEffect: Empty channel");let S=(0,b.readUint16)(e);if(x-2>t())throw new Error("filterEffect: Invalid channel length");let A=(0,b.readBytes)(e,x-2);m.push({compressionMode:S,data:A})}else m.push(void 0);if(n.filterEffectsMasks.push({id:a,top:c,left:f,bottom:u,right:d,depth:p,colorMode:i.colorMode,channels:m}),e.offset<s&&(0,b.readUint8)(e)){let g=(0,b.readInt32)(e),k=(0,b.readInt32)(e),x=(0,b.readInt32)(e),S=(0,b.readInt32)(e);if((0,b.readUint32)(e))throw new Error("filterEffect: 64 bit length is not supported");let A=(0,b.readUint32)(e),D=(0,b.readUint16)(e);if(A-2>t())throw new Error("filterEffect: Invalid extra channel length");let C=(0,b.readBytes)(e,A-2);n.filterEffectsMasks[n.filterEffectsMasks.length-1].extra={top:g,left:k,bottom:x,right:S,compressionMode:D,data:C}}e.offset=s;let y=r;for(;y%4;)e.offset++,y++}},(e,n)=>{(0,w.writeInt32)(e,3);for(let t of n.filterEffectsMasks){(0,w.writeUint32)(e,0),(0,w.writeUint32)(e,0);let i=e.offset;(0,w.writePascalString)(e,t.id,1),(0,w.writeInt32)(e,1),(0,w.writeUint32)(e,0),(0,w.writeUint32)(e,0);let o=e.offset;(0,w.writeInt32)(e,t.top),(0,w.writeInt32)(e,t.left),(0,w.writeInt32)(e,t.bottom),(0,w.writeInt32)(e,t.right),(0,w.writeInt32)(e,t.depth);let r=Math.max(0,t.channels.length-2);(0,w.writeInt32)(e,r);for(let l=0;l<r+2;l++){let c=t.channels[l];(0,w.writeInt32)(e,c?1:0),c&&((0,w.writeUint32)(e,0),(0,w.writeUint32)(e,c.data.length+2),(0,w.writeUint16)(e,c.compressionMode),(0,w.writeBytes)(e,c.data))}e.view.setUint32(o-4,e.offset-o,!1);let s=t.extra;s&&((0,w.writeUint8)(e,1),(0,w.writeInt32)(e,s.top),(0,w.writeInt32)(e,s.left),(0,w.writeInt32)(e,s.bottom),(0,w.writeInt32)(e,s.right),(0,w.writeUint32)(e,0),(0,w.writeUint32)(e,s.data.byteLength+2),(0,w.writeUint16)(e,s.compressionMode),(0,w.writeBytes)(e,s.data));let a=e.offset-i;for(e.view.setUint32(i-4,a,!1);a%4;)(0,w.writeZeros)(e,1),a++}});lt("FXid","FEid");lt("FELS","FEid");lt("hue ","hue2");lt("plLd","PlLd");lt("abdd","artb");U("FMsk",le("filterMask"),(e,n)=>{n.filterMask={colorSpace:(0,b.readColor)(e),opacity:(0,b.readUint16)(e)/100}},(e,n)=>{var t;(0,w.writeColor)(e,n.filterMask.colorSpace),(0,w.writeUint16)(e,Math.round((0,De.clamp)((t=n.filterMask.opacity)!==null&&t!==void 0?t:1,0,1)*100))});U("artd",e=>e.artboards!==void 0,(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e),o=n.artboards={count:i["Cnt "]};i.autoExpandOffset&&(o.autoExpandOffset={horizontal:i.autoExpandOffset.Hrzn,vertical:i.autoExpandOffset.Vrtc}),i.origin&&(o.origin={horizontal:i.origin.Hrzn,vertical:i.origin.Vrtc}),i.autoExpandEnabled!==void 0&&(o.autoExpandEnabled=i.autoExpandEnabled),i.autoNestEnabled!==void 0&&(o.autoNestEnabled=i.autoNestEnabled),i.autoPositionEnabled!==void 0&&(o.autoPositionEnabled=i.autoPositionEnabled),o.shrinkwrapOnSaveEnabled=!!i.shrinkwrapOnSaveEnabled,i.docDefaultNewArtboardBackgroundColor&&(o.docDefaultNewArtboardBackgroundColor=(0,v.parseColor)(i.docDefaultNewArtboardBackgroundColor)),i.docDefaultNewArtboardBackgroundType!==void 0&&(o.docDefaultNewArtboardBackgroundType=i.docDefaultNewArtboardBackgroundType),(0,b.skipBytes)(e,t())},(e,n)=>{var t,i,o,r,s;let a=n.artboards,l={"Cnt ":a.count,autoExpandOffset:a.autoExpandOffset?{Hrzn:a.autoExpandOffset.horizontal,Vrtc:a.autoExpandOffset.vertical}:{Hrzn:0,Vrtc:0},origin:a.origin?{Hrzn:a.origin.horizontal,Vrtc:a.origin.vertical}:{Hrzn:0,Vrtc:0},autoExpandEnabled:(t=a.autoExpandEnabled)!==null&&t!==void 0?t:!0,autoNestEnabled:(i=a.autoNestEnabled)!==null&&i!==void 0?i:!0,autoPositionEnabled:(o=a.autoPositionEnabled)!==null&&o!==void 0?o:!0,shrinkwrapOnSaveEnabled:(r=a.shrinkwrapOnSaveEnabled)!==null&&r!==void 0?r:!0,docDefaultNewArtboardBackgroundColor:(0,v.serializeColor)(a.docDefaultNewArtboardBackgroundColor),docDefaultNewArtboardBackgroundType:(s=a.docDefaultNewArtboardBackgroundType)!==null&&s!==void 0?s:1};(0,v.writeVersionAndDescriptor)(e,"","null",l,"artd")});function Ts(e){return!!e.children}function Do(e){return Object.keys(e).map(n=>e[n]).some(n=>Array.isArray(n)&&n.length>1)}U("lfx2",e=>e.effects!==void 0&&!Ts(e)&&!Do(e.effects),(e,n,t)=>{if((0,b.readUint32)(e)!==0)throw new Error("Invalid lfx2 version");let o=(0,v.readVersionAndDescriptor)(e);n.effects=(0,v.parseEffects)(o,e),(0,b.skipBytes)(e,t())},(e,n)=>{let t=(0,v.serializeEffects)(n.effects,e,!0);(0,w.writeUint32)(e,0),(0,v.writeVersionAndDescriptor)(e,"","null",t)});U("cinf",le("compositorUsed"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);function o(r){return r.split(".")[1]}n.compositorUsed={description:i.description,reason:i.reason,engine:o(i.Engn)},i.Vrsn&&(n.compositorUsed.version=i.Vrsn),i.psVersion&&(n.compositorUsed.photoshopVersion=i.psVersion),i.enableCompCore&&(n.compositorUsed.enableCompCore=o(i.enableCompCore)),i.enableCompCoreGPU&&(n.compositorUsed.enableCompCoreGPU=o(i.enableCompCoreGPU)),i.enableCompCoreThreads&&(n.compositorUsed.enableCompCoreThreads=o(i.enableCompCoreThreads)),i.compCoreSupport&&(n.compositorUsed.compCoreSupport=o(i.compCoreSupport)),i.compCoreGPUSupport&&(n.compositorUsed.compCoreGPUSupport=o(i.compCoreGPUSupport)),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.compositorUsed,i={Vrsn:t.version||{major:1,minor:0,fix:0}};t.photoshopVersion&&(i.psVersion=t.photoshopVersion),i.description=t.description,i.reason=t.reason,i.Engn=`Engn.${t.engine}`,t.enableCompCore&&(i.enableCompCore=`enable.${t.enableCompCore}`),t.enableCompCoreGPU&&(i.enableCompCoreGPU=`enable.${t.enableCompCoreGPU}`),t.enableCompCoreThreads&&(i.enableCompCoreThreads=`enable.${t.enableCompCoreThreads}`),t.compCoreSupport&&(i.compCoreSupport=`reason.${t.compCoreSupport}`),t.compCoreGPUSupport&&(i.compCoreGPUSupport=`reason.${t.compCoreGPUSupport}`),(0,v.writeVersionAndDescriptor)(e,"","null",i)});U("extn",e=>e.generatorSettings!==void 0&&Ls(e),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);i.generatorSettings&&(n.generatorSettings=Us(i.generatorSettings)),(0,b.skipBytes)(e,t())},(e,n)=>{(0,v.writeVersionAndDescriptor)(e,"","null",sd(n.generatorSettings))});U("extd",()=>!1,(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e);i.generatorSettings&&n.generatorSettings===void 0&&(n.generatorSettings=Us(i.generatorSettings)),(0,b.skipBytes)(e,t())},()=>{});U("frgb",le("framedGroup"),(e,n,t)=>{let i=(0,v.readVersionAndDescriptor)(e),o=i.framedGroupRect;n.framedGroup={rect:{top:o["Top "],left:o.Left,bottom:o.Btom,right:o.Rght},type:i.framedGroupType},i.LockPPI!==void 0&&(n.framedGroup.lockPPI=i.LockPPI),i.PreferredResolution!==void 0&&(n.framedGroup.preferredResolution=i.PreferredResolution),i.SavedIteratedName!==void 0&&(n.framedGroup.savedIteratedName=i.SavedIteratedName),(0,b.skipBytes)(e,t())},(e,n)=>{let t=n.framedGroup,i=t.rect,o={framedGroupRect:{_name:"",_classID:"classFloatRect","Top ":i.top,Left:i.left,Btom:i.bottom,Rght:i.right},framedGroupType:t.type};t.lockPPI!==void 0&&(o.LockPPI=t.lockPPI),t.preferredResolution!==void 0&&(o.PreferredResolution=t.preferredResolution),t.savedIteratedName!==void 0&&(o.SavedIteratedName=t.savedIteratedName),(0,v.writeVersionAndDescriptor)(e,"","framedGroup",o)});U("anFX",le("animationEffects"),(e,n,t)=>{n.animationEffects=(0,b.readBytes)(e,t())},(e,n)=>{(0,w.writeBytes)(e,n.animationEffects)});U("PxSD",le("pixelSourceData"),(e,n,t)=>{for(n.pixelSourceData=[];t()>=8;){let i=Io(e);if(i>t())throw new Error("Invalid PxSD data length");n.pixelSourceData.push((0,b.readBytes)(e,i))}(0,b.skipBytes)(e,t())},(e,n)=>{for(let t of n.pixelSourceData)(0,w.writeUint32)(e,0),(0,w.writeUint32)(e,t.byteLength),(0,w.writeBytes)(e,t)});U("iOpa",le("fillOpacity"),(e,n)=>{n.fillOpacity=(0,b.readUint8)(e)/255,(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,Math.round((0,De.clamp)(n.fillOpacity,0,1)*255)),(0,w.writeZeros)(e,3)});U("brst",le("channelBlendingRestrictions"),(e,n,t)=>{for(n.channelBlendingRestrictions=[];t()>=4;)n.channelBlendingRestrictions.push((0,b.readInt32)(e))},(e,n)=>{for(let t of n.channelBlendingRestrictions)(0,w.writeInt32)(e,t)});U("tsly",le("transparencyShapesLayer"),(e,n)=>{n.transparencyShapesLayer=!!(0,b.readUint8)(e),(0,b.skipBytes)(e,3)},(e,n)=>{(0,w.writeUint8)(e,n.transparencyShapesLayer?1:0),(0,w.writeZeros)(e,3)})});var En=ae(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});ue.createWriter=lm;ue.getWriterBuffer=cm;ue.getWriterBufferNoCopy=fm;ue.writeUint8=ye;ue.writeInt16=Zt;ue.writeUint16=q;ue.writeUint16LE=yd;ue.writeInt32=je;ue.writeInt32LE=dm;ue.writeUint32=me;ue.writeFloat32=um;ue.writeFloat64=Vs;ue.writeFixedPoint32=pm;ue.writeFixedPointPath32=hm;ue.writeBytes=Ii;ue.writeZeros=Gn;ue.writeSignature=Ut;ue.writeAsciiString=gm;ue.writePascalString=Fo;ue.writeUnicodeStringWithoutLength=bd;ue.writeUnicodeStringWithoutLengthLE=mm;ue.writeUnicodeString=wd;ue.writeUnicodeStringWithPadding=ym;ue.getRLEChannelBound=Lo;ue.writeUint64=vd;ue.writeSection=Ke;ue.writePsd=vm;ue.writeColor=Um;ue.writePattern=Bm;var re=Ot(),sm=Hi(),ud=ui(),am=qr(),Eo=st();function lm(e=4096){let n=new ArrayBuffer(e),t=new DataView(n);return{buffer:n,view:t,offset:0,tempBuffer:void 0,log:console.log}}function cm(e){return e.buffer.slice(0,e.offset)}function fm(e){return new Uint8Array(e.buffer,0,e.offset)}function ye(e,n){let t=Bt(e,1);e.view.setUint8(t,n)}function Zt(e,n){let t=Bt(e,2);e.view.setInt16(t,n,!1)}function q(e,n){let t=Bt(e,2);e.view.setUint16(t,n,!1)}function yd(e,n){let t=Bt(e,2);e.view.setUint16(t,n,!0)}function je(e,n){let t=Bt(e,4);e.view.setInt32(t,n,!1)}function dm(e,n){let t=Bt(e,4);e.view.setInt32(t,n,!0)}function me(e,n){let t=Bt(e,4);e.view.setUint32(t,n,!1)}function um(e,n){let t=Bt(e,4);e.view.setFloat32(t,n,!1)}function Vs(e,n){let t=Bt(e,8);e.view.setFloat64(t,n,!1)}function pm(e,n){je(e,n*65536)}function hm(e,n){je(e,n*(1<<24))}function Ii(e,n){n&&(Ws(e,e.offset+n.length),new Uint8Array(e.buffer).set(n,e.offset),e.offset+=n.length)}function Gn(e,n){for(let t=0;t<n;t++)ye(e,0)}function Ut(e,n){if(n.length!==4)throw new Error(`Invalid signature: '${n}'`);for(let t=0;t<4;t++)ye(e,n.charCodeAt(t))}function gm(e,n){for(let t=0;t<n.length;t++)ye(e,n.charCodeAt(t))}function Fo(e,n,t){let i=n.length;if(i>255)throw new Error("String too long");ye(e,i);for(let o=0;o<i;o++){let r=n.charCodeAt(o);ye(e,r<128?r:63)}for(;++i%t;)ye(e,0)}function bd(e,n){for(let t=0;t<n.length;t++)q(e,n.charCodeAt(t))}function mm(e,n){for(let t=0;t<n.length;t++)yd(e,n.charCodeAt(t))}function wd(e,n){me(e,n.length),bd(e,n)}function ym(e,n){me(e,n.length+1);for(let t=0;t<n.length;t++)q(e,n.charCodeAt(t));q(e,0)}function Lo(e,n,t){return n*((t?4:2)+e+Math.ceil(e/128))}function Gs(e=[],n){let t=0;for(let i of e){for(let o of[i,i.mask,i.realMask])if(o){let{width:r,height:s}=Xs(o);t=Math.max(t,Lo(r,s,n))}i.children&&(t=Math.max(t,Gs(i.children,n)))}return t}function vd(e,n){me(e,Math.floor(n/4294967296)),me(e,n>>>0)}function Ke(e,n,t,i=!1,o=!1){let r=e.offset;o&&me(e,0),me(e,0);let s=e.offset;t();let a=e.offset-s,l=a;for(;l%n;)ye(e,0),l++;if(i&&(a=l),o)e.view.setUint32(r,Math.floor(a/4294967296),!1),e.view.setUint32(r+4,a>>>0,!1);else{if(a>4294967295)throw new Error("Section too large, use PSB format instead");e.view.setUint32(r,a,!1)}}function js(e,n){let t=e&&e.data.BYTES_PER_ELEMENT;if(t!==void 0&&t!==1&&t!==2&&!(e.data instanceof Float32Array))throw new Error(`${n} has incorrect bitDepth (only Uint8Array, Uint8ClampedArray, Uint16Array and Float32Array data is supported for writing)`)}var bm={0:[1],1:[8,16,32],2:[8],3:[8,16,32],4:[8,16]},zs={0:"Bitmap",1:"Grayscale",2:"Indexed",3:"RGB",4:"CMYK",7:"Multichannel",8:"Duotone",9:"Lab"};function Sd(e){return e===3?3:e===4?4:1}var wm=[104,100,114,116,0,0,0,3,62,107,133,31,0,0,0,2,0,0,0,7,0,76,0,105,0,110,0,101,0,97,0,114,0,0,0,2,0,2,0,0,0,0,0,255,0,255,1,1,0,0,0,0,0,0,0,0,65,128,0,0,0,0,0,1,0,0,0,0,63,128,0,0,104,100,114,97,0,0,0,6,0,0,0,0,65,160,0,0,65,240,0,0,0,0,0,0,0,0,0,0,63,128,0,0,0,0,0,0,0,0];function xd(e){var n,t,i;(n=e.children)===null||n===void 0||n.forEach(xd),js(e.imageData,"imageData"),"mask"in e&&js((t=e.mask)===null||t===void 0?void 0:t.imageData,"mask imageData"),"realMask"in e&&js((i=e.realMask)===null||i===void 0?void 0:i.imageData,"realMask imageData")}function vm(e,n,t={}){var i,o,r,s;if(!(+n.width>0&&+n.height>0))throw new Error("Invalid document size");if((n.width>3e4||n.height>3e4)&&!t.psb)throw new Error("Document size is too large (max is 30000x30000, use PSB format instead)");let a=(i=n.colorMode)!==null&&i!==void 0?i:3,l=(o=n.bitsPerChannel)!==null&&o!==void 0?o:a===0?1:8,c=bm[a];if(!c)throw new Error(`${(r=zs[a])!==null&&r!==void 0?r:a} color mode is not supported for writing`);if(c.indexOf(l)===-1)throw new Error(`bitsPerChannel ${l} is not supported for writing in ${zs[a]} color mode`);let f=a!==0&&a!==2;if(!f&&(!((s=n.children)===null||s===void 0)&&s.length))throw new Error(`Layers are not supported in ${zs[a]} color mode`);if(a===2&&!n.palette)throw new Error("Missing color palette for Indexed color mode");t.log&&(e.log=t.log),t.logMissingFeatures&&(e.logMissingFeatures=!0);let u=[];Id(u,n.children),!u.length&&f&&u.push({}),xd(n);let d=Object.assign({},n.imageResources),p=Object.assign(Object.assign({},t),{layerIds:new Set,layerToId:new Map,colorMode:a,bitsPerChannel:l}),h=l===16||l===32;p.generateThumbnail&&(d.thumbnail=Om(n));let m=n.imageData;if(!m&&n.canvas&&(m=n.canvas.getContext("2d").getImageData(0,0,n.canvas.width,n.canvas.height)),!m&&n.rawCompositeData&&(m=(0,Eo.getCompositeImageData)(n)),m&&(n.width!==m.width||n.height!==m.height))throw new Error("Document canvas must have the same size as document");let y=!!m&&f&&(0,re.hasAlpha)(m);if(e.tempBuffer=new Uint8Array(Gs(n.children,!!t.psb)),Ut(e,"8BPS"),q(e,t.psb?2:1),Gn(e,6),q(e,Sd(a)+(y?1:0)),me(e,n.height),me(e,n.width),q(e,l),q(e,a),Ke(e,1,()=>{var g,k,x,S,A,D;if(a===2){let C=n.palette;for(let O=0;O<256;O++)ye(e,(k=(g=C[O])===null||g===void 0?void 0:g.r)!==null&&k!==void 0?k:0);for(let O=0;O<256;O++)ye(e,(S=(x=C[O])===null||x===void 0?void 0:x.g)!==null&&S!==void 0?S:0);for(let O=0;O<256;O++)ye(e,(D=(A=C[O])===null||A===void 0?void 0:A.b)!==null&&D!==void 0?D:0)}else l===32&&Ii(e,new Uint8Array(wm))}),d.layersGroup=u.map(g=>g.linkGroup||0),d.layerGroupsEnabledId=u.map(g=>g.linkGroupEnabled==!1?0:1),Ke(e,1,()=>{for(let g of am.resourceHandlers){let k=g.has(d),x=k===!1?0:k===!0?1:k;for(let S=0;S<x;S++){let A=g.keyCount>1?g.key+S:g.key,D=g.name?g.name(d,S):"";Ut(e,"8BIM"),q(e,A),Fo(e,D,2),Ke(e,2,()=>g.write(e,d,S,n))}}}),Ke(e,2,()=>{h||!f?Ke(e,4,()=>{},!0,p.psb):Am(e,u,n,y,p),Pm(e,n.globalLayerMaskInfo),h&&(y&&pd(e,l===16?"Mt16":"Mt32",!!p.psb,()=>{}),pd(e,l===16?"Lr16":"Lr32",!!p.psb,()=>{_d(e,u,n,y,p)})),Ad(e,n,n,p)},void 0,!!p.psb),e.tempBuffer=void 0,a===3&&l===8&&(!m||Mo(m))){q(e,1);let g=y?[0,1,2,3]:[0,1,2],k=_m(m,n.width,n.height,y),x=g.length*Lo(k.width,k.height,!!t.psb);Ws(e,e.offset+x);let S=new Uint8Array(e.buffer,e.offset,x);e.offset+=(0,re.writeDataRLE)(S,k,g,!!t.psb).length}else Sm(e,n,m,a,l,y,!!t.psb)}function pd(e,n,t,i){Ut(e,t?"8B64":"8BIM"),Ut(e,n),Ke(e,4,i,!1,t)}function Mo(e){return e.data.BYTES_PER_ELEMENT===1}function Hs(e,n,t,i){let{data:o,width:r,height:s}=e,a=r*s,l=o instanceof Float32Array,c=l?1:o instanceof Uint16Array?65535:255,f=t===32,u=f?1:t===16?65535:255,d=Sd(n),p=()=>f?new Float32Array(a):t===16?new Uint16Array(a):new Uint8Array(a),h=[];for(let D=0;D<d;D++)h.push(p());let m=p(),y=D=>l?Math.pow((0,re.clamp)(D,0,1),1/2.2):D/c,g=D=>f?Math.pow(D,2.2):Math.round((0,re.clamp)(D,0,1)*u),k=l===f&&c===u,x=D=>k?f?D:Math.round(D):g(y(D)),S=D=>k?D:f?D/c:Math.round((0,re.clamp)(D/c,0,1)*u),A=[0,0,0,0];for(let D=0,C=0;D<a;D++,C+=4){let O=o[C+3],E=S(O);m[D]=E;let L=i&&O!==c&&O>0?(0,re.clamp)(O/c,0,1):1;if(n===4){(0,re.rgbToCmykValues)(y(o[C]),y(o[C+1]),y(o[C+2]),A);for(let M=0;M<4;M++)h[M][D]=Math.round((1-(0,re.clamp)(A[M]*L,0,1))*u)}else for(let M=0;M<d;M++){let J;if(n===3)J=x(o[C+M]);else{let pe=o[C],R=o[C+1],ie=o[C+2];J=x(pe===R&&R===ie?pe:.299*pe+.587*R+.114*ie)}L!==1&&(J=f?J*L+1-L:Math.round(J*L+u*(1-L))),h[M][D]=J}}return{colors:h,alpha:m}}function kd(e,n,t,i){return e instanceof Uint8Array?i.compress?{data:(0,sm.deflate)(e),compression:2}:{data:(0,re.writeDataRLEBytes)(e,n,t,!!i.psb),compression:1}:{data:(0,re.writeDataZipWithPrediction)(e,n,t),compression:3}}function Sm(e,n,t,i,o,r,s){var a;let{width:l,height:c}=n,f=t??{data:new Uint8Array(l*c*4),width:l,height:c},u=[];if(i===0||i===2){let d=i===0?xm(f):km(f,n.palette,(a=n.imageResources)===null||a===void 0?void 0:a.transparencyIndex),p=i===0?Math.ceil(l/8):l;i===0?(q(e,0),u.push(d)):(q(e,1),u.push((0,re.writeDataRLEBytes)(d,p,c,s)))}else{let{colors:d,alpha:p}=Hs(f,i,o,r),h=r?[...d,p]:d;if(o===8){let m=h.map(g=>(0,re.writeDataRLEBytes)(g,l,c,s)),y=c*(s?4:2);q(e,1);for(let g of m)u.push(g.subarray(0,y));for(let g of m)u.push(g.subarray(y))}else{q(e,0);for(let m of h)u.push((0,re.planarToBytes)(m))}}for(let d of u)Ii(e,d)}function xm({data:e,width:n,height:t}){let i=Math.ceil(n/8),o=new Uint8Array(i*t),r=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255;for(let s=0,a=0;s<t;s++)for(let l=0;l<n;l++,a+=4){let c=e[a+3]/r;(.299*e[a]+.587*e[a+1]+.114*e[a+2])/r*c+(1-c)<.5&&(o[s*i+(l>>3)]|=128>>(l&7))}return o}function km({data:e,width:n,height:t},i,o){let r=n*t,s=new Uint8Array(r),a=e instanceof Uint16Array?8:0,l=new Map;for(let c=0;c<i.length&&c<256;c++){let f=i[c].r<<16|i[c].g<<8|i[c].b;c!==o&&!l.has(f)&&l.set(f,c)}for(let c=0,f=0;c<r;c++,f+=4){let u=k=>e instanceof Float32Array?Math.round(Math.pow((0,re.clamp)(k,0,1),.45454545454545453)*255):k>>>a,d=e instanceof Float32Array?e[f+3]*255:e[f+3]>>>a;if(o!==void 0&&o>=0&&d<128){s[c]=o;continue}let p=u(e[f]),h=u(e[f+1]),m=u(e[f+2]),y=p<<16|h<<8|m,g=l.get(y);if(g===void 0){let k=1/0;g=0;for(let x=0;x<i.length&&x<256;x++){if(x===o)continue;let S=i[x].r-p,A=i[x].g-h,D=i[x].b-m,C=S*S+A*A+D*D;C<k&&(k=C,g=x)}l.set(y,g)}s[c]=g}return s}function _m(e,n,t,i){if(!e)return{data:new Uint8Array(n*t*4),width:n,height:t};let o=n*t*4,r=e.data,s;if(i)for(let a=0;a<o;a+=4){let l=r[a+3];if(l!=0&&l!=255){s||(s=new Uint8Array(r.buffer,r.byteOffset,o).slice());let c=l/255,f=255*(1-c);s[a+0]=r[a+0]*c+f,s[a+1]=r[a+1]*c+f,s[a+2]=r[a+2]*c+f}}return s?{data:s,width:n,height:t}:e}function Am(e,n,t,i,o){Ke(e,4,()=>_d(e,n,t,i,o),!0,o.psb)}function _d(e,n,t,i,o){var r;Zt(e,i?-n.length:n.length);let s=n.map((a,l)=>Em(e,a,l===0,o));for(let a of s){let{layer:l,top:c,left:f,bottom:u,right:d,channels:p}=a;je(e,c),je(e,f),je(e,u),je(e,d),q(e,p.length);for(let m of p)Zt(e,m.id),o.psb?vd(e,m.length):me(e,m.length);Ut(e,"8BIM"),Ut(e,re.fromBlendMode[l.blendMode]||"norm"),ye(e,Math.round((0,re.clamp)((r=l.opacity)!==null&&r!==void 0?r:1,0,1)*255)),ye(e,l.clipping?1:0);let h=8;l.transparencyProtected&&(h|=1),l.hidden&&(h|=2),(l.vectorMask||l.sectionDivider&&l.sectionDivider.type!==0||l.adjustment)&&(h|=16),l.effectsOpen&&(h|=32),ye(e,h),ye(e,0),Ke(e,1,()=>{Im(e,l,a),Cm(e,l),Fo(e,(l.name||"").substring(0,255),4),Ad(e,l,t,o)})}for(let a of s)for(let l of a.channels)q(e,l.compression),l.data&&Ii(e,l.data)}function Ns(e){return e.mask?{mask:e.mask,realMask:e.realMask}:{mask:e.realMask,realMask:void 0}}function Im(e,n,t){let{mask:i,realMask:o}=Ns(n);Ke(e,4,()=>{if(!i&&!o)return;let r=0,s=0,a=0;i&&(i.userMaskDensity!==void 0&&(r|=1),i.userMaskFeather!==void 0&&(r|=2),i.vectorMaskDensity!==void 0&&(r|=4),i.vectorMaskFeather!==void 0&&(r|=8),i.disabled&&(s|=2),i.positionRelativeToLayer&&(s|=1),i.fromVectorData&&(s|=8),r&&(s|=16));let l=t.mask||{};if(je(e,l.top||0),je(e,l.left||0),je(e,l.bottom||0),je(e,l.right||0),ye(e,i&&i.defaultColor||0),ye(e,s),o){o.disabled&&(a|=2),o.positionRelativeToLayer&&(a|=1),o.fromVectorData&&(a|=8);let c=t.realMask||{};ye(e,a),ye(e,o.defaultColor||0),je(e,c.top||0),je(e,c.left||0),je(e,c.bottom||0),je(e,c.right||0)}r&&i&&(ye(e,r),i.userMaskDensity!==void 0&&ye(e,Math.round(i.userMaskDensity*255)),i.userMaskFeather!==void 0&&Vs(e,i.userMaskFeather),i.vectorMaskDensity!==void 0&&ye(e,Math.round(i.vectorMaskDensity*255)),i.vectorMaskFeather!==void 0&&Vs(e,i.vectorMaskFeather))},!0)}function Oo(e,n){ye(e,n[0]),ye(e,n[1]),ye(e,n[2]),ye(e,n[3])}function Cm(e,n){Ke(e,1,()=>{let t=n.blendingRanges;if(t){Oo(e,t.compositeGrayBlendSource),Oo(e,t.compositeGraphBlendDestinationRange);for(let i of t.ranges)Oo(e,i.sourceRange),Oo(e,i.destRange)}})}function Pm(e,n){Ke(e,1,()=>{n&&(q(e,n.overlayColorSpace),q(e,n.colorSpace1),q(e,n.colorSpace2),q(e,n.colorSpace3),q(e,n.colorSpace4),q(e,Math.round((0,re.clamp)(n.opacity,0,1)*100)),ye(e,n.kind),Gn(e,3))})}function Ad(e,n,t,i){for(let o of ud.infoHandlers){let r=o.key;if(!(r==="Txt2"&&i.invalidateTextLayers)&&(r==="vmsk"&&ud.infoHandlersMap.vscg.has(n)&&(r="vsms"),o.has(n))){let s=i.psb&&re.largeAdditionalInfoKeys.indexOf(r)!==-1,a=r!=="Txt2"&&r!=="cinf"&&r!=="extn"&&r!=="CAI "&&r!=="OCIO",l=r==="levl"||r==="Txt2"||r==="luni"||r==="vmsk"||r==="artb"||r==="artd"||r==="vogk"||r==="SoLd"||r==="SoLE"||r==="lnk2"||r==="vscg"||r==="vsms"||r==="GdFl"||r==="lmfx"||r==="lrFX"||r==="cinf"||r==="PlLd"||r==="Anno"||r==="CAI "||r==="OCIO"||r==="GenI"||r==="FEid"||r==="curv"||r==="CgEd"||r==="vibA"||r==="blwh"||r==="grdm";Ut(e,s?"8B64":"8BIM"),Ut(e,r),Ke(e,l?4:2,()=>{o.write(e,n,t,i)},a,s)}}}function Id(e,n){if(n)for(let t of n){if(t.children&&t.canvas)throw new Error("Invalid layer, cannot have both 'canvas' and 'children' properties");if(t.children&&t.imageData)throw new Error("Invalid layer, cannot have both 'imageData' and 'children' properties");t.children?(e.push({name:"</Layer group>",sectionDivider:{type:3}}),Id(e,t.children),e.push(Object.assign(Object.assign({},t),{blendMode:t.blendMode==="pass through"?"normal":t.blendMode,sectionDivider:{type:t.opened===!1?2:1,key:re.fromBlendMode[t.blendMode]||"pass",subType:0}}))):e.push(Object.assign({},t))}}function Dm(e,n){let t=Math.max(e.buffer.byteLength*2,n),i=new ArrayBuffer(t),o=new Uint8Array(i),r=new Uint8Array(e.buffer);o.set(r),e.buffer=i,e.view=new DataView(e.buffer)}function Ws(e,n){n>e.buffer.byteLength&&Dm(e,n)}function Bt(e,n){let t=e.offset;return Ws(e,e.offset+=n),t}function Om(e){let n=(0,re.createCanvas)(10,10),t=1;e.width>e.height?(n.width=160,n.height=Math.max(1,Math.floor(e.height*(n.width/e.width))),t=n.width/e.width):(n.height=160,n.width=Math.max(1,Math.floor(e.width*(n.height/e.height))),t=n.height/e.height);let i=n.getContext("2d");return i.scale(t,t),e.imageData?i.drawImage((0,re.imageDataToCanvas)(e.imageData),0,0):e.canvas&&i.drawImage(e.canvas,0,0),n}function hd(e,n,t,i,o){var r;let s=t.top|0,a=t.left|0,l=t.right|0,c=t.bottom|0,{width:f,height:u}=Xs(t),d=t.imageData;if(!d&&t.canvas&&f&&u&&(d=t.canvas.getContext("2d").getImageData(0,0,f,u)),d&&(d.width!==f||d.height!==u))throw new Error("Invalid imageData dimentions");l=a+f,c=s+u;let p,h,m=(r=i.bitsPerChannel)!==null&&r!==void 0?r:8;if(!d)p=new Uint8Array(0),h=1;else if(m!==8||!Mo(d)){let{colors:y}=Hs(d,3,m,!1);({data:p,compression:h}=kd(y[0],f,u,i))}else i.compress?(p=(0,re.writeDataZipWithoutPrediction)(d,[0]),h=2):(p=(0,re.writeDataRLE)(e,d,[0],!!i.psb).slice(),h=1);n.channels.push({id:o?-3:-2,compression:h,data:p,length:2+p.length}),n[o?"realMask":"mask"]={top:s,left:a,right:l,bottom:c}}function $s(e){return e?{top:e.top||0,left:e.left||0,right:e.right||0,bottom:e.bottom||0}:void 0}function Em(e,n,t,i){var o,r;let s=n;if(n.rawData){let{colorMode:u,bitsPerChannel:d,large:p}=n.rawData,h=i;if(p===!!i.psb&&u===((o=h.colorMode)!==null&&o!==void 0?o:3)&&d===((r=h.bitsPerChannel)!==null&&r!==void 0?r:8)){let{mask:y,realMask:g}=Ns(n);return Object.assign(Object.assign({layer:n,channels:n.rawData.channels.map(k=>{var x,S;return Object.assign(Object.assign({},k),{length:2+((S=(x=k.data)===null||x===void 0?void 0:x.byteLength)!==null&&S!==void 0?S:0)})})},$s(n)),{mask:$s(y),realMask:$s(g)})}s=Object.assign(Object.assign({},n),{rawData:void 0,canvas:void 0,imageData:(0,Eo.getLayerImageData)(n),mask:n.mask&&Object.assign(Object.assign({},n.mask),{canvas:void 0,imageData:(0,Eo.getLayerMaskImageData)(n)}),realMask:n.realMask&&Object.assign(Object.assign({},n.realMask),{canvas:void 0,imageData:(0,Eo.getLayerRealMaskImageData)(n)})});let m=Gs([Object.assign(Object.assign({},s),{children:void 0})],!!i.psb);e.tempBuffer.byteLength<m&&(e.tempBuffer=new Uint8Array(m))}let a=e.tempBuffer,{mask:l,realMask:c}=Ns(s),f=Lm(a,s,t,i);return l&&hd(a,f,l,i,!1),c&&hd(a,f,c,i,!0),f.layer=n,f}function Xs({canvas:e,imageData:n}){var t,i,o,r;let s=(i=(t=n?.width)!==null&&t!==void 0?t:e?.width)!==null&&i!==void 0?i:0,a=(r=(o=n?.height)!==null&&o!==void 0?o:e?.height)!==null&&r!==void 0?r:0;return{width:s,height:a}}function Fm(e,n,t,i,o){let r=Mo(e)?(0,re.createImageData)(i,o):{width:i,height:o,data:new e.data.constructor(i*o*4)},s=e.data,a=r.data;for(let l=0;l<o;l++)for(let c=0;c<i;c++){let f=(c+n+(l+t)*e.width)*4,u=(c+l*i)*4;a[u]=s[f],a[u+1]=s[f+1],a[u+2]=s[f+2],a[u+3]=s[f+3]}return r}function Lm(e,n,t,i){var o,r;let s=n.top|0,a=n.left|0,l=n.right|0,c=n.bottom|0,f=[{id:-1,compression:0,data:void 0,length:2},{id:0,compression:0,data:void 0,length:2},{id:1,compression:0,data:void 0,length:2},{id:2,compression:0,data:void 0,length:2}],{width:u,height:d}=Xs(n);if(!(n.canvas||n.imageData)||!u||!d)return(n.right===void 0||l>a)&&(l=a),(n.bottom===void 0||c>s)&&(c=s),{layer:n,top:s,left:a,right:l,bottom:c,channels:f};l=a+u,c=s+d;let p=n.imageData||n.canvas.getContext("2d").getImageData(0,0,u,d);if(i.trimImageData){let g=Mm(p);if(g.left!==0||g.top!==0||g.right!==p.width||g.bottom!==p.height){if(a+=g.left,s+=g.top,l-=p.width-g.right,c-=p.height-g.bottom,u=l-a,d=c-s,!u||!d)return{layer:n,top:s,left:a,right:l,bottom:c,channels:f};p=Fm(p,g.left,g.top,u,d)}}let h=[0,1,2];(!t||i.noBackground||n.mask||(0,re.hasAlpha)(p))&&h.unshift(-1);let m=(o=i.colorMode)!==null&&o!==void 0?o:3,y=(r=i.bitsPerChannel)!==null&&r!==void 0?r:8;if(m!==3||y!==8||!Mo(p)){let{colors:g,alpha:k}=Hs(p,m,y,!1),x=h[0]===-1?[-1]:[];for(let S=0;S<g.length;S++)x.push(S);return f=x.map(S=>{let{data:A,compression:D}=kd(S===-1?k:g[S],u,d,i);return{id:S,compression:D,data:A,length:2+A.length}}),{layer:n,top:s,left:a,right:l,bottom:c,channels:f}}return f=h.map(g=>{let k=(0,re.offsetForChannel)(g,!1),x,S;return i.compress?(x=(0,re.writeDataZipWithoutPrediction)(p,[k]),S=2):(x=(0,re.writeDataRLE)(e,p,[k],!!i.psb).slice(),S=1),{id:g,compression:S,data:x,length:2+x.length}}),{layer:n,top:s,left:a,right:l,bottom:c,channels:f}}function gd({data:e,width:n},t,i,o){let r=(t*n+i)*4+3|0,s=r+(o-i)*4|0;for(let a=r;a<s;a=a+4|0)if(e[a]!==0)return!1;return!0}function md({data:e,width:n},t,i,o){let r=n*4|0,s=i*r+t*4+3|0;for(let a=i,l=s;a<o;a++,l=l+r|0)if(e[l]!==0)return!1;return!0}function Mm(e){let n=0,t=0,i=e.width,o=e.height;for(;n<o&&gd(e,n,t,i);)n++;for(;o>n&&gd(e,o-1,t,i);)o--;for(;t<i&&md(e,t,n,o);)t++;for(;i>t&&md(e,i-1,n,o);)i--;return{top:n,left:t,right:i,bottom:o}}function Um(e,n){n?"r"in n?(q(e,0),q(e,Math.round(n.r*257)),q(e,Math.round(n.g*257)),q(e,Math.round(n.b*257)),q(e,0)):"fr"in n?(q(e,0),q(e,Math.round(n.fr*255*257)),q(e,Math.round(n.fg*255*257)),q(e,Math.round(n.fb*255*257)),q(e,0)):"l"in n?(q(e,7),Zt(e,Math.round(n.l*1e4)),Zt(e,Math.round((0,re.denormalizeLabAB)(n.a,100))),Zt(e,Math.round((0,re.denormalizeLabAB)(n.b,100))),q(e,0)):"h"in n?(q(e,1),q(e,Math.round(n.h*65535)),q(e,Math.round(n.s*65535)),q(e,Math.round(n.b*65535)),q(e,0)):"c"in n?(q(e,2),q(e,65535-Math.round((0,re.clamp)(n.c,0,255)*257)),q(e,65535-Math.round((0,re.clamp)(n.m,0,255)*257)),q(e,65535-Math.round((0,re.clamp)(n.y,0,255)*257)),q(e,65535-Math.round((0,re.clamp)(n.k,0,255)*257))):(q(e,8),q(e,Math.round(n.k*1e4/255)),Gn(e,6)):(q(e,0),Gn(e,8))}function Bm(e,n){let t=n.bounds.w,i=n.bounds.h,o={width:t,height:i,data:n.data};me(e,0);let r=e.offset;me(e,1),me(e,3),Zt(e,n.x),Zt(e,n.y),wd(e,n.name+"\0"),Fo(e,n.id,1),me(e,3),me(e,0);let s=e.offset,a=n.bounds.y,l=n.bounds.x,c=a+i,f=l+t;me(e,a),me(e,l),me(e,c),me(e,f),me(e,24);let u=new Uint8Array(Lo(t,i,!1));for(let h=0;h<26;h++){let m=h<3?h:h===25?3:-1;if(m<0){me(e,0);continue}let y=(0,re.writeDataRLE)(u,o,[m],!1);me(e,1),me(e,y.length+4+16+2+1),me(e,8),me(e,a),me(e,l),me(e,c),me(e,f),q(e,8),ye(e,1),Ii(e,y)}let d=e.offset-s,p=e.offset-r;for(;p%4;)Gn(e,1),p++;e.view.setUint32(s-4,d,!1),e.view.setUint32(r-4,p,!1)}});var Ld=ae(qs=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});qs.readAbr=$m;var K=ao(),se=st(),Rm=["off","fade","pen pressure","pen tilt","stylus wheel","initial direction","direction","initial rotation","rotation"],Cd=["round point","round blunt","round curve","round angle","round fan","flat point","flat blunt","flat curve","flat angle","flat fan"],Tm=["erodible point","erodible flat","erodible round","erodible square","erodible triangle","custom"],Pd=1e4,jm={_:"brush",MixB:"mixer brush",SmTl:"smudge brush"};function Fe(e){return{control:Rm[e.bVTy],steps:e.fStp,jitter:(0,K.parsePercent)(e.jitter),minimum:(0,K.parsePercent)(e["Mnm "])}}function Dd(e){switch(e._classID){case"computedBrush":return{type:"computed",size:(0,K.parseUnitsToNumber)(e.Dmtr,"Pixels"),angle:(0,K.parseAngle)(e.Angl),roundness:(0,K.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,K.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY,hardness:(0,K.parsePercent)(e.Hrdn)};case"sampledBrush":return{type:"sampled",size:(0,K.parseUnitsToNumber)(e.Dmtr,"Pixels"),angle:(0,K.parseAngle)(e.Angl),roundness:(0,K.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,K.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY,name:e["Nm "],sampledData:e.sampledData};case"dBrush":return{type:"dynamic",shape:Cd[e["Shp "]],angle:(0,K.parseAngle)(e.Angl),size:(0,K.parseUnitsToNumber)(e.Dmtr,"Pixels"),density:(0,K.parsePercent)(e.Dnst),length:(0,K.parsePercent)(e.Lngt),clumping:(0,K.parsePercent)(e.clumping),thickness:(0,K.parsePercent)(e.thickness),stiffness:(0,K.parsePercent)(e.stiffness),physics:e.physics,spacing:(0,K.parsePercent)(e.Spcn),spacingOn:e.Intr,flipX:e.flipX,flipY:e.flipY};case"dTips":return Object.assign(Object.assign({type:"tips",angle:(0,K.parseAngle)(e.Angl),size:(0,K.parseUnitsToNumber)(e.Dmtr,"Pixels"),shape:Cd[e["Shp "]],physics:e.physics,spacing:(0,K.parsePercent)(e.Spcn),spacingOn:e.Intr,flipX:e.flipX,flipY:e.flipY,tipsType:Tm[e.dtipsType],tipsLengthRatio:(0,K.parsePercent)(e.dtipsLengthRatio),tipsHardness:(0,K.parsePercent)(e.dtipsHardness)},e.dtipsGridSize&&e.dtipsErodibleTipHeightMap?{tipsGridSize:e.dtipsGridSize,tipsErodibleTipHeightMap:zm(e.dtipsErodibleTipHeightMap)}:{}),{tipsAirbrushCutoffAngle:e.dtipsAirbrushCutoffAngle,tipsAirbrushGranularity:(0,K.parsePercent)(e.dtipsAirbrushGranularity),tipsAirbrushStreakiness:(0,K.parsePercent)(e.dtipsAirbrushStreakiness),tipsAirbrushSplatSize:(0,K.parsePercent)(e.dtipsAirbrushSplatSize),tipsAirbrushSplatCount:e.dtipsAirbrushSplatCount});default:throw new Error(`Unknown brush classId: ${e._classID}`)}}function zm(e){let n=[];for(let t=0;t<e.byteLength;t++)n.push(e[t]);return n}function Od(e,n){let t=(0,se.createReader)(e.view.buffer,e.view.byteOffset+e.offset,n-e.offset);return(0,K.readVersionAndDescriptor)(t,!0)}function $m(e,n={}){let t=(0,se.createReader)(e.buffer,e.byteOffset,e.byteLength);t.logMissingFeatures=n.logMissingFeatures,t.throwForMissingFeatures=n.throwForMissingFeatures,t.totalMemoryLimit="totalMemoryLimit"in n?n.totalMemoryLimit:2*1024*1024*1024;let i=(f,u)=>{if(n.throwForMissingFeatures)throw f;n.logMissingFeatures&&t.log(`Skipped ${u}: ${f.message}`)};if(t.view.byteLength<4)throw new Error("Invalid ABR file");let o=(0,se.readInt16)(t),r=[],s=[],a=[],l=[],c;if(o===1||o===2)Nm(t,o,r,s,i);else if(o===6||o===7||o===9||o===10){let f=(0,se.readInt16)(t);if(f!==1&&f!==2)throw new Error("Unsupported ABR minor version");for(;t.offset+12<=t.view.byteLength;){(0,se.checkSignature)(t,"8BIM");let u=(0,se.readSignature)(t),d=(0,se.readUint32)(t),p=Math.min(t.offset+d,t.view.byteLength);try{switch(u){case"samp":{for(;t.offset+4<=p;){let h=(0,se.readUint32)(t);for(;h&3;)h++;let m=Math.min(t.offset+h,p);try{let y=Vm(t,m,f);r.push(y)}catch(y){i(y,"brush sample")}t.offset=m}break}case"desc":{let h=Od(t,p);for(let[m,y]of(h.Brsh||[]).entries())try{let g=Gm(y);s.push(g),l[m]=g}catch(g){i(g,`brush "${y["Nm "]}"`)}break}case"patt":{for(;t.offset+4<=p;){let h=(0,se.readPatternSafe)(t);h&&a.push(h)}break}case"phry":{c=Od(t,p).hierarchy;break}default:n.logMissingFeatures&&t.log(`Unhandled brush section: ${u}`);break}}catch(h){i(h,`brush section ${u}`)}for(t.offset=p;t.offset%4;)t.offset++}}else throw new Error(`Unsupported ABR version (${o})`);if(c){let f=[],u=0;for(let d of c)if(d._classID==="Grup")f.push(d["Nm "]);else if(d._classID==="groupEnd")f.pop();else if(d._classID==="preset"){let p=l[u];p&&f.length&&(p.group=f.slice()),u++}}return{samples:r,patterns:a,brushes:s}}function Vm(e,n,t){let i=(0,se.readPascalString)(e,1);return(0,se.skipBytes)(e,t===1?10:264),Fd(e,n,i)}function Fd(e,n,t){let i=(0,se.readInt32)(e),o=(0,se.readInt32)(e),r=(0,se.readInt32)(e)-i,s=(0,se.readInt32)(e)-o;if(s<=0||r<=0)throw new Error("Invalid bounds");if(s>Pd||r>Pd)throw new Error(`Brush sample too large (${s}x${r})`);let a=(0,se.readInt16)(e),l=(0,se.readUint8)(e);if(a!==8&&a!==16)throw new Error("Invalid depth");if(l!==0&&l!==1)throw new Error("Invalid compression");let c=s*(a===16?2:1);if((l===0?r*c:r*(2+Math.ceil(c/128)*2))>n-e.offset)throw new Error("Brush sample data out of bounds");(0,se.consumeMemory)(e,s*r*(a===16?3:1));let u=new Uint8Array(s*r);if(a===8)if(l===0)u.set((0,se.readBytes)(e,u.byteLength));else if(l===1)(0,se.readDataRLE)(e,{width:s,height:r,data:u},s,r,a,1,[0],!1);else throw new Error("Invalid compression");else if(a===16){let d=new Uint16Array(s*r);if(l===0)for(let m=0;m<d.length;m++)d[m]=(0,se.readUint16)(e);else if(l===1)(0,se.readDataRLE)(e,{width:s,height:r,data:d},s,r,a,1,[0],!1);else throw new Error("Invalid compression");let p=0;for(let m=0;m<d.length;m++)p=Math.max(p,d[m]);let h=p>32768?255/65535:255/32768;for(let m=0;m<u.byteLength;m++)u[m]=Math.round(d[m]*h)}else throw new Error("Invalid depth");return{id:t,bounds:{x:o,y:i,w:s,h:r},alpha:u}}function Nm(e,n,t,i,o){let r=(0,se.readUint16)(e);for(let s=0;s<r;s++){let a=(0,se.readUint16)(e),l=(0,se.readUint32)(e),c=e.offset+l;if(c>e.view.byteLength){o(new Error("Brush data out of bounds"),`brush ${s+1}`);break}try{if(a===1){(0,se.skipBytes)(e,4);let f=(0,se.readUint16)(e),u=(0,se.readUint16)(e),d=(0,se.readUint16)(e),p=(0,se.readInt16)(e),h=(0,se.readUint16)(e);if(e.offset>c)throw new Error("Brush data out of bounds");i.push(Ed("",{type:"computed",size:u,angle:p,roundness:d/100,spacingOn:f!==0,spacing:f/100,flipX:!1,flipY:!1,hardness:h/100}))}else if(a===2){(0,se.skipBytes)(e,4);let f=(0,se.readUint16)(e),u=n===2?(0,se.readUnicodeString)(e):"";(0,se.skipBytes)(e,9);let d=Fd(e,c,`brush-${s+1}`);t.push(d),i.push(Ed(u,{type:"sampled",size:Math.max(d.bounds.w,d.bounds.h),angle:0,roundness:1,spacingOn:f!==0,spacing:f/100,flipX:!1,flipY:!1,name:u,sampledData:d.id}))}else throw new Error(`Unknown brush type: ${a}`)}catch(f){o(f,`brush ${s+1}`)}e.offset=c}}function Ed(e,n){return{name:e,shape:n,spacing:1,wetEdges:!1,noise:!1,buildUp:!1,useBrushSize:!0}}function Gm(e){var n,t,i;let o={name:e["Nm "],shape:Dd(e.Brsh),spacing:(0,K.parsePercent)(e.Spcn),wetEdges:e.Wtdg,noise:e.Nose,buildUp:!!e["Rpt "],useBrushSize:e.useBrushSize};e.interpretation!=null&&(o.interpretation=e.interpretation),e.protectTexture!=null&&(o.protectTexture=e.protectTexture),e.useTipDynamics&&(o.shapeDynamics={tiltScale:(0,K.parsePercent)(e.tiltScale),sizeDynamics:Fe(e.szVr),angleDynamics:Fe(e.angleDynamics),roundnessDynamics:Fe(e.roundnessDynamics),flipX:e.flipX,flipY:e.flipY,brushProjection:e.brushProjection,minimumDiameter:(0,K.parsePercent)(e.minimumDiameter),minimumRoundness:(0,K.parsePercent)(e.minimumRoundness)}),e.useScatter&&(o.scatter={count:e["Cnt "],bothAxes:e.bothAxes,countDynamics:Fe(e.countDynamics),scatterDynamics:Fe(e.scatterDynamics)}),e.useTexture&&e.Txtr&&(o.texture={id:e.Txtr.Idnt,name:e.Txtr["Nm "],blendMode:K.BlnM.decode(e.textureBlendMode),depth:(0,K.parsePercent)(e.textureDepth),depthMinimum:(0,K.parsePercent)(e.minimumDepth),depthDynamics:Fe(e.textureDepthDynamics),scale:(0,K.parsePercent)(e.textureScale),invert:e.InvT,brightness:e.textureBrightness,contrast:e.textureContrast,textureEachTip:!!e.TxtC});let r=e.dualBrush;r&&r.useDualBrush&&(o.dualBrush={flip:r.Flip,shape:Dd(r.Brsh),blendMode:K.BlnM.decode(r.BlnM),useScatter:r.useScatter,spacing:(0,K.parsePercent)(r.Spcn),count:r["Cnt "],bothAxes:r.bothAxes,countDynamics:Fe(r.countDynamics),scatterDynamics:Fe(r.scatterDynamics)}),e.useColorDynamics&&(o.colorDynamics={foregroundBackground:Fe(e.clVr),hue:(0,K.parsePercent)(e["H "]),saturation:(0,K.parsePercent)(e.Strt),brightness:(0,K.parsePercent)(e.Brgh),purity:(0,K.parsePercent)(e.purity),perTip:e.colorDynamicsPerTip}),e.usePaintDynamics&&(o.transfer={flowDynamics:Fe(e.prVr),opacityDynamics:Fe(e.opVr)},e.wtVr&&(o.transfer.wetnessDynamics=Fe(e.wtVr)),e.mxVr&&(o.transfer.mixDynamics=Fe(e.mxVr))),e.useBrushPose&&(o.brushPose={overrideAngle:e.overridePoseAngle,overrideTiltX:e.overridePoseTiltX,overrideTiltY:e.overridePoseTiltY,overridePressure:e.overridePosePressure,pressure:(0,K.parsePercent)(e.brushPosePressure),tiltX:e.brushPoseTiltX,tiltY:e.brushPoseTiltY,angle:e.brushPoseAngle});let s=e.toolOptions;return s&&(o.toolOptions={type:jm[s._classID]||"brush",brushPreset:s.brushPreset,flow:(n=s.flow)!==null&&n!==void 0?n:100,smooth:(t=s.Smoo)!==null&&t!==void 0?t:0,mode:K.BlnM.decode(s["Md "]||"BlnM.Nrml"),opacity:(i=s.Opct)!==null&&i!==void 0?i:100,smoothing:!!s.smoothing,smoothingValue:s.smoothingValue||0,smoothingRadiusMode:!!s.smoothingRadiusMode,smoothingCatchup:!!s.smoothingCatchup,smoothingCatchupAtEnd:!!s.smoothingCatchupAtEnd,smoothingZoomCompensation:!!s.smoothingZoomCompensation,pressureSmoothing:!!s.pressureSmoothing,usePressureOverridesSize:!!s.usePressureOverridesSize,usePressureOverridesOpacity:!!s.usePressureOverridesOpacity,useLegacy:!!s.useLegacy},s.prVr&&(o.toolOptions.flowDynamics=Fe(s.prVr)),s.opVr&&(o.toolOptions.opacityDynamics=Fe(s.opVr)),s.szVr&&(o.toolOptions.sizeDynamics=Fe(s.szVr)),"wetness"in s&&(o.toolOptions.wetness=s.wetness),"dryness"in s&&(o.toolOptions.dryness=s.dryness),"mix"in s&&(o.toolOptions.mix=s.mix),"autoFill"in s&&(o.toolOptions.autoFill=s.autoFill),"autoClean"in s&&(o.toolOptions.autoClean=s.autoClean),"loadSolidColorOnly"in s&&(o.toolOptions.loadSolidColorOnly=s.loadSolidColorOnly),"sampleAllLayers"in s&&(o.toolOptions.sampleAllLayers=s.sampleAllLayers),"SmdF"in s&&(o.toolOptions.smudgeFingerPainting=s.SmdF),"SmdS"in s&&(o.toolOptions.smudgeSampleAllLayers=s.SmdS),"Prs "in s&&(o.toolOptions.strength=s["Prs "])),o}});var Md=ae(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.readCsh=Wm;var Hm=ui(),tt=st();function Wm(e,n={}){let t=(0,tt.createReader)(e.buffer,e.byteOffset,e.byteLength);t.totalMemoryLimit="totalMemoryLimit"in n?n.totalMemoryLimit:2*1024*1024*1024;let i={shapes:[]};if((0,tt.checkSignature)(t,"cush"),(0,tt.readUint32)(t)!==2)throw new Error("Invalid version");let o=(0,tt.readUint32)(t);for(let r=0;r<o;r++){let s=(0,tt.readUnicodeString)(t);for(;t.offset%4;)t.offset++;if((0,tt.readUint32)(t)!==1)throw new Error("Invalid shape version");let a=(0,tt.readUint32)(t),l=t.offset+a,c=(0,tt.readPascalString)(t,1),f=(0,tt.readUint32)(t),u=(0,tt.readUint32)(t),d=(0,tt.readUint32)(t),h=(0,tt.readUint32)(t)-u,m=d-f,y={paths:[]};(0,Hm.readVectorMask)(t,y,h,m,l-t.offset),i.shapes.push(Object.assign({name:s,id:c,width:h,height:m},y)),t.offset=l}return i}});var Ud=ae(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.readAse=Xm;var ze=st();function Xm(e,n={}){let t=(0,ze.createReader)(e.buffer,e.byteOffset,e.byteLength);if(t.totalMemoryLimit="totalMemoryLimit"in n?n.totalMemoryLimit:2*1024*1024*1024,(0,ze.readSignature)(t)!=="ASEF")throw new Error("Invalid signature");let o=(0,ze.readUint16)(t);if((0,ze.readUint16)(t),o!==1)throw new Error("Invalid version");let r=(0,ze.readUint32)(t),s={colors:[]},a=s;for(let l=0;l<r&&t.offset+6<=t.view.byteLength;l++){let c=(0,ze.readUint16)(t),f=(0,ze.readUint32)(t),u=Math.min(t.offset+f,t.view.byteLength),d=(0,ze.createReader)(t.view.buffer,t.view.byteOffset+t.offset,u-t.offset);d.totalMemoryLimit=t.totalMemoryLimit;try{switch(c){case 1:{let p=qm(d);if(p)a.colors.push(p);else{if(n.throwForMissingFeatures)throw new Error("Unsupported color mode");n.logMissingFeatures&&t.log("Skipped color with unsupported color mode")}break}case 49153:{let p=(0,ze.readUint16)(d),h=(0,ze.readUnicodeStringWithLength)(d,p);s.colors.push(a={name:h,colors:[]});break}case 49154:a=s;break;default:if(n.throwForMissingFeatures)throw new Error(`Invalid block type: ${c}`);n.logMissingFeatures&&t.log(`Skipped unknown block type: ${c}`)}}catch(p){if(n.throwForMissingFeatures)throw p;n.logMissingFeatures&&t.log(`Skipped invalid block: ${p.message}`)}t.totalMemoryLimit=d.totalMemoryLimit,t.offset=u}return s}function qm(e){let n=(0,ze.readUint16)(e),t=(0,ze.readUnicodeStringWithLength)(e,n),i=(0,ze.readSignature)(e),o=()=>{let s=(0,ze.readFloat32)(e);return isFinite(s)?s:0},r=()=>{let s=e.offset+2<=e.view.byteLength?(0,ze.readUint16)(e):2;return Zm[s]||"normal"};switch(i){case"RGB ":return{name:t,color:{r:o(),g:o(),b:o(),type:r()}};case"CMYK":return{name:t,color:{c:o(),m:o(),y:o(),k:o(),type:r()}};case"Gray":return{name:t,color:{k:o(),type:r()}};case"LAB ":return{name:t,color:{l:o(),a:o(),b:o(),type:r()}};default:return}}var Zm=["global","spot","normal"]});var $d=ae(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.Compression=nt.ChannelID=nt.LayerCompCapturedInfo=nt.SectionDividerType=nt.ColorMode=void 0;var Bd;(function(e){e[e.Bitmap=0]="Bitmap",e[e.Grayscale=1]="Grayscale",e[e.Indexed=2]="Indexed",e[e.RGB=3]="RGB",e[e.CMYK=4]="CMYK",e[e.Multichannel=7]="Multichannel",e[e.Duotone=8]="Duotone",e[e.Lab=9]="Lab"})(Bd||(nt.ColorMode=Bd={}));var Rd;(function(e){e[e.Other=0]="Other",e[e.OpenFolder=1]="OpenFolder",e[e.ClosedFolder=2]="ClosedFolder",e[e.BoundingSectionDivider=3]="BoundingSectionDivider"})(Rd||(nt.SectionDividerType=Rd={}));var Td;(function(e){e[e.None=0]="None",e[e.Visibility=1]="Visibility",e[e.Position=2]="Position",e[e.Appearance=4]="Appearance"})(Td||(nt.LayerCompCapturedInfo=Td={}));var jd;(function(e){e[e.Color0=0]="Color0",e[e.Color1=1]="Color1",e[e.Color2=2]="Color2",e[e.Color3=3]="Color3",e[e.Transparency=-1]="Transparency",e[e.UserMask=-2]="UserMask",e[e.RealUserMask=-3]="RealUserMask"})(jd||(nt.ChannelID=jd={}));var zd;(function(e){e[e.RawData=0]="RawData",e[e.RleCompressed=1]="RleCompressed",e[e.ZipWithoutPrediction=2]="ZipWithoutPrediction",e[e.ZipWithPrediction=3]="ZipWithPrediction"})(zd||(nt.Compression=zd={}))});var Nd=ae(Y=>{"use strict";var Km=Y&&Y.__createBinding||(Object.create?(function(e,n,t,i){i===void 0&&(i=t);var o=Object.getOwnPropertyDescriptor(n,t);(!o||("get"in o?!n.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return n[t]}}),Object.defineProperty(e,i,o)}):(function(e,n,t,i){i===void 0&&(i=t),e[i]=n[t]})),Uo=Y&&Y.__exportStar||function(e,n){for(var t in e)t!=="default"&&!Object.prototype.hasOwnProperty.call(n,t)&&Km(n,e,t)};Object.defineProperty(Y,"__esModule",{value:!0});Y.getFilterEffectsMaskExtraCanvas=Y.getFilterEffectsMaskCanvas=Y.getFilterEffectsMaskExtraImageData=Y.getFilterEffectsMaskImageData=Y.getCompositeCanvas=Y.getCompositeImageData=Y.getLayerRealMaskCanvas=Y.getLayerMaskCanvas=Y.getLayerCanvas=Y.getLayerRealMaskImageData=Y.getLayerMaskImageData=Y.getLayerImageData=Y.decodeLayerPixels=Y.byteArrayToBase64=Y.initializeCanvas=void 0;Y.readPsd=Qm;Y.writePsd=ey;Y.writePsdUint8Array=Vd;Y.writePsdBuffer=ty;var Hn=En(),Le=st();Object.defineProperty(Y,"decodeLayerPixels",{enumerable:!0,get:function(){return Le.decodeLayerPixels}});Object.defineProperty(Y,"getLayerImageData",{enumerable:!0,get:function(){return Le.getLayerImageData}});Object.defineProperty(Y,"getLayerMaskImageData",{enumerable:!0,get:function(){return Le.getLayerMaskImageData}});Object.defineProperty(Y,"getLayerRealMaskImageData",{enumerable:!0,get:function(){return Le.getLayerRealMaskImageData}});Object.defineProperty(Y,"getLayerCanvas",{enumerable:!0,get:function(){return Le.getLayerCanvas}});Object.defineProperty(Y,"getLayerMaskCanvas",{enumerable:!0,get:function(){return Le.getLayerMaskCanvas}});Object.defineProperty(Y,"getLayerRealMaskCanvas",{enumerable:!0,get:function(){return Le.getLayerRealMaskCanvas}});Object.defineProperty(Y,"getCompositeImageData",{enumerable:!0,get:function(){return Le.getCompositeImageData}});Object.defineProperty(Y,"getCompositeCanvas",{enumerable:!0,get:function(){return Le.getCompositeCanvas}});Object.defineProperty(Y,"getFilterEffectsMaskImageData",{enumerable:!0,get:function(){return Le.getFilterEffectsMaskImageData}});Object.defineProperty(Y,"getFilterEffectsMaskExtraImageData",{enumerable:!0,get:function(){return Le.getFilterEffectsMaskExtraImageData}});Object.defineProperty(Y,"getFilterEffectsMaskCanvas",{enumerable:!0,get:function(){return Le.getFilterEffectsMaskCanvas}});Object.defineProperty(Y,"getFilterEffectsMaskExtraCanvas",{enumerable:!0,get:function(){return Le.getFilterEffectsMaskExtraCanvas}});var Ym=no();Uo(Ld(),Y);Uo(Md(),Y);Uo(Ud(),Y);var Jm=Ot();Object.defineProperty(Y,"initializeCanvas",{enumerable:!0,get:function(){return Jm.initializeCanvas}});Uo($d(),Y);Y.byteArrayToBase64=Ym.fromByteArray;function Qm(e,n){let t="buffer"in e?(0,Le.createReader)(e.buffer,e.byteOffset,e.byteLength):(0,Le.createReader)(e);return(0,Le.readPsd)(t,n)}function ey(e,n){let t=(0,Hn.createWriter)();return(0,Hn.writePsd)(t,e,n),(0,Hn.getWriterBuffer)(t)}function Vd(e,n){let t=(0,Hn.createWriter)();return(0,Hn.writePsd)(t,e,n),(0,Hn.getWriterBufferNoCopy)(t)}function ty(e,n){if(typeof Buffer>"u")throw new Error("Buffer not supported on this platform");return Buffer.from(Vd(e,n))}});var To=mu(Nd(),1);var Ro=class{view;offset=0;constructor(n){this.view=new DataView(n)}get length(){return this.view.byteLength}ensure(n,t=this.length,i="Adobe resource"){if(!Number.isSafeInteger(n)||n<0||this.offset+n>t||t>this.length)throw new Error(`${i} is truncated or has an invalid length.`)}u8(n,t){return this.ensure(1,n,t),this.view.getUint8(this.offset++)}i16(n,t){this.ensure(2,n,t);let i=this.view.getInt16(this.offset,!1);return this.offset+=2,i}u16(n,t){this.ensure(2,n,t);let i=this.view.getUint16(this.offset,!1);return this.offset+=2,i}i32(n,t){this.ensure(4,n,t);let i=this.view.getInt32(this.offset,!1);return this.offset+=4,i}u32(n,t){this.ensure(4,n,t);let i=this.view.getUint32(this.offset,!1);return this.offset+=4,i}i32le(n,t){this.ensure(4,n,t);let i=this.view.getInt32(this.offset,!0);return this.offset+=4,i}ascii(n,t,i){this.ensure(n,t,i);let o="";for(let r=0;r<n;r+=1)o+=String.fromCharCode(this.view.getUint8(this.offset++));return o}skip(n,t,i){this.ensure(n,t,i),this.offset+=n}},Ys=e=>{let n=e+3&-4;if(!Number.isSafeInteger(n)||n<e)throw new Error("Adobe resource alignment overflowed.");return n},_t=(e,n,t)=>{let i=e*n;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t} overflows the safe integer range.`);return i},Gd=(e,n,t)=>{if(e.byteLength>n.maxFileBytes)throw new Error(`${t.toUpperCase()} source exceeds the ${n.maxFileBytes}-byte safety limit.`)},un=(e,n,t)=>{if(!Number.isSafeInteger(e)||e<0||e>n.maxResourceItems)throw new Error(`${t} exceeds the ${n.maxResourceItems}-item safety limit.`)},Hd=(e,n,t,i)=>{un(n,t,i),e.descriptorItems+=n;let o=Math.min(1e6,t.maxResourceItems*64);if(e.descriptorItems>o)throw new Error(`Adobe descriptor complexity exceeds the ${o}-record safety limit.`)},Wd=(e,n,t,i,o)=>{if(n<=0||n>i.maxResourcePreviewPixels)throw new Error(`${o} exceeds the ${i.maxResourcePreviewPixels}-pixel preview limit.`);if(e.previewPixels+=n,e.decodedBytes+=t,e.previewPixels>i.maxResourcePreviewPixels)throw new Error(`Adobe resource previews exceed the ${i.maxResourcePreviewPixels}-pixel collection limit.`);if(e.decodedBytes>i.maxDecodedBytes)throw new Error(`Adobe resource decoding exceeds the ${i.maxDecodedBytes}-byte safety limit.`)},Wn=(e,n,t,i)=>{let o=e.u32(n,i);if(o>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-code-unit name limit.`);e.skip(_t(o,2,`${i} length`),n,i)},Js=(e,n,t,i)=>{let o=e.u8(n,i);if(o>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-code-unit name limit.`);e.skip(o,n,i)},Rt=(e,n,t,i)=>{let o=e.i32(n,i);if(o<0)throw new Error(`${i} has a negative string length.`);let r=o||4;if(r>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-character identifier limit.`);e.skip(r,n,i)},dn=(e,n,t,i)=>{Wn(e,n,t,`${i} name`),Rt(e,n,t,`${i} class id`)},Bo=(e,n,t,i,o)=>{let r=e.i32(n,o);if(r<0)throw new Error(`${o} has a negative item count.`);return Hd(t,r,i,o),r},Xd=(e,n,t,i,o,r)=>{if(i>r.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${r.maxNestingDepth}-level safety limit.`);switch(t){case"obj ":{let s=Bo(e,n,o,r,"Adobe descriptor reference");for(let a=0;a<s;a+=1){let l=e.ascii(4,n,"Adobe descriptor reference type");if(l==="prop")dn(e,n,r,"Adobe property reference"),Rt(e,n,r,"Adobe property key");else if(l==="Clss")dn(e,n,r,"Adobe class reference");else if(l==="Enmr")dn(e,n,r,"Adobe enum reference"),Rt(e,n,r,"Adobe enum type"),Rt(e,n,r,"Adobe enum value");else if(l==="rele")dn(e,n,r,"Adobe offset reference"),e.skip(4,n,"Adobe offset reference");else if(l==="Idnt"||l==="indx")e.skip(4,n,"Adobe integer reference");else if(l==="name")dn(e,n,r,"Adobe name reference"),Wn(e,n,r,"Adobe reference name");else throw new Error(`Unsupported Adobe descriptor reference type ${JSON.stringify(l)}.`)}return}case"Objc":case"GlbO":qd(e,n,i+1,o,r);return;case"VlLs":{let s=Bo(e,n,o,r,"Adobe descriptor list");for(let a=0;a<s;a+=1){let l=e.ascii(4,n,"Adobe descriptor list type");Xd(e,n,l,i+1,o,r)}return}case"doub":e.skip(8,n,"Adobe double");return;case"UntF":e.skip(12,n,"Adobe unit double");return;case"UnFl":e.skip(8,n,"Adobe unit float");return;case"TEXT":Wn(e,n,r,"Adobe descriptor text");return;case"enum":Rt(e,n,r,"Adobe enum type"),Rt(e,n,r,"Adobe enum value");return;case"long":e.skip(4,n,"Adobe integer");return;case"comp":e.skip(8,n,"Adobe large integer");return;case"bool":e.skip(1,n,"Adobe boolean");return;case"type":case"GlbC":dn(e,n,r,"Adobe descriptor class");return;case"alis":case"tdta":{let s=e.i32(n,"Adobe descriptor data length");if(s<0||s>r.maxDecodedBytes)throw new Error(`Adobe descriptor data exceeds the ${r.maxDecodedBytes}-byte safety limit.`);e.skip(s,n,"Adobe descriptor data");return}case"ObAr":{e.skip(4,n,"Adobe object-array version"),Wn(e,n,r,"Adobe object-array name"),Rt(e,n,r,"Adobe object-array class");let s=Bo(e,n,o,r,"Adobe object array");for(let a=0;a<s;a+=1){Rt(e,n,r,"Adobe object-array item type");let l=e.ascii(4,n,"Adobe object-array value type");if(l!=="UnFl")throw new Error(`Unsupported Adobe object-array value type ${JSON.stringify(l)}.`);e.skip(4,n,"Adobe object-array units");let c=Bo(e,n,o,r,"Adobe object-array values");e.skip(_t(c,8,"Adobe object-array values"),n,"Adobe object-array values")}return}case"Pth ":{let s=e.i32(n,"Adobe path length");if(s<0||s>r.maxDecodedBytes)throw new Error("Adobe descriptor path length is invalid.");e.skip(4,n,"Adobe path signature");let a=e.i32le(n,"Adobe path size"),l=e.i32le(n,"Adobe path character count");if(a<0||l<0||l>r.maxResourceNameCodeUnits)throw new Error("Adobe descriptor path exceeds its bounded string limits.");e.skip(_t(l,2,"Adobe path characters"),n,"Adobe descriptor path");return}default:throw new Error(`Unsupported Adobe descriptor value type ${JSON.stringify(t)}.`)}},qd=(e,n,t,i,o)=>{if(t>o.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${o.maxNestingDepth}-level safety limit.`);dn(e,n,o,"Adobe descriptor");let r=e.u32(n,"Adobe descriptor item count");Hd(i,r,o,"Adobe descriptor item count");for(let s=0;s<r;s+=1){Rt(e,n,o,"Adobe descriptor key");let a=e.ascii(4,n,"Adobe descriptor value type");Xd(e,n,a,t+1,i,o)}},ny=(e,n,t,i)=>{let o=e.u32(n,"Adobe descriptor version");if(o!==16)throw new Error(`Unsupported Adobe descriptor version ${o}.`);qd(e,n,0,t,i)},Zd=(e,n,t,i,o)=>{let r=_t(i,2,`${o} row table`);e.ensure(r,n,o);let s=Array.from({length:i},()=>e.u16(n,`${o} row length`));for(let a=0;a<i;a+=1){let l=e.offset+s[a];if(l>n)throw new Error(`${o} compressed row ${a} is truncated.`);let c=0;for(;e.offset<l;){let f=e.u8(l,`${o} PackBits header`);if(f<=127){let u=f+1;e.skip(u,l,`${o} PackBits literal`),c+=u}else f>=129&&(e.skip(1,l,`${o} PackBits repeat value`),c+=257-f);if(c>t)throw new Error(`${o} PackBits row ${a} expands beyond its declared width.`)}if(c!==t)throw new Error(`${o} PackBits row ${a} does not expand to its declared width.`)}},iy=(e,n,t,i,o)=>{let r=0;for(;e.offset<n;){un(++r,o,"ABR sample count");let s=e.u32(n,"ABR sample length"),a=e.offset,l=a+s,c=a+Ys(s);if(l>n||c>n)throw new Error("ABR sample record is truncated.");Js(e,l,o,"ABR sample id"),e.skip(t===1?10:264,l,"ABR sample header");let f=e.i32(l,"ABR sample top"),u=e.i32(l,"ABR sample left"),d=e.i32(l,"ABR sample bottom"),h=e.i32(l,"ABR sample right")-u,m=d-f;if(h<=0||m<=0||h>o.maxCanvasDimension||m>o.maxCanvasDimension)throw new Error(`ABR sample dimensions exceed the ${o.maxCanvasDimension}-pixel side limit.`);let y=_t(h,m,"ABR sample pixels"),g=e.i16(l,"ABR sample depth"),k=e.u8(l,"ABR sample compression");if(g!==8&&g!==16)throw new Error(`Unsupported ABR sample depth ${g}.`);if(k!==0&&k!==1)throw new Error(`Unsupported ABR sample compression ${k}.`);if(g===16&&k===1)throw new Error("ABR 16-bit RLE samples are not supported by the decoding engine.");if(Wd(i,y,y,o,"ABR sample"),k===0?e.skip(_t(y,g/8,"ABR raw sample bytes"),l,"ABR raw sample"):Zd(e,l,h,m,"ABR sample"),e.offset>l)throw new Error("ABR sample payload exceeded its declared record boundary.");e.offset=l,e.offset=c}return r},oy=(e,n,t,i)=>{let o=e.u32(n,"ABR pattern length"),s=e.offset+Ys(o);if(s>n)throw new Error("ABR pattern record is truncated.");if(e.u32(s,"ABR pattern version")!==1)throw new Error("Unsupported ABR pattern version.");let a=e.u32(s,"ABR pattern color mode");if(a!==1&&a!==2&&a!==3)throw new Error(`Unsupported ABR pattern color mode ${a}.`);if(e.skip(4,s,"ABR pattern origin"),Wn(e,s,i,"ABR pattern name"),Js(e,s,i,"ABR pattern id"),a===2&&e.skip(772,s,"ABR indexed palette"),e.u32(s,"ABR pattern VMAL version")!==3)throw new Error("Unsupported ABR pattern VMAL version.");e.u32(s,"ABR pattern VMAL length");let l=e.u32(s,"ABR pattern top"),c=e.u32(s,"ABR pattern left"),f=e.u32(s,"ABR pattern bottom"),u=e.u32(s,"ABR pattern right"),d=e.u32(s,"ABR pattern channel count");if(f<=l||u<=c||d>16)throw new Error("ABR pattern bounds or channel count is invalid.");let p=u-c,h=f-l;if(p>i.maxCanvasDimension||h>i.maxCanvasDimension)throw new Error(`ABR pattern dimensions exceed the ${i.maxCanvasDimension}-pixel side limit.`);let m=_t(p,h,"ABR pattern pixels");Wd(t,m,_t(m,4,"ABR pattern RGBA bytes"),i,"ABR pattern");for(let y=0;y<d+2;y+=1){if(!e.u32(s,"ABR pattern channel presence"))continue;let k=e.u32(s,"ABR pattern channel length");if(k<23)throw new Error("ABR pattern channel length is invalid.");let x=e.offset+k;if(x>s)throw new Error("ABR pattern channel is truncated.");let S=e.u32(x,"ABR pattern channel depth"),A=e.u32(x,"ABR pattern channel top"),D=e.u32(x,"ABR pattern channel left"),C=e.u32(x,"ABR pattern channel bottom"),O=e.u32(x,"ABR pattern channel right"),E=e.u16(x,"ABR pattern channel depth duplicate"),L=e.u8(x,"ABR pattern channel compression");if(S!==8||E!==8||L!==0&&L!==1)throw new Error("ABR pattern channel uses an unsupported depth or compression mode.");if(C<A||O<D||A<l||D<c||C>f||O>u)throw new Error("ABR pattern channel bounds are invalid.");let M=O-D,J=C-A,pe=_t(M,J,"ABR pattern channel pixels");if(L===0){if(x-e.offset!==pe)throw new Error("ABR raw pattern channel length does not match its dimensions.");e.skip(pe,x,"ABR raw pattern channel")}else if(Zd(e,x,M,J,"ABR pattern channel"),e.offset!==x)throw new Error("ABR RLE pattern channel has trailing bytes.")}e.offset=s},Kd=(e,n)=>{Gd(e,n,"ABR");let t=new Ro(e),i=t.i16(void 0,"ABR version");if(i!==6&&i!==7&&i!==9&&i!==10)throw new Error(`Unsupported ABR version ${i}; the browser engine supports modern ABR versions 6, 7, 9, and 10.`);let o=t.i16(void 0,"ABR minor version");if(o!==1&&o!==2)throw new Error(`Unsupported ABR minor version ${o}.`);let r={descriptorItems:0,previewPixels:0,decodedBytes:0},s=0,a=0,l=0;for(;t.offset<t.length;){if(un(++s,n,"ABR section count"),t.ascii(4,void 0,"ABR section signature")!=="8BIM")throw new Error("Invalid ABR section signature.");let c=t.ascii(4,void 0,"ABR section type"),f=t.u32(void 0,"ABR section length"),u=t.offset,d=u+f,p=u+Ys(f);if(d>t.length||p>t.length)throw new Error("ABR section is truncated.");if(c==="samp")a+=iy(t,d,o,r,n);else if(c==="desc"||c==="phry"){if(ny(t,d,r,n),t.offset!==d)throw new Error(`ABR ${c} descriptor does not consume its declared section.`)}else if(c==="patt")for(;t.offset<d;)un(++l,n,"ABR pattern count"),oy(t,d,r,n);else throw new Error(`Unsupported ABR section type ${JSON.stringify(c)}.`);if(t.offset>d)throw new Error(`ABR ${c} section exceeded its declared boundary.`);t.offset=p}return un(a+l,n,"ABR decoded resource count"),{format:"abr",majorVersion:i,minorVersion:o,sections:s,samples:a,patterns:l,previewPixels:r.previewPixels,decodedBytes:r.decodedBytes}},Yd=(e,n)=>{Gd(e,n,"CSH");let t=new Ro(e);if(t.ascii(4,void 0,"CSH signature")!=="cush")throw new Error("Invalid CSH signature.");let i=t.u32(void 0,"CSH version");if(i!==2)throw new Error(`Unsupported CSH version ${i}; version 2 is required.`);let o=t.u32(void 0,"CSH shape count");un(o,n,"CSH shape count");let r=0,s=0,a=Math.min(1e6,n.maxResourceItems*64);for(let l=0;l<o;l+=1){for(Wn(t,t.length,n,`CSH shape ${l} name`);t.offset%4;)t.skip(1,t.length,"CSH name padding");if(t.u32(void 0,"CSH shape version")!==1)throw new Error("Unsupported CSH shape record version.");let c=t.u32(void 0,"CSH shape record length"),f=t.offset+c;if(f>t.length)throw new Error("CSH shape record is truncated.");Js(t,f,n,`CSH shape ${l} id`);let u=t.u32(f,"CSH shape top"),d=t.u32(f,"CSH shape left"),p=t.u32(f,"CSH shape bottom"),h=t.u32(f,"CSH shape right");if(p<=u||h<=d)throw new Error("CSH shape bounds are invalid.");let m=h-d,y=p-u;if(m>n.maxCanvasDimension||y>n.maxCanvasDimension)throw new Error(`CSH shape dimensions exceed the ${n.maxCanvasDimension}-pixel side limit.`);let g=_t(m,y,"CSH shape preview pixels");if(s+=g,s>n.maxResourcePreviewPixels)throw new Error(`CSH previews exceed the ${n.maxResourcePreviewPixels}-pixel collection limit.`);if((f-t.offset)%26!==0)throw new Error("CSH vector record section is not aligned to 26-byte path records.");let k=0,x=0,S=!1;for(;t.offset<f;){if(r+=1,r>a)throw new Error(`CSH path complexity exceeds the ${a}-record safety limit.`);let A=t.u16(f,"CSH vector selector");if(A===0||A===3){if(S&&x!==k)throw new Error("CSH path knot count does not match its declared count.");k=t.u16(f,"CSH path knot count"),un(k,n,"CSH path knot count");let D=t.i16(f,"CSH path boolean operation");if(D<-1||D>3)throw new Error("CSH path boolean operation is invalid.");t.skip(20,f,"CSH path header"),x=0,S=!0}else if(A===1||A===2||A===4||A===5){if(!S)throw new Error("CSH knot appears before a path header.");if(t.skip(24,f,"CSH Bezier knot"),x+=1,x>k)throw new Error("CSH path contains more knots than declared.")}else if(A===6||A===7||A===8)t.skip(24,f,"CSH vector metadata record");else throw new Error(`Unsupported CSH vector selector ${A}.`)}if(S&&x!==k)throw new Error("CSH path knot count does not match its declared count.")}if(t.offset!==t.length)throw new Error("CSH file has trailing bytes outside its declared shapes.");return{format:"csh",version:2,shapes:o,pathRecords:r,previewPixels:s}};var Tt=(e,n)=>{if(!Number.isFinite(e))throw new Error(`${n} is not finite.`);return e},pn=(e,n,t)=>{if(e.length>n.maxResourceNameCodeUnits)throw new Error(`${t} exceeds the ${n.maxResourceNameCodeUnits}-code-unit name limit.`);return e},ry=(e,n,t)=>{let i=Tt(e.size,`${t} size`),o=Tt(e.angle,`${t} angle`);if(i<0||i>n.maxCanvasDimension)throw new Error(`${t} size exceeds the ${n.maxCanvasDimension}-pixel side limit.`);let r={type:e.type,size:i,angle:o};return"roundness"in e&&(r.roundness=Tt(e.roundness,`${t} roundness`)),"hardness"in e&&(r.hardness=Tt(e.hardness,`${t} hardness`)),"spacing"in e&&(r.spacing=Tt(e.spacing,`${t} spacing`)),e.type==="sampled"&&(r.sampledDataId=pn(e.sampledData,n,`${t} sampled-data id`)),r},sy=(e,n)=>({name:pn(e.name,n,"ABR brush name"),shape:ry(e.shape,n,`ABR brush ${JSON.stringify(e.name)}`),hasDynamics:!!(e.shapeDynamics||e.scatter||e.colorDynamics||e.transfer||e.brushPose),hasTexture:!!e.texture,hasDualBrush:!!e.dualBrush,...e.toolOptions?.type?{toolType:e.toolOptions.type}:{}}),ay=(e,n)=>{let t=Kd(e,n),i=(0,To.readAbr)(new Uint8Array(e),{logMissingFeatures:!1,totalMemoryLimit:n.maxDecodedBytes});if(i.brushes.length+i.samples.length+i.patterns.length>n.maxResourceItems)throw new Error(`ABR decoded resources exceed the ${n.maxResourceItems}-item safety limit.`);let r=0,s=0,a=i.samples.map((c,f)=>{let{w:u,h:d,x:p,y:h}=c.bounds,m=u*d;if(!Number.isSafeInteger(m)||m<=0||c.alpha.byteLength!==m)throw new Error(`ABR sample ${f} returned inconsistent decoded pixels.`);return s+=m,r+=c.alpha.byteLength,{id:pn(c.id,n,`ABR sample ${f} id`),x:Tt(p,`ABR sample ${f} x`),y:Tt(h,`ABR sample ${f} y`),width:u,height:d,alpha:c.alpha}}),l=i.patterns.map((c,f)=>{let{w:u,h:d,x:p,y:h}=c.bounds,m=u*d;if(!Number.isSafeInteger(m)||m<=0||c.data.byteLength!==m*4)throw new Error(`ABR pattern ${f} returned inconsistent decoded pixels.`);return s+=m,r+=c.data.byteLength,{id:pn(c.id,n,`ABR pattern ${f} id`),name:pn(c.name,n,`ABR pattern ${f} name`),x:Tt(p,`ABR pattern ${f} x`),y:Tt(h,`ABR pattern ${f} y`),width:u,height:d,rgba:c.data}});if(s!==t.previewPixels||s>n.maxResourcePreviewPixels)throw new Error("ABR decoded preview pixels do not match the bounded preflight result.");if(r!==t.decodedBytes||r>n.maxDecodedBytes)throw new Error("ABR decoded byte count does not match the bounded preflight result.");return{format:"abr",version:`${t.majorVersion}.${t.minorVersion}`,engine:"ag-psd",fidelity:"decoded-tip-and-metadata-preview",brushes:i.brushes.map(c=>sy(c,n)),samples:a,patterns:l,limitations:["The preview shows decoded tip alpha, embedded pattern pixels, and preset metadata; it does not simulate a painted stroke.","The bounded decoder rejects legacy ABR versions 1 and 2 and 16-bit RLE brush samples."]}},Ne=e=>{let n=Math.abs(e)<1e-9?0:e;return Number(n.toFixed(4)).toString()},ly=(e,n)=>{if(!e.knots.length)return{d:"",fillRule:e.fillRule,...e.operation?{operation:e.operation}:{}};let t=e.knots.map((r,s)=>{if(r.points.length!==6||r.points.some(a=>!Number.isFinite(a)))throw new Error(`${n} knot ${s} has invalid Bezier coordinates.`);return r.points}),i=t[0],o=`M ${Ne(i[2])} ${Ne(i[3])}`;for(let r=1;r<t.length;r+=1){let s=t[r-1],a=t[r];o+=` C ${Ne(s[4])} ${Ne(s[5])} ${Ne(a[0])} ${Ne(a[1])} ${Ne(a[2])} ${Ne(a[3])}`}if(!e.open){let r=t.at(-1);o+=` C ${Ne(r[4])} ${Ne(r[5])} ${Ne(i[0])} ${Ne(i[1])} ${Ne(i[2])} ${Ne(i[3])} Z`}return{d:o,fillRule:e.fillRule,...e.operation?{operation:e.operation}:{}}},cy=(e,n)=>{let t=Yd(e,n),i=(0,To.readCsh)(new Uint8Array(e),{totalMemoryLimit:n.maxDecodedBytes});if(i.shapes.length!==t.shapes)throw new Error("CSH decoded shape count does not match its bounded preflight result.");let o=0,r=0,s=Math.min(1e6,n.maxResourceItems*64);return{format:"csh",version:"2",engine:"ag-psd",fidelity:"vector-path-preview",shapes:i.shapes.map((l,c)=>{if(!Number.isSafeInteger(l.width)||!Number.isSafeInteger(l.height)||l.width<=0||l.height<=0)throw new Error(`CSH shape ${c} has invalid dimensions.`);o+=l.paths.length;let f=l.paths.map((u,d)=>(r+=u.knots.length,ly(u,`CSH shape ${c} path ${d}`)));if(o+r>s)throw new Error(`CSH decoded path complexity exceeds the ${s}-record safety limit.`);return{id:pn(l.id,n,`CSH shape ${c} id`),name:pn(l.name,n,`CSH shape ${c} name`),width:l.width,height:l.height,paths:f,hasUnsupportedBooleanComposition:l.paths.some(u=>u.operation&&u.operation!=="combine")}}),limitations:["Bezier geometry is preserved, but Photoshop exclude/subtract/intersect path operations are exposed as metadata rather than rasterized with Photoshop composition semantics.","The preview does not include Photoshop tool presets, fills, strokes, or effects because CSH stores custom-shape paths rather than a styled document."]}},Jd=(e,n,t)=>n==="abr"?ay(e,t):cy(e,t);var fy=(e,n,t)=>{let i=e*n;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t} exceeds the safe integer range.`);return i},dy=(e,n)=>{if(!Number.isFinite(e))throw new Error(`${n} is not finite.`);return e},Xn=class{bytes;view;offset=0;constructor(n){this.bytes=n instanceof Uint8Array?n:new Uint8Array(n),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength)}get length(){return this.bytes.byteLength}get remaining(){return this.length-this.offset}ensure(n,t=this.length,i="Adobe binary data"){if(!Number.isSafeInteger(n)||n<0||this.offset>t||n>t-this.offset)throw new Error(`${i} is truncated.`)}u8(n=this.length,t){return this.ensure(1,n,t),this.view.getUint8(this.offset++)}u16(n=this.length,t){this.ensure(2,n,t);let i=this.view.getUint16(this.offset,!1);return this.offset+=2,i}i16(n=this.length,t){this.ensure(2,n,t);let i=this.view.getInt16(this.offset,!1);return this.offset+=2,i}u32(n=this.length,t){this.ensure(4,n,t);let i=this.view.getUint32(this.offset,!1);return this.offset+=4,i}i32(n=this.length,t){this.ensure(4,n,t);let i=this.view.getInt32(this.offset,!1);return this.offset+=4,i}i64(n=this.length,t){this.ensure(8,n,t);let i=this.view.getBigInt64(this.offset,!1);return this.offset+=8,i}f64(n=this.length,t){this.ensure(8,n,t);let i=this.view.getFloat64(this.offset,!1);return this.offset+=8,dy(i,t||"Adobe double")}ascii(n,t=this.length,i="Adobe ASCII data"){this.ensure(n,t,i);let o="";for(let r=0;r<n;r+=1)o+=String.fromCharCode(this.bytes[this.offset+r]);return this.offset+=n,o}slice(n,t=this.length,i="Adobe binary data"){this.ensure(n,t,i);let o=this.bytes.subarray(this.offset,this.offset+n);return this.offset+=n,o}skip(n,t=this.length,i="Adobe binary data"){this.ensure(n,t,i),this.offset+=n}},Pi=(e,n,t,i)=>{let o=e.u32(n,`${i} length`);if(o>t.maxResourceNameCodeUnits+1)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-code-unit safety limit.`);let r=e.slice(fy(o,2,`${i} bytes`),n,i),s="";for(let a=0;a<o;a+=1){let l=r[a*2]<<8|r[a*2+1];if(!(l===0&&a===o-1))if(l>=55296&&l<=56319){if(a+1>=o)throw new Error(`${i} ends with an unpaired UTF-16 surrogate.`);let c=r[(a+1)*2]<<8|r[(a+1)*2+1];if(c<56320||c>57343)throw new Error(`${i} contains an invalid UTF-16 surrogate pair.`);s+=String.fromCodePoint(65536+(l-55296<<10)+(c-56320)),a+=1}else{if(l>=56320&&l<=57343)throw new Error(`${i} contains an unpaired UTF-16 surrogate.`);s+=String.fromCharCode(l)}}if(s.length>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-code-unit safety limit.`);return s},Kt=(e,n,t,i)=>{let o=e.u32(n,`${i} length`),r=o===0?4:o;if(r===0||r>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-byte safety limit.`);return e.ascii(r,n,i)},Ci=(e,n,t)=>{if(!Number.isSafeInteger(n)||n<0||n>e.maximum-e.values)throw new Error(`${t} exceeds the ${e.maximum}-value descriptor safety limit.`);e.values+=n},Qd=(e,n,t,i)=>({name:Pi(e,n,t,`${i} name`),classId:Kt(e,n,t,`${i} id`)}),uy=(e,n,t,i)=>{let o=e.u32(n,"Adobe reference count");Ci(i,o,"Adobe reference count");let r=[];for(let s=0;s<o;s+=1){let a=e.ascii(4,n,"Adobe reference form"),{name:l,classId:c}=Qd(e,n,t,"Adobe reference class"),f={form:a,className:l,classId:c};if(a==="prop")f.property=Kt(e,n,t,"Adobe reference property");else if(a==="Enmr")f.enumType=Kt(e,n,t,"Adobe reference enum type"),f.enumValue=Kt(e,n,t,"Adobe reference enum value");else if(a==="rele"||a==="Idnt"||a==="indx")f.index=e.i32(n,"Adobe reference index");else if(a==="name")f.name=Pi(e,n,t,"Adobe reference name");else if(a!=="Clss")throw new Error(`Unsupported Adobe reference form ${JSON.stringify(a)}.`);r.push(f)}return r},py=(e,n,t)=>{let i=e.u32(n,"Adobe descriptor path length");if(i>t.maxDecodedBytes)throw new Error(`Adobe descriptor path exceeds the ${t.maxDecodedBytes}-byte safety limit.`);return e.skip(i,n,"Adobe descriptor path"),{type:"path",length:i}},eu=(e,n,t,i,o,r)=>{if(r>i.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${i.maxNestingDepth}-level safety limit.`);switch(t){case"bool":return{type:"boolean",value:e.u8(n,"Adobe boolean")!==0};case"long":return{type:"integer",value:e.i32(n,"Adobe integer")};case"comp":return{type:"large-integer",value:e.i64(n,"Adobe large integer")};case"doub":return{type:"double",value:e.f64(n,"Adobe double")};case"UntF":return{type:"unit-double",unit:e.ascii(4,n,"Adobe unit"),value:e.f64(n,"Adobe unit double")};case"TEXT":return{type:"text",value:Pi(e,n,i,"Adobe descriptor text")};case"enum":return{type:"enum",enumType:Kt(e,n,i,"Adobe enum type"),value:Kt(e,n,i,"Adobe enum value")};case"Objc":case"GlbO":return{type:"object",value:hn(e,n,i,o,r+1)};case"VlLs":{let s=e.u32(n,"Adobe list count");Ci(o,s,"Adobe list count");let a=[];for(let l=0;l<s;l+=1)a.push(eu(e,n,e.ascii(4,n,"Adobe list value type"),i,o,r+1));return{type:"list",value:a}}case"alis":case"tdta":{let s=e.u32(n,"Adobe raw data length");if(s>i.maxDecodedBytes)throw new Error(`Adobe raw data exceeds the ${i.maxDecodedBytes}-byte safety limit.`);return e.skip(s,n,"Adobe raw data"),{type:"raw",length:s,alias:t==="alis"}}case"type":case"GlbC":{let s=Qd(e,n,i,"Adobe class reference");return{type:"class",name:s.name,classId:s.classId}}case"UnFl":{let s=e.ascii(4,n,"Adobe unit-float-array unit"),a=e.u32(n,"Adobe unit-float-array count");Ci(o,a,"Adobe unit-float-array count");let l=Array.from({length:a},()=>e.f64(n,"Adobe unit-float-array value"));return{type:"unit-double-array",unit:s,value:l}}case"ObAr":{let s=e.u32(n,"Adobe object-array count");return Ci(o,s,"Adobe object-array count"),{type:"object-array",count:s,value:hn(e,n,i,o,r+1)}}case"obj ":return{type:"reference",value:uy(e,n,i,o)};case"Pth ":return py(e,n,i);default:throw new Error(`Unsupported Adobe descriptor value type ${JSON.stringify(t)}.`)}},Di=e=>{let n=Number.isSafeInteger(e.maxResourceItems)&&e.maxResourceItems>0?Math.min(1e6,e.maxResourceItems):1;return{values:0,maximum:n>3906?1e6:n*256}},hn=(e,n,t,i=Di(t),o=0)=>{if(o>t.maxNestingDepth)throw new Error(`Adobe descriptor nesting exceeds the ${t.maxNestingDepth}-level safety limit.`);let r=Pi(e,n,t,"Adobe descriptor name"),s=Kt(e,n,t,"Adobe descriptor class"),a=e.u32(n,"Adobe descriptor item count");Ci(i,a,"Adobe descriptor item count");let l=new Map,c=[];for(let f=0;f<a;f+=1){let u=Kt(e,n,t,"Adobe descriptor key");if(l.has(u))throw new Error(`Adobe descriptor contains duplicate key ${JSON.stringify(u)}.`);let d=e.ascii(4,n,"Adobe descriptor value type");l.set(u,eu(e,n,d,t,i,o+1)),c.push(u)}return{name:r,classId:s,entries:l,keys:c}},Me=(e,n)=>e?.entries.get(n),Oi=(e,n)=>{let t=Me(e,n);return t?.type==="object"?t.value:void 0},gn=(e,n)=>{let t=Me(e,n);return t?.type==="text"?t.value:void 0},Ei=(e,n)=>{let t=Me(e,n);return t?.type==="enum"?t.value:void 0},Fi=(e,n,t=!1)=>{let i=Me(e,n);return i?.type==="boolean"?i.value:t},Ie=(e,n,t=0)=>{let i=Me(e,n);return i?i.type==="integer"||i.type==="double"||i.type==="unit-double"?i.value:i.type==="large-integer"?Number(i.value):t:t},tu=Pi;var hy=["maxFileBytes","maxCanvasPixels","maxCanvasDimension","maxLayers","maxNestingDepth","maxLayerPixels","maxDecodedBytes","maxLayerCacheBytes","maxResourceItems","maxResourceNameCodeUnits","maxResourcePreviewPixels"],gy=e=>{for(let n of hy){let t=e[n];if(!Number.isSafeInteger(t)||t<=0)throw new Error(`Invalid Adobe preset safety limit ${n}.`)}},ru=e=>e+3&-4,ct=(e,n,t)=>{let i=e+n;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t} exceeds the safe integer range.`);return i},zo=(e,n,t)=>{let i=e*n;if(!Number.isSafeInteger(i)||i<0)throw new Error(`${t} exceeds the safe integer range.`);return i},ea=(e,n,t)=>{if(e.byteLength>n.maxFileBytes)throw new Error(`${t} source exceeds the ${n.maxFileBytes}-byte safety limit.`);if(!e.byteLength)throw new Error(`${t} source is empty.`)},su=(e,n,t,i,o)=>{if(e.previewPixels=ct(e.previewPixels,n,`${o} preview pixels`),e.decodedBytes=ct(e.decodedBytes,t,`${o} decoded bytes`),e.previewPixels>i.maxResourcePreviewPixels)throw new Error(`${o} exceeds the ${i.maxResourcePreviewPixels}-pixel preview safety limit.`);if(e.decodedBytes>i.maxDecodedBytes)throw new Error(`${o} exceeds the ${i.maxDecodedBytes}-byte decoded-data safety limit.`)},my=(e,n,t,i)=>{let o=e.u8(n,`${i} length`);if(o>t.maxResourceNameCodeUnits)throw new Error(`${i} exceeds the ${t.maxResourceNameCodeUnits}-byte safety limit.`);let r=e.ascii(o,n,i),s=r.length;for(;s>0&&r.charCodeAt(s-1)===0;)s-=1;return r.slice(0,s)},yy=(e,n,t,i,o,r)=>{let s=Array.from({length:i},(l,c)=>e.u16(n,`${r} row ${c} length`)),a=o?new Uint8Array(zo(t,i,`${r} pixels`)):void 0;for(let l=0;l<i;l+=1){let c=ct(e.offset,s[l],`${r} row ${l} end`);if(c>n)throw new Error(`${r} compressed row ${l} is truncated.`);let f=0;for(;e.offset<c;){let u=e.u8(c,`${r} PackBits header`);if(u<=127){let d=u+1,p=e.slice(d,c,`${r} PackBits literal`);if(f+d>t)throw new Error(`${r} row ${l} expands beyond its declared width.`);a&&a.set(p,l*t+f),f+=d}else if(u>=129){let d=257-u,p=e.u8(c,`${r} PackBits repeat value`);if(f+d>t)throw new Error(`${r} row ${l} expands beyond its declared width.`);a?.fill(p,l*t+f,l*t+f+d),f+=d}}if(f!==t)throw new Error(`${r} row ${l} expands to ${f} instead of ${t} pixels.`)}if(e.offset!==n)throw new Error(`${r} has trailing compressed bytes.`);return a},by=(e,n,t,i,o,r,s)=>{let a=zo(t,i,`${s} pixels`);if(o===0){if(e.offset+a!==n)throw new Error(`${s} raw byte length does not match its dimensions.`);return r?Uint8Array.from(e.slice(a,n,s)):(e.skip(a,n,s),void 0)}if(o===1)return yy(e,n,t,i,r,s);throw new Error(`${s} uses unsupported compression mode ${o}.`)},nu=(e,n,t,i,o,r,s,a)=>{for(let l=0;l<i.height;l+=1)for(let c=0;c<i.width;c+=1){let f=l*i.width+c,u=((i.top-n.top+l)*n.width+i.left-n.left+c)*4,d=t[f];r===1&&o===0?(e[u]=d,e[u+1]=d,e[u+2]=d):r===2&&o===0&&s?(e[u]=s[d*3],e[u+1]=s[d*3+1],e[u+2]=s[d*3+2],a&&(a[(i.top-n.top+l)*n.width+i.left-n.left+c]=d)):e[u+o]=d}},au=(e,n,t,i,o,r)=>{if(e.u32(n,`PAT pattern ${r} version`)!==1)throw new Error(`PAT pattern ${r} uses an unsupported record version.`);let s=e.u32(n,`PAT pattern ${r} color mode`);if(s!==1&&s!==2&&s!==3)throw new Error(`PAT pattern ${r} uses unsupported color mode ${s}; only 8-bit grayscale, indexed, and RGB tiles are decoded.`);let a=e.i16(n,`PAT pattern ${r} vertical value`),l=e.i16(n,`PAT pattern ${r} horizontal value`),c=tu(e,n,t,`PAT pattern ${r} name`),f=my(e,n,t,`PAT pattern ${r} id`);if(!f)throw new Error(`PAT pattern ${r} has an empty unique id.`);let u,d=65535;if(s===2&&(u=Uint8Array.from(e.slice(768,n,`PAT pattern ${r} indexed palette`)),o?(e.u16(n,`PAT pattern ${r} indexed color count`),d=e.u16(n,`PAT pattern ${r} transparent palette index`)):e.skip(4,n,`PAT pattern ${r} indexed footer`)),e.u32(n,`PAT pattern ${r} VMAL version`)!==3)throw new Error(`PAT pattern ${r} uses an unsupported VMAL version.`);let p=e.u32(n,`PAT pattern ${r} VMAL length`),h=ct(e.offset,p,`PAT pattern ${r} VMAL end`);if(h>n)throw new Error(`PAT pattern ${r} VMAL is truncated.`);let m=e.i32(h,`PAT pattern ${r} top`),y=e.i32(h,`PAT pattern ${r} left`),g=e.i32(h,`PAT pattern ${r} bottom`),k=e.i32(h,`PAT pattern ${r} right`),x=k-y,S=g-m,A=e.u32(h,`PAT pattern ${r} channel count`);if(x<=0||S<=0||x>t.maxCanvasDimension||S>t.maxCanvasDimension)throw new Error(`PAT pattern ${r} dimensions exceed the ${t.maxCanvasDimension}-pixel side safety limit.`);if(o&&(l!==x||a!==S))throw new Error(`PAT pattern ${r} header dimensions disagree with its decoded VMAL bounds.`);if(A>64)throw new Error(`PAT pattern ${r} channel count exceeds the 64-channel safety limit.`);let D=zo(x,S,`PAT pattern ${r} pixels`);su(i,D,zo(D,4,`PAT pattern ${r} RGBA bytes`),t,`PAT pattern ${r}`);let C=new Uint8Array(D*4);for(let R=3;R<C.length;R+=4)C[R]=255;let O=s===2?new Uint8Array(D):void 0,E=s===3?3:1,L=new Set,M=!1,J={top:m,left:y,width:x,height:S};for(let R=0;R<A+2;R+=1){let ie=e.u32(h,`PAT pattern ${r} channel ${R} presence`);if(!ie)continue;if(ie!==1)throw new Error(`PAT pattern ${r} channel ${R} has an invalid presence marker.`);let he=e.u32(h,`PAT pattern ${r} channel ${R} length`);if(he<23)throw new Error(`PAT pattern ${r} channel ${R} is shorter than its header.`);let ce=ct(e.offset,he,`PAT pattern ${r} channel ${R} end`);if(ce>h)throw new Error(`PAT pattern ${r} channel ${R} is truncated.`);let Ce=e.u32(ce,`PAT pattern ${r} channel ${R} depth`),W=e.i32(ce,`PAT pattern ${r} channel ${R} top`),B=e.i32(ce,`PAT pattern ${r} channel ${R} left`),$=e.i32(ce,`PAT pattern ${r} channel ${R} bottom`),ne=e.i32(ce,`PAT pattern ${r} channel ${R} right`),ge=e.u16(ce,`PAT pattern ${r} channel ${R} depth copy`),Q=e.u8(ce,`PAT pattern ${r} channel ${R} compression`);if(Ce!==8||ge!==8)throw new Error(`PAT pattern ${r} channel ${R} is not 8-bit.`);if(W<m||B<y||$>g||ne>k||$<=W||ne<=B)throw new Error(`PAT pattern ${r} channel ${R} bounds are outside the tile.`);let ee=ne-B,be=$-W,Se=R<E,xe=R===A+1,jt=by(e,ce,ee,be,Q,Se||xe,`PAT pattern ${r} channel ${R}`);jt&&Se?(L.add(R),nu(C,J,jt,{top:W,left:B,width:ee,height:be},R,s,u,O)):jt&&xe&&(M=!0,nu(C,J,jt,{top:W,left:B,width:ee,height:be},3,s))}if(e.offset!==h)throw new Error(`PAT pattern ${r} VMAL has trailing or unparsed bytes.`);if(L.size!==E)throw new Error(`PAT pattern ${r} is missing one or more required color planes.`);if(s===2&&!M&&d<256&&O)for(let R=0;R<O.length;R+=1)O[R]===d&&(C[R*4+3]=0);let pe=!1;for(let R=0;R<D;R+=1)if(C[R*4+3]!==255){pe=!0;break}return{name:c||`Pattern ${r}`,id:f,width:x,height:S,colorMode:s===1?"grayscale":s===2?"indexed":"rgb",rgba:C,hasTransparency:pe}},wy=(e,n,t,i)=>{let o=[];for(;e.offset<n;){if(o.length>=t.maxResourceItems)throw new Error(`Embedded pattern count exceeds the ${t.maxResourceItems}-item safety limit.`);let r=e.u32(n,"Embedded PAT record length"),s=ct(e.offset,r,"Embedded PAT record end"),a=ct(e.offset,ru(r),"Embedded PAT padded end");if(!r||s>n||a>n)throw new Error("Embedded PAT record is truncated.");if(o.push(au(e,s,t,i,!1,o.length+1)),e.offset!==s)throw new Error(`Embedded PAT pattern ${o.length} length does not match its decoded payload.`);for(let l of e.slice(a-s,a,"Embedded PAT padding"))if(l!==0)throw new Error(`Embedded PAT pattern ${o.length} has non-zero alignment bytes.`)}if(e.offset!==n)throw new Error("Embedded PAT block length is invalid.");return o},vy=(e,n)=>{ea(e,n,"PAT");let t=new Xn(e);if(t.ascii(4,t.length,"PAT signature")!=="8BPT")throw new Error("Invalid Photoshop PAT signature.");if(t.u16(t.length,"PAT version")!==1)throw new Error("Unsupported Photoshop PAT version; expected version 1.");let i=t.u32(t.length,"PAT pattern count");if(!i||i>n.maxResourceItems)throw new Error(`PAT pattern count must be between 1 and ${n.maxResourceItems}.`);let o={previewPixels:0,decodedBytes:0},r=Array.from({length:i},(s,a)=>au(t,t.length,n,o,!0,a+1));return na(t,n,Di(n),r.length),{format:"pat",version:"1",engine:"file-viewer-native",fidelity:"decoded-pattern-tile",patterns:r,limitations:["The renderer decodes Photoshop PAT v1 grayscale, indexed, and RGB tiles with 8-bit raw or PackBits planes; CMYK, Lab, multichannel, 16-bit, and 32-bit pattern records are rejected.","Tile pixels and transparency are preserved. Photoshop pattern transforms, fills, layer blending, and color-management behavior are outside a standalone PAT library."]}},Ue=(e,n,t,i)=>{if(!Number.isFinite(e)||e<n||e>t)throw new Error(`${i} is outside ${n}\u2026${t}.`);return e},$e=e=>Math.max(0,Math.min(255,Math.round(e))),Sy=(e,n,t)=>{let i=(e%360+360)%360/60,o=Math.max(0,Math.min(1,n/100)),r=Math.max(0,Math.min(1,t/100)),s=r*o,a=s*(1-Math.abs(i%2-1)),l=r-s;return(i<1?[s,a,0]:i<2?[a,s,0]:i<3?[0,s,a]:i<4?[0,a,s]:i<5?[a,0,s]:[s,0,a]).map(f=>$e((f+l)*255))},xy=(e,n,t)=>{let i=.20689655172413793,o=p=>p>i?p**3:3*i*i*(p-4/29),r=(e+16)/116,s=.96422*o(r+n/500),a=o(r),l=.82521*o(r-t/200),c=.9555766*s-.0230393*a+.0631636*l,f=-.0282895*s+1.0099416*a+.0210077*l,u=.0122982*s-.020483*a+1.3299098*l;return[3.2404542*c-1.5371385*f-.4985314*u,-.969266*c+1.8760108*f+.041556*u,.0556434*c-.2040259*f+1.0572252*u].map(p=>$e((p<=.0031308?12.92*p:1.055*Math.max(0,p)**(1/2.4)-.055)*255))},ky=e=>{if(!e)return{rgb:[0,0,0],colorSpace:"unknown"};if(e.classId==="RGBC")return{rgb:[$e(Ie(e,"Rd ")),$e(Ie(e,"Grn ")),$e(Ie(e,"Bl "))],colorSpace:"rgb"};if(e.classId==="Grsc"){let n=$e(Ue(Ie(e,"Gry "),0,100,"GRD gray")*2.55);return{rgb:[n,n,n],colorSpace:"gray"}}if(e.classId==="HSBC"||e.classId==="HSBl")return{rgb:Sy(Ie(e,"H "),Ie(e,"Strt"),Ie(e,"Brgh")),colorSpace:"hsb"};if(e.classId==="LbCl")return{rgb:xy(Ie(e,"Lmnc"),Ie(e,"A "),Ie(e,"B ")),colorSpace:"lab"};if(e.classId==="CMYC"){let n=Ue(Ie(e,"Cyn "),0,100,"GRD cyan")/100,t=Ue(Ie(e,"Mgnt"),0,100,"GRD magenta")/100,i=Ue(Ie(e,"Ylw "),0,100,"GRD yellow")/100,o=Ue(Ie(e,"Blck"),0,100,"GRD black")/100;return{rgb:[$e((1-n)*(1-o)*255),$e((1-t)*(1-o)*255),$e((1-i)*(1-o)*255)],colorSpace:"cmyk"}}return{rgb:[0,0,0],colorSpace:"unknown"}},Qs=(e,n,t)=>{if(!e||e.type!=="list")throw new Error(`${n} list is missing.`);if(e.value.length>t)throw new Error(`${n} exceeds the ${t}-item safety limit.`);return e.value.map((i,o)=>{if(i.type!=="object")throw new Error(`${n} item ${o+1} is not an object.`);return i.value})},_y=(e,n)=>e<=n?n<=0?.5:.5*e/n:n>=1?.5:.5+.5*(e-n)/(1-n),iu=(e,n,t)=>{if(n<=e[0].location)return e[0].value;if(n>=e.at(-1).location)return e.at(-1).value;let i=e.findIndex(l=>l.location>=n),o=e[i-1],r=e[i],s=Math.max(1e-9,r.location-o.location),a=_y((n-o.location)/s,Math.max(.001,Math.min(.999,o.midpoint)));return Array.from({length:t},(l,c)=>o.value[c]+(r.value[c]-o.value[c])*a)},Ay=(e,n)=>{let t=new Uint8Array(1024),i=e.map(r=>({location:r.location,midpoint:r.midpoint,value:r.rgb})),o=n.map(r=>({location:r.location,midpoint:r.midpoint,value:[r.opacity]}));for(let r=0;r<256;r+=1){let s=r/255,a=iu(i,s,3),l=iu(o,s,1)[0];t.set([$e(a[0]),$e(a[1]),$e(a[2]),$e(l*255)],r*4)}return t},ou=(e,n,t)=>{let i=Me(e,n),o=i?.type==="list"?i.value:[];return[0,1,2,3].map(r=>{let s=o[r];return s?.type==="integer"?Ue(s.value,0,100,`GRD ${n} range`):t})},Iy=(e,n,t,i)=>{let o=new Uint8Array(1024),r=e>>>0||2654435769,s=()=>(r^=r<<13,r^=r>>>17,r^=r<<5,(r>>>0)/4294967295);for(let a=0;a<256;a+=1){for(let l=0;l<3;l+=1)o[a*4+l]=$e((n[l]+s()*(t[l]-n[l]))*2.55);o[a*4+3]=i?$e((n[3]+s()*(t[3]-n[3]))*2.55):255}return o},ta=e=>{if(!e.startsWith("$$$/"))return e;let n=e.lastIndexOf("=");if(n>=0&&n+1<e.length)return e.slice(n+1);let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e},Cy=(e,n,t,i)=>{su(i,256,1024,t,`GRD gradient ${n}`);let o=Oi(e,"Grad")||e,r=ta(gn(o,"Nm ")||`Gradient ${n}`),s=Ei(o,"GrdF")||"CstS";if(s==="ClNs"){let u=ou(o,"Mnm ",0),d=ou(o,"Mxm ",100);d.forEach((k,x)=>{if(k<u[x])throw new Error(`${r}: noise maximum is below its minimum.`)});let p=Ue(Ie(o,"RndS",0),0,4294967295,`${r} random seed`),h=Ue(Ie(o,"Smth",2048),0,4096,`${r} roughness`),m=Ei(o,"ClrS")||"RGBC",y=m==="HSBl"||m==="HSBC"?"hsb":m==="LbCl"||m==="LABC"?"lab":"rgb",g=Fi(o,"ShTr",!1);return{name:r,definition:{form:"noise",seed:p,roughness:h,colorModel:y,restrictColors:Fi(o,"VctC",!0),addTransparency:g,minimum:u,maximum:d},previewRgba:Iy(p,u,d,g)}}if(s!=="CstS")throw new Error(`${r}: unsupported GRD gradient form ${JSON.stringify(s)}.`);let l=Qs(Me(o,"Clrs"),`${r} color stops`,Math.min(256,t.maxResourceItems)).map((u,d)=>{let p=Ue(Ie(u,"Lctn")/4096,0,1,`${r} color stop ${d+1} location`),h=Ue(Ie(u,"Mdpn",50)/100,0,1,`${r} color stop ${d+1} midpoint`),m=Ei(u,"Type")||"UsrS",y=m==="FrgC"?"foreground":m==="BckC"?"background":"user",g=y==="foreground"?{rgb:[0,0,0],colorSpace:"unknown"}:y==="background"?{rgb:[255,255,255],colorSpace:"unknown"}:ky(Oi(u,"Clr "));if(y==="user"&&g.colorSpace==="unknown")throw new Error(`${r} color stop ${d+1} uses an unsupported color object.`);return{location:p,midpoint:h,kind:y,...g}}).sort((u,d)=>u.location-d.location);if(l.length<2)throw new Error(`${r} has fewer than two usable color stops.`);let c=Me(o,"Trns"),f=c?Qs(c,`${r} transparency stops`,Math.min(256,t.maxResourceItems)).map((u,d)=>({location:Ue(Ie(u,"Lctn")/4096,0,1,`${r} alpha stop ${d+1} location`),midpoint:Ue(Ie(u,"Mdpn",50)/100,0,1,`${r} alpha stop ${d+1} midpoint`),opacity:Ue(Ie(u,"Opct",100)/100,0,1,`${r} alpha stop ${d+1} opacity`)})).sort((u,d)=>u.location-d.location):[{location:0,midpoint:.5,opacity:1},{location:1,midpoint:.5,opacity:1}];if(!f.length)throw new Error(`${r} declares an empty transparency-stop list.`);return{name:r,definition:{form:"solid",smoothness:Ue(Ie(o,"Intr",4096),0,4096,`${r} smoothness`),colorStops:l,alphaStops:f},previewRgba:Ay(l,f)}},Py=(e,n)=>{let t=Me(e,"hierarchy");if(!t||t.type!=="list")return Array.from({length:n},()=>"");let i=Array.from({length:n},()=>""),o=[],r=0;for(let s of t.value)s.type==="object"&&(s.value.classId==="Grup"?o.push(ta(gn(s.value,"Nm ")||"")):s.value.classId==="groupEnd"?o.pop():s.value.classId==="preset"&&r<i.length&&(i[r++]=o.filter(Boolean).join(" / ")));return i},na=(e,n,t,i)=>{if(!e.remaining)return Array.from({length:i},()=>"");if(e.remaining<12||e.ascii(4,e.length,"Adobe hierarchy signature")!=="8BIM"||e.ascii(4,e.length,"Adobe hierarchy key")!=="phry")throw new Error("Adobe preset file has unrecognized trailing data.");let o=e.u32(e.length,"Adobe hierarchy length"),r=ct(e.offset,o,"Adobe hierarchy end");if(r>e.length)throw new Error("Adobe hierarchy data is truncated.");if(e.u32(r,"Adobe hierarchy descriptor version")!==16)throw new Error("Unsupported Adobe hierarchy descriptor version.");let s=hn(e,r,n,t);if(e.offset!==r)throw new Error("Adobe hierarchy descriptor has trailing bytes.");if(e.remaining)throw new Error("Adobe preset file has bytes after its hierarchy data.");return Py(s,i)},Dy=(e,n)=>{ea(e,n,"GRD");let t=new Xn(e);if(t.ascii(4,t.length,"GRD signature")!=="8BGR")throw new Error("Invalid Photoshop GRD signature.");if(t.u16(t.length,"GRD version")!==5)throw new Error("Unsupported Photoshop GRD version; only descriptor-based version 5 is decoded.");if(t.u32(t.length,"GRD descriptor version")!==16)throw new Error("Unsupported GRD Action Descriptor version.");let i=Di(n),o=hn(t,t.length,n,i),r={previewPixels:0,decodedBytes:0},s=Qs(Me(o,"GrdL"),"GRD gradients",n.maxResourceItems).map((l,c)=>Cy(l,c+1,n,r));if(!s.length)throw new Error("GRD file contains no gradients.");let a=na(t,n,i,s.length);return s.forEach((l,c)=>{a[c]&&(l.folder=a[c])}),{format:"grd",version:"5",engine:"file-viewer-native",fidelity:"solid-stop-preview-noise-approximation",gradients:s,limitations:["Solid-gradient stops, midpoint positions, transparency, names, and folders are preserved. Foreground/background stops use black/white because their final colors depend on Photoshop application state.","Noise-gradient metadata is preserved, but the thumbnail is a deterministic approximation; Photoshop does not publish its exact noise synthesis and color-management pipeline."]}},Oy=[{single:"DrSh",multi:"dropShadowMulti",kind:"drop-shadow"},{single:"IrSh",multi:"innerShadowMulti",kind:"inner-shadow"},{single:"OrGl",multi:"outerGlowMulti",kind:"outer-glow"},{single:"IrGl",multi:"innerGlowMulti",kind:"inner-glow"},{single:"ChFX",multi:"chromeFXMulti",kind:"satin"},{single:"ebbl",multi:"bevelEmbossMulti",kind:"bevel-emboss"},{single:"SoFi",multi:"solidFillMulti",kind:"color-overlay"},{single:"GrFl",multi:"gradientFillMulti",kind:"gradient-overlay"},{single:"patternFill",multi:"patternFillMulti",kind:"pattern-overlay"},{single:"FrFX",multi:"frameFXMulti",kind:"stroke"}],Ey=e=>{if(!e)return[];let n=[];for(let t of Oy){let i=Me(e,t.single),o=Me(e,t.multi),r=[];if(i?.type==="object"&&r.push(i.value),o?.type==="list")for(let s of o.value)s.type==="object"&&r.push(s.value);r.length&&n.push({kind:t.kind,enabled:r.some(s=>Fi(s,"enab",!0)),instances:r.length})}return n},jo=(e,n)=>{if(e.type==="object"){n(e.value);for(let t of e.value.entries.values())jo(t,n)}else if(e.type==="list")e.value.forEach(t=>jo(t,n));else if(e.type==="object-array"){n(e.value);for(let t of e.value.entries.values())jo(t,n)}},Fy=e=>{let n=new Map;if(!e)return[];let t=i=>{if(i.classId!=="Ptrn"&&!i.entries.has("Idnt"))return;let o=gn(i,"Idnt")||"",r=gn(i,"Nm ")||"";o&&n.set(o,{name:r,id:o})};t(e);for(let i of e.entries.values())jo(i,t);return[...n.values()]},Ly=(e,n,t,i,o)=>{if(e.u32(n,`ASL style ${o} identity descriptor version`)!==16)throw new Error(`ASL style ${o} uses an unsupported identity descriptor version.`);let r=hn(e,n,t,i),s=ta(gn(r,"Nm ")||""),a=gn(r,"Idnt")||"";if(!s||!a)throw new Error(`ASL style ${o} is missing its name or unique id.`);if(e.u32(n,`ASL style ${o} effect descriptor version`)!==16)throw new Error(`ASL style ${o} uses an unsupported effect descriptor version.`);let l=hn(e,n,t,i),c=Oi(l,"Lefx"),f=Oi(l,"blendOptions"),u=Me(f,"Blnd"),d={name:s,id:a,effectsVisible:Fi(c,"masterFXSwitch",!0),effects:Ey(c),blendIfChannels:u?.type==="list"?u.value.length:0,referencedPatterns:Fy(c)},p=Ei(f,"Md ");p&&(d.blendMode=p);let h=Me(f,"Opct");(h?.type==="unit-double"||h?.type==="double"||h?.type==="integer")&&(d.opacity=Ue(h.value,0,100,`${s} opacity`));let m=Me(f,"fillOpacity");if((m?.type==="unit-double"||m?.type==="double"||m?.type==="integer")&&(d.fillOpacity=Ue(m.value,0,100,`${s} fill opacity`)),!d.effects.length&&!f)throw new Error(`${s} contains no supported effect graph or blending options.`);return d},My=(e,n)=>{ea(e,n,"ASL");let t=new Xn(e);if(t.u16(t.length,"ASL version")!==2)throw new Error("Unsupported Photoshop ASL version; expected version 2.");if(t.ascii(4,t.length,"ASL signature")!=="8BSL")throw new Error("Invalid Photoshop ASL signature.");if(t.u16(t.length,"ASL pattern section version")!==3)throw new Error("Unsupported ASL embedded-pattern section version.");let i=t.u32(t.length,"ASL embedded-pattern section length"),o=ct(t.offset,i,"ASL embedded-pattern section end");if(o>t.length)throw new Error("ASL embedded-pattern section is truncated.");let s=i?wy(t,o,n,{previewPixels:0,decodedBytes:0}):[],a=t.u32(t.length,"ASL style count");if(!a||a>n.maxResourceItems)throw new Error(`ASL style count must be between 1 and ${n.maxResourceItems}.`);let l=Di(n),c=[];for(let f=0;f<a;f+=1){let u=t.u32(t.length,`ASL style ${f+1} length`),d=ct(t.offset,u,`ASL style ${f+1} end`),p=ct(t.offset,ru(u),`ASL style ${f+1} padded end`);if(!u||d>t.length||p>t.length)throw new Error(`ASL style ${f+1} record is truncated.`);c.push(Ly(t,d,n,l,f+1));for(let h of t.slice(d-t.offset,d,`ASL style ${f+1} padding`))if(h!==0)throw new Error(`ASL style ${f+1} has unparsed non-zero bytes.`);for(let h of t.slice(p-d,p,`ASL style ${f+1} alignment`))if(h!==0)throw new Error(`ASL style ${f+1} has non-zero alignment bytes.`)}return na(t,n,l,c.length),{format:"asl",version:"2",engine:"file-viewer-native",fidelity:"effect-graph-metadata-preview",styles:c,patterns:s,limitations:["Names, ids, effect graph presence, multi-effect counts, blending options, pattern references, and embedded pattern tiles are decoded. The preview does not claim Photoshop layer rasterization.","Exact layer-style appearance depends on Photoshop contours, blend modes, global light, color management, target-layer pixels, and undocumented renderer behavior; unsupported descriptor value types are rejected rather than ignored."]}},lu=(e,n,t)=>{if(gy(t),n==="pat")return vy(e,t);if(n==="grd")return Dy(e,t);if(n==="asl")return My(e,t);throw new Error(`Unsupported Adobe preset format ${JSON.stringify(n)}.`)};var $o=self,cu=e=>e.format==="abr"?[...e.samples.map(n=>n.alpha.buffer),...e.patterns.map(n=>n.rgba.buffer)].filter(n=>n instanceof ArrayBuffer):e.format==="pat"?e.patterns.map(n=>n.rgba.buffer).filter(n=>n instanceof ArrayBuffer):e.format==="grd"?e.gradients.map(n=>n.previewRgba.buffer).filter(n=>n instanceof ArrayBuffer):e.format==="asl"?e.patterns.map(n=>n.rgba.buffer).filter(n=>n instanceof ArrayBuffer):[];$o.addEventListener("message",e=>{let n=e.data;try{if(!n||n.type!=="parse"&&n.type!=="parse-preset")throw new Error("Invalid Adobe resource Worker request.");if(n.type==="parse-preset"){let t=lu(n.buffer,n.format,n.limits),i={id:n.id,ok:!0,result:t};$o.postMessage(i,cu(t))}else{let t=Jd(n.buffer,n.format,n.limits),i={id:n.id,ok:!0,result:t};$o.postMessage(i,cu(t))}}catch(t){let i={id:n?.id??0,ok:!1,error:{name:t instanceof Error?t.name:"Error",message:t instanceof Error?t.message:String(t)}};$o.postMessage(i)}});