agent-device 0.21.5 → 0.21.6
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/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.5.apk → agent-device-android-ime-helper-0.21.6.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.6.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.5.manifest.json → agent-device-android-ime-helper-0.21.6.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.5.apk → agent-device-android-snapshot-helper-0.21.6.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.6.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.5.manifest.json → agent-device-android-snapshot-helper-0.21.6.manifest.json} +6 -6
- package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +8 -1
- package/dist/src/adapter.js +1 -1
- package/dist/src/adb-executor.js +2 -2
- package/dist/src/adb-transport.js +1 -0
- package/dist/src/agent-browser-tool.js +1 -1
- package/dist/src/android-adb.js +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/app-helpers.js +1 -1
- package/dist/src/app-lifecycle.js +3 -3
- package/dist/src/app-log-reconnect.js +1 -1
- package/dist/src/device-input-state.d.ts +3 -4
- package/dist/src/device-session.js +1 -1
- package/dist/src/file.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/run-script-http-child.d.ts +1 -1
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/limrun-runtime-dependencies.js +1 -1
- package/dist/src/logcat.js +1 -1
- package/dist/src/mechanics.js +16 -16
- package/dist/src/perf-runtime-plan.js +1 -1
- package/dist/src/platform-runtime-android-adb-host.js +1 -1
- package/dist/src/runner-cache-metadata.js +2 -2
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/semantic-index.js +1 -1
- package/dist/src/session2.js +5 -5
- package/dist/src/tree.js +1 -1
- package/dist/src/video.js +2 -2
- package/package.json +2 -2
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.5.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.5.apk.sha256 +0 -1
- package/dist/src/adb-host.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Br as e,Hr as t,Mr as n,Or as r,Ur as i,zr as a}from"./sdk-batch.js";import{n as o,t as s}from"./scroll-indicator.js";import{a as c,i as l,o as ee,r as u}from"./react-native-overlay.js";import{t as d}from"./rect-center.js";import{a as f,c as te,d as p,f as m,g as ne,h,i as g,l as re,m as _,n as v,o as y,p as b,r as x,s as S,t as C,u as ie}from"./tree.js";function ae(e,t){let n=g(t.sourceNodesByIndex.values());for(let r of e)oe(r,t.sourceNodesByIndex,n)&&b(t.replacements,r,{type:`Cell`})}function oe(e,t,r){return!(n(e.type??``)!==`other`||e.enabled===!1||!e.rect||!le(e.label)||!f(e,t,ce)||!se(e)||re(e.rect,r))}function se(e){return e.rect?e.rect.height>=44&&e.rect.height<=160&&e.rect.width>=120:!1}function ce(e){let t=n(e.type??``);return t===`scrollview`||t===`scrollarea`}function le(e){let t=e?.trim();return!(!t||/^(toolbar|window|application)$/i.test(t)||t.startsWith(`!,`)||/debugger|fast refresh/i.test(t))}function ue(e,t){let n=new Set;for(let r of e)de(t.replacements.get(r.index)??r)&&fe(r,t.sourceNodesByIndex,t,n);pe(e,t,n)}function de(e){let t=e.label?.trim();return!!(t&&o(t))}function fe(e,t,n,r){let i=!p(e.type)||n.isSuppressed(e),a=s(e.label?.trim()??``,e.value),o=a?y(e,t,{includeSelf:!0}):void 0;i&&n.suppressNode(e,o?[o]:[]),o&&a&&j(n,o,e,a)&&r.add(o.index)}function pe(e,t,n){let r=new Map;for(let i of e){let e=r.get(i.parentIndex??-1),a=e?.clip,o=t.replacements.get(i.index)??i,s=k(o.rect,a),c=me(o,a,s),l=w(e,c,o);T(t,i,o,a,s,c,l),r.set(i.index,E(i,o,a,s,l,n))}}function me(e,t,n){return!!(t&&a(e.rect)&&!a(n))}function w(e,t,n){return!!(e?.projectedOut||t&&O(n))}function T(e,t,n,r,i,a,o){o||a?e.suppressNode(t,[]):r&&i&&!A(n.rect,i)&&b(e.replacements,t,{rect:i})}function E(e,t,n,r,i,a){return{projectedOut:i,...D(e,t,n,r,a)?{clip:r}:n?{clip:n}:{}}}function D(e,t,n,r,i){return!!(a(r)&&(i.has(e.index)||n!==void 0&&p(t.type)))}function O(e){return e.type?.trim().toLowerCase()===`cell`||p(e.type)}function k(e,t){if(!e||!t)return e;let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return{x:n,y:r,width:Math.max(0,i-n),height:Math.max(0,a-r)}}function A(e,t){return!!(e&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height)}function j(e,t,n,r){let i=N((e.replacements.get(t.index)??t).rect,n.rect);return ne(e.replacements,t,e=>({rect:i??e.rect,hiddenContentAbove:M(e.hiddenContentAbove,r.above),hiddenContentBelow:M(e.hiddenContentBelow,r.below)})),!!i}function M(e,t){return e===!0||t?!0:void 0}function N(e,t){if(!(!e||!t)&&!(t.height<=0||t.height>=e.height)&&!(t.y<e.y||t.y>e.y+e.height))return{...e,y:t.y,height:Math.min(t.height,e.y+e.height-t.y)}}function P(e,t){for(let r=0;r<e.length;r+=1){let i=e[r],a=i?.label?.trim();i&&a&&n(i.type??``)===`other`&&t(i,a,r)}}function F(e,t){P(e,(n,r,i)=>{if(!c(r)||!n.rect)return;let a=x(e,i,e=>!!e.rect&&ee(e.label?.trim()??``));if(!a?.rect)return;let o=L(n.rect,a.rect);if(!o)return;let s=I(e,i,o);b(t,n,{rect:s}),S(e,i,e=>{c(e.label?.trim()??``)&&b(t,e,{rect:s})})})}function I(e,n,r){let a=r;return S(e,n,e=>{let n=e.label?.trim()??``;!e.rect||!c(n)||i(r,e.rect)&&t(e.rect)<t(a)&&(a=e.rect)}),a}function L(e,t){let n=e.x+e.width,r=t.x+t.width,i={x:t.x,y:e.y,width:n-t.x,height:e.height};if(t.x>e.x&&d(t,i))return{...e,width:t.x-e.x};let a={x:e.x,y:e.y,width:r-e.x,height:e.height};if(r<n&&d(t,a))return{...e,x:r,width:n-r}}function R(e,t){P(e,(n,r,i)=>{u(n)&&l(n,z(e,i))&&t.suppressNode(n,z(e,i))})}function z(e,t){let n=[];return S(e,t,e=>{n.push(e)}),n}function he(e,t){let n=g(e),r=n?n.y+n.height:null;if(r!==null)for(let n=0;n<e.length;n+=1){let i=e[n];!i||!ge(i,r)||(t.suppressNode(i,[]),_e(i,t,r),S(e,n,e=>{t.suppressNode(e,[])}))}}function ge(e,t){return!e.rect||n(e.type??``)!==`keyboard`?!1:e.rect.y>=t}function _e(e,t,n){let r=typeof e.parentIndex==`number`?t.sourceNodesByIndex.get(e.parentIndex):void 0;for(;r?.rect&&r.rect.y>=n;)t.suppressNode(r,[]),r=typeof r.parentIndex==`number`?t.sourceNodesByIndex.get(r.parentIndex):void 0}function ve(e,t){for(let r=0;r<e.length;r+=1){let i=e[r];if(!i)continue;if(ye(i)){B(e,r,i,t);continue}if(!be(i))continue;let a=x(e,r,e=>n(e.type??``)===`searchfield`&&e.label===`Search`);a&&(t.suppressNode(i,[a]),xe(i,a,t),B(e,r,a,t))}}function ye(e){return n(e.type??``)===`searchfield`&&e.label===`Search`}function be(e){let t=n(e.type??``);return e.label===`Toolbar`&&(t===`toolbar`||t===`searchfield`)}function B(e,t,n,r){S(e,t,e=>{e.index!==n.index&&Se(e)&&r.suppressNode(e,[n])})}function xe(e,t,n){let r=e;for(;typeof r.parentIndex==`number`;){let e=n.sourceNodesByIndex.get(r.parentIndex);if(!e||e.label!==`Toolbar`)return;n.suppressNode(e,[t]),r=e}}function Se(e){let t=n(e.type??``);return t===`button`?!1:t===`image`||e.label===`Search`}function Ce(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?.label?.trim();!r||t.isSuppressed(r)||!i||we(e,n,r,i,t)}}function we(e,t,r,i,a){let o=n(r.type??``);if(o===`statictext`||o===`link`){V(e,t,i,r,a);return}if(o!==`other`)return;let s=Te(e,t,i);if(s){a.suppressNode(r,[s]);return}V(e,t,i,r,a)}function Te(e,t,r){return x(e,t,e=>{let t=n(e.type??``);return(t===`link`||t===`searchfield`||p(e.type))&&e.label?.trim()===r})}function V(e,t,n,r,i){S(e,t,e=>{!i.semanticRepresentativeIndexes.has(e.index)&&ie(e,n)&&i.suppressNode(e,[r])})}function Ee(e,t){P(e,(n,r,i)=>{let a=x(e,i,e=>m(e)&&e.label?.trim()===r&&(d(e.rect,n.rect)||De(n,e)));a&&t.suppressNode(n,[a])})}function De(e,t){if(t.label?.trim()!==e.label?.trim())return!1;let r=n(t.type??``);return Oe(e,r)||r===`textfield`||ke(e,r,t)}function Oe(e,t){let n=e.label?.trim();return t===`button`&&(n===`Dismiss`||n===`Back`)}function ke(e,t,n){return t!==`button`||!e.rect||!n.rect?!1:e.rect.x===0&&e.rect.y===0&&e.rect.width>=300&&e.rect.height>=600&&n.rect.width<e.rect.width}function Ae(e,t){let r=C(e);for(let i of e){if(n(i.type??``)!==`other`||i.hittable===!0||i.label?.trim()||i.value?.trim()||!i.identifier?.trim())continue;let e=je(i,r);(e.length!==0||i.hittable===!1)&&t.suppressNode(i,e)}}function je(e,t){let n=[],r=new Set([e.index]),i=[...t.get(e.index)??[]];for(;i.length>0;){let e=i.pop();if(!e||r.has(e.index))continue;r.add(e.index),n.push(e);let a=t.get(e.index);a&&i.push(...a)}return n}function Me(e,t){he(e,t),Ae(e,t),ue(e,t),ve(e,t),Ee(e,t),F(e,t.replacements),R(e,t),Ce(e,t)}function Ne(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?Pe(e,n,r,t):void 0;!r?.rect||!i||Le(e,n,r,i,t)}}function Pe(e,t,r,i){let a=r.label?.trim();if(n(r.type??``)!==`cell`||a&&!Fe(a,r.identifier)&&!o(a))return a;let s=v(e,t).find(Ie),c=s?.label?.trim();return!s||!c?a:(b(i.replacements,r,{label:c}),i.suppressNode(s,[r]),c)}function Fe(e,t){return t?.trim()===e&&/^[A-Z_$][A-Za-z0-9_$]*Cell$/.test(e)}function Ie(e){if(!e.label?.trim())return!1;let t=n(e.type??``);return t===`statictext`||t===`text`||t===`textview`}function Le(e,t,r,i,a){let o=n(r.type??``);if(o===`button`){H(v(e,t),i,a,r);return}if(o!==`cell`)return;let s=v(e,t);Re(s,r,i,a)||ze(s,r,i,a)}function Re(e,t,n,r){let i=e.find(e=>Ve(e,t,n));if(!i)return!1;let a=e.find(e=>U(e,t,n)),o=i.identifier?void 0:a?.identifier??t.identifier;return o&&b(r.replacements,i,{identifier:o}),r.suppressNode(t,[i]),Be(e,t,n,i,r),!0}function ze(e,t,n,r){let i=e.find(e=>U(e,t,n));if(!i){e.some(te)&&H(e,n,r,t);return}!t.identifier&&i.identifier&&b(r.replacements,t,{identifier:i.identifier}),r.suppressNode(i,[t]),H(e.filter(e=>e.index!==i.index),n,r,t)}function Be(e,t,n,r,i){for(let a of e)a.index!==r.index&&(U(a,t,n)||W(a,t)||He(a,r)||h(a,n))&&i.suppressNode(a,[r])}function H(e,t,n,r){for(let i of e)(h(i,t)||r&&W(i,r))&&n.suppressNode(i,r?[r]:[])}function U(e,t,r){if(n(e.type??``)!==`button`)return!1;let i=t.identifier?.trim(),a=e.identifier?.trim();return i&&a&&i===a?!0:e.label?.trim()===r&&d(e.rect,t.rect)}function W(e,t){return n(e.type??``)===`button`&&!e.label?.trim()&&!e.value?.trim()&&d(e.rect,t.rect)}function Ve(e,t,r){if(n(e.type??``)!==`switch`)return!1;let i=t.identifier?.trim(),a=e.identifier?.trim();return i&&a&&i===a?!0:e.label?.trim()===r}function He(e,t){if(n(e.type??``)!==`switch`||e.index===t.index)return!1;let r=e.label?.trim();return r===t.value?.trim()||r===`0`||r===`1`}const G=1.15;function Ue(t,n,r){let i=new Map(t.map((e,t)=>[e.index,t]));for(let[a,o]of t.entries()){let s=We(t,i,n,o,r);if(!s)continue;q(t,a,r);let c=J(s.shelfRect,2);for(let n of s.intermediateSiblings){if($e(n)||!n.rect||!e(n.rect,c))continue;let a=i.get(n.index);a!==void 0&&q(t,a,r)}}}function We(e,t,n,r,i){let a=Ge(r,n,i.sourceNodesByIndex);if(!a)return;let o=Je(e,t,a.siblings,a.position,a.parent);if(!(o<0))return{shelfRect:a.rect,intermediateSiblings:a.siblings.slice(a.position+1,o)}}function Ge(e,t,n){let r=Ye(e,K(t,e.index));if(!r)return;let i=qe(e,n);if(!i||!i.rect)return;let a=K(t,i.index),o=a.findIndex(t=>t.index===e.index);if(Ke(a,o,e,r))return{rect:r.rect,parent:i,siblings:a,position:o}}function K(e,t){return e.get(t)??[]}function Ke(e,t,n,r){if(t<1)return!1;let i=Xe(e,t,n);return i?!r.childActionsPresented||!Ze(i,r.actionButtons):!1}function qe(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function Je(e,t,n,r,i){return n.findIndex((n,a)=>a>r&&Qe(e,t.get(n.index),n,i))}function Ye(e,t){if(!p(e.type)||!e.rect)return;let r=e.rect,a=t.filter(e=>n(e.type??``)===`button`&&e.rect);if(a.length===0&&e.hiddenContentBelow===!0)return{rect:r,childActionsPresented:!1,actionButtons:a};if(a.length<3)return;let o=a.map(e=>e.rect.x+e.rect.width/2);if(o.every((e,t)=>t===0||e>o[t-1]))return{rect:r,childActionsPresented:a.some(e=>i(r,e.rect)),actionButtons:a}}function Xe(e,t,n){if(!(!n.rect||t<1))for(let r=t-1;r>=0;--r){let t=e[r];if(!(!t.rect||!m(t))&&t.rect.x+t.rect.width/2<n.rect.x&&et(t.rect,J(n.rect,2)))return t}}function Ze(e,t){if(!e.rect||t.length===0)return!1;let n=Math.max(...t.map(e=>e.rect?.width??0)),r=Math.max(...t.map(e=>e.rect?.height??0));return e.rect.width>n*G||e.rect.height>r*G}function Qe(e,t,r,i){return t!==void 0&&n(r.type??``)===`other`&&d(r.rect,i.rect)&&!!x(e,t,m)}function q(e,t,n){let r=e[t];if(r){n.suppressNode(r,[]);for(let r of v(e,t))n.suppressNode(r,[])}}function $e(e){let t=n(e.type??``);return t===`textfield`||t===`securetextfield`||t===`searchfield`||t===`textview`}function J(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function et(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function tt(e,t){let n=C(e);Ue(e,n,t),nt(e,n,t)}function nt(e,t,r){for(let i of e){if(n(i.type??``)!==`navigationbar`||!i.rect)continue;let e=t.get(i.index)??[],a=e.flatMap(t=>rt(t,e,i.rect));if(a.length!==1)continue;let{field:o,title:s,image:c,label:l}=a[0];b(r.replacements,o,{type:`Button`,label:l,enabled:!0,rect:st([c.rect,o.rect,s.rect])}),r.semanticRepresentativeIndexes.add(o.index),r.suppressNode(s,[o]),r.suppressNode(c,[o])}}function rt(e,t,n){let i=r(e);if(!it(e,i))return[];let a=X(t,e=>at(e,i)),o=X(t,Y);return a?.rect&&o?.rect&&ot(o.rect,e.rect,a.rect,n)?[{field:e,title:a,image:o,label:i}]:[]}function it(e,t){return n(e.type??``)===`textfield`&&e.enabled===!1&&!!e.rect&&!!t&&e.value?.trim()===t}function at(e,t){return n(e.type??``)===`statictext`&&e.label?.trim()===t&&!!e.rect}function Y(e){return n(e.type??``)===`image`&&!!e.identifier?.trim()&&!!e.rect}function X(e,t){let n=e.filter(t);return n.length===1?n[0]:void 0}function ot(e,t,n,r){let a=t.x-(e.x+e.width),o=n.x-(t.x+t.width);return i(r,e)&&i(r,t)&&i(r,n)&&a>=0&&a<=12&&o>=0&&o<=12&&Z(e,t)&&Z(t,n)}function Z(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function st(e){let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t,y:n,width:r-t,height:i-n}}function ct(e,t){let r=C(e);for(let i of e){if(n(i.type??``)===`element(58)`){b(t.replacements,i,{type:`WebView`});continue}let e=lt(i,t.sourceNodesByIndex,r);if(e?.kind===`suppress`){t.suppressNode(i,[]);continue}e&&(b(t.replacements,i,{type:e.type,...e.type===`Heading`?{value:void 0}:{}}),t.semanticRepresentativeIndexes.add(i.index))}}function lt(e,t,r){if(n(e.type??``)!==`other`)return null;let i=f(e,t,ft),a=e.label?.trim();return!i||!a?null:dt(e,i,a)?{kind:`suppress`}:ut(e,a,r)?{kind:`semantic`,type:Q(e.value)?`Heading`:`StaticText`}:null}function ut(e,t,r){let i=r.get(e.index);if(i?.length!==1)return!1;let a=i[0];return n(a.type??``)===`statictext`&&a.label?.trim()===t&&!r.has(a.index)}function dt(e,t,n){return e.parentIndex===t.index&&t.label?.trim()===n&&!Q(e.value)}function ft(e){let t=n(e.type??``);return t===`webview`||t===`element(58)`}function Q(e){return/^[1-6]$/.test(e?.trim()??``)}const pt=[ct,tt,ae,Ne,Me];function mt(e){if(e.length===0)return{nodes:e,presentedIndexesBySourceIndex:new Map};let t=new Map,n=new Map,r=new Set,i=new Map(e.map(e=>[e.index,e])),a=new Set,o={replacements:t,semanticRepresentativeIndexes:r,sourceNodesByIndex:i,isSuppressed:e=>a.has(e.index),suppressNode(e,t){if(a.add(e.index),t.length===0)return;let r=n.get(e.index)??new Set;for(let e of t)r.add(e.index);n.set(e.index,r)}};for(let t of pt)t(e,o);if(a.size===0&&t.size===0)return{nodes:e,presentedIndexesBySourceIndex:new Map(e.map(e=>[e.index,[e.index]]))};let s=e.filter(e=>!a.has(e.index)).map(e=>t.get(e.index)??e),c=_(s,a,e),l=new Map(s.map((e,t)=>[e.index,c[t].index]));return{nodes:c,presentedIndexesBySourceIndex:new Map(e.map(e=>[e.index,$(e.index,l,n)]))}}function $(e,t,n,r=new Set){let i=t.get(e);if(i!==void 0)return[i];if(r.has(e))return[];r.add(e);let a=new Set;for(let i of n.get(e)??[])for(let e of $(i,t,n,r))a.add(e);return[...a].sort((e,t)=>e-t)}export{mt as t};
|
|
1
|
+
import{Br as e,Hr as t,Mr as n,Or as r,Ur as i,zr as a}from"./sdk-batch.js";import{n as o,t as s}from"./scroll-indicator.js";import{a as c,i as l,o as ee,r as u}from"./react-native-overlay.js";import{t as d}from"./rect-center.js";import{a as f,c as te,d as p,f as m,g as ne,h,i as g,l as re,m as _,n as v,o as y,p as b,r as x,s as S,t as C,u as ie}from"./tree.js";function ae(e,t){let n=g(t.sourceNodesByIndex.values());for(let r of e)oe(r,t.sourceNodesByIndex,n)&&b(t.replacements,r,{type:`Cell`})}function oe(e,t,r){return!(n(e.type??``)!==`other`||e.enabled===!1||!e.rect||!le(e.label)||!f(e,t,ce)||!se(e)||re(e.rect,r))}function se(e){return e.rect?e.rect.height>=44&&e.rect.height<=160&&e.rect.width>=120:!1}function ce(e){let t=n(e.type??``);return t===`scrollview`||t===`scrollarea`}function le(e){let t=e?.trim();return!(!t||/^(toolbar|window|application)$/i.test(t)||t.startsWith(`!,`)||/debugger|fast refresh/i.test(t))}function ue(e,t){let n=new Set;for(let r of e)de(t.replacements.get(r.index)??r)&&fe(r,t.sourceNodesByIndex,t,n);pe(e,t,n)}function de(e){let t=e.label?.trim();return!!(t&&o(t))}function fe(e,t,n,r){let i=!p(e.type)||n.isSuppressed(e),a=s(e.label?.trim()??``,e.value),o=a?y(e,t,{includeSelf:!0}):void 0;i&&n.suppressNode(e,o?[o]:[]),o&&a&&j(n,o,e,a)&&r.add(o.index)}function pe(e,t,n){let r=new Map;for(let i of e){let e=r.get(i.parentIndex??-1),a=e?.clip,o=t.replacements.get(i.index)??i,s=k(o.rect,a),c=me(o,a,s),l=w(e,c,o);T(t,i,o,a,s,c,l),r.set(i.index,E(i,o,a,s,l,n))}}function me(e,t,n){return!!(t&&a(e.rect)&&!a(n))}function w(e,t,n){return!!(e?.projectedOut||t&&O(n))}function T(e,t,n,r,i,a,o){o||a?e.suppressNode(t,[]):r&&i&&!A(n.rect,i)&&b(e.replacements,t,{rect:i})}function E(e,t,n,r,i,a){return{projectedOut:i,...D(e,t,n,r,a)?{clip:r}:n?{clip:n}:{}}}function D(e,t,n,r,i){return!!(a(r)&&(i.has(e.index)||n!==void 0&&p(t.type)))}function O(e){return e.type?.trim().toLowerCase()===`cell`||p(e.type)}function k(e,t){if(!e||!t)return e;let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return{x:n,y:r,width:Math.max(0,i-n),height:Math.max(0,a-r)}}function A(e,t){return!!(e&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height)}function j(e,t,n,r){let i=N((e.replacements.get(t.index)??t).rect,n.rect);return ne(e.replacements,t,e=>({rect:i??e.rect,hiddenContentAbove:M(e.hiddenContentAbove,r.above),hiddenContentBelow:M(e.hiddenContentBelow,r.below)})),!!i}function M(e,t){return e===!0||t?!0:void 0}function N(e,t){if(!(!e||!t)&&!(t.height<=0||t.height>=e.height)&&!(t.y<e.y||t.y>e.y+e.height))return{...e,y:t.y,height:Math.min(t.height,e.y+e.height-t.y)}}function P(e,t){for(let r=0;r<e.length;r+=1){let i=e[r],a=i?.label?.trim();i&&a&&n(i.type??``)===`other`&&t(i,a,r)}}function F(e,t){P(e,(n,r,i)=>{if(!c(r)||!n.rect)return;let a=x(e,i,e=>!!e.rect&&ee(e.label?.trim()??``));if(!a?.rect)return;let o=L(n.rect,a.rect);if(!o)return;let s=I(e,i,o);b(t,n,{rect:s}),S(e,i,e=>{c(e.label?.trim()??``)&&b(t,e,{rect:s})})})}function I(e,n,r){let a=r;return S(e,n,e=>{let n=e.label?.trim()??``;!e.rect||!c(n)||i(r,e.rect)&&t(e.rect)<t(a)&&(a=e.rect)}),a}function L(e,t){let n=e.x+e.width,r=t.x+t.width,i={x:t.x,y:e.y,width:n-t.x,height:e.height};if(t.x>e.x&&d(t,i))return{...e,width:t.x-e.x};let a={x:e.x,y:e.y,width:r-e.x,height:e.height};if(r<n&&d(t,a))return{...e,x:r,width:n-r}}function R(e,t){P(e,(n,r,i)=>{u(n)&&l(n,z(e,i))&&t.suppressNode(n,z(e,i))})}function z(e,t){let n=[];return S(e,t,e=>{n.push(e)}),n}function he(e,t){let n=g(e),r=n?n.y+n.height:null;if(r!==null)for(let n=0;n<e.length;n+=1){let i=e[n];!i||!ge(i,r)||(t.suppressNode(i,[]),_e(i,t,r),S(e,n,e=>{t.suppressNode(e,[])}))}}function ge(e,t){return!e.rect||n(e.type??``)!==`keyboard`?!1:e.rect.y>=t}function _e(e,t,n){let r=typeof e.parentIndex==`number`?t.sourceNodesByIndex.get(e.parentIndex):void 0;for(;r?.rect&&r.rect.y>=n;)t.suppressNode(r,[]),r=typeof r.parentIndex==`number`?t.sourceNodesByIndex.get(r.parentIndex):void 0}function ve(e,t){for(let r=0;r<e.length;r+=1){let i=e[r];if(!i)continue;if(ye(i)){B(e,r,i,t);continue}if(!be(i))continue;let a=x(e,r,e=>n(e.type??``)===`searchfield`&&e.label===`Search`);a&&(t.suppressNode(i,[a]),xe(i,a,t),B(e,r,a,t))}}function ye(e){return n(e.type??``)===`searchfield`&&e.label===`Search`}function be(e){let t=n(e.type??``);return e.label===`Toolbar`&&(t===`toolbar`||t===`searchfield`)}function B(e,t,n,r){S(e,t,e=>{e.index!==n.index&&Se(e)&&r.suppressNode(e,[n])})}function xe(e,t,n){let r=e;for(;typeof r.parentIndex==`number`;){let e=n.sourceNodesByIndex.get(r.parentIndex);if(!e||e.label!==`Toolbar`)return;n.suppressNode(e,[t]),r=e}}function Se(e){let t=n(e.type??``);return t===`button`?!1:t===`image`||e.label===`Search`}function Ce(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?.label?.trim();!r||t.isSuppressed(r)||!i||we(e,n,r,i,t)}}function we(e,t,r,i,a){let o=n(r.type??``);if(o===`statictext`||o===`link`){V(e,t,i,r,a);return}if(o!==`other`)return;let s=Te(e,t,i);if(s){a.suppressNode(r,[s]);return}V(e,t,i,r,a)}function Te(e,t,r){return x(e,t,e=>{let t=n(e.type??``);return(t===`link`||t===`searchfield`||p(e.type))&&e.label?.trim()===r})}function V(e,t,n,r,i){S(e,t,e=>{!i.semanticRepresentativeIndexes.has(e.index)&&ie(e,n)&&i.suppressNode(e,[r])})}function Ee(e,t){P(e,(n,r,i)=>{let a=x(e,i,e=>m(e)&&e.label?.trim()===r&&(d(e.rect,n.rect)||De(n,e)));a&&t.suppressNode(n,[a])})}function De(e,t){if(t.label?.trim()!==e.label?.trim())return!1;let r=n(t.type??``);return Oe(e,r)||r===`textfield`||ke(e,r,t)}function Oe(e,t){let n=e.label?.trim();return t===`button`&&(n===`Dismiss`||n===`Back`)}function ke(e,t,n){return t!==`button`||!e.rect||!n.rect?!1:e.rect.x===0&&e.rect.y===0&&e.rect.width>=300&&e.rect.height>=600&&n.rect.width<e.rect.width}function Ae(e,t){let r=C(e);for(let i of e){if(n(i.type??``)!==`other`||i.hittable===!0||i.label?.trim()||i.value?.trim()||!i.identifier?.trim())continue;let e=je(i,r);(e.length!==0||i.hittable===!1)&&t.suppressNode(i,e)}}function je(e,t){let n=[],r=new Set([e.index]),i=[...t.get(e.index)??[]];for(;i.length>0;){let e=i.pop();if(!e||r.has(e.index))continue;r.add(e.index),n.push(e);let a=t.get(e.index);a&&i.push(...a)}return n}function Me(e,t){he(e,t),Ae(e,t),ue(e,t),ve(e,t),Ee(e,t),F(e,t.replacements),R(e,t),Ce(e,t)}function Ne(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?Pe(e,n,r,t):void 0;!r?.rect||!i||Le(e,n,r,i,t)}}function Pe(e,t,r,i){let a=r.label?.trim();if(n(r.type??``)!==`cell`||a&&!Fe(a,r.identifier)&&!o(a))return a;let s=v(e,t).find(Ie),c=s?.label?.trim();return!s||!c?a:(b(i.replacements,r,{label:c}),i.suppressNode(s,[r]),c)}function Fe(e,t){return t?.trim()===e&&/^[A-Z_$][A-Za-z0-9_$]*Cell$/.test(e)}function Ie(e){if(!e.label?.trim())return!1;let t=n(e.type??``);return t===`statictext`||t===`text`||t===`textview`}function Le(e,t,r,i,a){let o=n(r.type??``);if(o===`button`){H(v(e,t),i,a,r);return}if(o!==`cell`)return;let s=v(e,t);Re(s,r,i,a)||ze(s,r,i,a)}function Re(e,t,n,r){let i=e.find(e=>Ve(e,t,n));if(!i)return!1;let a=e.find(e=>U(e,t,n)),o=i.identifier?void 0:a?.identifier??t.identifier;return o&&b(r.replacements,i,{identifier:o}),r.suppressNode(t,[i]),Be(e,t,n,i,r),!0}function ze(e,t,n,r){let i=e.find(e=>U(e,t,n));if(!i){e.some(te)&&H(e,n,r,t);return}!t.identifier&&i.identifier&&b(r.replacements,t,{identifier:i.identifier}),r.suppressNode(i,[t]),H(e.filter(e=>e.index!==i.index),n,r,t)}function Be(e,t,n,r,i){for(let a of e)a.index!==r.index&&(U(a,t,n)||W(a,t)||He(a,r)||h(a,n))&&i.suppressNode(a,[r])}function H(e,t,n,r){for(let i of e)(h(i,t)||r&&W(i,r))&&n.suppressNode(i,r?[r]:[])}function U(e,t,r){if(n(e.type??``)!==`button`)return!1;let i=t.identifier?.trim(),a=e.identifier?.trim();return i&&a&&i===a?!0:e.label?.trim()===r&&d(e.rect,t.rect)}function W(e,t){return n(e.type??``)===`button`&&!e.label?.trim()&&!e.value?.trim()&&d(e.rect,t.rect)}function Ve(e,t,r){if(n(e.type??``)!==`switch`)return!1;let i=t.identifier?.trim(),a=e.identifier?.trim();return i&&a&&i===a?!0:e.label?.trim()===r}function He(e,t){if(n(e.type??``)!==`switch`||e.index===t.index)return!1;let r=e.label?.trim();return r===t.value?.trim()||r===`0`||r===`1`}const G=1.15;function Ue(t,n,r){let i=new Map(t.map((e,t)=>[e.index,t]));for(let[a,o]of t.entries()){let s=We(t,i,n,o,r);if(!s)continue;q(t,a,r);let c=J(s.shelfRect,2);for(let n of s.intermediateSiblings){if($e(n)||!n.rect||!e(n.rect,c))continue;let a=i.get(n.index);a!==void 0&&q(t,a,r)}}}function We(e,t,n,r,i){let a=Ge(r,n,i.sourceNodesByIndex);if(!a)return;let o=Je(e,t,a.siblings,a.position,a.parent);if(!(o<0))return{shelfRect:a.rect,intermediateSiblings:a.siblings.slice(a.position+1,o)}}function Ge(e,t,n){let r=Ye(e,K(t,e.index));if(!r)return;let i=qe(e,n);if(!i||!i.rect)return;let a=K(t,i.index),o=a.findIndex(t=>t.index===e.index);if(Ke(a,o,e,r))return{rect:r.rect,parent:i,siblings:a,position:o}}function K(e,t){return e.get(t)??[]}function Ke(e,t,n,r){if(t<1)return!1;let i=Xe(e,t,n);return i?!r.childActionsPresented||!Ze(i,r.actionButtons):!1}function qe(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function Je(e,t,n,r,i){return n.findIndex((n,a)=>a>r&&Qe(e,t.get(n.index),n,i))}function Ye(e,t){if(!p(e.type)||!e.rect)return;let r=e.rect,a=t.filter(e=>n(e.type??``)===`button`&&e.rect);if(a.length===0&&e.hiddenContentBelow===!0)return{rect:r,childActionsPresented:!1,actionButtons:a};if(a.length<3)return;let o=a.map(e=>e.rect.x+e.rect.width/2);if(o.every((e,t)=>t===0||e>o[t-1]))return{rect:r,childActionsPresented:a.some(e=>i(r,e.rect)),actionButtons:a}}function Xe(e,t,n){if(!(!n.rect||t<1))for(let r=t-1;r>=0;--r){let t=e[r];if(!(!t.rect||!m(t))&&t.rect.x+t.rect.width/2<n.rect.x&&et(t.rect,J(n.rect,2)))return t}}function Ze(e,t){if(!e.rect||t.length===0)return!1;let n=Math.max(...t.map(e=>e.rect?.width??0)),r=Math.max(...t.map(e=>e.rect?.height??0));return e.rect.width>n*G||e.rect.height>r*G}function Qe(e,t,r,i){return t!==void 0&&n(r.type??``)===`other`&&d(r.rect,i.rect)&&!!x(e,t,m)}function q(e,t,n){let r=e[t];if(r){n.suppressNode(r,[]);for(let r of v(e,t))n.suppressNode(r,[])}}function $e(e){let t=n(e.type??``);return t===`textfield`||t===`securetextfield`||t===`searchfield`||t===`textview`}function J(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function et(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function tt(e,t){let n=C(e);Ue(e,n,t),nt(e,n,t)}function nt(e,t,r){for(let i of e){if(n(i.type??``)!==`navigationbar`||!i.rect)continue;let e=t.get(i.index)??[],a=e.flatMap(t=>rt(t,e,i.rect));if(a.length!==1)continue;let{field:o,title:s,image:c,label:l}=a[0];b(r.replacements,o,{type:`Button`,label:l,enabled:!0,hittable:void 0,rect:st([c.rect,o.rect,s.rect])}),r.semanticRepresentativeIndexes.add(o.index),r.suppressNode(s,[o]),r.suppressNode(c,[o])}}function rt(e,t,n){let i=r(e);if(!it(e,i))return[];let a=X(t,e=>at(e,i)),o=X(t,Y);return a?.rect&&o?.rect&&ot(o.rect,e.rect,a.rect,n)?[{field:e,title:a,image:o,label:i}]:[]}function it(e,t){return n(e.type??``)===`textfield`&&e.enabled===!1&&!!e.rect&&!!t&&e.value?.trim()===t}function at(e,t){return n(e.type??``)===`statictext`&&e.label?.trim()===t&&!!e.rect}function Y(e){return n(e.type??``)===`image`&&!!e.identifier?.trim()&&!!e.rect}function X(e,t){let n=e.filter(t);return n.length===1?n[0]:void 0}function ot(e,t,n,r){let a=t.x-(e.x+e.width),o=n.x-(t.x+t.width);return i(r,e)&&i(r,t)&&i(r,n)&&a>=0&&a<=12&&o>=0&&o<=12&&Z(e,t)&&Z(t,n)}function Z(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function st(e){let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t,y:n,width:r-t,height:i-n}}function ct(e,t){let r=C(e);for(let i of e){if(n(i.type??``)===`element(58)`){b(t.replacements,i,{type:`WebView`});continue}let e=lt(i,t.sourceNodesByIndex,r);if(e?.kind===`suppress`){t.suppressNode(i,[]);continue}e&&(b(t.replacements,i,{type:e.type,...e.type===`Heading`?{value:void 0}:{}}),t.semanticRepresentativeIndexes.add(i.index))}}function lt(e,t,r){if(n(e.type??``)!==`other`)return null;let i=f(e,t,ft),a=e.label?.trim();return!i||!a?null:dt(e,i,a)?{kind:`suppress`}:ut(e,a,r)?{kind:`semantic`,type:Q(e.value)?`Heading`:`StaticText`}:null}function ut(e,t,r){let i=r.get(e.index);if(i?.length!==1)return!1;let a=i[0];return n(a.type??``)===`statictext`&&a.label?.trim()===t&&!r.has(a.index)}function dt(e,t,n){return e.parentIndex===t.index&&t.label?.trim()===n&&!Q(e.value)}function ft(e){let t=n(e.type??``);return t===`webview`||t===`element(58)`}function Q(e){return/^[1-6]$/.test(e?.trim()??``)}const pt=[ct,tt,ae,Ne,Me];function mt(e){if(e.length===0)return{nodes:e,presentedIndexesBySourceIndex:new Map};let t=new Map,n=new Map,r=new Set,i=new Map(e.map(e=>[e.index,e])),a=new Set,o={replacements:t,semanticRepresentativeIndexes:r,sourceNodesByIndex:i,isSuppressed:e=>a.has(e.index),suppressNode(e,t){if(a.add(e.index),t.length===0)return;let r=n.get(e.index)??new Set;for(let e of t)r.add(e.index);n.set(e.index,r)}};for(let t of pt)t(e,o);if(a.size===0&&t.size===0)return{nodes:e,presentedIndexesBySourceIndex:new Map(e.map(e=>[e.index,[e.index]]))};let s=e.filter(e=>!a.has(e.index)).map(e=>t.get(e.index)??e),c=_(s,a,e),l=new Map(s.map((e,t)=>[e.index,c[t].index]));return{nodes:c,presentedIndexesBySourceIndex:new Map(e.map(e=>[e.index,$(e.index,l,n)]))}}function $(e,t,n,r=new Set){let i=t.get(e);if(i!==void 0)return[i];if(r.has(e))return[];r.add(e);let a=new Set;for(let i of n.get(e)??[])for(let e of $(i,t,n,r))a.add(e);return[...a].sort((e,t)=>e-t)}export{mt as t};
|