dsh-codex-subscription 2.0.1 → 2.1.0-beta.1
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.
- package/README.en.md +13 -1
- package/README.md +13 -1
- package/THIRD_PARTY_NOTICES.md +79 -0
- package/lib/client.js +710 -33
- package/lib/index.js +261 -8
- package/lib/sketch-psd-worker.js +11 -0
- package/package.json +3 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),t=e(((e,t)=>{function n(e){let t=e.length;for(;--t>=0;)e[t]=0}let r=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]),i=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]),a=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),o=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=Array(288*2);n(s);let c=Array(60);n(c);let l=Array(512);n(l);let u=Array(256);n(u);let d=Array(29);n(d);let f=Array(30);n(f);function p(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let m,h,g;function _(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}let v=e=>e<256?l[e]:l[256+(e>>>7)],y=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},b=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<<e.bi_valid&65535,y(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},x=(e,t,n)=>{b(e,n[t*2],n[t*2+1])},S=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},C=e=>{e.bi_valid===16?(y(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)},w=(e,t)=>{let n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,d,f,p,m,h=0;for(f=0;f<=15;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<573;l++)u=e.heap[l],f=n[n[u*2+1]*2+1]+1,f>c&&(f=c,h++),n[u*2+1]=f,!(u>r)&&(e.bl_count[f]++,p=0,u>=s&&(p=o[u-s]),m=n[u*2],e.opt_len+=m*(f+p),a&&(e.static_len+=m*(i[u*2+1]+p)));if(h!==0){do{for(f=c-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(f=c;f!==0;f--)for(u=e.bl_count[f];u!==0;)d=e.heap[--l],!(d>r)&&(n[d*2+1]!==f&&(e.opt_len+=(f-n[d*2+1])*n[d*2],n[d*2+1]=f),u--)}},T=(e,t,n)=>{let r=Array(16),i=0,a,o;for(a=1;a<=15;a++)i=i+n[a-1]<<1,r[a]=i;for(o=0;o<=t;o++){let t=e[o*2+1];t!==0&&(e[o*2]=S(r[t]++,t))}},E=()=>{let e,t,n,o,_,v=Array(16);for(n=0,o=0;o<28;o++)for(d[o]=n,e=0;e<1<<r[o];e++)u[n++]=o;for(u[n-1]=o,_=0,o=0;o<16;o++)for(f[o]=_,e=0;e<1<<i[o];e++)l[_++]=o;for(_>>=7;o<30;o++)for(f[o]=_<<7,e=0;e<1<<i[o]-7;e++)l[256+_++]=o;for(t=0;t<=15;t++)v[t]=0;for(e=0;e<=143;)s[e*2+1]=8,e++,v[8]++;for(;e<=255;)s[e*2+1]=9,e++,v[9]++;for(;e<=279;)s[e*2+1]=7,e++,v[7]++;for(;e<=287;)s[e*2+1]=8,e++,v[8]++;for(T(s,287,v),e=0;e<30;e++)c[e*2+1]=5,c[e*2]=S(e,5);m=new p(s,r,257,286,15),h=new p(c,i,0,30,15),g=new p([],a,0,19,7)},D=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[t*2]=0;for(t=0;t<30;t++)e.dyn_dtree[t*2]=0;for(t=0;t<19;t++)e.bl_tree[t*2]=0;e.dyn_ltree[256*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},ee=e=>{e.bi_valid>8?y(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},O=(e,t,n,r)=>{let i=t*2,a=n*2;return e[i]<e[a]||e[i]===e[a]&&r[t]<=r[n]},k=(e,t,n)=>{let r=e.heap[n],i=n<<1;for(;i<=e.heap_len&&(i<e.heap_len&&O(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!O(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r},A=(e,t,n)=>{let a,o,s=0,c,l;if(e.sym_next!==0)do a=e.pending_buf[e.sym_buf+s++]&255,a+=(e.pending_buf[e.sym_buf+s++]&255)<<8,o=e.pending_buf[e.sym_buf+s++],a===0?x(e,o,t):(c=u[o],x(e,c+256+1,t),l=r[c],l!==0&&(o-=d[c],b(e,o,l)),a--,c=v(a),x(e,c,n),l=i[c],l!==0&&(a-=f[c],b(e,a,l)));while(s<e.sym_next);x(e,256,t)},j=(e,t)=>{let n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,c=-1,l;for(e.heap_len=0,e.heap_max=573,o=0;o<a;o++)n[o*2]===0?n[o*2+1]=0:(e.heap[++e.heap_len]=c=o,e.depth[o]=0);for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,n[l*2]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=r[l*2+1]);for(t.max_code=c,o=e.heap_len>>1;o>=1;o--)k(e,n,o);l=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],k(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[l*2]=n[o*2]+n[s*2],e.depth[l]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[o*2+1]=n[s*2+1]=l,e.heap[1]=l++,k(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],w(e,t),T(n,c,e.bl_count)},M=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)&&(s<l?e.bl_tree[a*2]+=s:a===0?s<=10?e.bl_tree[34]++:e.bl_tree[36]++:(a!==i&&e.bl_tree[a*2]++,e.bl_tree[32]++),s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4))},N=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),r=0;r<=n;r++)if(a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)){if(s<l)do x(e,a,e.bl_tree);while(--s!==0);else a===0?s<=10?(x(e,17,e.bl_tree),b(e,s-3,3)):(x(e,18,e.bl_tree),b(e,s-11,7)):(a!==i&&(x(e,a,e.bl_tree),s--),x(e,16,e.bl_tree),b(e,s-3,2));s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4)}},P=e=>{let t;for(M(e,e.dyn_ltree,e.l_desc.max_code),M(e,e.dyn_dtree,e.d_desc.max_code),j(e,e.bl_desc),t=18;t>=3&&e.bl_tree[o[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},F=(e,t,n,r)=>{let i;for(b(e,t-257,5),b(e,n-1,5),b(e,r-4,4),i=0;i<r;i++)b(e,e.bl_tree[o[i]*2+1],3);N(e,e.dyn_ltree,t-1),N(e,e.dyn_dtree,n-1)},te=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<256;n++)if(e.dyn_ltree[n*2]!==0)return 1;return 0},I=!1,L=e=>{I||=(E(),!0),e.l_desc=new _(e.dyn_ltree,m),e.d_desc=new _(e.dyn_dtree,h),e.bl_desc=new _(e.bl_tree,g),e.bi_buf=0,e.bi_valid=0,D(e)},R=(e,t,n,r)=>{b(e,0+ +!!r,3),ee(e),y(e,n),y(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},ne=e=>{b(e,2,3),x(e,256,s),C(e)},z=(e,t,n,r)=>{let i,a,o=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=te(e)),j(e,e.l_desc),j(e,e.d_desc),o=P(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=n+5,n+4<=i&&t!==-1?R(e,t,n,r):e.strategy===4||a===i?(b(e,2+ +!!r,3),A(e,s,c)):(b(e,4+ +!!r,3),F(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),A(e,e.dyn_ltree,e.dyn_dtree)),D(e),r&&ee(e)},re=(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[(u[n]+256+1)*2]++,e.dyn_dtree[v(t)*2]++),e.sym_next===e.sym_end);t.exports._tr_init=L,t.exports._tr_stored_block=R,t.exports._tr_flush_block=z,t.exports._tr_tally=re,t.exports._tr_align=ne})),n=e(((e,t)=>{t.exports=(e,t,n,r)=>{let i=e&65535|0,a=e>>>16&65535|0,o=0;for(;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+t[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0}})),r=e(((e,t)=>{let n=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t})());t.exports=(e,t,r,i)=>{let a=n,o=i+r;e^=-1;for(let n=i;n<o;n++)e=e>>>8^a[(e^t[n])&255];return e^-1}})),i=e(((e,t)=>{t.exports={2:`need dictionary`,1:`stream end`,0:``,"-1":`file error`,"-2":`stream error`,"-3":`data error`,"-4":`insufficient memory`,"-5":`buffer error`,"-6":`incompatible version`}})),a=e(((e,t)=>{t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_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}})),o=e(((e,o)=>{let{_tr_init:s,_tr_stored_block:c,_tr_flush_block:l,_tr_tally:u,_tr_align:d}=t(),f=n(),p=r(),m=i(),{Z_NO_FLUSH:h,Z_PARTIAL_FLUSH:g,Z_FULL_FLUSH:_,Z_FINISH:v,Z_BLOCK:y,Z_OK:b,Z_STREAM_END:x,Z_STREAM_ERROR:S,Z_DATA_ERROR:C,Z_BUF_ERROR:w,Z_DEFAULT_COMPRESSION:T,Z_FILTERED:E,Z_HUFFMAN_ONLY:D,Z_RLE:ee,Z_FIXED:O,Z_DEFAULT_STRATEGY:k,Z_UNKNOWN:A,Z_DEFLATED:j}=a(),M=(e,t)=>(e.msg=m[t],t),N=e=>e*2-(e>4?9:0),P=e=>{let t=e.length;for(;--t>=0;)e[t]=0},F=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do n=e.head[--r],e.head[r]=n>=i?n-i:0;while(--t);t=i,r=t;do n=e.prev[--r],e.prev[r]=n>=i?n-i:0;while(--t)},te=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask,I=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))},L=(e,t)=>{l(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,I(e.strm)},R=(e,t)=>{e.pending_buf[e.pending++]=t},ne=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},z=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=f(e.adler,t,i,n):e.state.wrap===2&&(e.adler=p(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},re=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+258,p=l[r+o-1],m=l[r+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(i=t,l[i+o]!==m||l[i+o-1]!==p||l[i]!==l[r]||l[++i]!==l[r+1])continue;r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<f);if(a=258-(f-r),r=f-258,a>o){if(e.match_start=t,o=a,a>=s)break;p=l[r+o-1],m=l[r+o]}}while((t=d[t&u])>c&&--n!==0);return o<=e.lookahead?o:e.lookahead},ie=e=>{let t=e.w_size,n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-262)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),F(e),r+=t),e.strm.avail_in===0)break;if(n=z(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=3)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=te(e,e.ins_h,e.window[i+1]);e.insert&&(e.ins_h=te(e,e.ins_h,e.window[i+3-1]),e.prev[i&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=i,i++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&e.strm.avail_in!==0)},ae=(e,t)=>{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r,i,a,o=0,s=e.strm.avail_in;do{if(r=65535,a=e.bi_valid+42>>3,e.strm.avail_out<a||(a=e.strm.avail_out-a,i=e.strstart-e.block_start,r>i+e.strm.avail_in&&(r=i+e.strm.avail_in),r>a&&(r=a),r<n&&(r===0&&t!==v||t===h||r!==i+e.strm.avail_in)))break;o=+(t===v&&r===i+e.strm.avail_in),c(e,0,0,o),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,I(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(z(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(o===0);return s-=e.strm.avail_in,s&&(s>=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<=s&&(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-s,e.strm.next_in),e.strstart),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),o?4:t!==h&&t!==v&&e.strm.avail_in===0&&e.strstart===e.block_start?2:(a=e.window_size-e.strstart,e.strm.avail_in>a&&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++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(z(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water<e.strstart&&(e.high_water=e.strstart),a=e.bi_valid+42>>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,n=a>e.w_size?e.w_size:a,i=e.strstart-e.block_start,(i>=n||(i||t===v)&&t!==h&&e.strm.avail_in===0&&i<=a)&&(r=i>a?a:i,o=+(t===v&&e.strm.avail_in===0&&r===i),c(e,e.block_start,r,o),e.block_start+=r,I(e.strm)),o?3:1)},oe=(e,t)=>{let n,r;for(;;){if(e.lookahead<262){if(ie(e),e.lookahead<262&&t===h)return 1;if(e.lookahead===0)break}if(n=0,e.lookahead>=3&&(e.ins_h=te(e,e.ins_h,e.window[e.strstart+3-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-262&&(e.match_length=re(e,n)),e.match_length>=3)if(r=u(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do e.strstart++,e.ins_h=te(e,e.ins_h,e.window[e.strstart+3-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=te(e,e.ins_h,e.window[e.strstart+1]);else r=u(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(L(e,!1),e.strm.avail_out===0))return 1}return e.insert=e.strstart<2?e.strstart:2,t===v?(L(e,!0),e.strm.avail_out===0?3:4):e.sym_next&&(L(e,!1),e.strm.avail_out===0)?1:2},B=(e,t)=>{let n,r,i;for(;;){if(e.lookahead<262){if(ie(e),e.lookahead<262&&t===h)return 1;if(e.lookahead===0)break}if(n=0,e.lookahead>=3&&(e.ins_h=te(e,e.ins_h,e.window[e.strstart+3-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=2,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-262&&(e.match_length=re(e,n),e.match_length<=5&&(e.strategy===E||e.match_length===3&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,r=u(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=te(e,e.ins_h,e.window[e.strstart+3-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=2,e.strstart++,r&&(L(e,!1),e.strm.avail_out===0))return 1}else if(e.match_available){if(r=u(e,0,e.window[e.strstart-1]),r&&L(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&=(r=u(e,0,e.window[e.strstart-1]),0),e.insert=e.strstart<2?e.strstart:2,t===v?(L(e,!0),e.strm.avail_out===0?3:4):e.sym_next&&(L(e,!1),e.strm.avail_out===0)?1:2},V=(e,t)=>{let n,r,i,a,o=e.window;for(;;){if(e.lookahead<=258){if(ie(e),e.lookahead<=258&&t===h)return 1;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=e.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){a=e.strstart+258;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<a);e.match_length=258-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=u(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=u(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(L(e,!1),e.strm.avail_out===0))return 1}return e.insert=0,t===v?(L(e,!0),e.strm.avail_out===0?3:4):e.sym_next&&(L(e,!1),e.strm.avail_out===0)?1:2},se=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(ie(e),e.lookahead===0)){if(t===h)return 1;break}if(e.match_length=0,n=u(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(L(e,!1),e.strm.avail_out===0))return 1}return e.insert=0,t===v?(L(e,!0),e.strm.avail_out===0?3:4):e.sym_next&&(L(e,!1),e.strm.avail_out===0)?1:2};function H(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}let U=[new H(0,0,0,0,ae),new H(4,4,8,4,oe),new H(4,5,16,8,oe),new H(4,6,32,32,oe),new H(4,4,16,16,B),new H(8,16,32,32,B),new H(8,16,128,128,B),new H(8,32,128,256,B),new H(32,128,258,1024,B),new H(32,258,258,4096,B)],ce=e=>{e.window_size=2*e.w_size,P(e.head),e.max_lazy_match=U[e.level].max_lazy,e.good_match=U[e.level].good_length,e.nice_match=U[e.level].nice_length,e.max_chain_length=U[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=2,e.match_available=0,e.ins_h=0};function le(){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=j,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(573*2),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),P(this.dyn_ltree),P(this.dyn_dtree),P(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),P(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),P(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}let ue=e=>{if(!e)return 1;let t=e.state;return+(!t||t.strm!==e||t.status!==42&&t.status!==57&&t.status!==69&&t.status!==73&&t.status!==91&&t.status!==103&&t.status!==113&&t.status!==666)},W=e=>{if(ue(e))return M(e,S);e.total_in=e.total_out=0,e.data_type=A;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?57:t.wrap?42:113,e.adler=t.wrap===2?0:1,t.last_flush=-2,s(t),b},de=e=>{let t=W(e);return t===b&&ce(e.state),t},G=(e,t)=>ue(e)||e.state.wrap!==2?S:(e.state.gzhead=t,b),K=(e,t,n,r,i,a)=>{if(!e)return S;let o=1;if(t===T&&(t=6),r<0?(o=0,r=-r):r>15&&(o=2,r-=16),i<1||i>9||n!==j||r<8||r>15||t<0||t>9||a<0||a>O||r===8&&o!==1)return M(e,S);r===8&&(r=9);let s=new le;return e.state=s,s.strm=e,s.status=42,s.wrap=o,s.gzhead=null,s.w_bits=r,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new Uint8Array(s.w_size*2),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Uint8Array(s.pending_buf_size),s.sym_buf=s.lit_bufsize,s.sym_end=(s.lit_bufsize-1)*3,s.level=t,s.strategy=a,s.method=n,de(e)},q=(e,t)=>K(e,t,j,15,8,k),J=(e,t)=>{if(ue(e)||t>y||t<0)return e?M(e,S):S;let n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===666&&t!==v)return M(e,e.avail_out===0?w:S);let r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(I(e),e.avail_out===0)return n.last_flush=-1,b}else if(e.avail_in===0&&N(t)<=N(r)&&t!==v)return M(e,w);if(n.status===666&&e.avail_in!==0)return M(e,w);if(n.status===42&&n.wrap===0&&(n.status=113),n.status===42){let t=j+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=D||n.level<2?0:n.level<6?1:n.level===6?2:3,t|=r<<6,n.strstart!==0&&(t|=32),t+=31-t%31,ne(n,t),n.strstart!==0&&(ne(n,e.adler>>>16),ne(n,e.adler&65535)),e.adler=1,n.status=113,I(e),n.pending!==0)return n.last_flush=-1,b}if(n.status===57){if(e.adler=0,R(n,31),R(n,139),R(n,8),n.gzhead)R(n,+!!n.gzhead.text+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),R(n,n.gzhead.time&255),R(n,n.gzhead.time>>8&255),R(n,n.gzhead.time>>16&255),R(n,n.gzhead.time>>24&255),R(n,n.level===9?2:n.strategy>=D||n.level<2?4:0),R(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(R(n,n.gzhead.extra.length&255),R(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=p(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(R(n,0),R(n,0),R(n,0),R(n,0),R(n,0),R(n,n.level===9?2:n.strategy>=D||n.level<2?4:0),R(n,3),n.status=113,I(e),n.pending!==0)return n.last_flush=-1,b}if(n.status===69){if(n.gzhead.extra){let t=n.pending,r=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=p(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,I(e),n.pending!==0)return n.last_flush=-1,b;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=p(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(n.status===73){if(n.gzhead.name){let t=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>t&&(e.adler=p(e.adler,n.pending_buf,n.pending-t,t)),I(e),n.pending!==0)return n.last_flush=-1,b;t=0}r=n.gzindex<n.gzhead.name.length?n.gzhead.name.charCodeAt(n.gzindex++)&255:0,R(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>t&&(e.adler=p(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=91}if(n.status===91){if(n.gzhead.comment){let t=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>t&&(e.adler=p(e.adler,n.pending_buf,n.pending-t,t)),I(e),n.pending!==0)return n.last_flush=-1,b;t=0}r=n.gzindex<n.gzhead.comment.length?n.gzhead.comment.charCodeAt(n.gzindex++)&255:0,R(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>t&&(e.adler=p(e.adler,n.pending_buf,n.pending-t,t))}n.status=103}if(n.status===103){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(I(e),n.pending!==0))return n.last_flush=-1,b;R(n,e.adler&255),R(n,e.adler>>8&255),e.adler=0}if(n.status=113,I(e),n.pending!==0)return n.last_flush=-1,b}if(e.avail_in!==0||n.lookahead!==0||t!==h&&n.status!==666){let r=n.level===0?ae(n,t):n.strategy===D?se(n,t):n.strategy===ee?V(n,t):U[n.level].func(n,t);if((r===3||r===4)&&(n.status=666),r===1||r===3)return e.avail_out===0&&(n.last_flush=-1),b;if(r===2&&(t===g?d(n):t!==y&&(c(n,0,0,!1),t===_&&(P(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),I(e),e.avail_out===0))return n.last_flush=-1,b}return t===v?n.wrap<=0?x:(n.wrap===2?(R(n,e.adler&255),R(n,e.adler>>8&255),R(n,e.adler>>16&255),R(n,e.adler>>24&255),R(n,e.total_in&255),R(n,e.total_in>>8&255),R(n,e.total_in>>16&255),R(n,e.total_in>>24&255)):(ne(n,e.adler>>>16),ne(n,e.adler&65535)),I(e),n.wrap>0&&(n.wrap=-n.wrap),n.pending===0?x:b):b},Y=e=>{if(ue(e))return S;let t=e.state.status;return e.state=null,t===113?M(e,C):b},X=(e,t)=>{let n=t.length;if(ue(e))return S;let r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==42||r.lookahead)return S;if(i===1&&(e.adler=f(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(P(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}let a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,ie(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do r.ins_h=te(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++;while(--t);r.strstart=e,r.lookahead=2,ie(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,r.wrap=i,b};o.exports.deflateInit=q,o.exports.deflateInit2=K,o.exports.deflateReset=de,o.exports.deflateResetKeep=W,o.exports.deflateSetHeader=G,o.exports.deflate=J,o.exports.deflateEnd=Y,o.exports.deflateSetDictionary=X,o.exports.deflateInfo=`pako deflate (from Nodeca project)`})),s=e(((e,t)=>{let n=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);t.exports.assign=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if(typeof r!=`object`)throw TypeError(r+`must be non-object`);for(let t in r)n(r,t)&&(e[t]=r[t])}}return e},t.exports.flattenChunks=e=>{let t=0;for(let n=0,r=e.length;n<r;n++)t+=e[n].length;let n=new Uint8Array(t);for(let t=0,r=0,i=e.length;t<i;t++){let i=e[t];n.set(i,r),r+=i.length}return n}})),c=e(((e,t)=>{let n=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{n=!1}let r=new Uint8Array(256);for(let e=0;e<256;e++)r[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;r[254]=r[254]=1,t.exports.string2buf=e=>{if(typeof TextEncoder==`function`&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,a,o=e.length,s=0;for(i=0;i<o;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(s),a=0,i=0;a<s;i++)n=e.charCodeAt(i),(n&64512)==55296&&i+1<o&&(r=e.charCodeAt(i+1),(r&64512)==56320&&(n=65536+(n-55296<<10)+(r-56320),i++)),n<128?t[a++]=n:n<2048?(t[a++]=192|n>>>6,t[a++]=128|n&63):n<65536?(t[a++]=224|n>>>12,t[a++]=128|n>>>6&63,t[a++]=128|n&63):(t[a++]=240|n>>>18,t[a++]=128|n>>>12&63,t[a++]=128|n>>>6&63,t[a++]=128|n&63);return t};let i=(e,t)=>{if(t<65534&&e.subarray&&n)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r=``;for(let n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r};t.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 a,o,s=Array(n*2);for(o=0,a=0;a<n;){let t=e[a++];if(t<128){s[o++]=t;continue}let i=r[t];if(i>4){s[o++]=65533,a+=i-1;continue}for(t&=i===2?31:i===3?15:7;i>1&&a<n;)t=t<<6|e[a++]&63,i--;if(i>1){s[o++]=65533;continue}t<65536?s[o++]=t:(t-=65536,s[o++]=55296|t>>10&1023,s[o++]=56320|t&1023)}return i(s,o)},t.exports.utf8border=(e,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+r[e[n]]>t?n:t}})),l=e(((e,t)=>{function n(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=``,this.state=null,this.data_type=2,this.adler=0}t.exports=n})),u=e(((e,t)=>{let n=o(),r=s(),u=c(),d=i(),f=l(),p=Object.prototype.toString,{Z_NO_FLUSH:m,Z_SYNC_FLUSH:h,Z_FULL_FLUSH:g,Z_FINISH:_,Z_OK:v,Z_STREAM_END:y,Z_DEFAULT_COMPRESSION:b,Z_DEFAULT_STRATEGY:x,Z_DEFLATED:S}=a();function C(e){this.options=r.assign({level:b,method:S,chunkSize:16384,windowBits:15,memLevel:8,strategy:x},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 f,this.strm.avail_out=0;let i=n.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==v)throw Error(d[i]);if(t.header&&n.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e=typeof t.dictionary==`string`?u.string2buf(t.dictionary):p.call(t.dictionary)===`[object ArrayBuffer]`?new Uint8Array(t.dictionary):t.dictionary,i=n.deflateSetDictionary(this.strm,e),i!==v)throw Error(d[i]);this._dict_set=!0}}C.prototype.push=function(e,t){let r=this.strm,i=this.options.chunkSize,a,o;if(this.ended)return!1;for(o=t===~~t?t:t===!0?_:m,typeof e==`string`?r.input=u.string2buf(e):p.call(e)===`[object ArrayBuffer]`?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){if(r.avail_out===0&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),(o===h||o===g)&&r.avail_out<=6){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(a=n.deflate(r,o),a===y)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),a=n.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===v;if(r.avail_out===0){this.onData(r.output);continue}if(o>0&&r.next_out>0){this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;continue}if(r.avail_in===0)break}return!0},C.prototype.onData=function(e){this.chunks.push(e)},C.prototype.onEnd=function(e){e===v&&(this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function w(e,t){let n=new C(t);if(n.push(e,!0),n.err)throw n.msg||d[n.err];return n.result}function T(e,t){return t||={},t.raw=!0,w(e,t)}function E(e,t){return t||={},t.gzip=!0,w(e,t)}t.exports.Deflate=C,t.exports.deflate=w,t.exports.deflateRaw=T,t.exports.gzip=E,t.exports.constants=a()})),d=e(((e,t)=>{let n=16209;t.exports=function(e,t){let r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D=e.state;r=e.next_in,T=e.input,i=r+(e.avail_in-5),a=e.next_out,E=e.output,o=a-(t-e.avail_out),s=a+(e.avail_out-257),c=D.dmax,l=D.wsize,u=D.whave,d=D.wnext,f=D.window,p=D.hold,m=D.bits,h=D.lencode,g=D.distcode,_=(1<<D.lenbits)-1,v=(1<<D.distbits)-1;top:do{m<15&&(p+=T[r++]<<m,m+=8,p+=T[r++]<<m,m+=8),y=h[p&_];dolen:for(;;){if(b=y>>>24,p>>>=b,m-=b,b=y>>>16&255,b===0)E[a++]=y&65535;else if(b&16){x=y&65535,b&=15,b&&(m<b&&(p+=T[r++]<<m,m+=8),x+=p&(1<<b)-1,p>>>=b,m-=b),m<15&&(p+=T[r++]<<m,m+=8,p+=T[r++]<<m,m+=8),y=g[p&v];dodist:for(;;){if(b=y>>>24,p>>>=b,m-=b,b=y>>>16&255,b&16){if(S=y&65535,b&=15,m<b&&(p+=T[r++]<<m,m+=8,m<b&&(p+=T[r++]<<m,m+=8)),S+=p&(1<<b)-1,S>c){e.msg=`invalid distance too far back`,D.mode=n;break top}if(p>>>=b,m-=b,b=a-o,S>b){if(b=S-b,b>u&&D.sane){e.msg=`invalid distance too far back`,D.mode=n;break top}if(C=0,w=f,d===0){if(C+=l-b,b<x){x-=b;do E[a++]=f[C++];while(--b);C=a-S,w=E}}else if(d<b){if(C+=l+d-b,b-=d,b<x){x-=b;do E[a++]=f[C++];while(--b);if(C=0,d<x){b=d,x-=b;do E[a++]=f[C++];while(--b);C=a-S,w=E}}}else if(C+=d-b,b<x){x-=b;do E[a++]=f[C++];while(--b);C=a-S,w=E}for(;x>2;)E[a++]=w[C++],E[a++]=w[C++],E[a++]=w[C++],x-=3;x&&(E[a++]=w[C++],x>1&&(E[a++]=w[C++]))}else{C=a-S;do E[a++]=E[C++],E[a++]=E[C++],E[a++]=E[C++],x-=3;while(x>2);x&&(E[a++]=E[C++],x>1&&(E[a++]=E[C++]))}}else if(b&64){e.msg=`invalid distance code`,D.mode=n;break top}else{y=g[(y&65535)+(p&(1<<b)-1)];continue dodist}break}}else if(!(b&64)){y=h[(y&65535)+(p&(1<<b)-1)];continue dolen}else if(b&32){D.mode=16191;break top}else{e.msg=`invalid literal/length code`,D.mode=n;break top}break}}while(r<i&&a<s);x=m>>3,r-=x,m-=x<<3,p&=(1<<m)-1,e.next_in=r,e.next_out=a,e.avail_in=r<i?5+(i-r):5-(r-i),e.avail_out=a<s?257+(s-a):257-(a-s),D.hold=p,D.bits=m}})),f=e(((e,t)=>{let n=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]),r=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]),i=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]),a=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]);t.exports=(e,t,o,s,c,l,u,d)=>{let f=d.bits,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,C,w,T,E,D,ee=null,O,k=new Uint16Array(16),A=new Uint16Array(16),j=null,M,N,P;for(p=0;p<=15;p++)k[p]=0;for(m=0;m<s;m++)k[t[o+m]]++;for(_=f,g=15;g>=1&&k[g]===0;g--);if(_>g&&(_=g),g===0)return c[l++]=20971520,c[l++]=20971520,d.bits=1,0;for(h=1;h<g&&k[h]===0;h++);for(_<h&&(_=h),b=1,p=1;p<=15;p++)if(b<<=1,b-=k[p],b<0)return-1;if(b>0&&(e===0||g!==1))return-1;for(A[1]=0,p=1;p<15;p++)A[p+1]=A[p]+k[p];for(m=0;m<s;m++)t[o+m]!==0&&(u[A[t[o+m]]++]=m);if(e===0?(ee=j=u,O=20):e===1?(ee=n,j=r,O=257):(ee=i,j=a,O=0),S=0,m=0,p=h,D=l,v=_,y=0,T=-1,x=1<<_,E=x-1,e===1&&x>852||e===2&&x>592)return 1;for(;;){M=p-y,u[m]+1<O?(N=0,P=u[m]):u[m]>=O?(N=j[u[m]-O],P=ee[u[m]-O]):(N=96,P=0),C=1<<p-y,w=1<<v,h=w;do w-=C,c[D+(S>>y)+w]=M<<24|N<<16|P|0;while(w!==0);for(C=1<<p-1;S&C;)C>>=1;if(C===0?S=0:(S&=C-1,S+=C),m++,--k[p]===0){if(p===g)break;p=t[o+u[m]]}if(p>_&&(S&E)!==T){for(y===0&&(y=_),D+=h,v=p-y,b=1<<v;v+y<g&&(b-=k[v+y],!(b<=0));)v++,b<<=1;if(x+=1<<v,e===1&&x>852||e===2&&x>592)return 1;T=S&E,c[T]=_<<24|v<<16|D-l|0}}return S!==0&&(c[D+S]=p-y<<24|4194304),d.bits=_,0}})),p=e(((e,t)=>{let i=n(),o=r(),s=d(),c=f(),{Z_FINISH:l,Z_BLOCK:u,Z_TREES:p,Z_OK:m,Z_STREAM_END:h,Z_NEED_DICT:g,Z_STREAM_ERROR:_,Z_DATA_ERROR:v,Z_MEM_ERROR:y,Z_BUF_ERROR:b,Z_DEFLATED:x}=a(),S=16180,C=16181,w=16182,T=16183,E=16184,D=16185,ee=16186,O=16187,k=16188,A=16189,j=16190,M=16191,N=16192,P=16193,F=16194,te=16195,I=16196,L=16197,R=16198,ne=16199,z=16200,re=16201,ie=16202,ae=16203,oe=16204,B=16205,V=16206,se=16207,H=16208,U=16209,ce=16210,le=16211,ue=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function W(){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}let de=e=>{if(!e)return 1;let t=e.state;return+(!t||t.strm!==e||t.mode<S||t.mode>le)},G=e=>{if(de(e))return _;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=S,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(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,m},K=e=>{if(de(e))return _;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,G(e)},q=(e,t)=>{let n;if(de(e))return _;let r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?_:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,K(e))},J=(e,t)=>{if(!e)return _;let n=new W;e.state=n,n.strm=e,n.window=null,n.mode=S;let r=q(e,t);return r!==m&&(e.state=null),r},Y=e=>J(e,15),X=!0,fe,pe,me=e=>{if(X){fe=new Int32Array(512),pe=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(c(1,e.lens,0,288,fe,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;c(2,e.lens,0,32,pe,0,e.work,{bits:5}),X=!1}e.lencode=fe,e.lenbits=9,e.distcode=pe,e.distbits=5},Z=(e,t,n,r)=>{let i,a=e.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),r>=a.wsize?(a.window.set(t.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>r&&(i=r),a.window.set(t.subarray(n-r,n-r+i),a.wnext),r-=i,r?(a.window.set(t.subarray(n-r,n),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0},Q=(e,t)=>{let n,r,a,d,f,W,G,K,q,J,Y,X,fe,pe,Q=0,$,he,ge,_e,ve,ye,be,xe,Se=new Uint8Array(4),Ce,we,Te=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(de(e)||!e.output||!e.input&&e.avail_in!==0)return _;n=e.state,n.mode===M&&(n.mode=N),f=e.next_out,a=e.output,G=e.avail_out,d=e.next_in,r=e.input,W=e.avail_in,K=n.hold,q=n.bits,J=W,Y=G,xe=m;inf_leave:for(;;)switch(n.mode){case S:if(n.wrap===0){n.mode=N;break}for(;q<16;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}if(n.wrap&2&&K===35615){n.wbits===0&&(n.wbits=15),n.check=0,Se[0]=K&255,Se[1]=K>>>8&255,n.check=o(n.check,Se,2,0),K=0,q=0,n.mode=C;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((K&255)<<8)+(K>>8))%31){e.msg=`incorrect header check`,n.mode=U;break}if((K&15)!==x){e.msg=`unknown compression method`,n.mode=U;break}if(K>>>=4,q-=4,be=(K&15)+8,n.wbits===0&&(n.wbits=be),be>15||be>n.wbits){e.msg=`invalid window size`,n.mode=U;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=K&512?A:M,K=0,q=0;break;case C:for(;q<16;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}if(n.flags=K,(n.flags&255)!==x){e.msg=`unknown compression method`,n.mode=U;break}if(n.flags&57344){e.msg=`unknown header flags set`,n.mode=U;break}n.head&&(n.head.text=K>>8&1),n.flags&512&&n.wrap&4&&(Se[0]=K&255,Se[1]=K>>>8&255,n.check=o(n.check,Se,2,0)),K=0,q=0,n.mode=w;case w:for(;q<32;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}n.head&&(n.head.time=K),n.flags&512&&n.wrap&4&&(Se[0]=K&255,Se[1]=K>>>8&255,Se[2]=K>>>16&255,Se[3]=K>>>24&255,n.check=o(n.check,Se,4,0)),K=0,q=0,n.mode=T;case T:for(;q<16;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}n.head&&(n.head.xflags=K&255,n.head.os=K>>8),n.flags&512&&n.wrap&4&&(Se[0]=K&255,Se[1]=K>>>8&255,n.check=o(n.check,Se,2,0)),K=0,q=0,n.mode=E;case E:if(n.flags&1024){for(;q<16;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}n.length=K,n.head&&(n.head.extra_len=K),n.flags&512&&n.wrap&4&&(Se[0]=K&255,Se[1]=K>>>8&255,n.check=o(n.check,Se,2,0)),K=0,q=0}else n.head&&(n.head.extra=null);n.mode=D;case D:if(n.flags&1024&&(X=n.length,X>W&&(X=W),X&&(n.head&&(be=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(d,d+X),be)),n.flags&512&&n.wrap&4&&(n.check=o(n.check,r,X,d)),W-=X,d+=X,n.length-=X),n.length))break inf_leave;n.length=0,n.mode=ee;case ee:if(n.flags&2048){if(W===0)break inf_leave;X=0;do be=r[d+X++],n.head&&be&&n.length<65536&&(n.head.name+=String.fromCharCode(be));while(be&&X<W);if(n.flags&512&&n.wrap&4&&(n.check=o(n.check,r,X,d)),W-=X,d+=X,be)break inf_leave}else n.head&&(n.head.name=null);n.length=0,n.mode=O;case O:if(n.flags&4096){if(W===0)break inf_leave;X=0;do be=r[d+X++],n.head&&be&&n.length<65536&&(n.head.comment+=String.fromCharCode(be));while(be&&X<W);if(n.flags&512&&n.wrap&4&&(n.check=o(n.check,r,X,d)),W-=X,d+=X,be)break inf_leave}else n.head&&(n.head.comment=null);n.mode=k;case k:if(n.flags&512){for(;q<16;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}if(n.wrap&4&&K!==(n.check&65535)){e.msg=`header crc mismatch`,n.mode=U;break}K=0,q=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=M;break;case A:for(;q<32;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}e.adler=n.check=ue(K),K=0,q=0,n.mode=j;case j:if(n.havedict===0)return e.next_out=f,e.avail_out=G,e.next_in=d,e.avail_in=W,n.hold=K,n.bits=q,g;e.adler=n.check=1,n.mode=M;case M:if(t===u||t===p)break inf_leave;case N:if(n.last){K>>>=q&7,q-=q&7,n.mode=V;break}for(;q<3;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}switch(n.last=K&1,K>>>=1,--q,K&3){case 0:n.mode=P;break;case 1:if(me(n),n.mode=ne,t===p){K>>>=2,q-=2;break inf_leave}break;case 2:n.mode=I;break;case 3:e.msg=`invalid block type`,n.mode=U}K>>>=2,q-=2;break;case P:for(K>>>=q&7,q-=q&7;q<32;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}if((K&65535)!=(K>>>16^65535)){e.msg=`invalid stored block lengths`,n.mode=U;break}if(n.length=K&65535,K=0,q=0,n.mode=F,t===p)break inf_leave;case F:n.mode=te;case te:if(X=n.length,X){if(X>W&&(X=W),X>G&&(X=G),X===0)break inf_leave;a.set(r.subarray(d,d+X),f),W-=X,d+=X,G-=X,f+=X,n.length-=X;break}n.mode=M;break;case I:for(;q<14;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}if(n.nlen=(K&31)+257,K>>>=5,q-=5,n.ndist=(K&31)+1,K>>>=5,q-=5,n.ncode=(K&15)+4,K>>>=4,q-=4,n.nlen>286||n.ndist>30){e.msg=`too many length or distance symbols`,n.mode=U;break}n.have=0,n.mode=L;case L:for(;n.have<n.ncode;){for(;q<3;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}n.lens[Te[n.have++]]=K&7,K>>>=3,q-=3}for(;n.have<19;)n.lens[Te[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,Ce={bits:n.lenbits},xe=c(0,n.lens,0,19,n.lencode,0,n.work,Ce),n.lenbits=Ce.bits,xe){e.msg=`invalid code lengths set`,n.mode=U;break}n.have=0,n.mode=R;case R:for(;n.have<n.nlen+n.ndist;){for(;Q=n.lencode[K&(1<<n.lenbits)-1],$=Q>>>24,he=Q>>>16&255,ge=Q&65535,!($<=q);){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}if(ge<16)K>>>=$,q-=$,n.lens[n.have++]=ge;else{if(ge===16){for(we=$+2;q<we;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}if(K>>>=$,q-=$,n.have===0){e.msg=`invalid bit length repeat`,n.mode=U;break}be=n.lens[n.have-1],X=3+(K&3),K>>>=2,q-=2}else if(ge===17){for(we=$+3;q<we;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}K>>>=$,q-=$,be=0,X=3+(K&7),K>>>=3,q-=3}else{for(we=$+7;q<we;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}K>>>=$,q-=$,be=0,X=11+(K&127),K>>>=7,q-=7}if(n.have+X>n.nlen+n.ndist){e.msg=`invalid bit length repeat`,n.mode=U;break}for(;X--;)n.lens[n.have++]=be}}if(n.mode===U)break;if(n.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,n.mode=U;break}if(n.lenbits=9,Ce={bits:n.lenbits},xe=c(1,n.lens,0,n.nlen,n.lencode,0,n.work,Ce),n.lenbits=Ce.bits,xe){e.msg=`invalid literal/lengths set`,n.mode=U;break}if(n.distbits=6,n.distcode=n.distdyn,Ce={bits:n.distbits},xe=c(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,Ce),n.distbits=Ce.bits,xe){e.msg=`invalid distances set`,n.mode=U;break}if(n.mode=ne,t===p)break inf_leave;case ne:n.mode=z;case z:if(W>=6&&G>=258){e.next_out=f,e.avail_out=G,e.next_in=d,e.avail_in=W,n.hold=K,n.bits=q,s(e,Y),f=e.next_out,a=e.output,G=e.avail_out,d=e.next_in,r=e.input,W=e.avail_in,K=n.hold,q=n.bits,n.mode===M&&(n.back=-1);break}for(n.back=0;Q=n.lencode[K&(1<<n.lenbits)-1],$=Q>>>24,he=Q>>>16&255,ge=Q&65535,!($<=q);){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}if(he&&!(he&240)){for(_e=$,ve=he,ye=ge;Q=n.lencode[ye+((K&(1<<_e+ve)-1)>>_e)],$=Q>>>24,he=Q>>>16&255,ge=Q&65535,!(_e+$<=q);){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}K>>>=_e,q-=_e,n.back+=_e}if(K>>>=$,q-=$,n.back+=$,n.length=ge,he===0){n.mode=B;break}if(he&32){n.back=-1,n.mode=M;break}if(he&64){e.msg=`invalid literal/length code`,n.mode=U;break}n.extra=he&15,n.mode=re;case re:if(n.extra){for(we=n.extra;q<we;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}n.length+=K&(1<<n.extra)-1,K>>>=n.extra,q-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=ie;case ie:for(;Q=n.distcode[K&(1<<n.distbits)-1],$=Q>>>24,he=Q>>>16&255,ge=Q&65535,!($<=q);){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}if(!(he&240)){for(_e=$,ve=he,ye=ge;Q=n.distcode[ye+((K&(1<<_e+ve)-1)>>_e)],$=Q>>>24,he=Q>>>16&255,ge=Q&65535,!(_e+$<=q);){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}K>>>=_e,q-=_e,n.back+=_e}if(K>>>=$,q-=$,n.back+=$,he&64){e.msg=`invalid distance code`,n.mode=U;break}n.offset=ge,n.extra=he&15,n.mode=ae;case ae:if(n.extra){for(we=n.extra;q<we;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}n.offset+=K&(1<<n.extra)-1,K>>>=n.extra,q-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg=`invalid distance too far back`,n.mode=U;break}n.mode=oe;case oe:if(G===0)break inf_leave;if(X=Y-G,n.offset>X){if(X=n.offset-X,X>n.whave&&n.sane){e.msg=`invalid distance too far back`,n.mode=U;break}X>n.wnext?(X-=n.wnext,fe=n.wsize-X):fe=n.wnext-X,X>n.length&&(X=n.length),pe=n.window}else pe=a,fe=f-n.offset,X=n.length;X>G&&(X=G),G-=X,n.length-=X;do a[f++]=pe[fe++];while(--X);n.length===0&&(n.mode=z);break;case B:if(G===0)break inf_leave;a[f++]=n.length,G--,n.mode=z;break;case V:if(n.wrap){for(;q<32;){if(W===0)break inf_leave;W--,K|=r[d++]<<q,q+=8}if(Y-=G,e.total_out+=Y,n.total+=Y,n.wrap&4&&Y&&(e.adler=n.check=n.flags?o(n.check,a,Y,f-Y):i(n.check,a,Y,f-Y)),Y=G,n.wrap&4&&(n.flags?K:ue(K))!==n.check){e.msg=`incorrect data check`,n.mode=U;break}K=0,q=0}n.mode=se;case se:if(n.wrap&&n.flags){for(;q<32;){if(W===0)break inf_leave;W--,K+=r[d++]<<q,q+=8}if(n.wrap&4&&K!==(n.total&4294967295)){e.msg=`incorrect length check`,n.mode=U;break}K=0,q=0}n.mode=H;case H:xe=h;break inf_leave;case U:xe=v;break inf_leave;case ce:return y;case le:default:return _}return e.next_out=f,e.avail_out=G,e.next_in=d,e.avail_in=W,n.hold=K,n.bits=q,(n.wsize||Y!==e.avail_out&&n.mode<U&&(n.mode<V||t!==l))&&Z(e,e.output,e.next_out,Y-e.avail_out)?(n.mode=ce,y):(J-=e.avail_in,Y-=e.avail_out,e.total_in+=J,e.total_out+=Y,n.total+=Y,n.wrap&4&&Y&&(e.adler=n.check=n.flags?o(n.check,a,Y,e.next_out-Y):i(n.check,a,Y,e.next_out-Y)),e.data_type=n.bits+(n.last?64:0)+(n.mode===M?128:0)+(n.mode===ne||n.mode===F?256:0),(J===0&&Y===0||t===l)&&xe===m&&(xe=b),xe)},$=e=>{if(de(e))return _;let t=e.state;return t.window&&=null,e.state=null,m},he=(e,t)=>{if(de(e))return _;let n=e.state;return n.wrap&2?(n.head=t,t.done=!1,m):_},ge=(e,t)=>{let n=t.length,r,a,o;return de(e)||(r=e.state,r.wrap!==0&&r.mode!==j)?_:r.mode===j&&(a=1,a=i(a,t,n,0),a!==r.check)?v:(o=Z(e,t,n,n),o?(r.mode=ce,y):(r.havedict=1,m))};t.exports.inflateReset=K,t.exports.inflateReset2=q,t.exports.inflateResetKeep=G,t.exports.inflateInit=Y,t.exports.inflateInit2=J,t.exports.inflate=Q,t.exports.inflateEnd=$,t.exports.inflateGetHeader=he,t.exports.inflateSetDictionary=ge,t.exports.inflateInfo=`pako inflate (from Nodeca project)`})),m=e(((e,t)=>{function n(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=``,this.comment=``,this.hcrc=0,this.done=!1}t.exports=n})),h=e(((e,t)=>{let n=p(),r=s(),o=c(),u=i(),d=l(),f=m(),h=Object.prototype.toString,{Z_NO_FLUSH:g,Z_FINISH:_,Z_OK:v,Z_STREAM_END:y,Z_NEED_DICT:b,Z_STREAM_ERROR:x,Z_DATA_ERROR:S,Z_MEM_ERROR:C}=a();function w(e){this.options=r.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||(t.windowBits|=15)),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;let i=n.inflateInit2(this.strm,t.windowBits);if(i!==v||(this.header=new f,n.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary==`string`?t.dictionary=o.string2buf(t.dictionary):h.call(t.dictionary)===`[object ArrayBuffer]`&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=n.inflateSetDictionary(this.strm,t.dictionary),i!==v))))throw Error(u[i])}w.prototype.push=function(e,t){let r=this.strm,i=this.options.chunkSize,a=this.options.dictionary,s,c,l;if(this.ended)return!1;for(c=t===~~t?t:t===!0?_:g,h.call(e)===`[object ArrayBuffer]`?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),s=n.inflate(r,c),s===b&&a&&(s=n.inflateSetDictionary(r,a),s===v?s=n.inflate(r,c):s===S&&(s=b));r.avail_in>0&&s===y&&r.state.wrap>0&&e[r.next_in]!==0;)n.inflateReset(r),s=n.inflate(r,c);switch(s){case x:case S:case b:case C:return this.onEnd(s),this.ended=!0,!1}if(l=r.avail_out,r.next_out&&(r.avail_out===0||s===y))if(this.options.to===`string`){let e=o.utf8border(r.output,r.next_out),t=r.next_out-e,n=o.buf2string(r.output,e);r.next_out=t,r.avail_out=i-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(n)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(!(s===v&&l===0)){if(s===y)return s=n.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(r.avail_in===0)break}}return!0},w.prototype.onData=function(e){this.chunks.push(e)},w.prototype.onEnd=function(e){e===v&&(this.options.to===`string`?this.result=this.chunks.join(``):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function T(e,t){let n=new w(t);if(n.push(e),n.err)throw n.msg||u[n.err];return n.result}function E(e,t){return t||={},t.raw=!0,T(e,t)}t.exports.Inflate=w,t.exports.inflate=T,t.exports.inflateRaw=E,t.exports.ungzip=T,t.exports.constants=a()})),g=e(((e,t)=>{let{Deflate:n,deflate:r,deflateRaw:i,gzip:o}=u(),{Inflate:s,inflate:c,inflateRaw:l,ungzip:d}=h(),f=a();t.exports.Deflate=n,t.exports.deflate=r,t.exports.deflateRaw=i,t.exports.gzip=o,t.exports.Inflate=s,t.exports.inflate=c,t.exports.inflateRaw=l,t.exports.ungzip=d,t.exports.constants=f})),_=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decodeJpeg=v;let t=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]),n=4017,r=3406,i=2276,a=1567,o=3784,s=5793,c=2896,l=64*1024*1024,u=0;function d(e){let t=u+e;if(t>l){let e=Math.ceil((t-l)/1024/1024);throw Error(`Max memory limit exceeded by at least ${e}MB`)}u=t}function f(e,t){let n=16;for(;n>0&&!e[n-1];)n--;let r=[{children:[],index:0}],i=0,a=r[0];for(let o=0;o<n;o++){for(let n=0;n<e[o];n++){for(a=r.pop(),a.children[a.index]=t[i];a.index>0;){if(r.length===0)throw Error(`Could not recreate Huffman Table`);a=r.pop()}for(a.index++,r.push(a);r.length<=o;){let e={children:[],index:0};r.push(e),a.children[a.index]=e.children,a=e}i++}if(o+1<n){let e={children:[],index:0};r.push(e),a.children[a.index]=e.children,a=e}}return r[0].children}function p(e,n,r,i,a,o,s,c,l){let u=r.mcusPerLine,d=r.progressive,f=n,p=0,m=0;function h(){if(m>0)return m--,p>>m&1;if(p=e[n++],p==255){let t=e[n++];if(t)throw Error(`unexpected marker: ${(p<<8|t).toString(16)}`)}return m=7,p>>>7}function g(e){let t=e;for(;;){if(t=t[h()],typeof t==`number`)return t;if(t===void 0)throw Error(`invalid huffman sequence`)}}function _(e){let t=0;for(;e>0;)t=t<<1|h(),e--;return t}function v(e){let t=_(e);return t>=1<<e-1?t:t+(-1<<e)+1}function y(e,n){let r=g(e.huffmanTableDC),i=r===0?0:v(r);n[0]=e.pred+=i;let a=1;for(;a<64;){let r=g(e.huffmanTableAC),i=r&15,o=r>>4;if(i===0){if(o<15)break;a+=16;continue}a+=o;let s=t[a];n[s]=v(i),a++}}function b(e,t){let n=g(e.huffmanTableDC),r=n===0?0:v(n)<<l;t[0]=e.pred+=r}function x(e,t){t[0]|=h()<<l}let S=0;function C(e,n){if(S>0){S--;return}let r=o,i=s;for(;r<=i;){let i=g(e.huffmanTableAC),a=i&15,o=i>>4;if(a===0){if(o<15){S=_(o)+(1<<o)-1;break}r+=16;continue}r+=o;let s=t[r];n[s]=v(a)*(1<<l),r++}}let w=0,T=0;function E(e,n){let r=o,i=s,a=0;for(;r<=i;){let i=t[r],o=n[i]<0?-1:1;switch(w){case 0:let t=g(e.huffmanTableAC),r=t&15;if(a=t>>4,r===0)a<15?(S=_(a)+(1<<a),w=4):(a=16,w=1);else{if(r!==1)throw Error(`invalid ACn encoding`);T=v(r),w=a?2:3}continue;case 1:case 2:n[i]?n[i]+=(h()<<l)*o:(a--,a===0&&(w=w==2?3:0));break;case 3:n[i]?n[i]+=(h()<<l)*o:(n[i]=T<<l,w=0);break;case 4:n[i]&&(n[i]+=(h()<<l)*o);break}r++}w===4&&(S--,S===0&&(w=0))}function D(e,t,n,r,i){let a=n/u|0,o=n%u,s=a*e.v+r,c=o*e.h+i;e.blocks[s]!==void 0&&t(e,e.blocks[s][c])}function ee(e,t,n){let r=n/e.blocksPerLine|0,i=n%e.blocksPerLine;e.blocks[r]!==void 0&&t(e,e.blocks[r][i])}let O=i.length,k,A;A=d?o===0?c===0?b:x:c===0?C:E:y;let j=0,M;M=O==1?i[0].blocksPerLine*i[0].blocksPerColumn:u*r.mcusPerColumn,a||=M;let N,P,F;for(;j<M;){for(let e=0;e<O;e++)i[e].pred=0;if(S=0,O==1){k=i[0];for(let e=0;e<a;e++)ee(k,A,j),j++}else for(let e=0;e<a;e++){for(let e=0;e<O;e++){k=i[e],N=k.h,P=k.v;for(let e=0;e<P;e++)for(let t=0;t<N;t++)D(k,A,j,e,t)}if(j++,j===M)break}if(j===M)do{if(e[n]===255&&e[n+1]!==0)break;n+=1}while(n<e.length-2);if(m=0,F=e[n]<<8|e[n+1],F<65280)throw Error(`marker was not found`);if(F>=65488&&F<=65495)n+=2;else break}return n-f}function m(e){let t=[],l=e.blocksPerLine,u=e.blocksPerColumn,f=l<<3,p=new Int32Array(64),m=new Uint8Array(64);function h(t,l,u){let d=e.quantizationTable,f=u;for(let e=0;e<64;e++)f[e]=t[e]*d[e];for(let e=0;e<8;++e){let t=8*e;if(f[1+t]==0&&f[2+t]==0&&f[3+t]==0&&f[4+t]==0&&f[5+t]==0&&f[6+t]==0&&f[7+t]==0){let e=s*f[0+t]+512>>10;f[0+t]=e,f[1+t]=e,f[2+t]=e,f[3+t]=e,f[4+t]=e,f[5+t]=e,f[6+t]=e,f[7+t]=e;continue}let l=s*f[0+t]+128>>8,u=s*f[4+t]+128>>8,d=f[2+t],p=f[6+t],m=c*(f[1+t]-f[7+t])+128>>8,h=c*(f[1+t]+f[7+t])+128>>8,g=f[3+t]<<4,_=f[5+t]<<4,v=l-u+1>>1;l=l+u+1>>1,u=v,v=d*o+p*a+128>>8,d=d*a-p*o+128>>8,p=v,v=m-_+1>>1,m=m+_+1>>1,_=v,v=h+g+1>>1,g=h-g+1>>1,h=v,v=l-p+1>>1,l=l+p+1>>1,p=v,v=u-d+1>>1,u=u+d+1>>1,d=v,v=m*i+h*r+2048>>12,m=m*r-h*i+2048>>12,h=v,v=g*799+_*n+2048>>12,g=g*n-_*799+2048>>12,_=v,f[0+t]=l+h,f[7+t]=l-h,f[1+t]=u+_,f[6+t]=u-_,f[2+t]=d+g,f[5+t]=d-g,f[3+t]=p+m,f[4+t]=p-m}for(let e=0;e<8;++e){let t=e;if(f[8+t]==0&&f[16+t]==0&&f[24+t]==0&&f[32+t]==0&&f[40+t]==0&&f[48+t]==0&&f[56+t]==0){let n=s*u[e+0]+8192>>14;f[0+t]=n,f[8+t]=n,f[16+t]=n,f[24+t]=n,f[32+t]=n,f[40+t]=n,f[48+t]=n,f[56+t]=n;continue}let l=s*f[0+t]+2048>>12,d=s*f[32+t]+2048>>12,p=f[16+t],m=f[48+t],h=c*(f[8+t]-f[56+t])+2048>>12,g=c*(f[8+t]+f[56+t])+2048>>12,_=f[24+t],v=f[40+t],y=l-d+1>>1;l=l+d+1>>1,d=y,y=p*o+m*a+2048>>12,p=p*a-m*o+2048>>12,m=y,y=h-v+1>>1,h=h+v+1>>1,v=y,y=g+_+1>>1,_=g-_+1>>1,g=y,y=l-m+1>>1,l=l+m+1>>1,m=y,y=d-p+1>>1,d=d+p+1>>1,p=y,y=h*i+g*r+2048>>12,h=h*r-g*i+2048>>12,g=y,y=_*799+v*n+2048>>12,_=_*n-v*799+2048>>12,v=y,f[0+t]=l+g,f[56+t]=l-g,f[8+t]=d+v,f[48+t]=d-v,f[16+t]=p+_,f[40+t]=p-_,f[24+t]=m+h,f[32+t]=m-h}for(let e=0;e<64;++e){let t=128+(f[e]+8>>4);l[e]=t<0?0:t>255?255:t}}d(f*u*8);for(let n=0;n<u;n++){let r=n<<3;for(let e=0;e<8;e++)t.push(new Uint8Array(f));for(let i=0;i<l;i++){h(e.blocks[n][i],m,p);let a=0,o=i<<3;for(let e=0;e<8;e++){let n=t[r+e];for(let e=0;e<8;e++)n[o+e]=m[a++]}}}return t}function h(e){return e<0?0:e>255?255:e}function g(e){let n={width:0,height:0,adobe:void 0,components:[],exifBuffer:void 0,jfif:void 0},r=100*1e3*1e3,i=0;function a(){let t=e[i]<<8|e[i+1];return i+=2,t}function o(){let t=a(),n=e.subarray(i,i+t-2);return i+=n.length,n}function s(e){let t=0,n=0;for(let r in e.components)if(e.components.hasOwnProperty(r)){let i=e.components[r];t<i.h&&(t=i.h),n<i.v&&(n=i.v)}let r=Math.ceil(e.samplesPerLine/8/t),i=Math.ceil(e.scanLines/8/n);for(let a in e.components)if(e.components.hasOwnProperty(a)){let o=e.components[a],s=Math.ceil(Math.ceil(e.samplesPerLine/8)*o.h/t),c=Math.ceil(Math.ceil(e.scanLines/8)*o.v/n),l=r*o.h,u=i*o.v,f=u*l,p=[];d(f*256);for(let e=0;e<u;e++){let e=[];for(let t=0;t<l;t++)e.push(new Int32Array(64));p.push(e)}o.blocksPerLine=s,o.blocksPerColumn=c,o.blocks=p}e.maxH=t,e.maxV=n,e.mcusPerLine=r,e.mcusPerColumn=i}let c=null,l=null,u,h=0,g=[],_=[],v=[],y=[],b=a(),x=-1;if(b!=65496)throw Error(`SOI not found`);for(b=a();b!=65497;){switch(b){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 e=o();b===65504&&e[0]===74&&e[1]===70&&e[2]===73&&e[3]===70&&e[4]===0&&(c={version:{major:e[5],minor:e[6]},densityUnits:e[7],xDensity:e[8]<<8|e[9],yDensity:e[10]<<8|e[11],thumbWidth:e[12],thumbHeight:e[13],thumbData:e.subarray(14,14+3*e[12]*e[13])}),b===65505&&e[0]===69&&e[1]===120&&e[2]===105&&e[3]===102&&e[4]===0&&(n.exifBuffer=e.subarray(5,e.length)),b===65518&&e[0]===65&&e[1]===100&&e[2]===111&&e[3]===98&&e[4]===101&&e[5]===0&&(l={version:e[6],flags0:e[7]<<8|e[8],flags1:e[9]<<8|e[10],transformCode:e[11]});break}case 65499:{let n=a()+i-2;for(;i<n;){let n=e[i++];d(256);let r=new Int32Array(64);if(!(n>>4))for(let n=0;n<64;n++){let a=t[n];r[a]=e[i++]}else if(n>>4==1)for(let e=0;e<64;e++){let n=t[e];r[n]=a()}else throw Error(`DQT: invalid table spec`);g[n&15]=r}break}case 65472:case 65473:case 65474:{a(),u={extended:b===65473,progressive:b===65474,precision:e[i++],scanLines:a(),samplesPerLine:a(),components:{},componentsOrder:[],maxH:0,maxV:0,mcusPerLine:0,mcusPerColumn:0};let t=u.scanLines*u.samplesPerLine;if(t>r){let e=Math.ceil((t-r)/1e6);throw Error(`maxResolutionInMP limit exceeded by ${e}MP`)}let n=e[i++];for(let t=0;t<n;t++){let t=e[i],n=e[i+1]>>4,r=e[i+1]&15,a=e[i+2];u.componentsOrder.push(t),u.components[t]={h:n,v:r,quantizationIdx:a,blocksPerColumn:0,blocksPerLine:0,blocks:[],pred:0},i+=3}s(u),_.push(u);break}case 65476:{let t=a();for(let n=2;n<t;){let t=e[i++],r=new Uint8Array(16),a=0;for(let t=0;t<16;t++,i++)a+=r[t]=e[i];d(16+a);let o=new Uint8Array(a);for(let t=0;t<a;t++,i++)o[t]=e[i];n+=17+a;let s=t&15,c=t>>4?v:y;c[s]=f(r,o)}break}case 65501:a(),h=a();break;case 65500:a(),a();break;case 65498:{a();let t=e[i++],n=[];for(let r=0;r<t;r++){let t=u.components[e[i++]],r=e[i++];t.huffmanTableDC=y[r>>4],t.huffmanTableAC=v[r&15],n.push(t)}let r=e[i++],o=e[i++],s=e[i++],c=p(e,i,u,n,h,r,o,s>>4,s&15);i+=c;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(b===224||b==225){if(x!==-1)throw Error(`first unknown JPEG marker at offset ${x.toString(16)}, second unknown JPEG marker ${b.toString(16)} at offset ${(i-1).toString(16)}`);x=i-1;let t=a();if(e[i+t-2]===255){i+=t-2;break}}throw Error(`unknown JPEG marker `+b.toString(16))}b=a()}if(_.length!=1)throw Error(`only single frame JPEGs supported`);for(let e=0;e<_.length;e++){let t=_[e].components;for(let e in t)t[e].quantizationTable=g[t[e].quantizationIdx],delete t[e].quantizationIdx}n.width=u.samplesPerLine,n.height=u.scanLines,n.jfif=c,n.adobe=l,n.components=[];for(let e=0;e<u.componentsOrder.length;e++){let t=u.components[u.componentsOrder[e]];n.components.push({lines:m(t),scaleX:t.h/u.maxH,scaleY:t.v/u.maxV})}return n}function _(e){let t=0,n=!1,r=e.width,i=e.height,a=r*i*e.components.length;d(a);let o=new Uint8Array(a);switch(e.components.length){case 1:{let n=e.components[0];for(let e=0;e<i;e++){let i=n.lines[0|e*n.scaleY];for(let e=0;e<r;e++){let r=i[0|e*n.scaleX];o[t++]=r}}break}case 2:{let n=e.components[0],a=e.components[1];for(let e=0;e<i;e++){let i=n.lines[0|e*n.scaleY],s=a.lines[0|e*a.scaleY];for(let e=0;e<r;e++){let r=i[0|e*n.scaleX];o[t++]=r;let c=s[0|e*a.scaleX];o[t++]=c}}break}case 3:{n=!0,e.adobe&&e.adobe.transformCode&&(n=!0);let a=e.components[0],s=e.components[1],c=e.components[2];for(let e=0;e<i;e++){let i=a.lines[0|e*a.scaleY],l=s.lines[0|e*s.scaleY],u=c.lines[0|e*c.scaleY];for(let e=0;e<r;e++){let r,d,f,p,m,g;n?(r=i[0|e*a.scaleX],d=l[0|e*s.scaleX],f=u[0|e*c.scaleX],p=h(r+1.402*(f-128)),m=h(r-.3441363*(d-128)-.71413636*(f-128)),g=h(r+1.772*(d-128))):(p=i[0|e*a.scaleX],m=l[0|e*s.scaleX],g=u[0|e*c.scaleX]),o[t++]=p,o[t++]=m,o[t++]=g}}break}case 4:{if(!e.adobe)throw Error(`Unsupported color mode (4 components)`);n=!1,e.adobe&&e.adobe.transformCode&&(n=!0);let a=e.components[0],s=e.components[1],c=e.components[2],l=e.components[3];for(let e=0;e<i;e++){let i=a.lines[0|e*a.scaleY],u=s.lines[0|e*s.scaleY],d=c.lines[0|e*c.scaleY],f=l.lines[0|e*l.scaleY];for(let e=0;e<r;e++){let r,p,m,g,_,v,y;n?(r=i[0|e*a.scaleX],p=u[0|e*s.scaleX],m=d[0|e*c.scaleX],g=f[0|e*l.scaleX],_=255-h(r+1.402*(m-128)),v=255-h(r-.3441363*(p-128)-.71413636*(m-128)),y=255-h(r+1.772*(p-128))):(_=i[0|e*a.scaleX],v=u[0|e*s.scaleX],y=d[0|e*c.scaleX],g=f[0|e*l.scaleX]),o[t++]=255-_,o[t++]=255-v,o[t++]=255-y,o[t++]=255-g}}break}default:throw Error(`Unsupported color mode`)}return o}function v(e,t){if(u=0,e.length===0)throw Error(`Empty jpeg buffer`);let n=g(e);d(n.width*n.height*4);let r=_(n),i=t(n.width,n.height),a=i.width,o=i.height,s=i.data,c=0,l=0;switch(n.components.length){case 1:for(let e=0;e<o;e++)for(let e=0;e<a;e++){let e=r[c++];s[l++]=e,s[l++]=e,s[l++]=e,s[l++]=255}break;case 2:for(let e=0;e<o;e++)for(let e=0;e<a;e++){let e=r[c++],t=r[c++];s[l++]=e,s[l++]=e,s[l++]=e,s[l++]=t}break;case 3:for(let e=0;e<o;e++)for(let e=0;e<a;e++){let e=r[c++],t=r[c++],n=r[c++];s[l++]=e,s[l++]=t,s[l++]=n,s[l++]=255}break;case 4:for(let e=0;e<o;e++)for(let e=0;e<a;e++){let e=r[c++],t=r[c++],n=r[c++],i=r[c++],a=255-h(e*(1-i/255)+i),o=255-h(t*(1-i/255)+i),u=255-h(n*(1-i/255)+i);s[l++]=a,s[l++]=o,s[l++]=u,s[l++]=255}break;default:throw Error(`Unsupported color mode`)}return i}})),v=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createImageData=e.createCanvas=e.MaskParams=e.LayerMaskFlags=e.ColorSpace=e.largeAdditionalInfoKeys=e.layerColors=e.toBlendMode=e.fromBlendMode=e.RAW_IMAGE_DATA=e.MOCK_HANDLERS=void 0,e.revMap=r,e.createEnum=i,e.offsetForChannel=c,e.clamp=l,e.hasAlpha=u,e.resetImageData=d,e.imageDataToCanvas=f,e.decodeBitmap=p,e.writeDataRaw=m,e.writeDataRLE=h,e.writeDataZipWithoutPrediction=v,e.createCanvasFromData=y,e.initializeCanvas=x;let t=g(),n=_();e.MOCK_HANDLERS=!1,e.RAW_IMAGE_DATA=!1,e.fromBlendMode={},e.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(e.toBlendMode).forEach(t=>e.fromBlendMode[e.toBlendMode[t]]=t),e.layerColors=[`none`,`red`,`orange`,`yellow`,`green`,`blue`,`violet`,`gray`],e.largeAdditionalInfoKeys=[`LMsk`,`Lr16`,`Lr32`,`Layr`,`Mt16`,`Mt32`,`Mtrn`,`Alph`,`FMsk`,`lnk2`,`FEid`,`FXid`,`PxSD`,`cinf`];function r(e){let t={};return Object.keys(e).forEach(n=>t[e[n]]=n),t}function i(e,t,n){let i=r(n);return{decode:e=>{let r=e.split(`.`)[1];if(r&&!i[r]){if(Object.prototype.hasOwnProperty.call(n,r))return r;let t=r.replace(/([A-Z])/g,` $1`).toLowerCase();if(Object.prototype.hasOwnProperty.call(n,t))return t;throw Error(`Unrecognized value for enum: '${e}'`)}return i[r]||t},encode:r=>{if(r&&!n[r])throw Error(`Invalid value for enum: '${r}'`);return`${e}.${r?n[r]:n[t]}`}}}var a;(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`})(a||(e.ColorSpace=a={}));var o;(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`})(o||(e.LayerMaskFlags=o={}));var s;(function(e){e[e.UserMaskDensity=1]=`UserMaskDensity`,e[e.UserMaskFeather=2]=`UserMaskFeather`,e[e.VectorMaskDensity=4]=`VectorMaskDensity`,e[e.VectorMaskFeather=8]=`VectorMaskFeather`})(s||(e.MaskParams=s={}));function c(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 l(e,t,n){return e<t?t:e>n?n:e}function u(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 d({data:e}){let t=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255;for(let n=0,r=e.length|0;n<r;n=n+4|0)e[n+0]=0,e[n+1]=0,e[n+2]=0,e[n+3]=t}function f(t){let n=(0,e.createCanvas)(t.width,t.height),r;if(t.data instanceof Uint8ClampedArray)r=t;else{r=(0,e.createImageData)(t.width,t.height);let n=t.data,i=r.data;if(n instanceof Float32Array)for(let e=0,t=n.length;e<t;e+=4)i[e+0]=Math.round(n[e+0]**(1/2.2)*255),i[e+1]=Math.round(n[e+1]**(1/2.2)*255),i[e+2]=Math.round(n[e+2]**(1/2.2)*255),i[e+3]=Math.round(n[e+3]*255);else{let e=n instanceof Uint16Array?8:0;for(let t=0,r=n.length;t<r;t++)i[t]=n[t]>>>e}}return n.getContext(`2d`).putImageData(r,0,0),n}function p(e,t,n,r){if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray))throw Error(`Invalid bit depth`);for(let i=0,a=0,o=0;i<r;i++)for(let r=0;r<n;){let i=e[o++];for(let e=0;e<8&&r<n;e++,r++,a+=4){let e=i&128?0:255;i<<=1,t[a+0]=e,t[a+1]=e,t[a+2]=e,t[a+3]=255}}}function m(e,t,n,r){if(!n||!r)return;let i=new Uint8Array(n*r);for(let n=0;n<i.length;n++)i[n]=e.data[n*4+t];return i}function h(e,{data:t,width:n,height:r},i,a){if(!n||!r)return;let o=4*n|0,s=0,c=i.length*(a?4:2)*r|0;for(let n of i)for(let i=0,l=n|0;i<r;i++){let r=i*o|0,u=r+o|0,d=u+n-4|0,f=d-4|0,p=c;for(l=r+n|0;l<u;l=l+4|0)if(l<f){let n=t[l];l=l+4|0;let r=t[l];l=l+4|0;let i=t[l];if(n===r&&n===i){let r=3;for(;r<128&&l<d&&t[l+4|0]===n;)r=r+1|0,l=l+4|0;e[c++]=1-r,e[c++]=n}else{let a=c,o=!0,s=1;for(e[c++]=0,e[c++]=n;l<d&&s<128;)if(l=l+4|0,n=r,r=i,i=t[l],n===r&&n===i){l=l-12|0,o=!1;break}else s++,e[c++]=n;o&&(s<127?(e[c++]=r,e[c++]=i,s+=2):s<128?(e[c++]=r,s++,l=l-4|0):l=l-8|0),e[a]=s-1}}else l===d?(e[c++]=0,e[c++]=t[l]):(e[c++]=1,e[c++]=t[l],l=l+4|0,e[c++]=t[l]);let m=c-p;a&&(e[s++]=m>>24&255,e[s++]=m>>16&255),e[s++]=m>>8&255,e[s++]=m&255}return e.slice(0,c)}function v({data:e,width:n,height:r},i){let a=n*r,o=new Uint8Array(a),s=[],c=0;for(let n of i){for(let t=0,r=n;t<a;t++,r+=4)o[t]=e[r];let r=(0,t.deflate)(o);s.push(r),c+=r.byteLength}if(s.length>0){let e=new Uint8Array(c),t=0;for(let n of s)e.set(n,t),t+=n.byteLength;return e}else return s[0]}function y(t){let r=(0,e.createCanvas)(100,100);try{let e=r.getContext(`2d`),i=(0,n.decodeJpeg)(t,(t,n)=>e.createImageData(t,n));r.width=i.width,r.height=i.height,e.putImageData(i,0,0)}catch(e){console.error(`JPEG decompression error`,e.message)}return r}e.createCanvas=()=>{throw Error(`Canvas not initialized, use initializeCanvas method to set up createCanvas method`)};let b;e.createImageData=(t,n)=>(b||=(0,e.createCanvas)(1,1),b.getContext(`2d`).createImageData(t,n)),typeof document<`u`&&(e.createCanvas=(e,t)=>{let n=document.createElement(`canvas`);return n.width=e,n.height=t,n});function x(t,n){e.createCanvas=t,e.createImageData=n||e.createImageData}})),y=e((e=>{e.byteLength=c,e.toByteArray=u,e.fromByteArray=p;for(var t=[],n=[],r=typeof Uint8Array<`u`?Uint8Array:Array,i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,a=0,o=i.length;a<o;++a)t[a]=i[a],n[i.charCodeAt(a)]=a;n[45]=62,n[95]=63;function s(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function c(e){var t=s(e),n=t[0],r=t[1];return(n+r)*3/4-r}function l(e,t,n){return(t+n)*3/4-n}function u(e){var t,i=s(e),a=i[0],o=i[1],c=new r(l(e,a,o)),u=0,d=o>0?a-4:a,f;for(f=0;f<d;f+=4)t=n[e.charCodeAt(f)]<<18|n[e.charCodeAt(f+1)]<<12|n[e.charCodeAt(f+2)]<<6|n[e.charCodeAt(f+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=t&255;return o===2&&(t=n[e.charCodeAt(f)]<<2|n[e.charCodeAt(f+1)]>>4,c[u++]=t&255),o===1&&(t=n[e.charCodeAt(f)]<<10|n[e.charCodeAt(f+1)]<<4|n[e.charCodeAt(f+2)]>>2,c[u++]=t>>8&255,c[u++]=t&255),c}function d(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[e&63]}function f(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(d(r));return i.join(``)}function p(e){for(var n,r=e.length,i=r%3,a=[],o=16383,s=0,c=r-i;s<c;s+=o)a.push(f(e,s,s+o>c?c:s+o));return i===1?(n=e[r-1],a.push(t[n>>2]+t[n<<4&63]+`==`)):i===2&&(n=(e[r-2]<<8)+e[r-1],a.push(t[n>>10]+t[n>>4&63]+t[n<<2&63]+`=`)),a.join(``)}})),b=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.stringLengthInBytes=r,e.encodeStringTo=a,e.encodeString=o,e.decodeString=s;function t(e){return e&4294967168?e&4294965248?e&4294901760?4:3:2:1}function n(e,t){let n=e.charCodeAt(t);if(n>=55296&&n<=56319&&t+1<e.length){let r=e.charCodeAt(t+1);if(r>=56320&&r<=57343)return{code:((n&1023)<<10)+(r&1023)+65536,size:2}}return n>=55296&&n<=57343?{code:65533,size:1}:{code:n,size:1}}function r(e){let r=0;for(let i=0;i<e.length;){let{code:a,size:o}=n(e,i);r+=t(a),i+=o}return r}function i(e,n,r){let i=t(r);switch(i){case 1:e[n]=r;break;case 2:e[n]=r>>6&31|192,e[n+1]=r&63|128;break;case 3:e[n]=r>>12&15|224,e[n+1]=r>>6&63|128,e[n+2]=r&63|128;break;default:e[n]=r>>18&7|240,e[n+1]=r>>12&63|128,e[n+2]=r>>6&63|128,e[n+3]=r&63|128;break}return i}function a(e,t,r){for(let a=0;a<r.length;){let{code:o,size:s}=n(r,a);t+=i(e,t,o),a+=s}return t}function o(e){if(e.length>1e3&&typeof TextEncoder<`u`)return new TextEncoder().encode(e);let t=new Uint8Array(r(e));return a(t,0,e),t}function s(e){if(e.byteLength>1e3&&typeof TextDecoder<`u`)return new TextDecoder().decode(e);let t=[];function n(e){e>65535&&(e-=65536,t.push(String.fromCharCode(e>>>10&1023|55296)),e=56320|e&1023),t.push(String.fromCharCode(e))}let r=0,i=0,a=0,o=128,s=191;for(let t=0;t<e.length;t++){let c=e[t];if(a===0){c<=127?n(c):c>=194&&c<=223?(a=1,r=c&31):c>=224&&c<=239?(c===224&&(o=160),c===237&&(s=159),a=2,r=c&15):c>=240&&c<=244?(c===240&&(o=144),c===244&&(s=143),a=3,r=c&7):n(65533);continue}if(c<o||c>s){r=0,a=0,i=0,o=128,s=191,n(65533),t--;continue}o=128,s=191,r=r<<6|c&63,i++,i===a&&(n(r),r=0,a=0,i=0)}return a!==0&&n(65533),t.join(``)}})),x=e((e=>{var t=e&&e.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};Object.defineProperty(e,"__esModule",{value:!0}),e.IntC=e.IntE=e.Drct=e.WndM=e.CntE=e.FlCl=e.ExtR=e.ExtT=e.DfsM=e.blurType=e.Lns=e.MztT=e.Chnl=e.Dstr=e.ZZTy=e.Wvtp=e.SphM=e.RplS=e.Cnvr=e.UndA=e.DspM=e.SmBQ=e.SmBM=e.BlrQ=e.BlrM=e.strokeStyleLineAlignment=e.strokeStyleLineJoinType=e.strokeStyleLineCapType=e.ESliceBGColorType=e.ESliceOrigin=e.ESliceVertAlign=e.ESliceHorzAlign=e.ESliceType=e.FrFl=e.FStl=e.ClrS=e.gradientInterpolationMethodType=e.stdTrackID=e.animInterpStyleEnum=e.GrdT=e.IGSr=e.BETE=e.BESs=e.bvlT=e.BESl=e.BlnM=e.warpStyle=e.Annt=e.Ornt=e.textGridding=void 0,e.presetKindType=e.prjM=e.FlMd=void 0,e.setLogErrors=l,e.readAsciiStringOrClassId=b,e.readDescriptorStructure=S,e.writeDescriptorStructure=w,e.readVersionAndDescriptor=M,e.writeVersionAndDescriptor=N,e.horzVrtcToXY=P,e.xyToHorzVrtc=F,e.descBoundsToBounds=te,e.boundsToDescBounds=I,e.serializeEffects=ne,e.parseEffects=z,e.parseTrackList=ae,e.serializeTrackList=oe,e.parseVectorContent=le,e.serializeVectorContent=de,e.parseColor=G,e.serializeColor=K,e.parseAngle=q,e.parsePercent=J,e.parsePercentOrAngle=Y,e.parseUnits=X,e.parseUnitsOrNumber=fe,e.parseUnitsToNumber=pe,e.unitsAngle=me,e.unitsPercent=Z,e.unitsPercentF=Q,e.unitsValue=$,e.frac=he;let n=v(),r=C(),i=O();function a(e){let t={};return Object.keys(e).forEach(n=>t[e[n]]=n),t}let o={"#Ang":`Angle`,"#Rsl":`Density`,"#Rlt":`Distance`,"#Nne":`None`,"#Prc":`Percent`,"#Pxl":`Pixels`,"#Mlm":`Millimeters`,"#Pnt":`Points`,RrPi:`Picas`,RrIn:`Inches`,RrCm:`Centimeters`},s=a(o),c=!1;function l(e){c=e}function u(e,t){return{name:e,classID:t}}let d=u(``,`null`),f={strokeStyleContent:u(``,`solidColorLayer`),printProofSetup:u(`Proof Setup`,`proofSetup`),Grad:u(`Gradient`,`Grdn`),Trnf:u(`Transform`,`Trnf`),patternFill:u(``,`patternFill`),ebbl:u(``,`ebbl`),SoFi:u(``,`SoFi`),GrFl:u(``,`GrFl`),sdwC:u(``,`RGBC`),hglC:u(``,`RGBC`),"Clr ":u(``,`RGBC`),tintColor:u(``,`RGBC`),Ofst:u(``,`Pnt `),ChFX:u(``,`ChFX`),MpgS:u(``,`ShpC`),DrSh:u(``,`DrSh`),IrSh:u(``,`IrSh`),OrGl:u(``,`OrGl`),IrGl:u(``,`IrGl`),TrnS:u(``,`ShpC`),Ptrn:u(``,`Ptrn`),FrFX:u(``,`FrFX`),phase:u(``,`Pnt `),frameStep:d,duration:d,workInTime:d,workOutTime:d,audioClipGroupList:d,bounds:u(``,`Rctn`),customEnvelopeWarp:u(``,`customEnvelopeWarp`),warp:u(``,`warp`),"Sz ":u(``,`Pnt `),origin:u(``,`Pnt `),autoExpandOffset:u(``,`Pnt `),keyOriginShapeBBox:u(``,`unitRect`),Vrsn:d,psVersion:d,docDefaultNewArtboardBackgroundColor:u(``,`RGBC`),artboardRect:u(``,`classFloatRect`),keyOriginRRectRadii:u(``,`radii`),keyOriginBoxCorners:d,rectangleCornerA:u(``,`Pnt `),rectangleCornerB:u(``,`Pnt `),rectangleCornerC:u(``,`Pnt `),rectangleCornerD:u(``,`Pnt `),compInfo:d,quiltWarp:u(``,`quiltWarp`),generatorSettings:d,crema:d,FrIn:d,blendOptions:d,FXRf:d,Lefx:d,time:d,animKey:d,timeScope:d,inTime:d,outTime:d,sheetStyle:d,translation:d,Skew:d,boundingBox:u(``,`boundingBox`),"Lnk ":u(``,`ExternalFileLink`),frameReader:u(``,`FrameReader`),effectParams:u(``,`motionTrackEffectParams`),Impr:u(`None`,`none`),Anch:u(``,`Pnt `),"Fwd ":u(``,`Pnt `),"Bwd ":u(``,`Pnt `),FlrC:u(``,`Pnt `),meshBoundaryPath:u(``,`pathClass`),filterFX:u(``,`filterFXStyle`),Fltr:u(``,`rigidTransform`),FrgC:u(``,`RGBC`),BckC:u(``,`RGBC`),sdwM:u(`Parameters`,`adaptCorrectTones`),hglM:u(`Parameters`,`adaptCorrectTones`),customShape:u(``,`customShape`),origFXRefPoint:d,FXRefPoint:d,ClMg:u(``,`ClMg`)},p={"Crv ":u(``,`CrPt`),Clrs:u(``,`Clrt`),Trns:u(``,`TrnS`),keyDescriptorList:d,solidFillMulti:u(``,`SoFi`),gradientFillMulti:u(``,`GrFl`),dropShadowMulti:u(``,`DrSh`),innerShadowMulti:u(``,`IrSh`),frameFXMulti:u(``,`FrFX`),FrIn:d,FSts:d,LaSt:d,sheetTimelineOptions:d,trackList:u(``,`animationTrack`),globalTrackList:u(``,`animationTrack`),keyList:d,audioClipGroupList:d,audioClipList:d,countObjectList:u(``,`countObject`),countGroupList:u(``,`countGroup`),slices:u(``,`slice`),"Pts ":u(``,`Pthp`),SbpL:u(``,`SbpL`),pathComponents:u(``,`PaCm`),filterFXList:u(``,`filterFX`),puppetShapeList:u(``,`puppetShape`),channelDenoise:u(``,`channelDenoiseParams`),ShrP:u(``,`Pnt `),layerSettings:d,list:d,Adjs:u(``,`CrvA`)},m={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`.split(`.`),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`.split(`.`),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`.split(`.`),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`.split(`.`),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`.split(`.`),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`.split(`.`),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`.split(`.`),ObAr:[`meshPoints`,`quiltSliceX`,`quiltSliceY`],"obj ":[`null`,`Chnl`],"Pth ":[`DspF`]},h=[`Rd `,`Grn `,`Bl `,`Yllw`,`Ylw `,`Cyn `,`Mgnt`,`Blck`,`Gry `,`Lmnc`,`A `,`B `],g={"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`},_={};for(let e of Object.keys(m))for(let t of m[e])_[t]=e;for(let e of Object.keys(f))_[e]||(_[e]=`Objc`);for(let e of Object.keys(p))g[e]=`Objc`;function y(e,t,n,r){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`)&&(r.Type===`keyType.Pstn`||r._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`:_[e]}function b(e){let t=(0,r.readInt32)(e);return(0,r.readAsciiString)(e,t||4)}function x(e,t){if(t.length===4&&t!==`warp`&&t!==`time`&&t!==`hold`&&t!==`list`)(0,i.writeInt32)(e,0),(0,i.writeSignature)(e,t);else{(0,i.writeInt32)(e,t.length);for(let n=0;n<t.length;n++)(0,i.writeUint8)(e,t.charCodeAt(n))}}function S(e,t){let n=A(e),i=t?{_name:n.name,_classID:n.classID}:{},a=(0,r.readUint32)(e);for(let n=0;n<a;n++){let n=b(e);i[n]=T(e,(0,r.readSignature)(e),t)}return i}function w(e,t,n,r,a){c&&!n&&console.log(`Missing classId for: `,t,n,r),(0,i.writeUnicodeStringWithPadding)(e,t),x(e,n);let o=Object.keys(r),s=o.length;`_name`in r&&s--,`_classID`in r&&s--,(0,i.writeUint32)(e,s);for(let t of o){if(t===`_name`||t===`_classID`)continue;let s=y(t,r[t],a,r),l=f[t];t===`bounds`&&a===`text`?l=u(``,`bounds`):t===`origin`?s=a===`slices`?`enum`:`Objc`:(t===`Cyn `||t===`Mgnt`||t===`Ylw `||t===`Blck`)&&r._classID===`CMYC`?s=`doub`:/^PN[a-z][a-z]$/.test(t)?s=`TEXT`:/^PT[a-z][a-z]$/.test(t)?s=`long`:/^PF[a-z][a-z]$/.test(t)||(t===`Rds `||t===`Thsh`)&&typeof r[t]==`number`&&r._classID===`SmrB`?s=`doub`:t===`ClSz`||t===`Rds `||t===`Amnt`?s=typeof r[t]==`number`?`long`:`UntF`:(t===`sdwM`||t===`hglM`)&&typeof r[t]==`string`||t===`blur`&&typeof r[t]==`string`?s=`enum`:t===`Hght`&&typeof r[t]==`number`&&r._classID===`Embs`||t===`Angl`&&typeof r[t]==`number`&&(r._classID===`Embs`||r._classID===`smartSharpen`||r._classID===`Twrl`||r._classID===`MtnB`)?s=`long`:t===`Angl`&&typeof r[t]==`number`?s=`doub`:t===`bounds`&&a===`slices`?(s=`Objc`,l=u(``,`Rct1`)):t===`Scl `?typeof r[t]==`object`&&`Hrzn`in r[t]?(s=`Objc`,l=d):s=typeof r[t]==`number`?`long`:`UntF`:t===`audioClipGroupList`&&o.length===1?s=`VlLs`:(t===`Strt`||t===`Brgh`)&&`H `in r?s=`doub`:t===`Wdth`&&typeof r[t]==`object`?s=`UntF`:t===`Ofst`&&typeof r[t]==`number`?s=`long`:t===`Strt`&&typeof r[t]==`object`?(s=`Objc`,l=d):h.indexOf(t)===-1?t===`profile`?s=n===`printOutput`?`TEXT`:`tdta`:t===`strokeStyleContent`?r[t][`Clr `]?l=u(``,`solidColorLayer`):r[t].Grad?l=u(``,`gradientLayer`):r[t].Ptrn?l=u(``,`patternLayer`):c&&console.log(`Invalid strokeStyleContent value`,r[t]):t===`bounds`&&a===`quiltWarp`&&(l=u(``,`classFloatRect`)):s=n===`RGBC`&&a!==`artd`?`doub`:`long`,l&&l.classID===`RGBC`&&`H `in r[t]&&(l={classID:`HSBC`,name:``}),x(e,t),(0,i.writeSignature)(e,s||`long`),D(e,s||`long`,r[t],t,l,a),c&&!s&&console.log(`Missing descriptor field type for: '${t}' in`,r)}}function T(e,t,n){switch(t){case`obj `:return ee(e);case`Objc`:case`GlbO`:return S(e,n);case`VlLs`:{let t=(0,r.readInt32)(e),i=[];for(let a=0;a<t;a++){let t=(0,r.readSignature)(e);i.push(T(e,t,n))}return i}case`doub`:return(0,r.readFloat64)(e);case`UntF`:{let t=(0,r.readSignature)(e),n=(0,r.readFloat64)(e);if(!o[t])throw Error(`Invalid units: ${t}`);return{units:o[t],value:n}}case`UnFl`:{let t=(0,r.readSignature)(e),n=(0,r.readFloat32)(e);if(!o[t])throw Error(`Invalid units: ${t}`);return{units:o[t],value:n}}case`TEXT`:return(0,r.readUnicodeString)(e);case`enum`:return`${b(e)}.${b(e)}`;case`long`:return(0,r.readInt32)(e);case`comp`:return{low:(0,r.readUint32)(e),high:(0,r.readUint32)(e)};case`bool`:return!!(0,r.readUint8)(e);case`type`:case`GlbC`:return A(e);case`alis`:{let t=(0,r.readInt32)(e);return(0,r.readAsciiString)(e,t)}case`tdta`:{let t=(0,r.readInt32)(e);return(0,r.readBytes)(e,t)}case`ObAr`:{(0,r.readInt32)(e),(0,r.readUnicodeString)(e),b(e);let t=(0,r.readInt32)(e),n=[];for(let i=0;i<t;i++){let t=b(e);(0,r.readSignature)(e),(0,r.readSignature)(e);let i=(0,r.readInt32)(e),a=[];for(let t=0;t<i;t++)a.push((0,r.readFloat64)(e));n.push({type:t,values:a})}return n}case`Pth `:{(0,r.readInt32)(e);let t=(0,r.readSignature)(e);(0,r.readInt32LE)(e);let n=(0,r.readInt32LE)(e);return{sig:t,path:(0,r.readUnicodeStringWithLengthLE)(e,n)}}default:throw Error(`Invalid TySh descriptor OSType: ${t} at ${e.offset.toString(16)}`)}}let E={meshPoints:`rationalPoint`,quiltSliceX:`UntF`,quiltSliceY:`UntF`};function D(e,t,n,r,a,o){switch(t){case`obj `:k(e,r,n);break;case`Objc`:case`GlbO`:if(typeof n!=`object`)throw Error(`Invalid struct value: ${JSON.stringify(n)}, key: ${r}`);if(!a)throw Error(`Missing ext type for: '${r}' (${JSON.stringify(n)})`);w(e,n._name||a.name,n._classID||a.classID,n,o);break;case`VlLs`:if(!Array.isArray(n))throw Error(`Invalid list value: ${JSON.stringify(n)}, key: ${r}`);(0,i.writeInt32)(e,n.length);for(let t=0;t<n.length;t++){let a=g[r];(0,i.writeSignature)(e,a||`long`),D(e,a||`long`,n[t],`${r}[]`,p[r],o),c&&!a&&console.log(`Missing descriptor array type for: '${r}' in`,n)}break;case`doub`:if(typeof n!=`number`)throw Error(`Invalid number value: ${JSON.stringify(n)}, key: ${r}`);(0,i.writeFloat64)(e,n);break;case`UntF`:if(!s[n.units])throw Error(`Invalid units: ${n.units} in ${r}`);(0,i.writeSignature)(e,s[n.units]),(0,i.writeFloat64)(e,n.value);break;case`UnFl`:if(!s[n.units])throw Error(`Invalid units: ${n.units} in ${r}`);(0,i.writeSignature)(e,s[n.units]),(0,i.writeFloat32)(e,n.value);break;case`TEXT`:(0,i.writeUnicodeStringWithPadding)(e,n);break;case`enum`:{if(typeof n!=`string`)throw Error(`Invalid enum value: ${JSON.stringify(n)}, key: ${r}`);let[t,i]=n.split(`.`);x(e,t),x(e,i);break}case`long`:if(typeof n!=`number`)throw Error(`Invalid integer value: ${JSON.stringify(n)}, key: ${r}`);(0,i.writeInt32)(e,n);break;case`bool`:if(typeof n!=`boolean`)throw Error(`Invalid boolean value: ${JSON.stringify(n)}, key: ${r}`);(0,i.writeUint8)(e,+!!n);break;case`tdta`:(0,i.writeInt32)(e,n.byteLength),(0,i.writeBytes)(e,n);break;case`ObAr`:{(0,i.writeInt32)(e,16),(0,i.writeUnicodeStringWithPadding)(e,``);let t=E[r];if(!t)throw Error(`Not implemented ObArType for: ${r}`);x(e,t),(0,i.writeInt32)(e,n.length);for(let t=0;t<n.length;t++){x(e,n[t].type),(0,i.writeSignature)(e,`UnFl`),(0,i.writeSignature)(e,`#Pxl`),(0,i.writeInt32)(e,n[t].values.length);for(let r=0;r<n[t].values.length;r++)(0,i.writeFloat64)(e,n[t].values[r])}break}case`Pth `:{let t=12+n.path.length*2;(0,i.writeInt32)(e,t),(0,i.writeSignature)(e,n.sig),(0,i.writeInt32LE)(e,t),(0,i.writeInt32LE)(e,n.path.length),(0,i.writeUnicodeStringWithoutLengthLE)(e,n.path);break}default:throw Error(`Not implemented descriptor OSType: ${t}`)}}function ee(e){let t=(0,r.readInt32)(e),n=[];for(let i=0;i<t;i++){let t=(0,r.readSignature)(e);switch(t){case`prop`:{A(e);let t=b(e);n.push(t);break}case`Clss`:n.push(A(e));break;case`Enmr`:{A(e);let t=b(e),r=b(e);n.push(`${t}.${r}`);break}case`rele`:A(e),n.push((0,r.readUint32)(e));break;case`Idnt`:n.push((0,r.readInt32)(e));break;case`indx`:n.push((0,r.readInt32)(e));break;case`name`:A(e),n.push((0,r.readUnicodeString)(e));break;default:throw Error(`Invalid descriptor reference type: ${t}`)}}return n}function k(e,t,n){(0,i.writeInt32)(e,n.length);for(let t=0;t<n.length;t++){let r=n[t],a=`unknown`;switch(typeof r==`string`&&(a=/^[a-z ]+\.[a-z ]+$/i.test(r)?`Enmr`:`name`),(0,i.writeSignature)(e,a),a){case`Enmr`:{let[t,n]=r.split(`.`);j(e,`\0`,t),x(e,t),x(e,n);break}case`name`:j(e,`\0`,`Lyr `),(0,i.writeUnicodeString)(e,r+`\0`);break;default:throw Error(`Invalid descriptor reference type: ${a}`)}}return n}function A(e){return{name:(0,r.readUnicodeString)(e),classID:b(e)}}function j(e,t,n){(0,i.writeUnicodeString)(e,t),x(e,n)}function M(e,t=!1){let n=(0,r.readUint32)(e);if(n!==16)throw Error(`Invalid descriptor version: ${n}`);return S(e,t)}function N(e,t,n,r,a=``){(0,i.writeUint32)(e,16),w(e,t,n,r,a)}function P(e){return{x:e.Hrzn,y:e.Vrtc}}function F(e){return{Hrzn:e.x,Vrtc:e.y}}function te(e){return{top:X(e[`Top `]),left:X(e.Left),right:X(e.Rght),bottom:X(e.Btom)}}function I(e){return{Left:$(e.left,`bounds.left`),"Top ":$(e.top,`bounds.top`),Rght:$(e.right,`bounds.right`),Btom:$(e.bottom,`bounds.bottom`)}}function L(t){let n={enabled:!!t.enab,position:e.FStl.decode(t.Styl),fillType:e.FrFl.decode(t.PntT),blendMode:e.BlnM.decode(t[`Md `]),opacity:J(t.Opct),size:X(t[`Sz `])};return t.present!==void 0&&(n.present=t.present),t.showInDialog!==void 0&&(n.showInDialog=t.showInDialog),t.overprint!==void 0&&(n.overprint=t.overprint),t[`Clr `]&&(n.color=G(t[`Clr `])),t.Grad&&(n.gradient=U(t)),t.Ptrn&&(n.pattern=ce(t)),n}function R(t){let n={};return n.enab=!!t.enabled,t.present!==void 0&&(n.present=!!t.present),t.showInDialog!==void 0&&(n.showInDialog=!!t.showInDialog),n.Styl=e.FStl.encode(t.position),n.PntT=e.FrFl.encode(t.fillType),n[`Md `]=e.BlnM.encode(t.blendMode),n.Opct=Z(t.opacity),n[`Sz `]=$(t.size,`size`),t.color&&(n[`Clr `]=K(t.color)),t.gradient&&(n=Object.assign(Object.assign({},n),ue(t.gradient))),t.pattern&&(n=Object.assign(Object.assign({},n),W(t.pattern))),t.overprint!==void 0&&(n.overprint=!!t.overprint),n}function ne(e,t,n){let r=n?{"Scl ":Q(e.scale??1),masterFXSwitch:!e.disabled}:{masterFXSwitch:!e.disabled,"Scl ":Q(e.scale??1)};for(let t of[`dropShadow`,`innerShadow`,`solidFill`,`gradientOverlay`,`stroke`])if(e[t]&&!Array.isArray(e[t]))throw Error(`${t} should be an array`);let i=e=>!!e&&e.length>1&&n,a=e=>!!e&&e.length>=1&&(!n||e.length===1);if(a(e.dropShadow)&&(r.DrSh=V(e.dropShadow[0],`dropShadow`,t)),i(e.dropShadow)&&(r.dropShadowMulti=e.dropShadow.map(e=>V(e,`dropShadow`,t))),a(e.innerShadow)&&(r.IrSh=V(e.innerShadow[0],`innerShadow`,t)),i(e.innerShadow)&&(r.innerShadowMulti=e.innerShadow.map(e=>V(e,`innerShadow`,t))),e.outerGlow&&(r.OrGl=V(e.outerGlow,`outerGlow`,t)),i(e.solidFill)&&(r.solidFillMulti=e.solidFill.map(e=>V(e,`solidFill`,t))),i(e.gradientOverlay)&&(r.gradientFillMulti=e.gradientOverlay.map(e=>V(e,`gradientOverlay`,t))),i(e.stroke)&&(r.frameFXMulti=e.stroke.map(e=>R(e))),e.innerGlow&&(r.IrGl=V(e.innerGlow,`innerGlow`,t)),e.bevel&&(r.ebbl=V(e.bevel,`bevel`,t)),a(e.solidFill)&&(r.SoFi=V(e.solidFill[0],`solidFill`,t)),e.patternOverlay&&(r.patternFill=V(e.patternOverlay,`patternOverlay`,t)),a(e.gradientOverlay)&&(r.GrFl=V(e.gradientOverlay[0],`gradientOverlay`,t)),e.satin&&(r.ChFX=V(e.satin,`satin`,t)),a(e.stroke)&&(r.FrFX=R(e.stroke?.[0])),n){r.numModifyingFX=0;for(let t of Object.keys(e)){let n=e[t];if(Array.isArray(n))for(let e of n)e.enabled&&r.numModifyingFX++;else n.enabled&&r.numModifyingFX++}}return r}function z(e,n){let r={},{masterFXSwitch:i,DrSh:a,dropShadowMulti:o,IrSh:s,innerShadowMulti:c,OrGl:l,IrGl:u,ebbl:d,SoFi:f,solidFillMulti:p,patternFill:m,GrFl:h,gradientFillMulti:g,ChFX:_,FrFX:v,frameFXMulti:y,numModifyingFX:b}=e,x=t(e,[`masterFXSwitch`,`DrSh`,`dropShadowMulti`,`IrSh`,`innerShadowMulti`,`OrGl`,`IrGl`,`ebbl`,`SoFi`,`solidFillMulti`,`patternFill`,`GrFl`,`gradientFillMulti`,`ChFX`,`FrFX`,`frameFXMulti`,`numModifyingFX`]);return i||(r.disabled=!0),e[`Scl `]&&(r.scale=J(e[`Scl `])),a&&(r.dropShadow=[B(a,n)]),o&&(r.dropShadow=o.map(e=>B(e,n))),s&&(r.innerShadow=[B(s,n)]),c&&(r.innerShadow=c.map(e=>B(e,n))),l&&(r.outerGlow=B(l,n)),u&&(r.innerGlow=B(u,n)),d&&(r.bevel=B(d,n)),f&&(r.solidFill=[B(f,n)]),p&&(r.solidFill=p.map(e=>B(e,n))),m&&(r.patternOverlay=B(m,n)),h&&(r.gradientOverlay=[B(h,n)]),g&&(r.gradientOverlay=g.map(e=>B(e,n))),_&&(r.satin=B(_,n)),v&&(r.stroke=[L(v)]),y&&(r.stroke=y.map(e=>L(e))),n&&Object.keys(x).length>1&&console.log(`Unhandled effect keys:`,x),r}function re(t,n){let r=[];for(let i=0;i<t.length;i++){let a=t[i],{time:{denominator:o,numerator:s},selected:c,animKey:l}=a,u={numerator:s,denominator:o},d=e.animInterpStyleEnum.decode(a.animInterpStyle);switch(l.Type){case`keyType.Opct`:r.push({interpolation:d,time:u,selected:c,type:`opacity`,value:J(l.Opct)});break;case`keyType.Pstn`:r.push({interpolation:d,time:u,selected:c,type:`position`,x:l.Hrzn,y:l.Vrtc});break;case`keyType.Trnf`:r.push({interpolation:d,time:u,selected:c,type:`transform`,scale:P(l[`Scl `]),skew:P(l.Skew),rotation:l.rotation,translation:P(l.translation)});break;case`keyType.sheetStyle`:{let e={interpolation:d,time:u,selected:c,type:`style`};l.sheetStyle.Lefx&&(e.style=z(l.sheetStyle.Lefx,n)),r.push(e);break}case`keyType.globalLighting`:r.push({interpolation:d,time:u,selected:c,type:`globalLighting`,globalAngle:l.gblA,globalAltitude:l.globalAltitude});break;default:throw Error(`Unsupported keyType value`)}}return r}function ie(t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],{time:a,selected:o=!1,interpolation:s}=i,c=e.animInterpStyleEnum.encode(s),l;switch(i.type){case`opacity`:l={Type:`keyType.Opct`,Opct:Z(i.value)};break;case`position`:l={Type:`keyType.Pstn`,Hrzn:i.x,Vrtc:i.y};break;case`transform`:l={Type:`keyType.Trnf`,"Scl ":F(i.scale),Skew:F(i.skew),rotation:i.rotation,translation:F(i.translation)};break;case`style`:l={Type:`keyType.sheetStyle`,sheetStyle:{Vrsn:1,blendOptions:{}}},i.style&&(l.sheetStyle={Vrsn:1,Lefx:ne(i.style,!1,!1),blendOptions:{}});break;case`globalLighting`:l={Type:`keyType.globalLighting`,gblA:i.globalAngle,globalAltitude:i.globalAltitude};break;default:throw Error(`Unsupported keyType value`)}n.push({Vrsn:1,animInterpStyle:c,time:a,animKey:l,selected:o})}return n}function ae(t,n){let r=[];for(let i=0;i<t.length;i++){let a=t[i],o={type:e.stdTrackID.decode(a.trackID),enabled:a.enab,keys:re(a.keyList,n)};a.effectParams&&(o.effectParams={fillCanvas:a.effectParams.fillCanvas,zoomOrigin:a.effectParams.zoomOrigin,keys:re(a.effectParams.keyList,n)}),r.push(o)}return r}function oe(t){let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(Object.assign(Object.assign({trackID:e.stdTrackID.encode(i.type),Vrsn:1,enab:!!i.enabled,Effc:!!i.effectParams},i.effectParams?{effectParams:{keyList:ie(i.keys),fillCanvas:i.effectParams.fillCanvas,zoomOrigin:i.effectParams.zoomOrigin}}:{}),{keyList:ie(i.keys)}))}return n}function B(t,n){let r={};for(let i of Object.keys(t)){let a=t[i];switch(i){case`enab`:r.enabled=!!a;break;case`uglg`:r.useGlobalLight=!!a;break;case`AntA`:r.antialiased=!!a;break;case`Algn`:r.align=!!a;break;case`Dthr`:r.dither=!!a;break;case`Invr`:r.invert=!!a;break;case`Rvrs`:r.reverse=!!a;break;case`Clr `:r.color=G(a);break;case`hglC`:r.highlightColor=G(a);break;case`sdwC`:r.shadowColor=G(a);break;case`Styl`:r.position=e.FStl.decode(a);break;case`Md `:r.blendMode=e.BlnM.decode(a);break;case`hglM`:r.highlightBlendMode=e.BlnM.decode(a);break;case`sdwM`:r.shadowBlendMode=e.BlnM.decode(a);break;case`bvlS`:r.style=e.BESl.decode(a);break;case`bvlD`:r.direction=e.BESs.decode(a);break;case`bvlT`:r.technique=e.bvlT.decode(a);break;case`GlwT`:r.technique=e.BETE.decode(a);break;case`glwS`:r.source=e.IGSr.decode(a);break;case`Type`:r.type=e.GrdT.decode(a);break;case`gs99`:r.interpolationMethod=e.gradientInterpolationMethodType.decode(a);break;case`Opct`:r.opacity=J(a);break;case`hglO`:r.highlightOpacity=J(a);break;case`sdwO`:r.shadowOpacity=J(a);break;case`lagl`:r.angle=q(a);break;case`Angl`:r.angle=q(a);break;case`Lald`:r.altitude=q(a);break;case`Sftn`:r.soften=X(a);break;case`srgR`:r.strength=J(a);break;case`blur`:r.size=X(a);break;case`Nose`:r.noise=J(a);break;case`Inpr`:r.range=J(a);break;case`Ckmt`:r.choke=X(a);break;case`ShdN`:r.jitter=J(a);break;case`Dstn`:r.distance=X(a);break;case`Scl `:r.scale=J(a);break;case`Ptrn`:r.pattern={name:a[`Nm `],id:a.Idnt};break;case`phase`:r.phase={x:a.Hrzn,y:a.Vrtc};break;case`Ofst`:r.offset={x:J(a.Hrzn),y:J(a.Vrtc)};break;case`MpgS`:case`TrnS`:r.contour={name:a[`Nm `],curve:a[`Crv `].map(e=>({x:e.Hrzn,y:e.Vrtc}))};break;case`Grad`:r.gradient=se(a);break;case`useTexture`:case`useShape`:case`layerConceals`:case`present`:case`showInDialog`:case`antialiasGloss`:r[i]=a;break;case`_name`:case`_classID`:break;default:n&&console.log(`Invalid effect key: '${i}', value:`,a)}}return r}function V(t,n,r){let i={enab:!1};n===`dropShadow`&&(i.TrnS={"Nm ":``,"Crv ":[]});for(let a of Object.keys(t)){let o=a,s=t[o];switch(o){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 `]=K(s);break;case`highlightColor`:i.hglC=K(s);break;case`shadowColor`:i.sdwC=K(s);break;case`position`:i.Styl=e.FStl.encode(s);break;case`blendMode`:i[`Md `]=e.BlnM.encode(s);break;case`highlightBlendMode`:i.hglM=e.BlnM.encode(s);break;case`shadowBlendMode`:i.sdwM=e.BlnM.encode(s);break;case`style`:i.bvlS=e.BESl.encode(s);break;case`direction`:i.bvlD=e.BESs.encode(s);break;case`technique`:n===`bevel`?i.bvlT=e.bvlT.encode(s):i.GlwT=e.BETE.encode(s);break;case`source`:i.glwS=e.IGSr.encode(s);break;case`type`:i.Type=e.GrdT.encode(s);break;case`interpolationMethod`:i.gs99=e.gradientInterpolationMethodType.encode(s);break;case`opacity`:i.Opct=Z(s);break;case`highlightOpacity`:i.hglO=Z(s);break;case`shadowOpacity`:i.sdwO=Z(s);break;case`angle`:n===`gradientOverlay`||n===`patternFill`?i.Angl=me(s):i.lagl=me(s);break;case`altitude`:i.Lald=me(s);break;case`soften`:i.Sftn=$(s,o);break;case`strength`:i.srgR=Z(s);break;case`size`:i.blur=$(s,o);break;case`noise`:i.Nose=Z(s);break;case`range`:i.Inpr=Z(s);break;case`choke`:i.Ckmt=$(s,o);break;case`jitter`:i.ShdN=Z(s);break;case`distance`:i.Dstn=$(s,o);break;case`scale`:i[`Scl `]=Z(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:Z(s.x),Vrtc:Z(s.y)};break;case`contour`:i[n===`satin`?`MpgS`:`TrnS`]={"Nm ":s.name,"Crv ":s.curve.map(e=>({Hrzn:e.x,Vrtc:e.y}))};break;case`gradient`:i.Grad=H(s);break;case`useTexture`:case`useShape`:case`layerConceals`:case`present`:case`showInDialog`:case`antialiasGloss`:i[o]=s;break;default:r&&console.log(`Invalid effect key: '${o}', value:`,s)}}return i}function se(t){if(t.GrdF===`GrdF.CstS`){let e=t.Intr||4096;return{type:`solid`,name:t[`Nm `],smoothness:t.Intr/4096,colorStops:t.Clrs.map(t=>({color:G(t[`Clr `]),location:t.Lctn/e,midpoint:t.Mdpn/100})),opacityStops:t.Trns.map(t=>({opacity:J(t.Opct),location:t.Lctn/e,midpoint:t.Mdpn/100}))}}else return{type:`noise`,name:t[`Nm `],roughness:t.Smth/4096,colorModel:e.ClrS.decode(t.ClrS),randomSeed:t.RndS,restrictColors:!!t.VctC,addTransparency:!!t.ShTr,min:t[`Mnm `].map(e=>e/100),max:t[`Mxm `].map(e=>e/100)}}function H(t){if(t.type===`solid`){let e=Math.round((t.smoothness??1)*4096);return{"Nm ":t.name||``,GrdF:`GrdF.CstS`,Intr:e,Clrs:t.colorStops.map(t=>({"Clr ":K(t.color),Type:`Clry.UsrS`,Lctn:Math.round(t.location*e),Mdpn:Math.round((t.midpoint??.5)*100)})),Trns:t.opacityStops.map(t=>({Opct:Z(t.opacity),Lctn:Math.round(t.location*e),Mdpn:Math.round((t.midpoint??.5)*100)}))}}else return{GrdF:`GrdF.ClNs`,"Nm ":t.name||``,ShTr:!!t.addTransparency,VctC:!!t.restrictColors,ClrS:e.ClrS.encode(t.colorModel),RndS:t.randomSeed||0,Smth:Math.round((t.roughness??1)*4096),"Mnm ":(t.min||[0,0,0,0]).map(e=>e*100),"Mxm ":(t.max||[1,1,1,1]).map(e=>e*100)}}function U(t){let n=se(t.Grad);return n.style=e.GrdT.decode(t.Type),t.Dthr!==void 0&&(n.dither=t.Dthr),t.gradientsInterpolationMethod!==void 0&&(n.interpolationMethod=e.gradientInterpolationMethodType.decode(t.gradientsInterpolationMethod)),t.Rvrs!==void 0&&(n.reverse=t.Rvrs),t.Angl!==void 0&&(n.angle=q(t.Angl)),t[`Scl `]!==void 0&&(n.scale=J(t[`Scl `])),t.Algn!==void 0&&(n.align=t.Algn),t.Ofst!==void 0&&(n.offset={x:J(t.Ofst.Hrzn),y:J(t.Ofst.Vrtc)}),n}function ce(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 le(e){if(`Grad`in e)return U(e);if(`Ptrn`in e)return Object.assign({type:`pattern`},ce(e));if(`Clr `in e)return{type:`color`,color:G(e[`Clr `])};throw Error(`Invalid vector content`)}function ue(t){let n={};return t.dither!==void 0&&(n.Dthr=t.dither),t.interpolationMethod!==void 0&&(n.gradientsInterpolationMethod=e.gradientInterpolationMethodType.encode(t.interpolationMethod)),t.reverse!==void 0&&(n.Rvrs=t.reverse),t.angle!==void 0&&(n.Angl=me(t.angle)),n.Type=e.GrdT.encode(t.style),t.align!==void 0&&(n.Algn=t.align),t.scale!==void 0&&(n[`Scl `]=Z(t.scale)),t.offset&&(n.Ofst={Hrzn:Z(t.offset.x),Vrtc:Z(t.offset.y)}),n.Grad=H(t),n}function W(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 de(e){return e.type===`color`?{key:`SoCo`,descriptor:{"Clr ":K(e.color)}}:e.type===`pattern`?{key:`PtFl`,descriptor:W(e)}:{key:`GdFl`,descriptor:ue(e)}}function G(e){if(`H `in e)return{h:Y(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 Error(`Unsupported color descriptor`)}function K(e){if(!e)return{_name:``,_classID:`RGBC`,"Rd ":0,"Grn ":0,"Bl ":0};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 ":me(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 Error(`Invalid color value`)}function q(e){if(e===void 0)return 0;if(e.units!==`Angle`)throw Error(`Invalid units: ${e.units}`);return e.value}function J(e){if(e===void 0)return 1;if(e.units!==`Percent`)throw Error(`Invalid units: ${e.units}`);return e.value/100}function Y(e){if(e===void 0)return 1;if(e.units===`Percent`)return e.value/100;if(e.units===`Angle`)return e.value/360;throw Error(`Invalid units: ${e.units}`)}function X({units:e,value:t}){if(e!==`Pixels`&&e!==`Millimeters`&&e!==`Points`&&e!==`None`&&e!==`Picas`&&e!==`Inches`&&e!==`Centimeters`&&e!==`Density`)throw Error(`Invalid units: ${JSON.stringify({units:e,value:t})}`);return{value:t,units:e}}function fe(e,t=`Pixels`){return typeof e==`number`?{value:e,units:t}:X(e)}function pe({units:e,value:t},n){if(e!==n)throw Error(`Invalid units: ${JSON.stringify({units:e,value:t})}`);return t}function me(e){return{units:`Angle`,value:e||0}}function Z(e){return{units:`Percent`,value:Math.round((e||0)*100)}}function Q(e){return{units:`Percent`,value:(e||0)*100}}function $(e,t){if(e==null)return{units:`Pixels`,value:0};if(typeof e!=`object`)throw Error(`Invalid value: ${JSON.stringify(e)} (key: ${t}) (should have value and units)`);let{units:n,value:r}=e;if(typeof r!=`number`)throw 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 Error(`Invalid units in ${JSON.stringify(e)} (key: ${t})`);return{units:n,value:r}}function he({numerator:e,denominator:t}){return{numerator:e,denominator:t}}e.textGridding=(0,n.createEnum)(`textGridding`,`none`,{none:`None`,round:`Rnd `}),e.Ornt=(0,n.createEnum)(`Ornt`,`horizontal`,{horizontal:`Hrzn`,vertical:`Vrtc`}),e.Annt=(0,n.createEnum)(`Annt`,`sharp`,{none:`Anno`,sharp:`antiAliasSharp`,crisp:`AnCr`,strong:`AnSt`,smooth:`AnSm`,platform:`antiAliasPlatformGray`,platformLCD:`antiAliasPlatformLCD`}),e.warpStyle=(0,n.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`}),e.BlnM=(0,n.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":`????`}),e.BESl=(0,n.createEnum)(`BESl`,`inner bevel`,{"inner bevel":`InrB`,"outer bevel":`OtrB`,emboss:`Embs`,"pillow emboss":`PlEb`,"stroke emboss":`strokeEmboss`}),e.bvlT=(0,n.createEnum)(`bvlT`,`smooth`,{smooth:`SfBL`,"chisel hard":`PrBL`,"chisel soft":`Slmt`}),e.BESs=(0,n.createEnum)(`BESs`,`up`,{up:`In `,down:`Out `}),e.BETE=(0,n.createEnum)(`BETE`,`softer`,{softer:`SfBL`,precise:`PrBL`}),e.IGSr=(0,n.createEnum)(`IGSr`,`edge`,{edge:`SrcE`,center:`SrcC`}),e.GrdT=(0,n.createEnum)(`GrdT`,`linear`,{linear:`Lnr `,radial:`Rdl `,angle:`Angl`,reflected:`Rflc`,diamond:`Dmnd`}),e.animInterpStyleEnum=(0,n.createEnum)(`animInterpStyle`,`linear`,{linear:`Lnr `,hold:`hold`}),e.stdTrackID=(0,n.createEnum)(`stdTrackID`,`opacity`,{opacity:`opacityTrack`,style:`styleTrack`,sheetTransform:`sheetTransformTrack`,sheetPosition:`sheetPositionTrack`,globalLighting:`globalLightingTrack`}),e.gradientInterpolationMethodType=(0,n.createEnum)(`gradientInterpolationMethodType`,`perceptual`,{perceptual:`Perc`,linear:`Lnr `,classic:`Gcls`,smooth:`Smoo`}),e.ClrS=(0,n.createEnum)(`ClrS`,`rgb`,{rgb:`RGBC`,hsb:`HSBl`,lab:`LbCl`,hsl:`HSLC`}),e.FStl=(0,n.createEnum)(`FStl`,`outside`,{outside:`OutF`,center:`CtrF`,inside:`InsF`}),e.FrFl=(0,n.createEnum)(`FrFl`,`color`,{color:`SClr`,gradient:`GrFl`,pattern:`Ptrn`}),e.ESliceType=(0,n.createEnum)(`ESliceType`,`image`,{image:`Img `,noImage:`noImage`}),e.ESliceHorzAlign=(0,n.createEnum)(`ESliceHorzAlign`,`default`,{default:`default`}),e.ESliceVertAlign=(0,n.createEnum)(`ESliceVertAlign`,`default`,{default:`default`}),e.ESliceOrigin=(0,n.createEnum)(`ESliceOrigin`,`userGenerated`,{userGenerated:`userGenerated`,autoGenerated:`autoGenerated`,layer:`layer`}),e.ESliceBGColorType=(0,n.createEnum)(`ESliceBGColorType`,`none`,{none:`None`,matte:`matte`,color:`Clr `}),e.strokeStyleLineCapType=(0,n.createEnum)(`strokeStyleLineCapType`,`butt`,{butt:`strokeStyleButtCap`,round:`strokeStyleRoundCap`,square:`strokeStyleSquareCap`}),e.strokeStyleLineJoinType=(0,n.createEnum)(`strokeStyleLineJoinType`,`miter`,{miter:`strokeStyleMiterJoin`,round:`strokeStyleRoundJoin`,bevel:`strokeStyleBevelJoin`}),e.strokeStyleLineAlignment=(0,n.createEnum)(`strokeStyleLineAlignment`,`inside`,{inside:`strokeStyleAlignInside`,center:`strokeStyleAlignCenter`,outside:`strokeStyleAlignOutside`}),e.BlrM=(0,n.createEnum)(`BlrM`,`spin`,{spin:`Spn `,zoom:`Zm `}),e.BlrQ=(0,n.createEnum)(`BlrQ`,`good`,{draft:`Drft`,good:`Gd `,best:`Bst `}),e.SmBM=(0,n.createEnum)(`SmBM`,`normal`,{normal:`SBMN`,"edge only":`SBME`,"overlay edge":`SBMO`}),e.SmBQ=(0,n.createEnum)(`SmBQ`,`medium`,{low:`SBQL`,medium:`SBQM`,high:`SBQH`}),e.DspM=(0,n.createEnum)(`DspM`,`stretch to fit`,{"stretch to fit":`StrF`,tile:`Tile`}),e.UndA=(0,n.createEnum)(`UndA`,`repeat edge pixels`,{"wrap around":`WrpA`,"repeat edge pixels":`RptE`}),e.Cnvr=(0,n.createEnum)(`Cnvr`,`rectangular to polar`,{"rectangular to polar":`RctP`,"polar to rectangular":`PlrR`}),e.RplS=(0,n.createEnum)(`RplS`,`medium`,{small:`Sml `,medium:`Mdm `,large:`Lrg `}),e.SphM=(0,n.createEnum)(`SphM`,`normal`,{normal:`Nrml`,"horizontal only":`HrzO`,"vertical only":`VrtO`}),e.Wvtp=(0,n.createEnum)(`Wvtp`,`sine`,{sine:`WvSn`,triangle:`WvTr`,square:`WvSq`}),e.ZZTy=(0,n.createEnum)(`ZZTy`,`pond ripples`,{"around center":`ArnC`,"out from center":`OtFr`,"pond ripples":`PndR`}),e.Dstr=(0,n.createEnum)(`Dstr`,`uniform`,{uniform:`Unfr`,gaussian:`Gsn `}),e.Chnl=(0,n.createEnum)(`Chnl`,`composite`,{red:`Rd `,green:`Grn `,blue:`Bl `,composite:`Cmps`}),e.MztT=(0,n.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`}),e.Lns=(0,n.createEnum)(`Lns `,`50-300mm zoom`,{"50-300mm zoom":`Zm `,"32mm prime":`Nkn `,"105mm prime":`Nkn1`,"movie prime":`PnVs`}),e.blurType=(0,n.createEnum)(`blurType`,`gaussian blur`,{"gaussian blur":`GsnB`,"lens blur":`lensBlur`,"motion blur":`MtnB`}),e.DfsM=(0,n.createEnum)(`DfsM`,`normal`,{normal:`Nrml`,"darken only":`DrkO`,"lighten only":`LghO`,anisotropic:`anisotropic`}),e.ExtT=(0,n.createEnum)(`ExtT`,`blocks`,{blocks:`Blks`,pyramids:`Pyrm`}),e.ExtR=(0,n.createEnum)(`ExtR`,`random`,{random:`Rndm`,"level-based":`LvlB`}),e.FlCl=(0,n.createEnum)(`FlCl`,`background color`,{"background color":`FlBc`,"foreground color":`FlFr`,"inverse image":`FlIn`,"unaltered image":`FlSm`}),e.CntE=(0,n.createEnum)(`CntE`,`upper`,{lower:`Lwr `,upper:`Upr `}),e.WndM=(0,n.createEnum)(`WndM`,`wind`,{wind:`Wnd `,blast:`Blst`,stagger:`Stgr`}),e.Drct=(0,n.createEnum)(`Drct`,`right`,{left:`Left`,right:`Rght`}),e.IntE=(0,n.createEnum)(`IntE`,`odd lines`,{"odd lines":`ElmO`,"even lines":`ElmE`}),e.IntC=(0,n.createEnum)(`IntC`,`interpolation`,{duplication:`CrtD`,interpolation:`CrtI`}),e.FlMd=(0,n.createEnum)(`FlMd`,`wrap around`,{"set to transparent":`Bckg`,"repeat edge pixels":`Rpt `,"wrap around":`Wrp `}),e.prjM=(0,n.createEnum)(`prjM`,`fisheye`,{fisheye:`fisP`,perspective:`perP`,auto:`auto`,"full spherical":`fusP`}),e.presetKindType=(0,n.createEnum)(`presetKindType`,`custom`,{custom:`presetKindCustom`,default:`presetKindDefault`})})),S=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resourceHandlersMap=e.resourceHandlers=void 0;let t=y(),n=C(),r=O(),i=v(),a=b(),o=x();e.resourceHandlers=[],e.resourceHandlersMap={};function s(t,n,r,i){let a={key:t,has:n,read:r,write:i};e.resourceHandlers.push(a),e.resourceHandlersMap[a.key]=a}let c=[void 0,`PPI`,`PPCM`],l=[void 0,`Inches`,`Centimeters`,`Points`,`Picas`,`Columns`],u=`0123456789abcdef`;function d(e){return e<=57?e-48:e>=97?e-87:e-55}function f(e,t){return d(e.charCodeAt(t))<<4|d(e.charCodeAt(t+1))}function p(e,t){let r=(0,n.readBytes)(e,t);return(0,a.decodeString)(r)}function m(e,t){let n=(0,a.encodeString)(t);(0,r.writeBytes)(e,n)}function h(e){let t=(0,n.readUint8)(e),r=(0,n.readBytes)(e,t),i=!1;for(let e=0;e<r.byteLength;e++)if(r[e]&128){i=!0;break}if(i)try{return new TextDecoder(`gbk`).decode(r)}catch{}return(0,a.decodeString)(r)}function g(e,t){let n=``;for(let e=0,r=t.codePointAt(e++);r!==void 0;r=t.codePointAt(e++))n+=r>127?`?`:String.fromCodePoint(r);let i=(0,a.encodeString)(n);(0,r.writeUint8)(e,i.byteLength),(0,r.writeBytes)(e,i)}i.MOCK_HANDLERS&&s(1028,e=>e._ir1028!==void 0,(e,t,r)=>{t._ir1028=(0,n.readBytes)(e,r())},(e,t)=>{(0,r.writeBytes)(e,t._ir1028)}),s(1061,e=>e.captionDigest!==void 0,(e,t)=>{let r=``;for(let t=0;t<16;t++){let t=(0,n.readUint8)(e);r+=u[t>>4],r+=u[t&15]}t.captionDigest=r},(e,t)=>{for(let n=0;n<16;n++)(0,r.writeUint8)(e,f(t.captionDigest,n*2))}),s(1060,e=>e.xmpMetadata!==void 0,(e,t,n)=>{t.xmpMetadata=p(e,n())},(e,t)=>{m(e,t.xmpMetadata)});let _=(0,i.createEnum)(`Inte`,`perceptual`,{perceptual:`Img `,saturation:`Grp `,"relative colorimetric":`Clrm`,"absolute colorimetric":`AClr`});i.MOCK_HANDLERS&&s(1085,e=>e._ir1085!==void 0,(e,t,r)=>{t._ir1085=(0,n.readBytes)(e,r())},(e,t)=>{(0,r.writeBytes)(e,t._ir1085)}),s(1082,e=>e.printInformation!==void 0,(e,t)=>{let n=(0,o.readVersionAndDescriptor)(e);t.printInformation={printerName:n.printerName||``,renderingIntent:_.decode(n.Inte??`Inte.Img `)};let r=t.printInformation;n.PstS!==void 0&&(r.printerManagesColors=n.PstS),n[`Nm `]!==void 0&&(r.printerProfile=n[`Nm `]),n.MpBl!==void 0&&(r.blackPointCompensation=n.MpBl),n.printSixteenBit!==void 0&&(r.printSixteenBit=n.printSixteenBit),n.hardProof!==void 0&&(r.hardProof=n.hardProof),n.printProofSetup&&(`Bltn`in n.printProofSetup?r.proofSetup={builtin:n.printProofSetup.Bltn.split(`.`)[1]}:r.proofSetup={profile:n.printProofSetup.profile,renderingIntent:_.decode(n.printProofSetup.Inte??`Inte.Img `),blackPointCompensation:!!n.printProofSetup.MpBl,paperWhite:!!n.printProofSetup.paperWhite})},(e,t)=>{let n=t.printInformation,r={};n.printerManagesColors?r.PstS=!0:(n.hardProof!==void 0&&(r.hardProof=!!n.hardProof),r.ClrS=`ClrS.RGBC`,r[`Nm `]=n.printerProfile??`CIE RGB`),r.Inte=_.encode(n.renderingIntent),n.printerManagesColors||(r.MpBl=!!n.blackPointCompensation),r.printSixteenBit=!!n.printSixteenBit,r.printerName=n.printerName||``,n.proofSetup&&`profile`in n.proofSetup?r.printProofSetup={profile:n.proofSetup.profile||``,Inte:_.encode(n.proofSetup.renderingIntent),MpBl:!!n.proofSetup.blackPointCompensation,paperWhite:!!n.proofSetup.paperWhite}:r.printProofSetup={Bltn:n.proofSetup?.builtin?`builtinProof.${n.proofSetup.builtin}`:`builtinProof.proofCMYK`},(0,o.writeVersionAndDescriptor)(e,``,`printOutput`,r)}),i.MOCK_HANDLERS&&s(1083,e=>e._ir1083!==void 0,(e,t,r)=>{t._ir1083=(0,n.readBytes)(e,r())},(e,t)=>{(0,r.writeBytes)(e,t._ir1083)}),s(1005,e=>e.resolutionInfo!==void 0,(e,t)=>{let r=(0,n.readFixedPoint32)(e),i=(0,n.readUint16)(e),a=(0,n.readUint16)(e),o=(0,n.readFixedPoint32)(e),s=(0,n.readUint16)(e),u=(0,n.readUint16)(e);t.resolutionInfo={horizontalResolution:r,horizontalResolutionUnit:c[i]||`PPI`,widthUnit:l[a]||`Inches`,verticalResolution:o,verticalResolutionUnit:c[s]||`PPI`,heightUnit:l[u]||`Inches`}},(e,t)=>{let n=t.resolutionInfo;(0,r.writeFixedPoint32)(e,n.horizontalResolution||0),(0,r.writeUint16)(e,Math.max(1,c.indexOf(n.horizontalResolutionUnit))),(0,r.writeUint16)(e,Math.max(1,l.indexOf(n.widthUnit))),(0,r.writeFixedPoint32)(e,n.verticalResolution||0),(0,r.writeUint16)(e,Math.max(1,c.indexOf(n.verticalResolutionUnit))),(0,r.writeUint16)(e,Math.max(1,l.indexOf(n.heightUnit)))});let S=[`centered`,`size to fit`,`user defined`];s(1062,e=>e.printScale!==void 0,(e,t)=>{t.printScale={style:S[(0,n.readInt16)(e)],x:(0,n.readFloat32)(e),y:(0,n.readFloat32)(e),scale:(0,n.readFloat32)(e)}},(e,t)=>{let{style:n,x:i,y:a,scale:o}=t.printScale;(0,r.writeInt16)(e,Math.max(0,S.indexOf(n))),(0,r.writeFloat32)(e,i||0),(0,r.writeFloat32)(e,a||0),(0,r.writeFloat32)(e,o||0)}),s(1006,e=>e.alphaChannelNames!==void 0,(e,t,r)=>{if(t.alphaChannelNames)(0,n.skipBytes)(e,r());else for(t.alphaChannelNames=[];r()>0;){let n=h(e);t.alphaChannelNames.push(n)}},(e,t)=>{for(let n of t.alphaChannelNames)g(e,n)}),s(1045,e=>e.alphaChannelNames!==void 0,(e,t,r)=>{for(t.alphaChannelNames=[];r()>0;)t.alphaChannelNames.push((0,n.readUnicodeString)(e))},(e,t)=>{for(let n of t.alphaChannelNames)(0,r.writeUnicodeStringWithPadding)(e,n)}),i.MOCK_HANDLERS&&s(1077,e=>e._ir1077!==void 0,(e,t,r)=>{t._ir1077=(0,n.readBytes)(e,r())},(e,t)=>{(0,r.writeBytes)(e,t._ir1077)}),s(1053,e=>e.alphaIdentifiers!==void 0,(e,t,r)=>{for(t.alphaIdentifiers=[];r()>=4;)t.alphaIdentifiers.push((0,n.readUint32)(e))},(e,t)=>{for(let n of t.alphaIdentifiers)(0,r.writeUint32)(e,n)}),s(1010,e=>e.backgroundColor!==void 0,(e,t)=>t.backgroundColor=(0,n.readColor)(e),(e,t)=>(0,r.writeColor)(e,t.backgroundColor)),s(1037,e=>e.globalAngle!==void 0,(e,t)=>t.globalAngle=(0,n.readInt32)(e),(e,t)=>(0,r.writeInt32)(e,t.globalAngle)),s(1049,e=>e.globalAltitude!==void 0,(e,t)=>t.globalAltitude=(0,n.readUint32)(e),(e,t)=>(0,r.writeUint32)(e,t.globalAltitude)),s(1011,e=>e.printFlags!==void 0,(e,t)=>{t.printFlags={labels:!!(0,n.readUint8)(e),cropMarks:!!(0,n.readUint8)(e),colorBars:!!(0,n.readUint8)(e),registrationMarks:!!(0,n.readUint8)(e),negative:!!(0,n.readUint8)(e),flip:!!(0,n.readUint8)(e),interpolate:!!(0,n.readUint8)(e),caption:!!(0,n.readUint8)(e),printFlags:!!(0,n.readUint8)(e)}},(e,t)=>{let n=t.printFlags;(0,r.writeUint8)(e,+!!n.labels),(0,r.writeUint8)(e,+!!n.cropMarks),(0,r.writeUint8)(e,+!!n.colorBars),(0,r.writeUint8)(e,+!!n.registrationMarks),(0,r.writeUint8)(e,+!!n.negative),(0,r.writeUint8)(e,+!!n.flip),(0,r.writeUint8)(e,+!!n.interpolate),(0,r.writeUint8)(e,+!!n.caption),(0,r.writeUint8)(e,+!!n.printFlags)}),s(1034,e=>e.copyrighted!==void 0,(e,t)=>{t.copyrighted=!!(0,n.readUint8)(e)},(e,t)=>{(0,r.writeUint8)(e,+!!t.copyrighted)}),s(1035,e=>e.url!==void 0,(e,t,r)=>{t.url=(0,n.readAsciiString)(e,r())},(e,t)=>{(0,r.writeAsciiString)(e,t.url)}),i.MOCK_HANDLERS&&s(1e4,e=>e._ir10000!==void 0,(e,t,r)=>{t._ir10000=(0,n.readBytes)(e,r())},(e,t)=>{(0,r.writeBytes)(e,t._ir10000)}),i.MOCK_HANDLERS&&s(1013,e=>e._ir1013!==void 0,(e,t,r)=>{t._ir1013=(0,n.readBytes)(e,r())},(e,t)=>{(0,r.writeBytes)(e,t._ir1013)}),i.MOCK_HANDLERS&&s(1016,e=>e._ir1016!==void 0,(e,t,r)=>{t._ir1016=(0,n.readBytes)(e,r())},(e,t)=>{(0,r.writeBytes)(e,t._ir1016)}),s(1080,e=>e.countInformation!==void 0,(e,t)=>{t.countInformation=(0,o.readVersionAndDescriptor)(e).countGroupList.map(e=>({color:{r:e[`Rd `],g:e[`Grn `],b:e[`Bl `]},name:e[`Nm `],size:e[`Rds `],fontSize:e.fontSize,visible:e.Vsbl,points:e.countObjectList.map(e=>({x:e[`X `],y:e[`Y `]}))}))},(e,t)=>{let n={Vrsn:1,countGroupList:t.countInformation.map(e=>({"Rd ":e.color.r,"Grn ":e.color.g,"Bl ":e.color.b,"Nm ":e.name,"Rds ":e.size,fontSize:e.fontSize,Vsbl:e.visible,countObjectList:e.points.map(e=>({"X ":e.x,"Y ":e.y}))}))};(0,o.writeVersionAndDescriptor)(e,``,`Cnt `,n)}),s(1024,e=>e.layerState!==void 0,(e,t)=>t.layerState=(0,n.readUint16)(e),(e,t)=>(0,r.writeUint16)(e,t.layerState)),s(1026,e=>e.layersGroup!==void 0,(e,t,r)=>{for(t.layersGroup=[];r()>0;)t.layersGroup.push((0,n.readUint16)(e))},(e,t)=>{for(let n of t.layersGroup)(0,r.writeUint16)(e,n)}),s(1072,e=>e.layerGroupsEnabledId!==void 0,(e,t,r)=>{for(t.layerGroupsEnabledId=[];r()>0;)t.layerGroupsEnabledId.push((0,n.readUint8)(e))},(e,t)=>{for(let n of t.layerGroupsEnabledId)(0,r.writeUint8)(e,n)}),s(1069,e=>e.layerSelectionIds!==void 0,(e,t)=>{let r=(0,n.readUint16)(e);for(t.layerSelectionIds=[];r--;)t.layerSelectionIds.push((0,n.readUint32)(e))},(e,t)=>{(0,r.writeUint16)(e,t.layerSelectionIds.length);for(let n of t.layerSelectionIds)(0,r.writeUint32)(e,n)}),s(1032,e=>e.gridAndGuidesInformation!==void 0,(e,t)=>{let r=(0,n.readUint32)(e),i=(0,n.readUint32)(e),a=(0,n.readUint32)(e),o=(0,n.readUint32)(e);if(r!==1)throw Error(`Invalid 1032 resource version: ${r}`);t.gridAndGuidesInformation={grid:{horizontal:i,vertical:a},guides:[]};for(let r=0;r<o;r++)t.gridAndGuidesInformation.guides.push({location:(0,n.readUint32)(e)/32,direction:(0,n.readUint8)(e)?`horizontal`:`vertical`})},(e,t)=>{let n=t.gridAndGuidesInformation,i=n.grid||{horizontal:576,vertical:576},a=n.guides||[];(0,r.writeUint32)(e,1),(0,r.writeUint32)(e,i.horizontal),(0,r.writeUint32)(e,i.vertical),(0,r.writeUint32)(e,a.length);for(let t of a)(0,r.writeUint32)(e,t.location*32),(0,r.writeUint8)(e,+(t.direction===`horizontal`))}),s(1065,e=>e.layerComps!==void 0,(e,t)=>{let n=(0,o.readVersionAndDescriptor)(e,!0);t.layerComps={list:[]};for(let e of n.list)t.layerComps.list.push({id:e.compID,name:e[`Nm `],capturedInfo:e.capturedInfo}),`comment`in e&&(t.layerComps.list[t.layerComps.list.length-1].comment=e.comment);`lastAppliedComp`in n&&(t.layerComps.lastApplied=n.lastAppliedComp)},(e,t)=>{let n=t.layerComps,r={list:[]};for(let e of n.list){let t={};t._classID=`Comp`,t[`Nm `]=e.name,`comment`in e&&(t.comment=e.comment),t.compID=e.id,t.capturedInfo=e.capturedInfo,r.list.push(t)}`lastApplied`in n&&(r.lastAppliedComp=n.lastApplied),(0,o.writeVersionAndDescriptor)(e,``,`CompList`,r)}),i.MOCK_HANDLERS&&s(1092,e=>e._ir1092!==void 0,(e,t,r)=>{t._ir1092=(0,n.readBytes)(e,r())},(e,t)=>{(0,r.writeBytes)(e,t._ir1092)});let w=[`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`];s(1078,e=>e.onionSkins!==void 0,(e,t)=>{let n=(0,o.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:w[n.BlnM]||`normal`}},(e,t)=>{let n=t.onionSkins,r={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,w.indexOf(n.blendMode))};(0,o.writeVersionAndDescriptor)(e,``,`null`,r)}),s(1075,e=>e.timelineInformation!==void 0,(e,t)=>{let n=(0,o.readVersionAndDescriptor)(e);t.timelineInformation={enabled:n.enab,frameStep:(0,o.frac)(n.frameStep),frameRate:n.frameRate,time:(0,o.frac)(n.time),duration:(0,o.frac)(n.duration),workInTime:(0,o.frac)(n.workInTime),workOutTime:(0,o.frac)(n.workOutTime),repeats:n.LCnt,hasMotion:n.hasMotion,globalTracks:(0,o.parseTrackList)(n.globalTrackList,!!e.logMissingFeatures)},n.audioClipGroupList?.audioClipGroupList?.length&&(t.timelineInformation.audioClipGroups=n.audioClipGroupList.audioClipGroupList.map(e=>({id:e.groupID,muted:e.muted,audioClips:e.audioClipList.map(({clipID:e,timeScope:t,muted:n,audioLevel:r,frameReader:i})=>({id:e,start:(0,o.frac)(t.Strt),duration:(0,o.frac)(t.duration),inTime:(0,o.frac)(t.inTime),outTime:(0,o.frac)(t.outTime),muted:n,audioLevel:r,frameReader:{type:i.frameReaderType,mediaDescriptor:i.mediaDescriptor,link:{name:i[`Lnk `][`Nm `],fullPath:i[`Lnk `].fullPath,relativePath:i[`Lnk `].relPath}}}))})))},(e,t)=>{let n=t.timelineInformation,r={Vrsn:1,enab:n.enabled,frameStep:n.frameStep,frameRate:n.frameRate,time:n.time,duration:n.duration,workInTime:n.workInTime,workOutTime:n.workOutTime,LCnt:n.repeats,globalTrackList:(0,o.serializeTrackList)(n.globalTracks),audioClipGroupList:{audioClipGroupList:n.audioClipGroups?.map(e=>({groupID:e.id,muted:e.muted,audioClipList:e.audioClips.map(e=>({clipID:e.id,timeScope:{Vrsn:1,Strt:e.start,duration:e.duration,inTime:e.inTime,outTime:e.outTime},frameReader:{frameReaderType:e.frameReader.type,descVersion:1,"Lnk ":{descVersion:1,"Nm ":e.frameReader.link.name,fullPath:e.frameReader.link.fullPath,relPath:e.frameReader.link.relativePath},mediaDescriptor:e.frameReader.mediaDescriptor},muted:e.muted,audioLevel:e.audioLevel}))}))},hasMotion:n.hasMotion};(0,o.writeVersionAndDescriptor)(e,``,`null`,r,`anim`)}),s(1076,e=>e.sheetDisclosure!==void 0,(e,t)=>{let n=(0,o.readVersionAndDescriptor)(e);t.sheetDisclosure={},n.sheetTimelineOptions&&(t.sheetDisclosure.sheetTimelineOptions=n.sheetTimelineOptions.map(e=>({sheetID:e.sheetID,sheetDisclosed:e.sheetDisclosed,lightsDisclosed:e.lightsDisclosed,meshesDisclosed:e.meshesDisclosed,materialsDisclosed:e.materialsDisclosed})))},(e,t)=>{let n=t.sheetDisclosure,r={Vrsn:1};n.sheetTimelineOptions&&(r.sheetTimelineOptions=n.sheetTimelineOptions.map(e=>({Vrsn:2,sheetID:e.sheetID,sheetDisclosed:e.sheetDisclosed,lightsDisclosed:e.lightsDisclosed,meshesDisclosed:e.meshesDisclosed,materialsDisclosed:e.materialsDisclosed}))),(0,o.writeVersionAndDescriptor)(e,``,`null`,r)}),s(1054,e=>e.urlsList!==void 0,(e,t)=>{let r=(0,n.readUint32)(e);t.urlsList=[];for(let i=0;i<r;i++){if((0,n.readSignature)(e)!==`slic`&&e.throwForMissingFeatures)throw Error(`Unknown long`);let r=(0,n.readUint32)(e),i=(0,n.readUnicodeString)(e);t.urlsList.push({id:r,url:i,ref:`slice`})}},(e,t)=>{let n=t.urlsList;(0,r.writeUint32)(e,n.length);for(let t=0;t<n.length;t++)(0,r.writeSignature)(e,`slic`),(0,r.writeUint32)(e,n[t].id),(0,r.writeUnicodeString)(e,n[t].url)});function T(e){return{"Top ":e.top,Left:e.left,Btom:e.bottom,Rght:e.right}}function E(e){return{top:e[`Top `],left:e.Left,bottom:e.Btom,right:e.Rght}}function D(e,t){return e[Math.max(0,Math.min(e.length-1,t))]}let ee=[`autoGenerated`,`layer`,`userGenerated`],k=[`noImage`,`image`],A=[`default`];s(1050,e=>e.slices?e.slices.length:0,(e,t)=>{let r=(0,n.readUint32)(e);if(r===6){t.slices||=[];let r=(0,n.readInt32)(e),i=(0,n.readInt32)(e),a=(0,n.readInt32)(e),s=(0,n.readInt32)(e),c=(0,n.readUnicodeString)(e),l=(0,n.readUint32)(e);t.slices.push({bounds:{top:r,left:i,bottom:a,right:s},groupName:c,slices:[]});let u=t.slices[t.slices.length-1].slices;for(let t=0;t<l;t++){let t=(0,n.readUint32)(e),r=(0,n.readUint32)(e),i=D(ee,(0,n.readUint32)(e)),a=i==`layer`?(0,n.readUint32)(e):0,o=(0,n.readUnicodeString)(e),s=D(k,(0,n.readUint32)(e)),c=(0,n.readInt32)(e),l=(0,n.readInt32)(e),d=(0,n.readInt32)(e),f=(0,n.readInt32)(e),p=(0,n.readUnicodeString)(e),m=(0,n.readUnicodeString)(e),h=(0,n.readUnicodeString)(e),g=(0,n.readUnicodeString)(e),_=!!(0,n.readUint8)(e),v=(0,n.readUnicodeString)(e),y=D(A,(0,n.readUint32)(e)),b=D(A,(0,n.readUint32)(e)),x=(0,n.readUint8)(e),S=(0,n.readUint8)(e),C=(0,n.readUint8)(e),w=(0,n.readUint8)(e),T=x+S+C+w===0?`none`:x===0?`matte`:`color`;u.push({id:t,groupId:r,origin:i,associatedLayerId:a,name:o,target:m,message:h,altTag:g,cellTextIsHTML:_,cellText:v,horizontalAlignment:y,verticalAlignment:b,type:s,url:p,bounds:{top:l,left:c,bottom:f,right:d},backgroundColorType:T,backgroundColor:{r:S,g:C,b:w,a:x}})}(0,o.readVersionAndDescriptor)(e).slices.forEach(e=>{let t=u.find(t=>e.sliceID==t.id);t&&(t.topOutset=e.topOutset,t.leftOutset=e.leftOutset,t.bottomOutset=e.bottomOutset,t.rightOutset=e.rightOutset)})}else if(r===7||r===8){let n=(0,o.readVersionAndDescriptor)(e);t.slices||=[],t.slices.push({groupName:n.baseName,bounds:E(n.bounds),slices:n.slices.map(e=>Object.assign(Object.assign({},e[`Nm `]?{name:e[`Nm `]}:{}),{id:e.sliceID,groupId:e.groupID,associatedLayerId:0,origin:o.ESliceOrigin.decode(e.origin),type:o.ESliceType.decode(e.Type),bounds:E(e.bounds),url:e.url,target:e.null,message:e.Msge,altTag:e.altTag,cellTextIsHTML:e.cellTextIsHTML,cellText:e.cellText,horizontalAlignment:o.ESliceHorzAlign.decode(e.horzAlign),verticalAlignment:o.ESliceVertAlign.decode(e.vertAlign),backgroundColorType:o.ESliceBGColorType.decode(e.bgColorType),backgroundColor:e.bgColor?{r:e.bgColor[`Rd `],g:e.bgColor[`Grn `],b:e.bgColor[`Bl `],a:e.bgColor.alpha}:{r:0,g:0,b:0,a:0},topOutset:e.topOutset||0,leftOutset:e.leftOutset||0,bottomOutset:e.bottomOutset||0,rightOutset:e.rightOutset||0}))})}else throw Error(`Invalid slices version (${r})`)},(e,t,n)=>{let{bounds:i,groupName:a,slices:s}=t.slices[n];(0,r.writeUint32)(e,6),(0,r.writeInt32)(e,i.top),(0,r.writeInt32)(e,i.left),(0,r.writeInt32)(e,i.bottom),(0,r.writeInt32)(e,i.right),(0,r.writeUnicodeString)(e,a),(0,r.writeUint32)(e,s.length);for(let t=0;t<s.length;t++){let n=s[t],{a:i,r:a,g:o,b:c}=n.backgroundColor;n.backgroundColorType===`none`?i=a=o=c=0:n.backgroundColorType===`matte`&&(i=0,a=o=c=255),(0,r.writeUint32)(e,n.id),(0,r.writeUint32)(e,n.groupId),(0,r.writeUint32)(e,ee.indexOf(n.origin)),n.origin===`layer`&&(0,r.writeUint32)(e,n.associatedLayerId),(0,r.writeUnicodeString)(e,n.name||``),(0,r.writeUint32)(e,k.indexOf(n.type)),(0,r.writeInt32)(e,n.bounds.left),(0,r.writeInt32)(e,n.bounds.top),(0,r.writeInt32)(e,n.bounds.right),(0,r.writeInt32)(e,n.bounds.bottom),(0,r.writeUnicodeString)(e,n.url),(0,r.writeUnicodeString)(e,n.target),(0,r.writeUnicodeString)(e,n.message),(0,r.writeUnicodeString)(e,n.altTag),(0,r.writeUint8)(e,+!!n.cellTextIsHTML),(0,r.writeUnicodeString)(e,n.cellText),(0,r.writeUint32)(e,A.indexOf(n.horizontalAlignment)),(0,r.writeUint32)(e,A.indexOf(n.verticalAlignment)),(0,r.writeUint8)(e,i),(0,r.writeUint8)(e,a),(0,r.writeUint8)(e,o),(0,r.writeUint8)(e,c)}let c={bounds:T(i),slices:[]};s.forEach(e=>{let t=Object.assign(Object.assign({sliceID:e.id,groupID:e.groupId,origin:o.ESliceOrigin.encode(e.origin),Type:o.ESliceType.encode(e.type),bounds:T(e.bounds)},e.name?{"Nm ":e.name}:{}),{url:e.url,null:e.target,Msge:e.message,altTag:e.altTag,cellTextIsHTML:e.cellTextIsHTML,cellText:e.cellText,horzAlign:o.ESliceHorzAlign.encode(e.horizontalAlignment),vertAlign:o.ESliceVertAlign.encode(e.verticalAlignment),bgColorType:o.ESliceBGColorType.encode(e.backgroundColorType)});if(e.backgroundColorType===`color`){let{r:n,g:r,b:i,a}=e.backgroundColor;t.bgColor={"Rd ":n,"Grn ":r,"Bl ":i,alpha:a}}t.topOutset=e.topOutset||0,t.leftOutset=e.leftOutset||0,t.bottomOutset=e.bottomOutset||0,t.rightOutset=e.rightOutset||0,c.slices.push(t)}),(0,o.writeVersionAndDescriptor)(e,``,`null`,c,`slices`)}),s(1064,e=>e.pixelAspectRatio!==void 0,(e,t)=>{if((0,n.readUint32)(e)>2)throw Error(`Invalid pixelAspectRatio version`);t.pixelAspectRatio={aspect:(0,n.readFloat64)(e)}},(e,t)=>{(0,r.writeUint32)(e,2),(0,r.writeFloat64)(e,t.pixelAspectRatio.aspect)}),s(1041,e=>e.iccUntaggedProfile!==void 0,(e,t)=>{t.iccUntaggedProfile=!!(0,n.readUint8)(e)},(e,t)=>{(0,r.writeUint8)(e,+!!t.iccUntaggedProfile)}),i.MOCK_HANDLERS&&s(1039,e=>e._ir1039!==void 0,(e,t,r)=>{t._ir1039=(0,n.readBytes)(e,r())},(e,t)=>{(0,r.writeBytes)(e,t._ir1039)}),s(1044,e=>e.idsSeedNumber!==void 0,(e,t)=>t.idsSeedNumber=(0,n.readUint32)(e),(e,t)=>(0,r.writeUint32)(e,t.idsSeedNumber)),s(1036,e=>e.thumbnail!==void 0||e.thumbnailRaw!==void 0,(e,t,r)=>{let a=(0,n.readUint32)(e),o=(0,n.readUint32)(e),s=(0,n.readUint32)(e);(0,n.readUint32)(e),(0,n.readUint32)(e),(0,n.readUint32)(e);let c=(0,n.readUint16)(e),l=(0,n.readUint16)(e);if(a!==1||c!==24||l!==1){e.logMissingFeatures&&e.log(`Invalid thumbnail data (format: ${a}, bitsPerPixel: ${c}, planes: ${l})`),(0,n.skipBytes)(e,r());return}let u=r(),d=(0,n.readBytes)(e,u);e.useRawThumbnail?t.thumbnailRaw={width:o,height:s,data:d}:d.byteLength&&(t.thumbnail=(0,i.createCanvasFromData)(d))},(e,n)=>{let i=0,a=0,o=new Uint8Array;if(n.thumbnailRaw)i=n.thumbnailRaw.width,a=n.thumbnailRaw.height,o=n.thumbnailRaw.data;else try{let e=n.thumbnail.toDataURL(`image/jpeg`,1)?.substring(23);e&&(o=(0,t.toByteArray)(e),i=n.thumbnail.width,a=n.thumbnail.height)}catch{}let s=Math.floor((i*24+31)/32)*4,c=s*a*1,l=o.length;(0,r.writeUint32)(e,1),(0,r.writeUint32)(e,i),(0,r.writeUint32)(e,a),(0,r.writeUint32)(e,s),(0,r.writeUint32)(e,c),(0,r.writeUint32)(e,l),(0,r.writeUint16)(e,24),(0,r.writeUint16)(e,1),(0,r.writeBytes)(e,o)}),s(1057,e=>e.versionInfo!==void 0,(e,t,r)=>{if((0,n.readUint32)(e)!==1)throw Error(`Invalid versionInfo version`);t.versionInfo={hasRealMergedData:!!(0,n.readUint8)(e),writerName:(0,n.readUnicodeString)(e),readerName:(0,n.readUnicodeString)(e),fileVersion:(0,n.readUint32)(e)},(0,n.skipBytes)(e,r())},(e,t)=>{let n=t.versionInfo;(0,r.writeUint32)(e,1),(0,r.writeUint8)(e,+!!n.hasRealMergedData),(0,r.writeUnicodeString)(e,n.writerName),(0,r.writeUnicodeString)(e,n.readerName),(0,r.writeUint32)(e,n.fileVersion)}),i.MOCK_HANDLERS&&s(1058,e=>e._ir1058!==void 0,(e,t,r)=>{t._ir1058=(0,n.readBytes)(e,r())},(e,t)=>{(0,r.writeBytes)(e,t._ir1058)}),s(7e3,e=>e.imageReadyVariables!==void 0,(e,t,n)=>{t.imageReadyVariables=p(e,n())},(e,t)=>{m(e,t.imageReadyVariables)}),s(7001,e=>e.imageReadyDataSets!==void 0,(e,t,n)=>{t.imageReadyDataSets=p(e,n())},(e,t)=>{m(e,t.imageReadyDataSets)}),s(1088,e=>e.pathSelectionState!==void 0,(e,t,n)=>{t.pathSelectionState=(0,o.readVersionAndDescriptor)(e).null},(e,t)=>{let n={null:t.pathSelectionState};(0,o.writeVersionAndDescriptor)(e,``,`null`,n)}),i.MOCK_HANDLERS&&s(1025,e=>e._ir1025!==void 0,(e,t,r)=>{t._ir1025=(0,n.readBytes)(e,r())},(e,t)=>{(0,r.writeBytes)(e,t._ir1025)});let j=(0,i.createEnum)(`FrmD`,`auto`,{auto:`Auto`,none:`None`,dispose:`Disp`});s(4e3,e=>e.animations!==void 0,(e,t,r)=>{let i=(0,n.readSignature)(e);if(i===`mani`)(0,n.checkSignature)(e,`IRFR`),(0,n.readSection)(e,1,r=>{for(;r()>0;){(0,n.checkSignature)(e,`8BIM`);let r=(0,n.readSignature)(e);(0,n.readSection)(e,1,i=>{if(r===`AnDs`){let n=(0,o.readVersionAndDescriptor)(e);t.animations={frames:n.FrIn.map(e=>({id:e.FrID,delay:(e.FrDl||0)/100,dispose:e.FrDs?j.decode(e.FrDs):`auto`})),animations:n.FSts.map(e=>({id:e.FsID,frames:e.FsFr,repeats:e.LCnt,activeFrame:e.AFrm||0}))}}else if(r===`Roll`){let t=(0,n.readBytes)(e,i());e.logDevFeatures&&e.log(`#4000 Roll`,t)}else e.logMissingFeatures&&e.log(`Unhandled subsection in #4000`,r)})}});else if(i===`mopt`){let t=(0,n.readBytes)(e,r());e.logDevFeatures&&e.log(`#4000 mopt`,t)}else e.logMissingFeatures&&e.log(`Unhandled key in #4000:`,i)},(e,t)=>{t.animations&&((0,r.writeSignature)(e,`mani`),(0,r.writeSignature)(e,`IRFR`),(0,r.writeSection)(e,1,()=>{(0,r.writeSignature)(e,`8BIM`),(0,r.writeSignature)(e,`AnDs`),(0,r.writeSection)(e,1,()=>{let n={FrIn:[],FSts:[]};for(let e=0;e<t.animations.frames.length;e++){let r=t.animations.frames[e],i={FrID:r.id};r.delay&&(i.FrDl=r.delay*100|0),i.FrDs=j.encode(r.dispose),n.FrIn.push(i)}for(let e=0;e<t.animations.animations.length;e++){let r=t.animations.animations[e],i={FsID:r.id,AFrm:r.activeFrame|0,FsFr:r.frames,LCnt:r.repeats|0};n.FSts.push(i)}(0,o.writeVersionAndDescriptor)(e,``,`null`,n)})}))}),i.MOCK_HANDLERS&&s(4001,e=>e._ir4001!==void 0,(e,t,r)=>{if(i.MOCK_HANDLERS){t._ir4001=(0,n.readBytes)(e,r());return}let a=(0,n.readSignature)(e);if(a===`mfri`){if((0,n.readUint32)(e)!==2)throw Error(`Invalid mfri version`);let t=(0,n.readUint32)(e),r=(0,n.readBytes)(e,t);e.logDevFeatures&&e.log(`mfri`,r)}else if(a===`mset`){let t=(0,o.readVersionAndDescriptor)(e);e.logDevFeatures&&e.log(`mset`,t)}else e.logMissingFeatures&&e.log(`Unhandled key in #4001`,a)},(e,t)=>{(0,r.writeBytes)(e,t._ir4001)}),i.MOCK_HANDLERS&&s(4002,e=>e._ir4002!==void 0,(e,t,r)=>{t._ir4002=(0,n.readBytes)(e,r())},(e,t)=>{(0,r.writeBytes)(e,t._ir4002)})})),C=e((e=>{var t=e&&e.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};Object.defineProperty(e,"__esModule",{value:!0}),e.supportedColorModes=void 0,e.createReader=c,e.warnOrThrow=l,e.readUint8=u,e.peekUint8=d,e.readInt16=f,e.readUint16=p,e.readUint16LE=m,e.readInt32=h,e.readInt32LE=_,e.readUint32=y,e.readFloat32=b,e.readFloat64=x,e.readFixedPoint32=C,e.readFixedPointPath32=w,e.readBytes=T,e.readSignature=E,e.validSignatureAt=D,e.readPascalString=O,e.readUnicodeString=k,e.readUnicodeStringWithLength=A,e.readUnicodeStringWithLengthLE=j,e.readAsciiString=M,e.skipBytes=N,e.checkSignature=P,e.readPsd=I,e.readLayerInfo=L,e.getCompositeImageData=B,e.getCompositeCanvas=V,e.getLayerImageData=se,e.getLayerMaskImageData=H,e.getLayerRealMaskImageData=U,e.getLayerCanvas=ce,e.getLayerMaskCanvas=le,e.getLayerRealMaskCanvas=ue,e.decodeLayerPixels=G,e.readGlobalLayerMaskInfo=X,e.readAdditionalLayerInfo=Z,e.readDataZip=Se,e.readDataRLE=Ce,e.readSection=we,e.readColor=Te,e.readPattern=Ee;let n=g(),r=v(),i=ee(),a=S();e.supportedColorModes=[0,1,3,2];let o=[`bitmap`,`grayscale`,`indexed`,`RGB`,`CMYK`,``,``,`multichannel`,`duotone`,`lab`];function s(e){let t=e.width*e.height*4;for(let n=0;n<t;n+=4){let t=e.data[n];e.data[n+1]=t,e.data[n+2]=t}}function c(e,t,n){return{view:new DataView(e,t,n),offset:0,strict:!1,debug:!1,large:!1,globalAlpha:!1,log:console.log}}function l(e,t){if(e.strict)throw Error(t);e.debug&&e.log(t)}function u(e){return e.offset+=1,e.view.getUint8(e.offset-1)}function d(e){return e.view.getUint8(e.offset)}function f(e){return e.offset+=2,e.view.getInt16(e.offset-2,!1)}function p(e){return e.offset+=2,e.view.getUint16(e.offset-2,!1)}function m(e){return e.offset+=2,e.view.getUint16(e.offset-2,!0)}function h(e){return e.offset+=4,e.view.getInt32(e.offset-4,!1)}function _(e){return e.offset+=4,e.view.getInt32(e.offset-4,!0)}function y(e){return e.offset+=4,e.view.getUint32(e.offset-4,!1)}function b(e){return e.offset+=4,e.view.getFloat32(e.offset-4,!1)}function x(e){return e.offset+=8,e.view.getFloat64(e.offset-8,!1)}function C(e){return h(e)/65536}function w(e){return h(e)/(1<<24)}function T(e,t){let n=e.view.byteOffset+e.offset;if(e.offset+=t,n+t>e.view.buffer.byteLength){if(l(e,`Reading bytes exceeding buffer length`),t>100*1024*1024)throw Error(`Reading past end of file`);let r=new Uint8Array(t),i=Math.min(t,e.view.byteLength-n);return i>0&&r.set(new Uint8Array(e.view.buffer,n,i)),r}else return new Uint8Array(e.view.buffer,n,t)}function E(e){return F(e,4)}function D(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 O(e,t){let n=u(e),r=n?F(e,n):``;for(;++n%t;)e.offset++;return r}function k(e){return A(e,y(e))}function A(e,t){let n=``;for(;t--;){let r=p(e);(r||t>0)&&(n+=String.fromCharCode(r))}return n}function j(e,t){let n=``;for(;t--;){let r=m(e);(r||t>0)&&(n+=String.fromCharCode(r))}return n}function M(e,t){let n=``;for(;t--;)n+=String.fromCharCode(u(e));return n}function N(e,t){e.offset+=t}function P(e,t,n){let r=e.offset,i=E(e);if(i!==t&&i!==n)throw Error(`Invalid signature: '${i}' at 0x${r.toString(16)}`)}function F(e,t){let n=T(e,t),r=``;for(let e=0;e<n.length;e++)r+=String.fromCharCode(n[e]);return r}function te(e){return e===`8BIM`||e===`MeSa`||e===`AgHg`||e===`PHUT`||e===`DCSR`}function I(n,i={}){P(n,`8BPS`);let s=p(n);if(s!==1&&s!==2)throw Error(`Invalid PSD file version: ${s}`);N(n,6);let c=p(n),l=y(n),f=y(n),m=p(n),h=p(n),g=s===1?3e4:3e5;if(f>g||l>g)throw Error(`Invalid size: ${f}x${l}`);if(c>16)throw Error(`Invalid channel count: ${c}`);if(![1,8,16,32].includes(m))throw Error(`Invalid bitsPerChannel: ${m}`);if(e.supportedColorModes.indexOf(h)===-1)throw Error(`Color mode not supported: ${o[h]??h}`);let _={width:f,height:l,channels:c,bitsPerChannel:m,colorMode:h};Object.assign(n,i),n.large=s===2,n.globalAlpha=!1,`totalMemoryLimit`in n||(n.totalMemoryLimit=2*1024*1024*1024),we(n,1,e=>{if(e()){if(h===2){if(e()!=768)throw Error(`Invalid color palette size`);_.palette=[];for(let e=0;e<256;e++)_.palette.push({r:u(n),g:0,b:0});for(let e=0;e<256;e++)_.palette[e].g=u(n);for(let e=0;e<256;e++)_.palette[e].b=u(n)}N(n,e())}});let v={};we(n,1,e=>{for(;e()>0;){pe(n,te);let e=p(n);O(n,2),we(n,2,t=>{let r=a.resourceHandlersMap[e],i=e===1036&&!!n.skipThumbnail;if(r&&!i)try{r.read(n,v,t)}catch(e){if(n.throwForMissingFeatures)throw e;N(n,t())}else N(n,t())})}});let{layersGroup:b,layerGroupsEnabledId:x}=v,S=t(v,[`layersGroup`,`layerGroupsEnabledId`]);Object.keys(S).length&&(_.imageResources=S),we(n,1,e=>{if(we(n,2,e=>{L(n,_,v),N(n,e())},void 0,n.large),e()>0){let e=X(n);e&&(_.globalLayerMaskInfo=e)}else N(n,e());for(;e()>0;){for(;e()&&d(n)===0;)N(n,1);e()>=12?Z(n,_,_,v):N(n,e())}},void 0,n.large);let C=_.children&&_.children.length;if(!(n.skipCompositeImageData&&(n.skipLayerImageData||C)))if(n.useRawData)_.rawCompositeData=new Uint8Array(n.view.buffer,n.view.byteOffset+n.offset);else{let e=$(n,_);n.useImageData?_.imageData=e:_.canvas=(0,r.imageDataToCanvas)(e)}return _}function L(e,t,n){let{layersGroup:i=[],layerGroupsEnabledId:a=[]}=n,o=f(e);o<0&&(e.globalAlpha=!0,o=-o);let s=[],c=[];for(let r=0;r<o;r++){let{layer:o,channels:l}=R(e,t,n);i[r]!==void 0&&(o.linkGroup=i[r]),a[r]!==void 0&&(o.linkGroupEnabled=!!a[r]),s.push(o),c.push(l)}for(let n=0;n<o;n++)ae(e,t,s[n],c[n]);t.children||=[];let l=[t];for(let e=s.length-1;e>=0;e--){let t=s[e],n=t.sectionDivider?t.sectionDivider.type:0;n===1||n===2?(t.opened=n===1,t.children=[],t.sectionDivider?.key&&(t.blendMode=r.toBlendMode[t.sectionDivider.key]??t.blendMode),l[l.length-1].children.unshift(t),l.push(t)):n===3?l.pop():l[l.length-1].children.unshift(t)}}function R(e,t,n){let i={};if(i.top=h(e),i.left=h(e),i.bottom=h(e),i.right=h(e),!ne(i,e))throw Error(`Invalid layer size`);let a=p(e),o=[];for(let t=0;t<a;t++){let t=f(e),n=y(e);if(e.large){if(n!==0)throw Error(`Sizes larger than 4GB are not supported`);n=y(e)}o.push({id:t,length:n})}P(e,`8BIM`);let s=E(e);if(!r.toBlendMode[s])throw Error(`Invalid blend mode: '${s}'`);i.blendMode=r.toBlendMode[s],i.opacity=u(e)/255,i.clipping=u(e)===1;let c=u(e);return i.transparencyProtected=(c&1)!=0,i.hidden=(c&2)!=0,c&32&&(i.effectsOpen=!0),N(e,1),we(e,1,r=>{z(e,i);let a=ie(e);for(a&&(i.blendingRanges=a),i.name=O(e,1);r()>4&&!D(e,e.offset);)e.offset++;for(;r()>=12;)Z(e,i,t,n);N(e,r())}),{layer:i,channels:o}}function ne(e,t){let n=(e.right||0)-(e.left||0),r=(e.bottom||0)-(e.top||0),i=t.large?3e5:3e4;return n>=0&&r>=0&&n<=i&&r<=i}function z(e,t){return we(e,1,n=>{if(!n())return;let r={};if(t.mask=r,r.top=h(e),r.left=h(e),r.bottom=h(e),r.right=h(e),!ne(r,e))throw Error(`Invalid mask size`);r.defaultColor=u(e);let i=u(e);if(r.positionRelativeToLayer=(i&1)!=0,r.disabled=(i&2)!=0,r.fromVectorData=(i&8)!=0,n()>=18){let n={};t.realMask=n;let r=u(e);if(n.positionRelativeToLayer=(r&1)!=0,n.disabled=(r&2)!=0,n.fromVectorData=(r&8)!=0,n.defaultColor=u(e),n.top=h(e),n.left=h(e),n.bottom=h(e),n.right=h(e),!ne(n,e))throw Error(`Invalid realMask size`)}if(i&16){let t=u(e);t&1&&(r.userMaskDensity=u(e)/255),t&2&&(r.userMaskFeather=x(e)),t&4&&(r.vectorMaskDensity=u(e)/255),t&8&&(r.vectorMaskFeather=x(e))}N(e,n())})}function re(e){return[u(e),u(e),u(e),u(e)]}function ie(e){return we(e,1,t=>{let n=re(e),r=re(e),i=[];for(;t()>0;){let t=re(e),n=re(e);i.push({sourceRange:t,destRange:n})}return{compositeGrayBlendSource:n,compositeGraphBlendDestinationRange:r,ranges:i}})}function ae(e,t,n,r){if(e.skipLayerImageData)return;let{colorMode:i=3,bitsPerChannel:a=8}=t;n.rawData={colorMode:i,bitsPerChannel:a,channels:[],large:e.large};for(let t of r){let r=e.offset,i=0,a;if(t.length===1)throw Error(`Invalid channel length`);if(t.length){if(i=p(e),i>3&&(--e.offset,i=p(e)),i>3&&(e.offset-=3,i=p(e)),i>3)throw Error(`Invalid compression: ${i}`);t.length>2&&(a=T(e,t.length-2))}e.offset=r+t.length,n.rawData.channels.push({id:t.id,compression:i,data:a})}e.useRawData||K(n,e)}function oe({data:e},t){let n=e instanceof Float32Array?1:e instanceof Uint16Array?65535:255,r=(t?4:3)|0,i=e.length|0,a=(t?5:4)|0;for(let t=r;t<i;t=t+a|0)e[t]=n}function B(e){let t=e.rawCompositeData;if(t)return $(c(t.buffer,t.byteOffset,t.byteLength),e)}function V(e){return W(B(e))}function se(e){return J(e,q.Layer,!1,void 0)}function H(e){return J(e,q.Mask,!1,void 0)}function U(e){return J(e,q.RealMask,!1,void 0)}function ce(e){return W(se(e))}function le(e){return W(H(e))}function ue(e){return W(U(e))}function W(e){return e&&(0,r.imageDataToCanvas)(e)}function de(e,t,n){t&&(n?e.imageData=t:e.canvas=(0,r.imageDataToCanvas)(t))}function G(e,t){K(e,{useImageData:t})}function K(e,t){let{throwForMissingFeatures:n,useImageData:r}=t,i=J(e,q.Layer,n,t.totalMemoryLimit);if(de(e,i,r),t.totalMemoryLimit!==void 0&&(t.totalMemoryLimit-=i?.data.byteLength??0),e.mask){let i=J(e,q.Mask,n,t.totalMemoryLimit);de(e.mask,i,r),t.totalMemoryLimit!==void 0&&(t.totalMemoryLimit-=i?.data.byteLength??0)}if(e.realMask){let i=J(e,q.RealMask,n,t.totalMemoryLimit);de(e.realMask,i,r),t.totalMemoryLimit!==void 0&&(t.totalMemoryLimit-=i?.data.byteLength??0)}delete e.rawData}var q;(function(e){e[e.Layer=0]=`Layer`,e[e.Mask=1]=`Mask`,e[e.RealMask=2]=`RealMask`})(q||={});function J(e,t,n,i){if(!e.rawData)return;let{colorMode:a,bitsPerChannel:o,channels:l,large:u}=e.rawData,d=Math.max(0,(e.right||0)-(e.left||0)),f=Math.max(0,(e.bottom||0)-(e.top||0)),p=a===4,m,h,g=!1;if(d&&f&&t===q.Layer)if(p){if(o!==8)throw Error(`bitsPerChannel Not supproted`);m={width:d,height:f,data:new Uint8ClampedArray(d*f*5)}}else m=Q(d,f,o,4,i);r.RAW_IMAGE_DATA&&(e.imageDataRaw=[],e.imageDataRawCompression=[]);for(let{id:_,compression:v,data:y}of l){if(!y)continue;let l=c(y.buffer,y.byteOffset,y.byteLength);if(_===-2||_===-3){if(_===-2&&t!==q.Mask||_===-3&&t!==q.RealMask)continue;let n=_===-2?e.mask:e.realMask;if(!n)throw Error(`Missing layer ${_===-2?`mask`:`real mask`} data`);let a=Math.max(0,(n.right||0)-(n.left||0)),c=Math.max(0,(n.bottom||0)-(n.top||0));a&&c&&(h=Q(a,c,o,4,i),Y(l,y.byteLength,h,v,a,c,o,0,u,4),r.RAW_IMAGE_DATA&&(_===-2?(e.maskDataRawCompression=v,e.maskDataRaw=y):(e.realMaskDataRawCompression=v,e.realMaskDataRaw=y)),s(h),oe(h,!1))}else{if(t!==q.Layer)continue;let i=(0,r.offsetForChannel)(_,p),c=m;if(i<0&&(c=void 0,n))throw Error(`Channel not supported: ${_}`);Y(l,y.byteLength,c,v,d,f,o,i,u,p?5:4),r.RAW_IMAGE_DATA&&(e.imageDataRawCompression[_]=v,e.imageDataRaw[_]=y),c&&a===1&&s(c)}_===-1&&(g=!0)}if(m&&(g||oe(m,p),p)){let e=m;m=(0,r.createImageData)(e.width,e.height),he(e,m,!1)}return t===q.Layer?m:h}function Y(e,t,n,r,i,a,o,s,c,l){if(t)if(r===0)t!==i*a*Math.floor(o/8)&&e.log(`Invalid length (${t}, ${i*a*Math.floor(o/8)})`),be(T(e,t),n,o,l,s);else if(r===1)Ce(e,n,i,a,o,l,[s],c);else if(r===2)Se(T(e,t),n,i,a,o,l,s,!1);else if(r===3)Se(T(e,t),n,i,a,o,l,s,!0);else throw Error(`Invalid Compression type: ${r}`)}function X(e){return we(e,1,t=>{if(!t())return;let n=p(e),r=p(e),i=p(e),a=p(e),o=p(e),s=p(e)/255,c=u(e);return N(e,t()),{overlayColorSpace:n,colorSpace1:r,colorSpace2:i,colorSpace3:a,colorSpace4:o,opacity:s,kind:c}})}let fe=[0,1,-1,2,-2,3,-3,4,-4];function pe(e,t){let n=e.offset,r=``;for(let i of fe){try{e.offset=n+i,r=E(e)}catch{}if(t(r))break}if(!t(r))throw Error(`Invalid signature: '${r}' at 0x${n.toString(16)}`);return r}function me(e){return e===`8BIM`||e===`8B64`}function Z(e,t,n,a){let o=pe(e,me),s=E(e);we(e,2,r=>{let o=i.infoHandlersMap[s];if(o)try{o.read(e,t,r,n,a)}catch(t){if(e.throwForMissingFeatures)throw t}else e.logMissingFeatures&&e.log(`Unhandled additional info: ${s}`),N(e,r());r()&&(e.logMissingFeatures&&e.log(`Unread ${r()} bytes left for additional info: ${s}`),N(e,r()))},!1,o===`8B64`||e.large&&r.largeAdditionalInfoKeys.indexOf(s)!==-1)}function Q(e,t,n,i,a){let o=e*t*i*Math.max(1,n/8);if(a!==void 0&&o>a)throw Error(`Exceeded memory limit`);if(n===1||n===8)return i===4?(0,r.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 Error(`Invalid bitDepth (${n})`)}function $(t,n){let i=p(t),a=n.bitsPerChannel??8;if(e.supportedColorModes.indexOf(n.colorMode)===-1)throw Error(`Color mode not supported: ${n.colorMode}`);if(i!==0&&i!==1)throw Error(`Compression type not supported: ${i}`);let o=Q(n.width,n.height,a,4,t.totalMemoryLimit);switch(t.totalMemoryLimit!==void 0&&(t.totalMemoryLimit-=o.data.byteLength),(0,r.resetImageData)(o),n.colorMode){case 0:{if(a!==1)throw Error(`Invalid bitsPerChannel for bitmap color mode`);let e;if(i===0)e=T(t,Math.ceil(n.width/8)*n.height);else if(i===1)e=new Uint8Array(n.width*n.height),Ce(t,{data:e,width:n.width,height:n.height},n.width,n.height,8,1,[0],t.large);else throw Error(`Compression not supported: ${i}`);(0,r.decodeBitmap)(e,o.data,n.width,n.height);break}case 3:case 1:{let e=n.colorMode===1?[0]:[0,1,2];if(n.channels&&n.channels>3)for(let t=3;t<n.channels;t++)e.push(t);else t.globalAlpha&&e.push(3);if(i===0)for(let r=0;r<e.length;r++)be(T(t,n.width*n.height*Math.floor(a/8)),o,a,4,e[r]);else if(i===1){let i=t.offset;Ce(t,o,n.width,n.height,a,4,e,t.large),r.RAW_IMAGE_DATA&&(n.imageDataRaw=new Uint8Array(t.view.buffer,t.view.byteOffset+i,t.offset-i))}else throw Error(`Compression not supported: ${i}`);n.colorMode===1&&s(o);break}case 2:if(a!==8)throw Error(`bitsPerChannel Not supproted`);if(n.channels!==1)throw Error(`Invalid channel count`);if(!n.palette)throw Error(`Missing color palette`);if(i===0)throw Error(`Compression not supported: ${i}`);if(i===1){let e={width:o.width,height:o.height,data:new Uint8Array(o.width*o.height)};Ce(t,e,n.width,n.height,a,1,[0],t.large),ge(e,o,n.palette)}else throw Error(`Compression not supported: ${i}`);break;case 4:{if(a!==8)throw Error(`bitsPerChannel Not supproted`);if(n.channels!==4)throw Error(`Invalid channel count`);let e=[0,1,2,3];if(t.globalAlpha&&e.push(4),i===0)throw Error(`Compression not supported: ${i}`);if(i===1){let i={width:o.width,height:o.height,data:new Uint8Array(o.width*o.height*5)},s=t.offset;Ce(t,i,n.width,n.height,a,5,e,t.large),he(i,o,!0),r.RAW_IMAGE_DATA&&(n.imageDataRaw=new Uint8Array(t.view.buffer,t.view.byteOffset+s,t.offset-s))}else throw Error(`Compression not supported: ${i}`);break}default:throw Error(`Color mode not supported: ${n.colorMode}`)}if(t.globalAlpha){if(n.bitsPerChannel!==8)throw Error(`bitsPerChannel Not supproted`);let e=o.data,t=o.width*o.height*4;for(let n=0;n<t;n+=4){let t=e[n+3];if(t!=0&&t!=255){let r=1/(t/255),i=255*(1-r);e[n+0]=e[n+0]*r+i,e[n+1]=e[n+1]*r+i,e[n+2]=e[n+2]*r+i}}}return o}function he(e,t,n){let r=t.width*t.height*4,i=e.data,a=t.data;for(let e=0,t=0;t<r;e+=5,t+=4){let r=i[e],o=i[e+1],s=i[e+2],c=i[e+3];a[t]=(r*c|0)/255|0,a[t+1]=(o*c|0)/255|0,a[t+2]=(s*c|0)/255|0,a[t+3]=n?255-i[e+4]:i[e+4]}}function ge(e,t,n){let r=e.width*e.height,i=e.data,a=t.data;for(let e=0,t=0;e<r;e++,t+=4){let r=n[i[e]];a[t+0]=r.r,a[t+1]=r.g,a[t+2]=r.b,a[t+3]=255}}function _e(e,t){if(e.byteLength/e.length!==t.byteLength/t.length)throw Error(`Invalid array types`)}function ve(e,t){if(t===8)return e;if(t===16){for(let t=0;t<e.byteLength;t+=2){let n=e[t];e[t]=e[t+1],e[t+1]=n}if(e.byteOffset%2){let t=new Uint16Array(e.byteLength/2);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength).set(e),t}else return new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2)}else if(t===32)if(e.byteOffset%4){let t=new Float32Array(e.byteLength/4);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength).set(e),t}else return new Float32Array(e.buffer,e.byteOffset,e.byteLength/4);else throw Error(`Invalid bitDepth (${t})`)}function ye(e,t,n,r){_e(e.data,t);let i=e.width*e.height,a=e.data;for(let e=0,o=n|0;e<i;e++,o=o+r|0)a[o]=t[e]}function be(e,t,n,r,i){if(n==32)for(let t=0;t<e.byteLength;t+=4){let n=e[t+0],r=e[t+1],i=e[t+2],a=e[t+3];e[t+0]=a,e[t+1]=i,e[t+2]=r,e[t+3]=n}let a=ve(e,n);t&&i<r&&ye(t,a,i,r)}function xe(e,t,n,r){for(let i=0;i<n;i++){let n=i*t;for(let i=1,a=n+1;i<t;i++,a++)e[a]=(e[a-1]+e[a])%r}}function Se(e,t,r,i,a,o,s,c){let l=(0,n.inflate)(e);if(t&&s<o){let e=ve(l,a);if(a===8)c&&xe(l,r,i,256),ye(t,l,s,o);else if(a===16)c&&xe(e,r,i,65536),ye(t,e,s,o);else if(a===32){c&&xe(l,r*4,i,256);let e=s,n=new Uint32Array(t.data.buffer,t.data.byteOffset,t.data.length);for(let t=0;t<i;t++){let i=r*4*t;for(let t=0;t<r;t++,i++,e+=o){let t=i+r,a=t+r,o=a+r;n[e]=(l[i]<<24|l[t]<<16|l[a]<<8|l[o])>>>0}}}else throw Error(`Invalid bitDepth`)}}function Ce(e,t,n,r,i,a,o,s){let c=t&&t.data,l;if(s){Oe(e,o.length*r*4),l=new Uint32Array(o.length*r);for(let t=0,n=0;t<o.length;t++)for(let t=0;t<r;t++,n++)l[n]=y(e)}else{Oe(e,o.length*r*2),l=new Uint16Array(o.length*r);for(let t=0,n=0;t<o.length;t++)for(let t=0;t<r;t++,n++)l[n]=p(e)}let u=a-1|0;for(let t=0,i=0;t<o.length;t++){let s=o[t]|0;if(!c||t>u||s>u)for(let t=0;t<r;t++,i++)N(e,l[i]);else for(let t=0,o=s|0;t<r;t++,i++){let t=l[i],r=T(e,t);for(let e=0,i=0;e<t;e++){let t=r[e];if(t>128){let s=r[++e];t=256-t|0;for(let e=0;e<=t&&i<n;e=e+1|0,i=i+1|0)c[o]=s,o=o+a|0}else if(t<128)for(let s=0;s<=t&&i<n;s=s+1|0,i=i+1|0)c[o]=r[++e],o=o+a|0}}}ke(e,l.byteLength)}function we(e,t,n,r=!0,i=!1){let a=y(e);if(i){if(a!==0)throw Error(`Sizes larger than 4GB are not supported`);a=y(e)}if(a<=0&&r)return;let o=e.offset+a;if(o>e.view.byteLength)throw Error(`Section exceeds file size`);let s=n(()=>o-e.offset);for(e.offset!==o&&(e.offset>o?l(e,`Exceeded section limits`):l(e,`Unread section data`));a%t;)a++,o++;return e.offset=o,s}function Te(e){switch(p(e)){case 0:{let t=p(e)/257,n=p(e)/257,r=p(e)/257;return N(e,2),{r:t,g:n,b:r}}case 1:{let t=p(e)/65535,n=p(e)/65535,r=p(e)/65535;return N(e,2),{h:t,s:n,b:r}}case 2:return{c:p(e)/257,m:p(e)/257,y:p(e)/257,k:p(e)/257};case 7:{let t=f(e)/1e4,n=f(e),r=f(e),i=n<0?n/12800:n/12700,a=r<0?r/12800:r/12700;return N(e,2),{l:t,a:i,b:a}}case 8:{let t=p(e)*255/1e4;return N(e,6),{k:t}}default:throw Error(`Invalid color space`)}}function Ee(e){let t=y(e);for(;t%4;)t++;let n=e.offset+t,r=y(e);if(r!==1)throw Error(`Invalid pattern version: ${r}`);let i=y(e),a=f(e),o=f(e);if(i!==3&&i!==1&&i!==2)throw Error(`Unsupported pattern color mode: ${i}`);let l=k(e),d=O(e,1),m=[];if(i===2){for(let t=0;t<256;t++)m.push({r:u(e),g:u(e),b:u(e)});N(e,4)}let h=y(e);if(h!==3)throw Error(`Invalid pattern VMAL version: ${h}`);y(e);let g=y(e),_=y(e),v=y(e),b=y(e),x=y(e),S=b-_,C=v-g,w=S*C*4;Oe(e,w);let E=new Uint8Array(w);for(let e=3;e<E.byteLength;e+=4)E[e]=255;for(let t=0,n=0;t<x+2;t++){if(!y(e))continue;let t=y(e),r=y(e),a=y(e),o=y(e),l=y(e),d=y(e),f=p(e),h=u(e),v=T(e,t-23);if(r!==8||f!==8)throw Error(`16bit pixel depth not supported for patterns`);let b=d-o,x=l-a,w=o-_,D=a-g;if(h===0){if(i===3&&n<3)for(let e=0;e<x;e++)for(let t=0;t<b;t++){let r=t+e*b,i=(w+t+(e+D)*S)*4;E[i+n]=v[r]}else if(i===1&&n<1)for(let e=0;e<x;e++)for(let t=0;t<b;t++){let n=t+e*b,r=(w+t+(e+D)*S)*4,i=v[n];E[r+0]=i,E[r+1]=i,E[r+2]=i}else if(i===2)for(let e=0;e<x;e++)for(let t=0;t<b;t++){let n=t+e*b,r=(w+t+(e+D)*S)*4,i=m[v[n]];E[r+0]=i.r,E[r+1]=i.g,E[r+2]=i.b}else if(e.throwForMissingFeatures)throw Error(`Invalid color pattern`)}else if(h===1){Oe(e,b*x);let t={data:E,width:S,height:C},r={data:new Uint8Array(b*x),width:b,height:x},a=c(v.buffer,v.byteOffset,v.byteLength);if(i===3&&n<3&&(Ce(a,r,b,x,8,1,[0],!1),De(r,t,w,D,n)),i===1&&n<1&&(Ce(a,r,b,x,8,1,[0],!1),De(r,t,w,D,0),s(t)),i===2)throw Error(`Indexed pattern color mode not implemented`);ke(e,b*x)}else throw Error(`Invalid pattern compression mode`);n++}return e.offset=n,{id:d,name:l,x:a,y:o,bounds:{x:_,y:g,w:S,h:C},data:E}}function De(e,t,n,r,i){let a=e.width,o=e.height,s=t.width;for(let c=0;c<o;c++)for(let o=0;o<a;o++){let l=o+c*a,u=(n+o+(c+r)*s)*4,d=e.data[l];t.data[u+i]=d}}function Oe(e,t){if(e.totalMemoryLimit!==void 0){if(e.totalMemoryLimit<t)throw Error(`Exceeded memory limit`);e.totalMemoryLimit-=t}}function ke(e,t){e.totalMemoryLimit!==void 0&&(e.totalMemoryLimit+=t)}})),w=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.readEffects=l,e.writeEffects=d;let t=v(),n=C(),r=O(),i=[void 0,`outer bevel`,`inner bevel`,`emboss`,`pillow emboss`,`stroke emboss`];function a(e){return(0,n.checkSignature)(e,`8BIM`),t.toBlendMode[(0,n.readSignature)(e)]||`normal`}function o(e,n){(0,r.writeSignature)(e,`8BIM`),(0,r.writeSignature)(e,t.fromBlendMode[n]||`norm`)}function s(e){return(0,n.readUint8)(e)/255}function c(e,t){(0,r.writeUint8)(e,Math.round(t*255)|0)}function l(e){let t=(0,n.readUint16)(e);if(t!==0)throw Error(`Invalid effects layer version: ${t}`);let r=(0,n.readUint16)(e),o={};for(let t=0;t<r;t++){(0,n.checkSignature)(e,`8BIM`);let t=(0,n.readSignature)(e);switch(t){case`cmnS`:{let t=(0,n.readUint32)(e),r=(0,n.readUint32)(e),i=!!(0,n.readUint8)(e);if((0,n.skipBytes)(e,2),t!==7||r!==0||!i)throw Error(`Invalid effects common state`);break}case`dsdw`:case`isdw`:{let r=(0,n.readUint32)(e),i=(0,n.readUint32)(e);if(r!==41&&r!==51)throw Error(`Invalid shadow size: ${r}`);if(i!==0&&i!==2)throw Error(`Invalid shadow version: ${i}`);let c=(0,n.readFixedPoint32)(e);(0,n.readFixedPoint32)(e);let l=(0,n.readFixedPoint32)(e),u=(0,n.readFixedPoint32)(e),d=(0,n.readColor)(e),f=a(e),p=!!(0,n.readUint8)(e),m=!!(0,n.readUint8)(e),h=s(e);r>=51&&(0,n.readColor)(e);let g={size:{units:`Pixels`,value:c},distance:{units:`Pixels`,value:u},angle:l,color:d,blendMode:f,enabled:p,useGlobalLight:m,opacity:h};t===`dsdw`?o.dropShadow=[g]:o.innerShadow=[g];break}case`oglw`:{let t=(0,n.readUint32)(e),r=(0,n.readUint32)(e);if(t!==32&&t!==42)throw Error(`Invalid outer glow size: ${t}`);if(r!==0&&r!==2)throw Error(`Invalid outer glow version: ${r}`);let i=(0,n.readFixedPoint32)(e);(0,n.readFixedPoint32)(e);let c=(0,n.readColor)(e),l=a(e),u=!!(0,n.readUint8)(e),d=s(e);t>=42&&(0,n.readColor)(e),o.outerGlow={size:{units:`Pixels`,value:i},color:c,blendMode:l,enabled:u,opacity:d};break}case`iglw`:{let t=(0,n.readUint32)(e),r=(0,n.readUint32)(e);if(t!==32&&t!==43)throw Error(`Invalid inner glow size: ${t}`);if(r!==0&&r!==2)throw Error(`Invalid inner glow version: ${r}`);let i=(0,n.readFixedPoint32)(e);(0,n.readFixedPoint32)(e);let c=(0,n.readColor)(e),l=a(e),u=!!(0,n.readUint8)(e),d=s(e);t>=43&&((0,n.readUint8)(e),(0,n.readColor)(e)),o.innerGlow={size:{units:`Pixels`,value:i},color:c,blendMode:l,enabled:u,opacity:d};break}case`bevl`:{let t=(0,n.readUint32)(e),r=(0,n.readUint32)(e);if(t!==58&&t!==78)throw Error(`Invalid bevel size: ${t}`);if(r!==0&&r!==2)throw Error(`Invalid bevel version: ${r}`);let c=(0,n.readFixedPoint32)(e),l=(0,n.readFixedPoint32)(e),u=(0,n.readFixedPoint32)(e),d=a(e),f=a(e),p=(0,n.readColor)(e),m=(0,n.readColor)(e),h=i[(0,n.readUint8)(e)]||`inner bevel`,g=s(e),_=s(e),v=!!(0,n.readUint8)(e),y=!!(0,n.readUint8)(e),b=(0,n.readUint8)(e)?`down`:`up`;t>=78&&((0,n.readColor)(e),(0,n.readColor)(e)),o.bevel={size:{units:`Pixels`,value:u},angle:c,strength:l,highlightBlendMode:d,shadowBlendMode:f,highlightColor:p,shadowColor:m,style:h,highlightOpacity:g,shadowOpacity:_,enabled:v,useGlobalLight:y,direction:b};break}case`sofi`:{let t=(0,n.readUint32)(e),r=(0,n.readUint32)(e);if(t!==34)throw Error(`Invalid effects solid fill info size: ${t}`);if(r!==2)throw Error(`Invalid effects solid fill info version: ${r}`);let i=a(e),c=(0,n.readColor)(e),l=s(e),u=!!(0,n.readUint8)(e);(0,n.readColor)(e),o.solidFill=[{blendMode:i,color:c,opacity:l,enabled:u}];break}default:throw Error(`Invalid effect type: '${t}'`)}}return o}function u(e,t){(0,r.writeUint32)(e,51),(0,r.writeUint32)(e,2),(0,r.writeFixedPoint32)(e,t.size&&t.size.value||0),(0,r.writeFixedPoint32)(e,0),(0,r.writeFixedPoint32)(e,t.angle||0),(0,r.writeFixedPoint32)(e,t.distance&&t.distance.value||0),(0,r.writeColor)(e,t.color),o(e,t.blendMode),(0,r.writeUint8)(e,+!!t.enabled),(0,r.writeUint8)(e,+!!t.useGlobalLight),c(e,t.opacity??1),(0,r.writeColor)(e,t.color)}function d(e,t){let n=t.dropShadow?.[0],a=t.innerShadow?.[0],s=t.outerGlow,l=t.innerGlow,d=t.bevel,f=t.solidFill?.[0],p=1;if(n&&p++,a&&p++,s&&p++,l&&p++,d&&p++,f&&p++,(0,r.writeUint16)(e,0),(0,r.writeUint16)(e,p),(0,r.writeSignature)(e,`8BIM`),(0,r.writeSignature)(e,`cmnS`),(0,r.writeUint32)(e,7),(0,r.writeUint32)(e,0),(0,r.writeUint8)(e,1),(0,r.writeZeros)(e,2),n&&((0,r.writeSignature)(e,`8BIM`),(0,r.writeSignature)(e,`dsdw`),u(e,n)),a&&((0,r.writeSignature)(e,`8BIM`),(0,r.writeSignature)(e,`isdw`),u(e,a)),s&&((0,r.writeSignature)(e,`8BIM`),(0,r.writeSignature)(e,`oglw`),(0,r.writeUint32)(e,42),(0,r.writeUint32)(e,2),(0,r.writeFixedPoint32)(e,s.size?.value||0),(0,r.writeFixedPoint32)(e,0),(0,r.writeColor)(e,s.color),o(e,s.blendMode),(0,r.writeUint8)(e,+!!s.enabled),c(e,s.opacity||0),(0,r.writeColor)(e,s.color)),l&&((0,r.writeSignature)(e,`8BIM`),(0,r.writeSignature)(e,`iglw`),(0,r.writeUint32)(e,43),(0,r.writeUint32)(e,2),(0,r.writeFixedPoint32)(e,l.size?.value||0),(0,r.writeFixedPoint32)(e,0),(0,r.writeColor)(e,l.color),o(e,l.blendMode),(0,r.writeUint8)(e,+!!l.enabled),c(e,l.opacity||0),(0,r.writeUint8)(e,0),(0,r.writeColor)(e,l.color)),d){(0,r.writeSignature)(e,`8BIM`),(0,r.writeSignature)(e,`bevl`),(0,r.writeUint32)(e,78),(0,r.writeUint32)(e,2),(0,r.writeFixedPoint32)(e,d.angle||0),(0,r.writeFixedPoint32)(e,d.strength||0),(0,r.writeFixedPoint32)(e,d.size?.value||0),o(e,d.highlightBlendMode),o(e,d.shadowBlendMode),(0,r.writeColor)(e,d.highlightColor),(0,r.writeColor)(e,d.shadowColor);let t=i.indexOf(d.style);(0,r.writeUint8)(e,t<=0?1:t),c(e,d.highlightOpacity||0),c(e,d.shadowOpacity||0),(0,r.writeUint8)(e,+!!d.enabled),(0,r.writeUint8)(e,+!!d.useGlobalLight),(0,r.writeUint8)(e,+(d.direction===`down`)),(0,r.writeColor)(e,d.highlightColor),(0,r.writeColor)(e,d.shadowColor)}f&&((0,r.writeSignature)(e,`8BIM`),(0,r.writeSignature)(e,`sofi`),(0,r.writeUint32)(e,34),(0,r.writeUint32)(e,2),o(e,f.blendMode),(0,r.writeColor)(e,f.color),c(e,f.opacity||0),(0,r.writeUint8)(e,+!!f.enabled),(0,r.writeColor)(e,f.color))}})),T=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.parseEngineData=r,e.serializeEngineData=o;function t(e){return e===32||e===10||e===13||e===9}function n(e){return e>=48&&e<=57||e===46||e===45}function r(e){let r=0;function i(){for(;r<e.length&&t(e[r]);)r++}function a(){let t=e[r];return r++,t===92&&(t=e[r],r++),t}function o(){let t=``;if(e[r]===41)return r++,t;if(e[r]!==254||e[r+1]!==255)throw Error(`Invalid utf-16 BOM`);for(r+=2;r<e.length&&e[r]!==41;){let e=a(),n=a(),r=e<<8|n;t+=String.fromCharCode(r)}return r++,t}let s=null,c=[];function l(e){c.length?(u(e),c.push(e)):(c.push(e),s=e)}function u(e){if(!c.length)throw Error(`Invalid data`);let t=c[c.length-1];if(typeof t==`string`)c[c.length-2][t]=e,f();else if(Array.isArray(t))t.push(e);else throw Error(`Invalid data`)}function d(e){c.length||l({});let t=c[c.length-1];if(t&&typeof t==`string`)u(e===`nil`?null:`/${e}`);else if(t&&typeof t==`object`)c.push(e);else throw Error(`Invalid data`)}function f(){if(!c.length)throw Error(`Invalid data`);c.pop()}i();let p=e.length;for(;p>0&&e[p-1]===0;)p--;for(;r<p;){let a=r,s=e[a];if(s===60&&e[a+1]===60)r+=2,l({});else if(s===62&&e[a+1]===62)r+=2,f();else if(s===47){r+=1;let n=r;for(;r<e.length&&!t(e[r]);)r++;let i=``;for(let t=n;t<r;t++)i+=String.fromCharCode(e[t]);d(i)}else if(s===40)r+=1,u(o());else if(s===91)r+=1,l([]);else if(s===93)r+=1,f();else if(s===110&&e[a+1]===117&&e[a+2]===108&&e[a+3]===108)r+=4,u(null);else if(s===116&&e[a+1]===114&&e[a+2]===117&&e[a+3]===101)r+=4,u(!0);else if(s===102&&e[a+1]===97&&e[a+2]===108&&e[a+3]===115&&e[a+4]===101)r+=5,u(!1);else if(n(s)){let t=``;for(;r<e.length&&n(e[r]);)t+=String.fromCharCode(e[r]),r++;u(parseFloat(t))}else r+=1,console.log(`Invalid token '${String.fromCharCode(s)}' (${s}) at ${r}`);i()}return s}let i=`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`.split(`.`),a=[`RunLengthArray`];function o(e,t=!1){let n=new Uint8Array(1024),r=0,o=0;function s(e){if(r>=n.length){let e=new Uint8Array(n.length*2);e.set(n),n=e}n[r]=e,r++}function c(e){for(let t=0;t<e.length;t++)s(e.charCodeAt(t))}function l(){if(t)c(` `);else for(let e=0;e<o;e++)c(` `)}function u(e,n){l(),c(`/${e}`),g(n,e,!0),t||c(`
|
|
2
|
+
`)}function d(e){return e.toString()}function f(e){return e.toFixed(5).replace(/(\d)0+$/g,`$1`).replace(/^0+\.([1-9])/g,`.$1`).replace(/^-0+\.0(\d)/g,`-.0$1`)}function p(e,t){return t&&i.indexOf(t)!==-1||(e|0)!==e?f(e):d(e)}function m(e){let t=Object.keys(e);return t.indexOf(`98`)!==-1&&t.unshift(...t.splice(t.indexOf(`98`),1)),t.indexOf(`99`)!==-1&&t.unshift(...t.splice(t.indexOf(`99`),1)),t}function h(e){(e===40||e===41||e===92)&&s(92),s(e)}function g(e,n,r=!1){function i(){r?c(` `):l()}if(e===null)i(),c(t?`/nil`:`null`);else if(typeof e==`number`)i(),c(p(e,n));else if(typeof e==`boolean`)i(),c(e?`true`:`false`);else if(typeof e==`string`)if(i(),(n===`99`||n===`98`)&&e.charAt(0)===`/`)c(e);else{c(`(`),s(254),s(255);for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);h(n>>8&255),h(n&255)}c(`)`)}else if(Array.isArray(e))if(i(),e.every(e=>typeof e==`number`)){c(`[`);let t=a.indexOf(n)!==-1;for(let n of e)c(` `),c(t?p(n):f(n));c(` ]`)}else{c(`[`),t||c(`
|
|
3
|
+
`);for(let r of e)g(r,n),t||c(`
|
|
4
|
+
`);l(),c(`]`)}else if(typeof e==`object`){r&&!t&&c(`
|
|
5
|
+
`),l(),c(`<<`),t||c(`
|
|
6
|
+
`),o++;for(let t of m(e))u(t,e[t]);o--,l(),c(`>>`)}}if(t){if(typeof e==`object`)for(let t of m(e))u(t,e[t])}else c(`
|
|
7
|
+
|
|
8
|
+
`),g(e);return n.slice(0,r)}})),E=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decodeEngineData=S,e.encodeEngineData=C;let t={name:`MyriadPro-Regular`,script:0,type:0,synthetic:0},n={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},r={font:t,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},i={isOn:!1,show:!1,size:18,leading:22,color:{r:0,g:0,b:255},leadingFillColor:{r:0,g:0,b:255},alignLineHeightToGridFlags:!1},a=[`justification`,`firstLineIndent`,`startIndent`,`endIndent`,`spaceBefore`,`spaceAfter`,`autoHyphenate`,`hyphenatedWordSize`,`preHyphen`,`postHyphen`,`consecutiveHyphens`,`zone`,`wordSpacing`,`letterSpacing`,`glyphSpacing`,`autoLeading`,`leadingType`,`hanging`,`burasagari`,`kinsokuOrder`,`everyLineComposer`],o=`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`.split(`.`),s=[`none`,`crisp`,`strong`,`smooth`,`sharp`],c=[`left`,`right`,`center`,`justify-left`,`justify-right`,`justify-center`,`justify-all`];function l(e){return e.substring(0,1).toUpperCase()+e.substring(1)}function u(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 Error(`Unknown color type in text layer`)}}function d(e){if(!e)return{Type:1,Values:[0,0,0,0]};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 Error(`Invalid color type in text layer`)}function f(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 p(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 m(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 h(e,t,n){let r={};for(let i of t){let t=l(i);e[t]!==void 0&&(i===`justification`?r[i]=c[e[t]]:i===`font`?r[i]=n[e[t]]:i===`fillColor`||i===`strokeColor`?r[i]=u(e[t]):r[i]=e[t])}return r}function g(e,t,n){let r={};for(let i of t){let t=l(i);e[i]!==void 0&&(i===`justification`?r[t]=c.indexOf(e[i]??`left`):i===`font`?r[t]=m(n,e[i]):i===`fillColor`||i===`strokeColor`?r[t]=d(e[i]):r[t]=e[i])}return r}function _(e,t){return h(e,a,t)}function v(e,t){return h(e,o,t)}function y(e,t){return g(e,a,t)}function b(e,t){return g(e,o,t)}function x(e,t,n){if(t.length){for(let r of n){let n=t[0].style[r];if(n!==void 0){let i=!1;i=Array.isArray(n)?t.every(e=>f(e.style[r],n)):typeof n==`object`?t.every(e=>p(e.style[r],n)):t.every(e=>e.style[r]===n),i&&(e[r]=n)}if(e[r]!==void 0)for(let e of t){let t=!1;t=Array.isArray(n)?f(e.style[r],n):typeof n==`object`?p(e.style[r],n):e.style[r]===n,t&&delete e.style[r]}}t.every(e=>Object.keys(e.style).length===0)&&(t.length=0)}}function S(e){let t=e.EngineDict,n=e.ResourceDict,r=n.FontSet.map(e=>({name:e.Name,script:e.Script,type:e.FontType,synthetic:e.Synthetic})),i=t.Editor.Text.replace(/\r/g,`
|
|
9
|
+
`),c=0;for(;/\n$/.test(i);)i=i.substring(0,i.length-1),c++;let l={text:i,antiAlias:s[t.AntiAlias]??`smooth`,useFractionalGlyphWidths:!!t.UseFractionalGlyphWidths,superscriptSize:n.SuperscriptSize,superscriptPosition:n.SuperscriptPosition,subscriptSize:n.SubscriptSize,subscriptPosition:n.SubscriptPosition,smallCapSize:n.SmallCapSize},u=t.Rendered?.Shapes?.Children?.[0]?.Cookie?.Photoshop;u&&(l.shapeType=u.ShapeType===1?`box`:`point`,u.PointBase&&(l.pointBase=u.PointBase),u.BoxBounds&&(l.boxBounds=u.BoxBounds));let d=t.ParagraphRun;l.paragraphStyle={},l.paragraphStyleRuns=[];for(let e=0;e<d.RunArray.length;e++){let t=d.RunArray[e],n=d.RunLengthArray[e],i=_(t.ParagraphSheet.Properties,r);l.paragraphStyleRuns.push({length:n,style:i})}for(let e=c;l.paragraphStyleRuns.length&&e>0;e--)--l.paragraphStyleRuns[l.paragraphStyleRuns.length-1].length===0&&l.paragraphStyleRuns.pop();x(l.paragraphStyle,l.paragraphStyleRuns,a),l.paragraphStyleRuns.length||delete l.paragraphStyleRuns;let f=t.StyleRun;l.style={},l.styleRuns=[];for(let e=0;e<f.RunArray.length;e++){let t=f.RunLengthArray[e],n=v(f.RunArray[e].StyleSheet.StyleSheetData,r);n.font||=r[0],l.styleRuns.push({length:t,style:n})}for(let e=c;l.styleRuns.length&&e>0;e--)--l.styleRuns[l.styleRuns.length-1].length===0&&l.styleRuns.pop();return x(l.style,l.styleRuns,o),l.styleRuns.length||delete l.styleRuns,l}function C(e){let a=`${(e.text||``).replace(/\r?\n/g,`\r`)}\r`,o=[{name:`AdobeInvisFont`,script:0,type:0,synthetic:0}],c=e.style?.font||(e.styleRuns?.find(e=>e.style.font))?.style.font||t,l=[],u=[],f=e.paragraphStyleRuns;if(f&&f.length){let t=a.length;for(let r of f){let i=Math.min(r.length,t);t-=i,i&&(t===1&&r===f[f.length-1]&&(i++,t--),u.push(i),l.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:y(Object.assign(Object.assign(Object.assign({},n),e.paragraphStyle),r.style),o)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}))}t&&(u.push(t),l.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:y(Object.assign(Object.assign({},n),e.paragraphStyle),o)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}))}else for(let t=0,r=0;t<a.length;t++)a.charCodeAt(t)===13&&(u.push(t-r+1),l.push({ParagraphSheet:{DefaultStyleSheet:0,Properties:y(Object.assign(Object.assign({},n),e.paragraphStyle),o)},Adjustments:{Axis:[1,0,1],XY:[0,0]}}),r=t+1);let p=b(Object.assign(Object.assign({},r),{font:c}),o),m=e.styleRuns||[{length:a.length,style:e.style||{}}],h=[],g=[],_=a.length;for(let t of m){let n=Math.min(t.length,_);_-=n,n&&(_===1&&t===m[m.length-1]&&(n++,_--),g.push(n),h.push({StyleSheet:{StyleSheetData:b(Object.assign(Object.assign({kerning:0,autoKerning:!0,fillColor:{r:0,g:0,b:0}},e.style),t.style),o)}}))}_&&m.length&&(g.push(_),h.push({StyleSheet:{StyleSheetData:b(Object.assign({kerning:0,autoKerning:!0,fillColor:{r:0,g:0,b:0}},e.style),o)}}));let v=Object.assign(Object.assign({},i),e.gridInfo),x=e.orientation===`vertical`?2:0,S=+(e.orientation===`vertical`),C=+(e.shapeType===`box`),w={ShapeType:C};C===0?w.PointBase=e.pointBase||[0,0]:w.BoxBounds=e.boxBounds||[0,0,0,0],w.Base={ShapeType:C,TransformPoint0:[1,0],TransformPoint1:[0,1],TransformPoint2:[0,0]};let T={KinsokuSet:[{Name:`PhotoshopKinsokuHard`,NoStart:`、。,.・:;?!ー―’”)〕]}〉》」』】ヽヾゝゞ々ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮヵヶ゛゜?!)]},.:;℃℉¢%‰`,NoEnd:`‘“(〔[{〈《「『【([{¥$£@§〒#`,Keep:`―‥`,Hanging:`、。.,`},{Name:`PhotoshopKinsokuSoft`,NoStart:`、。,.・:;?!’”)〕]}〉》」』】ヽヾゝゞ々`,NoEnd:`‘“(〔[{〈《「『【`,Keep:`―‥`,Hanging:`、。.,`}],MojiKumiSet:[{InternalName:`Photoshop6MojiKumiSet1`},{InternalName:`Photoshop6MojiKumiSet2`},{InternalName:`Photoshop6MojiKumiSet3`},{InternalName:`Photoshop6MojiKumiSet4`}],TheNormalStyleSheet:0,TheNormalParagraphSheet:0,ParagraphSheetSet:[{Name:`Normal RGB`,DefaultStyleSheet:0,Properties:y(Object.assign(Object.assign({},n),e.paragraphStyle),o)}],StyleSheetSet:[{Name:`Normal RGB`,StyleSheetData:p}],FontSet:o.map(e=>({Name:e.name,Script:e.script||0,FontType:e.type||0,Synthetic:e.synthetic||0})),SuperscriptSize:e.superscriptSize??.583,SuperscriptPosition:e.superscriptPosition??.333,SubscriptSize:e.subscriptSize??.583,SubscriptPosition:e.subscriptPosition??.333,SmallCapSize:e.smallCapSize??.7};return{EngineDict:{Editor:{Text:a},ParagraphRun:{DefaultRunData:{ParagraphSheet:{DefaultStyleSheet:0,Properties:{}},Adjustments:{Axis:[1,0,1],XY:[0,0]}},RunArray:l,RunLengthArray:u,IsJoinable:1},StyleRun:{DefaultRunData:{StyleSheet:{StyleSheetData:{}}},RunArray:h,RunLengthArray:g,IsJoinable:2},GridInfo:{GridIsOn:!!v.isOn,ShowGrid:!!v.show,GridSize:v.size??18,GridLeading:v.leading??22,GridColor:d(v.color),GridLeadingFillColor:d(v.color),AlignLineHeightToGridFlags:!!v.alignLineHeightToGridFlags},AntiAlias:s.indexOf(e.antiAlias??`sharp`),UseFractionalGlyphWidths:e.useFractionalGlyphWidths??!0,Rendered:{Version:1,Shapes:{WritingDirection:x,Children:[{ShapeType:C,Procession:S,Lines:{WritingDirection:x,Children:[]},Cookie:{Photoshop:w}}]}}},ResourceDict:Object.assign({},T),DocumentResources:Object.assign({},T)}}})),D=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decodeEngineData2=s;let t={0:{uproot:!0,children:{0:{name:`Type`},1:{name:`Values`}}}},n={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:t},54:{name:`StrokeColor`,children:t},55:{children:{99:{uproot:!0}}},79:{children:t}},r={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:n}},i={name:`StyleSheetData`,children:n},a={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:i}}}}}},6:{name:`ParagraphSheetSet`,children:{0:{uproot:!0,children:{0:{uproot:!0,children:{0:{name:`Name`},5:{name:`Properties`,children:r},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:r},6:{name:`6`}}}}},1:{name:`RunLength`}}}}},6:{name:`StyleRun`,children:{0:{name:`RunArray`,children:{0:{name:`StyleSheet`,children:{0:{uproot:!0,children:{6:i}}}},1:{name:`RunLength`}}}}}}},1:{name:`FontVectorData ???`}}},2:{name:`StyleSheet`,children:n},3:{name:`ParagraphSheet`,children:r}}}};function o(e,t){if(e===null)return e;if(Array.isArray(e))return e.map(e=>o(e,t));if(typeof e!=`object`)return e;let n={};for(let r of Object.keys(e))if(t[r])if(t[r].uproot){r!==`99`&&(n=o(e[r],t[r].children??{})),e[99]&&(n._type=e[99]);break}else n[t[r].name||r]=o(e[r],t[r].children??{});else r===`99`?n._type=e[r]:n[r]=o(e[r],{});return n}function s(e){return o(e,a)}})),ee=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.booleanOperations=e.infoHandlersMap=e.infoHandlers=void 0,e.readBezierKnot=g,e.readVectorMask=b,e.hasMultiEffects=Z;let t=y(),n=w(),r=v(),i=C(),a=O(),o=x(),s=T(),c=E(),l=D(),u=`abcdefghijklmnopqrstuvwxyz`;e.infoHandlers=[],e.infoHandlersMap={};function d(t,n,r,i){let a={key:t,has:n,read:r,write:i};e.infoHandlers.push(a),e.infoHandlersMap[a.key]=a}function f(t,n){e.infoHandlersMap[t]=e.infoHandlersMap[n]}function p(e){return t=>t[e]!==void 0}function m(e){if((0,i.readUint32)(e))throw Error(`Resource size above 4 GB limit at ${e.offset.toString(16)}`);return(0,i.readUint32)(e)}function h(e,t){(0,a.writeUint32)(e,0),(0,a.writeUint32)(e,t)}d(`TySh`,p(`text`),(e,t,n)=>{if((0,i.readInt16)(e)!==1)throw Error(`Invalid TySh version`);let r=[];for(let t=0;t<6;t++)r.push((0,i.readFloat64)(e));if((0,i.readInt16)(e)!==50)throw Error(`Invalid TySh text version`);let a=(0,o.readVersionAndDescriptor)(e);if((0,i.readInt16)(e)!==1)throw Error(`Invalid TySh warp version`);let l=(0,o.readVersionAndDescriptor)(e);if(t.text={transform:r,left:(0,i.readFloat32)(e),top:(0,i.readFloat32)(e),right:(0,i.readFloat32)(e),bottom:(0,i.readFloat32)(e),text:a[`Txt `].replace(/\r/g,`
|
|
10
|
+
`),index:a.TextIndex||0,gridding:o.textGridding.decode(a.textGridding),antiAlias:o.Annt.decode(a.AntA),orientation:o.Ornt.decode(a.Ornt),warp:{style:o.warpStyle.decode(l.warpStyle),value:l.warpValue||0,perspective:l.warpPerspective||0,perspectiveOther:l.warpPerspectiveOther||0,rotate:o.Ornt.decode(l.warpRotate)}},a.bounds&&(t.text.bounds=(0,o.descBoundsToBounds)(a.bounds)),a.boundingBox&&(t.text.boundingBox=(0,o.descBoundsToBounds)(a.boundingBox)),a.EngineData){let e=(0,s.parseEngineData)(a.EngineData),n=(0,c.decodeEngineData)(e);t.text=Object.assign(Object.assign({},t.text),n)}(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.text,r=n.warp||{},i=n.transform||[1,0,0,1,0,0],l=Object.assign(Object.assign(Object.assign({"Txt ":(n.text||``).replace(/\r?\n/g,`\r`),textGridding:o.textGridding.encode(n.gridding),Ornt:o.Ornt.encode(n.orientation),AntA:o.Annt.encode(n.antiAlias)},n.bounds?{bounds:(0,o.boundsToDescBounds)(n.bounds)}:{}),n.boundingBox?{boundingBox:(0,o.boundsToDescBounds)(n.boundingBox)}:{}),{TextIndex:n.index||0,EngineData:(0,s.serializeEngineData)((0,c.encodeEngineData)(n))});(0,a.writeInt16)(e,1);for(let t=0;t<6;t++)(0,a.writeFloat64)(e,i[t]);(0,a.writeInt16)(e,50),(0,o.writeVersionAndDescriptor)(e,``,`TxLr`,l,`text`),(0,a.writeInt16)(e,1),(0,o.writeVersionAndDescriptor)(e,``,`warp`,A(r)),(0,a.writeFloat32)(e,n.left),(0,a.writeFloat32)(e,n.top),(0,a.writeFloat32)(e,n.right),(0,a.writeFloat32)(e,n.bottom)}),d(`SoCo`,e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&e.vectorFill.type===`color`,(e,t)=>{let n=(0,o.readVersionAndDescriptor)(e);t.vectorFill=(0,o.parseVectorContent)(n)},(e,t)=>{let{descriptor:n}=(0,o.serializeVectorContent)(t.vectorFill);(0,o.writeVersionAndDescriptor)(e,``,`null`,n)}),d(`GdFl`,e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&(e.vectorFill.type===`solid`||e.vectorFill.type===`noise`),(e,t,n)=>{let r=(0,o.readVersionAndDescriptor)(e);t.vectorFill=(0,o.parseVectorContent)(r),(0,i.skipBytes)(e,n())},(e,t)=>{let{descriptor:n}=(0,o.serializeVectorContent)(t.vectorFill);(0,o.writeVersionAndDescriptor)(e,``,`null`,n)}),d(`PtFl`,e=>e.vectorFill!==void 0&&e.vectorStroke===void 0&&e.vectorFill.type===`pattern`,(e,t)=>{let n=(0,o.readVersionAndDescriptor)(e);t.vectorFill=(0,o.parseVectorContent)(n)},(e,t)=>{let{descriptor:n}=(0,o.serializeVectorContent)(t.vectorFill);(0,o.writeVersionAndDescriptor)(e,``,`null`,n)}),d(`vscg`,e=>e.vectorFill!==void 0&&e.vectorStroke!==void 0,(e,t,n)=>{(0,i.readSignature)(e);let r=(0,o.readVersionAndDescriptor)(e);t.vectorFill=(0,o.parseVectorContent)(r),(0,i.skipBytes)(e,n())},(e,t)=>{let{descriptor:n,key:r}=(0,o.serializeVectorContent)(t.vectorFill);(0,a.writeSignature)(e,r),(0,o.writeVersionAndDescriptor)(e,``,`null`,n)});function g(e,t,n){let r=(0,i.readFixedPointPath32)(e)*n,a=(0,i.readFixedPointPath32)(e)*t,o=(0,i.readFixedPointPath32)(e)*n,s=(0,i.readFixedPointPath32)(e)*t,c=(0,i.readFixedPointPath32)(e)*n;return[a,r,s,o,(0,i.readFixedPointPath32)(e)*t,c]}function _(e,t,n,r){(0,a.writeFixedPointPath32)(e,t[1]/r),(0,a.writeFixedPointPath32)(e,t[0]/n),(0,a.writeFixedPointPath32)(e,t[3]/r),(0,a.writeFixedPointPath32)(e,t[2]/n),(0,a.writeFixedPointPath32)(e,t[5]/r),(0,a.writeFixedPointPath32)(e,t[4]/n)}e.booleanOperations=[`exclude`,`combine`,`subtract`,`intersect`];function b(t,n,r,a,o){let s=t.offset+o,c=n.paths,l;for(;s-t.offset>=26;){let o=(0,i.readUint16)(t);switch(o){case 0:case 3:{(0,i.readUint16)(t);let n=(0,i.readInt16)(t),r=(0,i.readUint16)(t);(0,i.skipBytes)(t,18),l={open:o===3,knots:[],fillRule:r===2?`non-zero`:`even-odd`},n!==-1&&(l.operation=e.booleanOperations[n]),c.push(l);break}case 1:case 2:case 4:case 5:l.knots.push({linked:o===1||o===4,points:g(t,r,a)});break;case 6:(0,i.skipBytes)(t,24);break;case 7:{let e=(0,i.readFixedPointPath32)(t),r=(0,i.readFixedPointPath32)(t),a=(0,i.readFixedPointPath32)(t),o=(0,i.readFixedPointPath32)(t),s=(0,i.readFixedPointPath32)(t);(0,i.skipBytes)(t,4),n.clipboard={top:e,left:r,bottom:a,right:o,resolution:s};break}case 8:n.fillStartsWithAllPixels=!!(0,i.readUint16)(t),(0,i.skipBytes)(t,22);break;default:throw Error(`Invalid vmsk section`)}}return c}d(`vmsk`,p(`vectorMask`),(e,t,n,{width:r,height:a})=>{if((0,i.readUint32)(e)!==3)throw Error(`Invalid vmsk version`);t.vectorMask={paths:[]};let o=t.vectorMask,s=(0,i.readUint32)(e);o.invert=(s&1)!=0,o.notLink=(s&2)!=0,o.disable=(s&4)!=0,b(e,o,r,a,n()),(0,i.skipBytes)(e,n())},(t,n,{width:r,height:i})=>{let o=n.vectorMask,s=!!o.invert|(o.notLink?2:0)|(o.disable?4:0);(0,a.writeUint32)(t,3),(0,a.writeUint32)(t,s),(0,a.writeUint16)(t,6),(0,a.writeZeros)(t,24);let c=o.clipboard;c&&((0,a.writeUint16)(t,7),(0,a.writeFixedPointPath32)(t,c.top),(0,a.writeFixedPointPath32)(t,c.left),(0,a.writeFixedPointPath32)(t,c.bottom),(0,a.writeFixedPointPath32)(t,c.right),(0,a.writeFixedPointPath32)(t,c.resolution),(0,a.writeZeros)(t,4)),(0,a.writeUint16)(t,8),(0,a.writeUint16)(t,+!!o.fillStartsWithAllPixels),(0,a.writeZeros)(t,22);for(let n of o.paths){(0,a.writeUint16)(t,n.open?3:0),(0,a.writeUint16)(t,n.knots.length),(0,a.writeUint16)(t,n.operation?e.booleanOperations.indexOf(n.operation):-1),(0,a.writeUint16)(t,n.fillRule===`non-zero`?2:1),(0,a.writeZeros)(t,18);let o=n.open?4:1,s=n.open?5:2;for(let{linked:e,points:c}of n.knots)(0,a.writeUint16)(t,e?o:s),_(t,c,r,i)}}),f(`vsms`,`vmsk`),d(`vowv`,p(`vowv`),(e,t)=>{t.vowv=(0,i.readUint32)(e)},(e,t)=>{(0,a.writeUint32)(e,t.vowv)}),d(`vogk`,p(`vectorOrigination`),(e,t,n)=>{if((0,i.readInt32)(e)!==1)throw Error(`Invalid vogk version`);let r=(0,o.readVersionAndDescriptor)(e);t.vectorOrigination={keyDescriptorList:[]};for(let e of r.keyDescriptorList){let n={};e.keyShapeInvalidated!=null&&(n.keyShapeInvalidated=e.keyShapeInvalidated),e.keyOriginType!=null&&(n.keyOriginType=e.keyOriginType),e.keyOriginResolution!=null&&(n.keyOriginResolution=e.keyOriginResolution),e.keyOriginShapeBBox&&(n.keyOriginShapeBoundingBox={top:(0,o.parseUnitsOrNumber)(e.keyOriginShapeBBox[`Top `]),left:(0,o.parseUnitsOrNumber)(e.keyOriginShapeBBox.Left),bottom:(0,o.parseUnitsOrNumber)(e.keyOriginShapeBBox.Btom),right:(0,o.parseUnitsOrNumber)(e.keyOriginShapeBBox.Rght)});let r=e.keyOriginRRectRadii;r&&(n.keyOriginRRectRadii={topRight:(0,o.parseUnits)(r.topRight),topLeft:(0,o.parseUnits)(r.topLeft),bottomLeft:(0,o.parseUnits)(r.bottomLeft),bottomRight:(0,o.parseUnits)(r.bottomRight)});let i=e.keyOriginBoxCorners;i&&(n.keyOriginBoxCorners=[{x:i.rectangleCornerA.Hrzn,y:i.rectangleCornerA.Vrtc},{x:i.rectangleCornerB.Hrzn,y:i.rectangleCornerB.Vrtc},{x:i.rectangleCornerC.Hrzn,y:i.rectangleCornerC.Vrtc},{x:i.rectangleCornerD.Hrzn,y:i.rectangleCornerD.Vrtc}]);let a=e.Trnf;a&&(n.transform=[a.xx,a.xy,a.yx,a.yy,a.tx,a.ty]),t.vectorOrigination.keyDescriptorList.push(n)}(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.vectorOrigination,r={keyDescriptorList:[]};for(let e=0;e<n.keyDescriptorList.length;e++){let t=n.keyDescriptorList[e];r.keyDescriptorList.push({});let i=r.keyDescriptorList[r.keyDescriptorList.length-1];t.keyOriginType!=null&&(i.keyOriginType=t.keyOriginType),t.keyOriginResolution!=null&&(i.keyOriginResolution=t.keyOriginResolution);let a=t.keyOriginRRectRadii;a&&(i.keyOriginRRectRadii={unitValueQuadVersion:1,topRight:(0,o.unitsValue)(a.topRight,`topRight`),topLeft:(0,o.unitsValue)(a.topLeft,`topLeft`),bottomLeft:(0,o.unitsValue)(a.bottomLeft,`bottomLeft`),bottomRight:(0,o.unitsValue)(a.bottomRight,`bottomRight`)});let s=t.keyOriginShapeBoundingBox;s&&(i.keyOriginShapeBBox={unitValueQuadVersion:1,"Top ":(0,o.unitsValue)(s.top,`top`),Left:(0,o.unitsValue)(s.left,`left`),Btom:(0,o.unitsValue)(s.bottom,`bottom`),Rght:(0,o.unitsValue)(s.right,`right`)});let c=t.keyOriginBoxCorners;c&&c.length===4&&(i.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 l=t.transform;l&&l.length===6&&(i.Trnf={xx:l[0],xy:l[1],yx:l[2],yy:l[3],tx:l[4],ty:l[5]}),t.keyShapeInvalidated!=null&&(i.keyShapeInvalidated=t.keyShapeInvalidated),i.keyOriginIndex=e}(0,a.writeInt32)(e,1),(0,o.writeVersionAndDescriptor)(e,``,`null`,r)}),d(`lmfx`,e=>e.effects!==void 0&&Z(e.effects),(e,t,n)=>{if((0,i.readUint32)(e)!==0)throw Error(`Invalid lmfx version`);let r=(0,o.readVersionAndDescriptor)(e);t.effects=(0,o.parseEffects)(r,!!e.logMissingFeatures),(0,i.skipBytes)(e,n())},(e,t,n,r)=>{let i=(0,o.serializeEffects)(t.effects,!!r.logMissingFeatures,!0);(0,a.writeUint32)(e,0),(0,o.writeVersionAndDescriptor)(e,``,`null`,i)}),d(`lrFX`,p(`effects`),(e,t,r)=>{t.effects||=(0,n.readEffects)(e),(0,i.skipBytes)(e,r())},(e,t)=>{(0,n.writeEffects)(e,t.effects)}),d(`luni`,p(`name`),(e,t,n)=>{if(n()>4){let r=(0,i.readUint32)(e);n()>=r*2?t.name=(0,i.readUnicodeStringWithLength)(e,r):e.logDevFeatures&&e.log(`name in luni section is too long`)}else e.logDevFeatures&&e.log(`empty luni section`);(0,i.skipBytes)(e,n())},(e,t)=>{(0,a.writeUnicodeString)(e,t.name)}),d(`lnsr`,p(`nameSource`),(e,t)=>t.nameSource=(0,i.readSignature)(e),(e,t)=>(0,a.writeSignature)(e,t.nameSource)),d(`lyid`,p(`id`),(e,t)=>{t.id=(0,i.readUint32)(e)},(e,t,n,r)=>{let i=t.id;for(;r.layerIds.has(i);)i+=100;(0,a.writeUint32)(e,i),r.layerIds.add(i),r.layerToId.set(t,i)}),d(`lsct`,p(`sectionDivider`),(e,t,n)=>{t.sectionDivider={type:(0,i.readUint32)(e)},n()&&((0,i.checkSignature)(e,`8BIM`),t.sectionDivider.key=(0,i.readSignature)(e)),n()&&(t.sectionDivider.subType=(0,i.readUint32)(e))},(e,t)=>{(0,a.writeUint32)(e,t.sectionDivider.type),t.sectionDivider.key&&((0,a.writeSignature)(e,`8BIM`),(0,a.writeSignature)(e,t.sectionDivider.key),t.sectionDivider.subType!==void 0&&(0,a.writeUint32)(e,t.sectionDivider.subType))}),f(`lsdk`,`lsct`),d(`clbl`,p(`blendClippendElements`),(e,t)=>{t.blendClippendElements=!!(0,i.readUint8)(e),(0,i.skipBytes)(e,3)},(e,t)=>{(0,a.writeUint8)(e,+!!t.blendClippendElements),(0,a.writeZeros)(e,3)}),d(`infx`,p(`blendInteriorElements`),(e,t)=>{t.blendInteriorElements=!!(0,i.readUint8)(e),(0,i.skipBytes)(e,3)},(e,t)=>{(0,a.writeUint8)(e,+!!t.blendInteriorElements),(0,a.writeZeros)(e,3)}),d(`knko`,p(`knockout`),(e,t)=>{t.knockout=!!(0,i.readUint8)(e),(0,i.skipBytes)(e,3)},(e,t)=>{(0,a.writeUint8)(e,+!!t.knockout),(0,a.writeZeros)(e,3)}),d(`lmgm`,p(`layerMaskAsGlobalMask`),(e,t)=>{t.layerMaskAsGlobalMask=!!(0,i.readUint8)(e),(0,i.skipBytes)(e,3)},(e,t)=>{(0,a.writeUint8)(e,+!!t.layerMaskAsGlobalMask),(0,a.writeZeros)(e,3)}),d(`lspf`,p(`protected`),(e,t)=>{let n=(0,i.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|(t.protected.composite?2:0)|(t.protected.position?4:0)|(t.protected.artboards?8:0);(0,a.writeUint32)(e,n)}),d(`lclr`,p(`layerColor`),(e,t)=>{let n=(0,i.readUint16)(e);(0,i.skipBytes)(e,6),t.layerColor=r.layerColors[n]},(e,t)=>{let n=r.layerColors.indexOf(t.layerColor);(0,a.writeUint16)(e,n===-1?0:n),(0,a.writeZeros)(e,6)}),d(`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 r=(0,i.readUint32)(e);for(let n=0;n<r;n++){(0,i.checkSignature)(e,`8BIM`);let n=(0,i.readSignature)(e);(0,i.readUint8)(e),(0,i.skipBytes)(e,3),(0,i.readSection)(e,1,r=>{if(n===`cust`){let n=(0,o.readVersionAndDescriptor)(e);n.layerTime!==void 0&&(t.timestamp=n.layerTime)}else if(n===`mlst`){let n=(0,o.readVersionAndDescriptor)(e);t.animationFrames=[];for(let r=0;r<n.LaSt.length;r++){let i=n.LaSt[r],a={frames:i.FrLs};i.enab!==void 0&&(a.enable=i.enab),i.Ofst&&(a.offset=(0,o.horzVrtcToXY)(i.Ofst)),i.FXRf&&(a.referencePoint=(0,o.horzVrtcToXY)(i.FXRf)),i.Lefx&&(a.effects=(0,o.parseEffects)(i.Lefx,!!e.logMissingFeatures)),i.blendOptions&&i.blendOptions.Opct&&(a.opacity=(0,o.parsePercent)(i.blendOptions.Opct)),t.animationFrames.push(a)}}else if(n===`mdyn`){(0,i.readUint16)(e);let n=(0,i.readUint8)(e),r=(0,i.readUint8)(e);t.animationFrameFlags={propagateFrameOne:!n,unifyLayerPosition:(r&1)!=0,unifyLayerStyle:(r&2)!=0,unifyLayerVisibility:(r&4)!=0}}else if(n===`tmln`){let n=(0,o.readVersionAndDescriptor)(e),r=n.timeScope,i={start:(0,o.frac)(r.Strt),duration:(0,o.frac)(r.duration),inTime:(0,o.frac)(r.inTime),outTime:(0,o.frac)(r.outTime),autoScope:n.autoScope,audioLevel:n.audioLevel};n.trackList&&(i.tracks=(0,o.parseTrackList)(n.trackList,!!e.logMissingFeatures)),t.timeline=i}else if(n===`cmls`){let n=(0,o.readVersionAndDescriptor)(e);t.comps={settings:[]},n.origFXRefPoint&&(t.comps.originalEffectsReferencePoint={x:n.origFXRefPoint.Hrzn,y:n.origFXRefPoint.Vrtc});for(let e of n.layerSettings){t.comps.settings.push({compList:e.compList});let n=t.comps.settings[t.comps.settings.length-1];`enab`in e&&(n.enabled=e.enab),e.Ofst&&(n.offset={x:e.Ofst.Hrzn,y:e.Ofst.Vrtc}),e.FXRefPoint&&(n.effectsReferencePoint={x:e.FXRefPoint.Hrzn,y:e.FXRefPoint.Vrtc})}}else n===`extn`&&(0,o.readVersionAndDescriptor)(e),e.logMissingFeatures&&e.log(`Unhandled "shmd" section key`,n);(0,i.skipBytes)(e,r())})}(0,i.skipBytes)(e,n())},(e,t,n,r)=>{let{animationFrames:i,animationFrameFlags:s,timestamp:c,timeline:l,comps:u}=t,d=0;i&&d++,s&&d++,l&&d++,c!==void 0&&d++,u&&d++,(0,a.writeUint32)(e,d),i&&((0,a.writeSignature)(e,`8BIM`),(0,a.writeSignature)(e,`mlst`),(0,a.writeUint8)(e,0),(0,a.writeZeros)(e,3),(0,a.writeSection)(e,2,()=>{let n={LaID:t.id??0,LaSt:[]};for(let e=0;e<i.length;e++){let t=i[e],r={};t.enable!==void 0&&(r.enab=t.enable),r.FrLs=t.frames,t.offset&&(r.Ofst=(0,o.xyToHorzVrtc)(t.offset)),t.referencePoint&&(r.FXRf=(0,o.xyToHorzVrtc)(t.referencePoint)),t.effects&&(r.Lefx=(0,o.serializeEffects)(t.effects,!1,!1)),t.opacity!==void 0&&(r.blendOptions={Opct:(0,o.unitsPercent)(t.opacity)}),n.LaSt.push(r)}(0,o.writeVersionAndDescriptor)(e,``,`null`,n)},!0)),s&&((0,a.writeSignature)(e,`8BIM`),(0,a.writeSignature)(e,`mdyn`),(0,a.writeUint8)(e,0),(0,a.writeZeros)(e,3),(0,a.writeSection)(e,2,()=>{(0,a.writeUint16)(e,0),(0,a.writeUint8)(e,s.propagateFrameOne?0:15),(0,a.writeUint8)(e,!!s.unifyLayerPosition|(s.unifyLayerStyle?2:0)|(s.unifyLayerVisibility?4:0))})),l&&((0,a.writeSignature)(e,`8BIM`),(0,a.writeSignature)(e,`tmln`),(0,a.writeUint8)(e,0),(0,a.writeZeros)(e,3),(0,a.writeSection)(e,2,()=>{let n={Vrsn:1,timeScope:{Vrsn:1,Strt:l.start,duration:l.duration,inTime:l.inTime,outTime:l.outTime},autoScope:l.autoScope,audioLevel:l.audioLevel};l.tracks&&(n.trackList=(0,o.serializeTrackList)(l.tracks));let i=r.layerToId.get(t)||t.id;if(!i)throw Error(`You need to provide layer.id value whan writing document with animations`);n.LyrI=i,(0,o.writeVersionAndDescriptor)(e,``,`null`,n,`anim`)},!0)),c!==void 0&&((0,a.writeSignature)(e,`8BIM`),(0,a.writeSignature)(e,`cust`),(0,a.writeUint8)(e,0),(0,a.writeZeros)(e,3),(0,a.writeSection)(e,2,()=>{let t={layerTime:c};(0,o.writeVersionAndDescriptor)(e,``,`metadata`,t)},!0)),u&&((0,a.writeSignature)(e,`8BIM`),(0,a.writeSignature)(e,`cmls`),(0,a.writeUint8)(e,0),(0,a.writeZeros)(e,3),(0,a.writeSection)(e,2,()=>{let n=r.layerToId.get(t)||t.id;if(!n)throw Error(`You need to provide layer.id value whan writing document with layer comps`);let i={};u.originalEffectsReferencePoint&&(i.origFXRefPoint={Hrzn:u.originalEffectsReferencePoint.x,Vrtc:u.originalEffectsReferencePoint.y}),i.LyrI=n,i.layerSettings=[];for(let e of u.settings){let t={};e.enabled!==void 0&&(t.enab=e.enabled),e.offset&&(t.Ofst={Hrzn:e.offset.x,Vrtc:e.offset.y}),e.effectsReferencePoint&&(t.FXRefPoint={Hrzn:e.effectsReferencePoint.x,Vrtc:e.effectsReferencePoint.y}),t.compList=e.compList,i.layerSettings.push(t)}(0,o.writeVersionAndDescriptor)(e,``,`null`,i)},!0))}),d(`PxSc`,()=>!1,(e,t)=>{let n=(0,o.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,r={_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,o.writeVersionAndDescriptor)(e,``,`PixelSource`,r)}),d(`vstk`,p(`vectorStroke`),(e,t,n)=>{let r=(0,o.readVersionAndDescriptor)(e);t.vectorStroke={strokeEnabled:r.strokeEnabled,fillEnabled:r.fillEnabled,lineWidth:(0,o.parseUnits)(r.strokeStyleLineWidth),lineDashOffset:(0,o.parseUnits)(r.strokeStyleLineDashOffset),miterLimit:r.strokeStyleMiterLimit,lineCapType:o.strokeStyleLineCapType.decode(r.strokeStyleLineCapType),lineJoinType:o.strokeStyleLineJoinType.decode(r.strokeStyleLineJoinType),lineAlignment:o.strokeStyleLineAlignment.decode(r.strokeStyleLineAlignment),scaleLock:r.strokeStyleScaleLock,strokeAdjust:r.strokeStyleStrokeAdjust,lineDashSet:r.strokeStyleLineDashSet.map(o.parseUnits),blendMode:o.BlnM.decode(r.strokeStyleBlendMode),opacity:(0,o.parsePercent)(r.strokeStyleOpacity),content:(0,o.parseVectorContent)(r.strokeStyleContent),resolution:r.strokeStyleResolution},(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.vectorStroke,r={strokeStyleVersion:2,strokeEnabled:!!n.strokeEnabled,fillEnabled:!!n.fillEnabled,strokeStyleLineWidth:n.lineWidth||{value:3,units:`Points`},strokeStyleLineDashOffset:n.lineDashOffset||{value:0,units:`Points`},strokeStyleMiterLimit:n.miterLimit??100,strokeStyleLineCapType:o.strokeStyleLineCapType.encode(n.lineCapType),strokeStyleLineJoinType:o.strokeStyleLineJoinType.encode(n.lineJoinType),strokeStyleLineAlignment:o.strokeStyleLineAlignment.encode(n.lineAlignment),strokeStyleScaleLock:!!n.scaleLock,strokeStyleStrokeAdjust:!!n.strokeAdjust,strokeStyleLineDashSet:n.lineDashSet||[],strokeStyleBlendMode:o.BlnM.encode(n.blendMode),strokeStyleOpacity:(0,o.unitsPercent)(n.opacity??1),strokeStyleContent:(0,o.serializeVectorContent)(n.content||{type:`color`,color:{r:0,g:0,b:0}}).descriptor,strokeStyleResolution:n.resolution??72};(0,o.writeVersionAndDescriptor)(e,``,`strokeStyle`,r)}),d(`artb`,p(`artboard`),(e,t,n)=>{let r=(0,o.readVersionAndDescriptor)(e),a=r.artboardRect;t.artboard={rect:{top:a[`Top `],left:a.Left,bottom:a.Btom,right:a.Rght},guideIndices:r.guideIndeces,presetName:r.artboardPresetName,color:(0,o.parseColor)(r[`Clr `]),backgroundType:r.artboardBackgroundType},(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.artboard,r=n.rect,i={artboardRect:{"Top ":r.top,Left:r.left,Btom:r.bottom,Rght:r.right},guideIndeces:n.guideIndices||[],artboardPresetName:n.presetName||``,"Clr ":(0,o.serializeColor)(n.color),artboardBackgroundType:n.backgroundType??1};(0,o.writeVersionAndDescriptor)(e,``,`artboard`,i)}),d(`sn2P`,p(`usingAlignedRendering`),(e,t)=>t.usingAlignedRendering=!!(0,i.readUint32)(e),(e,t)=>(0,a.writeUint32)(e,+!!t.usingAlignedRendering));let S=[`unknown`,`vector`,`raster`,`image stack`];function ee(e){let t=Object.assign(Object.assign({style:o.warpStyle.decode(e.warpStyle)},e.warpValues?{values:e.warpValues}:{value:e.warpValue||0}),{perspective:e.warpPerspective||0,perspectiveOther:e.warpPerspectiveOther||0,rotate:o.Ornt.decode(e.warpRotate),bounds:e.bounds&&{top:(0,o.parseUnitsOrNumber)(e.bounds[`Top `]),left:(0,o.parseUnitsOrNumber)(e.bounds.Left),bottom:(0,o.parseUnitsOrNumber)(e.bounds.Btom),right:(0,o.parseUnitsOrNumber)(e.bounds.Rght)},uOrder:e.uOrder,vOrder:e.vOrder});(e.deformNumRows!=null||e.deformNumCols!=null)&&(t.deformNumRows=e.deformNumRows,t.deformNumCols=e.deformNumCols);let n=e.customEnvelopeWarp;if(n){t.customEnvelopeWarp={meshPoints:[]};let e=n.meshPoints.find(e=>e.type===`Hrzn`)?.values||[],r=n.meshPoints.find(e=>e.type===`Vrtc`)?.values||[];for(let n=0;n<e.length;n++)t.customEnvelopeWarp.meshPoints.push({x:e[n],y:r[n]});(n.quiltSliceX||n.quiltSliceY)&&(t.customEnvelopeWarp.quiltSliceX=n.quiltSliceX?.[0]?.values||[],t.customEnvelopeWarp.quiltSliceY=n.quiltSliceY?.[0]?.values||[])}return t}function k(e){return e.deformNumCols!=null||e.deformNumRows!=null||e.customEnvelopeWarp?.quiltSliceX||e.customEnvelopeWarp?.quiltSliceY}function A(e){let t=e.bounds,n=Object.assign(Object.assign({warpStyle:o.warpStyle.encode(e.style)},e.values?{warpValues:e.values}:{warpValue:e.value||0}),{warpPerspective:e.perspective||0,warpPerspectiveOther:e.perspectiveOther||0,warpRotate:o.Ornt.encode(e.rotate),bounds:{"Top ":(0,o.unitsValue)(t&&t.top||{units:`Pixels`,value:0},`bounds.top`),Left:(0,o.unitsValue)(t&&t.left||{units:`Pixels`,value:0},`bounds.left`),Btom:(0,o.unitsValue)(t&&t.bottom||{units:`Pixels`,value:0},`bounds.bottom`),Rght:(0,o.unitsValue)(t&&t.right||{units:`Pixels`,value:0},`bounds.right`)},uOrder:e.uOrder||0,vOrder:e.vOrder||0}),r=k(e);if(r){let t=n;t.deformNumRows=e.deformNumRows||0,t.deformNumCols=e.deformNumCols||0}let i=e.customEnvelopeWarp;if(i){let e=i.meshPoints||[];if(r){let t=n;t.customEnvelopeWarp={_name:``,_classID:`customEnvelopeWarp`,quiltSliceX:[{type:`quiltSliceX`,values:i.quiltSliceX||[]}],quiltSliceY:[{type:`quiltSliceY`,values:i.quiltSliceY||[]}],meshPoints:[{type:`Hrzn`,values:e.map(e=>e.x)},{type:`Vrtc`,values:e.map(e=>e.y)}]}}else n.customEnvelopeWarp={_name:``,_classID:`customEnvelopeWarp`,meshPoints:[{type:`Hrzn`,values:e.map(e=>e.x)},{type:`Vrtc`,values:e.map(e=>e.y)}]}}return n}d(`PlLd`,p(`placedLayer`),(e,t,n)=>{if((0,i.readSignature)(e)!==`plcL`)throw Error(`Invalid PlLd signature`);if((0,i.readInt32)(e)!==3)throw Error(`Invalid PlLd version`);let r=(0,i.readPascalString)(e,1),a=(0,i.readInt32)(e),s=(0,i.readInt32)(e);(0,i.readInt32)(e);let c=(0,i.readInt32)(e);if(!S[c])throw Error(`Invalid PlLd type`);let l=[];for(let t=0;t<8;t++)l.push((0,i.readFloat64)(e));let u=(0,i.readInt32)(e);if(u!==0)throw Error(`Invalid Warp version ${u}`);let d=(0,o.readVersionAndDescriptor)(e);t.placedLayer=t.placedLayer||{id:r,type:S[c],pageNumber:a,totalPages:s,transform:l,warp:ee(d)},(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.placedLayer;if((0,a.writeSignature)(e,`plcL`),(0,a.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 Error(`Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)`);if((0,a.writePascalString)(e,n.id,1),(0,a.writeInt32)(e,n.pageNumber||1),(0,a.writeInt32)(e,n.totalPages||1),(0,a.writeInt32)(e,16),S.indexOf(n.type)===-1)throw Error(`Invalid placedLayer type`);(0,a.writeInt32)(e,S.indexOf(n.type));for(let t=0;t<8;t++)(0,a.writeFloat64)(e,n.transform[t]);(0,a.writeInt32)(e,0);let r=ie(n),i=k(r)?`quiltWarp`:`warp`;(0,o.writeVersionAndDescriptor)(e,``,i,A(r),i)});function j(e){return new Float32Array(e.buffer.slice(e.byteOffset),0,e.byteLength/4)}function M(e){return new Uint32Array(e.buffer.slice(e.byteOffset),0,e.byteLength/4)}function N(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function P(e){let t=[];for(let n=0;n<e.length;n+=2)t.push({x:e[n],y:e[n+1]});return t}function F(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].x,e[n].y);return t}function te(e){return P(j(e))}function I(e){return{x:(0,o.parseUnits)(e.Hrzn),y:(0,o.parseUnits)(e.Vrtc)}}function L(e){return{_name:``,_classID:`Pnt `,Hrzn:(0,o.unitsValue)(e.x,`x`),Vrtc:(0,o.unitsValue)(e.y,`y`)}}function R(e,t){let n={name:e[`Nm `],opacity:(0,o.parsePercent)(e.blendOptions.Opct),blendMode:o.BlnM.decode(e.blendOptions[`Md `]),enabled:e.enab,hasOptions:e.hasoptions,foregroundColor:(0,o.parseColor)(e.FrgC),backgroundColor:(0,o.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,o.parseUnits)(e.Fltr[`Rds `])}});case`GsnB`:return Object.assign(Object.assign({},n),{type:`gaussian blur`,filter:{radius:(0,o.parseUnits)(e.Fltr[`Rds `])}});case`MtnB`:return Object.assign(Object.assign({},n),{type:`motion blur`,filter:{angle:e.Fltr.Angl,distance:(0,o.parseUnits)(e.Fltr.Dstn)}});case`RdlB`:return Object.assign(Object.assign({},n),{type:`radial blur`,filter:{amount:e.Fltr.Amnt,method:o.BlrM.decode(e.Fltr.BlrM),quality:o.BlrQ.decode(e.Fltr.BlrQ)}});case`shapeBlur`:return Object.assign(Object.assign({},n),{type:`shape blur`,filter:{radius:(0,o.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:o.SmBQ.decode(e.Fltr.SmBQ),mode:o.SmBM.decode(e.Fltr.SmBM)}});case`surfaceBlur`:return Object.assign(Object.assign({},n),{type:`surface blur`,filter:{radius:(0,o.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:o.DspM.decode(e.Fltr.DspM),undefinedAreas:o.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:o.Cnvr.decode(e.Fltr.Cnvr)}});case`Rple`:return Object.assign(Object.assign({},n),{type:`ripple`,filter:{amount:e.Fltr.Amnt,size:o.RplS.decode(e.Fltr.RplS)}});case`Shr `:return Object.assign(Object.assign({},n),{type:`shear`,filter:{shearPoints:e.Fltr.ShrP.map(e=>({x:e.Hrzn,y:e.Vrtc})),shearStart:e.Fltr.ShrS,shearEnd:e.Fltr.ShrE,undefinedAreas:o.UndA.decode(e.Fltr.UndA)}});case`Sphr`:return Object.assign(Object.assign({},n),{type:`spherize`,filter:{amount:e.Fltr.Amnt,mode:o.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:o.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:o.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:o.ZZTy.decode(e.Fltr.ZZTy)}});case`AdNs`:return Object.assign(Object.assign({},n),{type:`add noise`,filter:{amount:(0,o.parsePercent)(e.Fltr.Nose),distribution:o.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,o.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,o.parsePercent)(e.Fltr.ClNs),sharpenDetails:(0,o.parsePercent)(e.Fltr.Shrp),channelDenoise:e.Fltr.channelDenoise.map(e=>Object.assign({channels:e.Chnl.map(o.Chnl.decode),amount:e.Amnt},e.EdgF?{preserveDetails:e.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:o.MztT.decode(e.Fltr.MztT),randomSeed:e.Fltr.FlRs}});case`Msc `:return Object.assign(Object.assign({},n),{type:`mosaic`,filter:{cellSize:(0,o.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:o.Lns.decode(e.Fltr[`Lns `])}});case`smartSharpen`:return Object.assign(Object.assign({},n),{type:`smart sharpen`,filter:{amount:(0,o.parsePercent)(e.Fltr.Amnt),radius:(0,o.parseUnits)(e.Fltr[`Rds `]),threshold:e.Fltr.Thsh,angle:e.Fltr.Angl,moreAccurate:e.Fltr.moreAccurate,blur:o.blurType.decode(e.Fltr.blur),preset:e.Fltr.preset,shadow:{fadeAmount:(0,o.parsePercent)(e.Fltr.sdwM.Amnt),tonalWidth:(0,o.parsePercent)(e.Fltr.sdwM.Wdth),radius:e.Fltr.sdwM[`Rds `]},highlight:{fadeAmount:(0,o.parsePercent)(e.Fltr.hglM.Amnt),tonalWidth:(0,o.parsePercent)(e.Fltr.hglM.Wdth),radius:e.Fltr.hglM[`Rds `]}}});case`UnsM`:return Object.assign(Object.assign({},n),{type:`unsharp mask`,filter:{amount:(0,o.parsePercent)(e.Fltr.Amnt),radius:(0,o.parseUnits)(e.Fltr[`Rds `]),threshold:e.Fltr.Thsh}});case`Dfs `:return Object.assign(Object.assign({},n),{type:`diffuse`,filter:{mode:o.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:o.ExtT.decode(e.Fltr.ExtT),size:e.Fltr.ExtS,depth:e.Fltr.ExtD,depthMode:o.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:o.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:o.CntE.decode(e.Fltr[`Edg `])}});case`Wnd `:return Object.assign(Object.assign({},n),{type:`wind`,filter:{method:o.WndM.decode(e.Fltr.WndM),direction:o.Drct.decode(e.Fltr.Drct)}});case`Dntr`:return Object.assign(Object.assign({},n),{type:`de-interlace`,filter:{eliminate:o.IntE.decode(e.Fltr.IntE),newFieldsBy:o.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,o.parseUnits)(e.Fltr[`Rds `])}});case`Mxm `:return Object.assign(Object.assign({},n),{type:`maximum`,filter:{radius:(0,o.parseUnits)(e.Fltr[`Rds `])}});case`Mnm `:return Object.assign(Object.assign({},n),{type:`minimum`,filter:{radius:(0,o.parseUnits)(e.Fltr[`Rds `])}});case`Ofst`:return Object.assign(Object.assign({},n),{type:`offset`,filter:{horizontal:e.Fltr.Hrzn,vertical:e.Fltr.Vrtc,undefinedAreas:o.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(e=>({rigidType:e.rigidType,originalVertexArray:te(e.originalVertexArray),deformedVertexArray:te(e.deformedVertexArray),indexArray:Array.from(M(e.indexArray)),pinOffsets:P(e.pinOffsets),posFinalPins:P(e.posFinalPins),pinVertexIndices:e.pinVertexIndices,selectedPin:e.selectedPin,pinPosition:P(e.PinP),pinRotation:e.PnRt,pinOverlay:e.PnOv,pinDepth:e.PnDp,meshQuality:e.meshQuality,meshExpansion:e.meshExpansion,meshRigidity:e.meshRigidity,imageResolution:e.imageResolution,meshBoundaryPath:{pathComponents:e.meshBoundaryPath.pathComponents.map(e=>({shapeOperation:e.shapeOperation.split(`.`)[1],paths:e.SbpL.map(e=>({closed:e.Clsp,points:e[`Pts `].map(e=>({anchor:I(e.Anch),forward:I(e[`Fwd `]),backward:I(e[`Bwd `]),smooth:e.Smoo}))}))}))}}))}});case`PbPl`:{let t=[],r=e.Fltr;for(let e=0;e<26&&r[`PN${u[e]}a`];e++)for(let n=0;n<26&&r[`PN${u[e]}${u[n]}`];n++)t.push({name:r[`PN${u[e]}${u[n]}`],value:r[`PF${u[e]}${u[n]}`]});return Object.assign(Object.assign({},n),{type:`oil paint plugin`,filter:{name:e.Fltr.KnNm,gpu:e.Fltr.GpuY,lighting:e.Fltr.LIWy,parameters:t}})}case`HsbP`:return Object.assign(Object.assign({},n),{type:`hsb/hsl`,filter:{inputMode:o.ClrS.decode(e.Fltr.Inpt),rowOrder:o.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(I),warpedVertices:e.Fltr.warpedVertices.map(I),quads:e.Fltr.quads.map(e=>e.indices)}});case`Crvs`:return Object.assign(Object.assign({},n),{type:`curves`,filter:Object.assign({presetKind:o.presetKindType.decode(e.Fltr.presetKind)},e.Fltr.Adjs?{adjustments:e.Fltr.Adjs.map(e=>{let t=e.Chnl.map(o.Chnl.decode);if(e[`Crv `])return{channels:t,curve:e[`Crv `].map(e=>{let t={x:e.Hrzn,y:e.Vrtc};return e.Cnty&&(t.curved=!0),t})};if(e.Mpng)return{channels:t,values:e.Mpng};throw 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 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 Error(`Unknown filterID: ${e.filterID}`)}}function ne(e,t){return{enabled:e.enab,validAtPosition:e.validAtPosition,maskEnabled:e.filterMaskEnable,maskLinked:e.filterMaskLinked,maskExtendWithWhite:e.filterMaskExtendWithWhite,list:e.filterFXList.map(e=>R(e,t)).filter(e=>!!e)}}function z(e){return(0,o.unitsValue)(e.radius,`radius`)}function re(e){let t={_name:``,_classID:`filterFX`,"Nm ":e.name,blendOptions:{_name:``,_classID:`blendOptions`,Opct:(0,o.unitsPercentF)(e.opacity),"Md ":o.BlnM.encode(e.blendMode)},enab:e.enabled,hasoptions:e.hasOptions,FrgC:(0,o.serializeColor)(e.foregroundColor),BckC:(0,o.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 ":z(e.filter)},filterID:697});case`gaussian blur`:return Object.assign(Object.assign({},t),{Fltr:{_name:`Gaussian Blur`,_classID:`GsnB`,"Rds ":z(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,o.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:o.BlrM.encode(e.filter.method),BlrQ:o.BlrQ.encode(e.filter.quality)},filterID:1382313026});case`shape blur`:return Object.assign(Object.assign({},t),{Fltr:{_name:`Shape Blur`,_classID:`shapeBlur`,"Rds ":z(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:o.SmBQ.encode(e.filter.quality),SmBM:o.SmBM.encode(e.filter.mode)},filterID:1399681602});case`surface blur`:return Object.assign(Object.assign({},t),{Fltr:{_name:`Surface Blur`,_classID:`surfaceBlur`,"Rds ":z(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:o.DspM.encode(e.filter.displacementMap),UndA:o.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:o.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:o.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(e=>({_name:``,_classID:`Pnt `,Hrzn:e.x,Vrtc:e.y})),UndA:o.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:o.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:o.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:o.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:o.ZZTy.encode(e.filter.style)},filterID:1516722791});case`add noise`:return Object.assign(Object.assign({},t),{Fltr:{_name:`Add Noise`,_classID:`AdNs`,Dstr:o.Dstr.encode(e.filter.distribution),Nose:(0,o.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 ":z(e.filter)},filterID:1298427424});case`reduce noise`:return Object.assign(Object.assign({},t),{Fltr:{_name:`Reduce Noise`,_classID:`denoise`,ClNs:(0,o.unitsPercentF)(e.filter.reduceColorNoise),Shrp:(0,o.unitsPercentF)(e.filter.sharpenDetails),removeJPEGArtifact:e.filter.removeJpegArtifact,channelDenoise:e.filter.channelDenoise.map(e=>Object.assign({_name:``,_classID:`channelDenoiseParams`,Chnl:e.channels.map(e=>o.Chnl.encode(e)),Amnt:e.amount},e.preserveDetails?{EdgF:e.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:o.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,o.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 ":o.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,o.unitsPercentF)(e.filter.amount),"Rds ":z(e.filter),Thsh:e.filter.threshold,Angl:e.filter.angle,moreAccurate:e.filter.moreAccurate,blur:o.blurType.encode(e.filter.blur),preset:e.filter.preset,sdwM:{_name:`Parameters`,_classID:`adaptCorrectTones`,Amnt:(0,o.unitsPercentF)(e.filter.shadow.fadeAmount),Wdth:(0,o.unitsPercentF)(e.filter.shadow.tonalWidth),"Rds ":e.filter.shadow.radius},hglM:{_name:`Parameters`,_classID:`adaptCorrectTones`,Amnt:(0,o.unitsPercentF)(e.filter.highlight.fadeAmount),Wdth:(0,o.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,o.unitsPercentF)(e.filter.amount),"Rds ":z(e.filter),Thsh:e.filter.threshold},filterID:1433301837});case`diffuse`:return Object.assign(Object.assign({},t),{Fltr:{_name:`Diffuse`,_classID:`Dfs `,"Md ":o.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:o.ExtT.encode(e.filter.type),ExtR:o.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:o.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 ":o.CntE.encode(e.filter.edge)},filterID:1416782659});case`wind`:return Object.assign(Object.assign({},t),{Fltr:{_name:`Wind`,_classID:`Wnd `,WndM:o.WndM.encode(e.filter.method),Drct:o.Drct.encode(e.filter.direction)},filterID:1466852384});case`de-interlace`:return Object.assign(Object.assign({},t),{Fltr:{_name:`De-Interlace`,_classID:`Dntr`,IntE:o.IntE.encode(e.filter.eliminate),IntC:o.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 ":z(e.filter)},filterID:1214736464});case`maximum`:return Object.assign(Object.assign({},t),{Fltr:{_name:`Maximum`,_classID:`Mxm `,"Rds ":z(e.filter)},filterID:1299737888});case`minimum`:return Object.assign(Object.assign({},t),{Fltr:{_name:`Minimum`,_classID:`Mnm `,"Rds ":z(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 ":o.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(e=>({_name:``,_classID:`puppetShape`,rigidType:e.rigidType,VrsM:1,VrsN:0,originalVertexArray:N(new Float32Array(F(e.originalVertexArray))),deformedVertexArray:N(new Float32Array(F(e.deformedVertexArray))),indexArray:N(new Uint32Array(e.indexArray)),pinOffsets:F(e.pinOffsets),posFinalPins:F(e.posFinalPins),pinVertexIndices:e.pinVertexIndices,PinP:F(e.pinPosition),PnRt:e.pinRotation,PnOv:e.pinOverlay,PnDp:e.pinDepth,meshQuality:e.meshQuality,meshExpansion:e.meshExpansion,meshRigidity:e.meshRigidity,imageResolution:e.imageResolution,meshBoundaryPath:{_name:``,_classID:`pathClass`,pathComponents:e.meshBoundaryPath.pathComponents.map(e=>({_name:``,_classID:`PaCm`,shapeOperation:`shapeOperation.${e.shapeOperation}`,SbpL:e.paths.map(e=>({_name:``,_classID:`Sbpl`,Clsp:e.closed,"Pts ":e.points.map(e=>({_name:``,_classID:`Pthp`,Anch:L(e.anchor),"Fwd ":L(e.forward),"Bwd ":L(e.backward),Smoo:e.smooth}))}))}))},selectedPin:e.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 t=0;t<e.filter.parameters.length;t++){let{name:r,value:i}=e.filter.parameters[t],a=`${u[Math.floor(t/26)]}${u[t%26]}`;n[`PN${a}`]=r,n[`PT${a}`]=0,n[`PF${a}`]=i}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(L),warpedVertices:e.filter.warpedVertices.map(L),quads:e.filter.quads.map(e=>({indices:e}))},filterID:442});case`curves`:return Object.assign(Object.assign({},t),{Fltr:Object.assign({_name:`Curves`,_classID:`Crvs`,presetKind:o.presetKindType.encode(e.filter.presetKind)},e.filter.adjustments?{Adjs:e.filter.adjustments.map(e=>`curve`in e?{_name:``,_classID:`CrvA`,Chnl:e.channels.map(o.Chnl.encode),"Crv ":e.curve.map(e=>Object.assign({_name:``,_classID:`Pnt `,Hrzn:e.x,Vrtc:e.y},e.curved?{Cnty:!0}:{}))}:{_name:``,_classID:`CrvA`,Chnl:e.channels.map(o.Chnl.encode),Mpng:e.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 Error(`Unknow filter type: ${e.type}`)}}function ie(e){if(e.warp)return e.warp;if(!e.width||!e.height)throw Error(`You must provide width and height of the linked image in placedLayer`);let t=e.width,n=e.height,r=t/3,i=t*2/3,a=t,o=n/3,s=n*2/3,c=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:0,y:0},{x:r,y:0},{x:i,y:0},{x:a,y:0},{x:0,y:o},{x:r,y:o},{x:i,y:o},{x:a,y:o},{x:0,y:s},{x:r,y:s},{x:i,y:s},{x:a,y:s},{x:0,y:c},{x:r,y:c},{x:i,y:c},{x:a,y:c}]}}}d(`SoLd`,p(`placedLayer`),(e,t,n)=>{if((0,i.readSignature)(e)!==`soLD`)throw Error(`Invalid SoLd type`);let r=(0,i.readInt32)(e);if(r!==4&&r!==5)throw Error(`Invalid SoLd version`);let a=(0,o.readVersionAndDescriptor)(e,!0);t.placedLayer={id:a.Idnt,placed:a.placed,type:S[a.Type],pageNumber:a.PgNm,totalPages:a.totalPages,frameStep:(0,o.frac)(a.frameStep),duration:(0,o.frac)(a.duration),frameCount:a.frameCount,transform:a.Trnf,width:a[`Sz `].Wdth,height:a[`Sz `].Hght,resolution:(0,o.parseUnits)(a.Rslt),warp:ee(a.quiltWarp||a.warp)},a.nonAffineTransform&&a.nonAffineTransform.some((e,t)=>e!==a.Trnf[t])&&(t.placedLayer.nonAffineTransform=a.nonAffineTransform),a.Crop&&(t.placedLayer.crop=a.Crop),a.comp&&(t.placedLayer.comp=a.comp),a.compInfo&&(t.placedLayer.compInfo={compID:a.compInfo.compID,originalCompID:a.compInfo.originalCompID}),a.filterFX&&(t.placedLayer.filter=ne(a.filterFX,e)),(0,i.skipBytes)(e,n())},(e,t)=>{(0,a.writeSignature)(e,`soLD`),(0,a.writeInt32)(e,4);let n=t.placedLayer;if(!n.id||typeof n.id!=`string`||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(n.id))throw Error(`Placed layer ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)`);let r=Object.assign(Object.assign({Idnt:n.id,placed:n.placed??n.id,PgNm:n.pageNumber||1,totalPages:n.totalPages||1},n.crop?{Crop:n.crop}:{}),{frameStep:n.frameStep||{numerator:0,denominator:600},duration:n.duration||{numerator:0,denominator:600},frameCount:n.frameCount||0,Annt:16,Type:S.indexOf(n.type),Trnf:n.transform,nonAffineTransform:n.nonAffineTransform??n.transform,warp:A(ie(n)),"Sz ":{_name:``,_classID:`Pnt `,Wdth:n.width||0,Hght:n.height||0},Rslt:n.resolution?(0,o.unitsValue)(n.resolution,`resolution`):{units:`Density`,value:72}});if(n.filter&&(r.filterFX={_name:``,_classID:`filterFXStyle`,enab:n.filter.enabled,validAtPosition:n.filter.validAtPosition,filterMaskEnable:n.filter.maskEnabled,filterMaskLinked:n.filter.maskLinked,filterMaskExtendWithWhite:n.filter.maskExtendWithWhite,filterFXList:n.filter.list.map(e=>re(e))}),n.warp&&k(n.warp)){let e=A(n.warp);r.quiltWarp=e,r.warp={warpStyle:`warpStyle.warpNone`,warpValue:e.warpValue,warpPerspective:e.warpPerspective,warpPerspectiveOther:e.warpPerspectiveOther,warpRotate:e.warpRotate,bounds:e.bounds,uOrder:e.uOrder,vOrder:e.vOrder}}else delete r.quiltWarp;n.comp&&(r.comp=n.comp),n.compInfo&&(r.compInfo=n.compInfo),(0,o.writeVersionAndDescriptor)(e,``,`null`,r,r.quiltWarp?`quiltWarp`:`warp`)}),f(`SoLE`,`SoLd`),d(`fxrp`,p(`referencePoint`),(e,t)=>{t.referencePoint={x:(0,i.readFloat64)(e),y:(0,i.readFloat64)(e)}},(e,t)=>{(0,a.writeFloat64)(e,t.referencePoint.x),(0,a.writeFloat64)(e,t.referencePoint.y)}),d(`Lr16`,()=>!1,(e,t,n,r,a)=>{(0,i.readLayerInfo)(e,r,a)},(e,t)=>{}),d(`Lr32`,()=>!1,(e,t,n,r,a)=>{(0,i.readLayerInfo)(e,r,a)},(e,t)=>{}),d(`LMsk`,p(`userMask`),(e,t)=>{if(t.userMask={colorSpace:(0,i.readColor)(e),opacity:(0,i.readUint16)(e)/255},(0,i.readUint8)(e)!==128)throw Error(`Invalid flag value`);(0,i.skipBytes)(e,1)},(e,t)=>{let n=t.userMask;(0,a.writeColor)(e,n.colorSpace),(0,a.writeUint16)(e,(0,r.clamp)(n.opacity,0,1)*255),(0,a.writeUint8)(e,128),(0,a.writeZeros)(e,1)}),r.MOCK_HANDLERS?d(`Patt`,e=>e._Patt!==void 0,(e,t,n)=>{t._Patt=(0,i.readBytes)(e,n())},(e,t)=>!1):d(`Patt`,e=>!!(e.patterns&&e.patterns.length>0),(e,t,n)=>{for(;n()>0;){let n=(0,i.readPattern)(e);t.patterns===void 0&&(t.patterns=[]),t.patterns.push(n)}},(e,t,n,r)=>{let i=t.patterns||[];for(let t of i)(0,a.writePattern)(e,t)}),f(`Pat2`,`Patt`),f(`Pat3`,`Patt`),r.MOCK_HANDLERS&&d(`CAI `,e=>e._CAI_!==void 0,(e,t,n)=>{t._CAI_=(0,i.readBytes)(e,n())},(e,t)=>{(0,a.writeBytes)(e,t._CAI_)}),r.MOCK_HANDLERS&&d(`OCIO`,e=>e._OCIO!==void 0,(e,t,n)=>{t._OCIO=(0,i.readBytes)(e,n())},(e,t)=>{(0,a.writeBytes)(e,t._OCIO)}),r.MOCK_HANDLERS&&d(`GenI`,e=>e._GenI!==void 0,(e,t,n)=>{t._GenI=(0,i.readBytes)(e,n())},(e,t)=>{(0,a.writeBytes)(e,t._GenI)});function ae(e){return{top:(0,i.readInt32)(e),left:(0,i.readInt32)(e),bottom:(0,i.readInt32)(e),right:(0,i.readInt32)(e)}}function oe(e,t){(0,a.writeInt32)(e,t.top),(0,a.writeInt32)(e,t.left),(0,a.writeInt32)(e,t.bottom),(0,a.writeInt32)(e,t.right)}d(`Anno`,e=>e.annotations!==void 0,(e,t,n)=>{let r=(0,i.readUint16)(e),a=(0,i.readUint16)(e);if(r!==2||a!==1)throw Error(`Invalid Anno version`);let o=(0,i.readUint32)(e),s=[];for(let t=0;t<o;t++){(0,i.readUint32)(e);let t=(0,i.readSignature)(e),n=!!(0,i.readUint8)(e);(0,i.readUint8)(e),(0,i.readUint16)(e);let r=ae(e),a=ae(e),o=(0,i.readColor)(e),c=(0,i.readPascalString)(e,2),l=(0,i.readPascalString)(e,2),u=(0,i.readPascalString)(e,2);(0,i.readUint32)(e),(0,i.readSignature)(e);let d=(0,i.readUint32)(e),f;if(t===`txtA`)d>=2&&(0,i.readUint16)(e)===65279?f=(0,i.readUnicodeStringWithLength)(e,(d-2)/2):(e.offset-=2,f=(0,i.readAsciiString)(e,d)),f=f.replace(/\r/g,`
|
|
11
|
+
`);else if(t===`sndA`)f=(0,i.readBytes)(e,d);else throw Error(`Unknown annotation type`);s.push({type:t===`txtA`?`text`:`sound`,open:n,iconLocation:r,popupLocation:a,color:o,author:c,name:l,date:u,data:f})}t.annotations=s,(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.annotations;(0,a.writeUint16)(e,2),(0,a.writeUint16)(e,1),(0,a.writeUint32)(e,n.length);for(let t of n){let n=t.type===`sound`;if(n&&!(t.data instanceof Uint8Array))throw Error(`Sound annotation data should be Uint8Array`);if(!n&&typeof t.data!=`string`)throw Error(`Text annotation data should be string`);let r=e.offset;(0,a.writeUint32)(e,0),(0,a.writeSignature)(e,n?`sndA`:`txtA`),(0,a.writeUint8)(e,+!!t.open),(0,a.writeUint8)(e,28),(0,a.writeUint16)(e,1),oe(e,t.iconLocation),oe(e,t.popupLocation),(0,a.writeColor)(e,t.color),(0,a.writePascalString)(e,t.author||``,2),(0,a.writePascalString)(e,t.name||``,2),(0,a.writePascalString)(e,t.date||``,2);let i=e.offset;(0,a.writeUint32)(e,0),(0,a.writeSignature)(e,n?`sndM`:`txtC`),(0,a.writeUint32)(e,0);let o=e.offset;if(n)(0,a.writeBytes)(e,t.data);else{(0,a.writeUint16)(e,65279);let n=t.data.replace(/\n/g,`\r`);for(let t=0;t<n.length;t++)(0,a.writeUint16)(e,n.charCodeAt(t))}e.view.setUint32(r,e.offset-r,!1),e.view.setUint32(i,e.offset-i,!1),e.view.setUint32(o-4,e.offset-o,!1)}});function B(e){d(e,t=>{let n=t;return!(!n.linkedFiles||!n.linkedFiles.length||e===`lnkE`&&!n.linkedFiles.some(e=>e.linkedFile))},(t,n,r,a)=>{let s=n;for(s.linkedFiles=s.linkedFiles||[];r()>8;){let n=m(t),r=t.offset,a=(0,i.readSignature)(t),c=(0,i.readInt32)(t),l=(0,i.readPascalString)(t,1),u=(0,i.readUnicodeString)(t),d=(0,i.readSignature)(t).trim(),f=(0,i.readSignature)(t).trim(),p=m(t),h=(0,i.readUint8)(t)?(0,o.readVersionAndDescriptor)(t):void 0,g=a===`liFE`?(0,o.readVersionAndDescriptor)(t):void 0,_={id:l,name:u};if(d&&(_.type=d),f&&(_.creator=f),h&&(_.descriptor={compInfo:{compID:h.compInfo.compID,originalCompID:h.compInfo.originalCompID}}),a===`liFE`&&c>3){let e=(0,i.readInt32)(t),n=(0,i.readUint8)(t),r=(0,i.readUint8)(t),a=(0,i.readUint8)(t),o=(0,i.readUint8)(t),s=(0,i.readFloat64)(t),c=Math.floor(s),l=(s-c)*1e3;_.time=new Date(Date.UTC(e,n,r,a,o,c,l)).toISOString()}let v=a===`liFE`?m(t):0;for(a===`liFA`&&(0,i.skipBytes)(t,8),a===`liFD`&&(_.data=(0,i.readBytes)(t,p)),c>=5&&(_.childDocumentID=(0,i.readUnicodeString)(t)),c>=6&&(_.assetModTime=(0,i.readFloat64)(t)),c>=7&&(_.assetLockedState=(0,i.readUint8)(t)),a===`liFE`&&c===2&&(_.data=(0,i.readBytes)(t,v)),t.skipLinkedFilesData&&(_.data=void 0),e===`lnkE`&&(_.linkedFile={fileSize:v,name:g?.[`Nm `]||``,fullPath:g?.fullPath||``,originalPath:g?.originalPath||``,relativePath:g?.relPath||``}),s.linkedFiles.push(_);n%4;)n++;t.offset=r+n}(0,i.skipBytes)(t,r())},(t,n)=>{let r=n;for(let n of r.linkedFiles){if(e===`lnkE`!=!!n.linkedFile)continue;let r=2;n.assetLockedState==null?n.assetModTime==null?n.childDocumentID==null?e===`lnkE`&&(r=3):r=5:r=6:r=7,h(t,0);let i=t.offset;if((0,a.writeSignature)(t,e===`lnkE`?`liFE`:n.data?`liFD`:`liFA`),(0,a.writeInt32)(t,r),!n.id||typeof n.id!=`string`||!/^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/.test(n.id))throw Error(`Linked file ID must be in a GUID format (example: 20953ddb-9391-11ec-b4f1-c15674f50bc4)`);if((0,a.writePascalString)(t,n.id,1),(0,a.writeUnicodeStringWithPadding)(t,n.name||``),(0,a.writeSignature)(t,n.type?`${n.type} `.substring(0,4):` `),(0,a.writeSignature)(t,n.creator?`${n.creator} `.substring(0,4):`\0\0\0\0`),h(t,n.data?n.data.byteLength:0),n.descriptor&&n.descriptor.compInfo){let e={compInfo:{compID:n.descriptor.compInfo.compID,originalCompID:n.descriptor.compInfo.originalCompID}};(0,a.writeUint8)(t,1),(0,o.writeVersionAndDescriptor)(t,``,`null`,e)}else(0,a.writeUint8)(t,0);if(e===`lnkE`){let e={descVersion:2,"Nm ":n.linkedFile?.name??``,fullPath:n.linkedFile?.fullPath??``,originalPath:n.linkedFile?.originalPath??``,relPath:n.linkedFile?.relativePath??``};(0,o.writeVersionAndDescriptor)(t,``,`ExternalFileLink`,e);let r=n.time?new Date(n.time):new Date;(0,a.writeInt32)(t,r.getUTCFullYear()),(0,a.writeUint8)(t,r.getUTCMonth()),(0,a.writeUint8)(t,r.getUTCDate()),(0,a.writeUint8)(t,r.getUTCHours()),(0,a.writeUint8)(t,r.getUTCMinutes()),(0,a.writeFloat64)(t,r.getUTCSeconds()+r.getUTCMilliseconds()/1e3)}n.data?(0,a.writeBytes)(t,n.data):h(t,n.linkedFile?.fileSize||0),r>=5&&(0,a.writeUnicodeStringWithPadding)(t,n.childDocumentID||``),r>=6&&(0,a.writeFloat64)(t,n.assetModTime||0),r>=7&&(0,a.writeUint8)(t,n.assetLockedState||0);let s=t.offset-i;for(t.view.setUint32(i-4,s,!1);s%4;)s++,(0,a.writeUint8)(t,0)}})}B(`lnk2`),B(`lnkE`),f(`lnkD`,`lnk2`),f(`lnk3`,`lnk2`),d(`pths`,p(`pathList`),(e,t)=>{(0,o.readVersionAndDescriptor)(e,!0),t.pathList=[]},(e,t)=>{(0,o.writeVersionAndDescriptor)(e,``,`pathsDataClass`,{pathList:[]})}),d(`lyvr`,p(`version`),(e,t)=>t.version=(0,i.readUint32)(e),(e,t)=>(0,a.writeUint32)(e,t.version)),d(`lfxs`,()=>!1,(e,t,n)=>{if((0,i.readUint32)(e)!==0)throw Error(`Invalid lfxs version`);let r=(0,o.readVersionAndDescriptor)(e);t.effects=(0,o.parseEffects)(r,!!e.logMissingFeatures),(0,i.skipBytes)(e,n())},(e,t,n,r)=>{let i=(0,o.serializeEffects)(t.effects,!!r.logMissingFeatures,!0);(0,a.writeUint32)(e,0),(0,o.writeVersionAndDescriptor)(e,``,`null`,i)});function V(e){return t=>!!t.adjustment&&t.adjustment.type===e}d(`brit`,V(`brightness/contrast`),(e,t,n)=>{t.adjustment||={type:`brightness/contrast`,brightness:(0,i.readInt16)(e),contrast:(0,i.readInt16)(e),meanValue:(0,i.readInt16)(e),labColorOnly:!!(0,i.readUint8)(e),useLegacy:!0},(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,a.writeInt16)(e,n.brightness||0),(0,a.writeInt16)(e,n.contrast||0),(0,a.writeInt16)(e,n.meanValue??127),(0,a.writeUint8)(e,+!!n.labColorOnly),(0,a.writeZeros)(e,1)});function se(e){return{shadowInput:(0,i.readInt16)(e),highlightInput:(0,i.readInt16)(e),shadowOutput:(0,i.readInt16)(e),highlightOutput:(0,i.readInt16)(e),midtoneInput:(0,i.readInt16)(e)/100}}function H(e,t){(0,a.writeInt16)(e,t.shadowInput),(0,a.writeInt16)(e,t.highlightInput),(0,a.writeInt16)(e,t.shadowOutput),(0,a.writeInt16)(e,t.highlightOutput),(0,a.writeInt16)(e,Math.round(t.midtoneInput*100))}d(`levl`,V(`levels`),(e,t,n)=>{if((0,i.readUint16)(e)!==2)throw Error(`Invalid levl version`);t.adjustment=Object.assign(Object.assign({},t.adjustment),{type:`levels`,rgb:se(e),red:se(e),green:se(e),blue:se(e)}),(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,r={shadowInput:0,highlightInput:255,shadowOutput:0,highlightOutput:255,midtoneInput:1};(0,a.writeUint16)(e,2),H(e,n.rgb||r),H(e,n.red||r),H(e,n.green||r),H(e,n.blue||r);for(let t=0;t<59;t++)H(e,r)});function U(e){let t=(0,i.readUint16)(e),n=[];for(let r=0;r<t;r++){let t=(0,i.readInt16)(e),r=(0,i.readInt16)(e);n.push({input:r,output:t})}return n}function ce(e,t){(0,a.writeUint16)(e,t.length);for(let n of t)(0,a.writeUint16)(e,n.output),(0,a.writeUint16)(e,n.input)}d(`curv`,V(`curves`),(e,t,n)=>{if((0,i.readUint8)(e),(0,i.readUint16)(e)!==1)throw Error(`Invalid curv version`);(0,i.readUint16)(e);let r=(0,i.readUint16)(e),a={type:`curves`};r&1&&(a.rgb=U(e)),r&2&&(a.red=U(e)),r&4&&(a.green=U(e)),r&8&&(a.blue=U(e)),t.adjustment=Object.assign(Object.assign({},t.adjustment),a),(0,i.skipBytes)(e,n())},(e,t)=>{let{rgb:n,red:r,green:i,blue:o}=t.adjustment,s=0,c=0;n&&n.length&&(s|=1,c++),r&&r.length&&(s|=2,c++),i&&i.length&&(s|=4,c++),o&&o.length&&(s|=8,c++),(0,a.writeUint8)(e,0),(0,a.writeUint16)(e,1),(0,a.writeUint16)(e,0),(0,a.writeUint16)(e,s),n&&n.length&&ce(e,n),r&&r.length&&ce(e,r),i&&i.length&&ce(e,i),o&&o.length&&ce(e,o),(0,a.writeSignature)(e,`Crv `),(0,a.writeUint16)(e,4),(0,a.writeUint16)(e,0),(0,a.writeUint16)(e,c),n&&n.length&&((0,a.writeUint16)(e,0),ce(e,n)),r&&r.length&&((0,a.writeUint16)(e,1),ce(e,r)),i&&i.length&&((0,a.writeUint16)(e,2),ce(e,i)),o&&o.length&&((0,a.writeUint16)(e,3),ce(e,o))}),d(`expA`,V(`exposure`),(e,t,n)=>{if((0,i.readUint16)(e)!==1)throw Error(`Invalid expA version`);t.adjustment=Object.assign(Object.assign({},t.adjustment),{type:`exposure`,exposure:(0,i.readFloat32)(e),offset:(0,i.readFloat32)(e),gamma:(0,i.readFloat32)(e)}),(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,a.writeUint16)(e,1),(0,a.writeFloat32)(e,n.exposure),(0,a.writeFloat32)(e,n.offset),(0,a.writeFloat32)(e,n.gamma),(0,a.writeZeros)(e,2)}),d(`vibA`,V(`vibrance`),(e,t,n)=>{let r=(0,o.readVersionAndDescriptor)(e);t.adjustment={type:`vibrance`},r.vibrance!==void 0&&(t.adjustment.vibrance=r.vibrance),r.Strt!==void 0&&(t.adjustment.saturation=r.Strt),(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,r={};n.vibrance!==void 0&&(r.vibrance=n.vibrance),n.saturation!==void 0&&(r.Strt=n.saturation),(0,o.writeVersionAndDescriptor)(e,``,`null`,r)});function le(e){return{a:(0,i.readInt16)(e),b:(0,i.readInt16)(e),c:(0,i.readInt16)(e),d:(0,i.readInt16)(e),hue:(0,i.readInt16)(e),saturation:(0,i.readInt16)(e),lightness:(0,i.readInt16)(e)}}function ue(e,t){let n=t||{};(0,a.writeInt16)(e,n.a||0),(0,a.writeInt16)(e,n.b||0),(0,a.writeInt16)(e,n.c||0),(0,a.writeInt16)(e,n.d||0),(0,a.writeInt16)(e,n.hue||0),(0,a.writeInt16)(e,n.saturation||0),(0,a.writeInt16)(e,n.lightness||0)}d(`hue2`,V(`hue/saturation`),(e,t,n)=>{if((0,i.readUint16)(e)!==2)throw Error(`Invalid hue2 version`);t.adjustment=Object.assign(Object.assign({},t.adjustment),{type:`hue/saturation`,master:le(e),reds:le(e),yellows:le(e),greens:le(e),cyans:le(e),blues:le(e),magentas:le(e)}),(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,a.writeUint16)(e,2),ue(e,n.master),ue(e,n.reds),ue(e,n.yellows),ue(e,n.greens),ue(e,n.cyans),ue(e,n.blues),ue(e,n.magentas)});function W(e){return{cyanRed:(0,i.readInt16)(e),magentaGreen:(0,i.readInt16)(e),yellowBlue:(0,i.readInt16)(e)}}function de(e,t){(0,a.writeInt16)(e,t.cyanRed||0),(0,a.writeInt16)(e,t.magentaGreen||0),(0,a.writeInt16)(e,t.yellowBlue||0)}d(`blnc`,V(`color balance`),(e,t,n)=>{t.adjustment={type:`color balance`,shadows:W(e),midtones:W(e),highlights:W(e),preserveLuminosity:!!(0,i.readUint8)(e)},(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;de(e,n.shadows||{}),de(e,n.midtones||{}),de(e,n.highlights||{}),(0,a.writeUint8)(e,+!!n.preserveLuminosity),(0,a.writeZeros)(e,1)}),d(`blwh`,V(`black & white`),(e,t,n)=>{let r=(0,o.readVersionAndDescriptor)(e);t.adjustment={type:`black & white`,reds:r[`Rd `],yellows:r.Yllw,greens:r[`Grn `],cyans:r[`Cyn `],blues:r[`Bl `],magentas:r.Mgnt,useTint:!!r.useTint,presetKind:r.bwPresetKind,presetFileName:r.blackAndWhitePresetFileName},r.tintColor!==void 0&&(t.adjustment.tintColor=(0,o.parseColor)(r.tintColor)),(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,r={"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,o.serializeColor)(n.tintColor),bwPresetKind:n.presetKind||0,blackAndWhitePresetFileName:n.presetFileName||``};(0,o.writeVersionAndDescriptor)(e,``,`null`,r)}),d(`phfl`,V(`photo filter`),(e,t,n)=>{let r=(0,i.readUint16)(e);if(r!==2&&r!==3)throw Error(`Invalid phfl version`);let a;a=r===2?(0,i.readColor)(e):{l:(0,i.readInt32)(e)/100,a:(0,i.readInt32)(e)/100,b:(0,i.readInt32)(e)/100},t.adjustment={type:`photo filter`,color:a,density:(0,i.readUint32)(e)/100,preserveLuminosity:!!(0,i.readUint8)(e)},(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,a.writeUint16)(e,2),(0,a.writeColor)(e,n.color||{l:0,a:0,b:0}),(0,a.writeUint32)(e,(n.density||0)*100),(0,a.writeUint8)(e,+!!n.preserveLuminosity),(0,a.writeZeros)(e,3)});function G(e){let t=(0,i.readInt16)(e),n=(0,i.readInt16)(e),r=(0,i.readInt16)(e);return(0,i.skipBytes)(e,2),{red:t,green:n,blue:r,constant:(0,i.readInt16)(e)}}function K(e,t){let n=t||{};(0,a.writeInt16)(e,n.red),(0,a.writeInt16)(e,n.green),(0,a.writeInt16)(e,n.blue),(0,a.writeZeros)(e,2),(0,a.writeInt16)(e,n.constant)}d(`mixr`,V(`channel mixer`),(e,t,n)=>{if((0,i.readUint16)(e)!==1)throw Error(`Invalid mixr version`);let r=t.adjustment=Object.assign(Object.assign({},t.adjustment),{type:`channel mixer`,monochrome:!!(0,i.readUint16)(e)});r.monochrome||(r.red=G(e),r.green=G(e),r.blue=G(e)),r.gray=G(e),(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,a.writeUint16)(e,1),(0,a.writeUint16)(e,+!!n.monochrome),n.monochrome?(K(e,n.gray),(0,a.writeZeros)(e,30)):(K(e,n.red),K(e,n.green),K(e,n.blue),K(e,n.gray))});let q=(0,r.createEnum)(`colorLookupType`,`3dlut`,{"3dlut":`3DLUT`,abstractProfile:`abstractProfile`,deviceLinkProfile:`deviceLinkProfile`}),J=(0,r.createEnum)(`LUTFormatType`,`look`,{look:`LUTFormatLOOK`,cube:`LUTFormatCUBE`,"3dl":`LUTFormat3DL`}),Y=(0,r.createEnum)(`colorLookupOrder`,`rgb`,{rgb:`rgbOrder`,bgr:`bgrOrder`});d(`clrL`,V(`color lookup`),(e,t,n)=>{if((0,i.readUint16)(e)!==1)throw Error(`Invalid clrL version`);let r=(0,o.readVersionAndDescriptor)(e);t.adjustment={type:`color lookup`};let a=t.adjustment;r.lookupType!==void 0&&(a.lookupType=q.decode(r.lookupType)),r[`Nm `]!==void 0&&(a.name=r[`Nm `]),r.Dthr!==void 0&&(a.dither=r.Dthr),r.profile!==void 0&&(a.profile=r.profile),r.LUTFormat!==void 0&&(a.lutFormat=J.decode(r.LUTFormat)),r.dataOrder!==void 0&&(a.dataOrder=Y.decode(r.dataOrder)),r.tableOrder!==void 0&&(a.tableOrder=Y.decode(r.tableOrder)),r.LUT3DFileData!==void 0&&(a.lut3DFileData=r.LUT3DFileData),r.LUT3DFileName!==void 0&&(a.lut3DFileName=r.LUT3DFileName),(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment,r={};n.lookupType!==void 0&&(r.lookupType=q.encode(n.lookupType)),n.name!==void 0&&(r[`Nm `]=n.name),n.dither!==void 0&&(r.Dthr=n.dither),n.profile!==void 0&&(r.profile=n.profile),n.lutFormat!==void 0&&(r.LUTFormat=J.encode(n.lutFormat)),n.dataOrder!==void 0&&(r.dataOrder=Y.encode(n.dataOrder)),n.tableOrder!==void 0&&(r.tableOrder=Y.encode(n.tableOrder)),n.lut3DFileData!==void 0&&(r.LUT3DFileData=n.lut3DFileData),n.lut3DFileName!==void 0&&(r.LUT3DFileName=n.lut3DFileName),(0,a.writeUint16)(e,1),(0,o.writeVersionAndDescriptor)(e,``,`null`,r)}),d(`nvrt`,V(`invert`),(e,t,n)=>{t.adjustment={type:`invert`},(0,i.skipBytes)(e,n())},()=>{}),d(`post`,V(`posterize`),(e,t,n)=>{t.adjustment={type:`posterize`,levels:(0,i.readUint16)(e)},(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,a.writeUint16)(e,n.levels??4),(0,a.writeZeros)(e,2)}),d(`thrs`,V(`threshold`),(e,t,n)=>{t.adjustment={type:`threshold`,level:(0,i.readUint16)(e)},(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;(0,a.writeUint16)(e,n.level??128),(0,a.writeZeros)(e,2)});let X=[``,``,``,`rgb`,`hsb`,``,`lab`];d(`grdm`,V(`gradient map`),(e,t,n)=>{let r=(0,i.readUint16)(e);if(r!==1&&r!==3)throw Error(`Invalid grdm version`);let a={type:`gradient map`,gradientType:`solid`};a.reverse=!!(0,i.readUint8)(e),a.dither=!!(0,i.readUint8)(e);let s=!!(0,i.readUint8)(e);if(e.offset--,s){let t=(0,i.readSignature)(e);a.method=o.gradientInterpolationMethodType.decode(t)}a.name=(0,i.readUnicodeString)(e),a.colorStops=[],a.opacityStops=[];let c=(0,i.readUint16)(e);for(let t=0;t<c;t++)a.colorStops.push({location:(0,i.readUint32)(e),midpoint:(0,i.readUint32)(e)/100,color:(0,i.readColor)(e)}),(0,i.skipBytes)(e,2);let l=(0,i.readUint16)(e);for(let t=0;t<l;t++)a.opacityStops.push({location:(0,i.readUint32)(e),midpoint:(0,i.readUint32)(e)/100,opacity:(0,i.readUint16)(e)/255});if((0,i.readUint16)(e)!==2)throw Error(`Invalid grdm expansion count`);let u=(0,i.readUint16)(e);if(a.smoothness=u/4096,(0,i.readUint16)(e)!==32)throw Error(`Invalid grdm length`);a.gradientType=(0,i.readUint16)(e)?`noise`:`solid`,a.randomSeed=(0,i.readUint32)(e),a.addTransparency=!!(0,i.readUint16)(e),a.restrictColors=!!(0,i.readUint16)(e),a.roughness=(0,i.readUint32)(e)/4096,a.colorModel=X[(0,i.readUint16)(e)]||`rgb`,a.min=[(0,i.readUint16)(e)/32768,(0,i.readUint16)(e)/32768,(0,i.readUint16)(e)/32768,(0,i.readUint16)(e)/32768],a.max=[(0,i.readUint16)(e)/32768,(0,i.readUint16)(e)/32768,(0,i.readUint16)(e)/32768,(0,i.readUint16)(e)/32768],(0,i.skipBytes)(e,n());for(let e of a.colorStops)e.location/=u;for(let e of a.opacityStops)e.location/=u;t.adjustment=a},(e,t)=>{let n=t.adjustment;(0,a.writeUint16)(e,n.method===void 0?1:3),(0,a.writeUint8)(e,+!!n.reverse),(0,a.writeUint8)(e,+!!n.dither),n.method!==void 0&&(0,a.writeSignature)(e,o.gradientInterpolationMethodType.encode(n.method)),(0,a.writeUnicodeStringWithPadding)(e,n.name||``),(0,a.writeUint16)(e,n.colorStops&&n.colorStops.length||0);let r=Math.round((n.smoothness??1)*4096);for(let t of n.colorStops||[])(0,a.writeUint32)(e,Math.round(t.location*r)),(0,a.writeUint32)(e,Math.round(t.midpoint*100)),(0,a.writeColor)(e,t.color),(0,a.writeZeros)(e,2);(0,a.writeUint16)(e,n.opacityStops&&n.opacityStops.length||0);for(let t of n.opacityStops||[])(0,a.writeUint32)(e,Math.round(t.location*r)),(0,a.writeUint32)(e,Math.round(t.midpoint*100)),(0,a.writeUint16)(e,Math.round(t.opacity*255));(0,a.writeUint16)(e,2),(0,a.writeUint16)(e,r),(0,a.writeUint16)(e,32),(0,a.writeUint16)(e,+(n.gradientType===`noise`)),(0,a.writeUint32)(e,n.randomSeed||0),(0,a.writeUint16)(e,+!!n.addTransparency),(0,a.writeUint16)(e,+!!n.restrictColors),(0,a.writeUint32)(e,Math.round((n.roughness??1)*4096));let i=X.indexOf(n.colorModel??`rgb`);(0,a.writeUint16)(e,i===-1?3:i);for(let t=0;t<4;t++)(0,a.writeUint16)(e,Math.round((n.min&&n.min[t]||0)*32768));for(let t=0;t<4;t++)(0,a.writeUint16)(e,Math.round((n.max&&n.max[t]||0)*32768));(0,a.writeZeros)(e,4)});function fe(e){return{c:(0,i.readInt16)(e),m:(0,i.readInt16)(e),y:(0,i.readInt16)(e),k:(0,i.readInt16)(e)}}function pe(e,t){let n=t||{};(0,a.writeInt16)(e,n.c),(0,a.writeInt16)(e,n.m),(0,a.writeInt16)(e,n.y),(0,a.writeInt16)(e,n.k)}d(`selc`,V(`selective color`),(e,t)=>{if((0,i.readUint16)(e)!==1)throw Error(`Invalid selc version`);let n=(0,i.readUint16)(e)?`absolute`:`relative`;(0,i.skipBytes)(e,8),t.adjustment={type:`selective color`,mode:n,reds:fe(e),yellows:fe(e),greens:fe(e),cyans:fe(e),blues:fe(e),magentas:fe(e),whites:fe(e),neutrals:fe(e),blacks:fe(e)}},(e,t)=>{let n=t.adjustment;(0,a.writeUint16)(e,1),(0,a.writeUint16)(e,+(n.mode===`absolute`)),(0,a.writeZeros)(e,8),pe(e,n.reds),pe(e,n.yellows),pe(e,n.greens),pe(e,n.cyans),pe(e,n.blues),pe(e,n.magentas),pe(e,n.whites),pe(e,n.neutrals),pe(e,n.blacks)}),d(`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 r=(0,o.readVersionAndDescriptor)(e);if(r.Vrsn!==1)throw Error(`Invalid CgEd version`);`presetFileName`in r?t.adjustment=Object.assign(Object.assign({},t.adjustment),{presetKind:r.presetKind,presetFileName:r.presetFileName}):`curvesPresetFileName`in r?t.adjustment=Object.assign(Object.assign({},t.adjustment),{presetKind:r.curvesPresetKind,presetFileName:r.curvesPresetFileName}):`mixerPresetFileName`in r?t.adjustment=Object.assign(Object.assign({},t.adjustment),{presetKind:r.mixerPresetKind,presetFileName:r.mixerPresetFileName}):t.adjustment={type:`brightness/contrast`,brightness:r.Brgh,contrast:r.Cntr,meanValue:r.means,useLegacy:!!r.useLegacy,labColorOnly:!!r[`Lab `],auto:!!r.Auto},(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.adjustment;if(n.type===`levels`||n.type===`exposure`||n.type===`hue/saturation`){let t={Vrsn:1,presetKind:n.presetKind??1,presetFileName:n.presetFileName||``};(0,o.writeVersionAndDescriptor)(e,``,`null`,t)}else if(n.type===`curves`){let t={Vrsn:1,curvesPresetKind:n.presetKind??1,curvesPresetFileName:n.presetFileName||``};(0,o.writeVersionAndDescriptor)(e,``,`null`,t)}else if(n.type===`channel mixer`){let t={Vrsn:1,mixerPresetKind:n.presetKind??1,mixerPresetFileName:n.presetFileName||``};(0,o.writeVersionAndDescriptor)(e,``,`null`,t)}else if(n.type===`brightness/contrast`){let t={Vrsn:1,Brgh:n.brightness||0,Cntr:n.contrast||0,means:n.meanValue??127,"Lab ":!!n.labColorOnly,useLegacy:!!n.useLegacy,Auto:!!n.auto};(0,o.writeVersionAndDescriptor)(e,``,`null`,t)}else throw Error(`Unhandled CgEd case`)});function me(e){let t=[];function n(e){if(e.children)for(let r of e.children)r.text?.index!==void 0&&(t[r.text.index]=r),n(r)}return n(e),t}d(`Txt2`,p(`engineData`),(e,n,r,a)=>{let o=(0,i.readBytes)(e,r());n.engineData=(0,t.fromByteArray)(o);let c=me(a),u=(0,s.parseEngineData)(o),d=(0,l.decodeEngineData2)(u).ResourceDict.TextFrameSet;if(d)for(let e=0;e<d.length;e++){let t=c[e];d[e].path&&t?.text&&(t.text.textPath=d[e].path)}},(e,n)=>{let r=(0,t.toByteArray)(n.engineData);(0,a.writeBytes)(e,r)}),d(`FEid`,p(`filterEffectsMasks`),(e,t,n)=>{let r=(0,i.readInt32)(e);if(r<1||r>3)throw Error(`Invalid filterEffects version ${r}`);for(t.filterEffectsMasks=[];n()>8;){if((0,i.readUint32)(e))throw Error(`filterEffects: 64 bit length is not supported`);let n=(0,i.readUint32)(e),r=e.offset+n,a=(0,i.readPascalString)(e,1),o=(0,i.readInt32)(e);if(o!==1)throw Error(`Invalid filterEffect version ${o}`);if((0,i.readUint32)(e))throw Error(`filterEffect: 64 bit length is not supported`);(0,i.readUint32)(e);let s=(0,i.readInt32)(e),c=(0,i.readInt32)(e),l=(0,i.readInt32)(e),u=(0,i.readInt32)(e),d=(0,i.readInt32)(e),f=(0,i.readInt32)(e),p=[];for(let t=0;t<f+2;t++)if((0,i.readInt32)(e)){if((0,i.readUint32)(e))throw Error(`filterEffect: 64 bit length is not supported`);let t=(0,i.readUint32)(e);if(!t)throw Error(`filterEffect: Empty channel`);let n=(0,i.readUint16)(e),r=(0,i.readBytes)(e,t-2);p.push({compressionMode:n,data:r})}else p.push(void 0);if(t.filterEffectsMasks.push({id:a,top:s,left:c,bottom:l,right:u,depth:d,channels:p}),e.offset<r&&(0,i.readUint8)(e)){let n=(0,i.readInt32)(e),r=(0,i.readInt32)(e),a=(0,i.readInt32)(e),o=(0,i.readInt32)(e);if((0,i.readUint32)(e))throw Error(`filterEffect: 64 bit length is not supported`);let s=(0,i.readUint32)(e),c=(0,i.readUint16)(e),l=(0,i.readBytes)(e,s-2);t.filterEffectsMasks[t.filterEffectsMasks.length-1].extra={top:n,left:r,bottom:a,right:o,compressionMode:c,data:l}}e.offset=r;let m=n;for(;m%4;)e.offset++,m++}},(e,t)=>{(0,a.writeInt32)(e,3);for(let n of t.filterEffectsMasks){(0,a.writeUint32)(e,0),(0,a.writeUint32)(e,0);let r=e.offset;(0,a.writePascalString)(e,n.id,1),(0,a.writeInt32)(e,1),(0,a.writeUint32)(e,0),(0,a.writeUint32)(e,0);let i=e.offset;(0,a.writeInt32)(e,n.top),(0,a.writeInt32)(e,n.left),(0,a.writeInt32)(e,n.bottom),(0,a.writeInt32)(e,n.right),(0,a.writeInt32)(e,n.depth);let o=Math.max(0,n.channels.length-2);(0,a.writeInt32)(e,o);for(let t=0;t<o+2;t++){let r=n.channels[t];(0,a.writeInt32)(e,+!!r),r&&((0,a.writeUint32)(e,0),(0,a.writeUint32)(e,r.data.length+2),(0,a.writeUint16)(e,r.compressionMode),(0,a.writeBytes)(e,r.data))}e.view.setUint32(i-4,e.offset-i,!1);let s=t.filterEffectsMasks[t.filterEffectsMasks.length-1]?.extra;s&&((0,a.writeUint8)(e,1),(0,a.writeInt32)(e,s.top),(0,a.writeInt32)(e,s.left),(0,a.writeInt32)(e,s.bottom),(0,a.writeInt32)(e,s.right),(0,a.writeUint32)(e,0),(0,a.writeUint32)(e,s.data.byteLength+2),(0,a.writeUint16)(e,s.compressionMode),(0,a.writeBytes)(e,s.data));let c=e.offset-r;for(e.view.setUint32(r-4,c,!1);c%4;)(0,a.writeZeros)(e,1),c++}}),f(`FXid`,`FEid`),d(`FMsk`,p(`filterMask`),(e,t)=>{t.filterMask={colorSpace:(0,i.readColor)(e),opacity:(0,i.readUint16)(e)/255}},(e,t)=>{(0,a.writeColor)(e,t.filterMask.colorSpace),(0,a.writeUint16)(e,(0,r.clamp)(t.filterMask.opacity??1,0,1)*255)}),d(`artd`,e=>e.artboards!==void 0,(e,t,n)=>{let r=(0,o.readVersionAndDescriptor)(e);t.artboards={count:r[`Cnt `],autoExpandOffset:{horizontal:r.autoExpandOffset.Hrzn,vertical:r.autoExpandOffset.Vrtc},origin:{horizontal:r.origin.Hrzn,vertical:r.origin.Vrtc},autoExpandEnabled:r.autoExpandEnabled,autoNestEnabled:r.autoNestEnabled,autoPositionEnabled:r.autoPositionEnabled,shrinkwrapOnSaveEnabled:!!r.shrinkwrapOnSaveEnabled,docDefaultNewArtboardBackgroundColor:(0,o.parseColor)(r.docDefaultNewArtboardBackgroundColor),docDefaultNewArtboardBackgroundType:r.docDefaultNewArtboardBackgroundType},(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.artboards,r={"Cnt ":n.count,autoExpandOffset:n.autoExpandOffset?{Hrzn:n.autoExpandOffset.horizontal,Vrtc:n.autoExpandOffset.vertical}:{Hrzn:0,Vrtc:0},origin:n.origin?{Hrzn:n.origin.horizontal,Vrtc:n.origin.vertical}:{Hrzn:0,Vrtc:0},autoExpandEnabled:n.autoExpandEnabled??!0,autoNestEnabled:n.autoNestEnabled??!0,autoPositionEnabled:n.autoPositionEnabled??!0,shrinkwrapOnSaveEnabled:n.shrinkwrapOnSaveEnabled??!0,docDefaultNewArtboardBackgroundColor:(0,o.serializeColor)(n.docDefaultNewArtboardBackgroundColor),docDefaultNewArtboardBackgroundType:n.docDefaultNewArtboardBackgroundType??1};(0,o.writeVersionAndDescriptor)(e,``,`null`,r,`artd`)});function Z(e){return Object.keys(e).map(t=>e[t]).some(e=>Array.isArray(e)&&e.length>1)}d(`lfx2`,e=>e.effects!==void 0&&!Z(e.effects),(e,t,n)=>{if((0,i.readUint32)(e)!==0)throw Error(`Invalid lfx2 version`);let r=(0,o.readVersionAndDescriptor)(e);t.effects=(0,o.parseEffects)(r,!!e.logMissingFeatures),(0,i.skipBytes)(e,n())},(e,t,n,r)=>{let i=(0,o.serializeEffects)(t.effects,!!r.logMissingFeatures,!0);(0,a.writeUint32)(e,0),(0,o.writeVersionAndDescriptor)(e,``,`null`,i)}),d(`cinf`,p(`compositorUsed`),(e,t,n)=>{let r=(0,o.readVersionAndDescriptor)(e);function a(e){return e.split(`.`)[1]}t.compositorUsed={description:r.description,reason:r.reason,engine:a(r.Engn)},r.Vrsn&&(t.compositorUsed.version=r.Vrsn),r.psVersion&&(t.compositorUsed.photoshopVersion=r.psVersion),r.enableCompCore&&(t.compositorUsed.enableCompCore=a(r.enableCompCore)),r.enableCompCoreGPU&&(t.compositorUsed.enableCompCoreGPU=a(r.enableCompCoreGPU)),r.enableCompCoreThreads&&(t.compositorUsed.enableCompCoreThreads=a(r.enableCompCoreThreads)),r.compCoreSupport&&(t.compositorUsed.compCoreSupport=a(r.compCoreSupport)),r.compCoreGPUSupport&&(t.compositorUsed.compCoreGPUSupport=a(r.compCoreGPUSupport)),(0,i.skipBytes)(e,n())},(e,t)=>{let n=t.compositorUsed,r={Vrsn:n.version||{major:1,minor:0,fix:0}};n.photoshopVersion&&(r.psVersion=n.photoshopVersion),r.description=n.description,r.reason=n.reason,r.Engn=`Engn.${n.engine}`,n.enableCompCore&&(r.enableCompCore=`enable.${n.enableCompCore}`),n.enableCompCoreGPU&&(r.enableCompCoreGPU=`enable.${n.enableCompCoreGPU}`),n.enableCompCoreThreads&&(r.enableCompCoreThreads=`enable.${n.enableCompCoreThreads}`),n.compCoreSupport&&(r.compCoreSupport=`reason.${n.compCoreSupport}`),n.compCoreGPUSupport&&(r.compCoreGPUSupport=`reason.${n.compCoreGPUSupport}`),(0,o.writeVersionAndDescriptor)(e,``,`null`,r)}),d(`extn`,e=>e._extn!==void 0,(e,t)=>{let n=(0,o.readVersionAndDescriptor)(e);r.MOCK_HANDLERS&&(t._extn=n)},(e,t)=>{r.MOCK_HANDLERS&&(0,o.writeVersionAndDescriptor)(e,``,`null`,t._extn)}),d(`iOpa`,p(`fillOpacity`),(e,t)=>{t.fillOpacity=(0,i.readUint8)(e)/255,(0,i.skipBytes)(e,3)},(e,t)=>{(0,a.writeUint8)(e,t.fillOpacity*255),(0,a.writeZeros)(e,3)}),d(`brst`,p(`channelBlendingRestrictions`),(e,t,n)=>{for(t.channelBlendingRestrictions=[];n()>4;)t.channelBlendingRestrictions.push((0,i.readInt32)(e))},(e,t)=>{for(let n of t.channelBlendingRestrictions)(0,a.writeInt32)(e,n)}),d(`tsly`,p(`transparencyShapesLayer`),(e,t)=>{t.transparencyShapesLayer=!!(0,i.readUint8)(e),(0,i.skipBytes)(e,3)},(e,t)=>{(0,a.writeUint8)(e,+!!t.transparencyShapesLayer),(0,a.writeZeros)(e,3)})})),O=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createWriter=i,e.getWriterBuffer=a,e.getWriterBufferNoCopy=o,e.writeUint8=s,e.writeInt16=c,e.writeUint16=l,e.writeUint16LE=u,e.writeInt32=d,e.writeInt32LE=f,e.writeUint32=p,e.writeFloat32=m,e.writeFloat64=h,e.writeFixedPoint32=g,e.writeFixedPointPath32=_,e.writeBytes=y,e.writeZeros=b,e.writeSignature=x,e.writeAsciiString=C,e.writePascalString=w,e.writeUnicodeStringWithoutLength=T,e.writeUnicodeStringWithoutLengthLE=E,e.writeUnicodeString=D,e.writeUnicodeStringWithPadding=O,e.writeSection=A,e.writePsd=M,e.writeColor=ue,e.writePattern=W;let t=v(),n=ee(),r=S();function i(e=4096){let t=new ArrayBuffer(e);return{buffer:t,view:new DataView(t),offset:0,tempBuffer:void 0}}function a(e){return e.buffer.slice(0,e.offset)}function o(e){return new Uint8Array(e.buffer,0,e.offset)}function s(e,t){let n=re(e,1);e.view.setUint8(n,t)}function c(e,t){let n=re(e,2);e.view.setInt16(n,t,!1)}function l(e,t){let n=re(e,2);e.view.setUint16(n,t,!1)}function u(e,t){let n=re(e,2);e.view.setUint16(n,t,!0)}function d(e,t){let n=re(e,4);e.view.setInt32(n,t,!1)}function f(e,t){let n=re(e,4);e.view.setInt32(n,t,!0)}function p(e,t){let n=re(e,4);e.view.setUint32(n,t,!1)}function m(e,t){let n=re(e,4);e.view.setFloat32(n,t,!1)}function h(e,t){let n=re(e,8);e.view.setFloat64(n,t,!1)}function g(e,t){d(e,t*65536)}function _(e,t){d(e,t*(1<<24))}function y(e,t){t&&(z(e,e.offset+t.length),new Uint8Array(e.buffer).set(t,e.offset),e.offset+=t.length)}function b(e,t){for(let n=0;n<t;n++)s(e,0)}function x(e,t){if(t.length!==4)throw Error(`Invalid signature: '${t}'`);for(let n=0;n<4;n++)s(e,t.charCodeAt(n))}function C(e,t){for(let n=0;n<t.length;n++)s(e,t.charCodeAt(n))}function w(e,t,n){let r=t.length;if(r>255)throw Error(`String too long`);s(e,r);for(let n=0;n<r;n++){let r=t.charCodeAt(n);s(e,r<128?r:63)}for(;++r%n;)s(e,0)}function T(e,t){for(let n=0;n<t.length;n++)l(e,t.charCodeAt(n))}function E(e,t){for(let n=0;n<t.length;n++)u(e,t.charCodeAt(n))}function D(e,t){p(e,t.length),T(e,t)}function O(e,t){p(e,t.length+1);for(let n=0;n<t.length;n++)l(e,t.charCodeAt(n));l(e,0)}function k(e=[]){let t=0;for(let n of e){let{width:e,height:r}=V(n);if(t=Math.max(t,2*r+2*e*r),n.mask){let{width:e,height:r}=V(n.mask);t=Math.max(t,2*r+2*e*r)}if(n.realMask){let{width:e,height:r}=V(n.realMask);t=Math.max(t,2*r+2*e*r)}n.children&&(t=Math.max(t,k(n.children)))}return t}function A(e,t,n,r=!1,i=!1){i&&p(e,0);let a=e.offset;p(e,0),n();let o=e.offset-a-4,c=o;for(;c%t;)s(e,0),c++;r&&(o=c),e.view.setUint32(a,o,!1)}function j(e){var t;(t=e.children)==null||t.forEach(j);let n=e.imageData;if(n&&(n.data instanceof Uint32Array||n.data instanceof Uint16Array))throw Error(`imageData has incorrect bitDepth`);if(`mask`in e&&e.mask){let t=e.mask.imageData;if(t&&(t.data instanceof Uint32Array||t.data instanceof Uint16Array))throw Error(`mask imageData has incorrect bitDepth`)}}function M(e,n,i={}){if(!(+n.width>0&&+n.height>0))throw Error(`Invalid document size`);if((n.width>3e4||n.height>3e4)&&!i.psb)throw Error(`Document size is too large (max is 30000x30000, use PSB format instead)`);let a=n.bitsPerChannel??8;if(a!==8)throw Error(`bitsPerChannel other than 8 are not supported for writing`);j(n);let o=Object.assign({},n.imageResources),c=Object.assign(Object.assign({},i),{layerIds:new Set,layerToId:new Map});c.generateThumbnail&&(o.thumbnail=ie(n));let u=n.imageData;if(!u&&n.canvas&&(u=n.canvas.getContext(`2d`).getImageData(0,0,n.canvas.width,n.canvas.height)),u&&(n.width!==u.width||n.height!==u.height))throw Error(`Document canvas must have the same size as document`);let d=!!u&&(0,t.hasAlpha)(u),f=Math.max(k(n.children),8*n.width*n.height+2*n.height);e.tempBuffer=new Uint8Array(f),x(e,`8BPS`),l(e,i.psb?2:1),b(e,6),l(e,d?4:3),p(e,n.height),p(e,n.width),l(e,a),l(e,3),A(e,1,()=>{if(n.palette){for(let t=0;t<256;t++)s(e,n.palette[t]?.r||0);for(let t=0;t<256;t++)s(e,n.palette[t]?.g||0);for(let t=0;t<256;t++)s(e,n.palette[t]?.b||0)}});let m=[];R(m,n.children),m.length||m.push({}),o.layersGroup=m.map(e=>e.linkGroup||0),o.layerGroupsEnabledId=m.map(e=>e.linkGroupEnabled==0?0:1),A(e,1,()=>{for(let t of r.resourceHandlers){let n=t.has(o),r=n===!1?0:n===!0?1:n;for(let n=0;n<r;n++)x(e,`8BIM`),l(e,t.key),w(e,``,2),A(e,2,()=>t.write(e,o,n))}}),A(e,2,()=>{N(e,m,n,d,c),I(e,n.globalLayerMaskInfo),L(e,n,n,c)},void 0,!!c.psb);let h=d?[0,1,2,3]:[0,1,2],g=u?u.width:n.width,_=u?u.height:n.height,v={data:new Uint8Array(g*_*4),width:g,height:_};if(l(e,1),t.RAW_IMAGE_DATA&&n.imageDataRaw)console.log(`writing raw image data`),y(e,n.imageDataRaw);else{if(u&&v.data.set(new Uint8Array(u.data.buffer,u.data.byteOffset,u.data.byteLength)),d){let e=v.width*v.height*4,t=v.data;for(let n=0;n<e;n+=4){let e=t[n+3];if(e!=0&&e!=255){let r=e/255,i=255*(1-r);t[n+0]=t[n+0]*r+i,t[n+1]=t[n+1]*r+i,t[n+2]=t[n+2]*r+i}}}y(e,(0,t.writeDataRLE)(e.tempBuffer,v,h,!!i.psb))}}function N(e,n,r,i,a){A(e,4,()=>{c(e,i?-n.length:n.length);let o=n.map((t,n)=>B(e.tempBuffer,t,n===0,a));for(let n of o){let{layer:i,top:o,left:u,bottom:f,right:m,channels:h}=n;d(e,o),d(e,u),d(e,f),d(e,m),l(e,h.length);for(let t of h)c(e,t.id),a.psb&&p(e,0),p(e,t.length);x(e,`8BIM`),x(e,t.fromBlendMode[i.blendMode]||`norm`),s(e,Math.round((0,t.clamp)(i.opacity??1,0,1)*255)),s(e,+!!i.clipping);let g=8;i.transparencyProtected&&(g|=1),i.hidden&&(g|=2),(i.vectorMask||i.sectionDivider&&i.sectionDivider.type!==0||i.adjustment)&&(g|=16),i.effectsOpen&&(g|=32),s(e,g),s(e,0),A(e,1,()=>{P(e,i,n),te(e,i),w(e,(i.name||``).substring(0,255),4),L(e,i,r,a)})}for(let t of o)for(let n of t.channels)l(e,n.compression),n.data&&y(e,n.data)},!0,a.psb)}function P(e,{mask:t,realMask:n},r){A(e,1,()=>{if(!t&&!n)return;let i=0,a=0,o=0;t&&(t.userMaskDensity!==void 0&&(i|=1),t.userMaskFeather!==void 0&&(i|=2),t.vectorMaskDensity!==void 0&&(i|=4),t.vectorMaskFeather!==void 0&&(i|=8),t.disabled&&(a|=2),t.positionRelativeToLayer&&(a|=1),t.fromVectorData&&(a|=8),i&&(a|=16));let c=r.mask||{};if(d(e,c.top||0),d(e,c.left||0),d(e,c.bottom||0),d(e,c.right||0),s(e,t&&t.defaultColor||0),s(e,a),n){n.disabled&&(o|=2),n.positionRelativeToLayer&&(o|=1),n.fromVectorData&&(o|=8);let t=r.realMask||{};s(e,o),s(e,n.defaultColor||0),d(e,t.top||0),d(e,t.left||0),d(e,t.bottom||0),d(e,t.right||0)}i&&t&&(s(e,i),t.userMaskDensity!==void 0&&s(e,Math.round(t.userMaskDensity*255)),t.userMaskFeather!==void 0&&h(e,t.userMaskFeather),t.vectorMaskDensity!==void 0&&s(e,Math.round(t.vectorMaskDensity*255)),t.vectorMaskFeather!==void 0&&h(e,t.vectorMaskFeather)),b(e,2)})}function F(e,t){s(e,t[0]),s(e,t[1]),s(e,t[2]),s(e,t[3])}function te(e,t){A(e,1,()=>{let n=t.blendingRanges;if(n){F(e,n.compositeGrayBlendSource),F(e,n.compositeGraphBlendDestinationRange);for(let t of n.ranges)F(e,t.sourceRange),F(e,t.destRange)}})}function I(e,t){A(e,1,()=>{t&&(l(e,t.overlayColorSpace),l(e,t.colorSpace1),l(e,t.colorSpace2),l(e,t.colorSpace3),l(e,t.colorSpace4),l(e,Math.round(t.opacity*255)),s(e,t.kind),b(e,3))})}function L(e,r,i,a){for(let o of n.infoHandlers){let n=o.key;if(!(n===`Txt2`&&a.invalidateTextLayers)&&(n===`vmsk`&&a.psb&&(n=`vsms`),o.has(r))){let s=a.psb&&t.largeAdditionalInfoKeys.indexOf(n)!==-1,c=n!==`Txt2`&&n!==`cinf`&&n!==`extn`&&n!==`CAI `&&n!==`OCIO`,l=n===`Txt2`||n===`luni`||n===`vmsk`||n===`artb`||n===`artd`||n===`vogk`||n===`SoLd`||n===`lnk2`||n===`vscg`||n===`vsms`||n===`GdFl`||n===`lmfx`||n===`lrFX`||n===`cinf`||n===`PlLd`||n===`Anno`||n===`CAI `||n===`OCIO`||n===`GenI`||n===`FEid`||n===`curv`||n===`CgEd`||n===`vibA`||n===`blwh`||n===`grdm`;x(e,s?`8B64`:`8BIM`),x(e,n),A(e,l?4:2,()=>{o.write(e,r,i,a)},c,s)}}}function R(e,n){if(n)for(let r of n){if(r.children&&r.canvas)throw Error(`Invalid layer, cannot have both 'canvas' and 'children' properties`);if(r.children&&r.imageData)throw Error(`Invalid layer, cannot have both 'imageData' and 'children' properties`);r.children?(e.push({name:`</Layer group>`,sectionDivider:{type:3}}),R(e,r.children),e.push(Object.assign(Object.assign({},r),{blendMode:r.blendMode===`pass through`?`normal`:r.blendMode,sectionDivider:{type:r.opened===!1?2:1,key:t.fromBlendMode[r.blendMode]||`pass`,subType:0}}))):e.push(Object.assign({},r))}}function ne(e,t){let n=e.buffer.byteLength;do n*=2;while(t>n);let r=new ArrayBuffer(n),i=new Uint8Array(r),a=new Uint8Array(e.buffer);i.set(a),e.buffer=r,e.view=new DataView(e.buffer)}function z(e,t){t>e.buffer.byteLength&&ne(e,t)}function re(e,t){let n=e.offset;return z(e,e.offset+=t),n}function ie(e){let n=(0,t.createCanvas)(10,10),r=1;e.width>e.height?(n.width=160,n.height=Math.floor(e.height*(n.width/e.width)),r=n.width/e.width):(n.height=160,n.width=Math.floor(e.width*(n.height/e.height)),r=n.height/e.height);let i=n.getContext(`2d`);return i.scale(r,r),e.imageData?i.drawImage((0,t.imageDataToCanvas)(e.imageData),0,0):e.canvas&&i.drawImage(e.canvas,0,0),n}function ae(e,n,r,i,a,o){let s=i.top|0,c=i.left|0,l=i.right|0,u=i.bottom|0,{width:d,height:f}=V(i),p=i.imageData;if(!p&&i.canvas&&d&&f&&(p=i.canvas.getContext(`2d`).getImageData(0,0,d,f)),p&&(p.width!==d||p.height!==f))throw Error(`Invalid imageData dimentions`);l=c+d,u=s+f;let m,h;t.RAW_IMAGE_DATA&&r[o?`realMaskDataRaw`:`maskDataRaw`]?(m=r[o?`realMaskDataRaw`:`maskDataRaw`],h=r[o?`realMaskDataRawCompression`:`maskDataRawCompression`]):p?a.compress?(m=(0,t.writeDataZipWithoutPrediction)(p,[0]),h=2):(m=(0,t.writeDataRLE)(e,p,[0],!!a.psb),h=1):(m=new Uint8Array,h=1),n.channels.push({id:o?-3:-2,compression:h,data:m,length:2+m.length}),n[o?`realMask`:`mask`]={top:s,left:c,right:l,bottom:u}}function oe(e){return e?{top:e.top||0,left:e.left||0,right:e.right||0,bottom:e.bottom||0}:void 0}function B(e,t,n,r){if(t.rawData)return Object.assign(Object.assign({layer:t,channels:t.rawData.channels.map(e=>Object.assign(Object.assign({},e),{length:2+(e.data?.byteLength??0)}))},oe(t)),{mask:oe(t.mask),realMask:oe(t.realMask)});let i=H(e,t,n,r);return t.mask&&ae(e,i,t,t.mask,r,!1),t.realMask&&ae(e,i,t,t.realMask,r,!0),i}function V({canvas:e,imageData:t}){return{width:t?.width??e?.width??0,height:t?.height??e?.height??0}}function se(e,n,r,i,a){if(e.data instanceof Uint32Array||e.data instanceof Uint16Array)throw Error(`imageData has incorrect bit depth`);let o=(0,t.createImageData)(i,a),s=e.data,c=o.data;for(let t=0;t<a;t++)for(let a=0;a<i;a++){let o=(a+n+(t+r)*e.width)*4,l=(a+t*i)*4;c[l]=s[o],c[l+1]=s[o+1],c[l+2]=s[o+2],c[l+3]=s[o+3]}return o}function H(e,n,r,i){let a=n.top|0,o=n.left|0,s=n.right|0,c=n.bottom|0,l=[{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}=V(n);if(!(n.canvas||n.imageData)||!u||!d)return s=o,c=a,{layer:n,top:a,left:o,right:s,bottom:c,channels:l};s=o+u,c=a+d;let f=n.imageData||n.canvas.getContext(`2d`).getImageData(0,0,u,d);if(i.trimImageData){let e=le(f);if(e.left!==0||e.top!==0||e.right!==f.width||e.bottom!==f.height){if(o+=e.left,a+=e.top,s-=f.width-e.right,c-=f.height-e.bottom,u=s-o,d=c-a,!u||!d)return{layer:n,top:a,left:o,right:s,bottom:c,channels:l};f=se(f,e.left,e.top,u,d)}}let p=[0,1,2];return(!r||i.noBackground||n.mask||(0,t.hasAlpha)(f)||t.RAW_IMAGE_DATA&&n.imageDataRaw?.[-1])&&p.unshift(-1),l=p.map(r=>{let a=(0,t.offsetForChannel)(r,!1),o,s;return t.RAW_IMAGE_DATA&&n.imageDataRaw?(o=n.imageDataRaw[r],s=n.imageDataRawCompression[r]):i.compress?(o=(0,t.writeDataZipWithoutPrediction)(f,[a]),s=2):(o=(0,t.writeDataRLE)(e,f,[a],!!i.psb),s=1),{id:r,compression:s,data:o,length:2+o.length}}),{layer:n,top:a,left:o,right:s,bottom:c,channels:l}}function U({data:e,width:t},n,r,i){let a=(n*t+r)*4+3|0,o=a+(i-r)*4|0;for(let t=a;t<o;t=t+4|0)if(e[t]!==0)return!1;return!0}function ce({data:e,width:t},n,r,i){let a=t*4|0,o=r*a+n*4+3|0;for(let t=r,n=o;t<i;t++,n=n+a|0)if(e[n]!==0)return!1;return!0}function le(e){let t=0,n=0,r=e.width,i=e.height;for(;t<i&&U(e,t,n,r);)t++;for(;i>t&&U(e,i-1,n,r);)i--;for(;n<r&&ce(e,n,t,i);)n++;for(;r>n&&ce(e,r-1,t,i);)r--;return{top:t,left:n,right:r,bottom:i}}function ue(e,t){t?`r`in t?(l(e,0),l(e,Math.round(t.r*257)),l(e,Math.round(t.g*257)),l(e,Math.round(t.b*257)),l(e,0)):`fr`in t?(l(e,0),l(e,Math.round(t.fr*255*257)),l(e,Math.round(t.fg*255*257)),l(e,Math.round(t.fb*255*257)),l(e,0)):`l`in t?(l(e,7),c(e,Math.round(t.l*1e4)),c(e,Math.round(t.a<0?t.a*12800:t.a*12700)),c(e,Math.round(t.b<0?t.b*12800:t.b*12700)),l(e,0)):`h`in t?(l(e,1),l(e,Math.round(t.h*65535)),l(e,Math.round(t.s*65535)),l(e,Math.round(t.b*65535)),l(e,0)):`c`in t?(l(e,2),l(e,Math.round(t.c*257)),l(e,Math.round(t.m*257)),l(e,Math.round(t.y*257)),l(e,Math.round(t.k*257))):(l(e,8),l(e,Math.round(t.k*1e4/255)),b(e,6)):(l(e,0),b(e,8))}function W(e,n){let r=n.bounds.w,i=n.bounds.h,a={width:r,height:i,data:n.data};p(e,0);let o=e.offset;p(e,1),p(e,3),c(e,n.x),c(e,n.y),D(e,n.name+`\0`),w(e,n.id,1),p(e,3),p(e,0);let u=e.offset,d=n.bounds.y,f=n.bounds.x,m=d+i,h=f+r;p(e,d),p(e,f),p(e,m),p(e,h),p(e,24);for(let n=0;n<26;n++){let o=n<3?n:n===25?3:-1;if(o<0){p(e,0);continue}let c=new Uint8Array(r*i+2*i+2*r+16),u=(0,t.writeDataRLE)(c,a,[o],!1);p(e,1),p(e,u.length+4+16+2+1),p(e,8),p(e,d),p(e,f),p(e,m),p(e,h),l(e,8),s(e,1),y(e,u)}let g=e.offset-u,_=e.offset-o;for(;_%4;)b(e,1),_++;e.view.setUint32(u-4,g,!1),e.view.setUint32(o-4,_,!1)}})),k=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.readAbr=u;let t=x(),n=C(),r=[`off`,`fade`,`pen pressure`,`pen tilt`,`stylus wheel`,`initial direction`,`direction`,`initial rotation`,`rotation`],i=[`round point`,`round blunt`,`round curve`,`round angle`,`round fan`,`flat point`,`flat blunt`,`flat curve`,`flat angle`,`flat fan`],a=[`erodible point`,`erodible flat`,`erodible round`,`erodible square`,`erodible triangle`,`custom`],o={_:`brush`,MixB:`mixer brush`,SmTl:`smudge brush`};function s(e){return{control:r[e.bVTy],steps:e.fStp,jitter:(0,t.parsePercent)(e.jitter),minimum:(0,t.parsePercent)(e[`Mnm `])}}function c(e){switch(e._classID){case`computedBrush`:return{type:`computed`,size:(0,t.parseUnitsToNumber)(e.Dmtr,`Pixels`),angle:(0,t.parseAngle)(e.Angl),roundness:(0,t.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,t.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY,hardness:(0,t.parsePercent)(e.Hrdn)};case`sampledBrush`:return{type:`sampled`,size:(0,t.parseUnitsToNumber)(e.Dmtr,`Pixels`),angle:(0,t.parseAngle)(e.Angl),roundness:(0,t.parsePercent)(e.Rndn),spacingOn:e.Intr,spacing:(0,t.parsePercent)(e.Spcn),flipX:e.flipX,flipY:e.flipY,name:e[`Nm `],sampledData:e.sampledData};case`dBrush`:return{type:`dynamic`,shape:i[e[`Shp `]],angle:(0,t.parseAngle)(e.Angl),size:(0,t.parseUnitsToNumber)(e.Dmtr,`Pixels`),density:(0,t.parsePercent)(e.Dnst),length:(0,t.parsePercent)(e.Lngt),clumping:(0,t.parsePercent)(e.clumping),thickness:(0,t.parsePercent)(e.thickness),stiffness:(0,t.parsePercent)(e.stiffness),physics:e.physics,spacing:(0,t.parsePercent)(e.Spcn),spacingOn:e.Intr,flipX:e.flipX,flipY:e.flipY};case`dTips`:return Object.assign(Object.assign({type:`tips`,angle:(0,t.parseAngle)(e.Angl),size:(0,t.parseUnitsToNumber)(e.Dmtr,`Pixels`),shape:i[e[`Shp `]],physics:e.physics,spacing:(0,t.parsePercent)(e.Spcn),spacingOn:e.Intr,flipX:e.flipX,flipY:e.flipY,tipsType:a[e.dtipsType],tipsLengthRatio:(0,t.parsePercent)(e.dtipsLengthRatio),tipsHardness:(0,t.parsePercent)(e.dtipsHardness)},e.dtipsGridSize&&e.dtipsErodibleTipHeightMap?{tipsGridSize:e.dtipsGridSize,tipsErodibleTipHeightMap:l(e.dtipsErodibleTipHeightMap)}:{}),{tipsAirbrushCutoffAngle:e.dtipsAirbrushCutoffAngle,tipsAirbrushGranularity:(0,t.parsePercent)(e.dtipsAirbrushGranularity),tipsAirbrushStreakiness:(0,t.parsePercent)(e.dtipsAirbrushStreakiness),tipsAirbrushSplatSize:(0,t.parsePercent)(e.dtipsAirbrushSplatSize),tipsAirbrushSplatCount:e.dtipsAirbrushSplatCount});default:throw Error(`Unknown brush classId: ${e._classID}`)}}function l(e){let t=[];for(let n=0;n<e.byteLength;n++)t.push(e[n]);return t}function u(e,r={}){let i=(0,n.createReader)(e.buffer,e.byteOffset,e.byteLength),a=(0,n.readInt16)(i),l=[],u=[],d=[];if(a===1||a===2)throw Error(`Unsupported ABR version (${a})`);if(a===6||a===7||a===9||a===10){let e=(0,n.readInt16)(i);if(e!==1&&e!==2)throw Error(`Unsupported ABR minor version`);for(;i.offset<i.view.byteLength;){(0,n.checkSignature)(i,`8BIM`);let a=(0,n.readSignature)(i),f=(0,n.readUint32)(i),p=i.offset+f;switch(a){case`samp`:for(;i.offset<p;){let t=(0,n.readUint32)(i);for(;t&3;)t++;let r=i.offset+t,a=(0,n.readPascalString)(i,1);(0,n.skipBytes)(i,e===1?10:264);let o=(0,n.readInt32)(i),s=(0,n.readInt32)(i),c=(0,n.readInt32)(i)-o,u=(0,n.readInt32)(i)-s;if(u<=0||c<=0)throw Error(`Invalid bounds`);let d=(0,n.readInt16)(i),f=(0,n.readUint8)(i),p=new Uint8Array(u*c);if(d===8)if(f===0)p.set((0,n.readBytes)(i,p.byteLength));else if(f===1)(0,n.readDataRLE)(i,{width:u,height:c,data:p},u,c,d,1,[0],!1);else throw Error(`Invalid compression`);else if(d===16)if(f===0)for(let e=0;e<p.byteLength;e++)p[e]=(0,n.readUint16)(i)>>8;else if(f===1)throw Error(`not implemented (16bit RLE)`);else throw Error(`Invalid compression`);else throw Error(`Invalid depth`);l.push({id:a,bounds:{x:s,y:o,w:u,h:c},alpha:p}),i.offset=r}break;case`desc`:{let e=(0,t.readVersionAndDescriptor)(i,!0);for(let n of e.Brsh){let e={name:n[`Nm `],shape:c(n.Brsh),spacing:(0,t.parsePercent)(n.Spcn),wetEdges:n.Wtdg,noise:n.Nose,useBrushSize:n.useBrushSize};n.interpretation!=null&&(e.interpretation=n.interpretation),n.protectTexture!=null&&(e.protectTexture=n.protectTexture),n.useTipDynamics&&(e.shapeDynamics={tiltScale:(0,t.parsePercent)(n.tiltScale),sizeDynamics:s(n.szVr),angleDynamics:s(n.angleDynamics),roundnessDynamics:s(n.roundnessDynamics),flipX:n.flipX,flipY:n.flipY,brushProjection:n.brushProjection,minimumDiameter:(0,t.parsePercent)(n.minimumDiameter),minimumRoundness:(0,t.parsePercent)(n.minimumRoundness)}),n.useScatter&&(e.scatter={count:n[`Cnt `],bothAxes:n.bothAxes,countDynamics:s(n.countDynamics),scatterDynamics:s(n.scatterDynamics)}),n.useTexture&&n.Txtr&&(e.texture={id:n.Txtr.Idnt,name:n.Txtr[`Nm `],blendMode:t.BlnM.decode(n.textureBlendMode),depth:(0,t.parsePercent)(n.textureDepth),depthMinimum:(0,t.parsePercent)(n.minimumDepth),depthDynamics:s(n.textureDepthDynamics),scale:(0,t.parsePercent)(n.textureScale),invert:n.InvT,brightness:n.textureBrightness,contrast:n.textureContrast,textureEachTip:!!n.TxtC});let r=n.dualBrush;r&&r.useDualBrush&&(e.dualBrush={flip:r.Flip,shape:c(r.Brsh),blendMode:t.BlnM.decode(r.BlnM),useScatter:r.useScatter,spacing:(0,t.parsePercent)(r.Spcn),count:r[`Cnt `],bothAxes:r.bothAxes,countDynamics:s(r.countDynamics),scatterDynamics:s(r.scatterDynamics)}),n.useColorDynamics&&(e.colorDynamics={foregroundBackground:s(n.clVr),hue:(0,t.parsePercent)(n[`H `]),saturation:(0,t.parsePercent)(n.Strt),brightness:(0,t.parsePercent)(n.Brgh),purity:(0,t.parsePercent)(n.purity),perTip:n.colorDynamicsPerTip}),n.usePaintDynamics&&(e.transfer={flowDynamics:s(n.prVr),opacityDynamics:s(n.opVr),wetnessDynamics:s(n.wtVr),mixDynamics:s(n.mxVr)}),n.useBrushPose&&(e.brushPose={overrideAngle:n.overridePoseAngle,overrideTiltX:n.overridePoseTiltX,overrideTiltY:n.overridePoseTiltY,overridePressure:n.overridePosePressure,pressure:(0,t.parsePercent)(n.brushPosePressure),tiltX:n.brushPoseTiltX,tiltY:n.brushPoseTiltY,angle:n.brushPoseAngle});let i=n.toolOptions;i&&(e.toolOptions={type:o[i._classID]||`brush`,brushPreset:i.brushPreset,flow:i.flow??100,smooth:i.Smoo??0,mode:t.BlnM.decode(i[`Md `]||`BlnM.Nrml`),opacity:i.Opct??100,smoothing:!!i.smoothing,smoothingValue:i.smoothingValue||0,smoothingRadiusMode:!!i.smoothingRadiusMode,smoothingCatchup:!!i.smoothingCatchup,smoothingCatchupAtEnd:!!i.smoothingCatchupAtEnd,smoothingZoomCompensation:!!i.smoothingZoomCompensation,pressureSmoothing:!!i.pressureSmoothing,usePressureOverridesSize:!!i.usePressureOverridesSize,usePressureOverridesOpacity:!!i.usePressureOverridesOpacity,useLegacy:!!i.useLegacy},i.prVr&&(e.toolOptions.flowDynamics=s(i.prVr)),i.opVr&&(e.toolOptions.opacityDynamics=s(i.opVr)),i.szVr&&(e.toolOptions.sizeDynamics=s(i.szVr)),`wetness`in i&&(e.toolOptions.wetness=i.wetness),`dryness`in i&&(e.toolOptions.dryness=i.dryness),`mix`in i&&(e.toolOptions.mix=i.mix),`autoFill`in i&&(e.toolOptions.autoFill=i.autoFill),`autoClean`in i&&(e.toolOptions.autoClean=i.autoClean),`loadSolidColorOnly`in i&&(e.toolOptions.loadSolidColorOnly=i.loadSolidColorOnly),`sampleAllLayers`in i&&(e.toolOptions.sampleAllLayers=i.sampleAllLayers),`SmdF`in i&&(e.toolOptions.smudgeFingerPainting=i.SmdF),`SmdS`in i&&(e.toolOptions.smudgeSampleAllLayers=i.SmdS),`Prs `in i&&(e.toolOptions.strength=i[`Prs `])),u.push(e)}break}case`patt`:for(;i.offset<p;)d.push((0,n.readPattern)(i));i.offset=p;break;case`phry`:{let e=(0,t.readVersionAndDescriptor)(i);r.logMissingFeatures&&e.hierarchy?.length;break}default:throw Error(`Invalid brush type: ${a}`)}for(;f%4;)i.offset++,f++}}else throw Error(`Unsupported ABR version (${a})`);return{samples:l,patterns:d,brushes:u}}})),A=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.readCsh=r;let t=ee(),n=C();function r(e){let r=(0,n.createReader)(e.buffer,e.byteOffset,e.byteLength),i={shapes:[]};if((0,n.checkSignature)(r,`cush`),(0,n.readUint32)(r)!==2)throw Error(`Invalid version`);let a=(0,n.readUint32)(r);for(let e=0;e<a;e++){let e=(0,n.readUnicodeString)(r);for(;r.offset%4;)r.offset++;if((0,n.readUint32)(r)!==1)throw Error(`Invalid shape version`);let a=(0,n.readUint32)(r),o=r.offset+a,s=(0,n.readPascalString)(r,1),c=(0,n.readUint32)(r),l=(0,n.readUint32)(r),u=(0,n.readUint32)(r),d=(0,n.readUint32)(r)-l,f=u-c,p={paths:[]};(0,t.readVectorMask)(r,p,d,f,o-r.offset),i.shapes.push(Object.assign({name:e,id:s,width:d,height:f},p)),r.offset=o}return i}})),j=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Compression=e.ChannelID=e.LayerCompCapturedInfo=e.SectionDividerType=e.ColorMode=void 0;var t;(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`})(t||(e.ColorMode=t={}));var n;(function(e){e[e.Other=0]=`Other`,e[e.OpenFolder=1]=`OpenFolder`,e[e.ClosedFolder=2]=`ClosedFolder`,e[e.BoundingSectionDivider=3]=`BoundingSectionDivider`})(n||(e.SectionDividerType=n={}));var r;(function(e){e[e.None=0]=`None`,e[e.Visibility=1]=`Visibility`,e[e.Position=2]=`Position`,e[e.Appearance=4]=`Appearance`})(r||(e.LayerCompCapturedInfo=r={}));var i;(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`})(i||(e.ChannelID=i={}));var a;(function(e){e[e.RawData=0]=`RawData`,e[e.RleCompressed=1]=`RleCompressed`,e[e.ZipWithoutPrediction=2]=`ZipWithoutPrediction`,e[e.ZipWithPrediction=3]=`ZipWithPrediction`})(a||(e.Compression=a={}))})),M=e((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.getCompositeCanvas=e.getCompositeImageData=e.getLayerRealMaskCanvas=e.getLayerMaskCanvas=e.getLayerCanvas=e.getLayerRealMaskImageData=e.getLayerMaskImageData=e.getLayerImageData=e.decodeLayerPixels=e.byteArrayToBase64=e.initializeCanvas=void 0,e.readPsd=s,e.writePsd=c,e.writePsdUint8Array=l,e.writePsdBuffer=u;let r=O(),i=C();Object.defineProperty(e,"decodeLayerPixels",{enumerable:!0,get:function(){return i.decodeLayerPixels}}),Object.defineProperty(e,"getLayerImageData",{enumerable:!0,get:function(){return i.getLayerImageData}}),Object.defineProperty(e,"getLayerMaskImageData",{enumerable:!0,get:function(){return i.getLayerMaskImageData}}),Object.defineProperty(e,"getLayerRealMaskImageData",{enumerable:!0,get:function(){return i.getLayerRealMaskImageData}}),Object.defineProperty(e,"getLayerCanvas",{enumerable:!0,get:function(){return i.getLayerCanvas}}),Object.defineProperty(e,"getLayerMaskCanvas",{enumerable:!0,get:function(){return i.getLayerMaskCanvas}}),Object.defineProperty(e,"getLayerRealMaskCanvas",{enumerable:!0,get:function(){return i.getLayerRealMaskCanvas}}),Object.defineProperty(e,"getCompositeImageData",{enumerable:!0,get:function(){return i.getCompositeImageData}}),Object.defineProperty(e,"getCompositeCanvas",{enumerable:!0,get:function(){return i.getCompositeCanvas}});let a=y();n(k(),e),n(A(),e);var o=v();Object.defineProperty(e,"initializeCanvas",{enumerable:!0,get:function(){return o.initializeCanvas}}),n(j(),e),e.byteArrayToBase64=a.fromByteArray;function s(e,t){let n=`buffer`in e?(0,i.createReader)(e.buffer,e.byteOffset,e.byteLength):(0,i.createReader)(e);return(0,i.readPsd)(n,t)}function c(e,t){let n=(0,r.createWriter)();return(0,r.writePsd)(n,e,t),(0,r.getWriterBuffer)(n)}function l(e,t){let n=(0,r.createWriter)();return(0,r.writePsd)(n,e,t),(0,r.getWriterBufferNoCopy)(n)}function u(e,t){if(typeof Buffer>`u`)throw Error(`Buffer not supported on this platform`);return Buffer.from(l(e,t))}}))();(0,M.initializeCanvas)((e,t)=>new OffscreenCanvas(e,t),void 0,(e,t)=>new ImageData(e,t));const N=()=>{throw Error(`PSD supports 8-bit RGB pixel layers, normal blending, up to 8 layers and 4096 × 4096. Flatten masks/effects in your painting software first.`)};function P(e,t={opacity:1,hidden:!1},n=[]){for(let r of e??[]){(r.blendMode&&![`normal`,`pass through`].includes(r.blendMode)||r.mask||r.realMask||r.effects||r.adjustment||r.clipping||r.vectorMask)&&N();let e=t.opacity*(r.opacity??1),i=t.hidden||!!r.hidden;r.children&&e!==1&&N(),r.children?P(r.children,{opacity:e,hidden:i},n):r.imageData&&n.push({name:String(r.name??``).slice(0,40),left:r.left??0,top:r.top??0,opacity:e,hidden:i,imageData:r.imageData}),n.length>8&&N()}return n}self.onmessage=e=>{try{let{action:t,payload:n}=e.data;if(t===`write`){let e=(0,M.writePsd)(n,{noBackground:!0,trimImageData:!0});self.postMessage({ok:!0,value:e},[e]);return}if(t!==`read`)throw Error(`Unknown PSD operation`);let r=new DataView(n);(r.byteLength<26||r.getUint32(0)!==943870035||r.getUint16(4)!==1||r.getUint16(22)!==8||r.getUint16(24)!==3||r.getUint32(14)<1||r.getUint32(18)<1||r.getUint32(14)>4096||r.getUint32(18)>4096)&&N();let i=(0,M.readPsd)(n,{useImageData:!0,skipThumbnail:!0,skipLinkedFilesData:!0,totalMemoryLimit:192*1024*1024,throwForMissingFeatures:!0}),a=P(i.children);if(!a.length&&i.imageData&&a.push({name:`Background`,left:0,top:0,opacity:1,hidden:!1,imageData:i.imageData}),!a.length)throw Error(`PSD has no readable pixels`);self.postMessage({ok:!0,value:{width:i.width,height:i.height,layers:a}})}catch(e){self.postMessage({ok:!1,error:e.message})}};
|