agent-device 0.20.6 → 0.20.7

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.
Files changed (175) hide show
  1. package/README.md +3 -3
  2. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.6.apk → agent-device-android-ime-helper-0.20.7.apk} +0 -0
  3. package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.7.apk.sha256 +1 -0
  4. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.20.6.manifest.json → agent-device-android-ime-helper-0.20.7.manifest.json} +4 -4
  5. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.6.apk → agent-device-android-snapshot-helper-0.20.7.apk} +0 -0
  6. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.7.apk.sha256 +1 -0
  7. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.20.6.manifest.json → agent-device-android-snapshot-helper-0.20.7.manifest.json} +6 -6
  8. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +20 -0
  9. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +67 -0
  10. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +339 -4
  11. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSelectorMatchPolicy.swift +78 -0
  12. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +31 -2
  13. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +29 -7
  14. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CoordinateTextEntryTests.swift +4 -0
  15. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +36 -28
  16. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +7 -0
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SelectorMatchPolicyTests.swift +4 -0
  18. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +2 -1
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +100 -12
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +4 -0
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +57 -0
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +1 -0
  23. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +18 -3
  24. package/dist/src/agent-browser-tool.js +1 -1
  25. package/dist/src/agent-device-client.js +2 -2
  26. package/dist/src/android-adb.js +1 -1
  27. package/dist/src/android.js +1 -1
  28. package/dist/src/app-helpers.js +1 -1
  29. package/dist/src/app-lifecycle.js +7 -7
  30. package/dist/src/app-lifecycle2.js +2 -0
  31. package/dist/src/app-log-files.js +1 -0
  32. package/dist/src/app-log-reconnect.js +1 -0
  33. package/dist/src/app-log-runtime.js +4 -0
  34. package/dist/src/app-resolution.js +2 -1
  35. package/dist/src/apps.js +5 -5
  36. package/dist/src/audio-probe.js +1 -1
  37. package/dist/src/auth-session.js +1 -0
  38. package/dist/src/auth.js +2 -0
  39. package/dist/src/boot-diagnostics.js +2 -2
  40. package/dist/src/cli-config.js +1 -1
  41. package/dist/src/cli-grammar.js +1 -0
  42. package/dist/src/cli-help.js +199 -259
  43. package/dist/src/cli-output.js +1 -0
  44. package/dist/src/cli-runner.js +1 -2
  45. package/dist/src/cli.js +6 -16
  46. package/dist/src/client-metro.js +1 -1
  47. package/dist/src/cloud-artifacts.d.ts +2 -137
  48. package/dist/src/command-schema.js +3 -3
  49. package/dist/src/connection-runtime.js +1 -0
  50. package/dist/src/connection.js +5 -0
  51. package/dist/src/context.js +1 -1
  52. package/dist/src/daemon-shutdown-report.js +1 -0
  53. package/dist/src/daemon.js +2 -0
  54. package/dist/src/debug-symbols.js +3 -3
  55. package/dist/src/device-claim-inspection.js +1 -0
  56. package/dist/src/device-input-state.js +2 -2
  57. package/dist/src/device.js +1 -1
  58. package/dist/src/device2.js +2 -0
  59. package/dist/src/find.js +1 -1
  60. package/dist/src/finders.js +1 -1
  61. package/dist/src/generic-settle.js +1 -1
  62. package/dist/src/generic.js +1 -1
  63. package/dist/src/harmonyos.js +1 -0
  64. package/dist/src/helper.js +1 -1
  65. package/dist/src/host-process.js +2 -2
  66. package/dist/src/ime-lifecycle.js +7 -7
  67. package/dist/src/index.d.ts +43 -12
  68. package/dist/src/input-actions.js +4 -4
  69. package/dist/src/input-actions2.js +1 -1
  70. package/dist/src/input-actions3.js +1 -0
  71. package/dist/src/install-artifact.js +1 -5
  72. package/dist/src/install-artifact2.js +1 -1
  73. package/dist/src/install-source2.js +1 -1
  74. package/dist/src/interaction-runtime.js +1 -1
  75. package/dist/src/interaction-snapshot.js +1 -1
  76. package/dist/src/interaction-touch-reference-frame.js +1 -1
  77. package/dist/src/interaction.js +1 -1
  78. package/dist/src/interactor.js +2 -2
  79. package/dist/src/interactor2.js +1 -1
  80. package/dist/src/internal/bin.js +2 -2
  81. package/dist/src/internal/daemon.js +8 -15
  82. package/dist/src/inventory.js +5 -0
  83. package/dist/src/inventory2.js +1 -0
  84. package/dist/src/inventory3.js +2 -0
  85. package/dist/src/inventory4.js +1 -0
  86. package/dist/src/inventory5.js +1 -0
  87. package/dist/src/inventory6.js +1 -0
  88. package/dist/src/lease-context.js +1 -1
  89. package/dist/src/lease.js +1 -1
  90. package/dist/src/limrun-runtime-dependencies.js +1 -0
  91. package/dist/src/limrun.d.ts +10 -125
  92. package/dist/src/limrun.js +1 -1
  93. package/dist/src/linux.js +1 -1
  94. package/dist/src/logcat.js +1 -1
  95. package/dist/src/manifest.js +1 -1
  96. package/dist/src/owner-identity.js +1 -0
  97. package/dist/src/physical-device-control.js +1 -1
  98. package/dist/src/platform-runtime-app-log-android-transport.js +1 -0
  99. package/dist/src/platform-runtime-app-log-process.js +1 -0
  100. package/dist/src/platform-runtime-host.js +1 -0
  101. package/dist/src/platform-runtime-network-web-transport.js +1 -0
  102. package/dist/src/platform-runtime-operation-host.js +5 -0
  103. package/dist/src/platform-runtime-toolchain-host.js +1 -0
  104. package/dist/src/platform-runtime.js +1 -0
  105. package/dist/src/prepare-kind.js +15 -0
  106. package/dist/src/process-entry.js +1 -0
  107. package/dist/src/process-lock.js +1 -1
  108. package/dist/src/provider-webdriver.js +1 -0
  109. package/dist/src/provider.js +1 -0
  110. package/dist/src/proxy.js +2 -0
  111. package/dist/src/react-native.js +1 -1
  112. package/dist/src/record-trace.js +1 -1
  113. package/dist/src/registry.js +24 -24
  114. package/dist/src/remote-config2.js +1 -1
  115. package/dist/src/replay.js +3 -0
  116. package/dist/src/reporting.js +3 -3
  117. package/dist/src/runner-client.js +1 -1
  118. package/dist/src/runner-disposal.js +1 -1
  119. package/dist/src/runner-lease.js +1 -1
  120. package/dist/src/runtime.js +2 -2
  121. package/dist/src/runtime2.js +4 -0
  122. package/dist/src/runtime3.js +3 -0
  123. package/dist/src/runtime4.js +1 -0
  124. package/dist/src/runtime5.js +1 -0
  125. package/dist/src/runtime6.js +1 -0
  126. package/dist/src/runtime7.js +1 -0
  127. package/dist/src/screenshot-result.js +4 -4
  128. package/dist/src/screenshot.js +1 -0
  129. package/dist/src/sdk-android-adb.js +2 -2
  130. package/dist/src/sdk-batch-runner.js +3 -3
  131. package/dist/src/sdk-contracts.d.ts +31 -5
  132. package/dist/src/sdk-contracts.js +1 -1
  133. package/dist/src/sdk-device.js +1 -1
  134. package/dist/src/sdk-finders.js +1 -1
  135. package/dist/src/sdk-remote-config.js +1 -1
  136. package/dist/src/sdk-selectors.d.ts +280 -4
  137. package/dist/src/sdk-selectors.js +1 -1
  138. package/dist/src/selector-runtime.js +1 -1
  139. package/dist/src/selector-vocabulary.js +1 -1
  140. package/dist/src/selectors.js +1 -1
  141. package/dist/src/server.js +3 -3
  142. package/dist/src/session-target-evidence.js +1 -1
  143. package/dist/src/session.js +10 -9
  144. package/dist/src/shared.js +2 -0
  145. package/dist/src/shell-quote.js +1 -0
  146. package/dist/src/simulator.js +1 -1
  147. package/dist/src/snapshot-runtime.js +1 -0
  148. package/dist/src/snapshot-session.js +1 -0
  149. package/dist/src/snapshot.js +1 -1
  150. package/dist/src/snapshot2.js +1 -1
  151. package/dist/src/src.js +1 -1
  152. package/dist/src/src2.js +2 -0
  153. package/dist/src/src3.js +1 -0
  154. package/dist/src/text-surface.js +1 -1
  155. package/dist/src/timing-safe-equal.js +1 -0
  156. package/dist/src/tool-provider.js +3 -3
  157. package/dist/src/tool-provider2.js +1 -1
  158. package/dist/src/tool-provider3.js +1 -1
  159. package/dist/src/update-check.js +1 -1
  160. package/dist/src/version.js +1 -1
  161. package/dist/src/web.js +1 -1
  162. package/package.json +36 -20
  163. package/server.json +2 -2
  164. package/skills/agent-device/SKILL.md +6 -31
  165. package/android/ime-helper/dist/agent-device-android-ime-helper-0.20.6.apk.sha256 +0 -1
  166. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.20.6.apk.sha256 +0 -1
  167. package/dist/src/app-log-request-scope.js +0 -1
  168. package/dist/src/devices.js +0 -1
  169. package/dist/src/devices2.js +0 -1
  170. package/dist/src/devices3.js +0 -1
  171. package/dist/src/devices4.js +0 -1
  172. package/dist/src/provider-limrun-runtime.js +0 -1
  173. package/dist/src/register-builtins.js +0 -1
  174. package/dist/src/screenshot-geometry.js +0 -1
  175. package/dist/src/viewport-dimension.js +0 -15
@@ -1,3 +1,3 @@
1
- import{_ as e,a as t,i as n,u as r,v as i}from"./sdk-contracts.js";function a(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function o(t,n,r,i){let a=r(t[n]);if(a===void 0)throw new e(`COMMAND_FAILED`,i,{response:t});return a}function s(e,t,n){return n(e[t])}function c(e,t,n){let r=e[t];return r===null?null:n(r)}function l(e,t){return o(e,t,oe,`Daemon response is missing "${t}".`)}function u(e,t){return s(e,t,oe)}function d(e,t){return c(e,t,oe)}function ee(e,t){return o(e,t,se,`Daemon response is missing numeric "${t}".`)}function te(e,t){return o(e,t,ce,`Daemon response has invalid "${t}".`)}function ne(e,t){return o(e,t,le,`Daemon response has invalid "${t}".`)}function re(e,t){return s(e,t,ue)??`mobile`}function ie(e){if(!p(e))return;let t=f(e,`x`),n=f(e,`y`),r=f(e,`width`),i=f(e,`height`);if(!(t===void 0||n===void 0||r===void 0||i===void 0))return{x:t,y:n,width:r,height:i}}function ae(e){if(!p(e))return;let t=f(e,`x`),n=f(e,`y`);if(!(t===void 0||n===void 0))return{x:t,y:n}}function f(e,t){let n=e[t];return typeof n==`number`?n:void 0}function oe(e){return typeof e==`string`&&e.length>0?e:void 0}function se(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function ce(e){return e===`apple`?`ios`:e===`ios`||e===`macos`||e===`android`||e===`vega`||e===`linux`||e===`web`?e:void 0}function le(e){return e===`simulator`||e===`emulator`||e===`device`?e:void 0}function ue(e){return e===`tv`||e===`mobile`||e===`desktop`?e:void 0}function de(t){if(!p(t))throw new e(`COMMAND_FAILED`,`Daemon returned an unexpected response shape.`,{value:t});return t}function p(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fe(e){return p(e)?e:void 0}function pe(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function me(e){return e.split(`
2
- `).map(e=>e.trim()).filter(e=>e.length>0)}function he(e){let t=`${e??``}`.toLowerCase();return t.includes(`scroll`)||t.includes(`recyclerview`)||t.includes(`listview`)||t.includes(`gridview`)||t.includes(`collectionview`)||t===`table`}function ge(e){return he(e.type)?!0:`${e.role??``} ${e.subrole??``}`.toLowerCase().includes(`scroll`)}function m(e){return new Map(e.map(e=>[e.index,e]))}function _e(e,t,n,r){let i=t,a=new Set;for(;typeof i.parentIndex==`number`&&!a.has(i.index);){if(a.add(i.index),i=n.get(i.parentIndex)??e[i.parentIndex],!i)return null;let t=r(i);if(t!==null)return t}return null}function h(e){return!!(e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&e.width>0&&e.height>0)}function ve(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}function ye(e){return e.width*e.height}function be(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function g(e){let t=null,n=-1;for(let r of e){let e=r.width*r.height;e>n&&(t=r,n=e)}return t}function xe(e,t){return Se(e.x,e.x+e.width,t.x,t.x+t.width)&&Se(e.y,e.y+e.height,t.y,t.y+t.height)}function Se(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function _(e){let t=e.trim().replace(/XCUIElementType/gi,``).replace(/^AX/,``).toLowerCase(),n=Math.max(t.lastIndexOf(`.`),t.lastIndexOf(`/`));return n!==-1&&(t=t.slice(n+1)),t}function Ce(e,t){let n=_(e);return n?t===`android`?n.includes(`edittext`)||n.includes(`autocompletetextview`):n.includes(`textfield`)||n.includes(`securetextfield`)||n.includes(`searchfield`)||n.includes(`textview`)||n.includes(`textarea`)||n===`search`:!0}function v(e){return[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).filter(e=>e.length>0)[0]??``}function we(e){let t=[e.type,e.role,e.subrole].map(e=>_(e??``)).join(` `);return t.includes(`application`)||t.includes(`window`)}function y(e,t){let n=r(t),i=e.flatMap(e=>Te(e.rect)?[{node:e,rect:e.rect}]:[]),a=i.filter(e=>we(e.node)).map(e=>e.rect),o=e=>be(e,n.x,n.y);return g(a.filter(o))??g(a)??g(i.map(e=>e.rect).filter(o))}function Te(e){return e?Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height):!1}function Ee(e,t,n=m(t)){if(!e.rect)return!0;let r=ke(e,t,n);return r?xe(e.rect,r):!0}function De(e,t,n=m(t)){if(!e.rect)return!0;if(!Ee(e,t,n))return!1;let r=y(t,e.rect);return Oe(e.rect,r)}function Oe(e,t){return!t||t.width<=0||t.height<=0?!0:be(t,e.x+e.width/2,e.y+e.height/2)}function ke(e,t,n=m(t)){return Ae(e,n,e=>!!e.rect)?.rect||y(t,e.rect??{x:0,y:0,width:0,height:0})}function Ae(e,t,n=()=>!0){let r=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);){if(i.add(r.index),n(r)&&ge(r))return r;r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}return null}function je(e,t){if(t===`android`&&e.visibleToUser===!1)return!1;let n=_(e.type??``);return n.includes(`application`)||n.includes(`window`)||n.includes(`scrollview`)||n.includes(`tableview`)||n.includes(`collectionview`)||n===`table`||n===`list`||n===`listview`?!1:t===`android`?e.hittable===!0&&h(e.rect):e.hittable===!0||h(e.rect)}function b(e){return e.hittable===!0?!0:e.rect?e.rect.width>0&&e.rect.height>0:!1}function Me(e,t){return Ce(e.type??``,t)&&e.enabled!==!1}const Ne=new Set([`id`,`role`,`text`,`label`,`value`,`appname`,`windowtitle`]),Pe=new Set([`visible`,`hidden`,`editable`,`selected`,`focused`,`enabled`,`hittable`]),x=new Set([...Ne,...Pe]),Fe=[...x],Ie=new Set(`button.imagebutton.link.cell.statictext.checkedtextview.textfield.textbox.edittext.textarea.switch.slider.image.imageview.webview.framelayout.linearlayout.relativelayout.constraintlayout.viewgroup.view.listview.recyclerview.collectionview.list.searchfield.segmentedcontrol.group.window.checkbox.radio.menuitem.toolbar.scrollarea.scrollview.nestedscrollview.table.application.navigationbar.tabbar.tab.alert.dialog.header`.split(`.`));function Le(e){return Ie.has(e.trim().toLowerCase())}const Re=new Map([[`"`,`"`],[`'`,`'`],[`\\`,`\\`],[`/`,`/`],[`b`,`\b`],[`f`,`\f`],[`n`,`
3
- `],[`r`,`\r`],[`t`,` `]]);function S(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=Ue(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>Ve(e))}}function C(e){try{return S(e)}catch{return null}}function ze(e){let t=e.trim();if(!t)return!1;if(t===`||`)return!0;let n=t.indexOf(`=`);if(n!==-1){let e=t.slice(0,n).trim().toLowerCase();return x.has(e)}return x.has(t.toLowerCase())}function Be(e){let t=e.trim(),n=t.indexOf(`=`);if(n===-1)return null;let r=t.slice(0,n).trim().toLowerCase();if(!r||x.has(r))return null;let i=t.slice(n+1).trim();if(!i)return null;let a=Ke(i).trim();return a?{key:r,value:a}:null}function w(e,t={}){if(e.length===0)return null;let n=t.preferTrailingValue??!1,r=0,i=[];for(;r<e.length;){let t=e[r];if(t===void 0||!ze(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&C(n)&&i.push(r)}if(i.length===0)return null;let a=i.at(-1);if(a===void 0)return null;let o=a;if(n)for(let t=i.length-1;t>=0;--t){let n=i[t];if(n!==void 0&&n<e.length){o=n;break}}let s=e.slice(0,o).join(` `).trim();return s?{selectorExpression:s,rest:e.slice(o)}:null}function Ve(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=We(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(He)}}function He(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Empty selector term`);let r=n.indexOf(`=`);if(r===-1){let r=n.toLowerCase();if(!Pe.has(r))throw new e(`INVALID_ARGS`,`Invalid selector term "${t}", expected key=value`);return{key:r,value:!0}}let i=n.slice(0,r).trim().toLowerCase(),a=n.slice(r+1).trim();if(!x.has(i))throw new e(`INVALID_ARGS`,`Unknown selector key: ${i}`);if(!a)throw new e(`INVALID_ARGS`,`Missing selector value for key: ${i}`);if(Pe.has(i)){let t=Ye(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:Ke(a)}}function Ue(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!Xe(t,a)){i=Ge(i,o),r+=o;continue}if(!i&&o===`|`&&t[a+1]===`|`){let i=r.trim();if(!i)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);n.push(i),r=``,a+=1;continue}r+=o}let a=r.trim();if(!a)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);return n.push(a),n}function We(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!Xe(t,e)){i=Ge(i,a),r+=a;continue}if(!i&&/\s/.test(a)){r.trim()&&n.push(r.trim()),r=``;continue}r+=a}if(i)throw new e(`INVALID_ARGS`,`Unclosed quote in selector: ${t}`);return r.trim()&&n.push(r.trim()),n}function Ge(e,t){return e?e===t?null:e:t}function Ke(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?qe(t.slice(1,-1)):t}function qe(e){let t=``,n=0;for(;n<e.length;){let r=e.charAt(n);if(r!==`\\`){t+=r,n+=1;continue}let i=e.charAt(n+1);if(!i){t+=r,n+=1;continue}let a=Je(i);if(a!==null){t+=a,n+=2;continue}if(i===`u`){let r=e.slice(n+2,n+6);if(/^[0-9a-fA-F]{4}$/.test(r)){t+=String.fromCharCode(Number.parseInt(r,16)),n+=6;continue}}t+=r,n+=1}return t}function Je(e){return Re.get(e)??null}function Ye(e){let t=Ke(e).toLowerCase();return t===`true`?!0:t===`false`?!1:null}function Xe(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}const Ze=[`any`,`text`,`label`,`value`,`role`,`id`],Qe=[`text`,`label`,`value`,`role`,`id`];function $e(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function et(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function tt(e,t,n,r={}){let i=E(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=nt(n,t,i);if(!(e<=0)){if(e>a){a=e,o.length=0,o.push(n);continue}e===a&&o.push(n)}}return{matches:o,score:a}}function nt(e,t,n){switch(t){case`role`:return rt(e.type,n);case`label`:return T(e.label,n);case`value`:return T(e.value,n);case`id`:return T(e.identifier,n);default:return Math.max(T(e.label,n),T(e.value,n),T(e.identifier,n))}}function T(e,t){let n=E(e??``);return n?n===t?2:+!!n.includes(t):0}function rt(e,t){let n=it(e??``);return n?n===t?2:+!!n.includes(t):0}function E(e){return e.trim().toLowerCase().replace(/\s+/g,` `)}function it(e){let t=e.trim();return t?(t=(t.split(`.`).pop()??t).replace(/XCUIElementType/gi,``).toLowerCase(),t):``}const at=`find requires a value`,ot=`find actions: click (default; press/tap are aliases), list, focus, fill, type, exists, wait, get text, get attrs — there is no longpress/swipe find action. Run find "<text>" list to inspect every match with its @ref without acting, then dispatch the gesture on the chosen ref, e.g. longpress @eNN.`;function st(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=D([...e]);return n.query?t?.findFirst&&t?.findLast?{ok:!1,code:`INVALID_ARGS`,message:`find accepts only one of --first or --last`}:{ok:!0,parsed:n}:{ok:!1,code:`INVALID_ARGS`,message:at}}const ct=[`exists`,`list`,`click`,`focus`];function lt(e){return ct.includes(e)}function D(t){let n=`any`,r=0;Qe.includes(t[0])&&(n=t[0],r=1);let i=t[r]??``,a=t.slice(r+1);if(a.length===0)return{locator:n,query:i,action:`click`};let o=$e(a[0]);if(lt(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:ut(a[1])};if(o===`wait`){let e=ft(a[1]);return{locator:n,query:i,action:`wait`,timeoutMs:e??void 0}}if(o===`fill`||o===`type`)return{locator:n,query:i,action:o,value:a.slice(1).join(` `)};throw new e(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`,{hint:ot})}function ut(t){let n=t?.toLowerCase();if(n===`text`)return`get_text`;if(n===`attrs`)return`get_attrs`;throw new e(`INVALID_ARGS`,`find get only supports text or attrs`)}function dt(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:C(t)?t:null}function ft(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function O(e,t,n){return t.terms.every(t=>pt(e,t,n))}function pt(e,t,n){switch(t.key){case`id`:return k(e.identifier,String(t.value));case`role`:return k(_(e.type??``),String(t.value));case`label`:return k(e.label,String(t.value));case`value`:return k(e.value,String(t.value));case`text`:return k(v(e),String(t.value));case`appname`:return k(e.appName,String(t.value));case`windowtitle`:return k(e.windowTitle,String(t.value));case`visible`:return b(e)===!!t.value;case`hidden`:return!b(e)==!!t.value;case`editable`:return Me(e,n)===!!t.value;case`selected`:return e.selected===!0==!!t.value;case`focused`:return e.focused===!0==!!t.value;case`enabled`:return e.enabled!==!1==!!t.value;case`hittable`:return e.hittable===!0==!!t.value;default:return!1}}function k(e,t){return E(e??``)===E(t)}function A(e,t,n){let r=n.requireRect??!1,i=n.requireUnique??!0,a=[];for(let[o,s]of t.selectors.entries()){let t=vt(e,s,n.platform,r);if(a.push({selector:s.raw,matches:t.count}),!(t.count===0||!t.firstNode)){if(i&&t.count!==1){if(!n.disambiguateAmbiguous||!t.disambiguated||!t.tiebreak)continue;return{node:t.disambiguated,selector:s,selectorIndex:o,matches:t.count,diagnostics:a,disambiguation:{matchCount:t.count,tiebreak:t.tiebreak,alternatives:t.candidates.filter(e=>e!==t.disambiguated)}}}return{node:t.firstNode,selector:s,selectorIndex:o,matches:t.count,diagnostics:a}}}return null}function j(e,t,n){let r=n.requireRect??!1;for(let[i,a]of t.selectors.entries()){let t=e.filter(e=>r&&!e.rect?!1:O(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function mt(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=St(e,o,n.platform,r);if(i.push({selector:o.raw,matches:t}),t>0)return{selectorIndex:a,selector:o,matches:t,diagnostics:i}}return null}const ht=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function gt(e){return e.some(e=>e.matches>1)?`Add more terms to disambiguate (e.g. role=button text="Sign in"), use an @ref from snapshot -i, or use find <text> --first/--last.`:`Selector text/label values match exactly (quote multi-word values: text="Sign in"). Run snapshot -i to see current elements and refs, or use find <text> for contains matching.`}function _t(e,t,n){if(t.length===0)return`Selector did not match: ${e}`;let r=t.map(e=>`${e.selector} -> ${e.matches}`).join(`, `);return n.unique??!0?`Selector did not resolve uniquely (${r})`:`Selector did not match (${r})`}function vt(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c,l=t=>(c??=m(e),De(t,e,c));for(let c of e)r&&!c.rect||O(c,t,n)&&(i+=1,a??=c,o.push(c),yt(s,c,l));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:bt(o,s.best,l),candidates:o}}function yt(e,t,n){if(!e.best){e.best=t;return}e.bestVisible||=n(e.best);let r=n(t);if(r!==e.bestVisible){r&&(e.best=t,e.bestVisible=!0,e.tie=!1);return}let i=Ct(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function bt(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||xt(i,r,n).result>0)&&(r=i);return r?xt(t,r,n).criterion:null}function xt(e,t,n){let r=n(e);return r===n(t)?Ct(e,t):{result:r?1:-1,criterion:`visible`}}function St(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||O(a,t,n)&&(i+=1);return i}function Ct(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=wt(e),a=wt(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function wt(e){return e.rect?e.rect.width*e.rect.height:1/0}function Tt(e,t,n,r){let i={...r,requireRect:n.requireRect};if(n.ambiguity===`reject-candidates`){let n=j(e,t,i);return!n||n.matchedNodes.length===0?{kind:`none`}:n.matchedNodes.length>1?{kind:`ambiguous`,selector:n.selector.raw,selectorIndex:n.selectorIndex,matchedNodes:n.matchedNodes}:Et(n)}if(n.ambiguity===`first-match`){let n=j(e,t,i);return!n||n.matchedNodes.length===0?{kind:`none`}:Et(n)}let a=A(e,t,{...i,requireUnique:!0,disambiguateAmbiguous:n.ambiguity===`disambiguate`});if(a)return{kind:`resolved`,resolution:a,matchedNodes:j(e,t,i)?.matchedNodes??[a.node]};let o=j(e,t,i);return!o||o.matchedNodes.length===0?{kind:`none`}:{kind:`ambiguous`,selector:o.selector.raw,selectorIndex:o.selectorIndex,matchedNodes:o.matchedNodes}}function Et(e){let t=e.matchedNodes[0];return t?{kind:`resolved`,matchedNodes:e.matchedNodes,resolution:{node:t,selector:e.selector,selectorIndex:e.selectorIndex,matches:e.matchedNodes.length,diagnostics:[{selector:e.selector.raw,matches:e.matchedNodes.length}]}}:{kind:`none`}}function M(e,t){return{ok:!1,code:`INVALID_ARGS`,message:e,...t?{hint:t}:{}}}function Dt(e){return[`visible`,`hidden`,`exists`,`editable`,`selected`,`focused`,`text`].includes(e)}function Ot(e){let t=e.toLowerCase();return Dt(t)?{ok:!0,predicate:t}:M(`is requires predicate: visible|hidden|exists|editable|selected|focused|text`,kt)}const kt=`Use "is <predicate> <selector>" or "is <selector> <predicate>". visible|hidden|editable|selected|focused double as selector keys: a bare predicate token after the selector is read as the predicate, so write key=true (e.g. visible=true) inside the selector to use it as a filter instead.`;function At(e){if(Dt((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(Dt(n)&&C(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function jt(e){let{predicate:t,node:n,nodes:r,expectedText:i,platform:a}=e,o=v(n),s=Me(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?b(n):Mt(n,r,a),d=!1;switch(t){case`visible`:d=u;break;case`hidden`:d=!u;break;case`editable`:d=s;break;case`selected`:d=c;break;case`focused`:d=l;break;case`text`:d=o===(i??``);break}let ee=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:ee}}function Mt(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(h(e.rect))return Nt(e,t);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=Pt(e,t,n);return r?h(r.rect)?Nt(r,t):n!==`android`&&r.hittable===!0:!1}function Nt(e,t){return Ee(e,t)}function Pt(e,t,n){return _e(t,e,m(t),e=>je(e,n)?e:null)}function Ft(e){let t=At(e),n=t[0]??``;return{predicate:n,split:w(t.slice(1),{preferTrailingValue:n===`text`})}}const It=`is requires a selector expression`,Lt=`is text requires expected text value`;function Rt(e){let{predicate:t,split:n}=Ft([...e]),r=Ot(t);if(!r.ok)return r;if(!n)return M(It);let i=n.rest.join(` `).trim();return r.predicate===`text`&&!i?M(Lt):r.predicate!==`text`&&n.rest.length>0?M(`is ${r.predicate} does not accept trailing values`):{ok:!0,predicate:r.predicate,selectorExpression:n.selectorExpression,expectedText:i}}function zt(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:M(`get only supports text or attrs`)}function Bt(e){let t=e[0];if(t?.startsWith(`@`)){let n=e.slice(1).join(` `).trim();return{ok:!0,ref:t,...n?{label:n}:{}}}let n=e.join(` `).trim();return n?{ok:!0,selector:n}:M(`get requires @ref or selector expression`)}function Vt(e){return e?{ok:!0,text:e}:M(`wait requires text`)}function Ht(t,n,r={}){let i=t[n];if(i===void 0)return;if(!Number.isInteger(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be an integer.`);let a=i;if(r.min!==void 0&&a<r.min)throw new e(`INVALID_ARGS`,`Expected ${n} to be at least ${r.min}.`);if(r.max!==void 0&&a>r.max)throw new e(`INVALID_ARGS`,`Expected ${n} to be at most ${r.max}.`);return a}function Ut(t,n,r={}){let i=t[n];if(i!==void 0){if(typeof i!=`number`||!Number.isFinite(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be a finite number.`);if(r.min!==void 0&&i<r.min)throw new e(`INVALID_ARGS`,`Expected ${n} to be at least ${r.min}.`);if(r.max!==void 0&&i>r.max)throw new e(`INVALID_ARGS`,`Expected ${n} to be at most ${r.max}.`);return i}}const Wt=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,Gt=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,Kt=4096;function qt(e){return e.normalize(`NFC`)}function Jt(e){if(e===void 0)return;let t=qt(e);return t.length>0?t:void 0}function Yt(e){return qt(e)}function Xt(e){if(e===void 0)return;let t=qt(e).trim().replace(/\s+/g,` `);return t.length>0?t:void 0}function N(e){return Buffer.byteLength(e,`utf8`)}function Zt(e,t){if(N(e)<=t)return e;let n=e.length;for(;n>0&&N(e.slice(0,n))>t;)--n;if(n>0){let t=e.charCodeAt(n-1);t>=55296&&t<=56319&&--n}return e.slice(0,n)}function Qt(e){let t={};return e.id!==void 0&&(t.id=e.id),t.role=e.role,e.label!==void 0&&(t.label=e.label),t.ancestry=e.ancestry.map($t),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=en(e.scrollRegion)),e.rect&&(t.rect=tn(e.rect)),t.verification=e.verification,t}function $t(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function en(e){let t={role:e.role};return e.id!==void 0&&(t.id=e.id),e.label!==void 0&&(t.label=e.label),t}function tn(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function nn(e){return JSON.stringify(Qt(e))}function rn(e){return`# agent-device:target-v1 ${nn(e)}`}function an(e){return JSON.stringify({source:Qt(e.source),destination:Qt(e.destination)})}function on(e){return`# agent-device:targets-v1 ${an(e)}`}function sn(e){let t=e.trim(),n=Gt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:cn((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function cn(t){if(N(t)>8320)throw new e(`INVALID_ARGS`,`targets-v1 annotation exceeds the 8320-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`targets-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`targets-v1 annotation must be a JSON object.`);let r=n;if(r.source===void 0||r.destination===void 0)throw new e(`INVALID_ARGS`,`targets-v1 annotation requires source and destination evidence.`);return{source:un(JSON.stringify(r.source)),destination:un(JSON.stringify(r.destination))}}function ln(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=Wt.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:un((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function un(t){if(N(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${Kt}-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`target-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`target-v1 annotation must be a JSON object.`);let r=n,i=dn(r.role,`role`),a=fn(r.id,`id`),o=pn(r.label,`label`),s=hn(r.ancestry),c=_n(r.sibling,`sibling`,0),l=_n(r.viewportOrder,`viewportOrder`,0),u=vn(r.scrollRegion),d=yn(r.rect),ee=bn(r.verification);return{...a===void 0?{}:{id:a},role:i,...o===void 0?{}:{label:o},ancestry:s,sibling:c,viewportOrder:l,...u?{scrollRegion:u}:{},...d?{rect:d}:{},verification:ee}}function dn(t,n){if(t===void 0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" is required.`);if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);return mn(Yt(t),n)}function fn(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=Jt(t);return r===void 0?void 0:mn(r,n)}function pn(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=Xt(t);return r===void 0?void 0:mn(r,n)}function mn(t,n){if(N(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function hn(t){if(t===void 0)return[];if(!Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry" must be an array.`);if(t.length>8)throw new e(`INVALID_ARGS`,`target-v1 "ancestry" exceeds the 8-entry cap.`);return t.map((e,t)=>gn(e,t))}function gn(t,n){if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry[${n}]" must be an object.`);let r=t,i=dn(r.role,`ancestry[${n}].role`),a=pn(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function _n(t,n,r){if(t===void 0)return r;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a non-negative integer.`);return t}function vn(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "scrollRegion" must be an object.`);let n=t,r=dn(n.role,`scrollRegion.role`),i=fn(n.id,`id`),a=pn(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function yn(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "rect" must be an object.`);let n=t;return{x:P(n.x,`rect.x`),y:P(n.y,`rect.y`),width:P(n.width,`rect.width`),height:P(n.height,`rect.height`)}}function P(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a finite number.`);return t}function bn(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function xn(e){let t=Yt(_(e.type??``)),n=Jt(e.identifier),r=Xt(e.label);return{...n===void 0?{}:{id:Zt(n,256)},role:Zt(t,256),...r===void 0?{}:{label:Zt(r,256)}}}function Sn(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function Cn(e,t){let n=0;for(let r of e)xn(r).id===t&&(n+=1);return n}function wn(e,t){if(e.id===void 0||Cn(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function Tn(e,t){let n=0;for(let r of e)if(r.parentIndex===t.parentIndex){if(r.index===t.index)return n;n+=1}return 0}function En(e,t){return{documentOrder:e.index,sibling:Tn(t,e)}}function Dn(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function On(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function kn(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function An(e,t){if(e.length<t.length)return!1;for(let[n,r]of t.entries()){let t=e[n];if(!t||t.role!==r.role||r.label!==void 0&&t.label!==r.label)return!1}return!0}function jn(e,t){let n=[];return e.id!==t.id&&n.push(`id: recorded=${e.id??`(none)`} observed=${t.id??`(none)`}`),e.role!==t.role&&n.push(`role: recorded=${e.role} observed=${t.role}`),e.label!==t.label&&n.push(`label: recorded=${e.label??`(none)`} observed=${t.label??`(none)`}`),n}function Mn(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function Nn(e,t){return!t||t.role!==e.role?!0:e.label!==void 0&&t.label!==e.label}function Pn(e,t){for(let[n,r]of e.entries()){let e=t[n];if(Nn(r,e))return[`ancestry[${n}]: recorded=${Mn(r)} observed=${Mn(e)}`]}return[]}function Fn(e,t,n={}){let r=[],i=_(e.type??``),a=In(e,n.nodes),o=I(e.label),s=I(e.value),c=I(v(e)),l=n.action===`fill`;a&&r.push(`id=${F(a)}`),i&&o&&r.push(l?`role=${F(i)} label=${F(o)} editable=true`:`role=${F(i)} label=${F(o)}`),o&&r.push(l?`label=${F(o)} editable=true`:`label=${F(o)}`),s&&r.push(l?`value=${F(s)} editable=true`:`value=${F(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${F(c)} editable=true`:`text=${F(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${F(i)} editable=true`);let u=Ln(r);return u.length===0&&i&&u.push(l?`role=${F(i)} editable=true`:`role=${F(i)}`),u.length===0&&b(e)&&u.push(`visible=true`),u}function In(e,t){let n=I(e.identifier);if(!n||!t)return n;let r=xn(e).id;return r===void 0?n:Cn(t,r)>1?null:n}function Ln(e){return Array.from(new Set(e))}function F(e){return JSON.stringify(e)}function I(e){return e&&e.trim()||null}function Rn(e,t){let n=e===`is`?Ft([...t]).split:w([...t]);return n?C(n.selectorExpression)?{kind:`expression`,expression:n.selectorExpression,rest:n.rest}:{kind:`invalid`}:{kind:`not-applicable`}}function zn(e,t,n){let r=C(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let i=A(t,r,{platform:n.platform,requireRect:n.requireRect,requireUnique:!0,disambiguateAmbiguous:n.allowDisambiguation});if(i){let e=t.filter(e=>n.requireRect&&!e.rect?!1:O(e,i.selector,n.platform));return{kind:`resolved`,winner:i.node,matchedNodes:e,matchCount:e.length,...i.disambiguation?{disambiguation:{tiebreak:i.disambiguation.tiebreak,matchCount:i.disambiguation.matchCount,alternatives:i.disambiguation.alternatives}}:{}}}let a=j(t,r,{platform:n.platform,requireRect:n.requireRect})?.matchedNodes??[];return{kind:`unresolved`,reason:a.length>0?`ambiguous`:`no-match`,matchedNodes:a}}function Bn(e,t,n={}){return Fn(e,t,n)}function Vn(e,t,n){let r=C(e);if(!r)return;let i=A(t,r,{platform:n.platform,requireRect:n.requireRect,requireUnique:!0,disambiguateAmbiguous:n.allowDisambiguation});if(i)return{node:i.node,basis:Un(i.selector)}}function Hn(e){if(!e)return;let t=C(e);if(!t)return;let n=t.selectors.flatMap(e=>e.terms.flatMap(e=>(e.key===`label`||e.key===`text`||e.key===`id`)&&typeof e.value==`string`?[e.value]:[]));if(n.length===0)return;let r=n[0];return r&&n.every(e=>e===r)?r:void 0}function Un(e){let t=new Set(e.terms.map(e=>e.key));if(t.has(`id`))return`id`;let n=t.has(`role`),r=t.has(`label`)||t.has(`text`);return n&&r?`role-label`:r||t.has(`value`)?`label`:`other`}const Wn={act:{ambiguity:`disambiguate`,requireRect:!0},actCoveredDiagnosis:{ambiguity:`first-match`,requireRect:!0},readText:{ambiguity:`disambiguate`,requireRect:!1},readUnique:{ambiguity:`fail-closed`,requireRect:!1},readAny:{ambiguity:`first-match`,requireRect:!1},wait:{ambiguity:`first-match`,requireRect:!1},findAct:{ambiguity:`reject-candidates`,requireRect:!0}};function Gn(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function Kn(e,t){let n=C(e);if(!n)return e.includes(`=`)||e.includes(`||`)?null:e;let r=new Set(t.textKeys);return n.selectors.length>1?qn(n.selectors,r):Jn(n.selectors[0],r,new Set(t.booleanKeys))}function qn(e,t){let n=e.map(e=>{let n=e.terms.length===1?e.terms[0]:void 0;return n&&t.has(n.key)&&typeof n.value==`string`?n.value:void 0}),r=n[0];return r!==void 0&&n.every(e=>e===r)?r:null}function Jn(e,t,n){if(!e)return null;let r={},i=0;for(let a of e.terms){if(Yn(a,t,`string`))i+=1;else if(!Yn(a,n,`boolean`))return null;r[a.key]=a.value}return i<=1&&Object.keys(r).length>0?r:null}function Yn(e,t,n){return t.has(e.key)&&typeof e.value===n}function Xn(e){let t=C(e);if(!t||t.selectors.length!==1)return null;let n=t.selectors[0];if(!n||n.terms.length!==1)return null;let r=n.terms[0];return!r||typeof r.value!=`string`||r.key!==`id`&&r.key!==`label`&&r.key!==`text`&&r.key!==`value`?null:{key:r.key,value:r.value,raw:n.raw}}function Zn(e,t){if(!t)return!1;let n=C(e);return n?n.selectors.some(e=>e.terms.some(e=>(e.key===`text`||e.key===`label`||e.key===`value`)&&typeof e.value==`string`&&e.value.includes(t))):!1}function Qn(e){return S(e).selectors.map(e=>e.raw)}function $n(e){return C(e)!==null}function er(e,t,n){let r=mt(e,S(t),n);return r?{...r,selector:r.selector.raw}:null}function tr(e,t,n){let r=j(e,S(t),n);return r?{...r,selector:r.selector.raw}:null}function nr(e,t,n){let r=A(e,S(t),n);return r?{...r,selector:r.selector.raw}:null}function rr(e,t,n,r){let i=Tt(e,S(t),n,r);return i.kind===`resolved`?{...i,resolution:{...i.resolution,selector:i.resolution.selector.raw}}:i}function L(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function ir(e){let t=e[0];if(t===void 0)return null;let n=L(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=L(e[e.length-1]);if(t===`text`)return{kind:`text`,text:(r===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:r};if(t===`stable`){let t=e.slice(1),n=t.length>1?L(t[1]):null;return{kind:`stable`,quietMs:t.length>0?L(t[0]):null,timeoutMs:n}}if(t.startsWith(`@`))return{kind:`ref`,rawRef:t,timeoutMs:r};let i=w(r===null?e.slice():e.slice(0,-1));return i&&i.rest.length===0&&$n(i.selectorExpression)?{kind:`selector`,selectorExpression:i.selectorExpression,timeoutMs:r}:{kind:`text`,text:(r===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:r}}function ar(e){let t=ir(e);return t?t.kind===`sleep`?t.durationMs:t.timeoutMs:null}const or=24e4,R={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},sr={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,scroll:`settle`,back:`settle`};function cr(e){if(e!==void 0)return sr[e]}const z={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},B={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},lr=()=>!0,ur=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,dr=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),fr=new Set([`status`,`get`]),pr=e=>yr(e,fr,`status`),mr=new Set([`get`,`wait`]),hr=e=>yr(e,mr,`get`),gr=e=>br(e,fr,`status`),_r=e=>br(e,mr,`get`),vr=e=>{try{return et(D(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}};function yr(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function br(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const V={simulator:!0,device:!0},H={emulator:!0,device:!0,unknown:!0},U={emulator:!0},W={device:!0},G={},K={apple:V,android:H,linux:W},xr={...K,vega:U},Sr={apple:V,android:H,linux:G},Cr={apple:V,android:H,linux:G},q={recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:R,batchable:!0},J={...R,onTimeout:`preserve-daemon`},Y={...R,envelopeMs:18e4},wr={...R,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},Tr={fields:{count:{defaultValue:1,omitDefault:!0},intervalMs:{defaultValue:0,omitDefault:!0},holdMs:{defaultValue:0,omitDefault:!0},jitterPx:{defaultValue:0,omitDefault:!0},doubleTap:{defaultValue:!1,omitDefault:!0}}},Er={fields:{delayMs:{defaultValue:0}}};function X(e,t){return cr(e)===void 0?t:wr}function Z(e){let t=cr(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const Dr=[{name:`lease_allocate`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...z},timeoutPolicy:R,batchable:!1},{name:`lease_heartbeat`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...z},timeoutPolicy:R,batchable:!1},{name:`lease_release`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...z},timeoutPolicy:R,batchable:!1},{name:`artifacts`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...z},timeoutPolicy:R,batchable:!1},{name:`session_list`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...B},timeoutPolicy:R,batchable:!1},{name:`session_save_script`,catalog:{group:`internal`,key:`sessionSaveScript`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`publication`},timeoutPolicy:R,batchable:!1},{name:`devices`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...B},timeoutPolicy:R,batchable:!0},{name:`capabilities`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...B},timeoutPolicy:R,batchable:!0},{name:`doctor`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,allowSessionlessDefaultDevice:lr,...B},timeoutPolicy:R,batchable:!0},{name:`apps`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0},capability:Sr,timeoutPolicy:R,batchable:!0},{name:`boot`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},capability:{apple:V,android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`shutdown`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},capability:{apple:{simulator:!0},android:{emulator:!0},linux:G},timeoutPolicy:R,batchable:!0},{name:`appstate`,catalog:{group:`public`,key:`appState`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`state`},timeoutPolicy:R,batchable:!0},{name:`perf`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:V,android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`logs`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:V,android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`events`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...B},timeoutPolicy:R,batchable:!1},{name:`network`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:V,android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`audio`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:V,android:{emulator:!0},linux:G},timeoutPolicy:R,batchable:!0},{name:`replay`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:dr,saveScriptFlagOwner:!0},timeoutPolicy:{...R,budget:{source:`flag`}},batchable:!1},{name:`test`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:dr},timeoutPolicy:{...R,envelopeMs:`unbounded`},batchable:!0},{name:`runtime`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:R,batchable:!1},{name:`clipboard`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:R,batchable:!0},{name:`keyboard`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:gr,daemon:{route:`session`,refFrameEffect:pr,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`install`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},capability:Cr,timeoutPolicy:Y,batchable:!0},{name:`reinstall`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},capability:Cr,timeoutPolicy:Y,batchable:!0},{name:`install_source`,catalog:{group:`internal`,key:`installSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},timeoutPolicy:Y,batchable:!1},{name:`release_materialized_paths`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...B},timeoutPolicy:R,batchable:!1},{name:`push`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:{simulator:!0},android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`trigger-app-event`,catalog:{group:`public`,key:`triggerAppEvent`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:V,android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`open`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:lr,saveScriptFlagOwner:!0},dispatch:{},capability:xr,timeoutPolicy:R,batchable:!0},{name:`prepare`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},capability:{apple:V,android:{},linux:G},timeoutPolicy:{budget:{source:`flag`},envelopeMs:or,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1},{name:`batch`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`},timeoutPolicy:R,batchable:!1},{name:`close`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowInvalidRecording:!0,saveScriptFlagOwner:!0},dispatch:{},capability:xr,timeoutPolicy:R,batchable:!0},{name:`snapshot`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},dispatch:{},capability:K,timeoutPolicy:{...J,budget:{source:`flag`}},batchable:!0},{name:`diff`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},capability:K,timeoutPolicy:R,batchable:!0},{name:`wait`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,targetIdentityVerification:`post-resolution`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},capability:K,timeoutPolicy:{...J,budget:{source:`positional-parser`,parser:ar}},batchable:!0},{name:`alert`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:_r,daemon:{route:`snapshot`,refFrameEffect:hr},capability:{apple:V,android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`settings`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`snapshot`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:V,android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`react-native`,catalog:{group:`public`,key:`reactNative`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`reactNative`,refFrameEffect:`may-invalidate`},capability:{apple:V,android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`record`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`,allowInvalidRecording:!0,allowSessionlessDefaultDevice:ur},capability:{apple:V,android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`trace`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:R,batchable:!0},{name:`find`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:vr,daemon:{route:`find`,refFrameEffect:`may-invalidate`},capability:K,timeoutPolicy:J,batchable:!0},{name:`click`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:{apple:V,android:H,linux:W},timeoutPolicy:X(`click`,J),postActionObservation:Z(`click`),responseDataTransform:Tr,batchable:!0},{name:`fill`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:X(`fill`,J),postActionObservation:Z(`fill`),responseDataTransform:Er,batchable:!0},{name:`longpress`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`,key:`longPress`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:{...wr,envelopeMs:21e4},postActionObservation:Z(`longpress`),batchable:!0},{name:`press`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:W},timeoutPolicy:X(`press`,J),postActionObservation:Z(`press`),responseDataTransform:Tr,batchable:!0},{name:`type`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:K,timeoutPolicy:X(`type`,J),batchable:!0},{name:`get`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},capability:K,timeoutPolicy:X(`get`,J),batchable:!0},{name:`read`,catalog:{group:`dispatch-alias`},recordsSessionAction:!1,dispatch:{},timeoutPolicy:R,batchable:!1},{name:`is`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},capability:K,timeoutPolicy:X(`is`,J),batchable:!0},{name:`back`,catalog:{group:`public`},...q,capability:{...q.capability,vega:U},timeoutPolicy:X(`back`,R),postActionObservation:Z(`back`)},{name:`gesture`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,targetIdentityVerification:`pre-dispatch`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:K,timeoutPolicy:R,batchable:!0},{name:`home`,catalog:{group:`public`},...q,capability:{...q.capability,vega:U}},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,vega:U,linux:G},timeoutPolicy:R,batchable:!0},{name:`orientation`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:V,android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`scroll`,catalog:{group:`public`},...q,timeoutPolicy:X(`scroll`,R),postActionObservation:Z(`scroll`)},{name:`swipe`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:{apple:V,android:H,linux:W},timeoutPolicy:R,batchable:!0},{name:`focus`,catalog:{group:`public`},...q},{name:`screenshot`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`},dispatch:{},capability:K,timeoutPolicy:R,batchable:!0},{name:`viewport`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:{},android:{},linux:G},timeoutPolicy:R,batchable:!1},{name:`app-switcher`,catalog:{group:`public`,key:`appSwitcher`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:V,android:H,linux:G},timeoutPolicy:R,batchable:!0},{name:`install-from-source`,catalog:{group:`public`,key:`installFromSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,capability:Cr,timeoutPolicy:R,batchable:!0},{name:`debug`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1},{name:`daemon`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1,mcpExposed:!1},{name:`device`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1,mcpExposed:!1},{name:`metro`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1},{name:`session`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1},{name:`cdp`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1,mcpExposed:!1},{name:`auth`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1,mcpExposed:!1},{name:`connect`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1,mcpExposed:!1},{name:`connection`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1,mcpExposed:!1},{name:`disconnect`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1,mcpExposed:!1},{name:`mcp`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1,mcpExposed:!1},{name:`proxy`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1,mcpExposed:!1},{name:`react-devtools`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1,mcpExposed:!1},{name:`web`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:R,batchable:!1,mcpExposed:!1}],Or=new Set([`public`,`local-cli`]),kr=new Set(Dr.filter(e=>Or.has(Fr(e))).map(e=>e.name)),Q=Dr.map(e=>({...e,mcpExposed:Nr(e)}));function Ar(e){return Q.filter(t=>Fr(t)===e).map(e=>[Ir(e),e.name])}function jr(){return Q.filter(e=>Pr(e)).map(e=>e.name).sort()}const $=new Map(Q.map(e=>[e.name,e]));function Mr(e){return kr.has(e)}function Nr(e){return e.mcpExposed??kr.has(e.name)}function Pr(e){return e.mcpExposed&&Mr(e.name)}function Fr(e){return e.catalog.group}function Ir(e){return e.catalog.key??e.name}const Lr=new Map(Q.map(e=>[e.name,e.timeoutPolicy])),Rr=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function zr(e){if(e!==void 0)return $.get(e)?.postActionObservation}function Br(e){return zr(e)!==void 0}function Vr(e){return zr(e)===`settle-and-verify`}function Hr(e){return e===void 0?R:Lr.get(e)??R}function Ur(e){if(e!==void 0)return Rr.get(e)}function Wr(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function Gr(e){return $.get(e)?.targetIdentityVerification}function Kr(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function qr(){return[...new Set(Array.from(Rr.values()).flatMap(e=>Object.keys(e.fields)))].sort()}function Jr(e){return Number.isInteger(e)&&e>=1&&e<=1e3}function Yr(t,n){if(t>n)throw new e(`INVALID_ARGS`,`batch has ${t} steps; max allowed is ${n}.`)}function Xr(t,n){if(!a(t))throw new e(`INVALID_ARGS`,`Invalid batch step ${n}.`);return t}function Zr(t,n){let r=t.input;if(!a(r))throw new e(`INVALID_ARGS`,`Batch step ${n} input must be an object.`);return r}function Qr(t,r){if(t!==void 0)try{return n.parse(t)}catch(t){throw new e(`INVALID_ARGS`,`Batch step ${r} runtime is invalid: ${t instanceof Error?t.message:String(t)}`)}}function $r(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=/^([A-Za-z][A-Za-z0-9+.-]*):(.+)$/.exec(t);if(!n)return!1;let r=n[1]?.toLowerCase(),i=n[2]??``;return r===`http`||r===`https`||r===`ws`||r===`wss`||r===`ftp`||r===`ftps`?i.startsWith(`//`):!0}function ei(e){let t=e.trim().split(`:`)[0]?.toLowerCase();return t===`http`||t===`https`}function ti(e,t){let n=e?.trim();if(n)return n;if(ei(t))return`com.apple.mobilesafari`}function ni(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function ri(e){let t={};for(let n of e)n.capability&&(t[n.name]=n.capability);return t}function ii(e){return e.filter(e=>e.batchable).map(e=>e.name)}const ai=ii(Q),oi=new Set([`batch`,`replay`]),si=[`command`,`positionals`,`input`,`flags`,`runtime`],ci=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],li=new Set(ai);function ui(e){return li.has(e)}function di(e){return typeof e==`string`?e.trim().toLowerCase():``}function fi(t,n){let r=di(t);if(ui(r))return r;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`)}function pi(t,n){if(oi.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}const mi=new Set(si);async function hi(e,t,n){let r=Si(e.flags),a=r?.batchOnError??`stop`;if(a!==`stop`)return Ci(`INVALID_ARGS`,`Unsupported batch on-error mode: ${a}.`);let o=r?.batchMaxSteps??100;if(!Jr(o))return Ci(`INVALID_ARGS`,`Invalid batch max-steps: ${String(r?.batchMaxSteps)}`);try{let i=gi(r?.batchSteps,o),a=Date.now(),s=[];for(let[r,a]of i.entries()){let o=await xi(e,t,a,n,r+1,r===i.length-1);if(!o.ok)return{ok:!1,error:{code:o.error.code,message:`Batch failed at step ${o.step} (${a.command}): ${o.error.message}`,hint:o.error.hint,diagnosticId:o.error.diagnosticId,logPath:o.error.logPath,details:{...o.error.details??{},step:o.step,command:a.command,positionals:a.positionals,executed:r,total:i.length,partialResults:s}}};s.push(o.result)}return{ok:!0,data:{total:i.length,executed:i.length,totalDurationMs:Date.now()-a,results:s}}}catch(e){let t=i(e);return Ci(t.code,t.message,t.details)}}function gi(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty batchSteps array.`);Yr(t.length,n);let r=[];for(let n=0;n<t.length;n+=1){let i=t[n];if(!p(i))throw new e(`INVALID_ARGS`,`Invalid batch step at index ${n}.`);let a=Object.keys(i).filter(e=>!mi.has(e));if(a.length>0){let t=a.map(e=>`"${e}"`).join(`, `);throw new e(`INVALID_ARGS`,`Batch step ${n+1} has unknown field(s): ${t}. Allowed fields: command, positionals, input, flags, runtime.`)}let o=di(i.command);if(!o)throw new e(`INVALID_ARGS`,`Batch step ${n+1} requires command.`);if(pi(o,n+1),i.positionals!==void 0&&!Array.isArray(i.positionals))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must be an array.`);let s=i.positionals??[];if(s.some(e=>typeof e!=`string`))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must contain only strings.`);if(i.flags!==void 0&&!p(i.flags))throw new e(`INVALID_ARGS`,`Batch step ${n+1} flags must be an object.`);if(i.input!==void 0&&!p(i.input))throw new e(`INVALID_ARGS`,`Batch step ${n+1} input must be an object.`);r.push({command:o,positionals:s,input:i.input,flags:i.flags??{},runtime:Qr(i.runtime,n+1)})}return r}function _i(e,t){let{batchSteps:n,batchOnError:r,batchMaxSteps:i,...a}=t??{};return vi(Si(e),a)}function vi(e,t){let n=Si(e)??{},r=t;for(let e of ci)r[e]===void 0&&n[e]!==void 0&&(r[e]=n[e]);return t}function yi(e,n){return t(e)?n?e:`digest`:e}function bi(e,t){let n=e?.responseLevel,r=yi(n,t);return r===n?e:{...e,responseLevel:r}}async function xi(e,t,n,r,i,a){let o=Date.now(),s=_i(e.flags,n.flags);s.session===void 0&&(s.session=t);let c=await r({token:e.token,session:t,command:n.command,positionals:n.positionals,input:n.input,flags:s,runtime:n.runtime===void 0?e.runtime:n.runtime,meta:bi(e.meta,a)}),l=Date.now()-o;return c.ok?{ok:!0,step:i,result:{step:i,command:n.command,ok:!0,data:c.data??{},durationMs:l}}:{ok:!1,step:i,error:c.error}}function Si(e){return e}function Ci(e,t,n){return{ok:!1,error:{code:e,message:t,...n?{details:n}:{}}}}export{kn as $,Ce as $t,$n as A,st as At,Bn as B,S as Bt,Ur as C,me as Cn,mt as Ct,ir as D,Ze as Dt,or as E,gt as Et,nr as F,dt as Ft,Fn as G,Ae as Gt,Rn as H,C as Ht,rr as I,Fe as It,wn as J,Oe as Jt,I as K,Ee as Kt,Zn as L,Be as Lt,Kn as M,et as Mt,Qn as N,$e as Nt,L as O,at as Ot,Xn as P,D as Pt,An as Q,y as Qt,Wn as R,Le as Rt,Wr as S,l as Sn,ht as St,Gr as T,a as Tn,A as Tt,zn as U,Me as Ut,Hn as V,w as Vt,Vn as W,b as Wt,jn as X,we as Xt,Pn as Y,je as Yt,Sn as Z,ke as Zt,Vr as _,d as _n,Rt as _t,ri as a,ye as an,on as at,jr as b,ee as bn,jt as bt,ei as c,_e as cn,ln as ct,Jr as d,fe as dn,Ht as dt,_ as en,xn as et,Qr as f,de as fn,Ut as ft,Br as g,re as gn,zt as gt,Q as h,ie as hn,Bt as ht,fi as i,g as in,Kt as it,tr as j,tt as jt,er as k,ot as kt,ti as l,ge as ln,nn as lt,Xr as m,ae as mn,It as mt,hi as n,h as nn,Tn as nt,ni as o,ve as on,rn as ot,Zr as p,p as pn,Lt as pt,On as q,De as qt,ai as r,xe as rn,Dn as rt,$r as s,m as sn,sn as st,vi as t,be as tn,En as tt,Yr as u,he as un,N as ut,qr as v,u as vn,Vt as vt,Hr as w,pe as wn,_t as wt,Kr as x,te as xn,At as xt,Ar as y,ne as yn,Ot as yt,Gn as z,ze as zt};
1
+ import{_ as e,a as t,i as n,u as r,v as i}from"./sdk-contracts.js";import{c as a,d as o,l as s,n as c,s as l,x as u}from"./sdk-device.js";function d(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function f(t,n,r,i){let a=r(t[n]);if(a===void 0)throw new e(`COMMAND_FAILED`,i,{response:t});return a}function ee(e,t,n){return n(e[t])}function te(e,t,n){let r=e[t];return r===null?null:n(r)}function ne(e,t){return f(e,t,de,`Daemon response is missing "${t}".`)}function re(e,t){return ee(e,t,de)}function ie(e,t){return te(e,t,de)}function ae(e,t){return f(e,t,fe,`Daemon response is missing numeric "${t}".`)}function oe(e,t){return f(e,t,pe,`Daemon response has invalid "${t}".`)}function se(e,t){return f(e,t,me,`Daemon response has invalid "${t}".`)}function ce(e,t){return ee(e,t,he)??`mobile`}function le(e){if(!m(e))return;let t=p(e,`x`),n=p(e,`y`),r=p(e,`width`),i=p(e,`height`);if(!(t===void 0||n===void 0||r===void 0||i===void 0))return{x:t,y:n,width:r,height:i}}function ue(e){if(!m(e))return;let t=p(e,`x`),n=p(e,`y`);if(!(t===void 0||n===void 0))return{x:t,y:n}}function p(e,t){let n=e[t];return typeof n==`number`?n:void 0}function de(e){return typeof e==`string`&&e.length>0?e:void 0}function fe(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function pe(e){return e===`apple`?`ios`:e===`ios`||e===`macos`||e===`android`||e===`harmonyos`||e===`vega`||e===`linux`||e===`web`?e:void 0}function me(e){return e===`simulator`||e===`emulator`||e===`device`?e:void 0}function he(e){return e===`tv`||e===`mobile`||e===`desktop`?e:void 0}function ge(t){if(!m(t))throw new e(`COMMAND_FAILED`,`Daemon returned an unexpected response shape.`,{value:t});return t}function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _e(e){return m(e)?e:void 0}function ve(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function ye(e){return e.split(`
2
+ `).map(e=>e.trim()).filter(e=>e.length>0)}function be(e){let t=`${e??``}`.toLowerCase();return t.includes(`scroll`)||t.includes(`recyclerview`)||t.includes(`listview`)||t.includes(`gridview`)||t.includes(`collectionview`)||t===`table`}function xe(e){return be(e.type)?!0:`${e.role??``} ${e.subrole??``}`.toLowerCase().includes(`scroll`)}function h(e){return new Map(e.map(e=>[e.index,e]))}function Se(e,t,n,r){let i=t,a=new Set;for(;typeof i.parentIndex==`number`&&!a.has(i.index);){if(a.add(i.index),i=n.get(i.parentIndex)??e[i.parentIndex],!i)return null;let t=r(i);if(t!==null)return t}return null}function g(e){return!!(e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&e.width>0&&e.height>0)}function Ce(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}function we(e){return e.width*e.height}function Te(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function _(e){let t=null,n=-1;for(let r of e){let e=r.width*r.height;e>n&&(t=r,n=e)}return t}function Ee(e,t){return De(e.x,e.x+e.width,t.x,t.x+t.width)&&De(e.y,e.y+e.height,t.y,t.y+t.height)}function De(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function v(e){let t=e.trim().replace(/XCUIElementType/gi,``).replace(/^AX/,``).toLowerCase(),n=Math.max(t.lastIndexOf(`.`),t.lastIndexOf(`/`));return n!==-1&&(t=t.slice(n+1)),t}function Oe(e,t){let n=v(e);return n?t===`android`?n.includes(`edittext`)||n.includes(`autocompletetextview`):n.includes(`textfield`)||n.includes(`securetextfield`)||n.includes(`searchfield`)||n.includes(`textview`)||n.includes(`textarea`)||n===`search`:!0}function ke(e){return[e.label,e.value,e.identifier].map(e=>typeof e==`string`?e.trim():``).filter(e=>e.length>0)[0]??``}function Ae(e){let t=[e.type,e.role,e.subrole].map(e=>v(e??``)).join(` `);return t.includes(`application`)||t.includes(`window`)}function je(e,t){let n=r(t),i=e.flatMap(e=>Me(e.rect)?[{node:e,rect:e.rect}]:[]),a=i.filter(e=>Ae(e.node)).map(e=>e.rect),o=e=>Te(e,n.x,n.y);return _(a.filter(o))??_(a)??_(i.map(e=>e.rect).filter(o))}function Me(e){return e?Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.width)&&Number.isFinite(e.height):!1}function Ne(e,t,n=h(t)){if(!e.rect)return!0;let r=Ie(e,t,n);return r?Ee(e.rect,r):!0}function Pe(e,t,n=h(t)){if(!e.rect)return!0;if(!Ne(e,t,n))return!1;let r=je(t,e.rect);return Fe(e.rect,r)}function Fe(e,t){return!t||t.width<=0||t.height<=0?!0:Te(t,e.x+e.width/2,e.y+e.height/2)}function Ie(e,t,n=h(t)){return Le(e,n,e=>!!e.rect)?.rect||je(t,e.rect??{x:0,y:0,width:0,height:0})}function Le(e,t,n=()=>!0){let r=typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0,i=new Set;for(;r&&!i.has(r.index);){if(i.add(r.index),n(r)&&xe(r))return r;r=typeof r.parentIndex==`number`?t.get(r.parentIndex):void 0}return null}function Re(e,t){if(t===`android`&&e.visibleToUser===!1)return!1;let n=v(e.type??``);return n.includes(`application`)||n.includes(`window`)||n.includes(`scrollview`)||n.includes(`tableview`)||n.includes(`collectionview`)||n===`table`||n===`list`||n===`listview`?!1:t===`android`?e.hittable===!0&&g(e.rect):e.hittable===!0||g(e.rect)}function y(e){return e.hittable===!0?!0:e.rect?e.rect.width>0&&e.rect.height>0:!1}function ze(e,t){return Oe(e.type??``,t)&&e.enabled!==!1}const Be=new Set([`id`,`role`,`text`,`label`,`value`,`appname`,`windowtitle`]),Ve=new Set([`visible`,`hidden`,`editable`,`selected`,`focused`,`enabled`,`hittable`]),b=new Set([...Be,...Ve]),He=[...b],Ue=new Set(`button.imagebutton.link.cell.statictext.checkedtextview.textfield.textbox.edittext.textarea.switch.slider.image.imageview.webview.framelayout.linearlayout.relativelayout.constraintlayout.viewgroup.view.listview.recyclerview.collectionview.list.searchfield.segmentedcontrol.group.window.checkbox.radio.menuitem.toolbar.scrollarea.scrollview.nestedscrollview.table.application.navigationbar.tabbar.tab.alert.dialog.header`.split(`.`));function We(e){return Ue.has(e.trim().toLowerCase())}const Ge=new Map([[`"`,`"`],[`'`,`'`],[`\\`,`\\`],[`/`,`/`],[`b`,`\b`],[`f`,`\f`],[`n`,`
3
+ `],[`r`,`\r`],[`t`,` `]]);function x(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);let r=Ze(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Selector expression cannot be empty`);return{raw:n,selectors:r.map(e=>Ye(e))}}function S(e){try{return x(e)}catch{return null}}function Ke(e){let t=e.trim();if(!t)return!1;if(t===`||`)return!0;let n=t.indexOf(`=`);if(n!==-1){let e=t.slice(0,n).trim().toLowerCase();return b.has(e)}return b.has(t.toLowerCase())}function qe(e){let t=e.trim(),n=t.indexOf(`=`);if(n===-1)return null;let r=t.slice(0,n).trim().toLowerCase();if(!r||b.has(r))return null;let i=t.slice(n+1).trim();if(!i)return null;let a=et(i).trim();return a?{key:r,value:a}:null}function Je(e,t={}){if(e.length===0)return null;let n=t.preferTrailingValue??!1,r=0,i=[];for(;r<e.length;){let t=e[r];if(t===void 0||!Ke(t))break;r+=1;let n=e.slice(0,r).join(` `).trim();n&&S(n)&&i.push(r)}if(i.length===0)return null;let a=i.at(-1);if(a===void 0)return null;let o=a;if(n)for(let t=i.length-1;t>=0;--t){let n=i[t];if(n!==void 0&&n<e.length){o=n;break}}let s=e.slice(0,o).join(` `).trim();return s?{selectorExpression:s,rest:e.slice(o)}:null}function Ye(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Selector segment cannot be empty`);let r=Qe(n);if(r.length===0)throw new e(`INVALID_ARGS`,`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(Xe)}}function Xe(t){let n=t.trim();if(!n)throw new e(`INVALID_ARGS`,`Empty selector term`);let r=n.indexOf(`=`);if(r===-1){let r=n.toLowerCase();if(!Ve.has(r))throw new e(`INVALID_ARGS`,`Invalid selector term "${t}", expected key=value`);return{key:r,value:!0}}let i=n.slice(0,r).trim().toLowerCase(),a=n.slice(r+1).trim();if(!b.has(i))throw new e(`INVALID_ARGS`,`Unknown selector key: ${i}`);if(!a)throw new e(`INVALID_ARGS`,`Missing selector value for key: ${i}`);if(Ve.has(i)){let t=rt(a);if(t===null)throw new e(`INVALID_ARGS`,`Invalid boolean value for ${i}: ${a}`);return{key:i,value:t}}return{key:i,value:et(a)}}function Ze(t){let n=[],r=``,i=null;for(let a=0;a<t.length;a+=1){let o=t[a];if((o===`"`||o===`'`)&&!it(t,a)){i=$e(i,o),r+=o;continue}if(!i&&o===`|`&&t[a+1]===`|`){let i=r.trim();if(!i)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);n.push(i),r=``,a+=1;continue}r+=o}let a=r.trim();if(!a)throw new e(`INVALID_ARGS`,`Invalid selector fallback expression: ${t}`);return n.push(a),n}function Qe(t){let n=[],r=``,i=null;for(let e=0;e<t.length;e+=1){let a=t.charAt(e);if((a===`"`||a===`'`)&&!it(t,e)){i=$e(i,a),r+=a;continue}if(!i&&/\s/.test(a)){r.trim()&&n.push(r.trim()),r=``;continue}r+=a}if(i)throw new e(`INVALID_ARGS`,`Unclosed quote in selector: ${t}`);return r.trim()&&n.push(r.trim()),n}function $e(e,t){return e?e===t?null:e:t}function et(e){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)||t.startsWith(`'`)&&t.endsWith(`'`)?tt(t.slice(1,-1)):t}function tt(e){let t=``,n=0;for(;n<e.length;){let r=e.charAt(n);if(r!==`\\`){t+=r,n+=1;continue}let i=e.charAt(n+1);if(!i){t+=r,n+=1;continue}let a=nt(i);if(a!==null){t+=a,n+=2;continue}if(i===`u`){let r=e.slice(n+2,n+6);if(/^[0-9a-fA-F]{4}$/.test(r)){t+=String.fromCharCode(Number.parseInt(r,16)),n+=6;continue}}t+=r,n+=1}return t}function nt(e){return Ge.get(e)??null}function rt(e){let t=et(e).toLowerCase();return t===`true`?!0:t===`false`?!1:null}function it(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}const at=[`any`,`text`,`label`,`value`,`role`,`id`],ot=[`text`,`label`,`value`,`role`,`id`];function st(e){let t=e?.toLowerCase();return t===`press`||t===`tap`?`click`:t}function ct(e){return e===`exists`||e===`wait`||e===`get_text`||e===`get_attrs`||e===`list`}function lt(e,t,n,r={}){let i=w(n);if(!i)return{matches:[],score:0};let a=0,o=[];for(let n of e){if(r.requireRect&&!n.rect)continue;let e=ut(n,t,i);if(!(e<=0)){if(e>a){a=e,o.length=0,o.push(n);continue}e===a&&o.push(n)}}return{matches:o,score:a}}function ut(e,t,n){switch(t){case`role`:return dt(e.type,n);case`label`:return C(e.label,n);case`value`:return C(e.value,n);case`id`:return C(e.identifier,n);default:return Math.max(C(e.label,n),C(e.value,n),C(e.identifier,n))}}function C(e,t){let n=w(e??``);return n?n===t?2:+!!n.includes(t):0}function dt(e,t){let n=ft(e??``);return n?n===t?2:+!!n.includes(t):0}function w(e){return e.trim().toLowerCase().replace(/\s+/g,` `)}function ft(e){let t=e.trim();return t?(t=(t.split(`.`).pop()??t).replace(/XCUIElementType/gi,``).toLowerCase(),t):``}const pt=`find requires a value`,mt=`find actions: click (default; press/tap are aliases), list, focus, fill, type, exists, wait, get text, get attrs — there is no longpress/swipe find action. Run find "<text>" list to inspect every match with its @ref without acting, then dispatch the gesture on the chosen ref, e.g. longpress @eNN.`;function ht(e,t){if(e.length===0)return{ok:!1,code:`INVALID_ARGS`,message:`find requires a locator or text`};let n=vt([...e]);return n.query?t?.findFirst&&t?.findLast?{ok:!1,code:`INVALID_ARGS`,message:`find accepts only one of --first or --last`}:{ok:!0,parsed:n}:{ok:!1,code:`INVALID_ARGS`,message:pt}}const gt=[`exists`,`list`,`click`,`focus`];function _t(e){return gt.includes(e)}function vt(t){let n=`any`,r=0;ot.includes(t[0])&&(n=t[0],r=1);let i=t[r]??``,a=t.slice(r+1);if(a.length===0)return{locator:n,query:i,action:`click`};let o=st(a[0]);if(_t(o))return{locator:n,query:i,action:o};if(o===`get`)return{locator:n,query:i,action:yt(a[1])};if(o===`wait`){let e=xt(a[1]);return{locator:n,query:i,action:`wait`,timeoutMs:e??void 0}}if(o===`fill`||o===`type`)return{locator:n,query:i,action:o,value:a.slice(1).join(` `)};throw new e(`INVALID_ARGS`,`Unsupported find action: ${a[0]}`,{hint:mt})}function yt(t){let n=t?.toLowerCase();if(n===`text`)return`get_text`;if(n===`attrs`)return`get_attrs`;throw new e(`INVALID_ARGS`,`find get only supports text or attrs`)}function bt(e,t){return e!==`any`||!t.includes(`=`)&&!t.includes(`||`)?null:S(t)?t:null}function xt(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function T(e,t,n){return t.terms.every(t=>St(e,t,n))}function St(e,t,n){switch(t.key){case`id`:return E(e.identifier,String(t.value));case`role`:return E(v(e.type??``),String(t.value));case`label`:return E(e.label,String(t.value));case`value`:return E(e.value,String(t.value));case`text`:return E(ke(e),String(t.value));case`appname`:return E(e.appName,String(t.value));case`windowtitle`:return E(e.windowTitle,String(t.value));case`visible`:return y(e)===!!t.value;case`hidden`:return!y(e)==!!t.value;case`editable`:return ze(e,n)===!!t.value;case`selected`:return e.selected===!0==!!t.value;case`focused`:return e.focused===!0==!!t.value;case`enabled`:return e.enabled!==!1==!!t.value;case`hittable`:return e.hittable===!0==!!t.value;default:return!1}}function E(e,t){return w(e??``)===w(t)}function D(e,t,n){let r=n.requireRect??!1,i=n.requireUnique??!0,a=[];for(let[o,s]of t.selectors.entries()){let t=Dt(e,s,n.platform,r);if(a.push({selector:s.raw,matches:t.count}),!(t.count===0||!t.firstNode)){if(i&&t.count!==1){if(!n.disambiguateAmbiguous||!t.disambiguated||!t.tiebreak)continue;return{node:t.disambiguated,selector:s,selectorIndex:o,matches:t.count,diagnostics:a,disambiguation:{matchCount:t.count,tiebreak:t.tiebreak,alternatives:t.candidates.filter(e=>e!==t.disambiguated)}}}return{node:t.firstNode,selector:s,selectorIndex:o,matches:t.count,diagnostics:a}}}return null}function O(e,t,n){let r=n.requireRect??!1;for(let[i,a]of t.selectors.entries()){let t=e.filter(e=>r&&!e.rect?!1:T(e,a,n.platform));if(t.length>0)return{selector:a,selectorIndex:i,matchedNodes:t}}return null}function Ct(e,t,n){let r=n.requireRect??!1,i=[];for(let[a,o]of t.selectors.entries()){let t=jt(e,o,n.platform,r);if(i.push({selector:o.raw,matches:t}),t>0)return{selectorIndex:a,selector:o,matches:t,diagnostics:i}}return null}const wt=`Snapshot refs expire when the UI changes. Run snapshot -i and retry with a fresh @ref.`;function Tt(e){return e.some(e=>e.matches>1)?`Add more terms to disambiguate (e.g. role=button text="Sign in"), use an @ref from snapshot -i, or use find <text> --first/--last.`:`Selector text/label values match exactly (quote multi-word values: text="Sign in"). Run snapshot -i to see current elements and refs, or use find <text> for contains matching.`}function Et(e,t,n){if(t.length===0)return`Selector did not match: ${e}`;let r=t.map(e=>`${e.selector} -> ${e.matches}`).join(`, `);return n.unique??!0?`Selector did not resolve uniquely (${r})`:`Selector did not match (${r})`}function Dt(e,t,n,r){let i=0,a=null,o=[],s={best:null,bestVisible:!1,tie:!1},c,l=t=>(c??=h(e),Pe(t,e,c));for(let c of e)r&&!c.rect||T(c,t,n)&&(i+=1,a??=c,o.push(c),Ot(s,c,l));return{count:i,firstNode:a,disambiguated:s.tie?null:s.best,tiebreak:s.tie?null:kt(o,s.best,l),candidates:o}}function Ot(e,t,n){if(!e.best){e.best=t;return}e.bestVisible||=n(e.best);let r=n(t);if(r!==e.bestVisible){r&&(e.best=t,e.bestVisible=!0,e.tie=!1);return}let i=Mt(t,e.best);i.result>0?(e.best=t,e.tie=!1):i.result===0&&(e.tie=!0)}function kt(e,t,n){if(!t)return null;let r=null;for(let i of e)i!==t&&(!r||At(i,r,n).result>0)&&(r=i);return r?At(t,r,n).criterion:null}function At(e,t,n){let r=n(e);return r===n(t)?Mt(e,t):{result:r?1:-1,criterion:`visible`}}function jt(e,t,n,r){let i=0;for(let a of e)r&&!a.rect||T(a,t,n)&&(i+=1);return i}function Mt(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return{result:n>r?1:-1,criterion:`deepest`};let i=Nt(e),a=Nt(t);return i===a?{result:0,criterion:null}:{result:i<a?1:-1,criterion:`smallest-area`}}function Nt(e){return e.rect?e.rect.width*e.rect.height:1/0}function Pt(e,t,n,r){let i={...r,requireRect:n.requireRect};if(n.ambiguity===`reject-candidates`){let n=O(e,t,i);return!n||n.matchedNodes.length===0?{kind:`none`}:n.matchedNodes.length>1?{kind:`ambiguous`,selector:n.selector.raw,selectorIndex:n.selectorIndex,matchedNodes:n.matchedNodes}:Ft(n)}if(n.ambiguity===`first-match`){let n=O(e,t,i);return!n||n.matchedNodes.length===0?{kind:`none`}:Ft(n)}let a=D(e,t,{...i,requireUnique:!0,disambiguateAmbiguous:n.ambiguity===`disambiguate`});if(a)return{kind:`resolved`,resolution:a,matchedNodes:O(e,t,i)?.matchedNodes??[a.node]};let o=O(e,t,i);return!o||o.matchedNodes.length===0?{kind:`none`}:{kind:`ambiguous`,selector:o.selector.raw,selectorIndex:o.selectorIndex,matchedNodes:o.matchedNodes}}function Ft(e){let t=e.matchedNodes[0];return t?{kind:`resolved`,matchedNodes:e.matchedNodes,resolution:{node:t,selector:e.selector,selectorIndex:e.selectorIndex,matches:e.matchedNodes.length,diagnostics:[{selector:e.selector.raw,matches:e.matchedNodes.length}]}}:{kind:`none`}}function k(e,t){return{ok:!1,code:`INVALID_ARGS`,message:e,...t?{hint:t}:{}}}function It(e){return[`visible`,`hidden`,`exists`,`editable`,`selected`,`focused`,`text`].includes(e)}function Lt(e){let t=e.toLowerCase();return It(t)?{ok:!0,predicate:t}:k(`is requires predicate: visible|hidden|exists|editable|selected|focused|text`,Rt)}const Rt=`Use "is <predicate> <selector>" or "is <selector> <predicate>". visible|hidden|editable|selected|focused double as selector keys: a bare predicate token after the selector is read as the predicate, so write key=true (e.g. visible=true) inside the selector to use it as a filter instead.`;function zt(e){if(It((e[0]??``).toLowerCase()))return e;for(let t=1;t<e.length;t+=1){let n=(e[t]??``).toLowerCase();if(It(n)&&S(e.slice(0,t).join(` `)))return[n,...e.slice(0,t),...e.slice(t+1)]}return e}function Bt(e){let{predicate:t,node:n,nodes:r,expectedText:i,platform:a}=e,o=ke(n),s=ze(n,a),c=n.selected===!0,l=n.focused===!0,u=t===`text`?y(n):Vt(n,r,a),d=!1;switch(t){case`visible`:d=u;break;case`hidden`:d=!u;break;case`editable`:d=s;break;case`selected`:d=c;break;case`focused`:d=l;break;case`text`:d=o===(i??``);break}let f=t===`text`?`expected="${i??``}" actual="${o}"`:`actual=${JSON.stringify({visible:u,editable:s,selected:c,focused:l})}`;return{pass:d,actualText:o,details:f}}function Vt(e,t,n){if(n===`android`&&e.visibleToUser===!1)return!1;if(g(e.rect))return Ht(e,t);if(e.rect)return!1;if(n!==`android`&&e.hittable===!0)return!0;let r=Ut(e,t,n);return r?g(r.rect)?Ht(r,t):n!==`android`&&r.hittable===!0:!1}function Ht(e,t){return Ne(e,t)}function Ut(e,t,n){return Se(t,e,h(t),e=>Re(e,n)?e:null)}function Wt(e){let t=zt(e),n=t[0]??``;return{predicate:n,split:Je(t.slice(1),{preferTrailingValue:n===`text`})}}const Gt=`is requires a selector expression`,Kt=`is text requires expected text value`;function qt(e){let{predicate:t,split:n}=Wt([...e]),r=Lt(t);if(!r.ok)return r;if(!n)return k(Gt);let i=n.rest.join(` `).trim();return r.predicate===`text`&&!i?k(Kt):r.predicate!==`text`&&n.rest.length>0?k(`is ${r.predicate} does not accept trailing values`):{ok:!0,predicate:r.predicate,selectorExpression:n.selectorExpression,expectedText:i}}function Jt(e){return e===`text`||e===`attrs`?{ok:!0,format:e}:k(`get only supports text or attrs`)}function Yt(e){let t=e[0];if(t?.startsWith(`@`)){let n=e.slice(1).join(` `).trim();return{ok:!0,ref:t,...n?{label:n}:{}}}let n=e.join(` `).trim();return n?{ok:!0,selector:n}:k(`get requires @ref or selector expression`)}function Xt(e){return e?{ok:!0,text:e}:k(`wait requires text`)}function Zt(t,n,r={}){let i=t[n];if(i===void 0)return;if(!Number.isInteger(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be an integer.`);let a=i;if(r.min!==void 0&&a<r.min)throw new e(`INVALID_ARGS`,`Expected ${n} to be at least ${r.min}.`);if(r.max!==void 0&&a>r.max)throw new e(`INVALID_ARGS`,`Expected ${n} to be at most ${r.max}.`);return a}function Qt(t,n,r={}){let i=t[n];if(i!==void 0){if(typeof i!=`number`||!Number.isFinite(i))throw new e(`INVALID_ARGS`,`Expected ${n} to be a finite number.`);if(r.min!==void 0&&i<r.min)throw new e(`INVALID_ARGS`,`Expected ${n} to be at least ${r.min}.`);if(r.max!==void 0&&i>r.max)throw new e(`INVALID_ARGS`,`Expected ${n} to be at most ${r.max}.`);return i}}const $t=/^#\s*agent-device:target-v(\d+)(?:\s+(\S.*))?$/,en=/^#\s*agent-device:targets-v(\d+)(?:\s+(\S.*))?$/,tn=4096;function nn(e){return e.normalize(`NFC`)}function rn(e){if(e===void 0)return;let t=nn(e);return t.length>0?t:void 0}function an(e){return nn(e)}function on(e){if(e===void 0)return;let t=nn(e).trim().replace(/\s+/g,` `);return t.length>0?t:void 0}function A(e){return Buffer.byteLength(e,`utf8`)}function sn(e,t){if(A(e)<=t)return e;let n=e.length;for(;n>0&&A(e.slice(0,n))>t;)--n;if(n>0){let t=e.charCodeAt(n-1);t>=55296&&t<=56319&&--n}return e.slice(0,n)}function cn(e){let t={};return e.id!==void 0&&(t.id=e.id),t.role=e.role,e.label!==void 0&&(t.label=e.label),t.ancestry=e.ancestry.map(ln),t.sibling=e.sibling,t.viewportOrder=e.viewportOrder,e.scrollRegion&&(t.scrollRegion=un(e.scrollRegion)),e.rect&&(t.rect=dn(e.rect)),t.verification=e.verification,t}function ln(e){let t={role:e.role};return e.label!==void 0&&(t.label=e.label),t}function un(e){let t={role:e.role};return e.id!==void 0&&(t.id=e.id),e.label!==void 0&&(t.label=e.label),t}function dn(e){return{x:e.x,y:e.y,width:e.width,height:e.height}}function fn(e){return JSON.stringify(cn(e))}function pn(e){return`# agent-device:target-v1 ${fn(e)}`}function mn(e){return JSON.stringify({source:cn(e.source),destination:cn(e.destination)})}function hn(e){return`# agent-device:targets-v1 ${mn(e)}`}function gn(e){let t=e.trim(),n=en.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:_n((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function _n(t){if(A(t)>8320)throw new e(`INVALID_ARGS`,`targets-v1 annotation exceeds the 8320-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`targets-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`targets-v1 annotation must be a JSON object.`);let r=n;if(r.source===void 0||r.destination===void 0)throw new e(`INVALID_ARGS`,`targets-v1 annotation requires source and destination evidence.`);return{source:yn(JSON.stringify(r.source)),destination:yn(JSON.stringify(r.destination))}}function vn(e){let t=e.trim();if(!t.startsWith(`#`))return{kind:`none`};let n=$t.exec(t);return n?Number(n[1])===1?{kind:`v1`,evidence:yn((n[2]??``).trim())}:{kind:`future-version`}:{kind:`none`}}function yn(t){if(A(t)>4096)throw new e(`INVALID_ARGS`,`target-v1 annotation exceeds the ${tn}-byte payload cap.`);let n;try{n=JSON.parse(t)}catch{throw new e(`INVALID_ARGS`,`target-v1 annotation is not valid JSON.`)}if(typeof n!=`object`||!n||Array.isArray(n))throw new e(`INVALID_ARGS`,`target-v1 annotation must be a JSON object.`);let r=n,i=bn(r.role,`role`),a=xn(r.id,`id`),o=Sn(r.label,`label`),s=wn(r.ancestry),c=En(r.sibling,`sibling`,0),l=En(r.viewportOrder,`viewportOrder`,0),u=Dn(r.scrollRegion),d=On(r.rect),f=kn(r.verification);return{...a===void 0?{}:{id:a},role:i,...o===void 0?{}:{label:o},ancestry:s,sibling:c,viewportOrder:l,...u?{scrollRegion:u}:{},...d?{rect:d}:{},verification:f}}function bn(t,n){if(t===void 0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" is required.`);if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);return Cn(an(t),n)}function xn(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=rn(t);return r===void 0?void 0:Cn(r,n)}function Sn(t,n){if(t===void 0)return;if(typeof t!=`string`)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a string.`);let r=on(t);return r===void 0?void 0:Cn(r,n)}function Cn(t,n){if(A(t)>256)throw new e(`INVALID_ARGS`,`target-v1 "${n}" exceeds the 256-byte field cap.`);return t}function wn(t){if(t===void 0)return[];if(!Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry" must be an array.`);if(t.length>8)throw new e(`INVALID_ARGS`,`target-v1 "ancestry" exceeds the 8-entry cap.`);return t.map((e,t)=>Tn(e,t))}function Tn(t,n){if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "ancestry[${n}]" must be an object.`);let r=t,i=bn(r.role,`ancestry[${n}].role`),a=Sn(r.label,`ancestry[${n}].label`);return{role:i,...a===void 0?{}:{label:a}}}function En(t,n,r){if(t===void 0)return r;if(typeof t!=`number`||!Number.isSafeInteger(t)||t<0)throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a non-negative integer.`);return t}function Dn(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "scrollRegion" must be an object.`);let n=t,r=bn(n.role,`scrollRegion.role`),i=xn(n.id,`id`),a=Sn(n.label,`scrollRegion.label`);return{role:r,...i===void 0?{}:{id:i},...a===void 0?{}:{label:a}}}function On(t){if(t===void 0)return;if(typeof t!=`object`||!t||Array.isArray(t))throw new e(`INVALID_ARGS`,`target-v1 "rect" must be an object.`);let n=t;return{x:j(n.x,`rect.x`),y:j(n.y,`rect.y`),width:j(n.width,`rect.width`),height:j(n.height,`rect.height`)}}function j(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new e(`INVALID_ARGS`,`target-v1 "${n}" must be a finite number.`);return t}function kn(t){if(t===`verified`||t===`unverifiable`)return t;throw new e(`INVALID_ARGS`,`target-v1 "verification" must be "verified" or "unverifiable".`)}function An(e){let t=an(v(e.type??``)),n=rn(e.identifier),r=on(e.label);return{...n===void 0?{}:{id:sn(n,256)},role:sn(t,256),...r===void 0?{}:{label:sn(r,256)}}}function jn(e,t){return e.id===t.id&&e.role===t.role&&e.label===t.label}function Mn(e,t){let n=0;for(let r of e)An(r).id===t&&(n+=1);return n}function Nn(e,t){if(e.id===void 0||Mn(t,e.id)<=1)return e;let{role:n,label:r}=e;return{role:n,...r===void 0?{}:{label:r}}}function Pn(e,t){let n=0;for(let r of e)if(r.parentIndex===t.parentIndex){if(r.index===t.index)return n;n+=1}return 0}function Fn(e,t){return{documentOrder:e.index,sibling:Pn(t,e)}}function In(e,t){return e.documentOrder===t.documentOrder&&e.sibling===t.sibling}function Ln(e){return{...e.id===void 0?{}:{id:e.id},role:e.role,...e.label===void 0?{}:{label:e.label}}}function Rn(e,t){return t.id===void 0?e.role===t.role&&e.label===t.label:e.id===t.id}function zn(e,t){if(e.length<t.length)return!1;for(let[n,r]of t.entries()){let t=e[n];if(!t||t.role!==r.role||r.label!==void 0&&t.label!==r.label)return!1}return!0}function Bn(e,t){let n=[];return e.id!==t.id&&n.push(`id: recorded=${e.id??`(none)`} observed=${t.id??`(none)`}`),e.role!==t.role&&n.push(`role: recorded=${e.role} observed=${t.role}`),e.label!==t.label&&n.push(`label: recorded=${e.label??`(none)`} observed=${t.label??`(none)`}`),n}function Vn(e){return e?`${e.role}${e.label?`/${e.label}`:``}`:`(missing)`}function Hn(e,t){return!t||t.role!==e.role?!0:e.label!==void 0&&t.label!==e.label}function Un(e,t){for(let[n,r]of e.entries()){let e=t[n];if(Hn(r,e))return[`ancestry[${n}]: recorded=${Vn(r)} observed=${Vn(e)}`]}return[]}function Wn(e,t,n={}){let r=[],i=v(e.type??``),a=Gn(e,n.nodes),o=N(e.label),s=N(e.value),c=N(ke(e)),l=n.action===`fill`;a&&r.push(`id=${M(a)}`),i&&o&&r.push(l?`role=${M(i)} label=${M(o)} editable=true`:`role=${M(i)} label=${M(o)}`),o&&r.push(l?`label=${M(o)} editable=true`:`label=${M(o)}`),s&&r.push(l?`value=${M(s)} editable=true`:`value=${M(s)}`),c&&c!==o&&c!==s&&r.push(l?`text=${M(c)} editable=true`:`text=${M(c)}`),i&&l&&!r.some(e=>e.includes(`editable=true`))&&r.push(`role=${M(i)} editable=true`);let u=Kn(r);return u.length===0&&i&&u.push(l?`role=${M(i)} editable=true`:`role=${M(i)}`),u.length===0&&y(e)&&u.push(`visible=true`),u}function Gn(e,t){let n=N(e.identifier);if(!n||!t)return n;let r=An(e).id;return r===void 0?n:Mn(t,r)>1?null:n}function Kn(e){return Array.from(new Set(e))}function M(e){return JSON.stringify(e)}function N(e){return e&&e.trim()||null}function qn(e,t){let n=e===`is`?Wt([...t]).split:Je([...t]);return n?S(n.selectorExpression)?{kind:`expression`,expression:n.selectorExpression,rest:n.rest}:{kind:`invalid`}:{kind:`not-applicable`}}function Jn(e,t,n){let r=S(e);if(!r)return{kind:`unresolved`,reason:`parse-invalid`,matchedNodes:[]};let i=D(t,r,{platform:n.platform,requireRect:n.requireRect,requireUnique:!0,disambiguateAmbiguous:n.allowDisambiguation});if(i){let e=t.filter(e=>n.requireRect&&!e.rect?!1:T(e,i.selector,n.platform));return{kind:`resolved`,winner:i.node,matchedNodes:e,matchCount:e.length,...i.disambiguation?{disambiguation:{tiebreak:i.disambiguation.tiebreak,matchCount:i.disambiguation.matchCount,alternatives:i.disambiguation.alternatives}}:{}}}let a=O(t,r,{platform:n.platform,requireRect:n.requireRect})?.matchedNodes??[];return{kind:`unresolved`,reason:a.length>0?`ambiguous`:`no-match`,matchedNodes:a}}function Yn(e,t,n={}){return Wn(e,t,n)}function Xn(e,t,n){let r=S(e);if(!r)return;let i=D(t,r,{platform:n.platform,requireRect:n.requireRect,requireUnique:!0,disambiguateAmbiguous:n.allowDisambiguation});if(i)return{node:i.node,basis:Qn(i.selector)}}function Zn(e){if(!e)return;let t=S(e);if(!t)return;let n=t.selectors.flatMap(e=>e.terms.flatMap(e=>(e.key===`label`||e.key===`text`||e.key===`id`)&&typeof e.value==`string`?[e.value]:[]));if(n.length===0)return;let r=n[0];return r&&n.every(e=>e===r)?r:void 0}function Qn(e){let t=new Set(e.terms.map(e=>e.key));if(t.has(`id`))return`id`;let n=t.has(`role`),r=t.has(`label`)||t.has(`text`);return n&&r?`role-label`:r||t.has(`value`)?`label`:`other`}const $n={act:{ambiguity:`reject-candidates`,requireRect:!0},actCoveredDiagnosis:{ambiguity:`first-match`,requireRect:!0},readText:{ambiguity:`disambiguate`,requireRect:!1},readUnique:{ambiguity:`fail-closed`,requireRect:!1},readAny:{ambiguity:`first-match`,requireRect:!1},wait:{ambiguity:`first-match`,requireRect:!1},findAct:{ambiguity:`reject-candidates`,requireRect:!0}};function er(e){return e.ambiguity===`first-match`?{requireRect:e.requireRect,requireUnique:!1}:{requireRect:e.requireRect,requireUnique:!0,disambiguateAmbiguous:e.ambiguity===`disambiguate`}}function tr(e,t){let n=S(e);if(!n)return e.includes(`=`)||e.includes(`||`)?null:e;let r=new Set(t.textKeys);return n.selectors.length>1?nr(n.selectors,r):rr(n.selectors[0],r,new Set(t.booleanKeys))}function nr(e,t){let n=e.map(e=>{let n=e.terms.length===1?e.terms[0]:void 0;return n&&t.has(n.key)&&typeof n.value==`string`?n.value:void 0}),r=n[0];return r!==void 0&&n.every(e=>e===r)?r:null}function rr(e,t,n){if(!e)return null;let r={},i=0;for(let a of e.terms){if(ir(a,t,`string`))i+=1;else if(!ir(a,n,`boolean`))return null;r[a.key]=a.value}return i<=1&&Object.keys(r).length>0?r:null}function ir(e,t,n){return t.has(e.key)&&typeof e.value===n}function ar(e){let t=S(e);if(!t||t.selectors.length!==1)return null;let n=t.selectors[0];if(!n||n.terms.length!==1)return null;let r=n.terms[0];return!r||typeof r.value!=`string`||r.key!==`id`&&r.key!==`label`&&r.key!==`text`&&r.key!==`value`?null:{key:r.key,value:r.value,raw:n.raw}}function or(e,t){if(!t)return!1;let n=S(e);return n?n.selectors.some(e=>e.terms.some(e=>(e.key===`text`||e.key===`label`||e.key===`value`)&&typeof e.value==`string`&&e.value.includes(t))):!1}function sr(e){return x(e).selectors.map(e=>e.raw)}function cr(e){return S(e)!==null}function lr(e,t,n){let r=Ct(e,x(t),n);return r?{...r,selector:r.selector.raw}:null}function ur(e,t,n){let r=O(e,x(t),n);return r?{...r,selector:r.selector.raw}:null}function dr(e,t,n){let r=D(e,x(t),n);return r?{...r,selector:r.selector.raw}:null}function fr(e,t,n,r){let i=Pt(e,x(t),n,r);return i.kind===`resolved`?{...i,resolution:{...i.resolution,selector:i.resolution.selector.raw}}:i}function P(e){if(!e)return null;let t=Number(e);return Number.isFinite(t)?t:null}function pr(e){let t=e[0];if(t===void 0)return null;let n=P(t);if(n!==null)return{kind:`sleep`,durationMs:n};let r=P(e[e.length-1]);if(t===`text`)return{kind:`text`,text:(r===null?e.slice(1).join(` `):e.slice(1,-1).join(` `)).trim(),timeoutMs:r};if(t===`stable`){let t=e.slice(1),n=t.length>1?P(t[1]):null;return{kind:`stable`,quietMs:t.length>0?P(t[0]):null,timeoutMs:n}}if(t.startsWith(`@`))return{kind:`ref`,rawRef:t,timeoutMs:r};let i=Je(r===null?e.slice():e.slice(0,-1));return i&&i.rest.length===0&&cr(i.selectorExpression)?{kind:`selector`,selectorExpression:i.selectorExpression,timeoutMs:r}:{kind:`text`,text:(r===null?e.join(` `):e.slice(0,-1).join(` `)).trim(),timeoutMs:r}}function mr(e){let t=pr(e);return t?t.kind===`sleep`?t.durationMs:t.timeoutMs:null}const hr=24e4,F={budget:{source:`none`},envelopeMs:9e4,onTimeout:`reset-daemon`},gr={click:`settle-and-verify`,press:`settle-and-verify`,fill:`settle-and-verify`,longpress:`settle`,scroll:`settle`,back:`settle`};function _r(e){if(e!==void 0)return gr[e]}const I=new Set([`com.google.android.inputmethod.latin`,`com.samsung.android.honeyboard`,`com.touchtype.swiftkey`,`com.microsoft.swiftkey`]);function vr(e){let t=L(e.packageName),n=(e.resourceId??``).toLowerCase(),r=L(e.activeInputMethodPackage);if(t&&r&&t===r)return{inputMethodOwned:!0,source:`active-input-method`};if(r&&n.startsWith(`${r}:id/`))return{inputMethodOwned:!0,source:`active-input-method-resource`};if(t&&I.has(t))return{inputMethodOwned:!0,source:`known-ime-package`};for(let e of I)if(n.startsWith(`${e}:id/`))return{inputMethodOwned:!0,source:`known-ime-resource`};return{inputMethodOwned:!1,source:`app`}}function yr(e,t,n){return vr({packageName:e,resourceId:t,activeInputMethodPackage:n}).inputMethodOwned}function br(e){return vr(e).inputMethodOwned}function xr(e){let t=L(e);return!!(t&&I.has(t))}function Sr(e){let t=(e??``).toLowerCase();for(let e of I)if(t.startsWith(`${e}:id/`))return!0;return!1}function Cr(e,t,n){return!e&&!t?`unknown`:yr(e,t,n)?`ime`:`app`}function wr(e){for(let t of[/\bmCurMethodId=([^\s]+)/i,/\bmCurId=([^\s]+)/i,/\bmCurrentInputMethodId=([^\s]+)/i,/\bcurMethodId=([^\s]+)/i]){let n=Tr(e.match(t)?.[1]);if(n)return n}}function Tr(e){let t=(e??``).trim();if(t)return L((t.split(`/`)[0]??``).match(/[a-zA-Z0-9_.]+/)?.[0])}function L(e){return(e??``).trim().toLowerCase()||void 0}const Er=`com.android.systemui`;function Dr(e){let t=e??``;if(!t.startsWith(`com.android.systemui:id/`))return!1;let n=t.slice(`${Er}:id/`.length);return/(^|_)(status_bar|navigation_bar)(_|$)/.test(n)}function Or(e){return`systemChrome`in e&&e.systemChrome===!0}function kr(e){if(!Or(e))return e;let{systemChrome:t,...n}=e;return n}function Ar(e){return e.some(Or)?e.map(kr):e}const jr={ios:`iOS`,ipados:`iPadOS`,tvos:`tvOS`,watchos:`watchOS`,visionos:`visionOS`,macos:`macOS`},Mr={visionos:`visionOS uses spatial input and does not support two-finger touch synthesis.`,tvos:`tvOS has no touch input — this gesture is supported on Android and the iOS simulator only.`,macos:`macOS automation has no multi-touch input — this gesture is supported on Android and the iOS simulator only.`};function Nr(t,n){if(!l(t.platform))throw Pr(n,t.platform);let r=u(t);if(!((r===`ios`||r===`ipados`)&&t.kind===`simulator`))throw r===`ios`||r===`ipados`?new e(`UNSUPPORTED_OPERATION`,`gesture ${n} is not supported on physical iOS devices`,{hint:`Two-finger gesture synthesis is iOS-simulator only — not available on physical iOS devices.`}):Pr(n,jr[r],Mr[r])}function Pr(t,n,r){return new e(`UNSUPPORTED_OPERATION`,`gesture ${t} is not supported on ${n}`,r===void 0?void 0:{hint:r})}function Fr(e){let t=e.state??`stopped`;return{audio:`probe`,state:t,active:t===`running`,heard:!1,source:e.source,backend:e.backend,durationMs:e.durationMs,elapsedMs:e.elapsedMs??0,bucketMs:e.bucketMs,sampleCount:0,mediaElementCount:e.mediaElementCount,sourceCount:e.sourceCount??0,rmsDbfs:[],peakDbfs:[],reason:e.reason,notes:e.notes}}function Ir(e,t){let n=Br(e),r=Lr(n),i=Rr(n.rmsDbfs),a=Rr(n.peakDbfs),o=[...zr(n.notes)??[],...t.notes??[]];return{audio:`probe`,state:r,active:r===`running`&&Vr(n.active,t.activeFallback??!0),heard:n.heard===!0,source:t.source,backend:Hr(n.backend)??t.backend,durationMs:R(n.durationMs,t.durationMs),elapsedMs:R(n.elapsedMs,t.elapsedMs),bucketMs:R(n.bucketMs,t.bucketMs),sampleCount:R(n.sampleCount,i.length),mediaElementCount:t.mediaElementCount===void 0?Ur(n.mediaElementCount):R(n.mediaElementCount,t.mediaElementCount),sourceCount:R(n.sourceCount,t.sourceCount??0),rmsDbfs:i,peakDbfs:a,startedAt:Hr(n.startedAt),stoppedAt:Hr(n.stoppedAt),reason:Hr(n.reason),notes:o.length>0?o:void 0}}function Lr(e){return e.state===`running`?`running`:`stopped`}function R(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function Rr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e)typeof n==`number`&&Number.isFinite(n)&&t.push(n);return t}function zr(e){if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}function Br(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Vr(e,t){return typeof e==`boolean`?e:t}function Hr(e){return typeof e==`string`?e:void 0}function Ur(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Wr(e){return process.platform===`darwin`&&(s(e)||a(e)&&e.kind===`simulator`||e.platform===`android`&&e.kind===`emulator`)}function Gr(e){return e.platform===`web`||Wr(e)}function Kr(e){if(typeof e!=`object`||!e)throw ei();let t=e,n=Object.keys(t).sort();if(!(t.kind===`legacy`&&z(n,[`kind`]))&&!(t.kind===`inventory`&&z(n,[`kind`,`use`])&&Yr(t.use))&&!(t.kind===`device-runtime`&&z(n,[`kind`,`use`])&&Xr(t.use))&&!(t.kind===`device-runtime`&&z(n,[`kind`,`uses`])&&qr(t.uses)))throw ei()}function qr(e){if(!Array.isArray(e)||e.length===0||!e.every(Xr))return!1;let t=e.map(Jr);return new Set(t).size===t.length}function Jr(e){return JSON.stringify({required:[...e.required].sort(),preferred:[...e.preferred].sort()})}function Yr(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`device-inventory`&&z(Object.keys(t).sort(),[`kind`])}function Xr(e){if(typeof e!=`object`||!e)return!1;let t=e,n=Zr(t.required),r=Zr(t.preferred);return!n||!r||!Qr(n)||!Qr(r)||!$r(n,r)?!1:z(Object.keys(t).sort(),[`preferred`,`required`])}function Zr(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)?e:null}function Qr(e){return new Set(e).size===e.length}function $r(e,t){let n=new Set(e);return t.every(e=>!n.has(e))}function z(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function ei(){return TypeError(`Command platform execution must declare exactly one of legacy, inventory, or device-runtime`)}var ti=class{#e=[];#t=`open`;get disposed(){return this.#t===`disposed`}defer(e){this.#n(),this.#e.push(e)}use(e){return this.defer(async()=>await e[Symbol.asyncDispose]()),e}async[Symbol.asyncDispose](){if(this.#t===`disposed`)return;if(this.#t===`disposing`)throw TypeError(`Async cleanup stack disposal is already in progress`);this.#t=`disposing`;let e=[];for(;this.#e.length>0;){let t=this.#e.pop();if(t)try{await t()}catch(t){e.push(t)}}if(this.#t=`disposed`,e.length===1)throw e[0];if(e.length>1)throw AggregateError(e,`Multiple asynchronous cleanups failed`)}#n(){if(this.#t!==`open`)throw TypeError(`Cannot register cleanup after disposal has begun`)}},ni=class{#e;#t=`pending`;constructor(e){this.#e=e}get pending(){return this.#t===`pending`}transfer(){if(this.#t!==`pending`)throw TypeError(`Cannot transfer handle in ${this.#t} state`);return this.#t=`transferred`,this.#e}async[Symbol.asyncDispose](){this.#t===`pending`&&(this.#t=`disposed`,await this.#e[Symbol.asyncDispose]())}};function ri(){return e=>{let t=ii(e.required,`required`),n=ii(e.preferred??[],`preferred`),r=n.find(e=>t.includes(e));if(r!==void 0)throw TypeError(`Runtime operation cannot be both required and preferred: ${r}`);return Object.freeze({required:t,preferred:n})}}function ii(e,t){let n=[...e];if(new Set(n).size!==n.length)throw TypeError(`Runtime use contains duplicate ${t} operations`);return Object.freeze(n)}function ai(e){if(!o(e))throw TypeError(`Unknown local runtime family: ${String(e)}`);return Object.freeze({kind:`local-family`,family:e})}function oi(e,t){let n=e.trim(),r=t.trim();if(n.length===0||r.length===0)throw TypeError(`Provider runtime owner requires non-empty provider and instance identities`);return Object.freeze({kind:`provider-runtime`,provider:n,instance:r})}function si(e){return e.kind===`local-family`?`local:${e.family}`:`provider:${JSON.stringify([e.provider,e.instance])}`}function ci(e,t){return si(e)===si(t)}function li(e,t){let n={},r={};for(let i of t.required){let t=ui(e.facts.operations,i);if(n[i]=t,!t.available)throw hi(i,t);r[i]=pi(e.operations,i)}for(let i of t.preferred){let t=ui(e.facts.operations,i);n[i]=t,t.available&&(r[i]=pi(e.operations,i))}return Object.freeze({device:e.device,owner:e.owner,facts:Object.freeze(n),operations:Object.freeze(r)})}function ui(e,t){let n=e[t];if(!di(n))throw gi(`Runtime owner omitted the ${t} fact`);let r=fi(n);if(r)return r;throw gi(`Runtime owner returned an invalid ${t} fact`)}function di(e){return typeof e==`object`&&!!e&&`available`in e}function fi(e){if(e.available===!0)return Object.freeze({available:!0});if(e.available===!1&&mi(e.reason)&&!(e.hint!==void 0&&typeof e.hint!=`string`))return Object.freeze({available:!1,reason:e.reason,...e.hint===void 0?{}:{hint:e.hint}})}function pi(e,t){let n=e[t];if(typeof n!=`function`)throw gi(`Runtime owner advertised ${t} without an implementation`);return n}function mi(e){return e===`unsupported-platform-leaf`||e===`unsupported-device-kind`||e===`unsupported-device-backend`||e===`unsupported-provider-mode`||e===`owner-capability-missing`}function hi(t,n){return new e(`UNSUPPORTED_OPERATION`,`Runtime operation ${t} is unavailable`,{reason:n.reason,hint:n.hint})}function gi(t){return new e(`COMMAND_FAILED`,t,{reason:`runtime-contract-invalid`,hint:`This is an agent-device runtime contract bug; report the selected device and command.`})}function _i(e){return e.status===`cleaned`||e.status===`already-missing`}const vi=`app-log`,yi=ri(),bi=yi({required:[`networkDump`]}),xi=yi({required:[],preferred:[`networkDump`]}),Si=[`dump`,`log`],Ci=[`summary`,`headers`,`body`,`all`];function wi(t){let n=(t.action??`dump`).toLowerCase(),r=(t.include??`summary`).toLowerCase();if(!Ti(n))throw new e(`INVALID_ARGS`,`network requires dump or log`);if(!Ei(r))throw new e(`INVALID_ARGS`,`network --include must be summary, headers, body, or all`);return Object.freeze({action:n,include:r,use:bi})}function Ti(e){return Si.some(t=>t===e)}function Ei(e){return Ci.some(t=>t===e)}const Di=ri(),B=Di({required:[`appLogInspect`]}),Oi=Di({required:[`appLogInspect`,`appLogDoctor`]}),ki=Di({required:[`appLogInspect`,`appLogStart`]}),Ai=Di({required:[],preferred:[`appLogInspect`]}),ji=Object.freeze([B,Oi,ki]);function Mi(t){let n=(t.action??`path`).toLowerCase();if(t.restart&&n!==`clear`)throw new e(`INVALID_ARGS`,`logs --restart is only supported with logs clear`);switch(n){case`path`:return Object.freeze({kind:`path`,requiresAppSession:!1,use:B});case`start`:return Object.freeze({kind:`start`,requiresAppSession:!0,use:ki});case`stop`:return Object.freeze({kind:`stop`,requiresAppSession:!1,use:B});case`doctor`:return Object.freeze({kind:`doctor`,requiresAppSession:!1,use:Oi});case`mark`:return Object.freeze({kind:`mark`,marker:t.marker??``,requiresAppSession:!1,use:B});case`clear`:return t.restart?Object.freeze({kind:`clear-restart`,requiresAppSession:!0,use:ki}):Object.freeze({kind:`clear`,requiresAppSession:!1,use:B});default:throw new e(`INVALID_ARGS`,`logs requires path, start, stop, doctor, mark, or clear`)}}function Ni(e){let t=new Map;for(let n of e){if(!o(n.family))throw TypeError(`Unknown platform family registration: ${String(n.family)}`);if(t.has(n.family))throw TypeError(`Duplicate platform family registration: ${n.family}`);t.set(n.family,Pi(n))}let n=c.filter(e=>!t.has(e));if(n.length>0)throw TypeError(`Missing platform family registrations: ${n.join(`, `)}`);let r=Object.freeze([...c]),i=Object.freeze(r.map(e=>Fi(t,e)));return Object.freeze({families:r,modules:i,get:e=>Fi(t,e)})}function Pi(e){return Object.freeze({...e})}function Fi(e,t){let n=e.get(t);if(!n)throw TypeError(`Missing platform family registration: ${t}`);return n}const Ii=Object.freeze({kind:`device-inventory`}),Li={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0},V={leaseAdmissionExempt:!0,sessionExecutionLockExempt:!0,selectorValidationExempt:!0},Ri=()=>!0,zi=e=>(e.positionals?.[0]??``).toLowerCase()===`start`,Bi=e=>e.command===`test`&&(typeof e.flags?.shardAll==`number`||typeof e.flags?.shardSplit==`number`),Vi=new Set([`status`,`get`]),Hi=e=>Ji(e,Vi,`status`),Ui=new Set([`get`,`wait`]),Wi=e=>Ji(e,Ui,`get`),Gi=e=>Yi(e,Vi,`status`),Ki=e=>Yi(e,Ui,`get`),qi=e=>{try{return ct(vt(e.positionals??[]).action)?`observes-app`:`mutates-app`}catch{return`mutates-app`}};function Ji(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`preserve`:`may-invalidate`}function Yi(e,t,n){return t.has((e.positionals?.[0]??n).toLowerCase())?`observes-app`:`mutates-app`}const H={simulator:!0,device:!0},U={emulator:!0,device:!0,unknown:!0},W={emulator:!0},G={device:!0},K={},q={apple:H,android:U,linux:G},Xi={...q,vega:W},Zi={apple:H,android:U,linux:K},Qi={apple:H,android:U,linux:K},J={recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,linux:G},timeoutPolicy:F,batchable:!0},Y={...F,onTimeout:`preserve-daemon`},$i={...F,envelopeMs:18e4},ea={...F,budget:{source:`flag`,envelope:`widen`,defaultBudgetMs:1e4},onTimeout:`preserve-daemon`},ta={fields:{count:{defaultValue:1,omitDefault:!0},intervalMs:{defaultValue:0,omitDefault:!0},holdMs:{defaultValue:0,omitDefault:!0},jitterPx:{defaultValue:0,omitDefault:!0},doubleTap:{defaultValue:!1,omitDefault:!0}}},na={fields:{delayMs:{defaultValue:0}}};function X(e,t){return _r(e)===void 0?t:ea}function Z(e){let t=_r(e);if(t===void 0)throw Error(`Missing post-action observation descriptor support for ${e}`);return t}const ra=[{name:`lease_allocate`,catalog:{group:`internal`,key:`leaseAllocate`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...Li},timeoutPolicy:F,batchable:!1},{name:`lease_heartbeat`,catalog:{group:`internal`,key:`leaseHeartbeat`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...Li},timeoutPolicy:F,batchable:!1},{name:`lease_release`,catalog:{group:`internal`,key:`leaseRelease`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...Li},timeoutPolicy:F,batchable:!1},{name:`artifacts`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`lease`,refFrameEffect:`preserve`,...Li},timeoutPolicy:F,batchable:!1},{name:`session_list`,catalog:{group:`internal`,key:`sessionList`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,...V},timeoutPolicy:F,batchable:!1},{name:`session_save_script`,catalog:{group:`internal`,key:`sessionSaveScript`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`publication`},timeoutPolicy:F,batchable:!1},{name:`devices`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,...V},timeoutPolicy:F,batchable:!0,platformExecution:{kind:`inventory`,use:Ii}},{name:`capabilities`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0,...V},timeoutPolicy:F,batchable:!0},{name:`doctor`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,allowSessionlessDefaultDevice:Ri,...V},timeoutPolicy:F,batchable:!0},{name:`apps`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`inventory`,lockPolicySelectorOverride:!0,preferExplicitDeviceOverExistingSession:!0},capability:Zi,timeoutPolicy:F,batchable:!0},{name:`boot`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`shutdown`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`may-invalidate`,sessionKind:`state`},capability:{apple:{simulator:!0},android:{emulator:!0},linux:K},timeoutPolicy:F,batchable:!0},{name:`appstate`,catalog:{group:`public`,key:`appState`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`state`},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`perf`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`logs`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,uses:ji},timeoutPolicy:F,batchable:!0},{name:`events`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`,allowInvalidRecording:!0,...V},timeoutPolicy:F,batchable:!1},{name:`network`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},platformExecution:{kind:`device-runtime`,use:bi},timeoutPolicy:F,batchable:!0},{name:`audio`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,sessionKind:`observability`},capability:{apple:H,android:{emulator:!0},linux:K},timeoutPolicy:F,batchable:!0},{name:`replay`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Bi,saveScriptFlagOwner:!0},timeoutPolicy:{...F,budget:{source:`flag`}},batchable:!1},{name:`test`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`,sessionKind:`replay`,skipSessionlessProviderDevice:Bi},timeoutPolicy:{...F,envelopeMs:`unbounded`},batchable:!0},{name:`runtime`,catalog:{group:`internal`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},timeoutPolicy:F,batchable:!1},{name:`clipboard`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`session`,refFrameEffect:`preserve`},dispatch:{},capability:{apple:H,android:U,linux:G},timeoutPolicy:F,batchable:!0},{name:`keyboard`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:Gi,daemon:{route:`session`,refFrameEffect:Hi,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`install`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},capability:Qi,timeoutPolicy:$i,batchable:!0},{name:`reinstall`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},capability:Qi,timeoutPolicy:$i,batchable:!0},{name:`install_source`,catalog:{group:`internal`,key:`installSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},timeoutPolicy:$i,batchable:!1},{name:`release_materialized_paths`,catalog:{group:`internal`,key:`releaseMaterializedPaths`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`,...V},timeoutPolicy:F,batchable:!1},{name:`push`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:{simulator:!0},android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`trigger-app-event`,catalog:{group:`public`,key:`triggerAppEvent`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`open`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowSessionlessDefaultDevice:Ri,saveScriptFlagOwner:!0},dispatch:{},capability:Xi,timeoutPolicy:F,batchable:!0},{name:`prepare`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`preserve`},capability:{apple:H,android:{},linux:K},timeoutPolicy:{budget:{source:`flag`},envelopeMs:hr,onTimeout:`reset-daemon`},batchable:!1,mcpExposed:!1},{name:`batch`,catalog:{group:`public`},recordsSessionAction:!1,daemon:{route:`session`,refFrameEffect:`delegated`},timeoutPolicy:F,batchable:!1},{name:`close`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`session`,refFrameEffect:`may-invalidate`,allowInvalidRecording:!0,saveScriptFlagOwner:!0},dispatch:{},capability:Xi,timeoutPolicy:F,batchable:!0},{name:`snapshot`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},dispatch:{},capability:q,timeoutPolicy:{...Y,budget:{source:`flag`}},batchable:!0},{name:`diff`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},capability:q,timeoutPolicy:F,batchable:!0},{name:`wait`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,targetIdentityVerification:`post-resolution`,daemon:{route:`snapshot`,refFrameEffect:`preserve`},capability:q,timeoutPolicy:{...Y,budget:{source:`positional-parser`,parser:mr}},batchable:!0},{name:`alert`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:Ki,daemon:{route:`snapshot`,refFrameEffect:Wi},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`settings`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`snapshot`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`react-native`,catalog:{group:`public`,key:`reactNative`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`reactNative`,refFrameEffect:`may-invalidate`},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`record`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`,allowInvalidRecording:!0,allowSessionlessDefaultDevice:zi},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`trace`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`recordTrace`,refFrameEffect:`preserve`},timeoutPolicy:F,batchable:!0},{name:`find`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:qi,daemon:{route:`find`,refFrameEffect:`may-invalidate`},capability:q,timeoutPolicy:Y,batchable:!0},{name:`click`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:{apple:H,android:U,linux:G},timeoutPolicy:X(`click`,Y),postActionObservation:Z(`click`),responseDataTransform:ta,batchable:!0},{name:`fill`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,linux:G},timeoutPolicy:X(`fill`,Y),postActionObservation:Z(`fill`),responseDataTransform:na,batchable:!0},{name:`longpress`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`,key:`longPress`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,linux:G},timeoutPolicy:{...ea,envelopeMs:21e4},postActionObservation:Z(`longpress`),batchable:!0},{name:`press`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,linux:G},timeoutPolicy:X(`press`,Y),postActionObservation:Z(`press`),responseDataTransform:ta,batchable:!0},{name:`type`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:q,timeoutPolicy:X(`type`,Y),batchable:!0},{name:`get`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},capability:q,timeoutPolicy:X(`get`,Y),batchable:!0},{name:`read`,catalog:{group:`dispatch-alias`},recordsSessionAction:!1,dispatch:{},timeoutPolicy:F,batchable:!1},{name:`is`,targetIdentityVerification:`pre-dispatch`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`interaction`,refFrameEffect:`preserve`},capability:q,timeoutPolicy:X(`is`,Y),batchable:!0},{name:`back`,catalog:{group:`public`},...J,capability:{...J.capability,vega:W},timeoutPolicy:X(`back`,F),postActionObservation:Z(`back`)},{name:`gesture`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,targetIdentityVerification:`pre-dispatch`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:q,timeoutPolicy:F,batchable:!0},{name:`home`,catalog:{group:`public`},...J,capability:{...J.capability,vega:W}},{name:`tv-remote`,catalog:{group:`public`,key:`tvRemote`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,vega:W,linux:K},timeoutPolicy:F,batchable:!0},{name:`orientation`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},dispatch:{},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`scroll`,catalog:{group:`public`},...J,timeoutPolicy:X(`scroll`,F),postActionObservation:Z(`scroll`)},{name:`swipe`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`interaction`,refFrameEffect:`may-invalidate`,androidBlockingDialogGuard:!0},capability:{apple:H,android:U,linux:G},timeoutPolicy:F,batchable:!0},{name:`focus`,catalog:{group:`public`},...J},{name:`screenshot`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`observes-app`,daemon:{route:`generic`,refFrameEffect:`preserve`},dispatch:{},capability:q,timeoutPolicy:F,batchable:!0},{name:`viewport`,catalog:{group:`public`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:{},android:{},linux:K},timeoutPolicy:F,batchable:!1},{name:`app-switcher`,catalog:{group:`public`,key:`appSwitcher`},recordsSessionAction:!0,recordingEffect:`mutates-app`,daemon:{route:`generic`,refFrameEffect:`may-invalidate`},dispatch:{},capability:{apple:H,android:U,linux:K},timeoutPolicy:F,batchable:!0},{name:`install-from-source`,catalog:{group:`public`,key:`installFromSource`},recordsSessionAction:!0,recordingEffect:`mutates-app`,capability:Qi,timeoutPolicy:F,batchable:!0},{name:`debug`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1},{name:`daemon`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`device`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`metro`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1},{name:`session`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1},{name:`cdp`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`auth`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`connect`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`connection`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`disconnect`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`mcp`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`proxy`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`react-devtools`,catalog:{group:`local-cli`,key:`reactDevtools`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1},{name:`web`,catalog:{group:`local-cli`},recordsSessionAction:!1,timeoutPolicy:F,batchable:!1,mcpExposed:!1}],ia=new Set([`public`,`local-cli`]),aa=new Set(ra.filter(e=>ia.has(da(e))).map(e=>e.name)),Q=ra.map(e=>{let t=`platformExecution`in e?e.platformExecution:{kind:`legacy`};return Kr(t),{...e,mcpExposed:la(e),platformExecution:t}});function oa(e){return Q.filter(t=>da(t)===e).map(e=>[fa(e),e.name])}function sa(){return Q.filter(e=>ua(e)).map(e=>e.name).sort()}const $=new Map(Q.map(e=>[e.name,e]));function ca(e){return aa.has(e)}function la(e){return e.mcpExposed??aa.has(e.name)}function ua(e){return e.mcpExposed&&ca(e.name)}function da(e){return e.catalog.group}function fa(e){return e.catalog.key??e.name}const pa=new Map(Q.map(e=>[e.name,e.timeoutPolicy])),ma=new Map(Array.from($.values()).flatMap(e=>e.responseDataTransform?[[e.name,e.responseDataTransform]]:[]));function ha(e){if(e!==void 0)return $.get(e)?.postActionObservation}function ga(e){return ha(e)!==void 0}function _a(e){return ha(e)===`settle-and-verify`}function va(e){return e===void 0?F:pa.get(e)??F}function ya(e){if(e!==void 0)return ma.get(e)}function ba(e){return e===void 0?!1:$.get(e)?.recordsSessionAction??!1}function xa(e){return $.get(e)?.targetIdentityVerification}function Sa(e){let t=$.get(e.command);if(t?.recordsSessionAction)return typeof t.recordingEffect==`function`?t.recordingEffect(e):t.recordingEffect}function Ca(){return[...new Set(Array.from(ma.values()).flatMap(e=>Object.keys(e.fields)))].sort()}function wa(e){return Number.isInteger(e)&&e>=1&&e<=1e3}function Ta(t,n){if(t>n)throw new e(`INVALID_ARGS`,`batch has ${t} steps; max allowed is ${n}.`)}function Ea(t,n){if(!d(t))throw new e(`INVALID_ARGS`,`Invalid batch step ${n}.`);return t}function Da(t,n){let r=t.input;if(!d(r))throw new e(`INVALID_ARGS`,`Batch step ${n} input must be an object.`);return r}function Oa(t,r){if(t!==void 0)try{return n.parse(t)}catch(t){throw new e(`INVALID_ARGS`,`Batch step ${r} runtime is invalid: ${t instanceof Error?t.message:String(t)}`)}}function ka(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=/^([A-Za-z][A-Za-z0-9+.-]*):(.+)$/.exec(t);if(!n)return!1;let r=n[1]?.toLowerCase(),i=n[2]??``;return r===`http`||r===`https`||r===`ws`||r===`wss`||r===`ftp`||r===`ftps`?i.startsWith(`//`):!0}function Aa(e){let t=e.trim().split(`:`)[0]?.toLowerCase();return t===`http`||t===`https`}function ja(e,t){let n=e?.trim();if(n)return n;if(Aa(t))return`com.apple.mobilesafari`}function Ma(e){let t=[];for(let n of e)n.daemon&&t.push({command:n.name,...n.daemon,replayScopedAction:n.recordsSessionAction});return t}function Na(e){let t={};for(let n of e)n.capability&&(t[n.name]=n.capability);return t}function Pa(e){return e.filter(e=>e.batchable).map(e=>e.name)}const Fa=Pa(Q),Ia=new Set([`batch`,`replay`]),La=[`command`,`positionals`,`input`,`flags`,`runtime`],Ra=[`platform`,`target`,`device`,`udid`,`serial`,`verbose`,`out`],za=new Set(Fa);function Ba(e){return za.has(e)}function Va(e){return typeof e==`string`?e.trim().toLowerCase():``}function Ha(t,n){let r=Va(t);if(Ba(r))return r;throw new e(`INVALID_ARGS`,`Batch step ${n} command is not available through command batch: ${String(t)}`)}function Ua(t,n){if(Ia.has(t))throw new e(`INVALID_ARGS`,`Batch step ${n} cannot run ${t}.`)}const Wa=new Set(La);async function Ga(e,t,n){let r=Qa(e.flags),a=r?.batchOnError??`stop`;if(a!==`stop`)return $a(`INVALID_ARGS`,`Unsupported batch on-error mode: ${a}.`);let o=r?.batchMaxSteps??100;if(!wa(o))return $a(`INVALID_ARGS`,`Invalid batch max-steps: ${String(r?.batchMaxSteps)}`);try{let i=Ka(r?.batchSteps,o),a=Date.now(),s=[];for(let[r,a]of i.entries()){let o=await Za(e,t,a,n,r+1,r===i.length-1);if(!o.ok)return{ok:!1,error:{code:o.error.code,message:`Batch failed at step ${o.step} (${a.command}): ${o.error.message}`,hint:o.error.hint,diagnosticId:o.error.diagnosticId,logPath:o.error.logPath,details:{...o.error.details??{},step:o.step,command:a.command,positionals:a.positionals,executed:r,total:i.length,partialResults:s}}};s.push(o.result)}return{ok:!0,data:{total:i.length,executed:i.length,totalDurationMs:Date.now()-a,results:s}}}catch(e){let t=i(e);return $a(t.code,t.message,t.details)}}function Ka(t,n){if(!Array.isArray(t)||t.length===0)throw new e(`INVALID_ARGS`,`batch requires a non-empty batchSteps array.`);Ta(t.length,n);let r=[];for(let n=0;n<t.length;n+=1){let i=t[n];if(!m(i))throw new e(`INVALID_ARGS`,`Invalid batch step at index ${n}.`);let a=Object.keys(i).filter(e=>!Wa.has(e));if(a.length>0){let t=a.map(e=>`"${e}"`).join(`, `);throw new e(`INVALID_ARGS`,`Batch step ${n+1} has unknown field(s): ${t}. Allowed fields: command, positionals, input, flags, runtime.`)}let o=Va(i.command);if(!o)throw new e(`INVALID_ARGS`,`Batch step ${n+1} requires command.`);if(Ua(o,n+1),i.positionals!==void 0&&!Array.isArray(i.positionals))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must be an array.`);let s=i.positionals??[];if(s.some(e=>typeof e!=`string`))throw new e(`INVALID_ARGS`,`Batch step ${n+1} positionals must contain only strings.`);if(i.flags!==void 0&&!m(i.flags))throw new e(`INVALID_ARGS`,`Batch step ${n+1} flags must be an object.`);if(i.input!==void 0&&!m(i.input))throw new e(`INVALID_ARGS`,`Batch step ${n+1} input must be an object.`);r.push({command:o,positionals:s,input:i.input,flags:i.flags??{},runtime:Oa(i.runtime,n+1)})}return r}function qa(e,t){let{batchSteps:n,batchOnError:r,batchMaxSteps:i,...a}=t??{};return Ja(Qa(e),a)}function Ja(e,t){let n=Qa(e)??{},r=t;for(let e of Ra)r[e]===void 0&&n[e]!==void 0&&(r[e]=n[e]);return t}function Ya(e,n){return t(e)?n?e:`digest`:e}function Xa(e,t){let n=e?.responseLevel,r=Ya(n,t);return r===n?e:{...e,responseLevel:r}}async function Za(e,t,n,r,i,a){let o=Date.now(),s=qa(e.flags,n.flags);s.session===void 0&&(s.session=t);let c=await r({token:e.token,session:t,command:n.command,positionals:n.positionals,input:n.input,flags:s,runtime:n.runtime===void 0?e.runtime:n.runtime,meta:Xa(e.meta,a)}),l=Date.now()-o;return c.ok?{ok:!0,step:i,result:{step:i,command:n.command,ok:!0,data:c.data??{},durationMs:l}}:{ok:!1,step:i,error:c.error}}function Qa(e){return e}function $a(e,t,n){return{ok:!1,error:{code:e,message:t,...n?{details:n}:{}}}}export{br as $,ne as $n,wt as $t,wi as A,Oe as An,Rn as At,ni as B,xe as Bn,fn as Bt,ya as C,Ne as Cn,N as Ct,Ai as D,Ae as Dn,Bn as Dt,Ni as E,Re as En,Un as Et,oi as F,_ as Fn,tn as Ft,Nr as G,ue as Gn,Gt,Wr as H,_e as Hn,Zt as Ht,si as I,we as In,hn as It,Dr as J,ie as Jn,qt as Jt,Er as K,le as Kn,Yt as Kt,ri as L,Ce as Ln,pn as Lt,_i as M,Te as Mn,Fn as Mt,ai as N,g as Nn,Pn as Nt,Mi as O,Ie as On,jn as Ot,li as P,Ee as Pn,In as Pt,vr as Q,oe as Qn,zt as Qt,ci as R,h as Rn,gn as Rt,ba as S,Le as Sn,Wn as St,xa as T,Fe as Tn,Nn as Tt,Fr as U,ge as Un,Qt as Ut,Gr as V,be as Vn,A as Vt,Ir as W,m as Wn,Kt as Wt,kr as X,se as Xn,Lt as Xt,Ar as Y,re as Yn,Xt as Yt,Cr as Z,ae as Zn,Bt as Zt,_a as _,x as _n,Yn as _t,Na as a,pt as an,P as at,sa as b,ze as bn,Jn as bt,Aa as c,lt as cn,ur as ct,wa as d,vt as dn,ar as dt,Ct as en,ye as er,xr as et,Oa as f,bt as fn,dr as ft,ga as g,Ke as gn,er as gt,Q as h,We as hn,$n as ht,Ha as i,at as in,pr as it,vi as j,v as jn,An as jt,xi as k,je as kn,zn as kt,ja as l,ct as ln,tr as lt,Ea as m,qe as mn,or as mt,Ga as n,D as nn,d as nr,wr as nt,Ma as o,mt as on,lr as ot,Da as p,He as pn,fr as pt,Or as q,ce as qn,Jt as qt,Fa as r,Tt as rn,hr as rt,ka as s,ht as sn,cr as st,Ja as t,Et as tn,ve as tr,Sr as tt,Ta as u,st as un,sr as ut,Ca as v,Je as vn,Zn as vt,va as w,Pe as wn,Ln as wt,Sa as x,y as xn,Xn as xt,oa as y,S as yn,qn as yt,ti as z,Se as zn,vn as zt};
@@ -1,11 +1,11 @@
1
1
  //#region packages/kernel/src/device.d.ts
2
2
  declare const APPLE_OS_VALUES: readonly ['ios', 'ipados', 'tvos', 'watchos', 'visionos', 'macos'];
3
3
  type AppleOS = (typeof APPLE_OS_VALUES)[number];
4
- declare const PLATFORMS: readonly ['apple', 'android', 'vega', 'linux', 'web'];
4
+ declare const PLATFORMS: readonly ['apple', 'android', 'harmonyos', 'vega', 'linux', 'web'];
5
5
  type Platform = (typeof PLATFORMS)[number];
6
- declare const PUBLIC_PLATFORMS: readonly ['ios', 'macos', 'android', 'vega', 'linux', 'web'];
6
+ declare const PUBLIC_PLATFORMS: readonly ['ios', 'macos', 'android', 'harmonyos', 'vega', 'linux', 'web'];
7
7
  type PublicPlatform = (typeof PUBLIC_PLATFORMS)[number];
8
- declare const PLATFORM_SELECTORS: readonly ["apple", "android", "vega", "linux", "web", "ios", "macos"];
8
+ declare const PLATFORM_SELECTORS: readonly ["apple", "android", "harmonyos", "vega", "linux", "web", "ios", "macos"];
9
9
  type PlatformSelector = (typeof PLATFORM_SELECTORS)[number];
10
10
  declare const DEVICE_KINDS: readonly ['simulator', 'emulator', 'device'];
11
11
  type DeviceKind = (typeof DEVICE_KINDS)[number];
@@ -44,9 +44,21 @@ type SnapshotQualityVerdict = {
44
44
  state: 'healthy' | 'recovered' | 'sparse';
45
45
  backend: SnapshotCaptureBackend;
46
46
  reason?: string;
47
- reasonCode?: 'ax-rejected' | 'sparse-tree' | 'budget' | 'no-nodes' | 'capture-failed' | 'deferred';
47
+ reasonCode?: 'ax-rejected' | 'sparse-tree' | 'budget' | 'no-nodes' | 'capture-failed' | 'deferred' | 'requested-backend';
48
48
  effectiveDepth?: number;
49
49
  collapsedLeafIndexes?: number[];
50
+ /**
51
+ * Coverage of an opt-in custom-action pass (`snapshot --actions`): how many
52
+ * merged elements were eligible and how many the bounded pass reached. An
53
+ * unread element is indistinguishable from one with no actions, so a partial
54
+ * pass has to be disclosed rather than left to look complete.
55
+ */
56
+ customActions?: {
57
+ read: number;
58
+ candidates: number;
59
+ truncated: number;
60
+ blocked: boolean;
61
+ };
50
62
  };
51
63
  type Rect = {
52
64
  x: number;
@@ -70,6 +82,12 @@ type SnapshotOptions = {
70
82
  * captured the way its baseline was.
71
83
  */
72
84
  preferredBackend?: 'private-ax';
85
+ /**
86
+ * Read accessibility custom actions for elements that merge their children
87
+ * away. Opt-in because each such element costs its own accessibility round
88
+ * trip; see `RawSnapshotNode.actions`.
89
+ */
90
+ customActions?: boolean;
73
91
  };
74
92
  type RawSnapshotNode = {
75
93
  index: number;
@@ -96,6 +114,14 @@ type RawSnapshotNode = {
96
114
  hiddenContentBelow?: boolean;
97
115
  interactionBlocked?: 'covered';
98
116
  presentationHints?: string[];
117
+ /**
118
+ * Accessibility custom actions the element exposes (iOS
119
+ * `UIAccessibilityCustomAction`, React Native `accessibilityActions`). Merged
120
+ * cards publish their real affordances here instead of as child elements, so
121
+ * this is often the only evidence that a collapsed node has any. Populated by
122
+ * opt-in captures only — see `snapshot --actions`.
123
+ */
124
+ actions?: string[];
99
125
  };
100
126
  type SnapshotNode = RawSnapshotNode & {
101
127
  ref: string;
@@ -108,7 +134,7 @@ type SnapshotNode = RawSnapshotNode & {
108
134
  inheritsLabel?: true;
109
135
  inheritsIdentifier?: true;
110
136
  };
111
- type SnapshotBackend = 'xctest' | 'android' | 'macos-helper' | 'linux-atspi' | 'web';
137
+ type SnapshotBackend = 'xctest' | 'android' | 'harmonyos-arkui' | 'macos-helper' | 'linux-atspi' | 'web';
112
138
  type SnapshotState = {
113
139
  nodes: SnapshotNode[];
114
140
  createdAt: number;
@@ -1,2 +1,2 @@
1
1
  const e=/(token|secret|password|authorization|cookie|api[_-]?key|access[_-]?key|private[_-]?key|user[_-]?code|device[_-]?code|refresh[_-]?credential)/i,t=/\b(?:bearer\s+[a-z0-9._-]+|adc_(?:agent|live|refresh|cli)_[a-z0-9._-]+)\b/gi,n=/\b([a-z0-9_-]*(?:api[_-]?key|token|secret|password|user[_-]?code|device[_-]?code|refresh[_-]?credential)[a-z0-9_-]*)(\s*[=:]\s*)("[^"]*"|'[^']*'|\S+)/gi,r=/https?:\/\/[^\s"'<>]+/gi;function i(e){return a(e,new WeakSet)}function a(t,n,r){if(t==null)return t;if(typeof t==`string`)return o(t,r);if(typeof t!=`object`)return t;if(n.has(t))return`[Circular]`;if(n.add(t),Array.isArray(t))return t.map(e=>a(e,n));let i={};for(let[r,o]of Object.entries(t)){if(e.test(r)){i[r]=`[REDACTED]`;continue}i[r]=a(o,n,r)}return i}function o(r,i){let a=r.trim();if(!a)return r;if(i&&e.test(i))return`[REDACTED]`;let o=s(a);return o=o.replace(t,`[REDACTED]`),o=o.replace(n,(e,t,n,r,i,a)=>l({key:t,separator:n,rawValue:r,offset:i,input:a})||c(r)?e:`${t}${n}[REDACTED]`),o===a?a.length>400?`${a.slice(0,200)}...<truncated>`:a:o}function s(e){return e.replace(r,e=>u(e)??e)}function c(e){return/^adc_(?:agent|live|refresh|cli)_\.\.\.$/i.test(e)}function l(e){if(e.key.toLowerCase()!==`token`||!e.separator.includes(`:`))return!1;try{return new URL(e.rawValue).pathname.replace(/\/+$/,``)===`/api-keys`?/(?:^|\b)(?:service\/)?api\s+$/i.test(e.input.slice(0,e.offset)):!1}catch{return!1}}function u(e){try{let t=new URL(e);return t.search&&=`?REDACTED`,(t.username||t.password)&&(t.username=`REDACTED`,t.password=`REDACTED`),t.toString()}catch{return null}}const d=[`INVALID_ARGS`,`DEVICE_NOT_FOUND`,`DEVICE_IN_USE`,`TOOL_MISSING`,`APP_NOT_INSTALLED`,`UNSUPPORTED_PLATFORM`,`UNSUPPORTED_OPERATION`,`NOT_IMPLEMENTED`,`COMMAND_FAILED`,`SESSION_NOT_FOUND`,`UNAUTHORIZED`,`AMBIGUOUS_MATCH`,`REPLAY_DIVERGENCE`,`REPAIR_SESSION_EXPIRED`,`REPAIR_COMMIT_FAILED`,`UNKNOWN`];function f(e,t=`COMMAND_FAILED`){return typeof e==`string`&&e.length>0?e:t}var p=class extends Error{code;details;cause;constructor(e,t,n,r){super(t),this.code=e,this.details=n,this.cause=r}};function m(e){throw new p(f(e.code),e.message,{...e.details??{},hint:e.hint,diagnosticId:e.diagnosticId,logPath:e.logPath,retriable:e.retriable,supportedOn:e.supportedOn})}function h(e,t=`UNKNOWN`){return e instanceof p?e:e instanceof Error?new p(t,e.message,void 0,e):new p(t,`Unknown error`,{err:e})}function g(e){return e instanceof p}function _(e,t={}){return v(e,t)}function v(e,t={}){let n=h(e),r=n.details?i(n.details):void 0,a=w(r,`diagnosticId`)??t.diagnosticId,o=w(r,`logPath`)??t.logPath,s=w(r,`hint`)??A(n.code),c=T(r,`retriable`)??k(n.code),l=w(r,`supportedOn`),u=E(r),d=b(n.code,n.message,r);return{code:n.code,message:d,hint:s,diagnosticId:a,logPath:o,...c===void 0?{}:{retriable:c},...l===void 0?{}:{supportedOn:l},details:u}}const y=/^\S+ exited with code -?\d+$/;function b(e,t,n){if(e!==`COMMAND_FAILED`||n?.processExitError!==!0)return t;let r=C(typeof n?.stderr==`string`?n.stderr:``);return r?y.test(t)?r:t.includes(r)?t:`${t}: ${r}`:t}const x=[/^an error was encountered processing the command/i,/^underlying error\b/i,/^simulator device failed to complete the requested operation/i],S=/^(?:(?:adb|xcrun|simctl):\s*)?(?:error:\s*)?/i;function C(e){for(let t of e.split(`
2
- `)){let e=t.trim();if(!e||x.some(t=>t.test(e)))continue;let n=e.replace(S,``).trim();if(n)return n.length>200?`${n.slice(0,200)}...`:n}return null}function w(e,t){let n=e?.[t];return typeof n==`string`?n:void 0}function T(e,t){let n=e?.[t];return typeof n==`boolean`?n:void 0}function E(e){if(!e)return;let t={...e};return delete t.hint,delete t.diagnosticId,delete t.logPath,delete t.retriable,delete t.supportedOn,Object.keys(t).length>0?t:void 0}const D={DEVICE_IN_USE:!0};function O(e){return d.includes(e)}function k(e){return O(e)?D[e]:void 0}function A(e){switch(e){case`INVALID_ARGS`:return`Check command arguments and run --help for usage examples.`;case`SESSION_NOT_FOUND`:return`Run open first or pass an explicit device selector.`;case`TOOL_MISSING`:return`Install required platform tooling and ensure it is available in PATH.`;case`DEVICE_NOT_FOUND`:return`Verify the target device is booted/connected and selectors match.`;case`APP_NOT_INSTALLED`:return`Run apps to discover the exact installed package or bundle id, or install the app before open.`;case`UNSUPPORTED_OPERATION`:return`This command is not available for the selected platform/device.`;case`UNSUPPORTED_PLATFORM`:return`This platform is not supported for the requested operation; run devices to inspect available targets.`;case`AMBIGUOUS_MATCH`:return`Multiple candidates matched. Narrow the query or pass an exact identifier.`;case`DEVICE_IN_USE`:return`The device is busy with another agent-device request; retry once it frees up.`;case`REPLAY_DIVERGENCE`:return`Read details.divergence (screen/suggestions) for repair context, or rerun with --json for the full report.`;case`REPAIR_SESSION_EXPIRED`:return`The --save-script repair session was reaped before it was finalized; re-run replay <script> --save-script from the start.`;case`REPAIR_COMMIT_FAILED`:return`The repair transaction completed, but committing its healed script failed at teardown (no-clobber refusal or a filesystem error); inspect the target path/permissions, then re-run replay <script> --save-script to retry.`;case`NOT_IMPLEMENTED`:return`This command is part of the planned API but is not implemented yet.`;case`COMMAND_FAILED`:return`Retry with --debug and inspect diagnostics log for details.`;case`UNAUTHORIZED`:return`Refresh daemon metadata and retry the command.`;case`UNKNOWN`:return`Unexpected internal error. Retry with --debug and report the diagnostics log if it persists.`;default:return`Retry with --debug and inspect diagnostics log for details.`}}function j(e){return e===`xctest`||e===`android`||e===`macos-helper`||e===`linux-atspi`||e===`web`}function M(e){return e===void 0||e===`xctest`||e===`android`}function N(e){return e.map((e,t)=>({...e,ref:`e${t+1}`}))}const P=/^~s(\d+)$/,F=`Refs look like @e12, optionally pinned to the snapshot generation that minted them: @e12~s3 (the ref, then "~s" and the refsGeneration reported by the issuing snapshot/find response).`;function I(e){let t=e.trim(),n=t.indexOf(`~`);if(n===-1)return{base:t};let r=P.exec(t.slice(n));return!r||n===0?null:{base:t.slice(0,n),generation:Number(r[1])}}function L(e){let t=I(e);if(!t)return null;let n=t.base;return n.startsWith(`@`)?n.slice(1)||null:n.startsWith(`e`)?n:null}function R(e,t){return e.find(e=>e.ref===t)??null}function z(e){return JSON.stringify({interactiveOnly:e?.interactiveOnly===!0,depth:typeof e?.depth==`number`?e.depth:null,scope:e?.scope?.trim()||null,raw:e?.raw===!0})}function B(e){if(e)return{depth:e.snapshotDepth,interactiveOnly:e.snapshotInteractiveOnly,raw:e.snapshotRaw,scope:e.snapshotScope}}function V(e){return{x:Math.round(e.x+e.width/2),y:Math.round(e.y+e.height/2)}}const H=[`summary`,`headers`,`body`,`all`],ee=[`digest`,`default`,`full`];function U(e){return e!==void 0&&e!=="default"}function W(e){return{parse(t){return e(t,`$`)}}}function G(e,t){throw Error(`${e}: ${t}`)}function K(e,t){return(!e||typeof e!=`object`||Array.isArray(e))&&G(t,`Expected an object`),e}function q(e,t){return typeof e!=`string`&&G(t,`Expected a string`),e}function J(e,t){return Number.isInteger(e)||G(t,`Expected an integer`),e}function Y(e,t){return Array.isArray(e)||G(t,`Expected an array`),e}function X(e,t,n){let r=e[t];return r===void 0?void 0:q(r,`${n}.${t}`)}function Z(e,t,n){let r=e[t];if(r!==void 0)return Y(r,`${n}.${t}`).map((e,r)=>q(e,`${n}.${t}[${String(r)}]`))}function Q(e,t,n){let r=e[t];return r===void 0?void 0:J(r,`${n}.${t}`)}function $(e,t,n){let r=e[t];return r===void 0?void 0:K(r,`${n}.${t}`)}function te(e,t,n,r){let i=e[t];if(i!==void 0)return(typeof i!=`string`||!n.includes(i))&&G(`${r}.${t}`,`Expected one of: ${n.join(`, `)}`),i}const ne=W((e,t)=>{let n=K(e,t);return{platform:te(n,`platform`,[`ios`,`android`],t),metroHost:X(n,`metroHost`,t),metroPort:Q(n,`metroPort`,t),bundleUrl:X(n,`bundleUrl`,t),launchUrl:X(n,`launchUrl`,t)}});function re(e,t){let n=e.id;return n==null||typeof n!=`string`&&typeof n!=`number`&&G(`${t}.id`,`Expected a string, number, or null`),n}const ie=W((e,t)=>{let n=K(e,t);return{jsonrpc:X(n,`jsonrpc`,t),id:re(n,t),method:X(n,`method`,t),params:n.params}}),ae=W((e,t)=>{let n=K(e,t);return{token:X(n,`token`,t),session:X(n,`session`,t),command:X(n,`command`,t),positionals:Z(n,`positionals`,t),input:$(n,`input`,t),flags:$(n,`flags`,t),runtime:$(n,`runtime`,t),meta:$(n,`meta`,t)}});export{k as C,i as E,v as S,f as T,p as _,U as a,g as b,N as c,R as d,j as f,M as g,I as h,ne as i,z as l,B as m,ee as n,ie as o,L as p,ae as r,F as s,H as t,V as u,h as v,m as w,_ as x,A as y};
2
+ `)){let e=t.trim();if(!e||x.some(t=>t.test(e)))continue;let n=e.replace(S,``).trim();if(n)return n.length>200?`${n.slice(0,200)}...`:n}return null}function w(e,t){let n=e?.[t];return typeof n==`string`?n:void 0}function T(e,t){let n=e?.[t];return typeof n==`boolean`?n:void 0}function E(e){if(!e)return;let t={...e};return delete t.hint,delete t.diagnosticId,delete t.logPath,delete t.retriable,delete t.supportedOn,Object.keys(t).length>0?t:void 0}const D={DEVICE_IN_USE:!0};function O(e){return d.includes(e)}function k(e){return O(e)?D[e]:void 0}function A(e){switch(e){case`INVALID_ARGS`:return`Check command arguments and run --help for usage examples.`;case`SESSION_NOT_FOUND`:return`Run open first or pass an explicit device selector.`;case`TOOL_MISSING`:return`Install required platform tooling and ensure it is available in PATH.`;case`DEVICE_NOT_FOUND`:return`Verify the target device is booted/connected and selectors match.`;case`APP_NOT_INSTALLED`:return`Run apps to discover the exact installed package or bundle id, or install the app before open.`;case`UNSUPPORTED_OPERATION`:return`This command is not available for the selected platform/device.`;case`UNSUPPORTED_PLATFORM`:return`This platform is not supported for the requested operation; run devices to inspect available targets.`;case`AMBIGUOUS_MATCH`:return`Multiple candidates matched. Narrow the query or pass an exact identifier.`;case`DEVICE_IN_USE`:return`The device is busy with another agent-device request; retry once it frees up.`;case`REPLAY_DIVERGENCE`:return`Read details.divergence (screen/suggestions) for repair context, or rerun with --json for the full report.`;case`REPAIR_SESSION_EXPIRED`:return`The --save-script repair session was reaped before it was finalized; re-run replay <script> --save-script from the start.`;case`REPAIR_COMMIT_FAILED`:return`The repair transaction completed, but committing its healed script failed at teardown (no-clobber refusal or a filesystem error); inspect the target path/permissions, then re-run replay <script> --save-script to retry.`;case`NOT_IMPLEMENTED`:return`This command is part of the planned API but is not implemented yet.`;case`COMMAND_FAILED`:return`Retry with --debug and inspect diagnostics log for details.`;case`UNAUTHORIZED`:return`Refresh daemon metadata and retry the command.`;case`UNKNOWN`:return`Unexpected internal error. Retry with --debug and report the diagnostics log if it persists.`;default:return`Retry with --debug and inspect diagnostics log for details.`}}function j(e){return e===`xctest`||e===`android`||e===`harmonyos-arkui`||e===`macos-helper`||e===`linux-atspi`||e===`web`}function M(e){return e===void 0||e===`xctest`||e===`android`||e===`harmonyos-arkui`}function N(e){return e.map((e,t)=>({...e,ref:`e${t+1}`}))}const P=/^~s(\d+)$/,F=`Refs look like @e12, optionally pinned to the snapshot generation that minted them: @e12~s3 (the ref, then "~s" and the refsGeneration reported by the issuing snapshot/find response).`;function I(e){let t=e.trim(),n=t.indexOf(`~`);if(n===-1)return{base:t};let r=P.exec(t.slice(n));return!r||n===0?null:{base:t.slice(0,n),generation:Number(r[1])}}function L(e){let t=I(e);if(!t)return null;let n=t.base;return n.startsWith(`@`)?n.slice(1)||null:n.startsWith(`e`)?n:null}function R(e,t){return e.find(e=>e.ref===t)??null}function z(e){return JSON.stringify({interactiveOnly:e?.interactiveOnly===!0,depth:typeof e?.depth==`number`?e.depth:null,scope:e?.scope?.trim()||null,raw:e?.raw===!0,customActions:e?.customActions===!0})}function B(e){if(e)return{depth:e.snapshotDepth,interactiveOnly:e.snapshotInteractiveOnly,raw:e.snapshotRaw,scope:e.snapshotScope,customActions:e.snapshotCustomActions}}function V(e){return{x:Math.round(e.x+e.width/2),y:Math.round(e.y+e.height/2)}}const H=[`summary`,`headers`,`body`,`all`],ee=[`digest`,`default`,`full`];function U(e){return e!==void 0&&e!=="default"}function W(e){return{parse(t){return e(t,`$`)}}}function G(e,t){throw Error(`${e}: ${t}`)}function K(e,t){return(!e||typeof e!=`object`||Array.isArray(e))&&G(t,`Expected an object`),e}function q(e,t){return typeof e!=`string`&&G(t,`Expected a string`),e}function J(e,t){return Number.isInteger(e)||G(t,`Expected an integer`),e}function Y(e,t){return Array.isArray(e)||G(t,`Expected an array`),e}function X(e,t,n){let r=e[t];return r===void 0?void 0:q(r,`${n}.${t}`)}function Z(e,t,n){let r=e[t];if(r!==void 0)return Y(r,`${n}.${t}`).map((e,r)=>q(e,`${n}.${t}[${String(r)}]`))}function Q(e,t,n){let r=e[t];return r===void 0?void 0:J(r,`${n}.${t}`)}function $(e,t,n){let r=e[t];return r===void 0?void 0:K(r,`${n}.${t}`)}function te(e,t,n,r){let i=e[t];if(i!==void 0)return(typeof i!=`string`||!n.includes(i))&&G(`${r}.${t}`,`Expected one of: ${n.join(`, `)}`),i}const ne=W((e,t)=>{let n=K(e,t);return{platform:te(n,`platform`,[`ios`,`android`],t),metroHost:X(n,`metroHost`,t),metroPort:Q(n,`metroPort`,t),bundleUrl:X(n,`bundleUrl`,t),launchUrl:X(n,`launchUrl`,t)}});function re(e,t){let n=e.id;return n==null||typeof n!=`string`&&typeof n!=`number`&&G(`${t}.id`,`Expected a string, number, or null`),n}const ie=W((e,t)=>{let n=K(e,t);return{jsonrpc:X(n,`jsonrpc`,t),id:re(n,t),method:X(n,`method`,t),params:n.params}}),ae=W((e,t)=>{let n=K(e,t);return{token:X(n,`token`,t),session:X(n,`session`,t),command:X(n,`command`,t),positionals:Z(n,`positionals`,t),input:$(n,`input`,t),flags:$(n,`flags`,t),runtime:$(n,`runtime`,t),meta:$(n,`meta`,t)}});export{k as C,i as E,v as S,f as T,p as _,U as a,g as b,N as c,R as d,j as f,M as g,I as h,ne as i,z as l,B as m,ee as n,ie as o,L as p,ae as r,F as s,H as t,V as u,h as v,m as w,_ as x,A as y};
@@ -1 +1 @@
1
- import{_ as e}from"./sdk-contracts.js";const t=[`ios`,`ipados`,`tvos`,`watchos`,`visionos`,`macos`],n=[`apple`,`android`,`vega`,`linux`,`web`],r=[`ios`,`macos`,`android`,`vega`,`linux`,`web`],i=[...n,`ios`,`macos`],a=[`mobile`,`tv`,`desktop`];function o(e){return e===`apple`||e===`ios`||e===`macos`}function s(e){return e.appleOs===`macos`||e.platform===`macos`}function c(e){return o(e.platform)&&!s(e)}function l(e){return e.platform===`android`||o(e.platform)&&!s(e)}function u(e){return o(e.platform)?s(e)?`macos`:`ios`:e.platform}function d(e){return e===`macos`?{platform:`apple`,appleOs:`macos`}:e===`ios`?{platform:`apple`}:{platform:e}}function f(e){return o(e.platform)&&e.target===`tv`}function p(e){return e.appleOs?e.appleOs:e.platform===`macos`?`macos`:f(e)?`tvos`:`ios`}function m(e){return r.includes(e)}function h(e){return t.includes(e)}function g(e,t){return t?t===`apple`?o(e.platform):t===`ios`?o(e.platform)&&!s(e):t===`macos`?o(e.platform)&&s(e):e.platform===t:!0}function _(e,t){return t?v(t):e===`macos`||e===`desktop`?`macOS`:e===`tv`?`tvOS`:`iOS`}function v(e){switch(e){case`tvos`:return`tvOS`;case`macos`:return`macOS`;case`visionos`:return`visionOS`;default:return`iOS`}}function y(e){let{simulatorSetPath:t,platform:n,target:r}=e;if(t&&!(n===`macos`||r===`desktop`))return t}function b(e){return e.map((e,t)=>({device:e,index:t})).sort((e,t)=>A(e,t)).map(({device:e})=>e)}function x(e){return!e||e===`apple`||e===`ios`}async function S(t,n,r={}){let i=t.filter(e=>w(e,n));if(n.udid){let t=i.find(e=>e.id===n.udid&&o(e.platform));if(!t)throw new e(`DEVICE_NOT_FOUND`,`No Apple device with UDID ${n.udid}`);return t}if(n.serial){let t=i.find(e=>e.id===n.serial&&E(e.platform));if(!t)throw new e(`DEVICE_NOT_FOUND`,D(n));return t}if(r.allowStoppedAndroidAvdPlaceholders!==!0&&(i=i.filter(e=>!C(e))),n.deviceName){let t=k(n.deviceName),r=i.find(e=>k(e.name)===t);if(!r)throw new e(`DEVICE_NOT_FOUND`,`No device named ${n.deviceName}`);return r}N(i)&&(i=b(i));let a=i[0];if(a!==void 0&&i.length===1)return a;i.length===0&&O(n,r);let s=i.filter(e=>e.kind!==`device`),c=s.length>0?s:i,l=c.filter(e=>e.booted),u=l[0];if(u&&l.length===1&&!N(c))return u;let d=N(c)?c[0]:l[0]??c[0];return d||O(n,r),d}function C(e){return e.platform===`android`&&e.kind===`emulator`&&e.booted===!1&&!/^emulator-\d+$/.test(e.id)}function w(e,t,n={}){return g(e,t.platform)&&(!t.target||(e.target??`mobile`)===t.target)&&(!n.includeExplicitSelectors||T(e,t))}function T(e,t){return!(t.udid&&!(e.id===t.udid&&o(e.platform))||t.serial&&!(e.id===t.serial&&E(e.platform))||t.deviceName&&k(e.name)!==k(t.deviceName))}function E(e){return e===`android`||e===`vega`}function D(e){return e.platform===`android`?`No Android device with serial ${e.serial}`:e.platform===`vega`?`No Vega VVD with serial ${e.serial}`:`No Android device or Vega VVD with serial ${e.serial}`}function O(t,n){let r=n.simulatorSetPath;throw r&&x(t.platform)?new e(`DEVICE_NOT_FOUND`,`No devices found in the scoped simulator set`,{simulatorSetPath:r,hint:`The simulator set at "${r}" appears to be empty. Create a compatible simulator first with xcrun simctl --set "${r}" create, or remove the scoped simulator set.`,selector:t}):new e(`DEVICE_NOT_FOUND`,`No devices found`,{selector:t})}function k(e){return e.toLowerCase().replace(/_/g,` `).replace(/\s+/g,` `).trim()}function A(e,t){return j(e.device)-j(t.device)||Number(t.device.booted===!0)-Number(e.device.booted===!0)||e.device.name.localeCompare(t.device.name)||e.index-t.index}function j(e){return e.kind===`simulator`?M(e,0,1,2,3):e.kind===`device`&&o(e.platform)&&!s(e)?M(e,10,11,12,13):14}function M(e,t,n,r,i){return{mobile:P(e.name)?n:t,tv:r,desktop:i}[e.target??`mobile`]}function N(e){return e.length>0&&e.every(e=>o(e.platform))}function P(e){return/\bipad\b/i.test(e)}export{y as _,h as a,b,s as c,E as d,f,_ as g,u as h,d as i,l,g as m,i as n,o,w as p,r,c as s,a as t,m as u,S as v,p as y};
1
+ import{_ as e}from"./sdk-contracts.js";function t(e){return Object.freeze({family:e.platform,...e.appleOs===void 0?{}:{appleOs:e.appleOs},kind:e.kind,...e.target===void 0?{}:{target:e.target},...e.iosPhysicalDeviceBackend===void 0?{}:{iosPhysicalDeviceBackend:e.iosPhysicalDeviceBackend}})}function n(e){return Object.freeze({id:e.id,...t(e)})}function r(e){return JSON.stringify([e.id,...o(e)])}function i(e,t){return r(e)===r(t)}function a(e,t){return JSON.stringify(o(e))===JSON.stringify(o(t))}function o(e){return[e.family,e.appleOs??null,e.kind,e.target??null,e.iosPhysicalDeviceBackend??null]}const s=[`ios`,`ipados`,`tvos`,`watchos`,`visionos`,`macos`],c=[`apple`,`android`,`harmonyos`,`vega`,`linux`,`web`],l=[`ios`,`macos`,`android`,`harmonyos`,`vega`,`linux`,`web`],u=[...c,`ios`,`macos`],d=[`mobile`,`tv`,`desktop`];function f(e){return e===`apple`||e===`ios`||e===`macos`}function p(e){return e.appleOs===`macos`||e.platform===`macos`}function m(e){return f(e.platform)&&!p(e)}function h(e){return e.platform===`android`||e.platform===`harmonyos`||f(e.platform)&&!p(e)}function g(e){return f(e.platform)?p(e)?`macos`:`ios`:e.platform}function _(e){return e===`macos`?{platform:`apple`,appleOs:`macos`}:e===`ios`?{platform:`apple`}:{platform:e}}function v(e){return f(e.platform)&&e.target===`tv`}function y(e){return e.appleOs?e.appleOs:e.platform===`macos`?`macos`:v(e)?`tvos`:`ios`}function b(e){return c.includes(e)}function x(e){return l.includes(e)}function S(e){return s.includes(e)}function C(e,t){return t?t===`apple`?f(e.platform):t===`ios`?f(e.platform)&&!p(e):t===`macos`?f(e.platform)&&p(e):e.platform===t:!0}function w(e,t){return t?T(t):e===`macos`||e===`desktop`?`macOS`:e===`tv`?`tvOS`:`iOS`}function T(e){switch(e){case`tvos`:return`tvOS`;case`macos`:return`macOS`;case`visionos`:return`visionOS`;default:return`iOS`}}function E(e){let{simulatorSetPath:t,platform:n,target:r}=e;if(t&&!(n===`macos`||r===`desktop`))return t}function D(e){return e.map((e,t)=>({device:e,index:t})).sort((e,t)=>U(e,t)).map(({device:e})=>e)}function O(e){return!e||e===`apple`||e===`ios`}async function k(e,t,n={}){let r=e.filter(e=>L(e,t));return A(r,t)||(n.allowStoppedAndroidAvdPlaceholders!==!0&&(r=r.filter(e=>!I(e))),N(r,t.deviceName)||(K(r)&&(r=D(r)),P(r,t,n)))}function A(e,t){if(t.udid)return j(e,t.udid);if(t.serial)return M(e,t)}function j(t,n){let r=t.find(e=>e.id===n&&f(e.platform));if(!r)throw new e(`DEVICE_NOT_FOUND`,`No Apple device with UDID ${n}`);return r}function M(t,n){let r=t.find(e=>e.id===n.serial&&z(e.platform));if(!r)throw new e(`DEVICE_NOT_FOUND`,B(n));return r}function N(t,n){if(!n)return;let r=H(n),i=t.find(e=>H(e.name)===r);if(!i)throw new e(`DEVICE_NOT_FOUND`,`No device named ${n}`);return i}function P(e,t,n){let r=e[0];if(r!==void 0&&e.length===1)return r;e.length===0&&V(t,n);let i=F(e);return i||V(t,n),i}function F(e){let t=e.filter(e=>e.kind!==`device`),n=t.length>0?t:e;if(K(n))return n[0];let r=n.filter(e=>e.booted),i=r[0];return i&&r.length===1?i:r[0]??n[0]}function I(e){return e.platform===`android`&&e.kind===`emulator`&&e.booted===!1&&!/^emulator-\d+$/.test(e.id)}function L(e,t,n={}){return C(e,t.platform)&&(!t.target||(e.target??`mobile`)===t.target)&&(!n.includeExplicitSelectors||R(e,t))}function R(e,t){return!(t.udid&&!(e.id===t.udid&&f(e.platform))||t.serial&&!(e.id===t.serial&&z(e.platform))||t.deviceName&&H(e.name)!==H(t.deviceName))}function z(e){return e===`android`||e===`harmonyos`||e===`vega`}function B(e){return e.platform===`android`?`No Android device with serial ${e.serial}`:e.platform===`vega`?`No Vega VVD with serial ${e.serial}`:e.platform===`harmonyos`?`No HarmonyOS device with serial ${e.serial}`:`No Android, HarmonyOS device, or Vega VVD with serial ${e.serial}`}function V(t,n){let r=n.simulatorSetPath;throw r&&O(t.platform)?new e(`DEVICE_NOT_FOUND`,`No devices found in the scoped simulator set`,{simulatorSetPath:r,hint:`The simulator set at "${r}" appears to be empty. Create a compatible simulator first with xcrun simctl --set "${r}" create, or remove the scoped simulator set.`,selector:t}):new e(`DEVICE_NOT_FOUND`,`No devices found`,{selector:t})}function H(e){return e.toLowerCase().replace(/_/g,` `).replace(/\s+/g,` `).trim()}function U(e,t){return W(e.device)-W(t.device)||Number(t.device.booted===!0)-Number(e.device.booted===!0)||e.device.name.localeCompare(t.device.name)||e.index-t.index}function W(e){return e.kind===`simulator`?G(e,0,1,2,3):e.kind===`device`&&f(e.platform)&&!p(e)?G(e,10,11,12,13):14}function G(e,t,n,r,i){return{mobile:q(e.name)?n:t,tv:r,desktop:i}[e.target??`mobile`]}function K(e){return e.length>0&&e.every(e=>f(e.platform))}function q(e){return/\bipad\b/i.test(e)}export{n as C,a as D,i as E,D as S,t as T,g as _,_ as a,k as b,m as c,b as d,x as f,C as g,L as h,l as i,p as l,v as m,c as n,S as o,z as p,u as r,f as s,d as t,h as u,w as v,r as w,y as x,E as y};
@@ -1 +1 @@
1
- import{jt as e}from"./sdk-batch-runner.js";function t(t,n,r,i){return e(t,n,r,typeof i==`boolean`?{requireRect:i}:i)}export{t};
1
+ import{cn as e}from"./sdk-batch-runner.js";function t(t,n,r,i){return e(t,n,r,typeof i==`boolean`?{requireRect:i}:i)}export{t};
@@ -1 +1 @@
1
- import{n as e}from"./sdk-device.js";import{E as t}from"./sdk-android-adb.js";const n=[`portrait`,`landscape`],r=[{key:`stateDir`,type:`string`,path:!0},{key:`daemonBaseUrl`,type:`string`},{key:`daemonAuthToken`,type:`string`},{key:`daemonTransport`,type:`enum`,enumValues:[`auto`,`socket`,`http`]},{key:`daemonServerMode`,type:`enum`,enumValues:[`socket`,`http`,`dual`]},{key:`tenant`,type:`string`},{key:`sessionIsolation`,type:`enum`,enumValues:[`none`,`tenant`]},{key:`runId`,type:`string`},{key:`leaseId`,type:`string`},{key:`leaseBackend`,type:`enum`,enumValues:[`ios-simulator`,`ios-instance`,`android-instance`]},{key:`platform`,type:`enum`,enumValues:e},{key:`target`,type:`enum`,enumValues:[`mobile`,`tv`,`desktop`]},{key:`device`,type:`string`},{key:`udid`,type:`string`},{key:`serial`,type:`string`},{key:`iosSimulatorDeviceSet`,type:`string`,path:!0,env:!1},{key:`androidDeviceAllowlist`,type:`string`},{key:`session`,type:`string`},{key:`providerApp`,type:`string`},{key:`providerOsVersion`,type:`string`},{key:`providerProject`,type:`string`},{key:`providerBuild`,type:`string`},{key:`providerSessionName`,type:`string`},{key:`providerDeviceOrientation`,type:`enum`,enumValues:n},{key:`providerGeoLocation`,type:`string`},{key:`providerTimezone`,type:`string`},{key:`providerLanguage`,type:`string`},{key:`providerLocale`,type:`string`},{key:`providerNetworkProfile`,type:`string`},{key:`providerCustomNetwork`,type:`string`},{key:`providerNoResignApp`,type:`boolean`},{key:`awsProjectArn`,type:`string`},{key:`awsDeviceArn`,type:`string`},{key:`awsAppArn`,type:`string`},{key:`awsRegion`,type:`string`},{key:`awsInteractionMode`,type:`enum`,enumValues:[`INTERACTIVE`,`NO_VIDEO`,`VIDEO_ONLY`]},{key:`metroProjectRoot`,type:`string`,path:!0},{key:`metroKind`,type:`enum`,enumValues:[`auto`,`react-native`,`expo`,`repack`]},{key:`metroPublicBaseUrl`,type:`string`},{key:`metroProxyBaseUrl`,type:`string`},{key:`metroBearerToken`,type:`string`},{key:`metroPreparePort`,type:`int`,min:1,max:65535},{key:`metroListenHost`,type:`string`},{key:`metroStatusHost`,type:`string`},{key:`metroStartupTimeoutMs`,type:`int`,min:1},{key:`metroProbeTimeoutMs`,type:`int`,min:1},{key:`metroRuntimeFile`,type:`string`,path:!0},{key:`metroNoReuseExisting`,type:`boolean`},{key:`metroNoInstallDeps`,type:`boolean`},{key:`launchUrl`,type:`string`}],i=[{key:`leaseProvider`,type:`string`,env:!1},{key:`deviceKey`,type:`string`,env:!1},{key:`clientId`,type:`string`,env:!1}],a=[...r,...i],o=new Map(a.map(e=>[e.key,e]));function s(e){return o.get(e)}function c(e){return s(e)?.env===!1?[]:[t(e)]}export{n as a,s as i,a as n,c as r,r as t};
1
+ import{r as e}from"./sdk-device.js";import{T as t}from"./sdk-android-adb.js";const n=[`portrait`,`landscape`],r=[{key:`stateDir`,type:`string`,path:!0},{key:`daemonBaseUrl`,type:`string`},{key:`daemonAuthToken`,type:`string`},{key:`daemonTransport`,type:`enum`,enumValues:[`auto`,`socket`,`http`]},{key:`daemonServerMode`,type:`enum`,enumValues:[`socket`,`http`,`dual`]},{key:`tenant`,type:`string`},{key:`sessionIsolation`,type:`enum`,enumValues:[`none`,`tenant`]},{key:`runId`,type:`string`},{key:`leaseId`,type:`string`},{key:`leaseBackend`,type:`enum`,enumValues:[`ios-simulator`,`ios-instance`,`android-instance`]},{key:`platform`,type:`enum`,enumValues:e},{key:`target`,type:`enum`,enumValues:[`mobile`,`tv`,`desktop`]},{key:`device`,type:`string`},{key:`udid`,type:`string`},{key:`serial`,type:`string`},{key:`iosSimulatorDeviceSet`,type:`string`,path:!0,env:!1},{key:`androidDeviceAllowlist`,type:`string`},{key:`session`,type:`string`},{key:`providerApp`,type:`string`},{key:`providerOsVersion`,type:`string`},{key:`providerProject`,type:`string`},{key:`providerBuild`,type:`string`},{key:`providerSessionName`,type:`string`},{key:`providerDeviceOrientation`,type:`enum`,enumValues:n},{key:`providerGeoLocation`,type:`string`},{key:`providerTimezone`,type:`string`},{key:`providerLanguage`,type:`string`},{key:`providerLocale`,type:`string`},{key:`providerNetworkProfile`,type:`string`},{key:`providerCustomNetwork`,type:`string`},{key:`providerNoResignApp`,type:`boolean`},{key:`awsProjectArn`,type:`string`},{key:`awsDeviceArn`,type:`string`},{key:`awsAppArn`,type:`string`},{key:`awsRegion`,type:`string`},{key:`awsInteractionMode`,type:`enum`,enumValues:[`INTERACTIVE`,`NO_VIDEO`,`VIDEO_ONLY`]},{key:`metroProjectRoot`,type:`string`,path:!0},{key:`metroKind`,type:`enum`,enumValues:[`auto`,`react-native`,`expo`,`repack`]},{key:`metroPublicBaseUrl`,type:`string`},{key:`metroProxyBaseUrl`,type:`string`},{key:`metroBearerToken`,type:`string`},{key:`metroPreparePort`,type:`int`,min:1,max:65535},{key:`metroListenHost`,type:`string`},{key:`metroStatusHost`,type:`string`},{key:`metroStartupTimeoutMs`,type:`int`,min:1},{key:`metroProbeTimeoutMs`,type:`int`,min:1},{key:`metroRuntimeFile`,type:`string`,path:!0},{key:`metroNoReuseExisting`,type:`boolean`},{key:`metroNoInstallDeps`,type:`boolean`},{key:`launchUrl`,type:`string`}],i=[{key:`leaseProvider`,type:`string`,env:!1},{key:`deviceKey`,type:`string`,env:!1},{key:`clientId`,type:`string`,env:!1}],a=[...r,...i],o=new Map(a.map(e=>[e.key,e]));function s(e){return o.get(e)}function c(e){return s(e)?.env===!1?[]:[t(e)]}export{n as a,s as i,a as n,c as r,r as t};