@pix3/cli 1.6.3 → 2.0.0-alpha.0

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 (168) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +722 -788
  3. package/dist/index.js +557 -421
  4. package/dist/runtime-types.json +1 -1
  5. package/dist/smoke/prebuilt/{build-7MIXIMSZ.mjs → build-7REMSA2S.mjs} +52 -52
  6. package/dist/smoke/prebuilt/chunk-4DGG2BKR.mjs +2 -0
  7. package/dist/smoke/prebuilt/chunk-YLBMUJ2H.mjs +238 -0
  8. package/dist/smoke/prebuilt/runtime.mjs +1 -1
  9. package/dist/smoke/prebuilt/smoke-worker.mjs +211 -2
  10. package/dist/smoke/prebuilt/tree-defaults.mjs +1 -1
  11. package/dist/validate/prebuilt/{build-AUGKXER3.js → build-ADF5EEE2.js} +52 -52
  12. package/dist/validate/prebuilt/bundle-main.js +223 -18
  13. package/dist/validate/prebuilt/chunk-VIHIF4G2.js +238 -0
  14. package/dist/validate/prebuilt/runtime.js +1 -1
  15. package/kit/files/.claude/skills/pix3-editor/SKILL.md +200 -0
  16. package/kit/files/.claude/skills/pix3-nodes/SKILL.md +13 -15
  17. package/kit/files/.claude/skills/pix3-nodes/reference.md +77 -71
  18. package/kit/files/.claude/skills/pix3-scene-format/SKILL.md +38 -41
  19. package/kit/files/.claude/skills/pix3-scene-format/pix3anim.md +185 -0
  20. package/kit/files/.claude/skills/pix3-scene-format/project-files.md +244 -0
  21. package/kit/files/.claude/skills/pix3-scene-format/reference.md +28 -16
  22. package/kit/files/.claude/skills/pix3-scripts/SKILL.md +34 -24
  23. package/kit/files/.claude/skills/pix3-scripts/reference.md +68 -141
  24. package/kit/files/.claude/skills/pix3-verify/SKILL.md +65 -326
  25. package/kit/files/.claude/skills/pix3-verify/reference.md +2 -14
  26. package/kit/files/AGENTS.md +76 -84
  27. package/kit/files/design/tests/bots/pix3-test-bot.d.ts +89 -0
  28. package/kit/kit.json +8 -5
  29. package/package.json +62 -54
  30. package/templates/2d/files/scenes/main.pix3scene +31 -0
  31. package/templates/2d/template.yaml +11 -0
  32. package/templates/3d/files/scenes/main.pix3scene +50 -0
  33. package/templates/3d/template.yaml +11 -0
  34. package/templates/base/files/README.md +39 -0
  35. package/templates/base/files/gitignore +11 -0
  36. package/templates/base/files/index.html +23 -0
  37. package/templates/base/files/package.json +28 -0
  38. package/templates/base/files/src/main.ts +3 -0
  39. package/templates/base/files/tsconfig.json +17 -0
  40. package/templates/base/files/vite.config.ts +10 -0
  41. package/dist/smoke/prebuilt/chunk-CBFYKDS7.mjs +0 -2
  42. package/dist/smoke/prebuilt/chunk-VJHJ5BCO.mjs +0 -239
  43. package/dist/validate/prebuilt/chunk-CFQFEI52.js +0 -239
  44. package/templates/empty-2d/files/README.md +0 -20
  45. package/templates/empty-2d/files/scenes/main.pix3scene +0 -68
  46. package/templates/empty-2d/files/sprites/pix3-logo.png +0 -0
  47. package/templates/empty-2d/template.yaml +0 -7
  48. package/templates/empty-3d/files/README.md +0 -20
  49. package/templates/empty-3d/files/scenes/main.pix3scene +0 -108
  50. package/templates/empty-3d/files/sprites/pix3-logo.png +0 -0
  51. package/templates/empty-3d/template.yaml +0 -7
  52. package/templates/idea-blank/files/README.md +0 -22
  53. package/templates/idea-blank/files/scenes/main.pix3scene +0 -37
  54. package/templates/idea-blank/template.yaml +0 -10
  55. package/templates/minigame-2d/files/README.md +0 -44
  56. package/templates/minigame-2d/files/design/tests/reachability.json +0 -1
  57. package/templates/minigame-2d/files/design/tests/routines/mute-music.json +0 -44
  58. package/templates/minigame-2d/files/scenes/main.pix3scene +0 -84
  59. package/templates/minigame-2d/files/scenes/menu.pix3scene +0 -118
  60. package/templates/minigame-2d/files/scenes/ui/settings-window.pix3scene +0 -138
  61. package/templates/minigame-2d/files/scripts/GameFlow.ts +0 -133
  62. package/templates/minigame-2d/files/scripts/MenuFlow.ts +0 -217
  63. package/templates/minigame-2d/files/scripts/SettingsWindow.ts +0 -198
  64. package/templates/minigame-2d/template.yaml +0 -10
  65. package/templates/playable-2d/files/README.md +0 -30
  66. package/templates/playable-2d/files/design/recipe.md +0 -83
  67. package/templates/playable-2d/files/design/tests/reachability.json +0 -4
  68. package/templates/playable-2d/files/design/tests/routines/intro-to-cta.json +0 -32
  69. package/templates/playable-2d/files/scenes/main.pix3scene +0 -111
  70. package/templates/playable-2d/files/scenes/ui/end-screen.pix3scene +0 -91
  71. package/templates/playable-2d/files/scenes/ui/intro.pix3scene +0 -65
  72. package/templates/playable-2d/files/scripts/CtaButton.ts +0 -55
  73. package/templates/playable-2d/files/scripts/GameFlow.ts +0 -256
  74. package/templates/playable-2d/files/sprites/pix3-logo.png +0 -0
  75. package/templates/playable-2d/template.yaml +0 -9
  76. package/templates/playable-3d/files/README.md +0 -32
  77. package/templates/playable-3d/files/design/recipe.md +0 -127
  78. package/templates/playable-3d/files/design/tests/reachability.json +0 -4
  79. package/templates/playable-3d/files/design/tests/routines/intro-to-cta.json +0 -32
  80. package/templates/playable-3d/files/scenes/main.pix3scene +0 -230
  81. package/templates/playable-3d/files/scenes/ui/end-screen.pix3scene +0 -91
  82. package/templates/playable-3d/files/scenes/ui/intro.pix3scene +0 -65
  83. package/templates/playable-3d/files/scripts/CtaButton.ts +0 -55
  84. package/templates/playable-3d/files/scripts/GameFlow.ts +0 -309
  85. package/templates/playable-3d/files/scripts/GameRules.ts +0 -290
  86. package/templates/playable-3d/files/scripts/ScoreHud.ts +0 -113
  87. package/templates/playable-3d/template.yaml +0 -9
  88. package/templates/recipe-arena-2d/files/README.md +0 -48
  89. package/templates/recipe-arena-2d/files/design/recipe.md +0 -127
  90. package/templates/recipe-arena-2d/files/design/tests/reachability.json +0 -4
  91. package/templates/recipe-arena-2d/files/design/tests/routines/terminal-retry.json +0 -23
  92. package/templates/recipe-arena-2d/files/scenes/main.pix3scene +0 -292
  93. package/templates/recipe-arena-2d/files/scenes/menu.pix3scene +0 -100
  94. package/templates/recipe-arena-2d/files/scenes/prefabs/hazard.pix3scene +0 -42
  95. package/templates/recipe-arena-2d/files/scenes/prefabs/pickup.pix3scene +0 -45
  96. package/templates/recipe-arena-2d/files/scenes/ui/result.pix3scene +0 -85
  97. package/templates/recipe-arena-2d/files/scripts/GameRules.ts +0 -368
  98. package/templates/recipe-arena-2d/files/scripts/MenuFlow.ts +0 -106
  99. package/templates/recipe-arena-2d/files/scripts/PlayerController.ts +0 -151
  100. package/templates/recipe-arena-2d/files/scripts/ScoreHud.ts +0 -94
  101. package/templates/recipe-arena-2d/files/scripts/Spawner.ts +0 -214
  102. package/templates/recipe-arena-2d/files/scripts/TouchRules.ts +0 -174
  103. package/templates/recipe-arena-2d/files/sprites/ph-avatar.png +0 -0
  104. package/templates/recipe-arena-2d/files/sprites/ph-hazard.png +0 -0
  105. package/templates/recipe-arena-2d/files/sprites/ph-pickup.png +0 -0
  106. package/templates/recipe-arena-2d/template.yaml +0 -10
  107. package/templates/recipe-blank-2d/files/README.md +0 -61
  108. package/templates/recipe-blank-2d/files/design/recipe.md +0 -148
  109. package/templates/recipe-blank-2d/files/design/tests/reachability.json +0 -4
  110. package/templates/recipe-blank-2d/files/design/tests/routines/restart.json +0 -27
  111. package/templates/recipe-blank-2d/files/design/tests/routines/terminal-retry.json +0 -23
  112. package/templates/recipe-blank-2d/files/scenes/main.pix3scene +0 -224
  113. package/templates/recipe-blank-2d/files/scenes/ui/result.pix3scene +0 -85
  114. package/templates/recipe-blank-2d/files/scripts/GameRules.ts +0 -350
  115. package/templates/recipe-blank-2d/files/scripts/ScoreHud.ts +0 -110
  116. package/templates/recipe-blank-2d/files/sprites/ph-bg.png +0 -0
  117. package/templates/recipe-blank-2d/files/sprites/ph-capsule.png +0 -0
  118. package/templates/recipe-blank-2d/files/sprites/ph-circle.png +0 -0
  119. package/templates/recipe-blank-2d/files/sprites/ph-orb.png +0 -0
  120. package/templates/recipe-blank-2d/files/sprites/ph-ring.png +0 -0
  121. package/templates/recipe-blank-2d/files/sprites/ph-star.png +0 -0
  122. package/templates/recipe-blank-2d/template.yaml +0 -10
  123. package/templates/recipe-bouncer-2d/files/README.md +0 -81
  124. package/templates/recipe-bouncer-2d/files/design/recipe.md +0 -146
  125. package/templates/recipe-bouncer-2d/files/design/tests/reachability.json +0 -4
  126. package/templates/recipe-bouncer-2d/files/design/tests/routines/terminal-retry.json +0 -23
  127. package/templates/recipe-bouncer-2d/files/scenes/main.pix3scene +0 -615
  128. package/templates/recipe-bouncer-2d/files/scenes/menu.pix3scene +0 -191
  129. package/templates/recipe-bouncer-2d/files/scenes/ui/result.pix3scene +0 -87
  130. package/templates/recipe-bouncer-2d/files/scripts/BallBody.ts +0 -298
  131. package/templates/recipe-bouncer-2d/files/scripts/GameRules.ts +0 -377
  132. package/templates/recipe-bouncer-2d/files/scripts/MenuFlow.ts +0 -109
  133. package/templates/recipe-bouncer-2d/files/scripts/PaddleController.ts +0 -112
  134. package/templates/recipe-bouncer-2d/files/scripts/ScoreHud.ts +0 -94
  135. package/templates/recipe-bouncer-2d/files/scripts/TouchRules.ts +0 -263
  136. package/templates/recipe-bouncer-2d/files/scripts/ball-collision.ts +0 -307
  137. package/templates/recipe-bouncer-2d/files/sprites/ph-ball.png +0 -0
  138. package/templates/recipe-bouncer-2d/files/sprites/ph-bg.png +0 -0
  139. package/templates/recipe-bouncer-2d/files/sprites/ph-bumper.png +0 -0
  140. package/templates/recipe-bouncer-2d/files/sprites/ph-paddle.png +0 -0
  141. package/templates/recipe-bouncer-2d/template.yaml +0 -10
  142. package/templates/recipe-grid-3d/files/README.md +0 -22
  143. package/templates/recipe-grid-3d/files/design/recipe.md +0 -110
  144. package/templates/recipe-grid-3d/files/scenes/main.pix3scene +0 -169
  145. package/templates/recipe-grid-3d/files/scenes/menu.pix3scene +0 -100
  146. package/templates/recipe-grid-3d/files/scenes/ui/result.pix3scene +0 -105
  147. package/templates/recipe-grid-3d/files/scripts/GridBoard.ts +0 -319
  148. package/templates/recipe-grid-3d/files/scripts/GridRules.ts +0 -278
  149. package/templates/recipe-grid-3d/files/scripts/MenuFlow.ts +0 -106
  150. package/templates/recipe-grid-3d/files/scripts/ScoreHud.ts +0 -94
  151. package/templates/recipe-grid-3d/template.yaml +0 -10
  152. package/templates/recipe-tapper-2d/files/README.md +0 -39
  153. package/templates/recipe-tapper-2d/files/design/recipe.md +0 -132
  154. package/templates/recipe-tapper-2d/files/design/tests/reachability.json +0 -4
  155. package/templates/recipe-tapper-2d/files/design/tests/routines/terminal-retry.json +0 -23
  156. package/templates/recipe-tapper-2d/files/scenes/main.pix3scene +0 -269
  157. package/templates/recipe-tapper-2d/files/scenes/menu.pix3scene +0 -100
  158. package/templates/recipe-tapper-2d/files/scenes/prefabs/hazard.pix3scene +0 -42
  159. package/templates/recipe-tapper-2d/files/scenes/prefabs/target.pix3scene +0 -45
  160. package/templates/recipe-tapper-2d/files/scenes/ui/result.pix3scene +0 -85
  161. package/templates/recipe-tapper-2d/files/scripts/GameRules.ts +0 -368
  162. package/templates/recipe-tapper-2d/files/scripts/MenuFlow.ts +0 -106
  163. package/templates/recipe-tapper-2d/files/scripts/ScoreHud.ts +0 -94
  164. package/templates/recipe-tapper-2d/files/scripts/Spawner.ts +0 -214
  165. package/templates/recipe-tapper-2d/files/scripts/TouchRules.ts +0 -192
  166. package/templates/recipe-tapper-2d/files/sprites/ph-hazard.png +0 -0
  167. package/templates/recipe-tapper-2d/files/sprites/ph-target.png +0 -0
  168. package/templates/recipe-tapper-2d/template.yaml +0 -10
package/dist/index.js CHANGED
@@ -1,156 +1,363 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __pix3CreateRequire } from 'node:module'; const require = __pix3CreateRequire(import.meta.url);
3
- var iV=Object.create;var fg=Object.defineProperty;var aV=Object.getOwnPropertyDescriptor;var cV=Object.getOwnPropertyNames;var lV=Object.getPrototypeOf,uV=Object.prototype.hasOwnProperty;var je=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var $=(t,e)=>()=>(t&&(e=t(t=0)),e);var _=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Je=(t,e)=>{for(var r in e)fg(t,r,{get:e[r],enumerable:!0})},dV=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of cV(e))!uV.call(t,s)&&s!==r&&fg(t,s,{get:()=>e[s],enumerable:!(n=aV(e,s))||n.enumerable});return t};var Ze=(t,e,r)=>(r=t!=null?iV(lV(t)):{},dV(e||!t||!t.__esModule?fg(r,"default",{value:t,enumerable:!0}):r,t));var pe=_(lt=>{"use strict";var pg=Symbol.for("yaml.alias"),HE=Symbol.for("yaml.document"),gd=Symbol.for("yaml.map"),WE=Symbol.for("yaml.pair"),hg=Symbol.for("yaml.scalar"),yd=Symbol.for("yaml.seq"),gn=Symbol.for("yaml.node.type"),fV=t=>!!t&&typeof t=="object"&&t[gn]===pg,pV=t=>!!t&&typeof t=="object"&&t[gn]===HE,hV=t=>!!t&&typeof t=="object"&&t[gn]===gd,mV=t=>!!t&&typeof t=="object"&&t[gn]===WE,JE=t=>!!t&&typeof t=="object"&&t[gn]===hg,gV=t=>!!t&&typeof t=="object"&&t[gn]===yd;function GE(t){if(t&&typeof t=="object")switch(t[gn]){case gd:case yd:return!0}return!1}function yV(t){if(t&&typeof t=="object")switch(t[gn]){case pg:case gd:case hg:case yd:return!0}return!1}var _V=t=>(JE(t)||GE(t))&&!!t.anchor;lt.ALIAS=pg;lt.DOC=HE;lt.MAP=gd;lt.NODE_TYPE=gn;lt.PAIR=WE;lt.SCALAR=hg;lt.SEQ=yd;lt.hasAnchor=_V;lt.isAlias=fV;lt.isCollection=GE;lt.isDocument=pV;lt.isMap=hV;lt.isNode=yV;lt.isPair=mV;lt.isScalar=JE;lt.isSeq=gV});var qa=_(mg=>{"use strict";var tt=pe(),Nt=Symbol("break visit"),YE=Symbol("skip children"),Wr=Symbol("remove node");function _d(t,e){let r=XE(e);tt.isDocument(t)?Do(null,t.contents,r,Object.freeze([t]))===Wr&&(t.contents=null):Do(null,t,r,Object.freeze([]))}_d.BREAK=Nt;_d.SKIP=YE;_d.REMOVE=Wr;function Do(t,e,r,n){let s=QE(t,e,r,n);if(tt.isNode(s)||tt.isPair(s))return eT(t,n,s),Do(t,s,r,n);if(typeof s!="symbol"){if(tt.isCollection(e)){n=Object.freeze(n.concat(e));for(let o=0;o<e.items.length;++o){let i=Do(o,e.items[o],r,n);if(typeof i=="number")o=i-1;else{if(i===Nt)return Nt;i===Wr&&(e.items.splice(o,1),o-=1)}}}else if(tt.isPair(e)){n=Object.freeze(n.concat(e));let o=Do("key",e.key,r,n);if(o===Nt)return Nt;o===Wr&&(e.key=null);let i=Do("value",e.value,r,n);if(i===Nt)return Nt;i===Wr&&(e.value=null)}}return s}async function vd(t,e){let r=XE(e);tt.isDocument(t)?await qo(null,t.contents,r,Object.freeze([t]))===Wr&&(t.contents=null):await qo(null,t,r,Object.freeze([]))}vd.BREAK=Nt;vd.SKIP=YE;vd.REMOVE=Wr;async function qo(t,e,r,n){let s=await QE(t,e,r,n);if(tt.isNode(s)||tt.isPair(s))return eT(t,n,s),qo(t,s,r,n);if(typeof s!="symbol"){if(tt.isCollection(e)){n=Object.freeze(n.concat(e));for(let o=0;o<e.items.length;++o){let i=await qo(o,e.items[o],r,n);if(typeof i=="number")o=i-1;else{if(i===Nt)return Nt;i===Wr&&(e.items.splice(o,1),o-=1)}}}else if(tt.isPair(e)){n=Object.freeze(n.concat(e));let o=await qo("key",e.key,r,n);if(o===Nt)return Nt;o===Wr&&(e.key=null);let i=await qo("value",e.value,r,n);if(i===Nt)return Nt;i===Wr&&(e.value=null)}}return s}function XE(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function QE(t,e,r,n){if(typeof r=="function")return r(t,e,n);if(tt.isMap(e))return r.Map?.(t,e,n);if(tt.isSeq(e))return r.Seq?.(t,e,n);if(tt.isPair(e))return r.Pair?.(t,e,n);if(tt.isScalar(e))return r.Scalar?.(t,e,n);if(tt.isAlias(e))return r.Alias?.(t,e,n)}function eT(t,e,r){let n=e[e.length-1];if(tt.isCollection(n))n.items[t]=r;else if(tt.isPair(n))t==="key"?n.key=r:n.value=r;else if(tt.isDocument(n))n.contents=r;else{let s=tt.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}mg.visit=_d;mg.visitAsync=vd});var gg=_(rT=>{"use strict";var tT=pe(),vV=qa(),wV={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},bV=t=>t.replace(/[!,[\]{}]/g,e=>wV[e]),Fa=class t{constructor(e,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,r)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,r){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let n=e.trim().split(/[ \t]+/),s=n.shift();switch(s){case"%TAG":{if(n.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[o,i]=n;return this.tags[o]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[o]=n;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let i=/^\d+\.\d+$/.test(o);return r(6,`Unsupported YAML version ${o}`,i),!1}}default:return r(0,`Unknown directive ${s}`,!0),!1}}tagName(e,r){if(e==="!")return"!";if(e[0]!=="!")return r(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let i=e.slice(2,-1);return i==="!"||i==="!!"?(r(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&r("Verbatim tags must end with a >"),i)}let[,n,s]=e.match(/^(.*!)([^!]*)$/s);s||r(`The ${e} tag has no suffix`);let o=this.tags[n];if(o)try{return o+decodeURIComponent(s)}catch(i){return r(String(i)),null}return n==="!"?e:(r(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[r,n]of Object.entries(this.tags))if(e.startsWith(n))return r+bV(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),s;if(e&&n.length>0&&tT.isNode(e.contents)){let o={};vV.visit(e.contents,(i,a)=>{tT.isNode(a)&&a.tag&&(o[a.tag]=!0)}),s=Object.keys(o)}else s=[];for(let[o,i]of n)o==="!!"&&i==="tag:yaml.org,2002:"||(!e||s.some(a=>a.startsWith(i)))&&r.push(`%TAG ${o} ${i}`);return r.join(`
4
- `)}};Fa.defaultYaml={explicit:!1,version:"1.2"};Fa.defaultTags={"!!":"tag:yaml.org,2002:"};rT.Directives=Fa});var wd=_(Za=>{"use strict";var nT=pe(),SV=qa();function $V(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(r)}return!0}function sT(t){let e=new Set;return SV.visit(t,{Value(r,n){n.anchor&&e.add(n.anchor)}}),e}function oT(t,e){for(let r=1;;++r){let n=`${t}${r}`;if(!e.has(n))return n}}function kV(t,e){let r=[],n=new Map,s=null;return{onAnchor:o=>{r.push(o),s??(s=sT(t));let i=oT(e,s);return s.add(i),i},setAnchors:()=>{for(let o of r){let i=n.get(o);if(typeof i=="object"&&i.anchor&&(nT.isScalar(i.node)||nT.isCollection(i.node)))i.node.anchor=i.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:n}}Za.anchorIsValid=$V;Za.anchorNames=sT;Za.createNodeAnchors=kV;Za.findNewAnchor=oT});var yg=_(iT=>{"use strict";function Ua(t,e,r,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let s=0,o=n.length;s<o;++s){let i=n[s],a=Ua(t,n,String(s),i);a===void 0?delete n[s]:a!==i&&(n[s]=a)}else if(n instanceof Map)for(let s of Array.from(n.keys())){let o=n.get(s),i=Ua(t,n,s,o);i===void 0?n.delete(s):i!==o&&n.set(s,i)}else if(n instanceof Set)for(let s of Array.from(n)){let o=Ua(t,n,s,s);o===void 0?n.delete(s):o!==s&&(n.delete(s),n.add(o))}else for(let[s,o]of Object.entries(n)){let i=Ua(t,n,s,o);i===void 0?delete n[s]:i!==o&&(n[s]=i)}return t.call(e,r,n)}iT.applyReviver=Ua});var Bn=_(cT=>{"use strict";var xV=pe();function aT(t,e,r){if(Array.isArray(t))return t.map((n,s)=>aT(n,String(s),r));if(t&&typeof t.toJSON=="function"){if(!r||!xV.hasAnchor(t))return t.toJSON(e,r);let n={aliasCount:0,count:1,res:void 0};r.anchors.set(t,n),r.onCreate=o=>{n.res=o,delete r.onCreate};let s=t.toJSON(e,r);return r.onCreate&&r.onCreate(s),s}return typeof t=="bigint"&&!r?.keep?Number(t):t}cT.toJS=aT});var bd=_(uT=>{"use strict";var EV=yg(),lT=pe(),TV=Bn(),_g=class{constructor(e){Object.defineProperty(this,lT.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:r,maxAliasCount:n,onAnchor:s,reviver:o}={}){if(!lT.isDocument(e))throw new TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},a=TV.toJS(this,"",i);if(typeof s=="function")for(let{count:c,res:l}of i.anchors.values())s(l,c);return typeof o=="function"?EV.applyReviver(o,{"":a},"",a):a}};uT.NodeBase=_g});var Va=_(dT=>{"use strict";var PV=wd(),OV=qa(),Fo=pe(),IV=bd(),NV=Bn(),vg=class extends IV.NodeBase{constructor(e){super(Fo.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let n;r?.aliasResolveCache?n=r.aliasResolveCache:(n=[],OV.visit(e,{Node:(o,i)=>{(Fo.isAlias(i)||Fo.hasAnchor(i))&&n.push(i)}}),r&&(r.aliasResolveCache=n));let s;for(let o of n){if(o===this)break;o.anchor===this.source&&(s=o)}return s}toJSON(e,r){if(!r)return{source:this.source};let{anchors:n,doc:s,maxAliasCount:o}=r,i=this.resolve(s,r);if(!i){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=n.get(i);if(a||(NV.toJS(i,null,r),a=n.get(i)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(o>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Sd(s,i,n)),a.count*a.aliasCount>o)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(e,r,n){let s=`*${this.source}`;if(e){if(PV.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(e.implicitKey)return`${s} `}return s}};function Sd(t,e,r){if(Fo.isAlias(e)){let n=e.resolve(t),s=r&&n&&r.get(n);return s?s.count*s.aliasCount:0}else if(Fo.isCollection(e)){let n=0;for(let s of e.items){let o=Sd(t,s,r);o>n&&(n=o)}return n}else if(Fo.isPair(e)){let n=Sd(t,e.key,r),s=Sd(t,e.value,r);return Math.max(n,s)}return 1}dT.Alias=vg});var Xe=_(wg=>{"use strict";var CV=pe(),RV=bd(),AV=Bn(),zV=t=>!t||typeof t!="function"&&typeof t!="object",Kn=class extends RV.NodeBase{constructor(e){super(CV.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:AV.toJS(this.value,e,r)}toString(){return String(this.value)}};Kn.BLOCK_FOLDED="BLOCK_FOLDED";Kn.BLOCK_LITERAL="BLOCK_LITERAL";Kn.PLAIN="PLAIN";Kn.QUOTE_DOUBLE="QUOTE_DOUBLE";Kn.QUOTE_SINGLE="QUOTE_SINGLE";wg.Scalar=Kn;wg.isScalarValue=zV});var Ba=_(pT=>{"use strict";var jV=Va(),js=pe(),fT=Xe(),MV="tag:yaml.org,2002:";function LV(t,e,r){if(e){let n=r.filter(o=>o.tag===e),s=n.find(o=>!o.format)??n[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return r.find(n=>n.identify?.(t)&&!n.format)}function DV(t,e,r){if(js.isDocument(t)&&(t=t.contents),js.isNode(t))return t;if(js.isPair(t)){let d=r.schema[js.MAP].createNode?.(r.schema,null,r);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:n,onAnchor:s,onTagObj:o,schema:i,sourceObjects:a}=r,c;if(n&&t&&typeof t=="object"){if(c=a.get(t),c)return c.anchor??(c.anchor=s(t)),new jV.Alias(c.anchor);c={anchor:null,node:null},a.set(t,c)}e?.startsWith("!!")&&(e=MV+e.slice(2));let l=LV(t,e,i.tags);if(!l){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new fT.Scalar(t);return c&&(c.node=d),d}l=t instanceof Map?i[js.MAP]:Symbol.iterator in Object(t)?i[js.SEQ]:i[js.MAP]}o&&(o(l),delete r.onTagObj);let u=l?.createNode?l.createNode(r.schema,t,r):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(r.schema,t,r):new fT.Scalar(t);return e?u.tag=e:l.default||(u.tag=l.tag),c&&(c.node=u),u}pT.createNode=DV});var kd=_($d=>{"use strict";var qV=Ba(),Jr=pe(),FV=bd();function bg(t,e,r){let n=r;for(let s=e.length-1;s>=0;--s){let o=e[s];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let i=[];i[o]=n,n=i}else n=new Map([[o,n]])}return qV.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var hT=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Sg=class extends FV.NodeBase{constructor(e,r){super(e),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(e){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(r.schema=e),r.items=r.items.map(n=>Jr.isNode(n)||Jr.isPair(n)?n.clone(e):n),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(hT(e))this.add(r);else{let[n,...s]=e,o=this.get(n,!0);if(Jr.isCollection(o))o.addIn(s,r);else if(o===void 0&&this.schema)this.set(n,bg(this.schema,s,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}}deleteIn(e){let[r,...n]=e;if(n.length===0)return this.delete(r);let s=this.get(r,!0);if(Jr.isCollection(s))return s.deleteIn(n);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}getIn(e,r){let[n,...s]=e,o=this.get(n,!0);return s.length===0?!r&&Jr.isScalar(o)?o.value:o:Jr.isCollection(o)?o.getIn(s,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!Jr.isPair(r))return!1;let n=r.value;return n==null||e&&Jr.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[r,...n]=e;if(n.length===0)return this.has(r);let s=this.get(r,!0);return Jr.isCollection(s)?s.hasIn(n):!1}setIn(e,r){let[n,...s]=e;if(s.length===0)this.set(n,r);else{let o=this.get(n,!0);if(Jr.isCollection(o))o.setIn(s,r);else if(o===void 0&&this.schema)this.set(n,bg(this.schema,s,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}}};$d.Collection=Sg;$d.collectionFromPath=bg;$d.isEmptyPath=hT});var Ka=_(xd=>{"use strict";var ZV=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function $g(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var UV=(t,e,r)=>t.endsWith(`
5
- `)?$g(r,e):r.includes(`
3
+ var Ny=Object.create;var $i=Object.defineProperty;var Ay=Object.getOwnPropertyDescriptor;var Iy=Object.getOwnPropertyNames;var Ry=Object.getPrototypeOf,My=Object.prototype.hasOwnProperty;var B=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var O=(t,e)=>()=>(t&&(e=t(t=0)),e);var x=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),X=(t,e)=>{for(var r in e)$i(t,r,{get:e[r],enumerable:!0})},Ly=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Iy(e))!My.call(t,s)&&s!==r&&$i(t,s,{get:()=>e[s],enumerable:!(n=Ay(e,s))||n.enumerable});return t};var U=(t,e,r)=>(r=t!=null?Ny(Ry(t)):{},Ly(e||!t||!t.__esModule?$i(r,"default",{value:t,enumerable:!0}):r,t));var $=x(Y=>{"use strict";var Ni=Symbol.for("yaml.alias"),yc=Symbol.for("yaml.document"),yn=Symbol.for("yaml.map"),Sc=Symbol.for("yaml.pair"),Ai=Symbol.for("yaml.scalar"),Sn=Symbol.for("yaml.seq"),Ne=Symbol.for("yaml.node.type"),jy=t=>!!t&&typeof t=="object"&&t[Ne]===Ni,Dy=t=>!!t&&typeof t=="object"&&t[Ne]===yc,Fy=t=>!!t&&typeof t=="object"&&t[Ne]===yn,qy=t=>!!t&&typeof t=="object"&&t[Ne]===Sc,bc=t=>!!t&&typeof t=="object"&&t[Ne]===Ai,By=t=>!!t&&typeof t=="object"&&t[Ne]===Sn;function wc(t){if(t&&typeof t=="object")switch(t[Ne]){case yn:case Sn:return!0}return!1}function Uy(t){if(t&&typeof t=="object")switch(t[Ne]){case Ni:case yn:case Ai:case Sn:return!0}return!1}var Ky=t=>(bc(t)||wc(t))&&!!t.anchor;Y.ALIAS=Ni;Y.DOC=yc;Y.MAP=yn;Y.NODE_TYPE=Ne;Y.PAIR=Sc;Y.SCALAR=Ai;Y.SEQ=Sn;Y.hasAnchor=Ky;Y.isAlias=jy;Y.isCollection=wc;Y.isDocument=Dy;Y.isMap=Fy;Y.isNode=Uy;Y.isPair=qy;Y.isScalar=bc;Y.isSeq=By});var pr=x(Ii=>{"use strict";var G=$(),re=Symbol("break visit"),xc=Symbol("skip children"),ke=Symbol("remove node");function bn(t,e){let r=vc(e);G.isDocument(t)?Nt(null,t.contents,r,Object.freeze([t]))===ke&&(t.contents=null):Nt(null,t,r,Object.freeze([]))}bn.BREAK=re;bn.SKIP=xc;bn.REMOVE=ke;function Nt(t,e,r,n){let s=_c(t,e,r,n);if(G.isNode(s)||G.isPair(s))return Ec(t,n,s),Nt(t,s,r,n);if(typeof s!="symbol"){if(G.isCollection(e)){n=Object.freeze(n.concat(e));for(let i=0;i<e.items.length;++i){let o=Nt(i,e.items[i],r,n);if(typeof o=="number")i=o-1;else{if(o===re)return re;o===ke&&(e.items.splice(i,1),i-=1)}}}else if(G.isPair(e)){n=Object.freeze(n.concat(e));let i=Nt("key",e.key,r,n);if(i===re)return re;i===ke&&(e.key=null);let o=Nt("value",e.value,r,n);if(o===re)return re;o===ke&&(e.value=null)}}return s}async function wn(t,e){let r=vc(e);G.isDocument(t)?await At(null,t.contents,r,Object.freeze([t]))===ke&&(t.contents=null):await At(null,t,r,Object.freeze([]))}wn.BREAK=re;wn.SKIP=xc;wn.REMOVE=ke;async function At(t,e,r,n){let s=await _c(t,e,r,n);if(G.isNode(s)||G.isPair(s))return Ec(t,n,s),At(t,s,r,n);if(typeof s!="symbol"){if(G.isCollection(e)){n=Object.freeze(n.concat(e));for(let i=0;i<e.items.length;++i){let o=await At(i,e.items[i],r,n);if(typeof o=="number")i=o-1;else{if(o===re)return re;o===ke&&(e.items.splice(i,1),i-=1)}}}else if(G.isPair(e)){n=Object.freeze(n.concat(e));let i=await At("key",e.key,r,n);if(i===re)return re;i===ke&&(e.key=null);let o=await At("value",e.value,r,n);if(o===re)return re;o===ke&&(e.value=null)}}return s}function vc(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function _c(t,e,r,n){if(typeof r=="function")return r(t,e,n);if(G.isMap(e))return r.Map?.(t,e,n);if(G.isSeq(e))return r.Seq?.(t,e,n);if(G.isPair(e))return r.Pair?.(t,e,n);if(G.isScalar(e))return r.Scalar?.(t,e,n);if(G.isAlias(e))return r.Alias?.(t,e,n)}function Ec(t,e,r){let n=e[e.length-1];if(G.isCollection(n))n.items[t]=r;else if(G.isPair(n))t==="key"?n.key=r:n.value=r;else if(G.isDocument(n))n.contents=r;else{let s=G.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}Ii.visit=bn;Ii.visitAsync=wn});var Ri=x(Cc=>{"use strict";var kc=$(),Wy=pr(),Vy={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Gy=t=>t.replace(/[!,[\]{}]/g,e=>Vy[e]),hr=class t{constructor(e,r){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,r)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,r){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let n=e.trim().split(/[ \t]+/),s=n.shift();switch(s){case"%TAG":{if(n.length!==2&&(r(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[i,o]=n;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return r(0,"%YAML directive should contain exactly one part"),!1;let[i]=n;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return r(6,`Unsupported YAML version ${i}`,o),!1}}default:return r(0,`Unknown directive ${s}`,!0),!1}}tagName(e,r){if(e==="!")return"!";if(e[0]!=="!")return r(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(r(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&r("Verbatim tags must end with a >"),o)}let[,n,s]=e.match(/^(.*!)([^!]*)$/s);s||r(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(s)}catch(o){return r(String(o)),null}return n==="!"?e:(r(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[r,n]of Object.entries(this.tags))if(e.startsWith(n))return r+Gy(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),s;if(e&&n.length>0&&kc.isNode(e.contents)){let i={};Wy.visit(e.contents,(o,a)=>{kc.isNode(a)&&a.tag&&(i[a.tag]=!0)}),s=Object.keys(i)}else s=[];for(let[i,o]of n)i==="!!"&&o==="tag:yaml.org,2002:"||(!e||s.some(a=>a.startsWith(o)))&&r.push(`%TAG ${i} ${o}`);return r.join(`
4
+ `)}};hr.defaultYaml={explicit:!1,version:"1.2"};hr.defaultTags={"!!":"tag:yaml.org,2002:"};Cc.Directives=hr});var xn=x(mr=>{"use strict";var Oc=$(),Jy=pr();function Hy(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let r=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(r)}return!0}function Tc(t){let e=new Set;return Jy.visit(t,{Value(r,n){n.anchor&&e.add(n.anchor)}}),e}function Pc(t,e){for(let r=1;;++r){let n=`${t}${r}`;if(!e.has(n))return n}}function Yy(t,e){let r=[],n=new Map,s=null;return{onAnchor:i=>{r.push(i),s??(s=Tc(t));let o=Pc(e,s);return s.add(o),o},setAnchors:()=>{for(let i of r){let o=n.get(i);if(typeof o=="object"&&o.anchor&&(Oc.isScalar(o.node)||Oc.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:n}}mr.anchorIsValid=Hy;mr.anchorNames=Tc;mr.createNodeAnchors=Yy;mr.findNewAnchor=Pc});var Mi=x($c=>{"use strict";function gr(t,e,r,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let s=0,i=n.length;s<i;++s){let o=n[s],a=gr(t,n,String(s),o);a===void 0?delete n[s]:a!==o&&(n[s]=a)}else if(n instanceof Map)for(let s of Array.from(n.keys())){let i=n.get(s),o=gr(t,n,s,i);o===void 0?n.delete(s):o!==i&&n.set(s,o)}else if(n instanceof Set)for(let s of Array.from(n)){let i=gr(t,n,s,s);i===void 0?n.delete(s):i!==s&&(n.delete(s),n.add(i))}else for(let[s,i]of Object.entries(n)){let o=gr(t,n,s,i);o===void 0?delete n[s]:o!==i&&(n[s]=o)}return t.call(e,r,n)}$c.applyReviver=gr});var Ve=x(Ac=>{"use strict";var zy=$();function Nc(t,e,r){if(Array.isArray(t))return t.map((n,s)=>Nc(n,String(s),r));if(t&&typeof t.toJSON=="function"){if(!r||!zy.hasAnchor(t))return t.toJSON(e,r);let n={aliasCount:0,count:1,res:void 0};r.anchors.set(t,n),r.onCreate=i=>{n.res=i,delete r.onCreate};let s=t.toJSON(e,r);return r.onCreate&&r.onCreate(s),s}return typeof t=="bigint"&&!r?.keep?Number(t):t}Ac.toJS=Nc});var vn=x(Rc=>{"use strict";var Xy=Mi(),Ic=$(),Qy=Ve(),Li=class{constructor(e){Object.defineProperty(this,Ic.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:r,maxAliasCount:n,onAnchor:s,reviver:i}={}){if(!Ic.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},a=Qy.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?Xy.applyReviver(i,{"":a},"",a):a}};Rc.NodeBase=Li});var yr=x(Mc=>{"use strict";var Zy=xn(),eS=pr(),It=$(),tS=vn(),rS=Ve(),ji=class extends tS.NodeBase{constructor(e){super(It.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,r){if(r?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let n;r?.aliasResolveCache?n=r.aliasResolveCache:(n=[],eS.visit(e,{Node:(i,o)=>{(It.isAlias(o)||It.hasAnchor(o))&&n.push(o)}}),r&&(r.aliasResolveCache=n));let s;for(let i of n){if(i===this)break;i.anchor===this.source&&(s=i)}if(s&&r){let{anchors:i,doc:o,maxAliasCount:a}=r,l=i.get(s);if(l||(rS.toJS(s,null,r),l=i.get(s)),l?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(a>=0&&(l.count+=1,l.aliasCount===0&&(l.aliasCount=_n(o,s,i)),l.count*l.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}}return s}toJSON(e,r){if(!r)return{source:this.source};let n=this.resolve(r.doc,r);if(!n){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(s)}return r.anchors.get(n).res}toString(e,r,n){let s=`*${this.source}`;if(e){if(Zy.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(e.implicitKey)return`${s} `}return s}};function _n(t,e,r){if(It.isAlias(e)){let n=e.resolve(t),s=r&&n&&r.get(n);return s?s.count*s.aliasCount:0}else if(It.isCollection(e)){let n=0;for(let s of e.items){let i=_n(t,s,r);i>n&&(n=i)}return n}else if(It.isPair(e)){let n=_n(t,e.key,r),s=_n(t,e.value,r);return Math.max(n,s)}return 1}Mc.Alias=ji});var V=x(Di=>{"use strict";var nS=$(),sS=vn(),iS=Ve(),oS=t=>!t||typeof t!="function"&&typeof t!="object",Ge=class extends sS.NodeBase{constructor(e){super(nS.SCALAR),this.value=e}toJSON(e,r){return r?.keep?this.value:iS.toJS(this.value,e,r)}toString(){return String(this.value)}};Ge.BLOCK_FOLDED="BLOCK_FOLDED";Ge.BLOCK_LITERAL="BLOCK_LITERAL";Ge.PLAIN="PLAIN";Ge.QUOTE_DOUBLE="QUOTE_DOUBLE";Ge.QUOTE_SINGLE="QUOTE_SINGLE";Di.Scalar=Ge;Di.isScalarValue=oS});var Sr=x(jc=>{"use strict";var aS=yr(),ft=$(),Lc=V(),lS="tag:yaml.org,2002:";function cS(t,e,r){if(e){let n=r.filter(i=>i.tag===e),s=n.find(i=>!i.format)??n[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return r.find(n=>n.identify?.(t)&&!n.format)}function uS(t,e,r){if(ft.isDocument(t)&&(t=t.contents),ft.isNode(t))return t;if(ft.isPair(t)){let f=r.schema[ft.MAP].createNode?.(r.schema,null,r);return f.items.push(t),f}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:n,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=r,l;if(n&&t&&typeof t=="object"){if(l=a.get(t),l)return l.anchor??(l.anchor=s(t)),new aS.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=lS+e.slice(2));let c=cS(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let f=new Lc.Scalar(t);return l&&(l.node=f),f}c=t instanceof Map?o[ft.MAP]:Symbol.iterator in Object(t)?o[ft.SEQ]:o[ft.MAP]}i&&(i(c),delete r.onTagObj);let u=c?.createNode?c.createNode(r.schema,t,r):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(r.schema,t,r):new Lc.Scalar(t);return e?u.tag=e:c.default||(u.tag=c.tag),l&&(l.node=u),u}jc.createNode=uS});var kn=x(En=>{"use strict";var dS=Sr(),Ce=$(),fS=vn();function Fi(t,e,r){let n=r;for(let s=e.length-1;s>=0;--s){let i=e[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=n,n=o}else n=new Map([[i,n]])}return dS.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var Dc=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,qi=class extends fS.NodeBase{constructor(e,r){super(e),Object.defineProperty(this,"schema",{value:r,configurable:!0,enumerable:!1,writable:!0})}clone(e){let r=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(r.schema=e),r.items=r.items.map(n=>Ce.isNode(n)||Ce.isPair(n)?n.clone(e):n),this.range&&(r.range=this.range.slice()),r}addIn(e,r){if(Dc(e))this.add(r);else{let[n,...s]=e,i=this.get(n,!0);if(Ce.isCollection(i))i.addIn(s,r);else if(i===void 0&&this.schema)this.set(n,Fi(this.schema,s,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}}deleteIn(e){let[r,...n]=e;if(n.length===0)return this.delete(r);let s=this.get(r,!0);if(Ce.isCollection(s))return s.deleteIn(n);throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}getIn(e,r){let[n,...s]=e,i=this.get(n,!0);return s.length===0?!r&&Ce.isScalar(i)?i.value:i:Ce.isCollection(i)?i.getIn(s,r):void 0}hasAllNullValues(e){return this.items.every(r=>{if(!Ce.isPair(r))return!1;let n=r.value;return n==null||e&&Ce.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[r,...n]=e;if(n.length===0)return this.has(r);let s=this.get(r,!0);return Ce.isCollection(s)?s.hasIn(n):!1}setIn(e,r){let[n,...s]=e;if(s.length===0)this.set(n,r);else{let i=this.get(n,!0);if(Ce.isCollection(i))i.setIn(s,r);else if(i===void 0&&this.schema)this.set(n,Fi(this.schema,s,r));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}}};En.Collection=qi;En.collectionFromPath=Fi;En.isEmptyPath=Dc});var br=x(Cn=>{"use strict";var pS=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Bi(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var hS=(t,e,r)=>t.endsWith(`
5
+ `)?Bi(r,e):r.includes(`
6
6
  `)?`
7
- `+$g(r,e):(t.endsWith(" ")?"":" ")+r;xd.indentComment=$g;xd.lineComment=UV;xd.stringifyComment=ZV});var gT=_(Ha=>{"use strict";var VV="flow",kg="block",Ed="quoted";function BV(t,e,r="flow",{indentAtStart:n,lineWidth:s=80,minContentWidth:o=20,onFold:i,onOverflow:a}={}){if(!s||s<0)return t;s<o&&(o=0);let c=Math.max(1+o,1+s-e.length);if(t.length<=c)return t;let l=[],u={},d=s-e.length;typeof n=="number"&&(n>s-Math.max(2,o)?l.push(0):d=s-n);let f,p,m=!1,h=-1,g=-1,y=-1;r===kg&&(h=mT(t,h,e.length),h!==-1&&(d=h+c));for(let b;b=t[h+=1];){if(r===Ed&&b==="\\"){switch(g=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}y=h}if(b===`
8
- `)r===kg&&(h=mT(t,h,e.length)),d=h+e.length+c,f=void 0;else{if(b===" "&&p&&p!==" "&&p!==`
9
- `&&p!==" "){let x=t[h+1];x&&x!==" "&&x!==`
10
- `&&x!==" "&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(r===Ed){for(;p===" "||p===" ";)p=b,b=t[h+=1],m=!0;let x=h>y+1?h-2:g-1;if(u[x])return t;l.push(x),u[x]=!0,d=x+c,f=void 0}else m=!0}p=b}if(m&&a&&a(),l.length===0)return t;i&&i();let w=t.slice(0,l[0]);for(let b=0;b<l.length;++b){let x=l[b],v=l[b+1]||t.length;x===0?w=`
11
- ${e}${t.slice(0,v)}`:(r===Ed&&u[x]&&(w+=`${t[x]}\\`),w+=`
12
- ${e}${t.slice(x+1,v)}`)}return w}function mT(t,e,r){let n=e,s=e+1,o=t[s];for(;o===" "||o===" ";)if(e<s+r)o=t[++e];else{do o=t[++e];while(o&&o!==`
13
- `);n=e,s=e+1,o=t[s]}return n}Ha.FOLD_BLOCK=kg;Ha.FOLD_FLOW=VV;Ha.FOLD_QUOTED=Ed;Ha.foldFlowLines=BV});var Ja=_(yT=>{"use strict";var kr=Xe(),Hn=gT(),Pd=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Od=t=>/^(%|---|\.\.\.)/m.test(t);function KV(t,e,r){if(!e||e<0)return!1;let n=e-r,s=t.length;if(s<=n)return!1;for(let o=0,i=0;o<s;++o)if(t[o]===`
14
- `){if(o-i>n)return!0;if(i=o+1,s-i<=n)return!1}return!0}function Wa(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:n}=e,s=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(Od(t)?" ":""),i="",a=0;for(let c=0,l=r[c];l;l=r[++c])if(l===" "&&r[c+1]==="\\"&&r[c+2]==="n"&&(i+=r.slice(a,c)+"\\ ",c+=1,a=c,l="\\"),l==="\\")switch(r[c+1]){case"u":{i+=r.slice(a,c);let u=r.substr(c+2,4);switch(u){case"0000":i+="\\0";break;case"0007":i+="\\a";break;case"000b":i+="\\v";break;case"001b":i+="\\e";break;case"0085":i+="\\N";break;case"00a0":i+="\\_";break;case"2028":i+="\\L";break;case"2029":i+="\\P";break;default:u.substr(0,2)==="00"?i+="\\x"+u.substr(2):i+=r.substr(c,6)}c+=5,a=c+1}break;case"n":if(n||r[c+2]==='"'||r.length<s)c+=1;else{for(i+=r.slice(a,c)+`
15
-
16
- `;r[c+2]==="\\"&&r[c+3]==="n"&&r[c+4]!=='"';)i+=`
17
- `,c+=2;i+=o,r[c+2]===" "&&(i+="\\"),c+=1,a=c+1}break;default:c+=1}return i=a?i+r.slice(a):r,n?i:Hn.foldFlowLines(i,o,Hn.FOLD_QUOTED,Pd(e,!1))}function xg(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
18
- `)||/[ \t]\n|\n[ \t]/.test(t))return Wa(t,e);let r=e.indent||(Od(t)?" ":""),n="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
19
- ${r}`)+"'";return e.implicitKey?n:Hn.foldFlowLines(n,r,Hn.FOLD_FLOW,Pd(e,!1))}function Zo(t,e){let{singleQuote:r}=e.options,n;if(r===!1)n=Wa;else{let s=t.includes('"'),o=t.includes("'");s&&!o?n=xg:o&&!s?n=Wa:n=r?xg:Wa}return n(t,e)}var Eg;try{Eg=new RegExp(`(^|(?<!
7
+ `+Bi(r,e):(t.endsWith(" ")?"":" ")+r;Cn.indentComment=Bi;Cn.lineComment=hS;Cn.stringifyComment=pS});var qc=x(wr=>{"use strict";var mS="flow",Ui="block",On="quoted";function gS(t,e,r="flow",{indentAtStart:n,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return t;s<i&&(i=0);let l=Math.max(1+i,1+s-e.length);if(t.length<=l)return t;let c=[],u={},f=s-e.length;typeof n=="number"&&(n>s-Math.max(2,i)?c.push(0):f=s-n);let d,h,g=!1,p=-1,m=-1,y=-1;r===Ui&&(p=Fc(t,p,e.length),p!==-1&&(f=p+l));for(let _;_=t[p+=1];){if(r===On&&_==="\\"){switch(m=p,t[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}y=p}if(_===`
8
+ `)r===Ui&&(p=Fc(t,p,e.length)),f=p+e.length+l,d=void 0;else{if(_===" "&&h&&h!==" "&&h!==`
9
+ `&&h!==" "){let v=t[p+1];v&&v!==" "&&v!==`
10
+ `&&v!==" "&&(d=p)}if(p>=f)if(d)c.push(d),f=d+l,d=void 0;else if(r===On){for(;h===" "||h===" ";)h=_,_=t[p+=1],g=!0;let v=p>y+1?p-2:m-1;if(u[v])return t;c.push(v),u[v]=!0,f=v+l,d=void 0}else g=!0}h=_}if(g&&a&&a(),c.length===0)return t;o&&o();let w=t.slice(0,c[0]);for(let _=0;_<c.length;++_){let v=c[_],E=c[_+1]||t.length;v===0?w=`
11
+ ${e}${t.slice(0,E)}`:(r===On&&u[v]&&(w+=`${t[v]}\\`),w+=`
12
+ ${e}${t.slice(v+1,E)}`)}return w}function Fc(t,e,r){let n=e,s=e+1,i=t[s];for(;i===" "||i===" ";)if(e<s+r)i=t[++e];else{do i=t[++e];while(i&&i!==`
13
+ `);n=e,s=e+1,i=t[s]}return n}wr.FOLD_BLOCK=Ui;wr.FOLD_FLOW=mS;wr.FOLD_QUOTED=On;wr.foldFlowLines=gS});var vr=x(Bc=>{"use strict";var ge=V(),Je=qc(),Pn=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),$n=t=>/^(%|---|\.\.\.)/m.test(t);function yS(t,e,r){if(!e||e<0)return!1;let n=e-r,s=t.length;if(s<=n)return!1;for(let i=0,o=0;i<s;++i)if(t[i]===`
14
+ `){if(i-o>n)return!0;if(o=i+1,s-o<=n)return!1}return!0}function xr(t,e){let r=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return r;let{implicitKey:n}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||($n(t)?" ":""),o="",a=0;for(let l=0,c=r[l];c;c=r[++l])if(c===" "&&r[l+1]==="\\"&&r[l+2]==="n"&&(o+=r.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(r[l+1]){case"u":{o+=r.slice(a,l);let u=r.substr(l+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:u.substr(0,2)==="00"?o+="\\x"+u.substr(2):o+=r.substr(l,6)}l+=5,a=l+1}break;case"n":if(n||r[l+2]==='"'||r.length<s)l+=1;else{for(o+=r.slice(a,l)+`
15
+
16
+ `;r[l+2]==="\\"&&r[l+3]==="n"&&r[l+4]!=='"';)o+=`
17
+ `,l+=2;o+=i,r[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+r.slice(a):r,n?o:Je.foldFlowLines(o,i,Je.FOLD_QUOTED,Pn(e,!1))}function Ki(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
18
+ `)||/[ \t]\n|\n[ \t]/.test(t))return xr(t,e);let r=e.indent||($n(t)?" ":""),n="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
19
+ ${r}`)+"'";return e.implicitKey?n:Je.foldFlowLines(n,r,Je.FOLD_FLOW,Pn(e,!1))}function Rt(t,e){let{singleQuote:r}=e.options,n;if(r===!1)n=xr;else{let s=t.includes('"'),i=t.includes("'");s&&!i?n=Ki:i&&!s?n=xr:n=r?Ki:xr}return n(t,e)}var Wi;try{Wi=new RegExp(`(^|(?<!
20
20
  ))
21
21
  +(?!
22
- |$)`,"g")}catch{Eg=/\n+(?!\n|$)/g}function Td({comment:t,type:e,value:r},n,s,o){let{blockQuote:i,commentString:a,lineWidth:c}=n.options;if(!i||/\n[\t ]+$/.test(r))return Zo(r,n);let l=n.indent||(n.forceBlockIndent||Od(r)?" ":""),u=i==="literal"?!0:i==="folded"||e===kr.Scalar.BLOCK_FOLDED?!1:e===kr.Scalar.BLOCK_LITERAL?!0:!KV(r,c,l.length);if(!r)return u?`|
22
+ |$)`,"g")}catch{Wi=/\n+(?!\n|$)/g}function Tn({comment:t,type:e,value:r},n,s,i){let{blockQuote:o,commentString:a,lineWidth:l}=n.options;if(!o||/\n[\t ]+$/.test(r))return Rt(r,n);let c=n.indent||(n.forceBlockIndent||$n(r)?" ":""),u=o==="literal"?!0:o==="folded"||e===ge.Scalar.BLOCK_FOLDED?!1:e===ge.Scalar.BLOCK_LITERAL?!0:!yS(r,l,c.length);if(!r)return u?`|
23
23
  `:`>
24
- `;let d,f;for(f=r.length;f>0;--f){let v=r[f-1];if(v!==`
25
- `&&v!==" "&&v!==" ")break}let p=r.substring(f),m=p.indexOf(`
26
- `);m===-1?d="-":r===p||m!==p.length-1?(d="+",o&&o()):d="",p&&(r=r.slice(0,-p.length),p[p.length-1]===`
27
- `&&(p=p.slice(0,-1)),p=p.replace(Eg,`$&${l}`));let h=!1,g,y=-1;for(g=0;g<r.length;++g){let v=r[g];if(v===" ")h=!0;else if(v===`
28
- `)y=g;else break}let w=r.substring(0,y<g?y+1:g);w&&(r=r.substring(w.length),w=w.replace(/\n+/g,`$&${l}`));let x=(h?l?"2":"1":"")+d;if(t&&(x+=" "+a(t.replace(/ ?[\r\n]+/g," ")),s&&s()),!u){let v=r.replace(/\n+/g,`
29
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),S=!1,T=Pd(n,!0);i!=="folded"&&e!==kr.Scalar.BLOCK_FOLDED&&(T.onOverflow=()=>{S=!0});let P=Hn.foldFlowLines(`${w}${v}${p}`,l,Hn.FOLD_BLOCK,T);if(!S)return`>${x}
30
- ${l}${P}`}return r=r.replace(/\n+/g,`$&${l}`),`|${x}
31
- ${l}${w}${r}${p}`}function HV(t,e,r,n){let{type:s,value:o}=t,{actualString:i,implicitKey:a,indent:c,indentStep:l,inFlow:u}=e;if(a&&o.includes(`
32
- `)||u&&/[[\]{},]/.test(o))return Zo(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||u||!o.includes(`
33
- `)?Zo(o,e):Td(t,e,r,n);if(!a&&!u&&s!==kr.Scalar.PLAIN&&o.includes(`
34
- `))return Td(t,e,r,n);if(Od(o)){if(c==="")return e.forceBlockIndent=!0,Td(t,e,r,n);if(a&&c===l)return Zo(o,e)}let d=o.replace(/\n+/g,`$&
35
- ${c}`);if(i){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:m}=e.doc.schema;if(m.some(f)||p?.some(f))return Zo(o,e)}return a?d:Hn.foldFlowLines(d,c,Hn.FOLD_FLOW,Pd(e,!1))}function WV(t,e,r,n){let{implicitKey:s,inFlow:o}=e,i=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==kr.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value)&&(a=kr.Scalar.QUOTE_DOUBLE);let c=u=>{switch(u){case kr.Scalar.BLOCK_FOLDED:case kr.Scalar.BLOCK_LITERAL:return s||o?Zo(i.value,e):Td(i,e,r,n);case kr.Scalar.QUOTE_DOUBLE:return Wa(i.value,e);case kr.Scalar.QUOTE_SINGLE:return xg(i.value,e);case kr.Scalar.PLAIN:return HV(i,e,r,n);default:return null}},l=c(a);if(l===null){let{defaultKeyType:u,defaultStringType:d}=e.options,f=s&&u||d;if(l=c(f),l===null)throw new Error(`Unsupported default string type ${f}`)}return l}yT.stringifyString=WV});var Ga=_(Tg=>{"use strict";var JV=wd(),Wn=pe(),GV=Ka(),YV=Ja();function XV(t,e){let r=Object.assign({blockQuote:!0,commentString:GV.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),n;switch(r.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:t,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:n,options:r}}function QV(t,e){if(e.tag){let s=t.filter(o=>o.tag===e.tag);if(s.length>0)return s.find(o=>o.format===e.format)??s[0]}let r,n;if(Wn.isScalar(e)){n=e.value;let s=t.filter(o=>o.identify?.(n));if(s.length>1){let o=s.filter(i=>i.test);o.length>0&&(s=o)}r=s.find(o=>o.format===e.format)??s.find(o=>!o.format)}else n=e,r=t.find(s=>s.nodeClass&&n instanceof s.nodeClass);if(!r){let s=n?.constructor?.name??(n===null?"null":typeof n);throw new Error(`Tag not resolved for ${s} value`)}return r}function e4(t,e,{anchors:r,doc:n}){if(!n.directives)return"";let s=[],o=(Wn.isScalar(t)||Wn.isCollection(t))&&t.anchor;o&&JV.anchorIsValid(o)&&(r.add(o),s.push(`&${o}`));let i=t.tag??(e.default?null:e.tag);return i&&s.push(n.directives.tagString(i)),s.join(" ")}function t4(t,e,r,n){if(Wn.isPair(t))return t.toString(e,r,n);if(Wn.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let s,o=Wn.isNode(t)?t:e.doc.createNode(t,{onTagObj:c=>s=c});s??(s=QV(e.doc.schema.tags,o));let i=e4(o,s,e);i.length>0&&(e.indentAtStart=(e.indentAtStart??0)+i.length+1);let a=typeof s.stringify=="function"?s.stringify(o,e,r,n):Wn.isScalar(o)?YV.stringifyString(o,e,r,n):o.toString(e,r,n);return i?Wn.isScalar(o)||a[0]==="{"||a[0]==="["?`${i} ${a}`:`${i}
36
- ${e.indent}${a}`:a}Tg.createStringifyContext=XV;Tg.stringify=t4});var bT=_(wT=>{"use strict";var yn=pe(),_T=Xe(),vT=Ga(),Ya=Ka();function r4({key:t,value:e},r,n,s){let{allNullValues:o,doc:i,indent:a,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=r,f=yn.isNode(t)&&t.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(yn.isCollection(t)||!yn.isNode(t)&&typeof t=="object"){let T="With simple keys, collection cannot be used as a key value";throw new Error(T)}}let p=!d&&(!t||f&&e==null&&!r.inFlow||yn.isCollection(t)||(yn.isScalar(t)?t.type===_T.Scalar.BLOCK_FOLDED||t.type===_T.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!p&&(d||!o),indent:a+c});let m=!1,h=!1,g=vT.stringify(t,r,()=>m=!0,()=>h=!0);if(!p&&!r.inFlow&&g.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(r.inFlow){if(o||e==null)return m&&n&&n(),g===""?"?":p?`? ${g}`:g}else if(o&&!d||e==null&&p)return g=`? ${g}`,f&&!m?g+=Ya.lineComment(g,r.indent,l(f)):h&&s&&s(),g;m&&(f=null),p?(f&&(g+=Ya.lineComment(g,r.indent,l(f))),g=`? ${g}
37
- ${a}:`):(g=`${g}:`,f&&(g+=Ya.lineComment(g,r.indent,l(f))));let y,w,b;yn.isNode(e)?(y=!!e.spaceBefore,w=e.commentBefore,b=e.comment):(y=!1,w=null,b=null,e&&typeof e=="object"&&(e=i.createNode(e))),r.implicitKey=!1,!p&&!f&&yn.isScalar(e)&&(r.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!r.inFlow&&!p&&yn.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let x=!1,v=vT.stringify(e,r,()=>x=!0,()=>h=!0),S=" ";if(f||y||w){if(S=y?`
38
- `:"",w){let T=l(w);S+=`
39
- ${Ya.indentComment(T,r.indent)}`}v===""&&!r.inFlow?S===`
40
- `&&b&&(S=`
41
-
42
- `):S+=`
43
- ${r.indent}`}else if(!p&&yn.isCollection(e)){let T=v[0],P=v.indexOf(`
44
- `),A=P!==-1,Z=r.inFlow??e.flow??e.items.length===0;if(A||!Z){let ee=!1;if(A&&(T==="&"||T==="!")){let J=v.indexOf(" ");T==="&"&&J!==-1&&J<P&&v[J+1]==="!"&&(J=v.indexOf(" ",J+1)),(J===-1||P<J)&&(ee=!0)}ee||(S=`
45
- ${r.indent}`)}}else(v===""||v[0]===`
46
- `)&&(S="");return g+=S+v,r.inFlow?x&&n&&n():b&&!x?g+=Ya.lineComment(g,r.indent,l(b)):h&&s&&s(),g}wT.stringifyPair=r4});var Og=_(Pg=>{"use strict";var ST=je("process");function n4(t,...e){t==="debug"&&console.log(...e)}function s4(t,e){(t==="debug"||t==="warn")&&(typeof ST.emitWarning=="function"?ST.emitWarning(e):console.warn(e))}Pg.debug=n4;Pg.warn=s4});var Ad=_(Rd=>{"use strict";var Cd=pe(),$T=Xe(),Id="<<",Nd={identify:t=>t===Id||typeof t=="symbol"&&t.description===Id,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new $T.Scalar(Symbol(Id)),{addToJSMap:kT}),stringify:()=>Id},o4=(t,e)=>(Nd.identify(e)||Cd.isScalar(e)&&(!e.type||e.type===$T.Scalar.PLAIN)&&Nd.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===Nd.tag&&r.default);function kT(t,e,r){let n=xT(t,r);if(Cd.isSeq(n))for(let s of n.items)Ig(t,e,s);else if(Array.isArray(n))for(let s of n)Ig(t,e,s);else Ig(t,e,n)}function Ig(t,e,r){let n=xT(t,r);if(!Cd.isMap(n))throw new Error("Merge sources must be maps or map aliases");let s=n.toJSON(null,t,Map);for(let[o,i]of s)e instanceof Map?e.has(o)||e.set(o,i):e instanceof Set?e.add(o):Object.prototype.hasOwnProperty.call(e,o)||Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0});return e}function xT(t,e){return t&&Cd.isAlias(e)?e.resolve(t.doc,t):e}Rd.addMergeToJSMap=kT;Rd.isMergeKey=o4;Rd.merge=Nd});var Cg=_(PT=>{"use strict";var i4=Og(),ET=Ad(),a4=Ga(),TT=pe(),Ng=Bn();function c4(t,e,{key:r,value:n}){if(TT.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,n);else if(ET.isMergeKey(t,r))ET.addMergeToJSMap(t,e,n);else{let s=Ng.toJS(r,"",t);if(e instanceof Map)e.set(s,Ng.toJS(n,s,t));else if(e instanceof Set)e.add(s);else{let o=l4(r,s,t),i=Ng.toJS(n,o,t);o in e?Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):e[o]=i}}return e}function l4(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(TT.isNode(t)&&r?.doc){let n=a4.createStringifyContext(r.doc,{});n.anchors=new Set;for(let o of r.anchors.keys())n.anchors.add(o.anchor);n.inFlow=!0,n.inStringifyKey=!0;let s=t.toString(n);if(!r.mapKeyWarned){let o=JSON.stringify(s);o.length>40&&(o=o.substring(0,36)+'..."'),i4.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return s}return JSON.stringify(e)}PT.addPairToJSMap=c4});var Jn=_(Rg=>{"use strict";var OT=Ba(),u4=bT(),d4=Cg(),zd=pe();function f4(t,e,r){let n=OT.createNode(t,void 0,r),s=OT.createNode(e,void 0,r);return new jd(n,s)}var jd=class t{constructor(e,r=null){Object.defineProperty(this,zd.NODE_TYPE,{value:zd.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:n}=this;return zd.isNode(r)&&(r=r.clone(e)),zd.isNode(n)&&(n=n.clone(e)),new t(r,n)}toJSON(e,r){let n=r?.mapAsMap?new Map:{};return d4.addPairToJSMap(r,n,this)}toString(e,r,n){return e?.doc?u4.stringifyPair(this,e,r,n):JSON.stringify(this)}};Rg.Pair=jd;Rg.createPair=f4});var Ag=_(NT=>{"use strict";var Ms=pe(),IT=Ga(),Md=Ka();function p4(t,e,r){return(e.inFlow??t.flow?m4:h4)(t,e,r)}function h4({comment:t,items:e},r,{blockItemPrefix:n,flowChars:s,itemIndent:o,onChompKeep:i,onComment:a}){let{indent:c,options:{commentString:l}}=r,u=Object.assign({},r,{indent:o,type:null}),d=!1,f=[];for(let m=0;m<e.length;++m){let h=e[m],g=null;if(Ms.isNode(h))!d&&h.spaceBefore&&f.push(""),Ld(r,f,h.commentBefore,d),h.comment&&(g=h.comment);else if(Ms.isPair(h)){let w=Ms.isNode(h.key)?h.key:null;w&&(!d&&w.spaceBefore&&f.push(""),Ld(r,f,w.commentBefore,d))}d=!1;let y=IT.stringify(h,u,()=>g=null,()=>d=!0);g&&(y+=Md.lineComment(y,o,l(g))),d&&g&&(d=!1),f.push(n+y)}let p;if(f.length===0)p=s.start+s.end;else{p=f[0];for(let m=1;m<f.length;++m){let h=f[m];p+=h?`
47
- ${c}${h}`:`
48
- `}}return t?(p+=`
49
- `+Md.indentComment(l(t),c),a&&a()):d&&i&&i(),p}function m4({items:t},e,{flowChars:r,itemIndent:n}){let{indent:s,indentStep:o,flowCollectionPadding:i,options:{commentString:a}}=e;n+=o;let c=Object.assign({},e,{indent:n,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let m=0;m<t.length;++m){let h=t[m],g=null;if(Ms.isNode(h))h.spaceBefore&&d.push(""),Ld(e,d,h.commentBefore,!1),h.comment&&(g=h.comment);else if(Ms.isPair(h)){let w=Ms.isNode(h.key)?h.key:null;w&&(w.spaceBefore&&d.push(""),Ld(e,d,w.commentBefore,!1),w.comment&&(l=!0));let b=Ms.isNode(h.value)?h.value:null;b?(b.comment&&(g=b.comment),b.commentBefore&&(l=!0)):h.value==null&&w?.comment&&(g=w.comment)}g&&(l=!0);let y=IT.stringify(h,c,()=>g=null);l||(l=d.length>u||y.includes(`
50
- `)),m<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(l||(l=d.reduce((w,b)=>w+b.length+2,2)+(y.length+2)>e.options.lineWidth)),l&&(y+=",")),g&&(y+=Md.lineComment(y,n,a(g))),d.push(y),u=d.length}let{start:f,end:p}=r;if(d.length===0)return f+p;if(!l){let m=d.reduce((h,g)=>h+g.length+2,2);l=e.options.lineWidth>0&&m>e.options.lineWidth}if(l){let m=f;for(let h of d)m+=h?`
51
- ${o}${s}${h}`:`
52
- `;return`${m}
53
- ${s}${p}`}else return`${f}${i}${d.join(" ")}${i}${p}`}function Ld({indent:t,options:{commentString:e}},r,n,s){if(n&&s&&(n=n.replace(/^\n+/,"")),n){let o=Md.indentComment(e(n),t);r.push(o.trimStart())}}NT.stringifyCollection=p4});var Yn=_(jg=>{"use strict";var g4=Ag(),y4=Cg(),_4=kd(),Gn=pe(),Dd=Jn(),v4=Xe();function Xa(t,e){let r=Gn.isScalar(e)?e.value:e;for(let n of t)if(Gn.isPair(n)&&(n.key===e||n.key===r||Gn.isScalar(n.key)&&n.key.value===r))return n}var zg=class extends _4.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Gn.MAP,e),this.items=[]}static from(e,r,n){let{keepUndefined:s,replacer:o}=n,i=new this(e),a=(c,l)=>{if(typeof o=="function")l=o.call(r,c,l);else if(Array.isArray(o)&&!o.includes(c))return;(l!==void 0||s)&&i.items.push(Dd.createPair(c,l,n))};if(r instanceof Map)for(let[c,l]of r)a(c,l);else if(r&&typeof r=="object")for(let c of Object.keys(r))a(c,r[c]);return typeof e.sortMapEntries=="function"&&i.items.sort(e.sortMapEntries),i}add(e,r){let n;Gn.isPair(e)?n=e:!e||typeof e!="object"||!("key"in e)?n=new Dd.Pair(e,e?.value):n=new Dd.Pair(e.key,e.value);let s=Xa(this.items,n.key),o=this.schema?.sortMapEntries;if(s){if(!r)throw new Error(`Key ${n.key} already set`);Gn.isScalar(s.value)&&v4.isScalarValue(n.value)?s.value.value=n.value:s.value=n.value}else if(o){let i=this.items.findIndex(a=>o(n,a)<0);i===-1?this.items.push(n):this.items.splice(i,0,n)}else this.items.push(n)}delete(e){let r=Xa(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let s=Xa(this.items,e)?.value;return(!r&&Gn.isScalar(s)?s.value:s)??void 0}has(e){return!!Xa(this.items,e)}set(e,r){this.add(new Dd.Pair(e,r),!0)}toJSON(e,r,n){let s=n?new n:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(s);for(let o of this.items)y4.addPairToJSMap(r,s,o);return s}toString(e,r,n){if(!e)return JSON.stringify(this);for(let s of this.items)if(!Gn.isPair(s))throw new Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),g4.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:r})}};jg.YAMLMap=zg;jg.findPair=Xa});var Uo=_(RT=>{"use strict";var w4=pe(),CT=Yn(),b4={collection:"map",default:!0,nodeClass:CT.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return w4.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>CT.YAMLMap.from(t,e,r)};RT.map=b4});var Xn=_(AT=>{"use strict";var S4=Ba(),$4=Ag(),k4=kd(),Fd=pe(),x4=Xe(),E4=Bn(),Mg=class extends k4.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Fd.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=qd(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let n=qd(e);if(typeof n!="number")return;let s=this.items[n];return!r&&Fd.isScalar(s)?s.value:s}has(e){let r=qd(e);return typeof r=="number"&&r<this.items.length}set(e,r){let n=qd(e);if(typeof n!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[n];Fd.isScalar(s)&&x4.isScalarValue(r)?s.value=r:this.items[n]=r}toJSON(e,r){let n=[];r?.onCreate&&r.onCreate(n);let s=0;for(let o of this.items)n.push(E4.toJS(o,String(s++),r));return n}toString(e,r,n){return e?$4.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:r}):JSON.stringify(this)}static from(e,r,n){let{replacer:s}=n,o=new this(e);if(r&&Symbol.iterator in Object(r)){let i=0;for(let a of r){if(typeof s=="function"){let c=r instanceof Set?a:String(i++);a=s.call(r,c,a)}o.items.push(S4.createNode(a,void 0,n))}}return o}};function qd(t){let e=Fd.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}AT.YAMLSeq=Mg});var Vo=_(jT=>{"use strict";var T4=pe(),zT=Xn(),P4={collection:"seq",default:!0,nodeClass:zT.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return T4.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>zT.YAMLSeq.from(t,e,r)};jT.seq=P4});var Qa=_(MT=>{"use strict";var O4=Ja(),I4={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,r,n){return e=Object.assign({actualString:!0},e),O4.stringifyString(t,e,r,n)}};MT.string=I4});var Zd=_(qT=>{"use strict";var LT=Xe(),DT={identify:t=>t==null,createNode:()=>new LT.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new LT.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&DT.test.test(t)?t:e.options.nullStr};qT.nullTag=DT});var Lg=_(ZT=>{"use strict";var N4=Xe(),FT={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new N4.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&FT.test.test(t)){let n=t[0]==="t"||t[0]==="T";if(e===n)return t}return e?r.options.trueStr:r.options.falseStr}};ZT.boolTag=FT});var Bo=_(UT=>{"use strict";function C4({format:t,minFractionDigits:e,tag:r,value:n}){if(typeof n=="bigint")return String(n);let s=typeof n=="number"?n:Number(n);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let o=Object.is(n,-0)?"-0":JSON.stringify(n);if(!t&&e&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let i=o.indexOf(".");i<0&&(i=o.length,o+=".");let a=e-(o.length-i-1);for(;a-- >0;)o+="0"}return o}UT.stringifyNumber=C4});var qg=_(Ud=>{"use strict";var R4=Xe(),Dg=Bo(),A4={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Dg.stringifyNumber},z4={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Dg.stringifyNumber(t)}},j4={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new R4.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:Dg.stringifyNumber};Ud.float=j4;Ud.floatExp=z4;Ud.floatNaN=A4});var Zg=_(Bd=>{"use strict";var VT=Bo(),Vd=t=>typeof t=="bigint"||Number.isInteger(t),Fg=(t,e,r,{intAsBigInt:n})=>n?BigInt(t):parseInt(t.substring(e),r);function BT(t,e,r){let{value:n}=t;return Vd(n)&&n>=0?r+n.toString(e):VT.stringifyNumber(t)}var M4={identify:t=>Vd(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>Fg(t,2,8,r),stringify:t=>BT(t,8,"0o")},L4={identify:Vd,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>Fg(t,0,10,r),stringify:VT.stringifyNumber},D4={identify:t=>Vd(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>Fg(t,2,16,r),stringify:t=>BT(t,16,"0x")};Bd.int=L4;Bd.intHex=D4;Bd.intOct=M4});var HT=_(KT=>{"use strict";var q4=Uo(),F4=Zd(),Z4=Vo(),U4=Qa(),V4=Lg(),Ug=qg(),Vg=Zg(),B4=[q4.map,Z4.seq,U4.string,F4.nullTag,V4.boolTag,Vg.intOct,Vg.int,Vg.intHex,Ug.floatNaN,Ug.floatExp,Ug.float];KT.schema=B4});var GT=_(JT=>{"use strict";var K4=Xe(),H4=Uo(),W4=Vo();function WT(t){return typeof t=="bigint"||Number.isInteger(t)}var Kd=({value:t})=>JSON.stringify(t),J4=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:Kd},{identify:t=>t==null,createNode:()=>new K4.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Kd},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:Kd},{identify:WT,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:r})=>r?BigInt(t):parseInt(t,10),stringify:({value:t})=>WT(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:Kd}],G4={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},Y4=[H4.map,W4.seq].concat(J4,G4);JT.schema=Y4});var Kg=_(YT=>{"use strict";var ec=je("buffer"),Bg=Xe(),X4=Ja(),Q4={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof ec.Buffer=="function")return ec.Buffer.from(t,"base64");if(typeof atob=="function"){let r=atob(t.replace(/[\n\r]/g,"")),n=new Uint8Array(r.length);for(let s=0;s<r.length;++s)n[s]=r.charCodeAt(s);return n}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:r},n,s,o){if(!r)return"";let i=r,a;if(typeof ec.Buffer=="function")a=i instanceof ec.Buffer?i.toString("base64"):ec.Buffer.from(i.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<i.length;++l)c+=String.fromCharCode(i[l]);a=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Bg.Scalar.BLOCK_LITERAL),e!==Bg.Scalar.QUOTE_DOUBLE){let c=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),l=Math.ceil(a.length/c),u=new Array(l);for(let d=0,f=0;d<l;++d,f+=c)u[d]=a.substr(f,c);a=u.join(e===Bg.Scalar.BLOCK_LITERAL?`
54
- `:" ")}return X4.stringifyString({comment:t,type:e,value:a},n,s,o)}};YT.binary=Q4});var Jd=_(Wd=>{"use strict";var Hd=pe(),Hg=Jn(),e9=Xe(),t9=Xn();function XT(t,e){if(Hd.isSeq(t))for(let r=0;r<t.items.length;++r){let n=t.items[r];if(!Hd.isPair(n)){if(Hd.isMap(n)){n.items.length>1&&e("Each pair must have its own sequence indicator");let s=n.items[0]||new Hg.Pair(new e9.Scalar(null));if(n.commentBefore&&(s.key.commentBefore=s.key.commentBefore?`${n.commentBefore}
55
- ${s.key.commentBefore}`:n.commentBefore),n.comment){let o=s.value??s.key;o.comment=o.comment?`${n.comment}
56
- ${o.comment}`:n.comment}n=s}t.items[r]=Hd.isPair(n)?n:new Hg.Pair(n)}}else e("Expected a sequence for this tag");return t}function QT(t,e,r){let{replacer:n}=r,s=new t9.YAMLSeq(t);s.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let i of e){typeof n=="function"&&(i=n.call(e,String(o++),i));let a,c;if(Array.isArray(i))if(i.length===2)a=i[0],c=i[1];else throw new TypeError(`Expected [key, value] tuple: ${i}`);else if(i&&i instanceof Object){let l=Object.keys(i);if(l.length===1)a=l[0],c=i[a];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=i;s.items.push(Hg.createPair(a,c,r))}return s}var r9={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:XT,createNode:QT};Wd.createPairs=QT;Wd.pairs=r9;Wd.resolvePairs=XT});var Gg=_(Jg=>{"use strict";var eP=pe(),Wg=Bn(),tc=Yn(),n9=Xn(),tP=Jd(),Ls=class t extends n9.YAMLSeq{constructor(){super(),this.add=tc.YAMLMap.prototype.add.bind(this),this.delete=tc.YAMLMap.prototype.delete.bind(this),this.get=tc.YAMLMap.prototype.get.bind(this),this.has=tc.YAMLMap.prototype.has.bind(this),this.set=tc.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,r){if(!r)return super.toJSON(e);let n=new Map;r?.onCreate&&r.onCreate(n);for(let s of this.items){let o,i;if(eP.isPair(s)?(o=Wg.toJS(s.key,"",r),i=Wg.toJS(s.value,o,r)):o=Wg.toJS(s,"",r),n.has(o))throw new Error("Ordered maps must not include duplicate keys");n.set(o,i)}return n}static from(e,r,n){let s=tP.createPairs(e,r,n),o=new this;return o.items=s.items,o}};Ls.tag="tag:yaml.org,2002:omap";var s9={collection:"seq",identify:t=>t instanceof Map,nodeClass:Ls,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=tP.resolvePairs(t,e),n=[];for(let{key:s}of r.items)eP.isScalar(s)&&(n.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):n.push(s.value));return Object.assign(new Ls,r)},createNode:(t,e,r)=>Ls.from(t,e,r)};Jg.YAMLOMap=Ls;Jg.omap=s9});var iP=_(Yg=>{"use strict";var rP=Xe();function nP({value:t,source:e},r){return e&&(t?sP:oP).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var sP={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new rP.Scalar(!0),stringify:nP},oP={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new rP.Scalar(!1),stringify:nP};Yg.falseTag=oP;Yg.trueTag=sP});var aP=_(Gd=>{"use strict";var o9=Xe(),Xg=Bo(),i9={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Xg.stringifyNumber},a9={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Xg.stringifyNumber(t)}},c9={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new o9.Scalar(parseFloat(t.replace(/_/g,""))),r=t.indexOf(".");if(r!==-1){let n=t.substring(r+1).replace(/_/g,"");n[n.length-1]==="0"&&(e.minFractionDigits=n.length)}return e},stringify:Xg.stringifyNumber};Gd.float=c9;Gd.floatExp=a9;Gd.floatNaN=i9});var lP=_(nc=>{"use strict";var cP=Bo(),rc=t=>typeof t=="bigint"||Number.isInteger(t);function Yd(t,e,r,{intAsBigInt:n}){let s=t[0];if((s==="-"||s==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),n){switch(r){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let i=BigInt(t);return s==="-"?BigInt(-1)*i:i}let o=parseInt(t,r);return s==="-"?-1*o:o}function Qg(t,e,r){let{value:n}=t;if(rc(n)){let s=n.toString(e);return n<0?"-"+r+s.substr(1):r+s}return cP.stringifyNumber(t)}var l9={identify:rc,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>Yd(t,2,2,r),stringify:t=>Qg(t,2,"0b")},u9={identify:rc,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>Yd(t,1,8,r),stringify:t=>Qg(t,8,"0")},d9={identify:rc,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>Yd(t,0,10,r),stringify:cP.stringifyNumber},f9={identify:rc,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>Yd(t,2,16,r),stringify:t=>Qg(t,16,"0x")};nc.int=d9;nc.intBin=l9;nc.intHex=f9;nc.intOct=u9});var ty=_(ey=>{"use strict";var ef=pe(),Xd=Jn(),Qd=Yn(),Ds=class t extends Qd.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;ef.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new Xd.Pair(e.key,null):r=new Xd.Pair(e,null),Qd.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let n=Qd.findPair(this.items,e);return!r&&ef.isPair(n)?ef.isScalar(n.key)?n.key.value:n.key:n}set(e,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let n=Qd.findPair(this.items,e);n&&!r?this.items.splice(this.items.indexOf(n),1):!n&&r&&this.items.push(new Xd.Pair(e))}toJSON(e,r){return super.toJSON(e,r,Set)}toString(e,r,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),r,n);throw new Error("Set items must all have null values")}static from(e,r,n){let{replacer:s}=n,o=new this(e);if(r&&Symbol.iterator in Object(r))for(let i of r)typeof s=="function"&&(i=s.call(r,i,i)),o.items.push(Xd.createPair(i,null,n));return o}};Ds.tag="tag:yaml.org,2002:set";var p9={collection:"map",identify:t=>t instanceof Set,nodeClass:Ds,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>Ds.from(t,e,r),resolve(t,e){if(ef.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new Ds,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};ey.YAMLSet=Ds;ey.set=p9});var ny=_(tf=>{"use strict";var h9=Bo();function ry(t,e){let r=t[0],n=r==="-"||r==="+"?t.substring(1):t,s=i=>e?BigInt(i):Number(i),o=n.replace(/_/g,"").split(":").reduce((i,a)=>i*s(60)+s(a),s(0));return r==="-"?s(-1)*o:o}function uP(t){let{value:e}=t,r=i=>i;if(typeof e=="bigint")r=i=>BigInt(i);else if(isNaN(e)||!isFinite(e))return h9.stringifyNumber(t);let n="";e<0&&(n="-",e*=r(-1));let s=r(60),o=[e%s];return e<60?o.unshift(0):(e=(e-o[0])/s,o.unshift(e%s),e>=60&&(e=(e-o[0])/s,o.unshift(e))),n+o.map(i=>String(i).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var m9={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:r})=>ry(t,r),stringify:uP},g9={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>ry(t,!1),stringify:uP},dP={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(dP.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,s,o,i,a]=e.map(Number),c=e[7]?Number((e[7]+"00").substr(1,3)):0,l=Date.UTC(r,n-1,s,o||0,i||0,a||0,c),u=e[8];if(u&&u!=="Z"){let d=ry(u,!1);Math.abs(d)<30&&(d*=60),l-=6e4*d}return new Date(l)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};tf.floatTime=g9;tf.intTime=m9;tf.timestamp=dP});var hP=_(pP=>{"use strict";var y9=Uo(),_9=Zd(),v9=Vo(),w9=Qa(),b9=Kg(),fP=iP(),sy=aP(),rf=lP(),S9=Ad(),$9=Gg(),k9=Jd(),x9=ty(),oy=ny(),E9=[y9.map,v9.seq,w9.string,_9.nullTag,fP.trueTag,fP.falseTag,rf.intBin,rf.intOct,rf.int,rf.intHex,sy.floatNaN,sy.floatExp,sy.float,b9.binary,S9.merge,$9.omap,k9.pairs,x9.set,oy.intTime,oy.floatTime,oy.timestamp];pP.schema=E9});var kP=_(cy=>{"use strict";var _P=Uo(),T9=Zd(),vP=Vo(),P9=Qa(),O9=Lg(),iy=qg(),ay=Zg(),I9=HT(),N9=GT(),wP=Kg(),sc=Ad(),bP=Gg(),SP=Jd(),mP=hP(),$P=ty(),nf=ny(),gP=new Map([["core",I9.schema],["failsafe",[_P.map,vP.seq,P9.string]],["json",N9.schema],["yaml11",mP.schema],["yaml-1.1",mP.schema]]),yP={binary:wP.binary,bool:O9.boolTag,float:iy.float,floatExp:iy.floatExp,floatNaN:iy.floatNaN,floatTime:nf.floatTime,int:ay.int,intHex:ay.intHex,intOct:ay.intOct,intTime:nf.intTime,map:_P.map,merge:sc.merge,null:T9.nullTag,omap:bP.omap,pairs:SP.pairs,seq:vP.seq,set:$P.set,timestamp:nf.timestamp},C9={"tag:yaml.org,2002:binary":wP.binary,"tag:yaml.org,2002:merge":sc.merge,"tag:yaml.org,2002:omap":bP.omap,"tag:yaml.org,2002:pairs":SP.pairs,"tag:yaml.org,2002:set":$P.set,"tag:yaml.org,2002:timestamp":nf.timestamp};function R9(t,e,r){let n=gP.get(e);if(n&&!t)return r&&!n.includes(sc.merge)?n.concat(sc.merge):n.slice();let s=n;if(!s)if(Array.isArray(t))s=[];else{let o=Array.from(gP.keys()).filter(i=>i!=="yaml11").map(i=>JSON.stringify(i)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(t))for(let o of t)s=s.concat(o);else typeof t=="function"&&(s=t(s.slice()));return r&&(s=s.concat(sc.merge)),s.reduce((o,i)=>{let a=typeof i=="string"?yP[i]:i;if(!a){let c=JSON.stringify(i),l=Object.keys(yP).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return o.includes(a)||o.push(a),o},[])}cy.coreKnownTags=C9;cy.getTags=R9});var dy=_(xP=>{"use strict";var ly=pe(),A9=Uo(),z9=Vo(),j9=Qa(),sf=kP(),M9=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,uy=class t{constructor({compat:e,customTags:r,merge:n,resolveKnownTags:s,schema:o,sortMapEntries:i,toStringDefaults:a}){this.compat=Array.isArray(e)?sf.getTags(e,"compat"):e?sf.getTags(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=s?sf.coreKnownTags:{},this.tags=sf.getTags(r,this.name,n),this.toStringOptions=a??null,Object.defineProperty(this,ly.MAP,{value:A9.map}),Object.defineProperty(this,ly.SCALAR,{value:j9.string}),Object.defineProperty(this,ly.SEQ,{value:z9.seq}),this.sortMapEntries=typeof i=="function"?i:i===!0?M9:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};xP.Schema=uy});var TP=_(EP=>{"use strict";var L9=pe(),fy=Ga(),oc=Ka();function D9(t,e){let r=[],n=e.directives===!0;if(e.directives!==!1&&t.directives){let c=t.directives.toString(t);c?(r.push(c),n=!0):t.directives.docStart&&(n=!0)}n&&r.push("---");let s=fy.createStringifyContext(t,e),{commentString:o}=s.options;if(t.commentBefore){r.length!==1&&r.unshift("");let c=o(t.commentBefore);r.unshift(oc.indentComment(c,""))}let i=!1,a=null;if(t.contents){if(L9.isNode(t.contents)){if(t.contents.spaceBefore&&n&&r.push(""),t.contents.commentBefore){let u=o(t.contents.commentBefore);r.push(oc.indentComment(u,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let c=a?void 0:()=>i=!0,l=fy.stringify(t.contents,s,()=>a=null,c);a&&(l+=oc.lineComment(l,"",o(a))),(l[0]==="|"||l[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${l}`:r.push(l)}else r.push(fy.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let c=o(t.comment);c.includes(`
57
- `)?(r.push("..."),r.push(oc.indentComment(c,""))):r.push(`... ${c}`)}else r.push("...");else{let c=t.comment;c&&i&&(c=c.replace(/^\n+/,"")),c&&((!i||a)&&r[r.length-1]!==""&&r.push(""),r.push(oc.indentComment(o(c),"")))}return r.join(`
24
+ `;let f,d;for(d=r.length;d>0;--d){let E=r[d-1];if(E!==`
25
+ `&&E!==" "&&E!==" ")break}let h=r.substring(d),g=h.indexOf(`
26
+ `);g===-1?f="-":r===h||g!==h.length-1?(f="+",i&&i()):f="",h&&(r=r.slice(0,-h.length),h[h.length-1]===`
27
+ `&&(h=h.slice(0,-1)),h=h.replace(Wi,`$&${c}`));let p=!1,m,y=-1;for(m=0;m<r.length;++m){let E=r[m];if(E===" ")p=!0;else if(E===`
28
+ `)y=m;else break}let w=r.substring(0,y<m?y+1:m);w&&(r=r.substring(w.length),w=w.replace(/\n+/g,`$&${c}`));let v=(p?c?"2":"1":"")+f;if(t&&(v+=" "+a(t.replace(/ ?[\r\n]+/g," ")),s&&s()),!u){let E=r.replace(/\n+/g,`
29
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),k=!1,T=Pn(n,!0);o!=="folded"&&e!==ge.Scalar.BLOCK_FOLDED&&(T.onOverflow=()=>{k=!0});let S=Je.foldFlowLines(`${w}${E}${h}`,c,Je.FOLD_BLOCK,T);if(!k)return`>${v}
30
+ ${c}${S}`}return r=r.replace(/\n+/g,`$&${c}`),`|${v}
31
+ ${c}${w}${r}${h}`}function SS(t,e,r,n){let{type:s,value:i}=t,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:u}=e;if(a&&i.includes(`
32
+ `)||u&&/[[\]{},]/.test(i))return Rt(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||u||!i.includes(`
33
+ `)?Rt(i,e):Tn(t,e,r,n);if(!a&&!u&&s!==ge.Scalar.PLAIN&&i.includes(`
34
+ `))return Tn(t,e,r,n);if($n(i)){if(l==="")return e.forceBlockIndent=!0,Tn(t,e,r,n);if(a&&l===c)return Rt(i,e)}let f=i.replace(/\n+/g,`$&
35
+ ${l}`);if(o){let d=p=>p.default&&p.tag!=="tag:yaml.org,2002:str"&&p.test?.test(f),{compat:h,tags:g}=e.doc.schema;if(g.some(d)||h?.some(d))return Rt(i,e)}return a?f:Je.foldFlowLines(f,l,Je.FOLD_FLOW,Pn(e,!1))}function bS(t,e,r,n){let{implicitKey:s,inFlow:i}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==ge.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=ge.Scalar.QUOTE_DOUBLE);let l=u=>{switch(u){case ge.Scalar.BLOCK_FOLDED:case ge.Scalar.BLOCK_LITERAL:return s||i?Rt(o.value,e):Tn(o,e,r,n);case ge.Scalar.QUOTE_DOUBLE:return xr(o.value,e);case ge.Scalar.QUOTE_SINGLE:return Ki(o.value,e);case ge.Scalar.PLAIN:return SS(o,e,r,n);default:return null}},c=l(a);if(c===null){let{defaultKeyType:u,defaultStringType:f}=e.options,d=s&&u||f;if(c=l(d),c===null)throw new Error(`Unsupported default string type ${d}`)}return c}Bc.stringifyString=bS});var _r=x(Vi=>{"use strict";var wS=xn(),He=$(),xS=br(),vS=vr();function _S(t,e){let r=Object.assign({blockQuote:!0,commentString:xS.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),n;switch(r.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:t,flowCollectionPadding:r.flowCollectionPadding?" ":"",indent:"",indentStep:typeof r.indent=="number"?" ".repeat(r.indent):" ",inFlow:n,options:r}}function ES(t,e){if(e.tag){let s=t.filter(i=>i.tag===e.tag);if(s.length>0)return s.find(i=>i.format===e.format)??s[0]}let r,n;if(He.isScalar(e)){n=e.value;let s=t.filter(i=>i.identify?.(n));if(s.length>1){let i=s.filter(o=>o.test);i.length>0&&(s=i)}r=s.find(i=>i.format===e.format)??s.find(i=>!i.format)}else n=e,r=t.find(s=>s.nodeClass&&n instanceof s.nodeClass);if(!r){let s=n?.constructor?.name??(n===null?"null":typeof n);throw new Error(`Tag not resolved for ${s} value`)}return r}function kS(t,e,{anchors:r,doc:n}){if(!n.directives)return"";let s=[],i=(He.isScalar(t)||He.isCollection(t))&&t.anchor;i&&wS.anchorIsValid(i)&&(r.add(i),s.push(`&${i}`));let o=t.tag??(e.default?null:e.tag);return o&&s.push(n.directives.tagString(o)),s.join(" ")}function CS(t,e,r,n){if(He.isPair(t))return t.toString(e,r,n);if(He.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let s,i=He.isNode(t)?t:e.doc.createNode(t,{onTagObj:l=>s=l});s??(s=ES(e.doc.schema.tags,i));let o=kS(i,s,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof s.stringify=="function"?s.stringify(i,e,r,n):He.isScalar(i)?vS.stringifyString(i,e,r,n):i.toString(e,r,n);return o?He.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
36
+ ${e.indent}${a}`:a}Vi.createStringifyContext=_S;Vi.stringify=CS});var Vc=x(Wc=>{"use strict";var Ae=$(),Uc=V(),Kc=_r(),Er=br();function OS({key:t,value:e},r,n,s){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:u,simpleKeys:f}}=r,d=Ae.isNode(t)&&t.comment||null;if(f){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(Ae.isCollection(t)||!Ae.isNode(t)&&typeof t=="object"){let T="With simple keys, collection cannot be used as a key value";throw new Error(T)}}let h=!f&&(!t||d&&e==null&&!r.inFlow||Ae.isCollection(t)||(Ae.isScalar(t)?t.type===Uc.Scalar.BLOCK_FOLDED||t.type===Uc.Scalar.BLOCK_LITERAL:typeof t=="object"));r=Object.assign({},r,{allNullValues:!1,implicitKey:!h&&(f||!i),indent:a+l});let g=!1,p=!1,m=Kc.stringify(t,r,()=>g=!0,()=>p=!0);if(!h&&!r.inFlow&&m.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(r.inFlow){if(i||e==null)return g&&n&&n(),m===""?"?":h?`? ${m}`:m}else if(i&&!f||e==null&&h)return m=`? ${m}`,d&&!g?m+=Er.lineComment(m,r.indent,c(d)):p&&s&&s(),m;g&&(d=null),h?(d&&(m+=Er.lineComment(m,r.indent,c(d))),m=`? ${m}
37
+ ${a}:`):(m=`${m}:`,d&&(m+=Er.lineComment(m,r.indent,c(d))));let y,w,_;Ae.isNode(e)?(y=!!e.spaceBefore,w=e.commentBefore,_=e.comment):(y=!1,w=null,_=null,e&&typeof e=="object"&&(e=o.createNode(e))),r.implicitKey=!1,!h&&!d&&Ae.isScalar(e)&&(r.indentAtStart=m.length+1),p=!1,!u&&l.length>=2&&!r.inFlow&&!h&&Ae.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(r.indent=r.indent.substring(2));let v=!1,E=Kc.stringify(e,r,()=>v=!0,()=>p=!0),k=" ";if(d||y||w){if(k=y?`
38
+ `:"",w){let T=c(w);k+=`
39
+ ${Er.indentComment(T,r.indent)}`}E===""&&!r.inFlow?k===`
40
+ `&&_&&(k=`
41
+
42
+ `):k+=`
43
+ ${r.indent}`}else if(!h&&Ae.isCollection(e)){let T=E[0],S=E.indexOf(`
44
+ `),b=S!==-1,C=r.inFlow??e.flow??e.items.length===0;if(b||!C){let R=!1;if(b&&(T==="&"||T==="!")){let A=E.indexOf(" ");T==="&"&&A!==-1&&A<S&&E[A+1]==="!"&&(A=E.indexOf(" ",A+1)),(A===-1||S<A)&&(R=!0)}R||(k=`
45
+ ${r.indent}`)}}else(E===""||E[0]===`
46
+ `)&&(k="");return m+=k+E,r.inFlow?v&&n&&n():_&&!v?m+=Er.lineComment(m,r.indent,c(_)):p&&s&&s(),m}Wc.stringifyPair=OS});var Ji=x(Gi=>{"use strict";var Gc=B("process");function TS(t,...e){t==="debug"&&console.log(...e)}function PS(t,e){(t==="debug"||t==="warn")&&(typeof Gc.emitWarning=="function"?Gc.emitWarning(e):console.warn(e))}Gi.debug=TS;Gi.warn=PS});var Mn=x(Rn=>{"use strict";var In=$(),Jc=V(),Nn="<<",An={identify:t=>t===Nn||typeof t=="symbol"&&t.description===Nn,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Jc.Scalar(Symbol(Nn)),{addToJSMap:Hc}),stringify:()=>Nn},$S=(t,e)=>(An.identify(e)||In.isScalar(e)&&(!e.type||e.type===Jc.Scalar.PLAIN)&&An.identify(e.value))&&t?.doc.schema.tags.some(r=>r.tag===An.tag&&r.default);function Hc(t,e,r){let n=Yc(t,r);if(In.isSeq(n))for(let s of n.items)Hi(t,e,s);else if(Array.isArray(n))for(let s of n)Hi(t,e,s);else Hi(t,e,n)}function Hi(t,e,r){let n=Yc(t,r);if(!In.isMap(n))throw new Error("Merge sources must be maps or map aliases");let s=n.toJSON(null,t,Map);for(let[i,o]of s)e instanceof Map?e.has(i)||e.set(i,o):e instanceof Set?e.add(i):Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function Yc(t,e){return t&&In.isAlias(e)?e.resolve(t.doc,t):e}Rn.addMergeToJSMap=Hc;Rn.isMergeKey=$S;Rn.merge=An});var zi=x(Qc=>{"use strict";var NS=Ji(),zc=Mn(),AS=_r(),Xc=$(),Yi=Ve();function IS(t,e,{key:r,value:n}){if(Xc.isNode(r)&&r.addToJSMap)r.addToJSMap(t,e,n);else if(zc.isMergeKey(t,r))zc.addMergeToJSMap(t,e,n);else{let s=Yi.toJS(r,"",t);if(e instanceof Map)e.set(s,Yi.toJS(n,s,t));else if(e instanceof Set)e.add(s);else{let i=RS(r,s,t),o=Yi.toJS(n,i,t);i in e?Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[i]=o}}return e}function RS(t,e,r){if(e===null)return"";if(typeof e!="object")return String(e);if(Xc.isNode(t)&&r?.doc){let n=AS.createStringifyContext(r.doc,{});n.anchors=new Set;for(let i of r.anchors.keys())n.anchors.add(i.anchor);n.inFlow=!0,n.inStringifyKey=!0;let s=t.toString(n);if(!r.mapKeyWarned){let i=JSON.stringify(s);i.length>40&&(i=i.substring(0,36)+'..."'),NS.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return s}return JSON.stringify(e)}Qc.addPairToJSMap=IS});var Ye=x(Xi=>{"use strict";var Zc=Sr(),MS=Vc(),LS=zi(),Ln=$();function jS(t,e,r){let n=Zc.createNode(t,void 0,r),s=Zc.createNode(e,void 0,r);return new jn(n,s)}var jn=class t{constructor(e,r=null){Object.defineProperty(this,Ln.NODE_TYPE,{value:Ln.PAIR}),this.key=e,this.value=r}clone(e){let{key:r,value:n}=this;return Ln.isNode(r)&&(r=r.clone(e)),Ln.isNode(n)&&(n=n.clone(e)),new t(r,n)}toJSON(e,r){let n=r?.mapAsMap?new Map:{};return LS.addPairToJSMap(r,n,this)}toString(e,r,n){return e?.doc?MS.stringifyPair(this,e,r,n):JSON.stringify(this)}};Xi.Pair=jn;Xi.createPair=jS});var Qi=x(tu=>{"use strict";var pt=$(),eu=_r(),Dn=br();function DS(t,e,r){return(e.inFlow??t.flow?qS:FS)(t,e,r)}function FS({comment:t,items:e},r,{blockItemPrefix:n,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=r,u=Object.assign({},r,{indent:i,type:null}),f=!1,d=[];for(let g=0;g<e.length;++g){let p=e[g],m=null;if(pt.isNode(p))!f&&p.spaceBefore&&d.push(""),Fn(r,d,p.commentBefore,f),p.comment&&(m=p.comment);else if(pt.isPair(p)){let w=pt.isNode(p.key)?p.key:null;w&&(!f&&w.spaceBefore&&d.push(""),Fn(r,d,w.commentBefore,f))}f=!1;let y=eu.stringify(p,u,()=>m=null,()=>f=!0);m&&(y+=Dn.lineComment(y,i,c(m))),f&&m&&(f=!1),d.push(n+y)}let h;if(d.length===0)h=s.start+s.end;else{h=d[0];for(let g=1;g<d.length;++g){let p=d[g];h+=p?`
47
+ ${l}${p}`:`
48
+ `}}return t?(h+=`
49
+ `+Dn.indentComment(c(t),l),a&&a()):f&&o&&o(),h}function qS({items:t},e,{flowChars:r,itemIndent:n}){let{indent:s,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;n+=i;let l=Object.assign({},e,{indent:n,inFlow:!0,type:null}),c=!1,u=0,f=[];for(let g=0;g<t.length;++g){let p=t[g],m=null;if(pt.isNode(p))p.spaceBefore&&f.push(""),Fn(e,f,p.commentBefore,!1),p.comment&&(m=p.comment);else if(pt.isPair(p)){let w=pt.isNode(p.key)?p.key:null;w&&(w.spaceBefore&&f.push(""),Fn(e,f,w.commentBefore,!1),w.comment&&(c=!0));let _=pt.isNode(p.value)?p.value:null;_?(_.comment&&(m=_.comment),_.commentBefore&&(c=!0)):p.value==null&&w?.comment&&(m=w.comment)}m&&(c=!0);let y=eu.stringify(p,l,()=>m=null);c||(c=f.length>u||y.includes(`
50
+ `)),g<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(c||(c=f.reduce((w,_)=>w+_.length+2,2)+(y.length+2)>e.options.lineWidth)),c&&(y+=",")),m&&(y+=Dn.lineComment(y,n,a(m))),f.push(y),u=f.length}let{start:d,end:h}=r;if(f.length===0)return d+h;if(!c){let g=f.reduce((p,m)=>p+m.length+2,2);c=e.options.lineWidth>0&&g>e.options.lineWidth}if(c){let g=d;for(let p of f)g+=p?`
51
+ ${i}${s}${p}`:`
52
+ `;return`${g}
53
+ ${s}${h}`}else return`${d}${o}${f.join(" ")}${o}${h}`}function Fn({indent:t,options:{commentString:e}},r,n,s){if(n&&s&&(n=n.replace(/^\n+/,"")),n){let i=Dn.indentComment(e(n),t);r.push(i.trimStart())}}tu.stringifyCollection=DS});var Xe=x(eo=>{"use strict";var BS=Qi(),US=zi(),KS=kn(),ze=$(),qn=Ye(),WS=V();function kr(t,e){let r=ze.isScalar(e)?e.value:e;for(let n of t)if(ze.isPair(n)&&(n.key===e||n.key===r||ze.isScalar(n.key)&&n.key.value===r))return n}var Zi=class extends KS.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(ze.MAP,e),this.items=[]}static from(e,r,n){let{keepUndefined:s,replacer:i}=n,o=new this(e),a=(l,c)=>{if(typeof i=="function")c=i.call(r,l,c);else if(Array.isArray(i)&&!i.includes(l))return;(c!==void 0||s)&&o.items.push(qn.createPair(l,c,n))};if(r instanceof Map)for(let[l,c]of r)a(l,c);else if(r&&typeof r=="object")for(let l of Object.keys(r))a(l,r[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,r){let n;ze.isPair(e)?n=e:!e||typeof e!="object"||!("key"in e)?n=new qn.Pair(e,e?.value):n=new qn.Pair(e.key,e.value);let s=kr(this.items,n.key),i=this.schema?.sortMapEntries;if(s){if(!r)throw new Error(`Key ${n.key} already set`);ze.isScalar(s.value)&&WS.isScalarValue(n.value)?s.value.value=n.value:s.value=n.value}else if(i){let o=this.items.findIndex(a=>i(n,a)<0);o===-1?this.items.push(n):this.items.splice(o,0,n)}else this.items.push(n)}delete(e){let r=kr(this.items,e);return r?this.items.splice(this.items.indexOf(r),1).length>0:!1}get(e,r){let s=kr(this.items,e)?.value;return(!r&&ze.isScalar(s)?s.value:s)??void 0}has(e){return!!kr(this.items,e)}set(e,r){this.add(new qn.Pair(e,r),!0)}toJSON(e,r,n){let s=n?new n:r?.mapAsMap?new Map:{};r?.onCreate&&r.onCreate(s);for(let i of this.items)US.addPairToJSMap(r,s,i);return s}toString(e,r,n){if(!e)return JSON.stringify(this);for(let s of this.items)if(!ze.isPair(s))throw new Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),BS.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:r})}};eo.YAMLMap=Zi;eo.findPair=kr});var Mt=x(nu=>{"use strict";var VS=$(),ru=Xe(),GS={collection:"map",default:!0,nodeClass:ru.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return VS.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,r)=>ru.YAMLMap.from(t,e,r)};nu.map=GS});var Qe=x(su=>{"use strict";var JS=Sr(),HS=Qi(),YS=kn(),Un=$(),zS=V(),XS=Ve(),to=class extends YS.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Un.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let r=Bn(e);return typeof r!="number"?!1:this.items.splice(r,1).length>0}get(e,r){let n=Bn(e);if(typeof n!="number")return;let s=this.items[n];return!r&&Un.isScalar(s)?s.value:s}has(e){let r=Bn(e);return typeof r=="number"&&r<this.items.length}set(e,r){let n=Bn(e);if(typeof n!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[n];Un.isScalar(s)&&zS.isScalarValue(r)?s.value=r:this.items[n]=r}toJSON(e,r){let n=[];r?.onCreate&&r.onCreate(n);let s=0;for(let i of this.items)n.push(XS.toJS(i,String(s++),r));return n}toString(e,r,n){return e?HS.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:r}):JSON.stringify(this)}static from(e,r,n){let{replacer:s}=n,i=new this(e);if(r&&Symbol.iterator in Object(r)){let o=0;for(let a of r){if(typeof s=="function"){let l=r instanceof Set?a:String(o++);a=s.call(r,l,a)}i.items.push(JS.createNode(a,void 0,n))}}return i}};function Bn(t){let e=Un.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}su.YAMLSeq=to});var Lt=x(ou=>{"use strict";var QS=$(),iu=Qe(),ZS={collection:"seq",default:!0,nodeClass:iu.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return QS.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,r)=>iu.YAMLSeq.from(t,e,r)};ou.seq=ZS});var Cr=x(au=>{"use strict";var eb=vr(),tb={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,r,n){return e=Object.assign({actualString:!0},e),eb.stringifyString(t,e,r,n)}};au.string=tb});var Kn=x(uu=>{"use strict";var lu=V(),cu={identify:t=>t==null,createNode:()=>new lu.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new lu.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&cu.test.test(t)?t:e.options.nullStr};uu.nullTag=cu});var ro=x(fu=>{"use strict";var rb=V(),du={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new rb.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},r){if(t&&du.test.test(t)){let n=t[0]==="t"||t[0]==="T";if(e===n)return t}return e?r.options.trueStr:r.options.falseStr}};fu.boolTag=du});var jt=x(pu=>{"use strict";function nb({format:t,minFractionDigits:e,tag:r,value:n}){if(typeof n=="bigint")return String(n);let s=typeof n=="number"?n:Number(n);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let i=Object.is(n,-0)?"-0":JSON.stringify(n);if(!t&&e&&(!r||r==="tag:yaml.org,2002:float")&&/^-?\d/.test(i)&&!i.includes("e")){let o=i.indexOf(".");o<0&&(o=i.length,i+=".");let a=e-(i.length-o-1);for(;a-- >0;)i+="0"}return i}pu.stringifyNumber=nb});var so=x(Wn=>{"use strict";var sb=V(),no=jt(),ib={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:no.stringifyNumber},ob={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():no.stringifyNumber(t)}},ab={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new sb.Scalar(parseFloat(t)),r=t.indexOf(".");return r!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-r-1),e},stringify:no.stringifyNumber};Wn.float=ab;Wn.floatExp=ob;Wn.floatNaN=ib});var oo=x(Gn=>{"use strict";var hu=jt(),Vn=t=>typeof t=="bigint"||Number.isInteger(t),io=(t,e,r,{intAsBigInt:n})=>n?BigInt(t):parseInt(t.substring(e),r);function mu(t,e,r){let{value:n}=t;return Vn(n)&&n>=0?r+n.toString(e):hu.stringifyNumber(t)}var lb={identify:t=>Vn(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,r)=>io(t,2,8,r),stringify:t=>mu(t,8,"0o")},cb={identify:Vn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,r)=>io(t,0,10,r),stringify:hu.stringifyNumber},ub={identify:t=>Vn(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,r)=>io(t,2,16,r),stringify:t=>mu(t,16,"0x")};Gn.int=cb;Gn.intHex=ub;Gn.intOct=lb});var yu=x(gu=>{"use strict";var db=Mt(),fb=Kn(),pb=Lt(),hb=Cr(),mb=ro(),ao=so(),lo=oo(),gb=[db.map,pb.seq,hb.string,fb.nullTag,mb.boolTag,lo.intOct,lo.int,lo.intHex,ao.floatNaN,ao.floatExp,ao.float];gu.schema=gb});var wu=x(bu=>{"use strict";var yb=V(),Sb=Mt(),bb=Lt();function Su(t){return typeof t=="bigint"||Number.isInteger(t)}var Jn=({value:t})=>JSON.stringify(t),wb=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:Jn},{identify:t=>t==null,createNode:()=>new yb.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Jn},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:Jn},{identify:Su,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:r})=>r?BigInt(t):parseInt(t,10),stringify:({value:t})=>Su(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:Jn}],xb={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},vb=[Sb.map,bb.seq].concat(wb,xb);bu.schema=vb});var uo=x(xu=>{"use strict";var Or=B("buffer"),co=V(),_b=vr(),Eb={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof Or.Buffer=="function")return Or.Buffer.from(t,"base64");if(typeof atob=="function"){let r=atob(t.replace(/[\n\r]/g,"")),n=new Uint8Array(r.length);for(let s=0;s<r.length;++s)n[s]=r.charCodeAt(s);return n}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:r},n,s,i){if(!r)return"";let o=r,a;if(typeof Or.Buffer=="function")a=o instanceof Or.Buffer?o.toString("base64"):Or.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=co.Scalar.BLOCK_LITERAL),e!==co.Scalar.QUOTE_DOUBLE){let l=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),c=Math.ceil(a.length/l),u=new Array(c);for(let f=0,d=0;f<c;++f,d+=l)u[f]=a.substr(d,l);a=u.join(e===co.Scalar.BLOCK_LITERAL?`
54
+ `:" ")}return _b.stringifyString({comment:t,type:e,value:a},n,s,i)}};xu.binary=Eb});var zn=x(Yn=>{"use strict";var Hn=$(),fo=Ye(),kb=V(),Cb=Qe();function vu(t,e){if(Hn.isSeq(t))for(let r=0;r<t.items.length;++r){let n=t.items[r];if(!Hn.isPair(n)){if(Hn.isMap(n)){n.items.length>1&&e("Each pair must have its own sequence indicator");let s=n.items[0]||new fo.Pair(new kb.Scalar(null));if(n.commentBefore&&(s.key.commentBefore=s.key.commentBefore?`${n.commentBefore}
55
+ ${s.key.commentBefore}`:n.commentBefore),n.comment){let i=s.value??s.key;i.comment=i.comment?`${n.comment}
56
+ ${i.comment}`:n.comment}n=s}t.items[r]=Hn.isPair(n)?n:new fo.Pair(n)}}else e("Expected a sequence for this tag");return t}function _u(t,e,r){let{replacer:n}=r,s=new Cb.YAMLSeq(t);s.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof n=="function"&&(o=n.call(e,String(i++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;s.items.push(fo.createPair(a,l,r))}return s}var Ob={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:vu,createNode:_u};Yn.createPairs=_u;Yn.pairs=Ob;Yn.resolvePairs=vu});var mo=x(ho=>{"use strict";var Eu=$(),po=Ve(),Tr=Xe(),Tb=Qe(),ku=zn(),ht=class t extends Tb.YAMLSeq{constructor(){super(),this.add=Tr.YAMLMap.prototype.add.bind(this),this.delete=Tr.YAMLMap.prototype.delete.bind(this),this.get=Tr.YAMLMap.prototype.get.bind(this),this.has=Tr.YAMLMap.prototype.has.bind(this),this.set=Tr.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,r){if(!r)return super.toJSON(e);let n=new Map;r?.onCreate&&r.onCreate(n);for(let s of this.items){let i,o;if(Eu.isPair(s)?(i=po.toJS(s.key,"",r),o=po.toJS(s.value,i,r)):i=po.toJS(s,"",r),n.has(i))throw new Error("Ordered maps must not include duplicate keys");n.set(i,o)}return n}static from(e,r,n){let s=ku.createPairs(e,r,n),i=new this;return i.items=s.items,i}};ht.tag="tag:yaml.org,2002:omap";var Pb={collection:"seq",identify:t=>t instanceof Map,nodeClass:ht,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let r=ku.resolvePairs(t,e),n=[];for(let{key:s}of r.items)Eu.isScalar(s)&&(n.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):n.push(s.value));return Object.assign(new ht,r)},createNode:(t,e,r)=>ht.from(t,e,r)};ho.YAMLOMap=ht;ho.omap=Pb});var $u=x(go=>{"use strict";var Cu=V();function Ou({value:t,source:e},r){return e&&(t?Tu:Pu).test.test(e)?e:t?r.options.trueStr:r.options.falseStr}var Tu={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Cu.Scalar(!0),stringify:Ou},Pu={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Cu.Scalar(!1),stringify:Ou};go.falseTag=Pu;go.trueTag=Tu});var Nu=x(Xn=>{"use strict";var $b=V(),yo=jt(),Nb={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:yo.stringifyNumber},Ab={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():yo.stringifyNumber(t)}},Ib={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new $b.Scalar(parseFloat(t.replace(/_/g,""))),r=t.indexOf(".");if(r!==-1){let n=t.substring(r+1).replace(/_/g,"");n[n.length-1]==="0"&&(e.minFractionDigits=n.length)}return e},stringify:yo.stringifyNumber};Xn.float=Ib;Xn.floatExp=Ab;Xn.floatNaN=Nb});var Iu=x($r=>{"use strict";var Au=jt(),Pr=t=>typeof t=="bigint"||Number.isInteger(t);function Qn(t,e,r,{intAsBigInt:n}){let s=t[0];if((s==="-"||s==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),n){switch(r){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return s==="-"?BigInt(-1)*o:o}let i=parseInt(t,r);return s==="-"?-1*i:i}function So(t,e,r){let{value:n}=t;if(Pr(n)){let s=n.toString(e);return n<0?"-"+r+s.substr(1):r+s}return Au.stringifyNumber(t)}var Rb={identify:Pr,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,r)=>Qn(t,2,2,r),stringify:t=>So(t,2,"0b")},Mb={identify:Pr,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,r)=>Qn(t,1,8,r),stringify:t=>So(t,8,"0")},Lb={identify:Pr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,r)=>Qn(t,0,10,r),stringify:Au.stringifyNumber},jb={identify:Pr,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,r)=>Qn(t,2,16,r),stringify:t=>So(t,16,"0x")};$r.int=Lb;$r.intBin=Rb;$r.intHex=jb;$r.intOct=Mb});var wo=x(bo=>{"use strict";var ts=$(),Zn=Ye(),es=Xe(),mt=class t extends es.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let r;ts.isPair(e)?r=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?r=new Zn.Pair(e.key,null):r=new Zn.Pair(e,null),es.findPair(this.items,r.key)||this.items.push(r)}get(e,r){let n=es.findPair(this.items,e);return!r&&ts.isPair(n)?ts.isScalar(n.key)?n.key.value:n.key:n}set(e,r){if(typeof r!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof r}`);let n=es.findPair(this.items,e);n&&!r?this.items.splice(this.items.indexOf(n),1):!n&&r&&this.items.push(new Zn.Pair(e))}toJSON(e,r){return super.toJSON(e,r,Set)}toString(e,r,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),r,n);throw new Error("Set items must all have null values")}static from(e,r,n){let{replacer:s}=n,i=new this(e);if(r&&Symbol.iterator in Object(r))for(let o of r)typeof s=="function"&&(o=s.call(r,o,o)),i.items.push(Zn.createPair(o,null,n));return i}};mt.tag="tag:yaml.org,2002:set";var Db={collection:"map",identify:t=>t instanceof Set,nodeClass:mt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,r)=>mt.from(t,e,r),resolve(t,e){if(ts.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new mt,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};bo.YAMLSet=mt;bo.set=Db});var vo=x(rs=>{"use strict";var Fb=jt();function xo(t,e){let r=t[0],n=r==="-"||r==="+"?t.substring(1):t,s=o=>e?BigInt(o):Number(o),i=n.replace(/_/g,"").split(":").reduce((o,a)=>o*s(60)+s(a),s(0));return r==="-"?s(-1)*i:i}function Ru(t){let{value:e}=t,r=o=>o;if(typeof e=="bigint")r=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return Fb.stringifyNumber(t);let n="";e<0&&(n="-",e*=r(-1));let s=r(60),i=[e%s];return e<60?i.unshift(0):(e=(e-i[0])/s,i.unshift(e%s),e>=60&&(e=(e-i[0])/s,i.unshift(e))),n+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var qb={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:r})=>xo(t,r),stringify:Ru},Bb={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>xo(t,!1),stringify:Ru},Mu={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(Mu.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,s,i,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(r,n-1,s,i||0,o||0,a||0,l),u=e[8];if(u&&u!=="Z"){let f=xo(u,!1);Math.abs(f)<30&&(f*=60),c-=6e4*f}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};rs.floatTime=Bb;rs.intTime=qb;rs.timestamp=Mu});var Du=x(ju=>{"use strict";var Ub=Mt(),Kb=Kn(),Wb=Lt(),Vb=Cr(),Gb=uo(),Lu=$u(),_o=Nu(),ns=Iu(),Jb=Mn(),Hb=mo(),Yb=zn(),zb=wo(),Eo=vo(),Xb=[Ub.map,Wb.seq,Vb.string,Kb.nullTag,Lu.trueTag,Lu.falseTag,ns.intBin,ns.intOct,ns.int,ns.intHex,_o.floatNaN,_o.floatExp,_o.float,Gb.binary,Jb.merge,Hb.omap,Yb.pairs,zb.set,Eo.intTime,Eo.floatTime,Eo.timestamp];ju.schema=Xb});var Hu=x(Oo=>{"use strict";var Uu=Mt(),Qb=Kn(),Ku=Lt(),Zb=Cr(),ew=ro(),ko=so(),Co=oo(),tw=yu(),rw=wu(),Wu=uo(),Nr=Mn(),Vu=mo(),Gu=zn(),Fu=Du(),Ju=wo(),ss=vo(),qu=new Map([["core",tw.schema],["failsafe",[Uu.map,Ku.seq,Zb.string]],["json",rw.schema],["yaml11",Fu.schema],["yaml-1.1",Fu.schema]]),Bu={binary:Wu.binary,bool:ew.boolTag,float:ko.float,floatExp:ko.floatExp,floatNaN:ko.floatNaN,floatTime:ss.floatTime,int:Co.int,intHex:Co.intHex,intOct:Co.intOct,intTime:ss.intTime,map:Uu.map,merge:Nr.merge,null:Qb.nullTag,omap:Vu.omap,pairs:Gu.pairs,seq:Ku.seq,set:Ju.set,timestamp:ss.timestamp},nw={"tag:yaml.org,2002:binary":Wu.binary,"tag:yaml.org,2002:merge":Nr.merge,"tag:yaml.org,2002:omap":Vu.omap,"tag:yaml.org,2002:pairs":Gu.pairs,"tag:yaml.org,2002:set":Ju.set,"tag:yaml.org,2002:timestamp":ss.timestamp};function sw(t,e,r){let n=qu.get(e);if(n&&!t)return r&&!n.includes(Nr.merge)?n.concat(Nr.merge):n.slice();let s=n;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(qu.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${i} or define customTags array`)}if(Array.isArray(t))for(let i of t)s=s.concat(i);else typeof t=="function"&&(s=t(s.slice()));return r&&(s=s.concat(Nr.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?Bu[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Bu).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return i.includes(a)||i.push(a),i},[])}Oo.coreKnownTags=nw;Oo.getTags=sw});var $o=x(Yu=>{"use strict";var To=$(),iw=Mt(),ow=Lt(),aw=Cr(),is=Hu(),lw=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Po=class t{constructor({compat:e,customTags:r,merge:n,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?is.getTags(e,"compat"):e?is.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?is.coreKnownTags:{},this.tags=is.getTags(r,this.name,n),this.toStringOptions=a??null,Object.defineProperty(this,To.MAP,{value:iw.map}),Object.defineProperty(this,To.SCALAR,{value:aw.string}),Object.defineProperty(this,To.SEQ,{value:ow.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?lw:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};Yu.Schema=Po});var Xu=x(zu=>{"use strict";var cw=$(),No=_r(),Ar=br();function uw(t,e){let r=[],n=e.directives===!0;if(e.directives!==!1&&t.directives){let l=t.directives.toString(t);l?(r.push(l),n=!0):t.directives.docStart&&(n=!0)}n&&r.push("---");let s=No.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){r.length!==1&&r.unshift("");let l=i(t.commentBefore);r.unshift(Ar.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(cw.isNode(t.contents)){if(t.contents.spaceBefore&&n&&r.push(""),t.contents.commentBefore){let u=i(t.contents.commentBefore);r.push(Ar.indentComment(u,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=No.stringify(t.contents,s,()=>a=null,l);a&&(c+=Ar.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&r[r.length-1]==="---"?r[r.length-1]=`--- ${c}`:r.push(c)}else r.push(No.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let l=i(t.comment);l.includes(`
57
+ `)?(r.push("..."),r.push(Ar.indentComment(l,""))):r.push(`... ${l}`)}else r.push("...");else{let l=t.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&r[r.length-1]!==""&&r.push(""),r.push(Ar.indentComment(i(l),"")))}return r.join(`
58
58
  `)+`
59
- `}EP.stringifyDocument=D9});var ic=_(PP=>{"use strict";var q9=Va(),Ko=kd(),ir=pe(),F9=Jn(),Z9=Bn(),U9=dy(),V9=TP(),py=wd(),B9=yg(),K9=Ba(),hy=gg(),my=class t{constructor(e,r,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ir.NODE_TYPE,{value:ir.DOC});let s=null;typeof r=="function"||Array.isArray(r)?s=r:n===void 0&&r&&(n=r,r=void 0);let o=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=o;let{version:i}=o;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(i=this.directives.yaml.version)):this.directives=new hy.Directives({version:i}),this.setSchema(i,n),this.contents=e===void 0?null:this.createNode(e,s,n)}clone(){let e=Object.create(t.prototype,{[ir.NODE_TYPE]:{value:ir.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=ir.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Ho(this.contents)&&this.contents.add(e)}addIn(e,r){Ho(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let n=py.anchorNames(this);e.anchor=!r||n.has(r)?py.findNewAnchor(r||"a",n):r}return new q9.Alias(e.anchor)}createNode(e,r,n){let s;if(typeof r=="function")e=r.call({"":e},"",e),s=r;else if(Array.isArray(r)){let g=w=>typeof w=="number"||w instanceof String||w instanceof Number,y=r.filter(g).map(String);y.length>0&&(r=r.concat(y)),s=r}else n===void 0&&r&&(n=r,r=void 0);let{aliasDuplicateObjects:o,anchorPrefix:i,flow:a,keepUndefined:c,onTagObj:l,tag:u}=n??{},{onAnchor:d,setAnchors:f,sourceObjects:p}=py.createNodeAnchors(this,i||"a"),m={aliasDuplicateObjects:o??!0,keepUndefined:c??!1,onAnchor:d,onTagObj:l,replacer:s,schema:this.schema,sourceObjects:p},h=K9.createNode(e,u,m);return a&&ir.isCollection(h)&&(h.flow=!0),f(),h}createPair(e,r,n={}){let s=this.createNode(e,null,n),o=this.createNode(r,null,n);return new F9.Pair(s,o)}delete(e){return Ho(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Ko.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Ho(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return ir.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return Ko.isEmptyPath(e)?!r&&ir.isScalar(this.contents)?this.contents.value:this.contents:ir.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return ir.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Ko.isEmptyPath(e)?this.contents!==void 0:ir.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=Ko.collectionFromPath(this.schema,[e],r):Ho(this.contents)&&this.contents.set(e,r)}setIn(e,r){Ko.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=Ko.collectionFromPath(this.schema,Array.from(e),r):Ho(this.contents)&&this.contents.setIn(e,r)}setSchema(e,r={}){typeof e=="number"&&(e=String(e));let n;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new hy.Directives({version:"1.1"}),n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new hy.Directives({version:e}),n={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,n=null;break;default:{let s=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${s}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(n)this.schema=new U9.Schema(Object.assign(n,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:r,mapAsMap:n,maxAliasCount:s,onAnchor:o,reviver:i}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},c=Z9.toJS(this.contents,r??"",a);if(typeof o=="function")for(let{count:l,res:u}of a.anchors.values())o(u,l);return typeof i=="function"?B9.applyReviver(i,{"":c},"",c):c}toJSON(e,r){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:r})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let r=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return V9.stringifyDocument(this,e)}};function Ho(t){if(ir.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}PP.Document=my});var lc=_(cc=>{"use strict";var ac=class extends Error{constructor(e,r,n,s){super(),this.name=e,this.code=n,this.message=s,this.pos=r}},gy=class extends ac{constructor(e,r,n){super("YAMLParseError",e,r,n)}},yy=class extends ac{constructor(e,r,n){super("YAMLWarning",e,r,n)}},H9=(t,e)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(a=>e.linePos(a));let{line:n,col:s}=r.linePos[0];r.message+=` at line ${n}, column ${s}`;let o=s-1,i=t.substring(e.lineStarts[n-1],e.lineStarts[n]).replace(/[\n\r]+$/,"");if(o>=60&&i.length>80){let a=Math.min(o-39,i.length-79);i="\u2026"+i.substring(a),o-=a-1}if(i.length>80&&(i=i.substring(0,79)+"\u2026"),n>1&&/^ *$/.test(i.substring(0,o))){let a=t.substring(e.lineStarts[n-2],e.lineStarts[n-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
60
- `),i=a+i}if(/[^ ]/.test(i)){let a=1,c=r.linePos[1];c?.line===n&&c.col>s&&(a=Math.max(1,Math.min(c.col-s,80-o)));let l=" ".repeat(o)+"^".repeat(a);r.message+=`:
61
-
62
- ${i}
63
- ${l}
64
- `}};cc.YAMLError=ac;cc.YAMLParseError=gy;cc.YAMLWarning=yy;cc.prettifyError=H9});var uc=_(OP=>{"use strict";function W9(t,{flow:e,indicator:r,next:n,offset:s,onError:o,parentIndent:i,startOnNewline:a}){let c=!1,l=a,u=a,d="",f="",p=!1,m=!1,h=null,g=null,y=null,w=null,b=null,x=null,v=null;for(let P of t)switch(m&&(P.type!=="space"&&P.type!=="newline"&&P.type!=="comma"&&o(P.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),h&&(l&&P.type!=="comment"&&P.type!=="newline"&&o(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),P.type){case"space":!e&&(r!=="doc-start"||n?.type!=="flow-collection")&&P.source.includes(" ")&&(h=P),u=!0;break;case"comment":{u||o(P,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let A=P.source.substring(1)||" ";d?d+=f+A:d=A,f="",l=!1;break}case"newline":l?d?d+=P.source:(!x||r!=="seq-item-ind")&&(c=!0):f+=P.source,l=!0,p=!0,(g||y)&&(w=P),u=!0;break;case"anchor":g&&o(P,"MULTIPLE_ANCHORS","A node can have at most one anchor"),P.source.endsWith(":")&&o(P.offset+P.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=P,v??(v=P.offset),l=!1,u=!1,m=!0;break;case"tag":{y&&o(P,"MULTIPLE_TAGS","A node can have at most one tag"),y=P,v??(v=P.offset),l=!1,u=!1,m=!0;break}case r:(g||y)&&o(P,"BAD_PROP_ORDER",`Anchors and tags must be after the ${P.source} indicator`),x&&o(P,"UNEXPECTED_TOKEN",`Unexpected ${P.source} in ${e??"collection"}`),x=P,l=r==="seq-item-ind"||r==="explicit-key-ind",u=!1;break;case"comma":if(e){b&&o(P,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),b=P,l=!1,u=!1;break}default:o(P,"UNEXPECTED_TOKEN",`Unexpected ${P.type} token`),l=!1,u=!1}let S=t[t.length-1],T=S?S.offset+S.source.length:s;return m&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!=="")&&o(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(l&&h.indent<=i||n?.type==="block-map"||n?.type==="block-seq")&&o(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:x,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:y,newlineAfterProp:w,end:T,start:v??T}}OP.resolveProps=W9});var of=_(IP=>{"use strict";function _y(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
65
- `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let r of e.start)if(r.type==="newline")return!0;if(e.sep){for(let r of e.sep)if(r.type==="newline")return!0}if(_y(e.key)||_y(e.value))return!0}return!1;default:return!0}}IP.containsNewline=_y});var vy=_(NP=>{"use strict";var J9=of();function G9(t,e,r){if(e?.type==="flow-collection"){let n=e.end[0];n.indent===t&&(n.source==="]"||n.source==="}")&&J9.containsNewline(e)&&r(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}NP.flowIndentCheck=G9});var wy=_(RP=>{"use strict";var CP=pe();function Y9(t,e,r){let{uniqueKeys:n}=t.options;if(n===!1)return!1;let s=typeof n=="function"?n:(o,i)=>o===i||CP.isScalar(o)&&CP.isScalar(i)&&o.value===i.value;return e.some(o=>s(o.key,r))}RP.mapIncludes=Y9});var DP=_(LP=>{"use strict";var AP=Jn(),X9=Yn(),zP=uc(),Q9=of(),jP=vy(),eB=wy(),MP="All mapping items must start at the same column";function tB({composeNode:t,composeEmptyNode:e},r,n,s,o){let i=o?.nodeClass??X9.YAMLMap,a=new i(r.schema);r.atRoot&&(r.atRoot=!1);let c=n.offset,l=null;for(let u of n.items){let{start:d,key:f,sep:p,value:m}=u,h=zP.resolveProps(d,{indicator:"explicit-key-ind",next:f??p?.[0],offset:c,onError:s,parentIndent:n.indent,startOnNewline:!0}),g=!h.found;if(g){if(f&&(f.type==="block-seq"?s(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==n.indent&&s(c,"BAD_INDENT",MP)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(a.comment?a.comment+=`
66
- `+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||Q9.containsNewline(f))&&s(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==n.indent&&s(c,"BAD_INDENT",MP);r.atKey=!0;let y=h.end,w=f?t(r,f,h,s):e(r,y,d,null,h,s);r.schema.compat&&jP.flowIndentCheck(n.indent,f,s),r.atKey=!1,eB.mapIncludes(r,a.items,w)&&s(y,"DUPLICATE_KEY","Map keys must be unique");let b=zP.resolveProps(p??[],{indicator:"map-value-ind",next:m,offset:w.range[2],onError:s,parentIndent:n.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=b.end,b.found){g&&(m?.type==="block-map"&&!b.hasNewline&&s(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&h.start<b.found.offset-1024&&s(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let x=m?t(r,m,b,s):e(r,c,p,null,b,s);r.schema.compat&&jP.flowIndentCheck(n.indent,m,s),c=x.range[2];let v=new AP.Pair(w,x);r.options.keepSourceTokens&&(v.srcToken=u),a.items.push(v)}else{g&&s(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(w.comment?w.comment+=`
67
- `+b.comment:w.comment=b.comment);let x=new AP.Pair(w);r.options.keepSourceTokens&&(x.srcToken=u),a.items.push(x)}}return l&&l<c&&s(l,"IMPOSSIBLE","Map comment with trailing content"),a.range=[n.offset,c,l??c],a}LP.resolveBlockMap=tB});var FP=_(qP=>{"use strict";var rB=Xn(),nB=uc(),sB=vy();function oB({composeNode:t,composeEmptyNode:e},r,n,s,o){let i=o?.nodeClass??rB.YAMLSeq,a=new i(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let c=n.offset,l=null;for(let{start:u,value:d}of n.items){let f=nB.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:c,onError:s,parentIndent:n.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||d)d?.type==="block-seq"?s(f.end,"BAD_INDENT","All sequence items must start at the same column"):s(c,"MISSING_CHAR","Sequence item without - indicator");else{l=f.end,f.comment&&(a.comment=f.comment);continue}let p=d?t(r,d,f,s):e(r,f.end,u,null,f,s);r.schema.compat&&sB.flowIndentCheck(n.indent,d,s),c=p.range[2],a.items.push(p)}return a.range=[n.offset,c,l??c],a}qP.resolveBlockSeq=oB});var Wo=_(ZP=>{"use strict";function iB(t,e,r,n){let s="";if(t){let o=!1,i="";for(let a of t){let{source:c,type:l}=a;switch(l){case"space":o=!0;break;case"comment":{r&&!o&&n(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";s?s+=i+u:s=u,i="";break}case"newline":s&&(i+=c),o=!0;break;default:n(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}e+=c.length}}return{comment:s,offset:e}}ZP.resolveEnd=iB});var KP=_(BP=>{"use strict";var aB=pe(),cB=Jn(),UP=Yn(),lB=Xn(),uB=Wo(),VP=uc(),dB=of(),fB=wy(),by="Block collections are not allowed within flow collections",Sy=t=>t&&(t.type==="block-map"||t.type==="block-seq");function pB({composeNode:t,composeEmptyNode:e},r,n,s,o){let i=n.start.source==="{",a=i?"flow map":"flow sequence",c=o?.nodeClass??(i?UP.YAMLMap:lB.YAMLSeq),l=new c(r.schema);l.flow=!0;let u=r.atRoot;u&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let d=n.offset+n.start.source.length;for(let g=0;g<n.items.length;++g){let y=n.items[g],{start:w,key:b,sep:x,value:v}=y,S=VP.resolveProps(w,{flow:a,indicator:"explicit-key-ind",next:b??x?.[0],offset:d,onError:s,parentIndent:n.indent,startOnNewline:!1});if(!S.found){if(!S.anchor&&!S.tag&&!x&&!v){g===0&&S.comma?s(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<n.items.length-1&&s(S.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),S.comment&&(l.comment?l.comment+=`
68
- `+S.comment:l.comment=S.comment),d=S.end;continue}!i&&r.options.strict&&dB.containsNewline(b)&&s(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)S.comma&&s(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(S.comma||s(S.start,"MISSING_CHAR",`Missing , between ${a} items`),S.comment){let T="";e:for(let P of w)switch(P.type){case"comma":case"space":break;case"comment":T=P.source.substring(1);break e;default:break e}if(T){let P=l.items[l.items.length-1];aB.isPair(P)&&(P=P.value??P.key),P.comment?P.comment+=`
69
- `+T:P.comment=T,S.comment=S.comment.substring(T.length+1)}}if(!i&&!x&&!S.found){let T=v?t(r,v,S,s):e(r,S.end,x,null,S,s);l.items.push(T),d=T.range[2],Sy(v)&&s(T.range,"BLOCK_IN_FLOW",by)}else{r.atKey=!0;let T=S.end,P=b?t(r,b,S,s):e(r,T,w,null,S,s);Sy(b)&&s(P.range,"BLOCK_IN_FLOW",by),r.atKey=!1;let A=VP.resolveProps(x??[],{flow:a,indicator:"map-value-ind",next:v,offset:P.range[2],onError:s,parentIndent:n.indent,startOnNewline:!1});if(A.found){if(!i&&!S.found&&r.options.strict){if(x)for(let J of x){if(J===A.found)break;if(J.type==="newline"){s(J,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}S.start<A.found.offset-1024&&s(A.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else v&&("source"in v&&v.source?.[0]===":"?s(v,"MISSING_CHAR",`Missing space after : in ${a}`):s(A.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let Z=v?t(r,v,A,s):A.found?e(r,A.end,x,null,A,s):null;Z?Sy(v)&&s(Z.range,"BLOCK_IN_FLOW",by):A.comment&&(P.comment?P.comment+=`
70
- `+A.comment:P.comment=A.comment);let ee=new cB.Pair(P,Z);if(r.options.keepSourceTokens&&(ee.srcToken=y),i){let J=l;fB.mapIncludes(r,J.items,P)&&s(T,"DUPLICATE_KEY","Map keys must be unique"),J.items.push(ee)}else{let J=new UP.YAMLMap(r.schema);J.flow=!0,J.items.push(ee);let fe=(Z??P).range;J.range=[P.range[0],fe[1],fe[2]],l.items.push(J)}d=Z?Z.range[2]:A.end}}let f=i?"}":"]",[p,...m]=n.end,h=d;if(p?.source===f)h=p.offset+p.source.length;else{let g=a[0].toUpperCase()+a.substring(1),y=u?`${g} must end with a ${f}`:`${g} in block collection must be sufficiently indented and end with a ${f}`;s(d,u?"MISSING_CHAR":"BAD_INDENT",y),p&&p.source.length!==1&&m.unshift(p)}if(m.length>0){let g=uB.resolveEnd(m,h,r.options.strict,s);g.comment&&(l.comment?l.comment+=`
71
- `+g.comment:l.comment=g.comment),l.range=[n.offset,h,g.offset]}else l.range=[n.offset,h,h];return l}BP.resolveFlowCollection=pB});var WP=_(HP=>{"use strict";var hB=pe(),mB=Xe(),gB=Yn(),yB=Xn(),_B=DP(),vB=FP(),wB=KP();function $y(t,e,r,n,s,o){let i=r.type==="block-map"?_B.resolveBlockMap(t,e,r,n,o):r.type==="block-seq"?vB.resolveBlockSeq(t,e,r,n,o):wB.resolveFlowCollection(t,e,r,n,o),a=i.constructor;return s==="!"||s===a.tagName?(i.tag=a.tagName,i):(s&&(i.tag=s),i)}function bB(t,e,r,n,s){let o=n.tag,i=o?e.directives.tagName(o.source,f=>s(o,"TAG_RESOLVE_FAILED",f)):null;if(r.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=n,m=f&&o?f.offset>o.offset?f:o:f??o;m&&(!p||p.offset<m.offset)&&s(m,"MISSING_CHAR","Missing newline after block sequence props")}let a=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!o||!i||i==="!"||i===gB.YAMLMap.tagName&&a==="map"||i===yB.YAMLSeq.tagName&&a==="seq")return $y(t,e,r,s,i);let c=e.schema.tags.find(f=>f.tag===i&&f.collection===a);if(!c){let f=e.schema.knownTags[i];if(f?.collection===a)e.schema.tags.push(Object.assign({},f,{default:!1})),c=f;else return f?s(o,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0):s(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0),$y(t,e,r,s,i)}let l=$y(t,e,r,s,i,c),u=c.resolve?.(l,f=>s(o,"TAG_RESOLVE_FAILED",f),e.options)??l,d=hB.isNode(u)?u:new mB.Scalar(u);return d.range=l.range,d.tag=i,c?.format&&(d.format=c.format),d}HP.composeCollection=bB});var xy=_(JP=>{"use strict";var ky=Xe();function SB(t,e,r){let n=e.offset,s=$B(e,t.options.strict,r);if(!s)return{value:"",type:null,comment:"",range:[n,n,n]};let o=s.mode===">"?ky.Scalar.BLOCK_FOLDED:ky.Scalar.BLOCK_LITERAL,i=e.source?kB(e.source):[],a=i.length;for(let h=i.length-1;h>=0;--h){let g=i[h][1];if(g===""||g==="\r")a=h;else break}if(a===0){let h=s.chomp==="+"&&i.length>0?`
72
- `.repeat(Math.max(1,i.length-1)):"",g=n+s.length;return e.source&&(g+=e.source.length),{value:h,type:o,comment:s.comment,range:[n,g,g]}}let c=e.indent+s.indent,l=e.offset+s.length,u=0;for(let h=0;h<a;++h){let[g,y]=i[h];if(y===""||y==="\r")s.indent===0&&g.length>c&&(c=g.length);else{g.length<c&&r(l+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(c=g.length),u=h,c===0&&!t.atRoot&&r(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=g.length+y.length+1}for(let h=i.length-1;h>=a;--h)i[h][0].length>c&&(a=h+1);let d="",f="",p=!1;for(let h=0;h<u;++h)d+=i[h][0].slice(c)+`
73
- `;for(let h=u;h<a;++h){let[g,y]=i[h];l+=g.length+y.length+1;let w=y[y.length-1]==="\r";if(w&&(y=y.slice(0,-1)),y&&g.length<c){let x=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;r(l-y.length-(w?2:1),"BAD_INDENT",x),g=""}o===ky.Scalar.BLOCK_LITERAL?(d+=f+g.slice(c)+y,f=`
74
- `):g.length>c||y[0]===" "?(f===" "?f=`
75
- `:!p&&f===`
76
- `&&(f=`
77
-
78
- `),d+=f+g.slice(c)+y,f=`
79
- `,p=!0):y===""?f===`
80
- `?d+=`
81
- `:f=`
82
- `:(d+=f+y,f=" ",p=!1)}switch(s.chomp){case"-":break;case"+":for(let h=a;h<i.length;++h)d+=`
83
- `+i[h][0].slice(c);d[d.length-1]!==`
84
- `&&(d+=`
85
- `);break;default:d+=`
86
- `}let m=n+s.length+e.source.length;return{value:d,type:o,comment:s.comment,range:[n,m,m]}}function $B({offset:t,props:e},r,n){if(e[0].type!=="block-scalar-header")return n(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=e[0],o=s[0],i=0,a="",c=-1;for(let f=1;f<s.length;++f){let p=s[f];if(!a&&(p==="-"||p==="+"))a=p;else{let m=Number(p);!i&&m?i=m:c===-1&&(c=t+f)}}c!==-1&&n(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let l=!1,u="",d=s.length;for(let f=1;f<e.length;++f){let p=e[f];switch(p.type){case"space":l=!0;case"newline":d+=p.source.length;break;case"comment":r&&!l&&n(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,u=p.source.substring(1);break;case"error":n(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let m=`Unexpected token in block scalar header: ${p.type}`;n(p,"UNEXPECTED_TOKEN",m);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:o,indent:i,chomp:a,comment:u,length:d}}function kB(t){let e=t.split(/\n( *)/),r=e[0],n=r.match(/^( *)/),o=[n?.[1]?[n[1],r.slice(n[1].length)]:["",r]];for(let i=1;i<e.length;i+=2)o.push([e[i],e[i+1]]);return o}JP.resolveBlockScalar=SB});var Ty=_(YP=>{"use strict";var Ey=Xe(),xB=Wo();function EB(t,e,r){let{offset:n,type:s,source:o,end:i}=t,a,c,l=(f,p,m)=>r(n+f,p,m);switch(s){case"scalar":a=Ey.Scalar.PLAIN,c=TB(o,l);break;case"single-quoted-scalar":a=Ey.Scalar.QUOTE_SINGLE,c=PB(o,l);break;case"double-quoted-scalar":a=Ey.Scalar.QUOTE_DOUBLE,c=OB(o,l);break;default:return r(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[n,n+o.length,n+o.length]}}let u=n+o.length,d=xB.resolveEnd(i,u,e,r);return{value:c,type:a,comment:d.comment,range:[n,u,d.offset]}}function TB(t,e){let r="";switch(t[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${t[0]}`;break}case"@":case"`":{r=`reserved character ${t[0]}`;break}}return r&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),GP(t)}function PB(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),GP(t.slice(1,-1)).replace(/''/g,"'")}function GP(t){let e,r;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
87
- `,"sy"),r=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
88
- `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=e.exec(t);if(!n)return t;let s=n[1],o=" ",i=e.lastIndex;for(r.lastIndex=i;n=r.exec(t);)n[1]===""?o===`
89
- `?s+=o:o=`
90
- `:(s+=o+n[1],o=" "),i=r.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=i,n=a.exec(t),s+o+(n?.[1]??"")}function OB(t,e){let r="";for(let n=1;n<t.length-1;++n){let s=t[n];if(!(s==="\r"&&t[n+1]===`
59
+ `}zu.stringifyDocument=uw});var Ir=x(Qu=>{"use strict";var dw=yr(),Dt=kn(),le=$(),fw=Ye(),pw=Ve(),hw=$o(),mw=Xu(),Ao=xn(),gw=Mi(),yw=Sr(),Io=Ri(),Ro=class t{constructor(e,r,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,le.NODE_TYPE,{value:le.DOC});let s=null;typeof r=="function"||Array.isArray(r)?s=r:n===void 0&&r&&(n=r,r=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},n);this.options=i;let{version:o}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Io.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,s,n)}clone(){let e=Object.create(t.prototype,{[le.NODE_TYPE]:{value:le.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=le.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Ft(this.contents)&&this.contents.add(e)}addIn(e,r){Ft(this.contents)&&this.contents.addIn(e,r)}createAlias(e,r){if(!e.anchor){let n=Ao.anchorNames(this);e.anchor=!r||n.has(r)?Ao.findNewAnchor(r||"a",n):r}return new dw.Alias(e.anchor)}createNode(e,r,n){let s;if(typeof r=="function")e=r.call({"":e},"",e),s=r;else if(Array.isArray(r)){let m=w=>typeof w=="number"||w instanceof String||w instanceof Number,y=r.filter(m).map(String);y.length>0&&(r=r.concat(y)),s=r}else n===void 0&&r&&(n=r,r=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:u}=n??{},{onAnchor:f,setAnchors:d,sourceObjects:h}=Ao.createNodeAnchors(this,o||"a"),g={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:f,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:h},p=yw.createNode(e,u,g);return a&&le.isCollection(p)&&(p.flow=!0),d(),p}createPair(e,r,n={}){let s=this.createNode(e,null,n),i=this.createNode(r,null,n);return new fw.Pair(s,i)}delete(e){return Ft(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Dt.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Ft(this.contents)?this.contents.deleteIn(e):!1}get(e,r){return le.isCollection(this.contents)?this.contents.get(e,r):void 0}getIn(e,r){return Dt.isEmptyPath(e)?!r&&le.isScalar(this.contents)?this.contents.value:this.contents:le.isCollection(this.contents)?this.contents.getIn(e,r):void 0}has(e){return le.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Dt.isEmptyPath(e)?this.contents!==void 0:le.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,r){this.contents==null?this.contents=Dt.collectionFromPath(this.schema,[e],r):Ft(this.contents)&&this.contents.set(e,r)}setIn(e,r){Dt.isEmptyPath(e)?this.contents=r:this.contents==null?this.contents=Dt.collectionFromPath(this.schema,Array.from(e),r):Ft(this.contents)&&this.contents.setIn(e,r)}setSchema(e,r={}){typeof e=="number"&&(e=String(e));let n;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Io.Directives({version:"1.1"}),n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Io.Directives({version:e}),n={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,n=null;break;default:{let s=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${s}`)}}if(r.schema instanceof Object)this.schema=r.schema;else if(n)this.schema=new hw.Schema(Object.assign(n,r));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:r,mapAsMap:n,maxAliasCount:s,onAnchor:i,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},l=pw.toJS(this.contents,r??"",a);if(typeof i=="function")for(let{count:c,res:u}of a.anchors.values())i(u,c);return typeof o=="function"?gw.applyReviver(o,{"":l},"",l):l}toJSON(e,r){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:r})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let r=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${r}`)}return mw.stringifyDocument(this,e)}};function Ft(t){if(le.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Qu.Document=Ro});var Lr=x(Mr=>{"use strict";var Rr=class extends Error{constructor(e,r,n,s){super(),this.name=e,this.code=n,this.message=s,this.pos=r}},Mo=class extends Rr{constructor(e,r,n){super("YAMLParseError",e,r,n)}},Lo=class extends Rr{constructor(e,r,n){super("YAMLWarning",e,r,n)}},Sw=(t,e)=>r=>{if(r.pos[0]===-1)return;r.linePos=r.pos.map(a=>e.linePos(a));let{line:n,col:s}=r.linePos[0];r.message+=` at line ${n}, column ${s}`;let i=s-1,o=t.substring(e.lineStarts[n-1],e.lineStarts[n]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="\u2026"+o.substring(a),i-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),n>1&&/^ *$/.test(o.substring(0,i))){let a=t.substring(e.lineStarts[n-2],e.lineStarts[n-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
60
+ `),o=a+o}if(/[^ ]/.test(o)){let a=1,l=r.linePos[1];l?.line===n&&l.col>s&&(a=Math.max(1,Math.min(l.col-s,80-i)));let c=" ".repeat(i)+"^".repeat(a);r.message+=`:
61
+
62
+ ${o}
63
+ ${c}
64
+ `}};Mr.YAMLError=Rr;Mr.YAMLParseError=Mo;Mr.YAMLWarning=Lo;Mr.prettifyError=Sw});var jr=x(Zu=>{"use strict";function bw(t,{flow:e,indicator:r,next:n,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,u=a,f="",d="",h=!1,g=!1,p=null,m=null,y=null,w=null,_=null,v=null,E=null;for(let S of t)switch(g&&(S.type!=="space"&&S.type!=="newline"&&S.type!=="comma"&&i(S.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),p&&(c&&S.type!=="comment"&&S.type!=="newline"&&i(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),p=null),S.type){case"space":!e&&(r!=="doc-start"||n?.type!=="flow-collection")&&S.source.includes(" ")&&(p=S),u=!0;break;case"comment":{u||i(S,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let b=S.source.substring(1)||" ";f?f+=d+b:f=b,d="",c=!1;break}case"newline":c?f?f+=S.source:(!v||r!=="seq-item-ind")&&(l=!0):d+=S.source,c=!0,h=!0,(m||y)&&(w=S),u=!0;break;case"anchor":m&&i(S,"MULTIPLE_ANCHORS","A node can have at most one anchor"),S.source.endsWith(":")&&i(S.offset+S.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=S,E??(E=S.offset),c=!1,u=!1,g=!0;break;case"tag":{y&&i(S,"MULTIPLE_TAGS","A node can have at most one tag"),y=S,E??(E=S.offset),c=!1,u=!1,g=!0;break}case r:(m||y)&&i(S,"BAD_PROP_ORDER",`Anchors and tags must be after the ${S.source} indicator`),v&&i(S,"UNEXPECTED_TOKEN",`Unexpected ${S.source} in ${e??"collection"}`),v=S,c=r==="seq-item-ind"||r==="explicit-key-ind",u=!1;break;case"comma":if(e){_&&i(S,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),_=S,c=!1,u=!1;break}default:i(S,"UNEXPECTED_TOKEN",`Unexpected ${S.type} token`),c=!1,u=!1}let k=t[t.length-1],T=k?k.offset+k.source.length:s;return g&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!=="")&&i(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p&&(c&&p.indent<=o||n?.type==="block-map"||n?.type==="block-seq")&&i(p,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:_,found:v,spaceBefore:l,comment:f,hasNewline:h,anchor:m,tag:y,newlineAfterProp:w,end:T,start:E??T}}Zu.resolveProps=bw});var os=x(ed=>{"use strict";function jo(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
65
+ `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let r of e.start)if(r.type==="newline")return!0;if(e.sep){for(let r of e.sep)if(r.type==="newline")return!0}if(jo(e.key)||jo(e.value))return!0}return!1;default:return!0}}ed.containsNewline=jo});var Do=x(td=>{"use strict";var ww=os();function xw(t,e,r){if(e?.type==="flow-collection"){let n=e.end[0];n.indent===t&&(n.source==="]"||n.source==="}")&&ww.containsNewline(e)&&r(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}td.flowIndentCheck=xw});var Fo=x(nd=>{"use strict";var rd=$();function vw(t,e,r){let{uniqueKeys:n}=t.options;if(n===!1)return!1;let s=typeof n=="function"?n:(i,o)=>i===o||rd.isScalar(i)&&rd.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,r))}nd.mapIncludes=vw});var cd=x(ld=>{"use strict";var sd=Ye(),_w=Xe(),id=jr(),Ew=os(),od=Do(),kw=Fo(),ad="All mapping items must start at the same column";function Cw({composeNode:t,composeEmptyNode:e},r,n,s,i){let o=i?.nodeClass??_w.YAMLMap,a=new o(r.schema);r.atRoot&&(r.atRoot=!1);let l=n.offset,c=null;for(let u of n.items){let{start:f,key:d,sep:h,value:g}=u,p=id.resolveProps(f,{indicator:"explicit-key-ind",next:d??h?.[0],offset:l,onError:s,parentIndent:n.indent,startOnNewline:!0}),m=!p.found;if(m){if(d&&(d.type==="block-seq"?s(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==n.indent&&s(l,"BAD_INDENT",ad)),!p.anchor&&!p.tag&&!h){c=p.end,p.comment&&(a.comment?a.comment+=`
66
+ `+p.comment:a.comment=p.comment);continue}(p.newlineAfterProp||Ew.containsNewline(d))&&s(d??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else p.found?.indent!==n.indent&&s(l,"BAD_INDENT",ad);r.atKey=!0;let y=p.end,w=d?t(r,d,p,s):e(r,y,f,null,p,s);r.schema.compat&&od.flowIndentCheck(n.indent,d,s),r.atKey=!1,kw.mapIncludes(r,a.items,w)&&s(y,"DUPLICATE_KEY","Map keys must be unique");let _=id.resolveProps(h??[],{indicator:"map-value-ind",next:g,offset:w.range[2],onError:s,parentIndent:n.indent,startOnNewline:!d||d.type==="block-scalar"});if(l=_.end,_.found){m&&(g?.type==="block-map"&&!_.hasNewline&&s(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&p.start<_.found.offset-1024&&s(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let v=g?t(r,g,_,s):e(r,l,h,null,_,s);r.schema.compat&&od.flowIndentCheck(n.indent,g,s),l=v.range[2];let E=new sd.Pair(w,v);r.options.keepSourceTokens&&(E.srcToken=u),a.items.push(E)}else{m&&s(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),_.comment&&(w.comment?w.comment+=`
67
+ `+_.comment:w.comment=_.comment);let v=new sd.Pair(w);r.options.keepSourceTokens&&(v.srcToken=u),a.items.push(v)}}return c&&c<l&&s(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[n.offset,l,c??l],a}ld.resolveBlockMap=Cw});var dd=x(ud=>{"use strict";var Ow=Qe(),Tw=jr(),Pw=Do();function $w({composeNode:t,composeEmptyNode:e},r,n,s,i){let o=i?.nodeClass??Ow.YAMLSeq,a=new o(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let l=n.offset,c=null;for(let{start:u,value:f}of n.items){let d=Tw.resolveProps(u,{indicator:"seq-item-ind",next:f,offset:l,onError:s,parentIndent:n.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||f)f?.type==="block-seq"?s(d.end,"BAD_INDENT","All sequence items must start at the same column"):s(l,"MISSING_CHAR","Sequence item without - indicator");else{c=d.end,d.comment&&(a.comment=d.comment);continue}let h=f?t(r,f,d,s):e(r,d.end,u,null,d,s);r.schema.compat&&Pw.flowIndentCheck(n.indent,f,s),l=h.range[2],a.items.push(h)}return a.range=[n.offset,l,c??l],a}ud.resolveBlockSeq=$w});var qt=x(fd=>{"use strict";function Nw(t,e,r,n){let s="";if(t){let i=!1,o="";for(let a of t){let{source:l,type:c}=a;switch(c){case"space":i=!0;break;case"comment":{r&&!i&&n(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=l.substring(1)||" ";s?s+=o+u:s=u,o="";break}case"newline":s&&(o+=l),i=!0;break;default:n(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:s,offset:e}}fd.resolveEnd=Nw});var gd=x(md=>{"use strict";var Aw=$(),Iw=Ye(),pd=Xe(),Rw=Qe(),Mw=qt(),hd=jr(),Lw=os(),jw=Fo(),qo="Block collections are not allowed within flow collections",Bo=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Dw({composeNode:t,composeEmptyNode:e},r,n,s,i){let o=n.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?pd.YAMLMap:Rw.YAMLSeq),c=new l(r.schema);c.flow=!0;let u=r.atRoot;u&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let f=n.offset+n.start.source.length;for(let m=0;m<n.items.length;++m){let y=n.items[m],{start:w,key:_,sep:v,value:E}=y,k=hd.resolveProps(w,{flow:a,indicator:"explicit-key-ind",next:_??v?.[0],offset:f,onError:s,parentIndent:n.indent,startOnNewline:!1});if(!k.found){if(!k.anchor&&!k.tag&&!v&&!E){m===0&&k.comma?s(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):m<n.items.length-1&&s(k.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),k.comment&&(c.comment?c.comment+=`
68
+ `+k.comment:c.comment=k.comment),f=k.end;continue}!o&&r.options.strict&&Lw.containsNewline(_)&&s(_,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)k.comma&&s(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(k.comma||s(k.start,"MISSING_CHAR",`Missing , between ${a} items`),k.comment){let T="";e:for(let S of w)switch(S.type){case"comma":case"space":break;case"comment":T=S.source.substring(1);break e;default:break e}if(T){let S=c.items[c.items.length-1];Aw.isPair(S)&&(S=S.value??S.key),S.comment?S.comment+=`
69
+ `+T:S.comment=T,k.comment=k.comment.substring(T.length+1)}}if(!o&&!v&&!k.found){let T=E?t(r,E,k,s):e(r,k.end,v,null,k,s);c.items.push(T),f=T.range[2],Bo(E)&&s(T.range,"BLOCK_IN_FLOW",qo)}else{r.atKey=!0;let T=k.end,S=_?t(r,_,k,s):e(r,T,w,null,k,s);Bo(_)&&s(S.range,"BLOCK_IN_FLOW",qo),r.atKey=!1;let b=hd.resolveProps(v??[],{flow:a,indicator:"map-value-ind",next:E,offset:S.range[2],onError:s,parentIndent:n.indent,startOnNewline:!1});if(b.found){if(!o&&!k.found&&r.options.strict){if(v)for(let A of v){if(A===b.found)break;if(A.type==="newline"){s(A,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}k.start<b.found.offset-1024&&s(b.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else E&&("source"in E&&E.source?.[0]===":"?s(E,"MISSING_CHAR",`Missing space after : in ${a}`):s(b.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let C=E?t(r,E,b,s):b.found?e(r,b.end,v,null,b,s):null;C?Bo(E)&&s(C.range,"BLOCK_IN_FLOW",qo):b.comment&&(S.comment?S.comment+=`
70
+ `+b.comment:S.comment=b.comment);let R=new Iw.Pair(S,C);if(r.options.keepSourceTokens&&(R.srcToken=y),o){let A=c;jw.mapIncludes(r,A.items,S)&&s(T,"DUPLICATE_KEY","Map keys must be unique"),A.items.push(R)}else{let A=new pd.YAMLMap(r.schema);A.flow=!0,A.items.push(R);let D=(C??S).range;A.range=[S.range[0],D[1],D[2]],c.items.push(A)}f=C?C.range[2]:b.end}}let d=o?"}":"]",[h,...g]=n.end,p=f;if(h?.source===d)p=h.offset+h.source.length;else{let m=a[0].toUpperCase()+a.substring(1),y=u?`${m} must end with a ${d}`:`${m} in block collection must be sufficiently indented and end with a ${d}`;s(f,u?"MISSING_CHAR":"BAD_INDENT",y),h&&h.source.length!==1&&g.unshift(h)}if(g.length>0){let m=Mw.resolveEnd(g,p,r.options.strict,s);m.comment&&(c.comment?c.comment+=`
71
+ `+m.comment:c.comment=m.comment),c.range=[n.offset,p,m.offset]}else c.range=[n.offset,p,p];return c}md.resolveFlowCollection=Dw});var Sd=x(yd=>{"use strict";var Fw=$(),qw=V(),Bw=Xe(),Uw=Qe(),Kw=cd(),Ww=dd(),Vw=gd();function Uo(t,e,r,n,s,i){let o=r.type==="block-map"?Kw.resolveBlockMap(t,e,r,n,i):r.type==="block-seq"?Ww.resolveBlockSeq(t,e,r,n,i):Vw.resolveFlowCollection(t,e,r,n,i),a=o.constructor;return s==="!"||s===a.tagName?(o.tag=a.tagName,o):(s&&(o.tag=s),o)}function Gw(t,e,r,n,s){let i=n.tag,o=i?e.directives.tagName(i.source,d=>s(i,"TAG_RESOLVE_FAILED",d)):null;if(r.type==="block-seq"){let{anchor:d,newlineAfterProp:h}=n,g=d&&i?d.offset>i.offset?d:i:d??i;g&&(!h||h.offset<g.offset)&&s(g,"MISSING_CHAR","Missing newline after block sequence props")}let a=r.type==="block-map"?"map":r.type==="block-seq"?"seq":r.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===Bw.YAMLMap.tagName&&a==="map"||o===Uw.YAMLSeq.tagName&&a==="seq")return Uo(t,e,r,s,o);let l=e.schema.tags.find(d=>d.tag===o&&d.collection===a);if(!l){let d=e.schema.knownTags[o];if(d?.collection===a)e.schema.tags.push(Object.assign({},d,{default:!1})),l=d;else return d?s(i,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Uo(t,e,r,s,o)}let c=Uo(t,e,r,s,o,l),u=l.resolve?.(c,d=>s(i,"TAG_RESOLVE_FAILED",d),e.options)??c,f=Fw.isNode(u)?u:new qw.Scalar(u);return f.range=c.range,f.tag=o,l?.format&&(f.format=l.format),f}yd.composeCollection=Gw});var Wo=x(bd=>{"use strict";var Ko=V();function Jw(t,e,r){let n=e.offset,s=Hw(e,t.options.strict,r);if(!s)return{value:"",type:null,comment:"",range:[n,n,n]};let i=s.mode===">"?Ko.Scalar.BLOCK_FOLDED:Ko.Scalar.BLOCK_LITERAL,o=e.source?Yw(e.source):[],a=o.length;for(let p=o.length-1;p>=0;--p){let m=o[p][1];if(m===""||m==="\r")a=p;else break}if(a===0){let p=s.chomp==="+"&&o.length>0?`
72
+ `.repeat(Math.max(1,o.length-1)):"",m=n+s.length;return e.source&&(m+=e.source.length),{value:p,type:i,comment:s.comment,range:[n,m,m]}}let l=e.indent+s.indent,c=e.offset+s.length,u=0;for(let p=0;p<a;++p){let[m,y]=o[p];if(y===""||y==="\r")s.indent===0&&m.length>l&&(l=m.length);else{m.length<l&&r(c+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(l=m.length),u=p,l===0&&!t.atRoot&&r(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=m.length+y.length+1}for(let p=o.length-1;p>=a;--p)o[p][0].length>l&&(a=p+1);let f="",d="",h=!1;for(let p=0;p<u;++p)f+=o[p][0].slice(l)+`
73
+ `;for(let p=u;p<a;++p){let[m,y]=o[p];c+=m.length+y.length+1;let w=y[y.length-1]==="\r";if(w&&(y=y.slice(0,-1)),y&&m.length<l){let v=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;r(c-y.length-(w?2:1),"BAD_INDENT",v),m=""}i===Ko.Scalar.BLOCK_LITERAL?(f+=d+m.slice(l)+y,d=`
74
+ `):m.length>l||y[0]===" "?(d===" "?d=`
75
+ `:!h&&d===`
76
+ `&&(d=`
77
+
78
+ `),f+=d+m.slice(l)+y,d=`
79
+ `,h=!0):y===""?d===`
80
+ `?f+=`
81
+ `:d=`
82
+ `:(f+=d+y,d=" ",h=!1)}switch(s.chomp){case"-":break;case"+":for(let p=a;p<o.length;++p)f+=`
83
+ `+o[p][0].slice(l);f[f.length-1]!==`
84
+ `&&(f+=`
85
+ `);break;default:f+=`
86
+ `}let g=n+s.length+e.source.length;return{value:f,type:i,comment:s.comment,range:[n,g,g]}}function Hw({offset:t,props:e},r,n){if(e[0].type!=="block-scalar-header")return n(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=e[0],i=s[0],o=0,a="",l=-1;for(let d=1;d<s.length;++d){let h=s[d];if(!a&&(h==="-"||h==="+"))a=h;else{let g=Number(h);!o&&g?o=g:l===-1&&(l=t+d)}}l!==-1&&n(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let c=!1,u="",f=s.length;for(let d=1;d<e.length;++d){let h=e[d];switch(h.type){case"space":c=!0;case"newline":f+=h.source.length;break;case"comment":r&&!c&&n(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),f+=h.source.length,u=h.source.substring(1);break;case"error":n(h,"UNEXPECTED_TOKEN",h.message),f+=h.source.length;break;default:{let g=`Unexpected token in block scalar header: ${h.type}`;n(h,"UNEXPECTED_TOKEN",g);let p=h.source;p&&typeof p=="string"&&(f+=p.length)}}}return{mode:i,indent:o,chomp:a,comment:u,length:f}}function Yw(t){let e=t.split(/\n( *)/),r=e[0],n=r.match(/^( *)/),i=[n?.[1]?[n[1],r.slice(n[1].length)]:["",r]];for(let o=1;o<e.length;o+=2)i.push([e[o],e[o+1]]);return i}bd.resolveBlockScalar=Jw});var Go=x(xd=>{"use strict";var Vo=V(),zw=qt();function Xw(t,e,r){let{offset:n,type:s,source:i,end:o}=t,a,l,c=(d,h,g)=>r(n+d,h,g);switch(s){case"scalar":a=Vo.Scalar.PLAIN,l=Qw(i,c);break;case"single-quoted-scalar":a=Vo.Scalar.QUOTE_SINGLE,l=Zw(i,c);break;case"double-quoted-scalar":a=Vo.Scalar.QUOTE_DOUBLE,l=ex(i,c);break;default:return r(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[n,n+i.length,n+i.length]}}let u=n+i.length,f=zw.resolveEnd(o,u,e,r);return{value:l,type:a,comment:f.comment,range:[n,u,f.offset]}}function Qw(t,e){let r="";switch(t[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":{r=`block scalar indicator ${t[0]}`;break}case"@":case"`":{r=`reserved character ${t[0]}`;break}}return r&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),wd(t)}function Zw(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),wd(t.slice(1,-1)).replace(/''/g,"'")}function wd(t){let e=/(.*?)\r?\n/sy,r=e.exec(t);if(!r)return t;let n,s;try{n=new RegExp("(?<![ ])[ ]+$"),s=new RegExp("^[ ]+|(?<![ ])[ ]+$","g")}catch{n=/[ \t]+$/,s=/^[ \t]+|[ \t]+$/g}let i=r[1].replace(n,""),o=" ",a=e.lastIndex;for(;r=e.exec(t);){let c=r[1].replace(s,"");c===""?o===`
87
+ `?i+=o:o=`
88
+ `:(i+=o+c,o=" "),a=e.lastIndex}let l=/[ \t]*(.*)/sy;return l.lastIndex=a,r=l.exec(t),i+o+(r?.[1]??"")}function ex(t,e){let r="";for(let n=1;n<t.length-1;++n){let s=t[n];if(!(s==="\r"&&t[n+1]===`
91
89
  `))if(s===`
92
- `){let{fold:o,offset:i}=IB(t,n);r+=o,n=i}else if(s==="\\"){let o=t[++n],i=NB[o];if(i)r+=i;else if(o===`
93
- `)for(o=t[n+1];o===" "||o===" ";)o=t[++n+1];else if(o==="\r"&&t[n+1]===`
94
- `)for(o=t[++n+1];o===" "||o===" ";)o=t[++n+1];else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;r+=CB(t,n+1,a,e),n+=a}else{let a=t.substr(n-1,2);e(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),r+=a}}else if(s===" "||s===" "){let o=n,i=t[n+1];for(;i===" "||i===" ";)i=t[++n+1];i!==`
95
- `&&!(i==="\r"&&t[n+2]===`
96
- `)&&(r+=n>o?t.slice(o,n+1):s)}else r+=s}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),r}function IB(t,e){let r="",n=t[e+1];for(;(n===" "||n===" "||n===`
90
+ `){let{fold:i,offset:o}=tx(t,n);r+=i,n=o}else if(s==="\\"){let i=t[++n],o=rx[i];if(o)r+=o;else if(i===`
91
+ `)for(i=t[n+1];i===" "||i===" ";)i=t[++n+1];else if(i==="\r"&&t[n+1]===`
92
+ `)for(i=t[++n+1];i===" "||i===" ";)i=t[++n+1];else if(i==="x"||i==="u"||i==="U"){let a=i==="x"?2:i==="u"?4:8;r+=nx(t,n+1,a,e),n+=a}else{let a=t.substr(n-1,2);e(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),r+=a}}else if(s===" "||s===" "){let i=n,o=t[n+1];for(;o===" "||o===" ";)o=t[++n+1];o!==`
93
+ `&&!(o==="\r"&&t[n+2]===`
94
+ `)&&(r+=n>i?t.slice(i,n+1):s)}else r+=s}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),r}function tx(t,e){let r="",n=t[e+1];for(;(n===" "||n===" "||n===`
97
95
  `||n==="\r")&&!(n==="\r"&&t[e+2]!==`
98
96
  `);)n===`
99
97
  `&&(r+=`
100
- `),e+=1,n=t[e+1];return r||(r=" "),{fold:r,offset:e}}var NB={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
101
- `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function CB(t,e,r,n){let s=t.substr(e,r),i=s.length===r&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;try{return String.fromCodePoint(i)}catch{let a=t.substr(e-2,r+2);return n(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}YP.resolveFlowScalar=EB});var eO=_(QP=>{"use strict";var qs=pe(),XP=Xe(),RB=xy(),AB=Ty();function zB(t,e,r,n){let{value:s,type:o,comment:i,range:a}=e.type==="block-scalar"?RB.resolveBlockScalar(t,e,n):AB.resolveFlowScalar(e,t.options.strict,n),c=r?t.directives.tagName(r.source,d=>n(r,"TAG_RESOLVE_FAILED",d)):null,l;t.options.stringKeys&&t.atKey?l=t.schema[qs.SCALAR]:c?l=jB(t.schema,s,c,r,n):e.type==="scalar"?l=MB(t,s,e,n):l=t.schema[qs.SCALAR];let u;try{let d=l.resolve(s,f=>n(r??e,"TAG_RESOLVE_FAILED",f),t.options);u=qs.isScalar(d)?d:new XP.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);n(r??e,"TAG_RESOLVE_FAILED",f),u=new XP.Scalar(s)}return u.range=a,u.source=s,o&&(u.type=o),c&&(u.tag=c),l.format&&(u.format=l.format),i&&(u.comment=i),u}function jB(t,e,r,n,s){if(r==="!")return t[qs.SCALAR];let o=[];for(let a of t.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(e))return a;let i=t.knownTags[r];return i&&!i.collection?(t.tags.push(Object.assign({},i,{default:!1,test:void 0})),i):(s(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),t[qs.SCALAR])}function MB({atKey:t,directives:e,schema:r},n,s,o){let i=r.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(n))||r[qs.SCALAR];if(r.compat){let a=r.compat.find(c=>c.default&&c.test?.test(n))??r[qs.SCALAR];if(i.tag!==a.tag){let c=e.tagString(i.tag),l=e.tagString(a.tag),u=`Value may be parsed as either ${c} or ${l}`;o(s,"TAG_RESOLVE_FAILED",u,!0)}}return i}QP.composeScalar=zB});var rO=_(tO=>{"use strict";function LB(t,e,r){if(e){r??(r=e.length);for(let n=r-1;n>=0;--n){let s=e[n];switch(s.type){case"space":case"comment":case"newline":t-=s.source.length;continue}for(s=e[++n];s?.type==="space";)t+=s.source.length,s=e[++n];break}}return t}tO.emptyScalarPosition=LB});var oO=_(Oy=>{"use strict";var DB=Va(),qB=pe(),FB=WP(),nO=eO(),ZB=Wo(),UB=rO(),VB={composeNode:sO,composeEmptyNode:Py};function sO(t,e,r,n){let s=t.atKey,{spaceBefore:o,comment:i,anchor:a,tag:c}=r,l,u=!0;switch(e.type){case"alias":l=BB(t,e,n),(a||c)&&n(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=nO.composeScalar(t,e,c,n),a&&(l.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=FB.composeCollection(VB,t,e,r,n),a&&(l.anchor=a.source.substring(1))}catch(d){let f=d instanceof Error?d.message:String(d);n(e,"RESOURCE_EXHAUSTION",f)}break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;n(e,"UNEXPECTED_TOKEN",d),u=!1}}return l??(l=Py(t,e.offset,void 0,null,r,n)),a&&l.anchor===""&&n(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&t.options.stringKeys&&(!qB.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&n(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),o&&(l.spaceBefore=!0),i&&(e.type==="scalar"&&e.source===""?l.comment=i:l.commentBefore=i),t.options.keepSourceTokens&&u&&(l.srcToken=e),l}function Py(t,e,r,n,{spaceBefore:s,comment:o,anchor:i,tag:a,end:c},l){let u={type:"scalar",offset:UB.emptyScalarPosition(e,r,n),indent:-1,source:""},d=nO.composeScalar(t,u,a,l);return i&&(d.anchor=i.source.substring(1),d.anchor===""&&l(i,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(d.spaceBefore=!0),o&&(d.comment=o,d.range[2]=c),d}function BB({options:t},{offset:e,source:r,end:n},s){let o=new DB.Alias(r.substring(1));o.source===""&&s(e,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&s(e+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=e+r.length,a=ZB.resolveEnd(n,i,t.strict,s);return o.range=[e,i,a.offset],a.comment&&(o.comment=a.comment),o}Oy.composeEmptyNode=Py;Oy.composeNode=sO});var cO=_(aO=>{"use strict";var KB=ic(),iO=oO(),HB=Wo(),WB=uc();function JB(t,e,{offset:r,start:n,value:s,end:o},i){let a=Object.assign({_directives:e},t),c=new KB.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=WB.resolveProps(n,{indicator:"doc-start",next:s??o?.[0],offset:r,onError:i,parentIndent:0,startOnNewline:!0});u.found&&(c.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!u.hasNewline&&i(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=s?iO.composeNode(l,s,u,i):iO.composeEmptyNode(l,u.end,n,null,u,i);let d=c.contents.range[2],f=HB.resolveEnd(o,d,!1,i);return f.comment&&(c.comment=f.comment),c.range=[r,d,f.offset],c}aO.composeDoc=JB});var Ny=_(dO=>{"use strict";var GB=je("process"),YB=gg(),XB=ic(),dc=lc(),lO=pe(),QB=cO(),e3=Wo();function fc(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:r}=t;return[e,e+(typeof r=="string"?r.length:1)]}function uO(t){let e="",r=!1,n=!1;for(let s=0;s<t.length;++s){let o=t[s];switch(o[0]){case"#":e+=(e===""?"":n?`
98
+ `),e+=1,n=t[e+1];return r||(r=" "),{fold:r,offset:e}}var rx={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
99
+ `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function nx(t,e,r,n){let s=t.substr(e,r),o=s.length===r&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;try{return String.fromCodePoint(o)}catch{let a=t.substr(e-2,r+2);return n(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}xd.resolveFlowScalar=Xw});var Ed=x(_d=>{"use strict";var gt=$(),vd=V(),sx=Wo(),ix=Go();function ox(t,e,r,n){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?sx.resolveBlockScalar(t,e,n):ix.resolveFlowScalar(e,t.options.strict,n),l=r?t.directives.tagName(r.source,f=>n(r,"TAG_RESOLVE_FAILED",f)):null,c;t.options.stringKeys&&t.atKey?c=t.schema[gt.SCALAR]:l?c=ax(t.schema,s,l,r,n):e.type==="scalar"?c=lx(t,s,e,n):c=t.schema[gt.SCALAR];let u;try{let f=c.resolve(s,d=>n(r??e,"TAG_RESOLVE_FAILED",d),t.options);u=gt.isScalar(f)?f:new vd.Scalar(f)}catch(f){let d=f instanceof Error?f.message:String(f);n(r??e,"TAG_RESOLVE_FAILED",d),u=new vd.Scalar(s)}return u.range=a,u.source=s,i&&(u.type=i),l&&(u.tag=l),c.format&&(u.format=c.format),o&&(u.comment=o),u}function ax(t,e,r,n,s){if(r==="!")return t[gt.SCALAR];let i=[];for(let a of t.tags)if(!a.collection&&a.tag===r)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(e))return a;let o=t.knownTags[r];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(s(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,r!=="tag:yaml.org,2002:str"),t[gt.SCALAR])}function lx({atKey:t,directives:e,schema:r},n,s,i){let o=r.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(n))||r[gt.SCALAR];if(r.compat){let a=r.compat.find(l=>l.default&&l.test?.test(n))??r[gt.SCALAR];if(o.tag!==a.tag){let l=e.tagString(o.tag),c=e.tagString(a.tag),u=`Value may be parsed as either ${l} or ${c}`;i(s,"TAG_RESOLVE_FAILED",u,!0)}}return o}_d.composeScalar=ox});var Cd=x(kd=>{"use strict";function cx(t,e,r){if(e){r??(r=e.length);for(let n=r-1;n>=0;--n){let s=e[n];switch(s.type){case"space":case"comment":case"newline":t-=s.source.length;continue}for(s=e[++n];s?.type==="space";)t+=s.source.length,s=e[++n];break}}return t}kd.emptyScalarPosition=cx});var Pd=x(Ho=>{"use strict";var ux=yr(),dx=$(),fx=Sd(),Od=Ed(),px=qt(),hx=Cd(),mx={composeNode:Td,composeEmptyNode:Jo};function Td(t,e,r,n){let s=t.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=r,c,u=!0;switch(e.type){case"alias":c=gx(t,e,n),(a||l)&&n(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=Od.composeScalar(t,e,l,n),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=fx.composeCollection(mx,t,e,r,n),a&&(c.anchor=a.source.substring(1))}catch(f){let d=f instanceof Error?f.message:String(f);n(e,"RESOURCE_EXHAUSTION",d)}break;default:{let f=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;n(e,"UNEXPECTED_TOKEN",f),u=!1}}return c??(c=Jo(t,e.offset,void 0,null,r,n)),a&&c.anchor===""&&n(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&t.options.stringKeys&&(!dx.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&n(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(c.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?c.comment=o:c.commentBefore=o),t.options.keepSourceTokens&&u&&(c.srcToken=e),c}function Jo(t,e,r,n,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let u={type:"scalar",offset:hx.emptyScalarPosition(e,r,n),indent:-1,source:""},f=Od.composeScalar(t,u,a,c);return o&&(f.anchor=o.source.substring(1),f.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(f.spaceBefore=!0),i&&(f.comment=i,f.range[2]=l),f}function gx({options:t},{offset:e,source:r,end:n},s){let i=new ux.Alias(r.substring(1));i.source===""&&s(e,"BAD_ALIAS","Alias cannot be an empty string"),i.source.endsWith(":")&&s(e+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+r.length,a=px.resolveEnd(n,o,t.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}Ho.composeEmptyNode=Jo;Ho.composeNode=Td});var Ad=x(Nd=>{"use strict";var yx=Ir(),$d=Pd(),Sx=qt(),bx=jr();function wx(t,e,{offset:r,start:n,value:s,end:i},o){let a=Object.assign({_directives:e},t),l=new yx.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},u=bx.resolveProps(n,{indicator:"doc-start",next:s??i?.[0],offset:r,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(l.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!u.hasNewline&&o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=s?$d.composeNode(c,s,u,o):$d.composeEmptyNode(c,u.end,n,null,u,o);let f=l.contents.range[2],d=Sx.resolveEnd(i,f,!1,o);return d.comment&&(l.comment=d.comment),l.range=[r,f,d.offset],l}Nd.composeDoc=wx});var zo=x(Md=>{"use strict";var xx=B("process"),vx=Ri(),_x=Ir(),Dr=Lr(),Id=$(),Ex=Ad(),kx=qt();function Fr(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:r}=t;return[e,e+(typeof r=="string"?r.length:1)]}function Rd(t){let e="",r=!1,n=!1;for(let s=0;s<t.length;++s){let i=t[s];switch(i[0]){case"#":e+=(e===""?"":n?`
102
100
 
103
101
  `:`
104
- `)+(o.substring(1)||" "),r=!0,n=!1;break;case"%":t[s+1]?.[0]!=="#"&&(s+=1),r=!1;break;default:r||(n=!0),r=!1}}return{comment:e,afterEmptyLine:n}}var Iy=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,n,s,o)=>{let i=fc(r);o?this.warnings.push(new dc.YAMLWarning(i,n,s)):this.errors.push(new dc.YAMLParseError(i,n,s))},this.directives=new YB.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:n,afterEmptyLine:s}=uO(this.prelude);if(n){let o=e.contents;if(r)e.comment=e.comment?`${e.comment}
105
- ${n}`:n;else if(s||e.directives.docStart||!o)e.commentBefore=n;else if(lO.isCollection(o)&&!o.flow&&o.items.length>0){let i=o.items[0];lO.isPair(i)&&(i=i.key);let a=i.commentBefore;i.commentBefore=a?`${n}
106
- ${a}`:n}else{let i=o.commentBefore;o.commentBefore=i?`${n}
107
- ${i}`:n}}if(r){for(let o=0;o<this.errors.length;++o)e.errors.push(this.errors[o]);for(let o=0;o<this.warnings.length;++o)e.warnings.push(this.warnings[o])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:uO(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,r=!1,n=-1){for(let s of e)yield*this.next(s);yield*this.end(r,n)}*next(e){switch(GB.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,n,s)=>{let o=fc(e);o[0]+=r,this.onError(o,"BAD_DIRECTIVE",n,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=QB.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(r,!1),this.doc&&(yield this.doc),this.doc=r,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let r=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new dc.YAMLParseError(fc(e),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){let n="Unexpected doc-end without preceding document";this.errors.push(new dc.YAMLParseError(fc(e),"UNEXPECTED_TOKEN",n));break}this.doc.directives.docEnd=!0;let r=e3.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),r.comment){let n=this.doc.comment;this.doc.comment=n?`${n}
108
- ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new dc.YAMLParseError(fc(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let n=Object.assign({_directives:this.directives},this.options),s=new XB.Document(void 0,n);this.atDirectives&&this.onError(r,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,r,r],this.decorate(s,!1),yield s}}};dO.Composer=Iy});var hO=_(af=>{"use strict";var t3=xy(),r3=Ty(),n3=lc(),fO=Ja();function s3(t,e=!0,r){if(t){let n=(s,o,i)=>{let a=typeof s=="number"?s:Array.isArray(s)?s[0]:s.offset;if(r)r(a,o,i);else throw new n3.YAMLParseError([a,a+1],o,i)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return r3.resolveFlowScalar(t,e,n);case"block-scalar":return t3.resolveBlockScalar({options:{strict:e}},t,n)}}return null}function o3(t,e){let{implicitKey:r=!1,indent:n,inFlow:s=!1,offset:o=-1,type:i="PLAIN"}=e,a=fO.stringifyString({type:i,value:t},{implicitKey:r,indent:n>0?" ".repeat(n):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),c=e.end??[{type:"newline",offset:-1,indent:n,source:`
109
- `}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
110
- `),u=a.substring(0,l),d=a.substring(l+1)+`
111
- `,f=[{type:"block-scalar-header",offset:o,indent:n,source:u}];return pO(f,c)||f.push({type:"newline",offset:-1,indent:n,source:`
112
- `}),{type:"block-scalar",offset:o,indent:n,props:f,source:d}}case'"':return{type:"double-quoted-scalar",offset:o,indent:n,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:n,source:a,end:c};default:return{type:"scalar",offset:o,indent:n,source:a,end:c}}}function i3(t,e,r={}){let{afterKey:n=!1,implicitKey:s=!1,inFlow:o=!1,type:i}=r,a="indent"in t?t.indent:null;if(n&&typeof a=="number"&&(a+=2),!i)switch(t.type){case"single-quoted-scalar":i="QUOTE_SINGLE";break;case"double-quoted-scalar":i="QUOTE_DOUBLE";break;case"block-scalar":{let l=t.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:i="PLAIN"}let c=fO.stringifyString({type:i,value:e},{implicitKey:s||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":a3(t,c);break;case'"':Cy(t,c,"double-quoted-scalar");break;case"'":Cy(t,c,"single-quoted-scalar");break;default:Cy(t,c,"scalar")}}function a3(t,e){let r=e.indexOf(`
102
+ `)+(i.substring(1)||" "),r=!0,n=!1;break;case"%":t[s+1]?.[0]!=="#"&&(s+=1),r=!1;break;default:r||(n=!0),r=!1}}return{comment:e,afterEmptyLine:n}}var Yo=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(r,n,s,i)=>{let o=Fr(r);i?this.warnings.push(new Dr.YAMLWarning(o,n,s)):this.errors.push(new Dr.YAMLParseError(o,n,s))},this.directives=new vx.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,r){let{comment:n,afterEmptyLine:s}=Rd(this.prelude);if(n){let i=e.contents;if(r)e.comment=e.comment?`${e.comment}
103
+ ${n}`:n;else if(s||e.directives.docStart||!i)e.commentBefore=n;else if(Id.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];Id.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${n}
104
+ ${a}`:n}else{let o=i.commentBefore;i.commentBefore=o?`${n}
105
+ ${o}`:n}}if(r){for(let i=0;i<this.errors.length;++i)e.errors.push(this.errors[i]);for(let i=0;i<this.warnings.length;++i)e.warnings.push(this.warnings[i])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Rd(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,r=!1,n=-1){for(let s of e)yield*this.next(s);yield*this.end(r,n)}*next(e){switch(xx.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(r,n,s)=>{let i=Fr(e);i[0]+=r,this.onError(i,"BAD_DIRECTIVE",n,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let r=Ex.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!r.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(r,!1),this.doc&&(yield this.doc),this.doc=r,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let r=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new Dr.YAMLParseError(Fr(e),"UNEXPECTED_TOKEN",r);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){let n="Unexpected doc-end without preceding document";this.errors.push(new Dr.YAMLParseError(Fr(e),"UNEXPECTED_TOKEN",n));break}this.doc.directives.docEnd=!0;let r=kx.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),r.comment){let n=this.doc.comment;this.doc.comment=n?`${n}
106
+ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.push(new Dr.YAMLParseError(Fr(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,r=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let n=Object.assign({_directives:this.directives},this.options),s=new _x.Document(void 0,n);this.atDirectives&&this.onError(r,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,r,r],this.decorate(s,!1),yield s}}};Md.Composer=Yo});var Dd=x(as=>{"use strict";var Cx=Wo(),Ox=Go(),Tx=Lr(),Ld=vr();function Px(t,e=!0,r){if(t){let n=(s,i,o)=>{let a=typeof s=="number"?s:Array.isArray(s)?s[0]:s.offset;if(r)r(a,i,o);else throw new Tx.YAMLParseError([a,a+1],i,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Ox.resolveFlowScalar(t,e,n);case"block-scalar":return Cx.resolveBlockScalar({options:{strict:e}},t,n)}}return null}function $x(t,e){let{implicitKey:r=!1,indent:n,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=Ld.stringifyString({type:o,value:t},{implicitKey:r,indent:n>0?" ".repeat(n):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),l=e.end??[{type:"newline",offset:-1,indent:n,source:`
107
+ `}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
108
+ `),u=a.substring(0,c),f=a.substring(c+1)+`
109
+ `,d=[{type:"block-scalar-header",offset:i,indent:n,source:u}];return jd(d,l)||d.push({type:"newline",offset:-1,indent:n,source:`
110
+ `}),{type:"block-scalar",offset:i,indent:n,props:d,source:f}}case'"':return{type:"double-quoted-scalar",offset:i,indent:n,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:i,indent:n,source:a,end:l};default:return{type:"scalar",offset:i,indent:n,source:a,end:l}}}function Nx(t,e,r={}){let{afterKey:n=!1,implicitKey:s=!1,inFlow:i=!1,type:o}=r,a="indent"in t?t.indent:null;if(n&&typeof a=="number"&&(a+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=t.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=Ld.stringifyString({type:o,value:e},{implicitKey:s||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":Ax(t,l);break;case'"':Xo(t,l,"double-quoted-scalar");break;case"'":Xo(t,l,"single-quoted-scalar");break;default:Xo(t,l,"scalar")}}function Ax(t,e){let r=e.indexOf(`
113
111
  `),n=e.substring(0,r),s=e.substring(r+1)+`
114
- `;if(t.type==="block-scalar"){let o=t.props[0];if(o.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o.source=n,t.source=s}else{let{offset:o}=t,i="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:o,indent:i,source:n}];pO(a,"end"in t?t.end:void 0)||a.push({type:"newline",offset:-1,indent:i,source:`
115
- `});for(let c of Object.keys(t))c!=="type"&&c!=="offset"&&delete t[c];Object.assign(t,{type:"block-scalar",indent:i,props:a,source:s})}}function pO(t,e){if(e)for(let r of e)switch(r.type){case"space":case"comment":t.push(r);break;case"newline":return t.push(r),!0}return!1}function Cy(t,e,r){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=r,t.source=e;break;case"block-scalar":{let n=t.props.slice(1),s=e.length;t.props[0].type==="block-scalar-header"&&(s-=t.props[0].source.length);for(let o of n)o.offset+=s;delete t.props,Object.assign(t,{type:r,source:e,end:n});break}case"block-map":case"block-seq":{let s={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
116
- `};delete t.items,Object.assign(t,{type:r,source:e,end:[s]});break}default:{let n="indent"in t?t.indent:-1,s="end"in t&&Array.isArray(t.end)?t.end.filter(o=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(t))o!=="type"&&o!=="offset"&&delete t[o];Object.assign(t,{type:r,indent:n,source:e,end:s})}}}af.createScalarToken=o3;af.resolveAsScalar=s3;af.setScalarValue=i3});var gO=_(mO=>{"use strict";var c3=t=>"type"in t?lf(t):cf(t);function lf(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=lf(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=cf(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=cf(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=cf(t);if(t.end)for(let r of t.end)e+=r.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let r of t.end)e+=r.source;return e}}}function cf({start:t,key:e,sep:r,value:n}){let s="";for(let o of t)s+=o.source;if(e&&(s+=lf(e)),r)for(let o of r)s+=o.source;return n&&(s+=lf(n)),s}mO.stringify=c3});var wO=_(vO=>{"use strict";var Ry=Symbol("break visit"),l3=Symbol("skip children"),yO=Symbol("remove item");function Fs(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),_O(Object.freeze([]),t,e)}Fs.BREAK=Ry;Fs.SKIP=l3;Fs.REMOVE=yO;Fs.itemAtPath=(t,e)=>{let r=t;for(let[n,s]of e){let o=r?.[n];if(o&&"items"in o)r=o.items[s];else return}return r};Fs.parentCollection=(t,e)=>{let r=Fs.itemAtPath(t,e.slice(0,-1)),n=e[e.length-1][0],s=r?.[n];if(s&&"items"in s)return s;throw new Error("Parent collection not found")};function _O(t,e,r){let n=r(e,t);if(typeof n=="symbol")return n;for(let s of["key","value"]){let o=e[s];if(o&&"items"in o){for(let i=0;i<o.items.length;++i){let a=_O(Object.freeze(t.concat([[s,i]])),o.items[i],r);if(typeof a=="number")i=a-1;else{if(a===Ry)return Ry;a===yO&&(o.items.splice(i,1),i-=1)}}typeof n=="function"&&s==="key"&&(n=n(e,t))}}return typeof n=="function"?n(e,t):n}vO.visit=Fs});var uf=_(Ct=>{"use strict";var Ay=hO(),u3=gO(),d3=wO(),zy="\uFEFF",jy="",My="",Ly="",f3=t=>!!t&&"items"in t,p3=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function h3(t){switch(t){case zy:return"<BOM>";case jy:return"<DOC>";case My:return"<FLOW_END>";case Ly:return"<SCALAR>";default:return JSON.stringify(t)}}function m3(t){switch(t){case zy:return"byte-order-mark";case jy:return"doc-mode";case My:return"flow-error-end";case Ly:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
112
+ `;if(t.type==="block-scalar"){let i=t.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=n,t.source=s}else{let{offset:i}=t,o="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:n}];jd(a,"end"in t?t.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
113
+ `});for(let l of Object.keys(t))l!=="type"&&l!=="offset"&&delete t[l];Object.assign(t,{type:"block-scalar",indent:o,props:a,source:s})}}function jd(t,e){if(e)for(let r of e)switch(r.type){case"space":case"comment":t.push(r);break;case"newline":return t.push(r),!0}return!1}function Xo(t,e,r){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=r,t.source=e;break;case"block-scalar":{let n=t.props.slice(1),s=e.length;t.props[0].type==="block-scalar-header"&&(s-=t.props[0].source.length);for(let i of n)i.offset+=s;delete t.props,Object.assign(t,{type:r,source:e,end:n});break}case"block-map":case"block-seq":{let s={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
114
+ `};delete t.items,Object.assign(t,{type:r,source:e,end:[s]});break}default:{let n="indent"in t?t.indent:-1,s="end"in t&&Array.isArray(t.end)?t.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(t))i!=="type"&&i!=="offset"&&delete t[i];Object.assign(t,{type:r,indent:n,source:e,end:s})}}}as.createScalarToken=$x;as.resolveAsScalar=Px;as.setScalarValue=Nx});var qd=x(Fd=>{"use strict";var Ix=t=>"type"in t?cs(t):ls(t);function cs(t){switch(t.type){case"block-scalar":{let e="";for(let r of t.props)e+=cs(r);return e+t.source}case"block-map":case"block-seq":{let e="";for(let r of t.items)e+=ls(r);return e}case"flow-collection":{let e=t.start.source;for(let r of t.items)e+=ls(r);for(let r of t.end)e+=r.source;return e}case"document":{let e=ls(t);if(t.end)for(let r of t.end)e+=r.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let r of t.end)e+=r.source;return e}}}function ls({start:t,key:e,sep:r,value:n}){let s="";for(let i of t)s+=i.source;if(e&&(s+=cs(e)),r)for(let i of r)s+=i.source;return n&&(s+=cs(n)),s}Fd.stringify=Ix});var Wd=x(Kd=>{"use strict";var Qo=Symbol("break visit"),Rx=Symbol("skip children"),Bd=Symbol("remove item");function yt(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Ud(Object.freeze([]),t,e)}yt.BREAK=Qo;yt.SKIP=Rx;yt.REMOVE=Bd;yt.itemAtPath=(t,e)=>{let r=t;for(let[n,s]of e){let i=r?.[n];if(i&&"items"in i)r=i.items[s];else return}return r};yt.parentCollection=(t,e)=>{let r=yt.itemAtPath(t,e.slice(0,-1)),n=e[e.length-1][0],s=r?.[n];if(s&&"items"in s)return s;throw new Error("Parent collection not found")};function Ud(t,e,r){let n=r(e,t);if(typeof n=="symbol")return n;for(let s of["key","value"]){let i=e[s];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=Ud(Object.freeze(t.concat([[s,o]])),i.items[o],r);if(typeof a=="number")o=a-1;else{if(a===Qo)return Qo;a===Bd&&(i.items.splice(o,1),o-=1)}}typeof n=="function"&&s==="key"&&(n=n(e,t))}}return typeof n=="function"?n(e,t):n}Kd.visit=yt});var us=x(ne=>{"use strict";var Zo=Dd(),Mx=qd(),Lx=Wd(),ea="\uFEFF",ta="",ra="",na="",jx=t=>!!t&&"items"in t,Dx=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function Fx(t){switch(t){case ea:return"<BOM>";case ta:return"<DOC>";case ra:return"<FLOW_END>";case na:return"<SCALAR>";default:return JSON.stringify(t)}}function qx(t){switch(t){case ea:return"byte-order-mark";case ta:return"doc-mode";case ra:return"flow-error-end";case na:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
117
115
  `:case`\r
118
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}Ct.createScalarToken=Ay.createScalarToken;Ct.resolveAsScalar=Ay.resolveAsScalar;Ct.setScalarValue=Ay.setScalarValue;Ct.stringify=u3.stringify;Ct.visit=d3.visit;Ct.BOM=zy;Ct.DOCUMENT=jy;Ct.FLOW_END=My;Ct.SCALAR=Ly;Ct.isCollection=f3;Ct.isScalar=p3;Ct.prettyToken=h3;Ct.tokenType=m3});var Fy=_(SO=>{"use strict";var pc=uf();function xr(t){switch(t){case void 0:case" ":case`
119
- `:case"\r":case" ":return!0;default:return!1}}var bO=new Set("0123456789ABCDEFabcdef"),g3=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),df=new Set(",[]{}"),y3=new Set(` ,[]{}
120
- \r `),Dy=t=>!t||y3.has(t),qy=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,r=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!r;let n=this.next??"stream";for(;n&&(r||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,r=this.buffer[e];for(;r===" "||r===" ";)r=this.buffer[++e];return!r||r==="#"||r===`
116
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}ne.createScalarToken=Zo.createScalarToken;ne.resolveAsScalar=Zo.resolveAsScalar;ne.setScalarValue=Zo.setScalarValue;ne.stringify=Mx.stringify;ne.visit=Lx.visit;ne.BOM=ea;ne.DOCUMENT=ta;ne.FLOW_END=ra;ne.SCALAR=na;ne.isCollection=jx;ne.isScalar=Dx;ne.prettyToken=Fx;ne.tokenType=qx});var oa=x(Gd=>{"use strict";var qr=us();function ye(t){switch(t){case void 0:case" ":case`
117
+ `:case"\r":case" ":return!0;default:return!1}}var Vd=new Set("0123456789ABCDEFabcdef"),Bx=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ds=new Set(",[]{}"),Ux=new Set(` ,[]{}
118
+ \r `),sa=t=>!t||Ux.has(t),ia=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,r=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!r;let n=this.next??"stream";for(;n&&(r||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,r=this.buffer[e];for(;r===" "||r===" ";)r=this.buffer[++e];return!r||r==="#"||r===`
121
119
  `?!0:r==="\r"?this.buffer[e+1]===`
122
120
  `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let r=this.buffer[e];if(this.indentNext>0){let n=0;for(;r===" ";)r=this.buffer[++n+e];if(r==="\r"){let s=this.buffer[n+e+1];if(s===`
123
121
  `||!s&&!this.atEnd)return e+n+1}return r===`
124
- `||n>=this.indentNext||!r&&!this.atEnd?e+n:-1}if(r==="-"||r==="."){let n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&xr(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
125
- `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===pc.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let r=e.length,n=e.indexOf("#");for(;n!==-1;){let o=e[n-1];if(o===" "||o===" "){r=n-1;break}else n=e.indexOf("#",n+1)}for(;;){let o=e[r-1];if(o===" "||o===" ")r-=1;else break}let s=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-s),this.pushNewline(),"stream"}if(this.atLineEnd()){let r=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-r),yield*this.pushNewline(),"stream"}return yield pc.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&xr(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,r==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!xr(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&xr(r)){let n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(e[r]){case"#":yield*this.pushCount(e.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Dy),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,r,n=-1;do e=yield*this.pushNewline(),e>0?(r=yield*this.pushSpaces(!1),this.indentValue=n=r):r=0,r+=yield*this.pushSpaces(!0);while(e+r>0);let s=this.getLine();if(s===null)return this.setNext("flow");if((n!==-1&&n<this.indentNext&&s[0]!=="#"||n===0&&(s.startsWith("---")||s.startsWith("..."))&&xr(s[3]))&&!(n===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield pc.FLOW_END,yield*this.parseLineStart();let o=0;for(;s[o]===",";)o+=yield*this.pushCount(1),o+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(o+=yield*this.pushIndicators(),s[o]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-o),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Dy),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||xr(i)||i===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),r=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let o=0;for(;this.buffer[r-1-o]==="\\";)o+=1;if(o%2===0)break;r=this.buffer.indexOf('"',r+1)}let n=this.buffer.substring(0,r),s=n.indexOf(`
126
- `,this.pos);if(s!==-1){for(;s!==-1;){let o=this.continueScalar(s+1);if(o===-1)break;s=n.indexOf(`
127
- `,o)}s!==-1&&(r=s-(n[s-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let r=this.buffer[++e];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>xr(r)||r==="#")}*parseBlockScalar(){let e=this.pos-1,r=0,n;e:for(let o=this.pos;n=this.buffer[o];++o)switch(n){case" ":r+=1;break;case`
128
- `:e=o,r=0;break;case"\r":{let i=this.buffer[o+1];if(!i&&!this.atEnd)return this.setNext("block-scalar");if(i===`
129
- `)break}default:break e}if(!n&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=r:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let o=this.continueScalar(e+1);if(o===-1)break;e=this.buffer.indexOf(`
130
- `,o)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let s=e+1;for(n=this.buffer[s];n===" ";)n=this.buffer[++s];if(n===" "){for(;n===" "||n===" "||n==="\r"||n===`
131
- `;)n=this.buffer[++s];e=s-1}else if(!this.blockScalarKeep)do{let o=e-1,i=this.buffer[o];i==="\r"&&(i=this.buffer[--o]);let a=o;for(;i===" ";)i=this.buffer[--o];if(i===`
132
- `&&o>=this.pos&&o+1+r>a)e=o;else break}while(!0);return yield pc.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,r=this.pos-1,n=this.pos-1,s;for(;s=this.buffer[++n];)if(s===":"){let o=this.buffer[n+1];if(xr(o)||e&&df.has(o))break;r=n}else if(xr(s)){let o=this.buffer[n+1];if(s==="\r"&&(o===`
122
+ `||n>=this.indentNext||!r&&!this.atEnd?e+n:-1}if(r==="-"||r==="."){let n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&ye(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
123
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===qr.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let r=e.length,n=e.indexOf("#");for(;n!==-1;){let i=e[n-1];if(i===" "||i===" "){r=n-1;break}else n=e.indexOf("#",n+1)}for(;;){let i=e[r-1];if(i===" "||i===" ")r-=1;else break}let s=(yield*this.pushCount(r))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-s),this.pushNewline(),"stream"}if(this.atLineEnd()){let r=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-r),yield*this.pushNewline(),"stream"}return yield qr.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let r=this.peek(3);if((r==="---"||r==="...")&&ye(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,r==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ye(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,r]=this.peek(2);if(!r&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&ye(r)){let n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let r=yield*this.pushIndicators();switch(e[r]){case"#":yield*this.pushCount(e.length-r);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(sa),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return r+=yield*this.parseBlockScalarHeader(),r+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-r),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,r,n=-1;do e=yield*this.pushNewline(),e>0?(r=yield*this.pushSpaces(!1),this.indentValue=n=r):r=0,r+=yield*this.pushSpaces(!0);while(e+r>0);let s=this.getLine();if(s===null)return this.setNext("flow");if((n!==-1&&n<this.indentNext&&s[0]!=="#"||n===0&&(s.startsWith("---")||s.startsWith("..."))&&ye(s[3]))&&!(n===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield qr.FLOW_END,yield*this.parseLineStart();let i=0;for(;s[i]===",";)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),s[i]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-i),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(sa),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||ye(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),r=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;r!==-1&&this.buffer[r+1]==="'";)r=this.buffer.indexOf("'",r+2);else for(;r!==-1;){let i=0;for(;this.buffer[r-1-i]==="\\";)i+=1;if(i%2===0)break;r=this.buffer.indexOf('"',r+1)}let n=this.buffer.substring(0,r),s=n.indexOf(`
124
+ `,this.pos);if(s!==-1){for(;s!==-1;){let i=this.continueScalar(s+1);if(i===-1)break;s=n.indexOf(`
125
+ `,i)}s!==-1&&(r=s-(n[s-1]==="\r"?2:1))}if(r===-1){if(!this.atEnd)return this.setNext("quoted-scalar");r=this.buffer.length}return yield*this.pushToIndex(r+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let r=this.buffer[++e];if(r==="+")this.blockScalarKeep=!0;else if(r>"0"&&r<="9")this.blockScalarIndent=Number(r)-1;else if(r!=="-")break}return yield*this.pushUntil(r=>ye(r)||r==="#")}*parseBlockScalar(){let e=this.pos-1,r=0,n;e:for(let i=this.pos;n=this.buffer[i];++i)switch(n){case" ":r+=1;break;case`
126
+ `:e=i,r=0;break;case"\r":{let o=this.buffer[i+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
127
+ `)break}default:break e}if(!n&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=r:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let i=this.continueScalar(e+1);if(i===-1)break;e=this.buffer.indexOf(`
128
+ `,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let s=e+1;for(n=this.buffer[s];n===" ";)n=this.buffer[++s];if(n===" "){for(;n===" "||n===" "||n==="\r"||n===`
129
+ `;)n=this.buffer[++s];e=s-1}else if(!this.blockScalarKeep)do{let i=e-1,o=this.buffer[i];o==="\r"&&(o=this.buffer[--i]);let a=i;for(;o===" ";)o=this.buffer[--i];if(o===`
130
+ `&&i>=this.pos&&i+1+r>a)e=i;else break}while(!0);return yield qr.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,r=this.pos-1,n=this.pos-1,s;for(;s=this.buffer[++n];)if(s===":"){let i=this.buffer[n+1];if(ye(i)||e&&ds.has(i))break;r=n}else if(ye(s)){let i=this.buffer[n+1];if(s==="\r"&&(i===`
133
131
  `?(n+=1,s=`
134
- `,o=this.buffer[n+1]):r=n),o==="#"||e&&df.has(o))break;if(s===`
135
- `){let i=this.continueScalar(n+1);if(i===-1)break;n=Math.max(n,i-2)}}else{if(e&&df.has(s))break;r=n}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield pc.SCALAR,yield*this.pushToIndex(r+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,r){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(r&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Dy),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,n=this.charAt(1);if(xr(n)||r&&df.has(n)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,r=this.buffer[e];for(;!xr(r)&&r!==">";)r=this.buffer[++e];return yield*this.pushToIndex(r===">"?e+1:e,!1)}else{let e=this.pos+1,r=this.buffer[e];for(;r;)if(g3.has(r))r=this.buffer[++e];else if(r==="%"&&bO.has(this.buffer[e+1])&&bO.has(this.buffer[e+2]))r=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
132
+ `,i=this.buffer[n+1]):r=n),i==="#"||e&&ds.has(i))break;if(s===`
133
+ `){let o=this.continueScalar(n+1);if(o===-1)break;n=Math.max(n,o-2)}}else{if(e&&ds.has(s))break;r=n}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield qr.SCALAR,yield*this.pushToIndex(r+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,r){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(r&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(sa),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let r=this.flowLevel>0,n=this.charAt(1);if(ye(n)||r&&ds.has(n)){r?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,r=this.buffer[e];for(;!ye(r)&&r!==">";)r=this.buffer[++e];return yield*this.pushToIndex(r===">"?e+1:e,!1)}else{let e=this.pos+1,r=this.buffer[e];for(;r;)if(Bx.has(r))r=this.buffer[++e];else if(r==="%"&&Vd.has(this.buffer[e+1])&&Vd.has(this.buffer[e+2]))r=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
136
134
  `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
137
- `?yield*this.pushCount(2):0}*pushSpaces(e){let r=this.pos-1,n;do n=this.buffer[++r];while(n===" "||e&&n===" ");let s=r-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=r),s}*pushUntil(e){let r=this.pos,n=this.buffer[r];for(;!e(n);)n=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};SO.Lexer=qy});var Uy=_($O=>{"use strict";var Zy=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let r=0,n=this.lineStarts.length;for(;r<n;){let o=r+n>>1;this.lineStarts[o]<e?r=o+1:n=o}if(this.lineStarts[r]===e)return{line:r+1,col:1};if(r===0)return{line:0,col:e};let s=this.lineStarts[r-1];return{line:r,col:e-s+1}}}};$O.LineCounter=Zy});var By=_(PO=>{"use strict";var _3=je("process"),kO=uf(),v3=Fy();function Qn(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function xO(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function TO(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function ff(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function Jo(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function pf(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let r=0;r<e.length;++r)t.push(e[r])}function EO(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Qn(e.start,"explicit-key-ind")&&!Qn(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,TO(e.value)?e.value.end?pf(e.value.end,e.sep):e.value.end=e.sep:pf(e.start,e.sep),delete e.sep)}var Vy=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new v3.Lexer,this.onNewLine=e}*parse(e,r=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,r))yield*this.next(n);r||(yield*this.end())}*next(e){if(this.source=e,_3.env.LOG_TOKENS&&console.log("|",kO.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=kO.tokenType(e);if(r)if(r==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=r,yield*this.step(),r){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let n=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:n,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let r=e??this.stack.pop();if(!r)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield r;else{let n=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in n?n.indent:0:r.type==="flow-collection"&&n.type==="document"&&(r.indent=0),r.type==="flow-collection"&&EO(r),n.type){case"document":n.value=r;break;case"block-scalar":n.props.push(r);break;case"block-map":{let s=n.items[n.items.length-1];if(s.value){n.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(s.sep)s.value=r;else{Object.assign(s,{key:r,sep:[]}),this.onKeyLine=!s.explicitKey;return}break}case"block-seq":{let s=n.items[n.items.length-1];s.value?n.items.push({start:[],value:r}):s.value=r;break}case"flow-collection":{let s=n.items[n.items.length-1];!s||s.value?n.items.push({start:[],key:r,sep:[]}):s.sep?s.value=r:Object.assign(s,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((n.type==="document"||n.type==="block-map"||n.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){let s=r.items[r.items.length-1];s&&!s.sep&&!s.value&&s.start.length>0&&xO(s.start)===-1&&(r.indent===0||s.start.every(o=>o.type!=="comment"||o.indent<r.indent))&&(n.type==="document"?n.end=s.start:n.items.push({start:s.start}),r.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{xO(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let r=ff(this.peek(2)),n=Jo(r),s;e.end?(s=e.end,s.push(this.sourceToken),delete e.end):s=[this.sourceToken];let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
135
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let r=this.pos-1,n;do n=this.buffer[++r];while(n===" "||e&&n===" ");let s=r-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=r),s}*pushUntil(e){let r=this.pos,n=this.buffer[r];for(;!e(n);)n=this.buffer[++r];return yield*this.pushToIndex(r,!1)}};Gd.Lexer=ia});var la=x(Jd=>{"use strict";var aa=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let r=0,n=this.lineStarts.length;for(;r<n;){let i=r+n>>1;this.lineStarts[i]<e?r=i+1:n=i}if(this.lineStarts[r]===e)return{line:r+1,col:1};if(r===0)return{line:0,col:e};let s=this.lineStarts[r-1];return{line:r,col:e-s+1}}}};Jd.LineCounter=aa});var ua=x(Qd=>{"use strict";var Kx=B("process"),Hd=us(),Wx=oa();function Ze(t,e){for(let r=0;r<t.length;++r)if(t[r].type===e)return!0;return!1}function Yd(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Xd(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function fs(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function Bt(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function ps(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let r=0;r<e.length;++r)t.push(e[r])}function zd(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Ze(e.start,"explicit-key-ind")&&!Ze(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Xd(e.value)?e.value.end?ps(e.value.end,e.sep):e.value.end=e.sep:ps(e.start,e.sep),delete e.sep)}var ca=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Wx.Lexer,this.onNewLine=e}*parse(e,r=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,r))yield*this.next(n);r||(yield*this.end())}*next(e){if(this.source=e,Kx.env.LOG_TOKENS&&console.log("|",Hd.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=Hd.tokenType(e);if(r)if(r==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=r,yield*this.step(),r){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let n=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:n,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let r=e??this.stack.pop();if(!r)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield r;else{let n=this.peek(1);switch(r.type==="block-scalar"?r.indent="indent"in n?n.indent:0:r.type==="flow-collection"&&n.type==="document"&&(r.indent=0),r.type==="flow-collection"&&zd(r),n.type){case"document":n.value=r;break;case"block-scalar":n.props.push(r);break;case"block-map":{let s=n.items[n.items.length-1];if(s.value){n.items.push({start:[],key:r,sep:[]}),this.onKeyLine=!0;return}else if(s.sep)s.value=r;else{Object.assign(s,{key:r,sep:[]}),this.onKeyLine=!s.explicitKey;return}break}case"block-seq":{let s=n.items[n.items.length-1];s.value?n.items.push({start:[],value:r}):s.value=r;break}case"flow-collection":{let s=n.items[n.items.length-1];!s||s.value?n.items.push({start:[],key:r,sep:[]}):s.sep?s.value=r:Object.assign(s,{key:r,sep:[]});return}default:yield*this.pop(),yield*this.pop(r)}if((n.type==="document"||n.type==="block-map"||n.type==="block-seq")&&(r.type==="block-map"||r.type==="block-seq")){let s=r.items[r.items.length-1];s&&!s.sep&&!s.value&&s.start.length>0&&Yd(s.start)===-1&&(r.indent===0||s.start.every(i=>i.type!=="comment"||i.indent<r.indent))&&(n.type==="document"?n.end=s.start:n.items.push({start:s.start}),r.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{Yd(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let r=fs(this.peek(2)),n=Bt(r),s;e.end?(s=e.end,s.push(this.sourceToken),delete e.end):s=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let r=this.source.indexOf(`
138
136
  `)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
139
- `,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){pf(s,r.start),s.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,s=n&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",o=[];if(s&&r.sep&&!r.value){let i=[];for(let a=0;a<r.sep.length;++a){let c=r.sep[a];switch(c.type){case"newline":i.push(a);break;case"space":break;case"comment":c.indent>e.indent&&(i.length=0);break;default:i.length=0}}i.length>=2&&(o=r.sep.splice(i[1]))}switch(this.type){case"anchor":case"tag":s||r.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):s||r.value?(o.push(this.sourceToken),e.items.push({start:o,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Qn(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(TO(r.key)&&!Qn(r.sep,"newline")){let i=Jo(r.start),a=r.key,c=r.sep;c.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:a,sep:c}]})}else o.length>0?r.sep=r.sep.concat(o,this.sourceToken):r.sep.push(this.sourceToken);else if(Qn(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let i=Jo(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||s?e.items.push({start:o,key:null,sep:[this.sourceToken]}):Qn(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);s||r.value?(e.items.push({start:o,key:i,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(i):(Object.assign(r,{key:i,sep:[]}),this.onKeyLine=!0);return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!r.explicitKey&&r.sep&&!Qn(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else n&&e.items.push({start:o});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){pf(s,r.start),s.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=e.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;r.value||Qn(r.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>e.indent){let n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let r=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?e.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);!r||r.value?e.items.push({start:[],key:s,sep:[]}):r.sep?this.stack.push(s):Object.assign(r,{key:s,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let s=ff(n),o=Jo(s);EO(e);let i=e.end.splice(1,e.end.length);i.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:o,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let r=this.source.indexOf(`
137
+ `,r)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else if(r.sep)r.sep.push(this.sourceToken);else{if(this.atIndentedComment(r.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){ps(s,r.start),s.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,s=n&&(r.sep||r.explicitKey)&&this.type!=="seq-item-ind",i=[];if(s&&r.sep&&!r.value){let o=[];for(let a=0;a<r.sep.length;++a){let l=r.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(i=r.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":s||r.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"explicit-key-ind":!r.sep&&!r.explicitKey?(r.start.push(this.sourceToken),r.explicitKey=!0):s||r.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(r.explicitKey)if(r.sep)if(r.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ze(r.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Xd(r.key)&&!Ze(r.sep,"newline")){let o=Bt(r.start),a=r.key,l=r.sep;l.push(this.sourceToken),delete r.key,delete r.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else i.length>0?r.sep=r.sep.concat(i,this.sourceToken):r.sep.push(this.sourceToken);else if(Ze(r.start,"newline"))Object.assign(r,{key:null,sep:[this.sourceToken]});else{let o=Bt(r.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else r.sep?r.value||s?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Ze(r.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);s||r.value?(e.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0):r.sep?this.stack.push(o):(Object.assign(r,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!r.explicitKey&&r.sep&&!Ze(r.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let r=e.items[e.items.length-1];switch(this.type){case"newline":if(r.value){let n="end"in r.value?r.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment"?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else r.start.push(this.sourceToken);return;case"space":case"comment":if(r.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(r.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){ps(s,r.start),s.push(this.sourceToken),e.items.pop();return}}r.start.push(this.sourceToken)}return;case"anchor":case"tag":if(r.value||this.indent<=e.indent)break;r.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;r.value||Ze(r.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return}if(this.indent>e.indent){let n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let r=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!r||r.sep?e.items.push({start:[this.sourceToken]}):r.start.push(this.sourceToken);return;case"map-value-ind":!r||r.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):Object.assign(r,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!r||r.value?e.items.push({start:[this.sourceToken]}):r.sep?r.sep.push(this.sourceToken):r.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);!r||r.value?e.items.push({start:[],key:s,sep:[]}):r.sep?this.stack.push(s):Object.assign(r,{key:s,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let s=fs(n),i=Bt(s);zd(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let r=this.source.indexOf(`
140
138
  `)+1;for(;r!==0;)this.onNewLine(this.offset+r),r=this.source.indexOf(`
141
- `,r)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=ff(e),n=Jo(r);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=ff(e),n=Jo(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,r){return this.type!=="comment"||this.indent<=r?!1:e.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};PO.Parser=Vy});var RO=_(mc=>{"use strict";var OO=Ny(),w3=ic(),hc=lc(),b3=Og(),S3=pe(),$3=Uy(),IO=By();function NO(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new $3.LineCounter||null,prettyErrors:e}}function k3(t,e={}){let{lineCounter:r,prettyErrors:n}=NO(e),s=new IO.Parser(r?.addNewLine),o=new OO.Composer(e),i=Array.from(o.compose(s.parse(t)));if(n&&r)for(let a of i)a.errors.forEach(hc.prettifyError(t,r)),a.warnings.forEach(hc.prettifyError(t,r));return i.length>0?i:Object.assign([],{empty:!0},o.streamInfo())}function CO(t,e={}){let{lineCounter:r,prettyErrors:n}=NO(e),s=new IO.Parser(r?.addNewLine),o=new OO.Composer(e),i=null;for(let a of o.compose(s.parse(t),!0,t.length))if(!i)i=a;else if(i.options.logLevel!=="silent"){i.errors.push(new hc.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&r&&(i.errors.forEach(hc.prettifyError(t,r)),i.warnings.forEach(hc.prettifyError(t,r))),i}function x3(t,e,r){let n;typeof e=="function"?n=e:r===void 0&&e&&typeof e=="object"&&(r=e);let s=CO(t,r);if(!s)return null;if(s.warnings.forEach(o=>b3.warn(s.options.logLevel,o)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:n},r))}function E3(t,e,r){let n=null;if(typeof e=="function"||Array.isArray(e)?n=e:r===void 0&&e&&(r=e),typeof r=="string"&&(r=r.length),typeof r=="number"){let s=Math.round(r);r=s<1?void 0:s>8?{indent:8}:{indent:s}}if(t===void 0){let{keepUndefined:s}=r??e??{};if(!s)return}return S3.isDocument(t)&&!n?t.toString(r):new w3.Document(t,n,r).toString(r)}mc.parse=x3;mc.parseAllDocuments=k3;mc.parseDocument=CO;mc.stringify=E3});var Er=_(Se=>{"use strict";var T3=Ny(),P3=ic(),O3=dy(),Ky=lc(),I3=Va(),es=pe(),N3=Jn(),C3=Xe(),R3=Yn(),A3=Xn(),z3=uf(),j3=Fy(),M3=Uy(),L3=By(),hf=RO(),AO=qa();Se.Composer=T3.Composer;Se.Document=P3.Document;Se.Schema=O3.Schema;Se.YAMLError=Ky.YAMLError;Se.YAMLParseError=Ky.YAMLParseError;Se.YAMLWarning=Ky.YAMLWarning;Se.Alias=I3.Alias;Se.isAlias=es.isAlias;Se.isCollection=es.isCollection;Se.isDocument=es.isDocument;Se.isMap=es.isMap;Se.isNode=es.isNode;Se.isPair=es.isPair;Se.isScalar=es.isScalar;Se.isSeq=es.isSeq;Se.Pair=N3.Pair;Se.Scalar=C3.Scalar;Se.YAMLMap=R3.YAMLMap;Se.YAMLSeq=A3.YAMLSeq;Se.CST=z3;Se.Lexer=j3.Lexer;Se.LineCounter=M3.LineCounter;Se.Parser=L3.Parser;Se.parse=hf.parse;Se.parseAllDocuments=hf.parseAllDocuments;Se.parseDocument=hf.parseDocument;Se.stringify=hf.stringify;Se.visit=AO.visit;Se.visitAsync=AO.visitAsync});var LO={};Je(LO,{PROJECT_MANIFEST_FILE:()=>xe,buildManifestPayload:()=>Wy,createProjectId:()=>Hy,findProjectRoot:()=>Qe,readProjectId:()=>Zs,renderManifest:()=>Jy});import{randomUUID as D3}from"node:crypto";import{readFileSync as zO}from"node:fs";import{dirname as q3,join as jO,resolve as F3}from"node:path";var mf,xe,MO,Z3,U3,Hy,Wy,Jy,Qe,Zs,ut=$(()=>{"use strict";mf=Ze(Er(),1),xe="pix3project.yaml",MO="projectId",Z3="1.0.0",U3=t=>{switch(t){case"mobile":return{antialias:!1,shadows:!1,maxPixelRatio:2};case"desktop":return{antialias:!0,shadows:!0,maxPixelRatio:3};case"universal":return{antialias:!0,shadows:!0,maxPixelRatio:2}}},Hy=()=>D3(),Wy=(t,e)=>({version:Z3,defaultExportScenePath:t.entryScenePath,viewportBaseSize:{width:Math.max(64,t.viewport.width),height:Math.max(64,t.viewport.height)},ambientOcclusion:"baked",textureFiltering:"linear",projectType:t.projectType,targetPlatform:t.targetPlatform,quality:U3(t.targetPlatform),metadata:{projectName:e.projectName,templateId:t.id,[MO]:e.projectId},autoloads:[]}),Jy=t=>(0,mf.stringify)(t,{indent:2}),Qe=t=>{let e=F3(t);for(;;)try{return zO(jO(e,xe)),e}catch{let r=q3(e);if(r===e)return null;e=r}},Zs=t=>{try{let e=(0,mf.parse)(zO(jO(t,xe),"utf8"));if(!e||typeof e!="object")return null;let r=e,s=(r.metadata&&typeof r.metadata=="object"?r.metadata:{})[MO];return typeof s=="string"&&s.trim()?s.trim():typeof r.id=="string"&&r.id.trim()?r.id.trim():null}catch{return null}}});import{existsSync as V3,readFileSync as B3}from"node:fs";import{dirname as Gy,join as DO}from"node:path";import{fileURLToPath as K3}from"node:url";var H3,W3,gf,Wt,J3,yf,Us=$(()=>{"use strict";H3="@pix3/cli",W3=t=>{try{return JSON.parse(B3(t,"utf8")).name===H3}catch{return!1}},Wt=()=>{if(gf!==void 0)return gf;let t=Gy(K3(import.meta.url)),e=t;for(;;){let r=DO(e,"package.json");if(V3(r)&&W3(r))return gf=e;let n=Gy(e);if(n===e)break;e=n}return gf=Gy(t)},J3=()=>import.meta.url.endsWith(".ts"),yf=t=>J3()?null:DO(Wt(),"dist",t,"prebuilt")});import{readFileSync as G3}from"node:fs";import{join as Y3}from"node:path";var X3,be,ar=$(()=>{"use strict";Us();X3=()=>{try{let t=G3(Y3(Wt(),"package.json"),"utf8"),e=JSON.parse(t);return typeof e.version=="string"?e.version:"0.0.0"}catch{return"0.0.0"}},be=X3()});var HO={};Je(HO,{MCP_CONFIG_FILE:()=>_n,isDevCheckout:()=>BO,mcpConfigStep:()=>Xy,mcpLaunch:()=>Go,renderMcpConfig:()=>_f,setupInstructions:()=>rK,writeMcpConfig:()=>KO});import{existsSync as Yy,readFileSync as Q3,writeFileSync as eK}from"node:fs";import{dirname as qO,join as UO}from"node:path";import{fileURLToPath as tK}from"node:url";var _n,VO,BO,Go,_f,KO,Xy,FO,ZO,rK,vf=$(()=>{"use strict";ar();_n=".mcp.json",VO=()=>{try{return tK(new URL("./index.ts",import.meta.url))}catch{return null}},BO=()=>{if(process.env.PIX3_CLI_DEV==="1")return!0;if(process.env.PIX3_CLI_DEV==="0")return!1;let t=VO();if(!t)return!1;let e=qO(qO(t));return Yy(t)&&import.meta.url.endsWith(".ts")&&Yy(UO(e,"..","pix3-runtime","package.json"))},Go=(t={})=>{let e=t.dev??BO(),r=["mcp","--workspace",...t.projectDir?["--project",t.projectDir]:[]],n=e?VO():null;return n?{command:"node",args:[n,...r]}:{command:"npx",args:["-y",`@pix3/cli@${be}`,...r]}},_f=(t,e)=>{let r={};if(e)try{let s=JSON.parse(e);s&&typeof s=="object"&&!Array.isArray(s)&&(r=s)}catch{r={}}let n=r.mcpServers&&typeof r.mcpServers=="object"&&!Array.isArray(r.mcpServers)?r.mcpServers:{};return JSON.stringify({...r,mcpServers:{...n,pix3:{command:t.command,args:t.args}}},null,2)+`
142
- `},KO=(t,e={})=>{let r=UO(t,_n),n=Yy(r)?Q3(r,"utf8"):void 0;return eK(r,_f(Go({dev:e.dev}),n)),_n},Xy=(t={})=>e=>[KO(e.dir,t)],FO=t=>/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`,ZO=t=>JSON.stringify(t),rK=(t,e,r={})=>{let n=[];if(t===null||t==="claude"){let s=Go({dev:r.dev});n.push("Claude Code \u2014 run inside the project folder:","",` cd ${FO(e)}`,` claude mcp add pix3 -- ${[s.command,...s.args].map(FO).join(" ")}`,"",` (or commit the project's ${_n}; \`pix3 new\` writes one.)`,"")}if(t===null||t==="codex"){let s=Go({dev:r.dev,projectDir:e});n.push("Codex \u2014 add to ~/.codex/config.toml:",""," [mcp_servers.pix3]",` command = ${ZO(s.command)}`,` args = [${s.args.map(ZO).join(", ")}]`," # game_run can take longer than the default tool timeout"," tool_timeout_sec = 180","")}return n.push("Then start `pix3 serve` in the project, connect the Pix3 editor to it (File \u2192 Connect to","Workspace\u2026), and start the agent in the project folder.",""),n.join(`
143
- `)}});var kf={};Je(kf,{RUNTIME_TYPES_FORMAT:()=>Vs,buildRuntimeTypes:()=>dI,ensureRuntimeTypes:()=>NK,expandRuntimeTypes:()=>fI,packRuntimeTypes:()=>OK,readRuntimeTypesManifest:()=>wc,repoRuntimePackage:()=>Qo,runtimeSourceStamp:()=>bc,runtimeTypesArchive:()=>$f,runtimeTypesDir:()=>Xo});import{spawnSync as SK}from"node:child_process";import{createHash as $K}from"node:crypto";import{cpSync as r_,existsSync as n_,mkdirSync as wf,mkdtempSync as kK,readdirSync as aI,readFileSync as Sf,renameSync as xK,rmSync as yc,statSync as EK,writeFileSync as _c}from"node:fs";import{createRequire as cI}from"node:module";import{tmpdir as lI}from"node:os";import{dirname as vc,join as Pe,relative as uI,sep as TK}from"node:path";var Vs,bf,Xo,$f,Qo,s_,wc,o_,bc,PK,dI,OK,IK,fI,NK,Sc=$(()=>{"use strict";Us();ar();Vs=1,bf=()=>Wt(),Xo=()=>Pe(bf(),"runtime-types"),$f=()=>Pe(bf(),"dist","runtime-types.json"),Qo=()=>{let t=Pe(bf(),"..","pix3-runtime");return n_(Pe(t,"tsconfig.types.json"))&&n_(Pe(bf(),"scripts","build-runtime-types.mjs"))?t:null},s_=t=>{try{return JSON.parse(Sf(t,"utf8"))}catch{return null}},wc=(t=Xo())=>s_(Pe(t,"manifest.json")),o_=(t,e=[])=>{for(let r of aI(t,{withFileTypes:!0})){let n=Pe(t,r.name);r.isDirectory()?o_(n,e):r.isFile()&&e.push(n)}return e},bc=t=>{let e=$K("sha256");e.update(`${be}
144
- `);for(let n of["tsconfig.json","tsconfig.types.json","package.json"])e.update(Sf(Pe(t,n)));let r=o_(Pe(t,"src")).filter(n=>n.endsWith(".ts")&&!n.endsWith(".spec.ts")).sort();for(let n of r){let s=EK(n);e.update(`${uI(t,n)}:${s.size}:${Math.trunc(s.mtimeMs)}
145
- `)}return e.digest("hex")},PK=t=>{let e=cI(Pe(t,"package.json"));return vc(e.resolve("@types/three/package.json"))},dI=(t={})=>{let e=Qo();if(!e)throw new Error("runtime types can only be built from a checkout of the pix3 repo");let r=t.outDir??Xo(),n=cI(import.meta.url),s=Pe(vc(n.resolve("typescript/package.json")),"bin","tsc"),o=kK(Pe(lI(),"pix3-runtime-types-"));try{let i=Pe(o,"emit"),a=SK(process.execPath,[s,"-p",Pe(e,"tsconfig.types.json"),"--outDir",i],{encoding:"utf8"});if(a.status!==0)throw new Error(`tsc -p packages/pix3-runtime/tsconfig.types.json failed:
146
- ${a.stdout}${a.stderr}`);let c=s_(Pe(e,"package.json"))?.version??"0.0.0",l=PK(e),u=s_(Pe(l,"package.json"))?.version??"0.0.0",d=Pe(o,"out"),f=Pe(d,"@pix3","runtime");r_(i,f,{recursive:!0}),_c(Pe(f,"package.json"),`${JSON.stringify({name:"@pix3/runtime",version:c,types:"index.d.ts"},null,2)}
147
- `);let p=Pe(d,"@types","three");wf(p,{recursive:!0});for(let h of aI(l))h!=="node_modules"&&r_(Pe(l,h),Pe(p,h),{recursive:!0});let m={format:Vs,cliVersion:be,runtimeVersion:c,threeTypesVersion:u,sourceStamp:bc(e),builtAt:new Date().toISOString()};return _c(Pe(d,"manifest.json"),`${JSON.stringify(m,null,2)}
148
- `),yc(r,{recursive:!0,force:!0}),wf(vc(r),{recursive:!0}),r_(d,r,{recursive:!0}),t.log?.(`runtime types ${c} (+ @types/three ${u}) -> ${r}`),m}finally{yc(o,{recursive:!0,force:!0})}},OK=(t=Xo(),e=$f())=>{let r=wc(t);if(!r)throw new Error(`${t} has no manifest.json: build the runtime types first`);let n=o_(t).map(i=>uI(t,i).split(TK).join("/")).filter(i=>i!=="manifest.json").sort().map(i=>{let a=Sf(Pe(t,i)),c=a.toString("utf8");if(!Buffer.from(c,"utf8").equals(a))throw new Error(`runtime types: ${i} is not UTF-8 text and cannot be archived`);return[i,c]}),o=JSON.stringify({format:Vs,manifest:r,files:n});return wf(vc(e),{recursive:!0}),_c(e,o),{files:n.length,bytes:Buffer.byteLength(o)}},IK=(t,e)=>{let r=`${e}.tmp-${process.pid}-${Date.now()}`;yc(r,{recursive:!0,force:!0});try{for(let[n,s]of t.files){let o=Pe(r,...n.split("/"));wf(vc(o),{recursive:!0}),_c(o,s)}_c(Pe(r,"manifest.json"),`${JSON.stringify(t.manifest,null,2)}
149
- `),yc(e,{recursive:!0,force:!0}),xK(r,e)}catch(n){if(yc(r,{recursive:!0,force:!0}),wc(e)?.sourceStamp===t.manifest.sourceStamp)return;throw n}},fI=(t=$f(),e=Xo())=>{if(!n_(t))return null;let r=JSON.parse(Sf(t,"utf8"));if(r.format!==Vs)throw new Error(`${t}: runtime types archive format ${r.format}, expected ${Vs}`);let n=Pe(lI(),`pix3-cli-runtime-types-${r.manifest.cliVersion}-${r.manifest.sourceStamp.slice(0,12)}`);for(let s of[e,n]){if(wc(s)?.sourceStamp===r.manifest.sourceStamp)return{dir:s,manifest:r.manifest};try{return IK(r,s),{dir:s,manifest:r.manifest}}catch(o){if(s===n)throw o}}return null},NK=(t={})=>{let e=Xo(),r=Qo(),n=wc(e);if(r)return n&&n.format===Vs&&n.sourceStamp===bc(r)?{dir:e,manifest:n}:(t.log?.("Building the @pix3/runtime type declarations from the repo sources\u2026"),{dir:e,manifest:dI({log:t.log})});if(n?.format===Vs&&n.cliVersion===be)return{dir:e,manifest:n};let s=fI();if(s)return s;if(!n)throw new Error(`${$f()} is missing: this @pix3/cli package was published without its runtime types.`);return{dir:e,manifest:n}}});var a_,c_,xf,mI,$c,CK,RK,AK,pI,zK,i_,hI,Ef,l_=$(()=>{"use strict";a_=new Set(["play_start","play_restart","game_run"]),c_=new Set(["play_status","game_input","game_observe","viewport_screenshot","read_errors","read_logs"]),xf=["project_status","play_start","play_stop","play_restart","play_status","game_run","game_input","game_observe","read_errors","read_logs","viewport_screenshot","generate_asset","generate_sfx","get_selection"],mI=["disk_differs_from_agent","expectation_stale","sync_timeout","load_failed","pending_external","no_editor","permission_denied","no_workspace_server"],$c={type:"object",properties:{},additionalProperties:!1},CK={type:"object",description:'sha256 (lowercase hex of the RAW BYTES) of every project file you wrote since your last run, keyed by project-relative path, e.g. {"scenes/main.pix3scene": "ab12\u2026"}. The run starts only if the disk holds exactly these versions (else `disk_differs_from_agent`, with a recovery copy when one exists). Omit only when you wrote nothing; the answer then says `agentExpectations: "none"`.',additionalProperties:{type:"string",pattern:"^[0-9a-f]{64}$"}},RK=" Runs through the sync barrier first: checks `expect` against the disk, stops play, makes the editor load the current files and verifies its hashes against the disk, then starts; the answer carries `revision` (compact: file count, digest, and only the entries that changed since this process's previous answer \u2014 `fullRevision: true` for the whole map), `startupMs`, `matchesAgent`, `matchesDisk` and `changedDuringRun`.",AK=" Does not stop or resync the game: the answer carries the `revision` the running game started from (compact, as on barrier answers; `fullRevision: true` for the whole map) and `stale: true` when the disk moved since (use play_restart to pick new files up).",pI={type:"boolean",description:"Answer with the whole `revision` map ({path: sha256} of every verified file) instead of the compact form (file count, digest, and only the entries that changed since the previous answer of this MCP process). Default false."},zK={project_status:{name:"project_status",description:"Whether a Pix3 editor window is connected to this project, what it has open, external versions it has not applied yet, unreadable files, merge conflicts and the latest merge-log entries (why a write of yours did not land as written).",inputSchema:$c},play_start:{name:"play_start",description:"Enter play mode. Without `scene` plays the active scene; `scene` (res:// or project-relative .pix3scene) plays that one.",inputSchema:{type:"object",properties:{scene:{type:"string",description:"Scene to play (optional)."},reload:{type:"boolean",description:"Re-read the scene from disk first."}},additionalProperties:!1}},play_stop:{name:"play_stop",description:"Exit play mode.",inputSchema:$c},play_restart:{name:"play_restart",description:"Restart play mode.",inputSchema:$c},play_status:{name:"play_status",description:"Whether the game is playing, and what the last frame drew (draw calls, visible meshes).",inputSchema:$c},game_run:{name:"game_run",description:"Run the game frame by frame until a predicate holds (`until`, OR), fails (`fail`) or a budget runs out, or run a stored routine from design/tests/routines (`routine`, `args`). Read `verdict` first. Starts play mode when it is not running.",inputSchema:{type:"object",properties:{until:{type:"array",items:{type:"object"}},fail:{type:"array",items:{type:"object"}},watch:{type:"array",items:{type:"string"}},maxFrames:{type:"integer"},maxWallMs:{type:"integer"},routine:{type:"string"},args:{type:"object"}},additionalProperties:!0}},game_input:{name:"game_input",description:"Send real input to the running game (steps: tap / key / keys / drag / hover / invoke / wait) and report the reaction; `observe` watches nodes over the window. Read `verdict` first.",inputSchema:{type:"object",properties:{steps:{type:"array",items:{type:"object"}},observe:{type:"array",items:{type:"string"}},expect:{type:"object"}},required:["steps"],additionalProperties:!0}},game_observe:{name:"game_observe",description:"Read live node state of the running game (by name or id) without sending input.",inputSchema:{type:"object",properties:{},additionalProperties:!0}},read_errors:{name:"read_errors",description:"Recent runtime errors captured in the editor (console.error, window errors, rejections), each with an epoch-ms `at`; `since` (epoch ms) returns only newer ones.",inputSchema:{type:"object",properties:{since:{type:"number"}},additionalProperties:!1}},read_logs:{name:"read_logs",description:"Recent editor log entries; `since` (epoch ms) returns only newer ones.",inputSchema:{type:"object",properties:{since:{type:"number"}},additionalProperties:!1}},viewport_screenshot:{name:"viewport_screenshot",description:'A screenshot as an image: the running game while playing, else the editor viewport. `frame: "all" | "selection" | "node"` (+ `nodeId`) aims the editor camera temporarily.',inputSchema:{type:"object",properties:{maxSize:{type:"integer"},source:{type:"string",enum:["auto","game","editor"]},frame:{type:"string",enum:["current","all","selection","node"]},nodeId:{type:"string"},isolate:{type:"boolean"},padding:{type:"number"},visualReason:{type:"string"}},additionalProperties:!1}},generate_asset:{name:"generate_asset",description:"Generate an image with the editor's configured image provider (the user's keys \u2014 the editor asks the user to allow this for the session), post-process it and save it into the project.",inputSchema:{type:"object",properties:{prompt:{type:"string"},name:{type:"string",description:'Target file, e.g. "sprites/car.png".'},transparent:{type:"boolean"},postProcess:{type:"string",enum:["sprite","icon","texture","none"]},width:{type:"integer"},height:{type:"integer"},providerId:{type:"string"}},required:["prompt","name"],additionalProperties:!0}},generate_sfx:{name:"generate_sfx",description:"Generate a prototype sound effect (WAV under res://sfx/) with the editor's LLM (asks the user to allow this for the session). Not for music, ambience or voice.",inputSchema:{type:"object",properties:{prompt:{type:"string"},name:{type:"string"},soundline:{type:"string"},feedback:{type:"string"},save:{type:"boolean"}},required:["prompt"],additionalProperties:!0}},get_selection:{name:"get_selection",description:"What the human has selected in the editor right now (node ids, primary, hovered).",inputSchema:$c}},i_=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:null,hI=(t,e)=>{let r=i_(t.properties)??{};return{...t,type:"object",properties:{...r,...e}}},Ef=t=>{let e=new Map;for(let r of t??[]){let n=i_(r);if(!n||typeof n.name!="string"||!xf.includes(n.name))continue;let s=i_(n.inputSchema);s&&e.set(n.name,{name:n.name,description:typeof n.description=="string"?n.description:"",inputSchema:s})}return xf.map(r=>{let n=e.get(r)??zK[r];return a_.has(r)?{name:r,description:n.description+RK,inputSchema:hI(n.inputSchema,{expect:CK,fullRevision:pI})}:c_.has(r)?{...n,description:n.description+AK,inputSchema:hI(n.inputSchema,{fullRevision:pI})}:n})}});var gI,Tf,yI=$(()=>{"use strict";gI="kit.json",Tf="files"});var _I=_(()=>{throw new Error("src/kit/generate.ts is only available in a checkout of the pix3 repo (the published @pix3/cli ships its bundles prebuilt)")});var vI=_(()=>{throw new Error("src/kit/core-components.ts is only available in a checkout of the pix3 repo (the published @pix3/cli ships its bundles prebuilt)")});var TI={};Je(TI,{buildKitFromCheckout:()=>EI,ensureKit:()=>f_,isKitCheckout:()=>SI,kitDir:()=>u_,kitInputsStamp:()=>d_,kitMcpErrorCodes:()=>xI,kitMcpTools:()=>kI,kitSrcDir:()=>Of,repoRootOfCheckout:()=>If});import{createHash as jK}from"node:crypto";import{existsSync as wI,readdirSync as MK,readFileSync as kc}from"node:fs";import{join as Rt,relative as LK,sep as DK}from"node:path";var Pf,u_,Of,If,SI,qK,$I,kI,xI,d_,FK,EI,f_,p_=$(()=>{"use strict";Us();Sc();ar();l_();yI();Pf=()=>Wt(),u_=()=>Rt(Pf(),"kit"),Of=()=>Rt(Pf(),"kit-src"),If=()=>Rt(Pf(),"..",".."),SI=()=>wI(Of())&&wI(Rt(If(),"docs","pix3-specification.md"))&&Qo()!==null,qK=/\{\{include:([^#@|}]+)/g,$I=(t,e=t)=>{let r=[];for(let n of MK(e,{withFileTypes:!0})){let s=Rt(e,n.name);n.isDirectory()?r.push(...$I(t,s)):n.isFile()&&r.push(LK(t,s).split(DK).join("/"))}return r.sort()},kI=()=>Ef(null).map(t=>({name:t.name,summary:t.description.split(/(?<=\.)\s/)[0]??t.description})),xI=()=>[...mI],d_=()=>{let t=jK("sha256");t.update(`${1}:${be}
150
- `);let e=Of(),r=If(),n=new Set;for(let i of $I(e)){let a=kc(Rt(e,i),"utf8");t.update(`${i}
151
- `).update(a);for(let c of a.matchAll(qK))n.add(c[1].trim())}for(let i of[...n].sort()){t.update(`${i}
152
- `);try{t.update(kc(Rt(r,i)))}catch{t.update("(missing)")}}let s=Rt(Pf(),"src","kit");for(let i of["generate.ts","kit-format.ts","core-components.ts","kit-source.ts"])t.update(kc(Rt(s,i)));t.update(kc(Rt(s,"..","workspace-agent","tools.ts")));let o=Qo();return o&&t.update(bc(o)),t.digest("hex")},FK=t=>{try{return JSON.parse(kc(Rt(t,gI),"utf8"))}catch{return null}},EI=async(t={})=>{let{generateKit:e}=await Promise.resolve().then(()=>Ze(_I(),1)),r=t.coreComponents??await(await Promise.resolve().then(()=>Ze(vI(),1))).loadCoreComponentsFromSource();return e({repoRoot:If(),kitSrcDir:Of(),outDir:t.outDir??u_(),version:be,coreComponents:r,mcpTools:kI(),mcpErrorCodes:xI(),inputsStamp:t.stamp??d_()})},f_=async(t={})=>{let e=u_(),r=FK(e);if(SI()){let n=d_();if(r&&r.format===1&&r.inputsStamp===n)return{dir:e,filesDir:Rt(e,Tf),manifest:r};t.log?.("Generating the agent kit from the repo sources\u2026");let s=await EI({stamp:n});return{dir:e,filesDir:Rt(e,Tf),manifest:s}}if(!r)throw new Error(`${e} is missing: this @pix3/cli package was published without its kit.`);return{dir:e,filesDir:Rt(e,Tf),manifest:r}}});import{cpSync as ZK,existsSync as OI,mkdirSync as UK,readFileSync as m_,rmSync as VK,writeFileSync as PI}from"node:fs";import{join as vn}from"node:path";var h_,Bs,rs,g_,II,ei,BK,Nf,Cf,Rf=$(()=>{"use strict";h_=".pix3/types",Bs=".pix3/tsconfig.check.json",rs="tsconfig.json",g_=`{ "extends": "./.pix3/tsconfig.check.json" }
153
- `,II=`// Written by @pix3/cli (pix3 kit / pix3 check); replaced when the CLI version changes.
139
+ `,r)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let r=fs(e),n=Bt(r);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let r=fs(e),n=Bt(r);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,r){return this.type!=="comment"||this.indent<=r?!1:e.every(n=>n.type==="newline"||n.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Qd.Parser=ca});var nf=x(Ur=>{"use strict";var Zd=zo(),Vx=Ir(),Br=Lr(),Gx=Ji(),Jx=$(),Hx=la(),ef=ua();function tf(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new Hx.LineCounter||null,prettyErrors:e}}function Yx(t,e={}){let{lineCounter:r,prettyErrors:n}=tf(e),s=new ef.Parser(r?.addNewLine),i=new Zd.Composer(e),o=Array.from(i.compose(s.parse(t)));if(n&&r)for(let a of o)a.errors.forEach(Br.prettifyError(t,r)),a.warnings.forEach(Br.prettifyError(t,r));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function rf(t,e={}){let{lineCounter:r,prettyErrors:n}=tf(e),s=new ef.Parser(r?.addNewLine),i=new Zd.Composer(e),o=null;for(let a of i.compose(s.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Br.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&r&&(o.errors.forEach(Br.prettifyError(t,r)),o.warnings.forEach(Br.prettifyError(t,r))),o}function zx(t,e,r){let n;typeof e=="function"?n=e:r===void 0&&e&&typeof e=="object"&&(r=e);let s=rf(t,r);if(!s)return null;if(s.warnings.forEach(i=>Gx.warn(s.options.logLevel,i)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:n},r))}function Xx(t,e,r){let n=null;if(typeof e=="function"||Array.isArray(e)?n=e:r===void 0&&e&&(r=e),typeof r=="string"&&(r=r.length),typeof r=="number"){let s=Math.round(r);r=s<1?void 0:s>8?{indent:8}:{indent:s}}if(t===void 0){let{keepUndefined:s}=r??e??{};if(!s)return}return Jx.isDocument(t)&&!n?t.toString(r):new Vx.Document(t,n,r).toString(r)}Ur.parse=zx;Ur.parseAllDocuments=Yx;Ur.parseDocument=rf;Ur.stringify=Xx});var ce=x(M=>{"use strict";var Qx=zo(),Zx=Ir(),ev=$o(),da=Lr(),tv=yr(),et=$(),rv=Ye(),nv=V(),sv=Xe(),iv=Qe(),ov=us(),av=oa(),lv=la(),cv=ua(),hs=nf(),sf=pr();M.Composer=Qx.Composer;M.Document=Zx.Document;M.Schema=ev.Schema;M.YAMLError=da.YAMLError;M.YAMLParseError=da.YAMLParseError;M.YAMLWarning=da.YAMLWarning;M.Alias=tv.Alias;M.isAlias=et.isAlias;M.isCollection=et.isCollection;M.isDocument=et.isDocument;M.isMap=et.isMap;M.isNode=et.isNode;M.isPair=et.isPair;M.isScalar=et.isScalar;M.isSeq=et.isSeq;M.Pair=rv.Pair;M.Scalar=nv.Scalar;M.YAMLMap=sv.YAMLMap;M.YAMLSeq=iv.YAMLSeq;M.CST=ov;M.Lexer=av.Lexer;M.LineCounter=lv.LineCounter;M.Parser=cv.Parser;M.parse=hs.parse;M.parseAllDocuments=hs.parseAllDocuments;M.parseDocument=hs.parseDocument;M.stringify=hs.stringify;M.visit=sf.visit;M.visitAsync=sf.visitAsync});import{createHash as uv}from"node:crypto";import{chmodSync as dv,existsSync as fv,mkdirSync as pv,readFileSync as hv,renameSync as mv,statSync as gv,writeFileSync as yv}from"node:fs";import{dirname as fa,join as Sv,resolve as bv}from"node:path";var W,Q,Se,St,ms,tt,se=O(()=>{"use strict";W=t=>{try{return hv(t,"utf8")}catch{return null}},Q=(t,e,r={})=>{pv(fa(t),{recursive:!0});let n=`${t}.${process.pid}.tmp`;yv(n,e,r.mode===void 0?void 0:{mode:r.mode}),mv(n,t)},Se=t=>uv("sha256").update(t).digest("hex"),St=t=>{if(process.platform!=="win32")try{(gv(t).mode&63)!==0&&dv(t,384)}catch{}},ms=(t,e)=>(W(t)??"").trimEnd().split(`
140
+ `).slice(-e).join(`
141
+ `),tt=(t,e)=>{for(let r=bv(t);;r=fa(r)){let n=Sv(r,e);if(fv(n))return n;if(fa(r)===r)return null}}});import{randomUUID as wv}from"node:crypto";import{existsSync as xv}from"node:fs";import{dirname as vv,join as of,resolve as _v}from"node:path";var gs,K,Ev,kv,Cv,af,lf,cf,rt,ue,ys,Z=O(()=>{"use strict";gs=U(ce(),1);se();K="pix3project.yaml",Ev="projectId",kv="1.0.0",Cv=t=>{switch(t){case"mobile":return{antialias:!1,shadows:!1,maxPixelRatio:2};case"desktop":return{antialias:!0,shadows:!0,maxPixelRatio:3};case"universal":return{antialias:!0,shadows:!0,maxPixelRatio:2}}},af=()=>wv(),lf=(t,e)=>({version:kv,defaultExportScenePath:t.entryScenePath,viewportBaseSize:{width:Math.max(64,t.viewport.width),height:Math.max(64,t.viewport.height)},ambientOcclusion:"baked",textureFiltering:"linear",projectType:t.projectType,targetPlatform:t.targetPlatform,quality:Cv(t.targetPlatform),metadata:{projectName:e.projectName,templateId:t.id,[Ev]:e.projectId},autoloads:[]}),cf=t=>(0,gs.stringify)(t,{indent:2}),rt=t=>{let e=tt(t,K);return e===null?null:vv(e)},ue=(t,e)=>{let r=_v(t,e??"."),n=e?r:rt(r);return n&&xv(of(n,K))?{root:n}:{error:`no ${K} in ${r}${e?"":" or any parent folder"}. Run it inside a Pix3 project, or pass --project <dir>.`}},ys=t=>{let e=W(of(t,K));if(e===null)return null;try{let n=(0,gs.parse)(e)?.metadata?.agentKit?.version;return typeof n=="string"?n:null}catch{return null}}});import{existsSync as uf,mkdtempSync as Ov,readFileSync as Tv,rmSync as Pv}from"node:fs";import{tmpdir as $v}from"node:os";import{dirname as pa,join as bs}from"node:path";import{fileURLToPath as Nv}from"node:url";var Av,Iv,Ss,ie,Rv,ws,xs,Ie=O(()=>{"use strict";Av="@pix3/cli",Iv=t=>{try{return JSON.parse(Tv(t,"utf8")).name===Av}catch{return!1}},ie=()=>{if(Ss!==void 0)return Ss;let t=pa(Nv(import.meta.url)),e=t;for(;;){let r=bs(e,"package.json");if(uf(r)&&Iv(r))return Ss=e;let n=pa(e);if(n===e)break;e=n}return Ss=pa(t)},Rv=()=>import.meta.url.endsWith(".ts"),ws=async(t,e,r,n)=>{let s=Rv()?null:bs(ie(),"dist",t,"prebuilt");if(s&&uf(bs(s,e)))return n(s);let i=Ov(bs($v(),`pix3-${t}-bundle-`));try{return await r(i),await n(i)}finally{Pv(i,{recursive:!0,force:!0})}},xs=()=>{try{return import.meta.resolve("esbuild")}catch{return}}});import{readFileSync as Mv}from"node:fs";import{join as Lv}from"node:path";var jv,F,Re=O(()=>{"use strict";Ie();jv=()=>{try{let t=Mv(Lv(ie(),"package.json"),"utf8"),e=JSON.parse(t);return typeof e.version=="string"?e.version:"0.0.0"}catch{return"0.0.0"}},F=jv()});var Wt,Kt,s_,i_,ga,ya,o_,a_,l_,kf,Cf,Of,Me,c_,Oe,u_,Tf,Pf,Sa=O(()=>{"use strict";Wt=["coin","jump","hit","explosion","powerup","click"],Kt={wave:"square",freq:440,freqEnd:440,slide:0,arpAt:0,arpMul:1,vibratoDepth:0,vibratoHz:0,duty:.5,attack:.002,decay:.05,sustainLevel:.6,sustain:.05,release:.1,lowpassHz:0,lowpassQ:.707,volume:.8},s_={coin:{...Kt,freq:988,freqEnd:988,arpAt:.07,arpMul:4/3,duty:.5,decay:.02,sustainLevel:.7,sustain:.1,release:.18,volume:.7},jump:{...Kt,freq:260,freqEnd:720,slide:.16,duty:.35,decay:.04,sustainLevel:.6,sustain:.06,release:.1,lowpassHz:5e3,volume:.7},hit:{...Kt,wave:"noise",freq:1400,freqEnd:180,slide:.12,attack:.001,decay:.05,sustainLevel:.3,sustain:.02,release:.08,lowpassHz:3200,lowpassQ:1.2,volume:.85},explosion:{...Kt,wave:"noise",freq:520,freqEnd:40,slide:.7,attack:.002,decay:.12,sustainLevel:.55,sustain:.15,release:.5,lowpassHz:1400,lowpassQ:1,volume:.9},powerup:{...Kt,wave:"saw",freq:330,freqEnd:1320,slide:.38,vibratoDepth:.04,vibratoHz:14,attack:.005,decay:.05,sustainLevel:.7,sustain:.25,release:.15,lowpassHz:6e3,volume:.65},click:{...Kt,wave:"square",freq:1800,freqEnd:1200,slide:.02,duty:.25,attack:5e-4,decay:.012,sustainLevel:0,sustain:0,release:.012,lowpassHz:8e3,volume:.6}},i_={coin:["coin","pickup","pick up","collect","gem","ding","bling","money","score","reward"],jump:["jump","hop","leap","spring","bounce","boing"],hit:["hit","hurt","damage","punch","impact","thud","smack","crash","kick","slap"],explosion:["explosion","explode","boom","blast","bomb","kaboom","explod","detonat"],powerup:["powerup","power-up","power up","level up","upgrade","bonus","charge","magic"],click:["click","tap","button","ui","menu","select","tick","toggle","blip"]},ga=(t,e)=>({...t,freq:t.freq*e,freqEnd:t.freqEnd*e}),ya=(t,e)=>({...t,slide:t.slide*e,arpAt:t.arpAt*e,decay:t.decay*e,sustain:t.sustain*e,release:t.release*e}),o_=[{words:["high","bright","tiny","small","light"],apply:t=>ga(t,1.4)},{words:["low","deep","big","heavy","huge"],apply:t=>ga(t,.7)},{words:["short","quick","snappy","fast"],apply:t=>ya(t,.65)},{words:["long","slow"],apply:t=>ya(t,1.6)},{words:["soft","quiet"],apply:t=>({...t,volume:t.volume*.6})}],a_=t=>t.toLowerCase().split(/[^a-z-]+/).filter(Boolean),l_=(t,e)=>{let r=e.split(" ");for(let n=0;n+r.length<=t.length;n++)if(r.every((i,o)=>{let a=t[n+o];return a===i||i.length>=5&&a.startsWith(i)}))return n;return-1},kf=t=>{let e=a_(t),r=Wt.find(o=>t.trim().toLowerCase()===o),n=r;if(!n){let o=-1;for(let a of Wt)for(let l of[a,...i_[a]]){let c=l_(e,l);c>=0&&(o<0||c<o)&&(o=c,n=a)}}if(!n)return null;let s=s_[n],i=[];if(!r)for(let o of o_){let a=o.words.find(l=>e.includes(l));a&&(s=o.apply(s),i.push(a))}return{preset:n,params:s,modifiers:i}},Cf=t=>{let e=t>>>0;return()=>{e=e+1831565813>>>0;let r=e;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}},Of=(t,e)=>{let r=Cf(e^2654435769),n=o=>1+(r()*2-1)*o,s=n(.15),i=n(.2);return{...ya(ga(t,s),i),freqEnd:t.freqEnd*s*n(.08),duty:Math.min(.9,Math.max(.1,t.duty*n(.25))),vibratoDepth:t.vibratoDepth*n(.3),vibratoHz:t.vibratoHz*n(.2),lowpassHz:t.lowpassHz>0?t.lowpassHz*n(.25):0}},Me=44100,c_=t=>t.attack+t.decay+t.sustain+t.release,Oe=(t,e,r)=>Math.min(r,Math.max(e,Number.isFinite(t)?t:e)),u_=(t,e)=>{if(e<t.attack)return e/t.attack;let r=e-t.attack;return r<t.decay?1-(1-t.sustainLevel)*(r/t.decay):(r-=t.decay,r<t.sustain?t.sustainLevel:(r-=t.sustain,r<t.release?t.sustainLevel*(1-r/t.release)**2:0))},Tf=(t,e=1)=>{let r={...t,freq:Oe(t.freq,10,2e4),freqEnd:Oe(t.freqEnd,10,2e4),attack:Oe(t.attack,5e-4,5),decay:Oe(t.decay,0,5),sustain:Oe(t.sustain,0,5),release:Oe(t.release,.002,5),sustainLevel:Oe(t.sustainLevel,0,1),duty:Oe(t.duty,.05,.95),volume:Oe(t.volume,0,1),lowpassQ:Oe(t.lowpassQ,.5,8)},n=c_(r),s=Math.max(1,Math.round(n*Me)),i=new Float32Array(s),o=Cf(e),a=r.slide>0?r.slide:n,l=r.freqEnd/r.freq,c=r.lowpassHz>0&&r.lowpassHz<Me/2,u=1,f=0,d=0,h=0,g=0;if(c){let C=2*Math.PI*r.lowpassHz/Me,R=Math.sin(C)/(2*r.lowpassQ),A=Math.cos(C),D=1+R;u=(1-A)/2/D,f=(1-A)/D,d=u,h=-2*A/D,g=(1-R)/D}let p=0,m=0,y=0,w=0,_=0,v=0,E=0,k=o()*2-1,T=0;for(let C=0;C<s;C++){let R=C/Me,A=r.freq*l**Math.min(1,R/a);r.arpAt>0&&R>=r.arpAt&&(A*=r.arpMul),r.vibratoDepth>0&&(A*=1+r.vibratoDepth*Math.sin(2*Math.PI*r.vibratoHz*R)),E+=A/Me;let D;switch(r.wave){case"square":D=E%1<r.duty?1:-1;break;case"saw":D=2*(E%1)-1;break;case"sine":D=Math.sin(2*Math.PI*E);break;case"triangle":D=1-4*Math.abs(E%1-.5);break;case"noise":{let Ee=Math.floor(E*16);Ee!==T&&(T=Ee,k=o()*2-1),D=k;break}}if(D*=u_(r,R),c){let Ee=u*D+f*p+d*m-h*y-g*w;m=p,p=D,w=y,y=Ee,D=Ee}v=D-_+.995*v,_=D,i[C]=v}let S=Math.min(s,Math.round(.003*Me));for(let C=0;C<S;C++)i[s-1-C]*=C/S;let b=0;for(let C of i)b=Math.max(b,Math.abs(C));if(b>0){let C=r.volume/b;for(let R=0;R<s;R++)i[R]*=C}return i},Pf=(t,e=Me)=>{let r=t.length*2,n=new ArrayBuffer(44+r),s=new DataView(n),i=(o,a)=>{for(let l=0;l<a.length;l++)s.setUint8(o+l,a.charCodeAt(l))};i(0,"RIFF"),s.setUint32(4,36+r,!0),i(8,"WAVE"),i(12,"fmt "),s.setUint32(16,16,!0),s.setUint16(20,1,!0),s.setUint16(22,1,!0),s.setUint32(24,e,!0),s.setUint32(28,e*2,!0),s.setUint16(32,2,!0),s.setUint16(34,16,!0),i(36,"data"),s.setUint32(40,r,!0);for(let o=0;o<t.length;o++){let a=Math.max(-1,Math.min(1,t[o]));s.setInt16(44+o*2,Math.round(a<0?a*32768:a*32767),!0)}return new Uint8Array(n)}});var Wr,I,ba,de=O(()=>{"use strict";Sa();Re();Wr=`pix3 ${F}
142
+
143
+ Usage:
144
+ pix3 new List the starters (2d, 3d)
145
+ pix3 new <2d|3d> [dir] Create an empty project (dir defaults to pix3-<2d|3d>)
146
+ [--name <project name>]
147
+ pix3 editor [--project <dir>] Find (or start, detached) the project's Vite dev server
148
+ [--stop] [--chrome-only] from .pix3/dev.json and open the editor in Chrome, its
149
+ [--no-chrome] [--port <n>] CDP behind the token proxy ws://127.0.0.1:9333/pix3 (next
150
+ [--cdp-port <n>] free port when taken); --stop-chrome ends that Chrome.
151
+ [--headless] [--stop-chrome] Over SSH: prints what to run on your machine instead;
152
+ [--url <editor url>] there, --url opens a forwarded remote editor (no project)
153
+ [--ssh <host>] and prints the line that copies the token to <host>
154
+ pix3 agent-setup [claude|codex] Write the project's MCP config for chrome-devtools-mcp
155
+ [--repair] [--cdp-port <n>] (.mcp.json, .codex/config.toml, with the proxy token);
156
+ [--remote] --repair fixes an entry that drifted (version, port,
157
+ [--project <dir>] token, the P1 --browserUrl launch); --remote: the agent
158
+ is on an SSH host, Chrome on your machine (forwarded)
159
+ pix3 validate [paths\u2026] [--json] Strict scene check: schema, references, guards, then
160
+ [--no-hydrate] each scene loaded as the game loads it (exit 1 on errors)
161
+ pix3 check [--json] validate + TypeScript check of the scripts + version
162
+ [--no-hydrate] [--offline] check (exit 1 on errors)
163
+ [--project <dir>]
164
+ pix3 smoke [scene] [--json] Run the game headless in Node for N frames (no browser):
165
+ [--changed | --all] script throws with frame + stack, console errors, missing
166
+ [--frames N] [--timeout S] res:// (exit 1 on errors, 2 when it cannot run). No scene =
167
+ [--project <dir>] the scenes git changes reach, else every top-level scene
168
+ pix3 tree [scene] [--json] One line per node (type#id, pos, size, layout, components,
169
+ [--depth N] [--types A,B] prefab instances); no scene = project overview
170
+ [--props] [--project <dir>]
171
+ pix3 kit [--update] Install (or update) the agent kit: AGENTS.md, CLAUDE.md,
172
+ [--migrate] .claude/skills/pix3-*, script types; --migrate: a 1.x kit
173
+ [--project <dir>] \u2192 2.x (drops the pix3 mcp server, retired files, pix3Hybrid)
174
+ pix3 character-compile <spec> A 2D character from frame PNGs: <slug>.pix3anim with
175
+ [--dry-run] [--force] <variant>.<state> clips + a prefab with
176
+ [--json] [--project <dir>] core:CharacterVisual2D (refuses to overwrite)
177
+ pix3 sfx <preset|"text"> Synthesize a sound effect offline into a WAV (coin, jump,
178
+ [--out <file.wav>] hit, explosion, powerup, click; or "big explosion")
179
+ [--seed <n>] [--json]
180
+ pix3 gap "<what was missing>" Record a gap Pix3 had (you worked around it) in
181
+ [--kind capability|tool|node|doc|other] .pix3/gaps.jsonl;
182
+ [--detail <text>] [--context <text>] --list prints them
183
+ [--agent <name>] [--list] [--json] [--project <dir>]
184
+ pix3 help <command> That command's own usage (also pix3 <command> --help)
185
+ pix3 --version
186
+ `,I={new:`Usage: pix3 new [2d|3d] [dir] [--name <project name>]
187
+
188
+ Without a starter: list them. With one: create an empty Vite + @pix3/vite-plugin project in dir
189
+ (default pix3-<2d|3d>) with the agent kit (AGENTS.md, CLAUDE.md, .claude/skills/pix3-*, script
190
+ types). The same as npm create pix3.
191
+
192
+ --name name the project name (default: from the folder)
193
+ `,editor:`Usage: pix3 editor [--project <dir>] [--stop] [--stop-chrome] [--chrome-only] [--no-chrome]
194
+ [--headless] [--port <n>] [--cdp-port <n>] [--url <editor url>] [--ssh <host>]
195
+ [--remote-port <n>]
196
+
197
+ Find the project's Vite dev server (.pix3/dev.json), or start it detached, and open the editor
198
+ (/__pix3/) in a Chrome whose DevTools are reachable only through the token proxy
199
+ ws://127.0.0.1:9333/pix3 (the next free port up to 9339 when that one is taken). Idempotent.
200
+ Over SSH it prints what to run on your machine instead of starting Chrome.
201
+
202
+ --project dir project folder (default: nearest folder with pix3project.yaml)
203
+ --stop stop the dev server this command started
204
+ --stop-chrome close the Chrome (and its proxy) pix3 editor started
205
+ --no-chrome only the dev server
206
+ --chrome-only only Chrome, for a dev server that already runs
207
+ --headless headless Chrome (a plain tab)
208
+ --port n the dev server's port (Vite --port --strictPort)
209
+ --cdp-port n the proxy's preferred port (default 9333); over SSH: the one RemoteForward
210
+ port of this host (stored; never a scan)
211
+ --url url on your machine: open a forwarded remote editor (no project here)
212
+ --ssh host with --url: the host the printed token-copy line names
213
+ --remote-port n with --url: the remote port of your RemoteForward line (default 9333) \u2014 the
214
+ only one the proxy proves its token for
215
+ `,"agent-setup":`Usage: pix3 agent-setup [claude|codex] [--repair] [--remote] [--cdp-port <n>] [--project <dir>]
216
+
217
+ Write the project's MCP config for chrome-devtools-mcp \u2014 .mcp.json (Claude Code) and/or
218
+ .codex/config.toml (Codex), both by default \u2014 pointing at the token proxy through the 0600 file
219
+ ~/.pix3/cdp-mcp.json (no token in the project or on a command line).
220
+
221
+ --repair rewrite an entry that drifted (version, port, token, an older launch)
222
+ --remote the agent runs on an SSH host, Chrome on your machine (through the forward)
223
+ --cdp-port n the proxy port (default: the one pix3 editor recorded, else 9333); with
224
+ --remote the RemoteForward port (stored; default the one pix3 editor stored)
225
+ --project dir project folder (default: nearest folder with pix3project.yaml)
226
+ `,validate:`Usage: pix3 validate [paths\u2026] [--json] [--no-hydrate] [--project <dir>]
227
+
228
+ paths .pix3scene / .prefab files or folders (default: every scene and .prefab)
229
+ --json machine-readable report (diagnostics + sha256 of each validated file)
230
+ --no-hydrate do not load the scenes as the game does: no project code runs (user: component
231
+ properties not checked)
232
+ --project dir project root (default: nearest folder with pix3project.yaml)
233
+ `,check:`Usage: pix3 check [--json] [--no-hydrate] [--offline] [--no-sync] [--project <dir>]
234
+
235
+ Everything \`pix3 validate\` checks, plus a TypeScript type-check of the project's scripts
236
+ (tsc --noEmit) and a version check.
237
+
238
+ --json machine-readable report (diagnostics, sha256 of every checked file, typecheck,
239
+ kit)
240
+ --no-hydrate do not load the scenes as the game does (user: component properties not checked)
241
+ --offline never install TypeScript (fails with the command to run instead)
242
+ --no-sync do not ask a running Pix3 editor (.pix3/dev.json) to flush its unsaved scenes first
243
+ --project dir project root (default: nearest folder with pix3project.yaml)
244
+ `,smoke:`Usage: pix3 smoke [scene] [--changed | --all] [--frames N] [--timeout S] [--json] [--no-sync] [--project <dir>]
245
+
246
+ Run the game headless in Node \u2014 no browser, no editor: the project's scripts compiled, the scene
247
+ loaded by the real loader, N frames of 1/60 s stepped by the real SceneRunner. Reports every
248
+ script throw (onAttach/onStart/onUpdate, with script name, frame and stack), console.error/warn,
249
+ unhandled rejections, missing res:// files and per-frame step time. Nothing is rendered; audio,
250
+ input and network are inert.
251
+
252
+ scene .pix3scene to run (res://, project-relative or a path) \u2014 the surest way to test
253
+ the game: pix3 smoke scenes/main.pix3scene. With no scene, several run one after
254
+ another, a line each: in a git repo with uncommitted changes, the top-level scenes
255
+ those changes reach (the scene, a prefab/overlay it instances, a user: script it
256
+ attaches); otherwise \u2014 or when a changed scene/script reaches none \u2014 every
257
+ top-level scene (not a prefab or a .prefab, not scenes/ui), scenes/main.pix3scene
258
+ first.
259
+ --changed only the scenes changed files reach (needs git; exit 2 when nothing changed)
260
+ --all every top-level scene, whatever git says
261
+ --frames N frames to step (default 120 = 2 s of game time)
262
+ --timeout S wall-clock limit in seconds (default 20) \u2192 exit 2, E_SMOKE_TIMEOUT
263
+ --json machine-readable report
264
+ --no-sync do not ask a running Pix3 editor (.pix3/dev.json) to flush its unsaved scenes first
265
+ --project dir project folder (default: nearest folder with pix3project.yaml)
266
+
267
+ Exit: 0 = no errors, 1 = errors, 2 = could not run (no scene, bundle failure, unsupported, timeout,
268
+ or E_RUNTIME_VERSION: the project installs another @pix3/runtime than this CLI runs).
269
+ `,tree:`Usage: pix3 tree [scene] [--depth N] [--types A,B] [--props] [--json] [--project <dir>]
270
+
271
+ One line per node \u2014 type#id "name", position, size, anchor layout, components, prefab
272
+ instances (\u21B3 instance res://\u2026 (N overrides, M properties)) \u2014 indented by depth. Read this instead of the
273
+ whole .pix3scene when you need to find your way around a scene. A node anchored by margins
274
+ (layout: left/right/top/bottom) shows them \u2014 layout=left/top(left=40,top=30) \u2014 and the pos and
275
+ size they give at the design size (the parent's size, viewportBaseSize for a root; ? where the
276
+ file does not say enough), not the 0 its file holds on that axis.
277
+
278
+ scene .pix3scene (res://, project-relative or a path). Without one: every scene and
279
+ prefab in the project with node counts, node types and components.
280
+ --depth N stop N levels below the roots (0 = roots only); cut subtrees show "\u2026 +K below"
281
+ --types A,B only nodes of these types (or carrying these components; \`instance\` = prefab
282
+ instances), with their ancestors as "\xB7" context lines
283
+ --props also print each node's properties that differ from the type's defaults
284
+ --json the same as nested JSON
285
+ --project dir project folder (default: nearest folder with pix3project.yaml, else cwd)
286
+ `,kit:`Usage: pix3 kit [--update] [--migrate] [--project <dir>]
287
+
288
+ Install the agent kit into a project: AGENTS.md, CLAUDE.md, .claude/skills/pix3-*, the script
289
+ types (.pix3/types). An existing file is left alone unless --update; a file you edited is never
290
+ overwritten.
291
+
292
+ --update replace kit files that are unedited and out of date
293
+ --migrate a 1.x kit \u2192 2.x: drop the pix3 mcp server from .mcp.json, the retired files and
294
+ metadata.pix3Hybrid, then --update (edited files kept and reported)
295
+ --project dir project folder (default: nearest folder with pix3project.yaml)
296
+ `,"character-compile":`Usage: pix3 character-compile <spec.yaml|spec.json> [--project <dir>] [--dry-run] [--force] [--json]
297
+
298
+ Build a 2D character from frame PNGs: <sprites>/<slug>/<slug>.pix3anim (clips named
299
+ <variant>.<state>), the frames copied beside it as <variant>_<state>_<nnnn>.png, and the prefab
300
+ <prefabs>/<Name>.pix3scene \u2014 an AnimatedSprite2D root with core:CharacterVisual2D. Game code
301
+ then says character.playState('attack', { restart: true }) / character.setVariant('bow').
302
+
303
+ The spec (paths relative to the spec file):
304
+ name: Goblin # display name and prefab file name
305
+ slug: goblin # sprite folder (default: from name)
306
+ anchor: { x: 0.5, y: 0.9 } # where the node position lands, y from the top (the feet)
307
+ defaultVariant: sword # the pair the prefab starts on (default: the first clip's)
308
+ defaultState: idle
309
+ spriteDirectory: sprites # default sprites
310
+ prefabDirectory: scenes/prefabs # default scenes/prefabs
311
+ clips:
312
+ - { variant: sword, state: idle, fps: 10, frames: [art/sword/idle_1.png, art/sword/idle_2.png] }
313
+ - { variant: sword, state: attack, sequence: art/sword/attack } # art/sword/attack_<n>.png
314
+ - { state: die, sequence: art/die, loop: false } # no variant: clip "die"
315
+
316
+ Defaults are proposals and are printed as warnings: fps 12; loop false for attack, die, death,
317
+ hit and hurt, true otherwise. Frames must be PNG.
318
+
319
+ --project dir project root (default: nearest folder with pix3project.yaml)
320
+ --dry-run print what would be written, write nothing
321
+ --force replace files that exist with other bytes (default: refuse, write nothing)
322
+ --json machine-readable report
323
+
324
+ Exit: 0 = written (or nothing to do), 1 = refused (bad spec, missing frame, existing files),
325
+ 2 = usage or no project.
326
+ `,sfx:`Usage: pix3 sfx <preset|"description"> [--out <file.wav>] [--seed <n>] [--json]
327
+
328
+ Synthesizes a short sound effect offline into a 44.1 kHz 16-bit mono WAV.
329
+ presets ${Wt.join(", ")}
330
+ description words that name a preset ("coin pickup", "big explosion"), plus modifiers:
331
+ high/low, short/long, soft
332
+ --out output file (default: audio/<preset>.wav in the project root)
333
+ --seed a variation of the preset (same seed, same sound); default: the preset as tuned
334
+ --json print { path, res, durationMs, preset, seed, modifiers, bytes, peak, params }
335
+ Reference it from a scene or script as res://<path inside the project>.
336
+ `,gap:`Usage: pix3 gap "<what was missing>" [--kind capability|tool|node|doc|other] [--detail <text>]
337
+ [--context <text>] [--agent <name>] [--json] [--project <dir>]
338
+ pix3 gap --list [--json] [--project <dir>]
339
+
340
+ Record, in .pix3/gaps.jsonl, something Pix3 lacked that you worked around \u2014 not your own
341
+ mistakes or the game's features. One line per record.
342
+
343
+ --kind k capability, tool, node, doc or other (default other)
344
+ --detail text what you did instead
345
+ --context text the file or task it happened in
346
+ --agent name who records it (default: from the environment \u2014 claude-code, codex)
347
+ --list print the recorded gaps
348
+ --json machine-readable output
349
+ --project dir project folder (default: nearest folder with pix3project.yaml)
350
+ `},ba=t=>Object.prototype.hasOwnProperty.call(I,t)});var ks={};X(ks,{RUNTIME_TYPES_FORMAT:()=>st,buildRuntimeTypes:()=>Lf,ensureRuntimeTypes:()=>y_,expandRuntimeTypes:()=>jf,packRuntimeTypes:()=>m_,readRuntimeTypesManifest:()=>bt,repoRuntimePackage:()=>Jt,runtimeSourceStamp:()=>Hr,runtimeTypesArchive:()=>Es,runtimeTypesDir:()=>Gt});import{spawnSync as d_}from"node:child_process";import{createHash as $f}from"node:crypto";import{cpSync as wa,existsSync as xa,mkdirSync as vs,mkdtempSync as Nf,readdirSync as Af,readFileSync as _s,renameSync as If,rmSync as Vt,statSync as f_,writeFileSync as Vr}from"node:fs";import{createRequire as Rf}from"node:module";import{tmpdir as _a}from"node:os";import{dirname as Gr,join as j,relative as Mf,sep as p_}from"node:path";var st,Jr,Gt,Es,Jt,va,bt,Ea,Hr,h_,Lf,m_,g_,jf,y_,Yr=O(()=>{"use strict";Ie();Re();st=1,Jr=()=>ie(),Gt=()=>j(Jr(),"runtime-types"),Es=()=>j(Jr(),"dist","runtime-types.json"),Jt=()=>{let t=j(Jr(),"..","runtime");return xa(j(t,"tsconfig.types.json"))&&xa(j(Jr(),"scripts","build-runtime-types.mjs"))?t:null},va=t=>{try{return JSON.parse(_s(t,"utf8"))}catch{return null}},bt=(t=Gt())=>va(j(t,"manifest.json")),Ea=(t,e=[])=>{for(let r of Af(t,{withFileTypes:!0})){let n=j(t,r.name);r.isDirectory()?Ea(n,e):r.isFile()&&e.push(n)}return e},Hr=t=>{let e=$f("sha256");e.update(`${F}
351
+ `);for(let n of["tsconfig.json","tsconfig.types.json","package.json"])e.update(_s(j(t,n)));let r=Ea(j(t,"src")).filter(n=>n.endsWith(".ts")&&!n.endsWith(".spec.ts")).sort();for(let n of r){let s=f_(n);e.update(`${Mf(t,n)}:${s.size}:${Math.trunc(s.mtimeMs)}
352
+ `)}return e.digest("hex")},h_=t=>{let e=Rf(j(t,"package.json"));return Gr(e.resolve("@types/three/package.json"))},Lf=(t={})=>{let e=Jt();if(!e)throw new Error("runtime types can only be built from a checkout of the pix3 repo");let r=t.outDir??Gt(),n=Rf(import.meta.url),s=j(Gr(n.resolve("typescript/package.json")),"bin","tsc"),i=Nf(j(_a(),"pix3-runtime-types-"));try{let o=j(i,"emit"),a=d_(process.execPath,[s,"-p",j(e,"tsconfig.types.json"),"--outDir",o],{encoding:"utf8"});if(a.status!==0)throw new Error(`tsc -p packages/runtime/tsconfig.types.json failed:
353
+ ${a.stdout}${a.stderr}`);let l=va(j(e,"package.json"))?.version??"0.0.0",c=h_(e),u=va(j(c,"package.json"))?.version??"0.0.0",f=j(i,"out"),d=j(f,"@pix3","runtime");wa(o,d,{recursive:!0}),Vr(j(d,"package.json"),`${JSON.stringify({name:"@pix3/runtime",version:l,types:"index.d.ts"},null,2)}
354
+ `);let h=j(f,"@types","three");vs(h,{recursive:!0});for(let p of Af(c))p!=="node_modules"&&wa(j(c,p),j(h,p),{recursive:!0});let g={format:st,cliVersion:F,runtimeVersion:l,threeTypesVersion:u,sourceStamp:Hr(e),builtAt:new Date().toISOString()};return Vr(j(f,"manifest.json"),`${JSON.stringify(g,null,2)}
355
+ `),Vt(r,{recursive:!0,force:!0}),vs(Gr(r),{recursive:!0}),wa(f,r,{recursive:!0}),t.log?.(`runtime types ${l} (+ @types/three ${u}) -> ${r}`),g}finally{Vt(i,{recursive:!0,force:!0})}},m_=(t=Gt(),e=Es())=>{let r=bt(t);if(!r)throw new Error(`${t} has no manifest.json: build the runtime types first`);let n=Ea(t).map(o=>Mf(t,o).split(p_).join("/")).filter(o=>o!=="manifest.json").sort().map(o=>{let a=_s(j(t,o)),l=a.toString("utf8");if(!Buffer.from(l,"utf8").equals(a))throw new Error(`runtime types: ${o} is not UTF-8 text and cannot be archived`);return[o,l]}),i=JSON.stringify({format:st,manifest:r,files:n});return vs(Gr(e),{recursive:!0}),Vr(e,i),{files:n.length,bytes:Buffer.byteLength(i)}},g_=(t,e)=>{let r=`${e}.tmp-${process.pid}-${Date.now()}`;Vt(r,{recursive:!0,force:!0});try{for(let[n,s]of t.files){let i=j(r,...n.split("/"));vs(Gr(i),{recursive:!0}),Vr(i,s)}Vr(j(r,"manifest.json"),`${JSON.stringify(t.manifest,null,2)}
356
+ `),Vt(e,{recursive:!0,force:!0}),If(r,e)}catch(n){if(Vt(r,{recursive:!0,force:!0}),bt(e)?.sourceStamp===t.manifest.sourceStamp)return;throw n}},jf=(t=Es(),e=Gt())=>{if(!xa(t))return null;let r=JSON.parse(_s(t,"utf8"));if(r.format!==st)throw new Error(`${t}: runtime types archive format ${r.format}, expected ${st}`);let n=j(_a(),`pix3-cli-runtime-types-${r.manifest.cliVersion}-${r.manifest.sourceStamp.slice(0,12)}`);for(let s of[e,n]){if(bt(s)?.sourceStamp===r.manifest.sourceStamp)return{dir:s,manifest:r.manifest};try{return g_(r,s),{dir:s,manifest:r.manifest}}catch(i){if(s===n)throw i}}return null},y_=(t={})=>{let e=Gt(),r=Jt();if(r){let i=Hr(r),o=$f("sha256").update(Jr()).digest("hex").slice(0,16),a=j(_a(),`pix3-runtime-types-${o}-${i}`),l=bt(a);if(l?.format===st&&l.sourceStamp===i)return{dir:a,manifest:l};t.log?.("Building the @pix3/runtime type declarations from the repo sources\u2026");let c=Nf(`${a}.tmp-`);try{let u=Lf({outDir:c,log:t.log});try{return If(c,a),{dir:a,manifest:u}}catch(f){let d=bt(a);if(d?.format===st&&d.sourceStamp===i)return{dir:a,manifest:d};throw f}}finally{Vt(c,{recursive:!0,force:!0})}}let n=bt(e);if(n?.format===st&&n.cliVersion===F)return{dir:e,manifest:n};let s=jf();if(s)return s;if(!n)throw new Error(`${Es()} is missing: this @pix3/cli package was published without its runtime types.`);return{dir:e,manifest:n}}});var Df,Cs,Ff=O(()=>{"use strict";Df="kit.json",Cs="files"});var qf=x(()=>{throw new Error("src\\kit\\generate.ts is only available in a checkout of the pix3 repo (the published @pix3/cli ships its bundles prebuilt)")});var Bf=x(()=>{throw new Error("src\\kit\\core-components.ts is only available in a checkout of the pix3 repo (the published @pix3/cli ships its bundles prebuilt)")});var Jf={};X(Jf,{buildKitFromCheckout:()=>Gf,ensureKit:()=>Oa,isKitCheckout:()=>Wf,kitDir:()=>ka,kitInputsStamp:()=>Ca,kitSrcDir:()=>Ps,repoRootOfCheckout:()=>$s});import{createHash as S_}from"node:crypto";import{existsSync as Uf,readdirSync as b_,readFileSync as Os}from"node:fs";import{join as oe,relative as w_,sep as x_}from"node:path";var Ts,ka,Ps,$s,Wf,v_,Vf,Ca,__,Gf,Oa,Ta=O(()=>{"use strict";Ie();Yr();Re();Ff();Ts=()=>ie(),ka=()=>oe(Ts(),"kit"),Ps=()=>oe(Ts(),"kit-src"),$s=()=>oe(Ts(),"..",".."),Wf=()=>Uf(Ps())&&Uf(oe($s(),"docs","pix3-specification.md"))&&Jt()!==null,v_=/\{\{include:([^#@|}]+)/g,Vf=(t,e=t)=>{let r=[];for(let n of b_(e,{withFileTypes:!0})){let s=oe(e,n.name);n.isDirectory()?r.push(...Vf(t,s)):n.isFile()&&r.push(w_(t,s).split(x_).join("/"))}return r.sort()},Ca=()=>{let t=S_("sha256");t.update(`${1}:${F}
357
+ `);let e=Ps(),r=$s(),n=new Set;for(let o of Vf(e)){let a=Os(oe(e,o),"utf8");t.update(`${o}
358
+ `).update(a);for(let l of a.matchAll(v_))n.add(l[1].trim())}for(let o of[...n].sort()){t.update(`${o}
359
+ `);try{t.update(Os(oe(r,o)))}catch{t.update("(missing)")}}let s=oe(Ts(),"src","kit");for(let o of["generate.ts","kit-format.ts","core-components.ts","kit-source.ts"])t.update(Os(oe(s,o)));let i=Jt();return i&&t.update(Hr(i)),t.digest("hex")},__=t=>{try{return JSON.parse(Os(oe(t,Df),"utf8"))}catch{return null}},Gf=async(t={})=>{let{generateKit:e}=await Promise.resolve().then(()=>U(qf(),1)),r=t.coreComponents??await(await Promise.resolve().then(()=>U(Bf(),1))).loadCoreComponentsFromSource();return e({repoRoot:$s(),kitSrcDir:Ps(),outDir:t.outDir??ka(),version:F,coreComponents:r,inputsStamp:t.stamp??Ca()})},Oa=async(t={})=>{let e=ka(),r=__(e);if(Wf()){let n=Ca();if(r&&r.format===1&&r.inputsStamp===n)return{dir:e,filesDir:oe(e,Cs),manifest:r};t.log?.("Generating the agent kit from the repo sources\u2026");let s=await Gf({stamp:n});return{dir:e,filesDir:oe(e,Cs),manifest:s}}if(!r)throw new Error(`${e} is missing: this @pix3/cli package was published without its kit.`);return{dir:e,filesDir:oe(e,Cs),manifest:r}}});import{cpSync as E_,existsSync as Yf,mkdirSync as k_,readFileSync as $a,rmSync as C_,writeFileSync as Hf}from"node:fs";import{join as Le}from"node:path";var Pa,wt,it,Na,zf,Ht,O_,Ns,As,Is=O(()=>{"use strict";Pa=".pix3/types",wt=".pix3/tsconfig.check.json",it="tsconfig.json",Na=`{ "extends": "./.pix3/tsconfig.check.json" }
360
+ `,zf=`// Written by @pix3/cli (pix3 kit / pix3 check); replaced when the CLI version changes.
154
361
  // Type-checks the project's scripts against the @pix3/runtime declarations in ./types/.
155
362
  {
156
363
  "compilerOptions": {
@@ -172,328 +379,257 @@ ${a.stdout}${a.stderr}`);let c=s_(Pe(e,"package.json"))?.version??"0.0.0",l=PK(e
172
379
  },
173
380
  "include": ["../scripts/**/*.ts", "../src/scripts/**/*.ts"]
174
381
  }
175
- `,ei=t=>{let e=vn(t,rs);if(!OI(e))return!1;try{return m_(e,"utf8").trim()!==g_.trim()}catch{return!0}},BK=t=>{try{return JSON.parse(m_(vn(t,h_,"version.json"),"utf8"))}catch{return null}},Nf=(t,e)=>{let r=BK(t);return r!==null&&r.cliVersion===e.cliVersion&&r.sourceStamp===e.sourceStamp&&OI(vn(t,Bs))&&m_(vn(t,Bs),"utf8")===II},Cf=(t,e)=>{let r=vn(t,h_);VK(r,{recursive:!0,force:!0}),UK(r,{recursive:!0});for(let n of["@pix3","@types"])ZK(vn(e.dir,n),vn(r,n),{recursive:!0});return PI(vn(r,"version.json"),`${JSON.stringify(e.manifest,null,2)}
176
- `),PI(vn(t,Bs),II),[`${h_}/`,Bs]}});var jI={};Je(jI,{AGENTS_ALT_FILE:()=>ns,AGENTS_FILE:()=>cr,AGENTS_LINK_LINE:()=>w_,CLAUDE_FILE:()=>Hs,KIT_PROJECT_MANIFEST:()=>__,PRECEDENCE_SENTENCE:()=>v_,agentKitStep:()=>e6,ensureGitignore:()=>RI,formatKitReport:()=>b_,installKit:()=>jf,readProjectKitManifest:()=>CI,withAltAgentsHeader:()=>zI,writeAgentKitMetadata:()=>AI});import{createHash as KK}from"node:crypto";import{existsSync as Af,mkdirSync as HK,readFileSync as Ks,renameSync as WK,writeFileSync as JK}from"node:fs";import{dirname as GK,join as Gr}from"node:path";var NI,__,cr,ns,Hs,y_,YK,zf,xc,CI,ti,RI,AI,v_,w_,zI,XK,QK,jf,e6,b_,S_=$(()=>{"use strict";NI=Ze(Er(),1);ut();vf();Rf();__=".pix3/kit-manifest.json",cr="AGENTS.md",ns="AGENTS.pix3.md",Hs="CLAUDE.md",y_=".gitignore",YK=".pix3/",zf=t=>KK("sha256").update(t).digest("hex"),xc=t=>{try{return Ks(t,"utf8")}catch{return null}},CI=t=>{let e=xc(Gr(t,__));if(e===null)return null;try{let r=JSON.parse(e);return r&&typeof r.files=="object"&&r.files!==null?{format:1,version:String(r.version??""),files:r.files}:null}catch{return null}},ti=(t,e)=>{HK(GK(t),{recursive:!0});let r=`${t}.${process.pid}.tmp`;JK(r,e),WK(r,t)},RI=t=>{let e=Gr(t,y_),r=xc(e)??"";if(r.split(/\r?\n/).map(o=>o.trim()).some(o=>[".pix3",".pix3/","/.pix3","/.pix3/",".pix3/*","/.pix3/*"].includes(o)))return!1;let s=r.length===0||r.endsWith(`
382
+ `,Ht=t=>{let e=Le(t,it);if(!Yf(e))return!1;try{return $a(e,"utf8").trim()!==Na.trim()}catch{return!0}},O_=t=>{try{return JSON.parse($a(Le(t,Pa,"version.json"),"utf8"))}catch{return null}},Ns=(t,e)=>{let r=O_(t);return r!==null&&r.cliVersion===e.cliVersion&&r.sourceStamp===e.sourceStamp&&Yf(Le(t,wt))&&$a(Le(t,wt),"utf8")===zf},As=(t,e)=>{let r=Le(t,Pa);C_(r,{recursive:!0,force:!0}),k_(r,{recursive:!0});for(let n of["@pix3","@types"])E_(Le(e.dir,n),Le(r,n),{recursive:!0});return Hf(Le(r,"version.json"),`${JSON.stringify(e.manifest,null,2)}
383
+ `),Hf(Le(t,wt),zf),[`${Pa}/`,wt]}});var tp={};X(tp,{AGENTS_ALT_FILE:()=>ee,AGENTS_FILE:()=>J,AGENTS_LINK_LINE:()=>Ra,CLAUDE_FILE:()=>De,KIT_PROJECT_MANIFEST:()=>Ms,PRECEDENCE_SENTENCE:()=>Ia,agentKitStep:()=>N_,ensureGitignore:()=>Qf,formatKitReport:()=>zr,installKit:()=>Xt,readProjectKitManifest:()=>zt,withAltAgentsHeader:()=>ep,writeAgentKitMetadata:()=>Zf});import{existsSync as Rs,readFileSync as Yt}from"node:fs";import{join as je}from"node:path";var Xf,Ms,J,ee,De,Aa,T_,zt,Qf,Zf,Ia,Ra,ep,P_,$_,Xt,N_,zr,Ls=O(()=>{"use strict";Xf=U(ce(),1);se();Z();Is();Ms=".pix3/kit-manifest.json",J="AGENTS.md",ee="AGENTS.pix3.md",De="CLAUDE.md",Aa=".gitignore",T_=["# Pix3 editor + CLI bookkeeping \u2014 ignored, except the kit's record of the files it wrote","# (pix3 kit --update) and the template the project came from",".pix3/*",`!${Ms}`,"!.pix3/template.json"].join(`
384
+ `),zt=t=>{let e=W(je(t,Ms));if(e===null)return null;try{let r=JSON.parse(e);return r&&typeof r.files=="object"&&r.files!==null?{format:1,version:String(r.version??""),files:r.files}:null}catch{return null}},Qf=t=>{let e=je(t,Aa),r=W(e)??"";if(r.split(/\r?\n/).map(i=>i.trim()).some(i=>[".pix3",".pix3/","/.pix3","/.pix3/",".pix3/*","/.pix3/*"].includes(i)))return!1;let s=r.length===0||r.endsWith(`
177
385
  `)?r:`${r}
178
- `;return ti(e,`${s}${s?`
179
- `:""}# Pix3 editor + CLI bookkeeping (recovery journal, merge log, script types)
180
- ${YK}
181
- `),!0},AI=(t,e)=>{let r=Gr(t,xe),n=xc(r);if(n===null)return!1;let s=(0,NI.parseDocument)(n),o={version:e.version,files:[...e.files]},i=s.toJS();return JSON.stringify(i?.metadata?.agentKit??null)===JSON.stringify(o)?!1:((!i?.metadata||typeof i.metadata!="object")&&s.set("metadata",s.createNode({})),s.setIn(["metadata","agentKit"],s.createNode(o)),ti(r,s.toString({indent:2})),!0)},v_="The project's own AGENTS.md wins on process (planning first, config placement); the Pix3 kit wins on Pix3 facts (YAML, runtime API, pix3 check).",w_=`See ${ns} for the Pix3 engine rules.`,zI=t=>{let e=["",`> **This project has its own \`${cr}\`; this file is the Pix3 kit beside it.** ${v_}`,`> If \`${cr}\` does not mention this file yet, add the line "${w_}" to it (agents that read only \`${cr}\` will not find this one otherwise).`,""].join(`
386
+ `;return Q(e,`${s}${s?`
387
+ `:""}${T_}
388
+ `),!0},Zf=(t,e)=>{let r=je(t,K),n=W(r);if(n===null)return!1;let s=(0,Xf.parseDocument)(n),i={version:e.version,files:[...e.files]},o=s.toJS();return JSON.stringify(o?.metadata?.agentKit??null)===JSON.stringify(i)?!1:((!o?.metadata||typeof o.metadata!="object")&&s.set("metadata",s.createNode({})),s.setIn(["metadata","agentKit"],s.createNode(i)),Q(r,s.toString({indent:2})),!0)},Ia="The project's own AGENTS.md wins on process (planning first, config placement); the Pix3 kit wins on Pix3 facts (YAML, runtime API, pix3 check).",Ra=`See ${ee} for the Pix3 engine rules.`,ep=t=>{let e=["",`> **This project has its own \`${J}\`; this file is the Pix3 kit beside it.** ${Ia}`,`> If \`${J}\` does not mention this file yet, add the line "${Ra}" to it (agents that read only \`${J}\` will not find this one otherwise).`,""].join(`
182
389
  `),r=t.indexOf(`
183
390
  `);return r<0?`${t}
184
391
  ${e}
185
392
  `:`${t.slice(0,r+1)}${e}
186
- ${t.slice(r+1)}`},XK=t=>(xc(t)??"").includes(ns),QK=t=>t===cr?`@AGENTS.md
393
+ ${t.slice(r+1)}`},P_=t=>(W(t)??"").includes(ee),$_=t=>t===J?`@AGENTS.md
187
394
  `:`@AGENTS.md
188
- @${ns}
189
- `,jf=(t,e,r={})=>{let n=CI(t),s={...n?.files??{}},o=[],i=[],a=[],c=(v,S)=>{let T=Gr(t,v),P=zf(S),A=Af(T)?Ks(T):null;if(A===null){ti(T,S),s[v]=P,o.push({path:v,action:"written"});return}let Z=zf(A);if(Z===P){s[v]=P,o.push({path:v,action:"unchanged"});return}if(s[v]===Z){r.update?(ti(T,S),s[v]=P,o.push({path:v,action:"updated"})):o.push({path:v,action:"outdated"});return}o.push({path:v,action:"skipped-edited"})},l=Gr(t,cr),u=!Af(l)||s[cr]!==void 0&&s[cr]===zf(Ks(l)),d=s[ns]!==void 0||!u?ns:cr;for(let v of e.manifest.files){let S=Ks(Gr(e.filesDir,v),"utf8");if(v===cr){let T=d===ns;c(d,T?zI(S):S),T&&!XK(l)&&i.push(`This project already has its own ${cr}: the Pix3 kit is in ${ns}. ${v_} Add a line "${w_}" to ${cr}.`);continue}if(v===Hs){let T=Gr(t,Hs),P=QK(d);if(!Af(T)||s[Hs]===zf(Ks(T))||Ks(T,"utf8")===P)c(Hs,P);else{let Z=Ks(T,"utf8"),ee=`@${d}`;Z.split(/\r?\n/).some(J=>J.trim()===ee)||i.push(`This project already has its own ${Hs}: add the line "${ee}" to it so Claude Code loads the Pix3 kit.`),o.push({path:Hs,action:"skipped-edited"})}continue}c(v,S)}let f=Gr(t,_n),p=xc(f),m=_f(Go({dev:r.devMcp}),p??void 0),h=(()=>{try{return!!(p?JSON.parse(p):null)?.mcpServers?.pix3}catch{return!1}})();p===m?o.push({path:_n,action:"unchanged"}):!h||r.update?(ti(f,m),o.push({path:_n,action:p===null?"written":"updated"})):o.push({path:_n,action:"outdated"}),RI(t)&&o.push({path:y_,action:"updated"});let g;if(ei(t))g="own-tsconfig",a.push(`${rs} is the project's own: pix3 check type-checks with it (against node_modules), .pix3/types is not written.`);else{if(!r.runtimeTypes)throw new Error("installKit: runtime types are required");Nf(t,r.runtimeTypes.manifest)?g="current":(Cf(t,r.runtimeTypes),g="installed"),c(rs,g_)}let y=[...o.filter(v=>v.action!=="skipped-edited"&&v.path!==y_).map(v=>v.path)].sort(),w=o.filter(v=>v.action==="outdated"),b=w.length>0&&n?.version?n.version:e.manifest.version,x={format:1,version:b,files:Object.fromEntries(Object.entries(s).filter(([v])=>Af(Gr(t,v))).sort(([v],[S])=>v<S?-1:1))};return ti(Gr(t,__),`${JSON.stringify(x,null,2)}
190
- `),AI(t,{version:b,files:y}),w.length>0&&a.push(`${w.length} kit file(s) are from another version and unchanged by you: pix3 kit --update replaces them.`),{version:b,files:o,instructions:i,notes:a,types:g}},e6=(t,e,r={})=>n=>jf(n.dir,t,{runtimeTypes:e,devMcp:r.devMcp}).files.filter(o=>o.action==="written"||o.action==="updated").map(o=>o.path),b_=(t,e)=>{let r=[`Pix3 agent kit ${t.version} in ${e}`],n={written:"wrote",updated:"updated",unchanged:"current","skipped-edited":"SKIPPED",outdated:"outdated"};for(let s of t.files){let o=s.action==="skipped-edited"?" (edited since the kit wrote it, or not the kit's; left as is)":s.action==="outdated"?" (pix3 kit --update replaces it)":"";r.push(` ${n[s.action].padEnd(8)} ${s.path}${o}`)}t.types==="installed"&&r.push(" wrote .pix3/types/, .pix3/tsconfig.check.json");for(let s of t.notes)r.push(`note: ${s}`);for(let s of t.instructions)r.push(`TODO: ${s}`);return`${r.join(`
395
+ @${ee}
396
+ `,Xt=(t,e,r={})=>{let n=zt(t),s={...n?.files??{}},i=[],o=[],a=[],l=(y,w)=>{let _=je(t,y),v=Se(w),E=Rs(_)?Yt(_):null;if(E===null){Q(_,w),s[y]=v,i.push({path:y,action:"written"});return}let k=Se(E);if(k===v){s[y]=v,i.push({path:y,action:"unchanged"});return}if(s[y]===k){r.update?(Q(_,w),s[y]=v,i.push({path:y,action:"updated"})):i.push({path:y,action:"outdated"});return}i.push({path:y,action:"skipped-edited"})},c=je(t,J),u=!Rs(c)||s[J]!==void 0&&s[J]===Se(Yt(c)),f=s[ee]!==void 0||!u?ee:J;for(let y of e.manifest.files){let w=Yt(je(e.filesDir,y),"utf8");if(y===J){let _=f===ee;l(f,_?ep(w):w),_&&!P_(c)&&o.push(`This project already has its own ${J}: the Pix3 kit is in ${ee}. ${Ia} Add a line "${Ra}" to ${J}.`);continue}if(y===De){let _=je(t,De),v=$_(f);if(!Rs(_)||s[De]===Se(Yt(_))||Yt(_,"utf8")===v)l(De,v);else{let k=Yt(_,"utf8"),T=`@${f}`;k.split(/\r?\n/).some(S=>S.trim()===T)||o.push(`This project already has its own ${De}: add the line "${T}" to it so Claude Code loads the Pix3 kit.`),i.push({path:De,action:"skipped-edited"})}continue}l(y,w)}Qf(t)&&i.push({path:Aa,action:"updated"});let d;if(Ht(t))d="own-tsconfig",a.push(`${it} is the project's own: pix3 check type-checks with it (against node_modules), .pix3/types is not written.`);else{if(!r.runtimeTypes)throw new Error("installKit: runtime types are required");Ns(t,r.runtimeTypes.manifest)?d="current":(As(t,r.runtimeTypes),d="installed"),l(it,Na)}let h=[...i.filter(y=>y.action!=="skipped-edited"&&y.path!==Aa).map(y=>y.path)].sort(),g=i.filter(y=>y.action==="outdated"),p=g.length>0&&n?.version?n.version:e.manifest.version,m={format:1,version:p,files:Object.fromEntries(Object.entries(s).filter(([y])=>Rs(je(t,y))).sort(([y],[w])=>y<w?-1:1))};return Q(je(t,Ms),`${JSON.stringify(m,null,2)}
397
+ `),Zf(t,{version:p,files:h}),g.length>0&&a.push(`${g.length} kit file(s) are from another version and unchanged by you: pix3 kit --update replaces them.`),{version:p,files:i,instructions:o,notes:a,types:d}},N_=(t,e,r={})=>n=>Xt(n.dir,t,{runtimeTypes:e,...r}).files.filter(i=>i.action==="written"||i.action==="updated").map(i=>i.path),zr=(t,e)=>{let r=[`Pix3 agent kit ${t.version} in ${e}`],n={written:"wrote",updated:"updated",unchanged:"current","skipped-edited":"SKIPPED",outdated:"outdated"};for(let s of t.files){let i=s.action==="skipped-edited"?" (edited since the kit wrote it, or not the kit's; left as is)":s.action==="outdated"?" (pix3 kit --update replaces it)":"";r.push(` ${n[s.action].padEnd(8)} ${s.path}${i}`)}t.types==="installed"&&r.push(" wrote .pix3/types/, .pix3/tsconfig.check.json");for(let s of t.notes)r.push(`note: ${s}`);for(let s of t.instructions)r.push(`TODO: ${s}`);return`${r.join(`
191
398
  `)}
192
- `}});import{isAbsolute as t6,relative as r6,resolve as n6,sep as s6}from"node:path";var Mf,MI,LI=$(()=>{"use strict";Mf=(t,e)=>{let r=r6(t,e);return r&&!r.startsWith("..")&&!t6(r)?r.split(s6).join("/"):e},MI=(t,e,r)=>{let n=Date.now(),s=[],o=n6(e,r),i=Mf(e,o),a=f=>{let p=t.flattenDiagnosticMessageText(f.messageText,`
193
- `),m=`TS${f.code}`;if(f.file&&f.start!==void 0){let{line:h,character:g}=f.file.getLineAndCharacterOfPosition(f.start);return{file:Mf(e,f.file.fileName),line:h+1,column:g+1,tsCode:m,message:p}}return{file:f.file?Mf(e,f.file.fileName):i,tsCode:m,message:p}},c=[],l=t.getParsedCommandLineOfConfigFile(o,{noEmit:!0},{...t.sys,onUnRecoverableConfigFileDiagnostic:f=>c.push(f)});if(!l)return{tsconfig:i,files:[],errors:c.map(a),durationMs:Date.now()-n};let u=18003;for(let f of[...c,...l.errors])f.code!==u&&s.push(a(f));let d=l.fileNames.map(f=>Mf(e,f)).sort();if(l.fileNames.length>0){let f=t.createProgram({rootNames:l.fileNames,options:{...l.options,noEmit:!0},projectReferences:l.projectReferences});for(let p of t.getPreEmitDiagnostics(f))s.push(a(p))}return{tsconfig:i,files:d,errors:s,durationMs:Date.now()-n}}});import{spawnSync as o6}from"node:child_process";import{existsSync as $_,mkdirSync as i6}from"node:fs";import{createRequire as DI}from"node:module";import{homedir as a6}from"node:os";import{join as Yr}from"node:path";import{fileURLToPath as c6,pathToFileURL as l6}from"node:url";var Lf,ri,u6,d6,f6,p6,h6,m6,Ec,qI,FI=$(()=>{"use strict";Lf="5.8.3",ri=class extends Error{command;constructor(e,r){super(e),this.command=r}},u6=()=>Yr(a6(),".pix3","typescript"),d6=(t,e=Lf)=>`npm install --prefix ${JSON.stringify(t)} typescript@${e} --no-save --no-package-lock --no-audit --no-fund --loglevel=error`,f6=t=>{try{return Yr(t.resolve("typescript/package.json"),"..")}catch{return null}},p6=t=>f6(DI(Yr(t,"__pix3_check__.js"))),h6=()=>{try{let t=import.meta.resolve("typescript");return Yr(c6(t),"..","..")}catch{return null}},m6=(t,e)=>{i6(t,{recursive:!0});let r=process.platform==="win32"?"npm.cmd":"npm",n=o6(r,["install","--prefix",t,`typescript@${e}`,"--no-save","--no-package-lock","--no-audit","--no-fund","--loglevel=error"],{encoding:"utf8",stdio:["ignore","pipe","pipe"],shell:process.platform==="win32"});return n.error?n.error.message:n.status!==0?(n.stderr||n.stdout||`exit ${n.status}`).trim():null},Ec=async t=>{let r=DI(Yr(t,"package.json")).resolve("typescript"),n=await import(l6(r).href),s=n.default??n;if(typeof s.createProgram!="function")throw new Error(`${r} is not the TypeScript compiler API`);return{ts:s,version:s.version}},qI=async t=>{let e=process.env.PIX3_TYPESCRIPT;if(e){let{ts:c,version:l}=await Ec(e);return{ts:c,version:l,source:"env",dir:e}}let r=p6(t.projectRoot);if(r)return{...await Ec(r),source:"project",dir:r};let n=t.skipCliSibling?null:h6();if(n&&$_(Yr(n,"package.json")))return{...await Ec(n),source:"cli",dir:n};let s=Yr(t.cacheRoot??u6(),Lf),o=Yr(s,"node_modules","typescript"),i=d6(s);if($_(Yr(o,"package.json")))return{...await Ec(o),source:"cache",dir:o};if(t.offline)throw new ri(`TypeScript is not installed for pix3 check, and --offline forbids installing it. Run once:
194
- ${i}`,i);t.log?.(`pix3 check: installing TypeScript ${Lf} once into ${s}
195
- $ ${i}`);let a=(t.install??m6)(s,Lf);if(a!==null||!$_(Yr(o,"package.json")))throw new ri(`Could not install TypeScript (${a??"npm reported success but nothing was installed"}). Run it yourself:
196
- ${i}`,i);return{...await Ec(o),source:"installed",dir:o}}});var ZI=_(()=>{throw new Error("src/validate/bundle.ts is only available in a checkout of the pix3 repo (the published @pix3/cli ships its bundles prebuilt)")});var x_={};Je(x_,{runValidateCli:()=>b6,withValidateBundle:()=>KI});import{existsSync as g6,mkdtempSync as y6,rmSync as _6}from"node:fs";import{tmpdir as v6}from"node:os";import{join as k_}from"node:path";import{pathToFileURL as w6}from"node:url";var BI,UI,VI,KI,b6,E_=$(()=>{"use strict";Us();BI="bundle-main.js",UI=()=>{try{return import.meta.resolve("esbuild")}catch{return}},VI=async t=>await import(w6(k_(t,BI)).href),KI=async t=>{let e=yf("validate");if(e&&g6(k_(e,BI)))return t(await VI(e),UI());let r=y6(k_(v6(),"pix3-validate-bundle-"));try{let{buildValidateBundle:n}=await Promise.resolve().then(()=>Ze(ZI(),1));return await n(r),await t(await VI(r),UI())}finally{_6(r,{recursive:!0,force:!0})}},b6=t=>KI((e,r)=>e.runBundledValidate(t,{cwd:process.cwd(),stdout:n=>process.stdout.write(n),stderr:n=>process.stderr.write(n),esbuildSpecifier:r}))});var sN={};Je(sN,{CHECK_CODES:()=>I_,CHECK_USAGE:()=>T_,MERGE_LOG_TAIL:()=>GI,checkProject:()=>nN,describeMergeLogEntry:()=>P_,formatCheckHuman:()=>tN,formatCheckJson:()=>rN,hasNodeModules:()=>XI,installedRuntimeVersion:()=>QI,readKitVersion:()=>YI,readMergeLogTail:()=>eN,runCheck:()=>C6});import{createHash as S6}from"node:crypto";import{existsSync as Tc,readFileSync as Df}from"node:fs";import{dirname as WI,join as Ws,resolve as O_}from"node:path";var JI,T_,I_,GI,$6,k6,x6,E6,T6,ni,YI,XI,QI,eN,P6,HI,P_,O6,I6,tN,rN,N6,nN,C6,oN=$(()=>{"use strict";JI=Ze(Er(),1);ut();Rf();ar();LI();FI();T_=`Usage: pix3 check [--json] [--no-hydrate] [--offline] [--project <dir>]
197
-
198
- Everything \`pix3 validate\` checks, plus a TypeScript type-check of the project's scripts
199
- (tsc --noEmit), the newest .pix3/merge-log.jsonl entries and a version check.
200
-
201
- --json machine-readable report (diagnostics, sha256 of every checked file, typecheck,
202
- mergeLog, kit)
203
- --no-hydrate validate level 1 only (user: component properties not checked)
204
- --offline never install TypeScript (fails with the command to run instead)
205
- --project dir project root (default: nearest folder with pix3project.yaml)
206
- `,I_={E_TYPE:{severity:"error",summary:"a TypeScript error in a project script"},E_DEPENDENCIES_MISSING:{severity:"error",summary:"the project has its own tsconfig.json but no node_modules: run npm install (the type-check was skipped)"},E_TYPECHECK_UNAVAILABLE:{severity:"error",summary:"TypeScript could not be found or installed, so the scripts were not type-checked"},W_RUNTIME_VERSION_MISMATCH:{severity:"warning",summary:"the project's own node_modules/@pix3/runtime is not this CLI's version"},W_RUNTIME_NOT_INSTALLED:{severity:"warning",summary:"the project has its own tsconfig.json and node_modules, but no node_modules/@pix3/runtime"},W_KIT_OUTDATED:{severity:"warning",summary:"the agent kit in this project was written by another CLI version"}},GI=10,$6=".pix3/merge-log.jsonl",k6=40,x6=t=>{let e=!1,r=!0,n=!1,s,o=!1;for(let i=0;i<t.length;i++){let a=t[i];if(a==="--json")e=!0;else if(a==="--no-hydrate")r=!1;else if(a==="--offline")n=!0;else if(a==="--help"||a==="-h")o=!0;else if(a==="--project"){if(s=t[++i],!s)return{error:"--project needs a folder"}}else if(a.startsWith("--project="))s=a.slice(10);else return{error:`unknown argument ${a}`}}return{json:e,hydrate:r,offline:n,project:s,help:o}},E6=async t=>{let{withValidateBundle:e}=await Promise.resolve().then(()=>(E_(),x_));return e((r,n)=>r.validateBundledProject({...t,esbuildSpecifier:n}))},T6=t=>S6("sha256").update(Df(t)).digest("hex"),ni=(t,e)=>({severity:I_[t].severity,code:t,...e}),YI=t=>{try{let e=(0,JI.parse)(Df(Ws(t,xe),"utf8")),n=(e&&typeof e=="object"?e.metadata:void 0)?.agentKit?.version;return typeof n=="string"?n:null}catch{return null}},XI=t=>{let e=O_(t);for(;;){if(Tc(Ws(e,"node_modules")))return!0;let r=WI(e);if(r===e)return!1;e=r}},QI=t=>{let e=O_(t);for(;;){let r=Ws(e,"node_modules","@pix3","runtime","package.json");if(Tc(r))try{let s=JSON.parse(Df(r,"utf8")).version;return typeof s=="string"?s:null}catch{return null}let n=WI(e);if(n===e)return null;e=n}},eN=(t,e=GI)=>{let r;try{r=Df(Ws(t,$6),"utf8")}catch{return[]}let n=[];for(let s of r.split(`
207
- `))if(s.trim())try{let o=JSON.parse(s);o&&typeof o=="object"&&!Array.isArray(o)&&n.push(o)}catch{}return n.slice(-e)},P6=(t,e)=>{let r=typeof t=="string"?Date.parse(t):Number.NaN;if(!Number.isFinite(r))return"";let n=Math.max(0,Math.round((e.getTime()-r)/1e3));return n<90?`${n}s ago`:n<5400?`${Math.round(n/60)} min ago`:n<36*3600?`${Math.round(n/3600)} h ago`:`${Math.round(n/86400)} d ago`},HI=new Set(["ack-unknown"]),P_=(t,e)=>{let r=typeof t.file=="string"?t.file:"(project)",n=P6(t.at,e),s=`${n?`${n} `:""}${r} `;switch(t.event){case"merge":{let o=Array.isArray(t.decisions)?t.decisions:[],i=o.filter(u=>u&&typeof u=="object"&&u.kept==="human").length,a=o.filter(u=>u&&typeof u=="object"&&u.kept==="human-unchanged-by-agent").length,c=Array.isArray(t.conflicts)?t.conflicts.length:0;if(t.status==="rejected"){let u=Array.isArray(t.problems)?t.problems.join("; "):"";return`${s}REJECTED your version (${u||"unreadable"}); the editor kept its own. Fix the file and write it again.`}let l=[];return(i>0||c>0)&&l.push(`the editor KEPT ${Math.max(i,c)} human value(s) over yours \u2014 \`pix3 read ${r}\`, then write again if yours is still meant`),a>0&&l.push(`${a} human value(s) kept where your file carried the old value`),`${s}merged${l.length?`: ${l.join("; ")}`:" cleanly"}`}case"ack-applied":return`${s}your read confirmation was applied (released ${Array.isArray(t.released)?t.released.length:0} protected value(s))`;case"ack-unknown":return`${s}read confirmation for a version the editor has not recorded \u2014 ignored (harmless: nothing is protected by it and there is nothing to do; it stops showing once the file changes)`;case"accept-agent":return`${s}the human accepted your version`;case"keep-mine":return`${s}the human kept their version over yours`;case"restore-version":return`${s}the human restored an earlier version`;case"reload":return`${s}reloaded your version`;default:return`${s}${String(t.event??"entry")}`}},O6=(t,e)=>{if(typeof t.hash!="string"||typeof t.file!="string")return!1;let r=e.get(t.file);return r!==void 0&&r!==t.hash},I6=t=>{let e=`${t.file}${t.line!==void 0?`:${t.line}`:""}`,r=t.nodeId!==void 0?` [${t.nodeId}]`:"",n=`${e} ${t.severity} ${t.code}${r} ${t.message}
399
+ `}});import{readFileSync as A_}from"node:fs";import{join as I_}from"node:path";var R_,rp,M_,js,Ds,Ma=O(()=>{"use strict";R_=15e3,rp=2e3,M_=t=>{try{let e=JSON.parse(A_(I_(t,".pix3","dev.json"),"utf8"));return typeof e.url=="string"?e.url:null}catch{return null}},js=async(t,e={})=>{if(e.noSync)return{status:"skipped"};let r=M_(t);if(!r)return{status:"no-server"};let n=e.timeoutMs??R_,s=`${r.endsWith("/")?r:`${r}/`}__pix3/api/`,i=e.probeTimeoutMs??rp;try{if(!(await fetch(`${s}hello`,{signal:AbortSignal.timeout(i)})).ok)return{status:"no-server"}}catch(o){return o instanceof Error&&(o.name==="TimeoutError"||o.name==="AbortError")?{status:"unsynced",url:r,reason:`the dev server accepted the connection but did not answer within ${i/1e3} s`}:{status:"no-server"}}try{let o=await fetch(`${s}flush`,{method:"POST",headers:{"Content-Type":"application/json","X-Pix3":"1"},body:JSON.stringify({timeoutMs:n}),signal:AbortSignal.timeout(n+rp)}),a=await o.json();return a.ok===!1?{status:"unsynced",url:r,reason:a.reason??`HTTP ${o.status}`}:a.editor?{status:"flushed",url:r}:{status:"no-editor",url:r}}catch(o){return{status:"unsynced",url:r,reason:o instanceof Error?o.message:String(o)}}},Ds=t=>`the Pix3 editor at ${t.url} did not flush its unsaved scenes (${t.reason}); save in the editor and retry, or pass --no-sync to read the disk as it is`});var L_,np,sp,ip,La=O(()=>{"use strict";de();L_={E_YAML:{severity:"error",level:1,summary:"the file is not valid YAML"},E_SHAPE:{severity:"error",level:1,summary:"document structure is wrong (root, node, component or override shape)"},E_UNKNOWN_NODE_TYPE:{severity:"error",level:1,summary:"unknown `type:`"},W_TYPE_CASE:{severity:"warning",level:1,summary:"`type:` loads, but is not the canonical spelling"},E_UNKNOWN_PROPERTY:{severity:"error",level:1,summary:"a key under `properties:` the loader never reads for this type"},W_WRITE_ONLY_PROPERTY:{severity:"warning",level:1,summary:"the editor saves this property but the loader does not read it back"},W_LEGACY_KEY:{severity:"warning",level:1,summary:"a read-compat spelling; the editor rewrites it on save"},E_PROPERTY_TYPE:{severity:"error",level:1,summary:"value has the wrong type"},E_PROPERTY_RANGE:{severity:"error",level:1,summary:"value rejected by the property's validation rule (e.g. fov > 0)"},W_PROPERTY_RANGE:{severity:"warning",level:1,summary:"number outside the inspector's min..max (a UI range, not a load error)"},E_PROPERTY_ENUM:{severity:"error",level:1,summary:"value is not one of the options"},E_UNKNOWN_COMPONENT:{severity:"error",level:1,summary:"unknown component type"},E_UNKNOWN_CONFIG_KEY:{severity:"error",level:1,summary:"component config key the component does not declare (`user:` ones at level 2)"},E_USER_SCRIPT_NOT_FOUND:{severity:"error",level:1,summary:"no script under scripts/ exports a Script class with this name"},E_MISSING_RESOURCE:{severity:"error",level:1,summary:"referenced file does not exist"},E_MISSING_PREFAB:{severity:"error",level:1,summary:"`instance:` target does not exist"},E_PREFAB_CYCLE:{severity:"error",level:1,summary:"prefab instances form a cycle"},E_PREFAB_ROOT:{severity:"error",level:1,summary:"an instanced prefab must have exactly one root node"},E_UNKNOWN_OVERRIDE_TARGET:{severity:"error",level:1,summary:"`overrides.byLocalId` names a node the prefab does not have"},E_DUPLICATE_ID:{severity:"error",level:1,summary:"two nodes share an id"},E_EMOJI_AS_ART:{severity:"error",level:1,summary:"text that is nothing but emoji \u2014 a picture standing in for a sprite"},E_SVG_INVALID:{severity:"error",level:1,summary:"a referenced .svg has no <svg> root or no SVG xmlns \u2014 the browser will not decode it"},E_SVG_NO_SIZE:{severity:"error",level:1,summary:"a referenced .svg has no usable width/height (and no viewBox to derive one)"},W_SVG_VIEWBOX_ONLY:{severity:"warning",level:1,summary:"a referenced .svg has a viewBox but no width/height \u2014 renders at 300x150"},W_SVG_EXTERNAL_REF:{severity:"warning",level:1,summary:"a referenced .svg points outside itself (href, url(), @import) \u2014 never loads as an image"},E_ANIM_JSON:{severity:"error",level:1,summary:"a .pix3anim is not a JSON object the loader can read (or its clips are not a list)"},E_MISSING_FRAME:{severity:"error",level:1,summary:"an image a .pix3anim names (a frame texturePath, the spritesheet) does not exist; its .svg frames get the E_SVG_* checks too"},E_LOCALE_MISSING:{severity:"error",level:1,summary:"the default or fallback locale has no locales/<id>.json \u2014 labelKeys show the key"},W_LOCALE_MISSING:{severity:"warning",level:1,summary:"another declared locale has no locales/<id>.json \u2014 its texts fall back"},E_LOCALE_JSON:{severity:"error",level:1,summary:"the default or fallback locale table is not a JSON object with strings/sprites maps \u2014 it loads empty"},W_LOCALE_JSON:{severity:"warning",level:1,summary:"another locale table is not a JSON object with strings/sprites maps \u2014 it loads empty"},E_LOCALE_VALUE:{severity:"error",level:1,summary:"a non-string value in the default or fallback locale table (the runtime drops it)"},W_LOCALE_VALUE:{severity:"warning",level:1,summary:"a non-string value in another locale table (the runtime drops it; the text falls back)"},E_LOCALE_KEY:{severity:"error",level:1,summary:"a labelKey the default (and fallback) locale has no text for \u2014 the key shows on screen"},E_LOCALE_SCRIPT_KEY:{severity:"error",level:1,summary:"a literal key a script passes to tr()/setTextKey()/trPlural() that the default (and fallback) locale has no text for \u2014 the key shows on screen"},E_LOCALE_SPRITE_KEY:{severity:"error",level:1,summary:"a Sprite2D textureKey no default (or fallback) sprites entry has, on a sprite with no texture of its own \u2014 it draws nothing"},W_LOCALE_SPRITE_KEY:{severity:"warning",level:1,summary:"a textureKey / stateTextureKeys / trSprite() key no default (or fallback) sprites entry has \u2014 the node's own texture shows in every locale, trSprite gives null"},E_MISSING_LOCALE_SPRITE:{severity:"error",level:1,summary:"an image a locale table's sprites names does not exist (its .svg ones get the E_SVG_* checks too)"},E_AUTOLOAD:{severity:"error",level:1,summary:"a pix3project.yaml autoload that never runs: no singleton/scriptPath, a repeated singleton, or a script that is missing, outside scripts/, or exports no Script class named like the file"},W_MANIFEST_EXPORT:{severity:"warning",level:1,summary:"pix3project.yaml has the 1.x export: block (prune / include / exclude globs), which no 2.x build reads"},W_LEGACY_VERSION:{severity:"warning",level:1,summary:"scene `version:` is missing or not the current format version"},W_UNUSED_ASSET:{severity:"warning",level:1,summary:"a file under sprites/ or audio/ nothing references (whole-project runs only)"},E_LOAD:{severity:"error",level:2,summary:"the loader rejected the scene or warned"},E_PENDING_COMPONENT:{severity:"error",level:2,summary:"a component stayed unregistered after the scripts compiled"},E_SCRIPT_COMPILE:{severity:"error",level:2,summary:"the project scripts do not compile"},W_SCRIPT_IMPORT:{severity:"warning",level:2,summary:"compiled scripts threw on import in Node; user: properties not checked"},W_HYDRATE_SKIPPED:{severity:"warning",level:2,summary:"scenes not loaded as the game loads them"},W_RENDERABILITY:{severity:"warning",level:2,summary:"the scene may not show anything (W_RENDERABILITY_<ISSUE>)"}},np=()=>`${I.validate}
400
+ Codes:
401
+ ${Object.entries(L_).map(([t,e])=>` ${t.padEnd(26)} L${e.level} ${e.summary}`).join(`
402
+ `)}
403
+ `,sp=t=>{let e=`${t.file}${t.line!==void 0?`:${t.line}`:""}`,r=t.nodeId!==void 0?` [${t.nodeId}]`:"",n=`${e} ${t.severity} ${t.code}${r} ${t.message}
208
404
  `;return t.path&&(n+=` at ${t.path}
209
405
  `),t.fix&&(n+=` fix: ${t.fix}
210
- `),n},tN=(t,e)=>{let r="",n=new Map,s=0;for(let d of t.diagnostics){let f=(n.get(d.code)??0)+1;if(n.set(d.code,f),f>k6){s+=1;continue}r+=I6(d)}s>0&&(r+=`\u2026 ${s} more (pix3 check --json lists them all)
211
- `);for(let d of t.notes)r+=`note: ${d}
212
- `;let o=new Map(t.files.map(d=>[d.file,d.sha256])),i=t.mergeLog.filter(d=>HI.has(d.event)&&!O6(d,o)),a=t.mergeLog.filter(d=>!HI.has(d.event));for(let d of i)r+=`note: ${P_(d,e)}
213
- `;if(a.length>0){r+=`merge-log (newest ${a.length}, .pix3/merge-log.jsonl):
214
- `;for(let d of a)r+=` ${P_(d,e)}
215
- `}let c=t.typecheck,l=c.typescript?`typecheck ${c.files} file(s) with TypeScript ${c.typescript.version} (${c.typescript.source}, ${c.tsconfig}): ${c.errors} error(s)`:c.skipped?`typecheck skipped: ${c.skipped}`:"typecheck did not run",u=t.level2.state==="ran"?`level 2 hydrated ${t.level2.filesHydrated} file(s)${t.level2.filesSkippedForScripts?`, ${t.level2.filesSkippedForScripts} SKIPPED (scripts do not compile \u2014 user: components unchecked)`:""}`:t.level2.state==="disabled"?"level 2 off":`level 2 skipped: ${t.level2.reason}`;return r+=`${l}; ${u}.
216
- `,t.kit.version===null&&(r+=`kit: none in this project (pix3 kit installs it).
217
- `),r+=`${t.errorCount===0?"OK":"FAILED"}: ${t.files.length} file(s) checked, ${t.errorCount} error(s), ${t.warningCount} warning(s) in ${t.timingsMs.total} ms.
218
- `,r},rN=t=>`${JSON.stringify(t,null,2)}
219
- `,N6=(t,e)=>t.file.localeCompare(e.file)||(t.line??0)-(e.line??0)||t.code.localeCompare(e.code),nN=async(t,e)=>{let r=Date.now(),s=await(e.validate??E6)({projectRoot:t,hydrate:e.hydrate}),o=Date.now()-r,i=[],a=[...s.notes],c=ei(t),l,u=null;if(c){l=rs;let S=QI(t);XI(t)?S===null?i.push(ni("W_RUNTIME_NOT_INSTALLED",{file:rs,message:`This project has its own tsconfig.json, so its scripts are type-checked against its own node_modules \u2014 and node_modules/@pix3/runtime is missing (this CLI ships ${be}).`,fix:"npm install in the project, then run pix3 check again"})):S!==be&&i.push(ni("W_RUNTIME_VERSION_MISMATCH",{file:"node_modules/@pix3/runtime/package.json",message:`The project type-checks against @pix3/runtime ${S}; this CLI (and its kit and validator) is ${be}. APIs the kit describes may be missing, or behave differently.`,fix:`npm install @pix3/runtime@${be}, or run the @pix3/cli@${S} that matches it`})):(u="dependencies not installed (run npm install)",i.push(ni("E_DEPENDENCIES_MISSING",{file:Tc(Ws(t,"package.json"))?"package.json":rs,message:"This project has its own tsconfig.json, so its scripts are type-checked against its own node_modules \u2014 and there is no node_modules. The type-check was skipped; the scenes were still validated.",fix:"npm install"})))}else{l=Bs;let{ensureRuntimeTypes:S}=await Promise.resolve().then(()=>(Sc(),kf)),T=S({log:e.log});Nf(t,T.manifest)||(Cf(t,T),a.push(`Wrote the @pix3/runtime ${T.manifest.runtimeVersion} types to .pix3/types/ (and ${Bs}).`))}let d=Date.now(),f=null,p=null;if(u===null)try{f=await qI({projectRoot:t,offline:e.offline,log:e.log,...e.typescript}),p=MI(f.ts,t,l)}catch(S){let T=S instanceof ri?S.command:void 0;i.push(ni("E_TYPECHECK_UNAVAILABLE",{file:l,message:S instanceof Error?S.message:String(S),fix:T}))}let m=Date.now()-d,h=(p?.errors??[]).map(S=>ni("E_TYPE",{file:S.file,line:S.line,message:`${S.tsCode}: ${S.message}`}));i.push(...h);let g=YI(t),y=g===be;g!==null&&!y&&i.push(ni("W_KIT_OUTDATED",{file:xe,path:"metadata.agentKit.version",message:`The agent kit here is ${g}; this CLI is ${be}.`,fix:"pix3 kit --update (it never overwrites kit files you edited)"}));let w=new Map;for(let S of s.files)w.set(S.file,S.sha256);for(let S of p?.files??[]){if(S.startsWith("/")||/^[A-Za-z]:/.test(S))continue;let T=Ws(t,S);!w.has(S)&&Tc(T)&&w.set(S,T6(T))}let b=[...s.diagnostics,...[...i].sort(N6)],x=b.filter(S=>S.severity==="error").length,v=b.filter(S=>S.code==="E_TYPE"||S.code==="E_TYPECHECK_UNAVAILABLE"||S.code==="E_DEPENDENCIES_MISSING").length;return{ok:x===0,projectRoot:t,errorCount:x,warningCount:b.filter(S=>S.severity==="warning").length,level2:s.level2,files:[...w.entries()].sort(([S],[T])=>S<T?-1:S>T?1:0).map(([S,T])=>({file:S,sha256:T})),diagnostics:b,notes:a,typecheck:{ok:v===0,errors:v,tsconfig:l,mode:c?"project":"pix3-types",files:p?.files.length??0,typescript:f?{version:f.version,source:f.source}:null,skipped:u},mergeLog:eN(t),kit:{version:g,cliVersion:be,upToDate:y},timingsMs:{validate:o,typecheck:m,total:Date.now()-r}}},C6=async(t,e)=>{let r=x6(t);if("error"in r)return e.stderr(`pix3 check: ${r.error}
220
-
221
- ${T_}`),2;if(r.help)return e.stdout(`${T_}
406
+ `),n},ip=t=>t.state==="ran"?`${t.filesHydrated} scene file(s) loaded as the game loads them${t.filesSkippedForScripts?`, ${t.filesSkippedForScripts} NOT loaded (scripts do not compile \u2014 user: components unchecked)`:""}`:t.state==="disabled"?"scenes not loaded (--no-hydrate)":`scenes not loaded: ${t.reason}`});import{existsSync as j_,readFileSync as D_}from"node:fs";import{join as op}from"node:path";var F_,ap,q_,lp,ja,Fs,cp,Da=O(()=>{"use strict";se();Ie();Re();F_=["@pix3/cli","@pix3/vite-plugin","@pix3/editor-core"],ap=t=>{try{let e=JSON.parse(D_(t,"utf8")).version;return typeof e=="string"?e:null}catch{return null}},q_=()=>{let t=op(ie(),"..","runtime","package.json");return(j_(t)?ap(t):null)??F},lp=(t,e)=>{let r=tt(t,op("node_modules",...e.split("/"),"package.json"));return r===null?null:ap(r)},ja=t=>lp(t,"@pix3/runtime"),Fs=t=>{let e=ja(t),r=q_();return e===null||e===r?null:{installed:e,bundled:r,message:`The project installs @pix3/runtime ${e}, but this CLI validates and runs scenes with the @pix3/runtime ${r} bundled into it \u2014 its answers would be about an engine the game does not ship.`,fix:`run the project's own CLI (npx pix3 \u2026, the @pix3/cli its package.json pins with runtime ${e}), or npm install @pix3/runtime@${r} @pix3/cli@${r}`}},cp=t=>F_.flatMap(e=>{let r=lp(t,e);return r!==null&&r!==F?[{name:e,installed:r}]:[]})});var Fa,up,qa,dp,B_,U_,K_,W_,V_,qs,Bs=O(()=>{"use strict";Fa=["scripts","src/scripts"],up=["design/tests/bots"],qa=/\.(?:spec|test)\.ts$|\.d\.ts$/,dp=(t,e=Fa)=>t.endsWith(".ts")&&!qa.test(t)&&e.some(r=>t.startsWith(`${r}/`)),B_=t=>t.replace(/\/\*[\s\S]*?\*\//g," ").replace(/(^|[^:\\])\/\/.*$/gm,"$1"),U_=/\bexport\s+(default\s+)?(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)?/g,K_=/\bexport\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*class\b/g,W_=/\bexport\s+(type\s+)?\{([^}]*)\}/g,V_=/\bexport\s+\*\s+(?:as\s+[A-Za-z_$][\w$]*\s+)?from\b/,qs=t=>{let e=B_(t),r=[];for(let n of e.matchAll(U_))r.push(n[1]?"default":n[2]??"default");for(let n of e.matchAll(K_))r.push(n[1]);for(let n of e.matchAll(W_))if(!n[1])for(let s of n[2].split(",")){let i=s.trim();if(!i||i.startsWith("type "))continue;let o=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(i);r.push(o?o[1]:i.split(/\s+/)[0])}return{names:r,hasStar:V_.test(e)}}});import{existsSync as G_,readdirSync as J_,readFileSync as H_,statSync as Y_}from"node:fs";import{dirname as z_,isAbsolute as X_,join as Xr,relative as Q_,resolve as Z_,sep as e0}from"node:path";var t0,hp,fp,mp,r0,n0,s0,i0,Ba,Ua,o0,a0,l0,c0,pp,Us,u0,d0,gp,yp=O(()=>{"use strict";Bs();t0=[...Fa,...up],hp=new Set(["node_modules",".git","dist",".pix3"]),fp=[".ts",".tsx",".mts",".js",".mjs",".jsx"],mp=/\.(?:css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:\?(.*))?$/,r0=/(?:^|&)(?:raw|url|inline)(?:&|=|$)/,n0=new Set("(,=:[!&|?{};+-*%<>~^".split("")),s0=/(?:^|[^\w$])(?:return|typeof|case|do|else|in|of|new|delete|void|throw|yield|await)$/,i0=t=>{let e=t.split(""),r=new Map,n=(u,f)=>{for(let d=u;d<f;d++)e[d]!==`
407
+ `&&(e[d]=" ")},s=[],i=[],o=0,a=0,l=()=>{for(let u=a-1;u>=0;u--)if(!/\s/.test(e[u]))return e[u];return""},c=(u,f)=>{let d=f,h="";for(;d<t.length;){let g=t[d];if(g==="\\"){h+=t.slice(d,d+2),d+=2;continue}if(g==="`"){n(f,d);let p=r.get(u);r.set(u,{start:u,end:d+1,value:(p?.value??"")+h,substituted:p?.substituted??!1}),a=d+1;return}if(g==="$"&&t[d+1]==="{"){n(f,d);let p=r.get(u);r.set(u,{start:u,end:d,value:(p?.value??"")+h,substituted:!0}),s.push(o),o+=1,i.push(u),a=d+2;return}h+=g,d+=1}n(f,d),a=d};for(;a<t.length;){let u=t[a],f=t[a+1];if(u==="/"&&f==="/"){let d=t.indexOf(`
408
+ `,a),h=d===-1?t.length:d;n(a,h),a=h;continue}if(u==="/"&&f==="*"){let d=t.indexOf("*/",a+2),h=d===-1?t.length:d+2;n(a,h),a=h;continue}if(u==="'"||u==='"'){let d=a+1,h="";for(;d<t.length&&t[d]!==u&&t[d]!==`
409
+ `;){if(t[d]==="\\"){h+=t.slice(d,d+2),d+=2;continue}h+=t[d],d+=1}r.set(a,{start:a,end:d+1,value:h,substituted:!1}),n(a+1,d),a=d+1;continue}if(u==="`"){c(a,a+1);continue}if(u==="/"){let d=l(),h=e.slice(Math.max(0,a-12),a).join("").trimEnd();if(d===""||n0.has(d)||s0.test(h)){let g=a+1,p=!1;for(;g<t.length&&t[g]!==`
410
+ `;){let m=t[g];if(m==="\\"){g+=2;continue}if(m==="[")p=!0;else if(m==="]")p=!1;else if(m==="/"&&!p)break;g+=1}n(a+1,g),a=g+1;continue}}if(u==="{"&&(o+=1),u==="}"&&(o-=1,s.length>0&&s[s.length-1]===o)){s.pop();let d=i.pop();c(d,a+1);continue}a+=1}return{masked:e.join(""),strings:r}},Ba=(t,e)=>{let r=1;for(let n=0;n<e&&n<t.length;n++)t[n]===`
411
+ `&&(r+=1);return r},Ua=(t,e)=>{let r=t.lastIndexOf(`
412
+ `,e-1)+1,n=t.indexOf(`
413
+ `,e),s=t.slice(r,n===-1?t.length:n).trim();return s.length>120?`${s.slice(0,117)}...`:s},o0=/(?<![\w$.])import\s*\(/g,a0=/(?<![\w$.])import\s*\.\s*meta\s*(?:\?\s*)?\.\s*hot(?![\w$])/g,l0=/(?:(?<![\w$.])from|(?<![\w$.])import|(?<![\w$.])import\s*\()\s*$/,c0=t=>{let{masked:e,strings:r}=i0(t),n=[],s=[];for(let i of e.matchAll(a0)){let o=i.index??0;n.push({kind:"import-meta-hot",line:Ba(t,o),text:Ua(t,o)})}for(let i of e.matchAll(o0)){let o=i.index??0,a=o+i[0].length;for(;a<e.length&&/\s/.test(e[a]);)a+=1;let l=r.get(a);if(l&&!l.substituted){let c=l.end;for(;c<e.length&&/\s/.test(e[c]);)c+=1;if(e[c]===")"||e[c]===",")continue}n.push({kind:"dynamic-import",line:Ba(t,o),text:Ua(t,o)})}for(let i of r.values()){if(i.substituted||!l0.test(e.slice(Math.max(0,i.start-40),i.start)))continue;s.push({value:i.value,offset:i.start});let o=mp.exec(i.value);o&&!r0.test(o[1]??"")&&n.push({kind:"css-import",line:Ba(t,i.start),text:Ua(t,i.start)})}return n.sort((i,o)=>i.line-o.line),{specifiers:s,issues:n}},pp=(t,e)=>{let r=Q_(t,e);if(!r||r.startsWith("..")||X_(r))return null;let n=r.split(e0).join("/");return n.split("/").some(s=>hp.has(s))?null:n},Us=t=>{try{return Y_(t).isFile()}catch{return!1}},u0=(t,e,r)=>{let n=r.split("?")[0],s;if(n.startsWith("./")||n.startsWith("../"))s=Z_(z_(e),n);else if(n.startsWith("/")&&!n.startsWith("//"))s=Xr(t,n);else return null;if(Us(s))return s;let i=s.replace(/\.(?:js|mjs|jsx)$/,o=>o===".mjs"?".mts":o===".jsx"?".tsx":".ts");if(i!==s&&Us(i))return i;for(let o of fp)if(Us(`${s}${o}`))return`${s}${o}`;for(let o of fp){let a=Xr(s,`index${o}`);if(Us(a))return a}return null},d0=t=>{let e=[],r=n=>{let s;try{s=J_(n,{withFileTypes:!0})}catch{return}for(let i of s.sort((o,a)=>o.name.localeCompare(a.name)))i.isDirectory()?hp.has(i.name)||r(Xr(n,i.name)):i.name.endsWith(".ts")&&!qa.test(i.name)&&e.push(Xr(n,i.name))};for(let n of t0){let s=Xr(t,...n.split("/"));G_(s)&&r(s)}return e},gp=t=>{let e=[],r=[],n=new Set,s=[];for(let i of d0(t)){let o=pp(t,i);o!==null&&s.push({absolute:i,via:o})}for(;s.length>0;){let{absolute:i,via:o}=s.shift();if(n.has(i))continue;n.add(i);let a=pp(t,i);if(a===null)continue;let l;try{l=H_(i,"utf8")}catch{continue}e.push(a);let c=c0(l);for(let u of c.issues)r.push({...u,file:a,via:o});for(let{value:u}of c.specifiers){let f=u0(t,i,u);f&&!n.has(f)&&!mp.test(f)&&s.push({absolute:f,via:o})}}return{files:e,issues:r}}});import{isAbsolute as f0,relative as p0,resolve as h0,sep as m0}from"node:path";var Ks,Sp,bp=O(()=>{"use strict";Ks=(t,e)=>{let r=p0(t,e);return r&&!r.startsWith("..")&&!f0(r)?r.split(m0).join("/"):e},Sp=(t,e,r)=>{let n=Date.now(),s=[],i=h0(e,r),o=Ks(e,i),a=d=>{let h=t.flattenDiagnosticMessageText(d.messageText,`
414
+ `),g=`TS${d.code}`;if(d.file&&d.start!==void 0){let{line:p,character:m}=d.file.getLineAndCharacterOfPosition(d.start);return{file:Ks(e,d.file.fileName),line:p+1,column:m+1,tsCode:g,message:h}}return{file:d.file?Ks(e,d.file.fileName):o,tsCode:g,message:h}},l=[],c=t.getParsedCommandLineOfConfigFile(i,{noEmit:!0},{...t.sys,onUnRecoverableConfigFileDiagnostic:d=>l.push(d)});if(!c)return{tsconfig:o,files:[],errors:l.map(a),durationMs:Date.now()-n};let u=18003;for(let d of[...l,...c.errors])d.code!==u&&s.push(a(d));let f=c.fileNames.map(d=>Ks(e,d)).sort();if(c.fileNames.length>0){let d=t.createProgram({rootNames:c.fileNames,options:{...c.options,noEmit:!0},projectReferences:c.projectReferences});for(let h of t.getPreEmitDiagnostics(d))s.push(a(h))}return{tsconfig:o,files:f,errors:s,durationMs:Date.now()-n}}});import{spawnSync as g0}from"node:child_process";import{existsSync as Ka,mkdirSync as y0}from"node:fs";import{createRequire as wp}from"node:module";import{homedir as S0}from"node:os";import{join as Te}from"node:path";import{fileURLToPath as b0,pathToFileURL as w0}from"node:url";var Ws,Qt,x0,v0,_0,E0,k0,C0,Qr,xp,vp=O(()=>{"use strict";Ws="5.8.3",Qt=class extends Error{command;constructor(e,r){super(e),this.command=r}},x0=()=>Te(S0(),".pix3","typescript"),v0=(t,e=Ws)=>`npm install --prefix ${JSON.stringify(t)} typescript@${e} --no-save --no-package-lock --no-audit --no-fund --loglevel=error`,_0=t=>{try{return Te(t.resolve("typescript/package.json"),"..")}catch{return null}},E0=t=>_0(wp(Te(t,"__pix3_check__.js"))),k0=()=>{try{let t=import.meta.resolve("typescript");return Te(b0(t),"..","..")}catch{return null}},C0=(t,e)=>{y0(t,{recursive:!0});let r=process.platform==="win32"?"npm.cmd":"npm",n=g0(r,["install","--prefix",t,`typescript@${e}`,"--no-save","--no-package-lock","--no-audit","--no-fund","--loglevel=error"],{encoding:"utf8",stdio:["ignore","pipe","pipe"],shell:process.platform==="win32"});return n.error?n.error.message:n.status!==0?(n.stderr||n.stdout||`exit ${n.status}`).trim():null},Qr=async t=>{let r=wp(Te(t,"package.json")).resolve("typescript"),n=await import(w0(r).href),s=n.default??n;if(typeof s.createProgram!="function")throw new Error(`${r} is not the TypeScript compiler API`);return{ts:s,version:s.version}},xp=async t=>{let e=process.env.PIX3_TYPESCRIPT;if(e){let{ts:l,version:c}=await Qr(e);return{ts:l,version:c,source:"env",dir:e}}let r=E0(t.projectRoot);if(r)return{...await Qr(r),source:"project",dir:r};let n=t.skipCliSibling?null:k0();if(n&&Ka(Te(n,"package.json")))return{...await Qr(n),source:"cli",dir:n};let s=Te(t.cacheRoot??x0(),Ws),i=Te(s,"node_modules","typescript"),o=v0(s);if(Ka(Te(i,"package.json")))return{...await Qr(i),source:"cache",dir:i};if(t.offline)throw new Qt(`TypeScript is not installed for pix3 check, and --offline forbids installing it. Run once:
415
+ ${o}`,o);t.log?.(`pix3 check: installing TypeScript ${Ws} once into ${s}
416
+ $ ${o}`);let a=(t.install??C0)(s,Ws);if(a!==null||!Ka(Te(i,"package.json")))throw new Qt(`Could not install TypeScript (${a??"npm reported success but nothing was installed"}). Run it yourself:
417
+ ${o}`,o);return{...await Qr(i),source:"installed",dir:i}}});var _p=x(()=>{throw new Error("src\\validate\\bundle.ts is only available in a checkout of the pix3 repo (the published @pix3/cli ships its bundles prebuilt)")});var Wa={};X(Wa,{runValidateCli:()=>$0,withValidateBundle:()=>kp});import{join as O0}from"node:path";import{pathToFileURL as T0}from"node:url";var Ep,P0,kp,$0,Va=O(()=>{"use strict";Ie();La();Ep="bundle-main.js",P0=async t=>await import(T0(O0(t,Ep)).href),kp=t=>ws("validate",Ep,async e=>(await Promise.resolve().then(()=>U(_p(),1))).buildValidateBundle(e),async e=>t(await P0(e),xs())),$0=async(t,e)=>t.includes("--help")||t.includes("-h")?(e.stdout(np()),0):kp((r,n)=>r.runBundledValidate(t,{...e,esbuildSpecifier:n}))});var Np={};X(Np,{CHECK_CODES:()=>Ja,checkProject:()=>$p,formatCheckHuman:()=>Tp,formatCheckJson:()=>Pp,runCheck:()=>j0});import{existsSync as Cp,readFileSync as Op}from"node:fs";import{join as Ga}from"node:path";var Ja,N0,A0,I0,R0,ot,M0,Tp,Pp,L0,$p,j0,Ap=O(()=>{"use strict";Ma();se();Z();Is();de();La();Re();Da();yp();bp();vp();Ja={E_TYPE:{severity:"error",summary:"a TypeScript error in a project script"},E_DEPENDENCIES_MISSING:{severity:"error",summary:"the project has its own tsconfig.json but no node_modules: run npm install (the type-check was skipped)"},E_TYPECHECK_UNAVAILABLE:{severity:"error",summary:"TypeScript could not be found or installed, so the scripts were not type-checked"},E_EDITOR_UNSYNCED:{severity:"error",summary:"a running Pix3 editor did not flush its unsaved scenes in time, so the disk may be older than what the designer sees (--no-sync reads it anyway)"},E_RUNTIME_VERSION:{severity:"error",summary:"the project's node_modules/@pix3/runtime is not the runtime this CLI validates with (run the project's own CLI, or install the matching runtime)"},W_PIX3_VERSION_MISMATCH:{severity:"warning",summary:"an installed @pix3/cli, @pix3/vite-plugin or @pix3/editor-core is not this CLI's version (the packages are released in lockstep)"},W_RUNTIME_NOT_INSTALLED:{severity:"warning",summary:"the project has its own tsconfig.json and node_modules, but no node_modules/@pix3/runtime"},W_KIT_OUTDATED:{severity:"warning",summary:"the agent kit in this project was written by another CLI version"},W_EDITOR_HMR_API:{severity:"warning",summary:"import.meta.hot in a module the editor runs (a script, a bot policy or what they import): Vite puts its HMR client on the editor page, and a full-reload of the game reloads the editor"},W_EDITOR_CSS_IMPORT:{severity:"warning",summary:"a stylesheet imported by a module the editor runs: Vite puts its HMR client on the editor page"},W_EDITOR_DYNAMIC_IMPORT:{severity:"warning",summary:"a non-literal import() in a module the editor runs: Vite wraps it with a helper from its HMR client, which then loads on the editor page"}},N0={"import-meta-hot":{code:"W_EDITOR_HMR_API",what:"`import.meta.hot`",fix:"remove it: the editor re-imports scripts on pix3_sync, a script needs no HMR code (put HMR handling in src/main.ts if the game wants it)"},"css-import":{code:"W_EDITOR_CSS_IMPORT",what:"a stylesheet import",fix:"import the stylesheet from the game's entry (src/main.ts), or as a string with `?inline`"},"dynamic-import":{code:"W_EDITOR_DYNAMIC_IMPORT",what:"a non-literal `import()`",fix:"use a plain string, import('./levels/one.ts'), a static import, or import.meta.glob for a table of modules"}},A0=40,I0=t=>{let e=!1,r=!0,n=!1,s=!0,i,o=!1;for(let a=0;a<t.length;a++){let l=t[a];if(l==="--json")e=!0;else if(l==="--no-hydrate")r=!1;else if(l==="--offline")n=!0;else if(l==="--no-sync")s=!1;else if(l==="--help"||l==="-h")o=!0;else if(l==="--project"){if(i=t[++a],!i||i.startsWith("--"))return{error:"--project needs a folder"}}else if(l.startsWith("--project="))i=l.slice(10);else return{error:`unknown argument ${l}`}}return{json:e,hydrate:r,offline:n,sync:s,project:i,help:o}},R0=async t=>{let{withValidateBundle:e}=await Promise.resolve().then(()=>(Va(),Wa));return e((r,n)=>r.validateBundledProject({...t,esbuildSpecifier:n}))},ot=(t,e)=>({severity:Ja[t].severity,code:t,...e}),M0=t=>tt(t,"node_modules")!==null,Tp=t=>{let e="",r=new Map,n=0;for(let a of t.diagnostics){let l=(r.get(a.code)??0)+1;if(r.set(a.code,l),l>A0){n+=1;continue}e+=sp(a)}n>0&&(e+=`\u2026 ${n} more (pix3 check --json lists them all)
418
+ `);for(let a of t.notes)e+=`note: ${a}
419
+ `;let s=t.typecheck,i=s.typescript?`typecheck ${s.files} file(s) with TypeScript ${s.typescript.version} (${s.typescript.source}, ${s.tsconfig}): ${s.errors} error(s)`:s.skipped?`typecheck skipped: ${s.skipped}`:"typecheck did not run",o=ip(t.level2);return e+=`${i}; ${o}.
420
+ `,t.kit.version===null&&(e+=`kit: none in this project (pix3 kit installs it).
421
+ `),e+=`${t.errorCount===0?"OK":"FAILED"}: ${t.files.length} file(s) checked, ${t.errorCount} error(s), ${t.warningCount} warning(s) in ${t.timingsMs.total} ms.
422
+ `,e},Pp=t=>`${JSON.stringify(t,null,2)}
423
+ `,L0=(t,e)=>t.file.localeCompare(e.file)||(t.line??0)-(e.line??0)||t.code.localeCompare(e.code),$p=async(t,e)=>{let r=Date.now(),n=await js(t,{noSync:e.sync===!1}),s=[];n.status==="unsynced"&&s.push({code:"E_EDITOR_UNSYNCED",severity:"error",file:K,message:Ds(n)});let o=await(e.validate??R0)({projectRoot:t,hydrate:e.hydrate}),a=Date.now()-r,l=[...o.notes];n.status==="flushed"&&l.push(`editor at ${n.url} flushed its unsaved scenes`);let c=Ht(t),u,f=null;if(c){u=it;let b=ja(t);M0(t)?b===null&&s.push(ot("W_RUNTIME_NOT_INSTALLED",{file:it,message:`This project has its own tsconfig.json, so its scripts are type-checked against its own node_modules \u2014 and node_modules/@pix3/runtime is missing (this CLI ships ${F}).`,fix:"npm install in the project, then run pix3 check again"})):(f="dependencies not installed (run npm install)",s.push(ot("E_DEPENDENCIES_MISSING",{file:Cp(Ga(t,"package.json"))?"package.json":it,message:"This project has its own tsconfig.json, so its scripts are type-checked against its own node_modules \u2014 and there is no node_modules. The type-check was skipped; the scenes were still validated.",fix:"npm install"})))}else{u=wt;let{ensureRuntimeTypes:b}=await Promise.resolve().then(()=>(Yr(),ks)),C=b({log:e.log});Ns(t,C.manifest)||(As(t,C),l.push(`Wrote the @pix3/runtime ${C.manifest.runtimeVersion} types to .pix3/types/ (and ${wt}).`))}let d=Date.now(),h=null,g=null;if(f===null)try{h=await xp({projectRoot:t,offline:e.offline,log:e.log,...e.typescript}),g=Sp(h.ts,t,u)}catch(b){let C=b instanceof Qt?b.command:void 0;s.push(ot("E_TYPECHECK_UNAVAILABLE",{file:u,message:b instanceof Error?b.message:String(b),fix:C}))}let p=Date.now()-d,m=(g?.errors??[]).map(b=>ot("E_TYPE",{file:b.file,line:b.line,message:`${b.tsCode}: ${b.message}`}));s.push(...m);let y=Fs(t);y&&s.push(ot("E_RUNTIME_VERSION",{file:"node_modules/@pix3/runtime/package.json",message:y.message,fix:y.fix}));for(let b of cp(t))s.push(ot("W_PIX3_VERSION_MISMATCH",{file:`node_modules/${b.name}/package.json`,message:`${b.name} ${b.installed} is installed; this CLI is ${F}. The @pix3/* packages are released in lockstep, so the editor or the build may differ from what the kit and the CLI describe.`,fix:`npm install ${b.name}@${F}`}));let w=ys(t),_=w===F;w!==null&&!_&&s.push(ot("W_KIT_OUTDATED",{file:K,path:"metadata.agentKit.version",message:`The agent kit here is ${w}; this CLI is ${F}.`,fix:"pix3 kit --update (it never overwrites kit files you edited)"}));let v=gp(t);for(let b of v.issues){let C=N0[b.kind];s.push(ot(C.code,{file:b.file,line:b.line,message:`${C.what} in a module the editor runs${b.via!==b.file?` (imported from ${b.via})`:""}: \`${b.text}\`. Vite then loads /@vite/client into the editor page, and the game's full-reload reaches the editor (unsaved edits are lost).`,fix:C.fix}))}let E=new Map;for(let b of o.files)E.set(b.file,b.sha256);for(let b of g?.files??[]){if(b.startsWith("/")||/^[A-Za-z]:/.test(b))continue;let C=Ga(t,b);!E.has(b)&&Cp(C)&&E.set(b,Se(Op(C)))}for(let b of v.files)E.has(b)||E.set(b,Se(Op(Ga(t,b))));let k=[...o.diagnostics,...[...s].sort(L0)],T=k.filter(b=>b.severity==="error").length,S=k.filter(b=>b.code==="E_TYPE"||b.code==="E_TYPECHECK_UNAVAILABLE"||b.code==="E_DEPENDENCIES_MISSING").length;return{ok:T===0,projectRoot:t,errorCount:T,warningCount:k.filter(b=>b.severity==="warning").length,level2:o.level2,files:[...E.entries()].sort(([b],[C])=>b<C?-1:b>C?1:0).map(([b,C])=>({file:b,sha256:C})),diagnostics:k,notes:l,typecheck:{ok:S===0,errors:S,tsconfig:u,mode:c?"project":"pix3-types",files:g?.files.length??0,typescript:h?{version:h.version,source:h.source}:null,skipped:f},kit:{version:w,cliVersion:F,upToDate:_},timingsMs:{validate:a,typecheck:p,total:Date.now()-r}}},j0=async(t,e)=>{let r=I0(t);if("error"in r)return e.stderr(`pix3 check: ${r.error}
424
+
425
+ ${I.check}`),2;if(r.help)return e.stdout(`${I.check}
222
426
  Codes added to validate's (pix3 validate --help lists those):
223
- ${Object.entries(I_).map(([i,a])=>` ${i.padEnd(28)} ${a.summary}`).join(`
427
+ ${Object.entries(Ja).map(([o,a])=>` ${o.padEnd(28)} ${a.summary}`).join(`
224
428
  `)}
225
- `),0;let n=r.project?O_(e.cwd,r.project):e.cwd,s=r.project?n:Qe(n);if(!s||!Tc(Ws(s,xe)))return e.stderr(`pix3 check: no pix3project.yaml in ${n}${r.project?"":" or any parent folder"}. Run it inside a Pix3 project, or pass --project <dir>.
226
- `),2;let o=await nN(s,{hydrate:r.hydrate,offline:r.offline,validate:e.validate,typescript:e.typescript,log:i=>e.stderr(`${i}
227
- `)});return e.stdout(r.json?rN(o):tN(o,e.now?.()??new Date)),o.errorCount>0?1:0}});var iN={};Je(iN,{runKitCli:()=>j6});import{existsSync as R6}from"node:fs";import{join as A6,resolve as z6}from"node:path";var j6,aN=$(()=>{"use strict";ut();Rf();S_();p_();j6=async t=>{let e=t.projectDir?z6(t.cwd,t.projectDir):t.cwd,r=t.projectDir?e:Qe(e);if(!r||!R6(A6(r,xe)))return process.stderr.write(`pix3 kit: no ${xe} in ${e}${t.projectDir?"":" or any parent folder"}. Run it inside a Pix3 project, or pass --project <dir>.
228
- `),2;let n=a=>{process.stderr.write(`${a}
229
- `)},s=await f_({log:n}),o=ei(r)?void 0:(await Promise.resolve().then(()=>(Sc(),kf))).ensureRuntimeTypes({log:n}),i=jf(r,s,{update:t.update,runtimeTypes:o});return process.stdout.write(b_(i,r)),0}});var Jt,N_,cN,C_,lN,uN,dN,si,R_,qf,fN,pN,hN,Ff,A_,mN,gN,Tr=$(()=>{"use strict";Jt="127.0.0.1",N_=Array.from({length:10},(t,e)=>8490+e),cN=["https://editor.pix3.dev","http://localhost:8123","http://127.0.0.1:8123"],C_=".pix3/link",lN=1e4,uN=1e4,dN=25e3,si=6e4,R_=1,qf=N_,fN=".pix3/workspace.json",pN=5e3,hN=1e4,Ff=1e4,A_=100,mN=1e4,gN=3e4});var M,z_,yN,j_,Xr,oi,M6,ii,Zf,Gt,Pc=$(()=>{"use strict";Tr();M=class extends Error{status;code;extra;constructor(e,r,n,s={}){super(n),this.status=e,this.code=r,this.extra=s}},z_=t=>!!t&&typeof t=="object"&&!Array.isArray(t),yN=1024*1024,j_=(t,e=yN)=>new Promise((r,n)=>{let s=[],o=0;t.on("data",i=>{if(o+=i.length,o>e){n(new M(413,"too_large","Request body too large.")),t.destroy();return}s.push(i)}),t.on("end",()=>r(Buffer.concat(s).toString("utf8"))),t.on("error",n)}),Xr=async(t,e=yN)=>{let r=await j_(t,e);if(!r.trim())return{};try{let n=JSON.parse(r);if(z_(n))return n}catch{}throw new M(400,"bad_json","Body must be a JSON object.")},oi=t=>{let e=(t??"").trim().toLowerCase();if(!e)return!1;let r,n="";if(e.startsWith("[")){let s=e.indexOf("]");if(s<0)return!1;r=e.slice(0,s+1);let o=e.slice(s+1);if(o&&!o.startsWith(":"))return!1;n=o.slice(1)}else{let s=e.indexOf(":");if(r=s<0?e:e.slice(0,s),n=s<0?"":e.slice(s+1),s>=0&&!n)return!1}return n&&!/^\d{1,5}$/.test(n)?!1:r==="localhost"||r==="127.0.0.1"||r==="[::1]"},M6=/^http:\/\/(localhost|127\.0\.0\.1|\[::1\])(:\d{1,5})?$/,ii=t=>t===null||cN.includes(t)||M6.test(t),Zf=t=>{let e=t.headers.origin;return typeof e=="string"?e:null},Gt=(t,e,r,n,s={})=>{if(t.writableEnded||t.destroyed)return;let o={"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store",...s};n&&(o["Access-Control-Allow-Origin"]=n,o.Vary="Origin"),t.writeHead(e,o),t.end(JSON.stringify(r))}});import{lstat as L6,realpath as D6}from"node:fs/promises";import{basename as q6,join as _N}from"node:path";var At,F6,Pr,M_,Z6,lr,wn,U6,bn,V6,Oc,Uf=$(()=>{"use strict";Pc();At=".pix3",F6=new Set(["workspace.json","serve.lock","tmp","link"]),Pr=".pix3/ack.json",M_=t=>{let e=t.split("/");return e[0].toLowerCase()!==At?!1:e.length===1?!0:F6.has(e[1].toLowerCase())},Z6=4096,lr=t=>new M(400,"bad_path",t),wn=(t,e="path")=>{if(typeof t!="string"||t.length===0)throw lr(`\`${e}\` must be a non-empty string.`);if(t.length>Z6)throw lr(`\`${e}\` is too long.`);if(t.includes("\0"))throw lr(`\`${e}\` contains a NUL byte.`);if(t.includes("\\"))throw lr(`\`${e}\` must use "/" separators, not backslashes.`);if(t.startsWith("/"))throw lr(`\`${e}\` must be relative to the workspace root.`);if(/^[A-Za-z]:/.test(t))throw lr(`\`${e}\` must not carry a drive letter.`);let r=t.split("/");for(let n of r){if(n==="")throw lr(`\`${e}\` has an empty segment (leading, trailing or double "/").`);if(n==="."||n==="..")throw lr(`\`${e}\` must not contain "." or "..".`);if(n.includes(":"))throw lr(`\`${e}\` must not contain ":" (a drive or an NTFS stream name).`);if(n.endsWith(".")||n.endsWith(" "))throw lr(`\`${e}\` has a segment ending in "." or a space.`)}if(M_(t))throw new M(403,"reserved_path",`\`${At}\` itself and \`${At}/workspace.json\`, \`serve.lock\`, \`tmp/\` and \`link/\` belong to the server.`);return t},U6=t=>t&&typeof t=="object"&&"code"in t?String(t.code):void 0,bn=async(t,e,r)=>{let n=e.split("/"),s=t;for(let o=0;o<n.length;o++){s=_N(s,n[o]);let i=o===n.length-1,a;try{a=await L6(s)}catch(c){let l=U6(c);if(l==="ENOENT"){if(!r.allowMissing)throw new M(404,"not_found",`${e} does not exist.`);return{absolute:_N(t,...n),kind:null}}throw l==="ENOTDIR"?new M(409,"not_a_directory",`A parent of ${e} is not a directory.`):c}if(a.isSymbolicLink())throw new M(403,"symlink",`${e} goes through a symbolic link; the workspace server does not follow them.`);if(!i&&!a.isDirectory())throw new M(409,"not_a_directory",`A parent of ${e} is not a directory.`);if(process.platform==="win32"&&await V6(s,n[o],e),i)return{absolute:s,kind:a.isFile()?"file":a.isDirectory()?"dir":"other"}}throw lr("Empty path.")},V6=async(t,e,r)=>{let n=q6(await D6(t));if(n.toLowerCase()!==e.toLowerCase())throw lr(`${r} uses "${e}", an alias of "${n}"; use the long name.`)},Oc=t=>{let e=t.lastIndexOf("/");return e<0?null:t.slice(0,e)}});import{createHash as B6,randomBytes as SN,randomUUID as K6,timingSafeEqual as H6}from"node:crypto";import{chmodSync as W6,existsSync as J6,mkdirSync as G6,readFileSync as L_,renameSync as Y6,rmSync as vN,statSync as X6,writeFileSync as q_}from"node:fs";import{join as Bf}from"node:path";var Q6,F_,$N,D_,wN,kN,Js,eH,Or,xN,EN,Vf,Z_,TN,PN,bN,tH,ON,Ic=$(()=>{"use strict";Tr();Uf();Q6="p3ws_",F_=t=>Bf(t,...fN.split("/")),$N=t=>Bf(t,At),D_=t=>B6("sha256").update(t,"utf8").digest("hex"),wN=()=>`${Q6}${SN(32).toString("base64url")}`,kN=(t,e)=>{if(!e||!t)return!1;let r=Buffer.from(D_(t),"hex"),n=Buffer.from(e.sha256,"hex");return r.length===n.length&&H6(r,n)},Js=t=>typeof t=="string"&&t.length>0,eH=t=>{let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object")return null;let r=e;if(r.version!==1||!Js(r.workspaceId)||!Js(r.root))return null;let n=r.token,s=n&&typeof n=="object"&&Js(n.sha256)&&Js(n.issuedAt)?{sha256:n.sha256,issuedAt:n.issuedAt}:null,o=r.server,i=o&&typeof o=="object"&&typeof o.pid=="number"&&typeof o.port=="number"&&Js(o.serverSession)&&Js(o.control)&&Js(o.startedAt)?{pid:o.pid,port:o.port,serverSession:o.serverSession,control:o.control,startedAt:o.startedAt}:null;return{version:1,workspaceId:r.workspaceId,root:r.root,token:s,server:i}},Or=t=>{try{return eH(L_(F_(t),"utf8"))}catch{return null}},xN=t=>{try{let e=X6(F_(t),{bigint:!0});return`${e.mtimeNs}:${e.size}:${e.ino}`}catch{return null}},EN=t=>{let e=$N(t);G6(e,{recursive:!0,mode:448});let r=Bf(e,".gitignore");J6(r)||q_(r,`*
230
- `,{mode:384})},Vf=(t,e)=>{EN(t);let r=F_(t),n=`${r}.${process.pid}.${SN(4).toString("hex")}.tmp`;q_(n,`${JSON.stringify(e,null,2)}
231
- `,{mode:384}),W6(n,384),Y6(n,r)},Z_=(t,e)=>{let r=Or(t),n=r!==null&&r.root!==t;if(!r||n){let s=wN(),o={version:1,workspaceId:K6(),root:t,token:{sha256:D_(s),issuedAt:new Date().toISOString()},server:null};return Vf(t,o),{state:o,issuedToken:s,minted:n?"moved":"new"}}if(e.rotateToken||r.token===null){let s=wN(),o={...r,token:{sha256:D_(s),issuedAt:new Date().toISOString()}};return Vf(t,o),{state:o,issuedToken:s,minted:null}}return{state:r,issuedToken:null,minted:null}},TN=(t,e)=>{let r=Or(t);r&&Vf(t,{...r,server:e})},PN=(t,e)=>{let r=Or(t);!r||r.server?.serverSession!==e||Vf(t,{...r,server:null})},bN=t=>Bf($N(t),"serve.lock"),tH=t=>{if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(e){return!!e&&typeof e=="object"&&"code"in e&&e.code==="EPERM"}},ON=t=>{EN(t);let e=bN(t);for(let r=0;r<2;r++){try{q_(e,`${process.pid}
232
- `,{flag:"wx",mode:384});let s=!1;return{acquired:!0,release:()=>{if(!s){s=!0;try{L_(e,"utf8").trim()===String(process.pid)&&vN(e,{force:!0})}catch{}}}}}catch(s){if(!(s&&typeof s=="object"&&"code"in s&&s.code==="EEXIST"))throw s}let n=0;try{n=Number.parseInt(L_(e,"utf8").trim(),10)}catch{}if(n&&tH(n))return{acquired:!1,pid:n};vN(e,{force:!0})}throw new Error(`Could not take ${bN(t)}; remove it if no pix3 serve is running.`)}});var Yt,ss,IN,rH,nH,U_,Kf,V_=$(()=>{"use strict";Tr();Ic();Yt=class extends Error{root;constructor(e,r){super(`Workspace server is not running. Run \`pix3 serve\` in ${e}`+(r?` (${r})`:"")+", then open it in Pix3 (File \u2192 Connect to Workspace\u2026)."),this.root=e}},ss=class extends Error{status;code;body;constructor(e,r,n,s){super(n),this.status=e,this.code=r,this.body=s}},IN=2e3,rH=15e3,nH=5e3,U_=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Kf=class{root;connection=null;identity;constructor(e,r){this.root=e,this.identity=r}reset(){this.connection=null}async status(){return await this.request("GET","/ws/agent/status")}async tools(){let e=await this.request("GET","/ws/agent/tools",void 0,8e3);return Array.isArray(e.tools)?e.tools:[]}async call(e,r,n=12e4){let s=await this.request("POST","/ws/agent/call",{name:e,input:r,timeoutMs:n,agent:this.identity()},n+nH);if(!U_(s.result)||!Array.isArray(s.result.content))throw new ss(502,"bad_editor_reply","The server sent no tool result.",s);return s.result}async presence(e=!1,r=IN){await this.request("POST","/ws/agent/presence",{agent:this.identity(),...e?{leaving:!0}:{}},r)}async hash(e){if(e.length===0)return{hashes:{},seq:(await this.revision()).seq};let r=await this.request("POST","/ws/agent/hash",{paths:e});return{hashes:U_(r.hashes)?r.hashes:{},seq:typeof r.seq=="number"?r.seq:0}}async expect(e){return await this.request("POST","/ws/agent/expect",{expect:e})}async changes(e){return await this.request("GET",`/ws/agent/changes?since=${Math.max(0,Math.floor(e))}`)}async revision(){let e=await this.request("GET","/ws/revision");return{revision:String(e.revision??""),seq:typeof e.seq=="number"?e.seq:0,serverSession:String(e.serverSession??"")}}async connect(){if(this.connection)return this.connection;let e=Or(this.root);if(!e)throw new Yt(this.root,"no .pix3/workspace.json");let r=e.server;if(!r)throw new Yt(this.root);let n=`http://${Jt}:${r.port}`,s;try{let o=await fetch(`${n}/ws/agent/status`,{headers:{"X-Pix3-Control":r.control},signal:AbortSignal.timeout(IN)});if(!o.ok)throw new Yt(this.root,`port ${r.port} answers ${o.status}; an older pix3 serve, or another process`);s=await o.json()}catch(o){throw o instanceof Yt?o:new Yt(this.root,`nothing answers on port ${r.port}`)}if(s.serverSession!==r.serverSession||s.workspaceId!==e.workspaceId)throw new Yt(this.root,"the recorded server is gone");return this.connection={base:n,control:r.control,serverSession:r.serverSession},this.connection}async request(e,r,n,s=rH){for(let o=0;;o++){let i=await this.connect(),a;try{a=await fetch(`${i.base}${r}`,{method:e,headers:{"X-Pix3-Control":i.control,...n!==void 0?{"Content-Type":"application/json"}:{}},body:n!==void 0?JSON.stringify(n):void 0,signal:AbortSignal.timeout(s)})}catch(u){if(this.connection=null,u instanceof Error&&u.name==="TimeoutError")throw new ss(504,"no_editor_reply","The workspace server did not answer in time.",{});if(o===0)continue;throw new Yt(this.root,"the connection dropped")}let c=await a.text(),l={};try{let u=c?JSON.parse(c):{};l=U_(u)?u:{}}catch{l={}}if(a.ok)return l;if(a.status===401&&o===0){this.connection=null;continue}throw new ss(a.status,typeof l.error=="string"?l.error:`http_${a.status}`,typeof l.message=="string"?l.message:`HTTP ${a.status}`,l)}}}});import{createHash as sH}from"node:crypto";var oH,iH,aH,cH,Qr,lH,ai,Ir,Hf,uH,NN,dH,fH,pH,Wf,hH,mH,CN,RN=$(()=>{"use strict";V_();l_();oH=5e3,iH=250,aH=1e5,cH=12e4,Qr=t=>!!t&&typeof t=="object"&&!Array.isArray(t),lH=t=>new Promise(e=>setTimeout(e,t)),ai=t=>JSON.stringify(t,null,2),Ir=(t,e,r={})=>({content:[{type:"text",text:ai({error:t,message:e,...r})}],isError:!0}),Hf=t=>{let e=t.content.flatMap(o=>o.type==="text"?[o.text]:[]),r=t.content.filter(o=>o.type==="image"),n=e.join(`
233
- `),s=n;try{s=n?JSON.parse(n):null}catch{s=n}return{payload:s,images:r}},uH=t=>t.agentHash!==void 0&&t.diskHash!==t.agentHash&&(t.loadedHash===void 0||t.loadedHash===t.diskHash),NN=t=>t.mergeLog?`The editor merged your write of ${t.path} with the human's manual edits (see .pix3/merge-log.jsonl). Re-read the file: the merged version is what runs now.`:t.diskHash===null?`${t.path} is missing on disk. Write it again.`:t.recovery?`Your write of ${t.path} was overwritten. A copy of your version: ${t.recovery}.`:`Your write of ${t.path} was overwritten and no copy exists \u2014 write the file again.`,dH=t=>{if(!Qr(t)||!Qr(t.loaded))return null;let e={};for(let[n,s]of Object.entries(t.loaded))typeof s=="string"&&(e[n]=s);let r=[];for(let n of Array.isArray(t.errors)?t.errors:[]){if(!Qr(n)||typeof n.message!="string")continue;let s=n.kind==="compile"||n.kind==="pending"?n.kind:"load";r.push({file:typeof n.file=="string"?n.file:null,...typeof n.line=="number"?{line:n.line}:{},message:n.message,kind:s})}return{loaded:e,errors:r,holdId:typeof t.holdId=="string"?t.holdId:null}},fH=t=>{let e=sH("sha256");for(let r of Object.keys(t).sort())e.update(`${r}\0${t[r]}
234
- `);return e.digest("hex")},pH=(t,e)=>{let r={};for(let[s,o]of Object.entries(t))(!e||e[s]!==o)&&(r[s]=o);let n=e?Object.keys(e).filter(s=>!(s in t)):[];return{files:Object.keys(t).length,digest:fH(t),changed:r,...n.length>0?{removed:n.sort()}:{}}},Wf=class{lane;log;syncBudgetMs;advertised=null;lastRevision=null;describeRevision(e,r){if(!e)return null;let n=pH(e,this.lastRevision);return this.lastRevision={...e},r?e:n}constructor(e,r={}){this.lane=e,this.log=r.log??(()=>{}),this.syncBudgetMs=r.syncBudgetMs??oH}async list(){return Ef(await this.advertisedTools())}hasAdvertisedTools(){return this.advertised!==null}async advertisedTools(){try{let e=await this.lane.status();if(this.advertised?.serverSession===e.serverSession)return this.advertised.tools;if(e.holder!=="connected")return null;let r=await this.lane.tools();return this.advertised={serverSession:e.serverSession,tools:r},r}catch{return null}}async call(e,r){if(!xf.includes(e))return{content:[{type:"text",text:`Unknown tool: ${e}`}],isError:!0};try{return e==="project_status"?await this.projectStatus():a_.has(e)?await this.barrierTool(e,r):c_.has(e)?await this.observingTool(e,r):this.passthrough(await this.lane.call(e,r))}catch(n){return this.transportError(n)}}transportError(e){return e instanceof Yt?(this.log(e.message),Ir("no_workspace_server",e.message,{root:e.root})):e instanceof ss?e.code==="no_editor"?Ir("no_editor",e.message):e.code==="lease_lost"?Ir("no_editor",`${e.message} Open the project in Pix3 again.`,{reason:"lease_lost"}):e.code==="no_editor_reply"?Ir("no_editor","The Pix3 editor holds this project but did not answer in time (a background tab may be throttled \u2014 bring the editor window to the front and retry).",{reason:"no_reply"}):{content:[{type:"text",text:ai({error:e.code,message:e.message})}],isError:!0}:{content:[{type:"text",text:e instanceof Error?e.message:String(e)}],isError:!0}}passthrough(e){return{content:e.content,...e.isError?{isError:!0}:{}}}async projectStatus(){let e=await this.lane.status(),r={root:e.root,projectName:e.projectName,revision:e.revision,seq:e.seq,serverSession:e.serverSession,cliVersion:e.cliVersion};try{let n=await this.lane.call("project_status",{},15e3),{payload:s}=Hf(n);return{content:[{type:"text",text:ai({connected:!0,server:r,editor:s})}],...n.isError?{isError:!0}:{}}}catch(n){if(n instanceof ss&&n.code==="no_editor")return{content:[{type:"text",text:ai({connected:!1,server:r,editor:null,message:n.message})}]};throw n}}async observingTool(e,r){let{fullRevision:n,...s}=r,o=await this.lane.call(e,s),i=Qr(o._meta)&&Qr(o._meta.pix3)?o._meta.pix3:{},a=Qr(i.playRevision)?Object.fromEntries(Object.entries(i.playRevision).filter(([,d])=>typeof d=="string")):null,c=i.stale===!0;if(a&&!c){let{hashes:d}=await this.lane.hash(Object.keys(a));c=Object.entries(a).some(([f,p])=>d[f]!==p)}let{payload:l,images:u}=Hf(o);return{content:[{type:"text",text:ai({revision:this.describeRevision(a,n===!0),stale:c,result:l})},...u],...o.isError?{isError:!0}:{}}}async barrierTool(e,r){let{expect:n,fullRevision:s,...o}=r,i=null;if(n!=null){if(!Qr(n))return{content:[{type:"text",text:"`expect` must be an object {path: sha256}."}],isError:!0};i={};for(let[c,l]of Object.entries(n))typeof l=="string"&&(i[c.replace(/^res:\/\//,"")]=l.toLowerCase())}if(i&&Object.keys(i).length>0){let c=await this.lane.expect(i);if(!c.matchesAgent)return Ir("disk_differs_from_agent","The disk does not hold the versions you wrote; nothing was started.",{differing:c.differing.map(l=>({...l,hint:NN(l)}))})}else i=null;let a=null;try{let c=Date.now()+this.syncBudgetMs,l=null,u=0;for(;;){let S=await this.lane.call("sync_barrier",{tool:e},aH),{payload:T}=Hf(S);if(S.isError)return this.passthrough(S);let P=dH(T);if(!P)return{content:[{type:"text",text:"The editor answered sync_barrier without hashes."}],isError:!0};if(P.holdId&&a&&P.holdId!==a){let Re=a;await this.lane.call("sync_release",{holdId:Re},5e3).catch(()=>{})}a=P.holdId??a;let A={...P.loaded,...i??{}},Z=await this.lane.hash(Object.keys(A)),ee=Object.entries(A).filter(([Re,La])=>Z.hashes[Re]!==La).map(([Re,La])=>({path:Re,diskHash:Z.hashes[Re]??null,...i&&Re in i?{agentHash:La}:{},...Re in P.loaded?{loadedHash:P.loaded[Re]}:{}})),J=P.errors.filter(Re=>Re.kind!=="pending"),fe=P.errors.filter(Re=>Re.kind==="pending");if(ee.length>0&&ee.every(uH)&&i){let Re=ee.map($r=>$r.path),La=await this.lane.expect(Object.fromEntries(Re.map($r=>[$r,i[$r]]))),oV=new Map(La.differing.map($r=>[$r.path,$r]));return Ir("expectation_stale",`The disk holds a newer version of ${Re.length} file(s) than the one you expected \u2014 somebody wrote after your \`pix3 check\` (the editor merging your write with a human's edit, a human save, another agent). The editor's files match the disk, so this is not editor lag. Nothing was started: re-read the file(s) (\`pix3 read\`), re-run \`pix3 check --json\` and pass the new hashes as \`expect\`.`,{differing:ee.map($r=>{let Da=oV.get($r.path);return{...$r,...Da?.mergeLog?{mergeLog:!0}:{},...Da?.recovery?{recovery:Da.recovery}:{},hint:Da?NN(Da):`${$r.path} moved on disk after your write; re-read it.`}})})}if(ee.length===0){if(J.length>0)return Ir("load_failed","The editor could not load the current files.",{errors:J});if(fe.length>0)return Ir("pending_external",CN(fe),{errors:fe});l=A,u=Z.seq;break}if(Date.now()>=c)return fe.length>0?Ir("pending_external",CN(fe),{errors:fe}):J.length>0?Ir("load_failed","The editor could not load the current files.",{errors:J}):Ir("sync_timeout",`The editor's files did not match the disk within ${Math.round(this.syncBudgetMs/1e3)} s (still being written?). Nothing was started; call again when the writes are done.`,{differing:ee});await lH(iH)}let d=await this.lane.call(e,o,cH),f=await this.lane.hash(Object.keys(l)),p=await this.lane.changes(u),{changedDuringRun:m,editorWroteDuringRun:h}=hH(p,l,f.hashes),g=Object.entries(l).every(([S,T])=>f.hashes[S]===T),y=[];i&&(y=(await this.lane.expect(i)).differing.filter(T=>T.mergeLog).map(T=>T.path));let{payload:w,images:b}=Hf(d),x=mH(d,w),v={revision:this.describeRevision(l,s===!0),startupMs:x,matchesAgent:i?!0:null,...i?{}:{agentExpectations:"none"},matchesDisk:g,changedDuringRun:m,editorWroteDuringRun:h,...p.complete?{}:{changeLogIncomplete:!0},editorChangedSinceAgentWrite:y,result:w};return{content:[{type:"text",text:ai(v)},...b],...d.isError?{isError:!0}:{}}}finally{a&&await this.lane.call("sync_release",{holdId:a},5e3).catch(()=>{})}}},hH=(t,e,r)=>{let n=new Map,s=(a,c)=>{let l=n.get(a)??new Set;l.add(c),n.set(a,l)};if(t.entries)for(let a of t.entries)s(a.path,a.origin);else for(let a of t.paths)s(a,"external");for(let[a,c]of Object.entries(e))r[a]!==c&&!n.get(a)?.has("editor")&&s(a,"external");let o=[],i=[];for(let[a,c]of n)(c.has("external")?o:i).push(a);return{changedDuringRun:o.sort(),editorWroteDuringRun:i.sort()}},mH=(t,e)=>{let r=Qr(t._meta)&&Qr(t._meta.pix3)?t._meta.pix3:{};return typeof r.startupMs=="number"?r.startupMs:Qr(e)&&typeof e.startupMs=="number"?e.startupMs:null},CN=t=>`${t.map(r=>r.file??"?").join(", ")} cannot be read as a valid file (the editor keeps its last good version). Finish or fix the write, then call again.`});var ae,AN,C,Sn,Nc=$(()=>{(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let o={};for(let i of s)o[i]=i;return o},t.getValidEnumValues=s=>{let o=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),i={};for(let a of o)i[a]=s[a];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(o){return s[o]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let o=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&o.push(i);return o},t.find=(s,o)=>{for(let i of s)if(o(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,o=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o})(ae||(ae={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(AN||(AN={}));C=ae.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Sn=t=>{switch(typeof t){case"undefined":return C.undefined;case"string":return C.string;case"number":return Number.isNaN(t)?C.nan:C.number;case"boolean":return C.boolean;case"function":return C.function;case"bigint":return C.bigint;case"symbol":return C.symbol;case"object":return Array.isArray(t)?C.array:t===null?C.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?C.promise:typeof Map<"u"&&t instanceof Map?C.map:typeof Set<"u"&&t instanceof Set?C.set:typeof Date<"u"&&t instanceof Date?C.date:C.object;default:return C.unknown}}});var O,Xt,Jf=$(()=>{Nc();O=ae.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Xt=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(o){return o.message},n={_errors:[]},s=o=>{for(let i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let l=i.path[c],u=c===i.path.length-1;if(l==="_errors"){u&&a._errors.push(r(i)),c++;continue}Object.prototype.hasOwnProperty.call(a,l)||(l==="__proto__"?Object.defineProperty(a,l,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):a[l]={_errors:[]}),a=a[l],u&&a._errors.push(r(i)),c++}}};return s(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ae.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r=Object.create(null),n=[];for(let s of this.issues)if(s.path.length>0){let o=s.path[0];r[o]=r[o]||[],r[o].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Xt.create=t=>new Xt(t)});var gH,os,B_=$(()=>{Jf();Nc();gH=(t,e)=>{let r;switch(t.code){case O.invalid_type:t.received===C.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case O.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,ae.jsonStringifyReplacer)}`;break;case O.unrecognized_keys:r=`Unrecognized key(s) in object: ${ae.joinValues(t.keys,", ")}`;break;case O.invalid_union:r="Invalid input";break;case O.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ae.joinValues(t.options)}`;break;case O.invalid_enum_value:r=`Invalid enum value. Expected ${ae.joinValues(t.options)}, received '${t.received}'`;break;case O.invalid_arguments:r="Invalid function arguments";break;case O.invalid_return_type:r="Invalid function return type";break;case O.invalid_date:r="Invalid date";break;case O.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:ae.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case O.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case O.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case O.custom:r="Invalid input";break;case O.invalid_intersection_types:r="Intersection results could not be merged";break;case O.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case O.not_finite:r="Number must be finite";break;default:r=e.defaultError,ae.assertNever(t)}return{message:r}},os=gH});function Cc(){return yH}var yH,Gf=$(()=>{B_();yH=os});function N(t,e){let r=Cc(),n=Yf({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===os?void 0:os].filter(s=>!!s)});t.common.issues.push(n)}var Yf,mt,B,ci,St,K_,H_,Gs,Rc,W_=$(()=>{Gf();B_();Yf=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,o=[...r,...s.path||[]],i={...s,path:o};if(s.message!==void 0)return{...s,path:o,message:s.message};let a="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)a=l(i,{data:e,defaultError:a}).message;return{...s,path:o,message:a}};mt=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return B;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let o=await s.key,i=await s.value;n.push({key:o,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:o,value:i}=s;if(o.status==="aborted"||i.status==="aborted")return B;o.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[o.value]=i.value)}return{status:e.value,value:n}}},B=Object.freeze({status:"aborted"}),ci=t=>({status:"dirty",value:t}),St=t=>({status:"valid",value:t}),K_=t=>t.status==="aborted",H_=t=>t.status==="dirty",Gs=t=>t.status==="valid",Rc=t=>typeof Promise<"u"&&t instanceof Promise});var zN=$(()=>{});var z,jN=$(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(z||(z={}))});function G(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:s}}function DN(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function AH(t){return new RegExp(`^${DN(t)}$`)}function zH(t){let e=`${LN}T${DN(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function jH(t,e){return!!((e==="v4"||!e)&&TH.test(t)||(e==="v6"||!e)&&OH.test(t))}function MH(t,e){if(!$H.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function LH(t,e){return!!((e==="v4"||!e)&&PH.test(t)||(e==="v6"||!e)&&IH.test(t))}function DH(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return o%i/10**s}function li(t){if(t instanceof Qt){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Nr.create(li(n))}return new Qt({...t._def,shape:()=>e})}else return t instanceof as?new as({...t._def,type:li(t.element)}):t instanceof Nr?Nr.create(li(t.unwrap())):t instanceof xn?xn.create(li(t.unwrap())):t instanceof kn?kn.create(t.items.map(e=>li(e))):t}function Y_(t,e){let r=Sn(t),n=Sn(e);if(t===e)return{valid:!0,data:t};if(r===C.object&&n===C.object){let s=ae.objectKeys(e),o=ae.objectKeys(t).filter(a=>s.indexOf(a)!==-1),i={...t,...e};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(let a of o){if(a==="__proto__")continue;let c=Y_(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===C.array&&n===C.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let o=0;o<t.length;o++){let i=t[o],a=e[o],c=Y_(i,a);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===C.date&&n===C.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function qN(t,e){return new yi({values:t,typeName:I.ZodEnum,...G(e)})}var ur,MN,te,_H,vH,wH,bH,SH,$H,kH,xH,EH,J_,TH,PH,OH,IH,NH,CH,LN,RH,ui,Ac,zc,jc,Mc,Lc,di,fi,Dc,is,en,qc,as,Qt,pi,$n,G_,hi,kn,X_,Fc,Zc,Q_,mi,gi,yi,_i,Ys,Cr,Nr,xn,vi,wi,Uc,Xf,Qf,bi,Tpe,I,Ppe,Ope,Ipe,Npe,Cpe,Rpe,Ape,zpe,jpe,Mpe,Lpe,Dpe,qpe,Fpe,FN,Zpe,Upe,Vpe,Bpe,Kpe,Hpe,Wpe,Jpe,Gpe,Ype,Xpe,Qpe,ehe,the,rhe,nhe,she,ohe,ihe,ZN=$(()=>{Jf();Gf();jN();W_();Nc();ur=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},MN=(t,e)=>{if(Gs(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Xt(t.common.issues);return this._error=r,this._error}}};te=class{get description(){return this._def.description}_getType(e){return Sn(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new mt,ctx:{common:e.parent.common,data:e.data,parsedType:Sn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Rc(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Sn(e)},s=this._parseSync({data:e,path:n.path,parent:n});return MN(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Sn(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return Gs(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>Gs(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Sn(e)},s=this._parse({data:e,path:n.path,parent:n}),o=await(Rc(s)?s:Promise.resolve(s));return MN(n,o)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,o)=>{let i=e(s),a=()=>o.addIssue({code:O.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new Cr({schema:this,typeName:I.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Nr.create(this,this._def)}nullable(){return xn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return as.create(this)}promise(){return Ys.create(this,this._def)}or(e){return pi.create([this,e],this._def)}and(e){return hi.create(this,e,this._def)}transform(e){return new Cr({...G(this._def),schema:this,typeName:I.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new vi({...G(this._def),innerType:this,defaultValue:r,typeName:I.ZodDefault})}brand(){return new Xf({typeName:I.ZodBranded,type:this,...G(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new wi({...G(this._def),innerType:this,catchValue:r,typeName:I.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Qf.create(this,e)}readonly(){return bi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},_H=/^c[^\s-]{8,}$/i,vH=/^[0-9a-z]+$/,wH=/^[0-9A-HJKMNP-TV-Z]{26}$/i,bH=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,SH=/^[a-z0-9_-]{21}$/i,$H=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,kH=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,xH=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,EH="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",TH=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,PH=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,OH=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,IH=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,NH=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,CH=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,LN="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",RH=new RegExp(`^${LN}$`);ui=class t extends te{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==C.string){let o=this._getOrReturnCtx(e);return N(o,{code:O.invalid_type,expected:C.string,received:o.parsedType}),B}let n=new mt,s;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:O.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:O.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let i=e.data.length>o.value,a=e.data.length<o.value;(i||a)&&(s=this._getOrReturnCtx(e,s),i?N(s,{code:O.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&N(s,{code:O.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")xH.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"email",code:O.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")J_||(J_=new RegExp(EH,"u")),J_.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"emoji",code:O.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")bH.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"uuid",code:O.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")SH.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"nanoid",code:O.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")_H.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid",code:O.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")vH.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid2",code:O.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")wH.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ulid",code:O.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),N(s,{validation:"url",code:O.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"regex",code:O.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(s=this._getOrReturnCtx(e,s),N(s,{code:O.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:O.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:O.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?zH(o).test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:O.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?RH.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:O.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?AH(o).test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:O.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?kH.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"duration",code:O.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?jH(e.data,o.version)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ip",code:O.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?MH(e.data,o.alg)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"jwt",code:O.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?LH(e.data,o.version)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cidr",code:O.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?NH.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"base64",code:O.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?CH.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"base64url",code:O.invalid_string,message:o.message}),n.dirty()):ae.assertNever(o);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:O.invalid_string,...z.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...z.errToObj(e)})}url(e){return this._addCheck({kind:"url",...z.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...z.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...z.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...z.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...z.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...z.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...z.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...z.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...z.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...z.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...z.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...z.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...z.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...z.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...z.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...z.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...z.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...z.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...z.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...z.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...z.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...z.errToObj(r)})}nonempty(e){return this.min(1,z.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ui.create=t=>new ui({checks:[],typeName:I.ZodString,coerce:t?.coerce??!1,...G(t)});Ac=class t extends te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==C.number){let o=this._getOrReturnCtx(e);return N(o,{code:O.invalid_type,expected:C.number,received:o.parsedType}),B}let n,s=new mt;for(let o of this._def.checks)o.kind==="int"?ae.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:O.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:O.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:O.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?DH(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),N(n,{code:O.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),N(n,{code:O.not_finite,message:o.message}),s.dirty()):ae.assertNever(o);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,z.toString(r))}gt(e,r){return this.setLimit("min",e,!1,z.toString(r))}lte(e,r){return this.setLimit("max",e,!0,z.toString(r))}lt(e,r){return this.setLimit("max",e,!1,z.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:z.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:z.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:z.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:z.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:z.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:z.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:z.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ae.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Ac.create=t=>new Ac({checks:[],typeName:I.ZodNumber,coerce:t?.coerce||!1,...G(t)});zc=class t extends te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==C.bigint)return this._getInvalidInput(e);let n,s=new mt;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:O.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),N(n,{code:O.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),N(n,{code:O.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):ae.assertNever(o);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return N(r,{code:O.invalid_type,expected:C.bigint,received:r.parsedType}),B}gte(e,r){return this.setLimit("min",e,!0,z.toString(r))}gt(e,r){return this.setLimit("min",e,!1,z.toString(r))}lte(e,r){return this.setLimit("max",e,!0,z.toString(r))}lt(e,r){return this.setLimit("max",e,!1,z.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:z.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:z.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:z.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};zc.create=t=>new zc({checks:[],typeName:I.ZodBigInt,coerce:t?.coerce??!1,...G(t)});jc=class extends te{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==C.boolean){let n=this._getOrReturnCtx(e);return N(n,{code:O.invalid_type,expected:C.boolean,received:n.parsedType}),B}return St(e.data)}};jc.create=t=>new jc({typeName:I.ZodBoolean,coerce:t?.coerce||!1,...G(t)});Mc=class t extends te{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==C.date){let o=this._getOrReturnCtx(e);return N(o,{code:O.invalid_type,expected:C.date,received:o.parsedType}),B}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return N(o,{code:O.invalid_date}),B}let n=new mt,s;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:O.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:O.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):ae.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:z.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:z.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Mc.create=t=>new Mc({checks:[],coerce:t?.coerce||!1,typeName:I.ZodDate,...G(t)});Lc=class extends te{_parse(e){if(this._getType(e)!==C.symbol){let n=this._getOrReturnCtx(e);return N(n,{code:O.invalid_type,expected:C.symbol,received:n.parsedType}),B}return St(e.data)}};Lc.create=t=>new Lc({typeName:I.ZodSymbol,...G(t)});di=class extends te{_parse(e){if(this._getType(e)!==C.undefined){let n=this._getOrReturnCtx(e);return N(n,{code:O.invalid_type,expected:C.undefined,received:n.parsedType}),B}return St(e.data)}};di.create=t=>new di({typeName:I.ZodUndefined,...G(t)});fi=class extends te{_parse(e){if(this._getType(e)!==C.null){let n=this._getOrReturnCtx(e);return N(n,{code:O.invalid_type,expected:C.null,received:n.parsedType}),B}return St(e.data)}};fi.create=t=>new fi({typeName:I.ZodNull,...G(t)});Dc=class extends te{constructor(){super(...arguments),this._any=!0}_parse(e){return St(e.data)}};Dc.create=t=>new Dc({typeName:I.ZodAny,...G(t)});is=class extends te{constructor(){super(...arguments),this._unknown=!0}_parse(e){return St(e.data)}};is.create=t=>new is({typeName:I.ZodUnknown,...G(t)});en=class extends te{_parse(e){let r=this._getOrReturnCtx(e);return N(r,{code:O.invalid_type,expected:C.never,received:r.parsedType}),B}};en.create=t=>new en({typeName:I.ZodNever,...G(t)});qc=class extends te{_parse(e){if(this._getType(e)!==C.undefined){let n=this._getOrReturnCtx(e);return N(n,{code:O.invalid_type,expected:C.void,received:n.parsedType}),B}return St(e.data)}};qc.create=t=>new qc({typeName:I.ZodVoid,...G(t)});as=class t extends te{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==C.array)return N(r,{code:O.invalid_type,expected:C.array,received:r.parsedType}),B;if(s.exactLength!==null){let i=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(i||a)&&(N(r,{code:i?O.too_big:O.too_small,minimum:a?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(N(r,{code:O.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(N(r,{code:O.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,a)=>s.type._parseAsync(new ur(r,i,r.path,a)))).then(i=>mt.mergeArray(n,i));let o=[...r.data].map((i,a)=>s.type._parseSync(new ur(r,i,r.path,a)));return mt.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:z.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:z.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:z.toString(r)}})}nonempty(e){return this.min(1,e)}};as.create=(t,e)=>new as({type:t,minLength:null,maxLength:null,exactLength:null,typeName:I.ZodArray,...G(e)});Qt=class t extends te{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=ae.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==C.object){let l=this._getOrReturnCtx(e);return N(l,{code:O.invalid_type,expected:C.object,received:l.parsedType}),B}let{status:n,ctx:s}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof en&&this._def.unknownKeys==="strip"))for(let l in s.data)i.includes(l)||a.push(l);let c=[];for(let l of i){let u=o[l],d=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new ur(s,d,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof en){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of a)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")a.length>0&&(N(s,{code:O.unrecognized_keys,keys:a}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of a){let d=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new ur(s,d,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let d=await u.key,f=await u.value;l.push({key:d,value:f,alwaysSet:u.alwaysSet})}return l}).then(l=>mt.mergeObjectSync(n,l)):mt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return z.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:z.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:I.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of ae.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of ae.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return li(this)}partial(e){let r={};for(let n of ae.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of ae.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof Nr;)o=o._def.innerType;r[n]=o}return new t({...this._def,shape:()=>r})}keyof(){return qN(ae.objectKeys(this.shape))}};Qt.create=(t,e)=>new Qt({shape:()=>t,unknownKeys:"strip",catchall:en.create(),typeName:I.ZodObject,...G(e)});Qt.strictCreate=(t,e)=>new Qt({shape:()=>t,unknownKeys:"strict",catchall:en.create(),typeName:I.ZodObject,...G(e)});Qt.lazycreate=(t,e)=>new Qt({shape:t,unknownKeys:"strip",catchall:en.create(),typeName:I.ZodObject,...G(e)});pi=class extends te{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let i=o.map(a=>new Xt(a.ctx.common.issues));return N(r,{code:O.invalid_union,unionErrors:i}),B}if(r.common.async)return Promise.all(n.map(async o=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let o,i=[];for(let c of n){let l={...r,common:{...r.common,issues:[]},parent:null},u=c._parseSync({data:r.data,path:r.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!o&&(o={result:u,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(c=>new Xt(c));return N(r,{code:O.invalid_union,unionErrors:a}),B}}get options(){return this._def.options}};pi.create=(t,e)=>new pi({options:t,typeName:I.ZodUnion,...G(e)});$n=t=>t instanceof mi?$n(t.schema):t instanceof Cr?$n(t.innerType()):t instanceof gi?[t.value]:t instanceof yi?t.options:t instanceof _i?ae.objectValues(t.enum):t instanceof vi?$n(t._def.innerType):t instanceof di?[void 0]:t instanceof fi?[null]:t instanceof Nr?[void 0,...$n(t.unwrap())]:t instanceof xn?[null,...$n(t.unwrap())]:t instanceof Xf||t instanceof bi?$n(t.unwrap()):t instanceof wi?$n(t._def.innerType):[],G_=class t extends te{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==C.object)return N(r,{code:O.invalid_type,expected:C.object,received:r.parsedType}),B;let n=this.discriminator,s=r.data[n],o=this.optionsMap.get(s);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(N(r,{code:O.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),B)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let o of r){let i=$n(o.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,o)}}return new t({typeName:I.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...G(n)})}};hi=class extends te{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(o,i)=>{if(K_(o)||K_(i))return B;let a=Y_(o.value,i.value);return a.valid?((H_(o)||H_(i))&&r.dirty(),{status:r.value,value:a.data}):(N(n,{code:O.invalid_intersection_types}),B)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,i])=>s(o,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};hi.create=(t,e,r)=>new hi({left:t,right:e,typeName:I.ZodIntersection,...G(r)});kn=class t extends te{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.array)return N(n,{code:O.invalid_type,expected:C.array,received:n.parsedType}),B;if(n.data.length<this._def.items.length)return N(n,{code:O.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),B;!this._def.rest&&n.data.length>this._def.items.length&&(N(n,{code:O.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new ur(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(o).then(i=>mt.mergeArray(r,i)):mt.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};kn.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new kn({items:t,typeName:I.ZodTuple,rest:null,...G(e)})};X_=class t extends te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.object)return N(n,{code:O.invalid_type,expected:C.object,received:n.parsedType}),B;let s=[],o=this._def.keyType,i=this._def.valueType;for(let a in n.data)s.push({key:o._parse(new ur(n,a,n.path,a)),value:i._parse(new ur(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?mt.mergeObjectAsync(r,s):mt.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof te?new t({keyType:e,valueType:r,typeName:I.ZodRecord,...G(n)}):new t({keyType:ui.create(),valueType:e,typeName:I.ZodRecord,...G(r)})}},Fc=class extends te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.map)return N(n,{code:O.invalid_type,expected:C.map,received:n.parsedType}),B;let s=this._def.keyType,o=this._def.valueType,i=[...n.data.entries()].map(([a,c],l)=>({key:s._parse(new ur(n,a,n.path,[l,"key"])),value:o._parse(new ur(n,c,n.path,[l,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of i){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return B;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),a.set(l.value,u.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of i){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return B;(l.status==="dirty"||u.status==="dirty")&&r.dirty(),a.set(l.value,u.value)}return{status:r.value,value:a}}}};Fc.create=(t,e,r)=>new Fc({valueType:e,keyType:t,typeName:I.ZodMap,...G(r)});Zc=class t extends te{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.set)return N(n,{code:O.invalid_type,expected:C.set,received:n.parsedType}),B;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(N(n,{code:O.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(N(n,{code:O.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let o=this._def.valueType;function i(c){let l=new Set;for(let u of c){if(u.status==="aborted")return B;u.status==="dirty"&&r.dirty(),l.add(u.value)}return{status:r.value,value:l}}let a=[...n.data.values()].map((c,l)=>o._parse(new ur(n,c,n.path,l)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:z.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:z.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Zc.create=(t,e)=>new Zc({valueType:t,minSize:null,maxSize:null,typeName:I.ZodSet,...G(e)});Q_=class t extends te{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==C.function)return N(r,{code:O.invalid_type,expected:C.function,received:r.parsedType}),B;function n(a,c){return Yf({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Cc(),os].filter(l=>!!l),issueData:{code:O.invalid_arguments,argumentsError:c}})}function s(a,c){return Yf({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Cc(),os].filter(l=>!!l),issueData:{code:O.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Ys){let a=this;return St(async function(...c){let l=new Xt([]),u=await a._def.args.parseAsync(c,o).catch(p=>{throw l.addIssue(n(c,p)),l}),d=await Reflect.apply(i,this,u);return await a._def.returns._def.type.parseAsync(d,o).catch(p=>{throw l.addIssue(s(d,p)),l})})}else{let a=this;return St(function(...c){let l=a._def.args.safeParse(c,o);if(!l.success)throw new Xt([n(c,l.error)]);let u=Reflect.apply(i,this,l.data),d=a._def.returns.safeParse(u,o);if(!d.success)throw new Xt([s(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:kn.create(e).rest(is.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||kn.create([]).rest(is.create()),returns:r||is.create(),typeName:I.ZodFunction,...G(n)})}},mi=class extends te{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};mi.create=(t,e)=>new mi({getter:t,typeName:I.ZodLazy,...G(e)});gi=class extends te{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return N(r,{received:r.data,code:O.invalid_literal,expected:this._def.value}),B}return{status:"valid",value:e.data}}get value(){return this._def.value}};gi.create=(t,e)=>new gi({value:t,typeName:I.ZodLiteral,...G(e)});yi=class t extends te{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return N(r,{expected:ae.joinValues(n),received:r.parsedType,code:O.invalid_type}),B}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return N(r,{received:r.data,code:O.invalid_enum_value,options:n}),B}return St(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};yi.create=qN;_i=class extends te{_parse(e){let r=ae.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==C.string&&n.parsedType!==C.number){let s=ae.objectValues(r);return N(n,{expected:ae.joinValues(s),received:n.parsedType,code:O.invalid_type}),B}if(this._cache||(this._cache=new Set(ae.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=ae.objectValues(r);return N(n,{received:n.data,code:O.invalid_enum_value,options:s}),B}return St(e.data)}get enum(){return this._def.values}};_i.create=(t,e)=>new _i({values:t,typeName:I.ZodNativeEnum,...G(e)});Ys=class extends te{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==C.promise&&r.common.async===!1)return N(r,{code:O.invalid_type,expected:C.promise,received:r.parsedType}),B;let n=r.parsedType===C.promise?r.data:Promise.resolve(r.data);return St(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Ys.create=(t,e)=>new Ys({type:t,typeName:I.ZodPromise,...G(e)});Cr=class extends te{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===I.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,o={addIssue:i=>{N(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="preprocess"){let i=s.transform(n.data,o);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return B;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?B:c.status==="dirty"?ci(c.value):r.value==="dirty"?ci(c.value):c});{if(r.value==="aborted")return B;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?B:a.status==="dirty"?ci(a.value):r.value==="dirty"?ci(a.value):a}}if(s.type==="refinement"){let i=a=>{let c=s.refinement(a,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?B:(a.status==="dirty"&&r.dirty(),i(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?B:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Gs(i))return B;let a=s.transform(i.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Gs(i)?Promise.resolve(s.transform(i.value,o)).then(a=>({status:r.value,value:a})):B);ae.assertNever(s)}};Cr.create=(t,e,r)=>new Cr({schema:t,typeName:I.ZodEffects,effect:e,...G(r)});Cr.createWithPreprocess=(t,e,r)=>new Cr({schema:e,effect:{type:"preprocess",transform:t},typeName:I.ZodEffects,...G(r)});Nr=class extends te{_parse(e){return this._getType(e)===C.undefined?St(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Nr.create=(t,e)=>new Nr({innerType:t,typeName:I.ZodOptional,...G(e)});xn=class extends te{_parse(e){return this._getType(e)===C.null?St(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xn.create=(t,e)=>new xn({innerType:t,typeName:I.ZodNullable,...G(e)});vi=class extends te{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===C.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};vi.create=(t,e)=>new vi({innerType:t,typeName:I.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...G(e)});wi=class extends te{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Rc(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Xt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Xt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};wi.create=(t,e)=>new wi({innerType:t,typeName:I.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...G(e)});Uc=class extends te{_parse(e){if(this._getType(e)!==C.nan){let n=this._getOrReturnCtx(e);return N(n,{code:O.invalid_type,expected:C.nan,received:n.parsedType}),B}return{status:"valid",value:e.data}}};Uc.create=t=>new Uc({typeName:I.ZodNaN,...G(t)});Xf=class extends te{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Qf=class t extends te{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?B:o.status==="dirty"?(r.dirty(),ci(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?B:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:I.ZodPipeline})}},bi=class extends te{_parse(e){let r=this._def.innerType._parse(e),n=s=>(Gs(s)&&(s.value=Object.freeze(s.value)),s);return Rc(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};bi.create=(t,e)=>new bi({innerType:t,typeName:I.ZodReadonly,...G(e)});Tpe={object:Qt.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(I||(I={}));Ppe=ui.create,Ope=Ac.create,Ipe=Uc.create,Npe=zc.create,Cpe=jc.create,Rpe=Mc.create,Ape=Lc.create,zpe=di.create,jpe=fi.create,Mpe=Dc.create,Lpe=is.create,Dpe=en.create,qpe=qc.create,Fpe=as.create,FN=Qt.create,Zpe=Qt.strictCreate,Upe=pi.create,Vpe=G_.create,Bpe=hi.create,Kpe=kn.create,Hpe=X_.create,Wpe=Fc.create,Jpe=Zc.create,Gpe=Q_.create,Ype=mi.create,Xpe=gi.create,Qpe=yi.create,ehe=_i.create,the=Ys.create,rhe=Cr.create,nhe=Nr.create,she=xn.create,ohe=Cr.createWithPreprocess,ihe=Qf.create});var UN=$(()=>{Gf();W_();zN();Nc();ZN();Jf()});var Vc=$(()=>{UN()});var V={};Je(V,{BIGINT_FORMAT_RANGES:()=>np,CONSTANT_CATCH:()=>iC,Class:()=>rv,NUMBER_FORMAT_RANGES:()=>Kc,aborted:()=>Rr,allowsEval:()=>av,assert:()=>KH,assertEqual:()=>FH,assertIs:()=>VH,assertNever:()=>BH,assertNotEqual:()=>ZH,assignProp:()=>zt,attachSchema:()=>op,base64ToUint8Array:()=>sC,base64urlToUint8Array:()=>sW,cached:()=>xi,captureStackTrace:()=>tp,cleanEnum:()=>nW,cleanRegex:()=>Bc,clone:()=>jt,cloneDef:()=>JH,codePointLength:()=>Hc,constantCatch:()=>aC,createTransparentProxy:()=>tW,defineLazy:()=>BN,defineLazyInternal:()=>_e,derived:()=>cW,esc:()=>ov,escapeRegex:()=>Tn,explicitlyAborted:()=>dv,extend:()=>YN,finalizeIssue:()=>Ar,floatSafeRemainder:()=>sv,getElementAtPath:()=>GH,getEnumValues:()=>$i,getLengthableOrigin:()=>Wc,getParsedType:()=>eW,getSizableOrigin:()=>nC,hexToUint8Array:()=>iW,hide:()=>ip,installLazyProp:()=>hv,isObject:()=>Qs,isPlainObject:()=>ls,issue:()=>Ti,joinValues:()=>ep,jsonStringifyReplacer:()=>ki,members:()=>pv,merge:()=>eC,mergeDefs:()=>rn,normalizeParams:()=>U,nullish:()=>nv,numKeys:()=>QH,objectClone:()=>HH,omit:()=>GN,optionalKeys:()=>uv,own:()=>tn,parsedType:()=>fv,partial:()=>tC,pick:()=>JN,prefixIssues:()=>Pn,primitiveTypes:()=>WN,promiseAllObject:()=>YH,propertyKeyTypes:()=>lv,randomString:()=>XH,rawShape:()=>Ei,required:()=>rC,safeExtend:()=>QN,shallowClone:()=>cv,slugify:()=>iv,stringifyPrimitive:()=>rp,toZod:()=>UH,uint8ArrayToBase64:()=>oC,uint8ArrayToBase64url:()=>oW,uint8ArrayToHex:()=>aW,unwrapMessage:()=>Si});function FH(t){return t}function ZH(t){return t}function UH(){return t=>t}function VH(t){}function BH(t){throw new Error("Unexpected value in exhaustive check")}function KH(t){}function $i(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,s])=>e.indexOf(+n)===-1).map(([n,s])=>s)}function ep(t,e="|"){return t.map(r=>rp(r)).join(e)}function ki(t,e){return typeof e=="bigint"?e.toString():e}function xi(t){return new tv(t)}function nv(t){return t==null}function Bc(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function sv(t,e){let r=t/e,n=Math.round(r),s=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<s?0:r-n}function BN(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==VN)return n===void 0&&(n=VN,n=r()),n},set(s){Object.defineProperty(t,e,{value:s})},configurable:!0})}function HH(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function zt(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ei(t){let e=Object.getOwnPropertyDescriptor(t,"shape");return e?.get?e.get.raw:e?.value}function En(t){return Ei(t._zod.def)??t._zod.def.shape}function KN(t,e,r){Object.defineProperty(t,e,{get(){let n=r();return zt(this,e,n),n},enumerable:!0,configurable:!0})}function HN(t,e,r){e in t?zt(t,e,r):t[e]=r}function Xs(t,e,r,n){let s=En(e);for(let o of r){let i=Object.getOwnPropertyDescriptor(s,o);i.enumerable&&(i.get?KN(t,o,()=>{let a=e._zod.def.shape[o];return n?n(a,o):a}):HN(t,o,n?n(i.value,o):i.value))}}function WH(t,e){for(let r of Reflect.ownKeys(e)){let n=Object.getOwnPropertyDescriptor(e,r);n.enumerable&&(n.get?KN(t,r,()=>e[r]):HN(t,r,n.value))}}function rn(...t){let e={};for(let r of t){let n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function JH(t){return rn(t._zod.def)}function GH(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function YH(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let s={};for(let o=0;o<e.length;o++)s[e[o]]=n[o];return s})}function XH(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function ov(t){return JSON.stringify(t)}function iv(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function Qs(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ls(t){if(Qs(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(Qs(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function cv(t){return ls(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function QH(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}function Tn(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jt(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function U(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function tW(t){let e;return new Proxy({},{get(r,n,s){return e??(e=t()),Reflect.get(e,n,s)},set(r,n,s,o){return e??(e=t()),Reflect.set(e,n,s,o)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,s){return e??(e=t()),Reflect.defineProperty(e,n,s)}})}function rp(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function uv(t){return Object.keys(t).filter(e=>t[e]._zod.optin!==void 0&&t[e]._zod.optout==="optional")}function JN(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o={};return Xs(o,t,sp(t,e)),jt(t,rn(r,{shape:o,checks:[]}))}function sp(t,e){let r=En(t),n=[];for(let s of Reflect.ownKeys(e)){if(!Object.getOwnPropertyDescriptor(r,s)?.enumerable)throw new Error(`Unrecognized key: "${String(s)}"`);e[s]&&n.push(s)}return n}function GN(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=new Set(sp(t,e)),i={};return Xs(i,t,Reflect.ownKeys(En(t)).filter(a=>!o.has(a))),jt(t,rn(r,{shape:i,checks:[]}))}function YN(t,e){if(!ls(e))throw new Error("Invalid input to extend: expected a plain object");let r=t._zod.def.checks;if(r&&r.length>0){let s=En(t);for(let o of Reflect.ownKeys(e))if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return jt(t,rn(t._zod.def,{shape:XN(t,e)}))}function XN(t,e){let r={};return Xs(r,t,Reflect.ownKeys(En(t))),WH(r,e),r}function QN(t,e){if(!ls(e))throw new Error("Invalid input to safeExtend: expected a plain object");return jt(t,rn(t._zod.def,{shape:XN(t,e)}))}function eC(t,e){if(!e?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Xs(r,t,Reflect.ownKeys(En(t))),Xs(r,e,Reflect.ownKeys(En(e)));let n=rn(t._zod.def,{shape:r,get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return jt(t,n)}function tC(t,e,r,n="partial"){let o=e._zod.def.checks;if(o&&o.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(sp(e,r)):void 0,c={};return Xs(c,e,Reflect.ownKeys(En(e)),t&&((l,u)=>a&&!a.has(u)?l:new t({type:"optional",innerType:l}))),jt(e,rn(e._zod.def,{shape:c,checks:[]}))}function rC(t,e,r){let n=r?new Set(sp(e,r)):void 0,s={};return Xs(s,e,Reflect.ownKeys(En(e)),(o,i)=>n&&!n.has(i)?o:new t({type:"nonoptional",innerType:o})),jt(e,rn(e._zod.def,{shape:s}))}function Rr(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function dv(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue===!1)return!0;return!1}function Pn(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Si(t){return typeof t=="string"?t:t?.message}function op(t,e,r){var n;for(let s=e;s<t.length;s++)(n=t[s]).schema??(n.schema=r)}function Ar(t,e,r){var n;let s=t.inst?._zod?.traits;s?.has("$ZodType")&&(s.has("$ZodCheck")?(n=t).schema??(n.schema=t.inst):t.schema=t.inst);let o=t.schema!==t.inst?t.schema?._zod.def?.error:void 0,i=t.message?t.message:Si(t.inst?._zod.def?.error?.(t))??Si(o?.(t))??Si(e?.error?.(t))??Si(r.customError?.(t))??Si(r.localeError?.(t))??"Invalid input",a={};for(let c of Object.keys(t))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=t[c]);return a.path??(a.path=[]),a.message=i,e?.reportInput&&(a.input=t.input),a}function nC(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Hc(t){let e=t.length;if(!rW.test(t))return e;let r=e;for(let n=0;n<e-1;n++)(t.charCodeAt(n)&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function Wc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function fv(t){let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(t===null)return"null";if(Array.isArray(t))return"array";let r=t;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function Ti(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function nW(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function sC(t){let e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function oC(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}function sW(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return sC(e+r)}function oW(t){return oC(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function iW(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)r[n/2]=Number.parseInt(e.slice(n,n+2),16);return r}function aW(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}function pv(t,e){for(let r in e){let n=Object.getOwnPropertyDescriptor(e,r);n.get?Object.defineProperty(t,r,{...n,enumerable:!1}):lW(t,r,n.value)}}function tn(t,e,r,n=!0){return Object.defineProperty(t,e,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function ip(t,e,r){return tn(t,e,r,!1)}function cW(t,e){for(let r in t){let n=t[r];Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){return tn(this,r,n(this))},set(s){tn(this,r,s)}})}return e}function lW(t,e,r){Object.defineProperty(t,e,{configurable:!0,get(){return this==null?r:tn(this,e,r.bind(this))},set(n){tn(this,e,n)}})}function uW(t,e){let r=Object.getPrototypeOf(t);return e in r?void 0:r}function _e(t,e,r){let n=Object.getPrototypeOf(t._zod);if(e in n&&ev!==t._zod){ev=void 0;return}ev=t._zod,Object.defineProperty(n,e,{configurable:!0,get(){Object.defineProperty(this,e,dW);let s=cs;cs=!1;try{let o=r(this);return cs?delete this[e]:Object.defineProperty(this,e,{configurable:!0,writable:!0,value:o}),cs=cs||s,o}catch(o){throw delete this[e],cs=cs||s,o}},set(s){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:s})}})}function hv(t,e,r,n){let s=uW(t,e);s&&Object.defineProperty(s,e,{configurable:!0,get(){let o={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,e,o),o.value=r(this),Object.defineProperty(this,e,o),o.value},set(o){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:n,value:o})}})}function aC(t){let e=()=>t;return e[iC]=!0,e}var tv,VN,tp,av,eW,lv,WN,Kc,np,rW,rv,ev,cs,dW,iC,$t=$(()=>{eo();tv=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};VN=Symbol("evaluating");tp="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};av=xi(()=>{if(Mt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});eW=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},lv=new Set(["string","number","symbol"]),WN=new Set(["string","number","bigint","boolean","symbol","undefined"]);Kc={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},np={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};rW=/[\uD800-\uDBFF]/;rv=class{constructor(...e){}};cs=!1,dW={configurable:!0,get(){cs=!0}};iC="~constantCatch"});function fW(t){let e=lC;if(e){let r=e.stackTraceLimit;if(typeof r=="number"){try{e.stackTraceLimit=0}catch{return lC=null,new t}try{return new t}finally{e.stackTraceLimit=r}}}return new t}function E(t,e,r,n){let s={};function o(f){this.def=f,this.constr=d,this.traits=new Set}o.prototype=s;let i=r,a=i&&new WeakSet;function c(f,p){if(f._zod){if(f._zod.traits.has(t))return}else{mv.value=new o(p);try{Object.defineProperty(f,"_zod",mv)}finally{mv.value=void 0}}if(f._zod.traits.add(t),e(f,p),a){let h=Object.getPrototypeOf(f),g=f._zod.constr.prototype,y=h;for(;y&&y!==g;)y=Object.getPrototypeOf(y);let w=y??h;a.has(w)||(a.add(w),pv(w,i))}let m=d.prototype;for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&(h in f||(f[h]=m[h].bind(f)))}let l=n?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:t});function d(f){let p=n?.Parent?fW(u):this;c(p,f);let m=p._zod.deferred;if(m){for(let g of m)g();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>n?.Parent&&f instanceof n.Parent?!0:f?._zod?.traits?.has(t)}),Object.defineProperty(d,"name",{value:t}),d}function er(t){return t&&Object.assign(Mt,t),Mt}var cC,mv,lC,zr,Pi,Mt,eo=$(()=>{$t();mv={value:void 0,enumerable:!1},lC="captureStackTrace"in Error?Error:null;zr=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Pi=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(cC=globalThis).__zod_globalConfig??(cC.__zod_globalConfig={});Mt=globalThis.__zod_globalConfig});function pW(){let t=this._zod;return t.message??(t.message=JSON.stringify(t.def,ki,2)),t.message}function hW(t){this._zod.message=t}function gW(t,e,r){return Object.prototype.hasOwnProperty.call(t,e)||(e==="__proto__"?Object.defineProperty(t,e,{value:r(),writable:!0,enumerable:!0,configurable:!0}):t[e]=r()),t[e]}function pC(t,e=r=>r.message){let r={},n=[];for(let s of t.issues)s.path.length>0?gW(r,s.path[0],()=>[]).push(e(s)):n.push(e(s));return{formErrors:n,fieldErrors:r}}function hC(t,e=r=>r.message){let r={_errors:[]},n=(s,o=[])=>{for(let i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...o,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...o,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...o,...i.path]);else{let a=[...o,...i.path];if(a.length===0)r._errors.push(e(i));else{let c=r,l=0;for(;l<a.length;){let u=a[l],d=l===a.length-1;if(u==="_errors"){d&&c._errors.push(e(i)),l++;continue}Object.prototype.hasOwnProperty.call(c,u)||Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[u];d&&f._errors.push(e(i)),c=f,l++}}}};return n(t),r}var mW,yv,uC,dC,fC,Jc,_v=$(()=>{eo();$t();mW={get:pW,set:hW,enumerable:!0,configurable:!0},yv={value:void 0,enumerable:!1},uC=new WeakSet([Object.prototype,Error.prototype]),dC=(t,e)=>{t.name="$ZodError",yv.value=e,Object.defineProperty(t,"issues",yv),yv.value=void 0,Object.defineProperty(t,"message",mW);let r=Object.getPrototypeOf(t);uC.has(r)||(uC.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},fC=E("$ZodError",dC),Jc=E("$ZodError",dC,void 0,{Parent:Error})});function ap(t,e){return{callee:e?.callee??t,Err:e?.Err}}function mC(t,e,r){let n;return{success:!1,get error(){return n||(n=new t(e.map(s=>Ar(s,r,er()))),e=void 0,r=void 0),n},set error(s){n=s,e=void 0,r=void 0}}}function wW(t,e,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},s=t._zod.bag.fallbackRun,o;if(s?(n[vW]=!0,o=s({value:e,issues:[]},n)):o=t._zod.run({value:e,issues:[]},n),o instanceof Promise)throw new zr;return o.issues.length===0}var Gc,vv,Yc,wv,Xc,Qc,el,tl,_W,vW,cp,lp,gC,yC,_C,vC,wC,bC,SC,$C,kC=$(()=>{eo();_v();$t();Gc=t=>{let e=(r,n,s,o)=>{let i=s?{...s,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new zr;if(a.issues.length){let c=new(o?.Err??t)(a.issues.map(l=>Ar(l,i,er())));throw tp(c,o?.callee??e),c}return a.value};return e},vv=Gc(Jc),Yc=t=>{let e=async(r,n,s,o)=>{let i=s?{...s,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(o?.Err??t)(a.issues.map(l=>Ar(l,i,er())));throw tp(c,o?.callee??e),c}return a.value};return e},wv=Yc(Jc),Xc=t=>(e,r,n)=>{let s=n?{...n,async:!1}:{async:!1},o=e._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new zr;return o.issues.length?mC(t,o.issues,s):{success:!0,data:o.value}},Qc=Xc(Jc);el=t=>async(e,r,n)=>{let s=n?{...n,async:!0}:{async:!0},o=e._zod.run({value:r,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?mC(t,o.issues,s):{success:!0,data:o.value}},tl=el(Jc),_W=Symbol.for("zod.compile.invalid"),vW=Symbol.for("zod.compile.fallback"),cp=((t,e,r)=>{let n=t._zod.bag.validator;if(n!==void 0){if(n(e)!==_W)return!0;if(n.definite===!0&&r===void 0)return!1}return wW(t,e,r)});lp=async(t,e,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},s=t._zod.run({value:e,issues:[]},n);return s instanceof Promise&&(s=await s),s.issues.length===0},gC=t=>{let e=Gc(t),r=(n,s,o,i)=>{let a=o?{...o,direction:"backward"}:{direction:"backward"};return e(n,s,a,ap(r,i))};return r},yC=t=>{let e=Gc(t),r=(n,s,o,i)=>e(n,s,o,ap(r,i));return r},_C=t=>{let e=Yc(t),r=async(n,s,o,i)=>{let a=o?{...o,direction:"backward"}:{direction:"backward"};return await e(n,s,a,ap(r,i))};return r},vC=t=>{let e=Yc(t),r=async(n,s,o,i)=>await e(n,s,o,ap(r,i));return r},wC=t=>(e,r,n)=>{let s=n?{...n,direction:"backward"}:{direction:"backward"};return Xc(t)(e,r,s)},bC=t=>(e,r,n)=>Xc(t)(e,r,n),SC=t=>async(e,r,n)=>{let s=n?{...n,direction:"backward"}:{direction:"backward"};return el(t)(e,r,s)},$C=t=>async(e,r,n)=>el(t)(e,r,n)});function NC(t){return new RegExp(`^[a-zA-Z0-9_-]{${t}}$`)}function zC(){return new RegExp(bW,"u")}function SW(t){return new RegExp(`^${t}$`)}function bv(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:t.seconds?`${e}:[0-5]\\d(?:\\.\\d+)?`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function KC(t){return new RegExp(`^${bv(t)}$`)}function HC(t){let e=["Z"];t.offset&&e.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${bv({precision:t.precision,seconds:!0})}(?:${e.join("|")})`,n=t.local?`${r}|${bv({precision:t.precision})}`:r;return new RegExp(`^${VC}T(?:${n})$`)}var xC,EC,TC,PC,OC,IC,CC,RC,Sv,AC,bW,jC,MC,LC,DC,qC,FC,ZC,UC,VC,BC,WC,$v,rl,JC,GC,YC,XC,nl=$(()=>{xC=/^[cC][0-9a-z]{6,}$/,EC=/^[0-9a-z]+$/,TC=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,PC=/^[0-9a-vA-V]{20}$/,OC=/^[A-Za-z0-9]{27}$/,IC=/^[a-zA-Z0-9_-]{21}$/;CC=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,RC=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Sv=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,AC=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,bW="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";jC=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,MC=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,LC=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,DC=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,qC=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,FC=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,ZC=/^https?$/,UC=/^\+[1-9]\d{6,14}$/,VC="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";BC=SW(VC);WC=/^[\s\S]{0,}$/,$v=/^-?\d+$/,rl=/^-?\d+(?:\.\d+)?$/,JC=/^(?:true|false)$/i,GC=/^null$/i,YC=/^[^A-Z]*$/,XC=/^[^a-z]*$/});var nt,kv,up,xv,Ev,QC,eR,tR,rR,nR,sl,sR,oR,iR,aR,cR,lR,uR,dp=$(()=>{eo();nl();$t();nt=E("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),kv=t=>{let e=t.value;return!nv(e)&&e.length!==void 0},up={number:"number",bigint:"bigint",object:"date"},xv=E("$ZodCheckLessThan",(t,e)=>{nt.init(t,e);let r=up[typeof e.value];t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:up[typeof n.value]??r,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Ev=E("$ZodCheckGreaterThan",(t,e)=>{nt.init(t,e);let r=up[typeof e.value];t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:up[typeof n.value]??r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),QC=E("$ZodCheckMultipleOf",(t,e)=>{nt.init(t,e),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?e.value!==BigInt(0)&&r.value%e.value===BigInt(0):sv(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),eR=E("$ZodCheckNumberFormat",(t,e)=>{nt.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[s,o]=Kc[e.format];t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort});return}}a<s&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:t,continue:!e.abort}),a>o&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:t,continue:!e.abort})}}),tR=E("$ZodCheckMaxLength",(t,e)=>{var r;nt.init(t,e),(r=t._zod.def).when??(r.when=kv),t._zod.check=n=>{let s=n.value,o=s.length;if((typeof s=="string"&&o>e.maximum?Hc(s):o)<=e.maximum)return;let a=Wc(s);n.issues.push({origin:a,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),rR=E("$ZodCheckMinLength",(t,e)=>{var r;nt.init(t,e),(r=t._zod.def).when??(r.when=kv),t._zod.check=n=>{let s=n.value,o=s.length;if((typeof s=="string"&&o>=e.minimum&&o<e.minimum*2?Hc(s):o)>=e.minimum)return;let a=Wc(s);n.issues.push({origin:a,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),nR=E("$ZodCheckLengthEquals",(t,e)=>{var r;nt.init(t,e),(r=t._zod.def).when??(r.when=kv),t._zod.check=n=>{let s=n.value,o=s.length,i=typeof s=="string"&&o>=e.length&&o<=e.length*2?Hc(s):o;if(i===e.length)return;let a=Wc(s),c=i>e.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),sl=E("$ZodCheckStringFormat",(t,e)=>{var r,n;nt.init(t,e),e.pattern?(r=t._zod).check??(r.check=s=>{e.pattern.lastIndex=0,!e.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:e.format,input:s.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),sR=E("$ZodCheckRegex",(t,e)=>{sl.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),oR=E("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=YC),sl.init(t,e)}),iR=E("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=XC),sl.init(t,e)}),aR=E("$ZodCheckIncludes",(t,e)=>{nt.init(t,e);let r=Tn(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position},}${r}`:r);e.pattern=n,t._zod.check=s=>{s.value.includes(e.includes,e.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:s.value,inst:t,continue:!e.abort})}}),cR=E("$ZodCheckStartsWith",(t,e)=>{nt.init(t,e);let r=new RegExp(`^${Tn(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),lR=E("$ZodCheckEndsWith",(t,e)=>{nt.init(t,e);let r=new RegExp(`.*${Tn(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}}),uR=E("$ZodCheckOverwrite",(t,e)=>{nt.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}})});var fp,Tv=$(()=>{fp=class{constructor(e=[],r={}){this.content=[],this.indent=0,this.args=e,this.closed=r}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
235
- `).filter(i=>i),s=Math.min(...n.map(i=>i.length-i.trimStart().length)),o=n.map(i=>i.slice(s)).map(i=>" ".repeat(this.indent*2)+i);for(let i of o)this.content.push(i)}compile(){let e=Function,r=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
236
- ${r.join(`
429
+ `),0;let n=ue(e.cwd,r.project);if("error"in n)return e.stderr(`pix3 check: ${n.error}
430
+ `),2;let s=n.root,i=await $p(s,{hydrate:r.hydrate,offline:r.offline,sync:r.sync,validate:e.validate,typescript:e.typescript,log:o=>e.stderr(`${o}
431
+ `)});return e.stdout(r.json?Pp(i):Tp(i)),i.errorCount>0?1:0}});var Zr,P,xt=O(()=>{"use strict";Zr=U(ce(),1),P=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)});var Dp={};X(Dp,{CODEX_PROJECT_CONFIG:()=>Ha,MCP_CONFIG_FILE:()=>en,MIGRATE_STAGING_DIR:()=>jp,formatMigrationReport:()=>eE,isRetiredPix3McpEntry:()=>Ya,legacyMarkersIn:()=>za,migrateKit:()=>Z0});import{existsSync as D0,readdirSync as F0,readFileSync as Ip,rmdirSync as q0,rmSync as Rp}from"node:fs";import{dirname as Mp,join as fe,sep as B0}from"node:path";var Lp,en,Ha,jp,Ya,U0,K0,za,W0,V0,G0,J0,H0,Y0,z0,X0,Q0,Z0,eE,Fp=O(()=>{"use strict";Lp=U(ce(),1);se();Z();xt();Ls();en=".mcp.json",Ha=fe(".codex","config.toml"),jp=".pix3/kit-migrate",Ya=t=>{if(!P(t))return!1;let e=typeof t.command=="string"?t.command:"",r=Array.isArray(t.args)?t.args.filter(s=>typeof s=="string"):[],n=[e,...r];return n.includes("mcp")?n.some(s=>/^@pix3\/cli(@\S+)?$/.test(s)||/(^|[\\/])pix3(\.cmd)?$/.test(s)||/[\\/]packages[\\/]cli[\\/](src|dist)[\\/]index\.(ts|js)$/.test(s)||/[\\/]@pix3[\\/]cli[\\/]dist[\\/]index\.js$/.test(s)):!1},U0=t=>{if(!P(t))return"";let e=Array.isArray(t.args)?t.args.map(String):[];return[String(t.command??""),...e].join(" ").trim()},K0=[{pattern:/\bpix3 mcp\b/,label:"`pix3 mcp`"},{pattern:/\bpix3 serve\b/,label:"`pix3 serve`"},{pattern:/\bpix3 read\b/,label:"`pix3 read`"},{pattern:/\blive channel\b/i,label:"the live channel"},{pattern:/`(?:game_run|game_input|play_start|read_errors|set_property)`/,label:"1.x in-editor tools"}],za=t=>K0.filter(e=>e.pattern.test(t)).map(e=>e.label),W0=(t,e)=>{let r=t;for(;r.startsWith(e)&&r!==e;){try{if(F0(r).length>0)return;q0(r)}catch{return}r=Mp(r)}},V0=(t,e)=>{let r=fe(t,en),n=W(r);if(n===null)return!1;let s;try{s=JSON.parse(n)}catch{return/\bmcp\b/.test(n)&&/pix3/.test(n)&&e.push({path:en,action:"kept",detail:"not valid JSON, so it was left as is; remove its 1.x `pix3 mcp` server by hand"}),!1}if(!P(s)||!P(s.mcpServers))return!1;let i=s.mcpServers,o=Object.entries(i).filter(([,u])=>Ya(u));if(o.length===0)return!1;let a=Object.fromEntries(Object.entries(i).filter(([,u])=>!Ya(u))),l=Object.fromEntries(Object.entries(s).filter(([u])=>u!=="mcpServers")),c=Object.keys(a).length===0&&Object.keys(l).length===0;c?Rp(r):Q(r,`${JSON.stringify({...s,mcpServers:a},null,2)}
432
+ `);for(let[u,f]of o)e.push({path:en,action:"removed",detail:`mcpServers.${u} (${U0(f)}) \u2014 the 1.x live channel${c?"; the file had nothing else and is deleted":""}`});return!0},G0=(t,e)=>{let r=W(fe(t,Ha));if(r===null)return;let n=r.split(/^(?=\s*\[)/m);for(let s of n){let i=/^\s*\[mcp_servers\.([^\]]+)\]/.exec(s);i&&/"mcp"/.test(s)&&/pix3/.test(s)&&e.push({path:Ha.split(B0).join("/"),action:"kept",detail:`[mcp_servers.${i[1]}] launches the retired \`pix3 mcp\`; this command does not edit Codex config \u2014 delete that table by hand`})}},J0=(t,e)=>{let r=fe(t,K),n=W(r);if(n===null)return;let s=(0,Lp.parseDocument)(n);if(s.getIn(["metadata","pix3Hybrid"])===void 0)return;let o=s.toJS();s.deleteIn(["metadata","pix3Hybrid"]),Q(r,s.toString({indent:2})),e.push({path:K,action:"removed",detail:`metadata.pix3Hybrid (${JSON.stringify(o.metadata?.pix3Hybrid)}) \u2014 the 1.x cloud link; 2.x has no cloud`})},H0=(t,e,r,n)=>{let s=zt(t);if(!s)return;let i=new Set([...e.manifest.files,ee,"tsconfig.json"]);for(let[o,a]of Object.entries(s.files)){if(i.has(o))continue;let l=fe(t,o);D0(l)&&(Se(Ip(l))===a?(Rp(l),W0(Mp(l),fe(t,".claude")),r.push({path:o,action:"removed",detail:"a file the 2.x kit no longer ships"})):(r.push({path:o,action:"kept",detail:"a file the 2.x kit no longer ships, edited since the kit wrote it"}),n.push(`${o} is no longer part of the kit, and you edited it: keep what you need from it elsewhere and delete it.`)))}},Y0=(t,e,r,n,s)=>{for(let i of r.files){if(i.action!=="skipped-edited"||i.path===De)continue;let o=i.path===ee?J:i.path;if(!e.manifest.files.includes(o))continue;let a=W(fe(t,i.path))??"",l=za(a);if(l.length===0||i.path===J&&r.files.some(u=>u.path===ee))continue;let c=`${jp}/${i.path}`;Q(fe(t,c),Ip(fe(e.filesDir,o),"utf8")),n.push({path:i.path,action:"staged",detail:`edited by you and still the 1.x kit (mentions ${l.join(", ")}); the 2.x text is in ${c}`}),s.push(`Merge ${i.path} by hand: it still tells the agent about 1.x (${l.join(", ")}). Compare it with ${c}, keep your additions, then run pix3 kit --update (it skips files you edited, so copy the 2.x text over if you want the kit to own it again).`)}},z0=t=>{let e=zt(t);return e?.version?e.version:ys(t)},X0=t=>{let e=W(fe(t,en));if(e===null)return!1;try{let r=JSON.parse(e);return P(r)&&P(r.mcpServers)&&"pix3-browser"in r.mcpServers}catch{return!1}},Q0=t=>{let e=W(fe(t,"package.json"));if(e===null)return!1;try{let r=JSON.parse(e);return!!(r.dependencies?.["@pix3/vite-plugin"]??r.devDependencies?.["@pix3/vite-plugin"])}catch{return!1}},Z0=(t,e,r={})=>{let n=z0(t),s=[],i=[],o=[],a=V0(t,s);G0(t,s),J0(t,s),H0(t,e,s,i);let l=zt(t)?.files??{},c=Xt(t,e,{...r,update:!0});Y0(t,e,c,s,i);let u=W(fe(t,J)),f=u===null?[]:za(u);l[J]!==void 0&&f.length>0&&c.files.some(h=>h.path===ee)&&(s.push({path:J,action:"kept",detail:`your edited copy of the 1.x kit (mentions ${f.join(", ")}); the 2.x kit is now ${ee}`}),i.push(`Remove the 1.x kit text from ${J} (keep your own rules) \u2014 it contradicts ${ee}.`));let d=n!==null&&/^1\./.test(n);return(a||d)&&!X0(t)&&i.push("Connect the agent to the 2.x editor: npx pix3 agent-setup (writes the pix3-browser server \u2014 chrome-devtools-mcp \u2014 into .mcp.json and .codex/config.toml), then start a new agent thread."),(a||d)&&i.push("If ~/.codex/config.toml has an [mcp_servers.pix3] table running `@pix3/cli \u2026 mcp` (printed by the 1.x `pix3 setup`), delete it; this command never edits files outside the project."),Q0(t)||o.push("No @pix3/vite-plugin in package.json: the 2.x editor is served by the project's own Vite dev server at /__pix3/. Adding it (pix3() in vite.config) is a separate, manual step (plan \xA7A.4 step 3); the kit does not do it."),{from:n,steps:s,instructions:i,notes:o,kit:c}},eE=(t,e)=>{let r=[`Pix3 kit migration ${t.from??"(no kit recorded)"} \u2192 ${t.kit.version} in ${e}`],n={removed:"removed",kept:"KEPT",staged:"STILL 1.x"};t.steps.length===0&&r.push(" nothing of the 1.x kit left to remove");for(let i of t.steps)r.push(` ${n[i.action].padEnd(9)} ${i.path}: ${i.detail}`);let s=zr({...t.kit,instructions:[]},e).split(`
433
+ `).slice(1).filter(Boolean);r.push(...s);for(let i of t.notes)r.push(`note: ${i}`);for(let i of[...t.kit.instructions,...t.instructions])r.push(`TODO: ${i}`);return`${r.join(`
237
434
  `)}
238
- };`)(...Object.values(this.closed))}}});var fR,Pv=$(()=>{fR={major:4,minor:6,patch:5}});async function $W(t,e){let r={async:!0};return $R(await t._zod.run({value:e,issues:[]},r),r)}function Iv(t){return{validate:e=>{let r={async:!1};try{let n=t._zod.run({value:e,issues:[]},r);if(!(n instanceof Promise))return $R(n,r)}catch{}return $W(t,e)},vendor:"zod",version:1}}function xR(t){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(t):(new URL(t),!0)}catch{return!1}}function kW(t,e){return!("normalize"in e)&&!("hostname"in e)&&!("protocol"in e)?xR(t)||hp:xW(t,e)}function xW(t,e){if(!e.normalize&&e.protocol?.source===ZC.source&&!/^https?:\/\//i.test(t))return kR;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(t)??hp}return new URL(t)}catch{return hp}}function pR(t){return t.replace(EW,"")}function TW(t,e){return e.lastIndex=0,e.test(t.hostname)}function PW(t,e){return e.lastIndex=0,e.test(t.protocol.endsWith(":")?t.protocol.slice(0,-1):t.protocol)}function IR(t){return OW.test(t)?xR(`http://[${t}]`):!1}function IW(t){let e=t.split("/");if(e.length!==2)return!1;let[r,n]=e;if(!n)return!1;let s=Number(n);return`${s}`!==n||s<0||s>128?!1:IR(r)}function NR(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}function NW(t){if(!gp.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return NR(r)}function CW(t,e=null){try{let r=t.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let s=JSON.parse(atob(n));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||e&&(!("alg"in s)||s.alg!==e))}catch{return!1}}function hR(t,e,r){t.issues.length&&e.issues.push(...Pn(r,t.issues)),e.value[r]=t.value}function mp(t,e,r,n,s,o){let i=r in n,a=o==="optional";if(!(!i&&a&&s==="optional")){if(t.issues.length){if(s!==void 0&&a&&!i)return;e.issues.push(...Pn(r,t.issues))}if(!i&&s===void 0){t.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}t.value===void 0?(i||s==="defaulted"&&!a)&&(e.value[r]=void 0):e.value[r]=t.value}}function CR(t){let e=Object.keys(t.shape),r=Object.getOwnPropertySymbols(t.shape),n=r.length?r:RW,s=n.length?[...e,...n]:e;for(let i of s)if(!t.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let o=uv(t.shape);return{...t,allKeys:s,symbolKeys:n,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(o)}}function RR(t,e,r,n,s,o,i){let a=[],c=s.keySet,l=s.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let m in e){if(i&&r.issues.length!==p){if(Rr(r,p))break;p=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){u==="never"&&a.push(m);continue}if(u==="never"){a.push(m);continue}let h=l.run({value:e[m],issues:[]},n);h instanceof Promise?t.push(h.then(g=>mp(g,r,m,e,d,f))):mp(h,r,m,e,d,f)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:e,inst:o,continue:!0}),t.length?Promise.all(t).then(()=>r):r}function mR(t,e,r,n){for(let o of t)if(o.issues.length===0)return e.value=o.value,e;let s=t.filter(o=>!Rr(o));return s.length===1?(e.value=s[0].value,s[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(o=>o.issues.map(i=>Ar(i,n,er())))}),e)}function AW(t){let e=new Map;for(let r of t.options){let n=r._zod.propValues?.[t.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let s of n)if(e.has(s)){if(s!==void 0)throw new Error(`Duplicate discriminator value "${String(s)}"`);e.set(s,null)}else e.set(s,r)}return e}function Ov(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(ls(t)&&ls(e)){let r=Object.keys(e),n=Object.keys(t).filter(o=>r.indexOf(o)!==-1),s={...t,...e};Object.prototype.hasOwnProperty.call(s,"__proto__")&&delete s.__proto__;for(let o of n){if(o==="__proto__")continue;let i=Ov(t[o],e[o]);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};s[o]=i.data}return{valid:!0,data:s}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let s=t[n],o=e[n],i=Ov(s,o);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function gR(t,e,r){let n=new Map,s,o=new Map,i=(l,u)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)s??(s=l),d=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let f=String(l.path[0]);o.has(f)||o.set(f,l),d=[f]}else return!1;for(let f of d)n.has(f)||n.set(f,{}),n.get(f)[u]=!0;return!0};for(let l of e.issues)i(l,"l")||t.issues.push(l);for(let l of r.issues)i(l,"r")||t.issues.push(l);let a=[...n].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=s?a.filter(u=>s.keys.includes(u)):[];l.length&&t.issues.push({...s,keys:l});for(let u of a)!l.includes(u)&&o.has(u)&&t.issues.push(o.get(u))}let c=Ov(e.value,r.value);if(!c.valid){if(Rr(t))return t;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return t.value=c.data,t}function yR(t,e){return t.value=e.issues.length?void 0:e.value,t}function _R(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}function vR(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}function wR(t,e,r,n){return e.issues.length?(t.value=r.catchValue({...e,value:t.value,error:{issues:e.issues.map(s=>Ar(s,n,er()))},input:t.value}),t):(t.value=e.value,e.memo&&(t.memo=!0),t)}function pp(t,e,r){return t.issues.some(n=>n.code!=="unrecognized_keys")?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues},r)}function bR(t){return t.memo||(t.value=Object.freeze(t.value)),t}function SR(t,e,r,n){if(!t){let s={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(s.params=n._zod.def.params),e.issues.push(Ti(s))}}var Oe,$R,ol,Ae,Nv,Cv,Rv,kR,hp,EW,Av,zv,jv,Mv,Lv,Dv,qv,Fv,ER,TR,PR,OR,Zv,OW,Uv,Vv,Bv,Kv,Hv,gp,Wv,Jv,Gv,yp,Yv,Xv,Qv,ew,tw,rw,RW,nw,AR,_p,sw,ow,iw,aw,cw,lw,vp,uw,dw,fw,pw,hw,mw,wp,zR,gw,yw,_w=$(()=>{dp();eo();Tv();nl();$t();Pv();$t();Oe=E("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=fR;let n=t._zod.def.checks,s=t._zod.traits.has("$ZodCheck")?[t,...n??[]]:n?.length?[...n]:[];for(let o of s)for(let i of o._zod.onattach)i(t);if(s.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let o=(a,c,l)=>{if(a.memo)return a;let u=Rr(a),d;for(let f of c){if(f._zod.def.when){if(dv(a)||!f._zod.def.when(a))continue}else if(u)continue;let p=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new zr;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(op(a.issues,p,t),u||(u=Rr(a,p)))});else{if(a.issues.length===p)continue;op(a.issues,p,t),u||(u=Rr(a,p))}}return d?d.then(()=>a):a},i=(a,c,l)=>{if(Rr(a))return a.aborted=!0,a;let u=o(c,s,l);if(u instanceof Promise){if(l.async===!1)throw new zr;return u.then(d=>t._zod.parse(d,l))}return t._zod.parse(u,l)};t._zod.run=(a,c)=>{if(c.skipChecks)return t._zod.parse(a,c);if(c.direction==="backward"){let u=t._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(d=>i(d,a,c)):i(u,a,c)}let l=t._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new zr;return l.then(u=>o(u,s,c))}return o(l,s,c)}}},{get"~standard"(){return ip(this,"~standard",Iv(this))},set"~standard"(t){tn(this,"~standard",t)}}),$R=(t,e)=>t.issues.length?{issues:t.issues.map(r=>Ar(r,e,er()))}:{value:t.value};ol=E("$ZodString",(t,e)=>{Oe.init(t,e),t._zod.pattern=e.pattern??WC,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),Ae=E("$ZodStringFormat",(t,e)=>{sl.init(t,e),ol.init(t,e)}),Nv=E("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=RC),Ae.init(t,e)}),Cv=E("$ZodUUID",(t,e)=>{if(e.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Sv(n))}else e.pattern??(e.pattern=Sv());Ae.init(t,e)}),Rv=E("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=AC),Ae.init(t,e)}),kR=1,hp=2;EW=/[\t\n\r]/g;Av=E("$ZodURL",(t,e)=>{Ae.init(t,e),t._zod.check=r=>{try{let n=r.value.trim(),s=kW(n,e);if(s===kR){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:t,continue:!e.abort});return}if(s===hp){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort});return}if(s===!0){r.value=pR(n);return}e.hostname&&!TW(s,e.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:r.value,inst:t,continue:!e.abort}),e.protocol&&!PW(s,e.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort}),r.value=e.normalize?s.href:pR(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),zv=E("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=zC()),Ae.init(t,e)}),jv=E("$ZodNanoID",(t,e)=>{if(e.length!==void 0&&(!Number.isInteger(e.length)||e.length<1))throw new Error(`Invalid nanoid length: ${e.length}`);e.pattern??(e.pattern=e.length===void 0?IC:NC(e.length)),Ae.init(t,e)}),Mv=E("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=xC),Ae.init(t,e)}),Lv=E("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=EC),Ae.init(t,e)}),Dv=E("$ZodULID",(t,e)=>{e.pattern??(e.pattern=TC),Ae.init(t,e)}),qv=E("$ZodXID",(t,e)=>{e.pattern??(e.pattern=PC),Ae.init(t,e)}),Fv=E("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=OC),Ae.init(t,e)}),ER=E("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=HC(e)),Ae.init(t,e)}),TR=E("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=BC),Ae.init(t,e)}),PR=E("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=KC(e)),Ae.init(t,e)}),OR=E("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=CC),Ae.init(t,e)}),Zv=E("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=jC),Ae.init(t,e)}),OW=/^[0-9a-fA-F:.]+$/;Uv=E("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=MC),Ae.init(t,e),t._zod.check=r=>{IR(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}),Vv=E("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=LC),Ae.init(t,e)});Bv=E("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=DC),Ae.init(t,e),t._zod.check=r=>{IW(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}});Kv=/^[0-9a-zA-Z+/]*={0,2}$/,Hv=E("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Kv),Ae.init(t,e),t._zod.check=r=>{NR(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}}),gp=/^[A-Za-z0-9_-]*$/;Wv=E("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=gp),Ae.init(t,e),t._zod.check=r=>{NW(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Jv=E("$ZodE164",(t,e)=>{e.pattern??(e.pattern=UC),Ae.init(t,e)});Gv=E("$ZodJWT",(t,e)=>{Ae.init(t,e),t._zod.check=r=>{CW(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),yp=E("$ZodNumber",(t,e)=>{Oe.init(t,e),t._zod.pattern=rl,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let s=r.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return r;let o=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:String(s):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:t,...o?{received:o}:{}}),r}}),Yv=E("$ZodNumberFormat",(t,e)=>{eR.init(t,e),yp.init(t,e)}),Xv=E("$ZodBoolean",(t,e)=>{Oe.init(t,e),t._zod.pattern=JC,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}let s=r.value;return typeof s=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:t}),r}}),Qv=E("$ZodNull",(t,e)=>{Oe.init(t,e),t._zod.pattern=GC,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{let s=r.value;return s===null||r.issues.push({expected:"null",code:"invalid_type",input:s,inst:t}),r}}),ew=E("$ZodUnknown",(t,e)=>{Oe.init(t,e),t._zod.parse=r=>r}),tw=E("$ZodNever",(t,e)=>{Oe.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});rw=E("$ZodArray",(t,e)=>{Oe.init(t,e);let r=Mt.memoizer;r?.attach(t),t._zod.parse=(n,s)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:t}),n;n.value=r?r.alloc(t,n,Array(o.length),s):Array(o.length);let i=[],a=s?.abortEarly;for(let c=0;c<o.length;c++){let l=o[c],u=e.element._zod.run({value:l,issues:[]},s);if(u instanceof Promise)i.push(u.then(d=>hR(d,n,c)));else if(hR(u,n,c),a&&u.issues.length!==0&&Rr(u))break}return i.length?Promise.all(i).then(()=>n):n}});RW=[];nw=E("$ZodObject",(t,e)=>{Oe.init(t,e);let r=Object.getOwnPropertyDescriptor(e,"shape"),n=r?.get?r.get.raw:e.shape??{};if(n){let l=()=>{let u={...n};return Object.defineProperty(e,"shape",{value:u}),l.raw=u,u};l.raw=n,Object.defineProperty(e,"shape",{get:l})}let s=xi(()=>CR(e));_e(t,"propValues",l=>{let u=l.def.shape,d={};for(let f in u){let p=u[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,f)||zt(d,f,new Set);for(let m of p.values)d[f].add(m);p.optin!==void 0&&d[f].add(void 0)}}return d});let o=Qs,i=e.catchall,a,c=Mt.memoizer;c?.attach(t),t._zod.parse=(l,u)=>{a??(a=s.value);let d=l.value;if(!o(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:t}),l;l.value=c?c.alloc(t,l,{},u):{};let f=[],p=a.shape,m=u?.abortEarly,h=l.issues.length;for(let g of a.allKeys){if(m&&l.issues.length!==h){if(Rr(l,h))break;h=l.issues.length}if(g==="__proto__")continue;let y=p[g],w=y._zod.optin,b=y._zod.optout,x=y._zod.run({value:d[g],issues:[]},u);x instanceof Promise?f.push(x.then(v=>mp(v,l,g,d,w,b))):mp(x,l,g,d,w,b)}return i?RR(f,d,l,u,s.value,t,m===!0):f.length?Promise.all(f).then(()=>l):l}}),AR=E("$ZodObjectJIT",(t,e)=>{nw.init(t,e);let r=t._zod.parse,n=xi(()=>CR(e)),s=Mt.memoizer,o=p=>{let m=n.value,h=m.symbolKeys,g=new fp(["payload","ctx"],{shape:p,inst:t,memo:s,syms:h}),y=v=>`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`,w=(v,S)=>`
239
- let ${v}_ab = false;
240
- for (let i = 0; i < ${v}.issues.length; i++) {
241
- const iss = ${v}.issues[i];
242
- iss.path = iss.path ? [${S}, ...iss.path] : [${S}];
243
- payload.issues.push(iss);
244
- if (iss.continue !== true) ${v}_ab = true;
245
- }
246
- if (${v}_ab && ctx && ctx.abortEarly) {
247
- payload.value = newResult;
248
- return payload;
249
- }`;g.write("const input = payload.value;");let b=Object.create(null),x=0;for(let v of m.allKeys)b[v]=`key_${x++}`;g.write(s?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let v of m.allKeys){if(v==="__proto__")continue;let S=b[v],T=typeof v=="symbol"?`syms[${h.indexOf(v)}]`:ov(v),P=`${T} in input`,A=p[v],Z=A?._zod?.optin,ee=Z!==void 0,J=A?._zod?.optout==="optional";if(g.write(`const ${S} = ${y(T)};`),ee&&J){let fe=Z==="optional"?`${S}_present`:`${S}.value !== undefined || ${S}_present`;g.write(`
250
- const ${S}_present = ${P};
251
- if (!${S}.issues.length || ${S}_present) {
252
- if (${S}.issues.length) {${w(S,T)}
253
- }
254
-
255
- if (${fe}) {
256
- newResult[${T}] = ${S}.value;
257
- }
258
- }
259
-
260
- `)}else ee?(g.write(`
261
- if (${S}.issues.length) {${w(S,T)}
262
- }
263
- `),Z==="defaulted"?g.write(`newResult[${T}] = ${S}.value;`):g.write(`
264
- if (${S}.value !== undefined || ${P}) {
265
- newResult[${T}] = ${S}.value;
266
- }
267
- `)):g.write(`
268
- const ${S}_present = ${P};
269
- if (${S}.issues.length) {${w(S,T)}
270
- }
271
- if (!${S}_present && !${S}.issues.length) {
272
- payload.issues.push({
273
- code: "invalid_type",
274
- expected: "nonoptional",
275
- input: undefined,
276
- path: [${T}]
277
- });
278
- if (ctx && ctx.abortEarly) {
279
- payload.value = newResult;
280
- return payload;
281
- }
282
- }
283
-
284
- if (${S}_present) {
285
- newResult[${T}] = ${S}.value;
286
- }
287
-
288
- `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},i,a=Qs,c=!Mt.jitless,u=c&&av.value,d=e.catchall,f;t._zod.parse=(p,m)=>{f??(f=n.value);let h=p.value;return a(h)?c&&u&&m?.async===!1&&m.jitless!==!0?(i||(i=o(e.shape)),p=i(p,m),d?RR([],h,p,m,f,t,m?.abortEarly===!0):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:t}),p)}});_p=E("$ZodUnion",(t,e)=>{Oe.init(t,e),_e(t,"optin",n=>n.def.options.some(s=>s._zod.optin==="defaulted")?"defaulted":n.def.options.some(s=>s._zod.optin!==void 0)?"optional":void 0),_e(t,"optout",n=>n.def.options.some(s=>s._zod.optout==="optional")?"optional":void 0),_e(t,"values",n=>{if(n.def.options.every(s=>s._zod.values))return new Set(n.def.options.flatMap(s=>Array.from(s._zod.values)))}),_e(t,"pattern",n=>{if(n.def.options.every(s=>s._zod.pattern)){let s=n.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${s.map(o=>Bc(o.source)).join("|")})$`)}});let r=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(n,s)=>{if(r)return r(n,s);let o=!1,i=[];for(let a of e.options){let c=a._zod.run({value:n.value,issues:[]},s);if(c instanceof Promise)i.push(c),o=!0;else{if(c.issues.length===0)return c;i.push(c)}}return o?Promise.all(i).then(a=>mR(a,n,t,s)):mR(i,n,t,s)}});sw=E("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,_p.init(t,e);let r=t._zod.parse;_e(t,"propValues",s=>{let o={},i=0;for(let a of s.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${s.def.options.indexOf(a)}"`);c[s.def.discriminator]?.has(void 0)&&i++;for(let[l,u]of Object.entries(c)){Object.prototype.hasOwnProperty.call(o,l)||zt(o,l,new Set);for(let d of u)o[l].add(d)}}return!s.def.unionFallback&&i>1&&o[s.def.discriminator]?.delete(void 0),o}),e.options.forEach((s,o)=>{let i=Ei(s._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,e.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});let n=xi(()=>AW(e));t._zod.parse=(s,o)=>{let i=s.value;if(!Qs(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),s;let a=i?.[e.discriminator],c=n.value.get(a);return c&&(a!==void 0||o.direction!=="backward")?c._zod.run(s,o):e.unionFallback||o.direction==="backward"?r(s,o):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(n.value.keys()).filter(l=>n.value.get(l)!==null),input:i,path:[e.discriminator],inst:t}),s)}}),ow=E("$ZodIntersection",(t,e)=>{Oe.init(t,e),t._zod.parse=(r,n)=>{let s=r.value,o=e.left._zod.run({value:s,issues:[]},n),i=e.right._zod.run({value:s,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([c,l])=>gR(r,c,l)):gR(r,o,i)}});iw=E("$ZodRecord",(t,e)=>{Oe.init(t,e);let r=Mt.memoizer;r?.attach(t),t._zod.parse=(n,s)=>{let o=n.value;if(!ls(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),n;let i=[],a=e.keyType._zod.values;if(a&&!e.partial){n.value=r?r.alloc(t,n,{},s):{};let c=new Set;for(let u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){if(c.add(typeof u=="number"?u.toString():u),u==="__proto__")continue;let d=e.keyType._zod.run({value:u,issues:[]},s);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>Ar(m,s,er())),input:u,path:[u],inst:t});continue}let f=d.value;if(f==="__proto__")continue;let p=e.valueType._zod.run({value:o[u],issues:[]},s);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...Pn(u,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...Pn(u,p.issues)),n.value[f]=p.value)}let l;for(let u in o)if(!c.has(u))if(e.mode==="loose"){if(u==="__proto__")continue;n.value[u]=o[u]}else l=l??[],l.push(u);l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:l,continue:!0})}else{n.value=r?r.alloc(t,n,{},s):{};let c;for(let l of Reflect.ownKeys(o)){if(l==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,l))continue;let u=e.keyType._zod.run({value:l,issues:[]},s);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&rl.test(l)&&u.issues.length){let m=e.keyType._zod.run({value:Number(l),issues:[]},s);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(u=m)}if(u.issues.length){e.mode==="loose"?n.value[l]=o[l]:a?(c=c??[],c.push(l)):n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(m=>Ar(m,s,er())),input:l,path:[l],inst:t});continue}let f=u.value;if(f==="__proto__")continue;let p=e.valueType._zod.run({value:o[l],issues:[]},s);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...Pn(l,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...Pn(l,p.issues)),n.value[f]=p.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}}),aw=E("$ZodEnum",(t,e)=>{Oe.init(t,e);let r=$i(e.entries),n=new Set(r);t._zod.values=n,_e(t,"pattern",s=>{let o=$i(s.def.entries).filter(i=>lv.has(typeof i));return new RegExp(o.length?`^(${o.map(i=>Tn(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),t._zod.parse=(s,o)=>{let i=s.value;return n.has(i)||s.issues.push({code:"invalid_value",values:r,input:i,inst:t}),s}}),cw=E("$ZodLiteral",(t,e)=>{Oe.init(t,e);let r=new Set(e.values);t._zod.values=r,_e(t,"pattern",n=>{let s=n.def.values;return new RegExp(s.length?`^(${s.map(o=>typeof o=="string"?Tn(o):o?Tn(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),t._zod.parse=(n,s)=>{let o=n.value;return r.has(o)||n.issues.push({code:"invalid_value",values:e.values,input:o,inst:t}),n}}),lw=E("$ZodTransform",(t,e)=>{Oe.init(t,e),t._zod.optin="optional",Mt.memoizer?.guard(t),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Pi(t.constructor.name);let s=e.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(i=>(r.value=i,r));if(s instanceof Promise)throw new zr;return r.value=s,r}});vp=E("$ZodOptional",(t,e)=>{Oe.init(t,e),_e(t,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),t._zod.optout="optional",_e(t,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),_e(t,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Bc(n.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(r.value===void 0){if(e.innerType._zod.optin!=="defaulted")return r;let s=e.innerType._zod.run({value:r.value,issues:[]},n);return s instanceof Promise?s.then(o=>yR(r,o)):yR(r,s)}return e.innerType._zod.run(r,n)}}),uw=E("$ZodExactOptional",(t,e)=>{vp.init(t,e),_e(t,"values",r=>r.def.innerType._zod.values),_e(t,"pattern",r=>r.def.innerType._zod.pattern),t._zod.parse=(r,n)=>e.innerType._zod.run(r,n)}),dw=E("$ZodNullable",(t,e)=>{Oe.init(t,e),_e(t,"optin",r=>r.def.innerType._zod.optin),_e(t,"optout",r=>r.def.innerType._zod.optout),_e(t,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Bc(n.source)}|null)$`):void 0}),_e(t,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),fw=E("$ZodDefault",(t,e)=>{Oe.init(t,e),t._zod.optin="defaulted",_e(t,"values",r=>r.def.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>_R(o,e)):_R(s,e)}});pw=E("$ZodPrefault",(t,e)=>{Oe.init(t,e),t._zod.optin="defaulted",_e(t,"values",r=>r.def.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),hw=E("$ZodNonOptional",(t,e)=>{Oe.init(t,e),_e(t,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(s=>s!==void 0)):void 0}),t._zod.parse=(r,n)=>{let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(o=>vR(o,t)):vR(s,t)}});mw=E("$ZodCatch",(t,e)=>{Oe.init(t,e),_e(t,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),_e(t,"optout",r=>r.def.innerType._zod.optout),_e(t,"values",r=>r.def.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let s=e.innerType._zod.run({value:r.value,issues:[]},n);return s instanceof Promise?s.then(o=>wR(r,o,e,n)):wR(r,s,e,n)}}),wp=E("$ZodPipe",(t,e)=>{Oe.init(t,e),_e(t,"values",r=>r.def.in._zod.values),_e(t,"optin",r=>r.def.in._zod.optin),_e(t,"optout",r=>r.def.out._zod.optout),_e(t,"propValues",r=>r.def.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){let o=e.out._zod.run(r,n);return o instanceof Promise?o.then(i=>pp(i,e.in,n)):pp(o,e.in,n)}let s=e.in._zod.run(r,n);return s instanceof Promise?s.then(o=>pp(o,e.out,n)):pp(s,e.out,n)}});zR=E("$ZodPreprocess",(t,e)=>{wp.init(t,e)}),gw=E("$ZodReadonly",(t,e)=>{Oe.init(t,e),_e(t,"propValues",r=>r.def.innerType._zod.propValues),_e(t,"values",r=>r.def.innerType._zod.values),_e(t,"optin",r=>r.def.innerType?._zod?.optin),_e(t,"optout",r=>r.def.innerType?._zod?.optout),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(bR):bR(s)}});yw=E("$ZodCustom",(t,e)=>{nt.init(t,e),Oe.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,s=e.fn(n);if(s instanceof Promise)return s.then(o=>SR(o,r,n,t));SR(s,r,n,t)}})});function MR(t){return t!==null&&typeof t=="object"}function vw(t){return t.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}function kp(t,e,r){let n=LR.get(t);if(n!==void 0)return n?al:il;if(e.has(t))return al;e.add(t);let s=il,o=u=>{if(s!==al&&u?._zod){let d=kp(u,e,r);d>s&&(s=d)}},i=(u,d)=>{let f=il;for(let p of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,p);if(d&&!m.enumerable)continue;let h=m.get?$p:m.value?._zod?kp(m.value,e,r):il;h>f&&(f=h)}return f},a=u=>{u>s&&(s=u)},c=t._zod.def,l=c.type;switch(l){case"object":{let u=Ei(c);a(u?i(u,!0):$p),o(c.catchall);break}case"array":o(c.element);break;case"tuple":for(let u of c.items)o(u);o(c.rest);break;case"record":case"map":o(c.keyType),o(c.valueType);break;case"set":o(c.valueType);break;case"union":for(let u of c.options)o(u);break;case"intersection":o(c.left),o(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(c.innerType);break;case"pipe":o(c.in),o(c.out);break;case"function":o(c.input),o(c.output);break;case"lazy":{let u=c._cachedInner??(r?t._zod.innerType:void 0);a(u?kp(u,e,!1):$p);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let d=Object.getOwnPropertyDescriptor(c,u);if(!d||d.get)continue;let f=d.value;if(!(!f||typeof f!="object")){if(f._zod)o(f);else if(Array.isArray(f))for(let p of f)o(p)}}}return e.delete(t),zW(t,s)}function zW(t,e){return e!==$p&&LR.set(t,e===al),e}function jW(t,e){let r=t.buckets.get(e);return r||(r=new WeakMap,t.buckets.set(e,r)),r}function DR(){return MW}function LW(t,e){let r=t[bw]?.backEdges;return r!==void 0&&MR(e)&&r.has(e)}var ww,bw,jR,LR,il,$p,al,bp,Sp,MW,qR=$(()=>{$t();ww=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},bw="~memo",jR=[];LR=new WeakMap,il=0,$p=1,al=2;Sp=[],MW={alloc(t,e,r){let n=bp;if(!n)return r;bp=void 0;let s={value:r,issues:null};return n.set(e.value,s),Sp.push(s),r},guard(t){var e;(e=t._zod).deferred??(e.deferred=[]),t._zod.deferred.push(()=>{let r=t._zod.parse,n=(s,o)=>{if(o.direction!=="backward"&&LW(o,s.value))throw new ww;return r(s,o)};t._zod.parse=n,t._zod.run===r&&(t._zod.run=n)})},attach(t){var e;let r,n=!1,s,o;(e=t._zod).deferred??(e.deferred=[]),t._zod.deferred.push(()=>{let i=t._zod.parse,a=(c,l)=>{if(r===void 0){let y=kp(t,new Set,!1);if(y===il)return t._zod.parse=i,t._zod.run===a&&(t._zod.run=i),i(c,l);y===al||n?r=!0:n=!0}let u=c.value;if(!MR(u))return i(c,l);let d=l[bw];d||(d={buckets:new WeakMap,backEdges:void 0},l[bw]=d);let f;s===l?f=o:(f=jW(d,t),s=l,o=f);let p=f.get(u);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...vw(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;bp=f;let m=Sp.length,h=i(c,l);bp=void 0;let g=Sp.length>m?Sp.pop():void 0;return h instanceof Promise?h.then(y=>(g&&(g.issues=y.issues.length?vw(y.issues):jR),y)):(g&&(g.issues=h.issues.length?vw(h.issues):jR),h)};t._zod.parse=a,t._zod.run===i&&(t._zod.run=a)})}}});function FR(){return{localeError:DW()}}var DW,ZR=$(()=>{$t();DW=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(o){return t[o]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function s(o,i){return o==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[o]??o}return o=>{switch(o.code){case"invalid_type":{let i=s(o.expected),a=fv(o.input),c=s(a,o.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${rp(o.values[0])}`:`Invalid option: expected one of ${ep(o.values,"|")}`;case"too_big":{let i=o.exact?"exactly ":o.inclusive?"<=":"<",a=e(o.origin);return a?`Too big: expected ${o.origin??"value"} to have ${i}${o.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${i}${o.maximum.toString()}`}case"too_small":{let i=o.exact?"exactly ":o.inclusive?">=":">",a=e(o.origin);return a?`Too small: expected ${o.origin} to have ${i}${o.minimum.toString()} ${a.unit}`:`Too small: expected ${o.origin} to be ${i}${o.minimum.toString()}`}case"invalid_format":{let i=o;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${ep(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(a=>`'${a}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}}});var xp=$(()=>{});function qW(){return new $w}var UR,$w,to,kw=$(()=>{$w=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let n=r[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let s={...n,...this._map.get(e)};return Object.keys(s).length?s:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};(UR=globalThis).__zod_globalRegistry??(UR.__zod_globalRegistry=qW());to=globalThis.__zod_globalRegistry});var VR=$(()=>{});function BR(t){return t.checks&&(t.checks=[...t.checks]),t}function xw(t,e){return new t(BR({type:"string",...U(e)}))}function Ew(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...U(e)})}function Tw(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...U(e)})}function Pw(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...U(e)})}function Ow(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...U(e)})}function Iw(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...U(e)})}function Nw(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...U(e)})}function Cw(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...U(e)})}function Rw(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...U(e)})}function Aw(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...U(e)})}function zw(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...U(e)})}function jw(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...U(e)})}function Mw(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...U(e)})}function Lw(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...U(e)})}function Dw(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...U(e)})}function qw(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...U(e)})}function Fw(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...U(e)})}function Zw(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...U(e)})}function Uw(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...U(e)})}function Vw(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...U(e)})}function Bw(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...U(e)})}function Kw(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...U(e)})}function Hw(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...U(e)})}function Ep(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...U(e)})}function Tp(t,e){return new t({type:"string",format:"date",check:"string_format",...U(e)})}function Pp(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...U(e)})}function Op(t,e){return new t({type:"string",format:"duration",check:"string_format",...U(e)})}function Ww(t,e){return new t(BR({type:"number",checks:[],...U(e)}))}function Jw(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...U(e)})}function Gw(t,e){return new t({type:"boolean",...U(e)})}function Yw(t,e){return new t({type:"null",...U(e)})}function Xw(t){return new t({type:"unknown"})}function Qw(t,e){return new t({type:"never",...U(e)})}function Ip(t,e){return new xv({check:"less_than",...U(e),value:t,inclusive:!1})}function cl(t,e){return new xv({check:"less_than",...U(e),value:t,inclusive:!0})}function Np(t,e){return new Ev({check:"greater_than",...U(e),value:t,inclusive:!1})}function ll(t,e){return new Ev({check:"greater_than",...U(e),value:t,inclusive:!0})}function Cp(t,e){return new QC({check:"multiple_of",...U(e),value:t})}function Rp(t,e){return new tR({check:"max_length",...U(e),maximum:t})}function Ii(t,e){return new rR({check:"min_length",...U(e),minimum:t})}function Ap(t,e){return new nR({check:"length_equals",...U(e),length:t})}function eb(t,e){return new sR({check:"string_format",format:"regex",...U(e),pattern:t})}function tb(t){return new oR({check:"string_format",format:"lowercase",...U(t)})}function rb(t){return new iR({check:"string_format",format:"uppercase",...U(t)})}function nb(t,e){return new aR({check:"string_format",format:"includes",...U(e),includes:t})}function sb(t,e){return new cR({check:"string_format",format:"starts_with",...U(e),prefix:t})}function ob(t,e){return new lR({check:"string_format",format:"ends_with",...U(e),suffix:t})}function us(t){return new uR({check:"overwrite",tx:t})}function ib(t){return us(e=>e.normalize(t))}function ab(){return us(t=>t.trim())}function cb(){return us(t=>t.toLowerCase())}function lb(){return us(t=>t.toUpperCase())}function ub(){return us(t=>iv(t))}function KR(t,e,r){return new t({type:"array",element:e,...U(r)})}function db(t,e,r){let n=U(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function fb(t,e,r){return new t({type:"custom",check:"custom",fn:e,...U(r)})}function pb(t,e){let r=FW(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(Ti(s,n.value,r._zod.def));else{let o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=n.value),o.inst??(o.inst=r),o.continue??(o.continue=!r._zod.def.abort),n.issues.push(Ti(o))}},t(n.value,n)),e);return r}function FW(t,e){let r=new nt({check:"custom",...U(e)});return r._zod.check=t,r}var HR=$(()=>{dp();$t()});function ul(t,...e){for(let r of e)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&zt(t,n,r[n]);return t}function fl(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??to,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:t?.cycles??"ref",reused:t?.reused??"inline",intersections:[],deferred:[],external:t?.external??void 0}}function st(t,e,r,n,s){let o=typeof e.unrepresentable=="function"?e.unrepresentable({zodSchema:t,path:n.path,message:s}):e.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(s);return Object.assign(r,o),!0}function Ie(t,e,r={path:[],schemaPath:[]}){var n;let s=t._zod.def,o=e.seen.get(t);if(o)return o.count++,r.schemaPath.includes(t)&&(o.cycle=r.path),o.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(t,i),e.sharedDefsExtractedFor=void 0,e.sharedEmitDoneFor=void 0;let a=t._zod.toJSONSchema?.();if(a)i.schema=a;else{let u={...r,schemaPath:[...r.schemaPath,t],path:r.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,i.schema,u);else{let f=i.schema,p=e.processors[s.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);p(t,e,f,u)}let d=t._zod.parent;d&&(i.ref||(i.ref=d),Ie(d,e,u),e.seen.get(d).isParent=!0)}let c=e.metadataRegistry.get(t);return c&&ul(i.schema,c),e.io==="input"&&kt(t)&&(delete i.schema.examples,delete i.schema.default),e.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,e.seen.get(t).schema}function WR(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function pl(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(t.external&&t.sharedDefsExtractedFor===t.external)return;let n=new Map;for(let i of t.seen.entries()){let a=t.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let s=i=>{let a=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){let d=t.external.registry.get(i[0])?.id,f=t.external.uri??(m=>m);if(d)return{ref:f(d)};let p=i[1].defId??i[1].schema.id??`schema${t.counter++}`;return i[1].defId=p,{defId:p,ref:`${f("__shared")}#/${a}/${WR(p)}`}}let c="#",l=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let u=i[1].schema.id??`__schema${t.counter++}`;return{defId:u,ref:l+WR(u)}},o=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:l}=s(i);a.def={...a.schema},l&&(a.defId=l);let u=a.schema;for(let d in u)delete u[d];u.$ref=c};if(t.cycles==="throw")for(let i of t.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
289
-
290
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of t.seen.entries()){let a=i[1];if(e===i[0]){o(i);continue}if(t.external){let l=t.external.registry.get(i[0])?.id;if(e!==i[0]&&l){o(i);continue}}if(t.metadataRegistry.get(i[0])?.id){o(i);continue}if(a.cycle){o(i);continue}a.count>1&&t.reused==="ref"&&o(i)}t.external&&(t.sharedDefsExtractedFor=t.external)}function YR(t){let e=t.anyOf;if(!Array.isArray(e)||e.length===0||t.type!==void 0)return;let r=[];for(let n of e){if(!n||typeof n!="object")return;YR(n);let s=Object.keys(n);if(s.length!==1||s[0]!=="type")return;let o=n.type;for(let i of Array.isArray(o)?o:[o]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete t.anyOf,t.type=r.length===1?r[0]:r}function GR(t){let e=t.additionalProperties;return e===void 0||e===!1||typeof e!="object"||e===null?null:Object.keys(e).length?e:null}function hb(t){let e=[];for(let o of t){if(typeof o!="object"||o.type!=="object")return null;for(let i in o)if(!XR.has(i))return null;e.push(o)}let r={},n=new Set;for(let o of e){for(let i in o.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let l of e){let u=l.properties?.[i]??GR(l);u!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(u))||a.push(u))}let c=a.length===1?a[0]:hb(a)??{allOf:a};zt(r,i,c)}for(let i of o.required??[])n.add(i)}let s={type:"object",properties:r};if(n.size&&(s.required=[...n]),e.every(o=>o.additionalProperties===!1))s.additionalProperties=!1;else{let o=[];for(let i of e){let a=GR(i);a&&!o.some(c=>JSON.stringify(c)===JSON.stringify(a))&&o.push(a)}o.length===1?s.additionalProperties=o[0]:o.length>1&&(s.additionalProperties={allOf:o})}return s}function ZW(t){let e=t.allOf;if(!Array.isArray(e)||e.length<2)return;for(let s of XR)if(s in t)return;let r=e.filter(s=>JR.some(o=>Array.isArray(s[o]))),n=null;if(!r.length)n=hb(e);else{let s=r[0],o=JR.find(c=>Array.isArray(s[c]));if(Object.keys(s).length!==1)return;let i=e.filter(c=>c!==s),a=s[o].map(c=>hb([...i,c]));if(a.some(c=>!c))return;n={[o]:a}}n&&(delete t.allOf,ul(t,n))}function hl(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=t.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){n(d);let p=t.seen.get(d),m=p.schema;if(m.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(m)):ul(l,m),ul(l,u),a._zod.parent===d)for(let g in l)g==="$ref"||g==="allOf"||g in u||delete l[g];if(m.$ref&&p.def)for(let g in l)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(l[g])===JSON.stringify(p.def[g])&&delete l[g]}let f=a._zod.parent;if(f&&f!==d){n(f);let p=t.seen.get(f);if(p?.schema.$ref&&(l.$ref=p.schema.$ref,p.def))for(let m in l)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(l[m])===JSON.stringify(p.def[m])&&delete l[m]}t.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!t.external||t.sharedEmitDoneFor!==t.external){for(let a of[...t.seen.entries()].reverse())n(a[0]);if(t.target!=="openapi-3.0")for(let a of t.seen.entries())YR(a[1].def??a[1].schema);for(let a of t.deferred)a();if(t.intersections.length){let a=new Map;for(let c of t.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let d=a.get(u);d?d.push(l):a.set(u,[l])}for(let c of t.intersections)for(let l of a.get(c)??[])ZW(l)}}let s={};if(t.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");s.$id=t.external.uri(a)}ul(s,r.defId?r.schema:r.def??r.schema);let o=t.metadataRegistry.get(e)?.id;o!==void 0&&s.id===o&&delete s.id;let i=t.external?.defs??{};if(!t.external||t.sharedEmitDoneFor!==t.external)for(let a of t.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,zt(i,c.defId,c.def))}t.external&&(t.sharedEmitDoneFor=t.external),t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?s.$defs=i:s.definitions=i);try{let a=JSON.parse(JSON.stringify(s));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:dl(e,"input",t.processors),output:dl(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function kt(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let n=t._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return kt(n.element,r);if(n.type==="set")return kt(n.valueType,r);if(n.type==="lazy")return kt(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return kt(n.innerType,r);if(n.type==="intersection")return kt(n.left,r)||kt(n.right,r);if(n.type==="record"||n.type==="map")return kt(n.keyType,r)||kt(n.valueType,r);if(n.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:kt(n.in,r)||kt(n.out,r);if(n.type==="object"){for(let s in n.shape)if(kt(n.shape[s],r))return!0;return!1}if(n.type==="union"){for(let s of n.options)if(kt(s,r))return!0;return!1}if(n.type==="tuple"){for(let s of n.items)if(kt(s,r))return!0;return!!(n.rest&&kt(n.rest,r))}return!1}var XR,JR,QR,dl,zp=$(()=>{kw();$t();XR=new Set(["type","properties","required","additionalProperties"]),JR=["oneOf","anyOf"];QR=(t,e={})=>r=>{let n=fl({...r,processors:e});return Ie(t,n),pl(n,t),hl(n,t)},dl=(t,e,r={})=>n=>{let{libraryOptions:s,target:o}=n??{},i=fl({...s??{},target:o,io:e,processors:r});return Ie(t,i),pl(i,t),hl(i,t)}});function Lt(t){let e={},r=t._zod.def,n=t._zod.traits.has("$ZodCheck")?[t,...r.checks??[]]:r.checks??[];for(let o of n)UW[o._zod.def.check]?.(e,o._zod.def);let s=t._zod.bag;s.minimum!==void 0&&Ni(e,"minimum",s.minimum),s.exclusiveMinimum!==void 0&&Ni(e,"exclusiveMinimum",s.exclusiveMinimum),s.maximum!==void 0&&Ci(e,"maximum",s.maximum),s.exclusiveMaximum!==void 0&&Ci(e,"exclusiveMaximum",s.exclusiveMaximum),s.multipleOf!==void 0&&oA(e,s.multipleOf),s.format!==void 0&&(e.format??(e.format=s.format),s.format.includes("int")&&(e.isInt=!0)),s.mime&&aA(e,s.mime);for(let o of s.patterns??[])iA(e,o);return e}function ml(t){let e=t._zod.def;return e.type==="pipe"&&e.in._zod.traits.has("$ZodTransform")?ml(e.out):e.type==="catch"?ml(e.innerType):t._zod.optin}function mb(t,e,r){if(e.$ref){if(r.has(e))return e;r.add(e);let m=t.get(e)?.def;if(!m)return e;let h=mb(t,m,r);return h===m?e:h}for(let m of["anyOf","oneOf"]){let h=e[m];if(!Array.isArray(h))continue;let g=h.map(y=>mb(t,y,r));g.some((y,w)=>y!==h[w])&&(e={...e,[m]:g})}let n=Array.isArray(e.type)?e.type:[e.type],s=!n.includes("string")&&n.some(m=>m==="number"||m==="integer"),o=e.enum??(e.const!==void 0?[e.const]:void 0);if(!s&&!o?.some(m=>typeof m=="number"))return e;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=e;return p.enum?p.enum=p.enum.map(m=>typeof m=="number"?String(m):m):typeof p.const=="number"&&(p.const=String(p.const)),s&&(p.type="string",o||(p.pattern=(n.includes("number")?rl:$v).source)),p}function KW(t){let e=new Map;for(let n of t.seen.values())n.def&&!e.has(n.schema)&&e.set(n.schema,n);let r=new Map;for(let n of gb.get(t)??[]){let s=t.seen.get(n),o=(s?.def??s?.schema)?.propertyNames;if(!o||o===!0||r.has(o))continue;let i=mb(e,o,new Set);i!==o&&r.set(o,i)}if(r.size)for(let n of t.seen.values())for(let s of[n.schema,n.def]){let o=s&&r.get(s.propertyNames);o&&(s.propertyNames=o)}}function kA(t,e,r,n,s){let o=!1,i=JSON.stringify(t,(a,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(st(e,r,n,s,"BigInt defaults cannot be represented in JSON Schema"),Ab):JSON.parse(i)}function qb(t,e){if("_idmap"in t){let n=t,s=fl({...e,processors:sA}),o={};for(let c of n._idmap.entries()){let[l,u]=c;Ie(u,s)}let i={},a={registry:n,uri:e?.uri,defs:o};s.external=a;for(let c of n._idmap.entries()){let[l,u]=c;pl(s,u),zt(i,l,hl(s,u))}if(Object.keys(o).length>0){let c=s.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[c]:o}}return{schemas:i}}let r=fl({...e,processors:sA});return Ie(t,r),pl(r,t),hl(r,t)}var Ni,Ci,eA,oA,iA,aA,cA,tA,rA,nA,UW,VW,BW,lA,yb,_b,vb,uA,dA,wb,fA,pA,bb,hA,Sb,mA,$b,kb,gA,yA,_A,vA,xb,wA,Eb,bA,SA,Tb,Pb,Ob,Ib,$A,gb,Nb,Cb,Rb,Ab,zb,jb,Mb,Lb,Db,xA,jp,EA,sA,Fb=$(()=>{nl();_w();zp();$t();Ni=(t,e,r)=>{(t[e]===void 0||r>t[e])&&(t[e]=r)},Ci=(t,e,r)=>{(t[e]===void 0||r<t[e])&&(t[e]=r)},eA=(t,e)=>{Ni(t,"minimum",e),Ci(t,"maximum",e)},oA=(t,e)=>{t.multipleOf??(t.multipleOf=[]),t.multipleOf.includes(e)||t.multipleOf.push(e)},iA=(t,e)=>{t.patterns??(t.patterns=new Set),t.patterns.add(e)},aA=(t,e)=>{t.mime=t.mime?t.mime.filter(r=>e.includes(r)):[...e]},cA=(t,e)=>{t.format=e,e.includes("int")&&(t.isInt=!0)},tA=(t,e)=>Ni(t,"minimum",e.minimum),rA=(t,e)=>Ci(t,"maximum",e.maximum),nA=t=>(e,r)=>{cA(e,r.format);let[n,s]=t[r.format];Ni(e,"minimum",n),Ci(e,"maximum",s)},UW={greater_than:(t,e)=>Ni(t,e.inclusive?"minimum":"exclusiveMinimum",e.value),less_than:(t,e)=>Ci(t,e.inclusive?"maximum":"exclusiveMaximum",e.value),multiple_of:(t,e)=>oA(t,e.value),number_format:nA(Kc),bigint_format:nA(np),min_length:tA,max_length:rA,length_equals:(t,e)=>eA(t,e.length),min_size:tA,max_size:rA,size_equals:(t,e)=>eA(t,e.size),string_format:(t,e)=>{cA(t,e.format),e.pattern&&iA(t,e.pattern),(e.format==="base64"||e.format==="base64url")&&(t.contentEncoding=e.format),(e.local||e.precision===-1)&&(t.laxFormat=!0)},mime_type:(t,e)=>aA(t,e.mime)};VW={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},BW=new Map([[Kv,qC],[gp,FC]]),lA=t=>BW.get(t)??t,yb=(t,e,r,n)=>{let s=r;s.type="string";let{minimum:o,maximum:i,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Lt(t);if(typeof o=="number"&&(s.minLength=o),typeof i=="number"&&(s.maxLength=i),a&&(s.format=VW[a]??a,s.format===""&&delete s.format,(a==="time"||u)&&delete s.format),l&&(s.contentEncoding=l),c&&c.size>0){let d=[...c].map(lA);d.length===1?s.pattern=d[0].source:d.length>1&&(s.allOf=[...d.map(f=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},_b=(t,e,r,n)=>{let s=r,{minimum:o,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Lt(t);s.type=u?"integer":"number";let d=typeof l=="number"&&l>=(o??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=e.target==="draft-04"||e.target==="openapi-3.0";if(d?p?(s.minimum=l,s.exclusiveMinimum=!0):s.exclusiveMinimum=l:typeof o=="number"&&(s.minimum=o),f?p?(s.maximum=c,s.exclusiveMaximum=!0):s.exclusiveMaximum=c:typeof i=="number"&&(s.maximum=i),a){let m=new Set;for(let y of a)Number.isFinite(y)&&y!==0?m.add(Math.abs(y)):st(t,e,s,n,`A multipleOf divisor of ${y} cannot be represented in JSON Schema`);let[h,...g]=m;h!==void 0&&(s.multipleOf=h),g.length&&(s.allOf=[...s.allOf??[],...g.map(y=>({multipleOf:y}))])}},vb=(t,e,r,n)=>{r.type="boolean"},uA=(t,e,r,n)=>{st(t,e,r,n,"BigInt cannot be represented in JSON Schema")},dA=(t,e,r,n)=>{st(t,e,r,n,"Symbols cannot be represented in JSON Schema")},wb=(t,e,r,n)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},fA=(t,e,r,n)=>{st(t,e,r,n,"Undefined cannot be represented in JSON Schema")},pA=(t,e,r,n)=>{st(t,e,r,n,"Void cannot be represented in JSON Schema")},bb=(t,e,r,n)=>{r.not={}},hA=(t,e,r,n)=>{},Sb=(t,e,r,n)=>{},mA=(t,e,r,n)=>{st(t,e,r,n,"Date cannot be represented in JSON Schema")},$b=(t,e,r,n)=>{let s=t._zod.def,o=$i(s.entries);if(o.length===0){r.not={};return}o.every(i=>typeof i=="number")&&(r.type="number"),o.every(i=>typeof i=="string")&&(r.type="string"),r.enum=o},kb=(t,e,r,n)=>{let s=t._zod.def;if(s.values.length===0){r.not={};return}let o=[];for(let i of s.values)if(i===void 0){if(st(t,e,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(st(t,e,r,n,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(i))}else o.push(i);if(o.length!==0)if(o.length===1){let i=o[0];r.type=i===null?"null":typeof i,e.target==="draft-04"||e.target==="openapi-3.0"?r.enum=[i]:r.const=i}else o.every(i=>typeof i=="number")&&(r.type="number"),o.every(i=>typeof i=="string")&&(r.type="string"),o.every(i=>typeof i=="boolean")&&(r.type="boolean"),o.every(i=>i===null)&&(r.type="null"),r.enum=o},gA=(t,e,r,n)=>{st(t,e,r,n,"NaN cannot be represented in JSON Schema")},yA=(t,e,r,n)=>{let s=r,o=t._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");s.type="string",s.pattern=o.source},_A=(t,e,r,n)=>{let s=r;s.type="string",s.format="binary",s.contentEncoding="binary";let{minimum:o,maximum:i,mime:a}=Lt(t);o!==void 0&&(s.minLength=o),i!==void 0&&(s.maxLength=i),a&&(a.length===0?s.not={}:a.length===1?s.contentMediaType=a[0]:s.anyOf=a.map(c=>({contentMediaType:c})))},vA=(t,e,r,n)=>{r.type="boolean"},xb=(t,e,r,n)=>{st(t,e,r,n,"Custom types cannot be represented in JSON Schema")},wA=(t,e,r,n)=>{st(t,e,r,n,"Function types cannot be represented in JSON Schema")},Eb=(t,e,r,n)=>{st(t,e,r,n,"Transforms cannot be represented in JSON Schema")},bA=(t,e,r,n)=>{st(t,e,r,n,"Map cannot be represented in JSON Schema")},SA=(t,e,r,n)=>{st(t,e,r,n,"Set cannot be represented in JSON Schema")},Tb=(t,e,r,n)=>{let s=r,o=t._zod.def,{minimum:i,maximum:a}=Lt(t);typeof i=="number"&&(s.minItems=i),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=Ie(o.element,e,{...n,path:[...n.path,"items"]})};Pb=(t,e,r,n)=>{let s=r,o=t._zod.def,i=o.shape;if(Object.getOwnPropertySymbols(i).length&&st(t,e,s,n,"Symbol keys cannot be represented in JSON Schema"))return;s.type="object",s.properties={};for(let l in i)zt(s.properties,l,Ie(i[l],e,{...n,path:[...n.path,"properties",l]}));let c=[];for(let l of Object.keys(i)){let u=o.shape[l];(e.io==="input"?ml(u)===void 0:u._zod.optout===void 0)&&c.push(l)}c.length>0&&(s.required=c),o.catchall?._zod.def.type==="never"?s.additionalProperties=!1:o.catchall?o.catchall&&(s.additionalProperties=Ie(o.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(s.additionalProperties=!1)},Ob=(t,e,r,n)=>{let s=t._zod.def,o=s.inclusive===!1,i=s.options.map((a,c)=>Ie(a,e,{...n,path:[...n.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=i:r.anyOf=i},Ib=(t,e,r,n)=>{let s=t._zod.def,o=Ie(s.left,e,{...n,path:[...n.path,"allOf",0]}),i=Ie(s.right,e,{...n,path:[...n.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(o)?o.allOf:[o],...a(i)?i.allOf:[i]];r.allOf=c,e.intersections.push(c)},$A=(t,e,r,n)=>{let s=r,o=t._zod.def;s.type="array";let i=e.target==="draft-2020-12"?"prefixItems":"items",a=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((h,g)=>Ie(h,e,{...n,path:[...n.path,i,g]})),l=o.rest?Ie(o.rest,e,{...n,path:[...n.path,a,...e.target==="openapi-3.0"?[o.items.length]:[]]}):null,u=o.items.length;for(;u>0;){let h=o.items[u-1];if(!(e.io==="input"?ml(h)!==void 0:h._zod.optout==="optional"))break;u--}let d=o.items.length,f=!o.rest;e.target==="draft-2020-12"?(s.prefixItems=c,f?s.items=!1:l&&(s.items=l),u>0&&(s.minItems=u),f&&(s.maxItems=d)):e.target==="openapi-3.0"?(s.items={anyOf:c},l&&s.items.anyOf.push(l),u>0&&(s.minItems=u),f&&(s.maxItems=d)):(s.items=c,f?s.additionalItems=!1:l&&(s.additionalItems=l),u>0&&(s.minItems=u),f&&(s.maxItems=d));let{minimum:p,maximum:m}=Lt(t);typeof p=="number"&&(s.minItems=p),typeof m=="number"&&(s.maxItems=m)};gb=new WeakMap;Nb=(t,e,r,n)=>{let s=r,o=t._zod.def;s.type="object";let i=o.keyType,a=Lt(i).patterns;if(o.mode==="loose"&&a&&a.size>0){let u=Ie(o.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});s.patternProperties={};for(let d of a)zt(s.patternProperties,lA(d).source,u)}else{if(e.target==="draft-07"||e.target==="draft-2020-12"){s.propertyNames=Ie(o.keyType,e,{...n,path:[...n.path,"propertyNames"]});let u=gb.get(e);u||(u=[],gb.set(e,u),e.deferred.push(()=>KW(e))),u.push(t)}s.additionalProperties=Ie(o.valueType,e,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,l=e.io==="input"&&ml(o.valueType)!==void 0;if(c&&!o.partial&&!l){let u=[...c].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(s.required=u.map(String))}},Cb=(t,e,r,n)=>{let s=t._zod.def,o=Ie(s.innerType,e,n),i=e.seen.get(t);e.target==="openapi-3.0"?(i.ref=s.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},Rb=(t,e,r,n)=>{let s=t._zod.def;Ie(s.innerType,e,n);let o=e.seen.get(t);o.ref=s.innerType},Ab=Symbol();zb=(t,e,r,n)=>{let s=t._zod.def;Ie(s.innerType,e,n);let o=e.seen.get(t);o.ref=s.innerType;let i=kA(s.defaultValue,t,e,r,n);i!==Ab&&(r.default=i)},jb=(t,e,r,n)=>{let s=t._zod.def;Ie(s.innerType,e,n);let o=e.seen.get(t);if(o.ref=s.innerType,e.io!=="input")return;let i=kA(s.defaultValue,t,e,r,n);i!==Ab&&(r._prefault=i)},Mb=(t,e,r,n)=>{let s=t._zod.def;Ie(s.innerType,e,n);let o=e.seen.get(t);o.ref=s.innerType;let i;try{i=s.catchValue(void 0)}catch{st(t,e,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},Lb=(t,e,r,n)=>{let s=t._zod.def,o=s.in._zod.traits.has("$ZodTransform"),i=e.io==="input"?o?s.out:s.in:s.out;Ie(i,e,n);let a=e.seen.get(t);a.ref=i},Db=(t,e,r,n)=>{let s=t._zod.def;Ie(s.innerType,e,n);let o=e.seen.get(t);o.ref=s.innerType,r.readOnly=!0},xA=(t,e,r,n)=>{let s=t._zod.def;Ie(s.innerType,e,n);let o=e.seen.get(t);o.ref=s.innerType},jp=(t,e,r,n)=>{let s=t._zod.def;Ie(s.innerType,e,n);let o=e.seen.get(t);o.ref=s.innerType},EA=(t,e,r,n)=>{let s=t._zod.innerType;Ie(s,e,n);let o=e.seen.get(t);o.ref=s},sA={string:yb,number:_b,boolean:vb,bigint:uA,symbol:dA,null:wb,undefined:fA,void:pA,never:bb,any:hA,unknown:Sb,date:mA,enum:$b,literal:kb,nan:gA,template_literal:yA,file:_A,success:vA,custom:xb,function:wA,transform:Eb,map:bA,set:SA,array:Tb,object:Pb,union:Ob,intersection:Ib,tuple:$A,record:Nb,nullable:Cb,nonoptional:Rb,default:zb,prefault:jb,catch:Mb,pipe:Lb,readonly:Db,promise:xA,optional:jp,lazy:EA}});var TA=$(()=>{});var tr=$(()=>{eo();kC();_v();_w();qR();dp();Pv();$t();nl();xp();kw();Tv();VR();HR();zp();TA()});var Zb=$(()=>{tr()});function Ub(t,e){let r={type:"object",shape:t??{},...U(e)};return new q5(r)}var D5,q5,PA=$(()=>{tr();$t();Zb();D5=E("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");Oe.init(t,e),t.def=e,t.type=e.type},{get with(){return this.check},set with(t){tn(this,"with",t)},parse(t,e){return vv(this,t,e,{callee:this.parse})},parseAsync(t,e){return wv(this,t,e,{callee:this.parseAsync})},safeParse(t,e){return Qc(this,t,e)},safeParseAsync(t,e){return tl(this,t,e)},check(...t){let e=this.def;return this.clone({...e,checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]},{parent:!0})},clone(t,e){return jt(this,t,e)},brand(){return this},register(t,e){return t.add(this,e),this},apply(t,...e){return e.length===0?t(this):t(this,...e)}}),q5=E("ZodMiniObject",(t,e)=>{nw.init(t,e),D5.init(t,e),hv(t,"shape",r=>r._zod.def.shape,!1)})});var OA=$(()=>{});var IA=$(()=>{});var NA=$(()=>{});var CA=$(()=>{tr();Zb();PA();OA();Fb();xp();IA();NA()});var Vb=$(()=>{CA()});function nn(t){return!!t._zod}function no(t){let e=Object.values(t);if(e.length===0)return Ub({});let r=e.every(nn),n=e.every(s=>!nn(s));if(r)return Ub(t);if(n)return FN(t);throw new Error("Mixed Zod versions detected in object shape.")}function ds(t,e){return nn(t)?Qc(t,e):t.safeParse(e)}async function Mp(t,e){return nn(t)?await tl(t,e):await t.safeParseAsync(e)}function fs(t){if(!t)return;let e;if(nn(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Ri(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(s=>typeof s=="object"&&s!==null&&(s._def!==void 0||s._zod!==void 0||typeof s.parse=="function")))return no(t)}}if(nn(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function U5(t){return t.length===0?"object root":t.reduce((e,r,n)=>n===0?String(r):typeof r=="number"?`${e}[${r}]`:`${e}.${r}`,"")}function Lp(t){if(t&&typeof t=="object"){if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0)return t.issues.map(e=>e.path?.length?`${e.message} at ${U5(e.path)}`:e.message).join(`
291
- `);if("message"in t&&typeof t.message=="string")return t.message;try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function AA(t){return t.description}function zA(t){if(nn(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function Ai(t){if(nn(t)){let o=t._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}var gl=$(()=>{Vc();Vb()});var Bb=$(()=>{tr()});function Dp(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,e,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,e,{value:n,configurable:!0,writable:!0})}})}var jA,G5,rr,Kb=$(()=>{tr();tr();$t();jA=new WeakSet([Object.prototype,Error.prototype]);G5=(t,e)=>{fC.init(t,e),t.name="ZodError";let r=Object.getPrototypeOf(t);jA.has(r)||(jA.add(r),Dp(r,"format",n=>s=>hC(n,s)),Dp(r,"flatten",n=>s=>pC(n,s)),Dp(r,"addIssue",n=>s=>{n.issues.push(s),n.message=JSON.stringify(n.issues,ki,2)}),Dp(r,"addIssues",n=>s=>{n.issues.push(...s),n.message=JSON.stringify(n.issues,ki,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},rr=E("ZodError",G5,void 0,{Parent:Error})});var MA,LA,DA,qA,FA,ZA,UA,VA,BA,KA,HA,WA,Hb=$(()=>{tr();Kb();tr();MA=Gc(rr),LA=Yc(rr),DA=Xc(rr),qA=el(rr),FA=gC(rr),ZA=yC(rr),UA=_C(rr),VA=vC(rr),BA=wC(rr),KA=bC(rr),HA=SC(rr),WA=$C(rr)});function X5(){Mt.localeError||er(FR())}function Fp(){Mt.memoizer||er({memoizer:DR()})}function k(t){return xw(Q5,t)}function $e(t){return Ww(e1,t)}function JA(t){return Jw(_J,t)}function ot(t){return Gw(vJ,t)}function t1(t){return Yw(wJ,t)}function Ue(){return Xw(bJ)}function $J(t){return Qw(SJ,t)}function ce(t,e){return KR(kJ,t,e)}function R(t,e){let r={type:"object",shape:t??{},...V.normalizeParams(e)};return new r1(r)}function xt(t,e){return new r1({type:"object",shape:t,catchall:Ue(),...V.normalizeParams(e)})}function Me(t,e){return new n1({type:"union",options:t,...V.normalizeParams(e)})}function Jb(t,e,r){return new xJ({type:"union",options:e,discriminator:t,...V.normalizeParams(r)})}function Zp(t,e){return new EJ({type:"intersection",left:t,right:e})}function ze(t,e,r){return!e||!e._zod?new GA({type:"record",keyType:k(),valueType:t,...V.normalizeParams(e)}):new GA({type:"record",keyType:t,valueType:e,...V.normalizeParams(r)})}function Dt(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Wb({type:"enum",entries:r,...V.normalizeParams(e)})}function L(t,e){return new TJ({type:"literal",values:Array.isArray(t)?t:[t],...V.normalizeParams(e)})}function s1(t){return new PJ({type:"transform",transform:t})}function Ve(t){return new Up({type:"optional",innerType:t})}function OJ(t){return new o1({type:"optional",innerType:t})}function YA(t){return new IJ({type:"nullable",innerType:t})}function CJ(t,e){return new NJ({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():V.shallowClone(e)}})}function AJ(t,e){return new RJ({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():V.shallowClone(e)}})}function zJ(t,e){return new i1({type:"nonoptional",innerType:t,...V.normalizeParams(e)})}function MJ(t,e){return new jJ({type:"catch",innerType:t,catchValue:typeof e=="function"?e:V.constantCatch(e)})}function XA(t,e){return new a1({type:"pipe",in:t,out:e})}function qJ(t){return new DJ({type:"readonly",innerType:t})}function l1(t,e){return db(c1,t??(()=>!0),e)}function FJ(t,e={}){return fb(c1,t,e)}function ZJ(t,e){return pb(t,e)}function Gb(t,e){return new LJ({type:"pipe",in:s1(t),out:e})}var Be,QA,Q5,We,yl,_l,vl,wl,eJ,tJ,qp,rJ,nJ,sJ,oJ,iJ,aJ,cJ,lJ,uJ,dJ,fJ,pJ,hJ,mJ,gJ,yJ,e1,_J,vJ,wJ,bJ,SJ,kJ,r1,n1,xJ,EJ,GA,Wb,TJ,PJ,Up,o1,IJ,NJ,RJ,i1,jJ,a1,LJ,DJ,c1,Vp=$(()=>{tr();tr();Fb();zp();ZR();Bb();Hb();Be=E("ZodType",(t,e)=>(X5(),Oe.init(t,e),t.def=e,t.type=e.type,t),{check(...t){let e=this.def;return this.clone(V.mergeDefs(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...t){return this.check(...t)},clone(t,e){return jt(this,t,e)},brand(){return this},register(t,e){return t.add(this,e),this},refine(t,e){return this.check(FJ(t,e))},superRefine(t,e){return this.check(ZJ(t,e))},overwrite(t){return this.check(us(t))},optional(){return Ve(this)},exactOptional(){return OJ(this)},nullable(){return YA(this)},nullish(){return Ve(YA(this))},nonoptional(t){return zJ(this,t)},array(){return ce(this)},or(t){return Me([this,t])},and(t){return Zp(this,t)},transform(t){return XA(this,s1(t))},default(t){return CJ(this,t)},prefault(t){return AJ(this,t)},catch(t){return MJ(this,t)},pipe(t){return XA(this,t)},readonly(){return qJ(this)},describe(t){let e=this.clone();return to.add(e,{description:t}),e},meta(...t){if(t.length===0)return to.get(this);let e=this.clone();return to.add(e,t[0]),e},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(t,...e){return e.length===0?t(this):t(this,...e)},get"~standard"(){return V.hide(this,"~standard",{...Iv(this),jsonSchema:{input:dl(this,"input"),output:dl(this,"output")}})},set"~standard"(t){V.own(this,"~standard",t)},parse:function t(e,r){return MA(this,e,r,{callee:t})},parseAsync:async function t(e,r){return await LA(this,e,r,{callee:t})},safeParse(t,e){return DA(this,t,e)},async safeParseAsync(t,e){return qA(this,t,e)},get spa(){return this?.safeParseAsync},set spa(t){V.own(this,"spa",t)},validate(t,e){return cp(this,t,e)},validateAsync(t,e){return lp(this,t,e)},encode:function t(e,r){return FA(this,e,r,{callee:t})},decode:function t(e,r){return ZA(this,e,r,{callee:t})},encodeAsync:async function t(e,r){return await UA(this,e,r,{callee:t})},decodeAsync:async function t(e,r){return await VA(this,e,r,{callee:t})},safeEncode(t,e){return BA(this,t,e)},safeDecode(t,e){return KA(this,t,e)},async safeEncodeAsync(t,e){return HA(this,t,e)},async safeDecodeAsync(t,e){return WA(this,t,e)},toJSONSchema(t){return QR(this,{})(t)},get description(){return to.get(this)?.description},get _def(){return this._zod.def}}),QA=E("_ZodString",(t,e)=>{ol.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>yb(t,r,n,s)},V.derived({format:t=>Lt(t).format??null,minLength:t=>Lt(t).minimum??null,maxLength:t=>Lt(t).maximum??null},{regex(...t){return this.check(eb(...t))},includes(...t){return this.check(nb(...t))},startsWith(...t){return this.check(sb(...t))},endsWith(...t){return this.check(ob(...t))},min(...t){return this.check(Ii(...t))},max(...t){return this.check(Rp(...t))},length(...t){return this.check(Ap(...t))},nonempty(...t){return this.check(Ii(1,...t))},lowercase(t){return this.check(tb(t))},uppercase(t){return this.check(rb(t))},trim(){return this.check(ab())},normalize(...t){return this.check(ib(...t))},toLowerCase(){return this.check(cb())},toUpperCase(){return this.check(lb())},slugify(){return this.check(ub())}})),Q5=E("ZodString",(t,e)=>{ol.init(t,e),QA.init(t,e)},{email(t){return this.check(Ew(eJ,t))},url(t){return this.check(Cw(rJ,t))},jwt(t){return this.check(Hw(yJ,t))},emoji(t){return this.check(Rw(nJ,t))},guid(t){return this.check(Tw(tJ,t))},uuid(t){return this.check(Pw(qp,t))},uuidv4(t){return this.check(Ow(qp,t))},uuidv6(t){return this.check(Iw(qp,t))},uuidv7(t){return this.check(Nw(qp,t))},nanoid(t){return this.check(Aw(sJ,t))},cuid(t){return this.check(zw(oJ,t))},cuid2(t){return this.check(jw(iJ,t))},ulid(t){return this.check(Mw(aJ,t))},base64(t){return this.check(Vw(hJ,t))},base64url(t){return this.check(Bw(mJ,t))},xid(t){return this.check(Lw(cJ,t))},ksuid(t){return this.check(Dw(lJ,t))},ipv4(t){return this.check(qw(uJ,t))},ipv6(t){return this.check(Fw(dJ,t))},cidrv4(t){return this.check(Zw(fJ,t))},cidrv6(t){return this.check(Uw(pJ,t))},e164(t){return this.check(Kw(gJ,t))},datetime(t){return this.check(Ep(yl,t))},date(t){return this.check(Tp(_l,t))},time(t){return this.check(Pp(vl,t))},duration(t){return this.check(Op(wl,t))}});We=E("ZodStringFormat",(t,e)=>{Ae.init(t,e),QA.init(t,e)}),yl=E("ZodISODateTime",(t,e)=>{ER.init(t,e),We.init(t,e)}),_l=E("ZodISODate",(t,e)=>{TR.init(t,e),We.init(t,e)}),vl=E("ZodISOTime",(t,e)=>{PR.init(t,e),We.init(t,e)}),wl=E("ZodISODuration",(t,e)=>{OR.init(t,e),We.init(t,e)}),eJ=E("ZodEmail",(t,e)=>{Rv.init(t,e),We.init(t,e)}),tJ=E("ZodGUID",(t,e)=>{Nv.init(t,e),We.init(t,e)}),qp=E("ZodUUID",(t,e)=>{Cv.init(t,e),We.init(t,e)}),rJ=E("ZodURL",(t,e)=>{Av.init(t,e),We.init(t,e)}),nJ=E("ZodEmoji",(t,e)=>{zv.init(t,e),We.init(t,e)}),sJ=E("ZodNanoID",(t,e)=>{jv.init(t,e),We.init(t,e)}),oJ=E("ZodCUID",(t,e)=>{Mv.init(t,e),We.init(t,e)}),iJ=E("ZodCUID2",(t,e)=>{Lv.init(t,e),We.init(t,e)}),aJ=E("ZodULID",(t,e)=>{Dv.init(t,e),We.init(t,e)}),cJ=E("ZodXID",(t,e)=>{qv.init(t,e),We.init(t,e)}),lJ=E("ZodKSUID",(t,e)=>{Fv.init(t,e),We.init(t,e)}),uJ=E("ZodIPv4",(t,e)=>{Zv.init(t,e),We.init(t,e)}),dJ=E("ZodIPv6",(t,e)=>{Uv.init(t,e),We.init(t,e)}),fJ=E("ZodCIDRv4",(t,e)=>{Vv.init(t,e),We.init(t,e)}),pJ=E("ZodCIDRv6",(t,e)=>{Bv.init(t,e),We.init(t,e)}),hJ=E("ZodBase64",(t,e)=>{Hv.init(t,e),We.init(t,e)}),mJ=E("ZodBase64URL",(t,e)=>{Wv.init(t,e),We.init(t,e)}),gJ=E("ZodE164",(t,e)=>{Jv.init(t,e),We.init(t,e)}),yJ=E("ZodJWT",(t,e)=>{Gv.init(t,e),We.init(t,e)}),e1=E("ZodNumber",(t,e)=>{yp.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>_b(t,r,n,s),t.isFinite=!0},V.derived({minValue:t=>{let{minimum:e,exclusiveMinimum:r}=Lt(t);return Math.max(e??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:t=>{let{maximum:e,exclusiveMaximum:r}=Lt(t);return Math.min(e??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:t=>{let{isInt:e,multipleOf:r}=Lt(t);return!!e||!!r?.some(Number.isSafeInteger)},format:t=>Lt(t).format??null},{gt(t,e){return this.check(Np(t,e))},gte(t,e){return this.check(ll(t,e))},min(t,e){return this.check(ll(t,e))},lt(t,e){return this.check(Ip(t,e))},lte(t,e){return this.check(cl(t,e))},max(t,e){return this.check(cl(t,e))},int(t){return this.check(JA(t))},safe(t){return this.check(JA(t))},positive(t){return this.check(Np(0,t))},nonnegative(t){return this.check(ll(0,t))},negative(t){return this.check(Ip(0,t))},nonpositive(t){return this.check(cl(0,t))},multipleOf(t,e){return this.check(Cp(t,e))},step(t,e){return this.check(Cp(t,e))},finite(){return this}}));_J=E("ZodNumberFormat",(t,e)=>{Yv.init(t,e),e1.init(t,e)});vJ=E("ZodBoolean",(t,e)=>{Xv.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>vb(t,r,n,s)});wJ=E("ZodNull",(t,e)=>{Qv.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>wb(t,r,n,s)});bJ=E("ZodUnknown",(t,e)=>{ew.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>Sb(t,r,n,s)});SJ=E("ZodNever",(t,e)=>{tw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>bb(t,r,n,s)});kJ=E("ZodArray",(t,e)=>{Fp(),rw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>Tb(t,r,n,s),t.element=e.element},{min(t,e){return this.check(Ii(t,e))},nonempty(t){return this.check(Ii(1,t))},max(t,e){return this.check(Rp(t,e))},length(t,e){return this.check(Ap(t,e))},unwrap(){return this.element}});r1=E("ZodObject",(t,e)=>{Fp(),AR.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>Pb(t,r,n,s),V.installLazyProp(t,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Dt(Object.keys(this._zod.def.shape))},catchall(t){return this.clone(V.mergeDefs(this._zod.def,{catchall:t}))},passthrough(){return this.clone(V.mergeDefs(this._zod.def,{catchall:Ue()}))},loose(){return this.clone(V.mergeDefs(this._zod.def,{catchall:Ue()}))},strict(){return this.clone(V.mergeDefs(this._zod.def,{catchall:$J()}))},strip(){return this.clone(V.mergeDefs(this._zod.def,{catchall:void 0}))},extend(t){return V.extend(this,t)},safeExtend(t){return V.safeExtend(this,t)},merge(t){return V.merge(this,t)},pick(t){return V.pick(this,t)},omit(t){return V.omit(this,t)},partial(...t){return V.partial(Up,this,t[0])},exactPartial(...t){return V.partial(o1,this,t[0],"exactPartial")},required(...t){return V.required(i1,this,t[0])}});n1=E("ZodUnion",(t,e)=>{_p.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>Ob(t,r,n,s),t.options=e.options});xJ=E("ZodDiscriminatedUnion",(t,e)=>{n1.init(t,e),sw.init(t,e)});EJ=E("ZodIntersection",(t,e)=>{ow.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>Ib(t,r,n,s)});GA=E("ZodRecord",(t,e)=>{Fp(),iw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>Nb(t,r,n,s),t.keyType=e.keyType,t.valueType=e.valueType});Wb=E("ZodEnum",(t,e)=>{aw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(n,s,o)=>$b(t,n,s,o),t.enum=e.entries,t.options=[...t._zod.values];let r=new Set(Object.keys(e.entries));t.extract=(n,s)=>{let o={};for(let i of n)if(r.has(i))o[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Wb({...e,checks:[],...V.normalizeParams(s),entries:o})},t.exclude=(n,s)=>{let o={...e.entries};for(let i of n)if(r.has(i))delete o[i];else throw new Error(`Key ${i} not found in enum`);return new Wb({...e,checks:[],...V.normalizeParams(s),entries:o})}});TJ=E("ZodLiteral",(t,e)=>{cw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>kb(t,r,n,s),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});PJ=E("ZodTransform",(t,e)=>{Fp(),lw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>Eb(t,r,n,s),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Pi(t.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(V.issue(o,r.value,e));else{let i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=t),r.issues.push(V.issue(i))}};let s=e.transform(r.value,r);return s instanceof Promise?s.then(o=>(r.value=o,r)):(r.value=s,r)}});Up=E("ZodOptional",(t,e)=>{vp.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>jp(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});o1=E("ZodExactOptional",(t,e)=>{uw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>jp(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});IJ=E("ZodNullable",(t,e)=>{dw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>Cb(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});NJ=E("ZodDefault",(t,e)=>{fw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>zb(t,r,n,s),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});RJ=E("ZodPrefault",(t,e)=>{pw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>jb(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});i1=E("ZodNonOptional",(t,e)=>{hw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>Rb(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});jJ=E("ZodCatch",(t,e)=>{mw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>Mb(t,r,n,s),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});a1=E("ZodPipe",(t,e)=>{wp.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>Lb(t,r,n,s),t.in=e.in,t.out=e.out});LJ=E("ZodPreprocess",(t,e)=>{a1.init(t,e),zR.init(t,e)}),DJ=E("ZodReadonly",(t,e)=>{gw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>Db(t,r,n,s),t.unwrap=()=>t._zod.def.innerType});c1=E("ZodCustom",(t,e)=>{yw.init(t,e),Be.init(t,e),t._zod.processJSONSchema=(r,n,s)=>xb(t,r,n,s)})});var u1,d1=$(()=>{u1||(u1={})});var Bp={};Je(Bp,{ZodISODate:()=>_l,ZodISODateTime:()=>yl,ZodISODuration:()=>wl,ZodISOTime:()=>vl,date:()=>VJ,datetime:()=>UJ,duration:()=>KJ,time:()=>BJ});function UJ(t){return Ep(yl,t)}function VJ(t){return Tp(_l,t)}function BJ(t){return Pp(vl,t)}function KJ(t){return Op(wl,t)}var f1=$(()=>{tr();Vp();Vp()});var p1=$(()=>{});var Yb=$(()=>{tr();Vp();Bb();Kb();Hb();d1();xp();f1();p1()});var h1=$(()=>{Yb()});var m1=$(()=>{h1()});var Dz={};Je(Dz,{AnnotationsSchema:()=>ao,AudioContentSchema:()=>eh,BaseMetadataSchema:()=>so,BlobResourceContentsSchema:()=>f0,BooleanSchemaSchema:()=>mz,CallToolRequestParamsSchema:()=>rz,CallToolRequestSchema:()=>co,CallToolResultSchema:()=>Ul,CancelTaskRequestSchema:()=>jl,CancelTaskResultSchema:()=>c0,CancelledNotificationParamsSchema:()=>_1,CancelledNotificationSchema:()=>El,ClientCapabilitiesSchema:()=>S1,ClientNotificationSchema:()=>uG,ClientRequestSchema:()=>lG,ClientResultSchema:()=>dG,ClientTasksCapabilitySchema:()=>w1,CompatibilityCallToolResultSchema:()=>iG,CompleteRequestParamsSchema:()=>Az,CompleteRequestSchema:()=>Vl,CompleteResultSchema:()=>zz,ContentBlockSchema:()=>th,CreateMessageRequestParamsSchema:()=>pz,CreateMessageRequestSchema:()=>hz,CreateMessageResultSchema:()=>Ui,CreateMessageResultWithToolsSchema:()=>nh,CreateTaskResultSchema:()=>io,CursorSchema:()=>e0,DEFAULT_NEGOTIATED_PROTOCOL_VERSION:()=>JJ,ElicitRequestFormParamsSchema:()=>Tz,ElicitRequestParamsSchema:()=>Oz,ElicitRequestSchema:()=>Iz,ElicitRequestURLParamsSchema:()=>Pz,ElicitResultSchema:()=>lo,ElicitationCompleteNotificationParamsSchema:()=>Nz,ElicitationCompleteNotificationSchema:()=>Cz,EmbeddedResourceSchema:()=>W1,EmptyResultSchema:()=>xl,EnumSchemaSchema:()=>xz,ErrorCode:()=>F,GetPromptRequestParamsSchema:()=>K1,GetPromptRequestSchema:()=>Fl,GetPromptResultSchema:()=>Y1,GetTaskPayloadRequestSchema:()=>Rl,GetTaskPayloadResultSchema:()=>oG,GetTaskRequestSchema:()=>Nl,GetTaskResultSchema:()=>Cl,IconSchema:()=>v1,IconsSchema:()=>ji,ImageContentSchema:()=>Qp,ImplementationSchema:()=>a0,InitializeRequestParamsSchema:()=>$1,InitializeRequestSchema:()=>Tl,InitializeResultSchema:()=>x1,InitializedNotificationSchema:()=>Pl,JSONRPCErrorResponseSchema:()=>kl,JSONRPCErrorSchema:()=>XJ,JSONRPCMessageSchema:()=>i0,JSONRPCNotificationSchema:()=>s0,JSONRPCRequestSchema:()=>n0,JSONRPCResponseSchema:()=>eG,JSONRPCResultResponseSchema:()=>Jp,JSONRPC_VERSION:()=>Sl,LATEST_PROTOCOL_VERSION:()=>Hp,LegacyTitledEnumSchemaSchema:()=>wz,ListChangedOptionsBaseSchema:()=>aG,ListPromptsRequestSchema:()=>ql,ListPromptsResultSchema:()=>B1,ListResourceTemplatesRequestSchema:()=>Ll,ListResourceTemplatesResultSchema:()=>R1,ListResourcesRequestSchema:()=>Ml,ListResourcesResultSchema:()=>C1,ListRootsRequestSchema:()=>Mz,ListRootsResultSchema:()=>sh,ListTasksRequestSchema:()=>Al,ListTasksResultSchema:()=>zl,ListToolsRequestSchema:()=>Zl,ListToolsResultSchema:()=>tz,LoggingLevelSchema:()=>Zi,LoggingMessageNotificationParamsSchema:()=>oz,LoggingMessageNotificationSchema:()=>iz,McpError:()=>j,ModelHintSchema:()=>az,ModelPreferencesSchema:()=>cz,MultiSelectEnumSchemaSchema:()=>kz,NotificationSchema:()=>sr,NumberSchemaSchema:()=>yz,PaginatedRequestParamsSchema:()=>P1,PaginatedRequestSchema:()=>Mi,PaginatedResultSchema:()=>Li,PingRequestSchema:()=>Ol,PrimitiveSchemaDefinitionSchema:()=>Ez,ProgressNotificationParamsSchema:()=>T1,ProgressNotificationSchema:()=>Il,ProgressSchema:()=>E1,ProgressTokenSchema:()=>Qb,PromptArgumentSchema:()=>U1,PromptListChangedNotificationSchema:()=>X1,PromptMessageSchema:()=>G1,PromptReferenceSchema:()=>Rz,PromptSchema:()=>V1,RELATED_TASK_META_KEY:()=>On,ReadResourceRequestParamsSchema:()=>A1,ReadResourceRequestSchema:()=>Dl,ReadResourceResultSchema:()=>z1,RelatedTaskMetadataSchema:()=>y1,RequestIdSchema:()=>$l,RequestSchema:()=>it,ResourceContentsSchema:()=>l0,ResourceLinkSchema:()=>J1,ResourceListChangedNotificationSchema:()=>j1,ResourceReferenceSchema:()=>cG,ResourceRequestParamsSchema:()=>Yp,ResourceSchema:()=>p0,ResourceTemplateReferenceSchema:()=>m0,ResourceTemplateSchema:()=>N1,ResourceUpdatedNotificationParamsSchema:()=>F1,ResourceUpdatedNotificationSchema:()=>Z1,ResultSchema:()=>at,RoleSchema:()=>Fi,RootSchema:()=>jz,RootsListChangedNotificationSchema:()=>Lz,SUPPORTED_PROTOCOL_VERSIONS:()=>Xb,SamplingContentSchema:()=>dz,SamplingMessageContentBlockSchema:()=>bl,SamplingMessageSchema:()=>fz,ServerCapabilitiesSchema:()=>k1,ServerNotificationSchema:()=>pG,ServerRequestSchema:()=>fG,ServerResultSchema:()=>hG,ServerTasksCapabilitySchema:()=>b1,SetLevelRequestParamsSchema:()=>sz,SetLevelRequestSchema:()=>rh,SingleSelectEnumSchemaSchema:()=>bz,StringSchemaSchema:()=>gz,SubscribeRequestParamsSchema:()=>M1,SubscribeRequestSchema:()=>L1,TaskAugmentedRequestParamsSchema:()=>zi,TaskCreationParamsSchema:()=>GJ,TaskMetadataSchema:()=>g1,TaskSchema:()=>Di,TaskStatusNotificationParamsSchema:()=>I1,TaskStatusNotificationSchema:()=>qi,TaskStatusSchema:()=>O1,TextContentSchema:()=>Xp,TextResourceContentsSchema:()=>u0,TitledMultiSelectEnumSchemaSchema:()=>$z,TitledSingleSelectEnumSchemaSchema:()=>vz,ToolAnnotationsSchema:()=>Q1,ToolChoiceSchema:()=>lz,ToolExecutionSchema:()=>ez,ToolListChangedNotificationSchema:()=>nz,ToolResultContentSchema:()=>uz,ToolSchema:()=>h0,ToolUseContentSchema:()=>H1,UnsubscribeRequestParamsSchema:()=>D1,UnsubscribeRequestSchema:()=>q1,UntitledMultiSelectEnumSchemaSchema:()=>Sz,UntitledSingleSelectEnumSchemaSchema:()=>_z,UrlElicitationRequiredError:()=>Kp,assertCompleteRequestPrompt:()=>g0,assertCompleteRequestResourceTemplate:()=>y0,isInitializeRequest:()=>nG,isInitializedNotification:()=>sG,isJSONRPCError:()=>QJ,isJSONRPCErrorResponse:()=>Gp,isJSONRPCNotification:()=>o0,isJSONRPCRequest:()=>Wp,isJSONRPCResponse:()=>YJ,isJSONRPCResultResponse:()=>oo,isTaskAugmentedRequestParams:()=>r0});function g0(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function y0(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var Hp,JJ,Xb,On,Sl,rt,Qb,e0,GJ,g1,y1,t0,nr,zi,r0,it,dr,sr,at,$l,n0,Wp,s0,o0,Jp,oo,YJ,F,kl,XJ,Gp,QJ,i0,eG,xl,_1,El,v1,ji,so,a0,tG,rG,w1,b1,S1,$1,Tl,nG,k1,x1,Pl,sG,Ol,E1,T1,Il,P1,Mi,Li,O1,Di,io,I1,qi,Nl,Cl,Rl,oG,Al,zl,jl,c0,l0,u0,d0,f0,Fi,ao,p0,N1,Ml,C1,Ll,R1,Yp,A1,Dl,z1,j1,M1,L1,D1,q1,F1,Z1,U1,V1,ql,B1,K1,Fl,Xp,Qp,eh,H1,W1,J1,th,G1,Y1,X1,Q1,ez,h0,Zl,tz,Ul,iG,rz,co,nz,aG,Zi,sz,rh,oz,iz,az,cz,lz,uz,dz,bl,fz,pz,hz,Ui,nh,mz,gz,yz,_z,vz,wz,bz,Sz,$z,kz,xz,Ez,Tz,Pz,Oz,Iz,Nz,Cz,lo,m0,cG,Rz,Az,Vl,zz,jz,Mz,sh,Lz,lG,uG,dG,fG,pG,hG,j,Kp,uo=$(()=>{m1();Hp="2025-11-25",JJ="2025-03-26",Xb=[Hp,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],On="io.modelcontextprotocol/related-task",Sl="2.0",rt=l1(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Qb=Me([k(),$e().int()]),e0=k(),GJ=xt({ttl:$e().optional(),pollInterval:$e().optional()}),g1=R({ttl:$e().optional()}),y1=R({taskId:k()}),t0=xt({progressToken:Qb.optional(),[On]:y1.optional()}),nr=R({_meta:t0.optional()}),zi=nr.extend({task:g1.optional()}),r0=t=>zi.safeParse(t).success,it=R({method:k(),params:nr.loose().optional()}),dr=R({_meta:t0.optional()}),sr=R({method:k(),params:dr.loose().optional()}),at=xt({_meta:t0.optional()}),$l=Me([k(),$e().int()]),n0=R({jsonrpc:L(Sl),id:$l,...it.shape}).strict(),Wp=t=>n0.safeParse(t).success,s0=R({jsonrpc:L(Sl),...sr.shape}).strict(),o0=t=>s0.safeParse(t).success,Jp=R({jsonrpc:L(Sl),id:$l,result:at}).strict(),oo=t=>Jp.safeParse(t).success,YJ=oo;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(F||(F={}));kl=R({jsonrpc:L(Sl),id:$l.optional(),error:R({code:$e().int(),message:k(),data:Ue().optional()})}).strict(),XJ=kl,Gp=t=>kl.safeParse(t).success,QJ=Gp,i0=Me([n0,s0,Jp,kl]),eG=Me([Jp,kl]),xl=at.strict(),_1=dr.extend({requestId:$l.optional(),reason:k().optional()}),El=sr.extend({method:L("notifications/cancelled"),params:_1}),v1=R({src:k(),mimeType:k().optional(),sizes:ce(k()).optional(),theme:Dt(["light","dark"]).optional()}),ji=R({icons:ce(v1).optional()}),so=R({name:k(),title:k().optional()}),a0=so.extend({...so.shape,...ji.shape,version:k(),websiteUrl:k().optional(),description:k().optional()}),tG=Zp(R({applyDefaults:ot().optional()}),ze(k(),Ue())),rG=Gb(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,Zp(R({form:tG.optional(),url:rt.optional()}),ze(k(),Ue()).optional())),w1=xt({list:rt.optional(),cancel:rt.optional(),requests:xt({sampling:xt({createMessage:rt.optional()}).optional(),elicitation:xt({create:rt.optional()}).optional()}).optional()}),b1=xt({list:rt.optional(),cancel:rt.optional(),requests:xt({tools:xt({call:rt.optional()}).optional()}).optional()}),S1=R({experimental:ze(k(),rt).optional(),sampling:R({context:rt.optional(),tools:rt.optional()}).optional(),elicitation:rG.optional(),roots:R({listChanged:ot().optional()}).optional(),tasks:w1.optional(),extensions:ze(k(),rt).optional()}),$1=nr.extend({protocolVersion:k(),capabilities:S1,clientInfo:a0}),Tl=it.extend({method:L("initialize"),params:$1}),nG=t=>Tl.safeParse(t).success,k1=R({experimental:ze(k(),rt).optional(),logging:rt.optional(),completions:rt.optional(),prompts:R({listChanged:ot().optional()}).optional(),resources:R({subscribe:ot().optional(),listChanged:ot().optional()}).optional(),tools:R({listChanged:ot().optional()}).optional(),tasks:b1.optional(),extensions:ze(k(),rt).optional()}),x1=at.extend({protocolVersion:k(),capabilities:k1,serverInfo:a0,instructions:k().optional()}),Pl=sr.extend({method:L("notifications/initialized"),params:dr.optional()}),sG=t=>Pl.safeParse(t).success,Ol=it.extend({method:L("ping"),params:nr.optional()}),E1=R({progress:$e(),total:Ve($e()),message:Ve(k())}),T1=R({...dr.shape,...E1.shape,progressToken:Qb}),Il=sr.extend({method:L("notifications/progress"),params:T1}),P1=nr.extend({cursor:e0.optional()}),Mi=it.extend({params:P1.optional()}),Li=at.extend({nextCursor:e0.optional()}),O1=Dt(["working","input_required","completed","failed","cancelled"]),Di=R({taskId:k(),status:O1,ttl:Me([$e(),t1()]),createdAt:k(),lastUpdatedAt:k(),pollInterval:Ve($e()),statusMessage:Ve(k())}),io=at.extend({task:Di}),I1=dr.merge(Di),qi=sr.extend({method:L("notifications/tasks/status"),params:I1}),Nl=it.extend({method:L("tasks/get"),params:nr.extend({taskId:k()})}),Cl=at.merge(Di),Rl=it.extend({method:L("tasks/result"),params:nr.extend({taskId:k()})}),oG=at.loose(),Al=Mi.extend({method:L("tasks/list")}),zl=Li.extend({tasks:ce(Di)}),jl=it.extend({method:L("tasks/cancel"),params:nr.extend({taskId:k()})}),c0=at.merge(Di),l0=R({uri:k(),mimeType:Ve(k()),_meta:ze(k(),Ue()).optional()}),u0=l0.extend({text:k()}),d0=k().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),f0=l0.extend({blob:d0}),Fi=Dt(["user","assistant"]),ao=R({audience:ce(Fi).optional(),priority:$e().min(0).max(1).optional(),lastModified:Bp.datetime({offset:!0}).optional()}),p0=R({...so.shape,...ji.shape,uri:k(),description:Ve(k()),mimeType:Ve(k()),size:Ve($e()),annotations:ao.optional(),_meta:Ve(xt({}))}),N1=R({...so.shape,...ji.shape,uriTemplate:k(),description:Ve(k()),mimeType:Ve(k()),annotations:ao.optional(),_meta:Ve(xt({}))}),Ml=Mi.extend({method:L("resources/list")}),C1=Li.extend({resources:ce(p0)}),Ll=Mi.extend({method:L("resources/templates/list")}),R1=Li.extend({resourceTemplates:ce(N1)}),Yp=nr.extend({uri:k()}),A1=Yp,Dl=it.extend({method:L("resources/read"),params:A1}),z1=at.extend({contents:ce(Me([u0,f0]))}),j1=sr.extend({method:L("notifications/resources/list_changed"),params:dr.optional()}),M1=Yp,L1=it.extend({method:L("resources/subscribe"),params:M1}),D1=Yp,q1=it.extend({method:L("resources/unsubscribe"),params:D1}),F1=dr.extend({uri:k()}),Z1=sr.extend({method:L("notifications/resources/updated"),params:F1}),U1=R({name:k(),description:Ve(k()),required:Ve(ot())}),V1=R({...so.shape,...ji.shape,description:Ve(k()),arguments:Ve(ce(U1)),_meta:Ve(xt({}))}),ql=Mi.extend({method:L("prompts/list")}),B1=Li.extend({prompts:ce(V1)}),K1=nr.extend({name:k(),arguments:ze(k(),k()).optional()}),Fl=it.extend({method:L("prompts/get"),params:K1}),Xp=R({type:L("text"),text:k(),annotations:ao.optional(),_meta:ze(k(),Ue()).optional()}),Qp=R({type:L("image"),data:d0,mimeType:k(),annotations:ao.optional(),_meta:ze(k(),Ue()).optional()}),eh=R({type:L("audio"),data:d0,mimeType:k(),annotations:ao.optional(),_meta:ze(k(),Ue()).optional()}),H1=R({type:L("tool_use"),name:k(),id:k(),input:ze(k(),Ue()),_meta:ze(k(),Ue()).optional()}),W1=R({type:L("resource"),resource:Me([u0,f0]),annotations:ao.optional(),_meta:ze(k(),Ue()).optional()}),J1=p0.extend({type:L("resource_link")}),th=Me([Xp,Qp,eh,J1,W1]),G1=R({role:Fi,content:th}),Y1=at.extend({description:k().optional(),messages:ce(G1)}),X1=sr.extend({method:L("notifications/prompts/list_changed"),params:dr.optional()}),Q1=R({title:k().optional(),readOnlyHint:ot().optional(),destructiveHint:ot().optional(),idempotentHint:ot().optional(),openWorldHint:ot().optional()}),ez=R({taskSupport:Dt(["required","optional","forbidden"]).optional()}),h0=R({...so.shape,...ji.shape,description:k().optional(),inputSchema:R({type:L("object"),properties:ze(k(),rt).optional(),required:ce(k()).optional()}).catchall(Ue()),outputSchema:R({type:L("object"),properties:ze(k(),rt).optional(),required:ce(k()).optional()}).catchall(Ue()).optional(),annotations:Q1.optional(),execution:ez.optional(),_meta:ze(k(),Ue()).optional()}),Zl=Mi.extend({method:L("tools/list")}),tz=Li.extend({tools:ce(h0)}),Ul=at.extend({content:ce(th).default([]),structuredContent:ze(k(),Ue()).optional(),isError:ot().optional()}),iG=Ul.or(at.extend({toolResult:Ue()})),rz=zi.extend({name:k(),arguments:ze(k(),Ue()).optional()}),co=it.extend({method:L("tools/call"),params:rz}),nz=sr.extend({method:L("notifications/tools/list_changed"),params:dr.optional()}),aG=R({autoRefresh:ot().default(!0),debounceMs:$e().int().nonnegative().default(300)}),Zi=Dt(["debug","info","notice","warning","error","critical","alert","emergency"]),sz=nr.extend({level:Zi}),rh=it.extend({method:L("logging/setLevel"),params:sz}),oz=dr.extend({level:Zi,logger:k().optional(),data:Ue()}),iz=sr.extend({method:L("notifications/message"),params:oz}),az=R({name:k().optional()}),cz=R({hints:ce(az).optional(),costPriority:$e().min(0).max(1).optional(),speedPriority:$e().min(0).max(1).optional(),intelligencePriority:$e().min(0).max(1).optional()}),lz=R({mode:Dt(["auto","required","none"]).optional()}),uz=R({type:L("tool_result"),toolUseId:k().describe("The unique identifier for the corresponding tool call."),content:ce(th).default([]),structuredContent:R({}).loose().optional(),isError:ot().optional(),_meta:ze(k(),Ue()).optional()}),dz=Jb("type",[Xp,Qp,eh]),bl=Jb("type",[Xp,Qp,eh,H1,uz]),fz=R({role:Fi,content:Me([bl,ce(bl)]),_meta:ze(k(),Ue()).optional()}),pz=zi.extend({messages:ce(fz),modelPreferences:cz.optional(),systemPrompt:k().optional(),includeContext:Dt(["none","thisServer","allServers"]).optional(),temperature:$e().optional(),maxTokens:$e().int(),stopSequences:ce(k()).optional(),metadata:rt.optional(),tools:ce(h0).optional(),toolChoice:lz.optional()}),hz=it.extend({method:L("sampling/createMessage"),params:pz}),Ui=at.extend({model:k(),stopReason:Ve(Dt(["endTurn","stopSequence","maxTokens"]).or(k())),role:Fi,content:dz}),nh=at.extend({model:k(),stopReason:Ve(Dt(["endTurn","stopSequence","maxTokens","toolUse"]).or(k())),role:Fi,content:Me([bl,ce(bl)])}),mz=R({type:L("boolean"),title:k().optional(),description:k().optional(),default:ot().optional()}),gz=R({type:L("string"),title:k().optional(),description:k().optional(),minLength:$e().optional(),maxLength:$e().optional(),format:Dt(["email","uri","date","date-time"]).optional(),default:k().optional()}),yz=R({type:Dt(["number","integer"]),title:k().optional(),description:k().optional(),minimum:$e().optional(),maximum:$e().optional(),default:$e().optional()}),_z=R({type:L("string"),title:k().optional(),description:k().optional(),enum:ce(k()),default:k().optional()}),vz=R({type:L("string"),title:k().optional(),description:k().optional(),oneOf:ce(R({const:k(),title:k()})),default:k().optional()}),wz=R({type:L("string"),title:k().optional(),description:k().optional(),enum:ce(k()),enumNames:ce(k()).optional(),default:k().optional()}),bz=Me([_z,vz]),Sz=R({type:L("array"),title:k().optional(),description:k().optional(),minItems:$e().optional(),maxItems:$e().optional(),items:R({type:L("string"),enum:ce(k())}),default:ce(k()).optional()}),$z=R({type:L("array"),title:k().optional(),description:k().optional(),minItems:$e().optional(),maxItems:$e().optional(),items:R({anyOf:ce(R({const:k(),title:k()}))}),default:ce(k()).optional()}),kz=Me([Sz,$z]),xz=Me([wz,bz,kz]),Ez=Me([xz,mz,gz,yz]),Tz=zi.extend({mode:L("form").optional(),message:k(),requestedSchema:R({type:L("object"),properties:ze(k(),Ez),required:ce(k()).optional()})}),Pz=zi.extend({mode:L("url"),message:k(),elicitationId:k(),url:k().url()}),Oz=Me([Tz,Pz]),Iz=it.extend({method:L("elicitation/create"),params:Oz}),Nz=dr.extend({elicitationId:k()}),Cz=sr.extend({method:L("notifications/elicitation/complete"),params:Nz}),lo=at.extend({action:Dt(["accept","decline","cancel"]),content:Gb(t=>t===null?void 0:t,ze(k(),Me([k(),$e(),ot(),ce(k())])).optional())}),m0=R({type:L("ref/resource"),uri:k()}),cG=m0,Rz=R({type:L("ref/prompt"),name:k()}),Az=nr.extend({ref:Me([Rz,m0]),argument:R({name:k(),value:k()}),context:R({arguments:ze(k(),k()).optional()}).optional()}),Vl=it.extend({method:L("completion/complete"),params:Az});zz=at.extend({completion:xt({values:ce(k()).max(100),total:Ve($e().int()),hasMore:Ve(ot())})}),jz=R({uri:k().startsWith("file://"),name:k().optional(),_meta:ze(k(),Ue()).optional()}),Mz=it.extend({method:L("roots/list"),params:nr.optional()}),sh=at.extend({roots:ce(jz)}),Lz=sr.extend({method:L("notifications/roots/list_changed"),params:dr.optional()}),lG=Me([Ol,Tl,Vl,rh,Fl,ql,Ml,Ll,Dl,L1,q1,co,Zl,Nl,Rl,Al,jl]),uG=Me([El,Il,Pl,Lz,qi]),dG=Me([xl,Ui,nh,lo,sh,Cl,zl,io]),fG=Me([Ol,hz,Iz,Mz,Nl,Rl,Al,jl]),pG=Me([El,Il,iz,Z1,j1,nz,X1,qi,Cz]),hG=Me([xl,x1,zz,Y1,B1,C1,R1,z1,Ul,tz,Cl,zl,io]),j=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===F.UrlElicitationRequired&&n){let s=n;if(s.elicitations)return new Kp(s.elicitations,r)}return new t(e,r,n)}},Kp=class extends j{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(F.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}});function ps(t){return t==="completed"||t==="failed"||t==="cancelled"}var qz=$(()=>{});var Zz,Fz,Uz,oh=$(()=>{Zz=Symbol("Let zodToJsonSchema decide on which parser to use"),Fz={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},Uz=t=>typeof t=="string"?{...Fz,name:t}:{...Fz,...t}});var Vz,_0=$(()=>{oh();Vz=t=>{let e=Uz(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}}});function v0(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function le(t,e,r,n,s){t[e]=r,v0(t,e,n,s)}var hs=$(()=>{});var ih,ah=$(()=>{ih=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")}});function Ke(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?ih(e,t.currentPath):e.join("/")}}var fr=$(()=>{ah()});function Bz(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==I.ZodAny&&(r.items=K(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&le(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&le(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(le(r,"minItems",t.exactLength.value,t.exactLength.message,e),le(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}var w0=$(()=>{Vc();hs();et()});function Kz(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?le(r,"minimum",n.value,n.message,e):le(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),le(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?le(r,"maximum",n.value,n.message,e):le(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),le(r,"maximum",n.value,n.message,e));break;case"multipleOf":le(r,"multipleOf",n.value,n.message,e);break}return r}var b0=$(()=>{hs()});function Hz(){return{type:"boolean"}}var S0=$(()=>{});function ch(t,e){return K(t.type._def,e)}var lh=$(()=>{et()});var Wz,$0=$(()=>{et();Wz=(t,e)=>K(t.innerType._def,e)});function k0(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,o)=>k0(t,e,s))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return mG(t,e)}}var mG,x0=$(()=>{hs();mG=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":le(r,"minimum",n.value,n.message,e);break;case"max":le(r,"maximum",n.value,n.message,e);break}return r}});function Jz(t,e){return{...K(t.innerType._def,e),default:t.defaultValue()}}var E0=$(()=>{et()});function Gz(t,e){return e.effectStrategy==="input"?K(t.schema._def,e):Ke(e)}var T0=$(()=>{et();fr()});function Yz(t){return{type:"string",enum:Array.from(t.values)}}var P0=$(()=>{});function Xz(t,e){let r=[K(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),K(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(o=>!!o),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(o=>{if(gG(o))s.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let i=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:a,...c}=o;i=c}else n=void 0;s.push(i)}}),s.length?{allOf:s,...n}:void 0}var gG,O0=$(()=>{et();gG=t=>"type"in t&&t.type==="string"?!1:"allOf"in t});function Qz(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var I0=$(()=>{});function uh(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":le(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":le(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Mr(r,"email",n.message,e);break;case"format:idn-email":Mr(r,"idn-email",n.message,e);break;case"pattern:zod":Et(r,jr.email,n.message,e);break}break;case"url":Mr(r,"uri",n.message,e);break;case"uuid":Mr(r,"uuid",n.message,e);break;case"regex":Et(r,n.regex,n.message,e);break;case"cuid":Et(r,jr.cuid,n.message,e);break;case"cuid2":Et(r,jr.cuid2,n.message,e);break;case"startsWith":Et(r,RegExp(`^${C0(n.value,e)}`),n.message,e);break;case"endsWith":Et(r,RegExp(`${C0(n.value,e)}$`),n.message,e);break;case"datetime":Mr(r,"date-time",n.message,e);break;case"date":Mr(r,"date",n.message,e);break;case"time":Mr(r,"time",n.message,e);break;case"duration":Mr(r,"duration",n.message,e);break;case"length":le(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),le(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Et(r,RegExp(C0(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&Mr(r,"ipv4",n.message,e),n.version!=="v4"&&Mr(r,"ipv6",n.message,e);break}case"base64url":Et(r,jr.base64url,n.message,e);break;case"jwt":Et(r,jr.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Et(r,jr.ipv4Cidr,n.message,e),n.version!=="v4"&&Et(r,jr.ipv6Cidr,n.message,e);break}case"emoji":Et(r,jr.emoji(),n.message,e);break;case"ulid":{Et(r,jr.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{Mr(r,"binary",n.message,e);break}case"contentEncoding:base64":{le(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Et(r,jr.base64,n.message,e);break}}break}case"nanoid":Et(r,jr.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function C0(t,e){return e.patternStrategy==="escape"?_G(t):t}function _G(t){let e="";for(let r=0;r<t.length;r++)yG.has(t[r])||(e+="\\"),e+=t[r];return e}function Mr(t,e,r,n){t.format||t.anyOf?.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):le(t,"format",e,r,n)}function Et(t,e,r,n){t.pattern||t.allOf?.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:ej(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):le(t,"pattern",ej(e,n),r,n)}function ej(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,s="",o=!1,i=!1,a=!1;for(let c=0;c<n.length;c++){if(o){s+=n[c],o=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){a?(s+=n[c],s+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(s+=n[c],a=!0):s+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){s+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){s+=`(^|(?<=[\r
292
- ]))`;continue}else if(n[c]==="$"){s+=`($|(?=[\r
293
- ]))`;continue}}if(r.s&&n[c]==="."){s+=i?`${n[c]}\r
294
- `:`[${n[c]}\r
295
- ]`;continue}s+=n[c],n[c]==="\\"?o=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return s}var N0,jr,yG,dh=$(()=>{hs();jr={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(N0===void 0&&(N0=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),N0),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};yG=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789")});function fh(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===I.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,s)=>({...n,[s]:K(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??Ke(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:K(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===I.ZodString&&t.keyType._def.checks?.length){let{type:n,...s}=uh(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===I.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===I.ZodBranded&&t.keyType._def.type._def.typeName===I.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...s}=ch(t.keyType._def,e);return{...r,propertyNames:s}}}return r}var ph=$(()=>{Vc();et();dh();lh();fr()});function tj(t,e){if(e.mapStrategy==="record")return fh(t,e);let r=K(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Ke(e),n=K(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Ke(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}var R0=$(()=>{et();ph();fr()});function rj(t){let e=t.values,n=Object.keys(t.values).filter(o=>typeof e[e[o]]!="number").map(o=>e[o]),s=Array.from(new Set(n.map(o=>typeof o)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}var A0=$(()=>{});function nj(t){return t.target==="openAi"?void 0:{not:Ke({...t,currentPath:[...t.currentPath,"not"]})}}var z0=$(()=>{fr()});function sj(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var j0=$(()=>{});function ij(t,e){if(e.target==="openApi3")return oj(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in Bl&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,o)=>{let i=Bl[o._def.typeName];return i&&!s.includes(i)?[...s,i]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,o)=>{let i=typeof o._def.value;switch(i){case"string":case"number":case"boolean":return[...s,i];case"bigint":return[...s,"integer"];case"object":if(o._def.value===null)return[...s,"null"];default:return s}},[]);if(n.length===r.length){let s=n.filter((o,i,a)=>a.indexOf(o)===i);return{type:s.length>1?s:s[0],enum:r.reduce((o,i)=>o.includes(i._def.value)?o:[...o,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(o=>!n.includes(o))],[])};return oj(t,e)}var Bl,oj,hh=$(()=>{et();Bl={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};oj=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>K(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0}});function aj(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:Bl[t.innerType._def.typeName],nullable:!0}:{type:[Bl[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=K(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=K(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}var M0=$(()=>{et();hh()});function cj(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",v0(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?le(r,"minimum",n.value,n.message,e):le(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),le(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?le(r,"maximum",n.value,n.message,e):le(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),le(r,"maximum",n.value,n.message,e));break;case"multipleOf":le(r,"multipleOf",n.value,n.message,e);break}return r}var L0=$(()=>{hs()});function lj(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},s=[],o=t.shape();for(let a in o){let c=o[a];if(c===void 0||c._def===void 0)continue;let l=wG(c);l&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),l=!1);let u=K(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});u!==void 0&&(n.properties[a]=u,l||s.push(a))}s.length&&(n.required=s);let i=vG(t,e);return i!==void 0&&(n.additionalProperties=i),n}function vG(t,e){if(t.catchall._def.typeName!=="ZodNever")return K(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function wG(t){try{return t.isOptional()}catch{return!0}}var D0=$(()=>{et()});var uj,q0=$(()=>{et();fr();uj=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return K(t.innerType._def,e);let r=K(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Ke(e)},r]}:Ke(e)}});var dj,F0=$(()=>{et();dj=(t,e)=>{if(e.pipeStrategy==="input")return K(t.in._def,e);if(e.pipeStrategy==="output")return K(t.out._def,e);let r=K(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=K(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}}});function fj(t,e){return K(t.type._def,e)}var Z0=$(()=>{et()});function pj(t,e){let n={type:"array",uniqueItems:!0,items:K(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&le(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&le(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}var U0=$(()=>{hs();et()});function hj(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>K(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:K(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>K(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}var V0=$(()=>{et()});function mj(t){return{not:Ke(t)}}var B0=$(()=>{fr()});function gj(t){return Ke(t)}var K0=$(()=>{fr()});var yj,H0=$(()=>{et();yj=(t,e)=>K(t.innerType._def,e)});var _j,W0=$(()=>{Vc();fr();w0();b0();S0();lh();$0();x0();E0();T0();P0();O0();I0();R0();A0();z0();j0();M0();L0();D0();q0();F0();Z0();ph();U0();dh();V0();B0();hh();K0();H0();_j=(t,e,r)=>{switch(e){case I.ZodString:return uh(t,r);case I.ZodNumber:return cj(t,r);case I.ZodObject:return lj(t,r);case I.ZodBigInt:return Kz(t,r);case I.ZodBoolean:return Hz();case I.ZodDate:return k0(t,r);case I.ZodUndefined:return mj(r);case I.ZodNull:return sj(r);case I.ZodArray:return Bz(t,r);case I.ZodUnion:case I.ZodDiscriminatedUnion:return ij(t,r);case I.ZodIntersection:return Xz(t,r);case I.ZodTuple:return hj(t,r);case I.ZodRecord:return fh(t,r);case I.ZodLiteral:return Qz(t,r);case I.ZodEnum:return Yz(t);case I.ZodNativeEnum:return rj(t);case I.ZodNullable:return aj(t,r);case I.ZodOptional:return uj(t,r);case I.ZodMap:return tj(t,r);case I.ZodSet:return pj(t,r);case I.ZodLazy:return()=>t.getter()._def;case I.ZodPromise:return fj(t,r);case I.ZodNaN:case I.ZodNever:return nj(r);case I.ZodEffects:return Gz(t,r);case I.ZodAny:return Ke(r);case I.ZodUnknown:return gj(r);case I.ZodDefault:return Jz(t,r);case I.ZodBranded:return ch(t,r);case I.ZodReadonly:return yj(t,r);case I.ZodCatch:return Wz(t,r);case I.ZodPipeline:return dj(t,r);case I.ZodFunction:case I.ZodVoid:case I.ZodSymbol:return;default:return(n=>{})(e)}}});function K(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==Zz)return a}if(n&&!r){let a=bG(n,e);if(a!==void 0)return a}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let o=_j(t,t.typeName,e),i=typeof o=="function"?K(o(),e):o;if(i&&SG(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return s.jsonSchema=i,a}return s.jsonSchema=i,i}var bG,SG,et=$(()=>{oh();W0();ah();fr();bG=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:ih(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),Ke(e)):e.$refStrategy==="seen"?Ke(e):void 0}},SG=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r)});var vj=$(()=>{});var J0,G0=$(()=>{et();_0();fr();J0=(t,e)=>{let r=Vz(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[l,u])=>({...c,[l]:K(u._def,{...r,currentPath:[...r.basePath,r.definitionPath,l]},!0)??Ke(r)}),{}):void 0,s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,o=K(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??Ke(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(o.title=i),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=s===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:o}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a}});var wj=$(()=>{oh();_0();hs();ah();et();vj();fr();w0();b0();S0();lh();$0();x0();E0();T0();P0();O0();I0();R0();A0();z0();j0();M0();L0();D0();q0();F0();Z0();H0();ph();U0();dh();V0();B0();hh();K0();W0();G0();G0()});function $G(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function Y0(t,e){return nn(t)?qb(t,{target:$G(e?.target),io:e?.pipeStrategy??"input"}):J0(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function X0(t){let r=fs(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ai(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Q0(t,e){let r=ds(t,e);if(!r.success)throw r.error;return r.data}var eS=$(()=>{Vb();gl();wj()});function bj(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Sj(t,e){let r={...t};for(let n in e){let s=n,o=e[s];if(o===void 0)continue;let i=r[s];bj(i)&&bj(o)?r[s]={...i,...o}:r[s]=o}return r}var kG,mh,$j=$(()=>{gl();uo();qz();eS();kG=6e4,mh=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(El,r=>{this._oncancel(r)}),this.setNotificationHandler(Il,r=>{this._onprogress(r)}),this.setRequestHandler(Ol,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Nl,async(r,n)=>{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new j(F.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(Rl,async(r,n)=>{let s=async()=>{let o=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,l=c.id,u=this._requestResolvers.get(l);if(u)if(this._requestResolvers.delete(l),a.type==="response")u(c);else{let d=c,f=new j(d.error.code,d.error.message,d.error.data);u(f)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${l}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(o,n.sessionId);if(!i)throw new j(F.InvalidParams,`Task not found: ${o}`);if(!ps(i.status))return await this._waitForTaskUpdate(o,n.signal),await s();if(ps(i.status)){let a=await this._taskStore.getTaskResult(o,n.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[On]:{taskId:o}}}}return await s()};return await s()}),this.setRequestHandler(Al,async(r,n)=>{try{let{tasks:s,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:s,nextCursor:o,_meta:{}}}catch(s){throw new j(F.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(jl,async(r,n)=>{try{let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new j(F.InvalidParams,`Task not found: ${r.params.taskId}`);if(ps(s.status))throw new j(F.InvalidParams,`Cannot cancel task in terminal status: ${s.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new j(F.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(s){throw s instanceof j?s:new j(F.InvalidRequest,`Failed to cancel task: ${s instanceof Error?s.message:String(s)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,s,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:s})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),j.fromError(F.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=o=>{n?.(o),this._onerror(o)};let s=this._transport?.onmessage;this._transport.onmessage=(o,i)=>{s?.(o,i),oo(o)||Gp(o)?this._onresponse(o):Wp(o)?this._onrequest(o,i):o0(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=j.fromError(F.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,s=this._transport,o=e.params?._meta?.[On]?.taskId;if(n===void 0){let u={jsonrpc:"2.0",id:e.id,error:{code:F.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:u,timestamp:Date.now()},s?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):s?.send(u).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=r0(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,s?.sessionId):void 0,l={signal:i.signal,sessionId:s?.sessionId,_meta:e.params?._meta,sendNotification:async u=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};o&&(d.relatedTask={taskId:o}),await this.notification(u,d)},sendRequest:async(u,d,f)=>{if(i.signal.aborted)throw new j(F.ConnectionClosed,"Request was cancelled");let p={...f,relatedRequestId:e.id};o&&!p.relatedTask&&(p.relatedTask={taskId:o});let m=p.relatedTask?.taskId??o;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(u,d,p)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,l)).then(async u=>{if(i.signal.aborted)return;let d={result:u,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},s?.sessionId):await s?.send(d)},async u=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(u.code)?u.code:F.InternalError,message:u.message??"Internal error",...u.data!==void 0&&{data:u.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},s?.sessionId):await s?.send(d)}).catch(u=>this._onerror(new Error(`Failed to send response: ${u}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,s=Number(r),o=this._progressHandlers.get(s);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(s),a=this._timeoutInfo.get(s);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(c){this._responseHandlers.delete(s),this._progressHandlers.delete(s),this._cleanupTimeout(s),i(c);return}o(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),oo(e))n(e);else{let i=new j(e.error.code,e.error.message,e.error.data);n(i)}return}let s=this._responseHandlers.get(r);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let o=!1;if(oo(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),oo(e))s(e);else{let i=j.fromError(e.error.code,e.error.message,e.error.data);s(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:s}=n??{};if(!s){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof j?i:new j(F.InternalError,String(i))}}return}let o;try{let i=await this.request(e,io,n);if(i.task)o=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new j(F.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},n);if(yield{type:"taskStatus",task:a},ps(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)}:a.status==="failed"?yield{type:"error",error:new j(F.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new j(F.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(l=>setTimeout(l,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof j?i:new j(F.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((l,u)=>{let d=w=>{u(w)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(w){d(w);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[On]:c}});let m=w=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(w)}},{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch(x=>this._onerror(new Error(`Failed to send cancellation: ${x}`)));let b=w instanceof j?w:new j(F.RequestTimeout,String(w));u(b)};this._responseHandlers.set(f,w=>{if(!n?.signal?.aborted){if(w instanceof Error)return u(w);try{let b=ds(r,w.result);b.success?l(b.data):u(b.error)}catch(b){u(b)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??kG,g=()=>m(j.fromError(F.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let w=b=>{let x=this._responseHandlers.get(f);x?x(b):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,w),this._enqueueTaskMessage(y,{type:"request",message:p,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(f),u(b)})}else this._transport.send(p,{relatedRequestId:s,resumptionToken:o,onresumptiontoken:i}).catch(w=>{this._cleanupTimeout(f),u(w)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Cl,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},zl,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},c0,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[On]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[On]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[On]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=X0(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,o)=>{let i=Q0(e,s);return Promise.resolve(r(i,o))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=X0(e);this._notificationHandlers.set(n,s=>{let o=Q0(e,s);return Promise.resolve(r(o))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let s=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,s)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let s of n)if(s.type==="request"&&Wp(s.message)){let o=s.message.id,i=this._requestResolvers.get(o);i?(i(new j(F.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let s=await this._taskStore?.getTask(e);s?.pollInterval&&(n=s.pollInterval)}catch{}return new Promise((s,o)=>{if(r.aborted){o(new j(F.InvalidRequest,"Request cancelled"));return}let i=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(i),o(new j(F.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async s=>{if(!e)throw new Error("No request provided");return await n.createTask(s,e.id,{method:e.method,params:e.params},r)},getTask:async s=>{let o=await n.getTask(s,r);if(!o)throw new j(F.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(s,o,i)=>{await n.storeTaskResult(s,o,i,r);let a=await n.getTask(s,r);if(a){let c=qi.parse({method:"notifications/tasks/status",params:a});await this.notification(c),ps(a.status)&&this._cleanupTaskProgressHandler(s)}},getTaskResult:s=>n.getTaskResult(s,r),updateTaskStatus:async(s,o,i)=>{let a=await n.getTask(s,r);if(!a)throw new j(F.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(ps(a.status))throw new j(F.InvalidParams,`Cannot update task "${s}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(s,o,i,r);let c=await n.getTask(s,r);if(c){let l=qi.parse({method:"notifications/tasks/status",params:c});await this.notification(l),ps(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}});var Wl=_(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.regexpCode=ve.getEsmExportName=ve.getProperty=ve.safeStringify=ve.stringify=ve.strConcat=ve.addCodeArg=ve.str=ve._=ve.nil=ve._Code=ve.Name=ve.IDENTIFIER=ve._CodeOrName=void 0;var Kl=class{};ve._CodeOrName=Kl;ve.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var fo=class extends Kl{constructor(e){if(super(),!ve.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};ve.Name=fo;var pr=class extends Kl{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof fo&&(r[n.str]=(r[n.str]||0)+1),r),{})}};ve._Code=pr;ve.nil=new pr("");function kj(t,...e){let r=[t[0]],n=0;for(;n<e.length;)rS(r,e[n]),r.push(t[++n]);return new pr(r)}ve._=kj;var tS=new pr("+");function xj(t,...e){let r=[Hl(t[0])],n=0;for(;n<e.length;)r.push(tS),rS(r,e[n]),r.push(tS,Hl(t[++n]));return xG(r),new pr(r)}ve.str=xj;function rS(t,e){e instanceof pr?t.push(...e._items):e instanceof fo?t.push(e):t.push(PG(e))}ve.addCodeArg=rS;function xG(t){let e=1;for(;e<t.length-1;){if(t[e]===tS){let r=EG(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function EG(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof fo||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof fo))return`"${t}${e.slice(1)}`}function TG(t,e){return e.emptyStr()?t:t.emptyStr()?e:xj`${t}${e}`}ve.strConcat=TG;function PG(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Hl(Array.isArray(t)?t.join(","):t)}function OG(t){return new pr(Hl(t))}ve.stringify=OG;function Hl(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}ve.safeStringify=Hl;function IG(t){return typeof t=="string"&&ve.IDENTIFIER.test(t)?new pr(`.${t}`):kj`[${t}]`}ve.getProperty=IG;function NG(t){if(typeof t=="string"&&ve.IDENTIFIER.test(t))return new pr(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}ve.getEsmExportName=NG;function CG(t){return new pr(t.toString())}ve.regexpCode=CG});var oS=_(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});Ft.ValueScope=Ft.ValueScopeName=Ft.Scope=Ft.varKinds=Ft.UsedValueState=void 0;var qt=Wl(),nS=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},gh;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(gh||(Ft.UsedValueState=gh={}));Ft.varKinds={const:new qt.Name("const"),let:new qt.Name("let"),var:new qt.Name("var")};var yh=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof qt.Name?e:this.name(e)}name(e){return new qt.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Ft.Scope=yh;var _h=class extends qt.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,qt._)`.${new qt.Name(r)}[${n}]`}};Ft.ValueScopeName=_h;var RG=(0,qt._)`\n`,sS=class extends yh{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?RG:qt.nil}}get(){return this._scope}name(e){return new _h(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let s=this.toName(e),{prefix:o}=s,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let u=a.get(i);if(u)return u}else a=this._values[o]=new Map;a.set(i,s);let c=this._scope[o]||(this._scope[o]=[]),l=c.length;return c[l]=r.ref,s.setValue(r,{property:o,itemIndex:l}),s}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,qt._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,s=>{if(s.value===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return s.value.code},r,n)}_reduceValues(e,r,n={},s){let o=qt.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(l=>{if(c.has(l))return;c.set(l,gh.Started);let u=r(l);if(u){let d=this.opts.es5?Ft.varKinds.var:Ft.varKinds.const;o=(0,qt._)`${o}${d} ${l} = ${u};${this.opts._n}`}else if(u=s?.(l))o=(0,qt._)`${o}${u}${this.opts._n}`;else throw new nS(l);c.set(l,gh.Completed)})}return o}};Ft.ValueScope=sS});var se=_(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.or=re.and=re.not=re.CodeGen=re.operators=re.varKinds=re.ValueScopeName=re.ValueScope=re.Scope=re.Name=re.regexpCode=re.stringify=re.getProperty=re.nil=re.strConcat=re.str=re._=void 0;var ue=Wl(),Lr=oS(),ms=Wl();Object.defineProperty(re,"_",{enumerable:!0,get:function(){return ms._}});Object.defineProperty(re,"str",{enumerable:!0,get:function(){return ms.str}});Object.defineProperty(re,"strConcat",{enumerable:!0,get:function(){return ms.strConcat}});Object.defineProperty(re,"nil",{enumerable:!0,get:function(){return ms.nil}});Object.defineProperty(re,"getProperty",{enumerable:!0,get:function(){return ms.getProperty}});Object.defineProperty(re,"stringify",{enumerable:!0,get:function(){return ms.stringify}});Object.defineProperty(re,"regexpCode",{enumerable:!0,get:function(){return ms.regexpCode}});Object.defineProperty(re,"Name",{enumerable:!0,get:function(){return ms.Name}});var Sh=oS();Object.defineProperty(re,"Scope",{enumerable:!0,get:function(){return Sh.Scope}});Object.defineProperty(re,"ValueScope",{enumerable:!0,get:function(){return Sh.ValueScope}});Object.defineProperty(re,"ValueScopeName",{enumerable:!0,get:function(){return Sh.ValueScopeName}});Object.defineProperty(re,"varKinds",{enumerable:!0,get:function(){return Sh.varKinds}});re.operators={GT:new ue._Code(">"),GTE:new ue._Code(">="),LT:new ue._Code("<"),LTE:new ue._Code("<="),EQ:new ue._Code("==="),NEQ:new ue._Code("!=="),NOT:new ue._Code("!"),OR:new ue._Code("||"),AND:new ue._Code("&&"),ADD:new ue._Code("+")};var In=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},iS=class extends In{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Lr.varKinds.var:this.varKind,s=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${s};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Bi(this.rhs,e,r)),this}get names(){return this.rhs instanceof ue._CodeOrName?this.rhs.names:{}}},vh=class extends In{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ue.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Bi(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ue.Name?{}:{...this.lhs.names};return bh(e,this.rhs)}},aS=class extends vh{constructor(e,r,n,s){super(e,n,s),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},cS=class extends In{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},lS=class extends In{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},uS=class extends In{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},dS=class extends In{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Bi(this.code,e,r),this}get names(){return this.code instanceof ue._CodeOrName?this.code.names:{}}},Jl=class extends In{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,s=n.length;for(;s--;){let o=n[s];o.optimizeNames(e,r)||(AG(e,o.names),n.splice(s,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>mo(e,r.names),{})}},Nn=class extends Jl{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},fS=class extends Jl{},Vi=class extends Nn{};Vi.kind="else";var po=class t extends Nn{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Vi(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Ej(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Bi(this.condition,e,r),this}get names(){let e=super.names;return bh(e,this.condition),this.else&&mo(e,this.else.names),e}};po.kind="if";var ho=class extends Nn{};ho.kind="for";var pS=class extends ho{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Bi(this.iteration,e,r),this}get names(){return mo(super.names,this.iteration.names)}},hS=class extends ho{constructor(e,r,n,s){super(),this.varKind=e,this.name=r,this.from=n,this.to=s}render(e){let r=e.es5?Lr.varKinds.var:this.varKind,{name:n,from:s,to:o}=this;return`for(${r} ${n}=${s}; ${n}<${o}; ${n}++)`+super.render(e)}get names(){let e=bh(super.names,this.from);return bh(e,this.to)}},wh=class extends ho{constructor(e,r,n,s){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=s}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Bi(this.iterable,e,r),this}get names(){return mo(super.names,this.iterable.names)}},Gl=class extends Nn{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Gl.kind="func";var Yl=class extends Jl{render(e){return"return "+super.render(e)}};Yl.kind="return";var mS=class extends Nn{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,s;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(s=this.finally)===null||s===void 0||s.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&mo(e,this.catch.names),this.finally&&mo(e,this.finally.names),e}},Xl=class extends Nn{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Xl.kind="catch";var Ql=class extends Nn{render(e){return"finally"+super.render(e)}};Ql.kind="finally";var gS=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
296
- `:""},this._extScope=e,this._scope=new Lr.Scope({parent:e}),this._nodes=[new fS]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,s){let o=this._scope.toName(r);return n!==void 0&&s&&(this._constants[o.str]=n),this._leafNode(new iS(e,o,n)),o}const(e,r,n){return this._def(Lr.varKinds.const,e,r,n)}let(e,r,n){return this._def(Lr.varKinds.let,e,r,n)}var(e,r,n){return this._def(Lr.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new vh(e,r,n))}add(e,r){return this._leafNode(new aS(e,re.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ue.nil&&this._leafNode(new dS(e)),this}object(...e){let r=["{"];for(let[n,s]of e)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0,ue.addCodeArg)(r,s));return r.push("}"),new ue._Code(r)}if(e,r,n){if(this._blockNode(new po(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new po(e))}else(){return this._elseNode(new Vi)}endIf(){return this._endBlockNode(po,Vi)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new pS(e),r)}forRange(e,r,n,s,o=this.opts.es5?Lr.varKinds.var:Lr.varKinds.let){let i=this._scope.toName(e);return this._for(new hS(o,i,r,n),()=>s(i))}forOf(e,r,n,s=Lr.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let i=r instanceof ue.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ue._)`${i}.length`,a=>{this.var(o,(0,ue._)`${i}[${a}]`),n(o)})}return this._for(new wh("of",s,o,r),()=>n(o))}forIn(e,r,n,s=this.opts.es5?Lr.varKinds.var:Lr.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ue._)`Object.keys(${r})`,n);let o=this._scope.toName(e);return this._for(new wh("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(ho)}label(e){return this._leafNode(new cS(e))}break(e){return this._leafNode(new lS(e))}return(e){let r=new Yl;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Yl)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new mS;if(this._blockNode(s),this.code(e),r){let o=this.name("e");this._currNode=s.catch=new Xl(o),r(o)}return n&&(this._currNode=s.finally=new Ql,this.code(n)),this._endBlockNode(Xl,Ql)}throw(e){return this._leafNode(new uS(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=ue.nil,n,s){return this._blockNode(new Gl(e,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(Gl)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof po))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};re.CodeGen=gS;function mo(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function bh(t,e){return e instanceof ue._CodeOrName?mo(t,e.names):t}function Bi(t,e,r){if(t instanceof ue.Name)return n(t);if(!s(t))return t;return new ue._Code(t._items.reduce((o,i)=>(i instanceof ue.Name&&(i=n(i)),i instanceof ue._Code?o.push(...i._items):o.push(i),o),[]));function n(o){let i=r[o.str];return i===void 0||e[o.str]!==1?o:(delete e[o.str],i)}function s(o){return o instanceof ue._Code&&o._items.some(i=>i instanceof ue.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function AG(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Ej(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ue._)`!${yS(t)}`}re.not=Ej;var zG=Tj(re.operators.AND);function jG(...t){return t.reduce(zG)}re.and=jG;var MG=Tj(re.operators.OR);function LG(...t){return t.reduce(MG)}re.or=LG;function Tj(t){return(e,r)=>e===ue.nil?r:r===ue.nil?e:(0,ue._)`${yS(e)} ${t} ${yS(r)}`}function yS(t){return t instanceof ue.Name?t:(0,ue._)`(${t})`}});var he=_(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.checkStrictMode=oe.getErrorPath=oe.Type=oe.useFunc=oe.setEvaluated=oe.evaluatedPropsToName=oe.mergeEvaluated=oe.eachItem=oe.unescapeJsonPointer=oe.escapeJsonPointer=oe.escapeFragment=oe.unescapeFragment=oe.schemaRefOrVal=oe.schemaHasRulesButRef=oe.schemaHasRules=oe.checkUnknownRules=oe.alwaysValidSchema=oe.toHash=void 0;var Ne=se(),DG=Wl();function qG(t){let e={};for(let r of t)e[r]=!0;return e}oe.toHash=qG;function FG(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Ij(t,e),!Nj(e,t.self.RULES.all))}oe.alwaysValidSchema=FG;function Ij(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let s=n.RULES.keywords;for(let o in e)s[o]||Aj(t,`unknown keyword: "${o}"`)}oe.checkUnknownRules=Ij;function Nj(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}oe.schemaHasRules=Nj;function ZG(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}oe.schemaHasRulesButRef=ZG;function UG({topSchemaRef:t,schemaPath:e},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Ne._)`${r}`}return(0,Ne._)`${t}${e}${(0,Ne.getProperty)(n)}`}oe.schemaRefOrVal=UG;function VG(t){return Cj(decodeURIComponent(t))}oe.unescapeFragment=VG;function BG(t){return encodeURIComponent(vS(t))}oe.escapeFragment=BG;function vS(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}oe.escapeJsonPointer=vS;function Cj(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}oe.unescapeJsonPointer=Cj;function KG(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}oe.eachItem=KG;function Pj({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(s,o,i,a)=>{let c=i===void 0?o:i instanceof Ne.Name?(o instanceof Ne.Name?t(s,o,i):e(s,o,i),i):o instanceof Ne.Name?(e(s,i,o),o):r(o,i);return a===Ne.Name&&!(c instanceof Ne.Name)?n(s,c):c}}oe.mergeEvaluated={props:Pj({mergeNames:(t,e,r)=>t.if((0,Ne._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,Ne._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,Ne._)`${r} || {}`).code((0,Ne._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,Ne._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,Ne._)`${r} || {}`),wS(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Rj}),items:Pj({mergeNames:(t,e,r)=>t.if((0,Ne._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,Ne._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,Ne._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,Ne._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Rj(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,Ne._)`{}`);return e!==void 0&&wS(t,r,e),r}oe.evaluatedPropsToName=Rj;function wS(t,e,r){Object.keys(r).forEach(n=>t.assign((0,Ne._)`${e}${(0,Ne.getProperty)(n)}`,!0))}oe.setEvaluated=wS;var Oj={};function HG(t,e){return t.scopeValue("func",{ref:e,code:Oj[e.code]||(Oj[e.code]=new DG._Code(e.code))})}oe.useFunc=HG;var _S;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(_S||(oe.Type=_S={}));function WG(t,e,r){if(t instanceof Ne.Name){let n=e===_S.Num;return r?n?(0,Ne._)`"[" + ${t} + "]"`:(0,Ne._)`"['" + ${t} + "']"`:n?(0,Ne._)`"/" + ${t}`:(0,Ne._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Ne.getProperty)(t).toString():"/"+vS(t)}oe.getErrorPath=WG;function Aj(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}oe.checkStrictMode=Aj});var Cn=_(bS=>{"use strict";Object.defineProperty(bS,"__esModule",{value:!0});var gt=se(),JG={data:new gt.Name("data"),valCxt:new gt.Name("valCxt"),instancePath:new gt.Name("instancePath"),parentData:new gt.Name("parentData"),parentDataProperty:new gt.Name("parentDataProperty"),rootData:new gt.Name("rootData"),dynamicAnchors:new gt.Name("dynamicAnchors"),vErrors:new gt.Name("vErrors"),errors:new gt.Name("errors"),this:new gt.Name("this"),self:new gt.Name("self"),scope:new gt.Name("scope"),json:new gt.Name("json"),jsonPos:new gt.Name("jsonPos"),jsonLen:new gt.Name("jsonLen"),jsonPart:new gt.Name("jsonPart")};bS.default=JG});var eu=_(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.extendErrors=yt.resetErrorsCount=yt.reportExtraError=yt.reportError=yt.keyword$DataError=yt.keywordError=void 0;var me=se(),$h=he(),Tt=Cn();yt.keywordError={message:({keyword:t})=>(0,me.str)`must pass "${t}" keyword validation`};yt.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,me.str)`"${t}" keyword must be ${e} ($data)`:(0,me.str)`"${t}" keyword is invalid ($data)`};function GG(t,e=yt.keywordError,r,n){let{it:s}=t,{gen:o,compositeRule:i,allErrors:a}=s,c=Mj(t,e,r);n??(i||a)?zj(o,c):jj(s,(0,me._)`[${c}]`)}yt.reportError=GG;function YG(t,e=yt.keywordError,r){let{it:n}=t,{gen:s,compositeRule:o,allErrors:i}=n,a=Mj(t,e,r);zj(s,a),o||i||jj(n,Tt.default.vErrors)}yt.reportExtraError=YG;function XG(t,e){t.assign(Tt.default.errors,e),t.if((0,me._)`${Tt.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,me._)`${Tt.default.vErrors}.length`,e),()=>t.assign(Tt.default.vErrors,null)))}yt.resetErrorsCount=XG;function QG({gen:t,keyword:e,schemaValue:r,data:n,errsCount:s,it:o}){if(s===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",s,Tt.default.errors,a=>{t.const(i,(0,me._)`${Tt.default.vErrors}[${a}]`),t.if((0,me._)`${i}.instancePath === undefined`,()=>t.assign((0,me._)`${i}.instancePath`,(0,me.strConcat)(Tt.default.instancePath,o.errorPath))),t.assign((0,me._)`${i}.schemaPath`,(0,me.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,me._)`${i}.schema`,r),t.assign((0,me._)`${i}.data`,n))})}yt.extendErrors=QG;function zj(t,e){let r=t.const("err",e);t.if((0,me._)`${Tt.default.vErrors} === null`,()=>t.assign(Tt.default.vErrors,(0,me._)`[${r}]`),(0,me._)`${Tt.default.vErrors}.push(${r})`),t.code((0,me._)`${Tt.default.errors}++`)}function jj(t,e){let{gen:r,validateName:n,schemaEnv:s}=t;s.$async?r.throw((0,me._)`new ${t.ValidationError}(${e})`):(r.assign((0,me._)`${n}.errors`,e),r.return(!1))}var go={keyword:new me.Name("keyword"),schemaPath:new me.Name("schemaPath"),params:new me.Name("params"),propertyName:new me.Name("propertyName"),message:new me.Name("message"),schema:new me.Name("schema"),parentSchema:new me.Name("parentSchema")};function Mj(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,me._)`{}`:e8(t,e,r)}function e8(t,e,r={}){let{gen:n,it:s}=t,o=[t8(s,r),r8(t,r)];return n8(t,e,o),n.object(...o)}function t8({errorPath:t},{instancePath:e}){let r=e?(0,me.str)`${t}${(0,$h.getErrorPath)(e,$h.Type.Str)}`:t;return[Tt.default.instancePath,(0,me.strConcat)(Tt.default.instancePath,r)]}function r8({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let s=n?e:(0,me.str)`${e}/${t}`;return r&&(s=(0,me.str)`${s}${(0,$h.getErrorPath)(r,$h.Type.Str)}`),[go.schemaPath,s]}function n8(t,{params:e,message:r},n){let{keyword:s,data:o,schemaValue:i,it:a}=t,{opts:c,propertyName:l,topSchemaRef:u,schemaPath:d}=a;n.push([go.keyword,s],[go.params,typeof e=="function"?e(t):e||(0,me._)`{}`]),c.messages&&n.push([go.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([go.schema,i],[go.parentSchema,(0,me._)`${u}${d}`],[Tt.default.data,o]),l&&n.push([go.propertyName,l])}});var Dj=_(Ki=>{"use strict";Object.defineProperty(Ki,"__esModule",{value:!0});Ki.boolOrEmptySchema=Ki.topBoolOrEmptySchema=void 0;var s8=eu(),o8=se(),i8=Cn(),a8={message:"boolean schema is false"};function c8(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Lj(t,!1):typeof r=="object"&&r.$async===!0?e.return(i8.default.data):(e.assign((0,o8._)`${n}.errors`,null),e.return(!0))}Ki.topBoolOrEmptySchema=c8;function l8(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Lj(t)):r.var(e,!0)}Ki.boolOrEmptySchema=l8;function Lj(t,e){let{gen:r,data:n}=t,s={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,s8.reportError)(s,a8,void 0,e)}});var SS=_(Hi=>{"use strict";Object.defineProperty(Hi,"__esModule",{value:!0});Hi.getRules=Hi.isJSONType=void 0;var u8=["string","number","integer","boolean","null","object","array"],d8=new Set(u8);function f8(t){return typeof t=="string"&&d8.has(t)}Hi.isJSONType=f8;function p8(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Hi.getRules=p8});var $S=_(gs=>{"use strict";Object.defineProperty(gs,"__esModule",{value:!0});gs.shouldUseRule=gs.shouldUseGroup=gs.schemaHasRulesForType=void 0;function h8({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&qj(t,n)}gs.schemaHasRulesForType=h8;function qj(t,e){return e.rules.some(r=>Fj(t,r))}gs.shouldUseGroup=qj;function Fj(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}gs.shouldUseRule=Fj});var tu=_(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.reportTypeError=_t.checkDataTypes=_t.checkDataType=_t.coerceAndCheckDataType=_t.getJSONTypes=_t.getSchemaTypes=_t.DataType=void 0;var m8=SS(),g8=$S(),y8=eu(),Y=se(),Zj=he(),Wi;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Wi||(_t.DataType=Wi={}));function _8(t){let e=Uj(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}_t.getSchemaTypes=_8;function Uj(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(m8.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}_t.getJSONTypes=Uj;function v8(t,e){let{gen:r,data:n,opts:s}=t,o=w8(e,s.coerceTypes),i=e.length>0&&!(o.length===0&&e.length===1&&(0,g8.schemaHasRulesForType)(t,e[0]));if(i){let a=xS(e,n,s.strictNumbers,Wi.Wrong);r.if(a,()=>{o.length?b8(t,e,o):ES(t)})}return i}_t.coerceAndCheckDataType=v8;var Vj=new Set(["string","number","integer","boolean","null"]);function w8(t,e){return e?t.filter(r=>Vj.has(r)||e==="array"&&r==="array"):[]}function b8(t,e,r){let{gen:n,data:s,opts:o}=t,i=n.let("dataType",(0,Y._)`typeof ${s}`),a=n.let("coerced",(0,Y._)`undefined`);o.coerceTypes==="array"&&n.if((0,Y._)`${i} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,Y._)`${s}[0]`).assign(i,(0,Y._)`typeof ${s}`).if(xS(e,s,o.strictNumbers),()=>n.assign(a,s))),n.if((0,Y._)`${a} !== undefined`);for(let l of r)(Vj.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),ES(t),n.endIf(),n.if((0,Y._)`${a} !== undefined`,()=>{n.assign(s,a),S8(t,a)});function c(l){switch(l){case"string":n.elseIf((0,Y._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,Y._)`"" + ${s}`).elseIf((0,Y._)`${s} === null`).assign(a,(0,Y._)`""`);return;case"number":n.elseIf((0,Y._)`${i} == "boolean" || ${s} === null
297
- || (${i} == "string" && ${s} && ${s} == +${s})`).assign(a,(0,Y._)`+${s}`);return;case"integer":n.elseIf((0,Y._)`${i} === "boolean" || ${s} === null
298
- || (${i} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(a,(0,Y._)`+${s}`);return;case"boolean":n.elseIf((0,Y._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(a,!1).elseIf((0,Y._)`${s} === "true" || ${s} === 1`).assign(a,!0);return;case"null":n.elseIf((0,Y._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(a,null);return;case"array":n.elseIf((0,Y._)`${i} === "string" || ${i} === "number"
299
- || ${i} === "boolean" || ${s} === null`).assign(a,(0,Y._)`[${s}]`)}}}function S8({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,Y._)`${e} !== undefined`,()=>t.assign((0,Y._)`${e}[${r}]`,n))}function kS(t,e,r,n=Wi.Correct){let s=n===Wi.Correct?Y.operators.EQ:Y.operators.NEQ,o;switch(t){case"null":return(0,Y._)`${e} ${s} null`;case"array":o=(0,Y._)`Array.isArray(${e})`;break;case"object":o=(0,Y._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=i((0,Y._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=i();break;default:return(0,Y._)`typeof ${e} ${s} ${t}`}return n===Wi.Correct?o:(0,Y.not)(o);function i(a=Y.nil){return(0,Y.and)((0,Y._)`typeof ${e} == "number"`,a,r?(0,Y._)`isFinite(${e})`:Y.nil)}}_t.checkDataType=kS;function xS(t,e,r,n){if(t.length===1)return kS(t[0],e,r,n);let s,o=(0,Zj.toHash)(t);if(o.array&&o.object){let i=(0,Y._)`typeof ${e} != "object"`;s=o.null?i:(0,Y._)`!${e} || ${i}`,delete o.null,delete o.array,delete o.object}else s=Y.nil;o.number&&delete o.integer;for(let i in o)s=(0,Y.and)(s,kS(i,e,r,n));return s}_t.checkDataTypes=xS;var $8={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,Y._)`{type: ${t}}`:(0,Y._)`{type: ${e}}`};function ES(t){let e=k8(t);(0,y8.reportError)(e,$8)}_t.reportTypeError=ES;function k8(t){let{gen:e,data:r,schema:n}=t,s=(0,Zj.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:t}}});var Kj=_(kh=>{"use strict";Object.defineProperty(kh,"__esModule",{value:!0});kh.assignDefaults=void 0;var Ji=se(),x8=he();function E8(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let s in r)Bj(t,s,r[s].default);else e==="array"&&Array.isArray(n)&&n.forEach((s,o)=>Bj(t,o,s.default))}kh.assignDefaults=E8;function Bj(t,e,r){let{gen:n,compositeRule:s,data:o,opts:i}=t;if(r===void 0)return;let a=(0,Ji._)`${o}${(0,Ji.getProperty)(e)}`;if(s){(0,x8.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,Ji._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Ji._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Ji._)`${a} = ${(0,Ji.stringify)(r)}`)}});var hr=_(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.validateUnion=Ee.validateArray=Ee.usePattern=Ee.callValidateCode=Ee.schemaProperties=Ee.allSchemaProperties=Ee.noPropertyInData=Ee.propertyInData=Ee.isOwnProperty=Ee.hasPropFunc=Ee.reportMissingProp=Ee.checkMissingProp=Ee.checkReportMissingProp=void 0;var Le=se(),TS=he(),ys=Cn(),T8=he();function P8(t,e){let{gen:r,data:n,it:s}=t;r.if(OS(r,n,e,s.opts.ownProperties),()=>{t.setParams({missingProperty:(0,Le._)`${e}`},!0),t.error()})}Ee.checkReportMissingProp=P8;function O8({gen:t,data:e,it:{opts:r}},n,s){return(0,Le.or)(...n.map(o=>(0,Le.and)(OS(t,e,o,r.ownProperties),(0,Le._)`${s} = ${o}`)))}Ee.checkMissingProp=O8;function I8(t,e){t.setParams({missingProperty:e},!0),t.error()}Ee.reportMissingProp=I8;function Hj(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Le._)`Object.prototype.hasOwnProperty`})}Ee.hasPropFunc=Hj;function PS(t,e,r){return(0,Le._)`${Hj(t)}.call(${e}, ${r})`}Ee.isOwnProperty=PS;function N8(t,e,r,n){let s=(0,Le._)`${e}${(0,Le.getProperty)(r)} !== undefined`;return n?(0,Le._)`${s} && ${PS(t,e,r)}`:s}Ee.propertyInData=N8;function OS(t,e,r,n){let s=(0,Le._)`${e}${(0,Le.getProperty)(r)} === undefined`;return n?(0,Le.or)(s,(0,Le.not)(PS(t,e,r))):s}Ee.noPropertyInData=OS;function Wj(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}Ee.allSchemaProperties=Wj;function C8(t,e){return Wj(e).filter(r=>!(0,TS.alwaysValidSchema)(t,e[r]))}Ee.schemaProperties=C8;function R8({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:i},a,c,l){let u=l?(0,Le._)`${t}, ${e}, ${n}${s}`:e,d=[[ys.default.instancePath,(0,Le.strConcat)(ys.default.instancePath,o)],[ys.default.parentData,i.parentData],[ys.default.parentDataProperty,i.parentDataProperty],[ys.default.rootData,ys.default.rootData]];i.opts.dynamicRef&&d.push([ys.default.dynamicAnchors,ys.default.dynamicAnchors]);let f=(0,Le._)`${u}, ${r.object(...d)}`;return c!==Le.nil?(0,Le._)`${a}.call(${c}, ${f})`:(0,Le._)`${a}(${f})`}Ee.callValidateCode=R8;var A8=(0,Le._)`new RegExp`;function z8({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:s}=e.code,o=s(r,n);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Le._)`${s.code==="new RegExp"?A8:(0,T8.useFunc)(t,s)}(${r}, ${n})`})}Ee.usePattern=z8;function j8(t){let{gen:e,data:r,keyword:n,it:s}=t,o=e.name("valid");if(s.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(o,!0),i(()=>e.break()),o;function i(a){let c=e.const("len",(0,Le._)`${r}.length`);e.forRange("i",0,c,l=>{t.subschema({keyword:n,dataProp:l,dataPropType:TS.Type.Num},o),e.if((0,Le.not)(o),a)})}}Ee.validateArray=j8;function M8(t){let{gen:e,schema:r,keyword:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,TS.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,l)=>{let u=t.subschema({keyword:n,schemaProp:l,compositeRule:!0},a);e.assign(i,(0,Le._)`${i} || ${a}`),t.mergeValidEvaluated(u,a)||e.if((0,Le.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}Ee.validateUnion=M8});var Yj=_(sn=>{"use strict";Object.defineProperty(sn,"__esModule",{value:!0});sn.validateKeywordUsage=sn.validSchemaType=sn.funcKeywordCode=sn.macroKeywordCode=void 0;var Pt=se(),yo=Cn(),L8=hr(),D8=eu();function q8(t,e){let{gen:r,keyword:n,schema:s,parentSchema:o,it:i}=t,a=e.macro.call(i.self,s,o,i),c=Gj(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let l=r.name("valid");t.subschema({schema:a,schemaPath:Pt.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),t.pass(l,()=>t.error(!0))}sn.macroKeywordCode=q8;function F8(t,e){var r;let{gen:n,keyword:s,schema:o,parentSchema:i,$data:a,it:c}=t;U8(c,e);let l=!a&&e.compile?e.compile.call(c.self,o,i,c):e.validate,u=Gj(n,s,l),d=n.let("valid");t.block$data(d,f),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function f(){if(e.errors===!1)h(),e.modifying&&Jj(t),g(()=>t.error());else{let y=e.async?p():m();e.modifying&&Jj(t),g(()=>Z8(t,y))}}function p(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,Pt._)`await `),w=>n.assign(d,!1).if((0,Pt._)`${w} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,Pt._)`${w}.errors`),()=>n.throw(w))),y}function m(){let y=(0,Pt._)`${u}.errors`;return n.assign(y,null),h(Pt.nil),y}function h(y=e.async?(0,Pt._)`await `:Pt.nil){let w=c.opts.passContext?yo.default.this:yo.default.self,b=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,Pt._)`${y}${(0,L8.callValidateCode)(t,u,w,b)}`,e.modifying)}function g(y){var w;n.if((0,Pt.not)((w=e.valid)!==null&&w!==void 0?w:d),y)}}sn.funcKeywordCode=F8;function Jj(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Pt._)`${n.parentData}[${n.parentDataProperty}]`))}function Z8(t,e){let{gen:r}=t;r.if((0,Pt._)`Array.isArray(${e})`,()=>{r.assign(yo.default.vErrors,(0,Pt._)`${yo.default.vErrors} === null ? ${e} : ${yo.default.vErrors}.concat(${e})`).assign(yo.default.errors,(0,Pt._)`${yo.default.vErrors}.length`),(0,D8.extendErrors)(t)},()=>t.error())}function U8({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Gj(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Pt.stringify)(r)})}function V8(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}sn.validSchemaType=V8;function B8({schema:t,opts:e,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");let i=s.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${i.join(",")}`);if(s.validateSchema&&!s.validateSchema(t[o])){let c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}sn.validateKeywordUsage=B8});var Qj=_(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.extendSubschemaMode=_s.extendSubschemaData=_s.getSubschema=void 0;var on=se(),Xj=he();function K8(t,{keyword:e,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,on._)`${t.schemaPath}${(0,on.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,on._)`${t.schemaPath}${(0,on.getProperty)(e)}${(0,on.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Xj.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:i,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}_s.getSubschema=K8;function H8(t,e,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:i}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:l,dataPathArr:u,opts:d}=e,f=a.let("data",(0,on._)`${e.data}${(0,on.getProperty)(r)}`,!0);c(f),t.errorPath=(0,on.str)`${l}${(0,Xj.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,on._)`${r}`,t.dataPathArr=[...u,t.parentDataProperty]}if(s!==void 0){let l=s instanceof on.Name?s:a.let("data",s,!0);c(l),i!==void 0&&(t.propertyName=i)}o&&(t.dataTypes=o);function c(l){t.data=l,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,l]}}_s.extendSubschemaData=H8;function W8(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(t.compositeRule=n),s!==void 0&&(t.createErrors=s),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}_s.extendSubschemaMode=W8});var ru=_((pve,eM)=>{"use strict";eM.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,s,o;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!t(e[s],r[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=n;s--!==0;){var i=o[s];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var rM=_((hve,tM)=>{"use strict";var vs=tM.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};xh(e,n,s,t,"",t)};vs.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};vs.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};vs.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};vs.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function xh(t,e,r,n,s,o,i,a,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,s,o,i,a,c,l);for(var u in n){var d=n[u];if(Array.isArray(d)){if(u in vs.arrayKeywords)for(var f=0;f<d.length;f++)xh(t,e,r,d[f],s+"/"+u+"/"+f,o,s,u,n,f)}else if(u in vs.propsKeywords){if(d&&typeof d=="object")for(var p in d)xh(t,e,r,d[p],s+"/"+u+"/"+J8(p),o,s,u,n,p)}else(u in vs.keywords||t.allKeys&&!(u in vs.skipKeywords))&&xh(t,e,r,d,s+"/"+u,o,s,u,n)}r(n,s,o,i,a,c,l)}}function J8(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var nu=_(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Zt.getSchemaRefs=Zt.resolveUrl=Zt.normalizeId=Zt._getFullPath=Zt.getFullPath=Zt.inlineRef=void 0;var G8=he(),Y8=ru(),X8=rM(),Q8=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function eY(t,e=!0){return typeof t=="boolean"?!0:e===!0?!IS(t):e?nM(t)<=e:!1}Zt.inlineRef=eY;var tY=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function IS(t){for(let e in t){if(tY.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(IS)||typeof r=="object"&&IS(r))return!0}return!1}function nM(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!Q8.has(r)&&(typeof t[r]=="object"&&(0,G8.eachItem)(t[r],n=>e+=nM(n)),e===1/0))return 1/0}return e}function sM(t,e="",r){r!==!1&&(e=Gi(e));let n=t.parse(e);return oM(t,n)}Zt.getFullPath=sM;function oM(t,e){return t.serialize(e).split("#")[0]+"#"}Zt._getFullPath=oM;var rY=/#\/?$/;function Gi(t){return t?t.replace(rY,""):""}Zt.normalizeId=Gi;function nY(t,e,r){return r=Gi(r),t.resolve(e,r)}Zt.resolveUrl=nY;var sY=/^[a-z_][-a-z0-9._]*$/i;function oY(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,s=Gi(t[r]||e),o={"":s},i=sM(n,s,!1),a={},c=new Set;return X8(t,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=i+f,g=o[m];typeof d[r]=="string"&&(g=y.call(this,d[r])),w.call(this,d.$anchor),w.call(this,d.$dynamicAnchor),o[f]=g;function y(b){let x=this.opts.uriResolver.resolve;if(b=Gi(g?x(g,b):b),c.has(b))throw u(b);c.add(b);let v=this.refs[b];return typeof v=="string"&&(v=this.refs[v]),typeof v=="object"?l(d,v.schema,b):b!==Gi(h)&&(b[0]==="#"?(l(d,a[b],b),a[b]=d):this.refs[b]=h),b}function w(b){if(typeof b=="string"){if(!sY.test(b))throw new Error(`invalid anchor "${b}"`);y.call(this,`#${b}`)}}}),a;function l(d,f,p){if(f!==void 0&&!Y8(d,f))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Zt.getSchemaRefs=oY});var iu=_(ws=>{"use strict";Object.defineProperty(ws,"__esModule",{value:!0});ws.getData=ws.KeywordCxt=ws.validateFunctionCode=void 0;var uM=Dj(),iM=tu(),CS=$S(),Eh=tu(),iY=Kj(),ou=Yj(),NS=Qj(),D=se(),H=Cn(),aY=nu(),Rn=he(),su=eu();function cY(t){if(pM(t)&&(hM(t),fM(t))){dY(t);return}dM(t,()=>(0,uM.topBoolOrEmptySchema)(t))}ws.validateFunctionCode=cY;function dM({gen:t,validateName:e,schema:r,schemaEnv:n,opts:s},o){s.code.es5?t.func(e,(0,D._)`${H.default.data}, ${H.default.valCxt}`,n.$async,()=>{t.code((0,D._)`"use strict"; ${aM(r,s)}`),uY(t,s),t.code(o)}):t.func(e,(0,D._)`${H.default.data}, ${lY(s)}`,n.$async,()=>t.code(aM(r,s)).code(o))}function lY(t){return(0,D._)`{${H.default.instancePath}="", ${H.default.parentData}, ${H.default.parentDataProperty}, ${H.default.rootData}=${H.default.data}${t.dynamicRef?(0,D._)`, ${H.default.dynamicAnchors}={}`:D.nil}}={}`}function uY(t,e){t.if(H.default.valCxt,()=>{t.var(H.default.instancePath,(0,D._)`${H.default.valCxt}.${H.default.instancePath}`),t.var(H.default.parentData,(0,D._)`${H.default.valCxt}.${H.default.parentData}`),t.var(H.default.parentDataProperty,(0,D._)`${H.default.valCxt}.${H.default.parentDataProperty}`),t.var(H.default.rootData,(0,D._)`${H.default.valCxt}.${H.default.rootData}`),e.dynamicRef&&t.var(H.default.dynamicAnchors,(0,D._)`${H.default.valCxt}.${H.default.dynamicAnchors}`)},()=>{t.var(H.default.instancePath,(0,D._)`""`),t.var(H.default.parentData,(0,D._)`undefined`),t.var(H.default.parentDataProperty,(0,D._)`undefined`),t.var(H.default.rootData,H.default.data),e.dynamicRef&&t.var(H.default.dynamicAnchors,(0,D._)`{}`)})}function dY(t){let{schema:e,opts:r,gen:n}=t;dM(t,()=>{r.$comment&&e.$comment&&gM(t),gY(t),n.let(H.default.vErrors,null),n.let(H.default.errors,0),r.unevaluated&&fY(t),mM(t),vY(t)})}function fY(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,D._)`${r}.evaluated`),e.if((0,D._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,D._)`${t.evaluated}.props`,(0,D._)`undefined`)),e.if((0,D._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,D._)`${t.evaluated}.items`,(0,D._)`undefined`))}function aM(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,D._)`/*# sourceURL=${r} */`:D.nil}function pY(t,e){if(pM(t)&&(hM(t),fM(t))){hY(t,e);return}(0,uM.boolOrEmptySchema)(t,e)}function fM({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function pM(t){return typeof t.schema!="boolean"}function hY(t,e){let{schema:r,gen:n,opts:s}=t;s.$comment&&r.$comment&&gM(t),yY(t),_Y(t);let o=n.const("_errs",H.default.errors);mM(t,o),n.var(e,(0,D._)`${o} === ${H.default.errors}`)}function hM(t){(0,Rn.checkUnknownRules)(t),mY(t)}function mM(t,e){if(t.opts.jtd)return cM(t,[],!1,e);let r=(0,iM.getSchemaTypes)(t.schema),n=(0,iM.coerceAndCheckDataType)(t,r);cM(t,r,!n,e)}function mY(t){let{schema:e,errSchemaPath:r,opts:n,self:s}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Rn.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function gY(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Rn.checkStrictMode)(t,"default is ignored in the schema root")}function yY(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,aY.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function _Y(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function gM({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===!0)t.code((0,D._)`${H.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let i=(0,D.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,D._)`${H.default.self}.opts.$comment(${o}, ${i}, ${a}.schema)`)}}function vY(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=t;r.$async?e.if((0,D._)`${H.default.errors} === 0`,()=>e.return(H.default.data),()=>e.throw((0,D._)`new ${s}(${H.default.vErrors})`)):(e.assign((0,D._)`${n}.errors`,H.default.vErrors),o.unevaluated&&wY(t),e.return((0,D._)`${H.default.errors} === 0`))}function wY({gen:t,evaluated:e,props:r,items:n}){r instanceof D.Name&&t.assign((0,D._)`${e}.props`,r),n instanceof D.Name&&t.assign((0,D._)`${e}.items`,n)}function cM(t,e,r,n){let{gen:s,schema:o,data:i,allErrors:a,opts:c,self:l}=t,{RULES:u}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Rn.schemaHasRulesButRef)(o,u))){s.block(()=>_M(t,"$ref",u.all.$ref.definition));return}c.jtd||bY(t,e),s.block(()=>{for(let f of u.rules)d(f);d(u.post)});function d(f){(0,CS.shouldUseGroup)(o,f)&&(f.type?(s.if((0,Eh.checkDataType)(f.type,i,c.strictNumbers)),lM(t,f),e.length===1&&e[0]===f.type&&r&&(s.else(),(0,Eh.reportTypeError)(t)),s.endIf()):lM(t,f),a||s.if((0,D._)`${H.default.errors} === ${n||0}`))}}function lM(t,e){let{gen:r,schema:n,opts:{useDefaults:s}}=t;s&&(0,iY.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,CS.shouldUseRule)(n,o)&&_M(t,o.keyword,o.definition,e.type)})}function bY(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(SY(t,e),t.opts.allowUnionTypes||$Y(t,e),kY(t,t.dataTypes))}function SY(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{yM(t.dataTypes,r)||RS(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),EY(t,e)}}function $Y(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&RS(t,"use allowUnionTypes to allow union type keyword")}function kY(t,e){let r=t.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0,CS.shouldUseRule)(t.schema,s)){let{type:o}=s.definition;o.length&&!o.some(i=>xY(e,i))&&RS(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function xY(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function yM(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function EY(t,e){let r=[];for(let n of t.dataTypes)yM(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function RS(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Rn.checkStrictMode)(t,e,t.opts.strictTypes)}var Th=class{constructor(e,r,n){if((0,ou.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Rn.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",vM(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,ou.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",H.default.errors))}result(e,r,n){this.failResult((0,D.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,D.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,D._)`${r} !== undefined && (${(0,D.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?su.reportExtraError:su.reportError)(this,this.def.error,r)}$dataError(){(0,su.reportError)(this,this.def.$dataError||su.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,su.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=D.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=D.nil,r=D.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:i}=this;n.if((0,D.or)((0,D._)`${s} === undefined`,r)),e!==D.nil&&n.assign(e,!0),(o.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==D.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,D.or)(i(),a());function i(){if(n.length){if(!(r instanceof D.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,D._)`${(0,Eh.checkDataTypes)(c,r,o.opts.strictNumbers,Eh.DataType.Wrong)}`}return D.nil}function a(){if(s.validateSchema){let c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,D._)`!${c}(${r})`}return D.nil}}subschema(e,r){let n=(0,NS.getSubschema)(this.it,e);(0,NS.extendSubschemaData)(n,this.it,e),(0,NS.extendSubschemaMode)(n,e);let s={...this.it,...n,items:void 0,props:void 0};return pY(s,r),s}mergeEvaluated(e,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Rn.mergeEvaluated.props(s,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Rn.mergeEvaluated.items(s,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(e,D.Name)),!0}};ws.KeywordCxt=Th;function _M(t,e,r,n){let s=new Th(t,r,e);"code"in r?r.code(s,n):s.$data&&r.validate?(0,ou.funcKeywordCode)(s,r):"macro"in r?(0,ou.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,ou.funcKeywordCode)(s,r)}var TY=/^\/(?:[^~]|~0|~1)*$/,PY=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function vM(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let s,o;if(t==="")return H.default.rootData;if(t[0]==="/"){if(!TY.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);s=t,o=H.default.rootData}else{let l=PY.exec(t);if(!l)throw new Error(`Invalid JSON-pointer: ${t}`);let u=+l[1];if(s=l[2],s==="#"){if(u>=e)throw new Error(c("property/index",u));return n[e-u]}if(u>e)throw new Error(c("data",u));if(o=r[e-u],!s)return o}let i=o,a=s.split("/");for(let l of a)l&&(o=(0,D._)`${o}${(0,D.getProperty)((0,Rn.unescapeJsonPointer)(l))}`,i=(0,D._)`${i} && ${o}`);return i;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${e}`}}ws.getData=vM});var Ph=_(zS=>{"use strict";Object.defineProperty(zS,"__esModule",{value:!0});var AS=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};zS.default=AS});var au=_(LS=>{"use strict";Object.defineProperty(LS,"__esModule",{value:!0});var jS=nu(),MS=class extends Error{constructor(e,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,jS.resolveUrl)(e,r,n),this.missingSchema=(0,jS.normalizeId)((0,jS.getFullPath)(e,this.missingRef))}};LS.default=MS});var Ih=_(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.resolveSchema=mr.getCompilingSchema=mr.resolveRef=mr.compileSchema=mr.SchemaEnv=void 0;var Dr=se(),OY=Ph(),_o=Cn(),qr=nu(),wM=he(),IY=iu(),Yi=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,qr.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};mr.SchemaEnv=Yi;function qS(t){let e=bM.call(this,t);if(e)return e;let r=(0,qr.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,i=new Dr.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),a;t.$async&&(a=i.scopeValue("Error",{ref:OY.default,code:(0,Dr._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let l={gen:i,allErrors:this.opts.allErrors,data:_o.default.data,parentData:_o.default.parentData,parentDataProperty:_o.default.parentDataProperty,dataNames:[_o.default.data],dataPathArr:[Dr.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Dr.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Dr.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Dr._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(t),(0,IY.validateFunctionCode)(l),i.optimize(this.opts.code.optimize);let d=i.toString();u=`${i.scopeRefs(_o.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,t));let p=new Function(`${_o.default.self}`,`${_o.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=t.schema,p.schemaEnv=t,t.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:h}=l;p.evaluated={props:m instanceof Dr.Name?void 0:m,items:h instanceof Dr.Name?void 0:h,dynamicProps:m instanceof Dr.Name,dynamicItems:h instanceof Dr.Name},p.source&&(p.source.evaluated=(0,Dr.stringify)(p.evaluated))}return t.validate=p,t}catch(d){throw delete t.validate,delete t.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(t)}}mr.compileSchema=qS;function NY(t,e,r){var n;r=(0,qr.resolveUrl)(this.opts.uriResolver,e,r);let s=t.refs[r];if(s)return s;let o=AY.call(this,t,r);if(o===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(o=new Yi({schema:i,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=CY.call(this,o)}mr.resolveRef=NY;function CY(t){return(0,qr.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:qS.call(this,t)}function bM(t){for(let e of this._compilations)if(RY(e,t))return e}mr.getCompilingSchema=bM;function RY(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function AY(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Oh.call(this,t,e)}function Oh(t,e){let r=this.opts.uriResolver.parse(e),n=(0,qr._getFullPath)(this.opts.uriResolver,r),s=(0,qr.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===s)return DS.call(this,r,t);let o=(0,qr.normalizeId)(n),i=this.refs[o]||this.schemas[o];if(typeof i=="string"){let a=Oh.call(this,t,i);return typeof a?.schema!="object"?void 0:DS.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||qS.call(this,i),o===(0,qr.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,l=a[c];return l&&(s=(0,qr.resolveUrl)(this.opts.uriResolver,s,l)),new Yi({schema:a,schemaId:c,root:t,baseId:s})}return DS.call(this,r,i)}}mr.resolveSchema=Oh;var zY=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function DS(t,{baseId:e,schema:r,root:n}){var s;if(((s=t.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,wM.unescapeFragment)(a)];if(c===void 0)return;r=c;let l=typeof r=="object"&&r[this.opts.schemaId];!zY.has(a)&&l&&(e=(0,qr.resolveUrl)(this.opts.uriResolver,e,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,wM.schemaHasRulesButRef)(r,this.RULES)){let a=(0,qr.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=Oh.call(this,n,a)}let{schemaId:i}=this.opts;if(o=o||new Yi({schema:r,schemaId:i,root:n,baseId:e}),o.schema!==o.root.schema)return o}});var SM=_((wve,jY)=>{jY.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var US=_((bve,PM)=>{"use strict";var MY=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),kM=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),FS=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),xM=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),LY=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function ZS(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var DY=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function $M(t){return t.length=0,!0}function qY(t,e,r){if(t.length){let n=ZS(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function FY(t){let e=0,r={error:!1,address:"",zone:""},n=[],s=[],o=!1,i=!1,a=qY;for(let c=0;c<t.length;c++){let l=t[c];if(!(l==="["||l==="]"))if(l===":"){if(o===!0&&(i=!0),!a(s,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(o=!0),n.push(":");continue}else if(l==="%"){if(!a(s,n,r))break;a=$M}else{s.push(l);continue}}return s.length&&(a===$M?r.zone=s.join(""):i?n.push(s.join("")):n.push(ZS(s))),r.address=n.join(""),r}function EM(t){if(ZY(t,":")<2)return{host:t,isIPV6:!1};let e=FY(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function ZY(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function UY(t){let e=t,r=[],n=-1,s=0;for(;s=e.length;){if(s===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(s===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(s===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var VY={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},BY=/[@/?#:]/g,KY=/[@/?#]/g;function TM(t,e){let r=e?KY:BY;return r.lastIndex=0,t.replace(r,n=>VY[n])}function HY(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let s=t.slice(n+1,n+3);if(FS(s)){let o=s.toUpperCase(),i=String.fromCharCode(parseInt(o,16));e&&xM(i)?r+=i:r+="%"+o,n+=2;continue}}r+=t[n]}return r}function WY(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(FS(n)){let s=n.toUpperCase(),o=String.fromCharCode(parseInt(s,16));o!=="."&&xM(o)?e+=o:e+="%"+s,r+=2;continue}}LY(t[r])?e+=t[r]:e+=escape(t[r])}return e}function JY(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(FS(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function GY(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!kM(r)){let n=EM(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=TM(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}PM.exports={nonSimpleDomain:DY,recomposeAuthority:GY,reescapeHostDelimiters:TM,normalizePercentEncoding:HY,normalizePathEncoding:WY,escapePreservingEscapes:JY,removeDotSegments:UY,isIPv4:kM,isUUID:MY,normalizeIPv6:EM,stringArrayToHexStripped:ZS}});var RM=_((Sve,CM)=>{"use strict";var{isUUID:YY}=US(),XY=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,QY=["http","https","ws","wss","urn","urn:uuid"];function e7(t){return QY.indexOf(t)!==-1}function VS(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function OM(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function IM(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function t7(t){return t.secure=VS(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function r7(t){if((t.port===(VS(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function n7(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(XY);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let s=`${n}:${e.nid||t.nid}`,o=BS(s);t.path=void 0,o&&(t=o.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function s7(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),s=`${r}:${e.nid||n}`,o=BS(s);o&&(t=o.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function o7(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!YY(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function i7(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var NM={scheme:"http",domainHost:!0,parse:OM,serialize:IM},a7={scheme:"https",domainHost:NM.domainHost,parse:OM,serialize:IM},Nh={scheme:"ws",domainHost:!0,parse:t7,serialize:r7},c7={scheme:"wss",domainHost:Nh.domainHost,parse:Nh.parse,serialize:Nh.serialize},l7={scheme:"urn",parse:n7,serialize:s7,skipNormalize:!0},u7={scheme:"urn:uuid",parse:o7,serialize:i7,skipNormalize:!0},Ch={http:NM,https:a7,ws:Nh,wss:c7,urn:l7,"urn:uuid":u7};Object.setPrototypeOf(Ch,null);function BS(t){return t&&(Ch[t]||Ch[t.toLowerCase()])||void 0}CM.exports={wsIsSecure:VS,SCHEMES:Ch,isValidSchemeName:e7,getSchemeHandler:BS}});var HS=_(($ve,Rh)=>{"use strict";var{normalizeIPv6:d7,removeDotSegments:cu,recomposeAuthority:f7,normalizePercentEncoding:p7,normalizePathEncoding:h7,escapePreservingEscapes:m7,reescapeHostDelimiters:g7,isIPv4:y7,nonSimpleDomain:_7}=US(),{SCHEMES:v7,getSchemeHandler:zM}=RM();function w7(t,e){return typeof t=="string"?t=x7(t,e):typeof t=="object"&&(t=Xi(vo(t,e),e)),t}function b7(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=jM(Xi(t,n),Xi(e,n),n,!0);return n.skipEscape=!0,vo(s,n)}function jM(t,e,r,n){let s={};return n||(t=Xi(vo(t,r),r),e=Xi(vo(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(s.scheme=e.scheme,s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=cu(e.path||""),s.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=cu(e.path||""),s.query=e.query):(e.path?(e.path[0]==="/"?s.path=cu(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?s.path="/"+e.path:t.path?s.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:s.path=e.path,s.path=cu(s.path)),s.query=e.query):(s.path=t.path,e.query!==void 0?s.query=e.query:s.query=t.query),s.userinfo=t.userinfo,s.host=t.host,s.port=t.port),s.scheme=t.scheme),s.fragment=e.fragment,s}function S7(t,e,r){let n=AM(t,r),s=AM(e,r);return n!==void 0&&s!==void 0&&n.toLowerCase()===s.toLowerCase()}function vo(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),s=[],o=zM(n.scheme||r.scheme);o&&o.serialize&&o.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=p7(r.path):(r.path=m7(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&s.push(r.scheme,":");let i=f7(r);if(i!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(i),r.path&&r.path[0]!=="/"&&s.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!o||!o.absolutePath)&&(a=cu(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),s.push(a)}return r.query!==void 0&&s.push("?",r.query),r.fragment!==void 0&&s.push("#",r.fragment),s.join("")}var $7=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function k7(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function MM(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=!1,o=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match($7);if(i){n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]);let a=k7(n,i);if(a!==void 0&&(n.error=n.error||a,s=!0),n.host)if(y7(n.host)===!1){let u=d7(n.host);n.host=u.host.toLowerCase(),o=u.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let c=zM(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&o===!1&&_7(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(l){n.error=n.error||"Host's domain name can not be converted to ASCII: "+l}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=g7(unescape(n.host),o))),n.path&&(n.path=h7(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:s}}function Xi(t,e){return MM(t,e).parsed}function x7(t,e){return LM(t,e).normalized}function LM(t,e){let{parsed:r,malformedAuthorityOrPort:n}=MM(t,e);return{normalized:n?t:vo(r,e),malformedAuthorityOrPort:n}}function AM(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=LM(t,e);return n?void 0:r}if(typeof t=="object")return vo(t,e)}var KS={SCHEMES:v7,normalize:w7,resolve:b7,resolveComponent:jM,equal:S7,serialize:vo,parse:Xi};Rh.exports=KS;Rh.exports.default=KS;Rh.exports.fastUri=KS});var qM=_(WS=>{"use strict";Object.defineProperty(WS,"__esModule",{value:!0});var DM=HS();DM.code='require("ajv/dist/runtime/uri").default';WS.default=DM});var WM=_(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.CodeGen=dt.Name=dt.nil=dt.stringify=dt.str=dt._=dt.KeywordCxt=void 0;var E7=iu();Object.defineProperty(dt,"KeywordCxt",{enumerable:!0,get:function(){return E7.KeywordCxt}});var Qi=se();Object.defineProperty(dt,"_",{enumerable:!0,get:function(){return Qi._}});Object.defineProperty(dt,"str",{enumerable:!0,get:function(){return Qi.str}});Object.defineProperty(dt,"stringify",{enumerable:!0,get:function(){return Qi.stringify}});Object.defineProperty(dt,"nil",{enumerable:!0,get:function(){return Qi.nil}});Object.defineProperty(dt,"Name",{enumerable:!0,get:function(){return Qi.Name}});Object.defineProperty(dt,"CodeGen",{enumerable:!0,get:function(){return Qi.CodeGen}});var T7=Ph(),BM=au(),P7=SS(),lu=Ih(),O7=se(),uu=nu(),Ah=tu(),GS=he(),FM=SM(),I7=qM(),KM=(t,e)=>new RegExp(t,e);KM.code="new RegExp";var N7=["removeAdditional","useDefaults","coerceTypes"],C7=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),R7={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},A7={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},ZM=200;function z7(t){var e,r,n,s,o,i,a,c,l,u,d,f,p,m,h,g,y,w,b,x,v,S,T,P,A;let Z=t.strict,ee=(e=t.code)===null||e===void 0?void 0:e.optimize,J=ee===!0||ee===void 0?1:ee||0,fe=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:KM,Re=(s=t.uriResolver)!==null&&s!==void 0?s:I7.default;return{strictSchema:(i=(o=t.strictSchema)!==null&&o!==void 0?o:Z)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:Z)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=t.strictTypes)!==null&&l!==void 0?l:Z)!==null&&u!==void 0?u:"log",strictTuples:(f=(d=t.strictTuples)!==null&&d!==void 0?d:Z)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=t.strictRequired)!==null&&p!==void 0?p:Z)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:J,regExp:fe}:{optimize:J,regExp:fe},loopRequired:(h=t.loopRequired)!==null&&h!==void 0?h:ZM,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:ZM,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(w=t.messages)!==null&&w!==void 0?w:!0,inlineRefs:(b=t.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(x=t.schemaId)!==null&&x!==void 0?x:"$id",addUsedSchema:(v=t.addUsedSchema)!==null&&v!==void 0?v:!0,validateSchema:(S=t.validateSchema)!==null&&S!==void 0?S:!0,validateFormats:(T=t.validateFormats)!==null&&T!==void 0?T:!0,unicodeRegExp:(P=t.unicodeRegExp)!==null&&P!==void 0?P:!0,int32range:(A=t.int32range)!==null&&A!==void 0?A:!0,uriResolver:Re}}var du=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...z7(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new O7.ValueScope({scope:{},prefixes:C7,es5:r,lines:n}),this.logger=F7(e.logger);let s=e.validateFormats;e.validateFormats=!1,this.RULES=(0,P7.getRules)(),UM.call(this,R7,e,"NOT SUPPORTED"),UM.call(this,A7,e,"DEPRECATED","warn"),this._metaOpts=D7.call(this),e.formats&&M7.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&L7.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),j7.call(this),e.validateFormats=s}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,s=FM;n==="id"&&(s={...FM},s.id=s.$id,delete s.$id),r&&e&&this.addMetaSchema(s,s[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let s=n(r);return"$async"in n||(this.errors=n.errors),s}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,e,r);async function s(u,d){await o.call(this,u.$schema);let f=this._addSchema(u,d);return f.validate||i.call(this,f)}async function o(u){u&&!this.getSchema(u)&&await s.call(this,{$ref:u},!0)}async function i(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof BM.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,u)}}function a({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function c(u){let d=await l.call(this,u);this.refs[u]||await o.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,r)}async function l(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=n(u))}finally{delete this._loading[u]}}}addSchema(e,r,n,s=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,s);return this}let o;if(typeof e=="object"){let{schemaId:i}=this.opts;if(o=e[i],o!==void 0&&typeof o!="string")throw new Error(`schema ${i} must be string`)}return r=(0,uu.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,s,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let s=this.validate(n,e);if(!s&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return s}getSchema(e){let r;for(;typeof(r=VM.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,s=new lu.SchemaEnv({schema:{},schemaId:n});if(r=lu.resolveSchema.call(this,s,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=VM.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,uu.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(U7.call(this,n,r),!r)return(0,GS.eachItem)(n,o=>JS.call(this,o)),this;B7.call(this,r);let s={...r,type:(0,Ah.getJSONTypes)(r.type),schemaType:(0,Ah.getJSONTypes)(r.schemaType)};return(0,GS.eachItem)(n,s.type.length===0?o=>JS.call(this,o,s):o=>s.type.forEach(i=>JS.call(this,o,s,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let s=n.rules.findIndex(o=>o.keyword===e);s>=0&&n.rules.splice(s,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,o)=>s+r+o)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let s of r){let o=s.split("/").slice(1),i=e;for(let a of o)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:l}=c.definition,u=i[a];l&&u&&(i[a]=HM(u))}}return e}_removeAllSchemas(e,r){for(let n in e){let s=e[n];(!r||r.test(n))&&(typeof s=="string"?delete e[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete e[n]))}}_addSchema(e,r,n,s=this.opts.validateSchema,o=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,uu.normalizeId)(i||n);let l=uu.getSchemaRefs.call(this,e,n);return c=new lu.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:l}),this._cache.set(c.schema,c),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),s&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):lu.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{lu.compileSchema.call(this,e)}finally{this.opts=r}}};du.ValidationError=T7.default;du.MissingRefError=BM.default;dt.default=du;function UM(t,e,r,n="error"){for(let s in t){let o=s;o in e&&this.logger[n](`${r}: option ${s}. ${t[o]}`)}}function VM(t){return t=(0,uu.normalizeId)(t),this.schemas[t]||this.refs[t]}function j7(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function M7(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function L7(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function D7(){let t={...this.opts};for(let e of N7)delete t[e];return t}var q7={log(){},warn(){},error(){}};function F7(t){if(t===!1)return q7;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var Z7=/^[a-z_$][a-z0-9_$:-]*$/i;function U7(t,e){let{RULES:r}=this;if((0,GS.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Z7.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function JS(t,e,r){var n;let s=e?.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,i=s?o.post:o.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},o.rules.push(i)),o.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,Ah.getJSONTypes)(e.type),schemaType:(0,Ah.getJSONTypes)(e.schemaType)}};e.before?V7.call(this,i,a,e.before):i.rules.push(a),o.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function V7(t,e,r){let n=t.rules.findIndex(s=>s.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function B7(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=HM(e)),t.validateSchema=this.compile(e,!0))}var K7={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function HM(t){return{anyOf:[t,K7]}}});var JM=_(YS=>{"use strict";Object.defineProperty(YS,"__esModule",{value:!0});var H7={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};YS.default=H7});var QM=_(wo=>{"use strict";Object.defineProperty(wo,"__esModule",{value:!0});wo.callRef=wo.getValidate=void 0;var W7=au(),GM=hr(),Ut=se(),ea=Cn(),YM=Ih(),zh=he(),J7={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:s,schemaEnv:o,validateName:i,opts:a,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return d();let u=YM.resolveRef.call(c,l,s,r);if(u===void 0)throw new W7.default(n.opts.uriResolver,s,r);if(u instanceof YM.SchemaEnv)return f(u);return p(u);function d(){if(o===l)return jh(t,i,o,o.$async);let m=e.scopeValue("root",{ref:l});return jh(t,(0,Ut._)`${m}.validate`,l,l.$async)}function f(m){let h=XM(t,m);jh(t,h,m,m.$async)}function p(m){let h=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Ut.stringify)(m)}:{ref:m}),g=e.name("valid"),y=t.subschema({schema:m,dataTypes:[],schemaPath:Ut.nil,topSchemaRef:h,errSchemaPath:r},g);t.mergeEvaluated(y),t.ok(g)}}};function XM(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Ut._)`${r.scopeValue("wrapper",{ref:e})}.validate`}wo.getValidate=XM;function jh(t,e,r,n){let{gen:s,it:o}=t,{allErrors:i,schemaEnv:a,opts:c}=o,l=c.passContext?ea.default.this:Ut.nil;n?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=s.let("valid");s.try(()=>{s.code((0,Ut._)`await ${(0,GM.callValidateCode)(t,e,l)}`),p(e),i||s.assign(m,!0)},h=>{s.if((0,Ut._)`!(${h} instanceof ${o.ValidationError})`,()=>s.throw(h)),f(h),i||s.assign(m,!1)}),t.ok(m)}function d(){t.result((0,GM.callValidateCode)(t,e,l),()=>p(e),()=>f(e))}function f(m){let h=(0,Ut._)`${m}.errors`;s.assign(ea.default.vErrors,(0,Ut._)`${ea.default.vErrors} === null ? ${h} : ${ea.default.vErrors}.concat(${h})`),s.assign(ea.default.errors,(0,Ut._)`${ea.default.vErrors}.length`)}function p(m){var h;if(!o.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=zh.mergeEvaluated.props(s,g.props,o.props));else{let y=s.var("props",(0,Ut._)`${m}.evaluated.props`);o.props=zh.mergeEvaluated.props(s,y,o.props,Ut.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=zh.mergeEvaluated.items(s,g.items,o.items));else{let y=s.var("items",(0,Ut._)`${m}.evaluated.items`);o.items=zh.mergeEvaluated.items(s,y,o.items,Ut.Name)}}}wo.callRef=jh;wo.default=J7});var eL=_(XS=>{"use strict";Object.defineProperty(XS,"__esModule",{value:!0});var G7=JM(),Y7=QM(),X7=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",G7.default,Y7.default];XS.default=X7});var tL=_(QS=>{"use strict";Object.defineProperty(QS,"__esModule",{value:!0});var Mh=se(),bs=Mh.operators,Lh={maximum:{okStr:"<=",ok:bs.LTE,fail:bs.GT},minimum:{okStr:">=",ok:bs.GTE,fail:bs.LT},exclusiveMaximum:{okStr:"<",ok:bs.LT,fail:bs.GTE},exclusiveMinimum:{okStr:">",ok:bs.GT,fail:bs.LTE}},Q7={message:({keyword:t,schemaCode:e})=>(0,Mh.str)`must be ${Lh[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Mh._)`{comparison: ${Lh[t].okStr}, limit: ${e}}`},eX={keyword:Object.keys(Lh),type:"number",schemaType:"number",$data:!0,error:Q7,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,Mh._)`${r} ${Lh[e].fail} ${n} || isNaN(${r})`)}};QS.default=eX});var rL=_(e$=>{"use strict";Object.defineProperty(e$,"__esModule",{value:!0});var fu=se(),tX={message:({schemaCode:t})=>(0,fu.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,fu._)`{multipleOf: ${t}}`},rX={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:tX,code(t){let{gen:e,data:r,schemaCode:n,it:s}=t,o=s.opts.multipleOfPrecision,i=e.let("res"),a=o?(0,fu._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:(0,fu._)`${i} !== parseInt(${i})`;t.fail$data((0,fu._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};e$.default=rX});var sL=_(t$=>{"use strict";Object.defineProperty(t$,"__esModule",{value:!0});function nL(t){let e=t.length,r=0,n=0,s;for(;n<e;)r++,s=t.charCodeAt(n++),s>=55296&&s<=56319&&n<e&&(s=t.charCodeAt(n),(s&64512)===56320&&n++);return r}t$.default=nL;nL.code='require("ajv/dist/runtime/ucs2length").default'});var oL=_(r$=>{"use strict";Object.defineProperty(r$,"__esModule",{value:!0});var bo=se(),nX=he(),sX=sL(),oX={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,bo.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,bo._)`{limit: ${t}}`},iX={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:oX,code(t){let{keyword:e,data:r,schemaCode:n,it:s}=t,o=e==="maxLength"?bo.operators.GT:bo.operators.LT,i=s.opts.unicode===!1?(0,bo._)`${r}.length`:(0,bo._)`${(0,nX.useFunc)(t.gen,sX.default)}(${r})`;t.fail$data((0,bo._)`${i} ${o} ${n}`)}};r$.default=iX});var iL=_(n$=>{"use strict";Object.defineProperty(n$,"__esModule",{value:!0});var aX=hr(),cX=he(),ta=se(),lX={message:({schemaCode:t})=>(0,ta.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,ta._)`{pattern: ${t}}`},uX={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:lX,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:o,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,l=c.code==="new RegExp"?(0,ta._)`new RegExp`:(0,cX.useFunc)(e,c),u=e.let("valid");e.try(()=>e.assign(u,(0,ta._)`${l}(${o}, ${a}).test(${r})`),()=>e.assign(u,!1)),t.fail$data((0,ta._)`!${u}`)}else{let c=(0,aX.usePattern)(t,s);t.fail$data((0,ta._)`!${c}.test(${r})`)}}};n$.default=uX});var aL=_(s$=>{"use strict";Object.defineProperty(s$,"__esModule",{value:!0});var pu=se(),dX={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,pu.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,pu._)`{limit: ${t}}`},fX={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:dX,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxProperties"?pu.operators.GT:pu.operators.LT;t.fail$data((0,pu._)`Object.keys(${r}).length ${s} ${n}`)}};s$.default=fX});var cL=_(o$=>{"use strict";Object.defineProperty(o$,"__esModule",{value:!0});var hu=hr(),mu=se(),pX=he(),hX={message:({params:{missingProperty:t}})=>(0,mu.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,mu._)`{missingProperty: ${t}}`},mX={keyword:"required",type:"object",schemaType:"array",$data:!0,error:hX,code(t){let{gen:e,schema:r,schemaCode:n,data:s,$data:o,it:i}=t,{opts:a}=i;if(!o&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?l():u(),a.strictRequired){let p=t.parentSchema.properties,{definedProperties:m}=t.it;for(let h of r)if(p?.[h]===void 0&&!m.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,pX.checkStrictMode)(i,y,i.opts.strictRequired)}}function l(){if(c||o)t.block$data(mu.nil,d);else for(let p of r)(0,hu.checkReportMissingProp)(t,p)}function u(){let p=e.let("missing");if(c||o){let m=e.let("valid",!0);t.block$data(m,()=>f(p,m)),t.ok(m)}else e.if((0,hu.checkMissingProp)(t,r,p)),(0,hu.reportMissingProp)(t,p),e.else()}function d(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,hu.noPropertyInData)(e,s,p,a.ownProperties),()=>t.error())})}function f(p,m){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(m,(0,hu.propertyInData)(e,s,p,a.ownProperties)),e.if((0,mu.not)(m),()=>{t.error(),e.break()})},mu.nil)}}};o$.default=mX});var lL=_(i$=>{"use strict";Object.defineProperty(i$,"__esModule",{value:!0});var gu=se(),gX={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,gu.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,gu._)`{limit: ${t}}`},yX={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:gX,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxItems"?gu.operators.GT:gu.operators.LT;t.fail$data((0,gu._)`${r}.length ${s} ${n}`)}};i$.default=yX});var Dh=_(a$=>{"use strict";Object.defineProperty(a$,"__esModule",{value:!0});var uL=ru();uL.code='require("ajv/dist/runtime/equal").default';a$.default=uL});var dL=_(l$=>{"use strict";Object.defineProperty(l$,"__esModule",{value:!0});var c$=tu(),ft=se(),_X=he(),vX=Dh(),wX={message:({params:{i:t,j:e}})=>(0,ft.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ft._)`{i: ${t}, j: ${e}}`},bX={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:wX,code(t){let{gen:e,data:r,$data:n,schema:s,parentSchema:o,schemaCode:i,it:a}=t;if(!n&&!s)return;let c=e.let("valid"),l=o.items?(0,c$.getSchemaTypes)(o.items):[];t.block$data(c,u,(0,ft._)`${i} === false`),t.ok(c);function u(){let m=e.let("i",(0,ft._)`${r}.length`),h=e.let("j");t.setParams({i:m,j:h}),e.assign(c,!0),e.if((0,ft._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return l.length>0&&!l.some(m=>m==="object"||m==="array")}function f(m,h){let g=e.name("item"),y=(0,c$.checkDataTypes)(l,g,a.opts.strictNumbers,c$.DataType.Wrong),w=e.const("indices",(0,ft._)`{}`);e.for((0,ft._)`;${m}--;`,()=>{e.let(g,(0,ft._)`${r}[${m}]`),e.if(y,(0,ft._)`continue`),l.length>1&&e.if((0,ft._)`typeof ${g} == "string"`,(0,ft._)`${g} += "_"`),e.if((0,ft._)`typeof ${w}[${g}] == "number"`,()=>{e.assign(h,(0,ft._)`${w}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,ft._)`${w}[${g}] = ${m}`)})}function p(m,h){let g=(0,_X.useFunc)(e,vX.default),y=e.name("outer");e.label(y).for((0,ft._)`;${m}--;`,()=>e.for((0,ft._)`${h} = ${m}; ${h}--;`,()=>e.if((0,ft._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};l$.default=bX});var fL=_(d$=>{"use strict";Object.defineProperty(d$,"__esModule",{value:!0});var u$=se(),SX=he(),$X=Dh(),kX={message:"must be equal to constant",params:({schemaCode:t})=>(0,u$._)`{allowedValue: ${t}}`},xX={keyword:"const",$data:!0,error:kX,code(t){let{gen:e,data:r,$data:n,schemaCode:s,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,u$._)`!${(0,SX.useFunc)(e,$X.default)}(${r}, ${s})`):t.fail((0,u$._)`${o} !== ${r}`)}};d$.default=xX});var pL=_(f$=>{"use strict";Object.defineProperty(f$,"__esModule",{value:!0});var yu=se(),EX=he(),TX=Dh(),PX={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,yu._)`{allowedValues: ${t}}`},OX={keyword:"enum",schemaType:"array",$data:!0,error:PX,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:o,it:i}=t;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let a=s.length>=i.opts.loopEnum,c,l=()=>c??(c=(0,EX.useFunc)(e,TX.default)),u;if(a||n)u=e.let("valid"),t.block$data(u,d);else{if(!Array.isArray(s))throw new Error("ajv implementation error");let p=e.const("vSchema",o);u=(0,yu.or)(...s.map((m,h)=>f(p,h)))}t.pass(u);function d(){e.assign(u,!1),e.forOf("v",o,p=>e.if((0,yu._)`${l()}(${r}, ${p})`,()=>e.assign(u,!0).break()))}function f(p,m){let h=s[m];return typeof h=="object"&&h!==null?(0,yu._)`${l()}(${r}, ${p}[${m}])`:(0,yu._)`${r} === ${h}`}}};f$.default=OX});var hL=_(p$=>{"use strict";Object.defineProperty(p$,"__esModule",{value:!0});var IX=tL(),NX=rL(),CX=oL(),RX=iL(),AX=aL(),zX=cL(),jX=lL(),MX=dL(),LX=fL(),DX=pL(),qX=[IX.default,NX.default,CX.default,RX.default,AX.default,zX.default,jX.default,MX.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},LX.default,DX.default];p$.default=qX});var m$=_(_u=>{"use strict";Object.defineProperty(_u,"__esModule",{value:!0});_u.validateAdditionalItems=void 0;var So=se(),h$=he(),FX={message:({params:{len:t}})=>(0,So.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,So._)`{limit: ${t}}`},ZX={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:FX,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,h$.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}mL(t,n)}};function mL(t,e){let{gen:r,schema:n,data:s,keyword:o,it:i}=t;i.items=!0;let a=r.const("len",(0,So._)`${s}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,So._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,h$.alwaysValidSchema)(i,n)){let l=r.var("valid",(0,So._)`${a} <= ${e.length}`);r.if((0,So.not)(l),()=>c(l)),t.ok(l)}function c(l){r.forRange("i",e.length,a,u=>{t.subschema({keyword:o,dataProp:u,dataPropType:h$.Type.Num},l),i.allErrors||r.if((0,So.not)(l),()=>r.break())})}}_u.validateAdditionalItems=mL;_u.default=ZX});var g$=_(vu=>{"use strict";Object.defineProperty(vu,"__esModule",{value:!0});vu.validateTuple=void 0;var gL=se(),qh=he(),UX=hr(),VX={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return yL(t,"additionalItems",e);r.items=!0,!(0,qh.alwaysValidSchema)(r,e)&&t.ok((0,UX.validateArray)(t))}};function yL(t,e,r=t.schema){let{gen:n,parentSchema:s,data:o,keyword:i,it:a}=t;u(s),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=qh.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),l=n.const("len",(0,gL._)`${o}.length`);r.forEach((d,f)=>{(0,qh.alwaysValidSchema)(a,d)||(n.if((0,gL._)`${l} > ${f}`,()=>t.subschema({keyword:i,schemaProp:f,dataProp:f},c)),t.ok(c))});function u(d){let{opts:f,errSchemaPath:p}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[e]===!1);if(f.strictTuples&&!h){let g=`"${i}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,qh.checkStrictMode)(a,g,f.strictTuples)}}}vu.validateTuple=yL;vu.default=VX});var _L=_(y$=>{"use strict";Object.defineProperty(y$,"__esModule",{value:!0});var BX=g$(),KX={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,BX.validateTuple)(t,"items")};y$.default=KX});var wL=_(_$=>{"use strict";Object.defineProperty(_$,"__esModule",{value:!0});var vL=se(),HX=he(),WX=hr(),JX=m$(),GX={message:({params:{len:t}})=>(0,vL.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,vL._)`{limit: ${t}}`},YX={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:GX,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:s}=r;n.items=!0,!(0,HX.alwaysValidSchema)(n,e)&&(s?(0,JX.validateAdditionalItems)(t,s):t.ok((0,WX.validateArray)(t)))}};_$.default=YX});var bL=_(v$=>{"use strict";Object.defineProperty(v$,"__esModule",{value:!0});var gr=se(),Fh=he(),XX={message:({params:{min:t,max:e}})=>e===void 0?(0,gr.str)`must contain at least ${t} valid item(s)`:(0,gr.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,gr._)`{minContains: ${t}}`:(0,gr._)`{minContains: ${t}, maxContains: ${e}}`},QX={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:XX,code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:o}=t,i,a,{minContains:c,maxContains:l}=n;o.opts.next?(i=c===void 0?1:c,a=l):i=1;let u=e.const("len",(0,gr._)`${s}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,Fh.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,Fh.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,Fh.alwaysValidSchema)(o,r)){let h=(0,gr._)`${u} >= ${i}`;a!==void 0&&(h=(0,gr._)`${h} && ${u} <= ${a}`),t.pass(h);return}o.items=!0;let d=e.name("valid");a===void 0&&i===1?p(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,gr._)`${s}.length > 0`,f)):(e.let(d,!1),f()),t.result(d,()=>t.reset());function f(){let h=e.name("_valid"),g=e.let("count",0);p(h,()=>e.if(h,()=>m(g)))}function p(h,g){e.forRange("i",0,u,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:Fh.Type.Num,compositeRule:!0},h),g()})}function m(h){e.code((0,gr._)`${h}++`),a===void 0?e.if((0,gr._)`${h} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,gr._)`${h} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,gr._)`${h} >= ${i}`,()=>e.assign(d,!0)))}}};v$.default=QX});var kL=_(an=>{"use strict";Object.defineProperty(an,"__esModule",{value:!0});an.validateSchemaDeps=an.validatePropertyDeps=an.error=void 0;var w$=se(),eQ=he(),wu=hr();an.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,w$.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,w$._)`{property: ${t},
300
- missingProperty: ${n},
301
- depsCount: ${e},
302
- deps: ${r}}`};var tQ={keyword:"dependencies",type:"object",schemaType:"object",error:an.error,code(t){let[e,r]=rQ(t);SL(t,e),$L(t,r)}};function rQ({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let s=Array.isArray(t[n])?e:r;s[n]=t[n]}return[e,r]}function SL(t,e=t.schema){let{gen:r,data:n,it:s}=t;if(Object.keys(e).length===0)return;let o=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,wu.propertyInData)(r,n,i,s.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),s.allErrors?r.if(c,()=>{for(let l of a)(0,wu.checkReportMissingProp)(t,l)}):(r.if((0,w$._)`${c} && (${(0,wu.checkMissingProp)(t,a,o)})`),(0,wu.reportMissingProp)(t,o),r.else())}}an.validatePropertyDeps=SL;function $L(t,e=t.schema){let{gen:r,data:n,keyword:s,it:o}=t,i=r.name("valid");for(let a in e)(0,eQ.alwaysValidSchema)(o,e[a])||(r.if((0,wu.propertyInData)(r,n,a,o.opts.ownProperties),()=>{let c=t.subschema({keyword:s,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}an.validateSchemaDeps=$L;an.default=tQ});var EL=_(b$=>{"use strict";Object.defineProperty(b$,"__esModule",{value:!0});var xL=se(),nQ=he(),sQ={message:"property name must be valid",params:({params:t})=>(0,xL._)`{propertyName: ${t.propertyName}}`},oQ={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:sQ,code(t){let{gen:e,schema:r,data:n,it:s}=t;if((0,nQ.alwaysValidSchema)(s,r))return;let o=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},o),e.if((0,xL.not)(o),()=>{t.error(!0),s.allErrors||e.break()})}),t.ok(o)}};b$.default=oQ});var $$=_(S$=>{"use strict";Object.defineProperty(S$,"__esModule",{value:!0});var Zh=hr(),Fr=se(),iQ=Cn(),Uh=he(),aQ={message:"must NOT have additional properties",params:({params:t})=>(0,Fr._)`{additionalProperty: ${t.additionalProperty}}`},cQ={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:aQ,code(t){let{gen:e,schema:r,parentSchema:n,data:s,errsCount:o,it:i}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,Uh.alwaysValidSchema)(i,r))return;let l=(0,Zh.allSchemaProperties)(n.properties),u=(0,Zh.allSchemaProperties)(n.patternProperties);d(),t.ok((0,Fr._)`${o} === ${iQ.default.errors}`);function d(){e.forIn("key",s,g=>{!l.length&&!u.length?m(g):e.if(f(g),()=>m(g))})}function f(g){let y;if(l.length>8){let w=(0,Uh.schemaRefOrVal)(i,n.properties,"properties");y=(0,Zh.isOwnProperty)(e,w,g)}else l.length?y=(0,Fr.or)(...l.map(w=>(0,Fr._)`${g} === ${w}`)):y=Fr.nil;return u.length&&(y=(0,Fr.or)(y,...u.map(w=>(0,Fr._)`${(0,Zh.usePattern)(t,w)}.test(${g})`))),(0,Fr.not)(y)}function p(g){e.code((0,Fr._)`delete ${s}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,Uh.alwaysValidSchema)(i,r)){let y=e.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),e.if((0,Fr.not)(y),()=>{t.reset(),p(g)})):(h(g,y),a||e.if((0,Fr.not)(y),()=>e.break()))}}function h(g,y,w){let b={keyword:"additionalProperties",dataProp:g,dataPropType:Uh.Type.Str};w===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(b,y)}}};S$.default=cQ});var OL=_(x$=>{"use strict";Object.defineProperty(x$,"__esModule",{value:!0});var lQ=iu(),TL=hr(),k$=he(),PL=$$(),uQ={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:o}=t;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&PL.default.code(new lQ.KeywordCxt(o,PL.default,"additionalProperties"));let i=(0,TL.allSchemaProperties)(r);for(let d of i)o.definedProperties.add(d);o.opts.unevaluated&&i.length&&o.props!==!0&&(o.props=k$.mergeEvaluated.props(e,(0,k$.toHash)(i),o.props));let a=i.filter(d=>!(0,k$.alwaysValidSchema)(o,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,TL.propertyInData)(e,s,d,o.opts.ownProperties)),u(d),o.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};x$.default=uQ});var RL=_(E$=>{"use strict";Object.defineProperty(E$,"__esModule",{value:!0});var IL=hr(),Vh=se(),NL=he(),CL=he(),dQ={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:s,it:o}=t,{opts:i}=o,a=(0,IL.allSchemaProperties)(r),c=a.filter(h=>(0,NL.alwaysValidSchema)(o,r[h]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let l=i.strictSchema&&!i.allowMatchingProperties&&s.properties,u=e.name("valid");o.props!==!0&&!(o.props instanceof Vh.Name)&&(o.props=(0,CL.evaluatedPropsToName)(e,o.props));let{props:d}=o;f();function f(){for(let h of a)l&&p(h),o.allErrors?m(h):(e.var(u,!0),m(h),e.if(u))}function p(h){for(let g in l)new RegExp(h).test(g)&&(0,NL.checkStrictMode)(o,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){e.forIn("key",n,g=>{e.if((0,Vh._)`${(0,IL.usePattern)(t,h)}.test(${g})`,()=>{let y=c.includes(h);y||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:CL.Type.Str},u),o.opts.unevaluated&&d!==!0?e.assign((0,Vh._)`${d}[${g}]`,!0):!y&&!o.allErrors&&e.if((0,Vh.not)(u),()=>e.break())})})}}};E$.default=dQ});var AL=_(T$=>{"use strict";Object.defineProperty(T$,"__esModule",{value:!0});var fQ=he(),pQ={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,fQ.alwaysValidSchema)(n,r)){t.fail();return}let s=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),t.failResult(s,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};T$.default=pQ});var zL=_(P$=>{"use strict";Object.defineProperty(P$,"__esModule",{value:!0});var hQ=hr(),mQ={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:hQ.validateUnion,error:{message:"must match a schema in anyOf"}};P$.default=mQ});var jL=_(O$=>{"use strict";Object.defineProperty(O$,"__esModule",{value:!0});var Bh=se(),gQ=he(),yQ={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Bh._)`{passingSchemas: ${t.passing}}`},_Q={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:yQ,code(t){let{gen:e,schema:r,parentSchema:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let o=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(l),t.result(i,()=>t.reset(),()=>t.error(!0));function l(){o.forEach((u,d)=>{let f;(0,gQ.alwaysValidSchema)(s,u)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Bh._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Bh._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),f&&t.mergeEvaluated(f,Bh.Name)})})}}};O$.default=_Q});var ML=_(I$=>{"use strict";Object.defineProperty(I$,"__esModule",{value:!0});var vQ=he(),wQ={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let s=e.name("valid");r.forEach((o,i)=>{if((0,vQ.alwaysValidSchema)(n,o))return;let a=t.subschema({keyword:"allOf",schemaProp:i},s);t.ok(s),t.mergeEvaluated(a)})}};I$.default=wQ});var qL=_(N$=>{"use strict";Object.defineProperty(N$,"__esModule",{value:!0});var Kh=se(),DL=he(),bQ={message:({params:t})=>(0,Kh.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Kh._)`{failingKeyword: ${t.ifClause}}`},SQ={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:bQ,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,DL.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=LL(n,"then"),o=LL(n,"else");if(!s&&!o)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),s&&o){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else s?e.if(a,l("then")):e.if((0,Kh.not)(a),l("else"));t.pass(i,()=>t.error(!0));function c(){let u=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(u)}function l(u,d){return()=>{let f=t.subschema({keyword:u},a);e.assign(i,a),t.mergeValidEvaluated(f,i),d?e.assign(d,(0,Kh._)`${u}`):t.setParams({ifClause:u})}}}};function LL(t,e){let r=t.schema[e];return r!==void 0&&!(0,DL.alwaysValidSchema)(t,r)}N$.default=SQ});var FL=_(C$=>{"use strict";Object.defineProperty(C$,"__esModule",{value:!0});var $Q=he(),kQ={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,$Q.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};C$.default=kQ});var ZL=_(R$=>{"use strict";Object.defineProperty(R$,"__esModule",{value:!0});var xQ=m$(),EQ=_L(),TQ=g$(),PQ=wL(),OQ=bL(),IQ=kL(),NQ=EL(),CQ=$$(),RQ=OL(),AQ=RL(),zQ=AL(),jQ=zL(),MQ=jL(),LQ=ML(),DQ=qL(),qQ=FL();function FQ(t=!1){let e=[zQ.default,jQ.default,MQ.default,LQ.default,DQ.default,qQ.default,NQ.default,CQ.default,IQ.default,RQ.default,AQ.default];return t?e.push(EQ.default,PQ.default):e.push(xQ.default,TQ.default),e.push(OQ.default),e}R$.default=FQ});var UL=_(A$=>{"use strict";Object.defineProperty(A$,"__esModule",{value:!0});var Ge=se(),ZQ={message:({schemaCode:t})=>(0,Ge.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Ge._)`{format: ${t}}`},UQ={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:ZQ,code(t,e){let{gen:r,data:n,$data:s,schema:o,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;s?f():p();function f(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,Ge._)`${m}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,Ge._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,Ge._)`${h}.type || "string"`).assign(y,(0,Ge._)`${h}.validate`),()=>r.assign(g,(0,Ge._)`"string"`).assign(y,h)),t.fail$data((0,Ge.or)(w(),b()));function w(){return c.strictSchema===!1?Ge.nil:(0,Ge._)`${i} && !${y}`}function b(){let x=u.$async?(0,Ge._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,Ge._)`${y}(${n})`,v=(0,Ge._)`(typeof ${y} == "function" ? ${x} : ${y}.test(${n}))`;return(0,Ge._)`${y} && ${y} !== true && ${g} === ${e} && !${v}`}}function p(){let m=d.formats[o];if(!m){w();return}if(m===!0)return;let[h,g,y]=b(m);h===e&&t.pass(x());function w(){if(c.strictSchema===!1){d.logger.warn(v());return}throw new Error(v());function v(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function b(v){let S=v instanceof RegExp?(0,Ge.regexpCode)(v):c.code.formats?(0,Ge._)`${c.code.formats}${(0,Ge.getProperty)(o)}`:void 0,T=r.scopeValue("formats",{key:o,ref:v,code:S});return typeof v=="object"&&!(v instanceof RegExp)?[v.type||"string",v.validate,(0,Ge._)`${T}.validate`]:["string",v,T]}function x(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Ge._)`await ${y}(${n})`}return typeof g=="function"?(0,Ge._)`${y}(${n})`:(0,Ge._)`${y}.test(${n})`}}}};A$.default=UQ});var VL=_(z$=>{"use strict";Object.defineProperty(z$,"__esModule",{value:!0});var VQ=UL(),BQ=[VQ.default];z$.default=BQ});var BL=_(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.contentVocabulary=ra.metadataVocabulary=void 0;ra.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ra.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var HL=_(j$=>{"use strict";Object.defineProperty(j$,"__esModule",{value:!0});var KQ=eL(),HQ=hL(),WQ=ZL(),JQ=VL(),KL=BL(),GQ=[KQ.default,HQ.default,(0,WQ.default)(),JQ.default,KL.metadataVocabulary,KL.contentVocabulary];j$.default=GQ});var JL=_(Hh=>{"use strict";Object.defineProperty(Hh,"__esModule",{value:!0});Hh.DiscrError=void 0;var WL;(function(t){t.Tag="tag",t.Mapping="mapping"})(WL||(Hh.DiscrError=WL={}))});var YL=_(L$=>{"use strict";Object.defineProperty(L$,"__esModule",{value:!0});var na=se(),M$=JL(),GL=Ih(),YQ=au(),XQ=he(),QQ={message:({params:{discrError:t,tagName:e}})=>t===M$.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,na._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},eee={keyword:"discriminator",type:"object",schemaType:"object",error:QQ,code(t){let{gen:e,data:r,schema:n,parentSchema:s,it:o}=t,{oneOf:i}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),l=e.const("tag",(0,na._)`${r}${(0,na.getProperty)(a)}`);e.if((0,na._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:M$.DiscrError.Tag,tag:l,tagName:a})),t.ok(c);function u(){let p=f();e.if(!1);for(let m in p)e.elseIf((0,na._)`${l} === ${m}`),e.assign(c,d(p[m]));e.else(),t.error(!1,{discrError:M$.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(p){let m=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:p},m);return t.mergeEvaluated(h,na.Name),m}function f(){var p;let m={},h=y(s),g=!0;for(let x=0;x<i.length;x++){let v=i[x];if(v?.$ref&&!(0,XQ.schemaHasRulesButRef)(v,o.self.RULES)){let T=v.$ref;if(v=GL.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,T),v instanceof GL.SchemaEnv&&(v=v.schema),v===void 0)throw new YQ.default(o.opts.uriResolver,o.baseId,T)}let S=(p=v?.properties)===null||p===void 0?void 0:p[a];if(typeof S!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(v)),w(S,x)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function y({required:x}){return Array.isArray(x)&&x.includes(a)}function w(x,v){if(x.const)b(x.const,v);else if(x.enum)for(let S of x.enum)b(S,v);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b(x,v){if(typeof x!="string"||x in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[x]=v}}}};L$.default=eee});var XL=_((dwe,tee)=>{tee.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var eD=_((De,D$)=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.MissingRefError=De.ValidationError=De.CodeGen=De.Name=De.nil=De.stringify=De.str=De._=De.KeywordCxt=De.Ajv=void 0;var ree=WM(),nee=HL(),see=YL(),QL=XL(),oee=["/properties"],Wh="http://json-schema.org/draft-07/schema",sa=class extends ree.default{_addVocabularies(){super._addVocabularies(),nee.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(see.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(QL,oee):QL;this.addMetaSchema(e,Wh,!1),this.refs["http://json-schema.org/schema"]=Wh}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Wh)?Wh:void 0)}};De.Ajv=sa;D$.exports=De=sa;D$.exports.Ajv=sa;Object.defineProperty(De,"__esModule",{value:!0});De.default=sa;var iee=iu();Object.defineProperty(De,"KeywordCxt",{enumerable:!0,get:function(){return iee.KeywordCxt}});var oa=se();Object.defineProperty(De,"_",{enumerable:!0,get:function(){return oa._}});Object.defineProperty(De,"str",{enumerable:!0,get:function(){return oa.str}});Object.defineProperty(De,"stringify",{enumerable:!0,get:function(){return oa.stringify}});Object.defineProperty(De,"nil",{enumerable:!0,get:function(){return oa.nil}});Object.defineProperty(De,"Name",{enumerable:!0,get:function(){return oa.Name}});Object.defineProperty(De,"CodeGen",{enumerable:!0,get:function(){return oa.CodeGen}});var aee=Ph();Object.defineProperty(De,"ValidationError",{enumerable:!0,get:function(){return aee.default}});var cee=au();Object.defineProperty(De,"MissingRefError",{enumerable:!0,get:function(){return cee.default}})});var cD=_(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.formatNames=ln.fastFormats=ln.fullFormats=void 0;function cn(t,e){return{validate:t,compare:e}}ln.fullFormats={date:cn(sD,U$),time:cn(F$(!0),V$),"date-time":cn(tD(!0),iD),"iso-time":cn(F$(),oD),"iso-date-time":cn(tD(),aD),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:hee,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:bee,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:mee,int32:{type:"number",validate:_ee},int64:{type:"number",validate:vee},float:{type:"number",validate:nD},double:{type:"number",validate:nD},password:!0,binary:!0};ln.fastFormats={...ln.fullFormats,date:cn(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,U$),time:cn(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,V$),"date-time":cn(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,iD),"iso-time":cn(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,oD),"iso-date-time":cn(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,aD),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};ln.formatNames=Object.keys(ln.fullFormats);function lee(t){return t%4===0&&(t%100!==0||t%400===0)}var uee=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,dee=[0,31,28,31,30,31,30,31,31,30,31,30,31];function sD(t){let e=uee.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],s=+e[3];return n>=1&&n<=12&&s>=1&&s<=(n===2&&lee(r)?29:dee[n])}function U$(t,e){if(t&&e)return t>e?1:t<e?-1:0}var q$=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function F$(t){return function(r){let n=q$.exec(r);if(!n)return!1;let s=+n[1],o=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||t&&!a)return!1;if(s<=23&&o<=59&&i<60)return!0;let d=o-u*c,f=s-l*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&i<61}}function V$(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function oD(t,e){if(!(t&&e))return;let r=q$.exec(t),n=q$.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var Z$=/t|\s/i;function tD(t){let e=F$(t);return function(n){let s=n.split(Z$);return s.length===2&&sD(s[0])&&e(s[1])}}function iD(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function aD(t,e){if(!(t&&e))return;let[r,n]=t.split(Z$),[s,o]=e.split(Z$),i=U$(r,s);if(i!==void 0)return i||V$(n,o)}var fee=/\/|:/,pee=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function hee(t){return fee.test(t)&&pee.test(t)}var rD=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function mee(t){return rD.lastIndex=0,rD.test(t)}var gee=-(2**31),yee=2**31-1;function _ee(t){return Number.isInteger(t)&&t<=yee&&t>=gee}function vee(t){return Number.isInteger(t)}function nD(){return!0}var wee=/[^\\]\\Z/;function bee(t){if(wee.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var $u=_(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.regexpCode=we.getEsmExportName=we.getProperty=we.safeStringify=we.stringify=we.strConcat=we.addCodeArg=we.str=we._=we.nil=we._Code=we.Name=we.IDENTIFIER=we._CodeOrName=void 0;var bu=class{};we._CodeOrName=bu;we.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var $o=class extends bu{constructor(e){if(super(),!we.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};we.Name=$o;var yr=class extends bu{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof $o&&(r[n.str]=(r[n.str]||0)+1),r),{})}};we._Code=yr;we.nil=new yr("");function lD(t,...e){let r=[t[0]],n=0;for(;n<e.length;)K$(r,e[n]),r.push(t[++n]);return new yr(r)}we._=lD;var B$=new yr("+");function uD(t,...e){let r=[Su(t[0])],n=0;for(;n<e.length;)r.push(B$),K$(r,e[n]),r.push(B$,Su(t[++n]));return See(r),new yr(r)}we.str=uD;function K$(t,e){e instanceof yr?t.push(...e._items):e instanceof $o?t.push(e):t.push(xee(e))}we.addCodeArg=K$;function See(t){let e=1;for(;e<t.length-1;){if(t[e]===B$){let r=$ee(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function $ee(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof $o||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof $o))return`"${t}${e.slice(1)}`}function kee(t,e){return e.emptyStr()?t:t.emptyStr()?e:uD`${t}${e}`}we.strConcat=kee;function xee(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Su(Array.isArray(t)?t.join(","):t)}function Eee(t){return new yr(Su(t))}we.stringify=Eee;function Su(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}we.safeStringify=Su;function Tee(t){return typeof t=="string"&&we.IDENTIFIER.test(t)?new yr(`.${t}`):lD`[${t}]`}we.getProperty=Tee;function Pee(t){if(typeof t=="string"&&we.IDENTIFIER.test(t))return new yr(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}we.getEsmExportName=Pee;function Oee(t){return new yr(t.toString())}we.regexpCode=Oee});var J$=_(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.ValueScope=Bt.ValueScopeName=Bt.Scope=Bt.varKinds=Bt.UsedValueState=void 0;var Vt=$u(),H$=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Jh;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Jh||(Bt.UsedValueState=Jh={}));Bt.varKinds={const:new Vt.Name("const"),let:new Vt.Name("let"),var:new Vt.Name("var")};var Gh=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Vt.Name?e:this.name(e)}name(e){return new Vt.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Bt.Scope=Gh;var Yh=class extends Vt.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Vt._)`.${new Vt.Name(r)}[${n}]`}};Bt.ValueScopeName=Yh;var Iee=(0,Vt._)`\n`,W$=class extends Gh{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Iee:Vt.nil}}get(){return this._scope}name(e){return new Yh(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let s=this.toName(e),{prefix:o}=s,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[o];if(a){let u=a.get(i);if(u)return u}else a=this._values[o]=new Map;a.set(i,s);let c=this._scope[o]||(this._scope[o]=[]),l=c.length;return c[l]=r.ref,s.setValue(r,{property:o,itemIndex:l}),s}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Vt._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,s=>{if(s.value===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return s.value.code},r,n)}_reduceValues(e,r,n={},s){let o=Vt.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(l=>{if(c.has(l))return;c.set(l,Jh.Started);let u=r(l);if(u){let d=this.opts.es5?Bt.varKinds.var:Bt.varKinds.const;o=(0,Vt._)`${o}${d} ${l} = ${u};${this.opts._n}`}else if(u=s?.(l))o=(0,Vt._)`${o}${u}${this.opts._n}`;else throw new H$(l);c.set(l,Jh.Completed)})}return o}};Bt.ValueScope=W$});var Q=_(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.or=ne.and=ne.not=ne.CodeGen=ne.operators=ne.varKinds=ne.ValueScopeName=ne.ValueScope=ne.Scope=ne.Name=ne.regexpCode=ne.stringify=ne.getProperty=ne.nil=ne.strConcat=ne.str=ne._=void 0;var de=$u(),Zr=J$(),Ss=$u();Object.defineProperty(ne,"_",{enumerable:!0,get:function(){return Ss._}});Object.defineProperty(ne,"str",{enumerable:!0,get:function(){return Ss.str}});Object.defineProperty(ne,"strConcat",{enumerable:!0,get:function(){return Ss.strConcat}});Object.defineProperty(ne,"nil",{enumerable:!0,get:function(){return Ss.nil}});Object.defineProperty(ne,"getProperty",{enumerable:!0,get:function(){return Ss.getProperty}});Object.defineProperty(ne,"stringify",{enumerable:!0,get:function(){return Ss.stringify}});Object.defineProperty(ne,"regexpCode",{enumerable:!0,get:function(){return Ss.regexpCode}});Object.defineProperty(ne,"Name",{enumerable:!0,get:function(){return Ss.Name}});var tm=J$();Object.defineProperty(ne,"Scope",{enumerable:!0,get:function(){return tm.Scope}});Object.defineProperty(ne,"ValueScope",{enumerable:!0,get:function(){return tm.ValueScope}});Object.defineProperty(ne,"ValueScopeName",{enumerable:!0,get:function(){return tm.ValueScopeName}});Object.defineProperty(ne,"varKinds",{enumerable:!0,get:function(){return tm.varKinds}});ne.operators={GT:new de._Code(">"),GTE:new de._Code(">="),LT:new de._Code("<"),LTE:new de._Code("<="),EQ:new de._Code("==="),NEQ:new de._Code("!=="),NOT:new de._Code("!"),OR:new de._Code("||"),AND:new de._Code("&&"),ADD:new de._Code("+")};var An=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},G$=class extends An{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Zr.varKinds.var:this.varKind,s=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${s};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=aa(this.rhs,e,r)),this}get names(){return this.rhs instanceof de._CodeOrName?this.rhs.names:{}}},Xh=class extends An{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof de.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=aa(this.rhs,e,r),this}get names(){let e=this.lhs instanceof de.Name?{}:{...this.lhs.names};return em(e,this.rhs)}},Y$=class extends Xh{constructor(e,r,n,s){super(e,n,s),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},X$=class extends An{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Q$=class extends An{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},ek=class extends An{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},tk=class extends An{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=aa(this.code,e,r),this}get names(){return this.code instanceof de._CodeOrName?this.code.names:{}}},ku=class extends An{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,s=n.length;for(;s--;){let o=n[s];o.optimizeNames(e,r)||(Nee(e,o.names),n.splice(s,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Eo(e,r.names),{})}},zn=class extends ku{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},rk=class extends ku{},ia=class extends zn{};ia.kind="else";var ko=class t extends zn{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new ia(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(dD(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=aa(this.condition,e,r),this}get names(){let e=super.names;return em(e,this.condition),this.else&&Eo(e,this.else.names),e}};ko.kind="if";var xo=class extends zn{};xo.kind="for";var nk=class extends xo{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=aa(this.iteration,e,r),this}get names(){return Eo(super.names,this.iteration.names)}},sk=class extends xo{constructor(e,r,n,s){super(),this.varKind=e,this.name=r,this.from=n,this.to=s}render(e){let r=e.es5?Zr.varKinds.var:this.varKind,{name:n,from:s,to:o}=this;return`for(${r} ${n}=${s}; ${n}<${o}; ${n}++)`+super.render(e)}get names(){let e=em(super.names,this.from);return em(e,this.to)}},Qh=class extends xo{constructor(e,r,n,s){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=s}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=aa(this.iterable,e,r),this}get names(){return Eo(super.names,this.iterable.names)}},xu=class extends zn{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};xu.kind="func";var Eu=class extends ku{render(e){return"return "+super.render(e)}};Eu.kind="return";var ok=class extends zn{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,s;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(s=this.finally)===null||s===void 0||s.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Eo(e,this.catch.names),this.finally&&Eo(e,this.finally.names),e}},Tu=class extends zn{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Tu.kind="catch";var Pu=class extends zn{render(e){return"finally"+super.render(e)}};Pu.kind="finally";var ik=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
303
- `:""},this._extScope=e,this._scope=new Zr.Scope({parent:e}),this._nodes=[new rk]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,s){let o=this._scope.toName(r);return n!==void 0&&s&&(this._constants[o.str]=n),this._leafNode(new G$(e,o,n)),o}const(e,r,n){return this._def(Zr.varKinds.const,e,r,n)}let(e,r,n){return this._def(Zr.varKinds.let,e,r,n)}var(e,r,n){return this._def(Zr.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Xh(e,r,n))}add(e,r){return this._leafNode(new Y$(e,ne.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==de.nil&&this._leafNode(new tk(e)),this}object(...e){let r=["{"];for(let[n,s]of e)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0,de.addCodeArg)(r,s));return r.push("}"),new de._Code(r)}if(e,r,n){if(this._blockNode(new ko(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new ko(e))}else(){return this._elseNode(new ia)}endIf(){return this._endBlockNode(ko,ia)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new nk(e),r)}forRange(e,r,n,s,o=this.opts.es5?Zr.varKinds.var:Zr.varKinds.let){let i=this._scope.toName(e);return this._for(new sk(o,i,r,n),()=>s(i))}forOf(e,r,n,s=Zr.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let i=r instanceof de.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,de._)`${i}.length`,a=>{this.var(o,(0,de._)`${i}[${a}]`),n(o)})}return this._for(new Qh("of",s,o,r),()=>n(o))}forIn(e,r,n,s=this.opts.es5?Zr.varKinds.var:Zr.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,de._)`Object.keys(${r})`,n);let o=this._scope.toName(e);return this._for(new Qh("in",s,o,r),()=>n(o))}endFor(){return this._endBlockNode(xo)}label(e){return this._leafNode(new X$(e))}break(e){return this._leafNode(new Q$(e))}return(e){let r=new Eu;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Eu)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let s=new ok;if(this._blockNode(s),this.code(e),r){let o=this.name("e");this._currNode=s.catch=new Tu(o),r(o)}return n&&(this._currNode=s.finally=new Pu,this.code(n)),this._endBlockNode(Tu,Pu)}throw(e){return this._leafNode(new ek(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=de.nil,n,s){return this._blockNode(new xu(e,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(xu)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof ko))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};ne.CodeGen=ik;function Eo(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function em(t,e){return e instanceof de._CodeOrName?Eo(t,e.names):t}function aa(t,e,r){if(t instanceof de.Name)return n(t);if(!s(t))return t;return new de._Code(t._items.reduce((o,i)=>(i instanceof de.Name&&(i=n(i)),i instanceof de._Code?o.push(...i._items):o.push(i),o),[]));function n(o){let i=r[o.str];return i===void 0||e[o.str]!==1?o:(delete e[o.str],i)}function s(o){return o instanceof de._Code&&o._items.some(i=>i instanceof de.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function Nee(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function dD(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,de._)`!${ak(t)}`}ne.not=dD;var Cee=fD(ne.operators.AND);function Ree(...t){return t.reduce(Cee)}ne.and=Ree;var Aee=fD(ne.operators.OR);function zee(...t){return t.reduce(Aee)}ne.or=zee;function fD(t){return(e,r)=>e===de.nil?r:r===de.nil?e:(0,de._)`${ak(e)} ${t} ${ak(r)}`}function ak(t){return t instanceof de.Name?t:(0,de._)`(${t})`}});var ge=_(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.checkStrictMode=ie.getErrorPath=ie.Type=ie.useFunc=ie.setEvaluated=ie.evaluatedPropsToName=ie.mergeEvaluated=ie.eachItem=ie.unescapeJsonPointer=ie.escapeJsonPointer=ie.escapeFragment=ie.unescapeFragment=ie.schemaRefOrVal=ie.schemaHasRulesButRef=ie.schemaHasRules=ie.checkUnknownRules=ie.alwaysValidSchema=ie.toHash=void 0;var Ce=Q(),jee=$u();function Mee(t){let e={};for(let r of t)e[r]=!0;return e}ie.toHash=Mee;function Lee(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(mD(t,e),!gD(e,t.self.RULES.all))}ie.alwaysValidSchema=Lee;function mD(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let s=n.RULES.keywords;for(let o in e)s[o]||vD(t,`unknown keyword: "${o}"`)}ie.checkUnknownRules=mD;function gD(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}ie.schemaHasRules=gD;function Dee(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}ie.schemaHasRulesButRef=Dee;function qee({topSchemaRef:t,schemaPath:e},r,n,s){if(!s){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Ce._)`${r}`}return(0,Ce._)`${t}${e}${(0,Ce.getProperty)(n)}`}ie.schemaRefOrVal=qee;function Fee(t){return yD(decodeURIComponent(t))}ie.unescapeFragment=Fee;function Zee(t){return encodeURIComponent(lk(t))}ie.escapeFragment=Zee;function lk(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}ie.escapeJsonPointer=lk;function yD(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}ie.unescapeJsonPointer=yD;function Uee(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}ie.eachItem=Uee;function pD({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(s,o,i,a)=>{let c=i===void 0?o:i instanceof Ce.Name?(o instanceof Ce.Name?t(s,o,i):e(s,o,i),i):o instanceof Ce.Name?(e(s,i,o),o):r(o,i);return a===Ce.Name&&!(c instanceof Ce.Name)?n(s,c):c}}ie.mergeEvaluated={props:pD({mergeNames:(t,e,r)=>t.if((0,Ce._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,Ce._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,Ce._)`${r} || {}`).code((0,Ce._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,Ce._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,Ce._)`${r} || {}`),uk(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:_D}),items:pD({mergeNames:(t,e,r)=>t.if((0,Ce._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,Ce._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,Ce._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,Ce._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function _D(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,Ce._)`{}`);return e!==void 0&&uk(t,r,e),r}ie.evaluatedPropsToName=_D;function uk(t,e,r){Object.keys(r).forEach(n=>t.assign((0,Ce._)`${e}${(0,Ce.getProperty)(n)}`,!0))}ie.setEvaluated=uk;var hD={};function Vee(t,e){return t.scopeValue("func",{ref:e,code:hD[e.code]||(hD[e.code]=new jee._Code(e.code))})}ie.useFunc=Vee;var ck;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(ck||(ie.Type=ck={}));function Bee(t,e,r){if(t instanceof Ce.Name){let n=e===ck.Num;return r?n?(0,Ce._)`"[" + ${t} + "]"`:(0,Ce._)`"['" + ${t} + "']"`:n?(0,Ce._)`"/" + ${t}`:(0,Ce._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Ce.getProperty)(t).toString():"/"+lk(t)}ie.getErrorPath=Bee;function vD(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}ie.checkStrictMode=vD});var jn=_(dk=>{"use strict";Object.defineProperty(dk,"__esModule",{value:!0});var vt=Q(),Kee={data:new vt.Name("data"),valCxt:new vt.Name("valCxt"),instancePath:new vt.Name("instancePath"),parentData:new vt.Name("parentData"),parentDataProperty:new vt.Name("parentDataProperty"),rootData:new vt.Name("rootData"),dynamicAnchors:new vt.Name("dynamicAnchors"),vErrors:new vt.Name("vErrors"),errors:new vt.Name("errors"),this:new vt.Name("this"),self:new vt.Name("self"),scope:new vt.Name("scope"),json:new vt.Name("json"),jsonPos:new vt.Name("jsonPos"),jsonLen:new vt.Name("jsonLen"),jsonPart:new vt.Name("jsonPart")};dk.default=Kee});var Ou=_(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.extendErrors=wt.resetErrorsCount=wt.reportExtraError=wt.reportError=wt.keyword$DataError=wt.keywordError=void 0;var ye=Q(),rm=ge(),Ot=jn();wt.keywordError={message:({keyword:t})=>(0,ye.str)`must pass "${t}" keyword validation`};wt.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,ye.str)`"${t}" keyword must be ${e} ($data)`:(0,ye.str)`"${t}" keyword is invalid ($data)`};function Hee(t,e=wt.keywordError,r,n){let{it:s}=t,{gen:o,compositeRule:i,allErrors:a}=s,c=SD(t,e,r);n??(i||a)?wD(o,c):bD(s,(0,ye._)`[${c}]`)}wt.reportError=Hee;function Wee(t,e=wt.keywordError,r){let{it:n}=t,{gen:s,compositeRule:o,allErrors:i}=n,a=SD(t,e,r);wD(s,a),o||i||bD(n,Ot.default.vErrors)}wt.reportExtraError=Wee;function Jee(t,e){t.assign(Ot.default.errors,e),t.if((0,ye._)`${Ot.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,ye._)`${Ot.default.vErrors}.length`,e),()=>t.assign(Ot.default.vErrors,null)))}wt.resetErrorsCount=Jee;function Gee({gen:t,keyword:e,schemaValue:r,data:n,errsCount:s,it:o}){if(s===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",s,Ot.default.errors,a=>{t.const(i,(0,ye._)`${Ot.default.vErrors}[${a}]`),t.if((0,ye._)`${i}.instancePath === undefined`,()=>t.assign((0,ye._)`${i}.instancePath`,(0,ye.strConcat)(Ot.default.instancePath,o.errorPath))),t.assign((0,ye._)`${i}.schemaPath`,(0,ye.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,ye._)`${i}.schema`,r),t.assign((0,ye._)`${i}.data`,n))})}wt.extendErrors=Gee;function wD(t,e){let r=t.const("err",e);t.if((0,ye._)`${Ot.default.vErrors} === null`,()=>t.assign(Ot.default.vErrors,(0,ye._)`[${r}]`),(0,ye._)`${Ot.default.vErrors}.push(${r})`),t.code((0,ye._)`${Ot.default.errors}++`)}function bD(t,e){let{gen:r,validateName:n,schemaEnv:s}=t;s.$async?r.throw((0,ye._)`new ${t.ValidationError}(${e})`):(r.assign((0,ye._)`${n}.errors`,e),r.return(!1))}var To={keyword:new ye.Name("keyword"),schemaPath:new ye.Name("schemaPath"),params:new ye.Name("params"),propertyName:new ye.Name("propertyName"),message:new ye.Name("message"),schema:new ye.Name("schema"),parentSchema:new ye.Name("parentSchema")};function SD(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,ye._)`{}`:Yee(t,e,r)}function Yee(t,e,r={}){let{gen:n,it:s}=t,o=[Xee(s,r),Qee(t,r)];return ete(t,e,o),n.object(...o)}function Xee({errorPath:t},{instancePath:e}){let r=e?(0,ye.str)`${t}${(0,rm.getErrorPath)(e,rm.Type.Str)}`:t;return[Ot.default.instancePath,(0,ye.strConcat)(Ot.default.instancePath,r)]}function Qee({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let s=n?e:(0,ye.str)`${e}/${t}`;return r&&(s=(0,ye.str)`${s}${(0,rm.getErrorPath)(r,rm.Type.Str)}`),[To.schemaPath,s]}function ete(t,{params:e,message:r},n){let{keyword:s,data:o,schemaValue:i,it:a}=t,{opts:c,propertyName:l,topSchemaRef:u,schemaPath:d}=a;n.push([To.keyword,s],[To.params,typeof e=="function"?e(t):e||(0,ye._)`{}`]),c.messages&&n.push([To.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([To.schema,i],[To.parentSchema,(0,ye._)`${u}${d}`],[Ot.default.data,o]),l&&n.push([To.propertyName,l])}});var kD=_(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.boolOrEmptySchema=ca.topBoolOrEmptySchema=void 0;var tte=Ou(),rte=Q(),nte=jn(),ste={message:"boolean schema is false"};function ote(t){let{gen:e,schema:r,validateName:n}=t;r===!1?$D(t,!1):typeof r=="object"&&r.$async===!0?e.return(nte.default.data):(e.assign((0,rte._)`${n}.errors`,null),e.return(!0))}ca.topBoolOrEmptySchema=ote;function ite(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),$D(t)):r.var(e,!0)}ca.boolOrEmptySchema=ite;function $D(t,e){let{gen:r,data:n}=t,s={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,tte.reportError)(s,ste,void 0,e)}});var fk=_(la=>{"use strict";Object.defineProperty(la,"__esModule",{value:!0});la.getRules=la.isJSONType=void 0;var ate=["string","number","integer","boolean","null","object","array"],cte=new Set(ate);function lte(t){return typeof t=="string"&&cte.has(t)}la.isJSONType=lte;function ute(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}la.getRules=ute});var pk=_($s=>{"use strict";Object.defineProperty($s,"__esModule",{value:!0});$s.shouldUseRule=$s.shouldUseGroup=$s.schemaHasRulesForType=void 0;function dte({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&xD(t,n)}$s.schemaHasRulesForType=dte;function xD(t,e){return e.rules.some(r=>ED(t,r))}$s.shouldUseGroup=xD;function ED(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}$s.shouldUseRule=ED});var Iu=_(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});bt.reportTypeError=bt.checkDataTypes=bt.checkDataType=bt.coerceAndCheckDataType=bt.getJSONTypes=bt.getSchemaTypes=bt.DataType=void 0;var fte=fk(),pte=pk(),hte=Ou(),X=Q(),TD=ge(),ua;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(ua||(bt.DataType=ua={}));function mte(t){let e=PD(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}bt.getSchemaTypes=mte;function PD(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(fte.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}bt.getJSONTypes=PD;function gte(t,e){let{gen:r,data:n,opts:s}=t,o=yte(e,s.coerceTypes),i=e.length>0&&!(o.length===0&&e.length===1&&(0,pte.schemaHasRulesForType)(t,e[0]));if(i){let a=mk(e,n,s.strictNumbers,ua.Wrong);r.if(a,()=>{o.length?_te(t,e,o):gk(t)})}return i}bt.coerceAndCheckDataType=gte;var OD=new Set(["string","number","integer","boolean","null"]);function yte(t,e){return e?t.filter(r=>OD.has(r)||e==="array"&&r==="array"):[]}function _te(t,e,r){let{gen:n,data:s,opts:o}=t,i=n.let("dataType",(0,X._)`typeof ${s}`),a=n.let("coerced",(0,X._)`undefined`);o.coerceTypes==="array"&&n.if((0,X._)`${i} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>n.assign(s,(0,X._)`${s}[0]`).assign(i,(0,X._)`typeof ${s}`).if(mk(e,s,o.strictNumbers),()=>n.assign(a,s))),n.if((0,X._)`${a} !== undefined`);for(let l of r)(OD.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);n.else(),gk(t),n.endIf(),n.if((0,X._)`${a} !== undefined`,()=>{n.assign(s,a),vte(t,a)});function c(l){switch(l){case"string":n.elseIf((0,X._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,X._)`"" + ${s}`).elseIf((0,X._)`${s} === null`).assign(a,(0,X._)`""`);return;case"number":n.elseIf((0,X._)`${i} == "boolean" || ${s} === null
304
- || (${i} == "string" && ${s} && ${s} == +${s})`).assign(a,(0,X._)`+${s}`);return;case"integer":n.elseIf((0,X._)`${i} === "boolean" || ${s} === null
305
- || (${i} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(a,(0,X._)`+${s}`);return;case"boolean":n.elseIf((0,X._)`${s} === "false" || ${s} === 0 || ${s} === null`).assign(a,!1).elseIf((0,X._)`${s} === "true" || ${s} === 1`).assign(a,!0);return;case"null":n.elseIf((0,X._)`${s} === "" || ${s} === 0 || ${s} === false`),n.assign(a,null);return;case"array":n.elseIf((0,X._)`${i} === "string" || ${i} === "number"
306
- || ${i} === "boolean" || ${s} === null`).assign(a,(0,X._)`[${s}]`)}}}function vte({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,X._)`${e} !== undefined`,()=>t.assign((0,X._)`${e}[${r}]`,n))}function hk(t,e,r,n=ua.Correct){let s=n===ua.Correct?X.operators.EQ:X.operators.NEQ,o;switch(t){case"null":return(0,X._)`${e} ${s} null`;case"array":o=(0,X._)`Array.isArray(${e})`;break;case"object":o=(0,X._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=i((0,X._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=i();break;default:return(0,X._)`typeof ${e} ${s} ${t}`}return n===ua.Correct?o:(0,X.not)(o);function i(a=X.nil){return(0,X.and)((0,X._)`typeof ${e} == "number"`,a,r?(0,X._)`isFinite(${e})`:X.nil)}}bt.checkDataType=hk;function mk(t,e,r,n){if(t.length===1)return hk(t[0],e,r,n);let s,o=(0,TD.toHash)(t);if(o.array&&o.object){let i=(0,X._)`typeof ${e} != "object"`;s=o.null?i:(0,X._)`!${e} || ${i}`,delete o.null,delete o.array,delete o.object}else s=X.nil;o.number&&delete o.integer;for(let i in o)s=(0,X.and)(s,hk(i,e,r,n));return s}bt.checkDataTypes=mk;var wte={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,X._)`{type: ${t}}`:(0,X._)`{type: ${e}}`};function gk(t){let e=bte(t);(0,hte.reportError)(e,wte)}bt.reportTypeError=gk;function bte(t){let{gen:e,data:r,schema:n}=t,s=(0,TD.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:t}}});var ND=_(nm=>{"use strict";Object.defineProperty(nm,"__esModule",{value:!0});nm.assignDefaults=void 0;var da=Q(),Ste=ge();function $te(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let s in r)ID(t,s,r[s].default);else e==="array"&&Array.isArray(n)&&n.forEach((s,o)=>ID(t,o,s.default))}nm.assignDefaults=$te;function ID(t,e,r){let{gen:n,compositeRule:s,data:o,opts:i}=t;if(r===void 0)return;let a=(0,da._)`${o}${(0,da.getProperty)(e)}`;if(s){(0,Ste.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,da._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,da._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,da._)`${a} = ${(0,da.stringify)(r)}`)}});var _r=_(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.validateUnion=Te.validateArray=Te.usePattern=Te.callValidateCode=Te.schemaProperties=Te.allSchemaProperties=Te.noPropertyInData=Te.propertyInData=Te.isOwnProperty=Te.hasPropFunc=Te.reportMissingProp=Te.checkMissingProp=Te.checkReportMissingProp=void 0;var qe=Q(),yk=ge(),ks=jn(),kte=ge();function xte(t,e){let{gen:r,data:n,it:s}=t;r.if(vk(r,n,e,s.opts.ownProperties),()=>{t.setParams({missingProperty:(0,qe._)`${e}`},!0),t.error()})}Te.checkReportMissingProp=xte;function Ete({gen:t,data:e,it:{opts:r}},n,s){return(0,qe.or)(...n.map(o=>(0,qe.and)(vk(t,e,o,r.ownProperties),(0,qe._)`${s} = ${o}`)))}Te.checkMissingProp=Ete;function Tte(t,e){t.setParams({missingProperty:e},!0),t.error()}Te.reportMissingProp=Tte;function CD(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,qe._)`Object.prototype.hasOwnProperty`})}Te.hasPropFunc=CD;function _k(t,e,r){return(0,qe._)`${CD(t)}.call(${e}, ${r})`}Te.isOwnProperty=_k;function Pte(t,e,r,n){let s=(0,qe._)`${e}${(0,qe.getProperty)(r)} !== undefined`;return n?(0,qe._)`${s} && ${_k(t,e,r)}`:s}Te.propertyInData=Pte;function vk(t,e,r,n){let s=(0,qe._)`${e}${(0,qe.getProperty)(r)} === undefined`;return n?(0,qe.or)(s,(0,qe.not)(_k(t,e,r))):s}Te.noPropertyInData=vk;function RD(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}Te.allSchemaProperties=RD;function Ote(t,e){return RD(e).filter(r=>!(0,yk.alwaysValidSchema)(t,e[r]))}Te.schemaProperties=Ote;function Ite({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:s,errorPath:o},it:i},a,c,l){let u=l?(0,qe._)`${t}, ${e}, ${n}${s}`:e,d=[[ks.default.instancePath,(0,qe.strConcat)(ks.default.instancePath,o)],[ks.default.parentData,i.parentData],[ks.default.parentDataProperty,i.parentDataProperty],[ks.default.rootData,ks.default.rootData]];i.opts.dynamicRef&&d.push([ks.default.dynamicAnchors,ks.default.dynamicAnchors]);let f=(0,qe._)`${u}, ${r.object(...d)}`;return c!==qe.nil?(0,qe._)`${a}.call(${c}, ${f})`:(0,qe._)`${a}(${f})`}Te.callValidateCode=Ite;var Nte=(0,qe._)`new RegExp`;function Cte({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:s}=e.code,o=s(r,n);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,qe._)`${s.code==="new RegExp"?Nte:(0,kte.useFunc)(t,s)}(${r}, ${n})`})}Te.usePattern=Cte;function Rte(t){let{gen:e,data:r,keyword:n,it:s}=t,o=e.name("valid");if(s.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(o,!0),i(()=>e.break()),o;function i(a){let c=e.const("len",(0,qe._)`${r}.length`);e.forRange("i",0,c,l=>{t.subschema({keyword:n,dataProp:l,dataPropType:yk.Type.Num},o),e.if((0,qe.not)(o),a)})}}Te.validateArray=Rte;function Ate(t){let{gen:e,schema:r,keyword:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,yk.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,l)=>{let u=t.subschema({keyword:n,schemaProp:l,compositeRule:!0},a);e.assign(i,(0,qe._)`${i} || ${a}`),t.mergeValidEvaluated(u,a)||e.if((0,qe.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}Te.validateUnion=Ate});var jD=_(un=>{"use strict";Object.defineProperty(un,"__esModule",{value:!0});un.validateKeywordUsage=un.validSchemaType=un.funcKeywordCode=un.macroKeywordCode=void 0;var It=Q(),Po=jn(),zte=_r(),jte=Ou();function Mte(t,e){let{gen:r,keyword:n,schema:s,parentSchema:o,it:i}=t,a=e.macro.call(i.self,s,o,i),c=zD(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let l=r.name("valid");t.subschema({schema:a,schemaPath:It.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),t.pass(l,()=>t.error(!0))}un.macroKeywordCode=Mte;function Lte(t,e){var r;let{gen:n,keyword:s,schema:o,parentSchema:i,$data:a,it:c}=t;qte(c,e);let l=!a&&e.compile?e.compile.call(c.self,o,i,c):e.validate,u=zD(n,s,l),d=n.let("valid");t.block$data(d,f),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function f(){if(e.errors===!1)h(),e.modifying&&AD(t),g(()=>t.error());else{let y=e.async?p():m();e.modifying&&AD(t),g(()=>Dte(t,y))}}function p(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,It._)`await `),w=>n.assign(d,!1).if((0,It._)`${w} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,It._)`${w}.errors`),()=>n.throw(w))),y}function m(){let y=(0,It._)`${u}.errors`;return n.assign(y,null),h(It.nil),y}function h(y=e.async?(0,It._)`await `:It.nil){let w=c.opts.passContext?Po.default.this:Po.default.self,b=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,It._)`${y}${(0,zte.callValidateCode)(t,u,w,b)}`,e.modifying)}function g(y){var w;n.if((0,It.not)((w=e.valid)!==null&&w!==void 0?w:d),y)}}un.funcKeywordCode=Lte;function AD(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,It._)`${n.parentData}[${n.parentDataProperty}]`))}function Dte(t,e){let{gen:r}=t;r.if((0,It._)`Array.isArray(${e})`,()=>{r.assign(Po.default.vErrors,(0,It._)`${Po.default.vErrors} === null ? ${e} : ${Po.default.vErrors}.concat(${e})`).assign(Po.default.errors,(0,It._)`${Po.default.vErrors}.length`),(0,jte.extendErrors)(t)},()=>t.error())}function qte({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function zD(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,It.stringify)(r)})}function Fte(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}un.validSchemaType=Fte;function Zte({schema:t,opts:e,self:r,errSchemaPath:n},s,o){if(Array.isArray(s.keyword)?!s.keyword.includes(o):s.keyword!==o)throw new Error("ajv implementation error");let i=s.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${i.join(",")}`);if(s.validateSchema&&!s.validateSchema(t[o])){let c=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}un.validateKeywordUsage=Zte});var LD=_(xs=>{"use strict";Object.defineProperty(xs,"__esModule",{value:!0});xs.extendSubschemaMode=xs.extendSubschemaData=xs.getSubschema=void 0;var dn=Q(),MD=ge();function Ute(t,{keyword:e,schemaProp:r,schema:n,schemaPath:s,errSchemaPath:o,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,dn._)`${t.schemaPath}${(0,dn.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,dn._)`${t.schemaPath}${(0,dn.getProperty)(e)}${(0,dn.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,MD.escapeFragment)(r)}`}}if(n!==void 0){if(s===void 0||o===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:i,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}xs.getSubschema=Ute;function Vte(t,e,{dataProp:r,dataPropType:n,data:s,dataTypes:o,propertyName:i}){if(s!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:l,dataPathArr:u,opts:d}=e,f=a.let("data",(0,dn._)`${e.data}${(0,dn.getProperty)(r)}`,!0);c(f),t.errorPath=(0,dn.str)`${l}${(0,MD.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,dn._)`${r}`,t.dataPathArr=[...u,t.parentDataProperty]}if(s!==void 0){let l=s instanceof dn.Name?s:a.let("data",s,!0);c(l),i!==void 0&&(t.propertyName=i)}o&&(t.dataTypes=o);function c(l){t.data=l,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,l]}}xs.extendSubschemaData=Vte;function Bte(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:o}){n!==void 0&&(t.compositeRule=n),s!==void 0&&(t.createErrors=s),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}xs.extendSubschemaMode=Bte});var qD=_((Twe,DD)=>{"use strict";var Es=DD.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},s=r.post||function(){};sm(e,n,s,t,"",t)};Es.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Es.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Es.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Es.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function sm(t,e,r,n,s,o,i,a,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,s,o,i,a,c,l);for(var u in n){var d=n[u];if(Array.isArray(d)){if(u in Es.arrayKeywords)for(var f=0;f<d.length;f++)sm(t,e,r,d[f],s+"/"+u+"/"+f,o,s,u,n,f)}else if(u in Es.propsKeywords){if(d&&typeof d=="object")for(var p in d)sm(t,e,r,d[p],s+"/"+u+"/"+Kte(p),o,s,u,n,p)}else(u in Es.keywords||t.allKeys&&!(u in Es.skipKeywords))&&sm(t,e,r,d,s+"/"+u,o,s,u,n)}r(n,s,o,i,a,c,l)}}function Kte(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Nu=_(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.getSchemaRefs=Kt.resolveUrl=Kt.normalizeId=Kt._getFullPath=Kt.getFullPath=Kt.inlineRef=void 0;var Hte=ge(),Wte=ru(),Jte=qD(),Gte=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Yte(t,e=!0){return typeof t=="boolean"?!0:e===!0?!wk(t):e?FD(t)<=e:!1}Kt.inlineRef=Yte;var Xte=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function wk(t){for(let e in t){if(Xte.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(wk)||typeof r=="object"&&wk(r))return!0}return!1}function FD(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!Gte.has(r)&&(typeof t[r]=="object"&&(0,Hte.eachItem)(t[r],n=>e+=FD(n)),e===1/0))return 1/0}return e}function ZD(t,e="",r){r!==!1&&(e=fa(e));let n=t.parse(e);return UD(t,n)}Kt.getFullPath=ZD;function UD(t,e){return t.serialize(e).split("#")[0]+"#"}Kt._getFullPath=UD;var Qte=/#\/?$/;function fa(t){return t?t.replace(Qte,""):""}Kt.normalizeId=fa;function ere(t,e,r){return r=fa(r),t.resolve(e,r)}Kt.resolveUrl=ere;var tre=/^[a-z_][-a-z0-9._]*$/i;function rre(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,s=fa(t[r]||e),o={"":s},i=ZD(n,s,!1),a={},c=new Set;return Jte(t,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=i+f,g=o[m];typeof d[r]=="string"&&(g=y.call(this,d[r])),w.call(this,d.$anchor),w.call(this,d.$dynamicAnchor),o[f]=g;function y(b){let x=this.opts.uriResolver.resolve;if(b=fa(g?x(g,b):b),c.has(b))throw u(b);c.add(b);let v=this.refs[b];return typeof v=="string"&&(v=this.refs[v]),typeof v=="object"?l(d,v.schema,b):b!==fa(h)&&(b[0]==="#"?(l(d,a[b],b),a[b]=d):this.refs[b]=h),b}function w(b){if(typeof b=="string"){if(!tre.test(b))throw new Error(`invalid anchor "${b}"`);y.call(this,`#${b}`)}}}),a;function l(d,f,p){if(f!==void 0&&!Wte(d,f))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Kt.getSchemaRefs=rre});var Au=_(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});Ts.getData=Ts.KeywordCxt=Ts.validateFunctionCode=void 0;var WD=kD(),VD=Iu(),Sk=pk(),om=Iu(),nre=ND(),Ru=jD(),bk=LD(),q=Q(),W=jn(),sre=Nu(),Mn=ge(),Cu=Ou();function ore(t){if(YD(t)&&(XD(t),GD(t))){cre(t);return}JD(t,()=>(0,WD.topBoolOrEmptySchema)(t))}Ts.validateFunctionCode=ore;function JD({gen:t,validateName:e,schema:r,schemaEnv:n,opts:s},o){s.code.es5?t.func(e,(0,q._)`${W.default.data}, ${W.default.valCxt}`,n.$async,()=>{t.code((0,q._)`"use strict"; ${BD(r,s)}`),are(t,s),t.code(o)}):t.func(e,(0,q._)`${W.default.data}, ${ire(s)}`,n.$async,()=>t.code(BD(r,s)).code(o))}function ire(t){return(0,q._)`{${W.default.instancePath}="", ${W.default.parentData}, ${W.default.parentDataProperty}, ${W.default.rootData}=${W.default.data}${t.dynamicRef?(0,q._)`, ${W.default.dynamicAnchors}={}`:q.nil}}={}`}function are(t,e){t.if(W.default.valCxt,()=>{t.var(W.default.instancePath,(0,q._)`${W.default.valCxt}.${W.default.instancePath}`),t.var(W.default.parentData,(0,q._)`${W.default.valCxt}.${W.default.parentData}`),t.var(W.default.parentDataProperty,(0,q._)`${W.default.valCxt}.${W.default.parentDataProperty}`),t.var(W.default.rootData,(0,q._)`${W.default.valCxt}.${W.default.rootData}`),e.dynamicRef&&t.var(W.default.dynamicAnchors,(0,q._)`${W.default.valCxt}.${W.default.dynamicAnchors}`)},()=>{t.var(W.default.instancePath,(0,q._)`""`),t.var(W.default.parentData,(0,q._)`undefined`),t.var(W.default.parentDataProperty,(0,q._)`undefined`),t.var(W.default.rootData,W.default.data),e.dynamicRef&&t.var(W.default.dynamicAnchors,(0,q._)`{}`)})}function cre(t){let{schema:e,opts:r,gen:n}=t;JD(t,()=>{r.$comment&&e.$comment&&eq(t),pre(t),n.let(W.default.vErrors,null),n.let(W.default.errors,0),r.unevaluated&&lre(t),QD(t),gre(t)})}function lre(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,q._)`${r}.evaluated`),e.if((0,q._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,q._)`${t.evaluated}.props`,(0,q._)`undefined`)),e.if((0,q._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,q._)`${t.evaluated}.items`,(0,q._)`undefined`))}function BD(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,q._)`/*# sourceURL=${r} */`:q.nil}function ure(t,e){if(YD(t)&&(XD(t),GD(t))){dre(t,e);return}(0,WD.boolOrEmptySchema)(t,e)}function GD({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function YD(t){return typeof t.schema!="boolean"}function dre(t,e){let{schema:r,gen:n,opts:s}=t;s.$comment&&r.$comment&&eq(t),hre(t),mre(t);let o=n.const("_errs",W.default.errors);QD(t,o),n.var(e,(0,q._)`${o} === ${W.default.errors}`)}function XD(t){(0,Mn.checkUnknownRules)(t),fre(t)}function QD(t,e){if(t.opts.jtd)return KD(t,[],!1,e);let r=(0,VD.getSchemaTypes)(t.schema),n=(0,VD.coerceAndCheckDataType)(t,r);KD(t,r,!n,e)}function fre(t){let{schema:e,errSchemaPath:r,opts:n,self:s}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Mn.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function pre(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Mn.checkStrictMode)(t,"default is ignored in the schema root")}function hre(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,sre.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function mre(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function eq({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:s}){let o=r.$comment;if(s.$comment===!0)t.code((0,q._)`${W.default.self}.logger.log(${o})`);else if(typeof s.$comment=="function"){let i=(0,q.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,q._)`${W.default.self}.opts.$comment(${o}, ${i}, ${a}.schema)`)}}function gre(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:s,opts:o}=t;r.$async?e.if((0,q._)`${W.default.errors} === 0`,()=>e.return(W.default.data),()=>e.throw((0,q._)`new ${s}(${W.default.vErrors})`)):(e.assign((0,q._)`${n}.errors`,W.default.vErrors),o.unevaluated&&yre(t),e.return((0,q._)`${W.default.errors} === 0`))}function yre({gen:t,evaluated:e,props:r,items:n}){r instanceof q.Name&&t.assign((0,q._)`${e}.props`,r),n instanceof q.Name&&t.assign((0,q._)`${e}.items`,n)}function KD(t,e,r,n){let{gen:s,schema:o,data:i,allErrors:a,opts:c,self:l}=t,{RULES:u}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,Mn.schemaHasRulesButRef)(o,u))){s.block(()=>rq(t,"$ref",u.all.$ref.definition));return}c.jtd||_re(t,e),s.block(()=>{for(let f of u.rules)d(f);d(u.post)});function d(f){(0,Sk.shouldUseGroup)(o,f)&&(f.type?(s.if((0,om.checkDataType)(f.type,i,c.strictNumbers)),HD(t,f),e.length===1&&e[0]===f.type&&r&&(s.else(),(0,om.reportTypeError)(t)),s.endIf()):HD(t,f),a||s.if((0,q._)`${W.default.errors} === ${n||0}`))}}function HD(t,e){let{gen:r,schema:n,opts:{useDefaults:s}}=t;s&&(0,nre.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,Sk.shouldUseRule)(n,o)&&rq(t,o.keyword,o.definition,e.type)})}function _re(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(vre(t,e),t.opts.allowUnionTypes||wre(t,e),bre(t,t.dataTypes))}function vre(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{tq(t.dataTypes,r)||$k(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),$re(t,e)}}function wre(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&$k(t,"use allowUnionTypes to allow union type keyword")}function bre(t,e){let r=t.self.RULES.all;for(let n in r){let s=r[n];if(typeof s=="object"&&(0,Sk.shouldUseRule)(t.schema,s)){let{type:o}=s.definition;o.length&&!o.some(i=>Sre(e,i))&&$k(t,`missing type "${o.join(",")}" for keyword "${n}"`)}}}function Sre(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function tq(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function $re(t,e){let r=[];for(let n of t.dataTypes)tq(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function $k(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Mn.checkStrictMode)(t,e,t.opts.strictTypes)}var im=class{constructor(e,r,n){if((0,Ru.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Mn.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",nq(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Ru.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",W.default.errors))}result(e,r,n){this.failResult((0,q.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,q.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,q._)`${r} !== undefined && (${(0,q.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?Cu.reportExtraError:Cu.reportError)(this,this.def.error,r)}$dataError(){(0,Cu.reportError)(this,this.def.$dataError||Cu.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Cu.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=q.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=q.nil,r=q.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:o,def:i}=this;n.if((0,q.or)((0,q._)`${s} === undefined`,r)),e!==q.nil&&n.assign(e,!0),(o.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==q.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:s,it:o}=this;return(0,q.or)(i(),a());function i(){if(n.length){if(!(r instanceof q.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,q._)`${(0,om.checkDataTypes)(c,r,o.opts.strictNumbers,om.DataType.Wrong)}`}return q.nil}function a(){if(s.validateSchema){let c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,q._)`!${c}(${r})`}return q.nil}}subschema(e,r){let n=(0,bk.getSubschema)(this.it,e);(0,bk.extendSubschemaData)(n,this.it,e),(0,bk.extendSubschemaMode)(n,e);let s={...this.it,...n,items:void 0,props:void 0};return ure(s,r),s}mergeEvaluated(e,r){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Mn.mergeEvaluated.props(s,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Mn.mergeEvaluated.items(s,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(r,()=>this.mergeEvaluated(e,q.Name)),!0}};Ts.KeywordCxt=im;function rq(t,e,r,n){let s=new im(t,r,e);"code"in r?r.code(s,n):s.$data&&r.validate?(0,Ru.funcKeywordCode)(s,r):"macro"in r?(0,Ru.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,Ru.funcKeywordCode)(s,r)}var kre=/^\/(?:[^~]|~0|~1)*$/,xre=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function nq(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let s,o;if(t==="")return W.default.rootData;if(t[0]==="/"){if(!kre.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);s=t,o=W.default.rootData}else{let l=xre.exec(t);if(!l)throw new Error(`Invalid JSON-pointer: ${t}`);let u=+l[1];if(s=l[2],s==="#"){if(u>=e)throw new Error(c("property/index",u));return n[e-u]}if(u>e)throw new Error(c("data",u));if(o=r[e-u],!s)return o}let i=o,a=s.split("/");for(let l of a)l&&(o=(0,q._)`${o}${(0,q.getProperty)((0,Mn.unescapeJsonPointer)(l))}`,i=(0,q._)`${i} && ${o}`);return i;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${e}`}}Ts.getData=nq});var am=_(xk=>{"use strict";Object.defineProperty(xk,"__esModule",{value:!0});var kk=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};xk.default=kk});var zu=_(Pk=>{"use strict";Object.defineProperty(Pk,"__esModule",{value:!0});var Ek=Nu(),Tk=class extends Error{constructor(e,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Ek.resolveUrl)(e,r,n),this.missingSchema=(0,Ek.normalizeId)((0,Ek.getFullPath)(e,this.missingRef))}};Pk.default=Tk});var lm=_(vr=>{"use strict";Object.defineProperty(vr,"__esModule",{value:!0});vr.resolveSchema=vr.getCompilingSchema=vr.resolveRef=vr.compileSchema=vr.SchemaEnv=void 0;var Ur=Q(),Ere=am(),Oo=jn(),Vr=Nu(),sq=ge(),Tre=Au(),pa=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,Vr.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};vr.SchemaEnv=pa;function Ik(t){let e=oq.call(this,t);if(e)return e;let r=(0,Vr.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:o}=this.opts,i=new Ur.CodeGen(this.scope,{es5:n,lines:s,ownProperties:o}),a;t.$async&&(a=i.scopeValue("Error",{ref:Ere.default,code:(0,Ur._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let l={gen:i,allErrors:this.opts.allErrors,data:Oo.default.data,parentData:Oo.default.parentData,parentDataProperty:Oo.default.parentDataProperty,dataNames:[Oo.default.data],dataPathArr:[Ur.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Ur.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Ur.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Ur._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(t),(0,Tre.validateFunctionCode)(l),i.optimize(this.opts.code.optimize);let d=i.toString();u=`${i.scopeRefs(Oo.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,t));let p=new Function(`${Oo.default.self}`,`${Oo.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=t.schema,p.schemaEnv=t,t.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:h}=l;p.evaluated={props:m instanceof Ur.Name?void 0:m,items:h instanceof Ur.Name?void 0:h,dynamicProps:m instanceof Ur.Name,dynamicItems:h instanceof Ur.Name},p.source&&(p.source.evaluated=(0,Ur.stringify)(p.evaluated))}return t.validate=p,t}catch(d){throw delete t.validate,delete t.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(t)}}vr.compileSchema=Ik;function Pre(t,e,r){var n;r=(0,Vr.resolveUrl)(this.opts.uriResolver,e,r);let s=t.refs[r];if(s)return s;let o=Nre.call(this,t,r);if(o===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(o=new pa({schema:i,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=Ore.call(this,o)}vr.resolveRef=Pre;function Ore(t){return(0,Vr.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Ik.call(this,t)}function oq(t){for(let e of this._compilations)if(Ire(e,t))return e}vr.getCompilingSchema=oq;function Ire(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Nre(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||cm.call(this,t,e)}function cm(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Vr._getFullPath)(this.opts.uriResolver,r),s=(0,Vr.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===s)return Ok.call(this,r,t);let o=(0,Vr.normalizeId)(n),i=this.refs[o]||this.schemas[o];if(typeof i=="string"){let a=cm.call(this,t,i);return typeof a?.schema!="object"?void 0:Ok.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Ik.call(this,i),o===(0,Vr.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,l=a[c];return l&&(s=(0,Vr.resolveUrl)(this.opts.uriResolver,s,l)),new pa({schema:a,schemaId:c,root:t,baseId:s})}return Ok.call(this,r,i)}}vr.resolveSchema=cm;var Cre=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ok(t,{baseId:e,schema:r,root:n}){var s;if(((s=t.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,sq.unescapeFragment)(a)];if(c===void 0)return;r=c;let l=typeof r=="object"&&r[this.opts.schemaId];!Cre.has(a)&&l&&(e=(0,Vr.resolveUrl)(this.opts.uriResolver,e,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,sq.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Vr.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=cm.call(this,n,a)}let{schemaId:i}=this.opts;if(o=o||new pa({schema:r,schemaId:i,root:n,baseId:e}),o.schema!==o.root.schema)return o}});var iq=_((Rwe,Rre)=>{Rre.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var cq=_(Nk=>{"use strict";Object.defineProperty(Nk,"__esModule",{value:!0});var aq=HS();aq.code='require("ajv/dist/runtime/uri").default';Nk.default=aq});var gq=_(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.CodeGen=pt.Name=pt.nil=pt.stringify=pt.str=pt._=pt.KeywordCxt=void 0;var Are=Au();Object.defineProperty(pt,"KeywordCxt",{enumerable:!0,get:function(){return Are.KeywordCxt}});var ha=Q();Object.defineProperty(pt,"_",{enumerable:!0,get:function(){return ha._}});Object.defineProperty(pt,"str",{enumerable:!0,get:function(){return ha.str}});Object.defineProperty(pt,"stringify",{enumerable:!0,get:function(){return ha.stringify}});Object.defineProperty(pt,"nil",{enumerable:!0,get:function(){return ha.nil}});Object.defineProperty(pt,"Name",{enumerable:!0,get:function(){return ha.Name}});Object.defineProperty(pt,"CodeGen",{enumerable:!0,get:function(){return ha.CodeGen}});var zre=am(),pq=zu(),jre=fk(),ju=lm(),Mre=Q(),Mu=Nu(),um=Iu(),Rk=ge(),lq=iq(),Lre=cq(),hq=(t,e)=>new RegExp(t,e);hq.code="new RegExp";var Dre=["removeAdditional","useDefaults","coerceTypes"],qre=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Fre={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},Zre={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},uq=200;function Ure(t){var e,r,n,s,o,i,a,c,l,u,d,f,p,m,h,g,y,w,b,x,v,S,T,P,A;let Z=t.strict,ee=(e=t.code)===null||e===void 0?void 0:e.optimize,J=ee===!0||ee===void 0?1:ee||0,fe=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:hq,Re=(s=t.uriResolver)!==null&&s!==void 0?s:Lre.default;return{strictSchema:(i=(o=t.strictSchema)!==null&&o!==void 0?o:Z)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:Z)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=t.strictTypes)!==null&&l!==void 0?l:Z)!==null&&u!==void 0?u:"log",strictTuples:(f=(d=t.strictTuples)!==null&&d!==void 0?d:Z)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=t.strictRequired)!==null&&p!==void 0?p:Z)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:J,regExp:fe}:{optimize:J,regExp:fe},loopRequired:(h=t.loopRequired)!==null&&h!==void 0?h:uq,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:uq,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(w=t.messages)!==null&&w!==void 0?w:!0,inlineRefs:(b=t.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(x=t.schemaId)!==null&&x!==void 0?x:"$id",addUsedSchema:(v=t.addUsedSchema)!==null&&v!==void 0?v:!0,validateSchema:(S=t.validateSchema)!==null&&S!==void 0?S:!0,validateFormats:(T=t.validateFormats)!==null&&T!==void 0?T:!0,unicodeRegExp:(P=t.unicodeRegExp)!==null&&P!==void 0?P:!0,int32range:(A=t.int32range)!==null&&A!==void 0?A:!0,uriResolver:Re}}var Lu=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...Ure(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new Mre.ValueScope({scope:{},prefixes:qre,es5:r,lines:n}),this.logger=Jre(e.logger);let s=e.validateFormats;e.validateFormats=!1,this.RULES=(0,jre.getRules)(),dq.call(this,Fre,e,"NOT SUPPORTED"),dq.call(this,Zre,e,"DEPRECATED","warn"),this._metaOpts=Hre.call(this),e.formats&&Bre.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&Kre.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),Vre.call(this),e.validateFormats=s}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,s=lq;n==="id"&&(s={...lq},s.id=s.$id,delete s.$id),r&&e&&this.addMetaSchema(s,s[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let s=n(r);return"$async"in n||(this.errors=n.errors),s}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,e,r);async function s(u,d){await o.call(this,u.$schema);let f=this._addSchema(u,d);return f.validate||i.call(this,f)}async function o(u){u&&!this.getSchema(u)&&await s.call(this,{$ref:u},!0)}async function i(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof pq.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,u)}}function a({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function c(u){let d=await l.call(this,u);this.refs[u]||await o.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,r)}async function l(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=n(u))}finally{delete this._loading[u]}}}addSchema(e,r,n,s=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,s);return this}let o;if(typeof e=="object"){let{schemaId:i}=this.opts;if(o=e[i],o!==void 0&&typeof o!="string")throw new Error(`schema ${i} must be string`)}return r=(0,Mu.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,s,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let s=this.validate(n,e);if(!s&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return s}getSchema(e){let r;for(;typeof(r=fq.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,s=new ju.SchemaEnv({schema:{},schemaId:n});if(r=ju.resolveSchema.call(this,s,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=fq.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,Mu.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Yre.call(this,n,r),!r)return(0,Rk.eachItem)(n,o=>Ck.call(this,o)),this;Qre.call(this,r);let s={...r,type:(0,um.getJSONTypes)(r.type),schemaType:(0,um.getJSONTypes)(r.schemaType)};return(0,Rk.eachItem)(n,s.type.length===0?o=>Ck.call(this,o,s):o=>s.type.forEach(i=>Ck.call(this,o,s,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let s=n.rules.findIndex(o=>o.keyword===e);s>=0&&n.rules.splice(s,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,o)=>s+r+o)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let s of r){let o=s.split("/").slice(1),i=e;for(let a of o)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:l}=c.definition,u=i[a];l&&u&&(i[a]=mq(u))}}return e}_removeAllSchemas(e,r){for(let n in e){let s=e[n];(!r||r.test(n))&&(typeof s=="string"?delete e[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete e[n]))}}_addSchema(e,r,n,s=this.opts.validateSchema,o=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,Mu.normalizeId)(i||n);let l=Mu.getSchemaRefs.call(this,e,n);return c=new ju.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:l}),this._cache.set(c.schema,c),o&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),s&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):ju.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{ju.compileSchema.call(this,e)}finally{this.opts=r}}};Lu.ValidationError=zre.default;Lu.MissingRefError=pq.default;pt.default=Lu;function dq(t,e,r,n="error"){for(let s in t){let o=s;o in e&&this.logger[n](`${r}: option ${s}. ${t[o]}`)}}function fq(t){return t=(0,Mu.normalizeId)(t),this.schemas[t]||this.refs[t]}function Vre(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function Bre(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function Kre(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function Hre(){let t={...this.opts};for(let e of Dre)delete t[e];return t}var Wre={log(){},warn(){},error(){}};function Jre(t){if(t===!1)return Wre;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var Gre=/^[a-z_$][a-z0-9_$:-]*$/i;function Yre(t,e){let{RULES:r}=this;if((0,Rk.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Gre.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function Ck(t,e,r){var n;let s=e?.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,i=s?o.post:o.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},o.rules.push(i)),o.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,um.getJSONTypes)(e.type),schemaType:(0,um.getJSONTypes)(e.schemaType)}};e.before?Xre.call(this,i,a,e.before):i.rules.push(a),o.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function Xre(t,e,r){let n=t.rules.findIndex(s=>s.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function Qre(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=mq(e)),t.validateSchema=this.compile(e,!0))}var ene={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function mq(t){return{anyOf:[t,ene]}}});var yq=_(Ak=>{"use strict";Object.defineProperty(Ak,"__esModule",{value:!0});var tne={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ak.default=tne});var bq=_(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});Io.callRef=Io.getValidate=void 0;var rne=zu(),_q=_r(),Ht=Q(),ma=jn(),vq=lm(),dm=ge(),nne={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:s,schemaEnv:o,validateName:i,opts:a,self:c}=n,{root:l}=o;if((r==="#"||r==="#/")&&s===l.baseId)return d();let u=vq.resolveRef.call(c,l,s,r);if(u===void 0)throw new rne.default(n.opts.uriResolver,s,r);if(u instanceof vq.SchemaEnv)return f(u);return p(u);function d(){if(o===l)return fm(t,i,o,o.$async);let m=e.scopeValue("root",{ref:l});return fm(t,(0,Ht._)`${m}.validate`,l,l.$async)}function f(m){let h=wq(t,m);fm(t,h,m,m.$async)}function p(m){let h=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Ht.stringify)(m)}:{ref:m}),g=e.name("valid"),y=t.subschema({schema:m,dataTypes:[],schemaPath:Ht.nil,topSchemaRef:h,errSchemaPath:r},g);t.mergeEvaluated(y),t.ok(g)}}};function wq(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Ht._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Io.getValidate=wq;function fm(t,e,r,n){let{gen:s,it:o}=t,{allErrors:i,schemaEnv:a,opts:c}=o,l=c.passContext?ma.default.this:Ht.nil;n?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=s.let("valid");s.try(()=>{s.code((0,Ht._)`await ${(0,_q.callValidateCode)(t,e,l)}`),p(e),i||s.assign(m,!0)},h=>{s.if((0,Ht._)`!(${h} instanceof ${o.ValidationError})`,()=>s.throw(h)),f(h),i||s.assign(m,!1)}),t.ok(m)}function d(){t.result((0,_q.callValidateCode)(t,e,l),()=>p(e),()=>f(e))}function f(m){let h=(0,Ht._)`${m}.errors`;s.assign(ma.default.vErrors,(0,Ht._)`${ma.default.vErrors} === null ? ${h} : ${ma.default.vErrors}.concat(${h})`),s.assign(ma.default.errors,(0,Ht._)`${ma.default.vErrors}.length`)}function p(m){var h;if(!o.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=dm.mergeEvaluated.props(s,g.props,o.props));else{let y=s.var("props",(0,Ht._)`${m}.evaluated.props`);o.props=dm.mergeEvaluated.props(s,y,o.props,Ht.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=dm.mergeEvaluated.items(s,g.items,o.items));else{let y=s.var("items",(0,Ht._)`${m}.evaluated.items`);o.items=dm.mergeEvaluated.items(s,y,o.items,Ht.Name)}}}Io.callRef=fm;Io.default=nne});var Sq=_(zk=>{"use strict";Object.defineProperty(zk,"__esModule",{value:!0});var sne=yq(),one=bq(),ine=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",sne.default,one.default];zk.default=ine});var $q=_(jk=>{"use strict";Object.defineProperty(jk,"__esModule",{value:!0});var pm=Q(),Ps=pm.operators,hm={maximum:{okStr:"<=",ok:Ps.LTE,fail:Ps.GT},minimum:{okStr:">=",ok:Ps.GTE,fail:Ps.LT},exclusiveMaximum:{okStr:"<",ok:Ps.LT,fail:Ps.GTE},exclusiveMinimum:{okStr:">",ok:Ps.GT,fail:Ps.LTE}},ane={message:({keyword:t,schemaCode:e})=>(0,pm.str)`must be ${hm[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,pm._)`{comparison: ${hm[t].okStr}, limit: ${e}}`},cne={keyword:Object.keys(hm),type:"number",schemaType:"number",$data:!0,error:ane,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,pm._)`${r} ${hm[e].fail} ${n} || isNaN(${r})`)}};jk.default=cne});var kq=_(Mk=>{"use strict";Object.defineProperty(Mk,"__esModule",{value:!0});var Du=Q(),lne={message:({schemaCode:t})=>(0,Du.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Du._)`{multipleOf: ${t}}`},une={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:lne,code(t){let{gen:e,data:r,schemaCode:n,it:s}=t,o=s.opts.multipleOfPrecision,i=e.let("res"),a=o?(0,Du._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:(0,Du._)`${i} !== parseInt(${i})`;t.fail$data((0,Du._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Mk.default=une});var Eq=_(Lk=>{"use strict";Object.defineProperty(Lk,"__esModule",{value:!0});function xq(t){let e=t.length,r=0,n=0,s;for(;n<e;)r++,s=t.charCodeAt(n++),s>=55296&&s<=56319&&n<e&&(s=t.charCodeAt(n),(s&64512)===56320&&n++);return r}Lk.default=xq;xq.code='require("ajv/dist/runtime/ucs2length").default'});var Tq=_(Dk=>{"use strict";Object.defineProperty(Dk,"__esModule",{value:!0});var No=Q(),dne=ge(),fne=Eq(),pne={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,No.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,No._)`{limit: ${t}}`},hne={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:pne,code(t){let{keyword:e,data:r,schemaCode:n,it:s}=t,o=e==="maxLength"?No.operators.GT:No.operators.LT,i=s.opts.unicode===!1?(0,No._)`${r}.length`:(0,No._)`${(0,dne.useFunc)(t.gen,fne.default)}(${r})`;t.fail$data((0,No._)`${i} ${o} ${n}`)}};Dk.default=hne});var Pq=_(qk=>{"use strict";Object.defineProperty(qk,"__esModule",{value:!0});var mne=_r(),gne=ge(),ga=Q(),yne={message:({schemaCode:t})=>(0,ga.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,ga._)`{pattern: ${t}}`},_ne={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:yne,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:o,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,l=c.code==="new RegExp"?(0,ga._)`new RegExp`:(0,gne.useFunc)(e,c),u=e.let("valid");e.try(()=>e.assign(u,(0,ga._)`${l}(${o}, ${a}).test(${r})`),()=>e.assign(u,!1)),t.fail$data((0,ga._)`!${u}`)}else{let c=(0,mne.usePattern)(t,s);t.fail$data((0,ga._)`!${c}.test(${r})`)}}};qk.default=_ne});var Oq=_(Fk=>{"use strict";Object.defineProperty(Fk,"__esModule",{value:!0});var qu=Q(),vne={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,qu.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,qu._)`{limit: ${t}}`},wne={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:vne,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxProperties"?qu.operators.GT:qu.operators.LT;t.fail$data((0,qu._)`Object.keys(${r}).length ${s} ${n}`)}};Fk.default=wne});var Iq=_(Zk=>{"use strict";Object.defineProperty(Zk,"__esModule",{value:!0});var Fu=_r(),Zu=Q(),bne=ge(),Sne={message:({params:{missingProperty:t}})=>(0,Zu.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Zu._)`{missingProperty: ${t}}`},$ne={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Sne,code(t){let{gen:e,schema:r,schemaCode:n,data:s,$data:o,it:i}=t,{opts:a}=i;if(!o&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?l():u(),a.strictRequired){let p=t.parentSchema.properties,{definedProperties:m}=t.it;for(let h of r)if(p?.[h]===void 0&&!m.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,bne.checkStrictMode)(i,y,i.opts.strictRequired)}}function l(){if(c||o)t.block$data(Zu.nil,d);else for(let p of r)(0,Fu.checkReportMissingProp)(t,p)}function u(){let p=e.let("missing");if(c||o){let m=e.let("valid",!0);t.block$data(m,()=>f(p,m)),t.ok(m)}else e.if((0,Fu.checkMissingProp)(t,r,p)),(0,Fu.reportMissingProp)(t,p),e.else()}function d(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,Fu.noPropertyInData)(e,s,p,a.ownProperties),()=>t.error())})}function f(p,m){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(m,(0,Fu.propertyInData)(e,s,p,a.ownProperties)),e.if((0,Zu.not)(m),()=>{t.error(),e.break()})},Zu.nil)}}};Zk.default=$ne});var Nq=_(Uk=>{"use strict";Object.defineProperty(Uk,"__esModule",{value:!0});var Uu=Q(),kne={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Uu.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Uu._)`{limit: ${t}}`},xne={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:kne,code(t){let{keyword:e,data:r,schemaCode:n}=t,s=e==="maxItems"?Uu.operators.GT:Uu.operators.LT;t.fail$data((0,Uu._)`${r}.length ${s} ${n}`)}};Uk.default=xne});var mm=_(Vk=>{"use strict";Object.defineProperty(Vk,"__esModule",{value:!0});var Cq=ru();Cq.code='require("ajv/dist/runtime/equal").default';Vk.default=Cq});var Rq=_(Kk=>{"use strict";Object.defineProperty(Kk,"__esModule",{value:!0});var Bk=Iu(),ht=Q(),Ene=ge(),Tne=mm(),Pne={message:({params:{i:t,j:e}})=>(0,ht.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ht._)`{i: ${t}, j: ${e}}`},One={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Pne,code(t){let{gen:e,data:r,$data:n,schema:s,parentSchema:o,schemaCode:i,it:a}=t;if(!n&&!s)return;let c=e.let("valid"),l=o.items?(0,Bk.getSchemaTypes)(o.items):[];t.block$data(c,u,(0,ht._)`${i} === false`),t.ok(c);function u(){let m=e.let("i",(0,ht._)`${r}.length`),h=e.let("j");t.setParams({i:m,j:h}),e.assign(c,!0),e.if((0,ht._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return l.length>0&&!l.some(m=>m==="object"||m==="array")}function f(m,h){let g=e.name("item"),y=(0,Bk.checkDataTypes)(l,g,a.opts.strictNumbers,Bk.DataType.Wrong),w=e.const("indices",(0,ht._)`{}`);e.for((0,ht._)`;${m}--;`,()=>{e.let(g,(0,ht._)`${r}[${m}]`),e.if(y,(0,ht._)`continue`),l.length>1&&e.if((0,ht._)`typeof ${g} == "string"`,(0,ht._)`${g} += "_"`),e.if((0,ht._)`typeof ${w}[${g}] == "number"`,()=>{e.assign(h,(0,ht._)`${w}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,ht._)`${w}[${g}] = ${m}`)})}function p(m,h){let g=(0,Ene.useFunc)(e,Tne.default),y=e.name("outer");e.label(y).for((0,ht._)`;${m}--;`,()=>e.for((0,ht._)`${h} = ${m}; ${h}--;`,()=>e.if((0,ht._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};Kk.default=One});var Aq=_(Wk=>{"use strict";Object.defineProperty(Wk,"__esModule",{value:!0});var Hk=Q(),Ine=ge(),Nne=mm(),Cne={message:"must be equal to constant",params:({schemaCode:t})=>(0,Hk._)`{allowedValue: ${t}}`},Rne={keyword:"const",$data:!0,error:Cne,code(t){let{gen:e,data:r,$data:n,schemaCode:s,schema:o}=t;n||o&&typeof o=="object"?t.fail$data((0,Hk._)`!${(0,Ine.useFunc)(e,Nne.default)}(${r}, ${s})`):t.fail((0,Hk._)`${o} !== ${r}`)}};Wk.default=Rne});var zq=_(Jk=>{"use strict";Object.defineProperty(Jk,"__esModule",{value:!0});var Vu=Q(),Ane=ge(),zne=mm(),jne={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Vu._)`{allowedValues: ${t}}`},Mne={keyword:"enum",schemaType:"array",$data:!0,error:jne,code(t){let{gen:e,data:r,$data:n,schema:s,schemaCode:o,it:i}=t;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let a=s.length>=i.opts.loopEnum,c,l=()=>c??(c=(0,Ane.useFunc)(e,zne.default)),u;if(a||n)u=e.let("valid"),t.block$data(u,d);else{if(!Array.isArray(s))throw new Error("ajv implementation error");let p=e.const("vSchema",o);u=(0,Vu.or)(...s.map((m,h)=>f(p,h)))}t.pass(u);function d(){e.assign(u,!1),e.forOf("v",o,p=>e.if((0,Vu._)`${l()}(${r}, ${p})`,()=>e.assign(u,!0).break()))}function f(p,m){let h=s[m];return typeof h=="object"&&h!==null?(0,Vu._)`${l()}(${r}, ${p}[${m}])`:(0,Vu._)`${r} === ${h}`}}};Jk.default=Mne});var jq=_(Gk=>{"use strict";Object.defineProperty(Gk,"__esModule",{value:!0});var Lne=$q(),Dne=kq(),qne=Tq(),Fne=Pq(),Zne=Oq(),Une=Iq(),Vne=Nq(),Bne=Rq(),Kne=Aq(),Hne=zq(),Wne=[Lne.default,Dne.default,qne.default,Fne.default,Zne.default,Une.default,Vne.default,Bne.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Kne.default,Hne.default];Gk.default=Wne});var Xk=_(Bu=>{"use strict";Object.defineProperty(Bu,"__esModule",{value:!0});Bu.validateAdditionalItems=void 0;var Co=Q(),Yk=ge(),Jne={message:({params:{len:t}})=>(0,Co.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Co._)`{limit: ${t}}`},Gne={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Jne,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Yk.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Mq(t,n)}};function Mq(t,e){let{gen:r,schema:n,data:s,keyword:o,it:i}=t;i.items=!0;let a=r.const("len",(0,Co._)`${s}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,Co._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Yk.alwaysValidSchema)(i,n)){let l=r.var("valid",(0,Co._)`${a} <= ${e.length}`);r.if((0,Co.not)(l),()=>c(l)),t.ok(l)}function c(l){r.forRange("i",e.length,a,u=>{t.subschema({keyword:o,dataProp:u,dataPropType:Yk.Type.Num},l),i.allErrors||r.if((0,Co.not)(l),()=>r.break())})}}Bu.validateAdditionalItems=Mq;Bu.default=Gne});var Qk=_(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});Ku.validateTuple=void 0;var Lq=Q(),gm=ge(),Yne=_r(),Xne={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Dq(t,"additionalItems",e);r.items=!0,!(0,gm.alwaysValidSchema)(r,e)&&t.ok((0,Yne.validateArray)(t))}};function Dq(t,e,r=t.schema){let{gen:n,parentSchema:s,data:o,keyword:i,it:a}=t;u(s),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=gm.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),l=n.const("len",(0,Lq._)`${o}.length`);r.forEach((d,f)=>{(0,gm.alwaysValidSchema)(a,d)||(n.if((0,Lq._)`${l} > ${f}`,()=>t.subschema({keyword:i,schemaProp:f,dataProp:f},c)),t.ok(c))});function u(d){let{opts:f,errSchemaPath:p}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[e]===!1);if(f.strictTuples&&!h){let g=`"${i}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,gm.checkStrictMode)(a,g,f.strictTuples)}}}Ku.validateTuple=Dq;Ku.default=Xne});var qq=_(ex=>{"use strict";Object.defineProperty(ex,"__esModule",{value:!0});var Qne=Qk(),ese={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,Qne.validateTuple)(t,"items")};ex.default=ese});var Zq=_(tx=>{"use strict";Object.defineProperty(tx,"__esModule",{value:!0});var Fq=Q(),tse=ge(),rse=_r(),nse=Xk(),sse={message:({params:{len:t}})=>(0,Fq.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Fq._)`{limit: ${t}}`},ose={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:sse,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:s}=r;n.items=!0,!(0,tse.alwaysValidSchema)(n,e)&&(s?(0,nse.validateAdditionalItems)(t,s):t.ok((0,rse.validateArray)(t)))}};tx.default=ose});var Uq=_(rx=>{"use strict";Object.defineProperty(rx,"__esModule",{value:!0});var wr=Q(),ym=ge(),ise={message:({params:{min:t,max:e}})=>e===void 0?(0,wr.str)`must contain at least ${t} valid item(s)`:(0,wr.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,wr._)`{minContains: ${t}}`:(0,wr._)`{minContains: ${t}, maxContains: ${e}}`},ase={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:ise,code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:o}=t,i,a,{minContains:c,maxContains:l}=n;o.opts.next?(i=c===void 0?1:c,a=l):i=1;let u=e.const("len",(0,wr._)`${s}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,ym.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,ym.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,ym.alwaysValidSchema)(o,r)){let h=(0,wr._)`${u} >= ${i}`;a!==void 0&&(h=(0,wr._)`${h} && ${u} <= ${a}`),t.pass(h);return}o.items=!0;let d=e.name("valid");a===void 0&&i===1?p(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,wr._)`${s}.length > 0`,f)):(e.let(d,!1),f()),t.result(d,()=>t.reset());function f(){let h=e.name("_valid"),g=e.let("count",0);p(h,()=>e.if(h,()=>m(g)))}function p(h,g){e.forRange("i",0,u,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:ym.Type.Num,compositeRule:!0},h),g()})}function m(h){e.code((0,wr._)`${h}++`),a===void 0?e.if((0,wr._)`${h} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,wr._)`${h} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,wr._)`${h} >= ${i}`,()=>e.assign(d,!0)))}}};rx.default=ase});var Kq=_(fn=>{"use strict";Object.defineProperty(fn,"__esModule",{value:!0});fn.validateSchemaDeps=fn.validatePropertyDeps=fn.error=void 0;var nx=Q(),cse=ge(),Hu=_r();fn.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,nx.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,nx._)`{property: ${t},
307
- missingProperty: ${n},
308
- depsCount: ${e},
309
- deps: ${r}}`};var lse={keyword:"dependencies",type:"object",schemaType:"object",error:fn.error,code(t){let[e,r]=use(t);Vq(t,e),Bq(t,r)}};function use({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let s=Array.isArray(t[n])?e:r;s[n]=t[n]}return[e,r]}function Vq(t,e=t.schema){let{gen:r,data:n,it:s}=t;if(Object.keys(e).length===0)return;let o=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,Hu.propertyInData)(r,n,i,s.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),s.allErrors?r.if(c,()=>{for(let l of a)(0,Hu.checkReportMissingProp)(t,l)}):(r.if((0,nx._)`${c} && (${(0,Hu.checkMissingProp)(t,a,o)})`),(0,Hu.reportMissingProp)(t,o),r.else())}}fn.validatePropertyDeps=Vq;function Bq(t,e=t.schema){let{gen:r,data:n,keyword:s,it:o}=t,i=r.name("valid");for(let a in e)(0,cse.alwaysValidSchema)(o,e[a])||(r.if((0,Hu.propertyInData)(r,n,a,o.opts.ownProperties),()=>{let c=t.subschema({keyword:s,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}fn.validateSchemaDeps=Bq;fn.default=lse});var Wq=_(sx=>{"use strict";Object.defineProperty(sx,"__esModule",{value:!0});var Hq=Q(),dse=ge(),fse={message:"property name must be valid",params:({params:t})=>(0,Hq._)`{propertyName: ${t.propertyName}}`},pse={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:fse,code(t){let{gen:e,schema:r,data:n,it:s}=t;if((0,dse.alwaysValidSchema)(s,r))return;let o=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},o),e.if((0,Hq.not)(o),()=>{t.error(!0),s.allErrors||e.break()})}),t.ok(o)}};sx.default=pse});var ix=_(ox=>{"use strict";Object.defineProperty(ox,"__esModule",{value:!0});var _m=_r(),Br=Q(),hse=jn(),vm=ge(),mse={message:"must NOT have additional properties",params:({params:t})=>(0,Br._)`{additionalProperty: ${t.additionalProperty}}`},gse={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:mse,code(t){let{gen:e,schema:r,parentSchema:n,data:s,errsCount:o,it:i}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,vm.alwaysValidSchema)(i,r))return;let l=(0,_m.allSchemaProperties)(n.properties),u=(0,_m.allSchemaProperties)(n.patternProperties);d(),t.ok((0,Br._)`${o} === ${hse.default.errors}`);function d(){e.forIn("key",s,g=>{!l.length&&!u.length?m(g):e.if(f(g),()=>m(g))})}function f(g){let y;if(l.length>8){let w=(0,vm.schemaRefOrVal)(i,n.properties,"properties");y=(0,_m.isOwnProperty)(e,w,g)}else l.length?y=(0,Br.or)(...l.map(w=>(0,Br._)`${g} === ${w}`)):y=Br.nil;return u.length&&(y=(0,Br.or)(y,...u.map(w=>(0,Br._)`${(0,_m.usePattern)(t,w)}.test(${g})`))),(0,Br.not)(y)}function p(g){e.code((0,Br._)`delete ${s}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,vm.alwaysValidSchema)(i,r)){let y=e.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),e.if((0,Br.not)(y),()=>{t.reset(),p(g)})):(h(g,y),a||e.if((0,Br.not)(y),()=>e.break()))}}function h(g,y,w){let b={keyword:"additionalProperties",dataProp:g,dataPropType:vm.Type.Str};w===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(b,y)}}};ox.default=gse});var Yq=_(cx=>{"use strict";Object.defineProperty(cx,"__esModule",{value:!0});var yse=Au(),Jq=_r(),ax=ge(),Gq=ix(),_se={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:s,it:o}=t;o.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Gq.default.code(new yse.KeywordCxt(o,Gq.default,"additionalProperties"));let i=(0,Jq.allSchemaProperties)(r);for(let d of i)o.definedProperties.add(d);o.opts.unevaluated&&i.length&&o.props!==!0&&(o.props=ax.mergeEvaluated.props(e,(0,ax.toHash)(i),o.props));let a=i.filter(d=>!(0,ax.alwaysValidSchema)(o,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,Jq.propertyInData)(e,s,d,o.opts.ownProperties)),u(d),o.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};cx.default=_se});var t2=_(lx=>{"use strict";Object.defineProperty(lx,"__esModule",{value:!0});var Xq=_r(),wm=Q(),Qq=ge(),e2=ge(),vse={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:s,it:o}=t,{opts:i}=o,a=(0,Xq.allSchemaProperties)(r),c=a.filter(h=>(0,Qq.alwaysValidSchema)(o,r[h]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let l=i.strictSchema&&!i.allowMatchingProperties&&s.properties,u=e.name("valid");o.props!==!0&&!(o.props instanceof wm.Name)&&(o.props=(0,e2.evaluatedPropsToName)(e,o.props));let{props:d}=o;f();function f(){for(let h of a)l&&p(h),o.allErrors?m(h):(e.var(u,!0),m(h),e.if(u))}function p(h){for(let g in l)new RegExp(h).test(g)&&(0,Qq.checkStrictMode)(o,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){e.forIn("key",n,g=>{e.if((0,wm._)`${(0,Xq.usePattern)(t,h)}.test(${g})`,()=>{let y=c.includes(h);y||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:e2.Type.Str},u),o.opts.unevaluated&&d!==!0?e.assign((0,wm._)`${d}[${g}]`,!0):!y&&!o.allErrors&&e.if((0,wm.not)(u),()=>e.break())})})}}};lx.default=vse});var r2=_(ux=>{"use strict";Object.defineProperty(ux,"__esModule",{value:!0});var wse=ge(),bse={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,wse.alwaysValidSchema)(n,r)){t.fail();return}let s=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),t.failResult(s,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};ux.default=bse});var n2=_(dx=>{"use strict";Object.defineProperty(dx,"__esModule",{value:!0});var Sse=_r(),$se={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Sse.validateUnion,error:{message:"must match a schema in anyOf"}};dx.default=$se});var s2=_(fx=>{"use strict";Object.defineProperty(fx,"__esModule",{value:!0});var bm=Q(),kse=ge(),xse={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,bm._)`{passingSchemas: ${t.passing}}`},Ese={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:xse,code(t){let{gen:e,schema:r,parentSchema:n,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let o=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(l),t.result(i,()=>t.reset(),()=>t.error(!0));function l(){o.forEach((u,d)=>{let f;(0,kse.alwaysValidSchema)(s,u)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,bm._)`${c} && ${i}`).assign(i,!1).assign(a,(0,bm._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),f&&t.mergeEvaluated(f,bm.Name)})})}}};fx.default=Ese});var o2=_(px=>{"use strict";Object.defineProperty(px,"__esModule",{value:!0});var Tse=ge(),Pse={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let s=e.name("valid");r.forEach((o,i)=>{if((0,Tse.alwaysValidSchema)(n,o))return;let a=t.subschema({keyword:"allOf",schemaProp:i},s);t.ok(s),t.mergeEvaluated(a)})}};px.default=Pse});var c2=_(hx=>{"use strict";Object.defineProperty(hx,"__esModule",{value:!0});var Sm=Q(),a2=ge(),Ose={message:({params:t})=>(0,Sm.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Sm._)`{failingKeyword: ${t.ifClause}}`},Ise={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Ose,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,a2.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=i2(n,"then"),o=i2(n,"else");if(!s&&!o)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),s&&o){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else s?e.if(a,l("then")):e.if((0,Sm.not)(a),l("else"));t.pass(i,()=>t.error(!0));function c(){let u=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(u)}function l(u,d){return()=>{let f=t.subschema({keyword:u},a);e.assign(i,a),t.mergeValidEvaluated(f,i),d?e.assign(d,(0,Sm._)`${u}`):t.setParams({ifClause:u})}}}};function i2(t,e){let r=t.schema[e];return r!==void 0&&!(0,a2.alwaysValidSchema)(t,r)}hx.default=Ise});var l2=_(mx=>{"use strict";Object.defineProperty(mx,"__esModule",{value:!0});var Nse=ge(),Cse={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,Nse.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};mx.default=Cse});var u2=_(gx=>{"use strict";Object.defineProperty(gx,"__esModule",{value:!0});var Rse=Xk(),Ase=qq(),zse=Qk(),jse=Zq(),Mse=Uq(),Lse=Kq(),Dse=Wq(),qse=ix(),Fse=Yq(),Zse=t2(),Use=r2(),Vse=n2(),Bse=s2(),Kse=o2(),Hse=c2(),Wse=l2();function Jse(t=!1){let e=[Use.default,Vse.default,Bse.default,Kse.default,Hse.default,Wse.default,Dse.default,qse.default,Lse.default,Fse.default,Zse.default];return t?e.push(Ase.default,jse.default):e.push(Rse.default,zse.default),e.push(Mse.default),e}gx.default=Jse});var d2=_(yx=>{"use strict";Object.defineProperty(yx,"__esModule",{value:!0});var Ye=Q(),Gse={message:({schemaCode:t})=>(0,Ye.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Ye._)`{format: ${t}}`},Yse={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Gse,code(t,e){let{gen:r,data:n,$data:s,schema:o,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;s?f():p();function f(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,Ye._)`${m}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,Ye._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,Ye._)`${h}.type || "string"`).assign(y,(0,Ye._)`${h}.validate`),()=>r.assign(g,(0,Ye._)`"string"`).assign(y,h)),t.fail$data((0,Ye.or)(w(),b()));function w(){return c.strictSchema===!1?Ye.nil:(0,Ye._)`${i} && !${y}`}function b(){let x=u.$async?(0,Ye._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,Ye._)`${y}(${n})`,v=(0,Ye._)`(typeof ${y} == "function" ? ${x} : ${y}.test(${n}))`;return(0,Ye._)`${y} && ${y} !== true && ${g} === ${e} && !${v}`}}function p(){let m=d.formats[o];if(!m){w();return}if(m===!0)return;let[h,g,y]=b(m);h===e&&t.pass(x());function w(){if(c.strictSchema===!1){d.logger.warn(v());return}throw new Error(v());function v(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function b(v){let S=v instanceof RegExp?(0,Ye.regexpCode)(v):c.code.formats?(0,Ye._)`${c.code.formats}${(0,Ye.getProperty)(o)}`:void 0,T=r.scopeValue("formats",{key:o,ref:v,code:S});return typeof v=="object"&&!(v instanceof RegExp)?[v.type||"string",v.validate,(0,Ye._)`${T}.validate`]:["string",v,T]}function x(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Ye._)`await ${y}(${n})`}return typeof g=="function"?(0,Ye._)`${y}(${n})`:(0,Ye._)`${y}.test(${n})`}}}};yx.default=Yse});var f2=_(_x=>{"use strict";Object.defineProperty(_x,"__esModule",{value:!0});var Xse=d2(),Qse=[Xse.default];_x.default=Qse});var p2=_(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});ya.contentVocabulary=ya.metadataVocabulary=void 0;ya.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ya.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var m2=_(vx=>{"use strict";Object.defineProperty(vx,"__esModule",{value:!0});var eoe=Sq(),toe=jq(),roe=u2(),noe=f2(),h2=p2(),soe=[eoe.default,toe.default,(0,roe.default)(),noe.default,h2.metadataVocabulary,h2.contentVocabulary];vx.default=soe});var y2=_($m=>{"use strict";Object.defineProperty($m,"__esModule",{value:!0});$m.DiscrError=void 0;var g2;(function(t){t.Tag="tag",t.Mapping="mapping"})(g2||($m.DiscrError=g2={}))});var v2=_(bx=>{"use strict";Object.defineProperty(bx,"__esModule",{value:!0});var _a=Q(),wx=y2(),_2=lm(),ooe=zu(),ioe=ge(),aoe={message:({params:{discrError:t,tagName:e}})=>t===wx.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,_a._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},coe={keyword:"discriminator",type:"object",schemaType:"object",error:aoe,code(t){let{gen:e,data:r,schema:n,parentSchema:s,it:o}=t,{oneOf:i}=s;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),l=e.const("tag",(0,_a._)`${r}${(0,_a.getProperty)(a)}`);e.if((0,_a._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:wx.DiscrError.Tag,tag:l,tagName:a})),t.ok(c);function u(){let p=f();e.if(!1);for(let m in p)e.elseIf((0,_a._)`${l} === ${m}`),e.assign(c,d(p[m]));e.else(),t.error(!1,{discrError:wx.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(p){let m=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:p},m);return t.mergeEvaluated(h,_a.Name),m}function f(){var p;let m={},h=y(s),g=!0;for(let x=0;x<i.length;x++){let v=i[x];if(v?.$ref&&!(0,ioe.schemaHasRulesButRef)(v,o.self.RULES)){let T=v.$ref;if(v=_2.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,T),v instanceof _2.SchemaEnv&&(v=v.schema),v===void 0)throw new ooe.default(o.opts.uriResolver,o.baseId,T)}let S=(p=v?.properties)===null||p===void 0?void 0:p[a];if(typeof S!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(v)),w(S,x)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function y({required:x}){return Array.isArray(x)&&x.includes(a)}function w(x,v){if(x.const)b(x.const,v);else if(x.enum)for(let S of x.enum)b(S,v);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b(x,v){if(typeof x!="string"||x in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[x]=v}}}};bx.default=coe});var w2=_((bbe,loe)=>{loe.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var S2=_((Fe,Sx)=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.MissingRefError=Fe.ValidationError=Fe.CodeGen=Fe.Name=Fe.nil=Fe.stringify=Fe.str=Fe._=Fe.KeywordCxt=Fe.Ajv=void 0;var uoe=gq(),doe=m2(),foe=v2(),b2=w2(),poe=["/properties"],km="http://json-schema.org/draft-07/schema",va=class extends uoe.default{_addVocabularies(){super._addVocabularies(),doe.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(foe.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(b2,poe):b2;this.addMetaSchema(e,km,!1),this.refs["http://json-schema.org/schema"]=km}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(km)?km:void 0)}};Fe.Ajv=va;Sx.exports=Fe=va;Sx.exports.Ajv=va;Object.defineProperty(Fe,"__esModule",{value:!0});Fe.default=va;var hoe=Au();Object.defineProperty(Fe,"KeywordCxt",{enumerable:!0,get:function(){return hoe.KeywordCxt}});var wa=Q();Object.defineProperty(Fe,"_",{enumerable:!0,get:function(){return wa._}});Object.defineProperty(Fe,"str",{enumerable:!0,get:function(){return wa.str}});Object.defineProperty(Fe,"stringify",{enumerable:!0,get:function(){return wa.stringify}});Object.defineProperty(Fe,"nil",{enumerable:!0,get:function(){return wa.nil}});Object.defineProperty(Fe,"Name",{enumerable:!0,get:function(){return wa.Name}});Object.defineProperty(Fe,"CodeGen",{enumerable:!0,get:function(){return wa.CodeGen}});var moe=am();Object.defineProperty(Fe,"ValidationError",{enumerable:!0,get:function(){return moe.default}});var goe=zu();Object.defineProperty(Fe,"MissingRefError",{enumerable:!0,get:function(){return goe.default}})});var $2=_(ba=>{"use strict";Object.defineProperty(ba,"__esModule",{value:!0});ba.formatLimitDefinition=void 0;var yoe=S2(),Kr=Q(),Os=Kr.operators,xm={formatMaximum:{okStr:"<=",ok:Os.LTE,fail:Os.GT},formatMinimum:{okStr:">=",ok:Os.GTE,fail:Os.LT},formatExclusiveMaximum:{okStr:"<",ok:Os.LT,fail:Os.GTE},formatExclusiveMinimum:{okStr:">",ok:Os.GT,fail:Os.LTE}},_oe={message:({keyword:t,schemaCode:e})=>(0,Kr.str)`should be ${xm[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Kr._)`{comparison: ${xm[t].okStr}, limit: ${e}}`};ba.formatLimitDefinition={keyword:Object.keys(xm),type:"string",schemaType:"string",$data:!0,error:_oe,code(t){let{gen:e,data:r,schemaCode:n,keyword:s,it:o}=t,{opts:i,self:a}=o;if(!i.validateFormats)return;let c=new yoe.KeywordCxt(o,a.RULES.all.format.definition,"format");c.$data?l():u();function l(){let f=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=e.const("fmt",(0,Kr._)`${f}[${c.schemaCode}]`);t.fail$data((0,Kr.or)((0,Kr._)`typeof ${p} != "object"`,(0,Kr._)`${p} instanceof RegExp`,(0,Kr._)`typeof ${p}.compare != "function"`,d(p)))}function u(){let f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${s}": format "${f}" does not define "compare" function`);let m=e.scopeValue("formats",{key:f,ref:p,code:i.code.formats?(0,Kr._)`${i.code.formats}${(0,Kr.getProperty)(f)}`:void 0});t.fail$data(d(m))}function d(f){return(0,Kr._)`${f}.compare(${r}, ${n}) ${xm[s].fail} 0`}},dependencies:["format"]};var voe=t=>(t.addKeyword(ba.formatLimitDefinition),t);ba.default=voe});var T2=_((Wu,E2)=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});var Sa=cD(),woe=$2(),$x=Q(),k2=new $x.Name("fullFormats"),boe=new $x.Name("fastFormats"),kx=(t,e={keywords:!0})=>{if(Array.isArray(e))return x2(t,e,Sa.fullFormats,k2),t;let[r,n]=e.mode==="fast"?[Sa.fastFormats,boe]:[Sa.fullFormats,k2],s=e.formats||Sa.formatNames;return x2(t,s,r,n),e.keywords&&(0,woe.default)(t),t};kx.get=(t,e="full")=>{let n=(e==="fast"?Sa.fastFormats:Sa.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function x2(t,e,r,n){var s,o;(s=(o=t.opts.code).formats)!==null&&s!==void 0||(o.formats=(0,$x._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}E2.exports=Wu=kx;Object.defineProperty(Wu,"__esModule",{value:!0});Wu.default=kx});function Soe(){let t=new P2.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,O2.default)(t),t}var P2,O2,Em,I2=$(()=>{P2=Ze(eD(),1),O2=Ze(T2(),1);Em=class{constructor(e){this._ajv=e??Soe()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}}});var Tm,N2=$(()=>{uo();Tm=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let s=e.messages[e.messages.length-1],o=Array.isArray(s.content)?s.content:[s.content],i=o.some(u=>u.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],l=c.some(u=>u.type==="tool_use");if(i){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){let u=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(o.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(u.size!==d.size||![...u].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},Ui,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),s=e.mode??"form";switch(s){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let o=s==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:o},lo,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}}});function C2(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function R2(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var A2=$(()=>{});var z2={};Je(z2,{Server:()=>Ju});var Ju,xx=$(()=>{$j();uo();I2();gl();N2();A2();Ju=class extends mh{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Zi.options.map((n,s)=>[n,s])),this.isMessageIgnored=(n,s)=>{let o=this._loggingLevels.get(s);return o?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Em,this.setRequestHandler(Tl,n=>this._oninitialize(n)),this.setNotificationHandler(Pl,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(rh,async(n,s)=>{let o=s.sessionId||s.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Zi.safeParse(i);return a.success&&this._loggingLevels.set(o,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Tm(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Sj(this._capabilities,e)}setRequestHandler(e,r){let s=fs(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let o=Ai(s);if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let a=async(c,l)=>{let u=ds(co,c);if(!u.success){let m=u.error instanceof Error?u.error.message:String(u.error);throw new j(F.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=u.data,f=await Promise.resolve(r(c,l));if(d.task){let m=ds(io,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new j(F.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let p=ds(Ul,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new j(F.InvalidParams,`Invalid tools/call result: ${m}`)}return p.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){R2(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&C2(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Xb.includes(r)?r:Hp,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},xl)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],s=Array.isArray(n.content)?n.content:[n.content],o=s.some(l=>l.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(l=>l.type==="tool_use");if(o){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let l=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),u=new Set(s.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(l.size!==u.size||![...l].every(d=>u.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},nh,r):this.request({method:"sampling/createMessage",params:e},Ui,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let s=e;return this.request({method:"elicitation/create",params:s},lo,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let s=e.mode==="form"?e:{...e,mode:"form"},o=await this.request({method:"elicitation/create",params:s},lo,r);if(o.action==="accept"&&o.content&&s.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(s.requestedSchema)(o.content);if(!a.valid)throw new j(F.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof j?i:new j(F.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return o}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},sh,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}});function koe(t){return i0.parse(JSON.parse(t))}function j2(t){return JSON.stringify(t)+`
310
- `}var $oe,Pm,M2=$(()=>{uo();$oe=10*1024*1024,Pm=class{constructor(e){this._maxBufferSize=e?.maxBufferSize??$oe}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
311
- `);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),koe(r)}clear(){this._buffer=void 0}}});var Tx={};Je(Tx,{StdioServerTransport:()=>Ex});import L2 from"node:process";var Ex,Px=$(()=>{M2();Ex=class{constructor(e=L2.stdin,r=L2.stdout,n){this._stdin=e,this._stdout=r,this._started=!1,this._ondata=s=>{try{this._readBuffer.append(s),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}},this._onerror=s=>{this.onerror?.(s)},this._readBuffer=new Pm({maxBufferSize:n?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=j2(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}}});var q2={};Je(q2,{runMcpWorkspace:()=>Eoe});import{randomUUID as xoe}from"node:crypto";import{resolve as D2}from"node:path";var Ox,Eoe,Toe,F2=$(()=>{"use strict";ut();Tr();ar();RN();V_();Ox=t=>{process.stderr.write(`[pix3 mcp] ${t}
312
- `)},Eoe=async t=>{let e=t.projectDir?D2(t.cwd,t.projectDir):Qe(t.cwd)??D2(t.cwd),[{Server:r},{StdioServerTransport:n},s]=await Promise.all([Promise.resolve().then(()=>(xx(),z2)),Promise.resolve().then(()=>(Px(),Tx)),Promise.resolve().then(()=>(uo(),Dz))]),o=new r({name:"pix3",version:be},{capabilities:{tools:{listChanged:!0}},instructions:"Pix3 editor tools for this project folder (run, observe, generate; no scene editing \u2014 edit the files). Pass `expect` {path: sha256 of the bytes you wrote} to play_start / play_restart / game_run so the run is verified against your writes."}),i=xoe(),a=new Kf(e,()=>({name:o.getClientVersion()?.name??t.agent??null,session:i})),c=new Wf(a,{log:Ox}),l=!1;o.setRequestHandler(s.ListToolsRequestSchema,async()=>{let g=await c.list();return l=c.hasAdvertisedTools(),{tools:g.map(y=>({...y,inputSchema:{type:"object",...y.inputSchema}}))}}),o.setRequestHandler(s.CallToolRequestSchema,async g=>{let y=g.params.arguments??{},w=await c.call(g.params.name,y);return l||c.list().then(()=>{c.hasAdvertisedTools()&&!l&&(l=!0,o.sendToolListChanged().catch(()=>{}))}),w});try{let g=await a.status();Ox(`workspace server ${g.root} (session ${g.serverSession.slice(0,8)}, editor ${g.holder??"not connected"})`)}catch(g){Ox(g instanceof Yt?g.message:`workspace server check failed: ${g instanceof Error?g.message:String(g)}`)}let u=Toe(),d=()=>{a.presence().catch(()=>{})},f=setInterval(d,u);f.unref();let p=!1,m=async()=>{p||(p=!0,clearInterval(f),await a.presence(!0,1e3).catch(()=>{}),await o.close().catch(()=>{}),process.exit(0))};process.on("SIGINT",()=>{m()}),process.on("SIGTERM",()=>{m()}),process.stdin.on("end",()=>{m()});let h=new n;h.onclose=()=>{m()},o.oninitialized=d,await o.connect(h),d()},Toe=()=>{let t=Number(process.env.PIX3_PRESENCE_HEARTBEAT_MS);return Number.isFinite(t)&&t>=50?t:mN}});import{randomUUID as Poe}from"node:crypto";var Om,Gu,Yu,Ix,Im,Ooe,$a,Xu=$(()=>{"use strict";Om=(t,e=!1)=>({content:[{type:"text",text:t}],...e?{isError:!0}:{}}),Gu=(t,e)=>({content:[{type:"text",text:e}],isError:!0,relayFailure:t}),Yu=t=>t.content.flatMap(e=>e.type==="text"?[e.text]:[]).join(`
313
- `),Ix=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Im=t=>{if(!Ix(t)||!Array.isArray(t.content))return null;let e=[];for(let r of t.content){if(!Ix(r))return null;if(r.type==="text"&&typeof r.text=="string")e.push({type:"text",text:r.text});else if(r.type==="image"&&typeof r.data=="string"&&typeof r.mimeType=="string")e.push({type:"image",data:r.data,mimeType:r.mimeType});else return null}return{content:e,...t.isError===!0?{isError:!0}:{},...Ix(t._meta)?{_meta:t._meta}:{}}},Ooe=64,$a=class{parked=new Map;onPark=null;setParkListener(e){this.onPark=e}park(e,r,n,s){if(this.parked.size>=Ooe)return Promise.resolve(Gu("overloaded","Too many editor calls are already in flight."));let o=`call_${Poe().replace(/-/g,"").slice(0,24)}`;return new Promise(i=>{let a=setTimeout(()=>{this.parked.delete(o)&&i(Gu("timeout",`The Pix3 editor did not answer "${e}" within ${Math.round(n/1e3)} s.`))},n);this.parked.set(o,{id:o,name:e,input:r,...s?{extra:s}:{},resolve:i,timer:a,flushed:!1}),this.onPark?.()})}hasUnflushed(){for(let e of this.parked.values())if(!e.flushed)return!0;return!1}takeUnflushed(){let e=[];for(let r of this.parked.values())r.flushed||(r.flushed=!0,e.push({id:r.id,name:r.name,input:r.input,...r.extra?{extra:r.extra}:{}}));return e}requeueDelivered(){for(let e of this.parked.values())e.flushed=!1}resolve(e,r){let n=this.parked.get(e);return n?(this.parked.delete(e),clearTimeout(n.timer),n.resolve(r),!0):!1}cancelAll(e){for(let r of[...this.parked.values()])this.resolve(r.id,Gu("cancelled",e))}get size(){return this.parked.size}}});import{randomBytes as Z2,randomUUID as U2}from"node:crypto";import{mkdirSync as Noe,rmSync as Nx,writeFileSync as Coe}from"node:fs";import{createServer as Roe}from"node:http";import{join as V2}from"node:path";var Aoe,zoe,Nm,B2=$(()=>{"use strict";Xu();ut();Tr();Pc();ar();Aoe=16,zoe=32,Nm=class{sessionId=U2();projectDir;relay=new $a;claims=new Map;endedLeases=new Map;options;claimTtlMs;leaseTtlMs;pollTimeoutMs;server=null;boundPort=null;lease=null;waiter=null;lastBrowserHelloAt=null;lastFailedClaimAt=null;constructor(e){this.options=e,this.projectDir=e.projectDir,this.claimTtlMs=e.claimTtlMs??lN,this.leaseTtlMs=e.leaseTtlMs??uN,this.pollTimeoutMs=e.pollTimeoutMs??dN,this.relay.setParkListener(()=>this.flushToWaiter())}get port(){return this.boundPort}async start(){let e=this.options.ports??N_,r=null;for(let n of e){let s=Roe((i,a)=>{this.handle(i,a)});try{await new Promise((i,a)=>{s.once("error",a),s.listen(n,Jt,()=>{s.off("error",a),i()})})}catch(i){r=i;continue}let o=s.address();return this.server=s,this.boundPort=typeof o=="object"&&o?o.port:n,this.boundPort}throw new Error(`No free port for the Pix3 link server in ${e.join(", ")}`+(r instanceof Error?` (${r.message})`:"")+". Another `pix3 mcp` per port is running \u2014 close one of them.")}async close(){for(let r of this.claims.values())clearTimeout(r.timer),Nx(r.file,{force:!0});this.claims.clear(),this.relay.cancelAll("The Pix3 link server is shutting down."),this.waiter&&this.answerWaiter([]);let e=this.server;this.server=null,this.boundPort=null,e&&(e.closeAllConnections(),await new Promise(r=>e.close(()=>r())))}status(){return{port:this.boundPort,sessionId:this.sessionId,projectId:Zs(this.projectDir),leased:this.currentLease()!==null,lastBrowserHelloAt:this.lastBrowserHelloAt,lastFailedClaimAt:this.lastFailedClaimAt}}isLeased(){return this.currentLease()!==null}callEditor(e,r,n=si){return this.isLeased()?this.relay.park(e,r,n):Promise.resolve(Om("No Pix3 editor window is connected.",!0))}currentLease(){let e=this.lease;return e?!(this.waiter?.leaseId===e.leaseId)&&Date.now()-e.lastSeen>this.leaseTtlMs?(this.dropLease("expired"),null):e:null}dropLease(e){let r=this.lease;if(r){if(this.options.log?.(`lease ${r.leaseId.slice(0,8)} ${e}`),this.lease=null,this.rememberEnded(r.leaseId,e),this.waiter?.leaseId===r.leaseId){let n=this.waiter;this.clearWaiter(),this.send(n.res,409,{error:"lease_lost",reason:e,message:"Lease lost."},n.origin)}this.relay.requeueDelivered()}}rememberEnded(e,r){if(this.endedLeases.set(e,r),this.endedLeases.size>zoe){let n=this.endedLeases.keys().next().value;n!==void 0&&this.endedLeases.delete(n)}}grantLease(){let e={leaseId:U2(),lastSeen:Date.now()};return this.lease=e,this.options.log?.(`lease ${e.leaseId.slice(0,8)} granted`),e}requireLease(e){let r=this.currentLease();if(r&&r.leaseId===e)return r;let n=this.endedLeases.get(e)??"unknown";throw new M(409,"lease_lost","This window does not hold the lease.",{reason:n})}clearWaiter(){this.waiter&&(clearTimeout(this.waiter.timer),this.waiter=null)}answerWaiter(e){let r=this.waiter;r&&(this.clearWaiter(),this.lease?.leaseId===r.leaseId&&(this.lease.lastSeen=Date.now()),this.send(r.res,200,{calls:e},r.origin))}flushToWaiter(){this.waiter&&this.relay.hasUnflushed()&&this.answerWaiter(this.relay.takeUnflushed())}createClaim(){if(this.claims.size>=Aoe)throw new M(429,"too_many_claims","Too many pending claims.");let e=`claim-${Z2(12).toString("hex")}`,r=`${C_}/${e}`,n=V2(this.projectDir,...r.split("/")),s=Z2(32).toString("hex");Noe(V2(this.projectDir,...C_.split("/")),{recursive:!0}),Coe(n,s+`
314
- `,{mode:384});let o=setTimeout(()=>{this.claims.delete(s)&&(Nx(n,{force:!0}),this.lastFailedClaimAt=Date.now())},this.claimTtlMs);return o.unref(),this.claims.set(s,{nonce:s,file:n,timer:o}),r}consumeNonce(e){let r=typeof e.nonce=="string"?e.nonce.trim():"",n=r?this.claims.get(r):void 0;if(!n)throw this.lastFailedClaimAt=Date.now(),new M(403,"bad_nonce","Nonce does not match a pending claim \u2014 the window has a different folder open, or the claim expired.");this.claims.delete(r),clearTimeout(n.timer),Nx(n.file,{force:!0})}leaseReply(e){return{leaseId:e.leaseId,sessionId:this.sessionId,leaseTtlMs:this.leaseTtlMs,pollTimeoutMs:this.pollTimeoutMs}}send(e,r,n,s){Gt(e,r,n,s)}hostAllowed(e){return this.boundPort!==null&&oi(e.headers.host)}async handle(e,r){let n=e.headers.origin,s=typeof n=="string"?n:null;try{if(!this.hostAllowed(e))throw new M(403,"forbidden_host","Forbidden host.");if(!ii(s)){this.options.log?.(`403 origin ${s}`),this.send(r,403,{error:"forbidden_origin",message:"Origin not allowed."},null);return}await this.route(e,r,s)}catch(o){if(o instanceof M){this.send(r,o.status,{error:o.code,message:o.message,...o.extra},o.code==="forbidden_host"?null:s);return}this.options.log?.(`500 ${String(o)}`),this.send(r,500,{error:"internal",message:"Internal error."},s)}}async route(e,r,n){let s=new URL(e.url??"/","http://127.0.0.1"),o=s.pathname,i=e.method??"GET";if(i==="OPTIONS"){let c={"Access-Control-Allow-Methods":"GET, POST, OPTIONS","Access-Control-Allow-Headers":"content-type","Access-Control-Max-Age":"600","Cache-Control":"no-store"};n&&(c["Access-Control-Allow-Origin"]=n,c.Vary="Origin"),e.headers["access-control-request-private-network"]==="true"&&(c["Access-Control-Allow-Private-Network"]="true"),r.writeHead(204,c),r.end();return}if(i==="GET"&&o==="/hello"){n&&(this.lastBrowserHelloAt=Date.now());let c=this.options.agent?.()??null;this.send(r,200,{projectId:Zs(this.projectDir),sessionId:this.sessionId,protocol:1,cliVersion:be,agent:c?{name:c,verified:!1}:null,pid:process.pid},n);return}if(i==="POST"&&o==="/claim"){await j_(e),this.send(r,200,{file:this.createClaim()},n);return}if(i==="POST"&&(o==="/claim/confirm"||o==="/claim/takeover")){let c=await Xr(e);if(this.consumeNonce(c),o==="/claim/confirm"){if(this.currentLease())throw new M(409,"busy","Another Pix3 window already serves this agent session.",{sessionId:this.sessionId})}else this.currentLease()&&this.dropLease("taken_over");this.send(r,200,this.leaseReply(this.grantLease()),n);return}if(i==="GET"&&o==="/calls"){let c=this.requireLease(s.searchParams.get("lease")??"");if(c.lastSeen=Date.now(),this.waiter&&this.answerWaiter([]),this.relay.hasUnflushed()){this.send(r,200,{calls:this.relay.takeUnflushed()},n);return}let l=setTimeout(()=>{this.waiter?.res===r&&this.answerWaiter([])},this.pollTimeoutMs);this.waiter={leaseId:c.leaseId,res:r,timer:l,origin:n},r.on("close",()=>{this.waiter?.res===r&&(this.clearWaiter(),this.lease?.leaseId===c.leaseId&&(this.lease.lastSeen=Date.now()))});return}let a=/^\/calls\/([A-Za-z0-9_-]+)$/.exec(o);if(i==="POST"&&a){let c=await Xr(e),l=this.requireLease(typeof c.lease=="string"?c.lease:"");l.lastSeen=Date.now();let u=Im(c.result);if(!u)throw new M(400,"bad_result",'`result` must be { content: [{ type: "text", text }], isError? }.');if(!this.relay.resolve(a[1],u))throw new M(404,"unknown_call","No pending call with that id.");this.send(r,200,{ok:!0},n);return}throw new M(404,"not_found","Not found.")}}});function Cx(t){return!!t&&typeof t=="object"&&H2 in t}function W2(t){return t[H2]?.complete}var H2,K2,J2=$(()=>{H2=Symbol.for("mcp.completable");(function(t){t.Completable="McpCompletable"})(K2||(K2={}))});var Cm,G2=$(()=>{Cm=class t{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,r,n){if(e.length>r)throw new Error(`${n} exceeds maximum length of ${r} characters (got ${e.length})`)}get variableNames(){return this.parts.flatMap(e=>typeof e=="string"?[]:e.names)}constructor(e){t.validateLength(e,1e6,"Template"),this.template=e,this.parts=this.parse(e)}toString(){return this.template}parse(e){let r=[],n="",s=0,o=0;for(;s<e.length;)if(e[s]==="{"){n&&(r.push(n),n="");let i=e.indexOf("}",s);if(i===-1)throw new Error("Unclosed template expression");if(o++,o>1e4)throw new Error("Template contains too many expressions (max 10000)");let a=e.slice(s+1,i),c=this.getOperator(a),l=a.includes("*"),u=this.getNames(a),d=u[0];for(let f of u)t.validateLength(f,1e6,"Variable name");r.push({name:d,operator:c,names:u,exploded:l}),s=i+1}else n+=e[s],s++;return n&&r.push(n),r}getOperator(e){return["+","#",".","/","?","&"].find(n=>e.startsWith(n))||""}getNames(e){let r=this.getOperator(e);return e.slice(r.length).split(",").map(n=>n.replace("*","").trim()).filter(n=>n.length>0)}encodeValue(e,r){return t.validateLength(e,1e6,"Variable value"),r==="+"||r==="#"?encodeURI(e):encodeURIComponent(e)}expandPart(e,r){if(e.operator==="?"||e.operator==="&"){let i=e.names.map(c=>{let l=r[c];if(l===void 0)return"";let u=Array.isArray(l)?l.map(d=>this.encodeValue(d,e.operator)).join(","):this.encodeValue(l.toString(),e.operator);return`${c}=${u}`}).filter(c=>c.length>0);return i.length===0?"":(e.operator==="?"?"?":"&")+i.join("&")}if(e.names.length>1){let i=e.names.map(a=>r[a]).filter(a=>a!==void 0);return i.length===0?"":i.map(a=>Array.isArray(a)?a[0]:a).join(",")}let n=r[e.name];if(n===void 0)return"";let o=(Array.isArray(n)?n:[n]).map(i=>this.encodeValue(i,e.operator));switch(e.operator){case"":return o.join(",");case"+":return o.join(",");case"#":return"#"+o.join(",");case".":return"."+o.join(".");case"/":return"/"+o.join("/");default:return o.join(",")}}expand(e){let r="",n=!1;for(let s of this.parts){if(typeof s=="string"){r+=s;continue}let o=this.expandPart(s,e);o&&((s.operator==="?"||s.operator==="&")&&n?r+=o.replace("?","&"):r+=o,(s.operator==="?"||s.operator==="&")&&(n=!0))}return r}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}partToRegExp(e){let r=[];for(let o of e.names)t.validateLength(o,1e6,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let o=0;o<e.names.length;o++){let i=e.names[o],a=o===0?"\\"+e.operator:"&";r.push({pattern:a+this.escapeRegExp(i)+"=([^&]+)",name:i})}return r}let n,s=e.name;switch(e.operator){case"":n=e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":n="(.+)";break;case".":n="\\.([^/,]+)";break;case"/":n="/"+(e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:n="([^/]+)"}return r.push({pattern:n,name:s}),r}match(e){t.validateLength(e,1e6,"URI");let r="^",n=[];for(let a of this.parts)if(typeof a=="string")r+=this.escapeRegExp(a);else{let c=this.partToRegExp(a);for(let{pattern:l,name:u}of c)r+=l,n.push({name:u,exploded:a.exploded})}r+="$",t.validateLength(r,1e6,"Generated regex pattern");let s=new RegExp(r),o=e.match(s);if(!o)return null;let i={};for(let a=0;a<n.length;a++){let{name:c,exploded:l}=n[a],u=o[a+1],d=c.replace("*","");l&&u.includes(",")?i[d]=u.split(","):i[d]=u}return i}}});function Moe(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!joe.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,s,o)=>o.indexOf(n)===s);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function Loe(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function Rx(t){let e=Moe(t);return Loe(t,e.warnings),e.isValid}var joe,Y2=$(()=>{joe=/^[A-Za-z0-9._-]{1,128}$/});var Rm,X2=$(()=>{Rm=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let s={taskSupport:"required",...r.execution};if(s.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,s,r._meta,n)}}});var Q2=$(()=>{Yb()});var sF={};Je(sF,{McpServer:()=>Ax,ResourceTemplate:()=>zx});function rF(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function nF(t){return"_def"in t||"_zod"in t||rF(t)}function jx(t){return typeof t!="object"||t===null||nF(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(rF)}function eF(t){if(t){if(jx(t))return no(t);if(!nF(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function qoe(t){let e=fs(t);return e?Object.entries(e).map(([r,n])=>{let s=AA(n),o=zA(n);return{name:r,description:s,required:!o}}):[]}function Is(t){let r=fs(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ai(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function tF(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Ax,zx,Doe,Qu,oF=$(()=>{xx();gl();eS();uo();J2();G2();Y2();X2();Q2();Ax=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Ju(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Rm(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Is(Zl)),this.server.assertCanSetRequestHandler(Is(co)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Zl,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let s=Ri(r.inputSchema);return s?Y0(s,{strictUnions:!0,pipeStrategy:"input"}):Doe})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let s=Ri(r.outputSchema);s&&(n.outputSchema=Y0(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(co,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new j(F.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new j(F.InvalidParams,`Tool ${e.params.name} disabled`);let s=!!e.params.task,o=n.execution?.taskSupport,i="createTask"in n.handler;if((o==="required"||o==="optional")&&!i)throw new j(F.InternalError,`Tool ${e.params.name} has taskSupport '${o}' but was not registered with registerToolTask`);if(o==="required"&&!s)throw new j(F.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(o==="optional"&&!s&&i)return await this.handleAutomaticTaskPolling(n,e,r);let a=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,a,r);return s||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof j&&n.code===F.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;let o=Ri(e.inputSchema)??e.inputSchema,i=await Mp(o,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=Lp(a);throw new j(F.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return i.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new j(F.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let s=Ri(e.outputSchema),o=await Mp(s,r.structuredContent);if(!o.success){let i="error"in o?o.error:"Unknown error",a=Lp(i);throw new j(F.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(e,r,n){let s=e.handler;if("createTask"in s){if(!n.taskStore)throw new Error("No task store provided.");let i={...n,taskStore:n.taskStore};if(e.inputSchema){let a=s;return await Promise.resolve(a.createTask(r,i))}else{let a=s;return await Promise.resolve(a.createTask(i))}}if(e.inputSchema){let i=s;return await Promise.resolve(i(r,n))}else{let i=s;return await Promise.resolve(i(n))}}async handleAutomaticTaskPolling(e,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let s=await this.validateToolInput(e,r.params.arguments,r.params.name),o=e.handler,i={...n,taskStore:n.taskStore},a=s?await Promise.resolve(o.createTask(s,i)):await Promise.resolve(o.createTask(i)),c=a.task.taskId,l=a.task,u=l.pollInterval??5e3;for(;l.status!=="completed"&&l.status!=="failed"&&l.status!=="cancelled";){await new Promise(f=>setTimeout(f,u));let d=await n.taskStore.getTask(c);if(!d)throw new j(F.InternalError,`Task ${c} not found during polling`);l=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Is(Vl)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Vl,async e=>{switch(e.params.ref.type){case"ref/prompt":return g0(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return y0(e),this.handleResourceCompletion(e,e.params.ref);default:throw new j(F.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new j(F.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new j(F.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Qu;let o=fs(n.argsSchema)?.[e.params.argument.name];if(!Cx(o))return Qu;let i=W2(o);if(!i)return Qu;let a=await i(e.params.argument.value,e.params.context);return tF(a)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Qu;throw new j(F.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return Qu;let o=await s(e.params.argument.value,e.params.context);return tF(o)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Is(Ml)),this.server.assertCanSetRequestHandler(Is(Ll)),this.server.assertCanSetRequestHandler(Is(Dl)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Ml,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([o,i])=>i.enabled).map(([o,i])=>({uri:o,name:i.name,...i.metadata})),s=[];for(let o of Object.values(this._registeredResourceTemplates)){if(!o.resourceTemplate.listCallback)continue;let i=await o.resourceTemplate.listCallback(r);for(let a of i.resources)s.push({...o.metadata,...a})}return{resources:[...n,...s]}}),this.server.setRequestHandler(Ll,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Dl,async(e,r)=>{let n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new j(F.InvalidParams,`Resource ${n} disabled`);return s.readCallback(n,r)}for(let o of Object.values(this._registeredResourceTemplates)){let i=o.resourceTemplate.uriTemplate.match(n.toString());if(i)return o.readCallback(n,i,r)}throw new j(F.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Is(ql)),this.server.assertCanSetRequestHandler(Is(Fl)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(ql,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?qoe(r.argsSchema):void 0}))})),this.server.setRequestHandler(Fl,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new j(F.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new j(F.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let s=Ri(n.argsSchema),o=await Mp(s,e.params.arguments);if(!o.success){let c="error"in o?o.error:"Unknown error",l=Lp(c);throw new j(F.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${l}`)}let i=o.data,a=n.callback;return await Promise.resolve(a(i,r))}else{let s=n.callback;return await Promise.resolve(s(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let s;typeof n[0]=="object"&&(s=n.shift());let o=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(e,void 0,r,s,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,void 0,r,s,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}registerResource(e,r,n,s){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,n.title,r,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}_createRegisteredResource(e,r,n,s,o){let i={name:e,title:r,metadata:s,readCallback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=i)),typeof a.name<"u"&&(i.name=a.name),typeof a.title<"u"&&(i.title=a.title),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,s,o){let i={resourceTemplate:n,title:r,metadata:s,readCallback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:l=>{typeof l.name<"u"&&l.name!==e&&(delete this._registeredResourceTemplates[e],l.name&&(this._registeredResourceTemplates[l.name]=i)),typeof l.title<"u"&&(i.title=l.title),typeof l.template<"u"&&(i.resourceTemplate=l.template),typeof l.metadata<"u"&&(i.metadata=l.metadata),typeof l.callback<"u"&&(i.readCallback=l.callback),typeof l.enabled<"u"&&(i.enabled=l.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=i;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(l=>!!n.completeCallback(l))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,r,n,s,o){let i={title:r,description:n,argsSchema:s===void 0?void 0:no(s),callback:o,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.description<"u"&&(i.description=a.description),typeof a.argsSchema<"u"&&(i.argsSchema=no(a.argsSchema)),typeof a.callback<"u"&&(i.callback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,s&&Object.values(s).some(c=>{let l=c instanceof Up?c._def?.innerType:c;return Cx(l)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,s,o,i,a,c,l){Rx(e);let u={title:r,description:n,inputSchema:eF(s),outputSchema:eF(o),annotations:i,execution:a,_meta:c,handler:l,enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&Rx(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=u)),typeof d.title<"u"&&(u.title=d.title),typeof d.description<"u"&&(u.description=d.description),typeof d.paramsSchema<"u"&&(u.inputSchema=no(d.paramsSchema)),typeof d.outputSchema<"u"&&(u.outputSchema=no(d.outputSchema)),typeof d.callback<"u"&&(u.handler=d.callback),typeof d.annotations<"u"&&(u.annotations=d.annotations),typeof d._meta<"u"&&(u._meta=d._meta),typeof d.enabled<"u"&&(u.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=u,this.setToolRequestHandlers(),this.sendToolListChanged(),u}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,s,o,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];if(jx(c))s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!jx(r[0])&&(i=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(l=>typeof l=="object"&&l!==null))throw new Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);i=r.shift()}}let a=r[0];return this._createRegisteredTool(e,void 0,n,s,o,i,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:s,description:o,inputSchema:i,outputSchema:a,annotations:c,_meta:l}=r;return this._createRegisteredTool(e,s,o,i,a,c,{taskSupport:"forbidden"},l,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let s;r.length>1&&(s=r.shift());let o=r[0],i=this._createRegisteredPrompt(e,void 0,n,s,o);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:s,description:o,argsSchema:i}=r,a=this._createRegisteredPrompt(e,s,o,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},zx=class{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new Cm(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}},Doe={type:"object",properties:{}};Qu={completion:{values:[],hasMore:!1}}});var lF={};Je(lF,{describeUnlinked:()=>aF,projectStatus:()=>cF,runMcp:()=>Zoe});import{resolve as iF}from"node:path";var Mx,Foe,aF,cF,Zoe,uF=$(()=>{"use strict";Xu();B2();ut();ar();Mx=t=>{process.stderr.write(`[pix3 mcp] ${t}
315
- `)},Foe=3e4,aF=(t,e,r=Date.now())=>{if(t.port===null)return"The Pix3 link server could not start (every port in 8490\u20138499 is taken), so no editor window can connect to this agent session. Close other `pix3 mcp` processes and restart the agent.";if(t.projectId===null)return`${e} is not a Pix3 project with a project id (no ${xe} with \`metadata.projectId\` here or above). Create one with \`npx @pix3/cli new\`, or start the agent from the project folder.`;let n=s=>s!==null&&r-s<Foe;return n(t.lastFailedClaimAt)?`A Pix3 editor window has a project with this id open, but not THIS folder \u2014 it is a copy, another checkout or a worktree. Open ${e} itself in Pix3 (Open Folder).`:n(t.lastBrowserHelloAt)?`A Pix3 editor window can see this agent but has not connected: it has a different folder open. Open ${e} in Pix3 (Open Folder).`:`The Pix3 editor is not open on this project. Open ${e} in Pix3 (Open Folder, or Recent projects); the window connects to this agent by itself. Files can be edited meanwhile \u2014 the editor picks them up when it opens.`},cF=async t=>t.isLeased()?t.callEditor("project_status",{}):Om(aF(t.status(),t.projectDir)),Zoe=async t=>{let e=t.projectDir?iF(t.cwd,t.projectDir):Qe(t.cwd)??iF(t.cwd),[{McpServer:r},{StdioServerTransport:n}]=await Promise.all([Promise.resolve().then(()=>(oF(),sF)),Promise.resolve().then(()=>(Px(),Tx))]),s=new r({name:"pix3",version:be}),o=new Nm({projectDir:e,agent:()=>t.agent??s.server.getClientVersion()?.name??null,log:Mx});s.registerTool("project_status",{description:"Whether a Pix3 editor window is connected to this project folder, and what it reports. When none is, says what the user has to open."},async()=>cF(o));try{let l=await o.start();Mx(`link server on http://127.0.0.1:${l} for ${e} (session ${o.sessionId})`)}catch(l){Mx(l instanceof Error?l.message:String(l))}let i=!1,a=async()=>{i||(i=!0,await o.close(),await s.close().catch(()=>{}),process.exit(0))};process.on("SIGINT",()=>{a()}),process.on("SIGTERM",()=>{a()}),process.stdin.on("end",()=>{a()});let c=new n;c.onclose=()=>{a()},await s.connect(c)}});import{createHash as fF}from"node:crypto";import{createReadStream as Uoe}from"node:fs";import{lstat as Voe,readdir as Boe}from"node:fs/promises";import{join as Koe}from"node:path";var pF,hF,Cs,Hoe,Woe,Ns,Ro,Dx,Am,Lx,ed,mF,gF,Joe,qx,dF,Goe,zm=$(()=>{"use strict";Uf();pF=new Set(["node_modules",".git",".yalc",".vscode",".idea","dist","build","out","coverage",".cache"]),hF=/^\..+\.pix3-tmp-[0-9a-f]+$/,Cs=t=>{let e=t.split("/");if(e[0]===At||hF.test(e[e.length-1]))return!0;for(let r=0;r<e.length-1;r++)if(pF.has(e[r]))return!0;return!1},Hoe=(t,e)=>t===At||pF.has(e),Woe=t=>t!==At&&M_(t)||hF.test(t.slice(t.lastIndexOf("/")+1)),Ns=t=>`${t.ino}:${t.size}:${t.mtimeNs}`,Ro=t=>Number(t.mtimeNs/1000000n),Dx=t=>new Promise((e,r)=>{let n=fF("sha256"),s=Uoe(t);s.on("data",o=>n.update(o)),s.on("error",r),s.on("end",()=>e(n.digest("hex")))}),Am=class t{entries=new Map;static MAX_ENTRIES=2e5;async hash(e,r,n){let s=Ns(n),o=this.entries.get(e);if(o&&o.key===s)return o.sha256;let i=await Dx(r);return this.remember(e,s,i),i}remember(e,r,n){this.entries.size>=t.MAX_ENTRIES&&this.entries.clear(),this.entries.set(e,{key:r,sha256:n})}forget(e){this.entries.delete(e)}},Lx=t=>t&&typeof t=="object"&&"code"in t?String(t.code):void 0,ed=async(t,e,r,n,s={})=>{let o=e?Koe(t,...e.split("/")):t,i=s.internal===!0;if(i?Woe(e):e&&Cs(e))return;let a;try{a=await Voe(o,{bigint:!0})}catch(u){let d=Lx(u);if(d==="ENOENT"||d==="ENOTDIR")return;throw u}if(a.isFile()){if(!e)return;let u;try{u=await r.hash(e,o,a)}catch(d){if(Lx(d)==="ENOENT")return;throw d}n.set(e,{kind:"file",size:Number(a.size),mtime:Ro(a),statKey:Ns(a),sha256:u});return}if(!a.isDirectory())return;let c=e.slice(e.lastIndexOf("/")+1);if(!i&&e&&Hoe(e,c))return;e&&n.set(e,{kind:"dir",size:0,mtime:Ro(a),statKey:Ns(a)});let l;try{l=await Boe(o)}catch(u){let d=Lx(u);if(d==="ENOENT"||d==="ENOTDIR")return;throw u}l.sort();for(let u of l)await ed(t,e?`${e}/${u}`:u,r,n,s)},mF=async(t,e)=>{let r=new Map;return await ed(t,At,e,r,{internal:!0}),r},gF=t=>{let e=[];for(let[r,n]of t)n.kind==="file"&&n.sha256&&e.push(`${r}:${n.sha256}`);return e.sort(),fF("sha256").update(e.join(`
316
- `)).digest("hex")},Joe=(t,e)=>e===""||t===e||t.startsWith(`${e}/`),qx=(t,e,r)=>{let n=[],s=[],o=[];for(let[i,a]of[...t])e.some(c=>Joe(i,c))&&(r.has(i)||(t.delete(i),s.push(dF(i,a))));for(let[i,a]of r){let c=t.get(i);t.set(i,a),c?c.kind!==a.kind?(s.push(dF(i,c)),n.push({op:"create",path:i,kind:a.kind,...a.sha256?{sha256:a.sha256}:{}})):a.kind==="file"&&c.sha256!==a.sha256&&o.push({op:"modify",path:i,kind:"file",...a.sha256?{sha256:a.sha256}:{}}):n.push({op:"create",path:i,kind:a.kind,...a.sha256?{sha256:a.sha256}:{}})}return Goe(s,n,o)},dF=(t,e)=>({op:"delete",path:t,kind:e.kind,...e.sha256?{sha256:e.sha256}:{}}),Goe=(t,e,r)=>{let n=u=>{let d=new Map;for(let f of u)f.kind==="file"&&f.sha256&&d.set(f.sha256,(d.get(f.sha256)??0)+1);return d},s=n(t),o=n(e),i=[],a=new Set,c=new Set;for(let u of e){let d=u.sha256;if(u.kind!=="file"||!d||s.get(d)!==1||o.get(d)!==1)continue;let f=t.find(p=>p.sha256===d);f&&(a.add(f),c.add(u),i.push({op:"rename",path:u.path,from:f.path,kind:"file",sha256:d}))}let l=u=>u.op==="delete"?{op:"delete",path:u.path,kind:u.kind}:u;return[...t.filter(u=>!a.has(u)).map(l),...i,...e.filter(u=>!c.has(u)),...r].sort((u,d)=>u.path<d.path?-1:u.path>d.path?1:0)}});import{lstat as Yoe,readdir as Xoe,readFile as Qoe}from"node:fs/promises";import{join as Fx}from"node:path";var eie,tie,rie,nie,jm,yF,_F,vF,wF,bF=$(()=>{"use strict";zm();eie=5e3,tie=".pix3/recovery",rie=".pix3/merge-log.jsonl",nie=5e3,jm=class{entries=[];droppedThrough=0;record(e,r,n){for(let o of r)this.entries.push({seq:e,path:o,origin:n});let s=this.entries.length-eie;if(s>0){let o=this.entries.splice(0,s);this.droppedThrough=Math.max(this.droppedThrough,o[o.length-1].seq)}}since(e){let r=this.entries.filter(s=>s.seq>e);return{paths:[...new Set(r.map(s=>s.path))].sort(),complete:e>=this.droppedThrough,entries:r}}},yF=t=>t&&typeof t=="object"&&"code"in t?String(t.code):void 0,_F=async(t,e,r)=>{let n=`${tie}/${encodeURIComponent(e)}`,s=Fx(t,...n.split("/")),o;try{o=await Xoe(s)}catch(a){let c=yF(a);if(c==="ENOENT"||c==="ENOTDIR")return null;throw a}let i=r.slice(0,8);o.sort((a,c)=>Number(c.includes(i))-Number(a.includes(i))||(a<c?1:-1));for(let a of o){let c=Fx(s,a);try{if(!(await Yoe(c)).isFile())continue;if(await Dx(c)===r)return`${n}/${a}`}catch{}}return null},vF=async t=>{let e;try{e=await Qoe(Fx(t,...rie.split("/")),"utf8")}catch(n){if(yF(n)==="ENOENT")return[];throw n}let r=[];for(let n of e.split(`
317
- `))if(n.trim())try{let s=JSON.parse(n);s&&typeof s=="object"&&!Array.isArray(s)&&r.push(s)}catch{}return r},wF=(t,e,r,n)=>t.some(s=>{if(s.file!==e)return!1;if(r&&(s.mergedHash===r||s.hash===r))return!0;if(n===null||typeof s.at!="string")return!1;let o=Date.parse(s.at);return Number.isFinite(o)&&o>=n-nie})});var Mm,SF=$(()=>{"use strict";Tr();Mm=class{entries=new Map;ttlMs;onChange;last;constructor(e,r=gN){this.onChange=e,this.ttlMs=r,this.last=JSON.stringify(this.snapshot())}touch(e,r){let n=this.entries.get(e);n&&clearTimeout(n.timer);let s=setTimeout(()=>this.drop(e),this.ttlMs);s.unref(),this.entries.set(e,{name:r??n?.name??null,lastSeen:Date.now(),timer:s}),this.emitIfChanged()}leave(e){this.drop(e)}snapshot(){let e=null;for(let r of this.entries.values())(!e||r.lastSeen>=e.lastSeen)&&(e=r);return e?{attached:!0,agent:{name:e.name,verified:!1}}:{attached:!1,agent:null}}close(){for(let e of this.entries.values())clearTimeout(e.timer);this.entries.clear()}drop(e){let r=this.entries.get(e);r&&(clearTimeout(r.timer),this.entries.delete(e),this.emitIfChanged())}emitIfChanged(){let e=this.snapshot(),r=JSON.stringify(e);r!==this.last&&(this.last=r,this.onChange(e))}}});var Lm,$F=$(()=>{"use strict";Ic();Lm=class{root;workspaceId;limit;windowMs;failures=[];record=null;stamp=void 0;constructor(e){this.root=e.root,this.workspaceId=e.workspaceId,this.limit=e.failureLimit,this.windowMs=e.failureWindowMs}current(){let e=xN(this.root);if(e!==this.stamp){this.stamp=e;let r=Or(this.root);this.record=r&&r.workspaceId===this.workspaceId?r.token:null}return this.record}check(e){let r=Date.now();if(this.failures=this.failures.filter(s=>r-s<this.windowMs),this.failures.length>=this.limit)return{ok:!1,code:"rate_limited",retryAfter:Math.max(1,Math.ceil((this.windowMs-(r-this.failures[0]))/1e3))};let n=this.current();return n&&kN(e,n)?{ok:!0,tokenHash:n.sha256}:(this.failures.push(r),{ok:!1,code:"unauthorized"})}}});var sie,kF,xF=$(()=>{"use strict";sie={pix3scene:"text/yaml; charset=utf-8",prefab:"text/yaml; charset=utf-8",pix3anim:"text/yaml; charset=utf-8",yaml:"text/yaml; charset=utf-8",yml:"text/yaml; charset=utf-8",json:"application/json; charset=utf-8",ts:"text/plain; charset=utf-8",tsx:"text/plain; charset=utf-8",js:"text/javascript; charset=utf-8",mjs:"text/javascript; charset=utf-8",md:"text/markdown; charset=utf-8",txt:"text/plain; charset=utf-8",csv:"text/csv; charset=utf-8",atlas:"text/plain; charset=utf-8",html:"text/html; charset=utf-8",css:"text/css; charset=utf-8",xml:"application/xml; charset=utf-8",svg:"image/svg+xml",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",avif:"image/avif",ktx2:"image/ktx2",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",wav:"audio/wav",m4a:"audio/mp4",aac:"audio/aac",flac:"audio/flac",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",glb:"model/gltf-binary",gltf:"model/gltf+json",ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2",wasm:"application/wasm"},kF=t=>{let e=t.slice(t.lastIndexOf("/")+1),r=e.lastIndexOf(".");return r<=0?"application/octet-stream":sie[e.slice(r+1).toLowerCase()]??"application/octet-stream"}});var Ln=_((M0e,PF)=>{"use strict";var EF=["nodebuffer","arraybuffer","fragments"],TF=typeof Blob<"u";TF&&EF.push("blob");PF.exports={BINARY_TYPES:EF,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:TF,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var td=_((L0e,Dm)=>{"use strict";var{EMPTY_BUFFER:oie}=Ln(),Zx=Buffer[Symbol.species];function iie(t,e){if(t.length===0)return oie;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),n=0;for(let s=0;s<t.length;s++){let o=t[s];r.set(o,n),n+=o.length}return n<e?new Zx(r.buffer,r.byteOffset,n):r}function OF(t,e,r,n,s){for(let o=0;o<s;o++)r[n+o]=t[o]^e[o&3]}function IF(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function aie(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Ux(t){if(Ux.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Zx(t):ArrayBuffer.isView(t)?e=new Zx(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Ux.readOnly=!1),e}Dm.exports={concat:iie,mask:OF,toArrayBuffer:aie,toBuffer:Ux,unmask:IF};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=je("bufferutil");Dm.exports.mask=function(e,r,n,s,o){o<48?OF(e,r,n,s,o):t.mask(e,r,n,s,o)},Dm.exports.unmask=function(e,r){e.length<32?IF(e,r):t.unmask(e,r)}}catch{}});var RF=_((D0e,CF)=>{"use strict";var NF=Symbol("kDone"),Vx=Symbol("kRun"),Bx=class{constructor(e){this[NF]=()=>{this.pending--,this[Vx]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Vx]()}[Vx](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[NF])}}};CF.exports=Bx});var Ea=_((q0e,MF)=>{"use strict";var rd=je("zlib"),AF=td(),cie=RF(),{kStatusCode:zF}=Ln(),lie=Buffer[Symbol.species],uie=Buffer.from([0,0,255,255]),Fm=Symbol("permessage-deflate"),Dn=Symbol("total-length"),ka=Symbol("callback"),Rs=Symbol("buffers"),xa=Symbol("error"),qm,Kx=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!qm){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;qm=new cie(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[ka];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,n=e.find(s=>!(r.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>s.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!s.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(n.server_no_context_takeover=!0),r.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(n.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?n.client_max_window_bits=r.clientMaxWindowBits:(n.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(n=>{let s=r[n];if(s.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(s=s[0],n==="client_max_window_bits"){if(s!==!0){let o=+s;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else if(n==="server_max_window_bits"){let o=+s;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=o}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(s!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else throw new Error(`Unknown parameter "${n}"`);r[n]=s})}),e}decompress(e,r,n){qm.add(s=>{this._decompress(e,r,(o,i)=>{s(),n(o,i)})})}compress(e,r,n){qm.add(s=>{this._compress(e,r,(o,i)=>{s(),n(o,i)})})}_decompress(e,r,n){let s=this._isServer?"client":"server";if(!this._inflate){let o=`${s}_max_window_bits`,i=typeof this.params[o]!="number"?rd.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=rd.createInflateRaw({...this._options.zlibInflateOptions,windowBits:i}),this._inflate[Fm]=this,this._inflate[Dn]=0,this._inflate[Rs]=[],this._inflate.on("error",fie),this._inflate.on("data",jF)}this._inflate[ka]=n,this._inflate.write(e),r&&this._inflate.write(uie),this._inflate.flush(()=>{let o=this._inflate[xa];if(o){this._inflate.close(),this._inflate=null,n(o);return}let i=AF.concat(this._inflate[Rs],this._inflate[Dn]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Dn]=0,this._inflate[Rs]=[],r&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),n(null,i)})}_compress(e,r,n){let s=this._isServer?"server":"client";if(!this._deflate){let o=`${s}_max_window_bits`,i=typeof this.params[o]!="number"?rd.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=rd.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),this._deflate[Dn]=0,this._deflate[Rs]=[],this._deflate.on("data",die)}this._deflate[ka]=n,this._deflate.write(e),this._deflate.flush(rd.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=AF.concat(this._deflate[Rs],this._deflate[Dn]);r&&(o=new lie(o.buffer,o.byteOffset,o.length-4)),this._deflate[ka]=null,this._deflate[Dn]=0,this._deflate[Rs]=[],r&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),n(null,o)})}};MF.exports=Kx;function die(t){this[Rs].push(t),this[Dn]+=t.length}function jF(t){if(this[Dn]+=t.length,this[Fm]._maxPayload<1||this[Dn]<=this[Fm]._maxPayload){this[Rs].push(t);return}this[xa]=new RangeError("Max payload size exceeded"),this[xa].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[xa][zF]=1009,this.removeListener("data",jF),this.reset()}function fie(t){if(this[Fm]._inflate=null,this[xa]){this[ka](this[xa]);return}t[zF]=1007,this[ka](t)}});var Ta=_((F0e,Zm)=>{"use strict";var{isUtf8:LF}=je("buffer"),{hasBlob:pie}=Ln(),hie=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function mie(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Hx(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function gie(t){return pie&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Zm.exports={isBlob:gie,isValidStatusCode:mie,isValidUTF8:Hx,tokenChars:hie};if(LF)Zm.exports.isValidUTF8=function(t){return t.length<24?Hx(t):LF(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=je("utf-8-validate");Zm.exports.isValidUTF8=function(e){return e.length<32?Hx(e):t(e)}}catch{}});var Xx=_((Z0e,BF)=>{"use strict";var{Writable:yie}=je("stream"),DF=Ea(),{BINARY_TYPES:_ie,EMPTY_BUFFER:qF,kStatusCode:vie,kWebSocket:wie}=Ln(),{concat:Wx,toArrayBuffer:bie,unmask:Sie}=td(),{isValidStatusCode:$ie,isValidUTF8:FF}=Ta(),Um=Buffer[Symbol.species],br=0,ZF=1,UF=2,VF=3,Jx=4,Gx=5,Vm=6,Yx=class extends yie{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||_ie[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[wie]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=br}_write(e,r,n){if(this._opcode===8&&this._state==br)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){n(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new Um(n.buffer,n.byteOffset+e,n.length-e),new Um(n.buffer,n.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let n=this._buffers[0],s=r.length-e;e>=n.length?r.set(this._buffers.shift(),s):(r.set(new Uint8Array(n.buffer,n.byteOffset,e),s),this._buffers[0]=new Um(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case br:this.getInfo(e);break;case ZF:this.getPayloadLength16(e);break;case UF:this.getPayloadLength64(e);break;case VF:this.getMask();break;case Jx:this.getData(e);break;case Gx:case Vm:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let s=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(s);return}let n=(r[0]&64)===64;if(n&&!this._extensions[DF.extensionName]){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(!this._fragmented){let s=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let s=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(s);return}if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let s=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(s);return}}else{let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let s=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(s);return}}else if(this._masked){let s=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(s);return}this._payloadLength===126?this._state=ZF:this._payloadLength===127?this._state=UF:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),n=r.readUInt32BE(0);if(n>Math.pow(2,21)-1){let s=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(s);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=VF:this._state=Jx}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Jx}getData(e){let r=qF;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Sie(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let n=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(n);return}if(this._compressed){this._state=Gx,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[DF.extensionName].decompress(e,this._fin,(s,o)=>{if(s)return r(s);if(o.length){if(this._messageLength+=o.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let i=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(i);return}this._fragments.push(o)}this.dataMessage(r),this._state===br&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=br;return}let r=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let s;this._binaryType==="nodebuffer"?s=Wx(n,r):this._binaryType==="arraybuffer"?s=bie(Wx(n,r)):this._binaryType==="blob"?s=new Blob(n):s=n,this._allowSynchronousEvents?(this.emit("message",s,!0),this._state=br):(this._state=Vm,setImmediate(()=>{this.emit("message",s,!0),this._state=br,this.startLoop(e)}))}else{let s=Wx(n,r);if(!this._skipUTF8Validation&&!FF(s)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(o);return}this._state===Gx||this._allowSynchronousEvents?(this.emit("message",s,!1),this._state=br):(this._state=Vm,setImmediate(()=>{this.emit("message",s,!1),this._state=br,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,qF),this.end();else{let n=e.readUInt16BE(0);if(!$ie(n)){let o=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(o);return}let s=new Um(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!FF(s)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(o);return}this._loop=!1,this.emit("conclude",n,s),this.end()}this._state=br;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=br):(this._state=Vm,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=br,this.startLoop(r)}))}createError(e,r,n,s,o){this._loop=!1,this._errored=!0;let i=new e(n?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(i,this.createError),i.code=o,i[vie]=s,i}};BF.exports=Yx});var tE=_((V0e,WF)=>{"use strict";var{Duplex:U0e}=je("stream"),{randomFillSync:kie}=je("crypto"),{types:{isUint8Array:xie}}=je("util"),KF=Ea(),{EMPTY_BUFFER:Eie,kWebSocket:Tie,NOOP:Pie}=Ln(),{isBlob:Pa,isValidStatusCode:Oie}=Ta(),{mask:HF,toBuffer:Ao}=td(),Sr=Symbol("kByteLength"),Iie=Buffer.alloc(4),Bm=8*1024,zo,Oa=Bm,Hr=0,Nie=1,Cie=2,Qx=class t{constructor(e,r,n){this._extensions=r||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Hr,this.onerror=Pie,this[Tie]=void 0}static frame(e,r){let n,s=!1,o=2,i=!1;r.mask&&(n=r.maskBuffer||Iie,r.generateMask?r.generateMask(n):(Oa===Bm&&(zo===void 0&&(zo=Buffer.alloc(Bm)),kie(zo,0,Bm),Oa=0),n[0]=zo[Oa++],n[1]=zo[Oa++],n[2]=zo[Oa++],n[3]=zo[Oa++]),i=(n[0]|n[1]|n[2]|n[3])===0,o=6);let a;typeof e=="string"?(!r.mask||i)&&r[Sr]!==void 0?a=r[Sr]:(e=Buffer.from(e),a=e.length):(a=e.length,s=r.mask&&r.readOnly&&!i);let c=a;a>=65536?(o+=8,c=127):a>125&&(o+=2,c=126);let l=Buffer.allocUnsafe(s?a+o:o);return l[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(l[0]|=64),l[1]=c,c===126?l.writeUInt16BE(a,2):c===127&&(l[2]=l[3]=0,l.writeUIntBE(a,4,6)),r.mask?(l[1]|=128,l[o-4]=n[0],l[o-3]=n[1],l[o-2]=n[2],l[o-1]=n[3],i?[l,e]:s?(HF(e,n,l,o,a),[l]):(HF(e,n,e,0,a),[l,e])):[l,e]}close(e,r,n,s){let o;if(e===void 0)o=Eie;else{if(typeof e!="number"||!Oie(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(e,0);else{let a=Buffer.byteLength(r);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");if(o=Buffer.allocUnsafe(2+a),o.writeUInt16BE(e,0),typeof r=="string")o.write(r,2);else if(xie(r))o.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let i={[Sr]:o.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Hr?this.enqueue([this.dispatch,o,!1,i,s]):this.sendFrame(t.frame(o,i),s)}ping(e,r,n){let s,o;if(typeof e=="string"?(s=Buffer.byteLength(e),o=!1):Pa(e)?(s=e.size,o=!1):(e=Ao(e),s=e.length,o=Ao.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[Sr]:s,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};Pa(e)?this._state!==Hr?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(e,!1,i,n):this._state!==Hr?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(t.frame(e,i),n)}pong(e,r,n){let s,o;if(typeof e=="string"?(s=Buffer.byteLength(e),o=!1):Pa(e)?(s=e.size,o=!1):(e=Ao(e),s=e.length,o=Ao.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[Sr]:s,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};Pa(e)?this._state!==Hr?this.enqueue([this.getBlobData,e,!1,i,n]):this.getBlobData(e,!1,i,n):this._state!==Hr?this.enqueue([this.dispatch,e,!1,i,n]):this.sendFrame(t.frame(e,i),n)}send(e,r,n){let s=this._extensions[KF.extensionName],o=r.binary?2:1,i=r.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Pa(e)?(a=e.size,c=!1):(e=Ao(e),a=e.length,c=Ao.readOnly),this._firstFragment?(this._firstFragment=!1,i&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(i=a>=s._threshold),this._compress=i):(i=!1,o=0),r.fin&&(this._firstFragment=!0);let l={[Sr]:a,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:c,rsv1:i};Pa(e)?this._state!==Hr?this.enqueue([this.getBlobData,e,this._compress,l,n]):this.getBlobData(e,this._compress,l,n):this._state!==Hr?this.enqueue([this.dispatch,e,this._compress,l,n]):this.dispatch(e,this._compress,l,n)}getBlobData(e,r,n,s){this._bufferedBytes+=n[Sr],this._state=Cie,e.arrayBuffer().then(o=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(eE,this,a,s);return}this._bufferedBytes-=n[Sr];let i=Ao(o);r?this.dispatch(i,r,n,s):(this._state=Hr,this.sendFrame(t.frame(i,n),s),this.dequeue())}).catch(o=>{process.nextTick(Rie,this,o,s)})}dispatch(e,r,n,s){if(!r){this.sendFrame(t.frame(e,n),s);return}let o=this._extensions[KF.extensionName];this._bufferedBytes+=n[Sr],this._state=Nie,o.compress(e,n.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");eE(this,c,s);return}this._bufferedBytes-=n[Sr],this._state=Hr,n.readOnly=!1,this.sendFrame(t.frame(a,n),s),this.dequeue()})}dequeue(){for(;this._state===Hr&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Sr],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Sr],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};WF.exports=Qx;function eE(t,e,r){typeof r=="function"&&r(e);for(let n=0;n<t._queue.length;n++){let s=t._queue[n],o=s[s.length-1];typeof o=="function"&&o(e)}}function Rie(t,e,r){eE(t,e,r),t.onerror(e)}});var nZ=_((B0e,rZ)=>{"use strict";var{kForOnEventAttribute:nd,kListener:rE}=Ln(),JF=Symbol("kCode"),GF=Symbol("kData"),YF=Symbol("kError"),XF=Symbol("kMessage"),QF=Symbol("kReason"),Ia=Symbol("kTarget"),eZ=Symbol("kType"),tZ=Symbol("kWasClean"),qn=class{constructor(e){this[Ia]=null,this[eZ]=e}get target(){return this[Ia]}get type(){return this[eZ]}};Object.defineProperty(qn.prototype,"target",{enumerable:!0});Object.defineProperty(qn.prototype,"type",{enumerable:!0});var jo=class extends qn{constructor(e,r={}){super(e),this[JF]=r.code===void 0?0:r.code,this[QF]=r.reason===void 0?"":r.reason,this[tZ]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[JF]}get reason(){return this[QF]}get wasClean(){return this[tZ]}};Object.defineProperty(jo.prototype,"code",{enumerable:!0});Object.defineProperty(jo.prototype,"reason",{enumerable:!0});Object.defineProperty(jo.prototype,"wasClean",{enumerable:!0});var Na=class extends qn{constructor(e,r={}){super(e),this[YF]=r.error===void 0?null:r.error,this[XF]=r.message===void 0?"":r.message}get error(){return this[YF]}get message(){return this[XF]}};Object.defineProperty(Na.prototype,"error",{enumerable:!0});Object.defineProperty(Na.prototype,"message",{enumerable:!0});var sd=class extends qn{constructor(e,r={}){super(e),this[GF]=r.data===void 0?null:r.data}get data(){return this[GF]}};Object.defineProperty(sd.prototype,"data",{enumerable:!0});var Aie={addEventListener(t,e,r={}){for(let s of this.listeners(t))if(!r[nd]&&s[rE]===e&&!s[nd])return;let n;if(t==="message")n=function(o,i){let a=new sd("message",{data:i?o:o.toString()});a[Ia]=this,Km(e,this,a)};else if(t==="close")n=function(o,i){let a=new jo("close",{code:o,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[Ia]=this,Km(e,this,a)};else if(t==="error")n=function(o){let i=new Na("error",{error:o,message:o.message});i[Ia]=this,Km(e,this,i)};else if(t==="open")n=function(){let o=new qn("open");o[Ia]=this,Km(e,this,o)};else return;n[nd]=!!r[nd],n[rE]=e,r.once?this.once(t,n):this.on(t,n)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[rE]===e&&!r[nd]){this.removeListener(t,r);break}}};rZ.exports={CloseEvent:jo,ErrorEvent:Na,Event:qn,EventTarget:Aie,MessageEvent:sd};function Km(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Hm=_((K0e,sZ)=>{"use strict";var{tokenChars:od}=Ta();function pn(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function zie(t){let e=Object.create(null),r=Object.create(null),n=!1,s=!1,o=!1,i,a,c=-1,l=-1,u=-1,d=0;for(;d<t.length;d++)if(l=t.charCodeAt(d),i===void 0)if(u===-1&&od[l]===1)c===-1&&(c=d);else if(d!==0&&(l===32||l===9))u===-1&&c!==-1&&(u=d);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${d}`);u===-1&&(u=d);let p=t.slice(c,u);l===44?(pn(e,p,r),r=Object.create(null)):i=p,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${d}`);else if(a===void 0)if(u===-1&&od[l]===1)c===-1&&(c=d);else if(l===32||l===9)u===-1&&c!==-1&&(u=d);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${d}`);u===-1&&(u=d),pn(r,t.slice(c,u),!0),l===44&&(pn(e,i,r),r=Object.create(null),i=void 0),c=u=-1}else if(l===61&&c!==-1&&u===-1)a=t.slice(c,d),c=u=-1;else throw new SyntaxError(`Unexpected character at index ${d}`);else if(s){if(od[l]!==1)throw new SyntaxError(`Unexpected character at index ${d}`);c===-1?c=d:n||(n=!0),s=!1}else if(o)if(od[l]===1)c===-1&&(c=d);else if(l===34&&c!==-1)o=!1,u=d;else if(l===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${d}`);else if(l===34&&t.charCodeAt(d-1)===61)o=!0;else if(u===-1&&od[l]===1)c===-1&&(c=d);else if(c!==-1&&(l===32||l===9))u===-1&&(u=d);else if(l===59||l===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${d}`);u===-1&&(u=d);let p=t.slice(c,u);n&&(p=p.replace(/\\/g,""),n=!1),pn(r,a,p),l===44&&(pn(e,i,r),r=Object.create(null),i=void 0),a=void 0,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${d}`);if(c===-1||o||l===32||l===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=d);let f=t.slice(c,u);return i===void 0?pn(e,f,r):(a===void 0?pn(r,f,!0):n?pn(r,a,f.replace(/\\/g,"")):pn(r,a,f),pn(e,i,r)),e}function jie(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(n=>[e].concat(Object.keys(n).map(s=>{let o=n[s];return Array.isArray(o)||(o=[o]),o.map(i=>i===!0?s:`${s}=${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}sZ.exports={format:jie,parse:zie}});var Ym=_((J0e,gZ)=>{"use strict";var Mie=je("events"),Lie=je("https"),Die=je("http"),aZ=je("net"),qie=je("tls"),{randomBytes:Fie,createHash:Zie}=je("crypto"),{Duplex:H0e,Readable:W0e}=je("stream"),{URL:nE}=je("url"),As=Ea(),Uie=Xx(),Vie=tE(),{isBlob:Bie}=Ta(),{BINARY_TYPES:oZ,CLOSE_TIMEOUT:Kie,EMPTY_BUFFER:Wm,GUID:Hie,kForOnEventAttribute:sE,kListener:Wie,kStatusCode:Jie,kWebSocket:ct,NOOP:cZ}=Ln(),{EventTarget:{addEventListener:Gie,removeEventListener:Yie}}=nZ(),{format:Xie,parse:Qie}=Hm(),{toBuffer:eae}=td(),lZ=Symbol("kAborted"),oE=[8,13],Fn=["CONNECTING","OPEN","CLOSING","CLOSED"],tae=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,He=class t extends Mie{constructor(e,r,n){super(),this._binaryType=oZ[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Wm,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),uZ(this,e,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){oZ.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,n){let s=new Uie({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:n.maxBufferedChunks,maxFragments:n.maxFragments,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),o=new Vie(e,this._extensions,n.generateMask);this._receiver=s,this._sender=o,this._socket=e,s[ct]=this,o[ct]=this,e[ct]=this,s.on("conclude",sae),s.on("drain",oae),s.on("error",iae),s.on("message",aae),s.on("ping",cae),s.on("pong",lae),o.onerror=uae,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",pZ),e.on("data",Gm),e.on("end",hZ),e.on("error",mZ),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[As.extensionName]&&this._extensions[As.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){or(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),fZ(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){iE(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Wm,r,n)}pong(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){iE(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Wm,r,n)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){iE(this,e,n);return}let s={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[As.extensionName]||(s.compress=!1),this._sender.send(e||Wm,s,n)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){or(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(He,"CONNECTING",{enumerable:!0,value:Fn.indexOf("CONNECTING")});Object.defineProperty(He.prototype,"CONNECTING",{enumerable:!0,value:Fn.indexOf("CONNECTING")});Object.defineProperty(He,"OPEN",{enumerable:!0,value:Fn.indexOf("OPEN")});Object.defineProperty(He.prototype,"OPEN",{enumerable:!0,value:Fn.indexOf("OPEN")});Object.defineProperty(He,"CLOSING",{enumerable:!0,value:Fn.indexOf("CLOSING")});Object.defineProperty(He.prototype,"CLOSING",{enumerable:!0,value:Fn.indexOf("CLOSING")});Object.defineProperty(He,"CLOSED",{enumerable:!0,value:Fn.indexOf("CLOSED")});Object.defineProperty(He.prototype,"CLOSED",{enumerable:!0,value:Fn.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(He.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(He.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[sE])return e[Wie];return null},set(e){for(let r of this.listeners(t))if(r[sE]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[sE]:!0})}})});He.prototype.addEventListener=Gie;He.prototype.removeEventListener=Yie;gZ.exports=He;function uZ(t,e,r,n){let s={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Kie,protocolVersion:oE[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=s.autoPong,t._closeTimeout=s.closeTimeout,!oE.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${oE.join(", ")})`);let o;if(e instanceof nE)o=e;else try{o=new nE(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}o.protocol==="http:"?o.protocol="ws:":o.protocol==="https:"&&(o.protocol="wss:"),t._url=o.href;let i=o.protocol==="wss:",a=o.protocol==="ws+unix:",c;if(o.protocol!=="ws:"&&!i&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!o.pathname?c="The URL's pathname is empty":o.hash&&(c="The URL contains a fragment identifier"),c){let h=new SyntaxError(c);if(t._redirects===0)throw h;Jm(t,h);return}let l=i?443:80,u=Fie(16).toString("base64"),d=i?Lie.request:Die.request,f=new Set,p;if(s.createConnection=s.createConnection||(i?nae:rae),s.defaultPort=s.defaultPort||l,s.port=o.port||l,s.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,s.headers={...s.headers,"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},s.path=o.pathname+o.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(p=new As({...s.perMessageDeflate,isServer:!1,maxPayload:s.maxPayload}),s.headers["Sec-WebSocket-Extensions"]=Xie({[As.extensionName]:p.offer()})),r.length){for(let h of r){if(typeof h!="string"||!tae.test(h)||f.has(h))throw new SyntaxError("An invalid or duplicated subprotocol was specified");f.add(h)}s.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(o.username||o.password)&&(s.auth=`${o.username}:${o.password}`),a){let h=s.path.split(":");s.socketPath=h[0],s.path=h[1]}let m;if(s.followRedirects){if(t._redirects===0){t._originalIpc=a,t._originalSecure=i,t._originalHostOrSocketPath=a?s.socketPath:o.host;let h=n&&n.headers;if(n={...n,headers:{}},h)for(let[g,y]of Object.entries(h))n.headers[g.toLowerCase()]=y}else if(t.listenerCount("redirect")===0){let h=a?t._originalIpc?s.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:o.host===t._originalHostOrSocketPath;(!h||t._originalSecure&&!i)&&(delete s.headers.authorization,delete s.headers.cookie,h||delete s.headers.host,s.auth=void 0)}s.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),m=t._req=d(s),t._redirects&&t.emit("redirect",t.url,m)}else m=t._req=d(s);s.timeout&&m.on("timeout",()=>{or(t,m,"Opening handshake has timed out")}),m.on("error",h=>{m===null||m[lZ]||(m=t._req=null,Jm(t,h))}),m.on("response",h=>{let g=h.headers.location,y=h.statusCode;if(g&&s.followRedirects&&y>=300&&y<400){if(++t._redirects>s.maxRedirects){or(t,m,"Maximum redirects exceeded");return}m.abort();let w;try{w=new nE(g,e)}catch{let x=new SyntaxError(`Invalid URL: ${g}`);Jm(t,x);return}uZ(t,w,r,n)}else t.emit("unexpected-response",m,h)||or(t,m,`Unexpected server response: ${h.statusCode}`)}),m.on("upgrade",(h,g,y)=>{if(t.emit("upgrade",h),t.readyState!==He.CONNECTING)return;m=t._req=null;let w=h.headers.upgrade;if(w===void 0||w.toLowerCase()!=="websocket"){or(t,g,"Invalid Upgrade header");return}let b=Zie("sha1").update(u+Hie).digest("base64");if(h.headers["sec-websocket-accept"]!==b){or(t,g,"Invalid Sec-WebSocket-Accept header");return}let x=h.headers["sec-websocket-protocol"],v;if(x!==void 0?f.size?f.has(x)||(v="Server sent an invalid subprotocol"):v="Server sent a subprotocol but none was requested":f.size&&(v="Server sent no subprotocol"),v){or(t,g,v);return}x&&(t._protocol=x);let S=h.headers["sec-websocket-extensions"];if(S!==void 0){if(!p){or(t,g,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let T;try{T=Qie(S)}catch{or(t,g,"Invalid Sec-WebSocket-Extensions header");return}let P=Object.keys(T);if(P.length!==1||P[0]!==As.extensionName){or(t,g,"Server indicated an extension that was not requested");return}try{p.accept(T[As.extensionName])}catch{or(t,g,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[As.extensionName]=p}t.setSocket(g,y,{allowSynchronousEvents:s.allowSynchronousEvents,generateMask:s.generateMask,maxBufferedChunks:s.maxBufferedChunks,maxFragments:s.maxFragments,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),s.finishRequest?s.finishRequest(m,t):m.end()}function Jm(t,e){t._readyState=He.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function rae(t){return t.path=t.socketPath,aZ.connect(t)}function nae(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=aZ.isIP(t.host)?"":t.host),qie.connect(t)}function or(t,e,r){t._readyState=He.CLOSING;let n=new Error(r);Error.captureStackTrace(n,or),e.setHeader?(e[lZ]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Jm,t,n)):(e.destroy(n),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function iE(t,e,r){if(e){let n=Bie(e)?e.size:eae(e).length;t._socket?t._sender._bufferedBytes+=n:t._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${t.readyState} (${Fn[t.readyState]})`);process.nextTick(r,n)}}function sae(t,e){let r=this[ct];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[ct]!==void 0&&(r._socket.removeListener("data",Gm),process.nextTick(dZ,r._socket),t===1005?r.close():r.close(t,e))}function oae(){let t=this[ct];t.isPaused||t._socket.resume()}function iae(t){let e=this[ct];e._socket[ct]!==void 0&&(e._socket.removeListener("data",Gm),process.nextTick(dZ,e._socket),e.close(t[Jie])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function iZ(){this[ct].emitClose()}function aae(t,e){this[ct].emit("message",t,e)}function cae(t){let e=this[ct];e._autoPong&&e.pong(t,!this._isServer,cZ),e.emit("ping",t)}function lae(t){this[ct].emit("pong",t)}function dZ(t){t.resume()}function uae(t){let e=this[ct];e.readyState!==He.CLOSED&&(e.readyState===He.OPEN&&(e._readyState=He.CLOSING,fZ(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function fZ(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function pZ(){let t=this[ct];if(this.removeListener("close",pZ),this.removeListener("data",Gm),this.removeListener("end",hZ),t._readyState=He.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[ct]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",iZ),t._receiver.on("finish",iZ))}function Gm(t){this[ct]._receiver.write(t)||this.pause()}function hZ(){let t=this[ct];t._readyState=He.CLOSING,t._receiver.end(),this.end()}function mZ(){let t=this[ct];this.removeListener("error",mZ),this.on("error",cZ),t&&(t._readyState=He.CLOSING,this.destroy())}});var wZ=_((Y0e,vZ)=>{"use strict";var G0e=Ym(),{Duplex:dae}=je("stream");function yZ(t){t.emit("close")}function fae(){!this.destroyed&&this._writableState.finished&&this.destroy()}function _Z(t){this.removeListener("error",_Z),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function pae(t,e){let r=!0,n=new dae({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(o,i){let a=!i&&n._readableState.objectMode?o.toString():o;n.push(a)||t.pause()}),t.once("error",function(o){n.destroyed||(r=!1,n.destroy(o))}),t.once("close",function(){n.destroyed||n.push(null)}),n._destroy=function(s,o){if(t.readyState===t.CLOSED){o(s),process.nextTick(yZ,n);return}let i=!1;t.once("error",function(c){i=!0,o(c)}),t.once("close",function(){i||o(s),process.nextTick(yZ,n)}),r&&t.terminate()},n._final=function(s){if(t.readyState===t.CONNECTING){t.once("open",function(){n._final(s)});return}t._socket!==null&&(t._socket._writableState.finished?(s(),n._readableState.endEmitted&&n.destroy()):(t._socket.once("finish",function(){s()}),t.close()))},n._read=function(){t.isPaused&&t.resume()},n._write=function(s,o,i){if(t.readyState===t.CONNECTING){t.once("open",function(){n._write(s,o,i)});return}t.send(s,i)},n.on("end",fae),n.on("error",_Z),n}vZ.exports=pae});var aE=_((X0e,bZ)=>{"use strict";var{tokenChars:hae}=Ta();function mae(t){let e=new Set,r=-1,n=-1,s=0;for(s;s<t.length;s++){let i=t.charCodeAt(s);if(n===-1&&hae[i]===1)r===-1&&(r=s);else if(s!==0&&(i===32||i===9))n===-1&&r!==-1&&(n=s);else if(i===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${s}`);n===-1&&(n=s);let a=t.slice(r,n);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let o=t.slice(r,s);if(e.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return e.add(o),e}bZ.exports={parse:mae}});var PZ=_((eSe,TZ)=>{"use strict";var gae=je("events"),Xm=je("http"),{Duplex:Q0e}=je("stream"),{createHash:yae}=je("crypto"),SZ=Hm(),Mo=Ea(),_ae=aE(),vae=Ym(),{CLOSE_TIMEOUT:wae,GUID:bae,kWebSocket:Sae}=Ln(),$ae=/^[+/0-9A-Za-z]{22}==$/,$Z=0,kZ=1,EZ=2,cE=class extends gae{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:wae,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:vae,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Xm.createServer((n,s)=>{let o=Xm.STATUS_CODES[426];s.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),s.end(o)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=kae(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(s,o,i)=>{this.handleUpgrade(s,o,i,n)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=$Z}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===EZ){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(id,this);return}if(e&&this.once("close",e),this._state!==kZ)if(this._state=kZ,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(id,this):process.nextTick(id,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{id(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,n,s){r.on("error",xZ);let o=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Lo(this,e,r,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){Lo(this,e,r,400,"Invalid Upgrade header");return}if(o===void 0||!$ae.test(o)){Lo(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){Lo(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ad(r,400);return}let c=e.headers["sec-websocket-protocol"],l=new Set;if(c!==void 0)try{l=_ae.parse(c)}catch{Lo(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],d={};if(this.options.perMessageDeflate&&u!==void 0){let f=new Mo({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let p=SZ.parse(u);p[Mo.extensionName]&&(f.accept(p[Mo.extensionName]),d[Mo.extensionName]=f)}catch{Lo(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(f,(p,m,h,g)=>{if(!p)return ad(r,m||401,h,g);this.completeUpgrade(d,o,l,e,r,n,s)});return}if(!this.options.verifyClient(f))return ad(r,401)}this.completeUpgrade(d,o,l,e,r,n,s)}completeUpgrade(e,r,n,s,o,i,a){if(!o.readable||!o.writable)return o.destroy();if(o[Sae])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>$Z)return ad(o,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${yae("sha1").update(r+bae).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(n.size){let d=this.options.handleProtocols?this.options.handleProtocols(n,s):n.values().next().value;d&&(l.push(`Sec-WebSocket-Protocol: ${d}`),u._protocol=d)}if(e[Mo.extensionName]){let d=e[Mo.extensionName].params,f=SZ.format({[Mo.extensionName]:[d]});l.push(`Sec-WebSocket-Extensions: ${f}`),u._extensions=e}this.emit("headers",l,s),o.write(l.concat(`\r
435
+ `}});var qp={};X(qp,{runKitCli:()=>rE});var tE,rE,Bp=O(()=>{"use strict";Z();Is();de();Ls();Ta();tE=t=>{let e,r=!1,n=!1,s=!1;for(let i=0;i<t.length;i++){let o=t[i];if(o==="--update")r=!0;else if(o==="--migrate")n=!0;else if(o==="--help"||o==="-h")s=!0;else if(o.startsWith("--project="))e=o.slice(10);else if(o==="--project"){if(e=t[++i],!e||e.startsWith("--"))return{error:"--project needs a folder"}}else return{error:`unknown option "${o}"`}}return{projectDir:e,update:r,migrate:n,help:s}},rE=async(t,e)=>{let r=tE(t);if("error"in r)return e.stderr(`pix3 kit: ${r.error}
436
+
437
+ ${I.kit}`),2;if(r.help)return e.stdout(I.kit),0;let n=ue(e.cwd,r.projectDir);if("error"in n)return e.stderr(`pix3 kit: ${n.error}
438
+ `),2;let{root:s}=n,i=l=>e.stderr(`${l}
439
+ `),o=await Oa({log:i}),a=Ht(s)?void 0:(await Promise.resolve().then(()=>(Yr(),ks))).ensureRuntimeTypes({log:i});if(r.migrate){let{formatMigrationReport:l,migrateKit:c}=await Promise.resolve().then(()=>(Fp(),Dp));return e.stdout(l(c(s,o,{runtimeTypes:a}),s)),0}return e.stdout(zr(Xt(s,o,{update:r.update,runtimeTypes:a}),s)),0}});import{homedir as nE,tmpdir as sE}from"node:os";import{join as be}from"node:path";var Fe,Vs,Up,Gs,vt,we,Xa,tn,Kp,_t,Pe,Zt,Et,Qa,er,Za,Js,el,tl,Wp,Vp,Hs,pe=O(()=>{"use strict";Fe=(t=process.env)=>t.PIX3_HOME||be(nE(),".pix3"),Vs=(t=process.env)=>t.PIX3_CHROME_PROFILE||be(Fe(t),"chrome"),Up=()=>be(sE(),"pix3-chrome"),Gs=(t=process.env)=>be(Fe(t),"chrome.json"),vt=t=>typeof t=="number"&&Number.isInteger(t)&&t>0&&t<65536,we=9333,Xa=6,tn=(t=process.env)=>be(Fe(t),"cdp-token"),Kp=(t=process.env)=>be(Fe(t),"chrome-owner.log"),_t="/pix3",Pe=t=>`ws://127.0.0.1:${t}${_t}`,Zt=1,Et="X-Pix3-Cdp-Proxy",Qa="X-Pix3-Challenge",er="X-Pix3-Proof",Za="X-Pix3-Proof-Scope",Js="X-Pix3-Proof-Refused",el=(t=process.env)=>be(Fe(t),"cdp-forward-ports.json"),tl=(t=process.env)=>be(Fe(t),"remote-cdp-port.json"),Wp=(t=process.env)=>be(Fe(t),"remote-cdp-token"),Vp=(t=process.env)=>be(Fe(t),"remote-cdp.json"),Hs=(t=process.env)=>be(Fe(t),"cdp-mcp.json")});import{createHash as iE,createHmac as oE,randomBytes as aE,timingSafeEqual as lE}from"node:crypto";var cE,Ys,rl,nl,sl,Gp,il,ol,zs,rn=O(()=>{"use strict";pe();cE=/^[A-Za-z0-9_-]{16,128}$/,Ys=1500,rl=()=>aE(24).toString("base64url"),nl=(t,e,r,n)=>oE("sha256",iE("sha256").update(t).digest()).update(`pix3-cdp-proof/2
440
+ ${r}:${n}
441
+ ${e}`).digest("base64url"),sl=t=>{let e=t[Qa.toLowerCase()];return typeof e=="string"&&cE.test(e)?e:null},Gp=t=>t[Za.toLowerCase()]==="forward"?"forward":"local",il=(t,e)=>({[Qa]:t,[Za]:e}),ol=(t,e,r,n,s)=>{if(!t)return!1;let i=Buffer.from(nl(e,r,n,s)),o=Buffer.from(t);return o.length===i.length&&lE(o,i)},zs=async(t,e,r={})=>{let n=r.scope??"local",s=rl(),i;try{i=await(r.fetch??fetch)(`http://127.0.0.1:${t}/json/version`,{headers:il(s,n),signal:AbortSignal.timeout(Ys)}),await i.body?.cancel()}catch{return{kind:"closed"}}return ol(i.headers.get(er),e,s,n,t)?{kind:"ours"}:i.headers.get(Et)?{kind:"foreign",detail:i.headers.get(Js)?`port ${t} answers as a Pix3 CDP proxy that will not prove the token for port ${t} \u2014 your proxy not told it is forwarded there (pix3 editor --url \u2026 --remote-port ${t} on your machine), or something relaying another port`:`port ${t} is a Pix3 CDP proxy that does not know this token`}:{kind:"foreign",detail:`port ${t} is in use by something that is not a Pix3 CDP proxy (HTTP ${i.status})`}}});import{createConnection as uE}from"node:net";var Xs,dE,Qs,Jp,fE,Hp,al=O(()=>{"use strict";rn();pe();Xs=async(t,e,r)=>{try{let n=await e(t,{signal:AbortSignal.timeout(Ys),headers:r}),s=n.headers.get(Et)!==null,i=n.headers.get(er),o=null;if(n.ok)try{o=await n.json()}catch{o=null}return{status:n.status,proxy:s,proof:i,body:o}}catch{return null}},dE=t=>/\/__pix3\/(?:[?#]|$)/.test(t),Qs=async(t,e={})=>{let r=e.fetch??fetch,n=e.token??null,s=`http://127.0.0.1:${t}`,i=rl(),o=await Xs(`${s}/json/version`,r,il(i,"local"));if(o&&n&&ol(o.proof,n,i,"local",t)){let c={Authorization:`Bearer ${n}`},u=await Xs(`${s}/json/version`,r,c),f=await Xs(`${s}/json/list`,r,c);return{kind:"ours",browser:u?.body?.Browser??"unknown browser",pages:Jp(f)}}if(o?.proxy)return{kind:"foreign",browser:null,detail:`port ${t} is a Pix3 CDP proxy that does not know this token (HTTP ${o.status}): another user's, or one started with another PIX3_HOME`};if(!o?.body)return await fE(t)?{kind:"foreign",browser:null,detail:`port ${t} is in use by something that is not Chrome`}:{kind:"free"};let a=o.body.Browser??"unknown browser",l=Jp(await Xs(`${s}/json/list`,r,{}));return l.some(dE)||e.recordedPort===t?{kind:"legacy",browser:a,pages:l}:{kind:"foreign",browser:a,detail:`port ${t} is a ${a} that is not Pix3's (${l.length} page(s), none is /__pix3/)`}},Jp=t=>(Array.isArray(t?.body)?t.body:[]).filter(e=>e.type==="page"||e.type===void 0).map(e=>e.url??""),fE=t=>new Promise(e=>{let r=uE({port:t,host:"127.0.0.1"}),n=s=>{r.destroy(),e(s)};r.once("connect",()=>n(!0)),r.once("error",()=>n(!1)),r.setTimeout(Ys,()=>n(!1))}),Hp=async(t={})=>{let e=t.preferred??we,r=[];for(let n=e;n<=e+(t.range??Xa);n++){let s=await Qs(n,t);if(s.kind!=="foreign")return{port:n,state:s,skipped:r};r.push({port:n,detail:s.detail})}throw new Error(`No free debugging port between ${e} and ${e+(t.range??Xa)}:
442
+ `+r.map(n=>` ${n.detail}`).join(`
443
+ `))}});import{randomBytes as pE}from"node:crypto";import{mkdirSync as hE,readFileSync as mE,writeFileSync as Yp}from"node:fs";import{dirname as gE}from"node:path";var yE,SE,ll,cl,zp,kt,nn=O(()=>{"use strict";se();pe();yE=32,SE=/^[A-Za-z0-9_-]{32,}$/,ll=()=>pE(yE).toString("base64url"),cl=t=>{try{let e=mE(t,"utf8").trim();return SE.test(e)?e:null}catch{return null}},zp=(t=process.env)=>cl(tn(t)),kt=(t=process.env)=>{let e=tn(t),r=zp(t);if(r)return St(e),r;hE(gE(e),{recursive:!0});let n=ll();try{return Yp(e,`${n}
444
+ `,{mode:384,flag:"wx"}),n}catch(s){if(s.code!=="EEXIST")throw s;let i=zp(t);return i||(Yp(e,`${n}
445
+ `,{mode:384}),St(e),n)}}});import{accessSync as bE,constants as wE,existsSync as Xp,mkdirSync as Qp}from"node:fs";import{delimiter as xE,join as ul}from"node:path";var vE,_E,EE,Zp,eh,th,rh,dl=O(()=>{"use strict";pe();vE=["--no-first-run","--no-default-browser-check","--disable-background-timer-throttling","--disable-renderer-backgrounding","--disable-backgrounding-occluded-windows"],_E=t=>{try{return bE(t,wE.X_OK),!0}catch{return!1}},EE=(t,e)=>{for(let r of(e.PATH??"").split(xE)){if(!r)continue;let n=ul(r,t);if(_E(n))return n}return null},Zp=(t=process.env,e=process.platform)=>{if(t.PIX3_CHROME)return{kind:"binary",path:t.PIX3_CHROME};if(e==="darwin"){let r=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",ul(t.HOME??"","Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),"/Applications/Chromium.app/Contents/MacOS/Chromium"];for(let n of r)if(Xp(n))return{kind:"binary",path:n};return null}if(e==="win32"){let r=[t.PROGRAMFILES,t["PROGRAMFILES(X86)"],t.LOCALAPPDATA].filter(n=>!!n);for(let n of r){let s=ul(n,"Google","Chrome","Application","chrome.exe");if(Xp(s))return{kind:"binary",path:s}}return null}for(let r of["google-chrome","google-chrome-stable","chromium","chromium-browser","chrome"]){let n=EE(r,t);if(n)return{kind:"binary",path:n}}return null},eh=(t=process.env)=>{let e=Vs(t);try{return Qp(e,{recursive:!0}),e}catch{let r=Up();return Qp(r,{recursive:!0}),r}},th=t=>[`--user-data-dir=${t.profile}`,"--remote-debugging-pipe",...vE,...t.headless?["--headless=new",t.url]:[`--app=${t.url}`]],rh=(t=process.platform)=>["No Chrome found. Install Google Chrome (or Chromium), or point PIX3_CHROME at the binary",t==="darwin"?"(the usual place is /Applications/Google Chrome.app).":t==="win32"?"(the usual place is %ProgramFiles%\\Google\\Chrome\\Application\\chrome.exe).":"(google-chrome, chromium or chromium-browser on the PATH)."].join(" ")});var qe=x((kA,ih)=>{"use strict";var nh=["nodebuffer","arraybuffer","fragments"],sh=typeof Blob<"u";sh&&nh.push("blob");ih.exports={BINARY_TYPES:nh,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:sh,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var oh=x(()=>{throw new Error("bufferutil is not bundled")});var sn=x((TA,Zs)=>{"use strict";var{EMPTY_BUFFER:kE}=qe(),fl=Buffer[Symbol.species];function CE(t,e){if(t.length===0)return kE;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),n=0;for(let s=0;s<t.length;s++){let i=t[s];r.set(i,n),n+=i.length}return n<e?new fl(r.buffer,r.byteOffset,n):r}function ah(t,e,r,n,s){for(let i=0;i<s;i++)r[n+i]=t[i]^e[i&3]}function lh(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function OE(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function pl(t){if(pl.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new fl(t):ArrayBuffer.isView(t)?e=new fl(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),pl.readOnly=!1),e}Zs.exports={concat:CE,mask:ah,toArrayBuffer:OE,toBuffer:pl,unmask:lh};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=oh();Zs.exports.mask=function(e,r,n,s,i){i<48?ah(e,r,n,s,i):t.mask(e,r,n,s,i)},Zs.exports.unmask=function(e,r){e.length<32?lh(e,r):t.unmask(e,r)}}catch{}});var dh=x((PA,uh)=>{"use strict";var ch=Symbol("kDone"),hl=Symbol("kRun"),ml=class{constructor(e){this[ch]=()=>{this.pending--,this[hl]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[hl]()}[hl](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ch])}}};uh.exports=ml});var nr=x(($A,mh)=>{"use strict";var on=B("zlib"),fh=sn(),TE=dh(),{kStatusCode:ph}=qe(),PE=Buffer[Symbol.species],$E=Buffer.from([0,0,255,255]),ti=Symbol("permessage-deflate"),Be=Symbol("total-length"),tr=Symbol("callback"),at=Symbol("buffers"),rr=Symbol("error"),ei,gl=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ei){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ei=new TE(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[tr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,n=e.find(s=>!(r.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>s.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&(typeof s.client_max_window_bits=="number"?r.clientMaxWindowBits>s.client_max_window_bits:!s.client_max_window_bits)));if(!n)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(n.server_no_context_takeover=!0),r.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(n.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?n.client_max_window_bits=r.clientMaxWindowBits:(n.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(n=>{let s=r[n];if(s.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(s=s[0],n==="client_max_window_bits"){if(s!==!0){let i=+s;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=i}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else if(n==="server_max_window_bits"){let i=+s;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=i}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(s!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else throw new Error(`Unknown parameter "${n}"`);r[n]=s})}),e}decompress(e,r,n){ei.add(s=>{this._decompress(e,r,(i,o)=>{s(),n(i,o)})})}compress(e,r,n){ei.add(s=>{this._compress(e,r,(i,o)=>{s(),n(i,o)})})}_decompress(e,r,n){let s=this._isServer?"client":"server";if(!this._inflate){let i=`${s}_max_window_bits`,o=typeof this.params[i]!="number"?on.Z_DEFAULT_WINDOWBITS:this.params[i];this._inflate=on.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[ti]=this,this._inflate[Be]=0,this._inflate[at]=[],this._inflate.on("error",AE),this._inflate.on("data",hh)}this._inflate[tr]=n,this._inflate.write(e),r&&this._inflate.write($E),this._inflate.flush(()=>{let i=this._inflate[rr];if(i){this._inflate.close(),this._inflate=null,n(i);return}let o=fh.concat(this._inflate[at],this._inflate[Be]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Be]=0,this._inflate[at]=[],r&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),n(null,o)})}_compress(e,r,n){let s=this._isServer?"server":"client";if(!this._deflate){let i=`${s}_max_window_bits`,o=typeof this.params[i]!="number"?on.Z_DEFAULT_WINDOWBITS:this.params[i];this._deflate=on.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[Be]=0,this._deflate[at]=[],this._deflate.on("data",NE)}this._deflate[tr]=n,this._deflate.write(e),this._deflate.flush(on.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let i=fh.concat(this._deflate[at],this._deflate[Be]);r&&(i=new PE(i.buffer,i.byteOffset,i.length-4)),this._deflate[tr]=null,this._deflate[Be]=0,this._deflate[at]=[],r&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),n(null,i)})}};mh.exports=gl;function NE(t){this[at].push(t),this[Be]+=t.length}function hh(t){if(this[Be]+=t.length,this[ti]._maxPayload<1||this[Be]<=this[ti]._maxPayload){this[at].push(t);return}this[rr]=new RangeError("Max payload size exceeded"),this[rr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[rr][ph]=1009,this.removeListener("data",hh),this.reset()}function AE(t){if(this[ti]._inflate=null,this[rr]){this[tr](this[rr]);return}t[ph]=1007,this[tr](t)}});var gh=x(()=>{throw new Error("utf-8-validate is not bundled")});var sr=x((IA,ri)=>{"use strict";var{isUtf8:yh}=B("buffer"),{hasBlob:IE}=qe(),RE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function ME(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function yl(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function LE(t){return IE&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}ri.exports={isBlob:LE,isValidStatusCode:ME,isValidUTF8:yl,tokenChars:RE};if(yh)ri.exports.isValidUTF8=function(t){return t.length<24?yl(t):yh(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=gh();ri.exports.isValidUTF8=function(e){return e.length<32?yl(e):t(e)}}catch{}});var vl=x((RA,Eh)=>{"use strict";var{Writable:jE}=B("stream"),Sh=nr(),{BINARY_TYPES:DE,EMPTY_BUFFER:bh,kStatusCode:FE,kWebSocket:qE}=qe(),{concat:Sl,toArrayBuffer:BE,unmask:UE}=sn(),{isValidStatusCode:KE,isValidUTF8:wh}=sr(),ni=Buffer[Symbol.species],he=0,xh=1,vh=2,_h=3,bl=4,wl=5,si=6,xl=class extends jE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||DE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[qE]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=he}_write(e,r,n){if(this._opcode===8&&this._state==he)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){n(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new ni(n.buffer,n.byteOffset+e,n.length-e),new ni(n.buffer,n.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let n=this._buffers[0],s=r.length-e;e>=n.length?r.set(this._buffers.shift(),s):(r.set(new Uint8Array(n.buffer,n.byteOffset,e),s),this._buffers[0]=new ni(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case he:this.getInfo(e);break;case xh:this.getPayloadLength16(e);break;case vh:this.getPayloadLength64(e);break;case _h:this.getMask();break;case bl:this.getData(e);break;case wl:case si:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let s=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(s);return}let n=(r[0]&64)===64;if(n&&!this._extensions[Sh.extensionName]){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(!this._fragmented){let s=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let s=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(s);return}if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let s=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(s);return}}else{let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let s=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(s);return}}else if(this._masked){let s=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(s);return}this._payloadLength===126?this._state=xh:this._payloadLength===127?this._state=vh:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),n=r.readUInt32BE(0);if(n>Math.pow(2,21)-1){let s=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(s);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=_h:this._state=bl}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=bl}getData(e){let r=bh;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&UE(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let n=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(n);return}if(this._compressed){this._state=wl,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[Sh.extensionName].decompress(e,this._fin,(s,i)=>{if(s)return r(s);if(i.length){if(this._messageLength+=i.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(o);return}this._fragments.push(i)}this.dataMessage(r),this._state===he&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=he;return}let r=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let s;this._binaryType==="nodebuffer"?s=Sl(n,r):this._binaryType==="arraybuffer"?s=BE(Sl(n,r)):this._binaryType==="blob"?s=new Blob(n):s=n,this._allowSynchronousEvents?(this.emit("message",s,!0),this._state=he):(this._state=si,setImmediate(()=>{this.emit("message",s,!0),this._state=he,this.startLoop(e)}))}else{let s=Sl(n,r);if(!this._skipUTF8Validation&&!wh(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(i);return}this._state===wl||this._allowSynchronousEvents?(this.emit("message",s,!1),this._state=he):(this._state=si,setImmediate(()=>{this.emit("message",s,!1),this._state=he,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,bh),this.end();else{let n=e.readUInt16BE(0);if(!KE(n)){let i=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(i);return}let s=new ni(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!wh(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(i);return}this._loop=!1,this.emit("conclude",n,s),this.end()}this._state=he;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=he):(this._state=si,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=he,this.startLoop(r)}))}createError(e,r,n,s,i){this._loop=!1,this._errored=!0;let o=new e(n?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(o,this.createError),o.code=i,o[FE]=s,o}};Eh.exports=xl});var kl=x((LA,Oh)=>{"use strict";var{Duplex:MA}=B("stream"),{randomFillSync:WE}=B("crypto"),{types:{isUint8Array:VE}}=B("util"),kh=nr(),{EMPTY_BUFFER:GE,kWebSocket:JE,NOOP:HE}=qe(),{isBlob:ir,isValidStatusCode:YE}=sr(),{mask:Ch,toBuffer:Ct}=sn(),me=Symbol("kByteLength"),zE=Buffer.alloc(4),ii=8*1024,Ot,or=ii,xe=0,XE=1,QE=2,_l=class t{constructor(e,r,n){this._extensions=r||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=xe,this.onerror=HE,this[JE]=void 0}static frame(e,r){let n,s=!1,i=2,o=!1;r.mask&&(n=r.maskBuffer||zE,r.generateMask?r.generateMask(n):(or===ii&&(Ot===void 0&&(Ot=Buffer.alloc(ii)),WE(Ot,0,ii),or=0),n[0]=Ot[or++],n[1]=Ot[or++],n[2]=Ot[or++],n[3]=Ot[or++]),o=(n[0]|n[1]|n[2]|n[3])===0,i=6);let a;typeof e=="string"?(!r.mask||o)&&r[me]!==void 0?a=r[me]:(e=Buffer.from(e),a=e.length):(a=e.length,s=r.mask&&r.readOnly&&!o);let l=a;a>=65536?(i+=8,l=127):a>125&&(i+=2,l=126);let c=Buffer.allocUnsafe(s?a+i:i);return c[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(c[0]|=64),c[1]=l,l===126?c.writeUInt16BE(a,2):l===127&&(c[2]=c[3]=0,c.writeUIntBE(a,4,6)),r.mask?(c[1]|=128,c[i-4]=n[0],c[i-3]=n[1],c[i-2]=n[2],c[i-1]=n[3],o?[c,e]:s?(Ch(e,n,c,i,a),[c]):(Ch(e,n,e,0,a),[c,e])):[c,e]}close(e,r,n,s){let i;if(e===void 0)i=GE;else{if(typeof e!="number"||!YE(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0);else{let a=Buffer.byteLength(r);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");if(i=Buffer.allocUnsafe(2+a),i.writeUInt16BE(e,0),typeof r=="string")i.write(r,2);else if(VE(r))i.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[me]:i.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==xe?this.enqueue([this.dispatch,i,!1,o,s]):this.sendFrame(t.frame(i,o),s)}ping(e,r,n){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):ir(e)?(s=e.size,i=!1):(e=Ct(e),s=e.length,i=Ct.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[me]:s,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};ir(e)?this._state!==xe?this.enqueue([this.getBlobData,e,!1,o,n]):this.getBlobData(e,!1,o,n):this._state!==xe?this.enqueue([this.dispatch,e,!1,o,n]):this.sendFrame(t.frame(e,o),n)}pong(e,r,n){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):ir(e)?(s=e.size,i=!1):(e=Ct(e),s=e.length,i=Ct.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[me]:s,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};ir(e)?this._state!==xe?this.enqueue([this.getBlobData,e,!1,o,n]):this.getBlobData(e,!1,o,n):this._state!==xe?this.enqueue([this.dispatch,e,!1,o,n]):this.sendFrame(t.frame(e,o),n)}send(e,r,n){let s=this._extensions[kh.extensionName],i=r.binary?2:1,o=r.compress,a,l;typeof e=="string"?(a=Buffer.byteLength(e),l=!1):ir(e)?(a=e.size,l=!1):(e=Ct(e),a=e.length,l=Ct.readOnly),this._firstFragment?(this._firstFragment=!1,o&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=s._threshold),this._compress=o):(o=!1,i=0),r.fin&&(this._firstFragment=!0);let c={[me]:a,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:l,rsv1:o};ir(e)?this._state!==xe?this.enqueue([this.getBlobData,e,this._compress,c,n]):this.getBlobData(e,this._compress,c,n):this._state!==xe?this.enqueue([this.dispatch,e,this._compress,c,n]):this.dispatch(e,this._compress,c,n)}getBlobData(e,r,n,s){this._bufferedBytes+=n[me],this._state=QE,e.arrayBuffer().then(i=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(El,this,a,s);return}this._bufferedBytes-=n[me];let o=Ct(i);r?this.dispatch(o,r,n,s):(this._state=xe,this.sendFrame(t.frame(o,n),s),this.dequeue())}).catch(i=>{process.nextTick(ZE,this,i,s)})}dispatch(e,r,n,s){if(!r){this.sendFrame(t.frame(e,n),s);return}let i=this._extensions[kh.extensionName];this._bufferedBytes+=n[me],this._state=XE,i.compress(e,n.fin,(o,a)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");El(this,l,s);return}this._bufferedBytes-=n[me],this._state=xe,n.readOnly=!1,this.sendFrame(t.frame(a,n),s),this.dequeue()})}dequeue(){for(;this._state===xe&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][me],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][me],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};Oh.exports=_l;function El(t,e,r){typeof r=="function"&&r(e);for(let n=0;n<t._queue.length;n++){let s=t._queue[n],i=s[s.length-1];typeof i=="function"&&i(e)}}function ZE(t,e,r){El(t,e,r),t.onerror(e)}});var Lh=x((jA,Mh)=>{"use strict";var{kForOnEventAttribute:an,kListener:Cl}=qe(),Th=Symbol("kCode"),Ph=Symbol("kData"),$h=Symbol("kError"),Nh=Symbol("kMessage"),Ah=Symbol("kReason"),ar=Symbol("kTarget"),Ih=Symbol("kType"),Rh=Symbol("kWasClean"),Ue=class{constructor(e){this[ar]=null,this[Ih]=e}get target(){return this[ar]}get type(){return this[Ih]}};Object.defineProperty(Ue.prototype,"target",{enumerable:!0});Object.defineProperty(Ue.prototype,"type",{enumerable:!0});var Tt=class extends Ue{constructor(e,r={}){super(e),this[Th]=r.code===void 0?0:r.code,this[Ah]=r.reason===void 0?"":r.reason,this[Rh]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Th]}get reason(){return this[Ah]}get wasClean(){return this[Rh]}};Object.defineProperty(Tt.prototype,"code",{enumerable:!0});Object.defineProperty(Tt.prototype,"reason",{enumerable:!0});Object.defineProperty(Tt.prototype,"wasClean",{enumerable:!0});var lr=class extends Ue{constructor(e,r={}){super(e),this[$h]=r.error===void 0?null:r.error,this[Nh]=r.message===void 0?"":r.message}get error(){return this[$h]}get message(){return this[Nh]}};Object.defineProperty(lr.prototype,"error",{enumerable:!0});Object.defineProperty(lr.prototype,"message",{enumerable:!0});var ln=class extends Ue{constructor(e,r={}){super(e),this[Ph]=r.data===void 0?null:r.data}get data(){return this[Ph]}};Object.defineProperty(ln.prototype,"data",{enumerable:!0});var ek={addEventListener(t,e,r={}){for(let s of this.listeners(t))if(!r[an]&&s[Cl]===e&&!s[an])return;let n;if(t==="message")n=function(i,o){let a=new ln("message",{data:o?i:i.toString()});a[ar]=this,oi(e,this,a)};else if(t==="close")n=function(i,o){let a=new Tt("close",{code:i,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[ar]=this,oi(e,this,a)};else if(t==="error")n=function(i){let o=new lr("error",{error:i,message:i.message});o[ar]=this,oi(e,this,o)};else if(t==="open")n=function(){let i=new Ue("open");i[ar]=this,oi(e,this,i)};else return;n[an]=!!r[an],n[Cl]=e,r.once?this.once(t,n):this.on(t,n)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Cl]===e&&!r[an]){this.removeListener(t,r);break}}};Mh.exports={CloseEvent:Tt,ErrorEvent:lr,Event:Ue,EventTarget:ek,MessageEvent:ln};function oi(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var ai=x((DA,jh)=>{"use strict";var{tokenChars:cn}=sr();function $e(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function tk(t){let e=Object.create(null),r=Object.create(null),n=!1,s=!1,i=!1,o,a,l=-1,c=-1,u=-1,f=0;for(;f<t.length;f++)if(c=t.charCodeAt(f),o===void 0)if(u===-1&&cn[c]===1)l===-1&&(l=f);else if(f!==0&&(c===32||c===9))u===-1&&l!==-1&&(u=f);else if(c===59||c===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f);let h=t.slice(l,u);c===44?($e(e,h,r),r=Object.create(null)):o=h,l=u=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);else if(a===void 0)if(u===-1&&cn[c]===1)l===-1&&(l=f);else if(c===32||c===9)u===-1&&l!==-1&&(u=f);else if(c===59||c===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f),$e(r,t.slice(l,u),!0),c===44&&($e(e,o,r),r=Object.create(null),o=void 0),l=u=-1}else if(c===61&&l!==-1&&u===-1)a=t.slice(l,f),l=u=-1;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(s){if(cn[c]!==1)throw new SyntaxError(`Unexpected character at index ${f}`);l===-1?l=f:n||(n=!0),s=!1}else if(i)if(cn[c]===1)l===-1&&(l=f);else if(c===34&&l!==-1)i=!1,u=f;else if(c===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${f}`);else if(c===34&&t.charCodeAt(f-1)===61)i=!0;else if(u===-1&&cn[c]===1)l===-1&&(l=f);else if(l!==-1&&(c===32||c===9))u===-1&&(u=f);else if(c===59||c===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${f}`);u===-1&&(u=f);let h=t.slice(l,u);n&&(h=h.replace(/\\/g,""),n=!1),$e(r,a,h),c===44&&($e(e,o,r),r=Object.create(null),o=void 0),a=void 0,l=u=-1}else throw new SyntaxError(`Unexpected character at index ${f}`);if(l===-1||i||c===32||c===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=f);let d=t.slice(l,u);return o===void 0?$e(e,d,r):(a===void 0?$e(r,d,!0):n?$e(r,a,d.replace(/\\/g,"")):$e(r,a,d),$e(e,o,r)),e}function rk(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(n=>[e].concat(Object.keys(n).map(s=>{let i=n[s];return Array.isArray(i)||(i=[i]),i.map(o=>o===!0?s:`${s}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}jh.exports={format:rk,parse:tk}});var di=x((BA,Yh)=>{"use strict";var nk=B("events"),sk=B("https"),ik=B("http"),qh=B("net"),ok=B("tls"),{randomBytes:ak,createHash:lk}=B("crypto"),{Duplex:FA,Readable:qA}=B("stream"),{URL:Ol}=B("url"),lt=nr(),ck=vl(),uk=kl(),{isBlob:dk}=sr(),{BINARY_TYPES:Dh,CLOSE_TIMEOUT:fk,EMPTY_BUFFER:li,GUID:pk,kForOnEventAttribute:Tl,kListener:hk,kStatusCode:mk,kWebSocket:H,NOOP:Bh}=qe(),{EventTarget:{addEventListener:gk,removeEventListener:yk}}=Lh(),{format:Sk,parse:bk}=ai(),{toBuffer:wk}=sn(),Uh=Symbol("kAborted"),Pl=[8,13],Ke=["CONNECTING","OPEN","CLOSING","CLOSED"],xk=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,q=class t extends nk{constructor(e,r,n){super(),this._binaryType=Dh[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=li,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?!n||n.protocols===void 0?r=[]:Array.isArray(n.protocols)?r=n.protocols:r=[n.protocols]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,n.protocols===void 0?r=[]:Array.isArray(n.protocols)?r=n.protocols:r=[n.protocols]):r=[r]),Kh(this,e,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Dh.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,n){let s=new ck({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:n.maxBufferedChunks,maxFragments:n.maxFragments,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),i=new uk(e,this._extensions,n.generateMask);this._receiver=s,this._sender=i,this._socket=e,s[H]=this,i[H]=this,e[H]=this,s.on("conclude",Ek),s.on("drain",kk),s.on("error",Ck),s.on("message",Ok),s.on("ping",Tk),s.on("pong",Pk),i.onerror=$k,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Gh),e.on("data",ui),e.on("end",Jh),e.on("error",Hh),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[lt.extensionName]&&this._extensions[lt.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ae(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._sender.close(e,r,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._readyState=t.CLOSING,Vh(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){$l(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||li,r,n)}pong(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){$l(this,e,n);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||li,r,n)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,n){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){$l(this,e,n);return}let s={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[lt.extensionName]||(s.compress=!1),this._sender.send(e||li,s,n)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ae(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(q,"CONNECTING",{enumerable:!0,value:Ke.indexOf("CONNECTING")});Object.defineProperty(q.prototype,"CONNECTING",{enumerable:!0,value:Ke.indexOf("CONNECTING")});Object.defineProperty(q,"OPEN",{enumerable:!0,value:Ke.indexOf("OPEN")});Object.defineProperty(q.prototype,"OPEN",{enumerable:!0,value:Ke.indexOf("OPEN")});Object.defineProperty(q,"CLOSING",{enumerable:!0,value:Ke.indexOf("CLOSING")});Object.defineProperty(q.prototype,"CLOSING",{enumerable:!0,value:Ke.indexOf("CLOSING")});Object.defineProperty(q,"CLOSED",{enumerable:!0,value:Ke.indexOf("CLOSED")});Object.defineProperty(q.prototype,"CLOSED",{enumerable:!0,value:Ke.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(q.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(q.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Tl])return e[hk];return null},set(e){for(let r of this.listeners(t))if(r[Tl]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Tl]:!0})}})});q.prototype.addEventListener=gk;q.prototype.removeEventListener=yk;Yh.exports=q;function Kh(t,e,r,n){let s={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:fk,protocolVersion:Pl[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,protocols:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=s.autoPong,t._closeTimeout=s.closeTimeout,!Pl.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${Pl.join(", ")})`);let i;if(e instanceof Ol)i=e;else try{i=new Ol(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}i.protocol==="http:"?i.protocol="ws:":i.protocol==="https:"&&(i.protocol="wss:"),t._url=i.href;let o=i.protocol==="wss:",a=i.protocol==="ws+unix:",l;if(i.protocol!=="ws:"&&!o&&!a?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!i.pathname?l="The URL's pathname is empty":i.hash&&(l="The URL contains a fragment identifier"),l){let p=new SyntaxError(l);if(t._redirects===0)throw p;ci(t,p);return}let c=o?443:80,u=ak(16).toString("base64"),f=o?sk.request:ik.request,d=new Set,h;if(s.createConnection=s.createConnection||(o?_k:vk),s.defaultPort=s.defaultPort||c,s.port=i.port||c,s.host=i.hostname.startsWith("[")?i.hostname.slice(1,-1):i.hostname,s.headers={...s.headers,"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},s.path=i.pathname+i.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(h=new lt({...s.perMessageDeflate,isServer:!1,maxPayload:s.maxPayload}),s.headers["Sec-WebSocket-Extensions"]=Sk({[lt.extensionName]:h.offer()})),r.length){for(let p of r){if(typeof p!="string"||!xk.test(p)||d.has(p))throw new SyntaxError("An invalid or duplicated subprotocol was specified");d.add(p)}s.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(i.username||i.password)&&(s.auth=`${i.username}:${i.password}`),a){let p=s.path.split(":");s.socketPath=p[0],s.path=p[1]}let g;if(s.followRedirects){if(t._redirects===0){t._originalIpc=a,t._originalSecure=o,t._originalHostOrSocketPath=a?s.socketPath:i.host;let p=n&&n.headers;if(n={...n,headers:{}},p)for(let[m,y]of Object.entries(p))n.headers[m.toLowerCase()]=y}else if(t.listenerCount("redirect")===0){let p=a?t._originalIpc?s.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:i.host===t._originalHostOrSocketPath;(!p||t._originalSecure&&!o)&&(delete s.headers.authorization,delete s.headers.cookie,p||delete s.headers.host,s.auth=void 0)}s.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),g=t._req=f(s),t._redirects&&t.emit("redirect",t.url,g)}else g=t._req=f(s);s.timeout&&g.on("timeout",()=>{ae(t,g,"Opening handshake has timed out")}),g.on("error",p=>{g===null||g[Uh]||(g=t._req=null,ci(t,p))}),g.on("response",p=>{let m=p.headers.location,y=p.statusCode;if(m&&s.followRedirects&&y>=300&&y<400){if(++t._redirects>s.maxRedirects){ae(t,g,"Maximum redirects exceeded");return}g.abort();let w;try{w=new Ol(m,e)}catch{let v=new SyntaxError(`Invalid URL: ${m}`);ci(t,v);return}Kh(t,w,r,n)}else t.emit("unexpected-response",g,p)||ae(t,g,`Unexpected server response: ${p.statusCode}`)}),g.on("upgrade",(p,m,y)=>{if(t.emit("upgrade",p),t.readyState!==q.CONNECTING)return;g=t._req=null;let w=p.headers.upgrade;if(w===void 0||w.toLowerCase()!=="websocket"){ae(t,m,"Invalid Upgrade header");return}let _=lk("sha1").update(u+pk).digest("base64");if(p.headers["sec-websocket-accept"]!==_){ae(t,m,"Invalid Sec-WebSocket-Accept header");return}let v=p.headers["sec-websocket-protocol"],E;if(v!==void 0?d.size?d.has(v)||(E="Server sent an invalid subprotocol"):E="Server sent a subprotocol but none was requested":d.size&&(E="Server sent no subprotocol"),E){ae(t,m,E);return}v&&(t._protocol=v);let k=p.headers["sec-websocket-extensions"];if(k!==void 0){if(!h){ae(t,m,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let T;try{T=bk(k)}catch{ae(t,m,"Invalid Sec-WebSocket-Extensions header");return}let S=Object.keys(T);if(S.length!==1||S[0]!==lt.extensionName){ae(t,m,"Server indicated an extension that was not requested");return}try{h.accept(T[lt.extensionName])}catch{ae(t,m,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[lt.extensionName]=h}t.setSocket(m,y,{allowSynchronousEvents:s.allowSynchronousEvents,generateMask:s.generateMask,maxBufferedChunks:s.maxBufferedChunks,maxFragments:s.maxFragments,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),s.finishRequest?s.finishRequest(g,t):g.end()}function ci(t,e){t._readyState=q.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function vk(t){return t.path=t.socketPath,qh.connect(t)}function _k(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=qh.isIP(t.host)?"":t.host),ok.connect(t)}function ae(t,e,r){t._readyState=q.CLOSING;let n=new Error(r);Error.captureStackTrace(n,ae),e.setHeader?(e[Uh]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(ci,t,n)):(e.destroy(n),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function $l(t,e,r){if(e){let n=dk(e)?e.size:wk(e).length;t._socket?t._sender._bufferedBytes+=n:t._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${t.readyState} (${Ke[t.readyState]})`);process.nextTick(r,n)}}function Ek(t,e){let r=this[H];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[H]!==void 0&&(r._socket.removeListener("data",ui),process.nextTick(Wh,r._socket),t===1005?r.close():r.close(t,e))}function kk(){let t=this[H];t.isPaused||t._socket.resume()}function Ck(t){let e=this[H];e._socket[H]!==void 0&&(e._socket.removeListener("data",ui),process.nextTick(Wh,e._socket),e.close(t[mk])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Fh(){this[H].emitClose()}function Ok(t,e){this[H].emit("message",t,e)}function Tk(t){let e=this[H];e._autoPong&&e.pong(t,!this._isServer,Bh),e.emit("ping",t)}function Pk(t){this[H].emit("pong",t)}function Wh(t){t.resume()}function $k(t){let e=this[H];e.readyState!==q.CLOSED&&(e.readyState===q.OPEN&&(e._readyState=q.CLOSING,Vh(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Vh(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Gh(){let t=this[H];if(this.removeListener("close",Gh),this.removeListener("data",ui),this.removeListener("end",Jh),t._readyState=q.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[H]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Fh),t._receiver.on("finish",Fh))}function ui(t){this[H]._receiver.write(t)||this.pause()}function Jh(){let t=this[H];t._readyState=q.CLOSING,t._receiver.end(),this.end()}function Hh(){let t=this[H];this.removeListener("error",Hh),this.on("error",Bh),t&&(t._readyState=q.CLOSING,this.destroy())}});var Zh=x((KA,Qh)=>{"use strict";var UA=di(),{Duplex:Nk}=B("stream");function zh(t){t.emit("close")}function Ak(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Xh(t){this.removeListener("error",Xh),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Ik(t,e){let r=!0,n=new Nk({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(i,o){let a=!o&&n._readableState.objectMode?i.toString():i;n.push(a)||t.pause()}),t.once("error",function(i){n.destroyed||(r=!1,n.destroy(i))}),t.once("close",function(){n.destroyed||n.push(null)}),n._destroy=function(s,i){if(t.readyState===t.CLOSED){i(s),process.nextTick(zh,n);return}let o=!1;t.once("error",function(l){o=!0,i(l)}),t.once("close",function(){o||i(s),process.nextTick(zh,n)}),r&&t.terminate()},n._final=function(s){if(t.readyState===t.CONNECTING){t.once("open",function(){n._final(s)});return}t._socket!==null&&(t._socket._writableState.finished?(s(),n._readableState.endEmitted&&n.destroy()):(t._socket.once("finish",function(){s()}),t.close()))},n._read=function(){t.isPaused&&t.resume()},n._write=function(s,i,o){if(t.readyState===t.CONNECTING){t.once("open",function(){n._write(s,i,o)});return}t.send(s,o)},n.on("end",Ak),n.on("error",Xh),n}Qh.exports=Ik});var Nl=x((WA,em)=>{"use strict";var{tokenChars:Rk}=sr();function Mk(t){let e=new Set,r=-1,n=-1,s=0;for(s;s<t.length;s++){let o=t.charCodeAt(s);if(n===-1&&Rk[o]===1)r===-1&&(r=s);else if(s!==0&&(o===32||o===9))n===-1&&r!==-1&&(n=s);else if(o===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${s}`);n===-1&&(n=s);let a=t.slice(r,n);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let i=t.slice(r,s);if(e.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);return e.add(i),e}em.exports={parse:Mk}});var am=x((GA,om)=>{"use strict";var Lk=B("events"),fi=B("http"),{Duplex:VA}=B("stream"),{createHash:jk}=B("crypto"),tm=ai(),Pt=nr(),Dk=Nl(),Fk=di(),{CLOSE_TIMEOUT:qk,GUID:Bk,kWebSocket:Uk}=qe(),Kk=/^[+/0-9A-Za-z]{22}==$/,rm=0,nm=1,im=2,Al=class extends Lk{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:qk,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Fk,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=fi.createServer((n,s)=>{let i=fi.STATUS_CODES[426];s.writeHead(426,{"Content-Length":i.length,"Content-Type":"text/plain"}),s.end(i)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=Wk(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(s,i,o)=>{this.handleUpgrade(s,i,o,n)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=rm}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===im){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(un,this);return}if(e&&this.once("close",e),this._state!==nm)if(this._state=nm,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(un,this):process.nextTick(un,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{un(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,n,s){r.on("error",sm);let i=e.headers["sec-websocket-key"],o=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){$t(this,e,r,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){$t(this,e,r,400,"Invalid Upgrade header");return}if(i===void 0||!Kk.test(i)){$t(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){$t(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){dn(r,400);return}let l=e.headers["sec-websocket-protocol"],c=new Set;if(l!==void 0)try{c=Dk.parse(l)}catch{$t(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],f={};if(this.options.perMessageDeflate&&u!==void 0){let d=new Pt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let h=tm.parse(u);h[Pt.extensionName]&&(d.accept(h[Pt.extensionName]),f[Pt.extensionName]=d)}catch{$t(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let d={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(d,(h,g,p,m)=>{if(!h)return dn(r,g||401,p,m);this.completeUpgrade(f,i,c,e,r,n,s)});return}if(!this.options.verifyClient(d))return dn(r,401)}this.completeUpgrade(f,i,c,e,r,n,s)}completeUpgrade(e,r,n,s,i,o,a){if(!i.readable||!i.writable)return i.destroy();if(i[Uk])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>rm)return dn(i,503);let c=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${jk("sha1").update(r+Bk).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(n.size){let f=this.options.handleProtocols?this.options.handleProtocols(n,s):n.values().next().value;f&&(c.push(`Sec-WebSocket-Protocol: ${f}`),u._protocol=f)}if(e[Pt.extensionName]){let f=e[Pt.extensionName].params,d=tm.format({[Pt.extensionName]:[f]});c.push(`Sec-WebSocket-Extensions: ${d}`),u._extensions=e}this.emit("headers",c,s),i.write(c.concat(`\r
318
446
  `).join(`\r
319
- `)),o.removeListener("error",xZ),u.setSocket(o,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&!this.clients.size&&process.nextTick(id,this)})),a(u,s)}};TZ.exports=cE;function kae(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let n of Object.keys(e))t.removeListener(n,e[n])}}function id(t){t._state=EZ,t.emit("close")}function xZ(){this.destroy()}function ad(t,e,r,n){r=r||Xm.STATUS_CODES[e],n={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...n},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${Xm.STATUS_CODES[e]}\r
447
+ `)),i.removeListener("error",sm),u.setSocket(i,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&!this.clients.size&&process.nextTick(un,this)})),a(u,s)}};om.exports=Al;function Wk(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let n of Object.keys(e))t.removeListener(n,e[n])}}function un(t){t._state=im,t.emit("close")}function sm(){this.destroy()}function dn(t,e,r,n){r=r||fi.STATUS_CODES[e],n={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...n},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${fi.STATUS_CODES[e]}\r
320
448
  `+Object.keys(n).map(s=>`${s}: ${n[s]}`).join(`\r
321
449
  `)+`\r
322
450
  \r
323
- `+r)}function Lo(t,e,r,n,s,o){if(t.listenerCount("wsClientError")){let i=new Error(s);Error.captureStackTrace(i,Lo),t.emit("wsClientError",i,r,e)}else ad(r,n,s,o)}});var xae,Eae,Tae,Pae,Oae,Iae,Nae,lE,OZ=$(()=>{xae=Ze(wZ(),1),Eae=Ze(Hm(),1),Tae=Ze(Ea(),1),Pae=Ze(Xx(),1),Oae=Ze(tE(),1),Iae=Ze(aE(),1),Nae=Ze(Ym(),1),lE=Ze(PZ(),1)});import{randomUUID as Cae}from"node:crypto";var cd,Rae,Aae,zae,jae,Mae,Qm,IZ=$(()=>{"use strict";OZ();Xu();Tr();Pc();cd=4401,Rae=4429,Aae=1003,zae=1001,jae=4409,Mae=64*1024*1024,Qm=class{options;wss=new lE.default({noServer:!0,maxPayload:Mae,perMessageDeflate:!1});clients=new Set;relay=new $a;lease=null;closed=!1;constructor(e){this.options=e,this.relay.setParkListener(()=>this.flushCalls())}handleUpgrade(e,r,n){let s=(a,c,l)=>{this.options.log(`events: upgrade refused ${a} (${l})`),r.write(`HTTP/1.1 ${a} ${c}\r
451
+ `+r)}function $t(t,e,r,n,s,i){if(t.listenerCount("wsClientError")){let o=new Error(s);Error.captureStackTrace(o,$t),t.emit("wsClientError",o,r,e)}else dn(r,n,s,i)}});var Vk,Gk,Jk,Hk,Yk,zk,lm,Il,cm,Rl=O(()=>{Vk=U(Zh(),1),Gk=U(ai(),1),Jk=U(nr(),1),Hk=U(vl(),1),Yk=U(kl(),1),zk=U(Nl(),1),lm=U(di(),1),Il=U(am(),1),cm=lm.default});import{createHash as Xk,timingSafeEqual as Qk}from"node:crypto";import{createServer as Zk}from"node:http";var eC,dm,tC,Ml,um,rC,pi,fm=O(()=>{"use strict";Rl();rn();pe();eC=256*1024*1024,dm=(t,e)=>{let r=[],n=[],s=[],i=!1;e.on("data",a=>{let l=0;for(let c=a.indexOf(0,l);c>=0;c=a.indexOf(0,l)){s.push(a.subarray(l,c));let u=Buffer.concat(s).toString("utf8");s=[];for(let f of r)f(u);l=c+1}l<a.length&&s.push(a.subarray(l))});let o=()=>{if(!i){i=!0;for(let a of n)a()}};return e.on("end",o),e.on("close",o),e.on("error",o),t.on("error",o),{send:a=>{i||t.write(`${a}\0`)},onMessage:a=>{r.push(a)},onClose:a=>{n.push(a)}}},tC=new Set(["127.0.0.1","localhost","[::1]"]),Ml=(t,e,r)=>{t.close(e,r),setTimeout(()=>t.terminate(),1e3).unref()},um=t=>Xk("sha256").update(t).digest(),rC=t=>{let e=/:(\d{1,5})$/.exec(t??""),r=e?Number(e[1]):NaN;return r>0&&r<65536?r:null},pi=class{#a;#f;#p;#n;#h;#l=0;#e;#c;#s=new Map;#t=new Map;#r=new Set;#m=[];#g=1;#i=!1;#d=null;constructor(e){this.#a=e.pipe,this.#f=um(e.token),this.#p=e.token,this.#n=e.log??(()=>{}),this.#h=e.forwardPorts??(()=>[]),this.#c=new Il.default({noServer:!0,perMessageDeflate:!1,maxPayload:eC}),this.#e=Zk((r,n)=>{this.#b(r,n)}),this.#e.on("upgrade",(r,n,s)=>{this.#v(r,n,s)}),this.#a.onMessage(r=>this.#k(r)),this.#a.onClose(()=>this.#O())}get clientCount(){return this.#r.size}listen(e,r="127.0.0.1"){return new Promise((n,s)=>{this.#e.once("error",s),this.#e.listen(e,r,()=>{this.#e.off("error",s);let i=this.#e.address();this.#l=typeof i=="object"&&i?i.port:e,n(this.#l)})})}onClose(e){this.#m.push(e)}call(e,r={},n){return new Promise((s,i)=>{if(this.#i){i(new Error(`${e}: Chrome is gone`));return}let o=this.#g++;this.#s.set(o,{internal:a=>a.error?i(new Error(`${e}: ${a.error.message}`)):s(a.result??{})}),this.#a.send(JSON.stringify({id:o,method:e,params:r,...n?{sessionId:n}:{}}))})}async close(){for(let e of[...this.#r])this.#u(e,!this.#i),Ml(e.socket,1001,"proxy closing");await new Promise(e=>{this.#e.close(()=>e()),this.#e.closeAllConnections()}),this.#c.close()}#y(e){if(e.headers.origin!==void 0)return{status:403,message:"CDP is not open to web pages (Origin header present)"};let r=(e.headers.host??"").toLowerCase(),n=r.startsWith("[")?r.slice(0,r.indexOf("]")+1):r.split(":")[0];if(!tC.has(n))return{status:403,message:`Host "${r}" is not a loopback address`};let s=/^Bearer\s+(\S+)\s*$/i.exec(e.headers.authorization??"");return!s||!Qk(um(s[1]),this.#f)?{status:401,message:s?"wrong token (the proxy expects the one in ~/.pix3/cdp-token)":'missing "Authorization: Bearer <token>" (the token is in ~/.pix3/cdp-token)'}:null}#S(e){let r=sl(e.headers);if(!r)return{};let n=Gp(e.headers),s=rC(e.headers.host);return s!==null&&(n==="local"?s===this.#l:this.#h().includes(s))?{[er]:nl(this.#p,r,n,s)}:(this.#n(`no proof for ${n}:${s??"-"}: `+(n==="local"?`this proxy listens on ${this.#l}`:"not a RemoteForward port of this proxy (pix3 editor --url \u2026 --remote-port <n> names one)")),{[Js]:`${n}:${s??"-"}`})}async#b(e,r){let n=this.#y(e),s=this.#S(e),i=(l,c)=>{r.writeHead(l,{"Content-Type":"application/json; charset=UTF-8",[Et]:String(Zt),...s,...l===401?{"WWW-Authenticate":'Bearer realm="pix3"'}:{}}),r.end(JSON.stringify(c,null,2))};if(n){sl(e.headers)!==null&&e.headers.authorization===void 0||this.#n(`refused ${e.method} ${e.url}: ${n.message}`),i(n.status,{error:n.message});return}let o=(e.url??"/").split("?")[0].replace(/\/+$/,""),a=`ws://${e.headers.host}${_t}`;try{e.method==="GET"&&o==="/json/version"?i(200,{...await this.#w(),webSocketDebuggerUrl:a}):e.method==="GET"&&(o==="/json"||o==="/json/list")?i(200,await this.#x(a)):i(404,{error:`no ${e.method} ${o} here (only /json/version and /json/list)`})}catch(l){i(502,{error:l instanceof Error?l.message:String(l)})}}async#w(){if(!this.#d){let e=await this.call("Browser.getVersion");this.#d={Browser:e.product,"Protocol-Version":e.protocolVersion,"User-Agent":e.userAgent,"V8-Version":e.jsVersion,"WebKit-Version":e.revision,"Pix3-Cdp-Proxy":Zt}}return this.#d}async#x(e){let{targetInfos:r}=await this.call("Target.getTargets");return(r??[]).filter(n=>n.type!=="browser"&&n.type!=="tab").map(n=>({description:"",id:n.targetId,title:n.title,type:n.type,url:n.url,webSocketDebuggerUrl:`${e}/page/${n.targetId}`}))}async#v(e,r,n){let s=(c,u)=>{this.#n(`refused WebSocket ${e.url}: ${u}`),r.end(`HTTP/1.1 ${c} ${c===401?"Unauthorized":c===403?"Forbidden":c===404?"Not Found":"Bad Gateway"}\r
452
+ ${Et}: ${Zt}\r
453
+ Content-Type: text/plain\r
324
454
  Connection: close\r
325
- Content-Length: 0\r
455
+ Content-Length: ${Buffer.byteLength(u)}\r
326
456
  \r
327
- `),r.destroy()},o=new URL(e.url??"/","http://127.0.0.1");if(!oi(e.headers.host))return s(403,"Forbidden",`host ${JSON.stringify(e.headers.host??null)}`);let i=Zf(e);if(!ii(i))return s(403,"Forbidden",`origin ${i}`);if(o.pathname!=="/ws/events")return s(404,"Not Found",`path ${o.pathname}`);if(this.closed)return s(503,"Service Unavailable","server shutting down");this.wss.handleUpgrade(e,r,n,a=>this.onSocket(a))}broadcast(e){let r=JSON.stringify(e);for(let n of this.clients)n.authed&&n.socket.readyState===n.socket.OPEN&&n.socket.send(r)}get leaseState(){return this.lease?"held":"free"}isLeased(){return this.lease!==null}enqueueCall(e,r,n=si,s){return this.lease?this.relay.park(e,r,n,s):Promise.resolve(Gu("no_editor","No Pix3 editor window holds this workspace."))}get holderState(){return this.lease?this.lease.client?"connected":"grace":null}ping(e){let r=Date.now();for(let n of this.clients)if(n.authed){if(r-n.lastSeen>e*3){n.socket.terminate();continue}this.send(n,{type:"ping"})}}enforceToken(e){for(let r of this.clients)!r.authed||r.tokenHash===e||(this.lease?.client===r&&this.endLease("revoked",{requeue:!1}),this.closeClient(r,cd,"revoked","The pairing token was rotated or revoked."))}close(){if(!this.closed){this.closed=!0,this.lease?.graceTimer&&clearTimeout(this.lease.graceTimer),this.lease=null,this.relay.cancelAll("The Pix3 workspace server is shutting down.");for(let e of this.clients)e.authTimer&&clearTimeout(e.authTimer),e.socket.close(zae,"server shutting down"),e.socket.terminate();this.clients.clear(),this.wss.close()}}onSocket(e){let r={socket:e,authed:!1,tokenHash:null,lastSeen:Date.now(),authTimer:null,refused:!1};this.clients.add(r),r.authTimer=setTimeout(()=>{r.authed||this.closeClient(r,cd,"auth_timeout","No auth frame in time.")},this.options.authTimeoutMs??pN),e.on("message",(n,s)=>this.onFrame(r,n,s)),e.on("close",()=>this.onSocketClosed(r)),e.on("error",()=>e.terminate())}authedCount(){let e=0;for(let r of this.clients)r.authed&&(e+=1);return e}send(e,r){e.socket.readyState===e.socket.OPEN&&e.socket.send(JSON.stringify(r))}error(e,r,n,s={}){this.send(e,{type:"error",error:r,message:n,...s})}closeClient(e,r,n,s){(!e.authed||n==="revoked")&&(this.options.log(`events: auth refused ${r} ${n} (${s})`),e.refused=!0),this.error(e,n,s),e.socket.close(r,n)}onFrame(e,r,n){if(e.lastSeen=Date.now(),n){this.closeClient(e,Aae,"bad_frame","Frames are JSON text.");return}let s;try{let o=Array.isArray(r)?Buffer.concat(r).toString("utf8"):r.toString(),i=JSON.parse(o);if(!z_(i))throw new Error("not an object");s=i}catch{e.authed?this.error(e,"bad_frame","Frames are JSON objects."):this.closeClient(e,cd,"unauthorized","The first frame must be JSON.");return}if(!e.authed){this.onAuthFrame(e,s);return}switch(s.type){case"ping":this.send(e,{type:"pong"});return;case"pong":return;case"lease":this.onLeaseFrame(e,s);return;case"call-result":this.onCallResult(e,s);return;default:this.error(e,"unknown_frame","Unknown frame type.")}}onAuthFrame(e,r){if(r.type!=="auth"||typeof r.token!="string"){this.closeClient(e,cd,"unauthorized",'The first frame must be {type:"auth", token}.');return}let n=this.options.auth.check(r.token);if(!n.ok){n.code==="rate_limited"?this.closeClient(e,Rae,"rate_limited",`Too many failed attempts; retry in ${n.retryAfter} s.`):this.closeClient(e,cd,"unauthorized","Wrong or revoked token.");return}e.authed=!0,e.tokenHash=n.tokenHash,this.options.log(`events: socket authenticated (${this.authedCount()} open)`),e.authTimer&&clearTimeout(e.authTimer),e.authTimer=null,this.send(e,this.options.hello())}granted(e,r,n){this.send(e,{type:"lease",state:"granted",leaseId:r.leaseId,resumed:n})}onLeaseFrame(e,r){let n=r.action,s=this.lease;if(n==="acquire"){if(!s)this.grantLease(e);else if(s.client===e)this.granted(e,s,!1);else if(s.client===null&&typeof r.leaseId=="string"&&r.leaseId===s.leaseId)s.graceTimer&&clearTimeout(s.graceTimer),s.graceTimer=null,s.client=e,this.options.log(`lease ${s.leaseId.slice(0,8)} resumed`),this.granted(e,s,!0),this.relay.requeueDelivered(),this.flushCalls();else if(typeof r.leaseId=="string"&&r.leaseId===s.leaseId)this.moveLease(s,e);else{let o=s.client===null,i=o?typeof r.leaseId=="string"?"holder in grace, leaseId does not match":"holder in grace, no leaseId":"another window holds it";this.options.log(`lease acquire refused: busy (${i})`),this.send(e,{type:"lease",state:"busy",inGrace:o})}return}if(n==="takeover"){if(s&&s.client===e){this.granted(e,s,!1);return}s&&this.endLease("taken_over",{requeue:!0}),this.grantLease(e);return}if(n==="release"){s&&s.client===e&&(this.lease=null,this.options.log(`lease ${s.leaseId.slice(0,8)} released`),this.relay.cancelAll("The Pix3 editor window released the workspace.")),this.send(e,{type:"lease",state:"released"});return}this.error(e,"bad_frame","lease.action must be acquire, release or takeover.")}moveLease(e,r){let n=e.client;e.client=r,this.options.log(`lease ${e.leaseId.slice(0,8)} resumed on a new socket`),n&&(this.send(n,{type:"lease",state:"lost",reason:"resumed_elsewhere",leaseId:e.leaseId}),n.socket.close(jae,"lease resumed elsewhere")),this.granted(r,e,!0),this.relay.requeueDelivered(),this.flushCalls()}grantLease(e){let r={leaseId:Cae(),client:e,graceTimer:null};this.lease=r,this.options.log(`lease ${r.leaseId.slice(0,8)} granted`),this.granted(e,r,!1),this.flushCalls()}endLease(e,r){let n=this.lease;n&&(this.lease=null,n.graceTimer&&clearTimeout(n.graceTimer),this.options.log(`lease ${n.leaseId.slice(0,8)} ${e}`),n.client&&this.send(n.client,{type:"lease",state:"lost",reason:e,leaseId:n.leaseId}),r.requeue?this.relay.requeueDelivered():this.relay.cancelAll(`The Pix3 editor window lost the workspace lease (${e}).`))}onSocketClosed(e){e.authTimer&&clearTimeout(e.authTimer),!e.authed&&!e.refused&&!this.closed&&this.options.log("events: socket closed by the client before auth"),this.clients.delete(e);let r=this.lease;!r||r.client!==e||this.closed||(r.client=null,r.graceTimer=setTimeout(()=>{this.lease===r&&r.client===null&&this.endLease("expired",{requeue:!1})},this.options.leaseGraceMs??Ff),r.graceTimer.unref())}flushCalls(){let e=this.lease?.client;if(!(!e||e.socket.readyState!==e.socket.OPEN))for(let r of this.relay.takeUnflushed())this.send(e,{...r.extra,type:"call",id:r.id,name:r.name,input:r.input})}onCallResult(e,r){let n=r.id??null;if(this.lease?.client!==e){this.error(e,"not_lease_holder","Only the lease holder answers calls.",{id:n});return}let s=Im(r.result);if(typeof r.id!="string"||!s){this.error(e,"bad_result",'call-result needs { id, result: { content: [{ type: "text", text }], isError? } }.',{id:n});return}this.relay.resolve(r.id,s)||this.error(e,"unknown_call","No pending call with that id.",{id:n})}}});import{readFileSync as Lae}from"node:fs";import{basename as Dae,join as qae}from"node:path";var NZ,ld,uE=$(()=>{"use strict";NZ=Ze(Er(),1);ut();ld=t=>{try{let e=(0,NZ.parse)(Lae(qae(t,xe),"utf8"));if(e&&typeof e=="object"){let r=e.metadata;if(r&&typeof r=="object"){let n=r.projectName;if(typeof n=="string"&&n.trim())return n.trim()}}}catch{}return Dae(t)}});import{watch as Fae}from"node:fs";import{join as Zae}from"node:path";var eg,CZ=$(()=>{"use strict";zm();eg=class{watchers=new Map;root;onPath;log;warnedLimit=!1;constructor(e,r,n){this.root=e,this.onPath=r,this.log=n}sync(e,r=[]){let n=new Set(["",...r]);for(let s of e)Cs(s)||n.add(s);for(let[s,o]of this.watchers)n.has(s)||(o.close(),this.watchers.delete(s));for(let s of n)this.watchers.has(s)||this.add(s)}close(){for(let e of this.watchers.values())e.close();this.watchers.clear()}get size(){return this.watchers.size}add(e){let r=e?Zae(this.root,...e.split("/")):this.root,n;try{n=Fae(r,{persistent:!1},(s,o)=>{let i=typeof o=="string"?o:null;if(i===null){this.onPath(e);return}this.onPath(e?`${e}/${i}`:i)})}catch(s){this.reportError(e,s);return}n.on("error",s=>{n.close(),this.watchers.get(e)===n&&this.watchers.delete(e),this.reportError(e,s),this.onPath(e)}),this.watchers.set(e,n)}reportError(e,r){let n=r&&typeof r=="object"&&"code"in r?String(r.code):"";if(!(n==="ENOENT"||n==="EPERM")){if(n==="ENOSPC"||n==="EMFILE"){this.warnedLimit||(this.warnedLimit=!0,this.log(`file watch limit reached (${n}) \u2014 some folders are not watched; the editor still sees their changes on its next full scan. Raise fs.inotify.max_user_watches to fix.`));return}this.log(`watch ${e||"."}: ${r instanceof Error?r.message:String(r)}`)}}}});import{createHash as yE,randomBytes as dE,randomUUID as Uae}from"node:crypto";import{createWriteStream as RZ}from"node:fs";import{chmod as Vae,lstat as ud,mkdir as tg,open as AZ,rename as fE,rm as pE,rmdir as Bae,stat as Kae,unlink as Hae}from"node:fs/promises";import{createServer as Wae}from"node:http";import{basename as Jae,dirname as hE,join as Ca}from"node:path";import{Transform as Gae}from"node:stream";import{pipeline as mE}from"node:stream/promises";var zZ,Yae,Xae,rg,Qae,jZ,ece,tce,rce,nce,sce,Ra,gE,Zn,oce,ice,MZ,ng,LZ=$(()=>{"use strict";Xu();ut();Tr();Pc();ar();bF();SF();$F();xF();IZ();Uf();uE();zm();Ic();CZ();zZ=1024*1024*1024,Yae=8*1024*1024,Xae=2e3,rg=2e4,Qae=/^[A-Za-z0-9_.:-]{1,128}$/,jZ=12e4,ece=5e3,tce=/^[0-9a-f]{64}$/,rce=1e3,nce="Authorization, Content-Type, If-Match, If-None-Match, X-Mutation-Id, Range",sce="ETag, Content-Range, Content-Length, Accept-Ranges, X-Mutation-Replayed",Ra=t=>t&&typeof t=="object"&&"code"in t?String(t.code):void 0,gE=t=>t.split(",").map(e=>e.trim()).filter(Boolean).map(e=>e.startsWith("W/")?e.slice(2):e).map(e=>e.startsWith('"')&&e.endsWith('"')&&e.length>=2?e.slice(1,-1):e),Zn=(t,e)=>{let r=t.headers[e];return typeof r=="string"?r:Array.isArray(r)?r.join(", "):null},oce=(t,e)=>{if(!t)return null;let r=/^bytes=(\d*)-(\d*)$/.exec(t.trim());if(!r)return null;let[,n,s]=r;if(!n&&!s)return null;if(!n){let a=Number(s);return a===0?"unsatisfiable":{start:Math.max(0,e-a),end:e-1}}let o=Number(n),i=s?Math.min(Number(s),e-1):e-1;return o>=e||i<o?"unsatisfiable":{start:o,end:i}},ice=async t=>{let e=yE("sha256"),r=t.createReadStream({start:0,autoClose:!1});for await(let n of r)e.update(n);return e.digest("hex")},MZ=t=>{if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return{name:typeof e.name=="string"?e.name.slice(0,120):null,session:typeof e.session=="string"?e.session.slice(0,80):null}},ng=class{serverSession=Uae();root;workspaceId;control=dE(24).toString("base64url");options;log;cache=new Am;table=new Map;journal=new Map;auth;hub;watcher;server=null;boundPort=null;seq=0;revisionMemo=null;serialTail=Promise.resolve();dirty=new Set;debounceTimer=null;firstDirtyAt=0;pingTimer=null;stateTimer=null;closed=!1;ackHash=null;ackTimer=null;changeLog=new jm;presence;constructor(e){this.options=e,this.root=e.root,this.log=e.log??(()=>{});let r=Or(e.root);if(!r)throw new Error(`No workspace identity in ${e.root}/.pix3/workspace.json.`);this.workspaceId=r.workspaceId,this.auth=new Lm({root:e.root,workspaceId:r.workspaceId,failureLimit:e.authFailureLimit??10,failureWindowMs:e.authFailureWindowMs??6e4}),this.hub=new Qm({auth:this.auth,hello:()=>this.helloFrame(),log:this.log,authTimeoutMs:e.authTimeoutMs,leaseGraceMs:e.leaseGraceMs}),this.watcher=new eg(e.root,n=>this.markDirty(n),this.log),this.presence=new Mm(n=>{this.log(n.attached?`agent attached (${n.agent?.name??"unnamed"})`:"agent detached"),this.hub.broadcast(this.presenceFrame(n))},e.agentPresenceTtlMs)}get agentPresence(){return this.presence.snapshot()}presenceFrame(e){return{type:"agent-presence",attached:e.attached,agent:e.agent}}get port(){return this.boundPort}revision(){return this.revisionMemo??=gF(this.table),this.revisionMemo}get currentSeq(){return this.seq}async start(){await this.serial(async()=>{let s=new Map;await ed(this.root,"",this.cache,s),qx(this.table,[""],s),this.revisionMemo=null,this.syncWatcher(),this.ackHash=await this.currentHashOf(Pr,this.ackAbsolute())});let e=this.options.ports??qf,r=null;for(let s of e){let o=Wae((a,c)=>{this.handle(a,c)});o.on("upgrade",(a,c,l)=>this.hub.handleUpgrade(a,c,l));try{await new Promise((a,c)=>{o.once("error",c),o.listen(s,Jt,()=>{o.off("error",c),a()})})}catch(a){r=a;continue}let i=o.address();this.server=o,this.boundPort=typeof i=="object"&&i?i.port:s;break}if(this.server===null||this.boundPort===null){this.watcher.close();let s=Ra(r)==="EADDRINUSE";throw new Error(e.length===1?`Port ${e[0]} on ${Jt} is ${s?"already in use":"not available"}`+(r instanceof Error&&!s?` (${r.message})`:"")+". Pick another with --port, or omit --port to take the first free one of 8490\u20138499.":`No free port for pix3 serve in ${e[0]}\u2013${e[e.length-1]}.`)}TN(this.root,{pid:process.pid,port:this.boundPort,serverSession:this.serverSession,control:this.control,startedAt:new Date().toISOString()});let n=this.options.pingIntervalMs??hN;return this.pingTimer=setInterval(()=>this.hub.ping(n),n),this.pingTimer.unref(),this.stateTimer=setInterval(()=>this.hub.enforceToken(this.auth.current()?.sha256??null),this.options.stateCheckIntervalMs??2e3),this.stateTimer.unref(),this.boundPort}async close(){if(this.closed)return;this.closed=!0,this.debounceTimer&&clearTimeout(this.debounceTimer),this.ackTimer&&clearTimeout(this.ackTimer),this.pingTimer&&clearInterval(this.pingTimer),this.stateTimer&&clearInterval(this.stateTimer),this.presence.close(),this.watcher.close(),this.hub.close();let e=this.server;this.server=null,e&&(e.closeAllConnections(),await new Promise(r=>e.close(()=>r()))),await this.serialTail.catch(()=>{}),PN(this.root,this.serverSession),this.boundPort=null,this.options.onClosed?.()}get controlSecret(){return this.control}isLeased(){return this.hub.isLeased()}enqueueCall(e,r,n=si,s){return this.hub.enqueueCall(e,r,n,s)}changesSince(e){return this.changeLog.since(e)}serial(e){let r=this.serialTail.then(e,e);return this.serialTail=r.catch(()=>{}),r}nextSeq(){return this.seq+=1,this.seq}logChange(e,r,n){let s=new Set;for(let o of r)if(o.kind==="file")for(let i of o.from?[o.path,o.from]:[o.path])i&&!Cs(i)&&s.add(i);s.size>0&&this.changeLog.record(e,s,n)}syncWatcher(){let e=[];for(let[r,n]of this.table)n.kind==="dir"&&e.push(r);this.watcher.sync(e,[At])}async rescan(e){let r=new Map;for(let s of e)await ed(this.root,s,this.cache,r);let n=qx(this.table,e,r);return n.length>0&&(this.revisionMemo=null),this.syncWatcher(),n}broadcastChange(e){if(e.length===0)return;let r=this.nextSeq();this.logChange(r,e,"external"),this.hub.broadcast({type:"change",seq:r,revision:this.revision(),events:e})}markDirty(e){if(this.closed)return;if(e===Pr||e===At){this.noteInternalChange();return}if(e&&Cs(e))return;this.dirty.size===0&&(this.firstDirtyAt=Date.now()),this.dirty.add(e),this.debounceTimer&&clearTimeout(this.debounceTimer);let r=this.options.debounceMs??A_,n=Date.now()-this.firstDirtyAt,s=Math.max(0,Math.min(r,rce-n));this.debounceTimer=setTimeout(()=>{this.flushDirty()},s)}async flushDirty(){this.debounceTimer=null;let e=[...this.dirty].sort();this.dirty=new Set;let r=[];for(let n of e)r.some(s=>s===""||n===s||n.startsWith(`${s}/`))||r.push(n);try{await this.serial(async()=>{this.closed||this.broadcastChange(await this.rescan(r))})}catch(n){this.log(`rescan failed: ${n instanceof Error?n.message:String(n)}`)}}ackAbsolute(){return Ca(this.root,...Pr.split("/"))}noteInternalChange(){this.ackTimer&&clearTimeout(this.ackTimer),this.ackTimer=setTimeout(()=>{this.ackTimer=null,this.serial(async()=>{if(this.closed)return;let e=await this.currentHashOf(Pr,this.ackAbsolute()),r=this.ackHash;if(e===r)return;this.ackHash=e;let n=e===null?{op:"delete",path:Pr,kind:"file"}:{op:r===null?"create":"modify",path:Pr,kind:"file",sha256:e};this.broadcastChange([n])}).catch(e=>{this.log(`ack check failed: ${e instanceof Error?e.message:String(e)}`)})},this.options.debounceMs??A_)}async refreshAckHash(...e){e.some(n=>Pr===n||Pr.startsWith(`${n}/`))&&(this.ackHash=await this.currentHashOf(Pr,this.ackAbsolute()))}recordOwnFile(e,r,n){if(e===Pr&&(this.ackHash=n),Cs(e))return;let s={kind:"file",size:Number(r.size),mtime:Ro(r),statKey:Ns(r),sha256:n};this.cache.remember(e,s.statKey,n),this.table.set(e,s),this.revisionMemo=null}async recordAncestors(e){let r=[];for(let s=Oc(e);s!==null;s=Oc(s))r.unshift(s);let n=!1;for(let s of r)if(!(this.table.has(s)||Cs(`${s}/x`)))try{let o=await ud(Ca(this.root,...s.split("/")),{bigint:!0});if(!o.isDirectory())continue;this.table.set(s,{kind:"dir",size:0,mtime:Ro(o),statKey:Ns(o)}),n=!0}catch{}n&&this.syncWatcher()}authorize(e,r){if(r){let i=Zn(e,"x-pix3-control");if(i&&i===this.control)return}let n=Zn(e,"authorization")??"",s=/^Bearer\s+(\S+)$/i.exec(n.trim()),o=this.auth.check(s?s[1]:"");if(!o.ok)throw o.code==="rate_limited"?new M(429,"rate_limited",`Too many failed attempts; retry in ${o.retryAfter} s.`,{retryAfter:o.retryAfter}):new M(401,"unauthorized","Missing, wrong or revoked token (Authorization: Bearer <token>).")}helloFrame(){return{type:"hello",workspaceId:this.workspaceId,serverSession:this.serverSession,protocol:R_,cliVersion:be,revision:this.revision(),seq:this.seq,root:this.root,projectId:Zs(this.root),projectName:ld(this.root),lease:this.hub.leaseState,leaseGraceMs:this.options.leaseGraceMs??Ff,agentPresence:this.presence.snapshot()}}corsHeaders(e){return e?{"Access-Control-Allow-Origin":e,"Access-Control-Expose-Headers":sce,Vary:"Origin"}:{}}async handle(e,r){let n=Zf(e);try{if(!oi(e.headers.host)){Gt(r,403,{error:"forbidden_host",message:"Forbidden host."},null);return}if(!ii(n)){this.log(`403 origin ${n}`),Gt(r,403,{error:"forbidden_origin",message:"Origin not allowed."},null);return}if(e.method==="OPTIONS"){this.preflight(e,r,n);return}await this.route(e,r,n)}catch(s){s instanceof M||this.log(`500 ${e.method} ${e.url}: ${s instanceof Error?s.stack:String(s)}`);let o=this.errorOutcome(s);if(r.headersSent){r.destroy();return}let i=this.corsHeaders(n);o.status===401&&(i["WWW-Authenticate"]="Bearer"),o.status===429&&typeof o.body.retryAfter=="number"&&(i["Retry-After"]=String(o.body.retryAfter)),e.resume(),Gt(r,o.status,o.body,null,i)}}errorOutcome(e){return e instanceof M?{status:e.status,body:{error:e.code,message:e.message,...e.extra}}:{status:500,body:{error:"internal",message:"Internal error."}}}preflight(e,r,n){let s={"Access-Control-Allow-Methods":"GET, HEAD, PUT, POST, OPTIONS","Access-Control-Allow-Headers":nce,"Access-Control-Max-Age":"600","Cache-Control":"no-store",...this.corsHeaders(n)};e.headers["access-control-request-private-network"]==="true"&&(s["Access-Control-Allow-Private-Network"]="true"),r.writeHead(204,s),r.end()}async route(e,r,n){let s=new URL(e.url??"/","http://127.0.0.1"),o=s.pathname,i=e.method??"GET";if(i==="GET"&&o==="/ws/status"){this.authorize(e,!0),Gt(r,200,this.statusBody(),n,this.corsHeaders(n));return}if(i==="GET"&&o==="/ws/revision"){this.authorize(e,!0),Gt(r,200,{revision:this.revision(),seq:this.seq,serverSession:this.serverSession},n,this.corsHeaders(n));return}if(o.startsWith("/ws/agent/")){await this.agentRoute(e,r,s,i,n);return}if(this.authorize(e,!1),(i==="GET"||i==="HEAD")&&o==="/ws/file"){await this.readFile(e,r,s,n,i==="HEAD");return}if(i==="GET"&&o==="/ws/manifest"){let a=await this.manifest();Gt(r,200,a,n,this.corsHeaders(n));return}if(i==="POST"&&o==="/ws/hash"){let a=await Xr(e);Gt(r,200,await this.hashPaths(a),n,this.corsHeaders(n));return}if(i==="PUT"&&o==="/ws/file"){await this.writeFile(e,r,s,n);return}if(i==="POST"&&(o==="/ws/mkdir"||o==="/ws/delete"||o==="/ws/move")){let a=await Xr(e);await this.jsonMutation(e,r,n,o.slice(4),a);return}throw new M(404,"not_found","Not found.")}async agentRoute(e,r,n,s,o){if(o!==null)throw new M(403,"forbidden_origin","The agent lane is for local processes (pix3 mcp); browsers never call it.");let i=Zn(e,"x-pix3-control");if(!i||i!==this.control)throw new M(401,"unauthorized","The agent lane needs X-Pix3-Control with the control secret from .pix3/workspace.json.");let a=n.pathname,c=l=>Gt(r,200,l,null);if(s==="GET"&&a==="/ws/agent/status"){c({...this.statusBody(),holder:this.hub.holderState,projectName:ld(this.root),projectId:Zs(this.root),agentPresence:this.presence.snapshot()});return}if(s==="POST"&&a==="/ws/agent/presence"){let l=await Xr(e),u=MZ(l.agent),d=u?.session??"default";l.leaving===!0?this.presence.leave(d):this.presence.touch(d,u?.name??null),c({agentPresence:this.presence.snapshot()});return}if(s==="GET"&&a==="/ws/agent/tools"){this.requireEditor();let l=await this.enqueueCall("tools_manifest",{},ece);this.throwRelayFailure(l,"tools_manifest");let u=null;try{let d=JSON.parse(Yu(l));u=d&&typeof d=="object"&&"tools"in d?d.tools:null}catch{u=null}if(!Array.isArray(u))throw new M(502,"bad_editor_reply","The editor sent no tool list.");c({tools:u,serverSession:this.serverSession});return}if(s==="POST"&&a==="/ws/agent/call"){let l=await Xr(e);if(typeof l.name!="string"||!l.name)throw new M(400,"bad_request","`name` must be a tool name.");let u=typeof l.timeoutMs=="number"?l.timeoutMs:jZ,d=Math.max(1e3,Math.min(jZ,u));this.requireEditor();let f=MZ(l.agent);f?.session&&this.presence.touch(f.session,f.name);let p=await this.enqueueCall(l.name,l.input??{},d,f?{agent:{name:f.name,session:f.session,verified:!1}}:void 0);this.throwRelayFailure(p,l.name),c({result:p});return}if(s==="POST"&&a==="/ws/agent/hash"){let l=await Xr(e);c(await this.hashPaths(l));return}if(s==="POST"&&a==="/ws/agent/expect"){let l=await Xr(e);c(await this.compareExpectations(l.expect));return}if(s==="GET"&&a==="/ws/agent/changes"){let l=n.searchParams.get("since")??"0";if(!/^\d{1,15}$/.test(l))throw new M(400,"bad_request","`since` must be a seq number.");await this.serial(async()=>{this.broadcastChange(await this.rescan([""]))});let u=Number(l),{paths:d,complete:f,entries:p}=this.changeLog.since(u);c({since:u,seq:this.seq,revision:this.revision(),paths:d,complete:f,entries:p.map(({seq:m,path:h,origin:g})=>({seq:m,path:h,origin:g}))});return}throw new M(404,"not_found","Not found.")}requireEditor(){if(!this.hub.isLeased())throw new M(409,"no_editor",`The Pix3 editor is not open on this project (or has another folder open). Open ${this.root} in Pix3: File \u2192 Connect to Workspace\u2026, address http://${Jt}:${this.boundPort??"?"} (the token \`pix3 serve\` printed). Files can still be edited meanwhile.`)}throwRelayFailure(e,r){switch(e.relayFailure){case void 0:return;case"timeout":throw new M(504,"no_editor_reply",`The Pix3 editor holds this workspace but did not answer "${r}" in time.`);case"no_editor":throw this.requireEditor(),new M(409,"no_editor",Yu(e));case"cancelled":throw new M(409,"lease_lost",Yu(e));case"overloaded":throw new M(429,"too_many_calls",Yu(e))}}async compareExpectations(e){if(!e||typeof e!="object"||Array.isArray(e))throw new M(400,"bad_request","`expect` must be an object {path: sha256}.");let r=Object.entries(e);if(r.length>rg)throw new M(413,"too_many_paths",`At most ${rg} paths.`);let n=new Map;for(let[a,c]of r){let l=wn(a,"expect");if(typeof c!="string"||!tce.test(c.toLowerCase()))throw new M(400,"bad_request",`expect["${a}"] must be a hex sha256.`);n.set(l,c.toLowerCase())}let{hashes:s}=await this.hashPaths({paths:[...n.keys()]}),o=[],i=null;for(let[a,c]of n){let l=s[a]??null;if(l===c)continue;i??=await vF(this.root);let u=null;if(l!==null)try{u=Ro(await ud(Ca(this.root,...a.split("/")),{bigint:!0}))}catch{u=null}let d=wF(i,a,l,u);o.push({path:a,diskHash:l,agentHash:c,recovery:await _F(this.root,a,c),...d?{mergeLog:!0}:{}})}return{matchesAgent:o.length===0,differing:o,hashes:s,seq:this.seq}}statusBody(){return{workspaceId:this.workspaceId,serverSession:this.serverSession,protocol:R_,cliVersion:be,root:this.root,pid:process.pid,port:this.boundPort,revision:this.revision(),seq:this.seq,leased:this.hub.isLeased()}}async manifest(){return this.serial(async()=>{this.broadcastChange(await this.rescan([""]));let e=await mF(this.root,this.cache),r=[...this.table.entries(),...e.entries()].sort(([n],[s])=>n<s?-1:n>s?1:0).map(([n,s])=>({path:n,kind:s.kind,size:s.size,mtime:s.mtime,...s.sha256?{sha256:s.sha256}:{}}));return{workspaceId:this.workspaceId,serverSession:this.serverSession,revision:this.revision(),seq:this.seq,files:r}})}async hashPaths(e){let r=e.paths;if(!Array.isArray(r))throw new M(400,"bad_request","`paths` must be an array of strings.");if(r.length>rg)throw new M(413,"too_many_paths",`At most ${rg} paths.`);let n=r.map((o,i)=>wn(o,`paths[${i}]`)),s={};for(let o of n){let i;try{i=await bn(this.root,o,{allowMissing:!0})}catch(a){if(a instanceof M&&a.code==="not_a_directory"){s[o]=null;continue}throw a}if(i.kind!=="file"){s[o]=null;continue}try{let a=await ud(i.absolute,{bigint:!0});s[o]=await this.cache.hash(o,i.absolute,a)}catch(a){if(Ra(a)!=="ENOENT")throw a;s[o]=null}}return{hashes:s,seq:this.seq}}async readFile(e,r,n,s,o){let i=wn(n.searchParams.get("path")??""),a=await bn(this.root,i,{allowMissing:!1});if(a.kind!=="file")throw new M(400,"not_a_file",`${i} is not a file.`);let c=await AZ(a.absolute,"r"),l=!1;try{let u=await c.stat({bigint:!0}),d=Number(u.size),f=null,p;if(d<=Yae)f=await c.readFile(),p=yE("sha256").update(f).digest("hex"),this.cache.remember(i,Ns(u),p);else{let T=Ns(u);p=this.cachedHash(i,T)??await ice(c),this.cache.remember(i,T,p)}let h={ETag:`"${p}"`,"Accept-Ranges":"bytes","Cache-Control":"private, no-cache","X-Content-Type-Options":"nosniff",...this.corsHeaders(s)},g=Zn(e,"if-none-match");if(g&&gE(g).some(T=>T==="*"||T===p)){r.writeHead(304,h),r.end();return}let y=oce(Zn(e,"range"),d);if(y==="unsatisfiable"){r.writeHead(416,{...h,"Content-Range":`bytes */${d}`}),r.end();return}let w=y?y.start:0,b=y?y.end:d-1,x=d===0?0:b-w+1,v={...h,"Content-Type":kF(i),"Content-Length":String(x),...y?{"Content-Range":`bytes ${w}-${b}/${d}`}:{}};if(r.writeHead(y?206:200,v),o||x===0){r.end();return}if(f){r.end(y?f.subarray(w,b+1):f);return}l=!0;let S=c.createReadStream({start:w,end:b,autoClose:!0});await mE(S,r).catch(()=>{})}finally{l||await c.close()}}cachedHash(e,r){let n=this.table.get(e);return n&&n.statKey===r&&n.sha256?n.sha256:null}mutationId(e){let r=Zn(e,"x-mutation-id");if(r===null)return null;if(!Qae.test(r))throw new M(400,"bad_mutation_id","X-Mutation-Id must be 1\u2013128 chars of [A-Za-z0-9_.:-].");return r}async journaled(e,r,n,s,o){let i=this.mutationId(e),a=i?this.journal.get(i):void 0;if(i&&a){if(e.resume(),a.fingerprint!==s)throw new M(422,"mutation_id_reused","That X-Mutation-Id was used for a different request.");let u=await a.outcome;Gt(r,u.status,u.body,null,{...this.corsHeaders(n),"X-Mutation-Replayed":"true"});return}let c=o().catch(u=>(u instanceof M||this.log(`mutation failed: ${u instanceof Error?u.stack:String(u)}`),this.errorOutcome(u)));if(i&&(this.journal.set(i,{fingerprint:s,outcome:c}),this.journal.size>Xae)){let u=this.journal.keys().next().value;u!==void 0&&this.journal.delete(u)}let l=await c;e.resume(),Gt(r,l.status,l.body,null,this.corsHeaders(n))}async currentHashOf(e,r){try{let n=await ud(r,{bigint:!0});return n.isFile()?await this.cache.hash(e,r,n):null}catch(n){if(Ra(n)==="ENOENT")return null;throw n}}async writeFile(e,r,n,s){let o=wn(n.searchParams.get("path")??""),i=Zn(e,"if-match"),a=Zn(e,"if-none-match"),c=i?gE(i):null,l=a!==null&&gE(a).includes("*"),u=`put
328
- ${o}
329
- ${i??""}
330
- ${a??""}`;await this.journaled(e,r,s,u,()=>this.performPut(e,o,c,l))}async performPut(e,r,n,s){if(Number(Zn(e,"content-length")??"0")>zZ)throw new M(413,"too_large","File too large.");await bn(this.root,r,{allowMissing:!0});let i=Ca(this.root,At,"tmp");await tg(i,{recursive:!0,mode:448});let a=Ca(i,`put-${dE(8).toString("hex")}`),c=!0;try{let{sha256:l,size:u}=await this.streamBodyTo(e,a);return await this.serial(async()=>{let d=await bn(this.root,r,{allowMissing:!0});if(d.kind==="dir"||d.kind==="other")throw new M(409,"not_a_file",`${r} exists and is not a file.`);let f=d.kind==="file"?await this.currentHashOf(r,d.absolute):null;if(s&&f!==null)throw new M(409,"exists",`${r} already exists.`,{currentHash:f});if(n&&!n.includes("*")&&!n.includes(f??""))throw new M(409,"base_mismatch",`${r} changed since the base you edited.`,{currentHash:f});if(n&&n.includes("*")&&f===null)throw new M(409,"base_mismatch",`${r} does not exist.`,{currentHash:null});let p=hE(d.absolute);if(await tg(p,{recursive:!0}),d.kind==="file"){let g=await Kae(d.absolute);await Vae(a,g.mode&4095)}await this.renameIntoPlace(a,d.absolute),c=!1;let m=await ud(d.absolute,{bigint:!0});await this.recordAncestors(r),this.recordOwnFile(r,m,l);let h=this.nextSeq();return this.logChange(h,[{op:"modify",path:r,kind:"file"}],"editor"),{status:200,body:{path:r,sha256:l,size:u,mtime:Ro(m),seq:h}}})}finally{c&&await pE(a,{force:!0})}}async renameIntoPlace(e,r){try{await fE(e,r)}catch(n){if(Ra(n)!=="EXDEV")throw n;let s=Ca(hE(r),`.${Jae(r)}.pix3-tmp-${dE(6).toString("hex")}`),o=await AZ(e,"r");try{await mE(o.createReadStream(),RZ(s,{flags:"wx"}))}finally{await o.close().catch(()=>{})}await fE(s,r),await pE(e,{force:!0})}}async streamBodyTo(e,r){let n=yE("sha256"),s=0,o=new Gae({transform(i,a,c){if(s+=i.length,s>zZ){c(new M(413,"too_large","File too large."));return}n.update(i),c(null,i)}});return await mE(e,o,RZ(r,{flags:"wx"})),{sha256:n.digest("hex"),size:s}}async jsonMutation(e,r,n,s,o){if(s==="mkdir"){let l=wn(o.path);await this.journaled(e,r,n,`mkdir
331
- ${l}`,()=>this.serial(()=>this.performMkdir(l)));return}if(s==="delete"){let l=wn(o.path),u=o.recursive===!0;await this.journaled(e,r,n,`delete
332
- ${l}
333
- ${u}`,()=>this.serial(()=>this.performDelete(l,u)));return}let i=wn(o.from,"from"),a=wn(o.to,"to"),c=o.overwrite===!0;await this.journaled(e,r,n,`move
334
- ${i}
335
- ${a}
336
- ${c}`,()=>this.serial(()=>this.performMove(i,a,c)))}async performMkdir(e){let r=await bn(this.root,e,{allowMissing:!0});if(r.kind==="dir")return{status:200,body:{path:e,created:!1,seq:this.seq}};if(r.kind!==null)throw new M(409,"exists",`${e} exists and is not a directory.`);await tg(r.absolute,{recursive:!0});let n=await this.rescan([this.topmostNew(e)]),s=this.nextSeq();return this.logChange(s,n,"editor"),{status:200,body:{path:e,created:!0,seq:s}}}topmostNew(e){let r=e;for(let n=Oc(e);n!==null&&!this.table.has(n);n=Oc(n))r=n;return r}async performDelete(e,r){let n=await bn(this.root,e,{allowMissing:!1});if(n.kind==="dir")if(r)await pE(n.absolute,{recursive:!0});else try{await Bae(n.absolute)}catch(i){throw Ra(i)==="ENOTEMPTY"||Ra(i)==="EEXIST"?new M(409,"not_empty",`${e} is not empty; pass recursive: true.`):i}else await Hae(n.absolute);let s=await this.rescan([e]);await this.refreshAckHash(e);let o=this.nextSeq();return this.logChange(o,s,"editor"),{status:200,body:{path:e,kind:n.kind==="dir"?"dir":"file",seq:o}}}async performMove(e,r,n){if(r===e||r.startsWith(`${e}/`))throw new M(400,"bad_move","`to` must not be `from` or inside it.");let s=await bn(this.root,e,{allowMissing:!1}),o=await bn(this.root,r,{allowMissing:!0});if(o.kind!==null){if(!n)throw new M(409,"exists",`${r} already exists.`);if(o.kind==="dir"||s.kind==="dir")throw new M(409,"exists",`${r} exists; only a file may overwrite a file.`)}await tg(hE(o.absolute),{recursive:!0});for(let[l,u]of this.table)(l===e||l.startsWith(`${e}/`))&&u.sha256&&this.cache.remember(r+l.slice(e.length),u.statKey,u.sha256);await fE(s.absolute,o.absolute);let i=await this.rescan([e,this.topmostNew(r)]);await this.refreshAckHash(e,r);let a=this.table.get(r),c=this.nextSeq();return this.logChange(c,i,"editor"),{status:200,body:{from:e,to:r,kind:s.kind==="dir"?"dir":"file",...a?.sha256?{sha256:a.sha256}:{},seq:c}}}}});import{realpath as ace}from"node:fs/promises";var cce,DZ,qZ=$(()=>{"use strict";Tr();Ic();LZ();cce=async(t,e,r)=>{try{let n=await fetch(`http://${Jt}:${t}/ws/status`,{headers:{"X-Pix3-Control":e},signal:AbortSignal.timeout(r)});if(!n.ok)return null;let s=await n.json();return typeof s.workspaceId!="string"||typeof s.serverSession!="string"?null:{workspaceId:s.workspaceId,serverSession:s.serverSession}}catch{return null}},DZ=async t=>{let e=await ace(t.projectDir),r=ON(e);if(!r.acquired){let n=t.rotateToken?Z_(e,{rotateToken:!0}).issuedToken:null,s=Or(e),o=s?.server;if(s&&o&&o.pid===r.pid){let i=await cce(o.port,o.control,t.probeTimeoutMs??2e3);if(i&&i.serverSession===o.serverSession&&i.workspaceId===s.workspaceId)return{kind:"running",port:o.port,pid:o.pid,workspaceId:s.workspaceId,serverSession:o.serverSession,issuedToken:n}}return{kind:"unresponsive",pid:r.pid}}try{let n=Z_(e,{rotateToken:t.rotateToken===!0}),s=new ng({...t,root:e,onClosed:r.release}),o=await s.start().catch(async i=>{throw await s.close().catch(()=>{}),i});return{kind:"started",server:s,port:o,identity:n}}catch(n){throw r.release(),n}}});var UZ={};Je(UZ,{runServe:()=>dce});import{existsSync as lce}from"node:fs";import{join as FZ,resolve as ZZ}from"node:path";var uce,dce,VZ=$(()=>{"use strict";ut();Tr();qZ();uE();uce=t=>{if(!/^\d{1,5}$/.test(t))throw new Error(`--port must be a number, got "${t}".`);let e=Number(t);if(e<1||e>65535)throw new Error(`--port must be 1\u201365535, got ${e}.`);return e},dce=async t=>{let e=t.projectDir?ZZ(t.cwd,t.projectDir):Qe(t.cwd)??ZZ(t.cwd);if(!lce(FZ(e,xe)))return process.stderr.write(`pix3 serve: ${e} is not a Pix3 project (no ${xe}). Run it inside the project folder, or pass --project <dir>.
337
- `),1;let r=t.port===void 0?qf:[uce(t.port)],n=c=>{process.stdout.write(c)},s=await DZ({projectDir:e,ports:r,rotateToken:t.newToken,log:c=>process.stderr.write(`[pix3 serve] ${c}
338
- `)});if(s.kind==="unresponsive")return process.stderr.write(`pix3 serve: another pix3 serve (pid ${s.pid}) holds ${e} but does not answer. Stop that process, or delete ${FZ(e,".pix3","serve.lock")} if it is not a pix3 serve.
339
- `),1;if(s.kind==="running")return n(`pix3 serve is already running for ${e}
340
- Address http://${Jt}:${s.port} (pid ${s.pid})
341
- `),s.issuedToken&&n(` Token ${s.issuedToken}
342
- New token issued; the running server now refuses the old one.
343
- `),0;let{server:o,port:i,identity:a}=s;return n(`Pix3 workspace server
344
- Project ${ld(o.root)}
345
- Root ${o.root}
346
- Address http://${Jt}:${i}
347
- Workspace ${o.workspaceId}
348
- `),a.issuedToken?n(` Token ${a.issuedToken}
349
- Shown once: paste it into Pix3 (File \u2192 Connect to Workspace\u2026) with the address.
350
- `+(a.minted==="moved"?` (This folder was copied from another workspace; it got its own identity.)
351
- `:"")):n(" Token paired earlier (not shown again); `pix3 serve --new-token` issues a new one.\n"),n(`
352
- Forward port ${i} to your computer (VS Code: Ports panel, or ssh -L ${i}:127.0.0.1:${i}),
353
- then connect from Pix3 with the address and token. Ctrl+C stops the server.
354
- `),await new Promise(c=>{let l=!1,u=()=>{l||(l=!0,o.close().finally(c))};process.once("SIGINT",u),process.once("SIGTERM",u)}),0}});var KZ={};Je(KZ,{ACK_FILE:()=>wE,ackFile:()=>wce,appendAck:()=>kE,readAndAck:()=>vce,resolveAckProjectRoot:()=>SE,sha256Bytes:()=>bE,toAckPath:()=>$E});import{createHash as fce}from"node:crypto";import{mkdirSync as pce,readFileSync as vE,renameSync as hce,writeFileSync as mce}from"node:fs";import{isAbsolute as BZ,join as dd,relative as gce,resolve as _E,sep as yce}from"node:path";var wE,bE,SE,$E,_ce,kE,vce,wce,HZ=$(()=>{"use strict";ut();wE=".pix3/ack.json",bE=t=>fce("sha256").update(t).digest("hex"),SE=(t,e)=>e?_E(t,e):Qe(t)??_E(t),$E=(t,e,r)=>{let n=BZ(r)?r:_E(e,r.replace(/^res:\/\//,"")),s=gce(t,n);if(!s||s.startsWith("..")||BZ(s))throw new Error(`${r} is not inside the project ${t}`);let o=s.split(yce).join("/");if(o===".pix3"||o.startsWith(".pix3/"))throw new Error(`${r} is editor-private (.pix3/)`);return o},_ce=t=>{let e;try{e=vE(dd(t,wE),"utf8")}catch{return[]}try{let r=JSON.parse(e),n=r&&typeof r=="object"?r.acks:void 0;return Array.isArray(n)?n.filter(s=>!!s&&typeof s=="object"&&typeof s.path=="string"&&typeof s.sha256=="string"):[]}catch{return[]}},kE=(t,e)=>{let r=_ce(t).filter(o=>!(o.path===e.path&&o.sha256===e.sha256));r.push(e);let n=dd(t,wE);pce(dd(t,".pix3"),{recursive:!0});let s=`${n}.${process.pid}.tmp`;mce(s,`${JSON.stringify({acks:r},null,2)}
355
- `),hce(s,n)},vce=t=>{let e=SE(t.cwd,t.projectDir),r=$E(e,t.cwd,t.file),n=vE(dd(e,r)),s={path:r,sha256:bE(n),at:(t.now?.()??new Date).toISOString()};return kE(e,s),{bytes:n,record:s}},wce=t=>{let e=SE(t.cwd,t.projectDir),r=$E(e,t.cwd,t.file),n=t.hash?.trim().toLowerCase();if(n!==void 0&&!/^[0-9a-f]{64}$/.test(n))throw new Error("--sha256 must be 64 hex characters");n??=bE(vE(dd(e,r)));let s={path:r,sha256:n,at:(t.now?.()??new Date).toISOString()};return kE(e,s),s}});var fd,ke,pd=$(()=>{"use strict";fd=Ze(Er(),1),ke=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)});import{readdirSync as bce,readFileSync as Sce}from"node:fs";import{isAbsolute as $ce,join as xE,relative as JZ,resolve as WZ,sep as GZ}from"node:path";var kce,EE,xce,Aa,YZ,XZ,Ece,sg=$(()=>{"use strict";kce=Ze(Er(),1);pd();EE=new Set(["node_modules",".yalc",".git",".pix3","dist",".vite",".cache"]),xce=".pix3scene",Aa=class{root;files;fileSet;textCache=new Map;constructor(e){this.root=WZ(e),this.files=YZ(this.root,this.root).sort(),this.fileSet=new Set(this.files)}has(e){return this.fileSet.has(e)}absolute(e){return xE(this.root,e)}relativeOf(e){let r=JZ(this.root,WZ(e));return r.startsWith("..")||$ce(r)?null:r.split(GZ).join("/")}readText(e){let r=this.textCache.get(e);if(r!==void 0)return r;let n=Sce(this.absolute(e),"utf8");return this.textCache.set(e,n),n}scenes(){return this.files.filter(e=>e.endsWith(xce))}},YZ=(t,e)=>{let r=[],n;try{n=bce(e,{withFileTypes:!0})}catch{return r}for(let s of n)if(s.isDirectory()){if(EE.has(s.name))continue;r.push(...YZ(t,xE(e,s.name)))}else s.isFile()&&r.push(JZ(t,xE(e,s.name)).split(GZ).join("/"));return r},XZ=t=>{let e=t.trim();if(e.length===0)return null;let r=/^([a-z][a-z0-9+.-]*):/i.exec(e)?.[1]?.toLowerCase();if(r&&r!=="res")return null;let s=(r==="res"?e.replace(/^res:\/\//i,""):e).replace(/[?#].*$/,""),o=[];for(let i of s.replace(/\\/g,"/").split("/"))if(!(i===""||i===".")){if(i===".."){if(o.length===0)return null;o.pop();continue}o.push(Ece(i))}return o.length===0?null:o.join("/")},Ece=t=>{try{return decodeURIComponent(t)}catch{return t}}});var QZ=_(()=>{throw new Error("src/smoke/bundle.ts is only available in a checkout of the pix3 repo (the published @pix3/cli ships its bundles prebuilt)")});var tU={};Je(tU,{SMOKE_WORKER_FILE:()=>og,TREE_DEFAULTS_FILE:()=>Nce,cliPackageRoot:()=>Wt,resolveEsbuild:()=>TE,withSmokeBundle:()=>PE});import{existsSync as Tce,mkdtempSync as Pce,rmSync as Oce}from"node:fs";import{tmpdir as Ice}from"node:os";import{join as eU}from"node:path";var og,Nce,TE,PE,OE=$(()=>{"use strict";Us();og="smoke-worker.mjs",Nce="tree-defaults.mjs",TE=()=>{try{return import.meta.resolve("esbuild")}catch{return}},PE=async t=>{let e=yf("smoke");if(e&&Tce(eU(e,og)))return t(e);let r=Pce(eU(Ice(),"pix3-smoke-bundle-"));try{let{buildSmokeBundle:n}=await Promise.resolve().then(()=>Ze(QZ(),1));return await n(r),await t(r)}finally{Oce(r,{recursive:!0,force:!0})}}});var zs,rU=$(()=>{"use strict";zs=t=>"code"in t});import{execFileSync as Cce}from"node:child_process";import{realpathSync as Rce}from"node:fs";import{isAbsolute as Ace,join as zce,relative as jce,sep as Mce}from"node:path";var Lce,Dce,qce,Fce,Zce,Uce,sU,Vce,Bce,IE,oU,Kce,Hce,Wce,Jce,nU,Gce,iU,aU=$(()=>{"use strict";ut();sg();Lce="scenes/main.pix3scene",Dce=/^\s*(?:-\s+)?instance:\s*["']?(?:res:\/\/)?([^"'\s#]+)/gm,qce=/res:\/\/[^"'\s#)]+/g,Fce=/\buser:([A-Za-z_$][\w$]*)/g,Zce=/\bexport\s+(?:default\s+)?(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/g,Uce=/(^|\/)(prefabs?|ui)\//i,sU=t=>/\.(ts|mts|js|mjs)$/.test(t)&&!/\.(d|spec|test)\.(ts|mts|js|mjs)$/.test(t),Vce=t=>t.split("/").some(e=>EE.has(e)),Bce=t=>t.endsWith(".pix3scene")||sU(t),IE=(t,e)=>{try{return t.readText(e)}catch{return""}},oU=(t,e)=>{let r=[];for(let n of IE(t,e).matchAll(Dce))r.push(n[1].replace(/^\/+/,""));return r},Kce=t=>{let e=t.scenes(),r=new Set;for(let n of e)for(let s of oU(t,n))r.add(s);return e.filter(n=>!r.has(n)&&!Uce.test(n))},Hce=(t,e)=>{let r=n=>n===Lce?0:n===e?1:2;return[...t].sort((n,s)=>r(n)-r(s)||n.localeCompare(s))},Wce=(t,e,r)=>{let n=new Set,s=[e];for(;s.length>0;){let o=s.pop();if(n.has(o))continue;n.add(o);let i=IE(t,o);for(let a of oU(t,o))s.push(a);for(let a of i.matchAll(qce)){let c=XZ(a[0]);c&&(c.endsWith(".pix3scene")||n.add(c))}for(let a of i.matchAll(Fce))for(let c of r.get(a[1])??[])n.add(c)}return n},Jce=t=>{let e=new Map;for(let r of t.files)if(sU(r))for(let n of IE(t,r).matchAll(Zce)){let s=e.get(n[1])??[];s.push(r),e.set(n[1],s)}return e},nU=(t,e)=>{try{return Cce("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,maxBuffer:64*1024*1024})}catch{return null}},Gce=t=>{let e=nU(t,["rev-parse","--show-toplevel"])?.trim();if(!e)return null;let r=nU(t,["status","--porcelain=v1","-z","--untracked-files=all","--","."]);if(r===null)return null;let n=t;try{n=Rce(t)}catch{}let s=new Set,o=r.split("\0");for(let i=0;i<o.length;i++){let a=o[i];if(a.length<4)continue;let c=a.slice(0,2),l=a.slice(3);if((c.includes("R")||c.includes("C"))&&(i+=1),c.includes("D"))continue;let u=jce(n,zce(e,l));u.startsWith("..")||Ace(u)||s.add(u.split(Mce).join("/"))}return[...s].sort()},iU=(t,e)=>{let r=Hce(Kce(t),e.manifestDefault);if(t.scenes().length===0)return{error:"the project has no .pix3scene files."};if(r.length===0)return{error:"every scene is a prefab, a scenes/ui overlay or instanced by another \u2014 name one: pix3 smoke <scene>."};let n=(u,d)=>({mode:"all",scenes:r,reason:u,...d?{changed:d}:{}});if(e.all)return n("--all: every top-level scene");let s=e.changedFiles!==void 0?e.changedFiles:Gce(t.root),o=s===null?null:s.filter(u=>!Vce(u));if(o===null)return e.changedOnly?{error:"--changed needs git and a project inside a git work tree."}:n("every top-level scene (no git history to narrow it down)");if(o.length===0)return e.changedOnly?{error:"--changed: nothing changed since the last commit."}:n("every top-level scene (nothing changed since the last commit)");if(o.includes(xe))return n(`every top-level scene (${xe} changed)`,o);let i=Jce(t),a=new Map(r.map(u=>[u,Wce(t,u,i)])),c=r.filter(u=>o.some(d=>a.get(u)?.has(d))),l=o.filter(u=>Bce(u)&&!r.some(d=>a.get(d)?.has(u)));if(l.length>0||c.length===0){let u=l.slice(0,3).join(", ")+(l.length>3?", \u2026":"");return n(l.length>0?`every top-level scene (changed ${u} reaches no scene directly)`:"every top-level scene (no changed file is used by a scene)",o)}return{mode:"changed",scenes:c,reason:`scenes reached by files changed since the last commit (${o.length} changed; --all for every scene)`,changed:o}}});var kU={};Je(kU,{SMOKE_USAGE:()=>CE,errorSummary:()=>cle,formatGameSnapshot:()=>wU,formatSmokeHuman:()=>zE,formatSmokeJson:()=>jE,formatSmokeSetHuman:()=>SU,formatSmokeSetJson:()=>$U,resolveSmokeScene:()=>hU,runSmoke:()=>gU,runSmokeCli:()=>ale,runSmokeSet:()=>_U,selectScenesFor:()=>yU,smokeExitCode:()=>ME,smokeSetExitCode:()=>bU});import{existsSync as Yce,readFileSync as Xce,statSync as Qce}from"node:fs";import{isAbsolute as ele,join as cU,resolve as RE,sep as lU}from"node:path";import{pathToFileURL as uU}from"node:url";import{Worker as tle}from"node:worker_threads";var dU,CE,fU,pU,rle,Un,nle,hU,sle,AE,ole,mU,gU,yU,_U,vU,hd,NE,wU,zE,jE,ME,bU,ile,SU,$U,ale,cle,xU=$(()=>{"use strict";dU=Ze(Er(),1);ut();sg();pd();OE();rU();aU();CE=`Usage: pix3 smoke [scene] [--changed | --all] [--frames N] [--timeout S] [--json] [--project <dir>]
457
+ ${u}`)},i=this.#y(e);if(i){s(i.status,i.message);return}let o=(e.url??"/").split("?")[0],a=o.startsWith(`${_t}/page/`)?decodeURIComponent(o.slice(`${_t}/page/`.length)):null;if(o!==_t&&!a){s(404,`no WebSocket at ${o} (the browser is at ${_t})`);return}let l;try{let c=a?await this.call("Target.attachToTarget",{targetId:a,flatten:!0}):await this.call("Target.attachToBrowserTarget");l=String(c.sessionId)}catch(c){s(a?404:502,c instanceof Error?c.message:String(c));return}if(r.destroyed){this.call("Target.detachFromTarget",{sessionId:l}).catch(()=>{});return}this.#c.handleUpgrade(e,r,n,c=>this.#_(c,l,a))}#_(e,r,n){let s={socket:e,root:r,sessions:new Set([r]),closed:!1};this.#r.add(s),this.#t.set(r,s),this.#n(`client connected (${n?`page ${n}`:"browser"}; ${this.#r.size} now)`),e.on("message",i=>this.#E(s,i)),e.on("close",()=>{this.#u(s,!0),this.#n(`client gone (${this.#r.size} left)`)}),e.on("error",()=>e.terminate())}#E(e,r){if(e.closed)return;let n;try{n=JSON.parse(r.toString())}catch{this.#o(e,{id:0,error:{code:-32700,message:"Message must be valid JSON"}});return}if(!n||typeof n!="object"||typeof n.id!="number"||typeof n.method!="string"){this.#o(e,{id:typeof n?.id=="number"?n.id:0,error:{code:-32600,message:"Message must have an integer id and a string method"}});return}if(n.sessionId!==void 0&&!e.sessions.has(n.sessionId)){this.#o(e,{id:n.id,error:{code:-32001,message:"Session with given id not found."},sessionId:n.sessionId});return}if(this.#i){this.#o(e,{id:n.id,error:{code:-32e3,message:"Chrome is gone"}});return}let s=this.#g++;this.#s.set(s,{client:e,id:n.id}),this.#a.send(JSON.stringify({...n,id:s,sessionId:n.sessionId??e.root}))}#k(e){let r;try{r=JSON.parse(e)}catch{return}if(typeof r.id=="number"){let o=this.#s.get(r.id);if(!o)return;this.#s.delete(r.id),"internal"in o?o.internal(r):o.client.closed||this.#o(o.client,{...r,id:o.id});return}let n=r.sessionId;if(n===void 0){this.#C(r);return}let s=this.#t.get(n);if(!s)return;let i=r.params?.sessionId;typeof i=="string"&&(r.method==="Target.attachedToTarget"?(s.sessions.add(i),this.#t.set(i,s)):r.method==="Target.detachedFromTarget"&&(s.sessions.delete(i),this.#t.delete(i))),this.#o(s,r)}#C(e){if(e.method!=="Target.detachedFromTarget")return;let r=e.params?.sessionId,n=typeof r=="string"?this.#t.get(r):void 0;!n||n.root!==r||(this.#u(n,!1),Ml(n.socket,1e3,"target closed"))}#o(e,r){if(e.closed)return;let n=r.sessionId===e.root?{...r,sessionId:void 0}:r;e.socket.send(JSON.stringify(n))}#u(e,r){if(!e.closed){e.closed=!0,this.#r.delete(e);for(let n of e.sessions)this.#t.get(n)===e&&this.#t.delete(n);r&&!this.#i&&this.call("Target.detachFromTarget",{sessionId:e.root}).catch(()=>{})}}#O(){if(!this.#i){this.#i=!0;for(let[e,r]of this.#s)"internal"in r&&r.internal({id:e,error:{code:-32e3,message:"Chrome is gone"}});this.#s.clear();for(let e of[...this.#r])this.#u(e,!1),Ml(e.socket,1001,"Chrome closed");this.#e.close(),this.#e.closeAllConnections(),this.#c.close();for(let e of this.#m)e()}}}});import{mkdirSync as nC,readFileSync as sC,rmSync as iC,writeFileSync as oC}from"node:fs";import{dirname as aC}from"node:path";var cr,pm,hm,hi=O(()=>{"use strict";pe();cr=(t=process.env)=>{try{let e=JSON.parse(sC(Gs(t),"utf8"));return typeof e.port=="number"&&typeof e.profile=="string"?e:null}catch{return null}},pm=(t,e=process.env)=>{let r=Gs(e);nC(aC(r),{recursive:!0}),oC(r,`${JSON.stringify(t,null,2)}
458
+ `)},hm=(t,e=process.env)=>{cr(e)?.ownerPid===t&&iC(Gs(e),{force:!0})}});import{mkdirSync as lC,readFileSync as cC,writeFileSync as uC}from"node:fs";import{dirname as dC}from"node:path";var mi,gi,Ll,mm,gm,ym,jl,Sm,fC,bm,yi=O(()=>{"use strict";se();Re();nn();pe();mi=(t=process.env)=>{let e=Wp(t),r=cl(e);return r&&St(e),r},gi=(t,e=process.env)=>{if(t!==void 0)return ym(tl(e),{port:t}),t;let r=gm(tl(e));return vt(r?.port)?r.port:we},Ll=(t=process.env)=>{let e=gm(el(t));return Array.isArray(e?.ports)?e.ports.filter(vt):[]},mm=(t,e=process.env)=>{let r=Ll(e);r.includes(t)||ym(el(e),{ports:[...r,t]})},gm=t=>{try{return JSON.parse(cC(t,"utf8"))}catch{return null}},ym=(t,e)=>{lC(dC(t),{recursive:!0}),uC(t,`${JSON.stringify(e)}
459
+ `)},jl=(t,e=we)=>[`RemoteForward 127.0.0.1:${t} 127.0.0.1:${e}`,"ExitOnForwardFailure yes"],Sm=(t,e,r=process.platform)=>{let n="umask 077 && mkdir -p ~/.pix3 && cat > ~/.pix3/remote-cdp-token";return r==="win32"?`type "${t}" | ssh ${e} "${n}"`:`ssh ${e} '${n}' < ${t}`},fC=(t,e)=>`npx @pix3/cli@${F} editor --chrome-only --url ${t} --remote-port ${e}`,bm=t=>{let{forward:e,port:r}=t,n=t.publicEditorUrl??t.editorUrl,s=["SSH session: Chrome is not launched here \u2014 it runs on the machine with your screen, and an agent","here drives it through an SSH port forward of its CDP token proxy.",""," On your machine, once \u2014 ~/.ssh/config, under the Host you connect to, then reconnect"," (the second port is the proxy's on your machine; pix3 editor prints it there):",...jl(r).map(i=>` ${i}`),` On your machine, each session \u2014 VS Code forwards port ${t.devPort} (its Ports tab shows the local address):`,` ${fC(n,r)}`,t.publicEditorUrl?` (${t.publicEditorUrl} is where a browser reached this server; dev.json publicEditorUrl)`:` (use the local address of port ${t.devPort} if VS Code forwarded it to another port)`," It prints one ssh line that copies its CDP token here; run that line on your machine."," Here, once: npx pix3 agent-setup --remote, then start a new agent thread.",""];return t.token?e.kind==="ours"?s.push(` CDP forward: live on 127.0.0.1:${r} \u2014 it proved it knows the token of ~/.pix3/remote-cdp-token, for this port.`):e.kind==="foreign"?s.push(` CDP forward: port ${r} on this host is held by something that does not prove the token (${e.detail}).`," On a shared host that may be another user waiting for your token: with ExitOnForwardFailure your SSH"," session cannot forward to it. Pick another port \u2014 pix3 editor --cdp-port <n> here (stored), the same"," <n> in your RemoteForward line and --remote-port \u2014 and reconnect."):s.push(` CDP forward: nothing answers on 127.0.0.1:${r} yet (is the SSH session up with the RemoteForward line, and pix3 editor --chrome-only running on your machine?).`):s.push(e.kind==="closed"?` CDP forward: no token here yet (~/.pix3/remote-cdp-token); port ${r} is free.`:` CDP forward: no token here yet (~/.pix3/remote-cdp-token); something answers on port ${r} \u2014 your forward if the SSH session is up, else someone else's: run pix3 editor again after the token copy to tell which.`),`${s.join(`
460
+ `)}
461
+ `}});var vm={};X(vm,{CHROME_OWNER_COMMAND:()=>xm,FIRST_TAB_WAIT_MS:()=>Bl,ensureEditorTab:()=>Ul,runChromeOwner:()=>SC,startChromeOwner:()=>ql,stopChromeOwner:()=>Kl});import{spawn as wm}from"node:child_process";import{mkdirSync as pC,openSync as hC}from"node:fs";import{dirname as mC}from"node:path";import{setTimeout as Fl}from"node:timers/promises";var xm,Dl,gC,yC,SC,ql,Bl,bC,Ul,wC,Kl,Wl=O(()=>{"use strict";Rl();se();al();fm();nn();dl();hi();pe();yi();xm="__chrome-owner",Dl=2e4,gC=3e3,yC=t=>`${new Date().toISOString()} [owner ${process.pid}] ${t}
462
+ `,SC=async(t,e=process.env)=>{let r=m=>process.stdout.write(yC(m)),n;try{if(n=JSON.parse(t[0]??""),typeof n.chrome!="string"||typeof n.port!="number")throw new Error}catch{return r(`bad options: ${t[0]??"(none)"}`),2}let s=kt(e),i=th(n);r(`launching ${n.chrome} ${i.join(" ")}`);let o=wm(n.chrome,i,{stdio:["ignore","ignore","pipe","pipe","pipe"],windowsHide:!1}),a=[];o.stderr?.setEncoding("utf8"),o.stderr?.on("data",m=>{a.push(...m.split(`
463
+ `).filter(Boolean)),a.splice(0,Math.max(0,a.length-20))});let l=new Promise(m=>{o.once("exit",(y,w)=>m(`code ${y??"-"}, signal ${w??"-"}`)),o.once("error",y=>m(y.message))}),c=dm(o.stdio[3],o.stdio[4]),u=new pi({pipe:c,token:s,log:r,forwardPorts:()=>Ll(e)}),f=await Promise.race([u.call("Browser.getVersion").then(m=>({ok:!0,product:String(m.product)}),()=>Promise.race([l,new Promise(m=>setTimeout(()=>m("pipe closed"),2e3))]).then(m=>({ok:!1,why:`Chrome exited before it answered (${m})`}))),l.then(m=>({ok:!1,why:`Chrome exited before it answered (${m})`})),new Promise(m=>setTimeout(()=>m({ok:!1,why:`Chrome did not answer within ${Dl} ms`}),Dl).unref())]);if(!f.ok)return r(`${f.why}. A Chrome that already runs the profile ${n.profile} (an editor window of an earlier pix3 editor?) takes a new launch over: close it and run pix3 editor again.`+(a.length?`
464
+ Chrome said:
465
+ ${a.join(`
466
+ `)}`:"")),o.kill("SIGKILL"),3;let d;try{d=await u.listen(n.port)}catch(m){return r(`cannot listen on 127.0.0.1:${n.port}: ${m.message}`),o.kill("SIGKILL"),4}pm({port:d,profile:n.profile,startedAt:new Date().toISOString(),editorUrl:n.url,ownerPid:process.pid,chromePid:o.pid,proxy:Zt},e),r(`${f.product} (pid ${o.pid}) behind ${Pe(d)}`);let h=!1,g=m=>{h||(h=!0,r(`${m}: closing Chrome`),u.call("Browser.close").catch(()=>{}),setTimeout(()=>o.kill("SIGKILL"),gC).unref())};for(let m of["SIGTERM","SIGINT","SIGHUP"])process.on(m,()=>g(m));let p=await new Promise(m=>{u.onClose(()=>m("pipe closed")),l.then(m)});return r(`Chrome is gone (${p})`),hm(process.pid,e),await u.close().catch(()=>{}),0},ql=async t=>{let{entry:e,env:r,timeoutMs:n,...s}=t,i=Kp(r);pC(mC(i),{recursive:!0});let o=hC(i,"w"),a=kt(r),l=wm(process.execPath,[e,xm,JSON.stringify(s)],{detached:!0,stdio:["ignore",o,o],env:r,windowsHide:!0});l.unref();let c=Date.now()+(n??Dl+2e3);for(;Date.now()<c&&l.exitCode===null;){if((await Qs(t.port,{token:a})).kind==="ours")return l;await Fl(150)}l.exitCode===null&&l.kill("SIGTERM");let u=ms(i,12);throw new Error(`${l.exitCode!==null?`the Chrome owner exited (code ${l.exitCode})`:"the CDP proxy did not come up"} \u2014 ${i}:
467
+ ${u}`)},Bl=4e3,bC=5e3,Ul=async(t,e,r,n={})=>{let s=async l=>{let c=Date.now()+l;for(;;){let u=await Qs(t,{token:e});if(u.kind!=="ours")return null;let f=u.pages.some(d=>d.startsWith(r));if(f||Date.now()>=c)return{open:f,browser:u.browser};await Fl(200)}},i=await s(n.waitMs??0);if(!i)return{ok:!1,detail:`the CDP proxy on port ${t} stopped answering`};if(i.open)return{ok:!0,detail:n.waitMs?`${r}`:`${r} \u2014 the editor tab is open there`};let o=/headless/i.test(i.browser);try{await wC(t,e,"Target.createTarget",{url:r,...o?{}:{newWindow:!0}})}catch(l){return{ok:!1,detail:`could not open the editor in the running Chrome: ${l.message}`}}return(await s(bC))?.open?{ok:!0,detail:`${r} \u2014 opened the editor in a new ${o?"tab":"window"} through the proxy`}:{ok:!1,detail:`Chrome took Target.createTarget for ${r}, but no such tab is listed by the proxy (/json/list)`}},wC=(t,e,r,n={},s=5e3)=>new Promise((i,o)=>{let a=new cm(Pe(t),{headers:{Authorization:`Bearer ${e}`},perMessageDeflate:!1}),l=setTimeout(()=>{a.terminate(),o(new Error(`${r}: no answer within ${s} ms`))},s);a.once("error",c=>{clearTimeout(l),o(c)}),a.once("open",()=>a.send(JSON.stringify({id:1,method:r,params:n}))),a.on("message",c=>{let u=JSON.parse(c.toString());u.id===1&&(clearTimeout(l),a.close(),u.error?o(new Error(`${r}: ${u.error.message}`)):i(u.result??{}))})}),Kl=async(t,e=6e3)=>{try{process.kill(t,"SIGTERM")}catch{return!1}let r=Date.now()+e;for(;Date.now()<r;){try{process.kill(t,0)}catch{return!0}await Fl(100)}return!1}});import{spawn as xC}from"node:child_process";import{mkdirSync as vC,openSync as _C,readFileSync as EC,rmSync as Em}from"node:fs";import{join as We}from"node:path";import{setTimeout as kC}from"node:timers/promises";var bi,Si,_m,CC,wi,xi,km,OC,Cm,Om,Tm=O(()=>{"use strict";se();bi=We(".pix3","dev.json"),Si=We(".pix3","dev.log"),_m=15e3,CC=2e3,wi=t=>{try{let e=JSON.parse(EC(We(t,bi),"utf8"));return typeof e.url=="string"&&typeof e.editorUrl=="string"&&typeof e.pid=="number"?e:null}catch{return null}},xi=async(t,e=fetch)=>{let r=`${t.endsWith("/")?t:`${t}/`}__pix3/api/hello`;try{return(await e(r,{signal:AbortSignal.timeout(CC)})).ok}catch{return!1}},km=async(t,e=fetch)=>{let r=wi(t);return r?await xi(r.url,e)?{status:"live",info:r}:{status:"stale",info:r}:{status:"none"}},OC=t=>tt(t,We("node_modules","vite","bin","vite.js")),Cm=async(t,e={})=>{let r=OC(t);if(!r)throw new Error(`No vite in ${t} (node_modules/vite/bin/vite.js): run \`npm install\` in the project first.`);let n=wi(t);vC(We(t,".pix3"),{recursive:!0}),Em(We(t,bi),{force:!0});let s=_C(We(t,Si),"w"),i=[r,...e.port?["--port",String(e.port),"--strictPort"]:[]],o=(e.spawnImpl??xC)(process.execPath,i,{cwd:t,detached:!0,stdio:["ignore",s,s],env:{...process.env,FORCE_COLOR:"0"},windowsHide:!0});o.unref();let a=Date.now()+(e.timeoutMs??_m);for(;Date.now()<a&&o.exitCode===null;){let c=wi(t);if(c&&c.pid!==n?.pid&&await xi(c.url,e.fetch))return c;await kC(200)}let l=ms(We(t,Si),15);throw new Error(o.exitCode!==null?`vite exited with code ${o.exitCode} (see ${Si}):
468
+ ${l}`:`the dev server did not write ${bi} within ${e.timeoutMs??_m} ms (see ${Si}):
469
+ ${l}`)},Om=t=>{let e=wi(t);if(!e)return{stopped:!1,pid:null};try{return process.kill(e.pid,"SIGTERM"),{stopped:!0,pid:e.pid}}catch{return Em(We(t,bi),{force:!0}),{stopped:!1,pid:e.pid}}}});import{copyFileSync as TC}from"node:fs";import{join as Gl}from"node:path";var Jl,ct,PC,$C,NC,AC,vi,IC,_i,$m,Nm,RC,Am,Im,MC,LC,Pm,Rm,jC,DC,Mm,FC,Lm,qC,Vl,jm,BC,UC,Dm,Fm,qm,Hl=O(()=>{"use strict";pe();se();Jl="1.10.1",ct="pix3-browser",PC=".mcp.json",$C=Gl(".codex","config.toml"),NC=300,AC=20,vi=["claude","codex"],IC=t=>JSON.stringify({Authorization:`Bearer ${t}`}),_i=(t,e=process.platform)=>{let r=["npx","-y",`chrome-devtools-mcp@${Jl}`,"--categoryExperimentalThirdParty=true","--experimentalVision=true",`--config=${t}`];return e==="win32"?{command:"cmd",args:["/c",...r]}:{command:r[0],args:r.slice(1)}},$m=(t,e)=>`${JSON.stringify({wsEndpoint:Pe(t),wsHeaders:IC(e)},null,2)}
470
+ `,Nm=(t,e,r)=>{let n=$m(e,r),s=W(t);return s!==n&&Q(t,n,{mode:384}),St(t),s===null?"written":s===n?"unchanged":"updated"},RC=(t,e,r)=>W(t)===$m(e,r),Am=t=>{if(!t)return{};try{let e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}},Im=t=>({command:t.command,args:[...t.args]}),MC=(t,e)=>{let r=Am(t),n=r.mcpServers&&typeof r.mcpServers=="object"&&!Array.isArray(r.mcpServers)?r.mcpServers:{};return`${JSON.stringify({...r,mcpServers:{...n,[ct]:Im(e)}},null,2)}
471
+ `},LC=t=>{let e=Am(t).mcpServers;if(!e||typeof e!="object")return null;let r=e[ct];return r&&typeof r=="object"?r:null},Pm=t=>JSON.stringify(t),Rm=t=>[`[mcp_servers.${ct}]`,`command = ${Pm(t.command)}`,`args = [${t.args.map(Pm).join(", ")}]`,`startup_timeout_sec = ${AC}`,`tool_timeout_sec = ${NC}`,""].join(`
472
+ `),jC=new RegExp(`^\\[mcp_servers\\.${ct.replace(/-/g,"\\-")}\\]\\s*$`),DC=/^\s*\[/,Mm=t=>{let e=t.findIndex(n=>jC.test(n.trim()));if(e<0)return null;let r=e+1;for(;r<t.length&&!DC.test(t[r]);)r++;return{start:e,end:r}},FC=t=>{if(!t)return null;let e=t.split(`
473
+ `),r=Mm(e);return r?Lm(e.slice(r.start,r.end).join(`
474
+ `)):null},Lm=t=>t.split(`
475
+ `).map(e=>e.trim()).filter(e=>e&&!e.startsWith("#")).join(`
476
+ `),qC=(t,e)=>{let r=Rm(e);if(!t)return r;let n=t.split(`
477
+ `),s=Mm(n);if(!s){let l=t.endsWith(`
478
+ `)?t.endsWith(`
356
479
 
357
- Run the game headless in Node \u2014 no browser, no editor: the project's scripts compiled, the scene
358
- loaded by the real loader, N frames of 1/60 s stepped by the real SceneRunner. Reports every
359
- script throw (onAttach/onStart/onUpdate, with script name, frame and stack), console.error/warn,
360
- unhandled rejections, missing res:// files and per-frame step time. Nothing is rendered; audio,
361
- input and network are inert.
480
+ `)?"":`
481
+ `:`
362
482
 
363
- scene .pix3scene to run (res://, project-relative or a path) \u2014 the surest way to test
364
- the game: pix3 smoke scenes/main.pix3scene. With no scene, several run one after
365
- another, a line each: in a git repo with uncommitted changes, the top-level scenes
366
- those changes reach (the scene, a prefab/overlay it instances, a user: script it
367
- attaches); otherwise \u2014 or when a changed scene/script reaches none \u2014 every
368
- top-level scene (not a prefab, not scenes/ui), scenes/main.pix3scene first.
369
- --changed only the scenes changed files reach (needs git; exit 2 when nothing changed)
370
- --all every top-level scene, whatever git says
371
- --frames N frames to step (default 120 = 2 s of game time)
372
- --timeout S wall-clock limit in seconds (default 20) \u2192 exit 2, E_SMOKE_TIMEOUT
373
- --json machine-readable report
374
- --project dir project folder (default: nearest folder with pix3project.yaml)
483
+ `;return`${t}${l}${r}`}let i=n.slice(s.end),o=n.slice(0,s.start).join(`
484
+ `),a=i.join(`
485
+ `);return`${o?`${o}
486
+ `:""}${r}${a?`${a.startsWith(`
487
+ `)?"":`
488
+ `}${a}`:""}`},Vl=t=>t==="claude"?PC:$C,jm=(t,e,r)=>{let n=t==="claude"?JSON.stringify(Im(r)):Lm(Rm(r)),s=t==="claude"?LC(e):null;return{current:t==="claude"?s?JSON.stringify(s):null:FC(e),expected:n}},BC=t=>t.includes("--browserUrl="),UC=t=>t.includes("--wsHeaders"),Dm=t=>t?BC(t)?" (the P1 launch: --browserUrl at an open debugging port, no token)":UC(t)?" (an earlier launch with the CDP token on its command line and in this file)":"":"",Fm=(t,e)=>{let r=_i(e.configPath,e.platform),n=[],s=!1;for(let i of e.targets??vi){let{current:o,expected:a}=jm(i,W(Gl(t,Vl(i))),r);o!==null&&o!==a&&n.push(Vl(i)),o===a&&(s=!0)}return s&&!RC(e.configPath,e.port,e.token)&&n.push(e.configPath),n},qm=(t,e)=>{let r=_i(e.configPath,e.platform),n=[];for(let s of e.targets??vi){let i=Vl(s),o=Gl(t,i),a=W(o),{current:l,expected:c}=jm(s,a,r),u=s==="claude"?MC:qC;if(l===null)Q(o,u(a,r)),n.push({target:s,file:i,action:"written"});else if(l===c)n.push({target:s,file:i,action:"unchanged"});else if(e.repair){let f=`${o}.bak`;TC(o,f),Q(o,u(a,r)),n.push({target:s,file:i,action:"repaired",backup:`${i}.bak`})}else n.push({target:s,file:i,action:"drift",current:l})}return n}});var Km={};X(Km,{parseEditorArgs:()=>Bm,runEditorCli:()=>WC});var Bm,KC,WC,VC,Um,Wm=O(()=>{"use strict";Z();al();rn();nn();dl();Wl();hi();Tm();pe();yi();Hl();de();Bm=t=>{let e={};for(let r=0;r<t.length;r++){let n=t[r],s=()=>{let o=t[++r];return o===void 0||o.startsWith("-")?{error:`${n} needs a value`}:o},i=()=>{let o=s();if(typeof o!="string")return o;let a=Number(o);return vt(a)?a:{error:`${n} needs a port`}};switch(n){case"--stop":e.stop=!0;break;case"--stop-chrome":e.stopChrome=!0;break;case"--chrome-only":e.chromeOnly=!0;break;case"--no-chrome":e.noChrome=!0;break;case"--headless":e.headless=!0;break;case"--url":{let o=s();if(typeof o!="string")return o;let a;try{a=new URL(o)}catch{return{error:`--url needs an http(s) URL, not "${o}"`}}if(a.protocol!=="http:"&&a.protocol!=="https:")return{error:`--url needs an http(s) URL, not "${o}"`};e.url=KC(a),e.chromeOnly=!0;break}case"--ssh":{let o=s();if(typeof o!="string")return o;e.sshHost=o;break}case"--project":{let o=s();if(typeof o!="string")return o;e.projectDir=o;break}case"--cdp-port":{let o=i();if(typeof o!="number")return o;e.cdpPort=o;break}case"--port":{let o=i();if(typeof o!="number")return o;e.devPort=o;break}case"--remote-port":{let o=i();if(typeof o!="number")return o;e.remotePort=o;break}default:return{error:`unknown option "${n}"`}}}return e.remotePort!==void 0&&!e.url?{error:"--remote-port goes with --url"}:e},KC=t=>{let e=t.pathname.replace(/\/+$/,""),r=e.endsWith("/__pix3")?e.slice(0,-7):e;return`${t.origin}${r}/__pix3/`},WC=async(t,e)=>{if(t.includes("--help")||t.includes("-h"))return e.stdout(I.editor),0;let r=Bm(t);if("error"in r)return e.stderr(`pix3 editor: ${r.error}
375
489
 
376
- Exit: 0 = no errors, 1 = errors, 2 = could not run (no scene, bundle failure, unsupported, timeout).
377
- `,fU=120,pU=20,rle=t=>{let e,r=fU,n=pU,s=!1,o=!1,i=!1,a,c=!1,l=(u,d)=>{let f=u.indexOf("=");return f>0?{value:u.slice(f+1),next:d}:{value:t[d+1],next:d+1}};for(let u=0;u<t.length;u++){let d=t[u],f=d.split("=")[0];if(d==="--json")s=!0;else if(d==="--changed")o=!0;else if(d==="--all")i=!0;else if(d==="--help"||d==="-h")c=!0;else if(f==="--frames"||f==="--timeout"||f==="--project"){let{value:p,next:m}=l(d,u);if(u=m,p===void 0||p.startsWith("--"))return{error:`${f} needs a value`};if(f==="--project")a=p;else{let h=Number(p);if(!Number.isFinite(h)||h<=0)return{error:`${f} needs a positive number`};f==="--frames"?r=Math.floor(h):n=h}}else{if(d.startsWith("-"))return{error:`unknown argument ${d}`};if(e===void 0)e=d;else return{error:`one scene at a time (got ${e} and ${d})`}}}return o&&i?{error:"--changed and --all exclude each other"}:e!==void 0&&(o||i)?{error:`${o?"--changed":"--all"} picks the scenes; drop ${e} or the flag`}:{scene:e,changed:o,all:i,frames:r,timeoutSec:n,json:s,project:a,help:c}},Un=(t,e,r)=>({ok:!1,code:t,reason:e,...r?{scene:r}:{}}),nle=t=>{let e={viewport:{width:1920,height:1080},localization:null};try{let r=(0,dU.parse)(Xce(cU(t,xe),"utf8"));if(!ke(r))return e;let n=ke(r.viewportBaseSize)?r.viewportBaseSize:{},s=typeof n.width=="number"&&n.width>0?n.width:1920,o=typeof n.height=="number"&&n.height>0?n.height:1080,i=typeof r.defaultExportScenePath=="string"&&r.defaultExportScenePath.trim()?r.defaultExportScenePath.trim().replace(/^res:\/\//i,"").replace(/^\/+/,""):void 0;return{viewport:{width:s,height:o},localization:ke(r.localization)?r.localization:null,...i?{defaultScene:i}:{}}}catch{return e}},hU=(t,e,r)=>{let n=[],s=r.replace(/^res:\/\//i,"").replace(/^\/+/,"");n.push(s.split(lU).join("/"));let o=t.relativeOf(ele(r)?r:RE(e,r));o&&n.push(o);let i=n.find(a=>t.has(a));return i?i.endsWith(".pix3scene")?i:Un("E_SMOKE_NO_SCENE",`${i} is not a .pix3scene.`):Un("E_SMOKE_NO_SCENE",`${r} is not a file in the project (${t.root}).`)},sle=(t,e,r)=>new Promise(n=>{let s=!1,o=new tle(uU(cU(t,og)),{workerData:e,stdout:!0,stderr:!0});o.stdout.resume(),o.stderr.resume();let i=c=>{s||(s=!0,clearTimeout(a),o.terminate(),n(c))},a=setTimeout(()=>{i(Un("E_SMOKE_TIMEOUT",`the run did not finish within ${r} s (a script stuck in a loop, or a scene too heavy for ${e.frames} frames; try --frames or --timeout).`,e.scene))},r*1e3);o.once("message",c=>i(c)),o.once("error",c=>i(Un("E_SMOKE_CRASH",`the smoke worker crashed: ${c instanceof Error?c.message:String(c)}`,e.scene))),o.once("exit",c=>i(Un("E_SMOKE_CRASH",`the smoke worker exited (code ${c}) without a report.`,e.scene)))}),AE=t=>{let e=RE(t);return!Yce(e)||!Qce(e).isDirectory()?Un("E_SMOKE_NO_PROJECT",`${e} is not a folder.`):{root:e,project:new Aa(e),manifest:nle(e)}},ole=(t,e,r)=>({projectRoot:t.root,scene:e,frames:r.frames??fU,viewport:t.manifest.viewport,localization:t.manifest.localization,esbuildSpecifier:TE(),fallbackResolveDir:Wt()}),mU=async(t,e,r)=>{let n=r.timeoutSec??pU;try{return await PE(async s=>{let o=[];for(let i of e)o.push(await sle(s,ole(t,i,r),n));return o})}catch(s){let o=`could not build or load the smoke bundle: ${s instanceof Error?s.message:String(s)}`;return e.map(i=>Un("E_SMOKE_BUNDLE",o,i))}},gU=async t=>{let e=AE(t.projectRoot);if("code"in e)return e;let r=hU(e.project,t.cwd??e.root,t.scene);if(typeof r!="string")return r;let[n]=await mU(e,[r],t);return n},yU=t=>{let e=AE(t.projectRoot);if("code"in e)return e;let r=iU(e.project,{manifestDefault:e.manifest.defaultScene,changedOnly:t.changedOnly,all:t.all,...t.changedFiles!==void 0?{changedFiles:t.changedFiles}:{}});return"error"in r?Un("E_SMOKE_NO_SCENE",r.error):r},_U=async t=>{let e=AE(t.projectRoot);if("code"in e)return e;let r=yU(t);if("code"in r)return r;let n=await mU(e,r.scenes,t);return{ok:n.every(s=>!zs(s)&&s.errors.length===0),selection:r.mode,reason:r.reason,...r.changed?{changed:r.changed}:{},runs:n}},vU=(t,e,r)=>{if(!t)return[];let n=uU(e).href;return t.split(`
378
- `).slice(1).map(s=>s.trim().replaceAll(`${n}/`,"").replaceAll(`${e}${lU}`,"").replaceAll(`${e}/`,"")).filter(s=>s.startsWith("at ")).slice(0,r)},hd=(t,e)=>`${t} ${e}${t===1?"":"s"}`,NE=4e3,wU=t=>{let e=JSON.stringify(t)??"null";if(e.length<=120)return e;let r=JSON.stringify(t,null,2)??"null";return`
379
- ${(r.length>NE?`${r.slice(0,NE)}
380
- \u2026 (${r.length-NE} more characters; pix3 smoke --json has it whole)`:r).split(`
490
+ ${I.editor}`),2;let n=e.env??process.env;if(r.stopChrome){let c=cr(n);if(!c?.ownerPid)return e.stdout(`No Chrome owner recorded in ~/.pix3/chrome.json.
491
+ `),0;let u=await Kl(c.ownerPid);return e.stdout(u?`Stopped Chrome and its CDP proxy on port ${c.port} (owner pid ${c.ownerPid}).
492
+ `:`The Chrome owner recorded (pid ${c.ownerPid}) is not running or did not stop.
493
+ `),0}if(r.url)return VC(r.url,r,e,n);let s=ue(e.cwd,r.projectDir);if("error"in s)return e.stderr(`pix3 editor: ${s.error}
494
+ `),2;let{root:i}=s;if(r.stop){let c=Om(i);return e.stdout(c.stopped?`Stopped the dev server (pid ${c.pid}).
495
+ `:c.pid===null?`No dev server recorded in .pix3/dev.json.
496
+ `:`The dev server recorded in .pix3/dev.json (pid ${c.pid}) is already gone; record removed.
497
+ `),0}let o,a=await km(i);if(a.status==="live")o=a.info,e.stdout(`Dev server: ${o.url} (pid ${o.pid}, reused)
498
+ `);else{if(r.chromeOnly)return e.stderr(a.status==="stale"?`pix3 editor: .pix3/dev.json points at ${a.info.url}, which does not answer; start the dev server (\`npm run dev\` or \`pix3 editor\` without --chrome-only).
499
+ `:"pix3 editor: no .pix3/dev.json \u2014 start the dev server first (`npm run dev` or `pix3 editor` without --chrome-only).\n"),1;a.status==="stale"&&e.stdout(`Dev server recorded at ${a.info.url} does not answer; starting a new one.
500
+ `);try{o=await Cm(i,{port:r.devPort})}catch(c){return e.stderr(`pix3 editor: ${c instanceof Error?c.message:String(c)}
501
+ `),1}e.stdout(`Dev server: ${o.url} (pid ${o.pid}, started; log in .pix3/dev.log)
502
+ `)}if(e.stdout(`Editor: ${o.editorUrl}
503
+ `),o.publicEditorUrl&&e.stdout(`Browser: ${o.publicEditorUrl} (dev.json publicEditorUrl)
504
+ `),r.noChrome)return 0;if(n.SSH_CONNECTION&&!r.headless&&!n.PIX3_CHROME){let c=mi(n),u=gi(r.cdpPort,n),f=c??ll();return e.stdout(`
505
+ ${bm({editorUrl:o.editorUrl,publicEditorUrl:o.publicEditorUrl,devPort:o.port,token:c,port:u,forward:await zs(u,f,{scope:"forward"})})}`),0}return await Um(o.editorUrl,i,r,e,n)===null?1:0},VC=async(t,e,r,n)=>{if(!await xi(t.slice(0,-7)))return r.stderr(`pix3 editor: ${t} does not answer as a Pix3 editor. Is the dev server running on the remote host (\`npm run editor\` there) and its port forwarded here (VS Code: the Ports tab)?
506
+ `),1;r.stdout(`Editor: ${t} (a dev server reached through a port forward)
507
+ `);let s=e.remotePort??we;mm(s,n);let i=await Um(t,null,e,r,n);return i===null?1:(r.stdout(`
508
+ For a coding agent on the remote host (once per token): copy the token there over SSH \u2014
509
+ ${Sm(tn(n),e.sshHost??"<ssh-host>")}
510
+ then run \`npx pix3 agent-setup --remote\` there and start a new agent thread. Your ~/.ssh/config
511
+ must bring this proxy back to port ${s} of the remote host (the port pix3 editor printed there;
512
+ another one: --remote-port <n> here, pix3 editor --cdp-port <n> there):
513
+ `+jl(s,i).map(o=>` ${o}
514
+ `).join("")),0)},Um=async(t,e,r,n,s)=>{let i=Zp(s);if(!i)return n.stderr(`pix3 editor: ${rh()}
515
+ `),null;let o=kt(s),a=cr(s),l=r.cdpPort??we,c;try{c=await Hp({preferred:l,recordedPort:a?.port??null,token:o})}catch(d){return n.stderr(`pix3 editor: ${d instanceof Error?d.message:String(d)}
516
+ `),null}for(let d of c.skipped)n.stdout(`Port ${d.port}: ${d.detail}
517
+ `);if(c.state.kind==="legacy")return n.stderr(`pix3 editor: port ${c.port} is ${c.state.browser} started by an earlier pix3 editor with an open debugging port and no token \u2014 any local process can drive it. Close that Chrome (every window of the Pix3 profile ${a?.profile??Vs(s)}) and run pix3 editor again: Chrome now runs behind the token proxy.
518
+ `),null;let u=a?.profile&&c.state.kind==="ours"?a.profile:eh(s);if(c.state.kind==="ours")n.stdout(`Chrome: ${c.state.browser} already behind ${Pe(c.port)}
519
+ `);else{try{await ql({entry:n.entry??process.argv[1],env:s,chrome:i.path,port:c.port,profile:u,url:t,headless:r.headless})}catch(d){return n.stderr(`pix3 editor: ${d instanceof Error?d.message:String(d)}
520
+ `),null}n.stdout(`Chrome: launched behind the CDP proxy ${Pe(c.port)} (token in ~/.pix3/cdp-token; profile ${u})
521
+ `)}let f=await Ul(c.port,o,t,{waitMs:c.state.kind==="ours"?0:Bl});if(!f.ok)return n.stderr(`pix3 editor: ${f.detail}
522
+ `),null;if(n.stdout(`Editor tab: ${f.detail}
523
+ `),e&&c.port!==l)n.stdout(`Port ${l} was taken, using ${c.port}: run \`pix3 agent-setup --repair\` so chrome-devtools-mcp points at it. A Codex or Claude Code session that is already running keeps the old port \u2014 restart it or start a new thread.
524
+ `);else if(e){let d=Hs(s),h=Fm(e,{port:c.port,token:o,configPath:d}),g=h.filter(m=>m!==d),p=[];g.length&&p.push(`${g.join(" and ")} ${g.length>1?"have":"has"} a pix3-browser entry that does not reach this Chrome (an older launch: another port, another token, the token on its command line)`),h.includes(d)&&p.push(`${d} (what chrome-devtools-mcp reads) holds another port or token`),p.length&&n.stdout(`${p.join("; ")}: run \`pix3 agent-setup --repair\`, then start a new agent thread.
525
+ `)}return c.port}});var Gm={};X(Gm,{parseAgentSetupArgs:()=>Vm,runAgentSetupCli:()=>GC});var Vm,GC,JC,Jm=O(()=>{"use strict";nn();hi();rn();pe();yi();Z();de();Hl();Vm=t=>{let e=[],r=!1,n,s,i=!1;for(let o=0;o<t.length;o++){let a=t[o];if(a==="--repair")r=!0;else if(a==="--remote")i=!0;else if(a==="--project"){if(n=t[++o],!n||n.startsWith("-"))return{error:"--project needs a directory"}}else if(a==="--cdp-port"){let l=Number(t[++o]);if(!vt(l))return{error:"--cdp-port needs a port"};s=l}else if(a==="claude"||a==="codex")e.push(a);else return{error:`agent-setup takes claude or codex, not "${a}"`}}return{targets:e.length?e:vi,repair:r,projectDir:n,cdpPort:s,...i?{remote:i}:{}}},GC=async(t,e)=>{if(t.includes("--help")||t.includes("-h"))return e.stdout(I["agent-setup"]),0;let r=Vm(t);if("error"in r)return e.stderr(`pix3 agent-setup: ${r.error}
526
+
527
+ ${I["agent-setup"]}`),2;let n=e.env??process.env,s=ue(e.cwd,r.projectDir);if("error"in s)return e.stderr(`pix3 agent-setup: ${s.error}
528
+ `),2;let{root:i}=s,o,a,l;if(r.remote){let p=await JC(r,e,n);if(!p)return 1;({port:o,token:a}=p),l=Vp(n)}else o=r.cdpPort??cr(n)?.port??we,a=kt(n),l=Hs(n);let c=Nm(l,o,a),u=_i(l),f=[u.command,...u.args].join(" ");e.stdout(`${ct}: ${f}
529
+ (chrome-devtools-mcp ${Jl}; ${l} (0600, ${c}) holds the endpoint ${Pe(o)} \u2014 `+(r.remote?"the SSH forward of your machine's CDP proxy":`the CDP proxy of pix3 editor${o!==we?", the port it recorded":""}`)+` \u2014 and its token; no token in the project or on a command line)
530
+ `);let d=qm(i,{targets:r.targets,configPath:l,repair:r.repair}),h=!1;for(let p of d){let m=p.target==="claude"?"Claude Code":"Codex";switch(p.action){case"written":e.stdout(` ${m}: wrote ${p.file}
531
+ `);break;case"unchanged":e.stdout(` ${m}: ${p.file} is up to date
532
+ `);break;case"repaired":e.stdout(` ${m}: repaired ${p.file} (previous copy in ${p.backup})
533
+ `);break;case"drift":h=!0,e.stdout(` ${m}: ${p.file} has a different ${ct} entry${Dm(p.current)} \u2014 run \`pix3 agent-setup --repair\` to rewrite it
534
+ `);break}}return(c==="updated"||d.some(p=>p.action==="written"||p.action==="repaired"))&&e.stdout(`
535
+ A Codex or Claude Code session that is already running does not see the change: start a new thread.
536
+ `),r.targets.includes("codex")&&e.stdout(`Codex reads .codex/config.toml of a trusted project; for one global entry instead: copy the table into ~/.codex/config.toml.
537
+ Codex\u2019s sandbox must allow the MCP process to reach 127.0.0.1 \u2014 approve it once when asked; nothing here changes sandbox settings.
538
+ `),r.targets.includes("claude")&&e.stdout(`Claude Code picks .mcp.json up from the project (approve it when asked); for every project instead: \`claude mcp add --scope user ${ct} -- ${f}\`.
539
+ `),h?1:0},JC=async(t,e,r)=>{let n=gi(t.cdpPort,r),s=mi(r);if(!s)return e.stderr(`pix3 agent-setup --remote: no ~/.pix3/remote-cdp-token here. On your machine, run
540
+ npx @pix3/cli editor --chrome-only --url <the editor address VS Code forwarded> --remote-port ${n}
541
+ and the ssh line it prints (it copies the token here over SSH; never paste the token by hand).
542
+ `),null;let i=await zs(n,s,{scope:"forward"});return i.kind==="foreign"?(e.stderr(`pix3 agent-setup --remote: port ${n} on this host does not prove it knows the token for port ${n} \u2014 nothing written.
543
+ ${i.detail}
544
+ On a shared host it may be another user waiting for the token. If your SSH session is up with
545
+ ExitOnForwardFailure and RemoteForward 127.0.0.1:${n} \u2026, it is not your forward. Pick another port:
546
+ \`pix3 editor --cdp-port <n>\` here, the same <n> in RemoteForward and in --remote-port on your machine.
547
+ `),null):(i.kind==="closed"&&e.stdout(` Port ${n} does not answer yet; written anyway \u2014 it must prove the token once the SSH session is up (pix3 editor here says when).
548
+ `),{port:n,token:s})}});import{readdirSync as HC,readFileSync as YC}from"node:fs";import{isAbsolute as zC,join as Yl,relative as Ym,resolve as Hm,sep as zm}from"node:path";var XC,zl,QC,Xl,ur,Xm,ut,ZC,fn=O(()=>{"use strict";XC=U(ce(),1);se();Z();xt();zl=new Set(["node_modules",".yalc",".git",".pix3","dist",".vite",".cache"]),QC=[".pix3scene",".prefab"],Xl=t=>{let e=t.toLowerCase();return QC.some(r=>e.endsWith(r))},ur=class{root;files;fileSet;textCache=new Map;constructor(e){this.root=Hm(e),this.files=Xm(this.root,this.root).sort(),this.fileSet=new Set(this.files)}has(e){return this.fileSet.has(e)}absolute(e){return Yl(this.root,e)}relativeOf(e){let r=Ym(this.root,Hm(e));return r.startsWith("..")||zC(r)?null:r.split(zm).join("/")}readText(e){let r=this.textCache.get(e);if(r!==void 0)return r;let n=YC(this.absolute(e),"utf8");return this.textCache.set(e,n),n}scenes(){return this.files.filter(Xl)}},Xm=(t,e)=>{let r=[],n;try{n=HC(e,{withFileTypes:!0})}catch{return r}for(let s of n)if(s.isDirectory()){if(zl.has(s.name))continue;r.push(...Xm(t,Yl(e,s.name)))}else s.isFile()&&r.push(Ym(t,Yl(e,s.name)).split(zm).join("/"));return r},ut=t=>{let e=t.trim();if(e.length===0)return null;let r=/^([a-z][a-z0-9+.-]*):/i.exec(e)?.[1]?.toLowerCase();if(r&&r!=="res")return null;let s=(r==="res"?e.replace(/^res:\/\//i,""):e).replace(/[?#].*$/,""),i=[];for(let o of s.replace(/\\/g,"/").split("/"))if(!(o===""||o===".")){if(o===".."){if(i.length===0)return null;i.pop();continue}i.push(ZC(o))}return i.length===0?null:i.join("/")},ZC=t=>{try{return decodeURIComponent(t)}catch{return t}}});var Qm=x(()=>{throw new Error("src\\smoke\\bundle.ts is only available in a checkout of the pix3 repo (the published @pix3/cli ships its bundles prebuilt)")});var Zm={};X(Zm,{SMOKE_WORKER_FILE:()=>Ei,TREE_DEFAULTS_FILE:()=>eO,withSmokeBundle:()=>Ql});var Ei,eO,Ql,Zl=O(()=>{"use strict";Ie();Ei="smoke-worker.mjs",eO="tree-defaults.mjs",Ql=t=>ws("smoke",Ei,async e=>(await Promise.resolve().then(()=>U(Qm(),1))).buildSmokeBundle(e),t)});var dt,eg=O(()=>{"use strict";dt=t=>"code"in t});import{execFileSync as tO}from"node:child_process";import{realpathSync as rO}from"node:fs";import{isAbsolute as nO,join as sO,relative as iO,sep as oO}from"node:path";var aO,lO,cO,uO,dO,rg,fO,pO,ec,ng,hO,mO,gO,yO,tg,SO,sg,ig=O(()=>{"use strict";Z();Bs();fn();aO="scenes/main.pix3scene",lO=/^\s*(?:-\s+)?instance:\s*["']?(?:res:\/\/)?([^"'\s#]+)/gm,cO=/res:\/\/[^"'\s#)]+/g,uO=/\buser:([A-Za-z_$][\w$]*)/g,dO=/(^|\/)(prefabs?|ui)\/|\.prefab$/i,rg=t=>/\.(ts|mts|js|mjs)$/.test(t)&&!/\.(d|spec|test)\.(ts|mts|js|mjs)$/.test(t),fO=t=>t.split("/").some(e=>zl.has(e)),pO=t=>Xl(t)||rg(t),ec=(t,e)=>{try{return t.readText(e)}catch{return""}},ng=(t,e)=>{let r=[];for(let n of ec(t,e).matchAll(lO)){let s=ut(n[1]);s&&r.push(s)}return r},hO=t=>{let e=t.scenes(),r=new Set;for(let n of e)for(let s of ng(t,n))r.add(s);return e.filter(n=>!r.has(n)&&!dO.test(n))},mO=(t,e)=>{let r=n=>n===aO?0:n===e?1:2;return[...t].sort((n,s)=>r(n)-r(s)||n.localeCompare(s))},gO=(t,e,r)=>{let n=new Set,s=[e];for(;s.length>0;){let i=s.pop();if(n.has(i))continue;n.add(i);let o=ec(t,i);for(let a of ng(t,i))s.push(a);for(let a of o.matchAll(cO)){let l=ut(a[0]);l&&(l.endsWith(".pix3scene")||n.add(l))}for(let a of o.matchAll(uO))for(let l of r.get(a[1])??[])n.add(l)}return n},yO=t=>{let e=new Map;for(let r of t.files)if(rg(r))for(let n of qs(ec(t,r)).names){let s=e.get(n)??[];s.push(r),e.set(n,s)}return e},tg=(t,e)=>{try{return tO("git",["-C",t,...e],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,maxBuffer:64*1024*1024})}catch{return null}},SO=t=>{let e=tg(t,["rev-parse","--show-toplevel"])?.trim();if(!e)return null;let r=tg(t,["status","--porcelain=v1","-z","--untracked-files=all","--","."]);if(r===null)return null;let n=t;try{n=rO(t)}catch{}let s=new Set,i=r.split("\0");for(let o=0;o<i.length;o++){let a=i[o];if(a.length<4)continue;let l=a.slice(0,2),c=a.slice(3);if((l.includes("R")||l.includes("C"))&&(o+=1),l.includes("D"))continue;let u=iO(n,sO(e,c));u.startsWith("..")||nO(u)||s.add(u.split(oO).join("/"))}return[...s].sort()},sg=(t,e)=>{let r=mO(hO(t),e.manifestDefault);if(t.scenes().length===0)return{error:"the project has no .pix3scene files."};if(r.length===0)return{error:"every scene is a prefab, a scenes/ui overlay or instanced by another \u2014 name one: pix3 smoke <scene>."};let n=(u,f)=>({mode:"all",scenes:r,reason:u,...f?{changed:f}:{}});if(e.all)return n("--all: every top-level scene");let s=e.changedFiles!==void 0?e.changedFiles:SO(t.root),i=s===null?null:s.filter(u=>!fO(u));if(i===null)return e.changedOnly?{error:"--changed needs git and a project inside a git work tree."}:n("every top-level scene (no git history to narrow it down)");if(i.length===0)return e.changedOnly?{error:"--changed: nothing changed since the last commit."}:n("every top-level scene (nothing changed since the last commit)");if(i.includes(K))return n(`every top-level scene (${K} changed)`,i);let o=yO(t),a=new Map(r.map(u=>[u,gO(t,u,o)])),l=r.filter(u=>i.some(f=>a.get(u)?.has(f))),c=i.filter(u=>pO(u)&&!r.some(f=>a.get(f)?.has(u)));if(c.length>0||l.length===0){let u=c.slice(0,3).join(", ")+(c.length>3?", \u2026":"");return n(c.length>0?`every top-level scene (changed ${u} reaches no scene directly)`:"every top-level scene (no changed file is used by a scene)",i)}return{mode:"changed",scenes:l,reason:`scenes reached by files changed since the last commit (${i.length} changed; --all for every scene)`,changed:i}}});var vg={};X(vg,{errorSummary:()=>NO,formatGameSnapshot:()=>Sg,formatSmokeHuman:()=>sc,formatSmokeJson:()=>ic,formatSmokeSetHuman:()=>wg,formatSmokeSetJson:()=>xg,resolveSmokeScene:()=>fg,runSmoke:()=>hg,runSmokeCli:()=>$O,runSmokeSet:()=>gg,selectScenesFor:()=>TO,smokeExitCode:()=>oc,smokeSetExitCode:()=>bg});import{existsSync as bO,readFileSync as wO,statSync as xO}from"node:fs";import{isAbsolute as vO,join as og,resolve as rc,sep as ag}from"node:path";import{pathToFileURL as lg}from"node:url";import{Worker as _O}from"node:worker_threads";var cg,ug,dg,EO,ve,kO,fg,CO,nc,OO,pg,hg,TO,mg,gg,yg,pn,tc,Sg,sc,ic,oc,bg,PO,wg,xg,$O,NO,_g=O(()=>{"use strict";cg=U(ce(),1);Ma();Z();Ie();fn();xt();Zl();eg();Da();de();ig();ug=120,dg=20,EO=t=>{let e,r=ug,n=dg,s=!1,i=!0,o=!1,a=!1,l,c=!1,u=(f,d)=>{let h=f.indexOf("=");return h>0?{value:f.slice(h+1),next:d}:{value:t[d+1],next:d+1}};for(let f=0;f<t.length;f++){let d=t[f],h=d.split("=")[0];if(d==="--json")s=!0;else if(d==="--no-sync")i=!1;else if(d==="--changed")o=!0;else if(d==="--all")a=!0;else if(d==="--help"||d==="-h")c=!0;else if(h==="--frames"||h==="--timeout"||h==="--project"){let{value:g,next:p}=u(d,f);if(f=p,g===void 0||g.startsWith("--"))return{error:`${h} needs a value`};if(h==="--project")l=g;else{let m=Number(g);if(!Number.isFinite(m)||m<=0)return{error:`${h} needs a positive number`};h==="--frames"?r=Math.floor(m):n=m}}else{if(d.startsWith("-"))return{error:`unknown argument ${d}`};if(e===void 0)e=d;else return{error:`one scene at a time (got ${e} and ${d})`}}}return o&&a?{error:"--changed and --all exclude each other"}:e!==void 0&&(o||a)?{error:`${o?"--changed":"--all"} picks the scenes; drop ${e} or the flag`}:{scene:e,changed:o,all:a,frames:r,timeoutSec:n,json:s,sync:i,project:l,help:c}},ve=(t,e,r)=>({ok:!1,code:t,reason:e,...r?{scene:r}:{}}),kO=t=>{let e={viewport:{width:1920,height:1080},autoloads:[]};try{let r=(0,cg.parse)(wO(og(t,K),"utf8"));if(!P(r))return e;let n=P(r.viewportBaseSize)?r.viewportBaseSize:{},s=typeof n.width=="number"&&n.width>0?n.width:1920,i=typeof n.height=="number"&&n.height>0?n.height:1080,o=typeof r.defaultExportScenePath=="string"&&r.defaultExportScenePath.trim()?ut(r.defaultExportScenePath)??void 0:void 0;return{viewport:{width:s,height:i},autoloads:r.autoloads??[],...o?{defaultScene:o}:{}}}catch{return e}},fg=(t,e,r)=>{let n=[],s=r.replace(/^res:\/\//i,"").replace(/^\/+/,"");n.push(s.split(ag).join("/"));let i=t.relativeOf(vO(r)?r:rc(e,r));i&&n.push(i);let o=n.find(a=>t.has(a));return o?o.endsWith(".pix3scene")?o:ve("E_SMOKE_NO_SCENE",`${o} is not a .pix3scene.`):ve("E_SMOKE_NO_SCENE",`${r} is not a file in the project (${t.root}).`)},CO=(t,e,r)=>new Promise(n=>{let s=!1,i=new _O(lg(og(t,Ei)),{workerData:e,stdout:!0,stderr:!0});i.stdout.resume(),i.stderr.resume();let o=l=>{s||(s=!0,clearTimeout(a),i.terminate(),n(l))},a=setTimeout(()=>{o(ve("E_SMOKE_TIMEOUT",`the run did not finish within ${r} s (a script stuck in a loop, or a scene too heavy for ${e.frames} frames; try --frames or --timeout).`,e.scene))},r*1e3);i.once("message",l=>o(l)),i.once("error",l=>o(ve("E_SMOKE_CRASH",`the smoke worker crashed: ${l instanceof Error?l.message:String(l)}`,e.scene))),i.once("exit",l=>o(ve("E_SMOKE_CRASH",`the smoke worker exited (code ${l}) without a report.`,e.scene)))}),nc=t=>{let e=rc(t);if(!bO(e)||!xO(e).isDirectory())return ve("E_SMOKE_NO_PROJECT",`${e} is not a folder.`);let r=Fs(e);return r?ve("E_RUNTIME_VERSION",`${r.message} Fix: ${r.fix}.`):{root:e,project:new ur(e),manifest:kO(e)}},OO=(t,e,r)=>({projectRoot:t.root,scene:e,frames:r.frames??ug,viewport:t.manifest.viewport,autoloads:t.manifest.autoloads,esbuildSpecifier:xs(),fallbackResolveDir:ie()}),pg=async(t,e,r)=>{let n=r.timeoutSec??dg;try{return await Ql(async s=>{let i=[];for(let o of e)i.push(await CO(s,OO(t,o,r),n));return i})}catch(s){let i=`could not build or load the smoke bundle: ${s instanceof Error?s.message:String(s)}`;return e.map(o=>ve("E_SMOKE_BUNDLE",i,o))}},hg=async t=>{let e=nc(t.projectRoot);if("code"in e)return e;let r=fg(e.project,t.cwd??e.root,t.scene);if(typeof r!="string")return r;let[n]=await pg(e,[r],t);return n},TO=t=>{let e=nc(t.projectRoot);return"code"in e?e:mg(e,t)},mg=(t,e)=>{let r=sg(t.project,{manifestDefault:t.manifest.defaultScene,changedOnly:e.changedOnly,all:e.all,...e.changedFiles!==void 0?{changedFiles:e.changedFiles}:{}});return"error"in r?ve("E_SMOKE_NO_SCENE",r.error):r},gg=async t=>{let e=nc(t.projectRoot);if("code"in e)return e;let r=mg(e,t);if("code"in r)return r;let n=await pg(e,r.scenes,t);return{ok:n.every(s=>!dt(s)&&s.errors.length===0),selection:r.mode,reason:r.reason,...r.changed?{changed:r.changed}:{},runs:n}},yg=(t,e,r)=>{if(!t)return[];let n=lg(e).href;return t.split(`
549
+ `).slice(1).map(s=>s.trim().replaceAll(`${n}/`,"").replaceAll(`${e}${ag}`,"").replaceAll(`${e}/`,"")).filter(s=>s.startsWith("at ")).slice(0,r)},pn=(t,e)=>`${t} ${e}${t===1?"":"s"}`,tc=4e3,Sg=t=>{let e=JSON.stringify(t)??"null";if(e.length<=120)return e;let r=JSON.stringify(t,null,2)??"null";return`
550
+ ${(r.length>tc?`${r.slice(0,tc)}
551
+ \u2026 (${r.length-tc} more characters; pix3 smoke --json has it whole)`:r).split(`
381
552
  `).map(s=>` ${s}`).join(`
382
- `)}`},zE=(t,e)=>{if(zs(t))return`pix3 smoke${t.scene?` ${t.scene}`:""}: could not run \u2014 ${t.code}: ${t.reason}
383
- `;let r=t,n=[],s=r.timingsMs;if(n.push(`pix3 smoke ${r.scene} \u2014 ${r.frames}/${r.framesRequested} frames at 1/60 s: ${hd(r.errors.length,"error")}, ${hd(r.warnings.length,"warning")}`),n.push(` first frame ${r.firstFrameOk?"ok":"NOT ok"} \xB7 nodes ${r.nodes.start} \u2192 ${r.nodes.end} \xB7 scripts ${r.scripts.length}`),n.push(` compile ${s.compile} ms \xB7 load+onStart ${s.load} ms \xB7 frame 1 ${s.firstFrame} ms \xB7 step mean ${s.step.mean} / p95 ${s.step.p95} / max ${s.step.max} ms \xB7 total ${s.total} ms`),r.game&&n.push(` game "${r.game.name}" snapshot: ${wU(r.game.snapshot)}`),r.errors.length>0){n.push("errors:");for(let o of r.errors){let i=[o.script,o.nodeName?`on "${o.nodeName}"`:o.nodeId?`on ${o.nodeId}`:void 0,o.phase?`(${o.phase})`:void 0].filter(Boolean).join(" ");n.push(` frame ${o.frame} ${o.code}${i?` ${i}`:""}: ${o.message}`),o.domAccess&&o.domAccess.length>0&&n.push(` missing browser API read just before: ${o.domAccess.join(", ")}`);for(let a of vU(o.stack,e,3))n.push(` ${a}`)}}if(r.warnings.length>0){n.push("warnings:");for(let o of r.warnings)n.push(` ${o.frame!==void 0?`frame ${o.frame} `:""}${o.code}: ${o.message}${o.count?` (\xD7${o.count})`:""}`)}if(r.notes.length>0){n.push("notes:");for(let o of r.notes)n.push(` ${o}`)}return`${n.join(`
553
+ `)}`},sc=(t,e)=>{if(dt(t))return`pix3 smoke${t.scene?` ${t.scene}`:""}: could not run \u2014 ${t.code}: ${t.reason}
554
+ `;let r=t,n=[],s=r.timingsMs;if(n.push(`pix3 smoke ${r.scene} \u2014 ${r.frames}/${r.framesRequested} frames at 1/60 s: ${pn(r.errors.length,"error")}, ${pn(r.warnings.length,"warning")}`),n.push(` first frame ${r.firstFrameOk?"ok":"NOT ok"} \xB7 nodes ${r.nodes.start} \u2192 ${r.nodes.end} \xB7 scripts ${r.scripts.length}`),n.push(` compile ${s.compile} ms \xB7 load+onStart ${s.load} ms \xB7 frame 1 ${s.firstFrame} ms \xB7 step mean ${s.step.mean} / p95 ${s.step.p95} / max ${s.step.max} ms \xB7 total ${s.total} ms`),r.game&&n.push(` game "${r.game.name}" snapshot: ${Sg(r.game.snapshot)}`),r.errors.length>0){n.push("errors:");for(let i of r.errors){let o=[i.script,i.nodeName?`on "${i.nodeName}"`:i.nodeId?`on ${i.nodeId}`:void 0,i.phase?`(${i.phase})`:void 0].filter(Boolean).join(" ");n.push(` frame ${i.frame} ${i.code}${o?` ${o}`:""}: ${i.message}`),i.domAccess&&i.domAccess.length>0&&n.push(` missing browser API read just before: ${i.domAccess.join(", ")}`);for(let a of yg(i.stack,e,3))n.push(` ${a}`)}}if(r.warnings.length>0){n.push("warnings:");for(let i of r.warnings)n.push(` ${i.frame!==void 0?`frame ${i.frame} `:""}${i.code}: ${i.message}${i.count?` (\xD7${i.count})`:""}`)}if(r.notes.length>0){n.push("notes:");for(let i of r.notes)n.push(` ${i}`)}return`${n.join(`
384
555
  `)}
385
- `},jE=(t,e)=>zs(t)?`${JSON.stringify(t,null,2)}
386
- `:`${JSON.stringify({...t,errors:t.errors.map(r=>({...r,...r.stack?{stack:vU(r.stack,e,12).join(`
556
+ `},ic=(t,e)=>dt(t)?`${JSON.stringify(t,null,2)}
557
+ `:`${JSON.stringify({...t,errors:t.errors.map(r=>({...r,...r.stack?{stack:yg(r.stack,e,12).join(`
387
558
  `)}:{}}))},null,2)}
388
- `,ME=t=>zs(t)?2:t.errors.length>0?1:0,bU=t=>t.runs.reduce((e,r)=>Math.max(e,ME(r)),0),ile=t=>{if(zs(t))return`could not run (${t.code})`;let e=[hd(t.errors.length,"error"),hd(t.warnings.length,"warning")];return`${t.errors.length>0?"FAILED":"ok"} \u2014 ${t.frames} frames, ${e.join(", ")}`},SU=(t,e)=>{let r=[];r.push(`pix3 smoke: ${hd(t.runs.length,"scene")} \u2014 ${t.reason}`);for(let s of t.runs)r.push(` ${(s.scene??"?").padEnd(32)} ${ile(s)}`);let n=t.runs.filter(s=>zs(s)||s.errors.length>0||s.warnings.length>0||t.runs.length===1);for(let s of n)r.push("",zE(s,e).trimEnd());return t.runs.length>1&&n.length===0&&r.push("Run one scene for its details: pix3 smoke <scene>."),`${r.join(`
559
+ `,oc=t=>dt(t)?2:t.errors.length>0?1:0,bg=t=>t.runs.reduce((e,r)=>Math.max(e,oc(r)),0),PO=t=>{if(dt(t))return`could not run (${t.code})`;let e=[pn(t.errors.length,"error"),pn(t.warnings.length,"warning")];return`${t.errors.length>0?"FAILED":"ok"} \u2014 ${t.frames} frames, ${e.join(", ")}`},wg=(t,e)=>{let r=[];r.push(`pix3 smoke: ${pn(t.runs.length,"scene")} \u2014 ${t.reason}`);for(let s of t.runs)r.push(` ${(s.scene??"?").padEnd(32)} ${PO(s)}`);let n=t.runs.filter(s=>dt(s)||s.errors.length>0||s.warnings.length>0||t.runs.length===1);for(let s of n)r.push("",sc(s,e).trimEnd());return t.runs.length>1&&n.length===0&&r.push("Run one scene for its details: pix3 smoke <scene>."),`${r.join(`
389
560
  `)}
390
- `},$U=(t,e)=>`${JSON.stringify({...t,runs:t.runs.map(r=>JSON.parse(jE(r,e)))},null,2)}
391
- `,ale=async(t,e)=>{let r=rle(t);if("error"in r)return e.stderr(`pix3 smoke: ${r.error}
561
+ `},xg=(t,e)=>`${JSON.stringify({...t,runs:t.runs.map(r=>JSON.parse(ic(r,e)))},null,2)}
562
+ `,$O=async(t,e)=>{let r=EO(t);if("error"in r)return e.stderr(`pix3 smoke: ${r.error}
392
563
 
393
- ${CE}`),2;if(r.help)return e.stdout(CE),0;let n=r.project?RE(e.cwd,r.project):Qe(e.cwd),s=n??e.cwd,o={frames:r.frames,timeoutSec:r.timeoutSec,cwd:e.cwd},i;return n?r.scene!==void 0?i=await gU({projectRoot:n,scene:r.scene,...o}):i=await _U({projectRoot:n,changedOnly:r.changed,all:r.all,...o}):i=Un("E_SMOKE_NO_PROJECT",`no pix3project.yaml in ${e.cwd} or above \u2014 run inside a project or pass --project <dir>.`),"runs"in i?(e.stdout(r.json?$U(i,s):SU(i,s)),bU(i)):(r.json?e.stdout(jE(i,s)):e.stdout(zE(i,s)),ME(i))},cle=t=>zs(t)?[`${t.code}: ${t.reason}`]:t.errors.map(e=>`${e.frame} ${e.code}${e.script?` ${e.script}`:""}: ${e.message}`)});var lle,ule,dle,EU,TU=$(()=>{"use strict";lle=/^(src\/)?scripts\//,ule=/extends\s+Script\b/,dle=/\bexport\s+(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/g,EU=t=>{let e=new Set;for(let r of t.files){if(!lle.test(r)||r.endsWith(".d.ts")||r.includes(".spec.")||!r.endsWith(".ts")&&!r.endsWith(".js"))continue;let n;try{n=t.readText(r)}catch{continue}if(ule.test(n))for(let s of n.matchAll(dle))e.add(`user:${s[1]}`)}return[...e].sort()}});var IU,ja,ag,NU,cg,za,ig,PU,OU,CU,RU,AU,fle,ple,hle,LE,zU,jU,DE,mle,gle,yle,MU,qE,LU,FE,_le,DU,qU=$(()=>{"use strict";IU=Ze(Er(),1);pd();ja=class extends Error{},ag=t=>{let e;try{e=(0,IU.parse)(t,{maxAliasCount:1e3})}catch(r){throw new ja(`not valid YAML: ${(r instanceof Error?r.message:String(r)).split(`
394
- `)[0]}`)}if(!ke(e)||!Array.isArray(e.root))throw new ja("not a .pix3scene (no `root:` list)");return e},NU=t=>{let e=t.trim(),r=/^([a-z][a-z0-9+.-]*):/i.exec(e)?.[1]?.toLowerCase();return r&&r!=="res"?null:e.replace(/^res:\/\//i,"").replace(/^\/+/,"")||null},cg=t=>Array.isArray(t)&&t.every(e=>typeof e=="number")?t:ke(t)&&typeof t.x=="number"&&typeof t.y=="number"?["x","y","z","w"].filter(e=>typeof t[e]=="number").map(e=>t[e]):null,za=t=>Math.round(t*1e4)/1e4,ig=t=>{if(typeof t=="number")return za(t);let e=cg(t);return e?e.map(za):t},PU=t=>typeof t=="string"&&/^#[0-9a-f]{3,8}$/i.test(t),OU=t=>t.length===4?`#${[...t.slice(1)].map(e=>e+e).join("")}`.toLowerCase():t.toLowerCase(),CU=(t,e)=>{if(e===void 0)return!1;let r=ig(t),n=ig(e);return typeof r=="number"&&typeof n=="number"?Math.abs(r-n)<1e-6:Array.isArray(r)&&Array.isArray(n)?r.length===n.length&&r.every((s,o)=>CU(s,n[o])):PU(r)&&PU(n)?OU(r)===OU(n):r===null||typeof r!="object"?r===n:JSON.stringify(r)===JSON.stringify(n)},RU=new Set(["transform.position","position","width","height","label"]),AU=t=>{let e=[];for(let[r,n]of Object.entries(t)){let s=ke(n)&&typeof n.url=="string";if(ke(n)&&!s&&cg(n)===null)for(let[o,i]of Object.entries(n))e.push([`${r}.${o}`,i]);else e.push([r,n])}return e},fle=(t,e,r,n)=>{let s={};for(let[o,i]of AU(t)){if(RU.has(o)||r&&(o==="layout.enabled"||o==="layout.horizontalAlign"||o==="layout.verticalAlign")||n&&o==="visible")continue;let a=e?.[o];e&&CU(i,a)||(s[o]=ig(i))}return s},ple=t=>{let e=ke(t.properties)?Object.keys(t.properties).length:0,r=0,n=ke(t.overrides)?t.overrides.byLocalId:void 0;if(ke(n))for(let s of Object.values(n))r+=ke(s)&&ke(s.properties)?Object.keys(s.properties).length:1;return{overrides:r,properties:e}},hle=(t,e)=>{let r=NU(t);if(!r||!e)return{};let n=e(r);if(n===null)return{};try{let o=ag(n).root[0];return ke(o)?{...typeof o.type=="string"?{type:o.type}:{},...typeof o.name=="string"?{name:o.name}:{}}:{}}catch{return{}}},LE=t=>t.toLowerCase().replace(/[^a-z0-9]/g,""),zU=t=>(Array.isArray(t.children)?t.children:[]).reduce((r,n)=>r+(ke(n)?1+zU(n):0),0),jU=(t,e={})=>{let r=e.types&&e.types.length>0?new Set(e.types.map(LE)):null,n=(s,o)=>{if(!ke(s))return null;let i=ke(s.properties)?s.properties:{},a=typeof s.instance=="string"?s.instance:void 0,c=a?hle(a,e.readPrefab):{},l=typeof s.type=="string"?s.type:c.type??null,u=ke(i.transform)?i.transform:{},d=cg(u.position??i.position),f=i.width,p=i.height,m=ke(i.layout)?i.layout:null,h=m&&m.enabled===!0?`${String(m.horizontalAlign??"none")}/${String(m.verticalAlign??"none")}`:void 0,g=i.visible===!1,y=(Array.isArray(s.components)?s.components:[]).filter(ke).filter(A=>typeof A.type=="string").map(A=>({type:A.type,...typeof A.id=="string"?{id:A.id}:{},enabled:A.enabled!==!1})),w=Array.isArray(s.groups)?s.groups.filter(A=>typeof A=="string"):[],b=Array.isArray(s.children)?s.children:[],x=e.depth!==void 0&&o>=e.depth,v=x?[]:b.map(A=>n(A,o+1)).filter(A=>A!==null),S=r===null||l!==null&&r.has(LE(l))||a!==void 0&&r.has("instance")||y.some(A=>r.has(LE(A.type)));if(!S&&v.length===0)return null;let T=e.props===!0?a?Object.fromEntries(AU(i).filter(([A])=>!(g&&A==="visible")&&!RU.has(A)).map(([A,Z])=>[A,ig(Z)])):fle(i,l?e.defaults?.[l]:void 0,h!==void 0,g):void 0,P=x?zU(s):0;return{id:typeof s.id=="string"?s.id:"?",type:l,...typeof s.name=="string"?{name:s.name}:{},depth:o,...d?{position:d.map(za)}:{},...typeof f=="number"&&typeof p=="number"?{size:[za(f),za(p)]}:{},...h?{layout:h}:{},...g?{hidden:!0}:{},...typeof i.label=="string"?{text:i.label}:{},...w.length>0?{groups:w}:{},components:y,...a?{instance:{path:a,...c.type?{rootType:c.type}:{},...c.name?{rootName:c.name}:{},...ple(s)}}:{},...T&&Object.keys(T).length>0?{props:T}:{},...S?{}:{context:!0},...P>0?{hiddenBelow:P}:{},children:v}};return t.root.map(s=>n(s,0)).filter(s=>s!==null)},DE=(t,e=40)=>{let r=t.replace(/\s+/g," ");return JSON.stringify(r.length>e?`${r.slice(0,e-1)}\u2026`:r)},mle=t=>{if(typeof t=="string")return/^[\w#./:-]+$/.test(t)&&t.length>0?t:DE(t,60);if(typeof t=="number"||typeof t=="boolean"||t===null)return String(t);let e=cg(t);if(e)return`(${e.map(za).join(",")})`;if(ke(t)&&typeof t.url=="string")return t.url;let r=JSON.stringify(t)??String(t);return r.length>80?`${r.slice(0,79)}\u2026`:r},gle=(t,e)=>`${t} ${e}${t===1?"":"s"}`,yle=t=>{let e=[],r=`${t.type??(t.instance?"Instance":"?")}#${t.id}`;if(e.push(t.name!==void 0&&t.name!==t.id?`${r} ${DE(t.name)}`:r),t.instance){let{overrides:s,properties:o}=t.instance,i=[...s>0?[gle(s,"override")]:[],...o>0?[`${o} ${o===1?"property":"properties"}`]:[]];e.push(`\u21B3 instance ${t.instance.path} (${i.length>0?i.join(", "):"no overrides"})`)}t.text!==void 0&&e.push(`text=${DE(t.text,28)}`),t.position&&t.position.some(s=>s!==0)&&e.push(`pos=(${t.position.join(",")})`),t.size&&e.push(`size=${t.size[0]}x${t.size[1]}`),t.layout&&e.push(`layout=${t.layout}`),t.hidden&&e.push("hidden"),t.groups&&e.push(`groups=[${t.groups.join(",")}]`);let n=e.join(" ");return t.components.length>0&&(n+=` components=[${t.components.map(s=>s.enabled?s.type:`${s.type}(off)`).join(", ")}]`),t.hiddenBelow&&(n+=` \u2026 +${t.hiddenBelow} below`),n},MU=t=>{let e=[],r=n=>{let s=" ".repeat(n.depth);if(e.push(`${s}${n.context?"\xB7 ":""}${yle(n)}`),n.props){let o=Object.entries(n.props).map(([i,a])=>`${i}=${mle(a)}`);o.length>0&&e.push(`${s} ${o.join(" ")}`)}n.children.forEach(r)};return t.forEach(r),e.length>0?`${e.join(`
564
+ ${I.smoke}`),2;if(r.help)return e.stdout(I.smoke),0;let n=r.project?rc(e.cwd,r.project):rt(e.cwd),s=n??e.cwd,i={frames:r.frames,timeoutSec:r.timeoutSec,cwd:e.cwd},o=n?await js(n,{noSync:!r.sync}):{status:"skipped"},a;return n?o.status==="unsynced"?a=ve("E_EDITOR_UNSYNCED",Ds(o),r.scene):r.scene!==void 0?a=await hg({projectRoot:n,scene:r.scene,...i}):a=await gg({projectRoot:n,changedOnly:r.changed,all:r.all,...i}):a=ve("E_SMOKE_NO_PROJECT",`no pix3project.yaml in ${e.cwd} or above \u2014 run inside a project or pass --project <dir>.`),"runs"in a?(e.stdout(r.json?xg(a,s):wg(a,s)),bg(a)):(r.json?e.stdout(ic(a,s)):e.stdout(sc(a,s)),oc(a))},NO=t=>dt(t)?[`${t.code}: ${t.reason}`]:t.errors.map(e=>`${e.frame} ${e.code}${e.script?` ${e.script}`:""}: ${e.message}`)});var Eg,kg=O(()=>{"use strict";Bs();Eg=t=>{let e=new Set;for(let r of t.files){if(!dp(r))continue;let n;try{n=t.readText(r)}catch{continue}for(let s of qs(n).names)e.add(`user:${s}`)}return[...e].sort()}});var Tg,dr,Ci,Oi,_e,ki,Cg,Og,Pg,$g,Ng,AO,IO,RO,ac,Ag,Ig,MO,LO,jO,Rg,lc,DO,FO,qO,BO,Mg,cc,Lg,uc,UO,jg,Dg=O(()=>{"use strict";Tg=U(ce(),1);fn();xt();dr=class extends Error{},Ci=t=>{let e;try{e=(0,Tg.parse)(t,{maxAliasCount:1e3})}catch(r){throw new dr(`not valid YAML: ${(r instanceof Error?r.message:String(r)).split(`
565
+ `)[0]}`)}if(!P(e)||!Array.isArray(e.root))throw new dr("not a .pix3scene (no `root:` list)");return e},Oi=t=>Array.isArray(t)&&t.every(e=>typeof e=="number")?t:P(t)&&typeof t.x=="number"&&typeof t.y=="number"?["x","y","z","w"].filter(e=>typeof t[e]=="number").map(e=>t[e]):null,_e=t=>Math.round(t*1e4)/1e4,ki=t=>{if(typeof t=="number")return _e(t);let e=Oi(t);return e?e.map(_e):t},Cg=t=>typeof t=="string"&&/^#[0-9a-f]{3,8}$/i.test(t),Og=t=>t.length===4?`#${[...t.slice(1)].map(e=>e+e).join("")}`.toLowerCase():t.toLowerCase(),Pg=(t,e)=>{if(e===void 0)return!1;let r=ki(t),n=ki(e);return typeof r=="number"&&typeof n=="number"?Math.abs(r-n)<1e-6:Array.isArray(r)&&Array.isArray(n)?r.length===n.length&&r.every((s,i)=>Pg(s,n[i])):Cg(r)&&Cg(n)?Og(r)===Og(n):r===null||typeof r!="object"?r===n:JSON.stringify(r)===JSON.stringify(n)},$g=new Set(["transform.position","position","width","height","label"]),Ng=t=>{let e=[];for(let[r,n]of Object.entries(t)){let s=P(n)&&typeof n.url=="string";if(P(n)&&!s&&Oi(n)===null)for(let[i,o]of Object.entries(n))e.push([`${r}.${i}`,o]);else e.push([r,n])}return e},AO=(t,e,r,n,s)=>{let i={};for(let[o,a]of Ng(t)){if($g.has(o)||r&&(o==="layout.enabled"||o==="layout.horizontalAlign"||o==="layout.verticalAlign"||n.includes(o.slice(7)))||s&&o==="visible")continue;let l=e?.[o];e&&Pg(a,l)||(i[o]=ki(a))}return i},IO=t=>{let e=P(t.properties)?Object.keys(t.properties).length:0,r=0,n=P(t.overrides)?t.overrides.byLocalId:void 0;if(P(n))for(let s of Object.values(n))r+=P(s)&&P(s.properties)?Object.keys(s.properties).length:1;return{overrides:r,properties:e}},RO=(t,e)=>{let r=ut(t);if(!r||!e)return{};let n=e(r);if(n===null)return{};try{let i=Ci(n).root[0];return P(i)?{...typeof i.type=="string"?{type:i.type}:{},...typeof i.name=="string"?{name:i.name}:{}}:{}}catch{return{}}},ac=t=>t.toLowerCase().replace(/[^a-z0-9]/g,""),Ag=t=>(Array.isArray(t.children)?t.children:[]).reduce((r,n)=>r+(P(n)?1+Ag(n):0),0),Ig=[{index:0,align:"horizontalAlign",lo:"left",hi:"right"},{index:1,align:"verticalAlign",lo:"bottom",hi:"top"}],MO=(t,e,r)=>t===e?"lo":t===r?"hi":t==="stretch"?"both":null,LO=t=>{if(!t||t.enabled!==!0)return null;let e={},r=Ig.map(n=>{let s=MO(t[n.align],n.lo,n.hi);if(!s)return null;let i=s==="lo"?[n.lo]:s==="hi"?[n.hi]:[n.lo,n.hi];if(!i.every(o=>typeof t[o]=="number"))return null;for(let o of i)e[o]=t[o];return s});return r.some(Boolean)?{margins:e,modes:r}:null},jO=(t,e,r,n,s)=>{if(s===null)return{center:null,size:t==="both"?null:n};if(t==="both"){let o=-s/2+e,a=s/2-r;return{center:(o+a)/2,size:Math.max(1,a-o)}}if(n===null)return{center:null,size:n};let i=Math.max(0,n);return t==="lo"?{center:-s/2+e+i/2,size:n}:{center:s/2-r-i/2,size:n}},Rg=(t,e={})=>{let r=e.types&&e.types.length>0?new Set(e.types.map(ac)):null,n=(i,o,a)=>{if(!P(i))return null;let l=P(i.properties)?i.properties:{},c=typeof i.instance=="string"?i.instance:void 0,u=c?RO(c,e.readPrefab):{},f=typeof i.type=="string"?i.type:u.type??null,d=P(l.transform)?l.transform:{},h=Oi(d.position??l.position),g=l.width,p=l.height,m=P(l.layout)?l.layout:null,y=m&&m.enabled===!0?`${String(m.horizontalAlign??"none")}/${String(m.verticalAlign??"none")}`:void 0,w=[typeof g=="number"?g:null,typeof p=="number"?p:null],_=LO(m),v=_?Ig.map(L=>{let te=_.modes[L.index];return te?jO(te,_.margins[L.lo]??0,_.margins[L.hi]??0,w[L.index],a[L.index]):{center:h?.[L.index]??0,size:w[L.index]}}):null,E=v?[v[0].size,v[1].size]:w,k=l.visible===!1,T=(Array.isArray(i.components)?i.components:[]).filter(P).filter(L=>typeof L.type=="string").map(L=>({type:L.type,...typeof L.id=="string"?{id:L.id}:{},enabled:L.enabled!==!1})),S=Array.isArray(i.groups)?i.groups.filter(L=>typeof L=="string"):[],b=Array.isArray(i.children)?i.children:[],C=e.depth!==void 0&&o>=e.depth,R=C?[]:b.map(L=>n(L,o+1,E)).filter(L=>L!==null),A=r===null||f!==null&&r.has(ac(f))||c!==void 0&&r.has("instance")||T.some(L=>r.has(ac(L.type)));if(!A&&R.length===0)return null;let D=e.props===!0?c?Object.fromEntries(Ng(l).filter(([L])=>!(k&&L==="visible")&&!$g.has(L)).map(([L,te])=>[L,ki(te)])):AO(l,f?e.defaults?.[f]:void 0,y!==void 0,Object.keys(_?.margins??{}),k):void 0,Ee=C?Ag(i):0;return{id:typeof i.id=="string"?i.id:"?",type:f,...typeof i.name=="string"?{name:i.name}:{},depth:o,...h?{position:h.map(_e)}:{},...typeof g=="number"&&typeof p=="number"?{size:[_e(g),_e(p)]}:{},...y?{layout:y}:{},..._&&v?{margins:_.margins,resolved:{position:[v[0].center===null?null:_e(v[0].center),v[1].center===null?null:_e(v[1].center)],size:[v[0].size===null?null:_e(v[0].size),v[1].size===null?null:_e(v[1].size)]}}:{},...k?{hidden:!0}:{},...typeof l.label=="string"?{text:l.label}:{},...S.length>0?{groups:S}:{},components:T,...c?{instance:{path:c,...u.type?{rootType:u.type}:{},...u.name?{rootName:u.name}:{},...IO(i)}}:{},...D&&Object.keys(D).length>0?{props:D}:{},...A?{}:{context:!0},...Ee>0?{hiddenBelow:Ee}:{},children:R}},s=e.viewport?[e.viewport.width,e.viewport.height]:[null,null];return t.root.map(i=>n(i,0,s)).filter(i=>i!==null)},lc=(t,e=40)=>{let r=t.replace(/\s+/g," ");return JSON.stringify(r.length>e?`${r.slice(0,e-1)}\u2026`:r)},DO=t=>{if(typeof t=="string")return/^[\w#./:-]+$/.test(t)&&t.length>0?t:lc(t,60);if(typeof t=="number"||typeof t=="boolean"||t===null)return String(t);let e=Oi(t);if(e)return`(${e.map(_e).join(",")})`;if(P(t)&&typeof t.url=="string")return t.url;let r=JSON.stringify(t)??String(t);return r.length>80?`${r.slice(0,79)}\u2026`:r},FO=["left","right","top","bottom"],qO=(t,e)=>`${t} ${e}${t===1?"":"s"}`,BO=t=>{let e=[],r=`${t.type??(t.instance?"Instance":"?")}#${t.id}`;if(e.push(t.name!==void 0&&t.name!==t.id?`${r} ${lc(t.name)}`:r),t.instance){let{overrides:s,properties:i}=t.instance,o=[...s>0?[qO(s,"override")]:[],...i>0?[`${i} ${i===1?"property":"properties"}`]:[]];e.push(`\u21B3 instance ${t.instance.path} (${o.length>0?o.join(", "):"no overrides"})`)}if(t.text!==void 0&&e.push(`text=${lc(t.text,28)}`),t.resolved){let s=c=>c===null?"?":String(c),[i,o]=t.resolved.position;(i!==0||o!==0)&&e.push(`pos=(${s(i)},${s(o)})`);let[a,l]=t.resolved.size;(a!==null||l!==null)&&e.push(`size=${s(a)}x${s(l)}`)}else t.position&&t.position.some(s=>s!==0)&&e.push(`pos=(${t.position.join(",")})`),t.size&&e.push(`size=${t.size[0]}x${t.size[1]}`);if(t.layout){let s=t.margins?FO.filter(i=>t.margins?.[i]!==void 0).map(i=>`${i}=${_e(t.margins?.[i]??0)}`).join(","):"";e.push(`layout=${t.layout}${s?`(${s})`:""}`)}t.hidden&&e.push("hidden"),t.groups&&e.push(`groups=[${t.groups.join(",")}]`);let n=e.join(" ");return t.components.length>0&&(n+=` components=[${t.components.map(s=>s.enabled?s.type:`${s.type}(off)`).join(", ")}]`),t.hiddenBelow&&(n+=` \u2026 +${t.hiddenBelow} below`),n},Mg=t=>{let e=[],r=n=>{let s=" ".repeat(n.depth);if(e.push(`${s}${n.context?"\xB7 ":""}${BO(n)}`),n.props){let i=Object.entries(n.props).map(([o,a])=>`${o}=${DO(a)}`);i.length>0&&e.push(`${s} ${i.join(" ")}`)}n.children.forEach(r)};return t.forEach(r),e.length>0?`${e.join(`
395
566
  `)}
396
- `:""},qE=t=>t.reduce((e,r)=>e+1+qE(r.children),0),LU=t=>{let e=new Set,r=n=>{ke(n)&&(typeof n.type=="string"&&e.add(n.type),Array.isArray(n.children)&&n.children.forEach(r))};return t.root.forEach(r),[...e].sort()},FE=(t,e)=>{let r;try{r=ag(e)}catch(c){return{path:t,nodes:0,types:{},components:{},instances:[],error:c instanceof Error?c.message:String(c)}}let n={},s={},o=new Set,i=0,a=c=>{if(ke(c)){if(i+=1,typeof c.instance=="string"){let l=NU(c.instance);l&&o.add(l)}else typeof c.type=="string"&&(n[c.type]=(n[c.type]??0)+1);if(Array.isArray(c.components))for(let l of c.components)ke(l)&&typeof l.type=="string"&&(s[l.type]=(s[l.type]??0)+1);Array.isArray(c.children)&&c.children.forEach(a)}};return r.root.forEach(a),{path:t,nodes:i,types:n,components:s,instances:[...o].sort()}},_le=t=>Object.entries(t).sort((e,r)=>r[1]-e[1]||e[0].localeCompare(r[0])),DU=(t,e)=>{let r=`${t.path}${t.entry?" *":""}`.padEnd(e);if(t.error)return`${r} UNPARSABLE: ${t.error}`;let n=_le(t.types).map(([i,a])=>a>1?`${i}\xD7${a}`:i).join(" "),s=[`${r} ${t.kind.padEnd(7)} ${String(t.nodes).padStart(3)} ${t.nodes===1?"node ":"nodes"} ${n}`],o=Object.keys(t.components).sort();return o.length>0&&s.push(`${" ".repeat(e+2)}components: ${o.join(" ")}`),t.instances.length>0&&s.push(`${" ".repeat(e+2)}instances: ${t.instances.join(" ")}`),s.join(`
397
- `)}});var VU={};Je(VU,{TREE_USAGE:()=>UE,runTreeCli:()=>Ple});import{existsSync as FU,readFileSync as lg}from"node:fs";import{isAbsolute as ZU,join as ug,relative as vle,resolve as ZE,sep as wle}from"node:path";import{pathToFileURL as ble}from"node:url";var UU,UE,Sle,$le,kle,xle,Ele,Tle,Ple,BU=$(()=>{"use strict";UU=Ze(Er(),1);ut();sg();pd();TU();qU();UE=`Usage: pix3 tree [scene] [--depth N] [--types A,B] [--props] [--json] [--project <dir>]
398
-
399
- One line per node \u2014 type#id "name", position, size, anchor layout, components, prefab
400
- instances (\u21B3 instance res://\u2026 (N overrides, M properties)) \u2014 indented by depth. Read this instead of the
401
- whole .pix3scene when you need to find your way around a scene.
567
+ `:""},cc=t=>t.reduce((e,r)=>e+1+cc(r.children),0),Lg=t=>{let e=new Set,r=n=>{P(n)&&(typeof n.type=="string"&&e.add(n.type),Array.isArray(n.children)&&n.children.forEach(r))};return t.root.forEach(r),[...e].sort()},uc=(t,e)=>{let r;try{r=Ci(e)}catch(l){return{path:t,nodes:0,types:{},components:{},instances:[],error:l instanceof Error?l.message:String(l)}}let n={},s={},i=new Set,o=0,a=l=>{if(P(l)){if(o+=1,typeof l.instance=="string"){let c=ut(l.instance);c&&i.add(c)}else typeof l.type=="string"&&(n[l.type]=(n[l.type]??0)+1);if(Array.isArray(l.components))for(let c of l.components)P(c)&&typeof c.type=="string"&&(s[c.type]=(s[c.type]??0)+1);Array.isArray(l.children)&&l.children.forEach(a)}};return r.root.forEach(a),{path:t,nodes:o,types:n,components:s,instances:[...i].sort()}},UO=t=>Object.entries(t).sort((e,r)=>r[1]-e[1]||e[0].localeCompare(r[0])),jg=(t,e)=>{let r=`${t.path}${t.entry?" *":""}`.padEnd(e);if(t.error)return`${r} UNPARSABLE: ${t.error}`;let n=UO(t.types).map(([o,a])=>a>1?`${o}\xD7${a}`:o).join(" "),s=[`${r} ${t.kind.padEnd(7)} ${String(t.nodes).padStart(3)} ${t.nodes===1?"node ":"nodes"} ${n}`],i=Object.keys(t.components).sort();return i.length>0&&s.push(`${" ".repeat(e+2)}components: ${i.join(" ")}`),t.instances.length>0&&s.push(`${" ".repeat(e+2)}instances: ${t.instances.join(" ")}`),s.join(`
568
+ `)}});var Kg={};X(Kg,{runTreeCli:()=>QO});import{existsSync as Fg,readFileSync as dc}from"node:fs";import{isAbsolute as qg,join as Ti,relative as KO,resolve as fc,sep as WO}from"node:path";import{pathToFileURL as VO}from"node:url";var Bg,GO,JO,HO,YO,Ug,zO,XO,QO,Wg=O(()=>{"use strict";Bg=U(ce(),1);Z();fn();xt();de();kg();Dg();GO=t=>{let e,r,n,s=!1,i=!1,o,a=!1;for(let l=0;l<t.length;l++){let c=t[l],u=c.indexOf("="),f=u>0?c.slice(0,u):c;if(c==="--json")i=!0;else if(c==="--props")s=!0;else if(c==="--help"||c==="-h")a=!0;else if(f==="--depth"||f==="--types"||f==="--project"){let d=u>0?c.slice(u+1):t[++l];if(d===void 0||d.startsWith("--"))return{error:`${f} needs a value`};if(f==="--depth"){let h=Number(d);if(!Number.isInteger(h)||h<0)return{error:"--depth needs a whole number \u2265 0"};r=h}else f==="--types"?n=d.split(",").map(h=>h.trim()).filter(Boolean):o=d}else{if(c.startsWith("-"))return{error:`unknown argument ${c}`};if(e===void 0)e=c;else return{error:`one scene at a time (got ${e} and ${c})`}}}return{scene:e,depth:r,types:n,props:s,json:i,project:o,help:a}},JO=(t,e,r)=>[Ti(e,t.replace(/^res:\/\//i,"").replace(/^\/+/,"")),qg(t)?t:fc(r,t)].find(s=>Fg(s))??null,HO=(t,e)=>{let r=KO(t,e);return r.startsWith("..")||qg(r)?e:r.split(WO).join("/")},YO=async t=>{try{let{TREE_DEFAULTS_FILE:e,withSmokeBundle:r}=await Promise.resolve().then(()=>(Zl(),Zm));return await r(async n=>{let i=(await import(VO(Ti(n,e)).href)).defaultsForTypes(t);return Object.fromEntries(Object.entries(i).map(([o,a])=>[o,a.defaults]))})}catch(e){return{error:e instanceof Error?e.message:String(e)}}},Ug=t=>{let e=Ti(t,K);if(!Fg(e))return null;try{let r=(0,Bg.parse)(dc(e,"utf8"));if(!P(r))return{};let n=P(r.metadata)?r.metadata:{},s=P(r.viewportBaseSize)?r.viewportBaseSize:null;return{...typeof n.projectName=="string"?{name:n.projectName}:{},...typeof r.projectType=="string"?{projectType:r.projectType}:{},...s&&typeof s.width=="number"&&typeof s.height=="number"?{viewport:`${s.width}x${s.height}`}:{},...typeof r.defaultExportScenePath=="string"&&r.defaultExportScenePath.trim()?{entry:r.defaultExportScenePath.trim().replace(/^res:\/\//i,"")}:{}}}catch{return{}}},zO=t=>{let[e,r]=(Ug(t)?.viewport??"").split("x").map(Number);return e>0&&r>0?{width:e,height:r}:void 0},XO=(t,e,r)=>{let n=new ur(t),s=Ug(t),i=n.scenes().map(d=>uc(d,n.readText(d))),o=new Set(i.flatMap(d=>d.instances)),a=i.map(d=>({...d,kind:/(^|\/)ui\//.test(d.path)?"overlay":o.has(d.path)||/(^|\/)prefabs?\/|\.prefab$/i.test(d.path)?"prefab":"scene",entry:s?.entry===d.path})),l=Eg(n),c=a.filter(d=>d.error).length;if(e.json)return r.stdout(`${JSON.stringify({projectRoot:t,project:s,scripts:l,scenes:a},null,2)}
569
+ `),c>0?1:0;let u=[];if(s){let d=[s.projectType,s.viewport,s.entry?`entry ${s.entry} (*)`:void 0].filter(Boolean).join(", ");u.push(`${s.name?`"${s.name}"`:"Project"}${d?` \u2014 ${d}`:""}`)}else u.push(`${t} (no pix3project.yaml)`);u.push(l.length>0?`scripts: ${l.join(" ")}`:"scripts: none (no Script classes under scripts/ or src/scripts/)"),a.length===0&&u.push("no .pix3scene files");let f=Math.max(0,...a.map(d=>d.path.length+(d.entry?2:0)));for(let d of a)u.push(jg(d,f));return u.push("\n`pix3 tree <scene>` for one scene's nodes (--depth N, --types A,B, --props)."),r.stdout(`${u.join(`
570
+ `)}
571
+ `),c>0?1:0},QO=async(t,e)=>{let r=GO(t);if("error"in r)return e.stderr(`pix3 tree: ${r.error}
402
572
 
403
- scene .pix3scene (res://, project-relative or a path). Without one: every scene and
404
- prefab in the project with node counts, node types and components.
405
- --depth N stop N levels below the roots (0 = roots only); cut subtrees show "\u2026 +K below"
406
- --types A,B only nodes of these types (or carrying these components; \`instance\` = prefab
407
- instances), with their ancestors as "\xB7" context lines
408
- --props also print each node's properties that differ from the type's defaults
409
- --json the same as nested JSON
410
- --project dir project folder (default: nearest folder with pix3project.yaml, else cwd)
411
- `,Sle=t=>{let e,r,n,s=!1,o=!1,i,a=!1;for(let c=0;c<t.length;c++){let l=t[c],u=l.indexOf("="),d=u>0?l.slice(0,u):l;if(l==="--json")o=!0;else if(l==="--props")s=!0;else if(l==="--help"||l==="-h")a=!0;else if(d==="--depth"||d==="--types"||d==="--project"){let f=u>0?l.slice(u+1):t[++c];if(f===void 0||f.startsWith("--"))return{error:`${d} needs a value`};if(d==="--depth"){let p=Number(f);if(!Number.isInteger(p)||p<0)return{error:"--depth needs a whole number \u2265 0"};r=p}else d==="--types"?n=f.split(",").map(p=>p.trim()).filter(Boolean):i=f}else{if(l.startsWith("-"))return{error:`unknown argument ${l}`};if(e===void 0)e=l;else return{error:`one scene at a time (got ${e} and ${l})`}}}return{scene:e,depth:r,types:n,props:s,json:o,project:i,help:a}},$le=(t,e,r)=>[ug(e,t.replace(/^res:\/\//i,"").replace(/^\/+/,"")),ZU(t)?t:ZE(r,t)].find(s=>FU(s))??null,kle=(t,e)=>{let r=vle(t,e);return r.startsWith("..")||ZU(r)?e:r.split(wle).join("/")},xle=async t=>{try{let{TREE_DEFAULTS_FILE:e,withSmokeBundle:r}=await Promise.resolve().then(()=>(OE(),tU));return await r(async n=>{let o=(await import(ble(ug(n,e)).href)).defaultsForTypes(t);return Object.fromEntries(Object.entries(o).map(([i,a])=>[i,a.defaults]))})}catch(e){return{error:e instanceof Error?e.message:String(e)}}},Ele=t=>{let e=ug(t,xe);if(!FU(e))return null;try{let r=(0,UU.parse)(lg(e,"utf8"));if(!ke(r))return{};let n=ke(r.metadata)?r.metadata:{},s=ke(r.viewportBaseSize)?r.viewportBaseSize:null;return{...typeof n.projectName=="string"?{name:n.projectName}:{},...typeof r.projectType=="string"?{projectType:r.projectType}:{},...s&&typeof s.width=="number"&&typeof s.height=="number"?{viewport:`${s.width}x${s.height}`}:{},...typeof r.defaultExportScenePath=="string"&&r.defaultExportScenePath.trim()?{entry:r.defaultExportScenePath.trim().replace(/^res:\/\//i,"")}:{}}}catch{return{}}},Tle=(t,e,r)=>{let n=new Aa(t),s=Ele(t),o=n.scenes().map(f=>FE(f,n.readText(f))),i=new Set(o.flatMap(f=>f.instances)),a=o.map(f=>({...f,kind:/(^|\/)ui\//.test(f.path)?"overlay":i.has(f.path)||/(^|\/)prefabs?\//.test(f.path)?"prefab":"scene",entry:s?.entry===f.path})),c=EU(n),l=a.filter(f=>f.error).length;if(e.json)return r.stdout(`${JSON.stringify({projectRoot:t,project:s,scripts:c,scenes:a},null,2)}
412
- `),l>0?1:0;let u=[];if(s){let f=[s.projectType,s.viewport,s.entry?`entry ${s.entry} (*)`:void 0].filter(Boolean).join(", ");u.push(`${s.name?`"${s.name}"`:"Project"}${f?` \u2014 ${f}`:""}`)}else u.push(`${t} (no pix3project.yaml)`);u.push(c.length>0?`scripts: ${c.join(" ")}`:"scripts: none (no Script classes under scripts/ or src/scripts/)"),a.length===0&&u.push("no .pix3scene files");let d=Math.max(0,...a.map(f=>f.path.length+(f.entry?2:0)));for(let f of a)u.push(DU(f,d));return u.push("\n`pix3 tree <scene>` for one scene's nodes (--depth N, --types A,B, --props)."),r.stdout(`${u.join(`
573
+ ${I.tree}`),2;if(r.help)return e.stdout(I.tree),0;let n=r.project?fc(e.cwd,r.project):rt(e.cwd)??fc(e.cwd);if(r.scene===void 0)return XO(n,r,e);let s=JO(r.scene,n,e.cwd);if(!s)return e.stderr(`pix3 tree: ${r.scene} not found (looked in ${n} and ${e.cwd}).
574
+ `),2;let i=HO(n,s),o=dc(s,"utf8"),a;try{a=Ci(o)}catch(g){if(!(g instanceof dr))throw g;return e.stderr(`pix3 tree: ${i} is ${g.message}.
575
+ `),1}let l,c;if(r.props){let g=await YO(Lg(a));"error"in g?c=`defaults unavailable (${String(g.error)}): every authored property is shown`:l=g}let u=Rg(a,{viewport:zO(n),depth:r.depth,types:r.types,props:r.props,defaults:l,readPrefab:g=>{let p=Ti(n,g);try{return dc(p,"utf8")}catch{return null}}});if(r.json)return e.stdout(`${JSON.stringify({scene:i,nodes:u,...c?{note:c}:{}},null,2)}
576
+ `),0;let f=cc(u),d=uc(i,o).nodes,h=[r.types?`matching ${r.types.join(",")} (with ancestors)`:void 0,r.depth!==void 0?`to depth ${r.depth}`:void 0].filter(Boolean);return e.stdout(`${i} \u2014 ${d} node${d===1?"":"s"}${f!==d||h.length>0?`, ${f} shown${h.length>0?` ${h.join(", ")}`:""}`:""}
577
+ ${Mg(u)}${c?`(${c})
578
+ `:""}`),0}});function pc(t){let e=new Map,r=[];for(let s of t){let i=s.path.replace(/\\/g,"/"),o=i.lastIndexOf("/"),a=o>=0?i.slice(0,o):"",l=i.slice(o+1),c=l.lastIndexOf("."),u=c>0?l.slice(0,c):l,f=ZO.exec(u);if(!f||f[1].length===0){r.push(s);continue}let d=f[1],h=a?`${a}/${d}`:d,g=e.get(h);g||(g={key:h,directory:a,stem:d,frames:[],gaps:[],duplicates:[],mixedSizes:[]},e.set(h,g)),g.frames.push({...s,path:i,number:Number.parseInt(f[2],10)})}let n=[...e.values()].sort((s,i)=>s.key.localeCompare(i.key));for(let s of n){s.frames.sort((c,u)=>c.number-u.number||c.path.localeCompare(u.path));let i=new Set;for(let c of s.frames)i.has(c.number)&&!s.duplicates.includes(c.number)&&s.duplicates.push(c.number),i.add(c.number);let o=s.frames[0]?.number??0,a=s.frames[s.frames.length-1]?.number??0;for(let c=o;c<=a;c+=1)i.has(c)||s.gaps.push(c);let l=new Set(s.frames.map(c=>`${c.width}x${c.height}`));s.mixedSizes=l.size>1?[...l]:[]}return{sequences:n,unnumbered:r}}function nT(t){return!rT.includes(t.trim().toLowerCase())}function sT(t){return t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"frame"}function iT(t){let e=t.split(/[\\/]/).pop()??"",r=e.lastIndexOf(".");return r>0?e.slice(r+1).toLowerCase():"png"}function Yg(t){let e=t.name.trim(),r=t.slug.trim();if(!e||!r)throw new N("name and slug are required.");if(!/^[a-z0-9][a-z0-9_-]*$/i.test(r))throw new N(`slug "${r}" must be a plain folder name.`);if(t.clips.length===0)throw new N("a character needs at least one clip.");let n=t.separator&&t.separator.length>0?t.separator:".",s=Jg(t.spriteDirectory??eT),i=Jg(t.prefabDirectory??tT);for(let S of[s,i])if(S.split("/").some(b=>b===".."||b==="."))throw new N(`"${S}" must be a path inside the project.`);let o=s?`${s}/${r}`:r,a=`${o}/${r}.pix3anim`,l=Gg(a),c=t.anchor??{x:.5,y:.5};if(![c.x,c.y].every(S=>typeof S=="number"&&Number.isFinite(S)))throw new N("anchor must be finite numbers.");let u=[],f=[],d=[],h=new Set;for(let S of t.clips){let b=S.variant.trim(),C=S.state.trim();if(!C)throw new N("every clip needs a state.");let R=b?`${b}${n}${C}`:C;if(h.has(R))throw new N(`duplicate clip "${R}".`);if(h.add(R),S.frames.length===0)throw new N(`clip "${R}" has no frames.`);if(S.fps!==void 0&&!(Number.isFinite(S.fps)&&S.fps>0))throw new N(`clip "${R}": fps must be a positive number.`);let A=new Set(S.frames.map(te=>`${te.width}x${te.height}`));A.size>1&&u.push(`${R}: frames differ in size (${[...A].join(", ")}); sizeMode native keeps each frame's own size.`),S.fps===void 0&&u.push(`${R}: fps defaulted to ${Vg}.`);let D=S.loop??nT(C);S.loop===void 0&&u.push(`${R}: loop defaulted to ${D}.`);let Ee=sT(R),L=S.frames.map((te,Py)=>{let $y=String(Py+1).padStart(4,"0"),gc=`${o}/${Ee}_${$y}.${iT(te.path)}`;return f.push({sourcePath:te.path,targetPath:gc}),{textureIndex:0,offset:{x:0,y:0},repeat:{x:1,y:1},durationMultiplier:1,anchor:{x:c.x,y:c.y},texturePath:Gg(gc),boundingBox:{x:0,y:0,width:te.width,height:te.height},collisionPolygon:[],events:[],sourceSize:{width:te.width,height:te.height},points:[]}});d.push({name:R,fps:S.fps??Vg,loop:D,playbackMode:"normal",frames:L})}let g=new Map;for(let S of f){let b=g.get(S.targetPath);if(b!==void 0&&b!==S.sourcePath)throw new N(`two frames would be written to ${S.targetPath} (clip names that differ only in punctuation or case).`);g.set(S.targetPath,S.sourcePath)}let p=(t.defaultVariant??t.clips[0].variant).trim(),m=(t.defaultState??t.clips[0].state).trim(),y=p?`${p}${n}${m}`:m,w=d.find(S=>S.name===y);if(!w)throw new N(`default pair ${p||"<none>"}/${m} has no clip (have: ${[...h].join(", ")}).`);let _=w.frames[0].sourceSize,v={version:"1.0.0",texturePath:"",clips:d},E=`${JSON.stringify(v,null,2)}
579
+ `,k={version:"1.0.0",metadata:{name:e,description:`${e} \u2014 2D character (variant/state flipbook)`},root:[{id:r,type:"AnimatedSprite2D",name:e,properties:{animationResourcePath:l,currentClip:y,isPlaying:!0,sizeMode:"native",width:_.width,height:_.height,transform:{position:[0,0],scale:[1,1],rotation:0}},components:[{id:`${r}-character`,type:"core:CharacterVisual2D",enabled:!0,config:{variant:p,state:m,separator:n}}],children:[]}]},T=`${e.replace(/[\\/:*?"<>|]+/g,"_")}.pix3scene`;return{animationPath:a,animation:v,animationJson:E,prefabPath:i?`${i}/${T}`:T,prefabYaml:(0,Hg.stringify)(k,{lineWidth:0}),frameFiles:f,warnings:u}}function zg(t){if(t.length<24)return null;let e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(!(e.getUint32(0)===2303741511&&e.getUint32(4)===218765834&&String.fromCharCode(...t.subarray(12,16))==="IHDR"))return null;let n=e.getUint32(16),s=e.getUint32(20);return n>0&&s>0?{width:n,height:s}:null}var Hg,ZO,Vg,eT,tT,rT,N,Gg,Jg,Xg=O(()=>{"use strict";Hg=U(ce(),1),ZO=/^(.*?)[ _\-.]*(\d+)$/;Vg=12,eT="sprites",tT="scenes/prefabs",rT=["attack","die","death","hit","hurt"],N=class extends Error{};Gg=t=>`res://${t}`,Jg=t=>t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")});var ly={};X(ly,{compileCharacterIntoProject:()=>oy,formatCharacterReport:()=>ay,loadCharacterSpec:()=>iy,runCharacterCompileCli:()=>pT,slugOf:()=>ny});import{existsSync as mn,readdirSync as oT,readFileSync as Pi}from"node:fs";import{dirname as ty,isAbsolute as aT,join as Qg,relative as lT,resolve as hn,sep as cT}from"node:path";var ry,uT,Zg,ey,ny,fr,sy,dT,iy,fT,oy,ay,pT,cy=O(()=>{"use strict";ry=U(ce(),1);se();Z();de();xt();Xg();uT=t=>{let e,r,n=!1,s=!1,i=!1,o=!1;for(let a=0;a<t.length;a++){let l=t[a];if(l==="--dry-run")n=!0;else if(l==="--force")s=!0;else if(l==="--json")i=!0;else if(l==="--help"||l==="-h")o=!0;else if(l==="--project"||l.startsWith("--project=")){let c=l.includes("=")?l.slice(l.indexOf("=")+1):t[++a];if(!c||c.startsWith("--"))return{error:"--project needs a value"};r=c}else{if(l.startsWith("-"))return{error:`unknown argument ${l}`};if(e===void 0)e=l;else return{error:`one spec at a time (got ${e} and ${l})`}}}return{spec:e,project:r,dryRun:n,force:s,json:i,help:o}},Zg=["name","slug","anchor","defaultVariant","defaultState","separator","spriteDirectory","prefabDirectory","clips"],ey=["variant","state","fps","loop","frames","sequence"],ny=t=>t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),fr=(t,e,r)=>{let n=t[e];if(n!=null){if(typeof n!="string")throw new N(`${r}${e} must be a string.`);return n}},sy=(t,e,r)=>{let n=hn(t,e);if(!mn(n))throw new N(`${r}: ${e} does not exist.`);let s=zg(Pi(n));if(!s)throw new N(`${r}: ${e} is not a PNG (frames must be PNG files).`);return{path:lT(t,n).split(cT).join("/"),...s}},dT=(t,e,r,n)=>{let s=e.replace(/\\/g,"/").replace(/\/+$/,"").replace(/[ _\-.]+$/,""),i=s.lastIndexOf("/"),o=i>=0?s.slice(0,i):"",a=hn(t,o||".");if(!mn(a))throw new N(`${r}: folder ${o||"."} does not exist.`);let l=oT(a).filter(u=>u.toLowerCase().endsWith(".png")).map(u=>({path:o?`${o}/${u}`:u,width:0,height:0})),c=pc(l).sequences.find(u=>u.key===s);if(!c)throw new N(`${r}: no numbered PNGs ${s}<n>.png (sequences there: ${pc(l).sequences.map(u=>u.key).join(", ")||"none"}).`);if(c.duplicates.length>0)throw new N(`${r}: ${s} has frame number(s) ${c.duplicates.join(", ")} more than once \u2014 rename one.`);return c.gaps.length>0&&n.push(`${r}: ${s} skips frame number(s) ${c.gaps.join(", ")}.`),c.frames.map(u=>sy(t,u.path,r))},iy=t=>{let e;try{e=(0,ry.parse)(Pi(t,"utf8"))}catch(f){throw new N(`${t}: ${f instanceof Error?f.message:String(f)}`)}if(!P(e))throw new N(`${t}: expected a mapping.`);let r=Object.keys(e).filter(f=>!Zg.includes(f));if(r.length>0)throw new N(`unknown key(s) ${r.join(", ")} (known: ${Zg.join(", ")}).`);let n=fr(e,"name","");if(!n?.trim())throw new N("name is required.");let s=fr(e,"slug","")??ny(n),i=e.anchor,o;if(i!==void 0){if(!P(i)||typeof i.x!="number"||typeof i.y!="number")throw new N("anchor must be { x: <number>, y: <number> }.");o={x:i.x,y:i.y}}if(!Array.isArray(e.clips)||e.clips.length===0)throw new N("clips must be a non-empty list.");let a=ty(t),l=[],c=e.clips.map((f,d)=>{let h=`clips[${d}]`;if(!P(f))throw new N(`${h} must be a mapping.`);let g=Object.keys(f).filter(v=>!ey.includes(v));if(g.length>0)throw new N(`${h}: unknown key(s) ${g.join(", ")} (known: ${ey.join(", ")}).`);let p=fr(f,"state",`${h}.`);if(!p?.trim())throw new N(`${h}.state is required.`);let m=fr(f,"variant",`${h}.`)??"";if(f.fps!==void 0&&typeof f.fps!="number")throw new N(`${h}.fps must be a number.`);if(f.loop!==void 0&&typeof f.loop!="boolean")throw new N(`${h}.loop must be true or false.`);let y=f.frames!==void 0,w=f.sequence!==void 0;if(y===w)throw new N(`${h}: give exactly one of frames (a list) or sequence.`);let _;if(y){if(!Array.isArray(f.frames)||f.frames.some(v=>typeof v!="string"))throw new N(`${h}.frames must be a list of paths.`);_=f.frames.map(v=>sy(a,v,h))}else{let v=fr(f,"sequence",`${h}.`)??"";_=dT(a,v,h,l)}return{variant:m,state:p,frames:_,...typeof f.fps=="number"?{fps:f.fps}:{},...typeof f.loop=="boolean"?{loop:f.loop}:{}}});return{spec:{name:n,slug:s,clips:c,...o?{anchor:o}:{},...Object.fromEntries(["defaultVariant","defaultState","separator","spriteDirectory","prefabDirectory"].flatMap(f=>{let d=fr(e,f,"");return d===void 0?[]:[[f,d]]}))},warnings:l}},fT=(t,e)=>mn(t)?Buffer.compare(Pi(t),Buffer.from(e))===0:!1,oy=t=>{let{spec:e,warnings:r}=iy(t.specPath),n=Yg(e),s=ty(t.specPath),i=hn(t.projectRoot),o=[{path:n.animationPath,kind:"animation",bytes:Buffer.from(n.animationJson)},{path:n.prefabPath,kind:"prefab",bytes:Buffer.from(n.prefabYaml)},...n.frameFiles.map(u=>({path:u.targetPath,kind:"frame",bytes:Pi(hn(s,u.sourcePath))}))],a=o.map(u=>{let f=Qg(i,u.path),d=mn(f)?fT(f,u.bytes)?"unchanged":t.force?"replaced":"conflict":"written";return{path:u.path,kind:u.kind,action:d}}),l=a.filter(u=>u.action==="conflict"),c={dryRun:t.dryRun??!1,name:e.name.trim(),slug:e.slug.trim(),animationPath:n.animationPath,prefabPath:n.prefabPath,clips:n.animation.clips.map(u=>({name:u.name,frames:u.frames.length,fps:u.fps,loop:u.loop})),warnings:[...r,...n.warnings]};if(l.length>0)return{...c,ok:!1,files:a,error:`${l.length} file(s) exist with other content; nothing was written (--force replaces them).`};if(!t.dryRun)for(let[u,f]of o.entries())(a[u].action==="written"||a[u].action==="replaced")&&Q(Qg(i,f.path),f.bytes);return{...c,ok:!0,files:a}},ay=t=>{let e=[],r=t.clips.reduce((s,i)=>s+i.frames,0);e.push(`pix3 character-compile: ${t.name} (${t.slug}) \u2014 ${t.clips.length} clip(s), ${r} frame(s)${t.dryRun?" \u2014 dry run, nothing written":""}`);for(let s of t.clips)e.push(` clip ${s.name.padEnd(20)} ${s.frames} frame(s), ${s.fps} fps, ${s.loop?"loop":"once"}`);let n={written:t.dryRun?"would write":"wrote",replaced:t.dryRun?"would replace":"replaced",unchanged:"current",conflict:"EXISTS"};for(let s of t.files)e.push(` ${n[s.action].padEnd(13)} ${s.path}${s.action==="conflict"?" (other content; --force replaces it)":""}`);for(let s of t.warnings)e.push(`warning: ${s}`);return t.error?e.push(`error: ${t.error}`):t.dryRun||e.push(`Next: instance it in a scene (\`instance: res://${t.prefabPath}\`), drive it from a script with core:CharacterVisual2D's playState / setVariant, then pix3 check.`),`${e.join(`
413
580
  `)}
414
- `),l>0?1:0},Ple=async(t,e)=>{let r=Sle(t);if("error"in r)return e.stderr(`pix3 tree: ${r.error}
581
+ `},pT=async(t,e)=>{let r=uT(t);if("error"in r)return e.stderr(`pix3 character-compile: ${r.error}
415
582
 
416
- ${UE}`),2;if(r.help)return e.stdout(UE),0;let n=r.project?ZE(e.cwd,r.project):Qe(e.cwd)??ZE(e.cwd);if(r.scene===void 0)return Tle(n,r,e);let s=$le(r.scene,n,e.cwd);if(!s)return e.stderr(`pix3 tree: ${r.scene} not found (looked in ${n} and ${e.cwd}).
417
- `),2;let o=kle(n,s),i;try{i=ag(lg(s,"utf8"))}catch(p){if(!(p instanceof ja))throw p;return e.stderr(`pix3 tree: ${o} is ${p.message}.
418
- `),1}let a,c;if(r.props){let p=await xle(LU(i));"error"in p?c=`defaults unavailable (${String(p.error)}): every authored property is shown`:a=p}let l=jU(i,{depth:r.depth,types:r.types,props:r.props,defaults:a,readPrefab:p=>{let m=ug(n,p);try{return lg(m,"utf8")}catch{return null}}});if(r.json)return e.stdout(`${JSON.stringify({scene:o,nodes:l,...c?{note:c}:{}},null,2)}
419
- `),0;let u=qE(l),d=FE(o,lg(s,"utf8")).nodes,f=[r.types?`matching ${r.types.join(",")} (with ancestors)`:void 0,r.depth!==void 0?`to depth ${r.depth}`:void 0].filter(Boolean);return e.stdout(`${o} \u2014 ${d} node${d===1?"":"s"}${u!==d||f.length>0?`, ${u} shown${f.length>0?` ${f.join(", ")}`:""}`:""}
420
- ${MU(l)}${c?`(${c})
421
- `:""}`),0}});var md,Ma,Ole,Ile,VE,BE,Nle,Cle,Rle,KU,HU,WU,Vn,Ale,hn,zle,JU,GU,YU=$(()=>{"use strict";md=["coin","jump","hit","explosion","powerup","click"],Ma={wave:"square",freq:440,freqEnd:440,slide:0,arpAt:0,arpMul:1,vibratoDepth:0,vibratoHz:0,duty:.5,attack:.002,decay:.05,sustainLevel:.6,sustain:.05,release:.1,lowpassHz:0,lowpassQ:.707,volume:.8},Ole={coin:{...Ma,freq:988,freqEnd:988,arpAt:.07,arpMul:4/3,duty:.5,decay:.02,sustainLevel:.7,sustain:.1,release:.18,volume:.7},jump:{...Ma,freq:260,freqEnd:720,slide:.16,duty:.35,decay:.04,sustainLevel:.6,sustain:.06,release:.1,lowpassHz:5e3,volume:.7},hit:{...Ma,wave:"noise",freq:1400,freqEnd:180,slide:.12,attack:.001,decay:.05,sustainLevel:.3,sustain:.02,release:.08,lowpassHz:3200,lowpassQ:1.2,volume:.85},explosion:{...Ma,wave:"noise",freq:520,freqEnd:40,slide:.7,attack:.002,decay:.12,sustainLevel:.55,sustain:.15,release:.5,lowpassHz:1400,lowpassQ:1,volume:.9},powerup:{...Ma,wave:"saw",freq:330,freqEnd:1320,slide:.38,vibratoDepth:.04,vibratoHz:14,attack:.005,decay:.05,sustainLevel:.7,sustain:.25,release:.15,lowpassHz:6e3,volume:.65},click:{...Ma,wave:"square",freq:1800,freqEnd:1200,slide:.02,duty:.25,attack:5e-4,decay:.012,sustainLevel:0,sustain:0,release:.012,lowpassHz:8e3,volume:.6}},Ile={coin:["coin","pickup","pick up","collect","gem","ding","bling","money","score","reward"],jump:["jump","hop","leap","spring","bounce","boing"],hit:["hit","hurt","damage","punch","impact","thud","smack","crash","kick","slap"],explosion:["explosion","explode","boom","blast","bomb","kaboom","explod","detonat"],powerup:["powerup","power-up","power up","level up","upgrade","bonus","charge","magic"],click:["click","tap","button","ui","menu","select","tick","toggle","blip"]},VE=(t,e)=>({...t,freq:t.freq*e,freqEnd:t.freqEnd*e}),BE=(t,e)=>({...t,slide:t.slide*e,arpAt:t.arpAt*e,decay:t.decay*e,sustain:t.sustain*e,release:t.release*e}),Nle=[{words:["high","bright","tiny","small","light"],apply:t=>VE(t,1.4)},{words:["low","deep","big","heavy","huge"],apply:t=>VE(t,.7)},{words:["short","quick","snappy","fast"],apply:t=>BE(t,.65)},{words:["long","slow"],apply:t=>BE(t,1.6)},{words:["soft","quiet"],apply:t=>({...t,volume:t.volume*.6})}],Cle=t=>t.toLowerCase().split(/[^a-z-]+/).filter(Boolean),Rle=(t,e)=>{let r=e.split(" ");for(let n=0;n+r.length<=t.length;n++)if(r.every((o,i)=>{let a=t[n+i];return a===o||o.length>=5&&a.startsWith(o)}))return n;return-1},KU=t=>{let e=Cle(t),r=md.find(i=>t.trim().toLowerCase()===i),n=r;if(!n){let i=-1;for(let a of md)for(let c of[a,...Ile[a]]){let l=Rle(e,c);l>=0&&(i<0||l<i)&&(i=l,n=a)}}if(!n)return null;let s=Ole[n],o=[];if(!r)for(let i of Nle){let a=i.words.find(c=>e.includes(c));a&&(s=i.apply(s),o.push(a))}return{preset:n,params:s,modifiers:o}},HU=t=>{let e=t>>>0;return()=>{e=e+1831565813>>>0;let r=e;return r=Math.imul(r^r>>>15,r|1),r^=r+Math.imul(r^r>>>7,r|61),((r^r>>>14)>>>0)/4294967296}},WU=(t,e)=>{let r=HU(e^2654435769),n=i=>1+(r()*2-1)*i,s=n(.15),o=n(.2);return{...BE(VE(t,s),o),freqEnd:t.freqEnd*s*n(.08),duty:Math.min(.9,Math.max(.1,t.duty*n(.25))),vibratoDepth:t.vibratoDepth*n(.3),vibratoHz:t.vibratoHz*n(.2),lowpassHz:t.lowpassHz>0?t.lowpassHz*n(.25):0}},Vn=44100,Ale=t=>t.attack+t.decay+t.sustain+t.release,hn=(t,e,r)=>Math.min(r,Math.max(e,Number.isFinite(t)?t:e)),zle=(t,e)=>{if(e<t.attack)return e/t.attack;let r=e-t.attack;return r<t.decay?1-(1-t.sustainLevel)*(r/t.decay):(r-=t.decay,r<t.sustain?t.sustainLevel:(r-=t.sustain,r<t.release?t.sustainLevel*(1-r/t.release)**2:0))},JU=(t,e=1)=>{let r={...t,freq:hn(t.freq,10,2e4),freqEnd:hn(t.freqEnd,10,2e4),attack:hn(t.attack,5e-4,5),decay:hn(t.decay,0,5),sustain:hn(t.sustain,0,5),release:hn(t.release,.002,5),sustainLevel:hn(t.sustainLevel,0,1),duty:hn(t.duty,.05,.95),volume:hn(t.volume,0,1),lowpassQ:hn(t.lowpassQ,.5,8)},n=Ale(r),s=Math.max(1,Math.round(n*Vn)),o=new Float32Array(s),i=HU(e),a=r.slide>0?r.slide:n,c=r.freqEnd/r.freq,l=r.lowpassHz>0&&r.lowpassHz<Vn/2,u=1,d=0,f=0,p=0,m=0;if(l){let Z=2*Math.PI*r.lowpassHz/Vn,ee=Math.sin(Z)/(2*r.lowpassQ),J=Math.cos(Z),fe=1+ee;u=(1-J)/2/fe,d=(1-J)/fe,f=u,p=-2*J/fe,m=(1-ee)/fe}let h=0,g=0,y=0,w=0,b=0,x=0,v=0,S=i()*2-1,T=0;for(let Z=0;Z<s;Z++){let ee=Z/Vn,J=r.freq*c**Math.min(1,ee/a);r.arpAt>0&&ee>=r.arpAt&&(J*=r.arpMul),r.vibratoDepth>0&&(J*=1+r.vibratoDepth*Math.sin(2*Math.PI*r.vibratoHz*ee)),v+=J/Vn;let fe;switch(r.wave){case"square":fe=v%1<r.duty?1:-1;break;case"saw":fe=2*(v%1)-1;break;case"sine":fe=Math.sin(2*Math.PI*v);break;case"triangle":fe=1-4*Math.abs(v%1-.5);break;case"noise":{let Re=Math.floor(v*16);Re!==T&&(T=Re,S=i()*2-1),fe=S;break}}if(fe*=zle(r,ee),l){let Re=u*fe+d*h+f*g-p*y-m*w;g=h,h=fe,w=y,y=Re,fe=Re}x=fe-b+.995*x,b=fe,o[Z]=x}let P=Math.min(s,Math.round(.003*Vn));for(let Z=0;Z<P;Z++)o[s-1-Z]*=Z/P;let A=0;for(let Z of o)A=Math.max(A,Math.abs(Z));if(A>0){let Z=r.volume/A;for(let ee=0;ee<s;ee++)o[ee]*=Z}return o},GU=(t,e=Vn)=>{let r=t.length*2,n=new ArrayBuffer(44+r),s=new DataView(n),o=(i,a)=>{for(let c=0;c<a.length;c++)s.setUint8(i+c,a.charCodeAt(c))};o(0,"RIFF"),s.setUint32(4,36+r,!0),o(8,"WAVE"),o(12,"fmt "),s.setUint32(16,16,!0),s.setUint16(20,1,!0),s.setUint16(22,1,!0),s.setUint32(24,e,!0),s.setUint32(28,e*2,!0),s.setUint16(32,2,!0),s.setUint16(34,16,!0),o(36,"data"),s.setUint32(40,r,!0);for(let i=0;i<t.length;i++){let a=Math.max(-1,Math.min(1,t[i]));s.setInt16(44+i*2,Math.round(a<0?a*32768:a*32767),!0)}return new Uint8Array(n)}});var nV={};Je(nV,{SFX_USAGE:()=>dg,runSfx:()=>Dle});import{mkdirSync as jle,writeFileSync as Mle}from"node:fs";import{dirname as XU,relative as QU,resolve as eV,sep as tV}from"node:path";var dg,rV,Lle,Dle,sV=$(()=>{"use strict";ut();YU();dg=`Usage: pix3 sfx <preset|"description"> [--out <file.wav>] [--seed <n>] [--json]
583
+ ${I["character-compile"]}`),2;if(r.help)return e.stdout(I["character-compile"]),0;if(!r.spec)return e.stderr(`pix3 character-compile: name the spec file.
422
584
 
423
- Synthesizes a short sound effect offline into a 44.1 kHz 16-bit mono WAV.
424
- presets ${md.join(", ")}
425
- description words that name a preset ("coin pickup", "big explosion"), plus modifiers:
426
- high/low, short/long, soft
427
- --out output file (default: audio/<preset>.wav in the project root)
428
- --seed a variation of the preset (same seed, same sound); default: the preset as tuned
429
- --json print { path, res, durationMs, preset, seed, modifiers, bytes, peak, params }
430
- Reference it from a scene or script as res://<path inside the project>.
431
- `,rV=(t,e=4)=>Number(t.toFixed(e)),Lle=t=>{let e={};for(let[r,n]of Object.entries(t))e[r]=typeof n=="number"?rV(n):n;return e},Dle=(t,e)=>{let r,n,s,o=!1;for(let g=0;g<t.length;g++){let y=t[g];if(y==="--help"||y==="-h")return e.stdout(dg),0;if(y==="--json")o=!0;else if(y==="--out"||y==="--seed"){let w=t[g+1];if(w===void 0||w.startsWith("--"))return e.stderr(`pix3 sfx: ${y} needs a value.
432
- `),2;y==="--out"?n=w:s=w,g++}else if(y.startsWith("--out="))n=y.slice(6);else if(y.startsWith("--seed="))s=y.slice(7);else{if(y.startsWith("--"))return e.stderr(`pix3 sfx: unknown option ${y}.
585
+ ${I["character-compile"]}`),2;let n=ue(e.cwd,r.project);if("error"in n)return e.stderr(`pix3 character-compile: ${n.error}
586
+ `),2;let{root:s}=n,i=aT(r.spec)?r.spec:hn(e.cwd,r.spec);if(!mn(i))return e.stderr(`pix3 character-compile: ${r.spec} does not exist.
587
+ `),2;let o;try{o=oy({projectRoot:s,specPath:i,dryRun:r.dryRun,force:r.force})}catch(a){if(!(a instanceof N))throw a;return r.json?e.stdout(`${JSON.stringify({ok:!1,error:a.message},null,2)}
588
+ `):e.stderr(`pix3 character-compile: ${a.message}
589
+ `),1}return e.stdout(r.json?`${JSON.stringify(o,null,2)}
590
+ `:ay(o)),o.ok?0:1}});var Sy={};X(Sy,{GAPS_FILE:()=>gn,GAP_KINDS:()=>mc,buildGap:()=>gy,detectAgent:()=>my,parseGapArgs:()=>hy,readGaps:()=>yy,runGapCli:()=>bT});import{appendFileSync as hT,mkdirSync as mT,readFileSync as gT}from"node:fs";import{dirname as yT,join as hc}from"node:path";var gn,mc,uy,dy,fy,ST,hy,my,py,gy,yy,bT,by=O(()=>{"use strict";Z();de();gn=hc(".pix3","gaps.jsonl"),mc=["capability","tool","node","doc","other"],uy=200,dy=4e3,fy=500,ST=t=>mc.includes(t),hy=t=>{let e={list:!1,json:!1,kind:"other"};for(let r=0;r<t.length;r++){let n=t[r],s=()=>{let i=t[++r];return i===void 0?{error:`${n} needs a value`}:i};if(n==="--list")e.list=!0;else if(n==="--json")e.json=!0;else if(n==="--kind"||n==="--detail"||n==="--context"||n==="--agent"){let i=s();if(typeof i!="string")return i;if(n==="--kind"){if(!ST(i))return{error:`--kind is one of ${mc.join(", ")}, not "${i}"`};e.kind=i}else e[n.slice(2)]=i}else if(n==="--project"){let i=s();if(typeof i!="string")return i;e.projectDir=i}else{if(n.startsWith("--"))return{error:`unknown option "${n}"`};if(e.summary===void 0)e.summary=n;else return{error:'one summary only \u2014 quote it ("\u2026"); put the rest in --detail'}}}return e},my=t=>{if(t.CLAUDECODE==="1")return"claude-code";if(Object.keys(t).some(e=>e.startsWith("CODEX_")))return"codex"},py=t=>t.replace(/\s+/g," ").trim(),gy=(t,e,r)=>{let n=py(t.summary??"");if(!n)return{error:'say what was missing: pix3 gap "<summary>" --kind <kind>'};if(n.length>uy)return{error:`the summary is one line of at most ${uy} characters; put the rest in --detail`};if((t.detail?.length??0)>dy)return{error:`--detail is at most ${dy} characters`};let s=t.context===void 0?void 0:py(t.context);if((s?.length??0)>fy)return{error:`--context is at most ${fy} characters`};let i=t.agent??my(e);return{ts:r.toISOString(),...i?{agent:i}:{},kind:t.kind,summary:n,...t.detail?.trim()?{detail:t.detail.trim()}:{},...s?{context:s}:{}}},yy=t=>{let e;try{e=gT(hc(t,gn),"utf8")}catch{return[]}let r=[];for(let n of e.split(`
591
+ `))if(n.trim())try{let s=JSON.parse(n);typeof s.summary=="string"&&typeof s.kind=="string"&&r.push(s)}catch{}return r},bT=(t,e)=>{if(t.includes("--help")||t.includes("-h"))return e.stdout(I.gap),0;let r=hy(t);if("error"in r)return e.stderr(`pix3 gap: ${r.error}
433
592
 
434
- ${dg}`),2;r=r===void 0?y:`${r} ${y}`}}if(r===void 0||r.trim()==="")return e.stderr(`pix3 sfx: say which sound.
593
+ ${I.gap}`),2;let n=ue(e.cwd,r.projectDir);if("error"in n)return e.stderr(`pix3 gap: ${n.error}
594
+ `),2;let{root:s}=n;if(r.list){let a=yy(s);if(r.json)e.stdout(`${JSON.stringify(a,null,2)}
595
+ `);else if(!a.length)e.stdout(`No gaps recorded (${gn}).
596
+ `);else for(let l of a)e.stdout(`${l.ts} ${l.kind.padEnd(10)} ${l.agent?`[${l.agent}] `:""}${l.summary}
597
+ `);return 0}let i=gy(r,e.env??process.env,(e.now??(()=>new Date))());if("error"in i)return e.stderr(`pix3 gap: ${i.error}
598
+ `),2;let o=hc(s,gn);return mT(yT(o),{recursive:!0}),hT(o,`${JSON.stringify(i)}
599
+ `),e.stdout(r.json?`${JSON.stringify(i)}
600
+ `:`Recorded in ${gn}: [${i.kind}] ${i.summary}
601
+ `),0}});var ky={};X(ky,{runSfx:()=>CT});import{mkdirSync as wT,writeFileSync as xT}from"node:fs";import{dirname as wy,relative as xy,resolve as vy,sep as _y}from"node:path";var Ey,vT,_T,ET,kT,CT,Cy=O(()=>{"use strict";Z();de();Sa();Ey=(t,e=4)=>Number(t.toFixed(e)),vT=t=>{let e={};for(let[r,n]of Object.entries(t))e[r]=typeof n=="number"?Ey(n):n;return e},_T=t=>{let e,r,n,s=!1;for(let o=0;o<t.length;o++){let a=t[o];if(a==="--help"||a==="-h")return{help:!0};if(a==="--json")s=!0;else if(a==="--out"||a==="--seed"){let l=t[o+1];if(l===void 0||l.startsWith("--"))return{error:`${a} needs a value.`};a==="--out"?r=l:n=l,o++}else if(a.startsWith("--out="))r=a.slice(6);else if(a.startsWith("--seed="))n=a.slice(7);else{if(a.startsWith("--"))return{error:`unknown option ${a}.`,usage:!0};e=e===void 0?a:`${e} ${a}`}}if(e===void 0||e.trim()==="")return{error:"say which sound.",usage:!0};let i=null;if(n!==void 0){let o=Number(n);if(!Number.isInteger(o)||o<0||o>4294967295)return{error:`--seed takes a whole number 0..4294967295, not "${n}".`};i=o}return r!==void 0&&!/\.wav$/i.test(r)?{error:`--out must end in .wav (the only format this writes), got "${r}".`}:{text:e,out:r,seed:i,json:s}},ET=(t,e)=>{let r=kf(t.text);if(!r)return{error:`"${t.text}" names no preset. Use one of ${Wt.join(", ")}, or words like "coin pickup", "big explosion", "button click".`};let{seed:n}=t,s=n===null?r.params:Of(r.params,n),i=Tf(s,n??1),o=Pf(i),a=t.out!==void 0?vy(e,t.out):vy(rt(e)??e,"audio",`${r.preset}.wav`);wT(wy(a),{recursive:!0}),xT(a,o);let l=0;for(let f of i)l=Math.max(l,Math.abs(f));let c=rt(wy(a)),u=c?xy(c,a):null;return{path:xy(e,a).split(_y).join("/"),res:u&&!u.startsWith("..")?`res://${u.split(_y).join("/")}`:null,durationMs:Math.round(i.length/Me*1e3),preset:r.preset,seed:n,modifiers:r.modifiers,bytes:o.byteLength,peak:Ey(l,3),params:vT(s)}},kT=t=>{let e=[t.modifiers.length>0?t.modifiers.join(" "):null,t.seed!==null?`seed ${t.seed}`:null].filter(Boolean).join(", ");return`wrote ${t.path} ${t.preset}${e?` (${e})`:""}, ${t.durationMs} ms, ${(t.bytes/1024).toFixed(1)} KiB${t.res?`
602
+ use it as ${t.res}`:""}
603
+ `},CT=(t,e)=>{let r=_T(t);if("help"in r)return e.stdout(I.sfx),0;if("error"in r)return e.stderr(`pix3 sfx: ${r.error}
604
+ ${r.usage?`
605
+ ${I.sfx}`:""}`),2;let n=ET(r,e.cwd);return"error"in n?(e.stderr(`pix3 sfx: ${n.error}
606
+ `),2):(e.stdout(r.json?`${JSON.stringify(n,null,2)}
607
+ `:kT(n)),0)}});import{relative as OT,resolve as TT}from"node:path";Z();Re();import{existsSync as Dv,mkdirSync as df,readdirSync as hf,readFileSync as ff,writeFileSync as Fv}from"node:fs";import{basename as qv,extname as Bv,join as Kr,relative as Uv,resolve as Kv}from"node:path";var Wv=["design","scenes","sprites","scripts","audio"],Vv=new Set([".pix3scene",".ts",".md",".yaml",".yml",".json",".txt",".html"]),pf={gitignore:".gitignore"},Gv=t=>t.toLowerCase().replace(/[^a-z0-9._~-]+/g,"-").replace(/^[-._~]+|[-._~]+$/g,"").slice(0,214)||"pix3-game",Jv=[],mf=(t,e=t)=>{let r=[];for(let n of hf(e,{withFileTypes:!0})){let s=Kr(e,n.name);n.isDirectory()?r.push(...mf(t,s)):n.isFile()&&r.push(Uv(t,s).split("\\").join("/"))}return r.sort()},gf=t=>{let e=Kv(t.dir);if(Dv(e)&&hf(e).length>0)throw new Error(`${e} is not empty. Choose an empty or new folder for a new project.`);let r=t.template,n=(t.projectName??qv(e)).trim()||"Pix3 Project",s=t.projectId??af(),i=[],o=(u,f)=>{let d=Kr(e,u);df(Kr(d,".."),{recursive:!0}),Fv(d,f),i.push(u)};for(let u of[...Wv,...r.directories])df(Kr(e,u),{recursive:!0});o(K,cf(lf(r,{projectName:n,projectId:s})));let a=u=>u.replaceAll("{{PROJECT_NAME}}",n).replaceAll("{{PACKAGE_NAME}}",Gv(n)).replaceAll("{{PIX3_VERSION}}",F),l=new Map;for(let u of[...r.layerDirs,r.filesDir])for(let f of mf(u)){let d=f.split("/").pop()??f,h=d in pf?f.slice(0,f.length-d.length)+pf[d]:f;l.set(h,Kr(u,f))}for(let[u,f]of[...l].sort(([d],[h])=>d.localeCompare(h)))Vv.has(Bv(f).toLowerCase())?o(u,a(ff(f,"utf8"))):o(u,ff(f));o(".pix3/template.json",JSON.stringify({templateId:r.id,editorVersion:F,createdBy:"@pix3/cli",createdAt:new Date().toISOString()},null,2)+`
608
+ `);let c={dir:e,projectId:s,projectName:n,template:r,files:i};for(let u of t.postCreateSteps??Jv)i.push(...u(c));return c};var xf=U(ce(),1);Ie();import{existsSync as Ut,readdirSync as Hv,readFileSync as Yv,statSync as zv}from"node:fs";import{join as nt,resolve as yf}from"node:path";var Xv=["2d","3d"],Qv=["mobile","desktop","universal"],Zv="3d",e_="universal",Sf={width:1920,height:1080},vf=()=>ie(),t_=()=>{let t=vf(),e=nt(t,"..",".."),r=nt(e,"packages","create-pix3","templates");return yf(e,"packages","cli")===yf(t)&&Ut(nt(e,"packages","runtime"))&&Ut(r)?r:null},bf=()=>{let t=t_();return t?[t]:[nt(vf(),"templates")]},r_=()=>{let t=process.env.PIX3_TEMPLATES_DIR;if(t)return t;for(let e of bf())if(Ut(e)&&zv(e).isDirectory())return e;throw new Error(`No project templates found in ${bf().join(", ")}. The package is incomplete \u2014 reinstall it (published builds carry a templates/ copy).`)},ha=(t,e)=>{let r=Number(t);return Number.isFinite(r)&&r>0?Math.round(r):e},wf=t=>t&&typeof t=="object"?t:{},n_=(t,e)=>{let r=nt(t,e),n=nt(r,"template.yaml"),s=nt(r,"files");if(!Ut(n)||!Ut(s))return null;let i={};try{i=wf((0,xf.parse)(Yv(n,"utf8")))}catch(h){process.stderr.write(`pix3: failed to parse ${n}: ${String(h)}
609
+ `)}let o=typeof i.projectType=="string"?i.projectType:"",a=typeof i.targetPlatform=="string"?i.targetPlatform:"",l=wf(i.viewport),c=typeof i.entryScene=="string"?i.entryScene.trim():"",u=c?c.replace(/^res:\/\//i,""):void 0,f=typeof i.extends=="string"?i.extends.trim():"",d=f?nt(t,f,"files"):null;return d&&!Ut(d)?(process.stderr.write(`pix3: ${n} extends "${f}", which has no files/
610
+ `),null):{id:e,title:typeof i.title=="string"&&i.title.trim()?i.title.trim():e,description:typeof i.description=="string"?i.description.trim():"",projectType:Xv.includes(o)?o:Zv,targetPlatform:Qv.includes(a)?a:e_,viewport:{width:ha(l.width,Sf.width),height:ha(l.height,Sf.height)},order:ha(i.order,1e3),hidden:i.hidden===!0,...u?{entryScenePath:u}:{},directories:Array.isArray(i.directories)?i.directories.filter(h=>typeof h=="string"&&h.length>0):[],filesDir:s,layerDirs:d?[d]:[]}},ma=(t=r_())=>Hv(t,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>n_(t,e.name)).filter(e=>e!==null).sort((e,r)=>e.order-r.order||e.title.localeCompare(r.title)),_f=(t,e)=>{let r=t.trim().toLowerCase(),n=e.find(i=>i.id.toLowerCase()===r);if(n)return{template:n};let s=e.filter(i=>!i.hidden).map(i=>i.id).join(", ");return{error:`Unknown template "${t}" (${s}).`}},Ef=t=>{let e=t.replace(/\s+/g," ").trim(),r=/^(.+?[.!?])(\s|$)/.exec(e);return r?r[1]:e};de();Re();var Ty=t=>{let e=[],r=new Map;for(let n=0;n<t.length;n++){let s=t[n];if(s.startsWith("--")){let i=s.indexOf("=");i>0?r.set(s.slice(2,i),s.slice(i+1)):n+1<t.length&&!t[n+1].startsWith("-")?r.set(s.slice(2),t[++n]):r.set(s.slice(2),!0)}else s==="-v"?r.set("version",!0):s==="-h"?r.set("help",!0):e.push(s)}return{positionals:e,flags:r}},PT=(t,e)=>{let r=t.flags.get(e);return typeof r=="string"?r:void 0},z={cwd:process.cwd(),stdout:t=>{process.stdout.write(t)},stderr:t=>{process.stderr.write(t)}},$T=()=>{let t=ma().filter(r=>!r.hidden),e=Math.max(...t.map(r=>r.id.length));z.stdout(`Starters:
611
+ `);for(let r of t)z.stdout(` ${r.id.padEnd(e)} ${r.title} \u2014 ${Ef(r.description)}
612
+ `);z.stdout(`
613
+ Create one: pix3 new <id> [dir] (or: npm create pix3)
614
+ `)},NT=async(t,e)=>{if(e.includes("--help")||e.includes("-h"))return z.stdout(I.new),0;let[r,n]=t.positionals;if(!r)return $T(),0;let s=_f(r,ma());if("error"in s)return z.stderr(`pix3: ${s.error}
615
+ `),1;let i=TT(process.cwd(),n??`pix3-${s.template.id}`),o=g=>z.stderr(`${g}
616
+ `),{ensureKit:a}=await Promise.resolve().then(()=>(Ta(),Jf)),{ensureRuntimeTypes:l}=await Promise.resolve().then(()=>(Yr(),ks)),{agentKitStep:c}=await Promise.resolve().then(()=>(Ls(),tp)),u=await a({log:o}),f=l({log:o}),d=gf({template:s.template,dir:i,projectName:PT(t,"name"),postCreateSteps:[c(u,f)]}),h=OT(process.cwd(),d.dir)||".";return z.stdout(`Created ${d.projectName} (${d.template.title}) in ${d.dir}
617
+ ${d.files.length} files, project id ${d.projectId}, agent kit ${u.manifest.version}
435
618
 
436
- ${dg}`),2;let i=null;if(s!==void 0){let g=Number(s);if(!Number.isInteger(g)||g<0||g>4294967295)return e.stderr(`pix3 sfx: --seed takes a whole number 0..4294967295, not "${s}".
437
- `),2;i=g}let a=KU(r);if(!a)return e.stderr(`pix3 sfx: "${r}" names no preset. Use one of ${md.join(", ")}, or words like "coin pickup", "big explosion", "button click".
438
- `),2;if(n!==void 0&&!/\.wav$/i.test(n))return e.stderr(`pix3 sfx: --out must end in .wav (the only format this writes), got "${n}".
439
- `),2;let c=i===null?a.params:WU(a.params,i),l=JU(c,i??1),u=GU(l),d=n!==void 0?eV(e.cwd,n):eV(Qe(e.cwd)??e.cwd,"audio",`${a.preset}.wav`);jle(XU(d),{recursive:!0}),Mle(d,u);let f=0;for(let g of l)f=Math.max(f,Math.abs(g));let p=Qe(XU(d)),m=p?QU(p,d):null,h={path:QU(e.cwd,d).split(tV).join("/"),res:m&&!m.startsWith("..")?`res://${m.split(tV).join("/")}`:null,durationMs:Math.round(l.length/Vn*1e3),preset:a.preset,seed:i,modifiers:a.modifiers,bytes:u.byteLength,peak:rV(f,3),params:Lle(c)};if(o)e.stdout(`${JSON.stringify(h,null,2)}
440
- `);else{let g=[a.modifiers.length>0?a.modifiers.join(" "):null,i!==null?`seed ${i}`:null].filter(Boolean).join(", ");e.stdout(`wrote ${h.path} ${h.preset}${g?` (${g})`:""}, ${h.durationMs} ms, ${(h.bytes/1024).toFixed(1)} KiB${h.res?`
441
- use it as ${h.res}`:""}
442
- `)}return 0}});import{resolve as KE}from"node:path";ut();vf();ar();import{existsSync as nK,mkdirSync as WO,readdirSync as GO,readFileSync as JO,writeFileSync as sK}from"node:fs";import{basename as oK,extname as iK,join as gc,relative as aK,resolve as cK}from"node:path";var lK=["design","scenes","sprites","scripts","audio","references"],uK=new Set([".pix3scene",".ts",".md",".yaml",".yml",".json",".txt"]),dK=[Xy()],YO=(t,e=t)=>{let r=[];for(let n of GO(e,{withFileTypes:!0})){let s=gc(e,n.name);n.isDirectory()?r.push(...YO(t,s)):n.isFile()&&r.push(aK(t,s).split("\\").join("/"))}return r.sort()},XO=t=>{let e=cK(t.dir);if(nK(e)&&GO(e).length>0)throw new Error(`${e} is not empty. Choose an empty or new folder for a new project.`);let r=t.template,n=(t.projectName??oK(e)).trim()||"Pix3 Project",s=t.projectId??Hy(),o=[],i=(c,l)=>{let u=gc(e,c);WO(gc(u,".."),{recursive:!0}),sK(u,l),o.push(c)};for(let c of[...lK,...r.directories])WO(gc(e,c),{recursive:!0});i(xe,Jy(Wy(r,{projectName:n,projectId:s})));for(let c of YO(r.filesDir)){let l=gc(r.filesDir,c);uK.has(iK(c).toLowerCase())?i(c,JO(l,"utf8").replaceAll("{{PROJECT_NAME}}",n)):i(c,JO(l))}i(".pix3/template.json",JSON.stringify({templateId:r.id,editorVersion:be,createdBy:"@pix3/cli",createdAt:new Date().toISOString()},null,2)+`
443
- `);let a={dir:e,projectId:s,projectName:n,template:r,files:o};for(let c of t.postCreateSteps??dK)o.push(...c(a));return a};var nI=Ze(Er(),1);Us();import{existsSync as Yo,readdirSync as fK,readFileSync as pK,statSync as hK}from"node:fs";import{join as ts,resolve as QO}from"node:path";var mK=["2d","3d"],gK=["mobile","desktop","universal"],yK="3d",_K="universal",eI={width:1920,height:1080},sI=()=>Wt(),vK=()=>{let t=sI(),e=ts(t,"..",".."),r=ts(e,"src","templates","projects");return QO(e,"packages","pix3-cli")===QO(t)&&Yo(ts(e,"packages","pix3-runtime"))&&Yo(r)?r:null},tI=()=>{let t=vK();return t?[t]:[ts(sI(),"templates")]},wK=()=>{let t=process.env.PIX3_TEMPLATES_DIR;if(t)return t;for(let e of tI())if(Yo(e)&&hK(e).isDirectory())return e;throw new Error(`No project templates found in ${tI().join(", ")}. The package is incomplete \u2014 reinstall it (published builds carry a templates/ copy).`)},Qy=(t,e)=>{let r=Number(t);return Number.isFinite(r)&&r>0?Math.round(r):e},rI=t=>t&&typeof t=="object"?t:{},bK=(t,e)=>{let r=ts(t,e),n=ts(r,"template.yaml"),s=ts(r,"files");if(!Yo(n)||!Yo(s))return null;let o={};try{o=rI((0,nI.parse)(pK(n,"utf8")))}catch(d){process.stderr.write(`pix3: failed to parse ${n}: ${String(d)}
444
- `)}let i=typeof o.projectType=="string"?o.projectType:"",a=typeof o.targetPlatform=="string"?o.targetPlatform:"",c=rI(o.viewport),l=typeof o.entryScene=="string"?o.entryScene.trim():"",u=l?l.replace(/^res:\/\//i,""):void 0;return{id:e,title:typeof o.title=="string"&&o.title.trim()?o.title.trim():e,description:typeof o.description=="string"?o.description.trim():"",projectType:mK.includes(i)?i:yK,targetPlatform:gK.includes(a)?a:_K,viewport:{width:Qy(c.width,eI.width),height:Qy(c.height,eI.height)},order:Qy(o.order,1e3),hidden:o.hidden===!0,isRecipe:Yo(ts(s,"design","recipe.md")),...u?{entryScenePath:u}:{},directories:Array.isArray(o.directories)?o.directories.filter(d=>typeof d=="string"&&d.length>0):[],filesDir:s}},e_=(t=wK())=>fK(t,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>bK(t,e.name)).filter(e=>e!==null).sort((e,r)=>e.order-r.order||e.title.localeCompare(r.title)),oI=(t,e)=>{let r=e.find(o=>o.id===t);if(r)return{template:r};let s=e.filter(o=>!o.hidden).filter(o=>o.id===`recipe-${t}`||o.id.startsWith(`recipe-${t}-`));return s.length===1?{template:s[0]}:s.length>1?{error:`"${t}" is ambiguous: ${s.map(o=>o.id).join(", ")}.`}:{error:`Unknown recipe or template "${t}". Run \`pix3 new\` to list them.`}},iI=t=>{let e=t.replace(/\s+/g," ").trim(),r=/^(.+?[.!?])(\s|$)/.exec(e);return r?r[1]:e};ar();var t_=`pix3 ${be}
619
+ Next:
620
+ `+(h==="."?"":` cd ${h}
621
+ `)+` npm install
622
+ npm run dev # the game at /, the Pix3 editor at /__pix3/
623
+ npm run build # dist/index.html
624
+ npm run editor # the editor in Chrome for your coding agent (starts dev if needed)
625
+ npx pix3 agent-setup # once per project: connects Codex / Claude Code to that Chrome
445
626
 
446
- Usage:
447
- pix3 new List recipes and templates
448
- pix3 new <recipe> [dir] Create a project (dir defaults to the recipe id)
449
- [--name <project name>]
450
- pix3 mcp --workspace MCP server for your agent (stdio), relayed through the
451
- [--project <dir>] running \`pix3 serve\` to the connected Pix3 editor
452
- pix3 mcp [--project <dir>] (phase-0 prototype) MCP server + FSA loopback link
453
- [--agent <name>]
454
- pix3 setup [claude|codex] Print how to register the MCP server with your agent
455
- pix3 serve [--project <dir>] Serve this project folder to a Pix3 editor over one
456
- [--port <n>] [--new-token] loopback port (e.g. through VS Code Remote SSH)
457
- pix3 validate [paths\u2026] [--json] Strict scene check: schema, references, guards, then
458
- [--no-hydrate] hydration with the real loader (exit 1 on errors)
459
- pix3 check [--json] validate + TypeScript check of the scripts + merge-log +
460
- [--no-hydrate] [--offline] version check (exit 1 on errors)
461
- [--project <dir>]
462
- pix3 smoke [scene] [--json] Run the game headless in Node for N frames (no browser):
463
- [--changed | --all] script throws with frame + stack, console errors, missing
464
- [--frames N] [--timeout S] res:// (exit 1 on errors, 2 when it cannot run). No scene =
465
- [--project <dir>] the scenes git changes reach, else every top-level scene
466
- pix3 tree [scene] [--json] One line per node (type#id, pos, size, layout, components,
467
- [--depth N] [--types A,B] prefab instances); no scene = project overview
468
- [--props] [--project <dir>]
469
- pix3 kit [--update] Install (or update) the agent kit: AGENTS.md, CLAUDE.md,
470
- [--project <dir>] .claude/skills/pix3-*, .mcp.json, script types
471
- pix3 read <path> Print a project file and confirm to the editor that you
472
- read exactly these bytes (.pix3/ack.json)
473
- pix3 ack <path> --sha256 <hash> Confirm you read the version with this byte hash
474
- pix3 sfx <preset|"text"> Synthesize a sound effect offline into a WAV (coin, jump,
475
- [--out <file.wav>] hit, explosion, powerup, click; or "big explosion")
476
- [--seed <n>] [--json]
477
- pix3 --version
478
- `;ar();var qle=t=>{let e=[],r=new Map;for(let n=0;n<t.length;n++){let s=t[n];if(s.startsWith("--")){let o=s.indexOf("=");o>0?r.set(s.slice(2,o),s.slice(o+1)):n+1<t.length&&!t[n+1].startsWith("-")?r.set(s.slice(2),t[++n]):r.set(s.slice(2),!0)}else s==="-v"?r.set("version",!0):s==="-h"?r.set("help",!0):e.push(s)}return{positionals:e,flags:r}},mn=(t,e)=>{let r=t.flags.get(e);return typeof r=="string"?r:void 0},Fle=()=>{let t=e_().filter(n=>!n.hidden),e=Math.max(...t.map(n=>n.id.length)),r=(n,s)=>{if(s.length!==0){process.stdout.write(`${n}
479
- `);for(let o of s)process.stdout.write(` ${o.id.padEnd(e)} ${o.title} \u2014 ${iI(o.description)}
480
- `);process.stdout.write(`
481
- `)}};r("Recipes (ship design/recipe.md \u2014 a playable core loop):",t.filter(n=>n.isRecipe)),r("Starter templates:",t.filter(n=>!n.isRecipe)),process.stdout.write(`Create one: pix3 new <id> [dir] (recipes also by short name: pix3 new tapper)
482
- `)},Zle=async t=>{let[,e,r]=t.positionals;if(!e)return Fle(),0;let n=oI(e,e_());if("error"in n)return process.stderr.write(`pix3: ${n.error}
483
- `),1;let s=KE(process.cwd(),r??n.template.id),o=f=>{process.stderr.write(`${f}
484
- `)},{ensureKit:i}=await Promise.resolve().then(()=>(p_(),TI)),{ensureRuntimeTypes:a}=await Promise.resolve().then(()=>(Sc(),kf)),{agentKitStep:c}=await Promise.resolve().then(()=>(S_(),jI)),l=await i({log:o}),u=a({log:o}),d=XO({template:n.template,dir:s,projectName:mn(t,"name"),postCreateSteps:[c(l,u)]});return process.stdout.write(`Created ${d.projectName} from ${d.template.id} in ${d.dir}
485
- ${d.files.length} files, project id ${d.projectId}, agent kit ${l.manifest.version}
486
-
487
- Next: open that folder in Pix3 (Open Folder), or run \`pix3 serve\` in it and connect
488
- (File \u2192 Connect to Workspace\u2026); then start your agent inside it \u2014 AGENTS.md / CLAUDE.md
489
- and .claude/skills/ tell it how, .mcp.json connects it, \`pix3 check\` verifies its work.
490
- `),0},Ule=async()=>{let t=qle(process.argv.slice(2)),e=t.positionals[0];if(t.flags.has("version"))return process.stdout.write(`${be}
491
- `),0;if(!e||t.flags.has("help")||e==="help")return process.stdout.write(t_),e||t.flags.has("help")?0:1;switch(e){case"new":return Zle(t);case"check":return(await Promise.resolve().then(()=>(oN(),sN))).runCheck(process.argv.slice(process.argv.indexOf("check")+1),{cwd:process.cwd(),stdout:r=>process.stdout.write(r),stderr:r=>process.stderr.write(r)});case"kit":return(await Promise.resolve().then(()=>(aN(),iN))).runKitCli({cwd:process.cwd(),projectDir:mn(t,"project"),update:t.flags.has("update")});case"mcp":{if(t.flags.has("workspace")){let{runMcpWorkspace:n}=await Promise.resolve().then(()=>(F2(),q2));return await n({cwd:process.cwd(),projectDir:mn(t,"project"),agent:mn(t,"agent")??(process.env.PIX3_AGENT||void 0)}),-1}let{runMcp:r}=await Promise.resolve().then(()=>(uF(),lF));return await r({cwd:process.cwd(),projectDir:mn(t,"project"),agent:mn(t,"agent")??(process.env.PIX3_AGENT||void 0)}),-1}case"setup":{let r=t.positionals[1]??null;if(r!==null&&r!=="claude"&&r!=="codex")return process.stderr.write(`pix3: setup takes claude or codex, not "${r}".
492
- `),1;let{findProjectRoot:n}=await Promise.resolve().then(()=>(ut(),LO)),{setupInstructions:s}=await Promise.resolve().then(()=>(vf(),HO)),o=mn(t,"project"),i=o?KE(process.cwd(),o):n(process.cwd())??KE(process.cwd());return process.stdout.write(s(r,i)),0}case"serve":{let{runServe:r}=await Promise.resolve().then(()=>(VZ(),UZ)),n=t.flags.get("port");return n===!0?(process.stderr.write(`pix3: --port needs a number.
493
- `),1):r({cwd:process.cwd(),projectDir:mn(t,"project"),port:n,newToken:t.flags.has("new-token")})}case"read":case"ack":{let r=t.positionals[1];if(!r)return process.stderr.write(`pix3: ${e} needs a file path.
494
- `),1;let{ackFile:n,readAndAck:s}=await Promise.resolve().then(()=>(HZ(),KZ)),o=mn(t,"project");if(e==="read")return process.stdout.write(s({cwd:process.cwd(),file:r,projectDir:o}).bytes),0;if(t.flags.get("sha256")===!0)return process.stderr.write(`pix3: --sha256 needs a hash.
495
- `),1;let i=n({cwd:process.cwd(),file:r,projectDir:o,hash:mn(t,"sha256")});return process.stdout.write(`acked ${i.path} ${i.sha256}
496
- `),0}case"smoke":return(await Promise.resolve().then(()=>(xU(),kU))).runSmokeCli(process.argv.slice(process.argv.indexOf("smoke")+1),{cwd:process.cwd(),stdout:r=>process.stdout.write(r),stderr:r=>process.stderr.write(r)});case"tree":return(await Promise.resolve().then(()=>(BU(),VU))).runTreeCli(process.argv.slice(process.argv.indexOf("tree")+1),{cwd:process.cwd(),stdout:r=>process.stdout.write(r),stderr:r=>process.stderr.write(r)});case"validate":return(await Promise.resolve().then(()=>(E_(),x_))).runValidateCli(process.argv.slice(process.argv.indexOf("validate")+1));case"sfx":return(await Promise.resolve().then(()=>(sV(),nV))).runSfx(process.argv.slice(process.argv.indexOf("sfx")+1),{cwd:process.cwd(),stdout:r=>process.stdout.write(r),stderr:r=>process.stderr.write(r)});default:return process.stderr.write(`pix3: unknown command "${e}".
497
-
498
- ${t_}`),1}};Ule().then(t=>{t>=0&&(process.exitCode=t)},t=>{process.stderr.write(`pix3: ${t instanceof Error?t.message:String(t)}
627
+ AGENTS.md / CLAUDE.md and .claude/skills/ tell the agent how, \`npm run check\` (pix3 check)
628
+ verifies its work.
629
+ `),0},Oy=async(t,e)=>{switch(t){case"new":return NT(Ty(e),e);case"check":return(await Promise.resolve().then(()=>(Ap(),Np))).runCheck(e,z);case"kit":return(await Promise.resolve().then(()=>(Bp(),qp))).runKitCli(e,z);case"editor":return(await Promise.resolve().then(()=>(Wm(),Km))).runEditorCli(e,z);case"__chrome-owner":return(await Promise.resolve().then(()=>(Wl(),vm))).runChromeOwner(e);case"agent-setup":return(await Promise.resolve().then(()=>(Jm(),Gm))).runAgentSetupCli(e,z);case"smoke":return(await Promise.resolve().then(()=>(_g(),vg))).runSmokeCli(e,z);case"tree":return(await Promise.resolve().then(()=>(Wg(),Kg))).runTreeCli(e,z);case"validate":return(await Promise.resolve().then(()=>(Va(),Wa))).runValidateCli(e,z);case"character-compile":return(await Promise.resolve().then(()=>(cy(),ly))).runCharacterCompileCli(e,z);case"gap":return(await Promise.resolve().then(()=>(by(),Sy))).runGapCli(e,z);case"sfx":return(await Promise.resolve().then(()=>(Cy(),ky))).runSfx(e,z)}},AT=async()=>{let t=process.argv.slice(2),e=Ty(t),r=e.positionals[0];if(e.flags.has("version"))return process.stdout.write(`${F}
630
+ `),0;let n=e.flags.get("help"),s=r==="help"?e.positionals[1]:r===void 0&&typeof n=="string"?n:void 0;return r==="help"||r===void 0&&n!==void 0?s===void 0?(process.stdout.write(Wr),0):ba(s)?Oy(s,["--help"]):(process.stderr.write(`pix3: unknown command "${s}".
631
+
632
+ ${Wr}`),1):r?!ba(r)&&r!=="__chrome-owner"?(process.stderr.write(`pix3: unknown command "${r}".
633
+
634
+ ${Wr}`),1):Oy(r,t.slice(t.indexOf(r)+1)):(process.stdout.write(Wr),1)};AT().then(t=>{t>=0&&(process.exitCode=t)},t=>{process.stderr.write(`pix3: ${t instanceof Error?t.message:String(t)}
499
635
  `),process.exitCode=1});