@doubao-dev/cli 0.0.32 → 0.0.34

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 (94) hide show
  1. package/dist/2168.js +16 -16
  2. package/dist/275.js +12 -14
  3. package/dist/2932.js +1 -1
  4. package/dist/318.js +1 -1
  5. package/dist/{1560.js → 3688.js} +2 -2
  6. package/dist/3974.js +22 -22
  7. package/dist/4525.js +1 -1
  8. package/dist/4880.js +1 -1
  9. package/dist/4931.js +2 -2
  10. package/dist/6427.js +126 -0
  11. package/dist/7410.js +1 -1
  12. package/dist/7417.js +204 -0
  13. package/dist/7417.js.LICENSE.txt +107 -0
  14. package/dist/7945.js +1 -0
  15. package/dist/8981.js +78 -0
  16. package/dist/{8891.js.LICENSE.txt → 8981.js.LICENSE.txt} +0 -108
  17. package/dist/@byted-doubao-apps/create.js +1 -1
  18. package/dist/@byted-doubao-apps/kit.js +1 -0
  19. package/dist/@byted-doubao-apps/login.js +1 -1
  20. package/dist/@byted-doubao-apps/login~1.js +1 -1
  21. package/dist/@byted-doubao-apps/template-empty/package.json +3 -3
  22. package/dist/@byted-doubao-apps/template-starter/package.json +3 -3
  23. package/dist/@byted-hdt/cli.js +1 -1
  24. package/dist/@inquirer/select.js +1 -1
  25. package/dist/app.js +1 -1
  26. package/dist/assets/web-sdk-debugger/__doubao_web_sdk_native_modules/applet-bridge-module-core.js +1 -1
  27. package/dist/assets/web-sdk-debugger/index.html +1 -1
  28. package/dist/assets/web-sdk-debugger/static/js/index.9f626ba3a2.js +44 -0
  29. package/dist/assets/web-sdk-debugger/wsd/doubao-apps-api.template.js +0 -0
  30. package/dist/assets/web-sdk-debugger/wsd/doubao-apps-framework.template.js +0 -0
  31. package/dist/build.js +1 -1
  32. package/dist/build~1.js +6 -6
  33. package/dist/check.js +1 -1
  34. package/dist/demo-server.js +1 -1
  35. package/dist/dev-config.js +1 -1
  36. package/dist/dev-shell.js +1 -1
  37. package/dist/dev.js +10 -10
  38. package/dist/devtools.js +1 -1
  39. package/dist/gen-explore.js +1 -1
  40. package/dist/gen-trajectory.js +1 -1
  41. package/dist/init.js +4 -4
  42. package/dist/ink.js +1 -1
  43. package/dist/inquirer.js +1 -0
  44. package/dist/json-file.js +1 -1
  45. package/dist/kit-dev-options.js +1 -1
  46. package/dist/legacy-upload.js +1 -1
  47. package/dist/lepus.js +1 -1
  48. package/dist/ora.js +1 -1
  49. package/dist/project-layout.js +1 -1
  50. package/dist/prompt.js +1 -1
  51. package/dist/prompts.js +1 -1
  52. package/dist/report.js +1 -1
  53. package/dist/run-registry.js +1 -1
  54. package/dist/run.js +44 -44
  55. package/dist/sandbox.js +1 -1
  56. package/dist/scan.js +1 -1
  57. package/dist/sdk.js +63 -188
  58. package/dist/sdk~1.js +50 -50
  59. package/dist/server.js +1 -1
  60. package/dist/skill.js +1 -1
  61. package/dist/skills.js +1 -1
  62. package/dist/skills~1.js +2 -1
  63. package/dist/static/assets/web-view-proxy-bootstrap.js +1 -0
  64. package/dist/static/assets/web-view-proxy-page-client.js +1 -1
  65. package/dist/static/assets/web-view-proxy-service-worker.js +1 -1
  66. package/dist/status~1.js +1 -1
  67. package/dist/stop.js +1 -1
  68. package/dist/sync.js +1 -1
  69. package/dist/templates/README.md +0 -1
  70. package/dist/update.js +1 -1
  71. package/dist/workspace.js +1 -1
  72. package/dist/wrapper.js +1 -0
  73. package/dist/yaml.js +1 -1
  74. package/package.json +2 -2
  75. package/skills/dbx-eval/SKILL.md +15 -7
  76. package/skills/doubao-agentic-service-development/SKILL.md +1 -1
  77. package/skills/doubao-agentic-service-development/references/auth.md +1 -1
  78. package/skills/doubao-agentic-service-development/references/dev-debug.md +3 -3
  79. package/skills/doubao-agentic-service-development/references/frontend/components/map-canvas.md +1 -1
  80. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/06-/350/267/257/347/224/261.md +2 -2
  81. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/07-/347/225/214/351/235/242.md +0 -6
  82. package/skills/doubao-agentic-service-development/references/frontend/doubao-agentic-service-api/08-/344/272/244/344/272/222.md +2 -2
  83. package/skills/doubao-agentic-service-development/references/frontend/guides/debugger-mcp.md +2 -2
  84. package/skills/doubao-agentic-service-development/references/frontend/widget-templates/props.md +1 -1
  85. package/skills/doubao-agentic-service-development/references/frontend-dev.md +3 -3
  86. package/skills/doubao-agentic-service-development/references/local-debug/overview.md +2 -2
  87. package/skills/doubao-agentic-service-development/references/overview.md +16 -31
  88. package/skills/doubao-agentic-service-development/scripts/workspace.py +6 -89
  89. package/dist/180.js +0 -1
  90. package/dist/8891.js +0 -280
  91. package/dist/9635.js +0 -1
  92. package/dist/assets/web-sdk-debugger/static/js/index.75528d6de7.js +0 -26
  93. package/dist/dbx.js +0 -3
  94. package/dist/skills~2.js +0 -2
package/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import"node:module";import{__webpack_require__ as e}from"./rslib-runtime.js";import{external_node_stream_promises_namespaceObject as t}from"./9635.js";import{DEV_ACTIONS as n,ensureDevActionSucceeded as r,summarizeData as o,parseJsonData as i,DEV_EVENTS as s,connectDevService as a,ServiceManager as d,startForegroundDevService as l}from"./275.js";import{isRecord as c,getApiBaseUrl as u,reportCommand as p,version_version as h,runTrackedDevAction as f,flushEvents as m,reportDevAction as g,command_Command as _,runCommand as w,setEventTrackingUid as y,classifyEventStatus as b,build_getAuthOptions as v}from"./2168.js";import{listMiniAppVersions as E}from"./app.js";import{openUrlInBrowser as I}from"./browser.js";import{source as A}from"./1560.js";import{resolveDevSimulatorPaths as T,prepareDevBusinessTemplates as C,extractDevPermissions as k,prepareDevManifest as S,resolveDevMcpEndpoint as j,formatFinalDevWarnings as D}from"./dev-config.js";import{resolveProjectLayout as P}from"./project-layout.js";import{extractMCPHeadersFromManifest as x}from"./manifest-mcp-config.js";import{createKitDevOptions as L}from"./kit-dev-options.js";import"./180.js";import"./3551.js";e.add({"../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/index.js"(e,t,n){t.Ph=void 0;var r=n("../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/realDeviceDebugQRCode.js");Object.defineProperty(t,"Ph",{enumerable:!0,get:function(){return r.createRealDeviceDebugQRCodeValue}})},"../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/realDeviceDebugQRCode.js"(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.createRealDeviceDebugQRCodeValue=t.REAL_DEVICE_DEBUG_QR_ACTION=t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL=void 0;let r=n("../../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs"),o=r.__importStar(n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/index.js"));t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL="https://hello.doubao-dev.com",t.REAL_DEVICE_DEBUG_QR_ACTION="start_real_device_debug";class i extends Error{constructor(e,t){super(t),this.name="RealDeviceDebugAuthError",this.code=e}}let s=null;function a(e,t){let n=e.trim();if(!n)throw Error(t);return n}t.createRealDeviceDebugQRCodeValue=function(e){var n,d,l;return r.__awaiter(this,void 0,void 0,function*(){var c;let u=Object.assign(Object.assign({hostUrl:a(e.hostUrl,"hostUrl is required to request real-device debug ticket"),appKey:a(e.appKey,"appKey is required to request real-device debug ticket"),isSigned:e.isSigned,isEncrypted:!!e.isEncrypted,signPublicKeyVersion:null==(n=e.signPublicKeyVersion)?void 0:n.trim(),versionTag:(c=e.versionTag,void 0===c?void 0:a(c,"versionTag must not be empty")),appletType:e.appletType,baseApiUrl:e.baseApiUrl||t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL},!1===e.defaultDebugTagState?{defaultDebugTagState:!1}:{}),e.wifiConnectUrl?{wifiConnectUrl:e.wifiConnectUrl}:{}),p=yield function(e,n){return r.__awaiter(this,void 0,void 0,function*(){var r;let o,i=(r=e.appKey,o=a(e.baseApiUrl||t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL,"baseApiUrl is required to request real-device debug ticket"),new URL(`/developer/check_api/apps/${encodeURIComponent(r)}/debug/ticket`,o).toString()),s=yield n({method:"POST",url:i,data:{debug_context:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({appletName:e.appKey,appletHost:e.hostUrl,appletType:e.appletType,isSigned:e.isSigned,isEncrypted:e.isEncrypted},e.versionTag?{versionTag:e.versionTag}:{}),e.isSigned&&e.signPublicKeyVersion?{signPublicKeyVersion:e.signPublicKeyVersion}:{}),!1===e.defaultDebugTagState?{defaultDebugTagState:!1}:{}),e.wifiConnectUrl?{wifiConnectUrl:e.wifiConnectUrl}:{}))}});return null==s?void 0:s.data})}(u,function(e){return({method:t,url:n,data:a,headers:d})=>r.__awaiter(this,void 0,void 0,function*(){try{let r,i=Object.entries(Object.assign(Object.assign({},void 0===a?{}:{"Content-Type":"application/json"}),d)).reduce((e,[t,n])=>("string"==typeof n&&(e[t]=n),e),{}),l=yield(e?o.withAuth(fetch,e):(!s&&(s=o.withAuth()),s))(n,{method:t,headers:i,body:void 0===a?void 0:JSON.stringify(a)}),c=yield l.text();if(c)try{r=JSON.parse(c)}catch(e){r=c}if(!l.ok)throw Error(`Authed request failed with HTTP ${l.status}${c?`: ${c}`:""}`);return{data:r,status:l.status,headers:l.headers}}catch(e){throw e instanceof o.NotLoggedInError?new i("NOT_LOGGED_IN","No open-platform login session is available. Please run dbx auth:login first, then retry."):e instanceof o.TokenExpiredError?new i("TOKEN_EXPIRED","The open-platform login session has expired. Please run dbx auth:login again, then retry."):e instanceof o.AuthError?new i("AUTH_FAILED",`Open-platform authentication failed: ${e.message}`):e instanceof Error?e:Error(String(e))}})}(e.authOptions));if(!p||0!==p.code){let e=(null==p?void 0:p.code)===void 0?"unknown":String(p.code);if((null==p?void 0:p.code)===0x2fb1793)throw new i("APP_ROLE_PERMISSION_REQUIRED",`真机调试授权失败:当前账号没有工程所配置智能服务的角色权限。
1
+ import"node:module";import{__webpack_require__ as e}from"./rslib-runtime.js";import{external_node_stream_promises_namespaceObject as t}from"./7945.js";import{DEV_ACTIONS as n,ensureDevActionSucceeded as r,summarizeData as o,parseJsonData as i,DEV_EVENTS as s,connectDevService as a,ServiceManager as d,startForegroundDevService as l}from"./275.js";import{isRecord as c,getApiBaseUrl as u,reportCommand as p,version_version as h,runTrackedDevAction as f,flushEvents as m,reportDevAction as g,command_Command as _,runCommand as w,setEventTrackingUid as y,classifyEventStatus as b,build_getAuthOptions as v}from"./2168.js";import{listMiniAppVersions as E}from"./app.js";import{openUrlInBrowser as I}from"./browser.js";import{source as A}from"./3688.js";import{resolveDevSimulatorPaths as T,prepareDevBusinessTemplates as C,extractDevPermissions as S,prepareDevManifest as k,resolveDevMcpEndpoint as j,formatFinalDevWarnings as D}from"./dev-config.js";import{resolveProjectLayout as P}from"./project-layout.js";import{extractMCPHeadersFromManifest as x}from"./manifest-mcp-config.js";import{createKitDevOptions as L}from"./kit-dev-options.js";import"./3551.js";e.add({"../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/index.js"(e,t,n){t.Ph=void 0;var r=n("../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/realDeviceDebugQRCode.js");Object.defineProperty(t,"Ph",{enumerable:!0,get:function(){return r.createRealDeviceDebugQRCodeValue}})},"../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/realDeviceDebugQRCode.js"(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.createRealDeviceDebugQRCodeValue=t.REAL_DEVICE_DEBUG_QR_ACTION=t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL=void 0;let r=n("../../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs"),o=r.__importStar(n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/index.js"));t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL="https://hello.doubao-dev.com",t.REAL_DEVICE_DEBUG_QR_ACTION="start_real_device_debug";class i extends Error{constructor(e,t){super(t),this.name="RealDeviceDebugAuthError",this.code=e}}let s=null;function a(e,t){let n=e.trim();if(!n)throw Error(t);return n}t.createRealDeviceDebugQRCodeValue=function(e){var n,d,l;return r.__awaiter(this,void 0,void 0,function*(){var c;let u=Object.assign(Object.assign({hostUrl:a(e.hostUrl,"hostUrl is required to request real-device debug ticket"),appKey:a(e.appKey,"appKey is required to request real-device debug ticket"),isSigned:e.isSigned,isEncrypted:!!e.isEncrypted,signPublicKeyVersion:null==(n=e.signPublicKeyVersion)?void 0:n.trim(),versionTag:(c=e.versionTag,void 0===c?void 0:a(c,"versionTag must not be empty")),appletType:e.appletType,baseApiUrl:e.baseApiUrl||t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL},!1===e.defaultDebugTagState?{defaultDebugTagState:!1}:{}),e.wifiConnectUrl?{wifiConnectUrl:e.wifiConnectUrl}:{}),p=yield function(e,n){return r.__awaiter(this,void 0,void 0,function*(){var r;let o,i=(r=e.appKey,o=a(e.baseApiUrl||t.DEFAULT_REAL_DEVICE_DEBUG_BASE_API_URL,"baseApiUrl is required to request real-device debug ticket"),new URL(`/developer/check_api/apps/${encodeURIComponent(r)}/debug/ticket`,o).toString()),s=yield n({method:"POST",url:i,data:{debug_context:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({appletName:e.appKey,appletHost:e.hostUrl,appletType:e.appletType,isSigned:e.isSigned,isEncrypted:e.isEncrypted},e.versionTag?{versionTag:e.versionTag}:{}),e.isSigned&&e.signPublicKeyVersion?{signPublicKeyVersion:e.signPublicKeyVersion}:{}),!1===e.defaultDebugTagState?{defaultDebugTagState:!1}:{}),e.wifiConnectUrl?{wifiConnectUrl:e.wifiConnectUrl}:{}))}});return null==s?void 0:s.data})}(u,function(e){return({method:t,url:n,data:a,headers:d})=>r.__awaiter(this,void 0,void 0,function*(){try{let r,i=Object.entries(Object.assign(Object.assign({},void 0===a?{}:{"Content-Type":"application/json"}),d)).reduce((e,[t,n])=>("string"==typeof n&&(e[t]=n),e),{}),l=yield(e?o.withAuth(fetch,e):(!s&&(s=o.withAuth()),s))(n,{method:t,headers:i,body:void 0===a?void 0:JSON.stringify(a)}),c=yield l.text();if(c)try{r=JSON.parse(c)}catch(e){r=c}if(!l.ok)throw Error(`Authed request failed with HTTP ${l.status}${c?`: ${c}`:""}`);return{data:r,status:l.status,headers:l.headers}}catch(e){throw e instanceof o.NotLoggedInError?new i("NOT_LOGGED_IN","No open-platform login session is available. Please run dbx auth:login first, then retry."):e instanceof o.TokenExpiredError?new i("TOKEN_EXPIRED","The open-platform login session has expired. Please run dbx auth:login again, then retry."):e instanceof o.AuthError?new i("AUTH_FAILED",`Open-platform authentication failed: ${e.message}`):e instanceof Error?e:Error(String(e))}})}(e.authOptions));if(!p||0!==p.code){let e=(null==p?void 0:p.code)===void 0?"unknown":String(p.code);if((null==p?void 0:p.code)===0x2fb1793)throw new i("APP_ROLE_PERMISSION_REQUIRED",`真机调试授权失败:当前账号没有工程所配置智能服务的角色权限。
2
2
  工程 AppKey:${u.appKey}
3
3
  请先检查本地工程的 app_key 是否正确,且不是 mock 或占位值;该 AppKey 应属于你有权限的智能服务。
4
4
  权限开通:进入豆包开发者平台 → 对应智能服务 → 成员管理,请应用管理员邀请你的账号并授予开发或调试权限。
@@ -6,12 +6,12 @@ import"node:module";import{__webpack_require__ as e}from"./rslib-runtime.js";imp
6
6
  工程 AppKey:${u.appKey}
7
7
  请先检查本地工程的 app_key 是否正确,且不是 mock 或占位值;该 AppKey 应属于你要调试的智能服务。
8
8
  权限配置:进入豆包开发者平台 → 对应智能服务 → 白名单配置,添加真机调试所需权限后重试。
9
- 错误码:${e}`);let t=(null==p?void 0:p.message)||"Failed to get debug ticket";throw Error(`${t} (code=${e}, appKey=${u.appKey}, baseApiUrl=${u.baseApiUrl})`)}let h=String((null==(d=p.data)?void 0:d.debug_token)||"").trim(),f=String((null==(l=p.data)?void 0:l.encrypted_debug_payload)||"").trim();if(!h||!f)throw Error("Debug ticket response is missing required fields");return{qrCodeValue:JSON.stringify({action:t.REAL_DEVICE_DEBUG_QR_ACTION,debug_token:h,encrypted_debug_payload:f}),debugToken:h,encryptedDebugPayload:f}})}},"../../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js"(e){var t={single_source_shortest_paths:function(e,n,r){var o,i,s,a,d,l,c,u={},p={};p[n]=0;var h=t.PriorityQueue.make();for(h.push(n,0);!h.empty();)for(s in i=(o=h.pop()).value,a=o.cost,d=e[i]||{})d.hasOwnProperty(s)&&(l=a+d[s],c=p[s],(void 0===p[s]||c>l)&&(p[s]=l,h.push(s,l),u[s]=i));if(void 0!==r&&void 0===p[r])throw Error(["Could not find a path from ",n," to ",r,"."].join(""));return u},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,n,r){var o=t.single_source_shortest_paths(e,n,r);return t.extract_shortest_path_from_predecessor_list(o,r)},PriorityQueue:{make:function(e){var n,r=t.PriorityQueue,o={};for(n in e=e||{},r)r.hasOwnProperty(n)&&(o[n]=r[n]);return o.queue=[],o.sorter=e.sorter||r.default_sorter,o},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){this.queue.push({value:e,cost:t}),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitmapper.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/interlace.js"),o=[function(){},function(e,t,n,r){if(r===t.length)throw Error("Ran out of data");let o=t[r];e[n]=o,e[n+1]=o,e[n+2]=o,e[n+3]=255},function(e,t,n,r){if(r+1>=t.length)throw Error("Ran out of data");let o=t[r];e[n]=o,e[n+1]=o,e[n+2]=o,e[n+3]=t[r+1]},function(e,t,n,r){if(r+2>=t.length)throw Error("Ran out of data");e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=255},function(e,t,n,r){if(r+3>=t.length)throw Error("Ran out of data");e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=t[r+3]}],i=[function(){},function(e,t,n,r){let o=t[0];e[n]=o,e[n+1]=o,e[n+2]=o,e[n+3]=r},function(e,t,n){let r=t[0];e[n]=r,e[n+1]=r,e[n+2]=r,e[n+3]=t[1]},function(e,t,n,r){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=r},function(e,t,n){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=t[3]}];t.dataToBitMap=function(e,t){let n,s,a,d,l,c,u=t.width,p=t.height,h=t.depth,f=t.bpp,m=t.interlace;8!==h&&(n=[],s=0,a={get:function(t){for(;n.length<t;)!function(){let t,r,o,i;if(s===e.length)throw Error("Ran out of data");let a=e[s];switch(s++,h){default:throw Error("unrecognised depth");case 16:o=e[s],s++,n.push((a<<8)+o);break;case 4:o=15&a,i=a>>4,n.push(i,o);break;case 2:t=3&a,r=a>>2&3,o=a>>4&3,i=a>>6&3,n.push(i,o,r,t);break;case 1:t=a>>4&1,r=a>>5&1,o=a>>6&1,i=a>>7&1,n.push(i,o,r,t,a>>3&1,a>>2&1,a>>1&1,1&a)}}();let r=n.slice(0,t);return n=n.slice(t),r},resetAfterLine:function(){n.length=0},end:function(){if(s!==e.length)throw Error("extra data found")}}),d=h<=8?Buffer.alloc(u*p*4):new Uint16Array(u*p*4);let g=Math.pow(2,h)-1,_=0;if(m)l=r.getImagePasses(u,p),c=r.getInterlaceIterator(u,p);else{let e=0;c=function(){let t=e;return e+=4,t},l=[{width:u,height:p}]}for(let t=0;t<l.length;t++)8===h?_=function(e,t,n,r,i,s){let a=e.width,d=e.height,l=e.index;for(let e=0;e<d;e++)for(let d=0;d<a;d++){let a=n(d,e,l);o[r](t,i,a,s),s+=r}return s}(l[t],d,c,f,e,_):function(e,t,n,r,o,s){let a=e.width,d=e.height,l=e.index;for(let e=0;e<d;e++){for(let d=0;d<a;d++){let a=o.get(r),c=n(d,e,l);i[r](t,a,c,s)}o.resetAfterLine()}}(l[t],d,c,f,a,g);if(8===h){if(_!==e.length)throw Error("extra data found")}else a.end();return d}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitpacker.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js");e.exports=function(e,t,n,o){let i=-1!==[r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(o.colorType);if(o.colorType===o.inputColorType){let t,n=(new DataView(t=new ArrayBuffer(2)).setInt16(0,256,!0),256!==new Int16Array(t)[0]);if(8===o.bitDepth||16===o.bitDepth&&n)return e}let s=16!==o.bitDepth?e:new Uint16Array(e.buffer),a=255,d=r.COLORTYPE_TO_BPP_MAP[o.inputColorType];4!==d||o.inputHasAlpha||(d=3);let l=r.COLORTYPE_TO_BPP_MAP[o.colorType];16===o.bitDepth&&(a=65535,l*=2);let c=Buffer.alloc(t*n*l),u=0,p=0,h=o.bgColor||{};void 0===h.red&&(h.red=a),void 0===h.green&&(h.green=a),void 0===h.blue&&(h.blue=a);for(let e=0;e<n;e++)for(let e=0;e<t;e++){let e=function(){let e,t,n,d=a;switch(o.inputColorType){case r.COLORTYPE_COLOR_ALPHA:d=s[u+3],e=s[u],t=s[u+1],n=s[u+2];break;case r.COLORTYPE_COLOR:e=s[u],t=s[u+1],n=s[u+2];break;case r.COLORTYPE_ALPHA:d=s[u+1],t=e=s[u],n=e;break;case r.COLORTYPE_GRAYSCALE:t=e=s[u],n=e;break;default:throw Error("input color type:"+o.inputColorType+" is not supported at present")}return o.inputHasAlpha&&!i&&(d/=a,e=Math.min(Math.max(Math.round((1-d)*h.red+d*e),0),a),t=Math.min(Math.max(Math.round((1-d)*h.green+d*t),0),a),n=Math.min(Math.max(Math.round((1-d)*h.blue+d*n),0),a)),{red:e,green:t,blue:n,alpha:d}}();switch(o.colorType){case r.COLORTYPE_COLOR_ALPHA:case r.COLORTYPE_COLOR:8===o.bitDepth?(c[p]=e.red,c[p+1]=e.green,c[p+2]=e.blue,i&&(c[p+3]=e.alpha)):(c.writeUInt16BE(e.red,p),c.writeUInt16BE(e.green,p+2),c.writeUInt16BE(e.blue,p+4),i&&c.writeUInt16BE(e.alpha,p+6));break;case r.COLORTYPE_ALPHA:case r.COLORTYPE_GRAYSCALE:{let t=(e.red+e.green+e.blue)/3;8===o.bitDepth?(c[p]=t,i&&(c[p+1]=e.alpha)):(c.writeUInt16BE(t,p),i&&c.writeUInt16BE(e.alpha,p+2));break}default:throw Error("unrecognised color Type "+o.colorType)}u+=d,p+=l}return c}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/chunkstream.js"(e,t,n){let r=n("util"),o=n("stream"),i=e.exports=function(){o.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};r.inherits(i,o),i.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick((function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}).bind(this))},i.prototype.write=function(e,t){let n;return this.writable?(n=Buffer.isBuffer(e)?e:Buffer.from(e,t||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&0===this._reads.length&&(this._paused=!0),this.writable&&!this._paused):(this.emit("error",Error("Stream not writable")),!1)},i.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(0===this._buffers.length?this._end():(this._buffers.push(null),this._process()))},i.prototype.destroySoon=i.prototype.end,i.prototype._end=function(){this._reads.length>0&&this.emit("error",Error("Unexpected end of input")),this.destroy()},i.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},i.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))},i.prototype._processRead=function(e){this._reads.shift();let t=0,n=0,r=Buffer.alloc(e.length);for(;t<e.length;){let o=this._buffers[n++],i=Math.min(o.length,e.length-t);o.copy(r,t,0,i),t+=i,i!==o.length&&(this._buffers[--n]=o.slice(i))}n>0&&this._buffers.splice(0,n),this._buffered-=e.length,e.func.call(this,r)},i.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit("error",e)}}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"(e){e.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:0x49484452,TYPE_IEND:0x49454e44,TYPE_IDAT:0x49444154,TYPE_PLTE:0x504c5445,TYPE_tRNS:0x74524e53,TYPE_gAMA:0x67414d41,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/crc.js"(e){let t=[];for(let e=0;e<256;e++){let n=e;for(let e=0;e<8;e++)1&n?n=0xedb88320^n>>>1:n>>>=1;t[e]=n}let n=e.exports=function(){this._crc=-1};n.prototype.write=function(e){for(let n=0;n<e.length;n++)this._crc=t[(this._crc^e[n])&255]^this._crc>>>8;return!0},n.prototype.crc32=function(){return -1^this._crc},n.crc32=function(e){let n=-1;for(let r=0;r<e.length;r++)n=t[(n^e[r])&255]^n>>>8;return -1^n}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-pack.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/paeth-predictor.js"),o={0:function(e,t,n,r,o){for(let i=0;i<n;i++)r[o+i]=e[t+i]},1:function(e,t,n,r,o,i){for(let s=0;s<n;s++){let n=s>=i?e[t+s-i]:0,a=e[t+s]-n;r[o+s]=a}},2:function(e,t,n,r,o){for(let i=0;i<n;i++){let s=t>0?e[t+i-n]:0,a=e[t+i]-s;r[o+i]=a}},3:function(e,t,n,r,o,i){for(let s=0;s<n;s++){let a=s>=i?e[t+s-i]:0,d=t>0?e[t+s-n]:0,l=e[t+s]-(a+d>>1);r[o+s]=l}},4:function(e,t,n,o,i,s){for(let a=0;a<n;a++){let d=a>=s?e[t+a-s]:0,l=t>0?e[t+a-n]:0,c=t>0&&a>=s?e[t+a-(n+s)]:0,u=e[t+a]-r(d,l,c);o[i+a]=u}}},i={0:function(e,t,n){let r=0,o=t+n;for(let n=t;n<o;n++)r+=Math.abs(e[n]);return r},1:function(e,t,n,r){let o=0;for(let i=0;i<n;i++){let n=i>=r?e[t+i-r]:0;o+=Math.abs(e[t+i]-n)}return o},2:function(e,t,n){let r=0,o=t+n;for(let i=t;i<o;i++){let o=t>0?e[i-n]:0;r+=Math.abs(e[i]-o)}return r},3:function(e,t,n,r){let o=0;for(let i=0;i<n;i++){let s=i>=r?e[t+i-r]:0,a=t>0?e[t+i-n]:0;o+=Math.abs(e[t+i]-(s+a>>1))}return o},4:function(e,t,n,o){let i=0;for(let s=0;s<n;s++){let a=s>=o?e[t+s-o]:0,d=t>0?e[t+s-n]:0,l=t>0&&s>=o?e[t+s-(n+o)]:0;i+=Math.abs(e[t+s]-r(a,d,l))}return i}};e.exports=function(e,t,n,r,s){let a;if("filterType"in r&&-1!==r.filterType)if("number"==typeof r.filterType)a=[r.filterType];else throw Error("unrecognised filter types");else a=[0,1,2,3,4];16===r.bitDepth&&(s*=2);let d=t*s,l=0,c=0,u=Buffer.alloc((d+1)*n),p=a[0];for(let t=0;t<n;t++){if(a.length>1){let t=1/0;for(let n=0;n<a.length;n++){let r=i[a[n]](e,c,d,s);r<t&&(p=a[n],t=r)}}u[l]=p,l++,o[p](e,c,d,u,l,s),l+=d,c+=d}return u}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-async.js"(e,t,n){let r=n("util"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/chunkstream.js"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse.js"),s=e.exports=function(e){o.call(this);let t=[],n=this;this._filter=new i(e,{read:this.read.bind(this),write:function(e){t.push(e)},complete:function(){n.emit("complete",Buffer.concat(t))}}),this._filter.start()};r.inherits(s,o)},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-sync.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-reader.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse.js");t.process=function(e,t){let n=[],i=new r(e);return new o(t,{read:i.read.bind(i),write:function(e){n.push(e)},complete:function(){}}).start(),i.process(),Buffer.concat(n)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/interlace.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/paeth-predictor.js");function i(e,t,n){let r=e*t;return 8!==n&&(r=Math.ceil(r/(8/n))),r}let s=e.exports=function(e,t){let n=e.width,o=e.height,s=e.interlace,a=e.bpp,d=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],s){let e=r.getImagePasses(n,o);for(let t=0;t<e.length;t++)this._images.push({byteWidth:i(e[t].width,a,d),height:e[t].height,lineIndex:0})}else this._images.push({byteWidth:i(n,a,d),height:o,lineIndex:0});8===d?this._xComparison=a:16===d?this._xComparison=2*a:this._xComparison=1};s.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},s.prototype._unFilterType1=function(e,t,n){let r=this._xComparison,o=r-1;for(let i=0;i<n;i++){let n=e[1+i],s=i>o?t[i-r]:0;t[i]=n+s}},s.prototype._unFilterType2=function(e,t,n){let r=this._lastLine;for(let o=0;o<n;o++){let n=e[1+o],i=r?r[o]:0;t[o]=n+i}},s.prototype._unFilterType3=function(e,t,n){let r=this._xComparison,o=r-1,i=this._lastLine;for(let s=0;s<n;s++){let n=e[1+s],a=i?i[s]:0,d=Math.floor(((s>o?t[s-r]:0)+a)/2);t[s]=n+d}},s.prototype._unFilterType4=function(e,t,n){let r=this._xComparison,i=r-1,s=this._lastLine;for(let a=0;a<n;a++){let n=e[1+a],d=s?s[a]:0,l=o(a>i?t[a-r]:0,d,a>i&&s?s[a-r]:0);t[a]=n+l}},s.prototype._reverseFilterLine=function(e){let t,n=e[0],r=this._images[this._imageIndex],o=r.byteWidth;if(0===n)t=e.slice(1,o+1);else switch(t=Buffer.alloc(o),n){case 1:this._unFilterType1(e,t,o);break;case 2:this._unFilterType2(e,t,o);break;case 3:this._unFilterType3(e,t,o);break;case 4:this._unFilterType4(e,t,o);break;default:throw Error("Unrecognised filter type - "+n)}this.write(t),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=t,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/format-normaliser.js"(e){e.exports=function(e,t){let n=t.depth,r=t.width,o=t.height,i=t.colorType,s=t.transColor,a=t.palette,d=e;return 3===i?!function(e,t,n,r,o){let i=0;for(let s=0;s<r;s++)for(let r=0;r<n;r++){let n=o[e[i]];if(!n)throw Error("index "+e[i]+" not in palette");for(let e=0;e<4;e++)t[i+e]=n[e];i+=4}}(e,d,r,o,a):(s&&function(e,t,n,r,o){let i=0;for(let s=0;s<r;s++)for(let r=0;r<n;r++){let n=!1;if(1===o.length?o[0]===e[i]&&(n=!0):o[0]===e[i]&&o[1]===e[i+1]&&o[2]===e[i+2]&&(n=!0),n)for(let e=0;e<4;e++)t[i+e]=0;i+=4}}(e,d,r,o,s),8!==n&&(16===n&&(d=Buffer.alloc(r*o*4)),!function(e,t,n,r,o){let i=Math.pow(2,o)-1,s=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){for(let n=0;n<4;n++)t[s+n]=Math.floor(255*e[s+n]/i+.5);s+=4}}(e,d,r,o,n))),d}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/interlace.js"(e,t){let n=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];t.getImagePasses=function(e,t){let r=[],o=e%8,i=t%8,s=(e-o)/8,a=(t-i)/8;for(let e=0;e<n.length;e++){let t=n[e],d=s*t.x.length,l=a*t.y.length;for(let e=0;e<t.x.length;e++)if(t.x[e]<o)d++;else break;for(let e=0;e<t.y.length;e++)if(t.y[e]<i)l++;else break;d>0&&l>0&&r.push({width:d,height:l,index:e})}return r},t.getInterlaceIterator=function(e){return function(t,r,o){let i=t%n[o].x.length,s=(t-i)/n[o].x.length*8+n[o].x[i],a=r%n[o].y.length;return 4*s+((r-a)/n[o].y.length*8+n[o].y[a])*e*4}}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-async.js"(e,t,n){let r=n("util"),o=n("stream"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer.js"),a=e.exports=function(e){o.call(this),this._packer=new s(e||{}),this._deflate=this._packer.createDeflate(),this.readable=!0};r.inherits(a,o),a.prototype.pack=function(e,t,n,r){this.emit("data",Buffer.from(i.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(t,n)),r&&this.emit("data",this._packer.packGAMA(r));let o=this._packer.filterData(e,t,n);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",(function(e){this.emit("data",this._packer.packIDAT(e))}).bind(this)),this._deflate.on("end",(function(){this.emit("data",this._packer.packIEND()),this.emit("end")}).bind(this)),this._deflate.end(o)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-sync.js"(e,t,n){let r=!0,o=n("zlib");o.deflateSync||(r=!1);let i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer.js");e.exports=function(e,t){if(!r)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let n=new s(t||{}),a=[];a.push(Buffer.from(i.PNG_SIGNATURE)),a.push(n.packIHDR(e.width,e.height)),e.gamma&&a.push(n.packGAMA(e.gamma));let d=n.filterData(e.data,e.width,e.height),l=o.deflateSync(d,n.getDeflateOptions());if(d=null,!l||!l.length)throw Error("bad png - invalid compressed data response");return a.push(n.packIDAT(l)),a.push(n.packIEND()),Buffer.concat(a)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/crc.js"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitpacker.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-pack.js"),a=n("zlib"),d=e.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32768,e.deflateLevel=null!=e.deflateLevel?e.deflateLevel:9,e.deflateStrategy=null!=e.deflateStrategy?e.deflateStrategy:3,e.inputHasAlpha=null==e.inputHasAlpha||e.inputHasAlpha,e.deflateFactory=e.deflateFactory||a.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType="number"==typeof e.colorType?e.colorType:r.COLORTYPE_COLOR_ALPHA,e.inputColorType="number"==typeof e.inputColorType?e.inputColorType:r.COLORTYPE_COLOR_ALPHA,-1===[r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.colorType))throw Error("option color type:"+e.colorType+" is not supported at present");if(-1===[r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.inputColorType))throw Error("option input color type:"+e.inputColorType+" is not supported at present");if(8!==e.bitDepth&&16!==e.bitDepth)throw Error("option bit depth:"+e.bitDepth+" is not supported at present")};d.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},d.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},d.prototype.filterData=function(e,t,n){let o=i(e,t,n,this._options),a=r.COLORTYPE_TO_BPP_MAP[this._options.colorType];return s(o,t,n,this._options,a)},d.prototype._packChunk=function(e,t){let n=t?t.length:0,r=Buffer.alloc(n+12);return r.writeUInt32BE(n,0),r.writeUInt32BE(e,4),t&&t.copy(r,8),r.writeInt32BE(o.crc32(r.slice(4,r.length-4)),r.length-4),r},d.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*r.GAMMA_DIVISION),0),this._packChunk(r.TYPE_gAMA,t)},d.prototype.packIHDR=function(e,t){let n=Buffer.alloc(13);return n.writeUInt32BE(e,0),n.writeUInt32BE(t,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(r.TYPE_IHDR,n)},d.prototype.packIDAT=function(e){return this._packChunk(r.TYPE_IDAT,e)},d.prototype.packIEND=function(){return this._packChunk(r.TYPE_IEND,null)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/paeth-predictor.js"(e){e.exports=function(e,t,n){let r=e+t-n,o=Math.abs(r-e),i=Math.abs(r-t),s=Math.abs(r-n);return o<=i&&o<=s?e:i<=s?t:n}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-async.js"(e,t,n){let r=n("util"),o=n("zlib"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/chunkstream.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-async.js"),a=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser.js"),d=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitmapper.js"),l=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/format-normaliser.js"),c=e.exports=function(e){i.call(this),this._parser=new a(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};r.inherits(c,i),c.prototype._handleError=function(e){this.emit("error",e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",function(){})),this.errord=!0},c.prototype._inflateData=function(e){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=o.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let e=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,t=Math.max(e,o.Z_MIN_CHUNK);this._inflate=o.createInflate({chunkSize:t});let n=e,r=this.emit.bind(this,"error");this._inflate.on("error",function(e){n&&r(e)}),this._filter.on("complete",this._complete.bind(this));let i=this._filter.write.bind(this._filter);this._inflate.on("data",function(e){n&&(e.length>n&&(e=e.slice(0,n)),n-=e.length,i(e))}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(e)},c.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new s(this._bitmapInfo)},c.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e},c.prototype._handlePalette=function(e){this._bitmapInfo.palette=e},c.prototype._simpleTransparency=function(){this._metaData.alpha=!0},c.prototype._headersFinished=function(){this.emit("metadata",this._metaData)},c.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))},c.prototype._complete=function(e){let t;if(!this.errord){try{let n=d.dataToBitMap(e,this._bitmapInfo);t=l(n,this._bitmapInfo),n=null}catch(e){this._handleError(e);return}this.emit("parsed",t)}}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-sync.js"(e,t,n){let r=!0,o=n("zlib"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-inflate.js");o.deflateSync||(r=!1);let s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-reader.js"),a=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-sync.js"),d=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser.js"),l=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitmapper.js"),c=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/format-normaliser.js");e.exports=function(e,t){let n,u,p,h;if(!r)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let f=[],m=new s(e);if(new d(t,{read:m.read.bind(m),error:function(e){n=e},metadata:function(e){u=e},gamma:function(e){p=e},palette:function(e){u.palette=e},transColor:function(e){u.transColor=e},inflateData:function(e){f.push(e)},simpleTransparency:function(){u.alpha=!0}}).start(),m.process(),n)throw n;let g=Buffer.concat(f);if(f.length=0,u.interlace)h=o.inflateSync(g);else{let e=((u.width*u.bpp*u.depth+7>>3)+1)*u.height;h=i(g,{chunkSize:e,maxLength:e})}if(g=null,!h||!h.length)throw Error("bad png - invalid inflate data response");let _=a.process(h,u);g=null;let w=l.dataToBitMap(_,u);_=null;let y=c(w,u);return u.data=y,u.gamma=p||0,u}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/crc.js"),i=e.exports=function(e,t){this._options=e,e.checkCRC=!1!==e.checkCRC,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[r.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[r.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[r.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[r.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[r.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[r.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};i.prototype.start=function(){this.read(r.PNG_SIGNATURE.length,this._parseSignature.bind(this))},i.prototype._parseSignature=function(e){let t=r.PNG_SIGNATURE;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return void this.error(Error("Invalid file signature"));this.read(8,this._parseChunkBegin.bind(this))},i.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),n=e.readUInt32BE(4),i="";for(let t=4;t<8;t++)i+=String.fromCharCode(e[t]);let s=!!(32&e[4]);return this._hasIHDR||n===r.TYPE_IHDR?(this._crc=new o,this._crc.write(Buffer.from(i)),this._chunks[n])?this._chunks[n](t):s?void this.read(t+4,this._skipChunk.bind(this)):void this.error(Error("Unsupported critical chunk type "+i)):void this.error(Error("Expected IHDR on beggining"))},i.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},i.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),n=this._crc.crc32();this._options.checkCRC&&n!==t?this.error(Error("Crc error - "+t+" - "+n)):this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))},i.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),n=e.readUInt32BE(4),o=e[8],i=e[9],s=e[10],a=e[11],d=e[12];if(8!==o&&4!==o&&2!==o&&1!==o&&16!==o)return void this.error(Error("Unsupported bit depth "+o));if(!(i in r.COLORTYPE_TO_BPP_MAP))return void this.error(Error("Unsupported color type"));if(0!==s)return void this.error(Error("Unsupported compression method"));if(0!==a)return void this.error(Error("Unsupported filter method"));if(0!==d&&1!==d)return void this.error(Error("Unsupported interlace method"));this._colorType=i;let l=r.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:n,depth:o,interlace:!!d,palette:!!(i&r.COLORTYPE_PALETTE),color:!!(i&r.COLORTYPE_COLOR),alpha:!!(i&r.COLORTYPE_ALPHA),bpp:l,colorType:i}),this._handleChunkEnd()},i.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))},i.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let n=0;n<t;n++)this._palette.push([e[3*n],e[3*n+1],e[3*n+2],255]);this.palette(this._palette),this._handleChunkEnd()},i.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))},i.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===r.COLORTYPE_PALETTE_COLOR){if(0===this._palette.length)return void this.error(Error("Transparency chunk must be after palette"));if(e.length>this._palette.length)return void this.error(Error("More transparent colors than palette size"));for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===r.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===r.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()},i.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))},i.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/r.GAMMA_DIVISION),this._handleChunkEnd()},i.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))},i.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===r.COLORTYPE_PALETTE_COLOR&&0===this._palette.length)throw Error("Expected palette not found");this.inflateData(t);let n=e-t.length;n>0?this._handleIDAT(n):this._handleChunkEnd()},i.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))},i.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png-sync.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-sync.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-sync.js");t.read=function(e,t){return r(e,t||{})},t.write=function(e,t){return o(e,t)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png.js"(e,t,n){let r=n("util"),o=n("stream"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-async.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-async.js"),a=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png-sync.js"),d=t.O=function(e){o.call(this),e=e||{},this.width=0|e.width,this.height=0|e.height,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new i(e),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",(function(e){this.data=e,this.emit("parsed",e)}).bind(this)),this._packer=new s(e),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};r.inherits(d,o),d.sync=a,d.prototype.pack=function(){return this.data&&this.data.length?process.nextTick((function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}).bind(this)):this.emit("error","No data provided"),this},d.prototype.parse=function(e,t){if(t){let e,n;e=(function(e){this.removeListener("error",n),this.data=e,t(null,this)}).bind(this),n=(function(n){this.removeListener("parsed",e),t(n,null)}).bind(this),this.once("parsed",e),this.once("error",n)}return this.end(e),this},d.prototype.write=function(e){return this._parser.write(e),!0},d.prototype.end=function(e){this._parser.end(e)},d.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit("metadata",e)},d.prototype._gamma=function(e){this.gamma=e},d.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},d.bitblt=function(e,t,n,r,o,i,s,a){if(r|=0,o|=0,i|=0,s|=0,a|=0,(n|=0)>e.width||r>e.height||n+o>e.width||r+i>e.height)throw Error("bitblt reading outside image");if(s>t.width||a>t.height||s+o>t.width||a+i>t.height)throw Error("bitblt writing outside image");for(let d=0;d<i;d++)e.data.copy(t.data,(a+d)*t.width+s<<2,(r+d)*e.width+n<<2,(r+d)*e.width+n+o<<2)},d.prototype.bitblt=function(e,t,n,r,o,i,s){return d.bitblt(this,e,t,n,r,o,i,s),this},d.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++){let r=e.width*t+n<<2;for(let t=0;t<3;t++){let n=e.data[r+t]/255;n=Math.pow(n,1/2.2/e.gamma),e.data[r+t]=Math.round(255*n)}}e.gamma=0}},d.prototype.adjustGamma=function(){d.adjustGamma(this)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-inflate.js"(e,t,n){let r=n("assert").ok,o=n("zlib"),i=n("util"),s=n("buffer").kMaxLength;function a(e){if(!(this instanceof a))return new a(e);e&&e.chunkSize<o.Z_MIN_CHUNK&&(e.chunkSize=o.Z_MIN_CHUNK),o.Inflate.call(this,e),this._offset=void 0===this._offset?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&null!=e.maxLength&&(this._maxLength=e.maxLength)}function d(e,t){t&&process.nextTick(t),e._handle&&(e._handle.close(),e._handle=null)}function l(e,t){var n=new a(t),r=e;if("string"==typeof r&&(r=Buffer.from(r)),!(r instanceof Buffer))throw TypeError("Not a string or buffer");let i=n._finishFlushFlag;return null==i&&(i=o.Z_FINISH),n._processChunk(r,i)}a.prototype._processChunk=function(e,t,n){let i,a;if("function"==typeof n)return o.Inflate._processChunk.call(this,e,t,n);let l=this,c=e&&e.length,u=this._chunkSize-this._offset,p=this._maxLength,h=0,f=[],m=0;this.on("error",function(e){i=e}),r(this._handle,"zlib binding closed");do a=(a=this._handle.writeSync(t,e,h,c,this._buffer,this._offset,u))||this._writeState;while(!this._hadError&&function(e,t){if(l._hadError)return;let n=u-t;if(r(n>=0,"have should not go down"),n>0){let e=l._buffer.slice(l._offset,l._offset+n);if(l._offset+=n,e.length>p&&(e=e.slice(0,p)),f.push(e),m+=e.length,0==(p-=e.length))return!1}return(0===t||l._offset>=l._chunkSize)&&(u=l._chunkSize,l._offset=0,l._buffer=Buffer.allocUnsafe(l._chunkSize)),0===t&&(h+=c-e,c=e,!0)}(a[0],a[1]));if(this._hadError)throw i;if(m>=s)throw d(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+s.toString(16)+" bytes");let g=Buffer.concat(f,m);return d(this),g},i.inherits(a,o.Inflate),e.exports=t=l,t.Inflate=a,t.createInflate=function(e){return new a(e)},t.inflateSync=l},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-reader.js"(e){let t=e.exports=function(e){this._buffer=e,this._reads=[]};t.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})},t.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}return this._reads.length>0?Error("There are some read requests waitng on finished stream"):this._buffer.length>0?Error("unrecognised content at end of stream"):void 0}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js");function a(e,t,n,i,s){let a=[].slice.call(arguments,1),d=a.length,l="function"==typeof a[d-1];if(!l&&!r())throw Error("Callback required as last argument");if(l){if(d<2)throw Error("Too few arguments provided");2===d?(s=n,n=t,t=i=void 0):3===d&&(t.getContext&&void 0===s?(s=i,i=void 0):(s=i,i=n,n=t,t=void 0))}else{if(d<1)throw Error("Too few arguments provided");return 1===d?(n=t,t=i=void 0):2!==d||t.getContext||(i=n,n=t,t=void 0),new Promise(function(r,s){try{let s=o.create(n,i);r(e(s,t,i))}catch(e){s(e)}})}try{let r=o.create(n,i);s(null,e(r,t,i))}catch(e){s(e)}}o.create,a.bind(null,i.render),a.bind(null,i.renderToDataURL),a.bind(null,function(e,t,n){return s.render(e,n)})},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"(e){e.exports=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js").getSymbolSize;t.getRowColCoords=function(e){if(1===e)return[];let t=Math.floor(e/7)+2,n=r(e),o=145===n?26:2*Math.ceil((n-13)/(2*t-2)),i=[n-7];for(let e=1;e<t-1;e++)i[e]=i[e-1]-o;return i.push(6),i.reverse()},t.getPositions=function(e){let n=[],r=t.getRowColCoords(e),o=r.length;for(let e=0;e<o;e++)for(let t=0;t<o;t++)(0!==e||0!==t)&&(0!==e||t!==o-1)&&(e!==o-1||0!==t)&&n.push([r[e],r[t]]);return n}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),o=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(e){this.mode=r.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=45*o.indexOf(this.data[t]);n+=o.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(o.indexOf(this.data[t]),6)},e.exports=i},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js"(e){function t(){this.buffer=[],this.length=0}t.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},e.exports=t},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js"(e){function t(e){if(!e||e<1)throw Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}t.prototype.set=function(e,t,n,r){let o=e*this.size+t;this.data[o]=n,r&&(this.reservedBit[o]=!0)},t.prototype.get=function(e,t){return this.data[e*this.size+t]},t.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},t.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},e.exports=t},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js");function o(e){this.mode=r.BYTE,"string"==typeof e?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}o.getBitsLength=function(e){return 8*e},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},e.exports=o},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"),o=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];t.getBlocksCount=function(e,t){switch(t){case r.L:return o[(e-1)*4+0];case r.M:return o[(e-1)*4+1];case r.Q:return o[(e-1)*4+2];case r.H:return o[(e-1)*4+3];default:return}},t.getTotalCodewordsCount=function(e,t){switch(t){case r.L:return i[(e-1)*4+0];case r.M:return i[(e-1)*4+1];case r.Q:return i[(e-1)*4+2];case r.H:return i[(e-1)*4+3];default:return}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"(e,t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2},t.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},t.from=function(e,n){if(t.isValid(e))return e;try{if("string"!=typeof e)throw Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw Error("Unknown EC Level: "+e)}}catch(e){return n}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js").getSymbolSize;t.getPositions=function(e){let t=r(e);return[[0,0],[t-7,0],[0,t-7]]}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),o=r.getBCHDigit(1335);t.getEncodedBits=function(e,t){let n=e.bit<<3|t,i=n<<10;for(;r.getBCHDigit(i)-o>=0;)i^=1335<<r.getBCHDigit(i)-o;return(n<<10|i)^21522}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js"(e,t){let n=new Uint8Array(512),r=new Uint8Array(256),o=1;for(let e=0;e<255;e++)n[e]=o,r[o]=e,256&(o<<=1)&&(o^=285);for(let e=255;e<512;e++)n[e]=n[e-255];t.exp=function(e){return n[e]},t.mul=function(e,t){return 0===e||0===t?0:n[r[e]+r[t]]}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js");function i(e){this.mode=r.KANJI,this.data=e}i.getBitsLength=function(e){return 13*e},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=o.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");n=(n>>>8&255)*192+(255&n),e.put(n,13)}},e.exports=i},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js"(e,t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};t.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},t.from=function(e){return t.isValid(e)?parseInt(e,10):void 0},t.getPenaltyN1=function(e){let t=e.size,n=0,r=0,o=0,i=null,s=null;for(let a=0;a<t;a++){r=o=0,i=s=null;for(let d=0;d<t;d++){let t=e.get(a,d);t===i?r++:(r>=5&&(n+=3+(r-5)),i=t,r=1),(t=e.get(d,a))===s?o++:(o>=5&&(n+=3+(o-5)),s=t,o=1)}r>=5&&(n+=3+(r-5)),o>=5&&(n+=3+(o-5))}return n},t.getPenaltyN2=function(e){let t=e.size,n=0;for(let r=0;r<t-1;r++)for(let o=0;o<t-1;o++){let t=e.get(r,o)+e.get(r,o+1)+e.get(r+1,o)+e.get(r+1,o+1);(4===t||0===t)&&n++}return 3*n},t.getPenaltyN3=function(e){let t=e.size,n=0,r=0,o=0;for(let i=0;i<t;i++){r=o=0;for(let s=0;s<t;s++)r=r<<1&2047|e.get(i,s),s>=10&&(1488===r||93===r)&&n++,o=o<<1&2047|e.get(s,i),s>=10&&(1488===o||93===o)&&n++}return 40*n},t.getPenaltyN4=function(e){let t=0,n=e.data.length;for(let r=0;r<n;r++)t+=e.data[r];return 10*Math.abs(Math.ceil(100*t/n/5)-10)},t.applyMask=function(e,n){let r=n.size;for(let o=0;o<r;o++)for(let i=0;i<r;i++)n.isReserved(i,o)||n.xor(i,o,function(e,n,r){switch(e){case t.Patterns.PATTERN000:return(n+r)%2==0;case t.Patterns.PATTERN001:return n%2==0;case t.Patterns.PATTERN010:return r%3==0;case t.Patterns.PATTERN011:return(n+r)%3==0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case t.Patterns.PATTERN101:return n*r%2+n*r%3==0;case t.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case t.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error("bad maskPattern:"+e)}}(e,i,o))},t.getBestMask=function(e,n){let r=Object.keys(t.Patterns).length,o=0,i=1/0;for(let s=0;s<r;s++){n(s),t.applyMask(s,e);let r=t.getPenaltyN1(e)+t.getPenaltyN2(e)+t.getPenaltyN3(e)+t.getPenaltyN4(e);t.applyMask(s,e),r<i&&(i=r,o=s)}return o}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js");t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(e,t){if(!e.ccBits)throw Error("Invalid mode: "+e);if(!r.isValid(t))throw Error("Invalid version: "+t);return t>=1&&t<10?e.ccBits[0]:t<27?e.ccBits[1]:e.ccBits[2]},t.getBestModeForData=function(e){return o.testNumeric(e)?t.NUMERIC:o.testAlphanumeric(e)?t.ALPHANUMERIC:o.testKanji(e)?t.KANJI:t.BYTE},t.toString=function(e){if(e&&e.id)return e.id;throw Error("Invalid mode")},t.isValid=function(e){return e&&e.bit&&e.ccBits},t.from=function(e,n){if(t.isValid(e))return e;try{if("string"!=typeof e)throw Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw Error("Unknown mode: "+e)}}catch(e){return n}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js");function o(e){this.mode=r.NUMERIC,this.data=e.toString()}o.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(e){let t,n;for(t=0;t+3<=this.data.length;t+=3)n=parseInt(this.data.substr(t,3),10),e.put(n,10);let r=this.data.length-t;r>0&&(n=parseInt(this.data.substr(t),10),e.put(n,3*r+1))},e.exports=o},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js");t.mul=function(e,t){let n=new Uint8Array(e.length+t.length-1);for(let o=0;o<e.length;o++)for(let i=0;i<t.length;i++)n[o+i]^=r.mul(e[o],t[i]);return n},t.mod=function(e,t){let n=new Uint8Array(e);for(;n.length-t.length>=0;){let e=n[0];for(let o=0;o<t.length;o++)n[o]^=r.mul(t[o],e);let o=0;for(;o<n.length&&0===n[o];)o++;n=n.slice(o)}return n},t.generateECPolynomial=function(e){let n=new Uint8Array([1]);for(let o=0;o<e;o++)n=t.mul(n,new Uint8Array([1,r.exp(o)]));return n}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js"),a=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js"),d=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js"),l=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js"),c=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"),u=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js"),p=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js"),h=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js"),f=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),m=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js");function g(e,t,n){let r,o,i=e.size,s=h.getEncodedBits(t,n);for(r=0;r<15;r++)o=(s>>r&1)==1,r<6?e.set(r,8,o,!0):r<8?e.set(r+1,8,o,!0):e.set(i-15+r,8,o,!0),r<8?e.set(8,i-r-1,o,!0):r<9?e.set(8,15-r-1+1,o,!0):e.set(8,15-r-1,o,!0);e.set(i-8,8,1,!0)}t.create=function(e,t){let n,h;if(void 0===e||""===e)throw Error("No input text");let _=o.M;return void 0!==t&&(_=o.from(t.errorCorrectionLevel,o.M),n=p.from(t.version),h=l.from(t.maskPattern),t.toSJISFunc&&r.setToSJISFunction(t.toSJISFunc)),function(e,t,n,o){let h;if(Array.isArray(e))h=m.fromArray(e);else if("string"==typeof e){let r=t;if(!r){let t=m.rawSplit(e);r=p.getBestVersionForData(t,n)}h=m.fromString(e,r||40)}else throw Error("Invalid data");let _=p.getBestVersionForData(h,n);if(!_)throw Error("The amount of data is too big to be stored in a QR Code");if(t){if(t<_)throw Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+_+".\n")}else t=_;let w=function(e,t,n){let o=new i;n.forEach(function(t){o.put(t.mode.bit,4),o.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(o)});let s=(r.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,t))*8;for(o.getLengthInBits()+4<=s&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(0);let a=(s-o.getLengthInBits())/8;for(let e=0;e<a;e++)o.put(e%2?17:236,8);return function(e,t,n){let o,i,s=r.getSymbolTotalCodewords(t),a=s-c.getTotalCodewordsCount(t,n),d=c.getBlocksCount(t,n),l=s%d,p=d-l,h=Math.floor(s/d),f=Math.floor(a/d),m=f+1,g=h-f,_=new u(g),w=0,y=Array(d),b=Array(d),v=0,E=new Uint8Array(e.buffer);for(let e=0;e<d;e++){let t=e<p?f:m;y[e]=E.slice(w,w+t),b[e]=_.encode(y[e]),w+=t,v=Math.max(v,t)}let I=new Uint8Array(s),A=0;for(o=0;o<v;o++)for(i=0;i<d;i++)o<y[i].length&&(I[A++]=y[i][o]);for(o=0;o<g;o++)for(i=0;i<d;i++)I[A++]=b[i][o];return I}(o,e,t)}(t,n,h),y=new s(r.getSymbolSize(t));!function(e,t){let n=e.size,r=d.getPositions(t);for(let t=0;t<r.length;t++){let o=r[t][0],i=r[t][1];for(let t=-1;t<=7;t++)if(!(o+t<=-1)&&!(n<=o+t))for(let r=-1;r<=7;r++)i+r<=-1||n<=i+r||(t>=0&&t<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===t||6===t)||t>=2&&t<=4&&r>=2&&r<=4?e.set(o+t,i+r,!0,!0):e.set(o+t,i+r,!1,!0))}}(y,t);let b=y.size;for(let e=8;e<b-8;e++){let t=e%2==0;y.set(e,6,t,!0),y.set(6,e,t,!0)}return!function(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],o=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)-2===t||2===t||-2===n||2===n||0===t&&0===n?e.set(r+t,o+n,!0,!0):e.set(r+t,o+n,!1,!0)}}(y,t),g(y,n,0),t>=7&&function(e,t){let n,r,o,i=e.size,s=p.getEncodedBits(t);for(let t=0;t<18;t++)n=Math.floor(t/3),r=t%3+i-8-3,o=(s>>t&1)==1,e.set(n,r,o,!0),e.set(r,n,o,!0)}(y,t),!function(e,t){let n=e.size,r=-1,o=n-1,i=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!e.isReserved(o,a-n)){let r=!1;s<t.length&&(r=(t[s]>>>i&1)==1),e.set(o,a-n,r),-1==--i&&(s++,i=7)}if((o+=r)<0||n<=o){o-=r,r=-r;break}}}(y,w),isNaN(o)&&(o=l.getBestMask(y,g.bind(null,y,n))),l.applyMask(o,y),g(y,n,o),{modules:y,version:t,errorCorrectionLevel:n,maskPattern:o,segments:h}}(e,n,_,h)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js");function o(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}o.prototype.initialize=function(e){this.degree=e,this.genPoly=r.generateECPolynomial(this.degree)},o.prototype.encode=function(e){if(!this.genPoly)throw Error("Encoder not initialized");let t=new Uint8Array(e.length+this.degree);t.set(e);let n=r.mod(t,this.genPoly),o=this.degree-n.length;if(o>0){let e=new Uint8Array(this.degree);return e.set(n,o),e}return n},e.exports=o},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"(e,t){let n="[0-9]+",r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",o="(?:(?![A-Z0-9 $%*+\\-./:]|"+(r=r.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";t.KANJI=RegExp(r,"g"),t.BYTE_KANJI=RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),t.BYTE=RegExp(o,"g"),t.NUMERIC=RegExp(n,"g"),t.ALPHANUMERIC=RegExp("[A-Z $%*+\\-./:]+","g");let i=RegExp("^"+r+"$"),s=RegExp("^"+n+"$"),a=RegExp("^[A-Z0-9 $%*+\\-./:]+$");t.testKanji=function(e){return i.test(e)},t.testNumeric=function(e){return s.test(e)},t.testAlphanumeric=function(e){return a.test(e)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js"),a=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js"),d=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"),l=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),c=n("../../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js");function u(e){return unescape(encodeURIComponent(e)).length}function p(e,t,n){let r,o=[];for(;null!==(r=e.exec(n));)o.push({data:r[0],index:r.index,mode:t,length:r[0].length});return o}function h(e){let t,n,o=p(d.NUMERIC,r.NUMERIC,e),i=p(d.ALPHANUMERIC,r.ALPHANUMERIC,e);return l.isKanjiModeEnabled()?(t=p(d.BYTE,r.BYTE,e),n=p(d.KANJI,r.KANJI,e)):(t=p(d.BYTE_KANJI,r.BYTE,e),n=[]),o.concat(i,t,n).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,t){switch(t){case r.NUMERIC:return o.getBitsLength(e);case r.ALPHANUMERIC:return i.getBitsLength(e);case r.KANJI:return a.getBitsLength(e);case r.BYTE:return s.getBitsLength(e)}}function m(e,t){let n,d=r.getBestModeForData(e);if((n=r.from(t,d))!==r.BYTE&&n.bit<d.bit)throw Error('"'+e+'" cannot be encoded with mode '+r.toString(n)+".\n Suggested mode is: "+r.toString(d));switch(n===r.KANJI&&!l.isKanjiModeEnabled()&&(n=r.BYTE),n){case r.NUMERIC:return new o(e);case r.ALPHANUMERIC:return new i(e);case r.KANJI:return new a(e);case r.BYTE:return new s(e)}}t.fromArray=function(e){return e.reduce(function(e,t){return"string"==typeof t?e.push(m(t,null)):t.data&&e.push(m(t.data,t.mode)),e},[])},t.fromString=function(e,n){let o=function(e,t){let n={},o={start:{}},i=["start"];for(let s=0;s<e.length;s++){let a=e[s],d=[];for(let e=0;e<a.length;e++){let l=a[e],c=""+s+e;d.push(c),n[c]={node:l,lastCount:0},o[c]={};for(let e=0;e<i.length;e++){let s=i[e];n[s]&&n[s].node.mode===l.mode?(o[s][c]=f(n[s].lastCount+l.length,l.mode)-f(n[s].lastCount,l.mode),n[s].lastCount+=l.length):(n[s]&&(n[s].lastCount=l.length),o[s][c]=f(l.length,l.mode)+4+r.getCharCountIndicator(l.mode,t))}}i=d}for(let e=0;e<i.length;e++)o[i[e]].end=0;return{map:o,table:n}}(function(e){let t=[];for(let n=0;n<e.length;n++){let o=e[n];switch(o.mode){case r.NUMERIC:t.push([o,{data:o.data,mode:r.ALPHANUMERIC,length:o.length},{data:o.data,mode:r.BYTE,length:o.length}]);break;case r.ALPHANUMERIC:t.push([o,{data:o.data,mode:r.BYTE,length:o.length}]);break;case r.KANJI:t.push([o,{data:o.data,mode:r.BYTE,length:u(o.data)}]);break;case r.BYTE:t.push([{data:o.data,mode:r.BYTE,length:u(o.data)}])}}return t}(h(e,l.isKanjiModeEnabled())),n),i=c.find_path(o.map,"start","end"),s=[];for(let e=1;e<i.length-1;e++)s.push(o.table[i[e]].node);return t.fromArray(s.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?e[e.length-1].data+=t.data:e.push(t),e},[]))},t.rawSplit=function(e){return t.fromArray(h(e,l.isKanjiModeEnabled()))}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"(e,t){let n,r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];t.getSymbolSize=function(e){if(!e)throw Error('"version" cannot be null or undefined');if(e<1||e>40)throw Error('"version" should be in range from 1 to 40');return 4*e+17},t.getSymbolTotalCodewords=function(e){return r[e]},t.getBCHDigit=function(e){let t=0;for(;0!==e;)t++,e>>>=1;return t},t.setToSJISFunction=function(e){if("function"!=typeof e)throw Error('"toSJISFunc" is not a valid function.');n=e},t.isKanjiModeEnabled=function(){return void 0!==n},t.toSJIS=function(e){return n(e)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"(e,t){t.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),a=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"),d=r.getBCHDigit(7973);function l(e,t){return s.getCharCountIndicator(e,t)+4}t.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},t.getCapacity=function(e,t,n){if(!a.isValid(e))throw Error("Invalid QR Code version");void 0===n&&(n=s.BYTE);let i=(r.getSymbolTotalCodewords(e)-o.getTotalCodewordsCount(e,t))*8;if(n===s.MIXED)return i;let d=i-l(n,e);switch(n){case s.NUMERIC:return Math.floor(d/10*3);case s.ALPHANUMERIC:return Math.floor(d/11*2);case s.KANJI:return Math.floor(d/13);case s.BYTE:default:return Math.floor(d/8)}},t.getBestVersionForData=function(e,n){let r,o=i.from(n,i.M);if(Array.isArray(e)){if(e.length>1){for(let n=1;n<=40;n++)if(function(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}(e,n)<=t.getCapacity(n,o,s.MIXED))return n;return}if(0===e.length)return 1;r=e[0]}else r=e;return function(e,n,r){for(let o=1;o<=40;o++)if(n<=t.getCapacity(o,r,e))return o}(r.mode,r.getLength(),o)},t.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error("Invalid QR Code version");let t=e<<12;for(;r.getBCHDigit(t)-d>=0;)t^=7973<<r.getBCHDigit(t)-d;return e<<12|t}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/index.js"(e,t,n){e.exports=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/server.js")},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js");t.render=function(e,t,n){var o;let i=n,s=t;void 0!==i||t&&t.getContext||(i=t,t=void 0),t||(s=function(){try{return document.createElement("canvas")}catch(e){throw Error("You need to specify a canvas element")}}()),i=r.getOptions(i);let a=r.getImageWidth(e.modules.size,i),d=s.getContext("2d"),l=d.createImageData(a,a);return r.qrToImageData(l.data,e,i),o=s,d.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=a,o.width=a,o.style.height=a+"px",o.style.width=a+"px",d.putImageData(l,0,0),s},t.renderToDataURL=function(e,n,r){let o=r;void 0!==o||n&&n.getContext||(o=n,n=void 0),o||(o={});let i=t.render(e,n,o),s=o.type||"image/png",a=o.rendererOpts||{};return i.toDataURL(s,a.quality)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js"(e,t,n){let r=n("fs"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png.js").O,i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js");t.render=function(e,t){let n=i.getOptions(t),r=n.rendererOpts,s=i.getImageWidth(e.modules.size,n);r.width=s,r.height=s;let a=new o(r);return i.qrToImageData(a.data,e,n),a},t.renderToDataURL=function(e,n,r){void 0===r&&(r=n,n=void 0),t.renderToBuffer(e,n,function(e,t){e&&r(e);let n="data:image/png;base64,";n+=t.toString("base64"),r(null,n)})},t.renderToBuffer=function(e,n,r){void 0===r&&(r=n,n=void 0);let o=t.render(e,n),i=[];o.on("error",r),o.on("data",function(e){i.push(e)}),o.on("end",function(){r(null,Buffer.concat(i))}),o.pack()},t.renderToFile=function(e,n,o,i){void 0===i&&(i=o,o=void 0);let s=!1,a=(...e)=>{s||(s=!0,i.apply(null,e))},d=r.createWriteStream(e);d.on("error",a),d.on("close",a),t.renderToFileStream(d,n,o)},t.renderToFileStream=function(e,n,r){t.render(n,r).pack().pipe(e)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js");function o(e,t){let n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function i(e,t,n){let r=e+t;return void 0!==n&&(r+=" "+n),r}t.render=function(e,t,n){let s=r.getOptions(t),a=e.modules.size,d=e.modules.data,l=a+2*s.margin,c=s.color.light.a?"<path "+o(s.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",u="<path "+o(s.color.dark,"stroke")+' d="'+function(e,t,n){let r="",o=0,s=!1,a=0;for(let d=0;d<e.length;d++){let l=Math.floor(d%t),c=Math.floor(d/t);l||s||(s=!0),e[d]?(a++,d>0&&l>0&&e[d-1]||(r+=s?i("M",l+n,.5+c+n):i("m",o,0),o=0,s=!1),l+1<t&&e[d+1]||(r+=i("h",a),a=0)):o++}return r}(d,a,s.margin)+'"/>',p='<svg xmlns="http://www.w3.org/2000/svg" '+(s.width?'width="'+s.width+'" height="'+s.width+'" ':"")+('viewBox="0 0 '+l+" ")+l+'" shape-rendering="crispEdges">'+c+u+"</svg>\n";return"function"==typeof n&&n(null,p),p}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"(e,t,n){t.render=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js").render,t.renderToFile=function(e,r,o,i){void 0===i&&(i=o,o=void 0);let s=n("fs"),a=t.render(r,o);s.writeFile(e,'<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'+a,i)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal-small.js");t.render=function(e,t,n){return t&&t.small?o.render(e,t,n):r.render(e,t,n)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal-small.js"(e,t){let n="\x1b[37m",r="\x1b[30m",o="\x1b[0m",i="\x1b[47m"+r,s="\x1b[40m"+n,a=function(e,t,n,r){let o=t+1;return n>=o||r>=o||r<-1||n<-1?"0":n>=t||r>=t||r<0||n<0?"1":e[r*t+n]?"2":"1"},d=function(e,t,n,r){return a(e,t,n,r)+a(e,t,n,r+1)};t.render=function(e,t,a){var l,c;let u=e.modules.size,p=e.modules.data,h=!!(t&&t.inverse),f=t&&t.inverse?s:i,m={"00":o+" "+f,"01":o+(l=h?r:n)+"▄"+f,"02":o+(c=h?n:r)+"▄"+f,10:o+l+"▀"+f,11:" ",12:"▄",20:o+c+"▀"+f,21:"▀",22:"█"},g=o+"\n"+f,_=f;for(let e=-1;e<u+1;e+=2){for(let t=-1;t<u;t++)_+=m[d(p,u,t,e)];_+=m[d(p,u,u,e)]+g}return _+=o,"function"==typeof a&&a(null,_),_}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal.js"(e,t){t.render=function(e,t,n){let r=e.modules.size,o=e.modules.data,i="\x1b[47m \x1b[0m",s="",a=Array(r+3).join(i),d=[,,].join(i);s+=a+"\n";for(let e=0;e<r;++e){s+=i;for(let t=0;t<r;t++)s+=o[e*r+t]?"\x1b[40m \x1b[0m":i;s+=d+"\n"}return s+=a+"\n","function"==typeof n&&n(null,s),s}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utf8.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js"),o={WW:" ",WB:"▄",BB:"█",BW:"▀"},i={BB:" ",BW:"▄",WW:"█",WB:"▀"};t.render=function(e,t,n){let s=r.getOptions(t),a=o;("#ffffff"===s.color.dark.hex||"#000000"===s.color.light.hex)&&(a=i);let d=e.modules.size,l=e.modules.data,c="",u=Array(d+2*s.margin+1).join(a.WW);u=Array(s.margin/2+1).join(u+"\n");let p=Array(s.margin+1).join(a.WW);c+=u;for(let e=0;e<d;e+=2){c+=p;for(let t=0;t<d;t++){var h;let n=l[e*d+t],r=l[(e+1)*d+t];c+=(h=a,n&&r?h.BB:n&&!r?h.BW:!n&&r?h.WB:h.WW)}c+=p+"\n"}return c+=u.slice(0,-1),"function"==typeof n&&n(null,c),c},t.renderToFile=function(e,r,o,i){void 0===i&&(i=o,o=void 0);let s=n("fs"),a=t.render(r,o);s.writeFile(e,a,i)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js"(e,t){function n(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw Error("Invalid hex color: "+e);(3===t.length||4===t.length)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");let n=parseInt(t.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+t.slice(0,6).join("")}}t.getOptions=function(e){e||(e={}),e.color||(e.color={});let t=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,o=e.scale||4;return{width:r,scale:r?4:o,margin:t,color:{dark:n(e.color.dark||"#000000ff"),light:n(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},t.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},t.getImageWidth=function(e,n){let r=t.getScale(e,n);return Math.floor((e+2*n.margin)*r)},t.qrToImageData=function(e,n,r){let o=n.modules.size,i=n.modules.data,s=t.getScale(o,r),a=Math.floor((o+2*r.margin)*s),d=r.margin*s,l=[r.color.light,r.color.dark];for(let t=0;t<a;t++)for(let n=0;n<a;n++){let c=(t*a+n)*4,u=r.color.light;t>=d&&n>=d&&t<a-d&&n<a-d&&(u=l[+!!i[Math.floor((t-d)/s)*o+Math.floor((n-d)/s)]]),e[c++]=u.r,e[c++]=u.g,e[c++]=u.b,e[c]=u.a}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/server.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utf8.js"),a=(n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal.js"),n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"));function d(e,t,n){if(void 0===e)throw Error("String required as first argument");if(void 0===n&&(n=t,t={}),"function"!=typeof n)if(r())t=n||{},n=null;else throw Error("Callback required as last argument");return{opts:t,cb:n}}function l(e){switch(e){case"svg":return a;case"txt":case"utf8":return s;default:return i}}function c(e,t,n){if(!n.cb)return new Promise(function(r,i){try{let s=o.create(t,n.opts);return e(s,n.opts,function(e,t){return e?i(e):r(t)})}catch(e){i(e)}});try{let r=o.create(t,n.opts);return e(r,n.opts,n.cb)}catch(e){n.cb(e)}}o.create,n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"),t.toBuffer=function(e,t,n){let r=d(e,t,n);return c(l(r.opts.type).renderToBuffer,e,r)},t.toFile=function(e,t,n,o){if("string"!=typeof e||"string"!=typeof t&&"object"!=typeof t)throw Error("Invalid argument");if(arguments.length<3&&!r())throw Error("Too few arguments provided");let i=d(t,n,o);return c(l(i.opts.type||e.slice((e.lastIndexOf(".")-1>>>0)+2).toLowerCase()).renderToFile.bind(null,e),t,i)}},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"(e,t,n){var r=n("node:os"),o=n("node:path");let i=o.join(r.homedir(),".dbx","token"),s=o.join(r.homedir(),".doubao","token"),a={};function d(e){Object.assign(a,e)}function l(e={}){let t={...a,...e},n=function(e,t){let n;try{n=new URL(c(e))}catch{throw Error(`${t} must be an absolute HTTPS URL`)}if("https:"!==n.protocol)throw Error(`${t} must use https`);return c(n.toString())}(t.baseUrl??"https://developer.doubao.com","baseUrl"),r=t.tokenPath??i;return{...t,baseUrl:n,allowedOrigins:function(e,t){let n=new Set([new URL(t).origin]);for(let t of e??[]){let e;try{e=new URL(t)}catch{throw Error(`allowedOrigins entries must be absolute HTTPS origins: ${t}`)}if("https:"!==e.protocol)throw Error(`allowedOrigins entries must use https: ${t}`);n.add(e.origin)}return[...n]}(t.allowedOrigins,n),tokenPath:r,legacyTokenPath:t.tokenPath?void 0:s,requestHeaders:new Headers(t.requestHeaders)}}function c(e){return e.replace(/\/+$/,"")}n.d(t,{$i:()=>l,ZI:()=>d},{E:"dbx-cli"})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/credential-store.js"(e,t,n){var r=n("node:child_process"),o=n("node:crypto"),i=n("node:fs"),s=n("node:os"),a=n("node:path");let d=(0,n("node:util").promisify)(r.execFile),l="byted-doubao-open-dbx-cli",c="dbx-cli",u="aes-256-gcm";class p extends Error{constructor(e){super(e),this.name="CredentialStoreError"}}function h(){let e=new m;return"darwin"===process.platform?new f(new g,e):"linux"===process.platform?new f(new _,e):e}class f{constructor(e,t){this.primary=e,this.fallback=t}async get(e){let t;try{let t=await this.primary.get(e);if(t)return t}catch(e){t=e}try{let t=await this.fallback.get(e);if(t)return t}catch(e){if(t)throw new p(`Failed to read token from system credential store (${A(t)}); encrypted-file fallback also failed: ${A(e)}`);throw e}if(t)throw t instanceof Error?t:new p(`Failed to read token from system credential store: ${String(t)}`)}async set(e,t){let n;try{await this.primary.set(e,t)}catch(e){n=e}try{await this.fallback.set(e,t)}catch(e){if(n)throw new p(`Failed to write token to system credential store (${A(n)}) and encrypted-file fallback (${A(e)})`);throw e}}async delete(e){let t;try{await this.primary.delete(e)}catch(e){t=e}try{await this.fallback.delete(e)}catch(e){if(t)throw new p(`Failed to delete token from system credential store (${A(t)}) and encrypted-file fallback (${A(e)})`);throw e}}}class m{constructor(e={}){this.baseDir=e.baseDir??("darwin"===process.platform?a.join(s.homedir(),"Library","Application Support",c):"win32"===process.platform?a.join(process.env.APPDATA||a.join(s.homedir(),"AppData","Roaming"),c):a.join(process.env.XDG_DATA_HOME||a.join(s.homedir(),".local","share"),c))}async get(e){var t,n;let r,s,a=this.credentialFilePath(e);try{r=await i.promises.readFile(a,"utf8")}catch(e){if(I(e)&&"ENOENT"===e.code)return;throw new p(`Failed to read encrypted token file: ${A(e)}`)}try{s=JSON.parse(r)}catch(e){throw new p(`Encrypted token file is not valid JSON: ${A(e)}`)}if(!((t=s)&&"object"==typeof t&&1===t.version&&t.algorithm===u&&"string"==typeof t.iv&&"string"==typeof t.authTag&&"string"==typeof t.ciphertext))throw new p("Encrypted token file has an unsupported format");let d=await this.readMasterKey();try{let t=o.createDecipheriv(u,d,Buffer.from(s.iv,"base64url"));return t.setAAD(Buffer.from((n=e,`${l}:${n}`),"utf8")),t.setAuthTag(Buffer.from(s.authTag,"base64url")),Buffer.concat([t.update(Buffer.from(s.ciphertext,"base64url")),t.final()]).toString("utf8")}catch(e){throw new p(`Failed to decrypt encrypted token file: ${A(e)}`)}}async set(e,t){var n;let r=await this.readOrCreateMasterKey(),i=o.randomBytes(12),s=o.createCipheriv(u,r,i);s.setAAD(Buffer.from((n=e,`${l}:${n}`),"utf8"));let a=Buffer.concat([s.update(t,"utf8"),s.final()]),d={version:1,algorithm:u,iv:i.toString("base64url"),authTag:s.getAuthTag().toString("base64url"),ciphertext:a.toString("base64url")};await w(this.credentialFilePath(e),`${JSON.stringify(d,null,2)}
9
+ 错误码:${e}`);let t=(null==p?void 0:p.message)||"Failed to get debug ticket";throw Error(`${t} (code=${e}, appKey=${u.appKey}, baseApiUrl=${u.baseApiUrl})`)}let h=String((null==(d=p.data)?void 0:d.debug_token)||"").trim(),f=String((null==(l=p.data)?void 0:l.encrypted_debug_payload)||"").trim();if(!h||!f)throw Error("Debug ticket response is missing required fields");return{qrCodeValue:JSON.stringify({action:t.REAL_DEVICE_DEBUG_QR_ACTION,debug_token:h,encrypted_debug_payload:f}),debugToken:h,encryptedDebugPayload:f}})}},"../../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js"(e){var t={single_source_shortest_paths:function(e,n,r){var o,i,s,a,d,l,c,u={},p={};p[n]=0;var h=t.PriorityQueue.make();for(h.push(n,0);!h.empty();)for(s in i=(o=h.pop()).value,a=o.cost,d=e[i]||{})d.hasOwnProperty(s)&&(l=a+d[s],c=p[s],(void 0===p[s]||c>l)&&(p[s]=l,h.push(s,l),u[s]=i));if(void 0!==r&&void 0===p[r])throw Error(["Could not find a path from ",n," to ",r,"."].join(""));return u},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,n,r){var o=t.single_source_shortest_paths(e,n,r);return t.extract_shortest_path_from_predecessor_list(o,r)},PriorityQueue:{make:function(e){var n,r=t.PriorityQueue,o={};for(n in e=e||{},r)r.hasOwnProperty(n)&&(o[n]=r[n]);return o.queue=[],o.sorter=e.sorter||r.default_sorter,o},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){this.queue.push({value:e,cost:t}),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitmapper.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/interlace.js"),o=[function(){},function(e,t,n,r){if(r===t.length)throw Error("Ran out of data");let o=t[r];e[n]=o,e[n+1]=o,e[n+2]=o,e[n+3]=255},function(e,t,n,r){if(r+1>=t.length)throw Error("Ran out of data");let o=t[r];e[n]=o,e[n+1]=o,e[n+2]=o,e[n+3]=t[r+1]},function(e,t,n,r){if(r+2>=t.length)throw Error("Ran out of data");e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=255},function(e,t,n,r){if(r+3>=t.length)throw Error("Ran out of data");e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=t[r+3]}],i=[function(){},function(e,t,n,r){let o=t[0];e[n]=o,e[n+1]=o,e[n+2]=o,e[n+3]=r},function(e,t,n){let r=t[0];e[n]=r,e[n+1]=r,e[n+2]=r,e[n+3]=t[1]},function(e,t,n,r){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=r},function(e,t,n){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=t[3]}];t.dataToBitMap=function(e,t){let n,s,a,d,l,c,u=t.width,p=t.height,h=t.depth,f=t.bpp,m=t.interlace;8!==h&&(n=[],s=0,a={get:function(t){for(;n.length<t;)!function(){let t,r,o,i;if(s===e.length)throw Error("Ran out of data");let a=e[s];switch(s++,h){default:throw Error("unrecognised depth");case 16:o=e[s],s++,n.push((a<<8)+o);break;case 4:o=15&a,i=a>>4,n.push(i,o);break;case 2:t=3&a,r=a>>2&3,o=a>>4&3,i=a>>6&3,n.push(i,o,r,t);break;case 1:t=a>>4&1,r=a>>5&1,o=a>>6&1,i=a>>7&1,n.push(i,o,r,t,a>>3&1,a>>2&1,a>>1&1,1&a)}}();let r=n.slice(0,t);return n=n.slice(t),r},resetAfterLine:function(){n.length=0},end:function(){if(s!==e.length)throw Error("extra data found")}}),d=h<=8?Buffer.alloc(u*p*4):new Uint16Array(u*p*4);let g=Math.pow(2,h)-1,_=0;if(m)l=r.getImagePasses(u,p),c=r.getInterlaceIterator(u,p);else{let e=0;c=function(){let t=e;return e+=4,t},l=[{width:u,height:p}]}for(let t=0;t<l.length;t++)8===h?_=function(e,t,n,r,i,s){let a=e.width,d=e.height,l=e.index;for(let e=0;e<d;e++)for(let d=0;d<a;d++){let a=n(d,e,l);o[r](t,i,a,s),s+=r}return s}(l[t],d,c,f,e,_):function(e,t,n,r,o,s){let a=e.width,d=e.height,l=e.index;for(let e=0;e<d;e++){for(let d=0;d<a;d++){let a=o.get(r),c=n(d,e,l);i[r](t,a,c,s)}o.resetAfterLine()}}(l[t],d,c,f,a,g);if(8===h){if(_!==e.length)throw Error("extra data found")}else a.end();return d}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitpacker.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js");e.exports=function(e,t,n,o){let i=-1!==[r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(o.colorType);if(o.colorType===o.inputColorType){let t,n=(new DataView(t=new ArrayBuffer(2)).setInt16(0,256,!0),256!==new Int16Array(t)[0]);if(8===o.bitDepth||16===o.bitDepth&&n)return e}let s=16!==o.bitDepth?e:new Uint16Array(e.buffer),a=255,d=r.COLORTYPE_TO_BPP_MAP[o.inputColorType];4!==d||o.inputHasAlpha||(d=3);let l=r.COLORTYPE_TO_BPP_MAP[o.colorType];16===o.bitDepth&&(a=65535,l*=2);let c=Buffer.alloc(t*n*l),u=0,p=0,h=o.bgColor||{};void 0===h.red&&(h.red=a),void 0===h.green&&(h.green=a),void 0===h.blue&&(h.blue=a);for(let e=0;e<n;e++)for(let e=0;e<t;e++){let e=function(){let e,t,n,d=a;switch(o.inputColorType){case r.COLORTYPE_COLOR_ALPHA:d=s[u+3],e=s[u],t=s[u+1],n=s[u+2];break;case r.COLORTYPE_COLOR:e=s[u],t=s[u+1],n=s[u+2];break;case r.COLORTYPE_ALPHA:d=s[u+1],t=e=s[u],n=e;break;case r.COLORTYPE_GRAYSCALE:t=e=s[u],n=e;break;default:throw Error("input color type:"+o.inputColorType+" is not supported at present")}return o.inputHasAlpha&&!i&&(d/=a,e=Math.min(Math.max(Math.round((1-d)*h.red+d*e),0),a),t=Math.min(Math.max(Math.round((1-d)*h.green+d*t),0),a),n=Math.min(Math.max(Math.round((1-d)*h.blue+d*n),0),a)),{red:e,green:t,blue:n,alpha:d}}();switch(o.colorType){case r.COLORTYPE_COLOR_ALPHA:case r.COLORTYPE_COLOR:8===o.bitDepth?(c[p]=e.red,c[p+1]=e.green,c[p+2]=e.blue,i&&(c[p+3]=e.alpha)):(c.writeUInt16BE(e.red,p),c.writeUInt16BE(e.green,p+2),c.writeUInt16BE(e.blue,p+4),i&&c.writeUInt16BE(e.alpha,p+6));break;case r.COLORTYPE_ALPHA:case r.COLORTYPE_GRAYSCALE:{let t=(e.red+e.green+e.blue)/3;8===o.bitDepth?(c[p]=t,i&&(c[p+1]=e.alpha)):(c.writeUInt16BE(t,p),i&&c.writeUInt16BE(e.alpha,p+2));break}default:throw Error("unrecognised color Type "+o.colorType)}u+=d,p+=l}return c}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/chunkstream.js"(e,t,n){let r=n("util"),o=n("stream"),i=e.exports=function(){o.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding="utf8",this.writable=!0};r.inherits(i,o),i.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick((function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit("drain"))}).bind(this))},i.prototype.write=function(e,t){let n;return this.writable?(n=Buffer.isBuffer(e)?e:Buffer.from(e,t||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&0===this._reads.length&&(this._paused=!0),this.writable&&!this._paused):(this.emit("error",Error("Stream not writable")),!1)},i.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(0===this._buffers.length?this._end():(this._buffers.push(null),this._process()))},i.prototype.destroySoon=i.prototype.end,i.prototype._end=function(){this._reads.length>0&&this.emit("error",Error("Unexpected end of input")),this.destroy()},i.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit("close"))},i.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))},i.prototype._processRead=function(e){this._reads.shift();let t=0,n=0,r=Buffer.alloc(e.length);for(;t<e.length;){let o=this._buffers[n++],i=Math.min(o.length,e.length-t);o.copy(r,t,0,i),t+=i,i!==o.length&&(this._buffers[--n]=o.slice(i))}n>0&&this._buffers.splice(0,n),this._buffered-=e.length,e.func.call(this,r)},i.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit("error",e)}}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"(e){e.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:0x49484452,TYPE_IEND:0x49454e44,TYPE_IDAT:0x49444154,TYPE_PLTE:0x504c5445,TYPE_tRNS:0x74524e53,TYPE_gAMA:0x67414d41,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/crc.js"(e){let t=[];for(let e=0;e<256;e++){let n=e;for(let e=0;e<8;e++)1&n?n=0xedb88320^n>>>1:n>>>=1;t[e]=n}let n=e.exports=function(){this._crc=-1};n.prototype.write=function(e){for(let n=0;n<e.length;n++)this._crc=t[(this._crc^e[n])&255]^this._crc>>>8;return!0},n.prototype.crc32=function(){return -1^this._crc},n.crc32=function(e){let n=-1;for(let r=0;r<e.length;r++)n=t[(n^e[r])&255]^n>>>8;return -1^n}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-pack.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/paeth-predictor.js"),o={0:function(e,t,n,r,o){for(let i=0;i<n;i++)r[o+i]=e[t+i]},1:function(e,t,n,r,o,i){for(let s=0;s<n;s++){let n=s>=i?e[t+s-i]:0,a=e[t+s]-n;r[o+s]=a}},2:function(e,t,n,r,o){for(let i=0;i<n;i++){let s=t>0?e[t+i-n]:0,a=e[t+i]-s;r[o+i]=a}},3:function(e,t,n,r,o,i){for(let s=0;s<n;s++){let a=s>=i?e[t+s-i]:0,d=t>0?e[t+s-n]:0,l=e[t+s]-(a+d>>1);r[o+s]=l}},4:function(e,t,n,o,i,s){for(let a=0;a<n;a++){let d=a>=s?e[t+a-s]:0,l=t>0?e[t+a-n]:0,c=t>0&&a>=s?e[t+a-(n+s)]:0,u=e[t+a]-r(d,l,c);o[i+a]=u}}},i={0:function(e,t,n){let r=0,o=t+n;for(let n=t;n<o;n++)r+=Math.abs(e[n]);return r},1:function(e,t,n,r){let o=0;for(let i=0;i<n;i++){let n=i>=r?e[t+i-r]:0;o+=Math.abs(e[t+i]-n)}return o},2:function(e,t,n){let r=0,o=t+n;for(let i=t;i<o;i++){let o=t>0?e[i-n]:0;r+=Math.abs(e[i]-o)}return r},3:function(e,t,n,r){let o=0;for(let i=0;i<n;i++){let s=i>=r?e[t+i-r]:0,a=t>0?e[t+i-n]:0;o+=Math.abs(e[t+i]-(s+a>>1))}return o},4:function(e,t,n,o){let i=0;for(let s=0;s<n;s++){let a=s>=o?e[t+s-o]:0,d=t>0?e[t+s-n]:0,l=t>0&&s>=o?e[t+s-(n+o)]:0;i+=Math.abs(e[t+s]-r(a,d,l))}return i}};e.exports=function(e,t,n,r,s){let a;if("filterType"in r&&-1!==r.filterType)if("number"==typeof r.filterType)a=[r.filterType];else throw Error("unrecognised filter types");else a=[0,1,2,3,4];16===r.bitDepth&&(s*=2);let d=t*s,l=0,c=0,u=Buffer.alloc((d+1)*n),p=a[0];for(let t=0;t<n;t++){if(a.length>1){let t=1/0;for(let n=0;n<a.length;n++){let r=i[a[n]](e,c,d,s);r<t&&(p=a[n],t=r)}}u[l]=p,l++,o[p](e,c,d,u,l,s),l+=d,c+=d}return u}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-async.js"(e,t,n){let r=n("util"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/chunkstream.js"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse.js"),s=e.exports=function(e){o.call(this);let t=[],n=this;this._filter=new i(e,{read:this.read.bind(this),write:function(e){t.push(e)},complete:function(){n.emit("complete",Buffer.concat(t))}}),this._filter.start()};r.inherits(s,o)},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-sync.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-reader.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse.js");t.process=function(e,t){let n=[],i=new r(e);return new o(t,{read:i.read.bind(i),write:function(e){n.push(e)},complete:function(){}}).start(),i.process(),Buffer.concat(n)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/interlace.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/paeth-predictor.js");function i(e,t,n){let r=e*t;return 8!==n&&(r=Math.ceil(r/(8/n))),r}let s=e.exports=function(e,t){let n=e.width,o=e.height,s=e.interlace,a=e.bpp,d=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],s){let e=r.getImagePasses(n,o);for(let t=0;t<e.length;t++)this._images.push({byteWidth:i(e[t].width,a,d),height:e[t].height,lineIndex:0})}else this._images.push({byteWidth:i(n,a,d),height:o,lineIndex:0});8===d?this._xComparison=a:16===d?this._xComparison=2*a:this._xComparison=1};s.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},s.prototype._unFilterType1=function(e,t,n){let r=this._xComparison,o=r-1;for(let i=0;i<n;i++){let n=e[1+i],s=i>o?t[i-r]:0;t[i]=n+s}},s.prototype._unFilterType2=function(e,t,n){let r=this._lastLine;for(let o=0;o<n;o++){let n=e[1+o],i=r?r[o]:0;t[o]=n+i}},s.prototype._unFilterType3=function(e,t,n){let r=this._xComparison,o=r-1,i=this._lastLine;for(let s=0;s<n;s++){let n=e[1+s],a=i?i[s]:0,d=Math.floor(((s>o?t[s-r]:0)+a)/2);t[s]=n+d}},s.prototype._unFilterType4=function(e,t,n){let r=this._xComparison,i=r-1,s=this._lastLine;for(let a=0;a<n;a++){let n=e[1+a],d=s?s[a]:0,l=o(a>i?t[a-r]:0,d,a>i&&s?s[a-r]:0);t[a]=n+l}},s.prototype._reverseFilterLine=function(e){let t,n=e[0],r=this._images[this._imageIndex],o=r.byteWidth;if(0===n)t=e.slice(1,o+1);else switch(t=Buffer.alloc(o),n){case 1:this._unFilterType1(e,t,o);break;case 2:this._unFilterType2(e,t,o);break;case 3:this._unFilterType3(e,t,o);break;case 4:this._unFilterType4(e,t,o);break;default:throw Error("Unrecognised filter type - "+n)}this.write(t),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=t,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/format-normaliser.js"(e){e.exports=function(e,t){let n=t.depth,r=t.width,o=t.height,i=t.colorType,s=t.transColor,a=t.palette,d=e;return 3===i?!function(e,t,n,r,o){let i=0;for(let s=0;s<r;s++)for(let r=0;r<n;r++){let n=o[e[i]];if(!n)throw Error("index "+e[i]+" not in palette");for(let e=0;e<4;e++)t[i+e]=n[e];i+=4}}(e,d,r,o,a):(s&&function(e,t,n,r,o){let i=0;for(let s=0;s<r;s++)for(let r=0;r<n;r++){let n=!1;if(1===o.length?o[0]===e[i]&&(n=!0):o[0]===e[i]&&o[1]===e[i+1]&&o[2]===e[i+2]&&(n=!0),n)for(let e=0;e<4;e++)t[i+e]=0;i+=4}}(e,d,r,o,s),8!==n&&(16===n&&(d=Buffer.alloc(r*o*4)),!function(e,t,n,r,o){let i=Math.pow(2,o)-1,s=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){for(let n=0;n<4;n++)t[s+n]=Math.floor(255*e[s+n]/i+.5);s+=4}}(e,d,r,o,n))),d}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/interlace.js"(e,t){let n=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];t.getImagePasses=function(e,t){let r=[],o=e%8,i=t%8,s=(e-o)/8,a=(t-i)/8;for(let e=0;e<n.length;e++){let t=n[e],d=s*t.x.length,l=a*t.y.length;for(let e=0;e<t.x.length;e++)if(t.x[e]<o)d++;else break;for(let e=0;e<t.y.length;e++)if(t.y[e]<i)l++;else break;d>0&&l>0&&r.push({width:d,height:l,index:e})}return r},t.getInterlaceIterator=function(e){return function(t,r,o){let i=t%n[o].x.length,s=(t-i)/n[o].x.length*8+n[o].x[i],a=r%n[o].y.length;return 4*s+((r-a)/n[o].y.length*8+n[o].y[a])*e*4}}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-async.js"(e,t,n){let r=n("util"),o=n("stream"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer.js"),a=e.exports=function(e){o.call(this),this._packer=new s(e||{}),this._deflate=this._packer.createDeflate(),this.readable=!0};r.inherits(a,o),a.prototype.pack=function(e,t,n,r){this.emit("data",Buffer.from(i.PNG_SIGNATURE)),this.emit("data",this._packer.packIHDR(t,n)),r&&this.emit("data",this._packer.packGAMA(r));let o=this._packer.filterData(e,t,n);this._deflate.on("error",this.emit.bind(this,"error")),this._deflate.on("data",(function(e){this.emit("data",this._packer.packIDAT(e))}).bind(this)),this._deflate.on("end",(function(){this.emit("data",this._packer.packIEND()),this.emit("end")}).bind(this)),this._deflate.end(o)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-sync.js"(e,t,n){let r=!0,o=n("zlib");o.deflateSync||(r=!1);let i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer.js");e.exports=function(e,t){if(!r)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let n=new s(t||{}),a=[];a.push(Buffer.from(i.PNG_SIGNATURE)),a.push(n.packIHDR(e.width,e.height)),e.gamma&&a.push(n.packGAMA(e.gamma));let d=n.filterData(e.data,e.width,e.height),l=o.deflateSync(d,n.getDeflateOptions());if(d=null,!l||!l.length)throw Error("bad png - invalid compressed data response");return a.push(n.packIDAT(l)),a.push(n.packIEND()),Buffer.concat(a)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/crc.js"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitpacker.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-pack.js"),a=n("zlib"),d=e.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32768,e.deflateLevel=null!=e.deflateLevel?e.deflateLevel:9,e.deflateStrategy=null!=e.deflateStrategy?e.deflateStrategy:3,e.inputHasAlpha=null==e.inputHasAlpha||e.inputHasAlpha,e.deflateFactory=e.deflateFactory||a.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType="number"==typeof e.colorType?e.colorType:r.COLORTYPE_COLOR_ALPHA,e.inputColorType="number"==typeof e.inputColorType?e.inputColorType:r.COLORTYPE_COLOR_ALPHA,-1===[r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.colorType))throw Error("option color type:"+e.colorType+" is not supported at present");if(-1===[r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.inputColorType))throw Error("option input color type:"+e.inputColorType+" is not supported at present");if(8!==e.bitDepth&&16!==e.bitDepth)throw Error("option bit depth:"+e.bitDepth+" is not supported at present")};d.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},d.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},d.prototype.filterData=function(e,t,n){let o=i(e,t,n,this._options),a=r.COLORTYPE_TO_BPP_MAP[this._options.colorType];return s(o,t,n,this._options,a)},d.prototype._packChunk=function(e,t){let n=t?t.length:0,r=Buffer.alloc(n+12);return r.writeUInt32BE(n,0),r.writeUInt32BE(e,4),t&&t.copy(r,8),r.writeInt32BE(o.crc32(r.slice(4,r.length-4)),r.length-4),r},d.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*r.GAMMA_DIVISION),0),this._packChunk(r.TYPE_gAMA,t)},d.prototype.packIHDR=function(e,t){let n=Buffer.alloc(13);return n.writeUInt32BE(e,0),n.writeUInt32BE(t,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(r.TYPE_IHDR,n)},d.prototype.packIDAT=function(e){return this._packChunk(r.TYPE_IDAT,e)},d.prototype.packIEND=function(){return this._packChunk(r.TYPE_IEND,null)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/paeth-predictor.js"(e){e.exports=function(e,t,n){let r=e+t-n,o=Math.abs(r-e),i=Math.abs(r-t),s=Math.abs(r-n);return o<=i&&o<=s?e:i<=s?t:n}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-async.js"(e,t,n){let r=n("util"),o=n("zlib"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/chunkstream.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-async.js"),a=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser.js"),d=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitmapper.js"),l=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/format-normaliser.js"),c=e.exports=function(e){i.call(this),this._parser=new a(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,"gamma"),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};r.inherits(c,i),c.prototype._handleError=function(e){this.emit("error",e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on("error",function(){})),this.errord=!0},c.prototype._inflateData=function(e){if(!this._inflate)if(this._bitmapInfo.interlace)this._inflate=o.createInflate(),this._inflate.on("error",this.emit.bind(this,"error")),this._filter.on("complete",this._complete.bind(this)),this._inflate.pipe(this._filter);else{let e=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,t=Math.max(e,o.Z_MIN_CHUNK);this._inflate=o.createInflate({chunkSize:t});let n=e,r=this.emit.bind(this,"error");this._inflate.on("error",function(e){n&&r(e)}),this._filter.on("complete",this._complete.bind(this));let i=this._filter.write.bind(this._filter);this._inflate.on("data",function(e){n&&(e.length>n&&(e=e.slice(0,n)),n-=e.length,i(e))}),this._inflate.on("end",this._filter.end.bind(this._filter))}this._inflate.write(e)},c.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new s(this._bitmapInfo)},c.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e},c.prototype._handlePalette=function(e){this._bitmapInfo.palette=e},c.prototype._simpleTransparency=function(){this._metaData.alpha=!0},c.prototype._headersFinished=function(){this.emit("metadata",this._metaData)},c.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit("error","No Inflate block"))},c.prototype._complete=function(e){let t;if(!this.errord){try{let n=d.dataToBitMap(e,this._bitmapInfo);t=l(n,this._bitmapInfo),n=null}catch(e){this._handleError(e);return}this.emit("parsed",t)}}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-sync.js"(e,t,n){let r=!0,o=n("zlib"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-inflate.js");o.deflateSync||(r=!1);let s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-reader.js"),a=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/filter-parse-sync.js"),d=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser.js"),l=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/bitmapper.js"),c=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/format-normaliser.js");e.exports=function(e,t){let n,u,p,h;if(!r)throw Error("To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0");let f=[],m=new s(e);if(new d(t,{read:m.read.bind(m),error:function(e){n=e},metadata:function(e){u=e},gamma:function(e){p=e},palette:function(e){u.palette=e},transColor:function(e){u.transColor=e},inflateData:function(e){f.push(e)},simpleTransparency:function(){u.alpha=!0}}).start(),m.process(),n)throw n;let g=Buffer.concat(f);if(f.length=0,u.interlace)h=o.inflateSync(g);else{let e=((u.width*u.bpp*u.depth+7>>3)+1)*u.height;h=i(g,{chunkSize:e,maxLength:e})}if(g=null,!h||!h.length)throw Error("bad png - invalid inflate data response");let _=a.process(h,u);g=null;let w=l.dataToBitMap(_,u);_=null;let y=c(w,u);return u.data=y,u.gamma=p||0,u}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/constants.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/crc.js"),i=e.exports=function(e,t){this._options=e,e.checkCRC=!1!==e.checkCRC,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[r.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[r.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[r.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[r.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[r.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[r.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};i.prototype.start=function(){this.read(r.PNG_SIGNATURE.length,this._parseSignature.bind(this))},i.prototype._parseSignature=function(e){let t=r.PNG_SIGNATURE;for(let n=0;n<t.length;n++)if(e[n]!==t[n])return void this.error(Error("Invalid file signature"));this.read(8,this._parseChunkBegin.bind(this))},i.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),n=e.readUInt32BE(4),i="";for(let t=4;t<8;t++)i+=String.fromCharCode(e[t]);let s=!!(32&e[4]);return this._hasIHDR||n===r.TYPE_IHDR?(this._crc=new o,this._crc.write(Buffer.from(i)),this._chunks[n])?this._chunks[n](t):s?void this.read(t+4,this._skipChunk.bind(this)):void this.error(Error("Unsupported critical chunk type "+i)):void this.error(Error("Expected IHDR on beggining"))},i.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},i.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),n=this._crc.crc32();this._options.checkCRC&&n!==t?this.error(Error("Crc error - "+t+" - "+n)):this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))},i.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),n=e.readUInt32BE(4),o=e[8],i=e[9],s=e[10],a=e[11],d=e[12];if(8!==o&&4!==o&&2!==o&&1!==o&&16!==o)return void this.error(Error("Unsupported bit depth "+o));if(!(i in r.COLORTYPE_TO_BPP_MAP))return void this.error(Error("Unsupported color type"));if(0!==s)return void this.error(Error("Unsupported compression method"));if(0!==a)return void this.error(Error("Unsupported filter method"));if(0!==d&&1!==d)return void this.error(Error("Unsupported interlace method"));this._colorType=i;let l=r.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:n,depth:o,interlace:!!d,palette:!!(i&r.COLORTYPE_PALETTE),color:!!(i&r.COLORTYPE_COLOR),alpha:!!(i&r.COLORTYPE_ALPHA),bpp:l,colorType:i}),this._handleChunkEnd()},i.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))},i.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let n=0;n<t;n++)this._palette.push([e[3*n],e[3*n+1],e[3*n+2],255]);this.palette(this._palette),this._handleChunkEnd()},i.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))},i.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===r.COLORTYPE_PALETTE_COLOR){if(0===this._palette.length)return void this.error(Error("Transparency chunk must be after palette"));if(e.length>this._palette.length)return void this.error(Error("More transparent colors than palette size"));for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===r.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===r.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()},i.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))},i.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/r.GAMMA_DIVISION),this._handleChunkEnd()},i.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))},i.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===r.COLORTYPE_PALETTE_COLOR&&0===this._palette.length)throw Error("Expected palette not found");this.inflateData(t);let n=e-t.length;n>0?this._handleIDAT(n):this._handleChunkEnd()},i.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))},i.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png-sync.js"(e,t,n){let r=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-sync.js"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-sync.js");t.read=function(e,t){return r(e,t||{})},t.write=function(e,t){return o(e,t)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png.js"(e,t,n){let r=n("util"),o=n("stream"),i=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/parser-async.js"),s=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/packer-async.js"),a=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png-sync.js"),d=t.O=function(e){o.call(this),e=e||{},this.width=0|e.width,this.height=0|e.height,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new i(e),this._parser.on("error",this.emit.bind(this,"error")),this._parser.on("close",this._handleClose.bind(this)),this._parser.on("metadata",this._metadata.bind(this)),this._parser.on("gamma",this._gamma.bind(this)),this._parser.on("parsed",(function(e){this.data=e,this.emit("parsed",e)}).bind(this)),this._packer=new s(e),this._packer.on("data",this.emit.bind(this,"data")),this._packer.on("end",this.emit.bind(this,"end")),this._parser.on("close",this._handleClose.bind(this)),this._packer.on("error",this.emit.bind(this,"error"))};r.inherits(d,o),d.sync=a,d.prototype.pack=function(){return this.data&&this.data.length?process.nextTick((function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}).bind(this)):this.emit("error","No data provided"),this},d.prototype.parse=function(e,t){if(t){let e,n;e=(function(e){this.removeListener("error",n),this.data=e,t(null,this)}).bind(this),n=(function(n){this.removeListener("parsed",e),t(n,null)}).bind(this),this.once("parsed",e),this.once("error",n)}return this.end(e),this},d.prototype.write=function(e){return this._parser.write(e),!0},d.prototype.end=function(e){this._parser.end(e)},d.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit("metadata",e)},d.prototype._gamma=function(e){this.gamma=e},d.prototype._handleClose=function(){this._parser.writable||this._packer.readable||this.emit("close")},d.bitblt=function(e,t,n,r,o,i,s,a){if(r|=0,o|=0,i|=0,s|=0,a|=0,(n|=0)>e.width||r>e.height||n+o>e.width||r+i>e.height)throw Error("bitblt reading outside image");if(s>t.width||a>t.height||s+o>t.width||a+i>t.height)throw Error("bitblt writing outside image");for(let d=0;d<i;d++)e.data.copy(t.data,(a+d)*t.width+s<<2,(r+d)*e.width+n<<2,(r+d)*e.width+n+o<<2)},d.prototype.bitblt=function(e,t,n,r,o,i,s){return d.bitblt(this,e,t,n,r,o,i,s),this},d.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++){let r=e.width*t+n<<2;for(let t=0;t<3;t++){let n=e.data[r+t]/255;n=Math.pow(n,1/2.2/e.gamma),e.data[r+t]=Math.round(255*n)}}e.gamma=0}},d.prototype.adjustGamma=function(){d.adjustGamma(this)}},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-inflate.js"(e,t,n){let r=n("assert").ok,o=n("zlib"),i=n("util"),s=n("buffer").kMaxLength;function a(e){if(!(this instanceof a))return new a(e);e&&e.chunkSize<o.Z_MIN_CHUNK&&(e.chunkSize=o.Z_MIN_CHUNK),o.Inflate.call(this,e),this._offset=void 0===this._offset?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&null!=e.maxLength&&(this._maxLength=e.maxLength)}function d(e,t){t&&process.nextTick(t),e._handle&&(e._handle.close(),e._handle=null)}function l(e,t){var n=new a(t),r=e;if("string"==typeof r&&(r=Buffer.from(r)),!(r instanceof Buffer))throw TypeError("Not a string or buffer");let i=n._finishFlushFlag;return null==i&&(i=o.Z_FINISH),n._processChunk(r,i)}a.prototype._processChunk=function(e,t,n){let i,a;if("function"==typeof n)return o.Inflate._processChunk.call(this,e,t,n);let l=this,c=e&&e.length,u=this._chunkSize-this._offset,p=this._maxLength,h=0,f=[],m=0;this.on("error",function(e){i=e}),r(this._handle,"zlib binding closed");do a=(a=this._handle.writeSync(t,e,h,c,this._buffer,this._offset,u))||this._writeState;while(!this._hadError&&function(e,t){if(l._hadError)return;let n=u-t;if(r(n>=0,"have should not go down"),n>0){let e=l._buffer.slice(l._offset,l._offset+n);if(l._offset+=n,e.length>p&&(e=e.slice(0,p)),f.push(e),m+=e.length,0==(p-=e.length))return!1}return(0===t||l._offset>=l._chunkSize)&&(u=l._chunkSize,l._offset=0,l._buffer=Buffer.allocUnsafe(l._chunkSize)),0===t&&(h+=c-e,c=e,!0)}(a[0],a[1]));if(this._hadError)throw i;if(m>=s)throw d(this),RangeError("Cannot create final Buffer. It would be larger than 0x"+s.toString(16)+" bytes");let g=Buffer.concat(f,m);return d(this),g},i.inherits(a,o.Inflate),e.exports=t=l,t.Inflate=a,t.createInflate=function(e){return new a(e)},t.inflateSync=l},"../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/sync-reader.js"(e){let t=e.exports=function(e){this._buffer=e,this._reads=[]};t.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})},t.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}return this._reads.length>0?Error("There are some read requests waitng on finished stream"):this._buffer.length>0?Error("unrecognised content at end of stream"):void 0}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js");function a(e,t,n,i,s){let a=[].slice.call(arguments,1),d=a.length,l="function"==typeof a[d-1];if(!l&&!r())throw Error("Callback required as last argument");if(l){if(d<2)throw Error("Too few arguments provided");2===d?(s=n,n=t,t=i=void 0):3===d&&(t.getContext&&void 0===s?(s=i,i=void 0):(s=i,i=n,n=t,t=void 0))}else{if(d<1)throw Error("Too few arguments provided");return 1===d?(n=t,t=i=void 0):2!==d||t.getContext||(i=n,n=t,t=void 0),new Promise(function(r,s){try{let s=o.create(n,i);r(e(s,t,i))}catch(e){s(e)}})}try{let r=o.create(n,i);s(null,e(r,t,i))}catch(e){s(e)}}o.create,a.bind(null,i.render),a.bind(null,i.renderToDataURL),a.bind(null,function(e,t,n){return s.render(e,n)})},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"(e){e.exports=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js").getSymbolSize;t.getRowColCoords=function(e){if(1===e)return[];let t=Math.floor(e/7)+2,n=r(e),o=145===n?26:2*Math.ceil((n-13)/(2*t-2)),i=[n-7];for(let e=1;e<t-1;e++)i[e]=i[e-1]-o;return i.push(6),i.reverse()},t.getPositions=function(e){let n=[],r=t.getRowColCoords(e),o=r.length;for(let e=0;e<o;e++)for(let t=0;t<o;t++)(0!==e||0!==t)&&(0!==e||t!==o-1)&&(e!==o-1||0!==t)&&n.push([r[e],r[t]]);return n}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),o=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(e){this.mode=r.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=45*o.indexOf(this.data[t]);n+=o.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(o.indexOf(this.data[t]),6)},e.exports=i},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js"(e){function t(){this.buffer=[],this.length=0}t.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},e.exports=t},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js"(e){function t(e){if(!e||e<1)throw Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}t.prototype.set=function(e,t,n,r){let o=e*this.size+t;this.data[o]=n,r&&(this.reservedBit[o]=!0)},t.prototype.get=function(e,t){return this.data[e*this.size+t]},t.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},t.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},e.exports=t},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js");function o(e){this.mode=r.BYTE,"string"==typeof e?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}o.getBitsLength=function(e){return 8*e},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},e.exports=o},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"),o=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];t.getBlocksCount=function(e,t){switch(t){case r.L:return o[(e-1)*4+0];case r.M:return o[(e-1)*4+1];case r.Q:return o[(e-1)*4+2];case r.H:return o[(e-1)*4+3];default:return}},t.getTotalCodewordsCount=function(e,t){switch(t){case r.L:return i[(e-1)*4+0];case r.M:return i[(e-1)*4+1];case r.Q:return i[(e-1)*4+2];case r.H:return i[(e-1)*4+3];default:return}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"(e,t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2},t.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},t.from=function(e,n){if(t.isValid(e))return e;try{if("string"!=typeof e)throw Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw Error("Unknown EC Level: "+e)}}catch(e){return n}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js").getSymbolSize;t.getPositions=function(e){let t=r(e);return[[0,0],[t-7,0],[0,t-7]]}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),o=r.getBCHDigit(1335);t.getEncodedBits=function(e,t){let n=e.bit<<3|t,i=n<<10;for(;r.getBCHDigit(i)-o>=0;)i^=1335<<r.getBCHDigit(i)-o;return(n<<10|i)^21522}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js"(e,t){let n=new Uint8Array(512),r=new Uint8Array(256),o=1;for(let e=0;e<255;e++)n[e]=o,r[o]=e,256&(o<<=1)&&(o^=285);for(let e=255;e<512;e++)n[e]=n[e-255];t.exp=function(e){return n[e]},t.mul=function(e,t){return 0===e||0===t?0:n[r[e]+r[t]]}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js");function i(e){this.mode=r.KANJI,this.data=e}i.getBitsLength=function(e){return 13*e},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=o.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");n=(n>>>8&255)*192+(255&n),e.put(n,13)}},e.exports=i},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js"(e,t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};t.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},t.from=function(e){return t.isValid(e)?parseInt(e,10):void 0},t.getPenaltyN1=function(e){let t=e.size,n=0,r=0,o=0,i=null,s=null;for(let a=0;a<t;a++){r=o=0,i=s=null;for(let d=0;d<t;d++){let t=e.get(a,d);t===i?r++:(r>=5&&(n+=3+(r-5)),i=t,r=1),(t=e.get(d,a))===s?o++:(o>=5&&(n+=3+(o-5)),s=t,o=1)}r>=5&&(n+=3+(r-5)),o>=5&&(n+=3+(o-5))}return n},t.getPenaltyN2=function(e){let t=e.size,n=0;for(let r=0;r<t-1;r++)for(let o=0;o<t-1;o++){let t=e.get(r,o)+e.get(r,o+1)+e.get(r+1,o)+e.get(r+1,o+1);(4===t||0===t)&&n++}return 3*n},t.getPenaltyN3=function(e){let t=e.size,n=0,r=0,o=0;for(let i=0;i<t;i++){r=o=0;for(let s=0;s<t;s++)r=r<<1&2047|e.get(i,s),s>=10&&(1488===r||93===r)&&n++,o=o<<1&2047|e.get(s,i),s>=10&&(1488===o||93===o)&&n++}return 40*n},t.getPenaltyN4=function(e){let t=0,n=e.data.length;for(let r=0;r<n;r++)t+=e.data[r];return 10*Math.abs(Math.ceil(100*t/n/5)-10)},t.applyMask=function(e,n){let r=n.size;for(let o=0;o<r;o++)for(let i=0;i<r;i++)n.isReserved(i,o)||n.xor(i,o,function(e,n,r){switch(e){case t.Patterns.PATTERN000:return(n+r)%2==0;case t.Patterns.PATTERN001:return n%2==0;case t.Patterns.PATTERN010:return r%3==0;case t.Patterns.PATTERN011:return(n+r)%3==0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case t.Patterns.PATTERN101:return n*r%2+n*r%3==0;case t.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case t.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error("bad maskPattern:"+e)}}(e,i,o))},t.getBestMask=function(e,n){let r=Object.keys(t.Patterns).length,o=0,i=1/0;for(let s=0;s<r;s++){n(s),t.applyMask(s,e);let r=t.getPenaltyN1(e)+t.getPenaltyN2(e)+t.getPenaltyN3(e)+t.getPenaltyN4(e);t.applyMask(s,e),r<i&&(i=r,o=s)}return o}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js");t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(e,t){if(!e.ccBits)throw Error("Invalid mode: "+e);if(!r.isValid(t))throw Error("Invalid version: "+t);return t>=1&&t<10?e.ccBits[0]:t<27?e.ccBits[1]:e.ccBits[2]},t.getBestModeForData=function(e){return o.testNumeric(e)?t.NUMERIC:o.testAlphanumeric(e)?t.ALPHANUMERIC:o.testKanji(e)?t.KANJI:t.BYTE},t.toString=function(e){if(e&&e.id)return e.id;throw Error("Invalid mode")},t.isValid=function(e){return e&&e.bit&&e.ccBits},t.from=function(e,n){if(t.isValid(e))return e;try{if("string"!=typeof e)throw Error("Param is not a string");switch(e.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw Error("Unknown mode: "+e)}}catch(e){return n}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js");function o(e){this.mode=r.NUMERIC,this.data=e.toString()}o.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(e){let t,n;for(t=0;t+3<=this.data.length;t+=3)n=parseInt(this.data.substr(t,3),10),e.put(n,10);let r=this.data.length-t;r>0&&(n=parseInt(this.data.substr(t),10),e.put(n,3*r+1))},e.exports=o},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js");t.mul=function(e,t){let n=new Uint8Array(e.length+t.length-1);for(let o=0;o<e.length;o++)for(let i=0;i<t.length;i++)n[o+i]^=r.mul(e[o],t[i]);return n},t.mod=function(e,t){let n=new Uint8Array(e);for(;n.length-t.length>=0;){let e=n[0];for(let o=0;o<t.length;o++)n[o]^=r.mul(t[o],e);let o=0;for(;o<n.length&&0===n[o];)o++;n=n.slice(o)}return n},t.generateECPolynomial=function(e){let n=new Uint8Array([1]);for(let o=0;o<e;o++)n=t.mul(n,new Uint8Array([1,r.exp(o)]));return n}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js"),a=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js"),d=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js"),l=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js"),c=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"),u=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js"),p=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js"),h=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js"),f=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),m=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js");function g(e,t,n){let r,o,i=e.size,s=h.getEncodedBits(t,n);for(r=0;r<15;r++)o=(s>>r&1)==1,r<6?e.set(r,8,o,!0):r<8?e.set(r+1,8,o,!0):e.set(i-15+r,8,o,!0),r<8?e.set(8,i-r-1,o,!0):r<9?e.set(8,15-r-1+1,o,!0):e.set(8,15-r-1,o,!0);e.set(i-8,8,1,!0)}t.create=function(e,t){let n,h;if(void 0===e||""===e)throw Error("No input text");let _=o.M;return void 0!==t&&(_=o.from(t.errorCorrectionLevel,o.M),n=p.from(t.version),h=l.from(t.maskPattern),t.toSJISFunc&&r.setToSJISFunction(t.toSJISFunc)),function(e,t,n,o){let h;if(Array.isArray(e))h=m.fromArray(e);else if("string"==typeof e){let r=t;if(!r){let t=m.rawSplit(e);r=p.getBestVersionForData(t,n)}h=m.fromString(e,r||40)}else throw Error("Invalid data");let _=p.getBestVersionForData(h,n);if(!_)throw Error("The amount of data is too big to be stored in a QR Code");if(t){if(t<_)throw Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+_+".\n")}else t=_;let w=function(e,t,n){let o=new i;n.forEach(function(t){o.put(t.mode.bit,4),o.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(o)});let s=(r.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,t))*8;for(o.getLengthInBits()+4<=s&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(0);let a=(s-o.getLengthInBits())/8;for(let e=0;e<a;e++)o.put(e%2?17:236,8);return function(e,t,n){let o,i,s=r.getSymbolTotalCodewords(t),a=s-c.getTotalCodewordsCount(t,n),d=c.getBlocksCount(t,n),l=s%d,p=d-l,h=Math.floor(s/d),f=Math.floor(a/d),m=f+1,g=h-f,_=new u(g),w=0,y=Array(d),b=Array(d),v=0,E=new Uint8Array(e.buffer);for(let e=0;e<d;e++){let t=e<p?f:m;y[e]=E.slice(w,w+t),b[e]=_.encode(y[e]),w+=t,v=Math.max(v,t)}let I=new Uint8Array(s),A=0;for(o=0;o<v;o++)for(i=0;i<d;i++)o<y[i].length&&(I[A++]=y[i][o]);for(o=0;o<g;o++)for(i=0;i<d;i++)I[A++]=b[i][o];return I}(o,e,t)}(t,n,h),y=new s(r.getSymbolSize(t));!function(e,t){let n=e.size,r=d.getPositions(t);for(let t=0;t<r.length;t++){let o=r[t][0],i=r[t][1];for(let t=-1;t<=7;t++)if(!(o+t<=-1)&&!(n<=o+t))for(let r=-1;r<=7;r++)i+r<=-1||n<=i+r||(t>=0&&t<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===t||6===t)||t>=2&&t<=4&&r>=2&&r<=4?e.set(o+t,i+r,!0,!0):e.set(o+t,i+r,!1,!0))}}(y,t);let b=y.size;for(let e=8;e<b-8;e++){let t=e%2==0;y.set(e,6,t,!0),y.set(6,e,t,!0)}return!function(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],o=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)-2===t||2===t||-2===n||2===n||0===t&&0===n?e.set(r+t,o+n,!0,!0):e.set(r+t,o+n,!1,!0)}}(y,t),g(y,n,0),t>=7&&function(e,t){let n,r,o,i=e.size,s=p.getEncodedBits(t);for(let t=0;t<18;t++)n=Math.floor(t/3),r=t%3+i-8-3,o=(s>>t&1)==1,e.set(n,r,o,!0),e.set(r,n,o,!0)}(y,t),!function(e,t){let n=e.size,r=-1,o=n-1,i=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!e.isReserved(o,a-n)){let r=!1;s<t.length&&(r=(t[s]>>>i&1)==1),e.set(o,a-n,r),-1==--i&&(s++,i=7)}if((o+=r)<0||n<=o){o-=r,r=-r;break}}}(y,w),isNaN(o)&&(o=l.getBestMask(y,g.bind(null,y,n))),l.applyMask(o,y),g(y,n,o),{modules:y,version:t,errorCorrectionLevel:n,maskPattern:o,segments:h}}(e,n,_,h)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js");function o(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}o.prototype.initialize=function(e){this.degree=e,this.genPoly=r.generateECPolynomial(this.degree)},o.prototype.encode=function(e){if(!this.genPoly)throw Error("Encoder not initialized");let t=new Uint8Array(e.length+this.degree);t.set(e);let n=r.mod(t,this.genPoly),o=this.degree-n.length;if(o>0){let e=new Uint8Array(this.degree);return e.set(n,o),e}return n},e.exports=o},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"(e,t){let n="[0-9]+",r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",o="(?:(?![A-Z0-9 $%*+\\-./:]|"+(r=r.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";t.KANJI=RegExp(r,"g"),t.BYTE_KANJI=RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),t.BYTE=RegExp(o,"g"),t.NUMERIC=RegExp(n,"g"),t.ALPHANUMERIC=RegExp("[A-Z $%*+\\-./:]+","g");let i=RegExp("^"+r+"$"),s=RegExp("^"+n+"$"),a=RegExp("^[A-Z0-9 $%*+\\-./:]+$");t.testKanji=function(e){return i.test(e)},t.testNumeric=function(e){return s.test(e)},t.testAlphanumeric=function(e){return a.test(e)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js"),a=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js"),d=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js"),l=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),c=n("../../../node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js");function u(e){return unescape(encodeURIComponent(e)).length}function p(e,t,n){let r,o=[];for(;null!==(r=e.exec(n));)o.push({data:r[0],index:r.index,mode:t,length:r[0].length});return o}function h(e){let t,n,o=p(d.NUMERIC,r.NUMERIC,e),i=p(d.ALPHANUMERIC,r.ALPHANUMERIC,e);return l.isKanjiModeEnabled()?(t=p(d.BYTE,r.BYTE,e),n=p(d.KANJI,r.KANJI,e)):(t=p(d.BYTE_KANJI,r.BYTE,e),n=[]),o.concat(i,t,n).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,t){switch(t){case r.NUMERIC:return o.getBitsLength(e);case r.ALPHANUMERIC:return i.getBitsLength(e);case r.KANJI:return a.getBitsLength(e);case r.BYTE:return s.getBitsLength(e)}}function m(e,t){let n,d=r.getBestModeForData(e);if((n=r.from(t,d))!==r.BYTE&&n.bit<d.bit)throw Error('"'+e+'" cannot be encoded with mode '+r.toString(n)+".\n Suggested mode is: "+r.toString(d));switch(n===r.KANJI&&!l.isKanjiModeEnabled()&&(n=r.BYTE),n){case r.NUMERIC:return new o(e);case r.ALPHANUMERIC:return new i(e);case r.KANJI:return new a(e);case r.BYTE:return new s(e)}}t.fromArray=function(e){return e.reduce(function(e,t){return"string"==typeof t?e.push(m(t,null)):t.data&&e.push(m(t.data,t.mode)),e},[])},t.fromString=function(e,n){let o=function(e,t){let n={},o={start:{}},i=["start"];for(let s=0;s<e.length;s++){let a=e[s],d=[];for(let e=0;e<a.length;e++){let l=a[e],c=""+s+e;d.push(c),n[c]={node:l,lastCount:0},o[c]={};for(let e=0;e<i.length;e++){let s=i[e];n[s]&&n[s].node.mode===l.mode?(o[s][c]=f(n[s].lastCount+l.length,l.mode)-f(n[s].lastCount,l.mode),n[s].lastCount+=l.length):(n[s]&&(n[s].lastCount=l.length),o[s][c]=f(l.length,l.mode)+4+r.getCharCountIndicator(l.mode,t))}}i=d}for(let e=0;e<i.length;e++)o[i[e]].end=0;return{map:o,table:n}}(function(e){let t=[];for(let n=0;n<e.length;n++){let o=e[n];switch(o.mode){case r.NUMERIC:t.push([o,{data:o.data,mode:r.ALPHANUMERIC,length:o.length},{data:o.data,mode:r.BYTE,length:o.length}]);break;case r.ALPHANUMERIC:t.push([o,{data:o.data,mode:r.BYTE,length:o.length}]);break;case r.KANJI:t.push([o,{data:o.data,mode:r.BYTE,length:u(o.data)}]);break;case r.BYTE:t.push([{data:o.data,mode:r.BYTE,length:u(o.data)}])}}return t}(h(e,l.isKanjiModeEnabled())),n),i=c.find_path(o.map,"start","end"),s=[];for(let e=1;e<i.length-1;e++)s.push(o.table[i[e]].node);return t.fromArray(s.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?e[e.length-1].data+=t.data:e.push(t),e},[]))},t.rawSplit=function(e){return t.fromArray(h(e,l.isKanjiModeEnabled()))}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"(e,t){let n,r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];t.getSymbolSize=function(e){if(!e)throw Error('"version" cannot be null or undefined');if(e<1||e>40)throw Error('"version" should be in range from 1 to 40');return 4*e+17},t.getSymbolTotalCodewords=function(e){return r[e]},t.getBCHDigit=function(e){let t=0;for(;0!==e;)t++,e>>>=1;return t},t.setToSJISFunction=function(e){if("function"!=typeof e)throw Error('"toSJISFunc" is not a valid function.');n=e},t.isKanjiModeEnabled=function(){return void 0!==n},t.toSJIS=function(e){return n(e)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"(e,t){t.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js"),a=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js"),d=r.getBCHDigit(7973);function l(e,t){return s.getCharCountIndicator(e,t)+4}t.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},t.getCapacity=function(e,t,n){if(!a.isValid(e))throw Error("Invalid QR Code version");void 0===n&&(n=s.BYTE);let i=(r.getSymbolTotalCodewords(e)-o.getTotalCodewordsCount(e,t))*8;if(n===s.MIXED)return i;let d=i-l(n,e);switch(n){case s.NUMERIC:return Math.floor(d/10*3);case s.ALPHANUMERIC:return Math.floor(d/11*2);case s.KANJI:return Math.floor(d/13);case s.BYTE:default:return Math.floor(d/8)}},t.getBestVersionForData=function(e,n){let r,o=i.from(n,i.M);if(Array.isArray(e)){if(e.length>1){for(let n=1;n<=40;n++)if(function(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}(e,n)<=t.getCapacity(n,o,s.MIXED))return n;return}if(0===e.length)return 1;r=e[0]}else r=e;return function(e,n,r){for(let o=1;o<=40;o++)if(n<=t.getCapacity(o,r,e))return o}(r.mode,r.getLength(),o)},t.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error("Invalid QR Code version");let t=e<<12;for(;r.getBCHDigit(t)-d>=0;)t^=7973<<r.getBCHDigit(t)-d;return e<<12|t}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/index.js"(e,t,n){e.exports=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/server.js")},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/canvas.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js");t.render=function(e,t,n){var o;let i=n,s=t;void 0!==i||t&&t.getContext||(i=t,t=void 0),t||(s=function(){try{return document.createElement("canvas")}catch(e){throw Error("You need to specify a canvas element")}}()),i=r.getOptions(i);let a=r.getImageWidth(e.modules.size,i),d=s.getContext("2d"),l=d.createImageData(a,a);return r.qrToImageData(l.data,e,i),o=s,d.clearRect(0,0,o.width,o.height),o.style||(o.style={}),o.height=a,o.width=a,o.style.height=a+"px",o.style.width=a+"px",d.putImageData(l,0,0),s},t.renderToDataURL=function(e,n,r){let o=r;void 0!==o||n&&n.getContext||(o=n,n=void 0),o||(o={});let i=t.render(e,n,o),s=o.type||"image/png",a=o.rendererOpts||{};return i.toDataURL(s,a.quality)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js"(e,t,n){let r=n("fs"),o=n("../../../node_modules/.pnpm/pngjs@5.0.0/node_modules/pngjs/lib/png.js").O,i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js");t.render=function(e,t){let n=i.getOptions(t),r=n.rendererOpts,s=i.getImageWidth(e.modules.size,n);r.width=s,r.height=s;let a=new o(r);return i.qrToImageData(a.data,e,n),a},t.renderToDataURL=function(e,n,r){void 0===r&&(r=n,n=void 0),t.renderToBuffer(e,n,function(e,t){e&&r(e);let n="data:image/png;base64,";n+=t.toString("base64"),r(null,n)})},t.renderToBuffer=function(e,n,r){void 0===r&&(r=n,n=void 0);let o=t.render(e,n),i=[];o.on("error",r),o.on("data",function(e){i.push(e)}),o.on("end",function(){r(null,Buffer.concat(i))}),o.pack()},t.renderToFile=function(e,n,o,i){void 0===i&&(i=o,o=void 0);let s=!1,a=(...e)=>{s||(s=!0,i.apply(null,e))},d=r.createWriteStream(e);d.on("error",a),d.on("close",a),t.renderToFileStream(d,n,o)},t.renderToFileStream=function(e,n,r){t.render(n,r).pack().pipe(e)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js");function o(e,t){let n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function i(e,t,n){let r=e+t;return void 0!==n&&(r+=" "+n),r}t.render=function(e,t,n){let s=r.getOptions(t),a=e.modules.size,d=e.modules.data,l=a+2*s.margin,c=s.color.light.a?"<path "+o(s.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",u="<path "+o(s.color.dark,"stroke")+' d="'+function(e,t,n){let r="",o=0,s=!1,a=0;for(let d=0;d<e.length;d++){let l=Math.floor(d%t),c=Math.floor(d/t);l||s||(s=!0),e[d]?(a++,d>0&&l>0&&e[d-1]||(r+=s?i("M",l+n,.5+c+n):i("m",o,0),o=0,s=!1),l+1<t&&e[d+1]||(r+=i("h",a),a=0)):o++}return r}(d,a,s.margin)+'"/>',p='<svg xmlns="http://www.w3.org/2000/svg" '+(s.width?'width="'+s.width+'" height="'+s.width+'" ':"")+('viewBox="0 0 '+l+" ")+l+'" shape-rendering="crispEdges">'+c+u+"</svg>\n";return"function"==typeof n&&n(null,p),p}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"(e,t,n){t.render=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg-tag.js").render,t.renderToFile=function(e,r,o,i){void 0===i&&(i=o,o=void 0);let s=n("fs"),a=t.render(r,o);s.writeFile(e,'<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'+a,i)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal-small.js");t.render=function(e,t,n){return t&&t.small?o.render(e,t,n):r.render(e,t,n)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal-small.js"(e,t){let n="\x1b[37m",r="\x1b[30m",o="\x1b[0m",i="\x1b[47m"+r,s="\x1b[40m"+n,a=function(e,t,n,r){let o=t+1;return n>=o||r>=o||r<-1||n<-1?"0":n>=t||r>=t||r<0||n<0?"1":e[r*t+n]?"2":"1"},d=function(e,t,n,r){return a(e,t,n,r)+a(e,t,n,r+1)};t.render=function(e,t,a){var l,c;let u=e.modules.size,p=e.modules.data,h=!!(t&&t.inverse),f=t&&t.inverse?s:i,m={"00":o+" "+f,"01":o+(l=h?r:n)+"▄"+f,"02":o+(c=h?n:r)+"▄"+f,10:o+l+"▀"+f,11:" ",12:"▄",20:o+c+"▀"+f,21:"▀",22:"█"},g=o+"\n"+f,_=f;for(let e=-1;e<u+1;e+=2){for(let t=-1;t<u;t++)_+=m[d(p,u,t,e)];_+=m[d(p,u,u,e)]+g}return _+=o,"function"==typeof a&&a(null,_),_}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal/terminal.js"(e,t){t.render=function(e,t,n){let r=e.modules.size,o=e.modules.data,i="\x1b[47m \x1b[0m",s="",a=Array(r+3).join(i),d=[,,].join(i);s+=a+"\n";for(let e=0;e<r;++e){s+=i;for(let t=0;t<r;t++)s+=o[e*r+t]?"\x1b[40m \x1b[0m":i;s+=d+"\n"}return s+=a+"\n","function"==typeof n&&n(null,s),s}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utf8.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js"),o={WW:" ",WB:"▄",BB:"█",BW:"▀"},i={BB:" ",BW:"▄",WW:"█",WB:"▀"};t.render=function(e,t,n){let s=r.getOptions(t),a=o;("#ffffff"===s.color.dark.hex||"#000000"===s.color.light.hex)&&(a=i);let d=e.modules.size,l=e.modules.data,c="",u=Array(d+2*s.margin+1).join(a.WW);u=Array(s.margin/2+1).join(u+"\n");let p=Array(s.margin+1).join(a.WW);c+=u;for(let e=0;e<d;e+=2){c+=p;for(let t=0;t<d;t++){var h;let n=l[e*d+t],r=l[(e+1)*d+t];c+=(h=a,n&&r?h.BB:n&&!r?h.BW:!n&&r?h.WB:h.WW)}c+=p+"\n"}return c+=u.slice(0,-1),"function"==typeof n&&n(null,c),c},t.renderToFile=function(e,r,o,i){void 0===i&&(i=o,o=void 0);let s=n("fs"),a=t.render(r,o);s.writeFile(e,a,i)}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utils.js"(e,t){function n(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw Error("Invalid hex color: "+e);(3===t.length||4===t.length)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");let n=parseInt(t.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+t.slice(0,6).join("")}}t.getOptions=function(e){e||(e={}),e.color||(e.color={});let t=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,o=e.scale||4;return{width:r,scale:r?4:o,margin:t,color:{dark:n(e.color.dark||"#000000ff"),light:n(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},t.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},t.getImageWidth=function(e,n){let r=t.getScale(e,n);return Math.floor((e+2*n.margin)*r)},t.qrToImageData=function(e,n,r){let o=n.modules.size,i=n.modules.data,s=t.getScale(o,r),a=Math.floor((o+2*r.margin)*s),d=r.margin*s,l=[r.color.light,r.color.dark];for(let t=0;t<a;t++)for(let n=0;n<a;n++){let c=(t*a+n)*4,u=r.color.light;t>=d&&n>=d&&t<a-d&&n<a-d&&(u=l[+!!i[Math.floor((t-d)/s)*o+Math.floor((n-d)/s)]]),e[c++]=u.r,e[c++]=u.g,e[c++]=u.b,e[c]=u.a}}},"../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/server.js"(e,t,n){let r=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/can-promise.js"),o=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/qrcode.js"),i=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js"),s=n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/utf8.js"),a=(n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/terminal.js"),n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"));function d(e,t,n){if(void 0===e)throw Error("String required as first argument");if(void 0===n&&(n=t,t={}),"function"!=typeof n)if(r())t=n||{},n=null;else throw Error("Callback required as last argument");return{opts:t,cb:n}}function l(e){switch(e){case"svg":return a;case"txt":case"utf8":return s;default:return i}}function c(e,t,n){if(!n.cb)return new Promise(function(r,i){try{let s=o.create(t,n.opts);return e(s,n.opts,function(e,t){return e?i(e):r(t)})}catch(e){i(e)}});try{let r=o.create(t,n.opts);return e(r,n.opts,n.cb)}catch(e){n.cb(e)}}o.create,n("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/browser.js"),t.toBuffer=function(e,t,n){let r=d(e,t,n);return c(l(r.opts.type).renderToBuffer,e,r)},t.toFile=function(e,t,n,o){if("string"!=typeof e||"string"!=typeof t&&"object"!=typeof t)throw Error("Invalid argument");if(arguments.length<3&&!r())throw Error("Too few arguments provided");let i=d(t,n,o);return c(l(i.opts.type||e.slice((e.lastIndexOf(".")-1>>>0)+2).toLowerCase()).renderToFile.bind(null,e),t,i)}},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"(e,t,n){var r=n("node:os"),o=n("node:path");let i=o.join(r.homedir(),".dbx","token"),s=o.join(r.homedir(),".doubao","token"),a={};function d(e){Object.assign(a,e)}function l(e={}){let t={...a,...e},n=function(e,t){let n;try{n=new URL(c(e))}catch{throw Error(`${t} must be an absolute HTTPS URL`)}if("https:"!==n.protocol)throw Error(`${t} must use https`);return c(n.toString())}(t.baseUrl??"https://developer.doubao.com","baseUrl"),r=t.tokenPath??i;return{...t,baseUrl:n,allowedOrigins:function(e,t){let n=new Set([new URL(t).origin]);for(let t of e??[]){let e;try{e=new URL(t)}catch{throw Error(`allowedOrigins entries must be absolute HTTPS origins: ${t}`)}if("https:"!==e.protocol)throw Error(`allowedOrigins entries must use https: ${t}`);n.add(e.origin)}return[...n]}(t.allowedOrigins,n),tokenPath:r,legacyTokenPath:t.tokenPath?void 0:s,requestHeaders:new Headers(t.requestHeaders)}}function c(e){return e.replace(/\/+$/,"")}n.d(t,{$i:()=>l,ZI:()=>d},{E:"dbx-cli"})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/credential-store.js"(e,t,n){var r=n("node:child_process"),o=n("node:crypto"),i=n("node:fs"),s=n("node:os"),a=n("node:path");let d=(0,n("node:util").promisify)(r.execFile),l="byted-doubao-open-dbx-cli",c="dbx-cli",u="aes-256-gcm";class p extends Error{constructor(e){super(e),this.name="CredentialStoreError"}}function h(){let e=new m;return"darwin"===process.platform?new f(new g,e):"linux"===process.platform?new f(new _,e):e}class f{constructor(e,t){this.primary=e,this.fallback=t}async get(e){let t;try{let t=await this.primary.get(e);if(t)return t}catch(e){t=e}try{let t=await this.fallback.get(e);if(t)return t}catch(e){if(t)throw new p(`Failed to read token from system credential store (${A(t)}); encrypted-file fallback also failed: ${A(e)}`);throw e}if(t)throw t instanceof Error?t:new p(`Failed to read token from system credential store: ${String(t)}`)}async set(e,t){let n;try{await this.primary.set(e,t)}catch(e){n=e}try{await this.fallback.set(e,t)}catch(e){if(n)throw new p(`Failed to write token to system credential store (${A(n)}) and encrypted-file fallback (${A(e)})`);throw e}}async delete(e){let t;try{await this.primary.delete(e)}catch(e){t=e}try{await this.fallback.delete(e)}catch(e){if(t)throw new p(`Failed to delete token from system credential store (${A(t)}) and encrypted-file fallback (${A(e)})`);throw e}}}class m{constructor(e={}){this.baseDir=e.baseDir??("darwin"===process.platform?a.join(s.homedir(),"Library","Application Support",c):"win32"===process.platform?a.join(process.env.APPDATA||a.join(s.homedir(),"AppData","Roaming"),c):a.join(process.env.XDG_DATA_HOME||a.join(s.homedir(),".local","share"),c))}async get(e){var t,n;let r,s,a=this.credentialFilePath(e);try{r=await i.promises.readFile(a,"utf8")}catch(e){if(I(e)&&"ENOENT"===e.code)return;throw new p(`Failed to read encrypted token file: ${A(e)}`)}try{s=JSON.parse(r)}catch(e){throw new p(`Encrypted token file is not valid JSON: ${A(e)}`)}if(!((t=s)&&"object"==typeof t&&1===t.version&&t.algorithm===u&&"string"==typeof t.iv&&"string"==typeof t.authTag&&"string"==typeof t.ciphertext))throw new p("Encrypted token file has an unsupported format");let d=await this.readMasterKey();try{let t=o.createDecipheriv(u,d,Buffer.from(s.iv,"base64url"));return t.setAAD(Buffer.from((n=e,`${l}:${n}`),"utf8")),t.setAuthTag(Buffer.from(s.authTag,"base64url")),Buffer.concat([t.update(Buffer.from(s.ciphertext,"base64url")),t.final()]).toString("utf8")}catch(e){throw new p(`Failed to decrypt encrypted token file: ${A(e)}`)}}async set(e,t){var n;let r=await this.readOrCreateMasterKey(),i=o.randomBytes(12),s=o.createCipheriv(u,r,i);s.setAAD(Buffer.from((n=e,`${l}:${n}`),"utf8"));let a=Buffer.concat([s.update(t,"utf8"),s.final()]),d={version:1,algorithm:u,iv:i.toString("base64url"),authTag:s.getAuthTag().toString("base64url"),ciphertext:a.toString("base64url")};await w(this.credentialFilePath(e),`${JSON.stringify(d,null,2)}
10
10
  `)}async delete(e){try{await i.promises.unlink(this.credentialFilePath(e))}catch(e){if(!I(e)||"ENOENT"!==e.code)throw new p(`Failed to delete encrypted token file: ${A(e)}`)}}masterKeyPath(){return a.join(this.baseDir,"master.key")}credentialFilePath(e){let t=o.createHash("sha256").update(e).digest("hex");return a.join(this.baseDir,"credentials",`${t}.json`)}async readMasterKey(){try{var e=await i.promises.readFile(this.masterKeyPath(),"utf8");let t=Buffer.from(e.trim(),"base64url");if(32!==t.length)throw new p("Encrypted token master key has an unsupported format");return t}catch(e){if(I(e)&&"ENOENT"===e.code)throw new p("Encrypted token master key is missing");if(e instanceof p)throw e;throw new p(`Failed to read encrypted token master key: ${A(e)}`)}}async readOrCreateMasterKey(){try{return await this.readMasterKey()}catch(e){if(!(e instanceof p)||!e.message.includes("master key is missing"))throw e}let e=o.randomBytes(32);try{return await w(this.masterKeyPath(),`${e.toString("base64url")}
11
- `),e}catch(e){if(I(e)&&"EEXIST"===e.code)return this.readMasterKey();throw new p(`Failed to write encrypted token master key: ${A(e)}`)}}}class g{async get(e){try{let{stdout:t}=await d("security",["find-generic-password","-a",e,"-s",l,"-w"]);return String(t).replace(/\n$/,"")}catch(e){if(y(e))return;throw new p(`Failed to read token from macOS Keychain: ${A(e)}`)}}async set(e,t){try{await d("security",["add-generic-password","-a",e,"-s",l,"-w",t,"-U"])}catch(e){throw new p(`Failed to write token to macOS Keychain: ${A(e)}`)}}async delete(e){try{await d("security",["delete-generic-password","-a",e,"-s",l])}catch(e){if(y(e))return;throw new p(`Failed to delete token from macOS Keychain: ${A(e)}`)}}}class _{async get(e){try{let{stdout:t}=await d("secret-tool",["lookup","service",l,"account",e]);return String(t).replace(/\n$/,"")}catch(e){if(b(e))return;throw new p(`Failed to read token from Secret Service: ${A(e)}`)}}async set(e,t){try{var n,o,i;await (n="secret-tool",o=["store","--label","Doubao Open CLI token","service",l,"account",e],i=t,new Promise((e,t)=>{let s=(0,r.spawn)(n,o,{stdio:["pipe","ignore","pipe"]}),a="";s.stderr.setEncoding("utf8"),s.stderr.on("data",e=>{a+=String(e)}),s.on("error",t),s.on("close",r=>{0===r?e():t(Error(a.trim()||`${n} exited with code ${r}`))}),s.stdin.end(i)}))}catch(e){throw new p(`Failed to write token to Secret Service: ${A(e)}`)}}async delete(e){try{await d("secret-tool",["clear","service",l,"account",e])}catch(e){if(b(e))return;throw new p(`Failed to delete token from Secret Service: ${A(e)}`)}}}async function w(e,t){let n=a.dirname(e);await i.promises.mkdir(n,{recursive:!0,mode:448}),"win32"!==process.platform&&await i.promises.chmod(n,448);let r=a.join(n,`.${a.basename(e)}.${process.pid}.${Date.now()}.tmp`);try{await i.promises.writeFile(r,t,{mode:384,flag:"wx"}),"win32"!==process.platform&&await i.promises.chmod(r,384),await i.promises.rename(r,e),"win32"!==process.platform&&await i.promises.chmod(e,384)}finally{try{await i.promises.unlink(r)}catch{}}}function y(e){let t=v(e),n=E(e);return(1===t||44===t)&&(n.includes("could not be found")||n.includes("The specified item could not be found"))}function b(e){let t=v(e),n=E(e);return 1===t&&(n.includes("could not be found")||n.includes("No matching items")||""===n.trim())}function v(e){return"object"==typeof e&&null!==e&&"code"in e?e.code:void 0}function E(e){return"object"==typeof e&&null!==e&&"stderr"in e?String(e.stderr??""):""}function I(e){return e instanceof Error&&"code"in e}function A(e){if("object"==typeof e&&null!==e&&"stderr"in e){let t=String(e.stderr??"").trim();if(t)return t}return e instanceof Error&&e.message?e.message:String(e)}n.d(t,{Mj:()=>h,RI:()=>p})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/device-flow.js"(e,t,n){var r=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"),o=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"),i=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/jwt.js"),s=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/store.js"),a=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/types.js");async function d(e={}){let t=(0,r.$i)(e),n=t.fetch??fetch,l=t.sleep??w,c=await u(n,t.baseUrl,t.requestHeaders),h=y(t.baseUrl,c.user_code);t.onVerification?.({userCode:c.user_code,verificationUrl:h,expiresIn:c.expires_in,interval:c.interval});let f=Math.max(1,c.interval),m=Date.now()+1e3*c.expires_in;for(;Date.now()<m;){await l(1e3*f);let e=await p(n,t.baseUrl,c.device_code,t.requestHeaders);if(t.onPoll?.({status:e.status,interval:f}),e.status!==a.A.Pending){if(e.status===a.A.SlowDown){f+=Math.max(1,c.interval);continue}if(e.status===a.A.Expired)throw new o.JC("Device authorization expired","DEVICE_AUTH_EXPIRED");if(e.status===a.A.Invalid)throw new o.JC("Device authorization is invalid","DEVICE_AUTH_INVALID");if(e.status===a.A.Authorized){if(!e.access_token)throw new o.JC("Authorization response did not include an access token");let n=_(e,t.baseUrl);return await (0,s.tK)(t.tokenPath,n,{credentialStore:t.credentialStore}),{accessToken:n.accessToken,tokenType:n.tokenType,expiresAt:n.expiresAt,baseUrl:n.baseUrl,uid:(0,i.m)(n.accessToken),tokenPath:t.tokenPath}}throw new o.JC(`Unexpected authorization status: ${String(e.status)}`)}}throw new o.JC("Device authorization timed out","DEVICE_AUTH_EXPIRED")}async function l(e={}){let t=(0,r.$i)(e),n=t.fetch??fetch,o=await u(n,t.baseUrl,t.requestHeaders),i=y(t.baseUrl,o.user_code);return t.onVerification?.({userCode:o.user_code,verificationUrl:i,expiresIn:o.expires_in,interval:o.interval}),{userCode:o.user_code,deviceCode:o.device_code,verificationUrl:i,expiresIn:o.expires_in,interval:o.interval}}async function c(e,t={}){let n=(0,r.$i)(t),d=n.fetch??fetch,l=n.sleep??w,u=n.baseUrl,h=n.requestHeaders,f=5,m=Date.now()+6e5;for(;Date.now()<m;){await l(1e3*f);let t=await p(d,u,e,h);if(n.onPoll?.({status:t.status,interval:f}),t.status!==a.A.Pending){if(t.status===a.A.SlowDown){f+=5;continue}if(t.status===a.A.Expired)throw new o.JC("Device authorization expired","DEVICE_AUTH_EXPIRED");if(t.status===a.A.Invalid)throw new o.JC("Device authorization is invalid","DEVICE_AUTH_INVALID");if(t.status===a.A.Authorized){if(!t.access_token)throw new o.JC("Authorization response did not include an access token");let e=_(t,u);return await (0,s.tK)(n.tokenPath,e,{credentialStore:n.credentialStore}),{accessToken:e.accessToken,tokenType:e.tokenType,expiresAt:e.expiresAt,baseUrl:e.baseUrl,uid:(0,i.m)(e.accessToken),tokenPath:n.tokenPath}}throw new o.JC(`Unexpected authorization status: ${String(t.status)}`)}}throw new o.JC("Device authorization timed out","DEVICE_AUTH_EXPIRED")}async function u(e,t,n){let i=await e(`${t}/app_developer/oauth/device/code`,{method:"POST",headers:g(n),body:JSON.stringify({client_name:r.E})}),s=await h(i),a=m(s);if(!a||!a.device_code||!a.user_code||"number"!=typeof a.expires_in||"number"!=typeof a.interval)throw new o.JC(`Device code response is malformed (HTTP ${i.status}): ${JSON.stringify(s)}`);return a}async function p(e,t,n,r){let i=await e(`${t}/app_developer/oauth/token`,{method:"POST",headers:g(r),body:JSON.stringify({device_code:n})}),s=await h(i),d=m(s);if(d?.access_token)return{status:a.A.Authorized,access_token:d.access_token,token_type:d.token_type,expires_in:d.expires_in,expires_at:d.expires_at};if(!d||"number"!=typeof d.status)throw new o.JC(`Token response is malformed (HTTP ${i.status}): ${JSON.stringify(s)}`);return d}async function h(e){var t;let n,r=e.headers.get("x-tt-logid")??void 0;try{n=await e.json()}catch{throw new o.JC(`Auth server returned non-JSON response with status ${e.status}${f(r)}`,"DEVICE_AUTH_FAILED",{logId:r})}let i=function(e){if(e&&"object"==typeof e)return"string"==typeof e.log_id&&e.log_id?e.log_id:void 0}(n)??r;if(!e.ok)throw new o.JC(`Auth server returned HTTP ${e.status}: ${JSON.stringify(n)}${f(i)}`,"DEVICE_AUTH_FAILED",{logId:i});let s=(t=n)&&"object"==typeof t&&"number"==typeof t.code&&0!==t.code?{code:t.code,message:"string"==typeof t.message?t.message:"Unknown error",logId:"string"==typeof t.log_id?t.log_id:void 0}:null;if(s)throw new o.JC(`Auth server error (code ${s.code}): ${s.message}${f(s.logId??i)}`,"DEVICE_AUTH_FAILED",{logId:s.logId??i});return n}function f(e){return e?` [log_id: ${e}]`:""}function m(e){return e&&"object"==typeof e&&"data"in e?e.data:e}function g(e){let t=new Headers(e);return t.set("Content-Type","application/json"),t}function _(e,t){let n=Math.floor(Date.now()/1e3);return{accessToken:e.access_token??"",tokenType:e.token_type??"Bearer",expiresAt:"number"==typeof e.expires_at?e.expires_at:n+(e.expires_in??0),baseUrl:t}}function w(e){return new Promise(t=>{setTimeout(t,e)})}function y(e,t){let n=new URL(e).host,r=new URL(`https://${n}/oauth/device`);return r.searchParams.set("user_code",t),r.toString()}n.d(t,{R$:()=>c,c$:()=>l,iD:()=>d})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"(e,t,n){class r extends Error{constructor(e,t){super(e),this.code=t,this.name="AuthError"}}class o extends r{constructor(e="Not logged in"){super(e,"NOT_LOGGED_IN"),this.name="NotLoggedInError"}}class i extends r{constructor(e="Login token has expired"){super(e,"TOKEN_EXPIRED"),this.name="TokenExpiredError"}}class s extends r{constructor(e,t="DEVICE_AUTH_FAILED",n={}){super(e,t),this.name="DeviceAuthError",this.logId=n.logId}}n.d(t,{BX:()=>i,JC:()=>s,bG:()=>o,lR:()=>r})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/http.js"(e,t,n){var r=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"),o=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"),i=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/store.js");function s(e=fetch,t={}){return async(n,s={})=>{let a=(0,o.$i)(t);var d=n,l=a.allowedOrigins;let c=function(e){try{if("string"==typeof e)return new URL(e);if(e instanceof URL)return e;return new URL(e.url)}catch{throw Error("Authenticated requests must use an absolute HTTPS URL")}}(d);if("https:"!==c.protocol)throw Error(`Authenticated requests must use https: ${c.toString()}`);if(!l.includes(c.origin))throw Error(`Refusing to attach Authorization header to untrusted origin: ${c.origin}`);let u=await (0,i.AI)(a.tokenPath,{allowExpired:!0,envTokenBaseUrl:a.baseUrl,credentialStore:a.credentialStore,legacyTokenPath:a.legacyTokenPath});if(!u)throw new r.bG;if((0,i._d)(u))throw new r.BX;let p=new Headers(s.headers);return a.requestHeaders.forEach((e,t)=>{p.set(t,e)}),p.set("Authorization",`${u.tokenType||"Bearer"} ${u.accessToken}`),e(n,{...s,headers:p})}}n.d(t,{r:()=>s})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/index.js"(e,t,n){n.r(t);var r=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"),o=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/credential-store.js"),i=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/device-flow.js"),s=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/store.js"),a=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/http.js"),d=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"),l=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/types.js");async function c(e={}){let t=(0,r.$i)(e);await (0,s.ni)(t.tokenPath,{credentialStore:t.credentialStore}),t.legacyTokenPath&&await (0,s.ni)(t.legacyTokenPath,{credentialStore:t.credentialStore})}async function u(e={}){let t,n=(0,r.$i)(e);try{t=await (0,s.AI)(n.tokenPath,{envTokenBaseUrl:n.baseUrl,credentialStore:n.credentialStore,legacyTokenPath:n.legacyTokenPath})}catch(e){if(e instanceof o.RI)return{loggedIn:!1,tokenPath:n.tokenPath,baseUrl:n.baseUrl,credentialError:{code:"CREDENTIAL_STORE_UNAVAILABLE",message:e.message}};throw e}if(!t)return{loggedIn:!1,tokenPath:n.tokenPath};let i=await p(e.fetch??fetch,n.baseUrl,t,n.requestHeaders);return i?{loggedIn:!0,uid:i.userId,name:i.name,avatar:i.avatar,expiresAt:t.expiresAt,tokenPath:n.tokenPath,baseUrl:n.baseUrl}:{loggedIn:!1,expiresAt:t.expiresAt,tokenPath:n.tokenPath,baseUrl:n.baseUrl}}async function p(e,t,n,r){let o=new Headers(r);o.set("Authorization",`${n.tokenType||"Bearer"} ${n.accessToken}`);let i=await e(`${t.replace(/\/+$/,"")}/app_developer/api/user/basic`,{method:"GET",headers:o});if(!i.ok)return;let s=await i.json();if(0===s.code){var a;return{userId:"string"==typeof(a=s.data?.user_id)&&a.length>0?a:"number"==typeof a&&Number.isFinite(a)?String(a):void 0,name:s.data?.name,avatar:s.data?.avatar}}}n.d(t,{AuthError:()=>d.lR,CredentialStoreError:()=>o.RI,DeviceAuthError:()=>d.JC,NotLoggedInError:()=>d.bG,TokenExpiredError:()=>d.BX,TokenStatus:()=>l.A,completeLogin:()=>i.R$,configureAuth:()=>r.ZI,login:()=>i.iD,logout:()=>c,startLogin:()=>i.c$,whoami:()=>u,withAuth:()=>a.r})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/jwt.js"(e,t,n){function r(e){let t=function(e){let t=e.split(".")[1];if(t)try{let e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.padEnd(e.length+(4-e.length%4)%4,"="),r=Buffer.from(n,"base64").toString("utf8"),o=JSON.parse(r);return o&&"object"==typeof o?o:void 0}catch{return}}(e),n=t?.uid??t?.sub;return"string"==typeof n&&n.length>0?n:"number"==typeof n&&Number.isFinite(n)?String(n):void 0}n.d(t,{m:()=>r})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/store.js"(e,t,n){var r=n("node:fs"),o=n("node:crypto"),i=n("node:path"),s=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/credential-store.js");async function a(e,t={}){let n,r=process.env.DBX_ACCESS_TOKEN?.trim()||void 0;if(r)return{accessToken:r,tokenType:"Bearer",expiresAt:0xf4865700,baseUrl:t.envTokenBaseUrl??""};let o=await h(e);if(void 0===o)return f(e,t);try{n=JSON.parse(o)}catch(e){return}if(p(n)){if(!t.allowExpired&&c(n))return void await l(e,t);let r=await m(t).get(n.credentialAccount);if(!r)throw new s.RI("Stored login metadata exists, but the token credential is missing or inaccessible. Run dbx auth login again from a terminal that can access the credential store.");return{accessToken:r,tokenType:n.tokenType,expiresAt:n.expiresAt,baseUrl:n.baseUrl}}if(u(n))return!t.allowExpired&&c(n)?void await l(e,t):(await d(e,n,t),n)}async function d(e,t,n={}){let o={version:2,storage:"keychain",credentialAccount:g(e),tokenType:t.tokenType,expiresAt:t.expiresAt,baseUrl:t.baseUrl};await m(n).set(o.credentialAccount,t.accessToken),await r.promises.mkdir(i.dirname(e),{recursive:!0,mode:448}),"win32"!==process.platform&&await r.promises.chmod(i.dirname(e),448);let s=`${e}.${process.pid}.${Date.now()}.tmp`;await r.promises.writeFile(s,`${JSON.stringify(o,null,2)}
12
- `,{mode:384}),"win32"!==process.platform&&await r.promises.chmod(s,384),await r.promises.rename(s,e),"win32"!==process.platform&&await r.promises.chmod(e,384)}async function l(e,t={}){let n=await h(e);if(void 0!==n)try{let r=JSON.parse(n);p(r)?await m(t).delete(r.credentialAccount):await m(t).delete(g(e))}catch{}try{await r.promises.unlink(e)}catch(e){if(!_(e)||"ENOENT"!==e.code)throw e}}function c(e,t=Math.floor(Date.now()/1e3)){return e.expiresAt<=t}function u(e){return!!e&&"object"==typeof e&&"string"==typeof e.accessToken&&e.accessToken.length>0&&"string"==typeof e.tokenType&&e.tokenType.length>0&&"number"==typeof e.expiresAt&&Number.isFinite(e.expiresAt)&&"string"==typeof e.baseUrl&&e.baseUrl.length>0}function p(e){return!!e&&"object"==typeof e&&2===e.version&&"keychain"===e.storage&&"string"==typeof e.credentialAccount&&e.credentialAccount.length>0&&"string"==typeof e.tokenType&&e.tokenType.length>0&&"number"==typeof e.expiresAt&&Number.isFinite(e.expiresAt)&&"string"==typeof e.baseUrl&&e.baseUrl.length>0}async function h(e){try{return await r.promises.readFile(e,"utf8")}catch(e){_(e)&&e.code;return}}async function f(e,t){let n;if(!t.legacyTokenPath||i.resolve(t.legacyTokenPath)===i.resolve(e))return;let r=await h(t.legacyTokenPath);if(void 0!==r){try{n=JSON.parse(r)}catch{return}if(u(n))return!t.allowExpired&&c(n)?void await l(t.legacyTokenPath,t):(await d(e,n,t),await l(t.legacyTokenPath,t),n)}}function m(e){return e.credentialStore??(0,s.Mj)()}function g(e){let t=o.createHash("sha256").update(i.resolve(e)).digest("hex").slice(0,32);return`token:${t}`}function _(e){return e instanceof Error&&"code"in e}n.d(t,{AI:()=>a,_d:()=>c,ni:()=>l,tK:()=>d})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.30/node_modules/@byted-doubao-apps/auth-cli/dist/types.js"(e,t,n){var r,o;(o=r||(r={}))[o.Pending=1]="Pending",o[o.Authorized=2]="Authorized",o[o.Expired=3]="Expired",o[o.Invalid=4]="Invalid",o[o.SlowDown=5]="SlowDown",n.d(t,{A:()=>r})}});var R={};e.r(R),e.d(R,{createDeferredDevShellSession:()=>nc,default:()=>na,isInteractiveTerminal:()=>np});let O=e("node:zlib"),$=e("../../../node_modules/.pnpm/@byted-doubao-tools+devtool-connection-core@0.1.0-beta.12_debug@4.4.3_react@19.2.7/node_modules/@byted-doubao-tools/devtool-connection-core/dist/lib/ipc/index.js"),N=4*Math.ceil(5614250.666666667),q=new Map;class M extends Error{code;cause;constructor(e,t,n){super(t),this.code=e,this.name="RuntimeInspectionError",n&&"cause"in n&&(this.cause=n.cause)}}async function B(e){let t,r=new d(e.namespace,{nodeId:`${e.nodeIdPrefix}-${process.pid}-${Math.random().toString(36).slice(2,8)}`,requestTimeout:12e3}),o=new Set,i=new Set,a=0,l=!0;r.createService({name:`runtimeInspection${process.pid}${Math.random().toString(36).slice(2,8)}`,events:{[$.DEVTOOL_CONNECTION_IPC_EVENTS.messageReceived](e){let n=e.params,r=function(e){if("Page.screencastFrame"===e.method&&c(e.params)&&"string"==typeof e.params.data&&e.params.data)return{data:e.params.data}}(n);for(let e of(r&&Number.isSafeInteger(n.clientId)&&Number.isSafeInteger(n.sessionId)&&(t={clientId:n.clientId,sessionId:n.sessionId,data:r.data}),o))e(n)},[s.runtimeInspectionTargetChanged](e){let t=function(e){if(c(e)&&"number"==typeof e.clientId&&"number"==typeof e.sessionId&&"string"==typeof e.url)return{clientId:e.clientId,sessionId:e.sessionId,url:e.url}}(e.params);if(t)for(let e of i)e(t)}}});try{await r.start()}catch(e){throw await r.stop().catch(()=>void 0),e}let u=(e,t)=>eh(()=>r.call(`${$.DEFAULT_DEVTOOL_CONNECTION_IPC_SERVICE_NAME}.${e}`,t),5e3);return{eventSubscriptionWarmupMs:e.eventSubscriptionWarmupMs??5e3,getConnectedClients:()=>u($.DEVTOOL_CONNECTION_IPC_ACTIONS.getConnectedClients),getLatestScreencastFrame(e){if(t?.clientId===e.clientId&&t.sessionId===e.sessionId)return{data:t.data}},async getRuntimeInspectionTarget(){if(!l)return null;try{return await r.call(n.getRuntimeInspectionTarget)}catch(e){if(ep(e))return l=!1,null;throw e}},subscribeRuntimeInspectionTarget:e=>(i.add(e),()=>{i.delete(e)}),async sendCdp(e,t,n={},r={}){let o={id:1e9+process.pid%1e5*1e3+a++,clientId:e.clientId,sessionId:e.sessionId,method:t,params:n,messageType:"CDP",timeoutMs:!1===r.expectResponse?100:1e4};try{let e=await u($.DEVTOOL_CONNECTION_IPC_ACTIONS.sendMessageToApp,o);var i,s,d=t,l=e;if(!l.success)throw Error([l.reason,l.apps?.length?`apps=${l.apps.join(",")}`:"",l.clients?.length?`clients=${l.clients.map(e=>`${e.clientId}:${e.info.App}`).join(",")}`:""].filter(Boolean).join("; "));if(c(l.data)&&c(l.data.error)){let e=void 0===l.data.error.code?"unknown":String(l.data.error.code),t=void 0===l.data.error.message?"unknown error":String(l.data.error.message);throw Error(`${d} failed: ${t} (code=${e})`)}return X(l.data)}catch(e){if(!1===r.expectResponse&&(i=e,s=t,(i instanceof Error?i.message:String(i)).includes(`send CDP message timeout, method: ${s}`)))return;throw Error(`${t} failed: ${e instanceof Error?e.message:String(e)}`)}},subscribeMessage:e=>(o.add(e),()=>{o.delete(e)}),async stop(){o.clear(),i.clear(),t=void 0,await r.stop()}}}async function U(e,t={}){let n=Date.now()+(t.timeoutMs??3e3);for(;;){em(t.signal);let r=await e.getConnectedClients(),o=function(e,t={}){let n,r=t.explicitTarget??(t.policy?.kind==="fixed"?t.policy.target:void 0);if(r){let n=e.find(e=>e.device.clientId===r.clientId);if(!n){if(t.activeClientId===r.clientId)throw new M("TARGET_CLIENT_DISCONNECTED",`debug client ${r.clientId} is disconnected`);throw new M("TARGET_STALE",`${F(r)} no longer points to a connected debug client`)}let o=n.sessions.find(e=>e.sessionId===r.sessionId&&W(e));if(!o)throw new M("TARGET_STALE",`${F(r)} no longer points to a live Lynx session`);return{clientId:n.device.clientId,sessionId:o.sessionId,url:o.url}}if(void 0!==t.activeClientId){if(!(n=e.find(e=>e.device.clientId===t.activeClientId)))throw new M("TARGET_CLIENT_DISCONNECTED",`authenticated debug client ${t.activeClientId} is disconnected`)}else if(e.length>1)throw new M("TARGET_AMBIGUOUS",`more than one debug device is connected: ${e.map(e=>`${e.device.clientId}:${e.device.info.App||"unknown"}`).join(", ")}`);else n=e[0];if(!n)return;let o=n.sessions.filter(W).sort((e,t)=>t.sessionId-e.sessionId)[0];if(o)return{clientId:n.device.clientId,sessionId:o.sessionId,url:o.url}}(r,t);if(o)return o;if(Date.now()>=n)throw 0===r.length?new M("DEVICE_NOT_CONNECTED","no debug device is connected"):new M("NO_ACTIVE_LYNX_SESSION","the connected device has no active Lynx session");await eg(100,t.signal)}}function F(e){return`@${e.clientId}:${e.sessionId}`}function V(e){let t=/^@([1-9]\d*):([1-9]\d*)$/.exec(e.trim());if(!t)throw new M("INVALID_TARGET_REF",`invalid target ref "${e}"; expected @<clientId>:<sessionId>`);let n={clientId:Number(t[1]),sessionId:Number(t[2])};if(!Number.isSafeInteger(n.clientId)||!Number.isSafeInteger(n.sessionId))throw new M("INVALID_TARGET_REF",`invalid target ref "${e}"; every id must be a safe integer`);return n}function H(e){return`@${e.clientId}:${e.sessionId}:${e.nodeId}`}async function K(e,t){let n=(await e.getConnectedClients()).find(e=>e.device.clientId===t.clientId),r=n?.sessions.find(e=>e.sessionId===t.sessionId&&W(e));if(!n||!r)throw new M("STALE_NODE_REF",`${H(t)} no longer points to a live Lynx session; run get-page-tree again`);return{clientId:t.clientId,sessionId:t.sessionId,url:r.url}}async function z(e,t,n={}){var r,o,i;let s,a,d,l,u,p=n.depth??-1,h=n.maxNodes??5e3;if(!Number.isInteger(p)||p<-1)throw Error("page tree depth must be -1 or a non-negative integer");if(!Number.isSafeInteger(h)||h<1)throw Error("page tree maxNodes must be a positive integer");await e.sendCdp(t,"DOM.enable",{useCompression:!1});try{u=await e.sendCdp(t,"DOM.getDocument",{depth:p})}catch{u=await e.sendCdp(t,"DOM.getDocument")}let f=function(e){let t=X(e);if(!c(t))throw ei("DOM.getDocument","response is not an object");let n=t.root;if(!0===t.compress&&"string"==typeof n)try{if(n.length>N)throw Error("compressed root exceeds the input limit");n=JSON.parse((0,O.inflateSync)(Buffer.from(n,"base64"),{maxOutputLength:0x1000000}).toString("utf8"))}catch(e){throw ei("DOM.getDocument","failed to decode compressed root",e)}else if("string"==typeof n)try{n=JSON.parse(n)}catch(e){throw ei("DOM.getDocument","root is not valid JSON",e)}if(!c(n))throw ei("DOM.getDocument","missing root node");return n}(u),m=await Q(e,t,f,p,h),g=(r=f,o=t,i=h,s=0,a=!1,d=[],{root:(l=e=>{var t;let n=ee(e.nodeId),r="string"==typeof e.nodeName&&e.nodeName?e.nodeName:"unknown";if(void 0===n)throw ei("DOM.getDocument",`node ${r} has no valid nodeId`);s++;let c=[],u={ref:H({clientId:o.clientId,sessionId:o.sessionId,nodeId:n}),nodeId:n,...void 0===ee(e.backendNodeId)?{}:{backendNodeId:ee(e.backendNodeId)},nodeType:"number"==typeof e.nodeType&&Number.isSafeInteger(e.nodeType)?e.nodeType:0,nodeName:r,..."string"==typeof e.localName?{localName:e.localName}:{},nodeValue:"string"==typeof e.nodeValue?e.nodeValue:"",attributes:function(e){if(!Array.isArray(e))return{};let t={};for(let n=0;n<e.length;n+=2){let r=e[n];if("string"!=typeof r||!r)continue;let o=e[n+1];t[r]="string"==typeof o?o:String(o??"")}return t}(e.attributes),childNodeCount:"number"==typeof e.childNodeCount&&Number.isSafeInteger(e.childNodeCount)?Math.max(0,e.childNodeCount):Z(e).length,children:c};for(let t of(et(u)&&u.nodeValue&&(u.text=u.nodeValue),Z(e))){if(s>=i){a=!0;break}c.push(l(t))}if("text"===((t=u).localName||t.nodeName).toLowerCase()){let e=function e(t){return t.children.flatMap(t=>et(t)?[t.nodeValue]:[e(t)]).join("")}(u);e?u.text=e:d.push(u)}return u})(r),nodeCount:s,truncated:a,textCandidates:d});return await en(e,t,g.textCandidates),{target:t,depth:p,nodeCount:g.nodeCount,truncated:m.truncated||g.truncated,root:g.root}}async function Y(e,t,n,r=[]){let o;await e.sendCdp(t,"DOM.enable",{useCompression:!1});try{o=await e.sendCdp(t,"CSS.getComputedStyleForNode",{nodeId:n.nodeId})}catch(e){var i;if(i=e,/(could not find|cannot find|no such|unknown|invalid|stale).{0,40}node|node.{0,40}(not found|does not exist|invalid|stale)/i.test(i instanceof Error?i.message:String(i)))throw new M("STALE_NODE_REF",`${H(n)} is stale; run get-page-tree again`,{cause:e});throw e}let s=X(o);if(!c(s)||!Array.isArray(s.computedStyle))throw ei("CSS.getComputedStyleForNode","missing computedStyle array");let a=s.computedStyle.filter(c).flatMap(e=>"string"==typeof e.name&&"string"==typeof e.value?[{name:e.name,value:e.value}]:[]),d=0===r.length?a:r.flatMap(e=>{let t=a.find(t=>t.name===e);return t?[t]:[]});return{target:t,nodeRef:H(n),nodeId:n.nodeId,properties:d}}function W(e){return"lynx"===e.type&&Number.isSafeInteger(e.sessionId)&&e.sessionId>0&&!J(e.url)}function G(e){return`${e.clientId}:${e.sessionId}`}function J(e){return/(?:-main\.js|\.main\.lynx\.js)(?:[?#].*)?$/.test(e)}async function Q(e,t,n,r,o){let i=0,s=!1,a=async(n,d)=>{if(i>=o){s=!0;return}if(i++,r>=0&&d>=r)return;let l=Z(n);if(("number"==typeof n.childNodeCount&&Number.isSafeInteger(n.childNodeCount)?Math.max(0,n.childNodeCount):l.length)>l.length&&"number"==typeof n.nodeId&&Number.isSafeInteger(n.nodeId)){let r=X(await e.sendCdp(t,"DOM.requestChildNodes",{nodeId:n.nodeId}));if(!c(r)||!Array.isArray(r.nodes))throw ei("DOM.requestChildNodes",`missing nodes array for node ${n.nodeId}`);n.children=l=r.nodes.filter(c)}for(let e of l)if(await a(e,d+1),i>=o){l.indexOf(e)<l.length-1&&(s=!0);break}};return await a(n,0),{truncated:s}}function X(e){return c(e)&&"id"in e&&"result"in e?e.result:e}function Z(e){return Array.isArray(e.children)?e.children.filter(c):[]}function ee(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>0?e:void 0}function et(e){return 3===e.nodeType||"#text"===e.nodeName.toLowerCase()}async function en(e,t,n){let r=n[0];if(!r)return;let o=await er(e,t,r);if(o.supported){o.text&&(r.text=o.text);for(let r=1;r<n.length;r+=8){let o=n.slice(r,r+8);await Promise.all(o.map(async n=>{let r=await er(e,t,n);r.text&&(n.text=r.text)}))}}}async function er(e,t,n){try{let r=X(await e.sendCdp(t,"DOM.innerText",{nodeId:n.nodeId}));if(!c(r)||!Array.isArray(r.rawTextValues))return{supported:!1};let o=r.rawTextValues.filter(c).flatMap(e=>"string"==typeof e.text?[e.text]:[]).join("");return{supported:!0,...o?{text:o}:{}}}catch{return{supported:!1}}}function eo(e,t=120){let n=e.replace(/\s+/g," ").trim();return JSON.stringify(n.length>t?`${n.slice(0,Math.max(0,t-1))}…`:n)}function ei(e,t,n){return new M("INVALID_CDP_RESPONSE",`${e} returned an invalid response: ${t}`,void 0===n?void 0:{cause:n})}async function es(e,t,n){let r,o,i,s=0,a=!1,d=G(t),l=new Promise((e,t)=>{o=e,i=t}),u=e=>{a||(a=!0,o({count:s,reason:e}))},p=()=>u("aborted"),h=e.getRuntimeInspectionTarget?.bind(e),f=e=>{if(a||!(Number.isSafeInteger(e.clientId)&&e.clientId>0&&Number.isSafeInteger(e.sessionId)&&e.sessionId>0&&!J(e.url)))return;let r=G(e);if(r!==d&&(d=r,r!==G(t)))try{n.onTargetChange?.(e)}catch{}},m=e.subscribeMessage(e=>{if(a||!ed(e,t))return;let r=function(e){var t;if("Runtime.consoleAPICalled"!==e.method||!c(e.params))return;let n={...t=e.params,...Array.isArray(t.args)?{args:t.args.map(e=>c(e)?{...e}:e)}:{},...c(t.stackTrace)?{stackTrace:{...t.stackTrace,...Array.isArray(t.stackTrace.callFrames)?{callFrames:t.stackTrace.callFrames.map(e=>c(e)?{...e}:e)}:{}}}:{}},r="string"==typeof n.consoleTag?n.consoleTag:void 0;return{type:"string"==typeof n.type?n.type:"log",thread:"Lepus"===r?"main":"background",args:Array.isArray(n.args)?n.args:[],...r?{consoleTag:r}:{},..."number"==typeof n.timestamp?{timestamp:n.timestamp}:{},..."stackTrace"in n?{stackTrace:n.stackTrace}:{},params:n}}(e);if(r){try{n.onMessage(r)}catch(e){a||(a=!0,i(e));return}s++,void 0!==n.limit&&s>=n.limit&&u("limit")}}),g=n.onTargetChange?e.subscribeRuntimeInspectionTarget?.(f):void 0;n.signal?.addEventListener("abort",p,{once:!0}),n.onTargetChange&&h&&h().then(e=>{e&&f(e)}).catch(()=>void 0);try{if(n.signal?.aborted)return u("aborted"),await l;if(await el(e,t,n.subscriptionWarmupMs??e.eventSubscriptionWarmupMs??5e3,n.signal),a)return await l;for(let o of(void 0!==n.timeoutMs&&(r=setTimeout(()=>u("timeout"),n.timeoutMs)),[{method:"Page.getResourceTree",params:{}},{method:"Debugger.enable",params:{}},{method:"Runtime.enable",params:{}}])){if(a)break;await e.sendCdp(t,o.method,o.params,{expectResponse:!1})}return await l}catch(e){if(n.signal?.aborted)return u("aborted"),await l;throw e}finally{r&&clearTimeout(r),n.signal?.removeEventListener("abort",p),g?.(),m()}}async function ea(e,t,n={}){return ef(t,async()=>{let r,o=new Promise(e=>{r=e}),i=e.subscribeMessage(e=>{ed(e,t)&&"Page.screencastFrame"===e.method&&c(e.params)&&"string"==typeof e.params.data&&e.params.data&&r({data:e.params.data})}),s=!1;try{var a,d,l;await el(e,t,e.eventSubscriptionWarmupMs??5e3);let r=n.activeCapture?void 0:e.getLatestScreencastFrame?.(t);!r&&n.activeCapture&&(await e.sendCdp(t,"Page.enable"),s=!0,await e.sendCdp(t,"Page.startScreencast",{format:"jpeg",quality:80},{expectResponse:!1})),r??=await (a=o,d=t,l=n.timeoutMs??1e4,new Promise((e,t)=>{let n=setTimeout(()=>t(new M("SCREENSHOT_TIMEOUT",`no Page.screencastFrame received for ${F(d)} within ${l}ms; make sure the target session is active and can produce screenshot frames`)),l);a.then(t=>{clearTimeout(n),e(t)},e=>{clearTimeout(n),t(e)})})),s&&await e.sendCdp(t,"Page.screencastFrameAck",{},{expectResponse:!1}).catch(()=>void 0);let i=function(e){let t=e.replace(/\s+/g,"");if(!t||t.length%4!=0||!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw new M("INVALID_SCREENSHOT_DATA","Page.screencastFrame returned invalid base64 data");let n=Buffer.from(t,"base64");if(n.length<4||255!==n[0]||216!==n[1]||255!==n[n.length-2]||217!==n[n.length-1])throw new M("INVALID_SCREENSHOT_DATA","Page.screencastFrame did not return a complete JPEG image");let r=function(e){let t=new Set([192,193,194,195,197,198,199,201,202,203,205,206,207]),n=2;for(;n+3<e.length;){if(255!==e[n]){n++;continue}for(;n<e.length&&255===e[n];)n++;let r=e[n++];if(void 0===r||217===r||218===r)break;if(1===r||r>=208&&r<=215)continue;if(n+1>=e.length)break;let o=e.readUInt16BE(n);if(o<2||n+o>e.length)break;if(t.has(r)){if(o<7)break;let t=e.readUInt16BE(n+3),r=e.readUInt16BE(n+5);if(r>0&&t>0)return{width:r,height:t};break}n+=o}}(n);if(!r)throw new M("INVALID_SCREENSHOT_DATA","Page.screencastFrame JPEG has no readable dimensions");return{buffer:n,data:t,...r}}(r.data);return{data:i.data,format:"jpeg",source:"Page.screencastFrame",width:i.width,height:i.height,byteLength:i.buffer.length}}finally{s&&await e.sendCdp(t,"Page.stopScreencast",{},{expectResponse:!1}).catch(()=>void 0),i()}})}function ed(e,t){return"CDP"===e.messageType&&e.clientId===t.clientId&&e.sessionId===t.sessionId}async function el(e,t,n,r){let o;if(n<=0)return;let i=Date.now()+n,s=new Promise(e=>{o=e}),a=e.subscribeMessage(e=>{ed(e,t)&&o()});try{for(;Date.now()<i;){if(em(r),await e.sendCdp(t,"Page.getResourceTree",{},{expectResponse:!1}).catch(()=>void 0),await function(e,t,n){return new Promise((r,o)=>{let i=new AbortController,s=setTimeout(()=>{i.abort(),r(!1)},t);n?.addEventListener("abort",()=>{clearTimeout(s),i.abort(),o(n?.reason instanceof Error?n.reason:Error("operation aborted"))},{once:!0,signal:i.signal}),e.then(()=>{clearTimeout(s),i.abort(),r(!0)},e=>{clearTimeout(s),i.abort(),o(e)})})}(s,Math.min(250,Math.max(0,i-Date.now())),r))return;await eg(Math.min(50,Math.max(0,i-Date.now())),r)}}finally{a()}}function ec(e){return c(e)?e.objectId?`<${String(e.description||e.className||"Object")} (objectId:${String(e.objectId)})>`:"value"in e?eu(e.value):"string"==typeof e.description?e.description:eu(e):eu(e)}function eu(e){if("string"==typeof e)return e;if(void 0===e)return"undefined";try{let t=JSON.stringify(e);return void 0===t?String(e):t}catch{return String(e)}}function ep(e){return/is not (found|available)/i.test(e instanceof Error?e.message:String(e))}async function eh(e,t){let n=Date.now()+t;for(;;)try{return await e()}catch(e){if(!ep(e)||Date.now()>=n)throw e;await eg(50)}}async function ef(e,t){let n,r=G(e),o=q.get(r)??Promise.resolve(),i=new Promise(e=>{n=e});q.set(r,i),await o.catch(()=>void 0);try{return await t()}finally{n(),q.get(r)===i&&q.delete(r)}}function em(e){if(e?.aborted)throw e.reason instanceof Error?e.reason:Error("operation aborted")}function eg(e,t){return new Promise((n,r)=>{if(t?.aborted)return void r(t.reason instanceof Error?t.reason:Error("operation aborted"));let o=new AbortController,i=setTimeout(()=>{o.abort(),n()},e);t?.addEventListener("abort",()=>{clearTimeout(i),o.abort(),r(t?.reason instanceof Error?t.reason:Error("operation aborted"))},{once:!0,signal:o.signal})})}let e_={schemaVersion:1,cliVersion:h,deviceAppVersion:"1.0.9",packages:{"darwin-arm64":{url:"https://lf3-cdn-tos.bytegoofy.com/obj/tron-demo/7610358476778248474/468636861/1.0.9/darwin-arm64/DoubaoDeveloperTools-v1.0.9-darwin-arm64.zip",sha256:"1b1aaf58f109efdc7cf0107a533ea043807d5f17c5ea9e001cede78511ae80b3",entry:"豆包开发者工具.app",sizeBytes:0x77fdf68},"win32-x64":{url:"https://lf3-cdn-tos.bytegoofy.com/obj/tron-demo/7610358476778248474/468636861/1.0.9/win32-x64/DoubaoDeveloperTools-v1.0.9-win32-x64.zip",sha256:"903ee97e1560006293afc978c16476d0b34c4789d03a709b200cb59da8fa4556",entry:"豆包开发者工具.exe",sizeBytes:0x84c4d6c}}},ew=e("node:child_process"),ey=e("node:crypto");var eb=e.n(ey);let ev=e("node:fs");var eE=e.n(ev);let eI=e("node:http"),eA=e("node:os");var eT=e.n(eA);let eC=e("node:path");var ek=e.n(eC);let eS=e("node:stream"),ej=e("node:url"),eD=e("node:util"),eP=e("../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/index.js"),ex=e("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/index.js"),eL="DBX_DEVICE_APP_PATH",eR="dbx-device-app.json",eO="state.json",e$="versions",eN=ek().dirname((0,ej.fileURLToPath)(import.meta.url)),eq=[{command:"web",description:"打开 Web 模拟器"},{command:"desktop",description:"进入桌面端工具,可进行真机调试"},{command:"status",description:"查看本地调试服务状态"}],eM=[{command:"qr",description:"重新生成真机调试二维码"},{command:"page [url]",description:"在真机打开页面(省略 url 可选择)"},{command:"pages",description:"列出真机可打开页面"},{command:"widget [id]",description:"向真机推送卡片(省略 id 可选择)"},{command:"widgets",description:"列出真机可推送卡片"},{command:"sessions",description:"列出当前可检查的 Lynx sessions"},{command:"use-session <@client:session|latest>",description:"固定 CLI session 或恢复跟随最新"},{command:"get-console",description:"持续输出当前 Lynx 页面新产生的日志"},{command:"take-screenshot",description:"截取当前 Lynx 页面画面"},{command:"get-page-tree",description:"获取当前 Lynx 页面的 DOM 树"},{command:"get-computed-style [node-ref]",description:"获取 DOM 节点的 computed style"},{command:"back",description:"返回主命令"}];function eB(e){if("complete"===e.phase)return`豆包开发者工具已安装:${e.appPath}`;if("install"===e.phase){let t={verify:"验证",extract:"解压",install:"安装"}[e.stage];return`安装豆包开发者工具:${t}`}let t=[void 0===e.percentage?void 0:`${e.percentage}%`,void 0===e.totalBytes?e.downloadedBytes>0?ts(e.downloadedBytes):void 0:`${ts(e.downloadedBytes)} / ${ts(e.totalBytes)}`,`${Math.max(0,Math.round(e.elapsedMs/1e3))}s`].filter(e=>!!e);return`下载豆包开发者工具:${t.join(" \xb7 ")}`}function eU(e,t){let n,r=!1;return o=>{if(!o)return void t?.(void 0);if("download"===o.phase){n=o,t?.(o);return}if(n&&!r&&(r=!0,ne(e,`✓ ${eB(n)}`)),"complete"===o.phase){t?.(void 0),ne(e,`✓ ${eB(o)}`);return}t?.(o)}}function eF(e,t){if("true"===e)return!0;if("false"===e)return!1;throw Error(`${t} must be "true" or "false"`)}async function eV(e){let t,n,r,o,i=e.output??process.stderr,s=e.client??await a({projectPath:e.projectPath,appDir:e.appDir,nodeIdPrefix:"dev-shell"}),d=e.closeDeviceApp??e3,l=new AbortController,c=e.openBrowser??I,u=new Set,p={runtime:e.runtime,client:s,output:i,manageDeviceApp:!0,runtimeInspectionTargetPolicy:{kind:"latest"},openBrowser:c,openQRCodeViewer:e.openQRCodeViewer??((e,t,n)=>t3(e,c,t,i,n)),signal:l.signal,launchDeviceApp:e.launchDeviceApp??(e=>e2(e,i)),closeDeviceApp:d,prepareDeviceApp:e.prepareDeviceApp??(e=>e4(i,e)),...e.onDeviceAppSetupProgress?{onDeviceAppSetupProgress:e.onDeviceAppSetupProgress}:{},openPreparedDeviceApp:e.openPreparedDeviceApp??e5,runRealDeviceAuth:e.runRealDeviceAuth??tH,...e.realDeviceDebugCoordinator?{realDeviceDebugCoordinator:e.realDeviceDebugCoordinator}:{},...e.createRuntimeInspectionSession?{createRuntimeInspectionSession:e.createRuntimeInspectionSession}:{},listAppVersions:e.listAppVersions??(async e=>{let t=await E(e);return t.data?.version_list??[]}),selectItem:e.selectItem,eventTracking:e.eventTracking},h=(e.createRuntimeInspectionSession??B)({namespace:e.runtime.getState().namespace,nodeIdPrefix:"dev-shell-runtime-inspection"});h.catch(()=>void 0),p.runtimeInspectionSession=h;let f=async()=>r||(r=(async()=>{p.activeDeviceId=void 0,t5(),p.manageDeviceApp&&await eY(p)})().finally(()=>{r=void 0})),m=tX(e.runtime.getState().namespace,async()=>{if(p.activeDeviceId&&!o){ne(i,"检测到真机连接断开,正在返回主命令并清理真机调试资源..."),await f();for(let e of u)try{e("client-disconnected")}catch{}}});return await m.start(),{stopped:e.runtime.stopped,getState:()=>e.runtime.getState(),execute(e){let r=new AbortController,o=AbortSignal.any([l.signal,r.signal]);n=r,p.signal=o;let i=eH(e,p);return t=i,i.finally(()=>{t===i&&(t=void 0),n===r&&(n=void 0),p.signal===o&&(p.signal=l.signal)})},cancelActiveCommand(){if(!n||n.signal.aborted)return!1;let e=Error("command cancelled");return e.name="AbortError",n.abort(e),!0},returnToRoot:()=>eK(p,"back","execute",f),handleClientDisconnected:()=>f(),subscribe:e=>(u.add(e),()=>{u.delete(e)}),close:()=>o??=(async()=>{l.abort(new tQ),await t?.catch(()=>void 0),await m.stop().catch(()=>void 0),await f(),await p.runtimeInspectionSession?.then(e=>e.stop()).catch(()=>void 0),await s.stop().catch(()=>void 0),await e.runtime.stop().catch(()=>void 0)})()}}async function eH(e,t){var n;let r;try{r=function(e){let t,n=[],r="",o=!1,i=()=>{r.length>0&&(n.push(r),r="")};for(let n of e.trim()){if(o){r+=n,o=!1;continue}if("\\"===n&&"'"!==t){o=!0;continue}if("'"===n||'"'===n){if(!t){t=n;continue}if(t===n){t=void 0;continue}}if(!t&&/\s/.test(n)){i();continue}r+=n}if(o&&(r+="\\"),t)throw Error(`unterminated ${t} quote`);return i(),n}(e)}catch(e){return ne(t.output,tG(nn(e))),"continue"}let o=r[0]?.toLowerCase(),i=r.slice(1);if(!o)return"continue";if((n=i).includes("--help")||n.includes("-h")){let e="desktop"===o&&i[0]&&!i[0].startsWith("-")?`desktop ${i[0].toLowerCase()}`:o;if(function(e,t){switch(t){case"desktop widget":return ne(e,"usage: widget [widget-id] [--data <json>] [--bot-id <id>] [--device-id <id>]"),ne(e,"推送卡片到已连接真机;省略 widget-id 时从 `widgets` 列表中选择。"),!0;case"desktop page":return ne(e,"usage: page [url] [--device-id <id>]"),ne(e,"通过完整 URL 打开页面;省略 url 时从 `pages` 列表中选择。页面参数请写入 URL query。"),!0;case"desktop":ne(e,"usage: desktop [--agent] [--mcp] [--timeout <seconds>] [--qr-file <file.png>] [--wifi-connect <true|false>] [--defaultDebugTagState <true|false>]"),ne(e,"进入真机模式并连接调试设备,默认准备并打开豆包开发者工具。"),ne(e,"使用 `desktop --agent` 进入 Agent 模式,不准备、启动或关闭豆包开发者工具。"),ne(e,"使用 --mcp 进入 MCP 端到端调试,并从当前 AppID 的版本列表中选择 versionTag。");for(let t of(ne(e,"真机调试命令"),eM))ne(e,` ${t.command.padEnd(22)}${t.description}`);return ne(e,"进入真机模式后执行 `<命令> --help` 查看参数。"),ne(e,"get-page-tree、get-computed-style、take-screenshot 支持通用的 --json 输出。"),!0;case"desktop qr":return ne(e,"usage: qr [--mcp] [--timeout <seconds>] [--qr-file <file.png>] [--wifi-connect <true|false>] [--defaultDebugTagState <true|false>]"),ne(e,"重新生成真机调试二维码;MCP 端到端调试会沿用已选择的 versionTag,也可用 --mcp 重新选择。"),!0;case"desktop get-console":return ne(e,"usage: get-console [--target <@client:session>] [--limit <count>] [--timeout-seconds <seconds>] [--include-stack-traces]"),ne(e,"持续输出当前 Lynx session 新产生的 console 日志;按 Ctrl+C 停止监听并返回真机命令。"),ne(e,"默认仅 error 日志显示调用栈;使用 --include-stack-traces 展开所有日志的调用栈。"),!0;case"desktop sessions":return ne(e,"usage: sessions"),ne(e,"列出当前可检查的 Lynx sessions,并标记 latest、CLI fixed 和 Electron current。"),!0;case"desktop use-session":return ne(e,"usage: use-session <@client:session|latest>"),ne(e,"固定 CLI 后续检查命令使用的 session,或用 latest 恢复到鉴权 client 内最新活跃 session;不会切换 Electron。"),!0;case"desktop take-screenshot":return ne(e,"usage: take-screenshot [--target <@client:session>] [-o, --output <file.jpeg>] [--json]"),ne(e,"保存 Electron 当前为目标 session 输出的最近一帧 JPEG;截图范围跟随 Electron 当前 mode。"),!0;case"desktop get-page-tree":return ne(e,"usage: get-page-tree [--target <@client:session>] [--depth <-1|n>] [--json]"),ne(e,"获取当前 Lynx session 的 DevTools Elements DOM 树;默认 depth=-1。"),ne(e,"终端输出紧凑树;--json 输出节点文本、完整 attributes 和可复用 node-ref。"),!0;case"desktop get-computed-style":return ne(e,"usage: get-computed-style <node-ref> [--properties <name,...>] [--json]"),ne(e,"获取元素节点的 computed style;node-ref 格式为 @<clientId>:<sessionId>:<nodeId>。"),ne(e,"省略 --properties 返回全部属性,例如 --properties color,font-size。"),!0;case"web":return ne(e,"usage: web"),ne(e,"在默认浏览器打开本地 Web 模拟器。"),!0;case"desktop pages":case"desktop widgets":{let n="desktop pages"===t?"打开的页面":"推送的卡片";return ne(e,`usage: ${t.slice(8)}`),ne(e,`列出真机可${n}。`),!0}case"status":return ne(e,"usage: status"),ne(e,"查看本地调试服务状态。"),!0;default:return!1}}(t.output,e))return"continue"}try{switch(o){case"status":return await eK(t,"status","execute",()=>eW(t)),"continue";case"web":return await eK(t,"web_open","execute",()=>eG(t)),"continue";case"desktop":return await ez(t,i)?"enter-device":"continue";case"device":return ne(t.output,"命令 `device` 已更名为 `desktop`,请改用 `desktop`。"),"continue";default:return ne(t.output,`unknown command: ${o}`),["qr","pages","page","widgets","widget","sessions","use-session","get-console","take-screenshot","get-page-tree","get-computed-style"].includes(o)&&ne(t.output,`\`${o}\` is only available in desktop mode; run \`desktop\` first.`),"continue"}}catch(e){return ne(t.output,tG(nn(e))),"continue"}}async function eK(e,t,n,r){let o=e.eventTracking;return o?f({action:t,actionSequence:++o.actionSequence,appId:o.appId??e.runtime.getState().appId,devSessionId:o.devSessionId,errorStage:n},r):r()}async function ez(e,t){let r=t[0]?.toLowerCase();if(!r||r.startsWith("-"))return await eJ(e,t,{reuseDeviceAppMode:!1,reuseVersionTag:!1}),!0;let o=function(e){let t=!1,n=[];for(let r of e)"--json"===r?t=!0:n.push(r);return{args:n,json:t}}(t.slice(1)),i=["get-page-tree","get-computed-style","take-screenshot"].includes(r);try{if(o.json&&!i)throw Error(`--json is not supported by desktop ${r}; use it with get-page-tree, get-computed-style, or take-screenshot`);switch(r){case"qr":return await e0(e,o.args),!0;case"pages":return await eK(e,"pages_list","execute",()=>tS(e,"page",n.discoverPages)),!0;case"page":return await eK(e,"page_push","page_push",()=>tM(e,o.args)),!0;case"widgets":return await eK(e,"widgets_list","execute",()=>tS(e,"widget",n.discoverWidgets)),!0;case"widget":return await eK(e,"widget_push","widget_push",()=>tB(e,o.args)),!0;case"sessions":return await eK(e,"sessions_list","execute",()=>tj(e,o.args)),!0;case"use-session":return await eK(e,"session_select","execute",()=>tD(e,o.args)),!0;case"get-console":return await eK(e,"console_stream","execute",()=>tP(e,o.args)),!0;case"take-screenshot":return await eK(e,"screenshot","execute",()=>tx(e,o.args,o.json)),!0;case"get-page-tree":return await eK(e,"page_tree","execute",()=>tL(e,o.args,o.json)),!0;case"get-computed-style":return await eK(e,"computed_style","execute",()=>tR(e,o.args,o.json)),!0;default:return ne(e.output,`unknown desktop subcommand: ${r}`),!1}}catch(t){if(!o.json||!i)throw t;return nt(e.output,{ok:!1,error:{code:t instanceof M?t.code:"INSPECTION_FAILED",message:nn(t)}}),!0}}async function eY(e){try{var t,n;let r=await e.closeDeviceApp();t=e.output,n=r,"closed"===n.status?ne(t,`豆包开发者工具已关闭:${n.appPath}`):ne(t,`关闭豆包开发者工具失败${n.reason?`:${tG(n.reason)}`:""}`)}catch(t){ne(e.output,`关闭豆包开发者工具失败:${tG(nn(t))}`)}}async function eW(e){let t=await e.client.call(n.getInfo);ne(e.output,`status: ${t.status}`),ne(e.output,`app_id: ${t.appId??"-"}`),ne(e.output,`dev_server: ${t.host??"-"}`),ne(e.output,`web_debugger: ${t.webDebuggerUrl??"-"}`)}async function eG(e){let t=await e.client.call(n.openWebDebugger);ne(e.output,`Web 模拟器已打开:${t}`)}async function eJ(e,t,n){let r=()=>e.realDeviceDebugCoordinator?e.realDeviceDebugCoordinator.runTerminal(()=>eQ(e,t,n)):eQ(e,t,n),o=e.eventTracking;if(!o)return void await r();let i=++o.actionSequence,s=performance.now(),a=n.reuseDeviceAppMode?"qr_refresh":"device_connect";try{let t=await r(),n=t?.status==="connected"?"success":t?.status==="cancelled"?"cancelled":t?.status==="timeout"?"timeout":t?.error?"failed":"skipped";await g({action:a,actionSequence:i,appId:o.appId??e.runtime.getState().appId,devSessionId:o.devSessionId,durationMs:performance.now()-s,...t?.error?{error:t.error,...t.failureStage?{errorStage:t.failureStage}:{},errorType:"device_connection_error"}:{},status:n})}catch(t){throw await g({action:a,actionSequence:i,appId:o.appId??e.runtime.getState().appId,devSessionId:o.devSessionId,durationMs:performance.now()-s,error:t,errorStage:"prepare_device_tool",errorType:"device_connection_error",status:b(t)}),t}}async function eQ(e,t,n){var r,o,i;let s,a,d,l=(0,eD.parseArgs)({args:t,allowPositionals:!1,options:{agent:{type:"boolean"},timeout:{type:"string"},"qr-file":{type:"string"},mcp:{type:"boolean"},"wifi-connect":{type:"string"},defaultDebugTagState:{type:"string"}}});if(n.reuseDeviceAppMode&&l.values.agent)throw Error("--agent is only supported when entering desktop mode");n.reuseDeviceAppMode||(e.manageDeviceApp=!l.values.agent);let c=function(e){if(void 0===e)return;let t=Number(e);if(!Number.isFinite(t)||t<=0)throw Error("--timeout must be a positive number of seconds");return Math.round(1e3*t)}(l.values.timeout),u=function(e){if(!e)return;let t=ek().resolve(e);if(".png"!==ek().extname(t).toLowerCase())throw Error("--qr-file must point to a .png file");return t}(l.values["qr-file"]),p=tz((r={defaultDebugTagState:l.values.defaultDebugTagState,wifiConnect:l.values["wifi-connect"]},d={},void 0!==r.defaultDebugTagState&&(d.defaultDebugTagState=eF(r.defaultDebugTagState,"--defaultDebugTagState")),void 0!==r.wifiConnect&&(d.usb=!eF(r.wifiConnect,"--wifi-connect")),Object.keys(d).length>0?d:void 0)),h=await e.client.call("dev.setConnectionTransport",{type:p.usb?"usb":"wifi"}),f=e.runtime.getState(),m=l.values.mcp?await eX(e,f.appId):n.reuseVersionTag?e.activeVersionTag:void 0;if(l.values.mcp&&!m)return;e.activeVersionTag=m,m&&!l.values.mcp&&ne(e.output,`沿用 MCP 端到端调试 versionTag:${m}`),e.manageDeviceApp||ne(e.output,"已启用 --agent:不会准备、启动或关闭豆包开发者工具。");let g={namespace:f.namespace,projectPath:f.projectPath,appDir:f.appDir,appKey:f.appId,hostUrl:f.host},_=e.manageDeviceApp?await eZ(e):void 0;if(_?.status==="skipped"){let t=_.reason??"豆包开发者工具准备失败";return ne(e.output,`启动真机调试失败:${tG(t)}`),{ok:!1,status:"skipped",timeoutMs:c??6e4,failureStage:"prepare_device_tool",error:t}}t5();let w=new AbortController,y=e.signal?AbortSignal.any([e.signal,w.signal]):w.signal;try{a=await e.runRealDeviceAuth({hostUrl:h.host||f.host,appKey:h.appId||f.appId,versionTag:m,namespace:f.namespace,timeoutMs:c,settings:p,wifiConnectUrl:h.wifiConnectUrl,output:e.output,signal:y,onQRCodeReady:async(t,n)=>{(s=await e.openQRCodeViewer(t,u,n)).closed.then(()=>{w.abort(new tQ)})}})}finally{await s?.close().catch(()=>void 0),t5()}if(function(e,t){let n;if(t.ok){let n=t.client?.clientId===void 0?"":`:client ${t.client.clientId}`,r=t.qrCodeValue?"扫码鉴权完成":"复用已连接设备,已跳过二维码鉴权";ne(e,`真机调试已连接${n}(${r})。`);return}"cancelled"===t.status?ne(e,"install"===t.waitingFor?"二维码页面已关闭,已取消等待设备安装。":"二维码页面已关闭,已取消等待设备连接。"):(n="timeout"===t.status?"install"===t.waitingFor?`设备已连接,但等待安装完成超时(${Math.max(1,Math.ceil(t.timeoutMs/1e3))} 秒)`:`等待设备连接超时(${Math.max(1,Math.ceil(t.timeoutMs/1e3))} 秒)`:tG(t.error??"未知错误"),ne(e,`启动真机调试失败:${n}`))}(e.output,a),a.ok&&"connected"===a.status){a.client?.clientId!==void 0&&(void 0!==e.activeClientId&&e.activeClientId!==a.client.clientId&&(e.runtimeInspectionTargetPolicy={kind:"latest"}),e.activeClientId=a.client.clientId);let t=a.client?.deviceId??(a.client?.clientId===void 0?void 0:String(a.client.clientId));t&&(e.activeDeviceId=t)}if(e.manageDeviceApp&&a.ok&&"connected"===a.status){let t=_?await e1(e,_,g):await e.launchDeviceApp(g);o=e.output,"opened"===(i=t).status?ne(o,`豆包开发者工具已启动:${i.appPath}`):ne(o,`启动豆包开发者工具失败${i.reason?`:${tG(i.reason)}`:""}`)}return a}async function eX(e,t){if(!t)throw Error("无法查询 versionTag,当前工程缺少 AppID。");let n=(await e.listAppVersions(t)).filter(e=>"string"==typeof e.version_tag&&!!e.version_tag.trim());if(!n.length)throw Error(`当前 AppID(${t})没有可选的 versionTag。`);let r=await e.selectItem("versionTag",n,e.output);return r?(ne(e.output,`MCP 端到端调试 versionTag:${r}`),r):void ne(e.output,"已取消 versionTag 选择,未生成二维码。")}async function eZ(e){if(e.prepareDeviceApp){e.onDeviceAppSetupProgress?.(void 0);try{return await e.prepareDeviceApp({onProgress:eU(e.output,e.onDeviceAppSetupProgress),signal:e.signal})}catch(t){return e.onDeviceAppSetupProgress?.(void 0),{status:"skipped",reason:nn(t)}}}}async function e0(e,t){await eJ(e,t,{reuseDeviceAppMode:!0,reuseVersionTag:!0})}async function e1(e,t,n){return"skipped"!==t.status&&t.appPath?e.openPreparedDeviceApp?e.openPreparedDeviceApp(t.appPath,n):e.launchDeviceApp(n):{status:"skipped",reason:t.reason}}async function e2(e,t=process.stderr){let n=await e4(t);return"skipped"!==n.status&&n.appPath?e5(n.appPath,e):{status:"skipped",reason:n.reason}}async function e4(e=process.stderr,t={}){let n=function(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,o=e.appDir??te(),i=e.manifest??e_,s=tn(t);if(t[eL]?.trim()||!s&&e7({...t,[eL]:""},n,o))return;tf(i);let a=tt(n,r);if(!a)return;let d=i.packages[a];if(!d)return;tm(d);let l=tg(i,d),c=e9(t,n);if(!(!s&&tr(c,i,a,d,l)))return{platform:a,version:l,...void 0===d.sizeBytes?{}:{sizeBytes:d.sizeBytes}}}();return n&&!t.onProgress&&(ne(e,"真机调试准备:"),ne(e,`首次或版本更新需要下载豆包开发者工具${n.sizeBytes?`(${ts(n.sizeBytes)})`:""}。`),ne(e,"下载完成后才会生成二维码;下载耗时取决于网络,进度和实际耗时将持续显示。")),await e6({runner:{onProgress:t.onProgress??eU(e),signal:t.signal}})}async function e5(e,t){return await function(e,t,n=process.platform){var r,o,i;let s,a=(r=e,o=n,s=(i=t)?[["namespace",i.namespace],["project",i.appDir??i.projectPath],["app-key",i.appKey],["host-url",i.hostUrl]].flatMap(([e,t])=>t?[`--${e}=${t}`]:[]):[],"darwin"===o?{command:"open",args:[r,...s.length?["--args",...s]:[]]}:"win32"===o?{command:"cmd",args:["/c","start","",r,...s],windowsVerbatimArguments:!0}:{command:r,args:s});return new Promise((e,t)=>{let n=(0,ew.spawn)(a.command,a.args,{stdio:"ignore",windowsVerbatimArguments:a.windowsVerbatimArguments});n.once("error",t),n.once("spawn",e)})}(e,t),{status:"opened",appPath:e}}async function e3(){let e=function(e=process.env,t=process.platform,n=process.arch,r=te()){let o=e[eL]?.trim();if(o)return ek().resolve(o);let i=e7({...e,[eL]:""},t,r);if(i)return i;let s=tt(t,n);if(!s)return;let a=e9(e,t),d=tl(a);if(!d||d.platform!==s)return;let l=ty(tp(a,d.activeDeviceAppVersion),d.entry,"device app state entry");return eE().existsSync(l)?l:void 0}();return e?(await function(e,t=process.platform){return"darwin"===t?tI(e):tA(tC(e,t),{rejectOnNonZero:!0}).then(()=>void 0)}(e),{status:"closed",appPath:e}):{status:"skipped",reason:`${eL} is not set and no packaged or cached device app was found`}}async function e6(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,o=e.appDir??te(),i=tn(t),s=t[eL]?.trim();if(s)return{status:"found",appPath:ek().resolve(s),source:"env"};if(!i){let e=e7({...t,[eL]:""},n,o);if(e)return{status:"found",appPath:e,source:"packaged"}}return e8({env:t,platform:n,arch:r,appDir:o,manifest:e.manifest,runner:e.runner})}async function e8(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,o=e.manifest??e_;tf(o);let i=tt(n,r);if(!i)return{status:"skipped",reason:`device app download is not supported on ${n}/${r}`};let s=o.packages[i];if(!s)return{status:"skipped",reason:`device app package is not configured for ${i} in CLI ${o.cliVersion}`};let a=e9(t,n),d=tg(o,s);if(!tn(t)){let e=tr(a,o,i,s,d);if(e)return tc(a,d),{status:"found",appPath:e,source:"cache"}}let l=await to(a,o,i,s,n,e.runner);return tc(a,d),{status:"found",appPath:l,source:"downloaded"}}function e7(e=process.env,t=process.platform,n=te()){let r=e[eL]?.trim();if(r)return ek().resolve(r);if(!eE().existsSync(n))return;let o=eE().readdirSync(n,{withFileTypes:!0}).find(e=>{var n,r;return n=e,"darwin"===(r=t)?n.isDirectory()&&n.name.endsWith(".app"):"win32"===r?n.isFile()&&n.name.toLowerCase().endsWith(".exe"):n.isFile()&&/\.(appimage|AppImage)$/.test(n.name)});return o?ek().join(n,o.name):void 0}function e9(e=process.env,t=process.platform){let n=e.DBX_DEVICE_APP_CACHE_DIR?.trim();if(n)return ek().resolve(n);if("darwin"===t)return ek().join(eT().homedir(),"Library","Application Support","dbx","device-app");if("win32"===t){let t=e.LOCALAPPDATA?.trim()||ek().join(eT().homedir(),"AppData","Local");return ek().join(t,"dbx","device-app")}return ek().join(eT().homedir(),".local","share","dbx","device-app")}function te(){return ek().resolve(eN,"../../..","device-app")}function tt(e,t){if(("darwin"===e||"win32"===e)&&("arm64"===t||"x64"===t))return`${e}-${t}`}function tn(e){let t=e.DBX_DEVICE_APP_FORCE_DOWNLOAD?.trim().toLowerCase();return!!(t&&"0"!==t&&"false"!==t)}function tr(e,t,n,r,o){var i,s,a,d,l;let c,u=tl(e);if(!u||u.activeDeviceAppVersion!==o||u.cliVersion!==t.cliVersion||u.platform!==n||!tw(u.sha256,r)||u.entry!==r.entry)return;let p=tp(e,o);if(i=p,s=t,a=n,d=r,l=o,!((c=td(i))&&c.cliVersion===s.cliVersion&&c.deviceAppVersion===l&&c.entry===d.entry&&c.platform===a&&tw(c.sha256,d)))return;let h=ty(p,r.entry,"device app entry");return eE().existsSync(h)?h:void 0}async function to(e,t,n,r,o,i={}){tm(r);let s=tg(t,r),a=i.now?.()??Date.now(),d=ek().join(e,".tmp");eE().mkdirSync(d,{recursive:!0}),eE().mkdirSync(ek().join(e,e$),{recursive:!0});let l=eE().mkdtempSync(ek().join(d,`${s}-`)),c=ek().join(l,"device-app.zip"),u=ek().join(l,"extract"),p=tp(e,s);try{var h,f,m,g,_,w,y,b;let d,l;if(i.onProgress?.({phase:"download",downloadedBytes:0,...void 0===r.sizeBytes?{}:{totalBytes:r.sizeBytes,percentage:0},elapsedMs:0}),await ti(r.url,c,i.fetch,i.onProgress,i.signal),r.sha256&&(i.onProgress?.({phase:"install",stage:"verify"}),i.signal?.throwIfAborted(),d=await tu(c),i.signal?.throwIfAborted(),d!==t_(r.sha256)))throw Error(`device app sha256 mismatch: expected ${r.sha256}, got ${d}`);eE().mkdirSync(u,{recursive:!0}),i.onProgress?.({phase:"install",stage:"extract"}),await ta(c,u,o,i);let v=ty(u,r.entry,"device app package entry");(function(e,t){if(!eE().existsSync(e))throw Error(`device app entry not found after extraction: ${e}`);let n=eE().statSync(e);if("darwin"===t){if(!n.isDirectory()||!e.endsWith(".app"))throw Error(`macOS device app entry must be a .app directory: ${e}`);return}if("win32"===t&&(!n.isFile()||!e.toLowerCase().endsWith(".exe")))throw Error(`Windows device app entry must be an .exe file: ${e}`)})(v,o),function(e,t,n,r,o){let i=td(e);if(i&&(i.cliVersion!==t.cliVersion||i.deviceAppVersion!==o||i.entry!==r.entry||i.platform!==n||!tw(i.sha256,r)))throw Error(`device app metadata does not match CLI manifest in ${ek().join(e,eR)}`)}(u,t,n,r,s),i.onProgress?.({phase:"install",stage:"install"}),eE().rmSync(p,{recursive:!0,force:!0}),eE().renameSync(u,p),h=p,f=t,m=n,g=r,_=s,w=a,l={name:"Doubao App V2",cliVersion:f.cliVersion,deviceAppVersion:_,entry:g.entry,platform:m,...g.sha256?{sha256:t_(g.sha256)}:{},installedAt:w},tE(ek().join(h,eR),l),y=e,b={activeDeviceAppVersion:s,cliVersion:t.cliVersion,entry:r.entry,platform:n,...r.sha256?{sha256:t_(r.sha256)}:{},installedAt:a},tE(ek().join(y,eO),b);let E=ty(p,r.entry,"device app entry");return i.onProgress?.({phase:"complete",appPath:E}),E}finally{eE().rmSync(l,{recursive:!0,force:!0})}}async function ti(e,n,r=fetch,o,i){var s,a;let d,l,c,u,p,h,f=new URL(e);if("https:"!==f.protocol&&"http:"!==f.protocol)throw Error(`device app package URL must be http(s): ${e}`);i?.throwIfAborted();let m=await r(e,{signal:i});if(!m.ok)throw Error(`device app package download failed: HTTP ${m.status} ${m.statusText}`);if(!m.body)throw Error("device app package download failed: empty response body");let g=m.body;await (0,t.pipeline)(eS.Readable.fromWeb(g),(s=m,a=o,d=function(e){if(!e)return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}(s.headers.get("content-length")),l=0,c=-1,u=0,p=Date.now(),(h=e=>{if(!a)return;if(d){let t=Math.min(100,Math.floor(l/d*100));if(!e&&100!==t&&t<c+10||t===c)return;c=t;let n=Date.now()-p;a({phase:"download",downloadedBytes:l,totalBytes:d,percentage:t,elapsedMs:n});return}if(!e&&l-u<0x3200000||l===u)return;u=l;let t=Date.now()-p;a({phase:"download",downloadedBytes:l,elapsedMs:t})})(!1),new eS.Transform({transform(e,t,n){l+=e.length,h(!1),n(null,e)},flush(e){h(!0),e()}})),eE().createWriteStream(n),{signal:i})}function ts(e){let t=["B","KB","MB","GB"],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return 0===r?`${n} ${t[r]}`:`${n.toFixed(1)} ${t[r]}`}async function ta(e,t,n,r){let o=r.runCommand??((e,t)=>tA(e,{rejectOnNonZero:!0,signal:t?.signal}).then(()=>void 0));if("darwin"===n){r.signal?.throwIfAborted(),await o({command:"ditto",args:["-x","-k",e,t]},{signal:r.signal});return}if("win32"===n){r.signal?.throwIfAborted(),await o({command:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","Bypass","-Command",`Expand-Archive -LiteralPath ${tb(e)} -DestinationPath ${tb(t)} -Force`],windowsVerbatimArguments:!0},{signal:r.signal});return}throw Error(`device app zip extraction is not supported on ${n}`)}function td(e){let t=tv(ek().join(e,eR));if(!c(t))return;let n=t.cliVersion,r=t.deviceAppVersion,o=t.entry,i=t.platform,s=t.sha256,a=t.installedAt;if("string"==typeof n&&"string"==typeof r&&"string"==typeof o&&"string"==typeof i&&(void 0===s||"string"==typeof s)&&"number"==typeof a)return{name:"string"==typeof t.name?t.name:void 0,cliVersion:n,deviceAppVersion:r,entry:o,platform:i,..."string"==typeof s?{sha256:s}:{},installedAt:a}}function tl(e){let t=tv(ek().join(e,eO));if(c(t)&&"string"==typeof t.activeDeviceAppVersion&&"string"==typeof t.cliVersion&&"string"==typeof t.entry&&"string"==typeof t.platform&&(void 0===t.sha256||"string"==typeof t.sha256)&&"number"==typeof t.installedAt)return{activeDeviceAppVersion:t.activeDeviceAppVersion,cliVersion:t.cliVersion,entry:t.entry,platform:t.platform,..."string"==typeof t.sha256?{sha256:t.sha256}:{},installedAt:t.installedAt}}function tc(e,t){let n=ek().join(e,e$);if(eE().existsSync(n)){for(let e of eE().readdirSync(n,{withFileTypes:!0}))if(e.isDirectory()&&e.name!==t)try{eE().rmSync(ek().join(n,e.name),{recursive:!0,force:!0})}catch{}}}async function tu(e){let n=eb().createHash("sha256");return await (0,t.pipeline)(eE().createReadStream(e),n),n.digest("hex")}function tp(e,t){return th(t),ek().join(e,e$,t)}function th(e){if(!/^[0-9A-Za-z._+-]+$/.test(e))throw Error(`device app version contains unsupported path characters: ${e}`)}function tf(e){if(1!==e.schemaVersion)throw Error(`unsupported device app manifest schemaVersion: ${e.schemaVersion}`);if(!e.cliVersion.trim())throw Error("device app manifest cliVersion is required");if(!e.deviceAppVersion.trim())throw Error("device app manifest deviceAppVersion is required");th(e.deviceAppVersion)}function tm(e){if(!e.url||!e.entry)throw Error("device app package requires url and entry");if(void 0!==e.version){if(!e.version.trim())throw Error("device app package version must not be empty");th(e.version)}if(e.sha256&&!/^[0-9a-fA-F]{64}$/.test(e.sha256))throw Error(`device app package sha256 must be 64 hex characters: ${e.sha256}`);if(void 0!==e.sizeBytes&&(!Number.isSafeInteger(e.sizeBytes)||e.sizeBytes<=0))throw Error(`device app package sizeBytes must be a positive integer: ${e.sizeBytes}`);if(ek().isAbsolute(e.entry)||e.entry.split(/[\\/]+/).includes(".."))throw Error(`device app package entry must be a relative path inside the zip: ${e.entry}`)}function tg(e,t){let n=t.version??e.deviceAppVersion;if(!n.trim())throw Error("device app package version must not be empty");return th(n),n}function t_(e){return e.toLowerCase()}function tw(e,t){return!t.sha256||e===t_(t.sha256)}function ty(e,t,n){if(ek().isAbsolute(t))throw Error(`${n} must be relative: ${t}`);let r=ek().resolve(e),o=ek().resolve(e,t);if(o!==r&&!o.startsWith(`${r}${ek().sep}`))throw Error(`${n} escapes target directory: ${t}`);return o}function tb(e){return`'${e.replace(/'/g,"''")}'`}function tv(e){try{return JSON.parse(eE().readFileSync(e,"utf8"))}catch{return}}function tE(e,t){eE().mkdirSync(ek().dirname(e),{recursive:!0}),eE().writeFileSync(e,`${JSON.stringify(t,null,2)}
13
- `,"utf8")}async function tI(e){let t=function(e){if(!e.endsWith(".app"))return;let t=function(e){let t=ek().join(e,"Contents","Info.plist");if(!eE().existsSync(t))return;let n=eE().readFileSync(t,"utf8").match(/<key>CFBundleExecutable<\/key>\s*<string>([^<]+)<\/string>/);return n?.[1]}(e)??ek().basename(e,".app");return ek().join(e,"Contents","MacOS",t)}(e);await tA(tC(e,"darwin"),{rejectOnNonZero:!1}),!t||await tT(t)&&await tA({command:"pkill",args:["-f",tk(t)]},{rejectOnNonZero:!1})}function tA(e,t){return new Promise((n,r)=>{let o;t.signal?.throwIfAborted();let i=(0,ew.spawn)(e.command,e.args,{stdio:"ignore",windowsVerbatimArguments:e.windowsVerbatimArguments}),s=!1,a=()=>{i.kill(),(o=setTimeout(()=>i.kill("SIGKILL"),1e3)).unref()},d=e=>{s||(s=!0,clearTimeout(o),t.signal?.removeEventListener("abort",a),e())};t.signal?.addEventListener("abort",a,{once:!0}),i.once("error",e=>d(()=>r(e))),i.once("close",o=>{if(t.signal?.aborted)return void d(()=>r(t.signal?.reason instanceof Error?t.signal.reason:new tQ));let i=o??0;0!==i&&t.rejectOnNonZero?d(()=>r(Error(`${e.command} exited with code ${i}`))):d(()=>n(i))})})}async function tT(e){return 0===await tA({command:"pgrep",args:["-f",tk(e)]},{rejectOnNonZero:!1})}function tC(e,t){return"darwin"===t?{command:"osascript",args:["-e",`tell application (POSIX file "${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}" as alias) to quit`]}:"win32"===t?{command:"cmd",args:["/c","taskkill","/IM",ek().basename(e),"/T"],windowsVerbatimArguments:!0}:{command:"pkill",args:["-f",e]}}function tk(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function tS(e,t,n){let r=await e.client.call(n);if(!r.length)return void ne(e.output,`no ${t}s found`);for(let n of r)ne(e.output,`- ${t7(t,n)}`)}async function tj(e,t){if(t.length>0)throw Error("sessions does not accept arguments");let n=await tq(e,"sessions"),{session:r}=n;try{let t=await r.getConnectedClients();if(0===t.length)throw new M("DEVICE_NOT_CONNECTED","no debug device is connected");let n=t.flatMap(e=>e.sessions.filter(W).map(t=>({clientId:e.device.clientId,sessionId:t.sessionId,url:t.url}))).sort((e,t)=>e.clientId-t.clientId||t.sessionId-e.sessionId);if(0===n.length)throw new M("NO_ACTIVE_LYNX_SESSION","the connected device has no active Lynx session");let o=r.getRuntimeInspectionTarget?await r.getRuntimeInspectionTarget().catch(()=>null):null,i=tO(e),s=e.activeClientId??(1===t.length?t[0]?.device.clientId:void 0),a=void 0===s?void 0:n.find(e=>e.clientId===s);for(let t of n){let n=[t$(t,o)?"electron":void 0,"fixed"===i.kind&&t$(t,i.target)?"cli":void 0,t$(t,a)?"latest":void 0].filter(e=>void 0!==e);ne(e.output,`${F(t)}${n.length?` ${n.map(e=>`[${e}]`).join(" ")}`:""} ${t.url||"unknown"}`)}}finally{n.owned&&await r.stop().catch(()=>void 0)}}async function tD(e,t){if(1!==t.length)throw Error("use-session requires @<clientId>:<sessionId> or latest");if(t[0]?.toLowerCase()==="latest"){e.runtimeInspectionTargetPolicy={kind:"latest"},ne(e.output,A.bold.blueBright(`CLI 调试目标已恢复为 latest${void 0===e.activeClientId?"":`(client ${e.activeClientId} 内最新活跃 Lynx session)`};不会切换 Electron。`));return}let n=V(t[0]??""),r=await tq(e,"use-session"),{session:o}=r;try{let t=await U(o,{activeClientId:e.activeClientId,explicitTarget:n,signal:e.signal});e.runtimeInspectionTargetPolicy={kind:"fixed",target:{clientId:t.clientId,sessionId:t.sessionId}},ne(e.output,A.bold.blueBright(`CLI 调试目标已固定为 ${F(t)}(${t.url||"unknown"});不会切换 Electron。`))}finally{r.owned&&await o.stop().catch(()=>void 0)}}async function tP(e,t){let n=(0,eD.parseArgs)({args:t,allowPositionals:!1,options:{limit:{type:"string"},"timeout-seconds":{type:"string"},"include-stack-traces":{type:"boolean"},target:{type:"string"}}}),r=function(e){if(void 0===e)return;let t=Number(e);if(!Number.isSafeInteger(t)||t<1||t>100)throw Error("--limit must be an integer between 1 and 100");return t}(n.values.limit),o=function(e){if(void 0===e)return;let t=Number(e);if(!Number.isFinite(t)||t<=0)throw Error("--timeout-seconds must be a positive number");return Math.round(1e3*t)}(n.values["timeout-seconds"]),i=await tq(e,"get-console"),{session:s}=i;try{let t=await tN(e,s,n.values.target);ne(e.output,A.bold.blueBright(`正在监听 client ${t.clientId}、session ${t.sessionId}(${t.url||"unknown"})的新日志;按 Ctrl+C 停止监听。`));let i=await es(s,t,{...void 0===r?{}:{limit:r},...void 0===o?{}:{timeoutMs:o},signal:e.signal,onTargetChange(n){ne(e.output,A.bold.blueBright(`提示:Electron 已切换到 client ${n.clientId}、session ${n.sessionId}(${n.url||"unknown"});当前 CLI 仍监听 client ${t.clientId}、session ${t.sessionId},不会自动跟随 Electron。`))},onMessage(t){ne(e.output,function(e,t={}){var n;let r=e.args.map(ec).join(" "),o=t.includeStackTraces||"error"===e.type?(n=e.stackTrace,c(n)&&Array.isArray(n.callFrames)?n.callFrames.filter(c).map(e=>{let t="string"==typeof e.url?e.url:"",n="number"==typeof e.lineNumber?e.lineNumber:"unknown",r="number"==typeof e.columnNumber?e.columnNumber:"unknown";return` at ${t}:${n}:${r}`}).join("\n"):""):"";return`[${e.type}/${e.thread}] ${r}${o?`
14
- ${o}`:""}`}(t,{includeStackTraces:n.values["include-stack-traces"]}))}});ne(e.output,`日志监听已停止,共 ${i.count} 条。`)}finally{i.owned&&await s.stop().catch(()=>void 0)}}async function tx(e,t,n=!1){let r=(0,eD.parseArgs)({args:t,allowPositionals:!1,options:{output:{type:"string",short:"o"},target:{type:"string"}}}),o=await tq(e,"take-screenshot"),{session:i}=o;try{let t=await tN(e,i,r.values.target),o=await ea(i,t,{activeCapture:!e.manageDeviceApp}),s=ek().resolve(r.values.output??`screenshot-${Date.now()}.jpeg`);await eE().promises.writeFile(s,Buffer.from(o.data,"base64")),n?nt(e.output,{ok:!0,command:"take-screenshot",target:t,output:s,format:o.format,source:o.source,width:o.width,height:o.height,byteLength:o.byteLength}):ne(e.output,`截图已保存:${s}(${o.width}\xd7${o.height},client ${t.clientId}、session ${t.sessionId},${t.url||"unknown"};${e.manageDeviceApp?"范围跟随 Electron 当前 mode":"由设备按当前截图 mode 生成"})`)}finally{o.owned&&await i.stop().catch(()=>void 0)}}async function tL(e,t,n=!1){let r=(0,eD.parseArgs)({args:t,allowPositionals:!1,options:{depth:{type:"string"},target:{type:"string"}}}),o=function(e){if(void 0===e)return -1;let t=Number(e);if(!Number.isSafeInteger(t)||t<-1)throw Error("--depth must be -1 or a non-negative integer");return t}(r.values.depth),i=await tq(e,"get-page-tree"),{session:s}=i;try{let t=await tN(e,s,r.values.target),i=await z(s,t,{depth:o});if(n)nt(e.output,{ok:!0,command:"get-page-tree",...i});else{let n,r;ne(e.output,`DOM tree: client ${t.clientId}、session ${t.sessionId}(${t.url||"unknown"})`),ne(e.output,(n=[],(r=(e,t,o)=>{n.push(`${t}${o}${function(e){if(et(e))return`${e.ref} #text ${eo(e.nodeValue)}`;let t=(e.localName||e.nodeName).toLowerCase();if(t.startsWith("#"))return`${e.ref} ${t}`;let n=Object.entries(e.attributes).map(([e,t])=>`${e}=${eo(t,80)}`).join(" "),r=e.text||e.children.filter(et).map(e=>e.nodeValue).join("");return[e.ref,`<${t}${n?` ${n}`:""}>`,r?eo(r,120):""].filter(Boolean).join(" ")}(e)}`);let i=e.children.filter(e=>!et(e));i.forEach((e,n)=>{r(e,`${t}${o?"└─ "===o?" ":"│ ":""}`,n===i.length-1?"└─ ":"├─ ")})})(i.root,"",""),i.truncated&&n.push(`… tree truncated after ${i.nodeCount} nodes`),n.join("\n"))),ne(e.output,`共 ${i.nodeCount} 个节点${i.truncated?"(已截断)":""}。`)}}finally{i.owned&&await s.stop().catch(()=>void 0)}}async function tR(e,t,n=!1){let r=(0,eD.parseArgs)({args:t,allowPositionals:!0,options:{properties:{type:"string"}}}),o=r.positionals[0];if(!o)throw new M("INVALID_NODE_REF","node-ref is required; run get-page-tree and pass @<clientId>:<sessionId>:<nodeId>");if(r.positionals.length>1)throw Error("get-computed-style accepts exactly one node-ref");let i=function(e){let t=/^@([1-9]\d*):([1-9]\d*):([1-9]\d*)$/.exec(e.trim());if(!t)throw new M("INVALID_NODE_REF",`invalid node ref "${e}"; expected @<clientId>:<sessionId>:<nodeId>`);let n={clientId:Number(t[1]),sessionId:Number(t[2]),nodeId:Number(t[3])};if(!Number.isSafeInteger(n.clientId)||!Number.isSafeInteger(n.sessionId)||!Number.isSafeInteger(n.nodeId))throw new M("INVALID_NODE_REF",`invalid node ref "${e}"; every id must be a safe integer`);return n}(o),s=function(e){if(void 0===e)return[];let t=e.split(",").map(e=>e.trim());if(0===t.length||t.some(e=>!/^-{0,2}[a-z][a-z0-9-]*$/i.test(e)))throw Error("--properties must be a comma-separated list of CSS property names");return[...new Set(t.map(e=>e.toLowerCase()))]}(r.values.properties),a=await tq(e,"get-computed-style"),{session:d}=a;try{let t=await K(d,i),r=await Y(d,t,i,s);if(n)nt(e.output,{ok:!0,command:"get-computed-style",...r});else if(ne(e.output,`${r.nodeRef} computed style(client ${t.clientId}、session ${t.sessionId})`),0===r.properties.length)ne(e.output,"没有匹配的 computed style 属性。");else{let t=Math.max(...r.properties.map(e=>e.name.length));for(let n of r.properties)ne(e.output,` ${n.name.padEnd(t)} ${n.value}`)}}finally{a.owned&&await d.stop().catch(()=>void 0)}}function tO(e){return e.runtimeInspectionTargetPolicy??{kind:"latest"}}function t$(e,t){return null!=e&&null!=t&&e.clientId===t.clientId&&e.sessionId===t.sessionId}function tN(e,t,n){return U(t,{activeClientId:e.activeClientId,policy:tO(e),...void 0===n?{}:{explicitTarget:V(n)},signal:e.signal})}async function tq(e,t){if(e.runtimeInspectionSession)return{owned:!1,session:await e.runtimeInspectionSession};let n=e.createRuntimeInspectionSession??B;return{owned:!0,session:await n({namespace:e.runtime.getState().namespace,nodeIdPrefix:`dev-shell-${t}`})}}async function tM(e,t){let o=(0,eD.parseArgs)({args:t,allowPositionals:!0,options:{"device-id":{type:"string"}}}),i=o.positionals[0]??await tF(e,"page",n.discoverPages);if(!i)throw Error("page url is required");let s=o.values["device-id"]??e.activeDeviceId;ne(e.output,`debug: page open request ${t9({url:i,deviceId:s})}`);let a=r("page",await e.client.call(n.openPageUrl,{url:i,deviceId:s}));ne(e.output,`page opened: ${i}`),ne(e.output,`status: ${tU(a)}`)}async function tB(e,t){let o=(0,eD.parseArgs)({args:t,allowPositionals:!0,options:{data:{type:"string"},"bot-id":{type:"string"},"device-id":{type:"string"}}}),s=o.positionals[0]??await tF(e,"widget",n.discoverWidgets);if(!s)throw Error("widget id is required");let a=i(o.values.data,"--data"),d=o.values["device-id"]??e.activeDeviceId;ne(e.output,`debug: widget push request ${t9({widgetId:s,data:a,botId:o.values["bot-id"],deviceId:d})}`);let l=r("widget",await e.client.call(n.pushWidget,{widgetId:s,widgetData:a,botId:o.values["bot-id"],deviceId:d}));ne(e.output,`widget pushed: ${s}`),ne(e.output,`status: ${tU(l)}`)}function tU(e){if(!e.ok)return"failed";let t=function(e){if(!e||"object"!=typeof e)return;let t=e.data;if(!t||"object"!=typeof t)return;let n=t.msg;return"string"==typeof n?n:void 0}(e.result);return"string"==typeof t&&t.trim()?t:"ok"}async function tF(e,t,n){let r=await e.client.call(n);if(r.length)return e.selectItem(t,r,e.output)}function tV(e,t){return t.map(t=>{let n=t8(e,t);return n?{label:t7(e,t),value:n}:void 0}).filter(e=>!!e)}async function tH(e){var t,r;let o,i,s,a,l=e.timeoutMs??6e4;if(!e.hostUrl||!e.appKey)return{ok:!1,status:"skipped",timeoutMs:l,failureStage:"create_qr",error:"无法生成二维码,缺少 hostUrl 或 appKey。"};let c=e.hostUrl,p=e.appKey,h=(t=e.namespace,r=l,i=new d(t,{nodeId:`dev-auth-${process.pid}-${Math.random().toString(36).slice(2,8)}`,requestTimeout:2e3}),s=!1,a=new Promise(e=>{o=e}),i.createService({name:`devAuthListener${process.pid}`,events:{"connection.newclient"(e){var t;s||(s=!0,o((t=e.params)&&"object"==typeof t?{scope:"string"==typeof t.scope?t.scope:void 0,type:"string"==typeof t.type?t.type:void 0,clientId:"number"==typeof t.clientId?t.clientId:void 0,deviceId:t1(t),app:"string"==typeof t.app?t.app:void 0}:{}))}}}),{start:()=>i.start(),stop:()=>i.stop(),wait:(e,t=r)=>{var n,o,i;return n=a,o=t,i=e,new Promise((e,t)=>{let r=()=>{clearTimeout(s),t(i?.reason instanceof Error?i.reason:new tQ)},s=setTimeout(()=>{i?.removeEventListener("abort",r),t(new tJ(o))},o);i?.aborted?r():(i?.addEventListener("abort",r,{once:!0}),n.then(t=>{clearTimeout(s),i?.removeEventListener("abort",r),e(t)},e=>{clearTimeout(s),i?.removeEventListener("abort",r),t(e)}))})},async findExistingClient(){let e=await t0(()=>i.call("devtoolConnection.getConnectedClients"),2e3).catch(()=>[]);return function(e){if(!e||"object"!=typeof e)return;let t=e.device,n=t?.info,r="number"==typeof t?.clientId?t.clientId:void 0;return{scope:"all",type:String(n?.network??"").toLowerCase().includes("wifi")?"wifi":"usb",...void 0===r?{}:{clientId:r},deviceId:t1({client:e}),app:"string"==typeof n?.App?n.App:""}}(Array.isArray(e)?e[0]:void 0)},async awaitDirectDebugReady(e){let t=Math.min(r,2500);try{return await i.call(n.awaitDirectDebugReady,{clientId:e,timeoutMs:t},{timeout:t+1e3})}catch{return!1}},waitForInstallResult:(e,t,r,o)=>{var s,a;return s=i.call(n.awaitDeviceInstallResult,{clientId:e,packageName:t,timeoutMs:r},{timeout:r+1e3}),(a=o)?new Promise((e,t)=>{let n=()=>{t(a.reason instanceof Error?a.reason:new tQ)};if(a.aborted){s.catch(()=>void 0),n();return}a.addEventListener("abort",n,{once:!0}),s.then(t=>{a.removeEventListener("abort",n),e(t)},e=>{a.removeEventListener("abort",n),t(e)})}):s}}),f={},m="connection",g="wait_device_connection";await h.start();try{let t;e.signal?.throwIfAborted();let n=await h.findExistingClient(),r=n?.clientId!==void 0&&await h.awaitDirectDebugReady(n.clientId);if(r)await e.onPhaseChange?.("reusing_client");else{let n,r,o;g="create_qr",t=await tK(f,()=>(0,eP.Ph)(function(e,t,n={}){let r=tz(n.settings);return{hostUrl:e,appKey:t,...void 0===n.versionTag?{}:{versionTag:n.versionTag},isSigned:!1,appletType:0,baseApiUrl:u(),authOptions:v(),...!1===r.defaultDebugTagState?{defaultDebugTagState:!1}:{},...!r.usb&&n.wifiConnectUrl?{wifiConnectUrl:n.wifiConnectUrl}:{}}}(c,p,{versionTag:e.versionTag,settings:e.settings,wifiConnectUrl:e.wifiConnectUrl})),e.signal),await e.onPhaseChange?.("waiting_for_scan"),ne(e.output,""),ne(e.output,"使用豆包 App 扫码连接调试设备."),ne(e.output,`二维码创建成功,请在 ${(n=Math.max(1,Math.round(l/1e3)),r=Math.floor(n/60),o=n%60,r>0?`${r}m ${o}s`:`${o}s`)} 前扫码; 超时可在真机模式执行 \`qr\` 创建新二维码.`),ne(e.output,""),await e.onQRCodeReady?.(t.qrCodeValue,t.debugToken),e.signal?.throwIfAborted()}g="wait_device_connection";let o=Date.now()+l;ne(e.output,`等待设备连接 (${l/1e3}s timeout)...`);let i=r?n:await h.wait(e.signal,tZ(o));if(void 0===i.clientId)throw Error("连接的设备缺少 clientId");m="install",g="install_debug_package",await e.onPhaseChange?.("waiting_for_install");let s=await h.waitForInstallResult(i.clientId,p,tZ(o),e.signal);if(!s)throw new tJ(l);if(!s.success)return{ok:!1,status:"skipped",timeoutMs:l,failureStage:g,waitingFor:m,client:i,error:s.message||"安装 AIPackage 失败,请检查网络环境并关注客户端提示"};return{ok:!0,status:"connected",timeoutMs:l,...t?{qrCodeValue:t.qrCodeValue,debugToken:t.debugToken,encryptedDebugPayload:t.encryptedDebugPayload}:{},client:i}}catch(o){let t=o instanceof tJ,n=o instanceof tQ||!!e.signal?.aborted,r=function(e){if(e&&"object"==typeof e)return tW(e,"logId")??tW(e,"log_id")}(o)??f.logId;return{ok:!1,status:n?"cancelled":t?"timeout":"skipped",timeoutMs:l,failureStage:g,waitingFor:m,...r?{logId:r}:{},error:o instanceof Error?o.message:String(o)}}finally{await h.stop()}}async function tK(e,t,n){let r=globalThis.fetch;globalThis.fetch=async(t,o)=>{var i;let s,a=(s=function(e){try{if("string"==typeof e)return new URL(e);if(e instanceof URL)return new URL(e.toString());return new URL(e.url)}catch{return}}(i=t))&&s.pathname.startsWith("/developer/check_api/apps/")&&s.pathname.endsWith("/debug/ticket")?(s.pathname=s.pathname.replace(/^\/developer\/check_api\//,"/app_developer/check_api/"),"string"==typeof i)?s.toString():i instanceof URL?s:new Request(s,i):i,d=await r(a,n&&a!==t&&!o?.signal?{...o,signal:n}:o);return await tY(e,d),d};try{return await t()}finally{globalThis.fetch=r}}function tz(e){return{defaultDebugTagState:e?.defaultDebugTagState??!0,usb:e?.usb??!0}}async function tY(e,t){let n=t.headers.get("x-tt-logid");if(n){e.logId=n;return}try{let n=await t.clone().text();if(!n)return;let r=JSON.parse(n),o=tW(r,"log_id")??tW(r,"logId");o&&(e.logId=o)}catch{}}function tW(e,t){if(!e||"object"!=typeof e)return;let n=e[t];return"string"==typeof n&&n?n:void 0}function tG(e){return e.replace(/\s*[\[((]log_id:\s*[^\]))]+[\]))]/gi,"").trim()}class tJ extends Error{constructor(e){super(`real-device auth timed out after ${e}ms`),this.name="RealDeviceAuthTimeoutError"}}class tQ extends Error{constructor(){super("real-device auth cancelled"),this.name="RealDeviceAuthCancelledError"}}function tX(e,t){let n=new d(e,{nodeId:`dev-disconnect-${process.pid}-${Math.random().toString(36).slice(2,8)}`,requestTimeout:2e3});return n.createService({name:`devDisconnectListener${process.pid}`,events:{"connection.clientDisconnected":()=>t()}}),{start:()=>n.start(),stop:()=>n.stop()}}function tZ(e){return Math.max(0,e-Date.now())}async function t0(e,t){let n=Date.now()+t;for(;;)try{return await e()}catch(e){if(Date.now()>=n)throw e;await new Promise(e=>{setTimeout(e,100)})}}function t1(e){let t=e.client?.device,n=t?.info;return n?.usbDeviceId||t?.xdbId||n?.did||n?.debugRouterId}async function t2(e,t){let n=ek().resolve(t);if(".png"!==ek().extname(n).toLowerCase())throw Error("QR file must use the .png extension");return eE().mkdirSync(ek().dirname(n),{recursive:!0}),await ex.toFile(n,e,{errorCorrectionLevel:"L",margin:4,type:"png"}),n}async function t4(e,t){let n=await ex.toBuffer(e,{errorCorrectionLevel:"L",margin:0,type:"png",width:320}),r=t?await ex.toBuffer(`doubaoapp://local_debug?short_token=${t}`,{errorCorrectionLevel:"L",margin:0,type:"png",width:320}):void 0;return{legacy:n,...r?{modern:r}:{}}}function t5(e=eT().tmpdir()){let t;try{t=eE().readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of t)if(/^dbx-real-device-qr-.*\.(?:png|svg)$/i.test(n.name)&&(n.isFile()||n.isSymbolicLink()))try{eE().unlinkSync(ek().join(e,n.name))}catch{}}async function t3(e,t,n,r=process.stderr,o){let i,s,a;if(n){let t=await t2(e,n);ne(r,`二维码图片已导出至:${t}`)}let{legacy:d,modern:l}=await t4(e,o),c=eb().randomBytes(18).toString("hex"),u=`/${c}/`,p=new Set,h=!1,f=new Promise(e=>{s=e}),m=()=>{clearTimeout(i),i=void 0,h||s()},g=(0,eI.createServer)((e,t)=>{let n=e.url?.split("?",1)[0];if(t.setHeader("Cache-Control","no-store, no-cache, must-revalidate, max-age=0"),t.setHeader("Expires","0"),t.setHeader("Pragma","no-cache"),"GET"===e.method&&n===u){var r;t.writeHead(200,{"Content-Security-Policy":"default-src 'none'; img-src 'self'; connect-src 'self'; script-src 'unsafe-inline'; style-src 'unsafe-inline'","Content-Type":"text/html; charset=utf-8"}),t.end((r=!!l,`<!doctype html>
11
+ `),e}catch(e){if(I(e)&&"EEXIST"===e.code)return this.readMasterKey();throw new p(`Failed to write encrypted token master key: ${A(e)}`)}}}class g{async get(e){try{let{stdout:t}=await d("security",["find-generic-password","-a",e,"-s",l,"-w"]);return String(t).replace(/\n$/,"")}catch(e){if(y(e))return;throw new p(`Failed to read token from macOS Keychain: ${A(e)}`)}}async set(e,t){try{await d("security",["add-generic-password","-a",e,"-s",l,"-w",t,"-U"])}catch(e){throw new p(`Failed to write token to macOS Keychain: ${A(e)}`)}}async delete(e){try{await d("security",["delete-generic-password","-a",e,"-s",l])}catch(e){if(y(e))return;throw new p(`Failed to delete token from macOS Keychain: ${A(e)}`)}}}class _{async get(e){try{let{stdout:t}=await d("secret-tool",["lookup","service",l,"account",e]);return String(t).replace(/\n$/,"")}catch(e){if(b(e))return;throw new p(`Failed to read token from Secret Service: ${A(e)}`)}}async set(e,t){try{var n,o,i;await (n="secret-tool",o=["store","--label","Doubao Open CLI token","service",l,"account",e],i=t,new Promise((e,t)=>{let s=(0,r.spawn)(n,o,{stdio:["pipe","ignore","pipe"]}),a="";s.stderr.setEncoding("utf8"),s.stderr.on("data",e=>{a+=String(e)}),s.on("error",t),s.on("close",r=>{0===r?e():t(Error(a.trim()||`${n} exited with code ${r}`))}),s.stdin.end(i)}))}catch(e){throw new p(`Failed to write token to Secret Service: ${A(e)}`)}}async delete(e){try{await d("secret-tool",["clear","service",l,"account",e])}catch(e){if(b(e))return;throw new p(`Failed to delete token from Secret Service: ${A(e)}`)}}}async function w(e,t){let n=a.dirname(e);await i.promises.mkdir(n,{recursive:!0,mode:448}),"win32"!==process.platform&&await i.promises.chmod(n,448);let r=a.join(n,`.${a.basename(e)}.${process.pid}.${Date.now()}.tmp`);try{await i.promises.writeFile(r,t,{mode:384,flag:"wx"}),"win32"!==process.platform&&await i.promises.chmod(r,384),await i.promises.rename(r,e),"win32"!==process.platform&&await i.promises.chmod(e,384)}finally{try{await i.promises.unlink(r)}catch{}}}function y(e){let t=v(e),n=E(e);return(1===t||44===t)&&(n.includes("could not be found")||n.includes("The specified item could not be found"))}function b(e){let t=v(e),n=E(e);return 1===t&&(n.includes("could not be found")||n.includes("No matching items")||""===n.trim())}function v(e){return"object"==typeof e&&null!==e&&"code"in e?e.code:void 0}function E(e){return"object"==typeof e&&null!==e&&"stderr"in e?String(e.stderr??""):""}function I(e){return e instanceof Error&&"code"in e}function A(e){if("object"==typeof e&&null!==e&&"stderr"in e){let t=String(e.stderr??"").trim();if(t)return t}return e instanceof Error&&e.message?e.message:String(e)}n.d(t,{Mj:()=>h,RI:()=>p})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/device-flow.js"(e,t,n){var r=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"),o=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"),i=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/jwt.js"),s=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/store.js"),a=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/types.js");async function d(e={}){let t=(0,r.$i)(e),n=t.fetch??fetch,l=t.sleep??w,c=await u(n,t.baseUrl,t.requestHeaders),h=y(t.baseUrl,c.user_code);t.onVerification?.({userCode:c.user_code,verificationUrl:h,expiresIn:c.expires_in,interval:c.interval});let f=Math.max(1,c.interval),m=Date.now()+1e3*c.expires_in;for(;Date.now()<m;){await l(1e3*f);let e=await p(n,t.baseUrl,c.device_code,t.requestHeaders);if(t.onPoll?.({status:e.status,interval:f}),e.status!==a.A.Pending){if(e.status===a.A.SlowDown){f+=Math.max(1,c.interval);continue}if(e.status===a.A.Expired)throw new o.JC("Device authorization expired","DEVICE_AUTH_EXPIRED");if(e.status===a.A.Invalid)throw new o.JC("Device authorization is invalid","DEVICE_AUTH_INVALID");if(e.status===a.A.Authorized){if(!e.access_token)throw new o.JC("Authorization response did not include an access token");let n=_(e,t.baseUrl);return await (0,s.tK)(t.tokenPath,n,{credentialStore:t.credentialStore}),{accessToken:n.accessToken,tokenType:n.tokenType,expiresAt:n.expiresAt,baseUrl:n.baseUrl,uid:(0,i.m)(n.accessToken),tokenPath:t.tokenPath}}throw new o.JC(`Unexpected authorization status: ${String(e.status)}`)}}throw new o.JC("Device authorization timed out","DEVICE_AUTH_EXPIRED")}async function l(e={}){let t=(0,r.$i)(e),n=t.fetch??fetch,o=await u(n,t.baseUrl,t.requestHeaders),i=y(t.baseUrl,o.user_code);return t.onVerification?.({userCode:o.user_code,verificationUrl:i,expiresIn:o.expires_in,interval:o.interval}),{userCode:o.user_code,deviceCode:o.device_code,verificationUrl:i,expiresIn:o.expires_in,interval:o.interval}}async function c(e,t={}){let n=(0,r.$i)(t),d=n.fetch??fetch,l=n.sleep??w,u=n.baseUrl,h=n.requestHeaders,f=5,m=Date.now()+6e5;for(;Date.now()<m;){await l(1e3*f);let t=await p(d,u,e,h);if(n.onPoll?.({status:t.status,interval:f}),t.status!==a.A.Pending){if(t.status===a.A.SlowDown){f+=5;continue}if(t.status===a.A.Expired)throw new o.JC("Device authorization expired","DEVICE_AUTH_EXPIRED");if(t.status===a.A.Invalid)throw new o.JC("Device authorization is invalid","DEVICE_AUTH_INVALID");if(t.status===a.A.Authorized){if(!t.access_token)throw new o.JC("Authorization response did not include an access token");let e=_(t,u);return await (0,s.tK)(n.tokenPath,e,{credentialStore:n.credentialStore}),{accessToken:e.accessToken,tokenType:e.tokenType,expiresAt:e.expiresAt,baseUrl:e.baseUrl,uid:(0,i.m)(e.accessToken),tokenPath:n.tokenPath}}throw new o.JC(`Unexpected authorization status: ${String(t.status)}`)}}throw new o.JC("Device authorization timed out","DEVICE_AUTH_EXPIRED")}async function u(e,t,n){let i=await e(`${t}/app_developer/oauth/device/code`,{method:"POST",headers:g(n),body:JSON.stringify({client_name:r.E})}),s=await h(i),a=m(s);if(!a||!a.device_code||!a.user_code||"number"!=typeof a.expires_in||"number"!=typeof a.interval)throw new o.JC(`Device code response is malformed (HTTP ${i.status}): ${JSON.stringify(s)}`);return a}async function p(e,t,n,r){let i=await e(`${t}/app_developer/oauth/token`,{method:"POST",headers:g(r),body:JSON.stringify({device_code:n})}),s=await h(i),d=m(s);if(d?.access_token)return{status:a.A.Authorized,access_token:d.access_token,token_type:d.token_type,expires_in:d.expires_in,expires_at:d.expires_at};if(!d||"number"!=typeof d.status)throw new o.JC(`Token response is malformed (HTTP ${i.status}): ${JSON.stringify(s)}`);return d}async function h(e){var t;let n,r=e.headers.get("x-tt-logid")??void 0;try{n=await e.json()}catch{throw new o.JC(`Auth server returned non-JSON response with status ${e.status}${f(r)}`,"DEVICE_AUTH_FAILED",{logId:r})}let i=function(e){if(e&&"object"==typeof e)return"string"==typeof e.log_id&&e.log_id?e.log_id:void 0}(n)??r;if(!e.ok)throw new o.JC(`Auth server returned HTTP ${e.status}: ${JSON.stringify(n)}${f(i)}`,"DEVICE_AUTH_FAILED",{logId:i});let s=(t=n)&&"object"==typeof t&&"number"==typeof t.code&&0!==t.code?{code:t.code,message:"string"==typeof t.message?t.message:"Unknown error",logId:"string"==typeof t.log_id?t.log_id:void 0}:null;if(s)throw new o.JC(`Auth server error (code ${s.code}): ${s.message}${f(s.logId??i)}`,"DEVICE_AUTH_FAILED",{logId:s.logId??i});return n}function f(e){return e?` [log_id: ${e}]`:""}function m(e){return e&&"object"==typeof e&&"data"in e?e.data:e}function g(e){let t=new Headers(e);return t.set("Content-Type","application/json"),t}function _(e,t){let n=Math.floor(Date.now()/1e3);return{accessToken:e.access_token??"",tokenType:e.token_type??"Bearer",expiresAt:"number"==typeof e.expires_at?e.expires_at:n+(e.expires_in??0),baseUrl:t}}function w(e){return new Promise(t=>{setTimeout(t,e)})}function y(e,t){let n=new URL(e).host,r=new URL(`https://${n}/oauth/device`);return r.searchParams.set("user_code",t),r.toString()}n.d(t,{R$:()=>c,c$:()=>l,iD:()=>d})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"(e,t,n){class r extends Error{constructor(e,t){super(e),this.code=t,this.name="AuthError"}}class o extends r{constructor(e="Not logged in"){super(e,"NOT_LOGGED_IN"),this.name="NotLoggedInError"}}class i extends r{constructor(e="Login token has expired"){super(e,"TOKEN_EXPIRED"),this.name="TokenExpiredError"}}class s extends r{constructor(e,t="DEVICE_AUTH_FAILED",n={}){super(e,t),this.name="DeviceAuthError",this.logId=n.logId}}n.d(t,{BX:()=>i,JC:()=>s,bG:()=>o,lR:()=>r})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/http.js"(e,t,n){var r=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"),o=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"),i=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/store.js");function s(e=fetch,t={}){return async(n,s={})=>{let a=(0,o.$i)(t);var d=n,l=a.allowedOrigins;let c=function(e){try{if("string"==typeof e)return new URL(e);if(e instanceof URL)return e;return new URL(e.url)}catch{throw Error("Authenticated requests must use an absolute HTTPS URL")}}(d);if("https:"!==c.protocol)throw Error(`Authenticated requests must use https: ${c.toString()}`);if(!l.includes(c.origin))throw Error(`Refusing to attach Authorization header to untrusted origin: ${c.origin}`);let u=await (0,i.AI)(a.tokenPath,{allowExpired:!0,envTokenBaseUrl:a.baseUrl,credentialStore:a.credentialStore,legacyTokenPath:a.legacyTokenPath});if(!u)throw new r.bG;if((0,i._d)(u))throw new r.BX;let p=new Headers(s.headers);return a.requestHeaders.forEach((e,t)=>{p.set(t,e)}),p.set("Authorization",`${u.tokenType||"Bearer"} ${u.accessToken}`),e(n,{...s,headers:p})}}n.d(t,{r:()=>s})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/index.js"(e,t,n){n.r(t);var r=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/config.js"),o=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/credential-store.js"),i=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/device-flow.js"),s=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/store.js"),a=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/http.js"),d=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/errors.js"),l=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/types.js");async function c(e={}){let t=(0,r.$i)(e);await (0,s.ni)(t.tokenPath,{credentialStore:t.credentialStore}),t.legacyTokenPath&&await (0,s.ni)(t.legacyTokenPath,{credentialStore:t.credentialStore})}async function u(e={}){let t,n=(0,r.$i)(e);try{t=await (0,s.AI)(n.tokenPath,{envTokenBaseUrl:n.baseUrl,credentialStore:n.credentialStore,legacyTokenPath:n.legacyTokenPath})}catch(e){if(e instanceof o.RI)return{loggedIn:!1,tokenPath:n.tokenPath,baseUrl:n.baseUrl,credentialError:{code:"CREDENTIAL_STORE_UNAVAILABLE",message:e.message}};throw e}if(!t)return{loggedIn:!1,tokenPath:n.tokenPath};let i=await p(e.fetch??fetch,n.baseUrl,t,n.requestHeaders);return i?{loggedIn:!0,uid:i.userId,name:i.name,avatar:i.avatar,expiresAt:t.expiresAt,tokenPath:n.tokenPath,baseUrl:n.baseUrl}:{loggedIn:!1,expiresAt:t.expiresAt,tokenPath:n.tokenPath,baseUrl:n.baseUrl}}async function p(e,t,n,r){let o=new Headers(r);o.set("Authorization",`${n.tokenType||"Bearer"} ${n.accessToken}`);let i=await e(`${t.replace(/\/+$/,"")}/app_developer/api/user/basic`,{method:"GET",headers:o});if(!i.ok)return;let s=await i.json();if(0===s.code){var a;return{userId:"string"==typeof(a=s.data?.user_id)&&a.length>0?a:"number"==typeof a&&Number.isFinite(a)?String(a):void 0,name:s.data?.name,avatar:s.data?.avatar}}}n.d(t,{AuthError:()=>d.lR,CredentialStoreError:()=>o.RI,DeviceAuthError:()=>d.JC,NotLoggedInError:()=>d.bG,TokenExpiredError:()=>d.BX,TokenStatus:()=>l.A,completeLogin:()=>i.R$,configureAuth:()=>r.ZI,login:()=>i.iD,logout:()=>c,startLogin:()=>i.c$,whoami:()=>u,withAuth:()=>a.r})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/jwt.js"(e,t,n){function r(e){let t=function(e){let t=e.split(".")[1];if(t)try{let e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.padEnd(e.length+(4-e.length%4)%4,"="),r=Buffer.from(n,"base64").toString("utf8"),o=JSON.parse(r);return o&&"object"==typeof o?o:void 0}catch{return}}(e),n=t?.uid??t?.sub;return"string"==typeof n&&n.length>0?n:"number"==typeof n&&Number.isFinite(n)?String(n):void 0}n.d(t,{m:()=>r})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/store.js"(e,t,n){var r=n("node:fs"),o=n("node:crypto"),i=n("node:path"),s=n("../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/credential-store.js");async function a(e,t={}){let n,r=process.env.DBX_ACCESS_TOKEN?.trim()||void 0;if(r)return{accessToken:r,tokenType:"Bearer",expiresAt:0xf4865700,baseUrl:t.envTokenBaseUrl??""};let o=await h(e);if(void 0===o)return f(e,t);try{n=JSON.parse(o)}catch(e){return}if(p(n)){if(!t.allowExpired&&c(n))return void await l(e,t);let r=await m(t).get(n.credentialAccount);if(!r)throw new s.RI("Stored login metadata exists, but the token credential is missing or inaccessible. Run dbx auth login again from a terminal that can access the credential store.");return{accessToken:r,tokenType:n.tokenType,expiresAt:n.expiresAt,baseUrl:n.baseUrl}}if(u(n))return!t.allowExpired&&c(n)?void await l(e,t):(await d(e,n,t),n)}async function d(e,t,n={}){let o={version:2,storage:"keychain",credentialAccount:g(e),tokenType:t.tokenType,expiresAt:t.expiresAt,baseUrl:t.baseUrl};await m(n).set(o.credentialAccount,t.accessToken),await r.promises.mkdir(i.dirname(e),{recursive:!0,mode:448}),"win32"!==process.platform&&await r.promises.chmod(i.dirname(e),448);let s=`${e}.${process.pid}.${Date.now()}.tmp`;await r.promises.writeFile(s,`${JSON.stringify(o,null,2)}
12
+ `,{mode:384}),"win32"!==process.platform&&await r.promises.chmod(s,384),await r.promises.rename(s,e),"win32"!==process.platform&&await r.promises.chmod(e,384)}async function l(e,t={}){let n=await h(e);if(void 0!==n)try{let r=JSON.parse(n);p(r)?await m(t).delete(r.credentialAccount):await m(t).delete(g(e))}catch{}try{await r.promises.unlink(e)}catch(e){if(!_(e)||"ENOENT"!==e.code)throw e}}function c(e,t=Math.floor(Date.now()/1e3)){return e.expiresAt<=t}function u(e){return!!e&&"object"==typeof e&&"string"==typeof e.accessToken&&e.accessToken.length>0&&"string"==typeof e.tokenType&&e.tokenType.length>0&&"number"==typeof e.expiresAt&&Number.isFinite(e.expiresAt)&&"string"==typeof e.baseUrl&&e.baseUrl.length>0}function p(e){return!!e&&"object"==typeof e&&2===e.version&&"keychain"===e.storage&&"string"==typeof e.credentialAccount&&e.credentialAccount.length>0&&"string"==typeof e.tokenType&&e.tokenType.length>0&&"number"==typeof e.expiresAt&&Number.isFinite(e.expiresAt)&&"string"==typeof e.baseUrl&&e.baseUrl.length>0}async function h(e){try{return await r.promises.readFile(e,"utf8")}catch(e){_(e)&&e.code;return}}async function f(e,t){let n;if(!t.legacyTokenPath||i.resolve(t.legacyTokenPath)===i.resolve(e))return;let r=await h(t.legacyTokenPath);if(void 0!==r){try{n=JSON.parse(r)}catch{return}if(u(n))return!t.allowExpired&&c(n)?void await l(t.legacyTokenPath,t):(await d(e,n,t),await l(t.legacyTokenPath,t),n)}}function m(e){return e.credentialStore??(0,s.Mj)()}function g(e){let t=o.createHash("sha256").update(i.resolve(e)).digest("hex").slice(0,32);return`token:${t}`}function _(e){return e instanceof Error&&"code"in e}n.d(t,{AI:()=>a,_d:()=>c,ni:()=>l,tK:()=>d})},"../../../node_modules/.pnpm/@byted-doubao-apps+auth-cli@0.0.33/node_modules/@byted-doubao-apps/auth-cli/dist/types.js"(e,t,n){var r,o;(o=r||(r={}))[o.Pending=1]="Pending",o[o.Authorized=2]="Authorized",o[o.Expired=3]="Expired",o[o.Invalid=4]="Invalid",o[o.SlowDown=5]="SlowDown",n.d(t,{A:()=>r})}});var R={};e.r(R),e.d(R,{createDeferredDevShellSession:()=>nc,default:()=>na,isInteractiveTerminal:()=>np});let O=e("node:zlib"),$=e("../../../node_modules/.pnpm/@byted-doubao-tools+devtool-connection-core@0.1.0-beta.12_debug@4.4.3_react@19.2.7/node_modules/@byted-doubao-tools/devtool-connection-core/dist/lib/ipc/index.js"),N=4*Math.ceil(5614250.666666667),q=new Map;class M extends Error{code;cause;constructor(e,t,n){super(t),this.code=e,this.name="RuntimeInspectionError",n&&"cause"in n&&(this.cause=n.cause)}}async function B(e){let t,r=new d(e.namespace,{nodeId:`${e.nodeIdPrefix}-${process.pid}-${Math.random().toString(36).slice(2,8)}`,requestTimeout:12e3}),o=new Set,i=new Set,a=0,l=!0;r.createService({name:`runtimeInspection${process.pid}${Math.random().toString(36).slice(2,8)}`,events:{[$.DEVTOOL_CONNECTION_IPC_EVENTS.messageReceived](e){let n=e.params,r=function(e){if("Page.screencastFrame"===e.method&&c(e.params)&&"string"==typeof e.params.data&&e.params.data)return{data:e.params.data}}(n);for(let e of(r&&Number.isSafeInteger(n.clientId)&&Number.isSafeInteger(n.sessionId)&&(t={clientId:n.clientId,sessionId:n.sessionId,data:r.data}),o))e(n)},[s.runtimeInspectionTargetChanged](e){let t=function(e){if(c(e)&&"number"==typeof e.clientId&&"number"==typeof e.sessionId&&"string"==typeof e.url)return{clientId:e.clientId,sessionId:e.sessionId,url:e.url}}(e.params);if(t)for(let e of i)e(t)}}});try{await r.start()}catch(e){throw await r.stop().catch(()=>void 0),e}let u=(e,t)=>eh(()=>r.call(`${$.DEFAULT_DEVTOOL_CONNECTION_IPC_SERVICE_NAME}.${e}`,t),5e3);return{eventSubscriptionWarmupMs:e.eventSubscriptionWarmupMs??5e3,getConnectedClients:()=>u($.DEVTOOL_CONNECTION_IPC_ACTIONS.getConnectedClients),getLatestScreencastFrame(e){if(t?.clientId===e.clientId&&t.sessionId===e.sessionId)return{data:t.data}},async getRuntimeInspectionTarget(){if(!l)return null;try{return await r.call(n.getRuntimeInspectionTarget)}catch(e){if(ep(e))return l=!1,null;throw e}},subscribeRuntimeInspectionTarget:e=>(i.add(e),()=>{i.delete(e)}),async sendCdp(e,t,n={},r={}){let o={id:1e9+process.pid%1e5*1e3+a++,clientId:e.clientId,sessionId:e.sessionId,method:t,params:n,messageType:"CDP",timeoutMs:!1===r.expectResponse?100:1e4};try{let e=await u($.DEVTOOL_CONNECTION_IPC_ACTIONS.sendMessageToApp,o);var i,s,d=t,l=e;if(!l.success)throw Error([l.reason,l.apps?.length?`apps=${l.apps.join(",")}`:"",l.clients?.length?`clients=${l.clients.map(e=>`${e.clientId}:${e.info.App}`).join(",")}`:""].filter(Boolean).join("; "));if(c(l.data)&&c(l.data.error)){let e=void 0===l.data.error.code?"unknown":String(l.data.error.code),t=void 0===l.data.error.message?"unknown error":String(l.data.error.message);throw Error(`${d} failed: ${t} (code=${e})`)}return X(l.data)}catch(e){if(!1===r.expectResponse&&(i=e,s=t,(i instanceof Error?i.message:String(i)).includes(`send CDP message timeout, method: ${s}`)))return;throw Error(`${t} failed: ${e instanceof Error?e.message:String(e)}`)}},subscribeMessage:e=>(o.add(e),()=>{o.delete(e)}),async stop(){o.clear(),i.clear(),t=void 0,await r.stop()}}}async function U(e,t={}){let n=Date.now()+(t.timeoutMs??3e3);for(;;){em(t.signal);let r=await e.getConnectedClients(),o=function(e,t={}){let n,r=t.explicitTarget??(t.policy?.kind==="fixed"?t.policy.target:void 0);if(r){let n=e.find(e=>e.device.clientId===r.clientId);if(!n){if(t.activeClientId===r.clientId)throw new M("TARGET_CLIENT_DISCONNECTED",`debug client ${r.clientId} is disconnected`);throw new M("TARGET_STALE",`${F(r)} no longer points to a connected debug client`)}let o=n.sessions.find(e=>e.sessionId===r.sessionId&&W(e));if(!o)throw new M("TARGET_STALE",`${F(r)} no longer points to a live Lynx session`);return{clientId:n.device.clientId,sessionId:o.sessionId,url:o.url}}if(void 0!==t.activeClientId){if(!(n=e.find(e=>e.device.clientId===t.activeClientId)))throw new M("TARGET_CLIENT_DISCONNECTED",`authenticated debug client ${t.activeClientId} is disconnected`)}else if(e.length>1)throw new M("TARGET_AMBIGUOUS",`more than one debug device is connected: ${e.map(e=>`${e.device.clientId}:${e.device.info.App||"unknown"}`).join(", ")}`);else n=e[0];if(!n)return;let o=n.sessions.filter(W).sort((e,t)=>t.sessionId-e.sessionId)[0];if(o)return{clientId:n.device.clientId,sessionId:o.sessionId,url:o.url}}(r,t);if(o)return o;if(Date.now()>=n)throw 0===r.length?new M("DEVICE_NOT_CONNECTED","no debug device is connected"):new M("NO_ACTIVE_LYNX_SESSION","the connected device has no active Lynx session");await eg(100,t.signal)}}function F(e){return`@${e.clientId}:${e.sessionId}`}function V(e){let t=/^@([1-9]\d*):([1-9]\d*)$/.exec(e.trim());if(!t)throw new M("INVALID_TARGET_REF",`invalid target ref "${e}"; expected @<clientId>:<sessionId>`);let n={clientId:Number(t[1]),sessionId:Number(t[2])};if(!Number.isSafeInteger(n.clientId)||!Number.isSafeInteger(n.sessionId))throw new M("INVALID_TARGET_REF",`invalid target ref "${e}"; every id must be a safe integer`);return n}function H(e){return`@${e.clientId}:${e.sessionId}:${e.nodeId}`}async function K(e,t){let n=(await e.getConnectedClients()).find(e=>e.device.clientId===t.clientId),r=n?.sessions.find(e=>e.sessionId===t.sessionId&&W(e));if(!n||!r)throw new M("STALE_NODE_REF",`${H(t)} no longer points to a live Lynx session; run get-page-tree again`);return{clientId:t.clientId,sessionId:t.sessionId,url:r.url}}async function z(e,t,n={}){var r,o,i;let s,a,d,l,u,p=n.depth??-1,h=n.maxNodes??5e3;if(!Number.isInteger(p)||p<-1)throw Error("page tree depth must be -1 or a non-negative integer");if(!Number.isSafeInteger(h)||h<1)throw Error("page tree maxNodes must be a positive integer");await e.sendCdp(t,"DOM.enable",{useCompression:!1});try{u=await e.sendCdp(t,"DOM.getDocument",{depth:p})}catch{u=await e.sendCdp(t,"DOM.getDocument")}let f=function(e){let t=X(e);if(!c(t))throw ei("DOM.getDocument","response is not an object");let n=t.root;if(!0===t.compress&&"string"==typeof n)try{if(n.length>N)throw Error("compressed root exceeds the input limit");n=JSON.parse((0,O.inflateSync)(Buffer.from(n,"base64"),{maxOutputLength:0x1000000}).toString("utf8"))}catch(e){throw ei("DOM.getDocument","failed to decode compressed root",e)}else if("string"==typeof n)try{n=JSON.parse(n)}catch(e){throw ei("DOM.getDocument","root is not valid JSON",e)}if(!c(n))throw ei("DOM.getDocument","missing root node");return n}(u),m=await Q(e,t,f,p,h),g=(r=f,o=t,i=h,s=0,a=!1,d=[],{root:(l=e=>{var t;let n=ee(e.nodeId),r="string"==typeof e.nodeName&&e.nodeName?e.nodeName:"unknown";if(void 0===n)throw ei("DOM.getDocument",`node ${r} has no valid nodeId`);s++;let c=[],u={ref:H({clientId:o.clientId,sessionId:o.sessionId,nodeId:n}),nodeId:n,...void 0===ee(e.backendNodeId)?{}:{backendNodeId:ee(e.backendNodeId)},nodeType:"number"==typeof e.nodeType&&Number.isSafeInteger(e.nodeType)?e.nodeType:0,nodeName:r,..."string"==typeof e.localName?{localName:e.localName}:{},nodeValue:"string"==typeof e.nodeValue?e.nodeValue:"",attributes:function(e){if(!Array.isArray(e))return{};let t={};for(let n=0;n<e.length;n+=2){let r=e[n];if("string"!=typeof r||!r)continue;let o=e[n+1];t[r]="string"==typeof o?o:String(o??"")}return t}(e.attributes),childNodeCount:"number"==typeof e.childNodeCount&&Number.isSafeInteger(e.childNodeCount)?Math.max(0,e.childNodeCount):Z(e).length,children:c};for(let t of(et(u)&&u.nodeValue&&(u.text=u.nodeValue),Z(e))){if(s>=i){a=!0;break}c.push(l(t))}if("text"===((t=u).localName||t.nodeName).toLowerCase()){let e=function e(t){return t.children.flatMap(t=>et(t)?[t.nodeValue]:[e(t)]).join("")}(u);e?u.text=e:d.push(u)}return u})(r),nodeCount:s,truncated:a,textCandidates:d});return await en(e,t,g.textCandidates),{target:t,depth:p,nodeCount:g.nodeCount,truncated:m.truncated||g.truncated,root:g.root}}async function Y(e,t,n,r=[]){let o;await e.sendCdp(t,"DOM.enable",{useCompression:!1});try{o=await e.sendCdp(t,"CSS.getComputedStyleForNode",{nodeId:n.nodeId})}catch(e){var i;if(i=e,/(could not find|cannot find|no such|unknown|invalid|stale).{0,40}node|node.{0,40}(not found|does not exist|invalid|stale)/i.test(i instanceof Error?i.message:String(i)))throw new M("STALE_NODE_REF",`${H(n)} is stale; run get-page-tree again`,{cause:e});throw e}let s=X(o);if(!c(s)||!Array.isArray(s.computedStyle))throw ei("CSS.getComputedStyleForNode","missing computedStyle array");let a=s.computedStyle.filter(c).flatMap(e=>"string"==typeof e.name&&"string"==typeof e.value?[{name:e.name,value:e.value}]:[]),d=0===r.length?a:r.flatMap(e=>{let t=a.find(t=>t.name===e);return t?[t]:[]});return{target:t,nodeRef:H(n),nodeId:n.nodeId,properties:d}}function W(e){return"lynx"===e.type&&Number.isSafeInteger(e.sessionId)&&e.sessionId>0&&!J(e.url)}function G(e){return`${e.clientId}:${e.sessionId}`}function J(e){return/(?:-main\.js|\.main\.lynx\.js)(?:[?#].*)?$/.test(e)}async function Q(e,t,n,r,o){let i=0,s=!1,a=async(n,d)=>{if(i>=o){s=!0;return}if(i++,r>=0&&d>=r)return;let l=Z(n);if(("number"==typeof n.childNodeCount&&Number.isSafeInteger(n.childNodeCount)?Math.max(0,n.childNodeCount):l.length)>l.length&&"number"==typeof n.nodeId&&Number.isSafeInteger(n.nodeId)){let r=X(await e.sendCdp(t,"DOM.requestChildNodes",{nodeId:n.nodeId}));if(!c(r)||!Array.isArray(r.nodes))throw ei("DOM.requestChildNodes",`missing nodes array for node ${n.nodeId}`);n.children=l=r.nodes.filter(c)}for(let e of l)if(await a(e,d+1),i>=o){l.indexOf(e)<l.length-1&&(s=!0);break}};return await a(n,0),{truncated:s}}function X(e){return c(e)&&"id"in e&&"result"in e?e.result:e}function Z(e){return Array.isArray(e.children)?e.children.filter(c):[]}function ee(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>0?e:void 0}function et(e){return 3===e.nodeType||"#text"===e.nodeName.toLowerCase()}async function en(e,t,n){let r=n[0];if(!r)return;let o=await er(e,t,r);if(o.supported){o.text&&(r.text=o.text);for(let r=1;r<n.length;r+=8){let o=n.slice(r,r+8);await Promise.all(o.map(async n=>{let r=await er(e,t,n);r.text&&(n.text=r.text)}))}}}async function er(e,t,n){try{let r=X(await e.sendCdp(t,"DOM.innerText",{nodeId:n.nodeId}));if(!c(r)||!Array.isArray(r.rawTextValues))return{supported:!1};let o=r.rawTextValues.filter(c).flatMap(e=>"string"==typeof e.text?[e.text]:[]).join("");return{supported:!0,...o?{text:o}:{}}}catch{return{supported:!1}}}function eo(e,t=120){let n=e.replace(/\s+/g," ").trim();return JSON.stringify(n.length>t?`${n.slice(0,Math.max(0,t-1))}…`:n)}function ei(e,t,n){return new M("INVALID_CDP_RESPONSE",`${e} returned an invalid response: ${t}`,void 0===n?void 0:{cause:n})}async function es(e,t,n){let r,o,i,s=0,a=!1,d=G(t),l=new Promise((e,t)=>{o=e,i=t}),u=e=>{a||(a=!0,o({count:s,reason:e}))},p=()=>u("aborted"),h=e.getRuntimeInspectionTarget?.bind(e),f=e=>{if(a||!(Number.isSafeInteger(e.clientId)&&e.clientId>0&&Number.isSafeInteger(e.sessionId)&&e.sessionId>0&&!J(e.url)))return;let r=G(e);if(r!==d&&(d=r,r!==G(t)))try{n.onTargetChange?.(e)}catch{}},m=e.subscribeMessage(e=>{if(a||!ed(e,t))return;let r=function(e){var t;if("Runtime.consoleAPICalled"!==e.method||!c(e.params))return;let n={...t=e.params,...Array.isArray(t.args)?{args:t.args.map(e=>c(e)?{...e}:e)}:{},...c(t.stackTrace)?{stackTrace:{...t.stackTrace,...Array.isArray(t.stackTrace.callFrames)?{callFrames:t.stackTrace.callFrames.map(e=>c(e)?{...e}:e)}:{}}}:{}},r="string"==typeof n.consoleTag?n.consoleTag:void 0;return{type:"string"==typeof n.type?n.type:"log",thread:"Lepus"===r?"main":"background",args:Array.isArray(n.args)?n.args:[],...r?{consoleTag:r}:{},..."number"==typeof n.timestamp?{timestamp:n.timestamp}:{},..."stackTrace"in n?{stackTrace:n.stackTrace}:{},params:n}}(e);if(r){try{n.onMessage(r)}catch(e){a||(a=!0,i(e));return}s++,void 0!==n.limit&&s>=n.limit&&u("limit")}}),g=n.onTargetChange?e.subscribeRuntimeInspectionTarget?.(f):void 0;n.signal?.addEventListener("abort",p,{once:!0}),n.onTargetChange&&h&&h().then(e=>{e&&f(e)}).catch(()=>void 0);try{if(n.signal?.aborted)return u("aborted"),await l;if(await el(e,t,n.subscriptionWarmupMs??e.eventSubscriptionWarmupMs??5e3,n.signal),a)return await l;for(let o of(void 0!==n.timeoutMs&&(r=setTimeout(()=>u("timeout"),n.timeoutMs)),[{method:"Page.getResourceTree",params:{}},{method:"Debugger.enable",params:{}},{method:"Runtime.enable",params:{}}])){if(a)break;await e.sendCdp(t,o.method,o.params,{expectResponse:!1})}return await l}catch(e){if(n.signal?.aborted)return u("aborted"),await l;throw e}finally{r&&clearTimeout(r),n.signal?.removeEventListener("abort",p),g?.(),m()}}async function ea(e,t,n={}){return ef(t,async()=>{let r,o=new Promise(e=>{r=e}),i=e.subscribeMessage(e=>{ed(e,t)&&"Page.screencastFrame"===e.method&&c(e.params)&&"string"==typeof e.params.data&&e.params.data&&r({data:e.params.data})}),s=!1;try{var a,d,l;await el(e,t,e.eventSubscriptionWarmupMs??5e3);let r=n.activeCapture?void 0:e.getLatestScreencastFrame?.(t);!r&&n.activeCapture&&(await e.sendCdp(t,"Page.enable"),s=!0,await e.sendCdp(t,"Page.startScreencast",{format:"jpeg",quality:80},{expectResponse:!1})),r??=await (a=o,d=t,l=n.timeoutMs??1e4,new Promise((e,t)=>{let n=setTimeout(()=>t(new M("SCREENSHOT_TIMEOUT",`no Page.screencastFrame received for ${F(d)} within ${l}ms; make sure the target session is active and can produce screenshot frames`)),l);a.then(t=>{clearTimeout(n),e(t)},e=>{clearTimeout(n),t(e)})})),s&&await e.sendCdp(t,"Page.screencastFrameAck",{},{expectResponse:!1}).catch(()=>void 0);let i=function(e){let t=e.replace(/\s+/g,"");if(!t||t.length%4!=0||!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw new M("INVALID_SCREENSHOT_DATA","Page.screencastFrame returned invalid base64 data");let n=Buffer.from(t,"base64");if(n.length<4||255!==n[0]||216!==n[1]||255!==n[n.length-2]||217!==n[n.length-1])throw new M("INVALID_SCREENSHOT_DATA","Page.screencastFrame did not return a complete JPEG image");let r=function(e){let t=new Set([192,193,194,195,197,198,199,201,202,203,205,206,207]),n=2;for(;n+3<e.length;){if(255!==e[n]){n++;continue}for(;n<e.length&&255===e[n];)n++;let r=e[n++];if(void 0===r||217===r||218===r)break;if(1===r||r>=208&&r<=215)continue;if(n+1>=e.length)break;let o=e.readUInt16BE(n);if(o<2||n+o>e.length)break;if(t.has(r)){if(o<7)break;let t=e.readUInt16BE(n+3),r=e.readUInt16BE(n+5);if(r>0&&t>0)return{width:r,height:t};break}n+=o}}(n);if(!r)throw new M("INVALID_SCREENSHOT_DATA","Page.screencastFrame JPEG has no readable dimensions");return{buffer:n,data:t,...r}}(r.data);return{data:i.data,format:"jpeg",source:"Page.screencastFrame",width:i.width,height:i.height,byteLength:i.buffer.length}}finally{s&&await e.sendCdp(t,"Page.stopScreencast",{},{expectResponse:!1}).catch(()=>void 0),i()}})}function ed(e,t){return"CDP"===e.messageType&&e.clientId===t.clientId&&e.sessionId===t.sessionId}async function el(e,t,n,r){let o;if(n<=0)return;let i=Date.now()+n,s=new Promise(e=>{o=e}),a=e.subscribeMessage(e=>{ed(e,t)&&o()});try{for(;Date.now()<i;){if(em(r),await e.sendCdp(t,"Page.getResourceTree",{},{expectResponse:!1}).catch(()=>void 0),await function(e,t,n){return new Promise((r,o)=>{let i=new AbortController,s=setTimeout(()=>{i.abort(),r(!1)},t);n?.addEventListener("abort",()=>{clearTimeout(s),i.abort(),o(n?.reason instanceof Error?n.reason:Error("operation aborted"))},{once:!0,signal:i.signal}),e.then(()=>{clearTimeout(s),i.abort(),r(!0)},e=>{clearTimeout(s),i.abort(),o(e)})})}(s,Math.min(250,Math.max(0,i-Date.now())),r))return;await eg(Math.min(50,Math.max(0,i-Date.now())),r)}}finally{a()}}function ec(e){return c(e)?e.objectId?`<${String(e.description||e.className||"Object")} (objectId:${String(e.objectId)})>`:"value"in e?eu(e.value):"string"==typeof e.description?e.description:eu(e):eu(e)}function eu(e){if("string"==typeof e)return e;if(void 0===e)return"undefined";try{let t=JSON.stringify(e);return void 0===t?String(e):t}catch{return String(e)}}function ep(e){return/is not (found|available)/i.test(e instanceof Error?e.message:String(e))}async function eh(e,t){let n=Date.now()+t;for(;;)try{return await e()}catch(e){if(!ep(e)||Date.now()>=n)throw e;await eg(50)}}async function ef(e,t){let n,r=G(e),o=q.get(r)??Promise.resolve(),i=new Promise(e=>{n=e});q.set(r,i),await o.catch(()=>void 0);try{return await t()}finally{n(),q.get(r)===i&&q.delete(r)}}function em(e){if(e?.aborted)throw e.reason instanceof Error?e.reason:Error("operation aborted")}function eg(e,t){return new Promise((n,r)=>{if(t?.aborted)return void r(t.reason instanceof Error?t.reason:Error("operation aborted"));let o=new AbortController,i=setTimeout(()=>{o.abort(),n()},e);t?.addEventListener("abort",()=>{clearTimeout(i),o.abort(),r(t?.reason instanceof Error?t.reason:Error("operation aborted"))},{once:!0,signal:o.signal})})}let e_={schemaVersion:1,cliVersion:h,deviceAppVersion:"1.0.10",packages:{"darwin-arm64":{url:"https://lf3-cdn-tos.bytegoofy.com/obj/tron-demo/7610358476778248474/484109562/1.0.10/darwin-arm64/DoubaoDeveloperTools-v1.0.10-darwin-arm64.zip",sha256:"753dde524302653f7b486382dcd8b76e8aa6eba3290a5cc41d7267c6456a9b79",entry:"豆包开发者工具.app",sizeBytes:0x77ffb5d},"win32-x64":{url:"https://lf3-cdn-tos.bytegoofy.com/obj/tron-demo/7610358476778248474/484109562/1.0.10/win32-x64/DoubaoDeveloperTools-v1.0.10-win32-x64.zip",sha256:"b89faff4d8546a3f15b20fdb653ea5b8c4b3b9bba720b28cb8192d3abc1ec755",entry:"豆包开发者工具.exe",sizeBytes:0x84c6466}}},ew=e("node:child_process"),ey=e("node:crypto");var eb=e.n(ey);let ev=e("node:fs");var eE=e.n(ev);let eI=e("node:http"),eA=e("node:os");var eT=e.n(eA);let eC=e("node:path");var eS=e.n(eC);let ek=e("node:stream"),ej=e("node:url"),eD=e("node:util"),eP=e("../../../node_modules/.pnpm/@byted-doubao-tools+real-device-debug-auth@0.1.3/node_modules/@byted-doubao-tools/real-device-debug-auth/dist/lib/index.js"),ex=e("../../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/index.js"),eL="DBX_DEVICE_APP_PATH",eR="dbx-device-app.json",eO="state.json",e$="versions",eN=eS().dirname((0,ej.fileURLToPath)(import.meta.url)),eq=[{command:"web",description:"打开 Web 模拟器"},{command:"desktop",description:"进入桌面端工具,可进行真机调试"},{command:"status",description:"查看本地调试服务状态"}],eM=[{command:"qr",description:"重新生成真机调试二维码"},{command:"page [url]",description:"在真机打开页面(省略 url 可选择)"},{command:"pages",description:"列出真机可打开页面"},{command:"widget [id]",description:"向真机推送卡片(省略 id 可选择)"},{command:"widgets",description:"列出真机可推送卡片"},{command:"sessions",description:"列出当前可检查的 Lynx sessions"},{command:"use-session <@client:session|latest>",description:"固定 CLI session 或恢复跟随最新"},{command:"get-console",description:"持续输出当前 Lynx 页面新产生的日志"},{command:"take-screenshot",description:"截取当前 Lynx 页面画面"},{command:"get-page-tree",description:"获取当前 Lynx 页面的 DOM 树"},{command:"get-computed-style [node-ref]",description:"获取 DOM 节点的 computed style"},{command:"back",description:"返回主命令"}];function eB(e){if("complete"===e.phase)return`豆包开发者工具已安装:${e.appPath}`;if("install"===e.phase){let t={verify:"验证",extract:"解压",install:"安装"}[e.stage];return`安装豆包开发者工具:${t}`}let t=[void 0===e.percentage?void 0:`${e.percentage}%`,void 0===e.totalBytes?e.downloadedBytes>0?ts(e.downloadedBytes):void 0:`${ts(e.downloadedBytes)} / ${ts(e.totalBytes)}`,`${Math.max(0,Math.round(e.elapsedMs/1e3))}s`].filter(e=>!!e);return`下载豆包开发者工具:${t.join(" \xb7 ")}`}function eU(e,t){let n,r=!1;return o=>{if(!o)return void t?.(void 0);if("download"===o.phase){n=o,t?.(o);return}if(n&&!r&&(r=!0,ne(e,`✓ ${eB(n)}`)),"complete"===o.phase){t?.(void 0),ne(e,`✓ ${eB(o)}`);return}t?.(o)}}function eF(e,t){if("true"===e)return!0;if("false"===e)return!1;throw Error(`${t} must be "true" or "false"`)}async function eV(e){let t,n,r,o,i=e.output??process.stderr,s=e.client??await a({projectPath:e.projectPath,appDir:e.appDir,nodeIdPrefix:"dev-shell"}),d=e.closeDeviceApp??e3,l=new AbortController,c=e.openBrowser??I,u=new Set,p={runtime:e.runtime,client:s,output:i,manageDeviceApp:!0,runtimeInspectionTargetPolicy:{kind:"latest"},openBrowser:c,openQRCodeViewer:e.openQRCodeViewer??((e,t,n)=>t3(e,c,t,i,n)),signal:l.signal,launchDeviceApp:e.launchDeviceApp??(e=>e2(e,i)),closeDeviceApp:d,prepareDeviceApp:e.prepareDeviceApp??(e=>e4(i,e)),...e.onDeviceAppSetupProgress?{onDeviceAppSetupProgress:e.onDeviceAppSetupProgress}:{},openPreparedDeviceApp:e.openPreparedDeviceApp??e5,runRealDeviceAuth:e.runRealDeviceAuth??tH,...e.realDeviceDebugCoordinator?{realDeviceDebugCoordinator:e.realDeviceDebugCoordinator}:{},...e.createRuntimeInspectionSession?{createRuntimeInspectionSession:e.createRuntimeInspectionSession}:{},listAppVersions:e.listAppVersions??(async e=>{let t=await E(e);return t.data?.version_list??[]}),selectItem:e.selectItem,eventTracking:e.eventTracking},h=(e.createRuntimeInspectionSession??B)({namespace:e.runtime.getState().namespace,nodeIdPrefix:"dev-shell-runtime-inspection"});h.catch(()=>void 0),p.runtimeInspectionSession=h;let f=async()=>r||(r=(async()=>{p.activeDeviceId=void 0,t5(),p.manageDeviceApp&&await eY(p)})().finally(()=>{r=void 0})),m=tX(e.runtime.getState().namespace,async()=>{if(p.activeDeviceId&&!o){ne(i,"检测到真机连接断开,正在返回主命令并清理真机调试资源..."),await f();for(let e of u)try{e("client-disconnected")}catch{}}});return await m.start(),{stopped:e.runtime.stopped,getState:()=>e.runtime.getState(),execute(e){let r=new AbortController,o=AbortSignal.any([l.signal,r.signal]);n=r,p.signal=o;let i=eH(e,p);return t=i,i.finally(()=>{t===i&&(t=void 0),n===r&&(n=void 0),p.signal===o&&(p.signal=l.signal)})},cancelActiveCommand(){if(!n||n.signal.aborted)return!1;let e=Error("command cancelled");return e.name="AbortError",n.abort(e),!0},returnToRoot:()=>eK(p,"back","execute",f),handleClientDisconnected:()=>f(),subscribe:e=>(u.add(e),()=>{u.delete(e)}),close:()=>o??=(async()=>{l.abort(new tQ),await t?.catch(()=>void 0),await m.stop().catch(()=>void 0),await f(),await p.runtimeInspectionSession?.then(e=>e.stop()).catch(()=>void 0),await s.stop().catch(()=>void 0),await e.runtime.stop().catch(()=>void 0)})()}}async function eH(e,t){var n;let r;try{r=function(e){let t,n=[],r="",o=!1,i=()=>{r.length>0&&(n.push(r),r="")};for(let n of e.trim()){if(o){r+=n,o=!1;continue}if("\\"===n&&"'"!==t){o=!0;continue}if("'"===n||'"'===n){if(!t){t=n;continue}if(t===n){t=void 0;continue}}if(!t&&/\s/.test(n)){i();continue}r+=n}if(o&&(r+="\\"),t)throw Error(`unterminated ${t} quote`);return i(),n}(e)}catch(e){return ne(t.output,tG(nn(e))),"continue"}let o=r[0]?.toLowerCase(),i=r.slice(1);if(!o)return"continue";if((n=i).includes("--help")||n.includes("-h")){let e="desktop"===o&&i[0]&&!i[0].startsWith("-")?`desktop ${i[0].toLowerCase()}`:o;if(function(e,t){switch(t){case"desktop widget":return ne(e,"usage: widget [widget-id] [--data <json>] [--bot-id <id>] [--device-id <id>]"),ne(e,"推送卡片到已连接真机;省略 widget-id 时从 `widgets` 列表中选择。"),!0;case"desktop page":return ne(e,"usage: page [url] [--device-id <id>]"),ne(e,"通过完整 URL 打开页面;省略 url 时从 `pages` 列表中选择。页面参数请写入 URL query。"),!0;case"desktop":ne(e,"usage: desktop [--agent] [--mcp] [--timeout <seconds>] [--qr-file <file.png>] [--wifi-connect <true|false>] [--defaultDebugTagState <true|false>]"),ne(e,"进入真机模式并连接调试设备,默认准备并打开豆包开发者工具。"),ne(e,"使用 `desktop --agent` 进入 Agent 模式,不准备、启动或关闭豆包开发者工具。"),ne(e,"使用 --mcp 进入 MCP 端到端调试,并从当前 AppID 的版本列表中选择 versionTag。");for(let t of(ne(e,"真机调试命令"),eM))ne(e,` ${t.command.padEnd(22)}${t.description}`);return ne(e,"进入真机模式后执行 `<命令> --help` 查看参数。"),ne(e,"get-page-tree、get-computed-style、take-screenshot 支持通用的 --json 输出。"),!0;case"desktop qr":return ne(e,"usage: qr [--mcp] [--timeout <seconds>] [--qr-file <file.png>] [--wifi-connect <true|false>] [--defaultDebugTagState <true|false>]"),ne(e,"重新生成真机调试二维码;MCP 端到端调试会沿用已选择的 versionTag,也可用 --mcp 重新选择。"),!0;case"desktop get-console":return ne(e,"usage: get-console [--target <@client:session>] [--limit <count>] [--timeout-seconds <seconds>] [--include-stack-traces]"),ne(e,"持续输出当前 Lynx session 新产生的 console 日志;按 Ctrl+C 停止监听并返回真机命令。"),ne(e,"默认仅 error 日志显示调用栈;使用 --include-stack-traces 展开所有日志的调用栈。"),!0;case"desktop sessions":return ne(e,"usage: sessions"),ne(e,"列出当前可检查的 Lynx sessions,并标记 latest、CLI fixed 和 Electron current。"),!0;case"desktop use-session":return ne(e,"usage: use-session <@client:session|latest>"),ne(e,"固定 CLI 后续检查命令使用的 session,或用 latest 恢复到鉴权 client 内最新活跃 session;不会切换 Electron。"),!0;case"desktop take-screenshot":return ne(e,"usage: take-screenshot [--target <@client:session>] [-o, --output <file.jpeg>] [--json]"),ne(e,"保存 Electron 当前为目标 session 输出的最近一帧 JPEG;截图范围跟随 Electron 当前 mode。"),!0;case"desktop get-page-tree":return ne(e,"usage: get-page-tree [--target <@client:session>] [--depth <-1|n>] [--json]"),ne(e,"获取当前 Lynx session 的 DevTools Elements DOM 树;默认 depth=-1。"),ne(e,"终端输出紧凑树;--json 输出节点文本、完整 attributes 和可复用 node-ref。"),!0;case"desktop get-computed-style":return ne(e,"usage: get-computed-style <node-ref> [--properties <name,...>] [--json]"),ne(e,"获取元素节点的 computed style;node-ref 格式为 @<clientId>:<sessionId>:<nodeId>。"),ne(e,"省略 --properties 返回全部属性,例如 --properties color,font-size。"),!0;case"web":return ne(e,"usage: web"),ne(e,"在默认浏览器打开本地 Web 模拟器。"),!0;case"desktop pages":case"desktop widgets":{let n="desktop pages"===t?"打开的页面":"推送的卡片";return ne(e,`usage: ${t.slice(8)}`),ne(e,`列出真机可${n}。`),!0}case"status":return ne(e,"usage: status"),ne(e,"查看本地调试服务状态。"),!0;default:return!1}}(t.output,e))return"continue"}try{switch(o){case"status":return await eK(t,"status","execute",()=>eW(t)),"continue";case"web":return await eK(t,"web_open","execute",()=>eG(t)),"continue";case"desktop":return await ez(t,i)?"enter-device":"continue";case"device":return ne(t.output,"命令 `device` 已更名为 `desktop`,请改用 `desktop`。"),"continue";default:return ne(t.output,`unknown command: ${o}`),["qr","pages","page","widgets","widget","sessions","use-session","get-console","take-screenshot","get-page-tree","get-computed-style"].includes(o)&&ne(t.output,`\`${o}\` is only available in desktop mode; run \`desktop\` first.`),"continue"}}catch(e){return ne(t.output,tG(nn(e))),"continue"}}async function eK(e,t,n,r){let o=e.eventTracking;return o?f({action:t,actionSequence:++o.actionSequence,appId:o.appId??e.runtime.getState().appId,devSessionId:o.devSessionId,errorStage:n},r):r()}async function ez(e,t){let r=t[0]?.toLowerCase();if(!r||r.startsWith("-"))return await eJ(e,t,{reuseDeviceAppMode:!1,reuseVersionTag:!1}),!0;let o=function(e){let t=!1,n=[];for(let r of e)"--json"===r?t=!0:n.push(r);return{args:n,json:t}}(t.slice(1)),i=["get-page-tree","get-computed-style","take-screenshot"].includes(r);try{if(o.json&&!i)throw Error(`--json is not supported by desktop ${r}; use it with get-page-tree, get-computed-style, or take-screenshot`);switch(r){case"qr":return await e0(e,o.args),!0;case"pages":return await eK(e,"pages_list","execute",()=>tk(e,"page",n.discoverPages)),!0;case"page":return await eK(e,"page_push","page_push",()=>tM(e,o.args)),!0;case"widgets":return await eK(e,"widgets_list","execute",()=>tk(e,"widget",n.discoverWidgets)),!0;case"widget":return await eK(e,"widget_push","widget_push",()=>tB(e,o.args)),!0;case"sessions":return await eK(e,"sessions_list","execute",()=>tj(e,o.args)),!0;case"use-session":return await eK(e,"session_select","execute",()=>tD(e,o.args)),!0;case"get-console":return await eK(e,"console_stream","execute",()=>tP(e,o.args)),!0;case"take-screenshot":return await eK(e,"screenshot","execute",()=>tx(e,o.args,o.json)),!0;case"get-page-tree":return await eK(e,"page_tree","execute",()=>tL(e,o.args,o.json)),!0;case"get-computed-style":return await eK(e,"computed_style","execute",()=>tR(e,o.args,o.json)),!0;default:return ne(e.output,`unknown desktop subcommand: ${r}`),!1}}catch(t){if(!o.json||!i)throw t;return nt(e.output,{ok:!1,error:{code:t instanceof M?t.code:"INSPECTION_FAILED",message:nn(t)}}),!0}}async function eY(e){try{var t,n;let r=await e.closeDeviceApp();t=e.output,n=r,"closed"===n.status?ne(t,`豆包开发者工具已关闭:${n.appPath}`):ne(t,`关闭豆包开发者工具失败${n.reason?`:${tG(n.reason)}`:""}`)}catch(t){ne(e.output,`关闭豆包开发者工具失败:${tG(nn(t))}`)}}async function eW(e){let t=await e.client.call(n.getInfo);ne(e.output,`status: ${t.status}`),ne(e.output,`app_id: ${t.appId??"-"}`),ne(e.output,`dev_server: ${t.host??"-"}`),ne(e.output,`web_debugger: ${t.webDebuggerUrl??"-"}`)}async function eG(e){let t=await e.client.call(n.openWebDebugger);ne(e.output,`Web 模拟器已打开:${t}`)}async function eJ(e,t,n){let r=()=>e.realDeviceDebugCoordinator?e.realDeviceDebugCoordinator.runTerminal(()=>eQ(e,t,n)):eQ(e,t,n),o=e.eventTracking;if(!o)return void await r();let i=++o.actionSequence,s=performance.now(),a=n.reuseDeviceAppMode?"qr_refresh":"device_connect";try{let t=await r(),n=t?.status==="connected"?"success":t?.status==="cancelled"?"cancelled":t?.status==="timeout"?"timeout":t?.error?"failed":"skipped";await g({action:a,actionSequence:i,appId:o.appId??e.runtime.getState().appId,devSessionId:o.devSessionId,durationMs:performance.now()-s,...t?.error?{error:t.error,...t.failureStage?{errorStage:t.failureStage}:{},errorType:"device_connection_error"}:{},status:n})}catch(t){throw await g({action:a,actionSequence:i,appId:o.appId??e.runtime.getState().appId,devSessionId:o.devSessionId,durationMs:performance.now()-s,error:t,errorStage:"prepare_device_tool",errorType:"device_connection_error",status:b(t)}),t}}async function eQ(e,t,n){var r,o,i;let s,a,d,l=(0,eD.parseArgs)({args:t,allowPositionals:!1,options:{agent:{type:"boolean"},timeout:{type:"string"},"qr-file":{type:"string"},mcp:{type:"boolean"},"wifi-connect":{type:"string"},defaultDebugTagState:{type:"string"}}});if(n.reuseDeviceAppMode&&l.values.agent)throw Error("--agent is only supported when entering desktop mode");n.reuseDeviceAppMode||(e.manageDeviceApp=!l.values.agent);let c=function(e){if(void 0===e)return;let t=Number(e);if(!Number.isFinite(t)||t<=0)throw Error("--timeout must be a positive number of seconds");return Math.round(1e3*t)}(l.values.timeout),u=function(e){if(!e)return;let t=eS().resolve(e);if(".png"!==eS().extname(t).toLowerCase())throw Error("--qr-file must point to a .png file");return t}(l.values["qr-file"]),p=tz((r={defaultDebugTagState:l.values.defaultDebugTagState,wifiConnect:l.values["wifi-connect"]},d={},void 0!==r.defaultDebugTagState&&(d.defaultDebugTagState=eF(r.defaultDebugTagState,"--defaultDebugTagState")),void 0!==r.wifiConnect&&(d.usb=!eF(r.wifiConnect,"--wifi-connect")),Object.keys(d).length>0?d:void 0)),h=await e.client.call("dev.setConnectionTransport",{type:p.usb?"usb":"wifi"}),f=e.runtime.getState(),m=l.values.mcp?await eX(e,f.appId):n.reuseVersionTag?e.activeVersionTag:void 0;if(l.values.mcp&&!m)return;e.activeVersionTag=m,m&&!l.values.mcp&&ne(e.output,`沿用 MCP 端到端调试 versionTag:${m}`),e.manageDeviceApp||ne(e.output,"已启用 --agent:不会准备、启动或关闭豆包开发者工具。");let g={namespace:f.namespace,projectPath:f.projectPath,appDir:f.appDir,appKey:f.appId,hostUrl:f.host},_=e.manageDeviceApp?await eZ(e):void 0;if(_?.status==="skipped"){let t=_.reason??"豆包开发者工具准备失败";return ne(e.output,`启动真机调试失败:${tG(t)}`),{ok:!1,status:"skipped",timeoutMs:c??6e4,failureStage:"prepare_device_tool",error:t}}t5();let w=new AbortController,y=e.signal?AbortSignal.any([e.signal,w.signal]):w.signal;try{a=await e.runRealDeviceAuth({hostUrl:h.host||f.host,appKey:h.appId||f.appId,versionTag:m,namespace:f.namespace,timeoutMs:c,settings:p,wifiConnectUrl:h.wifiConnectUrl,output:e.output,signal:y,onQRCodeReady:async(t,n)=>{(s=await e.openQRCodeViewer(t,u,n)).closed.then(()=>{w.abort(new tQ)})}})}finally{await s?.close().catch(()=>void 0),t5()}if(function(e,t){let n;if(t.ok){let n=t.client?.clientId===void 0?"":`:client ${t.client.clientId}`,r=t.qrCodeValue?"扫码鉴权完成":"复用已连接设备,已跳过二维码鉴权";ne(e,`真机调试已连接${n}(${r})。`);return}"cancelled"===t.status?ne(e,"install"===t.waitingFor?"二维码页面已关闭,已取消等待设备安装。":"二维码页面已关闭,已取消等待设备连接。"):(n="timeout"===t.status?"install"===t.waitingFor?`设备已连接,但等待安装完成超时(${Math.max(1,Math.ceil(t.timeoutMs/1e3))} 秒)`:`等待设备连接超时(${Math.max(1,Math.ceil(t.timeoutMs/1e3))} 秒)`:tG(t.error??"未知错误"),ne(e,`启动真机调试失败:${n}`))}(e.output,a),a.ok&&"connected"===a.status){a.client?.clientId!==void 0&&(void 0!==e.activeClientId&&e.activeClientId!==a.client.clientId&&(e.runtimeInspectionTargetPolicy={kind:"latest"}),e.activeClientId=a.client.clientId);let t=a.client?.deviceId??(a.client?.clientId===void 0?void 0:String(a.client.clientId));t&&(e.activeDeviceId=t)}if(e.manageDeviceApp&&a.ok&&"connected"===a.status){let t=_?await e1(e,_,g):await e.launchDeviceApp(g);o=e.output,"opened"===(i=t).status?ne(o,`豆包开发者工具已启动:${i.appPath}`):ne(o,`启动豆包开发者工具失败${i.reason?`:${tG(i.reason)}`:""}`)}return a}async function eX(e,t){if(!t)throw Error("无法查询 versionTag,当前工程缺少 AppID。");let n=(await e.listAppVersions(t)).filter(e=>"string"==typeof e.version_tag&&!!e.version_tag.trim());if(!n.length)throw Error(`当前 AppID(${t})没有可选的 versionTag。`);let r=await e.selectItem("versionTag",n,e.output);return r?(ne(e.output,`MCP 端到端调试 versionTag:${r}`),r):void ne(e.output,"已取消 versionTag 选择,未生成二维码。")}async function eZ(e){if(e.prepareDeviceApp){e.onDeviceAppSetupProgress?.(void 0);try{return await e.prepareDeviceApp({onProgress:eU(e.output,e.onDeviceAppSetupProgress),signal:e.signal})}catch(t){return e.onDeviceAppSetupProgress?.(void 0),{status:"skipped",reason:nn(t)}}}}async function e0(e,t){await eJ(e,t,{reuseDeviceAppMode:!0,reuseVersionTag:!0})}async function e1(e,t,n){return"skipped"!==t.status&&t.appPath?e.openPreparedDeviceApp?e.openPreparedDeviceApp(t.appPath,n):e.launchDeviceApp(n):{status:"skipped",reason:t.reason}}async function e2(e,t=process.stderr){let n=await e4(t);return"skipped"!==n.status&&n.appPath?e5(n.appPath,e):{status:"skipped",reason:n.reason}}async function e4(e=process.stderr,t={}){let n=function(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,o=e.appDir??te(),i=e.manifest??e_,s=tn(t);if(t[eL]?.trim()||!s&&e7({...t,[eL]:""},n,o))return;tf(i);let a=tt(n,r);if(!a)return;let d=i.packages[a];if(!d)return;tm(d);let l=tg(i,d),c=e9(t,n);if(!(!s&&tr(c,i,a,d,l)))return{platform:a,version:l,...void 0===d.sizeBytes?{}:{sizeBytes:d.sizeBytes}}}();return n&&!t.onProgress&&(ne(e,"真机调试准备:"),ne(e,`首次或版本更新需要下载豆包开发者工具${n.sizeBytes?`(${ts(n.sizeBytes)})`:""}。`),ne(e,"下载完成后才会生成二维码;下载耗时取决于网络,进度和实际耗时将持续显示。")),await e6({runner:{onProgress:t.onProgress??eU(e),signal:t.signal}})}async function e5(e,t){return await function(e,t,n=process.platform){var r,o,i;let s,a=(r=e,o=n,s=(i=t)?[["namespace",i.namespace],["project",i.appDir??i.projectPath],["app-key",i.appKey],["host-url",i.hostUrl]].flatMap(([e,t])=>t?[`--${e}=${t}`]:[]):[],"darwin"===o?{command:"open",args:[r,...s.length?["--args",...s]:[]]}:"win32"===o?{command:"cmd",args:["/c","start","",r,...s],windowsVerbatimArguments:!0}:{command:r,args:s});return new Promise((e,t)=>{let n=(0,ew.spawn)(a.command,a.args,{stdio:"ignore",windowsVerbatimArguments:a.windowsVerbatimArguments});n.once("error",t),n.once("spawn",e)})}(e,t),{status:"opened",appPath:e}}async function e3(){let e=function(e=process.env,t=process.platform,n=process.arch,r=te()){let o=e[eL]?.trim();if(o)return eS().resolve(o);let i=e7({...e,[eL]:""},t,r);if(i)return i;let s=tt(t,n);if(!s)return;let a=e9(e,t),d=tl(a);if(!d||d.platform!==s)return;let l=ty(tp(a,d.activeDeviceAppVersion),d.entry,"device app state entry");return eE().existsSync(l)?l:void 0}();return e?(await function(e,t=process.platform){return"darwin"===t?tI(e):tA(tC(e,t),{rejectOnNonZero:!0}).then(()=>void 0)}(e),{status:"closed",appPath:e}):{status:"skipped",reason:`${eL} is not set and no packaged or cached device app was found`}}async function e6(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,o=e.appDir??te(),i=tn(t),s=t[eL]?.trim();if(s)return{status:"found",appPath:eS().resolve(s),source:"env"};if(!i){let e=e7({...t,[eL]:""},n,o);if(e)return{status:"found",appPath:e,source:"packaged"}}return e8({env:t,platform:n,arch:r,appDir:o,manifest:e.manifest,runner:e.runner})}async function e8(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,o=e.manifest??e_;tf(o);let i=tt(n,r);if(!i)return{status:"skipped",reason:`device app download is not supported on ${n}/${r}`};let s=o.packages[i];if(!s)return{status:"skipped",reason:`device app package is not configured for ${i} in CLI ${o.cliVersion}`};let a=e9(t,n),d=tg(o,s);if(!tn(t)){let e=tr(a,o,i,s,d);if(e)return tc(a,d),{status:"found",appPath:e,source:"cache"}}let l=await to(a,o,i,s,n,e.runner);return tc(a,d),{status:"found",appPath:l,source:"downloaded"}}function e7(e=process.env,t=process.platform,n=te()){let r=e[eL]?.trim();if(r)return eS().resolve(r);if(!eE().existsSync(n))return;let o=eE().readdirSync(n,{withFileTypes:!0}).find(e=>{var n,r;return n=e,"darwin"===(r=t)?n.isDirectory()&&n.name.endsWith(".app"):"win32"===r?n.isFile()&&n.name.toLowerCase().endsWith(".exe"):n.isFile()&&/\.(appimage|AppImage)$/.test(n.name)});return o?eS().join(n,o.name):void 0}function e9(e=process.env,t=process.platform){let n=e.DBX_DEVICE_APP_CACHE_DIR?.trim();if(n)return eS().resolve(n);if("darwin"===t)return eS().join(eT().homedir(),"Library","Application Support","dbx","device-app");if("win32"===t){let t=e.LOCALAPPDATA?.trim()||eS().join(eT().homedir(),"AppData","Local");return eS().join(t,"dbx","device-app")}return eS().join(eT().homedir(),".local","share","dbx","device-app")}function te(){return eS().resolve(eN,"../../..","device-app")}function tt(e,t){if(("darwin"===e||"win32"===e)&&("arm64"===t||"x64"===t))return`${e}-${t}`}function tn(e){let t=e.DBX_DEVICE_APP_FORCE_DOWNLOAD?.trim().toLowerCase();return!!(t&&"0"!==t&&"false"!==t)}function tr(e,t,n,r,o){var i,s,a,d,l;let c,u=tl(e);if(!u||u.activeDeviceAppVersion!==o||u.cliVersion!==t.cliVersion||u.platform!==n||!tw(u.sha256,r)||u.entry!==r.entry)return;let p=tp(e,o);if(i=p,s=t,a=n,d=r,l=o,!((c=td(i))&&c.cliVersion===s.cliVersion&&c.deviceAppVersion===l&&c.entry===d.entry&&c.platform===a&&tw(c.sha256,d)))return;let h=ty(p,r.entry,"device app entry");return eE().existsSync(h)?h:void 0}async function to(e,t,n,r,o,i={}){tm(r);let s=tg(t,r),a=i.now?.()??Date.now(),d=eS().join(e,".tmp");eE().mkdirSync(d,{recursive:!0}),eE().mkdirSync(eS().join(e,e$),{recursive:!0});let l=eE().mkdtempSync(eS().join(d,`${s}-`)),c=eS().join(l,"device-app.zip"),u=eS().join(l,"extract"),p=tp(e,s);try{var h,f,m,g,_,w,y,b;let d,l;if(i.onProgress?.({phase:"download",downloadedBytes:0,...void 0===r.sizeBytes?{}:{totalBytes:r.sizeBytes,percentage:0},elapsedMs:0}),await ti(r.url,c,i.fetch,i.onProgress,i.signal),r.sha256&&(i.onProgress?.({phase:"install",stage:"verify"}),i.signal?.throwIfAborted(),d=await tu(c),i.signal?.throwIfAborted(),d!==t_(r.sha256)))throw Error(`device app sha256 mismatch: expected ${r.sha256}, got ${d}`);eE().mkdirSync(u,{recursive:!0}),i.onProgress?.({phase:"install",stage:"extract"}),await ta(c,u,o,i);let v=ty(u,r.entry,"device app package entry");(function(e,t){if(!eE().existsSync(e))throw Error(`device app entry not found after extraction: ${e}`);let n=eE().statSync(e);if("darwin"===t){if(!n.isDirectory()||!e.endsWith(".app"))throw Error(`macOS device app entry must be a .app directory: ${e}`);return}if("win32"===t&&(!n.isFile()||!e.toLowerCase().endsWith(".exe")))throw Error(`Windows device app entry must be an .exe file: ${e}`)})(v,o),function(e,t,n,r,o){let i=td(e);if(i&&(i.cliVersion!==t.cliVersion||i.deviceAppVersion!==o||i.entry!==r.entry||i.platform!==n||!tw(i.sha256,r)))throw Error(`device app metadata does not match CLI manifest in ${eS().join(e,eR)}`)}(u,t,n,r,s),i.onProgress?.({phase:"install",stage:"install"}),eE().rmSync(p,{recursive:!0,force:!0}),eE().renameSync(u,p),h=p,f=t,m=n,g=r,_=s,w=a,l={name:"Doubao App V2",cliVersion:f.cliVersion,deviceAppVersion:_,entry:g.entry,platform:m,...g.sha256?{sha256:t_(g.sha256)}:{},installedAt:w},tE(eS().join(h,eR),l),y=e,b={activeDeviceAppVersion:s,cliVersion:t.cliVersion,entry:r.entry,platform:n,...r.sha256?{sha256:t_(r.sha256)}:{},installedAt:a},tE(eS().join(y,eO),b);let E=ty(p,r.entry,"device app entry");return i.onProgress?.({phase:"complete",appPath:E}),E}finally{eE().rmSync(l,{recursive:!0,force:!0})}}async function ti(e,n,r=fetch,o,i){var s,a;let d,l,c,u,p,h,f=new URL(e);if("https:"!==f.protocol&&"http:"!==f.protocol)throw Error(`device app package URL must be http(s): ${e}`);i?.throwIfAborted();let m=await r(e,{signal:i});if(!m.ok)throw Error(`device app package download failed: HTTP ${m.status} ${m.statusText}`);if(!m.body)throw Error("device app package download failed: empty response body");let g=m.body;await (0,t.pipeline)(ek.Readable.fromWeb(g),(s=m,a=o,d=function(e){if(!e)return;let t=Number(e);return Number.isFinite(t)&&t>0?t:void 0}(s.headers.get("content-length")),l=0,c=-1,u=0,p=Date.now(),(h=e=>{if(!a)return;if(d){let t=Math.min(100,Math.floor(l/d*100));if(!e&&100!==t&&t<c+10||t===c)return;c=t;let n=Date.now()-p;a({phase:"download",downloadedBytes:l,totalBytes:d,percentage:t,elapsedMs:n});return}if(!e&&l-u<0x3200000||l===u)return;u=l;let t=Date.now()-p;a({phase:"download",downloadedBytes:l,elapsedMs:t})})(!1),new ek.Transform({transform(e,t,n){l+=e.length,h(!1),n(null,e)},flush(e){h(!0),e()}})),eE().createWriteStream(n),{signal:i})}function ts(e){let t=["B","KB","MB","GB"],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return 0===r?`${n} ${t[r]}`:`${n.toFixed(1)} ${t[r]}`}async function ta(e,t,n,r){let o=r.runCommand??((e,t)=>tA(e,{rejectOnNonZero:!0,signal:t?.signal}).then(()=>void 0));if("darwin"===n){r.signal?.throwIfAborted(),await o({command:"ditto",args:["-x","-k",e,t]},{signal:r.signal});return}if("win32"===n){r.signal?.throwIfAborted(),await o({command:"powershell.exe",args:["-NoProfile","-ExecutionPolicy","Bypass","-Command",`Expand-Archive -LiteralPath ${tb(e)} -DestinationPath ${tb(t)} -Force`],windowsVerbatimArguments:!0},{signal:r.signal});return}throw Error(`device app zip extraction is not supported on ${n}`)}function td(e){let t=tv(eS().join(e,eR));if(!c(t))return;let n=t.cliVersion,r=t.deviceAppVersion,o=t.entry,i=t.platform,s=t.sha256,a=t.installedAt;if("string"==typeof n&&"string"==typeof r&&"string"==typeof o&&"string"==typeof i&&(void 0===s||"string"==typeof s)&&"number"==typeof a)return{name:"string"==typeof t.name?t.name:void 0,cliVersion:n,deviceAppVersion:r,entry:o,platform:i,..."string"==typeof s?{sha256:s}:{},installedAt:a}}function tl(e){let t=tv(eS().join(e,eO));if(c(t)&&"string"==typeof t.activeDeviceAppVersion&&"string"==typeof t.cliVersion&&"string"==typeof t.entry&&"string"==typeof t.platform&&(void 0===t.sha256||"string"==typeof t.sha256)&&"number"==typeof t.installedAt)return{activeDeviceAppVersion:t.activeDeviceAppVersion,cliVersion:t.cliVersion,entry:t.entry,platform:t.platform,..."string"==typeof t.sha256?{sha256:t.sha256}:{},installedAt:t.installedAt}}function tc(e,t){let n=eS().join(e,e$);if(eE().existsSync(n)){for(let e of eE().readdirSync(n,{withFileTypes:!0}))if(e.isDirectory()&&e.name!==t)try{eE().rmSync(eS().join(n,e.name),{recursive:!0,force:!0})}catch{}}}async function tu(e){let n=eb().createHash("sha256");return await (0,t.pipeline)(eE().createReadStream(e),n),n.digest("hex")}function tp(e,t){return th(t),eS().join(e,e$,t)}function th(e){if(!/^[0-9A-Za-z._+-]+$/.test(e))throw Error(`device app version contains unsupported path characters: ${e}`)}function tf(e){if(1!==e.schemaVersion)throw Error(`unsupported device app manifest schemaVersion: ${e.schemaVersion}`);if(!e.cliVersion.trim())throw Error("device app manifest cliVersion is required");if(!e.deviceAppVersion.trim())throw Error("device app manifest deviceAppVersion is required");th(e.deviceAppVersion)}function tm(e){if(!e.url||!e.entry)throw Error("device app package requires url and entry");if(void 0!==e.version){if(!e.version.trim())throw Error("device app package version must not be empty");th(e.version)}if(e.sha256&&!/^[0-9a-fA-F]{64}$/.test(e.sha256))throw Error(`device app package sha256 must be 64 hex characters: ${e.sha256}`);if(void 0!==e.sizeBytes&&(!Number.isSafeInteger(e.sizeBytes)||e.sizeBytes<=0))throw Error(`device app package sizeBytes must be a positive integer: ${e.sizeBytes}`);if(eS().isAbsolute(e.entry)||e.entry.split(/[\\/]+/).includes(".."))throw Error(`device app package entry must be a relative path inside the zip: ${e.entry}`)}function tg(e,t){let n=t.version??e.deviceAppVersion;if(!n.trim())throw Error("device app package version must not be empty");return th(n),n}function t_(e){return e.toLowerCase()}function tw(e,t){return!t.sha256||e===t_(t.sha256)}function ty(e,t,n){if(eS().isAbsolute(t))throw Error(`${n} must be relative: ${t}`);let r=eS().resolve(e),o=eS().resolve(e,t);if(o!==r&&!o.startsWith(`${r}${eS().sep}`))throw Error(`${n} escapes target directory: ${t}`);return o}function tb(e){return`'${e.replace(/'/g,"''")}'`}function tv(e){try{return JSON.parse(eE().readFileSync(e,"utf8"))}catch{return}}function tE(e,t){eE().mkdirSync(eS().dirname(e),{recursive:!0}),eE().writeFileSync(e,`${JSON.stringify(t,null,2)}
13
+ `,"utf8")}async function tI(e){let t=function(e){if(!e.endsWith(".app"))return;let t=function(e){let t=eS().join(e,"Contents","Info.plist");if(!eE().existsSync(t))return;let n=eE().readFileSync(t,"utf8").match(/<key>CFBundleExecutable<\/key>\s*<string>([^<]+)<\/string>/);return n?.[1]}(e)??eS().basename(e,".app");return eS().join(e,"Contents","MacOS",t)}(e);await tA(tC(e,"darwin"),{rejectOnNonZero:!1}),!t||await tT(t)&&await tA({command:"pkill",args:["-f",tS(t)]},{rejectOnNonZero:!1})}function tA(e,t){return new Promise((n,r)=>{let o;t.signal?.throwIfAborted();let i=(0,ew.spawn)(e.command,e.args,{stdio:"ignore",windowsVerbatimArguments:e.windowsVerbatimArguments}),s=!1,a=()=>{i.kill(),(o=setTimeout(()=>i.kill("SIGKILL"),1e3)).unref()},d=e=>{s||(s=!0,clearTimeout(o),t.signal?.removeEventListener("abort",a),e())};t.signal?.addEventListener("abort",a,{once:!0}),i.once("error",e=>d(()=>r(e))),i.once("close",o=>{if(t.signal?.aborted)return void d(()=>r(t.signal?.reason instanceof Error?t.signal.reason:new tQ));let i=o??0;0!==i&&t.rejectOnNonZero?d(()=>r(Error(`${e.command} exited with code ${i}`))):d(()=>n(i))})})}async function tT(e){return 0===await tA({command:"pgrep",args:["-f",tS(e)]},{rejectOnNonZero:!1})}function tC(e,t){return"darwin"===t?{command:"osascript",args:["-e",`tell application (POSIX file "${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}" as alias) to quit`]}:"win32"===t?{command:"cmd",args:["/c","taskkill","/IM",eS().basename(e),"/T"],windowsVerbatimArguments:!0}:{command:"pkill",args:["-f",e]}}function tS(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async function tk(e,t,n){let r=await e.client.call(n);if(!r.length)return void ne(e.output,`no ${t}s found`);for(let n of r)ne(e.output,`- ${t7(t,n)}`)}async function tj(e,t){if(t.length>0)throw Error("sessions does not accept arguments");let n=await tq(e,"sessions"),{session:r}=n;try{let t=await r.getConnectedClients();if(0===t.length)throw new M("DEVICE_NOT_CONNECTED","no debug device is connected");let n=t.flatMap(e=>e.sessions.filter(W).map(t=>({clientId:e.device.clientId,sessionId:t.sessionId,url:t.url}))).sort((e,t)=>e.clientId-t.clientId||t.sessionId-e.sessionId);if(0===n.length)throw new M("NO_ACTIVE_LYNX_SESSION","the connected device has no active Lynx session");let o=r.getRuntimeInspectionTarget?await r.getRuntimeInspectionTarget().catch(()=>null):null,i=tO(e),s=e.activeClientId??(1===t.length?t[0]?.device.clientId:void 0),a=void 0===s?void 0:n.find(e=>e.clientId===s);for(let t of n){let n=[t$(t,o)?"electron":void 0,"fixed"===i.kind&&t$(t,i.target)?"cli":void 0,t$(t,a)?"latest":void 0].filter(e=>void 0!==e);ne(e.output,`${F(t)}${n.length?` ${n.map(e=>`[${e}]`).join(" ")}`:""} ${t.url||"unknown"}`)}}finally{n.owned&&await r.stop().catch(()=>void 0)}}async function tD(e,t){if(1!==t.length)throw Error("use-session requires @<clientId>:<sessionId> or latest");if(t[0]?.toLowerCase()==="latest"){e.runtimeInspectionTargetPolicy={kind:"latest"},ne(e.output,A.bold.blueBright(`CLI 调试目标已恢复为 latest${void 0===e.activeClientId?"":`(client ${e.activeClientId} 内最新活跃 Lynx session)`};不会切换 Electron。`));return}let n=V(t[0]??""),r=await tq(e,"use-session"),{session:o}=r;try{let t=await U(o,{activeClientId:e.activeClientId,explicitTarget:n,signal:e.signal});e.runtimeInspectionTargetPolicy={kind:"fixed",target:{clientId:t.clientId,sessionId:t.sessionId}},ne(e.output,A.bold.blueBright(`CLI 调试目标已固定为 ${F(t)}(${t.url||"unknown"});不会切换 Electron。`))}finally{r.owned&&await o.stop().catch(()=>void 0)}}async function tP(e,t){let n=(0,eD.parseArgs)({args:t,allowPositionals:!1,options:{limit:{type:"string"},"timeout-seconds":{type:"string"},"include-stack-traces":{type:"boolean"},target:{type:"string"}}}),r=function(e){if(void 0===e)return;let t=Number(e);if(!Number.isSafeInteger(t)||t<1||t>100)throw Error("--limit must be an integer between 1 and 100");return t}(n.values.limit),o=function(e){if(void 0===e)return;let t=Number(e);if(!Number.isFinite(t)||t<=0)throw Error("--timeout-seconds must be a positive number");return Math.round(1e3*t)}(n.values["timeout-seconds"]),i=await tq(e,"get-console"),{session:s}=i;try{let t=await tN(e,s,n.values.target);ne(e.output,A.bold.blueBright(`正在监听 client ${t.clientId}、session ${t.sessionId}(${t.url||"unknown"})的新日志;按 Ctrl+C 停止监听。`));let i=await es(s,t,{...void 0===r?{}:{limit:r},...void 0===o?{}:{timeoutMs:o},signal:e.signal,onTargetChange(n){ne(e.output,A.bold.blueBright(`提示:Electron 已切换到 client ${n.clientId}、session ${n.sessionId}(${n.url||"unknown"});当前 CLI 仍监听 client ${t.clientId}、session ${t.sessionId},不会自动跟随 Electron。`))},onMessage(t){ne(e.output,function(e,t={}){var n;let r=e.args.map(ec).join(" "),o=t.includeStackTraces||"error"===e.type?(n=e.stackTrace,c(n)&&Array.isArray(n.callFrames)?n.callFrames.filter(c).map(e=>{let t="string"==typeof e.url?e.url:"",n="number"==typeof e.lineNumber?e.lineNumber:"unknown",r="number"==typeof e.columnNumber?e.columnNumber:"unknown";return` at ${t}:${n}:${r}`}).join("\n"):""):"";return`[${e.type}/${e.thread}] ${r}${o?`
14
+ ${o}`:""}`}(t,{includeStackTraces:n.values["include-stack-traces"]}))}});ne(e.output,`日志监听已停止,共 ${i.count} 条。`)}finally{i.owned&&await s.stop().catch(()=>void 0)}}async function tx(e,t,n=!1){let r=(0,eD.parseArgs)({args:t,allowPositionals:!1,options:{output:{type:"string",short:"o"},target:{type:"string"}}}),o=await tq(e,"take-screenshot"),{session:i}=o;try{let t=await tN(e,i,r.values.target),o=await ea(i,t,{activeCapture:!e.manageDeviceApp}),s=eS().resolve(r.values.output??`screenshot-${Date.now()}.jpeg`);await eE().promises.writeFile(s,Buffer.from(o.data,"base64")),n?nt(e.output,{ok:!0,command:"take-screenshot",target:t,output:s,format:o.format,source:o.source,width:o.width,height:o.height,byteLength:o.byteLength}):ne(e.output,`截图已保存:${s}(${o.width}\xd7${o.height},client ${t.clientId}、session ${t.sessionId},${t.url||"unknown"};${e.manageDeviceApp?"范围跟随 Electron 当前 mode":"由设备按当前截图 mode 生成"})`)}finally{o.owned&&await i.stop().catch(()=>void 0)}}async function tL(e,t,n=!1){let r=(0,eD.parseArgs)({args:t,allowPositionals:!1,options:{depth:{type:"string"},target:{type:"string"}}}),o=function(e){if(void 0===e)return -1;let t=Number(e);if(!Number.isSafeInteger(t)||t<-1)throw Error("--depth must be -1 or a non-negative integer");return t}(r.values.depth),i=await tq(e,"get-page-tree"),{session:s}=i;try{let t=await tN(e,s,r.values.target),i=await z(s,t,{depth:o});if(n)nt(e.output,{ok:!0,command:"get-page-tree",...i});else{let n,r;ne(e.output,`DOM tree: client ${t.clientId}、session ${t.sessionId}(${t.url||"unknown"})`),ne(e.output,(n=[],(r=(e,t,o)=>{n.push(`${t}${o}${function(e){if(et(e))return`${e.ref} #text ${eo(e.nodeValue)}`;let t=(e.localName||e.nodeName).toLowerCase();if(t.startsWith("#"))return`${e.ref} ${t}`;let n=Object.entries(e.attributes).map(([e,t])=>`${e}=${eo(t,80)}`).join(" "),r=e.text||e.children.filter(et).map(e=>e.nodeValue).join("");return[e.ref,`<${t}${n?` ${n}`:""}>`,r?eo(r,120):""].filter(Boolean).join(" ")}(e)}`);let i=e.children.filter(e=>!et(e));i.forEach((e,n)=>{r(e,`${t}${o?"└─ "===o?" ":"│ ":""}`,n===i.length-1?"└─ ":"├─ ")})})(i.root,"",""),i.truncated&&n.push(`… tree truncated after ${i.nodeCount} nodes`),n.join("\n"))),ne(e.output,`共 ${i.nodeCount} 个节点${i.truncated?"(已截断)":""}。`)}}finally{i.owned&&await s.stop().catch(()=>void 0)}}async function tR(e,t,n=!1){let r=(0,eD.parseArgs)({args:t,allowPositionals:!0,options:{properties:{type:"string"}}}),o=r.positionals[0];if(!o)throw new M("INVALID_NODE_REF","node-ref is required; run get-page-tree and pass @<clientId>:<sessionId>:<nodeId>");if(r.positionals.length>1)throw Error("get-computed-style accepts exactly one node-ref");let i=function(e){let t=/^@([1-9]\d*):([1-9]\d*):([1-9]\d*)$/.exec(e.trim());if(!t)throw new M("INVALID_NODE_REF",`invalid node ref "${e}"; expected @<clientId>:<sessionId>:<nodeId>`);let n={clientId:Number(t[1]),sessionId:Number(t[2]),nodeId:Number(t[3])};if(!Number.isSafeInteger(n.clientId)||!Number.isSafeInteger(n.sessionId)||!Number.isSafeInteger(n.nodeId))throw new M("INVALID_NODE_REF",`invalid node ref "${e}"; every id must be a safe integer`);return n}(o),s=function(e){if(void 0===e)return[];let t=e.split(",").map(e=>e.trim());if(0===t.length||t.some(e=>!/^-{0,2}[a-z][a-z0-9-]*$/i.test(e)))throw Error("--properties must be a comma-separated list of CSS property names");return[...new Set(t.map(e=>e.toLowerCase()))]}(r.values.properties),a=await tq(e,"get-computed-style"),{session:d}=a;try{let t=await K(d,i),r=await Y(d,t,i,s);if(n)nt(e.output,{ok:!0,command:"get-computed-style",...r});else if(ne(e.output,`${r.nodeRef} computed style(client ${t.clientId}、session ${t.sessionId})`),0===r.properties.length)ne(e.output,"没有匹配的 computed style 属性。");else{let t=Math.max(...r.properties.map(e=>e.name.length));for(let n of r.properties)ne(e.output,` ${n.name.padEnd(t)} ${n.value}`)}}finally{a.owned&&await d.stop().catch(()=>void 0)}}function tO(e){return e.runtimeInspectionTargetPolicy??{kind:"latest"}}function t$(e,t){return null!=e&&null!=t&&e.clientId===t.clientId&&e.sessionId===t.sessionId}function tN(e,t,n){return U(t,{activeClientId:e.activeClientId,policy:tO(e),...void 0===n?{}:{explicitTarget:V(n)},signal:e.signal})}async function tq(e,t){if(e.runtimeInspectionSession)return{owned:!1,session:await e.runtimeInspectionSession};let n=e.createRuntimeInspectionSession??B;return{owned:!0,session:await n({namespace:e.runtime.getState().namespace,nodeIdPrefix:`dev-shell-${t}`})}}async function tM(e,t){let o=(0,eD.parseArgs)({args:t,allowPositionals:!0,options:{"device-id":{type:"string"}}}),i=o.positionals[0]??await tF(e,"page",n.discoverPages);if(!i)throw Error("page url is required");let s=o.values["device-id"]??e.activeDeviceId;ne(e.output,`debug: page open request ${t9({url:i,deviceId:s})}`);let a=r("page",await e.client.call(n.openPageUrl,{url:i,deviceId:s}));ne(e.output,`page opened: ${i}`),ne(e.output,`status: ${tU(a)}`)}async function tB(e,t){let o=(0,eD.parseArgs)({args:t,allowPositionals:!0,options:{data:{type:"string"},"bot-id":{type:"string"},"device-id":{type:"string"}}}),s=o.positionals[0]??await tF(e,"widget",n.discoverWidgets);if(!s)throw Error("widget id is required");let a=i(o.values.data,"--data"),d=o.values["device-id"]??e.activeDeviceId;ne(e.output,`debug: widget push request ${t9({widgetId:s,data:a,botId:o.values["bot-id"],deviceId:d})}`);let l=r("widget",await e.client.call(n.pushWidget,{widgetId:s,widgetData:a,botId:o.values["bot-id"],deviceId:d}));ne(e.output,`widget pushed: ${s}`),ne(e.output,`status: ${tU(l)}`)}function tU(e){if(!e.ok)return"failed";let t=function(e){if(!e||"object"!=typeof e)return;let t=e.data;if(!t||"object"!=typeof t)return;let n=t.msg;return"string"==typeof n?n:void 0}(e.result);return"string"==typeof t&&t.trim()?t:"ok"}async function tF(e,t,n){let r=await e.client.call(n);if(r.length)return e.selectItem(t,r,e.output)}function tV(e,t){return t.map(t=>{let n=t8(e,t);return n?{label:t7(e,t),value:n}:void 0}).filter(e=>!!e)}async function tH(e){var t,r;let o,i,s,a,l=e.timeoutMs??6e4;if(!e.hostUrl||!e.appKey)return{ok:!1,status:"skipped",timeoutMs:l,failureStage:"create_qr",error:"无法生成二维码,缺少 hostUrl 或 appKey。"};let c=e.hostUrl,p=e.appKey,h=(t=e.namespace,r=l,i=new d(t,{nodeId:`dev-auth-${process.pid}-${Math.random().toString(36).slice(2,8)}`,requestTimeout:2e3}),s=!1,a=new Promise(e=>{o=e}),i.createService({name:`devAuthListener${process.pid}`,events:{"connection.newclient"(e){var t;s||(s=!0,o((t=e.params)&&"object"==typeof t?{scope:"string"==typeof t.scope?t.scope:void 0,type:"string"==typeof t.type?t.type:void 0,clientId:"number"==typeof t.clientId?t.clientId:void 0,deviceId:t1(t),app:"string"==typeof t.app?t.app:void 0}:{}))}}}),{start:()=>i.start(),stop:()=>i.stop(),wait:(e,t=r)=>{var n,o,i;return n=a,o=t,i=e,new Promise((e,t)=>{let r=()=>{clearTimeout(s),t(i?.reason instanceof Error?i.reason:new tQ)},s=setTimeout(()=>{i?.removeEventListener("abort",r),t(new tJ(o))},o);i?.aborted?r():(i?.addEventListener("abort",r,{once:!0}),n.then(t=>{clearTimeout(s),i?.removeEventListener("abort",r),e(t)},e=>{clearTimeout(s),i?.removeEventListener("abort",r),t(e)}))})},async findExistingClient(){let e=await t0(()=>i.call("devtoolConnection.getConnectedClients"),2e3).catch(()=>[]);return function(e){if(!e||"object"!=typeof e)return;let t=e.device,n=t?.info,r="number"==typeof t?.clientId?t.clientId:void 0;return{scope:"all",type:String(n?.network??"").toLowerCase().includes("wifi")?"wifi":"usb",...void 0===r?{}:{clientId:r},deviceId:t1({client:e}),app:"string"==typeof n?.App?n.App:""}}(Array.isArray(e)?e[0]:void 0)},async awaitDirectDebugReady(e){let t=Math.min(r,2500);try{return await i.call(n.awaitDirectDebugReady,{clientId:e,timeoutMs:t},{timeout:t+1e3})}catch{return!1}},waitForInstallResult:(e,t,r,o)=>{var s,a;return s=i.call(n.awaitDeviceInstallResult,{clientId:e,packageName:t,timeoutMs:r},{timeout:r+1e3}),(a=o)?new Promise((e,t)=>{let n=()=>{t(a.reason instanceof Error?a.reason:new tQ)};if(a.aborted){s.catch(()=>void 0),n();return}a.addEventListener("abort",n,{once:!0}),s.then(t=>{a.removeEventListener("abort",n),e(t)},e=>{a.removeEventListener("abort",n),t(e)})}):s}}),f={},m="connection",g="wait_device_connection";await h.start();try{let t;e.signal?.throwIfAborted();let n=await h.findExistingClient(),r=n?.clientId!==void 0&&await h.awaitDirectDebugReady(n.clientId);if(r)await e.onPhaseChange?.("reusing_client");else{let n,r,o;g="create_qr",t=await tK(f,()=>(0,eP.Ph)(function(e,t,n={}){let r=tz(n.settings);return{hostUrl:e,appKey:t,...void 0===n.versionTag?{}:{versionTag:n.versionTag},isSigned:!1,appletType:0,baseApiUrl:u(),authOptions:v(),...!1===r.defaultDebugTagState?{defaultDebugTagState:!1}:{},...!r.usb&&n.wifiConnectUrl?{wifiConnectUrl:n.wifiConnectUrl}:{}}}(c,p,{versionTag:e.versionTag,settings:e.settings,wifiConnectUrl:e.wifiConnectUrl})),e.signal),await e.onPhaseChange?.("waiting_for_scan"),ne(e.output,""),ne(e.output,"使用豆包 App 扫码连接调试设备."),ne(e.output,`二维码创建成功,请在 ${(n=Math.max(1,Math.round(l/1e3)),r=Math.floor(n/60),o=n%60,r>0?`${r}m ${o}s`:`${o}s`)} 前扫码; 超时可在真机模式执行 \`qr\` 创建新二维码.`),ne(e.output,""),await e.onQRCodeReady?.(t.qrCodeValue,t.debugToken),e.signal?.throwIfAborted()}g="wait_device_connection";let o=Date.now()+l;ne(e.output,`等待设备连接 (${l/1e3}s timeout)...`);let i=r?n:await h.wait(e.signal,tZ(o));if(void 0===i.clientId)throw Error("连接的设备缺少 clientId");m="install",g="install_debug_package",await e.onPhaseChange?.("waiting_for_install");let s=await h.waitForInstallResult(i.clientId,p,tZ(o),e.signal);if(!s)throw new tJ(l);if(!s.success)return{ok:!1,status:"skipped",timeoutMs:l,failureStage:g,waitingFor:m,client:i,error:s.message||"安装 AIPackage 失败,请检查网络环境并关注客户端提示"};return{ok:!0,status:"connected",timeoutMs:l,...t?{qrCodeValue:t.qrCodeValue,debugToken:t.debugToken,encryptedDebugPayload:t.encryptedDebugPayload}:{},client:i}}catch(o){let t=o instanceof tJ,n=o instanceof tQ||!!e.signal?.aborted,r=function(e){if(e&&"object"==typeof e)return tW(e,"logId")??tW(e,"log_id")}(o)??f.logId;return{ok:!1,status:n?"cancelled":t?"timeout":"skipped",timeoutMs:l,failureStage:g,waitingFor:m,...r?{logId:r}:{},error:o instanceof Error?o.message:String(o)}}finally{await h.stop()}}async function tK(e,t,n){let r=globalThis.fetch;globalThis.fetch=async(t,o)=>{var i;let s,a=(s=function(e){try{if("string"==typeof e)return new URL(e);if(e instanceof URL)return new URL(e.toString());return new URL(e.url)}catch{return}}(i=t))&&s.pathname.startsWith("/developer/check_api/apps/")&&s.pathname.endsWith("/debug/ticket")?(s.pathname=s.pathname.replace(/^\/developer\/check_api\//,"/app_developer/check_api/"),"string"==typeof i)?s.toString():i instanceof URL?s:new Request(s,i):i,d=await r(a,n&&a!==t&&!o?.signal?{...o,signal:n}:o);return await tY(e,d),d};try{return await t()}finally{globalThis.fetch=r}}function tz(e){return{defaultDebugTagState:e?.defaultDebugTagState??!0,usb:e?.usb??!0}}async function tY(e,t){let n=t.headers.get("x-tt-logid");if(n){e.logId=n;return}try{let n=await t.clone().text();if(!n)return;let r=JSON.parse(n),o=tW(r,"log_id")??tW(r,"logId");o&&(e.logId=o)}catch{}}function tW(e,t){if(!e||"object"!=typeof e)return;let n=e[t];return"string"==typeof n&&n?n:void 0}function tG(e){return e.replace(/\s*[\[((]log_id:\s*[^\]))]+[\]))]/gi,"").trim()}class tJ extends Error{constructor(e){super(`real-device auth timed out after ${e}ms`),this.name="RealDeviceAuthTimeoutError"}}class tQ extends Error{constructor(){super("real-device auth cancelled"),this.name="RealDeviceAuthCancelledError"}}function tX(e,t){let n=new d(e,{nodeId:`dev-disconnect-${process.pid}-${Math.random().toString(36).slice(2,8)}`,requestTimeout:2e3});return n.createService({name:`devDisconnectListener${process.pid}`,events:{"connection.clientDisconnected":()=>t()}}),{start:()=>n.start(),stop:()=>n.stop()}}function tZ(e){return Math.max(0,e-Date.now())}async function t0(e,t){let n=Date.now()+t;for(;;)try{return await e()}catch(e){if(Date.now()>=n)throw e;await new Promise(e=>{setTimeout(e,100)})}}function t1(e){let t=e.client?.device,n=t?.info;return n?.usbDeviceId||t?.xdbId||n?.did||n?.debugRouterId}async function t2(e,t){let n=eS().resolve(t);if(".png"!==eS().extname(n).toLowerCase())throw Error("QR file must use the .png extension");return eE().mkdirSync(eS().dirname(n),{recursive:!0}),await ex.toFile(n,e,{errorCorrectionLevel:"L",margin:4,type:"png"}),n}async function t4(e,t){let n=await ex.toBuffer(e,{errorCorrectionLevel:"L",margin:0,type:"png",width:320}),r=t?await ex.toBuffer(`doubaoapp://local_debug?short_token=${t}`,{errorCorrectionLevel:"L",margin:0,type:"png",width:320}):void 0;return{legacy:n,...r?{modern:r}:{}}}function t5(e=eT().tmpdir()){let t;try{t=eE().readdirSync(e,{withFileTypes:!0})}catch{return}for(let n of t)if(/^dbx-real-device-qr-.*\.(?:png|svg)$/i.test(n.name)&&(n.isFile()||n.isSymbolicLink()))try{eE().unlinkSync(eS().join(e,n.name))}catch{}}async function t3(e,t,n,r=process.stderr,o){let i,s,a;if(n){let t=await t2(e,n);ne(r,`二维码图片已导出至:${t}`)}let{legacy:d,modern:l}=await t4(e,o),c=eb().randomBytes(18).toString("hex"),u=`/${c}/`,p=new Set,h=!1,f=new Promise(e=>{s=e}),m=()=>{clearTimeout(i),i=void 0,h||s()},g=(0,eI.createServer)((e,t)=>{let n=e.url?.split("?",1)[0];if(t.setHeader("Cache-Control","no-store, no-cache, must-revalidate, max-age=0"),t.setHeader("Expires","0"),t.setHeader("Pragma","no-cache"),"GET"===e.method&&n===u){var r;t.writeHead(200,{"Content-Security-Policy":"default-src 'none'; img-src 'self'; connect-src 'self'; script-src 'unsafe-inline'; style-src 'unsafe-inline'","Content-Type":"text/html; charset=utf-8"}),t.end((r=!!l,`<!doctype html>
15
15
  <html lang="zh-CN">
16
16
  <head>
17
17
  <meta charset="utf-8">
@@ -42,10 +42,10 @@ ${o}`:""}`}(t,{includeStackTraces:n.values["include-stack-traces"]}))}});ne(e.ou
42
42
  </script>
43
43
  </body>
44
44
  </html>`));return}if("GET"===e.method&&n===`${u}qr.png`){t.writeHead(200,{"Content-Type":"image/png"}),t.end(d);return}if("GET"===e.method&&n===`${u}qr-modern.png`){if(!l){t.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),t.end("Not found");return}t.writeHead(200,{"Content-Type":"image/png"}),t.end(l);return}if("GET"===e.method&&n===`${u}events`){clearTimeout(i),i=void 0,t.writeHead(200,{Connection:"keep-alive","Content-Type":"text/event-stream"}),t.write("retry: 250\nevent: ready\ndata: ready\n\n"),p.add(t),t.once("close",()=>{p.delete(t),h||0!==p.size||(i=setTimeout(m,750))});return}if("POST"===e.method&&n===`${u}closed`){e.resume(),t.writeHead(204).end(),m();return}t.writeHead(404,{"Content-Type":"text/plain; charset=utf-8"}),t.end("Not found")});await new Promise((e,t)=>{g.once("error",t),g.listen(0,"127.0.0.1",()=>{g.removeListener("error",t),e()})});let _=g.address();if(!_||"string"==typeof _)throw await t6(g),Error("failed to start QR code viewer");let w=`http://127.0.0.1:${_.port}${u}`,y=()=>a??=(async()=>{h=!0,clearTimeout(i);try{for(let e of p)try{e.destroyed||e.writableEnded||(e.once("error",()=>void 0),e.end("event: close\ndata: close\n\n"))}catch{}}finally{p.clear(),await t6(g)}})();try{await t(w),ne(r,"已在默认浏览器打开二维码。")}catch(e){throw await y(),Error(`二维码页面未能自动打开:${nn(e)}`)}return{closed:f,close:y}}function t6(e){return e.listening?new Promise(t=>{e.close(()=>t()),e.closeAllConnections()}):Promise.resolve()}function t8(e,t){if("page"!==e){if(!t||"object"!=typeof t)return;for(let e of["id","pageId","page_id","widgetId","widget_id","versionTag","version_tag","name","path"]){let n=t[e];if("string"==typeof n&&n.trim())return n}return}if(!t||"object"!=typeof t)return;let n=t.path;return"string"==typeof n&&n.trim()?n:void 0}function t7(e,t){let n=t8(e,t);if(!t||"object"!=typeof t)return n??String(t);let r="";return"string"==typeof t.title?r=t.title:"string"==typeof t.name&&(r=t.name),[n,r&&r!==n?r:""].filter(Boolean).join(" ")}function t9(e){return JSON.stringify(Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e).map(([e,t])=>[e,"data"===e?o(t):t])))}function ne(e,t=""){e.write(`${t}
45
- `)}function nt(e,t){ne(e,JSON.stringify(t))}function nn(e){return e instanceof Error?e.message:String(e)}let nr=new Set(["preparing","downloading","installing_tool","reusing_client","waiting_for_scan","waiting_for_install","launching_tool"]),no=new eS.Writable({write(e,t,n){n()}});class ni{options;provider;state={revision:0,phase:"idle",canCancel:!1,canRetry:!1};activeOperation;controlClient;controlClientPromise;disconnectWatcher;qrImages;qrRevision=0;deviceAppOpened=!1;disposed=!1;dependencies;constructor(e){this.options=e,this.dependencies={connectClient:a,prepareDeviceApp:e4,runAuth:tH,renderQRCodes:t4,openDeviceApp:e5,closeDeviceApp:e3,createDisconnectWatcher:tX,...e.dependencies},this.provider={getState:()=>this.getState(),start:()=>this.startWeb(),cancel:e=>this.cancelWeb(e),getQrImage:(e,t)=>this.getQrImage(e,t)}}async runTerminal(e){if(this.activeOperation&&this.isActive())throw Error("REAL_DEVICE_DEBUG_BUSY: Web 或终端已有真机调试流程正在运行。");"connected"===this.state.phase&&(await this.stopDisconnectWatcher(),this.deviceAppOpened&&(await this.dependencies.closeDeviceApp().catch(()=>void 0),this.deviceAppOpened=!1));let t={id:eb().randomUUID(),owner:"terminal",abortController:new AbortController};this.activeOperation=t,this.clearQrImages(),this.replaceState({operationId:t.id,owner:"terminal",phase:"preparing",connectionMode:void 0,deadlineAt:void 0,canCancel:!1,canRetry:!1});let n=Promise.resolve().then(e);t.promise=n.then(()=>void 0,()=>void 0);try{return await n}finally{this.activeOperation===t&&(this.activeOperation=void 0,this.replaceState({phase:"idle",operationId:void 0,owner:void 0,connectionMode:void 0,deadlineAt:void 0,canCancel:!1,canRetry:!1}))}}async dispose(){if(this.disposed)return;this.disposed=!0;let e=this.activeOperation;e?.abortController.abort(Error("dev runtime stopped")),await e?.promise?.catch(()=>void 0),this.activeOperation=void 0,this.clearQrImages(),await this.stopDisconnectWatcher(),this.deviceAppOpened&&(await this.dependencies.closeDeviceApp().catch(()=>void 0),this.deviceAppOpened=!1);let t=await this.controlClientPromise?.catch(()=>void 0);await (t??this.controlClient)?.stop().catch(()=>void 0),this.controlClient=void 0,this.controlClientPromise=void 0}getState(){return{...this.state,...this.state.progress?{progress:{...this.state.progress}}:{},...this.state.qr?{qr:{...this.state.qr}}:{},...this.state.error?{error:{...this.state.error}}:{}}}startWeb(){if(this.disposed)return this.fail("DEV_RUNTIME_UNAVAILABLE","runtime","本地调试服务已停止,请重新运行 dbx dev。"),this.getState();if("connected"===this.state.phase||this.activeOperation&&this.isActive())return this.getState();let e={id:eb().randomUUID(),owner:"web",abortController:new AbortController};return this.activeOperation=e,this.clearQrImages(),this.replaceState({operationId:e.id,owner:"web",phase:"preparing",connectionMode:void 0,deadlineAt:void 0,canCancel:!0,canRetry:!1}),e.promise=this.runWebOperation(e).finally(()=>{this.activeOperation===e&&(this.activeOperation=void 0)}),e.promise.catch(()=>void 0),this.getState()}async cancelWeb(e){let t=this.activeOperation;return t&&t.id===e&&"web"===t.owner&&this.isActive()&&(t.abortController.abort(Error("真机调试已取消")),await t.promise?.catch(()=>void 0)),this.getState()}async getQrImage(e,t){if(this.state.operationId!==e||"waiting_for_scan"!==this.state.phase)return;let n=this.qrImages?.[t];return n?{body:new Uint8Array(n),contentType:"image/png"}:void 0}async runWebOperation(e){let{signal:t}=e.abortController,n=!1;try{let r=await this.options.getRuntime();t.throwIfAborted();let o=r.getState();if("running"!==o.status)throw new ns("DEV_RUNTIME_UNAVAILABLE","runtime","本地调试服务尚未就绪,请稍后重试。");let i=await this.getControlClient();t.throwIfAborted();let s=await i.call("dev.setConnectionTransport",{type:"usb"});t.throwIfAborted();let a=await this.dependencies.prepareDeviceApp(no,{signal:t,onProgress:t=>this.handlePreparationProgress(e,t)});if(t.throwIfAborted(),"skipped"===a.status||!a.appPath)throw new ns(a.reason?.includes("not supported")?"UNSUPPORTED_PLATFORM":"TOOL_PREPARE_FAILED","prepare",a.reason?.includes("not supported")?"当前系统暂不支持自动准备 Desktop 工具。":"Desktop 工具准备失败,请重试或使用终端 desktop 查看详情。");let d=Date.now()+6e4;this.patchState(e,{deadlineAt:d});let l=await this.dependencies.runAuth({hostUrl:s.host||o.host,appKey:s.appId||o.appId,namespace:o.namespace,timeoutMs:6e4,settings:{usb:!0,defaultDebugTagState:!0},output:no,signal:t,onPhaseChange:t=>{if("reusing_client"===t){this.clearQrImages(),this.patchState(e,{phase:t,connectionMode:"existing_client"});return}"waiting_for_scan"===t?this.patchState(e,{phase:t,connectionMode:"qr"}):(this.clearQrImages(),this.patchState(e,{phase:t}))},onQRCodeReady:async(n,r)=>{let o=await this.dependencies.renderQRCodes(n,r);t.throwIfAborted(),this.isCurrent(e)&&(this.qrImages=o,this.qrRevision+=1,this.patchState(e,{phase:"waiting_for_scan",connectionMode:"qr",qr:{revision:this.qrRevision,modernAvailable:!!o.modern,legacyAvailable:!0}}))}});if(t.throwIfAborted(),!l.ok||"connected"!==l.status){if("cancelled"===l.status)return void this.cancelled(e);if("timeout"===l.status){this.clearQrImages(),this.replaceOperationState(e,{phase:"timed_out",canCancel:!1,canRetry:!0,error:{code:"install"===l.waitingFor?"PACKAGE_INSTALL_TIMEOUT":"CONNECTION_TIMEOUT",stage:"install"===l.waitingFor?"package_install":"connection",message:"install"===l.waitingFor?"设备已连接,但安装调试包超时,请重试。":"等待扫码连接超时,请重新生成二维码。"}});return}let t="waiting_for_scan"===this.state.phase||"reusing_client"===this.state.phase;throw new ns("install"===l.waitingFor?"PACKAGE_INSTALL_FAILED":t?"REAL_DEVICE_DEBUG_FAILED":"TICKET_FAILED","install"===l.waitingFor?"package_install":t?"connection":"ticket","install"===l.waitingFor?"调试包安装失败,请检查客户端提示后重试。":t?"设备连接失败,请重新扫码。":"二维码创建失败,请稍后重试。")}this.clearQrImages(),this.patchState(e,{phase:"launching_tool",qr:void 0});let c=await this.dependencies.openDeviceApp(a.appPath,{namespace:o.namespace,projectPath:o.projectPath,appDir:o.appDir,appKey:o.appId,hostUrl:o.host});if("opened"!==c.status)throw t.throwIfAborted(),new ns("TOOL_LAUNCH_FAILED","launch","Desktop 工具启动失败,请重试。");if(n=!0,this.deviceAppOpened=!0,t.throwIfAborted(),await this.watchForDisconnect(e,o.namespace),t.throwIfAborted(),"failed"===this.state.phase)return;this.replaceOperationState(e,{phase:"connected",deadlineAt:void 0,canCancel:!1,canRetry:!1})}catch(o){if(t.aborted){await this.stopDisconnectWatcher(),n&&this.deviceAppOpened&&(await this.dependencies.closeDeviceApp().catch(()=>void 0),this.deviceAppOpened=!1),this.cancelled(e);return}let r=o instanceof ns?o:new ns("launching_tool"===this.state.phase?"TOOL_LAUNCH_FAILED":"preparing"===this.state.phase||"downloading"===this.state.phase||"installing_tool"===this.state.phase?"TOOL_PREPARE_FAILED":"REAL_DEVICE_DEBUG_FAILED","launching_tool"===this.state.phase?"launch":"preparing"===this.state.phase||"downloading"===this.state.phase||"installing_tool"===this.state.phase?"prepare":"connection","launching_tool"===this.state.phase?"Desktop 工具启动失败,请重试。":"preparing"===this.state.phase||"downloading"===this.state.phase||"installing_tool"===this.state.phase?"Desktop 工具准备失败,请重试或使用终端 desktop 查看详情。":"真机调试启动失败,请重试。");this.clearQrImages(),this.replaceOperationState(e,{phase:"failed",canCancel:!1,canRetry:!0,error:{code:r.code,stage:r.stage,message:r.message}})}}handlePreparationProgress(e,t){if(t){if("download"===t.phase)return void this.patchState(e,{phase:"downloading",progress:{downloadedBytes:t.downloadedBytes,...void 0===t.totalBytes?{}:{totalBytes:t.totalBytes},...void 0===t.percentage?{}:{percentage:t.percentage}}});"install"===t.phase&&this.patchState(e,{phase:"installing_tool",progress:{installStage:t.stage}})}}async getControlClient(){return this.controlClient?this.controlClient:(this.controlClientPromise||(this.controlClientPromise=this.dependencies.connectClient({projectPath:this.options.projectPath,appDir:this.options.appDir,nodeIdPrefix:"web-real-device"}).then(e=>(this.controlClient=e,e)).catch(e=>{throw this.controlClientPromise=void 0,e})),this.controlClientPromise)}async watchForDisconnect(e,t){await this.stopDisconnectWatcher();let n=this.dependencies.createDisconnectWatcher(t,async()=>{this.isCurrentState(e)&&("launching_tool"===this.state.phase||"connected"===this.state.phase)&&(this.clearQrImages(),this.replaceState({phase:"failed",canCancel:!1,canRetry:!0,error:{code:"DEVICE_DISCONNECTED",stage:"disconnect",message:"真机连接已断开,请重新扫码。"}}),this.deviceAppOpened&&(await this.dependencies.closeDeviceApp().catch(()=>void 0),this.deviceAppOpened=!1))});(await n.start(),this.isCurrent(e))?this.disconnectWatcher=n:await n.stop().catch(()=>void 0)}async stopDisconnectWatcher(){let e=this.disconnectWatcher;this.disconnectWatcher=void 0,await e?.stop().catch(()=>void 0)}cancelled(e){this.clearQrImages(),this.replaceOperationState(e,{phase:"cancelled",connectionMode:void 0,deadlineAt:void 0,canCancel:!1,canRetry:!0})}fail(e,t,n){this.replaceState({phase:"failed",canCancel:!1,canRetry:!0,error:{code:e,stage:t,message:n}})}patchState(e,t){this.isCurrent(e)&&this.replaceState(t)}replaceOperationState(e,t){this.isCurrentState(e)&&this.replaceState(t)}replaceState(e){this.state={...this.state,...e,revision:this.state.revision+1,...e.phase&&!("error"in e)&&"failed"!==e.phase&&"timed_out"!==e.phase?{error:void 0}:{},...e.phase&&"waiting_for_scan"!==e.phase?{qr:void 0}:{},...e.phase&&"downloading"!==e.phase&&"installing_tool"!==e.phase?{progress:void 0}:{}}}clearQrImages(){this.qrImages=void 0}isCurrent(e){return this.activeOperation===e&&!e.abortController.signal.aborted}isCurrentState(e){return this.state.operationId===e.id}isActive(){return nr.has(this.state.phase)}}class ns extends Error{code;stage;constructor(e,t,n){super(n),this.code=e,this.stage=t}}function na(){return new _("dev").description("启动 dev 调试控制台(Web 模拟器、真机调试、页面和卡片推送)").option("--project-path <path>","dbx 项目路径,状态数据会写入该目录下的 .dbx",".").option("--mcp-endpoint <url>","临时覆盖 manifest.mcp_server.end_point;优先级高于环境变量和 manifest").option("--manifest <path>","manifest.yaml 路径;相对路径按 --project-path 解析,默认按项目布局自动解析").option("--skill <path>","运行态 Skill 目录;显式目录优先,相对路径按 --project-path 解析;未传默认 skill/,递归加载所有 SKILL.md").option("--verbose","输出 dev service 生命周期日志",!1).action(async(e,t)=>w(t,t=>nd(t,e)))}async function nd(e,t){let n=(0,ey.randomUUID)(),r=y(),o={devSessionId:n,actionSequence:1,startedAt:performance.now(),runtimeReady:!1,appId:void 0,eventTrackingReady:r};try{return await nl(e,t,o)}catch(e){if(!o.runtimeReady){let t=performance.now()-o.startedAt,r=b(e);await o.eventTrackingReady,await g({action:"start",actionSequence:1,appId:o.appId,devSessionId:n,durationMs:t,error:e,errorStage:"dev_startup",status:r}),await p({appId:o.appId,command:"dev",durationMs:t,error:e,errorStage:"dev_startup",outputMode:"human",status:r})}throw e}}async function nl(e,t,n){let r,o,i,s;e.json&&e.error("dbx dev starts an interactive console and does not support --json");let a=np(),d=(0,eC.resolve)(t.projectPath),{businessTemplatesPath:c,simulatorManifestPath:u,skillsDirectory:h,warnings:f}=T({projectPath:d,manifest:t.manifest,skill:t.skill}),m=[...f];c&&await C(c);let _=u,w=!1;if(_){let e=await S(_);m.push(...e.warnings),w=e.validated,e.usable?(n.appId=r=e.appId,o=e.manifest):_=void 0}let y=await j(process.env,t.mcpEndpoint,_,o),b=x(o),v=k(o),E=P(d).frontendDirectory,I=new eS.PassThrough,A=process.stdin,R=new AbortController,O={},$=new ni({projectPath:d,appDir:E,getRuntime:()=>O.promise?O.promise:Promise.reject(Error("Dev runtime is not ready"))}),N=process.env.DBX_WEB_REAL_DEVICE_DEBUG?.trim()!=="0",q=l({projectPath:d,appDir:E,installSignalHandlers:!0,signal:R.signal,verbose:t.verbose,...N?{realDeviceDebug:{provider:$.provider,dispose:()=>$.dispose()}}:{},devOptions:{...L({appId:r,permissions:v,mcpEndpoint:y,mcpHeaders:b,simulatorBusinessTemplatesPath:c,simulatorManifestPath:_,skillsDirectory:h,printLogs:a?t.verbose:void 0,onLog:a&&!t.verbose?e=>{("error"!==e.level||"build"!==e.scope||"Failed to bundle template"!==e.message)&&("warn"===e.level||"error"===e.level)&&I.write(`${"error"===e.level?"error:":"⚠"} ${e.message}
45
+ `)}function nt(e,t){ne(e,JSON.stringify(t))}function nn(e){return e instanceof Error?e.message:String(e)}let nr=new Set(["preparing","downloading","installing_tool","reusing_client","waiting_for_scan","waiting_for_install","launching_tool"]),no=new ek.Writable({write(e,t,n){n()}});class ni{options;provider;state={revision:0,phase:"idle",canCancel:!1,canRetry:!1};activeOperation;controlClient;controlClientPromise;disconnectWatcher;qrImages;qrRevision=0;deviceAppOpened=!1;disposed=!1;dependencies;constructor(e){this.options=e,this.dependencies={connectClient:a,prepareDeviceApp:e4,runAuth:tH,renderQRCodes:t4,openDeviceApp:e5,closeDeviceApp:e3,createDisconnectWatcher:tX,...e.dependencies},this.provider={getState:()=>this.getState(),start:()=>this.startWeb(),cancel:e=>this.cancelWeb(e),getQrImage:(e,t)=>this.getQrImage(e,t)}}async runTerminal(e){if(this.activeOperation&&this.isActive())throw Error("REAL_DEVICE_DEBUG_BUSY: Web 或终端已有真机调试流程正在运行。");"connected"===this.state.phase&&(await this.stopDisconnectWatcher(),this.deviceAppOpened&&(await this.dependencies.closeDeviceApp().catch(()=>void 0),this.deviceAppOpened=!1));let t={id:eb().randomUUID(),owner:"terminal",abortController:new AbortController};this.activeOperation=t,this.clearQrImages(),this.replaceState({operationId:t.id,owner:"terminal",phase:"preparing",connectionMode:void 0,deadlineAt:void 0,canCancel:!1,canRetry:!1});let n=Promise.resolve().then(e);t.promise=n.then(()=>void 0,()=>void 0);try{return await n}finally{this.activeOperation===t&&(this.activeOperation=void 0,this.replaceState({phase:"idle",operationId:void 0,owner:void 0,connectionMode:void 0,deadlineAt:void 0,canCancel:!1,canRetry:!1}))}}async dispose(){if(this.disposed)return;this.disposed=!0;let e=this.activeOperation;e?.abortController.abort(Error("dev runtime stopped")),await e?.promise?.catch(()=>void 0),this.activeOperation=void 0,this.clearQrImages(),await this.stopDisconnectWatcher(),this.deviceAppOpened&&(await this.dependencies.closeDeviceApp().catch(()=>void 0),this.deviceAppOpened=!1);let t=await this.controlClientPromise?.catch(()=>void 0);await (t??this.controlClient)?.stop().catch(()=>void 0),this.controlClient=void 0,this.controlClientPromise=void 0}getState(){return{...this.state,...this.state.progress?{progress:{...this.state.progress}}:{},...this.state.qr?{qr:{...this.state.qr}}:{},...this.state.error?{error:{...this.state.error}}:{}}}startWeb(){if(this.disposed)return this.fail("DEV_RUNTIME_UNAVAILABLE","runtime","本地调试服务已停止,请重新运行 dbx dev。"),this.getState();if("connected"===this.state.phase||this.activeOperation&&this.isActive())return this.getState();let e={id:eb().randomUUID(),owner:"web",abortController:new AbortController};return this.activeOperation=e,this.clearQrImages(),this.replaceState({operationId:e.id,owner:"web",phase:"preparing",connectionMode:void 0,deadlineAt:void 0,canCancel:!0,canRetry:!1}),e.promise=this.runWebOperation(e).finally(()=>{this.activeOperation===e&&(this.activeOperation=void 0)}),e.promise.catch(()=>void 0),this.getState()}async cancelWeb(e){let t=this.activeOperation;return t&&t.id===e&&"web"===t.owner&&this.isActive()&&(t.abortController.abort(Error("真机调试已取消")),await t.promise?.catch(()=>void 0)),this.getState()}async getQrImage(e,t){if(this.state.operationId!==e||"waiting_for_scan"!==this.state.phase)return;let n=this.qrImages?.[t];return n?{body:new Uint8Array(n),contentType:"image/png"}:void 0}async runWebOperation(e){let{signal:t}=e.abortController,n=!1;try{let r=await this.options.getRuntime();t.throwIfAborted();let o=r.getState();if("running"!==o.status)throw new ns("DEV_RUNTIME_UNAVAILABLE","runtime","本地调试服务尚未就绪,请稍后重试。");let i=await this.getControlClient();t.throwIfAborted();let s=await i.call("dev.setConnectionTransport",{type:"wifi"});t.throwIfAborted();let a=await this.dependencies.prepareDeviceApp(no,{signal:t,onProgress:t=>this.handlePreparationProgress(e,t)});if(t.throwIfAborted(),"skipped"===a.status||!a.appPath)throw new ns(a.reason?.includes("not supported")?"UNSUPPORTED_PLATFORM":"TOOL_PREPARE_FAILED","prepare",a.reason?.includes("not supported")?"当前系统暂不支持自动准备 Desktop 工具。":"Desktop 工具准备失败,请重试或使用终端 desktop 查看详情。");let d=Date.now()+6e4;this.patchState(e,{deadlineAt:d});let l=await this.dependencies.runAuth({hostUrl:s.host||o.host,appKey:s.appId||o.appId,namespace:o.namespace,timeoutMs:6e4,settings:{usb:!1,defaultDebugTagState:!0},wifiConnectUrl:s.wifiConnectUrl,output:no,signal:t,onPhaseChange:t=>{if("reusing_client"===t){this.clearQrImages(),this.patchState(e,{phase:t,connectionMode:"existing_client"});return}"waiting_for_scan"===t?this.patchState(e,{phase:t,connectionMode:"qr"}):(this.clearQrImages(),this.patchState(e,{phase:t}))},onQRCodeReady:async(n,r)=>{let o=await this.dependencies.renderQRCodes(n,r);t.throwIfAborted(),this.isCurrent(e)&&(this.qrImages=o,this.qrRevision+=1,this.patchState(e,{phase:"waiting_for_scan",connectionMode:"qr",qr:{revision:this.qrRevision,modernAvailable:!!o.modern,legacyAvailable:!0}}))}});if(t.throwIfAborted(),!l.ok||"connected"!==l.status){if("cancelled"===l.status)return void this.cancelled(e);if("timeout"===l.status){this.clearQrImages(),this.replaceOperationState(e,{phase:"timed_out",canCancel:!1,canRetry:!0,error:{code:"install"===l.waitingFor?"PACKAGE_INSTALL_TIMEOUT":"CONNECTION_TIMEOUT",stage:"install"===l.waitingFor?"package_install":"connection",message:"install"===l.waitingFor?"设备已连接,但安装调试包超时,请重试。":"等待扫码连接超时,请重新生成二维码。"}});return}let t="waiting_for_scan"===this.state.phase||"reusing_client"===this.state.phase;throw new ns("install"===l.waitingFor?"PACKAGE_INSTALL_FAILED":t?"REAL_DEVICE_DEBUG_FAILED":"TICKET_FAILED","install"===l.waitingFor?"package_install":t?"connection":"ticket","install"===l.waitingFor?"调试包安装失败,请检查客户端提示后重试。":t?"设备连接失败,请重新扫码。":"二维码创建失败,请稍后重试。")}this.clearQrImages(),this.patchState(e,{phase:"launching_tool",qr:void 0});let c=await this.dependencies.openDeviceApp(a.appPath,{namespace:o.namespace,projectPath:o.projectPath,appDir:o.appDir,appKey:o.appId,hostUrl:o.host});if("opened"!==c.status)throw t.throwIfAborted(),new ns("TOOL_LAUNCH_FAILED","launch","Desktop 工具启动失败,请重试。");if(n=!0,this.deviceAppOpened=!0,t.throwIfAborted(),await this.watchForDisconnect(e,o.namespace),t.throwIfAborted(),"failed"===this.state.phase)return;this.replaceOperationState(e,{phase:"connected",deadlineAt:void 0,canCancel:!1,canRetry:!1})}catch(o){if(t.aborted){await this.stopDisconnectWatcher(),n&&this.deviceAppOpened&&(await this.dependencies.closeDeviceApp().catch(()=>void 0),this.deviceAppOpened=!1),this.cancelled(e);return}let r=o instanceof ns?o:new ns("launching_tool"===this.state.phase?"TOOL_LAUNCH_FAILED":"preparing"===this.state.phase||"downloading"===this.state.phase||"installing_tool"===this.state.phase?"TOOL_PREPARE_FAILED":"REAL_DEVICE_DEBUG_FAILED","launching_tool"===this.state.phase?"launch":"preparing"===this.state.phase||"downloading"===this.state.phase||"installing_tool"===this.state.phase?"prepare":"connection","launching_tool"===this.state.phase?"Desktop 工具启动失败,请重试。":"preparing"===this.state.phase||"downloading"===this.state.phase||"installing_tool"===this.state.phase?"Desktop 工具准备失败,请重试或使用终端 desktop 查看详情。":"真机调试启动失败,请重试。");this.clearQrImages(),this.replaceOperationState(e,{phase:"failed",canCancel:!1,canRetry:!0,error:{code:r.code,stage:r.stage,message:r.message}})}}handlePreparationProgress(e,t){if(t){if("download"===t.phase)return void this.patchState(e,{phase:"downloading",progress:{downloadedBytes:t.downloadedBytes,...void 0===t.totalBytes?{}:{totalBytes:t.totalBytes},...void 0===t.percentage?{}:{percentage:t.percentage}}});"install"===t.phase&&this.patchState(e,{phase:"installing_tool",progress:{installStage:t.stage}})}}async getControlClient(){return this.controlClient?this.controlClient:(this.controlClientPromise||(this.controlClientPromise=this.dependencies.connectClient({projectPath:this.options.projectPath,appDir:this.options.appDir,nodeIdPrefix:"web-real-device"}).then(e=>(this.controlClient=e,e)).catch(e=>{throw this.controlClientPromise=void 0,e})),this.controlClientPromise)}async watchForDisconnect(e,t){await this.stopDisconnectWatcher();let n=this.dependencies.createDisconnectWatcher(t,async()=>{this.isCurrentState(e)&&("launching_tool"===this.state.phase||"connected"===this.state.phase)&&(this.clearQrImages(),this.replaceState({phase:"failed",canCancel:!1,canRetry:!0,error:{code:"DEVICE_DISCONNECTED",stage:"disconnect",message:"真机连接已断开,请重新扫码。"}}),this.deviceAppOpened&&(await this.dependencies.closeDeviceApp().catch(()=>void 0),this.deviceAppOpened=!1))});(await n.start(),this.isCurrent(e))?this.disconnectWatcher=n:await n.stop().catch(()=>void 0)}async stopDisconnectWatcher(){let e=this.disconnectWatcher;this.disconnectWatcher=void 0,await e?.stop().catch(()=>void 0)}cancelled(e){this.clearQrImages(),this.replaceOperationState(e,{phase:"cancelled",connectionMode:void 0,deadlineAt:void 0,canCancel:!1,canRetry:!0})}fail(e,t,n){this.replaceState({phase:"failed",canCancel:!1,canRetry:!0,error:{code:e,stage:t,message:n}})}patchState(e,t){this.isCurrent(e)&&this.replaceState(t)}replaceOperationState(e,t){this.isCurrentState(e)&&this.replaceState(t)}replaceState(e){this.state={...this.state,...e,revision:this.state.revision+1,...e.phase&&!("error"in e)&&"failed"!==e.phase&&"timed_out"!==e.phase?{error:void 0}:{},...e.phase&&"waiting_for_scan"!==e.phase?{qr:void 0}:{},...e.phase&&"downloading"!==e.phase&&"installing_tool"!==e.phase?{progress:void 0}:{}}}clearQrImages(){this.qrImages=void 0}isCurrent(e){return this.activeOperation===e&&!e.abortController.signal.aborted}isCurrentState(e){return this.state.operationId===e.id}isActive(){return nr.has(this.state.phase)}}class ns extends Error{code;stage;constructor(e,t,n){super(n),this.code=e,this.stage=t}}function na(){return new _("dev").description("启动 dev 调试控制台(Web 模拟器、真机调试、页面和卡片推送)").option("--project-path <path>","dbx 项目路径,状态数据会写入该目录下的 node_modules/.doubao-dev",".").option("--mcp-endpoint <url>","临时覆盖 manifest.mcp_server.end_point;优先级高于环境变量和 manifest").option("--manifest <path>","manifest.yaml 路径;相对路径按 --project-path 解析,默认按项目布局自动解析").option("--skill <path>","运行态 Skill 目录;显式目录优先,相对路径按 --project-path 解析;未传默认 skill/,递归加载所有 SKILL.md").option("--host [host]","开发服务器监听的主机名或 IP;不带值时交互选择,不传时自动选址").option("--verbose","输出 dev service 生命周期日志",!1).action(async(e,t)=>w(t,t=>nd(t,e)))}async function nd(e,t){let n=(0,ey.randomUUID)(),r=y(),o={devSessionId:n,actionSequence:1,startedAt:performance.now(),runtimeReady:!1,appId:void 0,eventTrackingReady:r};try{return await nl(e,t,o)}catch(e){if(!o.runtimeReady){let t=performance.now()-o.startedAt,r=b(e);await o.eventTrackingReady,await g({action:"start",actionSequence:1,appId:o.appId,devSessionId:n,durationMs:t,error:e,errorStage:"dev_startup",status:r}),await p({appId:o.appId,command:"dev",durationMs:t,error:e,errorStage:"dev_startup",outputMode:"human",status:r})}throw e}}async function nl(e,t,n){let r,o,i,s;e.json&&e.error("dbx dev starts an interactive console and does not support --json");let a=np(),d=t.host;if(!0===d){let t=Reflect.get(await import("./@byted-doubao-apps/kit.js"),"selectDevServerHost");t||e.error("当前内置 SDK 不支持交互选择地址,请升级 SDK,或使用 --host <IP>。"),d=await t()}let c=(0,eC.resolve)(t.projectPath),{businessTemplatesPath:u,simulatorManifestPath:h,skillsDirectory:f,warnings:m}=T({projectPath:c,manifest:t.manifest,skill:t.skill}),_=[...m];u&&await C(u);let w=h,y=!1;if(w){let e=await k(w);_.push(...e.warnings),y=e.validated,e.usable?(n.appId=r=e.appId,o=e.manifest):w=void 0}let b=await j(process.env,t.mcpEndpoint,w,o),v=x(o),E=S(o),I=P(c).frontendDirectory,A=new ek.PassThrough,R=process.stdin,O=new AbortController,$={},N=new ni({projectPath:c,appDir:I,getRuntime:()=>$.promise?$.promise:Promise.reject(Error("Dev runtime is not ready"))}),q=process.env.DBX_WEB_REAL_DEVICE_DEBUG?.trim()!=="0",M=l({projectPath:c,appDir:I,installSignalHandlers:!0,signal:O.signal,verbose:t.verbose,...q?{realDeviceDebug:{provider:N.provider,dispose:()=>N.dispose()}}:{},devOptions:{...L({host:d,appId:r,permissions:E,mcpEndpoint:b,mcpHeaders:v,simulatorBusinessTemplatesPath:u,simulatorManifestPath:w,skillsDirectory:f,printLogs:a?t.verbose:void 0,onLog:a&&!t.verbose?e=>{("error"!==e.level||"build"!==e.scope||"Failed to bundle template"!==e.message)&&("warn"===e.level||"error"===e.level)&&A.write(`${"error"===e.level?"error:":"⚠"} ${e.message}
46
46
  `)}:void 0,onProgress:a?({percentage:e})=>s?.(e):void 0}),compileHooks:{onAfterDevCompile(e){if(0===e.length)return;let t=new Set(e.map(e=>(0,eD.stripVTControlCharacters)(e.message))),n=`error: 应用编译失败,文件监听仍在运行;修复后将自动重新编译
47
47
  ${[...t].join("\n")}
48
- `;a?I.write(n):process.stderr.write(n)},onDevCompileFailed(e){let t=`error: 应用构建失败,文件监听已停止
48
+ `;a?A.write(n):process.stderr.write(n)},onDevCompileFailed(e){let t=`error: 应用构建失败,文件监听已停止
49
49
  ${(0,eD.stripVTControlCharacters)(e.stack??e.message)}
50
- `;a?I.write(t):process.stderr.write(t)}}}}).then(async e=>{i=e,s?.(1),n.appId=e.getState().appId??r,n.runtimeReady=!0;let t=performance.now()-n.startedAt;return await n.eventTrackingReady,await g({action:"start",actionSequence:1,appId:n.appId,devSessionId:n.devSessionId,durationMs:t,status:"success"}),await p({appId:e.getState().appId??r,command:"dev",durationMs:t,outputMode:"human",status:"success"}),e});O.promise=q;let M=D({manifestReady:w,mcpEndpointSet:!!y,warnings:m});if(!a){let t=await q;M&&e.warn(M,{style:"label"});let n=t.getState();return e.log(`Web 模拟器: ${n.webDebuggerUrl??"-"}`),e.log(`pid: ${n.pid??process.pid}`),e.log("stop: Ctrl+C or kill the process"),await t.stopped,nu()}M&&I.write(`⚠ ${M}
51
- `);try{let{runInkDevShell:e}=await import("./dev-shell.js");await e({createSession:(e,t,o)=>{I.pipe(e);let s=q.then(r=>{if("running"===r.getState().status)return eV({projectPath:d,appDir:E,runtime:{stopped:r.stopped,stop:()=>r.stop(),getState:()=>({...r.getState(),projectPath:d})},output:e,onDeviceAppSetupProgress:o,realDeviceDebugCoordinator:$,selectItem:t,eventTracking:n})});return Promise.resolve(nc({session:s,stopped:q.then(e=>e.stopped),subscribe:e=>{let t,n=!1;return s.then(r=>{n||(t=r?.subscribe(e))}).catch(()=>void 0),()=>{n=!0,t?.()}},close:async()=>{R.abort(),await i?.stop().catch(()=>void 0)},returnToRoot:async()=>{let e=await s.catch(()=>void 0);await e?.returnToRoot()},handleClientDisconnected:async()=>{let e=await s.catch(()=>void 0);await e?.handleClientDisconnected()},getState:()=>i?.getState()??{projectPath:d,appDir:E??d,appId:r,namespace:"",session_dir:"",status:"starting",created_at:0,updated_at:0}}))},subscribeCompileProgress:e=>(s=e,()=>{s===e&&(s=void 0)}),stdin:A,toChoices:tV})}finally{R.abort(),await i?.stop().catch(()=>void 0),await $.dispose().catch(()=>void 0),I.destroy()}return nu()}function nc(e){let t,n;return e.session.then(e=>{t=e},()=>void 0),{stopped:e.stopped,cancelActiveCommand:()=>n?.phase!=="waiting"||n.cancelled?t?.cancelActiveCommand()??!1:(n.cancelled=!0,n.resolveCancelled("continue"),!0),close:async()=>{await e.close(),t?await t.close():e.session.then(e=>e?.close()).catch(()=>void 0)},subscribe:e.subscribe,execute(r){let o,i=new Promise(e=>{o=e}),s={cancelled:!1,phase:"waiting",resolveCancelled:o};return n=s,Promise.race([e.session.then(e=>(t=e,s.cancelled)?"continue":(s.phase="running",e?.execute(r)??"continue")),i]).finally(()=>{n===s&&(n=void 0)})},returnToRoot:e.returnToRoot,handleClientDisconnected:e.handleClientDisconnected,getState:()=>t?.getState()??e.getState()}}async function nu(){await m(),process.exit(process.exitCode??0)}function np(e=process.stdin,t=process.stderr){return!!(e.isTTY&&t.isTTY)}export{eM as DEV_SHELL_DEVICE_HELP_ITEMS,eq as DEV_SHELL_HELP_ITEMS,R as dev_namespaceObject,eB as formatDeviceAppSetupStatus};
50
+ `;a?A.write(t):process.stderr.write(t)}}}}).then(async e=>{i=e,s?.(1),n.appId=e.getState().appId??r,n.runtimeReady=!0;let t=performance.now()-n.startedAt;return await n.eventTrackingReady,await g({action:"start",actionSequence:1,appId:n.appId,devSessionId:n.devSessionId,durationMs:t,status:"success"}),await p({appId:e.getState().appId??r,command:"dev",durationMs:t,outputMode:"human",status:"success"}),e});$.promise=M;let B=D({manifestReady:y,mcpEndpointSet:!!b,warnings:_});if(!a){let t=await M;B&&e.warn(B,{style:"label"});let n=t.getState();return e.log(`Web 模拟器: ${n.webDebuggerUrl??"-"}`),e.log(`pid: ${process.pid}`),e.log("stop: Ctrl+C or kill the process"),await t.stopped,nu()}B&&A.write(`⚠ ${B}
51
+ `);try{let{runInkDevShell:e}=await import("./dev-shell.js");await e({createSession:(e,t,o)=>{A.pipe(e);let s=M.then(r=>{if("running"===r.getState().status)return eV({projectPath:c,appDir:I,runtime:{stopped:r.stopped,stop:()=>r.stop(),getState:()=>({...r.getState(),projectPath:c})},output:e,onDeviceAppSetupProgress:o,realDeviceDebugCoordinator:N,selectItem:t,eventTracking:n})});return Promise.resolve(nc({session:s,stopped:M.then(e=>e.stopped),subscribe:e=>{let t,n=!1;return s.then(r=>{n||(t=r?.subscribe(e))}).catch(()=>void 0),()=>{n=!0,t?.()}},close:async()=>{O.abort(),await i?.stop().catch(()=>void 0)},returnToRoot:async()=>{let e=await s.catch(()=>void 0);await e?.returnToRoot()},handleClientDisconnected:async()=>{let e=await s.catch(()=>void 0);await e?.handleClientDisconnected()},getState:()=>i?.getState()??{projectPath:c,appDir:I??c,appId:r,namespace:"",status:"starting",created_at:0,updated_at:0}}))},subscribeCompileProgress:e=>(s=e,()=>{s===e&&(s=void 0)}),stdin:R,toChoices:tV})}finally{O.abort(),await i?.stop().catch(()=>void 0),await N.dispose().catch(()=>void 0),A.destroy()}return nu()}function nc(e){let t,n;return e.session.then(e=>{t=e},()=>void 0),{stopped:e.stopped,cancelActiveCommand:()=>n?.phase!=="waiting"||n.cancelled?t?.cancelActiveCommand()??!1:(n.cancelled=!0,n.resolveCancelled("continue"),!0),close:async()=>{await e.close(),t?await t.close():e.session.then(e=>e?.close()).catch(()=>void 0)},subscribe:e.subscribe,execute(r){let o,i=new Promise(e=>{o=e}),s={cancelled:!1,phase:"waiting",resolveCancelled:o};return n=s,Promise.race([e.session.then(e=>(t=e,s.cancelled)?"continue":(s.phase="running",e?.execute(r)??"continue")),i]).finally(()=>{n===s&&(n=void 0)})},returnToRoot:e.returnToRoot,handleClientDisconnected:e.handleClientDisconnected,getState:()=>t?.getState()??e.getState()}}async function nu(){await m(),process.exit(process.exitCode??0)}function np(e=process.stdin,t=process.stderr){return!!(e.isTTY&&t.isTTY)}export{eM as DEV_SHELL_DEVICE_HELP_ITEMS,eq as DEV_SHELL_HELP_ITEMS,R as dev_namespaceObject,eB as formatDeviceAppSetupStatus};