agent-device 0.21.7 → 0.21.9

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 (204) hide show
  1. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.7.apk → agent-device-android-ime-helper-0.21.9.apk} +0 -0
  2. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.9.apk.sha256 +1 -0
  3. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.7.manifest.json → agent-device-android-ime-helper-0.21.9.manifest.json} +4 -4
  4. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.7.apk → agent-device-android-snapshot-helper-0.21.9.apk} +0 -0
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.9.apk.sha256 +1 -0
  6. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.7.manifest.json → agent-device-android-snapshot-helper-0.21.9.manifest.json} +6 -6
  7. package/apple/macos-helper/Package.swift +16 -1
  8. package/apple/macos-helper/Sources/AgentDeviceMacOSDeviceHub/DeviceHubPose.swift +47 -0
  9. package/apple/macos-helper/Sources/AgentDeviceMacOSDeviceHub/DeviceHubWindowInventory.swift +65 -0
  10. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubPose.swift +225 -0
  11. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubSidebar.swift +57 -0
  12. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubWindowDiscovery.swift +108 -0
  13. package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/main.swift +66 -13
  14. package/apple/macos-helper/Sources/AgentDeviceMacOSInput/MouseClickDelivery.swift +116 -0
  15. package/apple/macos-helper/Sources/AgentDeviceMacOSInput/MouseClickSchedule.swift +61 -0
  16. package/apple/macos-helper/Tests/AgentDeviceMacOSDeviceHubTests/DeviceHubPoseTests.swift +30 -0
  17. package/apple/macos-helper/Tests/AgentDeviceMacOSDeviceHubTests/DeviceHubWindowInventoryTests.swift +65 -0
  18. package/apple/macos-helper/Tests/AgentDeviceMacOSInputTests/MouseClickScheduleTests.swift +58 -0
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h +1 -0
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAppScreenCapture.swift +175 -0
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +10 -2
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +42 -15
  23. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +8 -0
  24. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +45 -22
  25. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +39 -734
  26. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +20 -4
  27. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +63 -1
  28. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +13 -0
  29. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +25 -10
  30. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +5 -562
  31. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotAcquisition.swift +566 -0
  32. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +5 -1
  33. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +594 -0
  34. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.h +35 -1
  35. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.m +160 -0
  36. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +3 -0
  37. package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-frames.swift +203 -0
  38. package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotCoordinateSpace.swift +5 -0
  39. package/dist/src/absence-observation-errors.js +1 -1
  40. package/dist/src/adapter.js +1 -1
  41. package/dist/src/agent-browser-lifecycle.js +1 -1
  42. package/dist/src/agent-browser-process-record.js +1 -1
  43. package/dist/src/agent-device-client.js +2 -2
  44. package/dist/src/alert-runtime.js +1 -1
  45. package/dist/src/android-adb.js +1 -1
  46. package/dist/src/android-input-ownership.js +1 -1
  47. package/dist/src/android.js +1 -1
  48. package/dist/src/app-launch.js +1 -1
  49. package/dist/src/app-log-runtime2.js +3 -3
  50. package/dist/src/app-resolution.js +2 -2
  51. package/dist/src/apple-runner-platform.js +1 -1
  52. package/dist/src/application-lifecycle-interaction.js +1 -1
  53. package/dist/src/artifact-paths.js +1 -0
  54. package/dist/src/back-mode.js +1 -1
  55. package/dist/src/cli-config.js +1 -1
  56. package/dist/src/cli-help.js +15 -11
  57. package/dist/src/cli.js +4 -4
  58. package/dist/src/client-types.d.ts +51 -1
  59. package/dist/src/command-tools.js +3 -3
  60. package/dist/src/config.js +1 -1
  61. package/dist/src/connection-runtime.js +1 -1
  62. package/dist/src/device-claim-inspection.js +1 -1
  63. package/dist/src/device-claim-rule.js +2 -2
  64. package/dist/src/device-input-state.d.ts +1 -1
  65. package/dist/src/device-rotation.js +1 -1
  66. package/dist/src/device-selection-resolver.js +1 -1
  67. package/dist/src/device-session.js +1 -1
  68. package/dist/src/device.js +1 -1
  69. package/dist/src/device2.js +1 -1
  70. package/dist/src/devicectl.js +1 -1
  71. package/dist/src/dispatch-resolve.js +1 -1
  72. package/dist/src/display-inventory.js +1 -1
  73. package/dist/src/doctor-facade.js +1 -1
  74. package/dist/src/durable-resource.js +1 -1
  75. package/dist/src/exec.js +1 -1
  76. package/dist/src/find.js +1 -1
  77. package/dist/src/finders.js +1 -1
  78. package/dist/src/fold-runtime.js +1 -0
  79. package/dist/src/gesture-admission.js +1 -1
  80. package/dist/src/gesture-runtime.js +1 -1
  81. package/dist/src/harmonyos.js +1 -1
  82. package/dist/src/helper.js +2 -2
  83. package/dist/src/host.js +1 -0
  84. package/dist/src/interaction-positionals.js +1 -1
  85. package/dist/src/interaction-ref-policy.js +1 -1
  86. package/dist/src/interaction.js +1 -1
  87. package/dist/src/interaction2.js +1 -1
  88. package/dist/src/interactor-operation-binding.js +1 -0
  89. package/dist/src/interactor-operation-catalog.js +1 -1
  90. package/dist/src/interactor.js +4 -5
  91. package/dist/src/interactor2.js +1 -1
  92. package/dist/src/interactors.js +1 -1
  93. package/dist/src/internal/bin.js +1 -1
  94. package/dist/src/internal/daemon.js +2 -2
  95. package/dist/src/internal/png-worker.d.ts +5 -0
  96. package/dist/src/internal/png-worker.js +1 -1
  97. package/dist/src/inventory2.js +1 -1
  98. package/dist/src/ios-snapshot-acquisition.js +1 -1
  99. package/dist/src/ios-snapshot-runtime.js +1 -1
  100. package/dist/src/lease.js +1 -1
  101. package/dist/src/linux.js +1 -1
  102. package/dist/src/local-interactor-operation-set.js +1 -1
  103. package/dist/src/location-coordinates.js +1 -1
  104. package/dist/src/macos-facade.js +1 -1
  105. package/dist/src/managed-device-scope.js +1 -1
  106. package/dist/src/mechanics.js +17 -16
  107. package/dist/src/mobile-snapshot-semantics.js +1 -1
  108. package/dist/src/mp4-duration.js +1 -0
  109. package/dist/src/multitouch-support.js +1 -1
  110. package/dist/src/owner-identity.js +1 -1
  111. package/dist/src/parameterized-recorded-fill.js +1 -1
  112. package/dist/src/perf-facade.js +2 -2
  113. package/dist/src/perf-runtime-plan.js +1 -1
  114. package/dist/src/physical-device-control.js +1 -1
  115. package/dist/src/platform-request-scope.js +1 -1
  116. package/dist/src/platform-runtime-managed-owner.js +1 -1
  117. package/dist/src/platform-runtime-open-target.js +1 -1
  118. package/dist/src/platform-runtime-operation-host.js +2 -2
  119. package/dist/src/platform-runtime-runtime-hints.js +1 -1
  120. package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
  121. package/dist/src/platform-runtime-unavailable.js +1 -1
  122. package/dist/src/platform-runtime.js +1 -1
  123. package/dist/src/platform-runtime2.js +1 -1
  124. package/dist/src/png-crop-bytes.js +1 -1
  125. package/dist/src/png-encode.js +1 -0
  126. package/dist/src/png-size.js +1 -0
  127. package/dist/src/png-worker-client.js +1 -1
  128. package/dist/src/provider-webdriver.js +1 -1
  129. package/dist/src/quality-warnings.js +1 -1
  130. package/dist/src/react-native.js +1 -1
  131. package/dist/src/record-runtime.js +1 -1
  132. package/dist/src/recording-export-quality.js +1 -1
  133. package/dist/src/recording-scope.js +1 -0
  134. package/dist/src/recording.js +3 -0
  135. package/dist/src/registry.js +35 -35
  136. package/dist/src/replay.js +1 -1
  137. package/dist/src/request-admission.js +1 -1
  138. package/dist/src/request-runtime-binding.js +1 -1
  139. package/dist/src/result-serialization.js +1 -1
  140. package/dist/src/runner-cache-metadata.js +2 -2
  141. package/dist/src/runner-client.js +1 -1
  142. package/dist/src/runner-contract.js +3 -0
  143. package/dist/src/runner-dev-tools-security.js +1 -0
  144. package/dist/src/runner-device-readiness.js +1 -0
  145. package/dist/src/runner-disposal.js +1 -1
  146. package/dist/src/runner-operations-facade.js +1 -1
  147. package/dist/src/runner-presentation.js +1 -1
  148. package/dist/src/runner.js +1 -1
  149. package/dist/src/runtime.js +2 -2
  150. package/dist/src/runtime10.js +2 -1
  151. package/dist/src/runtime2.js +4 -4
  152. package/dist/src/runtime4.js +5 -5
  153. package/dist/src/runtime5.js +1 -1
  154. package/dist/src/runtime6.js +1 -1
  155. package/dist/src/runtime7.js +1 -1
  156. package/dist/src/runtime8.js +1 -1
  157. package/dist/src/runtime9.js +1 -1
  158. package/dist/src/screen-recording-admission-ledger.js +1 -1
  159. package/dist/src/screen-recording-resource-recovery.js +1 -1
  160. package/dist/src/screen-recording-transport.js +1 -1
  161. package/dist/src/screenshot-density.js +1 -1
  162. package/dist/src/screenshot-image.js +1 -0
  163. package/dist/src/screenshot-overlay-draw.js +1 -0
  164. package/dist/src/screenshot-runtime.js +1 -1
  165. package/dist/src/script.js +1 -1
  166. package/dist/src/scroll-gesture.js +1 -1
  167. package/dist/src/sdk-batch.js +2 -2
  168. package/dist/src/sdk-contracts.d.ts +7 -5
  169. package/dist/src/sdk-contracts.js +2 -2
  170. package/dist/src/sdk-device.js +1 -1
  171. package/dist/src/sdk-finders.js +1 -1
  172. package/dist/src/sdk-selectors.d.ts +58 -6
  173. package/dist/src/sdk-selectors.js +1 -1
  174. package/dist/src/selection.js +0 -0
  175. package/dist/src/selector-runtime.js +1 -1
  176. package/dist/src/selectors.js +1 -1
  177. package/dist/src/semantic-index.js +1 -1
  178. package/dist/src/session-routing.js +1 -1
  179. package/dist/src/session-snapshot.js +1 -1
  180. package/dist/src/session-store.js +3 -3
  181. package/dist/src/session2.js +3 -3
  182. package/dist/src/simctl.js +1 -1
  183. package/dist/src/simulator-boot.js +1 -1
  184. package/dist/src/simulator-facade.js +1 -1
  185. package/dist/src/simulator.js +1 -1
  186. package/dist/src/snapshot-runtime-binding.js +1 -1
  187. package/dist/src/snapshot-runtime.js +1 -1
  188. package/dist/src/snapshot-state.js +1 -1
  189. package/dist/src/snapshot4.js +1 -1
  190. package/dist/src/src.js +1 -1
  191. package/dist/src/src7.js +1 -1
  192. package/dist/src/src8.js +1 -1
  193. package/dist/src/stop-sequence.js +1 -1
  194. package/dist/src/text-entry-focus.js +1 -1
  195. package/dist/src/touch-runtime.js +1 -1
  196. package/dist/src/tree.js +1 -1
  197. package/dist/src/type-text-runtime.js +1 -1
  198. package/dist/src/video.js +2 -2
  199. package/dist/src/web2.js +1 -1
  200. package/package.json +3 -1
  201. package/server.json +2 -2
  202. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.7.apk.sha256 +0 -1
  203. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.7.apk.sha256 +0 -1
  204. package/dist/src/png-transcode.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-device",
3
- "version": "0.21.7",
3
+ "version": "0.21.9",
4
4
  "description": "Mobile app automation and verification for AI coding agents. CLI, MCP server, and typed Node.js API for iOS, Android, HarmonyOS, TV, web, macOS, and Linux.",
5
5
  "mcpName": "io.github.callstack/agent-device",
6
6
  "license": "MIT",
@@ -107,6 +107,8 @@
107
107
  "package:android-ime-helper:npm": "rm -rf android/ime-helper/dist && AGENT_DEVICE_ANDROID_HELPER=ime sh ./scripts/package-android-helper.sh $(node -p \"require('./package.json').version\") android/ime-helper/dist",
108
108
  "build:macos-helper": "node --experimental-strip-types scripts/swift-toolchain-tmpdir.ts swift build -c release --package-path apple/macos-helper",
109
109
  "build:macos-helper:clean": "node --experimental-strip-types scripts/swift-toolchain-tmpdir.ts swift package --package-path apple/macos-helper clean && pnpm build:macos-helper",
110
+ "test:macos-helper": "node --experimental-strip-types scripts/swift-toolchain-tmpdir.ts swift test --package-path apple/macos-helper",
111
+ "check:macos-helper": "pnpm build:macos-helper && pnpm test:macos-helper",
110
112
  "prepare:publish-assets": "node scripts/prepare-publish-assets.mjs",
111
113
  "build:package": "pnpm build && pnpm build:xcuitest:ios && pnpm build:xcuitest:macos && pnpm build:xcuitest:tvos && pnpm build:xcuitest:visionos && pnpm build:macos-helper:clean && pnpm prepare:publish-assets",
112
114
  "package:npm": "pnpm build:package && pnpm check:package",
package/server.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "url": "https://github.com/callstack/agent-device",
8
8
  "source": "github"
9
9
  },
10
- "version": "0.21.7",
10
+ "version": "0.21.9",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "agent-device",
15
- "version": "0.21.7",
15
+ "version": "0.21.9",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  },
@@ -1 +0,0 @@
1
- 76e2409c08e5fa41a217a01d0679ea8cfa567ba8828044bb38e02f95ac512248 agent-device-android-ime-helper-0.21.7.apk
@@ -1 +0,0 @@
1
- 19690a5cc158aafbe0dd2bf33cd58950ef1d40ad3b52fd9e5014578ca64a7d13 agent-device-android-snapshot-helper-0.21.7.apk
@@ -1 +0,0 @@
1
- import{t as e}from"./rolldown-runtime.js";import{D as t}from"./sdk-contracts.js";import{n,r}from"./png.js";var i=e(((e,t)=>{function n(e){var n=Math.floor,r=Array(64),i=Array(64),a=Array(64),o=Array(64),s,c,l,u,d=Array(65535),f=Array(65535),p=Array(64),m=Array(64),h=[],g=0,_=7,v=Array(64),y=Array(64),b=Array(64),x=Array(256),S=Array(2048),C,w=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],T=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],E=[0,1,2,3,4,5,6,7,8,9,10,11],D=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],O=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],k=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],A=[0,1,2,3,4,5,6,7,8,9,10,11],j=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],M=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function N(e){for(var t=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],s=0;s<64;s++){var c=n((t[s]*e+50)/100);c<1?c=1:c>255&&(c=255),r[w[s]]=c}for(var l=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],u=0;u<64;u++){var d=n((l[u]*e+50)/100);d<1?d=1:d>255&&(d=255),i[w[u]]=d}for(var f=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],p=0,m=0;m<8;m++)for(var h=0;h<8;h++)a[p]=1/(r[w[p]]*f[m]*f[h]*8),o[p]=1/(i[w[p]]*f[m]*f[h]*8),p++}function P(e,t){for(var n=0,r=0,i=[],a=1;a<=16;a++){for(var o=1;o<=e[a];o++)i[t[r]]=[],i[t[r]][0]=n,i[t[r]][1]=a,r++,n++;n*=2}return i}function F(){s=P(T,E),c=P(k,A),l=P(D,O),u=P(j,M)}function I(){for(var e=1,t=2,n=1;n<=15;n++){for(var r=e;r<t;r++)f[32767+r]=n,d[32767+r]=[],d[32767+r][1]=n,d[32767+r][0]=r;for(var i=-(t-1);i<=-e;i++)f[32767+i]=n,d[32767+i]=[],d[32767+i][1]=n,d[32767+i][0]=t-1+i;e<<=1,t<<=1}}function L(){for(var e=0;e<256;e++)S[e]=19595*e,S[e+256>>0]=38470*e,S[e+512>>0]=7471*e+32768,S[e+768>>0]=-11059*e,S[e+1024>>0]=-21709*e,S[e+1280>>0]=32768*e+8421375,S[e+1536>>0]=-27439*e,S[e+1792>>0]=-5329*e}function R(e){for(var t=e[0],n=e[1]-1;n>=0;)t&1<<n&&(g|=1<<_),n--,_--,_<0&&(g==255?(z(255),z(0)):z(g),_=7,g=0)}function z(e){h.push(e)}function B(e){z(e>>8&255),z(e&255)}function V(e,t){var n,r,i,a,o,s,c,l,u=0,d,f=8,m=64;for(d=0;d<f;++d){n=e[u],r=e[u+1],i=e[u+2],a=e[u+3],o=e[u+4],s=e[u+5],c=e[u+6],l=e[u+7];var h=n+l,g=n-l,_=r+c,v=r-c,y=i+s,b=i-s,x=a+o,S=a-o,C=h+x,w=h-x,T=_+y,E=_-y;e[u]=C+T,e[u+4]=C-T;var D=(E+w)*.707106781;e[u+2]=w+D,e[u+6]=w-D,C=S+b,T=b+v,E=v+g;var O=(C-E)*.382683433,k=.5411961*C+O,A=1.306562965*E+O,j=T*.707106781,M=g+j,N=g-j;e[u+5]=N+k,e[u+3]=N-k,e[u+1]=M+A,e[u+7]=M-A,u+=8}for(u=0,d=0;d<f;++d){n=e[u],r=e[u+8],i=e[u+16],a=e[u+24],o=e[u+32],s=e[u+40],c=e[u+48],l=e[u+56];var P=n+l,F=n-l,I=r+c,L=r-c,R=i+s,z=i-s,B=a+o,V=a-o,H=P+B,U=P-B,W=I+R,G=I-R;e[u]=H+W,e[u+32]=H-W;var K=(G+U)*.707106781;e[u+16]=U+K,e[u+48]=U-K,H=V+z,W=z+L,G=L+F;var q=(H-G)*.382683433,J=.5411961*H+q,Y=1.306562965*G+q,X=W*.707106781,Z=F+X,Q=F-X;e[u+40]=Q+J,e[u+24]=Q-J,e[u+8]=Z+Y,e[u+56]=Z-Y,u++}var $;for(d=0;d<m;++d)$=e[d]*t[d],p[d]=$>0?$+.5|0:$-.5|0;return p}function H(){B(65504),B(16),z(74),z(70),z(73),z(70),z(0),z(1),z(1),z(0),B(1),B(1),z(0),z(0)}function U(e){if(e){B(65505),e[0]===69&&e[1]===120&&e[2]===105&&e[3]===102?B(e.length+2):(B(e.length+5+2),z(69),z(120),z(105),z(102),z(0));for(var t=0;t<e.length;t++)z(e[t])}}function W(e,t){B(65472),B(17),z(8),B(t),B(e),z(3),z(1),z(17),z(0),z(2),z(17),z(1),z(3),z(17),z(1)}function G(){B(65499),B(132),z(0);for(var e=0;e<64;e++)z(r[e]);z(1);for(var t=0;t<64;t++)z(i[t])}function K(){B(65476),B(418),z(0);for(var e=0;e<16;e++)z(T[e+1]);for(var t=0;t<=11;t++)z(E[t]);z(16);for(var n=0;n<16;n++)z(D[n+1]);for(var r=0;r<=161;r++)z(O[r]);z(1);for(var i=0;i<16;i++)z(k[i+1]);for(var a=0;a<=11;a++)z(A[a]);z(17);for(var o=0;o<16;o++)z(j[o+1]);for(var s=0;s<=161;s++)z(M[s])}function q(e){e!==void 0&&e.constructor===Array&&e.forEach(e=>{if(typeof e==`string`){B(65534);var t=e.length;B(t+2);var n;for(n=0;n<t;n++)z(e.charCodeAt(n))}})}function J(){B(65498),B(12),z(3),z(1),z(0),z(2),z(17),z(3),z(17),z(0),z(63),z(0)}function Y(e,t,n,r,i){for(var a=i[0],o=i[240],s,c=16,l=63,u=64,p=V(e,t),h=0;h<u;++h)m[w[h]]=p[h];var g=m[0]-n;n=m[0],g==0?R(r[0]):(s=32767+g,R(r[f[s]]),R(d[s]));for(var _=63;_>0&&m[_]==0;_--);if(_==0)return R(a),n;for(var v=1,y;v<=_;){for(var b=v;m[v]==0&&v<=_;++v);var x=v-b;if(x>=c){y=x>>4;for(var S=1;S<=y;++S)R(o);x&=15}s=32767+m[v],R(i[(x<<4)+f[s]]),R(d[s]),v++}return _!=l&&R(a),n}function X(){for(var e=String.fromCharCode,t=0;t<256;t++)x[t]=e(t)}this.encode=function(e,n){new Date().getTime(),n&&Z(n),h=[],g=0,_=7,B(65496),H(),q(e.comments),U(e.exifBuffer),G(),W(e.width,e.height),K(),J();var r=0,i=0,d=0;g=0,_=7,this.encode.displayName=`_encode_`;var f=e.data,p=e.width,m=e.height,x=p*4;p*3;for(var C,w=0,T,E,D,O,k,A,j,M;w<m;){for(C=0;C<x;){for(O=x*w+C,k=O,A=-1,j=0,M=0;M<64;M++)j=M>>3,A=(M&7)*4,k=O+j*x+A,w+j>=m&&(k-=x*(w+1+j-m)),C+A>=x&&(k-=C+A-x+4),T=f[k++],E=f[k++],D=f[k++],v[M]=(S[T]+S[E+256>>0]+S[D+512>>0]>>16)-128,y[M]=(S[T+768>>0]+S[E+1024>>0]+S[D+1280>>0]>>16)-128,b[M]=(S[T+1280>>0]+S[E+1536>>0]+S[D+1792>>0]>>16)-128;r=Y(v,a,r,s,l),i=Y(y,o,i,c,u),d=Y(b,o,d,c,u),C+=32}w+=8}if(_>=0){var N=[];N[1]=_+1,N[0]=(1<<_+1)-1,R(N)}return B(65497),t===void 0?new Uint8Array(h):Buffer.from(h)};function Z(e){if(e<=0&&(e=1),e>100&&(e=100),C!=e){var t=0;t=Math.floor(e<50?5e3/e:200-e*2),N(t),C=e}}function Q(){var t=new Date().getTime();e||=50,X(),F(),I(),L(),Z(e),new Date().getTime()-t}Q()}t===void 0?typeof window<`u`&&(window[`jpeg-js`]=window[`jpeg-js`]||{},window[`jpeg-js`].encode=r):t.exports=r;function r(e,t){return t===void 0&&(t=50),{data:new n(t).encode(e,t),width:e.width,height:e.height}}})),a=e(((e,t)=>{var n=(function(){var e=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),t=4017,n=799,r=3406,i=2276,a=1567,o=3784,s=5793,c=2896;function l(){}function u(e,t){for(var n=0,r=[],i,a,o=16;o>0&&!e[o-1];)o--;r.push({children:[],index:0});var s=r[0],c;for(i=0;i<o;i++){for(a=0;a<e[i];a++){for(s=r.pop(),s.children[s.index]=t[n];s.index>0;){if(r.length===0)throw Error(`Could not recreate Huffman Table`);s=r.pop()}for(s.index++,r.push(s);r.length<=i;)r.push(c={children:[],index:0}),s.children[s.index]=c.children,s=c;n++}i+1<o&&(r.push(c={children:[],index:0}),s.children[s.index]=c.children,s=c)}return r[0].children}function d(t,n,r,i,a,o,s,c,l,u){r.precision,r.samplesPerLine,r.scanLines;var d=r.mcusPerLine,f=r.progressive;r.maxH,r.maxV;var p=n,m=0,h=0;function g(){if(h>0)return h--,m>>h&1;if(m=t[n++],m==255){var e=t[n++];if(e)throw Error(`unexpected marker: `+(m<<8|e).toString(16))}return h=7,m>>>7}function _(e){for(var t=e,n;(n=g())!==null;){if(t=t[n],typeof t==`number`)return t;if(typeof t!=`object`)throw Error(`invalid huffman sequence`)}return null}function v(e){for(var t=0;e>0;){var n=g();if(n===null)return;t=t<<1|n,e--}return t}function y(e){var t=v(e);return t>=1<<e-1?t:t+(-1<<e)+1}function b(t,n){var r=_(t.huffmanTableDC),i=r===0?0:y(r);n[0]=t.pred+=i;for(var a=1;a<64;){var o=_(t.huffmanTableAC),s=o&15,c=o>>4;if(s===0){if(c<15)break;a+=16;continue}a+=c;var l=e[a];n[l]=y(s),a++}}function x(e,t){var n=_(e.huffmanTableDC),r=n===0?0:y(n)<<l;t[0]=e.pred+=r}function S(e,t){t[0]|=g()<<l}var C=0;function w(t,n){if(C>0){C--;return}for(var r=o,i=s;r<=i;){var a=_(t.huffmanTableAC),c=a&15,u=a>>4;if(c===0){if(u<15){C=v(u)+(1<<u)-1;break}r+=16;continue}r+=u;var d=e[r];n[d]=y(c)*(1<<l),r++}}var T=0,E;function D(t,n){for(var r=o,i=s,a=0;r<=i;){var c=e[r],u=n[c]<0?-1:1;switch(T){case 0:var d=_(t.huffmanTableAC),f=d&15,a=d>>4;if(f===0)a<15?(C=v(a)+(1<<a),T=4):(a=16,T=1);else{if(f!==1)throw Error(`invalid ACn encoding`);E=y(f),T=a?2:3}continue;case 1:case 2:n[c]?n[c]+=(g()<<l)*u:(a--,a===0&&(T=T==2?3:0));break;case 3:n[c]?n[c]+=(g()<<l)*u:(n[c]=E<<l,T=0);break;case 4:n[c]&&(n[c]+=(g()<<l)*u)}r++}T===4&&(C--,C===0&&(T=0))}function O(e,t,n,r,i){var a=n/d|0,o=n%d,s=a*e.v+r,c=o*e.h+i;e.blocks[s]===void 0&&u.tolerantDecoding||t(e,e.blocks[s][c])}function k(e,t,n){var r=n/e.blocksPerLine|0,i=n%e.blocksPerLine;e.blocks[r]===void 0&&u.tolerantDecoding||t(e,e.blocks[r][i])}var A=i.length,j,M,N,P,F,I=f?o===0?c===0?x:S:c===0?w:D:b,L=0,R,z=A==1?i[0].blocksPerLine*i[0].blocksPerColumn:d*r.mcusPerColumn;a||=z;for(var B,V;L<z;){for(M=0;M<A;M++)i[M].pred=0;if(C=0,A==1)for(j=i[0],F=0;F<a;F++)k(j,I,L),L++;else for(F=0;F<a;F++){for(M=0;M<A;M++)for(j=i[M],B=j.h,V=j.v,N=0;N<V;N++)for(P=0;P<B;P++)O(j,I,L,N,P);if(L++,L===z)break}if(L===z)do{if(t[n]===255&&t[n+1]!==0)break;n+=1}while(n<t.length-2);if(h=0,R=t[n]<<8|t[n+1],R<65280)throw Error(`marker was not found`);if(R>=65488&&R<=65495)n+=2;else break}return n-p}function f(e,l){var u=[],d=l.blocksPerLine,f=l.blocksPerColumn,p=d<<3,m=new Int32Array(64),h=new Uint8Array(64);function _(e,u,d){var f=l.quantizationTable,p,m,h,g,_,v,y,b,x,S=d,C;for(C=0;C<64;C++)S[C]=e[C]*f[C];for(C=0;C<8;++C){var w=8*C;if(S[1+w]==0&&S[2+w]==0&&S[3+w]==0&&S[4+w]==0&&S[5+w]==0&&S[6+w]==0&&S[7+w]==0){x=s*S[0+w]+512>>10,S[0+w]=x,S[1+w]=x,S[2+w]=x,S[3+w]=x,S[4+w]=x,S[5+w]=x,S[6+w]=x,S[7+w]=x;continue}p=s*S[0+w]+128>>8,m=s*S[4+w]+128>>8,h=S[2+w],g=S[6+w],_=c*(S[1+w]-S[7+w])+128>>8,b=c*(S[1+w]+S[7+w])+128>>8,v=S[3+w]<<4,y=S[5+w]<<4,x=p-m+1>>1,p=p+m+1>>1,m=x,x=h*o+g*a+128>>8,h=h*a-g*o+128>>8,g=x,x=_-y+1>>1,_=_+y+1>>1,y=x,x=b+v+1>>1,v=b-v+1>>1,b=x,x=p-g+1>>1,p=p+g+1>>1,g=x,x=m-h+1>>1,m=m+h+1>>1,h=x,x=_*i+b*r+2048>>12,_=_*r-b*i+2048>>12,b=x,x=v*n+y*t+2048>>12,v=v*t-y*n+2048>>12,y=x,S[0+w]=p+b,S[7+w]=p-b,S[1+w]=m+y,S[6+w]=m-y,S[2+w]=h+v,S[5+w]=h-v,S[3+w]=g+_,S[4+w]=g-_}for(C=0;C<8;++C){var T=C;if(S[8+T]==0&&S[16+T]==0&&S[24+T]==0&&S[32+T]==0&&S[40+T]==0&&S[48+T]==0&&S[56+T]==0){x=s*d[C+0]+8192>>14,S[0+T]=x,S[8+T]=x,S[16+T]=x,S[24+T]=x,S[32+T]=x,S[40+T]=x,S[48+T]=x,S[56+T]=x;continue}p=s*S[0+T]+2048>>12,m=s*S[32+T]+2048>>12,h=S[16+T],g=S[48+T],_=c*(S[8+T]-S[56+T])+2048>>12,b=c*(S[8+T]+S[56+T])+2048>>12,v=S[24+T],y=S[40+T],x=p-m+1>>1,p=p+m+1>>1,m=x,x=h*o+g*a+2048>>12,h=h*a-g*o+2048>>12,g=x,x=_-y+1>>1,_=_+y+1>>1,y=x,x=b+v+1>>1,v=b-v+1>>1,b=x,x=p-g+1>>1,p=p+g+1>>1,g=x,x=m-h+1>>1,m=m+h+1>>1,h=x,x=_*i+b*r+2048>>12,_=_*r-b*i+2048>>12,b=x,x=v*n+y*t+2048>>12,v=v*t-y*n+2048>>12,y=x,S[0+T]=p+b,S[56+T]=p-b,S[8+T]=m+y,S[48+T]=m-y,S[16+T]=h+v,S[40+T]=h-v,S[24+T]=g+_,S[32+T]=g-_}for(C=0;C<64;++C){var E=128+(S[C]+8>>4);u[C]=E<0?0:E>255?255:E}}g(p*f*8);for(var v,y,b=0;b<f;b++){var x=b<<3;for(v=0;v<8;v++)u.push(new Uint8Array(p));for(var S=0;S<d;S++){_(l.blocks[b][S],h,m);var C=0,w=S<<3;for(y=0;y<8;y++){var T=u[x+y];for(v=0;v<8;v++)T[w+v]=h[C++]}}}return u}function p(e){return e<0?0:e>255?255:e}l.prototype={load:function(e){var t=new XMLHttpRequest;t.open(`GET`,e,!0),t.responseType=`arraybuffer`,t.onload=(function(){var e=new Uint8Array(t.response||t.mozResponseArrayBuffer);this.parse(e),this.onload&&this.onload()}).bind(this),t.send(null)},parse:function(t){var n=this.opts.maxResolutionInMP*1e3*1e3,r=0;t.length;function i(){var e=t[r]<<8|t[r+1];return r+=2,e}function a(){var e=i(),n=t.subarray(r,r+e-2);return r+=n.length,n}function o(e){var t=1,n=1,r,i;for(i in e.components)e.components.hasOwnProperty(i)&&(r=e.components[i],t<r.h&&(t=r.h),n<r.v&&(n=r.v));var a=Math.ceil(e.samplesPerLine/8/t),o=Math.ceil(e.scanLines/8/n);for(i in e.components)if(e.components.hasOwnProperty(i)){r=e.components[i];var s=Math.ceil(Math.ceil(e.samplesPerLine/8)*r.h/t),c=Math.ceil(Math.ceil(e.scanLines/8)*r.v/n),l=a*r.h,u=o*r.v,d=u*l,f=[];g(d*256);for(var p=0;p<u;p++){for(var m=[],h=0;h<l;h++)m.push(new Int32Array(64));f.push(m)}r.blocksPerLine=s,r.blocksPerColumn=c,r.blocks=f}e.maxH=t,e.maxV=n,e.mcusPerLine=a,e.mcusPerColumn=o}var s=null,c=null,l,p,m=[],h=[],_=[],v=[],y=i(),b=-1;if(this.comments=[],y!=65496)throw Error(`SOI not found`);for(y=i();y!=65497;){var x,S;switch(y){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var C=a();if(y===65534){var w=String.fromCharCode.apply(null,C);this.comments.push(w)}y===65504&&C[0]===74&&C[1]===70&&C[2]===73&&C[3]===70&&C[4]===0&&(s={version:{major:C[5],minor:C[6]},densityUnits:C[7],xDensity:C[8]<<8|C[9],yDensity:C[10]<<8|C[11],thumbWidth:C[12],thumbHeight:C[13],thumbData:C.subarray(14,14+3*C[12]*C[13])}),y===65505&&C[0]===69&&C[1]===120&&C[2]===105&&C[3]===102&&C[4]===0&&(this.exifBuffer=C.subarray(5,C.length)),y===65518&&C[0]===65&&C[1]===100&&C[2]===111&&C[3]===98&&C[4]===101&&C[5]===0&&(c={version:C[6],flags0:C[7]<<8|C[8],flags1:C[9]<<8|C[10],transformCode:C[11]});break;case 65499:for(var T=i()+r-2;r<T;){var E=t[r++];g(256);var D=new Int32Array(64);if(!(E>>4))for(S=0;S<64;S++){var O=e[S];D[O]=t[r++]}else if(E>>4==1)for(S=0;S<64;S++){var O=e[S];D[O]=i()}else throw Error(`DQT: invalid table spec`);m[E&15]=D}break;case 65472:case 65473:case 65474:i(),l={},l.extended=y===65473,l.progressive=y===65474,l.precision=t[r++],l.scanLines=i(),l.samplesPerLine=i(),l.components={},l.componentsOrder=[];var k=l.scanLines*l.samplesPerLine;if(k>n){var A=Math.ceil((k-n)/1e6);throw Error(`maxResolutionInMP limit exceeded by ${A}MP`)}var j=t[r++],M;for(x=0;x<j;x++){M=t[r];var N=t[r+1]>>4,P=t[r+1]&15,F=t[r+2];if(N<=0||P<=0)throw Error(`Invalid sampling factor, expected values above 0`);l.componentsOrder.push(M),l.components[M]={h:N,v:P,quantizationIdx:F},r+=3}o(l),h.push(l);break;case 65476:var I=i();for(x=2;x<I;){var L=t[r++],R=new Uint8Array(16),z=0;for(S=0;S<16;S++,r++)z+=R[S]=t[r];g(16+z);var B=new Uint8Array(z);for(S=0;S<z;S++,r++)B[S]=t[r];x+=17+z,(L>>4?_:v)[L&15]=u(R,B)}break;case 65501:i(),p=i();break;case 65500:i(),i();break;case 65498:i();var V=t[r++],H=[],U;for(x=0;x<V;x++){U=l.components[t[r++]];var W=t[r++];U.huffmanTableDC=v[W>>4],U.huffmanTableAC=_[W&15],H.push(U)}var G=t[r++],K=t[r++],q=t[r++],J=d(t,r,l,H,p,G,K,q>>4,q&15,this.opts);r+=J;break;case 65535:t[r]!==255&&r--;break;default:if(t[r-3]==255&&t[r-2]>=192&&t[r-2]<=254){r-=3;break}if(y===224||y==225){if(b!==-1)throw Error(`first unknown JPEG marker at offset ${b.toString(16)}, second unknown JPEG marker ${y.toString(16)} at offset ${(r-1).toString(16)}`);b=r-1;let e=i();if(t[r+e-2]===255){r+=e-2;break}}throw Error(`unknown JPEG marker `+y.toString(16))}y=i()}if(h.length!=1)throw Error(`only single frame JPEGs supported`);for(var x=0;x<h.length;x++){var Y=h[x].components;for(var S in Y)Y[S].quantizationTable=m[Y[S].quantizationIdx],delete Y[S].quantizationIdx}this.width=l.samplesPerLine,this.height=l.scanLines,this.jfif=s,this.adobe=c,this.components=[];for(var x=0;x<l.componentsOrder.length;x++){var U=l.components[l.componentsOrder[x]];this.components.push({lines:f(l,U),scaleX:U.h/l.maxH,scaleY:U.v/l.maxV})}},getData:function(e,t){var n=this.width/e,r=this.height/t,i,a,o,s,c,l,u,d,f,m,h=0,_,v,y,b,x,S,C,w,T,E,D,O=e*t*this.components.length;g(O);var k=new Uint8Array(O);switch(this.components.length){case 1:for(i=this.components[0],m=0;m<t;m++)for(c=i.lines[0|m*i.scaleY*r],f=0;f<e;f++)_=c[0|f*i.scaleX*n],k[h++]=_;break;case 2:for(i=this.components[0],a=this.components[1],m=0;m<t;m++)for(c=i.lines[0|m*i.scaleY*r],l=a.lines[0|m*a.scaleY*r],f=0;f<e;f++)_=c[0|f*i.scaleX*n],k[h++]=_,_=l[0|f*a.scaleX*n],k[h++]=_;break;case 3:for(D=!0,this.adobe&&this.adobe.transformCode?D=!0:this.opts.colorTransform!==void 0&&(D=!!this.opts.colorTransform),i=this.components[0],a=this.components[1],o=this.components[2],m=0;m<t;m++)for(c=i.lines[0|m*i.scaleY*r],l=a.lines[0|m*a.scaleY*r],u=o.lines[0|m*o.scaleY*r],f=0;f<e;f++)D?(_=c[0|f*i.scaleX*n],v=l[0|f*a.scaleX*n],y=u[0|f*o.scaleX*n],w=p(_+1.402*(y-128)),T=p(_-.3441363*(v-128)-.71413636*(y-128)),E=p(_+1.772*(v-128))):(w=c[0|f*i.scaleX*n],T=l[0|f*a.scaleX*n],E=u[0|f*o.scaleX*n]),k[h++]=w,k[h++]=T,k[h++]=E;break;case 4:if(!this.adobe)throw Error(`Unsupported color mode (4 components)`);for(D=!1,this.adobe&&this.adobe.transformCode?D=!0:this.opts.colorTransform!==void 0&&(D=!!this.opts.colorTransform),i=this.components[0],a=this.components[1],o=this.components[2],s=this.components[3],m=0;m<t;m++)for(c=i.lines[0|m*i.scaleY*r],l=a.lines[0|m*a.scaleY*r],u=o.lines[0|m*o.scaleY*r],d=s.lines[0|m*s.scaleY*r],f=0;f<e;f++)D?(_=c[0|f*i.scaleX*n],v=l[0|f*a.scaleX*n],y=u[0|f*o.scaleX*n],b=d[0|f*s.scaleX*n],x=255-p(_+1.402*(y-128)),S=255-p(_-.3441363*(v-128)-.71413636*(y-128)),C=255-p(_+1.772*(v-128))):(x=c[0|f*i.scaleX*n],S=l[0|f*a.scaleX*n],C=u[0|f*o.scaleX*n],b=d[0|f*s.scaleX*n]),k[h++]=255-x,k[h++]=255-S,k[h++]=255-C,k[h++]=255-b;break;default:throw Error(`Unsupported color mode`)}return k},copyToImageData:function(e,t){var n=e.width,r=e.height,i=e.data,a=this.getData(n,r),o=0,s=0,c,l,u,d,f,m,h,g,_;switch(this.components.length){case 1:for(l=0;l<r;l++)for(c=0;c<n;c++)u=a[o++],i[s++]=u,i[s++]=u,i[s++]=u,t&&(i[s++]=255);break;case 3:for(l=0;l<r;l++)for(c=0;c<n;c++)h=a[o++],g=a[o++],_=a[o++],i[s++]=h,i[s++]=g,i[s++]=_,t&&(i[s++]=255);break;case 4:for(l=0;l<r;l++)for(c=0;c<n;c++)f=a[o++],m=a[o++],u=a[o++],d=a[o++],h=255-p(f*(1-d/255)+d),g=255-p(m*(1-d/255)+d),_=255-p(u*(1-d/255)+d),i[s++]=h,i[s++]=g,i[s++]=_,t&&(i[s++]=255);break;default:throw Error(`Unsupported color mode`)}}};var m=0,h=0;function g(e=0){var t=m+e;if(t>h){var n=Math.ceil((t-h)/1024/1024);throw Error(`maxMemoryUsageInMB limit exceeded by at least ${n}MB`)}m=t}return l.resetMaxMemoryUsage=function(e){m=0,h=e},l.getBytesAllocated=function(){return m},l.requestMemoryAllocation=g,l})();t===void 0?typeof window<`u`&&(window[`jpeg-js`]=window[`jpeg-js`]||{},window[`jpeg-js`].decode=r):t.exports=r;function r(e,t={}){var r={colorTransform:void 0,useTArray:!1,formatAsRGBA:!0,tolerantDecoding:!0,maxResolutionInMP:100,maxMemoryUsageInMB:512,...t},i=new Uint8Array(e),a=new n;a.opts=r,n.resetMaxMemoryUsage(r.maxMemoryUsageInMB*1024*1024),a.parse(i);var o=r.formatAsRGBA?4:3,s=a.width*a.height*o;try{n.requestMemoryAllocation(s);var c={width:a.width,height:a.height,exifBuffer:a.exifBuffer,data:r.useTArray?new Uint8Array(s):Buffer.alloc(s)};a.comments.length>0&&(c.comments=a.comments)}catch(e){throw e instanceof RangeError?Error(`Could not allocate enough memory for the image. Required: `+s):e instanceof ReferenceError&&e.message===`Buffer is not defined`?Error(`Buffer is not globally defined in this environment. Consider setting useTArray to true`):e}return a.copyToImageData(c,r.formatAsRGBA),c}})),o=e(((e,t)=>{t.exports={encode:i(),decode:a()}}))();const s=Buffer.from([255,216,255]);function c(e){if(n(e))return`png`;if(e.subarray(0,s.length).equals(s))return`jpeg`}function l(e,n){let r=c(e);if(r===`png`)return e;if(r===`jpeg`)return u(e,n);throw new t(`COMMAND_FAILED`,`${n} is neither PNG nor JPEG`,{label:n,leadingBytes:e.subarray(0,4).toString(`hex`)})}function u(e,n){try{let t=(0,o.decode)(e,{useTArray:!0,formatAsRGBA:!0}),n=new r.PNG({width:t.width,height:t.height});return n.data=Buffer.from(t.data.buffer,t.data.byteOffset,t.data.byteLength),r.PNG.sync.write(n)}catch(e){throw new t(`COMMAND_FAILED`,`Failed to decode ${n} as JPEG`,{label:n,reason:e instanceof Error?e.message:String(e)})}}export{l as transcodeScreenshotToPng};