agent-device 0.21.29 → 0.21.30
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.29.apk → agent-device-android-ime-helper-0.21.30.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.30.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.29.manifest.json → agent-device-android-ime-helper-0.21.30.manifest.json} +4 -4
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.30.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.30.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.29.manifest.json → agent-device-android-snapshot-helper-0.21.30.manifest.json} +7 -7
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/AudioProbe.swift +4 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandDispatch.swift +2 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +12 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +25 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +8 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +9 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +3 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +35 -9
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +44 -26
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotModels.swift +20 -1
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentation.swift +4 -3
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationProjection.swift +4 -2
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFold.swift +20 -2
- package/dist/src/adapter.js +1 -1
- package/dist/src/agent-browser-lifecycle.js +1 -1
- package/dist/src/agent-browser-process-record.js +1 -1
- package/dist/src/agent-browser-provider.js +1 -1
- package/dist/src/agent-device-client.js +1 -1
- package/dist/src/alert2.js +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/app-lifecycle.js +1 -1
- package/dist/src/app-log-runtime2.js +3 -3
- package/dist/src/auth.js +1 -1
- package/dist/src/automation-helper.js +1 -1
- package/dist/src/back-mode.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +13 -10
- package/dist/src/cli.js +3 -3
- package/dist/src/client-types.d.ts +82 -13
- package/dist/src/cloud-artifacts.d.ts +99 -3
- package/dist/src/command-metadata.js +42 -42
- package/dist/src/composed-inventory-gateways.js +1 -1
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection.js +1 -1
- package/dist/src/contract.d.ts +2 -2
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/daemon-client-ensure.js +1 -1
- package/dist/src/daemon-client-ensuring.js +1 -1
- package/dist/src/daemon-client-lease-beat.js +1 -1
- package/dist/src/daemon-client-lifecycle.js +1 -1
- package/dist/src/daemon-client.js +2 -2
- package/dist/src/daemon-lifecycle-errors.js +1 -1
- package/dist/src/daemon-registration-owner.js +3 -3
- package/dist/src/daemon-registration.js +1 -1
- package/dist/src/daemon-resolution.js +1 -1
- package/dist/src/daemon-shutdown-report.js +1 -1
- package/dist/src/daemon-startup-diagnostics.js +1 -1
- package/dist/src/daemon.js +3 -3
- package/dist/src/device-claim-recovery.js +1 -1
- package/dist/src/durable-capture-resource.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/ended-lease.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/gesture-plan-types.d.ts +14 -4
- package/dist/src/gesture-plan.js +1 -1
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/host4.js +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/input-actions.js +1 -1
- package/dist/src/input-actions2.js +1 -1
- package/dist/src/interaction-positionals.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor-operation-catalog.js +1 -1
- package/dist/src/interactor.js +5 -5
- package/dist/src/interactor3.js +1 -1
- package/dist/src/interactor4.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +1 -1
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/inventory6.js +1 -1
- package/dist/src/ios-node-interpretation.js +1 -1
- package/dist/src/ios-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-engine.js +1 -1
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/keyboard-occlusion.js +1 -1
- package/dist/src/launch-confirmation.js +1 -1
- package/dist/src/lease-context.js +1 -1
- package/dist/src/lease-registry-scope.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/mechanics.js +12 -12
- package/dist/src/metro-session-hints.js +1 -1
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/observability.js +1 -1
- package/dist/src/observation.js +1 -1
- package/dist/src/parameterized-recorded-fill.js +1 -1
- package/dist/src/perf-facade.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +1 -1
- package/dist/src/platform-runtime-unavailable.js +1 -1
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -1
- package/dist/src/plugins2.js +1 -1
- package/dist/src/png-resize.js +1 -1
- package/dist/src/png-worker-client.js +1 -1
- package/dist/src/png-worker-contract.js +1 -1
- package/dist/src/provider-device-runtime.d.ts +20 -1
- package/dist/src/provider-plugin.d.ts +1 -1
- package/dist/src/react-native-overlay2.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/replay-maestro-backend.js +3 -3
- package/dist/src/replay-script-selection.js +1 -1
- package/dist/src/replay.d.ts +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/result-serialization.js +1 -1
- package/dist/src/runner-error-classification.js +1 -1
- package/dist/src/runtime-admission.js +1 -1
- package/dist/src/runtime-deployment.js +1 -1
- package/dist/src/runtime-factory.js +1 -1
- package/dist/src/runtime-session.js +1 -1
- package/dist/src/runtime.js +5 -5
- package/dist/src/runtime10.js +2 -2
- package/dist/src/runtime3.js +5 -5
- package/dist/src/runtime5.js +1 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +1 -1
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +2 -2
- package/dist/src/screenshot-image-size.js +1 -0
- package/dist/src/screenshot-image.js +1 -1
- package/dist/src/screenshot-runtime.js +1 -1
- package/dist/src/screenshot3.js +2 -2
- package/dist/src/sdk-batch.js +1 -1
- package/dist/src/sdk-contracts.d.ts +7 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-selectors.d.ts +1 -1
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-pipeline-policy.js +1 -1
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server-startup.js +1 -1
- package/dist/src/session-replay-vars.js +1 -1
- package/dist/src/session-store.js +2 -2
- package/dist/src/session.js +1 -1
- package/dist/src/session2.js +5 -5
- package/dist/src/settle-observation-capture.js +1 -1
- package/dist/src/snapshot-capture-annotations.js +1 -1
- package/dist/src/snapshot-chrome.js +1 -1
- package/dist/src/snapshot-desktop-projection.js +1 -1
- package/dist/src/snapshot-helper-install.js +7 -5
- package/dist/src/snapshot-node-lookup.js +1 -1
- package/dist/src/snapshot-occlusion.js +1 -1
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime-capture-input.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-state.js +1 -1
- package/dist/src/snapshot.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src3.js +1 -1
- package/dist/src/src4.js +1 -1
- package/dist/src/tap-keyboard-occlusion.js +1 -1
- package/dist/src/target-evidence-tree.js +1 -1
- package/dist/src/target-evidence.js +1 -1
- package/dist/src/telephony-runtime.js +1 -1
- package/dist/src/text-entry-focus.js +1 -1
- package/dist/src/touch-reference-frame.js +1 -1
- package/dist/src/touch-runtime2.js +1 -1
- package/dist/src/tree.js +1 -1
- package/dist/src/tv-remote-runtime.js +1 -1
- package/dist/src/tv-remote.js +2 -2
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/video.js +1 -1
- package/dist/src/webdriver-source.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.29.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.29.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.29.apk.sha256 +0 -1
- package/dist/src/daemon-client-lifecycle-request.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{y as e}from"./sdk-contracts.js";import{G as t,K as n}from"./tv-remote.js";import{$r as r,Lr as i,Qr as a,Vr as o,Zr as s,ei as c,ii as l,oi as u,ri as d}from"./sdk-batch.js";import{n as f}from"./rect-center.js";import{i as p,n as m,t as h}from"./ios-snapshot-planning.js";import{_ as g,a as _,c as v,d as ee,f as y,g as b,h as te,i as x,l as ne,m as S,n as C,o as w,p as T,r as re,t as E,u as ie}from"./tree.js";import{a as D,i as ae,o as oe,r as se}from"./react-native-overlay.js";function ce(e,t){let n=_(t.sourceNodesByIndex.values());for(let r of e)le(r,t.sourceNodesByIndex,n)&&S(t.replacements,r,{type:`Cell`})}function le(e,t,n){return!(o(e.type??``)!==`other`||e.enabled===!1||!e.rect||!fe(e.label)||!w(e,t,de)||!ue(e)||ie(e.rect,n))}function ue(e){return e.rect?e.rect.height>=44&&e.rect.height<=160&&e.rect.width>=120:!1}function de(e){let t=o(e.type??``);return t===`scrollview`||t===`scrollarea`}function fe(e){let t=e?.trim();return!(!t||/^(toolbar|window|application)$/i.test(t)||t.startsWith(`!,`)||/debugger|fast refresh/i.test(t))}function pe(e,t){let n=new Set;for(let r of e)me(t.replacements.get(r.index)??r)&&he(r,t.sourceNodesByIndex,t,n);ve(e,t,n)}function me(e){let t=e.label?.trim();return!!(t&&n(t))}function he(e,n,r,i){let a=!y(e.type)||r.isSuppressed(e),o=t(e.label?.trim()??``,e.value),s=o?_e(e,n):void 0;a&&r.suppressNode(e,s?[s]:[]),s&&o&&Ee(r,s,e,o)&&i.add(s.index)}function O(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function ge(e,t){return e.rect!=null&&t.rect!=null&&k(e.rect,t.rect)}function _e(e,t){if(y(e.type))return null;let n=O(e,t);for(;n&&!y(n.type);){let e=O(n,t);if(!e||!ge(n,e))return null;n=e}return n??null}function ve(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=Te(o.rect,a),c=ye(o,a,s),l=be(e,c,o);xe(t,i,o,a,s,c,l),r.set(i.index,Se(i,o,a,s,l,n))}}function ye(e,t,n){return!!(t&&r(e.rect)&&!r(n))}function be(e,t,n){return!!(e?.projectedOut||t&&we(n))}function xe(e,t,n,r,i,a,o){o||a?e.suppressNode(t,[]):r&&i&&!k(n.rect,i)&&S(e.replacements,t,{rect:i})}function Se(e,t,n,r,i,a){return{projectedOut:i,...Ce(e,t,n,r,a)?{clip:r}:n?{clip:n}:{}}}function Ce(e,t,n,i,a){return!!(r(i)&&(a.has(e.index)||n!==void 0&&y(t.type)))}function we(e){return e.type?.trim().toLowerCase()===`cell`||y(e.type)}function Te(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 k(e,t){return!!(e&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height)}function Ee(e,t,n,r){let i=De((e.replacements.get(t.index)??t).rect,n.rect);return g(e.replacements,t,e=>({rect:i??e.rect,hiddenContentAbove:A(e.hiddenContentAbove,r.above),hiddenContentBelow:A(e.hiddenContentBelow,r.below)})),!!i}function A(e,t){return e===!0||t?!0:void 0}function De(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 j(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?.label?.trim();r&&i&&o(r.type??``)===`other`&&t(r,i,n)}}function Oe(e,t){j(e,(n,r,i)=>{if(!D(r)||!n.rect)return;let a=x(e,i,e=>!!e.rect&&oe(e.label?.trim()??``));if(!a?.rect)return;let o=Ae(n.rect,a.rect);if(!o)return;let s=ke(e,i,o);S(t,n,{rect:s}),v(e,i,e=>{D(e.label?.trim()??``)&&S(t,e,{rect:s})})})}function ke(e,t,n){let r=n;return v(e,t,e=>{let t=e.label?.trim()??``;!e.rect||!D(t)||l(n,e.rect)&&d(e.rect)<d(r)&&(r=e.rect)}),r}function Ae(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&&f(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&&f(t,a))return{...e,x:r,width:n-r}}function je(e,t){j(e,(n,r,i)=>{se(n)&&ae(n,M(e,i))&&t.suppressNode(n,M(e,i))})}function M(e,t){let n=[];return v(e,t,e=>{n.push(e)}),n}function Me(e,t){let n=_(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||!Ne(i,r)||(t.suppressNode(i,[]),Pe(i,t,r),v(e,n,e=>{t.suppressNode(e,[])}))}}function Ne(e,t){return!e.rect||o(e.type??``)!==`keyboard`?!1:e.rect.y>=t}function Pe(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 Fe(e,t){for(let n=0;n<e.length;n+=1){let r=e[n];if(!r)continue;if(Ie(r)){N(e,n,r,t);continue}if(!Le(r))continue;let i=x(e,n,e=>o(e.type??``)===`searchfield`&&e.label===`Search`);i&&(t.suppressNode(r,[i]),Re(r,i,t),N(e,n,i,t))}}function Ie(e){return o(e.type??``)===`searchfield`&&e.label===`Search`}function Le(e){let t=o(e.type??``);return e.label===`Toolbar`&&(t===`toolbar`||t===`searchfield`)}function N(e,t,n,r){v(e,t,e=>{e.index!==n.index&&ze(e)&&r.suppressNode(e,[n])})}function Re(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 ze(e){let t=o(e.type??``);return t===`button`?!1:t===`image`||e.label===`Search`}function Be(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?.label?.trim();!r||t.isSuppressed(r)||!i||Ve(e,n,r,i,t)}}function Ve(e,t,n,r,i){let a=o(n.type??``);if(a===`statictext`||a===`link`){P(e,t,r,n,i);return}if(a!==`other`)return;let s=He(e,t,r);if(s){i.suppressNode(n,[s]);return}P(e,t,r,n,i)}function He(e,t,n){return x(e,t,e=>{let t=o(e.type??``);return(t===`link`||t===`searchfield`||y(e.type))&&e.label?.trim()===n})}function P(e,t,n,r,i){v(e,t,e=>{!i.semanticRepresentativeIndexes.has(e.index)&&ee(e,n)&&i.suppressNode(e,[r])})}function Ue(e,t){j(e,(n,r,i)=>{let a=x(e,i,e=>T(e)&&e.label?.trim()===r&&(f(e.rect,n.rect)||We(n,e)));a&&t.suppressNode(n,[a])})}function We(e,t){if(t.label?.trim()!==e.label?.trim())return!1;let n=o(t.type??``);return Ge(e,n)||n===`textfield`||Ke(e,n,t)}function Ge(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 qe(e,t){let n=E(e);for(let r of e){if(o(r.type??``)!==`other`||r.hittable===!0||r.label?.trim()||r.value?.trim()||!r.identifier?.trim())continue;let e=re(r,n);(e.length!==0||r.hittable===!1)&&t.suppressNode(r,e)}}function Je(e,t){Me(e,t),qe(e,t),pe(e,t),Fe(e,t),Ue(e,t),Oe(e,t.replacements),je(e,t),Be(e,t)}function Ye(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?Xe(e,n,r,t):void 0;!r?.rect||!i||$e(e,n,r,i,t)}}function Xe(e,t,r,i){let a=r.label?.trim();if(o(r.type??``)!==`cell`||a&&!Ze(a,r.identifier)&&!n(a))return a;let s=C(e,t).find(Qe),c=s?.label?.trim();return!s||!c?a:(S(i.replacements,r,{label:c}),i.suppressNode(s,[r]),c)}function Ze(e,t){return t?.trim()===e&&/^[A-Z_$][A-Za-z0-9_$]*Cell$/.test(e)}function Qe(e){if(!e.label?.trim())return!1;let t=o(e.type??``);return t===`statictext`||t===`text`||t===`textview`}function $e(e,t,n,r,i){let a=o(n.type??``);if(a===`button`){F(C(e,t),r,i,n);return}if(a!==`cell`)return;let s=C(e,t);et(s,n,r,i)||tt(s,n,r,i)}function et(e,t,n,r){let i=e.find(e=>rt(e,t,n));if(!i)return!1;let a=e.find(e=>I(e,t,n)),o=i.identifier?void 0:a?.identifier??t.identifier;return o&&S(r.replacements,i,{identifier:o}),r.suppressNode(t,[i]),nt(e,t,n,i,r),!0}function tt(e,t,n,r){let i=e.find(e=>I(e,t,n));if(!i){e.some(ne)&&F(e,n,r,t);return}!t.identifier&&i.identifier&&S(r.replacements,t,{identifier:i.identifier}),r.suppressNode(i,[t]),F(e.filter(e=>e.index!==i.index),n,r,t)}function nt(e,t,n,r,i){for(let a of e)a.index!==r.index&&(I(a,t,n)||L(a,t)||it(a,r)||b(a,n))&&i.suppressNode(a,[r])}function F(e,t,n,r){for(let i of e)(b(i,t)||r&&L(i,r))&&n.suppressNode(i,r?[r]:[])}function I(e,t,n){if(o(e.type??``)!==`button`)return!1;let r=t.identifier?.trim(),i=e.identifier?.trim();return r&&i&&r===i?!0:e.label?.trim()===n&&f(e.rect,t.rect)}function L(e,t){return o(e.type??``)===`button`&&!e.label?.trim()&&!e.value?.trim()&&f(e.rect,t.rect)}function rt(e,t,n){if(o(e.type??``)!==`switch`)return!1;let r=t.identifier?.trim(),i=e.identifier?.trim();return r&&i&&r===i?!0:e.label?.trim()===n}function it(e,t){if(o(e.type??``)!==`switch`||e.index===t.index)return!1;let n=e.label?.trim();return n===t.value?.trim()||n===`0`||n===`1`}const R=1.15;function at(e,t,n){let r=new Map(e.map((e,t)=>[e.index,t]));for(let[i,a]of e.entries()){let o=ot(e,r,t,a,n);if(!o)continue;B(e,i,n);let s=V(o.shelfRect,2);for(let t of o.intermediateSiblings){if(ht(t)||!t.rect||!c(t.rect,s))continue;let i=r.get(t.index);i!==void 0&&B(e,i,n)}}}function ot(e,t,n,r,i){let a=st(r,n,i.sourceNodesByIndex);if(!a)return;let o=ut(e,t,a.siblings,a.position,a.parent);if(!(o<0))return{shelfRect:a.rect,intermediateSiblings:a.siblings.slice(a.position+1,o)}}function st(e,t,n){let r=dt(e,z(t,e.index));if(!r)return;let i=lt(e,n);if(!i||!i.rect)return;let a=z(t,i.index),o=a.findIndex(t=>t.index===e.index);if(ct(a,o,e,r))return{rect:r.rect,parent:i,siblings:a,position:o}}function z(e,t){return e.get(t)??[]}function ct(e,t,n,r){if(t<1)return!1;let i=ft(e,t,n);return i?!r.childActionsPresented||!pt(i,r.actionButtons):!1}function lt(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function ut(e,t,n,r,i){return n.findIndex((n,a)=>a>r&&mt(e,t.get(n.index),n,i))}function dt(e,t){if(!y(e.type)||!e.rect)return;let n=e.rect,r=t.filter(e=>o(e.type??``)===`button`&&e.rect);if(r.length===0&&e.hiddenContentBelow===!0)return{rect:n,childActionsPresented:!1,actionButtons:r};if(r.length<3)return;let i=r.map(e=>e.rect.x+e.rect.width/2);if(i.every((e,t)=>t===0||e>i[t-1]))return{rect:n,childActionsPresented:r.some(e=>l(n,e.rect)),actionButtons:r}}function ft(e,t,n){if(!(!n.rect||t<1))for(let r=t-1;r>=0;--r){let t=e[r];if(!(!t.rect||!T(t))&&t.rect.x+t.rect.width/2<n.rect.x&>(t.rect,V(n.rect,2)))return t}}function pt(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*R||e.rect.height>r*R}function mt(e,t,n,r){return t!==void 0&&o(n.type??``)===`other`&&f(n.rect,r.rect)&&!!x(e,t,T)}function B(e,t,n){let r=e[t];if(r){n.suppressNode(r,[]);for(let r of C(e,t))n.suppressNode(r,[])}}function ht(e){let t=o(e.type??``);return t===`textfield`||t===`securetextfield`||t===`searchfield`||t===`textview`}function V(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function gt(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function _t(e,t){let n=E(e);at(e,n,t),vt(e,n,t)}function vt(e,t,n){for(let r of e){if(o(r.type??``)!==`navigationbar`||!r.rect)continue;let e=t.get(r.index)??[],i=e.flatMap(t=>yt(t,e,r.rect));if(i.length!==1)continue;let{field:a,title:s,image:c,label:l}=i[0];S(n.replacements,a,{type:`Button`,label:l,enabled:!0,hittable:void 0,rect:u([c.rect,a.rect,s.rect])}),n.semanticRepresentativeIndexes.add(a.index),n.suppressNode(s,[a]),n.suppressNode(c,[a])}}function yt(e,t,n){let r=i(e);if(!bt(e,r))return[];let a=H(t,e=>xt(e,r)),o=H(t,St);return a?.rect&&o?.rect&&Ct(o.rect,e.rect,a.rect,n)?[{field:e,title:a,image:o,label:r}]:[]}function bt(e,t){return o(e.type??``)===`textfield`&&e.enabled===!1&&!!e.rect&&!!t&&e.value?.trim()===t}function xt(e,t){return o(e.type??``)===`statictext`&&e.label?.trim()===t&&!!e.rect}function St(e){return o(e.type??``)===`image`&&!!e.identifier?.trim()&&!!e.rect}function H(e,t){let n=e.filter(t);return n.length===1?n[0]:void 0}function Ct(e,t,n,r){let i=t.x-(e.x+e.width),a=n.x-(t.x+t.width);return l(r,e)&&l(r,t)&&l(r,n)&&i>=0&&i<=12&&a>=0&&a<=12&&wt(e,t)&&wt(t,n)}function wt(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=E(e);for(let r of e){if(o(r.type??``)===`element(58)`){S(t.replacements,r,{type:`WebView`});continue}let e=Et(r,t.sourceNodesByIndex,n);if(e?.kind===`suppress`){t.suppressNode(r,[]);continue}e&&(S(t.replacements,r,{type:e.type,...e.type===`Heading`?{value:void 0}:{}}),t.semanticRepresentativeIndexes.add(r.index))}}function Et(e,t,n){if(o(e.type??``)!==`other`)return null;let r=w(e,t,kt),i=e.label?.trim();return!r||!i?null:Ot(e,r,i)?{kind:`suppress`}:Dt(e,i,n)?{kind:`semantic`,type:U(e.value)?`Heading`:`StaticText`}:null}function Dt(e,t,n){let r=n.get(e.index);if(r?.length!==1)return!1;let i=r[0];return o(i.type??``)===`statictext`&&i.label?.trim()===t&&!n.has(i.index)}function Ot(e,t,n){return e.parentIndex===t.index&&t.label?.trim()===n&&!U(e.value)}function kt(e){let t=o(e.type??``);return t===`webview`||t===`element(58)`}function U(e){return/^[1-6]$/.test(e?.trim()??``)}const At=[Tt,_t,ce,Ye,Je];function W(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 At)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=te(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,G(e.index,l,n)]))}}function G(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 G(i,t,n,r))a.add(e);return[...a].sort((e,t)=>e-t)}var K=class extends Error{code=`IOS_SNAPSHOT_ENGINE_FAILED`;reason;details;constructor(e,t,n={}){super(t),this.name=`IosSnapshotEngineError`,this.reason=e,this.details=n}};function jt(e){return{reason:e.reason,...e.details}}function q(e){let t=new Map;for(let[n,r]of e.entries()){if(!Number.isInteger(r.index)||r.index<0||t.has(r.index))throw new K(`malformed-graph`,`iOS snapshot graph contains a duplicate or invalid node index`,{index:r.index});if(t.set(r.index,n),r.depth!==void 0&&(!Number.isInteger(r.depth)||r.depth<0))throw new K(`malformed-graph`,`iOS snapshot graph contains an invalid node depth`,{index:r.index,field:`depth`})}for(let[n,r]of e.entries()){if(r.parentIndex===void 0)continue;let e=t.get(r.parentIndex);if(e===void 0||e>=n)throw new K(`malformed-graph`,`iOS snapshot graph parent must precede its child`,{index:r.index,parentIndex:r.parentIndex})}}const Mt=new Set([`collectionview`,`scrollview`,`table`]),Nt=new Set([`application`,`window`]),Pt=new Set([`UITextEffectsWindow`,`UIRemoteKeyboardWindow`]),Ft=new Map([[`Sheet`,5],[`Drawer`,6],[`Alert`,7],[`Dialog`,8]]);function It(){return{projectedOut:!1}}function Lt(e,t,n,i,a,s){let c=s===`cursor-projected`?t.ancestorClip:void 0,l=Rt(e.rect,n,c),u=r(J(e.rect)),d=r(l),f=o(e.type??``),p=zt(s,t.projectedOut,u,d,f,a),m=Kt(e,Bt(s,t.projectedOut,u,d)&&!Vt(e,u,s),i,s),h=Gt(f,m,d,a),g=Ut(s,t.projectedOut,u,d,e);return{isIncluded:m,descendants:Ht(s,p,c,l,h),effectiveRect:l,...g?{hiddenContentFrame:g}:{},establishesScrollAnchor:h}}function Rt(e,t,n){let r=J(e);if(!r)return;let i=Xt(r,t);return n&&(i=Xt(i,n)),i}function zt(e,t,n,r,i,a){return e===`plain-viewport`?!r:t||n&&!r&&Wt(i,a)}function Bt(e,t,n,r){return e===`plain-viewport`?r:!t&&(!n||r)}function Vt(e,t,n){return n!==`cursor-projected`||e.parentIndex===void 0||qt(e)||!t?!1:Jt(e.rect)<=1||Yt(e.rect)<=1}function Ht(e,t,n,r,i){return{projectedOut:t,...e===`cursor-projected`&&i?{ancestorClip:r}:{ancestorClip:n}}}function Ut(e,t,n,r,i){if(!(e!==`cursor-projected`||t||!n||r))return J(i.rect)}function Wt(e,t){return t&&(e===`cell`||Mt.has(e))}function Gt(e,t,n,r){return t&&n&&r&&Mt.has(e)}function Kt(e,t,n,r){if(e.parentIndex===void 0)return!0;let i=o(e.type??``);return r===`plain-viewport`&&n&&!t&&i!==`application`?!1:Nt.has(i)||t}function qt(e){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.trim().length>0)}function J(e){if(e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&!(e.width<0||e.height<0))return{...e,width:Math.max(0,e.width),height:Math.max(0,e.height)}}function Jt(e){return J(e)?.width??0}function Yt(e){return J(e)?.height??0}function Xt(e,t){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 i<=n||a<=r?{x:e.x,y:e.y,width:0,height:0}:{x:i>n?n:e.x,y:a>r?r:e.y,width:i-n,height:a-r}}function Zt(e){let t=E(e),n=new Set;for(let e of t.values()){let r=Qt(e,t);if(r){for(let i of e.slice(0,-1))if($t(r,i)){n.add(i.index);for(let e of re(i,t))n.add(e.index)}}}return n}function Qt(e,t){let n=e.at(-1);if(!n||!Y(n))return;let i=(t.get(n.index)??[]).find(en);if(!(i?.userInteractionEnabled!==!0||!r(i.rect)))return{container:n,dimmingRect:i.rect}}function $t(e,t){return Y(t)&&r(t.rect)&&l(e.dimmingRect,t.rect)}function Y(e){return tn(e,`UITransitionView`)}function en(e){return tn(e,`UIDimmingView`)}function tn(e,t){return o(e.role??``)===o(t)}function nn(e,t){let n=dn(e),r=fn(e,n);if(e.some((e,t)=>r.has(t)&&rn(e)))return`presented`;if(t!==`complete`||n.length===0||!e.every(e=>e.role!==void 0)||!un(e))return`unknown`;let i=n.filter(t=>!ln(e[t]));return i.length===1&&mn(e[i[0]],e).length===1?`absent`:`unknown`}function rn(e){return en(e)||an(e)||on(e)}function an(e){let t=e.role;return t!==void 0&&o(t).startsWith(o(`_UIAlertController`))}function on(e){let t=e.type;if(!t)return!1;if(Ft.has(t))return!0;let n=sn.exec(t);return n!==null&&cn.has(Number(n[1]))}const sn=/^Element\((\d+)\)$/,cn=new Set(Ft.values());function ln(e){let t=e.role;if(t===void 0)return!1;let n=o(t);for(let e of Pt)if(o(e)===n)return!0;return!1}function un(e){return new Set(e.map(e=>e.index)).size===e.length}function dn(e){let t=[];for(let[n,r]of e.entries())r.parentIndex===void 0&&t.push(n);if(t.length!==1)return[];let n=e[t[0]].index,r=[];for(let[t,i]of e.entries())i.parentIndex===n&&r.push(t);return r}function fn(e,t){let n=new Map;for(let[t,r]of e.entries()){if(typeof r.parentIndex!=`number`)continue;let e=n.get(r.parentIndex)??[];e.push(t),n.set(r.parentIndex,e)}let r=new Set(e.map((e,t)=>t));for(let i of t)if(ln(e[i]))for(let t of pn(i,e,n))r.delete(t);return r}function pn(e,t,n){let r=[e],i=new Set([e]);for(let e=0;e<r.length;e+=1)for(let a of n.get(t[r[e]].index)??[])i.has(a)||(i.add(a),r.push(a));return r}function mn(e,t){return t.filter(t=>t.parentIndex===e.index&&Y(t))}function hn(e,t,n,r,i={}){q(e);let a=Zt(e),o=e.filter(e=>!a.has(e.index)),s=gn(o),c=new Map,l=[],u=new Map,d=0;for(let e of o){let a=_n(e,c,()=>{d+=1}),o=a?.traversal??It(),f=r===`cursor-projected`?a?.anchor:void 0,p=Lt(e,o,t,n,s.has(e.index),r);vn(p,f,u);let m=yn(e,p,a,l,t,i),h=xn(p,f,m.keptIndex);c.set(e.index,{traversal:p.descendants,anchor:h,keptIndex:m.keptIndex,keptDepth:m.keptDepth})}let f=Cn(u,l);return{nodes:f,stats:{presentedNodeCount:f.length,sourceNodeCount:e.length,parentClipLookups:d,modalContainedNodeCount:a.size}}}function gn(e){let t=new Set;for(let n of e)n.parentIndex!==void 0&&t.add(n.parentIndex);return t}function _n(e,t,n){if(e.parentIndex!==void 0)return n(),t.get(e.parentIndex)}function vn(e,t,n){e.hiddenContentFrame&&t&&Sn(e.hiddenContentFrame,t,n)}function yn(e,t,n,r,i,a){let o=n?.keptIndex,s=n?.keptDepth??-1;if(!t.isIncluded)return{keptIndex:o,keptDepth:s};let c=r.length;s+=1;let{hittable:l,...u}=e;return r.push({raw:{...u,index:c,depth:s,parentIndex:o,...bn(l,e.parentIndex!==void 0,t.effectiveRect,e.enabled!==!1,i,a)},sourceIndex:e.index,...t.effectiveRect?{effectiveRect:t.effectiveRect}:{}}),o=c,{keptIndex:o,keptDepth:s}}function bn(e,t,n,r,i,o){return o.hittabilityAvailable===!1?e===!1||!r?{hittable:!1}:{}:{hittable:t&&e===!0&&a(r,n,i)}}function xn(e,t,n){return e.establishesScrollAnchor&&n!==void 0&&e.effectiveRect?{index:n,rect:e.effectiveRect}:t}function Sn(e,t,n){let r=n.get(t.index)??{above:!1,below:!1};e.y+e.height<=t.rect.y?r.above=!0:e.y>=t.rect.y+t.rect.height&&(r.below=!0),n.set(t.index,r)}function Cn(e,t){return t.map(t=>{let n=e.get(t.raw.index);if(!n)return t;let r=t.raw;return{...t,raw:{...r,hiddenContentAbove:r.hiddenContentAbove===!0||n.above?!0:void 0,hiddenContentBelow:r.hiddenContentBelow===!0||n.below?!0:void 0}}})}const wn=new Set([`collectionview`,`scrollview`,`table`]);function Tn(e){return En(e.viewport)}function En(e){if(e.kind===`missing`)throw new K(e.reason===`invalid`?`invalid-viewport`:`missing-viewport`,`regular iOS snapshot presentation requires a valid viewport`,{field:`viewport`});if(!r(e.rect))throw new K(`invalid-viewport`,`regular iOS snapshot presentation requires a positive finite viewport`,{field:`viewport`});return e.rect}function Dn(e,t,n,i=!0){q(e);let a=new Map,o=0;for(let s of e){let e=On(s,a,t,()=>{o+=1}),c=Pn(s.rect);if(kn(s,i),!c||!r(c)){An(s,c),a.set(s.index,e);continue}jn(s,c,e),Mn(s,c,t),a.set(s.index,Nn(s,c,e,n))}return{parentClipLookups:o}}function On(e,t,n,r){if(e.parentIndex===void 0)return n;r();let i=t.get(e.parentIndex);if(!i)throw new K(`invalid-presented-payload`,`regular iOS snapshot payload refers to a parent outside the payload`,{index:e.index,parentIndex:e.parentIndex});return i}function kn(e,t){if(!(e.hittable!==!0||t))throw new K(`invalid-presented-payload`,`iOS snapshot payload marked a node actionable without hittability evidence`,{index:e.index})}function An(e,t){if(e.hittable===!0)throw new K(`regular-degenerate-actionable-node`,`regular iOS snapshot node with a missing or degenerate frame is actionable`,{index:e.index,frame:t??e.rect})}function jn(e,t,n){if(!Fn(t,n))throw new K(`regular-node-outside-cumulative-clip`,`regular iOS snapshot node escaped its cumulative clip`,{index:e.index,frame:t,clip:n})}function Mn(e,t,n){if(!(e.hittable!==!0||e.enabled!==!1&&s(n,t.x+t.width/2,t.y+t.height/2)))throw new K(`invalid-presented-payload`,`regular iOS snapshot payload marked a disabled or off-viewport node actionable`,{index:e.index,frame:t})}function Nn(e,t,n,r){return r===`cursor-projected`&&wn.has(o(e.type??``))?t:n}function X(e,t,n,r,i=!0){if(t===`raw`)return q(e),{parentClipLookups:0};if(!n)throw new K(`missing-viewport`,`regular iOS snapshot payload cannot be validated without a viewport`,{field:`viewport`});try{return Dn(e,n,r,i)}catch(e){throw e instanceof K&&e.code===`IOS_SNAPSHOT_ENGINE_FAILED`&&e.reason===`malformed-graph`?new K(`invalid-presented-payload`,e.message,e.details):e}}function Pn(e){if(!(!e||![e.x,e.y,e.width,e.height].every(Number.isFinite))&&!(e.width<0||e.height<0))return{...e,width:Math.max(0,e.width),height:Math.max(0,e.height)}}function Fn(e,t){let n=1e-4;return l({x:t.x-n,y:t.y-n,width:t.width+n*2,height:t.height+n*2},e)}const In=new Set([`button`,`cell`,`checkbox`,`collectionview`,`keyboard`,`link`,`menuitem`,`picker`,`searchfield`,`securetextfield`,`segmentedcontrol`,`slider`,`scrollview`,`stepper`,`switch`,`tabbar`,`table`,`textfield`,`textview`,`webview`]);function Ln(e){let t=Yn(e.nodes),n=zn(e,t);return e.projection===`raw`?Bn(n,e.depth,t):Vn(n,e.depth)}function Z(e){let t=Yn(e.nodes);return e.projection===`raw`?Bn(e.nodes,e.depth,t):Vn(e.nodes,e.depth)}function Rn(e){return e.parentIndex===void 0||In.has(o(e.type??``))||Xn(e)}function zn(e,t){let n=e.scope?.trim().toLowerCase();if(!n)return[...e.nodes];for(let r=0;r<e.nodes.length;r+=1){let i=e.nodes[r];if(!i||!qn(i.raw,n))continue;let a=Jn(e.nodes,r,t);if(!(e.projection===`raw`||a.some(t=>Rn(e.nodes[t].raw))))continue;let o=a.map(t=>e.nodes[t]);return Kn(e.projection===`raw`&&e.depth!==null?o.filter(n=>Q(n,t)-Q(i,t)<=e.depth):o,Q(i,t),t)}return[]}function Bn(e,t,n){let r=t===null?[...e]:e.filter(e=>Q(e,n)<=t);return{nodes:r.map(e=>({...e.raw,rect:e.raw.rect})),sourceIndexes:r.map(e=>e.sourceIndex)}}function Vn(e,t){let n=[],r=[],i=new Map;for(let a of e){let e=Hn(a,i),o=Un(a,e,t,n.length);if(!o){Gn(a,e,i);continue}n.push(o),r.push(a.sourceIndex),i.set(a.raw.index,o)}return{nodes:n,sourceIndexes:r}}function Hn(e,t){return e.raw.parentIndex===void 0?void 0:t.get(e.raw.parentIndex)}function Un(e,t,n,r){if(!Rn(e.raw))return;let i=t?(t.depth??0)+1:0;if(n!==null&&i>n)return;let a=Wn(e);return{...e.raw,index:r,depth:i,parentIndex:t?.index,...e.effectiveRect?{rect:e.effectiveRect}:{rect:void 0},...a===void 0?{}:{hittable:a}}}function Wn(e){if(e.raw.hittable!==void 0)return!!(e.raw.hittable===!0&&e.effectiveRect&&e.effectiveRect.width>0&&e.effectiveRect.height>0)}function Gn(e,t,n){t&&n.set(e.raw.index,t)}function Kn(e,t,n){let r=new Map(e.map((e,t)=>[e.raw.index,t]));return e.map((e,i)=>({...e,raw:{...e.raw,index:i,depth:Math.max(0,Q(e,n)-t),parentIndex:e.raw.parentIndex===void 0?void 0:r.get(e.raw.parentIndex)}}))}function qn(e,t){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.toLowerCase().includes(t))}function Jn(e,t,n){let r=Q(e[t],n),i=[];for(let a=t;a<e.length&&!(a>t&&Q(e[a],n)<=r);a+=1)i.push(a);return i}function Q(e,t){return Math.max(0,e.raw.depth??t?.get(e.raw.index)??0)}function Yn(e){let t=new Map;for(let n of e){let e=(n.raw.parentIndex===void 0?-1:t.get(n.raw.parentIndex)??-1)+1;t.set(n.raw.index,n.raw.depth===void 0?e:Math.max(0,n.raw.depth))}return t}function Xn(e){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.trim().length>0)}function Zn(e,t,n=`cursor-projected`){Qn(e,t);let r=e.validation.presentationKey.projection,i=r===`regular`?En(e.validation.viewport):void 0,a=e.validation.hittability.kind===`available`,o=$n(e,r,i,n,a),s=er(e.presentation.payload.nodes,r,t),c=tr(s.nodes,r,i,n,a,o);return{nodes:s.nodes,...i?{validatedViewport:i}:{},...e.presentation.qualityPayload?{qualityNodes:[...e.presentation.qualityPayload.nodes]}:{},presentedIndexesBySourceIndex:s.presentedIndexesBySourceIndex,stats:{presentedNodeCount:s.nodes.length,sourceNodeCount:e.presentation.payload.nodes.length,parentClipLookups:c.parentClipLookups,modalContainedNodeCount:0}}}function Qn(e,t){if(!nr(m(t),e.validation.presentationKey))throw new K(`projection-mismatch`,`presented iOS snapshot does not match the requested presentation key`,{projection:e.validation.presentationKey.projection});if(e.presentation.intent!==t.acquisitionIntent)throw new K(`projection-mismatch`,`presented iOS snapshot does not match the requested acquisition intent`,{field:`acquisitionIntent`})}function $n(e,t,n,r,i){let a=X(e.presentation.payload.nodes,t,n,r,i);if(e.presentation.qualityPayload)try{X(e.presentation.qualityPayload.nodes,t,n,r,i)}catch(e){throw e instanceof K?new K(`invalid-quality-payload`,e.message,e.details):e}return a}function er(e,t,n){return t===`regular`&&n.interactiveOnly?W([...e]):{nodes:[...e],presentedIndexesBySourceIndex:rr(e)}}function tr(e,t,n,r,i,a){return t!==`regular`||!n?a:X(e,t,n,r,i)}function nr(e,t){return e.projection===t.projection&&e.interactiveOnly===t.interactiveOnly&&e.depth===t.depth&&e.scope===t.scope&&e.customActions===t.customActions}function rr(e){return new Map(e.map(e=>[e.index,[e.index]]))}function ir(t,n,r={}){let i=or(t,n,r),a=t.stage===`presented`?t.validation.presentationKey:m(n),o=t.stage===`acquired`?t.acquisition.truncated:t.presentation.payload.truncated;return{payload:{nodes:e(i.nodes),...o===void 0?{}:{truncated:o}},presentationKey:a,comparisonIdentity:h(t,n),residue:t.stage===`acquired`?[...t.acquisition.residue]:[...t.validation.residue],...i.validatedViewport?{validatedViewport:i.validatedViewport}:{},...t.stage===`acquired`?{presentedSurface:nn(t.acquisition.nodes,ar(t.acquisition))}:{}}}function ar(e){return e.truncated===void 0?`unstated`:e.truncated?`capped`:`complete`}function or(e,t,n={}){let r=n.foldPolicy??`cursor-projected`;return e.stage===`acquired`?sr(e.acquisition,t,r):Zn(e,t,r)}function sr(e,t,n){if(lr(e,p(t)),t.projection===`raw`){q(e.nodes);let r=e.nodes.map(e=>({raw:e,sourceIndex:e.index})),i=Ln({nodes:r,projection:`raw`,scope:t.scope,depth:t.depth,foldPolicy:n}),a=t.scope===null?void 0:Z({nodes:r,projection:`raw`,depth:null,foldPolicy:n}).nodes;return{nodes:i.nodes,...a?{qualityNodes:a}:{},presentedIndexesBySourceIndex:$(e.nodes,i.nodes,i.sourceIndexes,ur(i.nodes)),stats:{presentedNodeCount:i.nodes.length,sourceNodeCount:e.nodes.length,parentClipLookups:0,modalContainedNodeCount:0}}}let r=Tn(e),i=!cr(e.residue),a=hn(e.nodes,r,t.interactiveOnly,n,{hittabilityAvailable:i}),o=Ln({nodes:a.nodes,projection:`regular`,scope:t.scope,depth:t.depth,foldPolicy:n}),s=t.interactiveOnly?W(o.nodes):{nodes:o.nodes,presentedIndexesBySourceIndex:ur(o.nodes)},c=X(s.nodes,`regular`,r,n,i),l=t.scope===null?void 0:Z({nodes:a.nodes,projection:`regular`,depth:null,foldPolicy:n}).nodes;return{nodes:s.nodes,validatedViewport:r,...l?{qualityNodes:l}:{},presentedIndexesBySourceIndex:$(e.nodes,o.nodes,o.sourceIndexes,s.presentedIndexesBySourceIndex),stats:{presentedNodeCount:s.nodes.length,sourceNodeCount:e.nodes.length,parentClipLookups:a.stats.parentClipLookups+c.parentClipLookups,modalContainedNodeCount:a.stats.modalContainedNodeCount}}}function cr(e){return e.some(e=>e.kind===`unavailable-fact`&&e.fact===`hittability`)}function lr(e,t){let n=e.hint;if(n.projection!==t.projection||n.rawTraversalDepth!==t.rawTraversalDepth||n.regularPresentedDepth!==t.regularPresentedDepth||n.interactiveOnly!==t.interactiveOnly||n.customActions!==t.customActions||n.acquisitionIntent!==t.acquisitionIntent)throw new K(`projection-mismatch`,`acquired iOS snapshot does not match the requested capture hint`,{projection:n.projection})}function ur(e){return new Map(e.map(e=>[e.index,[e.index]]))}function $(e,t,n,r){let i=new Map(t.map((e,t)=>[e.index,n[t]])),a=new Map(e.map(e=>[e.index,[]]));for(let[e,t]of r){let n=i.get(e);n!==void 0&&a.set(n,t)}return a}export{W as a,jt as i,Zn as n,K as r,ir as t};
|
|
1
|
+
import{y as e}from"./sdk-contracts.js";import{X as t,Y as n}from"./tv-remote.js";import{Br as r,Wr as i,ei as a,li as o,ni as s,oi as c,ri as l,si as u,ti as d}from"./sdk-batch.js";import{n as f}from"./rect-center.js";import{i as p,n as m,t as h}from"./ios-snapshot-planning.js";import{_ as g,a as _,c as v,d as ee,f as y,g as te,h as ne,i as b,l as re,m as x,n as S,o as ie,p as C,r as w,t as T,u as ae}from"./tree.js";import{a as E,i as oe,o as se,r as ce}from"./react-native-overlay.js";function le(e,t){let n=_(t.sourceNodesByIndex.values());for(let r of e)ue(r,t.sourceNodesByIndex,n)&&x(t.replacements,r,{type:`Cell`})}function ue(e,t,n){return!(i(e.type??``)!==`other`||e.enabled===!1||!e.rect||!pe(e.label)||!ie(e,t,fe)||!de(e)||ae(e.rect,n))}function de(e){return e.rect?e.rect.height>=44&&e.rect.height<=160&&e.rect.width>=120:!1}function fe(e){let t=i(e.type??``);return t===`scrollview`||t===`scrollarea`}function pe(e){let t=e?.trim();return!(!t||/^(toolbar|window|application)$/i.test(t)||t.startsWith(`!,`)||/debugger|fast refresh/i.test(t))}function me(e,t){let n=new Set;for(let r of e)he(t.replacements.get(r.index)??r)&&ge(r,t.sourceNodesByIndex,t,n);ye(e,t,n)}function he(e){let n=e.label?.trim();return!!(n&&t(n))}function ge(e,t,r,i){let a=!y(e.type)||r.isSuppressed(e),o=n(e.label?.trim()??``,e.value),s=o?ve(e,t):void 0;a&&r.suppressNode(e,s?[s]:[]),s&&o&&De(r,s,e,o)&&i.add(s.index)}function D(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function _e(e,t){return e.rect!=null&&t.rect!=null&&O(e.rect,t.rect)}function ve(e,t){if(y(e.type))return null;let n=D(e,t);for(;n&&!y(n.type);){let e=D(n,t);if(!e||!_e(n,e))return null;n=e}return n??null}function ye(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=Ee(o.rect,a),c=be(o,a,s),l=xe(e,c,o);Se(t,i,o,a,s,c,l),r.set(i.index,Ce(i,o,a,s,l,n))}}function be(e,t,n){return!!(t&&s(e.rect)&&!s(n))}function xe(e,t,n){return!!(e?.projectedOut||t&&Te(n))}function Se(e,t,n,r,i,a,o){o||a?e.suppressNode(t,[]):r&&i&&!O(n.rect,i)&&x(e.replacements,t,{rect:i})}function Ce(e,t,n,r,i,a){return{projectedOut:i,...we(e,t,n,r,a)?{clip:r}:n?{clip:n}:{}}}function we(e,t,n,r,i){return!!(s(r)&&(i.has(e.index)||n!==void 0&&y(t.type)))}function Te(e){return e.type?.trim().toLowerCase()===`cell`||y(e.type)}function Ee(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 O(e,t){return!!(e&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height)}function De(e,t,n,r){let i=Oe((e.replacements.get(t.index)??t).rect,n.rect);return g(e.replacements,t,e=>({rect:i??e.rect,hiddenContentAbove:k(e.hiddenContentAbove,r.above),hiddenContentBelow:k(e.hiddenContentBelow,r.below)})),!!i}function k(e,t){return e===!0||t?!0:void 0}function Oe(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 A(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],a=r?.label?.trim();r&&a&&i(r.type??``)===`other`&&t(r,a,n)}}function ke(e,t){A(e,(n,r,i)=>{if(!E(r)||!n.rect)return;let a=b(e,i,e=>!!e.rect&&se(e.label?.trim()??``));if(!a?.rect)return;let o=je(n.rect,a.rect);if(!o)return;let s=Ae(e,i,o);x(t,n,{rect:s}),v(e,i,e=>{E(e.label?.trim()??``)&&x(t,e,{rect:s})})})}function Ae(e,t,n){let r=n;return v(e,t,e=>{let t=e.label?.trim()??``;!e.rect||!E(t)||u(n,e.rect)&&c(e.rect)<c(r)&&(r=e.rect)}),r}function je(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&&f(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&&f(t,a))return{...e,x:r,width:n-r}}function Me(e,t){A(e,(n,r,i)=>{ce(n)&&oe(n,Ne(e,i))&&t.suppressNode(n,Ne(e,i))})}function Ne(e,t){let n=[];return v(e,t,e=>{n.push(e)}),n}function Pe(e,t){let n=_(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||!Fe(i,r)||(t.suppressNode(i,[]),Ie(i,t,r),v(e,n,e=>{t.suppressNode(e,[])}))}}function Fe(e,t){return!e.rect||i(e.type??``)!==`keyboard`?!1:e.rect.y>=t}function Ie(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 Le(e,t){for(let n=0;n<e.length;n+=1){let r=e[n];if(!r)continue;if(Re(r)){Be(e,n,r,t);continue}if(!ze(r))continue;let a=b(e,n,e=>i(e.type??``)===`searchfield`&&e.label===`Search`);a&&(t.suppressNode(r,[a]),Ve(r,a,t),Be(e,n,a,t))}}function Re(e){return i(e.type??``)===`searchfield`&&e.label===`Search`}function ze(e){let t=i(e.type??``);return e.label===`Toolbar`&&(t===`toolbar`||t===`searchfield`)}function Be(e,t,n,r){v(e,t,e=>{e.index!==n.index&&He(e)&&r.suppressNode(e,[n])})}function Ve(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 He(e){let t=i(e.type??``);return t===`button`?!1:t===`image`||e.label===`Search`}function Ue(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,n,r,a){let o=i(n.type??``);if(o===`statictext`||o===`link`){Ke(e,t,r,n,a);return}if(o!==`other`)return;let s=Ge(e,t,r);if(s){a.suppressNode(n,[s]);return}Ke(e,t,r,n,a)}function Ge(e,t,n){return b(e,t,e=>{let t=i(e.type??``);return(t===`link`||t===`searchfield`||y(e.type))&&e.label?.trim()===n})}function Ke(e,t,n,r,i){v(e,t,e=>{!i.semanticRepresentativeIndexes.has(e.index)&&ee(e,n)&&i.suppressNode(e,[r])})}function qe(e,t){A(e,(n,r,i)=>{let a=b(e,i,e=>C(e)&&e.label?.trim()===r&&(f(e.rect,n.rect)||Je(n,e)));a&&t.suppressNode(n,[a])})}function Je(e,t){if(t.label?.trim()!==e.label?.trim())return!1;let n=i(t.type??``);return Ye(e,n)||n===`textfield`||Xe(e,n,t)}function Ye(e,t){let n=e.label?.trim();return t===`button`&&(n===`Dismiss`||n===`Back`)}function Xe(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 Ze(e,t){let n=T(e);for(let r of e){if(i(r.type??``)!==`other`||r.hittable===!0||r.label?.trim()||r.value?.trim()||!r.identifier?.trim())continue;let e=w(r,n);(e.length!==0||r.hittable===!1)&&t.suppressNode(r,e)}}function Qe(e,t){Pe(e,t),Ze(e,t),me(e,t),Le(e,t),qe(e,t),ke(e,t.replacements),Me(e,t),Ue(e,t)}function $e(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?et(e,n,r,t):void 0;!r?.rect||!i||rt(e,n,r,i,t)}}function et(e,n,r,a){let o=r.label?.trim();if(i(r.type??``)!==`cell`||o&&!tt(o,r.identifier)&&!t(o))return o;let s=S(e,n).find(nt),c=s?.label?.trim();return!s||!c?o:(x(a.replacements,r,{label:c}),a.suppressNode(s,[r]),c)}function tt(e,t){return t?.trim()===e&&/^[A-Z_$][A-Za-z0-9_$]*Cell$/.test(e)}function nt(e){if(!e.label?.trim())return!1;let t=i(e.type??``);return t===`statictext`||t===`text`||t===`textview`}function rt(e,t,n,r,a){let o=i(n.type??``);if(o===`button`){j(S(e,t),r,a,n);return}if(o!==`cell`)return;let s=S(e,t);it(s,n,r,a)||at(s,n,r,a)}function it(e,t,n,r){let i=e.find(e=>st(e,t,n));if(!i)return!1;let a=e.find(e=>M(e,t,n)),o=i.identifier?void 0:a?.identifier??t.identifier;return o&&x(r.replacements,i,{identifier:o}),r.suppressNode(t,[i]),ot(e,t,n,i,r),!0}function at(e,t,n,r){let i=e.find(e=>M(e,t,n));if(!i){e.some(re)&&j(e,n,r,t);return}!t.identifier&&i.identifier&&x(r.replacements,t,{identifier:i.identifier}),r.suppressNode(i,[t]),j(e.filter(e=>e.index!==i.index),n,r,t)}function ot(e,t,n,r,i){for(let a of e)a.index!==r.index&&(M(a,t,n)||N(a,t)||ct(a,r)||te(a,n))&&i.suppressNode(a,[r])}function j(e,t,n,r){for(let i of e)(te(i,t)||r&&N(i,r))&&n.suppressNode(i,r?[r]:[])}function M(e,t,n){if(i(e.type??``)!==`button`)return!1;let r=t.identifier?.trim(),a=e.identifier?.trim();return r&&a&&r===a?!0:e.label?.trim()===n&&f(e.rect,t.rect)}function N(e,t){return i(e.type??``)===`button`&&!e.label?.trim()&&!e.value?.trim()&&f(e.rect,t.rect)}function st(e,t,n){if(i(e.type??``)!==`switch`)return!1;let r=t.identifier?.trim(),a=e.identifier?.trim();return r&&a&&r===a?!0:e.label?.trim()===n}function ct(e,t){if(i(e.type??``)!==`switch`||e.index===t.index)return!1;let n=e.label?.trim();return n===t.value?.trim()||n===`0`||n===`1`}const P=1.15;function lt(e,t,n){let r=new Map(e.map((e,t)=>[e.index,t]));for(let[i,a]of e.entries()){let o=ut(e,r,t,a,n);if(!o)continue;I(e,i,n);let s=L(o.shelfRect,2);for(let t of o.intermediateSiblings){if(yt(t)||!t.rect||!l(t.rect,s))continue;let i=r.get(t.index);i!==void 0&&I(e,i,n)}}}function ut(e,t,n,r,i){let a=dt(r,n,i.sourceNodesByIndex);if(!a)return;let o=mt(e,t,a.siblings,a.position,a.parent);if(!(o<0))return{shelfRect:a.rect,intermediateSiblings:a.siblings.slice(a.position+1,o)}}function dt(e,t,n){let r=ht(e,F(t,e.index));if(!r)return;let i=pt(e,n);if(!i||!i.rect)return;let a=F(t,i.index),o=a.findIndex(t=>t.index===e.index);if(ft(a,o,e,r))return{rect:r.rect,parent:i,siblings:a,position:o}}function F(e,t){return e.get(t)??[]}function ft(e,t,n,r){if(t<1)return!1;let i=gt(e,t,n);return i?!r.childActionsPresented||!_t(i,r.actionButtons):!1}function pt(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function mt(e,t,n,r,i){return n.findIndex((n,a)=>a>r&&vt(e,t.get(n.index),n,i))}function ht(e,t){if(!y(e.type)||!e.rect)return;let n=e.rect,r=t.filter(e=>i(e.type??``)===`button`&&e.rect);if(r.length===0&&e.hiddenContentBelow===!0)return{rect:n,childActionsPresented:!1,actionButtons:r};if(r.length<3)return;let a=r.map(e=>e.rect.x+e.rect.width/2);if(a.every((e,t)=>t===0||e>a[t-1]))return{rect:n,childActionsPresented:r.some(e=>u(n,e.rect)),actionButtons:r}}function gt(e,t,n){if(!(!n.rect||t<1))for(let r=t-1;r>=0;--r){let t=e[r];if(!(!t.rect||!C(t))&&t.rect.x+t.rect.width/2<n.rect.x&&bt(t.rect,L(n.rect,2)))return t}}function _t(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*P||e.rect.height>r*P}function vt(e,t,n,r){return t!==void 0&&i(n.type??``)===`other`&&f(n.rect,r.rect)&&!!b(e,t,C)}function I(e,t,n){let r=e[t];if(r){n.suppressNode(r,[]);for(let r of S(e,t))n.suppressNode(r,[])}}function yt(e){let t=i(e.type??``);return t===`textfield`||t===`securetextfield`||t===`searchfield`||t===`textview`}function L(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function bt(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function xt(e,t){let n=T(e);lt(e,n,t),St(e,n,t)}function St(e,t,n){for(let r of e){if(i(r.type??``)!==`navigationbar`||!r.rect)continue;let e=t.get(r.index)??[],a=e.flatMap(t=>Ct(t,e,r.rect));if(a.length!==1)continue;let{field:s,title:c,image:l,label:u}=a[0];x(n.replacements,s,{type:`Button`,label:u,enabled:!0,hittable:void 0,rect:o([l.rect,s.rect,c.rect])}),n.semanticRepresentativeIndexes.add(s.index),n.suppressNode(c,[s]),n.suppressNode(l,[s])}}function Ct(e,t,n){let i=r(e);if(!wt(e,i))return[];let a=R(t,e=>Tt(e,i)),o=R(t,Et);return a?.rect&&o?.rect&&Dt(o.rect,e.rect,a.rect,n)?[{field:e,title:a,image:o,label:i}]:[]}function wt(e,t){return i(e.type??``)===`textfield`&&e.enabled===!1&&!!e.rect&&!!t&&e.value?.trim()===t}function Tt(e,t){return i(e.type??``)===`statictext`&&e.label?.trim()===t&&!!e.rect}function Et(e){return i(e.type??``)===`image`&&!!e.identifier?.trim()&&!!e.rect}function R(e,t){let n=e.filter(t);return n.length===1?n[0]:void 0}function Dt(e,t,n,r){let i=t.x-(e.x+e.width),a=n.x-(t.x+t.width);return u(r,e)&&u(r,t)&&u(r,n)&&i>=0&&i<=12&&a>=0&&a<=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 Ot(e,t){let n=T(e);for(let r of e){if(i(r.type??``)===`element(58)`){x(t.replacements,r,{type:`WebView`});continue}let e=kt(r,t.sourceNodesByIndex,n);if(e?.kind===`suppress`){t.suppressNode(r,[]);continue}e&&(x(t.replacements,r,{type:e.type,...e.type===`Heading`?{value:void 0}:{}}),t.semanticRepresentativeIndexes.add(r.index))}}function kt(e,t,n){if(i(e.type??``)!==`other`)return null;let r=ie(e,t,Mt),a=e.label?.trim();return!r||!a?null:jt(e,r,a)?{kind:`suppress`}:At(e,a,n)?{kind:`semantic`,type:B(e.value)?`Heading`:`StaticText`}:null}function At(e,t,n){let r=n.get(e.index);if(r?.length!==1)return!1;let a=r[0];return i(a.type??``)===`statictext`&&a.label?.trim()===t&&!n.has(a.index)}function jt(e,t,n){return e.parentIndex===t.index&&t.label?.trim()===n&&!B(e.value)}function Mt(e){let t=i(e.type??``);return t===`webview`||t===`element(58)`}function B(e){return/^[1-6]$/.test(e?.trim()??``)}const Nt=[Ot,xt,le,$e,Qe];function V(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 Nt)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=ne(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,H(e.index,l,n)]))}}function H(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 H(i,t,n,r))a.add(e);return[...a].sort((e,t)=>e-t)}var U=class extends Error{code=`IOS_SNAPSHOT_ENGINE_FAILED`;reason;details;constructor(e,t,n={}){super(t),this.name=`IosSnapshotEngineError`,this.reason=e,this.details=n}};function Pt(e){return{reason:e.reason,...e.details}}function W(e){let t=new Map;for(let[n,r]of e.entries()){if(!Number.isInteger(r.index)||r.index<0||t.has(r.index))throw new U(`malformed-graph`,`iOS snapshot graph contains a duplicate or invalid node index`,{index:r.index});if(t.set(r.index,n),r.depth!==void 0&&(!Number.isInteger(r.depth)||r.depth<0))throw new U(`malformed-graph`,`iOS snapshot graph contains an invalid node depth`,{index:r.index,field:`depth`})}for(let[n,r]of e.entries()){if(r.parentIndex===void 0)continue;let e=t.get(r.parentIndex);if(e===void 0||e>=n)throw new U(`malformed-graph`,`iOS snapshot graph parent must precede its child`,{index:r.index,parentIndex:r.parentIndex})}}const G=new Set([`collectionview`,`scrollview`,`table`]),Ft=new Set([`application`,`window`]),It=new Set([`UITextEffectsWindow`,`UIRemoteKeyboardWindow`]),K=new Map([[`Sheet`,5],[`Drawer`,6],[`Alert`,7],[`Dialog`,8]]);function Lt(){return{projectedOut:!1}}function Rt(e,t,n,r,a,o){let c=o===`cursor-projected`?t.ancestorClip:void 0,l=zt(e.rect,n,c),u=s(q(e.rect)),d=s(l),f=i(e.type??``),p=Bt(o,t.projectedOut,u,d,f,a),m=qt(e,Vt(o,t.projectedOut,u,d)&&!Ht(e,u,o),r,o),h=Kt(f,m,d,a),g=Wt(o,t.projectedOut,u,d,e);return{isIncluded:m,descendants:Ut(o,p,c,l,h),effectiveRect:l,...g?{hiddenContentFrame:g}:{},establishesScrollAnchor:h}}function zt(e,t,n){let r=q(e);if(!r)return;let i=J(r,t);return n&&(i=J(i,n)),i}function Bt(e,t,n,r,i,a){return e===`plain-viewport`?!r:t||n&&!r&&Gt(i,a)}function Vt(e,t,n,r){return e===`plain-viewport`?r:!t&&(!n||r)}function Ht(e,t,n){return n!==`cursor-projected`||e.parentIndex===void 0||Jt(e)||!t?!1:Yt(e.rect)<=1||Xt(e.rect)<=1}function Ut(e,t,n,r,i){return{projectedOut:t,...e===`cursor-projected`&&i?{ancestorClip:r}:{ancestorClip:n}}}function Wt(e,t,n,r,i){if(!(e!==`cursor-projected`||t||!n||r))return q(i.rect)}function Gt(e,t){return t&&(e===`cell`||G.has(e))}function Kt(e,t,n,r){return t&&n&&r&&G.has(e)}function qt(e,t,n,r){if(e.parentIndex===void 0)return!0;let a=i(e.type??``);return r===`plain-viewport`&&n&&!t&&a!==`application`?!1:Ft.has(a)||t}function Jt(e){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.trim().length>0)}function q(e){if(e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&!(e.width<0||e.height<0))return{...e,width:Math.max(0,e.width),height:Math.max(0,e.height)}}function Yt(e){return q(e)?.width??0}function Xt(e){return q(e)?.height??0}function J(e,t){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 i<=n||a<=r?{x:e.x,y:e.y,width:0,height:0}:{x:i>n?n:e.x,y:a>r?r:e.y,width:i-n,height:a-r}}function Zt(e){let t=T(e),n=new Set;for(let e of t.values()){let r=Qt(e,t);if(r){for(let i of e.slice(0,-1))if($t(r,i)){n.add(i.index);for(let e of w(i,t))n.add(e.index)}}}return n}function Qt(e,t){let n=e.at(-1);if(!n||!Y(n))return;let r=(t.get(n.index)??[]).find(X);if(!(r?.userInteractionEnabled!==!0||!s(r.rect)))return{container:n,dimmingRect:r.rect}}function $t(e,t){return Y(t)&&s(t.rect)&&u(e.dimmingRect,t.rect)}function Y(e){return en(e,`UITransitionView`)}function X(e){return en(e,`UIDimmingView`)}function en(e,t){return i(e.role??``)===i(t)}function tn(e,t){let n=un(e),r=dn(e,n);if(e.some((e,t)=>r.has(t)&&nn(e)))return`presented`;if(t!==`complete`||n.length===0||!e.every(e=>e.role!==void 0)||!ln(e))return`unknown`;let i=n.filter(t=>!cn(e[t]));return i.length===1&&pn(e[i[0]],e).length===1?`absent`:`unknown`}function nn(e){return X(e)||rn(e)||an(e)}function rn(e){let t=e.role;return t!==void 0&&i(t).startsWith(i(`_UIAlertController`))}function an(e){let t=e.type;if(!t)return!1;if(K.has(t))return!0;let n=on.exec(t);return n!==null&&sn.has(Number(n[1]))}const on=/^Element\((\d+)\)$/,sn=new Set(K.values());function cn(e){let t=e.role;if(t===void 0)return!1;let n=i(t);for(let e of It)if(i(e)===n)return!0;return!1}function ln(e){return new Set(e.map(e=>e.index)).size===e.length}function un(e){let t=[];for(let[n,r]of e.entries())r.parentIndex===void 0&&t.push(n);if(t.length!==1)return[];let n=e[t[0]].index,r=[];for(let[t,i]of e.entries())i.parentIndex===n&&r.push(t);return r}function dn(e,t){let n=new Map;for(let[t,r]of e.entries()){if(typeof r.parentIndex!=`number`)continue;let e=n.get(r.parentIndex)??[];e.push(t),n.set(r.parentIndex,e)}let r=new Set(e.map((e,t)=>t));for(let i of t)if(cn(e[i]))for(let t of fn(i,e,n))r.delete(t);return r}function fn(e,t,n){let r=[e],i=new Set([e]);for(let e=0;e<r.length;e+=1)for(let a of n.get(t[r[e]].index)??[])i.has(a)||(i.add(a),r.push(a));return r}function pn(e,t){return t.filter(t=>t.parentIndex===e.index&&Y(t))}function mn(e,t,n,r,i={}){W(e);let a=Zt(e),o=e.filter(e=>!a.has(e.index)),c=hn(o),l=new Map,u=[],d=new Map,f=0,p=0,m=0;for(let e of o){let a=gn(e,l,()=>{f+=1}),o=a?.traversal??Lt(),h=r===`cursor-projected`?a?.anchor:void 0,g=Rt(e,o,t,n,c.has(e.index),r);s(e.rect)&&(g.isIncluded&&g.effectiveRect&&!Cn(e.rect,g.effectiveRect)?p+=1:!g.isIncluded&&!s(g.effectiveRect)&&(m+=1)),_n(g,h,d);let _=vn(e,g,a,u,t,i),v=bn(g,h,_.keptIndex);l.set(e.index,{traversal:g.descendants,anchor:v,keptIndex:_.keptIndex,keptDepth:_.keptDepth})}let h=Sn(d,u);return{nodes:h,...p+m>0?{qualityNotes:[{code:`regular-geometry-clipped`,clippedNodeCount:p,droppedNodeCount:m}]}:{},stats:{presentedNodeCount:h.length,sourceNodeCount:e.length,parentClipLookups:f,modalContainedNodeCount:a.size}}}function hn(e){let t=new Set;for(let n of e)n.parentIndex!==void 0&&t.add(n.parentIndex);return t}function gn(e,t,n){if(e.parentIndex!==void 0)return n(),t.get(e.parentIndex)}function _n(e,t,n){e.hiddenContentFrame&&t&&xn(e.hiddenContentFrame,t,n)}function vn(e,t,n,r,i,a){let o=n?.keptIndex,s=n?.keptDepth??-1;if(!t.isIncluded)return{keptIndex:o,keptDepth:s};let c=r.length;s+=1;let{hittable:l,...u}=e;return r.push({raw:{...u,index:c,depth:s,parentIndex:o,...yn(l,e.parentIndex!==void 0,t.effectiveRect,e.enabled!==!1,i,a)},sourceIndex:e.index,...t.effectiveRect?{effectiveRect:t.effectiveRect}:{}}),o=c,{keptIndex:o,keptDepth:s}}function yn(e,t,n,r,i,a){return a.hittabilityAvailable===!1?e===!1||!r?{hittable:!1}:{}:{hittable:t&&e===!0&&d(r,n,i)}}function bn(e,t,n){return e.establishesScrollAnchor&&n!==void 0&&e.effectiveRect?{index:n,rect:e.effectiveRect}:t}function xn(e,t,n){let r=n.get(t.index)??{above:!1,below:!1};e.y+e.height<=t.rect.y?r.above=!0:e.y>=t.rect.y+t.rect.height&&(r.below=!0),n.set(t.index,r)}function Sn(e,t){return t.map(t=>{let n=e.get(t.raw.index);if(!n)return t;let r=t.raw;return{...t,raw:{...r,hiddenContentAbove:r.hiddenContentAbove===!0||n.above?!0:void 0,hiddenContentBelow:r.hiddenContentBelow===!0||n.below?!0:void 0}}})}function Cn(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}const wn=new Set([`collectionview`,`scrollview`,`table`]);function Tn(e){return En(e.viewport)}function En(e){if(e.kind===`missing`)throw new U(e.reason===`invalid`?`invalid-viewport`:`missing-viewport`,`regular iOS snapshot presentation requires a valid viewport`,{field:`viewport`});if(!s(e.rect))throw new U(`invalid-viewport`,`regular iOS snapshot presentation requires a positive finite viewport`,{field:`viewport`});return e.rect}function Dn(e,t,n,r=!0){W(e);let i=new Map,a=0;for(let o of e){let e=On(o,i,t,()=>{a+=1}),c=Pn(o.rect);if(kn(o,r),!c||!s(c)){An(o,c),i.set(o.index,e);continue}jn(o,c,e),Mn(o,c,t),i.set(o.index,Nn(o,c,e,n))}return{parentClipLookups:a}}function On(e,t,n,r){if(e.parentIndex===void 0)return n;r();let i=t.get(e.parentIndex);if(!i)throw new U(`invalid-presented-payload`,`regular iOS snapshot payload refers to a parent outside the payload`,{index:e.index,parentIndex:e.parentIndex});return i}function kn(e,t){if(!(e.hittable!==!0||t))throw new U(`invalid-presented-payload`,`iOS snapshot payload marked a node actionable without hittability evidence`,{index:e.index})}function An(e,t){if(e.hittable===!0)throw new U(`regular-degenerate-actionable-node`,`regular iOS snapshot node with a missing or degenerate frame is actionable`,{index:e.index,frame:t??e.rect})}function jn(e,t,n){if(!Fn(t,n))throw new U(`regular-node-outside-cumulative-clip`,`regular iOS snapshot node escaped its cumulative clip`,{index:e.index,frame:t,clip:n})}function Mn(e,t,n){if(!(e.hittable!==!0||e.enabled!==!1&&a(n,t.x+t.width/2,t.y+t.height/2)))throw new U(`invalid-presented-payload`,`regular iOS snapshot payload marked a disabled or off-viewport node actionable`,{index:e.index,frame:t})}function Nn(e,t,n,r){return r===`cursor-projected`&&wn.has(i(e.type??``))?t:n}function Z(e,t,n,r,i=!0){if(t===`raw`)return W(e),{parentClipLookups:0};if(!n)throw new U(`missing-viewport`,`regular iOS snapshot payload cannot be validated without a viewport`,{field:`viewport`});try{return Dn(e,n,r,i)}catch(e){throw e instanceof U&&e.code===`IOS_SNAPSHOT_ENGINE_FAILED`&&e.reason===`malformed-graph`?new U(`invalid-presented-payload`,e.message,e.details):e}}function Pn(e){if(!(!e||![e.x,e.y,e.width,e.height].every(Number.isFinite))&&!(e.width<0||e.height<0))return{...e,width:Math.max(0,e.width),height:Math.max(0,e.height)}}function Fn(e,t){let n=1e-4;return u({x:t.x-n,y:t.y-n,width:t.width+n*2,height:t.height+n*2},e)}const In=new Set([`button`,`cell`,`checkbox`,`collectionview`,`keyboard`,`link`,`menuitem`,`picker`,`searchfield`,`securetextfield`,`segmentedcontrol`,`slider`,`scrollview`,`stepper`,`switch`,`tabbar`,`table`,`textfield`,`textview`,`webview`]);function Ln(e){let t=Yn(e.nodes),n=zn(e,t);return e.projection===`raw`?Bn(n,e.depth,t):Vn(n,e.depth)}function Q(e){let t=Yn(e.nodes);return e.projection===`raw`?Bn(e.nodes,e.depth,t):Vn(e.nodes,e.depth)}function Rn(e){return e.parentIndex===void 0||In.has(i(e.type??``))||Xn(e)}function zn(e,t){let n=e.scope?.trim().toLowerCase();if(!n)return[...e.nodes];for(let r=0;r<e.nodes.length;r+=1){let i=e.nodes[r];if(!i||!qn(i.raw,n))continue;let a=Jn(e.nodes,r,t);if(!(e.projection===`raw`||a.some(t=>Rn(e.nodes[t].raw))))continue;let o=a.map(t=>e.nodes[t]);return Kn(e.projection===`raw`&&e.depth!==null?o.filter(n=>$(n,t)-$(i,t)<=e.depth):o,$(i,t),t)}return[]}function Bn(e,t,n){let r=t===null?[...e]:e.filter(e=>$(e,n)<=t);return{nodes:r.map(e=>({...e.raw,rect:e.raw.rect})),sourceIndexes:r.map(e=>e.sourceIndex)}}function Vn(e,t){let n=[],r=[],i=new Map;for(let a of e){let e=Hn(a,i),o=Un(a,e,t,n.length);if(!o){Gn(a,e,i);continue}n.push(o),r.push(a.sourceIndex),i.set(a.raw.index,o)}return{nodes:n,sourceIndexes:r}}function Hn(e,t){return e.raw.parentIndex===void 0?void 0:t.get(e.raw.parentIndex)}function Un(e,t,n,r){if(!Rn(e.raw))return;let i=t?(t.depth??0)+1:0;if(n!==null&&i>n)return;let a=Wn(e);return{...e.raw,index:r,depth:i,parentIndex:t?.index,...e.effectiveRect?{rect:e.effectiveRect}:{rect:void 0},...a===void 0?{}:{hittable:a}}}function Wn(e){if(e.raw.hittable!==void 0)return!!(e.raw.hittable===!0&&e.effectiveRect&&e.effectiveRect.width>0&&e.effectiveRect.height>0)}function Gn(e,t,n){t&&n.set(e.raw.index,t)}function Kn(e,t,n){let r=new Map(e.map((e,t)=>[e.raw.index,t]));return e.map((e,i)=>({...e,raw:{...e.raw,index:i,depth:Math.max(0,$(e,n)-t),parentIndex:e.raw.parentIndex===void 0?void 0:r.get(e.raw.parentIndex)}}))}function qn(e,t){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.toLowerCase().includes(t))}function Jn(e,t,n){let r=$(e[t],n),i=[];for(let a=t;a<e.length&&!(a>t&&$(e[a],n)<=r);a+=1)i.push(a);return i}function $(e,t){return Math.max(0,e.raw.depth??t?.get(e.raw.index)??0)}function Yn(e){let t=new Map;for(let n of e){let e=(n.raw.parentIndex===void 0?-1:t.get(n.raw.parentIndex)??-1)+1;t.set(n.raw.index,n.raw.depth===void 0?e:Math.max(0,n.raw.depth))}return t}function Xn(e){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.trim().length>0)}function Zn(e,t,n=`cursor-projected`){Qn(e,t);let r=e.validation.presentationKey.projection,i=r===`regular`?En(e.validation.viewport):void 0,a=e.validation.hittability.kind===`available`,o=$n(e,r,i,n,a),s=er(e.presentation.payload.nodes,r,t),c=tr(s.nodes,r,i,n,a,o);return{nodes:s.nodes,...i?{validatedViewport:i}:{},...e.presentation.qualityPayload?{qualityNodes:[...e.presentation.qualityPayload.nodes]}:{},presentedIndexesBySourceIndex:s.presentedIndexesBySourceIndex,stats:{presentedNodeCount:s.nodes.length,sourceNodeCount:e.presentation.payload.nodes.length,parentClipLookups:c.parentClipLookups,modalContainedNodeCount:0}}}function Qn(e,t){if(!nr(m(t),e.validation.presentationKey))throw new U(`projection-mismatch`,`presented iOS snapshot does not match the requested presentation key`,{projection:e.validation.presentationKey.projection});if(e.presentation.intent!==t.acquisitionIntent)throw new U(`projection-mismatch`,`presented iOS snapshot does not match the requested acquisition intent`,{field:`acquisitionIntent`})}function $n(e,t,n,r,i){let a=Z(e.presentation.payload.nodes,t,n,r,i);if(e.presentation.qualityPayload)try{Z(e.presentation.qualityPayload.nodes,t,n,r,i)}catch(e){throw e instanceof U?new U(`invalid-quality-payload`,e.message,e.details):e}return a}function er(e,t,n){return t===`regular`&&n.interactiveOnly?V([...e]):{nodes:[...e],presentedIndexesBySourceIndex:rr(e)}}function tr(e,t,n,r,i,a){return t!==`regular`||!n?a:Z(e,t,n,r,i)}function nr(e,t){return e.projection===t.projection&&e.interactiveOnly===t.interactiveOnly&&e.depth===t.depth&&e.scope===t.scope&&e.customActions===t.customActions}function rr(e){return new Map(e.map(e=>[e.index,[e.index]]))}function ir(t,n,r={}){let i=or(t,n,r),a=t.stage===`presented`?t.validation.presentationKey:m(n),o=t.stage===`acquired`?t.acquisition.truncated:t.presentation.payload.truncated;return{payload:{nodes:e(i.nodes),...o===void 0?{}:{truncated:o}},presentationKey:a,...i.qualityNotes?{qualityNotes:i.qualityNotes}:{},comparisonIdentity:h(t,n),residue:t.stage===`acquired`?[...t.acquisition.residue]:[...t.validation.residue],...i.validatedViewport?{validatedViewport:i.validatedViewport}:{},...t.stage===`acquired`?{presentedSurface:tn(t.acquisition.nodes,ar(t.acquisition))}:{}}}function ar(e){return e.truncated===void 0?`unstated`:e.truncated?`capped`:`complete`}function or(e,t,n={}){let r=n.foldPolicy??`cursor-projected`;return e.stage===`acquired`?sr(e.acquisition,t,r):Zn(e,t,r)}function sr(e,t,n){if(lr(e,p(t)),t.projection===`raw`){W(e.nodes);let r=e.nodes.map(e=>({raw:e,sourceIndex:e.index})),i=Ln({nodes:r,projection:`raw`,scope:t.scope,depth:t.depth,foldPolicy:n}),a=t.scope===null?void 0:Q({nodes:r,projection:`raw`,depth:null,foldPolicy:n}).nodes;return{nodes:i.nodes,...a?{qualityNodes:a}:{},presentedIndexesBySourceIndex:dr(e.nodes,i.nodes,i.sourceIndexes,ur(i.nodes)),stats:{presentedNodeCount:i.nodes.length,sourceNodeCount:e.nodes.length,parentClipLookups:0,modalContainedNodeCount:0}}}let r=Tn(e),i=!cr(e.residue),a=mn(e.nodes,r,t.interactiveOnly,n,{hittabilityAvailable:i}),o=Ln({nodes:a.nodes,projection:`regular`,scope:t.scope,depth:t.depth,foldPolicy:n}),s=t.interactiveOnly?V(o.nodes):{nodes:o.nodes,presentedIndexesBySourceIndex:ur(o.nodes)},c=Z(s.nodes,`regular`,r,n,i),l=t.scope===null?void 0:Q({nodes:a.nodes,projection:`regular`,depth:null,foldPolicy:n}).nodes;return{nodes:s.nodes,validatedViewport:r,...a.qualityNotes?{qualityNotes:a.qualityNotes}:{},...l?{qualityNodes:l}:{},presentedIndexesBySourceIndex:dr(e.nodes,o.nodes,o.sourceIndexes,s.presentedIndexesBySourceIndex),stats:{presentedNodeCount:s.nodes.length,sourceNodeCount:e.nodes.length,parentClipLookups:a.stats.parentClipLookups+c.parentClipLookups,modalContainedNodeCount:a.stats.modalContainedNodeCount}}}function cr(e){return e.some(e=>e.kind===`unavailable-fact`&&e.fact===`hittability`)}function lr(e,t){let n=e.hint;if(n.projection!==t.projection||n.rawTraversalDepth!==t.rawTraversalDepth||n.regularPresentedDepth!==t.regularPresentedDepth||n.interactiveOnly!==t.interactiveOnly||n.customActions!==t.customActions||n.acquisitionIntent!==t.acquisitionIntent)throw new U(`projection-mismatch`,`acquired iOS snapshot does not match the requested capture hint`,{projection:n.projection})}function ur(e){return new Map(e.map(e=>[e.index,[e.index]]))}function dr(e,t,n,r){let i=new Map(t.map((e,t)=>[e.index,n[t]])),a=new Map(e.map(e=>[e.index,[]]));for(let[e,t]of r){let n=i.get(e);n!==void 0&&a.set(n,t)}return a}export{V as a,Pt as i,Zn as n,U as r,ir as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as e}from"./sdk-contracts.js";import{
|
|
1
|
+
import{R as e}from"./sdk-contracts.js";import{ci as t}from"./sdk-batch.js";import{i as n,r}from"./ios-snapshot-planning.js";import{i,r as a,t as o}from"./ios-snapshot-engine.js";const s={"acquisition-depth":`iOS snapshot acquisition does not report hierarchy completeness; provider-side depth or child limits may omit nodes.`,hittability:`iOS snapshot acquisition does not provide hittability evidence; regular snapshots omit unverified hittability while raw snapshots preserve supplied facts.`,truncation:`iOS snapshot acquisition does not expose truncation metadata; tree completeness is not independently verified.`};function c(e,n){let i=r({raw:n?.raw,interactiveOnly:n?.interactiveOnly,depth:n?.depth,scope:n?.scope,customActions:n?.customActions,acquisitionIntent:e.acquisition.intent}),a=l(e,i);try{let n=o(a,i),r=t(n.validatedViewport);return{backend:`xctest`,...n.qualityNotes?{qualityNotes:n.qualityNotes}:{},producer:e.acquisition.producer,nodes:[...n.payload.nodes],...e.acquisition.keyboard?{keyboard:e.acquisition.keyboard}:{},comparisonIdentity:n.comparisonIdentity,...e.acquisition.truncated===void 0?{}:{truncated:e.acquisition.truncated},...r?{viewport:r}:{},...n.presentedSurface?{presentedSurface:n.presentedSurface}:{},...u(e.acquisition.residue)}}catch(e){d(e)}}function l(e,t){let r=n(t);return e.acquisition.intent===`full`?{stage:`acquired`,acquisition:{...e.acquisition,intent:`full`,hint:{...r,acquisitionIntent:`full`}}}:{stage:`acquired`,acquisition:{...e.acquisition,intent:`surface-observation`,hint:{...r,acquisitionIntent:`surface-observation`}}}}function u(e){let t=new Set(e.flatMap(e=>{if(e.kind===`missing-viewport`)return[`iOS snapshot acquisition did not provide a valid viewport (${e.reason}); retry with --raw to inspect the acquired tree, while regular presentation requires viewport evidence.`];if(e.kind!==`unavailable-fact`)return[];let t=s[e.fact];return t?[t]:[]}));return t.size===0?{}:{warnings:[...t]}}function d(t){if(!(t instanceof a))throw t;let n=i(t),r=t.reason===`missing-viewport`||t.reason===`invalid-viewport`?`Use snapshot --raw to inspect the acquired iOS tree; regular presentation requires valid viewport evidence.`:void 0;throw new e(`COMMAND_FAILED`,t.message,{...n,...r?{hint:r}:{}},t)}export{c as presentIosSnapshotAcquisition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as e,W as t}from"./sdk-contracts.js";import{
|
|
1
|
+
import{R as e,W as t}from"./sdk-contracts.js";import{Nr as n}from"./sdk-batch.js";import{r,t as i}from"./tap-keyboard-occlusion.js";function a(e){switch(e){case`click`:case`press`:case`tap`:return`be tapped`;case`fill`:return`be filled`;case`focus`:return`be focused`;case`longPress`:return`be long-pressed`;case`hover`:return`be hovered`;case`scroll`:return`be scrolled`;case`swipe`:return`be swiped`;case`pinch`:return`be pinched`;case`pan`:return`be panned`;case`drag`:return`be dragged`;case`fling`:return`be flung`;case`rotate`:return`be rotated`;case`transform`:return`be transformed`}}function o(e){let t=e.node.rect;if(!t||!e.tapPoint)return;let i=r({nodes:e.nodes,viewport:n(e.nodes).resolveViewport(t),point:e.tapPoint,node:e.node,...e.keyboard?{keyboard:e.keyboard}:{}});if(i.kind===`occluded`)throw l({label:e.label,action:e.action,ref:e.node.ref,targetRect:t,surface:i.surface})}function s(e){let t=r({nodes:e.nodes,viewport:e.viewport,point:e.point,...e.keyboard?{keyboard:e.keyboard}:{}});if(t.kind===`occluded`)return c(e.point,t.surface)}function c(e,t){return`(${e.x}, ${e.y}) is behind the visible keyboard, so this tap lands on the keyboard rather than anything under it (${i.reason}; keyboard frame ${Math.round(t.frame.y)}..${Math.round(t.frame.y+t.frame.height)}). `+i.hint}function l(n){return t(new e(`COMMAND_FAILED`,`${n.label} is behind the visible keyboard and cannot ${a(n.action)} safely`,{...i,ref:`@${n.ref}`,rect:n.targetRect,keyboardFrame:n.surface.frame}),`no`)}export{s as n,a as r,o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as e}from"./sdk-contracts.js";import{ht as t}from"./sdk-io.js";import"./diagnostics.js";import{
|
|
1
|
+
import{R as e}from"./sdk-contracts.js";import{ht as t}from"./sdk-io.js";import"./diagnostics.js";import{cn as n}from"./sdk-batch.js";import{s as r}from"./app-resolution.js";import{n as i}from"./alert.js";const a=`launch_confirmation_foreign_app`,o=/^Open in [“"].+[”"]\?$/u,s=1e4;async function c(n){let r=await u(()=>n.awaitAlert());if(`outcome`in r)return r;let i=r.alert;if(!i)return{outcome:`absent`};if(!p(i))return t({level:`warn`,phase:`ios_launch_confirmation_unanswered`,data:{reason:`alert-unrecognized`,title:i.message,buttons:i.items}}),{outcome:`unanswered`,reason:`alert-unrecognized`};let o=await d(n);if(`outcome`in o)return o;if(o.owner===void 0)return h(`url-owner-unresolved`,{}),{outcome:`unanswered`,reason:`url-owner-unresolved`};if(o.owner!==n.appBundleId)throw new e(`COMMAND_FAILED`,`The launch URL asks to open ${o.owner} instead.`,{reason:a,foreignAppBundleId:o.owner,sessionAppBundleId:n.appBundleId,hint:`iOS is asking whether to open ${o.owner}. Answer it with alert accept or alert dismiss, and pass a launch URL whose scheme belongs to the session app.`});return await n.acceptAlert().then(f,async e=>await l(n,i,e))}async function l(e,t,n){let r=await u(()=>e.readAlert());return`outcome`in r?m(`alert-accept`)(n):r.alert&&p(r.alert)&&r.alert.message===t.message?(h(`alert-still-present`,{}),{outcome:`unanswered`,reason:`alert-still-present`}):m(`alert-accept`)(n)}async function u(e){return await e().then(e=>({alert:e}),m(`alert-read`))}async function d(e){return await e.resolveUrlOwner().then(e=>({owner:e}),m(`url-owner`))}function f(){return{outcome:`accepted`}}function p(e){let t=e.message,n=e.items;return typeof t==`string`&&o.test(t)&&Array.isArray(n)&&n.length===2&&n.includes(`Cancel`)&&n.includes(`Open`)}function m(t){return n=>(h(`step-failed`,{step:t,code:n instanceof e?n.code:void 0}),{outcome:`unreadable`,step:t})}function h(e,n){t({level:`debug`,phase:`ios_launch_confirmation_unanswered`,data:{reason:e,...n}})}async function g(e,t,n,r){let i=await n.then(e=>({interactor:e}),m(`runner`));return`outcome`in i?i:await c(_(e,t,i.interactor,r))}function _(e,{url:t,appBundleId:a},o,c){let l=o.awaitAlert?.bind(o),u=o.readAlert?.bind(o),d=o.acceptAlert?.bind(o);if(!l||!u||!d)throw n(`Apple interactor has no alert wait, read or accept leg`);let f={appBundleId:a,surface:`app`};return Object.freeze({appBundleId:a,awaitAlert:async()=>await i(l({...f,timeoutMs:3e3})),readAlert:async()=>await i(u(f)),acceptAlert:async()=>await d(f),resolveUrlOwner:async()=>await r(e,t,{timeoutMs:s,signal:c})})}export{a as LAUNCH_CONFIRMATION_FOREIGN_APP_REASON,s as URL_OWNER_LOOKUP_TIMEOUT_MS,c as answerLaunchConfirmation,g as answerSimulatorLaunchConfirmation,_ as createLaunchConfirmationPort};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./sdk-batch-runner.js";import{
|
|
1
|
+
import{j as e}from"./sdk-batch-runner.js";import{gt as t}from"./back-mode.js";function n(e){return t(e)}function r(t,r){let i=n(t),a=i.leaseId??r?.leaseId,o=i.tenantId??r?.tenantId,s=i.runId??r?.runId;if(!(!o||!s||!a))return e({tenantId:o,runId:s,leaseId:a,leaseBackend:i.leaseBackend??r?.backend,leaseProvider:i.leaseProvider??r?.leaseProvider,deviceKey:i.deviceKey??r?.deviceKey,clientId:i.clientId??r?.clientId,expiresAt:r?.expiresAt})}function i(t,r){let i=n(t),a=r?.lease??r?.deviceLease??void 0;return e({tenantId:i.tenantId??a?.tenantId,runId:i.runId??a?.runId,leaseId:i.leaseId??a?.leaseId,leaseTtlMs:i.leaseTtlMs,leaseBackend:i.leaseBackend??a?.leaseBackend,leaseProvider:i.leaseProvider??a?.leaseProvider,deviceKey:i.deviceKey??a?.deviceKey,clientId:i.clientId??a?.clientId})}function a(t){let n=t.meta,r=e({leaseId:o(n?.leaseId),clientId:o(n?.clientId),tenantId:o(n?.tenantId),runId:o(n?.runId),leaseProvider:o(n?.leaseProvider),deviceKey:o(n?.deviceKey)});return Object.keys(r).length>0?r:void 0}function o(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}export{a as i,n,i as r,r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as e,t}from"./sdk-contracts.js";import{
|
|
1
|
+
import{R as e,t}from"./sdk-contracts.js";import{St as n,lt as r}from"./back-mode.js";import{w as i}from"./transport.js";import a from"node:crypto";const o=`default`;function s(t){let n=Number.isInteger(t.defaultLeaseTtlMs)?Math.max(1,Number(t.defaultLeaseTtlMs)):6e4,i=Number.isInteger(t.minLeaseTtlMs)?Math.max(1,Number(t.minLeaseTtlMs)):r,a=Number.isInteger(t.maxLeaseTtlMs)?Math.max(i,Number(t.maxLeaseTtlMs)):6e5;return t=>{if(!Number.isInteger(t))return n;let r=Number(t);if(r<i||r>a)throw new e(`INVALID_ARGS`,`Lease ttlMs must be between ${i} and ${a}.`);return r}}function c(e){if(!e)return;let t=e.trim();if(t&&/^[a-zA-Z0-9._-]{1,128}$/.test(t))return t}function l(e){if(!e)return;let t=e.trim();if(t&&/^[a-f0-9]{16,128}$/i.test(t))return t.toLowerCase()}function u(t){let n=l(t);if(!n)throw new e(`INVALID_ARGS`,`Invalid lease id.`);return n}function d(n){let r=(n??``).trim().toLowerCase();if(!r)return`ios-simulator`;let i=t.find(e=>e===r);if(i)return i;throw new e(`INVALID_ARGS`,`Unsupported lease backend: ${n??``}`)}function f(t){if(t===void 0)return;let n=t.trim();if(!n||n.length>256||!/^[\u0020-\u007E]+$/.test(n))throw new e(`INVALID_ARGS`,`Invalid device key. Use 1-256 printable characters.`);return n}function p(e){return h(e,`client id`,128)}function m(e){return h(e,`lease provider`,64)}function h(t,n,r){if(t===void 0)return;let i=t.trim();if(!i||i.length>r||!/^[a-zA-Z0-9._-]+$/.test(i))throw new e(`INVALID_ARGS`,`Invalid ${n}. Use 1-${String(r)} chars: letters, numbers, dot, underscore, hyphen.`);return i}function g(t){let n=i(t);if(!n)throw new e(`INVALID_ARGS`,`Invalid tenant id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return n}function _(t){let n=c(t);if(!n)throw new e(`INVALID_ARGS`,`Invalid run id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return n}function v(e){return{backend:d(e.leaseBackend),leaseProvider:m(e.leaseProvider),deviceKey:f(e.deviceKey),clientId:p(e.clientId),tenantId:g(e.tenantId),runId:_(e.runId),ttlMs:e.ttlMs,retainOnClose:e.retainOnClose}}function y(e){return!!(e.leaseProvider??e.deviceKey??e.clientId)}function b(e,t){return!t.tenantId||!t.runId?!1:[[e.leaseProvider,t.leaseProvider],[e.deviceKey,t.deviceKey],[e.clientId,t.clientId]].every(([e,t])=>!e||!!t)}function x(t,n){let r=C(n);if(r.tenantId&&t.tenantId!==r.tenantId||r.runId&&t.runId!==r.runId||r.leaseBackend&&t.backend!==r.leaseBackend||r.leaseProvider&&t.leaseProvider!==r.leaseProvider||r.deviceKey&&t.deviceKey!==r.deviceKey||r.clientId&&t.clientId!==r.clientId)throw new e(`UNAUTHORIZED`,`Lease does not match tenant/run scope`,{reason:`LEASE_SCOPE_MISMATCH`})}function S(t){let n=d(t.leaseBackend),r=i(t.tenantId);if(!r)throw new e(`INVALID_ARGS`,`tenant isolation requires tenant id.`);let a=c(t.runId);if(!a)throw new e(`INVALID_ARGS`,`tenant isolation requires run id.`);let o=l(t.leaseId);if(!o)throw new e(`INVALID_ARGS`,`tenant isolation requires lease id.`,{hint:`Allocate a lease with leases.allocate and pass its leaseId.`});return{...t,tenantId:r,runId:a,leaseId:o,leaseBackend:n}}function C(t){let n=i(t.tenantId),r=c(t.runId);if(t.tenantId&&!n)throw new e(`INVALID_ARGS`,`Invalid tenant id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);if(t.runId&&!r)throw new e(`INVALID_ARGS`,`Invalid run id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return{tenantId:n,runId:r,leaseBackend:t.leaseBackend?d(t.leaseBackend):void 0,leaseProvider:m(t.leaseProvider),deviceKey:f(t.deviceKey),clientId:p(t.clientId)}}function w(t,n){if(y(t)&&!b(t,n))throw new e(`UNAUTHORIZED`,`Lease owner scope is required`,{reason:`LEASE_SCOPE_REQUIRED`})}function T(e,t){return e.tenantId===t.tenantId&&e.runId===t.runId&&e.backend===t.backend&&e.leaseProvider===t.leaseProvider&&e.deviceKey===t.deviceKey&&e.clientId===t.clientId}function E(e){if(e.deviceKey)return JSON.stringify([e.backend,e.leaseProvider??o,e.deviceKey])}function D(e){return JSON.stringify([e.tenantId,e.runId,e.backend,e.leaseProvider??o,e.deviceKey??`*`])}function O(e,t,n,r=a.randomBytes(16).toString(`hex`)){return{leaseId:r,tenantId:e.tenantId,runId:e.runId,backend:e.backend,...e.leaseProvider?{leaseProvider:e.leaseProvider}:{},...e.deviceKey?{deviceKey:e.deviceKey}:{},...e.clientId?{clientId:e.clientId}:{},...e.retainOnClose?{retainOnClose:!0}:{},createdAt:n,heartbeatAt:n,expiresAt:n+t}}function k(e){return e.expiresAt-e.heartbeatAt}function A(t){return new e(`DEVICE_IN_USE`,`Device is already leased`,{reason:`DEVICE_LEASE_BUSY`,deviceKey:t.deviceKey,backend:t.backend,leaseProvider:t.leaseProvider,expiresAt:t.expiresAt,hint:`Retry after the lease expires or close the owning session.`})}function j(e){return n({leaseId:e.leaseId,tenantId:e.tenantId,runId:e.runId,leaseBackend:e.backend,leaseProvider:e.leaseProvider,deviceKey:e.deviceKey,clientId:e.clientId})}export{u as _,A as a,k as c,v as d,f,m as g,l as h,s as i,j as l,d as m,x as n,T as o,S as p,O as r,E as s,w as t,D as u};
|
package/dist/src/lease.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as e,V as t,m as n,q as r}from"./sdk-contracts.js";import{E as i,
|
|
1
|
+
import{R as e,V as t,m as n,q as r}from"./sdk-contracts.js";import{E as i,St as a,_t as o,bt as s,ft as c,mt as l,pt as u}from"./back-mode.js";import{O as d}from"./sdk-device.js";import{ln as f}from"./sdk-batch.js";import{N as p}from"./src.js";import{c as m}from"./device-shell.js";import{r as h}from"./artifact-tracking.js";import{g,l as _,m as v}from"./lease-registry-scope.js";import{n as y,r as b}from"./lease-context.js";import{o as x,s as S}from"./request.js";async function C(e){let{req:t,sessionName:n,sessionStore:r,leaseRegistry:o,providerRuntimeIds:c,failedPlugins:l,providerCredentials:u,leaseLifecycleProvider:d,cloudArtifactProvider:p,endSessionsForLease:m}=e,h=y(t);switch(t.command){case i.artifacts:return{ok:!0,data:await P(t,b(t,r.get(n)),o,p,e.host.env)};case`lease_allocate`:{H(h.leaseBackend);let n=g(h.leaseProvider);M(n,c??[],l??[]),N({leaseProvider:n,leaseBackend:h.leaseBackend},t.meta?.providerCredentialFingerprint,u);let{lease:r,reused:i}=await w(t,h,o,e.host),a=t.meta?.requestId;return await o.runDeviceMutation(r,async()=>{let n,s=d?.allocate?o.retainLeaseWork(r,()=>!S(a)):void 0;try{n=await d?.allocate?.(r,{...j(t,e.host),signal:x(a),deadline:Date.now()+f}),B(o,r,n)}catch(e){throw await D(r,i,a,d,o),e}finally{s?.release()}if(S(a))throw await O(r,d,o);return{ok:!0,data:{lease:o.getLease(_(r))??r,...n?{provider:n}:{}}}})}case`lease_heartbeat`:{let n=o.heartbeatLease(s(h)),r=await d?.heartbeat?.(n,j(t,e.host));return{ok:!0,data:{lease:n,...r?{provider:r}:{}}}}case`lease_release`:{let n=a(h),r=o.getLease(n);V(r);let i=await o.runDeviceMutation(r,async()=>await E(o,d,r,n,j(t,e.host)));return r&&i.registryReleased&&await m?.(r.leaseId),{ok:!0,data:{released:i.registryReleased,...i.provider?{provider:i.provider}:{}}}}default:return null}}async function w(e,t,n,r){let i=o(t),a=n.renewRequestedLease(i);if(a)return{lease:a,reused:!0};let s=await T(e,t,r.env),c=new Set(n.listActiveLeases().map(e=>e.leaseId)),l=n.allocateLease(s?{...i,deviceKey:s}:i);return{lease:l,reused:c.has(l.leaseId)}}async function T(e,t,r){if(!c(t)||t.deviceKey)return;let i=e.flags??{},{hasDeviceSelectionInput:a}=await import(`./src.js`).then(e=>e.T);if(!a(i))return;let{resolveTargetDevice:o}=await import(`./replay-script-selection.js`).then(e=>e.l),s=await o({platform:i.platform??(t.leaseBackend?n(t.leaseBackend):void 0),target:i.target,device:i.device,udid:i.udid,serial:i.serial,iosSimulatorDeviceSet:i.iosSimulatorDeviceSet,androidDeviceAllowlist:i.androidDeviceAllowlist},{env:r});return u({platform:d(s),target:s.target,id:s.id})}async function E(e,t,n,r,i){let a=n?await t?.release?.(n,i):void 0;return n&&B(e,n,a),{registryReleased:e.releaseLease(r).released,provider:a}}async function D(e,t,n,r,i){if(!t){i.releaseLease(_(e));return}if(S(n))throw await O(e,r,i)}async function O(e,t,n){let i=_(e),a,o;try{a=await E(n,t,e,i)}catch(e){o=r(e),a={registryReleased:n.releaseLease(i).released}}return k(e,a,o)}function k(e,n,r){let i=n.provider?.providerSessionId,a=Array.isArray(n.provider?.warnings)?n.provider.warnings:[],o=n.registryReleased&&r===void 0&&a.length===0;return t({leaseId:e.leaseId,leaseProvider:e.leaseProvider,released:o,registryReleased:n.registryReleased,providerSessionId:i,...a.length>0?{warnings:a}:{},...r===void 0?{}:{releaseError:r},hint:A(o,e.leaseId,i)})}function A(e,t,n){return e?`The lease request was canceled while the provider was still allocating; the session it produced was released.`:`The lease request was canceled while the provider was still allocating, and the session it produced could NOT be confirmed released — it may still be running and billing. Stop provider session ${String(n??`(unknown)`)} for lease ${t} by hand.`}function j(e,t){return{flags:e.flags,...typeof e.flags?.providerApp==`string`?{initialApp:e.flags.providerApp}:{},cwd:typeof e.meta?.cwd==`string`?e.meta.cwd:t.cwd,...e.internal?.publicNetworkOnly?{publicNetworkOnly:!0}:{}}}function M(t,n,r){let i=l({leaseProvider:t});if(i===void 0||n.includes(i))return;let a=r.flatMap(e=>e.state===`failed`&&(e.provider===i||e.provider===void 0)?[{...e.provider===void 0?{}:{provider:e.provider},...e.package===void 0?{}:{package:e.package},code:e.error.code,...e.error.reason===void 0?{}:{reason:e.error.reason},message:e.error.message}]:[]);throw new e(`UNSUPPORTED_OPERATION`,`Provider "${i}" is not available in this daemon runtime.`,{reason:`provider-not-registered`,provider:i,registeredProviders:[...n],...a.length>0?{failedPlugins:a}:{},hint:a.length>0?`Fix the plugin that failed to register (see failedPlugins or agent-device daemon status), restart the daemon, then retry lease allocation.`:`Restart the daemon with ${i} configured, then retry lease allocation.`})}function N({leaseProvider:t,leaseBackend:n},r,i){if(!i||!t||!r)return;let a=i.fingerprint(t,n);if(r!==a)throw new e(`INVALID_ARGS`,a?`The running daemon holds different ${t} credentials than this shell.`:`The running daemon was started without the ${t} credentials this shell holds.`,{reason:`provider-credentials-changed`,provider:t,hint:`Stop it with agent-device daemon stop --state-dir ${m(i.stateDir)}, then rerun the command so a new daemon starts with this shell's environment.`})}async function P(e,t,n,r,i){let a=z(e.flags,`providerSessionId`);return F(t,a)?await I(t.tenantId,i):await L(t,a,n,r)}function F(e,t){return c(e)||!e.leaseProvider&&!t}async function I(e,t){let n=await h(e,t);return{source:`daemon`,status:`ready`,artifacts:n,...n.length===0?{message:`No daemon artifacts available.`}:{}}}async function L(t,n,r,i){if(!t.leaseProvider)throw new e(`INVALID_ARGS`,`artifacts requires --provider for provider session lookup or an active cloud connection.`);if(!t.leaseId&&!n)throw new e(`INVALID_ARGS`,`artifacts requires an active cloud lease or --provider-session <id>.`);let a=R(r,t,n),o=await i?.listCloudArtifacts?.({provider:t.leaseProvider,leaseId:a?.leaseId??t.leaseId,providerSessionId:n});if(!o)throw new e(`UNSUPPORTED_OPERATION`,`Cloud artifacts are not available for provider "${t.leaseProvider}".`);return o}function R(t,n,r){if(!r)return;let i=t.resolveProviderSession({provider:n.leaseProvider,providerSessionId:r,tenantId:n.tenantId});if(i)return i;throw new e(`UNAUTHORIZED`,`Provider session is not owned by the request tenant`,{reason:`PROVIDER_SESSION_NOT_OWNED`})}function z(e,t){let n=e?.[t];return typeof n==`string`&&n.trim().length>0?n.trim():void 0}function B(e,t,n){let r=p(n);r&&e.recordProviderSession(t,r)}function V(t){if(t?.backend===`macos-app`)throw new e(`UNAUTHORIZED`,`A macos-app lease is released by the host administrator.`,{reason:`MACOS_APP_LEASE_HOST_OWNED`,retriable:!1,hint:`Disconnect only drops the client connection; the host ends the lease.`})}function H(t){if(v(t)===`macos-app`)throw new e(`UNAUTHORIZED`,`A macos-app lease is allocated by the host administrator.`,{reason:`MACOS_APP_LEASE_HOST_ALLOCATED`,retriable:!1,hint:`Ask the host administrator for a macos-app lease and connect with its leaseId.`})}export{C as handleLeaseCommands};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{sn as e}from"./sdk-batch.js";import{t}from"./touch-runtime.js";import{E as n,P as r,V as i,W as a,X as o,q as s}from"./tv-remote-runtime.js";import{t as c}from"./interactor-operation-catalog.js";function l(l){let{facts:u,pause:d}=l,f={device:l.device,signal:l.signal,resolveInteractor:l.resolveInteractor};return{...u.captureScreenshot.available?r(f):{},...u.focusPoint.available?s(f):{},...a({...f,facts:u}),...u.scrollDirection.available?i(f):{},...u.typeText.available?n(f):{},...u.readTextAtPoint.available?o(f):{},...e(u.tapPoint,()=>t({...f,facts:u,pause:d})),...c({...f,facts:u})}}export{l as t};
|