@kaeawc/auto-mobile 0.0.93 → 0.0.94
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/dist/build-info.json +12 -12
- package/dist/src/ble-peripheral.py +153 -0
- package/dist/src/{chunk-r6z1eztj.js → chunk-026y62r9.js} +11 -11
- package/dist/src/chunk-0jyfg947.js +4 -0
- package/dist/src/{chunk-8g1922rp.js → chunk-0zfpp1wh.js} +4 -4
- package/dist/src/{chunk-qf6nynk6.js → chunk-13qxf7ym.js} +5 -5
- package/dist/src/chunk-1scenrk7.js +4 -0
- package/dist/src/chunk-1vb5ph1k.js +4 -0
- package/dist/src/{chunk-710rxz9y.js → chunk-20g565q7.js} +3 -3
- package/dist/src/chunk-21h6dhdm.js +5 -0
- package/dist/src/chunk-25mfpthk.js +78 -0
- package/dist/src/{chunk-rbpdk7m0.js → chunk-2b39zyxc.js} +3 -3
- package/dist/src/chunk-2gzd6wbd.js +4 -0
- package/dist/src/{chunk-xgan0qqp.js → chunk-3dntffy9.js} +1 -1
- package/dist/src/chunk-3gfczcsn.js +4 -0
- package/dist/src/{chunk-dgrbdpb7.js → chunk-3h5jz1vb.js} +6 -6
- package/dist/src/{chunk-t6c8akcm.js → chunk-41zcy6b3.js} +3 -3
- package/dist/src/chunk-47n9m2de.js +4 -0
- package/dist/src/chunk-4vxeq0vd.js +58 -0
- package/dist/src/chunk-59dx6qaf.js +4 -0
- package/dist/src/chunk-5sdf9y92.js +4 -0
- package/dist/src/{chunk-58wzr3mt.js → chunk-5wk1t46v.js} +3 -3
- package/dist/src/{chunk-vy3bwm1d.js → chunk-661c50hh.js} +5 -5
- package/dist/src/chunk-68n6bjjd.js +21 -0
- package/dist/src/{chunk-v6pya0dm.js → chunk-69pmjdf2.js} +3 -3
- package/dist/src/{chunk-e98dqnc9.js → chunk-6hrj3jt6.js} +20 -20
- package/dist/src/{chunk-wbh8spm5.js → chunk-6myr26wx.js} +8 -8
- package/dist/src/chunk-6n96k09n.js +4 -0
- package/dist/src/chunk-6vwrbkre.js +4 -0
- package/dist/src/chunk-6wk0yrab.js +4 -0
- package/dist/src/chunk-6yhm9een.js +4 -0
- package/dist/src/{chunk-mjrps0ac.js → chunk-7k7gjg2t.js} +5 -5
- package/dist/src/chunk-7n5fz68h.js +4 -0
- package/dist/src/chunk-8cvnpnbp.js +4 -0
- package/dist/src/chunk-8kzv7rk7.js +4 -0
- package/dist/src/chunk-8nj68t1v.js +167 -0
- package/dist/src/{chunk-g7tmjbkt.js → chunk-96r3bpg7.js} +3 -3
- package/dist/src/chunk-97x887te.js +4 -0
- package/dist/src/{chunk-8ph29g99.js → chunk-99a6tbvd.js} +1 -1
- package/dist/src/chunk-9p5d2994.js +5 -0
- package/dist/src/{chunk-aabchzxk.js → chunk-9q265er0.js} +4 -4
- package/dist/src/{chunk-jh6vhqzx.js → chunk-9xgnrv5w.js} +3 -3
- package/dist/src/chunk-9xgsmshb.js +5 -0
- package/dist/src/chunk-a02d1wgv.js +4 -0
- package/dist/src/{chunk-ndt1ccxm.js → chunk-a9ps00a1.js} +10 -10
- package/dist/src/{chunk-5d2hft6c.js → chunk-aewdveet.js} +3 -3
- package/dist/src/{chunk-ycaj2sgf.js → chunk-b3tdtq7r.js} +6 -6
- package/dist/src/chunk-bn7jx7a2.js +4 -0
- package/dist/src/{chunk-3y6eykz9.js → chunk-bnyw27ja.js} +2 -2
- package/dist/src/{chunk-rqc9ap3x.js → chunk-bpwsg76p.js} +2 -2
- package/dist/src/chunk-bvranw3g.js +4 -0
- package/dist/src/chunk-c25a84zb.js +4 -0
- package/dist/src/chunk-c27yv1dx.js +5 -0
- package/dist/src/chunk-c3ewxm4x.js +5 -0
- package/dist/src/{chunk-rvvy1bte.js → chunk-cb1ga9rd.js} +5 -5
- package/dist/src/chunk-cn7fwy7k.js +4 -0
- package/dist/src/chunk-cnvy4a64.js +4 -0
- package/dist/src/{chunk-7rz9898k.js → chunk-cqhw4yr6.js} +3 -3
- package/dist/src/{chunk-g04bwyj3.js → chunk-ctmfshjc.js} +2 -2
- package/dist/src/chunk-ctwmhz13.js +4 -0
- package/dist/src/{chunk-waqwcjyn.js → chunk-d3jx9bz5.js} +2 -2
- package/dist/src/{chunk-ayp07wbb.js → chunk-d6rb08ga.js} +1 -1
- package/dist/src/chunk-ddqhj4eg.js +5 -0
- package/dist/src/{chunk-r7bpkgff.js → chunk-ddrhs1c3.js} +2 -2
- package/dist/src/chunk-dnjnh9p6.js +4 -0
- package/dist/src/{chunk-wyrkw6hw.js → chunk-dw5rwgya.js} +3 -3
- package/dist/src/{chunk-3xkpk44w.js → chunk-e0870khr.js} +3 -3
- package/dist/src/chunk-ea3k10kj.js +4 -0
- package/dist/src/chunk-emv82m1w.js +7 -0
- package/dist/src/chunk-f3m6pdnx.js +4 -0
- package/dist/src/chunk-f84z32cb.js +4 -0
- package/dist/src/chunk-fpczgf0z.js +4 -0
- package/dist/src/{chunk-2tqzq5qh.js → chunk-g2js4c2v.js} +18 -18
- package/dist/src/chunk-g3af2qbk.js +5 -0
- package/dist/src/{chunk-3qwrzxh0.js → chunk-gadtna7s.js} +6 -6
- package/dist/src/{chunk-ybbtagbt.js → chunk-gcyx407v.js} +3 -3
- package/dist/src/{chunk-bfw6125s.js → chunk-gfpntwc1.js} +3 -3
- package/dist/src/chunk-gmnm5e3e.js +4 -0
- package/dist/src/chunk-gp6vb5gf.js +4 -0
- package/dist/src/chunk-gppgy7pa.js +4 -0
- package/dist/src/chunk-hegfz0ae.js +5 -0
- package/dist/src/chunk-hpzxdp1k.js +17 -0
- package/dist/src/{chunk-qcxzr2my.js → chunk-j69g8b50.js} +3 -3
- package/dist/src/chunk-jvstjnqm.js +19 -0
- package/dist/src/chunk-jzqrv78s.js +4 -0
- package/dist/src/chunk-k2948b8d.js +4 -0
- package/dist/src/chunk-k4ftd40d.js +4 -0
- package/dist/src/{chunk-bxmsax22.js → chunk-kd9vfaxh.js} +3 -3
- package/dist/src/{chunk-s3jc6cwp.js → chunk-kdczmgwk.js} +3 -3
- package/dist/src/{chunk-t6bfvfkg.js → chunk-ke3wn14v.js} +1 -1
- package/dist/src/chunk-kh5n7m6w.js +4 -0
- package/dist/src/{chunk-6wt9rgjf.js → chunk-khejfph4.js} +3 -3
- package/dist/src/chunk-kny2xemh.js +4 -0
- package/dist/src/chunk-knyzw9md.js +4 -0
- package/dist/src/chunk-mbzpt2hp.js +4 -0
- package/dist/src/chunk-mm8rcxad.js +4 -0
- package/dist/src/chunk-nc4516tx.js +4 -0
- package/dist/src/{chunk-6bznss4t.js → chunk-ntfrqrqn.js} +5 -5
- package/dist/src/chunk-nz5h2j52.js +4 -0
- package/dist/src/chunk-p22s97qy.js +4 -0
- package/dist/src/chunk-p9kt1sgr.js +6 -0
- package/dist/src/{chunk-yb97j25b.js → chunk-pf282r5g.js} +4 -4
- package/dist/src/chunk-pnd4mrxy.js +4 -0
- package/dist/src/chunk-pqqteyj6.js +4 -0
- package/dist/src/{chunk-6xmss8er.js → chunk-qj1tbnv2.js} +6 -6
- package/dist/src/chunk-qnh9egwr.js +4 -0
- package/dist/src/chunk-qy3khhf8.js +8 -0
- package/dist/src/{chunk-z637nqg8.js → chunk-r0vp315h.js} +6 -6
- package/dist/src/chunk-r4j43b9s.js +237 -0
- package/dist/src/{chunk-1p7xf5kb.js → chunk-r54cxxze.js} +3 -3
- package/dist/src/{chunk-yf7ympyz.js → chunk-r6pvhj33.js} +92 -92
- package/dist/src/chunk-rb7aa5gr.js +54 -0
- package/dist/src/chunk-rdj50kb4.js +4 -0
- package/dist/src/chunk-rnd4vcas.js +4 -0
- package/dist/src/{chunk-w5b2jwk3.js → chunk-s3y3zfcx.js} +8 -8
- package/dist/src/chunk-s4g43k75.js +5 -0
- package/dist/src/chunk-sfqe223f.js +311 -0
- package/dist/src/{chunk-284ptqa4.js → chunk-sqdrxjw5.js} +5 -5
- package/dist/src/{chunk-zgja5f3p.js → chunk-t54k47em.js} +4 -4
- package/dist/src/{chunk-3sy6ahhz.js → chunk-tek4pnvv.js} +10 -10
- package/dist/src/chunk-tn74y7af.js +4 -0
- package/dist/src/{chunk-thbh3jew.js → chunk-tvq0nzam.js} +3 -3
- package/dist/src/{chunk-0jrrsnc9.js → chunk-tx4f0h9c.js} +4 -4
- package/dist/src/chunk-vdqag3fj.js +5 -0
- package/dist/src/chunk-vz5zzs57.js +4 -0
- package/dist/src/chunk-w4s2vfpj.js +4 -0
- package/dist/src/{chunk-4hw3665t.js → chunk-w5yypt53.js} +11 -11
- package/dist/src/{chunk-8037tzzj.js → chunk-w68v64vh.js} +3 -3
- package/dist/src/chunk-whwj0pdk.js +5 -0
- package/dist/src/chunk-wnmqt1dc.js +4 -0
- package/dist/src/{chunk-cyy71ggq.js → chunk-wpe46vsa.js} +3 -3
- package/dist/src/{chunk-w3vs79ex.js → chunk-wxdjeb4k.js} +19 -19
- package/dist/src/chunk-xcqzwf9j.js +247 -0
- package/dist/src/chunk-xezekwwn.js +5 -0
- package/dist/src/chunk-xf19m15s.js +4 -0
- package/dist/src/chunk-xghbxha4.js +4 -0
- package/dist/src/{chunk-00167wan.js → chunk-xn9m3xc2.js} +5 -5
- package/dist/src/{chunk-26k317v5.js → chunk-yqfz4vts.js} +3 -3
- package/dist/src/chunk-z8tvs8nk.js +5 -0
- package/dist/src/chunk-zm2rehqb.js +5 -0
- package/dist/src/chunk-zs6dqm35.js +4 -0
- package/dist/src/daemon/processEntry.js +2 -2
- package/dist/src/index.js +4 -4
- package/dist/src/runtime/bunRuntimeGuard.js +2 -2
- package/dist/src/utils/workers/iosBundleExtractWorker.js +2 -2
- package/package.json +2 -2
- package/dist/src/chunk-0n6swkwg.js +0 -5
- package/dist/src/chunk-0qsy1qsx.js +0 -57
- package/dist/src/chunk-11m8wj8j.js +0 -237
- package/dist/src/chunk-23p5f095.js +0 -4
- package/dist/src/chunk-28re4xrg.js +0 -4
- package/dist/src/chunk-2f9rkmhx.js +0 -5
- package/dist/src/chunk-2fxdh48t.js +0 -4
- package/dist/src/chunk-2tbdrbt6.js +0 -4
- package/dist/src/chunk-32gvv9b4.js +0 -21
- package/dist/src/chunk-3f3t1x97.js +0 -8
- package/dist/src/chunk-3fspkbc7.js +0 -4
- package/dist/src/chunk-3vg455e6.js +0 -4
- package/dist/src/chunk-49bsqdx3.js +0 -4
- package/dist/src/chunk-5snsn9cf.js +0 -4
- package/dist/src/chunk-5tm9mn47.js +0 -54
- package/dist/src/chunk-5zc77a5t.js +0 -4
- package/dist/src/chunk-64j0majr.js +0 -19
- package/dist/src/chunk-65y8v4td.js +0 -17
- package/dist/src/chunk-6awz7vhq.js +0 -5
- package/dist/src/chunk-6ep7f5ge.js +0 -4
- package/dist/src/chunk-7cs2da62.js +0 -5
- package/dist/src/chunk-7g103b54.js +0 -4
- package/dist/src/chunk-7j5vj4pa.js +0 -4
- package/dist/src/chunk-7tw8x05v.js +0 -4
- package/dist/src/chunk-7zy586cb.js +0 -4
- package/dist/src/chunk-84nanf8s.js +0 -5
- package/dist/src/chunk-8gvwcv2p.js +0 -4
- package/dist/src/chunk-8thrmfat.js +0 -4
- package/dist/src/chunk-8zgzzs7k.js +0 -78
- package/dist/src/chunk-97b1zmaq.js +0 -4
- package/dist/src/chunk-9fth9ayh.js +0 -4
- package/dist/src/chunk-9j6anhjr.js +0 -4
- package/dist/src/chunk-bfjwqk8q.js +0 -4
- package/dist/src/chunk-bnhscm2n.js +0 -4
- package/dist/src/chunk-c1vs4g1n.js +0 -4
- package/dist/src/chunk-ct3e7yng.js +0 -4
- package/dist/src/chunk-ddzkz92z.js +0 -4
- package/dist/src/chunk-drdz8hee.js +0 -5
- package/dist/src/chunk-eersndy7.js +0 -5
- package/dist/src/chunk-eggq53ks.js +0 -4
- package/dist/src/chunk-f2dya7cs.js +0 -4
- package/dist/src/chunk-fbakd6cw.js +0 -4
- package/dist/src/chunk-fgb98zjj.js +0 -5
- package/dist/src/chunk-fmpad823.js +0 -5
- package/dist/src/chunk-g0xr8zw0.js +0 -4
- package/dist/src/chunk-g3rjs80x.js +0 -4
- package/dist/src/chunk-g78rtrfv.js +0 -4
- package/dist/src/chunk-gabgv3y5.js +0 -4
- package/dist/src/chunk-gmr45m8f.js +0 -4
- package/dist/src/chunk-gsyfebqj.js +0 -4
- package/dist/src/chunk-h5rpn9wr.js +0 -247
- package/dist/src/chunk-hb1x7v55.js +0 -4
- package/dist/src/chunk-hrfytkxh.js +0 -168
- package/dist/src/chunk-j4yjzbak.js +0 -4
- package/dist/src/chunk-jd6a5v6p.js +0 -5
- package/dist/src/chunk-kn5spq15.js +0 -4
- package/dist/src/chunk-m94qs0f0.js +0 -4
- package/dist/src/chunk-n03dmn5q.js +0 -5
- package/dist/src/chunk-n72qhwd9.js +0 -4
- package/dist/src/chunk-nr6y0n4y.js +0 -5
- package/dist/src/chunk-pcsen2vs.js +0 -4
- package/dist/src/chunk-ppfr0b8h.js +0 -4
- package/dist/src/chunk-q10bdnat.js +0 -4
- package/dist/src/chunk-q9xmq595.js +0 -4
- package/dist/src/chunk-qyqypn28.js +0 -5
- package/dist/src/chunk-r2epb56s.js +0 -4
- package/dist/src/chunk-r5bxavdx.js +0 -311
- package/dist/src/chunk-r8jf3d92.js +0 -4
- package/dist/src/chunk-rc0dbypm.js +0 -4
- package/dist/src/chunk-rhcty4ms.js +0 -4
- package/dist/src/chunk-rpvckv3p.js +0 -4
- package/dist/src/chunk-ry0mz41y.js +0 -4
- package/dist/src/chunk-sfv61xjb.js +0 -6
- package/dist/src/chunk-t7w8rctc.js +0 -4
- package/dist/src/chunk-v2wd4n3e.js +0 -5
- package/dist/src/chunk-w4zga19f.js +0 -4
- package/dist/src/chunk-w7hkv422.js +0 -5
- package/dist/src/chunk-xa73x2cx.js +0 -5
- package/dist/src/chunk-y2vs6jwg.js +0 -4
- package/dist/src/chunk-yattm52s.js +0 -4
- package/dist/src/chunk-yjawdzk8.js +0 -4
- package/dist/src/chunk-zs1sghs9.js +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Dr,v,an,N,ft,$t,pt,K,ve,TR,_k,Qo,Hr,Ps,c9,kb,lr,Jie,Mo,x}from"./chunk-r5bxavdx.js";import{i,Tf,Qt,e}from"./chunk-z637nqg8.js";import{fu,Pv,Po,vn,Tv,FW,Oa,td}from"./chunk-0qsy1qsx.js";import{r,t}from"./chunk-rbpdk7m0.js";import{Nt,M,wt}from"./chunk-qcxzr2my.js";var me=M(function(ps,Ze){var Ke=wt("util"),pe=wt("stream"),B=Ze.exports=function(){pe.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};Ke.inherits(B,pe);B.prototype.read=function(n,s){this._reads.push({length:Math.abs(n),allowLess:n<0,func:s}),process.nextTick(function(){if(this._process(),this._paused&&this._reads&&this._reads.length>0)this._paused=!1,this.emit("drain")}.bind(this))};B.prototype.write=function(n,s){if(!this.writable)return this.emit("error",Error("Stream not writable")),!1;let o;if(Buffer.isBuffer(n))o=n;else o=Buffer.from(n,s||this._encoding);if(this._buffers.push(o),this._buffered+=o.length,this._process(),this._reads&&this._reads.length===0)this._paused=!0;return this.writable&&!this._paused};B.prototype.end=function(n,s){if(n)this.write(n,s);if(this.writable=!1,!this._buffers)return;if(this._buffers.length===0)this._end();else this._buffers.push(null),this._process()};B.prototype.destroySoon=B.prototype.end;B.prototype._end=function(){if(this._reads.length>0)this.emit("error",Error("Unexpected end of input"));this.destroy()};B.prototype.destroy=function(){if(!this._buffers)return;this.writable=!1,this._reads=null,this._buffers=null,this.emit("close")};B.prototype._processReadAllowingLess=function(n){this._reads.shift();let s=this._buffers[0];if(s.length>n.length)this._buffered-=n.length,this._buffers[0]=s.slice(n.length),n.func.call(this,s.slice(0,n.length));else this._buffered-=s.length,this._buffers.shift(),n.func.call(this,s)};B.prototype._processRead=function(n){this._reads.shift();let s=0,o=0,a=Buffer.alloc(n.length);while(s<n.length){let l=this._buffers[o++],c=Math.min(l.length,n.length-s);if(l.copy(a,s,0,c),s+=c,c!==l.length)this._buffers[--o]=l.slice(c)}if(o>0)this._buffers.splice(0,o);this._buffered-=n.length,n.func.call(this,a)};B.prototype._process=function(){try{while(this._buffered>0&&this._reads&&this._reads.length>0){let n=this._reads[0];if(n.allowLess)this._processReadAllowingLess(n);else if(this._buffered>=n.length)this._processRead(n);else break}if(this._buffers&&!this.writable)this._end()}catch(n){this.emit("error",n)}}});var ge=M(function(Zr){var F=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];Zr.getImagePasses=function(n,s){let o=[],a=n%8,l=s%8,c=(n-a)/8,u=(s-l)/8;for(let h=0;h<F.length;h++){let d=F[h],f=c*d.x.length,p=u*d.y.length;for(let g=0;g<d.x.length;g++)if(d.x[g]<a)f++;else break;for(let g=0;g<d.y.length;g++)if(d.y[g]<l)p++;else break;if(f>0&&p>0)o.push({width:f,height:p,index:h})}return o};Zr.getInterlaceIterator=function(n){return function(s,o,a){let l=s%F[a].x.length,c=(s-l)/F[a].x.length*8+F[a].x[l],u=o%F[a].y.length,h=(o-u)/F[a].y.length*8+F[a].y[u];return c*4+h*n*4}}});var be=M(function(gs,Qe){Qe.exports=function(s,o,a){let l=s+o-a,c=Math.abs(l-s),u=Math.abs(l-o),h=Math.abs(l-a);if(c<=u&&c<=h)return s;if(u<=h)return o;return a}});var ye=M(function(bs,tt){var et=ge(),ei=be();function Je(n,s,o){let a=n*s;if(o!==8)a=Math.ceil(a/(8/o));return a}var Y=tt.exports=function(n,s){let{width:o,height:a,interlace:l,bpp:c,depth:u}=n;if(this.read=s.read,this.write=s.write,this.complete=s.complete,this._imageIndex=0,this._images=[],l){let h=et.getImagePasses(o,a);for(let d=0;d<h.length;d++)this._images.push({byteWidth:Je(h[d].width,c,u),height:h[d].height,lineIndex:0})}else this._images.push({byteWidth:Je(o,c,u),height:a,lineIndex:0});if(u===8)this._xComparison=c;else if(u===16)this._xComparison=c*2;else this._xComparison=1};Y.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))};Y.prototype._unFilterType1=function(n,s,o){let a=this._xComparison,l=a-1;for(let c=0;c<o;c++){let u=n[1+c],h=c>l?s[c-a]:0;s[c]=u+h}};Y.prototype._unFilterType2=function(n,s,o){let a=this._lastLine;for(let l=0;l<o;l++){let c=n[1+l],u=a?a[l]:0;s[l]=c+u}};Y.prototype._unFilterType3=function(n,s,o){let a=this._xComparison,l=a-1,c=this._lastLine;for(let u=0;u<o;u++){let h=n[1+u],d=c?c[u]:0,f=u>l?s[u-a]:0,p=Math.floor((f+d)/2);s[u]=h+p}};Y.prototype._unFilterType4=function(n,s,o){let a=this._xComparison,l=a-1,c=this._lastLine;for(let u=0;u<o;u++){let h=n[1+u],d=c?c[u]:0,f=u>l?s[u-a]:0,p=u>l&&c?c[u-a]:0,g=ei(f,d,p);s[u]=h+g}};Y.prototype._reverseFilterLine=function(n){let s=n[0],o,a=this._images[this._imageIndex],l=a.byteWidth;if(s===0)o=n.slice(1,l+1);else switch(o=Buffer.alloc(l),s){case 1:this._unFilterType1(n,o,l);break;case 2:this._unFilterType2(n,o,l);break;case 3:this._unFilterType3(n,o,l);break;case 4:this._unFilterType4(n,o,l);break;default:throw Error("Unrecognised filter type - "+s)}if(this.write(o),a.lineIndex++,a.lineIndex>=a.height)this._lastLine=null,this._imageIndex++,a=this._images[this._imageIndex];else this._lastLine=o;if(a)this.read(a.byteWidth+1,this._reverseFilterLine.bind(this));else this._lastLine=null,this.complete()}});var nt=M(function(ys,it){var rt=wt("util"),Se=me(),ti=ye(),ri=it.exports=function(n){Se.call(this);let s=[],o=this;this._filter=new ti(n,{read:this.read.bind(this),write:function(a){s.push(a)},complete:function(){o.emit("complete",Buffer.concat(s))}}),this._filter.start()};rt.inherits(ri,Se)});var G=M(function(Ss,st){st.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}});var Ee=M(function(ws,ot){var we=[];(function(){for(let n=0;n<256;n++){let s=n;for(let o=0;o<8;o++)if(s&1)s=3988292384^s>>>1;else s=s>>>1;we[n]=s}})();var _e=ot.exports=function(){this._crc=-1};_e.prototype.write=function(n){for(let s=0;s<n.length;s++)this._crc=we[(this._crc^n[s])&255]^this._crc>>>8;return!0};_e.prototype.crc32=function(){return this._crc^-1};_e.crc32=function(n){let s=-1;for(let o=0;o<n.length;o++)s=we[(s^n[o])&255]^s>>>8;return s^-1}});var Ce=M(function(_s,at){var w=G(),ii=Ee(),T=at.exports=function(n,s){this._options=n,n.checkCRC=n.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[w.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[w.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[w.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[w.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[w.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[w.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=s.read,this.error=s.error,this.metadata=s.metadata,this.gamma=s.gamma,this.transColor=s.transColor,this.palette=s.palette,this.parsed=s.parsed,this.inflateData=s.inflateData,this.finished=s.finished,this.simpleTransparency=s.simpleTransparency,this.headersFinished=s.headersFinished||function(){}};T.prototype.start=function(){this.read(w.PNG_SIGNATURE.length,this._parseSignature.bind(this))};T.prototype._parseSignature=function(n){let s=w.PNG_SIGNATURE;for(let o=0;o<s.length;o++)if(n[o]!==s[o]){this.error(Error("Invalid file signature"));return}this.read(8,this._parseChunkBegin.bind(this))};T.prototype._parseChunkBegin=function(n){let s=n.readUInt32BE(0),o=n.readUInt32BE(4),a="";for(let c=4;c<8;c++)a+=String.fromCharCode(n[c]);let l=Boolean(n[4]&32);if(!this._hasIHDR&&o!==w.TYPE_IHDR){this.error(Error("Expected IHDR on beggining"));return}if(this._crc=new ii,this._crc.write(Buffer.from(a)),this._chunks[o])return this._chunks[o](s);if(!l){this.error(Error("Unsupported critical chunk type "+a));return}this.read(s+4,this._skipChunk.bind(this))};T.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))};T.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))};T.prototype._parseChunkEnd=function(n){let s=n.readInt32BE(0),o=this._crc.crc32();if(this._options.checkCRC&&o!==s){this.error(Error("Crc error - "+s+" - "+o));return}if(!this._hasIEND)this.read(8,this._parseChunkBegin.bind(this))};T.prototype._handleIHDR=function(n){this.read(n,this._parseIHDR.bind(this))};T.prototype._parseIHDR=function(n){this._crc.write(n);let s=n.readUInt32BE(0),o=n.readUInt32BE(4),a=n[8],l=n[9],c=n[10],u=n[11],h=n[12];if(a!==8&&a!==4&&a!==2&&a!==1&&a!==16){this.error(Error("Unsupported bit depth "+a));return}if(!(l in w.COLORTYPE_TO_BPP_MAP)){this.error(Error("Unsupported color type"));return}if(c!==0){this.error(Error("Unsupported compression method"));return}if(u!==0){this.error(Error("Unsupported filter method"));return}if(h!==0&&h!==1){this.error(Error("Unsupported interlace method"));return}this._colorType=l;let d=w.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:s,height:o,depth:a,interlace:Boolean(h),palette:Boolean(l&w.COLORTYPE_PALETTE),color:Boolean(l&w.COLORTYPE_COLOR),alpha:Boolean(l&w.COLORTYPE_ALPHA),bpp:d,colorType:l}),this._handleChunkEnd()};T.prototype._handlePLTE=function(n){this.read(n,this._parsePLTE.bind(this))};T.prototype._parsePLTE=function(n){this._crc.write(n);let s=Math.floor(n.length/3);for(let o=0;o<s;o++)this._palette.push([n[o*3],n[o*3+1],n[o*3+2],255]);this.palette(this._palette),this._handleChunkEnd()};T.prototype._handleTRNS=function(n){this.simpleTransparency(),this.read(n,this._parseTRNS.bind(this))};T.prototype._parseTRNS=function(n){if(this._crc.write(n),this._colorType===w.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error("Transparency chunk must be after palette"));return}if(n.length>this._palette.length){this.error(Error("More transparent colors than palette size"));return}for(let s=0;s<n.length;s++)this._palette[s][3]=n[s];this.palette(this._palette)}if(this._colorType===w.COLORTYPE_GRAYSCALE)this.transColor([n.readUInt16BE(0)]);if(this._colorType===w.COLORTYPE_COLOR)this.transColor([n.readUInt16BE(0),n.readUInt16BE(2),n.readUInt16BE(4)]);this._handleChunkEnd()};T.prototype._handleGAMA=function(n){this.read(n,this._parseGAMA.bind(this))};T.prototype._parseGAMA=function(n){this._crc.write(n),this.gamma(n.readUInt32BE(0)/w.GAMMA_DIVISION),this._handleChunkEnd()};T.prototype._handleIDAT=function(n){if(!this._emittedHeadersFinished)this._emittedHeadersFinished=!0,this.headersFinished();this.read(-n,this._parseIDAT.bind(this,n))};T.prototype._parseIDAT=function(n,s){if(this._crc.write(s),this._colorType===w.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error("Expected palette not found");this.inflateData(s);let o=n-s.length;if(o>0)this._handleIDAT(o);else this._handleChunkEnd()};T.prototype._handleIEND=function(n){this.read(n,this._parseIEND.bind(this))};T.prototype._parseIEND=function(n){if(this._crc.write(n),this._hasIEND=!0,this._handleChunkEnd(),this.finished)this.finished()}});var ke=M(function(ci){var re=ge(),ni=[function(){},function(n,s,o,a){if(a===s.length)throw Error("Ran out of data");let l=s[a];n[o]=l,n[o+1]=l,n[o+2]=l,n[o+3]=255},function(n,s,o,a){if(a+1>=s.length)throw Error("Ran out of data");let l=s[a];n[o]=l,n[o+1]=l,n[o+2]=l,n[o+3]=s[a+1]},function(n,s,o,a){if(a+2>=s.length)throw Error("Ran out of data");n[o]=s[a],n[o+1]=s[a+1],n[o+2]=s[a+2],n[o+3]=255},function(n,s,o,a){if(a+3>=s.length)throw Error("Ran out of data");n[o]=s[a],n[o+1]=s[a+1],n[o+2]=s[a+2],n[o+3]=s[a+3]}],si=[function(){},function(n,s,o,a){let l=s[0];n[o]=l,n[o+1]=l,n[o+2]=l,n[o+3]=a},function(n,s,o){let a=s[0];n[o]=a,n[o+1]=a,n[o+2]=a,n[o+3]=s[1]},function(n,s,o,a){n[o]=s[0],n[o+1]=s[1],n[o+2]=s[2],n[o+3]=a},function(n,s,o){n[o]=s[0],n[o+1]=s[1],n[o+2]=s[2],n[o+3]=s[3]}];function oi(n,s){let o=[],a=0;function l(){if(a===n.length)throw Error("Ran out of data");let c=n[a];a++;let u,h,d,f,p,g,m,b;switch(s){default:throw Error("unrecognised depth");case 16:m=n[a],a++,o.push((c<<8)+m);break;case 4:m=c&15,b=c>>4,o.push(b,m);break;case 2:p=c&3,g=c>>2&3,m=c>>4&3,b=c>>6&3,o.push(b,m,g,p);break;case 1:u=c&1,h=c>>1&1,d=c>>2&1,f=c>>3&1,p=c>>4&1,g=c>>5&1,m=c>>6&1,b=c>>7&1,o.push(b,m,g,p,f,d,h,u);break}}return{get:function(c){while(o.length<c)l();let u=o.slice(0,c);return o=o.slice(c),u},resetAfterLine:function(){o.length=0},end:function(){if(a!==n.length)throw Error("extra data found")}}}function ai(n,s,o,a,l,c){let{width:u,height:h,index:d}=n;for(let f=0;f<h;f++)for(let p=0;p<u;p++){let g=o(p,f,d);ni[a](s,l,g,c),c+=a}return c}function li(n,s,o,a,l,c){let{width:u,height:h,index:d}=n;for(let f=0;f<h;f++){for(let p=0;p<u;p++){let g=l.get(a),m=o(p,f,d);si[a](s,g,m,c)}l.resetAfterLine()}}ci.dataToBitMap=function(n,s){let{width:o,height:a,depth:l,bpp:c,interlace:u}=s,h;if(l!==8)h=oi(n,l);let d;if(l<=8)d=Buffer.alloc(o*a*4);else d=new Uint16Array(o*a*4);let f=Math.pow(2,l)-1,p=0,g,m;if(u)g=re.getImagePasses(o,a),m=re.getInterlaceIterator(o,a);else{let b=0;m=function(){let _=b;return b+=4,_},g=[{width:o,height:a}]}for(let b=0;b<g.length;b++)if(l===8)p=ai(g[b],d,m,c,n,p);else li(g[b],d,m,c,h,f);if(l===8){if(p!==n.length)throw Error("extra data found")}else h.end();return d}});var Te=M(function(Cs,lt){function hi(n,s,o,a,l){let c=0;for(let u=0;u<a;u++)for(let h=0;h<o;h++){let d=l[n[c]];if(!d)throw Error("index "+n[c]+" not in palette");for(let f=0;f<4;f++)s[c+f]=d[f];c+=4}}function di(n,s,o,a,l){let c=0;for(let u=0;u<a;u++)for(let h=0;h<o;h++){let d=!1;if(l.length===1){if(l[0]===n[c])d=!0}else if(l[0]===n[c]&&l[1]===n[c+1]&&l[2]===n[c+2])d=!0;if(d)for(let f=0;f<4;f++)s[c+f]=0;c+=4}}function fi(n,s,o,a,l){let c=255,u=Math.pow(2,l)-1,h=0;for(let d=0;d<a;d++)for(let f=0;f<o;f++){for(let p=0;p<4;p++)s[h+p]=Math.floor(n[h+p]*c/u+0.5);h+=4}}lt.exports=function(n,s,o=!1){let{depth:a,width:l,height:c,colorType:u,transColor:h,palette:d}=s,f=n;if(u===3)hi(n,f,l,c,d);else{if(h)di(n,f,l,c,h);if(a!==8&&!o){if(a===16)f=Buffer.alloc(l*c*4);fi(n,f,l,c,a)}}return f}});var dt=M(function(ks,ht){var ct=wt("util"),X=wt("zlib"),Ie=me(),pi=nt(),mi=Ce(),ut=ke(),gi=Te(),D=ht.exports=function(n){Ie.call(this),this._parser=new mi(n,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=n,this.writable=!0,this._parser.start()};ct.inherits(D,Ie);D.prototype._handleError=function(n){if(this.emit("error",n),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy)this._inflate.destroy();if(this._filter)this._filter.destroy(),this._filter.on("error",function(){});this.errord=!0};D.prototype._inflateData=function(n){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=X.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let o=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,a=Math.max(o,X.Z_MIN_CHUNK);this._inflate=X.createInflate({chunkSize:a});let l=o,c=this.emit.bind(this,"error");this._inflate.on("error",function(h){if(!l)return;c(h)}),this._filter.on("complete",this._complete.bind(this));let u=this._filter.write.bind(this._filter);this._inflate.on("data",function(h){if(!l)return;if(h.length>l)h=h.slice(0,l);l-=h.length,u(h)}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(n)};D.prototype._handleMetaData=function(n){this._metaData=n,this._bitmapInfo=Object.create(n),this._filter=new pi(this._bitmapInfo)};D.prototype._handleTransColor=function(n){this._bitmapInfo.transColor=n};D.prototype._handlePalette=function(n){this._bitmapInfo.palette=n};D.prototype._simpleTransparency=function(){this._metaData.alpha=!0};D.prototype._headersFinished=function(){this.emit("metadata",this._metaData)};D.prototype._finished=function(){if(this.errord)return;if(!this._inflate)this.emit("error","No Inflate block");else this._inflate.end()};D.prototype._complete=function(n){if(this.errord)return;let s;try{let o=ut.dataToBitMap(n,this._bitmapInfo);s=gi(o,this._bitmapInfo,this._options.skipRescale),o=null}catch(o){this._handleError(o);return}this.emit("parsed",s)}});var gt=M(function(Ts,mt){var k=G();mt.exports=function(n,s,o,a){let l=[k.COLORTYPE_COLOR_ALPHA,k.COLORTYPE_ALPHA].indexOf(a.colorType)!==-1;if(a.colorType===a.inputColorType){let _=function(){let C=new ArrayBuffer(2);return new DataView(C).setInt16(0,256,!0),new Int16Array(C)[0]!==256}();if(a.bitDepth===8||a.bitDepth===16&&_)return n}let c=a.bitDepth!==16?n:new Uint16Array(n.buffer),u=255,h=k.COLORTYPE_TO_BPP_MAP[a.inputColorType];if(h===4&&!a.inputHasAlpha)h=3;let d=k.COLORTYPE_TO_BPP_MAP[a.colorType];if(a.bitDepth===16)u=65535,d*=2;let f=Buffer.alloc(s*o*d),p=0,g=0,m=a.bgColor||{};if(m.red===void 0)m.red=u;if(m.green===void 0)m.green=u;if(m.blue===void 0)m.blue=u;function b(){let _,C,S,y=u;switch(a.inputColorType){case k.COLORTYPE_COLOR_ALPHA:y=c[p+3],_=c[p],C=c[p+1],S=c[p+2];break;case k.COLORTYPE_COLOR:_=c[p],C=c[p+1],S=c[p+2];break;case k.COLORTYPE_ALPHA:y=c[p+1],_=c[p],C=_,S=_;break;case k.COLORTYPE_GRAYSCALE:_=c[p],C=_,S=_;break;default:throw Error("input color type:"+a.inputColorType+" is not supported at present")}if(a.inputHasAlpha){if(!l)y/=u,_=Math.min(Math.max(Math.round((1-y)*m.red+y*_),0),u),C=Math.min(Math.max(Math.round((1-y)*m.green+y*C),0),u),S=Math.min(Math.max(Math.round((1-y)*m.blue+y*S),0),u)}return{red:_,green:C,blue:S,alpha:y}}for(let _=0;_<o;_++)for(let C=0;C<s;C++){let S=b(c,p);switch(a.colorType){case k.COLORTYPE_COLOR_ALPHA:case k.COLORTYPE_COLOR:if(a.bitDepth===8){if(f[g]=S.red,f[g+1]=S.green,f[g+2]=S.blue,l)f[g+3]=S.alpha}else if(f.writeUInt16BE(S.red,g),f.writeUInt16BE(S.green,g+2),f.writeUInt16BE(S.blue,g+4),l)f.writeUInt16BE(S.alpha,g+6);break;case k.COLORTYPE_ALPHA:case k.COLORTYPE_GRAYSCALE:{let y=(S.red+S.green+S.blue)/3;if(a.bitDepth===8){if(f[g]=y,l)f[g+1]=S.alpha}else if(f.writeUInt16BE(y,g),l)f.writeUInt16BE(S.alpha,g+2);break}default:throw Error("unrecognised color Type "+a.colorType)}p+=h,g+=d}return f}});var St=M(function(Is,yt){var bt=be();function bi(n,s,o,a,l){for(let c=0;c<o;c++)a[l+c]=n[s+c]}function yi(n,s,o){let a=0,l=s+o;for(let c=s;c<l;c++)a+=Math.abs(n[c]);return a}function Si(n,s,o,a,l,c){for(let u=0;u<o;u++){let h=u>=c?n[s+u-c]:0,d=n[s+u]-h;a[l+u]=d}}function wi(n,s,o,a){let l=0;for(let c=0;c<o;c++){let u=c>=a?n[s+c-a]:0,h=n[s+c]-u;l+=Math.abs(h)}return l}function _i(n,s,o,a,l){for(let c=0;c<o;c++){let u=s>0?n[s+c-o]:0,h=n[s+c]-u;a[l+c]=h}}function Ei(n,s,o){let a=0,l=s+o;for(let c=s;c<l;c++){let u=s>0?n[c-o]:0,h=n[c]-u;a+=Math.abs(h)}return a}function Ci(n,s,o,a,l,c){for(let u=0;u<o;u++){let h=u>=c?n[s+u-c]:0,d=s>0?n[s+u-o]:0,f=n[s+u]-(h+d>>1);a[l+u]=f}}function ki(n,s,o,a){let l=0;for(let c=0;c<o;c++){let u=c>=a?n[s+c-a]:0,h=s>0?n[s+c-o]:0,d=n[s+c]-(u+h>>1);l+=Math.abs(d)}return l}function Ti(n,s,o,a,l,c){for(let u=0;u<o;u++){let h=u>=c?n[s+u-c]:0,d=s>0?n[s+u-o]:0,f=s>0&&u>=c?n[s+u-(o+c)]:0,p=n[s+u]-bt(h,d,f);a[l+u]=p}}function Ii(n,s,o,a){let l=0;for(let c=0;c<o;c++){let u=c>=a?n[s+c-a]:0,h=s>0?n[s+c-o]:0,d=s>0&&c>=a?n[s+c-(o+a)]:0,f=n[s+c]-bt(u,h,d);l+=Math.abs(f)}return l}var xi={0:bi,1:Si,2:_i,3:Ci,4:Ti},Oi={0:yi,1:wi,2:Ei,3:ki,4:Ii};yt.exports=function(n,s,o,a,l){let c;if(!("filterType"in a)||a.filterType===-1)c=[0,1,2,3,4];else if(typeof a.filterType==="number")c=[a.filterType];else throw Error("unrecognised filter types");if(a.bitDepth===16)l*=2;let u=s*l,h=0,d=0,f=Buffer.alloc((u+1)*o),p=c[0];for(let g=0;g<o;g++){if(c.length>1){let m=1/0;for(let b=0;b<c.length;b++){let _=Oi[c[b]](n,d,u,l);if(_<m)p=c[b],m=_}}f[h]=p,h++,xi[p](n,d,u,f,h,l),h+=u,d+=u}return f}});var xe=M(function(xs,Ct){var E=G(),_t=Ee(),Ai=gt(),Ri=St(),Et=wt("zlib"),U=Ct.exports=function(n){if(this._options=n,n.deflateChunkSize=n.deflateChunkSize||32768,n.deflateLevel=n.deflateLevel!=null?n.deflateLevel:9,n.deflateStrategy=n.deflateStrategy!=null?n.deflateStrategy:3,n.inputHasAlpha=n.inputHasAlpha!=null?n.inputHasAlpha:!0,n.deflateFactory=n.deflateFactory||Et.createDeflate,n.bitDepth=n.bitDepth||8,n.colorType=typeof n.colorType==="number"?n.colorType:E.COLORTYPE_COLOR_ALPHA,n.inputColorType=typeof n.inputColorType==="number"?n.inputColorType:E.COLORTYPE_COLOR_ALPHA,[E.COLORTYPE_GRAYSCALE,E.COLORTYPE_COLOR,E.COLORTYPE_COLOR_ALPHA,E.COLORTYPE_ALPHA].indexOf(n.colorType)===-1)throw Error("option color type:"+n.colorType+" is not supported at present");if([E.COLORTYPE_GRAYSCALE,E.COLORTYPE_COLOR,E.COLORTYPE_COLOR_ALPHA,E.COLORTYPE_ALPHA].indexOf(n.inputColorType)===-1)throw Error("option input color type:"+n.inputColorType+" is not supported at present");if(n.bitDepth!==8&&n.bitDepth!==16)throw Error("option bit depth:"+n.bitDepth+" is not supported at present")};U.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}};U.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())};U.prototype.filterData=function(n,s,o){let a=Ai(n,s,o,this._options),l=E.COLORTYPE_TO_BPP_MAP[this._options.colorType];return Ri(a,s,o,this._options,l)};U.prototype._packChunk=function(n,s){let o=s?s.length:0,a=Buffer.alloc(o+12);if(a.writeUInt32BE(o,0),a.writeUInt32BE(n,4),s)s.copy(a,8);return a.writeInt32BE(_t.crc32(a.slice(4,a.length-4)),a.length-4),a};U.prototype.packGAMA=function(n){let s=Buffer.alloc(4);return s.writeUInt32BE(Math.floor(n*E.GAMMA_DIVISION),0),this._packChunk(E.TYPE_gAMA,s)};U.prototype.packIHDR=function(n,s){let o=Buffer.alloc(13);return o.writeUInt32BE(n,0),o.writeUInt32BE(s,4),o[8]=this._options.bitDepth,o[9]=this._options.colorType,o[10]=0,o[11]=0,o[12]=0,this._packChunk(E.TYPE_IHDR,o)};U.prototype.packIDAT=function(n){return this._packChunk(E.TYPE_IDAT,n)};U.prototype.packIEND=function(){return this._packChunk(E.TYPE_IEND,null)}});var Ot=M(function(Os,xt){var kt=wt("util"),Oe=wt("stream"),Tt=G(),vi=xe(),It=xt.exports=function(n){Oe.call(this);let s=n||{};this._packer=new vi(s),this._deflate=this._packer.createDeflate(),this.readable=!0};kt.inherits(It,Oe);It.prototype.pack=function(n,s,o,a){if(this.emit("data",Buffer.from(Tt.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(s,o)),a)this.emit("data",this._packer.packGAMA(a));let l=this._packer.filterData(n,s,o);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(c){this.emit("data",this._packer.packIDAT(c))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(l)}});var Bt=M(function(Z,Mt){var At=wt("assert").ok,P=wt("zlib"),Pt=wt("util"),Rt=wt("buffer").kMaxLength;function H(n){if(!(this instanceof H))return new H(n);if(n&&n.chunkSize<P.Z_MIN_CHUNK)n.chunkSize=P.Z_MIN_CHUNK;if(P.Inflate.call(this,n),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,n&&n.maxLength!=null)this._maxLength=n.maxLength}function Pi(n){return new H(n)}function vt(n,s){if(s)process.nextTick(s);if(!n._handle)return;n._handle.close(),n._handle=null}H.prototype._processChunk=function(n,s,o){if(typeof o==="function")return P.Inflate._processChunk.call(this,n,s,o);let a=this,l=n&&n.length,c=this._chunkSize-this._offset,u=this._maxLength,h=0,d=[],f=0,p;this.on("error",function(_){p=_});function g(_,C){if(a._hadError)return;let S=c-C;if(At(S>=0,"have should not go down"),S>0){let y=a._buffer.slice(a._offset,a._offset+S);if(a._offset+=S,y.length>u)y=y.slice(0,u);if(d.push(y),f+=y.length,u-=y.length,u===0)return!1}if(C===0||a._offset>=a._chunkSize)c=a._chunkSize,a._offset=0,a._buffer=Buffer.allocUnsafe(a._chunkSize);if(C===0)return h+=l-_,l=_,!0;return!1}At(this._handle,"zlib binding closed");let m;do m=this._handle.writeSync(s,n,h,l,this._buffer,this._offset,c),m=m||this._writeState;while(!this._hadError&&g(m[0],m[1]));if(this._hadError)throw p;if(f>=Rt)throw vt(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+Rt.toString(16)+" bytes");let b=Buffer.concat(d,f);return vt(this),b};Pt.inherits(H,P.Inflate);function Li(n,s){if(typeof s==="string")s=Buffer.from(s);if(!(s instanceof Buffer))throw TypeError("Not a string or buffer");let o=n._finishFlushFlag;if(o==null)o=P.Z_FINISH;return n._processChunk(s,o)}function Lt(n,s){return Li(new H(s),n)}Mt.exports=Z=Lt;Z.Inflate=H;Z.createInflate=Pi;Z.inflateSync=Lt});var Ae=M(function(As,Ft){var Dt=Ft.exports=function(n){this._buffer=n,this._reads=[]};Dt.prototype.read=function(n,s){this._reads.push({length:Math.abs(n),allowLess:n<0,func:s})};Dt.prototype.process=function(){while(this._reads.length>0&&this._buffer.length){let n=this._reads[0];if(this._buffer.length&&(this._buffer.length>=n.length||n.allowLess)){this._reads.shift();let s=this._buffer;this._buffer=s.slice(n.length),n.func.call(this,s.slice(0,n.length))}else break}if(this._reads.length>0)throw Error("There are some read requests waitng on finished stream");if(this._buffer.length>0)throw Error("unrecognised content at end of stream")}});var Ut=M(function(Di){var Mi=Ae(),Bi=ye();Di.process=function(n,s){let o=[],a=new Mi(n);return new Bi(s,{read:a.read.bind(a),write:function(c){o.push(c)},complete:function(){}}).start(),a.process(),Buffer.concat(o)}});var qt=M(function(vs,zt){var Wt=!0,ie=wt("zlib"),Ni=Bt();if(!ie.deflateSync)Wt=!1;var Ui=Ae(),Ht=Ut(),Wi=Ce(),Vt=ke(),Hi=Te();zt.exports=function(n,s){if(!Wt)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let o;function a(O){o=O}let l;function c(O){l=O}function u(O){l.transColor=O}function h(O){l.palette=O}function d(){l.alpha=!0}let f;function p(O){f=O}let g=[];function m(O){g.push(O)}let b=new Ui(n);if(new Wi(s,{read:b.read.bind(b),error:a,metadata:c,gamma:p,palette:h,transColor:u,inflateData:m,simpleTransparency:d}).start(),b.process(),o)throw o;let C=Buffer.concat(g);g.length=0;let S;if(l.interlace)S=ie.inflateSync(C);else{let z=((l.width*l.bpp*l.depth+7>>3)+1)*l.height;S=Ni(C,{chunkSize:z,maxLength:z})}if(C=null,!S||!S.length)throw Error("bad png - invalid inflate data response");let y=Ht.process(S,l);C=null;let R=Vt.dataToBitMap(y,l);y=null;let W=Hi(R,l,s.skipRescale);return l.data=W,l.gamma=f||0,l}});var jt=M(function(Ls,Xt){var Yt=!0,ne=wt("zlib");if(!ne.deflateSync)Yt=!1;var Gt=G(),Vi=xe();Xt.exports=function(n,s){if(!Yt)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let a=new Vi(s||{}),l=[];if(l.push(Buffer.from(Gt.PNG_SIGNATURE)),l.push(a.packIHDR(n.width,n.height)),n.gamma)l.push(a.packGAMA(n.gamma));let c=a.filterData(n.data,n.width,n.height),u=ne.deflateSync(c,a.getDeflateOptions());if(c=null,!u||!u.length)throw Error("bad png - invalid compressed data response");return l.push(a.packIDAT(u)),l.push(a.packIEND()),Buffer.concat(l)}});var Kt=M(function(qi){var $i=qt(),zi=jt();qi.read=function(n,s){return $i(n,s||{})};qi.write=function(n,s){return zi(n,s)}});var GF=M(function(Zi){var Zt=wt("util"),Re=wt("stream"),Xi=dt(),ji=Ot(),Ki=Kt(),A=Zi.PNG=function(n){if(Re.call(this),n=n||{},this.width=n.width|0,this.height=n.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,n.fill&&this.data)this.data.fill(0);this.gamma=0,this.readable=this.writable=!0,this._parser=new Xi(n),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(s){this.data=s,this.emit("parsed",s)}.bind(this)),this._packer=new ji(n),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};Zt.inherits(A,Re);A.sync=Ki;A.prototype.pack=function(){if(!this.data||!this.data.length)return this.emit("error","No data provided"),this;return process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this};A.prototype.parse=function(n,s){if(s){let o,a;o=function(l){this.removeListener("error",a),this.data=l,s(null,this)}.bind(this),a=function(l){this.removeListener("parsed",o),s(l,null)}.bind(this),this.once("parsed",o),this.once("error",a)}return this.end(n),this};A.prototype.write=function(n){return this._parser.write(n),!0};A.prototype.end=function(n){this._parser.end(n)};A.prototype._metadata=function(n){this.width=n.width,this.height=n.height,this.emit("metadata",n)};A.prototype._gamma=function(n){this.gamma=n};A.prototype._handleClose=function(){if(!this._parser.writable&&!this._packer.readable)this.emit("close")};A.bitblt=function(n,s,o,a,l,c,u,h){if(o|=0,a|=0,l|=0,c|=0,u|=0,h|=0,o>n.width||a>n.height||o+l>n.width||a+c>n.height)throw Error("bitblt reading outside image");if(u>s.width||h>s.height||u+l>s.width||h+c>s.height)throw Error("bitblt writing outside image");for(let d=0;d<c;d++)n.data.copy(s.data,(h+d)*s.width+u<<2,(a+d)*n.width+o<<2,(a+d)*n.width+o+l<<2)};A.prototype.bitblt=function(n,s,o,a,l,c,u){return A.bitblt(this,n,s,o,a,l,c,u),this};A.adjustGamma=function(n){if(n.gamma){for(let s=0;s<n.height;s++)for(let o=0;o<n.width;o++){let a=n.width*s+o<<2;for(let l=0;l<3;l++){let c=n.data[a+l]/255;c=Math.pow(c,0.45454545454545453/n.gamma),n.data[a+l]=Math.round(c*255)}}n.gamma=0}};A.prototype.adjustGamma=function(){A.adjustGamma(this)}});function E5(n,s,o,a){TR(n,s,[{x:Math.floor(o),y:Math.floor(a)}],"swipe")}function I5(n,s){let o=(s.left+s.right)/2,a=(s.top+s.bottom)/2,l=s.bottom-s.top,c=s.right-s.left;switch(n){case"down":return{startX:o,startY:s.top+l*0.25,endX:o,endY:s.top+l*0.75};case"up":return{startX:o,startY:s.bottom-l*0.25,endX:o,endY:s.top+l*0.25};case"right":return{startX:s.left+c*0.25,startY:a,endX:s.left+c*0.75,endY:a};case"left":return{startX:s.right-c*0.25,startY:a,endX:s.left+c*0.25,endY:a}}}var rr={up:"down",down:"up",left:"right",right:"left"},ir=(n)=>{let{direction:s,gestureType:o}=n;if(!s)return{error:"direction is required"};if(!o||o==="swipeFingerTowardsDirection")return{direction:s,message:`Swiping ${s} (finger gesture)`};return{direction:rr[s],message:`Scrolling ${s} to reveal content ${s==="up"?"above":s==="down"?"below":s==="left"?"from left":"from right"}`}},Yc=(n)=>ir(n);class Jc{parser;constructor(n=new K){this.parser=n}extract(n){if(!n?.hierarchy)return;let s=[],o,a=[],l=n.windows?.filter((u)=>u.hierarchy)??[];if(this.parser.traverseNode(n.hierarchy,(u,h)=>{let d=this.parser.extractNodeProperties(u),f=this.getAttribute(d,["resource-id","resourceId"]);if(f&&f.startsWith("navigation.")&&f.endsWith("Destination"))o=f.replace("navigation.","");if(this.getAttribute(d,["selected"])==="true"){let p=this.extractSelectedElement(u,d,f);if(p)s.push(p)}if(l.length===0)this.collectModalStack(a,d,h)}),l.length>0)this.collectWindowModals(a,l);let c=this.normalizeModalStack(a);if(s.length===0&&!o&&c.length===0)return;return{selectedElements:s,destinationId:o,modalStack:c.length>0?c:void 0}}extractSelectedElement(n,s,o){let a={},l=this.getAttribute(s,["text"]),c=this.getAttribute(s,["content-desc","contentDesc"]);if(l)a.text=l;if(o)a.resourceId=o;if(c)a.contentDesc=c;if(!a.text&&n.node){let u=this.findTextInChildren(n.node);if(u)a.text=u}return a.text||a.resourceId||a.contentDesc?a:void 0}collectWindowModals(n,s){for(let[o,a]of s.entries()){let l=a.id??void 0,c=a.type!==void 0?String(a.type):void 0,u=a.windowLayer??o;this.parser.traverseNode(a.hierarchy,(h,d)=>{let f=this.parser.extractNodeProperties(h);this.collectModalStack(n,f,u+d,{windowId:l,windowType:c})})}}extractFromObservation(n){if(!n?.viewHierarchy)return;let s=this.extract(n.viewHierarchy),o=s?.selectedElements??[];if(o.length>0){let l=this.applySelectedState(o,{method:"accessibility",confidence:1,reason:"selected attribute present in view hierarchy"});return{...s,selectedElements:l}}let a=n.selectedElements??[];if(a.length>0){if(s)return{...s,selectedElements:a};return{selectedElements:a}}return s}applySelectedState(n,s){return n.map((o)=>({...o,selectedState:o.selectedState??s}))}findTextInChildren(n){if(Array.isArray(n))for(let s of n){let o=this.parser.extractNodeProperties(s),a=this.getAttribute(o,["text"]);if(a)return a;if(!s.node)continue;let l=this.findTextInChildren(s.node);if(l)return l}else if(n&&typeof n==="object"){let s=this.parser.extractNodeProperties(n),o=this.getAttribute(s,["text"]);if(o)return o;if(n.node)return this.findTextInChildren(n.node)}return}getAttribute(n,s){for(let o of s){let a=n[o];if(typeof a==="string"&&a!=="")return a}return}collectModalStack(n,s,o,a){let l=this.getAttribute(s,["class","className"]);if(!l)return;let c=this.classifyModalType(l);if(!c)return;let u=this.getModalIdentifier(s,l),h=this.getWindowId(s,a?.windowId,c,{modalId:u,className:l}),d=this.getWindowType(s,a?.windowType);n.push({type:c,identifier:u,layer:o,windowId:h,windowType:d})}getWindowId(n,s,o,{modalId:a,className:l}){let c=this.getAttribute(n,["window-id","windowId","window_id"]),u=c?Number(c):NaN;if(Number.isFinite(u))return u;if(s!==void 0)return s;let h=`${o}:${a??l}`;return this.hashToId(h)}getWindowType(n,s){return this.getAttribute(n,["window-type","windowType","window_type"])??s}classifyModalType(n){let s=n.toLowerCase();if(s.includes("alert")||s.includes("dialog"))return"dialog";if(s.includes("actionsheet")||s.includes("sheet"))return"bottomsheet";if(s.includes("popover"))return"popup";if(s.includes("menu"))return"menu";if(s.includes("modal")||s.includes("presentation"))return"overlay";return null}getModalIdentifier(n,s){return this.getAttribute(n,["resource-id","resourceId","content-desc","contentDesc","text"])??s}hashToId(n){let s=0;for(let o=0;o<n.length;o+=1)s=s*31+n.charCodeAt(o)>>>0;return s}normalizeModalStack(n){if(n.length===0)return[];let s=new Map;for(let o of n){let a=o.identifier??`${o.type}-${o.layer}`;if(!s.has(a))s.set(a,o)}return Array.from(s.values()).sort((o,a)=>o.layer-a.layer).map((o,a)=>({...o,layer:a}))}static createScrollPosition(n){if(!n.lookFor)return;let s=Yc(n);if(!s.direction)return;let o={targetElement:{text:n.lookFor.text,resourceId:n.lookFor.elementId},direction:s.direction};if(n.container)o.container={text:n.container.text,resourceId:n.container.elementId};if(n.speed)o.speed=n.speed;return o}}var nr="Element subtree:",sr=/\{\{(-?[\d.]+), (-?[\d.]+)\}, \{(-?[\d.]+), (-?[\d.]+)\}\}/,or="(?=$|, (?:(?:identifier|label|value|placeholderValue): |(?:Selected|Disabled|Focused)(?:,|$)))",ar=["identifier","label","value"],cr=ar.map((n)=>[n,new RegExp(`, ${n}: '(.*?)'${or}`)]),ur=new Set(["Button","Cell","Link","Switch","Key"]);function hr(n){let s=sr.exec(n);if(!s)return;let[o,a,l,c]=s.slice(1).map(Number);return{left:o,top:a,right:o+l,bottom:a+c}}function dr(n){let s=/^(\s*)(?:\u2192)?([A-Za-z]+)((?:,.*)?)$/.exec(n);if(!s)return;let[,o,a,l]=s,c={depth:o.length,type:a,frame:hr(l)};for(let[u,h]of cr){let d=h.exec(l)?.[1];if(d!==void 0)c[u]=d}return c}function fr(n){let s=n.replace(/\r\n/g,`
|
|
2
|
+
import{Fr,v,dn,N,lt,Ut,ft,K,fe,VR,jk,rs,Wr,As,x9,Hb,ur,xoe,No,x}from"./chunk-sfqe223f.js";import{i,Uf,er,e}from"./chunk-r0vp315h.js";import{Pu,$v,To,Pn,Hv,iz,La,ad}from"./chunk-4vxeq0vd.js";import{r,t}from"./chunk-2b39zyxc.js";import{Ft,M,Pt}from"./chunk-j69g8b50.js";var ge=M(function(ms,Ze){var Ke=Pt("util"),me=Pt("stream"),B=Ze.exports=function(){me.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};Ke.inherits(B,me);B.prototype.read=function(n,s){this._reads.push({length:Math.abs(n),allowLess:n<0,func:s}),process.nextTick(function(){if(this._process(),this._paused&&this._reads&&this._reads.length>0)this._paused=!1,this.emit("drain")}.bind(this))};B.prototype.write=function(n,s){if(!this.writable)return this.emit("error",Error("Stream not writable")),!1;let o;if(Buffer.isBuffer(n))o=n;else o=Buffer.from(n,s||this._encoding);if(this._buffers.push(o),this._buffered+=o.length,this._process(),this._reads&&this._reads.length===0)this._paused=!0;return this.writable&&!this._paused};B.prototype.end=function(n,s){if(n)this.write(n,s);if(this.writable=!1,!this._buffers)return;if(this._buffers.length===0)this._end();else this._buffers.push(null),this._process()};B.prototype.destroySoon=B.prototype.end;B.prototype._end=function(){if(this._reads.length>0)this.emit("error",Error("Unexpected end of input"));this.destroy()};B.prototype.destroy=function(){if(!this._buffers)return;this.writable=!1,this._reads=null,this._buffers=null,this.emit("close")};B.prototype._processReadAllowingLess=function(n){this._reads.shift();let s=this._buffers[0];if(s.length>n.length)this._buffered-=n.length,this._buffers[0]=s.slice(n.length),n.func.call(this,s.slice(0,n.length));else this._buffered-=s.length,this._buffers.shift(),n.func.call(this,s)};B.prototype._processRead=function(n){this._reads.shift();let s=0,o=0,a=Buffer.alloc(n.length);while(s<n.length){let l=this._buffers[o++],c=Math.min(l.length,n.length-s);if(l.copy(a,s,0,c),s+=c,c!==l.length)this._buffers[--o]=l.slice(c)}if(o>0)this._buffers.splice(0,o);this._buffered-=n.length,n.func.call(this,a)};B.prototype._process=function(){try{while(this._buffered>0&&this._reads&&this._reads.length>0){let n=this._reads[0];if(n.allowLess)this._processReadAllowingLess(n);else if(this._buffered>=n.length)this._processRead(n);else break}if(this._buffers&&!this.writable)this._end()}catch(n){this.emit("error",n)}}});var be=M(function(Zr){var F=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];Zr.getImagePasses=function(n,s){let o=[],a=n%8,l=s%8,c=(n-a)/8,u=(s-l)/8;for(let h=0;h<F.length;h++){let d=F[h],f=c*d.x.length,p=u*d.y.length;for(let g=0;g<d.x.length;g++)if(d.x[g]<a)f++;else break;for(let g=0;g<d.y.length;g++)if(d.y[g]<l)p++;else break;if(f>0&&p>0)o.push({width:f,height:p,index:h})}return o};Zr.getInterlaceIterator=function(n){return function(s,o,a){let l=s%F[a].x.length,c=(s-l)/F[a].x.length*8+F[a].x[l],u=o%F[a].y.length,h=(o-u)/F[a].y.length*8+F[a].y[u];return c*4+h*n*4}}});var ye=M(function(bs,Qe){Qe.exports=function(s,o,a){let l=s+o-a,c=Math.abs(l-s),u=Math.abs(l-o),h=Math.abs(l-a);if(c<=u&&c<=h)return s;if(u<=h)return o;return a}});var Se=M(function(ys,tt){var et=be(),ei=ye();function Je(n,s,o){let a=n*s;if(o!==8)a=Math.ceil(a/(8/o));return a}var Y=tt.exports=function(n,s){let{width:o,height:a,interlace:l,bpp:c,depth:u}=n;if(this.read=s.read,this.write=s.write,this.complete=s.complete,this._imageIndex=0,this._images=[],l){let h=et.getImagePasses(o,a);for(let d=0;d<h.length;d++)this._images.push({byteWidth:Je(h[d].width,c,u),height:h[d].height,lineIndex:0})}else this._images.push({byteWidth:Je(o,c,u),height:a,lineIndex:0});if(u===8)this._xComparison=c;else if(u===16)this._xComparison=c*2;else this._xComparison=1};Y.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))};Y.prototype._unFilterType1=function(n,s,o){let a=this._xComparison,l=a-1;for(let c=0;c<o;c++){let u=n[1+c],h=c>l?s[c-a]:0;s[c]=u+h}};Y.prototype._unFilterType2=function(n,s,o){let a=this._lastLine;for(let l=0;l<o;l++){let c=n[1+l],u=a?a[l]:0;s[l]=c+u}};Y.prototype._unFilterType3=function(n,s,o){let a=this._xComparison,l=a-1,c=this._lastLine;for(let u=0;u<o;u++){let h=n[1+u],d=c?c[u]:0,f=u>l?s[u-a]:0,p=Math.floor((f+d)/2);s[u]=h+p}};Y.prototype._unFilterType4=function(n,s,o){let a=this._xComparison,l=a-1,c=this._lastLine;for(let u=0;u<o;u++){let h=n[1+u],d=c?c[u]:0,f=u>l?s[u-a]:0,p=u>l&&c?c[u-a]:0,g=ei(f,d,p);s[u]=h+g}};Y.prototype._reverseFilterLine=function(n){let s=n[0],o,a=this._images[this._imageIndex],l=a.byteWidth;if(s===0)o=n.slice(1,l+1);else switch(o=Buffer.alloc(l),s){case 1:this._unFilterType1(n,o,l);break;case 2:this._unFilterType2(n,o,l);break;case 3:this._unFilterType3(n,o,l);break;case 4:this._unFilterType4(n,o,l);break;default:throw Error("Unrecognised filter type - "+s)}if(this.write(o),a.lineIndex++,a.lineIndex>=a.height)this._lastLine=null,this._imageIndex++,a=this._images[this._imageIndex];else this._lastLine=o;if(a)this.read(a.byteWidth+1,this._reverseFilterLine.bind(this));else this._lastLine=null,this.complete()}});var nt=M(function(Ss,it){var rt=Pt("util"),we=ge(),ti=Se(),ri=it.exports=function(n){we.call(this);let s=[],o=this;this._filter=new ti(n,{read:this.read.bind(this),write:function(a){s.push(a)},complete:function(){o.emit("complete",Buffer.concat(s))}}),this._filter.start()};rt.inherits(ri,we)});var G=M(function(ws,st){st.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}});var Ce=M(function(_s,ot){var _e=[];(function(){for(let n=0;n<256;n++){let s=n;for(let o=0;o<8;o++)if(s&1)s=3988292384^s>>>1;else s=s>>>1;_e[n]=s}})();var Ee=ot.exports=function(){this._crc=-1};Ee.prototype.write=function(n){for(let s=0;s<n.length;s++)this._crc=_e[(this._crc^n[s])&255]^this._crc>>>8;return!0};Ee.prototype.crc32=function(){return this._crc^-1};Ee.crc32=function(n){let s=-1;for(let o=0;o<n.length;o++)s=_e[(s^n[o])&255]^s>>>8;return s^-1}});var ke=M(function(Es,at){var w=G(),ii=Ce(),T=at.exports=function(n,s){this._options=n,n.checkCRC=n.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[w.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[w.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[w.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[w.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[w.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[w.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=s.read,this.error=s.error,this.metadata=s.metadata,this.gamma=s.gamma,this.transColor=s.transColor,this.palette=s.palette,this.parsed=s.parsed,this.inflateData=s.inflateData,this.finished=s.finished,this.simpleTransparency=s.simpleTransparency,this.headersFinished=s.headersFinished||function(){}};T.prototype.start=function(){this.read(w.PNG_SIGNATURE.length,this._parseSignature.bind(this))};T.prototype._parseSignature=function(n){let s=w.PNG_SIGNATURE;for(let o=0;o<s.length;o++)if(n[o]!==s[o]){this.error(Error("Invalid file signature"));return}this.read(8,this._parseChunkBegin.bind(this))};T.prototype._parseChunkBegin=function(n){let s=n.readUInt32BE(0),o=n.readUInt32BE(4),a="";for(let c=4;c<8;c++)a+=String.fromCharCode(n[c]);let l=Boolean(n[4]&32);if(!this._hasIHDR&&o!==w.TYPE_IHDR){this.error(Error("Expected IHDR on beggining"));return}if(this._crc=new ii,this._crc.write(Buffer.from(a)),this._chunks[o])return this._chunks[o](s);if(!l){this.error(Error("Unsupported critical chunk type "+a));return}this.read(s+4,this._skipChunk.bind(this))};T.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))};T.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))};T.prototype._parseChunkEnd=function(n){let s=n.readInt32BE(0),o=this._crc.crc32();if(this._options.checkCRC&&o!==s){this.error(Error("Crc error - "+s+" - "+o));return}if(!this._hasIEND)this.read(8,this._parseChunkBegin.bind(this))};T.prototype._handleIHDR=function(n){this.read(n,this._parseIHDR.bind(this))};T.prototype._parseIHDR=function(n){this._crc.write(n);let s=n.readUInt32BE(0),o=n.readUInt32BE(4),a=n[8],l=n[9],c=n[10],u=n[11],h=n[12];if(a!==8&&a!==4&&a!==2&&a!==1&&a!==16){this.error(Error("Unsupported bit depth "+a));return}if(!(l in w.COLORTYPE_TO_BPP_MAP)){this.error(Error("Unsupported color type"));return}if(c!==0){this.error(Error("Unsupported compression method"));return}if(u!==0){this.error(Error("Unsupported filter method"));return}if(h!==0&&h!==1){this.error(Error("Unsupported interlace method"));return}this._colorType=l;let d=w.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:s,height:o,depth:a,interlace:Boolean(h),palette:Boolean(l&w.COLORTYPE_PALETTE),color:Boolean(l&w.COLORTYPE_COLOR),alpha:Boolean(l&w.COLORTYPE_ALPHA),bpp:d,colorType:l}),this._handleChunkEnd()};T.prototype._handlePLTE=function(n){this.read(n,this._parsePLTE.bind(this))};T.prototype._parsePLTE=function(n){this._crc.write(n);let s=Math.floor(n.length/3);for(let o=0;o<s;o++)this._palette.push([n[o*3],n[o*3+1],n[o*3+2],255]);this.palette(this._palette),this._handleChunkEnd()};T.prototype._handleTRNS=function(n){this.simpleTransparency(),this.read(n,this._parseTRNS.bind(this))};T.prototype._parseTRNS=function(n){if(this._crc.write(n),this._colorType===w.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error("Transparency chunk must be after palette"));return}if(n.length>this._palette.length){this.error(Error("More transparent colors than palette size"));return}for(let s=0;s<n.length;s++)this._palette[s][3]=n[s];this.palette(this._palette)}if(this._colorType===w.COLORTYPE_GRAYSCALE)this.transColor([n.readUInt16BE(0)]);if(this._colorType===w.COLORTYPE_COLOR)this.transColor([n.readUInt16BE(0),n.readUInt16BE(2),n.readUInt16BE(4)]);this._handleChunkEnd()};T.prototype._handleGAMA=function(n){this.read(n,this._parseGAMA.bind(this))};T.prototype._parseGAMA=function(n){this._crc.write(n),this.gamma(n.readUInt32BE(0)/w.GAMMA_DIVISION),this._handleChunkEnd()};T.prototype._handleIDAT=function(n){if(!this._emittedHeadersFinished)this._emittedHeadersFinished=!0,this.headersFinished();this.read(-n,this._parseIDAT.bind(this,n))};T.prototype._parseIDAT=function(n,s){if(this._crc.write(s),this._colorType===w.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error("Expected palette not found");this.inflateData(s);let o=n-s.length;if(o>0)this._handleIDAT(o);else this._handleChunkEnd()};T.prototype._handleIEND=function(n){this.read(n,this._parseIEND.bind(this))};T.prototype._parseIEND=function(n){if(this._crc.write(n),this._hasIEND=!0,this._handleChunkEnd(),this.finished)this.finished()}});var Te=M(function(ci){var re=be(),ni=[function(){},function(n,s,o,a){if(a===s.length)throw Error("Ran out of data");let l=s[a];n[o]=l,n[o+1]=l,n[o+2]=l,n[o+3]=255},function(n,s,o,a){if(a+1>=s.length)throw Error("Ran out of data");let l=s[a];n[o]=l,n[o+1]=l,n[o+2]=l,n[o+3]=s[a+1]},function(n,s,o,a){if(a+2>=s.length)throw Error("Ran out of data");n[o]=s[a],n[o+1]=s[a+1],n[o+2]=s[a+2],n[o+3]=255},function(n,s,o,a){if(a+3>=s.length)throw Error("Ran out of data");n[o]=s[a],n[o+1]=s[a+1],n[o+2]=s[a+2],n[o+3]=s[a+3]}],si=[function(){},function(n,s,o,a){let l=s[0];n[o]=l,n[o+1]=l,n[o+2]=l,n[o+3]=a},function(n,s,o){let a=s[0];n[o]=a,n[o+1]=a,n[o+2]=a,n[o+3]=s[1]},function(n,s,o,a){n[o]=s[0],n[o+1]=s[1],n[o+2]=s[2],n[o+3]=a},function(n,s,o){n[o]=s[0],n[o+1]=s[1],n[o+2]=s[2],n[o+3]=s[3]}];function oi(n,s){let o=[],a=0;function l(){if(a===n.length)throw Error("Ran out of data");let c=n[a];a++;let u,h,d,f,p,g,m,b;switch(s){default:throw Error("unrecognised depth");case 16:m=n[a],a++,o.push((c<<8)+m);break;case 4:m=c&15,b=c>>4,o.push(b,m);break;case 2:p=c&3,g=c>>2&3,m=c>>4&3,b=c>>6&3,o.push(b,m,g,p);break;case 1:u=c&1,h=c>>1&1,d=c>>2&1,f=c>>3&1,p=c>>4&1,g=c>>5&1,m=c>>6&1,b=c>>7&1,o.push(b,m,g,p,f,d,h,u);break}}return{get:function(c){while(o.length<c)l();let u=o.slice(0,c);return o=o.slice(c),u},resetAfterLine:function(){o.length=0},end:function(){if(a!==n.length)throw Error("extra data found")}}}function ai(n,s,o,a,l,c){let{width:u,height:h,index:d}=n;for(let f=0;f<h;f++)for(let p=0;p<u;p++){let g=o(p,f,d);ni[a](s,l,g,c),c+=a}return c}function li(n,s,o,a,l,c){let{width:u,height:h,index:d}=n;for(let f=0;f<h;f++){for(let p=0;p<u;p++){let g=l.get(a),m=o(p,f,d);si[a](s,g,m,c)}l.resetAfterLine()}}ci.dataToBitMap=function(n,s){let{width:o,height:a,depth:l,bpp:c,interlace:u}=s,h;if(l!==8)h=oi(n,l);let d;if(l<=8)d=Buffer.alloc(o*a*4);else d=new Uint16Array(o*a*4);let f=Math.pow(2,l)-1,p=0,g,m;if(u)g=re.getImagePasses(o,a),m=re.getInterlaceIterator(o,a);else{let b=0;m=function(){let _=b;return b+=4,_},g=[{width:o,height:a}]}for(let b=0;b<g.length;b++)if(l===8)p=ai(g[b],d,m,c,n,p);else li(g[b],d,m,c,h,f);if(l===8){if(p!==n.length)throw Error("extra data found")}else h.end();return d}});var Ie=M(function(ks,ct){function hi(n,s,o,a,l){let c=0;for(let u=0;u<a;u++)for(let h=0;h<o;h++){let d=l[n[c]];if(!d)throw Error("index "+n[c]+" not in palette");for(let f=0;f<4;f++)s[c+f]=d[f];c+=4}}function di(n,s,o,a,l){let c=0;for(let u=0;u<a;u++)for(let h=0;h<o;h++){let d=!1;if(l.length===1){if(l[0]===n[c])d=!0}else if(l[0]===n[c]&&l[1]===n[c+1]&&l[2]===n[c+2])d=!0;if(d)for(let f=0;f<4;f++)s[c+f]=0;c+=4}}function fi(n,s,o,a,l){let c=255,u=Math.pow(2,l)-1,h=0;for(let d=0;d<a;d++)for(let f=0;f<o;f++){for(let p=0;p<4;p++)s[h+p]=Math.floor(n[h+p]*c/u+0.5);h+=4}}ct.exports=function(n,s,o=!1){let{depth:a,width:l,height:c,colorType:u,transColor:h,palette:d}=s,f=n;if(u===3)hi(n,f,l,c,d);else{if(h)di(n,f,l,c,h);if(a!==8&&!o){if(a===16)f=Buffer.alloc(l*c*4);fi(n,f,l,c,a)}}return f}});var pt=M(function(Ts,dt){var ut=Pt("util"),X=Pt("zlib"),xe=ge(),pi=nt(),mi=ke(),ht=Te(),gi=Ie(),D=dt.exports=function(n){xe.call(this),this._parser=new mi(n,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=n,this.writable=!0,this._parser.start()};ut.inherits(D,xe);D.prototype._handleError=function(n){if(this.emit("error",n),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy)this._inflate.destroy();if(this._filter)this._filter.destroy(),this._filter.on("error",function(){});this.errord=!0};D.prototype._inflateData=function(n){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=X.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let o=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,a=Math.max(o,X.Z_MIN_CHUNK);this._inflate=X.createInflate({chunkSize:a});let l=o,c=this.emit.bind(this,"error");this._inflate.on("error",function(h){if(!l)return;c(h)}),this._filter.on("complete",this._complete.bind(this));let u=this._filter.write.bind(this._filter);this._inflate.on("data",function(h){if(!l)return;if(h.length>l)h=h.slice(0,l);l-=h.length,u(h)}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(n)};D.prototype._handleMetaData=function(n){this._metaData=n,this._bitmapInfo=Object.create(n),this._filter=new pi(this._bitmapInfo)};D.prototype._handleTransColor=function(n){this._bitmapInfo.transColor=n};D.prototype._handlePalette=function(n){this._bitmapInfo.palette=n};D.prototype._simpleTransparency=function(){this._metaData.alpha=!0};D.prototype._headersFinished=function(){this.emit("metadata",this._metaData)};D.prototype._finished=function(){if(this.errord)return;if(!this._inflate)this.emit("error","No Inflate block");else this._inflate.end()};D.prototype._complete=function(n){if(this.errord)return;let s;try{let o=ht.dataToBitMap(n,this._bitmapInfo);s=gi(o,this._bitmapInfo,this._options.skipRescale),o=null}catch(o){this._handleError(o);return}this.emit("parsed",s)}});var gt=M(function(Is,mt){var k=G();mt.exports=function(n,s,o,a){let l=[k.COLORTYPE_COLOR_ALPHA,k.COLORTYPE_ALPHA].indexOf(a.colorType)!==-1;if(a.colorType===a.inputColorType){let _=function(){let C=new ArrayBuffer(2);return new DataView(C).setInt16(0,256,!0),new Int16Array(C)[0]!==256}();if(a.bitDepth===8||a.bitDepth===16&&_)return n}let c=a.bitDepth!==16?n:new Uint16Array(n.buffer),u=255,h=k.COLORTYPE_TO_BPP_MAP[a.inputColorType];if(h===4&&!a.inputHasAlpha)h=3;let d=k.COLORTYPE_TO_BPP_MAP[a.colorType];if(a.bitDepth===16)u=65535,d*=2;let f=Buffer.alloc(s*o*d),p=0,g=0,m=a.bgColor||{};if(m.red===void 0)m.red=u;if(m.green===void 0)m.green=u;if(m.blue===void 0)m.blue=u;function b(){let _,C,S,y=u;switch(a.inputColorType){case k.COLORTYPE_COLOR_ALPHA:y=c[p+3],_=c[p],C=c[p+1],S=c[p+2];break;case k.COLORTYPE_COLOR:_=c[p],C=c[p+1],S=c[p+2];break;case k.COLORTYPE_ALPHA:y=c[p+1],_=c[p],C=_,S=_;break;case k.COLORTYPE_GRAYSCALE:_=c[p],C=_,S=_;break;default:throw Error("input color type:"+a.inputColorType+" is not supported at present")}if(a.inputHasAlpha){if(!l)y/=u,_=Math.min(Math.max(Math.round((1-y)*m.red+y*_),0),u),C=Math.min(Math.max(Math.round((1-y)*m.green+y*C),0),u),S=Math.min(Math.max(Math.round((1-y)*m.blue+y*S),0),u)}return{red:_,green:C,blue:S,alpha:y}}for(let _=0;_<o;_++)for(let C=0;C<s;C++){let S=b(c,p);switch(a.colorType){case k.COLORTYPE_COLOR_ALPHA:case k.COLORTYPE_COLOR:if(a.bitDepth===8){if(f[g]=S.red,f[g+1]=S.green,f[g+2]=S.blue,l)f[g+3]=S.alpha}else if(f.writeUInt16BE(S.red,g),f.writeUInt16BE(S.green,g+2),f.writeUInt16BE(S.blue,g+4),l)f.writeUInt16BE(S.alpha,g+6);break;case k.COLORTYPE_ALPHA:case k.COLORTYPE_GRAYSCALE:{let y=(S.red+S.green+S.blue)/3;if(a.bitDepth===8){if(f[g]=y,l)f[g+1]=S.alpha}else if(f.writeUInt16BE(y,g),l)f.writeUInt16BE(S.alpha,g+2);break}default:throw Error("unrecognised color Type "+a.colorType)}p+=h,g+=d}return f}});var St=M(function(xs,yt){var bt=ye();function bi(n,s,o,a,l){for(let c=0;c<o;c++)a[l+c]=n[s+c]}function yi(n,s,o){let a=0,l=s+o;for(let c=s;c<l;c++)a+=Math.abs(n[c]);return a}function Si(n,s,o,a,l,c){for(let u=0;u<o;u++){let h=u>=c?n[s+u-c]:0,d=n[s+u]-h;a[l+u]=d}}function wi(n,s,o,a){let l=0;for(let c=0;c<o;c++){let u=c>=a?n[s+c-a]:0,h=n[s+c]-u;l+=Math.abs(h)}return l}function _i(n,s,o,a,l){for(let c=0;c<o;c++){let u=s>0?n[s+c-o]:0,h=n[s+c]-u;a[l+c]=h}}function Ei(n,s,o){let a=0,l=s+o;for(let c=s;c<l;c++){let u=s>0?n[c-o]:0,h=n[c]-u;a+=Math.abs(h)}return a}function Ci(n,s,o,a,l,c){for(let u=0;u<o;u++){let h=u>=c?n[s+u-c]:0,d=s>0?n[s+u-o]:0,f=n[s+u]-(h+d>>1);a[l+u]=f}}function ki(n,s,o,a){let l=0;for(let c=0;c<o;c++){let u=c>=a?n[s+c-a]:0,h=s>0?n[s+c-o]:0,d=n[s+c]-(u+h>>1);l+=Math.abs(d)}return l}function Ti(n,s,o,a,l,c){for(let u=0;u<o;u++){let h=u>=c?n[s+u-c]:0,d=s>0?n[s+u-o]:0,f=s>0&&u>=c?n[s+u-(o+c)]:0,p=n[s+u]-bt(h,d,f);a[l+u]=p}}function Ii(n,s,o,a){let l=0;for(let c=0;c<o;c++){let u=c>=a?n[s+c-a]:0,h=s>0?n[s+c-o]:0,d=s>0&&c>=a?n[s+c-(o+a)]:0,f=n[s+c]-bt(u,h,d);l+=Math.abs(f)}return l}var xi={0:bi,1:Si,2:_i,3:Ci,4:Ti},Oi={0:yi,1:wi,2:Ei,3:ki,4:Ii};yt.exports=function(n,s,o,a,l){let c;if(!("filterType"in a)||a.filterType===-1)c=[0,1,2,3,4];else if(typeof a.filterType==="number")c=[a.filterType];else throw Error("unrecognised filter types");if(a.bitDepth===16)l*=2;let u=s*l,h=0,d=0,f=Buffer.alloc((u+1)*o),p=c[0];for(let g=0;g<o;g++){if(c.length>1){let m=1/0;for(let b=0;b<c.length;b++){let _=Oi[c[b]](n,d,u,l);if(_<m)p=c[b],m=_}}f[h]=p,h++,xi[p](n,d,u,f,h,l),h+=u,d+=u}return f}});var Oe=M(function(Os,Et){var E=G(),wt=Ce(),Ai=gt(),Ri=St(),_t=Pt("zlib"),U=Et.exports=function(n){if(this._options=n,n.deflateChunkSize=n.deflateChunkSize||32768,n.deflateLevel=n.deflateLevel!=null?n.deflateLevel:9,n.deflateStrategy=n.deflateStrategy!=null?n.deflateStrategy:3,n.inputHasAlpha=n.inputHasAlpha!=null?n.inputHasAlpha:!0,n.deflateFactory=n.deflateFactory||_t.createDeflate,n.bitDepth=n.bitDepth||8,n.colorType=typeof n.colorType==="number"?n.colorType:E.COLORTYPE_COLOR_ALPHA,n.inputColorType=typeof n.inputColorType==="number"?n.inputColorType:E.COLORTYPE_COLOR_ALPHA,[E.COLORTYPE_GRAYSCALE,E.COLORTYPE_COLOR,E.COLORTYPE_COLOR_ALPHA,E.COLORTYPE_ALPHA].indexOf(n.colorType)===-1)throw Error("option color type:"+n.colorType+" is not supported at present");if([E.COLORTYPE_GRAYSCALE,E.COLORTYPE_COLOR,E.COLORTYPE_COLOR_ALPHA,E.COLORTYPE_ALPHA].indexOf(n.inputColorType)===-1)throw Error("option input color type:"+n.inputColorType+" is not supported at present");if(n.bitDepth!==8&&n.bitDepth!==16)throw Error("option bit depth:"+n.bitDepth+" is not supported at present")};U.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}};U.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())};U.prototype.filterData=function(n,s,o){let a=Ai(n,s,o,this._options),l=E.COLORTYPE_TO_BPP_MAP[this._options.colorType];return Ri(a,s,o,this._options,l)};U.prototype._packChunk=function(n,s){let o=s?s.length:0,a=Buffer.alloc(o+12);if(a.writeUInt32BE(o,0),a.writeUInt32BE(n,4),s)s.copy(a,8);return a.writeInt32BE(wt.crc32(a.slice(4,a.length-4)),a.length-4),a};U.prototype.packGAMA=function(n){let s=Buffer.alloc(4);return s.writeUInt32BE(Math.floor(n*E.GAMMA_DIVISION),0),this._packChunk(E.TYPE_gAMA,s)};U.prototype.packIHDR=function(n,s){let o=Buffer.alloc(13);return o.writeUInt32BE(n,0),o.writeUInt32BE(s,4),o[8]=this._options.bitDepth,o[9]=this._options.colorType,o[10]=0,o[11]=0,o[12]=0,this._packChunk(E.TYPE_IHDR,o)};U.prototype.packIDAT=function(n){return this._packChunk(E.TYPE_IDAT,n)};U.prototype.packIEND=function(){return this._packChunk(E.TYPE_IEND,null)}});var xt=M(function(Rs,It){var Ct=Pt("util"),Ae=Pt("stream"),kt=G(),vi=Oe(),Tt=It.exports=function(n){Ae.call(this);let s=n||{};this._packer=new vi(s),this._deflate=this._packer.createDeflate(),this.readable=!0};Ct.inherits(Tt,Ae);Tt.prototype.pack=function(n,s,o,a){if(this.emit("data",Buffer.from(kt.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(s,o)),a)this.emit("data",this._packer.packGAMA(a));let l=this._packer.filterData(n,s,o);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",function(c){this.emit("data",this._packer.packIDAT(c))}.bind(this)),this._deflate.on("end",function(){this.emit("data",this._packer.packIEND()),this.emit("end")}.bind(this)),this._deflate.end(l)}});var Bt=M(function(Z,Mt){var Ot=Pt("assert").ok,P=Pt("zlib"),vt=Pt("util"),At=Pt("buffer").kMaxLength;function H(n){if(!(this instanceof H))return new H(n);if(n&&n.chunkSize<P.Z_MIN_CHUNK)n.chunkSize=P.Z_MIN_CHUNK;if(P.Inflate.call(this,n),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,n&&n.maxLength!=null)this._maxLength=n.maxLength}function Pi(n){return new H(n)}function Rt(n,s){if(s)process.nextTick(s);if(!n._handle)return;n._handle.close(),n._handle=null}H.prototype._processChunk=function(n,s,o){if(typeof o==="function")return P.Inflate._processChunk.call(this,n,s,o);let a=this,l=n&&n.length,c=this._chunkSize-this._offset,u=this._maxLength,h=0,d=[],f=0,p;this.on("error",function(_){p=_});function g(_,C){if(a._hadError)return;let S=c-C;if(Ot(S>=0,"have should not go down"),S>0){let y=a._buffer.slice(a._offset,a._offset+S);if(a._offset+=S,y.length>u)y=y.slice(0,u);if(d.push(y),f+=y.length,u-=y.length,u===0)return!1}if(C===0||a._offset>=a._chunkSize)c=a._chunkSize,a._offset=0,a._buffer=Buffer.allocUnsafe(a._chunkSize);if(C===0)return h+=l-_,l=_,!0;return!1}Ot(this._handle,"zlib binding closed");let m;do m=this._handle.writeSync(s,n,h,l,this._buffer,this._offset,c),m=m||this._writeState;while(!this._hadError&&g(m[0],m[1]));if(this._hadError)throw p;if(f>=At)throw Rt(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+At.toString(16)+" bytes");let b=Buffer.concat(d,f);return Rt(this),b};vt.inherits(H,P.Inflate);function Li(n,s){if(typeof s==="string")s=Buffer.from(s);if(!(s instanceof Buffer))throw TypeError("Not a string or buffer");let o=n._finishFlushFlag;if(o==null)o=P.Z_FINISH;return n._processChunk(s,o)}function Lt(n,s){return Li(new H(s),n)}Mt.exports=Z=Lt;Z.Inflate=H;Z.createInflate=Pi;Z.inflateSync=Lt});var Re=M(function(vs,Nt){var Dt=Nt.exports=function(n){this._buffer=n,this._reads=[]};Dt.prototype.read=function(n,s){this._reads.push({length:Math.abs(n),allowLess:n<0,func:s})};Dt.prototype.process=function(){while(this._reads.length>0&&this._buffer.length){let n=this._reads[0];if(this._buffer.length&&(this._buffer.length>=n.length||n.allowLess)){this._reads.shift();let s=this._buffer;this._buffer=s.slice(n.length),n.func.call(this,s.slice(0,n.length))}else break}if(this._reads.length>0)throw Error("There are some read requests waitng on finished stream");if(this._buffer.length>0)throw Error("unrecognised content at end of stream")}});var Wt=M(function(Di){var Mi=Re(),Bi=Se();Di.process=function(n,s){let o=[],a=new Mi(n);return new Bi(s,{read:a.read.bind(a),write:function(c){o.push(c)},complete:function(){}}).start(),a.process(),Buffer.concat(o)}});var qt=M(function(Ls,zt){var Ht=!0,ie=Pt("zlib"),Ni=Bt();if(!ie.deflateSync)Ht=!1;var Ui=Re(),Vt=Wt(),Wi=ke(),$t=Te(),Hi=Ie();zt.exports=function(n,s){if(!Ht)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let o;function a(O){o=O}let l;function c(O){l=O}function u(O){l.transColor=O}function h(O){l.palette=O}function d(){l.alpha=!0}let f;function p(O){f=O}let g=[];function m(O){g.push(O)}let b=new Ui(n);if(new Wi(s,{read:b.read.bind(b),error:a,metadata:c,gamma:p,palette:h,transColor:u,inflateData:m,simpleTransparency:d}).start(),b.process(),o)throw o;let C=Buffer.concat(g);g.length=0;let S;if(l.interlace)S=ie.inflateSync(C);else{let z=((l.width*l.bpp*l.depth+7>>3)+1)*l.height;S=Ni(C,{chunkSize:z,maxLength:z})}if(C=null,!S||!S.length)throw Error("bad png - invalid inflate data response");let y=Vt.process(S,l);C=null;let R=$t.dataToBitMap(y,l);y=null;let W=Hi(R,l,s.skipRescale);return l.data=W,l.gamma=f||0,l}});var jt=M(function(Ms,Xt){var Yt=!0,ne=Pt("zlib");if(!ne.deflateSync)Yt=!1;var Gt=G(),Vi=Oe();Xt.exports=function(n,s){if(!Yt)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let a=new Vi(s||{}),l=[];if(l.push(Buffer.from(Gt.PNG_SIGNATURE)),l.push(a.packIHDR(n.width,n.height)),n.gamma)l.push(a.packGAMA(n.gamma));let c=a.filterData(n.data,n.width,n.height),u=ne.deflateSync(c,a.getDeflateOptions());if(c=null,!u||!u.length)throw Error("bad png - invalid compressed data response");return l.push(a.packIDAT(u)),l.push(a.packIEND()),Buffer.concat(l)}});var Kt=M(function(qi){var $i=qt(),zi=jt();qi.read=function(n,s){return $i(n,s||{})};qi.write=function(n,s){return zi(n,s)}});var aL=M(function(Zi){var Zt=Pt("util"),ve=Pt("stream"),Xi=pt(),ji=xt(),Ki=Kt(),A=Zi.PNG=function(n){if(ve.call(this),n=n||{},this.width=n.width|0,this.height=n.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,n.fill&&this.data)this.data.fill(0);this.gamma=0,this.readable=this.writable=!0,this._parser=new Xi(n),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",function(s){this.data=s,this.emit("parsed",s)}.bind(this)),this._packer=new ji(n),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};Zt.inherits(A,ve);A.sync=Ki;A.prototype.pack=function(){if(!this.data||!this.data.length)return this.emit("error","No data provided"),this;return process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this};A.prototype.parse=function(n,s){if(s){let o,a;o=function(l){this.removeListener("error",a),this.data=l,s(null,this)}.bind(this),a=function(l){this.removeListener("parsed",o),s(l,null)}.bind(this),this.once("parsed",o),this.once("error",a)}return this.end(n),this};A.prototype.write=function(n){return this._parser.write(n),!0};A.prototype.end=function(n){this._parser.end(n)};A.prototype._metadata=function(n){this.width=n.width,this.height=n.height,this.emit("metadata",n)};A.prototype._gamma=function(n){this.gamma=n};A.prototype._handleClose=function(){if(!this._parser.writable&&!this._packer.readable)this.emit("close")};A.bitblt=function(n,s,o,a,l,c,u,h){if(o|=0,a|=0,l|=0,c|=0,u|=0,h|=0,o>n.width||a>n.height||o+l>n.width||a+c>n.height)throw Error("bitblt reading outside image");if(u>s.width||h>s.height||u+l>s.width||h+c>s.height)throw Error("bitblt writing outside image");for(let d=0;d<c;d++)n.data.copy(s.data,(h+d)*s.width+u<<2,(a+d)*n.width+o<<2,(a+d)*n.width+o+l<<2)};A.prototype.bitblt=function(n,s,o,a,l,c,u){return A.bitblt(this,n,s,o,a,l,c,u),this};A.adjustGamma=function(n){if(n.gamma){for(let s=0;s<n.height;s++)for(let o=0;o<n.width;o++){let a=n.width*s+o<<2;for(let l=0;l<3;l++){let c=n.data[a+l]/255;c=Math.pow(c,0.45454545454545453/n.gamma),n.data[a+l]=Math.round(c*255)}}n.gamma=0}};A.prototype.adjustGamma=function(){A.adjustGamma(this)}});function q5(n,s,o,a){VR(n,s,[{x:Math.floor(o),y:Math.floor(a)}],"swipe")}function V5(n,s){let o=(s.left+s.right)/2,a=(s.top+s.bottom)/2,l=s.bottom-s.top,c=s.right-s.left;switch(n){case"down":return{startX:o,startY:s.top+l*0.25,endX:o,endY:s.top+l*0.75};case"up":return{startX:o,startY:s.bottom-l*0.25,endX:o,endY:s.top+l*0.25};case"right":return{startX:s.left+c*0.25,startY:a,endX:s.left+c*0.75,endY:a};case"left":return{startX:s.right-c*0.25,startY:a,endX:s.left+c*0.25,endY:a}}}var rr={up:"down",down:"up",left:"right",right:"left"},ir=(n)=>{let{direction:s,gestureType:o}=n;if(!s)return{error:"direction is required"};if(!o||o==="swipeFingerTowardsDirection")return{direction:s,message:`Swiping ${s} (finger gesture)`};return{direction:rr[s],message:`Scrolling ${s} to reveal content ${s==="up"?"above":s==="down"?"below":s==="left"?"from left":"from right"}`}},td=(n)=>ir(n);class rd{parser;constructor(n=new K){this.parser=n}extract(n){if(!n?.hierarchy)return;let s=[],o,a=[],l=n.windows?.filter((u)=>u.hierarchy)??[];if(this.parser.traverseNode(n.hierarchy,(u,h)=>{let d=this.parser.extractNodeProperties(u),f=this.getAttribute(d,["resource-id","resourceId"]);if(f&&f.startsWith("navigation.")&&f.endsWith("Destination"))o=f.replace("navigation.","");if(this.getAttribute(d,["selected"])==="true"){let p=this.extractSelectedElement(u,d,f);if(p)s.push(p)}if(l.length===0)this.collectModalStack(a,d,h)}),l.length>0)this.collectWindowModals(a,l);let c=this.normalizeModalStack(a);if(s.length===0&&!o&&c.length===0)return;return{selectedElements:s,destinationId:o,modalStack:c.length>0?c:void 0}}extractSelectedElement(n,s,o){let a={},l=this.getAttribute(s,["text"]),c=this.getAttribute(s,["content-desc","contentDesc"]);if(l)a.text=l;if(o)a.resourceId=o;if(c)a.contentDesc=c;if(!a.text&&n.node){let u=this.findTextInChildren(n.node);if(u)a.text=u}return a.text||a.resourceId||a.contentDesc?a:void 0}collectWindowModals(n,s){for(let[o,a]of s.entries()){let l=a.id??void 0,c=a.type!==void 0?String(a.type):void 0,u=a.windowLayer??o;this.parser.traverseNode(a.hierarchy,(h,d)=>{let f=this.parser.extractNodeProperties(h);this.collectModalStack(n,f,u+d,{windowId:l,windowType:c})})}}extractFromObservation(n){if(!n?.viewHierarchy)return;let s=this.extract(n.viewHierarchy),o=s?.selectedElements??[];if(o.length>0){let l=this.applySelectedState(o,{method:"accessibility",confidence:1,reason:"selected attribute present in view hierarchy"});return{...s,selectedElements:l}}let a=n.selectedElements??[];if(a.length>0){if(s)return{...s,selectedElements:a};return{selectedElements:a}}return s}applySelectedState(n,s){return n.map((o)=>({...o,selectedState:o.selectedState??s}))}findTextInChildren(n){if(Array.isArray(n))for(let s of n){let o=this.parser.extractNodeProperties(s),a=this.getAttribute(o,["text"]);if(a)return a;if(!s.node)continue;let l=this.findTextInChildren(s.node);if(l)return l}else if(n&&typeof n==="object"){let s=this.parser.extractNodeProperties(n),o=this.getAttribute(s,["text"]);if(o)return o;if(n.node)return this.findTextInChildren(n.node)}return}getAttribute(n,s){for(let o of s){let a=n[o];if(typeof a==="string"&&a!=="")return a}return}collectModalStack(n,s,o,a){let l=this.getAttribute(s,["class","className"]);if(!l)return;let c=this.classifyModalType(l);if(!c)return;let u=this.getModalIdentifier(s,l),h=this.getWindowId(s,a?.windowId,c,{modalId:u,className:l}),d=this.getWindowType(s,a?.windowType);n.push({type:c,identifier:u,layer:o,windowId:h,windowType:d})}getWindowId(n,s,o,{modalId:a,className:l}){let c=this.getAttribute(n,["window-id","windowId","window_id"]),u=c?Number(c):NaN;if(Number.isFinite(u))return u;if(s!==void 0)return s;let h=`${o}:${a??l}`;return this.hashToId(h)}getWindowType(n,s){return this.getAttribute(n,["window-type","windowType","window_type"])??s}classifyModalType(n){let s=n.toLowerCase();if(s.includes("alert")||s.includes("dialog"))return"dialog";if(s.includes("actionsheet")||s.includes("sheet"))return"bottomsheet";if(s.includes("popover"))return"popup";if(s.includes("menu"))return"menu";if(s.includes("modal")||s.includes("presentation"))return"overlay";return null}getModalIdentifier(n,s){return this.getAttribute(n,["resource-id","resourceId","content-desc","contentDesc","text"])??s}hashToId(n){let s=0;for(let o=0;o<n.length;o+=1)s=s*31+n.charCodeAt(o)>>>0;return s}normalizeModalStack(n){if(n.length===0)return[];let s=new Map;for(let o of n){let a=o.identifier??`${o.type}-${o.layer}`;if(!s.has(a))s.set(a,o)}return Array.from(s.values()).sort((o,a)=>o.layer-a.layer).map((o,a)=>({...o,layer:a}))}static createScrollPosition(n){if(!n.lookFor)return;let s=td(n);if(!s.direction)return;let o={targetElement:{text:n.lookFor.text,resourceId:n.lookFor.elementId},direction:s.direction};if(n.container)o.container={text:n.container.text,resourceId:n.container.elementId};if(n.speed)o.speed=n.speed;return o}}var nr="Element subtree:",sr=/\{\{(-?[\d.]+), (-?[\d.]+)\}, \{(-?[\d.]+), (-?[\d.]+)\}\}/,or="(?=$|, (?:(?:identifier|label|value|placeholderValue): |(?:Selected|Disabled|Focused)(?:,|$)))",ar=["identifier","label","value"],lr=ar.map((n)=>[n,new RegExp(`, ${n}: '(.*?)'${or}`)]),cr=new Set(["Button","Cell","Link","Switch","Key"]);function hr(n){let s=sr.exec(n);if(!s)return;let[o,a,l,c]=s.slice(1).map(Number);return{left:o,top:a,right:o+l,bottom:a+c}}function dr(n){let s=/^(\s*)(?:\u2192)?([A-Za-z]+)((?:,.*)?)$/.exec(n);if(!s)return;let[,o,a,l]=s,c={depth:o.length,type:a,frame:hr(l)};for(let[u,h]of lr){let d=h.exec(l)?.[1];if(d!==void 0)c[u]=d}return c}function fr(n){let s=n.replace(/\r\n/g,`
|
|
3
3
|
`).split(`
|
|
4
|
-
`),o=s.findIndex((l)=>l.trim()===nr);if(o<0)return[];let a=s.findIndex((l,c)=>c>o&&/^\S/.test(l));return s.slice(o+1,a<0?void 0:a).map(dr).filter((l)=>l!==void 0)}function De(n,s){return{className:n.type,bounds:n.frame??s,accessibilityIdentifier:n.identifier,accessibilityLabel:n.label??n.value,hasTapTarget:ur.has(n.type),children:[]}}function pr(n,s){let o=De(n[0],s),a=[{depth:n[0].depth,node:o}];for(let l of n.slice(1)){while(a.length>1&&a[a.length-1].depth>=l.depth)a.pop();let c=a[a.length-1].node,u=De(l,c.bounds);c.children.push(u),a.push({depth:l.depth,node:u})}return o}function Fe(n,s){let o=fr(n),a=o.find((l)=>l.type==="Window"&&l.frame)?.frame;if(o.length===0||!a)throw new t("The watch XCUI dump has no element subtree with a window frame; capture it again.");return{timestamp:s.timestamp,screenWidth:a.right-a.left,screenHeight:a.bottom-a.top,screenScale:1,bundleId:s.bundleId,root:pr(o,a)}}var mr="com.apple.clockface",gr="widget";var br="Smart Stack Header",Ne="StackCollectionView",Ue="StackCollectionViewComplicationCell",q=" -- ";function yr(n,s){let o=/^(.*)-(\d+)$/.exec(n);if(!o)return;let[,a,l]=o,c=`${s}-`,u=a.startsWith(c)?a.slice(c.length):"",h=u.startsWith(`${s}.`)?u.indexOf("-"):-1;return{index:Number(l),...h>0&&h<u.length-1?{extensionBundleId:u.slice(0,h),widgetKind:u.slice(h+1)}:{}}}function Sr(n,s){if(n.length>2&&s){let o=s.split(q).length;if(n.slice(0,o).join(q)===s&&o<n.length)return[s,n.slice(o).join(q)]}return[n[0],n.slice(1).join(q)]}function J(n,s){let o=n.split(q);if(o[0]!==Ue||o.length<6)return;let[a,...l]=o.slice(1),c=l[l.length-1],u=l[l.length-2],h=yr(c,u);if(!h)return;let[d,f]=Sr(l.slice(0,-2),s);return{cellId:a,appName:d,widgetName:f,hostBundleId:u,descriptor:c,...h}}function j(n){return(n.children??[]).flatMap((s)=>[s,...j(s)])}function ae(n){return[...new Set(n.map((s)=>s.accessibilityLabel).filter((s)=>!!s))]}function wr(n){let s=j(n),o=s.find((c)=>c.accessibilityLabel)?.accessibilityLabel??void 0,a=J(n.accessibilityIdentifier??"",o);if(!a)return;let l=ae(s.filter((c)=>c.className==="StaticText"));return{type:"widget",...a,bounds:n.bounds,texts:l}}function _r(n){let s=n.accessibilityIdentifier??"";if(s.startsWith(`${Ue}${q}`))return wr(n);if(!s.startsWith(Ne)||s.includes(" "))return;return{type:"system",cellKind:s.slice(Ne.length),bounds:n.bounds,texts:ae(j(n))}}function Er(n){return[n,...j(n)].filter((s)=>s.className==="Cell").map((s)=>({cell:s,card:_r(s)}))}function Cr(n){let s=[n,...j(n)].find((a)=>a.accessibilityIdentifier===br);if(!s)return;let o=(s.children??[]).filter((a)=>a.className==="Button");return{bounds:s.bounds,labels:ae(o)}}function kr(n,s){let o=Cr(n);return{...o?{header:o}:{},cards:s.flatMap(({card:a})=>a?[a]:[])}}function We(n,s){let o=Fe(n,{bundleId:mr,timestamp:s.timestamp}),a=Er(o.root);for(let{cell:l,card:c}of a)if(c?.type==="widget")l.role=gr;return{hierarchy:Pv(o),smartStack:kr(o.root,a)}}async function le(n,s,o){try{let a=await n.request({type:"face",op:"dump"},o,{timeoutMs:2000});if(typeof a!=="string")throw Error("Clockface dump was not text");let{hierarchy:l,smartStack:c}=We(a,{timestamp:s()});return c.header||c.cards.length>0?{hierarchy:l,smartStack:c}:void 0}catch(a){e.debug(`Smart Stack tap preflight unavailable: ${r(a)}`);return}}function ee(n,s){let{left:o,top:a,right:l,bottom:c}=n;return l>o&&c>a&&o>=0&&a>=0&&l<=s.screenWidth&&c<=s.screenHeight}function Ve(n){let s=new K().flattenViewHierarchy(n).map((a)=>a.element),o=s.filter((a)=>ee(a.bounds,n));return{all:s,available:o}}function ce(n,s){return(s.elementId!==void 0||s.text!==void 0)&&(s.elementId===void 0||n["resource-id"]===s.elementId||n["view-id"]===s.elementId)&&(s.text===void 0||n.text===s.text)}function Tr(n){let s=new Set;return n.filter((o)=>{let{left:a,top:l,right:c,bottom:u}=o.bounds,h=`${o["resource-id"]??o["view-id"]}|${o.class}|${a},${l},${c},${u}`;if(s.has(h))return!1;return s.add(h),!0})}function ue(n,s){let o=n.filter((a)=>ce(a,s));return s.elementId!==void 0?Tr(o):o}async function he(n,s,o,a){let{screenWidth:l,screenHeight:c}=s;if(!l||!c||!Number.isFinite(o.x)||!Number.isFinite(o.y)||o.x<0||o.y<0||o.x>l||o.y>c)throw new t("Smart Stack tap is outside the screen; use coordinates in points within the watch screen.");await n.request({type:"face",op:"tap",x:o.x/l,y:o.y/c},a)}function Ir(n){let s=[],o;for(let{element:a,depth:l}of n){if(o!==void 0&&l<=o)o=void 0;let c=a["resource-id"];if(o===void 0&&c!==void 0&&J(c)!==void 0)o=l;if(o===void 0)s.push(a)}return s}function He(n,s,o){return o.text!==void 0&&n.texts.includes(o.text)||o.elementId!==void 0&&s?.["resource-id"]===o.elementId}async function $e(n,{hierarchy:s,smartStack:o},a,l){let c=new K().flattenViewHierarchy(s),u=c.map((y)=>y.element),h=o.cards.map((y)=>{let R=u.find((W)=>{let O=W["resource-id"];return O!==void 0&&(y.type==="widget"?J(O)?.cellId===y.cellId:O===`StackCollectionView${y.cellKind}`)});return{card:y,cell:R}}),d=h.filter(({card:y,cell:R})=>ee(y.bounds,s)&&He(y,R,a)),f=Ir(c).filter((y)=>ee(y.bounds,s)),p=ue(f,a)[a.index??0],g=d[a.index??0],m=d.length>0?g?.cell??(g?p:void 0):p;if(!m){let y=h.some(({card:R,cell:W})=>!ee(R.bounds,s)&&He(R,W,a));throw new t(`The Smart Stack is open, but no element matched.${y?" A matching card is off-screen; scroll the Smart Stack (for example with rotateCrown) until it is wholly on screen, then tap again.":""} To observe it, call the face dump, use tapAt with coordinates in points, or call launchApp to bring the host app forward.`)}let{left:b,top:_,right:C,bottom:S}=g?.card.bounds??m.bounds;return await he(n,s,{x:(b+C)/2,y:(_+S)/2},l),{success:!0,action:"tap",element:m}}function cu(n){throw new t(`${n} is not supported by the watchOS runner; use tap, directional swipe, rotateCrown or home.`)}var xr=0.4,Or=30000,Ar="rotateCrown changed nothing",Rr="The focused control's value stayed";function vr(n,s){if(!(n instanceof Oa)||!n.message.startsWith(Ar)||n.message.includes(Rr)||Math.abs(s)>=1)return n;return new Oa(`${n.message} A delta of ${s} is ${Math.abs(s)} of one crown revolution and may be smaller than one step of the focused control; if it is not at its limit, try a larger delta.`,n.errorCode)}async function Uee(n,s,o){if(n.platform!=="watchos")throw new t("rotateCrown requires a watchOS device; target an Apple Watch session.");let{delta:a,velocity:l=1}=s;if(typeof a!=="number"||!Number.isFinite(a)||a===0)throw new t("rotateCrown delta must be a finite non-zero number.");if(typeof l!=="number"||!Number.isFinite(l)||l<=0)throw new t("rotateCrown velocity must be a finite number greater than zero.");o?.throwIfAborted();try{await Po.require(n.deviceId).request({type:"crown",delta:a,velocity:l},o,{timeoutMs:Or})}catch(c){throw vr(c,a)}return{success:!0,delta:a,velocity:l}}function mv(n,s){if(n==="watchos")cu(s)}function te(n,s){let o=Object.entries(n).filter(([a,l])=>l!==void 0&&(l!==!1||a==="ensureChecked")&&!s.includes(a));if(o.length)cu(`watchOS options ${o.map(([a])=>a).join(", ")}`)}async function ze(n,s){let o=Pv(await n.hierarchy(s));return Ve(o)}function Pr(n,s){let o=(a)=>["XCUIElementType(45)","XCUIElementType(49)","XCUIElementType(50)"].includes(a.class??"");return s?n.toSorted((a,l)=>Number(o(l))-Number(o(a))):[...n]}function Lr(n){if(n.action!=="tap")cu(n.action);if(te(n,["action","elementId","text","index"]),n.index!==void 0&&(!Number.isInteger(n.index)||n.index<0))throw new t("watchOS tap index must be a non-negative integer.")}async function xV(n,s,o,a=!1){Lr(s),o?.throwIfAborted();let l=Po.require(n),c=await le(l,()=>i.now(),o);if(c)return $e(l,c,s,o);let{all:u,available:h}=await ze(l,o),f=Pr(ue(h,s),s.text!==void 0&&a)[s.index??0];if(!f)throw new t("No watch element matched; observe and check the identifier or exact text.");let{left:p,top:g,right:m,bottom:b}=f.bounds,_=(p+m)/2,C=(g+b)/2;return await l.request(f["resource-id"]&&u.filter((S)=>S["resource-id"]===f["resource-id"]).length===1?{type:"tap",identifier:f["resource-id"]}:{type:"tap",x:_,y:C},o),{success:!0,action:"tap",element:f}}function Mr(n){if(n.action!==void 0&&n.action!=="tap")cu(n.action);if(te(n,["action","x","y","coordinateSpace"]),n.coordinateSpace!==void 0&&n.coordinateSpace!=="absolute")cu("non-absolute coordinates");if(typeof n.x!=="number"||typeof n.y!=="number"||!Number.isFinite(n.x)||!Number.isFinite(n.y)||n.x<0||n.y<0)throw new t("watchOS tap requires finite non-negative x/y in XCTest points.")}async function Hee(n,s,o){Mr(s),o?.throwIfAborted();let a=Po.require(n),l=await le(a,()=>i.now(),o);if(l)await he(a,l.hierarchy,s,o);else await a.request({type:"tap",x:s.x,y:s.y},o);return{success:!0,x:s.x,y:s.y,action:"tap"}}function Br(n){if(te(n,["direction","gestureType","lookFor","autoTarget"]),n.lookFor)te(n.lookFor,["text","elementId","maxSwipes"]);let s=n.lookFor?n.lookFor.maxSwipes??10:1;if(!Number.isInteger(s)||s<0||s>100)throw new t("watchOS maxSwipes must be an integer from 0 to 100.");return s}function Fr(n,s){return s?{type:"swipe",direction:n,distance:xr}:{type:"swipe",direction:n}}async function qee(n,s,o){let a=Br(s),l={up:"down",down:"up",left:"right",right:"left"},c=s.gestureType==="scrollTowardsDirection"?l[s.direction]:s.direction;if(!Object.hasOwn(l,c))throw new t("Invalid watch swipe direction.");o?.throwIfAborted();let u=Po.require(n),h=0,d;for(;;){if(s.lookFor)d=(await ze(u,o)).available.find((f)=>ce(f,s.lookFor));if(d||h>=a)break;await u.request(Fr(c,!!s.lookFor),o),h++}return{success:s.lookFor===void 0||!!d,...s.lookFor&&!d?{error:"No watch element matched within the swipe limit; observe before trying again."}:{},targetType:"screen",x1:0,y1:0,x2:0,y2:0,duration:0,durationIgnored:!0,warning:"watchOS performs a directional swipe; stroke coordinates and duration are unavailable.",...s.lookFor?{found:!!d,element:d,scrollIterations:h}:{}}}async function Vee(n,s,o){if(s.toLowerCase()!=="home")cu(`press ${s}`);return o?.throwIfAborted(),await Po.require(n).request({type:"home"},o),{success:!0,button:s,keyCode:0}}var Nr=5000;function qe(n,s){throw new t(`The app's SDK web-view bridge rejected the ${s} (${n}). Re-observe and retry; XCTest does not stand in for this result, because the page may have changed.`)}function Ur(n,s){if(_k(n),n.result?.status==="accepted")return{backend:"sdk"};if(n.result)return qe(n.result.reason??n.result.status,s);if(n.failure==="bridge_unavailable"||n.unsupported)return{backend:"xctest",fallbackReason:"unavailable"};return qe(n.failure??n.error??"no reply",s)}function Ye(n,s){return n==="tap"?{click:{snapshotId:s.snapshotId,elementId:s.elementId}}:null}async function fT(n,s,o,{verb:a,signal:l}){if(!n)return{backend:"xctest",fallbackReason:"unavailable"};let c=await n.requestSdkWebActionForIos(s.webViewId,o,{timeoutMs:Nr,signal:l});return Ur(c,a)}var _5=5000,Wr=new Set(["unsupported_action"]);function Vr(n,s,o){switch(n.action){case"tap":return{tap:{observationIdentity:o,elementId:s}};case"longPress":return{longPress:{observationIdentity:o,elementId:s,durationMs:Math.max(0,Math.round(n.longPressDurationMs??500))}};default:return null}}function $r(n){return"longPress"in n?Hr(n.longPress.durationMs):_5}function Ge(n,s){throw new t(`The app's SDK observation bridge rejected the ${s} (${n}). Re-observe and retry; XCTest does not stand in for this result, because the element may have changed.`)}function gC(n,s){if(_k(n),n.result?.status==="accepted")return{backend:"sdk",nextObservationIdentity:n.result.nextObservationIdentity};if(n.result){let o=n.result.reason??n.result.status;return Wr.has(o)?{backend:"xctest",fallbackReason:"unsupported"}:Ge(o,s)}if(n.failure==="bridge_unavailable"||n.unsupported)return{backend:"xctest",fallbackReason:"unavailable"};return Ge(n.failure??n.error??"no reply",s)}function zr(n){let s=n.enabled??(()=>N.isIosSdkObservationBridgeEnabled());return{async tap(o){let a=FW(o.element);if(a&&s()&&o.action!=="focus"){let d=Ye(o.action,a);return d?fT(n.webClient?.()??null,a,d,{verb:"click",signal:o.signal}):{backend:"xctest",fallbackReason:"unsupported"}}let l=Tv(o.element);if(!l||!s()||o.action==="focus")return null;let c=Vr(o,l.elementId,l.observationIdentity);if(!c)return{backend:"xctest",fallbackReason:"unsupported"};let u=n.client();if(!u)return{backend:"xctest",fallbackReason:"unavailable"};let h=await u.requestSdkActionForIos(c,{timeoutMs:$r(c),signal:o.signal});return gC(h,"tap")}}}function Wee(n){return zr({client:()=>x.getExistingInstance(n.deviceId),webClient:()=>x.getExistingInstance(n.deviceId)})}async function KF(n,s,o){if(!fu())return;if(!n)return{searchCriteria:s,nearMisses:[],totalElementsChecked:0};try{let a=await(o??vn(n)).capture({freshness:"fresh",searchRaw:n.platform==="android"&&N.isRawElementSearchEnabled()}),l=new lr,c=s.container?.text?{...s.container,match:"contains"}:s.container,u=l.resolve({id:String(a.receivedAt),nodes:a.nodes},{elementId:s.resourceId,text:s.text,container:c,match:"contains"},{action:"tap"}),h=c?l.resolve({id:String(a.receivedAt),nodes:a.nodes},{container:c},{action:"inspect"}).candidates:a.nodes,d=new Set([...u.candidates,...u.matches.flatMap(({node:m,sourceNodes:b})=>[m,...b??[]])]),f=s.resourceId??s.text??"",p=new kb,g=h.filter((m)=>m.element&&!d.has(m)).flatMap((m)=>Object.entries(s.resourceId?{"resource-id":m.nativeId}:m.textSources).filter(([,b])=>b&&p.partialTextMatch(b,f)).map(([b,_])=>({element:m.element,property:b,value:_,reason:"Similar but did not match the selected mode"}))).slice(0,10);return{searchCriteria:s,nearMisses:g.length?g:void 0,totalElementsChecked:h.length}}catch(a){return e.warn("Could not build element search debug context",a),{searchCriteria:s,nearMisses:[],totalElementsChecked:0}}}var qr=td("vision",()=>import("./chunk-3sy6ahhz.js"));class de{module;client;constructor(n=qr){this.module=n}async analyzeUIElement(n,s,o){if(this.client===void 0){let{ClaudeVisionClient:a}=await this.module.load();this.client??=new a}return await this.client.analyzeUIElement(n,s,o)}}var Yr=64;class fe{config;claudeClient=null;resultCache;timer;checksums;constructor(n,s=i,o,a=new an){if(this.config=n,this.timer=s,this.checksums=a,this.resultCache=new Map,o)this.claudeClient=o;else if(n.provider==="claude")this.claudeClient=new de}async analyzeAndSuggest(n,s,o){if(!this.config.enabled)throw Error("Vision fallback is not enabled");let a=this.config.cacheResults?await this.generateCacheKey(n,o):null;if(a){let c=this.getCachedResult(a);if(c)return e.debug("Vision fallback: using cached result"),c}if(Gr(this.config.provider),!this.claudeClient)throw Error("Claude client not initialized");e.debug("Vision fallback: analyzing with Claude");let l=await this.claudeClient.analyzeUIElement(n,o,s);if(l.costUsd>this.config.maxCostUsd)e.warn(`Vision fallback cost ($${l.costUsd.toFixed(4)}) exceeds max ($${this.config.maxCostUsd})`);if(e.debug(`Vision fallback complete: confidence=${l.confidence}, cost=$${l.costUsd.toFixed(4)}, time=${l.durationMs}ms`),a)this.cacheResult(a,l);return l}getCachedResult(n){let s=this.resultCache.get(n);if(!s)return null;if((this.timer.now()-s.timestamp)/60000>this.config.cacheTtlMinutes)return this.resultCache.delete(n),null;return s.result}cacheResult(n,s){this.evictExpired(),this.resultCache.set(n,{result:s,timestamp:this.timer.now()}),this.evictOverflow()}evictExpired(){let n=this.timer.now();for(let[s,o]of this.resultCache)if((n-o.timestamp)/60000>this.config.cacheTtlMinutes)this.resultCache.delete(s)}evictOverflow(){while(this.resultCache.size>Yr){let n=this.resultCache.keys().next();if(n.done)return;this.resultCache.delete(n.value)}}async generateCacheKey(n,s){let o=Dr(s);return`${await this.fingerprintScreenshot(n)}:${o}`}async fingerprintScreenshot(n){try{let{checksum:s}=await this.checksums.computeFileSha256(n);return s}catch(s){return e.debug(`Vision fallback: could not fingerprint ${n}, using path as key: ${s}`),n}}clearCache(){this.resultCache.clear()}getCacheStats(){return{size:this.resultCache.size,keys:Array.from(this.resultCache.keys())}}}function Gr(n){if(n==="claude")return n;throw Error(`Unsupported vision provider: ${String(n)}`)}var Am={enabled:!1,provider:"claude",confidenceThreshold:"high",maxCostUsd:1,cacheResults:!0,cacheTtlMinutes:60};var Xr=(n)=>new fe(n),jr=8;class Xe{instances=new Map;createFallback;constructor(n=Xr){this.createFallback=n}get(n){let s=Dr(n),o=this.instances.get(s);if(o)return o;let a=this.createFallback(n);this.instances.set(s,a);while(this.instances.size>jr){let l=this.instances.keys().next();if(l.done)break;this.instances.delete(l.value)}return a}clear(){this.instances.clear()}get size(){return this.instances.size}}var Kr=new Xe;function je(n){return Kr.get(n)}async function Tm(n,s,o,a){let{visionConfig:l,baseError:c,signal:u,visionAnalyzer:h}=a;if(!l.enabled)return c;try{let d=await n.capture(u);if(!d)return e.error("Failed to capture screenshot for vision fallback"),c;let p=await(h??je(l)).analyzeAndSuggest(d,s,o);if(p.confidence==="high"&&p.navigationSteps&&p.navigationSteps.length>0)return`Element not found, but AI suggests these steps:
|
|
4
|
+
`),o=s.findIndex((l)=>l.trim()===nr);if(o<0)return[];let a=s.findIndex((l,c)=>c>o&&/^\S/.test(l));return s.slice(o+1,a<0?void 0:a).map(dr).filter((l)=>l!==void 0)}function De(n,s){return{className:n.type,bounds:n.frame??s,accessibilityIdentifier:n.identifier,accessibilityLabel:n.label??n.value,hasTapTarget:cr.has(n.type),children:[]}}function pr(n,s){let o=De(n[0],s),a=[{depth:n[0].depth,node:o}];for(let l of n.slice(1)){while(a.length>1&&a[a.length-1].depth>=l.depth)a.pop();let c=a[a.length-1].node,u=De(l,c.bounds);c.children.push(u),a.push({depth:l.depth,node:u})}return o}function Fe(n,s){let o=fr(n),a=o.find((l)=>l.type==="Window"&&l.frame)?.frame;if(o.length===0||!a)throw new t("The watch XCUI dump has no element subtree with a window frame; capture it again.");return{timestamp:s.timestamp,screenWidth:a.right-a.left,screenHeight:a.bottom-a.top,screenScale:1,bundleId:s.bundleId,root:pr(o,a)}}var mr="com.apple.clockface",gr="widget";var br="Smart Stack Header",Ne="StackCollectionView",Ue="StackCollectionViewComplicationCell",q=" -- ";function yr(n,s){let o=/^(.*)-(\d+)$/.exec(n);if(!o)return;let[,a,l]=o,c=`${s}-`,u=a.startsWith(c)?a.slice(c.length):"",h=u.startsWith(`${s}.`)?u.indexOf("-"):-1;return{index:Number(l),...h>0&&h<u.length-1?{extensionBundleId:u.slice(0,h),widgetKind:u.slice(h+1)}:{}}}function Sr(n,s){if(n.length>2&&s){let o=s.split(q).length;if(n.slice(0,o).join(q)===s&&o<n.length)return[s,n.slice(o).join(q)]}return[n[0],n.slice(1).join(q)]}function J(n,s){let o=n.split(q);if(o[0]!==Ue||o.length<6)return;let[a,...l]=o.slice(1),c=l[l.length-1],u=l[l.length-2],h=yr(c,u);if(!h)return;let[d,f]=Sr(l.slice(0,-2),s);return{cellId:a,appName:d,widgetName:f,hostBundleId:u,descriptor:c,...h}}function j(n){return(n.children??[]).flatMap((s)=>[s,...j(s)])}function ae(n){return[...new Set(n.map((s)=>s.accessibilityLabel).filter((s)=>!!s))]}function wr(n){let s=j(n),o=s.find((c)=>c.accessibilityLabel)?.accessibilityLabel??void 0,a=J(n.accessibilityIdentifier??"",o);if(!a)return;let l=ae(s.filter((c)=>c.className==="StaticText"));return{type:"widget",...a,bounds:n.bounds,texts:l}}function _r(n){let s=n.accessibilityIdentifier??"";if(s.startsWith(`${Ue}${q}`))return wr(n);if(!s.startsWith(Ne)||s.includes(" "))return;return{type:"system",cellKind:s.slice(Ne.length),bounds:n.bounds,texts:ae(j(n))}}function Er(n){return[n,...j(n)].filter((s)=>s.className==="Cell").map((s)=>({cell:s,card:_r(s)}))}function Cr(n){let s=[n,...j(n)].find((a)=>a.accessibilityIdentifier===br);if(!s)return;let o=(s.children??[]).filter((a)=>a.className==="Button");return{bounds:s.bounds,labels:ae(o)}}function kr(n,s){let o=Cr(n);return{...o?{header:o}:{},cards:s.flatMap(({card:a})=>a?[a]:[])}}function We(n,s){let o=Fe(n,{bundleId:mr,timestamp:s.timestamp}),a=Er(o.root);for(let{cell:l,card:c}of a)if(c?.type==="widget")l.role=gr;return{hierarchy:$v(o),smartStack:kr(o.root,a)}}async function le(n,s,o){try{let a=await n.request({type:"face",op:"dump"},o,{timeoutMs:2000});if(typeof a!=="string")throw Error("Clockface dump was not text");let{hierarchy:l,smartStack:c}=We(a,{timestamp:s()});return c.header||c.cards.length>0?{hierarchy:l,smartStack:c}:void 0}catch(a){e.debug(`Smart Stack tap preflight unavailable: ${r(a)}`);return}}function ee(n,s){let{left:o,top:a,right:l,bottom:c}=n;return l>o&&c>a&&o>=0&&a>=0&&l<=s.screenWidth&&c<=s.screenHeight}function Ve(n){let s=new K().flattenViewHierarchy(n).map((a)=>a.element),o=s.filter((a)=>ee(a.bounds,n));return{all:s,available:o}}function ce(n,s){return(s.elementId!==void 0||s.text!==void 0)&&(s.elementId===void 0||n["resource-id"]===s.elementId||n["view-id"]===s.elementId)&&(s.text===void 0||n.text===s.text)}function Tr(n){let s=new Set;return n.filter((o)=>{let{left:a,top:l,right:c,bottom:u}=o.bounds,h=`${o["resource-id"]??o["view-id"]}|${o.class}|${a},${l},${c},${u}`;if(s.has(h))return!1;return s.add(h),!0})}function ue(n,s){let o=n.filter((a)=>ce(a,s));return s.elementId!==void 0?Tr(o):o}async function he(n,s,o,a){let{screenWidth:l,screenHeight:c}=s;if(!l||!c||!Number.isFinite(o.x)||!Number.isFinite(o.y)||o.x<0||o.y<0||o.x>l||o.y>c)throw new t("Smart Stack tap is outside the screen; use coordinates in points within the watch screen.");await n.request({type:"face",op:"tap",x:o.x/l,y:o.y/c},a)}function Ir(n){let s=[],o;for(let{element:a,depth:l}of n){if(o!==void 0&&l<=o)o=void 0;let c=a["resource-id"];if(o===void 0&&c!==void 0&&J(c)!==void 0)o=l;if(o===void 0)s.push(a)}return s}function He(n,s,o){return o.text!==void 0&&n.texts.includes(o.text)||o.elementId!==void 0&&s?.["resource-id"]===o.elementId}async function $e(n,{hierarchy:s,smartStack:o},a,l){let c=new K().flattenViewHierarchy(s),u=c.map((y)=>y.element),h=o.cards.map((y)=>{let R=u.find((W)=>{let O=W["resource-id"];return O!==void 0&&(y.type==="widget"?J(O)?.cellId===y.cellId:O===`StackCollectionView${y.cellKind}`)});return{card:y,cell:R}}),d=h.filter(({card:y,cell:R})=>ee(y.bounds,s)&&He(y,R,a)),f=Ir(c).filter((y)=>ee(y.bounds,s)),p=ue(f,a)[a.index??0],g=d[a.index??0],m=d.length>0?g?.cell??(g?p:void 0):p;if(!m){let y=h.some(({card:R,cell:W})=>!ee(R.bounds,s)&&He(R,W,a));throw new t(`The Smart Stack is open, but no element matched.${y?" A matching card is off-screen; scroll the Smart Stack (for example with rotateCrown) until it is wholly on screen, then tap again.":""} To observe it, call the face dump, use tapAt with coordinates in points, or call launchApp to bring the host app forward.`)}let{left:b,top:_,right:C,bottom:S}=g?.card.bounds??m.bounds;return await he(n,s,{x:(b+C)/2,y:(_+S)/2},l),{success:!0,action:"tap",element:m}}function vu(n){throw new t(`${n} is not supported by the watchOS runner; use tap, directional swipe, rotateCrown or home.`)}var xr=0.4,Or=30000,Ar="rotateCrown changed nothing",Rr="The focused control's value stayed";function vr(n,s){if(!(n instanceof La)||!n.message.startsWith(Ar)||n.message.includes(Rr)||Math.abs(s)>=1)return n;return new La(`${n.message} A delta of ${s} is ${Math.abs(s)} of one crown revolution and may be smaller than one step of the focused control; if it is not at its limit, try a larger delta.`,n.errorCode)}async function ete(n,s,o){if(n.platform!=="watchos")throw new t("rotateCrown requires a watchOS device; target an Apple Watch session.");let{delta:a,velocity:l=1}=s;if(typeof a!=="number"||!Number.isFinite(a)||a===0)throw new t("rotateCrown delta must be a finite non-zero number.");if(typeof l!=="number"||!Number.isFinite(l)||l<=0)throw new t("rotateCrown velocity must be a finite number greater than zero.");o?.throwIfAborted();try{await To.require(n.deviceId).request({type:"crown",delta:a,velocity:l},o,{timeoutMs:Or})}catch(c){throw vr(c,a)}return{success:!0,delta:a,velocity:l}}function _v(n,s){if(n==="watchos")vu(s)}function te(n,s){let o=Object.entries(n).filter(([a,l])=>l!==void 0&&(l!==!1||a==="ensureChecked")&&!s.includes(a));if(o.length)vu(`watchOS options ${o.map(([a])=>a).join(", ")}`)}async function ze(n,s){let o=$v(await n.hierarchy(s));return Ve(o)}function Pr(n,s){let o=(a)=>["XCUIElementType(45)","XCUIElementType(49)","XCUIElementType(50)"].includes(a.class??"");return s?n.toSorted((a,l)=>Number(o(l))-Number(o(a))):[...n]}function Lr(n){if(n.action!=="tap")vu(n.action);if(te(n,["action","elementId","text","index"]),n.index!==void 0&&(!Number.isInteger(n.index)||n.index<0))throw new t("watchOS tap index must be a non-negative integer.")}async function HV(n,s,o,a=!1){Lr(s),o?.throwIfAborted();let l=To.require(n),c=await le(l,()=>i.now(),o);if(c)return $e(l,c,s,o);let{all:u,available:h}=await ze(l,o),f=Pr(ue(h,s),s.text!==void 0&&a)[s.index??0];if(!f)throw new t("No watch element matched; observe and check the identifier or exact text.");let{left:p,top:g,right:m,bottom:b}=f.bounds,_=(p+m)/2,C=(g+b)/2;return await l.request(f["resource-id"]&&u.filter((S)=>S["resource-id"]===f["resource-id"]).length===1?{type:"tap",identifier:f["resource-id"]}:{type:"tap",x:_,y:C},o),{success:!0,action:"tap",element:f}}function Mr(n){if(n.action!==void 0&&n.action!=="tap")vu(n.action);if(te(n,["action","x","y","coordinateSpace"]),n.coordinateSpace!==void 0&&n.coordinateSpace!=="absolute")vu("non-absolute coordinates");if(typeof n.x!=="number"||typeof n.y!=="number"||!Number.isFinite(n.x)||!Number.isFinite(n.y)||n.x<0||n.y<0)throw new t("watchOS tap requires finite non-negative x/y in XCTest points.")}async function tte(n,s,o){Mr(s),o?.throwIfAborted();let a=To.require(n),l=await le(a,()=>i.now(),o);if(l)await he(a,l.hierarchy,s,o);else await a.request({type:"tap",x:s.x,y:s.y},o);return{success:!0,x:s.x,y:s.y,action:"tap"}}function Br(n){if(te(n,["direction","gestureType","lookFor","autoTarget"]),n.lookFor)te(n.lookFor,["text","elementId","maxSwipes"]);let s=n.lookFor?n.lookFor.maxSwipes??10:1;if(!Number.isInteger(s)||s<0||s>100)throw new t("watchOS maxSwipes must be an integer from 0 to 100.");return s}function Dr(n,s){return s?{type:"swipe",direction:n,distance:xr}:{type:"swipe",direction:n}}async function rte(n,s,o){let a=Br(s),l={up:"down",down:"up",left:"right",right:"left"},c=s.gestureType==="scrollTowardsDirection"?l[s.direction]:s.direction;if(!Object.hasOwn(l,c))throw new t("Invalid watch swipe direction.");o?.throwIfAborted();let u=To.require(n),h=0,d;for(;;){if(s.lookFor)d=(await ze(u,o)).available.find((f)=>ce(f,s.lookFor));if(d||h>=a)break;await u.request(Dr(c,!!s.lookFor),o),h++}return{success:s.lookFor===void 0||!!d,...s.lookFor&&!d?{error:"No watch element matched within the swipe limit; observe before trying again."}:{},targetType:"screen",x1:0,y1:0,x2:0,y2:0,duration:0,durationIgnored:!0,warning:"watchOS performs a directional swipe; stroke coordinates and duration are unavailable.",...s.lookFor?{found:!!d,element:d,scrollIterations:h}:{}}}async function nte(n,s,o){if(s.toLowerCase()!=="home")vu(`press ${s}`);return o?.throwIfAborted(),await To.require(n).request({type:"home"},o),{success:!0,button:s,keyCode:0}}var Nr=5000;function qe(n,s){throw new t(`The app's SDK web-view bridge rejected the ${s} (${n}). Re-observe and retry; XCTest does not stand in for this result, because the page may have changed.`)}function Ur(n,s){if(jk(n),n.result?.status==="accepted")return{backend:"sdk"};if(n.result)return qe(n.result.reason??n.result.status,s);if(n.failure==="bridge_unavailable"||n.unsupported)return{backend:"xctest",fallbackReason:"unavailable"};return qe(n.failure??n.error??"no reply",s)}function Ye(n,s){return n==="tap"?{click:{snapshotId:s.snapshotId,elementId:s.elementId}}:null}async function TT(n,s,o,{verb:a,signal:l}){if(!n)return{backend:"xctest",fallbackReason:"unavailable"};let c=await n.requestSdkWebActionForIos(s.webViewId,o,{timeoutMs:Nr,signal:l});return Ur(c,a)}var W5=5000,Hr=new Set(["unsupported_action"]);function Vr(n,s,o){switch(n.action){case"tap":return{tap:{observationIdentity:o,elementId:s}};case"longPress":return{longPress:{observationIdentity:o,elementId:s,durationMs:Math.max(0,Math.round(n.longPressDurationMs??500))}};default:return null}}function $r(n){return"longPress"in n?Wr(n.longPress.durationMs):W5}function Ge(n,s){throw new t(`The app's SDK observation bridge rejected the ${s} (${n}). Re-observe and retry; XCTest does not stand in for this result, because the element may have changed.`)}function kC(n,s){if(jk(n),n.result?.status==="accepted")return{backend:"sdk",nextObservationIdentity:n.result.nextObservationIdentity};if(n.result){let o=n.result.reason??n.result.status;return Hr.has(o)?{backend:"xctest",fallbackReason:"unsupported"}:Ge(o,s)}if(n.failure==="bridge_unavailable"||n.unsupported)return{backend:"xctest",fallbackReason:"unavailable"};return Ge(n.failure??n.error??"no reply",s)}function zr(n){let s=n.enabled??(()=>N.isIosSdkObservationBridgeEnabled());return{async tap(o){let a=iz(o.element);if(a&&s()&&o.action!=="focus"){let d=Ye(o.action,a);return d?TT(n.webClient?.()??null,a,d,{verb:"click",signal:o.signal}):{backend:"xctest",fallbackReason:"unsupported"}}let l=Hv(o.element);if(!l||!s()||o.action==="focus")return null;let c=Vr(o,l.elementId,l.observationIdentity);if(!c)return{backend:"xctest",fallbackReason:"unsupported"};let u=n.client();if(!u)return{backend:"xctest",fallbackReason:"unavailable"};let h=await u.requestSdkActionForIos(c,{timeoutMs:$r(c),signal:o.signal});return kC(h,"tap")}}}function ite(n){return zr({client:()=>x.getExistingInstance(n.deviceId),webClient:()=>x.getExistingInstance(n.deviceId)})}async function sL(n,s,o){if(!Pu())return;if(!n)return{searchCriteria:s,nearMisses:[],totalElementsChecked:0};try{let a=await(o??Pn(n)).capture({freshness:"fresh",searchRaw:n.platform==="android"&&N.isRawElementSearchEnabled()}),l=new ur,c=s.container?.text?{...s.container,match:"contains"}:s.container,u=l.resolve({id:String(a.receivedAt),nodes:a.nodes},{elementId:s.resourceId,text:s.text,container:c,match:"contains"},{action:"tap"}),h=c?l.resolve({id:String(a.receivedAt),nodes:a.nodes},{container:c},{action:"inspect"}).candidates:a.nodes,d=new Set([...u.candidates,...u.matches.flatMap(({node:m,sourceNodes:b})=>[m,...b??[]])]),f=s.resourceId??s.text??"",p=new Hb,g=h.filter((m)=>m.element&&!d.has(m)).flatMap((m)=>Object.entries(s.resourceId?{"resource-id":m.nativeId}:m.textSources).filter(([,b])=>b&&p.partialTextMatch(b,f)).map(([b,_])=>({element:m.element,property:b,value:_,reason:"Similar but did not match the selected mode"}))).slice(0,10);return{searchCriteria:s,nearMisses:g.length?g:void 0,totalElementsChecked:h.length}}catch(a){return e.warn("Could not build element search debug context",a),{searchCriteria:s,nearMisses:[],totalElementsChecked:0}}}var qr=ad("vision",()=>import("./chunk-tek4pnvv.js"));class de{module;client;constructor(n=qr){this.module=n}async analyzeUIElement(n,s,o){if(this.client===void 0){let{ClaudeVisionClient:a}=await this.module.load();this.client??=new a}return await this.client.analyzeUIElement(n,s,o)}}var Yr=64;class pe{config;claudeClient=null;resultCache;timer;checksums;constructor(n,s=i,o,a=new dn){if(this.config=n,this.timer=s,this.checksums=a,this.resultCache=new Map,o)this.claudeClient=o;else if(n.provider==="claude")this.claudeClient=new de}async analyzeAndSuggest(n,s,o){if(!this.config.enabled)throw Error("Vision fallback is not enabled");let a=this.config.cacheResults?await this.generateCacheKey(n,o):null;if(a){let c=this.getCachedResult(a);if(c)return e.debug("Vision fallback: using cached result"),c}if(Gr(this.config.provider),!this.claudeClient)throw Error("Claude client not initialized");e.debug("Vision fallback: analyzing with Claude");let l=await this.claudeClient.analyzeUIElement(n,o,s);if(l.costUsd>this.config.maxCostUsd)e.warn(`Vision fallback cost ($${l.costUsd.toFixed(4)}) exceeds max ($${this.config.maxCostUsd})`);if(e.debug(`Vision fallback complete: confidence=${l.confidence}, cost=$${l.costUsd.toFixed(4)}, time=${l.durationMs}ms`),a)this.cacheResult(a,l);return l}getCachedResult(n){let s=this.resultCache.get(n);if(!s)return null;if((this.timer.now()-s.timestamp)/60000>this.config.cacheTtlMinutes)return this.resultCache.delete(n),null;return s.result}cacheResult(n,s){this.evictExpired(),this.resultCache.set(n,{result:s,timestamp:this.timer.now()}),this.evictOverflow()}evictExpired(){let n=this.timer.now();for(let[s,o]of this.resultCache)if((n-o.timestamp)/60000>this.config.cacheTtlMinutes)this.resultCache.delete(s)}evictOverflow(){while(this.resultCache.size>Yr){let n=this.resultCache.keys().next();if(n.done)return;this.resultCache.delete(n.value)}}async generateCacheKey(n,s){let o=Fr(s);return`${await this.fingerprintScreenshot(n)}:${o}`}async fingerprintScreenshot(n){try{let{checksum:s}=await this.checksums.computeFileSha256(n);return s}catch(s){return e.debug(`Vision fallback: could not fingerprint ${n}, using path as key: ${s}`),n}}clearCache(){this.resultCache.clear()}getCacheStats(){return{size:this.resultCache.size,keys:Array.from(this.resultCache.keys())}}}function Gr(n){if(n==="claude")return n;throw Error(`Unsupported vision provider: ${String(n)}`)}var Lm={enabled:!1,provider:"claude",confidenceThreshold:"high",maxCostUsd:1,cacheResults:!0,cacheTtlMinutes:60};var Xr=(n)=>new pe(n),jr=8;class Xe{instances=new Map;createFallback;constructor(n=Xr){this.createFallback=n}get(n){let s=Fr(n),o=this.instances.get(s);if(o)return o;let a=this.createFallback(n);this.instances.set(s,a);while(this.instances.size>jr){let l=this.instances.keys().next();if(l.done)break;this.instances.delete(l.value)}return a}clear(){this.instances.clear()}get size(){return this.instances.size}}var Kr=new Xe;function je(n){return Kr.get(n)}async function Bm(n,s,o,a){let{visionConfig:l,baseError:c,signal:u,visionAnalyzer:h}=a;if(!l.enabled)return c;try{let d=await n.capture(u);if(!d)return e.error("Failed to capture screenshot for vision fallback"),c;let p=await(h??je(l)).analyzeAndSuggest(d,s,o);if(p.confidence==="high"&&p.navigationSteps&&p.navigationSteps.length>0)return`Element not found, but AI suggests these steps:
|
|
5
5
|
${p.navigationSteps.map((m,b)=>`${b+1}. ${m.description}`).join(`
|
|
6
6
|
`)}
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ ${p.alternativeSelectors.map((m)=>`- ${m.type}: "${m.value}" (${m.reasoning})`).
|
|
|
11
11
|
|
|
12
12
|
(Cost: $${p.costUsd.toFixed(4)}, Confidence: ${p.confidence})`;return`${c}. ${p.reason||"No clear path found."}
|
|
13
13
|
|
|
14
|
-
(Cost: $${p.costUsd.toFixed(4)}, Confidence: ${p.confidence})`}catch(d){return e.error("Vision fallback failed:",d),c}}var Pe=Nt(GF());async function Qi(){let{default:n}=await import("./chunk-5snsn9cf.js");return n}function Ji(n){return{timer:n.timer??i,backend:n.backend??Ps()}}class I{static PNG_HEADER=Buffer.from([137,80,78,71,13,10,26,10]);static isPngBuffer(n){if(n.length<8)return!1;return n.subarray(0,8).equals(I.PNG_HEADER)}static async convertToPng(n,s=Ps()){try{return await s.execute(n,{operations:[],encoding:{mime:"image/png"}})}catch(o){throw Error(`Failed to convert image to PNG: ${o.message}`)}}static async getImageDimensions(n,s=Ps()){if(I.isPngBuffer(n)&&n.length>=24)return{width:n.readUInt32BE(16),height:n.readUInt32BE(20)};try{let{width:o,height:a}=await s.metadata(n);return{width:o,height:a}}catch(o){throw Error(`Failed to get image dimensions: ${o.message}`)}}static async resizeImageIfNeeded(n,s,o,a=Ps()){let{width:l,height:c}=await I.getImageDimensions(n,a);if(l===s&&c===o)return n;e.debug(`Resizing image from ${l}x${c} to ${s}x${o}`);try{return await a.execute(n,{operations:[{type:"resize",width:s,height:o,maintainAspectRatio:!1,mode:"nearest"}],encoding:{mime:"image/png"}})}catch(u){throw Error(`Failed to resize image: ${u.message}`)}}static getComparisonDimensions(n,s,o){let a=o?Math.min(n.width,s.width,400):Math.min(n.width,s.width),l=o?Math.min(n.height,s.height,600):Math.min(n.height,s.height);return{width:a,height:l}}static dimensionsMatch(n,s,o){return n.width===s&&n.height===o}static async compareImages(n,s,{threshold:o=0.1,fastMode:a=!1,deps:l={}}={}){let{timer:c,backend:u}=Ji(l),h=c.now();e.debug(`Starting image comparison with threshold ${o}${a?" (fast mode)":""}`);try{let d=I.isPngBuffer(n)?n:await I.convertToPng(n,u),f=I.isPngBuffer(s)?s:await I.convertToPng(s,u),p=await I.getImageDimensions(d,u),g=await I.getImageDimensions(f,u);e.debug(`Image 1 dimensions: ${p.width}x${p.height}`),e.debug(`Image 2 dimensions: ${g.width}x${g.height}`);let{width:m,height:b}=I.getComparisonDimensions(p,g,a);if(!I.dimensionsMatch(p,m,b))d=await I.resizeImageIfNeeded(d,m,b,u);if(!I.dimensionsMatch(g,m,b))f=await I.resizeImageIfNeeded(f,m,b,u);let _=Pe.PNG.sync.read(d),C=Pe.PNG.sync.read(f),{width:S,height:y}=_,R=S*y;e.debug(`Comparing images: ${S}x${y} (${R} pixels)`);let W=a?Math.min(o*1.5,0.2):o,z=(await Qi())(_.data,C.data,void 0,S,y,{threshold:W,includeAA:!1}),Be=(R-z)/R*100,tr=c.now()-h;return e.debug(`Image comparison completed in ${tr}ms: ${z}/${R} different pixels (${Be.toFixed(2)}% similar)`),{compared:!0,similarity:Be,pixelDifference:z,totalPixels:R}}catch(d){let f=c.now()-h,p=r(d);return e.warn(`Image comparison failed after ${f}ms: ${p}`,d),{compared:!1,error:p}}}}import oe from"path";var V=8;class se{static async generatePerceptualHash(n,s=Ps()){try{let o=await s.rawPixels(n),a=V*V,l=Array(a),c=0;for(let d=0;d<V;d++){let f=Math.floor(d*o.height/V);for(let p=0;p<V;p++){let g=Math.floor(p*o.width/V),m=(f*o.width+g)*4,b=Math.trunc(0.2126*o.data[m]+0.7152*o.data[m+1]+0.0722*o.data[m+2]);l[d*V+p]=b,c+=b}}let u=c/a,h="";for(let d=0;d<a;d++)h+=l[d]>u?"1":"0";return h}catch(o){return e.warn(`Failed to generate perceptual hash: ${o.message}`),""}}static calculateHammingDistance(n,s){if(n.length!==s.length)return Math.max(n.length,s.length);let o=0;for(let a=0;a<n.length;a++)if(n[a]!==s[a])o++;return o}static getPerceptualSimilarity(n,s){let o=se.calculateHammingDistance(n,s),a=Math.max(n.length,s.length);if(a===0)return 100;return(a-o)/a*100}}class L{static screenshotCache=new Map;static MAX_CACHE_ENTRIES=50;static CACHE_TTL_MS=600000;static async getCachedScreenshot(n,s=i){let o=oe.normalize(n),a=s.now(),l=L.screenshotCache.get(o);if(l&&a-l.lastAccess<L.CACHE_TTL_MS)return l.lastAccess=a,e.debug(`Screenshot cache hit: ${oe.basename(n)}`),{buffer:l.buffer,hash:l.hash};e.debug(`Screenshot cache miss: ${oe.basename(n)}`);let c=await Tf(n),u=await se.generatePerceptualHash(c);return L.addToCache(o,c,u,a),{buffer:c,hash:u}}static addToCache(n,s,o,a){if(L.screenshotCache.size>=L.MAX_CACHE_ENTRIES){let l=Array.from(L.screenshotCache.entries());l.sort((c,u)=>c[1].lastAccess-u[1].lastAccess);for(let c=0;c<10&&c<l.length;c++)L.screenshotCache.delete(l[c][0]);e.debug(`Evicted ${Math.min(10,l.length)} old screenshot cache entries`)}L.screenshotCache.set(n,{buffer:s,hash:o,lastAccess:a})}static clearCache(){L.screenshotCache.clear()}static async getScreenshotFiles(n){try{if(!await Qo(n))return e.debug(`Cache directory does not exist: ${n}`),[];let o=(await Qt(n)).filter((a)=>Jie(a)).map((a)=>oe.join(n,a));return e.debug(`Found ${o.length} screenshot files in ${n}`),o}catch(s){return e.warn(`Failed to get screenshot files from ${n}: ${s.message}`),[]}}}class Q{static async getImageDimensions(n){return I.getImageDimensions(n)}static async compareImages(n,s,o=0.1,a=!1){return I.compareImages(n,s,{threshold:o,fastMode:a})}static async getCachedScreenshot(n){return L.getCachedScreenshot(n)}}class Jt{async getCachedScreenshot(n){return Q.getCachedScreenshot(n)}async getImageDimensions(n){return Q.getImageDimensions(n)}async compareImages(n,s,o,a){return Q.compareImages(n,s,o,a)}}var er=new Jt;var en={minDifferencePercent:1,minElementSizePx:4,pixelmatchThreshold:0.1,confidenceScale:5},tn=0.75;function rn(n){return n?.screenChanged===!0&&(n.basis==="screenIdentity changed"||n.basis==="activeWindow changed")}function Le(n,s){return!n||n===s}function nn(n,s){let o=pt(n);if(!s||o<=0)return!1;let a=$t(n,s);return a!==null&&pt(a)/o>=tn}class Me{screenshotUtils;imageUtils;config;constructor(n={}){this.screenshotUtils=n.screenshotUtils??er,this.imageUtils=n.imageUtils??new c9,this.config={...en,...n.config}}async detectSelectedElements(n){let s=n.currentObservation;if(!s?.viewHierarchy)return[];let o=new Jc().extract(s.viewHierarchy);if(o?.selectedElements?.length){let a=this.applySelectedState(o.selectedElements,{method:"accessibility",confidence:1,reason:"selected attribute present in view hierarchy"});return e.info(`[SELECTION_STATE] Using accessibility selected state (${a.length} element(s))`),a}return this.detectVisualFallback(n,s)}async detectVisualFallback(n,s){let{tappedElement:o,beforeScreenshotPath:a,afterScreenshotPath:l}=n;if(!o)return e.debug("[SELECTION_STATE] Visual fallback skipped: no tapped element provided"),[];if(!a||!l)return e.debug("[SELECTION_STATE] Visual fallback skipped: missing before/after screenshots"),[];let c=this.buildSelectedElement(o);if(!c)return e.debug("[SELECTION_STATE] Visual fallback skipped: tapped element lacks identifiers"),[];let u=this.visualFallbackSkipReason(c,o.bounds,n.tapEffect,s.viewHierarchy);if(u)return e.debug(`[SELECTION_STATE] Visual fallback skipped: ${u}`),[];let h=await this.detectVisualSelection(o.bounds,a,l,{beforeScreenSize:n.previousObservation?.screenSize,afterScreenSize:s.screenSize});if(!h)return[];let d={method:"visual",confidence:h.confidence,reason:h.reason};return e.info(`[SELECTION_STATE] Using visual fallback for ${this.describeElement(c)} (diff=${h.differencePercent.toFixed(2)}%, confidence=${h.confidence})`),[{...c,selectedState:d}]}visualFallbackSkipReason(n,s,o,a){if(rn(o))return`tap navigated (${o?.basis})`;if(!this.isStillPresent(n,s,a))return`${this.describeElement(n)} is not in the post-tap hierarchy`;return null}applySelectedState(n,s){return n.map((o)=>({...o,selectedState:o.selectedState??s}))}buildSelectedElement(n){let s={text:n.text,resourceId:n["resource-id"],contentDesc:n["content-desc"]};if(!s.text&&!s.resourceId&&!s.contentDesc)return null;return s}isStillPresent(n,s,o){if(!o)return!1;return new ve().project(ft(o)??o).some(({properties:l,bounds:c})=>Le(n.text,l.text)&&Le(n.resourceId,l["resource-id"])&&Le(n.contentDesc,l["content-desc"])&&nn(s,c))}describeElement(n){return n.text||n.resourceId||n.contentDesc||"unknown element"}async detectVisualSelection(n,s,o,{beforeScreenSize:a,afterScreenSize:l}={}){try{let c=await this.screenshotUtils.getCachedScreenshot(s),u=await this.screenshotUtils.getCachedScreenshot(o),h=await this.screenshotUtils.getImageDimensions(c.buffer),d=await this.screenshotUtils.getImageDimensions(u.buffer);if(h.width!==d.width||h.height!==d.height)return e.debug(`[SELECTION_STATE] Visual fallback skipped: screenshot size changed ${h.width}x${h.height} -> ${d.width}x${d.height}`),null;let f=await this.cropElementRegion(c.buffer,n,a,h),p=await this.cropElementRegion(u.buffer,n,l,d);if(!f||!p)return e.debug("[SELECTION_STATE] Visual fallback skipped: invalid element bounds for cropping"),null;let g=await this.screenshotUtils.compareImages(f,p,this.config.pixelmatchThreshold,!1);if(!g.compared)return e.warn(`[SELECTION_STATE] Visual fallback skipped: ${g.error}`),null;let m=Math.max(0,100-g.similarity);if(m<this.config.minDifferencePercent)return e.debug(`[SELECTION_STATE] Visual fallback skipped: diff ${m.toFixed(2)}% < threshold ${this.config.minDifferencePercent}%`),null;let b=this.computeConfidence(m);return{differencePercent:m,confidence:b,reason:`visual diff ${m.toFixed(2)}% >= ${this.config.minDifferencePercent}%`}}catch(c){return e.warn(`[SELECTION_STATE] Visual fallback failed: ${r(c)}`,c),null}}async cropElementRegion(n,s,o,a){let l=this.normalizeBounds(s,o,a);if(!l)return null;return this.imageUtils.crop(n,l.width,l.height,{x:l.left,y:l.top})}normalizeBounds(n,s,o){if(o.width<=0||o.height<=0)return null;let a=s?.width?o.width/s.width:1,l=s?.height?o.height/s.height:1,c=Math.max(0,Math.floor(n.left*a)),u=Math.max(0,Math.floor(n.top*l)),h=Math.min(o.width,Math.ceil(n.right*a)),d=Math.min(o.height,Math.ceil(n.bottom*l)),f=h-c,p=d-u;if(f<this.config.minElementSizePx||p<this.config.minElementSizePx)return null;return{left:c,top:u,width:f,height:p}}computeConfidence(n){let s=Math.min(1,Math.max(0,n/this.config.confidenceScale));return Number(s.toFixed(2))}}class rp{device;adbFactory;constructor(n,s=v){this.device=n,this.adbFactory=s}async capture(n){let o=await new Mo(this.device,{adbFactory:this.adbFactory}).execute({format:"png"},n);if(!o.success||!o.path)return null;return o.path}}class x5{detector;screenshotCapturer;isUiPerfModeEnabled;constructor(n){this.detector=n.detector??new Me,this.screenshotCapturer=n.screenshotCapturer,this.isUiPerfModeEnabled=n.isUiPerfModeEnabled??(()=>N.isUiPerfModeEnabled())}async prepare(n){let{observation:s,element:o,action:a,signal:l}=n;if(!s?.viewHierarchy||!o)return null;if(!this.isUiPerfModeEnabled())return e.debug(`[SELECTION_STATE] Skip selection capture (${a}): ui-perf-mode disabled`),null;if(!this.hasIdentifier(o))return e.debug(`[SELECTION_STATE] Skip selection capture (${a}): element lacks identifier`),null;if(!this.isSelectionCandidate(o))return e.debug(`[SELECTION_STATE] Skip selection capture (${a}): element not selectable`),null;if(new Jc().extract(s.viewHierarchy)?.selectedElements?.length)return e.info(`[SELECTION_STATE] Skip visual capture (${a}): accessibility selected state available`),null;let u=await this.screenshotCapturer.capture(l);if(!u)return e.warn(`[SELECTION_STATE] Failed to capture pre-action screenshot (${a})`),null;return{beforeScreenshotPath:u,action:a}}async finalize(n){let{selectionState:s,currentObservation:o,previousObservation:a,element:l,effect:c,action:u,signal:h}=n;if(!s||!o||!l)return[];let d=await this.screenshotCapturer.capture(h);if(!d)return e.warn(`[SELECTION_STATE] Failed to capture post-action screenshot (${u})`),[];let f={currentObservation:o,previousObservation:a,tappedElement:l,tapEffect:c,beforeScreenshotPath:s.beforeScreenshotPath,afterScreenshotPath:d};return this.detector.detectSelectedElements(f)}hasIdentifier(n){return Boolean(n.text||n["resource-id"]||n["content-desc"])}isSelectionCandidate(n){let s=n.clickable===!0||n.clickable==="true",o=n.checkable===!0||n.checkable==="true";return s||o}}function du(n,s){if(!s)return n;return{...n,warnings:[...n.warnings??[],s]}}
|
|
15
|
-
export{
|
|
14
|
+
(Cost: $${p.costUsd.toFixed(4)}, Confidence: ${p.confidence})`}catch(d){return e.error("Vision fallback failed:",d),c}}var Pe=Ft(aL());async function Qi(){let{default:n}=await import("./chunk-gmnm5e3e.js");return n}function Ji(n){return{timer:n.timer??i,backend:n.backend??As()}}class I{static PNG_HEADER=Buffer.from([137,80,78,71,13,10,26,10]);static isPngBuffer(n){if(n.length<8)return!1;return n.subarray(0,8).equals(I.PNG_HEADER)}static async convertToPng(n,s=As()){try{return await s.execute(n,{operations:[],encoding:{mime:"image/png"}})}catch(o){throw Error(`Failed to convert image to PNG: ${o.message}`)}}static async getImageDimensions(n,s=As()){if(I.isPngBuffer(n)&&n.length>=24)return{width:n.readUInt32BE(16),height:n.readUInt32BE(20)};try{let{width:o,height:a}=await s.metadata(n);return{width:o,height:a}}catch(o){throw Error(`Failed to get image dimensions: ${o.message}`)}}static async resizeImageIfNeeded(n,s,o,a=As()){let{width:l,height:c}=await I.getImageDimensions(n,a);if(l===s&&c===o)return n;e.debug(`Resizing image from ${l}x${c} to ${s}x${o}`);try{return await a.execute(n,{operations:[{type:"resize",width:s,height:o,maintainAspectRatio:!1,mode:"nearest"}],encoding:{mime:"image/png"}})}catch(u){throw Error(`Failed to resize image: ${u.message}`)}}static getComparisonDimensions(n,s,o){let a=o?Math.min(n.width,s.width,400):Math.min(n.width,s.width),l=o?Math.min(n.height,s.height,600):Math.min(n.height,s.height);return{width:a,height:l}}static dimensionsMatch(n,s,o){return n.width===s&&n.height===o}static async compareImages(n,s,{threshold:o=0.1,fastMode:a=!1,deps:l={}}={}){let{timer:c,backend:u}=Ji(l),h=c.now();e.debug(`Starting image comparison with threshold ${o}${a?" (fast mode)":""}`);try{let d=I.isPngBuffer(n)?n:await I.convertToPng(n,u),f=I.isPngBuffer(s)?s:await I.convertToPng(s,u),p=await I.getImageDimensions(d,u),g=await I.getImageDimensions(f,u);e.debug(`Image 1 dimensions: ${p.width}x${p.height}`),e.debug(`Image 2 dimensions: ${g.width}x${g.height}`);let{width:m,height:b}=I.getComparisonDimensions(p,g,a);if(!I.dimensionsMatch(p,m,b))d=await I.resizeImageIfNeeded(d,m,b,u);if(!I.dimensionsMatch(g,m,b))f=await I.resizeImageIfNeeded(f,m,b,u);let _=Pe.PNG.sync.read(d),C=Pe.PNG.sync.read(f),{width:S,height:y}=_,R=S*y;e.debug(`Comparing images: ${S}x${y} (${R} pixels)`);let W=a?Math.min(o*1.5,0.2):o,z=(await Qi())(_.data,C.data,void 0,S,y,{threshold:W,includeAA:!1}),Be=(R-z)/R*100,tr=c.now()-h;return e.debug(`Image comparison completed in ${tr}ms: ${z}/${R} different pixels (${Be.toFixed(2)}% similar)`),{compared:!0,similarity:Be,pixelDifference:z,totalPixels:R}}catch(d){let f=c.now()-h,p=r(d);return e.warn(`Image comparison failed after ${f}ms: ${p}`,d),{compared:!1,error:p}}}}import oe from"path";var V=8;class se{static async generatePerceptualHash(n,s=As()){try{let o=await s.rawPixels(n),a=V*V,l=Array(a),c=0;for(let d=0;d<V;d++){let f=Math.floor(d*o.height/V);for(let p=0;p<V;p++){let g=Math.floor(p*o.width/V),m=(f*o.width+g)*4,b=Math.trunc(0.2126*o.data[m]+0.7152*o.data[m+1]+0.0722*o.data[m+2]);l[d*V+p]=b,c+=b}}let u=c/a,h="";for(let d=0;d<a;d++)h+=l[d]>u?"1":"0";return h}catch(o){return e.warn(`Failed to generate perceptual hash: ${o.message}`),""}}static calculateHammingDistance(n,s){if(n.length!==s.length)return Math.max(n.length,s.length);let o=0;for(let a=0;a<n.length;a++)if(n[a]!==s[a])o++;return o}static getPerceptualSimilarity(n,s){let o=se.calculateHammingDistance(n,s),a=Math.max(n.length,s.length);if(a===0)return 100;return(a-o)/a*100}}class L{static screenshotCache=new Map;static MAX_CACHE_ENTRIES=50;static CACHE_TTL_MS=600000;static async getCachedScreenshot(n,s=i){let o=oe.normalize(n),a=s.now(),l=L.screenshotCache.get(o);if(l&&a-l.lastAccess<L.CACHE_TTL_MS)return l.lastAccess=a,e.debug(`Screenshot cache hit: ${oe.basename(n)}`),{buffer:l.buffer,hash:l.hash};e.debug(`Screenshot cache miss: ${oe.basename(n)}`);let c=await Uf(n),u=await se.generatePerceptualHash(c);return L.addToCache(o,c,u,a),{buffer:c,hash:u}}static addToCache(n,s,o,a){if(L.screenshotCache.size>=L.MAX_CACHE_ENTRIES){let l=Array.from(L.screenshotCache.entries());l.sort((c,u)=>c[1].lastAccess-u[1].lastAccess);for(let c=0;c<10&&c<l.length;c++)L.screenshotCache.delete(l[c][0]);e.debug(`Evicted ${Math.min(10,l.length)} old screenshot cache entries`)}L.screenshotCache.set(n,{buffer:s,hash:o,lastAccess:a})}static clearCache(){L.screenshotCache.clear()}static async getScreenshotFiles(n){try{if(!await rs(n))return e.debug(`Cache directory does not exist: ${n}`),[];let o=(await er(n)).filter((a)=>xoe(a)).map((a)=>oe.join(n,a));return e.debug(`Found ${o.length} screenshot files in ${n}`),o}catch(s){return e.warn(`Failed to get screenshot files from ${n}: ${s.message}`),[]}}}class Q{static async getImageDimensions(n){return I.getImageDimensions(n)}static async compareImages(n,s,o=0.1,a=!1){return I.compareImages(n,s,{threshold:o,fastMode:a})}static async getCachedScreenshot(n){return L.getCachedScreenshot(n)}}class Qt{async getCachedScreenshot(n){return Q.getCachedScreenshot(n)}async getImageDimensions(n){return Q.getImageDimensions(n)}async compareImages(n,s,o,a){return Q.compareImages(n,s,o,a)}}var Jt=new Qt;var en={minDifferencePercent:1,minElementSizePx:4,pixelmatchThreshold:0.1,confidenceScale:5},tn=0.75;function rn(n){return n?.screenChanged===!0&&(n.basis==="screenIdentity changed"||n.basis==="activeWindow changed")}function Le(n,s){return!n||n===s}function nn(n,s){let o=ft(n);if(!s||o<=0)return!1;let a=Ut(n,s);return a!==null&&ft(a)/o>=tn}class Me{screenshotUtils;imageUtils;config;constructor(n={}){this.screenshotUtils=n.screenshotUtils??Jt,this.imageUtils=n.imageUtils??new x9,this.config={...en,...n.config}}async detectSelectedElements(n){let s=n.currentObservation;if(!s?.viewHierarchy)return[];let o=new rd().extract(s.viewHierarchy);if(o?.selectedElements?.length){let a=this.applySelectedState(o.selectedElements,{method:"accessibility",confidence:1,reason:"selected attribute present in view hierarchy"});return e.info(`[SELECTION_STATE] Using accessibility selected state (${a.length} element(s))`),a}return this.detectVisualFallback(n,s)}async detectVisualFallback(n,s){let{tappedElement:o,beforeScreenshotPath:a,afterScreenshotPath:l}=n;if(!o)return e.debug("[SELECTION_STATE] Visual fallback skipped: no tapped element provided"),[];if(!a||!l)return e.debug("[SELECTION_STATE] Visual fallback skipped: missing before/after screenshots"),[];let c=this.buildSelectedElement(o);if(!c)return e.debug("[SELECTION_STATE] Visual fallback skipped: tapped element lacks identifiers"),[];let u=this.visualFallbackSkipReason(c,o.bounds,n.tapEffect,s.viewHierarchy);if(u)return e.debug(`[SELECTION_STATE] Visual fallback skipped: ${u}`),[];let h=await this.detectVisualSelection(o.bounds,a,l,{beforeScreenSize:n.previousObservation?.screenSize,afterScreenSize:s.screenSize});if(!h)return[];let d={method:"visual",confidence:h.confidence,reason:h.reason};return e.info(`[SELECTION_STATE] Using visual fallback for ${this.describeElement(c)} (diff=${h.differencePercent.toFixed(2)}%, confidence=${h.confidence})`),[{...c,selectedState:d}]}visualFallbackSkipReason(n,s,o,a){if(rn(o))return`tap navigated (${o?.basis})`;if(!this.isStillPresent(n,s,a))return`${this.describeElement(n)} is not in the post-tap hierarchy`;return null}applySelectedState(n,s){return n.map((o)=>({...o,selectedState:o.selectedState??s}))}buildSelectedElement(n){let s={text:n.text,resourceId:n["resource-id"],contentDesc:n["content-desc"]};if(!s.text&&!s.resourceId&&!s.contentDesc)return null;return s}isStillPresent(n,s,o){if(!o)return!1;return new fe().project(lt(o)??o).some(({properties:l,bounds:c})=>Le(n.text,l.text)&&Le(n.resourceId,l["resource-id"])&&Le(n.contentDesc,l["content-desc"])&&nn(s,c))}describeElement(n){return n.text||n.resourceId||n.contentDesc||"unknown element"}async detectVisualSelection(n,s,o,{beforeScreenSize:a,afterScreenSize:l}={}){try{let c=await this.screenshotUtils.getCachedScreenshot(s),u=await this.screenshotUtils.getCachedScreenshot(o),h=await this.screenshotUtils.getImageDimensions(c.buffer),d=await this.screenshotUtils.getImageDimensions(u.buffer);if(h.width!==d.width||h.height!==d.height)return e.debug(`[SELECTION_STATE] Visual fallback skipped: screenshot size changed ${h.width}x${h.height} -> ${d.width}x${d.height}`),null;let f=await this.cropElementRegion(c.buffer,n,a,h),p=await this.cropElementRegion(u.buffer,n,l,d);if(!f||!p)return e.debug("[SELECTION_STATE] Visual fallback skipped: invalid element bounds for cropping"),null;let g=await this.screenshotUtils.compareImages(f,p,this.config.pixelmatchThreshold,!1);if(!g.compared)return e.warn(`[SELECTION_STATE] Visual fallback skipped: ${g.error}`),null;let m=Math.max(0,100-g.similarity);if(m<this.config.minDifferencePercent)return e.debug(`[SELECTION_STATE] Visual fallback skipped: diff ${m.toFixed(2)}% < threshold ${this.config.minDifferencePercent}%`),null;let b=this.computeConfidence(m);return{differencePercent:m,confidence:b,reason:`visual diff ${m.toFixed(2)}% >= ${this.config.minDifferencePercent}%`}}catch(c){return e.warn(`[SELECTION_STATE] Visual fallback failed: ${r(c)}`,c),null}}async cropElementRegion(n,s,o,a){let l=this.normalizeBounds(s,o,a);if(!l)return null;return this.imageUtils.crop(n,l.width,l.height,{x:l.left,y:l.top})}normalizeBounds(n,s,o){if(o.width<=0||o.height<=0)return null;let a=s?.width?o.width/s.width:1,l=s?.height?o.height/s.height:1,c=Math.max(0,Math.floor(n.left*a)),u=Math.max(0,Math.floor(n.top*l)),h=Math.min(o.width,Math.ceil(n.right*a)),d=Math.min(o.height,Math.ceil(n.bottom*l)),f=h-c,p=d-u;if(f<this.config.minElementSizePx||p<this.config.minElementSizePx)return null;return{left:c,top:u,width:f,height:p}}computeConfidence(n){let s=Math.min(1,Math.max(0,n/this.config.confidenceScale));return Number(s.toFixed(2))}}class gp{device;adbFactory;constructor(n,s=v){this.device=n,this.adbFactory=s}async capture(n){let o=await new No(this.device,{adbFactory:this.adbFactory}).execute({format:"png"},n);if(!o.success||!o.path)return null;return o.path}}class z5{detector;screenshotCapturer;isUiPerfModeEnabled;constructor(n){this.detector=n.detector??new Me,this.screenshotCapturer=n.screenshotCapturer,this.isUiPerfModeEnabled=n.isUiPerfModeEnabled??(()=>N.isUiPerfModeEnabled())}async prepare(n){let{observation:s,element:o,action:a,signal:l}=n;if(!s?.viewHierarchy||!o)return null;if(!this.isUiPerfModeEnabled())return e.debug(`[SELECTION_STATE] Skip selection capture (${a}): ui-perf-mode disabled`),null;if(!this.hasIdentifier(o))return e.debug(`[SELECTION_STATE] Skip selection capture (${a}): element lacks identifier`),null;if(!this.isSelectionCandidate(o))return e.debug(`[SELECTION_STATE] Skip selection capture (${a}): element not selectable`),null;if(new rd().extract(s.viewHierarchy)?.selectedElements?.length)return e.info(`[SELECTION_STATE] Skip visual capture (${a}): accessibility selected state available`),null;let u=await this.screenshotCapturer.capture(l);if(!u)return e.warn(`[SELECTION_STATE] Failed to capture pre-action screenshot (${a})`),null;return{beforeScreenshotPath:u,action:a}}async finalize(n){let{selectionState:s,currentObservation:o,previousObservation:a,element:l,effect:c,action:u,signal:h}=n;if(!s||!o||!l)return[];let d=await this.screenshotCapturer.capture(h);if(!d)return e.warn(`[SELECTION_STATE] Failed to capture post-action screenshot (${u})`),[];let f={currentObservation:o,previousObservation:a,tappedElement:l,tapEffect:c,beforeScreenshotPath:s.beforeScreenshotPath,afterScreenshotPath:d};return this.detector.detectSelectedElements(f)}hasIdentifier(n){return Boolean(n.text||n["resource-id"]||n["content-desc"])}isSelectionCandidate(n){let s=n.clickable===!0||n.clickable==="true",o=n.checkable===!0||n.checkable==="true";return s||o}}function ul(n,s){if(!s)return n;return{...n,warnings:[...n.warnings??[],s]}}
|
|
15
|
+
export{q5,V5,td,rd,vu,ete,_v,HV,tte,rte,nte,TT,W5,kC,ite,sL,Lm,Bm,aL,gp,z5,ul};
|
|
16
16
|
|
|
17
|
-
//# debugId=
|
|
17
|
+
//# debugId=DC67C318FBBA266B64756E2164756E21
|