@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
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{St,so,me,U,J,Ye,li,le,o,P,ya,dt,Rr,Cl,r$,Kg,N,lt,Nt,Ut,mn,ft,uo,rt,K,Ji,YD,JD,Bk,Dl,Wt,fe,qR,Sd,Ti,_b,VR,Ml,hr,nP,Ee,Af,Qt,Ya,Td,EO,tU,Ys,zr,or,xO,F9,ju,mE,fE,CO,Aoe,hE,OO,bP,Ct,Aa,Ed,ur,sU,aU,x,E,Xs}from"./chunk-sfqe223f.js";import{Ur,i,Q,ut,Bd,re,qt,e}from"./chunk-r0vp315h.js";import{ar,ji,Pn,Km,Gm,An,ko,tz,Hv,sD,rB,YT}from"./chunk-4vxeq0vd.js";import{q5,V5,td,vu,rte,TT,W5,kC,sL,Lm,Bm,gp,ul}from"./chunk-661c50hh.js";import{wc,Lv,wW,HC,Oe,jt,Tt}from"./chunk-e0870khr.js";import{ls,Na,br,zi,us,BC,IL,Tte,b3,S3,yW,Ete}from"./chunk-vdqag3fj.js";import{Eu,zo,Ec,Ba,vg,Kn,fa,bg,kre,jo}from"./chunk-cb1ga9rd.js";import{r,t,Rt}from"./chunk-2b39zyxc.js";function Se(n,s,a){if(!s)return[];let c=[...n.extractRootNodes(s),...n.extractWindowRootNodes(s,"topmost-first")],l=[];for(let u of c)n.traverseNode(u,(d)=>{if(!a(n.extractNodeProperties(d)))return;let p=n.parseNodeBounds(d);if(p)l.push(p)});return l}var It=(n)=>n.scrollable==="true"||n.scrollable===!0;class bC{parser;constructor(n=new K){this.parser=n}findScrollableElements(n){return Se(this.parser,n,It)}}class L5{parser;constructor(n=new K){this.parser=n}findClickableElements(n){return Se(this.parser,n,Cl)}}var SC=Object.freeze({partialMatch:!0,caseSensitive:!1}),Yee=Object.freeze({partialMatch:!1}),Iv=Object.freeze({intentAction:"inspect"}),Jee=Object.freeze({intentAction:"focus-input",allowHintFallback:!0}),Xee=Object.freeze({intentAction:"focus-input"}),Zee=Object.freeze({intentAction:"inspect",selectionIntent:"toggle"}),Qee=Object.freeze({intentAction:"inspect",selectionIntent:"focus-input"}),Fe=Object.freeze({intentAction:"drag"});function RT(n){return{partialMatch:n,caseSensitive:!1}}var j=(n)=>An(n)??"",wC=async(n,s)=>{let{observe:a,timer:c,maxWaitMs:l,pollIntervalMs:u,logPrefix:d,signal:p}=s;if(!n.viewHierarchy)return n;let m=c.now(),h=j(n.viewHierarchy),f=n;while(c.now()-m<l){p?.throwIfAborted();let S=await a();if(!S.viewHierarchy)break;let y=j(S.viewHierarchy);if(y===h)return e.info(`${d} Scroll settled after ${c.now()-m}ms idle check`),S;e.info(`${d} Scroll still settling (elapsed=${c.now()-m}ms), retrying in ${u}ms`),h=y,f=S,p?.throwIfAborted(),await c.sleep(u)}return e.info(`${d} Scroll idle check reached ${l}ms limit, proceeding`),f};class we{device;selector;constructor(n,s){this.device=n;this.selector=s}buildScrollableCandidates(n){let s=[],a=new Set;for(let c of n){let l={elementId:c["resource-id"],text:c.text,contentDesc:c["content-desc"],className:c.class};if(!l.elementId&&!l.text&&!l.contentDesc&&!l.className)continue;let u=`${l.elementId??""}|${l.text??""}|${l.contentDesc??""}|${l.className??""}`;if(a.has(u))continue;a.add(u),s.push(l)}return s}resolveAutoTargetDecision({scrollables:n,candidates:s,observeResult:a,direction:c,includeSystemInsets:l}){if(n.length===0)return e.info("[SwipeOn] Mode: screen swipe (no scrollables found)"),{};let u=a?this.selector().getScreenBounds(a,{platform:re(this.device.platform,"swipeOn"),includeSystemInsets:l}):null,d=this.selector().selectAutoTargetScrollable(n,u,c);if(!d)return e.info(`[SwipeOn] Mode: screen swipe (scrollables found but none matched direction=${c})`),{warning:"Scrollable containers found but none matched the swipe direction; swiping the screen. Set autoTarget: false to force screen swipes.",scrollableCandidates:s};let p=r$(d);if(!p&&this.device.platform==="android")return e.info("[SwipeOn] Mode: element swipe (auto-target element has no usable identifier)"),{element:d,warning:"Auto-targeted scrollable container lacks a usable identifier; swiping within its bounds without container metadata.",scrollableCandidates:s};if(!p)return e.info("[SwipeOn] Mode: screen swipe (auto-target element has no usable identifier)"),{scrollFrame:l?void 0:d.bounds,warning:"Auto-targeted scrollable container lacks a usable identifier; swiping the screen. Provide container.elementId or container.text to target it explicitly.",scrollableCandidates:s};return e.info(`[SwipeOn] Mode: auto-target element swipe (container=${JSON.stringify(p)})`),{container:p,warning:`Auto-targeted scrollable container (${this.selector().describeContainer(p)}). Set autoTarget: false to force full-screen swipes.`,scrollableCandidates:s}}withAutoTargetDecision({result:n,decision:s}){if(!s.warning)return n;return{...n,warning:this.selector().mergeWarnings(n.warning,s.warning),scrollableCandidates:s.scrollableCandidates}}}function T(n,s){return n!==void 0&&(!s||!Bd(n["visible-to-user"]))}var At="[REDACTED]";function Ne(n){return Ct(n).trim().toLowerCase()}function kt(n,s){let a=Ne(s),c=new Map;for(let{id:u}of n)c.set(u,(c.get(u)??0)+1);let l=n.filter((u)=>u.id!==""&&c.get(u.id)===1&&u.enabled&&u.visible&&[u.label,u.value===At?void 0:u.value].some((d)=>d!==void 0&&Ne(d)===a));return l.length===1?l[0]:null}function Pt(n){let s=n.enabled??(()=>N.isIosSdkObservationBridgeEnabled());return{async scroll(a,c,l){if(!s()||a.text===void 0)return null;if(rB(c.viewHierarchy).length!==1)return null;let u=await n.reader.snapshots(l),d=u.length===1?u[0]:void 0,p=d?.snapshot,m=p?kt(p.elements,a.text):null;if(!d||!p||!m)return null;let h={snapshotId:p.snapshotId,elementId:m.id};return TT(n.client(),{webViewId:d.webViewId,...h},{scrollIntoView:h},{verb:"scroll into view",signal:l})}}}function Mt(n){return Pt({reader:YT(n),client:()=>x.getExistingInstance(n.deviceId)})}function _e(n,s){return n.platform==="ios"?s??Mt(n):void 0}import{AsyncLocalStorage as Ft}from"async_hooks";var Be=new Ft;function Z(n){return Be.getStore()?n():Be.run(!0,()=>Km(n))}function ee(n){let s=so()?.getDeadlineMs?.();return Math.max(0,Math.min(ji,s===void 0?ji:s-n.now()))}async function M(n,s,a,c){if(o(c),!n.viewHierarchy||n.viewHierarchy.hierarchy.error||Gm(n.viewHierarchy))return n;let l=ee(a);if(l>0)try{let u=await s(l);return o(c),Kg(u)?{...u,viewHierarchy:void 0}:u}catch(u){if(o(c),u instanceof Ee||u instanceof Error&&u.name==="AbortError")throw u;e.warn(`[SwipeOn] Fresh hierarchy unavailable: ${r(u)}`,u)}return{...n,viewHierarchy:void 0}}var RC=600,tL=3000,PC=300,rL=2000,Pw=100,PT=3000,_t=100,Bt=Ya,Vt=0.5;function Ve(n,s,a){let c=n+s+a;return Math.max(Ji,c+Bt+c*Vt)}function te(n){return{success:!1,error:`Drag outcome is indeterminate: the request was dispatched but no result was confirmed (${n}). The gesture may have run. Do not retry automatically. Verify state first with observe.`}}function $e(n){if(n===void 0||n.trim()!==n)return!0;return!(["Gesture display routing requires Android 11 (API 30)","Stale frame context for input/drag; observe a fresh frame before retrying","Stale frame context; observe a fresh frame before retrying","Failed to dispatch gesture"].includes(n)||/^displayId must be non-negative: -[1-9]\d*$/.test(n)||/^Non-finite gesture coordinate: (x1|y1|x2|y2)=(NaN|-?Infinity)\. Coordinates must be finite \(not NaN or Infinity\)\.$/.test(n))}var $t=5000,Gt=15000;class B5 extends Oe{lastRenderedObservation;selector;hierarchyCapture;geometry;accessibilityService;visionConfig;screenshotCapturer;visionAnalyzer;constructor(n,s=null,a=i,c={}){super(n,{adb:s,timer:a,displayFence:c});this.lastRenderedObservation=c.lastRenderedObservation,this.selector=c.selector??new br(void 0,void 0,{platform:re(n.platform,"dragAndDrop"),iosMultiPanel:n.platform==="ios"&&(n.displays?.panels.length??0)>1}),this.hierarchyCapture=c.hierarchyCapture??Pn(n,{timer:a,adbFactory:this.adbFactory}),this.geometry=new or,this.accessibilityService=Xs(n,this.adbFactory),this.visionConfig=c.visionConfig??Lm,this.screenshotCapturer=c.screenshotCapturer??new gp(n,this.adbFactory),this.visionAnalyzer=c.visionAnalyzer}async executeOnAndroidDisplay(n,s,a){let c=s.observation.viewHierarchy;if(!c)throw new t("Selected display has no view hierarchy");let{sourcePoint:l,targetPoint:u}=this.resolveTargetPoints(c,{...n,observation:s.observation}),d=this.getDragDurationMs(n),p=await Ba(this.accessibilityService,s.displayId);if(s.assertCurrent(),o(a),p){let m=this.getPressDurationMs(n),h=this.getHoldDurationMs(n),f=!1,S;try{S=await P(Promise.resolve().then(()=>(o(a),this.accessibilityService.requestDrag({x1:l.x,y1:l.y,x2:u.x,y2:u.y,pressDurationMs:m,dragDurationMs:d,holdDurationMs:h,timeoutMs:Ve(m,d,h),signal:a,displayId:s.displayId===0?void 0:s.displayId,beforeSend:s.assertCurrent,onDispatch:()=>{f=!0}}))),a),o(a)}catch(y){if(o(a),!f)throw y;throw e.warn(`Drag outcome indeterminate: ${r(y)}`,y),new t(te(r(y)).error)}if(!S.success)throw new t(f&&$e(S.error)?te(S.error??"unknown error").error:S.error??"Android drag failed")}else{if(n.pressDurationMs!==void 0||n.holdDurationMs!==void 0)throw new t(`pressDurationMs and holdDurationMs require the CtrlProxy gesture route on display ${s.displayId} (capability gesture_display_id_v1); adb draganddrop cannot express press or hold durations`);await Ec(this.adb,`draganddrop ${l.x} ${l.y} ${u.x} ${u.y} ${zo(d)}`,s.displayId,{signal:a,assertCurrent:s.assertCurrent})}return{success:!0,duration:d,distance:Math.hypot(u.x-l.x,u.y-l.y)}}async executeExplicitDisplay(n,s){if(n.display!==void 0)try{let a=await zi(this.device,n.display,this.observeScreen,{adb:this.adb,lastRenderedObservation:this.lastRenderedObservation,signal:s,transitions:this.displayTransitionReader});if(this.device.platform==="android")return await this.observedInteraction(()=>this.executeOnAndroidDisplay(n,a,s),{...jt.rawCoordinateGesture,display:a.followUpDisplay,previousObservation:a.observation,signal:s})}catch(a){if(o(s),a instanceof Error&&a.name==="AbortError")throw a;return e.warn(`dragAndDrop display routing failed: ${r(a)}`,a),Qt(this.failureResult(a,r(a)),a)}return}async execute(n,s,a){let{progress:c,signal:l}=jo(s,a),u=this.device.platform==="ios"?me(l):l,d=await this.executeExplicitDisplay(n,u);if(d)return d;let p=J();if(p.serial("dragAndDrop"),this.device.platform!=="android"&&this.device.platform!=="ios")return p.end(),{success:!1,duration:0,distance:0,error:`dragAndDrop is not supported on ${this.device.platform}`};if(this.device.platform==="android"){let h=le.getInstance(this.device,{create:()=>this.adb});if(!await p.track("a11yAvailable",()=>h.isAvailable()))return p.end(),{success:!1,duration:0,distance:0,error:"dragAndDrop requires the Android accessibility service to be installed and enabled."}}let m=this.validateOptions(n);if(m)return p.end(),{success:!1,duration:0,distance:0,error:m};return this.executeObservedDrag(n,p,c,u)}async executeObservedDrag(n,s,a,c){try{let l=this.getPressDurationMs(n),u=this.getDragDurationMs(n),d=this.getHoldDurationMs(n),p,m=await this.observedInteraction(async(h,f)=>{o(c);let S=await this.resolveViewHierarchy(c);if(!S)return{success:!1,error:"Unable to get view hierarchy, cannot drag and drop"};let{sourcePoint:y,targetPoint:b}=this.resolveTargetPoints(S,{...n,observation:h});f?.assertCurrent();let w=await this.dispatchDrag({startX:y.x,startY:y.y,endX:b.x,endY:b.y,pressDurationMs:l,dragDurationMs:u,holdDurationMs:d,signal:c});if(this.device.platform==="ios"&&w.success)p=this.timer.now(),x.getExistingInstance(this.device.deviceId)?.invalidateCache();await this.timer.sleep(_t);let v=Math.hypot(b.x-y.x,b.y-y.y);return{success:w.success,duration:u,distance:v,a11yTotalTimeMs:w.a11yTotalTimeMs,a11yGestureTimeMs:w.a11yGestureTimeMs,error:w.error}},{...jt.selectorResolvedGesture,display:n.display,progress:a,perf:s,signal:c,observationTimestampProvider:()=>p,predictionContext:{toolName:"dragAndDrop",toolArgs:{source:n.source,target:n.target,pressDurationMs:l,dragDurationMs:u,holdDurationMs:d,platform:this.device.platform}}});return s.end(),o(c),{...m,duration:m.duration??this.getDragDurationMs(n),distance:m.distance??0}}catch(l){if(s.end(),e.warn(`Drag and drop failed: ${r(l)}`,l),o(c),l instanceof Ee||l instanceof hr)return Qt({success:!1,duration:0,distance:0},l);let u=r(l),d=`Failed to perform drag and drop: ${u}`;if(this.visionConfig.enabled){let p=this.isSourceResolutionError(u),m=p?n.source:n.target;if(m){let h={text:m.text,resourceId:m.elementId,description:p?"Source element for drag":"Target element for drop"},S=(await this.observeScreen.getMostRecentCachedObserveResult())?.viewHierarchy??null;d=await Bm(this.screenshotCapturer,S,h,{visionConfig:this.visionConfig,baseError:d,signal:c,visionAnalyzer:this.visionAnalyzer})}}return o(c),this.failureResult(l,d)}}failureResult(n,s){return{success:!1,duration:0,distance:0,error:s,...n instanceof t&&n.containerFailure?{containerFailure:n.containerFailure}:{}}}isSourceResolutionError(n){return n.startsWith("dragAndDrop source")||!n.startsWith("dragAndDrop target")&&n.toLowerCase().includes("source")}validateOptions(n){if(!n?.source||!n?.target)return"dragAndDrop requires source and target";if([n.source.text,n.source.elementId].filter(Boolean).length!==1)return"dragAndDrop source must specify exactly one of text or elementId";if([n.target.text,n.target.elementId].filter(Boolean).length!==1)return"dragAndDrop target must specify exactly one of text or elementId";if(!this.isDurationInRange(n.pressDurationMs,RC,tL))return`dragAndDrop pressDurationMs must be between ${RC}ms and ${tL}ms`;if(!this.isDurationInRange(n.dragDurationMs,PC,rL))return`dragAndDrop dragDurationMs must be between ${PC}ms and ${rL}ms`;if(!this.isDurationInRange(n.holdDurationMs,Pw,PT))return`dragAndDrop holdDurationMs must be between ${Pw}ms and ${PT}ms`;return null}resolveTargetPoints(n,s){let a={observationScreenSize:s.observation.screenSize,display:s.observation.viewHierarchy},c=Ti(n,s.layer),l=this.resolveTarget(c,{...s.source,screenSizeOptions:a},"source"),u=this.resolveTarget(c,{...s.target,screenSizeOptions:a},"target"),d=this.prototypeSafePoint(n,s.layer,l,"source"),p=this.prototypeSafePoint(n,s.layer,u,"target");return _b(n,s.layer,d,"drag from"),_b(n,s.layer,p,"drop"),{sourcePoint:d,targetPoint:p}}prototypeSafePoint(n,s,a,c){let l=this.geometry.getElementCenter(a);if(s!==void 0||this.device.platform==="ios")return l;let u=tU(n,a,a.bounds,l);if(!u)throw new t(`dragAndDrop ${c} is covered by an AutoMobile prototype window; hide or move the prototype, then retry.`);return u}get testHooks(){return{resolveTarget:this.resolveTarget.bind(this)}}resolveTarget(n,s,a){if([s.elementId,s.text].filter(Boolean).length!==1)throw new t(`dragAndDrop ${a} must specify exactly one of text or elementId`);let l;try{if(l=this.selectTargetElement(n,s),!l&&s.container)throw new t("Target not found within container")}catch(u){let d=ls(s,"any-container")?`dragAndDrop ${a}: `:"";throw new t(`${d}${r(u)}`,{cause:u})}if(!l){let u=s.elementId?"elementId":"text";throw new t(`dragAndDrop ${a} not found with ${u} '${s.elementId??s.text}'`)}return l}selectTargetElement(n,s){let a={...Fe,screenSizeOptions:s.screenSizeOptions,container:s.container,strategy:s.selectionStrategy};if(s.container&&!ls(s)&&this.selector.resolveContainer&&!this.selector.resolveContainer(n,s.container,s.selectionStrategy))throw new t(`Container level 1 not found: ${s.container.elementId??s.container.text}`,{containerFailure:{level:1,reason:"not-found",selector:s.container}});if(s.elementId)return this.selector.select(n,{elementId:s.elementId},a).element;let c=this.selector.select(n,{text:s.text??""},a);return c.matchedElement??c.element}async resolveViewHierarchy(n){let s=await this.hierarchyCapture.capture({freshness:"fresh",searchRaw:this.device.platform==="android"&&N.isRawElementSearchEnabled(),signal:n,timeoutMs:this.device.platform==="ios"?Gt:$t});if(this.device.platform==="ios")o(n);return s.hierarchy}getPressDurationMs(n){if(typeof n.pressDurationMs==="number")return n.pressDurationMs;return RC}getDragDurationMs(n){if(typeof n.dragDurationMs==="number")return n.dragDurationMs;return PC}getHoldDurationMs(n){if(typeof n.holdDurationMs==="number")return n.holdDurationMs;return Pw}isDurationInRange(n,s,a){if(typeof n!=="number")return!0;return n>=s&&n<=a}dispatchDrag=(n)=>this.executeDrag(n);setDragDispatchForTesting(n){this.dispatchDrag=n}async executeDrag({startX:n,startY:s,endX:a,endY:c,pressDurationMs:l,dragDurationMs:u,holdDurationMs:d,signal:p}){o(p);let m=Ve(l,u,d),h=!1,f=()=>{h=!0},S;try{let y=Promise.resolve().then(()=>(o(p),this.device.platform==="ios"?x.getInstance(this.device).requestDrag({x1:n,y1:s,x2:a,y2:c,pressDurationMs:l,dragDurationMs:u,holdDurationMs:d,timeoutMs:m,signal:p,onDispatch:f}):this.accessibilityService.requestDrag({x1:n,y1:s,x2:a,y2:c,pressDurationMs:l,dragDurationMs:u,holdDurationMs:d,timeoutMs:m,signal:p,onDispatch:f})));if(S=await P(y,p),o(p),!S.success&&h&&(this.device.platform==="ios"||$e(S.error)))return te(S.error??"unknown error")}catch(y){if(o(p),!h)throw y;return e.warn(`Drag outcome indeterminate: ${r(y)}`,y),te(r(y))}if(S.success)return{success:!0,a11yTotalTimeMs:S.totalTimeMs,a11yGestureTimeMs:S.gestureTimeMs};return{success:!1,error:S.error??"Drag failed via CtrlProxy"}}}var ie=Pw,Ge=3,He=4,Ht=new fe;function ne(n,s){let a=n.endX-n.startX,c=n.endY-n.startY,u=Math.abs(a)>Math.abs(c)?s.right-s.left:s.bottom-s.top,d=Math.hypot(a,c),p=d>0?Math.min(1,Math.floor(u*0.75)/d):1;return{...n,endX:Math.round(n.startX+a*p),endY:Math.round(n.startY+c*p)}}function AC(n){return{up:"down",down:"up",left:"right",right:"left"}[n]}function Le(n,s){if(!n.viewHierarchy)return[];let a=Ht.project(n.viewHierarchy),c=a.find((d)=>d.element&&d.element["resource-id"]===s["resource-id"]&&Nt(d.element.bounds,s.bounds)),l=new Set,u=[];for(let d of a){if(d===c){l.add(d.index);continue}if(!c||d.parentIndex===void 0||!l.has(d.parentIndex))continue;if(l.add(d.index),!Lt(d,s.bounds))continue;let p=Yt(d);if(p||Xt(d))u.push({key:p,bounds:d.bounds,textSources:d.textSources})}return u}function oe(n,s){let a=new Map;for(let{key:c}of Le(n,s)){if(c===void 0)continue;a.set(c,(a.get(c)??0)+1)}return a}function be(n,s){let a=Le(n,s);return a.length===0?"":JSON.stringify(a.map(({key:c,bounds:l,textSources:u})=>[c??null,l,Object.entries(u).sort(([d],[p])=>d.localeCompare(p))]))}function ye(n,s){return n.signature!==""&&be(s,n.container)===n.signature}function Lt(n,s){if(!n.bounds||n.categories.scrollable||!Ut(n.bounds,s))return!1;return![n.properties.visible,n.properties["visible-to-user"]].some((a)=>a===!1||a==="false")}function Xt(n){return n.textSources.value!==void 0||n.textSources["hint-text"]!==void 0}function Yt(n){let{text:s,"content-desc":a,"ios-accessibility-label":c}=n.textSources;if(!s&&!a&&!c&&!n.nativeId)return;return JSON.stringify([n.nativeId,s,a,c])}function We(n,s){let a=(c,l)=>[...c].filter(([u,d])=>d===1&&(l.get(u)??0)<=1).length;return a(n,s)>=He&&a(s,n)>=He}async function Xe(n){let s=n.observation,a=await n.keys(s);if(!We(n.previousKeys,a))return s;for(let c=0;;c++){if(o(n.signal),c>0&&await n.hasTarget?.(s))return s;let l=c===0?a:await n.keys(s);if([...l.keys()].some((u)=>n.previousKeys.has(u)))return s;if(!We(n.previousKeys,l))return e.debug("[SwipeOn] Recovery overlap evidence is sparse; continuing forward"),s;if(c>=Ge||n.timer.now()>=n.deadline)return e.debug(`[SwipeOn] Overlap not restored after ${c} back-scrolls; continuing forward`),s;e.debug(`[SwipeOn] Zero visible child overlap; back-scroll ${c+1}/${Ge}`),s=await n.backScroll(s)}}function zt(n,s){let a=s?.deviceInfo??n.requestDeviceInfo();if(s)s.deviceInfo=a;return a}function Kt(n,s){return n instanceof hr||n instanceof Ee&&!s}async function se(n){let{client:s,x1:a,y1:c,x2:l,y2:u,duration:d,signal:p,displayId:m,beforeSend:h}=n,f=()=>(o(p),h?.(),n.onFallback?.(),n.fallback()),S=(b)=>{n.onIndeterminate?.(b);let w=new hr(b);return Qt({success:!1,outcomeIndeterminate:!0,x1:a,y1:c,x2:l,y2:u,duration:d,error:w.message},w)},y=!1;try{o(p);let b=await zt(s,n.searchDragState);if(o(p),h?.(),!b.success||b.sdkInt===void 0||b.sdkInt<26)return f();let w=await s.requestDrag({x1:a,y1:c,x2:l,y2:u,pressDurationMs:0,dragDurationMs:d,holdDurationMs:ie,timeoutMs:5000,signal:p,displayId:m,beforeSend:h,onDispatch:()=>{y=!0,n.onDispatched?.()}});if(o(p),!w.success){if(!y)return f();return e.warn(`[SwipeOn] Search drag outcome indeterminate: ${w.error}`),S(w.error??"unknown error")}return{...w,x1:a,y1:c,x2:l,y2:u,duration:d}}catch(b){if(Kt(b,y))throw b;if(o(p),y)return e.warn(`[SwipeOn] Search drag outcome indeterminate: ${r(b)}`,b),S(b);return e.debug(`[SwipeOn] Precise search drag unavailable: ${r(b)}`,b),f()}}function ve(n,s){if(!n)return s;return{...n,container:ve(n.container,s)}}function Ue(n){if(!C(n.container)&&!W(n.lookFor))return"";let s=[];for(let a=ve(n.lookFor?.container,n.container);a;a=a.container)s.unshift(JSON.stringify(a.elementId??a.text));return s.length?` within container scope ${s.join(" > ")}`:""}function Jt(n){if(n.selectionStrategy==="unique")return!0;for(let s=n.container;s;s=s.container)if(s.selectionStrategy==="unique")return!0;return!1}function Zt(n,s){let a=s?n.find((l)=>l.element===s):void 0;if(!a)return{nodes:n,container:void 0};let c="swipe-resolved-scope";while(n.some((l)=>l.nativeId===c||l.nodeKey===c))c+="_";return{nodes:n.map((l)=>l===a?{...l,nodeKey:c}:l),container:{elementId:c}}}function C(n){return ls(n,"swipe-container-options")}function W(n){return ls(n,"swipe-look-for-options")}function qe({lookFor:n,container:s,containerElement:a,resolver:c,nodes:l,id:u}){if(!n.text&&!n.elementId)return null;let d=Zt(l,s&&!Jt(n)?a:void 0),p={...n,container:ve(n.container,d.container??s)},m=c.resolve({id:u,nodes:d.nodes},p,{action:"inspect"});if(Ed(m.error)||m.error?.startsWith("Target not found"))return null;if(m.error)throw new t(m.error);return Aa(m,p)?.element??null}class V extends Error{swipesDispatched;constructor(n,s){super(`${Ye} after ${n} swipe(s) were dispatched; the screen has scrolled. Observe before retrying.`,s);this.swipesDispatched=n;this.name="SwipeSearchCancelledError"}}var er=(n)=>n instanceof Error&&(n.message===Ye||n.name==="AbortError");function ze(n,s,a){if(!s?.aborted||a.dispatched===0||St(n)||!er(n))return n;return new V(a.dispatched,{cause:n})}var FV=Ji,TC=Ji-Ya,nL=PT,iL=TC/1,LV=0,BV=0,Aw=1,Tw=TC;function L(n){if(n.durationMs!==void 0)return n.durationMs;if(n.duration!==void 0)return n.duration;return n.geometry.getSwipeDurationFromSpeed(n.speed)}function k(n){return n.boomerang?{apexPauseMs:n.apexPause??100,returnSpeed:n.returnSpeed??1}:void 0}function Ke(n,s){return Math.max(1,Math.round(n/s))}function je(n,s){let a=Ke(n,s);if(!Number.isFinite(n)||n<0||!Number.isFinite(s)||s<=BV||s>iL||!Number.isFinite(a)||a>TC)return`returnSpeed must be finite, > 0 and <= ${iL}, and produce a finite return duration <= ${TC}ms; increase returnSpeed or shorten the forward duration`;return null}function F(n){let s=je(n.forwardDuration,n.returnSpeed);if(s)throw new t(s);return Ke(n.forwardDuration,n.returnSpeed)}function tr(n,s){if(!Number.isFinite(n.apexPauseMs)||n.apexPauseMs<LV||n.apexPauseMs>nL)return`apexPause must be finite and >= 0 and <= ${nL}ms; shorten the apex pause`;let a=je(s,n.returnSpeed);if(a)return a;let c=F({forwardDuration:s,returnSpeed:n.returnSpeed});if(s+n.apexPauseMs+c>FV)return`boomerang duration must be <= ${FV}ms; shorten duration/apexPause or increase returnSpeed`;return null}function oL(n){let{durationMs:s}=n;if(s===void 0)return null;if(n.speed!==void 0)return"durationMs cannot be combined with speed; give one or the other";if(n.lookFor)return"durationMs cannot be used with lookFor; search swipes choose their own pace";if(!Number.isInteger(s)||s<Aw||s>Tw)return`durationMs must be an integer from ${Aw} to ${Tw} ms`;return null}function Xh(n,s=L({...n,geometry:new or})){let a=oL(n);if(a)return a;if(n.boomerang&&n.lookFor)return"boomerang cannot be used with lookFor";if(!n.boomerang&&(n.apexPause!==void 0||n.returnSpeed!==void 0))return"apexPause/returnSpeed require boomerang=true";let c=k(n);return c?tr(c,s):null}var $5=4,$V=50,U5=0.5,Qe=0.7,rr={left:"right",right:"left",top:"down",bottom:"up"};function ir(n){let{edgeInset:s,at:a}=n;if(s!==void 0&&(!Number.isInteger(s)||s<0||s>$V))return`edgeInset must be an integer from 0 to ${$V}`;if(a!==void 0&&!(Number.isFinite(a)&&a>=0&&a<=1))return"at must be a finite number from 0 to 1";return null}function H5(n){if(n.fromEdge===void 0)return n.edgeInset!==void 0||n.at!==void 0?"edgeInset/at require fromEdge":null;if(n.container||n.lookFor||n.autoTarget===!0)return"fromEdge swipes the screen or panel edge; it cannot be combined with container, lookFor, or autoTarget=true";let s=ir(n);if(s)return s;let a=rr[n.fromEdge];if(n.direction!==a)return`fromEdge "${n.fromEdge}" swipes inward, so the finger direction must be "${a}"`;return null}function ae(n){return H5({...n,direction:td(n).direction??n.direction})}function ge(n){let{edge:s,bounds:a}=n,c=n.inset??$5,l=n.at??U5,u=a.right-a.left,d=a.bottom-a.top,p=(w,v,O)=>Math.min(O,Math.max(v,w)),m=p(Math.round(a.left+l*u),a.left,a.right-1),h=p(Math.round(a.top+l*d),a.top,a.bottom-1),f=Math.round(u*Qe),S=Math.round(d*Qe),y=(w)=>p(w,a.left,a.right-1),b=(w)=>p(w,a.top,a.bottom-1);switch(s){case"left":return{x1:y(a.left+c),y1:h,x2:y(a.left+c+f),y2:h};case"right":return{x1:y(a.right-1-c),y1:h,x2:y(a.right-1-c-f),y2:h};case"top":return{x1:m,y1:b(a.top+c),x2:m,y2:b(a.top+c+S)};case"bottom":return{x1:m,y1:b(a.bottom-1-c),x2:m,y2:b(a.bottom-1-c-S)}}}function Je(n,s,a){let{x1:c,y1:l,x2:u,y2:d}=ge({edge:s,bounds:a,inset:n.edgeInset,at:n.at});return{startX:c,startY:l,endX:u,endY:d}}function nr(n,s){if(!Number.isFinite(n)||!Number.isFinite(s))return;if(n<=0||s<=0)return;let a=n/(s/1000),c=Math.min(Math.max(a,100),1e4),l=Math.round(n/c*1000);if(Math.abs(l-s)<=1)return;return{effectiveDurationMs:l,warning:`durationMs ${s} was clamped on the iOS XCUICoordinate swipe route: velocity is limited to 100-10000 pt/s, so this ${Math.round(n)} pt swipe ran for about ${l} ms (effectiveDurationMs). The unpinned synthesized route honours the duration down to 50 ms.`}}function Ze(n,s,a){let{swipeRoute:c,effectiveDurationMs:l}=a;if(c===void 0||l===void 0){let u=nr(n,s);return u?{effectiveDurationMs:u.effectiveDurationMs,warnings:[u.warning]}:{}}if(Math.abs(l-s)<=1)return{dispatchRoute:c};return{dispatchRoute:c,effectiveDurationMs:l,warnings:[c==="xcuiCoordinate"?`durationMs ${s} was clamped on the iOS XCUICoordinate swipe route: velocity is limited to 100-10000 pt/s, so this swipe ran for about ${l} ms (effectiveDurationMs).`:`durationMs ${s} was adjusted on the iOS ${c} swipe route: the runner dispatched ${l} ms (effectiveDurationMs; the synthesized route floors the stroke at 50 ms).`]}}var sr="durationMs was ignored: the TalkBack semantic scroll route (ACTION_SCROLL on the container) performs a discrete scroll with no timed stroke, so the reported duration is a nominal value. Use a container without a stable selector, or turn TalkBack off, to get a timed swipe.";function ce(n,s){return{success:!0,...n,duration:s?.duration||300,durationIgnored:!0,...s?.durationExplicit?{warnings:[sr]}:{}}}function X(n){return n.durationMs===void 0?void 0:!0}function UV(n,s,a,c){if(c<=0)return n;let l=Math.hypot(a.x-s.x,a.y-s.y);return{...n,velocityPxPerSecond:Math.round(l/c*1000)}}function et(n,s){if(!n.success||n.durationIgnored||s.boomerang||s.lookFor)return n;if(![n.x1,n.y1,n.x2,n.y2].every(Number.isFinite))return n;return UV(n,{x:n.x1,y:n.y1},{x:n.x2,y:n.y2},n.effectiveDurationMs??n.duration)}var cr=["lookFor","focusTarget","autoTarget","includeSystemInsets","scrollMode","layer"];function lr(n,s){if(!s||n.warnings?.includes(s))return n;return{...n,warnings:[...n.warnings??[],s]}}function dr({options:n,platform:s}){return cr.find((a)=>n[a]!==void 0&&(s!=="android"||a==="focusTarget"||a==="layer"))}function pr(n,s,a){let c=a??{left:0,top:0,right:s.screenSize.width,bottom:s.screenSize.height};if(n.fromEdge)return ge({edge:n.fromEdge,bounds:c,inset:n.edgeInset,at:n.at});let l=Math.round((c.left+c.right)/2),u=Math.round((c.top+c.bottom)/2),d=Math.round((c.right-c.left)*0.6)/2,p=Math.round((c.bottom-c.top)*0.6)/2;switch(n.direction){case"left":return{x1:l+d,y1:u,x2:l-d,y2:u};case"right":return{x1:l-d,y1:u,x2:l+d,y2:u};case"up":return{x1:l,y1:u+p,x2:l,y2:u-p};default:return{x1:l,y1:u-p,x2:l,y2:u+p}}}function xe(n){return n instanceof t&&n.containerFailure?{containerFailure:n.containerFailure}:{}}class De{ctx;constructor(n){this.ctx=n}async executeOnAndroidDisplay({options:n,target:s,signal:a,talkBack:c}){let l=s.observation;if(n.container||n.autoTarget===!0)l=await M(l,(A)=>this.ctx().observeScreen.execute({...wc,display:s.followUpDisplay,freshness:"fresh",timeoutMs:A,signal:a}),this.ctx().timer,a);let u=this.validateSelectedDisplayObservation({observation:l,target:s,includeSystemInsets:n.includeSystemInsets}),d=await this.ctx().androidXr(u,a),{options:p,decision:m}=this.selectedDisplayAutoTarget({androidXr:d,options:n,observation:u}),{x1:h,y1:f,x2:S,y2:y,targetType:b,warning:w}=this.resolveDisplaySwipeCoordinates({options:p,decision:m,observation:u,androidXr:d}),v=L({...p,geometry:this.ctx().geometry}),O=k(p),g=JD(u,d);if(c.enabled||g){let A=await this.dispatchTalkBackDisplaySwipe({options:p,element:m.element??(g?this.selectedDisplayContainerElement(p,u):void 0),observation:u,coordinates:{x1:h,y1:f,x2:S,y2:y},duration:v,boomerang:O,target:s,signal:a});return this.ctx().autoTargeting.withAutoTargetDecision({result:{...A,targetType:b,warning:w},decision:m})}let D=await this.resolveDisplaySwipeRoute({options:p,target:s});await this.dispatchDisplaySwipeLeg({x1:h,y1:f,x2:S,y2:y,duration:v,target:s,observation:u,useCtrlProxy:D,signal:a});let I=v;if(O){let A=F({forwardDuration:v,returnSpeed:O.returnSpeed});I+=O.apexPauseMs+A;let R=await HC({timer:this.ctx().timer,apexPauseMs:O.apexPauseMs,signal:a,returnSwipe:()=>this.dispatchDisplayReturnLeg({x1:S,y1:y,x2:h,y2:f,duration:A,target:s,observation:u,useCtrlProxy:D,signal:a})});if(!R.success)return this.ctx().autoTargeting.withAutoTargetDecision({result:{...R,targetType:b,x1:h,y1:f,x2:S,y2:y,duration:I,warning:w},decision:m})}return this.ctx().autoTargeting.withAutoTargetDecision({result:{success:!0,targetType:b,x1:h,y1:f,x2:S,y2:y,duration:I,warning:w,...c.unknownWarning?{warnings:[c.unknownWarning]}:{}},decision:m})}async resolveDisplayTalkBack(n,s){let a=await this.ctx().accessibilityDetector.resolveTalkBackState(this.ctx().device.deviceId,this.ctx().adb,this.ctx().featureFlags);if(o(s),a!==!0)return{enabled:!1,unknownWarning:a===null?Na:void 0};let c=vg(n.displayId,"scrolling");if(c)throw c;return{enabled:!0}}async dispatchTalkBackDisplaySwipe({options:n,element:s,observation:a,coordinates:c,duration:l,boomerang:u,target:d,signal:p}){let m=td(n);if(!m.direction)throw new t(m.error??"direction is required");d.assertCurrent();let{x1:h,y1:f,x2:S,y2:y}=c,b=await this.ctx().talkBackExecutor.executeSwipeGesture({x1:h,y1:f,x2:S,y2:y,direction:m.direction,containerElement:s??null,observation:a,gestureOptions:{displayFence:{assertCurrent:d.assertCurrent},duration:l,durationExplicit:X(n),scrollMode:n.scrollMode},perf:void 0,boomerang:u,signal:p});if(o(p),!b.success)throw new t(b.error??"TalkBack swipe failed");return b}resolveDisplaySwipeCoordinates({options:n,decision:s,observation:a,androidXr:c}){let l=BC(a,c);if(s.element&&a.viewHierarchy){let p=this.ctx().resolveContainerSwipeCoordinates({...n,direction:n.direction},a.viewHierarchy,s.element,a);return{x1:p.startX,y1:p.startY,x2:p.endX,y2:p.endY,targetType:"element",warning:IL(p.warning,l)}}let u=this.selectedDisplayContainerElement(n,a)?.bounds;if(n.container&&!u)throw new t("Swipe container not found on selected display");let d=u?void 0:b3(a.backStack,c,n.fromEdge);return{...pr(n,a,d??this.resolveDisplaySwipeBounds(n,a,u)),targetType:u?"element":"screen",...l?{warning:l}:{}}}resolveDisplaySwipeBounds(n,s,a){return n.includeSystemInsets===!1||n.autoTarget===!0&&!a&&n.includeSystemInsets!==!0?this.insetDisplaySwipeBounds({observation:s,bounds:a}):a}selectedDisplayAutoTarget({options:n,observation:s,androidXr:a}){if(n.autoTarget!==!0||n.container)return{options:n,decision:{}};let c=td(n);if(!c.direction)throw new t(c.error??"direction is required");let l=s.viewHierarchy?this.ctx().scrollables.findScrollableElements(s.viewHierarchy).filter((d)=>T(d,a)):[],u=this.ctx().autoTargeting.resolveAutoTargetDecision({scrollables:l,candidates:this.ctx().autoTargeting.buildScrollableCandidates(l),observeResult:s,direction:c.direction,includeSystemInsets:n.includeSystemInsets});return{options:{...n,direction:c.direction,container:u.container},decision:u}}async resolveDisplaySwipeRoute({options:n,target:s}){if(n.scrollMode==="adb")return!1;let a=await Ba(this.ctx().accessibilityService,s.displayId);if(n.scrollMode==="a11y"&&!a)throw new t(`scrollMode "a11y" requires CtrlProxy capability gesture_display_id_v1 for display "${s.observation.display.key}". Update CtrlProxy or use scrollMode "adb".`);return a}insetDisplaySwipeBounds({observation:n,bounds:s}){let a={observation:n,platform:re(this.ctx().device.platform,"swipeOn")},c=ju(a)??n.screenSize;return fE({...a,bounds:s??Ys(c)})}validateSelectedDisplayObservation(n){let{observation:s,target:a,includeSystemInsets:c}=n;if(a.assertCurrent(),s.display.key!==a.observation.display.key)throw Af(a.observation.display.generation,this.ctx().displayTransitionReader.identityRevision(this.ctx().device.deviceId),this.ctx().displayTransitionReader.currentObservedPanel(this.ctx().device.deviceId)?.key);if(c!==void 0&&s.insets?.available!==!0)throw new t(`includeSystemInsets is not supported with \`display\` for display "${a.observation.display.key}": per-display system insets are unavailable`);return s.insets?.available===!0?s:{...s,systemInsets:{top:0,right:0,bottom:0,left:0}}}async resolveSearchDisplaySwipeRoute({options:n,target:s,signal:a}){if(n.scrollMode==="a11y")return this.resolveDisplaySwipeRoute({options:n,target:s});try{return await this.resolveDisplaySwipeRoute({options:n,target:s})}catch(c){return o(a),e.debug("[SwipeOn] CtrlProxy display gesture capability unavailable",c),!1}}executeDisplayTalkBackSwipe(n){return n.onDispatched?.(),this.ctx().talkBackExecutor.executeSwipeGesture({x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,direction:n.direction,containerElement:n.spatialPanel?this.selectedDisplayContainerElement(n.options,n.observation)??null:null,observation:n.observation,gestureOptions:{displayFence:{assertCurrent:n.target.assertCurrent},duration:n.duration,scrollMode:n.options.scrollMode,searchDragState:n.searchDragState},perf:void 0,boomerang:void 0,signal:n.signal})}validatedObserveScreen(n,s){let a=this.ctx().observeScreen;return{execute:async(c)=>(s.assertCurrent(),n(await a.execute(c))),getMostRecentCachedObserveResult:a.getMostRecentCachedObserveResult.bind(a),appendRawViewHierarchy:a.appendRawViewHierarchy.bind(a),captureScreenshot:a.captureScreenshot?.bind(a),runAccessibilityAudit:a.runAccessibilityAudit?.bind(a),processRecomposition:a.processRecomposition?.bind(a),captureCacheGeneration:a.captureCacheGeneration?.bind(a),cacheObserveResult:a.cacheObserveResult?.bind(a)}}async searchOnAndroidDisplay({options:n,target:s,progress:a,signal:c,talkBack:l}){let u=td(n);if(u.error)throw new t(u.error);let d=await this.resolveSearchDisplaySwipeRoute({options:n,target:s,signal:c}),p=s.followUpDisplay,m=(b)=>this.validateSelectedDisplayObservation({observation:b,target:s,includeSystemInsets:n.includeSystemInsets}),h=this.validatedObserveScreen(m,s),f=!1,S=async(b)=>{try{return s.assertCurrent(),m(await this.ctx().observeScreen.execute({display:p,freshness:b?.freshness??"cached-ok",timeoutMs:b?.timeoutMs,skipScreenshot:!0,skipAccessibilityAudit:!0,signal:c}))}catch(w){throw this.ctx().rethrowObservationAbort(w,c),e.warn(`[SwipeOn] Display search read failed: ${r(w)}`,w),f?new hr(w):w}},y=await this.ctx().scrollUntilVisible.executeWithStrategy({options:{...n,direction:u.direction},progress:a,signal:c,strategy:{observe:S,swipe:async({previousObservation:b,searchDragState:w,onDispatched:v,...O})=>{let g=await this.ctx().visual.observedInteraction(async()=>{let D=async()=>(O.onSearchFallback?.(),await this.dispatchDisplaySwipeLeg({...O,observation:b,target:s,useCtrlProxy:!1,signal:c,onDispatched:v}),f=!0,{...O,success:!0}),I=JD(b,await this.ctx().androidXr(b,c)),A=await(l.enabled||I?this.executeDisplayTalkBackSwipe({...O,observation:b,direction:u.direction,options:n,target:s,searchDragState:w,spatialPanel:I,signal:c,onDispatched:v}):d?se({...O,searchDragState:w,client:this.ctx().accessibilityService,signal:c,displayId:s.displayId===0?void 0:s.displayId,beforeSend:s.assertCurrent,fallback:D,onDispatched:v,onIndeterminate:(R)=>{throw new hr(R)}}):D());return f||=A.success,A},{changeExpected:!1,timeoutMs:Tt.brief,display:p,previousObservation:b,progress:a,signal:c,deferPostActionScreenshot:!0,postActionObserveScreen:h});return this.ctx().checkPostActionDisplay(g,()=>m(g.observation),c),{...O,targetType:"screen",success:g.success,error:g.error,outcomeIndeterminate:g.outcomeIndeterminate,observation:g.observation,staleDisplay:g.staleDisplay}}}});if(f)this.ctx().checkPostActionDisplay({},s.assertCurrent,c);else s.assertCurrent();return lr(y,l.unknownWarning)}async dispatchDisplayReturnLeg(n){let{x1:s,y1:a,x2:c,y2:l,duration:u,signal:d}=n;try{return await this.dispatchDisplaySwipeLeg(n),{success:!0,x1:s,y1:a,x2:c,y2:l,duration:u}}catch(p){if(o(d),St(p)||p instanceof Ee)throw p;if(p instanceof Error&&p.name==="AbortError")throw p;return e.warn(`swipeOn display return leg failed: ${r(p)}`,p),{success:!1,error:r(p),x1:s,y1:a,x2:c,y2:l,duration:u}}}async dispatchDisplaySwipeLeg(n){let{x1:s,y1:a,x2:c,y2:l,duration:u,target:d,useCtrlProxy:p,signal:m,onDispatched:h}=n;if(d.assertCurrent(),o(m),Bk(n.observation,await this.ctx().androidXr(n.observation,m)),p){let f=await this.ctx().accessibilityService.requestSwipe({x1:s,y1:a,x2:c,y2:l,duration:u,onDispatch:h,signal:m,displayId:d.displayId===0?void 0:d.displayId,beforeSend:d.assertCurrent});if(o(m),!f.success)throw new t(f.error??"Android swipe failed")}else await Ec(this.ctx().adb,`swipe ${s} ${a} ${c} ${l} ${zo(u)}`,d.displayId,{signal:m,assertCurrent:d.assertCurrent,onDispatch:h})}selectedDisplayContainerElement(n,s){if(!n.container||!s.viewHierarchy)return;if(C(n.container))return this.ctx().scrollUntilVisible.resolveSwipeContainer(s.viewHierarchy,n.container);let a=this.ctx().scrollUntilVisible.resolveElement(s.viewHierarchy,n.container,"inspect",n.container.text!==void 0);return a&&n.direction?this.ctx().scrollUntilVisible.resolveSwipeTarget(s.viewHierarchy,a,n.direction):a??void 0}async executeExplicitDisplay(n,s={}){let{progress:a,signal:c}=s;if(n.display!==void 0)try{let l=dr({options:n,platform:this.ctx().device.platform});if(l)throw new t(nP(l));let u=Xh(n,this.ctx().getDuration(n))??ae(n);if(u)throw new t(u);let d=await zi(this.ctx().device,n.display,this.ctx().observeScreen,{adb:this.ctx().adb,lastRenderedObservation:this.ctx().lastRenderedObservation,signal:c,transitions:this.ctx().displayTransitionReader});if(o(c),this.ctx().device.platform==="android"){this.validateSelectedDisplayObservation({observation:d.observation,target:d,includeSystemInsets:n.includeSystemInsets});let p=await this.resolveDisplayTalkBack(d,c);return n.lookFor?await this.searchOnAndroidDisplay({options:n,target:d,progress:a,signal:c,talkBack:p}):await this.ctx().observedSwipeInteraction(()=>this.executeOnAndroidDisplay({options:n,target:d,signal:c,talkBack:p}),{changeExpected:!1,display:d.followUpDisplay,previousObservation:d.observation,signal:c},{boomerang:k(n)})}}catch(l){if(l instanceof V)throw l;if(wW(c,l),l instanceof Error&&l.name==="AbortError")throw l;return e.warn(`swipeOn display routing failed: ${r(l)}`,l),Qt({...this.ctx().createErrorResult(r(l)),...xe(l)},l)}return}}function Re(n){return n.perf??new U}function mr(n,s){return(n.dispatched??s)&&n.acknowledged!==!0||Ml(n)}class AT extends Oe{constructor(n,s=null,a=i){super(n,{adb:s,timer:a});this.device=n}async swipe(n,s={},a={}){switch(o(a.signal),this.device.platform){case"android":return await this.executeAndroidSwipe(n,s,a);case"ios":return await this.executeiOSSwipe(n,s,a);default:throw Rt(this.device.platform,"execute gesture")}}async executeAndroidSwipe(n,s={},a={}){let{x1:c,y1:l,x2:u,y2:d}=n,{signal:p}=a,m=Re(a),h=s.duration??300,f=s.scrollMode||"adb";if(s.searchScroll){let S=s.searchScrollBounds?ne({startX:c,startY:l,endX:u,endY:d},s.searchScrollBounds):{startX:c,startY:l,endX:u,endY:d},y=new or().getSwipeDurationFromSpeed("slow"),b=()=>this.executeAndroidSwipe({x1:S.startX,y1:S.startY,x2:S.endX,y2:S.endY},{duration:y,scrollMode:"adb",displayFence:s.displayFence},a);if(s.scrollMode==="adb")return b();return se({client:E.getInstance(this.device,this.adbFactory),x1:S.startX,y1:S.startY,x2:S.endX,y2:S.endY,duration:y,signal:p,searchDragState:s.searchDragState,onFallback:s.onSearchFallback,fallback:b,beforeSend:()=>s.displayFence?.assertCurrent()})}if(f==="a11y")return await this.executeA11ySwipe(n,h,{perf:m,signal:p,displayFence:s.displayFence});try{await m.track("adbInputSwipe",async()=>{o(p),s.displayFence?.assertCurrent(),await this.adb.executeCommand(`shell input swipe ${c} ${l} ${u} ${d} ${zo(h)}`,{signal:p})}),o(p)}catch(S){if(S instanceof Ee)throw S;return o(p),e.warn(`[SWIPE] ADB swipe failed: ${r(S)}`),{success:!1,x1:c,y1:l,x2:u,y2:d,duration:h,error:r(S)}}return{success:!0,x1:c,y1:l,x2:u,y2:d,duration:h}}async executeA11ySwipe(n,s,a={}){let{x1:c,y1:l,x2:u,y2:d}=n,{signal:p}=a,m=Re(a),h=Lv(a),f=!1,S=(w)=>({success:!1,outcomeIndeterminate:!0,x1:c,y1:l,x2:u,y2:d,duration:s,error:`Swipe outcome is indeterminate: the request was dispatched but no result was confirmed (${w}). Do not retry automatically.`}),y,b="failure";try{o(p);let w=E.getInstance(this.device,this.adbFactory),v=await m.track("a11ySwipe",async()=>(o(p),h.assertCurrent(),await w.requestSwipe({x1:c,y1:l,x2:u,y2:d,duration:s,timeoutMs:5000,perf:m,onDispatch:()=>{f=!0}})));if(o(p),v.success)return e.info(`[SWIPE] A11y swipe successful: deviceTotal=${v.totalTimeMs}ms, gesture=${v.gestureTimeMs}ms`),{success:!0,x1:c,y1:l,x2:u,y2:d,duration:s,a11yTotalTimeMs:v.totalTimeMs,a11yGestureTimeMs:v.gestureTimeMs};if(f)return e.warn(`[SWIPE] A11y swipe outcome indeterminate: ${v.error}`),S(v.error??"unknown error");e.warn(`[SWIPE] A11y swipe failed: ${v.error}, falling back to ADB`),y=v.error}catch(w){if(w instanceof Ee)throw w;if(o(p),f)return e.warn(`[SWIPE] A11y swipe outcome indeterminate: ${w}`),S(`${w}`);e.warn(`[SWIPE] A11y swipe exception: ${w}, falling back to ADB`),y=r(w),b="exception"}try{await m.track("adbInputSwipeFallback",async()=>{o(p),h.assertCurrent(),await this.adb.executeCommand(`shell input swipe ${c} ${l} ${u} ${d} ${zo(s)}`,{signal:p})}),o(p)}catch(w){if(w instanceof Ee)throw w;return o(p),e.warn(`[SWIPE] ADB fallback failed after a11y ${b}: ${r(w)}`),{success:!1,x1:c,y1:l,x2:u,y2:d,duration:s,fallbackReason:y,error:`Accessibility swipe failed: ${y??"unknown error"}; ADB fallback failed: ${r(w)}`}}return{success:!0,x1:c,y1:l,x2:u,y2:d,duration:s,fallbackReason:y}}async executeiOSSwipe(n,s={},a={}){return await this.executeXCTestSwipe(n,s,a)}async executeXCTestSwipe(n,s={},a={}){let{x1:c,y1:l,x2:u,y2:d}=n,p=s.duration||300,{signal:m}=a,h=Re(a),f=s.displayFence;o(m);let S=x.getInstance(this.device),y=!1,b=(v)=>({success:!1,outcomeIndeterminate:!0,x1:c,y1:l,x2:u,y2:d,duration:p,error:`Swipe outcome is indeterminate: the request was dispatched but no result was confirmed (${v}). The swipe may have been applied. Do not retry automatically.`}),w;try{w=await h.track("xctestSwipe",async()=>(o(m),f?.assertCurrent(),await S.requestSwipe({x1:c,y1:l,x2:u,y2:d,duration:p,timeoutMs:Math.min(5000,s.timeoutMs??5000),perf:h,contextOptions:s.lockScreen===!0?{lockScreen:!0}:void 0,signal:m,onDispatch:()=>{y=!0}})))}catch(v){if(!y||v instanceof t)throw v;return e.warn(`[SWIPE] CtrlProxy iOS swipe outcome indeterminate: ${r(v)}`),b(r(v))}if(!w.success&&mr(w,y))return e.warn(`[SWIPE] CtrlProxy iOS swipe outcome indeterminate: ${w.error}`),b(w.error??"unknown error");if(o(m),w.success){e.info(`[SWIPE] CtrlProxy iOS swipe successful: deviceTotal=${w.totalTimeMs}ms, gesture=${w.gestureTimeMs}ms`);let v=Ze(Math.hypot(u-c,d-l),p,w);return{success:!0,x1:c,y1:l,x2:u,y2:d,duration:p,a11yTotalTimeMs:w.totalTimeMs,a11yGestureTimeMs:w.gestureTimeMs,...v}}else return e.error(`[SWIPE] CtrlProxy iOS swipe failed: ${w.error}`),{success:!1,x1:c,y1:l,x2:u,y2:d,duration:p,error:w.error}}async execute(n,s,a,c={}){let{durationMs:l=300,signal:u,displayFence:d}=typeof s==="object"?s:{durationMs:s,signal:a,displayFence:c.displayFence};switch(o(u),this.device.platform){case"android":return await this.executeAndroidGesture(n,l,u,{displayFence:d});case"ios":return await this.executeiOSGesture(n,l,u,{displayFence:d});default:throw Rt(this.device.platform,"execute gesture")}}async executeAndroidGesture(n,s,a,c={}){let l=c.displayFence;if(Array.isArray(n)&&n.length>0)if("finger"in n[0])throw Error("Multi-finger gestures not supported - use simple swipe instead");else{let u=n;if(u.length>=2){let d=u[0],p=u[u.length-1];o(a),l?.assertCurrent(),await this.adb.executeCommand(`shell input swipe ${d.x} ${d.y} ${p.x} ${p.y} ${zo(s)}`,{signal:a}),o(a)}}return{pathLength:n.length,duration:s,platform:"android"}}async executeiOSGesture(n,s,a,c={}){let l=c.displayFence;if(Array.isArray(n)&&n.length>0)if("finger"in n[0]){let u=n,d=this.resolveIOSMultiFingerSwipe(u);if(d)await this.executeIOSMultiFingerSwipe(d,s,a,l)}else{let u=n;if(u.length>=2)await this.executeIOSSingleFingerSwipe(u[0],u[u.length-1],s,{signal:a,fence:l})}return{pathLength:n.length,duration:s,platform:"ios"}}async executeIOSSingleFingerSwipe(n,s,a,{signal:c,fence:l}={}){o(c);let u=x.getInstance(this.device);l?.assertCurrent();let d=await u.requestSwipe({x1:n.x,y1:n.y,x2:s.x,y2:s.y,duration:a,signal:c});if(this.throwIfIosGestureUnconfirmed(d),o(c),!d.success)throw new t(`iOS gesture failed: ${d.error??"unknown error"}`)}async executeIOSMultiFingerSwipe(n,s,a,c){o(a);let l=x.getInstance(this.device);c?.assertCurrent();let u=await l.requestMultiFingerSwipe({x1:n.start.x,y1:n.start.y,x2:n.end.x,y2:n.end.y,fingerCount:n.fingerCount,duration:s,fingerSpacing:n.fingerSpacing,signal:a,beforeSend:()=>c?.assertCurrent()});if(this.throwIfIosGestureUnconfirmed(u),o(a),!u.success)throw new t(`iOS multi-finger gesture failed: ${u.error??"unknown error"}`)}throwIfIosGestureUnconfirmed(n){if(!n.success&&n.dispatched&&(n.acknowledged===!1||Ml(n)))throw new t(`Gesture outcome is indeterminate: the request was dispatched but no result was confirmed (${n.error??"unknown error"}). The gesture may have been applied. Do not retry automatically. Observe before retrying.`)}resolveIOSMultiFingerSwipe(n){if(n.length===0)return null;for(let u=0;u<n.length;u++){let d=n[u].points;if(d.length<2)throw Error("iOS multi-finger gestures require at least two points per finger");if(d.length!==2)throw Error("iOS multi-finger gestures only support two-point swipes")}let s=n[0].points,a=s[0],c=s[1],l=n.length>1?n[1].points[0].x-a.x:0;for(let u=0;u<n.length;u++){let d=n[u].points,p=d[0],m=d[1],h=u*l;if(!this.sameCoordinate(p.y,a.y)||!this.sameCoordinate(m.y,c.y)||!this.sameCoordinate(p.x-a.x,h)||!this.sameCoordinate(m.x-c.x,h))throw Error("iOS multi-finger gestures only support horizontally spaced parallel swipes")}return{start:a,end:c,fingerCount:n.length,fingerSpacing:l}}sameCoordinate(n,s){return Math.abs(n-s)<0.001}}class G{geometry;elementParser;static OVERLAY_PADDING=8;static CANDIDATE_FRACTIONS=[0.5,0.25,0.75,0.15,0.85];constructor(n,s){this.geometry=n;this.elementParser=s}collectOverlayCandidates(n,s){let a=this.elementParser,c=a.extractWindowRootGroups(n,"topmost-first"),l=c.length>0?c:[a.extractRootNodes(n)],u=Math.max(1,l.length),d=[],p=new Set,m=s.bounds,h=this.resolveSelectedContainerNode(n,a,s,m),f=h?.node??null,S=this.collectContainerAncestors(h?.roots??null,a,f),y=this.findContainerWindowIndex(l,a,f);return l.forEach((b,w)=>{if(y!==null&&w>y)return;let v=u-w,O=0;for(let g of b){let D=!1,I=-1;a.traverseNode(g,(A,R)=>{if(p.has(A))return;p.add(A);let pe=O++,H=a.extractNodeProperties(A);if(this.isContainerNode(A,H,f,{containerElement:s,containerBounds:m})){if(!D)D=!0,I=R;return}if(D&&R<=I)D=!1,I=-1;if(D||S.has(A))return;if(!this.isClickableNode(H))return;let _=a.parseNodeBounds(A);if(!_)return;let B=this.intersectBounds(m,_.bounds);if(!B)return;let z=ft(B);if(z<=0)return;d.push({bounds:_.bounds,overlapBounds:B,coverage:z,zOrder:{windowRank:v,nodeOrder:pe}})})}}),d}computeSafeSwipeCoordinates(n,s,a){let c=n==="up"||n==="down",l=c?s.top:s.left,u=c?s.bottom:s.right,d=c?s.left:s.top,p=c?s.right:s.bottom,m=this.buildCandidateCoordinates(d,p),h=this.findBestSwipeCandidate(c,s,a,{candidates:m,primary:{start:l,end:u}});if(!h)return null;let f=c?{left:s.left,right:s.right,top:h.interval.start,bottom:h.interval.end}:{left:h.interval.start,right:h.interval.end,top:s.top,bottom:s.bottom},S=this.geometry.getSwipeWithinBounds(n,f),{startX:y,startY:b,endX:w,endY:v}=S;if(c)y=h.coordinate,w=h.coordinate;else b=h.coordinate,v=h.coordinate;y=uo(y,f.left,f.right),w=uo(w,f.left,f.right),b=uo(b,f.top,f.bottom),v=uo(v,f.top,f.bottom);let O=Math.max(1,u-l),g=Math.max(50,O*0.1),D=h.interval.length<g?`Swipe area reduced by overlaying elements; safe ${c?"height":"width"} is ${Math.round(h.interval.length)}px.`:void 0;return{startX:y,startY:b,endX:w,endY:v,warning:D}}findBestSwipeCandidate(n,s,a,{candidates:c,primary:l}){let u=null;for(let d of c){let p=n?this.getBlockedIntervalsForX(a,s,d):this.getBlockedIntervalsForY(a,s,d),m=this.findLargestGap(l.start,l.end,p);if(!m)continue;if(!u||m.length>u.interval.length)u={coordinate:d,interval:m}}return u}getBlockedIntervalsForX(n,s,a){let c=[];for(let l of n){let u=this.expandBounds(l,G.OVERLAY_PADDING);if(a<u.left||a>u.right)continue;let d=Math.max(s.top,u.top),p=Math.min(s.bottom,u.bottom);if(p>d)c.push({start:d,end:p,length:p-d})}return c}getBlockedIntervalsForY(n,s,a){let c=[];for(let l of n){let u=this.expandBounds(l,G.OVERLAY_PADDING);if(a<u.top||a>u.bottom)continue;let d=Math.max(s.left,u.left),p=Math.min(s.right,u.right);if(p>d)c.push({start:d,end:p,length:p-d})}return c}findLargestGap(n,s,a){let c=this.mergeIntervals(a),l=n,u=null;for(let d of c){if(d.start>l){let p={start:l,end:d.start,length:d.start-l};if(!u||p.length>u.length)u=p}l=Math.max(l,d.end)}if(l<s){let d={start:l,end:s,length:s-l};if(!u||d.length>u.length)u=d}return u}mergeIntervals(n){let s=n.filter((c)=>c.end>c.start).sort((c,l)=>c.start-l.start),a=[];for(let c of s){let l=a[a.length-1];if(!l||c.start>l.end){a.push({...c});continue}l.end=Math.max(l.end,c.end),l.length=l.end-l.start}return a}buildCandidateCoordinates(n,s){let a=s-n;if(a<=0)return[];let c=G.CANDIDATE_FRACTIONS.map((l)=>Math.floor(n+a*l));return Array.from(new Set(c.filter((l)=>l>=n&&l<=s)))}expandBounds(n,s){return{left:n.left-s,top:n.top-s,right:n.right+s,bottom:n.bottom+s}}intersectBounds(n,s){let a=Math.max(n.left,s.left),c=Math.min(n.right,s.right),l=Math.max(n.top,s.top),u=Math.min(n.bottom,s.bottom);if(c<=a||u<=l)return null;return{left:a,top:l,right:c,bottom:u}}collectContainerAncestors(n,s,a){let c=new Set;if(!a||!n)return c;let l=[],u=!1;for(let d of n)if(s.traverseNode(d,(p,m)=>{if(u)return;if(l.length=m,l[m]=p,p===a){for(let h of l.slice(0,m))c.add(h);u=!0}}),u)return c;return c}findContainerWindowIndex(n,s,a){if(!a||n.length<2)return null;let c=n.findIndex((l)=>l.some((u)=>this.treeContains(u,s,a)));return c===-1?null:c}treeContains(n,s,a){let c=!1;return s.traverseNode(n,(l)=>{if(l===a)c=!0}),c}isClickableNode(n){return dt(n.clickable)||dt(n.focusable)}resolveSelectedContainerNode(n,s,a,c){let l=s.extractRootNodes(n),u=this.findSelectorBoundsMatch(l,s,a,c);if(u.matchCount>0)return u.matchCount===1&&u.match?{node:u.match,roots:l}:null;let d=s.extractWindowRootGroups(n,"topmost-first");for(let p of d){let m=this.findSelectorBoundsMatch(p,s,a,c);if(m.matchCount>0)return m.matchCount===1&&m.match?{node:m.match,roots:p}:null}return null}findSelectorBoundsMatch(n,s,a,c){let l=null,u=0;for(let d of n)s.traverseNode(d,(p)=>{let m=s.extractNodeProperties(p);if(!this.matchesContainerSelector(p,m,a,c))return;let h=this.elementParser.parseBounds(qt(p));if(h===null||!Nt(h,c))return;u++,l=p});return{match:l,matchCount:u}}isContainerNode(n,s,a,{containerElement:c,containerBounds:l}){if(a&&n===a)return!0;return this.matchesContainerSelector(n,s,c,l)}matchesContainerSelector(n,s,a,c){let l=Wt(s),u=Boolean(a["resource-id"]),d=Boolean(a.text),p=Boolean(a["content-desc"]);if(u||d||p){if(u&&l.nativeId!==a["resource-id"])return!1;if(d&&l.textSources.text!==a.text)return!1;if(p&&l.textSources["content-desc"]!==a["content-desc"])return!1;return!0}let m=this.elementParser.parseBounds(qt(n));return m!==null&&Nt(m,c)}}class q{geometry;constructor(n=new or){this.geometry=n}selectAutoTargetScrollable(n,s,a){let c=n.filter((d)=>this.matchesDirection(d,a));if(c.length===0)return null;let l=s?c.filter((d)=>!Nt(d.bounds,s)):c,u=l.length>0?l:c;if(s){let d=(s.left+s.right)/2,p=(s.top+s.bottom)/2,m=u.filter((h)=>this.geometry.isPointInElement(h,d,p));if(m.length>0)return m.reduce((h,f)=>ft(f.bounds)<ft(h.bounds)?f:h)}if(u.length>1){let d=a==="up"||a==="down",p=u.filter((m)=>{if(this.knownScrollAxis(m))return!0;let h=Math.abs(m.bounds.right-m.bounds.left),f=Math.abs(m.bounds.bottom-m.bounds.top);return d?f>=h:h>=f});if(p.length>0)return this.pickLargestScrollable(p)}return this.pickLargestScrollable(u)}pickLargestScrollable(n){if(n.length===0)return null;return n.reduce((s,a)=>{let c=ft(s.bounds);return ft(a.bounds)>c?a:s})}matchesDirection(n,s){let a=this.knownScrollAxis(n);return a===void 0||(s==="up"||s==="down")===(a==="vertical")}scrollsInDirection(n,s){return(ut(n.scrollable)||this.knownScrollAxis(n)!==void 0)&&this.matchesDirection(n,s)}knownScrollAxis(n){let s=typeof n.orientation==="string"?n.orientation.toLowerCase():void 0;if(s==="horizontal"||s==="vertical")return s;let a=n.class??n.className,c=typeof a==="string"?a.split(".").at(-1)??"":"";if(["HorizontalScrollView","ViewPager","ViewPager2","LazyRow"].includes(c))return"horizontal";if(["ScrollView","NestedScrollView","ListView","ExpandableListView","LazyColumn"].includes(c))return"vertical";return}getScreenBounds(n,s={}){let a=s.platform??zr(n.viewHierarchy)?.platform,c={observation:n,platform:a,includeSystemInsets:a==="ios"?s.includeSystemInsets:void 0},l=ju(c);if(!l)return null;return Ys(l,mE(c))}describeContainer(n){if(!n)return"unknown";if(n.elementId)return`elementId="${n.elementId}"`;if(n.text)return`text="${n.text}"`;return"unknown"}mergeWarnings(...n){let s=n.filter((a)=>Boolean(a));if(s.length===0)return;return Array.from(new Set(s)).join(" ")}}async function it(n,s,a){let{observation:c,direction:l,containerElement:u,gestureOptions:d,signal:p,perf:m}=s;if(!c||!JD(c,a))return;o(p);let h=Ie(l),f=Sr(c,u,h);if(!f)return;if(!await n.supportsNodeActionSelectors(m,p,!0))throw new t("Update CtrlProxy: XR panel scrolling requires verified accessibility node bounds.");if(o(p),d?.displayFence?.assertCurrent(),d?.searchDragState)d.searchDragState.pagingStep=!0;let S=await n.requestNodeAction(h,f.selector,{expectedBounds:f.expectedBounds,signal:p,perf:m});return o(p),fr(S,s)}function fr(n,s){let{gestureOptions:a,x1:c,y1:l,x2:u,y2:d}=s,p={success:!1,x1:c,y1:l,x2:u,y2:d,duration:a?.duration||300,error:"The XR panel cannot scroll further in that direction or its layout changed. Observe again before retrying."};if(n.success)return{...ce({x1:c,y1:l,x2:u,y2:d},a),warnings:["Scrolled the XR panel with an accessibility node action."+(a?.durationExplicit?" durationMs was ignored: a node scroll has no timed stroke; the reported duration is nominal.":""),...s.boomerang?["Boomerang has no return stroke on an XR spatial panel; performed one node scroll."]:[]]};if(n.dispatched&&n.acknowledged!==!0)return{...p,outcomeIndeterminate:!0,retryable:!1,error:`Swipe outcome is indeterminate: the node scroll was dispatched but no result was confirmed (${n.error??"no reply from CtrlProxy"}). Do not retry automatically.`};return p}function tt(){return new t("The XR panel cannot scroll further in that direction or its layout changed. Observe again before retrying.")}function Sr(n,s,a){let c=lt(n.viewHierarchy)??null;if(!Eu(c)){Bk(n,!0);return}let l=ya(c.hierarchy,c.windows),u=new fe,d=u.project({...c,windows:l}),p=YD(n),m=new Set(u.project({hierarchy:{},windows:l?.filter((g)=>g.type===1&&g.packageName===p&&!g.packageName?.startsWith("com.android.systemui"))}).map((g)=>g.source)),h=d.filter((g)=>m.has(g.source)&&g.bounds&&T(g.properties,!0)),f=(g)=>Rr(g.actions,"scroll_forward")||Rr(g.actions,"scroll_backward"),S=h.filter((g)=>f(g.properties)),y=s&&h.find((g)=>(ut(g.properties.scrollable)||f(g.properties))&&mn(g.bounds,s.bounds,0)&&(s["view-id"]?g.properties["view-id"]===s["view-id"]:s["resource-id"]===g.properties["resource-id"])),b=(g)=>(g.right-g.left)*(g.bottom-g.top),w=y||S.sort((g,D)=>b(D.bounds)-b(g.bounds))[0];if(!w){Bk(n,!0);return}if(!Rr(w.properties.actions,a))throw tt();let v=Kn(w.properties),O=d.filter((g)=>v?Dl(g.properties,v):g.bounds&&mn(g.bounds,w.bounds,0)&&Rr(g.properties.actions,a));if(new Set(O.map((g)=>g.source)).size!==1||!O[0]?.bounds||!mn(O[0].bounds,w.bounds,0))throw tt();return{selector:v,expectedBounds:w.bounds}}function Ie(n){return n==="up"||n==="left"?"scroll_forward":"scroll_backward"}class Ae{device;executeGesture;accessibilityService;accessibilityDetector;adb;timer;featureFlags;androidXr;constructor({device:n,executeGesture:s,accessibilityService:a,accessibilityDetector:c,adb:l,timer:u,featureFlags:d,androidXr:p}){this.device=n,this.executeGesture=s,this.accessibilityService=a,this.accessibilityDetector=c,this.adb=l,this.timer=u,this.featureFlags=d,this.androidXr=p}async executeSwipeGesture(n){let{observation:s,x1:a,y1:c,x2:l,y2:u,direction:d,containerElement:p,gestureOptions:m,perf:h,boomerang:f,signal:S}=n;o(S);let y=Boolean(f);if(e.info(`[SwipeOn] executeSwipeGesture: direction=${d}, (${a},${c})\u2192(${l},${u}), duration=${m?.duration}ms, boomerang=${y}, container=${p?.["resource-id"]??"none"}`),this.device.platform!=="android"){if(y)return this.executeBoomerangGesture({x1:a,y1:c,x2:l,y2:u,gestureOptions:m,boomerang:f,perf:h,signal:S});return this.executeGesture.swipe({x1:a,y1:c,x2:l,y2:u},m,{perf:h,signal:S})}let b=await this.accessibilityDetector.resolveTalkBackState(this.device.deviceId,this.adb,this.featureFlags),w=b===!0,v=b===null?Na:void 0;if(o(S),w){if(m?.searchDragState)m.searchDragState.pagingStep=!0;if(y)return e.info("[SwipeOn] TalkBack enabled, boomerang requested; announcing swipeable element"),this.announceSwipeable({x1:a,y1:c,x2:l,y2:u,containerElement:p,gestureOptions:m,perf:h,signal:S});return e.info("[SwipeOn] TalkBack enabled, using accessibility-aware swipe"),this.executeAndroidSwipeWithAccessibility({observation:s,x1:a,y1:c,x2:l,y2:u,direction:d,containerElement:p,gestureOptions:m,perf:h,signal:S})}else return this.executeNonTalkBackSwipe(n,v)}async executeNonTalkBackSwipe(n,s){let{observation:a,x1:c,y1:l,x2:u,y2:d,gestureOptions:p,boomerang:m,perf:h,signal:f}=n,S=await this.executePanelScroll(n);if(S)return ul(S,s);if(await this.assertDisplayInputSupported(a,f),m){let b=await this.executeBoomerangGesture({x1:c,y1:l,x2:u,y2:d,gestureOptions:p,boomerang:m,perf:h,signal:f});return ul(b,s)}let y=await this.executeGesture.swipe({x1:c,y1:l,x2:u,y2:d},p,{perf:h,signal:f});return ul(y,s)}async executeBoomerangGesture({x1:n,y1:s,x2:a,y2:c,gestureOptions:l,boomerang:u,perf:d=new U,signal:p}){let m=l?.duration??300,h=Xh({boomerang:!0,apexPause:u.apexPauseMs,returnSpeed:u.returnSpeed},m);if(h)throw new t(h);let f=this.getReturnDuration(m,u.returnSpeed),S=m+u.apexPauseMs+f,y=this.buildGestureOptions(l,m),b=this.buildGestureOptions(l,f),w=await this.executeGesture.swipe({x1:n,y1:s,x2:a,y2:c},y,{perf:d,signal:p});if(!w.success)return o(p),w;let v=await HC({timer:this.timer,apexPauseMs:u.apexPauseMs,signal:p,returnSwipe:()=>this.executeGesture.swipe({x1:a,y1:c,x2:n,y2:s},b,{perf:d,signal:p})});if(!v.success)return{...v,x1:n,y1:s,x2:a,y2:c,duration:S};return{...w,x1:n,y1:s,x2:a,y2:c,duration:S,a11yTotalTimeMs:this.sumOptional(w.a11yTotalTimeMs,v.a11yTotalTimeMs),a11yGestureTimeMs:this.sumOptional(w.a11yGestureTimeMs,v.a11yGestureTimeMs),fallbackReason:w.fallbackReason??v.fallbackReason}}async announceSwipeable({x1:n,y1:s,x2:a,y2:c,containerElement:l,gestureOptions:u,perf:d=new U,signal:p}){let m=u?.duration??0,h=l?.["resource-id"];if(!h)return e.warn("[SwipeOn] Boomerang swipe in TalkBack mode requires a container element with a resource-id."),{success:!1,error:"Boomerang swipe in TalkBack mode requires a container element with a resource-id.",x1:n,y1:s,x2:a,y2:c,duration:m};o(p);let f=await this.accessibilityService.requestAction("focus",h,5000,{perf:d});if(o(p),!f.success){let S=f.error??"Failed to set accessibility focus for boomerang swipe.";return e.warn(`[SwipeOn] ${S}`),{success:!1,error:S,x1:n,y1:s,x2:a,y2:c,duration:m}}return{success:!0,x1:n,y1:s,x2:a,y2:c,duration:m}}async executeAndroidSwipeWithAccessibility({observation:n,x1:s,y1:a,x2:c,y2:l,direction:u,containerElement:d,gestureOptions:p,perf:m,signal:h}){let f=d&&Kn(d);if(f){let v=await this.attemptAccessibilityScroll({x1:s,y1:a,x2:c,y2:l,direction:u,selector:f,gestureOptions:p,perf:m,signal:h});if(v)return v}else e.debug("[SwipeOn] No container with resource-id, skipping ACTION_SCROLL");let S=await this.executePanelScroll({observation:n,x1:s,y1:a,x2:c,y2:l,direction:u,containerElement:d,gestureOptions:p,perf:m,signal:h});if(S)return S;await this.assertDisplayInputSupported(n,h),e.info("[SwipeOn] Using two-finger swipe gesture for TalkBack");let y=p?.duration||300,b=100;o(h),p?.displayFence?.assertCurrent();let w=await this.accessibilityService.requestTwoFingerSwipe({x1:s,y1:a,x2:c,y2:l,duration:y,offset:b,timeoutMs:5000,perf:m||new U});if(o(h),w.success)return{success:!0,x1:s,y1:a,x2:c,y2:l,duration:y};else throw new t(`Two-finger swipe failed: ${w.error||"Unknown error"}`)}async attemptAccessibilityScroll({x1:n,y1:s,x2:a,y2:c,direction:l,selector:u,gestureOptions:d,perf:p,signal:m}){let h=(b)=>({success:!1,x1:n,y1:s,x2:a,y2:c,duration:d?.duration||300,error:`Swipe outcome is indeterminate: the request was dispatched but no result was confirmed (${b}). Do not retry automatically.`}),f=Ie(l),S=fa(u),y=await bg(u,{supportsNodeActionSelectors:()=>this.accessibilityService.supportsNodeActionSelectors(),getAccessibilityHierarchy:()=>this.accessibilityService.getAccessibilityHierarchy(void 0,{perf:p,skipWaitForFresh:!1,disableAllFiltering:!0})});if(y){e.info(`[SwipeOn] ${y}`);return}e.info(`[SwipeOn] Attempting ACTION_SCROLL (${f}) on container: ${JSON.stringify(u)}`);try{o(m);let b=S?await this.accessibilityService.requestNodeAction(f,u,{timeoutMs:5000,perf:p}):await this.accessibilityService.requestAction(f,u.resourceId,5000,{perf:p||new U});if(b.success)return e.info("[SwipeOn] ACTION_SCROLL succeeded"),ce({x1:n,y1:s,x2:a,y2:c},d);if(b.dispatched&&b.acknowledged!==!0)return e.warn(`[SwipeOn] ACTION_SCROLL outcome indeterminate: ${b.error}`),h(b.error??"unknown error");e.warn(`[SwipeOn] ACTION_SCROLL failed: ${b.error}, falling back to two-finger swipe`)}catch(b){if(b instanceof Ee)throw b;return o(m),e.warn(`[SwipeOn] ACTION_SCROLL outcome indeterminate: ${b}`),h(String(b))}return}async executePanelScroll(n){return it(this.accessibilityService,n,n.observation&&this.androidXr?await this.androidXr(n.observation,n.signal):!1)}async assertDisplayInputSupported(n,s){if(n&&this.androidXr)Bk(n,await this.androidXr(n,s))}buildGestureOptions(n,s){return{...n??{},duration:s}}getReturnDuration(n,s){return F({forwardDuration:n,returnSpeed:s})}sumOptional(n,s){if(n===void 0&&s===void 0)return;return(n??0)+(s??0)}resolveBoomerangConfig(n){return k(n)}}class Y extends t{constructor(n){super(n);this.name="SwipeOutcomeIndeterminateError"}}var wr=3000,yr=W5;function vr(n){return Math.min(Math.max(yr,n+wr),Ur)}function gr(n,s,a){let c=s.viewHierarchy;if(n.containerElement){let d=Hv(n.containerElement),p=d&&sD(c,d.elementId);if(!p)return null;if(n.boomerang)return"unsupported";let m={x:n.x1-n.x2,y:n.y1-n.y2};return{action:{scroll:{...p,delta:m}},verb:"scroll"}}let l=sD(c);if(!l)return null;if(n.boomerang)return"unsupported";return{action:{swipe:{observationIdentity:l.observationIdentity,start:{x:n.x1,y:n.y1},end:{x:n.x2,y:n.y2},durationMs:a}},verb:"swipe"}}var Or="durationMs was ignored: the app's SDK observation bridge scrolls the container by an offset with no timed stroke, so the reported duration is a nominal value.";function xr(n,s){return{...n,durationIgnored:!0,...s.gestureOptions?.durationExplicit?{warnings:[Or]}:{}}}class nt{xctest;options;enabled;constructor(n,s){this.xctest=n;this.options=s;this.enabled=s.enabled??(()=>N.isIosSdkObservationBridgeEnabled())}async executeSwipeGesture(n){let s=Math.max(0,Math.round(n.gestureOptions?.duration??300)),a=this.enabled()&&n.sdkObservation?gr(n,n.sdkObservation,s):null;if(!a)return this.xctest.executeSwipeGesture(n);let c=a==="unsupported"?{backend:"xctest",fallbackReason:"unsupported"}:await this.dispatch(a,s,n);if(c.backend==="sdk"){let{x1:u,y1:d,x2:p,y2:m}=n,h={success:!0,x1:u,y1:d,x2:p,y2:m,duration:s,backend:"sdk"};return a!=="unsupported"&&a.verb==="scroll"?xr(h,n):h}return{...await this.xctest.executeSwipeGesture(n),backend:"xctest",fallbackReason:c.fallbackReason}}async dispatch(n,s,a){a.gestureOptions?.displayFence?.assertCurrent();let c=a.signal,l=this.options.client();if(!l)return{backend:"xctest",fallbackReason:"unavailable"};let u=await l.requestSdkActionForIos(n.action,{timeoutMs:vr(s),signal:c});return kC(u,n.verb)}}function ot(n,s){return new nt(s,{client:()=>x.getExistingInstance(n.deviceId)})}var st="AutoMobile could not determine the current VoiceOver state; used the default gesture. VoiceOver may be enabled.";class at{device;executeGesture;iosClient;iosVoiceOverDetector;timer;featureFlags;constructor({device:n,executeGesture:s,iosClient:a,iosVoiceOverDetector:c,timer:l,featureFlags:u}){this.device=n,this.executeGesture=s,this.iosClient=a,this.iosVoiceOverDetector=c,this.timer=l,this.featureFlags=u}async executeSwipeGesture({x1:n,y1:s,x2:a,y2:c,gestureOptions:l,perf:u=new U,boomerang:d,signal:p}){if(o(p),this.device.platform!=="ios"){if(d)return this.executeBoomerangGesture({x1:n,y1:s,x2:a,y2:c,gestureOptions:l,boomerang:d,perf:u,signal:p});return this.executeGesture.swipe({x1:n,y1:s,x2:a,y2:c},l,{perf:u,signal:p})}let m=await this.iosVoiceOverDetector.resolveState(this.device.deviceId,this.iosClient,{featureFlags:this.featureFlags});if(o(p),m!==!0){let h=m===null?st:void 0,f=d?await this.executeBoomerangGesture({x1:n,y1:s,x2:a,y2:c,gestureOptions:l,boomerang:d,perf:u,signal:p}):await this.executeGesture.swipe({x1:n,y1:s,x2:a,y2:c},l,{perf:u,signal:p});return ul(f,h)}if(d)return this.voiceOverScrollFailure({x1:n,y1:s,x2:a,y2:c},l?.duration??300,"VoiceOver boomerang gestures are not supported because they require XCTest-synthesized touches, which do not reach VoiceOver");return this.voiceOverScrollFailure({x1:n,y1:s,x2:a,y2:c},l?.duration??300,"VoiceOver scrolling is not supported: CtrlProxy only provides XCTest-synthesized touches, which do not reach VoiceOver")}async executeBoomerangGesture({x1:n,y1:s,x2:a,y2:c,gestureOptions:l,boomerang:u,perf:d=new U,signal:p}){let m=l?.duration??300,h=Xh({boomerang:!0,apexPause:u.apexPauseMs,returnSpeed:u.returnSpeed},m);if(h)throw new t(h);let f=F({forwardDuration:m,returnSpeed:u.returnSpeed}),S=m+u.apexPauseMs+f,y=this.buildGestureOptions(l,m),b=this.buildGestureOptions(l,f),w=await this.executeGesture.swipe({x1:n,y1:s,x2:a,y2:c},y,{perf:d,signal:p});if(!w.success)return o(p),w;let v=await HC({timer:this.timer,apexPauseMs:u.apexPauseMs,signal:p,returnSwipe:()=>this.executeGesture.swipe({x1:a,y1:c,x2:n,y2:s},b,{perf:d,signal:p})});if(!v.success)return{...v,x1:n,y1:s,x2:a,y2:c,duration:S};return{...w,x1:n,y1:s,x2:a,y2:c,duration:S}}voiceOverScrollFailure(n,s,a){let{x1:c,y1:l,x2:u,y2:d}=n;return{success:!1,error:a,x1:c,y1:l,x2:u,y2:d,duration:s,fallbackReason:"XCTest-synthesized touches do not reach VoiceOver; no gesture fallback is available"}}buildGestureOptions(n,s){return{...n??{},duration:s}}}function ct(n){if(n.device.platform==="watchos")return{executeSwipeGesture:async()=>vu("VoiceOver swipe")};return ot(n.device,new at({...n,iosClient:x.getInstance(n.device)}))}function pt(n){let s=n.error??"iOS lock-screen swipe failed";return n.outcomeIndeterminate===!0?new Y(s):new t(s)}function Ce(n){return n.success||n.outcomeIndeterminate===!0}class Te{moved=0;pending=0;confirmedFingerprint="";get count(){return this.moved}reset(n){this.moved=0,this.pending=0,this.confirmedFingerprint=n}rebase(n){this.pending=0,this.confirmedFingerprint=n}recordMove(n,s){if(n)this.moved++;else if(s)this.pending++}confirm(n,s){if(!s||!n)return;if(this.pending>0&&n!==this.confirmedFingerprint)this.moved+=this.pending;this.rebase(n)}}var Er=150,Dr=250;class ke{request;deps;host;perf;observe;observationFence;lastObservation;containerElement;lookForOptions;maxTime=0;maxSwipes=0;startTime=0;foundElement=null;scrollIteration=0;lastFingerprint="";unchangedScrollCount=0;maxUnchangedScrolls=2;reachedEnd=!1;moves=new Te;scopeDescription="";target="";accessibilityWarnings=new Set;isTalkBackEnabled=!1;searchDragState={};overlapRecoveryUsed=!1;interruptedDisplay;swipeWarning;lastAndroidSwipeError;reverseMode=!1;reverseDirection;reverseOptions;fallbackLogged=!1;reverseSwipeBudget=Number.POSITIVE_INFINITY;reverseSwipes=0;reverseSweepMs=0;lastIterationMs=0;reverseStopReason;webScroll;onSearchFallback=()=>{if(!this.fallbackLogged)e.debug("[SwipeOn] lookFor using slow ADB swipe fallback (600ms, at most 75% viewport)"),this.fallbackLogged=!0};constructor(n,s,a,c){this.request=n;this.deps=s;this.host=a;this.perf=c;this.observe=n.strategy?.observe??((l)=>s.observeScreen.execute({freshness:l?.freshness??"cached-ok",timeoutMs:l?.timeoutMs,skipScreenshot:!0,skipAccessibilityAudit:!0,signal:n.signal}))}async execute(){if(await this.initialize(),await this.initialSearch(),this.foundElement)return this.initialSuccess();if(await this.scrollWebElementIntoView(),this.foundElement)return this.initialSuccess();this.initializeLoop();while(this.deps.timer.now()-this.startTime<this.maxTime&&this.scrollIteration<this.maxSwipes&&!this.reachedEnd&&!this.reverseSweepShouldStop()){let n=this.deps.timer.now(),s=this.createStep(),a=await this.dispatchStep(s);if(a.kind==="interrupted")break;if(a.kind==="failed")return a.result;await this.settleAndSearch();let c=this.lastObservation,l=this.host.computeHierarchyFingerprint(c.viewHierarchy),u=this.foundElement?!1:await this.recoverAndSearch(s,a.failedAndroidSwipe),d=this.foundElement?this.host.computeHierarchyFingerprint(this.lastObservation.viewHierarchy):await this.recheckStaleObservation(u);if(this.recordForwardMovement({observation:c,fingerprint:l},d,{recoveryAttempted:u,failedAndroidSwipe:a.failedAndroidSwipe,previousContent:s.previousContent}),this.foundElement)break;let p=this.reverseMode;await this.finishIteration({recoveryAttempted:u,currentFingerprint:d,failedAndroidSwipe:a.failedAndroidSwipe,chromeStartWarning:s.chromeStartWarning,previousContent:s.previousContent}),this.recordIterationTime(p,this.deps.timer.now()-n)}return this.finish()}async initialize(){if(o(this.request.signal),e.info(`[SwipeOn] Starting scroll-until-visible: direction=${this.request.options.direction}, lookFor=${JSON.stringify(this.request.options.lookFor)}`),this.observationFence=this.request.strategy?void 0:this.deps.captureDisplayFence?.(),this.lastObservation=await this.perf.track("initialObserve",async()=>M(await this.observe(),(n)=>this.observe({freshness:"fresh",timeoutMs:n}),this.deps.timer,this.request.signal)),o(this.request.signal),!this.lastObservation.viewHierarchy||!this.lastObservation.screenSize)throw Error("Failed to get initial observation for scrolling until visible.");if(this.containerElement=await this.perf.track("findContainer",async()=>this.host.findScrollableContainer(this.request.options,this.lastObservation,this.request.strategy?await this.host.screenBoundsContainer({observation:this.lastObservation,includeSystemInsets:this.request.options.includeSystemInsets}):void 0)),e.info(`[SwipeOn] Using container: bounds=${JSON.stringify(this.containerElement.bounds)}, scrollable=${this.containerElement.scrollable}`),this.lookForOptions=this.host.resolveLookForOptions(this.request.options,this.containerElement,this.lastObservation),this.maxTime=this.request.options.lookFor.maxTime??15000,this.maxSwipes=this.request.options.lookFor.maxSwipes??Number.POSITIVE_INFINITY,this.startTime=this.deps.timer.now(),this.foundElement=null,this.scrollIteration=0,this.lastFingerprint=this.host.computeHierarchyFingerprint(this.lastObservation.viewHierarchy),this.moves.reset(this.lastFingerprint),this.unchangedScrollCount=0,this.maxUnchangedScrolls=this.request.options.lookFor.maxUnchangedSwipes??2,!Number.isInteger(this.maxUnchangedScrolls)||this.maxUnchangedScrolls<1)throw new t("lookFor.maxUnchangedSwipes must be a positive integer");this.scopeDescription=Ue(this.request.options),this.target=this.request.options.lookFor.text?`text "${this.request.options.lookFor.text}"`:`element with id "${this.request.options.lookFor.elementId}"`,e.info(`[SwipeOn] Looking for ${this.target} with maxTime=${this.maxTime}ms`),this.accessibilityWarnings=new Set,this.isTalkBackEnabled=await this.perf.track("checkTalkBack",async()=>{if(o(this.request.signal),this.request.strategy||this.deps.device.platform!=="android")return!1;let n=await this.deps.accessibilityDetector.resolveTalkBackState(this.deps.device.deviceId,this.deps.adb,this.deps.featureFlags);if(n===null)this.accessibilityWarnings.add(Na);return n===!0})}recordForwardMovement(n,s,{recoveryAttempted:a,failedAndroidSwipe:c,previousContent:l}){let u=a?n.observation:this.lastObservation,d=a?n.fingerprint:s,p=u.freshness?.isFresh!==!1;if(!c&&d&&this.lastFingerprint&&d!==this.lastFingerprint&&!ye(l,u))this.moves.recordMove(p,!a);if(!a)this.moves.confirm(d,p)}async initialSearch(){if(this.foundElement=await this.perf.track("initialSearch",()=>this.host.findElementInHierarchy(this.request.options.lookFor,this.lastObservation.viewHierarchy,{container:this.request.options.container,containerElement:this.containerElement,layer:this.request.options.layer})),this.foundElement&&!this.host.isElementWithinContainer(this.foundElement,this.containerElement.bounds,this.lastObservation))e.info(`[SwipeOn] Found ${this.target} initially but it is outside container bounds (element center y=${Math.floor((this.foundElement.bounds.top+this.foundElement.bounds.bottom)/2)}, container=${JSON.stringify(this.containerElement.bounds)}), will scroll`),this.foundElement=null}async scrollWebElementIntoView(){let n=this.deps.webScrollIntoView;if(!n||!this.webScrollApplies())return;let s=await n.scroll(this.request.options.lookFor,this.lastObservation,this.request.signal);if(!s)return;if(s.backend==="xctest"){this.webScroll=s;return}await this.deps.timer.sleep(Dr),o(this.request.signal);let a=ee(this.deps.timer);if(a<=0)return;try{this.lastObservation=await this.observe({freshness:"fresh",timeoutMs:a})}catch(c){if(o(this.request.signal),c instanceof Error&&c.name==="AbortError")throw c;e.warn(`[SwipeOn] Read after the page scrolled failed: ${r(c)}`,c);return}if(o(this.request.signal),await this.initialSearch(),this.foundElement)this.webScroll=s;else this.lastFingerprint=this.host.computeHierarchyFingerprint(this.lastObservation.viewHierarchy),this.moves.rebase(this.lastFingerprint)}webScrollApplies(){let{container:n,layer:s,lookFor:a}=this.request.options;return!this.request.strategy&&this.deps.device.platform==="ios"&&n===void 0&&s===void 0&&!W(a)}webScrollFields(){if(!this.webScroll)return{};return this.webScroll.backend==="xctest"?{backend:"xctest",fallbackReason:this.webScroll.fallbackReason}:{backend:"sdk"}}async initialSuccess(){if(!this.foundElement)throw Error("Initial search did not find an element");if(e.info(`[SwipeOn] Element already visible at bounds=${JSON.stringify(this.foundElement.bounds)}, no scrolling needed`),this.isTalkBackEnabled&&this.request.options.focusTarget)o(this.request.signal),await this.host.setAccessibilityFocusOnElement(this.foundElement,this.perf);return this.perf.end(),o(this.request.signal),await this.deps.captureTerminalObservationScreenshot?.(this.lastObservation,this.perf),{success:!0,targetType:"element",element:this.foundElement,found:!0,...this.accessibilityWarnings.size?{warnings:[...this.accessibilityWarnings]}:{},scrollIterations:0,movedSwipes:0,elapsedMs:this.deps.timer.now()-this.startTime,...this.webScrollFields(),x1:0,y1:0,x2:0,y2:0,duration:0,observation:this.lastObservation}}initializeLoop(){this.searchDragState={},this.overlapRecoveryUsed=!1,this.reverseMode=!1,this.reverseDirection=AC(this.request.options.direction),this.reverseOptions={...this.lookForOptions,speed:"slow"},this.reverseSwipeBudget=Number.POSITIVE_INFINITY,this.reverseSwipes=0,this.reverseSweepMs=0,this.lastIterationMs=0,this.reverseStopReason=void 0}recordIterationTime(n,s){if(this.lastIterationMs=s,n)this.reverseSwipes++,this.reverseSweepMs+=s}reverseSweepShouldStop(){if(!this.reverseMode)return!1;if(this.reverseSwipes>=this.reverseSwipeBudget)return this.reverseStopReason="covered",!0;let n=this.reverseSwipes>0?this.reverseSweepMs/this.reverseSwipes:this.lastIterationMs;if(this.maxTime-(this.deps.timer.now()-this.startTime)<n)return this.reverseStopReason="time",!0;return!1}createStep(){o(this.request.signal),this.scrollIteration++,e.info(`[SwipeOn] Iteration ${this.scrollIteration}: elapsed=${this.deps.timer.now()-this.startTime}ms, reverseMode=${this.reverseMode}, unchangedScrollCount=${this.unchangedScrollCount}/${this.maxUnchangedScrolls}`);let n=this.host.resolveContainerSwipeCoordinates(this.request.options,this.lastObservation.viewHierarchy,this.containerElement,this.lastObservation);this.swipeWarning=n.warning??this.swipeWarning;let s=this.host.resolveReverseBounds(this.request.options,this.containerElement,this.lastObservation),a=oe(this.lastObservation,this.containerElement),c={container:this.containerElement,signature:be(this.lastObservation,this.containerElement)},l=this.reverseMode?this.host.computeHalfScreenReverseCoords(this.reverseDirection,s):this.deps.device.platform==="android"&&this.request.strategy?ne(n,s):n,u=this.reverseMode?this.reverseDirection:this.request.options.direction,d=this.deps.getDuration(this.reverseMode?this.reverseOptions:this.request.strategy&&this.deps.device.platform==="android"?{...this.lookForOptions,duration:void 0,speed:"slow"}:this.lookForOptions),{startX:p,startY:m,endX:h,endY:f}=l,S=CO({observation:this.lastObservation,platform:re(this.deps.device.platform,"swipeOn"),startX:Math.floor(p),startY:Math.floor(m)});return e.info(`[SwipeOn] Swipe: direction=${u}, coords=(${Math.floor(p)},${Math.floor(m)})\u2192(${Math.floor(h)},${Math.floor(f)}), duration=${d}ms`),{previousKeys:a,previousContent:c,chromeStartWarning:S,dispatch:{coordinates:l,direction:u,duration:d,options:this.request.options,containerElement:this.containerElement,observation:this.lastObservation,observationFence:this.observationFence,strategy:this.request.strategy,scrollIteration:this.scrollIteration,perf:this.perf,progress:this.request.progress,signal:this.request.signal,onSearchFallback:this.onSearchFallback,searchDragState:this.searchDragState,swipes:this.request.swipes}}}async dispatchStep(n){this.searchDragState.pagingStep=!1;let s=await this.host.dispatchSearchSwipe(n.dispatch);o(this.request.signal);for(let l of s.warnings??[])this.accessibilityWarnings.add(l);if(s.observation?.viewHierarchy)this.lastObservation=s.observation;if(s.staleDisplay&&!s.outcomeIndeterminate)return this.interruptedDisplay=s.staleDisplay,this.foundElement=await this.host.matchInterruptedDisplaySearch(this.request.options,this.lastObservation,this.containerElement,this.interruptedDisplay),{kind:"interrupted"};let a=await this.validateIosSwipe(s);if(a)return{kind:"failed",result:a};let c=this.validateAndroidSwipe(s);if(!s.observation?.viewHierarchy)throw Error("Lost observation after swipe during scroll until visible.");return{kind:"continue",failedAndroidSwipe:c}}async validateIosSwipe(n){if(!n.success&&n.outcomeIndeterminate&&this.deps.device.platform==="ios")throw this.perf.end(),new t(`${n.error??"iOS scroll swipe outcome is indeterminate."} The scroll may have happened. Observe before retrying.`);if(!n.success&&this.deps.device.platform==="ios")return this.perf.end(),o(this.request.signal),await this.deps.captureTerminalObservationScreenshot?.(this.lastObservation,this.perf),{...n,targetType:"screen",found:!1,scrollIterations:this.scrollIteration,elapsedMs:this.deps.timer.now()-this.startTime};return}validateAndroidSwipe(n){let s=this.deps.device.platform==="android"&&!n.success;if(s){let a=n.error??"Android scroll swipe failed";if(n.outcomeIndeterminate)throw this.perf.end(),new t(`${a} The scroll may have happened. Observe before retrying.`);if(this.lastAndroidSwipeError!==void 0||!n.observation?.viewHierarchy)throw this.perf.end(),new t(`Scroll swipe failed: ${a}`);this.lastAndroidSwipeError=a,e.warn(`[SwipeOn] Scroll swipe failed; tolerating one rejection: ${a}`)}else this.lastAndroidSwipeError=void 0;return s}async settleAndSearch(){if(this.host.computeHierarchyFingerprint(this.lastObservation.viewHierarchy)===this.lastFingerprint)e.warn(`[SwipeOn] iter=${this.scrollIteration} post-swipe fingerprint matches pre-swipe \u2014 `+"observation may be stale (cache hit) or swipe had no visible effect");let s=this.deps.timer.now()-this.startTime,a=Math.min(1500,Math.max(0,this.maxTime-s-300));if(a>100)this.lastObservation=await wC(this.lastObservation,{observe:this.observe,timer:this.deps.timer,maxWaitMs:a,pollIntervalMs:Er,logPrefix:"[SwipeOn]",signal:this.request.signal});this.foundElement=await this.host.findVisibleSearchTarget(this.request.options,this.lastObservation,this.containerElement)}async recoverAndSearch(n,s){let a=!1;if(this.host.shouldGuardSearchStep({failedAndroidSwipe:s,reverseMode:this.reverseMode,overlapRecoveryUsed:this.overlapRecoveryUsed,searchDragState:this.searchDragState})){let c=await this.host.recoverSearchObservation({previousKeys:n.previousKeys,observe:this.observe,deadline:this.startTime+this.maxTime,dispatch:{...n.dispatch,observation:this.lastObservation},onRecovery:()=>{a=!0,this.overlapRecoveryUsed=!0}});this.lastObservation=c.observation,this.interruptedDisplay=c.staleDisplay}if(a)this.foundElement=await this.host.findVisibleSearchTarget(this.request.options,this.lastObservation,this.containerElement);return a}async recheckStaleObservation(n){let s=this.host.computeHierarchyFingerprint(this.lastObservation.viewHierarchy);if(!n&&s===this.lastFingerprint&&this.lastObservation.freshness?.isFresh===!1)e.info(`[SwipeOn] Iteration ${this.scrollIteration}: stale unchanged observation; re-observing once before scroll-end decision`),this.lastObservation=await this.observe({freshness:"fresh",timeoutMs:ee(this.deps.timer)}),s=this.host.computeHierarchyFingerprint(this.lastObservation.viewHierarchy),this.foundElement=await this.host.findVisibleSearchTarget(this.request.options,this.lastObservation,this.containerElement);return s}async finishIteration({recoveryAttempted:n,currentFingerprint:s,failedAndroidSwipe:a,chromeStartWarning:c,previousContent:l}){let u=n||this.screenMoved(s,l);if(e.info(`[SwipeOn] Iteration ${this.scrollIteration}: hierarchy ${u?"changed":"UNCHANGED"} (fingerprint[0:40]="${s.slice(0,40)}")`),this.containerElement=await this.host.findScrollableContainer(this.request.options,this.lastObservation,this.containerElement),!u&&c)throw this.perf.end(),new t(`${c} Cannot determine end of container from this swipe. Retry without includeSystemInsets.`);if(!a&&!u&&this.lastObservation.freshness?.isFresh!==!1&&!!s&&!!this.lastFingerprint){if(this.unchangedScrollCount++,e.info(`[SwipeOn] Iteration ${this.scrollIteration}: unchanged count now ${this.unchangedScrollCount}/${this.maxUnchangedScrolls}`),this.unchangedScrollCount>=this.maxUnchangedScrolls)this.onDirectionExhausted()}else this.unchangedScrollCount=0;this.lastFingerprint=s,e.info(`[SwipeOn] Iteration ${this.scrollIteration}: ${this.target} not yet found`)}screenMoved(n,s){return n!==this.lastFingerprint&&!ye(s,this.lastObservation)}onDirectionExhausted(){if(this.reverseMode){this.reachedEnd=!0;return}if(this.reverseMode=!0,this.unchangedScrollCount=0,this.moves.count>0)this.reverseSwipeBudget=2*this.moves.count+this.maxUnchangedScrolls;e.info(`[SwipeOn] Reached end in forward direction without finding ${this.target}, switching to reverse half-screen recovery`)}missMessage(){let{direction:n}=this.request.options,s=this.reverseDirection;return`${this.reachedEnd?`Scroll reached end of container in both directions (${n} and ${s}; no change after ${this.maxUnchangedScrolls} consecutive swipes each way).`:this.reverseStopReason==="covered"?`Scroll reached end of container going ${n} (no change after ${this.maxUnchangedScrolls} consecutive swipes); the ${s} sweep then covered the searched range back past the start (${this.reverseSwipes} swipes).`:`Scroll reached end of container going ${n} (no change after ${this.maxUnchangedScrolls} consecutive swipes); the ${s} sweep stopped after ${this.reverseSwipes} swipes because the ${this.maxTime}ms search time budget could not cover another swipe.`} ${this.target} not found${this.scopeDescription}. ${this.moves.count} swipes moved the screen. The item may be absent from this container, or the swipe direction may be wrong.`}async notFound(){o(this.request.signal),this.perf.end();let n=this.deps.timer.now()-this.startTime;if(this.lastAndroidSwipeError!==void 0)throw new t(`Scroll swipe failed: ${this.lastAndroidSwipeError}`);if(this.reverseMode&&!this.reachedEnd&&n>=this.maxTime)this.reverseStopReason="time";if(!this.reachedEnd&&!this.reverseStopReason)throw new t(`${this.target} not found${this.scopeDescription} after scrolling for ${n}ms (${this.scrollIteration} iterations, timeout=${this.maxTime}ms).`);let s=this.missMessage();return e.info(`[SwipeOn] ${s}`),await this.deps.captureTerminalObservationScreenshot?.(this.lastObservation,this.perf),{success:!1,error:s,targetType:"screen",found:!1,reachedEnd:!0,movedSwipes:this.moves.count,scrollIterations:this.scrollIteration,elapsedMs:n,observation:this.lastObservation,x1:0,y1:0,x2:0,y2:0,duration:0,warning:this.swipeWarning,...this.accessibilityWarnings.size?{warnings:[...this.accessibilityWarnings]}:{}}}async finish(){if(!this.foundElement)return this.notFound();if(this.isTalkBackEnabled&&this.request.options.focusTarget)o(this.request.signal),await this.host.setAccessibilityFocusOnElement(this.foundElement,this.perf);return this.perf.end(),o(this.request.signal),await this.deps.captureTerminalObservationScreenshot?.(this.lastObservation,this.perf),{success:!0,targetType:"element",element:this.foundElement,found:!0,scrollIterations:this.scrollIteration,movedSwipes:this.moves.count,elapsedMs:this.deps.timer.now()-this.startTime,...this.webScrollFields(),observation:this.lastObservation,x1:0,y1:0,x2:0,y2:0,duration:0,warning:this.swipeWarning,...this.accessibilityWarnings.size?{warnings:[...this.accessibilityWarnings]}:{},...this.interruptedDisplay?{staleDisplay:this.interruptedDisplay}:{}}}}function mt(n,s){if(n===s)return[n];let a=Array.isArray(n.node)?n.node:n.node?[n.node]:[];for(let c of a){let l=mt(c,s);if(l)return[n,...l]}return}function ht({hierarchy:n,element:s,direction:a,parser:c,scrollsInDirection:l}){let u=rt(s);if(!u||l(s,a))return s;let d=[...c.extractRootNodes(n),...c.extractWindowRootNodes(n,"topmost-first")];for(let p of d){let m=mt(p,u);if(!m)continue;for(let h of m.slice(0,-1).reverse()){let f=c.parseNodeBounds(h);if(f&&l(f,a))return f}return s}return s}var Ir=48,wt=240,bt=120;function Ar({direction:n,bounds:s,screen:a}){let c=n==="up"||n==="down",l=c?s.bottom-s.top:s.right-s.left;if(l>=Ir)return;let u=Math.floor((s.left+s.right)/2),d=Math.floor((s.top+s.bottom)/2),p=n==="up"||n==="left"?-wt:wt,m=Ys(a),h=Math.floor(Math.max(m.left,Math.min(m.right,u+(c?0:p)))),f=Math.floor(Math.max(m.top,Math.min(m.bottom,d+(c?p:0)))),S=c?Math.abs(f-d):Math.abs(h-u),y=`Container is only ${l} pt along the swipe axis, so the swipe starts at its centre and travels ${S} pt in the swipe direction, like dragging a sheet grabber.`;return{startX:u,startY:d,endX:h,endY:f,warning:S<bt?`${y} Screen bounds leave less than ${bt} pt of travel; the drag may be too short.`:y}}function ue({geometry:n,overlayDetector:s,options:a,viewHierarchy:c,containerElement:l,observeResult:u,platform:d}){let p={observation:u,platform:d,includeSystemInsets:a.includeSystemInsets},m=fE({...p,bounds:l.bounds}),h=(w)=>{let v=CO({...p,...w});return v?{...w,warning:[w.warning,v].filter(Boolean).join(" ")}:w};if((d??zr(u.viewHierarchy)?.platform)==="ios"){let w=Ar({direction:a.direction,bounds:m,screen:ju(p)??u.screenSize});if(w)return h(w)}let f=n.getSwipeWithinBounds(a.direction,m),S=s.collectOverlayCandidates(c,l);if(S.length===0)return h(f);let y=S.map((w)=>w.overlapBounds),b=s.computeSafeSwipeCoordinates(a.direction,m,y);if(!b)return h({...f,warning:"No unobstructed swipe area found; using container bounds."});return h(b)}var Cr=150,Tr=10,kr=1000;function Pr(n,s){return s?n.filter((a)=>!Bd(a.properties["visible-to-user"])):void 0}class de{deps;static MAX_ATTEMPTS=5;searchable=new fe;parser=new K;autoTarget=new q;resolver;constructor(n){this.deps=n;this.resolver=n.resolver??new ur}swipePlatform(){return re(this.deps.device.platform,"swipeOn")}resolveSwipeTarget(n,s,a){return ht({hierarchy:n,element:s,direction:a,parser:this.parser,scrollsInDirection:(c,l)=>this.autoTarget.scrollsInDirection(c,l)})}resolveNamedSwipeContainer(n,s){let a=this.resolveElement(n,s.container);return a&&this.resolveSwipeTarget(n,a,s.direction)}resolveElement(n,s,a="inspect",c=!1){let l=this.resolver.resolve({id:String(n.updatedAt??"swipe"),nodes:this.searchable.project(n)},s,{action:a});if(Ed(l.error))return null;if(l.error)throw new t(l.error,{containerFailure:l.containerFailure});return c?Aa(l,s)?.element??null:l.chosen?.element??null}resolveSwipeContainer(n,s){let a=this.resolver.resolve({id:String(n.updatedAt??"swipe"),nodes:this.searchable.project(n)},{container:s},{action:"inspect"});if(a.error)throw new t(a.error,{containerFailure:a.containerFailure});let c=a.scope?.element;if(!c)throw new t(`Container level 1 not found: ${s.elementId??s.text}`,{containerFailure:{level:1,reason:"not-found",selector:s}});return c}async execute(n,s,a,c){let{progress:l,perf:u=new U,signal:d}=kre(s,a,c);return this.executeWithStrategy({options:n,progress:l,perf:u,signal:d})}async executeWithStrategy(n){let s={dispatched:0},a;try{let c=await Z(()=>new ke({...n,swipes:s},this.deps,{findScrollableContainer:(...l)=>this.findScrollableContainer(...l),screenBoundsContainer:(...l)=>this.screenBoundsContainer(...l),resolveLookForOptions:(...l)=>this.resolveLookForOptions(...l),computeHierarchyFingerprint:(...l)=>this.computeHierarchyFingerprint(...l),findElementInHierarchy:(...l)=>this.findElementInHierarchy(...l),isElementWithinContainer:(...l)=>this.isElementWithinContainer(...l),setAccessibilityFocusOnElement:(...l)=>this.setAccessibilityFocusOnElement(...l),resolveContainerSwipeCoordinates:(...l)=>this.resolveContainerSwipeCoordinates(...l),resolveReverseBounds:(...l)=>this.resolveReverseBounds(...l),computeHalfScreenReverseCoords:V5,dispatchSearchSwipe:(l)=>this.dispatchSearchSwipe(l,(u)=>{a=u}),matchInterruptedDisplaySearch:(...l)=>this.matchInterruptedDisplaySearch(...l),findVisibleSearchTarget:(...l)=>this.findVisibleSearchTarget(...l),shouldGuardSearchStep:(...l)=>this.shouldGuardSearchStep(...l),recoverSearchObservation:(...l)=>this.recoverSearchObservation(...l)},n.perf??new U).execute());return a?{...c,warning:IL(c.warning,a)}:c}catch(c){throw ze(c,n.signal,s)}}resolveLookForOptions(n,s,a){let c=s.bounds.bottom-s.bounds.top,l=a.screenSize.height,u=c/l*100,d=n.speed;if(u>=80){if(!d||d==="fast")d="normal",e.info(`[SwipeOn] Container is ${u.toFixed(1)}% of screen height, limiting lookFor speed to "normal"`)}else if(!d||d==="normal"||d==="fast")d="slow",e.info(`[SwipeOn] Container is ${u.toFixed(1)}% of screen height, limiting lookFor speed to "slow"`);return{...n,speed:d}}shouldGuardSearchStep(n){return this.deps.device.platform==="android"&&!n.failedAndroidSwipe&&!n.reverseMode&&!n.overlapRecoveryUsed&&!n.searchDragState.pagingStep}async findVisibleSearchTarget(n,s,a){let c=await this.findScrollableContainer(n,s,a),l=await this.findElementInHierarchy(n.lookFor,s.viewHierarchy,{container:n.container,containerElement:c,layer:n.layer});return l&&this.isElementWithinContainer(l,c.bounds,s)?l:null}async recoverSearchObservation({previousKeys:n,dispatch:s,observe:a,deadline:c,onRecovery:l}){let{options:u,containerElement:d}=s,p;return{observation:await Xe({previousKeys:n,observation:s.observation,timer:this.deps.timer,deadline:c,signal:s.signal,hasTarget:async(h)=>Boolean(await this.findVisibleSearchTarget(u,h,d)),keys:async(h)=>oe(h,await this.findScrollableContainer(u,h,d)),backScroll:async(h)=>{l();let f=await this.performOverlapBackScroll({...s,observation:h},a,c);return p=f.staleDisplay,f.observation}}),staleDisplay:p}}async performOverlapBackScroll(n,s,a){let{options:c,observation:l,signal:u}=n,d=await this.findScrollableContainer(c,l,n.containerElement),p=AC(n.direction),m=await this.dispatchSearchSwipe({...n,coordinates:V5(p,this.resolveReverseBounds(c,d,l)),direction:p,duration:this.deps.getDuration({...c,speed:"slow"}),containerElement:d});if(o(u),m.outcomeIndeterminate)throw new t(m.error??"Recovery scroll outcome is indeterminate");if(m.staleDisplay)return await this.matchInterruptedDisplaySearch(c,m.observation,d,m.staleDisplay),{observation:m.observation,staleDisplay:m.staleDisplay};if(!m.success||!m.observation?.viewHierarchy)return e.debug("[SwipeOn] Overlap recovery unavailable; continuing forward",m.error),{observation:l};if(await this.findVisibleSearchTarget(c,m.observation,d))return{observation:m.observation};return{observation:await wC(m.observation,{observe:s,timer:this.deps.timer,maxWaitMs:Math.min(1500,Math.max(0,a-this.deps.timer.now())),pollIntervalMs:Cr,logPrefix:"[SwipeOn] overshoot",signal:u})}}async dispatchSearchSwipe(n,s=()=>{}){if(this.swipePlatform()==="android"){let a=await S3(n.observation,this.deps.androidXr);a&&s(a)}return this.dispatchPoseCheckedSearchSwipe(n)}async dispatchPoseCheckedSearchSwipe({coordinates:n,direction:s,duration:a,options:c,containerElement:l,observation:u,observationFence:d,strategy:p,scrollIteration:m,perf:h,progress:f,signal:S,onSearchFallback:y,searchDragState:b,swipes:w}){let{startX:v,startY:O,endX:g,endY:D}=n;VR(u.viewHierarchy,c.layer,[{x:Math.floor(v),y:Math.floor(O)}],"swipe");let I=a,A=s,R=u,pe=this.deps.resolveBoomerangConfig(c),H={duration:I,scrollMode:c.scrollMode,searchScroll:this.deps.device.platform==="android",searchScrollBounds:this.resolveReverseBounds(c,l,u),onSearchFallback:y,searchDragState:b},_;if(p)o(S);let B=!1,z=()=>{if(!B)B=!0,w.dispatched++};return p?await p.swipe({x1:Math.floor(v),y1:Math.floor(O),x2:Math.floor(g),y2:Math.floor(D),duration:I,holdDurationMs:this.deps.device.platform==="android"?ie:void 0,onSearchFallback:y,searchDragState:b,previousObservation:R,onDispatched:z}):await this.deps.observedInteraction(async(Vr,Dt)=>{H.displayFence={assertCurrent:()=>{d?.assertCurrent(),Dt?.assertCurrent()}},o(S),w.dispatched++;let Me=this.deps.device.platform==="ios"?this.deps.voiceOverExecutor:this.deps.talkBackExecutor;if(!Me)throw Error("VoiceOver swipe runner is not configured for iOS scroll-until-visible");let he=await Me.executeSwipeGesture({observation:R,x1:Math.floor(v),y1:Math.floor(O),x2:Math.floor(g),y2:Math.floor(D),direction:A,containerElement:l,gestureOptions:H,perf:h,boomerang:pe,signal:S});if(this.deps.device.platform==="ios"&&(he.success||he.outcomeIndeterminate))_=this.deps.timer.now(),x.getExistingInstance(this.deps.device.deviceId)?.invalidateCache();return he},{...jt.selectorResolvedGesture,timeoutMs:Tt.brief,progress:f,perf:h,signal:S,previousObservation:R,deferPostActionScreenshot:!0,observationTimestampProvider:()=>_,predictionContext:{toolName:"swipeOn",toolArgs:this.deps.buildPredictionArgs(c)}})}async matchInterruptedDisplaySearch(n,s,a,c){let l=await this.findElementInHierarchy(n.lookFor,s.viewHierarchy,{container:n.container,containerElement:a,layer:n.layer});if(l&&this.isElementWithinContainer(l,a.bounds,s))return l;throw new hr(new Ee(c))}async findTargetElement(n,s,a=0,c){o(c);let l=null;if(!n.container)throw new t("Container must be specified for element swipe");if(s=Ti(s,n.layer),!n.container.text&&!n.container.elementId)throw new t("Container must specify either text or elementId");if(C(n.container))return this.resolveSwipeContainer(s,n.container);if(l=this.resolveElement(s,n.container,"inspect",n.container.text!==void 0),!l&&a<de.MAX_ATTEMPTS){let u=Q({initialDelayMs:Tr,maxDelayMs:kr}).delayForAttempt(a+1);await this.deps.timer.sleep(u),o(c);let d=await this.refreshContainerHierarchy(n.container,c);if(d)return e.info(`Retrying to find element after ${u}ms delay`),await this.findTargetElement(n,d,a+1,c)}if(!l)if(n.container.text)throw new t(`Element not found with provided text '${n.container.text}'`);else throw new t(`Element not found with provided elementId '${n.container.elementId}'`);return this.resolveSwipeTarget(s,l,n.direction)}async refreshContainerHierarchy(n,s){switch(this.deps.device.platform){case"android":let a={query:n.text||n.elementId||"",containerElementId:void 0};return await this.deps.accessibilityService.getAccessibilityHierarchy(a,{disableAllFiltering:N.isRawElementSearchEnabled()});case"ios":return(await this.deps.observeScreen.execute({freshness:"cached-ok",skipScreenshot:!0,skipAccessibilityAudit:!0,signal:s})).viewHierarchy;default:throw Rt(this.deps.device.platform,"scroll until visible")}}async findScrollableContainer(n,s,a){let c=await this.deps.androidXr(s),l=null,u=Ti(s.viewHierarchy,n.layer);if(n.container){if(C(n.container))return this.resolveSwipeContainer(u,n.container);if(n.container.elementId||n.container.text)l=this.resolveNamedSwipeContainer(u,n)}if(!l){let d=this.searchable.project(u);if(l=[...this.resolver.resolve({id:String(u.updatedAt??"swipe"),nodes:d,searchedNodes:Pr(d,c)},{},{action:"scroll"}).candidates].sort((h,f)=>Number(h.rootGroup!==0)-Number(f.rootGroup!==0)).find((h)=>h.element)?.element??null,l)e.info("[SwipeOn] Found scrollable container automatically")}if(!l)e.info("[SwipeOn] No scrollable container found, using fallback bounds"),l=T(a,c)?a:await this.screenBoundsContainer({observation:s});return l}async screenBoundsContainer({observation:n,includeSystemInsets:s}){let a={observation:n,platform:this.swipePlatform(),includeSystemInsets:s},c=ju(a)||{width:1080,height:1920},l=Ys(c,mE(a));return{bounds:await yW(n,this.deps.androidXr,l),scrollable:!0}}async findElementInHierarchy(n,s,{container:a,containerElement:c,layer:l}={}){if(!n.text&&!n.elementId)return null;if(s=Ti(s,l),!C(a)&&!W(n))return this.resolveElement(s,{...n,container:a},"inspect",!0);let u=C(a)?c:a?this.resolveElement(s,a):void 0;return qe({lookFor:n,container:C(a)||u?a:void 0,containerElement:u??void 0,resolver:this.resolver,nodes:this.searchable.project(s),id:String(s.updatedAt??"swipe")})}computeHierarchyFingerprint(n){return j(n)}async setAccessibilityFocusOnElement(n,s){try{await s.track("setAccessibilityFocus",async()=>{let a=n["resource-id"];if(!a){e.warn("[SwipeOn] Cannot set accessibility focus: element has no resource-id");return}await this.deps.accessibilityService.requestAction("focus",a,5000,{perf:s}),e.info(`[SwipeOn] Set accessibility focus on element: ${a}`)})}catch(a){e.warn(`[SwipeOn] Failed to set accessibility focus: ${a}`)}}isElementWithinContainer(n,s,a){let c=(n.bounds.top+n.bounds.bottom)/2,l=(n.bounds.left+n.bounds.right)/2,u=c>=s.top&&c<=s.bottom&&l>=s.left&&l<=s.right;return this.deps.device.platform==="ios"?this.isIosElementWithinContainer(n,s,a,u):u}isIosElementWithinContainer(n,s,a,c){let l=a.viewHierarchy,u=ju({observation:a,platform:"ios"});if(!l||!u)return c;let d=new Sd().collect(l,"ios"),p=d&&OO(d,n),m=F9(l,{observationScreenSize:a.screenSize});if(!p&&!Object.values(m).some((R)=>R>0))return c;let h=Ys(u,a.systemInsets??l.systemInsets),f={left:Math.max(s.left,h.left),top:Math.max(s.top,h.top),right:Math.min(s.right,h.right),bottom:Math.min(s.bottom,h.bottom)},S=xO({bounds:n.bounds,hierarchy:l,screen:u,elements:[n],forTapTarget:!0}).bounds;if(!S)return!1;let y=xO({bounds:f,hierarchy:l,screen:u,elements:[n]}).bounds;if(!y)return!1;let b={left:Math.max(S.left,y.left),top:Math.max(S.top,y.top),right:Math.min(S.right,y.right),bottom:Math.min(S.bottom,y.bottom)},{left:w,top:v,right:O,bottom:g}=b,D=p&&hE(p,u).bounds,I=this.deps.geometry.getElementCenter({bounds:b});return(D?[bP([w,v,O,g],D),I]:[I]).some((R)=>R!==null&&Number.isInteger(R.x)&&Number.isInteger(R.y)&&this.deps.geometry.isPointInElement({bounds:b},R.x,R.y)&&R.x<O&&R.y<g&&!(D&&R.x>=D[0]&&R.x<D[2]&&R.y>=D[1]&&R.y<D[3]))}resolveReverseBounds(n,s,a){return fE({observation:a,platform:this.swipePlatform(),includeSystemInsets:n.includeSystemInsets,bounds:s.bounds})}resolveContainerSwipeCoordinates(n,s,a,c){return ue({geometry:this.deps.geometry,overlayDetector:this.deps.overlayDetector,options:n,viewHierarchy:s,containerElement:a,observeResult:c,platform:this.swipePlatform()})}}function Pe(n,s){if(!n)return;let{bundleId:a,navigationRoute:c,navigationTitle:l,presentation:u,modalClass:d}=n.components;if(!c&&!l&&!u&&!d)return;return{kind:`${s}:${n.platform}:${n.source}`,key:JSON.stringify([a,c,l,u,d]),name:l??c??d??u??"",title:l}}function yt(n){let s=n.activeWindow;if(!s?.appId||!s.activityName)return;return{kind:"window",key:JSON.stringify([s.appId,s.activityName]),name:s.activityName}}function Mr(n){return Pe(qR(n.viewHierarchy,n.screenSize),"hierarchy")}function Fr(n){return Pe(tz(n.viewHierarchy),"hierarchy")}function vt(n){return Pe(n.screenIdentity,"reported")}function Nr(n,s,a){let c=a==="ios"?[Mr,vt,yt]:[vt,Fr,yt];for(let l of c){let u=l(n),d=l(s);if(u&&d&&u.kind===d.kind)return[u,d]}return}function gt(n){return n.trim().replace(/\s+/g," ").toLowerCase()}function _r(n,s){let a=gt(n),c=gt(s);if(!c)return!1;return a===c||a.startsWith(c)&&!/[\p{L}\p{N}]/u.test(a.charAt(c.length))}function Br(n,s,a){if(!n.viewHierarchy)return;let c=Td(new fe().project(n.viewHierarchy));for(let l of EO(c,s)){let u=[l.displayedLabel,l.label,...l.textFields].find((d)=>typeof d==="string"&&_r(d,a));if(u)return u}return}function Ot(n,s,a,c){if(!n||!s)return;let l=Nr(n,s,c);if(!l)return;let[u,d]=l;if(u.key===d.key)return u.kind==="window"?void 0:{navigated:!1};let p=`"${u.name}" to "${d.name}"`,m=d.title?Br(n,a,d.title):void 0;return{navigated:!0,warning:m?`Swipe navigated from ${p} instead of scrolling; the new screen is titled like the element under the start point ("${m}"), so the gesture likely registered as a tap. Observe and go back before retrying.`:`Swipe navigated from ${p} instead of scrolling. If you expected a scroll, observe before retrying.`}}function xt(n){let s=n?.screenIdentity;return s?.platform==="android"&&s.source==="sdk"?s.components.bundleId:void 0}async function Et(n,s,a,c){let{swipeEndedAtMs:l,source:u,reassess:d}=c,p=xt(a);if(n?.navigated!==!1||!u||!p||!s||xt(s)!==p||l===void 0)return n;let m=u.receivedAtMs(p);if(m!==void 0&&m>l)return n;let h=await u.awaitRouteAfter(p,l,300);if(!h)return;if(a)a.screenIdentity=h;return d()}class yu extends Oe{skipCallerDisplayFence;stopAfterIosGestureFailure;iosLockScreenSwipe;iosGestureTimeoutMs;lastRenderedObservation;executeGesture;scrollables;geometry;accessibilityService;accessibilityDetector;featureFlags;overlayDetector;autoTargetSelector;autoTargeting;androidDisplay;talkBackExecutor;voiceOverExecutor;scrollUntilVisible;visionConfig;screenshotCapturer;visionAnalyzer;sdkRouteSourceOverride;androidXr;constructor(n,s=null,a={}){super(n,{adb:s,timer:a.timer,displayFence:a});us(n.platform,"swipeOn"),this.skipCallerDisplayFence=a.skipCallerDisplayFence??!1,this.stopAfterIosGestureFailure=a.stopAfterIosGestureFailure??!1,this.iosLockScreenSwipe=a.iosLockScreenSwipe,this.iosGestureTimeoutMs=a.iosGestureTimeoutMs,this.lastRenderedObservation=a.lastRenderedObservation;let c=this.initializeGestureDependencies(n,s,a),l=a.featureFlags??ar.getInstance();if(this.featureFlags=l,this.visionConfig=a.visionConfig??Lm,this.screenshotCapturer=a.screenshotCapturer??new gp(n,this.adbFactory),this.visionAnalyzer=a.visionAnalyzer,this.sdkRouteSourceOverride=a.sdkRouteSource,this.androidXr=Ete(()=>this,a.xrDetector),a.observeScreen)this.observeScreen=a.observeScreen;this.overlayDetector=new G(this.geometry,c),this.autoTargetSelector=a.autoTargetSelector??new q,this.autoTargeting=new we(n,()=>this.autoTargetSelector),this.androidDisplay=new De(()=>({device:this.device,adb:this.adb,androidXr:this.androidXr,timer:this.timer,observeScreen:this.observeScreen,displayTransitionReader:this.displayTransitionReader,accessibilityService:this.accessibilityService,accessibilityDetector:this.accessibilityDetector,featureFlags:this.featureFlags,talkBackExecutor:this.talkBackExecutor,scrollUntilVisible:this.scrollUntilVisible,scrollables:this.scrollables,geometry:this.geometry,lastRenderedObservation:this.lastRenderedObservation,autoTargeting:this.autoTargeting,visual:this,getDuration:(u)=>this.getDuration(u),createErrorResult:(u)=>this.createErrorResult(u),observedSwipeInteraction:(u,d,p)=>this.observedSwipeInteraction(u,d,p),checkPostActionDisplay:(u,d,p)=>this.checkPostActionDisplay(u,d,p),rethrowObservationAbort:(u,d,p)=>this.rethrowObservationAbort(u,d,p),resolveContainerSwipeCoordinates:(u,d,p,m)=>this.resolveContainerSwipeCoordinates(u,d,p,m)})),this.talkBackExecutor=new Ae({androidXr:this.androidXr,device:n,executeGesture:this.executeGesture,accessibilityService:this.accessibilityService,accessibilityDetector:this.accessibilityDetector,adb:this.adb,timer:this.timer,featureFlags:l}),this.voiceOverExecutor=a.voiceOverExecutor??ct({device:n,executeGesture:this.executeGesture,iosVoiceOverDetector:a.iosVoiceOverDetector??ko,timer:this.timer,featureFlags:l}),this.scrollUntilVisible=new de({device:n,resolver:a.resolver,geometry:this.geometry,observeScreen:this.observeScreen,accessibilityService:this.accessibilityService,accessibilityDetector:this.accessibilityDetector,adb:this.adb,androidXr:this.androidXr,featureFlags:l,overlayDetector:this.overlayDetector,talkBackExecutor:this.talkBackExecutor,voiceOverExecutor:this.voiceOverExecutor,webScrollIntoView:_e(n,a.webScrollIntoView),timer:this.timer,getDuration:this.getDuration.bind(this),resolveBoomerangConfig:this.resolveBoomerangConfig.bind(this),buildPredictionArgs:this.buildPredictionArgs.bind(this),observedInteraction:this.observedInteraction.bind(this),captureDisplayFence:()=>this.captureDisplayFence(),captureTerminalObservationScreenshot:this.captureTerminalObservationScreenshot.bind(this)})}initializeGestureDependencies(n,s,a){this.executeGesture=a.executeGesture??new AT(n,s);let c=a.parser??new K;return this.scrollables=a.scrollables??new bC,this.geometry=a.geometry??new or,this.accessibilityService=a.accessibilityService??Xs(n,this.adbFactory),this.accessibilityDetector=a.accessibilityDetector||li,c}createErrorResult(n,s={}){return{success:!1,error:n,warning:s.warning,scrollableCandidates:s.scrollableCandidates,targetType:"screen",x1:0,y1:0,x2:0,y2:0,duration:0}}async getScrollableContext(n,s){o(n);let a=await this.observeScreen.getMostRecentCachedObserveResult(),c=sU(this.device.deviceId),l=c!==void 0||Oe.shouldRefetchCachedObservation(a);if(l||!a.viewHierarchy||a.viewHierarchy.hierarchy?.error)o(n),a=await this.observeScreen.execute({...wc,freshness:l?"fresh":"cached-ok",timeoutMs:ji,skipStaleWindowRecovery:!0,signal:n});if(a=await M(a,(m)=>this.observeScreen.execute({...wc,freshness:"fresh",timeoutMs:m,skipStaleWindowRecovery:!0,signal:n}),this.timer,n),!a.viewHierarchy||a.viewHierarchy.hierarchy?.error)return{scrollables:[],candidates:[],observeResult:a};if(Kg(a))return{scrollables:[],candidates:[],observeResult:a};if(c!==void 0)aU(this.device.deviceId,c);let u=await this.androidXr(a,n),d=this.scrollables.findScrollableElements(Ti(a.viewHierarchy,s)).filter((m)=>T(m,u)),p=this.autoTargeting.buildScrollableCandidates(d);return{scrollables:d,candidates:p,observeResult:a}}async execute(n,s,a){let{progress:c,signal:l}=jo(s,a);if(us(this.device.platform,"swipeOn"),this.device.platform==="watchos")return rte(this.device.deviceId,n,l);let u=await Z(()=>this.executeWithReadScope(n,c,l));return et(u,n)}executeExplicitDisplay(n,s={}){return this.androidDisplay.executeExplicitDisplay(n,s)}async executeWithReadScope(n,s,a){o(a);let c=await this.executeExplicitDisplay(n,{progress:s,signal:a});if(c)return c;return this.executeLegacy(n,s,a)}async executeAutoTargetSwipe({options:n,progress:s,perf:a,signal:c}){let l=await this.getScrollableContext(c,n.layer),u=this.autoTargeting.resolveAutoTargetDecision({...l,direction:n.direction,includeSystemInsets:n.includeSystemInsets}),d=u.element&&l.observeResult?await this.executeElementSwipe(n,{progress:s,perf:a,signal:c,selected:{element:u.element,observation:l.observeResult}}):u.container?await this.executeElementSwipe({...n,container:u.container},{progress:s,perf:a,signal:c,selected:l.observeResult?{observation:l.observeResult}:void 0}):await this.executeScreenSwipe(n,s,a,{signal:c,within:u.scrollFrame});return this.autoTargeting.withAutoTargetDecision({result:d,decision:u})}async executeLegacy(n,s,a){let c=J();c.serial("swipeOn");let l=this.validateOptions(n);if(l)return c.end(),this.createErrorResult(l);let u=td(n);if(u.error)return c.end(),this.createErrorResult(u.error);let d={...n,direction:u.direction};e.info(`[SwipeOn] execute: direction=${d.direction}, lookFor=${JSON.stringify(d.lookFor)}, container=${JSON.stringify(d.container)}, speed=${d.speed}, autoTarget=${d.autoTarget}`);try{return await yu.dispatchLegacySwipe(this,d,s,{perf:c,signal:a})}catch(p){if(c.end(),p instanceof V)throw p;if(wW(a,p),e.warn(`Swipe failed: ${r(p)}`,p),p instanceof Ee||p instanceof hr)return Qt(this.createErrorResult(p.message),p);let m=d.lookFor||d.container?await sL(this.device,yu.legacyDebugSearchCriteria(d)):void 0;o(a);let f=`Failed to perform swipeOn: ${r(p)}`,S=yu.legacyVisionSearchCriteria(this,d);if(S){o(a);let y=await this.observeScreen.getMostRecentCachedObserveResult(),b={visionConfig:this.visionConfig,visionAnalyzer:this.visionAnalyzer};f=await Bm(this.screenshotCapturer,y?.viewHierarchy??null,S,{...b,baseError:f})}return yu.legacyFailureResult({action:this,normalizedOptions:d,perf:c,errorMsg:f,debugContext:m,cause:p})}}static legacyDebugSearchCriteria(n){return{text:n.lookFor?.text,resourceId:n.lookFor?.elementId||n.container?.elementId,container:n.container}}static legacyVisionSearchCriteria(n,s){if(n.visionConfig.enabled&&(s.lookFor||s.container)){let a=null;if(s.lookFor)a={text:s.lookFor.text,resourceId:s.lookFor.elementId,description:"Target element to scroll to"};else if(s.container)a={text:s.container.text,resourceId:s.container.elementId,description:"Container element for swiping"};return a}return null}static legacyFailureResult({action:n,normalizedOptions:s,perf:a,errorMsg:c,debugContext:l,cause:u}){let d=n.device.platform==="ios"?a.getTimings():null;return{success:!1,error:c,...u instanceof Y?{outcomeIndeterminate:!0}:{},...xe(u),...d?{timing:d}:{},targetType:s.container?"element":"screen",x1:0,y1:0,x2:0,y2:0,duration:0,...l?{debug:{elementSearch:l}}:{}}}static dispatchLegacySwipe(n,s,a,{perf:c,signal:l}){if(s.lookFor)return e.info("[SwipeOn] Mode: scroll-until-visible"),n.scrollUntilVisible.execute(s,{progress:a,perf:c,signal:l});else if(!s.container){if(s.autoTarget===!1)return e.info("[SwipeOn] Mode: screen swipe (autoTarget disabled)"),n.executeScreenSwipe(s,a,c,{signal:l});return n.executeAutoTargetSwipe({options:s,progress:a,perf:c,signal:l})}else return e.info(`[SwipeOn] Mode: element swipe (explicit container=${JSON.stringify(s.container)})`),n.executeElementSwipe(s,{progress:a,perf:c,signal:l})}validateOptions(n){if(n.container){let s=[n.container.elementId,n.container.text].filter(Boolean).length;if(s===0)return"container must specify exactly one of elementId or text";if(s>1)return"container must specify exactly one of elementId or text"}if(n.lookFor){if([n.lookFor.elementId,n.lookFor.text].filter(Boolean).length!==1)return"lookFor must specify exactly one of elementId or text"}return Xh(n,this.getDuration(n))??ae(n)}buildPredictionArgs(n){return{includeSystemInsets:n.includeSystemInsets,container:n.container,autoTarget:n.autoTarget,direction:n.direction,lookFor:n.lookFor,speed:n.speed,boomerang:n.boomerang,apexPause:n.apexPause,returnSpeed:n.returnSpeed,platform:this.device.platform}}async observedSwipeInteraction(n,s,a){let c=null,l,u=this.sdkRouteSource(),d=await this.observedInteraction(async(p,m)=>{c=p;let h=await Tte(this.androidXr,n,p,m);return l=u?this.timer.now():void 0,h},{...s,observePartialApplication:!0});if(await this.annotateSwipeNavigation(d,c,l,u),this.device.platform!=="android")return d;if(d.effect=this.deriveInteractionEffect(c,d.observation),a.boomerang)return d;if(d.success&&d.effect?.screenChanged===!1&&d.effect.basis!=="insufficient observation data")d.warning=this.autoTargetSelector.mergeWarnings(d.warning,this.unchangedSwipeWarning(d,c));return d}sdkRouteSource(){if(this.device.platform!=="android")return;return this.sdkRouteSourceOverride??{receivedAtMs:(n)=>this.accessibilityService.getSdkScreenIdentityReceivedAtMs(n),awaitRouteAfter:(n,s,a)=>this.accessibilityService.awaitSdkScreenIdentityAfter(n,s,a)}}async annotateSwipeNavigation(n,s,a,c){if(!n.success)return;let l=()=>Ot(s,n.observation,{x:n.x1,y:n.y1},re(this.device.platform,"swipeOn")),u=await Et(l(),s,n.observation,{swipeEndedAtMs:a,source:c,reassess:l});if(!u)return;if(n.navigated=u.navigated,u.warning)e.warn(`[SwipeOn] ${u.warning}`),n.warning=this.autoTargetSelector.mergeWarnings(n.warning,u.warning)}unchangedSwipeWarning(n,s){let a=s?.viewHierarchy?this.scrollables.findScrollableElements(s.viewHierarchy):[],c=n.element&&dt(n.element.scrollable)?[n.element,...a]:a;if(c.some((l)=>this.geometry.isPointInElement(l,n.x1,n.y1)))return"Swipe did not change the screen; the start point was inside the scrollable, which may already be at the end of the scrollable content.";return c.length>0?"Swipe did not change the screen; the start point was outside every scrollable region, so the gesture geometry may have prevented scrolling.":"Swipe did not change the screen; no scrollable region was found in the hierarchy."}async executeScreenSwipe(n,s,a=new U,{signal:c,within:l}={}){e.info(`[SwipeOn] Starting screen swipe: direction=${n.direction}`);let u,d=this.resolveBoomerangConfig(n);return this.observedSwipeInteraction(async(p,m)=>{o(c);let h={observation:p,platform:re(this.device.platform,"swipeOn"),includeSystemInsets:n.includeSystemInsets,includeFloatingBars:!n.fromEdge},f=ju(h);if(!f)throw new t("Could not determine screen size");let S=await yW(p,this.androidXr,Ys(f,mE(h)),n.fromEdge),y=Aoe(S,l,n.fromEdge),{startX:b,startY:w,endX:v,endY:O}=n.fromEdge?Je(n,n.fromEdge,y):this.geometry.getSwipeWithinBounds(n.direction,y);q5(p.viewHierarchy,n.layer,b,w);let g=this.getDuration(n),D={displayFence:m,duration:g,scrollMode:n.scrollMode,durationExplicit:X(n),timeoutMs:this.iosGestureTimeoutMs?.(),lockScreen:this.iosLockScreenSwipe};if(D.timeoutMs!==void 0&&D.timeoutMs<=0)throw new t("iOS swipe budget exhausted before gesture dispatch");o(c);let I=await a.track("executeScreenSwipe",()=>this.device.platform==="ios"?this.voiceOverExecutor.executeSwipeGesture({x1:Math.floor(b),y1:Math.floor(w),x2:Math.floor(v),y2:Math.floor(O),direction:n.direction,containerElement:null,gestureOptions:D,perf:a,boomerang:d,signal:c,sdkObservation:n.fromEdge?void 0:p}):this.talkBackExecutor.executeSwipeGesture({observation:p,x1:Math.floor(b),y1:Math.floor(w),x2:Math.floor(v),y2:Math.floor(O),direction:n.direction,containerElement:null,gestureOptions:D,perf:a,boomerang:d,signal:c}));if(this.stopAfterIosGestureFailure&&this.device.platform==="ios"&&!I.success)throw pt(I);if(o(c),this.device.platform==="ios"&&Ce(I))u=this.timer.now(),x.getExistingInstance(this.device.deviceId)?.invalidateCache();return a.end(),{...I,targetType:"screen",warning:CO({...h,startX:Math.floor(b),startY:Math.floor(w)})}},{usesObservationForResolution:!1,changeExpected:!1,display:n.display,timeoutMs:Tt.brief,progress:s,perf:a,signal:c,skipCallerDisplayFence:this.skipCallerDisplayFence,observationTimestampProvider:()=>u,predictionContext:{toolName:"swipeOn",toolArgs:this.buildPredictionArgs(n)}},{boomerang:d})}async executeElementSwipe(n,{progress:s,perf:a=new U,signal:c,selected:l}={}){e.info(`[SwipeOn] Starting element swipe: direction=${n.direction}, container=${JSON.stringify(n.container)}`);let u,d=this.resolveBoomerangConfig(n);return this.observedSwipeInteraction(async(p,m)=>{o(c),p=await M(p,(I)=>this.observeScreen.execute({...wc,freshness:"fresh",timeoutMs:I,skipStaleWindowRecovery:!0,display:n.display,signal:c}),this.timer,c);let h=p.viewHierarchy;if(!h||h.hierarchy.error)throw new t("Unable to get view hierarchy, cannot swipe on element");let f=(l?.observation.viewHierarchy===h?l.element:void 0)??await a.track("findElement",()=>this.scrollUntilVisible.findTargetElement(n,h,0,c));o(c);let{startX:S,startY:y,endX:b,endY:w,warning:v}=this.resolveContainerSwipeCoordinates(n,h,f,p);q5(h,n.layer,S,y);let O=this.getDuration(n),g={displayFence:m,duration:O,scrollMode:n.scrollMode,durationExplicit:X(n)};o(c);let D=await a.track("executeElementSwipe",()=>this.device.platform==="ios"?this.voiceOverExecutor.executeSwipeGesture({x1:Math.floor(S),y1:Math.floor(y),x2:Math.floor(b),y2:Math.floor(w),direction:n.direction,containerElement:f??null,gestureOptions:g,perf:a,boomerang:d,signal:c,sdkObservation:p}):this.talkBackExecutor.executeSwipeGesture({observation:p,x1:Math.floor(S),y1:Math.floor(y),x2:Math.floor(b),y2:Math.floor(w),direction:n.direction,containerElement:f,gestureOptions:g,perf:a,boomerang:d,signal:c}));if(o(c),this.device.platform==="ios"&&Ce(D))u=this.timer.now(),x.getExistingInstance(this.device.deviceId)?.invalidateCache();return a.end(),{...D,targetType:"element",element:f,warning:v}},{previousObservation:l?.observation,resolvesTargetFromRead:!0,queryOptions:l||C(n.container)?void 0:{text:n.container?.text,elementId:n.container?.elementId,containerElementId:void 0},changeExpected:!1,display:n.display,timeoutMs:Tt.brief,progress:s,perf:a,signal:c,observationTimestampProvider:()=>u,predictionContext:{toolName:"swipeOn",toolArgs:this.buildPredictionArgs(n)}},{boomerang:d})}resolveContainerSwipeCoordinates(n,s,a,c){return ue({geometry:this.geometry,overlayDetector:this.overlayDetector,options:n,viewHierarchy:s,containerElement:a,observeResult:c,platform:re(this.device.platform,"swipeOn")})}getDuration(n){return L({...n,geometry:this.geometry})}resolveBoomerangConfig(n){return k(n)}}export{bC,L5,SC,Yee,Iv,Jee,Xee,Zee,Qee,RT,wC,RC,tL,PC,rL,Pw,PT,B5,AC,FV,TC,nL,iL,LV,BV,Aw,Tw,oL,Xh,$5,$V,U5,H5,UV,AT,yu};
|
|
3
|
+
|
|
4
|
+
//# debugId=DB1DEFC8009C19A264756E2164756E21
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{gn,eS,MK,nM,Nn,N8,F8}from"./chunk-aewdveet.js";import"./chunk-r0vp315h.js";import"./chunk-5wk1t46v.js";export{Nn as getMcpServerVersion,F8 as getSettledMcpServerVersion,MK as hasWorkingTreeHash,N8 as isMcpServerVersionSettled,nM as probeCheckoutMcpServerVersion,gn as releaseVersion,eS as withoutDirtyStamp};
|
|
3
|
+
|
|
4
|
+
//# debugId=E5BB1EEFE89A4F4664756E2164756E21
|