bailian-cli-core 2.10.2 → 2.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import{createRequire as e}from"node:module";import{appendFileSync as t,closeSync as n,createReadStream as r,createWriteStream as i,existsSync as a,mkdirSync as o,openSync as s,readFileSync as c,renameSync as l,rmSync as u,statSync as d,unlinkSync as f,writeFileSync as p}from"fs";import{homedir as m,tmpdir as h}from"os";import{basename as g,extname as _,join as v}from"path";import{parse as y,stringify as ee}from"yaml";import{Dispatcher as b,fetch as te,getGlobalDispatcher as ne,setGlobalDispatcher as re}from"undici";import{createHash as ie,createHmac as ae,randomBytes as oe,randomUUID as se}from"crypto";import{Readable as ce}from"stream";import{createInterface as le}from"readline";import{pipeline as ue}from"stream/promises";import*as de from"yauzl";import{copyFileSync as fe,cpSync as pe,createReadStream as me,createWriteStream as he,existsSync as x,lstatSync as ge,mkdirSync as _e,readFileSync as ve,readdirSync as ye,readlinkSync as S,realpathSync as C,renameSync as be,rmSync as xe,statSync as Se,symlinkSync as Ce,writeFileSync as we}from"node:fs";import{isIP as Te}from"node:net";import{Readable as Ee}from"node:stream";import{basename as De,dirname as Oe,isAbsolute as ke,join as w,relative as Ae,resolve as je,sep as Me}from"node:path";import{parse as Ne}from"csv-parse";import{stringify as Pe}from"csv-stringify/sync";import{link as Fe,mkdir as Ie,open as Le,readFile as Re,rename as ze,unlink as Be}from"node:fs/promises";import{createHash as Ve,randomUUID as He}from"node:crypto";import{setTimeout as Ue}from"node:timers/promises";import{createInterface as We}from"node:readline/promises";import{homedir as Ge}from"node:os";import{pipeline as Ke}from"node:stream/promises";import{createBrotliDecompress as qe}from"node:zlib";import Je from"tar-stream";var Ye=Object.create,Xe=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Qe=Object.getOwnPropertyNames,$e=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty,T=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),tt=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Qe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!et.call(e,s)&&s!==n&&Xe(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Ze(t,s))||r.enumerable});return e},nt=(e,t,n)=>(n=e==null?{}:Ye($e(e)),tt(t||!e||!e.__esModule||!et.call(e,`default`)?Xe(n,`default`,{value:e,enumerable:!0}):n,e)),rt=/* @__PURE__ */ e(import.meta.url);const it=/(?:authorization|cookie|apikey|accesskey(?:id)?|privatekey|credentials?|token|password|secret)$/i;function at(e,t=/* @__PURE__ */ new Set,n=0){if(typeof e==`bigint`)return e.toString();if(typeof e==`function`)return`[Function]`;if(typeof e!=`object`||!e)return e;if(t.has(e))return`[Circular]`;if(n>=8)return`[Truncated]`;t.add(e);try{let r=Object.getOwnPropertyDescriptors(e),i=e=>{if(e)return`value`in e?at(e.value,t,n+1):`[Accessor]`};if(Array.isArray(e)){let e=r.length?.value;return Array.from({length:e},(e,t)=>i(r[String(t)]))}return Object.fromEntries(Object.entries(r).filter(([,e])=>e.enumerable).map(([e,t])=>[e,it.test(e.replaceAll(/[-_]/g,``))?`[REDACTED]`:i(t)]))}catch{return`[Unserializable]`}finally{t.delete(e)}}const E={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONFIRMATION_REQUIRED:7,CONTENT_FILTER:10,INTERRUPTED:130};var D=class extends Error{exitCode;hint;api;rawResponse;constructor(e,t=E.GENERAL,n,r){super(e,r?.cause===void 0?void 0:{cause:r.cause}),this.name=`BailianError`,this.exitCode=t,this.hint=n,this.api=r?.api,this.rawResponse=r?.rawResponse}toJSON(){let e=st(this.cause);return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{},...this.api?.httpStatus===void 0?{}:{http_status:this.api.httpStatus},...this.api?.apiCode?{api_code:this.api.apiCode}:{},...this.api?.requestId?{request_id:this.api.requestId}:{},...e?{cause:e}:{}}}}},ot=class extends D{constructor(e,t){super(e,E.USAGE,t),this.name=`UsageError`}};function st(e){if(e!=null){if(e instanceof Error){let t={message:e.message},n=e.code;return n&&(t.code=n),t}if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return{message:String(e)};try{return{message:JSON.stringify(at(e))}}catch{return}}}var ct=class extends D{reason;constructor(e,t,n,r){super(t,E.AUTH,n,r),this.reason=e}};function lt(e,t,n){let r=t.error?.message||t.message||`HTTP ${e}`,i=t.error?.type??t.error?.code??t.code,a=typeof i==`string`?i:typeof i==`number`?String(i):void 0;return new D(r,E.GENERAL,void 0,{api:{httpStatus:e,apiCode:a,requestId:t.request_id??t.requestID}})}function ut(e){let t=e.trim(),n;try{n=new URL(t)}catch{throw dt(e)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw dt(e);return n.origin}function dt(e){return new D(`Invalid model base URL "${e}".`,E.USAGE,`Use an absolute http(s) URL.`)}const ft={cn:`https://dashscope.aliyuncs.com`,us:`https://dashscope-us.aliyuncs.com`,intl:`https://dashscope-intl.aliyuncs.com`},pt={cn:`https://help.aliyun.com/zh/model-studio`,us:`https://help.aliyun.com/zh/model-studio`,intl:`https://help.aliyun.com/zh/model-studio`},mt=`https://bailian.cn-beijing.aliyuncs.com`,ht=[`en-US`,`zh-CN`],gt=`en-US`,_t=[`language`,`api_key`,`access_token`,`access_key_id`,`access_key_secret`,`security_token`,`base_url`,`output`,`output_dir`,`timeout`,`watermark`,`default_text_model`,`default_video_model`,`default_image_to_video_model`,`default_reference_to_video_model`,`default_image_model`,`default_speech_model`,`default_speech_recognition_model`,`default_omni_model`,`api_key_capabilities`,`workspace_id`,`console_site`,`console_region`,`console_switch_agent`,`telemetry`],vt=/* @__PURE__ */ new Set([`text`,`json`]),yt=/* @__PURE__ */ new Set([`domestic`,`international`]),bt=/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;function xt(e){return bt.test(e)}function St(e){if(e===void 0)return;if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)return[];let e=n.trim();if(!xt(e))return[];t.includes(e)||t.push(e)}return t}function Ct(e){try{return ut(e)}catch{return}}function wt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t=e,n={};if(typeof t.language==`string`&&ht.includes(t.language)&&(n.language=t.language),typeof t.api_key==`string`&&(n.api_key=t.api_key),typeof t.access_token==`string`&&t.access_token.length>0?n.access_token=t.access_token:typeof t.accessToken==`string`&&t.accessToken.length>0&&(n.access_token=t.accessToken),typeof t.access_key_id==`string`&&t.access_key_id.length>0?n.access_key_id=t.access_key_id:typeof t.openapi_access_key_id==`string`&&t.openapi_access_key_id.length>0&&(n.access_key_id=t.openapi_access_key_id),typeof t.access_key_secret==`string`&&t.access_key_secret.length>0?n.access_key_secret=t.access_key_secret:typeof t.openapi_access_key_secret==`string`&&t.openapi_access_key_secret.length>0&&(n.access_key_secret=t.openapi_access_key_secret),typeof t.security_token==`string`&&t.security_token.length>0&&(n.security_token=t.security_token),typeof t.base_url==`string`){let e=Ct(t.base_url);e&&(n.base_url=e)}typeof t.output==`string`&&vt.has(t.output)&&(n.output=t.output),typeof t.output_dir==`string`&&t.output_dir.length>0&&(n.output_dir=t.output_dir),typeof t.timeout==`number`&&t.timeout>0&&(n.timeout=t.timeout),typeof t.watermark==`boolean`&&(n.watermark=t.watermark),typeof t.default_text_model==`string`&&t.default_text_model.length>0&&(n.default_text_model=t.default_text_model),typeof t.default_video_model==`string`&&t.default_video_model.length>0&&(n.default_video_model=t.default_video_model),typeof t.default_image_to_video_model==`string`&&t.default_image_to_video_model.length>0&&(n.default_image_to_video_model=t.default_image_to_video_model),typeof t.default_reference_to_video_model==`string`&&t.default_reference_to_video_model.length>0&&(n.default_reference_to_video_model=t.default_reference_to_video_model),typeof t.default_image_model==`string`&&t.default_image_model.length>0&&(n.default_image_model=t.default_image_model),typeof t.default_speech_model==`string`&&t.default_speech_model.length>0&&(n.default_speech_model=t.default_speech_model),typeof t.default_speech_recognition_model==`string`&&t.default_speech_recognition_model.length>0&&(n.default_speech_recognition_model=t.default_speech_recognition_model),typeof t.default_omni_model==`string`&&t.default_omni_model.length>0&&(n.default_omni_model=t.default_omni_model);let r=St(t.api_key_capabilities);return r!==void 0&&(n.api_key_capabilities=r),typeof t.workspace_id==`string`&&t.workspace_id.length>0&&(n.workspace_id=t.workspace_id),typeof t.console_site==`string`&&yt.has(t.console_site)&&(n.console_site=t.console_site),typeof t.console_region==`string`&&t.console_region.length>0&&(n.console_region=t.console_region),typeof t.console_switch_agent==`number`&&t.console_switch_agent>0&&(n.console_switch_agent=t.console_switch_agent),typeof t.telemetry==`boolean`&&(n.telemetry=t.telemetry),n}function Tt(e){if(e.flags.apiKey)return`flag`;if(e.env.DASHSCOPE_API_KEY?.trim())return`env`;if(e.file.api_key)return`config`}function Et(e){if(e.flags.baseUrl)return`flag`;if(e.env.DASHSCOPE_BASE_URL?.trim())return`env`;if(e.file.base_url)return`config`}function Dt(e){return{apiKeySource:Tt(e),baseUrlSource:Et(e)}}function Ot(e){let{apiKeySource:t,baseUrlSource:n}=e;return!!(t&&n&&t!==n)}function kt(e,t=ft.cn){let n=e.flags.baseUrl||e.env.DASHSCOPE_BASE_URL||e.file.base_url;return{baseUrl:ut(n||t),baseUrlIsDefault:!n}}function At(e,t=ft.cn){return kt(e,t).baseUrl}function jt(e){let t=At(e);if(e.flags.apiKey)return{token:e.flags.apiKey,baseUrl:t,source:`flag`};let n=e.env.DASHSCOPE_API_KEY?.trim();if(n)return{token:n,baseUrl:t,source:`env`};if(e.file.api_key)return{token:e.file.api_key,baseUrl:t,source:`config`};throw new ct(`missing-api-key`,`No API key found.`,`Set DASHSCOPE_API_KEY or pass --api-key.`)}function Mt(e){let t=e.file.access_token?.trim();if(!t)throw new ct(`missing-console-token`,`No console access token found.`);return{token:t,region:e.flags.consoleRegion||e.file.console_region||`cn-beijing`,site:e.flags.consoleSite||e.file.console_site||`domestic`,switchAgent:e.flags.consoleSwitchAgent||e.file.console_switch_agent||void 0,source:`config`}}function Nt(e){let t=Pt(`flag`,e.flags.accessKeyId,e.flags.accessKeySecret,e.flags.accessKeyId!==void 0||e.flags.accessKeySecret!==void 0,e.flags.securityToken);if(t)return t;let n=Pt(`env`,e.env.BAILIAN_ACCESS_KEY_ID,e.env.BAILIAN_ACCESS_KEY_SECRET,!!(Ft(e.env.BAILIAN_ACCESS_KEY_ID)||Ft(e.env.BAILIAN_ACCESS_KEY_SECRET)),e.env.BAILIAN_SECURITY_TOKEN,`BAILIAN`);if(n)return n;let r=Pt(`config`,e.file.access_key_id,e.file.access_key_secret,!!(e.file.access_key_id||e.file.access_key_secret),e.file.security_token);if(r)return r;let i=Pt(`env`,e.env.ALIBABA_CLOUD_ACCESS_KEY_ID,e.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET,!!(Ft(e.env.ALIBABA_CLOUD_ACCESS_KEY_ID)||Ft(e.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET)),e.env.ALIBABA_CLOUD_SECURITY_TOKEN);if(i)return i;throw new ct(`missing-openapi-pair`,`No OpenAPI AK/SK credentials found.`,`Set BAILIAN_ACCESS_KEY_ID and BAILIAN_ACCESS_KEY_SECRET (or ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET), or pass --access-key-id and --access-key-secret.`)}function Pt(e,t,n,r,i,a=`ALIBABA_CLOUD`){if(!r)return;let o=Ft(t),s=Ft(n);if(!o||!s)throw new ct(`incomplete-openapi-${e}`,`Incomplete OpenAPI AK/SK credentials found.`,It(e,a));return{accessKeyId:o,accessKeySecret:s,securityToken:Ft(i),source:e}}function Ft(e){return e?.trim()||void 0}function It(e,t){return e===`flag`?`Pass both --access-key-id and --access-key-secret, or remove the partial flags to use env/config credentials.`:e===`env`?`Set both ${t}_ACCESS_KEY_ID and ${t}_ACCESS_KEY_SECRET, or unset the partial env vars.`:`Save a complete AccessKey ID and secret pair in the selected configuration.`}function Lt(e){let t={};try{t.apiKey=jt(e)}catch{}try{t.console=Mt(e)}catch{}try{t.openapi=Nt(e)}catch{}return t}function Rt(){return process.env.BAILIAN_CONFIG_DIR?process.env.BAILIAN_CONFIG_DIR:v(m(),`.bailian`)}function zt(){return v(Rt(),`config.json`)}function Bt(){return v(Rt(),`credentials.json`)}async function Vt(){let e=Rt(),t=await import(`fs/promises`);await t.mkdir(e,{recursive:!0,mode:448});try{await t.chmod(e,448)}catch{}}function Ht(e){return ee(e).replace(/\n$/,``)}function Ut(e){return JSON.stringify(e,null,2)}function Wt(e,t,n){return JSON.stringify({error:{code:e,message:t,...n?{hint:n}:{}}},null,2)}function Gt(e){return e===`json`||e===`text`?e:`text`}function Kt(e,t){switch(t){case`json`:return Ut(e);case`text`:return Ht(e)}}const qt={"en-US":`Timeout must be a positive finite number.`,"zh-CN":`请求超时必须是一个有限的正数。`};function Jt(e){if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return qt}const Yt=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/,Xt=`active_config`;function Zt(e){return!(!e||typeof e!=`object`||Array.isArray(e))}function Qt(e){if(e!==void 0&&e!==``&&e!=="default"){if(typeof e!=`string`||!Yt.test(e))throw new D(`Invalid config name "${typeof e==`string`?e:JSON.stringify(e)}".`,E.USAGE,`Use letters, numbers, '-' or '_', starting with a letter or number.`);if(_t.includes(e)||e===Xt)throw new D(`Invalid config name "${e}". It conflicts with a config key.`,E.USAGE);return e}}function $t(e){let t=zt();if(!a(t))return{};try{let e=JSON.parse(c(t,`utf-8`));return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}catch(t){let n=t;return(n instanceof SyntaxError||n.message.includes(`JSON`))&&e?.({code:`CONFIG_CORRUPTED`,message:{"en-US":`Config file is corrupted; using defaults.`,"zh-CN":`配置文件已损坏,将使用默认配置。`}}),{}}}function en(e,t){let n=Qt(e[Xt]);if(n&&t&&!Zt(e[n]))throw new D(`Active config "${n}" does not exist.`,E.USAGE,`Use --config default to select the default config, then activate an existing profile.`);return n}function tn(e,t){if(!t)return e;let n=e[t];return Zt(n)?n:{}}function nn(e){return wt(tn($t(),e))}async function rn(e,t,n={}){let r=$t();if(t)r[t]=e;else{for(let e of Object.keys(r))_t.includes(e)&&delete r[e];Object.assign(r,e)}n.activate&&(r[Xt]=t??`default`),await an(r)}async function an(e){await Vt();let t=zt(),n=t+`.tmp`;p(n,JSON.stringify(e,null,2)+`
2
- `,{mode:384}),l(n,t)}function on(){let e=$t(),t={};for(let[n,r]of Object.entries(e))_t.includes(n)||n===Xt||Zt(r)&&(t[n]=wt(r));return{default:wt(e),named:t,active:en(e,!0)??`default`}}function sn(e,t){let n=Qt(t);if(n&&!Zt(e[n]))throw new D(`Config "${n}" does not exist.`,E.USAGE,`Create or log in to the profile before activating it.`);return n??`default`}function cn(e){return sn($t(),e)}async function ln(e){let t=$t(),n=sn(t,e);return t[Xt]=n,await an(t),n}async function un(e){let t=Qt(e);if(!t)throw new D(`Cannot delete the default profile.`,E.USAGE);let n=$t();return Zt(n[t])?(delete n[t],en(n,!1)===t&&(n[Xt]=`default`),await an(n),!0):!1}function dn(e,t){if(e.flags.apiKey||e.flags.baseUrl||e.env.DASHSCOPE_API_KEY?.trim()||e.env.DASHSCOPE_BASE_URL||!e.configName)return{sources:e};let n=e.file.api_key_capabilities;return n===void 0||n.includes(t)?{sources:e}:{sources:{...e,file:nn(),configName:void 0},fallbackFrom:e.configName}}function fn(e,t){let n=$t(t),r=e.config!==void 0,i=en(n,!r),a=r?Qt(e.config):i;return{flags:e,file:wt(tn(n,a)),env:process.env,configName:a,configPath:zt()}}function pn({flags:e,env:t,file:n={}}){let r=e.output||t.DASHSCOPE_OUTPUT||n.output;return{output:Gt(r),outputExplicit:!!r,outputSource:e.output?`flag`:t.DASHSCOPE_OUTPUT?`env`:n.output?`file`:`default`,quiet:e.quiet||t.DASHSCOPE_QUIET===`1`,verbose:e.verbose||t.DASHSCOPE_VERBOSE===`1`}}function mn(e){return e.flags.config===void 0?e.configName:e.configName??`default`}function hn(e){let{flags:t,file:n,env:r}=e,i=r.DASHSCOPE_TIMEOUT?Number(r.DASHSCOPE_TIMEOUT):void 0,a=Jt(i)===void 0?i:void 0,o=t.timeout??a??n.timeout??300,s=Jt(o);if(s)throw new D(s[`en-US`],E.USAGE);return{configPath:e.configPath??zt(),configName:e.configName,recoveryConfigName:mn(e),...pn(e),outputDir:n.output_dir||void 0,timeout:o,watermark:n.watermark??!0,defaultTextModel:n.default_text_model,defaultVideoModel:n.default_video_model,defaultImageToVideoModel:n.default_image_to_video_model,defaultReferenceToVideoModel:n.default_reference_to_video_model,defaultImageModel:n.default_image_model,defaultSpeechModel:n.default_speech_model,defaultSpeechRecognitionModel:n.default_speech_recognition_model,defaultOmniModel:n.default_omni_model,workspaceId:t.workspaceId||r.BAILIAN_WORKSPACE_ID||n.workspace_id||void 0,consoleRegion:t.consoleRegion||n.console_region||void 0,consoleSite:t.consoleSite||n.console_site||void 0,consoleSwitchAgent:t.consoleSwitchAgent||n.console_switch_agent||void 0,dryRun:t.dryRun||!1,telemetry:r.DO_NOT_TRACK===`1`?!1:n.telemetry??!0}}const gn={"token-plan":{baseUrl:`https://token-plan.cn-beijing.maas.aliyuncs.com`,defaultTextModel:`qwen3.8-max`,defaultVideoModel:`happyhorse-1.1-t2v`,defaultImageToVideoModel:`happyhorse-1.1-i2v`,defaultReferenceToVideoModel:`happyhorse-1.1-r2v`,defaultImageModel:`wan2.7-image`,defaultSpeechModel:`qwen-audio-3.0-tts-plus`,defaultSpeechRecognitionModel:`qwen-audio-3.0-asr-flash`,apiKeyCapabilities:[`text.chat`,`vision.describe`,`image.generate`,`image.edit`,`speech.recognize`,`speech.synthesize`,`video.generate`,`video.ref`,`video.task.get`,`video.download`]}};function _n(e){return e?gn[e]:void 0}function vn(e){let t=e.trim();return t.startsWith(`sk-sp-`)?`token-plan`:t.startsWith(`sk-`)?`ordinary`:`unknown`}function yn(e,t,n){if(n)return t;let r=vn(e);if(r===`token-plan`)return`token-plan`;if(r!==`ordinary`||t!==`token-plan`)return t}const bn={console:[`access_token`],openapi:[`access_key_id`,`access_key_secret`,`security_token`],all:[`api_key`,`base_url`,`access_token`,`access_key_id`,`access_key_secret`,`security_token`]};function xn(e){let t=e.configName,n=e.flags.config!==void 0;return{describe:()=>Lt({...e,file:nn(t)}),stored(){let e=nn(t);return{apiKey:!!e.api_key,console:!!e.access_token,openapi:!!(e.access_key_id||e.access_key_secret||e.security_token),baseUrl:e.base_url,apiKeyCapabilities:e.api_key_capabilities}},resolveBaseUrl:t=>At(e,t),async login(e){let r=e.api_key?yn(e.api_key,t,n):t,i=n||r!==t,a=nn(r);for(let[t,n]of Object.entries(e))if(n!==void 0){if(t===`api_key_capabilities`&&Array.isArray(n)){let e=Array.isArray(a[t])?a[t]:[];a[t]=[.../* @__PURE__ */ new Set([...e,...n])]}else a[t]=t===`base_url`?ut(String(n)):n}await rn(a,r,{activate:i})},async logout(e){let n=nn(t),r=bn[e];if(!r.some(e=>n[e]!==void 0))return!1;for(let e of r)delete n[e];return await rn(n,t),!0},get path(){return e.configPath??zt()}}}function Sn(e){try{let t=new URL(e);t.username=``,t.password=``;for(let e of t.searchParams.keys())t.searchParams.set(e,`[REDACTED]`);return t.hash=``,t.toString()}catch{return`[Invalid URL]`}}function Cn(e,t,n,r){e.debug?.({message:{"en-US":`HTTP request`,"zh-CN":`HTTP 请求`},details:{method:t,url:Sn(n),...r}})}function wn(e,t){e.debug?.({message:{"en-US":`HTTP response`,"zh-CN":`HTTP 响应`},details:{status:t.status,status_text:t.statusText,request_id:t.headers.get(`x-request-id`)??void 0}})}const Tn=process.versions.bun?void 0:ne();globalThis.Request,Tn&&ne()!==Tn&&re(Tn);const En={async fetch(e,t){return process.versions.bun?globalThis.fetch(e,t):te(e,t)}},Dn={"cn-beijing":{domestic:{csGateway:`bailian-cs.console.aliyun.com`,action:`BroadScopeAspnGateway`},international:{csGateway:`bailian-cs.console.alibabacloud.com`,action:`BroadScopeAspnGateway`}},"ap-southeast-1":{domestic:{csGateway:`modelstudio-cs.console.aliyun.com`,action:`IntlBroadScopeAspnGateway`},international:{csGateway:`bailian-singapore-cs.alibabacloud.com`,action:`IntlBroadScopeAspnGateway`}}};function On(e,t){return Dn[e]?.[t]??Dn[`cn-beijing`][t]}function kn(e){let t=e.consoleRegion??`cn-beijing`,n=e.consoleSite??`domestic`,r=e.consoleSwitchAgent;return r==null?{consoleRegion:t,consoleSite:n}:{consoleRegion:t,consoleSite:n,consoleSwitchAgent:r}}function An(e,t={}){let n=kn(e);return(r,i)=>Mn({region:n.consoleRegion,site:n.consoleSite,switchAgent:n.consoleSwitchAgent},e.timeout,{api:r,data:i},t)}function jn(e,t,n){return JSON.stringify({Api:e,V:`1.0`,Data:{...t,cornerstoneParam:{protocol:`V2`,console:`ONE_CONSOLE`,productCode:`p_efm`,switchUserType:3,consoleSite:`BAILIAN_ALIYUN`,...n==null?{}:{switchAgent:n},...typeof t.cornerstoneParam==`object`&&t.cornerstoneParam!==null?t.cornerstoneParam:{}}}})}async function Mn(e,t,{api:n,data:r},i={}){let a=On(e.region,e.site),o=`https://${a.csGateway}`,s=a.action,c=jn(n,r,e.switchAgent),l=new URLSearchParams({params:c,region:e.region}),u=t*1e3,d={Accept:`*/*`,"Content-Type":`application/x-www-form-urlencoded`};e.token&&(d.Authorization=`Bearer ${e.token}`);let f=`${o}/cli/api.json?action=${s}&product=sfm_bailian&api=${encodeURIComponent(n)}`;Cn(i,`POST`,f,{api:n,region:e.region});let p=await En.fetch(f,{method:`POST`,headers:d,body:l.toString(),signal:AbortSignal.timeout(u)});if(wn(i,p),!p.ok){let e=await p.text().catch(()=>``);throw new D(`Console CLI gateway failed: HTTP ${p.status} ${p.statusText}`,E.GENERAL,e.slice(0,500))}let m=await p.json(),h=m.data;if(h?.success===!1&&h.errorCode){let e=JSON.stringify(m),t=h.errorCode,n=typeof t==`string`?t:JSON.stringify(t);if(n.includes(`NotLogined`))throw new ct(`expired-console-session`,`Console session is not logged in or has expired.`,i.recoveryHint,{rawResponse:e});let r=typeof h.errorMsg==`string`&&h.errorMsg?h.errorMsg:typeof h.message==`string`&&h.message?h.message:n,a=[m.requestId,m.request_id,h.requestId,h.request_id].find(e=>typeof e==`string`&&e.length>0);throw new D(`${r} (HTTP ${p.status}; code=${n})`,E.GENERAL,void 0,{api:{httpStatus:p.status,apiCode:n,requestId:a},rawResponse:e})}return m}const Nn=`bailian-cli`,Pn=`bailian-cli-call`,Fn=`BailianCLI`,In=`X-Dashscope-Service`;function Ln(e){return JSON.stringify({channel:Nn,tags:{t1:`public`,t2:e.binName,t3:e.version}})}function Rn(e,t=Nn){return{"x-dashscope-source-config":Ln(e),"x-dashscope-openapisource":Fn,[In]:t}}const zn=e=>(t,n)=>e({...t,headersTimeout:0,bodyTimeout:0},n);function Bn(e){return typeof e!=`object`||!e||e instanceof FormData?!1:JSON.stringify(e).includes(`oss://`)}async function Vn(e,t){let n=Un((t.timeout??e.settings.timeout)*1e3,t.signal);try{return Wn(await Hn(e,t,n.signal),n)}catch(e){throw n.cleanup(),n.signal.aborted?n.signal.reason:e}}async function Hn(e,t,n){let r=typeof FormData<`u`&&t.body instanceof FormData,i={"User-Agent":`${e.identity.clientName}/${e.identity.version}`,...Rn(e.identity),...t.headers};!r&&!i[`Content-Type`]&&(i[`Content-Type`]=`application/json`),t.async&&(i[`X-DashScope-Async`]=`enable`),Bn(t.body)&&(i[`X-DashScope-OssResourceResolve`]=`enable`),Cn(e,t.method??`GET`,t.url);let a={method:t.method??`GET`,headers:i,body:t.body?r?t.body:JSON.stringify(t.body):void 0,signal:n,...process.versions.bun?{timeout:!1}:{dispatcher:b.prototype.compose.call(ne(),zn)}},o=await En.fetch(t.url,a);if(wn(e,o),!o.ok){let e=await o.text(),n;try{let t=JSON.parse(e);n=typeof t==`object`&&t?t:{message:e}}catch{n={message:e}}n.request_id??=o.headers.get(`x-request-id`)??void 0;let r=lt(o.status,n,t.url);throw new D(r.message,r.exitCode,r.hint,{api:r.api,rawResponse:e})}return o}function Un(e,t){let n=new AbortController,r,i=!1,a=t=>{i||(clearTimeout(r),r=setTimeout(()=>n.abort(t),e))},o=()=>n.abort(t?.reason),s=()=>{i=!0,clearTimeout(r),t?.removeEventListener(`abort`,o),n.signal.removeEventListener(`abort`,s)};return n.signal.addEventListener(`abort`,s,{once:!0}),t?.aborted?o():(t?.addEventListener(`abort`,o,{once:!0}),a()),{signal:n.signal,cleanup:s,abort:e=>n.abort(e),pauseTimeout:()=>clearTimeout(r),resetIdleTimeout:()=>a(new D(`Response body idle timeout: no data received for ${e/1e3}s.`,E.TIMEOUT,`Increase --timeout to allow a longer interval between response chunks.`))}}function Wn(e,t){if(!e.body)return t.cleanup(),e;t.pauseTimeout();let n=e.body.getReader(),{signal:r}=t,i=!1,a,o=()=>{i=!0,r.removeEventListener(`abort`,a),t.cleanup()},s=e=>n.cancel(e).finally(()=>n.releaseLock()),c=new ReadableStream({start(e){a=()=>{i||(o(),e.error(r.reason),s(r.reason).catch(()=>{}))},r.addEventListener(`abort`,a,{once:!0}),r.aborted&&a()},async pull(e){try{t.resetIdleTimeout();let r=await n.read();if(t.pauseTimeout(),i)return;r.done?(o(),n.releaseLock(),e.close()):e.enqueue(r.value)}catch(t){if(i)return;o(),n.releaseLock(),e.error(r.aborted?r.reason:t)}},cancel(e){return o(),t.abort(e),s(e).catch(()=>{})}},{highWaterMark:0}),l=new Response(c,{status:e.status,statusText:e.statusText,headers:e.headers});return Object.defineProperties(l,{url:{value:e.url},redirected:{value:e.redirected},type:{value:e.type}}),l}async function Gn(e,t){let n=Un((t.timeout??e.settings.timeout)*1e3,t.signal);try{let r=await Hn(e,t,n.signal),i;try{i=await r.json()}catch(e){if(n.signal.aborted)throw n.signal.reason;if(!(e instanceof SyntaxError))throw e;let t=r.headers.get(`content-type`)||``;throw new D(`API returned non-JSON response (${t||`unknown type`}). Server may be experiencing issues.\nAPI 返回了非 JSON 响应(${t||`未知类型`}),服务器可能出现问题。`,E.GENERAL)}if(typeof i==`object`&&i&&(i.code&&i.code!==`200`&&i.code!==200&&i.code!==`Success`||i.error)){let e=lt(r.status,{...i,request_id:i.request_id??i.requestID??r.headers.get(`x-request-id`)??void 0},t.url);throw new D(e.message,e.exitCode,e.hint,{api:e.api,rawResponse:JSON.stringify(i)})}return i}catch(e){throw n.signal.aborted?n.signal.reason:e}finally{n.cleanup()}}function Kn(e){let t=[];for(let[n,r]of Object.entries(e))if(r!==void 0&&r!==``){if(Array.isArray(r))for(let e=0;e<r.length;e++){let i=r[e];i!==``&&t.push([`${n}.${e+1}`,i])}else t.push([n,r])}return t.sort(([e],[t])=>e<t?-1:+(e>t)),t.map(([e,t])=>`${Jn(e)}=${Jn(String(t))}`).join(`&`)}function qn(e){let t=e.method??`POST`,n=(/* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/,`Z`),r=se(),i=Yn(e.body),a={host:e.host,"x-acs-action":e.action,"x-acs-version":e.version,"x-acs-date":n,"x-acs-signature-nonce":r,"x-acs-content-sha256":i,"content-type":`application/json`};e.securityToken&&(a[`x-acs-security-token`]=e.securityToken);let o=Object.keys(a).filter(e=>e===`host`||e===`content-type`||e.startsWith(`x-acs-`)).sort(),s=o.map(e=>`${e}:${a[e]}`).join(`
1
+ import{createRequire as e}from"node:module";import{appendFileSync as t,closeSync as n,createReadStream as r,createWriteStream as i,existsSync as a,mkdirSync as o,openSync as s,readFileSync as c,renameSync as l,rmSync as u,statSync as d,unlinkSync as f,writeFileSync as p}from"fs";import{homedir as m,tmpdir as h}from"os";import{basename as g,extname as _,join as v}from"path";import{parse as y,stringify as b}from"yaml";import{Dispatcher as x,fetch as ee,getGlobalDispatcher as te,setGlobalDispatcher as ne}from"undici";import{createHash as re,createHmac as ie,randomBytes as ae,randomUUID as oe}from"crypto";import{connect as se,isIP as ce}from"node:net";import{Readable as le}from"stream";import{createInterface as ue}from"readline";import{pipeline as de}from"stream/promises";import*as fe from"yauzl";import{closeSync as pe,copyFileSync as me,cpSync as he,createReadStream as ge,createWriteStream as _e,existsSync as S,lstatSync as ve,mkdirSync as C,openSync as w,readFileSync as ye,readdirSync as be,readlinkSync as xe,realpathSync as Se,renameSync as Ce,rmSync as we,statSync as Te,symlinkSync as Ee,unlinkSync as De,writeFileSync as Oe}from"node:fs";import{Readable as ke}from"node:stream";import{basename as Ae,dirname as je,isAbsolute as Me,join as T,relative as Ne,resolve as Pe,sep as Fe,win32 as Ie}from"node:path";import{parse as Le}from"csv-parse";import{stringify as Re}from"csv-stringify/sync";import{link as ze,mkdir as Be,open as Ve,readFile as He,rename as Ue,unlink as We}from"node:fs/promises";import{createHash as Ge,randomBytes as Ke,randomUUID as qe,timingSafeEqual as Je}from"node:crypto";import{setTimeout as Ye}from"node:timers/promises";import{lookup as Xe}from"node:dns/promises";import{createServer as Ze}from"node:http";import{spawn as Qe,spawnSync as $e}from"node:child_process";import{homedir as et}from"node:os";import{createInterface as tt}from"node:readline/promises";import{pipeline as nt}from"node:stream/promises";import{createBrotliDecompress as rt}from"node:zlib";import it from"tar-stream";var at=Object.create,ot=Object.defineProperty,st=Object.getOwnPropertyDescriptor,ct=Object.getOwnPropertyNames,lt=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty,E=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),dt=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=ct(t),a=0,o=i.length,s;a<o;a++)s=i[a],!ut.call(e,s)&&s!==n&&ot(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=st(t,s))||r.enumerable});return e},ft=(e,t,n)=>(n=e==null?{}:at(lt(e)),dt(t||!e||!e.__esModule||!ut.call(e,`default`)?ot(n,`default`,{value:e,enumerable:!0}):n,e)),pt=/* @__PURE__ */ e(import.meta.url);const mt=/(?:authorization|cookie|apikey|accesskey(?:id)?|privatekey|credentials?|token|password|secret)$/i;function ht(e,t=/* @__PURE__ */ new Set,n=0){if(typeof e==`bigint`)return e.toString();if(typeof e==`function`)return`[Function]`;if(typeof e!=`object`||!e)return e;if(t.has(e))return`[Circular]`;if(n>=8)return`[Truncated]`;t.add(e);try{let r=Object.getOwnPropertyDescriptors(e),i=e=>{if(e)return`value`in e?ht(e.value,t,n+1):`[Accessor]`};if(Array.isArray(e)){let e=r.length?.value;return Array.from({length:e},(e,t)=>i(r[String(t)]))}return Object.fromEntries(Object.entries(r).filter(([,e])=>e.enumerable).map(([e,t])=>[e,mt.test(e.replaceAll(/[-_]/g,``))?`[REDACTED]`:i(t)]))}catch{return`[Unserializable]`}finally{t.delete(e)}}const D={SUCCESS:0,GENERAL:1,USAGE:2,AUTH:3,QUOTA:4,TIMEOUT:5,NETWORK:6,CONFIRMATION_REQUIRED:7,CONTENT_FILTER:10,INTERRUPTED:130};var O=class extends Error{exitCode;hint;api;rawResponse;constructor(e,t=D.GENERAL,n,r){super(e,r?.cause===void 0?void 0:{cause:r.cause}),this.name=`BailianError`,this.exitCode=t,this.hint=n,this.api=r?.api,this.rawResponse=r?.rawResponse}toJSON(){let e=gt(this.cause);return{error:{code:this.exitCode,message:this.message,...this.hint?{hint:this.hint}:{},...this.api?.httpStatus===void 0?{}:{http_status:this.api.httpStatus},...this.api?.apiCode?{api_code:this.api.apiCode}:{},...this.api?.requestId?{request_id:this.api.requestId}:{},...e?{cause:e}:{}}}}},k=class extends O{constructor(e,t){super(e,D.USAGE,t),this.name=`UsageError`}};function gt(e){if(e!=null){if(e instanceof Error){let t={message:e.message},n=e.code;return n&&(t.code=n),t}if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return{message:String(e)};try{return{message:JSON.stringify(ht(e))}}catch{return}}}var _t=class extends O{reason;constructor(e,t,n,r){super(t,D.AUTH,n,r),this.reason=e}};function vt(e,t,n){let r=t.error?.message||t.message||`HTTP ${e}`,i=t.error?.type??t.error?.code??t.code,a=typeof i==`string`?i:typeof i==`number`?String(i):void 0;return new O(r,D.GENERAL,void 0,{api:{httpStatus:e,apiCode:a,requestId:t.request_id??t.requestID}})}function yt(e){let t=e.trim(),n;try{n=new URL(t)}catch{throw bt(e)}if(n.protocol!==`http:`&&n.protocol!==`https:`)throw bt(e);return n.origin}function bt(e){return new O(`Invalid model base URL "${e}".`,D.USAGE,`Use an absolute http(s) URL.`)}const xt={cn:`https://dashscope.aliyuncs.com`,us:`https://dashscope-us.aliyuncs.com`,intl:`https://dashscope-intl.aliyuncs.com`},St={cn:`https://help.aliyun.com/zh/model-studio`,us:`https://help.aliyun.com/zh/model-studio`,intl:`https://help.aliyun.com/zh/model-studio`},Ct=`https://bailian.cn-beijing.aliyuncs.com`,wt=[`en-US`,`zh-CN`],Tt=`en-US`,Et=[`language`,`api_key`,`access_token`,`access_key_id`,`access_key_secret`,`security_token`,`base_url`,`output`,`output_dir`,`timeout`,`watermark`,`default_text_model`,`default_video_model`,`default_image_to_video_model`,`default_reference_to_video_model`,`default_image_model`,`default_speech_model`,`default_speech_recognition_model`,`default_omni_model`,`api_key_capabilities`,`workspace_id`,`console_site`,`console_region`,`console_switch_agent`,`telemetry`],Dt=/* @__PURE__ */ new Set([`text`,`json`]),Ot=/* @__PURE__ */ new Set([`domestic`,`international`]),kt=/^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;function At(e){return kt.test(e)}function jt(e){if(e===void 0)return;if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)return[];let e=n.trim();if(!At(e))return[];t.includes(e)||t.push(e)}return t}function Mt(e){try{return yt(e)}catch{return}}function Nt(e){if(!e||typeof e!=`object`||Array.isArray(e))return{};let t=e,n={};if(typeof t.language==`string`&&wt.includes(t.language)&&(n.language=t.language),typeof t.api_key==`string`&&(n.api_key=t.api_key),typeof t.access_token==`string`&&t.access_token.length>0?n.access_token=t.access_token:typeof t.accessToken==`string`&&t.accessToken.length>0&&(n.access_token=t.accessToken),typeof t.access_key_id==`string`&&t.access_key_id.length>0?n.access_key_id=t.access_key_id:typeof t.openapi_access_key_id==`string`&&t.openapi_access_key_id.length>0&&(n.access_key_id=t.openapi_access_key_id),typeof t.access_key_secret==`string`&&t.access_key_secret.length>0?n.access_key_secret=t.access_key_secret:typeof t.openapi_access_key_secret==`string`&&t.openapi_access_key_secret.length>0&&(n.access_key_secret=t.openapi_access_key_secret),typeof t.security_token==`string`&&t.security_token.length>0&&(n.security_token=t.security_token),typeof t.base_url==`string`){let e=Mt(t.base_url);e&&(n.base_url=e)}typeof t.output==`string`&&Dt.has(t.output)&&(n.output=t.output),typeof t.output_dir==`string`&&t.output_dir.length>0&&(n.output_dir=t.output_dir),typeof t.timeout==`number`&&t.timeout>0&&(n.timeout=t.timeout),typeof t.watermark==`boolean`&&(n.watermark=t.watermark),typeof t.default_text_model==`string`&&t.default_text_model.length>0&&(n.default_text_model=t.default_text_model),typeof t.default_video_model==`string`&&t.default_video_model.length>0&&(n.default_video_model=t.default_video_model),typeof t.default_image_to_video_model==`string`&&t.default_image_to_video_model.length>0&&(n.default_image_to_video_model=t.default_image_to_video_model),typeof t.default_reference_to_video_model==`string`&&t.default_reference_to_video_model.length>0&&(n.default_reference_to_video_model=t.default_reference_to_video_model),typeof t.default_image_model==`string`&&t.default_image_model.length>0&&(n.default_image_model=t.default_image_model),typeof t.default_speech_model==`string`&&t.default_speech_model.length>0&&(n.default_speech_model=t.default_speech_model),typeof t.default_speech_recognition_model==`string`&&t.default_speech_recognition_model.length>0&&(n.default_speech_recognition_model=t.default_speech_recognition_model),typeof t.default_omni_model==`string`&&t.default_omni_model.length>0&&(n.default_omni_model=t.default_omni_model);let r=jt(t.api_key_capabilities);return r!==void 0&&(n.api_key_capabilities=r),typeof t.workspace_id==`string`&&t.workspace_id.length>0&&(n.workspace_id=t.workspace_id),typeof t.console_site==`string`&&Ot.has(t.console_site)&&(n.console_site=t.console_site),typeof t.console_region==`string`&&t.console_region.length>0&&(n.console_region=t.console_region),typeof t.console_switch_agent==`number`&&t.console_switch_agent>0&&(n.console_switch_agent=t.console_switch_agent),typeof t.telemetry==`boolean`&&(n.telemetry=t.telemetry),n}function Pt(e){if(e.flags.apiKey)return`flag`;if(e.env.DASHSCOPE_API_KEY?.trim())return`env`;if(e.file.api_key)return`config`}function Ft(e){if(e.flags.baseUrl)return`flag`;if(e.env.DASHSCOPE_BASE_URL?.trim())return`env`;if(e.file.base_url)return`config`}function It(e){return{apiKeySource:Pt(e),baseUrlSource:Ft(e)}}function Lt(e){let{apiKeySource:t,baseUrlSource:n}=e;return!!(t&&n&&t!==n)}function Rt(e,t=xt.cn){let n=e.flags.baseUrl||e.env.DASHSCOPE_BASE_URL||e.file.base_url;return{baseUrl:yt(n||t),baseUrlIsDefault:!n}}function zt(e,t=xt.cn){return Rt(e,t).baseUrl}function Bt(e){let t=zt(e);if(e.flags.apiKey)return{token:e.flags.apiKey,baseUrl:t,source:`flag`};let n=e.env.DASHSCOPE_API_KEY?.trim();if(n)return{token:n,baseUrl:t,source:`env`};if(e.file.api_key)return{token:e.file.api_key,baseUrl:t,source:`config`};throw new _t(`missing-api-key`,`No API key found.`,`Set DASHSCOPE_API_KEY or pass --api-key.`)}function Vt(e){let t=e.file.access_token?.trim();if(!t)throw new _t(`missing-console-token`,`No console access token found.`);return{token:t,region:e.flags.consoleRegion||e.file.console_region||`cn-beijing`,site:e.flags.consoleSite||e.file.console_site||`domestic`,switchAgent:e.flags.consoleSwitchAgent||e.file.console_switch_agent||void 0,source:`config`}}function Ht(e){let t=Ut(`flag`,e.flags.accessKeyId,e.flags.accessKeySecret,e.flags.accessKeyId!==void 0||e.flags.accessKeySecret!==void 0,e.flags.securityToken);if(t)return t;let n=Ut(`env`,e.env.BAILIAN_ACCESS_KEY_ID,e.env.BAILIAN_ACCESS_KEY_SECRET,!!(Wt(e.env.BAILIAN_ACCESS_KEY_ID)||Wt(e.env.BAILIAN_ACCESS_KEY_SECRET)),e.env.BAILIAN_SECURITY_TOKEN,`BAILIAN`);if(n)return n;let r=Ut(`config`,e.file.access_key_id,e.file.access_key_secret,!!(e.file.access_key_id||e.file.access_key_secret),e.file.security_token);if(r)return r;let i=Ut(`env`,e.env.ALIBABA_CLOUD_ACCESS_KEY_ID,e.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET,!!(Wt(e.env.ALIBABA_CLOUD_ACCESS_KEY_ID)||Wt(e.env.ALIBABA_CLOUD_ACCESS_KEY_SECRET)),e.env.ALIBABA_CLOUD_SECURITY_TOKEN);if(i)return i;throw new _t(`missing-openapi-pair`,`No OpenAPI AK/SK credentials found.`,`Set BAILIAN_ACCESS_KEY_ID and BAILIAN_ACCESS_KEY_SECRET (or ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET), or pass --access-key-id and --access-key-secret.`)}function Ut(e,t,n,r,i,a=`ALIBABA_CLOUD`){if(!r)return;let o=Wt(t),s=Wt(n);if(!o||!s)throw new _t(`incomplete-openapi-${e}`,`Incomplete OpenAPI AK/SK credentials found.`,Gt(e,a));return{accessKeyId:o,accessKeySecret:s,securityToken:Wt(i),source:e}}function Wt(e){return e?.trim()||void 0}function Gt(e,t){return e===`flag`?`Pass both --access-key-id and --access-key-secret, or remove the partial flags to use env/config credentials.`:e===`env`?`Set both ${t}_ACCESS_KEY_ID and ${t}_ACCESS_KEY_SECRET, or unset the partial env vars.`:`Save a complete AccessKey ID and secret pair in the selected configuration.`}function Kt(e){let t={};try{t.apiKey=Bt(e)}catch{}try{t.console=Vt(e)}catch{}try{t.openapi=Ht(e)}catch{}return t}function qt(){return process.env.BAILIAN_CONFIG_DIR?process.env.BAILIAN_CONFIG_DIR:v(m(),`.bailian`)}function Jt(){return v(qt(),`config.json`)}function Yt(){return v(qt(),`credentials.json`)}async function Xt(){let e=qt(),t=await import(`fs/promises`);await t.mkdir(e,{recursive:!0,mode:448});try{await t.chmod(e,448)}catch{}}function Zt(e){return b(e).replace(/\n$/,``)}function Qt(e){return JSON.stringify(e,null,2)}function $t(e,t,n){return JSON.stringify({error:{code:e,message:t,...n?{hint:n}:{}}},null,2)}function en(e){return e===`json`||e===`text`?e:`text`}function tn(e,t){switch(t){case`json`:return Qt(e);case`text`:return Zt(e)}}const nn={"en-US":`Timeout must be a positive finite number.`,"zh-CN":`请求超时必须是一个有限的正数。`};function rn(e){if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return nn}const an=/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/,on=`active_config`;function sn(e){return!(!e||typeof e!=`object`||Array.isArray(e))}function cn(e){if(e!==void 0&&e!==``&&e!=="default"){if(typeof e!=`string`||!an.test(e))throw new O(`Invalid config name "${typeof e==`string`?e:JSON.stringify(e)}".`,D.USAGE,`Use letters, numbers, '-' or '_', starting with a letter or number.`);if(Et.includes(e)||e===on)throw new O(`Invalid config name "${e}". It conflicts with a config key.`,D.USAGE);return e}}function ln(e){let t=Jt();if(!a(t))return{};try{let e=JSON.parse(c(t,`utf-8`));return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}catch(t){let n=t;return(n instanceof SyntaxError||n.message.includes(`JSON`))&&e?.({code:`CONFIG_CORRUPTED`,message:{"en-US":`Config file is corrupted; using defaults.`,"zh-CN":`配置文件已损坏,将使用默认配置。`}}),{}}}function un(e,t){let n=cn(e[on]);if(n&&t&&!sn(e[n]))throw new O(`Active config "${n}" does not exist.`,D.USAGE,`Use --config default to select the default config, then activate an existing profile.`);return n}function dn(e,t){if(!t)return e;let n=e[t];return sn(n)?n:{}}function fn(e){return Nt(dn(ln(),e))}async function pn(e,t,n={}){let r=ln();if(t)r[t]=e;else{for(let e of Object.keys(r))Et.includes(e)&&delete r[e];Object.assign(r,e)}n.activate&&(r[on]=t??`default`),await mn(r)}async function mn(e){await Xt();let t=Jt(),n=t+`.tmp`;p(n,JSON.stringify(e,null,2)+`
2
+ `,{mode:384}),l(n,t)}function hn(){let e=ln(),t={};for(let[n,r]of Object.entries(e))Et.includes(n)||n===on||sn(r)&&(t[n]=Nt(r));return{default:Nt(e),named:t,active:un(e,!0)??`default`}}function gn(e,t){let n=cn(t);if(n&&!sn(e[n]))throw new O(`Config "${n}" does not exist.`,D.USAGE,`Create or log in to the profile before activating it.`);return n??`default`}function _n(e){return gn(ln(),e)}async function vn(e){let t=ln(),n=gn(t,e);return t[on]=n,await mn(t),n}async function yn(e){let t=cn(e);if(!t)throw new O(`Cannot delete the default profile.`,D.USAGE);let n=ln();return sn(n[t])?(delete n[t],un(n,!1)===t&&(n[on]=`default`),await mn(n),!0):!1}function bn(e,t){if(e.flags.apiKey||e.flags.baseUrl||e.env.DASHSCOPE_API_KEY?.trim()||e.env.DASHSCOPE_BASE_URL||!e.configName)return{sources:e};let n=e.file.api_key_capabilities;return n===void 0||n.includes(t)?{sources:e}:{sources:{...e,file:fn(),configName:void 0},fallbackFrom:e.configName}}function xn(e,t){let n=ln(t),r=e.config!==void 0,i=un(n,!r),a=r?cn(e.config):i;return{flags:e,file:Nt(dn(n,a)),env:process.env,configName:a,configPath:Jt()}}function Sn({flags:e,env:t,file:n={}}){let r=e.output||t.DASHSCOPE_OUTPUT||n.output;return{output:en(r),outputExplicit:!!r,outputSource:e.output?`flag`:t.DASHSCOPE_OUTPUT?`env`:n.output?`file`:`default`,quiet:e.quiet||t.DASHSCOPE_QUIET===`1`,verbose:e.verbose||t.DASHSCOPE_VERBOSE===`1`}}function Cn(e){return e.flags.config===void 0?e.configName:e.configName??`default`}function wn(e){let{flags:t,file:n,env:r}=e,i=r.DASHSCOPE_TIMEOUT?Number(r.DASHSCOPE_TIMEOUT):void 0,a=rn(i)===void 0?i:void 0,o=t.timeout??a??n.timeout??300,s=rn(o);if(s)throw new O(s[`en-US`],D.USAGE);return{configPath:e.configPath??Jt(),configName:e.configName,recoveryConfigName:Cn(e),...Sn(e),outputDir:n.output_dir||void 0,timeout:o,watermark:n.watermark??!0,defaultTextModel:n.default_text_model,defaultVideoModel:n.default_video_model,defaultImageToVideoModel:n.default_image_to_video_model,defaultReferenceToVideoModel:n.default_reference_to_video_model,defaultImageModel:n.default_image_model,defaultSpeechModel:n.default_speech_model,defaultSpeechRecognitionModel:n.default_speech_recognition_model,defaultOmniModel:n.default_omni_model,workspaceId:t.workspaceId||r.BAILIAN_WORKSPACE_ID||n.workspace_id||void 0,consoleRegion:t.consoleRegion||n.console_region||void 0,consoleSite:t.consoleSite||n.console_site||void 0,consoleSwitchAgent:t.consoleSwitchAgent||n.console_switch_agent||void 0,dryRun:t.dryRun||!1,telemetry:r.DO_NOT_TRACK===`1`?!1:n.telemetry??!0}}const Tn={"token-plan":{baseUrl:`https://token-plan.cn-beijing.maas.aliyuncs.com`,defaultTextModel:`qwen3.8-max`,defaultVideoModel:`happyhorse-1.1-t2v`,defaultImageToVideoModel:`happyhorse-1.1-i2v`,defaultReferenceToVideoModel:`happyhorse-1.1-r2v`,defaultImageModel:`wan2.7-image`,defaultSpeechModel:`qwen-audio-3.0-tts-plus`,defaultSpeechRecognitionModel:`qwen-audio-3.0-asr-flash`,apiKeyCapabilities:[`text.chat`,`vision.describe`,`image.generate`,`image.edit`,`speech.recognize`,`speech.synthesize`,`video.generate`,`video.ref`,`video.task.get`,`video.download`]}};function En(e){return e?Tn[e]:void 0}function Dn(e){let t=e.trim();return t.startsWith(`sk-sp-`)?`token-plan`:t.startsWith(`sk-`)?`ordinary`:`unknown`}function On(e,t,n){if(n)return t;let r=Dn(e);if(r===`token-plan`)return`token-plan`;if(r!==`ordinary`||t!==`token-plan`)return t}const kn={console:[`access_token`],openapi:[`access_key_id`,`access_key_secret`,`security_token`],all:[`api_key`,`base_url`,`access_token`,`access_key_id`,`access_key_secret`,`security_token`]};function An(e){let t=e.configName,n=e.flags.config!==void 0;return{describe:()=>Kt({...e,file:fn(t)}),stored(){let e=fn(t);return{apiKey:!!e.api_key,console:!!e.access_token,openapi:!!(e.access_key_id||e.access_key_secret||e.security_token),baseUrl:e.base_url,apiKeyCapabilities:e.api_key_capabilities}},resolveBaseUrl:t=>zt(e,t),async login(e){let r=e.api_key?On(e.api_key,t,n):t,i=n||r!==t,a=fn(r);for(let[t,n]of Object.entries(e))if(n!==void 0){if(t===`api_key_capabilities`&&Array.isArray(n)){let e=Array.isArray(a[t])?a[t]:[];a[t]=[.../* @__PURE__ */ new Set([...e,...n])]}else a[t]=t===`base_url`?yt(String(n)):n}await pn(a,r,{activate:i})},async logout(e){let n=fn(t),r=kn[e];if(!r.some(e=>n[e]!==void 0))return!1;for(let e of r)delete n[e];return await pn(n,t),!0},get path(){return e.configPath??Jt()}}}function jn(e){try{let t=new URL(e);t.username=``,t.password=``;for(let e of t.searchParams.keys())t.searchParams.set(e,`[REDACTED]`);return t.hash=``,t.toString()}catch{return`[Invalid URL]`}}function Mn(e,t,n,r){e.debug?.({message:{"en-US":`HTTP request`,"zh-CN":`HTTP 请求`},details:{method:t,url:jn(n),...r}})}function Nn(e,t){e.debug?.({message:{"en-US":`HTTP response`,"zh-CN":`HTTP 响应`},details:{status:t.status,status_text:t.statusText,request_id:t.headers.get(`x-request-id`)??void 0}})}const Pn=process.versions.bun?void 0:te();globalThis.Request,Pn&&te()!==Pn&&ne(Pn);const Fn={async fetch(e,t){return process.versions.bun?globalThis.fetch(e,t):ee(e,t)}},In={"cn-beijing":{domestic:{csGateway:`bailian-cs.console.aliyun.com`,action:`BroadScopeAspnGateway`},international:{csGateway:`bailian-cs.console.alibabacloud.com`,action:`BroadScopeAspnGateway`}},"ap-southeast-1":{domestic:{csGateway:`modelstudio-cs.console.aliyun.com`,action:`IntlBroadScopeAspnGateway`},international:{csGateway:`bailian-singapore-cs.alibabacloud.com`,action:`IntlBroadScopeAspnGateway`}}};function Ln(e,t){return In[e]?.[t]??In[`cn-beijing`][t]}function Rn(e){let t=e.consoleRegion??`cn-beijing`,n=e.consoleSite??`domestic`,r=e.consoleSwitchAgent;return r==null?{consoleRegion:t,consoleSite:n}:{consoleRegion:t,consoleSite:n,consoleSwitchAgent:r}}function zn(e,t={}){let n=Rn(e);return(r,i)=>Hn({region:n.consoleRegion,site:n.consoleSite,switchAgent:n.consoleSwitchAgent},e.timeout,{api:r,data:i},t)}function Bn(e,t){return{protocol:`V2`,console:`ONE_CONSOLE`,productCode:`p_efm`,switchUserType:3,consoleSite:`BAILIAN_ALIYUN`,...t==null?{}:{switchAgent:t},...typeof e.cornerstoneParam==`object`&&e.cornerstoneParam!==null?e.cornerstoneParam:{}}}function Vn(e,t,n){return JSON.stringify({Api:e,V:`1.0`,Data:{...t,cornerstoneParam:Bn(t,n)}})}async function Hn(e,t,{api:n,data:r},i={}){let a=Ln(e.region,e.site),o=`https://${a.csGateway}`,s=a.action,c=Vn(n,r,e.switchAgent),l=new URLSearchParams({params:c,region:e.region}),u=t*1e3,d={Accept:`*/*`,"Content-Type":`application/x-www-form-urlencoded`};e.token&&(d.Authorization=`Bearer ${e.token}`);let f=`${o}/cli/api.json?action=${s}&product=sfm_bailian&api=${encodeURIComponent(n)}`;Mn(i,`POST`,f,{api:n,region:e.region});let p=await Fn.fetch(f,{method:`POST`,headers:d,body:l.toString(),signal:AbortSignal.timeout(u)});return Nn(i,p),Un(p,i)}async function Un(e,t){if(!e.ok){let t=await e.text().catch(()=>``);throw new O(`Console CLI gateway failed: HTTP ${e.status} ${e.statusText}`,D.GENERAL,t.slice(0,500))}let n=await e.json(),r=n.data;if(r?.success===!1&&r.errorCode){let i=JSON.stringify(n),a=r.errorCode,o=typeof a==`string`?a:JSON.stringify(a);if(o.includes(`NotLogined`))throw new _t(`expired-console-session`,`Console session is not logged in or has expired.`,t.recoveryHint,{rawResponse:i});let s=typeof r.errorMsg==`string`&&r.errorMsg?r.errorMsg:typeof r.message==`string`&&r.message?r.message:o,c=[n.requestId,n.request_id,r.requestId,r.request_id].find(e=>typeof e==`string`&&e.length>0);throw new O(`${s} (HTTP ${e.status}; code=${o})`,D.GENERAL,void 0,{api:{httpStatus:e.status,apiCode:o,requestId:c},rawResponse:i})}return n}const Wn=`bailian-cli`,Gn=`bailian-cli-call`,Kn=`BailianCLI`,qn=`X-Dashscope-Service`;function Jn(e){return JSON.stringify({channel:Wn,tags:{t1:`public`,t2:e.binName,t3:e.version}})}function Yn(e,t=Wn){return{"x-dashscope-source-config":Jn(e),"x-dashscope-openapisource":Kn,[qn]:t}}const Xn=e=>(t,n)=>e({...t,headersTimeout:0,bodyTimeout:0},n);function Zn(e){return typeof e!=`object`||!e||e instanceof FormData?!1:JSON.stringify(e).includes(`oss://`)}async function Qn(e,t){let n=er((t.timeout??e.settings.timeout)*1e3,t.signal);try{return tr(await $n(e,t,n.signal),n)}catch(e){throw n.cleanup(),n.signal.aborted?n.signal.reason:e}}async function $n(e,t,n){let r=typeof FormData<`u`&&t.body instanceof FormData,i={"User-Agent":`${e.identity.clientName}/${e.identity.version}`,...Yn(e.identity),...t.headers};!r&&!i[`Content-Type`]&&(i[`Content-Type`]=`application/json`),t.async&&(i[`X-DashScope-Async`]=`enable`),Zn(t.body)&&(i[`X-DashScope-OssResourceResolve`]=`enable`),Mn(e,t.method??`GET`,t.url);let a={method:t.method??`GET`,headers:i,body:t.body?r?t.body:JSON.stringify(t.body):void 0,signal:n,...process.versions.bun?{timeout:!1}:{dispatcher:x.prototype.compose.call(te(),Xn)}},o=await Fn.fetch(t.url,a);if(Nn(e,o),!o.ok){let e=await o.text(),n;try{let t=JSON.parse(e);n=typeof t==`object`&&t?t:{message:e}}catch{n={message:e}}n.request_id??=o.headers.get(`x-request-id`)??void 0;let r=vt(o.status,n,t.url);throw new O(r.message,r.exitCode,r.hint,{api:r.api,rawResponse:e})}return o}function er(e,t){let n=new AbortController,r,i=!1,a=t=>{i||(clearTimeout(r),r=setTimeout(()=>n.abort(t),e))},o=()=>n.abort(t?.reason),s=()=>{i=!0,clearTimeout(r),t?.removeEventListener(`abort`,o),n.signal.removeEventListener(`abort`,s)};return n.signal.addEventListener(`abort`,s,{once:!0}),t?.aborted?o():(t?.addEventListener(`abort`,o,{once:!0}),a()),{signal:n.signal,cleanup:s,abort:e=>n.abort(e),pauseTimeout:()=>clearTimeout(r),resetIdleTimeout:()=>a(new O(`Response body idle timeout: no data received for ${e/1e3}s.`,D.TIMEOUT,`Increase --timeout to allow a longer interval between response chunks.`))}}function tr(e,t){if(!e.body)return t.cleanup(),e;t.pauseTimeout();let n=e.body.getReader(),{signal:r}=t,i=!1,a,o=()=>{i=!0,r.removeEventListener(`abort`,a),t.cleanup()},s=e=>n.cancel(e).finally(()=>n.releaseLock()),c=new ReadableStream({start(e){a=()=>{i||(o(),e.error(r.reason),s(r.reason).catch(()=>{}))},r.addEventListener(`abort`,a,{once:!0}),r.aborted&&a()},async pull(e){try{t.resetIdleTimeout();let r=await n.read();if(t.pauseTimeout(),i)return;r.done?(o(),n.releaseLock(),e.close()):e.enqueue(r.value)}catch(t){if(i)return;o(),n.releaseLock(),e.error(r.aborted?r.reason:t)}},cancel(e){return o(),t.abort(e),s(e).catch(()=>{})}},{highWaterMark:0}),l=new Response(c,{status:e.status,statusText:e.statusText,headers:e.headers});return Object.defineProperties(l,{url:{value:e.url},redirected:{value:e.redirected},type:{value:e.type}}),l}async function nr(e,t){let n=er((t.timeout??e.settings.timeout)*1e3,t.signal);try{let r=await $n(e,t,n.signal),i;try{i=await r.json()}catch(e){if(n.signal.aborted)throw n.signal.reason;if(!(e instanceof SyntaxError))throw e;let t=r.headers.get(`content-type`)||``;throw new O(`API returned non-JSON response (${t||`unknown type`}). Server may be experiencing issues.\nAPI 返回了非 JSON 响应(${t||`未知类型`}),服务器可能出现问题。`,D.GENERAL)}if(typeof i==`object`&&i&&(i.code&&i.code!==`200`&&i.code!==200&&i.code!==`Success`||i.error)){let e=vt(r.status,{...i,request_id:i.request_id??i.requestID??r.headers.get(`x-request-id`)??void 0},t.url);throw new O(e.message,e.exitCode,e.hint,{api:e.api,rawResponse:JSON.stringify(i)})}return i}catch(e){throw n.signal.aborted?n.signal.reason:e}finally{n.cleanup()}}function rr(e){let t=[];for(let[n,r]of Object.entries(e))if(r!==void 0&&r!==``){if(Array.isArray(r))for(let e=0;e<r.length;e++){let i=r[e];i!==``&&t.push([`${n}.${e+1}`,i])}else t.push([n,r])}return t.sort(([e],[t])=>e<t?-1:+(e>t)),t.map(([e,t])=>`${ar(e)}=${ar(String(t))}`).join(`&`)}function ir(e){let t=e.method??`POST`,n=(/* @__PURE__ */ new Date()).toISOString().replace(/\.\d{3}Z$/,`Z`),r=oe(),i=or(e.body),a={host:e.host,"x-acs-action":e.action,"x-acs-version":e.version,"x-acs-date":n,"x-acs-signature-nonce":r,"x-acs-content-sha256":i,"content-type":`application/json`};e.securityToken&&(a[`x-acs-security-token`]=e.securityToken);let o=Object.keys(a).filter(e=>e===`host`||e===`content-type`||e.startsWith(`x-acs-`)).sort(),s=o.map(e=>`${e}:${a[e]}`).join(`
3
3
  `)+`
4
4
  `,c=o.join(`;`),l=e.queryString??``,u=[t,e.pathname,l,s,c,i].join(`
5
- `),d=`ACS3-HMAC-SHA256`,f=`${d}\n${Yn(u)}`,p=Xn(e.accessKeySecret,f);return a.authorization=`${d} Credential=${e.accessKeyId},SignedHeaders=${c},Signature=${p}`,a}function Jn(e){return encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}function Yn(e){return ie(`sha256`).update(e,`utf8`).digest(`hex`)}function Xn(e,t){return ae(`sha256`,e).update(t,`utf8`).digest(`hex`)}const Zn=[`cn-beijing`,`ap-southeast-1`];function Qn(e){return new D(`Local-file temporary upload is supported only in ${Zn.join(`, `)}; "${e}" is not supported.`,E.USAGE,`Use a reachable HTTPS media URL instead.`)}function $n(e){if(vn(e)===`token-plan`)throw Qn(`Token Plan`)}function er(e,t){let n=ut(e),r=new URL(n).hostname.toLowerCase();if(/^token-plan\.[a-z0-9-]+\.maas\.aliyuncs\.com$/.test(r))throw Qn(`Token Plan`);if(r===new URL(ft.cn).hostname||r===new URL(ft.intl).hostname)return $n(t),n;if(r===new URL(ft.us).hostname)throw Qn(r);let i=/^[^.]+\.([a-z0-9-]+)\.maas\.aliyuncs\.com$/.exec(r)?.[1];if(i===`cn-beijing`||i===`ap-southeast-1`)return $n(t),n;if(i)throw Qn(i);return n}async function tr(e,t,n,r,i){let a=`${er(r,e)}/api/v1/uploads`,o=`${a}?action=getPolicy&model=${encodeURIComponent(t)}`,s=fr(15e3,i),c=await En.fetch(o,{headers:{Authorization:`Bearer ${e}`,"Content-Type":`application/json`,...Rn(n)},signal:s.signal}).finally(s.cleanup);if(!c.ok){let e=await c.text().catch(()=>``),t;try{t=JSON.parse(e)}catch{}let n=typeof t?.message==`string`&&t.message?t.message:e||`${c.status} ${c.statusText}`,r=typeof t?.code==`string`?t.code:void 0,i=typeof t?.request_id==`string`?t.request_id:void 0;throw new D(`${[`HTTP ${c.status}`,r?`code=${r}`:void 0,i?`request_id=${i}`:void 0,`upload_endpoint=${a}`].filter(e=>e!==void 0).join(`; `)} - ${n}`,E.GENERAL,void 0,{api:{httpStatus:c.status,apiCode:r,requestId:i},rawResponse:e.slice(0,500)})}return(await c.json()).data}async function nr(e,t,n,r=120){let i=g(t),a=`${e.upload_dir}/${i}`,o=c(t),s=new FormData;s.append(`OSSAccessKeyId`,e.oss_access_key_id),s.append(`Signature`,e.signature),s.append(`policy`,e.policy),s.append(`x-oss-object-acl`,e.x_oss_object_acl),s.append(`x-oss-forbid-overwrite`,e.x_oss_forbid_overwrite),s.append(`key`,a),s.append(`success_action_status`,`200`),s.append(`file`,new Blob([o]),i);let l=fr(r*1e3,n),u=await En.fetch(e.upload_host,{method:`POST`,body:s,signal:l.signal}).finally(l.cleanup);if(!u.ok){let e=await u.text().catch(()=>``);throw new D(`Failed to upload file to OSS (HTTP ${u.status}): ${e}`,E.GENERAL)}return`oss://${a}`}const rr={".bmp":`image/bmp`,".heic":`image/heic`,".jpe":`image/jpeg`,".jpeg":`image/jpeg`,".jpg":`image/jpeg`,".png":`image/png`,".tif":`image/tiff`,".tiff":`image/tiff`,".webp":`image/webp`},ir={".aac":`audio/aac`,".amr":`audio/amr`,".flac":`audio/flac`,".m4a":`audio/mp4`,".mp3":`audio/mpeg`,".oga":`audio/ogg`,".ogg":`audio/ogg`,".opus":`audio/opus`,".wav":`audio/wav`,".weba":`audio/webm`,".wma":`audio/x-ms-wma`};function ar(e,t,n){if(!a(e))throw new D(`File not found: ${e}`,E.USAGE);if(!d(e).isFile())throw new D(`Not a file: ${e}`,E.USAGE);let r=_(e).toLowerCase(),i=t[r];if(!i)throw new D(`Unsupported ${n} format "${r||`unknown`}".`,E.USAGE,`Use an ${n} file with a recognized extension.`);return`data:${i};base64,${c(e).toString(`base64`)}`}function or(e){return ar(e,rr,`image`)}function sr(e){return ar(e,ir,`audio`)}function cr(e){let t=/^data:([^;,]+);base64,/i.exec(e);return t?`data:${t[1]};base64,<omitted>`:e}async function lr(e){let{apiKey:t,baseUrl:n=ft.cn,model:r,filePath:i,identity:o,signal:s,timeout:c}=e;if(!a(i))throw new D(`File not found: ${i}`,E.USAGE);if(!d(i).isFile())throw new D(`Not a file: ${i}`,E.USAGE);return nr(await tr(t,r,o,n,s),i,s,c)}function ur(e){return e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`oss://`)||e.startsWith(`data:`)?!1:a(e)}async function dr(e,t,n,r){return ur(e)?lr({apiKey:t,baseUrl:r.baseUrl,model:n,filePath:e,identity:r.identity,signal:r.signal,timeout:r.timeout}):e}function fr(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),e),i=()=>n.abort(t?.reason),a=()=>{clearTimeout(r),t?.removeEventListener(`abort`,i)};return t?.aborted?i():t?.addEventListener(`abort`,i,{once:!0}),n.signal.addEventListener(`abort`,a,{once:!0}),{signal:n.signal,cleanup:a}}const pr=Object.freeze({status:`aborted`});function O(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=/* @__PURE__ */ new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var mr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};const hr={};function gr(e){return e&&Object.assign(hr,e),hr}function _r(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function vr(e,t){return typeof t==`bigint`?t.toString():t}function yr(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function br(e){return e==null}function xr(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Sr(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}function k(e,t,n){Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Cr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function wr(e){return JSON.stringify(e)}const Tr=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Er(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Dr=yr(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Or(e){if(Er(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return Er(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}const kr=/* @__PURE__ */ new Set([`string`,`number`,`symbol`]);function Ar(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function jr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function A(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Mr(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const Nr={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Pr(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&(n[e]=r.shape[e])}return jr(e,{...e._zod.def,shape:n,checks:[]})}function Fr(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return jr(e,{...e._zod.def,shape:n,checks:[]})}function Ir(e,t){if(!Or(t))throw Error(`Invalid input to extend: expected a plain object`);return jr(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return Cr(this,`shape`,n),n},checks:[]})}function Lr(e,t){return jr(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Cr(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function Rr(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return jr(t,{...t._zod.def,shape:i,checks:[]})}function zr(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return jr(t,{...t._zod.def,shape:i,checks:[]})}function Br(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Vr(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Hr(e){return typeof e==`string`?e:e?.message}function Ur(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Hr(e.inst?._zod.def?.error?.(e))??Hr(t?.error?.(e))??Hr(n.customError?.(e))??Hr(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Wr(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Gr(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const Kr=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,vr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},qr=O(`$ZodError`,Kr),Jr=O(`$ZodError`,Kr,{Parent:Error});function Yr(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Xr(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}const Zr=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new mr;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Ur(e,a,gr())));throw Tr(t,i?.callee),t}return o.value},Qr=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Ur(e,a,gr())));throw Tr(t,i?.callee),t}return o.value},$r=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new mr;return a.issues.length?{success:!1,error:new(e??qr)(a.issues.map(e=>Ur(e,i,gr())))}:{success:!0,data:a.value}},ei=/* @__PURE__*/ $r(Jr),ti=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Ur(e,i,gr())))}:{success:!0,data:a.value}},ni=/* @__PURE__*/ ti(Jr),ri=/^[cC][^\s-]{8,}$/,ii=/^[0-9a-z]+$/,ai=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,oi=/^[0-9a-vA-V]{20}$/,si=/^[A-Za-z0-9]{27}$/,ci=/^[a-zA-Z0-9_-]{21}$/,li=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ui=/^([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})$/,di=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[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)$/,fi=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function pi(){return/* @__PURE__ */ RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const mi=/^(?:(?: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])$/,hi=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,gi=/^((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])$/,_i=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,vi=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,yi=/^[A-Za-z0-9_-]*$/,bi=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,xi=/^\+(?:[0-9]){6,14}[0-9]$/,Si=`(?:(?:\\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])))`,Ci=/*@__PURE__*/ RegExp(`^${Si}$`);function wi(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ti(e){return RegExp(`^${wi(e)}$`)}function Ei(e){let t=wi({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Si}T(?:${r})$`)}const Di=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Oi=/^\d+$/,ki=/^-?\d+(?:\.\d+)?/i,Ai=/true|false/i,ji=/null/i,Mi=/^[^A-Z]*$/,Ni=/^[^a-z]*$/,Pi=/*@__PURE__*/ O(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Fi={number:`number`,bigint:`bigint`,object:`date`},Ii=/*@__PURE__*/ O(`$ZodCheckLessThan`,(e,t)=>{Pi.init(e,t);let n=Fi[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Li=/*@__PURE__*/ O(`$ZodCheckGreaterThan`,(e,t)=>{Pi.init(e,t);let n=Fi[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ri=/*@__PURE__*/ O(`$ZodCheckMultipleOf`,(e,t)=>{Pi.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Sr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),zi=/*@__PURE__*/ O(`$ZodCheckNumberFormat`,(e,t)=>{Pi.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Nr[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Oi)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),Bi=/*@__PURE__*/ O(`$ZodCheckMaxLength`,(e,t)=>{var n;Pi.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!br(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Wr(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Vi=/*@__PURE__*/ O(`$ZodCheckMinLength`,(e,t)=>{var n;Pi.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!br(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Wr(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Hi=/*@__PURE__*/ O(`$ZodCheckLengthEquals`,(e,t)=>{var n;Pi.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!br(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Wr(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ui=/*@__PURE__*/ O(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Pi.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=/* @__PURE__ */ new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Wi=/*@__PURE__*/ O(`$ZodCheckRegex`,(e,t)=>{Ui.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Gi=/*@__PURE__*/ O(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Mi,Ui.init(e,t)}),Ki=/*@__PURE__*/ O(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Ni,Ui.init(e,t)}),qi=/*@__PURE__*/ O(`$ZodCheckIncludes`,(e,t)=>{Pi.init(e,t);let n=Ar(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ji=/*@__PURE__*/ O(`$ZodCheckStartsWith`,(e,t)=>{Pi.init(e,t);let n=RegExp(`^${Ar(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Yi=/*@__PURE__*/ O(`$ZodCheckEndsWith`,(e,t)=>{Pi.init(e,t);let n=RegExp(`.*${Ar(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Xi=/*@__PURE__*/ O(`$ZodCheckOverwrite`,(e,t)=>{Pi.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Zi=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
5
+ `),d=`ACS3-HMAC-SHA256`,f=`${d}\n${or(u)}`,p=sr(e.accessKeySecret,f);return a.authorization=`${d} Credential=${e.accessKeyId},SignedHeaders=${c},Signature=${p}`,a}function ar(e){return encodeURIComponent(e).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}function or(e){return re(`sha256`).update(e,`utf8`).digest(`hex`)}function sr(e,t){return ie(`sha256`,e).update(t,`utf8`).digest(`hex`)}const cr=[`cn-beijing`,`ap-southeast-1`];function lr(e){return new O(`Local-file temporary upload is supported only in ${cr.join(`, `)}; "${e}" is not supported.`,D.USAGE,`Use a reachable HTTPS media URL instead.`)}function ur(e){if(Dn(e)===`token-plan`)throw lr(`Token Plan`)}function dr(e,t){let n=yt(e),r=new URL(n).hostname.toLowerCase();if(/^token-plan\.[a-z0-9-]+\.maas\.aliyuncs\.com$/.test(r))throw lr(`Token Plan`);if(r===new URL(xt.cn).hostname||r===new URL(xt.intl).hostname)return ur(t),n;if(r===new URL(xt.us).hostname)throw lr(r);let i=/^[^.]+\.([a-z0-9-]+)\.maas\.aliyuncs\.com$/.exec(r)?.[1];if(i===`cn-beijing`||i===`ap-southeast-1`)return ur(t),n;if(i)throw lr(i);return n}async function fr(e,t,n,r,i){let a=`${dr(r,e)}/api/v1/uploads`,o=`${a}?action=getPolicy&model=${encodeURIComponent(t)}`,s=Cr(15e3,i),c=await Fn.fetch(o,{headers:{Authorization:`Bearer ${e}`,"Content-Type":`application/json`,...Yn(n)},signal:s.signal}).finally(s.cleanup);if(!c.ok){let e=await c.text().catch(()=>``),t;try{t=JSON.parse(e)}catch{}let n=typeof t?.message==`string`&&t.message?t.message:e||`${c.status} ${c.statusText}`,r=typeof t?.code==`string`?t.code:void 0,i=typeof t?.request_id==`string`?t.request_id:void 0;throw new O(`${[`HTTP ${c.status}`,r?`code=${r}`:void 0,i?`request_id=${i}`:void 0,`upload_endpoint=${a}`].filter(e=>e!==void 0).join(`; `)} - ${n}`,D.GENERAL,void 0,{api:{httpStatus:c.status,apiCode:r,requestId:i},rawResponse:e.slice(0,500)})}return(await c.json()).data}async function pr(e,t,n,r=120){let i=g(t),a=`${e.upload_dir}/${i}`,o=c(t),s=new FormData;s.append(`OSSAccessKeyId`,e.oss_access_key_id),s.append(`Signature`,e.signature),s.append(`policy`,e.policy),s.append(`x-oss-object-acl`,e.x_oss_object_acl),s.append(`x-oss-forbid-overwrite`,e.x_oss_forbid_overwrite),s.append(`key`,a),s.append(`success_action_status`,`200`),s.append(`file`,new Blob([o]),i);let l=Cr(r*1e3,n),u=await Fn.fetch(e.upload_host,{method:`POST`,body:s,signal:l.signal}).finally(l.cleanup);if(!u.ok){let e=await u.text().catch(()=>``);throw new O(`Failed to upload file to OSS (HTTP ${u.status}): ${e}`,D.GENERAL)}return`oss://${a}`}const mr={".bmp":`image/bmp`,".heic":`image/heic`,".jpe":`image/jpeg`,".jpeg":`image/jpeg`,".jpg":`image/jpeg`,".png":`image/png`,".tif":`image/tiff`,".tiff":`image/tiff`,".webp":`image/webp`},hr={".aac":`audio/aac`,".amr":`audio/amr`,".flac":`audio/flac`,".m4a":`audio/mp4`,".mp3":`audio/mpeg`,".oga":`audio/ogg`,".ogg":`audio/ogg`,".opus":`audio/opus`,".wav":`audio/wav`,".weba":`audio/webm`,".wma":`audio/x-ms-wma`};function gr(e,t,n){if(!a(e))throw new O(`File not found: ${e}`,D.USAGE);if(!d(e).isFile())throw new O(`Not a file: ${e}`,D.USAGE);let r=_(e).toLowerCase(),i=t[r];if(!i)throw new O(`Unsupported ${n} format "${r||`unknown`}".`,D.USAGE,`Use an ${n} file with a recognized extension.`);return`data:${i};base64,${c(e).toString(`base64`)}`}function _r(e){return gr(e,mr,`image`)}function vr(e){return gr(e,hr,`audio`)}function yr(e){let t=/^data:([^;,]+);base64,/i.exec(e);return t?`data:${t[1]};base64,<omitted>`:e}async function br(e){let{apiKey:t,baseUrl:n=xt.cn,model:r,filePath:i,identity:o,signal:s,timeout:c}=e;if(!a(i))throw new O(`File not found: ${i}`,D.USAGE);if(!d(i).isFile())throw new O(`Not a file: ${i}`,D.USAGE);return pr(await fr(t,r,o,n,s),i,s,c)}function xr(e){return e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`oss://`)||e.startsWith(`data:`)?!1:a(e)}async function Sr(e,t,n,r){return xr(e)?br({apiKey:t,baseUrl:r.baseUrl,model:n,filePath:e,identity:r.identity,signal:r.signal,timeout:r.timeout}):e}function Cr(e,t){let n=new AbortController,r=setTimeout(()=>n.abort(),e),i=()=>n.abort(t?.reason),a=()=>{clearTimeout(r),t?.removeEventListener(`abort`,i)};return t?.aborted?i():t?.addEventListener(`abort`,i,{once:!0}),n.signal.addEventListener(`abort`,a,{once:!0}),{signal:n.signal,cleanup:a}}const wr=Object.freeze({status:`aborted`});function A(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=/* @__PURE__ */ new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Tr=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};const Er={};function Dr(e){return e&&Object.assign(Er,e),Er}function Or(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function kr(e,t){return typeof t==`bigint`?t.toString():t}function Ar(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function jr(e){return e==null}function Mr(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Nr(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}function j(e,t,n){Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Pr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Fr(e){return JSON.stringify(e)}const Ir=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Lr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Rr=Ar(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function zr(e){if(Lr(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return Lr(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}const Br=/* @__PURE__ */ new Set([`string`,`number`,`symbol`]);function Vr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Hr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function M(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ur(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const Wr={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Gr(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&(n[e]=r.shape[e])}return Hr(e,{...e._zod.def,shape:n,checks:[]})}function Kr(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return Hr(e,{...e._zod.def,shape:n,checks:[]})}function qr(e,t){if(!zr(t))throw Error(`Invalid input to extend: expected a plain object`);return Hr(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return Pr(this,`shape`,n),n},checks:[]})}function Jr(e,t){return Hr(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Pr(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function Yr(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Hr(t,{...t._zod.def,shape:i,checks:[]})}function Xr(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Hr(t,{...t._zod.def,shape:i,checks:[]})}function Zr(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Qr(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function $r(e){return typeof e==`string`?e:e?.message}function ei(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=$r(e.inst?._zod.def?.error?.(e))??$r(t?.error?.(e))??$r(n.customError?.(e))??$r(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function ti(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function ni(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const ri=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,kr,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ii=A(`$ZodError`,ri),ai=A(`$ZodError`,ri,{Parent:Error});function oi(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function si(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}const ci=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Tr;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>ei(e,a,Dr())));throw Ir(t,i?.callee),t}return o.value},li=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>ei(e,a,Dr())));throw Ir(t,i?.callee),t}return o.value},ui=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Tr;return a.issues.length?{success:!1,error:new(e??ii)(a.issues.map(e=>ei(e,i,Dr())))}:{success:!0,data:a.value}},di=/* @__PURE__*/ ui(ai),fi=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>ei(e,i,Dr())))}:{success:!0,data:a.value}},pi=/* @__PURE__*/ fi(ai),mi=/^[cC][^\s-]{8,}$/,hi=/^[0-9a-z]+$/,gi=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,_i=/^[0-9a-vA-V]{20}$/,vi=/^[A-Za-z0-9]{27}$/,yi=/^[a-zA-Z0-9_-]{21}$/,bi=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,xi=/^([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})$/,Si=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[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)$/,Ci=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function wi(){return/* @__PURE__ */ RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const Ti=/^(?:(?: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])$/,Ei=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Di=/^((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])$/,Oi=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ki=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ai=/^[A-Za-z0-9_-]*$/,ji=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Mi=/^\+(?:[0-9]){6,14}[0-9]$/,Ni=`(?:(?:\\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])))`,Pi=/*@__PURE__*/ RegExp(`^${Ni}$`);function Fi(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ii(e){return RegExp(`^${Fi(e)}$`)}function Li(e){let t=Fi({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Ni}T(?:${r})$`)}const Ri=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},zi=/^\d+$/,Bi=/^-?\d+(?:\.\d+)?/i,Vi=/true|false/i,Hi=/null/i,Ui=/^[^A-Z]*$/,Wi=/^[^a-z]*$/,Gi=/*@__PURE__*/ A(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ki={number:`number`,bigint:`bigint`,object:`date`},qi=/*@__PURE__*/ A(`$ZodCheckLessThan`,(e,t)=>{Gi.init(e,t);let n=Ki[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ji=/*@__PURE__*/ A(`$ZodCheckGreaterThan`,(e,t)=>{Gi.init(e,t);let n=Ki[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Yi=/*@__PURE__*/ A(`$ZodCheckMultipleOf`,(e,t)=>{Gi.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Nr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Xi=/*@__PURE__*/ A(`$ZodCheckNumberFormat`,(e,t)=>{Gi.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Wr[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=zi)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),Zi=/*@__PURE__*/ A(`$ZodCheckMaxLength`,(e,t)=>{var n;Gi.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!jr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=ti(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Qi=/*@__PURE__*/ A(`$ZodCheckMinLength`,(e,t)=>{var n;Gi.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!jr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=ti(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$i=/*@__PURE__*/ A(`$ZodCheckLengthEquals`,(e,t)=>{var n;Gi.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!jr(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=ti(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ea=/*@__PURE__*/ A(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Gi.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=/* @__PURE__ */ new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ta=/*@__PURE__*/ A(`$ZodCheckRegex`,(e,t)=>{ea.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),na=/*@__PURE__*/ A(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Ui,ea.init(e,t)}),ra=/*@__PURE__*/ A(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Wi,ea.init(e,t)}),ia=/*@__PURE__*/ A(`$ZodCheckIncludes`,(e,t)=>{Gi.init(e,t);let n=Vr(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),aa=/*@__PURE__*/ A(`$ZodCheckStartsWith`,(e,t)=>{Gi.init(e,t);let n=RegExp(`^${Vr(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),oa=/*@__PURE__*/ A(`$ZodCheckEndsWith`,(e,t)=>{Gi.init(e,t);let n=RegExp(`.*${Vr(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=/* @__PURE__ */ new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),sa=/*@__PURE__*/ A(`$ZodCheckOverwrite`,(e,t)=>{Gi.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var ca=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
6
6
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
7
- `))}};const Qi={major:4,minor:0,patch:0},j=/*@__PURE__*/ O(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Qi;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Br(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new mr;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Br(e,t))});else{if(e.issues.length===t)continue;r||=Br(e,t)}}return i?i.then(()=>e):e};e._zod.run=(n,i)=>{let a=e._zod.parse(n,i);if(a instanceof Promise){if(i.async===!1)throw new mr;return a.then(e=>t(e,r,i))}return t(a,r,i)}}e[`~standard`]={validate:t=>{try{let n=ei(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return ni(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),$i=/*@__PURE__*/ O(`$ZodString`,(e,t)=>{j.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Di(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),M=/*@__PURE__*/ O(`$ZodStringFormat`,(e,t)=>{Ui.init(e,t),$i.init(e,t)}),ea=/*@__PURE__*/ O(`$ZodGUID`,(e,t)=>{t.pattern??=ui,M.init(e,t)}),ta=/*@__PURE__*/ O(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=di(e)}else t.pattern??=di();M.init(e,t)}),na=/*@__PURE__*/ O(`$ZodEmail`,(e,t)=>{t.pattern??=fi,M.init(e,t)}),ra=/*@__PURE__*/ O(`$ZodURL`,(e,t)=>{M.init(e,t),e._zod.check=n=>{try{let r=n.value,i=new URL(r),a=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:bi.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=!r.endsWith(`/`)&&a.endsWith(`/`)?a.slice(0,-1):a;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ia=/*@__PURE__*/ O(`$ZodEmoji`,(e,t)=>{t.pattern??=pi(),M.init(e,t)}),aa=/*@__PURE__*/ O(`$ZodNanoID`,(e,t)=>{t.pattern??=ci,M.init(e,t)}),oa=/*@__PURE__*/ O(`$ZodCUID`,(e,t)=>{t.pattern??=ri,M.init(e,t)}),sa=/*@__PURE__*/ O(`$ZodCUID2`,(e,t)=>{t.pattern??=ii,M.init(e,t)}),ca=/*@__PURE__*/ O(`$ZodULID`,(e,t)=>{t.pattern??=ai,M.init(e,t)}),la=/*@__PURE__*/ O(`$ZodXID`,(e,t)=>{t.pattern??=oi,M.init(e,t)}),ua=/*@__PURE__*/ O(`$ZodKSUID`,(e,t)=>{t.pattern??=si,M.init(e,t)}),da=/*@__PURE__*/ O(`$ZodISODateTime`,(e,t)=>{t.pattern??=Ei(t),M.init(e,t)}),fa=/*@__PURE__*/ O(`$ZodISODate`,(e,t)=>{t.pattern??=Ci,M.init(e,t)}),pa=/*@__PURE__*/ O(`$ZodISOTime`,(e,t)=>{t.pattern??=Ti(t),M.init(e,t)}),ma=/*@__PURE__*/ O(`$ZodISODuration`,(e,t)=>{t.pattern??=li,M.init(e,t)}),ha=/*@__PURE__*/ O(`$ZodIPv4`,(e,t)=>{t.pattern??=mi,M.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),ga=/*@__PURE__*/ O(`$ZodIPv6`,(e,t)=>{t.pattern??=hi,M.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),_a=/*@__PURE__*/ O(`$ZodCIDRv4`,(e,t)=>{t.pattern??=gi,M.init(e,t)}),va=/*@__PURE__*/ O(`$ZodCIDRv6`,(e,t)=>{t.pattern??=_i,M.init(e,t),e._zod.check=n=>{let[r,i]=n.value.split(`/`);try{if(!i)throw Error();let e=Number(i);if(`${e}`!==i||e<0||e>128)throw Error();new URL(`http://[${r}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function ya(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const ba=/*@__PURE__*/ O(`$ZodBase64`,(e,t)=>{t.pattern??=vi,M.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{ya(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function xa(e){if(!yi.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ya(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const Sa=/*@__PURE__*/ O(`$ZodBase64URL`,(e,t)=>{t.pattern??=yi,M.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{xa(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Ca=/*@__PURE__*/ O(`$ZodE164`,(e,t)=>{t.pattern??=xi,M.init(e,t)});function wa(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const Ta=/*@__PURE__*/ O(`$ZodJWT`,(e,t)=>{M.init(e,t),e._zod.check=n=>{wa(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Ea=/*@__PURE__*/ O(`$ZodNumber`,(e,t)=>{j.init(e,t),e._zod.pattern=e._zod.bag.pattern??ki,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Da=/*@__PURE__*/ O(`$ZodNumber`,(e,t)=>{zi.init(e,t),Ea.init(e,t)}),Oa=/*@__PURE__*/ O(`$ZodBoolean`,(e,t)=>{j.init(e,t),e._zod.pattern=Ai,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),ka=/*@__PURE__*/ O(`$ZodNull`,(e,t)=>{j.init(e,t),e._zod.pattern=ji,e._zod.values=/* @__PURE__ */ new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Aa=/*@__PURE__*/ O(`$ZodAny`,(e,t)=>{j.init(e,t),e._zod.parse=e=>e}),ja=/*@__PURE__*/ O(`$ZodUnknown`,(e,t)=>{j.init(e,t),e._zod.parse=e=>e}),Ma=/*@__PURE__*/ O(`$ZodNever`,(e,t)=>{j.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Na(e,t,n){e.issues.length&&t.issues.push(...Vr(n,e.issues)),t.value[n]=e.value}const Pa=/*@__PURE__*/ O(`$ZodArray`,(e,t)=>{j.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Na(t,n,e))):Na(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Fa(e,t,n){e.issues.length&&t.issues.push(...Vr(n,e.issues)),t.value[n]=e.value}function Ia(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...Vr(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}const La=/*@__PURE__*/ O(`$ZodObject`,(e,t)=>{j.init(e,t);let n=yr(()=>{let e=Object.keys(t.shape);for(let n of e)if(!(t.shape[n]instanceof j))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Mr(t.shape);return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}});k(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */ new Set);for(let e of r.values)n[t].add(e)}}return n});let r=e=>{let t=new Zi([`shape`,`payload`,`ctx`]),r=n.value,i=e=>{let t=wr(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of r.keys)a[e]=`key_${o++}`;t.write(`const newResult = {}`);for(let e of r.keys)if(r.optionalKeys.has(e)){let n=a[e];t.write(`const ${n} = ${i(e)};`);let r=wr(e);t.write(`
7
+ `))}};const la={major:4,minor:0,patch:0},N=/*@__PURE__*/ A(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=la;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Zr(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Tr;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Zr(e,t))});else{if(e.issues.length===t)continue;r||=Zr(e,t)}}return i?i.then(()=>e):e};e._zod.run=(n,i)=>{let a=e._zod.parse(n,i);if(a instanceof Promise){if(i.async===!1)throw new Tr;return a.then(e=>t(e,r,i))}return t(a,r,i)}}e[`~standard`]={validate:t=>{try{let n=di(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return pi(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),ua=/*@__PURE__*/ A(`$ZodString`,(e,t)=>{N.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Ri(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),P=/*@__PURE__*/ A(`$ZodStringFormat`,(e,t)=>{ea.init(e,t),ua.init(e,t)}),da=/*@__PURE__*/ A(`$ZodGUID`,(e,t)=>{t.pattern??=xi,P.init(e,t)}),fa=/*@__PURE__*/ A(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Si(e)}else t.pattern??=Si();P.init(e,t)}),pa=/*@__PURE__*/ A(`$ZodEmail`,(e,t)=>{t.pattern??=Ci,P.init(e,t)}),ma=/*@__PURE__*/ A(`$ZodURL`,(e,t)=>{P.init(e,t),e._zod.check=n=>{try{let r=n.value,i=new URL(r),a=i.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:ji.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=!r.endsWith(`/`)&&a.endsWith(`/`)?a.slice(0,-1):a;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ha=/*@__PURE__*/ A(`$ZodEmoji`,(e,t)=>{t.pattern??=wi(),P.init(e,t)}),ga=/*@__PURE__*/ A(`$ZodNanoID`,(e,t)=>{t.pattern??=yi,P.init(e,t)}),_a=/*@__PURE__*/ A(`$ZodCUID`,(e,t)=>{t.pattern??=mi,P.init(e,t)}),va=/*@__PURE__*/ A(`$ZodCUID2`,(e,t)=>{t.pattern??=hi,P.init(e,t)}),ya=/*@__PURE__*/ A(`$ZodULID`,(e,t)=>{t.pattern??=gi,P.init(e,t)}),ba=/*@__PURE__*/ A(`$ZodXID`,(e,t)=>{t.pattern??=_i,P.init(e,t)}),xa=/*@__PURE__*/ A(`$ZodKSUID`,(e,t)=>{t.pattern??=vi,P.init(e,t)}),Sa=/*@__PURE__*/ A(`$ZodISODateTime`,(e,t)=>{t.pattern??=Li(t),P.init(e,t)}),Ca=/*@__PURE__*/ A(`$ZodISODate`,(e,t)=>{t.pattern??=Pi,P.init(e,t)}),wa=/*@__PURE__*/ A(`$ZodISOTime`,(e,t)=>{t.pattern??=Ii(t),P.init(e,t)}),Ta=/*@__PURE__*/ A(`$ZodISODuration`,(e,t)=>{t.pattern??=bi,P.init(e,t)}),Ea=/*@__PURE__*/ A(`$ZodIPv4`,(e,t)=>{t.pattern??=Ti,P.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),Da=/*@__PURE__*/ A(`$ZodIPv6`,(e,t)=>{t.pattern??=Ei,P.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Oa=/*@__PURE__*/ A(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Di,P.init(e,t)}),ka=/*@__PURE__*/ A(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Oi,P.init(e,t),e._zod.check=n=>{let[r,i]=n.value.split(`/`);try{if(!i)throw Error();let e=Number(i);if(`${e}`!==i||e<0||e>128)throw Error();new URL(`http://[${r}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Aa(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const ja=/*@__PURE__*/ A(`$ZodBase64`,(e,t)=>{t.pattern??=ki,P.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{Aa(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Ma(e){if(!Ai.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Aa(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const Na=/*@__PURE__*/ A(`$ZodBase64URL`,(e,t)=>{t.pattern??=Ai,P.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{Ma(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Pa=/*@__PURE__*/ A(`$ZodE164`,(e,t)=>{t.pattern??=Mi,P.init(e,t)});function Fa(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const Ia=/*@__PURE__*/ A(`$ZodJWT`,(e,t)=>{P.init(e,t),e._zod.check=n=>{Fa(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),La=/*@__PURE__*/ A(`$ZodNumber`,(e,t)=>{N.init(e,t),e._zod.pattern=e._zod.bag.pattern??Bi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Ra=/*@__PURE__*/ A(`$ZodNumber`,(e,t)=>{Xi.init(e,t),La.init(e,t)}),za=/*@__PURE__*/ A(`$ZodBoolean`,(e,t)=>{N.init(e,t),e._zod.pattern=Vi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Ba=/*@__PURE__*/ A(`$ZodNull`,(e,t)=>{N.init(e,t),e._zod.pattern=Hi,e._zod.values=/* @__PURE__ */ new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Va=/*@__PURE__*/ A(`$ZodAny`,(e,t)=>{N.init(e,t),e._zod.parse=e=>e}),Ha=/*@__PURE__*/ A(`$ZodUnknown`,(e,t)=>{N.init(e,t),e._zod.parse=e=>e}),Ua=/*@__PURE__*/ A(`$ZodNever`,(e,t)=>{N.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Wa(e,t,n){e.issues.length&&t.issues.push(...Qr(n,e.issues)),t.value[n]=e.value}const Ga=/*@__PURE__*/ A(`$ZodArray`,(e,t)=>{N.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Wa(t,n,e))):Wa(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Ka(e,t,n){e.issues.length&&t.issues.push(...Qr(n,e.issues)),t.value[n]=e.value}function qa(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...Qr(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}const Ja=/*@__PURE__*/ A(`$ZodObject`,(e,t)=>{N.init(e,t);let n=Ar(()=>{let e=Object.keys(t.shape);for(let n of e)if(!(t.shape[n]instanceof N))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Ur(t.shape);return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}});j(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */ new Set);for(let e of r.values)n[t].add(e)}}return n});let r=e=>{let t=new ca([`shape`,`payload`,`ctx`]),r=n.value,i=e=>{let t=Fr(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of r.keys)a[e]=`key_${o++}`;t.write(`const newResult = {}`);for(let e of r.keys)if(r.optionalKeys.has(e)){let n=a[e];t.write(`const ${n} = ${i(e)};`);let r=Fr(e);t.write(`
8
8
  if (${n}.issues.length) {
9
9
  if (input[${r}] === undefined) {
10
10
  if (${r} in input) {
@@ -26,73 +26,148 @@ import{createRequire as e}from"node:module";import{appendFileSync as t,closeSync
26
26
  `)}else{let n=a[e];t.write(`const ${n} = ${i(e)};`),t.write(`
27
27
  if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
28
28
  ...iss,
29
- path: iss.path ? [${wr(e)}, ...iss.path] : [${wr(e)}]
30
- })));`),t.write(`newResult[${wr(e)}] = ${n}.value`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},i,a=Er,o=!hr.jitless,s=o&&Dr.value,c=t.catchall,l;e._zod.parse=(u,d)=>{l??=n.value;let f=u.value;if(!a(f))return u.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),u;let p=[];if(o&&s&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),u=i(u,d);else{u.value={};let e=l.shape;for(let t of l.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?Ia(e,u,t,f):Fa(e,u,t))):i?Ia(r,u,t,f):Fa(r,u,t)}}if(!c)return p.length?Promise.all(p).then(()=>u):u;let m=[],h=l.keySet,g=c._zod,_=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(_===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>Fa(t,u,e))):Fa(t,u,e)}return m.length&&u.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>u):u}});function Ra(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Ur(e,r,gr())))}),t}const za=/*@__PURE__*/ O(`$ZodUnion`,(e,t)=>{j.init(e,t),k(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),k(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),k(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),k(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>xr(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>Ra(t,n,e,r)):Ra(a,n,e,r)}}),Ba=/*@__PURE__*/ O(`$ZodDiscriminatedUnion`,(e,t)=>{za.init(e,t);let n=e._zod.parse;k(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=/* @__PURE__ */ new Set);for(let r of n)e[t].add(r)}}return e});let r=yr(()=>{let e=t.options,n=/* @__PURE__ */ new Map;for(let r of e){let e=r._zod.propValues[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Er(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,input:o,path:[t.discriminator],inst:e}),i)}}),Va=/*@__PURE__*/ O(`$ZodIntersection`,(e,t)=>{j.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Ua(e,t,n)):Ua(e,i,a)}});function Ha(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Or(e)&&Or(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Ha(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ha(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ua(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Br(e))return e;let r=Ha(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const Wa=/*@__PURE__*/ O(`$ZodRecord`,(e,t)=>{j.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Or(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Vr(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Vr(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>Ur(e,r,gr())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Vr(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Vr(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Ga=/*@__PURE__*/ O(`$ZodEnum`,(e,t)=>{j.init(e,t);let n=_r(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>kr.has(typeof e)).map(e=>typeof e==`string`?Ar(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),Ka=/*@__PURE__*/ O(`$ZodLiteral`,(e,t)=>{j.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Ar(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),qa=/*@__PURE__*/ O(`$ZodTransform`,(e,t)=>{j.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(t=>(e.value=t,e));if(r instanceof Promise)throw new mr;return e.value=r,e}}),Ja=/*@__PURE__*/ O(`$ZodOptional`,(e,t)=>{j.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,k(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,void 0]):void 0),k(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${xr(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),Ya=/*@__PURE__*/ O(`$ZodNullable`,(e,t)=>{j.init(e,t),k(e._zod,`optin`,()=>t.innerType._zod.optin),k(e._zod,`optout`,()=>t.innerType._zod.optout),k(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${xr(e.source)}|null)$`):void 0}),k(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Xa=/*@__PURE__*/ O(`$ZodDefault`,(e,t)=>{j.init(e,t),e._zod.optin=`optional`,k(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Za(e,t)):Za(r,t)}});function Za(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Qa=/*@__PURE__*/ O(`$ZodPrefault`,(e,t)=>{j.init(e,t),e._zod.optin=`optional`,k(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),$a=/*@__PURE__*/ O(`$ZodNonOptional`,(e,t)=>{j.init(e,t),k(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>eo(t,e)):eo(i,e)}});function eo(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const to=/*@__PURE__*/ O(`$ZodCatch`,(e,t)=>{j.init(e,t),e._zod.optin=`optional`,k(e._zod,`optout`,()=>t.innerType._zod.optout),k(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ur(e,n,gr()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Ur(e,n,gr()))},input:e.value}),e.issues=[]),e)}}),no=/*@__PURE__*/ O(`$ZodPipe`,(e,t)=>{j.init(e,t),k(e._zod,`values`,()=>t.in._zod.values),k(e._zod,`optin`,()=>t.in._zod.optin),k(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ro(e,t,n)):ro(r,t,n)}});function ro(e,t,n){return Br(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const io=/*@__PURE__*/ O(`$ZodReadonly`,(e,t)=>{j.init(e,t),k(e._zod,`propValues`,()=>t.innerType._zod.propValues),k(e._zod,`values`,()=>t.innerType._zod.values),k(e._zod,`optin`,()=>t.innerType._zod.optin),k(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(ao):ao(r)}});function ao(e){return e.value=Object.freeze(e.value),e}const oo=/*@__PURE__*/ O(`$ZodCustom`,(e,t)=>{Pi.init(e,t),j.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>so(t,n,r,e));so(i,n,r,e)}});function so(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Gr(e))}}var co=class{constructor(){this._map=/* @__PURE__ */ new Map,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=/* @__PURE__ */ new Map,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function lo(){return new co}const uo=/*@__PURE__*/ lo();function fo(e,t){return new e({type:`string`,...A(t)})}function po(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...A(t)})}function mo(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...A(t)})}function ho(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...A(t)})}function go(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...A(t)})}function _o(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...A(t)})}function vo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...A(t)})}function yo(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...A(t)})}function bo(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...A(t)})}function xo(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...A(t)})}function So(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...A(t)})}function Co(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...A(t)})}function wo(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...A(t)})}function To(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...A(t)})}function Eo(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...A(t)})}function Do(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...A(t)})}function Oo(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...A(t)})}function ko(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...A(t)})}function Ao(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...A(t)})}function jo(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...A(t)})}function Mo(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...A(t)})}function No(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...A(t)})}function Po(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...A(t)})}function Fo(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...A(t)})}function Io(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...A(t)})}function Lo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...A(t)})}function Ro(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...A(t)})}function zo(e,t){return new e({type:`number`,checks:[],...A(t)})}function Bo(e,t){return new e({type:`number`,coerce:!0,checks:[],...A(t)})}function Vo(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...A(t)})}function Ho(e,t){return new e({type:`boolean`,...A(t)})}function Uo(e,t){return new e({type:`null`,...A(t)})}function Wo(e){return new e({type:`any`})}function Go(e){return new e({type:`unknown`})}function Ko(e,t){return new e({type:`never`,...A(t)})}function qo(e,t){return new Ii({check:`less_than`,...A(t),value:e,inclusive:!1})}function Jo(e,t){return new Ii({check:`less_than`,...A(t),value:e,inclusive:!0})}function Yo(e,t){return new Li({check:`greater_than`,...A(t),value:e,inclusive:!1})}function Xo(e,t){return new Li({check:`greater_than`,...A(t),value:e,inclusive:!0})}function Zo(e,t){return new Ri({check:`multiple_of`,...A(t),value:e})}function Qo(e,t){return new Bi({check:`max_length`,...A(t),maximum:e})}function $o(e,t){return new Vi({check:`min_length`,...A(t),minimum:e})}function es(e,t){return new Hi({check:`length_equals`,...A(t),length:e})}function ts(e,t){return new Wi({check:`string_format`,format:`regex`,...A(t),pattern:e})}function ns(e){return new Gi({check:`string_format`,format:`lowercase`,...A(e)})}function rs(e){return new Ki({check:`string_format`,format:`uppercase`,...A(e)})}function is(e,t){return new qi({check:`string_format`,format:`includes`,...A(t),includes:e})}function as(e,t){return new Ji({check:`string_format`,format:`starts_with`,...A(t),prefix:e})}function os(e,t){return new Yi({check:`string_format`,format:`ends_with`,...A(t),suffix:e})}function ss(e){return new Xi({check:`overwrite`,tx:e})}function cs(e){return ss(t=>t.normalize(e))}function ls(){return ss(e=>e.trim())}function us(){return ss(e=>e.toLowerCase())}function ds(){return ss(e=>e.toUpperCase())}function fs(e,t,n){return new e({type:`array`,element:t,...A(n)})}function ps(e,t,n){let r=A(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function ms(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...A(n)})}function hs(e){return!!e._zod}function gs(e,t){return hs(e)?ei(e,t):e.safeParse(t)}function _s(e){if(!e)return;let t;if(t=hs(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function vs(e){if(hs(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}const ys=/*@__PURE__*/ O(`ZodISODateTime`,(e,t)=>{da.init(e,t),F.init(e,t)});function bs(e){return Fo(ys,e)}const xs=/*@__PURE__*/ O(`ZodISODate`,(e,t)=>{fa.init(e,t),F.init(e,t)});function Ss(e){return Io(xs,e)}const Cs=/*@__PURE__*/ O(`ZodISOTime`,(e,t)=>{pa.init(e,t),F.init(e,t)});function ws(e){return Lo(Cs,e)}const Ts=/*@__PURE__*/ O(`ZodISODuration`,(e,t)=>{ma.init(e,t),F.init(e,t)});function Es(e){return Ro(Ts,e)}const Ds=(e,t)=>{qr.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Xr(e,t)},flatten:{value:t=>Yr(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})};O(`ZodError`,Ds);const Os=O(`ZodError`,Ds,{Parent:Error}),ks=/* @__PURE__ */ Zr(Os),As=/* @__PURE__ */ Qr(Os),js=/* @__PURE__ */ $r(Os),Ms=/* @__PURE__ */ ti(Os),N=/*@__PURE__*/ O(`ZodType`,(e,t)=>(j.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>jr(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>ks(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>js(e,t,n),e.parseAsync=async(t,n)=>As(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ms(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(Wc(t,n)),e.superRefine=t=>e.check(Gc(t)),e.overwrite=t=>e.check(ss(t)),e.optional=()=>W(e),e.nullable=()=>Oc(e),e.nullish=()=>W(Oc(e)),e.nonoptional=t=>Pc(e,t),e.array=()=>z(e),e.or=t=>V([e,t]),e.and=t=>yc(e,t),e.transform=t=>Rc(e,Tc(t)),e.default=t=>Ac(e,t),e.prefault=t=>Mc(e,t),e.catch=t=>Ic(e,t),e.pipe=t=>Rc(e,t),e.readonly=()=>Bc(e),e.describe=t=>{let n=e.clone();return uo.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return uo.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return uo.get(e);let n=e.clone();return uo.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Ns=/*@__PURE__*/ O(`_ZodString`,(e,t)=>{$i.init(e,t),N.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(ts(...t)),e.includes=(...t)=>e.check(is(...t)),e.startsWith=(...t)=>e.check(as(...t)),e.endsWith=(...t)=>e.check(os(...t)),e.min=(...t)=>e.check($o(...t)),e.max=(...t)=>e.check(Qo(...t)),e.length=(...t)=>e.check(es(...t)),e.nonempty=(...t)=>e.check($o(1,...t)),e.lowercase=t=>e.check(ns(t)),e.uppercase=t=>e.check(rs(t)),e.trim=()=>e.check(ls()),e.normalize=(...t)=>e.check(cs(...t)),e.toLowerCase=()=>e.check(us()),e.toUpperCase=()=>e.check(ds())}),Ps=/*@__PURE__*/ O(`ZodString`,(e,t)=>{$i.init(e,t),Ns.init(e,t),e.email=t=>e.check(po(Fs,t)),e.url=t=>e.check(yo(Rs,t)),e.jwt=t=>e.check(Po(ec,t)),e.emoji=t=>e.check(bo(Bs,t)),e.guid=t=>e.check(mo(Is,t)),e.uuid=t=>e.check(ho(Ls,t)),e.uuidv4=t=>e.check(go(Ls,t)),e.uuidv6=t=>e.check(_o(Ls,t)),e.uuidv7=t=>e.check(vo(Ls,t)),e.nanoid=t=>e.check(xo(Vs,t)),e.guid=t=>e.check(mo(Is,t)),e.cuid=t=>e.check(So(Hs,t)),e.cuid2=t=>e.check(Co(Us,t)),e.ulid=t=>e.check(wo(Ws,t)),e.base64=t=>e.check(jo(Zs,t)),e.base64url=t=>e.check(Mo(Qs,t)),e.xid=t=>e.check(To(Gs,t)),e.ksuid=t=>e.check(Eo(Ks,t)),e.ipv4=t=>e.check(Do(qs,t)),e.ipv6=t=>e.check(Oo(Js,t)),e.cidrv4=t=>e.check(ko(Ys,t)),e.cidrv6=t=>e.check(Ao(Xs,t)),e.e164=t=>e.check(No($s,t)),e.datetime=t=>e.check(bs(t)),e.date=t=>e.check(Ss(t)),e.time=t=>e.check(ws(t)),e.duration=t=>e.check(Es(t))});function P(e){return fo(Ps,e)}const F=/*@__PURE__*/ O(`ZodStringFormat`,(e,t)=>{M.init(e,t),Ns.init(e,t)}),Fs=/*@__PURE__*/ O(`ZodEmail`,(e,t)=>{na.init(e,t),F.init(e,t)}),Is=/*@__PURE__*/ O(`ZodGUID`,(e,t)=>{ea.init(e,t),F.init(e,t)}),Ls=/*@__PURE__*/ O(`ZodUUID`,(e,t)=>{ta.init(e,t),F.init(e,t)}),Rs=/*@__PURE__*/ O(`ZodURL`,(e,t)=>{ra.init(e,t),F.init(e,t)});function zs(e){return yo(Rs,e)}const Bs=/*@__PURE__*/ O(`ZodEmoji`,(e,t)=>{ia.init(e,t),F.init(e,t)}),Vs=/*@__PURE__*/ O(`ZodNanoID`,(e,t)=>{aa.init(e,t),F.init(e,t)}),Hs=/*@__PURE__*/ O(`ZodCUID`,(e,t)=>{oa.init(e,t),F.init(e,t)}),Us=/*@__PURE__*/ O(`ZodCUID2`,(e,t)=>{sa.init(e,t),F.init(e,t)}),Ws=/*@__PURE__*/ O(`ZodULID`,(e,t)=>{ca.init(e,t),F.init(e,t)}),Gs=/*@__PURE__*/ O(`ZodXID`,(e,t)=>{la.init(e,t),F.init(e,t)}),Ks=/*@__PURE__*/ O(`ZodKSUID`,(e,t)=>{ua.init(e,t),F.init(e,t)}),qs=/*@__PURE__*/ O(`ZodIPv4`,(e,t)=>{ha.init(e,t),F.init(e,t)}),Js=/*@__PURE__*/ O(`ZodIPv6`,(e,t)=>{ga.init(e,t),F.init(e,t)}),Ys=/*@__PURE__*/ O(`ZodCIDRv4`,(e,t)=>{_a.init(e,t),F.init(e,t)}),Xs=/*@__PURE__*/ O(`ZodCIDRv6`,(e,t)=>{va.init(e,t),F.init(e,t)}),Zs=/*@__PURE__*/ O(`ZodBase64`,(e,t)=>{ba.init(e,t),F.init(e,t)}),Qs=/*@__PURE__*/ O(`ZodBase64URL`,(e,t)=>{Sa.init(e,t),F.init(e,t)}),$s=/*@__PURE__*/ O(`ZodE164`,(e,t)=>{Ca.init(e,t),F.init(e,t)}),ec=/*@__PURE__*/ O(`ZodJWT`,(e,t)=>{Ta.init(e,t),F.init(e,t)}),tc=/*@__PURE__*/ O(`ZodNumber`,(e,t)=>{Ea.init(e,t),N.init(e,t),e.gt=(t,n)=>e.check(Yo(t,n)),e.gte=(t,n)=>e.check(Xo(t,n)),e.min=(t,n)=>e.check(Xo(t,n)),e.lt=(t,n)=>e.check(qo(t,n)),e.lte=(t,n)=>e.check(Jo(t,n)),e.max=(t,n)=>e.check(Jo(t,n)),e.int=t=>e.check(rc(t)),e.safe=t=>e.check(rc(t)),e.positive=t=>e.check(Yo(0,t)),e.nonnegative=t=>e.check(Xo(0,t)),e.negative=t=>e.check(qo(0,t)),e.nonpositive=t=>e.check(Jo(0,t)),e.multipleOf=(t,n)=>e.check(Zo(t,n)),e.step=(t,n)=>e.check(Zo(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function I(e){return zo(tc,e)}const nc=/*@__PURE__*/ O(`ZodNumberFormat`,(e,t)=>{Da.init(e,t),tc.init(e,t)});function rc(e){return Vo(nc,e)}const ic=/*@__PURE__*/ O(`ZodBoolean`,(e,t)=>{Oa.init(e,t),N.init(e,t)});function L(e){return Ho(ic,e)}const ac=/*@__PURE__*/ O(`ZodNull`,(e,t)=>{ka.init(e,t),N.init(e,t)});function oc(e){return Uo(ac,e)}const sc=/*@__PURE__*/ O(`ZodAny`,(e,t)=>{Aa.init(e,t),N.init(e,t)});function cc(){return Wo(sc)}const lc=/*@__PURE__*/ O(`ZodUnknown`,(e,t)=>{ja.init(e,t),N.init(e,t)});function R(){return Go(lc)}const uc=/*@__PURE__*/ O(`ZodNever`,(e,t)=>{Ma.init(e,t),N.init(e,t)});function dc(e){return Ko(uc,e)}const fc=/*@__PURE__*/ O(`ZodArray`,(e,t)=>{Pa.init(e,t),N.init(e,t),e.element=t.element,e.min=(t,n)=>e.check($o(t,n)),e.nonempty=t=>e.check($o(1,t)),e.max=(t,n)=>e.check(Qo(t,n)),e.length=(t,n)=>e.check(es(t,n)),e.unwrap=()=>e.element});function z(e,t){return fs(fc,e,t)}const pc=/*@__PURE__*/ O(`ZodObject`,(e,t)=>{La.init(e,t),N.init(e,t),k(e,`shape`,()=>t.shape),e.keyof=()=>Sc(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:R()}),e.loose=()=>e.clone({...e._zod.def,catchall:R()}),e.strict=()=>e.clone({...e._zod.def,catchall:dc()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Ir(e,t),e.merge=t=>Lr(e,t),e.pick=t=>Pr(e,t),e.omit=t=>Fr(e,t),e.partial=(...t)=>Rr(Ec,e,t[0]),e.required=(...t)=>zr(Nc,e,t[0])});function B(e,t){let n={type:`object`,get shape(){return Cr(this,`shape`,{...e}),this.shape},...A(t)};return new pc(n)}function mc(e,t){return new pc({type:`object`,get shape(){return Cr(this,`shape`,{...e}),this.shape},catchall:R(),...A(t)})}const hc=/*@__PURE__*/ O(`ZodUnion`,(e,t)=>{za.init(e,t),N.init(e,t),e.options=t.options});function V(e,t){return new hc({type:`union`,options:e,...A(t)})}const gc=/*@__PURE__*/ O(`ZodDiscriminatedUnion`,(e,t)=>{hc.init(e,t),Ba.init(e,t)});function _c(e,t,n){return new gc({type:`union`,options:t,discriminator:e,...A(n)})}const vc=/*@__PURE__*/ O(`ZodIntersection`,(e,t)=>{Va.init(e,t),N.init(e,t)});function yc(e,t){return new vc({type:`intersection`,left:e,right:t})}const bc=/*@__PURE__*/ O(`ZodRecord`,(e,t)=>{Wa.init(e,t),N.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function H(e,t,n){return new bc({type:`record`,keyType:e,valueType:t,...A(n)})}const xc=/*@__PURE__*/ O(`ZodEnum`,(e,t)=>{Ga.init(e,t),N.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new xc({...t,checks:[],...A(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new xc({...t,checks:[],...A(r),entries:i})}});function Sc(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new xc({type:`enum`,entries:n,...A(t)})}const Cc=/*@__PURE__*/ O(`ZodLiteral`,(e,t)=>{Ka.init(e,t),N.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function U(e,t){return new Cc({type:`literal`,values:Array.isArray(e)?e:[e],...A(t)})}const wc=/*@__PURE__*/ O(`ZodTransform`,(e,t)=>{qa.init(e,t),N.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Gr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(Gr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Tc(e){return new wc({type:`transform`,transform:e})}const Ec=/*@__PURE__*/ O(`ZodOptional`,(e,t)=>{Ja.init(e,t),N.init(e,t),e.unwrap=()=>e._zod.def.innerType});function W(e){return new Ec({type:`optional`,innerType:e})}const Dc=/*@__PURE__*/ O(`ZodNullable`,(e,t)=>{Ya.init(e,t),N.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Oc(e){return new Dc({type:`nullable`,innerType:e})}const kc=/*@__PURE__*/ O(`ZodDefault`,(e,t)=>{Xa.init(e,t),N.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ac(e,t){return new kc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const jc=/*@__PURE__*/ O(`ZodPrefault`,(e,t)=>{Qa.init(e,t),N.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Mc(e,t){return new jc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const Nc=/*@__PURE__*/ O(`ZodNonOptional`,(e,t)=>{$a.init(e,t),N.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Pc(e,t){return new Nc({type:`nonoptional`,innerType:e,...A(t)})}const Fc=/*@__PURE__*/ O(`ZodCatch`,(e,t)=>{to.init(e,t),N.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ic(e,t){return new Fc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Lc=/*@__PURE__*/ O(`ZodPipe`,(e,t)=>{no.init(e,t),N.init(e,t),e.in=t.in,e.out=t.out});function Rc(e,t){return new Lc({type:`pipe`,in:e,out:t})}const zc=/*@__PURE__*/ O(`ZodReadonly`,(e,t)=>{io.init(e,t),N.init(e,t)});function Bc(e){return new zc({type:`readonly`,innerType:e})}const Vc=/*@__PURE__*/ O(`ZodCustom`,(e,t)=>{oo.init(e,t),N.init(e,t)});function Hc(e){let t=new Pi({check:`custom`});return t._zod.check=e,t}function Uc(e,t){return ps(Vc,e??(()=>!0),t)}function Wc(e,t={}){return ms(Vc,e,t)}function Gc(e){let t=Hc(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Gr(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Gr(r))}},e(n.value,n)));return t}function Kc(e,t){return Rc(Tc(e),t)}const qc={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};function Jc(e){return Bo(tc,e)}const Yc=`2025-11-25`,Xc=[Yc,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Zc=`io.modelcontextprotocol/related-task`,Qc=Uc(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),$c=V([P(),I().int()]),el=P();mc({ttl:I().optional(),pollInterval:I().optional()});const tl=B({ttl:I().optional()}),nl=B({taskId:P()}),rl=mc({progressToken:$c.optional(),[Zc]:nl.optional()}),il=B({_meta:rl.optional()}),al=il.extend({task:tl.optional()}),ol=e=>al.safeParse(e).success,sl=B({method:P(),params:il.loose().optional()}),cl=B({_meta:rl.optional()}),ll=B({method:P(),params:cl.loose().optional()}),ul=mc({_meta:rl.optional()}),dl=V([P(),I().int()]),fl=B({jsonrpc:U(`2.0`),id:dl,...sl.shape}).strict(),pl=e=>fl.safeParse(e).success,ml=B({jsonrpc:U(`2.0`),...ll.shape}).strict(),hl=e=>ml.safeParse(e).success,gl=B({jsonrpc:U(`2.0`),id:dl,result:ul}).strict(),_l=e=>gl.safeParse(e).success;var G;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(G||={});const vl=B({jsonrpc:U(`2.0`),id:dl.optional(),error:B({code:I().int(),message:P(),data:R().optional()})}).strict(),yl=e=>vl.safeParse(e).success,bl=V([fl,ml,gl,vl]);V([gl,vl]);const xl=ul.strict(),Sl=cl.extend({requestId:dl.optional(),reason:P().optional()}),Cl=ll.extend({method:U(`notifications/cancelled`),params:Sl}),wl=B({icons:z(B({src:P(),mimeType:P().optional(),sizes:z(P()).optional(),theme:Sc([`light`,`dark`]).optional()})).optional()}),Tl=B({name:P(),title:P().optional()}),El=Tl.extend({...Tl.shape,...wl.shape,version:P(),websiteUrl:P().optional(),description:P().optional()}),Dl=Kc(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,yc(B({form:yc(B({applyDefaults:L().optional()}),H(P(),R())).optional(),url:Qc.optional()}),H(P(),R()).optional())),Ol=mc({list:Qc.optional(),cancel:Qc.optional(),requests:mc({sampling:mc({createMessage:Qc.optional()}).optional(),elicitation:mc({create:Qc.optional()}).optional()}).optional()}),kl=mc({list:Qc.optional(),cancel:Qc.optional(),requests:mc({tools:mc({call:Qc.optional()}).optional()}).optional()}),Al=B({experimental:H(P(),Qc).optional(),sampling:B({context:Qc.optional(),tools:Qc.optional()}).optional(),elicitation:Dl.optional(),roots:B({listChanged:L().optional()}).optional(),tasks:Ol.optional(),extensions:H(P(),Qc).optional()}),jl=il.extend({protocolVersion:P(),capabilities:Al,clientInfo:El}),Ml=sl.extend({method:U(`initialize`),params:jl}),Nl=B({experimental:H(P(),Qc).optional(),logging:Qc.optional(),completions:Qc.optional(),prompts:B({listChanged:L().optional()}).optional(),resources:B({subscribe:L().optional(),listChanged:L().optional()}).optional(),tools:B({listChanged:L().optional()}).optional(),tasks:kl.optional(),extensions:H(P(),Qc).optional()}),Pl=ul.extend({protocolVersion:P(),capabilities:Nl,serverInfo:El,instructions:P().optional()}),Fl=ll.extend({method:U(`notifications/initialized`),params:cl.optional()}),Il=e=>Fl.safeParse(e).success,Ll=sl.extend({method:U(`ping`),params:il.optional()}),Rl=B({progress:I(),total:W(I()),message:W(P())}),zl=B({...cl.shape,...Rl.shape,progressToken:$c}),Bl=ll.extend({method:U(`notifications/progress`),params:zl}),Vl=il.extend({cursor:el.optional()}),Hl=sl.extend({params:Vl.optional()}),Ul=ul.extend({nextCursor:el.optional()}),Wl=Sc([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Gl=B({taskId:P(),status:Wl,ttl:V([I(),oc()]),createdAt:P(),lastUpdatedAt:P(),pollInterval:W(I()),statusMessage:W(P())}),Kl=ul.extend({task:Gl}),ql=cl.merge(Gl),Jl=ll.extend({method:U(`notifications/tasks/status`),params:ql}),Yl=sl.extend({method:U(`tasks/get`),params:il.extend({taskId:P()})}),Xl=ul.merge(Gl),Zl=sl.extend({method:U(`tasks/result`),params:il.extend({taskId:P()})});ul.loose();const Ql=Hl.extend({method:U(`tasks/list`)}),$l=Ul.extend({tasks:z(Gl)}),eu=sl.extend({method:U(`tasks/cancel`),params:il.extend({taskId:P()})}),tu=ul.merge(Gl),nu=B({uri:P(),mimeType:W(P()),_meta:H(P(),R()).optional()}),ru=nu.extend({text:P()}),iu=P().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),au=nu.extend({blob:iu}),ou=Sc([`user`,`assistant`]),su=B({audience:z(ou).optional(),priority:I().min(0).max(1).optional(),lastModified:bs({offset:!0}).optional()}),cu=B({...Tl.shape,...wl.shape,uri:P(),description:W(P()),mimeType:W(P()),size:W(I()),annotations:su.optional(),_meta:W(mc({}))}),lu=B({...Tl.shape,...wl.shape,uriTemplate:P(),description:W(P()),mimeType:W(P()),annotations:su.optional(),_meta:W(mc({}))}),uu=Hl.extend({method:U(`resources/list`)}),du=Ul.extend({resources:z(cu)}),fu=Hl.extend({method:U(`resources/templates/list`)}),pu=Ul.extend({resourceTemplates:z(lu)}),mu=il.extend({uri:P()}),hu=mu,gu=sl.extend({method:U(`resources/read`),params:hu}),_u=ul.extend({contents:z(V([ru,au]))}),vu=ll.extend({method:U(`notifications/resources/list_changed`),params:cl.optional()}),yu=mu,bu=sl.extend({method:U(`resources/subscribe`),params:yu}),xu=mu,Su=sl.extend({method:U(`resources/unsubscribe`),params:xu}),Cu=cl.extend({uri:P()}),wu=ll.extend({method:U(`notifications/resources/updated`),params:Cu}),Tu=B({name:P(),description:W(P()),required:W(L())}),Eu=B({...Tl.shape,...wl.shape,description:W(P()),arguments:W(z(Tu)),_meta:W(mc({}))}),Du=Hl.extend({method:U(`prompts/list`)}),Ou=Ul.extend({prompts:z(Eu)}),ku=il.extend({name:P(),arguments:H(P(),P()).optional()}),Au=sl.extend({method:U(`prompts/get`),params:ku}),ju=B({type:U(`text`),text:P(),annotations:su.optional(),_meta:H(P(),R()).optional()}),Mu=B({type:U(`image`),data:iu,mimeType:P(),annotations:su.optional(),_meta:H(P(),R()).optional()}),Nu=B({type:U(`audio`),data:iu,mimeType:P(),annotations:su.optional(),_meta:H(P(),R()).optional()}),Pu=B({type:U(`tool_use`),name:P(),id:P(),input:H(P(),R()),_meta:H(P(),R()).optional()}),Fu=B({type:U(`resource`),resource:V([ru,au]),annotations:su.optional(),_meta:H(P(),R()).optional()}),Iu=V([ju,Mu,Nu,cu.extend({type:U(`resource_link`)}),Fu]),Lu=B({role:ou,content:Iu}),Ru=ul.extend({description:P().optional(),messages:z(Lu)}),zu=ll.extend({method:U(`notifications/prompts/list_changed`),params:cl.optional()}),Bu=B({title:P().optional(),readOnlyHint:L().optional(),destructiveHint:L().optional(),idempotentHint:L().optional(),openWorldHint:L().optional()}),Vu=B({taskSupport:Sc([`required`,`optional`,`forbidden`]).optional()}),Hu=B({...Tl.shape,...wl.shape,description:P().optional(),inputSchema:B({type:U(`object`),properties:H(P(),Qc).optional(),required:z(P()).optional()}).catchall(R()),outputSchema:B({type:U(`object`),properties:H(P(),Qc).optional(),required:z(P()).optional()}).catchall(R()).optional(),annotations:Bu.optional(),execution:Vu.optional(),_meta:H(P(),R()).optional()}),Uu=Hl.extend({method:U(`tools/list`)}),Wu=Ul.extend({tools:z(Hu)}),Gu=ul.extend({content:z(Iu).default([]),structuredContent:H(P(),R()).optional(),isError:L().optional()});Gu.or(ul.extend({toolResult:R()}));const Ku=al.extend({name:P(),arguments:H(P(),R()).optional()}),qu=sl.extend({method:U(`tools/call`),params:Ku}),Ju=ll.extend({method:U(`notifications/tools/list_changed`),params:cl.optional()}),Yu=B({autoRefresh:L().default(!0),debounceMs:I().int().nonnegative().default(300)}),Xu=Sc([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Zu=il.extend({level:Xu}),Qu=sl.extend({method:U(`logging/setLevel`),params:Zu}),$u=cl.extend({level:Xu,logger:P().optional(),data:R()}),ed=ll.extend({method:U(`notifications/message`),params:$u}),td=B({hints:z(B({name:P().optional()})).optional(),costPriority:I().min(0).max(1).optional(),speedPriority:I().min(0).max(1).optional(),intelligencePriority:I().min(0).max(1).optional()}),nd=B({mode:Sc([`auto`,`required`,`none`]).optional()}),rd=B({type:U(`tool_result`),toolUseId:P().describe(`The unique identifier for the corresponding tool call.`),content:z(Iu).default([]),structuredContent:B({}).loose().optional(),isError:L().optional(),_meta:H(P(),R()).optional()}),id=_c(`type`,[ju,Mu,Nu]),ad=_c(`type`,[ju,Mu,Nu,Pu,rd]),od=B({role:ou,content:V([ad,z(ad)]),_meta:H(P(),R()).optional()}),sd=al.extend({messages:z(od),modelPreferences:td.optional(),systemPrompt:P().optional(),includeContext:Sc([`none`,`thisServer`,`allServers`]).optional(),temperature:I().optional(),maxTokens:I().int(),stopSequences:z(P()).optional(),metadata:Qc.optional(),tools:z(Hu).optional(),toolChoice:nd.optional()}),cd=sl.extend({method:U(`sampling/createMessage`),params:sd}),ld=ul.extend({model:P(),stopReason:W(Sc([`endTurn`,`stopSequence`,`maxTokens`]).or(P())),role:ou,content:id}),ud=ul.extend({model:P(),stopReason:W(Sc([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(P())),role:ou,content:V([ad,z(ad)])}),dd=B({type:U(`boolean`),title:P().optional(),description:P().optional(),default:L().optional()}),fd=B({type:U(`string`),title:P().optional(),description:P().optional(),minLength:I().optional(),maxLength:I().optional(),format:Sc([`email`,`uri`,`date`,`date-time`]).optional(),default:P().optional()}),pd=B({type:Sc([`number`,`integer`]),title:P().optional(),description:P().optional(),minimum:I().optional(),maximum:I().optional(),default:I().optional()}),md=B({type:U(`string`),title:P().optional(),description:P().optional(),enum:z(P()),default:P().optional()}),hd=B({type:U(`string`),title:P().optional(),description:P().optional(),oneOf:z(B({const:P(),title:P()})),default:P().optional()}),gd=V([V([B({type:U(`string`),title:P().optional(),description:P().optional(),enum:z(P()),enumNames:z(P()).optional(),default:P().optional()}),V([md,hd]),V([B({type:U(`array`),title:P().optional(),description:P().optional(),minItems:I().optional(),maxItems:I().optional(),items:B({type:U(`string`),enum:z(P())}),default:z(P()).optional()}),B({type:U(`array`),title:P().optional(),description:P().optional(),minItems:I().optional(),maxItems:I().optional(),items:B({anyOf:z(B({const:P(),title:P()}))}),default:z(P()).optional()})])]),dd,fd,pd]),_d=V([al.extend({mode:U(`form`).optional(),message:P(),requestedSchema:B({type:U(`object`),properties:H(P(),gd),required:z(P()).optional()})}),al.extend({mode:U(`url`),message:P(),elicitationId:P(),url:P().url()})]),vd=sl.extend({method:U(`elicitation/create`),params:_d}),yd=cl.extend({elicitationId:P()}),bd=ll.extend({method:U(`notifications/elicitation/complete`),params:yd}),xd=ul.extend({action:Sc([`accept`,`decline`,`cancel`]),content:Kc(e=>e===null?void 0:e,H(P(),V([P(),I(),L(),z(P())])).optional())}),Sd=B({type:U(`ref/resource`),uri:P()}),Cd=B({type:U(`ref/prompt`),name:P()}),wd=il.extend({ref:V([Cd,Sd]),argument:B({name:P(),value:P()}),context:B({arguments:H(P(),P()).optional()}).optional()}),Td=sl.extend({method:U(`completion/complete`),params:wd}),Ed=ul.extend({completion:mc({values:z(P()).max(100),total:W(I().int()),hasMore:W(L())})}),Dd=B({uri:P().startsWith(`file://`),name:P().optional(),_meta:H(P(),R()).optional()}),Od=sl.extend({method:U(`roots/list`),params:il.optional()}),kd=ul.extend({roots:z(Dd)}),Ad=ll.extend({method:U(`notifications/roots/list_changed`),params:cl.optional()});V([Ll,Ml,Td,Qu,Au,Du,uu,fu,gu,bu,Su,qu,Uu,Yl,Zl,Ql,eu]),V([Cl,Bl,Fl,Ad,Jl]),V([xl,ld,ud,xd,kd,Xl,$l,Kl]),V([Ll,cd,vd,Od,Yl,Zl,Ql,eu]),V([Cl,Bl,ed,wu,vu,Ju,zu,Jl,bd]),V([xl,Pl,Ed,Ru,Ou,du,pu,_u,Gu,Wu,Xl,$l,Kl]);var K=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===G.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new jd(e.elicitations,n)}return new e(t,n,r)}},jd=class extends K{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(G.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Md(e){return e===`completed`||e===`failed`||e===`cancelled`}function Nd(e){let t=_s(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=vs(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function Pd(e,t){let n=gs(e,t);if(!n.success)throw n.error;return n.data}var Fd=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=/* @__PURE__ */ new Map,this._requestHandlerAbortControllers=/* @__PURE__ */ new Map,this._notificationHandlers=/* @__PURE__ */ new Map,this._responseHandlers=/* @__PURE__ */ new Map,this._progressHandlers=/* @__PURE__ */ new Map,this._timeoutInfo=/* @__PURE__ */ new Map,this._pendingDebouncedNotifications=/* @__PURE__ */ new Set,this._taskProgressTokens=/* @__PURE__ */ new Map,this._requestResolvers=/* @__PURE__ */ new Map,this.setNotificationHandler(Cl,e=>{this._oncancel(e)}),this.setNotificationHandler(Bl,e=>{this._onprogress(e)}),this.setRequestHandler(Ll,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Yl,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new K(G.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(Zl,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(!await this._taskStore.getTask(r,t.sessionId))throw new K(G.InvalidParams,`Task not found: ${r}`);if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new K(e.error.code,e.error.message,e.error.data))}}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(/* @__PURE__ */ Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new K(G.InvalidParams,`Task not found: ${r}`);if(!Md(i.status))return await this._waitForTaskUpdate(r,t.signal,t.sessionId),await n();if(Md(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r,t.sessionId),{...e,_meta:{...e._meta,[Zc]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(Ql,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new K(G.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(eu,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new K(G.InvalidParams,`Task not found: ${e.params.taskId}`);if(Md(n.status))throw new K(G.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId,t.sessionId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new K(G.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof K?e:new K(G.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),K.fromError(G.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw 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 t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),_l(e)||yl(e)?this._onresponse(e):pl(e)?this._onrequest(e,t):hl(e)?this._onnotification(e):this._onerror(/* @__PURE__ */ Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=/* @__PURE__ */ new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=K.fromError(G.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(/* @__PURE__ */ Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[Zc]?.taskId,a=r?.sessionId,o=this._taskStore,s=!0,c;if(i&&o&&this._taskMessageQueue&&a!==void 0&&(s=!1,c=(async()=>{if(!await o.getTask(i,a))throw new K(G.InvalidParams,`Task not found: ${i}`);s=!0})()),n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:G.MethodNotFound,message:`Method not found`}};if(i&&c){let e={type:`error`,message:t,timestamp:Date.now()};c.then(()=>this._enqueueTaskMessage(i,e,a),()=>r?.send(t)).catch(e=>this._onerror(/* @__PURE__ */ Error(`Failed to send an error response: ${e}`)))}else i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(/* @__PURE__ */ Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(/* @__PURE__ */ Error(`Failed to send an error response: ${e}`)));return}let l=new AbortController;this._requestHandlerAbortControllers.set(e.id,l);let u=ol(e.params)?e.params.task:void 0,d=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,f={signal:l.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(l.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(l.signal.aborted)throw new K(G.ConnectionClosed,`Request was cancelled`);let a={...r,relatedRequestId:e.id};i&&!a.relatedTask&&(a.relatedTask={taskId:i});let o=a.relatedTask?.taskId??i;return o&&d&&await d.updateTaskStatus(o,`input_required`),await this.request(t,n,a)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:d,taskRequestedTtl:u?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};(c??Promise.resolve()).then(()=>{if(c&&l.signal.aborted)throw new K(G.ConnectionClosed,`Request was cancelled`);u&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,f)).then(async t=>{if(l.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(l.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:G.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue&&s?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(/* @__PURE__ */ Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===l&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(/* @__PURE__ */ Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),_l(e)?n(e):n(new K(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(/* @__PURE__ */ Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(_l(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),_l(e)?r(e):r(K.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof K?e:new K(G.InternalError,String(e))}}return}let i;try{let r=await this.request(e,Kl,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new K(G.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},Md(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new K(G.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new K(G.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof K?e:new K(G.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(/* @__PURE__ */ Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[Zc]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(/* @__PURE__ */ Error(`Failed to send cancellation: ${e}`))),l(e instanceof K?e:new K(G.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=gs(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(K.fromError(G.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(/* @__PURE__ */ Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},Xl,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},$l,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},tu,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[Zc]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.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 n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[Zc]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[Zc]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=Nd(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=Pd(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=Nd(e);this._notificationHandlers.set(n,n=>{let r=Pd(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n??this._transport?.sessionId,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&pl(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new K(G.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(/* @__PURE__ */ Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t,n){let r=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e,n);t?.pollInterval&&(r=t.pollInterval)}catch{}return new Promise((e,n)=>{if(t.aborted){n(new K(G.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,r);t.addEventListener(`abort`,()=>{clearTimeout(i),n(new K(G.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new K(G.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=Jl.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),Md(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new K(G.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Md(a.status))throw new K(G.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=Jl.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),Md(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function Id(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ld(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=Id(a)&&Id(i)?{...a,...i}:i}return n}var Rd=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{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(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),zd=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Rd();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=/* @__PURE__ */ new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||/* @__PURE__ */ new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),q=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=Rd(),n=zd();var r=Rd();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=zd();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=ce(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ce(this.rhs,e,n),this}get names(){return se(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=ce(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(le(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>oe(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(ue(t),n instanceof e?[n]:n.nodes);if(t!==!1&&this.nodes.length)return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=ce(this.condition,e,t),this}get names(){let e=super.names;return se(e,this.condition),this.else&&oe(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=ce(this.iteration,e,t),this}get names(){return oe(super.names,this.iteration.names)}},ee=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return se(se(super.names,this.from),this.to)}},b=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=ce(this.iterable,e,t),this}get names(){return oe(super.names,this.iterable.names)}},te=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};te.kind=`func`;var ne=class extends p{render(e){return`return `+super.render(e)}};ne.kind=`return`;var re=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&oe(e,this.catch.names),this.finally&&oe(e,this.finally.names),e}},ie=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ie.kind=`catch`;var ae=class extends m{render(e){return`finally`+super.render(e)}};ae.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
31
- `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=/* @__PURE__ */ new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new ee(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new b(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new b(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new ne;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(ne)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new re;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new ie(e),t(e)}return n&&(this._currNode=r.finally=new ae,this.code(n)),this._endBlockNode(ie,ae)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new te(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(te)}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,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function oe(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function se(e,n){return n instanceof t._CodeOrName?oe(e,n.names):e}function ce(e,n,r){return e instanceof t.Name?i(e):a(e)?new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[])):e;function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function le(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function ue(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${x(e)}`}e.not=ue;let de=he(e.operators.AND);function fe(...e){return e.reduce(de)}e.and=fe;let pe=he(e.operators.OR);function me(...e){return e.reduce(pe)}e.or=me;function he(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${x(n)} ${e} ${x(r)}`}function x(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),J=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=q(),n=Rd();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0||(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||b(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0||{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0||(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0||Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;let _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function ee(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=ee;function b(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=b})),Bd=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),Vd=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=q(),n=J(),r=Bd();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){
29
+ path: iss.path ? [${Fr(e)}, ...iss.path] : [${Fr(e)}]
30
+ })));`),t.write(`newResult[${Fr(e)}] = ${n}.value`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},i,a=Lr,o=!Er.jitless,s=o&&Rr.value,c=t.catchall,l;e._zod.parse=(u,d)=>{l??=n.value;let f=u.value;if(!a(f))return u.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),u;let p=[];if(o&&s&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),u=i(u,d);else{u.value={};let e=l.shape;for(let t of l.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?qa(e,u,t,f):Ka(e,u,t))):i?qa(r,u,t,f):Ka(r,u,t)}}if(!c)return p.length?Promise.all(p).then(()=>u):u;let m=[],h=l.keySet,g=c._zod,_=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(_===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>Ka(t,u,e))):Ka(t,u,e)}return m.length&&u.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>u):u}});function Ya(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>ei(e,r,Dr())))}),t}const Xa=/*@__PURE__*/ A(`$ZodUnion`,(e,t)=>{N.init(e,t),j(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),j(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),j(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),j(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Mr(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>Ya(t,n,e,r)):Ya(a,n,e,r)}}),Za=/*@__PURE__*/ A(`$ZodDiscriminatedUnion`,(e,t)=>{Xa.init(e,t);let n=e._zod.parse;j(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=/* @__PURE__ */ new Set);for(let r of n)e[t].add(r)}}return e});let r=Ar(()=>{let e=t.options,n=/* @__PURE__ */ new Map;for(let r of e){let e=r._zod.propValues[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Lr(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,input:o,path:[t.discriminator],inst:e}),i)}}),Qa=/*@__PURE__*/ A(`$ZodIntersection`,(e,t)=>{N.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>eo(e,t,n)):eo(e,i,a)}});function $a(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(zr(e)&&zr(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=$a(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=$a(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function eo(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Zr(e))return e;let r=$a(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const to=/*@__PURE__*/ A(`$ZodRecord`,(e,t)=>{N.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!zr(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Qr(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Qr(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>ei(e,r,Dr())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Qr(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Qr(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),no=/*@__PURE__*/ A(`$ZodEnum`,(e,t)=>{N.init(e,t);let n=Or(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>Br.has(typeof e)).map(e=>typeof e==`string`?Vr(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),ro=/*@__PURE__*/ A(`$ZodLiteral`,(e,t)=>{N.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Vr(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),io=/*@__PURE__*/ A(`$ZodTransform`,(e,t)=>{N.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(t=>(e.value=t,e));if(r instanceof Promise)throw new Tr;return e.value=r,e}}),ao=/*@__PURE__*/ A(`$ZodOptional`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,j(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,void 0]):void 0),j(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Mr(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),oo=/*@__PURE__*/ A(`$ZodNullable`,(e,t)=>{N.init(e,t),j(e._zod,`optin`,()=>t.innerType._zod.optin),j(e._zod,`optout`,()=>t.innerType._zod.optout),j(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Mr(e.source)}|null)$`):void 0}),j(e._zod,`values`,()=>t.innerType._zod.values?/* @__PURE__ */ new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),so=/*@__PURE__*/ A(`$ZodDefault`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,j(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>co(e,t)):co(r,t)}});function co(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const lo=/*@__PURE__*/ A(`$ZodPrefault`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,j(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),uo=/*@__PURE__*/ A(`$ZodNonOptional`,(e,t)=>{N.init(e,t),j(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>fo(t,e)):fo(i,e)}});function fo(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const po=/*@__PURE__*/ A(`$ZodCatch`,(e,t)=>{N.init(e,t),e._zod.optin=`optional`,j(e._zod,`optout`,()=>t.innerType._zod.optout),j(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>ei(e,n,Dr()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>ei(e,n,Dr()))},input:e.value}),e.issues=[]),e)}}),mo=/*@__PURE__*/ A(`$ZodPipe`,(e,t)=>{N.init(e,t),j(e._zod,`values`,()=>t.in._zod.values),j(e._zod,`optin`,()=>t.in._zod.optin),j(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ho(e,t,n)):ho(r,t,n)}});function ho(e,t,n){return Zr(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const go=/*@__PURE__*/ A(`$ZodReadonly`,(e,t)=>{N.init(e,t),j(e._zod,`propValues`,()=>t.innerType._zod.propValues),j(e._zod,`values`,()=>t.innerType._zod.values),j(e._zod,`optin`,()=>t.innerType._zod.optin),j(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(_o):_o(r)}});function _o(e){return e.value=Object.freeze(e.value),e}const vo=/*@__PURE__*/ A(`$ZodCustom`,(e,t)=>{Gi.init(e,t),N.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>yo(t,n,r,e));yo(i,n,r,e)}});function yo(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(ni(e))}}var bo=class{constructor(){this._map=/* @__PURE__ */ new Map,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=/* @__PURE__ */ new Map,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function xo(){return new bo}const So=/*@__PURE__*/ xo();function Co(e,t){return new e({type:`string`,...M(t)})}function wo(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...M(t)})}function To(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...M(t)})}function Eo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...M(t)})}function Do(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...M(t)})}function Oo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...M(t)})}function ko(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...M(t)})}function Ao(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...M(t)})}function jo(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...M(t)})}function Mo(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...M(t)})}function No(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...M(t)})}function Po(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...M(t)})}function Fo(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...M(t)})}function Io(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...M(t)})}function Lo(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...M(t)})}function Ro(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...M(t)})}function zo(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...M(t)})}function Bo(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...M(t)})}function Vo(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...M(t)})}function Ho(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...M(t)})}function Uo(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...M(t)})}function Wo(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...M(t)})}function Go(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...M(t)})}function Ko(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...M(t)})}function qo(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...M(t)})}function Jo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...M(t)})}function Yo(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...M(t)})}function Xo(e,t){return new e({type:`number`,checks:[],...M(t)})}function Zo(e,t){return new e({type:`number`,coerce:!0,checks:[],...M(t)})}function Qo(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...M(t)})}function $o(e,t){return new e({type:`boolean`,...M(t)})}function es(e,t){return new e({type:`null`,...M(t)})}function ts(e){return new e({type:`any`})}function ns(e){return new e({type:`unknown`})}function rs(e,t){return new e({type:`never`,...M(t)})}function is(e,t){return new qi({check:`less_than`,...M(t),value:e,inclusive:!1})}function as(e,t){return new qi({check:`less_than`,...M(t),value:e,inclusive:!0})}function os(e,t){return new Ji({check:`greater_than`,...M(t),value:e,inclusive:!1})}function ss(e,t){return new Ji({check:`greater_than`,...M(t),value:e,inclusive:!0})}function cs(e,t){return new Yi({check:`multiple_of`,...M(t),value:e})}function ls(e,t){return new Zi({check:`max_length`,...M(t),maximum:e})}function us(e,t){return new Qi({check:`min_length`,...M(t),minimum:e})}function ds(e,t){return new $i({check:`length_equals`,...M(t),length:e})}function fs(e,t){return new ta({check:`string_format`,format:`regex`,...M(t),pattern:e})}function ps(e){return new na({check:`string_format`,format:`lowercase`,...M(e)})}function ms(e){return new ra({check:`string_format`,format:`uppercase`,...M(e)})}function hs(e,t){return new ia({check:`string_format`,format:`includes`,...M(t),includes:e})}function gs(e,t){return new aa({check:`string_format`,format:`starts_with`,...M(t),prefix:e})}function _s(e,t){return new oa({check:`string_format`,format:`ends_with`,...M(t),suffix:e})}function vs(e){return new sa({check:`overwrite`,tx:e})}function ys(e){return vs(t=>t.normalize(e))}function bs(){return vs(e=>e.trim())}function xs(){return vs(e=>e.toLowerCase())}function Ss(){return vs(e=>e.toUpperCase())}function Cs(e,t,n){return new e({type:`array`,element:t,...M(n)})}function ws(e,t,n){let r=M(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Ts(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...M(n)})}function Es(e){return!!e._zod}function Ds(e,t){return Es(e)?di(e,t):e.safeParse(t)}function Os(e){if(!e)return;let t;if(t=Es(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function ks(e){if(Es(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}const As=/*@__PURE__*/ A(`ZodISODateTime`,(e,t)=>{Sa.init(e,t),L.init(e,t)});function js(e){return Ko(As,e)}const Ms=/*@__PURE__*/ A(`ZodISODate`,(e,t)=>{Ca.init(e,t),L.init(e,t)});function Ns(e){return qo(Ms,e)}const Ps=/*@__PURE__*/ A(`ZodISOTime`,(e,t)=>{wa.init(e,t),L.init(e,t)});function Fs(e){return Jo(Ps,e)}const Is=/*@__PURE__*/ A(`ZodISODuration`,(e,t)=>{Ta.init(e,t),L.init(e,t)});function Ls(e){return Yo(Is,e)}const Rs=(e,t)=>{ii.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>si(e,t)},flatten:{value:t=>oi(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})};A(`ZodError`,Rs);const zs=A(`ZodError`,Rs,{Parent:Error}),Bs=/* @__PURE__ */ ci(zs),Vs=/* @__PURE__ */ li(zs),Hs=/* @__PURE__ */ ui(zs),Us=/* @__PURE__ */ fi(zs),F=/*@__PURE__*/ A(`ZodType`,(e,t)=>(N.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>Hr(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Bs(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Hs(e,t,n),e.parseAsync=async(t,n)=>Vs(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Us(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(rl(t,n)),e.superRefine=t=>e.check(il(t)),e.overwrite=t=>e.check(vs(t)),e.optional=()=>zc(e),e.nullable=()=>Vc(e),e.nullish=()=>zc(Vc(e)),e.nonoptional=t=>qc(e,t),e.array=()=>B(e),e.or=t=>H([e,t]),e.and=t=>jc(e,t),e.transform=t=>Zc(e,Lc(t)),e.default=t=>Uc(e,t),e.prefault=t=>Gc(e,t),e.catch=t=>Yc(e,t),e.pipe=t=>Zc(e,t),e.readonly=()=>$c(e),e.describe=t=>{let n=e.clone();return So.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return So.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return So.get(e);let n=e.clone();return So.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Ws=/*@__PURE__*/ A(`_ZodString`,(e,t)=>{ua.init(e,t),F.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(fs(...t)),e.includes=(...t)=>e.check(hs(...t)),e.startsWith=(...t)=>e.check(gs(...t)),e.endsWith=(...t)=>e.check(_s(...t)),e.min=(...t)=>e.check(us(...t)),e.max=(...t)=>e.check(ls(...t)),e.length=(...t)=>e.check(ds(...t)),e.nonempty=(...t)=>e.check(us(1,...t)),e.lowercase=t=>e.check(ps(t)),e.uppercase=t=>e.check(ms(t)),e.trim=()=>e.check(bs()),e.normalize=(...t)=>e.check(ys(...t)),e.toLowerCase=()=>e.check(xs()),e.toUpperCase=()=>e.check(Ss())}),Gs=/*@__PURE__*/ A(`ZodString`,(e,t)=>{ua.init(e,t),Ws.init(e,t),e.email=t=>e.check(wo(Ks,t)),e.url=t=>e.check(Ao(Ys,t)),e.jwt=t=>e.check(Go(dc,t)),e.emoji=t=>e.check(jo(Zs,t)),e.guid=t=>e.check(To(qs,t)),e.uuid=t=>e.check(Eo(Js,t)),e.uuidv4=t=>e.check(Do(Js,t)),e.uuidv6=t=>e.check(Oo(Js,t)),e.uuidv7=t=>e.check(ko(Js,t)),e.nanoid=t=>e.check(Mo(Qs,t)),e.guid=t=>e.check(To(qs,t)),e.cuid=t=>e.check(No($s,t)),e.cuid2=t=>e.check(Po(ec,t)),e.ulid=t=>e.check(Fo(tc,t)),e.base64=t=>e.check(Ho(cc,t)),e.base64url=t=>e.check(Uo(lc,t)),e.xid=t=>e.check(Io(nc,t)),e.ksuid=t=>e.check(Lo(rc,t)),e.ipv4=t=>e.check(Ro(ic,t)),e.ipv6=t=>e.check(zo(ac,t)),e.cidrv4=t=>e.check(Bo(oc,t)),e.cidrv6=t=>e.check(Vo(sc,t)),e.e164=t=>e.check(Wo(uc,t)),e.datetime=t=>e.check(js(t)),e.date=t=>e.check(Ns(t)),e.time=t=>e.check(Fs(t)),e.duration=t=>e.check(Ls(t))});function I(e){return Co(Gs,e)}const L=/*@__PURE__*/ A(`ZodStringFormat`,(e,t)=>{P.init(e,t),Ws.init(e,t)}),Ks=/*@__PURE__*/ A(`ZodEmail`,(e,t)=>{pa.init(e,t),L.init(e,t)}),qs=/*@__PURE__*/ A(`ZodGUID`,(e,t)=>{da.init(e,t),L.init(e,t)}),Js=/*@__PURE__*/ A(`ZodUUID`,(e,t)=>{fa.init(e,t),L.init(e,t)}),Ys=/*@__PURE__*/ A(`ZodURL`,(e,t)=>{ma.init(e,t),L.init(e,t)});function Xs(e){return Ao(Ys,e)}const Zs=/*@__PURE__*/ A(`ZodEmoji`,(e,t)=>{ha.init(e,t),L.init(e,t)}),Qs=/*@__PURE__*/ A(`ZodNanoID`,(e,t)=>{ga.init(e,t),L.init(e,t)}),$s=/*@__PURE__*/ A(`ZodCUID`,(e,t)=>{_a.init(e,t),L.init(e,t)}),ec=/*@__PURE__*/ A(`ZodCUID2`,(e,t)=>{va.init(e,t),L.init(e,t)}),tc=/*@__PURE__*/ A(`ZodULID`,(e,t)=>{ya.init(e,t),L.init(e,t)}),nc=/*@__PURE__*/ A(`ZodXID`,(e,t)=>{ba.init(e,t),L.init(e,t)}),rc=/*@__PURE__*/ A(`ZodKSUID`,(e,t)=>{xa.init(e,t),L.init(e,t)}),ic=/*@__PURE__*/ A(`ZodIPv4`,(e,t)=>{Ea.init(e,t),L.init(e,t)}),ac=/*@__PURE__*/ A(`ZodIPv6`,(e,t)=>{Da.init(e,t),L.init(e,t)}),oc=/*@__PURE__*/ A(`ZodCIDRv4`,(e,t)=>{Oa.init(e,t),L.init(e,t)}),sc=/*@__PURE__*/ A(`ZodCIDRv6`,(e,t)=>{ka.init(e,t),L.init(e,t)}),cc=/*@__PURE__*/ A(`ZodBase64`,(e,t)=>{ja.init(e,t),L.init(e,t)}),lc=/*@__PURE__*/ A(`ZodBase64URL`,(e,t)=>{Na.init(e,t),L.init(e,t)}),uc=/*@__PURE__*/ A(`ZodE164`,(e,t)=>{Pa.init(e,t),L.init(e,t)}),dc=/*@__PURE__*/ A(`ZodJWT`,(e,t)=>{Ia.init(e,t),L.init(e,t)}),fc=/*@__PURE__*/ A(`ZodNumber`,(e,t)=>{La.init(e,t),F.init(e,t),e.gt=(t,n)=>e.check(os(t,n)),e.gte=(t,n)=>e.check(ss(t,n)),e.min=(t,n)=>e.check(ss(t,n)),e.lt=(t,n)=>e.check(is(t,n)),e.lte=(t,n)=>e.check(as(t,n)),e.max=(t,n)=>e.check(as(t,n)),e.int=t=>e.check(mc(t)),e.safe=t=>e.check(mc(t)),e.positive=t=>e.check(os(0,t)),e.nonnegative=t=>e.check(ss(0,t)),e.negative=t=>e.check(is(0,t)),e.nonpositive=t=>e.check(as(0,t)),e.multipleOf=(t,n)=>e.check(cs(t,n)),e.step=(t,n)=>e.check(cs(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function R(e){return Xo(fc,e)}const pc=/*@__PURE__*/ A(`ZodNumberFormat`,(e,t)=>{Ra.init(e,t),fc.init(e,t)});function mc(e){return Qo(pc,e)}const hc=/*@__PURE__*/ A(`ZodBoolean`,(e,t)=>{za.init(e,t),F.init(e,t)});function z(e){return $o(hc,e)}const gc=/*@__PURE__*/ A(`ZodNull`,(e,t)=>{Ba.init(e,t),F.init(e,t)});function _c(e){return es(gc,e)}const vc=/*@__PURE__*/ A(`ZodAny`,(e,t)=>{Va.init(e,t),F.init(e,t)});function yc(){return ts(vc)}const bc=/*@__PURE__*/ A(`ZodUnknown`,(e,t)=>{Ha.init(e,t),F.init(e,t)});function xc(){return ns(bc)}const Sc=/*@__PURE__*/ A(`ZodNever`,(e,t)=>{Ua.init(e,t),F.init(e,t)});function Cc(e){return rs(Sc,e)}const wc=/*@__PURE__*/ A(`ZodArray`,(e,t)=>{Ga.init(e,t),F.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(us(t,n)),e.nonempty=t=>e.check(us(1,t)),e.max=(t,n)=>e.check(ls(t,n)),e.length=(t,n)=>e.check(ds(t,n)),e.unwrap=()=>e.element});function B(e,t){return Cs(wc,e,t)}const Tc=/*@__PURE__*/ A(`ZodObject`,(e,t)=>{Ja.init(e,t),F.init(e,t),j(e,`shape`,()=>t.shape),e.keyof=()=>Pc(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:xc()}),e.loose=()=>e.clone({...e._zod.def,catchall:xc()}),e.strict=()=>e.clone({...e._zod.def,catchall:Cc()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>qr(e,t),e.merge=t=>Jr(e,t),e.pick=t=>Gr(e,t),e.omit=t=>Kr(e,t),e.partial=(...t)=>Yr(Rc,e,t[0]),e.required=(...t)=>Xr(Kc,e,t[0])});function V(e,t){let n={type:`object`,get shape(){return Pr(this,`shape`,{...e}),this.shape},...M(t)};return new Tc(n)}function Ec(e,t){return new Tc({type:`object`,get shape(){return Pr(this,`shape`,{...e}),this.shape},catchall:xc(),...M(t)})}const Dc=/*@__PURE__*/ A(`ZodUnion`,(e,t)=>{Xa.init(e,t),F.init(e,t),e.options=t.options});function H(e,t){return new Dc({type:`union`,options:e,...M(t)})}const Oc=/*@__PURE__*/ A(`ZodDiscriminatedUnion`,(e,t)=>{Dc.init(e,t),Za.init(e,t)});function kc(e,t,n){return new Oc({type:`union`,options:t,discriminator:e,...M(n)})}const Ac=/*@__PURE__*/ A(`ZodIntersection`,(e,t)=>{Qa.init(e,t),F.init(e,t)});function jc(e,t){return new Ac({type:`intersection`,left:e,right:t})}const Mc=/*@__PURE__*/ A(`ZodRecord`,(e,t)=>{to.init(e,t),F.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function U(e,t,n){return new Mc({type:`record`,keyType:e,valueType:t,...M(n)})}const Nc=/*@__PURE__*/ A(`ZodEnum`,(e,t)=>{no.init(e,t),F.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Nc({...t,checks:[],...M(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Nc({...t,checks:[],...M(r),entries:i})}});function Pc(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Nc({type:`enum`,entries:n,...M(t)})}const Fc=/*@__PURE__*/ A(`ZodLiteral`,(e,t)=>{ro.init(e,t),F.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function W(e,t){return new Fc({type:`literal`,values:Array.isArray(e)?e:[e],...M(t)})}const Ic=/*@__PURE__*/ A(`ZodTransform`,(e,t)=>{io.init(e,t),F.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(ni(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(ni(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Lc(e){return new Ic({type:`transform`,transform:e})}const Rc=/*@__PURE__*/ A(`ZodOptional`,(e,t)=>{ao.init(e,t),F.init(e,t),e.unwrap=()=>e._zod.def.innerType});function zc(e){return new Rc({type:`optional`,innerType:e})}const Bc=/*@__PURE__*/ A(`ZodNullable`,(e,t)=>{oo.init(e,t),F.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Vc(e){return new Bc({type:`nullable`,innerType:e})}const Hc=/*@__PURE__*/ A(`ZodDefault`,(e,t)=>{so.init(e,t),F.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Uc(e,t){return new Hc({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const Wc=/*@__PURE__*/ A(`ZodPrefault`,(e,t)=>{lo.init(e,t),F.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Gc(e,t){return new Wc({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}const Kc=/*@__PURE__*/ A(`ZodNonOptional`,(e,t)=>{uo.init(e,t),F.init(e,t),e.unwrap=()=>e._zod.def.innerType});function qc(e,t){return new Kc({type:`nonoptional`,innerType:e,...M(t)})}const Jc=/*@__PURE__*/ A(`ZodCatch`,(e,t)=>{po.init(e,t),F.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Yc(e,t){return new Jc({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Xc=/*@__PURE__*/ A(`ZodPipe`,(e,t)=>{mo.init(e,t),F.init(e,t),e.in=t.in,e.out=t.out});function Zc(e,t){return new Xc({type:`pipe`,in:e,out:t})}const Qc=/*@__PURE__*/ A(`ZodReadonly`,(e,t)=>{go.init(e,t),F.init(e,t)});function $c(e){return new Qc({type:`readonly`,innerType:e})}const el=/*@__PURE__*/ A(`ZodCustom`,(e,t)=>{vo.init(e,t),F.init(e,t)});function tl(e){let t=new Gi({check:`custom`});return t._zod.check=e,t}function nl(e,t){return ws(el,e??(()=>!0),t)}function rl(e,t={}){return Ts(el,e,t)}function il(e){let t=tl(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(ni(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(ni(r))}},e(n.value,n)));return t}function al(e,t){return Zc(Lc(e),t)}const ol={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`};function sl(e){return Zo(fc,e)}const cl=`2025-11-25`,ll=[cl,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],ul=`io.modelcontextprotocol/related-task`,dl=nl(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),fl=H([I(),R().int()]),pl=I();Ec({ttl:R().optional(),pollInterval:R().optional()});const ml=V({ttl:R().optional()}),hl=V({taskId:I()}),gl=Ec({progressToken:fl.optional(),[ul]:hl.optional()}),_l=V({_meta:gl.optional()}),vl=_l.extend({task:ml.optional()}),yl=e=>vl.safeParse(e).success,bl=V({method:I(),params:_l.loose().optional()}),xl=V({_meta:gl.optional()}),Sl=V({method:I(),params:xl.loose().optional()}),Cl=Ec({_meta:gl.optional()}),wl=H([I(),R().int()]),Tl=V({jsonrpc:W(`2.0`),id:wl,...bl.shape}).strict(),El=e=>Tl.safeParse(e).success,Dl=V({jsonrpc:W(`2.0`),...Sl.shape}).strict(),Ol=e=>Dl.safeParse(e).success,kl=V({jsonrpc:W(`2.0`),id:wl,result:Cl}).strict(),Al=e=>kl.safeParse(e).success;var G;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(G||={});const jl=V({jsonrpc:W(`2.0`),id:wl.optional(),error:V({code:R().int(),message:I(),data:xc().optional()})}).strict(),Ml=e=>jl.safeParse(e).success,Nl=H([Tl,Dl,kl,jl]);H([kl,jl]);const Pl=Cl.strict(),Fl=xl.extend({requestId:wl.optional(),reason:I().optional()}),Il=Sl.extend({method:W(`notifications/cancelled`),params:Fl}),Ll=V({icons:B(V({src:I(),mimeType:I().optional(),sizes:B(I()).optional(),theme:Pc([`light`,`dark`]).optional()})).optional()}),Rl=V({name:I(),title:I().optional()}),zl=Rl.extend({...Rl.shape,...Ll.shape,version:I(),websiteUrl:I().optional(),description:I().optional()}),Bl=al(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,jc(V({form:jc(V({applyDefaults:z().optional()}),U(I(),xc())).optional(),url:dl.optional()}),U(I(),xc()).optional())),Vl=Ec({list:dl.optional(),cancel:dl.optional(),requests:Ec({sampling:Ec({createMessage:dl.optional()}).optional(),elicitation:Ec({create:dl.optional()}).optional()}).optional()}),Hl=Ec({list:dl.optional(),cancel:dl.optional(),requests:Ec({tools:Ec({call:dl.optional()}).optional()}).optional()}),Ul=V({experimental:U(I(),dl).optional(),sampling:V({context:dl.optional(),tools:dl.optional()}).optional(),elicitation:Bl.optional(),roots:V({listChanged:z().optional()}).optional(),tasks:Vl.optional(),extensions:U(I(),dl).optional()}),Wl=_l.extend({protocolVersion:I(),capabilities:Ul,clientInfo:zl}),Gl=bl.extend({method:W(`initialize`),params:Wl}),Kl=V({experimental:U(I(),dl).optional(),logging:dl.optional(),completions:dl.optional(),prompts:V({listChanged:z().optional()}).optional(),resources:V({subscribe:z().optional(),listChanged:z().optional()}).optional(),tools:V({listChanged:z().optional()}).optional(),tasks:Hl.optional(),extensions:U(I(),dl).optional()}),ql=Cl.extend({protocolVersion:I(),capabilities:Kl,serverInfo:zl,instructions:I().optional()}),Jl=Sl.extend({method:W(`notifications/initialized`),params:xl.optional()}),Yl=e=>Jl.safeParse(e).success,Xl=bl.extend({method:W(`ping`),params:_l.optional()}),Zl=V({progress:R(),total:zc(R()),message:zc(I())}),Ql=V({...xl.shape,...Zl.shape,progressToken:fl}),$l=Sl.extend({method:W(`notifications/progress`),params:Ql}),eu=_l.extend({cursor:pl.optional()}),tu=bl.extend({params:eu.optional()}),nu=Cl.extend({nextCursor:pl.optional()}),ru=Pc([`working`,`input_required`,`completed`,`failed`,`cancelled`]),iu=V({taskId:I(),status:ru,ttl:H([R(),_c()]),createdAt:I(),lastUpdatedAt:I(),pollInterval:zc(R()),statusMessage:zc(I())}),au=Cl.extend({task:iu}),ou=xl.merge(iu),su=Sl.extend({method:W(`notifications/tasks/status`),params:ou}),cu=bl.extend({method:W(`tasks/get`),params:_l.extend({taskId:I()})}),lu=Cl.merge(iu),uu=bl.extend({method:W(`tasks/result`),params:_l.extend({taskId:I()})});Cl.loose();const du=tu.extend({method:W(`tasks/list`)}),fu=nu.extend({tasks:B(iu)}),pu=bl.extend({method:W(`tasks/cancel`),params:_l.extend({taskId:I()})}),mu=Cl.merge(iu),hu=V({uri:I(),mimeType:zc(I()),_meta:U(I(),xc()).optional()}),gu=hu.extend({text:I()}),_u=I().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),vu=hu.extend({blob:_u}),yu=Pc([`user`,`assistant`]),bu=V({audience:B(yu).optional(),priority:R().min(0).max(1).optional(),lastModified:js({offset:!0}).optional()}),xu=V({...Rl.shape,...Ll.shape,uri:I(),description:zc(I()),mimeType:zc(I()),size:zc(R()),annotations:bu.optional(),_meta:zc(Ec({}))}),Su=V({...Rl.shape,...Ll.shape,uriTemplate:I(),description:zc(I()),mimeType:zc(I()),annotations:bu.optional(),_meta:zc(Ec({}))}),Cu=tu.extend({method:W(`resources/list`)}),wu=nu.extend({resources:B(xu)}),Tu=tu.extend({method:W(`resources/templates/list`)}),Eu=nu.extend({resourceTemplates:B(Su)}),Du=_l.extend({uri:I()}),Ou=Du,ku=bl.extend({method:W(`resources/read`),params:Ou}),Au=Cl.extend({contents:B(H([gu,vu]))}),ju=Sl.extend({method:W(`notifications/resources/list_changed`),params:xl.optional()}),Mu=Du,Nu=bl.extend({method:W(`resources/subscribe`),params:Mu}),Pu=Du,Fu=bl.extend({method:W(`resources/unsubscribe`),params:Pu}),Iu=xl.extend({uri:I()}),Lu=Sl.extend({method:W(`notifications/resources/updated`),params:Iu}),Ru=V({name:I(),description:zc(I()),required:zc(z())}),zu=V({...Rl.shape,...Ll.shape,description:zc(I()),arguments:zc(B(Ru)),_meta:zc(Ec({}))}),Bu=tu.extend({method:W(`prompts/list`)}),Vu=nu.extend({prompts:B(zu)}),Hu=_l.extend({name:I(),arguments:U(I(),I()).optional()}),Uu=bl.extend({method:W(`prompts/get`),params:Hu}),Wu=V({type:W(`text`),text:I(),annotations:bu.optional(),_meta:U(I(),xc()).optional()}),Gu=V({type:W(`image`),data:_u,mimeType:I(),annotations:bu.optional(),_meta:U(I(),xc()).optional()}),Ku=V({type:W(`audio`),data:_u,mimeType:I(),annotations:bu.optional(),_meta:U(I(),xc()).optional()}),qu=V({type:W(`tool_use`),name:I(),id:I(),input:U(I(),xc()),_meta:U(I(),xc()).optional()}),Ju=V({type:W(`resource`),resource:H([gu,vu]),annotations:bu.optional(),_meta:U(I(),xc()).optional()}),Yu=H([Wu,Gu,Ku,xu.extend({type:W(`resource_link`)}),Ju]),Xu=V({role:yu,content:Yu}),Zu=Cl.extend({description:I().optional(),messages:B(Xu)}),Qu=Sl.extend({method:W(`notifications/prompts/list_changed`),params:xl.optional()}),$u=V({title:I().optional(),readOnlyHint:z().optional(),destructiveHint:z().optional(),idempotentHint:z().optional(),openWorldHint:z().optional()}),ed=V({taskSupport:Pc([`required`,`optional`,`forbidden`]).optional()}),td=V({...Rl.shape,...Ll.shape,description:I().optional(),inputSchema:V({type:W(`object`),properties:U(I(),dl).optional(),required:B(I()).optional()}).catchall(xc()),outputSchema:V({type:W(`object`),properties:U(I(),dl).optional(),required:B(I()).optional()}).catchall(xc()).optional(),annotations:$u.optional(),execution:ed.optional(),_meta:U(I(),xc()).optional()}),nd=tu.extend({method:W(`tools/list`)}),rd=nu.extend({tools:B(td)}),id=Cl.extend({content:B(Yu).default([]),structuredContent:U(I(),xc()).optional(),isError:z().optional()});id.or(Cl.extend({toolResult:xc()}));const ad=vl.extend({name:I(),arguments:U(I(),xc()).optional()}),od=bl.extend({method:W(`tools/call`),params:ad}),sd=Sl.extend({method:W(`notifications/tools/list_changed`),params:xl.optional()}),cd=V({autoRefresh:z().default(!0),debounceMs:R().int().nonnegative().default(300)}),ld=Pc([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),ud=_l.extend({level:ld}),dd=bl.extend({method:W(`logging/setLevel`),params:ud}),fd=xl.extend({level:ld,logger:I().optional(),data:xc()}),pd=Sl.extend({method:W(`notifications/message`),params:fd}),md=V({hints:B(V({name:I().optional()})).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),hd=V({mode:Pc([`auto`,`required`,`none`]).optional()}),gd=V({type:W(`tool_result`),toolUseId:I().describe(`The unique identifier for the corresponding tool call.`),content:B(Yu).default([]),structuredContent:V({}).loose().optional(),isError:z().optional(),_meta:U(I(),xc()).optional()}),_d=kc(`type`,[Wu,Gu,Ku]),vd=kc(`type`,[Wu,Gu,Ku,qu,gd]),yd=V({role:yu,content:H([vd,B(vd)]),_meta:U(I(),xc()).optional()}),bd=vl.extend({messages:B(yd),modelPreferences:md.optional(),systemPrompt:I().optional(),includeContext:Pc([`none`,`thisServer`,`allServers`]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:B(I()).optional(),metadata:dl.optional(),tools:B(td).optional(),toolChoice:hd.optional()}),xd=bl.extend({method:W(`sampling/createMessage`),params:bd}),Sd=Cl.extend({model:I(),stopReason:zc(Pc([`endTurn`,`stopSequence`,`maxTokens`]).or(I())),role:yu,content:_d}),Cd=Cl.extend({model:I(),stopReason:zc(Pc([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(I())),role:yu,content:H([vd,B(vd)])}),wd=V({type:W(`boolean`),title:I().optional(),description:I().optional(),default:z().optional()}),Td=V({type:W(`string`),title:I().optional(),description:I().optional(),minLength:R().optional(),maxLength:R().optional(),format:Pc([`email`,`uri`,`date`,`date-time`]).optional(),default:I().optional()}),Ed=V({type:Pc([`number`,`integer`]),title:I().optional(),description:I().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),Dd=V({type:W(`string`),title:I().optional(),description:I().optional(),enum:B(I()),default:I().optional()}),Od=V({type:W(`string`),title:I().optional(),description:I().optional(),oneOf:B(V({const:I(),title:I()})),default:I().optional()}),kd=H([H([V({type:W(`string`),title:I().optional(),description:I().optional(),enum:B(I()),enumNames:B(I()).optional(),default:I().optional()}),H([Dd,Od]),H([V({type:W(`array`),title:I().optional(),description:I().optional(),minItems:R().optional(),maxItems:R().optional(),items:V({type:W(`string`),enum:B(I())}),default:B(I()).optional()}),V({type:W(`array`),title:I().optional(),description:I().optional(),minItems:R().optional(),maxItems:R().optional(),items:V({anyOf:B(V({const:I(),title:I()}))}),default:B(I()).optional()})])]),wd,Td,Ed]),Ad=H([vl.extend({mode:W(`form`).optional(),message:I(),requestedSchema:V({type:W(`object`),properties:U(I(),kd),required:B(I()).optional()})}),vl.extend({mode:W(`url`),message:I(),elicitationId:I(),url:I().url()})]),jd=bl.extend({method:W(`elicitation/create`),params:Ad}),Md=xl.extend({elicitationId:I()}),Nd=Sl.extend({method:W(`notifications/elicitation/complete`),params:Md}),Pd=Cl.extend({action:Pc([`accept`,`decline`,`cancel`]),content:al(e=>e===null?void 0:e,U(I(),H([I(),R(),z(),B(I())])).optional())}),Fd=V({type:W(`ref/resource`),uri:I()}),Id=V({type:W(`ref/prompt`),name:I()}),Ld=_l.extend({ref:H([Id,Fd]),argument:V({name:I(),value:I()}),context:V({arguments:U(I(),I()).optional()}).optional()}),Rd=bl.extend({method:W(`completion/complete`),params:Ld}),zd=Cl.extend({completion:Ec({values:B(I()).max(100),total:zc(R().int()),hasMore:zc(z())})}),Bd=V({uri:I().startsWith(`file://`),name:I().optional(),_meta:U(I(),xc()).optional()}),Vd=bl.extend({method:W(`roots/list`),params:_l.optional()}),Hd=Cl.extend({roots:B(Bd)}),Ud=Sl.extend({method:W(`notifications/roots/list_changed`),params:xl.optional()});H([Xl,Gl,Rd,dd,Uu,Bu,Cu,Tu,ku,Nu,Fu,od,nd,cu,uu,du,pu]),H([Il,$l,Jl,Ud,su]),H([Pl,Sd,Cd,Pd,Hd,lu,fu,au]),H([Xl,xd,jd,Vd,cu,uu,du,pu]),H([Il,$l,pd,Lu,ju,sd,Qu,su,Nd]),H([Pl,ql,zd,Zu,Vu,wu,Eu,Au,id,rd,lu,fu,au]);var K=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===G.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Wd(e.elicitations,n)}return new e(t,n,r)}},Wd=class extends K{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(G.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Gd(e){return e===`completed`||e===`failed`||e===`cancelled`}function Kd(e){let t=Os(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=ks(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function qd(e,t){let n=Ds(e,t);if(!n.success)throw n.error;return n.data}var Jd=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=/* @__PURE__ */ new Map,this._requestHandlerAbortControllers=/* @__PURE__ */ new Map,this._notificationHandlers=/* @__PURE__ */ new Map,this._responseHandlers=/* @__PURE__ */ new Map,this._progressHandlers=/* @__PURE__ */ new Map,this._timeoutInfo=/* @__PURE__ */ new Map,this._pendingDebouncedNotifications=/* @__PURE__ */ new Set,this._taskProgressTokens=/* @__PURE__ */ new Map,this._requestResolvers=/* @__PURE__ */ new Map,this.setNotificationHandler(Il,e=>{this._oncancel(e)}),this.setNotificationHandler($l,e=>{this._onprogress(e)}),this.setRequestHandler(Xl,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(cu,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new K(G.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(uu,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(!await this._taskStore.getTask(r,t.sessionId))throw new K(G.InvalidParams,`Task not found: ${r}`);if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new K(e.error.code,e.error.message,e.error.data))}}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(/* @__PURE__ */ Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new K(G.InvalidParams,`Task not found: ${r}`);if(!Gd(i.status))return await this._waitForTaskUpdate(r,t.signal,t.sessionId),await n();if(Gd(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r,t.sessionId),{...e,_meta:{...e._meta,[ul]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(du,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new K(G.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(pu,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new K(G.InvalidParams,`Task not found: ${e.params.taskId}`);if(Gd(n.status))throw new K(G.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId,t.sessionId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new K(G.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof K?e:new K(G.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),K.fromError(G.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw 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 t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),Al(e)||Ml(e)?this._onresponse(e):El(e)?this._onrequest(e,t):Ol(e)?this._onnotification(e):this._onerror(/* @__PURE__ */ Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=/* @__PURE__ */ new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=K.fromError(G.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(/* @__PURE__ */ Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[ul]?.taskId,a=r?.sessionId,o=this._taskStore,s=!0,c;if(i&&o&&this._taskMessageQueue&&a!==void 0&&(s=!1,c=(async()=>{if(!await o.getTask(i,a))throw new K(G.InvalidParams,`Task not found: ${i}`);s=!0})()),n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:G.MethodNotFound,message:`Method not found`}};if(i&&c){let e={type:`error`,message:t,timestamp:Date.now()};c.then(()=>this._enqueueTaskMessage(i,e,a),()=>r?.send(t)).catch(e=>this._onerror(/* @__PURE__ */ Error(`Failed to send an error response: ${e}`)))}else i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(/* @__PURE__ */ Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(/* @__PURE__ */ Error(`Failed to send an error response: ${e}`)));return}let l=new AbortController;this._requestHandlerAbortControllers.set(e.id,l);let u=yl(e.params)?e.params.task:void 0,d=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,f={signal:l.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(l.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(l.signal.aborted)throw new K(G.ConnectionClosed,`Request was cancelled`);let a={...r,relatedRequestId:e.id};i&&!a.relatedTask&&(a.relatedTask={taskId:i});let o=a.relatedTask?.taskId??i;return o&&d&&await d.updateTaskStatus(o,`input_required`),await this.request(t,n,a)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:d,taskRequestedTtl:u?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};(c??Promise.resolve()).then(()=>{if(c&&l.signal.aborted)throw new K(G.ConnectionClosed,`Request was cancelled`);u&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,f)).then(async t=>{if(l.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(l.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:G.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue&&s?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(/* @__PURE__ */ Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===l&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(/* @__PURE__ */ Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),Al(e)?n(e):n(new K(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(/* @__PURE__ */ Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(Al(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),Al(e)?r(e):r(K.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof K?e:new K(G.InternalError,String(e))}}return}let i;try{let r=await this.request(e,au,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new K(G.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},Gd(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new K(G.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new K(G.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof K?e:new K(G.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(/* @__PURE__ */ Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[ul]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(/* @__PURE__ */ Error(`Failed to send cancellation: ${e}`))),l(e instanceof K?e:new K(G.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=Ds(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(K.fromError(G.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(/* @__PURE__ */ Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},lu,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},fu,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},mu,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[ul]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.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 n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[ul]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[ul]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=Kd(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=qd(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=Kd(e);this._notificationHandlers.set(n,n=>{let r=qd(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n??this._transport?.sessionId,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&El(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new K(G.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(/* @__PURE__ */ Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t,n){let r=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e,n);t?.pollInterval&&(r=t.pollInterval)}catch{}return new Promise((e,n)=>{if(t.aborted){n(new K(G.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,r);t.addEventListener(`abort`,()=>{clearTimeout(i),n(new K(G.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new K(G.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=su.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),Gd(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new K(G.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Gd(a.status))throw new K(G.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=su.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),Gd(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function Yd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Xd(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=Yd(a)&&Yd(i)?{...a,...i}:i}return n}var Zd=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{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(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),Qd=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let t=Zd();var n=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},r;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(r||(e.UsedValueState=r={})),e.varKinds={const:new t.Name(`const`),let:new t.Name(`let`),var:new t.Name(`var`)};var i=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=i;var a=class extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:n,itemIndex:r}){this.value=e,this.scopePath=(0,t._)`.${new t.Name(n)}[${r}]`}};e.ValueScopeName=a;let o=(0,t._)`\n`;e.ValueScope=class extends i{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=/* @__PURE__ */ new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,n=this._values){return this._reduceValues(n,n=>{if(n.scopePath===void 0)throw Error(`CodeGen: name "${n}" has no value`);return(0,t._)`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(i,a,o={},s){let c=t.nil;for(let l in i){let u=i[l];if(!u)continue;let d=o[l]=o[l]||/* @__PURE__ */ new Map;u.forEach(i=>{if(d.has(i))return;d.set(i,r.Started);let o=a(i);if(o){let n=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,t._)`${c}${n} ${i} = ${o};${this.opts._n}`}else if(o=s?.(i))c=(0,t._)`${c}${o}${this.opts._n}`;else throw new n(i);d.set(i,r.Completed)})}return c}}})),q=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let t=Zd(),n=Qd();var r=Zd();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var i=Qd();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),e.operators={GT:new t._Code(`>`),GTE:new t._Code(`>=`),LT:new t._Code(`<`),LTE:new t._Code(`<=`),EQ:new t._Code(`===`),NEQ:new t._Code(`!==`),NOT:new t._Code(`!`),OR:new t._Code(`||`),AND:new t._Code(`&&`),ADD:new t._Code(`+`)};var a=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},o=class extends a{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let r=e?n.varKinds.var:this.varKind,i=this.rhs===void 0?``:` = ${this.rhs}`;return`${r} ${this.name}${i};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=se(this.rhs,e,t),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}},s=class extends a{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,n){if(!(this.lhs instanceof t.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=se(this.rhs,e,n),this}get names(){return oe(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}},c=class extends s{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},l=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},u=class extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},d=class extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},f=class extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=se(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}},p=class extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(ce(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>ae(e,t.names),{})}},m=class extends p{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},h=class extends p{},g=class extends m{};g.kind=`else`;var _=class e extends m{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new g(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(le(t),n instanceof e?[n]:n.nodes);if(t!==!1&&this.nodes.length)return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=se(this.condition,e,t),this}get names(){let e=super.names;return oe(e,this.condition),this.else&&ae(e,this.else.names),e}};_.kind=`if`;var v=class extends m{};v.kind=`for`;var y=class extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=se(this.iteration,e,t),this}get names(){return ae(super.names,this.iteration.names)}},b=class extends v{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?n.varKinds.var:this.varKind,{name:r,from:i,to:a}=this;return`for(${t} ${r}=${i}; ${r}<${a}; ${r}++)`+super.render(e)}get names(){return oe(oe(super.names,this.from),this.to)}},x=class extends v{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=se(this.iterable,e,t),this}get names(){return ae(super.names,this.iterable.names)}},ee=class extends m{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};ee.kind=`func`;var te=class extends p{render(e){return`return `+super.render(e)}};te.kind=`return`;var ne=class extends m{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&ae(e,this.catch.names),this.finally&&ae(e,this.finally.names),e}},re=class extends m{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};re.kind=`catch`;var ie=class extends m{render(e){return`finally`+super.render(e)}};ie.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
31
+ `:``},this._extScope=e,this._scope=new n.Scope({parent:e}),this._nodes=[new h]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=/* @__PURE__ */ new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new o(e,i,n)),i}const(e,t,r){return this._def(n.varKinds.const,e,t,r)}let(e,t,r){return this._def(n.varKinds.let,e,t,r)}var(e,t,r){return this._def(n.varKinds.var,e,t,r)}assign(e,t,n){return this._leafNode(new s(e,t,n))}add(t,n){return this._leafNode(new c(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==t.nil&&this._leafNode(new f(e)),this}object(...e){let n=[`{`];for(let[r,i]of e)n.length>1&&n.push(`,`),n.push(r),(r!==i||this.opts.es5)&&(n.push(`:`),(0,t.addCodeArg)(n,i));return n.push(`}`),new t._Code(n)}if(e,t,n){if(this._blockNode(new _(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new _(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(_,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new y(e),t)}forRange(e,t,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.let){let o=this._scope.toName(e);return this._for(new b(a,o,t,r),()=>i(o))}forOf(e,r,i,a=n.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=r instanceof t.Name?r:this.var(`_arr`,r);return this.forRange(`_i`,0,(0,t._)`${e}.length`,n=>{this.var(o,(0,t._)`${e}[${n}]`),i(o)})}return this._for(new x(`of`,a,o,r),()=>i(o))}forIn(e,r,i,a=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,t._)`Object.keys(${r})`,i);let o=this._scope.toName(e);return this._for(new x(`in`,a,o,r),()=>i(o))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new l(e))}break(e){return this._leafNode(new u(e))}return(e){let t=new te;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(te)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new ne;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new re(e),t(e)}return n&&(this._currNode=r.finally=new ie,this.code(n)),this._endBlockNode(re,ie)}throw(e){return this._leafNode(new d(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,n=t.nil,r,i){return this._blockNode(new ee(e,n,r)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(ee)}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,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof _))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function ae(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function oe(e,n){return n instanceof t._CodeOrName?ae(e,n.names):e}function se(e,n,r){return e instanceof t.Name?i(e):a(e)?new t._Code(e._items.reduce((e,n)=>(n instanceof t.Name&&(n=i(n)),n instanceof t._Code?e.push(...n._items):e.push(n),e),[])):e;function i(e){let t=r[e.str];return t===void 0||n[e.str]!==1?e:(delete n[e.str],t)}function a(e){return e instanceof t._Code&&e._items.some(e=>e instanceof t.Name&&n[e.str]===1&&r[e.str]!==void 0)}}function ce(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function le(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,t._)`!${he(e)}`}e.not=le;let ue=me(e.operators.AND);function de(...e){return e.reduce(ue)}e.and=de;let fe=me(e.operators.OR);function pe(...e){return e.reduce(fe)}e.or=pe;function me(e){return(n,r)=>n===t.nil?r:r===t.nil?n:(0,t._)`${he(n)} ${e} ${he(r)}`}function he(e){return e instanceof t.Name?e:(0,t._)`(${e})`}})),J=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let t=q(),n=Zd();function r(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=r;function i(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0||(a(e,t),!o(t,e.self.RULES.all))}e.alwaysValidSchema=i;function a(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||x(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=a;function o(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=o;function s(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=s;function c({topSchemaRef:e,schemaPath:n},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,t._)`${r}`}return(0,t._)`${e}${n}${(0,t.getProperty)(i)}`}e.schemaRefOrVal=c;function l(e){return f(decodeURIComponent(e))}e.unescapeFragment=l;function u(e){return encodeURIComponent(d(e))}e.escapeFragment=u;function d(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=d;function f(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=f;function p(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=p;function m({mergeNames:e,mergeToName:n,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof t.Name?(o instanceof t.Name?e(a,o,s):n(a,o,s),s):o instanceof t.Name?(n(a,s,o),o):r(o,s);return c===t.Name&&!(l instanceof t.Name)?i(a,l):l}}e.mergeEvaluated={props:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>{e.if((0,t._)`${n} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,t._)`${r} || {}`).code((0,t._)`Object.assign(${r}, ${n})`))}),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>{n===!0?e.assign(r,!0):(e.assign(r,(0,t._)`${r} || {}`),g(e,r,n))}),mergeValues:(e,t)=>e===!0||{...e,...t},resultToName:h}),items:m({mergeNames:(e,n,r)=>e.if((0,t._)`${r} !== true && ${n} !== undefined`,()=>e.assign(r,(0,t._)`${n} === true ? true : ${r} > ${n} ? ${r} : ${n}`)),mergeToName:(e,n,r)=>e.if((0,t._)`${r} !== true`,()=>e.assign(r,n===!0||(0,t._)`${r} > ${n} ? ${r} : ${n}`)),mergeValues:(e,t)=>e===!0||Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function h(e,n){if(n===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,t._)`{}`);return n!==void 0&&g(e,r,n),r}e.evaluatedPropsToName=h;function g(e,n,r){Object.keys(r).forEach(r=>e.assign((0,t._)`${n}${(0,t.getProperty)(r)}`,!0))}e.setEvaluated=g;let _={};function v(e,t){return e.scopeValue(`func`,{ref:t,code:_[t.code]||(_[t.code]=new n._Code(t.code))})}e.useFunc=v;var y;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(y||(e.Type=y={}));function b(e,n,r){if(e instanceof t.Name){let i=n===y.Num;return r?i?(0,t._)`"[" + ${e} + "]"`:(0,t._)`"['" + ${e} + "']"`:i?(0,t._)`"/" + ${e}`:(0,t._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,t.getProperty)(e).toString():`/`+d(e)}e.getErrorPath=b;function x(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=x})),$d=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),ef=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=q(),n=J(),r=$d();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function i(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:u,allErrors:f}=o,p=d(n,r,i);a??(u||f)?c(s,p):l(o,(0,t._)`[${p}]`)}e.reportError=i;function a(t,n=e.keywordError,i){let{it:a}=t,{gen:o,compositeRule:s,allErrors:u}=a;c(o,d(t,n,i)),s||u||l(a,r.default.vErrors)}e.reportExtraError=a;function o(e,n){e.assign(r.default.errors,n),e.if((0,t._)`${r.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${r.default.vErrors}.length`,n),()=>e.assign(r.default.vErrors,null)))}e.resetErrorsCount=o;function s({gen:e,keyword:n,schemaValue:i,data:a,errsCount:o,it:s}){
32
32
  /* istanbul ignore if */
33
- if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),Hd=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=Vd(),n=q(),r=Bd(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),Ud=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;let t=/* @__PURE__ */ new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),Wd=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),Gd=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=Ud(),n=Wd(),r=Vd(),i=q(),a=J();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;let u=/* @__PURE__ */ new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
33
+ if(o===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,o,r.default.errors,o=>{e.const(c,(0,t._)`${r.default.vErrors}[${o}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(r.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,i),e.assign((0,t._)`${c}.data`,a))})}e.extendErrors=s;function c(e,n){let i=e.const(`err`,n);e.if((0,t._)`${r.default.vErrors} === null`,()=>e.assign(r.default.vErrors,(0,t._)`[${i}]`),(0,t._)`${r.default.vErrors}.push(${i})`),e.code((0,t._)`${r.default.errors}++`)}function l(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let u={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function d(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:f(e,n,r)}function f(e,t,n={}){let{gen:r,it:i}=e,a=[p(i,n),m(e,n)];return h(e,t,a),r.object(...a)}function p({errorPath:e},{instancePath:i}){let a=i?(0,t.str)`${e}${(0,n.getErrorPath)(i,n.Type.Str)}`:e;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,a)]}function m({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[u.schemaPath,o]}function h(e,{params:n,message:i},a){let{keyword:o,data:s,schemaValue:c,it:l}=e,{opts:d,propertyName:f,topSchemaRef:p,schemaPath:m}=l;a.push([u.keyword,o],[u.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),d.messages&&a.push([u.message,typeof i==`function`?i(e):i]),d.verbose&&a.push([u.schema,c],[u.parentSchema,(0,t._)`${p}${m}`],[r.default.data,s]),f&&a.push([u.propertyName,f])}})),tf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=ef(),n=q(),r=$d(),i={message:`boolean schema is false`};function a(e){let{gen:t,schema:i,validateName:a}=e;i===!1?s(e,!1):typeof i==`object`&&i.$async===!0?t.return(r.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=a;function o(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),s(e)):n.var(t,!0)}e.boolOrEmptySchema=o;function s(e,n){let{gen:r,data:a}=e,o={gen:r,keyword:`false schema`,data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(o,i,void 0,n)}})),nf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getRules=e.isJSONType=void 0;let t=/* @__PURE__ */ new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),rf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),af=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=nf(),n=rf(),r=ef(),i=q(),a=J();var o;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(o||(e.DataType=o={}));function s(e){let t=c(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=s;function c(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=c;function l(e,t){let{gen:r,data:i,opts:a}=e,s=d(t,a.coerceTypes),c=t.length>0&&!(s.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(c){let n=h(t,i,a.strictNumbers,o.Wrong);r.if(n,()=>{s.length?f(e,t,s):_(e)})}return c}e.coerceAndCheckDataType=l;let u=/* @__PURE__ */ new Set([`string`,`number`,`integer`,`boolean`,`null`]);function d(e,t){return t?e.filter(e=>u.has(e)||t===`array`&&e===`array`):[]}function f(e,t,n){let{gen:r,data:a,opts:o}=e,s=r.let(`dataType`,(0,i._)`typeof ${a}`),c=r.let(`coerced`,(0,i._)`undefined`);o.coerceTypes===`array`&&r.if((0,i._)`${s} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>r.assign(a,(0,i._)`${a}[0]`).assign(s,(0,i._)`typeof ${a}`).if(h(t,a,o.strictNumbers),()=>r.assign(c,a))),r.if((0,i._)`${c} !== undefined`);for(let e of n)(u.has(e)||e===`array`&&o.coerceTypes===`array`)&&l(e);r.else(),_(e),r.endIf(),r.if((0,i._)`${c} !== undefined`,()=>{r.assign(a,c),p(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,i._)`${s} == "number" || ${s} == "boolean"`).assign(c,(0,i._)`"" + ${a}`).elseIf((0,i._)`${a} === null`).assign(c,(0,i._)`""`);return;case`number`:r.elseIf((0,i._)`${s} == "boolean" || ${a} === null
34
34
  || (${s} == "string" && ${a} && ${a} == +${a})`).assign(c,(0,i._)`+${a}`);return;case`integer`:r.elseIf((0,i._)`${s} === "boolean" || ${a} === null
35
35
  || (${s} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(c,(0,i._)`+${a}`);return;case`boolean`:r.elseIf((0,i._)`${a} === "false" || ${a} === 0 || ${a} === null`).assign(c,!1).elseIf((0,i._)`${a} === "true" || ${a} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,i._)`${a} === "" || ${a} === 0 || ${a} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,i._)`${s} === "string" || ${s} === "number"
36
- || ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;let g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),Kd=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;let t=q(),n=J();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),qd=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=q(),n=J(),r=Bd(),i=J();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;let h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;
36
+ || ${s} === "boolean" || ${a} === null`).assign(c,(0,i._)`[${a}]`)}}}function p({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,i._)`${t} !== undefined`,()=>e.assign((0,i._)`${t}[${n}]`,r))}function m(e,t,n,r=o.Correct){let a=r===o.Correct?i.operators.EQ:i.operators.NEQ,s;switch(e){case`null`:return(0,i._)`${t} ${a} null`;case`array`:s=(0,i._)`Array.isArray(${t})`;break;case`object`:s=(0,i._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:s=c((0,i._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:s=c();break;default:return(0,i._)`typeof ${t} ${a} ${e}`}return r===o.Correct?s:(0,i.not)(s);function c(e=i.nil){return(0,i.and)((0,i._)`typeof ${t} == "number"`,e,n?(0,i._)`isFinite(${t})`:i.nil)}}e.checkDataType=m;function h(e,t,n,r){if(e.length===1)return m(e[0],t,n,r);let o,s=(0,a.toHash)(e);if(s.array&&s.object){let e=(0,i._)`typeof ${t} != "object"`;o=s.null?e:(0,i._)`!${t} || ${e}`,delete s.null,delete s.array,delete s.object}else o=i.nil;s.number&&delete s.integer;for(let e in s)o=(0,i.and)(o,m(e,t,n,r));return o}e.checkDataTypes=h;let g={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,i._)`{type: ${e}}`:(0,i._)`{type: ${t}}`};function _(e){let t=v(e);(0,r.reportError)(t,g)}e.reportTypeError=_;function v(e){let{gen:t,data:n,schema:r}=e,i=(0,a.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),of=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0;let t=q(),n=J();function r(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)i(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>i(e,n,t.default))}e.assignDefaults=r;function i(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),sf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=q(),n=J(),r=$d(),i=J();function a(e,n){let{gen:r,data:i,it:a}=e;r.if(d(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=a;function o({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(d(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=o;function s(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=s;function c(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=c;function l(e,n,r){return(0,t._)`${c(e)}.call(${n}, ${r})`}e.isOwnProperty=l;function u(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${l(e,n,r)}`:a}e.propertyInData=u;function d(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(l(e,n,r))):a}e.noPropertyInData=d;function f(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=f;function p(e,t){return f(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=p;function m({schemaCode:e,data:n,it:{gen:i,topSchemaRef:a,schemaPath:o,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${a}${o}`:n,p=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,s)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&p.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);let m=(0,t._)`${f}, ${i.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=m;let h=(0,t._)`new RegExp`;function g({gen:e,it:{opts:n}},r){let a=n.unicodeRegExp?`u`:``,{regExp:o}=n.code,s=o(r,a);return e.scopeValue(`pattern`,{key:s.toString(),ref:s,code:(0,t._)`${o.code===`new RegExp`?h:(0,i.useFunc)(e,o)}(${r}, ${a})`})}e.usePattern=g;function _(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=_;function v(e){let{gen:r,schema:i,keyword:a,it:o}=e;
37
37
  /* istanbul ignore if */
38
- if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),Jd=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=q(),n=Bd(),r=qd(),i=Vd();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)ee(),i.modifying&&s(e),b(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),b(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>ee((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),ee(t.nil),e}function ee(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function b(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){
38
+ if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=v})),cf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=q(),n=$d(),r=sf(),i=ef();function a(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=u(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let d=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},d),e.pass(d,()=>e.error(!0))}e.macroKeywordCode=a;function o(e,i){let{gen:a,keyword:o,schema:d,parentSchema:f,$data:p,it:m}=e;l(m,i);let h=u(a,o,!p&&i.compile?i.compile.call(m.self,d,f,m):i.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(i.valid??g);function _(){if(i.errors===!1)b(),i.modifying&&s(e),x(()=>e.error());else{let t=i.async?v():y();i.modifying&&s(e),x(()=>c(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${m.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=i.async?(0,t._)`await `:t.nil){let s=m.opts.passContext?n.default.this:n.default.self,c=!(`compile`in i&&!p||i.schema===!1);a.assign(g,(0,t._)`${o}${(0,r.callValidateCode)(e,h,s,c)}`,i.modifying)}function x(e){a.if((0,t.not)(i.valid??g),e)}}e.funcKeywordCode=o;function s(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function c(e,r){let{gen:a}=e;a.if((0,t._)`Array.isArray(${r})`,()=>{a.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,i.extendErrors)(e)},()=>e.error())}function l({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function u(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function d(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=d;function f({schema:e,opts:t,self:n,errSchemaPath:r},i,a){
39
39
  /* istanbul ignore if */
40
- if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),Yd=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=q(),n=J();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=/* @__PURE__ */ new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),Xd=/* @__PURE__ */ T(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),Zd=/* @__PURE__ */ T(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.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 r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else(p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),Qd=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=J(),n=Xd(),r=Zd(),i=/* @__PURE__ */ new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;let o=/* @__PURE__ */ new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;let d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;let m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=/* @__PURE__ */ new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return/* @__PURE__ */ Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),$d=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=Hd(),n=Gd(),r=Wd(),i=Gd(),a=Kd(),o=Jd(),s=Yd(),c=q(),l=Bd(),u=Qd(),d=J(),f=Vd();function p(e){if(te(e)&&(re(e),b(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&le(e),oe(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),ie(e),ue(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function ee(e,n){if(te(e)&&(re(e),b(e))){ne(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function b({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function te(e){return typeof e.schema!=`boolean`}function ne(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&le(e),se(e),ce(e);let a=r.const(`_errs`,l.default.errors);ie(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function re(e){(0,d.checkUnknownRules)(e),ae(e)}function ie(e,t){if(e.opts.jtd)return fe(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);fe(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function ae(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function oe(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function se(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function ce(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function le({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function ue(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&de(e),t.return((0,c._)`${l.default.errors} === 0`))}function de({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function fe(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>be(e,`$ref`,h.all.$ref.definition));return}p.jtd||me(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),pe(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):pe(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function pe(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&be(e,n.keyword,n.definition,t.type)})}function me(e,t){!e.schemaEnv.meta&&e.opts.strictTypes&&(he(e,t),e.opts.allowUnionTypes||x(e,t),ge(e,e.dataTypes))}function he(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{ve(e.dataTypes,t)||S(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),ye(e,t)}}function x(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&S(e,`use allowUnionTypes to allow union type keyword`)}function ge(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>_e(t,e))&&S(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function _e(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function ve(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function ye(e,t){let n=[];for(let r of e.dataTypes)ve(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function S(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var C=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,Ce(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}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:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){
40
+ if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=f})),lf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=q(),n=J();function r(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=r;function i(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=/* @__PURE__ */ new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=i;function a(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=a})),uf=/* @__PURE__ */ E(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),df=/* @__PURE__ */ E(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.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 r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else(p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),ff=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=J(),n=uf(),r=df(),i=/* @__PURE__ */ new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function a(e,t=!0){return typeof e==`boolean`?!0:t===!0?!s(e):t?c(e)<=t:!1}e.inlineRef=a;let o=/* @__PURE__ */ new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function s(e){for(let t in e){if(o.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(s)||typeof n==`object`&&s(n))return!0}return!1}function c(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!i.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=c(e)),n===1/0)))return 1/0;return n}function l(e,t=``,n){return n!==!1&&(t=f(t)),u(e,e.parse(t))}e.getFullPath=l;function u(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=u;let d=/#\/?$/;function f(e){return e?e.replace(d,``):``}e.normalizeId=f;function p(e,t,n){return n=f(n),e.resolve(t,n)}e.resolveUrl=p;let m=/^[a-z_][-a-z0-9._]*$/i;function h(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=f(e[i]||t),s={"":o},c=l(a,o,!1),u={},d=/* @__PURE__ */ new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=l.call(this,e[i])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),s[t]=o;function l(t){let n=this.opts.uriResolver.resolve;if(t=f(o?n(o,t):t),d.has(t))throw h(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?p(e,r.schema,t):t!==f(a)&&(t[0]===`#`?(p(e,u[t],t),u[t]=e):this.refs[t]=a),t}function g(e){if(typeof e==`string`){if(!m.test(e))throw Error(`invalid anchor "${e}"`);l.call(this,`#${e}`)}}}),u;function p(e,t,r){if(t!==void 0&&!n(e,t))throw h(r)}function h(e){return/* @__PURE__ */ Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=h})),pf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=tf(),n=af(),r=rf(),i=af(),a=of(),o=cf(),s=lf(),c=q(),l=$d(),u=ff(),d=J(),f=ef();function p(e){if(ee(e)&&(ne(e),x(e))){_(e);return}m(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=p;function m({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,c._)`${l.default.data}, ${l.default.valCxt}`,r.$async,()=>{e.code((0,c._)`"use strict"; ${y(n,i)}`),g(e,i),e.code(a)}):e.func(t,(0,c._)`${l.default.data}, ${h(i)}`,r.$async,()=>e.code(y(n,i)).code(a))}function h(e){return(0,c._)`{${l.default.instancePath}="", ${l.default.parentData}, ${l.default.parentDataProperty}, ${l.default.rootData}=${l.default.data}${e.dynamicRef?(0,c._)`, ${l.default.dynamicAnchors}={}`:c.nil}}={}`}function g(e,t){e.if(l.default.valCxt,()=>{e.var(l.default.instancePath,(0,c._)`${l.default.valCxt}.${l.default.instancePath}`),e.var(l.default.parentData,(0,c._)`${l.default.valCxt}.${l.default.parentData}`),e.var(l.default.parentDataProperty,(0,c._)`${l.default.valCxt}.${l.default.parentDataProperty}`),e.var(l.default.rootData,(0,c._)`${l.default.valCxt}.${l.default.rootData}`),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`${l.default.valCxt}.${l.default.dynamicAnchors}`)},()=>{e.var(l.default.instancePath,(0,c._)`""`),e.var(l.default.parentData,(0,c._)`undefined`),e.var(l.default.parentDataProperty,(0,c._)`undefined`),e.var(l.default.rootData,l.default.data),t.dynamicRef&&e.var(l.default.dynamicAnchors,(0,c._)`{}`)})}function _(e){let{schema:t,opts:n,gen:r}=e;m(e,()=>{n.$comment&&t.$comment&&ce(e),ae(e),r.let(l.default.vErrors,null),r.let(l.default.errors,0),n.unevaluated&&v(e),re(e),le(e)})}function v(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,c._)`${n}.evaluated`),t.if((0,c._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,c._)`${e.evaluated}.props`,(0,c._)`undefined`)),t.if((0,c._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,c._)`${e.evaluated}.items`,(0,c._)`undefined`))}function y(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,c._)`/*# sourceURL=${n} */`:c.nil}function b(e,n){if(ee(e)&&(ne(e),x(e))){te(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function x({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function ee(e){return typeof e.schema!=`boolean`}function te(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&ce(e),oe(e),se(e);let a=r.const(`_errs`,l.default.errors);re(e,a),r.var(t,(0,c._)`${a} === ${l.default.errors}`)}function ne(e){(0,d.checkUnknownRules)(e),ie(e)}function re(e,t){if(e.opts.jtd)return de(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);de(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function ie(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function ae(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,d.checkStrictMode)(e,`default is ignored in the schema root`)}function oe(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function se(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function ce({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,c._)`${l.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,c.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,c._)`${l.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function le(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,c._)`${l.default.errors} === 0`,()=>t.return(l.default.data),()=>t.throw((0,c._)`new ${i}(${l.default.vErrors})`)):(t.assign((0,c._)`${r}.errors`,l.default.vErrors),a.unevaluated&&ue(e),t.return((0,c._)`${l.default.errors} === 0`))}function ue({gen:e,evaluated:t,props:n,items:r}){n instanceof c.Name&&e.assign((0,c._)`${t}.props`,n),r instanceof c.Name&&e.assign((0,c._)`${t}.items`,r)}function de(e,t,n,a){let{gen:o,schema:s,data:u,allErrors:f,opts:p,self:m}=e,{RULES:h}=m;if(s.$ref&&(p.ignoreKeywordsWithRef||!(0,d.schemaHasRulesButRef)(s,h))){o.block(()=>ye(e,`$ref`,h.all.$ref.definition));return}p.jtd||pe(e,t),o.block(()=>{for(let e of h.rules)g(e);g(h.post)});function g(d){(0,r.shouldUseGroup)(s,d)&&(d.type?(o.if((0,i.checkDataType)(d.type,u,p.strictNumbers)),fe(e,d),t.length===1&&t[0]===d.type&&n&&(o.else(),(0,i.reportTypeError)(e)),o.endIf()):fe(e,d),f||o.if((0,c._)`${l.default.errors} === ${a||0}`))}}function fe(e,t){let{gen:n,schema:i,opts:{useDefaults:o}}=e;o&&(0,a.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,r.shouldUseRule)(i,n)&&ye(e,n.keyword,n.definition,t.type)})}function pe(e,t){!e.schemaEnv.meta&&e.opts.strictTypes&&(me(e,t),e.opts.allowUnionTypes||he(e,t),ge(e,e.dataTypes))}function me(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{S(e.dataTypes,t)||C(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),ve(e,t)}}function he(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&C(e,`use allowUnionTypes to allow union type keyword`)}function ge(e,t){let n=e.self.RULES.all;for(let i in n){let a=n[i];if(typeof a==`object`&&(0,r.shouldUseRule)(e.schema,a)){let{type:n}=a.definition;n.length&&!n.some(e=>_e(t,e))&&C(e,`missing type "${n.join(`,`)}" for keyword "${i}"`)}}}function _e(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function S(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function ve(e,t){let n=[];for(let r of e.dataTypes)S(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function C(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}var w=class{constructor(e,t,n){if((0,o.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,Se(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,o.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,l.default.errors))}result(e,t,n){this.failResult((0,c.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,c.not)(e),void 0,t)}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:t}=this;this.fail((0,c._)`${t} !== undefined && (${(0,c.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?f.reportExtraError:f.reportError)(this,this.def.error,t)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=c.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=c.nil,t=c.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,c.or)((0,c._)`${r} === undefined`,t)),e!==c.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==c.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:a}=this;return(0,c.or)(o(),s());function o(){if(n.length){
41
41
  /* istanbul ignore if */
42
- if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return ee(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=C;function be(e,t,n,r){let i=new C(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}let xe=/^\/(?:[^~]|~0|~1)*$/,Se=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Ce(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!xe.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=Se.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=Ce})),ef=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),tf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Qd();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),nf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=q(),n=ef(),r=Bd(),i=Qd(),a=J(),o=$d();var s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:/* @__PURE__ */ new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;let h=/* @__PURE__ */ new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),rf=/* @__PURE__ */ T(((e,t)=>{t.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}})),af=/* @__PURE__ */ T(((e,t)=>{let n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=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),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function s(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}let c=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function l(e){return e.length=0,!0}function u(e,t,n){if(e.length){let r=s(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function d(e){let t=0,n={error:!1,address:``,zone:``},r=[],i=[],a=!1,o=!1,c=u;for(let s=0;s<e.length;s++){let u=e[s];if(u!==`[`&&u!==`]`){if(u===`:`){if(a===!0&&(o=!0),!c(i,r,n))break;if(++t>7){n.error=!0;break}s>0&&e[s-1]===`:`&&(a=!0),r.push(`:`);continue}if(u===`%`){if(!c(i,r,n))break;c=l}else{i.push(u);continue}}}return i.length&&(c===l?n.zone=i.join(``):o?r.push(i.join(``)):r.push(s(i))),n.address=r.join(``),n}function f(e){if(p(e,`:`)<2)return{host:e,isIPV6:!1};let t=d(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function p(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function m(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}n.push(t);break}if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}let h={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},g=/[@/?#:]/g,_=/[@/?#]/g;function v(e,t){let n=t?_:g;return n.lastIndex=0,e.replace(n,e=>h[e])}function y(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function ee(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}o(e[n])?t+=e[n]:t+=escape(e[n])}return t}function b(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function te(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let e=f(n);n=e.isIPV6===!0?`[${e.escapedHost}]`:v(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:c,recomposeAuthority:te,reescapeHostDelimiters:v,normalizePercentEncoding:y,normalizePathEncoding:ee,escapePreservingEscapes:b,removeDotSegments:m,isIPv4:r,isUUID:n,normalizeIPv6:f,stringArrayToHexStripped:s}})),of=/* @__PURE__ */ T(((e,t)=>{let{isUUID:n}=af(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}let h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),sf=/* @__PURE__ */ T(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=af(),{SCHEMES:d,getSchemeHandler:f}=of();function p(e,t){return typeof e==`string`?e=te(e,t):typeof e==`object`&&(e=b(_(e,t),t)),e}function m(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=h(b(e,r),b(t,r),r,!0);return r.skipEscape=!0,_(i,r)}function h(e,t,n,i){let a={};return i||(e=b(_(e,n),n),t=b(_(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):(a.path=(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?`/`+t.path:e.path?e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,a.query=t.query===void 0?e.query:t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function g(e,t,n){let r=re(e,n),i=re(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function _(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[],l=f(o.scheme||n.scheme);l&&l.serialize&&l.serialize(n,o),n.path!==void 0&&(o.skipEscape?n.path=a(n.path):(n.path=s(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),o.reference!==`suffix`&&n.scheme&&c.push(n.scheme,`:`);let u=i(n);if(u!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(u),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!l||!l.absolutePath)&&(e=r(e)),u===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,n.query),n.fragment!==void 0&&c.push(`#`,n.fragment),c.join(``)}let v=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function y(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function ee(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1,s=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let d=e.match(v);if(d){i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||``,i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]);let t=y(i,d);if(t!==void 0&&(i.error=i.error||t,a=!0),i.host){if(l(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),s=e.isIPV6}else s=!0}i.reference=i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?`same-document`:i.scheme===void 0?`relative`:i.fragment===void 0?`absolute`:`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let p=f(r.scheme||i.scheme);if(!r.unicodeSupport&&(!p||!p.unicodeSupport)&&i.host&&(r.domainHost||p&&p.domainHost)&&s===!1&&u(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}if((!p||p&&!p.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=c(unescape(i.host),s))),i.path&&=o(i.path),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||`URI malformed`}p&&p.parse&&p.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:a}}function b(e,t){return ee(e,t).parsed}function te(e,t){return ne(e,t).normalized}function ne(e,t){let{parsed:n,malformedAuthorityOrPort:r}=ee(e,t);return{normalized:r?e:_(n,t),malformedAuthorityOrPort:r}}function re(e,t){if(typeof e==`string`){let{normalized:n,malformedAuthorityOrPort:r}=ne(e,t);return r?void 0:n}if(typeof e==`object`)return _(e,t)}let ie={SCHEMES:d,normalize:p,resolve:m,resolveComponent:h,equal:g,serialize:_,parse:b};t.exports=ie,t.exports.default=ie,t.exports.fastUri=ie})),cf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=sf();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),lf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=$d();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var n=q();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return n.CodeGen}});let r=ef(),i=tf(),a=Ud(),o=nf(),s=q(),c=Qd(),l=Gd(),u=J(),d=rf(),f=cf(),p=(e,t)=>new RegExp(e,t);p.code=`new RegExp`;let m=[`removeAdditional`,`useDefaults`,`coerceTypes`],h=/* @__PURE__ */ new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),g={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.`},_={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function v(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??p,a=e.uriResolver??f.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var y=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=/* @__PURE__ */ new Set,this._loading={},this._cache=/* @__PURE__ */ new Map,e=this.opts={...e,...v(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:h,es5:t,lines:n}),this.logger=oe(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),ee.call(this,g,e,`NOT SUPPORTED`),ee.call(this,_,e,`DEPRECATED`,`warn`),this._metaOpts=ie.call(this),e.formats&&ne.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&re.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),te.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=d;n===`id`&&(r={...d},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw 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 r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=b.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}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 t=b.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(ce.call(this,n,t),!t)return(0,u.eachItem)(n,e=>le.call(this,e)),this;de.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>le.call(this,e,r):e=>r.type.forEach(t=>le.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=pe(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){
42
+ if(!(t instanceof c.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,c._)`${(0,i.checkDataTypes)(e,t,a.opts.strictNumbers,i.DataType.Wrong)}`}return c.nil}function s(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,c._)`!${n}(${t})`}return c.nil}}subschema(e,t){let n=(0,s.getSubschema)(this.it,e);(0,s.extendSubschemaData)(n,this.it,e),(0,s.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return b(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=d.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=d.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,c.Name)),!0}};e.KeywordCxt=w;function ye(e,t,n,r){let i=new w(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,o.funcKeywordCode)(i,n):`macro`in n?(0,o.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,o.funcKeywordCode)(i,n)}let be=/^\/(?:[^~]|~0|~1)*$/,xe=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Se(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return l.default.rootData;if(e[0]===`/`){if(!be.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=l.default.rootData}else{let o=xe.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(u(`property/index`,s));return r[t-s]}if(s>t)throw Error(u(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,c._)`${a}${(0,c.getProperty)((0,d.unescapeJsonPointer)(e))}`,o=(0,c._)`${o} && ${a}`);return o;function u(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=Se})),mf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),hf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=ff();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),gf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=q(),n=mf(),r=$d(),i=ff(),a=J(),o=pf();var s=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,i.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=s;function c(e){let a=d.call(this,e);if(a)return a;let s=(0,i.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:c,lines:l}=this.opts.code,{ownProperties:u}=this.opts,f=new t.CodeGen(this.scope,{es5:c,lines:l,ownProperties:u}),p;e.$async&&(p=f.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let m=f.scopeName(`validate`);e.validateName=m;let h={gen:f,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:/* @__PURE__ */ new Set,topSchemaRef:f.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:m,ValidationError:p,schema:e.schema,schemaEnv:e,rootId:s,baseId:e.baseId||s,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,o.validateFunctionCode)(h),f.optimize(this.opts.code.optimize);let n=f.toString();g=`${f.scopeRefs(r.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let i=Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(m,{ref:i}),i.errors=null,i.schema=e.schema,i.schemaEnv=e,e.$async&&(i.$async=!0),this.opts.code.source===!0&&(i.source={validateName:m,validateCode:n,scopeValues:f._values}),this.opts.unevaluated){let{props:e,items:n}=h;i.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},i.source&&(i.source.evaluated=(0,t.stringify)(i.evaluated))}return e.validate=i,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=c;function l(e,t,n){n=(0,i.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let a=p.call(this,e,n);if(a===void 0){let r=e.localRefs?.[n],{schemaId:i}=this.opts;r&&(a=new s({schema:r,schemaId:i,root:e,baseId:t}))}if(a!==void 0)return e.refs[n]=u.call(this,a)}e.resolveRef=l;function u(e){return(0,i.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:c.call(this,e)}function d(e){for(let t of this._compilations)if(f(t,e))return t}e.getCompilingSchema=d;function f(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function p(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||m.call(this,e,t)}function m(e,t){let n=this.opts.uriResolver.parse(t),r=(0,i._getFullPath)(this.opts.uriResolver,n),a=(0,i.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===a)return g.call(this,n,e);let o=(0,i.normalizeId)(r),l=this.refs[o]||this.schemas[o];if(typeof l==`string`){let t=m.call(this,e,l);return typeof t?.schema==`object`?g.call(this,n,t):void 0}if(typeof l?.schema==`object`){if(l.validate||c.call(this,l),o===(0,i.normalizeId)(t)){let{schema:t}=l,{schemaId:n}=this.opts,r=t[n];return r&&(a=(0,i.resolveUrl)(this.opts.uriResolver,a,r)),new s({schema:t,schemaId:n,root:e,baseId:a})}return g.call(this,n,l)}}e.resolveSchema=m;let h=/* @__PURE__ */ new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function g(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,a.unescapeFragment)(r)];if(e===void 0)return;n=e;let o=typeof n==`object`&&n[this.opts.schemaId];!h.has(r)&&o&&(t=(0,i.resolveUrl)(this.opts.uriResolver,t,o))}let o;if(typeof n!=`boolean`&&n.$ref&&!(0,a.schemaHasRulesButRef)(n,this.RULES)){let e=(0,i.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=m.call(this,r,e)}let{schemaId:c}=this.opts;if(o||=new s({schema:n,schemaId:c,root:r,baseId:t}),o.schema!==o.root.schema)return o}})),_f=/* @__PURE__ */ E(((e,t)=>{t.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}})),vf=/* @__PURE__ */ E(((e,t)=>{let n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=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),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function s(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}let c=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function l(e){return e.length=0,!0}function u(e,t,n){if(e.length){let r=s(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function d(e){let t=0,n={error:!1,address:``,zone:``},r=[],i=[],a=!1,o=!1,c=u;for(let s=0;s<e.length;s++){let u=e[s];if(u!==`[`&&u!==`]`){if(u===`:`){if(a===!0&&(o=!0),!c(i,r,n))break;if(++t>7){n.error=!0;break}s>0&&e[s-1]===`:`&&(a=!0),r.push(`:`);continue}if(u===`%`){if(!c(i,r,n))break;c=l}else{i.push(u);continue}}}return i.length&&(c===l?n.zone=i.join(``):o?r.push(i.join(``)):r.push(s(i))),n.address=r.join(``),n}function f(e){if(p(e,`:`)<2)return{host:e,isIPV6:!1};let t=d(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function p(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function m(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}n.push(t);break}if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}let h={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},g=/[@/?#:]/g,_=/[@/?#]/g;function v(e,t){let n=t?_:g;return n.lastIndex=0,e.replace(n,e=>h[e])}function y(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function b(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}o(e[n])?t+=e[n]:t+=escape(e[n])}return t}function x(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function ee(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let e=f(n);n=e.isIPV6===!0?`[${e.escapedHost}]`:v(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:c,recomposeAuthority:ee,reescapeHostDelimiters:v,normalizePercentEncoding:y,normalizePathEncoding:b,escapePreservingEscapes:x,removeDotSegments:m,isIPv4:r,isUUID:n,normalizeIPv6:f,stringArrayToHexStripped:s}})),yf=/* @__PURE__ */ E(((e,t)=>{let{isUUID:n}=vf(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}let h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),bf=/* @__PURE__ */ E(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=vf(),{SCHEMES:d,getSchemeHandler:f}=yf();function p(e,t){return typeof e==`string`?e=ee(e,t):typeof e==`object`&&(e=x(_(e,t),t)),e}function m(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=h(x(e,r),x(t,r),r,!0);return r.skipEscape=!0,_(i,r)}function h(e,t,n,i){let a={};return i||(e=x(_(e,n),n),t=x(_(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):(a.path=(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?`/`+t.path:e.path?e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,a.query=t.query===void 0?e.query:t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function g(e,t,n){let r=ne(e,n),i=ne(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function _(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[],l=f(o.scheme||n.scheme);l&&l.serialize&&l.serialize(n,o),n.path!==void 0&&(o.skipEscape?n.path=a(n.path):(n.path=s(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),o.reference!==`suffix`&&n.scheme&&c.push(n.scheme,`:`);let u=i(n);if(u!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(u),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!l||!l.absolutePath)&&(e=r(e)),u===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,n.query),n.fragment!==void 0&&c.push(`#`,n.fragment),c.join(``)}let v=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function y(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function b(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1,s=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let d=e.match(v);if(d){i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||``,i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]);let t=y(i,d);if(t!==void 0&&(i.error=i.error||t,a=!0),i.host){if(l(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),s=e.isIPV6}else s=!0}i.reference=i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?`same-document`:i.scheme===void 0?`relative`:i.fragment===void 0?`absolute`:`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let p=f(r.scheme||i.scheme);if(!r.unicodeSupport&&(!p||!p.unicodeSupport)&&i.host&&(r.domainHost||p&&p.domainHost)&&s===!1&&u(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}if((!p||p&&!p.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=c(unescape(i.host),s))),i.path&&=o(i.path),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||`URI malformed`}p&&p.parse&&p.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:a}}function x(e,t){return b(e,t).parsed}function ee(e,t){return te(e,t).normalized}function te(e,t){let{parsed:n,malformedAuthorityOrPort:r}=b(e,t);return{normalized:r?e:_(n,t),malformedAuthorityOrPort:r}}function ne(e,t){if(typeof e==`string`){let{normalized:n,malformedAuthorityOrPort:r}=te(e,t);return r?void 0:n}if(typeof e==`object`)return _(e,t)}let re={SCHEMES:d,normalize:p,resolve:m,resolveComponent:h,equal:g,serialize:_,parse:x};t.exports=re,t.exports.default=re,t.exports.fastUri=re})),xf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=bf();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),Sf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=pf();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var n=q();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return n.CodeGen}});let r=mf(),i=hf(),a=nf(),o=gf(),s=q(),c=ff(),l=af(),u=J(),d=_f(),f=xf(),p=(e,t)=>new RegExp(e,t);p.code=`new RegExp`;let m=[`removeAdditional`,`useDefaults`,`coerceTypes`],h=/* @__PURE__ */ new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),g={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.`},_={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function v(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??p,a=e.uriResolver??f.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var y=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=/* @__PURE__ */ new Set,this._loading={},this._cache=/* @__PURE__ */ new Map,e=this.opts={...e,...v(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new s.ValueScope({scope:{},prefixes:h,es5:t,lines:n}),this.logger=ae(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),b.call(this,g,e,`NOT SUPPORTED`),b.call(this,_,e,`DEPRECATED`,`warn`),this._metaOpts=re.call(this),e.formats&&te.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&ne.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),ee.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=d;n===`id`&&(r={...d},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await a.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||o.call(this,n)}async function a(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof i.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await a.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw 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 r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=x.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new o.SchemaEnv({schema:{},schemaId:n});if(t=o.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}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 t=x.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,c.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(se.call(this,n,t),!t)return(0,u.eachItem)(n,e=>ce.call(this,e)),this;ue.call(this,t);let r={...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(n,r.type.length===0?e=>ce.call(this,e,r):e=>r.type.forEach(t=>ce.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=fe(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof e==`object`)a=e[s];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let l=this._cache.get(e);if(l!==void 0)return l;n=(0,c.normalizeId)(a||n);let u=c.getSchemaRefs.call(this,e,n);return l=new o.SchemaEnv({schema:e,schemaId:s,meta:t,baseId:n,localRefs:u}),this._cache.set(l.schema,l),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=l),r&&this.validateSchema(e,!0),l}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){
43
43
  /* istanbul ignore if */
44
- if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};y.ValidationError=r.default,y.MissingRefError=i.default,e.default=y;function ee(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function b(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function te(){let e=this.opts.schemas;if(e){if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}}function ne(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function re(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function ie(){let e={...this.opts};for(let t of m)delete e[t];return e}let ae={log(){},warn(){},error(){}};function oe(e){if(e===!1)return ae;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let se=/^[a-z_$][a-z0-9_$:-]*$/i;function ce(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!se.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function le(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?ue.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function ue(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function de(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=pe(t)),e.validateSchema=this.compile(t,!0))}let fe={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function pe(e){return{anyOf:[e,fe]}}})),uf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),df=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;let t=tf(),n=qd(),r=q(),i=Bd(),a=nf(),o=J(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);return h instanceof a.SchemaEnv?_(h):v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0){if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}}if(l.items!==!0){if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}}e.callRef=l,e.default=s})),ff=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=uf(),n=df();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),pf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),mf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),hf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),gf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r=hf();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),_f=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qd(),n=J(),r=q();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),vf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),yf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qd(),n=q(),r=J();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),bf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),xf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Xd();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Sf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Gd(),n=q(),r=J(),i=xf();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),Cf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r=xf();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),wf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r=xf();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{
44
+ if(e.meta?this._compileMetaSchema(e):o.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{o.compileSchema.call(this,e)}finally{this.opts=t}}};y.ValidationError=r.default,y.MissingRefError=i.default,e.default=y;function b(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function x(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function ee(){let e=this.opts.schemas;if(e){if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}}function te(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function ne(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function re(){let e={...this.opts};for(let t of m)delete e[t];return e}let ie={log(){},warn(){},error(){}};function ae(e){if(e===!1)return ie;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let oe=/^[a-z_$][a-z0-9_$:-]*$/i;function se(e,t){let{RULES:n}=this;if((0,u.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!oe.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function ce(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,l.getJSONTypes)(t.type),schemaType:(0,l.getJSONTypes)(t.schemaType)}};t.before?le.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function le(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function ue(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=fe(t)),e.validateSchema=this.compile(t,!0))}let de={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function fe(e){return{anyOf:[e,de]}}})),Cf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),wf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;let t=hf(),n=sf(),r=q(),i=$d(),a=gf(),o=J(),s={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:i,it:o}=e,{baseId:s,schemaEnv:u,validateName:d,opts:f,self:p}=o,{root:m}=u;if((i===`#`||i===`#/`)&&s===m.baseId)return g();let h=a.resolveRef.call(p,m,s,i);if(h===void 0)throw new t.default(o.opts.uriResolver,s,i);return h instanceof a.SchemaEnv?_(h):v(h);function g(){if(u===m)return l(e,d,u,u.$async);let t=n.scopeValue(`root`,{ref:m});return l(e,(0,r._)`${t}.validate`,m,m.$async)}function _(t){l(e,c(e,t),t,t.$async)}function v(t){let a=n.scopeValue(`schema`,f.code.source===!0?{ref:t,code:(0,r.stringify)(t)}:{ref:t}),o=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:r.nil,topSchemaRef:a,errSchemaPath:i},o);e.mergeEvaluated(s),e.ok(o)}}};function c(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,r._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=c;function l(e,t,a,s){let{gen:c,it:l}=e,{allErrors:u,schemaEnv:d,opts:f}=l,p=f.passContext?i.default.this:r.nil;s?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let i=c.let(`valid`);c.try(()=>{c.code((0,r._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||c.assign(i,!0)},e=>{c.if((0,r._)`!(${e} instanceof ${l.ValidationError})`,()=>c.throw(e)),g(e),u||c.assign(i,!1)}),e.ok(i)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,r._)`${e}.errors`;c.assign(i.default.vErrors,(0,r._)`${i.default.vErrors} === null ? ${t} : ${i.default.vErrors}.concat(${t})`),c.assign(i.default.errors,(0,r._)`${i.default.vErrors}.length`)}function _(e){if(!l.opts.unevaluated)return;let t=a?.validate?.evaluated;if(l.props!==!0){if(t&&!t.dynamicProps)t.props!==void 0&&(l.props=o.mergeEvaluated.props(c,t.props,l.props));else{let t=c.var(`props`,(0,r._)`${e}.evaluated.props`);l.props=o.mergeEvaluated.props(c,t,l.props,r.Name)}}if(l.items!==!0){if(t&&!t.dynamicItems)t.items!==void 0&&(l.items=o.mergeEvaluated.items(c,t.items,l.items));else{let t=c.var(`items`,(0,r._)`${e}.evaluated.items`);l.items=o.mergeEvaluated.items(c,t,l.items,r.Name)}}}}e.callRef=l,e.default=s})),Tf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Cf(),n=wf();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),Ef=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=t.operators,r={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(r),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${r[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${r[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:i,schemaCode:a}=e;e.fail$data((0,t._)`${i} ${r[n].fail} ${a} || isNaN(${i})`)}}})),Df=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),Of=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),kf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r=Of();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:i,data:a,schemaCode:o,it:s}=e,c=i===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${a}.length`:(0,t._)`${(0,n.useFunc)(e.gen,r.default)}(${a})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),Af=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=sf(),n=J(),r=q();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,r.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,r._)`{pattern: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,r._)`new RegExp`:(0,n.useFunc)(i,t),s=i.let(`valid`);i.try(()=>i.assign(s,(0,r._)`${o}(${c}, ${u}).test(${a})`),()=>i.assign(s,!1)),e.fail$data((0,r._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,r._)`!${n}.test(${a})`)}}}})),jf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),Mf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=sf(),n=q(),r=J();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:i,schema:a,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&a.length===0)return;let d=a.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of a)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of a)(0,t.checkReportMissingProp)(e,n)}function p(){let n=i.let(`missing`);if(d||c){let t=i.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else i.if((0,t.checkMissingProp)(e,a,n)),(0,t.reportMissingProp)(e,n),i.else()}function m(){i.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),i.if((0,t.noPropertyInData)(i,s,n,u.ownProperties),()=>e.error())})}function h(r,a){e.setParams({missingProperty:r}),i.forOf(r,o,()=>{i.assign(a,(0,t.propertyInData)(i,s,r,u.ownProperties)),i.if((0,n.not)(a),()=>{e.error(),i.break()})},n.nil)}}}})),Nf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),Pf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=uf();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),Ff=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=af(),n=q(),r=J(),i=Pf();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:a,data:o,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=a.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=a.let(`i`,(0,n._)`${o}.length`),r=a.let(`j`);e.setParams({i:t,j:r}),a.assign(f,!0),a.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,r))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(r,i){let s=a.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=a.const(`indices`,(0,n._)`{}`);a.for((0,n._)`;${r}--;`,()=>{a.let(s,(0,n._)`${o}[${r}]`),a.if(c,(0,n._)`continue`),p.length>1&&a.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),a.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{a.assign(i,(0,n._)`${l}[${s}]`),e.error(),a.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${r}`)})}function _(t,s){let c=(0,r.useFunc)(a,i.default),l=a.name(`outer`);a.label(l).for((0,n._)`;${t}--;`,()=>a.for((0,n._)`${s} = ${t}; ${s}--;`,()=>a.if((0,n._)`${c}(${o}[${t}], ${o}[${s}])`,()=>{e.error(),a.assign(f,!1).break(l)})))}}}})),If=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r=Pf();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:i,data:a,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(i,r.default)}(${a}, ${s})`):e.fail((0,t._)`${c} !== ${a}`)}}})),Lf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r=Pf();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:i,data:a,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(i,r.default),p;if(u||o)p=i.let(`valid`),e.block$data(p,m);else{
45
45
  /* istanbul ignore if */
46
- if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),Tf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=pf(),n=mf(),r=gf(),i=_f(),a=vf(),o=yf(),s=bf(),c=Sf(),l=Cf(),u=wf();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),Ef=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;let t=q(),n=J(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),Df=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;let t=q(),n=J(),r=qd(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),Of=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Df();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),kf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r=qd(),i=Ef();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),Af=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),jf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=q(),n=J(),r=qd();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
46
+ if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=i.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){i.assign(p,!1),i.forOf(`v`,c,e=>i.if((0,t._)`${f()}(${a}, ${e})`,()=>i.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${a}, ${e}[${n}])`:(0,t._)`${a} === ${r}`}}}})),Rf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ef(),n=Df(),r=kf(),i=Af(),a=jf(),o=Mf(),s=Nf(),c=Ff(),l=If(),u=Lf();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),zf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;let t=q(),n=J(),r={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}i(e,a)}};function i(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=i,e.default=r})),Bf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;let t=q(),n=J(),r=sf(),i={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:i}=e;if(Array.isArray(t))return a(e,`additionalItems`,t);i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&e.ok((0,r.validateArray)(e))}};function a(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=a,e.default=i})),Vf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Bf();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),Hf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r=sf(),i=zf();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:a,it:o}=e,{prefixItems:s}=a;o.items=!0,!(0,n.alwaysValidSchema)(o,t)&&(s?(0,i.validateAdditionalItems)(e,s):e.ok((0,r.validateArray)(e)))}}})),Uf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),Wf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=q(),n=J(),r=sf();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
47
47
  missingProperty: ${i},
48
48
  depsCount: ${n},
49
- deps: ${r}}`};let i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),Mf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),Nf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qd(),n=q(),r=Bd(),i=J();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;
49
+ deps: ${r}}`};let i={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=a(e);o(e,t),s(e,n)}};function a({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function o(e,n=e.schema){let{gen:i,data:a,it:o}=e;if(Object.keys(n).length===0)return;let s=i.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,r.propertyInData)(i,a,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?i.if(u,()=>{for(let t of l)(0,r.checkReportMissingProp)(e,t)}):(i.if((0,t._)`${u} && (${(0,r.checkMissingProp)(e,l,s)})`),(0,r.reportMissingProp)(e,s),i.else())}}e.validatePropertyDeps=o;function s(e,t=e.schema){let{gen:i,data:a,keyword:o,it:s}=e,c=i.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(i.if((0,r.propertyInData)(i,a,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>i.var(c,!0)),e.ok(c))}e.validateSchemaDeps=s,e.default=i})),Gf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),Kf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=sf(),n=q(),r=$d(),i=J();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:a,schema:o,parentSchema:s,data:c,errsCount:l,it:u}=e;
50
50
  /* istanbul ignore if */
51
- if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),Pf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=$d(),n=qd(),r=J(),i=Nf();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),Ff=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=qd(),n=q(),r=J(),i=J();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),If=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=J();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),Lf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:qd().validateUnion,error:{message:`must match a schema in anyOf`}}})),Rf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;
51
+ if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,i.alwaysValidSchema)(u,o))return;let p=(0,t.allSchemaProperties)(s.properties),m=(0,t.allSchemaProperties)(s.patternProperties);h(),e.ok((0,n._)`${l} === ${r.default.errors}`);function h(){a.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):a.if(g(e),()=>v(e))})}function g(r){let o;if(p.length>8){let e=(0,i.schemaRefOrVal)(u,s.properties,`properties`);o=(0,t.isOwnProperty)(a,e,r)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${r} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(i=>(0,n._)`${(0,t.usePattern)(e,i)}.test(${r})`))),(0,n.not)(o)}function _(e){a.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&o===!1){_(t);return}if(o===!1){e.setParams({additionalProperty:t}),e.error(),d||a.break();return}if(typeof o==`object`&&!(0,i.alwaysValidSchema)(u,o)){let r=a.name(`valid`);f.removeAdditional===`failing`?(y(t,r,!1),a.if((0,n.not)(r),()=>{e.reset(),_(t)})):(y(t,r),d||a.if((0,n.not)(r),()=>a.break()))}}function y(t,n,r){let a={keyword:`additionalProperties`,dataProp:t,dataPropType:i.Type.Str};r===!1&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(a,n)}}}})),qf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=pf(),n=sf(),r=J(),i=Kf();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&i.default.code(new t.KeywordCxt(l,i.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=a.name(`valid`);for(let t of d)p(t)?m(t):(a.if((0,n.propertyInData)(a,c,t,l.opts.ownProperties)),m(t),l.allErrors||a.else().var(f,!0),a.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),Jf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=sf(),n=q(),r=J(),i=J();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:a,schema:o,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(o),f=d.filter(e=>(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=a.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,i.evaluatedPropsToName)(a,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(a.var(m,!0),v(e),a.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,r.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(r){a.forIn(`key`,s,o=>{a.if((0,n._)`${(0,t.usePattern)(e,r)}.test(${o})`,()=>{let t=f.includes(r);t||e.subschema({keyword:`patternProperties`,schemaProp:r,dataProp:o,dataPropType:i.Type.Str},m),l.opts.unevaluated&&h!==!0?a.assign((0,n._)`${h}[${o}]`,!0):!t&&!l.allErrors&&a.if((0,n.not)(m),()=>a.break())})})}}}})),Yf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=J();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),Xf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:sf().validateUnion,error:{message:`must match a schema in anyOf`}}})),Zf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;
52
52
  /* istanbul ignore if */
53
- if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),zf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=J();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;
53
+ if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),Qf=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=J();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;
54
54
  /* istanbul ignore if */
55
- if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),Bf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),Vf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=J();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),Hf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Ef(),n=Of(),r=Df(),i=kf(),a=Af(),o=jf(),s=Mf(),c=Nf(),l=Pf(),u=Ff(),d=If(),f=Lf(),p=Rf(),m=zf(),h=Bf(),g=Vf();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),Uf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),Wf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=[Uf().default]})),Gf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),Kf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=ff(),n=Tf(),r=Hf(),i=Wf(),a=Gf();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),qf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),Jf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=qf(),r=nf(),i=tf(),a=J();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),Yf=/* @__PURE__ */ T(((e,t)=>{t.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}})),Xf=/* @__PURE__ */ T(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let n=lf(),r=Kf(),i=Jf(),a=Yf(),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`;var c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var l=$d();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=q();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=ef();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return d.default}});var f=tf();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return f.default}})})),Zf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c(!0),l),"date-time":t(f(!0),p),"iso-time":t(c(),u),"iso-date-time":t(f(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"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:ae,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:y,int32:{type:`number`,validate:te},int64:{type:`number`,validate:ne},float:{type:`number`,validate:re},double:{type:`number`,validate:re},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\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,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\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,m),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},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}let r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}let s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(e){return function(t){let n=s.exec(t);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4],c=n[5]===`-`?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!o)return!1;if(r<=23&&i<=59&&a<60)return!0;let d=i-u*c,f=r-l*c-+(d<0);return(f===23||f===-1)&&(d===59||d===-1)&&a<61}}function l(e,t){if(!(e&&t))return;let n=(/* @__PURE__ */ new Date(`2020-01-01T`+e)).valueOf(),r=(/* @__PURE__ */ new Date(`2020-01-01T`+t)).valueOf();if(n&&r)return n-r}function u(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3],t=r[1]+r[2]+r[3],e>t?1:e<t?-1:0}let d=/t|\s/i;function f(e){let t=c(e);return function(e){let n=e.split(d);return n.length===2&&a(n[0])&&t(n[1])}}function p(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),r=new Date(t).valueOf();if(n&&r)return n-r}function m(e,t){if(!(e&&t))return;let[n,r]=e.split(d),[i,a]=t.split(d),s=o(n,i);if(s!==void 0)return s||l(r,a)}let h=/\/|:/,g=/^(?:[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 _(e){return h.test(e)&&g.test(e)}let v=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(e){return v.lastIndex=0,v.test(e)}let ee=-(2**31),b=2**31-1;function te(e){return Number.isInteger(e)&&e<=b&&e>=ee}function ne(e){return Number.isInteger(e)}function re(){return!0}let ie=/[^\\]\\Z/;function ae(e){if(ie.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),Qf=/* @__PURE__ */ T((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;let t=Xf(),n=q(),r=n.operators,i={formatMaximum:{okStr:`<=`,ok:r.LTE,fail:r.GT},formatMinimum:{okStr:`>=`,ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:`<`,ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:`>`,ok:r.GT,fail:r.LTE}};e.formatLimitDefinition={keyword:Object.keys(i),type:`string`,schemaType:`string`,$data:!0,error:{message:({keyword:e,schemaCode:t})=>(0,n.str)`should be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,n._)`{comparison: ${i[e].okStr}, limit: ${t}}`},code(e){let{gen:r,data:a,schemaCode:o,keyword:s,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;let d=new t.KeywordCxt(c,u.RULES.all.format.definition,`format`);d.$data?f():p();function f(){let t=r.scopeValue(`formats`,{ref:u.formats,code:l.code.formats}),i=r.const(`fmt`,(0,n._)`${t}[${d.schemaCode}]`);e.fail$data((0,n.or)((0,n._)`typeof ${i} != "object"`,(0,n._)`${i} instanceof RegExp`,(0,n._)`typeof ${i}.compare != "function"`,m(i)))}function p(){let t=d.schema,i=u.formats[t];if(!i||i===!0)return;if(typeof i!=`object`||i instanceof RegExp||typeof i.compare!=`function`)throw Error(`"${s}": format "${t}" does not define "compare" function`);let a=r.scopeValue(`formats`,{key:t,ref:i,code:l.code.formats?(0,n._)`${l.code.formats}${(0,n.getProperty)(t)}`:void 0});e.fail$data(m(a))}function m(e){return(0,n._)`${e}.compare(${a}, ${o}) ${i[s].fail} 0`}},dependencies:[`format`]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)})),$f=/* @__PURE__ */ T(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});let n=Zf(),r=Qf(),i=q(),a=new i.Name(`fullFormats`),o=new i.Name(`fastFormats`),s=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,n.fullFormats,a),e;let[i,s]=t.mode===`fast`?[n.fastFormats,o]:[n.fullFormats,a];return c(e,t.formats||n.formatNames,i,s),t.keywords&&(0,r.default)(e),e};s.get=(e,t=`full`)=>{let r=(t===`fast`?n.fastFormats:n.fullFormats)[e];if(!r)throw Error(`Unknown format "${e}"`);return r};function c(e,t,n,r){var a;(a=e.opts.code).formats??(a.formats=(0,i._)`require("ajv-formats/dist/formats").${r}`);for(let r of t)e.addFormat(r,n[r])}t.exports=e=s,Object.defineProperty(e,"__esModule",{value:!0}),e.default=s})),ep=/* @__PURE__ */ nt(Xf(),1),tp=/* @__PURE__ */ nt($f(),1);function np(){let e=new ep.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,tp.default)(e),e}var rp=class{constructor(e){this._ajv=e??np()}getValidator(e){let t=`$id`in e&&typeof e.$id==`string`?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}},ip=class{constructor(e){this._client=e}async*callToolStream(e,t=Gu,n){let r=this._client,i={...n,task:n?.task??(r.isToolTask(e.name)?{}:void 0)},a=r.requestStream({method:`tools/call`,params:e},t,i),o=r.getToolOutputValidator(e.name);for await(let t of a){if(t.type===`result`&&o){let n=t.result;if(!n.structuredContent&&!n.isError){yield{type:`error`,error:new K(G.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(n.structuredContent)try{let e=o(n.structuredContent);if(!e.valid){yield{type:`error`,error:new K(G.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)};return}}catch(e){if(e instanceof K){yield{type:`error`,error:e};return}yield{type:`error`,error:new K(G.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)};return}}yield t}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._client.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,n){return this._client.requestStream(e,t,n)}};function ap(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);if(t===`tools/call`&&!e.tools?.call)throw Error(`${n} does not support task creation for tools/call (required for ${t})`)}function op(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`sampling/createMessage`:if(!e.sampling?.createMessage)throw Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case`elicitation/create`:if(!e.elicitation?.create)throw Error(`${n} does not support task creation for elicitation/create (required for ${t})`)}}function sp(e,t){if(e&&typeof t==`object`&&t){if(e.type===`object`&&e.properties&&typeof e.properties==`object`){let n=t,r=e.properties;for(let e of Object.keys(r)){let t=r[e];n[e]===void 0&&Object.prototype.hasOwnProperty.call(t,`default`)&&(n[e]=t.default),n[e]!==void 0&&sp(t,n[e])}}if(Array.isArray(e.anyOf))for(let n of e.anyOf)typeof n!=`boolean`&&sp(n,t);if(Array.isArray(e.oneOf))for(let n of e.oneOf)typeof n!=`boolean`&&sp(n,t)}}function cp(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,n=e.url!==void 0;return{supportsFormMode:t||!t&&!n,supportsUrlMode:n}}var lp=class extends Fd{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=/* @__PURE__ */ new Map,this._cachedKnownTaskTools=/* @__PURE__ */ new Set,this._cachedRequiredTaskTools=/* @__PURE__ */ new Set,this._listChangedDebounceTimers=/* @__PURE__ */ new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new rp,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler(`tools`,Ju,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler(`prompts`,zu,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler(`resources`,vu,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||={tasks:new ip(this)},this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=Ld(this._capabilities,e)}setRequestHandler(e,t){let n=_s(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r=vs(n);if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);let i=r;return i===`elicitation/create`?super.setRequestHandler(e,async(e,n)=>{let r=gs(vd,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new K(G.InvalidParams,`Invalid elicitation request: ${e}`)}let{params:i}=r.data;i.mode=i.mode??`form`;let{supportsFormMode:a,supportsUrlMode:o}=cp(this._capabilities.elicitation);if(i.mode===`form`&&!a)throw new K(G.InvalidParams,`Client does not support form-mode elicitation requests`);if(i.mode===`url`&&!o)throw new K(G.InvalidParams,`Client does not support URL-mode elicitation requests`);let s=await Promise.resolve(t(e,n));if(i.task){let e=gs(Kl,s);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new K(G.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let c=gs(xd,s);if(!c.success){let e=c.error instanceof Error?c.error.message:String(c.error);throw new K(G.InvalidParams,`Invalid elicitation result: ${e}`)}let l=c.data,u=i.mode===`form`?i.requestedSchema:void 0;if(i.mode===`form`&&l.action===`accept`&&l.content&&u&&this._capabilities.elicitation?.form?.applyDefaults)try{sp(u,l.content)}catch{}return l}):i===`sampling/createMessage`?super.setRequestHandler(e,async(e,n)=>{let r=gs(cd,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new K(G.InvalidParams,`Invalid sampling request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=gs(Kl,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new K(G.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=gs(i.tools||i.toolChoice?ud:ld,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new K(G.InvalidParams,`Invalid sampling result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:`initialize`,params:{protocolVersion:Yc,capabilities:this._capabilities,clientInfo:this._clientInfo}},Pl,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);if(!Xc.includes(n.protocolVersion))throw Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:`notifications/initialized`}),this._pendingListChangedConfig&&=(this._setupListChangedHandlers(this._pendingListChangedConfig),void 0)}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case`logging/setLevel`:if(!this._serverCapabilities?.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._serverCapabilities?.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:case`resources/subscribe`:case`resources/unsubscribe`:if(!this._serverCapabilities?.resources)throw Error(`Server does not support resources (required for ${e})`);if(e===`resources/subscribe`&&!this._serverCapabilities.resources.subscribe)throw Error(`Server does not support resource subscriptions (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._serverCapabilities?.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`completion/complete`:if(!this._serverCapabilities?.completions)throw Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){if(e===`notifications/roots/list_changed`&&!this._capabilities.roots?.listChanged)throw Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`sampling/createMessage`:if(!this._capabilities.sampling)throw Error(`Client does not support sampling capability (required for ${e})`);break;case`elicitation/create`:if(!this._capabilities.elicitation)throw Error(`Client does not support elicitation capability (required for ${e})`);break;case`roots/list`:if(!this._capabilities.roots)throw Error(`Client does not support roots capability (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Client does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){ap(this._serverCapabilities?.tasks?.requests,e,`Server`)}assertTaskHandlerCapability(e){this._capabilities&&op(this._capabilities.tasks?.requests,e,`Client`)}async ping(e){return this.request({method:`ping`},xl,e)}async complete(e,t){return this.request({method:`completion/complete`,params:e},Ed,t)}async setLoggingLevel(e,t){return this.request({method:`logging/setLevel`,params:{level:e}},xl,t)}async getPrompt(e,t){return this.request({method:`prompts/get`,params:e},Ru,t)}async listPrompts(e,t){return this.request({method:`prompts/list`,params:e},Ou,t)}async listResources(e,t){return this.request({method:`resources/list`,params:e},du,t)}async listResourceTemplates(e,t){return this.request({method:`resources/templates/list`,params:e},pu,t)}async readResource(e,t){return this.request({method:`resources/read`,params:e},_u,t)}async subscribeResource(e,t){return this.request({method:`resources/subscribe`,params:e},xl,t)}async unsubscribeResource(e,t){return this.request({method:`resources/unsubscribe`,params:e},xl,t)}async callTool(e,t=Gu,n){if(this.isToolTaskRequired(e.name))throw new K(G.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let r=await this.request({method:`tools/call`,params:e},t,n),i=this.getToolOutputValidator(e.name);if(i){if(!r.structuredContent&&!r.isError)throw new K(G.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{let e=i(r.structuredContent);if(!e.valid)throw new K(G.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){throw e instanceof K?e:new K(G.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return r}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let t of e){if(t.outputSchema){let e=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}let e=t.execution?.taskSupport;(e===`required`||e===`optional`)&&this._cachedKnownTaskTools.add(t.name),e===`required`&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){let n=await this.request({method:`tools/list`,params:e},Wu,t);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,t,n,r){let i=Yu.safeParse(n);if(!i.success)throw Error(`Invalid ${e} listChanged options: ${i.error.message}`);if(typeof n.onChanged!=`function`)throw Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:a,debounceMs:o}=i.data,{onChanged:s}=n,c=async()=>{if(!a){s(null,null);return}try{let e=await r();s(null,e)}catch(e){let t=e instanceof Error?e:Error(String(e));s(t,null)}};this.setNotificationHandler(t,()=>{if(o){let t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);let n=setTimeout(c,o);this._listChangedDebounceTimers.set(e,n)}else c()})}async sendRootsListChanged(){return this.notification({method:`notifications/roots/list_changed`})}},up=/* @__PURE__ */ nt((/* @__PURE__ */ T((e=>{
55
+ if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),$f=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=J(),r={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:a,it:o}=e;a.then===void 0&&a.else===void 0&&(0,n.checkStrictMode)(o,`"if" without "then" and "else" is ignored`);let s=i(o,`then`),c=i(o,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function i(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=r})),ep=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=J();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),tp=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=zf(),n=Vf(),r=Bf(),i=Hf(),a=Uf(),o=Wf(),s=Gf(),c=Kf(),l=qf(),u=Jf(),d=Yf(),f=Xf(),p=Zf(),m=Qf(),h=$f(),g=ep();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),np=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),rp=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=[np().default]})),ip=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),ap=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Tf(),n=Rf(),r=tp(),i=rp(),a=ip();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),op=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),sp=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=q(),n=op(),r=gf(),i=hf(),a=J();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:o,data:s,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=o.let(`valid`,!1),m=o.const(`tag`,(0,t._)`${s}${(0,t.getProperty)(f)}`);o.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let r=_();o.if(!1);for(let e in r)o.elseIf((0,t._)`${m} === ${e}`),o.assign(p,g(r[e]));o.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),o.endIf()}function g(n){let r=o.name(`valid`),i=e.subschema({keyword:`oneOf`,schemaProp:n},r);return e.mergeEvaluated(i,t.Name),r}function _(){let e={},t=o(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,a.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=r.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof r.SchemaEnv&&(c=c.schema),c===void 0)throw new i.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||o(c),s(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function o({required:e}){return Array.isArray(e)&&e.includes(f)}function s(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),cp=/* @__PURE__ */ E(((e,t)=>{t.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}})),lp=/* @__PURE__ */ E(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let n=Sf(),r=ap(),i=sp(),a=cp(),o=[`/properties`],s=`http://json-schema.org/draft-07/schema`;var c=class extends n.default{_addVocabularies(){super._addVocabularies(),r.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(i.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(a,o):a;this.addMetaSchema(e,s,!1),this.refs[`http://json-schema.org/schema`]=s}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}};e.Ajv=c,t.exports=e=c,t.exports.Ajv=c,Object.defineProperty(e,"__esModule",{value:!0}),e.default=c;var l=pf();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var u=q();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var d=mf();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return d.default}});var f=hf();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return f.default}})})),up=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0;function t(e,t){return{validate:e,compare:t}}e.fullFormats={date:t(a,o),time:t(c(!0),l),"date-time":t(f(!0),p),"iso-time":t(c(),u),"iso-date-time":t(f(),m),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:_,"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:ie,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:y,int32:{type:`number`,validate:ee},int64:{type:`number`,validate:te},float:{type:`number`,validate:ne},double:{type:`number`,validate:ne},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,o),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,l),"date-time":t(/^\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,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\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,m),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},e.formatNames=Object.keys(e.fullFormats);function n(e){return e%4==0&&(e%100!=0||e%400==0)}let r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function a(e){let t=r.exec(e);if(!t)return!1;let a=+t[1],o=+t[2],s=+t[3];return o>=1&&o<=12&&s>=1&&s<=(o===2&&n(a)?29:i[o])}function o(e,t){if(e&&t)return e>t?1:e<t?-1:0}let s=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(e){return function(t){let n=s.exec(t);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=n[4],c=n[5]===`-`?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!o)return!1;if(r<=23&&i<=59&&a<60)return!0;let d=i-u*c,f=r-l*c-+(d<0);return(f===23||f===-1)&&(d===59||d===-1)&&a<61}}function l(e,t){if(!(e&&t))return;let n=(/* @__PURE__ */ new Date(`2020-01-01T`+e)).valueOf(),r=(/* @__PURE__ */ new Date(`2020-01-01T`+t)).valueOf();if(n&&r)return n-r}function u(e,t){if(!(e&&t))return;let n=s.exec(e),r=s.exec(t);if(n&&r)return e=n[1]+n[2]+n[3],t=r[1]+r[2]+r[3],e>t?1:e<t?-1:0}let d=/t|\s/i;function f(e){let t=c(e);return function(e){let n=e.split(d);return n.length===2&&a(n[0])&&t(n[1])}}function p(e,t){if(!(e&&t))return;let n=new Date(e).valueOf(),r=new Date(t).valueOf();if(n&&r)return n-r}function m(e,t){if(!(e&&t))return;let[n,r]=e.split(d),[i,a]=t.split(d),s=o(n,i);if(s!==void 0)return s||l(r,a)}let h=/\/|:/,g=/^(?:[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 _(e){return h.test(e)&&g.test(e)}let v=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(e){return v.lastIndex=0,v.test(e)}let b=-(2**31),x=2**31-1;function ee(e){return Number.isInteger(e)&&e<=x&&e>=b}function te(e){return Number.isInteger(e)}function ne(){return!0}let re=/[^\\]\\Z/;function ie(e){if(re.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),dp=/* @__PURE__ */ E((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;let t=lp(),n=q(),r=n.operators,i={formatMaximum:{okStr:`<=`,ok:r.LTE,fail:r.GT},formatMinimum:{okStr:`>=`,ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:`<`,ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:`>`,ok:r.GT,fail:r.LTE}};e.formatLimitDefinition={keyword:Object.keys(i),type:`string`,schemaType:`string`,$data:!0,error:{message:({keyword:e,schemaCode:t})=>(0,n.str)`should be ${i[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,n._)`{comparison: ${i[e].okStr}, limit: ${t}}`},code(e){let{gen:r,data:a,schemaCode:o,keyword:s,it:c}=e,{opts:l,self:u}=c;if(!l.validateFormats)return;let d=new t.KeywordCxt(c,u.RULES.all.format.definition,`format`);d.$data?f():p();function f(){let t=r.scopeValue(`formats`,{ref:u.formats,code:l.code.formats}),i=r.const(`fmt`,(0,n._)`${t}[${d.schemaCode}]`);e.fail$data((0,n.or)((0,n._)`typeof ${i} != "object"`,(0,n._)`${i} instanceof RegExp`,(0,n._)`typeof ${i}.compare != "function"`,m(i)))}function p(){let t=d.schema,i=u.formats[t];if(!i||i===!0)return;if(typeof i!=`object`||i instanceof RegExp||typeof i.compare!=`function`)throw Error(`"${s}": format "${t}" does not define "compare" function`);let a=r.scopeValue(`formats`,{key:t,ref:i,code:l.code.formats?(0,n._)`${l.code.formats}${(0,n.getProperty)(t)}`:void 0});e.fail$data(m(a))}function m(e){return(0,n._)`${e}.compare(${a}, ${o}) ${i[s].fail} 0`}},dependencies:[`format`]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)})),fp=/* @__PURE__ */ E(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0});let n=up(),r=dp(),i=q(),a=new i.Name(`fullFormats`),o=new i.Name(`fastFormats`),s=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,n.fullFormats,a),e;let[i,s]=t.mode===`fast`?[n.fastFormats,o]:[n.fullFormats,a];return c(e,t.formats||n.formatNames,i,s),t.keywords&&(0,r.default)(e),e};s.get=(e,t=`full`)=>{let r=(t===`fast`?n.fastFormats:n.fullFormats)[e];if(!r)throw Error(`Unknown format "${e}"`);return r};function c(e,t,n,r){var a;(a=e.opts.code).formats??(a.formats=(0,i._)`require("ajv-formats/dist/formats").${r}`);for(let r of t)e.addFormat(r,n[r])}t.exports=e=s,Object.defineProperty(e,"__esModule",{value:!0}),e.default=s})),pp=/* @__PURE__ */ ft(lp(),1),mp=/* @__PURE__ */ ft(fp(),1);function hp(){let e=new pp.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,mp.default)(e),e}var gp=class{constructor(e){this._ajv=e??hp()}getValidator(e){let t=`$id`in e&&typeof e.$id==`string`?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}},_p=class{constructor(e){this._client=e}async*callToolStream(e,t=id,n){let r=this._client,i={...n,task:n?.task??(r.isToolTask(e.name)?{}:void 0)},a=r.requestStream({method:`tools/call`,params:e},t,i),o=r.getToolOutputValidator(e.name);for await(let t of a){if(t.type===`result`&&o){let n=t.result;if(!n.structuredContent&&!n.isError){yield{type:`error`,error:new K(G.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(n.structuredContent)try{let e=o(n.structuredContent);if(!e.valid){yield{type:`error`,error:new K(G.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)};return}}catch(e){if(e instanceof K){yield{type:`error`,error:e};return}yield{type:`error`,error:new K(G.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)};return}}yield t}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._client.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,n){return this._client.requestStream(e,t,n)}};function vp(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);if(t===`tools/call`&&!e.tools?.call)throw Error(`${n} does not support task creation for tools/call (required for ${t})`)}function yp(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`sampling/createMessage`:if(!e.sampling?.createMessage)throw Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case`elicitation/create`:if(!e.elicitation?.create)throw Error(`${n} does not support task creation for elicitation/create (required for ${t})`)}}function bp(e,t){if(e&&typeof t==`object`&&t){if(e.type===`object`&&e.properties&&typeof e.properties==`object`){let n=t,r=e.properties;for(let e of Object.keys(r)){let t=r[e];n[e]===void 0&&Object.prototype.hasOwnProperty.call(t,`default`)&&(n[e]=t.default),n[e]!==void 0&&bp(t,n[e])}}if(Array.isArray(e.anyOf))for(let n of e.anyOf)typeof n!=`boolean`&&bp(n,t);if(Array.isArray(e.oneOf))for(let n of e.oneOf)typeof n!=`boolean`&&bp(n,t)}}function xp(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,n=e.url!==void 0;return{supportsFormMode:t||!t&&!n,supportsUrlMode:n}}var Sp=class extends Jd{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=/* @__PURE__ */ new Map,this._cachedKnownTaskTools=/* @__PURE__ */ new Set,this._cachedRequiredTaskTools=/* @__PURE__ */ new Set,this._listChangedDebounceTimers=/* @__PURE__ */ new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new gp,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler(`tools`,sd,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler(`prompts`,Qu,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler(`resources`,ju,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||={tasks:new _p(this)},this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=Xd(this._capabilities,e)}setRequestHandler(e,t){let n=Os(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r=ks(n);if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);let i=r;return i===`elicitation/create`?super.setRequestHandler(e,async(e,n)=>{let r=Ds(jd,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new K(G.InvalidParams,`Invalid elicitation request: ${e}`)}let{params:i}=r.data;i.mode=i.mode??`form`;let{supportsFormMode:a,supportsUrlMode:o}=xp(this._capabilities.elicitation);if(i.mode===`form`&&!a)throw new K(G.InvalidParams,`Client does not support form-mode elicitation requests`);if(i.mode===`url`&&!o)throw new K(G.InvalidParams,`Client does not support URL-mode elicitation requests`);let s=await Promise.resolve(t(e,n));if(i.task){let e=Ds(au,s);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new K(G.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let c=Ds(Pd,s);if(!c.success){let e=c.error instanceof Error?c.error.message:String(c.error);throw new K(G.InvalidParams,`Invalid elicitation result: ${e}`)}let l=c.data,u=i.mode===`form`?i.requestedSchema:void 0;if(i.mode===`form`&&l.action===`accept`&&l.content&&u&&this._capabilities.elicitation?.form?.applyDefaults)try{bp(u,l.content)}catch{}return l}):i===`sampling/createMessage`?super.setRequestHandler(e,async(e,n)=>{let r=Ds(xd,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new K(G.InvalidParams,`Invalid sampling request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=Ds(au,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new K(G.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=Ds(i.tools||i.toolChoice?Cd:Sd,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new K(G.InvalidParams,`Invalid sampling result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:`initialize`,params:{protocolVersion:cl,capabilities:this._capabilities,clientInfo:this._clientInfo}},ql,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);if(!ll.includes(n.protocolVersion))throw Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:`notifications/initialized`}),this._pendingListChangedConfig&&=(this._setupListChangedHandlers(this._pendingListChangedConfig),void 0)}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case`logging/setLevel`:if(!this._serverCapabilities?.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._serverCapabilities?.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:case`resources/subscribe`:case`resources/unsubscribe`:if(!this._serverCapabilities?.resources)throw Error(`Server does not support resources (required for ${e})`);if(e===`resources/subscribe`&&!this._serverCapabilities.resources.subscribe)throw Error(`Server does not support resource subscriptions (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._serverCapabilities?.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`completion/complete`:if(!this._serverCapabilities?.completions)throw Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){if(e===`notifications/roots/list_changed`&&!this._capabilities.roots?.listChanged)throw Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`sampling/createMessage`:if(!this._capabilities.sampling)throw Error(`Client does not support sampling capability (required for ${e})`);break;case`elicitation/create`:if(!this._capabilities.elicitation)throw Error(`Client does not support elicitation capability (required for ${e})`);break;case`roots/list`:if(!this._capabilities.roots)throw Error(`Client does not support roots capability (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Client does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){vp(this._serverCapabilities?.tasks?.requests,e,`Server`)}assertTaskHandlerCapability(e){this._capabilities&&yp(this._capabilities.tasks?.requests,e,`Client`)}async ping(e){return this.request({method:`ping`},Pl,e)}async complete(e,t){return this.request({method:`completion/complete`,params:e},zd,t)}async setLoggingLevel(e,t){return this.request({method:`logging/setLevel`,params:{level:e}},Pl,t)}async getPrompt(e,t){return this.request({method:`prompts/get`,params:e},Zu,t)}async listPrompts(e,t){return this.request({method:`prompts/list`,params:e},Vu,t)}async listResources(e,t){return this.request({method:`resources/list`,params:e},wu,t)}async listResourceTemplates(e,t){return this.request({method:`resources/templates/list`,params:e},Eu,t)}async readResource(e,t){return this.request({method:`resources/read`,params:e},Au,t)}async subscribeResource(e,t){return this.request({method:`resources/subscribe`,params:e},Pl,t)}async unsubscribeResource(e,t){return this.request({method:`resources/unsubscribe`,params:e},Pl,t)}async callTool(e,t=id,n){if(this.isToolTaskRequired(e.name))throw new K(G.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let r=await this.request({method:`tools/call`,params:e},t,n),i=this.getToolOutputValidator(e.name);if(i){if(!r.structuredContent&&!r.isError)throw new K(G.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{let e=i(r.structuredContent);if(!e.valid)throw new K(G.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){throw e instanceof K?e:new K(G.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return r}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let t of e){if(t.outputSchema){let e=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}let e=t.execution?.taskSupport;(e===`required`||e===`optional`)&&this._cachedKnownTaskTools.add(t.name),e===`required`&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){let n=await this.request({method:`tools/list`,params:e},rd,t);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,t,n,r){let i=cd.safeParse(n);if(!i.success)throw Error(`Invalid ${e} listChanged options: ${i.error.message}`);if(typeof n.onChanged!=`function`)throw Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:a,debounceMs:o}=i.data,{onChanged:s}=n,c=async()=>{if(!a){s(null,null);return}try{let e=await r();s(null,e)}catch(e){let t=e instanceof Error?e:Error(String(e));s(t,null)}};this.setNotificationHandler(t,()=>{if(o){let t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);let n=setTimeout(c,o);this._listChangedDebounceTimers.set(e,n)}else c()})}async sendRootsListChanged(){return this.notification({method:`notifications/roots/list_changed`})}},Cp=/* @__PURE__ */ ft((/* @__PURE__ */ E((e=>{
56
56
  /*!
57
57
  * content-type
58
58
  * Copyright(c) 2015 Douglas Christopher Wilson
59
59
  * MIT Licensed
60
60
  */
61
- var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}})))(),1);function dp(e){if(e)try{return up.parse(e).type}catch{let t=(e.split(`;`,1)[0]??``).trim().toLowerCase();return t===``||e.slice(t.length).includes(`,`)?void 0:t}}function fp(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function pp(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{...fp(t.headers),...fp(r.headers)}:t.headers}):e}const mp=[301,302,303,307,308];function hp(e,t){return e.protocol===t.protocol&&e.hostname===t.hostname&&e.port===t.port||e.hostname===t.hostname&&e.protocol===`http:`&&e.port===``&&t.protocol===`https:`&&t.port===``}function gp(e,t){let n=mp.includes(e.status)?e.headers.get(`location`):null;try{return n?new URL(n,t):void 0}catch{return}}function _p(e,t,n,r,i=0){let a=gp(r,t),o=r.status===307||r.status===308||(n?.method??`GET`).toUpperCase()===`GET`;if(!a||i===5||!o)return;let s=new URL(t);if((!a.username&&!a.password||a.username===s.username&&a.password===s.password)&&hp(s,a))return Promise.resolve(r.body?.cancel()).then(()=>e(a,{...n,redirect:`manual`})).then(t=>_p(e,a,n,t,i+1)??t)}const vp=/* @__PURE__ */ new WeakSet;function yp(e){let t=(t,n)=>(e??fetch)(t,n);return vp.add(t),t}function bp(e=fetch){return vp.has(e)?e:(t,n)=>n?.redirect===`error`||n?.redirect===`manual`?e(t,n):Promise.resolve(e(t,{...n,redirect:`manual`})).then(r=>_p(e,t,n,r)??r)}function xp(e,t){if(e.type===`opaqueredirect`)return`Redirect not followed: this runtime does not expose the redirect target`;let n=e.url||t,r=gp(e,n);if(r)return r.username=r.password=r.search=r.hash=``,r.protocol===`http:`&&new URL(n).protocol===`https:`?(r.protocol=`https:`,`Redirect to plain http not followed; try ${r.href} instead`):`Redirect to ${r.href} not followed`}let Sp;Sp=globalThis.crypto?.webcrypto??globalThis.crypto??import(`node:crypto`).then(e=>e.webcrypto);async function Cp(e){return(await Sp).getRandomValues(new Uint8Array(e))}async function wp(e){let t=``;for(;t.length<e;){let n=await Cp(e-t.length);for(let e of n)e<198&&(t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e%66])}return t}async function Tp(e){return await wp(e)}async function Ep(e){let t=await(await Sp).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function Dp(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await Tp(e);return{code_verifier:t,code_challenge:await Ep(t)}}const Op=zs().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:qc.custom,message:`URL must be parseable`,fatal:!0}),pr}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),kp=mc({resource:P().url(),authorization_servers:z(Op).optional(),jwks_uri:P().url().optional(),scopes_supported:z(P()).optional(),bearer_methods_supported:z(P()).optional(),resource_signing_alg_values_supported:z(P()).optional(),resource_name:P().optional(),resource_documentation:P().optional(),resource_policy_uri:P().url().optional(),resource_tos_uri:P().url().optional(),tls_client_certificate_bound_access_tokens:L().optional(),authorization_details_types_supported:z(P()).optional(),dpop_signing_alg_values_supported:z(P()).optional(),dpop_bound_access_tokens_required:L().optional()}),Ap=mc({issuer:P(),authorization_endpoint:Op,token_endpoint:Op,registration_endpoint:Op.optional(),scopes_supported:z(P()).optional(),response_types_supported:z(P()),response_modes_supported:z(P()).optional(),grant_types_supported:z(P()).optional(),token_endpoint_auth_methods_supported:z(P()).optional(),token_endpoint_auth_signing_alg_values_supported:z(P()).optional(),service_documentation:Op.optional(),revocation_endpoint:Op.optional(),revocation_endpoint_auth_methods_supported:z(P()).optional(),revocation_endpoint_auth_signing_alg_values_supported:z(P()).optional(),introspection_endpoint:P().optional(),introspection_endpoint_auth_methods_supported:z(P()).optional(),introspection_endpoint_auth_signing_alg_values_supported:z(P()).optional(),code_challenge_methods_supported:z(P()).optional(),client_id_metadata_document_supported:L().optional()}),jp=B({...mc({issuer:P(),authorization_endpoint:Op,token_endpoint:Op,userinfo_endpoint:Op.optional(),jwks_uri:Op,registration_endpoint:Op.optional(),scopes_supported:z(P()).optional(),response_types_supported:z(P()),response_modes_supported:z(P()).optional(),grant_types_supported:z(P()).optional(),acr_values_supported:z(P()).optional(),subject_types_supported:z(P()),id_token_signing_alg_values_supported:z(P()),id_token_encryption_alg_values_supported:z(P()).optional(),id_token_encryption_enc_values_supported:z(P()).optional(),userinfo_signing_alg_values_supported:z(P()).optional(),userinfo_encryption_alg_values_supported:z(P()).optional(),userinfo_encryption_enc_values_supported:z(P()).optional(),request_object_signing_alg_values_supported:z(P()).optional(),request_object_encryption_alg_values_supported:z(P()).optional(),request_object_encryption_enc_values_supported:z(P()).optional(),token_endpoint_auth_methods_supported:z(P()).optional(),token_endpoint_auth_signing_alg_values_supported:z(P()).optional(),display_values_supported:z(P()).optional(),claim_types_supported:z(P()).optional(),claims_supported:z(P()).optional(),service_documentation:P().optional(),claims_locales_supported:z(P()).optional(),ui_locales_supported:z(P()).optional(),claims_parameter_supported:L().optional(),request_parameter_supported:L().optional(),request_uri_parameter_supported:L().optional(),require_request_uri_registration:L().optional(),op_policy_uri:Op.optional(),op_tos_uri:Op.optional(),client_id_metadata_document_supported:L().optional()}).shape,...Ap.pick({code_challenge_methods_supported:!0}).shape}),Mp=B({access_token:P(),id_token:P().optional(),token_type:P(),expires_in:Jc().optional(),scope:P().optional(),refresh_token:P().optional(),issuer:P().optional().catch(void 0)}).strip(),Np=B({error:P(),error_description:P().optional(),error_uri:P().optional()}),Pp=Op.optional().or(U(``).transform(()=>void 0)),Fp=B({redirect_uris:z(Op),token_endpoint_auth_method:P().optional(),grant_types:z(P()).optional(),response_types:z(P()).optional(),client_name:P().optional(),client_uri:Op.optional(),logo_uri:Pp,scope:P().optional(),contacts:z(P()).optional(),tos_uri:Pp,policy_uri:P().optional(),jwks_uri:Op.optional(),jwks:cc().optional(),software_id:P().optional(),software_version:P().optional(),software_statement:P().optional()}).strip(),Ip=B({client_id:P(),client_secret:P().optional(),client_id_issued_at:I().optional(),client_secret_expires_at:I().optional(),issuer:P().optional().catch(void 0)}).strip(),Lp=Fp.merge(Ip);B({error:P(),error_description:P().optional()}).strip(),B({token:P(),token_type_hint:P().optional()}).strip();function Rp(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function zp({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var Bp=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Vp=class extends Bp{};Vp.errorCode=`invalid_request`;var Hp=class extends Bp{};Hp.errorCode=`invalid_client`;var Up=class extends Bp{};Up.errorCode=`invalid_grant`;var Wp=class extends Bp{};Wp.errorCode=`unauthorized_client`;var Gp=class extends Bp{};Gp.errorCode=`unsupported_grant_type`;var Kp=class extends Bp{};Kp.errorCode=`invalid_scope`;var qp=class extends Bp{};qp.errorCode=`access_denied`;var Jp=class extends Bp{};Jp.errorCode=`server_error`;var Yp=class extends Bp{};Yp.errorCode=`temporarily_unavailable`;var Xp=class extends Bp{};Xp.errorCode=`unsupported_response_type`;var Zp=class extends Bp{};Zp.errorCode=`unsupported_token_type`;var Qp=class extends Bp{};Qp.errorCode=`invalid_token`;var $p=class extends Bp{};$p.errorCode=`method_not_allowed`;var em=class extends Bp{};em.errorCode=`too_many_requests`;var tm=class extends Bp{};tm.errorCode=`invalid_client_metadata`;var nm=class extends Bp{};nm.errorCode=`insufficient_scope`;var rm=class extends Bp{};rm.errorCode=`invalid_target`;const im={[Vp.errorCode]:Vp,[Hp.errorCode]:Hp,[Up.errorCode]:Up,[Wp.errorCode]:Wp,[Gp.errorCode]:Gp,[Kp.errorCode]:Kp,[qp.errorCode]:qp,[Jp.errorCode]:Jp,[Yp.errorCode]:Yp,[Xp.errorCode]:Xp,[Zp.errorCode]:Zp,[Qp.errorCode]:Qp,[$p.errorCode]:$p,[em.errorCode]:em,[tm.errorCode]:tm,[nm.errorCode]:nm,[rm.errorCode]:rm};var am=class extends Error{constructor(e){super(e??`Unauthorized`)}};function om(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}const sm=`code`,cm=`S256`;function lm(e,t){let n=e.client_secret!==void 0;return`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&om(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?n?`client_secret_basic`:`none`:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function um(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:dm(i,a,n);return;case`client_secret_post`:fm(i,a,r);return;case`none`:pm(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function dm(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function fm(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function pm(e,t){t.set(`client_id`,e)}async function mm(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=Np.parse(JSON.parse(n));return new(im[e]||Jp)(t||``,r)}catch(r){let i=e instanceof Response?xp(e,e.url):void 0;return new Jp(`${t?`HTTP ${t}: `:``}${i??`Invalid OAuth error response: ${r}. Raw body: ${n}`}`)}}function hm(e,t){let[n,r]=[e,t];try{[n,r]=[new URL(e).href,new URL(t).href]}catch{}return n===r||n.endsWith(`/`)&&n.slice(0,-1)===r||r.endsWith(`/`)&&r.slice(0,-1)===n}function gm(e,t){if(e)return typeof e.issuer==`string`?hm(e.issuer,t)?e:void 0:e.issuer==null?e:{...e,issuer:void 0}}const _m=Mp.omit({issuer:!0}),vm=Lp.omit({issuer:!0});function ym(e,t){return/* @__PURE__ */ Error(`OAuth client information is bound to authorization server ${e.issuer} and is not presented to ${t}. Clear the stored client information, or correct \`expectedIssuer\`, if the authorization server has moved.`)}async function bm(e,t){try{return await xm(e,t)}catch(n){if(n instanceof Hp||n instanceof Wp)return await e.invalidateCredentials?.(`all`),await xm(e,t);if(n instanceof Up)return await e.invalidateCredentials?.(`tokens`),await xm(e,t);throw n}}async function xm(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o=await e.discoveryState?.(),s,c,l,u=i;if(!u&&o?.resourceMetadataUrl&&(u=new URL(o.resourceMetadataUrl)),o?.authorizationServerUrl){if(c=o.authorizationServerUrl,s=o.resourceMetadata,l=o.authorizationServerMetadata??await Nm(c,{fetchFn:a}),!s)try{s=await Em(t,{resourceMetadataUrl:u},a)}catch{}(l!==o.authorizationServerMetadata||s!==o.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}else{let n=await Pm(t,{resourceMetadataUrl:u,fetchFn:a});c=n.authorizationServerUrl,l=n.authorizationServerMetadata,s=n.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}let d=String(c),f=await Cm(t,e,s),p=f&&s&&!e.validateResourceURL?s.resource:f,m=r||s?.scopes_supported?.join(` `)||e.clientMetadata.scope,h=await Promise.resolve(e.clientInformation()),g=gm(h,d),_=e.saveClientInformation!==void 0&&!!e.redirectUrl;if(h&&!g&&!_)throw ym(h,d);let v=g?.issuer==null?g:void 0,y=async()=>{try{v&&await e.saveClientInformation?.({...v,issuer:d})}catch{}};if(!g){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);let t=l?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!Sm(r))throw new tm(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)g={client_id:r,issuer:d},await e.saveClientInformation?.(g);else{if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);g={...await Vm(c,{metadata:l,clientMetadata:e.clientMetadata,scope:m,fetchFn:a}),issuer:d},await e.saveClientInformation(g)}}let ee=!e.redirectUrl;if(n!==void 0||ee){let t=await Bm(e,c,{metadata:l,resource:p,authorizationCode:n,fetchFn:a});return await y(),await e.saveTokens({...t,issuer:d}),`AUTHORIZED`}let b=gm(await e.tokens(),d);if(b?.refresh_token&&b.issuer==null&&console.warn(`[mcp-sdk] stored OAuth tokens have no 'issuer' property (saved by an earlier version, or by a provider that does not keep it) and are used as-is; make sure your OAuthClientProvider stores what saveTokens() and saveClientInformation() receive unchanged.`),b?.refresh_token)try{let t=await zm(c,{metadata:l,clientInformation:g,refreshToken:b.refresh_token,resource:p,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await y(),await e.saveTokens({...t,issuer:d}),`AUTHORIZED`}catch(e){if(!(!(e instanceof Bp)||e instanceof Jp))throw e}let te=e.state?await e.state():void 0,{authorizationUrl:ne,codeVerifier:re}=await Im(c,{metadata:l,clientInformation:g,state:te,redirectUrl:e.redirectUrl,scope:m,resource:p});return await e.saveCodeVerifier(re),await e.redirectToAuthorization(ne),`REDIRECT`}function Sm(e){if(!e)return!1;try{let t=new URL(e);return t.protocol===`https:`&&t.pathname!==`/`}catch{return!1}}async function Cm(e,t,n){let r=Rp(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!zp({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function wm(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return{};let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return{};let i=Tm(e,`resource_metadata`)||void 0,a;if(i)try{a=new URL(i)}catch{}let o=Tm(e,`scope`)||void 0,s=Tm(e,`error`)||void 0;return{resourceMetadataUrl:a,scope:o,error:s}}function Tm(e,t){let n=e.headers.get(`WWW-Authenticate`);if(!n)return null;let r=RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),i=n.match(r);return i?i[1]||i[2]:null}async function Em(e,t,n=fetch){let r=await jm(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.body?.cancel(),Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw await r.body?.cancel(),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return kp.parse(await r.json())}async function Dm(e,t,n=fetch){try{return await bp(n)(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?Dm(e,void 0,n):void 0;throw r}}function Om(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function km(e,t,n=fetch){return await Dm(e,{"MCP-Protocol-Version":t},n)}function Am(e,t){return!e||!e.ok&&e.status<500&&t!==`/`}async function jm(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??`2025-11-25`,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=Om(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await km(o,a,n);return!r?.metadataUrl&&Am(s,i.pathname)&&(s=await km(new URL(`/.well-known/${t}`,i),a,n)),s}function Mm(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function Nm(e,{fetchFn:t=fetch,protocolVersion:n=Yc}={}){let r={"MCP-Protocol-Version":n,Accept:`application/json`},i=Mm(e);for(let{url:e,type:n}of i){let i=await Dm(e,r,t);if(i){if(!i.ok){if(await i.body?.cancel(),i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?Ap.parse(await i.json()):jp.parse(await i.json())}}}async function Pm(e,t){let n,r;try{n=await Em(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),n.authorization_servers&&n.authorization_servers.length>0&&(r=n.authorization_servers[0])}catch{}r||=String(new URL(`/`,e));let i=await Nm(r,{fetchFn:t?.fetchFn});return{authorizationServerUrl:r,authorizationServerMetadata:i,resourceMetadata:n}}function Fm(e){return typeof e==`string`?e:e.href}async function Im(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(sm))throw Error(`Incompatible auth server: does not support response type ${sm}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(cm))throw Error(`Incompatible auth server: does not support code challenge method ${cm}`)}else s=new URL(`/authorize`,e);let c=await Dp(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,sm),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,cm),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,Fm(o)),{authorizationUrl:s,codeVerifier:l}}function Lm(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function Rm(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=t?.token_endpoint?new URL(t.token_endpoint):new URL(`/token`,e),c=new Headers({"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`});a&&n.set(`resource`,Fm(a)),i?await i(c,n,s,t):r&&um(lm(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await bp(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await mm(l);return _m.parse(await l.json())}async function zm(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await Rm(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}async function Bm(e,t,{metadata:n,resource:r,authorizationCode:i,fetchFn:a}={}){let o=async()=>{let n=await e.clientInformation(),r=gm(n,String(t));if(n&&!r)throw ym(n,String(t));return r},s=await o(),c=e.clientMetadata.scope,l;if(e.prepareTokenRequest&&(l=await e.prepareTokenRequest(c)),!l){if(!i)throw Error(`Either provider.prepareTokenRequest() or authorizationCode is required`);if(!e.redirectUrl)throw Error(`redirectUrl is required for authorization_code flow`);l=Lm(i,await e.codeVerifier(),e.redirectUrl)}return s??=await o(),Rm(t,{metadata:n,tokenRequestParams:l,clientInformation:s,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:a})}async function Vm(e,{metadata:t,clientMetadata:n,scope:r,fetchFn:i}){let a;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);a=new URL(t.registration_endpoint)}else a=new URL(`/register`,e);let o=await bp(i??fetch)(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n,...r===void 0?{}:{scope:r}})});if(!o.ok)throw await mm(o);return vm.parse(await o.json())}var Hm=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function Um(e){}function Wm(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=Um,onError:n=Um,onRetry:r=Um,onComment:i,maxBufferSize:a}=e,o=[],s=0,c=!0,l,u=``,d=0,f,p=!1;function m(e){if(p)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),o.length===0){let t=g(e);t!==``&&(o.push(t),s=t.length),h();return}if(e.indexOf(`
62
- `)===-1&&e.indexOf(`\r`)===-1){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join(``);o.length=0,s=0;let n=g(t);n!==``&&(o.push(n),s=n.length),h()}function h(){a!==void 0&&(s+u.length<=a||(p=!0,o.length=0,s=0,l=void 0,u=``,d=0,f=void 0,n(new Hm(`Buffered data exceeded max buffer size of ${a} characters`,{type:`max-buffer-size-exceeded`}))))}function g(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
61
+ var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}})))(),1);function wp(e){if(e)try{return Cp.parse(e).type}catch{let t=(e.split(`;`,1)[0]??``).trim().toLowerCase();return t===``||e.slice(t.length).includes(`,`)?void 0:t}}function Tp(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function Ep(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{...Tp(t.headers),...Tp(r.headers)}:t.headers}):e}const Dp=[301,302,303,307,308];function Op(e,t){return e.protocol===t.protocol&&e.hostname===t.hostname&&e.port===t.port||e.hostname===t.hostname&&e.protocol===`http:`&&e.port===``&&t.protocol===`https:`&&t.port===``}function kp(e,t){let n=Dp.includes(e.status)?e.headers.get(`location`):null;try{return n?new URL(n,t):void 0}catch{return}}function Ap(e,t,n,r,i=0){let a=kp(r,t),o=r.status===307||r.status===308||(n?.method??`GET`).toUpperCase()===`GET`;if(!a||i===5||!o)return;let s=new URL(t);if((!a.username&&!a.password||a.username===s.username&&a.password===s.password)&&Op(s,a))return Promise.resolve(r.body?.cancel()).then(()=>e(a,{...n,redirect:`manual`})).then(t=>Ap(e,a,n,t,i+1)??t)}const jp=/* @__PURE__ */ new WeakSet;function Mp(e){let t=(t,n)=>(e??fetch)(t,n);return jp.add(t),t}function Np(e=fetch){return jp.has(e)?e:(t,n)=>n?.redirect===`error`||n?.redirect===`manual`?e(t,n):Promise.resolve(e(t,{...n,redirect:`manual`})).then(r=>Ap(e,t,n,r)??r)}function Pp(e,t){if(e.type===`opaqueredirect`)return`Redirect not followed: this runtime does not expose the redirect target`;let n=e.url||t,r=kp(e,n);if(r)return r.username=r.password=r.search=r.hash=``,r.protocol===`http:`&&new URL(n).protocol===`https:`?(r.protocol=`https:`,`Redirect to plain http not followed; try ${r.href} instead`):`Redirect to ${r.href} not followed`}let Fp;Fp=globalThis.crypto?.webcrypto??globalThis.crypto??import(`node:crypto`).then(e=>e.webcrypto);async function Ip(e){return(await Fp).getRandomValues(new Uint8Array(e))}async function Lp(e){let t=``;for(;t.length<e;){let n=await Ip(e-t.length);for(let e of n)e<198&&(t+=`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~`[e%66])}return t}async function Rp(e){return await Lp(e)}async function zp(e){let t=await(await Fp).subtle.digest(`SHA-256`,new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,`_`).replace(/\+/g,`-`).replace(/=/g,``)}async function Bp(e){if(e||=43,e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await Rp(e);return{code_verifier:t,code_challenge:await zp(t)}}const Vp=Xs().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:ol.custom,message:`URL must be parseable`,fatal:!0}),wr}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),Hp=Ec({resource:I().url(),authorization_servers:B(Vp).optional(),jwks_uri:I().url().optional(),scopes_supported:B(I()).optional(),bearer_methods_supported:B(I()).optional(),resource_signing_alg_values_supported:B(I()).optional(),resource_name:I().optional(),resource_documentation:I().optional(),resource_policy_uri:I().url().optional(),resource_tos_uri:I().url().optional(),tls_client_certificate_bound_access_tokens:z().optional(),authorization_details_types_supported:B(I()).optional(),dpop_signing_alg_values_supported:B(I()).optional(),dpop_bound_access_tokens_required:z().optional()}),Up=Ec({issuer:I(),authorization_endpoint:Vp,token_endpoint:Vp,registration_endpoint:Vp.optional(),scopes_supported:B(I()).optional(),response_types_supported:B(I()),response_modes_supported:B(I()).optional(),grant_types_supported:B(I()).optional(),token_endpoint_auth_methods_supported:B(I()).optional(),token_endpoint_auth_signing_alg_values_supported:B(I()).optional(),service_documentation:Vp.optional(),revocation_endpoint:Vp.optional(),revocation_endpoint_auth_methods_supported:B(I()).optional(),revocation_endpoint_auth_signing_alg_values_supported:B(I()).optional(),introspection_endpoint:I().optional(),introspection_endpoint_auth_methods_supported:B(I()).optional(),introspection_endpoint_auth_signing_alg_values_supported:B(I()).optional(),code_challenge_methods_supported:B(I()).optional(),client_id_metadata_document_supported:z().optional()}),Wp=V({...Ec({issuer:I(),authorization_endpoint:Vp,token_endpoint:Vp,userinfo_endpoint:Vp.optional(),jwks_uri:Vp,registration_endpoint:Vp.optional(),scopes_supported:B(I()).optional(),response_types_supported:B(I()),response_modes_supported:B(I()).optional(),grant_types_supported:B(I()).optional(),acr_values_supported:B(I()).optional(),subject_types_supported:B(I()),id_token_signing_alg_values_supported:B(I()),id_token_encryption_alg_values_supported:B(I()).optional(),id_token_encryption_enc_values_supported:B(I()).optional(),userinfo_signing_alg_values_supported:B(I()).optional(),userinfo_encryption_alg_values_supported:B(I()).optional(),userinfo_encryption_enc_values_supported:B(I()).optional(),request_object_signing_alg_values_supported:B(I()).optional(),request_object_encryption_alg_values_supported:B(I()).optional(),request_object_encryption_enc_values_supported:B(I()).optional(),token_endpoint_auth_methods_supported:B(I()).optional(),token_endpoint_auth_signing_alg_values_supported:B(I()).optional(),display_values_supported:B(I()).optional(),claim_types_supported:B(I()).optional(),claims_supported:B(I()).optional(),service_documentation:I().optional(),claims_locales_supported:B(I()).optional(),ui_locales_supported:B(I()).optional(),claims_parameter_supported:z().optional(),request_parameter_supported:z().optional(),request_uri_parameter_supported:z().optional(),require_request_uri_registration:z().optional(),op_policy_uri:Vp.optional(),op_tos_uri:Vp.optional(),client_id_metadata_document_supported:z().optional()}).shape,...Up.pick({code_challenge_methods_supported:!0}).shape}),Gp=V({access_token:I(),id_token:I().optional(),token_type:I(),expires_in:sl().optional(),scope:I().optional(),refresh_token:I().optional(),issuer:I().optional().catch(void 0)}).strip(),Kp=V({error:I(),error_description:I().optional(),error_uri:I().optional()}),qp=Vp.optional().or(W(``).transform(()=>void 0)),Jp=V({redirect_uris:B(Vp),token_endpoint_auth_method:I().optional(),grant_types:B(I()).optional(),response_types:B(I()).optional(),client_name:I().optional(),client_uri:Vp.optional(),logo_uri:qp,scope:I().optional(),contacts:B(I()).optional(),tos_uri:qp,policy_uri:I().optional(),jwks_uri:Vp.optional(),jwks:yc().optional(),software_id:I().optional(),software_version:I().optional(),software_statement:I().optional()}).strip(),Yp=V({client_id:I(),client_secret:I().optional(),client_id_issued_at:R().optional(),client_secret_expires_at:R().optional(),issuer:I().optional().catch(void 0)}).strip(),Xp=Jp.merge(Yp);V({error:I(),error_description:I().optional()}).strip(),V({token:I(),token_type_hint:I().optional()}).strip();function Zp(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function Qp({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length<r.pathname.length)return!1;let i=n.pathname.endsWith(`/`)?n.pathname:n.pathname+`/`,a=r.pathname.endsWith(`/`)?r.pathname:r.pathname+`/`;return i.startsWith(a)}var $p=class extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},em=class extends $p{};em.errorCode=`invalid_request`;var tm=class extends $p{};tm.errorCode=`invalid_client`;var nm=class extends $p{};nm.errorCode=`invalid_grant`;var rm=class extends $p{};rm.errorCode=`unauthorized_client`;var im=class extends $p{};im.errorCode=`unsupported_grant_type`;var am=class extends $p{};am.errorCode=`invalid_scope`;var om=class extends $p{};om.errorCode=`access_denied`;var sm=class extends $p{};sm.errorCode=`server_error`;var cm=class extends $p{};cm.errorCode=`temporarily_unavailable`;var lm=class extends $p{};lm.errorCode=`unsupported_response_type`;var um=class extends $p{};um.errorCode=`unsupported_token_type`;var dm=class extends $p{};dm.errorCode=`invalid_token`;var fm=class extends $p{};fm.errorCode=`method_not_allowed`;var pm=class extends $p{};pm.errorCode=`too_many_requests`;var mm=class extends $p{};mm.errorCode=`invalid_client_metadata`;var hm=class extends $p{};hm.errorCode=`insufficient_scope`;var gm=class extends $p{};gm.errorCode=`invalid_target`;const _m={[em.errorCode]:em,[tm.errorCode]:tm,[nm.errorCode]:nm,[rm.errorCode]:rm,[im.errorCode]:im,[am.errorCode]:am,[om.errorCode]:om,[sm.errorCode]:sm,[cm.errorCode]:cm,[lm.errorCode]:lm,[um.errorCode]:um,[dm.errorCode]:dm,[fm.errorCode]:fm,[pm.errorCode]:pm,[mm.errorCode]:mm,[hm.errorCode]:hm,[gm.errorCode]:gm};var vm=class extends Error{constructor(e){super(e??`Unauthorized`)}};function ym(e){return[`client_secret_basic`,`client_secret_post`,`none`].includes(e)}const bm=`code`,xm=`S256`;function Sm(e,t){let n=e.client_secret!==void 0;return`token_endpoint_auth_method`in e&&e.token_endpoint_auth_method&&ym(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?n?`client_secret_basic`:`none`:n&&t.includes(`client_secret_basic`)?`client_secret_basic`:n&&t.includes(`client_secret_post`)?`client_secret_post`:t.includes(`none`)?`none`:n?`client_secret_post`:`none`}function Cm(e,t,n,r){let{client_id:i,client_secret:a}=t;switch(e){case`client_secret_basic`:wm(i,a,n);return;case`client_secret_post`:Tm(i,a,r);return;case`none`:Em(i,r);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function wm(e,t,n){if(!t)throw Error(`client_secret_basic authentication requires a client_secret`);let r=btoa(`${e}:${t}`);n.set(`Authorization`,`Basic ${r}`)}function Tm(e,t,n){n.set(`client_id`,e),t&&n.set(`client_secret`,t)}function Em(e,t){t.set(`client_id`,e)}async function Dm(e){let t=e instanceof Response?e.status:void 0,n=e instanceof Response?await e.text():e;try{let{error:e,error_description:t,error_uri:r}=Kp.parse(JSON.parse(n));return new(_m[e]||sm)(t||``,r)}catch(r){let i=e instanceof Response?Pp(e,e.url):void 0;return new sm(`${t?`HTTP ${t}: `:``}${i??`Invalid OAuth error response: ${r}. Raw body: ${n}`}`)}}function Om(e,t){let[n,r]=[e,t];try{[n,r]=[new URL(e).href,new URL(t).href]}catch{}return n===r||n.endsWith(`/`)&&n.slice(0,-1)===r||r.endsWith(`/`)&&r.slice(0,-1)===n}function km(e,t){if(e)return typeof e.issuer==`string`?Om(e.issuer,t)?e:void 0:e.issuer==null?e:{...e,issuer:void 0}}const Am=Gp.omit({issuer:!0}),jm=Xp.omit({issuer:!0});function Mm(e,t){return/* @__PURE__ */ Error(`OAuth client information is bound to authorization server ${e.issuer} and is not presented to ${t}. Clear the stored client information, or correct \`expectedIssuer\`, if the authorization server has moved.`)}async function Nm(e,t){try{return await Pm(e,t)}catch(n){if(n instanceof tm||n instanceof rm)return await e.invalidateCredentials?.(`all`),await Pm(e,t);if(n instanceof nm)return await e.invalidateCredentials?.(`tokens`),await Pm(e,t);throw n}}async function Pm(e,{serverUrl:t,authorizationCode:n,scope:r,resourceMetadataUrl:i,fetchFn:a}){let o=await e.discoveryState?.(),s,c,l,u=i;if(!u&&o?.resourceMetadataUrl&&(u=new URL(o.resourceMetadataUrl)),o?.authorizationServerUrl){if(c=o.authorizationServerUrl,s=o.resourceMetadata,l=o.authorizationServerMetadata??await Km(c,{fetchFn:a}),!s)try{s=await zm(t,{resourceMetadataUrl:u},a)}catch{}(l!==o.authorizationServerMetadata||s!==o.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}else{let n=await qm(t,{resourceMetadataUrl:u,fetchFn:a});c=n.authorizationServerUrl,l=n.authorizationServerMetadata,s=n.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:s,authorizationServerMetadata:l})}let d=String(c),f=await Im(t,e,s),p=f&&s&&!e.validateResourceURL?s.resource:f,m=r||s?.scopes_supported?.join(` `)||e.clientMetadata.scope,h=await Promise.resolve(e.clientInformation()),g=km(h,d),_=e.saveClientInformation!==void 0&&!!e.redirectUrl;if(h&&!g&&!_)throw Mm(h,d);let v=g?.issuer==null?g:void 0,y=async()=>{try{v&&await e.saveClientInformation?.({...v,issuer:d})}catch{}};if(!g){if(n!==void 0)throw Error(`Existing OAuth client information is required when exchanging an authorization code`);let t=l?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!Fm(r))throw new mm(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)g={client_id:r,issuer:d},await e.saveClientInformation?.(g);else{if(!e.saveClientInformation)throw Error(`OAuth client information must be saveable for dynamic registration`);g={...await eh(c,{metadata:l,clientMetadata:e.clientMetadata,scope:m,fetchFn:a}),issuer:d},await e.saveClientInformation(g)}}let b=!e.redirectUrl;if(n!==void 0||b){let t=await $m(e,c,{metadata:l,resource:p,authorizationCode:n,fetchFn:a});return await y(),await e.saveTokens({...t,issuer:d}),`AUTHORIZED`}let x=km(await e.tokens(),d);if(x?.refresh_token&&x.issuer==null&&console.warn(`[mcp-sdk] stored OAuth tokens have no 'issuer' property (saved by an earlier version, or by a provider that does not keep it) and are used as-is; make sure your OAuthClientProvider stores what saveTokens() and saveClientInformation() receive unchanged.`),x?.refresh_token)try{let t=await Qm(c,{metadata:l,clientInformation:g,refreshToken:x.refresh_token,resource:p,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await y(),await e.saveTokens({...t,issuer:d}),`AUTHORIZED`}catch(e){if(!(!(e instanceof $p)||e instanceof sm))throw e}let ee=e.state?await e.state():void 0,{authorizationUrl:te,codeVerifier:ne}=await Ym(c,{metadata:l,clientInformation:g,state:ee,redirectUrl:e.redirectUrl,scope:m,resource:p});return await e.saveCodeVerifier(ne),await e.redirectToAuthorization(te),`REDIRECT`}function Fm(e){if(!e)return!1;try{let t=new URL(e);return t.protocol===`https:`&&t.pathname!==`/`}catch{return!1}}async function Im(e,t,n){let r=Zp(e);if(t.validateResourceURL)return await t.validateResourceURL(r,n?.resource);if(n){if(!Qp({requestedResource:r,configuredResource:n.resource}))throw Error(`Protected resource ${n.resource} does not match expected ${r} (or origin)`);return new URL(n.resource)}}function Lm(e){let t=e.headers.get(`WWW-Authenticate`);if(!t)return{};let[n,r]=t.split(` `);if(n.toLowerCase()!==`bearer`||!r)return{};let i=Rm(e,`resource_metadata`)||void 0,a;if(i)try{a=new URL(i)}catch{}let o=Rm(e,`scope`)||void 0,s=Rm(e,`error`)||void 0;return{resourceMetadataUrl:a,scope:o,error:s}}function Rm(e,t){let n=e.headers.get(`WWW-Authenticate`);if(!n)return null;let r=RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),i=n.match(r);return i?i[1]||i[2]:null}async function zm(e,t,n=fetch){let r=await Wm(e,`oauth-protected-resource`,n,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.body?.cancel(),Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);if(!r.ok)throw await r.body?.cancel(),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return Hp.parse(await r.json())}async function Bm(e,t,n=fetch){try{return await Np(n)(e,{headers:t})}catch(r){if(r instanceof TypeError)return t?Bm(e,void 0,n):void 0;throw r}}function Vm(e,t=``,n={}){return t.endsWith(`/`)&&(t=t.slice(0,-1)),n.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function Hm(e,t,n=fetch){return await Bm(e,{"MCP-Protocol-Version":t},n)}function Um(e,t){return!e||!e.ok&&e.status<500&&t!==`/`}async function Wm(e,t,n,r){let i=new URL(e),a=r?.protocolVersion??`2025-11-25`,o;if(r?.metadataUrl)o=new URL(r.metadataUrl);else{let e=Vm(t,i.pathname);o=new URL(e,r?.metadataServerUrl??i),o.search=i.search}let s=await Hm(o,a,n);return!r?.metadataUrl&&Um(s,i.pathname)&&(s=await Hm(new URL(`/.well-known/${t}`,i),a,n)),s}function Gm(e){let t=typeof e==`string`?new URL(e):e,n=t.pathname!==`/`,r=[];if(!n)return r.push({url:new URL(`/.well-known/oauth-authorization-server`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration`,t.origin),type:`oidc`}),r;let i=t.pathname;return i.endsWith(`/`)&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:`oauth`}),r.push({url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:`oidc`}),r.push({url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:`oidc`}),r}async function Km(e,{fetchFn:t=fetch,protocolVersion:n=cl}={}){let r={"MCP-Protocol-Version":n,Accept:`application/json`},i=Gm(e);for(let{url:e,type:n}of i){let i=await Bm(e,r,t);if(i){if(!i.ok){if(await i.body?.cancel(),i.status<500)continue;throw Error(`HTTP ${i.status} trying to load ${n===`oauth`?`OAuth`:`OpenID provider`} metadata from ${e}`)}return n===`oauth`?Up.parse(await i.json()):Wp.parse(await i.json())}}}async function qm(e,t){let n,r;try{n=await zm(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),n.authorization_servers&&n.authorization_servers.length>0&&(r=n.authorization_servers[0])}catch{}r||=String(new URL(`/`,e));let i=await Km(r,{fetchFn:t?.fetchFn});return{authorizationServerUrl:r,authorizationServerMetadata:i,resourceMetadata:n}}function Jm(e){return typeof e==`string`?e:e.href}async function Ym(e,{metadata:t,clientInformation:n,redirectUrl:r,scope:i,state:a,resource:o}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(bm))throw Error(`Incompatible auth server: does not support response type ${bm}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(xm))throw Error(`Incompatible auth server: does not support code challenge method ${xm}`)}else s=new URL(`/authorize`,e);let c=await Bp(),l=c.code_verifier,u=c.code_challenge;return s.searchParams.set(`response_type`,bm),s.searchParams.set(`client_id`,n.client_id),s.searchParams.set(`code_challenge`,u),s.searchParams.set(`code_challenge_method`,xm),s.searchParams.set(`redirect_uri`,String(r)),a&&s.searchParams.set(`state`,a),i&&s.searchParams.set(`scope`,i),i?.includes(`offline_access`)&&s.searchParams.append(`prompt`,`consent`),o&&s.searchParams.set(`resource`,Jm(o)),{authorizationUrl:s,codeVerifier:l}}function Xm(e,t,n){return new URLSearchParams({grant_type:`authorization_code`,code:e,code_verifier:t,redirect_uri:String(n)})}async function Zm(e,{metadata:t,tokenRequestParams:n,clientInformation:r,addClientAuthentication:i,resource:a,fetchFn:o}){let s=t?.token_endpoint?new URL(t.token_endpoint):new URL(`/token`,e),c=new Headers({"Content-Type":`application/x-www-form-urlencoded`,Accept:`application/json`});a&&n.set(`resource`,Jm(a)),i?await i(c,n,s,t):r&&Cm(Sm(r,t?.token_endpoint_auth_methods_supported??[]),r,c,n);let l=await Np(o??fetch)(s,{method:`POST`,headers:c,body:n});if(!l.ok)throw await Dm(l);return Am.parse(await l.json())}async function Qm(e,{metadata:t,clientInformation:n,refreshToken:r,resource:i,addClientAuthentication:a,fetchFn:o}){return{refresh_token:r,...await Zm(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:`refresh_token`,refresh_token:r}),clientInformation:n,addClientAuthentication:a,resource:i,fetchFn:o})}}async function $m(e,t,{metadata:n,resource:r,authorizationCode:i,fetchFn:a}={}){let o=async()=>{let n=await e.clientInformation(),r=km(n,String(t));if(n&&!r)throw Mm(n,String(t));return r},s=await o(),c=e.clientMetadata.scope,l;if(e.prepareTokenRequest&&(l=await e.prepareTokenRequest(c)),!l){if(!i)throw Error(`Either provider.prepareTokenRequest() or authorizationCode is required`);if(!e.redirectUrl)throw Error(`redirectUrl is required for authorization_code flow`);l=Xm(i,await e.codeVerifier(),e.redirectUrl)}return s??=await o(),Zm(t,{metadata:n,tokenRequestParams:l,clientInformation:s,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:a})}async function eh(e,{metadata:t,clientMetadata:n,scope:r,fetchFn:i}){let a;if(t){if(!t.registration_endpoint)throw Error(`Incompatible auth server: does not support dynamic client registration`);a=new URL(t.registration_endpoint)}else a=new URL(`/register`,e);let o=await Np(i??fetch)(a,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n,...r===void 0?{}:{scope:r}})});if(!o.ok)throw await Dm(o);return jm.parse(await o.json())}var th=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function nh(e){}function rh(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=nh,onError:n=nh,onRetry:r=nh,onComment:i,maxBufferSize:a}=e,o=[],s=0,c=!0,l,u=``,d=0,f,p=!1;function m(e){if(p)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),o.length===0){let t=g(e);t!==``&&(o.push(t),s=t.length),h();return}if(e.indexOf(`
62
+ `)===-1&&e.indexOf(`\r`)===-1){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join(``);o.length=0,s=0;let n=g(t);n!==``&&(o.push(n),s=n.length),h()}function h(){a!==void 0&&(s+u.length<=a||(p=!0,o.length=0,s=0,l=void 0,u=``,d=0,f=void 0,n(new th(`Buffered data exceeded max buffer size of ${a} characters`,{type:`max-buffer-size-exceeded`}))))}function g(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
63
63
  `,n);for(;r!==-1;){if(n===r){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0,n=r+1,r=e.indexOf(`
64
- `,n);continue}let i=e.charCodeAt(n);if(Gm(e,n,i)){let i=e.charCodeAt(n+5)===32?n+6:n+5,a=e.slice(i,r);if(d===0&&e.charCodeAt(r+1)===10){t({id:l,event:f,data:a}),l=void 0,u=``,f=void 0,n=r+2,r=e.indexOf(`
64
+ `,n);continue}let i=e.charCodeAt(n);if(ih(e,n,i)){let i=e.charCodeAt(n+5)===32?n+6:n+5,a=e.slice(i,r);if(d===0&&e.charCodeAt(r+1)===10){t({id:l,event:f,data:a}),l=void 0,u=``,f=void 0,n=r+2,r=e.indexOf(`
65
65
  `,n);continue}u=d===0?a:`${u}
66
- ${a}`,d++}else Km(e,n,i)?f=e.slice(e.charCodeAt(n+6)===32?n+7:n+6,r)||void 0:_(e,n,r);n=r+1,r=e.indexOf(`
66
+ ${a}`,d++}else ah(e,n,i)?f=e.slice(e.charCodeAt(n+6)===32?n+7:n+6,r)||void 0:_(e,n,r);n=r+1,r=e.indexOf(`
67
67
  `,n)}return e.slice(n)}for(;n<e.length;){let t=e.indexOf(`\r`,n),r=e.indexOf(`
68
- `,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;_(e,n,i),n=i+1,e.charCodeAt(n-1)===13&&e.charCodeAt(n)===10&&n++}return e.slice(n)}function _(e,t,n){if(t===n){y();return}let r=e.charCodeAt(t);if(Gm(e,t,r)){let r=e.charCodeAt(t+5)===32?t+6:t+5,i=e.slice(r,n);u=d===0?i:`${u}
69
- ${i}`,d++;return}if(Km(e,t,r)){f=e.slice(e.charCodeAt(t+6)===32?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===32?t+4:t+3,n);r.includes(`\0`)||(l=r);return}if(r===58){if(i){let r=e.slice(t,n);i(r.slice(e.charCodeAt(t+1)===32?2:1))}return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){v(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===32?2:1;v(s,a.slice(o+c),a)}function v(e,t,i){switch(e){case`event`:f=t||void 0;break;case`data`:u=d===0?t:`${u}
70
- ${t}`,d++;break;case`id`:t.includes(`\0`)||(l=t);break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new Hm(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new Hm(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}))}}function y(){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0}function ee(e={}){if(e.consume&&o.length>0){let e=o.join(``);_(e,0,e.length)}c=!0,l=void 0,u=``,d=0,f=void 0,o.length=0,s=0,p=!1}return{feed:m,reset:ee}}function Gm(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function Km(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var qm=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n,maxBufferSize:r}={}){let i;super({start(a){i=Wm({onEvent:e=>{a.enqueue(e)},onError(t){typeof e==`function`&&e(t),(e===`terminate`||t.type===`max-buffer-size-exceeded`)&&a.error(t)},onRetry:t,onComment:n,maxBufferSize:r})},transform(e){i.feed(e)}})}};const Jm={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};var Ym=class extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}},Xm=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=pp(t?.fetch,t?.requestInit),this._followRedirects=t?.redirectPolicy===`follow`,this._followRedirects&&(this._fetch=yp(this._fetch),this._fetchWithInit=yp(this._fetchWithInit)),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??Jm}_unfollowedRedirect(e,t){let n=xp(e,t);return n&&!this._followRedirects?`${n} (redirectPolicy: 'same-origin')`:n}async _authThenStart(){if(!this._authProvider)throw new am(`No auth provider`);let e;try{e=await bm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new am;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e[`mcp-session-id`]=this._sessionId),this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=fp(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){let{resumptionToken:t}=e;try{let n=await this._commonHeaders();n.set(`Accept`,`text/event-stream`),t&&n.set(`last-event-id`,t);let r=this._fetch??fetch,i={method:`GET`,headers:n,signal:this._abortController?.signal},a=await r(this._url,this._followRedirects?i:{...i,redirect:`manual`}),o=this._followRedirects?void 0:_p(r,this._url,i,a);if(o&&(a=await o),!a.ok){if(await a.body?.cancel(),a.status===401&&this._authProvider)return await this._authThenStart();if(a.status===405)return;throw new Ym(a.status,`Failed to open SSE stream: ${this._unfollowedRedirect(a,this._url)??a.statusText}`)}this._handleSseStream(a.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*n**+e,r)}_scheduleReconnection(e,t=0){let n=this._reconnectionOptions.maxRetries;if(t>=n){this.onerror?.(/* @__PURE__ */ Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(/* @__PURE__ */ Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,n){if(!e)return;let{onresumptiontoken:r,replayMessageId:i}=t,a,o=!1,s=!1;(async()=>{try{let t=e.pipeThrough(new TextDecoderStream).pipeThrough(new qm({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){let{value:e,done:n}=await t.read();if(n)break;if(e.id&&(a=e.id,o=!0,r?.(e.id)),e.data&&(!e.event||e.event===`message`))try{let t=bl.parse(JSON.parse(e.data));_l(t)&&(s=!0,i!==void 0&&(t.id=i)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){if(this.onerror?.(/* @__PURE__ */ Error(`SSE stream disconnected: ${e}`)),(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){this.onerror?.(/* @__PURE__ */ Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw Error(`StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.`);this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new am(`No auth provider`);if(await bm(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new am(`Failed to authorize`)}async close(){this._reconnectionTimeout&&=(clearTimeout(this._reconnectionTimeout),void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{let{resumptionToken:n,onresumptiontoken:r}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:pl(e)?e.id:void 0}).catch(e=>this.onerror?.(e));return}let i=await this._commonHeaders();i.set(`content-type`,`application/json`),i.set(`accept`,`application/json, text/event-stream`);let a={...this._requestInit,method:`POST`,headers:i,body:JSON.stringify(e),signal:this._abortController?.signal},o=await bp(this._fetch??fetch)(this._url,a),s=o.headers.get(`mcp-session-id`);if(s&&(this._sessionId=s),!o.ok){let t=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Ym(401,`Server returned 401 after successful authentication`);let{resourceMetadataUrl:t,scope:n}=wm(o);if(this._resourceMetadataUrl=t,this._scope=n,await bm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new am;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){let{resourceMetadataUrl:t,scope:n,error:r}=wm(o);if(r===`insufficient_scope`){let r=o.headers.get(`WWW-Authenticate`);if(this._lastUpscopingHeader===r)throw new Ym(403,`Server returned 403 after trying upscoping`);if(n&&(this._scope=n),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=r??void 0,await bm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!==`AUTHORIZED`)throw new am;return this.send(e)}}throw new Ym(o.status,`Error POSTing to endpoint: ${this._unfollowedRedirect(o,this._url)??t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),Il(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e));return}let c=(Array.isArray(e)?e:[e]).filter(e=>`method`in e&&`id`in e&&e.id!==void 0).length>0,l=o.headers.get(`content-type`),u=dp(l);if(c){if(u===`text/event-stream`)this._handleSseStream(o.body,{onresumptiontoken:r},!1);else if(u===`application/json`){let e=await o.json(),t=Array.isArray(e)?e.map(e=>bl.parse(e)):[bl.parse(e)];for(let e of t)this.onmessage?.(e)}else throw await o.body?.cancel(),new Ym(-1,`Unexpected content type: ${l}`)}else await o.body?.cancel()}catch(e){throw this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:`DELETE`,headers:e,signal:this._abortController?.signal},n=await bp(this._fetch??fetch)(this._url,t);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new Ym(n.status,`Failed to terminate session: ${this._unfollowedRedirect(n,this._url)??n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}},Zm=class extends Event{constructor(e,t){super(e),this.code=t?.code??void 0,this.message=t?.message??void 0}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return n(eh(this),t)}[Symbol.for(`Deno.customInspect`)](e,t){return e(eh(this),t)}};function Qm(e){let t=globalThis.DOMException;return typeof t==`function`?new t(e,`SyntaxError`):SyntaxError(e)}function $m(e){return e instanceof Error?`errors`in e&&Array.isArray(e.errors)?e.errors.map($m).join(`, `):`cause`in e&&e.cause instanceof Error?`${e}: ${$m(e.cause)}`:e.message:`${e}`}function eh(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var th=e=>{throw TypeError(e)},nh=(e,t,n)=>t.has(e)||th(`Cannot `+n),Y=(e,t,n)=>(nh(e,t,`read from private field`),n?n.call(e):t.get(e)),rh=(e,t,n)=>t.has(e)?th(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),X=(e,t,n,r)=>(nh(e,t,`write to private field`),t.set(e,n),n),ih=(e,t,n)=>(nh(e,t,`access private method`),n),ah,oh,sh,ch,lh,uh,dh,fh,ph,mh,hh,gh,_h,vh,yh,bh,xh,Sh,Ch,wh,Th,Eh,Dh,Oh=class extends EventTarget{constructor(e,t){super(),rh(this,vh),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,rh(this,ah),rh(this,oh),rh(this,sh),rh(this,ch),rh(this,lh),rh(this,uh),rh(this,dh),rh(this,fh,null),rh(this,ph),rh(this,mh),rh(this,hh,null),rh(this,gh,null),rh(this,_h,null),rh(this,bh,async e=>{var t;Y(this,mh).reset();let{body:n,redirected:r,status:i,headers:a}=e;if(i===204){ih(this,vh,Th).call(this,`Server sent HTTP 204, not reconnecting`,204),this.close();return}if(r?X(this,sh,new URL(e.url)):X(this,sh,void 0),i!==200){ih(this,vh,Th).call(this,`Non-200 status code (${i})`,i);return}if(!(a.get(`content-type`)||``).startsWith(`text/event-stream`)){ih(this,vh,Th).call(this,`Invalid content type, expected "text/event-stream"`,i);return}if(Y(this,ah)===this.CLOSED)return;X(this,ah,this.OPEN);let o=new Event(`open`);if((t=Y(this,_h))==null||t.call(this,o),this.dispatchEvent(o),typeof n!=`object`||!n||!(`getReader`in n)){ih(this,vh,Th).call(this,`Invalid response body, expected a web ReadableStream`,i),this.close();return}let s=new TextDecoder,c=n.getReader(),l=!0;do{let{done:e,value:t}=await c.read();t&&Y(this,mh).feed(s.decode(t,{stream:!e})),e&&(l=!1,Y(this,mh).reset(),ih(this,vh,Eh).call(this))}while(l)}),rh(this,xh,e=>{X(this,ph,void 0),e.name!==`AbortError`&&e.type!==`aborted`&&ih(this,vh,Eh).call(this,$m(e))}),rh(this,Ch,e=>{typeof e.id==`string`&&X(this,fh,e.id);let t=new MessageEvent(e.event||`message`,{data:e.data,origin:Y(this,sh)?Y(this,sh).origin:Y(this,oh).origin,lastEventId:e.id||``});Y(this,gh)&&(!e.event||e.event===`message`)&&Y(this,gh).call(this,t),this.dispatchEvent(t)}),rh(this,wh,e=>{X(this,uh,e)}),rh(this,Dh,()=>{X(this,dh,void 0),Y(this,ah)===this.CONNECTING&&ih(this,vh,yh).call(this)});try{if(e instanceof URL)X(this,oh,e);else if(typeof e==`string`)X(this,oh,new URL(e,kh()));else throw Error(`Invalid URL`)}catch{throw Qm(`An invalid or illegal string was specified`)}X(this,mh,Wm({onEvent:Y(this,Ch),onRetry:Y(this,wh)})),X(this,ah,this.CONNECTING),X(this,uh,3e3),X(this,lh,t?.fetch??globalThis.fetch),X(this,ch,t?.withCredentials??!1),ih(this,vh,yh).call(this)}get readyState(){return Y(this,ah)}get url(){return Y(this,oh).href}get withCredentials(){return Y(this,ch)}get onerror(){return Y(this,hh)}set onerror(e){X(this,hh,e)}get onmessage(){return Y(this,gh)}set onmessage(e){X(this,gh,e)}get onopen(){return Y(this,_h)}set onopen(e){X(this,_h,e)}addEventListener(e,t,n){let r=t;super.addEventListener(e,r,n)}removeEventListener(e,t,n){let r=t;super.removeEventListener(e,r,n)}close(){Y(this,dh)&&clearTimeout(Y(this,dh)),Y(this,ah)!==this.CLOSED&&(Y(this,ph)&&Y(this,ph).abort(),X(this,ah,this.CLOSED),X(this,ph,void 0))}};ah=/* @__PURE__ */ new WeakMap,oh=/* @__PURE__ */ new WeakMap,sh=/* @__PURE__ */ new WeakMap,ch=/* @__PURE__ */ new WeakMap,lh=/* @__PURE__ */ new WeakMap,uh=/* @__PURE__ */ new WeakMap,dh=/* @__PURE__ */ new WeakMap,fh=/* @__PURE__ */ new WeakMap,ph=/* @__PURE__ */ new WeakMap,mh=/* @__PURE__ */ new WeakMap,hh=/* @__PURE__ */ new WeakMap,gh=/* @__PURE__ */ new WeakMap,_h=/* @__PURE__ */ new WeakMap,vh=/* @__PURE__ */ new WeakSet,yh=function(){X(this,ah,this.CONNECTING),X(this,ph,new AbortController),Y(this,lh)(Y(this,oh),ih(this,vh,Sh).call(this)).then(Y(this,bh)).catch(Y(this,xh))},bh=/* @__PURE__ */ new WeakMap,xh=/* @__PURE__ */ new WeakMap,Sh=function(){let e={mode:`cors`,redirect:`follow`,headers:{Accept:`text/event-stream`,...Y(this,fh)?{"Last-Event-ID":Y(this,fh)}:void 0},cache:`no-store`,signal:Y(this,ph)?.signal};return`window`in globalThis&&(e.credentials=this.withCredentials?`include`:`same-origin`),e},Ch=/* @__PURE__ */ new WeakMap,wh=/* @__PURE__ */ new WeakMap,Th=function(e,t){var n;Y(this,ah)!==this.CLOSED&&X(this,ah,this.CLOSED);let r=new Zm(`error`,{code:t,message:e});(n=Y(this,hh))==null||n.call(this,r),this.dispatchEvent(r)},Eh=function(e,t){var n;if(Y(this,ah)===this.CLOSED)return;X(this,ah,this.CONNECTING);let r=new Zm(`error`,{code:t,message:e});(n=Y(this,hh))==null||n.call(this,r),this.dispatchEvent(r),X(this,dh,setTimeout(Y(this,Dh),Y(this,uh)))},Dh=/* @__PURE__ */ new WeakMap,Oh.CONNECTING=0,Oh.OPEN=1,Oh.CLOSED=2;function kh(){let e=`document`in globalThis?globalThis.document:void 0;return e&&typeof e==`object`&&`baseURI`in e&&typeof e.baseURI==`string`?e.baseURI:void 0}var Ah=class extends Error{constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n}},jh=class{constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=t?.eventSourceInit,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=pp(t?.fetch,t?.requestInit),this._followRedirects=t?.redirectPolicy===`follow`,this._followRedirects&&(this._fetch=yp(this._fetch),this._fetchWithInit=yp(this._fetchWithInit))}_unfollowedRedirect(e,t){let n=xp(e,t);return n&&!this._followRedirects?`${n} (redirectPolicy: 'same-origin')`:n}async _authThenStart(){if(!this._authProvider)throw new am(`No auth provider`);let e;try{e=await bm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new am;return await this._startOrAuth()}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=fp(this._requestInit?.headers);return new Headers({...e,...t})}_startOrAuth(){let e=this?._eventSourceInit?.fetch??this._fetch??fetch,t=this._followRedirects?e:bp(e),n;return new Promise((e,r)=>{this._eventSource=new Oh(this._url.href,{...this._eventSourceInit,fetch:async(e,r)=>{let i=await this._commonHeaders();i.set(`Accept`,`text/event-stream`);let a=await t(e,{...r,headers:i});if(n=this._unfollowedRedirect(a,e),a.status===401&&a.headers.has(`www-authenticate`)){let{resourceMetadataUrl:e,scope:t}=wm(a);this._resourceMetadataUrl=e,this._scope=t}return a}}),this._abortController=new AbortController,this._eventSource.onerror=t=>{if(t.code===401&&this._authProvider){this._authThenStart().then(e,r);return}let i=new Ah(t.code,n??t.message,t);r(i),this.onerror?.(i)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener(`endpoint`,t=>{let n=t;try{if(this._endpoint=new URL(n.data,this._url),this._endpoint.origin!==this._url.origin)throw Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(e){r(e),this.onerror?.(e),this.close();return}e()}),this._eventSource.onmessage=e=>{let t=e,n;try{n=bl.parse(JSON.parse(t.data))}catch(e){this.onerror?.(e);return}this.onmessage?.(n)}})}async start(){if(this._eventSource)throw Error(`SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.`);return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new am(`No auth provider`);if(await bm(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new am(`Failed to authorize`)}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw Error(`Not connected`);try{let t=await this._commonHeaders();t.set(`content-type`,`application/json`);let n={...this._requestInit,method:`POST`,headers:t,body:JSON.stringify(e),signal:this._abortController?.signal},r=await bp(this._fetch??fetch)(this._endpoint,n);if(!r.ok){let t=await r.text().catch(()=>null);if(r.status===401&&this._authProvider){let{resourceMetadataUrl:t,scope:n}=wm(r);if(this._resourceMetadataUrl=t,this._scope=n,await bm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new am;return this.send(e)}throw Error(`Error POSTing to endpoint (HTTP ${r.status}): ${this._unfollowedRedirect(r,this._endpoint)??t}`)}await r.body?.cancel()}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}},Mh=class{adapter;constructor(e,t,n){this.adapter=new Lh({deps:e,url:t,authToken:n,transport:`streamable`})}initialize(){return this.adapter.initialize()}listTools(){return this.adapter.listTools()}callTool(e,t){return this.adapter.callTool(e,t)}close(){this.adapter.close()}};function Nh(e,t,n){if(e instanceof D)return e;if(e instanceof K){let t=Ph(e);return e.code===G.ConnectionClosed&&n?.localCloseFired?new D(t||`MCP connection closed.`,E.NETWORK):new D(`MCP error (${e.code}): ${t}`,E.GENERAL)}if(e instanceof Ym){let t=e.code;return new D(`MCP request failed: ${t}`,E.GENERAL,void 0,{api:{httpStatus:typeof t==`number`?t:void 0},cause:e})}if(e instanceof Ah&&t&&t.status===e.code){let n=`MCP request failed: ${t.status} ${t.statusText}`;return t.body&&(n+=` - ${t.body.slice(0,500)}`),new D(n,E.GENERAL,void 0,{api:{httpStatus:t.status},cause:e})}return e}function Ph(e){let t=`MCP error ${e.code}: `;return e.message.startsWith(t)?e.message.slice(t.length):e.message}function Fh(e,t,n){return async(r,i)=>{let a=i?.method??`GET`,o=typeof r==`string`?r:r.href,s;if(typeof i?.body==`string`)try{let e=JSON.parse(i.body);typeof e.method==`string`&&(s=e.method)}catch{}Cn(e,a,o,{rpc_method:s});let c=await En.fetch(r,i);if(wn(e,c),!c.ok&&a===`POST`&&!Ih(c.status)){let e=`MCP request failed: ${c.status} ${c.statusText}`;try{let t=await c.text();t&&(e+=` - ${t.slice(0,500)}`)}catch{}throw new D(e,E.GENERAL)}if(t===`sse`&&n&&!c.ok&&a===`GET`&&!Ih(c.status)){let e=``;try{e=await c.text()}catch{}n({status:c.status,statusText:c.statusText,body:e})}return c}}function Ih(e){return e>=300&&e<400}var Lh=class{deps;url;authToken;kind;serviceSource;client;transport;connecting;sseGetFailure;transportClosed=!1;constructor(e){this.deps=e.deps,this.url=e.url,this.authToken=e.authToken,this.kind=e.transport,this.serviceSource=e.serviceSource}async initialize(){if(!this.authToken)throw new D(`This command needs a model-domain API key.`,E.AUTH);return this.connecting||=this.connect().catch(e=>{throw this.connecting=void 0,this.mapTransportError(e)}),this.connecting}async listTools(){let e=await this.requireClient();try{return(await this.withLocalTimeout(e.listTools(void 0,this.requestOptions()))).tools}catch(e){throw this.mapTransportError(e)}}async callTool(e,t){let n=await this.requireClient();try{let r=await this.withLocalTimeout(n.callTool({name:e,arguments:t},void 0,this.requestOptions()));if(!Array.isArray(r.content))throw new D(`MCP tool returned an unexpected result shape.`,E.GENERAL);return r}catch(e){throw this.mapTransportError(e)}}close(){let e=this.transport;this.client=void 0,this.transport=void 0,this.connecting=void 0,this.sseGetFailure=void 0,e&&e.close().catch(()=>void 0)}mapTransportError(e){return Nh(e,this.sseGetFailure,{localCloseFired:this.transportClosed})}async connect(){let e={"User-Agent":`${this.deps.identity.clientName}/${this.deps.identity.version}`,...Rn(this.deps.identity,this.serviceSource),Authorization:`Bearer ${this.authToken}`},t=Fh(this.deps,this.kind,e=>{this.sseGetFailure=e}),n=new URL(this.url);this.transportClosed=!1;let r=this.kind===`sse`?new jh(n,{requestInit:{headers:e},fetch:t}):new Xm(n,{requestInit:{headers:e},fetch:t});r.onclose=()=>{this.transportClosed=!0};let i=new lp({name:this.deps.identity.clientName,version:this.deps.identity.version},{capabilities:{}});this.transport=r;let a=i.connect(r,this.requestOptions());a.catch(()=>void 0);let o,s=new Promise((e,t)=>{o=setTimeout(()=>t(new D(`MCP session handshake timed out after ${this.deps.settings.timeout}s.`,E.TIMEOUT)),this.deps.settings.timeout*1e3)});try{await Promise.race([a,s])}catch(e){throw this.transport=void 0,await r.close().catch(()=>void 0),e}finally{o&&clearTimeout(o)}if(this.transport!==r)throw await r.close().catch(()=>void 0),new D(`MCP connection was closed during the handshake.`,E.NETWORK);this.client=i;let c=i.getServerVersion();this.deps.debug?.({message:{"en-US":`MCP session initialized`,"zh-CN":`MCP 会话已初始化`},details:{transport:this.kind,has_session_id:r instanceof Xm&&!!r.sessionId,server_name:c?.name,server_version:c?.version}})}async requireClient(){if(await this.initialize(),!this.client)throw new D(`MCP client is not connected.`,E.GENERAL);return this.client}requestOptions(){return{timeout:2147483647}}async withLocalTimeout(e){let t=this.deps.settings.timeout,n,r=new Promise((e,r)=>{n=setTimeout(()=>{r(new D(`MCP request timed out after ${t}s.`,E.TIMEOUT))},t*1e3)});try{return await Promise.race([e,r])}finally{n&&clearTimeout(n)}}};function Rh(e){return`/api/v1/mcps/${e}/mcp`}function zh(e){return`/api/v1/mcps/${e}/sse`}function Bh(e){return e instanceof D&&/^MCP request failed:\s*405\b/i.test(e.message)}function Vh(e){return e instanceof D&&/^MCP request failed:\s*(405|404)\b/i.test(e.message)}async function Hh(e){let{deps:t,authToken:n,httpUrl:r,sseUrl:i,serverCode:a,urlOverride:o,serviceSource:s}=e;if(o){let e=new Lh({deps:t,url:o,authToken:n,transport:`streamable`,serviceSource:s});try{return await e.initialize(),{client:e,url:o}}catch(e){if(!Vh(e))throw e}let r=new Lh({deps:t,url:o,authToken:n,transport:`sse`,serviceSource:s});try{return await r.initialize(),{client:r,url:o}}catch(e){throw r.close(),e}}let c=new Lh({deps:t,url:r,authToken:n,transport:`streamable`,serviceSource:s});try{return await c.initialize(),{client:c,url:r}}catch(e){if(!Bh(e)||a===`WebSearch`)throw e}let l=new Lh({deps:t,url:i,authToken:n,transport:`sse`,serviceSource:s});try{return await l.initialize(),{client:l,url:i}}catch(e){throw l.close(),e}}var Uh=class e{deps;consoleTokenPersisted;consoleRefresh;constructor(e){this.deps=e,this.consoleTokenPersisted=e.consoleCred?.source===`config`}withSwitchAgent(t){let n=new e({...this.deps,settings:{...this.deps.settings,consoleSwitchAgent:t},consoleCred:this.deps.consoleCred?{...this.deps.consoleCred,switchAgent:t}:void 0});return n.consoleTokenPersisted=this.consoleTokenPersisted,n}async request(e,t){let n=this.deps.consoleCred;if(!n){let n=new D(`This command needs a console access token.`,E.AUTH);if(!this.deps.resolveConsoleOpenApiCredential)throw n;return this.refreshConsole(e,t,n)}try{return await this.requestConsole(n,e,t)}catch(r){if(!(r instanceof ct)||r.reason!==`expired-console-session`)throw r;return this.refreshConsole(e,t,r,n)}}async requestConsole(e,t,n){return await Mn(e,this.deps.settings.timeout,{api:t,data:n},{debug:this.deps.debug,recoveryHint:this.deps.consoleRecoveryHint})}async refreshConsole(e,t,n,r){if(this.deps.consoleCred&&this.deps.consoleCred!==r)return this.requestConsole(this.deps.consoleCred,e,t);let i=this.consoleRefresh;(!i||i.previous!==r)&&(i={previous:r,promise:this.exchangeConsoleToken(r),users:0},this.consoleRefresh=i),i.users++;try{let a=await i.promise.catch(e=>{throw e instanceof ct&&e.reason===`missing-openapi-pair`?n:e});if(!a)throw n;let o=await this.requestConsole(a.credential,e,t);return i.commit??=(async()=>{this.deps.consoleCred===r&&(a.persist&&await Xh(a.credential.token,this.deps.settings.configName),this.consoleTokenPersisted=a.persist,this.deps.consoleCred=a.credential)})(),await i.commit,o}finally{i.users--,i.users===0&&this.consoleRefresh===i&&(this.consoleRefresh=void 0)}}async exchangeConsoleToken(e){let t=this.deps.resolveConsoleOpenApiCredential?.(),n=e??Kh(this.deps.settings,this.deps.baseUrl),r=this.consoleTokenPersisted&&e?.source===`config`&&(!t||t.source===`config`),i=await Yh({identity:this.deps.identity,settings:{...this.deps.settings,consoleRegion:n.region,consoleSite:n.site,consoleSwitchAgent:n.switchAgent},debug:this.deps.debug,baseUrl:this.deps.baseUrl,credential:t,persist:!1,validateToken:async()=>{}});return i?{credential:{...n,token:i,source:t?.source??e?.source??`config`},persist:r}:null}},Wh=class e{deps;consoleSession;constructor(e){this.deps=e,this.consoleSession=new Uh(e)}get http(){return{identity:this.deps.identity,settings:this.deps.settings,debug:this.deps.debug}}requireApi(){if(!this.deps.apiCred)throw new D(`This command needs a model-domain API key.`,E.AUTH);return this.deps.apiCred}requireOpenApi(){if(!this.deps.openApiCred)throw new D(`This command needs Alibaba Cloud OpenAPI AK/SK credentials.`,E.AUTH);return this.deps.openApiCred}get baseUrl(){return this.deps.apiCred?.baseUrl??this.deps.baseUrl}exportApiCredential(){return this.deps.apiCred}bailianMcpRegistrationHeaders(){return{Authorization:`Bearer ${this.requireApi().token}`,...Rn(this.deps.identity)}}url(e,t){return(this.deps.baseUrlIsDefault&&t?t():this.baseUrl)+e}toOpts({path:e,...t}){let n=this.requireApi();return{...t,url:/^https?:\/\//.test(e)?e:n.baseUrl+e,headers:{...t.headers,Authorization:`Bearer ${n.token}`}}}request(e){return Vn(this.http,this.toOpts(e))}requestJson(e){return Gn(this.http,this.toOpts(e))}uploadFile(e,t,n={}){return ur(e)?dr(e,this.requireApi().token,t,{signal:n.signal,baseUrl:this.url(``,n.defaultBaseUrl),identity:this.deps.identity,timeout:this.deps.settings.timeout}):Promise.resolve(e)}resolveImageInput(e,t,n={}){return ur(e)?this.usesTokenPlanEndpoint()?Promise.resolve(or(e)):this.uploadFile(e,t,n):Promise.resolve(e)}usesTokenPlanEndpoint(){try{return/^token-plan\.[a-z0-9-]+\.maas\.aliyuncs\.com$/i.test(new URL(this.baseUrl).hostname)}catch{return!1}}usesTokenPlanConnection(){return this.usesTokenPlanEndpoint()||vn(this.deps.apiCred?.token??``)===`token-plan`}mcp(e){let t=/^https?:\/\//.test(e)?e:this.requireApi().baseUrl+e;return new Lh({deps:this.http,url:t,authToken:this.deps.apiCred?.token,transport:`streamable`})}connectBailianMcp(e,t,n){return this.requireApi(),Hh({deps:this.http,authToken:this.deps.apiCred?.token,httpUrl:this.url(Rh(e)),sseUrl:this.url(zh(e)),serverCode:e,urlOverride:t,serviceSource:n})}withConsoleSwitchAgent(t){let n=new e({...this.deps,settings:{...this.deps.settings,consoleSwitchAgent:t}});return n.consoleSession=this.consoleSession.withSwitchAgent(t),n}console(e,t){return this.consoleSession.request(e,t)}openApiQueryJson(e){return this.openApiJson(e)}async openApiJson(e){let t=this.requireOpenApi(),n=e.body===void 0?``:JSON.stringify(e.body),r=e.queryParams?Kn(e.queryParams):``,i=`https://${e.host}${e.path}${r?`?${r}`:``}`,a=qn({accessKeyId:t.accessKeyId,accessKeySecret:t.accessKeySecret,securityToken:t.securityToken,action:e.action,version:e.version,body:n,host:e.host,pathname:e.path,method:e.method,queryString:r});Cn(this.http,e.method,i,{action:e.action,version:e.version});let o=this.deps.settings.timeout*1e3,s=await En.fetch(i,{method:e.method,headers:{...a,...Rn(this.deps.identity)},body:n||void 0,signal:AbortSignal.timeout(o)}),c=await s.text();wn(this.http,s);let l;try{l=JSON.parse(c)}catch{throw new D(`${s.status} ${s.statusText} - ${c.slice(0,500)}`,E.GENERAL)}if(!s.ok||l.Success===!1)throw new D(`${l.Code||s.status} - ${l.Message||s.statusText}`,E.GENERAL);return l}};const Gh=/* @__PURE__ */ new Map([[`cn-beijing`,`modelstudio.cn-beijing.aliyuncs.com`],[`ap-southeast-1`,`modelstudio.ap-southeast-1.aliyuncs.com`]]);function Kh(e,t){let n=e.consoleRegion;if(!n){let e;try{e=new URL(t).hostname}catch{}n=e===`dashscope.aliyuncs.com`?`cn-beijing`:e===`dashscope-intl.aliyuncs.com`?`ap-southeast-1`:e?.match(/^[a-z0-9-]+\.(cn-beijing|ap-southeast-1)\.maas\.aliyuncs\.com$/)?.[1]}if(!n||!Gh.has(n))throw new D(`Cannot resolve a supported CLI token region. / 无法确定受支持的 CLI token 地域。`,E.USAGE,`Set console_region to cn-beijing or ap-southeast-1. / 请配置 console_region 为 cn-beijing 或 ap-southeast-1。`);return{region:n,site:e.consoleSite??`domestic`,switchAgent:e.consoleSwitchAgent}}async function qh(e,t,n={}){let r=await Mn(e,t.timeout,{api:`zeldaEasy.cornerstone-portal.cs-console.loginInfo`,data:{}},n);if(r?.data?.success!==!0)throw new D(`Console token validation did not return success. / 控制台 token 校验未返回成功结果。`,E.GENERAL,void 0,{rawResponse:JSON.stringify(r)})}async function Jh(e){let{identity:t,settings:n,baseUrl:r,accessKeyId:i,accessKeySecret:a,securityToken:o}=e,s=new Wh({identity:t,settings:n,debug:e.debug,baseUrl:r,openApiCred:{accessKeyId:i,accessKeySecret:a,securityToken:o,source:`flag`}}),c=Kh(n,r),l=Gh.get(c.region),u=await s.openApiQueryJson({host:l,path:`/modelstudio/cli/generateAccessToken`,action:`GenerateCLIAccessToken`,version:`2026-02-10`,method:`POST`,queryParams:{}});if(typeof u.cliAccessToken!=`string`||!u.cliAccessToken.trim())throw new D(`CLI token response is missing cliAccessToken. / CLI token 响应缺少有效的 cliAccessToken。`,E.GENERAL);return{...u,cliAccessToken:u.cliAccessToken.trim()}}async function Yh(e){let t=e.settings.configName,n=e.credential?void 0:nn(t),r=e.credential?.accessKeyId??n?.access_key_id,i=e.credential?.accessKeySecret??n?.access_key_secret;if(!r||!i)return null;e.debug?.({message:{"en-US":`Refreshing access token`,"zh-CN":`正在刷新访问令牌`}});let a=(await Jh({identity:e.identity,settings:e.settings,debug:e.debug,baseUrl:e.baseUrl,accessKeyId:r,accessKeySecret:i,securityToken:e.credential?e.credential.securityToken:n?.security_token})).cliAccessToken;return e.validateToken?await e.validateToken(a):await qh({...Kh(e.settings,e.baseUrl),token:a},e.settings,{debug:e.debug}),(e.persist??(!e.credential||e.credential.source===`config`))&&await Xh(a,t),a}async function Xh(e,t){let n=nn(t);n.access_token=e,await rn(n,t)}function Zh(e,t){if(!/^[a-zA-Z0-9_-]+$/.test(e))throw new ot(`Workspace ID must contain only letters, digits, hyphens or underscores. / Workspace ID 只能包含字母、数字、连字符或下划线。`);return`https://${e}.cn-beijing.maas.aliyuncs.com${t}`}function Qh(e){return Zh(e,``)}function $h(e,t,n){let r;try{r=new URL(e)}catch{throw new ot(`Invalid ParseX base URL. / ParseX Base URL 无效。`)}let i=[`localhost`,`127.0.0.1`,`[::1]`].includes(r.hostname),a=r.pathname.replace(/\/+$/,``);if(r.protocol!==`https:`&&!(r.protocol===`http:`&&i)||r.username||r.password||r.search||r.hash||a)throw new ot(`ParseX base URL must be an HTTPS origin (HTTP is allowed only on loopback). / ParseX Base URL 必须为 HTTPS 源站(仅本机回环地址允许 HTTP)。`);let o=r.hostname.endsWith(`.cn-beijing.pre-maas.aliyuncs.com`)?`/api/v2/apps/pre-parse-x`:`/api/v2/apps/parse-x`;return`${r.origin}${o}/${t}/${n}`}function eg(){return`/compatible-mode/v1/chat/completions`}function tg(){return`/compatible-mode/v1/batches`}function ng(e){return`${tg()}/${encodeURIComponent(e)}`}function rg(e){return`${ng(e)}/cancel`}function ig(e){return`/compatible-mode/v1/files/${encodeURIComponent(e)}/content`}function ag(){return`https://batch.dashscope.aliyuncs.com`}function og(){return`/compatible-mode/v1/responses`}function sg(){return`/compatible-mode/v1/systemone`}function cg(){return`/api/v1/services/aigc/image-generation/generation`}function lg(){return`/api/v1/services/aigc/multimodal-generation/generation`}function ug(){return`/api/v1/services/aigc/text2image/image-synthesis`}function dg(){return`/api/v1/services/aigc/image2image/image-synthesis`}function fg(){return`/api/v1/services/aigc/video-generation/video-synthesis`}function pg(){return`/api/v1/services/aigc/image2video/video-synthesis`}function mg(e){return`/api/v1/tasks/${encodeURIComponent(e)}`}function hg(){return`/api/v1/models/limits`}function gg(){return`/api/v1/models/permissions`}function _g(e){return`/api/v1/apps/${encodeURIComponent(e)}/completion`}function vg(e,t){return Zh(e,t)}function yg(){return`/api/v2/apps/memory/add-async`}function bg(e){return`/api/v2/apps/memory/events/${encodeURIComponent(e)}`}function xg(){return`/api/v2/apps/memory/memory_nodes/search`}function Sg(){return`/api/v2/apps/memory/memory_nodes`}function Cg(e){return`/api/v2/apps/memory/memory_nodes/${encodeURIComponent(e)}`}function wg(e){return`/api/v2/apps/memory/skill/export/${encodeURIComponent(e)}`}function Tg(){return`/api/v1/services/audio/tts/SpeechSynthesizer`}function Eg(){return`/api/v1/services/audio/asr/transcription`}function Dg(){return`/api/v1/services/audio/asr/customization`}function Og(){return`/api/v2/apps/memory/profile_schemas`}function kg(e){return`/api/v2/apps/memory/profile_schemas/${encodeURIComponent(e)}`}function Ag(e){return`${kg(e)}/user_profile`}function jg(e){return`${kg(e)}/profile_values`}function Mg(e,t=`cn-beijing`){return`https://${e}.${t}.maas.aliyuncs.com`}function Ng(e){return Zh(e,`/api/v1/indices/knowledge/search`)}function Pg(e){return Zh(e,`/api/v2/apps/knowledge/chat`)}function Fg(e){return`https://${e}.cn-beijing.maas.aliyuncs.com`}const Ig=`/api/v1/agentstudio/security`;function Lg(e){return`${e}${Ig}/overview`}function Rg(e){return`${e}${Ig}/agent_logs`}function zg(){return`/api/v1/mcps/WebSearch/mcp`}function Bg(){return`/compatible-mode/v1/files`}function Vg(){return`/api/v1/files`}function Hg(e){return`/api/v1/files/${encodeURIComponent(e)}`}function Ug(){return`/api/v1/fine-tunes`}function Wg(e){return`/api/v1/fine-tunes/${encodeURIComponent(e)}`}function Gg(e){return`/api/v1/fine-tunes/${encodeURIComponent(e)}/cancel`}function Kg(e){return`/api/v1/fine-tunes/${encodeURIComponent(e)}/logs`}function qg(){return`/api/v1/fine-tunes/fine-tunes-params`}function Jg(e){return`/api/v1/fine-tunes/${encodeURIComponent(e)}/basic_metrics`}function Yg(e){return`/api/v1/fine-tunes/${encodeURIComponent(e)}/checkpoints`}const Xg=`https://dashscope.aliyuncs.com/api/v1/custom_models/import`;function Zg(){return Xg}function Qg(e){return`${Xg}/${encodeURIComponent(e)}`}function $g(e,t){return`/api/v1/fine-tunes/${encodeURIComponent(e)}/export/${encodeURIComponent(t)}`}function e_(){return`/api/v1/fine-tunes/compress/templates`}function t_(){return`/api/v1/fine-tunes/compress/jobs`}function n_(e){return`/api/v1/fine-tunes/compress/jobs/${encodeURIComponent(e)}`}function r_(e){return`/api/v1/fine-tunes/compress/jobs/${encodeURIComponent(e)}/cancel`}function i_(e){return`/api/v1/fine-tunes/compress/jobs/${encodeURIComponent(e)}/logs`}function a_(){return`/api/v1/deployments`}function o_(e){return`/api/v1/deployments/${encodeURIComponent(e)}`}function s_(e){return`${o_(e)}/capacity-instances`}function c_(e,t){return`${s_(e)}/${encodeURIComponent(t)}`}function l_(e,t){return`${c_(e,t)}/scale`}function u_(e,t){return`${c_(e,t)}/renew`}function d_(e){return`${o_(e)}/update-overflowstrategy`}function f_(e,t){return`${o_(e)}/capacity-operations/${encodeURIComponent(t)}`}function p_(e){return`${o_(e)}/scale`}function m_(e){return`/api/v1/deployments/${encodeURIComponent(e)}/update`}function h_(){return`/api/v1/deployments/models`}function g_(e,t){return Zh(e,t)}function __(){return`/api/v1/agentstudio/files`}function v_(e){return`https://${e}.cn-beijing.maas.aliyuncs.com`}function y_(e){return`/api/v1/agentstudio/sandbox${e}`}function b_(e,t){return v_(e)+y_(t)}const x_={sandboxes:`/sandboxes`,sandboxList:`/v2/sandboxes`,templates:`/templates`,templateCreate:`/v3/templates`,templateList:`/v2/templates`};function S_(e){return`${x_.sandboxes}/${encodeURIComponent(e)}`}function C_(e,t){return`${S_(e)}/${t}`}function w_(e){return`${x_.templates}/${encodeURIComponent(e)}`}function T_(e,t){return`${w_(e)}/builds/${encodeURIComponent(t)}/status`}const E_={indexList:`/api/v1/indices/rag/index/list`,indexCreateV2:`/api/v1/indices/rag/index/create_v2`,indexUpdate:`/api/v1/indices/rag/index/update`,indexDelete:`/api/v1/indices/rag/index/delete`,indexMonitor:`/api/v1/indices/rag/index/monitor`,indexFileDetails:`/api/v1/indices/rag/list/index/file/details`,indexFiles:`/api/v1/indices/rag/index/files`,indexDeleteFile:`/api/v1/indices/rag/index/delete_file`,indexJobCreate:`/api/v1/indices/rag/index/job/create`,indexJobStatus:`/api/v1/indices/rag/index_job/status`,chunkList:`/api/v1/indices/rag/index/chunklist`,chunkCreate:`/api/v1/indices/rag/index/chunk/create`,chunkUpdate:`/api/v1/indices/rag/index/chunk/update`,chunkDelete:`/api/v1/indices/rag/index/chunk/delete`,agentList:`/api/v1/indices/rag/app/list`,agentGet:`/api/v1/indices/rag/app/get`,agentCreate:`/api/v1/indices/rag/app/create`,agentUpdate:`/api/v1/indices/rag/app/update`,agentDeploy:`/api/v1/indices/rag/app/deploy`,agentDelete:`/api/v1/indices/rag/app/delete`,agentCopy:`/api/v1/indices/rag/app/copy`,applyFileUploadLease:`/api/v1/connector/dash/applyFileUploadLease`,addFile:`/api/v1/connector/dash/addFile`,addFilesFromAuthorizedOss:`/api/v1/connector/dash/addFilesFromAuthorizedOss`,batchUpdateFileTag:`/api/v1/connector/dash/batchUpdateFileTag`,listFile:`/api/v1/connector/dash/listFile`,describeFile:`/api/v1/connector/dash/describeFile`,deleteFile:`/api/v1/connector/dash/deleteFile`,addConnector:`/api/v1/connector/dash/addConnector`,getConnector:`/api/v1/connector/dash/getConnector`,listCategory:`/api/v1/connector/dash/listCategory`,addCategory:`/api/v1/connector/dash/addCategory`,deleteCategory:`/api/v1/connector/dash/deleteCategory`},D_=[`qwen-image`,`wan2.7-image`,`z-image`],O_=[`qwen-image-3.0`,`qwen-image-2.0`,`qwen-image-edit`,`wan2.7-image`,`wan2.6-image`];function k_(e,t){return t.some(t=>e.startsWith(t))}function A_(e){return k_(e,D_)||e.startsWith(`wan2.6-image`)}function j_(e){return k_(e,D_)}function M_(e){return k_(e,O_)}function N_(e){return/^wanx-v1(?:-|$)/i.test(e)}function P_(e){return e.startsWith(`wan2.6-t2i`)||e.startsWith(`wan2.6-image`)||j_(e)?!1:!!(/^wan2\.[0-5][^-]*-t2i/i.test(e)||N_(e)||/^wanx/i.test(e)&&/t2i|text2image/i.test(e))}function F_(e){return/wan2\.5-i2i/i.test(e)}function I_(e){return/imageedit/i.test(e)}function L_(e){return e.startsWith(`qwen-image-3.0`)||e.startsWith(`qwen-image-2.0`)||e.startsWith(`qwen-image-edit`)?`qwen-image-2.0`:e.startsWith(`qwen-image`)?`qwen-image-fixed`:e.startsWith(`wan2.7-image`)?`wan27`:e.startsWith(`z-image`)?`z-image`:e.startsWith(`wan2.6-t2i`)||e.startsWith(`wan2.6-image`)||e.startsWith(`wan2.5-t2i`)?`wan26`:N_(e)?`wanx-v1`:/wan2\.5-i2i/i.test(e)?`wan25-i2i`:P_(e)?`wan-legacy`:`wan26`}function R_(e){if(e.startsWith(`qwen-image-3.0`)||e.startsWith(`qwen-image-2.0`)||e.startsWith(`qwen-image-max`))return!0;if(e.startsWith(`z-image`))return!1}function z_(e,t){return{...e,sizeProfile:L_(t),promptExtendDefault:R_(t)}}function B_(e){return j_(e)?z_({kind:`sync-multimodal`,path:lg(),useSync:!0,inputStyle:`messages`},e):P_(e)?z_({kind:`async-text2image`,path:ug(),useSync:!1,inputStyle:`prompt`},e):z_({kind:`async-image-generation`,path:cg(),useSync:!1,inputStyle:`messages`},e)}function V_(e){return M_(e)?z_({kind:`sync-multimodal`,path:lg(),useSync:!0,inputStyle:`messages`},e):I_(e)?z_({kind:`async-image2image`,path:dg(),useSync:!1,inputStyle:`function-base-image`},e):F_(e)?z_({kind:`async-image2image`,path:dg(),useSync:!1,inputStyle:`prompt-images`},e):z_({kind:`async-image-generation`,path:cg(),useSync:!1,inputStyle:`messages`},e)}function H_(e){return/realtime|streaming/i.test(e)}function U_(e){return/filetrans/i.test(e)}function W_(e){return/^qwen3-asr-flash-filetrans(?:-|$)/i.test(e)}const G_=[`fun-asr-flash`,`qwen-audio`];function K_(e){return H_(e)||U_(e)?!1:!!(e.startsWith(G_[0])||e.startsWith(G_[1])&&/asr-flash/i.test(e))}function q_(e){return!(!/^qwen3-asr-flash(?:-|$)/i.test(e)||U_(e)||H_(e)||K_(e))}function J_(e){if(H_(e))return{kind:`unsupported`,path:``,useSync:!1,unsupportedReason:`Model "${e}" is a realtime/streaming ASR model and requires a WebSocket API. Use an async filetrans model (e.g. fun-asr, qwen3-asr-flash-filetrans) or a sync flash model (e.g. qwen3-asr-flash, qwen-audio-3.0-asr-flash) with this command.`};if(U_(e)){let t=W_(e);return{kind:`async-filetrans`,path:Eg(),useSync:!1,asyncInputStyle:t?`file_url`:`file_urls`,asyncLanguageStyle:t?`language`:`language_hints`}}return K_(e)?{kind:`sync-flash`,path:lg(),useSync:!0,flashFamily:`input-audio`}:q_(e)?{kind:`sync-flash`,path:lg(),useSync:!0,flashFamily:`qwen3`}:{kind:`async-filetrans`,path:Eg(),useSync:!1,asyncInputStyle:`file_urls`,asyncLanguageStyle:`language_hints`}}function Y_(e){let t=/^data:audio\/([^;,]+)/i.exec(e)?.[1]?.toLowerCase();if(t)return t===`mpeg`?`mp3`:t===`x-wav`||t===`wave`?`wav`:t;let n=(e.split(/[?#]/,1)[0]??e).match(/\.([a-zA-Z0-9]+)$/)?.[1]?.toLowerCase();return n?n===`mpeg`?`mp3`:n:`wav`}function X_(e){return[{role:`user`,content:[{type:`input_text`,text:e}]}]}function Z_(e,t){return t?e===`language`?{language:t}:{language_hints:[t]}:{}}function Q_(e){let{model:t,audioUrl:n,language:r,vocabularyId:i,vocabulary:a,context:o,flashFamily:s}=e;if(s===`input-audio`){let e={format:Y_(n),sample_rate:`16000`};r&&(e.language_hints=[r]),i&&(e.vocabulary_id=i),a&&(e.vocabulary=a);let s=[];if(o)for(let e of X_(o))s.push(e);return s.push({role:`user`,content:[{type:`input_audio`,input_audio:{data:n}}]}),{model:t,input:{messages:s},parameters:e}}let c={};r&&(c.language=r);let l={};Object.keys(c).length>0&&(l.asr_options=c);let u={model:t,input:{messages:[{role:`user`,content:[{audio:n}]}]}};return Object.keys(l).length>0&&(u.parameters=l),u}function $_(e,t){let n=e.output;if(!n)return``;if(t===`input-audio`){if(typeof n.text==`string`&&n.text.length>0)return n.text;let e=n.sentence;if(typeof e?.text==`string`&&e.text.length>0)return e.text;let t=n.output?.sentence;return typeof t?.text==`string`?t.text:``}let r=n.choices;if(!r?.length)return``;let i=[];for(let e of r){let t=e.message;if(!t)continue;let n=t.content;if(typeof n==`string`){i.push(n);continue}if(Array.isArray(n))for(let e of n){if(typeof e==`string`){i.push(e);continue}if(e&&typeof e==`object`){let t=e;typeof t.text==`string`&&i.push(t.text)}}}return i.join(``)}function ev(e){if(e.results&&e.results.length>0)return e.results;let t=e.result?.transcription_url;return typeof t==`string`&&t.length>0?[{transcription_url:t,subtask_status:`SUCCEEDED`}]:[]}const tv={12000090:`STS credentials unavailable — retry in a moment`,12000091:`Service-linked role creation failed — retry`,12000092:`Use the primary account to create the service-linked role`,12000093:`Cloud security service is unavailable — retry later`,12000094:`Alert query failed — treat as no data`},nv=new Set(Object.values(ft));function rv(e){return nv.has(e.replace(/\/+$/,``))}function iv(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function av(...e){for(let t of e)if(typeof t==`string`&&t.length>0)return t}function ov(e,t,n){let r=e??`unknown`,i=e===void 0&&t===void 0?`\nUnexpected response body (truncated): ${n.slice(0,800)}`:``;throw new D(`Security API failed: ${r} - ${t??`no message`}${i}`,E.GENERAL,tv[r],{rawResponse:n.slice(0,500)})}function sv(e,t){let n;try{n=JSON.parse(e)}catch{throw new D(`Security API returned non-JSON response (${t??`unknown type`}).`,E.GENERAL,void 0,{rawResponse:e.slice(0,500)})}let r=iv(n),i=r?iv(r.data):void 0,a=i?iv(i.DataV2):void 0;if(a){let t=iv(a.data),n=Array.isArray(a.ret)?a.ret.map(e=>String(e)):[],o=n.length===0||n.some(e=>e.startsWith(`SUCCESS`)),s=av(i?.errorCode,r?.errorCode),c=av(i?.errorMsg,r?.errorMsg)??(o?void 0:n.join(`; `));return(r?.successResponse===!1||i?.success===!1||t?.success===!1||t?.failed===!0||!o||s!==void 0)&&ov(s,c,e),(t?t.data:void 0)??null}if(r&&`success`in r)return r.success||ov(av(r.errorCode),av(r.errorMsg),e),r.data??null;if(r){let t=av(i?.errorCode,r.errorCode),n=av(i?.errorMsg,r.errorMsg);(r.successResponse===!1||i?.success===!1||t!==void 0)&&ov(t,n,e)}if(r)return r;ov(void 0,void 0,e)}async function cv(e,t){let n=await e.request({path:t,method:`GET`});return sv(await n.text(),n.headers.get(`content-type`))}function lv(e){try{let{hostname:t}=new URL(e);return t===`aliyuncs.com`||t.endsWith(`.aliyuncs.com`)}catch{return!1}}function uv(e){return typeof e==`string`?e:e instanceof URL?e.href:e.url}function dv(e){return async(t,n={})=>{let r=uv(t),i=new Headers(n.headers??(t instanceof Request?t.headers:void 0));if(i.has(`user-agent`)||i.set(`User-Agent`,`${e.identity.clientName}/${e.identity.version}`),lv(r))for(let[t,n]of Object.entries(Rn(e.identity)))i.set(t,n);Cn(e,n.method??(t instanceof Request?t.method:`GET`),r);let a=await En.fetch(t,{...n,headers:i});return wn(e,a),a}}const fv=`2024-08-16`;function pv(e){return`bailiancontrol.${e}.aliyuncs.com`}function mv(e){return new Wh({identity:e.identity,settings:e.settings,debug:e.debug,baseUrl:e.baseUrl,openApiCred:{accessKeyId:e.accessKeyId,accessKeySecret:e.accessKeySecret,securityToken:e.securityToken,source:`flag`}})}async function hv(e){return mv(e).openApiJson({host:pv(e.regionId),path:`/bailianControl/User/createUser`,action:`CreateUser`,version:fv,method:`POST`,body:{data:JSON.stringify({reqDTO:e.reqDTO})}})}async function gv(e){return mv(e).openApiJson({host:pv(e.regionId),path:`/bailianControl/workspaces`,action:`ListWorkspaces`,version:fv,method:`GET`,queryParams:{data:JSON.stringify({reqDTO:{},cornerstoneParam:{}})}})}async function _v(e){return mv(e).openApiJson({host:pv(e.regionId),path:`/bailianControl/serviserAuthorityPolicy/resetPolicies4Agent`,action:`ChangeUserPermissions`,version:fv,method:`POST`,body:{data:JSON.stringify({cornerstoneParam:{},outerKey:e.outerKey,policyIndexList:e.policyIndexList??[1],agentId:e.agentId})}})}const vv={image:`TextGenerateImage`,video:`VideoGenerate`,speech:`TextGenerateSpeech`,asr:`SpeechGenerateText`},yv={imageGen:`bailian_image_gen`,imageEdit:`bailian_image_edit`,textToVideoSubmit:`bailian_text_to_video_submit_task`,imageToVideoSubmit:`bailian_image_to_video_submit_task`,videoFetchResult:`bailian_text_to_video_fetch_result`,tts:`bailian_tts`,speechToText:`bailian_speech_to_text`};function bv(e){let t=e.content.map(e=>e.text).filter(e=>typeof e==`string`&&e.length>0).join(`
71
- `);if(e.isError)throw new D(`Tool error: ${t}`,E.GENERAL);if(t.length===0)throw new D(`MCP tool returned no text content.`,E.GENERAL);let n;try{n=JSON.parse(t)}catch(e){throw new D(`Failed to parse MCP tool result: ${e.message}`,E.GENERAL)}if(!n||typeof n!=`object`||Array.isArray(n))throw new D(`MCP tool returned an unexpected payload shape.`,E.GENERAL);return n}function xv(e){return{prompt:e.prompt,...e.size===void 0?{}:{size:e.size},...e.n===void 0?{}:{n:e.n},...e.negativePrompt===void 0?{}:{negative_prompt:e.negativePrompt},...e.promptExtend===void 0?{}:{prompt_extend:e.promptExtend}}}function Sv(e){return{image_url:e.imageUrl,prompt:e.prompt,...e.negativePrompt===void 0?{}:{negative_prompt:e.negativePrompt}}}function Cv(e){return{...e.prompt===void 0?{}:{prompt:e.prompt},...e.duration===void 0?{}:{duration:e.duration},...e.resolution===void 0?{}:{resolution:e.resolution},...e.ratio===void 0?{}:{ratio:e.ratio}}}function wv(e){return{...e.firstFrameUrl===void 0?{}:{first_frame_url:e.firstFrameUrl},...e.prompt===void 0?{}:{prompt:e.prompt},...e.duration===void 0?{}:{duration:e.duration},...e.resolution===void 0?{}:{resolution:e.resolution}}}function Tv(e){return{task_id:e}}function Ev(e){return{text:e.text,...e.voice===void 0?{}:{voice:e.voice}}}function Dv(e){return{file_urls:e}}const Ov={"1:1":`1328*1328`,"3:4":`1104*1472`,"4:3":`1472*1104`,"9:16":`928*1664`,"16:9":`1664*928`};function kv(e){let t=/^(\d+)[*xX](\d+)$/.exec(e.trim());return t?`${t[1]}*${t[2]}`:Ov[e.trim()]}const Av=[`电商直播男`,`电商直播女`,`温柔女声`,`沉稳男声`,`英文男声`,`英文女生`,`老年女声`,`老年男声`,`童声男`,`童声女`];function jv(e){return Av.includes(e)}function Mv(e){if(typeof e==`string`&&e.length>0)return e;if(e&&typeof e==`object`){let t=e.url;if(typeof t==`string`&&t.length>0)return t}}function Nv(e){let t=e.results;if(!Array.isArray(t))throw new D("MCP image result is missing a `results` array.",E.GENERAL);return t.map(Mv).filter(e=>e!==void 0)}function Pv(e){let t=e.result;if(typeof t!=`string`||t.length===0)throw new D(`MCP TTS result is missing an audio URL.`,E.GENERAL);let n=typeof e.request_id==`string`?e.request_id:void 0;return{audioUrl:t,...n===void 0?{}:{requestId:n}}}function Fv(e){let t=e.task_id;if(typeof t!=`string`||t.length===0)throw new D(`MCP video submit result is missing a task_id.`,E.GENERAL);return t}function Iv(e){let t=typeof e.task_status==`string`?e.task_status:`UNKNOWN`,n=typeof e.video_url==`string`&&e.video_url.length>0?e.video_url:void 0,r=typeof e.task_id==`string`?e.task_id:void 0,i=typeof e.message==`string`&&e.message.length>0?e.message:void 0,a=typeof e.code==`string`&&e.code.length>0?e.code:void 0;return{taskStatus:t,...n===void 0?{}:{videoUrl:n},...r===void 0?{}:{taskId:r},...i===void 0?{}:{message:i},...a===void 0?{}:{code:a}}}function Lv(e){let t=e.results;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function Rv(e){let t=e,n=!1;t.endsWith(`\r`)&&(n=!0,t=t.slice(0,-1)),t=t.replace(/\r\n/g,`
68
+ `,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;_(e,n,i),n=i+1,e.charCodeAt(n-1)===13&&e.charCodeAt(n)===10&&n++}return e.slice(n)}function _(e,t,n){if(t===n){y();return}let r=e.charCodeAt(t);if(ih(e,t,r)){let r=e.charCodeAt(t+5)===32?t+6:t+5,i=e.slice(r,n);u=d===0?i:`${u}
69
+ ${i}`,d++;return}if(ah(e,t,r)){f=e.slice(e.charCodeAt(t+6)===32?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===32?t+4:t+3,n);r.includes(`\0`)||(l=r);return}if(r===58){if(i){let r=e.slice(t,n);i(r.slice(e.charCodeAt(t+1)===32?2:1))}return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){v(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===32?2:1;v(s,a.slice(o+c),a)}function v(e,t,i){switch(e){case`event`:f=t||void 0;break;case`data`:u=d===0?t:`${u}
70
+ ${t}`,d++;break;case`id`:t.includes(`\0`)||(l=t);break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new th(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new th(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}))}}function y(){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0}function b(e={}){if(e.consume&&o.length>0){let e=o.join(``);_(e,0,e.length)}c=!0,l=void 0,u=``,d=0,f=void 0,o.length=0,s=0,p=!1}return{feed:m,reset:b}}function ih(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function ah(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var oh=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n,maxBufferSize:r}={}){let i;super({start(a){i=rh({onEvent:e=>{a.enqueue(e)},onError(t){typeof e==`function`&&e(t),(e===`terminate`||t.type===`max-buffer-size-exceeded`)&&a.error(t)},onRetry:t,onComment:n,maxBufferSize:r})},transform(e){i.feed(e)}})}};const sh={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};var ch=class extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}},lh=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=Ep(t?.fetch,t?.requestInit),this._followRedirects=t?.redirectPolicy===`follow`,this._followRedirects&&(this._fetch=Mp(this._fetch),this._fetchWithInit=Mp(this._fetchWithInit)),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??sh}_unfollowedRedirect(e,t){let n=Pp(e,t);return n&&!this._followRedirects?`${n} (redirectPolicy: 'same-origin')`:n}async _authThenStart(){if(!this._authProvider)throw new vm(`No auth provider`);let e;try{e=await Nm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new vm;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e[`mcp-session-id`]=this._sessionId),this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=Tp(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){let{resumptionToken:t}=e;try{let n=await this._commonHeaders();n.set(`Accept`,`text/event-stream`),t&&n.set(`last-event-id`,t);let r=this._fetch??fetch,i={method:`GET`,headers:n,signal:this._abortController?.signal},a=await r(this._url,this._followRedirects?i:{...i,redirect:`manual`}),o=this._followRedirects?void 0:Ap(r,this._url,i,a);if(o&&(a=await o),!a.ok){if(await a.body?.cancel(),a.status===401&&this._authProvider)return await this._authThenStart();if(a.status===405)return;throw new ch(a.status,`Failed to open SSE stream: ${this._unfollowedRedirect(a,this._url)??a.statusText}`)}this._handleSseStream(a.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*n**+e,r)}_scheduleReconnection(e,t=0){let n=this._reconnectionOptions.maxRetries;if(t>=n){this.onerror?.(/* @__PURE__ */ Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(/* @__PURE__ */ Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,n){if(!e)return;let{onresumptiontoken:r,replayMessageId:i}=t,a,o=!1,s=!1;(async()=>{try{let t=e.pipeThrough(new TextDecoderStream).pipeThrough(new oh({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){let{value:e,done:n}=await t.read();if(n)break;if(e.id&&(a=e.id,o=!0,r?.(e.id)),e.data&&(!e.event||e.event===`message`))try{let t=Nl.parse(JSON.parse(e.data));Al(t)&&(s=!0,i!==void 0&&(t.id=i)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){if(this.onerror?.(/* @__PURE__ */ Error(`SSE stream disconnected: ${e}`)),(n||o)&&!s&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:a,onresumptiontoken:r,replayMessageId:i},0)}catch(e){this.onerror?.(/* @__PURE__ */ Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw Error(`StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.`);this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new vm(`No auth provider`);if(await Nm(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new vm(`Failed to authorize`)}async close(){this._reconnectionTimeout&&=(clearTimeout(this._reconnectionTimeout),void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{let{resumptionToken:n,onresumptiontoken:r}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:El(e)?e.id:void 0}).catch(e=>this.onerror?.(e));return}let i=await this._commonHeaders();i.set(`content-type`,`application/json`),i.set(`accept`,`application/json, text/event-stream`);let a={...this._requestInit,method:`POST`,headers:i,body:JSON.stringify(e),signal:this._abortController?.signal},o=await Np(this._fetch??fetch)(this._url,a),s=o.headers.get(`mcp-session-id`);if(s&&(this._sessionId=s),!o.ok){let t=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new ch(401,`Server returned 401 after successful authentication`);let{resourceMetadataUrl:t,scope:n}=Lm(o);if(this._resourceMetadataUrl=t,this._scope=n,await Nm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new vm;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){let{resourceMetadataUrl:t,scope:n,error:r}=Lm(o);if(r===`insufficient_scope`){let r=o.headers.get(`WWW-Authenticate`);if(this._lastUpscopingHeader===r)throw new ch(403,`Server returned 403 after trying upscoping`);if(n&&(this._scope=n),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=r??void 0,await Nm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!==`AUTHORIZED`)throw new vm;return this.send(e)}}throw new ch(o.status,`Error POSTing to endpoint: ${this._unfollowedRedirect(o,this._url)??t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),Yl(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e));return}let c=(Array.isArray(e)?e:[e]).filter(e=>`method`in e&&`id`in e&&e.id!==void 0).length>0,l=o.headers.get(`content-type`),u=wp(l);if(c){if(u===`text/event-stream`)this._handleSseStream(o.body,{onresumptiontoken:r},!1);else if(u===`application/json`){let e=await o.json(),t=Array.isArray(e)?e.map(e=>Nl.parse(e)):[Nl.parse(e)];for(let e of t)this.onmessage?.(e)}else throw await o.body?.cancel(),new ch(-1,`Unexpected content type: ${l}`)}else await o.body?.cancel()}catch(e){throw this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:`DELETE`,headers:e,signal:this._abortController?.signal},n=await Np(this._fetch??fetch)(this._url,t);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new ch(n.status,`Failed to terminate session: ${this._unfollowedRedirect(n,this._url)??n.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}},uh=class extends Event{constructor(e,t){super(e),this.code=t?.code??void 0,this.message=t?.message??void 0}[Symbol.for(`nodejs.util.inspect.custom`)](e,t,n){return n(ph(this),t)}[Symbol.for(`Deno.customInspect`)](e,t){return e(ph(this),t)}};function dh(e){let t=globalThis.DOMException;return typeof t==`function`?new t(e,`SyntaxError`):SyntaxError(e)}function fh(e){return e instanceof Error?`errors`in e&&Array.isArray(e.errors)?e.errors.map(fh).join(`, `):`cause`in e&&e.cause instanceof Error?`${e}: ${fh(e.cause)}`:e.message:`${e}`}function ph(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var mh=e=>{throw TypeError(e)},hh=(e,t,n)=>t.has(e)||mh(`Cannot `+n),Y=(e,t,n)=>(hh(e,t,`read from private field`),n?n.call(e):t.get(e)),gh=(e,t,n)=>t.has(e)?mh(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),X=(e,t,n,r)=>(hh(e,t,`write to private field`),t.set(e,n),n),_h=(e,t,n)=>(hh(e,t,`access private method`),n),vh,yh,bh,xh,Sh,Ch,wh,Th,Eh,Dh,Oh,kh,Ah,jh,Mh,Nh,Ph,Fh,Ih,Lh,Rh,zh,Bh,Vh=class extends EventTarget{constructor(e,t){super(),gh(this,jh),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,gh(this,vh),gh(this,yh),gh(this,bh),gh(this,xh),gh(this,Sh),gh(this,Ch),gh(this,wh),gh(this,Th,null),gh(this,Eh),gh(this,Dh),gh(this,Oh,null),gh(this,kh,null),gh(this,Ah,null),gh(this,Nh,async e=>{var t;Y(this,Dh).reset();let{body:n,redirected:r,status:i,headers:a}=e;if(i===204){_h(this,jh,Rh).call(this,`Server sent HTTP 204, not reconnecting`,204),this.close();return}if(r?X(this,bh,new URL(e.url)):X(this,bh,void 0),i!==200){_h(this,jh,Rh).call(this,`Non-200 status code (${i})`,i);return}if(!(a.get(`content-type`)||``).startsWith(`text/event-stream`)){_h(this,jh,Rh).call(this,`Invalid content type, expected "text/event-stream"`,i);return}if(Y(this,vh)===this.CLOSED)return;X(this,vh,this.OPEN);let o=new Event(`open`);if((t=Y(this,Ah))==null||t.call(this,o),this.dispatchEvent(o),typeof n!=`object`||!n||!(`getReader`in n)){_h(this,jh,Rh).call(this,`Invalid response body, expected a web ReadableStream`,i),this.close();return}let s=new TextDecoder,c=n.getReader(),l=!0;do{let{done:e,value:t}=await c.read();t&&Y(this,Dh).feed(s.decode(t,{stream:!e})),e&&(l=!1,Y(this,Dh).reset(),_h(this,jh,zh).call(this))}while(l)}),gh(this,Ph,e=>{X(this,Eh,void 0),e.name!==`AbortError`&&e.type!==`aborted`&&_h(this,jh,zh).call(this,fh(e))}),gh(this,Ih,e=>{typeof e.id==`string`&&X(this,Th,e.id);let t=new MessageEvent(e.event||`message`,{data:e.data,origin:Y(this,bh)?Y(this,bh).origin:Y(this,yh).origin,lastEventId:e.id||``});Y(this,kh)&&(!e.event||e.event===`message`)&&Y(this,kh).call(this,t),this.dispatchEvent(t)}),gh(this,Lh,e=>{X(this,Ch,e)}),gh(this,Bh,()=>{X(this,wh,void 0),Y(this,vh)===this.CONNECTING&&_h(this,jh,Mh).call(this)});try{if(e instanceof URL)X(this,yh,e);else if(typeof e==`string`)X(this,yh,new URL(e,Hh()));else throw Error(`Invalid URL`)}catch{throw dh(`An invalid or illegal string was specified`)}X(this,Dh,rh({onEvent:Y(this,Ih),onRetry:Y(this,Lh)})),X(this,vh,this.CONNECTING),X(this,Ch,3e3),X(this,Sh,t?.fetch??globalThis.fetch),X(this,xh,t?.withCredentials??!1),_h(this,jh,Mh).call(this)}get readyState(){return Y(this,vh)}get url(){return Y(this,yh).href}get withCredentials(){return Y(this,xh)}get onerror(){return Y(this,Oh)}set onerror(e){X(this,Oh,e)}get onmessage(){return Y(this,kh)}set onmessage(e){X(this,kh,e)}get onopen(){return Y(this,Ah)}set onopen(e){X(this,Ah,e)}addEventListener(e,t,n){let r=t;super.addEventListener(e,r,n)}removeEventListener(e,t,n){let r=t;super.removeEventListener(e,r,n)}close(){Y(this,wh)&&clearTimeout(Y(this,wh)),Y(this,vh)!==this.CLOSED&&(Y(this,Eh)&&Y(this,Eh).abort(),X(this,vh,this.CLOSED),X(this,Eh,void 0))}};vh=/* @__PURE__ */ new WeakMap,yh=/* @__PURE__ */ new WeakMap,bh=/* @__PURE__ */ new WeakMap,xh=/* @__PURE__ */ new WeakMap,Sh=/* @__PURE__ */ new WeakMap,Ch=/* @__PURE__ */ new WeakMap,wh=/* @__PURE__ */ new WeakMap,Th=/* @__PURE__ */ new WeakMap,Eh=/* @__PURE__ */ new WeakMap,Dh=/* @__PURE__ */ new WeakMap,Oh=/* @__PURE__ */ new WeakMap,kh=/* @__PURE__ */ new WeakMap,Ah=/* @__PURE__ */ new WeakMap,jh=/* @__PURE__ */ new WeakSet,Mh=function(){X(this,vh,this.CONNECTING),X(this,Eh,new AbortController),Y(this,Sh)(Y(this,yh),_h(this,jh,Fh).call(this)).then(Y(this,Nh)).catch(Y(this,Ph))},Nh=/* @__PURE__ */ new WeakMap,Ph=/* @__PURE__ */ new WeakMap,Fh=function(){let e={mode:`cors`,redirect:`follow`,headers:{Accept:`text/event-stream`,...Y(this,Th)?{"Last-Event-ID":Y(this,Th)}:void 0},cache:`no-store`,signal:Y(this,Eh)?.signal};return`window`in globalThis&&(e.credentials=this.withCredentials?`include`:`same-origin`),e},Ih=/* @__PURE__ */ new WeakMap,Lh=/* @__PURE__ */ new WeakMap,Rh=function(e,t){var n;Y(this,vh)!==this.CLOSED&&X(this,vh,this.CLOSED);let r=new uh(`error`,{code:t,message:e});(n=Y(this,Oh))==null||n.call(this,r),this.dispatchEvent(r)},zh=function(e,t){var n;if(Y(this,vh)===this.CLOSED)return;X(this,vh,this.CONNECTING);let r=new uh(`error`,{code:t,message:e});(n=Y(this,Oh))==null||n.call(this,r),this.dispatchEvent(r),X(this,wh,setTimeout(Y(this,Bh),Y(this,Ch)))},Bh=/* @__PURE__ */ new WeakMap,Vh.CONNECTING=0,Vh.OPEN=1,Vh.CLOSED=2;function Hh(){let e=`document`in globalThis?globalThis.document:void 0;return e&&typeof e==`object`&&`baseURI`in e&&typeof e.baseURI==`string`?e.baseURI:void 0}var Uh=class extends Error{constructor(e,t,n){super(`SSE error: ${t}`),this.code=e,this.event=n}},Wh=class{constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=t?.eventSourceInit,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=Ep(t?.fetch,t?.requestInit),this._followRedirects=t?.redirectPolicy===`follow`,this._followRedirects&&(this._fetch=Mp(this._fetch),this._fetchWithInit=Mp(this._fetchWithInit))}_unfollowedRedirect(e,t){let n=Pp(e,t);return n&&!this._followRedirects?`${n} (redirectPolicy: 'same-origin')`:n}async _authThenStart(){if(!this._authProvider)throw new vm(`No auth provider`);let e;try{e=await Nm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if(e!==`AUTHORIZED`)throw new vm;return await this._startOrAuth()}async _commonHeaders(){let e={};if(this._authProvider){let t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._protocolVersion&&(e[`mcp-protocol-version`]=this._protocolVersion);let t=Tp(this._requestInit?.headers);return new Headers({...e,...t})}_startOrAuth(){let e=this?._eventSourceInit?.fetch??this._fetch??fetch,t=this._followRedirects?e:Np(e),n;return new Promise((e,r)=>{this._eventSource=new Vh(this._url.href,{...this._eventSourceInit,fetch:async(e,r)=>{let i=await this._commonHeaders();i.set(`Accept`,`text/event-stream`);let a=await t(e,{...r,headers:i});if(n=this._unfollowedRedirect(a,e),a.status===401&&a.headers.has(`www-authenticate`)){let{resourceMetadataUrl:e,scope:t}=Lm(a);this._resourceMetadataUrl=e,this._scope=t}return a}}),this._abortController=new AbortController,this._eventSource.onerror=t=>{if(t.code===401&&this._authProvider){this._authThenStart().then(e,r);return}let i=new Uh(t.code,n??t.message,t);r(i),this.onerror?.(i)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener(`endpoint`,t=>{let n=t;try{if(this._endpoint=new URL(n.data,this._url),this._endpoint.origin!==this._url.origin)throw Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(e){r(e),this.onerror?.(e),this.close();return}e()}),this._eventSource.onmessage=e=>{let t=e,n;try{n=Nl.parse(JSON.parse(t.data))}catch(e){this.onerror?.(e);return}this.onmessage?.(n)}})}async start(){if(this._eventSource)throw Error(`SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.`);return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new vm(`No auth provider`);if(await Nm(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new vm(`Failed to authorize`)}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw Error(`Not connected`);try{let t=await this._commonHeaders();t.set(`content-type`,`application/json`);let n={...this._requestInit,method:`POST`,headers:t,body:JSON.stringify(e),signal:this._abortController?.signal},r=await Np(this._fetch??fetch)(this._endpoint,n);if(!r.ok){let t=await r.text().catch(()=>null);if(r.status===401&&this._authProvider){let{resourceMetadataUrl:t,scope:n}=Lm(r);if(this._resourceMetadataUrl=t,this._scope=n,await Nm(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!==`AUTHORIZED`)throw new vm;return this.send(e)}throw Error(`Error POSTing to endpoint (HTTP ${r.status}): ${this._unfollowedRedirect(r,this._endpoint)??t}`)}await r.body?.cancel()}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}},Gh=class{adapter;constructor(e,t,n){this.adapter=new Xh({deps:e,url:t,authToken:n,transport:`streamable`})}initialize(){return this.adapter.initialize()}listTools(){return this.adapter.listTools()}callTool(e,t){return this.adapter.callTool(e,t)}close(){this.adapter.close()}};function Kh(e,t,n){if(e instanceof O)return e;if(e instanceof K){let t=qh(e);return e.code===G.ConnectionClosed&&n?.localCloseFired?new O(t||`MCP connection closed.`,D.NETWORK):new O(`MCP error (${e.code}): ${t}`,D.GENERAL)}if(e instanceof ch){let t=e.code;return new O(`MCP request failed: ${t}`,D.GENERAL,void 0,{api:{httpStatus:typeof t==`number`?t:void 0},cause:e})}if(e instanceof Uh&&t&&t.status===e.code){let n=`MCP request failed: ${t.status} ${t.statusText}`;return t.body&&(n+=` - ${t.body.slice(0,500)}`),new O(n,D.GENERAL,void 0,{api:{httpStatus:t.status},cause:e})}return e}function qh(e){let t=`MCP error ${e.code}: `;return e.message.startsWith(t)?e.message.slice(t.length):e.message}function Jh(e,t,n){return async(r,i)=>{let a=i?.method??`GET`,o=typeof r==`string`?r:r.href,s;if(typeof i?.body==`string`)try{let e=JSON.parse(i.body);typeof e.method==`string`&&(s=e.method)}catch{}Mn(e,a,o,{rpc_method:s});let c=await Fn.fetch(r,i);if(Nn(e,c),!c.ok&&a===`POST`&&!Yh(c.status)){let e=`MCP request failed: ${c.status} ${c.statusText}`;try{let t=await c.text();t&&(e+=` - ${t.slice(0,500)}`)}catch{}throw new O(e,D.GENERAL)}if(t===`sse`&&n&&!c.ok&&a===`GET`&&!Yh(c.status)){let e=``;try{e=await c.text()}catch{}n({status:c.status,statusText:c.statusText,body:e})}return c}}function Yh(e){return e>=300&&e<400}var Xh=class{deps;url;authToken;kind;serviceSource;client;transport;connecting;sseGetFailure;transportClosed=!1;constructor(e){this.deps=e.deps,this.url=e.url,this.authToken=e.authToken,this.kind=e.transport,this.serviceSource=e.serviceSource}async initialize(){if(!this.authToken)throw new O(`This command needs a model-domain API key.`,D.AUTH);return this.connecting||=this.connect().catch(e=>{throw this.connecting=void 0,this.mapTransportError(e)}),this.connecting}async listTools(){let e=await this.requireClient();try{return(await this.withLocalTimeout(e.listTools(void 0,this.requestOptions()))).tools}catch(e){throw this.mapTransportError(e)}}async callTool(e,t){let n=await this.requireClient();try{let r=await this.withLocalTimeout(n.callTool({name:e,arguments:t},void 0,this.requestOptions()));if(!Array.isArray(r.content))throw new O(`MCP tool returned an unexpected result shape.`,D.GENERAL);return r}catch(e){throw this.mapTransportError(e)}}close(){let e=this.transport;this.client=void 0,this.transport=void 0,this.connecting=void 0,this.sseGetFailure=void 0,e&&e.close().catch(()=>void 0)}mapTransportError(e){return Kh(e,this.sseGetFailure,{localCloseFired:this.transportClosed})}async connect(){let e={"User-Agent":`${this.deps.identity.clientName}/${this.deps.identity.version}`,...Yn(this.deps.identity,this.serviceSource),Authorization:`Bearer ${this.authToken}`},t=Jh(this.deps,this.kind,e=>{this.sseGetFailure=e}),n=new URL(this.url);this.transportClosed=!1;let r=this.kind===`sse`?new Wh(n,{requestInit:{headers:e},fetch:t}):new lh(n,{requestInit:{headers:e},fetch:t});r.onclose=()=>{this.transportClosed=!0};let i=new Sp({name:this.deps.identity.clientName,version:this.deps.identity.version},{capabilities:{}});this.transport=r;let a=i.connect(r,this.requestOptions());a.catch(()=>void 0);let o,s=new Promise((e,t)=>{o=setTimeout(()=>t(new O(`MCP session handshake timed out after ${this.deps.settings.timeout}s.`,D.TIMEOUT)),this.deps.settings.timeout*1e3)});try{await Promise.race([a,s])}catch(e){throw this.transport=void 0,await r.close().catch(()=>void 0),e}finally{o&&clearTimeout(o)}if(this.transport!==r)throw await r.close().catch(()=>void 0),new O(`MCP connection was closed during the handshake.`,D.NETWORK);this.client=i;let c=i.getServerVersion();this.deps.debug?.({message:{"en-US":`MCP session initialized`,"zh-CN":`MCP 会话已初始化`},details:{transport:this.kind,has_session_id:r instanceof lh&&!!r.sessionId,server_name:c?.name,server_version:c?.version}})}async requireClient(){if(await this.initialize(),!this.client)throw new O(`MCP client is not connected.`,D.GENERAL);return this.client}requestOptions(){return{timeout:2147483647}}async withLocalTimeout(e){let t=this.deps.settings.timeout,n,r=new Promise((e,r)=>{n=setTimeout(()=>{r(new O(`MCP request timed out after ${t}s.`,D.TIMEOUT))},t*1e3)});try{return await Promise.race([e,r])}finally{n&&clearTimeout(n)}}};function Zh(e){return`/api/v1/mcps/${e}/mcp`}function Qh(e){return`/api/v1/mcps/${e}/sse`}function $h(e){return e instanceof O&&/^MCP request failed:\s*405\b/i.test(e.message)}function eg(e){return e instanceof O&&/^MCP request failed:\s*(405|404)\b/i.test(e.message)}async function tg(e){let{deps:t,authToken:n,httpUrl:r,sseUrl:i,serverCode:a,urlOverride:o,serviceSource:s}=e;if(o){let e=new Xh({deps:t,url:o,authToken:n,transport:`streamable`,serviceSource:s});try{return await e.initialize(),{client:e,url:o}}catch(e){if(!eg(e))throw e}let r=new Xh({deps:t,url:o,authToken:n,transport:`sse`,serviceSource:s});try{return await r.initialize(),{client:r,url:o}}catch(e){throw r.close(),e}}let c=new Xh({deps:t,url:r,authToken:n,transport:`streamable`,serviceSource:s});try{return await c.initialize(),{client:c,url:r}}catch(e){if(!$h(e)||a===`WebSearch`)throw e}let l=new Xh({deps:t,url:i,authToken:n,transport:`sse`,serviceSource:s});try{return await l.initialize(),{client:l,url:i}}catch(e){throw l.close(),e}}var ng=class e{deps;consoleTokenPersisted;consoleRefresh;constructor(e){this.deps=e,this.consoleTokenPersisted=e.consoleCred?.source===`config`}withSwitchAgent(t){let n=new e({...this.deps,settings:{...this.deps.settings,consoleSwitchAgent:t},consoleCred:this.deps.consoleCred?{...this.deps.consoleCred,switchAgent:t}:void 0});return n.consoleTokenPersisted=this.consoleTokenPersisted,n}async request(e,t){return this.dispatch(n=>Hn(n,this.deps.settings.timeout,{api:e,data:t},{debug:this.deps.debug,recoveryHint:this.deps.consoleRecoveryHint}))}async dispatch(e){let t=this.deps.consoleCred;if(!t){let t=new O(`This command needs a console access token.`,D.AUTH);if(!this.deps.resolveConsoleOpenApiCredential)throw t;return this.refreshConsole(e,t)}try{return await e(t)}catch(n){if(!(n instanceof _t)||n.reason!==`expired-console-session`)throw n;return this.refreshConsole(e,n,t)}}async refreshConsole(e,t,n){if(this.deps.consoleCred&&this.deps.consoleCred!==n)return e(this.deps.consoleCred);let r=this.consoleRefresh;(!r||r.previous!==n)&&(r={previous:n,promise:this.exchangeConsoleToken(n),users:0},this.consoleRefresh=r),r.users++;try{let i=await r.promise.catch(e=>{throw e instanceof _t&&e.reason===`missing-openapi-pair`?t:e});if(!i)throw t;let a=await e(i.credential);return r.commit??=(async()=>{this.deps.consoleCred===n&&(i.persist&&await lg(i.credential.token,this.deps.settings.configName),this.consoleTokenPersisted=i.persist,this.deps.consoleCred=i.credential)})(),await r.commit,a}finally{r.users--,r.users===0&&this.consoleRefresh===r&&(this.consoleRefresh=void 0)}}async exchangeConsoleToken(e){let t=this.deps.resolveConsoleOpenApiCredential?.(),n=e??ag(this.deps.settings,this.deps.baseUrl),r=this.consoleTokenPersisted&&e?.source===`config`&&(!t||t.source===`config`),i=await cg({identity:this.deps.identity,settings:{...this.deps.settings,consoleRegion:n.region,consoleSite:n.site,consoleSwitchAgent:n.switchAgent},debug:this.deps.debug,baseUrl:this.deps.baseUrl,credential:t,persist:!1,validateToken:async()=>{}});return i?{credential:{...n,token:i,source:t?.source??e?.source??`config`},persist:r}:null}},rg=class e{deps;consoleSession;constructor(e){this.deps=e,this.consoleSession=new ng(e)}get http(){return{identity:this.deps.identity,settings:this.deps.settings,debug:this.deps.debug}}requireApi(){if(!this.deps.apiCred)throw new O(`This command needs a model-domain API key.`,D.AUTH);return this.deps.apiCred}requireOpenApi(){if(!this.deps.openApiCred)throw new O(`This command needs Alibaba Cloud OpenAPI AK/SK credentials.`,D.AUTH);return this.deps.openApiCred}get baseUrl(){return this.deps.apiCred?.baseUrl??this.deps.baseUrl}exportApiCredential(){return this.deps.apiCred}bailianMcpRegistrationHeaders(){return{Authorization:`Bearer ${this.requireApi().token}`,...Yn(this.deps.identity)}}url(e,t){return(this.deps.baseUrlIsDefault&&t?t():this.baseUrl)+e}toOpts({path:e,...t}){let n=this.requireApi();return{...t,url:/^https?:\/\//.test(e)?e:n.baseUrl+e,headers:{...t.headers,Authorization:`Bearer ${n.token}`}}}request(e){return Qn(this.http,this.toOpts(e))}requestJson(e){return nr(this.http,this.toOpts(e))}uploadFile(e,t,n={}){return xr(e)?Sr(e,this.requireApi().token,t,{signal:n.signal,baseUrl:this.url(``,n.defaultBaseUrl),identity:this.deps.identity,timeout:this.deps.settings.timeout}):Promise.resolve(e)}resolveImageInput(e,t,n={}){return xr(e)?this.usesTokenPlanEndpoint()?Promise.resolve(_r(e)):this.uploadFile(e,t,n):Promise.resolve(e)}usesTokenPlanEndpoint(){try{return/^token-plan\.[a-z0-9-]+\.maas\.aliyuncs\.com$/i.test(new URL(this.baseUrl).hostname)}catch{return!1}}usesTokenPlanConnection(){return this.usesTokenPlanEndpoint()||Dn(this.deps.apiCred?.token??``)===`token-plan`}mcp(e){let t=/^https?:\/\//.test(e)?e:this.requireApi().baseUrl+e;return new Xh({deps:this.http,url:t,authToken:this.deps.apiCred?.token,transport:`streamable`})}connectBailianMcp(e,t,n){return this.requireApi(),tg({deps:this.http,authToken:this.deps.apiCred?.token,httpUrl:this.url(Zh(e)),sseUrl:this.url(Qh(e)),serverCode:e,urlOverride:t,serviceSource:n})}withConsoleSwitchAgent(t){let n=new e({...this.deps,settings:{...this.deps.settings,consoleSwitchAgent:t}});return n.consoleSession=this.consoleSession.withSwitchAgent(t),n}console(e,t){return this.consoleSession.request(e,t)}openApiQueryJson(e){return this.openApiJson(e)}async openApiJson(e){let t=this.requireOpenApi(),n=e.body===void 0?``:JSON.stringify(e.body),r=e.queryParams?rr(e.queryParams):``,i=`https://${e.host}${e.path}${r?`?${r}`:``}`,a=ir({accessKeyId:t.accessKeyId,accessKeySecret:t.accessKeySecret,securityToken:t.securityToken,action:e.action,version:e.version,body:n,host:e.host,pathname:e.path,method:e.method,queryString:r});Mn(this.http,e.method,i,{action:e.action,version:e.version});let o=this.deps.settings.timeout*1e3,s=await Fn.fetch(i,{method:e.method,headers:{...a,...Yn(this.deps.identity)},body:n||void 0,signal:AbortSignal.timeout(o)}),c=await s.text();Nn(this.http,s);let l;try{l=JSON.parse(c)}catch{throw new O(`${s.status} ${s.statusText} - ${c.slice(0,500)}`,D.GENERAL)}if(!s.ok||l.Success===!1)throw new O(`${l.Code||s.status} - ${l.Message||s.statusText}`,D.GENERAL);return l}};const ig=/* @__PURE__ */ new Map([[`cn-beijing`,`modelstudio.cn-beijing.aliyuncs.com`],[`ap-southeast-1`,`modelstudio.ap-southeast-1.aliyuncs.com`]]);function ag(e,t){let n=e.consoleRegion;if(!n){let e;try{e=new URL(t).hostname}catch{}n=e===`dashscope.aliyuncs.com`?`cn-beijing`:e===`dashscope-intl.aliyuncs.com`?`ap-southeast-1`:e?.match(/^[a-z0-9-]+\.(cn-beijing|ap-southeast-1)\.maas\.aliyuncs\.com$/)?.[1]}if(!n||!ig.has(n))throw new O(`Cannot resolve a supported CLI token region. / 无法确定受支持的 CLI token 地域。`,D.USAGE,`Set console_region to cn-beijing or ap-southeast-1. / 请配置 console_region 为 cn-beijing 或 ap-southeast-1。`);return{region:n,site:e.consoleSite??`domestic`,switchAgent:e.consoleSwitchAgent}}async function og(e,t,n={}){let r=await Hn(e,t.timeout,{api:`zeldaEasy.cornerstone-portal.cs-console.loginInfo`,data:{}},n);if(r?.data?.success!==!0)throw new O(`Console token validation did not return success. / 控制台 token 校验未返回成功结果。`,D.GENERAL,void 0,{rawResponse:JSON.stringify(r)})}async function sg(e){let{identity:t,settings:n,baseUrl:r,accessKeyId:i,accessKeySecret:a,securityToken:o}=e,s=new rg({identity:t,settings:n,debug:e.debug,baseUrl:r,openApiCred:{accessKeyId:i,accessKeySecret:a,securityToken:o,source:`flag`}}),c=ag(n,r),l=ig.get(c.region),u=await s.openApiQueryJson({host:l,path:`/modelstudio/cli/generateAccessToken`,action:`GenerateCLIAccessToken`,version:`2026-02-10`,method:`POST`,queryParams:{}});if(typeof u.cliAccessToken!=`string`||!u.cliAccessToken.trim())throw new O(`CLI token response is missing cliAccessToken. / CLI token 响应缺少有效的 cliAccessToken。`,D.GENERAL);return{...u,cliAccessToken:u.cliAccessToken.trim()}}async function cg(e){let t=e.settings.configName,n=e.credential?void 0:fn(t),r=e.credential?.accessKeyId??n?.access_key_id,i=e.credential?.accessKeySecret??n?.access_key_secret;if(!r||!i)return null;e.debug?.({message:{"en-US":`Refreshing access token`,"zh-CN":`正在刷新访问令牌`}});let a=(await sg({identity:e.identity,settings:e.settings,debug:e.debug,baseUrl:e.baseUrl,accessKeyId:r,accessKeySecret:i,securityToken:e.credential?e.credential.securityToken:n?.security_token})).cliAccessToken;return e.validateToken?await e.validateToken(a):await og({...ag(e.settings,e.baseUrl),token:a},e.settings,{debug:e.debug}),(e.persist??(!e.credential||e.credential.source===`config`))&&await lg(a,t),a}async function lg(e,t){let n=fn(t);n.access_token=e,await pn(n,t)}function ug(e,t){if(!/^[a-zA-Z0-9_-]+$/.test(e))throw new k(`Workspace ID must contain only letters, digits, hyphens or underscores. / Workspace ID 只能包含字母、数字、连字符或下划线。`);return`https://${e}.cn-beijing.maas.aliyuncs.com${t}`}function dg(e){return ug(e,``)}function fg(e,t,n){let r;try{r=new URL(e)}catch{throw new k(`Invalid ParseX base URL. / ParseX Base URL 无效。`)}let i=[`localhost`,`127.0.0.1`,`[::1]`].includes(r.hostname),a=r.pathname.replace(/\/+$/,``);if(r.protocol!==`https:`&&!(r.protocol===`http:`&&i)||r.username||r.password||r.search||r.hash||a)throw new k(`ParseX base URL must be an HTTPS origin (HTTP is allowed only on loopback). / ParseX Base URL 必须为 HTTPS 源站(仅本机回环地址允许 HTTP)。`);let o=r.hostname.endsWith(`.cn-beijing.pre-maas.aliyuncs.com`)?`/api/v2/apps/pre-parse-x`:`/api/v2/apps/parse-x`;return`${r.origin}${o}/${t}/${n}`}function pg(){return`/compatible-mode/v1/chat/completions`}function mg(){return`/compatible-mode/v1/batches`}function hg(e){return`${mg()}/${encodeURIComponent(e)}`}function gg(e){return`${hg(e)}/cancel`}function _g(e){return`/compatible-mode/v1/files/${encodeURIComponent(e)}/content`}function vg(){return`https://batch.dashscope.aliyuncs.com`}function yg(){return`/compatible-mode/v1/responses`}function bg(){return`/compatible-mode/v1/systemone`}function xg(){return`/api/v1/services/aigc/image-generation/generation`}function Sg(){return`/api/v1/services/aigc/multimodal-generation/generation`}function Cg(){return`/api/v1/services/aigc/text2image/image-synthesis`}function wg(){return`/api/v1/services/aigc/image2image/image-synthesis`}function Tg(){return`/api/v1/services/aigc/video-generation/video-synthesis`}function Eg(){return`/api/v1/services/aigc/image2video/video-synthesis`}function Dg(e){return`/api/v1/tasks/${encodeURIComponent(e)}`}function Og(){return`/api/v1/models/limits`}function kg(){return`/api/v1/models/permissions`}function Ag(e){return`/api/v1/apps/${encodeURIComponent(e)}/completion`}function jg(e,t){return ug(e,t)}function Mg(){return`/api/v2/apps/memory/add-async`}function Ng(e){return`/api/v2/apps/memory/events/${encodeURIComponent(e)}`}function Pg(){return`/api/v2/apps/memory/memory_nodes/search`}function Fg(){return`/api/v2/apps/memory/memory_nodes`}function Ig(e){return`/api/v2/apps/memory/memory_nodes/${encodeURIComponent(e)}`}function Lg(e){return`/api/v2/apps/memory/skill/export/${encodeURIComponent(e)}`}function Rg(){return`/api/v1/services/audio/tts/SpeechSynthesizer`}function zg(){return`/api/v1/services/audio/asr/transcription`}function Bg(){return`/api/v1/services/audio/asr/customization`}function Vg(){return`/api/v2/apps/memory/profile_schemas`}function Hg(e){return`/api/v2/apps/memory/profile_schemas/${encodeURIComponent(e)}`}function Ug(e){return`${Hg(e)}/user_profile`}function Wg(e){return`${Hg(e)}/profile_values`}function Gg(e,t=`cn-beijing`){return`https://${e}.${t}.maas.aliyuncs.com`}function Kg(e){return ug(e,`/api/v1/indices/knowledge/search`)}function qg(e){return ug(e,`/api/v2/apps/knowledge/chat`)}function Jg(e){return`https://${e}.cn-beijing.maas.aliyuncs.com`}const Yg=`/api/v1/agentstudio/security`;function Xg(e){return`${e}${Yg}/overview`}function Zg(e){return`${e}${Yg}/agent_logs`}function Qg(){return`/api/v1/mcps/WebSearch/mcp`}function $g(){return`/compatible-mode/v1/files`}function e_(){return`/api/v1/files`}function t_(e){return`/api/v1/files/${encodeURIComponent(e)}`}function n_(){return`/api/v1/fine-tunes`}function r_(e){return`/api/v1/fine-tunes/${encodeURIComponent(e)}`}function i_(e){return`/api/v1/fine-tunes/${encodeURIComponent(e)}/cancel`}function a_(e){return`/api/v1/fine-tunes/${encodeURIComponent(e)}/logs`}function o_(){return`/api/v1/fine-tunes/fine-tunes-params`}function s_(e){return`/api/v1/fine-tunes/${encodeURIComponent(e)}/basic_metrics`}function c_(e){return`/api/v1/fine-tunes/${encodeURIComponent(e)}/checkpoints`}const l_=`https://dashscope.aliyuncs.com/api/v1/custom_models/import`;function u_(){return l_}function d_(e){return`${l_}/${encodeURIComponent(e)}`}function f_(e,t){return`/api/v1/fine-tunes/${encodeURIComponent(e)}/export/${encodeURIComponent(t)}`}function p_(){return`/api/v1/fine-tunes/compress/templates`}function m_(){return`/api/v1/fine-tunes/compress/jobs`}function h_(e){return`/api/v1/fine-tunes/compress/jobs/${encodeURIComponent(e)}`}function g_(e){return`/api/v1/fine-tunes/compress/jobs/${encodeURIComponent(e)}/cancel`}function __(e){return`/api/v1/fine-tunes/compress/jobs/${encodeURIComponent(e)}/logs`}function v_(){return`/api/v1/deployments`}function y_(e){return`/api/v1/deployments/${encodeURIComponent(e)}`}function b_(e){return`${y_(e)}/capacity-instances`}function x_(e,t){return`${b_(e)}/${encodeURIComponent(t)}`}function S_(e,t){return`${x_(e,t)}/scale`}function C_(e,t){return`${x_(e,t)}/renew`}function w_(e){return`${y_(e)}/update-overflowstrategy`}function T_(e,t){return`${y_(e)}/capacity-operations/${encodeURIComponent(t)}`}function E_(e){return`${y_(e)}/scale`}function D_(e){return`/api/v1/deployments/${encodeURIComponent(e)}/update`}function O_(){return`/api/v1/deployments/models`}function k_(e,t){return ug(e,t)}function A_(){return`/api/v1/agentstudio/files`}function j_(e){return`https://${e}.cn-beijing.maas.aliyuncs.com`}function M_(e){return`/api/v1/agentstudio/sandbox${e}`}function N_(e,t){return j_(e)+M_(t)}const P_={sandboxes:`/sandboxes`,sandboxList:`/v2/sandboxes`,templates:`/templates`,templateCreate:`/v3/templates`,templateList:`/v2/templates`};function F_(e){return`${P_.sandboxes}/${encodeURIComponent(e)}`}function I_(e,t){return`${F_(e)}/${t}`}function L_(e){return`${P_.templates}/${encodeURIComponent(e)}`}function R_(e,t){return`${L_(e)}/builds/${encodeURIComponent(t)}/status`}const z_={indexList:`/api/v1/indices/rag/index/list`,indexCreateV2:`/api/v1/indices/rag/index/create_v2`,indexUpdate:`/api/v1/indices/rag/index/update`,indexDelete:`/api/v1/indices/rag/index/delete`,indexMonitor:`/api/v1/indices/rag/index/monitor`,indexFileDetails:`/api/v1/indices/rag/list/index/file/details`,indexFiles:`/api/v1/indices/rag/index/files`,indexDeleteFile:`/api/v1/indices/rag/index/delete_file`,indexJobCreate:`/api/v1/indices/rag/index/job/create`,indexJobStatus:`/api/v1/indices/rag/index_job/status`,chunkList:`/api/v1/indices/rag/index/chunklist`,chunkCreate:`/api/v1/indices/rag/index/chunk/create`,chunkUpdate:`/api/v1/indices/rag/index/chunk/update`,chunkDelete:`/api/v1/indices/rag/index/chunk/delete`,agentList:`/api/v1/indices/rag/app/list`,agentGet:`/api/v1/indices/rag/app/get`,agentCreate:`/api/v1/indices/rag/app/create`,agentUpdate:`/api/v1/indices/rag/app/update`,agentDeploy:`/api/v1/indices/rag/app/deploy`,agentDelete:`/api/v1/indices/rag/app/delete`,agentCopy:`/api/v1/indices/rag/app/copy`,applyFileUploadLease:`/api/v1/connector/dash/applyFileUploadLease`,addFile:`/api/v1/connector/dash/addFile`,addFilesFromAuthorizedOss:`/api/v1/connector/dash/addFilesFromAuthorizedOss`,batchUpdateFileTag:`/api/v1/connector/dash/batchUpdateFileTag`,listFile:`/api/v1/connector/dash/listFile`,describeFile:`/api/v1/connector/dash/describeFile`,deleteFile:`/api/v1/connector/dash/deleteFile`,addConnector:`/api/v1/connector/dash/addConnector`,getConnector:`/api/v1/connector/dash/getConnector`,listCategory:`/api/v1/connector/dash/listCategory`,addCategory:`/api/v1/connector/dash/addCategory`,deleteCategory:`/api/v1/connector/dash/deleteCategory`},B_=[`qwen-image`,`wan2.7-image`,`z-image`],V_=[`qwen-image-3.0`,`qwen-image-2.0`,`qwen-image-edit`,`wan2.7-image`,`wan2.6-image`];function H_(e,t){return t.some(t=>e.startsWith(t))}function U_(e){return H_(e,B_)||e.startsWith(`wan2.6-image`)}function W_(e){return H_(e,B_)}function G_(e){return H_(e,V_)}function K_(e){return/^wanx-v1(?:-|$)/i.test(e)}function q_(e){return e.startsWith(`wan2.6-t2i`)||e.startsWith(`wan2.6-image`)||W_(e)?!1:!!(/^wan2\.[0-5][^-]*-t2i/i.test(e)||K_(e)||/^wanx/i.test(e)&&/t2i|text2image/i.test(e))}function J_(e){return/wan2\.5-i2i/i.test(e)}function Y_(e){return/imageedit/i.test(e)}function X_(e){return e.startsWith(`qwen-image-3.0`)||e.startsWith(`qwen-image-2.0`)||e.startsWith(`qwen-image-edit`)?`qwen-image-2.0`:e.startsWith(`qwen-image`)?`qwen-image-fixed`:e.startsWith(`wan2.7-image`)?`wan27`:e.startsWith(`z-image`)?`z-image`:e.startsWith(`wan2.6-t2i`)||e.startsWith(`wan2.6-image`)||e.startsWith(`wan2.5-t2i`)?`wan26`:K_(e)?`wanx-v1`:/wan2\.5-i2i/i.test(e)?`wan25-i2i`:q_(e)?`wan-legacy`:`wan26`}function Z_(e){if(e.startsWith(`qwen-image-3.0`)||e.startsWith(`qwen-image-2.0`)||e.startsWith(`qwen-image-max`))return!0;if(e.startsWith(`z-image`))return!1}function Q_(e,t){return{...e,sizeProfile:X_(t),promptExtendDefault:Z_(t)}}function $_(e){return W_(e)?Q_({kind:`sync-multimodal`,path:Sg(),useSync:!0,inputStyle:`messages`},e):q_(e)?Q_({kind:`async-text2image`,path:Cg(),useSync:!1,inputStyle:`prompt`},e):Q_({kind:`async-image-generation`,path:xg(),useSync:!1,inputStyle:`messages`},e)}function ev(e){return G_(e)?Q_({kind:`sync-multimodal`,path:Sg(),useSync:!0,inputStyle:`messages`},e):Y_(e)?Q_({kind:`async-image2image`,path:wg(),useSync:!1,inputStyle:`function-base-image`},e):J_(e)?Q_({kind:`async-image2image`,path:wg(),useSync:!1,inputStyle:`prompt-images`},e):Q_({kind:`async-image-generation`,path:xg(),useSync:!1,inputStyle:`messages`},e)}function tv(e){return/realtime|streaming/i.test(e)}function nv(e){return/filetrans/i.test(e)}function rv(e){return/^qwen3-asr-flash-filetrans(?:-|$)/i.test(e)}const iv=[`fun-asr-flash`,`qwen-audio`];function av(e){return tv(e)||nv(e)?!1:!!(e.startsWith(iv[0])||e.startsWith(iv[1])&&/asr-flash/i.test(e))}function ov(e){return!(!/^qwen3-asr-flash(?:-|$)/i.test(e)||nv(e)||tv(e)||av(e))}function sv(e){if(tv(e))return{kind:`unsupported`,path:``,useSync:!1,unsupportedReason:`Model "${e}" is a realtime/streaming ASR model and requires a WebSocket API. Use an async filetrans model (e.g. fun-asr, qwen3-asr-flash-filetrans) or a sync flash model (e.g. qwen3-asr-flash, qwen-audio-3.0-asr-flash) with this command.`};if(nv(e)){let t=rv(e);return{kind:`async-filetrans`,path:zg(),useSync:!1,asyncInputStyle:t?`file_url`:`file_urls`,asyncLanguageStyle:t?`language`:`language_hints`}}return av(e)?{kind:`sync-flash`,path:Sg(),useSync:!0,flashFamily:`input-audio`}:ov(e)?{kind:`sync-flash`,path:Sg(),useSync:!0,flashFamily:`qwen3`}:{kind:`async-filetrans`,path:zg(),useSync:!1,asyncInputStyle:`file_urls`,asyncLanguageStyle:`language_hints`}}function cv(e){let t=/^data:audio\/([^;,]+)/i.exec(e)?.[1]?.toLowerCase();if(t)return t===`mpeg`?`mp3`:t===`x-wav`||t===`wave`?`wav`:t;let n=(e.split(/[?#]/,1)[0]??e).match(/\.([a-zA-Z0-9]+)$/)?.[1]?.toLowerCase();return n?n===`mpeg`?`mp3`:n:`wav`}function lv(e){return[{role:`user`,content:[{type:`input_text`,text:e}]}]}function uv(e,t){return t?e===`language`?{language:t}:{language_hints:[t]}:{}}function dv(e){let{model:t,audioUrl:n,language:r,vocabularyId:i,vocabulary:a,context:o,flashFamily:s}=e;if(s===`input-audio`){let e={format:cv(n),sample_rate:`16000`};r&&(e.language_hints=[r]),i&&(e.vocabulary_id=i),a&&(e.vocabulary=a);let s=[];if(o)for(let e of lv(o))s.push(e);return s.push({role:`user`,content:[{type:`input_audio`,input_audio:{data:n}}]}),{model:t,input:{messages:s},parameters:e}}let c={};r&&(c.language=r);let l={};Object.keys(c).length>0&&(l.asr_options=c);let u={model:t,input:{messages:[{role:`user`,content:[{audio:n}]}]}};return Object.keys(l).length>0&&(u.parameters=l),u}function fv(e,t){let n=e.output;if(!n)return``;if(t===`input-audio`){if(typeof n.text==`string`&&n.text.length>0)return n.text;let e=n.sentence;if(typeof e?.text==`string`&&e.text.length>0)return e.text;let t=n.output?.sentence;return typeof t?.text==`string`?t.text:``}let r=n.choices;if(!r?.length)return``;let i=[];for(let e of r){let t=e.message;if(!t)continue;let n=t.content;if(typeof n==`string`){i.push(n);continue}if(Array.isArray(n))for(let e of n){if(typeof e==`string`){i.push(e);continue}if(e&&typeof e==`object`){let t=e;typeof t.text==`string`&&i.push(t.text)}}}return i.join(``)}function pv(e){if(e.results&&e.results.length>0)return e.results;let t=e.result?.transcription_url;return typeof t==`string`&&t.length>0?[{transcription_url:t,subtask_status:`SUCCEEDED`}]:[]}const mv={12000090:`STS credentials unavailable — retry in a moment`,12000091:`Service-linked role creation failed — retry`,12000092:`Use the primary account to create the service-linked role`,12000093:`Cloud security service is unavailable — retry later`,12000094:`Alert query failed — treat as no data`},hv=new Set(Object.values(xt));function gv(e){return hv.has(e.replace(/\/+$/,``))}function _v(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}function vv(...e){for(let t of e)if(typeof t==`string`&&t.length>0)return t}function yv(e,t,n){let r=e??`unknown`,i=e===void 0&&t===void 0?`\nUnexpected response body (truncated): ${n.slice(0,800)}`:``;throw new O(`Security API failed: ${r} - ${t??`no message`}${i}`,D.GENERAL,mv[r],{rawResponse:n.slice(0,500)})}function bv(e,t){let n;try{n=JSON.parse(e)}catch{throw new O(`Security API returned non-JSON response (${t??`unknown type`}).`,D.GENERAL,void 0,{rawResponse:e.slice(0,500)})}let r=_v(n),i=r?_v(r.data):void 0,a=i?_v(i.DataV2):void 0;if(a){let t=_v(a.data),n=Array.isArray(a.ret)?a.ret.map(e=>String(e)):[],o=n.length===0||n.some(e=>e.startsWith(`SUCCESS`)),s=vv(i?.errorCode,r?.errorCode),c=vv(i?.errorMsg,r?.errorMsg)??(o?void 0:n.join(`; `));return(r?.successResponse===!1||i?.success===!1||t?.success===!1||t?.failed===!0||!o||s!==void 0)&&yv(s,c,e),(t?t.data:void 0)??null}if(r&&`success`in r)return r.success||yv(vv(r.errorCode),vv(r.errorMsg),e),r.data??null;if(r){let t=vv(i?.errorCode,r.errorCode),n=vv(i?.errorMsg,r.errorMsg);(r.successResponse===!1||i?.success===!1||t!==void 0)&&yv(t,n,e)}if(r)return r;yv(void 0,void 0,e)}async function xv(e,t){let n=await e.request({path:t,method:`GET`});return bv(await n.text(),n.headers.get(`content-type`))}function Sv(e){try{let{hostname:t}=new URL(e);return t===`aliyuncs.com`||t.endsWith(`.aliyuncs.com`)}catch{return!1}}function Cv(e){return typeof e==`string`?e:e instanceof URL?e.href:e.url}function wv(e){return async(t,n={})=>{let r=Cv(t),i=new Headers(n.headers??(t instanceof Request?t.headers:void 0));if(i.has(`user-agent`)||i.set(`User-Agent`,`${e.identity.clientName}/${e.identity.version}`),Sv(r))for(let[t,n]of Object.entries(Yn(e.identity)))i.set(t,n);Mn(e,n.method??(t instanceof Request?t.method:`GET`),r);let a=await Fn.fetch(t,{...n,headers:i});return Nn(e,a),a}}const Tv=`2024-08-16`;function Ev(e){return`bailiancontrol.${e}.aliyuncs.com`}function Dv(e){return new rg({identity:e.identity,settings:e.settings,debug:e.debug,baseUrl:e.baseUrl,openApiCred:{accessKeyId:e.accessKeyId,accessKeySecret:e.accessKeySecret,securityToken:e.securityToken,source:`flag`}})}async function Ov(e){return Dv(e).openApiJson({host:Ev(e.regionId),path:`/bailianControl/User/createUser`,action:`CreateUser`,version:Tv,method:`POST`,body:{data:JSON.stringify({reqDTO:e.reqDTO})}})}async function kv(e){return Dv(e).openApiJson({host:Ev(e.regionId),path:`/bailianControl/workspaces`,action:`ListWorkspaces`,version:Tv,method:`GET`,queryParams:{data:JSON.stringify({reqDTO:{},cornerstoneParam:{}})}})}async function Av(e){return Dv(e).openApiJson({host:Ev(e.regionId),path:`/bailianControl/serviserAuthorityPolicy/resetPolicies4Agent`,action:`ChangeUserPermissions`,version:Tv,method:`POST`,body:{data:JSON.stringify({cornerstoneParam:{},outerKey:e.outerKey,policyIndexList:e.policyIndexList??[1],agentId:e.agentId})}})}const jv={image:`TextGenerateImage`,video:`VideoGenerate`,speech:`TextGenerateSpeech`,asr:`SpeechGenerateText`},Mv={imageGen:`bailian_image_gen`,imageEdit:`bailian_image_edit`,textToVideoSubmit:`bailian_text_to_video_submit_task`,imageToVideoSubmit:`bailian_image_to_video_submit_task`,videoFetchResult:`bailian_text_to_video_fetch_result`,tts:`bailian_tts`,speechToText:`bailian_speech_to_text`};function Nv(e){let t=e.content.map(e=>e.text).filter(e=>typeof e==`string`&&e.length>0).join(`
71
+ `);if(e.isError)throw new O(`Tool error: ${t}`,D.GENERAL);if(t.length===0)throw new O(`MCP tool returned no text content.`,D.GENERAL);let n;try{n=JSON.parse(t)}catch(e){throw new O(`Failed to parse MCP tool result: ${e.message}`,D.GENERAL)}if(!n||typeof n!=`object`||Array.isArray(n))throw new O(`MCP tool returned an unexpected payload shape.`,D.GENERAL);return n}function Pv(e){return{prompt:e.prompt,...e.size===void 0?{}:{size:e.size},...e.n===void 0?{}:{n:e.n},...e.negativePrompt===void 0?{}:{negative_prompt:e.negativePrompt},...e.promptExtend===void 0?{}:{prompt_extend:e.promptExtend}}}function Fv(e){return{image_url:e.imageUrl,prompt:e.prompt,...e.negativePrompt===void 0?{}:{negative_prompt:e.negativePrompt}}}function Iv(e){return{...e.prompt===void 0?{}:{prompt:e.prompt},...e.duration===void 0?{}:{duration:e.duration},...e.resolution===void 0?{}:{resolution:e.resolution},...e.ratio===void 0?{}:{ratio:e.ratio}}}function Lv(e){return{...e.firstFrameUrl===void 0?{}:{first_frame_url:e.firstFrameUrl},...e.prompt===void 0?{}:{prompt:e.prompt},...e.duration===void 0?{}:{duration:e.duration},...e.resolution===void 0?{}:{resolution:e.resolution}}}function Rv(e){return{task_id:e}}function zv(e){return{text:e.text,...e.voice===void 0?{}:{voice:e.voice}}}function Bv(e){return{file_urls:e}}const Vv={"1:1":`1328*1328`,"3:4":`1104*1472`,"4:3":`1472*1104`,"9:16":`928*1664`,"16:9":`1664*928`};function Hv(e){let t=/^(\d+)[*xX](\d+)$/.exec(e.trim());return t?`${t[1]}*${t[2]}`:Vv[e.trim()]}const Uv=[`电商直播男`,`电商直播女`,`温柔女声`,`沉稳男声`,`英文男声`,`英文女生`,`老年女声`,`老年男声`,`童声男`,`童声女`];function Wv(e){return Uv.includes(e)}function Gv(e){if(typeof e==`string`&&e.length>0)return e;if(e&&typeof e==`object`){let t=e.url;if(typeof t==`string`&&t.length>0)return t}}function Kv(e){let t=e.results;if(!Array.isArray(t))throw new O("MCP image result is missing a `results` array.",D.GENERAL);return t.map(Gv).filter(e=>e!==void 0)}function qv(e){let t=e.result;if(typeof t!=`string`||t.length===0)throw new O(`MCP TTS result is missing an audio URL.`,D.GENERAL);let n=typeof e.request_id==`string`?e.request_id:void 0;return{audioUrl:t,...n===void 0?{}:{requestId:n}}}function Jv(e){let t=e.task_id;if(typeof t!=`string`||t.length===0)throw new O(`MCP video submit result is missing a task_id.`,D.GENERAL);return t}function Yv(e){let t=typeof e.task_status==`string`?e.task_status:`UNKNOWN`,n=typeof e.video_url==`string`&&e.video_url.length>0?e.video_url:void 0,r=typeof e.task_id==`string`?e.task_id:void 0,i=typeof e.message==`string`&&e.message.length>0?e.message:void 0,a=typeof e.code==`string`&&e.code.length>0?e.code:void 0;return{taskStatus:t,...n===void 0?{}:{videoUrl:n},...r===void 0?{}:{taskId:r},...i===void 0?{}:{message:i},...a===void 0?{}:{code:a}}}function Xv(e){let t=e.results;return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}function Zv(e){let t=e,n=!1;t.endsWith(`\r`)&&(n=!0,t=t.slice(0,-1)),t=t.replace(/\r\n/g,`
72
72
  `).replace(/\r/g,`
73
73
  `);let r=t.split(`
74
- `),i=r.pop()??``;return{lines:r,rest:n?`${i}\r`:i}}function zv(e,t,n){if(e===``)return t.data===void 0?{event:{}}:{event:{},completed:{data:t.data,event:t.event,id:t.id}};if(e.startsWith(`:`))return{event:t};let r=e.indexOf(`:`);if(r===-1)return{event:t};let i=e.slice(0,r),a=e.slice(r+1).trimStart(),o={...t};switch(i){case`data`:if(o.data=o.data===void 0?a:`${o.data}\n${a}`,o.data.length>n)throw new D(`SSE event exceeded the maximum buffer size.`,E.GENERAL);break;case`event`:o.event=a;break;case`id`:o.id=a}return{event:o}}async function*Bv(e){let t=e.body?.getReader();if(!t)return;let n=new TextDecoder,r=``,i=16777216;try{let e={};for(;;){let{done:a,value:o}=await t.read();if(a){if(r.length>0){let t=r.replace(/\r\n/g,`
74
+ `),i=r.pop()??``;return{lines:r,rest:n?`${i}\r`:i}}function Qv(e,t,n){if(e===``)return t.data===void 0?{event:{}}:{event:{},completed:{data:t.data,event:t.event,id:t.id}};if(e.startsWith(`:`))return{event:t};let r=e.indexOf(`:`);if(r===-1)return{event:t};let i=e.slice(0,r),a=e.slice(r+1).trimStart(),o={...t};switch(i){case`data`:if(o.data=o.data===void 0?a:`${o.data}\n${a}`,o.data.length>n)throw new O(`SSE event exceeded the maximum buffer size.`,D.GENERAL);break;case`event`:o.event=a;break;case`id`:o.id=a}return{event:o}}async function*$v(e){let t=e.body?.getReader();if(!t)return;let n=new TextDecoder,r=``,i=16777216;try{let e={};for(;;){let{done:a,value:o}=await t.read();if(a){if(r.length>0){let t=r.replace(/\r\n/g,`
75
75
  `).replace(/\r/g,`
76
76
  `).split(`
77
- `);r=t.pop()??``;for(let n of t){let t=zv(n,e,i);e=t.event,t.completed&&(yield t.completed)}}break}if(r+=n.decode(o,{stream:!0}),r.length>i)throw new D(`SSE stream exceeded the maximum buffer size.`,E.GENERAL);let{lines:s,rest:c}=Rv(r);r=c;for(let t of s){let n=zv(t,e,i);e=n.event,n.completed&&(yield n.completed)}}r.length>0&&(e=zv(r,e,i).event),e.data!==void 0&&(yield{data:e.data,event:e.event,id:e.id})}finally{await t.cancel().catch(()=>{}),t.releaseLock()}}function Vv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Hv=/* @__PURE__ */ new Set([`data`,`DataV2`,`success`,`successResponse`,`failed`,`code`,`errorCode`,`errorMsg`,`message`,`requestId`,`request_id`,`traceId`,`httpStatusCode`,`httpStatus`,`api`,`ret`]);function Uv(e,t=!1){return t&&(typeof e.success==`boolean`||typeof e.failed==`boolean`||Array.isArray(e.ret))||Object.hasOwn(e,`DataV2`)||typeof e.successResponse==`boolean`||Object.keys(e).every(e=>Hv.has(e))&&(Object.hasOwn(e,`data`)||Object.hasOwn(e,`errorCode`)||Array.isArray(e.ret)||typeof e.success==`boolean`||typeof e.failed==`boolean`)}function Wv(e){if(typeof e==`string`&&e.trim())return e;if(typeof e==`number`)return String(e)}function Gv(e){let t=[],n=e,r;for(;Vv(n)&&Uv(n,r!==void 0);){if(t.push(n),t.length>6)throw new D(`Invalid Console response envelope. / Console 响应信封无效。`,E.GENERAL);if(Object.hasOwn(n,`DataV2`))n=n.DataV2,r=`dataV2`;else if(Object.hasOwn(n,`data`))r=r===`dataV2`?`result`:void 0,n=n.data;else break}let i=t.flatMap(e=>Array.isArray(e.ret)?e.ret.filter(e=>typeof e==`string`&&!e.startsWith(`SUCCESS::`)):[]),a=t.filter(e=>{let t=Wv(e.errorCode);return e.success===!1||e.successResponse===!1||e.failed===!0||e.success!==!0&&e.successResponse!==!0&&t!==void 0&&t!==`0`&&t!==`200`});if(a.length>0||i.length>0){let n=[...a].reverse(),r=n.map(e=>Wv(e.errorMsg)??Wv(e.message)).find(Boolean)??(i.join(`; `)||`Console service failed without a message. / Console 服务失败,未提供错误消息。`),o=n.map(e=>Wv(e.errorCode)??(e.success===!1||e.failed===!0?Wv(e.code):void 0)).find(Boolean),s=t.map(e=>Wv(e.requestId)??Wv(e.request_id)).find(Boolean);throw new D(`${r} (${[`HTTP 200`,o?`code=${o}`:``,s?`request_id=${s}`:``].filter(Boolean).join(`; `)})`,E.GENERAL,void 0,{api:{httpStatus:200,apiCode:o,requestId:s},rawResponse:JSON.stringify(e)})}return n}const Kv=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,qv=`zeldaEasy.bmp.modelPredictRpcService.getPredictParamConfig`;function Jv(e){let t=e.data;if(!t)return e;let n=t.DataV2;if(n){let e=n.data;return e?.data??e??n}return t.data??t}async function Yv(e,t={}){let{pageNo:n=1,pageSize:r=50,name:i=``,providers:a=[],capabilities:o=[]}=t,s=Jv(await e(Kv,{input:{pageNo:n,pageSize:r,name:i,providers:a,inferenceProviders:[],features:[],group:!0,capabilities:o,contextWindows:[]}})),c=s.total??0,l=s.list??[],u=[];for(let e of l){let t=e.items;if(t?.length)for(let e of t)u.push(e);else u.push(e)}return{total:c,models:u}}async function Xv(e,t={}){let n=t.pageSize??50,r=await Yv(e,{...t,pageNo:1,pageSize:n}),i=[...r.models],a=Math.ceil(r.total/n);for(let r=2;r<=a;r++){let a=await Yv(e,{...t,pageNo:r,pageSize:n});if(a.models.length===0)break;i.push(...a.models)}return i}async function Zv(e,t){return(await Yv(e,{name:t,pageSize:50})).models.find(e=>e.model===t)??null}async function Qv(e,t={}){let{pageNo:n=1,pageSize:r=50,name:i=``,providers:a=[],capabilities:o=[],features:s=[],contextWindows:c=[],querySampleCode:l}=t,u={pageNo:n,pageSize:r,name:i,providers:a,inferenceProviders:[],features:s,group:!0,capabilities:o,contextWindows:c,queryPermissions:!0,queryApplyStatus:!0,queryActivationStatus:!0,queryPrice:!0,queryQpmInfo:!0,supports:{inference:!0}};l&&(u.querySampleCode=!0);let d=Jv(await e(Kv,{input:u}));return{total:d.total??0,groups:d.list??[]}}function $v(e){return e.flatMap(e=>e.items??[])}async function ey(e,t={}){let n=t.pageSize??50,r=await Qv(e,{...t,pageNo:1,pageSize:n}),i=Math.max(1,Math.ceil(r.total/n)),a=[];for(let e=2;e<=i;e++)a.push(e);let o=await Promise.all(a.map(r=>Qv(e,{...t,pageNo:r,pageSize:n})));return $v([r.groups,...o.map(e=>e.groups)].flat())}async function ty(e,t){return(Jv(await e(`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,{input:{pageNo:1,pageSize:50,group:!0,model:t,querySampleCode:!0,queryGroupByModel:!0,queryWorkspaceLimit:!0,queryPrice:!0,queryQuota:!1,queryQpmInfo:!0,queryApplyStatus:!0,queryPermissions:!0,queryActivationStatus:!0}})).list??[])[0]??null}const ny=[`name`,`key`,`default`,`tip`,`range`];function ry(e){return e.map(e=>{let t={};for(let n of ny)e[n]!==void 0&&(t[n]=e[n]);return t})}async function iy(e,t){let n=Jv(await e(qv,{modelId:t})).predictConfig;if(!n)return null;if(typeof n==`string`)try{let e=JSON.parse(n);return Array.isArray(e)?ry(e):null}catch{return null}return Array.isArray(n)?ry(n):null}function ay(e){return{read:()=>nn(e),async write(t){let n=nn(e);for(let[e,r]of Object.entries(t))r===void 0?delete n[e]:n[e]=e===`base_url`?ut(String(r)):r;await rn(n,e)},async unset(t){let n=nn(e);for(let e of t)delete n[e];await rn(n,e)},profiles:()=>on(),activate:e=>ln(e),validateActivation:e=>cn(e),get path(){return zt()}}}const oy=`{{commandPrefix}}`;function sy(e,t=[],n=[]){return{bin:e.commandInvocation?.bin??e.binName,path:[...e.commandInvocation?.path??[],...t],args:[...n]}}function cy(e,t=``){let n=typeof e==`string`?e:[e.commandInvocation?.bin??e.binName,...e.commandInvocation?.path??[]].join(` `);return t?`${n} ${t}`:n}function ly(e=``){return cy(oy,e)}function uy(e,t){return e.split(oy).join(cy(t))}const dy=`zeldaEasy.bmp.ossRpcService.download`;function fy(e){if(typeof e!=`string`||!/^https?:\/\//i.test(e))return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}async function py(e,t){let n=Gv(await e.console(dy,{fileKey:t}));if(typeof n!=`object`||!n||Array.isArray(n)||!(`url`in n)||!fy(n.url))throw new D(`Console file URL response must be an object with a valid HTTP(S) URL. / Console 文件地址响应必须是包含有效 HTTP(S) URL 的对象。`,E.GENERAL);return n}async function my(e,t){let{filePath:n,purpose:i=`fine-tune`,signal:a}=t,o=t.fileBlob?.size??d(n).size,s=g(n),c=t.fileBlob??await new Response(ce.toWeb(r(n))).blob(),l=new FormData;l.append(`file`,c,s),l.append(`purpose`,i);let u=await e.requestJson({path:Bg(),method:`POST`,body:l,signal:a});if(u.id)return{file_id:u.id,name:u.filename??s,size:u.bytes??o,purpose:u.purpose??i,gmt_create:u.created_at?(/* @__PURE__ */ new Date(u.created_at*1e3)).toISOString():void 0,request_id:u.request_id};let f=u.data?.failed_uploads;if(Array.isArray(f)&&f.length>0){let e=f[0]??{};throw new D(e.message??`Upload failed without a service message. / 上传失败,服务端未提供错误消息。`,E.GENERAL,void 0,{api:{httpStatus:200,apiCode:e.code,requestId:u.request_id},rawResponse:JSON.stringify(u)})}throw new D(`Upload response for ${s} has no usable file ID. / ${s} 的上传响应缺少可用文件 ID。`,E.GENERAL,`Success cannot be verified; inspect the file list before retrying. / 无法验证上传成功,请先检查文件列表,再决定是否重试。`,{api:{httpStatus:200,requestId:u.request_id},rawResponse:JSON.stringify(u)})}async function hy(e,t={}){let n=new URLSearchParams;t.pageNo!==void 0&&n.set(`page_no`,String(t.pageNo)),t.pageSize!==void 0&&n.set(`page_size`,String(t.pageSize)),t.purpose&&n.set(`purpose`,t.purpose);let r=Vg(),i=n.toString()?`${r}?${n.toString()}`:r;return e.requestJson({path:i,method:`GET`,signal:t.signal})}async function gy(e,t,n){return e.requestJson({path:Hg(t),method:`GET`,signal:n})}async function _y(e,t,n){let r=await e.request({path:Hg(t),method:`DELETE`,signal:n});try{return await r.json()}catch{return{data:{deleted:!0,file_id:t}}}}const vy=`zeldaEasy.broadscope-platform.dataset.queryByDatasetId.m_efm`,yy=`zeldaEasy.broadscope-platform.dataset.query.m_efm`,by=`zeldaEasy.broadscope-platform.datasetGroup.query.m_efm`;function xy(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Sy(e){return typeof e==`string`&&e.trim().length>0}function Cy(e,t){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=t}function wy(e={}){return{input:{datasetGroupPageNo:e.page??1,datasetGroupPageSize:e.pageSize??10,...e.name===void 0?{}:{name:e.name},datasetPageSize:1,datasetTaskTypeList:[0],datasetTaskPageSize:1}}}async function Ty(e,t={}){let n=Gv(await e.console(by,wy(t)));if(!xy(n)||!Array.isArray(n.records)||!n.records.every(e=>xy(e)&&Sy(e.datasetGroupId))||!Cy(n.page,1)||!Cy(n.itemsPerPage,1)||!Cy(n.items,0)||n.pageCount!==void 0&&!Cy(n.pageCount,0))throw new D(`Invalid Console dataset groups page: expected records with datasetGroupId and valid page/itemsPerPage/items. / Console 数据集组分页响应无效:需要包含 datasetGroupId 的 records 以及有效的 page/itemsPerPage/items。`,E.GENERAL);return n}function Ey(e){return{input:{datasetGroupId:e,datasetTaskTypeList:[0],datasetTaskPageSize:1}}}function Dy(e){let t=Array.isArray(e)?{result:e}:e;if(!xy(t)||!Array.isArray(t.result)||!t.result.every(xy))throw new D(`Console dataset version response must be an object array or contain a result array of objects. / Console 数据集版本响应必须为对象数组或包含对象数组 result。`,E.GENERAL);return t}async function Oy(e,t){let n=Dy(Gv(await e.console(yy,Ey(t))));if(!n.result.every(e=>Sy(e.datasetId)&&(e.datasetGroupId===void 0||e.datasetGroupId===t)))throw new D(`Console dataset versions have missing version IDs or belong to another dataset group. / Console 数据集版本缺少版本 ID 或属于其他数据集组。`,E.GENERAL);return n}async function ky(e,t){let n=Gv(await e.console(vy,{input:{datasetId:t}}));if(!xy(n)||![n.datasetId,n.datasetGroupId,n.datasetName].some(e=>typeof e==`string`&&e.trim()))throw new D(`Console dataset query returned no usable metadata. / Console 数据集查询未返回可用元信息。`,E.GENERAL);if(n.datasetId!==void 0&&n.datasetId!==t)throw new D(`Console dataset response does not match the requested version ID. / Console 数据集响应与请求的版本 ID 不匹配。`,E.GENERAL);return n}function Ay(e,t){return{input:{datasetId:e,datasetGroupId:t,page:1,itemsPerPage:1,datasetTaskTypeList:[0],datasetTaskPageSize:1}}}async function jy(e,t,n){let r=Dy(Gv(await e.console(yy,Ay(t,n)))).result.filter(e=>e.datasetId===t);if(r.length>1)throw new D(`Console dataset query returned multiple matches for one version ID. / Console 数据集查询为同一版本 ID 返回了多个匹配项。`,E.GENERAL);let i=r[0]??null;if(i&&i.datasetGroupId!==void 0&&i.datasetGroupId!==n)throw new D(`Console dataset version belongs to a different dataset group. / Console 数据集版本所属组与查询目标不匹配。`,E.GENERAL);return i}function My(e){let t=e&&xy(e.datasetTaskDTO)?e.datasetTaskDTO:void 0;return{release_status:e?.releaseStatus==null?`missing`:`returned`,import_status:t?.taskStatus==null?`missing`:`returned`}}const Ny=209715200,Py=314572800,Fy=314572800,Iy=2147483648;function Ly(e,t=Ny){if(!a(e))throw new D(`File not found: ${e}`,E.USAGE);let n=d(e);if(!n.isFile())throw new D(`Not a regular file: ${e}`,E.USAGE);if(n.size===0)throw new D(`File is empty: ${e}`,E.USAGE);if(n.size>t)throw new D(`File too large: ${(n.size/1048576).toFixed(1)}MB exceeds the ${(t/1048576).toFixed(0)}MB dataset upload cap.`,E.USAGE);return{bytes:n.size,ext:_(e).toLowerCase()}}function Z(e,t,n,r={}){return{severity:e,code:t,message:n,...r}}function Ry(e){if(e===void 0||e.trim()===``)return;let t=e.trim();if(t===`chatml`||t===`dpo`||t===`cpt`||t===`decision`||t===`tts`||t===`image`||t===`video`)return t;throw new D(`Unsupported --schema "${e}". Supported: chatml, dpo, cpt, decision, tts, image, video. / 不支持的 --schema;可选值:chatml、dpo、cpt、decision、tts、image、video。`,E.USAGE,`Omit --schema to auto-detect per record (state/questions → decision, chosen/rejected → DPO, text → CPT, wav_fn → TTS, img_path → image, first_frame_path/video_path → video, else ChatML). / 省略 --schema 可逐条自动识别。`)}function zy(e,t=50,n=100,r=10){if(e<=0)return[];if(e<=t+r)return Array.from({length:e},(e,t)=>t+1);let i=/* @__PURE__ */ new Set;for(let n=1;n<=Math.min(t,e);n++)i.add(n);for(let t=0;t<r;t++)i.add(e-t);let a=Math.max(1,Math.ceil(e/n));for(let n=t+1;n<=e-r;n+=a)i.add(n);return[...i].filter(t=>t>=1&&t<=e).sort((e,t)=>e-t)}const By=/* @__PURE__ */ new Set([`system`,`user`,`assistant`,`tool`]),Vy=.1;function Hy(e,t,n,r){let i=[],a=t=>{if(!(t in e))return;let a=e[t];(typeof a!=`number`||a<Vy||a>10)&&i.push(Z(`error`,`INVALID_VIDEO_FPS`,`"${t}" must be a number between ${Vy} and 10 (got ${JSON.stringify(a)}).`,{line:n,path:`${r}.${t}`}))};a(`fps`),a(`sample_fps`);let o=t?[`fps`,`video_start`,`video_end`]:[`sample_fps`],s=t?`frame-list`:`file-path`;for(let t of o)t in e&&i.push(Z(`warning`,`VIDEO_PARAM_MODE_MISMATCH`,`"${t}" does not apply to ${s} video mode and will be ignored by the platform.`,{line:n,path:`${r}.${t}`}));for(let a of[`video_start`,`video_end`])a in e&&!t&&typeof e[a]!=`number`&&i.push(Z(`error`,`INVALID_VIDEO_CLIP_TIME`,`"${a}" must be a number (seconds).`,{line:n,path:`${r}.${a}`}));return i}function Uy(e,t,n){let r=[];if(typeof e==`string`)return r;if(!Array.isArray(e))return r.push(Z(`error`,`INVALID_CONTENT`,`"content" must be a string or an array of content items (got ${typeof e}).`,{line:t,path:n})),r;if(e.length===0)return r.push(Z(`error`,`EMPTY_CONTENT_ARRAY`,`"content" array must not be empty.`,{line:t,path:n})),r;for(let i=0;i<e.length;i++){let a=e[i],o=`${n}[${i}]`;if(typeof a!=`object`||!a||Array.isArray(a)){r.push(Z(`error`,`INVALID_CONTENT_ITEM`,`Content item must be an object.`,{line:t,path:o}));continue}let s=a,c=`text`in s,l=`image`in s,u=`video`in s;if(!c&&!l&&!u){r.push(Z(`error`,`CONTENT_ITEM_NO_KNOWN_FIELD`,`Content item must contain at least one of: "text", "image", "video".`,{line:t,path:o}));continue}if(c&&typeof s.text!=`string`&&r.push(Z(`error`,`INVALID_CONTENT_TEXT`,`"text" in content item must be a string.`,{line:t,path:`${o}.text`})),l&&typeof s.image!=`string`&&r.push(Z(`error`,`INVALID_CONTENT_IMAGE`,`"image" in content item must be a string.`,{line:t,path:`${o}.image`})),u){let e=s.video;if(typeof e!=`string`&&!Array.isArray(e))r.push(Z(`error`,`INVALID_CONTENT_VIDEO`,`"video" in content item must be a string (file path) or an array of strings (frame list).`,{line:t,path:`${o}.video`}));else{if(Array.isArray(e))for(let n=0;n<e.length;n++)typeof e[n]!=`string`&&r.push(Z(`error`,`INVALID_VIDEO_FRAME`,`Video frame list item at index ${n} must be a string.`,{line:t,path:`${o}.video[${n}]`}));r.push(...Hy(s,Array.isArray(e),t,o))}}}return r}function Wy(e,t,n){let r=[];if(!Array.isArray(e))return r.push(Z(`error`,`INVALID_TOOL_CALLS`,`"tool_calls" must be an array.`,{line:t,path:n})),r;for(let i=0;i<e.length;i++){let a=e[i],o=`${n}[${i}]`;if(typeof a!=`object`||!a||Array.isArray(a)){r.push(Z(`error`,`INVALID_TOOL_CALL`,`tool_calls item must be an object.`,{line:t,path:o}));continue}let s=a;(typeof s.id!=`string`||s.id.length===0)&&r.push(Z(`error`,`TOOL_CALL_MISSING_ID`,`tool_calls item must have a non-empty "id".`,{line:t,path:`${o}.id`})),s.type!==`function`&&r.push(Z(`warning`,`TOOL_CALL_TYPE_NOT_FUNCTION`,`tool_calls item "type" should be "function" (got "${String(s.type)}").`,{line:t,path:`${o}.type`}));let c=s.function;if(typeof c!=`object`||!c||Array.isArray(c))r.push(Z(`error`,`TOOL_CALL_MISSING_FUNCTION`,`tool_calls item must have a "function" object.`,{line:t,path:`${o}.function`}));else{let e=c;(typeof e.name!=`string`||e.name.length===0)&&r.push(Z(`error`,`TOOL_CALL_FN_NO_NAME`,`tool_calls function must have a "name".`,{line:t,path:`${o}.function.name`})),typeof e.arguments!=`string`&&r.push(Z(`error`,`TOOL_CALL_FN_ARGS_NOT_STRING`,`tool_calls function "arguments" must be a JSON string.`,{line:t,path:`${o}.function.arguments`}))}}return r}function Gy(e,t,n){let r=[];if(typeof e!=`object`||!e||Array.isArray(e))return r.push(Z(`error`,`MESSAGE_NOT_OBJECT`,`Message must be an object.`,{line:t,path:n})),r;let i=e,a=i.role;return(typeof a!=`string`||!By.has(a))&&r.push(Z(`error`,`INVALID_ROLE`,`Invalid role "${String(a)}". Expected one of: system, user, assistant, tool.`,{line:t,path:`${n}.role`})),a===`tool`&&(typeof i.tool_call_id!=`string`||i.tool_call_id.length===0)&&r.push(Z(`error`,`TOOL_MISSING_CALL_ID`,`A "tool" role message must have a non-empty "tool_call_id".`,{line:t,path:`${n}.tool_call_id`})),`content`in i?r.push(...Uy(i.content,t,`${n}.content`)):(a!==`assistant`||!(`tool_calls`in i))&&r.push(Z(`error`,`MISSING_CONTENT`,`"content" field is missing.`,{line:t,path:`${n}.content`})),`tool_calls`in i&&r.push(...Wy(i.tool_calls,t,`${n}.tool_calls`)),`name`in i&&r.push(Z(`error`,`UNSUPPORTED_FIELD_NAME`,`Field "name" is not supported by Bailian and must be removed when migrating from OpenAI/Azure.`,{line:t,path:`${n}.name`})),`weight`in i&&r.push(Z(`error`,`UNSUPPORTED_FIELD_WEIGHT`,`Field "weight" is not supported by Bailian and must be removed when migrating from OpenAI/Azure. All assistant outputs are trained; per-line importance uses "loss_weight" (invite-only).`,{line:t,path:`${n}.weight`})),r}function Ky(e,t){let n=[],r=e.messages;if(!Array.isArray(r))return n.push(Z(`error`,`MISSING_MESSAGES`,`Required field "messages" is missing or not an array.`,{line:t,path:`messages`})),n;if(r.length===0)return n.push(Z(`error`,`EMPTY_MESSAGES`,`"messages" must contain at least one entry.`,{line:t,path:`messages`})),n;let i=!1,a,o=-1,s=/* @__PURE__ */ new Set,c=/* @__PURE__ */ new Set;for(let e=0;e<r.length;e++){let l=r[e],u=`messages[${e}]`;n.push(...Gy(l,t,u));let d=l,f=d?.role;if(f===`system`&&(e!==0&&n.push(Z(`warning`,`SYSTEM_NOT_FIRST`,`"system" message should appear at index 0; found at index ${e}.`,{line:t,path:`${u}.role`})),i=!0),f===`assistant`&&(o=e,d&&Array.isArray(d.tool_calls)))for(let e of d.tool_calls){let t=e;t&&typeof t.id==`string`&&s.add(t.id)}if(f===`tool`){let e=d?.tool_call_id;typeof e==`string`&&e.length>0&&c.add(e)}a===f&&(f===`user`||f===`assistant`)&&n.push(Z(`warning`,`ROLE_NOT_ALTERNATING`,`Consecutive ${f} messages — user/assistant turns should typically alternate.`,{line:t,path:`${u}.role`})),typeof f==`string`&&(a=f)}r.some(e=>e.role===`user`)||n.push(Z(`warning`,`NO_USER_ROLE`,`No "user" message found in this sample.`,{line:t,path:`messages`})),i&&r.length===1&&n.push(Z(`warning`,`SYSTEM_ONLY`,`Sample only contains a "system" message.`,{line:t,path:`messages`}));for(let e of c)s.has(e)||n.push(Z(`error`,`TOOL_CALL_ID_UNMATCHED`,`tool message references tool_call_id "${e}" which does not match any assistant tool_calls[].id.`,{line:t,path:`messages`}));for(let e of s)c.has(e)||n.push(Z(`warning`,`TOOL_CALL_NO_RESPONSE`,`assistant tool_calls[].id "${e}" has no matching tool response message.`,{line:t,path:`messages`}));if(o>=0)for(let e=0;e<r.length;e++){if(e===o)continue;let i=r[e];if(i?.role!==`assistant`||i&&Array.isArray(i.tool_calls))continue;let a=i?.content;qy(a)&&n.push(Z(`warning`,`THINK_TAG_NOT_LAST`,`Thinking tags (<think>…</think>) should only appear in the last assistant message (or an assistant message carrying tool_calls), found at messages[${e}].`,{line:t,path:`messages[${e}].content`}))}let l=(e,r)=>{(typeof e!=`number`||e<0||e>1)&&n.push(Z(`error`,`INVALID_LOSS_WEIGHT`,`"loss_weight" must be a number between 0.0 and 1.0 (got ${JSON.stringify(e)}).`,{line:t,path:r}))};`loss_weight`in e&&l(e.loss_weight,`loss_weight`);for(let e=0;e<r.length;e++){let i=r[e];i&&`loss_weight`in i&&(l(i.loss_weight,`messages[${e}].loss_weight`),(i.role!==`assistant`||e!==o)&&n.push(Z(`warning`,`LOSS_WEIGHT_PLACEMENT`,`"loss_weight" is only supported on the last assistant message; found at messages[${e}] (role "${String(i.role)}").`,{line:t,path:`messages[${e}].loss_weight`})))}return`weight`in e&&n.push(Z(`error`,`UNSUPPORTED_FIELD_WEIGHT`,`Record-level field "weight" is not supported by Bailian and must be removed when migrating from OpenAI/Azure.`,{line:t,path:`weight`})),n}function qy(e){return typeof e==`string`?e.includes(`<think>`):Array.isArray(e)?e.some(e=>e&&typeof e==`object`&&`text`in e?typeof e.text==`string`&&e.text.includes(`<think>`):!1):!1}const Jy={name:`chatml`,detect:()=>!0,inspect:Ky};function Yy(e,t){let n=[];if(!(`text`in e))return n.push(Z(`error`,`MISSING_TEXT`,`Required field "text" is missing.`,{line:t,path:`text`})),n;let r=e.text;return typeof r==`string`?(r.trim().length===0&&n.push(Z(`error`,`EMPTY_TEXT`,`"text" must not be empty / whitespace-only.`,{line:t,path:`text`})),n):(n.push(Z(`error`,`INVALID_TEXT`,`"text" must be a string (got ${typeof r}).`,{line:t,path:`text`})),n)}const Xy={name:`cpt`,detect:e=>`text`in e&&!(`messages`in e),inspect:Yy};function Zy(e,t){let n=Ky(e,t),r=e.messages;if(!Array.isArray(r)||r.length===0)return n;let i=(e,n)=>{if(!Array.isArray(e))return[];let r=[];for(let i=0;i<e.length;i++){let a=e[i];if(a&&typeof a==`object`)for(let e of[`image`,`video`])e in a&&r.push(Z(`error`,`DPO_UNSUPPORTED_ELEMENT`,`DPO training data does not support ${e} inputs; found at ${n}.content[${i}].`,{line:t,path:`${n}.content[${i}].${e}`}))}return r};`tools`in e&&n.push(Z(`error`,`DPO_UNSUPPORTED_ELEMENT`,`DPO training data does not support tool calling; remove the "tools" definition.`,{line:t,path:`tools`}));for(let e=0;e<r.length;e++){let a=r[e];if(!a)continue;let o=`messages[${e}]`;(a.role===`tool`||`tool_calls`in a)&&n.push(Z(`error`,`DPO_UNSUPPORTED_ELEMENT`,`DPO training data does not support tool calling; found ${a.role===`tool`?`role "tool"`:`"tool_calls"`} at ${o}.`,{line:t,path:o})),n.push(...i(a.content,o))}let a=r[r.length-1];a&&a.role!==`user`&&n.push(Z(`error`,`DPO_LAST_MSG_NOT_USER`,`DPO "messages" must end with a "user" message (the prompt for chosen/rejected). Got "${String(a.role)}" as the last message.`,{line:t,path:`messages[${r.length-1}].role`}));let o=`chosen`in e,s=`rejected`in e;if(o||n.push(Z(`error`,`MISSING_CHOSEN`,`DPO record is missing the "chosen" preference.`,{line:t,path:`chosen`})),s||n.push(Z(`error`,`MISSING_REJECTED`,`DPO record is missing the "rejected" preference.`,{line:t,path:`rejected`})),o){n.push(...Gy(e.chosen,t,`chosen`)),n.push(...i(e.chosen?.content,`chosen`));let r=e.chosen?.role;typeof r==`string`&&r!==`assistant`&&n.push(Z(`warning`,`PREFERENCE_ROLE_NOT_ASSISTANT`,`"chosen" role should be "assistant" (got "${r}").`,{line:t,path:`chosen.role`}))}if(s){n.push(...Gy(e.rejected,t,`rejected`)),n.push(...i(e.rejected?.content,`rejected`));let r=e.rejected?.role;typeof r==`string`&&r!==`assistant`&&n.push(Z(`warning`,`PREFERENCE_ROLE_NOT_ASSISTANT`,`"rejected" role should be "assistant" (got "${r}").`,{line:t,path:`rejected.role`}))}return n}const Qy={name:`dpo`,detect:e=>`chosen`in e||`rejected`in e,inspect:Zy},$y=[`choice`,`noul`,`score`],eb=255,tb=2,nb=255,rb=/* @__PURE__ */ new Set([`true`,`false`]);function ib(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ab(e){return typeof e==`string`&&e.trim().length>0}function ob(e,t,n,r){return{code:e,path:t,message:{"en-US":n,"zh-CN":r}}}function sb(e,t=`state`){return ab(e)||Array.isArray(e)&&e.length>0||ib(e)&&Object.keys(e).length>0?[]:[ob(`DECISION_INVALID_STATE`,t,`"${t}" must be a non-empty string, object, or array.`,`"${t}" 必须是非空字符串、对象或数组。`)]}function cb(e,t){let n=`${t}.criteria`;if(!ib(e))return[ob(`DECISION_INVALID_CHOICE_CRITERIA`,n,`"${n}" must be an option-to-description object.`,`"${n}" 必须是“选项名到描述”的对象。`)];let r=Object.keys(e).length;if(r<1||r>255)return[ob(`DECISION_INVALID_CHOICE_CRITERIA`,n,`"${n}" must contain 1-255 options (got ${r}).`,`"${n}" 必须包含 1-255 个选项(当前 ${r} 个)。`)];for(let[t,r]of Object.entries(e))if(!ab(t)||!ab(r))return[ob(`DECISION_INVALID_CHOICE_CRITERIA`,`${n}.${t}`,`Choice option names and descriptions in "${n}" must be non-empty strings.`,`"${n}" 中的选项名和描述必须是非空字符串。`)];return[]}function lb(e,t){let n=`${t}.criteria`;return!Array.isArray(e)||e.some(e=>!ab(e))?[ob(`DECISION_INVALID_SCORE_CRITERIA`,n,`"${n}" must be an array of non-empty level descriptions, from low to high.`,`"${n}" 必须是从低到高排列、由非空等级描述组成的数组。`)]:e.length<2||e.length>255?[ob(`DECISION_INVALID_SCORE_CRITERIA`,n,`"${n}" must contain 2-255 levels (got ${e.length}).`,`"${n}" 必须包含 2-255 个等级(当前 ${e.length} 个)。`)]:[]}function ub(e,t){if(e===void 0)return[];let n=`${t}.criteria`;return ib(e)&&Object.entries(e).every(([e,t])=>rb.has(e)&&typeof t==`string`)?[]:[ob(`DECISION_INVALID_NOUL_CRITERIA`,n,`"${n}" is optional; when provided it must be an object with only "true" / "false" string descriptions.`,`"${n}" 为可选项;填写时必须是只包含 "true" / "false" 字符串描述的对象。`)]}function db(e,t){if(!ib(e))return[ob(`DECISION_QUESTION_NOT_OBJECT`,t,`"${t}" must be an object.`,`"${t}" 必须是对象。`)];let n=[];return e.instructions!==void 0&&typeof e.instructions!=`string`&&n.push(ob(`DECISION_INVALID_INSTRUCTIONS`,`${t}.instructions`,`"${t}.instructions" must be a string when provided.`,`"${t}.instructions" 填写时必须是字符串。`)),e.type===`choice`?n.push(...cb(e.criteria,t)):e.type===`noul`?n.push(...ub(e.criteria,t)):e.type===`score`?n.push(...lb(e.criteria,t)):n.push(ob(`DECISION_INVALID_QUESTION_TYPE`,`${t}.type`,`"${t}.type" must be choice, noul, or score.`,`"${t}.type" 必须是 choice、noul 或 score。`)),n}function fb(e,t=`questions`){return ib(e)&&Object.keys(e).length>0?[]:[ob(`DECISION_INVALID_QUESTIONS`,t,`"${t}" must be a non-empty object keyed by question ID.`,`"${t}" 必须是以问题 ID 为键的非空对象。`)]}function pb(e,t=`questions`){return ab(e)?[]:[ob(`DECISION_INVALID_QUESTION_ID`,t,`Question IDs must be non-empty strings.`,`问题 ID 必须是非空字符串。`)]}function mb(e,t=`questions`){let n=fb(e,t);if(n.length>0)return n;let r=[];for(let[n,i]of Object.entries(e)){let e=pb(n,t);if(e.length>0){r.push(...e);continue}r.push(...db(i,`${t}.${n}`))}return r}function hb(e,t,n,r){return Z(`error`,e,t,{line:n,path:r})}function gb(e,t){return hb(e.code,`${e.message[`en-US`]} / ${e.message[`zh-CN`]}`,t,e.path)}function _b(e,t,n,r){if(!ib(e))return[hb(`DECISION_INVALID_TARGET`,`"${r}" must be an object containing a complete probability distribution. / "${r}" 必须是包含完整概率分布的对象。`,n,r)];let i=Object.keys(e).sort(),a=[...t].sort();if(i.length!==a.length||i.some((e,t)=>e!==a[t]))return[hb(`DECISION_INVALID_TARGET_KEYS`,`"${r}" must contain exactly these keys: ${a.join(`, `)}. / "${r}" 必须且只能包含这些键:${a.join(`, `)}。`,n,r)];let o=0;for(let t of a){let i=e[t];if(typeof i!=`number`||!Number.isFinite(i)||i<0||i>1)return[hb(`DECISION_INVALID_TARGET_PROBABILITY`,`"${r}.${t}" must be a finite number in [0, 1]. / "${r}.${t}" 必须是 [0, 1] 范围内的有限数字。`,n,`${r}.${t}`)];o+=i}return Math.abs(o-1)>1e-6?[hb(`DECISION_TARGET_SUM_NOT_ONE`,`Probabilities in "${r}" must sum to 1 (got ${o}). / "${r}" 中的概率之和必须为 1(当前为 ${o})。`,n,r)]:[]}function vb(e,t,n){let r=Object.keys(e.criteria);return typeof e.label!=`string`||!r.includes(e.label)?[hb(`DECISION_INVALID_CHOICE_LABEL`,`"${n}.label" must be one of: ${r.join(`, `)}. / "${n}.label" 必须是以下选项之一:${r.join(`, `)}。`,t,`${n}.label`)]:e.target===void 0?[]:_b(e.target,r,t,`${n}.target`)}function yb(e,t,n){return typeof e.label==`boolean`?e.target===void 0?[]:_b(e.target,[`true`,`false`],t,`${n}.target`):[hb(`DECISION_INVALID_NOUL_LABEL`,`"${n}.label" must be true or false. / "${n}.label" 必须是 true 或 false。`,t,`${n}.label`)]}function bb(e,t,n){let r=e.criteria.length;if(typeof e.label!=`number`||!Number.isInteger(e.label)||e.label<0||e.label>=r)return[hb(`DECISION_INVALID_SCORE_LABEL`,`"${n}.label" must be an integer from 0 to ${r-1}. / "${n}.label" 必须是 0 到 ${r-1} 之间的整数。`,t,`${n}.label`)];let i=Array.from({length:r},(e,t)=>String(t));return e.target===void 0?[]:_b(e.target,i,t,`${n}.target`)}function xb(e,t){let n=sb(e.state).map(e=>gb(e,t)),r=e.questions,i=fb(r);if(i.length>0)return n.push(...i.map(e=>gb(e,t))),n;for(let[e,i]of Object.entries(r)){let r=pb(e);if(r.length>0){n.push(...r.map(e=>gb(e,t)));continue}let a=`questions.${e}`,o=db(i,a);if(o.length>0){n.push(...o.map(e=>gb(e,t)));continue}let s=i;s.type===`choice`?n.push(...vb(s,t,a)):s.type===`noul`?n.push(...yb(s,t,a)):n.push(...bb(s,t,a))}return n}const Sb={name:`decision`,detect:e=>!(`messages`in e)&&(`questions`in e||`state`in e),inspect:xb};function Cb(e,t){let n=[];if(!(`wav_fn`in e))n.push(Z(`error`,`MISSING_WAV_FN`,`Required field "wav_fn" is missing.`,{line:t,path:`wav_fn`}));else{let r=e.wav_fn;if(typeof r!=`string`)n.push(Z(`error`,`INVALID_WAV_FN`,`"wav_fn" must be a string (got ${typeof r}).`,{line:t,path:`wav_fn`}));else if(r.trim().length===0)n.push(Z(`error`,`EMPTY_WAV_FN`,`"wav_fn" must not be empty.`,{line:t,path:`wav_fn`}));else{r.startsWith(`train/`)||n.push(Z(`error`,`WAV_FN_PREFIX`,`"wav_fn" must start with "train/" (got "${r}").`,{line:t,path:`wav_fn`}));let e=r.lastIndexOf(`.`),i=e>=0?r.slice(e).toLowerCase():``;i!==`.wav`&&n.push(Z(`error`,`INVALID_AUDIO_EXT`,`"wav_fn" must reference a .wav file (got "${i||`(none)`}"). CosyVoice training audio must be WAV.`,{line:t,path:`wav_fn`}))}}if(!(`text`in e))n.push(Z(`error`,`MISSING_TEXT`,`Required field "text" is missing.`,{line:t,path:`text`}));else{let r=e.text;typeof r==`string`?r.trim().length===0&&n.push(Z(`error`,`EMPTY_TEXT`,`"text" must not be empty / whitespace-only.`,{line:t,path:`text`})):n.push(Z(`error`,`INVALID_TEXT`,`"text" must be a string (got ${typeof r}).`,{line:t,path:`text`}))}return n}const wb={name:`tts`,detect:e=>`wav_fn`in e,inspect:Cb},Tb=/* @__PURE__ */ new Set([`.png`,`.jpg`,`.jpeg`,`.bmp`,`.tif`,`.tiff`,`.webp`]);function Eb(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t).toLowerCase():``}function Db(e){return/^[\x20-\x7E]+$/.test(e)}function Ob(e,t){let n=[];if(!(`prompt`in e))n.push(Z(`error`,`MISSING_PROMPT`,`Required field "prompt" is missing.`,{line:t,path:`prompt`}));else{let r=e.prompt;typeof r==`string`?r.trim().length===0&&n.push(Z(`error`,`EMPTY_PROMPT`,`"prompt" must not be empty / whitespace-only.`,{line:t,path:`prompt`})):n.push(Z(`error`,`INVALID_PROMPT`,`"prompt" must be a string (got ${typeof r}).`,{line:t,path:`prompt`}))}if(!(`img_path`in e))n.push(Z(`error`,`MISSING_IMG_PATH`,`Required field "img_path" is missing.`,{line:t,path:`img_path`}));else{let r=e.img_path;if(typeof r!=`string`)n.push(Z(`error`,`INVALID_IMG_PATH`,`"img_path" must be a string (got ${typeof r}).`,{line:t,path:`img_path`}));else if(r.trim().length===0)n.push(Z(`error`,`EMPTY_IMG_PATH`,`"img_path" must not be empty.`,{line:t,path:`img_path`}));else{let e=Eb(r);Tb.has(e)||n.push(Z(`warning`,`UNUSUAL_IMAGE_EXT`,`"img_path" points to a non-standard image extension "${e||`(none)`}". Expected one of: ${[...Tb].join(`, `)}.`,{line:t,path:`img_path`})),Db(r)||n.push(Z(`error`,`NON_ASCII_IMG_PATH`,`"img_path" must contain only ASCII characters (English filenames required). Got: "${r}".`,{line:t,path:`img_path`}))}}if(`input_img`in e){let r=e.input_img;if(typeof r!=`string`)n.push(Z(`error`,`INVALID_INPUT_IMG`,`"input_img" must be a string (got ${typeof r}).`,{line:t,path:`input_img`}));else if(r.trim().length===0)n.push(Z(`error`,`EMPTY_INPUT_IMG`,`"input_img" must not be empty.`,{line:t,path:`input_img`}));else{let e=Eb(r);Tb.has(e)||n.push(Z(`warning`,`UNUSUAL_INPUT_IMG_EXT`,`"input_img" points to a non-standard image extension "${e||`(none)`}". Expected one of: ${[...Tb].join(`, `)}.`,{line:t,path:`input_img`})),Db(r)||n.push(Z(`error`,`NON_ASCII_INPUT_IMG`,`"input_img" must contain only ASCII characters (English filenames required). Got: "${r}".`,{line:t,path:`input_img`}))}}return n}const kb={name:`image`,detect:e=>`img_path`in e,inspect:Ob},Ab=/* @__PURE__ */ new Set([`.png`,`.jpg`,`.jpeg`,`.bmp`,`.webp`]),jb=/* @__PURE__ */ new Set([`.mp4`,`.mov`]);function Mb(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t).toLowerCase():``}function Nb(e){return/^[\x20-\x7E]+$/.test(e)}function Pb(e,t,n,r,i,a){if(!(n in t)){r&&e.push(Z(`error`,`MISSING_FIELD`,`Required field "${n}" is missing.`,{line:a,path:n}));return}let o=t[n];if(typeof o!=`string`){e.push(Z(`error`,`INVALID_FIELD`,`"${n}" must be a string (got ${typeof o}).`,{line:a,path:n}));return}if(o.trim().length===0){e.push(Z(`error`,`EMPTY_FIELD`,`"${n}" must not be empty.`,{line:a,path:n}));return}let s=Mb(o);i.has(s)||e.push(Z(`warning`,`UNUSUAL_MEDIA_EXT`,`"${n}" points to a non-standard extension "${s||`(none)`}". Expected one of: ${[...i].join(`, `)}.`,{line:a,path:n})),Nb(o)||e.push(Z(`error`,`NON_ASCII_PATH`,`"${n}" must contain only ASCII characters (English filenames required). Got: "${o}".`,{line:a,path:n}))}function Fb(e,t){let n=[];if(!(`prompt`in e))n.push(Z(`error`,`MISSING_PROMPT`,`Required field "prompt" is missing.`,{line:t,path:`prompt`}));else{let r=e.prompt;typeof r==`string`?r.trim().length===0&&n.push(Z(`error`,`EMPTY_PROMPT`,`"prompt" must not be empty / whitespace-only.`,{line:t,path:`prompt`})):n.push(Z(`error`,`INVALID_PROMPT`,`"prompt" must be a string (got ${typeof r}).`,{line:t,path:`prompt`}))}return Pb(n,e,`first_frame_path`,!0,Ab,t),Pb(n,e,`last_frame_path`,!1,Ab,t),Pb(n,e,`video_path`,!1,jb,t),n}const Ib=[wb,kb,{name:`video`,detect:e=>`first_frame_path`in e||`video_path`in e,inspect:Fb},Sb,Qy,Xy,Jy];function Lb(e,t){return t===void 0?Ib.find(t=>t.detect(e))??Jy:Ib.find(e=>e.name===t)||Jy}async function Rb(e,t){let n=r(e,{encoding:`utf8`}),i=le({input:n,crlfDelay:1/0}),a=[],o=0,s=0;for await(let e of i){if(t?.aborted)break;o++;let n=e.trim();if(n.length===0){s++;continue}a.length>=20||(n[0]!==`{`||n[n.length-1]!==`}`)&&a.push(Z(`error`,`MALFORMED_LINE`,`Line does not start with '{' and end with '}'. JSONL requires one minified JSON object per line — pretty-printed JSON or arrays are not accepted here.`,{line:o}))}return{totalLines:o,blankLines:s,issues:a}}async function zb(e,t,n,i,a){let o=n?null:new Set(zy(t)),s=[],c=0,l=r(e,{encoding:`utf8`}),u=le({input:l,crlfDelay:1/0}),d=0;for await(let e of u){if(a?.aborted)break;if(d++,o&&!o.has(d))continue;let t=e.trim();if(t.length===0||(c++,s.length>=30))continue;let n;try{n=JSON.parse(t)}catch(e){s.push(Z(`error`,`MALFORMED_JSON`,`JSON.parse failed: ${e.message}`,{line:d}));continue}s.push(...Bb(n,d,i))}return{sampled:c,issues:s}}function Bb(e,t,n){if(typeof e!=`object`||!e||Array.isArray(e))return[Z(`error`,`RECORD_NOT_OBJECT`,`Each line must be a JSON object, got ${Array.isArray(e)?`array`:typeof e}.`,{line:t})];let r=e;return Lb(r,n).inspect(r,t)}const Vb={format:`jsonl`,extensions:[`.jsonl`],async validate(e,t){let n=Date.now(),r=await Rb(e,t.signal);if(r.totalLines===0||r.totalLines===r.blankLines)return{valid:!1,format:`jsonl`,filePath:e,errors:[Z(`error`,`EMPTY_FILE`,`File contains no non-blank lines.`)],warnings:[],stats:{totalRecords:0,sampledRecords:0,durationMs:Date.now()-n}};if(r.issues.length>0)return{valid:!1,format:`jsonl`,filePath:e,errors:r.issues,warnings:[],stats:{totalRecords:r.totalLines-r.blankLines,sampledRecords:0,durationMs:Date.now()-n}};let i=await zb(e,r.totalLines,!!t.fullValidate,t.schema,t.signal),a=i.issues.filter(e=>e.severity===`error`),o=i.issues.filter(e=>e.severity===`warning`);return{valid:a.length===0,format:`jsonl`,filePath:e,errors:a,warnings:o,stats:{totalRecords:r.totalLines-r.blankLines,sampledRecords:i.sampled,durationMs:Date.now()-n}}}};function Hb(e,t){return new Promise((n,r)=>{de.open(e,{lazyEntries:!0},(e,i)=>{if(e||!i){r(/* @__PURE__ */ Error(`Failed to open ZIP: ${e?.message??`unknown error`}`));return}i.readEntry(),i.on(`entry`,e=>{let r=e.fileName.replace(/\\/g,`/`);r===t||r.endsWith(`/${t}`)?n({entry:e,zipfile:i}):i.readEntry()}),i.on(`end`,()=>{i.close(),r(/* @__PURE__ */ Error(`Entry "${t}" not found in ZIP`))}),i.on(`error`,r)})})}function Ub(e){return new Promise((t,n)=>{de.open(e,{lazyEntries:!0},(e,r)=>{if(e||!r){n(/* @__PURE__ */ Error(`Failed to open ZIP: ${e?.message??`unknown error`}`));return}let i=[];r.readEntry(),r.on(`entry`,e=>{i.push(e.fileName.replace(/\\/g,`/`)),r.readEntry()}),r.on(`end`,()=>{r.close(),t(i)}),r.on(`error`,n)})})}const Wb=/^[a-zA-Z0-9_-]+$/;function Gb(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(0,t):e}function Kb(e){if(e===`__MACOSX`||e.startsWith(`__MACOSX/`))return!0;let t=e.split(`/`).filter(e=>e.length>0).pop()??``;return t===`.DS_Store`||t.startsWith(`._`)}function qb(e){let t=[],n=/* @__PURE__ */ new Map;for(let r of e){if(r.endsWith(`/`)||Kb(r))continue;let e=r.split(`/`).filter(e=>e.length>0);for(let n of e){let e=Gb(n),i=n.slice(e.length);e.length>0&&!Wb.test(e)&&t.length<10&&t.push(Z(`error`,`INVALID_FILENAME_CHARSET`,`File/folder name "${n}" contains invalid characters. Only a-z, A-Z, 0-9, underscore (_), and hyphen (-) are allowed.`,{path:r})),i.length>0&&!/^\.[a-zA-Z0-9]+$/.test(i)&&t.length<10&&t.push(Z(`error`,`INVALID_FILENAME_CHARSET`,`File extension "${i}" in "${n}" contains invalid characters.`,{path:r}))}let i=e[e.length-1]??``,a=Gb(i);if(a.length>120&&t.length<10&&t.push(Z(`error`,`FILENAME_TOO_LONG`,`Filename "${i}" (without extension) exceeds 120 characters (got ${a.length}). Shorten the name and re-upload.`,{path:r})),a.length>0){let e=n.get(a);e===void 0?n.set(a,r):t.length<10&&t.push(Z(`error`,`DUPLICATE_FILENAME`,`Filename "${i}" conflicts with "${e}" — names must be globally unique (ignoring extension) even across different folders.`,{path:r}))}}return t.length>=10&&t.push(Z(`warning`,`FILENAME_ISSUES_TRUNCATED`,`More filename issues exist but reporting is capped at 10.`)),t}async function Jb(e,t,n){let{entry:r,zipfile:a}=await Hb(e,t);return new Promise((e,t)=>{a.openReadStream(r,(r,o)=>{if(r||!o){a.close(),t(r??/* @__PURE__ */ Error(`Failed to open entry stream`));return}let s=i(n);ue(o,s).then(()=>{a.close(),e()}).catch(e=>{a.close(),t(e)})})})}async function Yb(e,t=100){let n=r(e,{encoding:`utf8`}),i=le({input:n,crlfDelay:1/0}),a=[],o=0;for await(let e of i){if(o++,a.length>=t)continue;let n=e.trim();if(n.length!==0)try{let e=JSON.parse(n);typeof e.wav_fn==`string`&&a.push(e.wav_fn),typeof e.img_path==`string`&&a.push(e.img_path),typeof e.input_img==`string`&&a.push(e.input_img),typeof e.first_frame_path==`string`&&a.push(e.first_frame_path),typeof e.last_frame_path==`string`&&a.push(e.last_frame_path),typeof e.video_path==`string`&&a.push(e.video_path),typeof e.image_fn==`string`&&a.push(e.image_fn),typeof e.video_fn==`string`&&a.push(e.video_fn)}catch{}}return{refs:a,totalLines:o}}const Xb={format:`zip`,extensions:[`.zip`],async validate(e,t){let n=Date.now(),r=[],i=[],a;try{a=await Ub(e)}catch(t){return{valid:!1,format:`zip`,filePath:e,errors:[Z(`error`,`ZIP_OPEN_FAILED`,`Could not open ZIP archive: ${t.message}`)],warnings:[],stats:{durationMs:Date.now()-n}}}if(a.length===0)return{valid:!1,format:`zip`,filePath:e,errors:[Z(`error`,`ZIP_EMPTY`,`ZIP archive contains no entries.`)],warnings:[],stats:{durationMs:Date.now()-n}};let s=a.some(e=>e===`data.jsonl`),c=!s&&a.find(e=>e.endsWith(`/data.jsonl`));s||(c?r.push(Z(`error`,`DATA_JSONL_NOT_AT_ROOT`,`"data.jsonl" must be at the ZIP root (found "${c}"). Re-package so that opening the ZIP shows data.jsonl directly, without a wrapping folder.`)):r.push(Z(`error`,`MISSING_DATA_JSONL`,`ZIP archive must contain "data.jsonl" at the root. This file maps media files (e.g. .wav, .jpg) to their labels.`)));let l=qb(a);for(let e of l)e.severity===`error`?r.push(e):i.push(e);let d=t.schema===`image`,f=t.schema===`video`,p=a.some(e=>e===`train/`||e.startsWith(`train/`)),m=a.some(e=>e.toLowerCase().endsWith(`.wav`));if(!p&&!d&&!f&&m&&i.push(Z(`warning`,`NO_TRAIN_DIR`,`No "train/" directory found in the ZIP. Media files are typically placed under "train/" and referenced as "train/xxx.wav" in data.jsonl.`)),d){let e=a.filter(e=>{if(e===`data.jsonl`||e.endsWith(`/data.jsonl`)||e.endsWith(`/`)||Kb(e))return!1;let t=e.lastIndexOf(`.`),n=t>=0?e.slice(t).toLowerCase():``;return Tb.has(n)});e.length<25&&r.push(Z(`error`,`INSUFFICIENT_IMAGES`,`Found ${e.length} image(s) in ZIP, but image generation fine-tuning requires at least 25 images (50+ recommended).`))}if(!s&&!c)return{valid:!1,format:`zip`,filePath:e,errors:r,warnings:i,stats:{totalRecords:a.length,durationMs:Date.now()-n}};let g=s?`data.jsonl`:a.find(e=>e.endsWith(`/data.jsonl`)),_=v(h(),`bl-zip-${oe(6).toString(`hex`)}`);o(_,{recursive:!0});let y=v(_,`data.jsonl`);try{await Jb(e,g,y)}catch(t){return r.push(Z(`error`,`EXTRACT_FAILED`,`Failed to extract "data.jsonl" from ZIP: ${t.message}`)),u(_,{recursive:!0,force:!0}),{valid:!1,format:`zip`,filePath:e,errors:r,warnings:i,stats:{durationMs:Date.now()-n}}}let ee=await Vb.validate(y,t);if(r.push(...ee.errors),i.push(...ee.warnings),ee.valid){let{refs:e}=await Yb(y),t=new Set(a),n=g.lastIndexOf(`/`),i=n>=0?g.slice(0,n+1):``,o=[];for(let n of e){let e=n.replace(/^\.\//,``);t.has(e)||t.has(i+e)||o.push(n)}if(o.length>0){let e=o.slice(0,5).join(`, `),t=o.length>5?` (and ${o.length-5} more)`:``;r.push(Z(`error`,`DANGLING_MEDIA_REFS`,`${o.length} media file(s) referenced in data.jsonl not found in ZIP: ${e}${t}`))}}return u(_,{recursive:!0,force:!0}),{valid:r.length===0,format:`zip`,filePath:e,errors:r,warnings:i,stats:{totalRecords:ee.stats.totalRecords??a.length,sampledRecords:ee.stats.sampledRecords,durationMs:Date.now()-n}}}};async function Zb(e){let t=_(e).toLowerCase();if(t===`.jsonl`)return Qb(e);if(t===`.zip`)return $b(e);throw new D(`Cannot inspect file with extension "${t}". Expected .jsonl or .zip.`,E.USAGE)}async function Qb(e){let t=await tx(e);if(!t)throw new D(`JSONL file is empty or contains only blank lines: ${e}`,E.USAGE);let n=ex(t);return n===`unknown`?`text`:n}async function $b(e){let t=await nx(e,`data.jsonl`);if(!t)throw new D(`ZIP archive does not contain "data.jsonl" or it is empty: ${e}`,E.USAGE,`Audio training data must be a ZIP with data.jsonl at the root and a train/ subfolder.`);let n=ex(t);if(n===`unknown`)throw new D(`ZIP data.jsonl does not match any supported media format (expected wav_fn / img_path / first_frame_path / video_path): ${e}`,E.USAGE,`ZIP archives are for audio/image/video training data. For text data, use a .jsonl file instead.`);return n}function ex(e){let t;try{t=JSON.parse(e)}catch{throw new D(`Failed to parse first JSON record for modality detection: ${e.slice(0,120)}`,E.USAGE)}if(typeof t!=`object`||!t||Array.isArray(t))throw new D(`Expected a JSON object as the first record, got ${Array.isArray(t)?`array`:typeof t}.`,E.USAGE);return`wav_fn`in t?`audio`:`img_path`in t?`input_img`in t?`image-i2i`:`image`:`first_frame_path`in t||`video_path`in t?`last_frame_path`in t?`video-kf2v`:`video`:`unknown`}function tx(e){return new Promise((t,n)=>{let i=r(e,{encoding:`utf8`}),a=le({input:i,crlfDelay:1/0}),o=!1;a.on(`line`,e=>{if(o)return;let n=e.trim();n.length!==0&&(o=!0,a.close(),i.destroy(),t(n))}),a.on(`close`,()=>{o||t(null)}),a.on(`error`,n),i.on(`error`,n)})}function nx(e,t){return Hb(e,t).then(({entry:e,zipfile:n})=>new Promise((r,i)=>{n.openReadStream(e,(e,a)=>{if(e||!a){n.close(),i(new D(`Failed to read "${t}" from ZIP: ${e?.message}`,E.USAGE));return}let o=le({input:a,crlfDelay:1/0}),s=!1;o.on(`line`,e=>{if(s)return;let t=e.trim();t.length!==0&&(s=!0,o.close(),a.destroy(),n.close(),r(t))}),o.on(`close`,()=>{s||(n.close(),r(null))}),o.on(`error`,e=>{n.close(),i(e)})})})).catch(e=>{if(e instanceof Error&&e.message.includes(`not found in ZIP`))return null;throw e})}const rx=[Vb,Xb];function ix(e){let t=_(e).toLowerCase(),n=rx.find(e=>e.extensions.includes(t));if(!n){let e=rx.flatMap(e=>e.extensions).join(`, `);throw new D(`Unsupported dataset format "${t||`(none)`}". Supported: ${e}`,E.USAGE,`Convert your data to one of the supported formats and re-run.`)}return n}function ax(e){rx.some(t=>t.format===e.format)||rx.push(e)}async function ox(e,t={}){let{bytes:n}=Ly(e,t.maxBytes??209715200),r=await ix(e).validate(e,t);return r.stats.bytes===void 0&&(r.stats.bytes=n),r}function sx(){return rx.map(e=>({format:e.format,extensions:[...e.extensions]}))}function cx(e){let t=[];e.line!==void 0&&t.push(`line ${e.line}`),e.path&&t.push(e.path);let n=t.length?` [${t.join(` · `)}]`:``;return` ${e.severity.toUpperCase()} ${e.code}${n}: ${e.message}`}const lx=[`/v1/chat/completions`,`/v1/embeddings`,`/v1/chat/ds-test`],ux=[`validating`,`in_progress`,`finalizing`,`completed`,`failed`,`expired`,`cancelling`,`cancelled`],dx=/* @__PURE__ */ new Set([`completed`,`failed`,`expired`,`cancelled`]),fx=524288e3,px=6291456,mx=5e4;function Q(e,t){throw new ot(`${e}\n${t}`)}function hx(e){if(e instanceof D)return e;let t=e?.code;return new D(`Batch file I/O failed${t?` (${t})`:``}.\nBatch 文件读写失败${t?`(${t})`:``}。`,E.GENERAL,t===`ENOENT`?`Check the file and parent directory paths. / 请检查文件及父目录路径。`:t===`EEXIST`?`Output exists; use --force to replace it. / 输出已存在,使用 --force 覆盖。`:`Check file permissions and available disk space. / 请检查文件权限与磁盘空间。`,{cause:e})}function gx(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function _x(e){return lx.includes(e)||Q(`Unsupported Batch endpoint: ${e}`,`不支持的 Batch endpoint:${e}`),e}async function*vx(e){let t=typeof e==`string`?me(e):e instanceof Blob?Ee.fromWeb(e.stream()):e;try{for await(let e of t)yield e}catch(e){throw hx(e)}}async function*yx(e,t=1/0,n=px){let r=Buffer.alloc(0),i=0,a=new TextDecoder(`utf-8`,{fatal:!0}),o=e=>{try{return a.decode(e)}catch{return Q(`Invalid UTF-8 input.`,`输入不是有效 UTF-8。`)}};for await(let a of vx(e)){i+=a.byteLength,i>t&&Q(`File exceeds ${t} bytes.`,`文件超过 ${t} 字节。`);let e=Buffer.concat([r,a]),s=0,c=e.indexOf(10,s);for(;c!==-1;){let t=c-s;t>n&&Q(`JSONL line exceeds 6 MiB.`,`JSONL 单行超过 6 MiB。`),yield{text:o(e.subarray(s,c)).replace(/\r$/,``),bytes:t+1},s=c+1,c=e.indexOf(10,s)}r=Buffer.from(e.subarray(s)),r.byteLength>n&&Q(`JSONL line exceeds 6 MiB.`,`JSONL 单行超过 6 MiB。`)}r.length&&(yield{text:o(r),bytes:r.length})}function bx(e,t=!1){if(typeof e==`string`&&t){if(/^data:[^,]+;base64,/i.test(e))return;let t;try{t=new URL(e)}catch{return Q(`Media must use a public HTTP(S) or base64 data URL.`,`媒体必须使用公网 HTTP(S) 或 base64 data URL。`)}let n=t.hostname.toLowerCase().replace(/^\[|\]$/g,``),r=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(n),i=r?parseInt(r[1],16):0,a=r?parseInt(r[2],16):0,o=r?[i>>8,i&255,a>>8,a&255].join(`.`):n,s=n===`localhost`||n.endsWith(`.localhost`)||Te(o)===4&&/^(0|10|127|169\.254|172\.(1[6-9]|2\d|3[01])|192\.168)(\.|$)/.test(o)||Te(n)===6&&/^(::1$|::$|f[cd]|fe[89ab])/.test(n);(![`http:`,`https:`].includes(t.protocol)||s)&&Q(`Media URLs must not use local/private addresses.`,`媒体 URL 不得使用本地或私网地址。`)}else if(Array.isArray(e))for(let n of e)bx(n,t);else if(gx(e))for(let[n,r]of Object.entries(e))bx(r,[`image_url`,`video_url`,`audio_url`,`file_url`,`image`,`video`].includes(n)||t&&n===`url`)}var xx=class{ids=/* @__PURE__ */ new Set;thinking;report={records:0,bytes:0,model:``,endpoint:`/v1/chat/completions`,warnings:[]};warn(e){this.report.warnings.includes(e)||this.report.warnings.push(e)}add(e,t){let n=this.report.records+1,r=e=>Q(`Invalid or inconsistent ${e} at record ${n}.`,`第 ${n} 条记录的 ${e} 无效或不一致。`);gx(e)||r(`JSON object`);let i=e,a=i.custom_id;(typeof a!=`string`||!a.trim()||Array.from(a).length>256||this.ids.has(a))&&r(`custom_id`),i.method!==`POST`&&r(`method=POST`);let o=_x(String(i.url));gx(i.body)||r(`body`);let s=i.body;if((typeof s.model!=`string`||!s.model.trim())&&r(`body.model`),s.enable_thinking!==void 0&&typeof s.enable_thinking!=`boolean`&&r(`enable_thinking`),this.report.records&&(this.report.model!==s.model||this.report.endpoint!==o||this.thinking!==s.enable_thinking)&&r(`model/url/enable_thinking`),o===`/v1/embeddings`){let e=e=>typeof e==`string`&&!!e.trim(),t=e=>Array.isArray(e)&&e.length>0&&e.every(e=>Number.isInteger(e)&&e>=0);e(s.input)||t(s.input)||Array.isArray(s.input)&&s.input.length>0&&(s.input.every(e)||s.input.every(t))||r(`body.input`)}else(!Array.isArray(s.messages)||!s.messages.length||s.messages.some(e=>!gx(e)||typeof e.role!=`string`||!e.role.trim()||typeof e.content!=`string`&&!(Array.isArray(e.content)&&e.content.length>0&&e.content.every(gx))&&!(Array.isArray(e.tool_calls)&&e.tool_calls.length>0&&e.tool_calls.every(gx))))&&r(`body.messages`);bx(s),gx(s.extra_body)&&(`enable_thinking`in s.extra_body||`thinking_budget`in s.extra_body)&&this.warn(`Place enable_thinking/thinking_budget at body top level, not extra_body. / enable_thinking/thinking_budget 应放在 body 顶层,而非 extra_body。`),t>6291456&&r(`line <=6 MiB`),t>1048576&&this.warn(`Line exceeds 1 MiB; documentation differs (1/6 MiB), compatibility is not guaranteed. / 单行超过 1 MiB,文档存在 1/6 MiB 差异,不保证兼容。`),this.ids.add(a),this.report.records++,this.report.bytes+=t,this.report.model=s.model,this.report.endpoint=o,this.thinking=s.enable_thinking,(this.report.records>5e4||this.report.bytes>524288e3)&&r(`50000 records / 500 MiB`),s.model===`batch-test-model`&&(this.report.records>100||this.report.bytes>1048576)&&r(`batch-test-model: 100 records / 1 MiB`)}finish(){return this.report.records||Q(`Batch input is empty.`,`Batch 输入为空。`),this.report}};async function Sx(e){let t=new xx,n=0;for await(let r of yx(e,fx)){n++;let e;try{e=JSON.parse(r.text)}catch{Q(`Invalid JSONL at line ${n}.`,`第 ${n} 行不是有效 JSONL。`)}t.add(e,r.bytes)}return t.finish()}async function Cx(e){let t=[],n=0;for await(let r of vx(e))n+=r.byteLength,n>524288e3&&Q(`File exceeds 500 MiB.`,`文件超过 500 MiB。`),t.push(r);return new Blob(t)}function wx(e,t,n){return e.requestJson({path:tg(),method:`POST`,body:t,signal:n})}function Tx(e,t,n){return e.requestJson({path:ng(t),signal:n})}function Ex(e,t,n){return e.requestJson({path:rg(t),method:`POST`,signal:n})}function Dx(e,t={},n){let r=new URLSearchParams;for(let[e,n]of Object.entries(t))n!==void 0&&r.set(e,Array.isArray(n)?n.join(`,`):String(n));return e.requestJson({path:tg()+(r.size?`?${r.toString()}`:``),signal:n})}function Ox(e,t,n){return e.request({path:ig(t),signal:n})}function kx(e){let t=e.url(eg(),ag),n=new URL(t).hostname.toLowerCase(),r=new URL(e.baseUrl).hostname.toLowerCase();return(e.usesTokenPlanEndpoint()||/^dashscope(?:-intl|-us)?\.aliyuncs\.com$/.test(n)||/^dashscope-(?:intl|us)\.aliyuncs\.com$/.test(r))&&Q(`--batch needs the Batch host, not a realtime/international/Token Plan endpoint; configure --base-url explicitly.`,`--batch 不能使用实时、国际站或 Token Plan 端点,请显式配置 Batch --base-url。`),t}async function Ax(e,t,n=!1){let r=je(e),i=je(Oe(r),`.${De(r)}.${He()}.tmp`),a,o=e=>{throw hx(e)};try{await Ie(Oe(r),{recursive:!0}).catch(o),a=await Le(i,`wx`,384).catch(o);for await(let e of t){let t=typeof e==`string`?Buffer.from(e):e,n=0;for(;n<t.byteLength;){let e=await a.write(t,n,t.byteLength-n).catch(o);n+=e.bytesWritten}}await a.sync().catch(o),await a.close().catch(o),a=void 0,n?await ze(i,r).catch(o):await Fe(i,r).catch(o)}finally{await a?.close().catch(()=>{}),await Be(i).catch(()=>{})}}async function jx(e){let t=_x(e.endpoint??`/v1/chat/completions`);(je(e.file)===je(e.outputFile)||e.bodyFile&&je(e.bodyFile)===je(e.outputFile))&&Q(`Output must differ from input/body file.`,`输出路径必须与输入及 body 文件不同。`),e.model.trim()||Q(`Model must not be empty.`,`模型不能为空。`);let n=e.idColumn??`custom_id`,r=e.inputColumn??`content`,i={};if(e.bodyFile){let t;try{t=await Re(e.bodyFile,`utf8`)}catch(e){throw hx(e)}try{let e=JSON.parse(t);if(!gx(e))throw Error();i=e}catch{Q(`--body-file must contain a JSON object.`,`--body-file 必须包含 JSON 对象。`)}}[`model`,`messages`,`input`].some(e=>e in i)&&Q(`--body-file cannot define model/messages/input.`,`--body-file 不得定义 model/messages/input。`),t===`/v1/embeddings`&&(e.system!==void 0||`enable_thinking`in i||`thinking_budget`in i)&&Q(`System/thinking parameters do not apply to embeddings.`,`向量请求不适用系统提示词或思考参数。`);let a=new xx,o=[],s=[],c;async function*l(){let t=new TextDecoder(`utf8`,{fatal:!0}),n=0;for await(let r of vx(e.file)){n+=r.byteLength,n>524288e3&&Q(`CSV exceeds 500 MiB.`,`CSV 超过 500 MiB。`);try{yield t.decode(r,{stream:!0})}catch{Q(`CSV must be UTF-8.`,`CSV 必须是 UTF-8。`)}}try{yield t.decode()}catch{Q(`CSV must be UTF-8.`,`CSV 必须是 UTF-8。`)}}async function*u(){let u=Ee.from(l()),d=Ne({bom:!0,max_record_size:6291456,columns:e=>((new Set(e).size!==e.length||!e.includes(n)||!e.includes(r))&&Q(`CSV requires unique headers and mapped ID/input columns.`,`CSV 表头必须唯一并包含映射的 ID/输入列。`),s=e.filter(e=>e!==n&&e!==r),e)});u.on(`error`,e=>d.destroy(e)),u.pipe(d);let f=0;try{for await(let s of d){f++;let c=s;c[r]?.trim()||Q(`Empty CSV input at record ${f}.`,`CSV 第 ${f} 条记录输入为空。`);let l={...i,model:e.model};t===`/v1/embeddings`?(l.input=c[r],l.encoding_format??=`float`):l.messages=[...e.system===void 0?[]:[{role:`system`,content:e.system}],{role:`user`,content:c[r]}];let u={custom_id:c[n],method:`POST`,url:t,body:l},d=JSON.stringify(u)+`
78
- `;a.add(u,Buffer.byteLength(d)),e.dryRun&&o.length<2&&o.push(u),yield d}c=a.finish()}catch(e){throw e instanceof Error&&e.name===`Error`&&`code`in e&&String(e.code).startsWith(`CSV_`)&&Q(`Invalid CSV near record ${f+1}: ${e.message}`,`第 ${f+1} 条记录附近 CSV 格式错误:${e.message}`),hx(e)}finally{u.destroy(),d.destroy()}}if(e.dryRun)for await(let e of u());else await Ax(e.outputFile,u(),e.force);return{...c,output_file:je(e.outputFile),ignored_columns:s,...e.dryRun?{samples:o}:{}}}const Mx=[`custom_id`,`model`,`request_id`,`status_code`,`content`,`embedding`,`error_code`,`error_message`,`prompt_tokens`,`completion_tokens`,`total_tokens`];function Nx(e){return gx(e)?e:{}}function Px(e){let t=e==null?``:typeof e==`string`?e:JSON.stringify(e);return/^[\s\x00-\x1f]*[=+@-]/.test(t)?`'${t}`:t}function Fx(e){return typeof e==`number`&&Number.isFinite(e)?e:``}function Ix(e){let t=Nx(e),n=Nx(t.response),r=Nx(n.body),i=Nx(t.error??r.error),a=Nx(r.usage),o=Nx(Nx(Array.isArray(r.choices)?r.choices[0]:void 0).message),s=Array.isArray(r.data)?r.data.map(e=>{let t=Nx(e);return{index:t.index,embedding:t.embedding}}):void 0;return{recognized:Array.isArray(r.choices)||Array.isArray(r.data)||`code`in i||`message`in i,row:{custom_id:Px(t.custom_id),model:Px(r.model),request_id:Px(n.request_id),status_code:Fx(n.status_code),content:Px(o.content),embedding:Px(s),error_code:Px(i.code),error_message:Px(i.message),prompt_tokens:Fx(a.prompt_tokens),completion_tokens:Fx(a.completion_tokens),total_tokens:Fx(a.total_tokens)}}}async function Lx(e,t,n=!1){let r=0,i=0;async function*a(){yield``+Pe([],{columns:[...Mx],header:!0});for(let t of e)for await(let e of yx(t,1/0,1/0)){if(!e.text.trim())continue;let n;try{n=JSON.parse(e.text)}catch{Q(`Invalid result JSONL at ${t}:${r+1}.`,`结果 JSONL 格式错误:${t}:${r+1}。`)}let a=Ix(n);r++,a.recognized||i++,yield Pe([a.row],{columns:[...Mx]})}}return await Ax(t,a(),n),{records:r,unknown_records:i}}function Rx(e){let t=e===`zh-CN`?`请介绍一下自己`:`Introduce yourself`,n={custom_id:`req-001`,method:`POST`,url:`/v1/chat/completions`,body:{model:`qwen-plus`,messages:[{role:`user`,content:t}]}},r={custom_id:`req-001`,method:`POST`,url:`/v1/embeddings`,body:{model:`text-embedding-v4`,input:t,encoding_format:`float`}},i={custom_id:`req-001`,method:`POST`,url:`/v1/chat/completions`,body:{model:`qwen-vl-plus`,messages:[{role:`user`,content:[{type:`text`,text:t},{type:`image_url`,image_url:{url:`https://example.com/image.jpg`}}]}]}},a={custom_id:`req-001`,response:{request_id:`request-001`,status_code:200,body:{model:`qwen-plus`,choices:[{message:{role:`assistant`,content:e===`zh-CN`?`你好`:`Hello`}}],usage:{prompt_tokens:10,completion_tokens:2,total_tokens:12}}},error:null};return{csv:`custom_id,content\nreq-001,${t}\nreq-002,2+2?`,chat:n,embedding:r,vision:i,defaults:{enable_thinking:!1,max_tokens:1024},success:a,failure:{custom_id:`req-002`,response:null,error:{code:`ExampleError`,message:`Example service error`}}}}function zx(e){let t=t=>{let n=Rx(t);if(e===`prepare`||e===`convert`)return`input.csv:\n${n.csv}\n\ninput.jsonl:\n${JSON.stringify(n.chat)}\n\ndefaults.json (--body-file):\n${JSON.stringify(n.defaults)}`;if(e===`create`)return`Chat JSONL:\n${JSON.stringify(n.chat)}\n\nEmbedding JSONL:\n${JSON.stringify(n.embedding)}\n\nMultimodal JSONL (${t===`zh-CN`?`请替换示例公网图片 URL`:`replace the example public image URL`}):\n${JSON.stringify(n.vision)}`;let r=Pe([n.success,n.failure].map(e=>Ix(e).row),{columns:[...Mx],header:!0});return`result.jsonl:\n${JSON.stringify(n.success)}\n\nerror.jsonl (${t===`zh-CN`?`示意包络,真实服务需联调`:`illustrative envelope; verify with the service`}):\n${JSON.stringify(n.failure)}\n\nresult.csv:\n${r}`};return{"en-US":t(`en-US`),"zh-CN":t(`zh-CN`)}}const Bx=`decision-model-preview`,Vx=[`cn-beijing`,`ap-southeast-1`],Hx=`cn-beijing`,Ux=[`label`,`target`];function Wx(e){if(!ib(e))return e;let t=e.questions;return ib(t)&&typeof t.type!=`string`?t:e}function Gx(e){if(!ib(e))return e;let t={};for(let[n,r]of Object.entries(e)){if(!ib(r)){t[n]=r;continue}let e={...r};for(let t of Ux)delete e[t];t[n]=e}return t}async function Kx(e,t,n,r){let i=await e.requestJson({path:$h(t,n,`submit`),method:`POST`,body:r});if(typeof i?.data?.biz_id!=`string`||!i.data.biz_id.trim())throw new D(`ParseX response is missing data.biz_id; submission may have succeeded. / ParseX 响应缺少 data.biz_id,任务可能已提交成功。`,void 0,`Check the task before submitting again. / 请核对任务后再决定是否重新提交。`,{api:{requestId:i?.request_id}});return i}async function qx(e,t,n,r,i){let a=await e.requestJson({path:$h(t,n,`result`),method:`POST`,body:r,signal:i});if(typeof a?.data?.status!=`string`||!a.data.status.trim())throw new D(`ParseX response is missing data.status. / ParseX 响应缺少 data.status。`,void 0,void 0,{api:{requestId:a?.request_id}});return a}async function Jx(e,t,n,r,i){let a=new AbortController,o=()=>a.abort(i.signal?.reason);i.signal?.aborted?o():i.signal?.addEventListener(`abort`,o,{once:!0});let s=setTimeout(()=>a.abort(new D(`ParseX polling timed out. / ParseX 轮询超时。`,E.TIMEOUT,`The remote task was not cancelled; query the same biz_id: ${r.biz_id}. / 未取消远端任务,请使用同一 biz_id 继续查询。`)),i.pollTimeout*1e3);try{for(;;){a.signal.throwIfAborted();try{let o=await qx(e,t,n,r,a.signal);if(a.signal.throwIfAborted(),i.progress?.(o),o.data.status===`success`||o.data.status===`failed`)return o}catch(e){if(a.signal.aborted||!(e instanceof D)||e.api?.apiCode!==`ResultNotReady`)throw e}await Ue(i.interval*1e3,void 0,{signal:a.signal})}}catch(e){throw a.signal.aborted?a.signal.reason:e}finally{clearTimeout(s),i.signal?.removeEventListener(`abort`,o)}}async function Yx(e,t,n){return e.requestJson({path:Ug(),method:`POST`,body:t,signal:n})}async function Xx(e,t={}){let n=new URLSearchParams;t.pageNo!==void 0&&n.set(`page_no`,String(t.pageNo)),t.pageSize!==void 0&&n.set(`page_size`,String(t.pageSize)),t.status&&n.set(`status`,t.status),t.model&&n.set(`model`,t.model);let r=Ug(),i=n.toString()?`${r}?${n.toString()}`:r;return e.requestJson({path:i,method:`GET`,signal:t.signal})}async function Zx(e,t,n){return e.requestJson({path:Wg(t),method:`GET`,signal:n})}async function Qx(e,t,n){return e.requestJson({path:Gg(t),method:`POST`,signal:n})}async function $x(e,t,n){return e.requestJson({path:Wg(t),method:`DELETE`,signal:n})}async function eS(e,t,n={}){let r=new URLSearchParams;n.pageNo!==void 0&&r.set(`page_no`,String(n.pageNo)),n.pageSize!==void 0&&r.set(`page_size`,String(n.pageSize));let i=Kg(t),a=r.toString()?`${i}?${r.toString()}`:i;return e.requestJson({path:a,method:`GET`,signal:n.signal})}async function tS(e,t){let n=new URLSearchParams;n.set(`input_model`,t.inputModel),n.set(`training_type`,t.trainingType),t.mtuSpecCode&&n.set(`mtu_spec_code`,t.mtuSpecCode),t.paramType&&n.set(`param_type`,t.paramType),t.trainOptions&&Object.keys(t.trainOptions).length>0&&n.set(`hyper_parameters`,JSON.stringify(t.trainOptions)),t.lang&&n.set(`lang`,t.lang);let r=`${qg()}?${n.toString()}`;return e.requestJson({path:r,method:`GET`,headers:t.workspaceId?{"X-DashScope-WorkSpace":t.workspaceId}:void 0,signal:t.signal})}async function nS(e,t,n={}){let r=new URLSearchParams;n.pageNo!==void 0&&r.set(`page_no`,String(n.pageNo)),n.pageSize!==void 0&&r.set(`page_size`,String(n.pageSize));let i=Jg(t),a=r.toString()?`${i}?${r.toString()}`:i;return e.requestJson({path:a,method:`GET`,headers:n.workspaceId?{"X-DashScope-WorkSpace":n.workspaceId}:void 0,signal:n.signal})}async function rS(e,t,n){return e.requestJson({path:Yg(t),method:`GET`,signal:n})}async function iS(e,t,n,r,i){let a=new URLSearchParams;return a.set(`model_name`,r),e.requestJson({path:`${$g(t,n)}?${a.toString()}`,method:`GET`,signal:i})}function aS(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))r!==void 0&&r!==``&&n.set(e,String(r));return n.toString()?`${e}?${n.toString()}`:e}async function oS(e,t={}){return e.requestJson({path:aS(e_(),{model:t.model,lang:t.lang}),method:`GET`,signal:t.signal})}async function sS(e,t,n){return e.requestJson({path:t_(),method:`POST`,body:t,signal:n})}async function cS(e,t={}){let n=aS(t_(),{status:t.status,model:t.model,template_id:t.templateId,quant_spec:t.quantSpec,quant_method:t.quantMethod,start_time:t.startTime,end_time:t.endTime,search_key:t.searchKey,select_key:t.selectKey,sort_order:t.sortOrder,page_no:t.pageNo,page_size:t.pageSize});return e.requestJson({path:n,method:`GET`,signal:t.signal})}async function lS(e,t,n){return e.requestJson({path:n_(t),method:`GET`,signal:n})}async function uS(e,t,n={}){return e.requestJson({path:aS(i_(t),{offset:n.offset,line:n.line}),method:`GET`,signal:n.signal})}async function dS(e,t,n){return e.requestJson({path:r_(t),method:`POST`,signal:n})}async function fS(e,t,n){return e.requestJson({path:n_(t),method:`DELETE`,signal:n})}const pS={sft:{server:`sft`,method:`sft`,variant:`full`},"sft-lora":{server:`efficient_sft`,method:`sft`,variant:`lora`},dpo:{server:`dpo_full`,method:`dpo`,variant:`full`},"dpo-lora":{server:`dpo_lora`,method:`dpo`,variant:`lora`},cpt:{server:`cpt`,method:`cpt`,variant:`full`}},mS=Object.keys(pS),hS=`sft-lora`;function gS(e){return e in pS}function _S(e){let{method:t,variant:n}=pS[e];return{method:t,variant:n}}function vS(e,t){if(!e)return!1;let{method:n,variant:r}=pS[t];if(e.supports?.[n]!==!0)return!1;let i=e.trainingTypes?.[n];return Array.isArray(i)&&i.includes(r)}function yS(e){return e?mS.filter(t=>vS(e,t)):[]}async function bS(e,t,n={}){return await Zv(An(e,n),t)}const xS=`INSUFFICIENT_SAMPLES`;function SS(e){let{recordCount:t,batchSize:n}=e;return t>n?{ok:!0}:{ok:!1,issue:{severity:`error`,code:xS,message:`Training dataset has ${t} sample(s), which is not greater than batch_size (${n}).`},hint:[`The platform requires the number of training samples to exceed batch_size.`,`Options:`,` • add more data (recommended: comfortably more than batch_size, since the`,` platform also holds back a default 0.9 train split),`,` • lower --batch-size within the range published for this model and training type.`].join(`
79
- `)}}function CS(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e!=`string`||e.trim()===``)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function wS(e,t,n){let r=(e-t)/n;return Math.abs(r-Math.round(r))<1e-9}function TS(e,t){let n=new Map(e.flatMap(e=>e.name?[[e.name,e]]:[])),r=[];for(let[e,i]of Object.entries(t)){let t=n.get(e);if(!t){r.push({parameter:e,value:i,code:`unsupported`});continue}if(t.editable===!1){r.push({parameter:e,value:i,code:`not_editable`});continue}let a=String(i),o=t.support_values??[];if(o.length>0&&!o.includes(a)){r.push({parameter:e,value:i,code:`not_supported`,expected:o.join(`, `)});continue}let s=t.data_range??[];if(t.type===`number`||t.type===`intInputNumber`||t.type===`floatInputNumber`||s.length===2||t.step!==void 0){let n=CS(i);if(n===void 0||t.type===`intInputNumber`&&!Number.isInteger(n)){r.push({parameter:e,value:i,code:`invalid_type`,expected:t.type===`intInputNumber`?`integer`:`number`});continue}let a=CS(s[0]),o=CS(s[1]),c=a!==void 0&&(t.left_range===`exclude`?n<=a:n<a),l=o!==void 0&&(t.right_range===`exclude`?n>=o:n>o);if(c||l){let n=t.left_range===`exclude`?`(`:`[`,a=t.right_range===`exclude`?`)`:`]`;r.push({parameter:e,value:i,code:`out_of_range`,expected:`${n}${s[0]}, ${s[1]}${a}`});continue}t.step!==void 0&&t.step>0&&!wS(n,a??0,t.step)&&r.push({parameter:e,value:i,code:`invalid_step`,expected:`step ${t.step} from ${a??0}`});continue}(i===null||typeof i==`object`||t.type===`input`&&a.trim()===``)&&r.push({parameter:e,value:i,code:`invalid_type`,expected:t.type??`scalar`})}return r}function ES(e,t){let n=e.find(e=>e.name===t);return CS(n?.defaultValue??n?.recommend_value)}function DS(e){let t={};return e.nEpochs!==void 0&&(t.n_epochs=e.nEpochs),e.learningRate!==void 0&&(t.learning_rate=e.learningRate),e.maxLength!==void 0&&(t.max_length=e.maxLength),e.batchSize!==void 0&&(t.batch_size=e.batchSize),t}function OS(e,t,n){return{clientTrainingType:e,serverTrainingType:t,acceptedExtensions:[`.jsonl`],async validate(e,t,r){return ox(e,{...r,schema:n})},resolveHyperParameters(e,t){return DS(t)},shouldSkipGate(e,t){return!1},shouldSkipCapabilityCheck(e){return!1}}}const kS=OS(`sft`,`sft`,`chatml`),AS={lm_max_epoch:60,lm_step:5,lm_num:3,lm_batch_size:1e3,fm_max_epoch:100,fm_step:10,fm_num:3,fm_batch_size:2e3},jS={learning_rate:`3e-5`,max_steps:800,eval_steps:200,max_token_length:`1k`,gradient_clip:.5,weight_decay:.02,max_pixels:`2k`,val_img_size:`2k`,generation_type:`t2i`,lora_rank:32,save_total_limit:10,split:.9},MS={...jS,max_pixels:`1k`,val_img_size:`1k`,generation_type:`i2i`},NS={n_epochs:50,learning_rate:`2e-5`,split:.5,max_split_val_dataset_sample:5,eval_epochs:20,save_total_limit:10,lora_rank:32,lora_alpha:32};function PS(e){return e===`image`||e===`image-i2i`}function FS(e){return e===`video`||e===`video-kf2v`}function IS(e){return typeof e==`string`&&/wan2\.5/i.test(e)}function LS(e){return typeof e==`string`&&/wan2\.7/i.test(e)}const RS=[kS,{clientTrainingType:`sft-lora`,serverTrainingType:`efficient_sft`,acceptedExtensions:[`.jsonl`,`.zip`],async validate(e,t,n){if(t===`audio`)return ox(e,{...n,schema:`tts`});if(PS(t))return ox(e,{...n,schema:`image`,maxBytes:Iy});if(FS(t)){let r=await ox(e,{...n,schema:`video`,maxBytes:Iy});if(typeof n.model==`string`&&n.model.length>0){let e=/kf2v/i.test(n.model),i=t===`video-kf2v`;e&&!i?r.errors.push(Z(`error`,`KF2V_DATA_MISMATCH`,`Model "${n.model}" is a first+last-frame (kf2v) model but the data has no "last_frame_path". kf2v training data must include a last frame per record.`)):!e&&i&&r.warnings.push(Z(`warning`,`I2V_LAST_FRAME_IGNORED`,`Model "${n.model}" is a first-frame (i2v) model but the data includes "last_frame_path"; the last frame will be ignored during training.`))}return r.valid=r.errors.length===0,r}return ox(e,{...n,schema:`chatml`})},resolveHyperParameters(e,t){if(e===`audio`)return{...AS};if(PS(e)){let n={...e===`image-i2i`?MS:jS};return t.learningRate!==void 0&&(n.learning_rate=t.learningRate),n}if(FS(e)){let e=t.model??t.baseModel,n={...NS,batch_size:LS(e)?1:4,max_pixels:LS(e)?102400:IS(e)?36864:262144};return t.nEpochs!==void 0&&(n.n_epochs=t.nEpochs),t.batchSize!==void 0&&(n.batch_size=t.batchSize),t.learningRate!==void 0&&(n.learning_rate=t.learningRate),n}return DS(t)},shouldSkipGate(e,t){return!(t!==`audio`&&!PS(t)&&!FS(t)||e!==`batch_size`)},shouldSkipCapabilityCheck(e){return e===`audio`||PS(e)||FS(e)}},OS(`dpo`,`dpo_full`,`dpo`),OS(`dpo-lora`,`dpo_lora`,`dpo`),{clientTrainingType:`cpt`,serverTrainingType:`cpt`,acceptedExtensions:[`.jsonl`],async validate(e,t,n){return ox(e,{...n,schema:`cpt`,maxBytes:Py})},resolveHyperParameters(e,t){return DS(t)},shouldSkipGate(e,t){return!1},shouldSkipCapabilityCheck(e){return!1}}];function zS(e){let t=RS.find(t=>t.clientTrainingType===e);if(!t){let t=RS.map(e=>e.clientTrainingType).join(`, `);throw new D(`Unknown training type "${e}".`,E.USAGE,`Supported training types: ${t}.`)}return t}function BS(){return RS.map(e=>e.clientTrainingType)}const VS=`zeldaEasy.broadscope-platform.modelCenter.getModelPrice`,HS=`zeldaEasy.broadscope-platform.modelInstance.calculateDatasetsTotalTokens`,US=`zeldaEasy.broadscope-platform.modelInstance.estimateFinetuneTokens`;async function WS(e,t){return Jv(await e.console(VS,{query:{type:0,modelId:t}}))}async function GS(e,t,n){return Jv(await e.console(HS,{input:{trainDatasetIds:t,hyperParams:n}}))}async function KS(e,t,n,r){let i=JSON.stringify({useDefault:!1,userDefinedObj:{batch_size:16,eval_steps:50,learning_rate:`7e-6`,lr_scheduler_type:`linear`,max_length:8192,n_epochs:r,split:.9,save_total_limit:`3`,resume_from_checkpoint:!1,save_strategy:`epoch`},useQwenMixedStrategy:!1});return Jv(await e.console(US,{input:{trainingType:`cpt`,instanceName:`${t}_cli_estimate`,algorithmType:100,bizType:100,trainDatasetIds:n,hyperParams:i,bailianTrainModel:t,validationDatasetIds:``,jobName:`${t}_cli_estimate`,priority:`L0`}}))}function qS(e){return e?{"x-acs-req-uuid":e,"X-DashScope-RequestId":e}:void 0}async function JS(e,t,n){return e.requestJson({path:a_(),method:`POST`,body:t,signal:n})}async function YS(e,t={}){let n=new URLSearchParams;t.pageNo!==void 0&&n.set(`page_no`,String(t.pageNo)),t.pageSize!==void 0&&n.set(`page_size`,String(t.pageSize)),t.plan!==void 0&&n.set(`plan`,t.plan);let r=a_(),i=n.toString()?`${r}?${n.toString()}`:r;return e.requestJson({path:i,method:`GET`,signal:t.signal})}async function XS(e,t,n){return e.requestJson({path:o_(t),method:`GET`,signal:n})}async function ZS(e,t,n={}){let r=new URLSearchParams;n.pageNo!==void 0&&r.set(`page_no`,String(n.pageNo)),n.pageSize!==void 0&&r.set(`page_size`,String(n.pageSize)),n.includeDeleted!==void 0&&r.set(`include_deleted`,String(n.includeDeleted)),n.statuses!==void 0&&r.set(`statuses`,n.statuses.join(`,`)),n.chargeTypes!==void 0&&r.set(`charge_types`,n.chargeTypes.join(`,`));let i=s_(t),a=r.toString()?`${i}?${r.toString()}`:i;return e.requestJson({path:a,method:`GET`,signal:n.signal})}async function QS(e,t,n,r){return e.requestJson({path:c_(t,n),method:`GET`,signal:r})}async function $S(e,t,n,r){return e.requestJson({path:f_(t,n),method:`GET`,signal:r})}async function eC(e,t,n,r={}){return e.requestJson({path:s_(t),method:`POST`,body:n,headers:qS(r.requestId),signal:r.signal})}async function tC(e,t,n,r,i={}){return e.requestJson({path:l_(t,n),method:`PUT`,body:r,headers:qS(i.requestId),signal:i.signal})}async function nC(e,t,n,r,i={}){return e.requestJson({path:u_(t,n),method:`PUT`,body:r,headers:qS(i.requestId),signal:i.signal})}async function rC(e,t,n,r={}){let i=c_(t,n),a=new URLSearchParams;return r.reason!==void 0&&a.set(`reason`,r.reason),e.requestJson({path:a.toString()?`${i}?${a.toString()}`:i,method:`DELETE`,headers:qS(r.requestId),signal:r.signal})}async function iC(e,t,n,r){return e.requestJson({path:d_(t),method:`PUT`,body:{overflow_strategy:n},signal:r})}async function aC(e,t,n){return e.requestJson({path:o_(t),method:`DELETE`,signal:n})}async function oC(e,t={}){let n=new URLSearchParams;t.pageNo!==void 0&&n.set(`page_no`,String(t.pageNo)),t.pageSize!==void 0&&n.set(`page_size`,String(t.pageSize)),t.version&&n.set(`version`,t.version),t.modelSource&&n.set(`model_source`,t.modelSource);let r=h_(),i=n.toString()?`${r}?${n.toString()}`:r;return e.requestJson({path:i,method:`GET`,signal:t.signal})}async function sC(e,t,n,r,i){return e.requestJson({path:p_(t),method:`PUT`,body:n,headers:qS(i),signal:r})}async function cC(e,t,n,r){return e.requestJson({path:m_(t),method:`PUT`,body:n,signal:r})}const lC={LORA:`lora`,PTU:`ptu`,MU:`mu`},uC=lC.LORA;function dC(e){return e===`audio`?lC.MU:uC}const fC={POST_PAY:`POST_PAY`,PRE_PAY:`PRE_PAY`},pC=fC.POST_PAY,mC={POST_PAID:`post_paid`,PRE_PAID:`pre_paid`};function hC(e,t){if(t||e.inputTpm!==void 0||e.outputTpm!==void 0){if(e.inputTpm===void 0||e.outputTpm===void 0)return`--input-tpm and --output-tpm must be provided together.
77
+ `);r=t.pop()??``;for(let n of t){let t=Qv(n,e,i);e=t.event,t.completed&&(yield t.completed)}}break}if(r+=n.decode(o,{stream:!0}),r.length>i)throw new O(`SSE stream exceeded the maximum buffer size.`,D.GENERAL);let{lines:s,rest:c}=Zv(r);r=c;for(let t of s){let n=Qv(t,e,i);e=n.event,n.completed&&(yield n.completed)}}r.length>0&&(e=Qv(r,e,i).event),e.data!==void 0&&(yield{data:e.data,event:e.event,id:e.id})}finally{await t.cancel().catch(()=>{}),t.releaseLock()}}const ey=/* @__PURE__ */ new Set([`EPERM`,`EACCES`,`ENETUNREACH`,`EHOSTUNREACH`]);function ty(e){let t=e;for(let e=0;e<5&&t!=null;e+=1){let e=t.code;if(typeof e==`string`&&e.length>0)return e;t=t.cause}}function ny(e){return e!==void 0&&ey.has(e)}const ry=`The execution environment (for example an AI agent sandbox) may be blocking outbound network. Enable network access for this process in the agent settings, or run the command in a regular terminal. If an egress proxy is required, set HTTPS_PROXY.`;function iy(e,t,n){return new Promise(r=>{let i=se({host:e,port:t}),a=e=>{i.destroy(),r(e)};i.setTimeout(n,()=>a(`ETIMEDOUT`)),i.once(`connect`,()=>a(void 0)),i.once(`error`,e=>a(e.code??`UNKNOWN`))})}function ay(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const oy=/* @__PURE__ */ new Set([`data`,`DataV2`,`success`,`successResponse`,`failed`,`code`,`errorCode`,`errorMsg`,`message`,`requestId`,`request_id`,`traceId`,`httpStatusCode`,`httpStatus`,`api`,`ret`]);function sy(e,t=!1){return t&&(typeof e.success==`boolean`||typeof e.failed==`boolean`||Array.isArray(e.ret))||Object.hasOwn(e,`DataV2`)||typeof e.successResponse==`boolean`||Object.keys(e).every(e=>oy.has(e))&&(Object.hasOwn(e,`data`)||Object.hasOwn(e,`errorCode`)||Array.isArray(e.ret)||typeof e.success==`boolean`||typeof e.failed==`boolean`)}function cy(e){if(typeof e==`string`&&e.trim())return e;if(typeof e==`number`)return String(e)}function ly(e){let t=[],n=e,r;for(;ay(n)&&sy(n,r!==void 0);){if(t.push(n),t.length>6)throw new O(`Invalid Console response envelope. / Console 响应信封无效。`,D.GENERAL);if(Object.hasOwn(n,`DataV2`))n=n.DataV2,r=`dataV2`;else if(Object.hasOwn(n,`data`))r=r===`dataV2`?`result`:void 0,n=n.data;else break}let i=t.flatMap(e=>Array.isArray(e.ret)?e.ret.filter(e=>typeof e==`string`&&!e.startsWith(`SUCCESS::`)):[]),a=t.filter(e=>{let t=cy(e.errorCode);return e.success===!1||e.successResponse===!1||e.failed===!0||e.success!==!0&&e.successResponse!==!0&&t!==void 0&&t!==`0`&&t!==`200`});if(a.length>0||i.length>0){let n=[...a].reverse(),r=n.map(e=>cy(e.errorMsg)??cy(e.message)).find(Boolean)??(i.join(`; `)||`Console service failed without a message. / Console 服务失败,未提供错误消息。`),o=n.map(e=>cy(e.errorCode)??(e.success===!1||e.failed===!0?cy(e.code):void 0)).find(Boolean),s=t.map(e=>cy(e.requestId)??cy(e.request_id)).find(Boolean);throw new O(`${r} (${[`HTTP 200`,o?`code=${o}`:``,s?`request_id=${s}`:``].filter(Boolean).join(`; `)})`,D.GENERAL,void 0,{api:{httpStatus:200,apiCode:o,requestId:s},rawResponse:JSON.stringify(e)})}return n}const uy=`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,dy=`zeldaEasy.bmp.modelPredictRpcService.getPredictParamConfig`;function fy(e){let t=e.data;if(!t)return e;let n=t.DataV2;if(n){let e=n.data;return e?.data??e??n}return t.data??t}async function py(e,t={}){let{pageNo:n=1,pageSize:r=50,name:i=``,providers:a=[],capabilities:o=[],supports:s}=t,c={pageNo:n,pageSize:r,name:i,providers:a,inferenceProviders:[],features:[],group:!0,capabilities:o,contextWindows:[]};s&&(c.supports=s);let l=fy(await e(uy,{input:c})),u=l.total??0,d=l.list??[],f=[];for(let e of d){let t=e.items;if(t?.length)for(let e of t)f.push(e);else f.push(e)}return{total:u,models:f}}async function my(e,t={}){let n=t.pageSize??50,r=await py(e,{...t,pageNo:1,pageSize:n}),i=[...r.models],a=Math.ceil(r.total/n);for(let r=2;r<=a;r++){let a=await py(e,{...t,pageNo:r,pageSize:n});if(a.models.length===0)break;i.push(...a.models)}return i}async function hy(e,t,n){return(await py(e,{name:t,pageSize:50,supports:n})).models.find(e=>e.model===t)??null}async function gy(e,t={}){let{pageNo:n=1,pageSize:r=50,name:i=``,providers:a=[],capabilities:o=[],features:s=[],contextWindows:c=[],querySampleCode:l}=t,u={pageNo:n,pageSize:r,name:i,providers:a,inferenceProviders:[],features:s,group:!0,capabilities:o,contextWindows:c,queryPermissions:!0,queryApplyStatus:!0,queryActivationStatus:!0,queryPrice:!0,queryQpmInfo:!0,supports:{inference:!0}};l&&(u.querySampleCode=!0);let d=fy(await e(uy,{input:u}));return{total:d.total??0,groups:d.list??[]}}function _y(e){return e.flatMap(e=>e.items??[])}async function vy(e,t={}){let n=t.pageSize??50,r=await gy(e,{...t,pageNo:1,pageSize:n}),i=Math.max(1,Math.ceil(r.total/n)),a=[];for(let e=2;e<=i;e++)a.push(e);let o=await Promise.all(a.map(r=>gy(e,{...t,pageNo:r,pageSize:n})));return _y([r.groups,...o.map(e=>e.groups)].flat())}async function yy(e,t){return(fy(await e(`zeldaHttp.dashscopeModel./zelda/api/v1/modelCenter/listFoundationModels`,{input:{pageNo:1,pageSize:50,group:!0,model:t,querySampleCode:!0,queryGroupByModel:!0,queryWorkspaceLimit:!0,queryPrice:!0,queryQuota:!1,queryQpmInfo:!0,queryApplyStatus:!0,queryPermissions:!0,queryActivationStatus:!0}})).list??[])[0]??null}const by=[`name`,`key`,`default`,`tip`,`range`];function xy(e){return e.map(e=>{let t={};for(let n of by)e[n]!==void 0&&(t[n]=e[n]);return t})}async function Sy(e,t){let n=fy(await e(dy,{modelId:t})).predictConfig;if(!n)return null;if(typeof n==`string`)try{let e=JSON.parse(n);return Array.isArray(e)?xy(e):null}catch{return null}return Array.isArray(n)?xy(n):null}function Cy(e){return{read:()=>fn(e),async write(t){let n=fn(e);for(let[e,r]of Object.entries(t))r===void 0?delete n[e]:n[e]=e===`base_url`?yt(String(r)):r;await pn(n,e)},async unset(t){let n=fn(e);for(let e of t)delete n[e];await pn(n,e)},profiles:()=>hn(),activate:e=>vn(e),validateActivation:e=>_n(e),get path(){return Jt()}}}const wy=`{{commandPrefix}}`;function Ty(e,t=[],n=[]){return{bin:e.commandInvocation?.bin??e.binName,path:[...e.commandInvocation?.path??[],...t],args:[...n]}}function Ey(e,t=``){let n=typeof e==`string`?e:[e.commandInvocation?.bin??e.binName,...e.commandInvocation?.path??[]].join(` `);return t?`${n} ${t}`:n}function Dy(e=``){return Ey(wy,e)}function Oy(e,t){return e.split(wy).join(Ey(t))}const ky=`zeldaEasy.bmp.ossRpcService.download`;function Ay(e){if(typeof e!=`string`||!/^https?:\/\//i.test(e))return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}async function jy(e,t){let n=ly(await e.console(ky,{fileKey:t}));if(typeof n!=`object`||!n||Array.isArray(n)||!(`url`in n)||!Ay(n.url))throw new O(`Console file URL response must be an object with a valid HTTP(S) URL. / Console 文件地址响应必须是包含有效 HTTP(S) URL 的对象。`,D.GENERAL);return n}async function My(e,t){let{filePath:n,purpose:i=`fine-tune`,signal:a}=t,o=t.fileBlob?.size??d(n).size,s=g(n),c=t.fileBlob??await new Response(le.toWeb(r(n))).blob(),l=new FormData;l.append(`file`,c,s),l.append(`purpose`,i);let u=await e.requestJson({path:$g(),method:`POST`,body:l,headers:t.workspaceId?{"X-DashScope-WorkSpace":t.workspaceId}:void 0,signal:a});if(u.id)return{file_id:u.id,name:u.filename??s,size:u.bytes??o,purpose:u.purpose??i,gmt_create:u.created_at?(/* @__PURE__ */ new Date(u.created_at*1e3)).toISOString():void 0,request_id:u.request_id};let f=u.data?.failed_uploads;if(Array.isArray(f)&&f.length>0){let e=f[0]??{};throw new O(e.message??`Upload failed without a service message. / 上传失败,服务端未提供错误消息。`,D.GENERAL,void 0,{api:{httpStatus:200,apiCode:e.code,requestId:u.request_id},rawResponse:JSON.stringify(u)})}throw new O(`Upload response for ${s} has no usable file ID. / ${s} 的上传响应缺少可用文件 ID。`,D.GENERAL,`Success cannot be verified; inspect the file list before retrying. / 无法验证上传成功,请先检查文件列表,再决定是否重试。`,{api:{httpStatus:200,requestId:u.request_id},rawResponse:JSON.stringify(u)})}async function Ny(e,t={}){let n=new URLSearchParams;t.pageNo!==void 0&&n.set(`page_no`,String(t.pageNo)),t.pageSize!==void 0&&n.set(`page_size`,String(t.pageSize)),t.purpose&&n.set(`purpose`,t.purpose);let r=e_(),i=n.toString()?`${r}?${n.toString()}`:r;return e.requestJson({path:i,method:`GET`,signal:t.signal})}async function Py(e,t,n){return e.requestJson({path:t_(t),method:`GET`,signal:n})}async function Fy(e,t,n){let r=await e.request({path:t_(t),method:`DELETE`,signal:n});try{return await r.json()}catch{return{data:{deleted:!0,file_id:t}}}}const Iy=`zeldaEasy.broadscope-platform.dataset.queryByDatasetId.m_efm`,Ly=`zeldaEasy.broadscope-platform.dataset.query.m_efm`,Ry=`zeldaEasy.broadscope-platform.datasetGroup.query.m_efm`;function zy(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function By(e){return typeof e==`string`&&e.trim().length>0}function Vy(e,t){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=t}function Hy(e={}){return{input:{datasetGroupPageNo:e.page??1,datasetGroupPageSize:e.pageSize??10,...e.name===void 0?{}:{name:e.name},datasetPageSize:1,datasetTaskTypeList:[0],datasetTaskPageSize:1}}}async function Uy(e,t={}){let n=ly(await e.console(Ry,Hy(t)));if(!zy(n)||!Array.isArray(n.records)||!n.records.every(e=>zy(e)&&By(e.datasetGroupId))||!Vy(n.page,1)||!Vy(n.itemsPerPage,1)||!Vy(n.items,0)||n.pageCount!==void 0&&!Vy(n.pageCount,0))throw new O(`Invalid Console dataset groups page: expected records with datasetGroupId and valid page/itemsPerPage/items. / Console 数据集组分页响应无效:需要包含 datasetGroupId 的 records 以及有效的 page/itemsPerPage/items。`,D.GENERAL);return n}function Wy(e){return{input:{datasetGroupId:e,datasetTaskTypeList:[0],datasetTaskPageSize:1}}}function Gy(e){let t=Array.isArray(e)?{result:e}:e;if(!zy(t)||!Array.isArray(t.result)||!t.result.every(zy))throw new O(`Console dataset version response must be an object array or contain a result array of objects. / Console 数据集版本响应必须为对象数组或包含对象数组 result。`,D.GENERAL);return t}async function Ky(e,t){let n=Gy(ly(await e.console(Ly,Wy(t))));if(!n.result.every(e=>By(e.datasetId)&&(e.datasetGroupId===void 0||e.datasetGroupId===t)))throw new O(`Console dataset versions have missing version IDs or belong to another dataset group. / Console 数据集版本缺少版本 ID 或属于其他数据集组。`,D.GENERAL);return n}async function qy(e,t){let n=ly(await e.console(Iy,{input:{datasetId:t}}));if(!zy(n)||![n.datasetId,n.datasetGroupId,n.datasetName].some(e=>typeof e==`string`&&e.trim()))throw new O(`Console dataset query returned no usable metadata. / Console 数据集查询未返回可用元信息。`,D.GENERAL);if(n.datasetId!==void 0&&n.datasetId!==t)throw new O(`Console dataset response does not match the requested version ID. / Console 数据集响应与请求的版本 ID 不匹配。`,D.GENERAL);return n}function Jy(e,t){return{input:{datasetId:e,datasetGroupId:t,page:1,itemsPerPage:1,datasetTaskTypeList:[0],datasetTaskPageSize:1}}}async function Yy(e,t,n){let r=Gy(ly(await e.console(Ly,Jy(t,n)))).result.filter(e=>e.datasetId===t);if(r.length>1)throw new O(`Console dataset query returned multiple matches for one version ID. / Console 数据集查询为同一版本 ID 返回了多个匹配项。`,D.GENERAL);let i=r[0]??null;if(i&&i.datasetGroupId!==void 0&&i.datasetGroupId!==n)throw new O(`Console dataset version belongs to a different dataset group. / Console 数据集版本所属组与查询目标不匹配。`,D.GENERAL);return i}function Xy(e){let t=e&&zy(e.datasetTaskDTO)?e.datasetTaskDTO:void 0;return{release_status:e?.releaseStatus==null?`missing`:`returned`,import_status:t?.taskStatus==null?`missing`:`returned`}}const Zy=209715200,Qy=314572800,$y=314572800,eb=2147483648;function tb(e,t=Zy){if(!a(e))throw new O(`File not found: ${e}`,D.USAGE);let n=d(e);if(!n.isFile())throw new O(`Not a regular file: ${e}`,D.USAGE);if(n.size===0)throw new O(`File is empty: ${e}`,D.USAGE);if(n.size>t)throw new O(`File too large: ${(n.size/1048576).toFixed(1)}MB exceeds the ${(t/1048576).toFixed(0)}MB dataset upload cap.`,D.USAGE);return{bytes:n.size,ext:_(e).toLowerCase()}}function Z(e,t,n,r={}){return{severity:e,code:t,message:n,...r}}function nb(e){if(e===void 0||e.trim()===``)return;let t=e.trim();if(t===`chatml`||t===`dpo`||t===`cpt`||t===`decision`||t===`tts`||t===`image`||t===`video`)return t;throw new O(`Unsupported --schema "${e}". Supported: chatml, dpo, cpt, decision, tts, image, video. / 不支持的 --schema;可选值:chatml、dpo、cpt、decision、tts、image、video。`,D.USAGE,`Omit --schema to auto-detect per record (state/questions → decision, chosen/rejected → DPO, text → CPT, wav_fn → TTS, img_path → image, first_frame_path/video_path → video, else ChatML). / 省略 --schema 可逐条自动识别。`)}function rb(e,t=50,n=100,r=10){if(e<=0)return[];if(e<=t+r)return Array.from({length:e},(e,t)=>t+1);let i=/* @__PURE__ */ new Set;for(let n=1;n<=Math.min(t,e);n++)i.add(n);for(let t=0;t<r;t++)i.add(e-t);let a=Math.max(1,Math.ceil(e/n));for(let n=t+1;n<=e-r;n+=a)i.add(n);return[...i].filter(t=>t>=1&&t<=e).sort((e,t)=>e-t)}const ib=/* @__PURE__ */ new Set([`system`,`user`,`assistant`,`tool`]),ab=.1;function ob(e,t,n,r){let i=[],a=t=>{if(!(t in e))return;let a=e[t];(typeof a!=`number`||a<ab||a>10)&&i.push(Z(`error`,`INVALID_VIDEO_FPS`,`"${t}" must be a number between ${ab} and 10 (got ${JSON.stringify(a)}).`,{line:n,path:`${r}.${t}`}))};a(`fps`),a(`sample_fps`);let o=t?[`fps`,`video_start`,`video_end`]:[`sample_fps`],s=t?`frame-list`:`file-path`;for(let t of o)t in e&&i.push(Z(`warning`,`VIDEO_PARAM_MODE_MISMATCH`,`"${t}" does not apply to ${s} video mode and will be ignored by the platform.`,{line:n,path:`${r}.${t}`}));for(let a of[`video_start`,`video_end`])a in e&&!t&&typeof e[a]!=`number`&&i.push(Z(`error`,`INVALID_VIDEO_CLIP_TIME`,`"${a}" must be a number (seconds).`,{line:n,path:`${r}.${a}`}));return i}function sb(e,t,n){let r=[];if(typeof e==`string`)return r;if(!Array.isArray(e))return r.push(Z(`error`,`INVALID_CONTENT`,`"content" must be a string or an array of content items (got ${typeof e}).`,{line:t,path:n})),r;if(e.length===0)return r.push(Z(`error`,`EMPTY_CONTENT_ARRAY`,`"content" array must not be empty.`,{line:t,path:n})),r;for(let i=0;i<e.length;i++){let a=e[i],o=`${n}[${i}]`;if(typeof a!=`object`||!a||Array.isArray(a)){r.push(Z(`error`,`INVALID_CONTENT_ITEM`,`Content item must be an object.`,{line:t,path:o}));continue}let s=a,c=`text`in s,l=`image`in s,u=`video`in s;if(!c&&!l&&!u){r.push(Z(`error`,`CONTENT_ITEM_NO_KNOWN_FIELD`,`Content item must contain at least one of: "text", "image", "video".`,{line:t,path:o}));continue}if(c&&typeof s.text!=`string`&&r.push(Z(`error`,`INVALID_CONTENT_TEXT`,`"text" in content item must be a string.`,{line:t,path:`${o}.text`})),l&&typeof s.image!=`string`&&r.push(Z(`error`,`INVALID_CONTENT_IMAGE`,`"image" in content item must be a string.`,{line:t,path:`${o}.image`})),u){let e=s.video;if(typeof e!=`string`&&!Array.isArray(e))r.push(Z(`error`,`INVALID_CONTENT_VIDEO`,`"video" in content item must be a string (file path) or an array of strings (frame list).`,{line:t,path:`${o}.video`}));else{if(Array.isArray(e))for(let n=0;n<e.length;n++)typeof e[n]!=`string`&&r.push(Z(`error`,`INVALID_VIDEO_FRAME`,`Video frame list item at index ${n} must be a string.`,{line:t,path:`${o}.video[${n}]`}));r.push(...ob(s,Array.isArray(e),t,o))}}}return r}function cb(e,t,n){let r=[];if(!Array.isArray(e))return r.push(Z(`error`,`INVALID_TOOL_CALLS`,`"tool_calls" must be an array.`,{line:t,path:n})),r;for(let i=0;i<e.length;i++){let a=e[i],o=`${n}[${i}]`;if(typeof a!=`object`||!a||Array.isArray(a)){r.push(Z(`error`,`INVALID_TOOL_CALL`,`tool_calls item must be an object.`,{line:t,path:o}));continue}let s=a;(typeof s.id!=`string`||s.id.length===0)&&r.push(Z(`error`,`TOOL_CALL_MISSING_ID`,`tool_calls item must have a non-empty "id".`,{line:t,path:`${o}.id`})),s.type!==`function`&&r.push(Z(`warning`,`TOOL_CALL_TYPE_NOT_FUNCTION`,`tool_calls item "type" should be "function" (got "${String(s.type)}").`,{line:t,path:`${o}.type`}));let c=s.function;if(typeof c!=`object`||!c||Array.isArray(c))r.push(Z(`error`,`TOOL_CALL_MISSING_FUNCTION`,`tool_calls item must have a "function" object.`,{line:t,path:`${o}.function`}));else{let e=c;(typeof e.name!=`string`||e.name.length===0)&&r.push(Z(`error`,`TOOL_CALL_FN_NO_NAME`,`tool_calls function must have a "name".`,{line:t,path:`${o}.function.name`})),typeof e.arguments!=`string`&&r.push(Z(`error`,`TOOL_CALL_FN_ARGS_NOT_STRING`,`tool_calls function "arguments" must be a JSON string.`,{line:t,path:`${o}.function.arguments`}))}}return r}function lb(e,t,n){let r=[];if(typeof e!=`object`||!e||Array.isArray(e))return r.push(Z(`error`,`MESSAGE_NOT_OBJECT`,`Message must be an object.`,{line:t,path:n})),r;let i=e,a=i.role;return(typeof a!=`string`||!ib.has(a))&&r.push(Z(`error`,`INVALID_ROLE`,`Invalid role "${String(a)}". Expected one of: system, user, assistant, tool.`,{line:t,path:`${n}.role`})),a===`tool`&&(typeof i.tool_call_id!=`string`||i.tool_call_id.length===0)&&r.push(Z(`error`,`TOOL_MISSING_CALL_ID`,`A "tool" role message must have a non-empty "tool_call_id".`,{line:t,path:`${n}.tool_call_id`})),`content`in i?r.push(...sb(i.content,t,`${n}.content`)):(a!==`assistant`||!(`tool_calls`in i))&&r.push(Z(`error`,`MISSING_CONTENT`,`"content" field is missing.`,{line:t,path:`${n}.content`})),`tool_calls`in i&&r.push(...cb(i.tool_calls,t,`${n}.tool_calls`)),`name`in i&&r.push(Z(`error`,`UNSUPPORTED_FIELD_NAME`,`Field "name" is not supported by Bailian and must be removed when migrating from OpenAI/Azure.`,{line:t,path:`${n}.name`})),`weight`in i&&r.push(Z(`error`,`UNSUPPORTED_FIELD_WEIGHT`,`Field "weight" is not supported by Bailian and must be removed when migrating from OpenAI/Azure. All assistant outputs are trained; per-line importance uses "loss_weight" (invite-only).`,{line:t,path:`${n}.weight`})),r}function ub(e,t){let n=[],r=e.messages;if(!Array.isArray(r))return n.push(Z(`error`,`MISSING_MESSAGES`,`Required field "messages" is missing or not an array.`,{line:t,path:`messages`})),n;if(r.length===0)return n.push(Z(`error`,`EMPTY_MESSAGES`,`"messages" must contain at least one entry.`,{line:t,path:`messages`})),n;let i=!1,a,o=-1,s=/* @__PURE__ */ new Set,c=/* @__PURE__ */ new Set;for(let e=0;e<r.length;e++){let l=r[e],u=`messages[${e}]`;n.push(...lb(l,t,u));let d=l,f=d?.role;if(f===`system`&&(e!==0&&n.push(Z(`warning`,`SYSTEM_NOT_FIRST`,`"system" message should appear at index 0; found at index ${e}.`,{line:t,path:`${u}.role`})),i=!0),f===`assistant`&&(o=e,d&&Array.isArray(d.tool_calls)))for(let e of d.tool_calls){let t=e;t&&typeof t.id==`string`&&s.add(t.id)}if(f===`tool`){let e=d?.tool_call_id;typeof e==`string`&&e.length>0&&c.add(e)}a===f&&(f===`user`||f===`assistant`)&&n.push(Z(`warning`,`ROLE_NOT_ALTERNATING`,`Consecutive ${f} messages — user/assistant turns should typically alternate.`,{line:t,path:`${u}.role`})),typeof f==`string`&&(a=f)}r.some(e=>e.role===`user`)||n.push(Z(`warning`,`NO_USER_ROLE`,`No "user" message found in this sample.`,{line:t,path:`messages`})),i&&r.length===1&&n.push(Z(`warning`,`SYSTEM_ONLY`,`Sample only contains a "system" message.`,{line:t,path:`messages`}));for(let e of c)s.has(e)||n.push(Z(`error`,`TOOL_CALL_ID_UNMATCHED`,`tool message references tool_call_id "${e}" which does not match any assistant tool_calls[].id.`,{line:t,path:`messages`}));for(let e of s)c.has(e)||n.push(Z(`warning`,`TOOL_CALL_NO_RESPONSE`,`assistant tool_calls[].id "${e}" has no matching tool response message.`,{line:t,path:`messages`}));if(o>=0)for(let e=0;e<r.length;e++){if(e===o)continue;let i=r[e];if(i?.role!==`assistant`||i&&Array.isArray(i.tool_calls))continue;let a=i?.content;db(a)&&n.push(Z(`warning`,`THINK_TAG_NOT_LAST`,`Thinking tags (<think>…</think>) should only appear in the last assistant message (or an assistant message carrying tool_calls), found at messages[${e}].`,{line:t,path:`messages[${e}].content`}))}let l=(e,r)=>{(typeof e!=`number`||e<0||e>1)&&n.push(Z(`error`,`INVALID_LOSS_WEIGHT`,`"loss_weight" must be a number between 0.0 and 1.0 (got ${JSON.stringify(e)}).`,{line:t,path:r}))};`loss_weight`in e&&l(e.loss_weight,`loss_weight`);for(let e=0;e<r.length;e++){let i=r[e];i&&`loss_weight`in i&&(l(i.loss_weight,`messages[${e}].loss_weight`),(i.role!==`assistant`||e!==o)&&n.push(Z(`warning`,`LOSS_WEIGHT_PLACEMENT`,`"loss_weight" is only supported on the last assistant message; found at messages[${e}] (role "${String(i.role)}").`,{line:t,path:`messages[${e}].loss_weight`})))}return`weight`in e&&n.push(Z(`error`,`UNSUPPORTED_FIELD_WEIGHT`,`Record-level field "weight" is not supported by Bailian and must be removed when migrating from OpenAI/Azure.`,{line:t,path:`weight`})),n}function db(e){return typeof e==`string`?e.includes(`<think>`):Array.isArray(e)?e.some(e=>e&&typeof e==`object`&&`text`in e?typeof e.text==`string`&&e.text.includes(`<think>`):!1):!1}const fb={name:`chatml`,detect:()=>!0,inspect:ub};function pb(e,t){let n=[];if(!(`text`in e))return n.push(Z(`error`,`MISSING_TEXT`,`Required field "text" is missing.`,{line:t,path:`text`})),n;let r=e.text;return typeof r==`string`?(r.trim().length===0&&n.push(Z(`error`,`EMPTY_TEXT`,`"text" must not be empty / whitespace-only.`,{line:t,path:`text`})),n):(n.push(Z(`error`,`INVALID_TEXT`,`"text" must be a string (got ${typeof r}).`,{line:t,path:`text`})),n)}const mb={name:`cpt`,detect:e=>`text`in e&&!(`messages`in e),inspect:pb};function hb(e,t){let n=ub(e,t),r=e.messages;if(!Array.isArray(r)||r.length===0)return n;let i=(e,n)=>{if(!Array.isArray(e))return[];let r=[];for(let i=0;i<e.length;i++){let a=e[i];if(a&&typeof a==`object`)for(let e of[`image`,`video`])e in a&&r.push(Z(`error`,`DPO_UNSUPPORTED_ELEMENT`,`DPO training data does not support ${e} inputs; found at ${n}.content[${i}].`,{line:t,path:`${n}.content[${i}].${e}`}))}return r};`tools`in e&&n.push(Z(`error`,`DPO_UNSUPPORTED_ELEMENT`,`DPO training data does not support tool calling; remove the "tools" definition.`,{line:t,path:`tools`}));for(let e=0;e<r.length;e++){let a=r[e];if(!a)continue;let o=`messages[${e}]`;(a.role===`tool`||`tool_calls`in a)&&n.push(Z(`error`,`DPO_UNSUPPORTED_ELEMENT`,`DPO training data does not support tool calling; found ${a.role===`tool`?`role "tool"`:`"tool_calls"`} at ${o}.`,{line:t,path:o})),n.push(...i(a.content,o))}let a=r[r.length-1];a&&a.role!==`user`&&n.push(Z(`error`,`DPO_LAST_MSG_NOT_USER`,`DPO "messages" must end with a "user" message (the prompt for chosen/rejected). Got "${String(a.role)}" as the last message.`,{line:t,path:`messages[${r.length-1}].role`}));let o=`chosen`in e,s=`rejected`in e;if(o||n.push(Z(`error`,`MISSING_CHOSEN`,`DPO record is missing the "chosen" preference.`,{line:t,path:`chosen`})),s||n.push(Z(`error`,`MISSING_REJECTED`,`DPO record is missing the "rejected" preference.`,{line:t,path:`rejected`})),o){n.push(...lb(e.chosen,t,`chosen`)),n.push(...i(e.chosen?.content,`chosen`));let r=e.chosen?.role;typeof r==`string`&&r!==`assistant`&&n.push(Z(`warning`,`PREFERENCE_ROLE_NOT_ASSISTANT`,`"chosen" role should be "assistant" (got "${r}").`,{line:t,path:`chosen.role`}))}if(s){n.push(...lb(e.rejected,t,`rejected`)),n.push(...i(e.rejected?.content,`rejected`));let r=e.rejected?.role;typeof r==`string`&&r!==`assistant`&&n.push(Z(`warning`,`PREFERENCE_ROLE_NOT_ASSISTANT`,`"rejected" role should be "assistant" (got "${r}").`,{line:t,path:`rejected.role`}))}return n}const gb={name:`dpo`,detect:e=>`chosen`in e||`rejected`in e,inspect:hb},_b=[`choice`,`noul`,`score`],vb=255,yb=2,bb=255,xb=/* @__PURE__ */ new Set([`true`,`false`]);function Sb(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Cb(e){return typeof e==`string`&&e.trim().length>0}function wb(e,t,n,r){return{code:e,path:t,message:{"en-US":n,"zh-CN":r}}}function Tb(e,t=`state`){return Cb(e)||Array.isArray(e)&&e.length>0||Sb(e)&&Object.keys(e).length>0?[]:[wb(`DECISION_INVALID_STATE`,t,`"${t}" must be a non-empty string, object, or array.`,`"${t}" 必须是非空字符串、对象或数组。`)]}function Eb(e,t){let n=`${t}.criteria`;if(!Sb(e))return[wb(`DECISION_INVALID_CHOICE_CRITERIA`,n,`"${n}" must be an option-to-description object.`,`"${n}" 必须是“选项名到描述”的对象。`)];let r=Object.keys(e).length;if(r<1||r>255)return[wb(`DECISION_INVALID_CHOICE_CRITERIA`,n,`"${n}" must contain 1-255 options (got ${r}).`,`"${n}" 必须包含 1-255 个选项(当前 ${r} 个)。`)];for(let[t,r]of Object.entries(e))if(!Cb(t)||!Cb(r))return[wb(`DECISION_INVALID_CHOICE_CRITERIA`,`${n}.${t}`,`Choice option names and descriptions in "${n}" must be non-empty strings.`,`"${n}" 中的选项名和描述必须是非空字符串。`)];return[]}function Db(e,t){let n=`${t}.criteria`;return!Array.isArray(e)||e.some(e=>!Cb(e))?[wb(`DECISION_INVALID_SCORE_CRITERIA`,n,`"${n}" must be an array of non-empty level descriptions, from low to high.`,`"${n}" 必须是从低到高排列、由非空等级描述组成的数组。`)]:e.length<2||e.length>255?[wb(`DECISION_INVALID_SCORE_CRITERIA`,n,`"${n}" must contain 2-255 levels (got ${e.length}).`,`"${n}" 必须包含 2-255 个等级(当前 ${e.length} 个)。`)]:[]}function Ob(e,t){if(e===void 0)return[];let n=`${t}.criteria`;return Sb(e)&&Object.entries(e).every(([e,t])=>xb.has(e)&&typeof t==`string`)?[]:[wb(`DECISION_INVALID_NOUL_CRITERIA`,n,`"${n}" is optional; when provided it must be an object with only "true" / "false" string descriptions.`,`"${n}" 为可选项;填写时必须是只包含 "true" / "false" 字符串描述的对象。`)]}function kb(e,t){if(!Sb(e))return[wb(`DECISION_QUESTION_NOT_OBJECT`,t,`"${t}" must be an object.`,`"${t}" 必须是对象。`)];let n=[];return e.instructions!==void 0&&typeof e.instructions!=`string`&&n.push(wb(`DECISION_INVALID_INSTRUCTIONS`,`${t}.instructions`,`"${t}.instructions" must be a string when provided.`,`"${t}.instructions" 填写时必须是字符串。`)),e.type===`choice`?n.push(...Eb(e.criteria,t)):e.type===`noul`?n.push(...Ob(e.criteria,t)):e.type===`score`?n.push(...Db(e.criteria,t)):n.push(wb(`DECISION_INVALID_QUESTION_TYPE`,`${t}.type`,`"${t}.type" must be choice, noul, or score.`,`"${t}.type" 必须是 choice、noul 或 score。`)),n}function Ab(e,t=`questions`){return Sb(e)&&Object.keys(e).length>0?[]:[wb(`DECISION_INVALID_QUESTIONS`,t,`"${t}" must be a non-empty object keyed by question ID.`,`"${t}" 必须是以问题 ID 为键的非空对象。`)]}function jb(e,t=`questions`){return Cb(e)?[]:[wb(`DECISION_INVALID_QUESTION_ID`,t,`Question IDs must be non-empty strings.`,`问题 ID 必须是非空字符串。`)]}function Mb(e,t=`questions`){let n=Ab(e,t);if(n.length>0)return n;let r=[];for(let[n,i]of Object.entries(e)){let e=jb(n,t);if(e.length>0){r.push(...e);continue}r.push(...kb(i,`${t}.${n}`))}return r}function Nb(e,t,n,r){return Z(`error`,e,t,{line:n,path:r})}function Pb(e,t){return Nb(e.code,`${e.message[`en-US`]} / ${e.message[`zh-CN`]}`,t,e.path)}function Fb(e,t,n,r){if(!Sb(e))return[Nb(`DECISION_INVALID_TARGET`,`"${r}" must be an object containing a complete probability distribution. / "${r}" 必须是包含完整概率分布的对象。`,n,r)];let i=Object.keys(e).sort(),a=[...t].sort();if(i.length!==a.length||i.some((e,t)=>e!==a[t]))return[Nb(`DECISION_INVALID_TARGET_KEYS`,`"${r}" must contain exactly these keys: ${a.join(`, `)}. / "${r}" 必须且只能包含这些键:${a.join(`, `)}。`,n,r)];let o=0;for(let t of a){let i=e[t];if(typeof i!=`number`||!Number.isFinite(i)||i<0||i>1)return[Nb(`DECISION_INVALID_TARGET_PROBABILITY`,`"${r}.${t}" must be a finite number in [0, 1]. / "${r}.${t}" 必须是 [0, 1] 范围内的有限数字。`,n,`${r}.${t}`)];o+=i}return Math.abs(o-1)>1e-6?[Nb(`DECISION_TARGET_SUM_NOT_ONE`,`Probabilities in "${r}" must sum to 1 (got ${o}). / "${r}" 中的概率之和必须为 1(当前为 ${o})。`,n,r)]:[]}function Ib(e,t,n){let r=Object.keys(e.criteria);return typeof e.label!=`string`||!r.includes(e.label)?[Nb(`DECISION_INVALID_CHOICE_LABEL`,`"${n}.label" must be one of: ${r.join(`, `)}. / "${n}.label" 必须是以下选项之一:${r.join(`, `)}。`,t,`${n}.label`)]:e.target===void 0?[]:Fb(e.target,r,t,`${n}.target`)}function Lb(e,t,n){return typeof e.label==`boolean`?e.target===void 0?[]:Fb(e.target,[`true`,`false`],t,`${n}.target`):[Nb(`DECISION_INVALID_NOUL_LABEL`,`"${n}.label" must be true or false. / "${n}.label" 必须是 true 或 false。`,t,`${n}.label`)]}function Rb(e,t,n){let r=e.criteria.length;if(typeof e.label!=`number`||!Number.isInteger(e.label)||e.label<0||e.label>=r)return[Nb(`DECISION_INVALID_SCORE_LABEL`,`"${n}.label" must be an integer from 0 to ${r-1}. / "${n}.label" 必须是 0 到 ${r-1} 之间的整数。`,t,`${n}.label`)];let i=Array.from({length:r},(e,t)=>String(t));return e.target===void 0?[]:Fb(e.target,i,t,`${n}.target`)}function zb(e,t){let n=Tb(e.state).map(e=>Pb(e,t)),r=e.questions,i=Ab(r);if(i.length>0)return n.push(...i.map(e=>Pb(e,t))),n;for(let[e,i]of Object.entries(r)){let r=jb(e);if(r.length>0){n.push(...r.map(e=>Pb(e,t)));continue}let a=`questions.${e}`,o=kb(i,a);if(o.length>0){n.push(...o.map(e=>Pb(e,t)));continue}let s=i;s.type===`choice`?n.push(...Ib(s,t,a)):s.type===`noul`?n.push(...Lb(s,t,a)):n.push(...Rb(s,t,a))}return n}const Bb={name:`decision`,detect:e=>!(`messages`in e)&&(`questions`in e||`state`in e),inspect:zb};function Vb(e,t){let n=[];if(!(`wav_fn`in e))n.push(Z(`error`,`MISSING_WAV_FN`,`Required field "wav_fn" is missing.`,{line:t,path:`wav_fn`}));else{let r=e.wav_fn;if(typeof r!=`string`)n.push(Z(`error`,`INVALID_WAV_FN`,`"wav_fn" must be a string (got ${typeof r}).`,{line:t,path:`wav_fn`}));else if(r.trim().length===0)n.push(Z(`error`,`EMPTY_WAV_FN`,`"wav_fn" must not be empty.`,{line:t,path:`wav_fn`}));else{r.startsWith(`train/`)||n.push(Z(`error`,`WAV_FN_PREFIX`,`"wav_fn" must start with "train/" (got "${r}").`,{line:t,path:`wav_fn`}));let e=r.lastIndexOf(`.`),i=e>=0?r.slice(e).toLowerCase():``;i!==`.wav`&&n.push(Z(`error`,`INVALID_AUDIO_EXT`,`"wav_fn" must reference a .wav file (got "${i||`(none)`}"). CosyVoice training audio must be WAV.`,{line:t,path:`wav_fn`}))}}if(!(`text`in e))n.push(Z(`error`,`MISSING_TEXT`,`Required field "text" is missing.`,{line:t,path:`text`}));else{let r=e.text;typeof r==`string`?r.trim().length===0&&n.push(Z(`error`,`EMPTY_TEXT`,`"text" must not be empty / whitespace-only.`,{line:t,path:`text`})):n.push(Z(`error`,`INVALID_TEXT`,`"text" must be a string (got ${typeof r}).`,{line:t,path:`text`}))}return n}const Hb={name:`tts`,detect:e=>`wav_fn`in e,inspect:Vb},Ub=/* @__PURE__ */ new Set([`.png`,`.jpg`,`.jpeg`,`.bmp`,`.tif`,`.tiff`,`.webp`]);function Wb(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t).toLowerCase():``}function Gb(e){return/^[\x20-\x7E]+$/.test(e)}function Kb(e,t){let n=[];if(!(`prompt`in e))n.push(Z(`error`,`MISSING_PROMPT`,`Required field "prompt" is missing.`,{line:t,path:`prompt`}));else{let r=e.prompt;typeof r==`string`?r.trim().length===0&&n.push(Z(`error`,`EMPTY_PROMPT`,`"prompt" must not be empty / whitespace-only.`,{line:t,path:`prompt`})):n.push(Z(`error`,`INVALID_PROMPT`,`"prompt" must be a string (got ${typeof r}).`,{line:t,path:`prompt`}))}if(!(`img_path`in e))n.push(Z(`error`,`MISSING_IMG_PATH`,`Required field "img_path" is missing.`,{line:t,path:`img_path`}));else{let r=e.img_path;if(typeof r!=`string`)n.push(Z(`error`,`INVALID_IMG_PATH`,`"img_path" must be a string (got ${typeof r}).`,{line:t,path:`img_path`}));else if(r.trim().length===0)n.push(Z(`error`,`EMPTY_IMG_PATH`,`"img_path" must not be empty.`,{line:t,path:`img_path`}));else{let e=Wb(r);Ub.has(e)||n.push(Z(`warning`,`UNUSUAL_IMAGE_EXT`,`"img_path" points to a non-standard image extension "${e||`(none)`}". Expected one of: ${[...Ub].join(`, `)}.`,{line:t,path:`img_path`})),Gb(r)||n.push(Z(`error`,`NON_ASCII_IMG_PATH`,`"img_path" must contain only ASCII characters (English filenames required). Got: "${r}".`,{line:t,path:`img_path`}))}}if(`input_img`in e){let r=e.input_img;if(typeof r!=`string`)n.push(Z(`error`,`INVALID_INPUT_IMG`,`"input_img" must be a string (got ${typeof r}).`,{line:t,path:`input_img`}));else if(r.trim().length===0)n.push(Z(`error`,`EMPTY_INPUT_IMG`,`"input_img" must not be empty.`,{line:t,path:`input_img`}));else{let e=Wb(r);Ub.has(e)||n.push(Z(`warning`,`UNUSUAL_INPUT_IMG_EXT`,`"input_img" points to a non-standard image extension "${e||`(none)`}". Expected one of: ${[...Ub].join(`, `)}.`,{line:t,path:`input_img`})),Gb(r)||n.push(Z(`error`,`NON_ASCII_INPUT_IMG`,`"input_img" must contain only ASCII characters (English filenames required). Got: "${r}".`,{line:t,path:`input_img`}))}}return n}const qb={name:`image`,detect:e=>`img_path`in e,inspect:Kb},Jb=/* @__PURE__ */ new Set([`.png`,`.jpg`,`.jpeg`,`.bmp`,`.webp`]),Yb=/* @__PURE__ */ new Set([`.mp4`,`.mov`]);function Xb(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t).toLowerCase():``}function Zb(e){return/^[\x20-\x7E]+$/.test(e)}function Qb(e,t,n,r,i,a){if(!(n in t)){r&&e.push(Z(`error`,`MISSING_FIELD`,`Required field "${n}" is missing.`,{line:a,path:n}));return}let o=t[n];if(typeof o!=`string`){e.push(Z(`error`,`INVALID_FIELD`,`"${n}" must be a string (got ${typeof o}).`,{line:a,path:n}));return}if(o.trim().length===0){e.push(Z(`error`,`EMPTY_FIELD`,`"${n}" must not be empty.`,{line:a,path:n}));return}let s=Xb(o);i.has(s)||e.push(Z(`warning`,`UNUSUAL_MEDIA_EXT`,`"${n}" points to a non-standard extension "${s||`(none)`}". Expected one of: ${[...i].join(`, `)}.`,{line:a,path:n})),Zb(o)||e.push(Z(`error`,`NON_ASCII_PATH`,`"${n}" must contain only ASCII characters (English filenames required). Got: "${o}".`,{line:a,path:n}))}function $b(e,t){let n=[];if(!(`prompt`in e))n.push(Z(`error`,`MISSING_PROMPT`,`Required field "prompt" is missing.`,{line:t,path:`prompt`}));else{let r=e.prompt;typeof r==`string`?r.trim().length===0&&n.push(Z(`error`,`EMPTY_PROMPT`,`"prompt" must not be empty / whitespace-only.`,{line:t,path:`prompt`})):n.push(Z(`error`,`INVALID_PROMPT`,`"prompt" must be a string (got ${typeof r}).`,{line:t,path:`prompt`}))}return Qb(n,e,`first_frame_path`,!0,Jb,t),Qb(n,e,`last_frame_path`,!1,Jb,t),Qb(n,e,`video_path`,!1,Yb,t),n}const ex=[Hb,qb,{name:`video`,detect:e=>`first_frame_path`in e||`video_path`in e,inspect:$b},Bb,gb,mb,fb];function tx(e,t){return t===void 0?ex.find(t=>t.detect(e))??fb:ex.find(e=>e.name===t)||fb}async function nx(e,t){let n=r(e,{encoding:`utf8`}),i=ue({input:n,crlfDelay:1/0}),a=[],o=0,s=0;for await(let e of i){if(t?.aborted)break;o++;let n=e.trim();if(n.length===0){s++;continue}a.length>=20||(n[0]!==`{`||n[n.length-1]!==`}`)&&a.push(Z(`error`,`MALFORMED_LINE`,`Line does not start with '{' and end with '}'. JSONL requires one minified JSON object per line — pretty-printed JSON or arrays are not accepted here.`,{line:o}))}return{totalLines:o,blankLines:s,issues:a}}async function rx(e,t,n,i,a){let o=n?null:new Set(rb(t)),s=[],c=0,l=r(e,{encoding:`utf8`}),u=ue({input:l,crlfDelay:1/0}),d=0;for await(let e of u){if(a?.aborted)break;if(d++,o&&!o.has(d))continue;let t=e.trim();if(t.length===0||(c++,s.length>=30))continue;let n;try{n=JSON.parse(t)}catch(e){s.push(Z(`error`,`MALFORMED_JSON`,`JSON.parse failed: ${e.message}`,{line:d}));continue}s.push(...ix(n,d,i))}return{sampled:c,issues:s}}function ix(e,t,n){if(typeof e!=`object`||!e||Array.isArray(e))return[Z(`error`,`RECORD_NOT_OBJECT`,`Each line must be a JSON object, got ${Array.isArray(e)?`array`:typeof e}.`,{line:t})];let r=e;return tx(r,n).inspect(r,t)}const ax={format:`jsonl`,extensions:[`.jsonl`],async validate(e,t){let n=Date.now(),r=await nx(e,t.signal);if(r.totalLines===0||r.totalLines===r.blankLines)return{valid:!1,format:`jsonl`,filePath:e,errors:[Z(`error`,`EMPTY_FILE`,`File contains no non-blank lines.`)],warnings:[],stats:{totalRecords:0,sampledRecords:0,durationMs:Date.now()-n}};if(r.issues.length>0)return{valid:!1,format:`jsonl`,filePath:e,errors:r.issues,warnings:[],stats:{totalRecords:r.totalLines-r.blankLines,sampledRecords:0,durationMs:Date.now()-n}};let i=await rx(e,r.totalLines,!!t.fullValidate,t.schema,t.signal),a=i.issues.filter(e=>e.severity===`error`),o=i.issues.filter(e=>e.severity===`warning`);return{valid:a.length===0,format:`jsonl`,filePath:e,errors:a,warnings:o,stats:{totalRecords:r.totalLines-r.blankLines,sampledRecords:i.sampled,durationMs:Date.now()-n}}}};function ox(e,t){return new Promise((n,r)=>{fe.open(e,{lazyEntries:!0},(e,i)=>{if(e||!i){r(/* @__PURE__ */ Error(`Failed to open ZIP: ${e?.message??`unknown error`}`));return}i.readEntry(),i.on(`entry`,e=>{let r=e.fileName.replace(/\\/g,`/`);r===t||r.endsWith(`/${t}`)?n({entry:e,zipfile:i}):i.readEntry()}),i.on(`end`,()=>{i.close(),r(/* @__PURE__ */ Error(`Entry "${t}" not found in ZIP`))}),i.on(`error`,r)})})}function sx(e){return new Promise((t,n)=>{fe.open(e,{lazyEntries:!0},(e,r)=>{if(e||!r){n(/* @__PURE__ */ Error(`Failed to open ZIP: ${e?.message??`unknown error`}`));return}let i=[];r.readEntry(),r.on(`entry`,e=>{i.push(e.fileName.replace(/\\/g,`/`)),r.readEntry()}),r.on(`end`,()=>{r.close(),t(i)}),r.on(`error`,n)})})}const cx=/^[a-zA-Z0-9_-]+$/;function lx(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(0,t):e}function ux(e){if(e===`__MACOSX`||e.startsWith(`__MACOSX/`))return!0;let t=e.split(`/`).filter(e=>e.length>0).pop()??``;return t===`.DS_Store`||t.startsWith(`._`)}function dx(e){let t=[],n=/* @__PURE__ */ new Map;for(let r of e){if(r.endsWith(`/`)||ux(r))continue;let e=r.split(`/`).filter(e=>e.length>0);for(let n of e){let e=lx(n),i=n.slice(e.length);e.length>0&&!cx.test(e)&&t.length<10&&t.push(Z(`error`,`INVALID_FILENAME_CHARSET`,`File/folder name "${n}" contains invalid characters. Only a-z, A-Z, 0-9, underscore (_), and hyphen (-) are allowed.`,{path:r})),i.length>0&&!/^\.[a-zA-Z0-9]+$/.test(i)&&t.length<10&&t.push(Z(`error`,`INVALID_FILENAME_CHARSET`,`File extension "${i}" in "${n}" contains invalid characters.`,{path:r}))}let i=e[e.length-1]??``,a=lx(i);if(a.length>120&&t.length<10&&t.push(Z(`error`,`FILENAME_TOO_LONG`,`Filename "${i}" (without extension) exceeds 120 characters (got ${a.length}). Shorten the name and re-upload.`,{path:r})),a.length>0){let e=n.get(a);e===void 0?n.set(a,r):t.length<10&&t.push(Z(`error`,`DUPLICATE_FILENAME`,`Filename "${i}" conflicts with "${e}" — names must be globally unique (ignoring extension) even across different folders.`,{path:r}))}}return t.length>=10&&t.push(Z(`warning`,`FILENAME_ISSUES_TRUNCATED`,`More filename issues exist but reporting is capped at 10.`)),t}async function fx(e,t,n){let{entry:r,zipfile:a}=await ox(e,t);return new Promise((e,t)=>{a.openReadStream(r,(r,o)=>{if(r||!o){a.close(),t(r??/* @__PURE__ */ Error(`Failed to open entry stream`));return}let s=i(n);de(o,s).then(()=>{a.close(),e()}).catch(e=>{a.close(),t(e)})})})}async function px(e,t=100){let n=r(e,{encoding:`utf8`}),i=ue({input:n,crlfDelay:1/0}),a=[],o=0;for await(let e of i){if(o++,a.length>=t)continue;let n=e.trim();if(n.length!==0)try{let e=JSON.parse(n);typeof e.wav_fn==`string`&&a.push(e.wav_fn),typeof e.img_path==`string`&&a.push(e.img_path),typeof e.input_img==`string`&&a.push(e.input_img),typeof e.first_frame_path==`string`&&a.push(e.first_frame_path),typeof e.last_frame_path==`string`&&a.push(e.last_frame_path),typeof e.video_path==`string`&&a.push(e.video_path),typeof e.image_fn==`string`&&a.push(e.image_fn),typeof e.video_fn==`string`&&a.push(e.video_fn)}catch{}}return{refs:a,totalLines:o}}const mx={format:`zip`,extensions:[`.zip`],async validate(e,t){let n=Date.now(),r=[],i=[],a;try{a=await sx(e)}catch(t){return{valid:!1,format:`zip`,filePath:e,errors:[Z(`error`,`ZIP_OPEN_FAILED`,`Could not open ZIP archive: ${t.message}`)],warnings:[],stats:{durationMs:Date.now()-n}}}if(a.length===0)return{valid:!1,format:`zip`,filePath:e,errors:[Z(`error`,`ZIP_EMPTY`,`ZIP archive contains no entries.`)],warnings:[],stats:{durationMs:Date.now()-n}};let s=a.some(e=>e===`data.jsonl`),c=!s&&a.find(e=>e.endsWith(`/data.jsonl`));s||(c?r.push(Z(`error`,`DATA_JSONL_NOT_AT_ROOT`,`"data.jsonl" must be at the ZIP root (found "${c}"). Re-package so that opening the ZIP shows data.jsonl directly, without a wrapping folder.`)):r.push(Z(`error`,`MISSING_DATA_JSONL`,`ZIP archive must contain "data.jsonl" at the root. This file maps media files (e.g. .wav, .jpg) to their labels.`)));let l=dx(a);for(let e of l)e.severity===`error`?r.push(e):i.push(e);let d=t.schema===`image`,f=t.schema===`video`,p=a.some(e=>e===`train/`||e.startsWith(`train/`)),m=a.some(e=>e.toLowerCase().endsWith(`.wav`));if(!p&&!d&&!f&&m&&i.push(Z(`warning`,`NO_TRAIN_DIR`,`No "train/" directory found in the ZIP. Media files are typically placed under "train/" and referenced as "train/xxx.wav" in data.jsonl.`)),d){let e=a.filter(e=>{if(e===`data.jsonl`||e.endsWith(`/data.jsonl`)||e.endsWith(`/`)||ux(e))return!1;let t=e.lastIndexOf(`.`),n=t>=0?e.slice(t).toLowerCase():``;return Ub.has(n)});e.length<25&&r.push(Z(`error`,`INSUFFICIENT_IMAGES`,`Found ${e.length} image(s) in ZIP, but image generation fine-tuning requires at least 25 images (50+ recommended).`))}if(!s&&!c)return{valid:!1,format:`zip`,filePath:e,errors:r,warnings:i,stats:{totalRecords:a.length,durationMs:Date.now()-n}};let g=s?`data.jsonl`:a.find(e=>e.endsWith(`/data.jsonl`)),_=v(h(),`bl-zip-${ae(6).toString(`hex`)}`);o(_,{recursive:!0});let y=v(_,`data.jsonl`);try{await fx(e,g,y)}catch(t){return r.push(Z(`error`,`EXTRACT_FAILED`,`Failed to extract "data.jsonl" from ZIP: ${t.message}`)),u(_,{recursive:!0,force:!0}),{valid:!1,format:`zip`,filePath:e,errors:r,warnings:i,stats:{durationMs:Date.now()-n}}}let b=await ax.validate(y,t);if(r.push(...b.errors),i.push(...b.warnings),b.valid){let{refs:e}=await px(y),t=new Set(a),n=g.lastIndexOf(`/`),i=n>=0?g.slice(0,n+1):``,o=[];for(let n of e){let e=n.replace(/^\.\//,``);t.has(e)||t.has(i+e)||o.push(n)}if(o.length>0){let e=o.slice(0,5).join(`, `),t=o.length>5?` (and ${o.length-5} more)`:``;r.push(Z(`error`,`DANGLING_MEDIA_REFS`,`${o.length} media file(s) referenced in data.jsonl not found in ZIP: ${e}${t}`))}}return u(_,{recursive:!0,force:!0}),{valid:r.length===0,format:`zip`,filePath:e,errors:r,warnings:i,stats:{totalRecords:b.stats.totalRecords??a.length,sampledRecords:b.stats.sampledRecords,durationMs:Date.now()-n}}}};async function hx(e){let t=_(e).toLowerCase();if(t===`.jsonl`)return gx(e);if(t===`.zip`)return _x(e);throw new O(`Cannot inspect file with extension "${t}". Expected .jsonl or .zip.`,D.USAGE)}async function gx(e){let t=await yx(e);if(!t)throw new O(`JSONL file is empty or contains only blank lines: ${e}`,D.USAGE);let n=vx(t);return n===`unknown`?`text`:n}async function _x(e){let t=await bx(e,`data.jsonl`);if(!t)throw new O(`ZIP archive does not contain "data.jsonl" or it is empty: ${e}`,D.USAGE,`Audio training data must be a ZIP with data.jsonl at the root and a train/ subfolder.`);let n=vx(t);if(n===`unknown`)throw new O(`ZIP data.jsonl does not match any supported media format (expected wav_fn / img_path / first_frame_path / video_path): ${e}`,D.USAGE,`ZIP archives are for audio/image/video training data. For text data, use a .jsonl file instead.`);return n}function vx(e){let t;try{t=JSON.parse(e)}catch{throw new O(`Failed to parse first JSON record for modality detection: ${e.slice(0,120)}`,D.USAGE)}if(typeof t!=`object`||!t||Array.isArray(t))throw new O(`Expected a JSON object as the first record, got ${Array.isArray(t)?`array`:typeof t}.`,D.USAGE);return`wav_fn`in t?`audio`:`img_path`in t?`input_img`in t?`image-i2i`:`image`:`first_frame_path`in t||`video_path`in t?`last_frame_path`in t?`video-kf2v`:`video`:`unknown`}function yx(e){return new Promise((t,n)=>{let i=r(e,{encoding:`utf8`}),a=ue({input:i,crlfDelay:1/0}),o=!1;a.on(`line`,e=>{if(o)return;let n=e.trim();n.length!==0&&(o=!0,a.close(),i.destroy(),t(n))}),a.on(`close`,()=>{o||t(null)}),a.on(`error`,n),i.on(`error`,n)})}function bx(e,t){return ox(e,t).then(({entry:e,zipfile:n})=>new Promise((r,i)=>{n.openReadStream(e,(e,a)=>{if(e||!a){n.close(),i(new O(`Failed to read "${t}" from ZIP: ${e?.message}`,D.USAGE));return}let o=ue({input:a,crlfDelay:1/0}),s=!1;o.on(`line`,e=>{if(s)return;let t=e.trim();t.length!==0&&(s=!0,o.close(),a.destroy(),n.close(),r(t))}),o.on(`close`,()=>{s||(n.close(),r(null))}),o.on(`error`,e=>{n.close(),i(e)})})})).catch(e=>{if(e instanceof Error&&e.message.includes(`not found in ZIP`))return null;throw e})}const xx=[ax,mx];function Sx(e){let t=_(e).toLowerCase(),n=xx.find(e=>e.extensions.includes(t));if(!n){let e=xx.flatMap(e=>e.extensions).join(`, `);throw new O(`Unsupported dataset format "${t||`(none)`}". Supported: ${e}`,D.USAGE,`Convert your data to one of the supported formats and re-run.`)}return n}function Cx(e){xx.some(t=>t.format===e.format)||xx.push(e)}async function wx(e,t={}){let{bytes:n}=tb(e,t.maxBytes??209715200),r=await Sx(e).validate(e,t);return r.stats.bytes===void 0&&(r.stats.bytes=n),r}function Tx(){return xx.map(e=>({format:e.format,extensions:[...e.extensions]}))}function Ex(e){let t=[];e.line!==void 0&&t.push(`line ${e.line}`),e.path&&t.push(e.path);let n=t.length?` [${t.join(` · `)}]`:``;return` ${e.severity.toUpperCase()} ${e.code}${n}: ${e.message}`}const Dx=[`/v1/chat/completions`,`/v1/embeddings`,`/v1/chat/ds-test`],Ox=[`validating`,`in_progress`,`finalizing`,`completed`,`failed`,`expired`,`cancelling`,`cancelled`],kx=/* @__PURE__ */ new Set([`completed`,`failed`,`expired`,`cancelled`]),Ax=524288e3,jx=6291456,Mx=5e4;function Q(e,t){throw new k(`${e}\n${t}`)}function Nx(e){if(e instanceof O)return e;let t=e?.code;return new O(`Batch file I/O failed${t?` (${t})`:``}.\nBatch 文件读写失败${t?`(${t})`:``}。`,D.GENERAL,t===`ENOENT`?`Check the file and parent directory paths. / 请检查文件及父目录路径。`:t===`EEXIST`?`Output exists; use --force to replace it. / 输出已存在,使用 --force 覆盖。`:`Check file permissions and available disk space. / 请检查文件权限与磁盘空间。`,{cause:e})}function Px(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Fx(e){return Dx.includes(e)||Q(`Unsupported Batch endpoint: ${e}`,`不支持的 Batch endpoint:${e}`),e}async function*Ix(e){let t=typeof e==`string`?ge(e):e instanceof Blob?ke.fromWeb(e.stream()):e;try{for await(let e of t)yield e}catch(e){throw Nx(e)}}async function*Lx(e,t=1/0,n=jx){let r=Buffer.alloc(0),i=0,a=new TextDecoder(`utf-8`,{fatal:!0}),o=e=>{try{return a.decode(e)}catch{return Q(`Invalid UTF-8 input.`,`输入不是有效 UTF-8。`)}};for await(let a of Ix(e)){i+=a.byteLength,i>t&&Q(`File exceeds ${t} bytes.`,`文件超过 ${t} 字节。`);let e=Buffer.concat([r,a]),s=0,c=e.indexOf(10,s);for(;c!==-1;){let t=c-s;t>n&&Q(`JSONL line exceeds 6 MiB.`,`JSONL 单行超过 6 MiB。`),yield{text:o(e.subarray(s,c)).replace(/\r$/,``),bytes:t+1},s=c+1,c=e.indexOf(10,s)}r=Buffer.from(e.subarray(s)),r.byteLength>n&&Q(`JSONL line exceeds 6 MiB.`,`JSONL 单行超过 6 MiB。`)}r.length&&(yield{text:o(r),bytes:r.length})}function Rx(e,t=!1){if(typeof e==`string`&&t){if(/^data:[^,]+;base64,/i.test(e))return;let t;try{t=new URL(e)}catch{return Q(`Media must use a public HTTP(S) or base64 data URL.`,`媒体必须使用公网 HTTP(S) 或 base64 data URL。`)}let n=t.hostname.toLowerCase().replace(/^\[|\]$/g,``),r=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(n),i=r?parseInt(r[1],16):0,a=r?parseInt(r[2],16):0,o=r?[i>>8,i&255,a>>8,a&255].join(`.`):n,s=n===`localhost`||n.endsWith(`.localhost`)||ce(o)===4&&/^(0|10|127|169\.254|172\.(1[6-9]|2\d|3[01])|192\.168)(\.|$)/.test(o)||ce(n)===6&&/^(::1$|::$|f[cd]|fe[89ab])/.test(n);(![`http:`,`https:`].includes(t.protocol)||s)&&Q(`Media URLs must not use local/private addresses.`,`媒体 URL 不得使用本地或私网地址。`)}else if(Array.isArray(e))for(let n of e)Rx(n,t);else if(Px(e))for(let[n,r]of Object.entries(e))Rx(r,[`image_url`,`video_url`,`audio_url`,`file_url`,`image`,`video`].includes(n)||t&&n===`url`)}var zx=class{ids=/* @__PURE__ */ new Set;thinking;report={records:0,bytes:0,model:``,endpoint:`/v1/chat/completions`,warnings:[]};warn(e){this.report.warnings.includes(e)||this.report.warnings.push(e)}add(e,t){let n=this.report.records+1,r=e=>Q(`Invalid or inconsistent ${e} at record ${n}.`,`第 ${n} 条记录的 ${e} 无效或不一致。`);Px(e)||r(`JSON object`);let i=e,a=i.custom_id;(typeof a!=`string`||!a.trim()||Array.from(a).length>256||this.ids.has(a))&&r(`custom_id`),i.method!==`POST`&&r(`method=POST`);let o=Fx(String(i.url));Px(i.body)||r(`body`);let s=i.body;if((typeof s.model!=`string`||!s.model.trim())&&r(`body.model`),s.enable_thinking!==void 0&&typeof s.enable_thinking!=`boolean`&&r(`enable_thinking`),this.report.records&&(this.report.model!==s.model||this.report.endpoint!==o||this.thinking!==s.enable_thinking)&&r(`model/url/enable_thinking`),o===`/v1/embeddings`){let e=e=>typeof e==`string`&&!!e.trim(),t=e=>Array.isArray(e)&&e.length>0&&e.every(e=>Number.isInteger(e)&&e>=0);e(s.input)||t(s.input)||Array.isArray(s.input)&&s.input.length>0&&(s.input.every(e)||s.input.every(t))||r(`body.input`)}else(!Array.isArray(s.messages)||!s.messages.length||s.messages.some(e=>!Px(e)||typeof e.role!=`string`||!e.role.trim()||typeof e.content!=`string`&&!(Array.isArray(e.content)&&e.content.length>0&&e.content.every(Px))&&!(Array.isArray(e.tool_calls)&&e.tool_calls.length>0&&e.tool_calls.every(Px))))&&r(`body.messages`);Rx(s),Px(s.extra_body)&&(`enable_thinking`in s.extra_body||`thinking_budget`in s.extra_body)&&this.warn(`Place enable_thinking/thinking_budget at body top level, not extra_body. / enable_thinking/thinking_budget 应放在 body 顶层,而非 extra_body。`),t>6291456&&r(`line <=6 MiB`),t>1048576&&this.warn(`Line exceeds 1 MiB; documentation differs (1/6 MiB), compatibility is not guaranteed. / 单行超过 1 MiB,文档存在 1/6 MiB 差异,不保证兼容。`),this.ids.add(a),this.report.records++,this.report.bytes+=t,this.report.model=s.model,this.report.endpoint=o,this.thinking=s.enable_thinking,(this.report.records>5e4||this.report.bytes>524288e3)&&r(`50000 records / 500 MiB`),s.model===`batch-test-model`&&(this.report.records>100||this.report.bytes>1048576)&&r(`batch-test-model: 100 records / 1 MiB`)}finish(){return this.report.records||Q(`Batch input is empty.`,`Batch 输入为空。`),this.report}};async function Bx(e){let t=new zx,n=0;for await(let r of Lx(e,Ax)){n++;let e;try{e=JSON.parse(r.text)}catch{Q(`Invalid JSONL at line ${n}.`,`第 ${n} 行不是有效 JSONL。`)}t.add(e,r.bytes)}return t.finish()}async function Vx(e){let t=[],n=0;for await(let r of Ix(e))n+=r.byteLength,n>524288e3&&Q(`File exceeds 500 MiB.`,`文件超过 500 MiB。`),t.push(r);return new Blob(t)}function Hx(e,t,n){return e.requestJson({path:mg(),method:`POST`,body:t,signal:n})}function Ux(e,t,n){return e.requestJson({path:hg(t),signal:n})}function Wx(e,t,n){return e.requestJson({path:gg(t),method:`POST`,signal:n})}function Gx(e,t={},n){let r=new URLSearchParams;for(let[e,n]of Object.entries(t))n!==void 0&&r.set(e,Array.isArray(n)?n.join(`,`):String(n));return e.requestJson({path:mg()+(r.size?`?${r.toString()}`:``),signal:n})}function Kx(e,t,n){return e.request({path:_g(t),signal:n})}function qx(e){let t=e.url(pg(),vg),n=new URL(t).hostname.toLowerCase(),r=new URL(e.baseUrl).hostname.toLowerCase();return(e.usesTokenPlanEndpoint()||/^dashscope(?:-intl|-us)?\.aliyuncs\.com$/.test(n)||/^dashscope-(?:intl|us)\.aliyuncs\.com$/.test(r))&&Q(`--batch needs the Batch host, not a realtime/international/Token Plan endpoint; configure --base-url explicitly.`,`--batch 不能使用实时、国际站或 Token Plan 端点,请显式配置 Batch --base-url。`),t}async function Jx(e,t,n=!1){let r=Pe(e),i=Pe(je(r),`.${Ae(r)}.${qe()}.tmp`),a,o=e=>{throw Nx(e)};try{await Be(je(r),{recursive:!0}).catch(o),a=await Ve(i,`wx`,384).catch(o);for await(let e of t){let t=typeof e==`string`?Buffer.from(e):e,n=0;for(;n<t.byteLength;){let e=await a.write(t,n,t.byteLength-n).catch(o);n+=e.bytesWritten}}await a.sync().catch(o),await a.close().catch(o),a=void 0,n?await Ue(i,r).catch(o):await ze(i,r).catch(o)}finally{await a?.close().catch(()=>{}),await We(i).catch(()=>{})}}async function Yx(e){let t=Fx(e.endpoint??`/v1/chat/completions`);(Pe(e.file)===Pe(e.outputFile)||e.bodyFile&&Pe(e.bodyFile)===Pe(e.outputFile))&&Q(`Output must differ from input/body file.`,`输出路径必须与输入及 body 文件不同。`),e.model.trim()||Q(`Model must not be empty.`,`模型不能为空。`);let n=e.idColumn??`custom_id`,r=e.inputColumn??`content`,i={};if(e.bodyFile){let t;try{t=await He(e.bodyFile,`utf8`)}catch(e){throw Nx(e)}try{let e=JSON.parse(t);if(!Px(e))throw Error();i=e}catch{Q(`--body-file must contain a JSON object.`,`--body-file 必须包含 JSON 对象。`)}}[`model`,`messages`,`input`].some(e=>e in i)&&Q(`--body-file cannot define model/messages/input.`,`--body-file 不得定义 model/messages/input。`),t===`/v1/embeddings`&&(e.system!==void 0||`enable_thinking`in i||`thinking_budget`in i)&&Q(`System/thinking parameters do not apply to embeddings.`,`向量请求不适用系统提示词或思考参数。`);let a=new zx,o=[],s=[],c;async function*l(){let t=new TextDecoder(`utf8`,{fatal:!0}),n=0;for await(let r of Ix(e.file)){n+=r.byteLength,n>524288e3&&Q(`CSV exceeds 500 MiB.`,`CSV 超过 500 MiB。`);try{yield t.decode(r,{stream:!0})}catch{Q(`CSV must be UTF-8.`,`CSV 必须是 UTF-8。`)}}try{yield t.decode()}catch{Q(`CSV must be UTF-8.`,`CSV 必须是 UTF-8。`)}}async function*u(){let u=ke.from(l()),d=Le({bom:!0,max_record_size:6291456,columns:e=>((new Set(e).size!==e.length||!e.includes(n)||!e.includes(r))&&Q(`CSV requires unique headers and mapped ID/input columns.`,`CSV 表头必须唯一并包含映射的 ID/输入列。`),s=e.filter(e=>e!==n&&e!==r),e)});u.on(`error`,e=>d.destroy(e)),u.pipe(d);let f=0;try{for await(let s of d){f++;let c=s;c[r]?.trim()||Q(`Empty CSV input at record ${f}.`,`CSV 第 ${f} 条记录输入为空。`);let l={...i,model:e.model};t===`/v1/embeddings`?(l.input=c[r],l.encoding_format??=`float`):l.messages=[...e.system===void 0?[]:[{role:`system`,content:e.system}],{role:`user`,content:c[r]}];let u={custom_id:c[n],method:`POST`,url:t,body:l},d=JSON.stringify(u)+`
78
+ `;a.add(u,Buffer.byteLength(d)),e.dryRun&&o.length<2&&o.push(u),yield d}c=a.finish()}catch(e){throw e instanceof Error&&e.name===`Error`&&`code`in e&&String(e.code).startsWith(`CSV_`)&&Q(`Invalid CSV near record ${f+1}: ${e.message}`,`第 ${f+1} 条记录附近 CSV 格式错误:${e.message}`),Nx(e)}finally{u.destroy(),d.destroy()}}if(e.dryRun)for await(let e of u());else await Jx(e.outputFile,u(),e.force);return{...c,output_file:Pe(e.outputFile),ignored_columns:s,...e.dryRun?{samples:o}:{}}}const Xx=[`custom_id`,`model`,`request_id`,`status_code`,`content`,`embedding`,`error_code`,`error_message`,`prompt_tokens`,`completion_tokens`,`total_tokens`];function Zx(e){return Px(e)?e:{}}function Qx(e){let t=e==null?``:typeof e==`string`?e:JSON.stringify(e);return/^[\s\x00-\x1f]*[=+@-]/.test(t)?`'${t}`:t}function $x(e){return typeof e==`number`&&Number.isFinite(e)?e:``}function eS(e){let t=Zx(e),n=Zx(t.response),r=Zx(n.body),i=Zx(t.error??r.error),a=Zx(r.usage),o=Zx(Zx(Array.isArray(r.choices)?r.choices[0]:void 0).message),s=Array.isArray(r.data)?r.data.map(e=>{let t=Zx(e);return{index:t.index,embedding:t.embedding}}):void 0;return{recognized:Array.isArray(r.choices)||Array.isArray(r.data)||`code`in i||`message`in i,row:{custom_id:Qx(t.custom_id),model:Qx(r.model),request_id:Qx(n.request_id),status_code:$x(n.status_code),content:Qx(o.content),embedding:Qx(s),error_code:Qx(i.code),error_message:Qx(i.message),prompt_tokens:$x(a.prompt_tokens),completion_tokens:$x(a.completion_tokens),total_tokens:$x(a.total_tokens)}}}async function tS(e,t,n=!1){let r=0,i=0;async function*a(){yield``+Re([],{columns:[...Xx],header:!0});for(let t of e)for await(let e of Lx(t,1/0,1/0)){if(!e.text.trim())continue;let n;try{n=JSON.parse(e.text)}catch{Q(`Invalid result JSONL at ${t}:${r+1}.`,`结果 JSONL 格式错误:${t}:${r+1}。`)}let a=eS(n);r++,a.recognized||i++,yield Re([a.row],{columns:[...Xx]})}}return await Jx(t,a(),n),{records:r,unknown_records:i}}function nS(e){let t=e===`zh-CN`?`请介绍一下自己`:`Introduce yourself`,n={custom_id:`req-001`,method:`POST`,url:`/v1/chat/completions`,body:{model:`qwen-plus`,messages:[{role:`user`,content:t}]}},r={custom_id:`req-001`,method:`POST`,url:`/v1/embeddings`,body:{model:`text-embedding-v4`,input:t,encoding_format:`float`}},i={custom_id:`req-001`,method:`POST`,url:`/v1/chat/completions`,body:{model:`qwen-vl-plus`,messages:[{role:`user`,content:[{type:`text`,text:t},{type:`image_url`,image_url:{url:`https://example.com/image.jpg`}}]}]}},a={custom_id:`req-001`,response:{request_id:`request-001`,status_code:200,body:{model:`qwen-plus`,choices:[{message:{role:`assistant`,content:e===`zh-CN`?`你好`:`Hello`}}],usage:{prompt_tokens:10,completion_tokens:2,total_tokens:12}}},error:null};return{csv:`custom_id,content\nreq-001,${t}\nreq-002,2+2?`,chat:n,embedding:r,vision:i,defaults:{enable_thinking:!1,max_tokens:1024},success:a,failure:{custom_id:`req-002`,response:null,error:{code:`ExampleError`,message:`Example service error`}}}}function rS(e){let t=t=>{let n=nS(t);if(e===`prepare`||e===`convert`)return`input.csv:\n${n.csv}\n\ninput.jsonl:\n${JSON.stringify(n.chat)}\n\ndefaults.json (--body-file):\n${JSON.stringify(n.defaults)}`;if(e===`create`)return`Chat JSONL:\n${JSON.stringify(n.chat)}\n\nEmbedding JSONL:\n${JSON.stringify(n.embedding)}\n\nMultimodal JSONL (${t===`zh-CN`?`请替换示例公网图片 URL`:`replace the example public image URL`}):\n${JSON.stringify(n.vision)}`;let r=Re([n.success,n.failure].map(e=>eS(e).row),{columns:[...Xx],header:!0});return`result.jsonl:\n${JSON.stringify(n.success)}\n\nerror.jsonl (${t===`zh-CN`?`示意包络,真实服务需联调`:`illustrative envelope; verify with the service`}):\n${JSON.stringify(n.failure)}\n\nresult.csv:\n${r}`};return{"en-US":t(`en-US`),"zh-CN":t(`zh-CN`)}}const iS=`decision-model-preview`,aS=[`cn-beijing`,`ap-southeast-1`],oS=`cn-beijing`,sS=[`label`,`target`];function cS(e){if(!Sb(e))return e;let t=e.questions;return Sb(t)&&typeof t.type!=`string`?t:e}function lS(e){if(!Sb(e))return e;let t={};for(let[n,r]of Object.entries(e)){if(!Sb(r)){t[n]=r;continue}let e={...r};for(let t of sS)delete e[t];t[n]=e}return t}async function uS(e,t,n,r){let i=await e.requestJson({path:fg(t,n,`submit`),method:`POST`,body:r});if(typeof i?.data?.biz_id!=`string`||!i.data.biz_id.trim())throw new O(`ParseX response is missing data.biz_id; submission may have succeeded. / ParseX 响应缺少 data.biz_id,任务可能已提交成功。`,void 0,`Check the task before submitting again. / 请核对任务后再决定是否重新提交。`,{api:{requestId:i?.request_id}});return i}async function dS(e,t,n,r,i){let a=await e.requestJson({path:fg(t,n,`result`),method:`POST`,body:r,signal:i});if(typeof a?.data?.status!=`string`||!a.data.status.trim())throw new O(`ParseX response is missing data.status. / ParseX 响应缺少 data.status。`,void 0,void 0,{api:{requestId:a?.request_id}});return a}async function fS(e,t,n,r,i){let a=new AbortController,o=()=>a.abort(i.signal?.reason);i.signal?.aborted?o():i.signal?.addEventListener(`abort`,o,{once:!0});let s=setTimeout(()=>a.abort(new O(`ParseX polling timed out. / ParseX 轮询超时。`,D.TIMEOUT,`The remote task was not cancelled; query the same biz_id: ${r.biz_id}. / 未取消远端任务,请使用同一 biz_id 继续查询。`)),i.pollTimeout*1e3);try{for(;;){a.signal.throwIfAborted();try{let o=await dS(e,t,n,r,a.signal);if(a.signal.throwIfAborted(),i.progress?.(o),o.data.status===`success`||o.data.status===`failed`)return o}catch(e){if(a.signal.aborted||!(e instanceof O)||e.api?.apiCode!==`ResultNotReady`)throw e}await Ye(i.interval*1e3,void 0,{signal:a.signal})}}catch(e){throw a.signal.aborted?a.signal.reason:e}finally{clearTimeout(s),i.signal?.removeEventListener(`abort`,o)}}function pS(e){return e?{"X-DashScope-WorkSpace":e}:void 0}async function mS(e,t,n,r){return e.requestJson({path:n_(),method:`POST`,body:t,headers:pS(r),signal:n})}async function hS(e,t={}){let n=new URLSearchParams;t.pageNo!==void 0&&n.set(`page_no`,String(t.pageNo)),t.pageSize!==void 0&&n.set(`page_size`,String(t.pageSize)),t.status&&n.set(`status`,t.status),t.model&&n.set(`model`,t.model);let r=n_(),i=n.toString()?`${r}?${n.toString()}`:r;return e.requestJson({path:i,method:`GET`,headers:pS(t.workspaceId),signal:t.signal})}async function gS(e,t,n,r){return e.requestJson({path:r_(t),method:`GET`,headers:pS(r),signal:n})}async function _S(e,t,n,r){return e.requestJson({path:i_(t),method:`POST`,headers:pS(r),signal:n})}async function vS(e,t,n,r){return e.requestJson({path:r_(t),method:`DELETE`,headers:pS(r),signal:n})}async function yS(e,t,n={}){let r=new URLSearchParams;n.pageNo!==void 0&&r.set(`page_no`,String(n.pageNo)),n.pageSize!==void 0&&r.set(`page_size`,String(n.pageSize));let i=a_(t),a=r.toString()?`${i}?${r.toString()}`:i;return e.requestJson({path:a,method:`GET`,headers:pS(n.workspaceId),signal:n.signal})}async function bS(e,t){let n=new URLSearchParams;n.set(`input_model`,t.inputModel),n.set(`training_type`,t.trainingType),t.mtuSpecCode&&n.set(`mtu_spec_code`,t.mtuSpecCode),t.paramType&&n.set(`param_type`,t.paramType),t.trainOptions&&Object.keys(t.trainOptions).length>0&&n.set(`hyper_parameters`,JSON.stringify(t.trainOptions)),t.lang&&n.set(`lang`,t.lang);let r=`${o_()}?${n.toString()}`;return e.requestJson({path:r,method:`GET`,headers:t.workspaceId?{"X-DashScope-WorkSpace":t.workspaceId}:void 0,signal:t.signal})}async function xS(e,t,n={}){let r=new URLSearchParams;n.pageNo!==void 0&&r.set(`page_no`,String(n.pageNo)),n.pageSize!==void 0&&r.set(`page_size`,String(n.pageSize));let i=s_(t),a=r.toString()?`${i}?${r.toString()}`:i;return e.requestJson({path:a,method:`GET`,headers:n.workspaceId?{"X-DashScope-WorkSpace":n.workspaceId}:void 0,signal:n.signal})}async function SS(e,t,n,r){return e.requestJson({path:c_(t),method:`GET`,headers:pS(r),signal:n})}async function CS(e,t,n,r,i,a){let o=new URLSearchParams;return o.set(`model_name`,r),e.requestJson({path:`${f_(t,n)}?${o.toString()}`,method:`GET`,headers:pS(a),signal:i})}function wS(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))r!==void 0&&r!==``&&n.set(e,String(r));return n.toString()?`${e}?${n.toString()}`:e}async function TS(e,t={}){return e.requestJson({path:wS(p_(),{model:t.model,lang:t.lang}),method:`GET`,signal:t.signal})}async function ES(e,t,n){return e.requestJson({path:m_(),method:`POST`,body:t,signal:n})}async function DS(e,t={}){let n=wS(m_(),{status:t.status,model:t.model,template_id:t.templateId,quant_spec:t.quantSpec,quant_method:t.quantMethod,start_time:t.startTime,end_time:t.endTime,search_key:t.searchKey,select_key:t.selectKey,sort_order:t.sortOrder,page_no:t.pageNo,page_size:t.pageSize});return e.requestJson({path:n,method:`GET`,signal:t.signal})}async function OS(e,t,n){return e.requestJson({path:h_(t),method:`GET`,signal:n})}async function kS(e,t,n={}){return e.requestJson({path:wS(__(t),{offset:n.offset,line:n.line}),method:`GET`,signal:n.signal})}async function AS(e,t,n){return e.requestJson({path:g_(t),method:`POST`,signal:n})}async function jS(e,t,n){return e.requestJson({path:h_(t),method:`DELETE`,signal:n})}const MS={sft:{server:`sft`,method:`sft`,variant:`full`},"sft-lora":{server:`efficient_sft`,method:`sft`,variant:`lora`},dpo:{server:`dpo_full`,method:`dpo`,variant:`full`},"dpo-lora":{server:`dpo_lora`,method:`dpo`,variant:`lora`},cpt:{server:`cpt`,method:`cpt`,variant:`full`}},NS=Object.keys(MS),PS=`sft-lora`,FS={fineTune:!0};function IS(e){return e in MS}function LS(e){let{method:t,variant:n}=MS[e];return{method:t,variant:n}}function RS(e,t){if(!e)return!1;let{method:n,variant:r}=MS[t];if(e.supports?.[n]!==!0)return!1;let i=e.trainingTypes?.[n];return Array.isArray(i)&&i.includes(r)}function zS(e){return e?NS.filter(t=>RS(e,t)):[]}async function BS(e,t,n={}){return await hy(zn(e,n),t,FS)}const VS=`INSUFFICIENT_SAMPLES`;function HS(e){let{recordCount:t,batchSize:n}=e;return t>n?{ok:!0}:{ok:!1,issue:{severity:`error`,code:VS,message:`Training dataset has ${t} sample(s), which is not greater than batch_size (${n}).`},hint:[`The platform requires the number of training samples to exceed batch_size.`,`Options:`,` • add more data (recommended: comfortably more than batch_size, since the`,` platform also holds back a default 0.9 train split),`,` • lower --batch-size within the range published for this model and training type.`].join(`
79
+ `)}}function US(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e!=`string`||e.trim()===``)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function WS(e,t,n){let r=(e-t)/n;return Math.abs(r-Math.round(r))<1e-9}function GS(e,t){let n=new Map(e.flatMap(e=>e.name?[[e.name,e]]:[])),r=[];for(let[e,i]of Object.entries(t)){let t=n.get(e);if(!t){r.push({parameter:e,value:i,code:`unsupported`});continue}if(t.editable===!1){r.push({parameter:e,value:i,code:`not_editable`});continue}let a=String(i),o=t.support_values??[];if(o.length>0&&!o.includes(a)){r.push({parameter:e,value:i,code:`not_supported`,expected:o.join(`, `)});continue}let s=t.data_range??[];if(t.type===`number`||t.type===`intInputNumber`||t.type===`floatInputNumber`||s.length===2||t.step!==void 0){let n=US(i);if(n===void 0||t.type===`intInputNumber`&&!Number.isInteger(n)){r.push({parameter:e,value:i,code:`invalid_type`,expected:t.type===`intInputNumber`?`integer`:`number`});continue}let a=US(s[0]),o=US(s[1]),c=a!==void 0&&(t.left_range===`exclude`?n<=a:n<a),l=o!==void 0&&(t.right_range===`exclude`?n>=o:n>o);if(c||l){let n=t.left_range===`exclude`?`(`:`[`,a=t.right_range===`exclude`?`)`:`]`;r.push({parameter:e,value:i,code:`out_of_range`,expected:`${n}${s[0]}, ${s[1]}${a}`});continue}t.step!==void 0&&t.step>0&&!WS(n,a??0,t.step)&&r.push({parameter:e,value:i,code:`invalid_step`,expected:`step ${t.step} from ${a??0}`});continue}(i===null||typeof i==`object`||t.type===`input`&&a.trim()===``)&&r.push({parameter:e,value:i,code:`invalid_type`,expected:t.type??`scalar`})}return r}function KS(e,t){let n=e.find(e=>e.name===t);return US(n?.defaultValue??n?.recommend_value)}function qS(e){let t={};return e.nEpochs!==void 0&&(t.n_epochs=e.nEpochs),e.learningRate!==void 0&&(t.learning_rate=e.learningRate),e.maxLength!==void 0&&(t.max_length=e.maxLength),e.batchSize!==void 0&&(t.batch_size=e.batchSize),t}function JS(e,t,n){return{clientTrainingType:e,serverTrainingType:t,acceptedExtensions:[`.jsonl`],async validate(e,t,r){return wx(e,{...r,schema:n})},resolveHyperParameters(e,t){return qS(t)},shouldSkipGate(e,t){return!1},shouldSkipCapabilityCheck(e){return!1}}}const YS=JS(`sft`,`sft`,`chatml`),XS={lm_max_epoch:60,lm_step:5,lm_num:3,lm_batch_size:1e3,fm_max_epoch:100,fm_step:10,fm_num:3,fm_batch_size:2e3},ZS={learning_rate:`3e-5`,max_steps:800,eval_steps:200,max_token_length:`1k`,gradient_clip:.5,weight_decay:.02,max_pixels:`2k`,val_img_size:`2k`,generation_type:`t2i`,lora_rank:32,save_total_limit:10,split:.9},QS={...ZS,max_pixels:`1k`,val_img_size:`1k`,generation_type:`i2i`},$S={n_epochs:50,learning_rate:`2e-5`,split:.5,max_split_val_dataset_sample:5,eval_epochs:20,save_total_limit:10,lora_rank:32,lora_alpha:32};function eC(e){return e===`image`||e===`image-i2i`}function tC(e){return e===`video`||e===`video-kf2v`}function nC(e){return typeof e==`string`&&/wan2\.5/i.test(e)}function rC(e){return typeof e==`string`&&/wan2\.7/i.test(e)}const iC=[YS,{clientTrainingType:`sft-lora`,serverTrainingType:`efficient_sft`,acceptedExtensions:[`.jsonl`,`.zip`],async validate(e,t,n){if(t===`audio`)return wx(e,{...n,schema:`tts`});if(eC(t))return wx(e,{...n,schema:`image`,maxBytes:eb});if(tC(t)){let r=await wx(e,{...n,schema:`video`,maxBytes:eb});if(typeof n.model==`string`&&n.model.length>0){let e=/kf2v/i.test(n.model),i=t===`video-kf2v`;e&&!i?r.errors.push(Z(`error`,`KF2V_DATA_MISMATCH`,`Model "${n.model}" is a first+last-frame (kf2v) model but the data has no "last_frame_path". kf2v training data must include a last frame per record.`)):!e&&i&&r.warnings.push(Z(`warning`,`I2V_LAST_FRAME_IGNORED`,`Model "${n.model}" is a first-frame (i2v) model but the data includes "last_frame_path"; the last frame will be ignored during training.`))}return r.valid=r.errors.length===0,r}return wx(e,{...n,schema:`chatml`})},resolveHyperParameters(e,t){if(e===`audio`)return{...XS};if(eC(e)){let n={...e===`image-i2i`?QS:ZS};return t.learningRate!==void 0&&(n.learning_rate=t.learningRate),n}if(tC(e)){let e=t.model??t.baseModel,n={...$S,batch_size:rC(e)?1:4,max_pixels:rC(e)?102400:nC(e)?36864:262144};return t.nEpochs!==void 0&&(n.n_epochs=t.nEpochs),t.batchSize!==void 0&&(n.batch_size=t.batchSize),t.learningRate!==void 0&&(n.learning_rate=t.learningRate),n}return qS(t)},shouldSkipGate(e,t){return!(t!==`audio`&&!eC(t)&&!tC(t)||e!==`batch_size`)},shouldSkipCapabilityCheck(e){return e===`audio`||eC(e)||tC(e)}},JS(`dpo`,`dpo_full`,`dpo`),JS(`dpo-lora`,`dpo_lora`,`dpo`),{clientTrainingType:`cpt`,serverTrainingType:`cpt`,acceptedExtensions:[`.jsonl`],async validate(e,t,n){return wx(e,{...n,schema:`cpt`,maxBytes:Qy})},resolveHyperParameters(e,t){return qS(t)},shouldSkipGate(e,t){return!1},shouldSkipCapabilityCheck(e){return!1}},{...JS(`pg-opd`,`pg_opd`,`chatml`),resolveHyperParameters:()=>({}),shouldSkipGate:()=>!0,shouldSkipCapabilityCheck:()=>!0}];function aC(e){let t=iC.find(t=>t.clientTrainingType===e);if(!t){let t=iC.map(e=>e.clientTrainingType).join(`, `);throw new O(`Unknown training type "${e}".`,D.USAGE,`Supported training types: ${t}.`)}return t}function oC(){return iC.map(e=>e.clientTrainingType)}const sC=`zeldaEasy.broadscope-platform.modelCenter.getModelPrice`,cC=`zeldaEasy.broadscope-platform.modelInstance.calculateDatasetsTotalTokens`,lC=`zeldaEasy.broadscope-platform.modelInstance.estimateFinetuneTokens`;async function uC(e,t){return fy(await e.console(sC,{query:{type:0,modelId:t}}))}async function dC(e,t,n){return fy(await e.console(cC,{input:{trainDatasetIds:t,hyperParams:n}}))}async function fC(e,t,n,r){let i=JSON.stringify({useDefault:!1,userDefinedObj:{batch_size:16,eval_steps:50,learning_rate:`7e-6`,lr_scheduler_type:`linear`,max_length:8192,n_epochs:r,split:.9,save_total_limit:`3`,resume_from_checkpoint:!1,save_strategy:`epoch`},useQwenMixedStrategy:!1});return fy(await e.console(lC,{input:{trainingType:`cpt`,instanceName:`${t}_cli_estimate`,algorithmType:100,bizType:100,trainDatasetIds:n,hyperParams:i,bailianTrainModel:t,validationDatasetIds:``,jobName:`${t}_cli_estimate`,priority:`L0`}}))}function pC(e){let t=e.trim();if(t===`true`)return!0;if(t===`false`)return!1;if(t===`null`)return null;if(t.startsWith(`{`)||t.startsWith(`[`)||t.startsWith(`"`))try{return JSON.parse(t)}catch{return e}return t!==``&&!Number.isNaN(Number(t))?Number(t):e}function mC(e){try{return JSON.parse(e)}catch{return e}}function hC(e,t,n){let r=e.indexOf(`=`);if(r<=0||r===e.length-1)throw new k(`Invalid ${t} value "${e}".`,`Expected ${n}.`);return{key:e.slice(0,r),value:e.slice(r+1)}}function gC(e,t,n){let{key:r,value:i}=hC(e,t,n),a=r.indexOf(`.`);if(a<=0||a===r.length-1)throw new k(`Invalid ${t} value "${e}".`,`Expected ${n}.`);return{name:r.slice(0,a),field:r.slice(a+1),value:i}}function _C(e,t){let n=Number(e);if(e.trim()===``||Number.isNaN(n)||!Number.isFinite(n))throw new k(`Invalid ${t} value "${e}".`,`Expected a finite number.`);return n}function vC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yC(e,t){let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];n[e]=vC(t)&&vC(r)?yC(t,r):r}return n}function bC(e){let t;try{t=y(e)}catch(e){throw new k(`Invalid --config YAML.`,e instanceof Error?e.message:void 0)}if(t==null)return{};if(!vC(t))throw new k(`Invalid --config YAML.`,`Expected a mapping at the document root.`);return t}function xC(e){return e.functions??=[],e.functions}function SC(e,t,n){let r=xC(e),i=r.find(e=>e.name===t);return i||(i={type:n,name:t},r.push(i)),i}function CC(e,t,n){let r=xC(e).find(e=>e.name===t);if(!r)throw new k(`Unknown function name "${t}" in ${n}.`,`Define the function first via --rollout / --reward or in --config.`);return r}function wC(e,t,n){e.datasets=[...(e.datasets??[]).filter(e=>e.type!==t),...n]}function TC(e,t,n){let r=[];for(let n of t??[])r.push({type:e,data_source_type:`file_id`,file_name:n});for(let t of n??[])r.push({type:e,data_source_type:`file_id`,file_id:t});return r}function EC(e,t){let n=t?bC(t):{};if(e.clearFunctions&&(n.functions=[]),e.rollout){let t=xC(n).find(e=>e.type===`rollout`)??SC(n,`rollout-1`,`rollout`);t.type=`rollout`,t.fcmodel={...t.fcmodel,classpath:e.rollout}}for(let t of e.rewards??[]){let{key:e,value:r}=hC(t,`--reward`,`--reward <name=classpath>`),i=SC(n,e,`reward`);i.type=`reward`,i.fcmodel={...i.fcmodel,classpath:r}}if(e.codeDir!==void 0||e.requirements!==void 0)for(let t of xC(n))t.fcmodel??={},e.codeDir!==void 0&&(t.fcmodel.zipdir=e.codeDir),e.requirements!==void 0&&(t.fcmodel.requirements_path=e.requirements);for(let t of e.functionTimeouts??[]){let{key:e,value:r}=hC(t,`--function-timeout`,`--function-timeout <name=sec>`);CC(n,e,`--function-timeout`).timeout=_C(r,`--function-timeout`)}for(let t of e.rewardWeights??[]){let{key:e,value:r}=hC(t,`--reward-weight`,`--reward-weight <name=num>`);CC(n,e,`--reward-weight`).weight=_C(r,`--reward-weight`)}for(let t of e.rewardMetrics??[]){let{name:e,field:r,value:i}=gC(t,`--reward-metric`,`--reward-metric <name.metric=num>`),a=CC(n,e,`--reward-metric`);a.reward_metric_weight??={},a.reward_metric_weight[r]=_C(i,`--reward-metric`)}for(let t of e.functionRuntime??[]){let{name:e,field:r,value:i}=gC(t,`--function-runtime`,`--function-runtime <name.field=value>`),a=CC(n,e,`--function-runtime`);a.runtime=yC(a.runtime??{},{[r]:pC(i)})}for(let t of e.functionEnv??[]){let{name:e,field:r,value:i}=gC(t,`--function-env`,`--function-env <name.KEY=value>`),a=CC(n,e,`--function-env`);a.runtime??={},a.runtime.env??={},a.runtime.env[r]=i}let r=TC(`training`,e.trainFiles,e.trainFileIds);r.length>0&&wC(n,`training`,r);let i=TC(`validation`,e.validationFiles,e.validationFileIds);if(i.length>0&&wC(n,`validation`,i),e.model!==void 0&&(n.model={...n.model,name:e.model}),e.name!==void 0&&(n.name=e.name),e.teacherModel!==void 0&&(n.teacher_model=e.teacherModel),e.hp&&e.hp.length>0){let t={};for(let n of e.hp){let{key:e,value:r}=hC(n,`--hp`,`--hp <key=value>`);t[e]=pC(r)}n.training??={},n.training.hyper_parameters=yC(n.training.hyper_parameters??{},t)}if(e.chargeType!==void 0||e.mtuSpec!==void 0||e.mtuCount!==void 0||e.instanceId!==void 0){n.training??={};let t={...n.training.resources};e.chargeType!==void 0&&(t.charge_type=e.chargeType),e.mtuSpec!==void 0&&(t.mtu_spec_code=e.mtuSpec),e.mtuCount!==void 0&&(t.mtu_capacity=e.mtuCount),e.instanceId!==void 0&&(t.instance_id=e.instanceId),n.training.resources=t}if(e.codeDir!==void 0||e.requirements!==void 0||e.include!==void 0||e.exclude!==void 0){let t=n.bailian??{};e.codeDir!==void 0&&(t.code_dir=e.codeDir),e.requirements!==void 0&&(t.requirements=e.requirements),(e.include!==void 0||e.exclude!==void 0)&&(t.package={...t.package,...e.include===void 0?{}:{include:e.include},...e.exclude===void 0?{}:{exclude:e.exclude}}),n.bailian=t}for(let t of e.set??[]){let{key:e,value:r}=hC(t,`--set`,`--set <key=value>`);n[e]=mC(r)}let a=e.opd===!0;if(n.training??={},a){if(n.training.type=`pg_opd`,!n.teacher_model)throw new k(`OPD requires a teacher model.`,`Pass --teacher-model <id>.`)}else{if(n.teacher_model)throw new k(`teacher_model is only valid for OPD jobs.`,`Remove --teacher-model, or use the OPD run command.`);n.training.type||(n.training.type=`reinforcement`)}if(!n.model?.name)throw new k(`A base model is required.`,`Pass --model <id> or set model.name in --config.`);return{spec:n,hasFunctions:(n.functions?.length??0)>0,isOpd:a}}function DC(e,t){let n=structuredClone(e);delete n.bailian;for(let e of n.functions??[])e.fcmodel&&(e.fcmodel.zipdir=t.deployCopyDir);for(let e of n.datasets??[])e.file_name&&=T(t.dataDir,Ae(e.file_name));return b(n)}const OC={checkUserWhitelist:`zeldaHttp.dashscopeFinetune./zelda/api/v1/finetune/common/checkUserWhitelist`,queryReinforcementEnabled:`zeldaHttp.dashscopeFinetune./zelda/api/v1/finetune/reinforcement/query_reinforcement_enabled`,queryOpdEnabled:`zeldaHttp.dashscopeFinetune./zelda/api/v1/finetune/opd/query_opd_enabled`,checkFineTuningSlrAuth:`zeldaEasy.broadscope-platform.modelInstance.checkSlrAuth.m_efm`,getTelemetrySlrStatus:`zeldaEasy.bailian-telemetry.activate.getTelemetrySlrStatus`,getTelemetryServiceStatus:`zeldaEasy.bailian-telemetry.activate.getTelemetryServiceStatus`,enableReinforcement:`zeldaHttp.dashscopeFinetune./zelda/api/v1/finetune/reinforcement/enable_reinforcement`,enableOpd:`zeldaHttp.dashscopeFinetune./zelda/api/v1/finetune/opd/enable_opd`},kC={"en-US":`SLS (Simple Log Service) activation must be completed manually in the Alibaba Cloud console; the CLI cannot open it. Its service-linked role is already covered by the fine-tuning SLR above.`,"zh-CN":`SLS(日志服务)开通需在阿里云控制台手动完成,CLI 无法代为开通;其服务关联角色已由上方 fine-tuning SLR 覆盖。`},AC={rl:`agentic_rl`,opd:`pg_opd`};function jC(e){return{"en-US":`The CLI does not create service-linked roles. Follow ${e} to authorize the required roles in the console, then re-run to continue.`,"zh-CN":`CLI 不会自动创建服务关联角色。请参照 ${e} 在控制台完成角色授权后重新执行。`}}function MC(e){return e instanceof Error?e.message:String(e)}function NC(e){let t;try{t=typeof e==`string`?e:JSON.stringify(e)??String(e)}catch{t=String(e)}return t.length>300?`${t.slice(0,300)}…`:t}function PC(e){if(typeof e==`boolean`)return e;if(typeof e!=`object`||!e)return;let t=e,n=t.data!==null&&typeof t.data==`object`?t.data:t;for(let e of[`enabled`,`authorized`,`whitelisted`,`created`,`opened`,`available`,`result`,`openStatus`]){let t=n[e];if(typeof t==`boolean`)return t}}async function FC(e,t){let n;try{n=ly(await t())}catch(t){let n=t.rawResponse,r=n===void 0?``:` | raw=${NC(n)}`;return{status:`UNKNOWN`,detail:`${e}: ${MC(t)}${r}`}}let r=PC(n);return r===void 0?{status:`UNKNOWN`,detail:`${e}: unrecognized response | raw=${NC(n)}`}:{status:r?`READY`:`MISSING`}}async function IC(e,t,n){try{return ly(await t()),n.push(e),!0}catch(t){return n.push(`${e}:failed (${MC(t)})`),!1}}async function LC(e){let{target:t,console:n,authorize:r=!1,workspaceId:i,manualAuthDocUrl:a}=e,o=e.localize??(e=>typeof e==`string`?e:e[`en-US`]),s=[],c=[],l=i?{workspaceId:i}:{},u=await FC(OC.checkUserWhitelist,()=>n(OC.checkUserWhitelist,{reqDTO:{type:AC[t]}}));s.push({name:`whitelist`,required:!0,status:u.status===`MISSING`?`REQUIRES_USER_ACTION`:u.status,detail:u.detail});let d={input:{role:`fine-tuning`}},f=await FC(OC.checkFineTuningSlrAuth,()=>n(OC.checkFineTuningSlrAuth,d));f.status===`MISSING`&&(f={status:`REQUIRES_USER_ACTION`,detail:o(jC(a))}),s.push({name:`finetune-slr`,required:!0,status:f.status,detail:f.detail});let p={reqDTO:{...l,slrType:`Xtrace`}},m=await FC(OC.getTelemetrySlrStatus,()=>n(OC.getTelemetrySlrStatus,p));m.status===`MISSING`&&(m={status:`REQUIRES_USER_ACTION`,detail:o(jC(a))}),s.push({name:`telemetry-slr`,required:!1,status:m.status,detail:m.detail});let h=await FC(OC.getTelemetryServiceStatus,()=>n(OC.getTelemetryServiceStatus,{reqDTO:{...l,serviceType:`AppTrace`}}));s.push({name:`apptrace-service`,required:!1,status:h.status===`READY`?`READY`:`REQUIRES_USER_ACTION`,detail:h.detail}),s.push({name:`sls-service`,required:!1,status:`REQUIRES_USER_ACTION`,detail:o(kC)});let g=t===`opd`?OC.queryOpdEnabled:OC.queryReinforcementEnabled,_=await FC(g,()=>n(g,{reqDTO:{}})),v=u.status===`READY`&&f.status===`READY`;if(r&&v&&_.status===`MISSING`){let e=t===`opd`?OC.enableOpd:OC.enableReinforcement;_=await IC(e,()=>n(e,{reqDTO:{}}),c)?await FC(g,()=>n(g,{reqDTO:{}})):{status:`FAILED`}}return s.push({name:`business-enabled`,required:!0,status:_.status,detail:_.detail}),{target:t,checks:s,ok:s.every(e=>!e.required||e.status===`READY`),actions:c}}function RC(){return Ke(8).toString(`hex`)}function zC(){return T(qt(),`runs`)}function BC(e=RC()){let t=T(zC(),e),n={runId:e,taskDir:t,snapshotDir:T(t,`snapshot`),dataDir:T(t,`data`),deployCopyDir:T(t,`deploy-copy`),tmpDir:T(t,`tmp`),homeDir:T(t,`home`),dashscopeDir:T(t,`home`,`.dashscope`),cacheDir:T(t,`cache`),configPath:T(t,`config.yaml`),resultPath:T(t,`result.json`)};for(let e of[n.snapshotDir,n.dataDir,n.deployCopyDir,n.tmpDir,n.dashscopeDir,n.cacheDir])C(e,{recursive:!0});return n}function VC(e){return T(HC(),e)}function HC(){return T(qt(),`runtimes`,`rl`)}function UC(){return T(qt(),`cache`,`rl`)}function WC(e){let t=e.platform??process.platform,n=e.hostEnv??process.env,r=`http://127.0.0.1:${e.proxyPort}`,i={};i.DASHSCOPE_API_KEY=e.apiKey,e.baseUrl&&(i.DASHSCOPE_HTTP_BASE_URL=e.baseUrl),i.LOG_LEVEL=e.logLevel??`info`,i.PYTHONDONTWRITEBYTECODE=`1`,i.XDG_CACHE_HOME=e.cacheDir,e.sdkEnv&&Object.assign(i,e.sdkEnv),i.HTTP_PROXY=r,i.HTTPS_PROXY=r,i.NO_PROXY=``;let a=T(e.runtimeRoot,`bin`);if(t===`win32`){i.TEMP=e.tmpDir,i.TMP=e.tmpDir,i.USERPROFILE=e.homeDir;let t=Ie.parse(e.homeDir).root,r=/^[A-Za-z]:/.test(t)?t.slice(0,2):``;i.HOMEDRIVE=r,i.HOMEPATH=r?e.homeDir.slice(r.length):e.homeDir;let o=n.SystemRoot??n.windir??`C:\\Windows`;i.SystemRoot=o,i.windir=o,i.PATH=`${e.runtimeRoot};${a};${T(o,`System32`)};${o}`}else{i.TMPDIR=e.tmpDir,i.HOME=e.homeDir,i.PATH=`${a}:/usr/bin:/bin`;for(let e of[`LANG`,`LC_ALL`]){let t=n[e];t&&(i[e]=t)}}return i}function GC(e,t){let n=T(e,`.dashscope`);C(n,{recursive:!0});let r=T(n,`config.toml`),i=[`# Managed by bailian CLI; credentials are injected via environment.`];return t&&i.push(`base_url = ${JSON.stringify(t)}`),Oe(r,`${i.join(`
80
+ `)}\n`,`utf8`),r}const KC=/* @__PURE__ */ new Set([`.git`,`.venv`,`node_modules`,`__pycache__`]),qC=[/^\.env/,/\.pem$/,/\.key$/];function JC(e){let t=e.replace(/\\/g,`/`),n=``;for(let e=0;e<t.length;e++){let r=t[e];r===`*`?t[e+1]===`*`?(n+=`.*`,e++,t[e+1]===`/`&&e++):n+=`[^/]*`:n+=r===`?`?`[^/]`:r.replace(/[.+^${}()|[\]\\]/g,`\\$&`)}return RegExp(`^${n}$`)}function YC(e,t){return!t||t.length===0?!1:t.some(t=>JC(t).test(e))}function XC(e,t){let n=e.split(`/`);if(n.some(e=>KC.has(e)))return!0;if(!t){let e=n[n.length-1];if(qC.some(t=>t.test(e)))return!0}return!1}function ZC(e){return Fe===`/`?e:e.split(Fe).join(`/`)}function QC(e){if(ve(e).isSymbolicLink())throw new O(`Refusing to snapshot symlink: ${e}`,D.USAGE,`Remove symlinks from the source directory; they may escape the upload scope.`)}function $C(e){let{sourceDir:t,snapshotDir:n,deployCopyDir:r}=e,i=e.maxPackageBytes??209715200,a=[],o=0;C(n,{recursive:!0});let s=r=>{for(let c of be(r)){let l=T(r,c);QC(l);let u=ve(l),d=ZC(Ne(t,l)),f=u.isDirectory();if(!XC(d,f)&&!YC(d,e.exclude)&&!(!f&&e.include&&e.include.length>0&&!YC(d,e.include))){if(f)s(l);else{let e=Te(l).size;if(o+=e,o>i)throw new O(`Source package exceeds the ${i} byte limit.`,D.USAGE,`Narrow --include or add --exclude to reduce the upload size.`);let t=T(n,d);C(T(t,`..`),{recursive:!0}),me(l,t),a.push(d)}}}};return s(t),he(n,r,{recursive:!0}),{fileCount:a.length,totalBytes:o,files:a}}function ew(e,t){C(t,{recursive:!0});let n=[];for(let r of e){QC(r);let e=T(t,Ae(r));me(r,e),n.push(e)}return n}const tw={managementDomains:[`dashscope.aliyuncs.com`],ossSuffixes:[`.oss-*.aliyuncs.com`,`.oss.aliyuncs.com`],allowedPorts:[443]};function nw(e){let t=ce(e);if(t===4){let[t,n]=e.split(`.`).map(Number);return t===0||t===10||t===127||t===169&&n===254||t===172&&n>=16&&n<=31||t===192&&n===168||t>=224}if(t===6){let t=e.toLowerCase();return t===`::1`||t===`::`?!0:t.startsWith(`::ffff:`)?nw(t.slice(7)):!!(t.startsWith(`fe80`)||t.startsWith(`fc`)||t.startsWith(`fd`))}return!0}function rw(e,t){return t.some(t=>e===t.toLowerCase())}function iw(e,t){if(!t)return e;let n;try{n=new URL(t).hostname.toLowerCase()}catch{return e}return!n||e.managementDomains.includes(n)?e:{...e,managementDomains:[...e.managementDomains,n]}}function aw(e,t){return t.some(t=>{if(t.includes(`*`)){let n=t.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`[a-z0-9-]+`);return RegExp(`${n}$`).test(e)}return e.endsWith(t)})}function ow(e,t){let n=e.toLowerCase();return rw(n,t.managementDomains)||aw(n,t.ossSuffixes)}function sw(e){let t=e.lastIndexOf(`:`);return t<=0?{host:e,port:NaN}:{host:e.slice(0,t),port:Number(e.slice(t+1))}}async function cw(e){if(ce(e)){if(nw(e))throw Error(`denied ip`);return e}let t=await Xe(e,{all:!0,verbatim:!0});if(t.length===0)throw Error(`no address`);if(t.some(e=>nw(e.address)))throw Error(`denied ip`);return t[0].address}function lw(e={}){let t=e.policy??tw,n=e.onEvent??(()=>{}),r=/* @__PURE__ */ new Set,i=e=>{r.add(e),e.on(`close`,()=>r.delete(e)),e.on(`error`,()=>e.destroy())},a=Ze();return a.on(`connect`,(e,r,a)=>{i(r);let{host:o,port:s}=sw(e.url??``);if(!o||!t.allowedPorts.includes(s)||!ow(o,t)){n({type:`deny`,host:o,port:s}),r.write(`HTTP/1.1 403 Forbidden\r
81
+ \r
82
+ `),r.destroy();return}cw(o).then(e=>{let t=se({host:e,port:s},()=>{n({type:`allow`,host:o,port:s}),r.write(`HTTP/1.1 200 Connection Established\r
83
+ \r
84
+ `),a.length>0&&t.write(a),t.pipe(r),r.pipe(t)});i(t),t.on(`error`,()=>r.destroy())}).catch(()=>{n({type:`deny`,host:o,port:s}),r.write(`HTTP/1.1 403 Forbidden\r
85
+ \r
86
+ `),r.destroy()})}),a.on(`request`,(e,t)=>{t.writeHead(403,{"Content-Type":`text/plain`}),t.end(`Forbidden`)}),new Promise((e,t)=>{a.once(`error`,t),a.listen(0,`127.0.0.1`,()=>{let t=a.address();e({port:typeof t==`object`&&t?t.port:0,close:()=>new Promise(e=>{for(let e of r)e.destroy();r.clear(),a.close(()=>e())})})})})}function uw(e,t){if(e!==void 0){if(t===`win32`){Qe(`taskkill`,[`/pid`,String(e),`/T`,`/F`],{shell:!1,windowsHide:!0});return}try{process.kill(-e,`SIGKILL`)}catch{try{process.kill(e,`SIGKILL`)}catch{}}}}function dw(e){let[t,...n]=e.wrapCommand?e.wrapCommand(e.command):e.command,r=process.platform;return new Promise((i,a)=>{let o=Qe(t,n,{env:e.env,cwd:e.cwd,shell:!1,windowsHide:!0,stdio:[`pipe`,`pipe`,`pipe`],detached:r!==`win32`}),s=``,c=``,l=0,u=0,d=!1,f=!1,p=setTimeout(()=>{d=!0,uw(o.pid,r)},e.timeoutMs),m=()=>uw(o.pid,r);e.signal?.addEventListener(`abort`,m,{once:!0});let h=()=>{clearTimeout(p),e.signal?.removeEventListener(`abort`,m)};o.stdout?.on(`data`,t=>{if(l+=t.length,l<=e.maxOutputBytes){let n=t.toString(`utf8`);s+=n,e.onStdout?.(n)}else uw(o.pid,r)}),o.stderr?.on(`data`,t=>{if(u+=t.length,u<=e.maxOutputBytes){let n=t.toString(`utf8`);c+=n,e.onStderr?.(n)}else uw(o.pid,r)}),o.on(`error`,e=>{f||(f=!0,h(),a(new O(`Failed to start sandboxed process: ${e.message}`,D.GENERAL,`Check the managed runtime via the runtime doctor command.`,{cause:e})))}),o.on(`close`,(e,t)=>{f||(f=!0,h(),i({exitCode:e,signal:t,stdout:s,stderr:c,timedOut:d}))})})}function fw(e){return e.replace(/OSSAccessKeyId=[^&\s"']+/g,`OSSAccessKeyId=***`).replace(/Signature=[^&\s"']+/g,`Signature=***`).replace(/sk-[A-Za-z0-9]+/g,`sk-***`)}function pw(e){let{layout:t}=e;return{runId:t.runId,runtimeRoot:e.runtimeRoot,taskDir:t.taskDir,snapshotDir:t.snapshotDir,deployCopyDir:t.deployCopyDir,dataDir:t.dataDir,homeDir:t.homeDir,tmpDir:t.tmpDir,cacheDir:t.cacheDir,configPath:t.configPath,command:e.command,apiKey:e.apiKey,baseUrl:e.baseUrl,credentialDenyPaths:e.credentialDenyPaths,network:e.network??tw,timeoutMs:e.timeoutMs,maxOutputBytes:e.maxOutputBytes,logLevel:e.logLevel,sdkEnv:e.sdkEnv}}async function mw(e,t){let n=await t.detect();if(!n.credentialDenyRead.available)throw new O(n.credentialDenyRead.reason??`Credential isolation is unavailable.`,D.GENERAL,`No cloud resources were created. See the runtime doctor command for diagnostics.`);let r=pw(e),i=await lw({policy:iw(r.network,r.baseUrl)});r.proxyPort=i.port;try{await t.prepare(r);let a=WC({homeDir:r.homeDir,tmpDir:r.tmpDir,cacheDir:r.cacheDir,runtimeRoot:r.runtimeRoot,apiKey:r.apiKey,baseUrl:r.baseUrl,proxyPort:i.port,logLevel:r.logLevel,sdkEnv:r.sdkEnv});GC(r.homeDir,r.baseUrl);let o=await dw({command:r.command,env:a,cwd:e.cwd??r.taskDir,timeoutMs:r.timeoutMs,maxOutputBytes:r.maxOutputBytes,wrapCommand:e=>t.wrapCommand(r,e),signal:e.signal});return{exitCode:o.exitCode,signal:o.signal,stdout:fw(o.stdout),stderr:fw(o.stderr),timedOut:o.timedOut,credentialDenyEnforced:n.credentialDenyRead.available,hardening:n.hardening}}finally{try{await i.close(),await t.dispose()}finally{try{we(r.taskDir,{recursive:!0,force:!0})}catch{}}}}const hw=864e5;function gw(e){return S(e)?be(e,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(t=>T(e,t.name)):[]}function _w(e={}){let t=e.now??Date.now(),n=e.runsTtlMs??864e5,r=e.dryRun===!0,i=[];if(e.pruneRuns!==!1)for(let r of gw(e.runsDir??zC())){let e;try{e=Te(r).mtimeMs}catch{continue}let a=t-e>n;i.push({path:r,kind:`run`,action:a?`remove`:`keep`,reason:a?`orphaned run older than TTL`:`within TTL`})}if(e.pruneRuntimes===!0&&e.currentRuntimeId!==void 0){let t=e.runtimesDir??HC(),n=T(t,e.currentRuntimeId);for(let e of gw(t)){let t=e===n;i.push({path:e,kind:`runtime`,action:t?`keep`:`remove`,reason:t?`current baseline runtime`:`superseded runtime version`})}}let a=0;for(let e of i)if(e.action===`remove`){if(r){a+=1;continue}try{we(e.path,{recursive:!0,force:!0}),a+=1}catch(t){e.action=`keep`,e.reason=`delete failed: ${t instanceof Error?t.message:String(t)}`}}return{dryRun:r,entries:i,removedCount:a}}const vw=`/usr/bin/sandbox-exec`;function yw(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function bw(e){let t=e.proxyPort??0,n=[e.runtimeRoot,e.taskDir,e.snapshotDir,e.dataDir,e.deployCopyDir,e.tmpDir,e.homeDir,`/usr/lib`,`/System/Library`,`/private/var/db/dyld`,`/private/etc/ssl`],r=[e.deployCopyDir,e.tmpDir,e.homeDir],i=n.map(e=>` (subpath ${yw(e)})`).join(`
87
+ `),a=r.map(e=>` (subpath ${yw(e)})`).join(`
88
+ `);return`(version 1)
89
+ (deny default)
90
+ (allow file-read*
91
+ ${i}
92
+ (literal ${yw(e.configPath)})
93
+ (literal "/dev/urandom")
94
+ (literal "/dev/null")
95
+ ; 根目录读权限:dyld 启动解析绝对路径需读根 inode,缺失则解释器 SIGABRT(exit 134)且无输出。
96
+ ; 仅放开根目录自身(readdir/stat),不放开任意文件,真实 home/凭据仍被 deny-default 禁读。
97
+ (literal "/"))
98
+ (allow file-write*
99
+ ${a})
100
+ (allow network-outbound (remote tcp "localhost:${t}"))
101
+ (allow process-exec (subpath ${yw(e.runtimeRoot)}))
102
+ (allow process-fork)
103
+ (allow sysctl-read)
104
+ (allow mach-lookup)
105
+ `}function xw(){return S(vw)?$e(vw,[`-p`,`(version 1)(allow default)`,`/usr/bin/true`],{shell:!1,timeout:1e4}).status===0?{credentialDenyRead:{available:!0,mechanism:`sbpl`},hardening:{networkEnforce:!0,processTree:!0,memoryLimit:!1}}:{credentialDenyRead:{available:!1,mechanism:`sbpl`,reason:`sandbox-exec is unavailable (nested sandbox or restricted host).`},hardening:{networkEnforce:!1,processTree:!1,memoryLimit:!1}}:{credentialDenyRead:{available:!1,mechanism:`sbpl`,reason:`sandbox-exec not found.`},hardening:{networkEnforce:!1,processTree:!1,memoryLimit:!1}}}function Sw(){let e;return{detect:async()=>xw(),prepare:async t=>{e=T(t.taskDir,`profile.sb`),Oe(e,bw(t),`utf8`)},wrapCommand:(t,n)=>{let r=e??T(t.taskDir,`profile.sb`);return[vw,`-f`,r,...n]},dispose:async()=>{if(e&&S(e))try{De(e)}catch{}e=void 0}}}const Cw=[`/usr`,`/lib`,`/lib64`,`/etc/ssl/certs`];function ww(e,t){let n=[`--unshare-pid`,`--die-with-parent`];for(let e of Cw)S(e)&&n.push(`--ro-bind`,e,e);return n.push(`--ro-bind`,e.runtimeRoot,e.runtimeRoot),n.push(`--ro-bind`,e.snapshotDir,e.snapshotDir),n.push(`--ro-bind`,e.dataDir,e.dataDir),n.push(`--bind`,e.deployCopyDir,e.deployCopyDir),n.push(`--bind`,e.tmpDir,e.tmpDir),n.push(`--bind`,e.homeDir,e.homeDir),n.push(`--ro-bind`,e.configPath,e.configPath),n.push(`--proc`,`/proc`,`--dev`,`/dev`),n.push(`--`,...t),n}function Tw(){let e={networkEnforce:!1,processTree:!0,memoryLimit:!1},t=$e(`bwrap`,[`--ro-bind`,`/`,`/`,`--`,`/bin/true`],{shell:!1,timeout:1e4});return t.error&&t.error.code===`ENOENT`?{credentialDenyRead:{available:!1,mechanism:`bwrap-nobind`,reason:`bwrap is not installed.`},hardening:{networkEnforce:!1,processTree:!1,memoryLimit:!1}}:t.status===0?{credentialDenyRead:{available:!0,mechanism:`bwrap-nobind`},hardening:e}:{credentialDenyRead:{available:!1,mechanism:`bwrap-nobind`,reason:`bwrap cannot create a user namespace (disabled or restricted host).`},hardening:{networkEnforce:!1,processTree:!1,memoryLimit:!1}}}function Ew(){return{detect:async()=>Tw(),prepare:async()=>{},wrapCommand:(e,t)=>[`bwrap`,...ww(e,t)],dispose:async()=>{}}}function Dw(){return{detect:async()=>({credentialDenyRead:{available:!1,mechanism:`appcontainer`,reason:`Not supported on Windows yet.`},hardening:{networkEnforce:!1,processTree:!1,memoryLimit:!1}}),prepare:async()=>{},wrapCommand:(e,t)=>t,dispose:async()=>{}}}function Ow(e){return{detect:async()=>({credentialDenyRead:{available:!1,mechanism:`none`,reason:`Not supported on ${e} yet.`},hardening:{networkEnforce:!1,processTree:!1,memoryLimit:!1}}),prepare:async()=>{},wrapCommand:(e,t)=>t,dispose:async()=>{}}}function kw(e=process.platform){switch(e){case`darwin`:return Sw();case`linux`:return Ew();case`win32`:return Dw();default:return Ow(e)}}async function Aw(e=process.platform){return kw(e).detect()}const jw=`1.25.23`,Mw=`7cb2cc48fd82536202e3100e93730e92c952435bb8cbe16d45de9700e1546bcc`,Nw=`3.11.9`,Pw=`BAILIAN_RL_PYTHON_MIRROR`,Fw=`BAILIAN_RL_PIP_INDEX_URL`,Iw=[`https://registry.npmmirror.com/-/binary/python-build-standalone/`],Lw=/^[0-9a-f]{64}$/;function Rw(e,t,n){let r=e[t];if(typeof r!=`string`||r.length===0)throw new k(`Invalid runtime manifest: ${n}.${t} must be a non-empty string.`);return r}function zw(e,t,n){let r=Rw(e,t,n);if(!Lw.test(r))throw new k(`Invalid runtime manifest: ${n}.${t} must be a 64-char hex SHA256.`);return r}function Bw(e){let t;try{t=JSON.parse(e)}catch(e){throw new k(`Invalid runtime manifest: not valid JSON.`,String(e))}if(typeof t!=`object`||!t||Array.isArray(t))throw new k(`Invalid runtime manifest: root must be an object.`);let n=t;if(n.schemaVersion!==2)throw new k(`Invalid runtime manifest: schemaVersion must be 2.`);let r=Rw(n,`dashscopeVersion`,`root`),i=Rw(n,`dashscopeUrl`,`root`),a=zw(n,`dashscopeSha256`,`root`);if(!Array.isArray(n.entries)||n.entries.length===0)throw new k(`Invalid runtime manifest: entries must be a non-empty array.`);return{schemaVersion:2,dashscopeVersion:r,dashscopeUrl:i,dashscopeSha256:a,entries:n.entries.map((e,t)=>{let n=`entries[${t}]`;if(typeof e!=`object`||!e||Array.isArray(e))throw new k(`Invalid runtime manifest: ${n} must be an object.`);let r=e,i=Rw(r,`os`,n);if(i!==`darwin`&&i!==`linux`)throw new k(`Invalid runtime manifest: ${n}.os must be darwin or linux.`);return{os:i,arch:Rw(r,`arch`,n),triple:Rw(r,`triple`,n),pythonVersion:Rw(r,`pythonVersion`,n),pythonUrl:Rw(r,`pythonUrl`,n),pythonSha256:zw(r,`pythonSha256`,n)}})}}function Vw(){return Bw(`{
106
+ "schemaVersion": 2,
107
+ "dashscopeVersion": "1.25.23",
108
+ "dashscopeUrl": "https://files.pythonhosted.org/packages/9e/47/556e3a5d9e9e0f2d7c45f8598c7b9a9569ec7e5340e8e2a21288b58e4cfc/dashscope-1.25.23-py3-none-any.whl",
109
+ "dashscopeSha256": "7cb2cc48fd82536202e3100e93730e92c952435bb8cbe16d45de9700e1546bcc",
110
+ "entries": [
111
+ {
112
+ "os": "darwin",
113
+ "arch": "arm64",
114
+ "triple": "aarch64-apple-darwin",
115
+ "pythonVersion": "3.11.9",
116
+ "pythonUrl": "https://github.com/astral-sh/python-build-standalone/releases/download/20240415/cpython-3.11.9+20240415-aarch64-apple-darwin-install_only.tar.gz",
117
+ "pythonSha256": "7af7058f7c268b4d87ed7e08c2c7844ef8460863b3e679db3afdce8bb1eedfae"
118
+ },
119
+ {
120
+ "os": "darwin",
121
+ "arch": "x64",
122
+ "triple": "x86_64-apple-darwin",
123
+ "pythonVersion": "3.11.9",
124
+ "pythonUrl": "https://github.com/astral-sh/python-build-standalone/releases/download/20240415/cpython-3.11.9+20240415-x86_64-apple-darwin-install_only.tar.gz",
125
+ "pythonSha256": "9afd734f63a23783cf0257bef25c9231ffc80e7747486dc54cf72f325213fd15"
126
+ },
127
+ {
128
+ "os": "linux",
129
+ "arch": "x64",
130
+ "triple": "x86_64-unknown-linux-gnu",
131
+ "pythonVersion": "3.11.9",
132
+ "pythonUrl": "https://github.com/astral-sh/python-build-standalone/releases/download/20240415/cpython-3.11.9+20240415-x86_64-unknown-linux-gnu-install_only.tar.gz",
133
+ "pythonSha256": "78b1c16a9fd032997ba92a60f46a64f795cd18ff335659dfdf6096df277b24d5"
134
+ },
135
+ {
136
+ "os": "linux",
137
+ "arch": "arm64",
138
+ "triple": "aarch64-unknown-linux-gnu",
139
+ "pythonVersion": "3.11.9",
140
+ "pythonUrl": "https://github.com/astral-sh/python-build-standalone/releases/download/20240415/cpython-3.11.9+20240415-aarch64-unknown-linux-gnu-install_only.tar.gz",
141
+ "pythonSha256": "b3a7199ac2615d75fb906e5ba556432efcf24baf8651fc70370d9f052d4069ee"
142
+ }
143
+ ]
144
+ }`)}function Hw(e,t,n){let r=t===`darwin`?`darwin`:t===`linux`?`linux`:void 0;if(r)return e.entries.find(e=>e.os===r&&e.arch===n)}function Uw(e){return Ge(`sha256`).update(e).digest(`hex`)}function Ww(e,t){if(!e.startsWith(`https://github.com/astral-sh/python-build-standalone/releases/download/`))return;let n=e.slice(71);return(t.endsWith(`/`)?t:`${t}/`)+n}function Gw(e,t=process.env){let n=[],r=t[Pw];if(r){let t=Ww(e,r);t&&n.push(t)}n.push(e);for(let t of Iw){let r=Ww(e,t);r&&n.push(r)}return[...new Set(n)]}function Kw(e,t){let n=Uw(e),r=Buffer.from(t,`utf8`),i=Buffer.from(n,`utf8`);if(r.length!==i.length||!Je(r,i))throw new O(`Runtime artifact integrity check failed (SHA256 mismatch).`,D.GENERAL,`The downloaded artifact does not match the reviewed manifest. Refusing to install. No cloud resources were created.`)}const qw=(/* @__PURE__ */ `aiohappyeyeballs==2.7.1 \\, --hash=sha256:065665c041c42a5938ed220bdcd7230f22527fbec085e1853d2402c8a3615d9d \\, --hash=sha256:9243213661e29250eb41368e5daa826fc017156c3b8a11440826b2e3ed376472, # via aiohttp,aiohttp==3.14.5 \\, --hash=sha256:0133c3c3b54a0bf1e71fa5c1ad95c93f07fd54e24ef1fe182f5122e1573d2bf1 \\, --hash=sha256:038c2c7e8caa26b6c8423779b5eaf1893904048a512c19b32fe841ffa5592b50 \\, --hash=sha256:0684952aeae1f5dbfe02d46039338513b94009baecd15d8e4098a357c4c4a2a6 \\, --hash=sha256:0790ec66fa4013e83c53b9025a45d454723da1a2fce28b3208c9b32d08af162f \\, --hash=sha256:083673c7a94c3ea035caaa5ca04288bdb44887abfe1f5ba23294e6a4b03efd2d \\, --hash=sha256:09e0eb18c7e0c8777e2f9149de63799195b9b3ca1b5c81ba6f32f2c6b8628210 \\, --hash=sha256:09ec102b4b8c9a920275733bbc11fdbb615efe6f9231a06007c0218d336fb77a \\, --hash=sha256:0a8ea271867e360ac985ae607f4a23ad9a38414b9aca1d49ec98839ae660e49f \\, --hash=sha256:0e6f16f5e49c4b8267988c05ab07760d7064cea57d077c3d068d04b0fbb992cb \\, --hash=sha256:1061b364556e8172e8d46b0b183adeeb73e8c42d30ebc745591e1bd89acad52e \\, --hash=sha256:1220353657ad49493551f089ce02f1a348fd57ffd585bfec77f2f3c4fe3a7346 \\, --hash=sha256:137351bf20bbed9a65e839f4a4452ac377389bdb2f2857d2acffef38f5e9f2d1 \\, --hash=sha256:149fb56caf7acb67073126f675d0958d9c4b3125fcd3f6d4877df98aa8a97ce9 \\, --hash=sha256:14f04769cfefe4734016a856a83af36133cd17779cef9ae817f812b8ba9d6d51 \\, --hash=sha256:15a310d3c71398e3d7bfc93a1a73fbe664315cd9e9016b8efc1cff85eeab7155 \\, --hash=sha256:1612fa5857b37bf32e5c1eaeefb96e3b01e9c70679eec81f0934e8a600080863 \\, --hash=sha256:16c8abd5bca220a47efe667d26f8460124c81810787e79ee87b242677563d9dd \\, --hash=sha256:19e2ba471507c34f8252402ab50f5ab512398b9ea8c8f1cb26beb3f75793ba30 \\, --hash=sha256:1aead151c3abbac6b32942e452020cb66d7efc099d253cc6c20f748e926c858b \\, --hash=sha256:1b438b73c38111818d0c9d6a5c2bfed8584c8e503a49ef085d70e874ec846738 \\, --hash=sha256:1b5416552740edf07234cc9437d0706f2acb67b93c198670b1a68e1b2b587dec \\, --hash=sha256:1d2d981b53dd09a319e3570ef8cc3bbc3ef86f5a7abef0f6b2bff3867db3a9e7 \\, --hash=sha256:1eb8167961ec4dfcc8cb9dd50bd0ee72519f7ef496be95203e49e27b01618382 \\, --hash=sha256:1ffa3a523a36d8628f98c06492ae16a31a23d14c0b4ec721757b477319f656d6 \\, --hash=sha256:20064a177a070d789ee64a50b01a9161d3468e989baacfc6c714aa685c4b332f \\, --hash=sha256:20726f9782d5c2744c1c66255842d1d163bb3edcf768b8de25216bf47f7b6ccf \\, --hash=sha256:20f085697d7e911f1f73c43ed03fafbed1e7121797e2eb5428efa80398060584 \\, --hash=sha256:225c579c23b68b343cccea27a7e06e3bd8ec23a09c30b427eb3f1e4ca6239b20 \\, --hash=sha256:24409db442e2fb6e766bc7f3943851a8381dec3098140e43bb2e843b79e31b12 \\, --hash=sha256:248d779ad720b49d4fb355720e60c9e5f444f95887bc16974fea48fc56c41789 \\, --hash=sha256:2528cb4c6b92008c76ac9ac6298624069bb2db91ff4929905512d1d84485f658 \\, --hash=sha256:276a4fc00b1d9ae492b802763a789c5b86328b989c5ea169f2faa447d6a11c7c \\, --hash=sha256:27c2322e03f66101acb09869ce1cf1efc04994ee95e1735b69827bf8c8b9d781 \\, --hash=sha256:293d3ae7c6a0ed176a42e59a1b5fde825ead65c835360f734148e96729f928d2 \\, --hash=sha256:2cc38a4f2b516bef1714e690df87a0e043faf1a7693c82d860091684453d5111 \\, --hash=sha256:3093b72c215bda16ce961a6d073f6e71d46e022962a9d5d457c5d4d421c78b57 \\, --hash=sha256:32e8fa6644e541fcd7e02430588c7fc93b602c1778ea0bc345505db76b61cfb4 \\, --hash=sha256:330900acd0dc4cb8b27f9c127fbaad770964845338493e7906ae3822e82dbf8d \\, --hash=sha256:33f706574e32c6e694f352a856e05caf18f7f2c871b3e87b41c55ea452b409ab \\, --hash=sha256:3ae800a20947e2c2e53088047d021e6bf7d51560cc49f6a0737a1f79d2e3a13c \\, --hash=sha256:3be7dd397d64ca3e1869626fa9318aaebb54b7bf93bc72d7a205448d83e4f748 \\, --hash=sha256:3e0eb43bed3c6801a6cee315195377789e90b2a72c2277a475b578535312488d \\, --hash=sha256:3e51a27980c3788e6e6b3325d694fdd4898087fa8a86b2763af77b39353da41e \\, --hash=sha256:3edbece0379b8b4aaa67619b8aa2399bb66fce372cd5911098a434ea77220aa0 \\, --hash=sha256:3f2dcc00191fd563e9075181a14ec31d7dd63223ced7582cc70a15a499de0c79 \\, --hash=sha256:42b5e616946dbaf505e2bff18c9af2cd4ef9e7ef300ee58a6e951a5b7cf147ae \\, --hash=sha256:42f320d4a5b00b9af0bddcfec5407dc6f2d9816f006b2f79ebbaa31f16895df3 \\, --hash=sha256:43351bdb5e4c3cb7d1772368e988534e869a74db7778079a83782c11c69535c7 \\, --hash=sha256:43e1b7994a8b038125f722bff07492ef501110722c2727c408995d9fb864c421 \\, --hash=sha256:4887d130a7bbfed3a85493bb5a25e5b5b558d40c1d986dd16970d2bb26d63793 \\, --hash=sha256:4f07fe3ac408d8b3f768be471dc3f56d43843c47d97c66120534467a15ead197 \\, --hash=sha256:50343c1757b4b6f6708eeaf24534b32f19dfb99fb1b762c00420867a62fc81e0 \\, --hash=sha256:50983e3be33d8c0942ab88cec3905b10602f64c469b20153c48c5d4e558dd016 \\, --hash=sha256:50a195903119008fe9cc68710535eb37f556ffffd6a7759afe70a2c145587045 \\, --hash=sha256:5558a7f5a05af9ecf744af91e5baefc436f93c9333e656c27ec253f9a6bbe178 \\, --hash=sha256:56572c42e3ecd636de8d2c3dd54cf5fc939cb5c32eb56297f176a0d366fac622 \\, --hash=sha256:56d9828f204331a5ca8850fcfe2bcce95a149f1f223f60cc7216e5524978e480 \\, --hash=sha256:579f97d5120f2971876d2ddca2968135f6944d00c44c3a6590ad7d86ca9b403f \\, --hash=sha256:5af42135fdfebdadbc2bcd9c0842a48ccf0d62794c36a260b21dc4b94d1e0119 \\, --hash=sha256:5ba14a839fbe87cf7c12a6b5661c05f324a296eb8363141edb3944ba63d4c9d3 \\, --hash=sha256:5c76f1802bab718a68ac3cce447160605c734551f95c67ae90fa1132b215cb29 \\, --hash=sha256:5e8f97c0488ffda3082766ac0f2c8150a9a58c4d05788330e479cfd449b37939 \\, --hash=sha256:5f3e96071686755d9cd3600c3880183eb94b012178e92746d68101800f0ed8a3 \\, --hash=sha256:5fb6a6e919bfb703227bc1ce6579281b84b1a2ba57deb9794dfdbec7dcd1e40c \\, --hash=sha256:602c1e9b718a3275c580149f947e7fac65044c0a20e599553fb12e9700da9eca \\, --hash=sha256:657291433bf4dd3142f3abac495764cd47d0c7c92087751e6666c6447e65fcef \\, --hash=sha256:6774814fd5c338e72ee0da5cbb9432816df450e69c019f72b5d29bdec2a1792d \\, --hash=sha256:6da32b5ff3fd78d244e37300463434c7145162bfd2b6e9e915ab164da37f7343 \\, --hash=sha256:6e1d8637cf73eebc92eba2e11d4cfff98a3b562f2505bd75bba766d908926e8d \\, --hash=sha256:6e4251c0ba4624a68a2c11471a1ac54c3306876c21f0ae86de085cc9241c8905 \\, --hash=sha256:6f275c11d1aa6d4c458e05a68be084efe3c55a113d99e3f46a318098e52948fc \\, --hash=sha256:6f967dde489ca6a8c02d093ab245d2cbf50ccb5c36adf0188b17b0ca39d24b67 \\, --hash=sha256:6fdcd6af7e2e51d1ba1b4bea16e97b074bcb7b5dd0246a9d8201341bb28085a0 \\, --hash=sha256:70cb4008ac2ed1e0ca9e824deb4b53d3aa0d939109698ebf1e723a84337bd794 \\, --hash=sha256:7457580535e019e1247ea35d6a02bf081ad30c26d0cbc210c93f6c3ab67a0835 \\, --hash=sha256:74b0a9c8270f9b0a11410e124ff8d4f18bfc1f1837440ec84da5ae7b50927b5d \\, --hash=sha256:74efb69332b85675b1eabd760a8cfc2e2cf42c60607c66f88014c1bdfb40942d \\, --hash=sha256:755933b107ea7a6a9ac916f635a70595a5b1a32fac10a8ff0b9f2ab88555550c \\, --hash=sha256:7779cd97e61ebe583ec2f1c5616cdd038aa08a4453b1848c67842176d054948e \\, --hash=sha256:788ecaa9c10533b786ce5ba70c4f2df78ad41819fd00a6c99d92b66f9a32e1da \\, --hash=sha256:7bd8ac754ebd6733a3e2a0dd1674c4d8ab086196803fd8dcd776f07b4e2607d9 \\, --hash=sha256:81c2b3dfd56c62bee6108e4852d5970b4cf9086390b6983f52b666e878c1f115 \\, --hash=sha256:823c910f046f23f4c713b8d99a2242dc65f591cb45ee86418fa11762a3c2963c \\, --hash=sha256:82c7583cd3dfdc7dcc927835b4f6c7faae7ecc1ba3ca5879321621ae2e6f8e84 \\, --hash=sha256:8966ecac808dd5f473c9c4cefd10cd3ffda71c18a4d3493b7c7d2ae1803bf2cc \\, --hash=sha256:8df7d481654ac96fe1ba9a02a9f67770fdd367823e0d5ef01b922725c4bd2cfa \\, --hash=sha256:8e317e0fb6b16212c881d2205a7d87414c29acd69320b3aa6dce9d9c7b86fe4f \\, --hash=sha256:932ce7e694bbc29b2bf6f64f2343c27d148d4997c771d01bdade4639b6749ff4 \\, --hash=sha256:939042d5cda21d41a6f512e7cc8b8e33a2aebff863352251da495fbd91b673b5 \\, --hash=sha256:94684b879ac1d71e4238850c99b62dc1b28d9086b156a2555f082010b85a865c \\, --hash=sha256:96a2e584f0b9ed8f1fa33211397dcf67bb7069866402cb405d191c2f0defb9a3 \\, --hash=sha256:9ad7e6aa38c20da1be697874349c4c273c8a03b7887169665081706398d0439a \\, --hash=sha256:9b42db919715e91eb76acf3bc492a9a7ccd8bd9adc6745c1412b689735269f14 \\, --hash=sha256:9bab2045550c4fe0f7baf89574db1b455c195750702ba96fef1f16972b146617 \\, --hash=sha256:9bf1d5dcc15204d9ec8b8ea4c18fd66e6b80e5de1f4ecbafb3a2f2740f8039d4 \\, --hash=sha256:9c061aa954daaf57d2a4b8374f9fca621ef0e1b603584431c220c22458c59b6d \\, --hash=sha256:9c428eb2bd8817588d16a0ab898aa4eb5d141f896aa2b394cc79a4cf61d9a8e2 \\, --hash=sha256:9cc882cf8619109583c906b4d4a85d6a111a98afa34b7a450d1e08118d016820 \\, --hash=sha256:9ce66feae6ac65327379460380549bf1b8df8e17c4e25df2a2bcf168272e3bed \\, --hash=sha256:a23fe35d776bc03cb495938b9594450d047e3bc08c5255315a82323e9cb7d2dd \\, --hash=sha256:a2c473a355f9239efcb72c92d5abfd8fcdb0cc78c8e9af607e72ca12dbb36593 \\, --hash=sha256:a63afd1f757de949028387e65a7127b61ad0f775432dbb0e62816ae619fe69ac \\, --hash=sha256:a6d02b4c38de03d9c7617813433e6a0fb6b522797974177d69d9dad431900833 \\, --hash=sha256:a7d470cf7b206e6359fc77b1b860632fde400d5a2ed59cd0181b93a686bc81ee \\, --hash=sha256:a95529a92a446db351675f4aab518feaf5e99842f63f5dd17160c2b74f382db3 \\, --hash=sha256:a9918e58faf62ba2c7147927d06057aec78f42475aff5048047ec47e7265a600 \\, --hash=sha256:a9d3983bd6ab7aa1cfd573544ae98df9b6cb6912a5185a198263e024a636861d \\, --hash=sha256:ab52d8f1fc1b64821c1fbad64a647ed6203627004059a6d1ed4f0858a1499703 \\, --hash=sha256:abfda5cb094a829f7bc25216a32f7db2e85cc65bd59910f8e7b40b3d9b224764 \\, --hash=sha256:adbeee7d6fd4cf5fe0aece2fb3edc4243615d3180430ba8149d01a90670cac99 \\, --hash=sha256:ae53924aa853a7a2ca20ed4142c7c6b56338e4d4cd999e2980075b9efc2e257a \\, --hash=sha256:b032a0023eb41d768ce77d83210ab2a3c389bc0b09313273c7e1eca48c10a755 \\, --hash=sha256:b1b8ece1e71132d2afba4dbc0c3d62c766e25165990b25db1196c04969eb3d84 \\, --hash=sha256:b2966998927d7bed9db12c0a4647b0c7b179755878fc9c357fe1ffd3e3b0c1a5 \\, --hash=sha256:b3cc509327c7b27f6f4727a8830f4004f6df7766e179f2f4b8e54e65c0bec5d3 \\, --hash=sha256:b7806e804889231b0e06469fd4a5c06313d1c0a3377322b6d9237fa5e0fe4167 \\, --hash=sha256:bea559ad70218d230663e4210875735076a9bfea5994cef34a55a25faeaf2544 \\, --hash=sha256:bf163cc701f3d4ac43ba7d97771bf5fd955220ef5500ef3ee847bc0ecfbf4ec1 \\, --hash=sha256:c147451b4a58e7050f7f7394e6c467867c84161560001f9ad4fb2d1446743946 \\, --hash=sha256:c172db893e516e1358e65a95ee20b7ce7173963eefe318b6ab2a2220688b999e \\, --hash=sha256:c1d60eafd9c7e8e74abd03a5b00df44e7febfe6d9b89b559c0a6551eef0699d4 \\, --hash=sha256:c2c30484dd1417ef98b51021ffa2cc0d7f3c78918adaaaab7e70817335ab3e02 \\, --hash=sha256:c32e26310cc10e547f53cd13d39a369034f69dcb7d749d5cb0e5f67bc196b6ba \\, --hash=sha256:c5ed596aedb9c42afd3fe0aae3117725378ac73d2cc5ddc735056fbdb96c5d02 \\, --hash=sha256:c8859a013ae0de1074660992139a1a440df3e6b219b86cf0d3f11c2692bb4fe3 \\, --hash=sha256:c8c4478bef6d57fcfda15dae461ea3c9f06aa7b257c58df3f2300174ccbb185a \\, --hash=sha256:cb11a971a3aea10f9b8373be628f1df932964fc6c6b174516d318a48c3ac4412 \\, --hash=sha256:cb131d775a1573c1aee66656bd78b023577bbdb6cb8349a07773bd4f73e68a6e \\, --hash=sha256:cd88b01f3d37b7a2a34f91d98f14720206f1ea3d540843fab2d649dd5fb91fec \\, --hash=sha256:d05e94cdfe0d15d0206f970722d2554780ce562787b21b218b275447f8751319 \\, --hash=sha256:d079c0a0135c36e7beb6f1c88087c8f108dc5891cdd0b5eafa778421bda70ed2 \\, --hash=sha256:d3112585250b199296c26ca6e0131640b6a8d01bab8b232d2eb3763ed469de11 \\, --hash=sha256:d418ce2af40c6bb685b3f663e9e8de27cb0a22431d8e88a167348d7f01878073 \\, --hash=sha256:d51db97c96384fbfcaf8f4c65922183a68b94f891c3c10c862ef5f6df2adbb1f \\, --hash=sha256:d94e44be379e569758fee8a9a58431cfc3c2598c708b92b1cfe96c66b4c94aef \\, --hash=sha256:dab9ac5a67c8d1f070c00fa8fccb7cbd1b8dcc1a8d6b42f37540df9b3d4cc603 \\, --hash=sha256:dbf53ae2601b7fd5a93c3944deea3a78d40f495226d582c35ef7a433425ce2b2 \\, --hash=sha256:dca3fa8d8a0a26679862eccb0b1a9151b2b9f1cd2c212e7a6335778faaff5833 \\, --hash=sha256:df37b620684e19b5e25724412518ccafc3b1a49cdac706fdbd2f983fad943450 \\, --hash=sha256:e1cc2bfaee8c214f06080a7c7d5772419b8a1108e8e5349236189811823fb02a \\, --hash=sha256:e29347c142cf6e99e0dff5e2995ead1d50fa3b51bf37a7c726a7ccfe5419745a \\, --hash=sha256:e4f5cf4dc72a71c4cfa9751b4950be22f733626670230d46e7d606592aa22d59 \\, --hash=sha256:e724a7b6091f0b1ac064f9d1b15ff9ec52e6033a86cdae649e5f086e32a3c0db \\, --hash=sha256:e87046c8ff77a8decdb6a41d8ab25824b47531b2da933aeab0c1e21c7acff329 \\, --hash=sha256:e95c8def4b81c5d68d5cf1f54c07acd7c0d2577af244e5b6da802120825737c6 \\, --hash=sha256:eb324e2009fb54db30a071dad7caf6998ee2879c4704007efb244514dad1fec1 \\, --hash=sha256:ef60869969180ec2464f1349aff07138ae35ca2200f0946cb3552e49e8f301a8 \\, --hash=sha256:ef692a24087a699c0a4a26af45e746e0c1eae2116f6d8a5ff91d8aae2b867b45 \\, --hash=sha256:efc21a454892828368b11c2c780de0ff8bc991f73f6b99c6b66e56205470929b \\, --hash=sha256:f001b571ead90ca1770f1e616db255351a1703317f20374c361ef22f12c06d09 \\, --hash=sha256:f2a7966bda23dd85051f1661ce0ace38d6890e05ec6c357ecae9d2479cba377e \\, --hash=sha256:f2ebb54b3f932210503072f09974b4fb574d823e497a944adfdcd140a6a00255 \\, --hash=sha256:f2ed8b64dc0c651c0f5a9c926777719770021251b8f336d97c4b80b660836ce1 \\, --hash=sha256:f375db73a39f5cf83696d500e21a67f418dc9a988955756f254be8f03b7b3651 \\, --hash=sha256:f59c7673465908cbe506117176156c127f29f917677afceada34957179221d91 \\, --hash=sha256:f8d40ce41991e9d56fab4f5dc4a51fe59bc3b5c77c27f4b148963064d00232e8 \\, --hash=sha256:f9033b43f511f27547c557dcaba0177649e10a3725336ccd2cce0fdc1dc4850d \\, --hash=sha256:fba47bc2c3d7303c3d027c6cf4d07626c37b1314ac81f5820c31032e0ca1f677 \\, --hash=sha256:fbdc5ec49f9ca3cd24955cf3520b10a4d4c901ba2572094c84274e9e7eb30534 \\, --hash=sha256:fce9523df31cea6284f3e2c479876750d7687cf671d7b25d32b19effc0e86441 \\, --hash=sha256:ff75a7537413a86e7cafe98e0e1d6e3dc4b15c6349896e7d5c6b881bfdb6d550, # via dashscope,aiosignal==1.4.0 \\, --hash=sha256:053243f8b92b990551949e63930a839ff0cf0b0ebbe0597b0f3fb19e1a0fe82e \\, --hash=sha256:f47eecd9468083c2029cc99945502cb7708b082c232f9aca65da147157b251c7, # via aiohttp,annotated-doc==0.0.6 \\, --hash=sha256:361ca0950cc7082f53fa69e9328409f40a62c61e57e0a47e1825a08078a58a53 \\, --hash=sha256:7969bb69912085b2285849c0dcac0b4b374fd180c13cf10a87f284ffcf347bbf, # via, # fastapi, # typer,annotated-types==0.8.0 \\, --hash=sha256:13b2beaad985e05e2d6407ee4c4f35590b11f8d693a258a561055cac8f64cab7 \\, --hash=sha256:f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0, # via pydantic,anyio==4.16.0 \\, --hash=sha256:59bb03251907983d1603d27c3087ddb1e93299ea2163adcdba37899a4fb12ffb \\, --hash=sha256:c66ae634e0b8228396b801741beb3294326d4b6102f7bba4041c0dfb58c29026, # via, # fastapi, # starlette,attrs==26.1.0 \\, --hash=sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309 \\, --hash=sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32, # via aiohttp,certifi==2026.10.23 \\, --hash=sha256:a9895e6e2758b371e0545e321a3a8fd1fcfd9829ada8824a936dfb16aaaf36cd \\, --hash=sha256:e9b54de76e530bb6cf0ccd036787103acb58fd42ba930ea8bf948ddbaa2f61d1, # via, # dashscope, # requests,cffi==2.1.1 ; platform_python_implementation != 'PyPy' \\, --hash=sha256:046bfc24911b37851ee1b51aab8bffe713d89c68c6a057b09484ce9fd5f69b4e \\, --hash=sha256:06c72bb76605a4b0cd0aad6930b69d4baf7dd5d806cfc409b824191099700e66 \\, --hash=sha256:0beceaabe56af686895136a2de78db54ecd8e4046b236b8fd6d6cb61389e9bf2 \\, --hash=sha256:154852545011f779917b11c78db2358d095da62a9a172b78ad0a583ee5adc0d0 \\, --hash=sha256:194cffa889098ced9976c3fc6340305e43f6303657d298da55366907c05c22d6 \\, --hash=sha256:19ee6127ee34de7d83ce3d371ebc5ed91addbdcc39f9ab15ce4eb35a4e534971 \\, --hash=sha256:1a18a57b58cfb21fc28d72e876acf10eaed67a1ed96226f92af4df681d571c4c \\, --hash=sha256:1aa5645c30469b09530c4ebca77ebf8f17618293c58f8549cb1a543a50236e7d \\, --hash=sha256:1dea0e4d7d4f11f619fe8c1d76caf49e24405b4b5743c0e3be16a500ecd930c9 \\, --hash=sha256:208f941bb9d18e768138677f0a6d2ce01f590df56043dda1df1535ac57c88517 \\, --hash=sha256:210019b6c7cf07f081b4c54635c8cf744377001350e29cc0f81c4377b4797735 \\, --hash=sha256:246fa40ce8645a614ff682e0b70f37134e460eaf93a775e0cbe3cca585a67a80 \\, --hash=sha256:25792eac27877609e7bb06d42ff88278a6624fff2ba9bbb523c09616b117e80f \\, --hash=sha256:27350daa11d4f10c540e6e89dada4c54feb7256ad03e9a4dc075ebad7ba360d1 \\, --hash=sha256:28907ab9bfb6aa13184cfc17c6b8e1023c5ab6fd7076d8c20a35e59fe04f8f29 \\, --hash=sha256:2ae64be792b8966f2c69538199728b290e34726562896df1e5dc8ffd8d8188e8 \\, --hash=sha256:31348097ff5bbe827ccc41795d4dd099d9f0625e7def00ee653c137a490c2a6c \\, --hash=sha256:3143d81e29e1e20a9ce10901ec369012947876596f75a222235965f2b7ae832e \\, --hash=sha256:3222ba5d678f80a030e6afbcc33dc1ae5cb45facabb61cee2c7016b8432fde48 \\, --hash=sha256:3311ed60d36f83378794e1009ac6258bafbf81f7888b4caa7b35a521e3f95813 \\, --hash=sha256:334644fbac4eff73d985a17a91226df55d0f394160c4cfb880e084c8f7161cac \\, --hash=sha256:34e261f78cb6ceaaa36f42f2613f4380d94d9c759a9c73c769ee6e0247364632 \\, --hash=sha256:363e05fa78e15116c3c32c210ee36884fd6b9afa6d440e47112c3bd511d64cb6 \\, --hash=sha256:398aff33cee2767e3e781d2554c54bd0dff386bb437581e0d8011fde1a942ec1 \\, --hash=sha256:3d22a20b1fb1632cc72c22f95f7b0d2961c3e1c235f245ba4c606c4771035659 \\, --hash=sha256:42a494cee34437f05546455144f2b5d9ac09b1face62bcfce597d2e521066688 \\, --hash=sha256:42e2f76b9455f5a9a844f770bf3e200ed3da0e15f5df3db9c31fe80b04b3d004 \\, --hash=sha256:42f6930c31dc7f50732c9ae793c2786c7b6b044195967bbdde40bb9be81c4cc0 \\, --hash=sha256:456a61fa52d579ebf9df2e9552ead5129855dbaff6c1e5a9b1bc408809bdc062 \\, --hash=sha256:471cee653ae88de62096552e6d24ccb4a5adb8c8c9f10b5054d0122c15bf2779 \\, --hash=sha256:49cbc70e6542d4ccccb936558d1064a8012541e78f821f955cff24e357776c94 \\, --hash=sha256:4a7c934f7360e8cd64fe9efadcbd10c7c6364f531e432b9a4bf5ccbc9e0e8b50 \\, --hash=sha256:4be96343e422f2dfcd12ab5c9f5aebe03f82f737c6bffeca6830b3875cb44aab \\, --hash=sha256:4f42141fc14250de6dde5ee7ea4432be017252d91f19c5ad043c084cea629cac \\, --hash=sha256:507a24c282e0f42f8ed737cf048572cbf580468da5555764a8331735e9c736b6 \\, --hash=sha256:51b31d1c98274844cfd7838ce00bfc27c7423a4dc00fc0772fc3331c2cc90676 \\, --hash=sha256:58acb8ab8e295e6c5ea12f888cbb13cf21511ef2a3303a23f4325c29d17fe5c1 \\, --hash=sha256:5a59cc1c4442bc3d5c703bf720b51138d0bfc173618807c9ee2490a7541dd3d9 \\, --hash=sha256:5bb4e7ea95dcd6a014a6fef62e62467d67d8e582326443f3d68e71d6320a9fcf \\, --hash=sha256:5c58fe613dc5e5336357eff555824a314d8e43282600435c8d1cb6a7a2fedd13 \\, --hash=sha256:5e7cecbaadb83884793e05828cee59b210b24583b9c7425d0ba6a754fe22eb4e \\, --hash=sha256:616f097f2fe415bc92a247f02e11f634e1f9e9a83d327e3c915c15089c87869e \\, --hash=sha256:63bbfd5ded17c4840ac07cd8f1c21ba9d9708141f840b324f422f41b207e3973 \\, --hash=sha256:64faea20f4e2613363a1a9b9c7dd73058f3ecd00133a511e72ad7c511658f527 \\, --hash=sha256:661c298b4821edebead0c91edd2b00374d67ad7c5a1f7a91d4442633b79d6a72 \\, --hash=sha256:68e62fe11f30d5ca8289242866f0a5291402d8529ca2178ab8afc5c9694ae890 \\, --hash=sha256:6a8dddef476fab96d066d578fc88526767b836ab5ab21754e1d5bf3879c31c7c \\, --hash=sha256:6e192623c49c94421616a5778fba35cf0d5a8d000650c1967ef4448ee5cdd990 \\, --hash=sha256:7225e4514edb64eb6740324353e0da0711954fd8d7da4576755b1c6e09b697cd \\, --hash=sha256:75f80557d1389eddbd0de2681f6a390a0c5338c31ddaa821381c203fc3fd50d9 \\, --hash=sha256:770de9db11e84213beec501cfcaa013b019820ca881e03344dea5844f7876d94 \\, --hash=sha256:7750c6449dff7864bb9bb27ddfb0267756189201a3afc911d82b3caacd70dfc3 \\, --hash=sha256:7bde5e4cc5c10140859842b9d383af292b22639a4dffb725314baf45968cef80 \\, --hash=sha256:7ce713ace7c0e4520535b42b77eaa742c16dab813978064913e5a3cf82973b41 \\, --hash=sha256:7da0c5eff80f0197f3b3d1232ec5a682a9325f4ae9016a78f5f5ca35f9ced1f5 \\, --hash=sha256:7dbb61fe3a7699468030f71bbe5f8a0e326a151daa91beb11a6fc1f980c55e1c \\, --hash=sha256:811bd1e21d32de12efca32393a0ab3f5133b54fce9bd44b8bd77ab07da14bf6a \\, --hash=sha256:8ef53b2de9bcb9197d31854256575d59dbac0cba72ac627bb291ef5eceb74be4 \\, --hash=sha256:937c0052c05a31ca1daf18de3158eed4dbfcb9cc107adbea227728d647be701e \\, --hash=sha256:9d2055050ea716bd38b7f7f1579c275386646b4894c155a3e2f3cd62ed41b7c6 \\, --hash=sha256:9f8d177621de5cb38ee3e731eda45d421db093ec0739f46a5594babda7987a98 \\, --hash=sha256:a2d7755bef5a12ed488f4ef1f1b69ee9191d7396083b755a5d2295f6edb4768b \\, --hash=sha256:a48d62ab9d6f4f98c983223a547af44be6ca3691074c31cecced6facd3ba2dc1 \\, --hash=sha256:a4f00aa42f75d6e4595e8866e748cc1705adc0cddfeb2ca86d0d03993d63ba03 \\, --hash=sha256:a6e721d4b0e45d5b65e87534470e67b18dcd092c83f68fba09f152b9cbc061af \\, --hash=sha256:a730a083190634c65cca36ba5f489531576ebd79bcd5c8e172130f6453127231 \\, --hash=sha256:a931079504ecc49efed7744c476a5c343a92fabf66dec2db95edb1b2fdc770e2 \\, --hash=sha256:aa9511c62d14da7aacc9b4bf51f3f697a621e83b2d6919008243c3aad168eea3 \\, --hash=sha256:ab36d55f9ed2d067327667c2fea18dda018eb628dd6347aa01dda6cf1f5d3836 \\, --hash=sha256:ad2c86c495b899d862ea0f4b42891b8713a3bd45dd4105c7fd51c2a72f39f3a5 \\, --hash=sha256:aeae0e330c9f6acd681f647d46cefd30c29f93e3392882e792e82080c9691399 \\, --hash=sha256:b0431303acaea1089ad4b3e9ce4e6518193def1118d4073ca848635ee4ea2e96 \\, --hash=sha256:b5bdfd1c873d4e093aabc0ca84c4ca6dbc4f752afb5c86f146d9742580c9da2e \\, --hash=sha256:baed1e86cc735622097354b9d1281406caf42ff42a886d29faa8e8d1630333be \\, --hash=sha256:c1453022f490d2459a11819d83ad1d586e9ff65a12ac3e705ffebd46d3685dcf \\, --hash=sha256:c26608d2222fb1e94487e4a387d85f13eb55d5ed725cb25a0c589ac4ee60e7bc \\, --hash=sha256:c7659f22557c5a0bc4855cd635f55edec690cc008a40768527762cb9fb263455 \\, --hash=sha256:c8c69575568085ba0b1b10c0249d779a214aea6f6522e949a0fc9fb0fcb449d0 \\, --hash=sha256:c8d2c9fd1f2d16f780d15127abb050d13d1a76c03a4bd87d7e4980e45e511e12 \\, --hash=sha256:ca82be1a1d406ecfe1d25dc16cb33488e5a16bf4438c9fb590484ea29d92478b \\, --hash=sha256:cc572dace3f60ef98d7b12ff411d20f5362feb31a0439eab0085bbfd349982d7 \\, --hash=sha256:d18e5ac0f2f03f4f518d3e23db0f0cad7faa1da8620e9c09461d443bbf6e6692 \\, --hash=sha256:d28630f5854ab07ab1fd4aba756de52326c82e6be15d414b12793f1975048b54 \\, --hash=sha256:d9c275eaacd24aa73f94ffd6de08fc3f932424d8b6c376f4bed7cde376fe7bc3 \\, --hash=sha256:da0e573f9f97159390c89d9f1a9e41908b66d408cc5b58d08cf3847d844c531b \\, --hash=sha256:dd31f52ea1086513bb9df30f8fcee9b8918323ae067a3d5b78bc826a000712be \\, --hash=sha256:dddad92b554513a31f272570678ba307fb9f618f05e3d4a5eacafff9eae03e1d \\, --hash=sha256:df423d40ee8654634421812bc3b196da3f9bd7d32929da813f8394c4348a5358 \\, --hash=sha256:df913725b79db7bcf03448f36b7bf8815363417d5b58deecf9305e3e30f0f21a \\, --hash=sha256:e0bcb7e0f677f543555d2adff3bf19c05f66cdb4796e5ff602442ab2fe3c4ef7 \\, --hash=sha256:e2d65b31f36619cda3999b78b2aa9632e76b78448e7a56fc4240824200e7c4fc \\, --hash=sha256:e6e8cff14d6fb0be70a09c0bdc58096f501952d04624ebf867e0e56da2df8960 \\, --hash=sha256:f16c709686a78c727bbbf059f92b0bf41c6fc60deec706d2dc19f529175a6125 \\, --hash=sha256:f24fb43132a4c6b4cb4eb029492919b2db645be6808d738f244fd146c03c32cb \\, --hash=sha256:f53e442b08449d42821fa4a4fba000095af9f62742a500f978a9f557ec44339a \\, --hash=sha256:f5cfbc5fe74540d335175b656c725d74d90e3730c626d92575eea35029d9afaa \\, --hash=sha256:f81b3b8f3d4e343550fa4baa0e479bba9f2d29ce9c2e9b51d1ce1718d7442fcf \\, --hash=sha256:f8ec5e643a9a937f64e1999eb9f75d072263751912dc5cd06d3c85f8f44be7c3 \\, --hash=sha256:fb92203a88b3d3053034db775110081c49d28be6551923805e039924093761e4 \\, --hash=sha256:fcd22650c908d7b7da162bbfaab594a1227a15d1643a98c68b122ac642fa2264, # via cryptography,charset-normalizer==3.5.2 \\, --hash=sha256:01077390b03f7988f11d700a2194e69b119741a86b1a638b1db88891e3eced8e \\, --hash=sha256:01b0c0d2262a9e28e8484a278c7e1b5d650e3ac8cf2683d2967e25899f208bdf \\, --hash=sha256:04851f73ae72b8413dddadb16a49dfee95263553741fd42d546f7d66907e6be5 \\, --hash=sha256:0521c5665880b33d603717defa76c094048900010897909952397feb3039da56 \\, --hash=sha256:0774bf9bf620249fee3e0b8b9fd3065de213be30f3aa94ce2494b3b638949e26 \\, --hash=sha256:0891b9d3903c5571c03771ca669a4b0ec5618ca722a5c957d3d29cd4e5062848 \\, --hash=sha256:0c951d5e6dd9c2ff60609476752bee49da4206adde960ebc247766937f72e718 \\, --hash=sha256:0fed1d06615f022ee3b13caf5e8b180cfea32bb2c5aded8a9d44277afc040f93 \\, --hash=sha256:114e4d0c92d618409ed82a99e22b5c5e768fe995f2973f78265f4524f49d4640 \\, --hash=sha256:11912e4bb14baae7c5d8791aa55ba0a3a03ec6729073307b0f57270abaa713d3 \\, --hash=sha256:11a4d68a6ecda3292cb1e50239e111543ba5d709bb62a6b4ea1afcfa729d8875 \\, --hash=sha256:124fbf1a8ff966d87ae05bb8bd45a71f966055ed8bba320d0c7cf450bc5f4d0e \\, --hash=sha256:1461ac396c4fdb983a675f20aa555624f0ee18ac83d832b9244ffff3d8055275 \\, --hash=sha256:1503bccbeb36d5527790c3930327704c39af22de3112f1b1666a9f3ce15ee204 \\, --hash=sha256:15bb4005af6320d259dc7593ca84a38d7fe06a421dbcf7b910ae23979101e787 \\, --hash=sha256:15c44f7edfd477b06f517a5cc317fc1707edb9de2c865f43d4b6513907473234 \\, --hash=sha256:16fa0eccf81304b79c5cd87f9271c3b85dd9dd99245e4422ae9c0dd45e0f99d3 \\, --hash=sha256:183b88127acdb4fabe59d951ab424faf1af7b63cdbb5f776186c1ea2ffcaed98 \\, --hash=sha256:195c26fb65950f8fce54e26349852b7bdd7c5f120aeefbcc440b8a20faaed4a3 \\, --hash=sha256:1afb975bd5d68d5ce9f6b6d44fdf2f7e34b895a35e95708a7a91b20a3b51d187 \\, --hash=sha256:1b4cbc7c3491ccb4aa17fcd8165649d01cf39f76de1696da8631b5f71b85401d \\, --hash=sha256:1bc0baf5ef96b6ede57d47f4b8fe4d9d84019c3bfcbeb20a41edc6a6ee341f1f \\, --hash=sha256:1c50fe28bbc2ced33386f298650d91218076c05420e6cbd790b913adc41659e7 \\, --hash=sha256:1db38f4c5496827c1a501846d64d14c3b80c7e6714e406cd7dc36a9899fa1011 \\, --hash=sha256:211d5a3eb6af8f513b8d4ca19a8c1b7accab1b5f0d3175f9826b03c1a920dc1f \\, --hash=sha256:23851fb4e1b85ed3f6c2a27b777cdfe2e19fb5b38429a8faf38c7542b7665869 \\, --hash=sha256:254eb48b9fa5ee9898a3c445825a1f340fe53712a098904b39b0bddba8ea3cb1 \\, --hash=sha256:2625388c6c754520c37abaf3b41eb34d1cc4a373f457898f08606c8e362b891d \\, --hash=sha256:281cb91036248400f4cc957495cccd44c275c2e0c5854f7e45ac5cf7dc193847 \\, --hash=sha256:28a15fdad492a99b6eccfaaed66ef3f74050680545ea61ec8b2f4c538f1f1320 \\, --hash=sha256:28b4f0d66fb834ff90f28209ac7bce77868c45d8c93e26f906709d9b7c2e1af9 \\, --hash=sha256:2a925889534b3748302dae5dead07cc13480de1dac3aea80a941b729b471ef93 \\, --hash=sha256:2b7b3bbfb4fe8ef40600792d762fbaa9057559f9d3fad209525b7a22b99e91fd \\, --hash=sha256:2c9ad19a6cfcd5ea5c0d41161d22f9df1dcc277e9bef2751391334546a314c00 \\, --hash=sha256:2cc961b171b3f3440f410489ab3573e86aea8736134ebbb40ea1338b7f0831bc \\, --hash=sha256:2ce45c6627b22c47e390bc91a41c3d13032192e699fa0bea96e9671b373d69b0 \\, --hash=sha256:2e06a3a98f916dd41d27f3105e02e7a40181c98c94b9158733d03a6f80506c09 \\, --hash=sha256:304d5463e65a35d7bb0850550e0780395395f6fcf452f04db7d5ca7cecc425ac \\, --hash=sha256:304d8e4d493af723536393eee0c689eb7813f4a474c8b479dee63f1fdd98f621 \\, --hash=sha256:30fcd120b732aa79317f08dee04d7de0847822e4cf7ee0e9f445bb958832252c \\, --hash=sha256:31f3930700408d211f13378ccbe1c40845d8da54bd0681fac3a9b5aae81c7aa8 \\, --hash=sha256:34276fd796040bf0993ab33a369aa572e6979c7aab225a88893667ad8eac8f7a \\, --hash=sha256:355ad8011081dec5412240c087a9a0c9d4d5039f3ed11a3f13e18c2b29b56c51 \\, --hash=sha256:38a873987f3be698494da8b2e3085e29da02da7b633dce73e79c699a113d7bf0 \\, --hash=sha256:39de2a259fc954455c57274dc94c79d5842774e1247a016aff30bc0efed0f4ef \\, --hash=sha256:3d14b50de6bf4d0edf857a9386836846f982b8f524e188e2e68b96d702bcf4aa \\, --hash=sha256:3d21b8b13c7592db2ac5e544a6d83187b995257472b0c9e8351b6d507ae37ed6 \\, --hash=sha256:3d31298449090ab8d47b7b1b2a555ff73cac7ed438a08b7ac160980c7ebed649 \\, --hash=sha256:3ddacd27458c45bdacd6bd6db644bfb730efbf9e830310186e3045c9c5be8fb2 \\, --hash=sha256:3df041de8887954562c9b261cba85ca0e9ded74048daf125f45edcfaa4832229 \\, --hash=sha256:40ab6bffa02ae10a0581e6c198be7d2d8ca5c2a0c64e4ed3465d766df457573e \\, --hash=sha256:4275811936e2f06feff5e598fb42a1b7ae852da8e39605211892b56b81a34efd \\, --hash=sha256:443eae2bf318abeaf6f15d785138f71fd6de770e99a92158b8b814265e079115 \\, --hash=sha256:447441e76ec720b15e64418d32e092297340387053047c7c694f579efb0ee1d9 \\, --hash=sha256:4495c5002a7b28557e7e222e77e0b661183e432b7d6d2e788101e3f240e05b8c \\, --hash=sha256:44bd4fbb29dfbeba60e7d2bd000c59e4b21ddb3cc53912b14048d37092706d7c \\, --hash=sha256:4685902cf26edf013ed7a3da0f426ebba7a00ebb9541386d835afbf002c11cab \\, --hash=sha256:498dc3188ca05a68231ac3fdbfc7f57eb67e1343c30e0fea17f8218c1599b253 \\, --hash=sha256:4c2b5031f63e331e3839b40aed2dd6f191e9c07edbde303e7876846ea1946995 \\, --hash=sha256:4d48f2d08b9de5864e2c8744d4461b862fb149a18274abc8b698c45975573438 \\, --hash=sha256:4f87960d57feabfb618e4e0af6e7371645fa26a277860739d6e5d6e0012c92f0 \\, --hash=sha256:50e3adfb96fc189eb27b1cf62d3b598b89b4bb0420d93a3d3e42e137409011be \\, --hash=sha256:51cf45226a9b588d0d2b4880c62d686934b63ab0bd79ca23ab0e9762eb27441b \\, --hash=sha256:52aa6992700996af31f375de0c6bacd402b0097fe40b53c426b9f51a90ebabc7 \\, --hash=sha256:55ea99acb17b9325618de155a0cd6a2e8f5d10be008113e1d433bbb58db543b2 \\, --hash=sha256:56bc200a365efb37383b7852e4cc5898d3b2da5987289b543956cf8cad71018a \\, --hash=sha256:588461c2e8384d309bd63e5826019b6977bc66d629b99ac8737bb795d7b2cb5a \\, --hash=sha256:58ca3755ee7ff7f59b57789ec9833c9de9ea275405cdd240eda1f193112e398a \\, --hash=sha256:58f361dcbab699cf8f42db3f47c8e7fd1036f138c23a5d08de9fde5f425a730c \\, --hash=sha256:598a11a2c7ebaa5334bf698bf29568c9c390abac6a154d8170fedecd1cea38c5 \\, --hash=sha256:59f63901b0031c3136cf64704dcb21de0bbae62ce2c9529bc39d27665463de37 \\, --hash=sha256:5cde776b7cc66e4f6c99612cea4aa7269aa65863f7a15841b2c264f103822f4e \\, --hash=sha256:5e2b6b57e9733d39f0c9fd3185efa6b8e29652c4cd8fe94180272cf6ed9a78c4 \\, --hash=sha256:5fb29fb8cd1a46c27a1bf9613ad5ec2599310d46b4025d9556404a6b6a292800 \\, --hash=sha256:6045373d5a89a5ec71afde535db987ca28e76dfa276c2d4c818265b375d4b055 \\, --hash=sha256:619799369eeef6366ed3e8755a5670f4f2f0fb6b30a0fd7264dc0fdc2357058e \\, --hash=sha256:62588a277bfb59def052abd940703fa35107152bf479781a878617d60faf8fb5 \\, --hash=sha256:62603db9a7caa0802eaa28c1c46fecd7b3a263a774069c24c3c28c302448721c \\, --hash=sha256:65cd72beeeca9d3aaea1201e5923859f308f952f9c71de93f06063c79f0f7a3b \\, --hash=sha256:68eb192d85ab8e5f6ec69c2bc6ac0179fbf04a5ac1569d12fbef74883fe102d0 \\, --hash=sha256:6bd128f206a7752ae1f2ab6c61bf8a24ba28913a10df8b14c2637b973ff97a80 \\, --hash=sha256:6be488a102b8cf28d0391d8c4ba7748938ae28b78ad901f8585520fca33ead1a \\, --hash=sha256:7218e8f32b0956cfcd048fd42d9d5779809745ca1d86113ca56f66e7ae1549c4 \\, --hash=sha256:7441d755b7ab94f8d4eb3e43ec05482d760842fd263d003a99102d742cd835e2 \\, --hash=sha256:749e97e1b32313717a565abbe321bc2190bc8b35f1a67e4cdbc7c56c8d8ffe58 \\, --hash=sha256:75a3ceed0724d625d64b86ca20aba182e4df462e04c2414fc941c0f523f06aac \\, --hash=sha256:780fbe7cab297b81dad9fb8dc5eb003c0468ffb0d9e5f65068c53a34661a96bc \\, --hash=sha256:78456a747de8dc58360ffa581f30a002baf5aa28cb262536545e91f113ed7639 \\, --hash=sha256:7967d08cf06dee78443b874f98c98036f624f3a4e73e11f9f64f5be4d25393cf \\, --hash=sha256:7a881931aa470808df94a8c380eed2bbbc76cd9dc622310f99665658c821eb6d \\, --hash=sha256:7dcd882da75ef9adf94903b1e3b9419e8aa8fb4c7396822b834b9ef7fb96954f \\, --hash=sha256:7e841fb9010836c992c9f12fcbd43a831de93a5f726fc1ccd8ca1d0268c5014c \\, --hash=sha256:7fdde2c9fd9e3eca40631e024664cf2584272cc8f96308cbe5fdfc930f51d8bc \\, --hash=sha256:8024d00c3faf3fc0c16e07a69f4405e8eac7cc0ab15f65fe6cf43827c4cf72b4 \\, --hash=sha256:80d02b6f04e92601a081dd97b23d3128033098bff5d35d392ddcc0476ea11253 \\, --hash=sha256:838dcc90063569a0448120554591a1d6c4a4ffe11babf048908793154ab86ade \\, --hash=sha256:849df64e889b2e17230d58410a03dba311a65b163508fd33679b2b737d4b7858 \\, --hash=sha256:87475fabc8d9996fd9c27debb395e642e8c838d78a00b6e932227a0e06b81e26 \\, --hash=sha256:87e50a3e7cb90af586b6c5faf23e302a970415ac73bd7bd90a515a04b427ef96 \\, --hash=sha256:89b53f3cda69831909888e0494f4fa0bcd3537e3e138dabeb620bd6ad946bae8 \\, --hash=sha256:8a893cc101149f80a653f82062ebc95b34525a2614382e1da5458fe7c6997249 \\, --hash=sha256:8b2bfab86aa71ae13aa41a6a26aab338e0db2b8bc75434b05aea89e011ff35a4 \\, --hash=sha256:8d86d6fc60743dc916eb79e2eb1ec4818e21e427731543af40a3021851174a13 \\, --hash=sha256:915563965d418f986e7e145accc592eae9e1a1be3566ff98a05d7a9ec42a76e1 \\, --hash=sha256:92888bb3187c5ba50500b00b3b310c9f2c651709d28036077680cb5255450a03 \\, --hash=sha256:93223adc95033dd47133a46ccfc316a0139176fd79085762e27202ec56018f03 \\, --hash=sha256:9373ad13ef0d2c0fb761e04e55bfdee5a08b52cef2c882c8fbe9935b1517152e \\, --hash=sha256:9409a8bf35cf78353942504b24a57de3d75b708997a1e4bd8db71ac8633ce364 \\, --hash=sha256:9b7f416ff0978e2f2249330527f0ad6fa02f4932e6199692d3b52da2048c19e4 \\, --hash=sha256:9bde855991b7e362c146535e3136a50bfaffc0487d38b33ca7e5edefc6e23849 \\, --hash=sha256:9cae88599c7219005d879f98e5ed53341e9a122af585e1091200358a3003d2a0 \\, --hash=sha256:9cf9b1a857e25c4baceeb3624e92a56df3668f398c4acba74e174d81fb4d1d3a \\, --hash=sha256:9f56f72050826f63dcee7a7f55b0a77168cb3bfc553fd405e7f8f9ece75a4036 \\, --hash=sha256:a090bb2c68df85450502e3e20d665e3a5af9c65a84d6508ed477badd49166fd3 \\, --hash=sha256:a192e2c40070d92c3ccf777e3a5c4ff515573cd2bb7ed0c537fdadbbec5bbf21 \\, --hash=sha256:a19a731138fc27d5682277d3b9df22855cea1239bce7fcec5f78f42ef2d1f3c3 \\, --hash=sha256:a66c3bc5ab1f0ff2164fc9965ddd611ff0802173f4b9d24554c563f6ab7e1d6e \\, --hash=sha256:a815775b6c38d4e0ff7bcffbeba67feded90202bb6a226b8dd35f1c855217413 \\, --hash=sha256:a89012d6d5476ee112d20d998570ed58df2260a852afb1758809cd6900411d21 \\, --hash=sha256:ae4f5fea5b8b8ccff88238cc8569303e5ee95efae67fa62922a311397a71f346 \\, --hash=sha256:b6856554c4f44d79fc2307d5768854310a8f0096e501c75637542c82292b0429 \\, --hash=sha256:b6b751274acb69d77b3323d6b7dbaa3c7fdfc1eb829b7eb61d262f32e1af9685 \\, --hash=sha256:b736353c0a625bbd5fcec108576e2385db3496f4f771f785ff32e108d3c3bc45 \\, --hash=sha256:b7fd005a73d9e657273b7a10dc71a9e03c8fb9ee6999798d6918ce095b81ac7f \\, --hash=sha256:b91363207bd9dc966a691e959bb47f64b30f7ac4b072be9968b366982f7db77c \\, --hash=sha256:ba0b1d2620edf869789c3879223f52bf2afc5d31b3cb47cc57b3a12c05e2aa9d \\, --hash=sha256:bbbfc8e28816f19d7c0f1816664980c0a9875d01b27cdf8eedddb639d9e108ad \\, --hash=sha256:bd16aabe4a02a297c23417aa17ac6299dbd8c49f673bcd645b4929b11f5a4400 \\, --hash=sha256:c0afc6800ba57ccc350374c5bd6150419915d95ce93cdbab2d783d75eaf30ecb \\, --hash=sha256:c6708715abcf3c73b99508253e961a9967f02fe536532834149574eda6de0d1c \\, --hash=sha256:c7c9ab723cde841fefb34efbad91e87f00a674b1fe1cd0784fde742bf2c154dc \\, --hash=sha256:c8f3d67aeaf55f017982b73683f0e7342ba2f6635a78f69ce89ebb26aa411e5c \\, --hash=sha256:c9790464842f85f437dbbb54417eda1e0e6bfc52dd8d22d6fd1c994b73b2dc74 \\, --hash=sha256:ca403d7e4798f525fdfc78e258820419cbbd0f0ecbab9de7840e3c017cf6b8cf \\, --hash=sha256:d008d90a7f2471519aef0c90dfbe73b3e6e4d5e66ac48e19154c17e89e98b604 \\, --hash=sha256:d19fbd981a488e22cd04883659ca6b08f50b5974f9fd7c95655ef6a043e5893f \\, --hash=sha256:d1befeed746d247c81127bb14de9dc3d30edb6e5976d34f83f86ed262b1d9105 \\, --hash=sha256:d2374b62878abb00cd8309b32af6c0b715cd02dec0ca74ef12e5069bdc64144a \\, --hash=sha256:d376bbd28b3a8999db1a103b3b388aee6f1ddeb3e51bc2172993efdcd86e064d \\, --hash=sha256:d4a7319f304a774bed22115bc891618e45f85065ab44ea6acd07d274e750519a \\, --hash=sha256:d6734d2ef8a50fbf8445c139477da401f50d62a0606bf00e20ec6d87773fefb1 \\, --hash=sha256:d760fe2a4d7c3b226cb9026d6a842868d52a7901bd98420e1baf14e80da85cf5 \\, --hash=sha256:d913de495d90407cd859d263bee2e5d1a4ed3eb6573c04e70d9ec619a7cbed7f \\, --hash=sha256:db19d07e2e0129e974a0e65d0064fc222a446cd5122c2fd4184d2af9fc734a9e \\, --hash=sha256:dca9ab98072a5a54ebacebdc45f53e645336b320c667410b061be1ca588ae709 \\, --hash=sha256:ddc7dacc8ece3a182e7f15cb862d1fd616b46d076cb1ae9dd232b2c38b655874 \\, --hash=sha256:ddf19c062bea7a0cc80f519243d2c01dd091be0cf952a0750d4ad576709559f5 \\, --hash=sha256:def79fa35ef0cef8d2accec024f4fdc7ead3012ff02f5215c783f39f03ef8cfc \\, --hash=sha256:df29a0a7107f7011e77f4eebdddec4c7331e24d787a0b21a46d63bdf7445da95 \\, --hash=sha256:e09a3942ecbdee5cce73ea9d42da82b81b72ac1bf031ce069b93b5adf4eac8cd \\, --hash=sha256:e242bb1c5e76e97dfa9e7f209a71e93a01d7f19ffdd5cfbb2e2d55b4f08f8ab0 \\, --hash=sha256:e243bd13217235fc7290c621941c3f5cc8b66e4872495be821d7436ba2fb838d \\, --hash=sha256:e2af3aad578aa6bd1384bcf4750fc285e5a9de53f40b7d41e5a0bf748edeb2b3 \\, --hash=sha256:e4e81e09c1578b8df602e3db08b0b3ea0a6947ad612f52bf8dc5ea8d47691f0c \\, --hash=sha256:e54da4baf05720032d527874d40b65fa4d7e5c6c6a43d0c3adbeffcaf275a2b3 \\, --hash=sha256:e80e6c2f55656b4824d72065abb4ddd6a525c74bd78a0aab5d9fc2cf4fb5af50 \\, --hash=sha256:ed2a239c0ea213acc1908150a3037257083c7c083128f1a4cec2ec4b97dca491 \\, --hash=sha256:ed905975ab14056a2e5eb1c376cb2e1ebc5396baf84163939c518556fccde9f5 \\, --hash=sha256:ee21e28f0430bd6dc9086c6e525d5e818a44a5ad19720c8a0ef766792f3eb5e5 \\, --hash=sha256:ee43c17b173d46a3212baa6ead3ae258eeabdae48c263a01ccf0218c366dd655 \\, --hash=sha256:ef4fcbf3327382cd4c9f540babd61248208af7b93eec4de397b4d5f58a09e288 \\, --hash=sha256:eff0ac9dbe711a4aee69bf04a83896aa9b85f19641264053a9f6d48573abb7dd \\, --hash=sha256:f0aa869112ef88429ae17820d99c3dd9504c9e9c671d3c246f3d7442cb051084 \\, --hash=sha256:f3c96f633825733f735c5a9cf21d21a257d8e1edf0b1cee0a064b9c424ca0f7d \\, --hash=sha256:f5833ad231be5eb6553de524a70f48d71b2c8563101750531e0b80184e175cd4 \\, --hash=sha256:f5ec61164adcec446f8969a3358ec3f9b26bbda3b9213e5586d219afa8df2915 \\, --hash=sha256:f7d486c83842422badd511868fd8a9a20e9407ace71564b6af47ce7e60a336c1 \\, --hash=sha256:fb9e68df06293761f9fe66ade60a9bc6d0f5e42b8acf2939a9158af86ab0e5bd \\, --hash=sha256:fc14a032f813bf5fe624d991960ea83e9715adc27e4c1830a2361eb1d02ac341 \\, --hash=sha256:fcff63213e8e6e47770541a4607175404f47cbb3ebea7b6058cc82d524a0e424 \\, --hash=sha256:fd1fbe0f116b6e55da77aca2c6ddcddcfac2186cbf78bdebf40fc156efca389d \\, --hash=sha256:fe9753dfee015c570d73df76f899f18444d41388bffcde097deba51c4fadbb9f, # via requests,click==8.5.1 \\, --hash=sha256:8bb5376d2006950386f8c6427613334a2acadc5f559cb80e638d00b4df957e37 \\, --hash=sha256:9bbfada76703fd1d784b83eea012e3e8c6a001a876543ef104fa56aaaeb072b4, # via uvicorn,colorama==0.4.6 ; sys_platform == 'win32' \\, --hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \\, --hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6, # via typer,cryptography==50.0.2 \\, --hash=sha256:0ddc924c04591c2811ca024d62ecad4f7f6f08af8939c211438f48a16bd23602 \\, --hash=sha256:0ec5f09541743261e66e291b4a0cbf0fb2997aeaab6d9e9c740b9dba1b58d1c2 \\, --hash=sha256:0ecbc5652bdb6fc9eaf89a7d196e20941adfe812f43bc4ca05d9150496821047 \\, --hash=sha256:1981f1db4630889b9ef7803fadef12b056f428cb6b85c27ba57b774793b6093c \\, --hash=sha256:1ba34f04897fcdaa73f74145c25f3ec146fbd56593853e88adc2e811303c5f42 \\, --hash=sha256:241449bf940a5d27309bd317e6f9a2af6932113818bb2b8f5c59ddc7ef16da18 \\, --hash=sha256:25784ce8b9621c90c643efb9e1e2162ab3b0224cae446ad5e70e7fcb1ce18b51 \\, --hash=sha256:3dc4fd8058cea1644971207d530e1a03a184a805ffc8ebdddf0599d78a331b81 \\, --hash=sha256:4061c0079120205fb760c58acab6443e217307dcf05e3702cf970e0689972856 \\, --hash=sha256:4a20ce1e5cb4284a86692fdcba7cb8754185c6b2e5c56fcef3751cf451d3cdc2 \\, --hash=sha256:4e81d95e5bafc2d6e34e4bed780e53e4d5b9a2f928573428aa4d35fbec1eb0de \\, --hash=sha256:58a0c478eeca76fe5e07993c5a0703def34a6dc6a0cda4f5564639b33112ffe7 \\, --hash=sha256:58ddb5a8e3179d12f19e4ea34d2d32e9d63a4baa142c875c1eb59f41b7243acd \\, --hash=sha256:630ebfea3bf689d075f82316324ff7433dc447fe6bc1bfc76524b74b4a9567d2 \\, --hash=sha256:6f8700550aa1474a91e5dc07049c46f98b423b5b1ddd0483e0b51362eeeaf5be \\, --hash=sha256:78198641e5be9521beea5aa782bb551a58068d10e6eb04c9c680c1b69f2e7d45 \\, --hash=sha256:79def8d059362e7831389ed3be0ecdf58a89386e1271e35dd9f5af84e81bffd0 \\, --hash=sha256:7a8701d6b584d76e909e3d305b7d126b41439876a5aaf76cddc67fc230eafa2e \\, --hash=sha256:7afa5a6602a9f29af1f3a2965f831bae7c9d5d597b7cbb716d41ab3b7d89879c \\, --hash=sha256:7b46165bb56eb4704e2eaaf86f3c940d19154535d9b0ca7d6d590b04060e00d5 \\, --hash=sha256:7b75de3c8b3be1cdb1052747c929440c3eea46c1bc2cb8a6e3a48388e9b7b452 \\, --hash=sha256:7c6d0330c472d96f6a6afe24d80dfdf15176c33096f0a4397ae4c60f3dd3be48 \\, --hash=sha256:828d49b0ff5a0e3975865571c5d91dbbdd0d38d8289b249a163e9425413a5e05 \\, --hash=sha256:84f964e537f916e2cc85199e5a88742e964939b575ac8598b3f9d6cc416cdaf1 \\, --hash=sha256:85d0d9a31b9098e98534226d5686b47264b95e62ce459dc2e62fdfc809f9fe93 \\, --hash=sha256:87e9ce85beb6b328ba370cc6e6aea483c92617b4c95b1d33a49297eb662bfb04 \\, --hash=sha256:8c71ba2cd31fc93748c38e1b613200ff1c2665cbfd5341fe3a61cfde35a1430e \\, --hash=sha256:92e665960f25fcdc73725b9cec7a3824f279ba97a98653afe9ffac2e43668f67 \\, --hash=sha256:94e5e9f108ee10471288214d3d233fbfbb492840a8457eb85178d643ddeb32c7 \\, --hash=sha256:9c8402a82ea0dc4ceeab793db05f0fafa8ca139ca34fcde5df0f596103c74107 \\, --hash=sha256:9dab55f57c74c3cad24c323bacbbd04be4705ba6eb0d92e920b1fc4837ed5079 \\, --hash=sha256:a582ab2ae1d34f67112cadc86702774c9ea4374df6bca6afe672817203c99134 \\, --hash=sha256:a6557e5f38e065ca9fbdaf7cfc7435ecb1d113aa81a022d1b51921ee7432e227 \\, --hash=sha256:a9f7355e6fab51f6c369b86fb7571cffa05edee2c2121e0380a37fb9ac1cd5c1 \\, --hash=sha256:ab50ee449bf968271e820086f10a33d101dd060370abc10bcd22279be2656539 \\, --hash=sha256:ac9ed99d81760c62fe89d5f0815cdfa1ba9a35141cf30f1c2d044f04b4803d2e \\, --hash=sha256:b13478603dcd0a2479ff8e87e2c19a7d525734686fe3c49542472293a204212d \\, --hash=sha256:c423ab384a46c4dff7217b2ea5ba2e11cffdeab6441acd04cf65a369caf0366c \\, --hash=sha256:c5e67125c7dca78d199ec4e116aa93dbb83494808ecbb8211a2cb09b1bf41dbd \\, --hash=sha256:c71be1cbfa5cd9a41ee452acf1eccd82b2c05950358b106ec8ceb83411d1a020 \\, --hash=sha256:cbc8738fd8526d80f35cb3a40d41f41a2e7030bb3b18b09a6778ef63d291c2fd \\, --hash=sha256:ce47f66801c20ec6c6632453bb5960fe38939e9306970b48b3a5a26de7745d94 \\, --hash=sha256:d370b8d1dfcdf7130178137f6fbee6140774a1acc6cacefc4b42643ec11d0a3a \\, --hash=sha256:d38cdff612d06fa6a32840d5e1b1f7a27cee4a349aa9085d94a67789d6bfd408 \\, --hash=sha256:d8947001be83df1394050758ce0e745dd74fb134eef0a4b5124208dfc3a68c37 \\, --hash=sha256:deb9fde5c60e437ee4821bc9bc39ff31b42135c27e1dc61ef0a629389c1de62e \\, --hash=sha256:dfe9763530994147d9af1def057a5b9658b00e8f8fe8743d144d1e0911c2e454 \\, --hash=sha256:e105ab60406787da31fccc883fc0f733af1efd78f0136a4599692c4083a73d0c \\, --hash=sha256:e275096ea1e60cc595cda2836fd4a6c725d1125108b868be17f53684d164e2cc \\, --hash=sha256:edc3342adf8f697fc5f59c887a304356f147b397809440ed64e2fa6af2f50f37 \\, --hash=sha256:ee247f5c245c9a2fe7c8e2214e295918838e44e00a45a6718451e4004219e767 \\, --hash=sha256:eef4c2f3423810b3070ab391f85436d2f8bbfcb286ac15cbc73190b3563b1f1a \\, --hash=sha256:f21e8a22c8605750c7af886bab299a363721264061b4ac0a30efb73cfd58efc5 \\, --hash=sha256:f265528741e048bce55c3463ed721fb0aa45a5888d8add8cfeccb3035451bbdc \\, --hash=sha256:f2f9bd7f90c64fe89253f0a2c05e3c4856072660429ce8831b4235bf29403a67 \\, --hash=sha256:f785f6161f202ab04d8ca194158968798e480ca058943907972da5f12e2881e8 \\, --hash=sha256:f9f6143a8c75945eb960d9eb98905a441394abfa24afaae239d514ffb2586480 \\, --hash=sha256:fa8f5efb344d6908a1ce62f4a24e2e5780f825d6f53f5f50ec5ffacac72936cb \\, --hash=sha256:fdd28f912fccfec1846a94e2e1e8f9b0012f557f0c46fe4f3eb0d7a87afcf90b, # via dashscope,dashscope==1.25.23 \\, --hash=sha256:7cb2cc48fd82536202e3100e93730e92c952435bb8cbe16d45de9700e1546bcc, # via -r rl-lock-input.in,fastapi==0.163.1 \\, --hash=sha256:3d364b02a68b67292e833ff2dfed3b8dc3aeadf73e271c15316c6c166668792f \\, --hash=sha256:68f2d8050f5c3583121c0d203046cc7def5c16a7d6c43a0e7707a8ea610fe2d3, # via -r rl-lock-input.in,frozenlist==1.8.0 \\, --hash=sha256:0325024fe97f94c41c08872db482cf8ac4800d80e79222c6b0b7b162d5b13686 \\, --hash=sha256:032efa2674356903cd0261c4317a561a6850f3ac864a63fc1583147fb05a79b0 \\, --hash=sha256:03ae967b4e297f58f8c774c7eabcce57fe3c2434817d4385c50661845a058121 \\, --hash=sha256:06be8f67f39c8b1dc671f5d83aaefd3358ae5cdcf8314552c57e7ed3e6475bdd \\, --hash=sha256:073f8bf8becba60aa931eb3bc420b217bb7d5b8f4750e6f8b3be7f3da85d38b7 \\, --hash=sha256:07cdca25a91a4386d2e76ad992916a85038a9b97561bf7a3fd12d5d9ce31870c \\, --hash=sha256:09474e9831bc2b2199fad6da3c14c7b0fbdd377cce9d3d77131be28906cb7d84 \\, --hash=sha256:0c18a16eab41e82c295618a77502e17b195883241c563b00f0aa5106fc4eaa0d \\, --hash=sha256:0f96534f8bfebc1a394209427d0f8a63d343c9779cda6fc25e8e121b5fd8555b \\, --hash=sha256:102e6314ca4da683dca92e3b1355490fed5f313b768500084fbe6371fddfdb79 \\, --hash=sha256:11847b53d722050808926e785df837353bd4d75f1d494377e59b23594d834967 \\, --hash=sha256:119fb2a1bd47307e899c2fac7f28e85b9a543864df47aa7ec9d3c1b4545f096f \\, --hash=sha256:13d23a45c4cebade99340c4165bd90eeb4a56c6d8a9d8aa49568cac19a6d0dc4 \\, --hash=sha256:154e55ec0655291b5dd1b8731c637ecdb50975a2ae70c606d100750a540082f7 \\, --hash=sha256:168c0969a329b416119507ba30b9ea13688fafffac1b7822802537569a1cb0ef \\, --hash=sha256:17c883ab0ab67200b5f964d2b9ed6b00971917d5d8a92df149dc2c9779208ee9 \\, --hash=sha256:1a7607e17ad33361677adcd1443edf6f5da0ce5e5377b798fba20fae194825f3 \\, --hash=sha256:1a7fa382a4a223773ed64242dbe1c9c326ec09457e6b8428efb4118c685c3dfd \\, --hash=sha256:1aa77cb5697069af47472e39612976ed05343ff2e84a3dcf15437b232cbfd087 \\, --hash=sha256:1b9290cf81e95e93fdf90548ce9d3c1211cf574b8e3f4b3b7cb0537cf2227068 \\, --hash=sha256:20e63c9493d33ee48536600d1a5c95eefc870cd71e7ab037763d1fbb89cc51e7 \\, --hash=sha256:21900c48ae04d13d416f0e1e0c4d81f7931f73a9dfa0b7a8746fb2fe7dd970ed \\, --hash=sha256:229bf37d2e4acdaf808fd3f06e854a4a7a3661e871b10dc1f8f1896a3b05f18b \\, --hash=sha256:2552f44204b744fba866e573be4c1f9048d6a324dfe14475103fd51613eb1d1f \\, --hash=sha256:27c6e8077956cf73eadd514be8fb04d77fc946a7fe9f7fe167648b0b9085cc25 \\, --hash=sha256:28bd570e8e189d7f7b001966435f9dac6718324b5be2990ac496cf1ea9ddb7fe \\, --hash=sha256:294e487f9ec720bd8ffcebc99d575f7eff3568a08a253d1ee1a0378754b74143 \\, --hash=sha256:29548f9b5b5e3460ce7378144c3010363d8035cea44bc0bf02d57f5a685e084e \\, --hash=sha256:2c5dcbbc55383e5883246d11fd179782a9d07a986c40f49abe89ddf865913930 \\, --hash=sha256:2dc43a022e555de94c3b68a4ef0b11c4f747d12c024a520c7101709a2144fb37 \\, --hash=sha256:2f05983daecab868a31e1da44462873306d3cbfd76d1f0b5b69c473d21dbb128 \\, --hash=sha256:33139dc858c580ea50e7e60a1b0ea003efa1fd42e6ec7fdbad78fff65fad2fd2 \\, --hash=sha256:332db6b2563333c5671fecacd085141b5800cb866be16d5e3eb15a2086476675 \\, --hash=sha256:33f48f51a446114bc5d251fb2954ab0164d5be02ad3382abcbfe07e2531d650f \\, --hash=sha256:34187385b08f866104f0c0617404c8eb08165ab1272e884abc89c112e9c00746 \\, --hash=sha256:342c97bf697ac5480c0a7ec73cd700ecfa5a8a40ac923bd035484616efecc2df \\, --hash=sha256:3462dd9475af2025c31cc61be6652dfa25cbfb56cbbf52f4ccfe029f38decaf8 \\, --hash=sha256:39ecbc32f1390387d2aa4f5a995e465e9e2f79ba3adcac92d68e3e0afae6657c \\, --hash=sha256:3e0761f4d1a44f1d1a47996511752cf3dcec5bbdd9cc2b4fe595caf97754b7a0 \\, --hash=sha256:3ede829ed8d842f6cd48fc7081d7a41001a56f1f38603f9d49bf3020d59a31ad \\, --hash=sha256:3ef2d026f16a2b1866e1d86fc4e1291e1ed8a387b2c333809419a2f8b3a77b82 \\, --hash=sha256:405e8fe955c2280ce66428b3ca55e12b3c4e9c336fb2103a4937e891c69a4a29 \\, --hash=sha256:42145cd2748ca39f32801dad54aeea10039da6f86e303659db90db1c4b614c8c \\, --hash=sha256:4314debad13beb564b708b4a496020e5306c7333fa9a3ab90374169a20ffab30 \\, --hash=sha256:433403ae80709741ce34038da08511d4a77062aa924baf411ef73d1146e74faf \\, --hash=sha256:44389d135b3ff43ba8cc89ff7f51f5a0bb6b63d829c8300f79a2fe4fe61bcc62 \\, --hash=sha256:48e6d3f4ec5c7273dfe83ff27c91083c6c9065af655dc2684d2c200c94308bb5 \\, --hash=sha256:494a5952b1c597ba44e0e78113a7266e656b9794eec897b19ead706bd7074383 \\, --hash=sha256:4970ece02dbc8c3a92fcc5228e36a3e933a01a999f7094ff7c23fbd2beeaa67c \\, --hash=sha256:4e0c11f2cc6717e0a741f84a527c52616140741cd812a50422f83dc31749fb52 \\, --hash=sha256:50066c3997d0091c411a66e710f4e11752251e6d2d73d70d8d5d4c76442a199d \\, --hash=sha256:517279f58009d0b1f2e7c1b130b377a349405da3f7621ed6bfae50b10adf20c1 \\, --hash=sha256:54b2077180eb7f83dd52c40b2750d0a9f175e06a42e3213ce047219de902717a \\, --hash=sha256:5500ef82073f599ac84d888e3a8c1f77ac831183244bfd7f11eaa0289fb30714 \\, --hash=sha256:581ef5194c48035a7de2aefc72ac6539823bb71508189e5de01d60c9dcd5fa65 \\, --hash=sha256:59a6a5876ca59d1b63af8cd5e7ffffb024c3dc1e9cf9301b21a2e76286505c95 \\, --hash=sha256:5a3a935c3a4e89c733303a2d5a7c257ea44af3a56c8202df486b7f5de40f37e1 \\, --hash=sha256:5c1c8e78426e59b3f8005e9b19f6ff46e5845895adbde20ece9218319eca6506 \\, --hash=sha256:5d63a068f978fc69421fb0e6eb91a9603187527c86b7cd3f534a5b77a592b888 \\, --hash=sha256:667c3777ca571e5dbeb76f331562ff98b957431df140b54c85fd4d52eea8d8f6 \\, --hash=sha256:6da155091429aeba16851ecb10a9104a108bcd32f6c1642867eadaee401c1c41 \\, --hash=sha256:6dc4126390929823e2d2d9dc79ab4046ed74680360fc5f38b585c12c66cdf459 \\, --hash=sha256:7398c222d1d405e796970320036b1b563892b65809d9e5261487bb2c7f7b5c6a \\, --hash=sha256:74c51543498289c0c43656701be6b077f4b265868fa7f8a8859c197006efb608 \\, --hash=sha256:776f352e8329135506a1d6bf16ac3f87bc25b28e765949282dcc627af36123aa \\, --hash=sha256:778a11b15673f6f1df23d9586f83c4846c471a8af693a22e066508b77d201ec8 \\, --hash=sha256:78f7b9e5d6f2fdb88cdde9440dc147259b62b9d3b019924def9f6478be254ac1 \\, --hash=sha256:799345ab092bee59f01a915620b5d014698547afd011e691a208637312db9186 \\, --hash=sha256:7bf6cdf8e07c8151fba6fe85735441240ec7f619f935a5205953d58009aef8c6 \\, --hash=sha256:8009897cdef112072f93a0efdce29cd819e717fd2f649ee3016efd3cd885a7ed \\, --hash=sha256:80f85f0a7cc86e7a54c46d99c9e1318ff01f4687c172ede30fd52d19d1da1c8e \\, --hash=sha256:8585e3bb2cdea02fc88ffa245069c36555557ad3609e83be0ec71f54fd4abb52 \\, --hash=sha256:878be833caa6a3821caf85eb39c5ba92d28e85df26d57afb06b35b2efd937231 \\, --hash=sha256:8a76ea0f0b9dfa06f254ee06053d93a600865b3274358ca48a352ce4f0798450 \\, --hash=sha256:8b7b94a067d1c504ee0b16def57ad5738701e4ba10cec90529f13fa03c833496 \\, --hash=sha256:8d92f1a84bb12d9e56f818b3a746f3efba93c1b63c8387a73dde655e1e42282a \\, --hash=sha256:908bd3f6439f2fef9e85031b59fd4f1297af54415fb60e4254a95f75b3cab3f3 \\, --hash=sha256:92db2bf818d5cc8d9c1f1fc56b897662e24ea5adb36ad1f1d82875bd64e03c24 \\, --hash=sha256:940d4a017dbfed9daf46a3b086e1d2167e7012ee297fef9e1c545c4d022f5178 \\, --hash=sha256:957e7c38f250991e48a9a73e6423db1bb9dd14e722a10f6b8bb8e16a0f55f695 \\, --hash=sha256:96153e77a591c8adc2ee805756c61f59fef4cf4073a9275ee86fe8cba41241f7 \\, --hash=sha256:96f423a119f4777a4a056b66ce11527366a8bb92f54e541ade21f2374433f6d4 \\, --hash=sha256:97260ff46b207a82a7567b581ab4190bd4dfa09f4db8a8b49d1a958f6aa4940e \\, --hash=sha256:974b28cf63cc99dfb2188d8d222bc6843656188164848c4f679e63dae4b0708e \\, --hash=sha256:9ff15928d62a0b80bb875655c39bf517938c7d589554cbd2669be42d97c2cb61 \\, --hash=sha256:a6483e309ca809f1efd154b4d37dc6d9f61037d6c6a81c2dc7a15cb22c8c5dca \\, --hash=sha256:a88f062f072d1589b7b46e951698950e7da00442fc1cacbe17e19e025dc327ad \\, --hash=sha256:ac913f8403b36a2c8610bbfd25b8013488533e71e62b4b4adce9c86c8cea905b \\, --hash=sha256:adbeebaebae3526afc3c96fad434367cafbfd1b25d72369a9e5858453b1bb71a \\, --hash=sha256:b2a095d45c5d46e5e79ba1e5b9cb787f541a8dee0433836cea4b96a2c439dcd8 \\, --hash=sha256:b3210649ee28062ea6099cfda39e147fa1bc039583c8ee4481cb7811e2448c51 \\, --hash=sha256:b37f6d31b3dcea7deb5e9696e529a6aa4a898adc33db82da12e4c60a7c4d2011 \\, --hash=sha256:b4dec9482a65c54a5044486847b8a66bf10c9cb4926d42927ec4e8fd5db7fed8 \\, --hash=sha256:b4f3b365f31c6cd4af24545ca0a244a53688cad8834e32f56831c4923b50a103 \\, --hash=sha256:b6db2185db9be0a04fecf2f241c70b63b1a242e2805be291855078f2b404dd6b \\, --hash=sha256:b9be22a69a014bc47e78072d0ecae716f5eb56c15238acca0f43d6eb8e4a5bda \\, --hash=sha256:bac9c42ba2ac65ddc115d930c78d24ab8d4f465fd3fc473cdedfccadb9429806 \\, --hash=sha256:bf0a7e10b077bf5fb9380ad3ae8ce20ef919a6ad93b4552896419ac7e1d8e042 \\, --hash=sha256:c23c3ff005322a6e16f71bf8692fcf4d5a304aaafe1e262c98c6d4adc7be863e \\, --hash=sha256:c4c800524c9cd9bac5166cd6f55285957fcfc907db323e193f2afcd4d9abd69b \\, --hash=sha256:c7366fe1418a6133d5aa824ee53d406550110984de7637d65a178010f759c6ef \\, --hash=sha256:c8d1634419f39ea6f5c427ea2f90ca85126b54b50837f31497f3bf38266e853d \\, --hash=sha256:c9a63152fe95756b85f31186bddf42e4c02c6321207fd6601a1c89ebac4fe567 \\, --hash=sha256:cb89a7f2de3602cfed448095bab3f178399646ab7c61454315089787df07733a \\, --hash=sha256:cba69cb73723c3f329622e34bdbf5ce1f80c21c290ff04256cff1cd3c2036ed2 \\, --hash=sha256:cee686f1f4cadeb2136007ddedd0aaf928ab95216e7691c63e50a8ec066336d0 \\, --hash=sha256:cf253e0e1c3ceb4aaff6df637ce033ff6535fb8c70a764a8f46aafd3d6ab798e \\, --hash=sha256:d1eaff1d00c7751b7c6662e9c5ba6eb2c17a2306ba5e2a37f24ddf3cc953402b \\, --hash=sha256:d3bb933317c52d7ea5004a1c442eef86f426886fba134ef8cf4226ea6ee1821d \\, --hash=sha256:d4d3214a0f8394edfa3e303136d0575eece0745ff2b47bd2cb2e66dd92d4351a \\, --hash=sha256:d6a5df73acd3399d893dafc71663ad22534b5aa4f94e8a2fabfe856c3c1b6a52 \\, --hash=sha256:d8b7138e5cd0647e4523d6685b0eac5d4be9a184ae9634492f25c6eb38c12a47 \\, --hash=sha256:db1e72ede2d0d7ccb213f218df6a078a9c09a7de257c2fe8fcef16d5925230b1 \\, --hash=sha256:e25ac20a2ef37e91c1b39938b591457666a0fa835c7783c3a8f33ea42870db94 \\, --hash=sha256:e2de870d16a7a53901e41b64ffdf26f2fbb8917b3e6ebf398098d72c5b20bd7f \\, --hash=sha256:e4a3408834f65da56c83528fb52ce7911484f0d1eaf7b761fc66001db1646eff \\, --hash=sha256:eaa352d7047a31d87dafcacbabe89df0aa506abb5b1b85a2fb91bc3faa02d822 \\, --hash=sha256:eab8145831a0d56ec9c4139b6c3e594c7a83c2c8be25d5bcf2d86136a532287a \\, --hash=sha256:ec3cc8c5d4084591b4237c0a272cc4f50a5b03396a47d9caaf76f5d7b38a4f11 \\, --hash=sha256:edee74874ce20a373d62dc28b0b18b93f645633c2943fd90ee9d898550770581 \\, --hash=sha256:eefdba20de0d938cec6a89bd4d70f346a03108a19b9df4248d3cf0d88f1b0f51 \\, --hash=sha256:ef2b7b394f208233e471abc541cc6991f907ffd47dc72584acee3147899d6565 \\, --hash=sha256:f21f00a91358803399890ab167098c131ec2ddd5f8f5fd5fe9c9f2c6fcd91e40 \\, --hash=sha256:f4be2e3d8bc8aabd566f8d5b8ba7ecc09249d74ba3c9ed52e54dc23a293f0b92 \\, --hash=sha256:f57fb59d9f385710aa7060e89410aeb5058b99e62f4d16b08b91986b9a2140c2 \\, --hash=sha256:f6292f1de555ffcc675941d65fffffb0a5bcd992905015f85d0592201793e0e5 \\, --hash=sha256:f833670942247a14eafbb675458b4e61c82e002a148f49e68257b79296e865c4 \\, --hash=sha256:fa47e444b8ba08fffd1c18e8cdb9a75db1b6a27f17507522834ad13ed5922b93 \\, --hash=sha256:fb30f9626572a76dfe4293c7194a09fb1fe93ba94c7d4f720dfae3b646b45027 \\, --hash=sha256:fe3c58d2f5db5fbd18c2987cba06d51b0529f52bc3a6cdc33d3f4eab725104bd, # via, # aiohttp, # aiosignal,h11==0.16.0 \\, --hash=sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1 \\, --hash=sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86, # via uvicorn,idna==3.20 \\, --hash=sha256:a7db850025b95ded1eae8a46181a1a6c56c92c96f0e2b005d9ff8dc0210cab44 \\, --hash=sha256:ab7ae7122974553370f0bdb919e1a960b2cd1bc1ef0276416d896db81c14582c, # via, # anyio, # requests, # yarl,markdown-it-py==4.3.0 \\, --hash=sha256:7aa1511a46c39138de78d9eba92ce47e63124d8003fc98b3a351909e04239efa \\, --hash=sha256:91a58fa5b72c71a40cf7177250fd767480d7a2bb3ac426ccfb76fb90305fdaaa, # via rich,mdurl==0.1.2 \\, --hash=sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8 \\, --hash=sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba, # via markdown-it-py,multidict==7.2.1 \\, --hash=sha256:02009b402129a73e1f3da68f48eb999afbacd29f25aef0d5052b84ff5c2786a2 \\, --hash=sha256:02d9c04d395a36eeebe89e45f2269614a4675b8e83fddcba15bba2be903971e5 \\, --hash=sha256:03846be88267369908fcd9a91159358a3b142d740991c96e4f696d362fce516c \\, --hash=sha256:08ea94663d9e7c25d14d78222f7aee906c472d4837766bec62477c38f6e419dc \\, --hash=sha256:0c454b677214fa604e9c4a38952c685dc88a62c96f5576a7ce550f213d1dc318 \\, --hash=sha256:0c52fdd8cb8194fcb6969a417149aa1d09d6e48b69fb1b34ee1b1e4cb51ec183 \\, --hash=sha256:0c7b4d8cc9e6ae7070b8129bdb840215552d4e2689ca765d37eb208a24919209 \\, --hash=sha256:0d852d3d9638f852158d7de7200dd77f7ff8d77fc8f3d396032f3d847883f631 \\, --hash=sha256:0eb7fa012ab47b13e96bffc1369642f520adcc4e3d3e170d7f1a2b39fb953bce \\, --hash=sha256:0ec95a02f9f08246cc7f1d85ac425e4d5c233fd3f098f5be1b2cca16aa690186 \\, --hash=sha256:0f30d6eaf3cb309b6c21096c6c2b4cf3800f195a78b1babae85f481ce851bdc2 \\, --hash=sha256:12bbab225ce7f69df75409ab8005b11b4e9309fae863821e019e81b32e53a2a8 \\, --hash=sha256:13268013a3db11a214ccb6920f778d175b765f69a40509610b92e43602272718 \\, --hash=sha256:15da10cf11fd8d8716720c95b93180e94c8317405d89d08524c579ef360128ac \\, --hash=sha256:1d369ed297e79b417766327ece16bb7e89306c588df63c364a85d90d4aeac843 \\, --hash=sha256:1fb8c1a3480c130c3a6422d5f16f3cad6552bf08c2089dd288ba7134649183b5 \\, --hash=sha256:2022bd3194968a027f64ed16f9779e62e71a823a9df3971a7328c1d45dfeb9ab \\, --hash=sha256:21d86f2aa58aa428fb9909d6b8587b75eea827287e3515b8506dca86b55e2c7d \\, --hash=sha256:223427392fdf993e198644ec40c404fd93f1cd2a61328d18842ecbf154d02c82 \\, --hash=sha256:2529873a3bf68c372532a9f8058bcf4199e78387e92cd6a01b73334bfe6a7e3f \\, --hash=sha256:2592fb6c335d67f1912bf72788c02fd5dab305fc3c8c7eab078a5bec1aaa0f88 \\, --hash=sha256:25ebc4208d9098f77caeb16df895a0e56eb6c3b22870ac4e3ec43e0a9d6a33b6 \\, --hash=sha256:27166b6ec73eac37696d66b2c6efbd44b6d04b597d655070959df54dc7c71c0b \\, --hash=sha256:27cc258247b13008742f0e239933ad01dec5ed4e6dfc63849e30e04e1aa5bc82 \\, --hash=sha256:295a15ccb8cfde9351dd6062b80af4e839460636b3c46813b4aa443905ded86a \\, --hash=sha256:2b4d0c4e13d329ffee73d46128e32dd3b4aeb2f9c6ac9c8a89eb28d3b82dcea8 \\, --hash=sha256:2bac371da2c3554a99ba126f545e79ab8e8d9426a3e41df81d00ad725c1e2cbf \\, --hash=sha256:2c4e6a97f79699f33e6dc13bddb5631781ee79a4a94c1822116d100e7d5c136c \\, --hash=sha256:2d4cfbbb1023f0f6795b5395c400752fb23a5a09ba756aa9003886bbc47b3e12 \\, --hash=sha256:2e279ad5a6e9347bc9e043fdbee180a0480c8fd52618c3258e983dd93d98ed49 \\, --hash=sha256:2f3cf710144b1859f4128051cc27ea86eee83caac5648cf2ca0c1b835261cbbe \\, --hash=sha256:30572b61c7932e4d3c2ad1e580de7db1f35b7a35d36db38f89397ce3f2e69096 \\, --hash=sha256:335f715f8c111654f29e4bf19086bdf0245579d2b4f4f59ca8dd9b3003b859c1 \\, --hash=sha256:363e5db93fc3f65f3218a79fe108d217b9d264181a4e993c77552bfe275d0393 \\, --hash=sha256:36b868758fb11cfa748c788b793994e73660abec90f83c780a678539c2c468bf \\, --hash=sha256:37b161535e92776788957a165fcf38a80b33c1efde7b18cab287db4e4574df78 \\, --hash=sha256:3b7542fad2706595c1b1853b46f2c3c4ae5cc5a6252b7225f294d607a29e1bdf \\, --hash=sha256:3ca4e2e9102d0788b94894a30a5e3561fd4818a0605d8748d8fe780f890aa069 \\, --hash=sha256:3ca60708f0ca9d994f46790c5a5c774771e2f1dcb75b12c70a5582f915d0e721 \\, --hash=sha256:3d22ebb716ac79bf32c2a1d15250f017faef719114af4376e8dd814d6633cf0a \\, --hash=sha256:3d6fce7cc4ef63d9a7633cbae43e737798412805a4c3ba876cdf472dc6ff9c51 \\, --hash=sha256:4b338b45dc26ca4bac702e1278754f78613d4d0081e14e94e44fe8e261bf1750 \\, --hash=sha256:4bebc9587cc29359e3b045518a7a09264fa882a7d165b0d143fdac8eeb7ea948 \\, --hash=sha256:4d61be3725016ef5db3543c95f1f062d7d150ba776582d959a982af88e75fa55 \\, --hash=sha256:4eb2650aa240b62ab0c6d87238bee5d14aa4d411c0d69ad61be53e026e0785ba \\, --hash=sha256:4f31ddf9c00e0e7db848b0236c717acbe8a51954d0d31b4d908c538ab3f0f5bc \\, --hash=sha256:522f7d2351743804cdf5c5a304bc45f9d55e935dd87706fae2dbeafe0fed0b49 \\, --hash=sha256:5324411117bdb67cfaeb3d1d28fb783710fcca3d88b855696af99044d7219e4b \\, --hash=sha256:554ee1d2e71fb5b4059c0c4ee35d8cbc8af2a3147036d65a454c53fea07ff4eb \\, --hash=sha256:57ac987ec5d26d89bbc48c03e486f659e1367d425c465552ac2e4c4af8219def \\, --hash=sha256:57b5d0df4c60ab8b1159687610a1c3ae069ad2380d390a79dedff5c82318e714 \\, --hash=sha256:584ebfa26c9dcf3e465637a5a9afa2647bebb3022b50b1ff384834ba8e0380d1 \\, --hash=sha256:5a7df927c7999d1d3196176a8d4139d3a0e1765936f5de8c768097275b2d617a \\, --hash=sha256:5b944091cfa7da4f7a9bd2587569cd90c94b89ec4721f8e87fe62504f2432b67 \\, --hash=sha256:5deadf03fb4a7842696d551f9f9a06dd4445bb43ca06b5f9736e4e1885561333 \\, --hash=sha256:5efddcdbcb73f5485dca2b6624edc8ee063604b77bd3a3eb772826063965819f \\, --hash=sha256:65e4448dadc7c94a8643bb41361e45f3a73d46e36a008a9bc03e9b525f4d7c80 \\, --hash=sha256:66af55b07e4593790157e85f897f06983ded8a8692cb2fb048f3049c1d3fa172 \\, --hash=sha256:678ac791b5820d9346eb13c8515fe0c9383659335e5cfc544bf6f54714ca1939 \\, --hash=sha256:68b97b721d95b77d75e718d1b62a227fa4b3e647bd2a9fb39552d1a79ffb67c0 \\, --hash=sha256:6966806cf917cbbeb9a8b5c581db52e19c9af0ef5fe009db54c1f5799a6e003f \\, --hash=sha256:69befda4b1ef57027ea95dc6ed733568642f330fb3203a3e5c5ef107d41e0a1f \\, --hash=sha256:6e22756c6e2d4f57ead0d2e6be179d8a16d661bee424b81de0c6c0c1305ec39f \\, --hash=sha256:6efdeed2723431999cf3bcbc84c72dbe0f65d16bb1f84e15a657f5b60ff18ca6 \\, --hash=sha256:714fe5f3eabd153b1b6911d0b5d31cfc2b808ae6b9e59a32fab17a4e6cdad5a6 \\, --hash=sha256:7238f7135481926d52a94c18a8cca633a9e72c1cbfccd5796548298a479b0656 \\, --hash=sha256:74d3e015c28b43b6c1a108eec324ea2efb185c359c459216cabd4cb98f7f02f6 \\, --hash=sha256:76a4f5132b8dc29eb3c768ee9b47e132a1d24fbc2e9259854c01af9beaff1d49 \\, --hash=sha256:7726c53b1d59eb57b009a9e8759d4f71049ebdacf30642a198a197f80cea451c \\, --hash=sha256:781ca5dfc2f1d58e47f52216a0c1c7e1ba91ce8aa235459e20de2d402af77fb3 \\, --hash=sha256:785ef2f3e372dabc131f228a275f97eca92ad17cfab1ab138790e330d99abe3e \\, --hash=sha256:7cb1a6bb70edcc06ea65cb9a35654f268ee39d9fc3a52240e6ba074db4d9c99e \\, --hash=sha256:7fb3bc8d58e1b7c1d9fa1d995e30a4ce9dbe49f4c63c755a1ffdecdfbd026ccb \\, --hash=sha256:8148c2aaaf4b85d7872f024c8bb0c9b9797cc76b10588e3594a69cb01057472a \\, --hash=sha256:81a5f84a76401c4330e6db4e170dddd58860b30c4e8a44a181e5c2809c7f9c9d \\, --hash=sha256:81c6fc88ac9bf6920a0cdf22d3c383964167f12d35eb630463fc6d5ac89e460d \\, --hash=sha256:822a7fcd33f6922b650e1b26594f09d53c5d011fe655fea7ded27b2728ce2a1b \\, --hash=sha256:83fbd7cfaca614975efdbdcd9e2df45f3e987e819216468fb73e1db6f0365b98 \\, --hash=sha256:846b17193f1c373d6f05ada894fadf56bce2473067caea0aab51828849894b31 \\, --hash=sha256:8648dd5dc4d5db32b5936dc5e85e9a4d79db1135513d40d1f54ca15503750324 \\, --hash=sha256:873d35366cc115be02a1c858f9b22a1a9f6182b99aab2171ee5276af02a153e3 \\, --hash=sha256:8c3ff4f5c376df7126695a52af61e6084b69c9e52dcb9f4713e71ce9819e1bfd \\, --hash=sha256:90efd90a0f9b7ae3844a4fb3ae614321832d364ae19567b7cd312315fac4ec39 \\, --hash=sha256:9306e0c5595f91874e685be0a9eb743d48ba069c888eea051bec3c67c08b5b8d \\, --hash=sha256:987f65f6c9321402bc7012f6c6d09ba501b88ddb1640f5b0b4a19f2caafe24a5 \\, --hash=sha256:9a53776adc1ba923c9e345fdea7b61553c44c17a9af5eba8d8def8c5dcac4dec \\, --hash=sha256:9c44bd978adddf39df5834c6a1efd7d075c84769a7a084168d035a2a276d9008 \\, --hash=sha256:9c9f285f788acf2448a57c9b93d31103ac69bd03f92907e2ffbb23c4e2b42eb6 \\, --hash=sha256:9df532dd12c59a7a4d381646fc1bf5ccb4bcdbd01c0887d07ec769fae965ea9a \\, --hash=sha256:a0f999155c22c8929cc492949c08c6fe7ec8079a5e1bfdeb34b9a3e4991959d0 \\, --hash=sha256:a2a322c8a6ca82a5a67ae6542e9c6a13ded9045cfd171dcccc5c213ac4fe0eab \\, --hash=sha256:a3d28ac22fe658ad7486d1532b3a9084fbf65b428db31f47212c5b0b6da826f1 \\, --hash=sha256:a3d9a59bcdf8531d46b56bcd512017533510c25e955c2c546efd0743bd840940 \\, --hash=sha256:a789e3d27fc5665cc0477f10a35a89383313e4c9cf8b5e6af7ea71f039cdcc0e \\, --hash=sha256:a7d120bdde5b213e67ed7dc80ea3adf4f014453fbc20195d619ba2ceb34084f3 \\, --hash=sha256:a878fef2797a7c082aa47559af68299372edebc7367bd5128dff2d36e6d820e1 \\, --hash=sha256:a92e3080d8889b0f7a80ea0c4a72181b4d4d5d3918a03136b4a459f51f5f59da \\, --hash=sha256:a9cc121b5ee2c8b4bd4b6b526d5a26bb782f4d620463f73707691b2004b8c349 \\, --hash=sha256:b4821bd30b38144d8ab75df56af0b07e9d71327c9cf94c0c7a1965f865bb9615 \\, --hash=sha256:b5fb6b048931ea925b484f0c7c01b007981415a00a6c62ee74bbf8d229d39c08 \\, --hash=sha256:b63acdf4df5a78a15223bbb510bb3e0f8234dfa807610ccb8796d0842db2c801 \\, --hash=sha256:b81ff0f2d375988152614eaea4d5023c98ecb08f77df4bb1d96762504bb86fca \\, --hash=sha256:b97bffa5772b7e853303de094829fcd3a9bd49fddd70534651ee4933691f6587 \\, --hash=sha256:ba5e8d9310a794b853fb0e327d46a827b5b015576341219a591f88ed9d799c27 \\, --hash=sha256:bc9decb36abd00ed5d123db9df70eb9a0da45d6376d86d64f4a94bfd5a1b83fe \\, --hash=sha256:c10ac5e3e76837180656079008f71add8339b00c3c26314092bcd1e8e449049f \\, --hash=sha256:c753b820738cddc097892fee95e7cd716fbdfc9640414c5e9ce9463ad125321b \\, --hash=sha256:c85a0a54a19429a17ef449e967baffe7b5089cb4f6ef2894c9168a69fa024d05 \\, --hash=sha256:cadd02ca804d6ebe799a7af19197d9730094fe2cc74b70eb4f374f4b8c1886c1 \\, --hash=sha256:cb43bb34346155d479acdc5423afccdff79ce1fc66adfcc9de995cbec8a13acf \\, --hash=sha256:cb7fc8820b206932ec6d8f8985aeba6edfd2932e13b6c4bf2434d6bcbbeef3e1 \\, --hash=sha256:cba29f12cd717f1cbbe220edf005666f8df0453347217748331a0c2f7522eca4 \\, --hash=sha256:cd69c99affd1b4debc1f9a53058ea6e3a9b34f2e733840bb45891666cd8ede0a \\, --hash=sha256:ce0f884408938fbd72e764031d0e23a8f5e438a7bf73641089c7a6465cb84456 \\, --hash=sha256:cecb2c778f00a65c6ca01410dd194d0e797a9eebb7c6dea0db87718719f293c7 \\, --hash=sha256:cff7657e79224dea46f2f2e58eb99186656ca63ebe356212210c5c00e9beb814 \\, --hash=sha256:d0381074dc21225951278d7e4a7a2241f7fb86a4d8b94154dfee1411f49cf851 \\, --hash=sha256:d094951489bb7836342c005e790bd005e60b669aaf5c936b96dd5d68cbd2e23b \\, --hash=sha256:d10e49b940e70e2a4e91f44098007dda0bacb78c3f8e31ba7a37ee2ce52269e6 \\, --hash=sha256:d37773029ba034a2cc970b6eeb67dad3bff9d894393c51f6bb1c6b4f563a032c \\, --hash=sha256:d4af0d863e72f3ea48e85d3aa1d1b426fd81e9544fd7976fc6d6753584a25b03 \\, --hash=sha256:d5738cd929f2af8651ebb284467acb58b1ec0f2f4d42489cd0597172bc82e15b \\, --hash=sha256:d615377a8e7bfc4f1983ede3f411c2ac2b0f7c3053f262d0437b7d8bcc4485e3 \\, --hash=sha256:dbda2baafe08f8431fd3333be02c261023fd454607e3bde5e7dc00565f7bebcb \\, --hash=sha256:dc6f3dcb08c4b41e64f2d6cf272b5686d9144db585b2e138a8b1664376ab3921 \\, --hash=sha256:e0f2b33a6ae233f4da38c77ea32f90aab2cb82ba819d7b6c4f1b68cd33d871b6 \\, --hash=sha256:e47d058c2db95010f5d2e1f6037acebdfb0e2fa4507650e1041437985c91db38 \\, --hash=sha256:e64b86d16158954825d12799271979c6944c1fd1d03575b2f22e869c3f7d00dc \\, --hash=sha256:e8af3e6f1bdbc31fd762b094133b478b89988eaebc63cbe82b1d9e3bbd15cede \\, --hash=sha256:eb5c4a5b1281985271b6c29be53f2c1a9decf11e30a0e2733439c4d9d61b9ebb \\, --hash=sha256:ec4ee5d2d624088775e61cada87bbe7629bfd936bfbd57f122a106970d8ab1ee \\, --hash=sha256:ed6c107642a9acaa7ede32dcd428a6c87e302c5d555ecd3ec132ffa8c6155b4b \\, --hash=sha256:edffdb3950d3a8b769ddaec3a0962fb7b76b3c96f317f6b88500455a537dded2 \\, --hash=sha256:efe695cc2081633b02fcb95bc1b13070f6647c9ad52d42a8beeb3c2a7ea062dc \\, --hash=sha256:f07f06db2e333b68dd52560b8b0b12b6f8bf6053cedebf9af4aecfecd2dc1b32 \\, --hash=sha256:f15205c67d4c45250fcff5da077f0ae54102b5bc39e9ee8bab90d99e09a728c5 \\, --hash=sha256:f2087ee23a18d1d618a135eedcafba7dfc40c6be4e8e52d7f29a1c8a2344cfcc \\, --hash=sha256:f278f118f9fdb5faba5a6792be397fbda094d1568efa4dfe8c3595ce4ce89eea \\, --hash=sha256:f29885fef157a602d1816439e5da964c70ebcdbbcd4bb9d2d21b7e8bb5636604 \\, --hash=sha256:f2cc27ec6a53b1d39bab44d2b9dd21cc31e796d01b5e18a76d569721282bb264 \\, --hash=sha256:f332b16911ffc668baec6aaf8f08a09e1af34a8ee87ccac26bd722589e264645 \\, --hash=sha256:f5812cfcf7daf3ace5fedf6e2ef8d4b342c92fb8ea3a87c1aed2b50453271093 \\, --hash=sha256:f62172cf387e92f4928b60e5936b02c06e3c8449ed7fb440978d6c9bcbfc85df \\, --hash=sha256:f9c118e866164ce05498d9106a4bd01e745321403cd6f0b77a0b2587768f8c06 \\, --hash=sha256:f9e78d98a29e969a001e953eb09167a48bbc71249e804dae5db987ee7e6531c9 \\, --hash=sha256:fa0ecd064b0ae18d235283abb5adbc4e07304dba8f2aa7c0d61f28bebcc70d4c \\, --hash=sha256:fa949c81e3865c10f981dea72fd8d418b59edd13a047a0aee89ae64790113d53 \\, --hash=sha256:fba33e264cdd2ec43b762b9960d1648478eecfc1ce6e8159e7573510f0412c0a \\, --hash=sha256:fc45ff19520bc5321dcd9c6dd7df6f35ddd894eed35e5be65d1828a9c3f5e7fb \\, --hash=sha256:fcfebcb537f419e415b6e2bfc77ddbd33abe3c036f0105410a25a14741df9c31 \\, --hash=sha256:fd24c4425fdb8e822601335602375c6d0cb020f7a368e1d5842eb7925a9c8748, # via, # aiohttp, # yarl,opentelemetry-api==1.45.2 \\, --hash=sha256:2cbd737377e710ee740d261c94e93fa0f08e6d037c18f17513cc0a2d94479a34 \\, --hash=sha256:d7b0008e21e5fd61cbe7a7f34ca3b6905a78ab677d9bc395e299359c75cda6b4, # via, # -r rl-lock-input.in, # fastapi, # opentelemetry-sdk, # opentelemetry-semantic-conventions,opentelemetry-sdk==1.45.2 \\, --hash=sha256:7eec4de13dd21ff3a1670dcb0e02079e692736f94d733dfdce5af461d884248d \\, --hash=sha256:ff974ea70ee4f1d51e2ec152db37c2b626c7bf82bb3f7d86114fd8704e7199c6, # via -r rl-lock-input.in,opentelemetry-semantic-conventions==0.66b2 \\, --hash=sha256:4cbe61e5f9275d57ab31708446e7938ef4291ebbe6a7fca6f7a629c5acae87d8 \\, --hash=sha256:7da5f1a5dc4383eb66711d4d3d3e71824d9403ac1559fea021cc103c1a4c4976, # via, # -r rl-lock-input.in, # opentelemetry-sdk,propcache==0.5.4 \\, --hash=sha256:004e685b315646c410771836e72a44f143bbe624f29653a42687815069a303d5 \\, --hash=sha256:02c0a34f16889cf800f10f0247a564d8ce6eeab6ffcd7c87198f769067eb8432 \\, --hash=sha256:03969626faf0783a592dfa17e28eac06018bd0b44dafae6943d53b92421a7f72 \\, --hash=sha256:03b229037d25b801e7af53fd52b9fc49d9439b036fca1e087e02780631adfa97 \\, --hash=sha256:0951315a6b3142ee2167404d707743f0157c110091342b1aa0accac5cf0e4acf \\, --hash=sha256:0a095db8e15a6020db149ecbed6461939fe74f6acaa3ae8b702a1fe8c38cd983 \\, --hash=sha256:0c889f6fa84957bc7e8b4eab71fd16a0455068d5045e3aa40c733071d2b2fd77 \\, --hash=sha256:0d21d0d2c82bbfeb1677a9711f38df968f9837576102bb4add1bd449d28d88f1 \\, --hash=sha256:10ef33a68a61ce317e095fd2e202a592ea92392b90944a78c993f0d9a73ab06c \\, --hash=sha256:12682126712ddc19b70ff819debbd279e58adf1f0c8f8f8138c18ade2044b284 \\, --hash=sha256:135036c5cfc93864affb0f9af9a27e5d7a71cb7bd745e7b6dbfc2d56cc30e827 \\, --hash=sha256:13e52b6e0bde97dee98ab66552dbff2931649c96f1ac432eac299fe689ec373b \\, --hash=sha256:141fdbd73748db0cf7636035030aaac383d2efde8f34e7bc24594cc776d225b8 \\, --hash=sha256:146f48a9e4812611a7581003b1a39de56c34967046310c4171a68ef908c9a745 \\, --hash=sha256:174507f82d3594622acb1dd2dafecf2d899d6d506335494e7107767bf05f3aae \\, --hash=sha256:1783582065a1f07f9d9ee1e992e13f15d7dc8fb1eb3a7476d43eb3f2e69d26bb \\, --hash=sha256:17a7400cec0256f0a71ae71f9da398f9894c956ff6668a1c9d317b3367316320 \\, --hash=sha256:1b2f3bec4261a94019575481c726c29850f72e27907773c75b1de421e20e9f9d \\, --hash=sha256:1d759d05634f1b038fb625a66662a8c85e5a8fec912da381b5149ddac107482b \\, --hash=sha256:1df8d8561b21465c5dd56110a01caf897e026d065b4b84e98a488209094272ec \\, --hash=sha256:213bb68d9ced5cf2bf717b1071bf2b09b4b04c426256f9fe6d054c60318424c4 \\, --hash=sha256:23278f808cd81d5ada7184a76606b925fb3389c60e1077b2cd7da7b1fcf0553c \\, --hash=sha256:251c63dd46a0659bb875cb254dc4c1e79ee91a847c737cd62373295afc2235dc \\, --hash=sha256:279655a16973f1ee2bd2fe79973137681642fd9ae0d89215bba263726eb0dc3a \\, --hash=sha256:2814ecd8e818f487bee4b0f921bc4d1c176cc5fc71ac0f072d0fa67eda4ac14b \\, --hash=sha256:286867fb156488c251a3721766e380ac4495e4fd6b51aaa1403d89ce7f4359d9 \\, --hash=sha256:2dba2f02d2d5c09ef8a0e6c1a42aeaa451f4be9898cb00b04fe98717da2eb23b \\, --hash=sha256:30cc1cebaf9aef49db06357a50398323ae04d70460c0491837d026ab7d6452ea \\, --hash=sha256:31eb43ba2edc704ab2ec27815315dd8a19def0fb16215be4cfe8d32fe78ffd51 \\, --hash=sha256:350b272b2279f4135a64fc0c304a5d08e28a137c9573442c606152446638a831 \\, --hash=sha256:36c0d9db44b523ef93d03341b1c42d69ff01d673c053d1b1c6c3a363bcaa39ba \\, --hash=sha256:3af0c8642b2da4815d86e631232ac8286e17644fad907c19508aa8e7cb4ba8ad \\, --hash=sha256:3cd3a7edb6b95b9b33998135ebfa18d709da82290fb8f27c858970b5a12c8b56 \\, --hash=sha256:3d605bb239b796e82a81c6709548b2bd460ab73b4590cb0c83de8a2dd9694d0f \\, --hash=sha256:3e413d7a4a9b4866b7a761d6060d434b64d23cd35122eda3b026a0bbe8196b25 \\, --hash=sha256:3eb2e820e8e2101407da93f17c57cbb7d225461955fc60105daaba14cd421ee2 \\, --hash=sha256:3fa15757fea1dfcd5b7745cad9f4638929605531bd4018ab2adff7955f1a403d \\, --hash=sha256:3fc24f209c1b7f7f688b66b98293954f5504279760999b58920ee12dd8471c1d \\, --hash=sha256:4054acf80d40456a0537f2913b349718649d8d6458a14ab7f48d0ce28c30869d \\, --hash=sha256:40e94adb1e7d39ff28a8bd8d8b8fbd1df6b9f40976dbe379134f1ce058e532dd \\, --hash=sha256:420162a77f94eb1cf5ef7893f500016dabd548e73de956785a1dd899cc73006a \\, --hash=sha256:425f8cc86ab5018b4b8d4a23bc8e74d964bd3d757c3702e301aa79be76c53f6c \\, --hash=sha256:44149f46500a0a41b95b4d99c2e586a77319539730607b9892974a092788b111 \\, --hash=sha256:445ee3bfb46e85838387fb3c536a73cc0b994dc192b004e40e170adc54aa2a7e \\, --hash=sha256:45488d1a5f9ab5bd90aaa1ca20f50fe1922b8ffad71a2009d2adf41355897aac \\, --hash=sha256:45bebbe252550fec975ba3b62bc6f931643cfd3b5464ef47619cf3fef154e01c \\, --hash=sha256:45bf2e730ab8905d0527fe05a86500f406e64305c34cc81ebe64b4617cab9760 \\, --hash=sha256:48cb48c5346a97de792254af77715aa2529c2a1ebc5f586aa0aae44a02f1fe57 \\, --hash=sha256:4a1f4f5ffa55dce6307631f3cb2948e117e665966ea512e0d502b16c24f567e7 \\, --hash=sha256:4cfe0a92ae30151869e67a4b5f5e105e4e03ad30b3f38e5211b5bf77d0881993 \\, --hash=sha256:4d86476a935c88963d9b8e1a9a0d38188790e9622169bfbafa173046846709d3 \\, --hash=sha256:4e985382be6d15da8d0c2710a6fa7b9070fc9ecdeefb7f580e88373984ec8be3 \\, --hash=sha256:4f2d880ff60f45898f4acfa152aac8d04e3ee627d90ff4003491bf92239d5757 \\, --hash=sha256:4fbc1a15dc8cd1689508758d626b372b1f09d28d9577667feaf9e6bfcd8efcbc \\, --hash=sha256:50e337653721d20ead710da33bf44487fbe8a0db8782714b60306481e9f95b51 \\, --hash=sha256:53eaa697c4d0422ff4cb714d00231b43352064d97b944033b30c1d57cc506ec0 \\, --hash=sha256:56fc3f7599528db40b1efa0889a620116e2704144495273d66066e8164e45838 \\, --hash=sha256:58134228927cee6c047d626c08e60a81be604a20578a12ce752cc5c9a84d4826 \\, --hash=sha256:594eb4c6ec35e7179b058481f4e9f02521b56de16fa577c4b85c76fb1bf8a9f8 \\, --hash=sha256:5cacf3c9efd09df409dc33654dd077e1c245ba8fb747b0f0236ef41b7c49b589 \\, --hash=sha256:60a64cbccaa11b7760ce705a14ada17ba459e7ca9f23ba587eb013821032d7ef \\, --hash=sha256:62530ca89187827e4a4fe733f971abe81a7542eeea48ff61995f19b64d7199c8 \\, --hash=sha256:62c60aec739ed00124573cce1178138fd690c7676352d67a37328c1cf51d7468 \\, --hash=sha256:69fc35c0779522da366c563e5faf203ffc1f8ff0021d5b1337fa4efa5be73177 \\, --hash=sha256:6af4693716bfb03f1752ef1b30faa593db2c01d5272e9b8564a1549452a979ab \\, --hash=sha256:6c7599df2b57ebeea8de011b5f2f7b85de95e76037d43d34b95e328430275487 \\, --hash=sha256:6e9368e87a3efc285e559131092c5db643eb8e56de4ee42064d5baec22ef2bb5 \\, --hash=sha256:6f0093ac3e9daada202c2082439d414a625c57184727a46e112a3fb2a81cb788 \\, --hash=sha256:7177c43eddf10a0893c4fec52ebb408fdcd7f7d63962caace9180d8f81b14ece \\, --hash=sha256:720cf832eb2d0b0dfee129cb3335a26f6ce3cc45ee1187e8f0731758caa16792 \\, --hash=sha256:770e8209d018175fc0063936fa9583b6d27e88c5ad31543f3383d66080efdd62 \\, --hash=sha256:7a8d5ff04eb1f85698a78d20c62a14676e7b960dcafde09a388d60ad377d355d \\, --hash=sha256:7b9100a93b372418d8688f3f2a3e5b45c64d70ca4d6176e121aca1e3bfc1e32f \\, --hash=sha256:7cc528e760a8af06f2b13e9b9f362cd90c7c718ea61228a96dbd31ba16ed7f47 \\, --hash=sha256:7ffafcbfc7b549ab940047e505c831eabac5e67de53e1bc174adbc5285c55944 \\, --hash=sha256:87a3caecf8095e48dc72f84bfa42e23a848cf410cc9cc13031fba4869b706a21 \\, --hash=sha256:886b59c4d28ca97dd23b025fdfc50a0356be934efbbbca89ad26230067f86fe5 \\, --hash=sha256:8876b39961e33d912afe3c1bee18ee564fdad0206f873cc15d522756b7f50737 \\, --hash=sha256:897d1ddf6716e8f47200f7aad9a0efa6cc7586df66c6defa572f9eab379c078e \\, --hash=sha256:8a1fc236528c457cd739c88abe823da851b7ab645d72792f88658114cc340c12 \\, --hash=sha256:8a235f73d6e020855dc29dff012d920c02ee0feab8d73a24185a7569f4be1161 \\, --hash=sha256:8f911c395cef73c510bac566da9507bb6a43e7763d0c79138dc60ee53f11207e \\, --hash=sha256:96f7c5c15656040ddcbc51e56dc59b58aa25999d743c126abd425b9766ab43e9 \\, --hash=sha256:978f28401afbc76cdc3df9e1717b4229a06b626a1dcc75db4e1f2beb3884c3e9 \\, --hash=sha256:98914de2c4d7f0f9f4a8c6ea4bf05841f4175796941e3ef7d47eb718f22311fb \\, --hash=sha256:9a2a8a50a93dee0268a860a07fa3b4bd968f8ce4dbd794957da772f395368526 \\, --hash=sha256:9cbfff4423eef4cc6cafc021469641a2b835f610b2647a6c5281903e21b8670d \\, --hash=sha256:9e9ab13760aa8b6d0881ae7cb04fd891d8d490cd2554ea8e79bb278399169bcc \\, --hash=sha256:9f3551b8a35c1df3e7ea4d2d86edee15f0dde1bddd434a71744048683544d0ef \\, --hash=sha256:9f86f7259efe2c951f43e57d471c9b41daa5bfc7db9f67189059cf1ae6d77fd9 \\, --hash=sha256:9fb0a5be8d9aa213150e8d8148a42aca4984b285bcad1e69587dc4298edd929b \\, --hash=sha256:a219f0ac59817a9114dd2aa57c13180f993e819ba658c7ddab4b66ed1ee0d370 \\, --hash=sha256:a419ee85e654927baabda3929c03c0cc1112bf472ff0dfd6142f4e3a81ca4162 \\, --hash=sha256:a4d7a54719b67338a305dca2ce6aafe366817df94ddfd4b5514374356f5ca546 \\, --hash=sha256:a5793c7698a53f56f4a1889a4737c7eeb1b7ad0842fa6b1abca22913ff79c8c1 \\, --hash=sha256:a5e8ef588c109725dc713ba69aadcac00a1ef90c2ce9c0a8c7075128f569f47f \\, --hash=sha256:a74bfa37147cc08fb29df10bd9c16f40fa7f860cd3a6d2fff853323a94f6e17f \\, --hash=sha256:ada748108a43d29b7c328ba7db3755327cd94f028bcc1a7ee3f0addcfacd9c38 \\, --hash=sha256:ae58f361bd5dae942717c65d3413b478c70aea9c462599e7b9adad3731db3894 \\, --hash=sha256:b28f41fa3b8c6900457f858ec5b03998f3a6d535fbc1bb2edec5961ea05ec429 \\, --hash=sha256:b3083bfe87f95c756e610bd8025f26cbd1cd4aaa03a422f2d65efb7a97cd53d8 \\, --hash=sha256:b61805357d966680acf68b3b6d49772631ed9df44ebece10ff1460e117a7da8a \\, --hash=sha256:b77c313314524ca9c38fbd70f73515d04597ac58c40c939bc0e71eeb4abff680 \\, --hash=sha256:bee7d3aed13d56f54e681df38c3a23031bc9e3863f687d9d598825c9146acd7d \\, --hash=sha256:c02c0e570c5c7e077b0181a9f3cdb7d4c3617d1cda6b5c95bd5d34022923d82c \\, --hash=sha256:c174bfd1c48a1b51a3078e95586dde718374bac79719ab3541ec9e74aec40574 \\, --hash=sha256:c2ba30a89035b57b73e00475de948521602f543d79ce01db10b04b36c4c76fc8 \\, --hash=sha256:c3e98c55bde2bcf7db3c70d1aed7ae9aa8aebbf19a250c66645cde44cdb8b867 \\, --hash=sha256:c3ef2818d63bc86071e9d2989ae75a1bc32b8f7059cfd9f5abbbee70c32e2ed6 \\, --hash=sha256:c83acbce9f2b5e3f5f5eda9e53d2001fed22fcdfef81274a9e02d8fd53b70a30 \\, --hash=sha256:c9281e922c072158c91974d4589f1dbe0fee6d467f284c28e463f9f5a4d933f4 \\, --hash=sha256:cc07876cfb079b6f6f36d21ce75784ad6c2c6b563eeac0ed26c2fa2669b85df9 \\, --hash=sha256:ccf4f7a79e26bb7efb06ecd50c177833b71df05cbc748701372325e6bcc17f6f \\, --hash=sha256:cdee8205a44d0be91bbac4c41b95d86641b72dfc7aef1279400e4fda3f26a937 \\, --hash=sha256:ceb3e879afac028f93d272c957814695dc5569e4904262dbee92f6c41bd5e4a3 \\, --hash=sha256:d1f5a500bfcbb2c0ab85e98a0dcd70f5899d34efe365a0187700369a79603031 \\, --hash=sha256:d42a9a856a4a6e2f6c10f1318c07e7daa498d6593abe745c71dae4521a26ca39 \\, --hash=sha256:d83b12902eb8bce151259c86c03ba746600b2d994543de46e370cecf96c452f2 \\, --hash=sha256:d8e017eeb7482bed34cdb0d61cf2bcfc88d104bbab296a17cd16a6af8aabc70e \\, --hash=sha256:db3ae52ccc150dbc84704e9d642743897f3e1c54742ff34cacb661e52e3818a9 \\, --hash=sha256:dbab5f5ff6897c81f355d079010cdae85b02e5a0b518b5251523b8ad8ae9ac3c \\, --hash=sha256:dc4242ca653c9b30ab51c5f8193323e7bc0928f897ee9103201e59a43abcb72e \\, --hash=sha256:dcbf346a318a5e30063f547630b02bb787ce2f45b6368d5da143660b6a3835d8 \\, --hash=sha256:dd2ac8f5b643454c2cc6b6118b13da16e88f4a6434fc3ba61aca384029f04f36 \\, --hash=sha256:e1d52a05dc417279f7e5c7618c5dfbbc29923aaf9bc0a5c1802ddcebf54c61a0 \\, --hash=sha256:e6720ba44ad7e72174314d0e1fb0172494cff5c73a3a8a2159c3d2402ff15565 \\, --hash=sha256:e738ab81179510ce79b2eac9a6ecf47feffd9e76d1c72e403005dddb6e36c06c \\, --hash=sha256:e904d4d01f36bd6e197590be1533c44e06058771e0746dd073a8ebb3ef880858 \\, --hash=sha256:e9f165403b81fea7e89c932d89046a1e3d9a3a60e8d7ef2f249dccdcb0982bf5 \\, --hash=sha256:ec6a85f424afa8d23e0d9a094e5dbb6eda01da91c92b9183cd433768247ffc97 \\, --hash=sha256:ee19113bce2f3acd46432050688b70f61acd6857d75abb9ec96341b7e9ced123 \\, --hash=sha256:ef3b928d9c984322b5c44e6964d8dbc653da87d2d8ee1647fa6da43072e650a9 \\, --hash=sha256:f273dcf7149a50527c4fd1f55cfe9eac0f60753f5af544b4c9352578e20c0874 \\, --hash=sha256:f5470694918830da62fac9e69133b53d23b736d7070e587b27a4a2be37e08e68 \\, --hash=sha256:f574e460d1c8a08384a016fdb09ccf3543433263ed6b2f97104f979e64ea57c2 \\, --hash=sha256:f85915e00dcb1cd9f2f890ead064ed40a27df06f0db65be427b29482ae357572 \\, --hash=sha256:fc2461ecc45f17893f8207e73b46ea8ba93e33630e51cf4af3fbc21d47462b1a \\, --hash=sha256:ff6b113f50bc066a698db5d944d2c6dc7507168dd3341e255a8892fd0715a558, # via, # aiohttp, # yarl,pycparser==3.12 ; implementation_name != 'PyPy' and platform_python_implementation != 'PyPy' \\, --hash=sha256:a076f3f489b39b43ed13563a1dafe42447445bec2e294154ec5c57fcdda4c85e \\, --hash=sha256:f03387877eab82ce01bbdfd0ba7252ee55a90b1c708d5129e2ce915475cf1db6, # via cffi,pydantic==2.14.3 \\, --hash=sha256:1054f237f4d4733e5a30e1e2333bd33a2004ab9ab1510bd053a9a31bb48e232d \\, --hash=sha256:3f7b347782ab7e4cf4c798496ae3a82787d9f21ec12676a9c564355eeef8daa8, # via, # fastapi, # typer,pydantic-core==2.50.4 \\, --hash=sha256:0001d6920e3a5d92758cda460d6dc9f918a78ad6d5d092f1c8b5395e6b775356 \\, --hash=sha256:0574866e05f6adeecc520d87e87dd06210c0a51706341f6ef8421572f5a64444 \\, --hash=sha256:09450778e3ab58d3f565899fcfbf6c82926e31af29e28e799d1d50941316e0cb \\, --hash=sha256:0af56dbf8822ba9f4efcbbfdc15478f8b6fb08f1609860cb50aa2cc8476b3c34 \\, --hash=sha256:0b059a7968b1911be5a2d9a8234827ab0bef9d1e465d4b42da525894143550e8 \\, --hash=sha256:0ec20aca2b067369913716847f7dfe5f4dddf16a46965b7a70bbad5defaaba86 \\, --hash=sha256:0f87ae9db5ba8d8de40dcb93982cf8dd544e6552a80d3345af51941cc2146b80 \\, --hash=sha256:1239daaf063e62213ca1f34d96663900bd7510c42a786e843fd328af70e46445 \\, --hash=sha256:13b6dd62b5279f5b9d72f3bf918a35443ee8bd549241d9dc52d79a2c3b6d7016 \\, --hash=sha256:15bece43a02ad543c621c8305e67dedb5f27d378c5ba741e5a2c36523f8ef37f \\, --hash=sha256:16902a147b3da4840612164a5e67947104d63e978f7a57c395877a5e26690b9c \\, --hash=sha256:1afefe44ec042fbabfb4483ea258c04cf75ff4ff328d754f09b321fdaa232aca \\, --hash=sha256:1de7be9a66fc8536770481ab64a05aae5067c725f2b29a09543af00e6a417b97 \\, --hash=sha256:1e20cbde2b6deb33a51d08cd168454dd9044ec7d4474056f4d98d63f51578783 \\, --hash=sha256:2039e323acee9abfec1fb5f661776e8965fe5928f3b7f8431900a774cba5c317 \\, --hash=sha256:219114f8dcdcbe4720d82ef016b1287ce5a0a67d7c69ca61524eb72e82aac344 \\, --hash=sha256:22e874666bdbd96d6bf629d32cd8ab376fedf1fd62585b52a42b9fa9fa6c20b6 \\, --hash=sha256:23a9ba564b2db709ff16eca990992ba95a19069972b34bff87c81d4b473cd755 \\, --hash=sha256:25e7e1080f9f7ce7cd9d114b31470ce912771bd02f38c824721d3c35d312abff \\, --hash=sha256:26cb012c4b8ca9f847bd0ac15978bd3d0f55b050bfbe6c47355edfc7e945029b \\, --hash=sha256:29358a8ca74e7d81158d14e2b10c904bd18773293ae3788716c0626fe0342347 \\, --hash=sha256:2980a701be88f9128a7470189fa3bcda5387f76c298a6f8e000fc29eb2a6f4e7 \\, --hash=sha256:2a60ec2a57ac3ef3767e526e9bf706ec75aa3d79c4ea134d9d4fcf7c62a297a7 \\, --hash=sha256:2f42584e5785385f681163a42506cab0d51295e17599a648396c52a7046c1372 \\, --hash=sha256:2f5cc5bcb94063fbbdfd285a2b302da34af07491337c10bb35de1d5220fa1583 \\, --hash=sha256:2f6767122b37c780bb756a720a4eef2bc6a050a0a1143428834b3cbc89448bd2 \\, --hash=sha256:300753f71c73302e218124baf995f00058e085cd01869bd9610bcbd0bd4500c1 \\, --hash=sha256:30d4dc35bc0eea52202a90b3820445ee0072c820241bfa710a623a078c9b267b \\, --hash=sha256:32a991aebd165f227b7c7c60bb9d66c2c7de9c24308552da264c9938fde0f8d6 \\, --hash=sha256:32d6dda86383645ec428ea64dfc277036f5cbc60a72238eab28b91a3fdb9a113 \\, --hash=sha256:33b21f69540a12c2053cd1d95766d8bd9667a3897f7c712a642de8aa37eb0865 \\, --hash=sha256:39f489ce31272073e6e146f6781690f9c1ee8c126836e6403361ef91154d89fe \\, --hash=sha256:3a48a5254d15a0ad050318bfc7a9566d4ec740118187e8f303e47a6840287eb7 \\, --hash=sha256:3b8ee2589a082739c522c1fe4be227412fcf108b903abb6672ae2f5570558882 \\, --hash=sha256:3de6c2a4df2af0ac9ab4dc1488746fe8b1a90e27955d870d9edda3187d20092b \\, --hash=sha256:3e0b395648c6cb871bceb2906907f255dc876ec425f2d5b024e129985cea8519 \\, --hash=sha256:3e547ceec1da7382f01f9e13963023e53367a71802c88778b21b9645a077cbdf \\, --hash=sha256:41b2cd8b29dbb5a4c9828a70f50d1abfc92011115c813213d3a91205c6f731b3 \\, --hash=sha256:41f4f8ae714e4fea1d635880f8a1af715ecf080eed4d13c5b04a0f3210f9c61a \\, --hash=sha256:474f7e598c7902165662a5d5160d3fce31037890a2975a9871ebf7c05862300b \\, --hash=sha256:477af785d1846e4e96bf56983b92ea7553aaeccdeb8acdaa55c7cee9eda0ae32 \\, --hash=sha256:49eb1241a969a5994db6880c18c012b6cbe2340343d8f529721571806583e500 \\, --hash=sha256:4c29b8f2d6417069bb1f257e6b9113f5d64dc2f554cc200ea90b4fe2c5cdb733 \\, --hash=sha256:4eb15be588407148ef5937dc8d9256a71f6b115e6cddadb7aa20b6ee384680dc \\, --hash=sha256:4eda7e3fdef382b7d4492745988a5baaf6953923a337f8b9dde5f76fa8afde20 \\, --hash=sha256:523466eba8ee10f7480f3c2057563145978011c583130d2cc01fb1e7af808e25 \\, --hash=sha256:57fa0a9490785139f1a4e4f43891830d55dfe4408845c0c9cb5eff4aeaf75f69 \\, --hash=sha256:5b26e5f1793b96cdc60242bf38da86ff24a27a708aa396214cac9b534bf571c7 \\, --hash=sha256:5bc1811ef2b4d4ba63e8e452f6e332b6374bd1d2cbbfdf66826c8cb1f71dd10d \\, --hash=sha256:5c074454dc6d4f6f4ba6561a56bf33a14db7651d882a5a5321ba3ae8868e082d \\, --hash=sha256:5c1013647be741647895c102831dcf79c34209662dbb683df9efb864417ed7d5 \\, --hash=sha256:601fce6cea9ddeaa85329e12e7f351def38d233075f42a3012b9c48071b02941 \\, --hash=sha256:6118e5a5550e36582e19bac1a403711a748f9f18251b054c326d3db02aaa7a18 \\, --hash=sha256:629eae995185540406e3635df5d5cf1d44f19ea240840b835d3f44541ff694d8 \\, --hash=sha256:6348ad12fa741bcc9c2f173e99fbf27cbc038826d8c31a4a7d836eca27878ba2 \\, --hash=sha256:65376dbe1ab4dbc768ca2b72b7c13993562c035f5925fd3bc7ff9c8c585c515d \\, --hash=sha256:6619d49a89a15cd04334f76fec530c155923bfc60da74ff5d815a52629e1aa6c \\, --hash=sha256:664e74848c2f5fc27db8505fe24e1ecd3ac669412913bf73d176916f86cc08e2 \\, --hash=sha256:67f7cc397e1d5556a801d1cba74de0d27d827eb242e6c036c0ca273c745414f1 \\, --hash=sha256:696613a0c0e7b2b35356e389ba4195ce20cfe7a2fc2e992c87d974d973eabec7 \\, --hash=sha256:6c5687b59b6ba0f663c4f2f15470f68507d6b45ccd3a19ee6d224f95cbee70d8 \\, --hash=sha256:6c7d7b0b596319e9ce79ef96ce57a14054a2eac629c0588a0539187a218be799 \\, --hash=sha256:70dbc9f83c41f37a4faa62dae5203853847223a891da446f48ef2efcfd5df806 \\, --hash=sha256:71395a43da5584bb70556f380387e15f845c0dcf76373c1afbfa0025737576ac \\, --hash=sha256:71ade6d2e445839350d589ff99bbddfde16f3f32db28da5c894a09f99c8b2a03 \\, --hash=sha256:71e03d2ea1a221d020cfc5b6cc8bbbedef23a06704c70fcf4d0afb42965b22d1 \\, --hash=sha256:7210398a1607ad607dc73196e575b3148b00a333cbb602ddbe1b60ba54554f43 \\, --hash=sha256:7472c39480ccc11dda69a196d1b7c7a6b48eb6594b77f05d945599d3e47f731c \\, --hash=sha256:7646353a5a7c553c04167aca628e2550b538f492765b03ccf34321a560acc43c \\, --hash=sha256:76e0065998159244ff4c097a6c05ff08019c6fbb6e597a85846e73044f0215b3 \\, --hash=sha256:789a6453e5ffd18a7ab6b8c3a0dd8403053829197ec258ecb90c604c21ffcc99 \\, --hash=sha256:789f88dea57841cdebef392b5d6e90444d767117e9ff2e0d9172df5c9de6690c \\, --hash=sha256:7ac2769a7ddd661e07e26c12220adc31b17014c48234b2a5a88993b8d4109e09 \\, --hash=sha256:817953730e4a73a09008b010c4a42396cefe799616a22df2ac21d3927b3080cf \\, --hash=sha256:83d2beac85b757bfc404c5c0612df51c4ef33bbb7be65cf4a96b4da7cbc4ff4f \\, --hash=sha256:86c7c4615634b5c57a79770f5b738354e45ae219a89949aeae84f19169a05283 \\, --hash=sha256:8923fcd49f875e8a0448d7223d1fdf1a9973ae2d1f20d4158753ceb8909facd2 \\, --hash=sha256:8cceae48ae7f94990c2f4e36291e9ec9868735e8b0f19e4489a17b0422338466 \\, --hash=sha256:92f8f63df729061bb14558ed740e7a222f6e2aa6c2e6a5bcfb4e706676562049 \\, --hash=sha256:930ad463d3fb7a340d323bcc496ec32dae469ec9974c29ff569f19806b6b03b4 \\, --hash=sha256:94733cb447c37b0ce6f71b39ca1288d5f966a084023a5617b4cc35a852586859 \\, --hash=sha256:9be1cfe715ecaa060ffd5d599ef410b94ef2697a0eed4cee562f788a2aa2175b \\, --hash=sha256:a0c5210d038418a115e7cf8706bfa611bd14add2f5787274dba45aadca3155e0 \\, --hash=sha256:a2f8716344bbbd10443391be0b1f2003b34949e3c4e6883005c2bc498ab6b64b \\, --hash=sha256:a4bb174bd65f795c39ad6642d9d5bdc43351b306b7d0a654ab0d0abb38be245f \\, --hash=sha256:a70d5effebd81ebd8e15a8aabdc7980832367b2b00c36543bac378977004cc80 \\, --hash=sha256:a9ee990bf2cfbd81574c5d4f9f6c9d480a14b5b43d2c4f2ca13f4c6f48089394 \\, --hash=sha256:ab2822bcdcefb54d1e8ca29f5e3ec3afe160fb794bb3a3a73b09d11ed2671104 \\, --hash=sha256:ad92d255a165cde5f9882ff69699eaf5495e0a1f32e97566bbbb80f11e46781f \\, --hash=sha256:aead3b74b68396bf0feab5d57e050b730ded7df55853c1e048a87e00aaf033c6 \\, --hash=sha256:aeb2e123cbf978a905e9f55155c1b8316fbbfa7cf64d04521fe174bab302d100 \\, --hash=sha256:aec3c2d741a8e3ee993de7f95f37afb51e31b169c95dbd29da4cf6688f340914 \\, --hash=sha256:b0cdb655fbd1562c2dfc9986f9103a106f7058cd0915afc6e656d4b1d73f3387 \\, --hash=sha256:b26f39a5be3cd91a2035818be3d0ffdf5282c3e1f5f53d3b80b7024021acee52 \\, --hash=sha256:b2f2d13239487cecaae98c9f4d5904ad0737643cdf8873c88ec6a78b12214f20 \\, --hash=sha256:b300a30304c4c6aeab03ed06809819d9eceacdd58441d3c7dffe41edfd006091 \\, --hash=sha256:b42f64825f5d750228f08318a9bf4d723b7ecb4c472aedcb3013c3ec2dc1f949 \\, --hash=sha256:b67d38e8bb0ade7e6e84575e4bb153fab35b122458077273aeb08fdf12be9d2c \\, --hash=sha256:b867f9fd183d76977f810c626d539265183c25b2284762893a31e8d6cacc81c0 \\, --hash=sha256:b99bed995ed7c41515c11fe2beb86f8a6cc298e5537cae2f736de2f982f74ef0 \\, --hash=sha256:bd46bcc28ed85d3cf71581b42d90b4ebd1f2062f81879519fed209f8a4d1cfc6 \\, --hash=sha256:bee28aab5a580eec673f7b68dfa8dece3dd37bd207ef8d22fafe23a8e9837296 \\, --hash=sha256:c04e9d920e2674f54651fd260a15c5d2843526c73d5242ee4311325ddc9573b3 \\, --hash=sha256:c4c5a1770ecfe8bdb6c6f09f8d81ea4de04f7efb012fac1efa4ad315dccc1fd1 \\, --hash=sha256:c733087ecf7dde06b1d071679bfd5f3ba03266ba77814c1c7253bc48c9adedd9 \\, --hash=sha256:c813ada7a651193acda85b6bc1cf12abd4b37cd25c7c6a75d7183512cc374969 \\, --hash=sha256:c81d98e27d9d9261909dcccab1ba5d6ea1c98b0bb9470e368604614fd1d36ddd \\, --hash=sha256:c81e35862aced259177a537ce1a6264c3a97bae1ced184ca9dc10ea754563688 \\, --hash=sha256:c856e439a9d54d514e81a7131229ba151cdf81df7c408e0f6c89340e5003dfe2 \\, --hash=sha256:c9e70012926e97069cdd09221861aff412aa94e4cac2e019055cdb79485b150c \\, --hash=sha256:ca83a32b2b41653d89f09a3d22b770bca96da72273bef8f7a68136bdd1e8b823 \\, --hash=sha256:cbf0777d54672990b10cb8ca9b0523499e182d7e2ea39f86b138519a902aa601 \\, --hash=sha256:d49127f137f871cde3c5650af33bbbdcee02679dae76e020902fa106f522b8ae \\, --hash=sha256:d690121e80ab16e623415351ab24713534d4e500b3cadff216409cb6826063d4 \\, --hash=sha256:d6a166978f22f10cb91413f70519861605219346decf65bc79008f9257c94afe \\, --hash=sha256:d6e3485a5e5c01fb5339c1ee3d4b9e21e2135a2a9d44caafb71acd994487ee7c \\, --hash=sha256:d7d406709ae924cf0b08b8282ca2f0e1c90526911d93bc040557cbc83b74c55f \\, --hash=sha256:d8201c9f9035520cdcc7dcad383b039ec8123969b87e01cf27c3dd883c02313b \\, --hash=sha256:da779ae50b46f3f7d1e1b5f362fdc0ad376a49fd55f6f3122dc2b6149936cdf7 \\, --hash=sha256:dcf2c7eaaa4cafe8e49b017e5bb49e76e084ab6f0cd712ee4019c812b5cf68b8 \\, --hash=sha256:dd8bed00731a21e3106e5dd6bbffb6c775a2c0bbc7c0c9face534d830057bdc9 \\, --hash=sha256:df1c174796cd63eb6b139f7daf783affe1f3ed659605850e843b24764c21bfc5 \\, --hash=sha256:dfcf6e51000b34f7026322cd9ea9bc340d745637e27e0bbc22f504b4f6b967ee \\, --hash=sha256:e498900bfbf7ddddd862f810440c09e9b81674739e8a11d619b40906dccd4a9a \\, --hash=sha256:e512c75ec5cf4475c1aa50ad975ecdf253f4963b06e152e1a11edd6de4010753 \\, --hash=sha256:e5bd109d095aaae989a0463d5ef0fcc43e9ddd5de125e656d3c119a79e466380 \\, --hash=sha256:e6b4b08d09054310a4dc389fa61ee22a7a5a292cb23ab8a985136ca8828bf924 \\, --hash=sha256:e6da138a1ecc1341c8b788a5ee822670b03788e1f5decf7af9d461de6e508b8e \\, --hash=sha256:ea2f61b0bc12f3592288503961b764579dea0658852d96a0b3d823614d808821 \\, --hash=sha256:ed9c0b6f236648dbf30d57e9f57e1f74878caafa04833a19f529b5ba5164b7a8 \\, --hash=sha256:edbca8789fd10f0de534b660a6b4c71f1fd18039679c918dad392ab044bb37e4 \\, --hash=sha256:edc17549ab592e33cfcaf285f047bb75fcd98f608aa9309af1187fd736ce9641 \\, --hash=sha256:ef8a9ddb2e2a4eae4abb72dc0710eca6c2726779b0664bd10c3ce9fcfaed8c4e \\, --hash=sha256:f08ee8248aad2d054e5bc4c73554d4505464698f6d754f16198dbc5764e9821d \\, --hash=sha256:f1d62fb172db35c6478c9323da34ff37d1f3d37d7d44337a9d94ba8c583e5730 \\, --hash=sha256:f8fd23653a252cefabea11cd041efd7b80bdf403e43a36dea53f9cb0aaa21f0f \\, --hash=sha256:faa4e96385c820ce9d7f7a623486e23d4134ae3c9ba2071e44e0ab5a5a5002c4 \\, --hash=sha256:fb2bb5b557080da398b866408117d98fe9731a12334afd0cdff221b458cdc5dc \\, --hash=sha256:fc04affef30be98c1f36f0c422a4061ef618fdc1dde79f5ad5458dd496fecffa \\, --hash=sha256:ffb616d8d55965839670301dc3bae3abacff560a7e137a89056058a8a9da4d96, # via pydantic,pygments==2.21.0 \\, --hash=sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9 \\, --hash=sha256:610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c, # via rich,pyyaml==6.0.3 \\, --hash=sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c \\, --hash=sha256:0150219816b6a1fa26fb4699fb7daa9caf09eb1999f3b70fb6e786805e80375a \\, --hash=sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3 \\, --hash=sha256:02ea2dfa234451bbb8772601d7b8e426c2bfa197136796224e50e35a78777956 \\, --hash=sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6 \\, --hash=sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c \\, --hash=sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65 \\, --hash=sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a \\, --hash=sha256:1ebe39cb5fc479422b83de611d14e2c0d3bb2a18bbcb01f229ab3cfbd8fee7a0 \\, --hash=sha256:214ed4befebe12df36bcc8bc2b64b396ca31be9304b8f59e25c11cf94a4c033b \\, --hash=sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1 \\, --hash=sha256:22ba7cfcad58ef3ecddc7ed1db3409af68d023b7f940da23c6c2a1890976eda6 \\, --hash=sha256:27c0abcb4a5dac13684a37f76e701e054692a9b2d3064b70f5e4eb54810553d7 \\, --hash=sha256:28c8d926f98f432f88adc23edf2e6d4921ac26fb084b028c733d01868d19007e \\, --hash=sha256:2e71d11abed7344e42a8849600193d15b6def118602c4c176f748e4583246007 \\, --hash=sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310 \\, --hash=sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4 \\, --hash=sha256:3c5677e12444c15717b902a5798264fa7909e41153cdf9ef7ad571b704a63dd9 \\, --hash=sha256:3ff07ec89bae51176c0549bc4c63aa6202991da2d9a6129d7aef7f1407d3f295 \\, --hash=sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea \\, --hash=sha256:418cf3f2111bc80e0933b2cd8cd04f286338bb88bdc7bc8e6dd775ebde60b5e0 \\, --hash=sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e \\, --hash=sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac \\, --hash=sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9 \\, --hash=sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7 \\, --hash=sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35 \\, --hash=sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb \\, --hash=sha256:5cf4e27da7e3fbed4d6c3d8e797387aaad68102272f8f9752883bc32d61cb87b \\, --hash=sha256:5e0b74767e5f8c593e8c9b5912019159ed0533c70051e9cce3e8b6aa699fcd69 \\, --hash=sha256:5ed875a24292240029e4483f9d4a4b8a1ae08843b9c54f43fcc11e404532a8a5 \\, --hash=sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b \\, --hash=sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c \\, --hash=sha256:6344df0d5755a2c9a276d4473ae6b90647e216ab4757f8426893b5dd2ac3f369 \\, --hash=sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd \\, --hash=sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824 \\, --hash=sha256:66291b10affd76d76f54fad28e22e51719ef9ba22b29e1d7d03d6777a9174198 \\, --hash=sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065 \\, --hash=sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c \\, --hash=sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c \\, --hash=sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764 \\, --hash=sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196 \\, --hash=sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b \\, --hash=sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00 \\, --hash=sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac \\, --hash=sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8 \\, --hash=sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e \\, --hash=sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28 \\, --hash=sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3 \\, --hash=sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5 \\, --hash=sha256:9c57bb8c96f6d1808c030b1687b9b5fb476abaa47f0db9c0101f5e9f394e97f4 \\, --hash=sha256:9c7708761fccb9397fe64bbc0395abcae8c4bf7b0eac081e12b809bf47700d0b \\, --hash=sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf \\, --hash=sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5 \\, --hash=sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702 \\, --hash=sha256:b30236e45cf30d2b8e7b3e85881719e98507abed1011bf463a8fa23e9c3e98a8 \\, --hash=sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788 \\, --hash=sha256:b865addae83924361678b652338317d1bd7e79b1f4596f96b96c77a5a34b34da \\, --hash=sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d \\, --hash=sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc \\, --hash=sha256:bdb2c67c6c1390b63c6ff89f210c8fd09d9a1217a465701eac7316313c915e4c \\, --hash=sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba \\, --hash=sha256:c2514fceb77bc5e7a2f7adfaa1feb2fb311607c9cb518dbc378688ec73d8292f \\, --hash=sha256:c3355370a2c156cffb25e876646f149d5d68f5e0a3ce86a5084dd0b64a994917 \\, --hash=sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5 \\, --hash=sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26 \\, --hash=sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f \\, --hash=sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b \\, --hash=sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be \\, --hash=sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c \\, --hash=sha256:efd7b85f94a6f21e4932043973a7ba2613b059c4a000551892ac9f1d11f5baf3 \\, --hash=sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6 \\, --hash=sha256:fa160448684b4e94d80416c0fa4aac48967a969efe22931448d853ada8baf926 \\, --hash=sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0, # via -r rl-lock-input.in,regex==2026.11.15 \\, --hash=sha256:03e3e31271f40e17f038e2810014a15b3e9b0950c8dac5ca910a3375ffc7b112 \\, --hash=sha256:058e6aa045d02985490d6622b986cb7db25929890384faf642233539439b804c \\, --hash=sha256:0a24a03358c429457365e600ad639ca6111b61a6275dd2756b4e02a792ec8477 \\, --hash=sha256:0e1cd15586d8afa75a925f1837ad347e61e3d32d9bbe0b0e63edb194b4d718c5 \\, --hash=sha256:0fa62f316890f582ec536aa4e993b8e3679d493b45d87de77b59e9df2325ad28 \\, --hash=sha256:119909bbaae76605210572042196de125e261037f915dec273af3b13fae65c06 \\, --hash=sha256:14feb390805c099e16bf7d37e5f574068eeac59c55336a76d0c1c6f7388b2510 \\, --hash=sha256:150f52dbcaf759d94c73a61dc31ccc60eb8a552acafa43e99e3ed76405173170 \\, --hash=sha256:19989877c737d3f648a6addd2cba45b2698b895cd15ac37388eb4af48b6af819 \\, --hash=sha256:1b34d1f63493a14845e70b72a53eb6b1542f63c44cb615ecf2fd68ec470ed489 \\, --hash=sha256:1bdcc15a5e10be63a05f6660ac28679f7ab50cd48d8a53c9328b030d2bc36060 \\, --hash=sha256:1c3c89fbbb08d2f75e36179d27154e867836656a9ab57616aaf8042c089c0d20 \\, --hash=sha256:1f05e0ea23b59b4a69e08498c6d2b58eb94719dd1966e97b73e4c1df1604db38 \\, --hash=sha256:20a86cd29d0323feab48ddb630cd7a48e66355504e6f4661329f11a931ed58f2 \\, --hash=sha256:20fb02e33c0e3c0a265d1b767c359c92d0df9292292c280ff67ace49e3e05467 \\, --hash=sha256:2388100a73abc2205b22b37f292661bfd1b221be0fde996e5e4f1ad272335471 \\, --hash=sha256:259abe2f6d24a87928715f758f55ad8bad58f02c950447cad42f46752cd96c66 \\, --hash=sha256:2ade9b8a36259183539c2eb82cc163ebaac1c38d14b4a30da9433295a4610dc0 \\, --hash=sha256:3232156a2b62a063f21aa155154e9cc943ca05eeae1d1a00dca7910c7cc1976c \\, --hash=sha256:34fd5add8dedc9b1de724049951e3835afddc21cc43e2741cdce6e1c92b88b81 \\, --hash=sha256:37f839f3a65368314d232376c754eee726ce4a34030c18247c76d238ef0ff249 \\, --hash=sha256:3a16f20dcfb68ad67bcc326757facad9b3e922693409c1c8c0deea3869e70669 \\, --hash=sha256:3b896ba13443de0048e7adc18632ea04a163641a77e977a010cc178f45b2352c \\, --hash=sha256:415ae840ea09b36e40fe602d65a84c2fec12a5bff845d932a6cc863c94a60b96 \\, --hash=sha256:42f9f6d0f3698f8b32cfe45b03cbd1830a7c203c9930fe15a1516ab9dda19c36 \\, --hash=sha256:481626b285706374a83f7ce569f2d1a0c640700a569d5ca54dba1d2668e03a04 \\, --hash=sha256:49ca893a13a1fb68fcec24ddf19e8c8dfb13fef697c1ed9d65711b5881d03180 \\, --hash=sha256:55db42bd5d8de089e2ab3e5ef48a83c013fa6eb81cc69e3e124556762b61cff3 \\, --hash=sha256:5607a1d49b4ef9d4a61de1a84902a09e4bd6619be71712d7c32381292ece5063 \\, --hash=sha256:5de7aeead82b6f40ec8524555bcbfdf21824ac97fd8e219598008befba56fc91 \\, --hash=sha256:66a49a7a63c0d77d0abe20edcc2d9466c8bb7b6a78d77c61871c768d6894f72f \\, --hash=sha256:681e92c0de78a5124e5a2e53788538c7acba4c8086d90623fc8101840583d40b \\, --hash=sha256:6dace895669eb1a4e4c02ffa6595fc4f02873de53f88fc21e70d41c4451220a7 \\, --hash=sha256:7011045ea36d3d642ae5207f2f80f0486f3495f6107326bc1d9a9c68b2ba9f72 \\, --hash=sha256:702089e41de56efc2cf4a690dcdc6c16e80833bb336eeee70b61c147bbb608f4 \\, --hash=sha256:7288fae326a15b1ea57c6b07225a1b6e0b68def5dbe7670651a35e4af61f785b \\, --hash=sha256:74e0b34c79b7c27e47d5929e565ab703a2149e89c5d50d99e06e33410ff29394 \\, --hash=sha256:76d4a6f241bd25e915ee292722cd06610d417689d11f9b1080fcb3693952fe6c \\, --hash=sha256:7848463f856954ca7991c076cad16734329596417e8ed266b1753ac09dc51097 \\, --hash=sha256:7912578bc32a25cde9648f35ef00e064464792980f43fa0a690501277e33042e \\, --hash=sha256:7ad141cdbb94ee48a9128b7118bf82b4df2b80f3b3caa22c36045da49e765481 \\, --hash=sha256:7ddabafb036132a20a8868637bfade62a98e5edefc574a52a91ce73961bc4e47 \\, --hash=sha256:7e0562f26fbe338b614691a3ab7040392b17c5ed1cb26e04032c9c1a874b0040 \\, --hash=sha256:808be73b8fcb4bc9f1996ce0dead2e49aaeee0cd11db0691f7b63eea7c0f8448 \\, --hash=sha256:81130194b54191230abe0bc57f15f70f18147d1c1c7c237f85e6a2425c1c0445 \\, --hash=sha256:81a0a8a2cecab76abc0fbb4d50f849d004a6128accb32d77109b92e8324d4272 \\, --hash=sha256:82abe7618741745c83a8cf3f0decc4605c3bb5a2b6e1bc5e7412be01ed10eabb \\, --hash=sha256:8721e5331ed77ddc52e86e2f3111840e58e3182bb049195fb632c441e8ed853b \\, --hash=sha256:88da86058c8ee083aa4ecb8c73bcbb46e388a34a4d548b73c834e77409a445a1 \\, --hash=sha256:8965eafcd408db9f44d7ae9debf052dfbad3748972510bc1c7e2d6241645a3bf \\, --hash=sha256:8a194defd67c120d7dfbd8459b9d98057bdcd03a8466b977d4d237a526c053a7 \\, --hash=sha256:8a3cb0651bc61270f3db6f733a277a9c1bea006ab9e0bf17d5a1ae36ea55def6 \\, --hash=sha256:8ba7541b08666615b6a5348fb9b2553dcdb7b6543089f318b77135667c3a7d43 \\, --hash=sha256:8f1c6871464b8da493f1f6828f1073725a0e9cbaacb1181a3334e65422c062ef \\, --hash=sha256:930c3244a9128d9546c50f9b03c01c22b3674bf006fd8830f2581e74bb5f1105 \\, --hash=sha256:958661f35e8f260fea889a9a4b42db0e2756f85971c8f7371d9059cfd1997f70 \\, --hash=sha256:95cf02fb529fdda5f9414303e3a9c0e1807bc4a00ae5b0ac214e66812fa175aa \\, --hash=sha256:99e61a4f575b3439de59de524bed94d144b22a11877407c81c702ce98fb4e1d3 \\, --hash=sha256:9a7d15f046e1ea4be447749462ad588effe5fe4c6e26271649385d89767d6e9b \\, --hash=sha256:9d304418a1de575974d85c1d3b4ca04b8371d18cbe55c9f953fbaebcb61741c6 \\, --hash=sha256:9dee9001be6426e1ca58411e5b77dbf297d89cfe4f1d3abe78595ecd912adba7 \\, --hash=sha256:9f94950edcaee1925e1e9ab11d1b458029d525f42b32eb8014c93ead19a22fdb \\, --hash=sha256:9fc28a3e2f8a1d6930dcdbefb31a80a82caa86619980f147d5bfeca30eae76b3 \\, --hash=sha256:a489fde13c1f49325ff8b3f4ac2138631edd093c02dfbfa31921cd8a478e8aff \\, --hash=sha256:a99aa9a355ebe33cc7a68e6651c20712f338fa57a8e8cebd782e4208543c3b46 \\, --hash=sha256:aafeb64c8569d69edfbf772feba49d2a001d3dca0f43e6a71e3735587ecb8222 \\, --hash=sha256:ac637b5ad26f868091fd939426dc5aa4b75237c2cc72196cab756a861abd107e \\, --hash=sha256:b22436339fe2fbf5e932f4b187dd1244663f05fe96d255c11c0cb1adaaa13576 \\, --hash=sha256:b2bc7e596c7fd46f303a42ce40b4e9c08fdd37f431695052acbee2e7ac7db6ae \\, --hash=sha256:b55f41770984827e083808892b25022b618a74e228887bdfc51574621dcf96e9 \\, --hash=sha256:b569ef5adf7dc957c24602b243cc3af6f4e8fc80d688d528ec478b4164f3f1b8 \\, --hash=sha256:b90e34261f0cc8ab174602a86bfc0b9b89825ba7fa05b996a1c97a1426730267 \\, --hash=sha256:b9aff8d89f72818646f192632c8249f3848a23d2c9527360de356d6025c5bcee \\, --hash=sha256:bbe5efba8a008a2a684173286be44b85b2cfc3427107662440903ccce6ec00d5 \\, --hash=sha256:befb860301d5c4736e0cdfabbbe2ea5887a7a643594f5e32c59d9a28f94a5f75 \\, --hash=sha256:c2873cc9abe12d0ad55e4ff5b616856c2e1b764f39d58e931038c06b37e5a7f4 \\, --hash=sha256:c487f7832327bbaf68d66b47e8848586e2d07ceb0028ba71a42cd5ec10585bd3 \\, --hash=sha256:c56b4d165feb65211571007f4b016d142b52fffb91b30bb4b38175cf3acd3917 \\, --hash=sha256:c58f6a5c1f080384010dfa8b33378fdc554b4ad96299d3dcbe362a7aaa50857d \\, --hash=sha256:c5d722af534ac05fea28db7876d45aaae1f8b6c504cf82a5ab27cd80e543e9fe \\, --hash=sha256:c6c868a2b8a2ca126930d2699b1a9ea7bd2134fe32107f8b5608d352783adce3 \\, --hash=sha256:c91d5a2a0b8fbf1e9deddbc2c59df93eb0de5c2314d9384969866cfaff6096c2 \\, --hash=sha256:c9d594f5785a4b0b7ad6a949ce8c799c67ee8105a6ffc8b4d5f4fd39f53bb9cb \\, --hash=sha256:ca38887219a8b77e56a8ded792a4ca6b0e78138c0ea0817de44022b0f73da3a7 \\, --hash=sha256:caeba590c348e1960ef9ce99589af4ab53b481f68b35ebd7f536abec2b072d54 \\, --hash=sha256:cb35195054f5eb044a9022a9d1c1799e0524adaa3f9ba936d2f134f3c7fa1d01 \\, --hash=sha256:cde33ba347b399d6b4f4c4ad03679a2570f945222596a56f9ca335e8ceea9340 \\, --hash=sha256:ce6afc332face9c5978dccf74c9bbee095d43b9794bc256f5acec1565c3e3fde \\, --hash=sha256:cfaf14e2080f5ced2699ebfbd5fd6cede980d331e14b2dc25235480bbd3de61d \\, --hash=sha256:d55cb1bb1f4309e7462324d70491d99b8cfe7af62c41a0e5bf42835f164fa2bc \\, --hash=sha256:d6ec7e29e62ebf93ab2a593d1137022b6025497d8610e5cb666d52f9ee5bb0ce \\, --hash=sha256:d7882799ee96f80e07cc0cc049e609ed3ccacf08fec81e47fdbbb06c0b8ea2c1 \\, --hash=sha256:d8d8f0dcd2583c0095e1764d591f35d9b974b6d98afec20b33512cc7778f389a \\, --hash=sha256:d96b2621622b040e5fec358cd9f45341845ab8517fd4d06d28088ea4a2fb2d5b \\, --hash=sha256:d9ab084d9c09cb95cce2e93bb59e19d55b98347e01649beeadf595d129111475 \\, --hash=sha256:da8dcbb501d6b3bc2c47db82fd1f3c78b7e980941db820e98562955e59c4a562 \\, --hash=sha256:dcb2f4ce63699ba4606d928ccf1e9f81557ba8b2ff263c52610253324856e199 \\, --hash=sha256:e3b0bac7b125515fee40b4df7069b2c3a89b4f722e159ccaaf78d44fe4fec261 \\, --hash=sha256:e4e69107963c47c35ca2d5f3c400e4dfe7eab5b107ab02830f712058e34e9846 \\, --hash=sha256:e53de052944732050022a81ea14f6dea25fbcfddc1c0c38def00e2ea3da1257a \\, --hash=sha256:e64ed603efac109f0ca26bb7e69ddcb5735aac463ca7dd15f7ca1eb7cf212f02 \\, --hash=sha256:e6cd01d3cefde448faacee38fcb1372e8e8687dd05a23d767e684b5081bcd0b4 \\, --hash=sha256:e7d10c6ac4e4a7cc65cc12ad61daa188c7fd16b32ba1919913b5da054ec6fd35 \\, --hash=sha256:e809decf3539660a2080b806d48a9b716b58b011a43f62f4272d256ec9cdf0c6 \\, --hash=sha256:e933aa169c3ec81518ce52b4db533eb3c7bfe5e55426a3e7f57742300263c4c0 \\, --hash=sha256:ece2f6ae38a8cd3eae07c8ca723af420351385294f989a76235a2b5bd465045a \\, --hash=sha256:f07145c751729bc78aa1a231018e4c98316c1e516514c09e926fbcb0d3b14ec8 \\, --hash=sha256:f11f0d4110a071aa6d8da35c199fdcc607271cb8c23babbf00aadc2d02b85b00 \\, --hash=sha256:f3758c3b1689ab778f3e1ae0f9aa4d22b8e4efc362e2e4cfdbbc5a208fed0bc1 \\, --hash=sha256:f48429378adb4a3e2c93ef4b551265350d712cb7cc5071538b7841a66da17014 \\, --hash=sha256:f5749d2d16ebd65e60ae1e1a2661c80ac1717e5cb2db50fb47cbeb0073108b5e \\, --hash=sha256:f8b2e49c18439db0a77533429d3ed7330671a262b8e82bdb6e9cf03b4ea91adc \\, --hash=sha256:fd90d5f29b349833fd692860ecdea1a9e6fd24127582b96234bfae15c1ae18ae \\, --hash=sha256:ff36007d31a0ba241f7bb09fd179febe221f52b3bf11798ab1b48e8b20a43220, # via tiktoken,requests==2.34.2 \\, --hash=sha256:2a0d60c172f83ac6ab31e4554906c0f3b3588d37b5cb939b1c061f4907e278e0 \\, --hash=sha256:f288924cae4e29463698d6d60bc6a4da69c89185ad1e0bcc4104f584e960b9ed, # via, # dashscope, # tiktoken,rich==15.0.0 \\, --hash=sha256:33bd4ef74232fb73fe9279a257718407f169c09b78a87ad3d296f548e27de0bb \\, --hash=sha256:edd07a4824c6b40189fb7ac9bc4c52536e9780fbbfbddf6f1e2502c31b068c36, # via, # dashscope, # typer,shellingham==1.5.4 \\, --hash=sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686 \\, --hash=sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de, # via typer,starlette==1.10.0 \\, --hash=sha256:478c0ab3b4ced6e82719849c118fa406f0278a3499c1a898cd15cd31bdc38ce4 \\, --hash=sha256:b8399098d4c1e3522734f7235dc79b1fc967f96cf139c81e0fa30479e0685f9b, # via fastapi,tenacity==9.2.1 \\, --hash=sha256:9e56f17539296baab7beabb08b92f6ee3d7be92d8be72d763360677c2ad6580e \\, --hash=sha256:a606b5c808d0cded4a359d5b9932d867ff2a6a6b64d37350260fd01bbdf83839, # via -r rl-lock-input.in,tiktoken==0.14.0 \\, --hash=sha256:087538c080e5ff421abd3a0785ed63c5111d06af98e6cd0d374dbe5969147ca3 \\, --hash=sha256:10f31e63e40313f2e518d87f7086cfa44e45f64cc14d8ae14103b41220c30a14 \\, --hash=sha256:11d8211b290855d2721334ff17dd9b3a17bfb26872be01f25d73612ef7ece890 \\, --hash=sha256:144a3fc369f92b7d548995217c5d6e84038d3572157a0f6f34080d65291d0f78 \\, --hash=sha256:149d97453c4c98c04b081d64a85e635921269b532710d6faf81e9e82b790e7d3 \\, --hash=sha256:14b47e3674f2624803a8acc8fb367b7e24fc53055f9df3296482fe9a3a34a232 \\, --hash=sha256:151d37a150c8f3dfc5f4345597b10e101876bd1bd13494e0185af6b508758d2e \\, --hash=sha256:18a1b651c4b032004bf7b4f1713391a54b2a341a52c6e8a2b59acae9d16e13c7 \\, --hash=sha256:19d643d701fdaa70e5b9c7f8f96abcaffe77ca5e482a3a1a7dde46feb4284695 \\, --hash=sha256:1b6e4adcfd285c44502aed51df98aaaca4f0fea028165dbf8a9e857b9f98d8ea \\, --hash=sha256:1f83081065ee5833d35b49e9180f3d8d15622a603dd1c435da0da6cc12b3662f \\, --hash=sha256:2157f52e4b4d7ac5ecc7457b3716834706e7ef9a46f5144029bfeb7cf71f4e06 \\, --hash=sha256:231dec90efcdccf1b565a1416107736f1e09b1a08fe736ef9d6363e626d03874 \\, --hash=sha256:26cc4b4840fa0e9f4b72ed489883e12f57e00d1021ca794720e3c29a12f0edef \\, --hash=sha256:26e60f6a956ee171ab728b37b8439905d7ea1db435c30f9822f291e9861c861d \\, --hash=sha256:2cc19ac87b41c9493c9778ff5847f0c8bbcf5bd0ec6b87ce06c1c802adc8a771 \\, --hash=sha256:2ea70afba6b9eddbf22c165142e5f0a2ad7aa36a452873c48b57bb2aeb8492ae \\, --hash=sha256:2ec16eb585332c55d022d86354e209ddf27326b1ea3477585ab248e7776d3b1f \\, --hash=sha256:2fc834fbe3f6a0736905c36ab709537e6840dbd63b982dc9e0216ae7d305ba1a \\, --hash=sha256:380873f330b741c4435574f37edb20813d04603ace2d53e0a63560e1fec83010 \\, --hash=sha256:3b12e54f8bec91433e41aff65d8d1f209a4f678081163747079806e5361f6c91 \\, --hash=sha256:3c5349c9f916283bba32bec8af69b763e4faa304dc004d0eaaea66a3cf004c1f \\, --hash=sha256:3de75343041a1c57333b1e707ac8a9769738241d7d6a55d39e12cf84548337c6 \\, --hash=sha256:3fd7c14b1cb45b486c39fc9b3443bb341f3e2fc7e6f31247f3435a5836651632 \\, --hash=sha256:447ada49af4898b5e992f0b5799d2f3af385921102c211947ce3fe960dd919da \\, --hash=sha256:4d8d91d68353bd167fdf26467e5ff9e56aaa5f87d6410c0238608629e4dc0d33 \\, --hash=sha256:50a7e5646cbac2a8f7c3e8c0934ffda1a4357ee9c44b652434b23c3ed54d0900 \\, --hash=sha256:561e7580f84a79859af1ef6f676968e9030fcc3fe195700b15235bca64f009c9 \\, --hash=sha256:60c47ca69ddda0dea8256fffd12e1b86f4b59734a20e4a70c61f63cc5f021df4 \\, --hash=sha256:6eb94895c45f26bb8f5546e5fd8a069efcf6e3f108ea9d5cbe3bf6f7f3983438 \\, --hash=sha256:728303a072163130c5b477b1f20d6211895569c1d5302c24ffc93a3009160871 \\, --hash=sha256:78571efc311c30b73f31eb949a921d6dac39a5d9dc42d1cfa8f8db157b3447b1 \\, --hash=sha256:7896eea257fe497a2b7134474d909156c6744ce8da35bce88011a960e008aa0d \\, --hash=sha256:7aab286a020660a039097912a088236b985d18a3090d73f136c4413d29d37ca0 \\, --hash=sha256:7b7acbb7a4b8383707bce22ad3c162006478c27b56368acd3e1fcb1658a80425 \\, --hash=sha256:7db45b98e94adf4173a5cd7422b150999a7ee11ff847783a14f6e1b80cc38cb6 \\, --hash=sha256:86951a971c53979ec857bd8c4a32dc227ab0fd33f6c12a3bd62d3fbf5f0bfcaa \\, --hash=sha256:86f66c85e796f5d05d5c4a60ec1d40cbfebc47a32464053528c797163fa9ab89 \\, --hash=sha256:8e947aefe98ef74cce94923f90e48c98fe34eb1ec0a6bfdfadfc5a96359bfc36 \\, --hash=sha256:90a762670c7f968184723769a06ed51f5cf5ce5dcd1e30164f25c72d85c2d1f1 \\, --hash=sha256:94f77b60a8ab23580db19ae822744c9716c1720020d2179ca5605112d12326f1 \\, --hash=sha256:979c1524f753b662b0f3cd261b135afe6659cce33caaa7a5ea00dd1756b3055c \\, --hash=sha256:a140e83317fef02faeeb78d9a8efac623887f2feaf0055c55dcdb2b17f0226ad \\, --hash=sha256:aa428a559d5fd02ae619aacaace86c7474a1f2702d2c01fc828908dd60f20f7a \\, --hash=sha256:b950248272f1b303dc32986396e2dccfa10cf6d1e83ec8f0bba1776660305482 \\, --hash=sha256:c2edf09b381fafbc014ae8e018ed25087abb9a3dafa8465a0ea63c6558c47a79 \\, --hash=sha256:c3093001ddce822b4587e6e94bf6de36a5f97b3f31de1c9fc8d4fda144c59ff4 \\, --hash=sha256:c6cb9896a82b9ee44e15ba0b5c8044072f2e4d48acaa704c8d3feeef5ad9487c \\, --hash=sha256:c77d4a3e1deb2707819df92046b89aad1ac81d27e07616b797cbff3f62c037da \\, --hash=sha256:ca4db6ff5c5bf600f9b7761a0070ed44dfe5797a76bd432fb978bc480ef40c58 \\, --hash=sha256:cbe2cc3bba939bcdaf103e03df9d5039d33887080b315624be28ec69059e5f94 \\, --hash=sha256:cd8ca1305c1c902fe42c486165f2e4808d9997625c98ffb05b9e0366d99d3948 \\, --hash=sha256:d0781223705199b289faa59601bb9c2441712d4c600dd13c43d8fd6a33d22cd5 \\, --hash=sha256:d6cebe67765569df3dafac8474e4eccf5c19d24140492567a5e58a11445732a4 \\, --hash=sha256:e067f4cbcc5d036e8aff7fe7a6b530a8f4de2e4616ad9005a24a1879e24e6450 \\, --hash=sha256:e2eca764c53490f8930dbce329e0769f11108d87d908282a80c5c130e26e7037 \\, --hash=sha256:e3442bbb2f0c588cec876061e37ae67b455b9df9978b003c8fe30e45f2ef5b42 \\, --hash=sha256:e4ddf863b59347deaa92302dcd90e5eb003cdc9be06ec2b692c38d1bdd9efd49 \\, --hash=sha256:e9c5fe393aab56469f04e432ff851216d3def3436cf5f07e442a240164bf500f \\, --hash=sha256:eceeff0c62419bc78d4b6e70a4762a4d25df3ae8f2d5946e3853ce93e7a57098 \\, --hash=sha256:f2af4a336ea56d6c14f27741a0e1d8294a35dd0b038bcf990d232ebb54eb994b \\, --hash=sha256:f3d6cf93fbe2e7117eb7bedca684216fbe328a41f0843ce34245451d8eb2df1c \\, --hash=sha256:f5e7665f6624e052e5e7f6a36919ab69279decdc976d7b16b4fa15e1897d0513 \\, --hash=sha256:f702e0aeeb6506e57687e881c59e844ebe8f0a6a097ddafe20e3ab25f387be4e, # via -r rl-lock-input.in,typer==0.29.1 \\, --hash=sha256:00dbc549c13428bec1be55fe1f4d0fb8c6637a310e4f178ef14abe9534ee7b58 \\, --hash=sha256:ab6eb3880bf67ce96147734717f9ec333c06f66e361f3ea947d0be43da39f242, # via dashscope,typing-extensions==4.16.0 \\, --hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8 \\, --hash=sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5, # via, # aiohttp, # aiosignal, # anyio, # fastapi, # opentelemetry-api, # opentelemetry-sdk, # opentelemetry-semantic-conventions, # pydantic, # pydantic-core, # starlette, # typing-inspection,typing-inspection==0.4.5 \\, --hash=sha256:7f16c411e7930dc79596d42ab44672a3fe5f60eb34b781a1647e7872363120c7 \\, --hash=sha256:bc210535442b39e1bf2805e0c7a17dfd6a4ace760c84c7f7d16245d23a6b1c39, # via, # fastapi, # pydantic,urllib3==2.8.0 \\, --hash=sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3 \\, --hash=sha256:63bf2ead4c879426ebf22ef2a781eeb4aa3b4ae798a0435506f8687fd5bb9b63, # via requests,uvicorn==0.54.0 \\, --hash=sha256:505bdb0f318731d45f1f712071fc781a8981f6847a31c902c9f5e652d4f67faf \\, --hash=sha256:a2e33cbfaa0306f8e6b0c13e0cb89d7d7a2da3e62b90c66e18c33d9807b28620, # via -r rl-lock-input.in,websocket-client==1.9.2 \\, --hash=sha256:0fcb57545848be86992e128218fd96dd87a6769ffdb1a968dff79632b85604d0 \\, --hash=sha256:e1a673830a9c7bfa47b1cd3d5e4178f4c9651d80a4eab02c9c23a1c3ec6250ce, # via dashscope,yarl==1.25.1 \\, --hash=sha256:0136d640dfa9b0523853e411430a99f8a91eca85774c6420285a33b755bc6de3 \\, --hash=sha256:03dd38de09bc213e9a8b29761eec33ee1d5318dac0e49d8af36e4d27830e23a7 \\, --hash=sha256:0a191bfdb30a79b98e5d175d75285f9fcb78bf0e46ba5efda042e1c72071a0de \\, --hash=sha256:0a66db89ea473abeac4b70523cafd94db3772380e565f9d28af7a179b7af71fa \\, --hash=sha256:0ae12ff2b805fa02c4dab838005caef735e39986322698c48588d3beacb65c62 \\, --hash=sha256:0f12afda4eea8c8994a76d4df1875c765194f5fbe8a9d197929ea303caee29ec \\, --hash=sha256:10b2fd95332f0d716d5eee3c9fb2ce8eada19082de7fee83d32e37992fd75c26 \\, --hash=sha256:126a2533570c554719ca40a1288fdee1700b6bc82e7131aa69fa85252d92e651 \\, --hash=sha256:12b6bc4906e11f5e1a1cdcb12296e7afbd366c783cc8073403cd2fb74334e453 \\, --hash=sha256:142c06c4d6a35ee3ec5da08499805e879cb3ca7c1fbfbecb0140fe72403818d6 \\, --hash=sha256:14b79a30a93a3ce2e8832603fd0ab780ada281b0ba5110b519a634f2d7d7d1fc \\, --hash=sha256:17c9877a89fb6e2bca6f9087eb24cd7fb434653946ef5075e470d23d49b52287 \\, --hash=sha256:192a866877a49993949ef1975864ad8728bea28ee810f6abe1a0729c2b500426 \\, --hash=sha256:1ab7618921a93767387a4b83776f751588f5b5ae9bb5bc96620e2e2e00bca868 \\, --hash=sha256:1e80dcf1446e1b080b1932b0d103c464a04112f5bc31f0f983ad418172063cde \\, --hash=sha256:1f51020b2eb8a003c84925638ec63c21a750a4bddd3a22ec8eac6a742dadf1b9 \\, --hash=sha256:1fb2a01ba8cd9c5d2c5dc1ec35e0fc951d04b4f037541d4ac090c993ce58b3d7 \\, --hash=sha256:2239a02249d9326655419e0168a28ca9008938eaab31dc29fc875c217927a6c0 \\, --hash=sha256:23bf5b403c879a54964e0feac7285688e04bb220074878d737d331522da0a5bf \\, --hash=sha256:24ce942011a61953e7d313438038f4d32ff21387b775f58a957f7a07dd55ef95 \\, --hash=sha256:25868beca8b6765f8f7d0e11fe6dd7c66dd4b0793b9500286d20cc92352126a5 \\, --hash=sha256:287e99ff5aa4dc1c7630bfc683ded6f106d756c99dec432a2d7f197a784f51c6 \\, --hash=sha256:29273edf1530e397bd07cb784db1fbe0d2590b77569f2e24679a9c0a2d763b94 \\, --hash=sha256:2b49375d22299b0a834c2bca72f39aaecc270d96fb24c30424899676f487b22a \\, --hash=sha256:30eec96e8a91bd588ce897c9543f6d5d8d34b28fbcba28a4dedf20ebeae9fe57 \\, --hash=sha256:319e070a01db9920fb63761843f96a104c8e2b9427266731810dc1e22595b17c \\, --hash=sha256:35dcbea443fafb3eece757ad4e514560ddeb6c34cfae1582c620d7b293d7feee \\, --hash=sha256:3f4d48a6112712973e676bd792121fee470e432d749177162d9949d5c9460a1b \\, --hash=sha256:3feb99222553a8cbedfa52c2f59dd84c3f50d5b582c728d522caf8d72769a54b \\, --hash=sha256:419f392a1da624877975709e3864dfe833af6cc7671b39318086d456e288380c \\, --hash=sha256:42a66563d8cc056ee32e6191e05097a7b2b3bc302e0bc3133daf8710eb18bd26 \\, --hash=sha256:48796ea00a303961507dc6c8437c4b325a6fc3f95f7c36c71b91ea9a8150963c \\, --hash=sha256:4bd6340d20ae2c7ca719b87b426e808e90743b676d05d4c26c4fb5ca71f41184 \\, --hash=sha256:4ca89e4e21854ed27ec753297dde84b16c9f8e53b14a4866fb44457d643c19f8 \\, --hash=sha256:4d781294bb815ecb5ea57ff6bbf8038e0a31a95fdf3e1788f66e0dc100d64b58 \\, --hash=sha256:4f1c91f5a5980a937ff8e238e98e6897e1ad74a4b1e2c0d68c73b5ffbb3f5c0b \\, --hash=sha256:564fdc7085d2245ab84f88882fdb1d6ac0723124bff6ded35bfb1c00f812630d \\, --hash=sha256:59ba3a6e1aa8cfe5adf4bd270fd965db21955401b7ca6f1696010c55ed4daec2 \\, --hash=sha256:5df89f769cc8ff94c3d7e7603386fba309d25ce5240132d26c15baa8d0e96c4c \\, --hash=sha256:632da579b2d879f6bad20f2cfa35ded1efe2f4f77f8abb26a6234a5b236acd2f \\, --hash=sha256:65b5b2066651b7432d389e9799d979c703bcc6ef44266bb8153ef54e91e4aab3 \\, --hash=sha256:664ec6a520b74a1df2810666eb67695fcb77fa663e6ea0a25aaf2e529cb24dfa \\, --hash=sha256:681c758b0490f9e96b78e5fa8e8dc6e648e9185bb6eaebe73183c33ea0c445f3 \\, --hash=sha256:683e362b8ba453080f7489c66f4ea794e751c35b72e7eab3575ef784c2fbc7fb \\, --hash=sha256:68782fdb4027b8d1eee25ec35e9a6db05e863b899eb0310b3a33b6c3fef55707 \\, --hash=sha256:6efaf45df6a849cef613a03a94c845647456662f85438c886bb67a9c027c8c2c \\, --hash=sha256:71f42c5b9a948c113bbdebfa544598321431d064ff959d32e99b1feb61d68345 \\, --hash=sha256:72849d892954be4d09e569b8b831ac39ce58417fedc767d4308a0fe542018a40 \\, --hash=sha256:72c34ac7ad4314c19362d5ce27626dcc8429bd30bbf8c179f4234078851f9492 \\, --hash=sha256:734f6e5400352ac4254456003d462866c684703570929cff7a7bde015d0cb371 \\, --hash=sha256:75baa6cf9b6d1c52f3e111a130e202fd8cf0a5b3a066c3f73d615e885092e4ec \\, --hash=sha256:77716e245c90f058466a05e6a465bb8600f767a8f4b18b4d40f3aff958e5f73c \\, --hash=sha256:77e5099b99b37f3cf79c246998ca9f7313a78054cd1809ec46bc1afad47e1c4c \\, --hash=sha256:783dd1467083f4d3f7722ad6a313f24c173e7571372738fcb7a6e6d1ba48df25 \\, --hash=sha256:7a5c3115595995779ee21f2567035793911c3802a43c74f3fbb0314929ec67ac \\, --hash=sha256:7c88edaec8c349ad4c5ad4c486a3defcc4b80ceb2f074436ffa0a87caf5e76a6 \\, --hash=sha256:7cb414a73e21a7ab58254926073f2930cb22f5b4314ea4260a687e2b3fd4dce3 \\, --hash=sha256:7d42e7e3ca399555578b4d617e3a6ecf13371b3743a115995fa010c7bf341459 \\, --hash=sha256:7d575b54cb3863ef9bc290ea4b009999d55dc237326131e4853cf33e888fee03 \\, --hash=sha256:7e4de3ac4adbad3d0bc7c6f4360a7dbff5de2f15e3b723be3198074e17fd9c40 \\, --hash=sha256:7efc9f082dfed77c316edffa9deb52888e1bc6789171887cc1f68e06d65465c8 \\, --hash=sha256:80a063f8297fc796296f00f100be520f209b23dc98f93ce8eba6ee7122598209 \\, --hash=sha256:80e47012e730da131c9f059c80936783f9659aae22dc31c03c0595590d11ed54 \\, --hash=sha256:83d4a37e4b95da4d8bda930d6d35b75b4cdadbacbb4980cae290ea3100b5d51d \\, --hash=sha256:83e9f4a25085bd4b7214701a0794ff1f50fc633ffb8bdfebf07abdd81c2db126 \\, --hash=sha256:85a18376073f8a39aa07be34f9fc77e2869aa72c55c441efdd2cf79a0407504d \\, --hash=sha256:87796fedc3ba97ec14fab55acb48584276e6c1e4c1e89c422bda62c838e754a9 \\, --hash=sha256:882569ff613758cac762a457a5d72d6e211b28d4bcfea89d1d71ea942b02eac0 \\, --hash=sha256:8ce4d6ccafb33d39bd78444612d14938ead674c25702ded2ee9c54a47735d225 \\, --hash=sha256:8e7d98cdbb6d71e726f7d525952867096053d1f290dd4e3c50d7d313a136f414 \\, --hash=sha256:8ee202350cf57abf0e9502a41601841019c25d3db7ff52d980aaf31446254059 \\, --hash=sha256:8fb0eb4955adf0579001581f2f71a126e8781ba61bcd120f127b0401163c6c2d \\, --hash=sha256:90c30ed53546da833c700115c0064c22120d1b1560f474699fd31f22dd668233 \\, --hash=sha256:9489e6abf47ba37f332075a91444c7cfedb03e6ce99fbb2f116bfe1ce810da3b \\, --hash=sha256:94d7aa6debf92a1dd14cb5280b083a764169a13cfb23a452111160274ed989f4 \\, --hash=sha256:98d370568f393215d605304cdb77b3d5539bd192c75b623c7304c42c8d6d8273 \\, --hash=sha256:9b1bdaae98bc016825dd3c9d8ee1832f829b3341f9cc6ebd1a1b0a7fef7367cc \\, --hash=sha256:9d693bf4bf534e9ba3ae2780cfd577f5135629f7b5ac653490859d0b77864865 \\, --hash=sha256:9d6ed3d17bccce4c05343e1ca8da13bc5c02c812a4e7282ddd05e8769322d3fc \\, --hash=sha256:9e23c82b63cd7652fc24d33ed6cc17099d607aa3b4fc4ddc75e95062f3d82df4 \\, --hash=sha256:a1daf47cd95a7c3a63456336bc5aaa8c86dd3a47d07ed3d0e76132ae4666a5a1 \\, --hash=sha256:a1e32763e641a1566507d90a8d3b19bfc3cc04a9d4e5ae3e32189874ed4b58a3 \\, --hash=sha256:a2059a2d891bd156bc5184e7ab7a56e78a84dfcfdeac8c501b552533ad1c36ee \\, --hash=sha256:a2ed0ba415ccdf08f14bf544cb78346d0f76086707ffee24921a2c84dbf1305a \\, --hash=sha256:a3faadac7d812ddac258feb57b9846b60c1b437c4f4b9ad42595c6f6fe4390df \\, --hash=sha256:a5877f2255aab518ebe528289037699201d5dc5f045f2396cb30aa02db22f57f \\, --hash=sha256:a78b50b4f7918a3de71105d5c0b93bbc57bb8339a4d03a9dfd449f9068e76f3d \\, --hash=sha256:a8c2b841478068440d8b733005d13a5ef535b9928cbc05f17182d410f32ba449 \\, --hash=sha256:a9ca696eb02e5c02a8afd872ada510eba9b7fe6e68b9572c2e9a9b1941e31e2e \\, --hash=sha256:aa4ed3dd308548f9e707d9caaf005d2d7f8c1e7868f858dfeb47fe76e16b391d \\, --hash=sha256:ab2054c5531af2a9ba7b69b8ec91e4f884420e83a8c5e579b013084cb57e5e5d \\, --hash=sha256:abb1384477f5901d436b5d2e5465954de46ea6098f59163d243660b5c4461d35 \\, --hash=sha256:acae6b45d1ace09b6ba3876da43b88366ef368f73b988c7f57e14231753d4420 \\, --hash=sha256:acfa7e22aa6c6e7a5996a41d275bfa01efa7ea56ab890590280e9063e2cf5c1b \\, --hash=sha256:af4ea5b37403ef4e30f3927eaed540db942bde01d8d3ff083527c0704d1c9c68 \\, --hash=sha256:b10dd0557ba422715b5206b3743192135a6022acca8baec51aa127d0a75db8fe \\, --hash=sha256:b13b88747769537f3d32e89e3a735da10c0a9e35d7322928c701b5f93d3afffd \\, --hash=sha256:b51c159a9794633f5e0db7ecec7b2b6e3734eca1f5d17dc989ff3552a43ff78b \\, --hash=sha256:b5402a340723fa7da00b5cff987ddab61276be6d11251ea71ae02bcac54890d8 \\, --hash=sha256:b7abffdf37af1cec6a2ad69b827aa84320db5894791bc8ed932dc93fb274b7e9 \\, --hash=sha256:b8075fe90bc08e40b8b8a1874fab42ee4c7b56af05c5886e9cc841397f916908 \\, --hash=sha256:bc3ac7bf569f6b64dad04dd7808c7872dae8a97df657856eac05e9b7e3614a85 \\, --hash=sha256:bd0912757081f89b107d6c00b2ff8a194401b0b87eadcf4481de2b865a8fd44f \\, --hash=sha256:bdc8d8b8c22e9e43ac68316b5e6cf083dec537f4ec213cb4aa967b583bc3fa64 \\, --hash=sha256:be80550d9bfe83d9b62398a37081a90434e6df2d978ec345c3d2820de6beddab \\, --hash=sha256:c6f117789d22dce188e5754e8bc65b7e6ebf8cb73963b9fa761f672a5883769d \\, --hash=sha256:ca32926d7d77bcc8838425c4c95e040a3ace1cb7dfdae599013458dcda2607ca \\, --hash=sha256:cce0727fd5ac04d372fa9bbfde9febc2bcf209aadfcf0468e45dec72719895d1 \\, --hash=sha256:d0f1489233a254bb3643d2f05de7d59019254d81daeca6b9162fe9edef57e0c7 \\, --hash=sha256:d1c557dfd5e3db046053a0bdc72261ade790ebe8e2c7a41b36b0ca1f14cb95f3 \\, --hash=sha256:d21f0fa80a02d05299207eeaafef345d812ace96d5306e4ef265e1d419a615fa \\, --hash=sha256:d45673badd08456d0340e9364eddafe1c53a9d2896424294de4d7dd71ad3ee57 \\, --hash=sha256:d5add7b4ca7afeea91d52e4d4e4db3b1fe9885b71f07054560d8c4296b7441a2 \\, --hash=sha256:d5f90e44653c4e0f78501ed9bb7d3fce835a8d62b7c6ed0cb16557534087e743 \\, --hash=sha256:d7306dee25b8a0e737363f347362b875094b4dc4e367311470656ae420fdbf8e \\, --hash=sha256:dbcef5a9119ef653653132cccaf999b30a0af6f33bb0a4ba80bec30056868487 \\, --hash=sha256:def538065f9e4d4cf1ae164bd59aba00dfa84f03923e0de4c3788f252d6bcd17 \\, --hash=sha256:df23df54b5114a17c2d0ef192433e2e5a9f0c5178c32375e90b7cfc965f349d0 \\, --hash=sha256:dfbf531053a0935f2e871bcd4753f90313688772ff8c017f5ea402e315a78c1f \\, --hash=sha256:e029648f9c951db30e98a7d7ec90835db88ec4b32820efe2a9bdc2287e032eb6 \\, --hash=sha256:e07595c7d6f4db270ceede356a1bd1c07a34f1c26f958d1ed0cd7b48e0d2bba3 \\, --hash=sha256:e12c538e00e7c1b286a07061046b90e8124e6a9793efae2c70db6a4aad07faad \\, --hash=sha256:e546fe1d4a93ebc2910f0d768baff19faa09843ab3f2036a67ed6e69fae4419d \\, --hash=sha256:e5637ca8d0bd7fb72648a6c7934af4baaccb697657f7438c9d264fc2abb8b0b1 \\, --hash=sha256:e636b64d24fd9c38053c5e389a1174c66361fa49dcfd220f4dd35b4abde7cb89 \\, --hash=sha256:e7011b8fb8c4054bf0c12e5edc6cd83778b0028e99ce59b18586ed036f92cfdc \\, --hash=sha256:e80f557716fd765439577131e526b8942ffc2c07bdbc5e39fa62f660ba1e963f \\, --hash=sha256:e92b6bcc741b86d67606c40d3cb9c7cc8e6c737f81e31f4a94efc204456c92e3 \\, --hash=sha256:eb96ed1ae6c7d072d60840c0434aef07a2df611812810807fbc54263a6053e9a \\, --hash=sha256:eda19ea5ee88742f47a2340816e6f2d40b53bed3ab5b69794769f36af9f35bb4 \\, --hash=sha256:ef74070ac553c59eb4f04258722066d6c6135b7baa03b2e9f2da65c096e96d98 \\, --hash=sha256:efb01a106f971cb3752856bca2318bbdf7f01bd8823779c461586cbe5ffd5258 \\, --hash=sha256:f074e8d4aa0a5798920ddb6de3d08b228c614ff3724c3e8bd7577f4bafea867b \\, --hash=sha256:f38a70074041d3b7e138e452799f5174198bae5bd5ab2000917badf403908c5f \\, --hash=sha256:f41753a76f4f63927d03a0d8ba8f5ce0f2083bec29a8cfaccc55371b1564b96b \\, --hash=sha256:f53dcd26694f148f738edc052b5a69234833e739f10f4c3287bdfd8ec0f7b326 \\, --hash=sha256:f61964f235a43738bfac50da46fc4254943a7eea3051aeb0b6fc7c992c29fadc \\, --hash=sha256:fe01645169a2112aa1d4ebc3e4c5f029c5c8f97adfc32e5d37c993b39a994d75, # via aiohttp`.split(`,`)).join(`
145
+ `)+`
146
+ `,Jw=`BAILIAN_RL_RUNTIME`;function Yw(e,t){let n=ty(t),r=ny(n)?` ${ry}`:``;return new O(`Failed to download runtime artifact from ${e}${n?` (${n})`:``}.`,D.NETWORK,`Check network connectivity, or set BAILIAN_RL_PYTHON_MIRROR to a reachable mirror, then retry runtime prepare.${r}`,{cause:t})}const Xw={async download(e){let t=new AbortController,n=setTimeout(()=>t.abort(),12e4);try{let n=await Fn.fetch(e,{signal:t.signal});if(!n.ok)throw new O(`Failed to download runtime artifact (HTTP ${n.status}).`,D.NETWORK);return Buffer.from(await n.arrayBuffer())}catch(t){throw t instanceof O?t:Yw(e,t)}finally{clearTimeout(n)}},run(e,t,n){return new Promise((r,i)=>{let a=Qe(e,t,{cwd:n?.cwd,shell:!1,windowsHide:!0}),o=``,s=``;a.stdout?.on(`data`,e=>o+=e.toString(`utf8`)),a.stderr?.on(`data`,e=>s+=e.toString(`utf8`)),a.on(`error`,i),a.on(`close`,e=>r({exitCode:e,stdout:o,stderr:s}))})}};function Zw(e,t){if(t===`win32`)return T(e,`python`,`python.exe`);let n=Nw.split(`.`).slice(0,2).join(`.`);return T(e,`python`,`bin`,`python${n}`)}function Qw(e,t){return`${e.os}-${e.arch}-${e.pythonVersion}-${t.dashscopeVersion}`}function $w(e=process.platform,t=process.arch){let n=Vw(),r=Hw(n,e,t);if(r)return Qw(r,n)}function eT(e,t){return(t===`win32`?[T(e,`python.exe`),T(e,`Scripts`,`python.exe`)]:[T(e,`bin`,`python`),T(e,`python`)]).find(e=>S(e))}function tT(e){return new O(`RUNTIME_UNAVAILABLE: ${e}`,D.GENERAL,`Prepare the managed runtime first (runtime prepare), or set BAILIAN_RL_RUNTIME to a local dashscope ${jw} Python directory for development. No cloud resources were created.`)}function nT(e){if(e&&S(e))return Bw(ye(e,`utf8`))}async function rT(e={}){let t=e.env??process.env,n=e.platform??process.platform,r=e.arch??process.arch,i=t[Jw];if(i){let t=eT(i,n);if(!t)throw new O(`BAILIAN_RL_RUNTIME is set but no Python interpreter was found under "${i}".`,D.GENERAL,`Point BAILIAN_RL_RUNTIME at a directory containing a dashscope ${jw} Python interpreter.`);let r=e.deps??Xw,a=``;try{let e=await r.run(t,[`-I`,`-c`,`import importlib.metadata; print(importlib.metadata.version("dashscope"))`]);e.exitCode===0&&(a=e.stdout.trim())}catch{}if(!a)throw new O(`BAILIAN_RL_RUNTIME points at "${i}" but dashscope is not importable there.`,D.GENERAL,`Install dashscope==${jw} (the reviewed baseline) into that Python environment, then retry.`);return{runtimeRoot:i,pythonPath:t,dashscopeVersion:a,source:`override`}}let a=e.manifest??nT(e.manifestPath)??Vw(),o=Hw(a,n,r);if(!o)throw tT(`no validated runtime for ${n}/${r}.`);let s=VC(Qw(o,a)),c=Zw(s,n);if(S(T(s,`READY`))&&S(c))return{runtimeRoot:s,pythonPath:c,dashscopeVersion:a.dashscopeVersion,source:`managed`};if(!e.allowInstall)throw tT(`the managed runtime is not prepared yet.`);return await oT(o,a,s,e.deps??Xw,n,t),{runtimeRoot:s,pythonPath:c,dashscopeVersion:a.dashscopeVersion,source:`managed`}}function iT(e){C(e,{recursive:!0});let t=T(e,`.lock`),n;try{n=w(t,`wx`)}catch{throw new O(`Another runtime prepare is in progress for this runtime.`,D.GENERAL,`Wait for it to finish, or remove the stale .lock if no prepare is running.`)}return Oe(n,String(process.pid)),pe(n),()=>{try{De(t)}catch{}}}async function aT(e,t,n){let r;for(let i of e)try{let e=await n.download(i);return Kw(e,t),e}catch(e){r=e}throw r instanceof Error?r:new O(`Failed to download CPython from all candidate sources.`,D.NETWORK)}async function oT(e,t,n,r,i,a=process.env){let o=iT(n);try{let o=UC();C(o,{recursive:!0});let s=await aT(Gw(e.pythonUrl,a),e.pythonSha256,r),c=T(o,`${e.pythonSha256}.tar.gz`);Oe(c,s),C(n,{recursive:!0});let l=await r.run(`tar`,[`-xzf`,c,`-C`,n]);if(l.exitCode!==0)throw new O(`Failed to extract CPython ${e.pythonVersion}: ${l.stderr}`,D.GENERAL);let u=Zw(n,i);if(!S(u))throw new O(`CPython interpreter missing after extract: ${u}`,D.GENERAL,`Retry runtime prepare; the incomplete runtime was not marked READY.`);await r.run(u,[`-m`,`ensurepip`,`--upgrade`]);let d=T(n,`requirements.lock`);Oe(d,qw,`utf8`);let f=[`-m`,`pip`,`install`,`--require-hashes`,`--no-warn-script-location`],p=a[Fw];p&&f.push(`--index-url`,p),f.push(`-r`,d);let m=await r.run(u,f);if(m.exitCode!==0)throw new O(`pip failed to install locked dependencies: ${m.stderr}`,D.GENERAL);let h=await r.run(u,[`-I`,`--version`]),g=await r.run(u,[`-I`,`-c`,`import dashscope`]);if(h.exitCode!==0||g.exitCode!==0)throw new O(`Runtime self-check failed (python --version / import dashscope).`,D.GENERAL,`Retry runtime prepare; the incomplete runtime was not marked READY.`);Oe(T(n,`READY`),`${JSON.stringify({dashscopeVersion:t.dashscopeVersion,pythonVersion:e.pythonVersion},null,2)}\n`,`utf8`),Oe(T(n,`runtime.json`),`${JSON.stringify({pythonPath:u},null,2)}\n`,`utf8`)}finally{o()}}function sT(e){if(e.timedOut)throw new O(`The RL task timed out; its remote result is unknown. / RL 任务超时,远端结果未知。`,D.TIMEOUT,`Check the job status with finetune rl get; the cloud job was not canceled.`);let t,n=e.stdout.trim();if(n)try{t=JSON.parse(n)}catch{t=void 0}if(e.exitCode!==0){let r=t&&typeof t==`object`?t.message??t.error:void 0;throw new O(typeof r==`string`&&r||e.stderr.trim()||n||`dashscope exited with code ${e.exitCode}. / dashscope 以退出码 ${e.exitCode} 结束。`,D.GENERAL)}return t??{raw:n}}async function cT(e){let t=await rT({allowInstall:e.allowInstall,...e.runtimeOptions}),n=BC(),r=!1;if(e.prepare){let t=e.prepare(n);typeof t==`string`&&(Oe(n.configPath,t,`utf8`),r=!0)}let i=typeof e.sdkArgs==`function`?e.sdkArgs(n):e.sdkArgs,a=[t.pythonPath,`-I`,`-m`,`dashscope.cli`,...i,...r?[`--config`,n.configPath]:[]];return sT(await mw({layout:n,runtimeRoot:t.runtimeRoot,command:a,apiKey:e.credential.token,baseUrl:e.credential.baseUrl,credentialDenyPaths:e.credentialDenyPaths??[T(et(),`.dashscope`)],timeoutMs:e.timeoutMs??6e4,maxOutputBytes:e.maxOutputBytes??16777216,sdkEnv:{FC_PYPI_LIB:`dashscope==${t.dashscopeVersion}`},cwd:n.deployCopyDir,signal:e.signal},e.adapter??kw()))}const lT=[{host:`dashscope.aliyuncs.com`,port:443},{host:`github.com`,port:443},{host:`pypi.org`,port:443}];async function uT(e,t){return new Promise((n,r)=>{let i=se({host:`127.0.0.1`,port:e},()=>{i.write(`CONNECT ${t} HTTP/1.1\r\nHost: ${t}\r\n\r\n`)}),a=``;i.on(`data`,e=>{a+=e.toString(`utf8`),a.includes(`\r
147
+ \r
148
+ `)&&(i.destroy(),n(a.includes(`403`)))}),i.on(`error`,r),i.setTimeout(5e3,()=>{i.destroy(),n(!1)})})}async function dT(e={}){let t=e.platform??process.platform,n=e.adapter??kw(t),r=e.timeoutMs??3e4,i=[],a=await n.detect(),o=a.credentialDenyRead.available;i.push({name:`credential-isolation-mechanism`,required:!0,status:o?`pass`:`fail`,detail:o?a.credentialDenyRead.mechanism:a.credentialDenyRead.reason}),i.push({name:`network-kernel-enforce`,required:!1,status:a.hardening.networkEnforce?`pass`:`degraded`,detail:a.hardening.networkEnforce?void 0:`Falling back to the whitelist proxy.`}),i.push({name:`process-tree-limit`,required:!1,status:a.hardening.processTree?`pass`:`degraded`}),i.push({name:`memory-limit`,required:!1,status:a.hardening.memoryLimit?`pass`:`degraded`,detail:a.hardening.memoryLimit?void 0:`Not enforced in this release.`});let s=await lw();try{let e=await uT(s.port,`example.com:443`);i.push({name:`proxy-denies-unrelated-domain`,required:!0,status:e?`pass`:`fail`,detail:e?void 0:`Whitelist proxy did not reject example.com.`})}finally{await s.close()}if(e.checkHostNetwork){let t=e.hostNetworkTargets??lT,n=e.hostNetworkProbe??((e,t)=>iy(e,t,5e3)),r=(await Promise.all(t.map(async e=>({target:e,code:await n(e.host,e.port)})))).filter(e=>e.code!==void 0);i.push({name:`host-network-reachability`,required:!1,status:r.length===0?`pass`:`degraded`,detail:r.length===0?void 0:`${r.map(e=>`${e.target.host}:${e.target.port} (${e.code})`).join(`, `)}. Agent host sandboxes (e.g. Codex workspace-write) block outbound network by default: enable network access for the agent, or run runtime prepare / job submission in a regular terminal. HTTPS_PROXY is honored when set.`})}let c=e.runtime,l=o&&c!==void 0,u=e.credentialDenyPaths??[];if(!l){let e=c===void 0?`runtime not resolved`:`credential isolation unavailable`;for(let t of[`python-version`,`sdk-import`,`fc-pypi-lib-injected`,`home-redirect`,`credential-deny-negative`])i.push({name:t,required:!0,status:`skip`,detail:e});return fT(i)}let d=async(e,t=[],i)=>{let a=BC();return{result:await mw({layout:a,runtimeRoot:c.runtimeRoot,command:[c.pythonPath,`-I`,`-c`,e,...t],apiKey:`doctor-self-check`,credentialDenyPaths:u,timeoutMs:r,maxOutputBytes:1048576,sdkEnv:i},n),layout:a}};try{let e=await d(`import sys; print(sys.version.split()[0])`);i.push({name:`python-version`,required:!0,status:e.result.exitCode===0?`pass`:`fail`,detail:e.result.exitCode===0?e.result.stdout.trim():e.result.stderr.trim()});let t=await d(`import dashscope, importlib.metadata; print(importlib.metadata.version("dashscope"))`);i.push({name:`sdk-import`,required:!0,status:t.result.exitCode===0?`pass`:`fail`,detail:t.result.exitCode===0?t.result.stdout.trim():t.result.stderr.trim()});let n=`dashscope==${c.dashscopeVersion}`,r=await d(`import os; print(os.environ.get('FC_PYPI_LIB', ''))`,[],{FC_PYPI_LIB:n}),a=r.result.exitCode===0&&r.result.stdout.trim()===n;i.push({name:`fc-pypi-lib-injected`,required:!0,status:a?`pass`:`fail`,detail:a?n:`expected ${n}, got ${r.result.stdout.trim()||r.result.stderr.trim()}`});let o=await d(`import os; print(os.path.expanduser('~'))`),s=o.result.exitCode===0&&o.result.stdout.trim()===o.layout.homeDir;if(i.push({name:`home-redirect`,required:!0,status:s?`pass`:`fail`,detail:s?o.layout.homeDir:`expected ${o.layout.homeDir}, got ${o.result.stdout.trim()}`}),u.length===0)i.push({name:`credential-deny-negative`,required:!0,status:`skip`,detail:`no real credential path provided`});else{let e=await d(`import sys
149
+ try:
150
+ open(sys.argv[1]).close()
151
+ except OSError:
152
+ sys.exit(3)
153
+ sys.exit(0)
154
+ `,[u[0]]);i.push({name:`credential-deny-negative`,required:!0,status:e.result.exitCode===0?`fail`:`pass`,detail:e.result.exitCode===0?`real credential path was readable inside the sandbox`:`real credential path is blocked inside the sandbox`})}}catch(e){let t=e instanceof O?e.message:String(e);i.push({name:`sandbox-self-check`,required:!0,status:`fail`,detail:t})}return fT(i)}function fT(e){return{checks:e,ok:e.every(e=>!e.required||e.status===`pass`)}}function pT(e){if(!e.ok)throw new O(`Runtime doctor failed: ${e.checks.filter(e=>e.required&&e.status!==`pass`).map(e=>`${e.name}: ${e.status}${e.detail?` (${e.detail})`:``}`).join(`; `)}`,D.GENERAL,`Fix the required checks above before running RL tasks. No cloud resources were created.`)}function mT(e){return e?{"x-acs-req-uuid":e,"X-DashScope-RequestId":e}:void 0}async function hT(e,t,n){return e.requestJson({path:v_(),method:`POST`,body:t,signal:n})}async function gT(e,t={}){let n=new URLSearchParams;t.pageNo!==void 0&&n.set(`page_no`,String(t.pageNo)),t.pageSize!==void 0&&n.set(`page_size`,String(t.pageSize)),t.plan!==void 0&&n.set(`plan`,t.plan);let r=v_(),i=n.toString()?`${r}?${n.toString()}`:r;return e.requestJson({path:i,method:`GET`,signal:t.signal})}async function _T(e,t,n){return e.requestJson({path:y_(t),method:`GET`,signal:n})}async function vT(e,t,n={}){let r=new URLSearchParams;n.pageNo!==void 0&&r.set(`page_no`,String(n.pageNo)),n.pageSize!==void 0&&r.set(`page_size`,String(n.pageSize)),n.includeDeleted!==void 0&&r.set(`include_deleted`,String(n.includeDeleted)),n.statuses!==void 0&&r.set(`statuses`,n.statuses.join(`,`)),n.chargeTypes!==void 0&&r.set(`charge_types`,n.chargeTypes.join(`,`));let i=b_(t),a=r.toString()?`${i}?${r.toString()}`:i;return e.requestJson({path:a,method:`GET`,signal:n.signal})}async function yT(e,t,n,r){return e.requestJson({path:x_(t,n),method:`GET`,signal:r})}async function bT(e,t,n,r){return e.requestJson({path:T_(t,n),method:`GET`,signal:r})}async function xT(e,t,n,r={}){return e.requestJson({path:b_(t),method:`POST`,body:n,headers:mT(r.requestId),signal:r.signal})}async function ST(e,t,n,r,i={}){return e.requestJson({path:S_(t,n),method:`PUT`,body:r,headers:mT(i.requestId),signal:i.signal})}async function CT(e,t,n,r,i={}){return e.requestJson({path:C_(t,n),method:`PUT`,body:r,headers:mT(i.requestId),signal:i.signal})}async function wT(e,t,n,r={}){let i=x_(t,n),a=new URLSearchParams;return r.reason!==void 0&&a.set(`reason`,r.reason),e.requestJson({path:a.toString()?`${i}?${a.toString()}`:i,method:`DELETE`,headers:mT(r.requestId),signal:r.signal})}async function TT(e,t,n,r){return e.requestJson({path:w_(t),method:`PUT`,body:{overflow_strategy:n},signal:r})}async function ET(e,t,n){return e.requestJson({path:y_(t),method:`DELETE`,signal:n})}async function DT(e,t={}){let n=new URLSearchParams;t.pageNo!==void 0&&n.set(`page_no`,String(t.pageNo)),t.pageSize!==void 0&&n.set(`page_size`,String(t.pageSize)),t.version&&n.set(`version`,t.version),t.modelSource&&n.set(`model_source`,t.modelSource);let r=O_(),i=n.toString()?`${r}?${n.toString()}`:r;return e.requestJson({path:i,method:`GET`,signal:t.signal})}async function OT(e,t,n,r,i){return e.requestJson({path:E_(t),method:`PUT`,body:n,headers:mT(i),signal:r})}async function kT(e,t,n,r){return e.requestJson({path:D_(t),method:`PUT`,body:n,signal:r})}const AT={LORA:`lora`,PTU:`ptu`,MU:`mu`},jT=AT.LORA;function MT(e){return e===`audio`?AT.MU:jT}const NT={POST_PAY:`POST_PAY`,PRE_PAY:`PRE_PAY`},PT=NT.POST_PAY,FT={POST_PAID:`post_paid`,PRE_PAID:`pre_paid`};function IT(e,t){if(t||e.inputTpm!==void 0||e.outputTpm!==void 0){if(e.inputTpm===void 0||e.outputTpm===void 0)return`--input-tpm and --output-tpm must be provided together.
80
155
  必须同时提供 --input-tpm 和 --output-tpm。`;if(!Number.isSafeInteger(e.inputTpm)||e.inputTpm<0)return`--input-tpm must be a non-negative safe integer in kTPM.
81
156
  --input-tpm 必须是非负安全整数,单位为 kTPM。`;if(!Number.isSafeInteger(e.outputTpm)||e.outputTpm<0)return`--output-tpm must be a non-negative safe integer in kTPM.
82
- --output-tpm 必须是非负安全整数,单位为 kTPM。`}}function gC(e){let t={};return e.inputTpm!==void 0&&(t.input_tpm=e.inputTpm),e.outputTpm!==void 0&&(t.output_tpm=e.outputTpm),t}function _C(e){return e.duration!==void 0||e.autoRenewal!==void 0||e.autoRenewalDuration!==void 0||e.autoRenewalCycle!==void 0}function vC(e,t){if(t||_C(e)){if(e.duration===void 0||!Number.isSafeInteger(e.duration)||e.duration<=0)return`--duration must be a positive safe integer in days.
157
+ --output-tpm 必须是非负安全整数,单位为 kTPM。`}}function LT(e){let t={};return e.inputTpm!==void 0&&(t.input_tpm=e.inputTpm),e.outputTpm!==void 0&&(t.output_tpm=e.outputTpm),t}function RT(e){return e.duration!==void 0||e.autoRenewal!==void 0||e.autoRenewalDuration!==void 0||e.autoRenewalCycle!==void 0}function zT(e,t){if(t||RT(e)){if(e.duration===void 0||!Number.isSafeInteger(e.duration)||e.duration<=0)return`--duration must be a positive safe integer in days.
83
158
  --duration 必须是正安全整数,单位为天。`;if(typeof e.autoRenewal!=`boolean`)return`--auto-renewal must explicitly be true or false.
84
159
  必须显式指定 --auto-renewal 为 true 或 false。`;if((e.autoRenewal||e.autoRenewalDuration!==void 0)&&(e.autoRenewalDuration===void 0||!Number.isSafeInteger(e.autoRenewalDuration)||e.autoRenewalDuration<=0))return`--auto-renewal-duration must be a positive safe integer in days; required when --auto-renewal=true.
85
160
  --auto-renewal-duration 必须是正安全整数(天);开启自动续费时必填。`;if(e.autoRenewalCycle!==void 0&&(typeof e.autoRenewalCycle!=`string`||e.autoRenewalCycle.trim()===``))return`--auto-renewal-cycle must be a non-empty string.
86
- --auto-renewal-cycle 必须是非空字符串。`}}function yC(e){if(!_C(e))return;let t={};return e.duration!==void 0&&(t.duration=e.duration),e.autoRenewal!==void 0&&(t.auto_renewal=e.autoRenewal),e.autoRenewalDuration!==void 0&&(t.auto_renewal_duration=e.autoRenewalDuration),e.autoRenewalCycle!==void 0&&(t.auto_renewal_cycle=e.autoRenewalCycle),t}const bC={name:lC.LORA,validateFlags(){},async resolve(){return{body:{capacity:1}}}},xC={name:lC.PTU,validateFlags(e){return e.capacity!==void 0||e.deploySpec!==void 0||e.billingMethod!==void 0?`--capacity, --deploy-spec and --billing-method are not supported for plan=ptu; use reservation capacity and --charge-type.
87
- plan=ptu 不支持 --capacity、--deploy-spec 和 --billing-method;请使用预留容量参数和 --charge-type。`:e.thinkingOutputTpm===void 0?e.chargeType!==mC.PRE_PAID&&e.chargeType!==mC.POST_PAID?`--charge-type is required for plan=ptu and must be pre_paid or post_paid.
161
+ --auto-renewal-cycle 必须是非空字符串。`}}function BT(e){if(!RT(e))return;let t={};return e.duration!==void 0&&(t.duration=e.duration),e.autoRenewal!==void 0&&(t.auto_renewal=e.autoRenewal),e.autoRenewalDuration!==void 0&&(t.auto_renewal_duration=e.autoRenewalDuration),e.autoRenewalCycle!==void 0&&(t.auto_renewal_cycle=e.autoRenewalCycle),t}const VT={name:AT.LORA,validateFlags(){},async resolve(){return{body:{capacity:1}}}},HT={name:AT.PTU,validateFlags(e){return e.capacity!==void 0||e.deploySpec!==void 0||e.billingMethod!==void 0?`--capacity, --deploy-spec and --billing-method are not supported for plan=ptu; use reservation capacity and --charge-type.
162
+ plan=ptu 不支持 --capacity、--deploy-spec 和 --billing-method;请使用预留容量参数和 --charge-type。`:e.thinkingOutputTpm===void 0?e.chargeType!==FT.PRE_PAID&&e.chargeType!==FT.POST_PAID?`--charge-type is required for plan=ptu and must be pre_paid or post_paid.
88
163
  plan=ptu 必须提供 --charge-type,且只能为 pre_paid 或 post_paid。`:e.serviceTier!==void 0&&e.serviceTier!==`ptu_fast`&&e.serviceTier!==`ptu_default`?`--service-tier must be ptu_fast or ptu_default.
89
- --service-tier 只能为 ptu_fast 或 ptu_default。`:e.serviceTier===`ptu_default`&&e.chargeType===mC.POST_PAID?`ptu_default only supports pre_paid.
90
- ptu_default 仅支持 pre_paid。`:e.chargeType===mC.POST_PAID&&_C(e)?`Prepaid flags are not allowed with --charge-type post_paid.
91
- --charge-type post_paid 不允许提供预付费参数。`:hC(e,!0)??vC(e,e.chargeType===mC.PRE_PAID):`--thinking-output-tpm is not supported by current reservation models.
92
- 当前吞吐预留模型不支持 --thinking-output-tpm。`},async resolve(e){let t={charge_type:e.flags.chargeType,ptu_capacity:gC(e.flags)};e.flags.serviceTier!==void 0&&(t.service_tier=e.flags.serviceTier),e.flags.suffix!==void 0&&(t.suffix=e.flags.suffix);let n=yC(e.flags);return n!==void 0&&(t.pre_paid_info=n),{body:t}}},SC={name:lC.MU,validateFlags(){},async resolve(e){let t=e.flags.billingMethod||pC,n=e.flags.deploySpec,r=e.flags.capacity;if(!e.dryRun&&!n){let i=()=>new D(`No mu-plan template found for model "${e.model}". `+(e.modelUnavailableHint??`Pass --deploy-spec explicitly.`),E.USAGE);try{let a=await oC(e.client,{modelSource:`base`,pageSize:100,version:`v1.0`}),o=((a.output??a.data)?.models??[]).find(t=>t.model_name===e.model)?.plans?.find(({plan:e})=>e===lC.MU)?.templates??[];if(o.length===0)throw i();let s=t===fC.POST_PAY?mC.POST_PAID:mC.PRE_PAID,c=o.find(e=>e.charge_type===s)??o[0];if(!c?.deploy_spec&&!c?.template_id)throw i();n=c.deploy_spec??c.template_id,r===void 0&&(r=c.roles?.unified?.capacity_unit_per_instance??1)}catch(e){throw e instanceof D?e:new D(`Failed to auto-pick template for plan=mu: ${e.message}. Pass --deploy-spec explicitly.`,E.USAGE)}}let i={capacity:r??1,billing_method:t};return n&&(i.deploy_spec=n),{body:i}}},CC={[lC.LORA]:bC,[lC.PTU]:xC,[lC.MU]:SC};function wC(e){let t=CC[e];if(!t)throw new D(`Unsupported plan "${e}". Supported plans: ${Object.keys(CC).join(`, `)}.`,E.USAGE);return t}const TC=`zeldaEasy.broadscope-platform.modelInstance.startModelService`,EC=`zeldaEasy.broadscope-platform.modelInstance.stopModelService`,DC=`zeldaEasy.broadscope-platform.modelInstance.listIndependentDeployedModel`;async function OC(e,t){return Jv(await e.console(TC,{input:{modelServiceId:t}}))}async function kC(e,t){return Jv(await e.console(EC,{input:{modelServiceId:t}}))}async function AC(e){let t=[],n=1;for(;;){let r=Jv(await e.console(DC,{input:{pageNo:n,pageSize:50}})),i=r.records??[];t.push(...i);let a=r.pageCount??1;if(n>=a||i.length===0)break;n++}return t}function jC(e,t){return e.find(e=>e.modelServiceId===t||e.deployedModel===t||e.deployed_model===t)}const MC=`zeldaEasy.broadscope-platform.modelInstance.listIndependentDeployedModel.m_efm`;function NC(e={}){return{input:{page:e.page??1,itemsPerPage:e.pageSize??10,...e.keyword===void 0?{}:{searchNameKeyword:e.keyword},...e.modelServiceId===void 0?{}:{modelServiceId:e.modelServiceId}}}}function PC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function FC(e,t){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=t}function IC(e){return PC(e)&&Array.isArray(e.records)&&e.records.every(PC)&&FC(e.items,0)&&FC(e.itemsPerPage,1)&&FC(e.page,1)&&FC(e.pageCount,0)}async function LC(e,t={}){let n=Gv(await e.console(MC,NC(t)));if(!IC(n))throw new D(`Invalid Console deployment instances page: records must be an array of objects; items and pageCount must be non-negative safe integers; page and itemsPerPage must be positive safe integers. / Console 部署实例分页响应无效:records 必须为对象数组;items 和 pageCount 必须为非负安全整数;page 和 itemsPerPage 必须为正安全整数。`,E.GENERAL);return n}async function RC(e,t,n){return e.requestJson({path:Zg(),method:`POST`,body:t,signal:n})}async function zC(e,t={}){let n=new URLSearchParams;t.pageNo!==void 0&&n.set(`page_no`,String(t.pageNo)),t.pageSize!==void 0&&n.set(`page_size`,String(t.pageSize)),t.status&&n.set(`status`,t.status),t.modelName&&n.set(`model_name`,t.modelName);let r=Zg(),i=n.toString()?`${r}?${n.toString()}`:r;return e.requestJson({path:i,method:`GET`,signal:t.signal})}async function BC(e,t,n){return e.requestJson({path:Qg(t),method:`GET`,signal:n})}async function VC(e,t,n){return e.requestJson({path:Qg(t),method:`DELETE`,signal:n})}const HC=`zeldaEasy.broadscope-platform.customModel.listSupportImportModels`;async function UC(e){let t=Jv(await e.console(HC,{}));return{total:t.total,pageNo:t.pageNo,pageSize:t.pageSize,list:t.list??[]}}function WC(e,t){let n=t.trim().toLowerCase();return e.find(e=>String(e.model??``).toLowerCase()===n)}function GC(e){return e===`lora`?`efficient_sft`:`sft`}const KC=`speech-biasing`;function qC(e,t){return{model:KC,input:{action:e,...t}}}async function JC(e,t,n,r){return e.requestJson({path:Dg(),method:`POST`,body:qC(t,n),signal:r})}function YC(e,t,n){return JC(e,`create_vocabulary`,{target_model:t.targetModel,prefix:t.prefix,vocabulary:t.vocabulary},n)}function XC(e,t={},n){let r={};return t.prefix!==void 0&&(r.prefix=t.prefix),t.pageIndex!==void 0&&(r.page_index=t.pageIndex),t.pageSize!==void 0&&(r.page_size=t.pageSize),JC(e,`list_vocabulary`,r,n)}function ZC(e,t,n){return JC(e,`query_vocabulary`,{vocabulary_id:t},n)}function QC(e,t,n,r){return JC(e,`update_vocabulary`,{vocabulary_id:t,vocabulary:n},r)}function $C(e,t,n){return JC(e,`delete_vocabulary`,{vocabulary_id:t},n)}function ew(e,t){try{return JSON.parse(e)}catch(e){throw new ot(`${t} is not valid JSON — ${e.message}`)}}function tw(e){let t=ew(e,`--vocabulary`);if(!t||typeof t!=`object`||Array.isArray(t))throw new ot(`--vocabulary must decode to a JSON object of word→weight.`);for(let[e,n]of Object.entries(t))if(typeof n!=`number`||!Number.isFinite(n))throw new ot(`--vocabulary weight for "${e}" must be a number.`);return t}function nw(e,t){let n=`--words`,r=ew(e,n),i;if(Array.isArray(r))i=r.map((e,t)=>{if(!e||typeof e!=`object`||Array.isArray(e))throw new ot(`${n} entry #${t} must be an object with string "text" and number "weight".`);let r=e;if(typeof r.text!=`string`||typeof r.weight!=`number`)throw new ot(`${n} entry #${t} must have a string "text" and a number "weight".`);if(!Number.isFinite(r.weight))throw new ot(`${n} entry #${t} weight must be a finite number.`);return{text:r.text,weight:r.weight,...typeof r.lang==`string`?{lang:r.lang}:{}}});else if(!r||typeof r!=`object`)throw new ot(`${n} must decode to a JSON object or array.`);else{i=[];for(let[e,a]of Object.entries(r)){if(typeof a!=`number`||!Number.isFinite(a))throw new ot(`${n} weight for "${e}" must be a number.`);i.push({text:e,weight:a,...t?{lang:t}:{}})}}if(i.length===0)throw new ot(`${n} must contain at least one hot word.`);return i}const rw={introspect:{type:`switch`,description:{"en-US":`Print the machine-readable command schema (JSON) and exit`,"zh-CN":`输出机器可读的命令说明(JSON)并退出`}},output:{type:`string`,valueHint:`<text|json>`,choices:[`text`,`json`],description:{"en-US":`Output format: text, json`,"zh-CN":`输出格式:text、json`}},timeout:{type:`number`,valueHint:`<seconds>`,description:{"en-US":`Request timeout`,"zh-CN":`请求超时时间`}},quiet:{type:`switch`,description:{"en-US":`Suppress non-essential output`,"zh-CN":`隐藏非必要输出`}},verbose:{type:`switch`,description:{"en-US":`Print HTTP request/response details`,"zh-CN":`打印 HTTP 请求和响应详情`}},dryRun:{type:`switch`,description:{"en-US":`Dry run mode`,"zh-CN":`仅预览,不实际执行`}},config:{type:`string`,valueHint:`<name>`,description:{"en-US":`Use a config profile for this command`,"zh-CN":`为当前命令使用指定配置 Profile`}},help:{type:`switch`,description:{"en-US":`Show help`,"zh-CN":`显示帮助信息`}},version:{type:`switch`,description:{"en-US":`Print version`,"zh-CN":`显示版本信息`}}},iw={concurrent:{type:`number`,valueHint:`<n>`,description:{"en-US":`Run N parallel requests (default: 1)`,"zh-CN":`并行发送 N 个请求(默认:1)`}}},aw={async:{type:`switch`,description:{"en-US":`Return async task id without waiting`,"zh-CN":`直接返回异步任务 ID,不等待任务完成`}}},ow={apiKey:{type:`string`,valueHint:`<key>`,description:{"en-US":`API key`,"zh-CN":`API Key`}},baseUrl:{type:`string`,valueHint:`<url>`,description:{"en-US":`API base URL`,"zh-CN":`API Base URL`}}},sw={consoleRegion:{type:`string`,valueHint:`<region>`,description:{"en-US":`Console gateway region (e.g. cn-beijing, ap-southeast-1)`,"zh-CN":`控制台网关地域(例如 cn-beijing、ap-southeast-1)`}},consoleSite:{type:`string`,valueHint:`<site>`,description:{"en-US":`Console site: domestic, international`,"zh-CN":`控制台站点:domestic、international`}},consoleSwitchAgent:{type:`number`,valueHint:`<uid>`,description:{"en-US":`Switch agent UID for delegated access`,"zh-CN":`切换代理访问的 UID`}},workspaceId:{type:`string`,valueHint:`<id>`,description:{"en-US":`Workspace ID (env: BAILIAN_WORKSPACE_ID)`,"zh-CN":`Workspace ID(环境变量:BAILIAN_WORKSPACE_ID)`}}},cw={accessKeyId:{type:`string`,valueHint:`<key>`,description:{"en-US":`Alibaba Cloud Access Key ID (env: ALIBABA_CLOUD_ACCESS_KEY_ID)`,"zh-CN":`阿里云 Access Key ID(环境变量:ALIBABA_CLOUD_ACCESS_KEY_ID)`}},accessKeySecret:{type:`string`,valueHint:`<key>`,description:{"en-US":`Alibaba Cloud Access Key Secret (env: ALIBABA_CLOUD_ACCESS_KEY_SECRET)`,"zh-CN":`阿里云 Access Key Secret(环境变量:ALIBABA_CLOUD_ACCESS_KEY_SECRET)`}},securityToken:{type:`string`,valueHint:`<token>`,description:{"en-US":`Alibaba Cloud STS Security Token (env: ALIBABA_CLOUD_SECURITY_TOKEN)`,"zh-CN":`阿里云 STS Security Token(环境变量:ALIBABA_CLOUD_SECURITY_TOKEN)`}}};function lw(e){return e.auth===`apiKey`?e.optionalConsole?{...ow,...sw}:ow:e.auth===`console`?sw:e.auth===`openapi`?cw:{}}function uw(e){return e}const dw=1;function fw(e,t){return e.normalize(`NFKC`).replace(/[\\/:*?"<>|]/g,`_`).replace(/\s+/g,`_`).replace(/_+/g,`_`).replace(/^_+|_+$/g,``)||t}function pw(e,t){return`${fw(e||`image`,`image`)}_${fw((t||``).substring(0,20),`untitled`)}_${Date.now()}`}function mw(e=m()){let t=process.env.HERMES_HOME?.trim();if(t)return hw(t);if(process.platform===`win32`){let t=process.env.LOCALAPPDATA?.trim();return t?v(t,`hermes`):v(e,`AppData`,`Local`,`hermes`)}return v(e,`.hermes`)}function hw(e){return e===`~`?m():e.startsWith(`~/`)||e.startsWith(`~\\`)?v(m(),e.slice(2)):e}const gw=()=>v(m(),`bailian-output`);function _w(e,t){let n=t?.flagDir||e.outputDir||gw(),r=t?.subDir?v(n,t.subDir):n;return a(r)||o(r,{recursive:!0}),r}function vw(e){return e.length>8?`${e.slice(0,4)}...${e.slice(-4)}`:`***`}function yw(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function bw(e){return c(e===`-`?0:e,`utf-8`)}async function xw(e,t){let n=[],r=0;async function i(){for(;r<e.length;){let t=r++;n[t]=await e[t]()}}let a=Array.from({length:Math.min(t,e.length)},()=>i());return await Promise.all(a),n}function Sw(e,t=`boolean`){if(typeof e==`boolean`)return e;if(typeof e==`string`){let t=e.trim().toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}throw new D(`Invalid ${t} value "${String(e)}". Use true or false.`,E.USAGE)}function Cw(e,t=`boolean`){if(e!=null)return Sw(e,t)}function ww(e,t,n=`boolean`){let r=Cw(e,n);return r===void 0?t:r}function Tw(e,t){return Cw(e,`watermark`)??t??!0}const Ew=`BAILIAN_CALLER_NAME`,Dw=/^[a-z0-9][a-z0-9.-]{0,63}$/,Ow=/^bailian-[a-z0-9-]{1,64}$/,kw=/^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]{1,20})?$/;function Aw(e,t){let n=e[t];if(typeof n!=`string`)return;let r=n.trim();return r.length>0?r:void 0}function jw(e){if(!e)return`unknown`;let t=e.toLowerCase().replace(/[\s_]+/g,`-`);return Dw.test(t)?t:`unknown`}function Mw(e){let t=Aw(e,`BAILIAN_CALLER_TYPE`)?.toLowerCase();if(t===`agent`||t===`ai_agent`){let t=Aw(e,`BAILIAN_SKILL_NAME`)?.toLowerCase(),n=t!==void 0&&Ow.test(t)?t:void 0,r=Aw(e,`BAILIAN_SKILL_VERSION`),i=n!==void 0&&r!==void 0&&kw.test(r)?r:void 0;return{callerType:`agent`,callerName:jw(Aw(e,Ew)),...n===void 0?{}:{skillName:n},...i===void 0?{}:{skillVersion:i}}}return t===`script`?{callerType:`script`,callerName:jw(Aw(e,Ew))}:{callerType:`unknown`}}function Nw(e){let t={command:e.command,timestamp:(/* @__PURE__ */ new Date()).toISOString(),durationMs:e.durationMs,success:e.success,cliVersion:e.identity.version,commandPrefix:cy(e.identity),nodeVersion:process.version,os:process.platform,callerType:e.caller.callerType};return e.caller.callerType===`agent`?(t.callerName=e.caller.callerName,e.caller.skillName!==void 0&&(t.skillName=e.caller.skillName),e.caller.skillVersion!==void 0&&(t.skillVersion=e.caller.skillVersion)):e.caller.callerType===`script`&&(t.callerName=e.caller.callerName),e.authMethod&&(t.authMethod=e.authMethod),!e.success&&e.error&&(e.error.message&&(t.errorMessage=e.error.message),e.error.exitCode!==void 0&&(t.exitCode=e.error.exitCode),e.error.httpStatus!==void 0&&(t.httpStatus=e.error.httpStatus),e.error.requestId&&(t.requestId=e.error.requestId)),e.params&&Object.keys(e.params).length>0&&(t.params=e.params),t}function Pw(e){if(e==null)return;let t=typeof e==`string`?e:JSON.stringify(e);return t.length<=500?t:t.slice(0,500)}function Fw(e){let{command:t,params:n,...r}=e,i={et:`EXP`,ext:r,c1:n,c2:e.success?`success`:`failure`};return e.httpStatus!==void 0&&(i.c3=String(e.httpStatus)),e.errorMessage&&(i.c4=Pw(e.errorMessage)),e.requestId&&(i.c5=e.requestId),i}let Iw;function Lw(){return Iw||(process.env.BAILIAN_COMPILED===`1`?(Iw=`prod`,Iw):process.env.NODE_ENV===`development`?(Iw=`dev`,Iw):(Iw=import.meta.url.includes(`/node_modules/`)?`prod`:`dev`,Iw))}const Rw=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;function zw(){return v(Rt(),`telemetry-uid`)}function Bw(e){let t;try{t=c(e,`utf8`)}catch(e){return e.code===`ENOENT`?{kind:`missing`}:{kind:`unreadable`}}let n=t.trim().toLowerCase();return Rw.test(n)?{kind:`ok`,id:n}:{kind:`invalid`}}function Vw(){let e=Bw(zw());return e.kind===`ok`?e.id:void 0}function Hw(e,t){let r=`${e}.${oe(6).toString(`hex`)}.tmp`;try{let i=s(r,`wx`,384);try{p(i,`${t}\n`)}finally{n(i)}l(r,e)}finally{try{f(r)}catch{}}}function Uw(){let e=zw(),t=Bw(e);if(t.kind===`ok`)return t.id;if(t.kind!==`unreadable`)try{o(Rt(),{recursive:!0,mode:448});let t=se();return Hw(e,t),t}catch{return Vw()}}var Ww=/* @__PURE__ */ T(((e,t)=>{t.exports=(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t||4&t&&typeof e==`object`&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&typeof e!=`string`)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=8)})([function(e,t){e.exports=rt(`os`)},function(e,t){e.exports=(...e)=>(process.versions.bun?globalThis.fetch:rt(`undici`).fetch)(...e)},function(e,t,n){e.exports=n(6)},function(e,t){e.exports=rt(`dns`)},function(e,t){e.exports=rt(`util`)},function(e,t){e.exports=rt(`crypto`)},function(e,t,n){Object.defineProperty(t,Symbol.toStringTag,{value:`Module`});let r=n(7),i=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},a=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},o=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},s=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},c=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},l=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},u=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},d=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},f=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},p=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},m=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},h=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},g=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},_=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},v=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},y=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},ee=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},b=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},te=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},ne=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},re=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},ie=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},ae=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},oe=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},se=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},ce=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},le=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},ue=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},de=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},fe=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},pe=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},me=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},he=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},x=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},ge=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},_e=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},ve=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},ye=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},S=/* @__PURE__ */ new Map,C=/* @__PURE__ */ new Map;S.set(`Baiduspider-render`,i),S.set(`Baiduspider+`,i),S.set(`Baiduspider-image+`,i),S.set(`360Spider`,a),S.set(`360Spider-Image`,a),S.set(`bingbot`,o),S.set(`Googlebot`,s),S.set(`YandexRenderResourcesBot`,c),S.set(`spider`,l),S.set(`Dataprovider.com`,u),S.set(`AhrefsBot`,d),S.set(`BitSightBot`,f),S.set(`oBot`,p),S.set(`Cincraw`,m),S.set(`DingTalkBot-LinkService`,h),S.set(`YisouSpider`,g),S.set(`Bytespider`,_),S.set(`ev-crawler`,v),S.set(`bitdiscovery`,y),S.set(`Spider`,ee),S.set(`Ai2Bot-Dolma`,b),S.set(`dianjing_ad_spider`,te),C.set(`Baiduspider-render`,ne),C.set(`Baiduspider+`,ne),C.set(`Baiduspider-image+`,ne),C.set(`360Spider`,re),C.set(`360Spider-Image`,re),C.set(`bingbot`,ie),C.set(`Googlebot`,ae),C.set(`YandexRenderResourcesBot`,oe),C.set(`spider`,se),C.set(`Dataprovider.com`,ce),C.set(`AhrefsBot`,le),C.set(`BitSightBot`,ue),C.set(`oBot`,de),C.set(`Cincraw`,fe),C.set(`DingTalkBot-LinkService`,pe),C.set(`YisouSpider`,me),C.set(`Bytespider`,he),C.set(`ev-crawler`,x),C.set(`bitdiscovery`,ge),C.set(`Spider`,_e),C.set(`Ai2Bot-Dolma`,ve),C.set(`dianjing_ad_spider`,ye);let be={productHandlerMap:S,commentHandlerMap:C,getSpecialProductHandler:()=>null,getSpecialCommentHandler:()=>null,getDefaultModelHandler:()=>null};t.isBot=function(e){let t=r.createUAInfo();return r.runTask(e,t,be),t.deviceType===`bot`}},function(e,t){function n(e){let t=[],n={parent:e,tokens:t,get firstToken(){return t.length===0?null:t[0]},getNewToken(r){let i=(function(){let e=[],t=[],n=[],r=null,i=null,a=null,o=!0,s=!0,c=!0,l=null,u={get key(){return o&&=(r=e.join(``),!1),r},get value(){return s&&=(i=t.join(``),!1),i},get originValue(){return c&&=(a=n.join(``),!1),a},previousToken:null,properties:null,appendKey(t){e.push(t),o=!0},appendValue(e){t.push(e===`_`?`.`:e),n.push(e),s=!0,c=!0,l=null},getSplitValue(e){if(l===null){let e=u.value;l=e===``?[]:e.split(`/`)}return e>=0&&e<l.length?l[e]:null},getPreviousNTokens(e){let t=[],n=u;for(let r=0;r<e;r++){if(n==null)return null;t.unshift(n.key),n=n.previousToken}return t.join(` `)}};return u})();return t.push(i),i.previousToken=r===void 0?t.length>1?t[t.length-2]:null:r,e&&(e.properties=n),i},getLastToken:()=>t.length===0?null:t[t.length-1],getFirstToken:()=>t.length===0?null:t[0],isEmpty:()=>t.length===0};return n}function r(){return{appName:null,appVersion:null,browserName:null,browserVersion:null,engineName:null,engineVersion:null,deviceBrand:null,deviceModel:null,deviceType:`mobile`,osName:null,osVersion:null,platform:`web`,tokenGroup:n(null)}}let i=new Set(` ;,"'`.split(``)),a=new Set(`/=:`.split(``)),o=/* @__PURE__ */ new Set([`Mozilla`,`AppleWebKit`,`Safari`,`Opera`,`Dalvik`,`com.ss.android.ugc.aweme`]);function s(e){return e.length===1&&i.has(e)}function c(e){return e.length===1&&a.has(e)}function l(e,t,n,r){if(e==null)return;let i=t.parent,a=e.key,s=null;if(i!=null){let e=i.key;o.has(e)?(s=r.commentHandlerMap.get(a)??null,s??=r.getSpecialCommentHandler(a),s==null&&a.endsWith(` Build`)&&(s=r.getDefaultModelHandler())):s=r.productHandlerMap.get(a)??r.getSpecialProductHandler(a)}else s=r.productHandlerMap.get(a)??r.getSpecialProductHandler(a);if(s!=null)try{s(e,n)}catch{}}function u(e,t,r){if(e==null)throw Error(`input can not be null`);return(function e(t,r,i,a,o){let u,d=null,f=null,p=!1,m=t.length,h=r>0?t[r-1]:`\0`;for(u=r;u<m;u++){let g=t[u];if(s(g)){let e=h!==`\0`&&s(h);if(!p&&r>0&&g===` `&&!e){let e=u+1;if(e<m){let n=t[e];/\d/.test(n)||n===`-`?p=!0:f?.appendKey(g)}else f?.appendKey(g)}else f!=null&&(d=f,f=null);h=g}else if(g===`(`){if(h===`(`){h=g;continue}let r=u;u=e(t,u+1,n(i.getLastToken()),a,o),f!=null&&(d=f,f=null),h=t[r]}else{if(g===`)`){if(r===0){h=g;continue}break}f??(l(i.getLastToken(),i,a,o),f=i.getNewToken(d),p=!1),c(g)?(p&&f.appendValue(g),p=!0):p?f.appendValue(g):f.appendKey(g),h=g}}return l(i.getLastToken(),i,a,o),u})(e,0,t.tokenGroup,t,r),t}Object.defineProperty(t,"DEFAULT_MODEL_HANDLER_KEY",{enumerable:!0,get:function(){return`DEFAULT_MODEL_HANDLER`}}),Object.defineProperty(t,"createUAInfo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"runTask",{enumerable:!0,get:function(){return u}})},function(e,t,n){n.r(t);var r=n(0),i=n.n(r),a=n(1),o=n.n(a);n(2);function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:20,t=arguments.length>1?arguments[1]:void 0;return t||=``,e?s(--e,`0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz`.charAt(Math.floor(60*Math.random()))+t):t}function c(e,t){for(var n in t)e[n]=t[n];return e}function l(e){return Object.prototype.toString.call(e)===`[object Object]`}function u(e){return typeof Promise<`u`&&e instanceof Promise}var d=Object.freeze({__aesBeforeSkip:1}),f=function(e){var t=Object.prototype.toString.call(e);if(t===`[object String]`&&e||t===`[object Number]`||t===`[object Boolean]`)return e;if(t===`[object Object]`||t===`[object Array]`)try{return JSON.stringify(e)}catch{}},p=function(e){var t={};for(var n in e){var r=e[n];r!==void 0&&(t[n]=f(r))}return t},m=function(e){var t=[];for(var n in e){var r=f(e[n]);r!==void 0&&t.push(`${n}=${encodeURIComponent(r)}`)}return t.join(`&`)};function h(e){return(e.requiredFields||[]).concat([`pid`]).some(function(t){return e[t]===void 0})}function g(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:``,t=arguments.length>1?arguments[1]:void 0;typeof console<`u`&&console.warn(`日志解析报错,埋点将被丢弃 => ${e}`,t)}var _=`AEM_TRACKER_UNIQUE_PVID`,v=typeof globalThis<`u`&&globalThis?globalThis:typeof window<`u`&&window?window:typeof global<`u`&&global?global:typeof self<`u`&&self?self:(console.error(`Unable to locate global object in current environment`),{});function y(e){this._queue=[],this._reqQueue=[],this._plugins={},this._subscribers={onConfigUpdated:[]},this._timeout=0,this._config={sdk_version:`3.3.18`,set pv_id(e){v[_]=e},get pv_id(){return v[_]||(v[_]=s()),v[_]},timezone_offset:(/* @__PURE__ */ new Date()).getTimezoneOffset()},e&&(this._config=c(this._config,e))}y.prototype={constructor:y,_sendAll:function(){if(this._timeout&&=(clearTimeout(this._timeout),0),this._queue.length){var e,t=this._config.maxUrlLength||3e4,n=this._getSendConfig();try{e=this._processData(this._queue,n)}catch{}if(e&&e.length<t)return this._queue=[],void this.send(e);for(var r,i=[];this._queue.length;){i.push(this._queue.shift());try{r=this._processData(i,n)}catch(e){var a=i.pop();g(e.message,a);continue}if(r.length>t){i.length>1&&(this._queue.unshift(i.pop()),r=this._processData(i,n));break}}r&&this.send(r),this._queue.length&&this._sendAll()}},_send:function(e,t){var n=this;if(!1===t){var r;try{r=this._processData([e])}catch(t){g(t.message,e)}r&&this.send(r)}else{this._queue.push(e);var i=this._config.mergeRequestInterval||500;this._timeout||=setTimeout(function(){n._sendAll()},i)}},_getSendConfig:function(){var e={},t=this._config;for(var n in t)n!==`requiredFields`&&n!==`maxUrlLength`&&n!==`queueGlobalName`&&n!==`debug`&&n!==`excludeCrawlers`&&n!==`collectClientHints`&&n.indexOf(`plugin`)!==0&&t[n]!==``&&t[n]!==null&&t[n]!==void 0&&(e[n]=f(t[n]));return e},_processData:function(e,t){t||=this._getSendConfig();var n=m(t);return n+=`&msg=`+encodeURIComponent(e.map(function(e){return m(e)}).join(`|`))},setConfig:function(e,t){var n=this,r={};t===void 0?r=e:r[e]=t;var i=!(function e(t,n){if(t===void 0||n===void 0||!l(t)||!l(n))return!1;for(var r in t)if(l(t[r])){if(!e(t[r],n[r]))return!1}else if(t[r]!==n[r])return!1;return!0})(r,this._config),a=function(){if(i){for(var e in r)l(r[e])?n._config[e]=c(n._config[e]||{},r[e]):n._config[e]=r[e];n._execSubscribe(`onConfigUpdated`,[r,n._config])}};this._reqQueue.length?(a(),h(this._config)||(this._reqQueue.forEach(function(e){n._send.apply(n,e)}),this._reqQueue=[])):(i&&this._sendAll(),a())},getConfig:function(e){return e?this._config[e]:this._config},updatePVID:(function(e,t){if(typeof e!=`function`)throw TypeError(`Expected a function`);t=typeof t==`number`&&t>=0?t:100;var n=null;return function(){if(n===null){var r=this,i=Array.prototype.slice.call(arguments);n=setTimeout(function(){n=null},t),e.apply(r,i)}}})(function(){v[_]=s()},200),log:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};e&&(t.ts=t.ts||(/* @__PURE__ */ new Date()).getTime(),t.type=e,this._print(`log`,e,t),t=p(t),h(this._config)?this._reqQueue.length<1e3&&this._reqQueue.push([t,n.combo]):this._send(t,n.combo))},before:function(e,t){var n=this;return function(){var r=arguments,i=t.apply(n,r);i!==d&&(u(i)?i.then(function(t){t!==d&&e.apply(n,t||r)}):e.apply(n,i||r))}},after:function(e,t){var n=this;return function(){var r=arguments;e.apply(n,r),t.apply(n,r)}},use:function(e,t){var n=this;return Object.prototype.toString.call(e)===`[object Array]`?e.map(function(e){if(Object.prototype.toString.call(e)===`[object Array]`){var t=e[0],r=e[1];return n._plugins[t]||(n._plugins[t]=new t(n,r))}return n._plugins[e]||(n._plugins[e]=new e(n))}):this._plugins[e]||(this._plugins[e]=new e(this,t))},_print:function(){this._config.debug&&typeof console<`u`&&console.log.apply(console,arguments)},onConfigUpdated:function(e){this._subscribers.onConfigUpdated&&this._subscribers.onConfigUpdated.push(e)},_execSubscribe:function(e,t){this._subscribers[e]&&this._subscribers[e].forEach(function(e){e.apply(this,t)})}};var ee=y,b=n(5),te=n.n(b);function ne(e){return(ne=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e})(e)}function re(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ie(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?re(Object(n),!0).forEach(function(t){ae(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):re(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ae(e,t,n){return(t=(function(e){var t=(function(e,t){if(ne(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(ne(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)})(e,`string`);return ne(t)==`symbol`?t:t+``})(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oe(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=ce(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
93
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function se(e,t){return(function(e){if(Array.isArray(e))return e})(e)||(function(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}})(e,t)||ce(e,t)||(function(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
94
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)})()}function ce(e,t){if(e){if(typeof e==`string`)return le(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?le(e,t):void 0}}function le(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ue(){for(var e=/(?:[0]{1,2}[:-]){5}[0]{1,2}/,t=i.a.networkInterfaces(),n=0,r=Object.entries(t);n<r.length;n++){var a=se(r[n],2),o=(a[0],a[1]);if(o){var s,c=oe(o);try{for(c.s();!(s=c.n()).done;){var l=s.value;if(!1===e.test(l.mac))return l.mac}}catch(e){c.e(e)}finally{c.f()}}}return`00:00:00:00:00:00`}var de,fe,pe=(de=process.version,{os:i.a.type(),os_version:i.a.release(),app_name:`node`,app_version:de,device_id:te.a.createHash(`md5`).update(ue()).digest(`hex`),platform:`node`});function me(e){this._offlineQueue=[],e.endpoint=e.endpoint||`gm.mmstat.com`,ee.call(this,ie(ie({},pe),e)),this._config.endpoint_url=`https://${this._config.endpoint}/aes.1.1`}me.prototype=((fe=function(){}).prototype=ee.prototype,new fe),me.prototype.constructor=me,me.prototype.send=async function(e,t={}){let n=t.signal;if(n?.aborted)return;let r;if(!process.versions.bun){let{Agent:e,EnvHttpProxyAgent:t}=rt(`undici`),i={signal:n,timeout:1e3},a=process.env.HTTP_PROXY?.trim()||void 0,o=process.env.HTTPS_PROXY?.trim()||void 0;r=a||o?new t({httpProxy:a,httpsProxy:o,noProxy:process.env.NO_PROXY?.trim()||void 0,connect:i,requestTls:i,proxyTls:i}):new e({connect:i})}let i=[...this._offlineQueue.splice(0),e];try{await Promise.all(i.map(async e=>{if(!n?.aborted)try{this._print(`send`,e),await(await o()(this._config.endpoint_url,{method:`POST`,keepalive:!0,signal:n,...r?{dispatcher:r}:{},body:JSON.stringify({gokey:encodeURIComponent(e),gmkey:`EXP`})})).body?.cancel().catch(()=>{})}catch{n?.aborted||(this._offlineQueue.length>500&&this._offlineQueue.shift(),this._offlineQueue.push(e))}}))}finally{await r?.destroy().catch(()=>{})}},t.default=me}]).default})),Gw=/* @__PURE__ */ T(((e,t)=>{t.exports=(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t||4&t&&typeof e==`object`&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&typeof e!=`string`)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=0)})([function(e,t,n){n.r(t);var r=[`ec`,`ea`,`el`,`et`],i=function(e,t){var n=function(e){var n=e.ec,r=e.ea,i=e.el,a=e.et,o=a===void 0?`CLK`:a,s=e.xpath;delete e.ec,delete e.ea,delete e.el,delete e.et,delete e.xpath,e.p1=n,e.p2=r,e.p3=i,e.p4=o,e.p5=s;try{t.log(`event`,e)}catch{}};return function(){var t=arguments,i={};if(t.length!==0){for(var a=0;a<t.length;a++){var o,s,c=t[a];if(a!==0&&typeof c==`object`&&a!==t.length-1)return void(e==null||(o=e.console)==null||(s=o.warn)==null||s.call(o,`Only the last argument can be object type`));if(typeof c==`string`||typeof c==`number`)i[r[a]]=c;else if(typeof c==`object`&&a===t.length-1)for(var l in c)c.hasOwnProperty(l)&&(i[l]=c[l])}n(i)}else{var u,d;(u=e.console)==null||(d=u.warn)==null||d.call(u,`At lease one augument`)}}};t.default=function(e,t){return i(global,e)}}]).default})),Kw=/* @__PURE__ */ nt(Ww(),1),qw=/* @__PURE__ */ nt(Gw(),1);const Jw=()=>v(Rt(),`telemetry.jsonl`);let Yw;const Xw=/* @__PURE__ */ new Set;let Zw,Qw=!1;function $w(){if(!Qw){Qw=!0;try{let e=Uw(),t=new Kw.default({pid:`bailian-cli-node`,env:Lw(),...e?{uid:e}:{}}),n=t.send.bind(t);t.send=function(e){let t=new AbortController,r=setTimeout(()=>t.abort(),1e3);r.unref?.();let i={controller:t,promise:Promise.resolve().then(()=>n(e,{signal:t.signal})).catch(()=>{}).finally(()=>{t.abort(),clearTimeout(r),Xw.delete(i)})};return Xw.add(i),i.promise},Zw=t,Yw=t.use(qw.default)}catch{}}}async function eT(e=1e3){let t;try{if(Zw)try{typeof Zw._sendAll==`function`&&Zw._sendAll()}catch{}if(Xw.size===0)return;await Promise.race([Promise.allSettled([...Xw].map(e=>e.promise)),new Promise(n=>{t=setTimeout(()=>{for(let e of Xw)e.controller.abort();n()},e),t.unref?.()})])}catch{}finally{clearTimeout(t)}}async function tT(e){try{await Vt();let n=Jw();try{d(n).size>5242880&&f(n)}catch{}let r=Vw();t(n,JSON.stringify(r?{...e,uid:r}:e)+`
95
- `,{mode:384})}catch{}}async function nT(e){try{if($w(),!Yw)return;Yw(e.command,Fw(e))}catch{}}const rT=/* @__PURE__ */ new Set([`apiKey`,`baseUrl`,`output`,`quiet`,`verbose`,`timeout`,`dryRun`,`help`,`console`]),iT=/* @__PURE__ */ new Set(/* @__PURE__ */ `page.pageSize.n.count.model.voice.language.provider.capability.temperature.topP.topK.maxTokens.seed.stream.size.resolution.ratio.duration.format.audioFormat.sampleRate.pitch.rate.volume.api.mode.download.textOnly.promptExtend.enableSsml.watermark.hasThoughts.listTools.rerank.rerankTopN.diarization`.split(`.`));function aT(e){let t={};for(let[n,r]of Object.entries(e))n.startsWith(`_`)||rT.has(n)||iT.has(n)&&r!==void 0&&r!==!1&&(n!==`page`||typeof r==`number`&&Number.isFinite(r))&&(t[n]=r);return t}async function oT(e,t,n,r){if(!e.settings.telemetry){await r();return}let i=performance.now(),a=!0,o,s,c,l;try{await r()}catch(e){throw a=!1,e instanceof D?(o=e.message,s=e.exitCode,c=e.api?.httpStatus,l=e.api?.requestId):e instanceof Error&&(o=e.message),e}finally{let r=Math.round(performance.now()-i),u=Nw({command:t.join(` `),durationMs:r,success:a,error:a?void 0:{message:o,exitCode:s,httpStatus:c,requestId:l},identity:e.identity,authMethod:e.authMethod,params:aT(n),caller:e.caller});tT(u).catch(()=>{}),nT(u).catch(()=>{})}}const sT=/* @__PURE__ */ `代码生成.创意写作.客服对话.知识问答.文档理解.数据分析.数学推理.翻译.图像生成.图像编辑.视频生成.视频编辑.语音合成.语音识别.实时对话.Agent编排.深度研究.教育辅导.电商营销.角色扮演.3D生成.向量检索.数字人.音乐生成.人脸人像.虚拟试穿.OCR文字识别.情感分析.意图识别.图像修复.语义重排.播客.有声书`.split(`.`),cT=`You are an intent analyzer for an AI model recommendation system. Given the user's requirement, understand the scenario first, then extract structured information.
164
+ --service-tier 只能为 ptu_fast 或 ptu_default。`:e.serviceTier===`ptu_default`&&e.chargeType===FT.POST_PAID?`ptu_default only supports pre_paid.
165
+ ptu_default 仅支持 pre_paid。`:e.chargeType===FT.POST_PAID&&RT(e)?`Prepaid flags are not allowed with --charge-type post_paid.
166
+ --charge-type post_paid 不允许提供预付费参数。`:IT(e,!0)??zT(e,e.chargeType===FT.PRE_PAID):`--thinking-output-tpm is not supported by current reservation models.
167
+ 当前吞吐预留模型不支持 --thinking-output-tpm。`},async resolve(e){let t={charge_type:e.flags.chargeType,ptu_capacity:LT(e.flags)};e.flags.serviceTier!==void 0&&(t.service_tier=e.flags.serviceTier),e.flags.suffix!==void 0&&(t.suffix=e.flags.suffix);let n=BT(e.flags);return n!==void 0&&(t.pre_paid_info=n),{body:t}}},UT={name:AT.MU,validateFlags(){},async resolve(e){let t=e.flags.billingMethod||PT,n=e.flags.deploySpec,r=e.flags.capacity;if(!e.dryRun&&!n){let i=()=>new O(`No mu-plan template found for model "${e.model}". `+(e.modelUnavailableHint??`Pass --deploy-spec explicitly.`),D.USAGE);try{let a=await DT(e.client,{modelSource:`base`,pageSize:100,version:`v1.0`}),o=((a.output??a.data)?.models??[]).find(t=>t.model_name===e.model)?.plans?.find(({plan:e})=>e===AT.MU)?.templates??[];if(o.length===0)throw i();let s=t===NT.POST_PAY?FT.POST_PAID:FT.PRE_PAID,c=o.find(e=>e.charge_type===s)??o[0];if(!c?.deploy_spec&&!c?.template_id)throw i();n=c.deploy_spec??c.template_id,r===void 0&&(r=c.roles?.unified?.capacity_unit_per_instance??1)}catch(e){throw e instanceof O?e:new O(`Failed to auto-pick template for plan=mu: ${e.message}. Pass --deploy-spec explicitly.`,D.USAGE)}}let i={capacity:r??1,billing_method:t};return n&&(i.deploy_spec=n),{body:i}}},WT={[AT.LORA]:VT,[AT.PTU]:HT,[AT.MU]:UT};function GT(e){let t=WT[e];if(!t)throw new O(`Unsupported plan "${e}". Supported plans: ${Object.keys(WT).join(`, `)}.`,D.USAGE);return t}const KT=`zeldaEasy.broadscope-platform.modelInstance.startModelService`,qT=`zeldaEasy.broadscope-platform.modelInstance.stopModelService`,JT=`zeldaEasy.broadscope-platform.modelInstance.listIndependentDeployedModel`;async function YT(e,t){return fy(await e.console(KT,{input:{modelServiceId:t}}))}async function XT(e,t){return fy(await e.console(qT,{input:{modelServiceId:t}}))}async function ZT(e){let t=[],n=1;for(;;){let r=fy(await e.console(JT,{input:{pageNo:n,pageSize:50}})),i=r.records??[];t.push(...i);let a=r.pageCount??1;if(n>=a||i.length===0)break;n++}return t}function QT(e,t){return e.find(e=>e.modelServiceId===t||e.deployedModel===t||e.deployed_model===t)}const $T=`zeldaEasy.broadscope-platform.modelInstance.listIndependentDeployedModel.m_efm`;function eE(e={}){return{input:{page:e.page??1,itemsPerPage:e.pageSize??10,...e.keyword===void 0?{}:{searchNameKeyword:e.keyword},...e.modelServiceId===void 0?{}:{modelServiceId:e.modelServiceId}}}}function tE(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function nE(e,t){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=t}function rE(e){return tE(e)&&Array.isArray(e.records)&&e.records.every(tE)&&nE(e.items,0)&&nE(e.itemsPerPage,1)&&nE(e.page,1)&&nE(e.pageCount,0)}async function iE(e,t={}){let n=ly(await e.console($T,eE(t)));if(!rE(n))throw new O(`Invalid Console deployment instances page: records must be an array of objects; items and pageCount must be non-negative safe integers; page and itemsPerPage must be positive safe integers. / Console 部署实例分页响应无效:records 必须为对象数组;items 和 pageCount 必须为非负安全整数;page 和 itemsPerPage 必须为正安全整数。`,D.GENERAL);return n}async function aE(e,t,n){return e.requestJson({path:u_(),method:`POST`,body:t,signal:n})}async function oE(e,t={}){let n=new URLSearchParams;t.pageNo!==void 0&&n.set(`page_no`,String(t.pageNo)),t.pageSize!==void 0&&n.set(`page_size`,String(t.pageSize)),t.status&&n.set(`status`,t.status),t.modelName&&n.set(`model_name`,t.modelName);let r=u_(),i=n.toString()?`${r}?${n.toString()}`:r;return e.requestJson({path:i,method:`GET`,signal:t.signal})}async function sE(e,t,n){return e.requestJson({path:d_(t),method:`GET`,signal:n})}async function cE(e,t,n){return e.requestJson({path:d_(t),method:`DELETE`,signal:n})}const lE=`zeldaEasy.broadscope-platform.customModel.listSupportImportModels`;async function uE(e){let t=fy(await e.console(lE,{}));return{total:t.total,pageNo:t.pageNo,pageSize:t.pageSize,list:t.list??[]}}function dE(e,t){let n=t.trim().toLowerCase();return e.find(e=>String(e.model??``).toLowerCase()===n)}function fE(e){return e===`lora`?`efficient_sft`:`sft`}const pE=`speech-biasing`;function mE(e,t){return{model:pE,input:{action:e,...t}}}async function hE(e,t,n,r){return e.requestJson({path:Bg(),method:`POST`,body:mE(t,n),signal:r})}function gE(e,t,n){return hE(e,`create_vocabulary`,{target_model:t.targetModel,prefix:t.prefix,vocabulary:t.vocabulary},n)}function _E(e,t={},n){let r={};return t.prefix!==void 0&&(r.prefix=t.prefix),t.pageIndex!==void 0&&(r.page_index=t.pageIndex),t.pageSize!==void 0&&(r.page_size=t.pageSize),hE(e,`list_vocabulary`,r,n)}function vE(e,t,n){return hE(e,`query_vocabulary`,{vocabulary_id:t},n)}function yE(e,t,n,r){return hE(e,`update_vocabulary`,{vocabulary_id:t,vocabulary:n},r)}function bE(e,t,n){return hE(e,`delete_vocabulary`,{vocabulary_id:t},n)}function xE(e,t){try{return JSON.parse(e)}catch(e){throw new k(`${t} is not valid JSON — ${e.message}`)}}function SE(e){let t=xE(e,`--vocabulary`);if(!t||typeof t!=`object`||Array.isArray(t))throw new k(`--vocabulary must decode to a JSON object of word→weight.`);for(let[e,n]of Object.entries(t))if(typeof n!=`number`||!Number.isFinite(n))throw new k(`--vocabulary weight for "${e}" must be a number.`);return t}function CE(e,t){let n=`--words`,r=xE(e,n),i;if(Array.isArray(r))i=r.map((e,t)=>{if(!e||typeof e!=`object`||Array.isArray(e))throw new k(`${n} entry #${t} must be an object with string "text" and number "weight".`);let r=e;if(typeof r.text!=`string`||typeof r.weight!=`number`)throw new k(`${n} entry #${t} must have a string "text" and a number "weight".`);if(!Number.isFinite(r.weight))throw new k(`${n} entry #${t} weight must be a finite number.`);return{text:r.text,weight:r.weight,...typeof r.lang==`string`?{lang:r.lang}:{}}});else if(!r||typeof r!=`object`)throw new k(`${n} must decode to a JSON object or array.`);else{i=[];for(let[e,a]of Object.entries(r)){if(typeof a!=`number`||!Number.isFinite(a))throw new k(`${n} weight for "${e}" must be a number.`);i.push({text:e,weight:a,...t?{lang:t}:{}})}}if(i.length===0)throw new k(`${n} must contain at least one hot word.`);return i}const wE={introspect:{type:`switch`,description:{"en-US":`Print the machine-readable command schema (JSON) and exit`,"zh-CN":`输出机器可读的命令说明(JSON)并退出`}},output:{type:`string`,valueHint:`<text|json>`,choices:[`text`,`json`],description:{"en-US":`Output format: text, json`,"zh-CN":`输出格式:text、json`}},timeout:{type:`number`,valueHint:`<seconds>`,description:{"en-US":`Request timeout`,"zh-CN":`请求超时时间`}},quiet:{type:`switch`,description:{"en-US":`Suppress non-essential output`,"zh-CN":`隐藏非必要输出`}},verbose:{type:`switch`,description:{"en-US":`Print HTTP request/response details`,"zh-CN":`打印 HTTP 请求和响应详情`}},dryRun:{type:`switch`,description:{"en-US":`Dry run mode`,"zh-CN":`仅预览,不实际执行`}},config:{type:`string`,valueHint:`<name>`,description:{"en-US":`Use a config profile for this command`,"zh-CN":`为当前命令使用指定配置 Profile`}},help:{type:`switch`,description:{"en-US":`Show help`,"zh-CN":`显示帮助信息`}},version:{type:`switch`,description:{"en-US":`Print version`,"zh-CN":`显示版本信息`}}},TE={concurrent:{type:`number`,valueHint:`<n>`,description:{"en-US":`Run N parallel requests (default: 1)`,"zh-CN":`并行发送 N 个请求(默认:1)`}}},EE={async:{type:`switch`,description:{"en-US":`Return async task id without waiting`,"zh-CN":`直接返回异步任务 ID,不等待任务完成`}}},DE={apiKey:{type:`string`,valueHint:`<key>`,description:{"en-US":`API key`,"zh-CN":`API Key`}},baseUrl:{type:`string`,valueHint:`<url>`,description:{"en-US":`API base URL`,"zh-CN":`API Base URL`}}},OE={consoleRegion:{type:`string`,valueHint:`<region>`,description:{"en-US":`Console gateway region (e.g. cn-beijing, ap-southeast-1)`,"zh-CN":`控制台网关地域(例如 cn-beijing、ap-southeast-1)`}},consoleSite:{type:`string`,valueHint:`<site>`,description:{"en-US":`Console site: domestic, international`,"zh-CN":`控制台站点:domestic、international`}},consoleSwitchAgent:{type:`number`,valueHint:`<uid>`,description:{"en-US":`Switch agent UID for delegated access`,"zh-CN":`切换代理访问的 UID`}},workspaceId:{type:`string`,valueHint:`<id>`,description:{"en-US":`Workspace ID (env: BAILIAN_WORKSPACE_ID)`,"zh-CN":`Workspace ID(环境变量:BAILIAN_WORKSPACE_ID)`}}},kE={accessKeyId:{type:`string`,valueHint:`<key>`,description:{"en-US":`Alibaba Cloud Access Key ID (env: ALIBABA_CLOUD_ACCESS_KEY_ID)`,"zh-CN":`阿里云 Access Key ID(环境变量:ALIBABA_CLOUD_ACCESS_KEY_ID)`}},accessKeySecret:{type:`string`,valueHint:`<key>`,description:{"en-US":`Alibaba Cloud Access Key Secret (env: ALIBABA_CLOUD_ACCESS_KEY_SECRET)`,"zh-CN":`阿里云 Access Key Secret(环境变量:ALIBABA_CLOUD_ACCESS_KEY_SECRET)`}},securityToken:{type:`string`,valueHint:`<token>`,description:{"en-US":`Alibaba Cloud STS Security Token (env: ALIBABA_CLOUD_SECURITY_TOKEN)`,"zh-CN":`阿里云 STS Security Token(环境变量:ALIBABA_CLOUD_SECURITY_TOKEN)`}}};function AE(e){return e.auth===`apiKey`?e.optionalConsole?{...DE,...OE}:DE:e.auth===`console`?OE:e.auth===`openapi`?kE:{}}function jE(e){return e}const ME=1;function NE(e,t){return e.normalize(`NFKC`).replace(/[\\/:*?"<>|]/g,`_`).replace(/\s+/g,`_`).replace(/_+/g,`_`).replace(/^_+|_+$/g,``)||t}function PE(e,t){return`${NE(e||`image`,`image`)}_${NE((t||``).substring(0,20),`untitled`)}_${Date.now()}`}function FE(e=m()){let t=process.env.HERMES_HOME?.trim();if(t)return IE(t);if(process.platform===`win32`){let t=process.env.LOCALAPPDATA?.trim();return t?v(t,`hermes`):v(e,`AppData`,`Local`,`hermes`)}return v(e,`.hermes`)}function IE(e){return e===`~`?m():e.startsWith(`~/`)||e.startsWith(`~\\`)?v(m(),e.slice(2)):e}const LE=()=>v(m(),`bailian-output`);function RE(e,t){let n=t?.flagDir||e.outputDir||LE(),r=t?.subDir?v(n,t.subDir):n;return a(r)||o(r,{recursive:!0}),r}function zE(e){return e.length>8?`${e.slice(0,4)}...${e.slice(-4)}`:`***`}function BE(e){for(let t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function VE(e){return c(e===`-`?0:e,`utf-8`)}async function HE(e,t){let n=[],r=0;async function i(){for(;r<e.length;){let t=r++;n[t]=await e[t]()}}let a=Array.from({length:Math.min(t,e.length)},()=>i());return await Promise.all(a),n}function UE(e,t=`boolean`){if(typeof e==`boolean`)return e;if(typeof e==`string`){let t=e.trim().toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}throw new O(`Invalid ${t} value "${String(e)}". Use true or false.`,D.USAGE)}function WE(e,t=`boolean`){if(e!=null)return UE(e,t)}function GE(e,t,n=`boolean`){let r=WE(e,n);return r===void 0?t:r}function KE(e,t){return WE(e,`watermark`)??t??!0}const qE=`BAILIAN_CALLER_NAME`,JE=/^[a-z0-9][a-z0-9.-]{0,63}$/,YE=/^bailian-[a-z0-9-]{1,64}$/,XE=/^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]{1,20})?$/;function ZE(e,t){let n=e[t];if(typeof n!=`string`)return;let r=n.trim();return r.length>0?r:void 0}function QE(e){if(!e)return`unknown`;let t=e.toLowerCase().replace(/[\s_]+/g,`-`);return JE.test(t)?t:`unknown`}function $E(e){let t=ZE(e,`BAILIAN_CALLER_TYPE`)?.toLowerCase();if(t===`agent`||t===`ai_agent`){let t=ZE(e,`BAILIAN_SKILL_NAME`)?.toLowerCase(),n=t!==void 0&&YE.test(t)?t:void 0,r=ZE(e,`BAILIAN_SKILL_VERSION`),i=n!==void 0&&r!==void 0&&XE.test(r)?r:void 0;return{callerType:`agent`,callerName:QE(ZE(e,qE)),...n===void 0?{}:{skillName:n},...i===void 0?{}:{skillVersion:i}}}return t===`script`?{callerType:`script`,callerName:QE(ZE(e,qE))}:{callerType:`unknown`}}function eD(e){let t={command:e.command,timestamp:(/* @__PURE__ */ new Date()).toISOString(),durationMs:e.durationMs,success:e.success,cliVersion:e.identity.version,commandPrefix:Ey(e.identity),nodeVersion:process.version,os:process.platform,callerType:e.caller.callerType};return e.caller.callerType===`agent`?(t.callerName=e.caller.callerName,e.caller.skillName!==void 0&&(t.skillName=e.caller.skillName),e.caller.skillVersion!==void 0&&(t.skillVersion=e.caller.skillVersion)):e.caller.callerType===`script`&&(t.callerName=e.caller.callerName),e.authMethod&&(t.authMethod=e.authMethod),!e.success&&e.error&&(e.error.message&&(t.errorMessage=e.error.message),e.error.exitCode!==void 0&&(t.exitCode=e.error.exitCode),e.error.httpStatus!==void 0&&(t.httpStatus=e.error.httpStatus),e.error.requestId&&(t.requestId=e.error.requestId)),e.params&&Object.keys(e.params).length>0&&(t.params=e.params),t}function tD(e){if(e==null)return;let t=typeof e==`string`?e:JSON.stringify(e);return t.length<=500?t:t.slice(0,500)}function nD(e){let{command:t,params:n,...r}=e,i={et:`EXP`,ext:r,c1:n,c2:e.success?`success`:`failure`};return e.httpStatus!==void 0&&(i.c3=String(e.httpStatus)),e.errorMessage&&(i.c4=tD(e.errorMessage)),e.requestId&&(i.c5=e.requestId),i}let rD;function iD(){return rD||(process.env.BAILIAN_COMPILED===`1`?(rD=`prod`,rD):process.env.NODE_ENV===`development`?(rD=`dev`,rD):(rD=import.meta.url.includes(`/node_modules/`)?`prod`:`dev`,rD))}const aD=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;function oD(){return v(qt(),`telemetry-uid`)}function sD(e){let t;try{t=c(e,`utf8`)}catch(e){return e.code===`ENOENT`?{kind:`missing`}:{kind:`unreadable`}}let n=t.trim().toLowerCase();return aD.test(n)?{kind:`ok`,id:n}:{kind:`invalid`}}function cD(){let e=sD(oD());return e.kind===`ok`?e.id:void 0}function lD(e,t){let r=`${e}.${ae(6).toString(`hex`)}.tmp`;try{let i=s(r,`wx`,384);try{p(i,`${t}\n`)}finally{n(i)}l(r,e)}finally{try{f(r)}catch{}}}function uD(){let e=oD(),t=sD(e);if(t.kind===`ok`)return t.id;if(t.kind!==`unreadable`)try{o(qt(),{recursive:!0,mode:448});let t=oe();return lD(e,t),t}catch{return cD()}}var dD=/* @__PURE__ */ E(((e,t)=>{t.exports=(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t||4&t&&typeof e==`object`&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&typeof e!=`string`)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=8)})([function(e,t){e.exports=pt(`os`)},function(e,t){e.exports=(...e)=>(process.versions.bun?globalThis.fetch:pt(`undici`).fetch)(...e)},function(e,t,n){e.exports=n(6)},function(e,t){e.exports=pt(`dns`)},function(e,t){e.exports=pt(`util`)},function(e,t){e.exports=pt(`crypto`)},function(e,t,n){Object.defineProperty(t,Symbol.toStringTag,{value:`Module`});let r=n(7),i=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},a=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},o=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},s=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},c=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},l=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},u=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},d=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},f=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},p=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},m=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},h=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},g=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},_=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},v=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},y=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},b=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},x=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},ee=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},te=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},ne=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},re=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},ie=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},ae=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},oe=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},se=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},ce=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},le=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},ue=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},de=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},fe=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},pe=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},me=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},he=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},ge=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},_e=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},S=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},ve=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},C=/* @__PURE__ */ new Map,w=/* @__PURE__ */ new Map;C.set(`Baiduspider-render`,i),C.set(`Baiduspider+`,i),C.set(`Baiduspider-image+`,i),C.set(`360Spider`,a),C.set(`360Spider-Image`,a),C.set(`bingbot`,o),C.set(`Googlebot`,s),C.set(`YandexRenderResourcesBot`,c),C.set(`spider`,l),C.set(`Dataprovider.com`,u),C.set(`AhrefsBot`,d),C.set(`BitSightBot`,f),C.set(`oBot`,p),C.set(`Cincraw`,m),C.set(`DingTalkBot-LinkService`,h),C.set(`YisouSpider`,g),C.set(`Bytespider`,_),C.set(`ev-crawler`,v),C.set(`bitdiscovery`,y),C.set(`Spider`,b),C.set(`Ai2Bot-Dolma`,x),C.set(`dianjing_ad_spider`,ee),w.set(`Baiduspider-render`,te),w.set(`Baiduspider+`,te),w.set(`Baiduspider-image+`,te),w.set(`360Spider`,ne),w.set(`360Spider-Image`,ne),w.set(`bingbot`,re),w.set(`Googlebot`,ie),w.set(`YandexRenderResourcesBot`,ae),w.set(`spider`,oe),w.set(`Dataprovider.com`,se),w.set(`AhrefsBot`,ce),w.set(`BitSightBot`,le),w.set(`oBot`,ue),w.set(`Cincraw`,de),w.set(`DingTalkBot-LinkService`,fe),w.set(`YisouSpider`,pe),w.set(`Bytespider`,me),w.set(`ev-crawler`,he),w.set(`bitdiscovery`,ge),w.set(`Spider`,_e),w.set(`Ai2Bot-Dolma`,S),w.set(`dianjing_ad_spider`,ve);let ye={productHandlerMap:C,commentHandlerMap:w,getSpecialProductHandler:()=>null,getSpecialCommentHandler:()=>null,getDefaultModelHandler:()=>null};t.isBot=function(e){let t=r.createUAInfo();return r.runTask(e,t,ye),t.deviceType===`bot`}},function(e,t){function n(e){let t=[],n={parent:e,tokens:t,get firstToken(){return t.length===0?null:t[0]},getNewToken(r){let i=(function(){let e=[],t=[],n=[],r=null,i=null,a=null,o=!0,s=!0,c=!0,l=null,u={get key(){return o&&=(r=e.join(``),!1),r},get value(){return s&&=(i=t.join(``),!1),i},get originValue(){return c&&=(a=n.join(``),!1),a},previousToken:null,properties:null,appendKey(t){e.push(t),o=!0},appendValue(e){t.push(e===`_`?`.`:e),n.push(e),s=!0,c=!0,l=null},getSplitValue(e){if(l===null){let e=u.value;l=e===``?[]:e.split(`/`)}return e>=0&&e<l.length?l[e]:null},getPreviousNTokens(e){let t=[],n=u;for(let r=0;r<e;r++){if(n==null)return null;t.unshift(n.key),n=n.previousToken}return t.join(` `)}};return u})();return t.push(i),i.previousToken=r===void 0?t.length>1?t[t.length-2]:null:r,e&&(e.properties=n),i},getLastToken:()=>t.length===0?null:t[t.length-1],getFirstToken:()=>t.length===0?null:t[0],isEmpty:()=>t.length===0};return n}function r(){return{appName:null,appVersion:null,browserName:null,browserVersion:null,engineName:null,engineVersion:null,deviceBrand:null,deviceModel:null,deviceType:`mobile`,osName:null,osVersion:null,platform:`web`,tokenGroup:n(null)}}let i=new Set(` ;,"'`.split(``)),a=new Set(`/=:`.split(``)),o=/* @__PURE__ */ new Set([`Mozilla`,`AppleWebKit`,`Safari`,`Opera`,`Dalvik`,`com.ss.android.ugc.aweme`]);function s(e){return e.length===1&&i.has(e)}function c(e){return e.length===1&&a.has(e)}function l(e,t,n,r){if(e==null)return;let i=t.parent,a=e.key,s=null;if(i!=null){let e=i.key;o.has(e)?(s=r.commentHandlerMap.get(a)??null,s??=r.getSpecialCommentHandler(a),s==null&&a.endsWith(` Build`)&&(s=r.getDefaultModelHandler())):s=r.productHandlerMap.get(a)??r.getSpecialProductHandler(a)}else s=r.productHandlerMap.get(a)??r.getSpecialProductHandler(a);if(s!=null)try{s(e,n)}catch{}}function u(e,t,r){if(e==null)throw Error(`input can not be null`);return(function e(t,r,i,a,o){let u,d=null,f=null,p=!1,m=t.length,h=r>0?t[r-1]:`\0`;for(u=r;u<m;u++){let g=t[u];if(s(g)){let e=h!==`\0`&&s(h);if(!p&&r>0&&g===` `&&!e){let e=u+1;if(e<m){let n=t[e];/\d/.test(n)||n===`-`?p=!0:f?.appendKey(g)}else f?.appendKey(g)}else f!=null&&(d=f,f=null);h=g}else if(g===`(`){if(h===`(`){h=g;continue}let r=u;u=e(t,u+1,n(i.getLastToken()),a,o),f!=null&&(d=f,f=null),h=t[r]}else{if(g===`)`){if(r===0){h=g;continue}break}f??(l(i.getLastToken(),i,a,o),f=i.getNewToken(d),p=!1),c(g)?(p&&f.appendValue(g),p=!0):p?f.appendValue(g):f.appendKey(g),h=g}}return l(i.getLastToken(),i,a,o),u})(e,0,t.tokenGroup,t,r),t}Object.defineProperty(t,"DEFAULT_MODEL_HANDLER_KEY",{enumerable:!0,get:function(){return`DEFAULT_MODEL_HANDLER`}}),Object.defineProperty(t,"createUAInfo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(t,"runTask",{enumerable:!0,get:function(){return u}})},function(e,t,n){n.r(t);var r=n(0),i=n.n(r),a=n(1),o=n.n(a);n(2);function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:20,t=arguments.length>1?arguments[1]:void 0;return t||=``,e?s(--e,`0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz`.charAt(Math.floor(60*Math.random()))+t):t}function c(e,t){for(var n in t)e[n]=t[n];return e}function l(e){return Object.prototype.toString.call(e)===`[object Object]`}function u(e){return typeof Promise<`u`&&e instanceof Promise}var d=Object.freeze({__aesBeforeSkip:1}),f=function(e){var t=Object.prototype.toString.call(e);if(t===`[object String]`&&e||t===`[object Number]`||t===`[object Boolean]`)return e;if(t===`[object Object]`||t===`[object Array]`)try{return JSON.stringify(e)}catch{}},p=function(e){var t={};for(var n in e){var r=e[n];r!==void 0&&(t[n]=f(r))}return t},m=function(e){var t=[];for(var n in e){var r=f(e[n]);r!==void 0&&t.push(`${n}=${encodeURIComponent(r)}`)}return t.join(`&`)};function h(e){return(e.requiredFields||[]).concat([`pid`]).some(function(t){return e[t]===void 0})}function g(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:``,t=arguments.length>1?arguments[1]:void 0;typeof console<`u`&&console.warn(`日志解析报错,埋点将被丢弃 => ${e}`,t)}var _=`AEM_TRACKER_UNIQUE_PVID`,v=typeof globalThis<`u`&&globalThis?globalThis:typeof window<`u`&&window?window:typeof global<`u`&&global?global:typeof self<`u`&&self?self:(console.error(`Unable to locate global object in current environment`),{});function y(e){this._queue=[],this._reqQueue=[],this._plugins={},this._subscribers={onConfigUpdated:[]},this._timeout=0,this._config={sdk_version:`3.3.18`,set pv_id(e){v[_]=e},get pv_id(){return v[_]||(v[_]=s()),v[_]},timezone_offset:(/* @__PURE__ */ new Date()).getTimezoneOffset()},e&&(this._config=c(this._config,e))}y.prototype={constructor:y,_sendAll:function(){if(this._timeout&&=(clearTimeout(this._timeout),0),this._queue.length){var e,t=this._config.maxUrlLength||3e4,n=this._getSendConfig();try{e=this._processData(this._queue,n)}catch{}if(e&&e.length<t)return this._queue=[],void this.send(e);for(var r,i=[];this._queue.length;){i.push(this._queue.shift());try{r=this._processData(i,n)}catch(e){var a=i.pop();g(e.message,a);continue}if(r.length>t){i.length>1&&(this._queue.unshift(i.pop()),r=this._processData(i,n));break}}r&&this.send(r),this._queue.length&&this._sendAll()}},_send:function(e,t){var n=this;if(!1===t){var r;try{r=this._processData([e])}catch(t){g(t.message,e)}r&&this.send(r)}else{this._queue.push(e);var i=this._config.mergeRequestInterval||500;this._timeout||=setTimeout(function(){n._sendAll()},i)}},_getSendConfig:function(){var e={},t=this._config;for(var n in t)n!==`requiredFields`&&n!==`maxUrlLength`&&n!==`queueGlobalName`&&n!==`debug`&&n!==`excludeCrawlers`&&n!==`collectClientHints`&&n.indexOf(`plugin`)!==0&&t[n]!==``&&t[n]!==null&&t[n]!==void 0&&(e[n]=f(t[n]));return e},_processData:function(e,t){t||=this._getSendConfig();var n=m(t);return n+=`&msg=`+encodeURIComponent(e.map(function(e){return m(e)}).join(`|`))},setConfig:function(e,t){var n=this,r={};t===void 0?r=e:r[e]=t;var i=!(function e(t,n){if(t===void 0||n===void 0||!l(t)||!l(n))return!1;for(var r in t)if(l(t[r])){if(!e(t[r],n[r]))return!1}else if(t[r]!==n[r])return!1;return!0})(r,this._config),a=function(){if(i){for(var e in r)l(r[e])?n._config[e]=c(n._config[e]||{},r[e]):n._config[e]=r[e];n._execSubscribe(`onConfigUpdated`,[r,n._config])}};this._reqQueue.length?(a(),h(this._config)||(this._reqQueue.forEach(function(e){n._send.apply(n,e)}),this._reqQueue=[])):(i&&this._sendAll(),a())},getConfig:function(e){return e?this._config[e]:this._config},updatePVID:(function(e,t){if(typeof e!=`function`)throw TypeError(`Expected a function`);t=typeof t==`number`&&t>=0?t:100;var n=null;return function(){if(n===null){var r=this,i=Array.prototype.slice.call(arguments);n=setTimeout(function(){n=null},t),e.apply(r,i)}}})(function(){v[_]=s()},200),log:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};e&&(t.ts=t.ts||(/* @__PURE__ */ new Date()).getTime(),t.type=e,this._print(`log`,e,t),t=p(t),h(this._config)?this._reqQueue.length<1e3&&this._reqQueue.push([t,n.combo]):this._send(t,n.combo))},before:function(e,t){var n=this;return function(){var r=arguments,i=t.apply(n,r);i!==d&&(u(i)?i.then(function(t){t!==d&&e.apply(n,t||r)}):e.apply(n,i||r))}},after:function(e,t){var n=this;return function(){var r=arguments;e.apply(n,r),t.apply(n,r)}},use:function(e,t){var n=this;return Object.prototype.toString.call(e)===`[object Array]`?e.map(function(e){if(Object.prototype.toString.call(e)===`[object Array]`){var t=e[0],r=e[1];return n._plugins[t]||(n._plugins[t]=new t(n,r))}return n._plugins[e]||(n._plugins[e]=new e(n))}):this._plugins[e]||(this._plugins[e]=new e(this,t))},_print:function(){this._config.debug&&typeof console<`u`&&console.log.apply(console,arguments)},onConfigUpdated:function(e){this._subscribers.onConfigUpdated&&this._subscribers.onConfigUpdated.push(e)},_execSubscribe:function(e,t){this._subscribers[e]&&this._subscribers[e].forEach(function(e){e.apply(this,t)})}};var b=y,x=n(5),ee=n.n(x);function te(e){return(te=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e})(e)}function ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function re(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ne(Object(n),!0).forEach(function(t){ie(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ne(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ie(e,t,n){return(t=(function(e){var t=(function(e,t){if(te(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(te(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)})(e,`string`);return te(t)==`symbol`?t:t+``})(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ae(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=se(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
168
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function oe(e,t){return(function(e){if(Array.isArray(e))return e})(e)||(function(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}})(e,t)||se(e,t)||(function(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
169
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)})()}function se(e,t){if(e){if(typeof e==`string`)return ce(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ce(e,t):void 0}}function ce(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function le(){for(var e=/(?:[0]{1,2}[:-]){5}[0]{1,2}/,t=i.a.networkInterfaces(),n=0,r=Object.entries(t);n<r.length;n++){var a=oe(r[n],2),o=(a[0],a[1]);if(o){var s,c=ae(o);try{for(c.s();!(s=c.n()).done;){var l=s.value;if(!1===e.test(l.mac))return l.mac}}catch(e){c.e(e)}finally{c.f()}}}return`00:00:00:00:00:00`}var ue,de,fe=(ue=process.version,{os:i.a.type(),os_version:i.a.release(),app_name:`node`,app_version:ue,device_id:ee.a.createHash(`md5`).update(le()).digest(`hex`),platform:`node`});function pe(e){this._offlineQueue=[],e.endpoint=e.endpoint||`gm.mmstat.com`,b.call(this,re(re({},fe),e)),this._config.endpoint_url=`https://${this._config.endpoint}/aes.1.1`}pe.prototype=((de=function(){}).prototype=b.prototype,new de),pe.prototype.constructor=pe,pe.prototype.send=async function(e,t={}){let n=t.signal;if(n?.aborted)return;let r;if(!process.versions.bun){let{Agent:e,EnvHttpProxyAgent:t}=pt(`undici`),i={signal:n,timeout:1e3},a=process.env.HTTP_PROXY?.trim()||void 0,o=process.env.HTTPS_PROXY?.trim()||void 0;r=a||o?new t({httpProxy:a,httpsProxy:o,noProxy:process.env.NO_PROXY?.trim()||void 0,connect:i,requestTls:i,proxyTls:i}):new e({connect:i})}let i=[...this._offlineQueue.splice(0),e];try{await Promise.all(i.map(async e=>{if(!n?.aborted)try{this._print(`send`,e),await(await o()(this._config.endpoint_url,{method:`POST`,keepalive:!0,signal:n,...r?{dispatcher:r}:{},body:JSON.stringify({gokey:encodeURIComponent(e),gmkey:`EXP`})})).body?.cancel().catch(()=>{})}catch{n?.aborted||(this._offlineQueue.length>500&&this._offlineQueue.shift(),this._offlineQueue.push(e))}}))}finally{await r?.destroy().catch(()=>{})}},t.default=pe}]).default})),fD=/* @__PURE__ */ E(((e,t)=>{t.exports=(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t||4&t&&typeof e==`object`&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&typeof e!=`string`)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=0)})([function(e,t,n){n.r(t);var r=[`ec`,`ea`,`el`,`et`],i=function(e,t){var n=function(e){var n=e.ec,r=e.ea,i=e.el,a=e.et,o=a===void 0?`CLK`:a,s=e.xpath;delete e.ec,delete e.ea,delete e.el,delete e.et,delete e.xpath,e.p1=n,e.p2=r,e.p3=i,e.p4=o,e.p5=s;try{t.log(`event`,e)}catch{}};return function(){var t=arguments,i={};if(t.length!==0){for(var a=0;a<t.length;a++){var o,s,c=t[a];if(a!==0&&typeof c==`object`&&a!==t.length-1)return void(e==null||(o=e.console)==null||(s=o.warn)==null||s.call(o,`Only the last argument can be object type`));if(typeof c==`string`||typeof c==`number`)i[r[a]]=c;else if(typeof c==`object`&&a===t.length-1)for(var l in c)c.hasOwnProperty(l)&&(i[l]=c[l])}n(i)}else{var u,d;(u=e.console)==null||(d=u.warn)==null||d.call(u,`At lease one augument`)}}};t.default=function(e,t){return i(global,e)}}]).default})),pD=/* @__PURE__ */ ft(dD(),1),mD=/* @__PURE__ */ ft(fD(),1);const hD=()=>v(qt(),`telemetry.jsonl`);let gD;const _D=/* @__PURE__ */ new Set;let vD,yD=!1;function bD(){if(!yD){yD=!0;try{let e=uD(),t=new pD.default({pid:`bailian-cli-node`,env:iD(),...e?{uid:e}:{}}),n=t.send.bind(t);t.send=function(e){let t=new AbortController,r=setTimeout(()=>t.abort(),1e3);r.unref?.();let i={controller:t,promise:Promise.resolve().then(()=>n(e,{signal:t.signal})).catch(()=>{}).finally(()=>{t.abort(),clearTimeout(r),_D.delete(i)})};return _D.add(i),i.promise},vD=t,gD=t.use(mD.default)}catch{}}}async function xD(e=1e3){let t;try{if(vD)try{typeof vD._sendAll==`function`&&vD._sendAll()}catch{}if(_D.size===0)return;await Promise.race([Promise.allSettled([..._D].map(e=>e.promise)),new Promise(n=>{t=setTimeout(()=>{for(let e of _D)e.controller.abort();n()},e),t.unref?.()})])}catch{}finally{clearTimeout(t)}}async function SD(e){try{await Xt();let n=hD();try{d(n).size>5242880&&f(n)}catch{}let r=cD();t(n,JSON.stringify(r?{...e,uid:r}:e)+`
170
+ `,{mode:384})}catch{}}async function CD(e){try{if(bD(),!gD)return;gD(e.command,nD(e))}catch{}}const wD=/* @__PURE__ */ new Set([`apiKey`,`baseUrl`,`output`,`quiet`,`verbose`,`timeout`,`dryRun`,`help`,`console`]),TD=/* @__PURE__ */ new Set(/* @__PURE__ */ `page.pageSize.n.count.model.voice.language.provider.capability.temperature.topP.topK.maxTokens.seed.stream.size.resolution.ratio.duration.format.audioFormat.sampleRate.pitch.rate.volume.api.mode.download.textOnly.promptExtend.enableSsml.watermark.hasThoughts.listTools.rerank.rerankTopN.diarization`.split(`.`));function ED(e){let t={};for(let[n,r]of Object.entries(e))n.startsWith(`_`)||wD.has(n)||TD.has(n)&&r!==void 0&&r!==!1&&(n!==`page`||typeof r==`number`&&Number.isFinite(r))&&(t[n]=r);return t}async function DD(e,t,n,r){if(!e.settings.telemetry){await r();return}let i=performance.now(),a=!0,o,s,c,l;try{await r()}catch(e){throw a=!1,e instanceof O?(o=e.message,s=e.exitCode,c=e.api?.httpStatus,l=e.api?.requestId):e instanceof Error&&(o=e.message),e}finally{let r=Math.round(performance.now()-i),u=eD({command:t.join(` `),durationMs:r,success:a,error:a?void 0:{message:o,exitCode:s,httpStatus:c,requestId:l},identity:e.identity,authMethod:e.authMethod,params:ED(n),caller:e.caller});SD(u).catch(()=>{}),CD(u).catch(()=>{})}}const OD=/* @__PURE__ */ `代码生成.创意写作.客服对话.知识问答.文档理解.数据分析.数学推理.翻译.图像生成.图像编辑.视频生成.视频编辑.语音合成.语音识别.实时对话.Agent编排.深度研究.教育辅导.电商营销.角色扮演.3D生成.向量检索.数字人.音乐生成.人脸人像.虚拟试穿.OCR文字识别.情感分析.意图识别.图像修复.语义重排.播客.有声书`.split(`.`),kD=`You are an intent analyzer for an AI model recommendation system. Given the user's requirement, understand the scenario first, then extract structured information.
96
171
 
97
172
  CRITICAL: Respond with ONLY a valid JSON object. taskSummary must be in English; segments[].step is a short Simplified Chinese label (e.g. "剧本创作", "图生视频").
98
173
 
@@ -154,8 +229,8 @@ Pick ONLY the capabilities actually needed (at most 2 for a single task — choo
154
229
  - 3D-generation: 3D model generation
155
230
 
156
231
  ## Scene mapping
157
- Map the user's need to ONE OR MORE of these ${sT.length} scenes (use exact Chinese labels):
158
- ${sT.join(`, `)}
232
+ Map the user's need to ONE OR MORE of these ${OD.length} scenes (use exact Chinese labels):
233
+ ${OD.join(`, `)}
159
234
 
160
235
  - matchedScenes: array of matched scene labels (max 3, ordered by relevance); [] if none match
161
236
  - sceneConfidence: 0.0-1.0 (1.0 = exact match, 0.5 = inferred, 0.0 = no match)
@@ -199,24 +274,24 @@ Set optimizeDimension ONLY when the user explicitly writes a single-dimension su
199
274
  "optimizeDimension": null | "price" | "speed" | "context" | "quality" // null unless an explicit superlative appears
200
275
  }
201
276
 
202
- Output only JSON, no other text.`;var lT=class extends Error{kind;status;code;requestId;stage;constructor(e,t,n={}){super(t,n.cause===void 0?void 0:{cause:n.cause}),this.name=`LLMError`,this.kind=e,this.status=n.status,this.code=n.code,this.requestId=n.requestId,this.stage=n.stage}get fatal(){return this.kind===`rate_limit`||this.kind===`auth`||this.kind===`cancelled`}get tag(){return this.status?`${this.status} ${this.kind}`:this.kind}};function $(e){if(!e?.aborted)return;let t=e.reason;throw new lT(`cancelled`,t instanceof Error?t.message:`执行已取消`,{cause:t})}function uT(e){return e===429?`rate_limit`:e===401||e===403?`auth`:`http`}function dT(e,t,n){return{stage:e,fallback:t,kind:n.kind,status:n.status,message:n.message}}function fT(e){let t=e.status?`${e.status} ${e.kind}`:e.kind;return`${e.fallback} (${t})`}function pT(e,t){return e instanceof lT?(e.stage??=t,e):new lT(`parse`,e instanceof Error?e.message:String(e),{stage:t,cause:e})}const mT=[`unconstrained`,`scoped`,`comparison`,`alternative`],hT=/* @__PURE__ */ new Set([`Text`,`Image`,`Video`,`Audio`]),gT=new Set(sT),_T=/* @__PURE__ */ new Set([`price`,`speed`,`context`,`quality`]),vT=/* @__PURE__ */ new Set([`one`,`few`,`many`]);function yT(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function bT(e){return yT(e).filter(e=>hT.has(e))}function xT(e){if(!e||typeof e!=`object`)return;let t=e,n=typeof t.mode==`string`&&mT.includes(t.mode)?t.mode:`unconstrained`,r=yT(t.targets),i=yT(t.excludes);return{mode:n,targets:r.length>0?r:void 0,excludes:i.length>0?i:void 0}}async function ST(e,t,n){let r;try{r=await e.chatJson([{role:`system`,content:cT},{role:`user`,content:t}],{stage:`intent`,signal:n})}catch(e){throw pT(e,`intent`)}if(!r||typeof r!=`object`||Array.isArray(r))throw new lT(`parse`,`Intent response is not a JSON object`,{stage:`intent`});let i=yT(r.matchedScenes).filter(e=>gT.has(e)),a=typeof r.sceneConfidence==`number`&&r.sceneConfidence>=0&&r.sceneConfidence<=1?r.sceneConfidence:i.length>0?.5:0;return{complexity:r.complexity===`pipeline`?`pipeline`:`single`,segments:Array.isArray(r.segments)?r.segments.map(e=>({step:typeof e.step==`string`?e.step:``,scene:typeof e.scene==`string`&&gT.has(e.scene)?e.scene:void 0,inputModality:bT(e.inputModality),outputModality:bT(e.outputModality),requiredCapabilities:yT(e.requiredCapabilities)})):void 0,taskSummary:typeof r.taskSummary==`string`?r.taskSummary:``,scenarioHints:yT(r.scenarioHints),inputModality:bT(r.inputModality),outputModality:bT(r.outputModality),requiredCapabilities:yT(r.requiredCapabilities),requiredFeatures:yT(r.requiredFeatures),budget:r.budget===`low`||r.budget===`high`?r.budget:`medium`,contextNeed:r.contextNeed===`large`||r.contextNeed===`extra-large`?r.contextNeed:`standard`,qualityPreference:r.qualityPreference===`cost-optimized`||r.qualityPreference===`balanced`?r.qualityPreference:`flagship`,confidence:1,modelPreference:xT(r.modelPreference),matchedScenes:i,sceneConfidence:a,cardinalityHint:typeof r.cardinalityHint==`string`&&vT.has(r.cardinalityHint)?r.cardinalityHint:void 0,optimizeDimension:typeof r.optimizeDimension==`string`&&_T.has(r.optimizeDimension)?r.optimizeDimension:void 0}}function CT(e){return!e.offlineInfo}function wT(e,t,n,r){let i=e.inferenceMetadata?.request_modality??[],a=e.inferenceMetadata?.response_modality??[];return!(t.length>0&&i.length>0&&!t.some(e=>i.includes(e))||n.length>0&&a.length>0&&!n.some(e=>a.includes(e))||r.length>0&&!r.some(t=>e.capabilities.includes(t)))}function TT(e,t){return wT(e,t.inputModality,t.outputModality,t.requiredCapabilities)}function ET(e,t){let n=[...t.matchedScenes,...t.scenarioHints].filter(Boolean);return n.length===0?e:e.filter(e=>{let t=e.profile?.notSuitableFor;return!t?.length||!t.some(e=>n.some(t=>e.includes(t)))})}function DT(e,t,n=5){let r=e.filter(e=>TT(e,t));if(r.length>=n)return r;if(t.requiredCapabilities.length>0){let n=e.filter(e=>t.requiredCapabilities.some(t=>e.capabilities.includes(t)));if(n.length>0)return n}return e}const OT=/* @__PURE__ */ new Set([`TG`,`Reasoning`,`VU`,`IG`,`VG`,`TTS`,`ASR`,`Realtime-ASR`,`Realtime-Text-to-Speech`,`Realtime-Audio-Translate`,`Realtime-Chatting`,`Realtime-Omni`,`Multimodal-Omni`,`ME`,`TR`,`3D-generation`]),kT=/* @__PURE__ */ new Set([`Reasoning`]),AT={TG:[`代码生成`,`创意写作`,`客服对话`,`知识问答`,`文档理解`,`数据分析`,`数学推理`,`翻译`,`Agent编排`,`深度研究`,`教育辅导`,`电商营销`,`角色扮演`,`情感分析`,`意图识别`],VU:[`文档理解`,`OCR文字识别`,`数据分析`],IG:[`图像生成`,`图像编辑`,`图像修复`,`人脸人像`,`虚拟试穿`,`电商营销`],VG:[`视频生成`,`视频编辑`,`数字人`],TTS:[`语音合成`,`有声书`,`播客`,`数字人`],ASR:[`语音识别`],"Realtime-ASR":[`语音识别`,`实时对话`],TR:[`向量检索`,`语义重排`,`知识问答`],ME:[`向量检索`],"3D-generation":[`3D生成`]},jT={IG:`图像生成`,VG:`视频生成`,TTS:`语音合成`,ASR:`语音识别`},MT=[[/重排|rerank/i,`语义重排`],[/向量|嵌入|embedding|索引/i,`向量检索`],[/翻译|translat/i,`翻译`],[/代码|编程|code/i,`代码生成`],[/剧本|脚本|文案|歌词|故事|小说|创作|写作|script|lyric/i,`创意写作`],[/纪要|摘要|总结|整理|summar/i,`文档理解`],[/问答|回答|答案|answer/i,`知识问答`],[/转写|识别|听写|transcri/i,`语音识别`],[/配音|旁白|朗读|语音合成|voice/i,`语音合成`],[/数字人|口型|lip/i,`数字人`]],NT=/剪辑|合成剪辑|合轨|混音|拼接|加字幕|字幕合成|后期|导出|assembl|edit(ing)? together|mux/i;function PT(e,t){let n=t[0];if(n===`Image`)return`IG`;if(n===`Video`)return`VG`;if(n===`Audio`)return e.includes(`Audio`)&&!e.includes(`Text`)?void 0:`TTS`;if(n===`Text`)return e.includes(`Audio`)?`ASR`:e.includes(`Image`)||e.includes(`Video`)?`VU`:`TG`}function FT(e){return{TG:`文本生成`,VU:`视觉理解`,IG:`图像生成`,VG:`视频生成`,TTS:`语音合成`,ASR:`语音识别`,TR:`文本检索`,ME:`多模态检索`,"3D-generation":`3D 生成`}[e]??e}function IT(e){let t=[];for(let n of e??[]){let e=n.requiredCapabilities.filter(e=>OT.has(e)),r=e.filter(e=>!kT.has(e)),i=n.step?.trim()??``;if(r.length===0&&NT.test(i))continue;let a=r[0]??PT(n.inputModality,n.outputModality);if(!a)continue;let o=[a,...e.filter(e=>e!==a)],s=i||FT(a);if(t.push({index:t.length+1,label:s,inputModality:n.inputModality,outputModality:n.outputModality,primaryCapability:a,capabilities:o,scene:LT(n.scene,s,a)}),t.length>=5)break}return t.length>=2?t:[]}function LT(e,t,n){let r=e=>(AT[n]??[]).includes(e);if(e&&r(e))return e;for(let[e,n]of MT)if(e.test(t)&&r(n))return n;return jT[n]}function RT(e,t){if(e.scene)return[e.scene];let n=new Set(AT[e.primaryCapability]??[]);return t.matchedScenes.filter(e=>n.has(e))}function zT(e,t){return{...t,complexity:`single`,segments:void 0,inputModality:e.inputModality,outputModality:e.outputModality,requiredCapabilities:[e.primaryCapability],requiredFeatures:e.primaryCapability===`TG`?t.requiredFeatures:[],matchedScenes:RT(e,t)}}const BT=/* @__PURE__ */ new Set([`IG`,`VG`,`TTS`,`Realtime-Text-to-Speech`,`3D-generation`]),VT=/* @__PURE__ */ new Set([`TG`,`Reasoning`,`ASR`,`Realtime-ASR`,`TR`,`ME`]);function HT(e){let t=!1,n=!1;for(let r of e)BT.has(r)&&(t=!0),VT.has(r)&&(n=!0);return t&&n}function UT(e){let t=e.modelPreference?.mode;if(t!==`comparison`&&t!==`alternative`){if(e.outputModality.length>0&&e.inputModality.length===0){let t=e.outputModality[0];if(t===`Video`&&e.matchedScenes.length===0)return{question:`你打算从什么素材出发生成视频?`,options:[`纯文字描述(文生视频)`,`已有图片(图生视频)`,`已有视频(视频编辑)`],defaultIfSkip:`纯文字描述(文生视频)`,impact:`text-to-video and image-to-video use completely different models`};if(t===`Audio`&&e.matchedScenes.length===0)return{question:`你需要的是哪类语音能力?`,options:[`文字转语音(TTS)`,`语音转文字(ASR)`,`实时语音对话`],defaultIfSkip:`文字转语音(TTS)`,impact:`TTS and ASR are completely different models`}}if(e.complexity!==`pipeline`&&e.requiredCapabilities.length>=3&&HT(e.requiredCapabilities))return{question:`你的核心需求是哪一类?`,options:e.requiredCapabilities.slice(0,4),defaultIfSkip:e.requiredCapabilities[0],impact:`different capabilities map to completely different model pools`}}}function WT(e,t){let n=e.modelPreference?.mode;if(n===`comparison`||n===`alternative`||n===`scoped`||e.matchedScenes.length>0&&e.sceneConfidence>=.5||e.complexity===`pipeline`)return;let r=t.filter(t=>TT(t,e));if(e.matchedScenes.length===0&&e.sceneConfidence<.5){let e=/* @__PURE__ */ new Map;for(let t of r)for(let n of t.profile?.scenes??[])e.set(n,(e.get(n)??0)+1);let t=[...e.entries()].sort((e,t)=>t[1]-e[1]).slice(0,3).map(([e])=>e);return t.length===0?void 0:{question:`你想用在什么场景?`,options:t,defaultIfSkip:t[0],impact:`不同场景对应完全不同的模型池`}}if(r.length<=20)return;let i=/* @__PURE__ */ new Map;for(let e of r)for(let t of e.profile?.scenes??[])i.set(t,(i.get(t)??0)+1);let a=[...i.entries()].sort((e,t)=>t[1]-e[1]);if(a.length===0||a[0][1]/r.length>=.5)return;let o=a.slice(0,3).map(([e])=>e);return{question:`你的需求更接近哪个场景?`,options:o,defaultIfSkip:o[0],impact:`different scenes produce completely different recommendations`}}function GT(e){let t=e.modelPreference;return!t||t.mode===`unconstrained`?`none`:t.mode===`comparison`?`existing`:t.mode===`alternative`?`reference`:`scope`}function KT(e){return e.modelPreference?.mode===`comparison`?(e.modelPreference?.targets?.length??0)<=1?`evaluate`:`differentiate`:e.optimizeDimension?`optimize`:`match`}function qT(e){return e.cardinalityHint??`few`}function JT(e,t,n){return t===`differentiate`?`compare`:t===`evaluate`?`validate`:n===`many`?`catalog`:`recommend`}function YT(e){return e.matchedScenes.length===0&&e.sceneConfidence<.5&&e.confidence>0}const XT=[{name:`forced-compare`,match:e=>e.anchor===`existing`,plan:{recall:`forced`,score:`none`,rank:`forced-order`,explain:`llm-compare`,fairness:!1,topN:3}},{name:`forced-alternative`,match:e=>e.anchor===`reference`,plan:{recall:`forced`,score:`formula`,rank:`score-sort`,explain:`llm-compare`,fairness:!1,topN:3}},{name:`pipeline-steps`,match:e=>e.pipeline&&e.steps>=2,plan:{recall:`structured`,score:`formula`,rank:`score-sort`,explain:`llm-generate`,fairness:!1,topN:2,stepwise:!0}},{name:`template-fast`,match:e=>e.sceneHit&&e.userIntent===`match`&&!e.pipeline,plan:{recall:`template`,score:`none`,rank:`template-order`,explain:`template-text`,fairness:!0,topN:3}},{name:`holistic-complex`,match:e=>e.pipeline||e.fuzzy,plan:{recall:`holistic-pool`,score:`holistic`,rank:`score-sort`,explain:`llm-generate`,fairness:!0,topN:3}},{name:`catalog-browse`,match:e=>e.cardinality===`many`,plan:{recall:`structured`,score:`formula`,rank:`score-sort`,explain:`catalog`,fairness:!0,topN:10}},{name:`optimize-single`,match:e=>e.userIntent===`optimize`&&e.cardinality===`one`,plan:{recall:`structured`,score:`formula`,rank:`score-sort`,explain:`llm-generate`,fairness:!1,topN:3}}],ZT={name:`structured-normal`,match:()=>!0,plan:{recall:`structured`,score:`formula`,rank:`score-sort`,explain:`llm-generate`,fairness:!0,topN:3}};function QT(e){return{recall:`structured`,score:`none`,rank:`score-sort`,explain:`llm-generate`,fairness:!1,topN:3,routingReason:`ambiguity-detected`,clarify:e}}function $T(e,t,n){let r=UT(e);if(r)return QT(r);let i=WT(e,t);if(i)return QT(i);let a=GT(e),o=KT(e),s=qT(e),c=JT(a,o,s),l={anchor:a,userIntent:o,cardinality:s,output:c,sceneHit:e.matchedScenes.length>0&&e.sceneConfidence>=.8,pipeline:e.complexity===`pipeline`,steps:e.complexity===`pipeline`?IT(e.segments).length:0,fuzzy:YT(e)},u=XT.find(e=>e.match(l))??ZT;return{...u.plan,...n!==void 0&&n>0?{topN:n}:{},routingReason:`${u.name}|${a}/${o}/${s}/${c}`}}const eE=/-\d{4}-\d{2}-\d{2}$/;function tE(e){return(e??``).toLowerCase().replace(eE,``).replace(/[\s_-]+/g,``).trim()}function nE(e,t){if(tE(e.model)===t||tE(e.name)===t)return!0;let n=e.model.lastIndexOf(`/`);return n>=0&&tE(e.model.slice(n+1))===t}function rE(e,t){return[e.family,e.familyName].some(e=>{if(!e)return!1;let n=tE(e);return n.length>0&&(t.includes(n)||n.includes(t))})}function iE(e,t){if(t.length===0)return[];let n=[],r=/* @__PURE__ */ new Set;for(let i of t){let t=tE(i);if(!t)continue;let a=e.filter(e=>nE(e,t));a.length===0&&(a=e.filter(e=>rE(e,t)));for(let e of a)r.has(e.model)||(r.add(e.model),n.push(e))}return n}function aE(e,t){return t.length===0?e:e.filter(e=>!t.some(t=>{let n=tE(t);return n.length>0&&(nE(e,n)||rE(e,n))}))}function oE(e){let t=e.prices?.[0]?.price,n=t?Number.parseFloat(t):NaN;return Number.isFinite(n)?n:1/0}const sE={flagship:0,balanced:1,lightweight:2},cE=/* @__PURE__ */ new Set([`qwen`,`qwen-domain-model`,`wan`]);function lE(e){return cE.has(e.provider)}function uE(e){let t=e.model.match(/(\d+(?:\.\d+)?)/);return t?Number.parseFloat(t[1]):-1/0}function dE(e){let t=e.budget===`low`||e.qualityPreference===`cost-optimized`;return(e,n)=>{let r=sE[e.profile?.familyTier??``]??1.5,i=sE[n.profile?.familyTier??``]??1.5,a=t?i-r:r-i;if(a!==0)return a;let o=+!lE(e),s=+!lE(n);if(o!==s)return o-s;let c=oE(e),l=oE(n),u=!Number.isFinite(c);if(u!==!Number.isFinite(l))return u?1:-1;if(!u){let e=t?c-l:l-c;if(e!==0)return e}return uE(n)-uE(e)}}function fE(e,t){return{model:e,hardScore:t,finalScore:t}}function pE(e,t){let n=e.matchedScenes[0];if(!n)return null;let r=t.filter(e=>e.profile?.scenes?.includes(n));return r.length<3?null:r.sort(dE(e)).map(e=>fE(e,1))}function mE(e,t){let n=DT(t,e),r=e.matchedScenes[0],i=dE(e),a=[...n].sort((e,t)=>{if(r){let n=+!e.profile?.scenes?.includes(r),i=+!t.profile?.scenes?.includes(r);if(n!==i)return n-i}return i(e,t)}),o=/* @__PURE__ */ new Map;for(let e of a){let t=e.profile?.familyTier??`unknown`,n=o.get(t)??[];n.push(e),o.set(t,n)}let s=[],c=Math.ceil(20/Math.max(o.size,1));for(let[,e]of o)s.push(...e.slice(0,c));if(s.length<20){let e=new Set(s.map(e=>e.model));for(let t of a){if(s.length>=20)break;e.has(t.model)||s.push(t)}}return s.slice(0,20).map(e=>fE(e,0))}function hE(e,t,n){let r=iE(t,e.modelPreference?.targets??[]),i=new Set(r.map(e=>e.model)),a=r.map(e=>fE(e,1));if(e.modelPreference?.mode===`comparison`)return a;let o=Math.max(0,Math.max(n,5)-a.length);if(o>0){let n=DT(t.filter(e=>!i.has(e.model)),e);for(let t of n.sort(dE(e)).slice(0,o))a.push(fE(t,0))}return a}function gE(e,t){let n=t.filter(t=>TT(t,e));return n.length<5&&(n=t),n.sort(dE(e)).slice(0,30).map(e=>fE(e,0))}function _E(e,t,n,r){let i=n.filter(CT);i=aE(i,t.modelPreference?.excludes??[]);let a;switch(e){case`template`:a=pE(t,i)??mE(t,i);break;case`forced`:a=hE(t,i,r);break;case`holistic-pool`:a=gE(t,i);break;default:a=mE(t,i)}if(e!==`forced`){let e=new Set(ET(a.map(e=>e.model),t).map(e=>e.model));a=a.filter(t=>e.has(t.model.model))}return a}function vE(e){let t=(e??``).replace(/```(?:json)?\s*([\s\S]*?)```/gi,`$1`).trim();try{return JSON.parse(t)}catch{}let n=t.indexOf(`{`),r=t.lastIndexOf(`}`);if(n!==-1&&r!==-1&&r>n){let e=t.slice(n,r+1);try{return JSON.parse(e)}catch{}let i=e.replace(/,\s*([}\]])/g,`$1`);try{return JSON.parse(i)}catch{}}throw Error(`Failed to extract valid JSON from LLM response`)}function yE(e,t){return`${e.length?e.join(`/`):`?`} → ${t.length?t.join(`/`):`?`}`}function bE(e){let t=[];e.taskSummary&&t.push(`Task: ${e.taskSummary}`),t.push(`Complexity: ${e.complexity}`);let n=e.complexity===`pipeline`?e.segments??[]:[];n.length>0&&(t.push(`Steps:`),n.forEach((e,n)=>{let r=e.requiredCapabilities.length?` [${e.requiredCapabilities.join(`, `)}]`:``;t.push(` ${n+1}. ${e.step||`step`}: ${yE(e.inputModality,e.outputModality)}${r}`)})),t.push(`Modality: ${yE(e.inputModality,e.outputModality)}`),e.requiredCapabilities.length&&t.push(`Capabilities: ${e.requiredCapabilities.join(`, `)}`),e.requiredFeatures.length&&t.push(`Features: ${e.requiredFeatures.join(`, `)}`),e.matchedScenes.length&&t.push(`Scenes: ${e.matchedScenes.join(`, `)}`),e.scenarioHints.length&&t.push(`Hints: ${e.scenarioHints.join(`, `)}`),t.push(`Budget: ${e.budget}`),t.push(`Quality: ${e.qualityPreference}`),e.contextNeed!==`standard`&&t.push(`Context need: ${e.contextNeed}`);let r=e.modelPreference?.excludes??[];return r.length&&t.push(`Excluded by user: ${r.join(`, `)}`),t.join(`
203
- `)}const xE={match:{scene:.4,tier:.2,price:.2,context:.2},optimize:{scene:.1,tier:.1,price:.6,context:.2},evaluate:{scene:.5,tier:.2,price:.1,context:.2},differentiate:{scene:.3,tier:.3,price:.2,context:.2}},SE={price:{scene:0,tier:0,price:1,context:0},context:{scene:0,tier:0,price:0,context:1},quality:{scene:.2,tier:.8,price:0,context:0},speed:{scene:.2,tier:0,price:.4,context:.4}};function CE(e,t){return e===`optimize`&&t.optimizeDimension?SE[t.optimizeDimension]??xE.optimize:xE[e]}const wE={standard:0,large:32e3,"extra-large":128e3};function TE(e){let t=e.prices?.[0]?.price,n=t?Number.parseFloat(t):NaN;return Number.isFinite(n)?n:void 0}function EE(e,t){if(t.matchedScenes.length===0)return 1;let n=e.profile?.scenes??[];return+!!t.matchedScenes.some(e=>n.includes(e))}function DE(e,t){let n=e.profile?.familyTier;return n?t.qualityPreference===`flagship`?n===`flagship`?1:.5:t.qualityPreference===`cost-optimized`?n===`lightweight`?1:.5:1:1}function OE(e,t,n){let r=n.map(e=>TE(e.model)).filter(e=>e!==void 0);if(r.length<2)return 1;let i=Math.min(...r),a=Math.max(...r);if(a===i)return 1;let o=TE(e),s=o===void 0?.5:1-(o-i)/(a-i);return t.budget===`low`?s:t.budget===`high`?1-s*.5:.5+s*.5}function kE(e,t){let n=wE[t.contextNeed]??0;if(n===0)return 1;let r=e.contextWindow??0;return r===0||r>=n?1:r/n}function AE(e,t,n){let r=CE(n,t);return e.map(n=>{let i=r.scene*EE(n.model,t)+r.tier*DE(n.model,t)+r.price*OE(n.model,t,e)+r.context*kE(n.model,t);return{...n,hardScore:i,finalScore:i}})}function jE(e){let t=e.model.profile;return[`ID: ${e.model.model}`,t?.oneLinePositioning?`Positioning: ${t.oneLinePositioning}`:``,t?.scenes?.length?`Scenes: ${t.scenes.join(`, `)}`:``,t?.styleKeywords?.length?`Style: ${t.styleKeywords.join(`, `)}`:``,t?.notSuitableFor?.length?`NotSuitableFor: ${t.notSuitableFor.join(`, `)}`:``].filter(Boolean).join(` | `)}async function ME(e,t){let n=t.llm,r=e.map(jE).join(`
204
- `);t.trace.performance.llmCalls++;let i=vE(await n.chat([{role:`system`,content:`You are a model-fit judge. For each candidate model, rate how well it fits the user's need on a 1-10 scale, considering the FULL user request and the parsed intent against the model's complete profile (positioning, scenes, style, limitations).
277
+ Output only JSON, no other text.`;var AD=class extends Error{kind;status;code;requestId;stage;constructor(e,t,n={}){super(t,n.cause===void 0?void 0:{cause:n.cause}),this.name=`LLMError`,this.kind=e,this.status=n.status,this.code=n.code,this.requestId=n.requestId,this.stage=n.stage}get fatal(){return this.kind===`rate_limit`||this.kind===`auth`||this.kind===`cancelled`}get tag(){return this.status?`${this.status} ${this.kind}`:this.kind}};function $(e){if(!e?.aborted)return;let t=e.reason;throw new AD(`cancelled`,t instanceof Error?t.message:`执行已取消`,{cause:t})}function jD(e){return e===429?`rate_limit`:e===401||e===403?`auth`:`http`}function MD(e,t,n){return{stage:e,fallback:t,kind:n.kind,status:n.status,message:n.message}}function ND(e){let t=e.status?`${e.status} ${e.kind}`:e.kind;return`${e.fallback} (${t})`}function PD(e,t){return e instanceof AD?(e.stage??=t,e):new AD(`parse`,e instanceof Error?e.message:String(e),{stage:t,cause:e})}const FD=[`unconstrained`,`scoped`,`comparison`,`alternative`],ID=/* @__PURE__ */ new Set([`Text`,`Image`,`Video`,`Audio`]),LD=new Set(OD),RD=/* @__PURE__ */ new Set([`price`,`speed`,`context`,`quality`]),zD=/* @__PURE__ */ new Set([`one`,`few`,`many`]);function BD(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function VD(e){return BD(e).filter(e=>ID.has(e))}function HD(e){if(!e||typeof e!=`object`)return;let t=e,n=typeof t.mode==`string`&&FD.includes(t.mode)?t.mode:`unconstrained`,r=BD(t.targets),i=BD(t.excludes);return{mode:n,targets:r.length>0?r:void 0,excludes:i.length>0?i:void 0}}async function UD(e,t,n){let r;try{r=await e.chatJson([{role:`system`,content:kD},{role:`user`,content:t}],{stage:`intent`,signal:n})}catch(e){throw PD(e,`intent`)}if(!r||typeof r!=`object`||Array.isArray(r))throw new AD(`parse`,`Intent response is not a JSON object`,{stage:`intent`});let i=BD(r.matchedScenes).filter(e=>LD.has(e)),a=typeof r.sceneConfidence==`number`&&r.sceneConfidence>=0&&r.sceneConfidence<=1?r.sceneConfidence:i.length>0?.5:0;return{complexity:r.complexity===`pipeline`?`pipeline`:`single`,segments:Array.isArray(r.segments)?r.segments.map(e=>({step:typeof e.step==`string`?e.step:``,scene:typeof e.scene==`string`&&LD.has(e.scene)?e.scene:void 0,inputModality:VD(e.inputModality),outputModality:VD(e.outputModality),requiredCapabilities:BD(e.requiredCapabilities)})):void 0,taskSummary:typeof r.taskSummary==`string`?r.taskSummary:``,scenarioHints:BD(r.scenarioHints),inputModality:VD(r.inputModality),outputModality:VD(r.outputModality),requiredCapabilities:BD(r.requiredCapabilities),requiredFeatures:BD(r.requiredFeatures),budget:r.budget===`low`||r.budget===`high`?r.budget:`medium`,contextNeed:r.contextNeed===`large`||r.contextNeed===`extra-large`?r.contextNeed:`standard`,qualityPreference:r.qualityPreference===`cost-optimized`||r.qualityPreference===`balanced`?r.qualityPreference:`flagship`,confidence:1,modelPreference:HD(r.modelPreference),matchedScenes:i,sceneConfidence:a,cardinalityHint:typeof r.cardinalityHint==`string`&&zD.has(r.cardinalityHint)?r.cardinalityHint:void 0,optimizeDimension:typeof r.optimizeDimension==`string`&&RD.has(r.optimizeDimension)?r.optimizeDimension:void 0}}function WD(e){return!e.offlineInfo}function GD(e,t,n,r){let i=e.inferenceMetadata?.request_modality??[],a=e.inferenceMetadata?.response_modality??[];return!(t.length>0&&i.length>0&&!t.some(e=>i.includes(e))||n.length>0&&a.length>0&&!n.some(e=>a.includes(e))||r.length>0&&!r.some(t=>e.capabilities.includes(t)))}function KD(e,t){return GD(e,t.inputModality,t.outputModality,t.requiredCapabilities)}function qD(e,t){let n=[...t.matchedScenes,...t.scenarioHints].filter(Boolean);return n.length===0?e:e.filter(e=>{let t=e.profile?.notSuitableFor;return!t?.length||!t.some(e=>n.some(t=>e.includes(t)))})}function JD(e,t,n=5){let r=e.filter(e=>KD(e,t));if(r.length>=n)return r;if(t.requiredCapabilities.length>0){let n=e.filter(e=>t.requiredCapabilities.some(t=>e.capabilities.includes(t)));if(n.length>0)return n}return e}const YD=/* @__PURE__ */ new Set([`TG`,`Reasoning`,`VU`,`IG`,`VG`,`TTS`,`ASR`,`Realtime-ASR`,`Realtime-Text-to-Speech`,`Realtime-Audio-Translate`,`Realtime-Chatting`,`Realtime-Omni`,`Multimodal-Omni`,`ME`,`TR`,`3D-generation`]),XD=/* @__PURE__ */ new Set([`Reasoning`]),ZD={TG:[`代码生成`,`创意写作`,`客服对话`,`知识问答`,`文档理解`,`数据分析`,`数学推理`,`翻译`,`Agent编排`,`深度研究`,`教育辅导`,`电商营销`,`角色扮演`,`情感分析`,`意图识别`],VU:[`文档理解`,`OCR文字识别`,`数据分析`],IG:[`图像生成`,`图像编辑`,`图像修复`,`人脸人像`,`虚拟试穿`,`电商营销`],VG:[`视频生成`,`视频编辑`,`数字人`],TTS:[`语音合成`,`有声书`,`播客`,`数字人`],ASR:[`语音识别`],"Realtime-ASR":[`语音识别`,`实时对话`],TR:[`向量检索`,`语义重排`,`知识问答`],ME:[`向量检索`],"3D-generation":[`3D生成`]},QD={IG:`图像生成`,VG:`视频生成`,TTS:`语音合成`,ASR:`语音识别`},$D=[[/重排|rerank/i,`语义重排`],[/向量|嵌入|embedding|索引/i,`向量检索`],[/翻译|translat/i,`翻译`],[/代码|编程|code/i,`代码生成`],[/剧本|脚本|文案|歌词|故事|小说|创作|写作|script|lyric/i,`创意写作`],[/纪要|摘要|总结|整理|summar/i,`文档理解`],[/问答|回答|答案|answer/i,`知识问答`],[/转写|识别|听写|transcri/i,`语音识别`],[/配音|旁白|朗读|语音合成|voice/i,`语音合成`],[/数字人|口型|lip/i,`数字人`]],eO=/剪辑|合成剪辑|合轨|混音|拼接|加字幕|字幕合成|后期|导出|assembl|edit(ing)? together|mux/i;function tO(e,t){let n=t[0];if(n===`Image`)return`IG`;if(n===`Video`)return`VG`;if(n===`Audio`)return e.includes(`Audio`)&&!e.includes(`Text`)?void 0:`TTS`;if(n===`Text`)return e.includes(`Audio`)?`ASR`:e.includes(`Image`)||e.includes(`Video`)?`VU`:`TG`}function nO(e){return{TG:`文本生成`,VU:`视觉理解`,IG:`图像生成`,VG:`视频生成`,TTS:`语音合成`,ASR:`语音识别`,TR:`文本检索`,ME:`多模态检索`,"3D-generation":`3D 生成`}[e]??e}function rO(e){let t=[];for(let n of e??[]){let e=n.requiredCapabilities.filter(e=>YD.has(e)),r=e.filter(e=>!XD.has(e)),i=n.step?.trim()??``;if(r.length===0&&eO.test(i))continue;let a=r[0]??tO(n.inputModality,n.outputModality);if(!a)continue;let o=[a,...e.filter(e=>e!==a)],s=i||nO(a);if(t.push({index:t.length+1,label:s,inputModality:n.inputModality,outputModality:n.outputModality,primaryCapability:a,capabilities:o,scene:iO(n.scene,s,a)}),t.length>=5)break}return t.length>=2?t:[]}function iO(e,t,n){let r=e=>(ZD[n]??[]).includes(e);if(e&&r(e))return e;for(let[e,n]of $D)if(e.test(t)&&r(n))return n;return QD[n]}function aO(e,t){if(e.scene)return[e.scene];let n=new Set(ZD[e.primaryCapability]??[]);return t.matchedScenes.filter(e=>n.has(e))}function oO(e,t){return{...t,complexity:`single`,segments:void 0,inputModality:e.inputModality,outputModality:e.outputModality,requiredCapabilities:[e.primaryCapability],requiredFeatures:e.primaryCapability===`TG`?t.requiredFeatures:[],matchedScenes:aO(e,t)}}const sO=/* @__PURE__ */ new Set([`IG`,`VG`,`TTS`,`Realtime-Text-to-Speech`,`3D-generation`]),cO=/* @__PURE__ */ new Set([`TG`,`Reasoning`,`ASR`,`Realtime-ASR`,`TR`,`ME`]);function lO(e){let t=!1,n=!1;for(let r of e)sO.has(r)&&(t=!0),cO.has(r)&&(n=!0);return t&&n}function uO(e){let t=e.modelPreference?.mode;if(t!==`comparison`&&t!==`alternative`){if(e.outputModality.length>0&&e.inputModality.length===0){let t=e.outputModality[0];if(t===`Video`&&e.matchedScenes.length===0)return{question:`你打算从什么素材出发生成视频?`,options:[`纯文字描述(文生视频)`,`已有图片(图生视频)`,`已有视频(视频编辑)`],defaultIfSkip:`纯文字描述(文生视频)`,impact:`text-to-video and image-to-video use completely different models`};if(t===`Audio`&&e.matchedScenes.length===0)return{question:`你需要的是哪类语音能力?`,options:[`文字转语音(TTS)`,`语音转文字(ASR)`,`实时语音对话`],defaultIfSkip:`文字转语音(TTS)`,impact:`TTS and ASR are completely different models`}}if(e.complexity!==`pipeline`&&e.requiredCapabilities.length>=3&&lO(e.requiredCapabilities))return{question:`你的核心需求是哪一类?`,options:e.requiredCapabilities.slice(0,4),defaultIfSkip:e.requiredCapabilities[0],impact:`different capabilities map to completely different model pools`}}}function dO(e,t){let n=e.modelPreference?.mode;if(n===`comparison`||n===`alternative`||n===`scoped`||e.matchedScenes.length>0&&e.sceneConfidence>=.5||e.complexity===`pipeline`)return;let r=t.filter(t=>KD(t,e));if(e.matchedScenes.length===0&&e.sceneConfidence<.5){let e=/* @__PURE__ */ new Map;for(let t of r)for(let n of t.profile?.scenes??[])e.set(n,(e.get(n)??0)+1);let t=[...e.entries()].sort((e,t)=>t[1]-e[1]).slice(0,3).map(([e])=>e);return t.length===0?void 0:{question:`你想用在什么场景?`,options:t,defaultIfSkip:t[0],impact:`不同场景对应完全不同的模型池`}}if(r.length<=20)return;let i=/* @__PURE__ */ new Map;for(let e of r)for(let t of e.profile?.scenes??[])i.set(t,(i.get(t)??0)+1);let a=[...i.entries()].sort((e,t)=>t[1]-e[1]);if(a.length===0||a[0][1]/r.length>=.5)return;let o=a.slice(0,3).map(([e])=>e);return{question:`你的需求更接近哪个场景?`,options:o,defaultIfSkip:o[0],impact:`different scenes produce completely different recommendations`}}function fO(e){let t=e.modelPreference;return!t||t.mode===`unconstrained`?`none`:t.mode===`comparison`?`existing`:t.mode===`alternative`?`reference`:`scope`}function pO(e){return e.modelPreference?.mode===`comparison`?(e.modelPreference?.targets?.length??0)<=1?`evaluate`:`differentiate`:e.optimizeDimension?`optimize`:`match`}function mO(e){return e.cardinalityHint??`few`}function hO(e,t,n){return t===`differentiate`?`compare`:t===`evaluate`?`validate`:n===`many`?`catalog`:`recommend`}function gO(e){return e.matchedScenes.length===0&&e.sceneConfidence<.5&&e.confidence>0}const _O=[{name:`forced-compare`,match:e=>e.anchor===`existing`,plan:{recall:`forced`,score:`none`,rank:`forced-order`,explain:`llm-compare`,fairness:!1,topN:3}},{name:`forced-alternative`,match:e=>e.anchor===`reference`,plan:{recall:`forced`,score:`formula`,rank:`score-sort`,explain:`llm-compare`,fairness:!1,topN:3}},{name:`pipeline-steps`,match:e=>e.pipeline&&e.steps>=2,plan:{recall:`structured`,score:`formula`,rank:`score-sort`,explain:`llm-generate`,fairness:!1,topN:2,stepwise:!0}},{name:`template-fast`,match:e=>e.sceneHit&&e.userIntent===`match`&&!e.pipeline,plan:{recall:`template`,score:`none`,rank:`template-order`,explain:`template-text`,fairness:!0,topN:3}},{name:`holistic-complex`,match:e=>e.pipeline||e.fuzzy,plan:{recall:`holistic-pool`,score:`holistic`,rank:`score-sort`,explain:`llm-generate`,fairness:!0,topN:3}},{name:`catalog-browse`,match:e=>e.cardinality===`many`,plan:{recall:`structured`,score:`formula`,rank:`score-sort`,explain:`catalog`,fairness:!0,topN:10}},{name:`optimize-single`,match:e=>e.userIntent===`optimize`&&e.cardinality===`one`,plan:{recall:`structured`,score:`formula`,rank:`score-sort`,explain:`llm-generate`,fairness:!1,topN:3}}],vO={name:`structured-normal`,match:()=>!0,plan:{recall:`structured`,score:`formula`,rank:`score-sort`,explain:`llm-generate`,fairness:!0,topN:3}};function yO(e){return{recall:`structured`,score:`none`,rank:`score-sort`,explain:`llm-generate`,fairness:!1,topN:3,routingReason:`ambiguity-detected`,clarify:e}}function bO(e,t,n){let r=uO(e);if(r)return yO(r);let i=dO(e,t);if(i)return yO(i);let a=fO(e),o=pO(e),s=mO(e),c=hO(a,o,s),l={anchor:a,userIntent:o,cardinality:s,output:c,sceneHit:e.matchedScenes.length>0&&e.sceneConfidence>=.8,pipeline:e.complexity===`pipeline`,steps:e.complexity===`pipeline`?rO(e.segments).length:0,fuzzy:gO(e)},u=_O.find(e=>e.match(l))??vO;return{...u.plan,...n!==void 0&&n>0?{topN:n}:{},routingReason:`${u.name}|${a}/${o}/${s}/${c}`}}const xO=/-\d{4}-\d{2}-\d{2}$/;function SO(e){return(e??``).toLowerCase().replace(xO,``).replace(/[\s_-]+/g,``).trim()}function CO(e,t){if(SO(e.model)===t||SO(e.name)===t)return!0;let n=e.model.lastIndexOf(`/`);return n>=0&&SO(e.model.slice(n+1))===t}function wO(e,t){return[e.family,e.familyName].some(e=>{if(!e)return!1;let n=SO(e);return n.length>0&&(t.includes(n)||n.includes(t))})}function TO(e,t){if(t.length===0)return[];let n=[],r=/* @__PURE__ */ new Set;for(let i of t){let t=SO(i);if(!t)continue;let a=e.filter(e=>CO(e,t));a.length===0&&(a=e.filter(e=>wO(e,t)));for(let e of a)r.has(e.model)||(r.add(e.model),n.push(e))}return n}function EO(e,t){return t.length===0?e:e.filter(e=>!t.some(t=>{let n=SO(t);return n.length>0&&(CO(e,n)||wO(e,n))}))}function DO(e){let t=e.prices?.[0]?.price,n=t?Number.parseFloat(t):NaN;return Number.isFinite(n)?n:1/0}const OO={flagship:0,balanced:1,lightweight:2},kO=/* @__PURE__ */ new Set([`qwen`,`qwen-domain-model`,`wan`]);function AO(e){return kO.has(e.provider)}function jO(e){let t=e.model.match(/(\d+(?:\.\d+)?)/);return t?Number.parseFloat(t[1]):-1/0}function MO(e){let t=e.budget===`low`||e.qualityPreference===`cost-optimized`;return(e,n)=>{let r=OO[e.profile?.familyTier??``]??1.5,i=OO[n.profile?.familyTier??``]??1.5,a=t?i-r:r-i;if(a!==0)return a;let o=+!AO(e),s=+!AO(n);if(o!==s)return o-s;let c=DO(e),l=DO(n),u=!Number.isFinite(c);if(u!==!Number.isFinite(l))return u?1:-1;if(!u){let e=t?c-l:l-c;if(e!==0)return e}return jO(n)-jO(e)}}function NO(e,t){return{model:e,hardScore:t,finalScore:t}}function PO(e,t){let n=e.matchedScenes[0];if(!n)return null;let r=t.filter(e=>e.profile?.scenes?.includes(n));return r.length<3?null:r.sort(MO(e)).map(e=>NO(e,1))}function FO(e,t){let n=JD(t,e),r=e.matchedScenes[0],i=MO(e),a=[...n].sort((e,t)=>{if(r){let n=+!e.profile?.scenes?.includes(r),i=+!t.profile?.scenes?.includes(r);if(n!==i)return n-i}return i(e,t)}),o=/* @__PURE__ */ new Map;for(let e of a){let t=e.profile?.familyTier??`unknown`,n=o.get(t)??[];n.push(e),o.set(t,n)}let s=[],c=Math.ceil(20/Math.max(o.size,1));for(let[,e]of o)s.push(...e.slice(0,c));if(s.length<20){let e=new Set(s.map(e=>e.model));for(let t of a){if(s.length>=20)break;e.has(t.model)||s.push(t)}}return s.slice(0,20).map(e=>NO(e,0))}function IO(e,t,n){let r=TO(t,e.modelPreference?.targets??[]),i=new Set(r.map(e=>e.model)),a=r.map(e=>NO(e,1));if(e.modelPreference?.mode===`comparison`)return a;let o=Math.max(0,Math.max(n,5)-a.length);if(o>0){let n=JD(t.filter(e=>!i.has(e.model)),e);for(let t of n.sort(MO(e)).slice(0,o))a.push(NO(t,0))}return a}function LO(e,t){let n=t.filter(t=>KD(t,e));return n.length<5&&(n=t),n.sort(MO(e)).slice(0,30).map(e=>NO(e,0))}function RO(e,t,n,r){let i=n.filter(WD);i=EO(i,t.modelPreference?.excludes??[]);let a;switch(e){case`template`:a=PO(t,i)??FO(t,i);break;case`forced`:a=IO(t,i,r);break;case`holistic-pool`:a=LO(t,i);break;default:a=FO(t,i)}if(e!==`forced`){let e=new Set(qD(a.map(e=>e.model),t).map(e=>e.model));a=a.filter(t=>e.has(t.model.model))}return a}function zO(e){let t=(e??``).replace(/```(?:json)?\s*([\s\S]*?)```/gi,`$1`).trim();try{return JSON.parse(t)}catch{}let n=t.indexOf(`{`),r=t.lastIndexOf(`}`);if(n!==-1&&r!==-1&&r>n){let e=t.slice(n,r+1);try{return JSON.parse(e)}catch{}let i=e.replace(/,\s*([}\]])/g,`$1`);try{return JSON.parse(i)}catch{}}throw Error(`Failed to extract valid JSON from LLM response`)}function BO(e,t){return`${e.length?e.join(`/`):`?`} → ${t.length?t.join(`/`):`?`}`}function VO(e){let t=[];e.taskSummary&&t.push(`Task: ${e.taskSummary}`),t.push(`Complexity: ${e.complexity}`);let n=e.complexity===`pipeline`?e.segments??[]:[];n.length>0&&(t.push(`Steps:`),n.forEach((e,n)=>{let r=e.requiredCapabilities.length?` [${e.requiredCapabilities.join(`, `)}]`:``;t.push(` ${n+1}. ${e.step||`step`}: ${BO(e.inputModality,e.outputModality)}${r}`)})),t.push(`Modality: ${BO(e.inputModality,e.outputModality)}`),e.requiredCapabilities.length&&t.push(`Capabilities: ${e.requiredCapabilities.join(`, `)}`),e.requiredFeatures.length&&t.push(`Features: ${e.requiredFeatures.join(`, `)}`),e.matchedScenes.length&&t.push(`Scenes: ${e.matchedScenes.join(`, `)}`),e.scenarioHints.length&&t.push(`Hints: ${e.scenarioHints.join(`, `)}`),t.push(`Budget: ${e.budget}`),t.push(`Quality: ${e.qualityPreference}`),e.contextNeed!==`standard`&&t.push(`Context need: ${e.contextNeed}`);let r=e.modelPreference?.excludes??[];return r.length&&t.push(`Excluded by user: ${r.join(`, `)}`),t.join(`
278
+ `)}const HO={match:{scene:.4,tier:.2,price:.2,context:.2},optimize:{scene:.1,tier:.1,price:.6,context:.2},evaluate:{scene:.5,tier:.2,price:.1,context:.2},differentiate:{scene:.3,tier:.3,price:.2,context:.2}},UO={price:{scene:0,tier:0,price:1,context:0},context:{scene:0,tier:0,price:0,context:1},quality:{scene:.2,tier:.8,price:0,context:0},speed:{scene:.2,tier:0,price:.4,context:.4}};function WO(e,t){return e===`optimize`&&t.optimizeDimension?UO[t.optimizeDimension]??HO.optimize:HO[e]}const GO={standard:0,large:32e3,"extra-large":128e3};function KO(e){let t=e.prices?.[0]?.price,n=t?Number.parseFloat(t):NaN;return Number.isFinite(n)?n:void 0}function qO(e,t){if(t.matchedScenes.length===0)return 1;let n=e.profile?.scenes??[];return+!!t.matchedScenes.some(e=>n.includes(e))}function JO(e,t){let n=e.profile?.familyTier;return n?t.qualityPreference===`flagship`?n===`flagship`?1:.5:t.qualityPreference===`cost-optimized`?n===`lightweight`?1:.5:1:1}function YO(e,t,n){let r=n.map(e=>KO(e.model)).filter(e=>e!==void 0);if(r.length<2)return 1;let i=Math.min(...r),a=Math.max(...r);if(a===i)return 1;let o=KO(e),s=o===void 0?.5:1-(o-i)/(a-i);return t.budget===`low`?s:t.budget===`high`?1-s*.5:.5+s*.5}function XO(e,t){let n=GO[t.contextNeed]??0;if(n===0)return 1;let r=e.contextWindow??0;return r===0||r>=n?1:r/n}function ZO(e,t,n){let r=WO(n,t);return e.map(n=>{let i=r.scene*qO(n.model,t)+r.tier*JO(n.model,t)+r.price*YO(n.model,t,e)+r.context*XO(n.model,t);return{...n,hardScore:i,finalScore:i}})}function QO(e){let t=e.model.profile;return[`ID: ${e.model.model}`,t?.oneLinePositioning?`Positioning: ${t.oneLinePositioning}`:``,t?.scenes?.length?`Scenes: ${t.scenes.join(`, `)}`:``,t?.styleKeywords?.length?`Style: ${t.styleKeywords.join(`, `)}`:``,t?.notSuitableFor?.length?`NotSuitableFor: ${t.notSuitableFor.join(`, `)}`:``].filter(Boolean).join(` | `)}async function $O(e,t){let n=t.llm,r=e.map(QO).join(`
279
+ `);t.trace.performance.llmCalls++;let i=zO(await n.chat([{role:`system`,content:`You are a model-fit judge. For each candidate model, rate how well it fits the user's need on a 1-10 scale, considering the FULL user request and the parsed intent against the model's complete profile (positioning, scenes, style, limitations).
205
280
 
206
281
  Rules:
207
282
  - Judge holistically; do not decompose into dimensions
208
283
  - The parsed intent is the structured reading of the request; use it, but the original request wins if they conflict
209
284
  - For a pipeline task (Complexity: pipeline), score each model by how well it serves the step that matches its capability; a model that fits no step must score ≤3
210
285
  - A model whose notSuitableFor conflicts with the need must score ≤3
211
- - Respond with ONLY JSON: {"scores": [{"model": "<id>", "score": <1-10>}]}`},{role:`user`,content:`User request: ${t.input}\n\nParsed intent:\n${bE(t.intent)}\n\nCandidates:\n${r}`}],{maxTokens:2048,stage:`holistic-score`,signal:t.signal})),a=new Map((i.scores??[]).map(e=>[e.model,e.score]));return e.map(e=>{let t=a.get(e.model.model),n=typeof t==`number`&&t>=1&&t<=10?t:5;return{...e,holisticScore:n,finalScore:n/10}})}async function NE(e,t,n,r){switch(e){case`none`:return t;case`holistic`:try{return await ME(t,n)}catch(e){if($(n.signal),pT(e,`holistic-score`).kind===`cancelled`)throw e;return n.trace.degradations.push(dT(`holistic-score`,`holistic-score→formula`,pT(e,`holistic-score`))),AE(t,n.intent,r)}default:return AE(t,n.intent,r)}}function PE(e,t){if(e.length<=1)return e;let n=/* @__PURE__ */ new Map,r=[],i=[];for(let t of e){let e=t.model.family;if(!e){r.push(t);continue}let a=n.get(e)??0;a<2?(r.push(t),n.set(e,a+1)):i.push(t)}let a=[...r,...i],o=a.slice(0,t),s=new Set(o.map(e=>e.model.family).filter(Boolean));if(t>=3&&s.size===1&&a.length>t){let e=o[0].model.family,n=a.findIndex((n,r)=>r>=t&&n.model.family!==e);if(n>=0){let[e]=a.splice(n,1);a.splice(t-1,0,e)}}return a}function FE(e){let t=e.model.prices?.[0]?.price,n=t?Number.parseFloat(t):NaN;return Number.isFinite(n)?n:1/0}function IE(e){return e.model.profile?.familyTier??`unknown`}function LE(e,t){let n=[`primary`,`runner-up`,`exploration`];return e.slice(0,t).map((e,t)=>({...e,rank:t+1,slot:n[Math.min(t,n.length-1)]}))}function RE(e,t,n){if(t<3||e.length<3)return LE(e,t);let r=[],i=/* @__PURE__ */ new Set,a=()=>{for(let t of e){if(r.length>=3)break;i.has(t.model.model)||(r.push(t),i.add(t.model.model))}};if(n.budget===`low`||n.qualityPreference===`cost-optimized`){let n=/* @__PURE__ */ new Map;for(let t of e){let e=IE(t),r=n.get(e)??[];r.push(t),n.set(e,r)}for(let e of[`lightweight`,`balanced`,`flagship`]){let t=n.get(e)?.[0];if(t&&!i.has(t.model.model)&&(r.push(t),i.add(t.model.model)),r.length>=3)break}return a(),LE(r,t)}let o=/* @__PURE__ */ new Set;for(let t of e){if(r.length>=3)break;IE(t)===`flagship`&&(o.has(t.model.provider)||(o.add(t.model.provider),r.push(t),i.add(t.model.model)))}return a(),LE(r,t)}function zE(e,t,n,r,i){let a;switch(e){case`template-order`:case`forced-order`:a=t;break;default:a=[...t].sort((e,t)=>{let n=t.finalScore-e.finalScore;return Math.abs(n)>1e-9?n:FE(e)-FE(t)})}return r&&(a=PE(a,n)),e===`forced-order`?LE(a,n):RE(a,n,i)}const BE={input_token:`输入`,output_token:`输出`,input_token_cache:`缓存输入`,input_token_cache_creation_5m:`缓存写入`,input_token_cache_read:`缓存读取`,input_token_batch:`批量输入`,output_token_batch:`批量输出`,input_token_batch_chat:`批量对话输入`,output_token_batch_chat:`批量对话输出`};function VE(e){let t=[];for(let n of e.prices??[]){if(t.length>=3)break;let e=BE[n.type]??n.type;t.push(`${e} ${n.price} / ${n.unit}`)}return{pricing:t,contextWindow:e.contextWindow,maxInputTokens:e.maxInputTokens,maxOutputTokens:e.maxOutputTokens,features:e.features??[]}}function HE(e){let t=e.model,n=t.profile;return[`ID: ${t.model}`,`Name: ${t.name}`,`Slot: ${e.slot}`,n?.oneLinePositioning?`Positioning: ${n.oneLinePositioning}`:`Description: ${t.description.slice(0,120)}`,n?.scenes?.length?`Scenes: ${n.scenes.join(`, `)}`:``,n?.familyTier?`Tier: ${n.familyTier}`:``,t.contextWindow?`Context: ${t.contextWindow}`:``,t.prices?.length?`Price: ${t.prices[0].price}/${t.prices[0].unit}`:``,n?.notSuitableFor?.length?`NotSuitableFor: ${n.notSuitableFor.join(`, `)}`:``].filter(Boolean).join(` | `)}function UE(e){return e.model.profile?.profileCompleteness===`structured-only`?`low`:e.slot===`exploration`||e.slot===`alternative`?`medium`:`high`}function WE(e){return e.map(e=>{let t=e.model.profile,n=[];return t?.familyTier&&n.push(t.familyTier),e.model.prices?.length&&n.push(`${e.model.prices[0].price}/${e.model.prices[0].unit}`),t?.styleKeywords?.length&&n.push(...t.styleKeywords.slice(0,2)),{model:e.model.model,name:e.model.name,reason:t?.oneLinePositioning??e.model.description.slice(0,80),highlights:n,confidence:UE(e),slot:e.slot,docUrl:e.model.docUrl,specs:VE(e.model)}})}function GE(e){return e.map(e=>({model:e.model.model,name:e.model.name,reason:e.model.profile?.oneLinePositioning??``,highlights:e.model.profile?.familyTier?[e.model.profile.familyTier]:[],confidence:UE(e),slot:e.slot,docUrl:e.model.docUrl,specs:VE(e.model)}))}async function KE(e,t,n){n.trace.performance.llmCalls++;let r=vE(await n.llm.chat([{role:`system`,content:e},{role:`user`,content:`User request: ${n.input}\n\nIntent:\n${bE(n.intent)}\n\nRanked candidates:\n${t.map(HE).join(`
212
- `)}`}],{maxTokens:2048,stage:`explain`,signal:n.signal})),i=new Map((r.items??[]).map(e=>[e.model,e]));return t.map(e=>{let t=i.get(e.model.model);return{model:e.model.model,name:e.model.name,reason:t?.reason??e.model.profile?.oneLinePositioning??``,highlights:t?.highlights??[],confidence:UE(e),slot:e.slot,docUrl:e.model.docUrl,specs:VE(e.model)}})}async function qE(e,t,n){switch(e){case`template-text`:return WE(t);case`catalog`:return GE(t);case`llm-compare`:try{return await KE(`You are a model comparison advisor for Alibaba Cloud Model Studio. Analyze the given models against the user's use case comparatively.
286
+ - Respond with ONLY JSON: {"scores": [{"model": "<id>", "score": <1-10>}]}`},{role:`user`,content:`User request: ${t.input}\n\nParsed intent:\n${VO(t.intent)}\n\nCandidates:\n${r}`}],{maxTokens:2048,stage:`holistic-score`,signal:t.signal})),a=new Map((i.scores??[]).map(e=>[e.model,e.score]));return e.map(e=>{let t=a.get(e.model.model),n=typeof t==`number`&&t>=1&&t<=10?t:5;return{...e,holisticScore:n,finalScore:n/10}})}async function ek(e,t,n,r){switch(e){case`none`:return t;case`holistic`:try{return await $O(t,n)}catch(e){if($(n.signal),PD(e,`holistic-score`).kind===`cancelled`)throw e;return n.trace.degradations.push(MD(`holistic-score`,`holistic-score→formula`,PD(e,`holistic-score`))),ZO(t,n.intent,r)}default:return ZO(t,n.intent,r)}}function tk(e,t){if(e.length<=1)return e;let n=/* @__PURE__ */ new Map,r=[],i=[];for(let t of e){let e=t.model.family;if(!e){r.push(t);continue}let a=n.get(e)??0;a<2?(r.push(t),n.set(e,a+1)):i.push(t)}let a=[...r,...i],o=a.slice(0,t),s=new Set(o.map(e=>e.model.family).filter(Boolean));if(t>=3&&s.size===1&&a.length>t){let e=o[0].model.family,n=a.findIndex((n,r)=>r>=t&&n.model.family!==e);if(n>=0){let[e]=a.splice(n,1);a.splice(t-1,0,e)}}return a}function nk(e){let t=e.model.prices?.[0]?.price,n=t?Number.parseFloat(t):NaN;return Number.isFinite(n)?n:1/0}function rk(e){return e.model.profile?.familyTier??`unknown`}function ik(e,t){let n=[`primary`,`runner-up`,`exploration`];return e.slice(0,t).map((e,t)=>({...e,rank:t+1,slot:n[Math.min(t,n.length-1)]}))}function ak(e,t,n){if(t<3||e.length<3)return ik(e,t);let r=[],i=/* @__PURE__ */ new Set,a=()=>{for(let t of e){if(r.length>=3)break;i.has(t.model.model)||(r.push(t),i.add(t.model.model))}};if(n.budget===`low`||n.qualityPreference===`cost-optimized`){let n=/* @__PURE__ */ new Map;for(let t of e){let e=rk(t),r=n.get(e)??[];r.push(t),n.set(e,r)}for(let e of[`lightweight`,`balanced`,`flagship`]){let t=n.get(e)?.[0];if(t&&!i.has(t.model.model)&&(r.push(t),i.add(t.model.model)),r.length>=3)break}return a(),ik(r,t)}let o=/* @__PURE__ */ new Set;for(let t of e){if(r.length>=3)break;rk(t)===`flagship`&&(o.has(t.model.provider)||(o.add(t.model.provider),r.push(t),i.add(t.model.model)))}return a(),ik(r,t)}function ok(e,t,n,r,i){let a;switch(e){case`template-order`:case`forced-order`:a=t;break;default:a=[...t].sort((e,t)=>{let n=t.finalScore-e.finalScore;return Math.abs(n)>1e-9?n:nk(e)-nk(t)})}return r&&(a=tk(a,n)),e===`forced-order`?ik(a,n):ak(a,n,i)}const sk={input_token:`输入`,output_token:`输出`,input_token_cache:`缓存输入`,input_token_cache_creation_5m:`缓存写入`,input_token_cache_read:`缓存读取`,input_token_batch:`批量输入`,output_token_batch:`批量输出`,input_token_batch_chat:`批量对话输入`,output_token_batch_chat:`批量对话输出`};function ck(e){let t=[];for(let n of e.prices??[]){if(t.length>=3)break;let e=sk[n.type]??n.type;t.push(`${e} ${n.price} / ${n.unit}`)}return{pricing:t,contextWindow:e.contextWindow,maxInputTokens:e.maxInputTokens,maxOutputTokens:e.maxOutputTokens,features:e.features??[]}}function lk(e){let t=e.model,n=t.profile;return[`ID: ${t.model}`,`Name: ${t.name}`,`Slot: ${e.slot}`,n?.oneLinePositioning?`Positioning: ${n.oneLinePositioning}`:`Description: ${t.description.slice(0,120)}`,n?.scenes?.length?`Scenes: ${n.scenes.join(`, `)}`:``,n?.familyTier?`Tier: ${n.familyTier}`:``,t.contextWindow?`Context: ${t.contextWindow}`:``,t.prices?.length?`Price: ${t.prices[0].price}/${t.prices[0].unit}`:``,n?.notSuitableFor?.length?`NotSuitableFor: ${n.notSuitableFor.join(`, `)}`:``].filter(Boolean).join(` | `)}function uk(e){return e.model.profile?.profileCompleteness===`structured-only`?`low`:e.slot===`exploration`||e.slot===`alternative`?`medium`:`high`}function dk(e){return e.map(e=>{let t=e.model.profile,n=[];return t?.familyTier&&n.push(t.familyTier),e.model.prices?.length&&n.push(`${e.model.prices[0].price}/${e.model.prices[0].unit}`),t?.styleKeywords?.length&&n.push(...t.styleKeywords.slice(0,2)),{model:e.model.model,name:e.model.name,reason:t?.oneLinePositioning??e.model.description.slice(0,80),highlights:n,confidence:uk(e),slot:e.slot,docUrl:e.model.docUrl,specs:ck(e.model)}})}function fk(e){return e.map(e=>({model:e.model.model,name:e.model.name,reason:e.model.profile?.oneLinePositioning??``,highlights:e.model.profile?.familyTier?[e.model.profile.familyTier]:[],confidence:uk(e),slot:e.slot,docUrl:e.model.docUrl,specs:ck(e.model)}))}async function pk(e,t,n){n.trace.performance.llmCalls++;let r=zO(await n.llm.chat([{role:`system`,content:e},{role:`user`,content:`User request: ${n.input}\n\nIntent:\n${VO(n.intent)}\n\nRanked candidates:\n${t.map(lk).join(`
287
+ `)}`}],{maxTokens:2048,stage:`explain`,signal:n.signal})),i=new Map((r.items??[]).map(e=>[e.model,e]));return t.map(e=>{let t=i.get(e.model.model);return{model:e.model.model,name:e.model.name,reason:t?.reason??e.model.profile?.oneLinePositioning??``,highlights:t?.highlights??[],confidence:uk(e),slot:e.slot,docUrl:e.model.docUrl,specs:ck(e.model)}})}async function mk(e,t,n){switch(e){case`template-text`:return dk(t);case`catalog`:return fk(t);case`llm-compare`:try{return await pk(`You are a model comparison advisor for Alibaba Cloud Model Studio. Analyze the given models against the user's use case comparatively.
213
288
 
214
289
  Rules:
215
290
  - reason and highlights MUST be in Simplified Chinese (简体中文)
216
291
  - Each reason must be comparative: strengths/weaknesses relative to the other models, and "choose this if ..."
217
292
  - highlights emphasize differentiators
218
293
  - Respond with ONLY JSON:
219
- {"items":[{"model":"<id>","reason":"...","highlights":["...","..."]}]}`,t,n)}catch(e){if($(n.signal),pT(e,`explain`).kind===`cancelled`)throw e;return n.trace.degradations.push(dT(`explain`,`llm-compare→template-text`,pT(e,`explain`))),WE(t)}default:try{return await KE(`You are a model recommendation advisor for Alibaba Cloud Model Studio. The candidates below are ALREADY ranked — do not reorder them. Write a recommendation reason for each.
294
+ {"items":[{"model":"<id>","reason":"...","highlights":["...","..."]}]}`,t,n)}catch(e){if($(n.signal),PD(e,`explain`).kind===`cancelled`)throw e;return n.trace.degradations.push(MD(`explain`,`llm-compare→template-text`,PD(e,`explain`))),dk(t)}default:try{return await pk(`You are a model recommendation advisor for Alibaba Cloud Model Studio. The candidates below are ALREADY ranked — do not reorder them. Write a recommendation reason for each.
220
295
 
221
296
  The candidates occupy distinct quality-tier slots. Write each reason from its slot's perspective:
222
297
  - primary (Best Pick): why this model is the best fit for the user's budget and quality preference
@@ -229,8 +304,8 @@ Rules:
229
304
  - The three reasons must take distinct angles
230
305
  - If the intent is a pipeline (Complexity: pipeline), name the step each model serves (e.g. "用于第3步图生视频")
231
306
  - Respond with ONLY JSON:
232
- {"items":[{"model":"<id>","reason":"...","highlights":["...","..."]}]}`,t,n)}catch(e){if($(n.signal),pT(e,`explain`).kind===`cancelled`)throw e;return n.trace.degradations.push(dT(`explain`,`llm-generate→template-text`,pT(e,`explain`))),WE(t)}}}function JE(e){let t=e.model,n=t.profile,r=(n?.pipelineRole??[]).map(e=>`${e.from}→${e.to}: ${e.role}`).slice(0,3);return[` - ID: ${t.model}`,`Slot: ${e.slot}`,n?.oneLinePositioning?`Positioning: ${n.oneLinePositioning}`:`Description: ${t.description.slice(0,120)}`,n?.familyTier?`Tier: ${n.familyTier}`:``,t.prices?.length?`Price: ${t.prices[0].price}/${t.prices[0].unit}`:``,r.length?`Roles: ${r.join(`; `)}`:``,n?.notSuitableFor?.length?`NotSuitableFor: ${n.notSuitableFor.slice(0,3).join(`, `)}`:``].filter(Boolean).join(` | `)}function YE({step:e,candidates:t}){let n=`${e.inputModality.join(`/`)||`?`} → ${e.outputModality.join(`/`)||`?`}`;return[`Step ${e.index}: ${e.label} (${n}, ${e.capabilities.join(`+`)})`,...t.map(JE)].join(`
233
- `)}function XE(e){return WE(e.candidates).map(t=>({...t,step:e.step.index}))}async function ZE(e,t){if(e.every(e=>e.candidates.length===0))return e.map(()=>[]);let n;try{t.trace.performance.llmCalls++,n=vE(await t.llm.chat([{role:`system`,content:`You are a model recommendation advisor for Alibaba Cloud Model Studio. The user's task is a multi-step pipeline. For EACH step, the candidates are ALREADY selected — do not reorder, add or drop models. Write a recommendation reason for each candidate.
307
+ {"items":[{"model":"<id>","reason":"...","highlights":["...","..."]}]}`,t,n)}catch(e){if($(n.signal),PD(e,`explain`).kind===`cancelled`)throw e;return n.trace.degradations.push(MD(`explain`,`llm-generate→template-text`,PD(e,`explain`))),dk(t)}}}function hk(e){let t=e.model,n=t.profile,r=(n?.pipelineRole??[]).map(e=>`${e.from}→${e.to}: ${e.role}`).slice(0,3);return[` - ID: ${t.model}`,`Slot: ${e.slot}`,n?.oneLinePositioning?`Positioning: ${n.oneLinePositioning}`:`Description: ${t.description.slice(0,120)}`,n?.familyTier?`Tier: ${n.familyTier}`:``,t.prices?.length?`Price: ${t.prices[0].price}/${t.prices[0].unit}`:``,r.length?`Roles: ${r.join(`; `)}`:``,n?.notSuitableFor?.length?`NotSuitableFor: ${n.notSuitableFor.slice(0,3).join(`, `)}`:``].filter(Boolean).join(` | `)}function gk({step:e,candidates:t}){let n=`${e.inputModality.join(`/`)||`?`} → ${e.outputModality.join(`/`)||`?`}`;return[`Step ${e.index}: ${e.label} (${n}, ${e.capabilities.join(`+`)})`,...t.map(hk)].join(`
308
+ `)}function _k(e){return dk(e.candidates).map(t=>({...t,step:e.step.index}))}async function vk(e,t){if(e.every(e=>e.candidates.length===0))return e.map(()=>[]);let n;try{t.trace.performance.llmCalls++,n=zO(await t.llm.chat([{role:`system`,content:`You are a model recommendation advisor for Alibaba Cloud Model Studio. The user's task is a multi-step pipeline. For EACH step, the candidates are ALREADY selected — do not reorder, add or drop models. Write a recommendation reason for each candidate.
234
309
 
235
310
  Rules:
236
311
  - reason and highlights MUST be in Simplified Chinese (简体中文)
@@ -239,12 +314,12 @@ Rules:
239
314
  - Each reason at most 80 Chinese characters; be specific to the user's task; no generic praise ("性能强大", "效果好")
240
315
  - highlights: 2-3 short phrases
241
316
  - Respond with ONLY JSON:
242
- {"steps":[{"index":1,"items":[{"model":"<id>","reason":"...","highlights":["...","..."]}]}]}`},{role:`user`,content:`User request: ${t.input}\n\nParsed intent:\n${bE(t.intent)}\n\nSelected candidates per step:\n${e.map(YE).join(`
317
+ {"steps":[{"index":1,"items":[{"model":"<id>","reason":"...","highlights":["...","..."]}]}]}`},{role:`user`,content:`User request: ${t.input}\n\nParsed intent:\n${VO(t.intent)}\n\nSelected candidates per step:\n${e.map(gk).join(`
243
318
 
244
- `)}`}],{maxTokens:2048,stage:`step-explain`,signal:t.signal}))}catch(n){if($(t.signal),pT(n,`explain`).kind===`cancelled`)throw n;return t.trace.degradations.push(dT(`explain`,`step-explain→template-text`,pT(n,`explain`))),e.map(XE)}let r=/* @__PURE__ */ new Map;for(let e of n.steps??[])typeof e.index==`number`&&r.set(e.index,new Map((e.items??[]).map(e=>[e.model,e])));return e.map(e=>{let t=XE(e),n=r.get(e.step.index);return t.map(e=>{let t=n?.get(e.model);return t?.reason?{...e,reason:t.reason,highlights:t.highlights?.length?t.highlights:e.highlights}:e})})}function QE(e){return e.inferenceMetadata?.request_modality??[]}function $E(e){return e.inferenceMetadata?.response_modality??[]}function eD(e,t){return t.length===0||e.length===0||t.some(t=>e.includes(t))}function tD(e,t,n){return e.capabilities.includes(t.primaryCapability)?n===`capability-only`?!0:eD($E(e),t.outputModality)?n===`relaxed-input`||eD(QE(e),t.inputModality):!1:!1}const nD={向量检索:`语义重排`};function rD(e,t){let n=e.filter(t);return n.length>=2?n:e}function iD(e,t,n){let r=zT(e,t);for(let t of[`strict`,`relaxed-input`,`capability-only`]){let i=n.filter(n=>tD(n,e,t));if(i.length<2)continue;let a=e.scene;if(a){i=rD(i,e=>e.profile?.scenes?.includes(a)??!1);let e=nD[a];e&&(i=rD(i,t=>!(t.profile?.scenes?.includes(e)??!1)))}return i=rD(i,e=>ET([e],r).length>0),{models:i,gate:t}}return{models:n.filter(t=>tD(t,e,`capability-only`)),gate:`capability-only`}}const aD={role:.35,scene:.2,tier:.2,price:.15,extras:.1},oD=/纯文[字本]|无图|仅[用靠]?文字|只有文字|无参考/;function sD(e,t){if(t.inputModality.length>0&&t.inputModality.every(e=>e===`Text`)&&t.outputModality.some(e=>e===`Image`||e===`Video`)&&(e.profile?.notSuitableFor??[]).some(e=>oD.test(e)))return .25;let n=e.profile?.pipelineRole??[];if(n.length===0)return .5;let r=e=>t.outputModality.length===0||t.outputModality.includes(e),i=e=>t.inputModality.length===0||t.inputModality.includes(e);return n.some(e=>i(e.from)&&r(e.to))?1:n.some(e=>r(e.to))?.5:0}function cD(e,t){let n=e.profile?.familyTier;return n?{flagship:{flagship:1,balanced:.6,lightweight:.3},"cost-optimized":{lightweight:1,balanced:.7,flagship:.4},balanced:{balanced:1,flagship:.85,lightweight:.7}}[t.qualityPreference]?.[n]??.7:.7}function lD(e){let t=e.prices?.[0],n=t?.price?Number.parseFloat(t.price):NaN;return Number.isFinite(n)?{value:n,unit:t.unit}:void 0}function uD(e,t){let n=/* @__PURE__ */ new Map;for(let t of e){let e=lD(t);e&&n.set(e.unit,(n.get(e.unit)??0)+1)}let r=[...n.entries()].sort((e,t)=>t[1]-e[1])[0]?.[0],i=e.map(lD).filter(e=>e!==void 0&&e.unit===r).map(e=>e.value),a=Math.min(...i),o=Math.max(...i);return e=>{let n=lD(e);if(!n||n.unit!==r||i.length<2||o===a)return .5;let s=1-(n.value-a)/(o-a);return t.budget===`low`?s:t.budget===`high`?1-s*.5:.5+s*.5}}function dD(e,t,n){let r=t.capabilities.filter(e=>e!==t.primaryCapability),i=r.length+n.length;return i===0?1:(r.filter(t=>e.capabilities.includes(t)).length+n.filter(t=>e.features.includes(t)).length)/i}function fD(e,t,n){let r=zT(t,n),i=RT(t,n),a=uD(e,n);return e.map(e=>{let o=sD(e,t),s=i.length===0||(e.profile?.scenes??[]).some(e=>i.includes(e))?1:.3,c=aD.role*o+aD.scene*s+aD.tier*cD(e,n)+aD.price*a(e)+aD.extras*dD(e,t,r.requiredFeatures);return e.profile?.profileCompleteness===`structured-only`&&(c*=.9),{model:e,score:c,role:o}}).sort((e,t)=>t.score-e.score||(lD(e.model)?.value??1/0)-(lD(t.model)?.value??1/0))}function pD(e){let[t,...n]=e;if(!t)return[];let r=n.filter(e=>e.role>=t.role),i=r.length>0?r:n,a=e=>e.model.profile?.familyTier??`unknown`,o=e=>e.model.family??e.model.provider,s=i.find(e=>a(e)!==a(t))??i.find(e=>o(e)!==o(t))??i[0];return s?[t,s]:[t]}const mD={Text:`文本`,Image:`图片`,Video:`视频`,Audio:`音频`};function hD(e,t){let n=[];for(let r=1;r<e.length;r++){let i=t[r-1],a=t[r];if(!i||!a)continue;let o=$E(i).length?$E(i):e[r-1].outputModality,s=e[r].inputModality.filter(e=>o.includes(e));if(s.length===0)continue;let c=QE(a);if(c.length>0&&!s.some(e=>c.includes(e))){let e=s.map(e=>mD[e]??e).join(`/`);n.push(`第${r}步 ${i.name} 输出${e},但第${r+1}步首选 ${a.name} 不接受${e}输入,衔接时需要转换或换用备选`)}}return n}function gD(e,t){return!t||e.models.length<2||e.gate===`capability-only`?`low`:e.gate===`strict`&&e.models.length>=3&&t.role===1?`high`:`medium`}const _D=[`low`,`medium`,`high`];function vD(e){return e.reduce((e,t)=>_D.indexOf(t)<_D.indexOf(e)?t:e,`high`)}async function yD(e){let t=IT(e.intent.segments),n=aE(e.models.filter(CT),e.intent.modelPreference?.excludes??[]),r=Date.now(),i=t.map(t=>iD(t,e.intent,n));e.trace.performance.recallMs=Date.now()-r;for(let n=0;n<t.length;n++)e.decisionLog?.push(`[step ${n+1} recall] ${t[n].label}: pool=${i[n].models.length} gate=${i[n].gate} scene=${t[n].scene??`-`}`);let a=Date.now(),o=t.map((t,n)=>fD(i[n].models,t,e.intent));e.trace.performance.scoreMs=Date.now()-a;for(let n=0;n<t.length;n++){let r=o[n].slice(0,3).map(e=>`${e.model.model}(${e.score.toFixed(2)},role=${e.role})`).join(`, `);e.decisionLog?.push(`[step ${n+1} score] ${t[n].label}: ${r}`)}let s=Date.now(),c=o.map(t=>pD(t).slice(0,e.topN));e.trace.performance.rankMs=Date.now()-s;for(let n=0;n<t.length;n++)e.decisionLog?.push(`[step ${n+1} pick] ${t[n].label}: ${c[n].map(e=>e.model.model).join(` + `)}`);let l=t.map((e,t)=>({step:e,candidates:c[t].map((e,t)=>({model:e.model,hardScore:e.score,finalScore:e.score,rank:t+1,slot:t===0?`primary`:`alternative`}))})),u=Date.now(),d=await ZE(l,e);e.trace.performance.explainMs=Date.now()-u;let f=t.map((e,t)=>({index:e.index,step:e.label,inputModality:e.inputModality,outputModality:e.outputModality,capabilities:e.capabilities,recommendations:d[t],candidatePool:i[t].models.length,confidence:gD(i[t],o[t][0]),gate:i[t].gate}));return{steps:f,warnings:hD(t,c.map(e=>e[0]?.model)),candidatePool:i.reduce((e,t)=>e+t.models.length,0),confidence:vD(f.map(e=>e.confidence))}}function bD(e,t){let{plan:n,intent:r}=e;if(n.recall===`template`&&r.sceneConfidence>=.8)return`high`;if(t.length<5&&n.recall!==`forced`)return`low`;let i=[...t].sort((e,t)=>t.finalScore-e.finalScore);return(i[0]?i[0].finalScore-(i[1]?.finalScore??0):0)>.2&&(i[0]?.finalScore??0)>.6||n.recall===`forced`?`high`:`medium`}async function xD(e,t,n){$(t.signal);let r=Date.now(),i={timestamp:(/* @__PURE__ */ new Date()).toISOString(),input:e,performance:{llmCalls:0},degradations:[]},a=await t.catalog();$(t.signal);let o=t.decisionLog??[],s=Date.now(),c;if(n)c=n;else{i.performance.llmCalls++;try{c=await ST(t.llm,e,t.signal),$(t.signal)}catch(e){let n=pT(e,`intent`);throw i.performance.intentMs=Date.now()-s,i.performance.totalMs=Date.now()-r,i.failure={stage:`intent`,kind:n.kind,status:n.status,code:n.code,requestId:n.requestId,message:n.message},t.onTrace?.(i),n}}i.performance.intentMs=Date.now()-s,i.matchedScenes=c.matchedScenes,i.sceneConfidence=c.sceneConfidence,o.push(`[intent] complexity=${c.complexity} scenes=[${c.matchedScenes.join(`,`)}] conf=${c.sceneConfidence} caps=[${c.requiredCapabilities.join(`,`)}] budget=${c.budget} quality=${c.qualityPreference}`);let l=$T(c,a,t.topN);if(i.routingReason=l.routingReason,o.push(`[route] ${l.routingReason}${l.clarify?` → clarify`:``}`),l.clarify)return i.performance.totalMs=Date.now()-r,t.onTrace?.(i),{type:`need_clarify`,...l.clarify,intent:c};let u={input:e,intent:c,models:a,plan:l,topN:l.topN,llm:t.llm,signal:t.signal,trace:i,decisionLog:o};if(l.stepwise){let e=await yD(u);return $(t.signal),i.performance.totalMs=Date.now()-r,t.onTrace?.(i),{type:`result`,recommendations:e.steps.flatMap(e=>e.recommendations),confidence:e.confidence,routingReason:l.routingReason,candidatePool:e.candidatePool,intent:c,degradations:[...i.degradations],steps:e.steps,warnings:e.warnings}}let d=KT(c),f=Date.now(),p=_E(l.recall,c,a,l.topN);i.performance.recallMs=Date.now()-f,o.push(`[recall] strategy=${l.recall} pool=${p.length}`);let m=Date.now(),h=await NE(l.score,p,u,d);$(t.signal),i.performance.scoreMs=Date.now()-m,o.push(`[score] strategy=${l.score} top=${h.slice(0,3).map(e=>`${e.model.model}(${e.finalScore.toFixed(2)})`).join(`, `)}`);let g=Date.now(),_=zE(l.rank,h,l.topN,l.fairness,c);i.performance.rankMs=Date.now()-g,o.push(`[rank] ${_.map(e=>`${e.model.model}/${e.slot}`).join(`, `)}`);let v=Date.now(),y=await qE(l.explain,_,u);return $(t.signal),i.performance.explainMs=Date.now()-v,i.performance.totalMs=Date.now()-r,t.onTrace?.(i),{type:`result`,recommendations:y,confidence:bD(u,h),routingReason:l.routingReason,candidatePool:p.length,intent:c,degradations:[...i.degradations]}}const SD=/* @__PURE__ */ new Set([`bailian-model-recommend`]);function CD(){let e=(process.env.BAILIAN_SKILL_EXCLUDE??``).split(`,`).map(e=>e.trim()).filter(Boolean);return/* @__PURE__ */ new Set([...SD,...e])}function wD(){return process.env.BAILIAN_SKILLS_DIR||w(Rt(),`skills`)}function TD(e){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!t)return{};let n=t[1].split(/\r?\n/),r={},i=``,a=!1;for(let e of n){if(a&&/^\s+/.test(e)){r[i]+=(r[i]?` `:``)+e.trim();continue}a=!1;let t=e.match(/^([a-zA-Z_][\w-]*)\s*:\s*(.*)/);if(!t)continue;let[,n,o]=t;o===`>-`||o===`|`||o===`>`||o===`|-`?(i=n,r[n]=``,a=!0):r[n]=o.trim()}return r}function ED(){let e=wD();if(!x(e))return[];let t=[],n;try{n=ye(e)}catch{return[]}let r=CD();for(let i of n){let n=w(e,i),a=w(n,`SKILL.md`);if(!x(a))continue;let o;try{o=ve(a,`utf-8`)}catch{continue}let s=TD(o),c=s.name||i;if(r.has(i)||r.has(c))continue;let l=s.description||``;l&&t.push({name:c,description:l,basePath:n})}return t}function DD(e){if(e.length===0)return``;let t=[`## Available Skills`,"When the user's request matches a skill's description, call the `use_skill` tool with that skill's name to load its full instructions.",``],n=0;for(let r of e){let e=r.description,i=8e3-n;i<=0?e=`(description truncated)`:e.length>i&&(e=e.slice(0,i)+`…`),n+=e.length,t.push(`- **${r.name}**: ${e}`)}return t.join(`
245
- `)}const OD=65536;function kD(e,t){let n=AD(wD());if(!n)return{error:`skills directory not found`};let r=t?AD(t)??n:n,i=je(r,e);if(!jD(i,n))return{error:`path escapes the skills sandbox: ${e}`};let a=AD(i);return a&&!jD(a,n)?{error:`symlink escapes the skills sandbox: ${e}`}:{resolved:i}}function AD(e){try{return C(e)}catch{return}}function jD(e,t){return e===t||e.startsWith(t+Me)}function MD(e,t,n){let{resolved:r,error:i}=kD(e,n);if(i||!r)return{ok:!1,error:i??`resolve failed`};let a=t.toLowerCase();try{let e=Se(r);if(!e.isFile())return{ok:!1,error:`not a regular file`};if(e.size>4194304)return{ok:!1,error:`file too large to search (${e.size} bytes)`};let t=ve(r,`utf-8`).split(`
246
- `),n=[],i=0;for(let e=0;e<t.length;e++)t[e].toLowerCase().includes(a)&&(i++,n.length<40&&n.push(`${e+1}: ${t[e]}`));return{ok:!0,matches:n,totalMatches:i}}catch(e){return{ok:!1,error:e.message}}}function ND(e,t){let{resolved:n,error:r}=kD(e,t);if(r||!n)return{ok:!1,error:r??`resolve failed`};try{if(!Se(n).isFile())return{ok:!1,error:`not a regular file`};let e=ve(n),t=e.length>OD;return{ok:!0,content:e.subarray(0,OD).toString(`utf-8`),truncated:t}}catch(e){return{ok:!1,error:e.message}}}function PD(e){return{originalInput:e,clarifications:[]}}function FD(e){if(e.clarifications.length===0)return e.originalInput;let t=e.clarifications.map(e=>`- ${e.question} → ${e.answer}`);return`${e.originalInput}\n\n补充说明:\n${t.join(`
247
- `)}`}const ID=[{type:`function`,function:{name:`recommend`,description:`Recommend models for the user's request. Takes no arguments: the system automatically passes the user's original request plus every answer collected via ask_user. Returns top-N recommendations + decision signals (confidence/candidatePool), or need_clarify (user clarification required). Also covers comparison/alternative requests.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`use_skill`,description:`Load a skill's full instructions (SKILL.md) by name. Use this when the user's request matches a skill in the Available Skills list — e.g. asking about a specific model's usage, API parameters, calling examples, pricing details, or any documentation lookup. Returns the skill's instructions and its base path; then follow those instructions using read_file.`,parameters:{type:`object`,properties:{skill:{type:`string`,description:`The skill name from the Available Skills list`}},required:[`skill`]}}},{type:`function`,function:{name:`search_files`,description:`Search a file inside the loaded skill for a keyword (case-insensitive substring) and return the matching lines. PREFERRED over read_file for large data files like models.jsonl or families.jsonl — those are truncated when read whole, but search scans the full file. Example: search_files(path='models/models.jsonl', pattern='qwen-image').`,parameters:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the skill's base path`},pattern:{type:`string`,description:`Keyword to search for (case-insensitive substring)`}},required:[`path`,`pattern`]}}},{type:`function`,function:{name:`read_file`,description:`Read a file inside the loaded skill's directory (or the skills root). Use relative paths as instructed by the skill's SKILL.md (e.g. 'models/models.jsonl', 'wiki/index.md'). Only use after loading a skill via use_skill.`,parameters:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the skill's base path`}},required:[`path`]}}},{type:`function`,function:{name:`ask_user`,description:`Ask the user a multiple-choice question to resolve ambiguity. Only use when different choices lead to completely different recommendations; max 2 rounds.`,parameters:{type:`object`,properties:{question:{type:`string`},options:{type:`array`,items:{type:`string`},maxItems:4},default_if_skip:{type:`string`}},required:[`question`,`options`,`default_if_skip`]}}}];async function LD(e,t,n){$(t.signal);let r;try{if(r=e.function.arguments.trim()?JSON.parse(e.function.arguments):{},!r||typeof r!=`object`||Array.isArray(r))throw Error(`参数必须是对象`)}catch{return{result:JSON.stringify({error:`invalid tool arguments`})}}switch(e.function.name){case`recommend`:{t.onProgress?.(`running recommendation engine`);let e=await xD(FD(n),t);if(e.type===`need_clarify`)return{recommendResult:e,result:JSON.stringify({type:`need_clarify`,question:e.question,options:e.options,default_if_skip:e.defaultIfSkip,impact:e.impact})};let r=e=>({model:e.model,name:e.name,reason:e.reason,highlights:e.highlights,slot:e.slot}),i=e.steps?{steps:e.steps.map(e=>({index:e.index,step:e.step,io:`${e.inputModality.join(`/`)} → ${e.outputModality.join(`/`)}`,confidence:e.confidence,recommendations:e.recommendations.map(r)})),warnings:e.warnings?.length?e.warnings:void 0}:{recommendations:e.recommendations.map(r)};return{result:JSON.stringify({type:`result`,confidence:e.confidence,routingReason:e.routingReason,candidatePool:e.candidatePool,...i}),recommendResult:e}}case`use_skill`:{let e=typeof r.skill==`string`?r.skill.trim():``;if(!e)return{result:JSON.stringify({error:`missing skill name`})};let i=ED(),a=i.find(t=>t.name===e);if(!a){let t=i.map(e=>e.name);return{result:JSON.stringify({error:`Skill "${e}" not found. Available skills: ${t.join(`, `)||`(none)`}`})}}t.onProgress?.(`matched skill "${a.name}"`);let o;try{o=ve(w(a.basePath,`SKILL.md`),`utf-8`)}catch(e){return{result:JSON.stringify({error:`Failed to read SKILL.md: ${e.message}`})}}return n.activeSkill=a,t.onProgress?.(`loaded skill "${a.name}" (SKILL.md, ${o.length} chars)`),{result:JSON.stringify({type:`skill_loaded`,skill:a.name,basePath:a.basePath,instructions:o})}}case`read_file`:{let e=typeof r.path==`string`?r.path.trim():``;if(!e)return{result:JSON.stringify({error:`missing file path`})};let i=n.activeSkill?.basePath;t.onProgress?.(`reading ${e}`);let a=ND(e,i);return a.ok?(t.onProgress?.(`read ${e} (${a.content?.length??0} chars${a.truncated?`, truncated`:``})`),{result:JSON.stringify({type:`file_content`,path:e,truncated:a.truncated??!1,content:a.content})}):(t.onProgress?.(`read failed: ${a.error}`),{result:JSON.stringify({error:a.error})})}case`search_files`:{let e=typeof r.path==`string`?r.path.trim():``,i=typeof r.pattern==`string`?r.pattern.trim():``;if(!e||!i)return{result:JSON.stringify({error:`missing path or pattern`})};t.onProgress?.(`searching ${e} for "${i}"`);let a=MD(e,i,n.activeSkill?.basePath);return a.ok?(t.onProgress?.(`search ${e}: ${a.totalMatches} match(es)`),{result:JSON.stringify({type:`search_results`,path:e,pattern:i,totalMatches:a.totalMatches,returned:a.matches?.length??0,matches:a.matches})}):(t.onProgress?.(`search failed: ${a.error}`),{result:JSON.stringify({error:a.error})})}case`ask_user`:{let e=typeof r.question==`string`?r.question:``;if(!e.trim()||!Array.isArray(r.options)||!r.options.every(e=>typeof e==`string`)||typeof r.default_if_skip!=`string`)return{result:JSON.stringify({error:`invalid clarification question/options/default`})};let i=await t.interaction.ask({signal:t.signal,question:e,options:Array.isArray(r.options)?r.options:[],defaultIfSkip:typeof r.default_if_skip==`string`?r.default_if_skip:``});return $(t.signal),i.trim()&&n.clarifications.push({question:e,answer:i.trim()}),{result:JSON.stringify({type:`user_answer`,answer:i,note:`Recorded. Call recommend again (no arguments) to apply it.`})}}default:return{result:JSON.stringify({error:`unknown tool: ${e.function.name}`})}}}function RD(){let e=DD(ED());return`You are an AI model selection assistant for Alibaba Cloud Model Studio. You help users find the best model via tools.
319
+ `)}`}],{maxTokens:2048,stage:`step-explain`,signal:t.signal}))}catch(n){if($(t.signal),PD(n,`explain`).kind===`cancelled`)throw n;return t.trace.degradations.push(MD(`explain`,`step-explain→template-text`,PD(n,`explain`))),e.map(_k)}let r=/* @__PURE__ */ new Map;for(let e of n.steps??[])typeof e.index==`number`&&r.set(e.index,new Map((e.items??[]).map(e=>[e.model,e])));return e.map(e=>{let t=_k(e),n=r.get(e.step.index);return t.map(e=>{let t=n?.get(e.model);return t?.reason?{...e,reason:t.reason,highlights:t.highlights?.length?t.highlights:e.highlights}:e})})}function yk(e){return e.inferenceMetadata?.request_modality??[]}function bk(e){return e.inferenceMetadata?.response_modality??[]}function xk(e,t){return t.length===0||e.length===0||t.some(t=>e.includes(t))}function Sk(e,t,n){return e.capabilities.includes(t.primaryCapability)?n===`capability-only`?!0:xk(bk(e),t.outputModality)?n===`relaxed-input`||xk(yk(e),t.inputModality):!1:!1}const Ck={向量检索:`语义重排`};function wk(e,t){let n=e.filter(t);return n.length>=2?n:e}function Tk(e,t,n){let r=oO(e,t);for(let t of[`strict`,`relaxed-input`,`capability-only`]){let i=n.filter(n=>Sk(n,e,t));if(i.length<2)continue;let a=e.scene;if(a){i=wk(i,e=>e.profile?.scenes?.includes(a)??!1);let e=Ck[a];e&&(i=wk(i,t=>!(t.profile?.scenes?.includes(e)??!1)))}return i=wk(i,e=>qD([e],r).length>0),{models:i,gate:t}}return{models:n.filter(t=>Sk(t,e,`capability-only`)),gate:`capability-only`}}const Ek={role:.35,scene:.2,tier:.2,price:.15,extras:.1},Dk=/纯文[字本]|无图|仅[用靠]?文字|只有文字|无参考/;function Ok(e,t){if(t.inputModality.length>0&&t.inputModality.every(e=>e===`Text`)&&t.outputModality.some(e=>e===`Image`||e===`Video`)&&(e.profile?.notSuitableFor??[]).some(e=>Dk.test(e)))return .25;let n=e.profile?.pipelineRole??[];if(n.length===0)return .5;let r=e=>t.outputModality.length===0||t.outputModality.includes(e),i=e=>t.inputModality.length===0||t.inputModality.includes(e);return n.some(e=>i(e.from)&&r(e.to))?1:n.some(e=>r(e.to))?.5:0}function kk(e,t){let n=e.profile?.familyTier;return n?{flagship:{flagship:1,balanced:.6,lightweight:.3},"cost-optimized":{lightweight:1,balanced:.7,flagship:.4},balanced:{balanced:1,flagship:.85,lightweight:.7}}[t.qualityPreference]?.[n]??.7:.7}function Ak(e){let t=e.prices?.[0],n=t?.price?Number.parseFloat(t.price):NaN;return Number.isFinite(n)?{value:n,unit:t.unit}:void 0}function jk(e,t){let n=/* @__PURE__ */ new Map;for(let t of e){let e=Ak(t);e&&n.set(e.unit,(n.get(e.unit)??0)+1)}let r=[...n.entries()].sort((e,t)=>t[1]-e[1])[0]?.[0],i=e.map(Ak).filter(e=>e!==void 0&&e.unit===r).map(e=>e.value),a=Math.min(...i),o=Math.max(...i);return e=>{let n=Ak(e);if(!n||n.unit!==r||i.length<2||o===a)return .5;let s=1-(n.value-a)/(o-a);return t.budget===`low`?s:t.budget===`high`?1-s*.5:.5+s*.5}}function Mk(e,t,n){let r=t.capabilities.filter(e=>e!==t.primaryCapability),i=r.length+n.length;return i===0?1:(r.filter(t=>e.capabilities.includes(t)).length+n.filter(t=>e.features.includes(t)).length)/i}function Nk(e,t,n){let r=oO(t,n),i=aO(t,n),a=jk(e,n);return e.map(e=>{let o=Ok(e,t),s=i.length===0||(e.profile?.scenes??[]).some(e=>i.includes(e))?1:.3,c=Ek.role*o+Ek.scene*s+Ek.tier*kk(e,n)+Ek.price*a(e)+Ek.extras*Mk(e,t,r.requiredFeatures);return e.profile?.profileCompleteness===`structured-only`&&(c*=.9),{model:e,score:c,role:o}}).sort((e,t)=>t.score-e.score||(Ak(e.model)?.value??1/0)-(Ak(t.model)?.value??1/0))}function Pk(e){let[t,...n]=e;if(!t)return[];let r=n.filter(e=>e.role>=t.role),i=r.length>0?r:n,a=e=>e.model.profile?.familyTier??`unknown`,o=e=>e.model.family??e.model.provider,s=i.find(e=>a(e)!==a(t))??i.find(e=>o(e)!==o(t))??i[0];return s?[t,s]:[t]}const Fk={Text:`文本`,Image:`图片`,Video:`视频`,Audio:`音频`};function Ik(e,t){let n=[];for(let r=1;r<e.length;r++){let i=t[r-1],a=t[r];if(!i||!a)continue;let o=bk(i).length?bk(i):e[r-1].outputModality,s=e[r].inputModality.filter(e=>o.includes(e));if(s.length===0)continue;let c=yk(a);if(c.length>0&&!s.some(e=>c.includes(e))){let e=s.map(e=>Fk[e]??e).join(`/`);n.push(`第${r}步 ${i.name} 输出${e},但第${r+1}步首选 ${a.name} 不接受${e}输入,衔接时需要转换或换用备选`)}}return n}function Lk(e,t){return!t||e.models.length<2||e.gate===`capability-only`?`low`:e.gate===`strict`&&e.models.length>=3&&t.role===1?`high`:`medium`}const Rk=[`low`,`medium`,`high`];function zk(e){return e.reduce((e,t)=>Rk.indexOf(t)<Rk.indexOf(e)?t:e,`high`)}async function Bk(e){let t=rO(e.intent.segments),n=EO(e.models.filter(WD),e.intent.modelPreference?.excludes??[]),r=Date.now(),i=t.map(t=>Tk(t,e.intent,n));e.trace.performance.recallMs=Date.now()-r;for(let n=0;n<t.length;n++)e.decisionLog?.push(`[step ${n+1} recall] ${t[n].label}: pool=${i[n].models.length} gate=${i[n].gate} scene=${t[n].scene??`-`}`);let a=Date.now(),o=t.map((t,n)=>Nk(i[n].models,t,e.intent));e.trace.performance.scoreMs=Date.now()-a;for(let n=0;n<t.length;n++){let r=o[n].slice(0,3).map(e=>`${e.model.model}(${e.score.toFixed(2)},role=${e.role})`).join(`, `);e.decisionLog?.push(`[step ${n+1} score] ${t[n].label}: ${r}`)}let s=Date.now(),c=o.map(t=>Pk(t).slice(0,e.topN));e.trace.performance.rankMs=Date.now()-s;for(let n=0;n<t.length;n++)e.decisionLog?.push(`[step ${n+1} pick] ${t[n].label}: ${c[n].map(e=>e.model.model).join(` + `)}`);let l=t.map((e,t)=>({step:e,candidates:c[t].map((e,t)=>({model:e.model,hardScore:e.score,finalScore:e.score,rank:t+1,slot:t===0?`primary`:`alternative`}))})),u=Date.now(),d=await vk(l,e);e.trace.performance.explainMs=Date.now()-u;let f=t.map((e,t)=>({index:e.index,step:e.label,inputModality:e.inputModality,outputModality:e.outputModality,capabilities:e.capabilities,recommendations:d[t],candidatePool:i[t].models.length,confidence:Lk(i[t],o[t][0]),gate:i[t].gate}));return{steps:f,warnings:Ik(t,c.map(e=>e[0]?.model)),candidatePool:i.reduce((e,t)=>e+t.models.length,0),confidence:zk(f.map(e=>e.confidence))}}function Vk(e,t){let{plan:n,intent:r}=e;if(n.recall===`template`&&r.sceneConfidence>=.8)return`high`;if(t.length<5&&n.recall!==`forced`)return`low`;let i=[...t].sort((e,t)=>t.finalScore-e.finalScore);return(i[0]?i[0].finalScore-(i[1]?.finalScore??0):0)>.2&&(i[0]?.finalScore??0)>.6||n.recall===`forced`?`high`:`medium`}async function Hk(e,t,n){$(t.signal);let r=Date.now(),i={timestamp:(/* @__PURE__ */ new Date()).toISOString(),input:e,performance:{llmCalls:0},degradations:[]},a=await t.catalog();$(t.signal);let o=t.decisionLog??[],s=Date.now(),c;if(n)c=n;else{i.performance.llmCalls++;try{c=await UD(t.llm,e,t.signal),$(t.signal)}catch(e){let n=PD(e,`intent`);throw i.performance.intentMs=Date.now()-s,i.performance.totalMs=Date.now()-r,i.failure={stage:`intent`,kind:n.kind,status:n.status,code:n.code,requestId:n.requestId,message:n.message},t.onTrace?.(i),n}}i.performance.intentMs=Date.now()-s,i.matchedScenes=c.matchedScenes,i.sceneConfidence=c.sceneConfidence,o.push(`[intent] complexity=${c.complexity} scenes=[${c.matchedScenes.join(`,`)}] conf=${c.sceneConfidence} caps=[${c.requiredCapabilities.join(`,`)}] budget=${c.budget} quality=${c.qualityPreference}`);let l=bO(c,a,t.topN);if(i.routingReason=l.routingReason,o.push(`[route] ${l.routingReason}${l.clarify?` → clarify`:``}`),l.clarify)return i.performance.totalMs=Date.now()-r,t.onTrace?.(i),{type:`need_clarify`,...l.clarify,intent:c};let u={input:e,intent:c,models:a,plan:l,topN:l.topN,llm:t.llm,signal:t.signal,trace:i,decisionLog:o};if(l.stepwise){let e=await Bk(u);return $(t.signal),i.performance.totalMs=Date.now()-r,t.onTrace?.(i),{type:`result`,recommendations:e.steps.flatMap(e=>e.recommendations),confidence:e.confidence,routingReason:l.routingReason,candidatePool:e.candidatePool,intent:c,degradations:[...i.degradations],steps:e.steps,warnings:e.warnings}}let d=pO(c),f=Date.now(),p=RO(l.recall,c,a,l.topN);i.performance.recallMs=Date.now()-f,o.push(`[recall] strategy=${l.recall} pool=${p.length}`);let m=Date.now(),h=await ek(l.score,p,u,d);$(t.signal),i.performance.scoreMs=Date.now()-m,o.push(`[score] strategy=${l.score} top=${h.slice(0,3).map(e=>`${e.model.model}(${e.finalScore.toFixed(2)})`).join(`, `)}`);let g=Date.now(),_=ok(l.rank,h,l.topN,l.fairness,c);i.performance.rankMs=Date.now()-g,o.push(`[rank] ${_.map(e=>`${e.model.model}/${e.slot}`).join(`, `)}`);let v=Date.now(),y=await mk(l.explain,_,u);return $(t.signal),i.performance.explainMs=Date.now()-v,i.performance.totalMs=Date.now()-r,t.onTrace?.(i),{type:`result`,recommendations:y,confidence:Vk(u,h),routingReason:l.routingReason,candidatePool:p.length,intent:c,degradations:[...i.degradations]}}const Uk=/* @__PURE__ */ new Set([`bailian-model-recommend`]);function Wk(){let e=(process.env.BAILIAN_SKILL_EXCLUDE??``).split(`,`).map(e=>e.trim()).filter(Boolean);return/* @__PURE__ */ new Set([...Uk,...e])}function Gk(){return process.env.BAILIAN_SKILLS_DIR||T(qt(),`skills`)}function Kk(e){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---/);if(!t)return{};let n=t[1].split(/\r?\n/),r={},i=``,a=!1;for(let e of n){if(a&&/^\s+/.test(e)){r[i]+=(r[i]?` `:``)+e.trim();continue}a=!1;let t=e.match(/^([a-zA-Z_][\w-]*)\s*:\s*(.*)/);if(!t)continue;let[,n,o]=t;o===`>-`||o===`|`||o===`>`||o===`|-`?(i=n,r[n]=``,a=!0):r[n]=o.trim()}return r}function qk(){let e=Gk();if(!S(e))return[];let t=[],n;try{n=be(e)}catch{return[]}let r=Wk();for(let i of n){let n=T(e,i),a=T(n,`SKILL.md`);if(!S(a))continue;let o;try{o=ye(a,`utf-8`)}catch{continue}let s=Kk(o),c=s.name||i;if(r.has(i)||r.has(c))continue;let l=s.description||``;l&&t.push({name:c,description:l,basePath:n})}return t}function Jk(e){if(e.length===0)return``;let t=[`## Available Skills`,"When the user's request matches a skill's description, call the `use_skill` tool with that skill's name to load its full instructions.",``],n=0;for(let r of e){let e=r.description,i=8e3-n;i<=0?e=`(description truncated)`:e.length>i&&(e=e.slice(0,i)+`…`),n+=e.length,t.push(`- **${r.name}**: ${e}`)}return t.join(`
320
+ `)}const Yk=65536;function Xk(e,t){let n=Zk(Gk());if(!n)return{error:`skills directory not found`};let r=t?Zk(t)??n:n,i=Pe(r,e);if(!Qk(i,n))return{error:`path escapes the skills sandbox: ${e}`};let a=Zk(i);return a&&!Qk(a,n)?{error:`symlink escapes the skills sandbox: ${e}`}:{resolved:i}}function Zk(e){try{return Se(e)}catch{return}}function Qk(e,t){return e===t||e.startsWith(t+Fe)}function $k(e,t,n){let{resolved:r,error:i}=Xk(e,n);if(i||!r)return{ok:!1,error:i??`resolve failed`};let a=t.toLowerCase();try{let e=Te(r);if(!e.isFile())return{ok:!1,error:`not a regular file`};if(e.size>4194304)return{ok:!1,error:`file too large to search (${e.size} bytes)`};let t=ye(r,`utf-8`).split(`
321
+ `),n=[],i=0;for(let e=0;e<t.length;e++)t[e].toLowerCase().includes(a)&&(i++,n.length<40&&n.push(`${e+1}: ${t[e]}`));return{ok:!0,matches:n,totalMatches:i}}catch(e){return{ok:!1,error:e.message}}}function eA(e,t){let{resolved:n,error:r}=Xk(e,t);if(r||!n)return{ok:!1,error:r??`resolve failed`};try{if(!Te(n).isFile())return{ok:!1,error:`not a regular file`};let e=ye(n),t=e.length>Yk;return{ok:!0,content:e.subarray(0,Yk).toString(`utf-8`),truncated:t}}catch(e){return{ok:!1,error:e.message}}}function tA(e){return{originalInput:e,clarifications:[]}}function nA(e){if(e.clarifications.length===0)return e.originalInput;let t=e.clarifications.map(e=>`- ${e.question} → ${e.answer}`);return`${e.originalInput}\n\n补充说明:\n${t.join(`
322
+ `)}`}const rA=[{type:`function`,function:{name:`recommend`,description:`Recommend models for the user's request. Takes no arguments: the system automatically passes the user's original request plus every answer collected via ask_user. Returns top-N recommendations + decision signals (confidence/candidatePool), or need_clarify (user clarification required). Also covers comparison/alternative requests.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`use_skill`,description:`Load a skill's full instructions (SKILL.md) by name. Use this when the user's request matches a skill in the Available Skills list — e.g. asking about a specific model's usage, API parameters, calling examples, pricing details, or any documentation lookup. Returns the skill's instructions and its base path; then follow those instructions using read_file.`,parameters:{type:`object`,properties:{skill:{type:`string`,description:`The skill name from the Available Skills list`}},required:[`skill`]}}},{type:`function`,function:{name:`search_files`,description:`Search a file inside the loaded skill for a keyword (case-insensitive substring) and return the matching lines. PREFERRED over read_file for large data files like models.jsonl or families.jsonl — those are truncated when read whole, but search scans the full file. Example: search_files(path='models/models.jsonl', pattern='qwen-image').`,parameters:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the skill's base path`},pattern:{type:`string`,description:`Keyword to search for (case-insensitive substring)`}},required:[`path`,`pattern`]}}},{type:`function`,function:{name:`read_file`,description:`Read a file inside the loaded skill's directory (or the skills root). Use relative paths as instructed by the skill's SKILL.md (e.g. 'models/models.jsonl', 'wiki/index.md'). Only use after loading a skill via use_skill.`,parameters:{type:`object`,properties:{path:{type:`string`,description:`File path relative to the skill's base path`}},required:[`path`]}}},{type:`function`,function:{name:`ask_user`,description:`Ask the user a multiple-choice question to resolve ambiguity. Only use when different choices lead to completely different recommendations; max 2 rounds.`,parameters:{type:`object`,properties:{question:{type:`string`},options:{type:`array`,items:{type:`string`},maxItems:4},default_if_skip:{type:`string`}},required:[`question`,`options`,`default_if_skip`]}}}];async function iA(e,t,n){$(t.signal);let r;try{if(r=e.function.arguments.trim()?JSON.parse(e.function.arguments):{},!r||typeof r!=`object`||Array.isArray(r))throw Error(`参数必须是对象`)}catch{return{result:JSON.stringify({error:`invalid tool arguments`})}}switch(e.function.name){case`recommend`:{t.onProgress?.(`running recommendation engine`);let e=await Hk(nA(n),t);if(e.type===`need_clarify`)return{recommendResult:e,result:JSON.stringify({type:`need_clarify`,question:e.question,options:e.options,default_if_skip:e.defaultIfSkip,impact:e.impact})};let r=e=>({model:e.model,name:e.name,reason:e.reason,highlights:e.highlights,slot:e.slot}),i=e.steps?{steps:e.steps.map(e=>({index:e.index,step:e.step,io:`${e.inputModality.join(`/`)} → ${e.outputModality.join(`/`)}`,confidence:e.confidence,recommendations:e.recommendations.map(r)})),warnings:e.warnings?.length?e.warnings:void 0}:{recommendations:e.recommendations.map(r)};return{result:JSON.stringify({type:`result`,confidence:e.confidence,routingReason:e.routingReason,candidatePool:e.candidatePool,...i}),recommendResult:e}}case`use_skill`:{let e=typeof r.skill==`string`?r.skill.trim():``;if(!e)return{result:JSON.stringify({error:`missing skill name`})};let i=qk(),a=i.find(t=>t.name===e);if(!a){let t=i.map(e=>e.name);return{result:JSON.stringify({error:`Skill "${e}" not found. Available skills: ${t.join(`, `)||`(none)`}`})}}t.onProgress?.(`matched skill "${a.name}"`);let o;try{o=ye(T(a.basePath,`SKILL.md`),`utf-8`)}catch(e){return{result:JSON.stringify({error:`Failed to read SKILL.md: ${e.message}`})}}return n.activeSkill=a,t.onProgress?.(`loaded skill "${a.name}" (SKILL.md, ${o.length} chars)`),{result:JSON.stringify({type:`skill_loaded`,skill:a.name,basePath:a.basePath,instructions:o})}}case`read_file`:{let e=typeof r.path==`string`?r.path.trim():``;if(!e)return{result:JSON.stringify({error:`missing file path`})};let i=n.activeSkill?.basePath;t.onProgress?.(`reading ${e}`);let a=eA(e,i);return a.ok?(t.onProgress?.(`read ${e} (${a.content?.length??0} chars${a.truncated?`, truncated`:``})`),{result:JSON.stringify({type:`file_content`,path:e,truncated:a.truncated??!1,content:a.content})}):(t.onProgress?.(`read failed: ${a.error}`),{result:JSON.stringify({error:a.error})})}case`search_files`:{let e=typeof r.path==`string`?r.path.trim():``,i=typeof r.pattern==`string`?r.pattern.trim():``;if(!e||!i)return{result:JSON.stringify({error:`missing path or pattern`})};t.onProgress?.(`searching ${e} for "${i}"`);let a=$k(e,i,n.activeSkill?.basePath);return a.ok?(t.onProgress?.(`search ${e}: ${a.totalMatches} match(es)`),{result:JSON.stringify({type:`search_results`,path:e,pattern:i,totalMatches:a.totalMatches,returned:a.matches?.length??0,matches:a.matches})}):(t.onProgress?.(`search failed: ${a.error}`),{result:JSON.stringify({error:a.error})})}case`ask_user`:{let e=typeof r.question==`string`?r.question:``;if(!e.trim()||!Array.isArray(r.options)||!r.options.every(e=>typeof e==`string`)||typeof r.default_if_skip!=`string`)return{result:JSON.stringify({error:`invalid clarification question/options/default`})};let i=await t.interaction.ask({signal:t.signal,question:e,options:Array.isArray(r.options)?r.options:[],defaultIfSkip:typeof r.default_if_skip==`string`?r.default_if_skip:``});return $(t.signal),i.trim()&&n.clarifications.push({question:e,answer:i.trim()}),{result:JSON.stringify({type:`user_answer`,answer:i,note:`Recorded. Call recommend again (no arguments) to apply it.`})}}default:return{result:JSON.stringify({error:`unknown tool: ${e.function.name}`})}}}function aA(){let e=Jk(qk());return`You are an AI model selection assistant for Alibaba Cloud Model Studio. You help users find the best model via tools.
248
323
 
249
324
  ## Workflow
250
325
  1. FIRST, classify the request type:
@@ -276,10 +351,10 @@ ${e?e+`
276
351
  - Ask about business scenarios, NOT technical parameters (e.g. never ask "how many tokens of context do you need")
277
352
  - Never fabricate model names not returned by tools
278
353
  - If the input is NOT a model request (greetings, jokes, casual chat), do NOT call any tool: respond naturally and briefly in Simplified Chinese, then introduce yourself in one sentence as the Bailian model selection assistant — mention that you can recommend models for any scenario (text/image/video/audio, single model or multi-step pipelines), compare models, look up specific models, and find cheaper alternatives — and guide the user with one concrete example question (e.g. "你可以试试问我:推荐一个写代码的模型")
279
- - Everything else — including vague requests like "推荐一个", "有什么好模型", "帮我选个模型" — MUST go through the recommend tool`}async function zD(e,t,n){let r=[{role:`system`,content:RD()},{role:`user`,content:e}],i=PD(e),a=[],o,s=0,c=0,l=e=>{a.push(e),n?.(e)};try{for(let e=0;e<10;e++){c=e,$(t.signal);let n;try{n=await t.llm.chatWithTools(r,ID,{stage:`agent`,signal:t.signal}),$(t.signal)}catch(n){$(t.signal);let r=pT(n,`agent`);if(r.kind===`cancelled`)throw r;if(r.fatal){if(!o)throw r;let n=dT(`agent`,`agent-summary→engine-result`,r);return t.onDiagnostic?.(`[recommend] agent loop failed (${r.tag}), using the recommendation already computed`),l({turn:e,type:`fallback`,reason:`agent_error_existing_result`}),{finalText:``,recommendResult:o,turns:e,degradations:[n],trajectory:a}}t.onDiagnostic?.(`[recommend] agent loop failed (${r.tag}), falling back to engine: ${r.message}`);let s=await xD(FD(i),t);return l({turn:e,type:`fallback`,reason:`agent_error_engine_rerun`}),{finalText:``,recommendResult:s,turns:e,degradations:[dT(`agent`,`agent→engine-rerun`,r)],trajectory:a}}if(!n.toolCalls.length)return l({turn:e,type:`final_answer`,reason:n.content.trim()?`completed`:`empty_answer`}),{finalText:n.content,recommendResult:o,turns:e+1,degradations:[],trajectory:a};r.push({role:`assistant`,content:n.content,tool_calls:n.toolCalls});for(let t of n.toolCalls){let n;try{n=JSON.parse(t.function.arguments||`{}`)}catch{}l({turn:e,type:`tool_call`,callId:t.id,tool:t.function.name,args:n})}for(let a of n.toolCalls)try{if($(t.signal),a.function.name===`ask_user`&&s>=2){let t={error:`clarify budget exhausted; proceed with defaults`};l({turn:e,type:`tool_result`,callId:a.id,tool:a.function.name,status:`rejected`,reason:`clarify_budget`,result:t}),r.push({role:`tool`,tool_call_id:a.id,content:JSON.stringify(t)});continue}let n=await LD(a,t,i);$(t.signal),n.recommendResult&&(o=n.recommendResult);let c=JSON.parse(n.result),u=c.error?`error`:`success`;a.function.name===`ask_user`&&u===`success`&&s++,l({turn:e,type:`tool_result`,callId:a.id,tool:a.function.name,status:u,result:c,resultType:typeof c.type==`string`?c.type:void 0,degradations:n.recommendResult?.type===`result`?n.recommendResult.degradations:void 0}),r.push({role:`tool`,tool_call_id:a.id,content:n.result})}catch(n){let r=t.signal?.aborted||pT(n,`agent`).kind===`cancelled`;throw l({turn:e,type:`tool_result`,callId:a.id,tool:a.function.name,status:r?`cancelled`:`error`,reason:n instanceof Error?n.message:String(n)}),n}}return c=10,$(t.signal),l({turn:10,type:`fallback`,reason:`turn_budget`}),o?{finalText:``,recommendResult:o,turns:10,degradations:[],trajectory:a}:{finalText:``,recommendResult:await xD(FD(i),t),turns:10,degradations:[],trajectory:a}}catch(e){let n=t.signal?.aborted||pT(e,`agent`).kind===`cancelled`,r=new Set(a.filter(e=>e.type===`tool_result`).map(e=>`${e.turn}:${e.callId}`));for(let e of a.filter(e=>e.type===`tool_call`&&!r.has(`${e.turn}:${e.callId}`)))l({turn:e.turn,type:`tool_result`,tool:e.tool,callId:e.callId,status:n?`cancelled`:`rejected`,reason:`run_terminated`});throw l({turn:c,type:n?`cancelled`:`error`,reason:e instanceof Error?e.message:String(e)}),$(t.signal),e}}const BD=`qwen-flash-2025-07-28`;function VD(e){let{baseUrl:t,apiKey:n,defaultModel:r=BD,timeoutMs:i=6e4,enableThinking:a,thinkingStages:o,thinkingLog:s,onThinking:c}=e,l=`${t.replace(/\/$/,``)}/compatible-mode/v1/chat/completions`;async function u(t,r,a){$(r.signal);let o=new AbortController,s=setTimeout(()=>o.abort(),i),c=r.signal?AbortSignal.any([r.signal,o.signal]):o.signal;try{e.onRequest?.(r.stage??`llm`);let i=await(e.fetch??fetch)(l,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${n}`},body:JSON.stringify(t),signal:c});if(!i.ok){let e=await i.text(),t={message:e.slice(0,200)};try{t=JSON.parse(e)}catch{}throw HD(t,i.status,i.headers.get(`x-request-id`)??void 0)}let o=await a(i,c);return $(r.signal),o}catch(e){throw $(r.signal),o.signal.aborted?new lT(`timeout`,`LLM request timed out after ${i}ms`,{cause:e}):e instanceof lT?e:e instanceof SyntaxError?new lT(`parse`,`LLM 响应不是有效 JSON`,{cause:e}):new lT(`network`,`LLM request failed: ${e?.cause?.code??e?.message}`,{cause:e})}finally{clearTimeout(s)}}async function d(e,t={}){return u(e,t,async e=>{let n=await e.json();if(n.error)throw HD(n,void 0,e.headers.get(`x-request-id`)??void 0);let r=n.choices?.[0];if(UD(r?.finish_reason),!r?.message)throw new lT(`parse`,`LLM 响应缺少 message`);if(WD(r.message.tool_calls??[]),!r.message.content?.trim()&&!r.message.tool_calls?.length)throw new lT(`parse`,`LLM 返回空响应`);let i=r.message.reasoning_content;return s&&i&&s.push({stage:t.stage??`llm`,content:i}),n})}async function f(e,t,n={}){let i=n.stage??(t?`agent`:`llm`);return u({model:n.model??r,messages:e.map(GD),...t?{tools:t}:{},temperature:n.temperature??0,max_tokens:n.maxTokens??4096,stream:!0,enable_thinking:!0},{...n,stage:i},async(e,t)=>{if(!e.body)throw new lT(`parse`,`SSE 响应缺少正文`);let n=e.body.getReader(),r=new TextDecoder,a=``,o=``,l=``,u=!1,d=``,f=[],p=/* @__PURE__ */ new Map,m=()=>{if(!f.length)return;let t=f.join(`
280
- `);if(f=[],t.trim()===`[DONE]`){u=!0;return}let n=JSON.parse(t);if(n.error||d===`error`)throw HD(n,void 0,e.headers.get(`x-request-id`)??void 0);let r=n.choices?.find(e=>e.index===0||e.index===void 0);UD(r?.finish_reason);let a=r?.delta;if(a){a.reasoning_content&&(l+=a.reasoning_content,c?.(i,a.reasoning_content)),o+=a.content??``;for(let e of a.tool_calls??[]){let t=e.index;if(t===void 0||!Number.isInteger(t)||t<0)throw new lT(`parse`,`工具片段缺少有效 index`);let n=p.get(t)??{id:``,name:``,arguments:``};if(e.id){if(n.id&&n.id!==e.id)throw new lT(`parse`,`同一工具 index 返回不同 id`);n.id=e.id}n.name+=e.function?.name??``,n.arguments+=e.function?.arguments??``,p.set(t,n)}}},h=e=>{let t=e.replace(/\r$/,``);t?t.startsWith(`data:`)?f.push(t.slice(5).replace(/^ /,``)):t.startsWith(`event:`)&&(d=t.slice(6).trim()):(m(),d=``)},g=()=>{n.cancel().catch(()=>{})};t.addEventListener(`abort`,g,{once:!0});try{for(;!u;){t.throwIfAborted();let{done:e,value:i}=await n.read();t.throwIfAborted(),a+=e?r.decode():r.decode(i,{stream:!0});let o=a.split(`
281
- `);a=o.pop()??``;for(let e of o)if(h(e),u)break;if(e&&(!u&&a&&h(a),u||m(),!u))throw new lT(`parse`,`SSE 在完成标记前断流`)}let e=[...p.entries()].sort(([e],[t])=>e-t).map(([,e])=>({id:e.id,type:`function`,function:{name:e.name,arguments:e.arguments}}));if(WD(e),!o.trim()&&!e.length)throw new lT(`parse`,`SSE 返回空响应`);return s&&l&&s.push({stage:i,content:l}),{content:o,toolCalls:e}}finally{t.removeEventListener(`abort`,g),await n.cancel().catch(()=>{}),n.releaseLock()}})}let p=e=>e?.stage!==void 0&&o?.includes(e.stage)||a===!0;return{async chat(e,t){return p(t)?(await f(e,void 0,t)).content:(await d({model:t?.model??r,messages:e,temperature:t?.temperature??0,max_tokens:t?.maxTokens??4096},{...t})).choices?.[0]?.message?.content??``},async chatJson(e,t){let n=await this.chat(e,t);try{return vE(n)}catch{let r=await this.chat([...e,{role:`assistant`,content:n},{role:`user`,content:`IMPORTANT: Your previous response was not valid JSON. Respond with ONLY a valid JSON object, no other text.`}],t);try{return vE(r)}catch(e){throw new lT(`parse`,`LLM returned invalid JSON twice: ${r.slice(0,120)}`,{cause:e})}}},async chatWithTools(e,t,n){if(p(n))return f(e,t,n);let i=(await d({model:n?.model??r,messages:e.map(GD),tools:t,temperature:0,max_tokens:4096},{...n,stage:n?.stage??`agent`})).choices?.[0]?.message;return{content:i?.content??``,toolCalls:i?.tool_calls??[]}}}}function HD(e,t,n){let r=e&&typeof e==`object`?e:{},i=r.error&&typeof r.error==`object`?r.error:r,a=typeof i.code==`string`?i.code:void 0;return new lT(t?uT(t):/invalid.?api.?key|unauthorized|accessdenied|forbidden/i.test(a??``)?`auth`:/quota|throttl|rate.?limit/i.test(a??``)?`rate_limit`:`http`,`LLM request failed: ${typeof i.message==`string`?i.message:typeof r.error==`string`?r.error:`服务端错误`}`,{status:t,code:a,requestId:typeof r.request_id==`string`?r.request_id:n})}function UD(e){if(e&&e!==`stop`&&e!==`tool_calls`)throw new lT(`parse`,`LLM 响应未完整结束: ${e}`)}function WD(e){let t=/* @__PURE__ */ new Set;for(let n of e){if(!n.id||t.has(n.id)||!n.function?.name||n.type!==`function`)throw new lT(`parse`,`工具调用缺少标识或标识重复`);t.add(n.id);let e;try{e=JSON.parse(n.function.arguments)}catch(e){throw new lT(`parse`,`工具参数不完整`,{cause:e})}if(!e||typeof e!=`object`||Array.isArray(e))throw new lT(`parse`,`工具参数必须是 JSON 对象`)}}function GD(e){let t={role:e.role,content:e.content};return e.tool_call_id&&(t.tool_call_id=e.tool_call_id),e.tool_calls&&(t.tool_calls=e.tool_calls),t}function KD(){return w(Rt(),`skills/bailian-docs-llm-wiki`,`models`)}const qD=/-\d{4}-\d{2}-\d{2}$/;let JD=null,YD=null;function XD(e){if(!x(e))return[];let t=[];for(let n of ve(e,`utf-8`).split(`
282
- `))if(n.trim())try{t.push(JSON.parse(n))}catch{}return t}function ZD(e){let t=new Set(e.map(({model:e})=>e));return e.filter(({model:e})=>{let n=e.replace(qD,``);return n===e||!t.has(n)})}async function QD(e=KD()){if(JD)return JD;let t=XD(w(e,`models.jsonl`));if(t.length===0)throw Error(`No model catalog found at ${w(e,`models.jsonl`)}. Run any bl advisor/agent command once to sync wiki data.`);return JD=ZD(t),JD}async function $D(e=KD()){if(YD)return YD;let t=XD(w(e,`families.jsonl`));return YD=new Map(t.map(e=>[e.slug,e])),YD}function eO(){JD=null,YD=null}function tO(){return{async ask({question:e,options:t,defaultIfSkip:n,signal:r}){$(r);let i=We({input:process.stdin,output:process.stderr});try{for(process.stderr.write(`\n${e}\n`),t.forEach((e,t)=>{let r=e===n;process.stderr.write(` ${t+1}. ${e}${r?` (default)`:``}\n`)}),process.stderr.write(` 输入序号选择,回车使用默认,或直接输入文字描述你的需求
283
- `);;){let e=(await i.question(`Select: `,{signal:r})).trim();if($(r),!e)return n;if(/^\d+$/.test(e)){let n=Number.parseInt(e,10)-1;if(n>=0&&n<t.length)return t[n];process.stderr.write(` 请输入 1-${t.length} 之间的序号,或直接输入文字描述\n`);continue}return e}}finally{i.close()}}}}function nO(){return{async ask({question:e,defaultIfSkip:t,signal:n}){return $(n),process.stderr.write(`[recommend] non-interactive, "${e}" → default: ${t}\n`),t}}}function rO(){return w(Rt(),`skills`)}function iO(){return w(rO(),`skill-lock.json`)}function aO(){return{version:1,skills:{}}}function oO(){let e=iO();if(!x(e))return aO();try{let t=JSON.parse(ve(e,`utf-8`));return t?.version!==1||typeof t.skills!=`object`||t.skills===null?aO():t}catch{return aO()}}function sO(e){_e(rO(),{recursive:!0}),we(iO(),JSON.stringify(e,null,2)+`
284
- `)}function cO(e,t){let n=oO();n.skills[e]={...n.skills[e],...t},sO(n)}const lO=`BL_SKIP_HOST_AGENTS`,uO=[`CLAUDE_CONFIG_DIR`,`CODEX_HOME`,`VIBE_HOME`,`HERMES_HOME`,`AUTOHAND_HOME`,`GROK_HOME`,`DSH_HOME`,`OPENCLAW_CONFIG_PATH`,`ZCODE_HOME`,`APPDATA`,`LOCALAPPDATA`,`FLATPAK_XDG_CONFIG_HOME`,`PI_CODING_AGENT_DIR`];function dO(){let e=Ge(),t=process.cwd(),n=process.env.XDG_CONFIG_HOME||w(e,`.config`),r=(t,n,r)=>({id:t,displayName:n,skillsDir:w(e,r,`skills`),detectDirs:[w(e,r)]}),i=(t,n)=>t?.trim()||w(e,n),a=(e,t,n)=>({id:e,displayName:t,skillsDir:w(n,`skills`),detectDirs:[n]}),o=[`.openclaw`,`.clawdbot`,`.moltbot`].map(t=>w(e,t)),s=o.find(e=>x(e))??o[0],c=[w(n,`zed`)],l=process.env.APPDATA?.trim();l&&c.push(w(l,`Zed`));let u=process.env.FLATPAK_XDG_CONFIG_HOME?.trim();u&&c.push(w(u,`zed`));let d=i(process.env.CODEX_HOME,`.codex`);return[{id:`universal`,displayName:`Universal (~/.agents/skills)`,skillsDir:w(e,`.agents`,`skills`),detectDirs:[w(e,`.agents`),w(e,`.cline`),w(e,`.dexto`),w(e,`.firebender`),w(e,`.kimi-code`),w(e,`.kimi`),w(e,`.loaf`),w(e,`.warp`),...c]},{id:`universal-xdg`,displayName:`Universal (XDG agents/skills)`,skillsDir:w(n,`agents`,`skills`),detectDirs:[w(n,`agents`),w(n,`amp`),w(t,`.replit`)]},r(`adal`,`AdaL`,`.adal`),r(`aider-desk`,`AiderDesk`,`.aider-desk`),r(`antigravity`,`Antigravity`,`.gemini/antigravity`),r(`antigravity-cli`,`Antigravity CLI`,`.gemini/antigravity-cli`),{id:`astrbot`,displayName:`AstrBot`,skillsDir:w(e,`.astrbot`,`data`,`skills`),detectDirs:[w(t,`data`,`skills`),w(e,`.astrbot`)]},a(`autohand-code`,`Autohand Code CLI`,i(process.env.AUTOHAND_HOME,`.autohand`)),r(`augment`,`Augment`,`.augment`),r(`bob`,`IBM Bob`,`.bob`),a(`claude-code`,`Claude Code`,i(process.env.CLAUDE_CONFIG_DIR,`.claude`)),r(`codearts-agent`,`CodeArts Agent`,`.codeartsdoer`),{id:`codebuddy`,displayName:`CodeBuddy`,skillsDir:w(e,`.codebuddy`,`skills`),detectDirs:[w(t,`.codebuddy`),w(e,`.codebuddy`)]},r(`codemaker`,`Codemaker`,`.codemaker`),r(`codestudio`,`Code Studio`,`.codestudio`),{id:`codex`,displayName:`Codex`,skillsDir:w(d,`skills`),detectDirs:[d,`/etc/codex`]},r(`command-code`,`Command Code`,`.commandcode`),{id:`continue`,displayName:`Continue`,skillsDir:w(e,`.continue`,`skills`),detectDirs:[w(t,`.continue`),w(e,`.continue`)]},r(`cortex`,`Cortex Code`,`.snowflake/cortex`),r(`crush`,`Crush`,`.config/crush`),r(`cursor`,`Cursor`,`.cursor`),{id:`deepagents`,displayName:`Deep Agents`,skillsDir:w(e,`.deepagents`,`agent`,`skills`),detectDirs:[w(e,`.deepagents`)]},{id:`devin`,displayName:`Devin for Terminal`,skillsDir:w(n,`devin`,`skills`),detectDirs:[w(n,`devin`)]},r(`droid`,`Droid`,`.factory`),a(`dsh`,`DeepSeek DSH`,i(process.env.DSH_HOME,`.dsh`)),r(`forgecode`,`ForgeCode`,`.forge`),r(`gemini-cli`,`Gemini CLI`,`.gemini`),r(`github-copilot`,`GitHub Copilot`,`.copilot`),{id:`goose`,displayName:`Goose`,skillsDir:w(n,`goose`,`skills`),detectDirs:[w(n,`goose`)]},a(`grok`,`Grok Build`,i(process.env.GROK_HOME,`.grok`)),a(`hermes`,`Hermes Agent`,mw(e)),r(`iflow-cli`,`iFlow CLI`,`.iflow`),r(`inference-sh`,`inference.sh`,`.inferencesh`),{id:`jazz`,displayName:`Jazz`,skillsDir:w(e,`.jazz`,`skills`),detectDirs:[w(e,`.jazz`),w(t,`.jazz`)]},r(`junie`,`Junie`,`.junie`),r(`kilo`,`Kilo Code`,`.kilocode`),{id:`kimchi`,displayName:`Kimchi`,skillsDir:w(e,`.config`,`kimchi`,`harness`,`skills`),detectDirs:[w(e,`.config`,`kimchi`)]},r(`kiro-cli`,`Kiro CLI`,`.kiro`),r(`kode`,`Kode`,`.kode`),r(`lingma`,`Lingma`,`.lingma`),r(`mcpjam`,`MCPJam`,`.mcpjam`),{id:`minimax-code`,displayName:`MiniMax Code`,skillsDir:w(e,`.minimax`,`skills`),detectDirs:[w(e,`.minimax`),`/Applications/MiniMax Code.app`]},a(`mistral-vibe`,`Mistral Vibe`,i(process.env.VIBE_HOME,`.vibe`)),r(`moxby`,`Moxby`,`.moxby`),r(`mux`,`Mux`,`.mux`),r(`neovate`,`Neovate`,`.neovate`),{id:`opencode`,displayName:`OpenCode`,skillsDir:w(n,`opencode`,`skills`),detectDirs:[w(n,`opencode`)]},{id:`openclaw`,displayName:`OpenClaw`,skillsDir:w(s,`skills`),detectDirs:o},r(`openhands`,`OpenHands`,`.openhands`),r(`ona`,`Ona`,`.ona`),r(`pi`,`Pi`,`.pi/agent`),r(`pochi`,`Pochi`,`.pochi`),r(`qoder`,`Qoder`,`.qoder`),r(`qoder-cn`,`Qoder CN`,`.qoder-cn`),r(`qwen-code`,`Qwen Code`,`.qwen`),r(`reasonix`,`Reasonix`,`.reasonix`),r(`rovodev`,`Rovo Dev`,`.rovodev`),r(`roo`,`Roo Code`,`.roo`),{id:`tabnine-cli`,displayName:`Tabnine CLI`,skillsDir:w(e,`.tabnine`,`agent`,`skills`),detectDirs:[w(e,`.tabnine`)]},r(`terramind`,`Terramind`,`.terramind`),r(`tinycloud`,`Tinycloud`,`.tinycloud`),r(`trae`,`Trae`,`.trae`),r(`trae-cli`,`Trae CLI`,`.traecli`),r(`trae-cn`,`Trae CN`,`.trae-cn`),r(`windsurf`,`Windsurf`,`.codeium/windsurf`),r(`workbuddy`,`Tencent WorkBuddy`,`.workbuddy`),{id:`zcode`,displayName:`ZCode`,skillsDir:w(e,`.zcode`,`skills`),detectDirs:[w(e,`.zcode`),`/Applications/ZCode.app`]},r(`zencoder`,`Zencoder`,`.zencoder`)]}function fO(e){let t=je(e);try{return C(t)}catch{let e=[],n=t;for(;n!==Oe(n);){if(x(n))try{return w(C(n),...e.reverse())}catch{break}e.push(De(n)),n=Oe(n)}return t}}function pO(e,t){let n=fO(e),r=fO(t);return n===r||n.startsWith(r+Me)}function mO(e){if(!ke(e)||pO(e,Ge()))return!1;let t=process.env.XDG_CONFIG_HOME?.trim();return!(t&&pO(e,t))}function hO(e){return process.env.BL_SKIP_HOST_AGENTS!==`1`||!mO(e)}function gO(){return dO().filter(e=>e.detectDirs.some(e=>hO(e)&&x(e)))}function _O(e,t){return process.platform===`win32`?e.toLowerCase()===t.toLowerCase():e===t}function vO(e){let t=rO();if(process.platform===`win32`){let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(r+Me)}return e===t||e.startsWith(t+Me)}function yO(e){try{if(!ge(e).isSymbolicLink())return!1;let t=S(e);return vO(ke(t)?t:je(Oe(e),t))}catch{return!1}}function bO(e,t){if(!t.some(t=>_O(t,e)))return!1;try{return ge(e).isDirectory()}catch{return!1}}function xO(e){try{return ge(e).isDirectory()?x(w(e,`SKILL.md`)):!1}catch{return!1}}const SO=`existing file/dir not managed by bl skill`;function CO(e,t=gO(),n=[]){let r=w(rO(),e),i=[];for(let a of t){let t=w(a.skillsDir,e);try{let e=!1;try{ge(t),e=!0}catch{}if(e){if(yO(t))xe(t);else if(bO(t,n))xe(t,{recursive:!0,force:!0});else if(xO(t))xe(t,{recursive:!0,force:!0});else{i.push({agent:a.id,path:t,mode:`skipped`,reason:SO});continue}}_e(a.skillsDir,{recursive:!0});try{Ce(r,t,process.platform===`win32`?`junction`:`dir`),i.push({agent:a.id,path:t,mode:`symlink`})}catch{pe(r,t,{recursive:!0}),i.push({agent:a.id,path:t,mode:`copy`})}}catch(e){i.push({agent:a.id,path:t,mode:`skipped`,reason:e instanceof Error?e.message:String(e)})}}return i}function wO(e,t=gO(),n=[]){let r=CO(e,t,n),i=r.filter(e=>e.mode!==`skipped`),a=i.map(e=>e.path),o=r.filter(e=>e.mode===`skipped`&&e.reason===SO).map(e=>e.path),s=n.filter(e=>!a.some(t=>_O(t,e))&&!o.some(t=>_O(t,e)));return{results:r,linkedAgents:i.map(e=>e.agent),links:[...a,...s]}}function TO(e,t=[]){let n=[],r=new Set(t);for(let t of dO())r.add(w(t.skillsDir,e));for(let e of r)try{let r;try{r=ge(e)}catch{continue}r.isSymbolicLink()?yO(e)&&n.push(e):t.some(t=>_O(t,e))&&n.push(e)}catch{}return n}function EO(e,t=[]){let n=[];for(let r of TO(e,t))try{if(yO(r))xe(r);else if(!ge(r).isSymbolicLink()&&t.some(e=>_O(e,r)))xe(r,{recursive:!0,force:!0});else continue;n.push(r)}catch{}return n}function DO(e){return e.includes(`\\`)||e.includes(`\0`)||e.startsWith(`/`)||/^[a-zA-Z]:[\\/]/.test(e)?!1:!e.split(`/`).includes(`..`)}async function OO(e,t){let n=Je.extract();n.on(`entry`,(e,r,i)=>{if(!DO(e.name)){r.on(`error`,()=>{}),r.resume(),n.destroy(/* @__PURE__ */ Error(`unsafe tar entry: ${e.name}`));return}let a=w(t,e.name);if(e.type===`directory`){_e(a,{recursive:!0}),r.resume(),r.on(`end`,i);return}_e(Oe(a),{recursive:!0});let o=he(a);r.pipe(o),o.on(`finish`,i),o.on(`error`,i)}),await Ke(Ee.from(e),qe(),n)}function kO(e){let t=[],n=r=>{for(let i of ye(r?w(e,r):e,{withFileTypes:!0})){let e=r?`${r}/${i.name}`:i.name;i.isDirectory()?n(e):i.isFile()&&t.push(e)}};n(``),t.sort((e,t)=>e<t?-1:+(e>t));let r=Ve(`sha256`);for(let n of t)r.update(n),r.update(ve(w(e,n)));return`sha256:${r.digest(`hex`)}`}function AO(e,t,n=259){let r,i=a=>{for(let o of ye(a,{withFileTypes:!0}).sort((e,t)=>e.name.localeCompare(t.name))){let s=w(a,o.name),c=Ae(e,s);for(let e of t){let t=w(e,c).length;t>n&&t>(r?.pathLength??0)&&(r={root:e,relativePath:c,pathLength:t})}o.isDirectory()&&i(s)}};for(let e of t)e.length>n&&e.length>(r?.pathLength??0)&&(r={root:e,relativePath:``,pathLength:e.length});return i(e),r}function jO(e){let t=[],n=r=>{for(let i of ye(r,{withFileTypes:!0}).sort((e,t)=>e.name.localeCompare(t.name))){let a=w(r,i.name),o=Ae(e,a);i.isDirectory()?(t.push({relativePath:o,type:`directory`}),n(a)):i.isFile()&&t.push({relativePath:o,type:`file`})}};return n(e),t}function MO(e,t){let n=jO(e),r=new Set(n.map(e=>e.relativePath));_e(t,{recursive:!0});for(let r of n){let n=w(e,r.relativePath),i=w(t,r.relativePath);if(x(i)){let e=ge(i);(!(r.type===`directory`?e.isDirectory():e.isFile())||e.isSymbolicLink())&&xe(i,{recursive:!0,force:!0})}r.type===`directory`?_e(i,{recursive:!0}):(_e(Oe(i),{recursive:!0}),fe(n,i))}let i=jO(t).filter(e=>!r.has(e.relativePath)).sort((e,t)=>t.relativePath.length-e.relativePath.length);for(let e of i)xe(w(t,e.relativePath),{recursive:!0,force:!0})}function NO(e){let t=e?.code;return t===`EPERM`||t===`EBUSY`}function PO(e){try{x(e)&&xe(e,{recursive:!0,force:!0})}catch{}}function FO(e,t,n={}){_e(Oe(t),{recursive:!0});let r=`${t}.old-${Date.now()}`;if(x(t))try{be(t,r)}catch(i){if(!(n.allowInPlaceFallback??process.platform===`win32`)||!NO(i))throw i;try{MO(t,r),MO(e,t),PO(r);return}catch(e){try{x(r)&&MO(r,t)}catch{}throw Error(`Skill directory is in use and could not be updated in place. Close running agent hosts and retry. / Skill 目录正被占用,无法原地更新;请关闭正在运行的 Agent 后重试。 ${e instanceof Error?e.message:String(e)}`,{cause:e})}}try{be(e,t)}catch(e){throw x(r)&&!x(t)&&be(r,t),e}PO(r)}function IO(e){if(e instanceof D){let t=e.api?.httpStatus;if(t!==void 0){if(t===408||t===429)return!0;if(t>=400&&t<500)return!1}return!0}return!0}function LO(e){return e instanceof D&&e.api?.httpStatus===429}function RO(e,t){return Math.min(t*2**(e-1),1e4)}function zO(e){return new Promise(t=>setTimeout(t,e))}async function BO(e,t=3){let n=typeof t==`number`?{attempts:t}:t,r=n.attempts??3,i=n.shouldRetry??IO,a=n.backoffBaseMs??500,o;for(let t=1;t<=r;t++)try{return await e(t)}catch(e){if(o=e,t>=r||!i(e,t))break;LO(e)&&await zO(RO(t,a))}throw o}function VO(){return(process.env.BAILIAN_SKILL_REGISTRY_URL?.trim()||`https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/skills`).replace(/\/+$/,``)}async function HO(e=3e4,t=3){return BO(async()=>{let t=`${VO()}/index.json`,n;try{n=await En.fetch(t,{signal:AbortSignal.timeout(e)})}catch(e){throw new D(`Cannot access skill registry: ${t}`,E.NETWORK,`Check network connectivity; if using a private mirror, verify BAILIAN_SKILL_REGISTRY_URL configuration`,{cause:e})}if(!n.ok)throw new D(`Skill registry returned HTTP ${n.status}: ${t}`,E.NETWORK,n.status===404?`Skill index not yet published or registry URL is incorrect; confirm the publisher has generated index.json`:`Remote error, retry later`);let r;try{r=await n.json()}catch(e){throw new D(`Skill index index.json is not valid JSON`,E.GENERAL,`Remote may be in the middle of publishing, retry later`,{cause:e})}let i=r;if(typeof i!=`object`||!i||typeof i.skills!=`object`||i.skills===null)throw new D(`Skill index index.json has invalid structure`,E.GENERAL,`Retry later or contact the publisher`);return i},{attempts:t})}const UO=/^sha256-[0-9a-f]{64}\.tar\.br$/;function WO(e){let t=e?.object;return t&&UO.test(t)?t:`skill.tar.br`}async function GO(e,t,n=3){return BO(async()=>{let n=`${VO()}/${e}/${WO(t)}`,r;try{r=await En.fetch(n,{signal:AbortSignal.timeout(12e4)})}catch(t){throw new D(`Failed to download skill ${e}: ${n}`,E.NETWORK,`Network error, retryable`,{cause:t})}if(!r.ok)throw new D(`Failed to download skill ${e}: HTTP ${r.status}`,E.NETWORK,r.status===404?`index.json and skill object are temporarily inconsistent (publishing in progress), retry later`:`Remote error, retry later`);return Buffer.from(await r.arrayBuffer())},{attempts:n})}function KO(e){return e.replace(/[\\/:*?"<>|\s]+/g,`-`).replace(/\.\.+/g,`-`).replace(/^[-.]+|[-.]+$/g,``)||`unnamed-skill`}function qO(e){return e.length>0&&KO(e)===e}function JO(e,t){throw new D(`Skill ${e} validation failed: ${t}`,E.GENERAL,`This skill package does not conform to the SKILL.md spec; contact the skill publisher to fix and republish`)}function YO(e){if(!e.startsWith(`---`))return null;let t=/^---\r?\n([\s\S]*?)\r?\n---(\r?\n|$)/.exec(e);return t?t[1]:null}function XO(e,t){let n=w(e,`SKILL.md`),r;try{Se(n).isFile()||JO(t,`SKILL.md is not a regular file`),r=ve(n,`utf-8`)}catch(e){if(e instanceof D)throw e;JO(t,`missing SKILL.md`)}let i=YO(r);i===null&&JO(t,`SKILL.md is missing frontmatter (--- delimited YAML header)`);let a;try{a=y(i)}catch{JO(t,`frontmatter is not valid YAML`)}(typeof a!=`object`||!a)&&JO(t,`frontmatter is not a key-value structure`);let o=a,s=typeof o.name==`string`?o.name.trim():``,c=typeof o.description==`string`?o.description.trim():``;return(!s||!c)&&JO(t,`frontmatter is missing non-empty name / description fields`),{name:s,description:c}}function ZO(e){if(!qO(e))throw new D(`Invalid skill name: ${e}`,E.GENERAL,`Skill name contains path separators, traversal sequences, or other illegal characters; refusing to write to disk`)}async function QO(e,t,n,r){ZO(e);let i=rO(),a=w(i,e),o=w(i,`.tmp-${e}-${process.pid}-${Date.now()}`);try{_e(o,{recursive:!0}),await OO(t,o);let i=AO(o,r??(process.platform===`win32`?[a]:[]));if(i)throw new D(`Skill ${e} contains a Windows-incompatible path (${i.pathLength} characters): ${i.relativePath}`,E.GENERAL,`The skill package must shorten this path before it can be installed safely on Windows. / Skill 包必须缩短该路径后才能在 Windows 上安全安装。`);if(n?.startsWith(`sha256:`)){let t=kO(o);if(t!==n)throw new D(`Skill ${e} failed integrity check: index says ${n}, archive is ${t}`,E.GENERAL,`Downloaded archive does not match the index fingerprint (registry may be mid-publish); retry later`)}let s=XO(o,e);return FO(o,a),{name:e,path:a,meta:s}}finally{try{x(o)&&xe(o,{recursive:!0,force:!0})}catch{}}}async function $O(e,t,n,r){if(t.compression&&t.compression!==`tar.br`)throw new D(`Skill ${e} uses unsupported compression format: ${t.compression}`,E.GENERAL,`Upgrade bailian-cli to the latest version and retry`);return QO(e,await GO(e,t,n),t.contentHash,r)}function ek(e){ZO(e);let t=w(rO(),e);return x(t)?(xe(t,{recursive:!0,force:!0}),!0):!1}function tk(e,t){return{...e.contentHash?{contentHash:e.contentHash}:{},...e.publishedAt?{publishedAt:e.publishedAt}:{},installedAt:(/* @__PURE__ */ new Date()).toISOString(),sourceType:`oss`,...e.description?{description:e.description}:{},links:t}}async function nk(e,t,n=gO(),r=[],i){await $O(e,t,i,process.platform===`win32`?[w(rO(),e),...n.map(t=>w(t.skillsDir,e))]:void 0);let a=wO(e,n,r);return{lockEntry:tk(t,a.links),linkedAgents:a.linkedAgents}}const rk=`bailian-docs-llm-wiki`;function ik(){return w(Rt(),`skills/bailian-docs-llm-wiki`)}function ak(){return x(w(ik(),`models`,`models.jsonl`))}function ok(){return w(Rt(),`wiki-sync-state.json`)}function sk(){try{return JSON.parse(ve(ok(),`utf-8`))}catch{return null}}function ck(e){try{we(ok(),JSON.stringify(e))}catch{}}function lk(e){try{cO(rk,e)}catch{}}function uk(e){try{let t=oO().skills[rk];return t?.contentHash!==e||!Array.isArray(t.links)}catch{return!0}}async function dk(){try{return(await HO(3e3,1)).skills[rk]??null}catch{return null}}async function fk(){let e=sk(),t=Date.now();if(e&&t-e.lastChecked<432e5&&ak())return!1;let n=await dk();if(!n?.contentHash)return!1;if(ak()&&(!e||e.contentHash===n.contentHash)){if(ck({lastChecked:t,contentHash:n.contentHash}),uk(n.contentHash)){let e=oO().skills[rk]?.links??[];lk(tk(n,wO(rk,gO(),e).links))}return!1}try{let e=oO().skills[rk]?.links??[];lk((await nk(rk,n,gO(),e,1)).lockEntry)}catch{return!1}return ck({lastChecked:t,contentHash:n.contentHash}),!0}const pk={Text:`Text`,Image:`Image`,Video:`Video`,Audio:`Audio`},mk={Single:`single`,Pipeline:`pipeline`},hk={Low:`low`,Medium:`medium`,High:`high`},gk={Standard:`standard`,Large:`large`,ExtraLarge:`extra-large`},_k={Flagship:`flagship`,Balanced:`balanced`,CostOptimized:`cost-optimized`},vk={TG:`TG`,Reasoning:`Reasoning`,VU:`VU`,IG:`IG`,VG:`VG`,TTS:`TTS`,ASR:`ASR`,RealtimeASR:`Realtime-ASR`,RealtimeTTS:`Realtime-Text-to-Speech`,RealtimeAudioTranslate:`Realtime-Audio-Translate`,RealtimeOmni:`Realtime-Omni`,MultimodalOmni:`Multimodal-Omni`,ME:`ME`,TR:`TR`,ThreeDGeneration:`3D-generation`},yk={FunctionCalling:`function-calling`,WebSearch:`web-search`,StructuredOutputs:`structured-outputs`,PrefixCompletion:`prefix-completion`},bk={Flagship:`Flagship`,CostOptimized:`Cost-optimized`},xk=`bailian-cli`,Sk=`install-method`,Ck=/* @__PURE__ */ new Set([`binary`,`npm`,`brew`,`winget`,`unknown`]);function wk(e){return e?w(Rt(),`${Sk}.${e}`):w(Rt(),Sk)}function Tk(){if(process.env.BAILIAN_COMPILED===`1`)return!0;let e=process.execPath.replaceAll(`\\`,`/`);return/(^|\/)node(\.exe)?$/i.test(e)||e.includes(`/node/`)||/(^|\/)bun(\.exe)?$/i.test(e)||e.includes(`/.bun/`)?!1:/\/(bl|bailian)(\.exe)?$/i.test(e)}function Ek(e){if(!e)return null;let t=e.trim().toLowerCase();return Ck.has(t)?t:null}function Dk(e){try{return Ek(ve(e,`utf-8`).split(`
285
- `)[0])}catch{return null}}function Ok(){let e=Ek(process.env.BAILIAN_INSTALL_METHOD);if(e)return e;if(Tk()){let e=process.execPath.replaceAll(`\\`,`/`);return e.includes(`/Cellar/`)||e.includes(`/homebrew/`)?`brew`:`binary`}return`npm`}function kk(e){let t=Ek(process.env.BAILIAN_INSTALL_METHOD);if(t)return t;if(e?.clientName){let t=Dk(wk(e.clientName));if(t)return t;if(e.clientName===`bailian-cli`){let e=Dk(wk());if(e)return e}return Ok()}return Dk(wk())||Ok()}function Ak(e){let t=kk(e);return t===`binary`&&e.npmPackage!==`bailian-cli`?`npm`:t}function jk(e,t={clientName:xk}){try{let n=Rt();x(n)||_e(n,{recursive:!0,mode:448}),we(wk(t.clientName),`${e}\n`,{mode:384}),t.clientName===`bailian-cli`&&we(wk(),`${e}\n`,{mode:384})}catch{}}const Mk=`https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release`,Nk=`https://github.com/modelstudioai/cli/releases`,Pk=`https://bailian.aliyun.com/cli/install.sh`,Fk=`https://bailian.aliyun.com/cli/install.ps1`;function Ik(){let e=process.env.BAILIAN_CLI_CDN?.trim();return e?e.replace(/\/$/,``):Mk}function Lk(e=`latest`){let t=e.trim();return!t||t===`latest`||t===`stable`?`${Ik()}/manifest.json`:`${Ik()}/${t}.json`}function Rk(e,t){let n=e.startsWith(`v`)?e:`v${e}`;return`${Ik()}/${n}/${t}`}function zk(){let e=process.platform,t=process.arch,n;if(e===`darwin`)n=`darwin`;else if(e===`linux`)n=`linux`;else if(e===`win32`)n=`windows`;else throw Error(`Unsupported platform for binary updates: ${e}`);let r;if(t===`arm64`)r=`arm64`;else if(t===`x64`)r=`x64`;else throw Error(`Unsupported architecture for binary updates: ${t}`);if(n===`windows`&&r===`arm64`)throw Error(`windows arm64 is not supported for binary updates; use: npm install -g bailian-cli`);return{os:n,arch:r,fileSuffix:e===`win32`?`.exe`:``}}function Bk(e,t,n,r=!1){return`bl-${e}-${t}-${n}.zip`}function Vk(e,t,n){if(t!==`windows`)return`bl-${e}-${t}-${n}.tar.gz`}function Hk(e,t,n,r=!1){return`bl-${e}-${t}-${n}${r?`.exe`:``}`}function Uk(e){return new Promise((t,n)=>{de.open(e,{lazyEntries:!0},(r,i)=>{if(r||!i){n(r??/* @__PURE__ */ Error(`Failed to open zip: ${e}`));return}t(i)})})}function Wk(e){let t=e.replace(/\\/g,`/`);return t.includes(`/`)?t.slice(t.lastIndexOf(`/`)+1):t}async function Gk(e,t,n){let r=await Uk(e);return new Promise((i,a)=>{let o=!1,s=e=>{if(!o){o=!0;try{r.close()}catch{}a(e instanceof Error?e:Error(String(e)))}},c=e=>{if(!o){o=!0;try{r.close()}catch{}i(e)}};r.on(`error`,s),r.on(`end`,()=>{o||s(/* @__PURE__ */ Error(n?`Zip entry not found: ${n} in ${e}`:`Zip has no file entries: ${e}`))}),r.on(`entry`,e=>{if(o)return;let i=e.fileName.replace(/\\/g,`/`);if(i.endsWith(`/`)){r.readEntry();return}let a=Wk(i);if(n&&i!==n&&a!==n){r.readEntry();return}r.openReadStream(e,(n,r)=>{if(n||!r){s(n??/* @__PURE__ */ Error(`Failed to read zip entry: ${e.fileName}`));return}(async()=>{try{await Ie(Oe(t),{recursive:!0}),await Ke(r,he(t)),c(a)}catch(e){s(e)}})()})}),r.readEntry()})}function Kk(e,t){let n=(e??(t?`all`:``)).trim();if(!n)throw new ot(`--name cannot be empty`,`Use --name all or --name skill-a,skill-b`);let r=[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))];if(r.includes(`all`)){if(r.length>1)throw new ot(`--name all cannot be mixed with specific skill names`,`Use either all or a comma-separated list of names`);return`all`}return r}function qk(){let e=rO();return x(e)?ye(e).filter(t=>{if(t.startsWith(`.`)||t.includes(`.tmp-`)||t.includes(`.old-`))return!1;try{return Se(w(e,t)).isDirectory()}catch{return!1}}):[]}function Jk(e,t,n){let r=new Set(n),i=/* @__PURE__ */ new Set,a=[];for(let[n,o]of Object.entries(e.skills)){i.add(n);let e=t.skills[n];if(e){let t=r.has(n)?e.contentHash===o.contentHash?`installed`:`outdated`:`missing`;a.push({name:n,status:t,publishedAt:o.publishedAt,description:o.description})}else r.has(n)?a.push({name:n,status:`untracked`,publishedAt:o.publishedAt,description:o.description}):a.push({name:n,status:`not-installed`,publishedAt:o.publishedAt,description:o.description})}for(let[e,n]of Object.entries(t.skills))i.has(e)||(i.add(e),a.push({name:e,status:r.has(e)?`installed`:`missing`,publishedAt:n.publishedAt,description:n.description}));for(let e of n)i.has(e)||a.push({name:e,status:`untracked`});return a.sort((e,t)=>e.name<t.name?-1:+(e.name>t.name))}export{uO as AGENT_ENV_KEYS,vv as AIGC_MCP_SERVER,yv as AIGC_MCP_TOOL,bt as API_KEY_CAPABILITY_PATTERN,aw as ASYNC_FLAG,mt as BAILIAN_HOST,Mx as BATCH_CSV_COLUMNS,lx as BATCH_ENDPOINTS,ux as BATCH_STATUSES,dx as BATCH_TERMINAL,fC as BILLING_METHOD,xk as BINARY_PRODUCT_CLIENT_NAME,D as BailianError,xx as BatchValidator,hk as Budgets,HS as CALC_DATASETS_TOKENS_API,Nn as CHANNEL,mC as CHARGE_TYPE,dw as COMMAND_PACK_API_VERSION,iw as CONCURRENT_FLAG,_t as CONFIG_FILE_KEYS,sw as CONSOLE_AUTH_FLAGS,vy as CONSOLE_DATASET_BY_ID_API,by as CONSOLE_DATASET_GROUPS_API,yy as CONSOLE_DATASET_VERSIONS_API,MC as CONSOLE_DEPLOY_INSTANCES_API,dy as CONSOLE_FILE_URL_API,vk as Capabilities,Wh as Client,mk as Complexities,gk as ContextNeeds,ct as CredentialError,In as DASHSCOPE_SERVICE_HEADER,$y as DECISION_QUESTION_TYPES,Vx as DECISION_REGIONS,pC as DEFAULT_BILLING_METHOD,Mk as DEFAULT_CLI_CDN_BASE,Bx as DEFAULT_DECISION_MODEL,Hx as DEFAULT_DECISION_REGION,uC as DEFAULT_DEPLOY_PLAN,Fk as DEFAULT_INSTALL_PS1_URL,Pk as DEFAULT_INSTALL_SCRIPT_URL,gt as DEFAULT_LANGUAGE,BD as DEFAULT_LLM_MODEL,hS as DEFAULT_TRAINING_TYPE,DC as DEPLOY_LIST_INDEPENDENT_API,lC as DEPLOY_PLAN,TC as DEPLOY_START_API,EC as DEPLOY_STOP_API,pt as DOCS_HOSTS,US as ESTIMATE_FINETUNE_TOKENS_API,E as ExitCode,yk as Features,Nk as GITHUB_RELEASES_BASE,rw as GLOBAL_FLAGS,xS as INSUFFICIENT_SAMPLES_CODE,HC as LIST_SUPPORT_IMPORT_MODELS_API,lT as LLMError,fx as MAX_BATCH_BYTES,px as MAX_BATCH_LINE_BYTES,mx as MAX_BATCH_RECORDS,Py as MAX_CPT_BYTES,Ny as MAX_DATASET_BYTES,eb as MAX_DECISION_CHOICE_OPTIONS,Fy as MAX_DECISION_DATASET_BYTES,nb as MAX_DECISION_SCORE_LEVELS,Iy as MAX_MEDIA_ZIP_BYTES,Pn as MCP_CALL_SERVICE,Ov as MCP_IMAGE_GEN_RATIO_SIZES,Av as MCP_TTS_VOICES,tb as MIN_DECISION_SCORE_LEVELS,ow as MODEL_AUTH_FLAGS,Kv as MODEL_LIST_API,Mh as McpClient,pk as Modalities,bk as ModelCategories,cw as OPENAPI_AUTH_FLAGS,Fn as OPEN_API_SOURCE,qv as PREDICT_CONFIG_API,_k as QualityPreferences,E_ as RAG_PATHS,ID as RECOMMEND_TOOLS,ft as REGIONS,x_ as SANDBOX_PATHS,lO as SKIP_HOST_AGENTS_ENV,KC as SPEECH_BIASING_MODEL,CC as STRATEGIES,ht as SUPPORTED_LANGUAGES,VS as TRAINING_MODEL_PRICE_API,mS as TRAINING_TYPES_CLI,pS as TRAINING_TYPE_MAP,ot as UsageError,ln as activateConfigProfile,zD as agentLoop,__ as agentStudioFilesPath,Fg as agentStudioHost,ST as analyzeEngineIntent,An as anonymousConsoleCall,_g as appCompletionPath,FO as atomicSwap,sr as audioFileToDataUri,Rh as bailianMcpPath,zh as bailianMcpSsePath,vx as batchChunks,zx as batchDataNotes,Rx as batchExamples,hx as batchIoError,yx as batchLines,gx as batchObject,Q as batchUsage,Bk as binaryAssetFileName,Hk as binaryInnerFileName,Vk as binaryTarFileName,Kn as buildAcsCanonicalQuery,X_ as buildAsrContextMessages,Q_ as buildAsrFlashRequest,Z_ as buildAsyncAsrLanguageFields,sy as buildCommandInvocation,wy as buildConsoleDatasetGroupsRequest,Ay as buildConsoleDatasetVersionRequest,Ey as buildConsoleDatasetVersionsRequest,NC as buildConsoleDeploymentInstancesRequest,FD as buildEngineInput,Sv as buildImageEditArgs,xv as buildImageGenArgs,wv as buildImageToVideoArgs,pn as buildOutputSettings,yC as buildPrepaidInfo,gC as buildReservationCapacity,hn as buildSettings,tk as buildSkillLockEntry,fn as buildSources,Dv as buildSpeechToTextArgs,Cv as buildTextToVideoArgs,Ev as buildTtsArgs,Tv as buildVideoFetchArgs,qC as buildVocabularyRequest,Mn as callConsoleGateway,Ex as cancelBatch,dS as cancelCompressJob,Qx as cancelFineTune,Lk as channelManifestUrl,eg as chatPath,ev as collectAsrTranscriptionItems,ly as commandRef,kO as computeDirContentHash,Jk as computeSkillStatuses,Hh as connectBailianMcpWithFallback,My as consoleDatasetStatusAvailability,hv as createBailianControlUser,wx as createBatch,eC as createCapacityInstance,sS as createCompressJob,RC as createCustomModelImport,JS as createDeployment,Yx as createFineTune,dv as createInstrumentedFetch,VD as createLLMClient,nO as createNonInteractive,tO as createReadlineInteraction,PD as createSession,Nw as createTrackingEvent,YC as createVocabulary,lw as credentialFlagDefs,sg as decisionPath,dC as defaultDeployPlan,uw as defineCommand,rC as deleteCapacityInstance,fS as deleteCompressJob,un as deleteConfigProfile,VC as deleteCustomModelImport,_y as deleteDataset,aC as deleteDeployment,$x as deleteFineTune,$C as deleteVocabulary,c_ as deploymentCapacityInstancePath,u_ as deploymentCapacityInstanceRenewPath,l_ as deploymentCapacityInstanceScalePath,s_ as deploymentCapacityInstancesPath,f_ as deploymentCapacityOperationPath,d_ as deploymentOverflowPath,Lt as describeAuthState,zk as detectBinaryPlatform,Ok as detectInstallMethod,gO as detectInstalledAgents,Zb as detectModality,Gt as detectOutputFormat,LD as dispatchTool,GO as downloadSkillAsset,kn as effectiveConsoleGatewayConfig,aO as emptySkillLock,Vt as ensureConfigDir,KS as estimateCptTokens,GS as estimateSftDpoTokens,Lx as exportBatchCsv,iS as exportCheckpoint,$_ as extractAsrFlashText,OO as extractTarBr,Gk as extractZipEntryToFile,wO as fanOutSkillToAgents,bS as fetchModelCapability,ty as fetchModelDetail,Qv as fetchModelGroups,ey as fetchModelGroupsAll,Yv as fetchModelList,Xv as fetchModelListAll,iy as fetchPredictConfig,HO as fetchSkillsIndex,WS as fetchTrainingModelPrice,jC as findDeploymentEntry,Zv as findModelByName,WC as findSupportImportModel,$v as flattenModelGroups,eT as flushTelemetry,Jx as followParsexResult,cy as formatCommand,fT as formatDegradation,Wt as formatErrorJson,cx as formatIssue,Ut as formatJson,Kt as formatOutput,Ht as formatText,Jh as generateCLIAccessToken,pw as generateFilename,dO as getAgentTargets,vn as getApiKeyLoginKind,Tx as getBatch,Ox as getBatchFileContent,QS as getCapacityInstance,$S as getCapacityOperation,Ik as getCliCdnBase,lS as getCompressJob,uS as getCompressJobLogs,Rt as getConfigDir,zt as getConfigPath,ky as getConsoleDatasetById,py as getConsoleFileUrl,Bt as getCredentialsPath,BC as getCustomModelImport,gy as getDataset,XS as getDeployment,Zx as getFineTune,ES as getFineTuneHyperParameterDefaultNumber,eS as getFineTuneLogs,tS as getFineTuneParams,mw as getHermesHome,kk as getInstallMethod,_n as getModelProfilePreset,qx as getParsexResult,zS as getProfile,iO as getSkillLockPath,VO as getSkillRegistryBaseUrl,rO as getSkillsDir,Ak as getUpdateInstallMethod,_C as hasPrepaidFlags,En as httpTransport,dg as image2ImagePath,pg as image2videoPath,or as imageFileToDataUri,cg as imagePath,lg as imageSyncPath,ug as imageText2ImagePath,Y_ as inferAudioFormatHint,db as inspectDecisionQuestion,pb as inspectDecisionQuestionId,fb as inspectDecisionQuestionTable,mb as inspectDecisionQuestions,sb as inspectDecisionState,$O as installSkill,QO as installSkillFromBuffer,nk as installSkillWithFanout,xt as isApiKeyCapability,Tk as isCompiledBinary,rv as isDashScopeGateway,ib as isDecisionObject,mO as isHostSystemDetectDir,F_ as isLegacyImage2ImageModel,P_ as isLegacyText2ImageModel,ur as isLocalFile,jv as isMcpTtsVoice,Ot as isModelConnectionSourceMismatch,DO as isSafeEntryName,qO as isSafeSkillName,Bh as isStreamableHttpUnsupported,A_ as isSyncMultimodalImageModel,gS as isTrainingTypeCli,Vh as isUrlOverrideSseFallbackCandidate,I_ as isWanxFunctionImageEditModel,Pg as knowledgeChatEndpoint,Ng as knowledgeSearchEndpoint,CO as linkSkillToAgents,gv as listBailianControlWorkspaces,nS as listBasicMetrics,Dx as listBatches,ZS as listCapacityInstances,rS as listCheckpoints,cS as listCompressJobs,oS as listCompressTemplates,Ty as listConsoleDatasetGroups,Oy as listConsoleDatasetVersions,LC as listConsoleDeploymentInstances,zC as listCustomModelImports,hy as listDatasets,oC as listDeployableModels,YS as listDeployments,Xx as listFineTunes,AC as listIndependentDeployedModels,qk as listSkillDirsOnDisk,UC as listSupportImportModels,sx as listSupportedFormats,yS as listSupportedTrainingTypes,BS as listTrainingTypes,XC as listVocabularies,QD as loadCatalog,$D as loadFamilies,tT as localSink,xn as makeAuthStore,ay as makeConfigStore,lt as mapApiError,vw as maskToken,fk as maybeSyncWikiData,zg as mcpWebSearchPath,yg as memoryAddAsyncPath,vg as memoryEndpoint,bg as memoryEventPath,Sg as memoryListPath,Cg as memoryNodePath,xg as memorySearchPath,wg as memorySkillExportPath,vS as modelSupportsTrainingType,hg as modelsLimitsPath,gg as modelsPermissionsPath,St as normalizeApiKeyCapabilities,Qt as normalizeConfigName,ut as normalizeModelBaseUrl,Lv as parseAigcAsrTexts,Nv as parseAigcImageResults,bv as parseAigcToolResult,Pv as parseAigcTtsResult,Fv as parseAigcVideoTaskId,Iv as parseAigcVideoTaskResult,_x as parseBatchEndpoint,Sw as parseBooleanValue,wt as parseConfigFile,Ry as parseDatasetSchemaFlag,tw as parseInstantVocabulary,Cw as parseOptionalBooleanValue,Bv as parseSSE,sv as parseSecurityBody,Kk as parseSkillNames,nw as parseVocabularyEntries,Qh as parsexBaseUrl,$h as parsexEndpoint,wC as pickPlanStrategy,ix as pickValidator,TO as planUnlinkSkillFromAgents,SS as preflightBatchSizeGate,jx as prepareBatch,kg as profileSchemaItemPath,Og as profileSchemaPath,Ix as projectBatchCsv,jy as queryConsoleDatasetVersion,ZC as queryVocabulary,g_ as ragEndpoint,Cx as readBatchBlob,Mw as readCaller,nn as readConfigFile,on as readConfigProfiles,oO as readSkillLock,bw as readTextFromPathOrStdin,xD as recommendEngine,cr as redactDataUri,Yh as refreshAccessToken,ax as registerValidator,Rk as releaseAssetUrl,nT as remoteSink,ek as removeSkillDir,uy as renderCommandText,nC as renewCapacityInstance,Vn as request,Gn as requestJson,GC as requiredTrainTypeForWeightType,_v as resetBailianControlPolicies4Agent,eO as resetCatalogCache,jt as resolveApiKey,Tt as resolveApiKeySource,J_ as resolveAsrApi,WO as resolveAssetFileName,kx as resolveBatchChatEndpoint,ww as resolveBooleanFlag,Kh as resolveCLIAccessTokenTarget,Mt as resolveConsole,dr as resolveFileUrl,V_ as resolveImageEditApi,B_ as resolveImageGenerateApi,L_ as resolveImageSizeProfile,kv as resolveMcpImageSize,At as resolveModelBaseUrl,Et as resolveModelBaseUrlSource,kt as resolveModelBaseUrlState,Dt as resolveModelConnectionProvenance,Nt as resolveOpenApi,_w as resolveOutputDir,R_ as resolvePromptExtendDefault,mn as resolveRecoveryConfigName,Tw as resolveWatermark,og as responsesPath,$T as routeEngine,xw as runWithConcurrency,y_ as sandboxApiPath,v_ as sandboxBaseUrl,b_ as sandboxEndpoint,C_ as sandboxInstanceActionPath,S_ as sandboxInstancePath,T_ as sandboxTemplateBuildStatusPath,w_ as sandboxTemplatePath,at as sanitizeDiagnosticDetails,KO as sanitizeSkillName,tC as scaleCapacityInstance,sC as scaleDeployment,Rg as securityAgentLogsEndpoint,cv as securityGet,Lg as securityOverviewEndpoint,dn as selectApiKeyResolutionSources,qn as signAcsRequest,Ln as sourceConfig,Eg as speechRecognizePath,Tg as speechSynthesizePath,Dg as speechVocabularyPath,OC as startModelService,kC as stopModelService,Gx as stripDecisionTrainingFields,yw as stripUndefined,Kx as submitParsexTask,mg as taskPath,oT as trackCommandExecution,Rn as trackingHeaders,_S as trainingTypeMethodVariant,EO as unlinkSkillFromAgents,Gv as unwrapConsoleResponse,Wx as unwrapDecisionQuestions,Jv as unwrapResponse,cC as updateDeployment,iC as updateDeploymentOverflow,QC as updateVocabulary,my as uploadDataset,lr as uploadFile,cO as upsertSkillLockEntry,Ag as userProfilePath,jg as userProfileValuesPath,Sx as validateBatch,cn as validateConfigProfileActivation,qh as validateConsoleAccessToken,ox as validateDataset,TS as validateFineTuneHyperParameterOverrides,vC as validatePrepaidFlags,hC as validateReservationCapacity,XO as validateSkillDir,Jt as validateTimeout,fg as videoGeneratePath,Mg as workspaceMaaSBaseUrl,Ax as writeBatchFile,rn as writeConfigFile,jk as writeInstallMethodSync,sO as writeSkillLock};
354
+ - Everything else — including vague requests like "推荐一个", "有什么好模型", "帮我选个模型" — MUST go through the recommend tool`}async function oA(e,t,n){let r=[{role:`system`,content:aA()},{role:`user`,content:e}],i=tA(e),a=[],o,s=0,c=0,l=e=>{a.push(e),n?.(e)};try{for(let e=0;e<10;e++){c=e,$(t.signal);let n;try{n=await t.llm.chatWithTools(r,rA,{stage:`agent`,signal:t.signal}),$(t.signal)}catch(n){$(t.signal);let r=PD(n,`agent`);if(r.kind===`cancelled`)throw r;if(r.fatal){if(!o)throw r;let n=MD(`agent`,`agent-summary→engine-result`,r);return t.onDiagnostic?.(`[recommend] agent loop failed (${r.tag}), using the recommendation already computed`),l({turn:e,type:`fallback`,reason:`agent_error_existing_result`}),{finalText:``,recommendResult:o,turns:e,degradations:[n],trajectory:a}}t.onDiagnostic?.(`[recommend] agent loop failed (${r.tag}), falling back to engine: ${r.message}`);let s=await Hk(nA(i),t);return l({turn:e,type:`fallback`,reason:`agent_error_engine_rerun`}),{finalText:``,recommendResult:s,turns:e,degradations:[MD(`agent`,`agent→engine-rerun`,r)],trajectory:a}}if(!n.toolCalls.length)return l({turn:e,type:`final_answer`,reason:n.content.trim()?`completed`:`empty_answer`}),{finalText:n.content,recommendResult:o,turns:e+1,degradations:[],trajectory:a};r.push({role:`assistant`,content:n.content,tool_calls:n.toolCalls});for(let t of n.toolCalls){let n;try{n=JSON.parse(t.function.arguments||`{}`)}catch{}l({turn:e,type:`tool_call`,callId:t.id,tool:t.function.name,args:n})}for(let a of n.toolCalls)try{if($(t.signal),a.function.name===`ask_user`&&s>=2){let t={error:`clarify budget exhausted; proceed with defaults`};l({turn:e,type:`tool_result`,callId:a.id,tool:a.function.name,status:`rejected`,reason:`clarify_budget`,result:t}),r.push({role:`tool`,tool_call_id:a.id,content:JSON.stringify(t)});continue}let n=await iA(a,t,i);$(t.signal),n.recommendResult&&(o=n.recommendResult);let c=JSON.parse(n.result),u=c.error?`error`:`success`;a.function.name===`ask_user`&&u===`success`&&s++,l({turn:e,type:`tool_result`,callId:a.id,tool:a.function.name,status:u,result:c,resultType:typeof c.type==`string`?c.type:void 0,degradations:n.recommendResult?.type===`result`?n.recommendResult.degradations:void 0}),r.push({role:`tool`,tool_call_id:a.id,content:n.result})}catch(n){let r=t.signal?.aborted||PD(n,`agent`).kind===`cancelled`;throw l({turn:e,type:`tool_result`,callId:a.id,tool:a.function.name,status:r?`cancelled`:`error`,reason:n instanceof Error?n.message:String(n)}),n}}return c=10,$(t.signal),l({turn:10,type:`fallback`,reason:`turn_budget`}),o?{finalText:``,recommendResult:o,turns:10,degradations:[],trajectory:a}:{finalText:``,recommendResult:await Hk(nA(i),t),turns:10,degradations:[],trajectory:a}}catch(e){let n=t.signal?.aborted||PD(e,`agent`).kind===`cancelled`,r=new Set(a.filter(e=>e.type===`tool_result`).map(e=>`${e.turn}:${e.callId}`));for(let e of a.filter(e=>e.type===`tool_call`&&!r.has(`${e.turn}:${e.callId}`)))l({turn:e.turn,type:`tool_result`,tool:e.tool,callId:e.callId,status:n?`cancelled`:`rejected`,reason:`run_terminated`});throw l({turn:c,type:n?`cancelled`:`error`,reason:e instanceof Error?e.message:String(e)}),$(t.signal),e}}const sA=`qwen-flash-2025-07-28`;function cA(e){let{baseUrl:t,apiKey:n,defaultModel:r=sA,timeoutMs:i=6e4,enableThinking:a,thinkingStages:o,thinkingLog:s,onThinking:c}=e,l=`${t.replace(/\/$/,``)}/compatible-mode/v1/chat/completions`;async function u(t,r,a){$(r.signal);let o=new AbortController,s=setTimeout(()=>o.abort(),i),c=r.signal?AbortSignal.any([r.signal,o.signal]):o.signal;try{e.onRequest?.(r.stage??`llm`);let i=await(e.fetch??fetch)(l,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${n}`},body:JSON.stringify(t),signal:c});if(!i.ok){let e=await i.text(),t={message:e.slice(0,200)};try{t=JSON.parse(e)}catch{}throw lA(t,i.status,i.headers.get(`x-request-id`)??void 0)}let o=await a(i,c);return $(r.signal),o}catch(e){throw $(r.signal),o.signal.aborted?new AD(`timeout`,`LLM request timed out after ${i}ms`,{cause:e}):e instanceof AD?e:e instanceof SyntaxError?new AD(`parse`,`LLM 响应不是有效 JSON`,{cause:e}):new AD(`network`,`LLM request failed: ${e?.cause?.code??e?.message}`,{cause:e})}finally{clearTimeout(s)}}async function d(e,t={}){return u(e,t,async e=>{let n=await e.json();if(n.error)throw lA(n,void 0,e.headers.get(`x-request-id`)??void 0);let r=n.choices?.[0];if(uA(r?.finish_reason),!r?.message)throw new AD(`parse`,`LLM 响应缺少 message`);if(dA(r.message.tool_calls??[]),!r.message.content?.trim()&&!r.message.tool_calls?.length)throw new AD(`parse`,`LLM 返回空响应`);let i=r.message.reasoning_content;return s&&i&&s.push({stage:t.stage??`llm`,content:i}),n})}async function f(e,t,n={}){let i=n.stage??(t?`agent`:`llm`);return u({model:n.model??r,messages:e.map(fA),...t?{tools:t}:{},temperature:n.temperature??0,max_tokens:n.maxTokens??4096,stream:!0,enable_thinking:!0},{...n,stage:i},async(e,t)=>{if(!e.body)throw new AD(`parse`,`SSE 响应缺少正文`);let n=e.body.getReader(),r=new TextDecoder,a=``,o=``,l=``,u=!1,d=``,f=[],p=/* @__PURE__ */ new Map,m=()=>{if(!f.length)return;let t=f.join(`
355
+ `);if(f=[],t.trim()===`[DONE]`){u=!0;return}let n=JSON.parse(t);if(n.error||d===`error`)throw lA(n,void 0,e.headers.get(`x-request-id`)??void 0);let r=n.choices?.find(e=>e.index===0||e.index===void 0);uA(r?.finish_reason);let a=r?.delta;if(a){a.reasoning_content&&(l+=a.reasoning_content,c?.(i,a.reasoning_content)),o+=a.content??``;for(let e of a.tool_calls??[]){let t=e.index;if(t===void 0||!Number.isInteger(t)||t<0)throw new AD(`parse`,`工具片段缺少有效 index`);let n=p.get(t)??{id:``,name:``,arguments:``};if(e.id){if(n.id&&n.id!==e.id)throw new AD(`parse`,`同一工具 index 返回不同 id`);n.id=e.id}n.name+=e.function?.name??``,n.arguments+=e.function?.arguments??``,p.set(t,n)}}},h=e=>{let t=e.replace(/\r$/,``);t?t.startsWith(`data:`)?f.push(t.slice(5).replace(/^ /,``)):t.startsWith(`event:`)&&(d=t.slice(6).trim()):(m(),d=``)},g=()=>{n.cancel().catch(()=>{})};t.addEventListener(`abort`,g,{once:!0});try{for(;!u;){t.throwIfAborted();let{done:e,value:i}=await n.read();t.throwIfAborted(),a+=e?r.decode():r.decode(i,{stream:!0});let o=a.split(`
356
+ `);a=o.pop()??``;for(let e of o)if(h(e),u)break;if(e&&(!u&&a&&h(a),u||m(),!u))throw new AD(`parse`,`SSE 在完成标记前断流`)}let e=[...p.entries()].sort(([e],[t])=>e-t).map(([,e])=>({id:e.id,type:`function`,function:{name:e.name,arguments:e.arguments}}));if(dA(e),!o.trim()&&!e.length)throw new AD(`parse`,`SSE 返回空响应`);return s&&l&&s.push({stage:i,content:l}),{content:o,toolCalls:e}}finally{t.removeEventListener(`abort`,g),await n.cancel().catch(()=>{}),n.releaseLock()}})}let p=e=>e?.stage!==void 0&&o?.includes(e.stage)||a===!0;return{async chat(e,t){return p(t)?(await f(e,void 0,t)).content:(await d({model:t?.model??r,messages:e,temperature:t?.temperature??0,max_tokens:t?.maxTokens??4096},{...t})).choices?.[0]?.message?.content??``},async chatJson(e,t){let n=await this.chat(e,t);try{return zO(n)}catch{let r=await this.chat([...e,{role:`assistant`,content:n},{role:`user`,content:`IMPORTANT: Your previous response was not valid JSON. Respond with ONLY a valid JSON object, no other text.`}],t);try{return zO(r)}catch(e){throw new AD(`parse`,`LLM returned invalid JSON twice: ${r.slice(0,120)}`,{cause:e})}}},async chatWithTools(e,t,n){if(p(n))return f(e,t,n);let i=(await d({model:n?.model??r,messages:e.map(fA),tools:t,temperature:0,max_tokens:4096},{...n,stage:n?.stage??`agent`})).choices?.[0]?.message;return{content:i?.content??``,toolCalls:i?.tool_calls??[]}}}}function lA(e,t,n){let r=e&&typeof e==`object`?e:{},i=r.error&&typeof r.error==`object`?r.error:r,a=typeof i.code==`string`?i.code:void 0;return new AD(t?jD(t):/invalid.?api.?key|unauthorized|accessdenied|forbidden/i.test(a??``)?`auth`:/quota|throttl|rate.?limit/i.test(a??``)?`rate_limit`:`http`,`LLM request failed: ${typeof i.message==`string`?i.message:typeof r.error==`string`?r.error:`服务端错误`}`,{status:t,code:a,requestId:typeof r.request_id==`string`?r.request_id:n})}function uA(e){if(e&&e!==`stop`&&e!==`tool_calls`)throw new AD(`parse`,`LLM 响应未完整结束: ${e}`)}function dA(e){let t=/* @__PURE__ */ new Set;for(let n of e){if(!n.id||t.has(n.id)||!n.function?.name||n.type!==`function`)throw new AD(`parse`,`工具调用缺少标识或标识重复`);t.add(n.id);let e;try{e=JSON.parse(n.function.arguments)}catch(e){throw new AD(`parse`,`工具参数不完整`,{cause:e})}if(!e||typeof e!=`object`||Array.isArray(e))throw new AD(`parse`,`工具参数必须是 JSON 对象`)}}function fA(e){let t={role:e.role,content:e.content};return e.tool_call_id&&(t.tool_call_id=e.tool_call_id),e.tool_calls&&(t.tool_calls=e.tool_calls),t}function pA(){return T(qt(),`skills/bailian-docs-llm-wiki`,`models`)}const mA=/-\d{4}-\d{2}-\d{2}$/;let hA=null,gA=null;function _A(e){if(!S(e))return[];let t=[];for(let n of ye(e,`utf-8`).split(`
357
+ `))if(n.trim())try{t.push(JSON.parse(n))}catch{}return t}function vA(e){let t=new Set(e.map(({model:e})=>e));return e.filter(({model:e})=>{let n=e.replace(mA,``);return n===e||!t.has(n)})}async function yA(e=pA()){if(hA)return hA;let t=_A(T(e,`models.jsonl`));if(t.length===0)throw Error(`No model catalog found at ${T(e,`models.jsonl`)}. Run any bl advisor/agent command once to sync wiki data.`);return hA=vA(t),hA}async function bA(e=pA()){if(gA)return gA;let t=_A(T(e,`families.jsonl`));return gA=new Map(t.map(e=>[e.slug,e])),gA}function xA(){hA=null,gA=null}function SA(){return{async ask({question:e,options:t,defaultIfSkip:n,signal:r}){$(r);let i=tt({input:process.stdin,output:process.stderr});try{for(process.stderr.write(`\n${e}\n`),t.forEach((e,t)=>{let r=e===n;process.stderr.write(` ${t+1}. ${e}${r?` (default)`:``}\n`)}),process.stderr.write(` 输入序号选择,回车使用默认,或直接输入文字描述你的需求
358
+ `);;){let e=(await i.question(`Select: `,{signal:r})).trim();if($(r),!e)return n;if(/^\d+$/.test(e)){let n=Number.parseInt(e,10)-1;if(n>=0&&n<t.length)return t[n];process.stderr.write(` 请输入 1-${t.length} 之间的序号,或直接输入文字描述\n`);continue}return e}}finally{i.close()}}}}function CA(){return{async ask({question:e,defaultIfSkip:t,signal:n}){return $(n),process.stderr.write(`[recommend] non-interactive, "${e}" → default: ${t}\n`),t}}}function wA(){return T(qt(),`skills`)}function TA(){return T(wA(),`skill-lock.json`)}function EA(){return{version:1,skills:{}}}function DA(){let e=TA();if(!S(e))return EA();try{let t=JSON.parse(ye(e,`utf-8`));return t?.version!==1||typeof t.skills!=`object`||t.skills===null?EA():t}catch{return EA()}}function OA(e){C(wA(),{recursive:!0}),Oe(TA(),JSON.stringify(e,null,2)+`
359
+ `)}function kA(e,t){let n=DA();n.skills[e]={...n.skills[e],...t},OA(n)}const AA=`BL_SKIP_HOST_AGENTS`,jA=[`CLAUDE_CONFIG_DIR`,`CODEX_HOME`,`VIBE_HOME`,`HERMES_HOME`,`AUTOHAND_HOME`,`GROK_HOME`,`DSH_HOME`,`OPENCLAW_CONFIG_PATH`,`ZCODE_HOME`,`APPDATA`,`LOCALAPPDATA`,`FLATPAK_XDG_CONFIG_HOME`,`PI_CODING_AGENT_DIR`];function MA(){let e=et(),t=process.cwd(),n=process.env.XDG_CONFIG_HOME||T(e,`.config`),r=(t,n,r)=>({id:t,displayName:n,skillsDir:T(e,r,`skills`),detectDirs:[T(e,r)]}),i=(t,n)=>t?.trim()||T(e,n),a=(e,t,n)=>({id:e,displayName:t,skillsDir:T(n,`skills`),detectDirs:[n]}),o=[`.openclaw`,`.clawdbot`,`.moltbot`].map(t=>T(e,t)),s=o.find(e=>S(e))??o[0],c=[T(n,`zed`)],l=process.env.APPDATA?.trim();l&&c.push(T(l,`Zed`));let u=process.env.FLATPAK_XDG_CONFIG_HOME?.trim();u&&c.push(T(u,`zed`));let d=i(process.env.CODEX_HOME,`.codex`);return[{id:`universal`,displayName:`Universal (~/.agents/skills)`,skillsDir:T(e,`.agents`,`skills`),detectDirs:[T(e,`.agents`),T(e,`.cline`),T(e,`.dexto`),T(e,`.firebender`),T(e,`.kimi-code`),T(e,`.kimi`),T(e,`.loaf`),T(e,`.warp`),...c]},{id:`universal-xdg`,displayName:`Universal (XDG agents/skills)`,skillsDir:T(n,`agents`,`skills`),detectDirs:[T(n,`agents`),T(n,`amp`),T(t,`.replit`)]},r(`adal`,`AdaL`,`.adal`),r(`aider-desk`,`AiderDesk`,`.aider-desk`),r(`antigravity`,`Antigravity`,`.gemini/antigravity`),r(`antigravity-cli`,`Antigravity CLI`,`.gemini/antigravity-cli`),{id:`astrbot`,displayName:`AstrBot`,skillsDir:T(e,`.astrbot`,`data`,`skills`),detectDirs:[T(t,`data`,`skills`),T(e,`.astrbot`)]},a(`autohand-code`,`Autohand Code CLI`,i(process.env.AUTOHAND_HOME,`.autohand`)),r(`augment`,`Augment`,`.augment`),r(`bob`,`IBM Bob`,`.bob`),a(`claude-code`,`Claude Code`,i(process.env.CLAUDE_CONFIG_DIR,`.claude`)),r(`codearts-agent`,`CodeArts Agent`,`.codeartsdoer`),{id:`codebuddy`,displayName:`CodeBuddy`,skillsDir:T(e,`.codebuddy`,`skills`),detectDirs:[T(t,`.codebuddy`),T(e,`.codebuddy`)]},r(`codemaker`,`Codemaker`,`.codemaker`),r(`codestudio`,`Code Studio`,`.codestudio`),{id:`codex`,displayName:`Codex`,skillsDir:T(d,`skills`),detectDirs:[d,`/etc/codex`]},r(`command-code`,`Command Code`,`.commandcode`),{id:`continue`,displayName:`Continue`,skillsDir:T(e,`.continue`,`skills`),detectDirs:[T(t,`.continue`),T(e,`.continue`)]},r(`cortex`,`Cortex Code`,`.snowflake/cortex`),r(`crush`,`Crush`,`.config/crush`),r(`cursor`,`Cursor`,`.cursor`),{id:`deepagents`,displayName:`Deep Agents`,skillsDir:T(e,`.deepagents`,`agent`,`skills`),detectDirs:[T(e,`.deepagents`)]},{id:`devin`,displayName:`Devin for Terminal`,skillsDir:T(n,`devin`,`skills`),detectDirs:[T(n,`devin`)]},r(`droid`,`Droid`,`.factory`),a(`dsh`,`DeepSeek DSH`,i(process.env.DSH_HOME,`.dsh`)),r(`forgecode`,`ForgeCode`,`.forge`),r(`gemini-cli`,`Gemini CLI`,`.gemini`),r(`github-copilot`,`GitHub Copilot`,`.copilot`),{id:`goose`,displayName:`Goose`,skillsDir:T(n,`goose`,`skills`),detectDirs:[T(n,`goose`)]},a(`grok`,`Grok Build`,i(process.env.GROK_HOME,`.grok`)),a(`hermes`,`Hermes Agent`,FE(e)),r(`iflow-cli`,`iFlow CLI`,`.iflow`),r(`inference-sh`,`inference.sh`,`.inferencesh`),{id:`jazz`,displayName:`Jazz`,skillsDir:T(e,`.jazz`,`skills`),detectDirs:[T(e,`.jazz`),T(t,`.jazz`)]},r(`junie`,`Junie`,`.junie`),r(`kilo`,`Kilo Code`,`.kilocode`),{id:`kimchi`,displayName:`Kimchi`,skillsDir:T(e,`.config`,`kimchi`,`harness`,`skills`),detectDirs:[T(e,`.config`,`kimchi`)]},r(`kiro-cli`,`Kiro CLI`,`.kiro`),r(`kode`,`Kode`,`.kode`),r(`lingma`,`Lingma`,`.lingma`),r(`mcpjam`,`MCPJam`,`.mcpjam`),{id:`minimax-code`,displayName:`MiniMax Code`,skillsDir:T(e,`.minimax`,`skills`),detectDirs:[T(e,`.minimax`),`/Applications/MiniMax Code.app`]},a(`mistral-vibe`,`Mistral Vibe`,i(process.env.VIBE_HOME,`.vibe`)),r(`moxby`,`Moxby`,`.moxby`),r(`mux`,`Mux`,`.mux`),r(`neovate`,`Neovate`,`.neovate`),{id:`opencode`,displayName:`OpenCode`,skillsDir:T(n,`opencode`,`skills`),detectDirs:[T(n,`opencode`)]},{id:`openclaw`,displayName:`OpenClaw`,skillsDir:T(s,`skills`),detectDirs:o},r(`openhands`,`OpenHands`,`.openhands`),r(`ona`,`Ona`,`.ona`),r(`pi`,`Pi`,`.pi/agent`),r(`pochi`,`Pochi`,`.pochi`),r(`qoder`,`Qoder`,`.qoder`),r(`qoder-cn`,`Qoder CN`,`.qoder-cn`),r(`qwen-code`,`Qwen Code`,`.qwen`),r(`reasonix`,`Reasonix`,`.reasonix`),r(`rovodev`,`Rovo Dev`,`.rovodev`),r(`roo`,`Roo Code`,`.roo`),{id:`tabnine-cli`,displayName:`Tabnine CLI`,skillsDir:T(e,`.tabnine`,`agent`,`skills`),detectDirs:[T(e,`.tabnine`)]},r(`terramind`,`Terramind`,`.terramind`),r(`tinycloud`,`Tinycloud`,`.tinycloud`),r(`trae`,`Trae`,`.trae`),r(`trae-cli`,`Trae CLI`,`.traecli`),r(`trae-cn`,`Trae CN`,`.trae-cn`),r(`windsurf`,`Windsurf`,`.codeium/windsurf`),r(`workbuddy`,`Tencent WorkBuddy`,`.workbuddy`),{id:`zcode`,displayName:`ZCode`,skillsDir:T(e,`.zcode`,`skills`),detectDirs:[T(e,`.zcode`),`/Applications/ZCode.app`]},r(`zencoder`,`Zencoder`,`.zencoder`)]}function NA(e){let t=Pe(e);try{return Se(t)}catch{let e=[],n=t;for(;n!==je(n);){if(S(n))try{return T(Se(n),...e.reverse())}catch{break}e.push(Ae(n)),n=je(n)}return t}}function PA(e,t){let n=NA(e),r=NA(t);return n===r||n.startsWith(r+Fe)}function FA(e){if(!Me(e)||PA(e,et()))return!1;let t=process.env.XDG_CONFIG_HOME?.trim();return!(t&&PA(e,t))}function IA(e){return process.env.BL_SKIP_HOST_AGENTS!==`1`||!FA(e)}function LA(){return MA().filter(e=>e.detectDirs.some(e=>IA(e)&&S(e)))}function RA(e,t){return process.platform===`win32`?e.toLowerCase()===t.toLowerCase():e===t}function zA(e){let t=wA();if(process.platform===`win32`){let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(r+Fe)}return e===t||e.startsWith(t+Fe)}function BA(e){try{if(!ve(e).isSymbolicLink())return!1;let t=xe(e);return zA(Me(t)?t:Pe(je(e),t))}catch{return!1}}function VA(e,t){if(!t.some(t=>RA(t,e)))return!1;try{return ve(e).isDirectory()}catch{return!1}}function HA(e){try{return ve(e).isDirectory()?S(T(e,`SKILL.md`)):!1}catch{return!1}}const UA=`existing file/dir not managed by bl skill`;function WA(e,t=LA(),n=[]){let r=T(wA(),e),i=[];for(let a of t){let t=T(a.skillsDir,e);try{let e=!1;try{ve(t),e=!0}catch{}if(e){if(BA(t))we(t);else if(VA(t,n))we(t,{recursive:!0,force:!0});else if(HA(t))we(t,{recursive:!0,force:!0});else{i.push({agent:a.id,path:t,mode:`skipped`,reason:UA});continue}}C(a.skillsDir,{recursive:!0});try{Ee(r,t,process.platform===`win32`?`junction`:`dir`),i.push({agent:a.id,path:t,mode:`symlink`})}catch{he(r,t,{recursive:!0}),i.push({agent:a.id,path:t,mode:`copy`})}}catch(e){i.push({agent:a.id,path:t,mode:`skipped`,reason:e instanceof Error?e.message:String(e)})}}return i}function GA(e,t=LA(),n=[]){let r=WA(e,t,n),i=r.filter(e=>e.mode!==`skipped`),a=i.map(e=>e.path),o=r.filter(e=>e.mode===`skipped`&&e.reason===UA).map(e=>e.path),s=n.filter(e=>!a.some(t=>RA(t,e))&&!o.some(t=>RA(t,e)));return{results:r,linkedAgents:i.map(e=>e.agent),links:[...a,...s]}}function KA(e,t=[]){let n=[],r=new Set(t);for(let t of MA())r.add(T(t.skillsDir,e));for(let e of r)try{let r;try{r=ve(e)}catch{continue}r.isSymbolicLink()?BA(e)&&n.push(e):t.some(t=>RA(t,e))&&n.push(e)}catch{}return n}function qA(e,t=[]){let n=[];for(let r of KA(e,t))try{if(BA(r))we(r);else if(!ve(r).isSymbolicLink()&&t.some(e=>RA(e,r)))we(r,{recursive:!0,force:!0});else continue;n.push(r)}catch{}return n}function JA(e){return e.includes(`\\`)||e.includes(`\0`)||e.startsWith(`/`)||/^[a-zA-Z]:[\\/]/.test(e)?!1:!e.split(`/`).includes(`..`)}async function YA(e,t){let n=it.extract();n.on(`entry`,(e,r,i)=>{if(!JA(e.name)){r.on(`error`,()=>{}),r.resume(),n.destroy(/* @__PURE__ */ Error(`unsafe tar entry: ${e.name}`));return}let a=T(t,e.name);if(e.type===`directory`){C(a,{recursive:!0}),r.resume(),r.on(`end`,i);return}C(je(a),{recursive:!0});let o=_e(a);r.pipe(o),o.on(`finish`,i),o.on(`error`,i)}),await nt(ke.from(e),rt(),n)}function XA(e){let t=[],n=r=>{for(let i of be(r?T(e,r):e,{withFileTypes:!0})){let e=r?`${r}/${i.name}`:i.name;i.isDirectory()?n(e):i.isFile()&&t.push(e)}};n(``),t.sort((e,t)=>e<t?-1:+(e>t));let r=Ge(`sha256`);for(let n of t)r.update(n),r.update(ye(T(e,n)));return`sha256:${r.digest(`hex`)}`}function ZA(e,t,n=259){let r,i=a=>{for(let o of be(a,{withFileTypes:!0}).sort((e,t)=>e.name.localeCompare(t.name))){let s=T(a,o.name),c=Ne(e,s);for(let e of t){let t=T(e,c).length;t>n&&t>(r?.pathLength??0)&&(r={root:e,relativePath:c,pathLength:t})}o.isDirectory()&&i(s)}};for(let e of t)e.length>n&&e.length>(r?.pathLength??0)&&(r={root:e,relativePath:``,pathLength:e.length});return i(e),r}function QA(e){let t=[],n=r=>{for(let i of be(r,{withFileTypes:!0}).sort((e,t)=>e.name.localeCompare(t.name))){let a=T(r,i.name),o=Ne(e,a);i.isDirectory()?(t.push({relativePath:o,type:`directory`}),n(a)):i.isFile()&&t.push({relativePath:o,type:`file`})}};return n(e),t}function $A(e,t){let n=QA(e),r=new Set(n.map(e=>e.relativePath));C(t,{recursive:!0});for(let r of n){let n=T(e,r.relativePath),i=T(t,r.relativePath);if(S(i)){let e=ve(i);(!(r.type===`directory`?e.isDirectory():e.isFile())||e.isSymbolicLink())&&we(i,{recursive:!0,force:!0})}r.type===`directory`?C(i,{recursive:!0}):(C(je(i),{recursive:!0}),me(n,i))}let i=QA(t).filter(e=>!r.has(e.relativePath)).sort((e,t)=>t.relativePath.length-e.relativePath.length);for(let e of i)we(T(t,e.relativePath),{recursive:!0,force:!0})}function ej(e){let t=e?.code;return t===`EPERM`||t===`EBUSY`}function tj(e){try{S(e)&&we(e,{recursive:!0,force:!0})}catch{}}function nj(e,t,n={}){C(je(t),{recursive:!0});let r=`${t}.old-${Date.now()}`;if(S(t))try{Ce(t,r)}catch(i){if(!(n.allowInPlaceFallback??process.platform===`win32`)||!ej(i))throw i;try{$A(t,r),$A(e,t),tj(r);return}catch(e){try{S(r)&&$A(r,t)}catch{}throw Error(`Skill directory is in use and could not be updated in place. Close running agent hosts and retry. / Skill 目录正被占用,无法原地更新;请关闭正在运行的 Agent 后重试。 ${e instanceof Error?e.message:String(e)}`,{cause:e})}}try{Ce(e,t)}catch(e){throw S(r)&&!S(t)&&Ce(r,t),e}tj(r)}function rj(e){if(e instanceof O){let t=e.api?.httpStatus;if(t!==void 0){if(t===408||t===429)return!0;if(t>=400&&t<500)return!1}return!0}return!0}function ij(e){return e instanceof O&&e.api?.httpStatus===429}function aj(e,t){return Math.min(t*2**(e-1),1e4)}function oj(e){return new Promise(t=>setTimeout(t,e))}async function sj(e,t=3){let n=typeof t==`number`?{attempts:t}:t,r=n.attempts??3,i=n.shouldRetry??rj,a=n.backoffBaseMs??500,o;for(let t=1;t<=r;t++)try{return await e(t)}catch(e){if(o=e,t>=r||!i(e,t))break;ij(e)&&await oj(aj(t,a))}throw o}function cj(){return(process.env.BAILIAN_SKILL_REGISTRY_URL?.trim()||`https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/skills`).replace(/\/+$/,``)}async function lj(e=3e4,t=3){return sj(async()=>{let t=`${cj()}/index.json`,n;try{n=await Fn.fetch(t,{signal:AbortSignal.timeout(e)})}catch(e){throw new O(`Cannot access skill registry: ${t}`,D.NETWORK,`Check network connectivity; if using a private mirror, verify BAILIAN_SKILL_REGISTRY_URL configuration`,{cause:e})}if(!n.ok)throw new O(`Skill registry returned HTTP ${n.status}: ${t}`,D.NETWORK,n.status===404?`Skill index not yet published or registry URL is incorrect; confirm the publisher has generated index.json`:`Remote error, retry later`);let r;try{r=await n.json()}catch(e){throw new O(`Skill index index.json is not valid JSON`,D.GENERAL,`Remote may be in the middle of publishing, retry later`,{cause:e})}let i=r;if(typeof i!=`object`||!i||typeof i.skills!=`object`||i.skills===null)throw new O(`Skill index index.json has invalid structure`,D.GENERAL,`Retry later or contact the publisher`);return i},{attempts:t})}const uj=/^sha256-[0-9a-f]{64}\.tar\.br$/;function dj(e){let t=e?.object;return t&&uj.test(t)?t:`skill.tar.br`}async function fj(e,t,n=3){return sj(async()=>{let n=`${cj()}/${e}/${dj(t)}`,r;try{r=await Fn.fetch(n,{signal:AbortSignal.timeout(12e4)})}catch(t){throw new O(`Failed to download skill ${e}: ${n}`,D.NETWORK,`Network error, retryable`,{cause:t})}if(!r.ok)throw new O(`Failed to download skill ${e}: HTTP ${r.status}`,D.NETWORK,r.status===404?`index.json and skill object are temporarily inconsistent (publishing in progress), retry later`:`Remote error, retry later`);return Buffer.from(await r.arrayBuffer())},{attempts:n})}function pj(e){return e.replace(/[\\/:*?"<>|\s]+/g,`-`).replace(/\.\.+/g,`-`).replace(/^[-.]+|[-.]+$/g,``)||`unnamed-skill`}function mj(e){return e.length>0&&pj(e)===e}function hj(e,t){throw new O(`Skill ${e} validation failed: ${t}`,D.GENERAL,`This skill package does not conform to the SKILL.md spec; contact the skill publisher to fix and republish`)}function gj(e){if(!e.startsWith(`---`))return null;let t=/^---\r?\n([\s\S]*?)\r?\n---(\r?\n|$)/.exec(e);return t?t[1]:null}function _j(e,t){let n=T(e,`SKILL.md`),r;try{Te(n).isFile()||hj(t,`SKILL.md is not a regular file`),r=ye(n,`utf-8`)}catch(e){if(e instanceof O)throw e;hj(t,`missing SKILL.md`)}let i=gj(r);i===null&&hj(t,`SKILL.md is missing frontmatter (--- delimited YAML header)`);let a;try{a=y(i)}catch{hj(t,`frontmatter is not valid YAML`)}(typeof a!=`object`||!a)&&hj(t,`frontmatter is not a key-value structure`);let o=a,s=typeof o.name==`string`?o.name.trim():``,c=typeof o.description==`string`?o.description.trim():``;return(!s||!c)&&hj(t,`frontmatter is missing non-empty name / description fields`),{name:s,description:c}}function vj(e){if(!mj(e))throw new O(`Invalid skill name: ${e}`,D.GENERAL,`Skill name contains path separators, traversal sequences, or other illegal characters; refusing to write to disk`)}async function yj(e,t,n,r){vj(e);let i=wA(),a=T(i,e),o=T(i,`.tmp-${e}-${process.pid}-${Date.now()}`);try{C(o,{recursive:!0}),await YA(t,o);let i=ZA(o,r??(process.platform===`win32`?[a]:[]));if(i)throw new O(`Skill ${e} contains a Windows-incompatible path (${i.pathLength} characters): ${i.relativePath}`,D.GENERAL,`The skill package must shorten this path before it can be installed safely on Windows. / Skill 包必须缩短该路径后才能在 Windows 上安全安装。`);if(n?.startsWith(`sha256:`)){let t=XA(o);if(t!==n)throw new O(`Skill ${e} failed integrity check: index says ${n}, archive is ${t}`,D.GENERAL,`Downloaded archive does not match the index fingerprint (registry may be mid-publish); retry later`)}let s=_j(o,e);return nj(o,a),{name:e,path:a,meta:s}}finally{try{S(o)&&we(o,{recursive:!0,force:!0})}catch{}}}async function bj(e,t,n,r){if(t.compression&&t.compression!==`tar.br`)throw new O(`Skill ${e} uses unsupported compression format: ${t.compression}`,D.GENERAL,`Upgrade bailian-cli to the latest version and retry`);return yj(e,await fj(e,t,n),t.contentHash,r)}function xj(e){vj(e);let t=T(wA(),e);return S(t)?(we(t,{recursive:!0,force:!0}),!0):!1}function Sj(e,t){return{...e.contentHash?{contentHash:e.contentHash}:{},...e.publishedAt?{publishedAt:e.publishedAt}:{},installedAt:(/* @__PURE__ */ new Date()).toISOString(),sourceType:`oss`,...e.description?{description:e.description}:{},links:t}}async function Cj(e,t,n=LA(),r=[],i){await bj(e,t,i,process.platform===`win32`?[T(wA(),e),...n.map(t=>T(t.skillsDir,e))]:void 0);let a=GA(e,n,r);return{lockEntry:Sj(t,a.links),linkedAgents:a.linkedAgents}}const wj=`bailian-docs-llm-wiki`;function Tj(){return T(qt(),`skills/bailian-docs-llm-wiki`)}function Ej(){return S(T(Tj(),`models`,`models.jsonl`))}function Dj(){return T(qt(),`wiki-sync-state.json`)}function Oj(){try{return JSON.parse(ye(Dj(),`utf-8`))}catch{return null}}function kj(e){try{Oe(Dj(),JSON.stringify(e))}catch{}}function Aj(e){try{kA(wj,e)}catch{}}function jj(e){try{let t=DA().skills[wj];return t?.contentHash!==e||!Array.isArray(t.links)}catch{return!0}}async function Mj(){try{return(await lj(3e3,1)).skills[wj]??null}catch{return null}}async function Nj(){let e=Oj(),t=Date.now();if(e&&t-e.lastChecked<432e5&&Ej())return!1;let n=await Mj();if(!n?.contentHash)return!1;if(Ej()&&(!e||e.contentHash===n.contentHash)){if(kj({lastChecked:t,contentHash:n.contentHash}),jj(n.contentHash)){let e=DA().skills[wj]?.links??[];Aj(Sj(n,GA(wj,LA(),e).links))}return!1}try{let e=DA().skills[wj]?.links??[];Aj((await Cj(wj,n,LA(),e,1)).lockEntry)}catch{return!1}return kj({lastChecked:t,contentHash:n.contentHash}),!0}const Pj={Text:`Text`,Image:`Image`,Video:`Video`,Audio:`Audio`},Fj={Single:`single`,Pipeline:`pipeline`},Ij={Low:`low`,Medium:`medium`,High:`high`},Lj={Standard:`standard`,Large:`large`,ExtraLarge:`extra-large`},Rj={Flagship:`flagship`,Balanced:`balanced`,CostOptimized:`cost-optimized`},zj={TG:`TG`,Reasoning:`Reasoning`,VU:`VU`,IG:`IG`,VG:`VG`,TTS:`TTS`,ASR:`ASR`,RealtimeASR:`Realtime-ASR`,RealtimeTTS:`Realtime-Text-to-Speech`,RealtimeAudioTranslate:`Realtime-Audio-Translate`,RealtimeOmni:`Realtime-Omni`,MultimodalOmni:`Multimodal-Omni`,ME:`ME`,TR:`TR`,ThreeDGeneration:`3D-generation`},Bj={FunctionCalling:`function-calling`,WebSearch:`web-search`,StructuredOutputs:`structured-outputs`,PrefixCompletion:`prefix-completion`},Vj={Flagship:`Flagship`,CostOptimized:`Cost-optimized`},Hj=`bailian-cli`,Uj=`install-method`,Wj=/* @__PURE__ */ new Set([`binary`,`npm`,`brew`,`winget`,`unknown`]);function Gj(e){return e?T(qt(),`${Uj}.${e}`):T(qt(),Uj)}function Kj(){if(process.env.BAILIAN_COMPILED===`1`)return!0;let e=process.execPath.replaceAll(`\\`,`/`);return/(^|\/)node(\.exe)?$/i.test(e)||e.includes(`/node/`)||/(^|\/)bun(\.exe)?$/i.test(e)||e.includes(`/.bun/`)?!1:/\/(bl|bailian)(\.exe)?$/i.test(e)}function qj(e){if(!e)return null;let t=e.trim().toLowerCase();return Wj.has(t)?t:null}function Jj(e){try{return qj(ye(e,`utf-8`).split(`
360
+ `)[0])}catch{return null}}function Yj(){let e=qj(process.env.BAILIAN_INSTALL_METHOD);if(e)return e;if(Kj()){let e=process.execPath.replaceAll(`\\`,`/`);return e.includes(`/Cellar/`)||e.includes(`/homebrew/`)?`brew`:`binary`}return`npm`}function Xj(e){let t=qj(process.env.BAILIAN_INSTALL_METHOD);if(t)return t;if(e?.clientName){let t=Jj(Gj(e.clientName));if(t)return t;if(e.clientName===`bailian-cli`){let e=Jj(Gj());if(e)return e}return Yj()}return Jj(Gj())||Yj()}function Zj(e){let t=Xj(e);return t===`binary`&&e.npmPackage!==`bailian-cli`?`npm`:t}function Qj(e,t={clientName:Hj}){try{let n=qt();S(n)||C(n,{recursive:!0,mode:448}),Oe(Gj(t.clientName),`${e}\n`,{mode:384}),t.clientName===`bailian-cli`&&Oe(Gj(),`${e}\n`,{mode:384})}catch{}}const $j=`https://bailian-wiki.oss-cn-hangzhou.aliyuncs.com/release`,eM=`https://github.com/modelstudioai/cli/releases`,tM=`https://bailian.aliyun.com/cli/install.sh`,nM=`https://bailian.aliyun.com/cli/install.ps1`;function rM(){let e=process.env.BAILIAN_CLI_CDN?.trim();return e?e.replace(/\/$/,``):$j}function iM(e=`latest`){let t=e.trim();return!t||t===`latest`||t===`stable`?`${rM()}/manifest.json`:`${rM()}/${t}.json`}function aM(e,t){let n=e.startsWith(`v`)?e:`v${e}`;return`${rM()}/${n}/${t}`}function oM(){let e=process.platform,t=process.arch,n;if(e===`darwin`)n=`darwin`;else if(e===`linux`)n=`linux`;else if(e===`win32`)n=`windows`;else throw Error(`Unsupported platform for binary updates: ${e}`);let r;if(t===`arm64`)r=`arm64`;else if(t===`x64`)r=`x64`;else throw Error(`Unsupported architecture for binary updates: ${t}`);if(n===`windows`&&r===`arm64`)throw Error(`windows arm64 is not supported for binary updates; use: npm install -g bailian-cli`);return{os:n,arch:r,fileSuffix:e===`win32`?`.exe`:``}}function sM(e,t,n,r=!1){return`bl-${e}-${t}-${n}.zip`}function cM(e,t,n){if(t!==`windows`)return`bl-${e}-${t}-${n}.tar.gz`}function lM(e,t,n,r=!1){return`bl-${e}-${t}-${n}${r?`.exe`:``}`}function uM(e){return new Promise((t,n)=>{fe.open(e,{lazyEntries:!0},(r,i)=>{if(r||!i){n(r??/* @__PURE__ */ Error(`Failed to open zip: ${e}`));return}t(i)})})}function dM(e){let t=e.replace(/\\/g,`/`);return t.includes(`/`)?t.slice(t.lastIndexOf(`/`)+1):t}async function fM(e,t,n){let r=await uM(e);return new Promise((i,a)=>{let o=!1,s=e=>{if(!o){o=!0;try{r.close()}catch{}a(e instanceof Error?e:Error(String(e)))}},c=e=>{if(!o){o=!0;try{r.close()}catch{}i(e)}};r.on(`error`,s),r.on(`end`,()=>{o||s(/* @__PURE__ */ Error(n?`Zip entry not found: ${n} in ${e}`:`Zip has no file entries: ${e}`))}),r.on(`entry`,e=>{if(o)return;let i=e.fileName.replace(/\\/g,`/`);if(i.endsWith(`/`)){r.readEntry();return}let a=dM(i);if(n&&i!==n&&a!==n){r.readEntry();return}r.openReadStream(e,(n,r)=>{if(n||!r){s(n??/* @__PURE__ */ Error(`Failed to read zip entry: ${e.fileName}`));return}(async()=>{try{await Be(je(t),{recursive:!0}),await nt(r,_e(t)),c(a)}catch(e){s(e)}})()})}),r.readEntry()})}function pM(e,t){let n=(e??(t?`all`:``)).trim();if(!n)throw new k(`--name cannot be empty`,`Use --name all or --name skill-a,skill-b`);let r=[...new Set(n.split(`,`).map(e=>e.trim()).filter(Boolean))];if(r.includes(`all`)){if(r.length>1)throw new k(`--name all cannot be mixed with specific skill names`,`Use either all or a comma-separated list of names`);return`all`}return r}function mM(){let e=wA();return S(e)?be(e).filter(t=>{if(t.startsWith(`.`)||t.includes(`.tmp-`)||t.includes(`.old-`))return!1;try{return Te(T(e,t)).isDirectory()}catch{return!1}}):[]}function hM(e,t,n){let r=new Set(n),i=/* @__PURE__ */ new Set,a=[];for(let[n,o]of Object.entries(e.skills)){i.add(n);let e=t.skills[n];if(e){let t=r.has(n)?e.contentHash===o.contentHash?`installed`:`outdated`:`missing`;a.push({name:n,status:t,publishedAt:o.publishedAt,description:o.description})}else r.has(n)?a.push({name:n,status:`untracked`,publishedAt:o.publishedAt,description:o.description}):a.push({name:n,status:`not-installed`,publishedAt:o.publishedAt,description:o.description})}for(let[e,n]of Object.entries(t.skills))i.has(e)||(i.add(e),a.push({name:e,status:r.has(e)?`installed`:`missing`,publishedAt:n.publishedAt,description:n.description}));for(let e of n)i.has(e)||a.push({name:e,status:`untracked`});return a.sort((e,t)=>e.name<t.name?-1:+(e.name>t.name))}export{jA as AGENT_ENV_KEYS,jv as AIGC_MCP_SERVER,Mv as AIGC_MCP_TOOL,kt as API_KEY_CAPABILITY_PATTERN,EE as ASYNC_FLAG,Ct as BAILIAN_HOST,Xx as BATCH_CSV_COLUMNS,Dx as BATCH_ENDPOINTS,Ox as BATCH_STATUSES,kx as BATCH_TERMINAL,NT as BILLING_METHOD,Hj as BINARY_PRODUCT_CLIENT_NAME,O as BailianError,zx as BatchValidator,Ij as Budgets,cC as CALC_DATASETS_TOKENS_API,Wn as CHANNEL,FT as CHARGE_TYPE,ME as COMMAND_PACK_API_VERSION,TE as CONCURRENT_FLAG,Et as CONFIG_FILE_KEYS,OE as CONSOLE_AUTH_FLAGS,Iy as CONSOLE_DATASET_BY_ID_API,Ry as CONSOLE_DATASET_GROUPS_API,Ly as CONSOLE_DATASET_VERSIONS_API,$T as CONSOLE_DEPLOY_INSTANCES_API,ky as CONSOLE_FILE_URL_API,zj as Capabilities,rg as Client,Fj as Complexities,Lj as ContextNeeds,_t as CredentialError,qn as DASHSCOPE_SERVICE_HEADER,_b as DECISION_QUESTION_TYPES,aS as DECISION_REGIONS,PT as DEFAULT_BILLING_METHOD,$j as DEFAULT_CLI_CDN_BASE,iS as DEFAULT_DECISION_MODEL,oS as DEFAULT_DECISION_REGION,jT as DEFAULT_DEPLOY_PLAN,nM as DEFAULT_INSTALL_PS1_URL,tM as DEFAULT_INSTALL_SCRIPT_URL,Tt as DEFAULT_LANGUAGE,sA as DEFAULT_LLM_MODEL,tw as DEFAULT_PROXY_POLICY,Iw as DEFAULT_PYTHON_MIRRORS,hw as DEFAULT_RUNS_TTL_MS,PS as DEFAULT_TRAINING_TYPE,JT as DEPLOY_LIST_INDEPENDENT_API,AT as DEPLOY_PLAN,KT as DEPLOY_START_API,qT as DEPLOY_STOP_API,St as DOCS_HOSTS,lC as ESTIMATE_FINETUNE_TOKENS_API,D as ExitCode,FS as FINETUNE_CATALOG_SUPPORTS,Bj as Features,eM as GITHUB_RELEASES_BASE,wE as GLOBAL_FLAGS,VS as INSUFFICIENT_SAMPLES_CODE,lE as LIST_SUPPORT_IMPORT_MODELS_API,AD as LLMError,Ax as MAX_BATCH_BYTES,jx as MAX_BATCH_LINE_BYTES,Mx as MAX_BATCH_RECORDS,Qy as MAX_CPT_BYTES,Zy as MAX_DATASET_BYTES,vb as MAX_DECISION_CHOICE_OPTIONS,$y as MAX_DECISION_DATASET_BYTES,bb as MAX_DECISION_SCORE_LEVELS,eb as MAX_MEDIA_ZIP_BYTES,Gn as MCP_CALL_SERVICE,Vv as MCP_IMAGE_GEN_RATIO_SIZES,Uv as MCP_TTS_VOICES,yb as MIN_DECISION_SCORE_LEVELS,DE as MODEL_AUTH_FLAGS,uy as MODEL_LIST_API,Gh as McpClient,Pj as Modalities,Vj as ModelCategories,kE as OPENAPI_AUTH_FLAGS,Kn as OPEN_API_SOURCE,dy as PREDICT_CONFIG_API,Rj as QualityPreferences,z_ as RAG_PATHS,rA as RECOMMEND_TOOLS,xt as REGIONS,OC as RL_AUTH_API,jw as RL_DASHSCOPE_VERSION,Mw as RL_DASHSCOPE_WHEEL_SHA256,qw as RL_DEPENDENCY_LOCK,Fw as RL_PIP_INDEX_ENV,Pw as RL_PYTHON_MIRROR_ENV,Nw as RL_PYTHON_VERSION,Jw as RUNTIME_OVERRIDE_ENV,ry as SANDBOX_NETWORK_HINT,P_ as SANDBOX_PATHS,AA as SKIP_HOST_AGENTS_ENV,pE as SPEECH_BIASING_MODEL,WT as STRATEGIES,wt as SUPPORTED_LANGUAGES,sC as TRAINING_MODEL_PRICE_API,NS as TRAINING_TYPES_CLI,MS as TRAINING_TYPE_MAP,k as UsageError,vn as activateConfigProfile,oA as agentLoop,A_ as agentStudioFilesPath,Jg as agentStudioHost,UD as analyzeEngineIntent,zn as anonymousConsoleCall,Ag as appCompletionPath,Kw as assertArtifactIntegrity,pT as assertDoctorPassed,nj as atomicSwap,vr as audioFileToDataUri,Zh as bailianMcpPath,Qh as bailianMcpSsePath,Ix as batchChunks,rS as batchDataNotes,nS as batchExamples,Nx as batchIoError,Lx as batchLines,Px as batchObject,Q as batchUsage,sM as binaryAssetFileName,lM as binaryInnerFileName,cM as binaryTarFileName,rr as buildAcsCanonicalQuery,lv as buildAsrContextMessages,dv as buildAsrFlashRequest,uv as buildAsyncAsrLanguageFields,ww as buildBwrapArgs,Ty as buildCommandInvocation,Hy as buildConsoleDatasetGroupsRequest,Jy as buildConsoleDatasetVersionRequest,Wy as buildConsoleDatasetVersionsRequest,eE as buildConsoleDeploymentInstancesRequest,nA as buildEngineInput,Fv as buildImageEditArgs,Pv as buildImageGenArgs,Lv as buildImageToVideoArgs,Sn as buildOutputSettings,BT as buildPrepaidInfo,LT as buildReservationCapacity,WC as buildSandboxEnv,bw as buildSbplProfile,wn as buildSettings,Sj as buildSkillLockEntry,xn as buildSources,Bv as buildSpeechToTextArgs,DC as buildTaskYaml,Iv as buildTextToVideoArgs,zv as buildTtsArgs,Rv as buildVideoFetchArgs,mE as buildVocabularyRequest,Vw as bundledRuntimeManifest,Hn as callConsoleGateway,Wx as cancelBatch,AS as cancelCompressJob,_S as cancelFineTune,iM as channelManifestUrl,pg as chatPath,_w as cleanupSandboxArtifacts,pv as collectAsrTranscriptionItems,Dy as commandRef,XA as computeDirContentHash,hM as computeSkillStatuses,tg as connectBailianMcpWithFallback,Xy as consoleDatasetStatusAvailability,Ov as createBailianControlUser,Hx as createBatch,xT as createCapacityInstance,ES as createCompressJob,aE as createCustomModelImport,Sw as createDarwinAdapter,hT as createDeployment,mS as createFineTune,wv as createInstrumentedFetch,kw as createIsolationAdapter,cA as createLLMClient,Ew as createLinuxAdapter,CA as createNonInteractive,SA as createReadlineInteraction,tA as createSession,$C as createSnapshot,BC as createTaskDir,eD as createTrackingEvent,gE as createVocabulary,Dw as createWindowsAdapter,AE as credentialFlagDefs,$w as currentManagedRuntimeId,bg as decisionPath,MT as defaultDeployPlan,jE as defineCommand,wT as deleteCapacityInstance,jS as deleteCompressJob,yn as deleteConfigProfile,cE as deleteCustomModelImport,Fy as deleteDataset,ET as deleteDeployment,vS as deleteFineTune,bE as deleteVocabulary,x_ as deploymentCapacityInstancePath,C_ as deploymentCapacityInstanceRenewPath,S_ as deploymentCapacityInstanceScalePath,b_ as deploymentCapacityInstancesPath,T_ as deploymentCapacityOperationPath,w_ as deploymentOverflowPath,Kt as describeAuthState,oM as detectBinaryPlatform,Yj as detectInstallMethod,LA as detectInstalledAgents,Aw as detectIsolation,hx as detectModality,en as detectOutputFormat,iA as dispatchTool,fj as downloadSkillAsset,Rn as effectiveConsoleGatewayConfig,EA as emptySkillLock,Xt as ensureConfigDir,fC as estimateCptTokens,dC as estimateSftDpoTokens,cT as executeInSandbox,mw as executeIsolatedRun,tS as exportBatchCsv,CS as exportCheckpoint,fv as extractAsrFlashText,PC as extractEnabledFlag,YA as extractTarBr,fM as extractZipEntryToFile,GA as fanOutSkillToAgents,BS as fetchModelCapability,yy as fetchModelDetail,gy as fetchModelGroups,vy as fetchModelGroupsAll,py as fetchModelList,my as fetchModelListAll,Sy as fetchPredictConfig,lj as fetchSkillsIndex,uC as fetchTrainingModelPrice,QT as findDeploymentEntry,hy as findModelByName,dE as findSupportImportModel,_y as flattenModelGroups,xD as flushTelemetry,fS as followParsexResult,Ey as formatCommand,ND as formatDegradation,$t as formatErrorJson,Ex as formatIssue,Qt as formatJson,tn as formatOutput,Zt as formatText,sg as generateCLIAccessToken,PE as generateFilename,MA as getAgentTargets,Dn as getApiKeyLoginKind,Ux as getBatch,Kx as getBatchFileContent,yT as getCapacityInstance,bT as getCapacityOperation,rM as getCliCdnBase,OS as getCompressJob,kS as getCompressJobLogs,qt as getConfigDir,Jt as getConfigPath,qy as getConsoleDatasetById,jy as getConsoleFileUrl,Yt as getCredentialsPath,sE as getCustomModelImport,Py as getDataset,_T as getDeployment,gS as getFineTune,KS as getFineTuneHyperParameterDefaultNumber,yS as getFineTuneLogs,bS as getFineTuneParams,FE as getHermesHome,Xj as getInstallMethod,En as getModelProfilePreset,dS as getParsexResult,aC as getProfile,TA as getSkillLockPath,cj as getSkillRegistryBaseUrl,wA as getSkillsDir,Zj as getUpdateInstallMethod,RT as hasPrepaidFlags,Fn as httpTransport,wg as image2ImagePath,Eg as image2videoPath,_r as imageFileToDataUri,xg as imagePath,Sg as imageSyncPath,Cg as imageText2ImagePath,cv as inferAudioFormatHint,kb as inspectDecisionQuestion,jb as inspectDecisionQuestionId,Ab as inspectDecisionQuestionTable,Mb as inspectDecisionQuestions,Tb as inspectDecisionState,oT as installRuntime,bj as installSkill,yj as installSkillFromBuffer,Cj as installSkillWithFanout,At as isApiKeyCapability,Kj as isCompiledBinary,gv as isDashScopeGateway,Sb as isDecisionObject,nw as isDeniedIp,FA as isHostSystemDetectDir,J_ as isLegacyImage2ImageModel,q_ as isLegacyText2ImageModel,xr as isLocalFile,Wv as isMcpTtsVoice,Lt as isModelConnectionSourceMismatch,JA as isSafeEntryName,mj as isSafeSkillName,ny as isSandboxNetworkDenialCode,$h as isStreamableHttpUnsupported,U_ as isSyncMultimodalImageModel,IS as isTrainingTypeCli,eg as isUrlOverrideSseFallbackCandidate,Y_ as isWanxFunctionImageEditModel,qg as knowledgeChatEndpoint,Kg as knowledgeSearchEndpoint,WA as linkSkillToAgents,kv as listBailianControlWorkspaces,xS as listBasicMetrics,Gx as listBatches,vT as listCapacityInstances,SS as listCheckpoints,DS as listCompressJobs,TS as listCompressTemplates,Uy as listConsoleDatasetGroups,Ky as listConsoleDatasetVersions,iE as listConsoleDeploymentInstances,oE as listCustomModelImports,Ny as listDatasets,DT as listDeployableModels,gT as listDeployments,hS as listFineTunes,ZT as listIndependentDeployedModels,mM as listSkillDirsOnDisk,uE as listSupportImportModels,Tx as listSupportedFormats,zS as listSupportedTrainingTypes,oC as listTrainingTypes,_E as listVocabularies,yA as loadCatalog,bA as loadFamilies,SD as localSink,An as makeAuthStore,Cy as makeConfigStore,Zw as managedPythonPath,HC as managedRuntimesRoot,vt as mapApiError,zE as maskToken,Nj as maybeSyncWikiData,Qg as mcpWebSearchPath,Mg as memoryAddAsyncPath,jg as memoryEndpoint,Ng as memoryEventPath,Fg as memoryListPath,Ig as memoryNodePath,Pg as memorySearchPath,Lg as memorySkillExportPath,RS as modelSupportsTrainingType,Og as modelsLimitsPath,kg as modelsPermissionsPath,ty as networkCauseCode,RC as newRunId,jt as normalizeApiKeyCapabilities,cn as normalizeConfigName,yt as normalizeModelBaseUrl,sT as normalizeSandboxResult,Xv as parseAigcAsrTexts,Kv as parseAigcImageResults,Nv as parseAigcToolResult,qv as parseAigcTtsResult,Jv as parseAigcVideoTaskId,Yv as parseAigcVideoTaskResult,hC as parseAssignment,Fx as parseBatchEndpoint,UE as parseBooleanValue,Nt as parseConfigFile,nb as parseDatasetSchemaFlag,gC as parseDottedAssignment,SE as parseInstantVocabulary,bC as parseJobYaml,mC as parseJsonValue,_C as parseNumericValue,WE as parseOptionalBooleanValue,Bw as parseRuntimeManifest,$v as parseSSE,bv as parseSecurityBody,pM as parseSkillNames,pC as parseTypedValue,CE as parseVocabularyEntries,dg as parsexBaseUrl,fg as parsexEndpoint,GT as pickPlanStrategy,Sx as pickValidator,KA as planUnlinkSkillFromAgents,HS as preflightBatchSizeGate,Yx as prepareBatch,GC as prepareTaskHome,Tw as probeBwrap,xw as probeSandboxExec,iy as probeTcpHost,Hg as profileSchemaItemPath,Vg as profileSchemaPath,eS as projectBatchCsv,Gw as pythonDownloadCandidates,Yy as queryConsoleDatasetVersion,vE as queryVocabulary,k_ as ragEndpoint,Vx as readBatchBlob,$E as readCaller,fn as readConfigFile,hn as readConfigProfiles,DA as readSkillLock,VE as readTextFromPathOrStdin,Hk as recommendEngine,yr as redactDataUri,cg as refreshAccessToken,Cx as registerValidator,aM as releaseAssetUrl,CD as remoteSink,xj as removeSkillDir,Oy as renderCommandText,CT as renewCapacityInstance,Qn as request,nr as requestJson,fE as requiredTrainTypeForWeightType,Av as resetBailianControlPolicies4Agent,xA as resetCatalogCache,Bt as resolveApiKey,Pt as resolveApiKeySource,sv as resolveAsrApi,dj as resolveAssetFileName,qx as resolveBatchChatEndpoint,GE as resolveBooleanFlag,ag as resolveCLIAccessTokenTarget,Vt as resolveConsole,Sr as resolveFileUrl,ev as resolveImageEditApi,$_ as resolveImageGenerateApi,X_ as resolveImageSizeProfile,Hv as resolveMcpImageSize,zt as resolveModelBaseUrl,Ft as resolveModelBaseUrlSource,Rt as resolveModelBaseUrlState,It as resolveModelConnectionProvenance,Ht as resolveOpenApi,RE as resolveOutputDir,Z_ as resolvePromptExtendDefault,Cn as resolveRecoveryConfigName,rT as resolveRuntime,EC as resolveTrainingSpec,KE as resolveWatermark,yg as responsesPath,bO as routeEngine,LC as runRlAuthorization,dT as runRuntimeDoctor,dw as runSandboxedProcess,HE as runWithConcurrency,zC as runsRoot,UC as runtimeCacheRoot,Yw as runtimeDownloadFailure,VC as runtimeRoot,M_ as sandboxApiPath,j_ as sandboxBaseUrl,N_ as sandboxEndpoint,I_ as sandboxInstanceActionPath,F_ as sandboxInstancePath,R_ as sandboxTemplateBuildStatusPath,L_ as sandboxTemplatePath,ht as sanitizeDiagnosticDetails,fw as sanitizeSecrets,pj as sanitizeSkillName,ST as scaleCapacityInstance,OT as scaleDeployment,Zg as securityAgentLogsEndpoint,xv as securityGet,Xg as securityOverviewEndpoint,bn as selectApiKeyResolutionSources,Hw as selectManifestEntry,Uw as sha256Hex,ir as signAcsRequest,Jn as sourceConfig,zg as speechRecognizePath,Rg as speechSynthesizePath,Bg as speechVocabularyPath,ew as stageDataFiles,YT as startModelService,lw as startWhitelistProxy,XT as stopModelService,lS as stripDecisionTrainingFields,BE as stripUndefined,uS as submitParsexTask,Dg as taskPath,DD as trackCommandExecution,Yn as trackingHeaders,LS as trainingTypeMethodVariant,qA as unlinkSkillFromAgents,ly as unwrapConsoleResponse,cS as unwrapDecisionQuestions,fy as unwrapResponse,kT as updateDeployment,TT as updateDeploymentOverflow,yE as updateVocabulary,My as uploadDataset,br as uploadFile,kA as upsertSkillLockEntry,Ug as userProfilePath,Wg as userProfileValuesPath,Bx as validateBatch,_n as validateConfigProfileActivation,og as validateConsoleAccessToken,wx as validateDataset,GS as validateFineTuneHyperParameterOverrides,zT as validatePrepaidFlags,IT as validateReservationCapacity,_j as validateSkillDir,rn as validateTimeout,Tg as videoGeneratePath,iw as withEndpointDomain,Gg as workspaceMaaSBaseUrl,Jx as writeBatchFile,pn as writeConfigFile,Qj as writeInstallMethodSync,OA as writeSkillLock};