@kaptures/cli 0.0.1 → 0.0.2
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/README.md +49 -11
- package/dist/dashboard/assets/{index-BZsjRjeC.js → index-NDgXncO0.js} +1 -1
- package/dist/dashboard/index.html +1 -1
- package/dist/index.js +322 -101
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as e}from"node:module";import{formatWithOptions as t,parseArgs as n}from"node:util";import{spawn as r}from"node:child_process";import{basename as i,dirname as a,extname as o,
|
|
3
|
-
`)}function
|
|
4
|
-
`)}catch(e){console.error(e)}}const
|
|
5
|
-
`)}async function
|
|
6
|
-
`),process.exit(1)}}var Ve=`0.0.1`;const He=e(import.meta.url),Ue=Pe({meta:{name:`browser`,description:`Manage the Kapture browser runtime`},subCommands:{install:Pe({meta:{name:`install`,description:`Install the Chrome runtime used by agent-browser`},args:{"with-deps":{type:`boolean`,default:!1,description:`Also install Linux system dependencies`}},async run({args:e}){let t=He.resolve(`agent-browser/package.json`),n=[u(a(t),`bin`,`agent-browser.js`),`install`];e[`with-deps`]&&n.push(`--with-deps`);let i=await new Promise((e,t)=>{let i=r(process.execPath,n,{stdio:`inherit`});i.once(`error`,t),i.once(`exit`,(n,r)=>{r?t(Error(`agent-browser install stopped by ${r}`)):e(n??1)})});if(i!==0)throw Error(`agent-browser install exited with code ${i}`)}})}}),We=`<!-- kapture-report:`,Ge={error:0,removed:1,changed:2,added:3,unchanged:4};function Ke(e){let t={version:e.version,baseRevision:e.baseRevision,headRevision:e.headRevision,environment:e.environment.id,threshold:e.threshold,entries:Object.values(e.entries).sort((e,t)=>e.id.localeCompare(t.id)).map(({id:e,status:t,changedPixels:n,diffRatio:r,threshold:i,error:a})=>({id:e,status:t,changedPixels:n,diffRatio:r,threshold:i,error:a}))};return f(`sha256`).update(JSON.stringify(t)).digest(`hex`)}function qe(e){return`${We}${Buffer.from(JSON.stringify(e)).toString(`base64url`)} -->`}function Je(e){let t=e.indexOf(We);if(t<0)return null;let n=t+20,r=e.indexOf(` -->`,n);if(r<0)return null;try{let t=JSON.parse(Buffer.from(e.slice(n,r),`base64url`).toString());return t.version!==1||!Ze(t.headSha)||!/^[0-9a-f]{64}$/.test(t.digest)||![`clean`,`changed`,`error`].includes(t.status)||t.reportUrl!==void 0&&Qe(t.reportUrl)!==t.reportUrl?null:t}catch{return null}}function Ye(e,t,n=`Kapture Visual Review`){let{summary:r}=e,i=r.changed+r.added+r.removed,a=new Set(Object.values(e.entries).map(e=>e.storyId)).size,o=rt(n,100),s=[qe(t),`## ${o}`,``,r.errors>0?`❌ **${r.errors}개의 실행 오류**를 해결해 주세요.`:i===0?`✅ 시각적 변경이 없습니다.`:`🔍 **${i}개의 시각적 변경**을 검토해 주세요.`,``,`**${a}개 스토리 · ${r.total}개 스냅샷 비교**`,``,`- 동일 ${r.unchanged} · 변경 ${r.changed} · 추가 ${r.added} · 삭제 ${r.removed} · 오류 ${r.errors}`,`- 환경 \`${at(e.environment.id)}\` · base \`${st(e.baseRevision)}\` → head \`${st(e.headRevision)}\``];if(t.reportUrl){let e=ot(t.reportUrl)?`전체 비교 리포트 다운로드`:`전체 비교 리포트 열기`;s.push(``,`[${e}](${t.reportUrl})`)}let c=Object.values(e.entries).filter(e=>e.status!==`unchanged`).sort(tt),l=c.slice(0,20);for(let e of[`error`,`removed`,`changed`,`added`]){let t=c.filter(t=>t.status===e),n=l.filter(t=>t.status===e);if(n.length!==0){s.push(``,`### ${nt(e)} (${t.length})`,``);for(let e of n)s.push(et(e))}}let u=c.length-l.length;return u>0&&s.push(``,`그 외 ${u}개 항목은 전체 비교 리포트에서 확인해 주세요.`),r.errors>0?s.push(``,`⚠️ 캡처 또는 비교 오류를 해결해야 합니다. 승인할 수 없습니다.`):i>0&&s.push(``,`전체 head 빌드를 승인하려면 쓰기 권한이 있는 리뷰어가 다음 명령을 남겨 주세요.`,``,`\`/kapture approve ${e.headRevision}\``),`${s.join(`
|
|
7
|
-
`)}\n`}function Xe(e){return e.trim().match(/^\/kapture\s+approve\s+([0-9a-f]{40})$/i)?.[1]?.toLowerCase()??null}function Ze(e){return/^[0-9a-f]{40}$/i.test(e)}function Qe(e){if(!e)return;if(e.length>2048)throw Error(`Report URL is too long`);let t;try{t=new URL(e)}catch{throw Error(`Report URL must be a valid HTTPS URL`)}if(t.protocol!==`https:`||t.username||t.password)throw Error(`Report URL must be an HTTPS URL without credentials`);return t.toString().replace(/\(/g,`%28`).replace(/\)/g,`%29`).replace(/\[/g,`%5B`).replace(/\]/g,`%5D`)}function $e(e){let t=it(e).replace(/\s+/g,` `).trim();if(!t||t.length>100)throw Error(`Status context must contain between 1 and 100 characters`);return t}function et(e){let t=`**${rt(e.title)} / ${rt(e.name)}** · ${rt(e.viewport.name)}`;return e.status===`error`?`- ${t} — ${rt(e.error??`캡처 또는 비교에 실패했습니다.`,180)}`:e.status===`removed`?`- ${t} — head Storybook에서 찾을 수 없음`:e.status===`added`?`- ${t} — 새 스냅샷`:`- ${t}`}function tt(e,t){let n=Ge[e.status]-Ge[t.status];return n===0?`${e.title}/${e.name}/${e.viewport.name}`.localeCompare(`${t.title}/${t.name}/${t.viewport.name}`):n}function nt(e){return e===`error`?`🚨 실행 오류`:e===`removed`?`⚠️ 삭제된 스냅샷`:e===`changed`?`🔍 시각 변경`:`➕ 추가된 스냅샷`}function rt(e,t=240){let n=it(e).replace(/\s+/g,` `).trim();return(n.length>t?`${n.slice(0,t-3)}...`:n).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\\/g,`\\\\`).replace(/([`*_[\]{}|])/g,`\\$1`).replace(/@/g,`@`)}function it(e){return Array.from(e,e=>{let t=e.codePointAt(0)??0;return t<=31||t===127?` `:e}).join(``)}function at(e){return e.replace(/`/g,`ˋ`).replace(/[\r\n]/g,` `)}function ot(e){return e.includes(`/actions/runs/`)&&e.includes(`/artifacts/`)}function st(e){return e.slice(0,8)}var ct=class{#e;#t;constructor(e,t){if(!e)throw Error(`GITHUB_TOKEN is required`);this.#e=e,this.#t=t}async setReviewStatus(e,t,n,r,i){await this.#r(`POST`,`/statuses/${encodeURIComponent(e)}`,{state:t,description:n.slice(0,140),context:r,target_url:i})}async postOrUpdateReportComment(e,t){let n=(await this.#n(e)).find(e=>e.user?.login===`github-actions[bot]`&&e.body?.includes(`<!-- kapture-report:`));return n?(await this.#r(`PATCH`,`/issues/comments/${n.id}`,{body:t})).id:this.createIssueComment(e,t)}async findCurrentReportMarker(e,t){let n=await this.#n(e);for(let e of n.reverse()){if(e.user?.login!==`github-actions[bot]`||!e.body)continue;let n=Je(e.body);if(n?.headSha===t)return n}return null}async assertWritePermission(e){let t=await this.#r(`GET`,`/collaborators/${encodeURIComponent(e)}/permission`);if(!t.permission||![`admin`,`maintain`,`write`].includes(t.permission))throw Error(`@${e} does not have write permission for this repository`)}async getPullRequest(e){return this.#r(`GET`,`/pulls/${e}`)}async createIssueComment(e,t){return(await this.#r(`POST`,`/issues/${e}/comments`,{body:t})).id}async#n(e){let t=[];for(let n=1;n<=10;n+=1){let r=await this.#r(`GET`,`/issues/${e}/comments?per_page=100&page=${n}`);if(t.push(...r),r.length<100)break}return t}async#r(e,t,n){let{owner:r,repo:i}=this.#t,a=`/repos/${encodeURIComponent(r)}/${encodeURIComponent(i)}${t}`,o=await fetch(`https://api.github.com${a}`,{method:e,headers:{Accept:`application/vnd.github+json`,Authorization:`Bearer ${this.#e}`,"X-GitHub-Api-Version":`2022-11-28`,"User-Agent":`kapture-cli`,...n?{"Content-Type":`application/json`}:{}},body:n?JSON.stringify(n):void 0});if(!o.ok)throw Error(`GitHub API ${e} ${t} failed with status ${o.status}`);return await o.json()}};async function lt(){let e=process.env.GITHUB_EVENT_PATH;if(!e)throw Error(`GITHUB_EVENT_PATH is required`);let t=await y(e);if(!t.isFile()||t.size>10485760)throw Error(`GitHub event payload is missing or too large`);try{return JSON.parse(await v(e,`utf8`))}catch{throw Error(`GITHUB_EVENT_PATH does not contain valid JSON`)}}function ut(e){let t=gt(e,`GitHub event payload`);if(t.action!==`completed`)throw Error(`Kapture report must run for a completed workflow_run event`);let n=gt(t.workflow_run,`workflow_run`);if(n.event!==`pull_request`)throw Error(`Kapture report only accepts workflow_run events created by pull_request`);let r=pt(n.head_sha,`workflow_run.head_sha`),i=n.pull_requests;if(!Array.isArray(i)||i.length!==1)throw Error(`workflow_run must identify exactly one pull request`);let a=gt(i[0],`workflow_run.pull_requests[0]`);return{repository:ft(t),issueNumber:mt(a.number,`pull request number`),headSha:r}}function dt(e){let t=gt(e,`GitHub event payload`);if(t.action!==`created`)throw Error(`Kapture approval only accepts newly created issue comments`);let n=gt(t.issue,`issue`);if(!n.pull_request)throw Error(`Kapture approval must be posted on a pull request`);let r=Xe(ht(gt(t.comment,`comment`).body));if(!r)throw Error(`Expected /kapture approve <full-head-sha>`);let i=ht(gt(t.sender,`sender`).login);if(!/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/.test(i))throw Error(`GitHub event contains an invalid sender login`);return{repository:ft(t),issueNumber:mt(n.number,`pull request number`),headSha:r,sender:i}}function ft(e){let t=ht(gt(e.repository,`repository`).full_name).match(/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)$/);if(!t?.[1]||!t[2])throw Error(`GitHub event contains an invalid repository`);return{owner:t[1],repo:t[2]}}function pt(e,t){let n=ht(e).toLowerCase();if(!Ze(n))throw Error(`${t} must be a full 40-character SHA`);return n}function mt(e,t){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(`${t} must be a positive integer`);return e}function ht(e){if(typeof e!=`string`)throw Error(`GitHub event contains an invalid string value`);return e}function gt(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`${t} must be an object`);return e}async function _t(e,t,n,r,i){if(!Ze(n.baseRevision))throw Error(`Report base ${n.baseRevision} must be a full 40-character SHA`);if(!Ze(n.headRevision)||n.headRevision.toLowerCase()!==t.headSha)throw Error(`Report head ${n.headRevision} does not match workflow head ${t.headSha}`);let a=await e.getPullRequest(t.issueNumber);if(a.number!==t.issueNumber||a.head.sha.toLowerCase()!==t.headSha)throw Error(`Workflow head ${t.headSha} is stale for PR #${t.issueNumber}`);let o=Ke(n),s=n.summary.changed+n.summary.added+n.summary.removed,c=n.summary.errors>0?`error`:s>0?`changed`:`clean`,l={version:1,headSha:t.headSha,digest:o,status:c,reportUrl:i},u=c===`error`?`failure`:c===`changed`?`pending`:`success`,d=c===`error`?`${n.summary.errors} visual capture error(s)`:c===`changed`?`${s} visual change(s) require approval`:`No visual changes`;return await e.setReviewStatus(t.headSha,u,d,r,i),{status:c,changedCount:s,commentId:await e.postOrUpdateReportComment(t.issueNumber,Ye(n,l,r)),reportDigest:o}}async function vt(e,t,n){await e.assertWritePermission(t.sender);let r=await e.getPullRequest(t.issueNumber);if(r.number!==t.issueNumber||r.head.sha.toLowerCase()!==t.headSha)throw Error(`Approval SHA ${t.headSha} is stale; current PR head is ${r.head.sha}`);let i=await e.findCurrentReportMarker(t.issueNumber,t.headSha);if(!i)throw Error(`No Kapture report exists for current head ${t.headSha}`);if(i.status!==`changed`)throw Error(`Kapture report for ${t.headSha} is not eligible for approval (${i.status})`);return await e.setReviewStatus(t.headSha,`success`,`Approved by @${t.sender}`,n,i.reportUrl),await e.createIssueComment(t.issueNumber,`✅ @${t.sender} 님이 Kapture 리포트 \`${i.digest.slice(0,12)}\`를 승인했습니다.`),{status:`approved`,reportDigest:i.digest}}async function yt(e){let t=process.env.GITHUB_OUTPUT;if(!t)return;let n=[];for(let[t,r]of Object.entries(e)){let e=String(r),i=`kapture_${p()}`;n.push(`${t}<<${i}\n${e}\n${i}\n`)}await m(t,n.join(``),`utf8`)}const bt=Pe({meta:{name:`approve`,description:`Approve the current full-SHA Kapture report`},args:{"status-context":{type:`string`,default:`Kapture Visual Review`,description:`GitHub commit status context`}},async run({args:e}){try{let t=process.env.GITHUB_TOKEN;if(!t)throw Error(`GITHUB_TOKEN is required`);let n=dt(await lt()),r=await vt(new ct(t,n.repository),n,$e(e[`status-context`]));await yt({status:r.status,"report-digest":r.reportDigest})}catch(e){throw await yt({status:`error`}),e}}});Object.freeze({status:`aborted`});function E(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}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 xt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},St=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};const Ct={};function wt(e){return e&&Object.assign(Ct,e),Ct}function Tt(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 Et(e,t){return typeof t==`bigint`?t.toString():t}function Dt(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ot(e){return e==null}function kt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function At(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}const jt=Symbol(`evaluating`);function D(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==jt)return r===void 0&&(r=jt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Mt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function O(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Nt(e){return JSON.stringify(e)}function Pt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const Ft=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function It(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Lt=Dt(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Rt(e){if(It(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return It(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function zt(e){return Rt(e)?{...e}:Array.isArray(e)?[...e]:e}const Bt=new Set([`string`,`number`,`symbol`]);function Vt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function k(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 Ht(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const Ut={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Wt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return k(e,O(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Mt(this,`shape`,e),e},checks:[]}))}function Gt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return k(e,O(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Mt(this,`shape`,r),r},checks:[]}))}function Kt(e,t){if(!Rt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return k(e,O(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Mt(this,`shape`,n),n}}))}function qt(e,t){if(!Rt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return k(e,O(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Mt(this,`shape`,n),n}}))}function Jt(e,t){return k(e,O(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Mt(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Yt(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return k(t,O(t._zod.def,{get shape(){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 Mt(this,`shape`,i),i},checks:[]}))}function Xt(e,t,n){return k(t,O(t._zod.def,{get shape(){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 Mt(this,`shape`,i),i}}))}function Zt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Qt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function $t(e){return typeof e==`string`?e:e?.message}function en(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=$t(e.inst?._zod.def?.error?.(e))??$t(t?.error?.(e))??$t(n.customError?.(e))??$t(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function tn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function nn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const rn=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Et,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},an=E(`$ZodError`,rn),on=E(`$ZodError`,rn,{Parent:Error});function sn(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 cn(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}const ln=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 xt;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>en(e,a,wt())));throw Ft(t,i?.callee),t}return o.value},un=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=>en(e,a,wt())));throw Ft(t,i?.callee),t}return o.value},dn=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 xt;return a.issues.length?{success:!1,error:new(e??an)(a.issues.map(e=>en(e,i,wt())))}:{success:!0,data:a.value}},fn=dn(on),pn=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=>en(e,i,wt())))}:{success:!0,data:a.value}},mn=pn(on),hn=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return ln(e)(t,n,i)},gn=e=>(t,n,r)=>ln(e)(t,n,r),_n=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return un(e)(t,n,i)},vn=e=>async(t,n,r)=>un(e)(t,n,r),yn=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return dn(e)(t,n,i)},bn=e=>(t,n,r)=>dn(e)(t,n,r),xn=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return pn(e)(t,n,i)},Sn=e=>async(t,n,r)=>pn(e)(t,n,r),Cn=/^[cC][^\s-]{8,}$/,wn=/^[0-9a-z]+$/,Tn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,En=/^[0-9a-vA-V]{20}$/,Dn=/^[A-Za-z0-9]{27}$/,On=/^[a-zA-Z0-9_-]{21}$/,kn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,An=/^([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})$/,jn=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|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Mn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Nn(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const Pn=/^(?:(?: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])$/,Fn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,In=/^((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])$/,Ln=/^(([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])$/,Rn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,zn=/^[A-Za-z0-9_-]*$/,Bn=/^\+[1-9]\d{6,14}$/,Vn=`(?:(?:\\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])))`,Hn=RegExp(`^${Vn}$`);function Un(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 Wn(e){return RegExp(`^${Un(e)}$`)}function Gn(e){let t=Un({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Vn}T(?:${r})$`)}const Kn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},qn=/^-?\d+$/,Jn=/^-?\d+(?:\.\d+)?$/,Yn=/^[^A-Z]*$/,Xn=/^[^a-z]*$/,j=E(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Zn={number:`number`,bigint:`bigint`,object:`date`},Qn=E(`$ZodCheckLessThan`,(e,t)=>{j.init(e,t);let n=Zn[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:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$n=E(`$ZodCheckGreaterThan`,(e,t)=>{j.init(e,t);let n=Zn[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:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),er=E(`$ZodCheckMultipleOf`,(e,t)=>{j.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):At(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})}}),tr=E(`$ZodCheckNumberFormat`,(e,t)=>{j.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ut[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=qn)}),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`,continue:!1,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,inclusive:!0,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,inclusive:!0,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,inclusive:!0,inst:e,continue:!t.abort})}}),nr=E(`$ZodCheckMaxLength`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ot(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=tn(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),rr=E(`$ZodCheckMinLength`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ot(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=tn(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ir=E(`$ZodCheckLengthEquals`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ot(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=tn(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})}}),ar=E(`$ZodCheckStringFormat`,(e,t)=>{var n,r;j.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=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=()=>{})}),or=E(`$ZodCheckRegex`,(e,t)=>{ar.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})}}),sr=E(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Yn,ar.init(e,t)}),cr=E(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Xn,ar.init(e,t)}),lr=E(`$ZodCheckIncludes`,(e,t)=>{j.init(e,t);let n=Vt(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??=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})}}),ur=E(`$ZodCheckStartsWith`,(e,t)=>{j.init(e,t);let n=RegExp(`^${Vt(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=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})}}),dr=E(`$ZodCheckEndsWith`,(e,t)=>{j.init(e,t);let n=RegExp(`.*${Vt(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=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})}}),fr=E(`$ZodCheckOverwrite`,(e,t)=>{j.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var pr=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(`
|
|
2
|
+
import{createRequire as e}from"node:module";import{formatWithOptions as t,parseArgs as n}from"node:util";import{spawn as r}from"node:child_process";import{basename as i,dirname as a,extname as o,isAbsolute as s,join as c,posix as l,relative as u,resolve as d,sep as f}from"node:path";import{appendFile as p,copyFile as m,cp as h,lstat as g,mkdir as _,mkdtemp as v,open as ee,readFile as y,realpath as te,rename as ne,rm as b,stat as re,writeFile as x}from"node:fs/promises";import{createHash as ie,randomUUID as ae}from"node:crypto";import{arch as oe,platform as se,release as ce}from"node:os";import{createServer as le}from"node:http";import{constants as ue}from"node:fs";import{fileURLToPath as de}from"node:url";import S,{stdin as fe,stdout as pe}from"node:process";import*as me from"node:tty";import{WriteStream as he}from"node:tty";import ge from"node:readline";var _e=Object.defineProperty,ve=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},C=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),ye=(e,t)=>{let n={};for(var r in e)_e(n,r,{get:e[r],enumerable:!0});return t||_e(n,Symbol.toStringTag,{value:`Module`}),n},w=e(import.meta.url);const be=/\d/,xe=[`-`,`_`,`/`,`.`];function Se(e=``){if(!be.test(e))return e!==e.toLowerCase()}function Ce(e,t){let n=t??xe,r=[];if(!e||typeof e!=`string`)return r;let i=``,a,o;for(let t of e){let e=n.includes(t);if(e===!0){r.push(i),i=``,a=void 0;continue}let s=Se(t);if(o===!1){if(a===!1&&s===!0){r.push(i),i=t,a=s;continue}if(a===!0&&s===!1&&i.length>1){let e=i.at(-1);r.push(i.slice(0,Math.max(0,i.length-1))),i=e+t,a=s;continue}}i+=t,a=s,o=e}return r.push(i),r}function we(e){return e?e[0].toUpperCase()+e.slice(1):``}function Te(e){return e?e[0].toLowerCase()+e.slice(1):``}function Ee(e,t){return e?(Array.isArray(e)?e:Ce(e)).map(e=>we(t?.normalize?e.toLowerCase():e)).join(``):``}function De(e,t){return Te(Ee(e||``,t))}function Oe(e,t){return e?(Array.isArray(e)?e:Ce(e)).map(e=>e.toLowerCase()).join(t??`-`):``}function ke(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function Ae(e,t=``){let n=[];for(let t of e)for(let[e,r]of t.entries())n[e]=Math.max(n[e]||0,r.length);return e.map(e=>e.map((e,r)=>t+e[r===0?`padStart`:`padEnd`](n[r])).join(` `)).join(`
|
|
3
|
+
`)}function T(e){return typeof e==`function`?e():e}var je=class extends Error{code;constructor(e,t){super(e),this.name=`CLIError`,this.code=t}};function Me(e=[],t={}){let r=new Set(t.boolean||[]),i=new Set(t.string||[]),a=t.alias||{},o=t.default||{},s=new Map,c=new Map;for(let[e,t]of Object.entries(a)){let n=t;for(let t of n)s.set(e,t),c.has(t)||c.set(t,[]),c.get(t).push(e),s.set(t,e),c.has(e)||c.set(e,[]),c.get(e).push(t)}let l={};function u(e){if(r.has(e))return`boolean`;let t=c.get(e)||[];for(let e of t)if(r.has(e))return`boolean`;return`string`}let d=new Set([...r,...i,...Object.keys(a),...Object.values(a).flat(),...Object.keys(o)]);for(let e of d)l[e]||(l[e]={type:u(e),default:o[e]});for(let[e,t]of s.entries())e.length===1&&l[t]&&!l[t].short&&(l[t].short=e);let f=[],p={};for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`){f.push(...e.slice(t));break}if(n.startsWith(`--no-`)){let e=n.slice(5);p[e]=!0;continue}f.push(n)}let m;try{m=n({args:f,options:Object.keys(l).length>0?l:void 0,allowPositionals:!0,strict:!1})}catch{m={values:{},positionals:f}}let h={_:[]};h._=m.positionals;for(let[e,t]of Object.entries(m.values))h[e]=t;for(let[e]of Object.entries(p)){h[e]=!1;let t=s.get(e);t&&(h[t]=!1);let n=c.get(e);if(n)for(let e of n)h[e]=!1}for(let[e,t]of s.entries())h[e]!==void 0&&h[t]===void 0&&(h[t]=h[e]),h[t]!==void 0&&h[e]===void 0&&(h[e]=h[t]);return h}const Ne=(()=>{let e=globalThis.process?.env??{};return e.NO_COLOR===`1`||e.TERM===`dumb`||e.TEST||e.CI})(),Pe=(e,t=39)=>n=>Ne?n:`\u001B[${e}m${n}\u001B[${t}m`,Fe=Pe(1,22),E=Pe(36),Ie=Pe(90),Le=Pe(4,24);function Re(e,t){let n={boolean:[],string:[],alias:{},default:{}},r=ze(t);for(let e of r){if(e.type===`positional`)continue;e.type===`string`||e.type===`enum`?n.string.push(e.name):e.type===`boolean`&&n.boolean.push(e.name),e.default!==void 0&&(n.default[e.name]=e.default),e.alias&&(n.alias[e.name]=e.alias);let t=De(e.name),r=Oe(e.name);if(t!==e.name||r!==e.name){let i=ke(n.alias[e.name]||[]);t!==e.name&&!i.includes(t)&&i.push(t),r!==e.name&&!i.includes(r)&&i.push(r),i.length>0&&(n.alias[e.name]=i)}}let i=Me(e,n),[...a]=i._,o=new Proxy(i,{get(e,t){return e[t]??e[De(t)]??e[Oe(t)]}});for(let[,e]of r.entries())if(e.type===`positional`){let t=a.shift();if(t!==void 0)o[e.name]=t;else if(e.default===void 0&&e.required!==!1)throw new je(`Missing required positional argument: ${e.name.toUpperCase()}`,`EARG`);else o[e.name]=e.default}else if(e.type===`enum`){let t=o[e.name],n=e.options||[];if(t!==void 0&&n.length>0&&!n.includes(t))throw new je(`Invalid value for argument: ${E(`--${e.name}`)} (${E(t)}). Expected one of: ${n.map(e=>E(e)).join(`, `)}.`,`EARG`)}else if(e.required&&o[e.name]===void 0)throw new je(`Missing required argument: --${e.name}`,`EARG`);return o}function ze(e){let t=[];for(let[n,r]of Object.entries(e||{}))t.push({...r,name:n,alias:ke(r.alias)});return t}function D(e){return e}async function Be(e,t){let n=await T(e.args||{}),r=Re(t.rawArgs,n),i={rawArgs:t.rawArgs,args:r,data:t.data,cmd:e};typeof e.setup==`function`&&await e.setup(i);let a;try{let n=await T(e.subCommands);if(n&&Object.keys(n).length>0){let r=t.rawArgs.findIndex(e=>!e.startsWith(`-`)),i=t.rawArgs[r];if(i){if(!n[i])throw new je(`Unknown command ${E(i)}`,`E_UNKNOWN_COMMAND`);let e=await T(n[i]);e&&await Be(e,{rawArgs:t.rawArgs.slice(r+1)})}else if(!e.run)throw new je(`No command specified.`,`E_NO_COMMAND`)}typeof e.run==`function`&&(a=await e.run(i))}finally{typeof e.cleanup==`function`&&await e.cleanup(i)}return{result:a}}async function Ve(e,t,n){let r=await T(e.subCommands);if(r&&Object.keys(r).length>0){let n=t.findIndex(e=>!e.startsWith(`-`)),i=t[n],a=await T(r[i]);if(a)return Ve(a,t.slice(n+1),e)}return[e,n]}async function He(e,t){try{console.log(await We(e,t)+`
|
|
4
|
+
`)}catch(e){console.error(e)}}const Ue=/^no[-A-Z]/;async function We(e,t){let n=await T(e.meta||{}),r=ze(await T(e.args||{})),i=await T(t?.meta||{}),a=`${i.name?`${i.name} `:``}`+(n.name||process.argv[1]),o=[],s=[],c=[],l=[];for(let e of r)if(e.type===`positional`){let t=e.name.toUpperCase(),n=e.required!==!1&&e.default===void 0,r=e.default?`="${e.default}"`:``;s.push([E(t+r),e.description||``,e.valueHint?`<${e.valueHint}>`:``]),l.push(n?`<${t}>`:`[${t}]`)}else{let t=e.required===!0&&e.default===void 0,n=[...(e.alias||[]).map(e=>`-${e}`),`--${e.name}`].join(`, `)+(e.type===`string`&&(e.valueHint||e.default)?`=${e.valueHint?`<${e.valueHint}>`:`"${e.default||``}"`}`:``)+(e.type===`enum`&&e.options?`=<${e.options.join(`|`)}>`:``);if(o.push([E(n+(t?` (required)`:``)),e.description||``]),e.type===`boolean`&&(e.default===!0||e.negativeDescription)&&!Ue.test(e.name)){let n=[...(e.alias||[]).map(e=>`--no-${e}`),`--no-${e.name}`].join(`, `);o.push([E(n+(t?` (required)`:``)),e.negativeDescription||``])}t&&l.push(n)}if(e.subCommands){let t=[],n=await T(e.subCommands);for(let[e,r]of Object.entries(n)){let n=await T((await T(r))?.meta);n?.hidden||(c.push([E(e),n?.description||``]),t.push(e))}l.push(t.join(`|`))}let u=[],d=n.version||i.version;u.push(Ie(`${n.description} (${a+(d?` v${d}`:``)})`),``);let f=o.length>0||s.length>0;return u.push(`${Le(Fe(`USAGE`))} ${E(`${a}${f?` [OPTIONS]`:``} ${l.join(` `)}`)}`,``),s.length>0&&(u.push(Le(Fe(`ARGUMENTS`)),``),u.push(Ae(s,` `)),u.push(``)),o.length>0&&(u.push(Le(Fe(`OPTIONS`)),``),u.push(Ae(o,` `)),u.push(``)),c.length>0&&(u.push(Le(Fe(`COMMANDS`)),``),u.push(Ae(c,` `)),u.push(``,`Use ${E(`${a} <command> --help`)} for more information about a command.`)),u.filter(e=>typeof e==`string`).join(`
|
|
5
|
+
`)}async function Ge(e,t={}){let n=t.rawArgs||process.argv.slice(2),r=t.showUsage||He;try{if(n.includes(`--help`)||n.includes(`-h`))await r(...await Ve(e,n)),process.exit(0);else if(n.length===1&&n[0]===`--version`){let t=typeof e.meta==`function`?await e.meta():await e.meta;if(!t?.version)throw new je(`No version specified`,`E_NO_VERSION`);console.log(t.version)}else await Be(e,{rawArgs:n})}catch(t){t instanceof je?(await r(...await Ve(e,n)),console.error(t.message)):console.error(t,`
|
|
6
|
+
`),process.exit(1)}}var Ke=`0.0.2`;const qe=e(import.meta.url),Je=D({meta:{name:`browser`,description:`Manage the Kapture browser runtime`},subCommands:{install:D({meta:{name:`install`,description:`Install the Chrome runtime used by agent-browser`},args:{"with-deps":{type:`boolean`,default:!1,description:`Also install Linux system dependencies`}},async run({args:e}){let t=qe.resolve(`agent-browser/package.json`),n=[d(a(t),`bin`,`agent-browser.js`),`install`];e[`with-deps`]&&n.push(`--with-deps`);let i=await new Promise((e,t)=>{let i=r(process.execPath,n,{stdio:`inherit`});i.once(`error`,t),i.once(`exit`,(n,r)=>{r?t(Error(`agent-browser install stopped by ${r}`)):e(n??1)})});if(i!==0)throw Error(`agent-browser install exited with code ${i}`)}})}});function Ye(e,t,n,r,i,a={}){let{threshold:o=.1,alpha:s=.1,aaColor:c=[255,255,0],diffColor:l=[255,0,0],includeAA:u,diffColorAlt:d,diffMask:f}=a;if(!Xe(e)||!Xe(t)||n&&!Xe(n))throw Error(`Image data: Uint8Array, Uint8ClampedArray or Buffer expected.`);if(e.length!==t.length||n&&n.length!==e.length)throw Error(`Image sizes do not match.`);if(e.length!==r*i*4)throw Error(`Image data size does not match width/height.`);let p=r*i,m=new Uint32Array(e.buffer,e.byteOffset,p),h=new Uint32Array(t.buffer,t.byteOffset,p),g=!0;for(let e=0;e<p;e++)if(m[e]!==h[e]){g=!1;break}if(g){if(n&&!f)for(let t=0;t<p;t++)tt(e,4*t,s,n);return 0}let _=35215*o*o,[v,ee,y]=c,[te,ne,b]=l,[re,x,ie]=d||l,ae=0;for(let a=0;a<i;a++)for(let o=0;o<r;o++){let c=a*r+o,l=c*4,d=m[c]===h[c]?0:$e(e,t,l,l,!1);if(Math.abs(d)>_){let s=Ze(e,o,a,r,i,m,h)||Ze(t,o,a,r,i,h,m);!u&&s?n&&!f&&et(n,l,v,ee,y):(n&&(d<0?et(n,l,re,x,ie):et(n,l,te,ne,b)),ae++)}else n&&!f&&tt(e,l,s,n)}return ae}function Xe(e){return ArrayBuffer.isView(e)&&e.BYTES_PER_ELEMENT===1}function Ze(e,t,n,r,i,a,o){let s=Math.max(t-1,0),c=Math.max(n-1,0),l=Math.min(t+1,r-1),u=Math.min(n+1,i-1),d=n*r+t,f=+(t===s||t===l||n===c||n===u),p=0,m=0,h=0,g=0,_=0,v=0;for(let i=s;i<=l;i++)for(let a=c;a<=u;a++){if(i===t&&a===n)continue;let o=$e(e,e,d*4,(a*r+i)*4,!0);if(o===0){if(f++,f>2)return!1}else o<p?(p=o,h=i,g=a):o>m&&(m=o,_=i,v=a)}return p===0||m===0?!1:Qe(a,h,g,r,i)&&Qe(o,h,g,r,i)||Qe(a,_,v,r,i)&&Qe(o,_,v,r,i)}function Qe(e,t,n,r,i){let a=Math.max(t-1,0),o=Math.max(n-1,0),s=Math.min(t+1,r-1),c=Math.min(n+1,i-1),l=e[n*r+t],u=+(t===a||t===s||n===o||n===c);for(let i=a;i<=s;i++)for(let a=o;a<=c;a++)if((i!==t||a!==n)&&(u+=+(l===e[a*r+i]),u>2))return!0;return!1}function $e(e,t,n,r,i){let a=e[n],o=e[n+1],s=e[n+2],c=e[n+3],l=t[r],u=t[r+1],d=t[r+2],f=t[r+3],p=a-l,m=o-u,h=s-d,g=c-f;if(!p&&!m&&!h&&!g)return 0;if(c<255||f<255){let e=48+n%2*159,t=48+159*((n/1.618033988749895|0)%2),r=48+159*((n/2.618033988749895|0)%2);p=(a*c-l*f-e*g)/255,m=(o*c-u*f-t*g)/255,h=(s*c-d*f-r*g)/255}let _=p*.29889531+m*.58662247+h*.11448223;if(i)return _;let v=p*.59597799-m*.2741761-h*.32180189,ee=p*.21147017-m*.52261711+h*.31114694,y=.5053*_*_+.299*v*v+.1957*ee*ee;return _>0?-y:y}function et(e,t,n,r,i){e[t+0]=n,e[t+1]=r,e[t+2]=i,e[t+3]=255}function tt(e,t,n,r){let i=255+(e[t]*.29889531+e[t+1]*.58662247+e[t+2]*.11448223-255)*n*e[t+3]/255;et(r,t,i,i,i)}var nt=C(((e,t)=>{let n=w(`util`),r=w(`stream`),i=t.exports=function(){r.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding=`utf8`,this.writable=!0};n.inherits(i,r),i.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit(`drain`))}.bind(this))},i.prototype.write=function(e,t){if(!this.writable)return this.emit(`error`,Error(`Stream not writable`)),!1;let n;return n=Buffer.isBuffer(e)?e:Buffer.from(e,t||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&this._reads.length===0&&(this._paused=!0),this.writable&&!this._paused},i.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(this._buffers.length===0?this._end():(this._buffers.push(null),this._process()))},i.prototype.destroySoon=i.prototype.end,i.prototype._end=function(){this._reads.length>0&&this.emit(`error`,Error(`Unexpected end of input`)),this.destroy()},i.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit(`close`))},i.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))},i.prototype._processRead=function(e){this._reads.shift();let t=0,n=0,r=Buffer.alloc(e.length);for(;t<e.length;){let i=this._buffers[n++],a=Math.min(i.length,e.length-t);i.copy(r,t,0,a),t+=a,a!==i.length&&(this._buffers[--n]=i.slice(a))}n>0&&this._buffers.splice(0,n),this._buffered-=e.length,e.func.call(this,r)},i.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit(`error`,e)}}})),rt=C((e=>{let t=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];e.getImagePasses=function(e,n){let r=[],i=e%8,a=n%8,o=(e-i)/8,s=(n-a)/8;for(let e=0;e<t.length;e++){let n=t[e],c=o*n.x.length,l=s*n.y.length;for(let e=0;e<n.x.length&&n.x[e]<i;e++)c++;for(let e=0;e<n.y.length&&n.y[e]<a;e++)l++;c>0&&l>0&&r.push({width:c,height:l,index:e})}return r},e.getInterlaceIterator=function(e){return function(n,r,i){let a=n%t[i].x.length,o=(n-a)/t[i].x.length*8+t[i].x[a],s=r%t[i].y.length,c=(r-s)/t[i].y.length*8+t[i].y[s];return o*4+c*e*4}}})),it=C(((e,t)=>{t.exports=function(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}})),at=C(((e,t)=>{let n=rt(),r=it();function i(e,t,n){let r=e*t;return n!==8&&(r=Math.ceil(r/(8/n))),r}let a=t.exports=function(e,t){let r=e.width,a=e.height,o=e.interlace,s=e.bpp,c=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],o){let e=n.getImagePasses(r,a);for(let t=0;t<e.length;t++)this._images.push({byteWidth:i(e[t].width,s,c),height:e[t].height,lineIndex:0})}else this._images.push({byteWidth:i(r,s,c),height:a,lineIndex:0});this._xComparison=c===8?s:c===16?s*2:1};a.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},a.prototype._unFilterType1=function(e,t,n){let r=this._xComparison,i=r-1;for(let a=0;a<n;a++){let n=e[1+a],o=a>i?t[a-r]:0;t[a]=n+o}},a.prototype._unFilterType2=function(e,t,n){let r=this._lastLine;for(let i=0;i<n;i++){let n=e[1+i],a=r?r[i]:0;t[i]=n+a}},a.prototype._unFilterType3=function(e,t,n){let r=this._xComparison,i=r-1,a=this._lastLine;for(let o=0;o<n;o++){let n=e[1+o],s=a?a[o]:0,c=o>i?t[o-r]:0,l=Math.floor((c+s)/2);t[o]=n+l}},a.prototype._unFilterType4=function(e,t,n){let i=this._xComparison,a=i-1,o=this._lastLine;for(let s=0;s<n;s++){let n=e[1+s],c=o?o[s]:0,l=s>a?t[s-i]:0,u=s>a&&o?o[s-i]:0,d=r(l,c,u);t[s]=n+d}},a.prototype._reverseFilterLine=function(e){let t=e[0],n,r=this._images[this._imageIndex],i=r.byteWidth;if(t===0)n=e.slice(1,i+1);else switch(n=Buffer.alloc(i),t){case 1:this._unFilterType1(e,n,i);break;case 2:this._unFilterType2(e,n,i);break;case 3:this._unFilterType3(e,n,i);break;case 4:this._unFilterType4(e,n,i);break;default:throw Error(`Unrecognised filter type - `+t)}this.write(n),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=n,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}})),ot=C(((e,t)=>{let n=w(`util`),r=nt(),i=at(),a=t.exports=function(e){r.call(this);let t=[],n=this;this._filter=new i(e,{read:this.read.bind(this),write:function(e){t.push(e)},complete:function(){n.emit(`complete`,Buffer.concat(t))}}),this._filter.start()};n.inherits(a,r)})),st=C(((e,t)=>{t.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}})),ct=C(((e,t)=>{let n=[];(function(){for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;n[e]=t}})();let r=t.exports=function(){this._crc=-1};r.prototype.write=function(e){for(let t=0;t<e.length;t++)this._crc=n[(this._crc^e[t])&255]^this._crc>>>8;return!0},r.prototype.crc32=function(){return this._crc^-1},r.crc32=function(e){let t=-1;for(let r=0;r<e.length;r++)t=n[(t^e[r])&255]^t>>>8;return t^-1}})),lt=C(((e,t)=>{let n=st(),r=ct(),i=t.exports=function(e,t){this._options=e,e.checkCRC=e.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[n.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[n.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[n.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[n.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[n.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[n.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};i.prototype.start=function(){this.read(n.PNG_SIGNATURE.length,this._parseSignature.bind(this))},i.prototype._parseSignature=function(e){let t=n.PNG_SIGNATURE;for(let n=0;n<t.length;n++)if(e[n]!==t[n]){this.error(Error(`Invalid file signature`));return}this.read(8,this._parseChunkBegin.bind(this))},i.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),i=e.readUInt32BE(4),a=``;for(let t=4;t<8;t++)a+=String.fromCharCode(e[t]);let o=!!(e[4]&32);if(!this._hasIHDR&&i!==n.TYPE_IHDR){this.error(Error(`Expected IHDR on beggining`));return}if(this._crc=new r,this._crc.write(Buffer.from(a)),this._chunks[i])return this._chunks[i](t);if(!o){this.error(Error(`Unsupported critical chunk type `+a));return}this.read(t+4,this._skipChunk.bind(this))},i.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},i.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),n=this._crc.crc32();if(this._options.checkCRC&&n!==t){this.error(Error(`Crc error - `+t+` - `+n));return}this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))},i.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),r=e.readUInt32BE(4),i=e[8],a=e[9],o=e[10],s=e[11],c=e[12];if(i!==8&&i!==4&&i!==2&&i!==1&&i!==16){this.error(Error(`Unsupported bit depth `+i));return}if(!(a in n.COLORTYPE_TO_BPP_MAP)){this.error(Error(`Unsupported color type`));return}if(o!==0){this.error(Error(`Unsupported compression method`));return}if(s!==0){this.error(Error(`Unsupported filter method`));return}if(c!==0&&c!==1){this.error(Error(`Unsupported interlace method`));return}this._colorType=a;let l=n.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:r,depth:i,interlace:!!c,palette:!!(a&n.COLORTYPE_PALETTE),color:!!(a&n.COLORTYPE_COLOR),alpha:!!(a&n.COLORTYPE_ALPHA),bpp:l,colorType:a}),this._handleChunkEnd()},i.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))},i.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let n=0;n<t;n++)this._palette.push([e[n*3],e[n*3+1],e[n*3+2],255]);this.palette(this._palette),this._handleChunkEnd()},i.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))},i.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===n.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error(`Transparency chunk must be after palette`));return}if(e.length>this._palette.length){this.error(Error(`More transparent colors than palette size`));return}for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===n.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===n.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()},i.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))},i.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/n.GAMMA_DIVISION),this._handleChunkEnd()},i.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))},i.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===n.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error(`Expected palette not found`);this.inflateData(t);let r=e-t.length;r>0?this._handleIDAT(r):this._handleChunkEnd()},i.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))},i.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}})),ut=C((e=>{let t=rt(),n=[function(){},function(e,t,n,r){if(r===t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=255},function(e,t,n,r){if(r+1>=t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=t[r+1]},function(e,t,n,r){if(r+2>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=255},function(e,t,n,r){if(r+3>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=t[r+3]}],r=[function(){},function(e,t,n,r){let i=t[0];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=r},function(e,t,n){let r=t[0];e[n]=r,e[n+1]=r,e[n+2]=r,e[n+3]=t[1]},function(e,t,n,r){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=r},function(e,t,n){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=t[3]}];function i(e,t){let n=[],r=0;function i(){if(r===e.length)throw Error(`Ran out of data`);let i=e[r];r++;let a,o,s,c,l,u,d,f;switch(t){default:throw Error(`unrecognised depth`);case 16:d=e[r],r++,n.push((i<<8)+d);break;case 4:d=i&15,f=i>>4,n.push(f,d);break;case 2:l=i&3,u=i>>2&3,d=i>>4&3,f=i>>6&3,n.push(f,d,u,l);break;case 1:a=i&1,o=i>>1&1,s=i>>2&1,c=i>>3&1,l=i>>4&1,u=i>>5&1,d=i>>6&1,f=i>>7&1,n.push(f,d,u,l,c,s,o,a)}}return{get:function(e){for(;n.length<e;)i();let t=n.slice(0,e);return n=n.slice(e),t},resetAfterLine:function(){n.length=0},end:function(){if(r!==e.length)throw Error(`extra data found`)}}}function a(e,t,r,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++)for(let c=0;c<s;c++){let s=r(c,e,l);n[i](t,a,s,o),o+=i}return o}function o(e,t,n,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++){for(let c=0;c<s;c++){let s=a.get(i),u=n(c,e,l);r[i](t,s,u,o)}a.resetAfterLine()}}e.dataToBitMap=function(e,n){let r=n.width,s=n.height,c=n.depth,l=n.bpp,u=n.interlace,d;c!==8&&(d=i(e,c));let f;f=c<=8?Buffer.alloc(r*s*4):new Uint16Array(r*s*4);let p=2**c-1,m=0,h,g;if(u)h=t.getImagePasses(r,s),g=t.getInterlaceIterator(r,s);else{let e=0;g=function(){let t=e;return e+=4,t},h=[{width:r,height:s}]}for(let t=0;t<h.length;t++)c===8?m=a(h[t],f,g,l,e,m):o(h[t],f,g,l,d,p);if(c===8){if(m!==e.length)throw Error(`extra data found`)}else d.end();return f}})),dt=C(((e,t)=>{function n(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=i[e[a]];if(!n)throw Error(`index `+e[a]+` not in palette`);for(let e=0;e<4;e++)t[a+e]=n[e];a+=4}}function r(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=!1;if(i.length===1?i[0]===e[a]&&(n=!0):i[0]===e[a]&&i[1]===e[a+1]&&i[2]===e[a+2]&&(n=!0),n)for(let e=0;e<4;e++)t[a+e]=0;a+=4}}function i(e,t,n,r,i){let a=2**i-1,o=0;for(let i=0;i<r;i++)for(let r=0;r<n;r++){for(let n=0;n<4;n++)t[o+n]=Math.floor(e[o+n]*255/a+.5);o+=4}}t.exports=function(e,t,a=!1){let o=t.depth,s=t.width,c=t.height,l=t.colorType,u=t.transColor,d=t.palette,f=e;return l===3?n(e,f,s,c,d):(u&&r(e,f,s,c,u),o!==8&&!a&&(o===16&&(f=Buffer.alloc(s*c*4)),i(e,f,s,c,o))),f}})),ft=C(((e,t)=>{let n=w(`util`),r=w(`zlib`),i=nt(),a=ot(),o=lt(),s=ut(),c=dt(),l=t.exports=function(e){i.call(this),this._parser=new o(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,`gamma`),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};n.inherits(l,i),l.prototype._handleError=function(e){this.emit(`error`,e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on(`error`,function(){})),this.errord=!0},l.prototype._inflateData=function(e){if(!this._inflate){if(this._bitmapInfo.interlace)this._inflate=r.createInflate(),this._inflate.on(`error`,this.emit.bind(this,`error`)),this._filter.on(`complete`,this._complete.bind(this)),this._inflate.pipe(this._filter);else{let e=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,t=Math.max(e,r.Z_MIN_CHUNK);this._inflate=r.createInflate({chunkSize:t});let n=e,i=this.emit.bind(this,`error`);this._inflate.on(`error`,function(e){n&&i(e)}),this._filter.on(`complete`,this._complete.bind(this));let a=this._filter.write.bind(this._filter);this._inflate.on(`data`,function(e){n&&(e.length>n&&(e=e.slice(0,n)),n-=e.length,a(e))}),this._inflate.on(`end`,this._filter.end.bind(this._filter))}}this._inflate.write(e)},l.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new a(this._bitmapInfo)},l.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e},l.prototype._handlePalette=function(e){this._bitmapInfo.palette=e},l.prototype._simpleTransparency=function(){this._metaData.alpha=!0},l.prototype._headersFinished=function(){this.emit(`metadata`,this._metaData)},l.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit(`error`,`No Inflate block`))},l.prototype._complete=function(e){if(this.errord)return;let t;try{let n=s.dataToBitMap(e,this._bitmapInfo);t=c(n,this._bitmapInfo,this._options.skipRescale),n=null}catch(e){this._handleError(e);return}this.emit(`parsed`,t)}})),pt=C(((e,t)=>{let n=st();t.exports=function(e,t,r,i){let a=[n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(i.colorType)!==-1;if(i.colorType===i.inputColorType){let t=(function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]!==256})();if(i.bitDepth===8||i.bitDepth===16&&t)return e}let o=i.bitDepth===16?new Uint16Array(e.buffer):e,s=255,c=n.COLORTYPE_TO_BPP_MAP[i.inputColorType];c===4&&!i.inputHasAlpha&&(c=3);let l=n.COLORTYPE_TO_BPP_MAP[i.colorType];i.bitDepth===16&&(s=65535,l*=2);let u=Buffer.alloc(t*r*l),d=0,f=0,p=i.bgColor||{};p.red===void 0&&(p.red=s),p.green===void 0&&(p.green=s),p.blue===void 0&&(p.blue=s);function m(){let e,t,r,c=s;switch(i.inputColorType){case n.COLORTYPE_COLOR_ALPHA:c=o[d+3],e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_COLOR:e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_ALPHA:c=o[d+1],e=o[d],t=e,r=e;break;case n.COLORTYPE_GRAYSCALE:e=o[d],t=e,r=e;break;default:throw Error(`input color type:`+i.inputColorType+` is not supported at present`)}return i.inputHasAlpha&&(a||(c/=s,e=Math.min(Math.max(Math.round((1-c)*p.red+c*e),0),s),t=Math.min(Math.max(Math.round((1-c)*p.green+c*t),0),s),r=Math.min(Math.max(Math.round((1-c)*p.blue+c*r),0),s))),{red:e,green:t,blue:r,alpha:c}}for(let e=0;e<r;e++)for(let e=0;e<t;e++){let e=m(o,d);switch(i.colorType){case n.COLORTYPE_COLOR_ALPHA:case n.COLORTYPE_COLOR:i.bitDepth===8?(u[f]=e.red,u[f+1]=e.green,u[f+2]=e.blue,a&&(u[f+3]=e.alpha)):(u.writeUInt16BE(e.red,f),u.writeUInt16BE(e.green,f+2),u.writeUInt16BE(e.blue,f+4),a&&u.writeUInt16BE(e.alpha,f+6));break;case n.COLORTYPE_ALPHA:case n.COLORTYPE_GRAYSCALE:{let t=(e.red+e.green+e.blue)/3;i.bitDepth===8?(u[f]=t,a&&(u[f+1]=e.alpha)):(u.writeUInt16BE(t,f),a&&u.writeUInt16BE(e.alpha,f+2));break}default:throw Error(`unrecognised color Type `+i.colorType)}d+=c,f+=l}return u}})),mt=C(((e,t)=>{let n=it();function r(e,t,n,r,i){for(let a=0;a<n;a++)r[i+a]=e[t+a]}function i(e,t,n){let r=0,i=t+n;for(let n=t;n<i;n++)r+=Math.abs(e[n]);return r}function a(e,t,n,r,i,a){for(let o=0;o<n;o++){let n=o>=a?e[t+o-a]:0,s=e[t+o]-n;r[i+o]=s}}function o(e,t,n,r){let i=0;for(let a=0;a<n;a++){let n=a>=r?e[t+a-r]:0,o=e[t+a]-n;i+=Math.abs(o)}return i}function s(e,t,n,r,i){for(let a=0;a<n;a++){let o=t>0?e[t+a-n]:0,s=e[t+a]-o;r[i+a]=s}}function c(e,t,n){let r=0,i=t+n;for(let a=t;a<i;a++){let i=t>0?e[a-n]:0,o=e[a]-i;r+=Math.abs(o)}return r}function l(e,t,n,r,i,a){for(let o=0;o<n;o++){let s=o>=a?e[t+o-a]:0,c=t>0?e[t+o-n]:0,l=e[t+o]-(s+c>>1);r[i+o]=l}}function u(e,t,n,r){let i=0;for(let a=0;a<n;a++){let o=a>=r?e[t+a-r]:0,s=t>0?e[t+a-n]:0,c=e[t+a]-(o+s>>1);i+=Math.abs(c)}return i}function d(e,t,r,i,a,o){for(let s=0;s<r;s++){let c=s>=o?e[t+s-o]:0,l=t>0?e[t+s-r]:0,u=t>0&&s>=o?e[t+s-(r+o)]:0,d=e[t+s]-n(c,l,u);i[a+s]=d}}function f(e,t,r,i){let a=0;for(let o=0;o<r;o++){let s=o>=i?e[t+o-i]:0,c=t>0?e[t+o-r]:0,l=t>0&&o>=i?e[t+o-(r+i)]:0,u=e[t+o]-n(s,c,l);a+=Math.abs(u)}return a}let p={0:r,1:a,2:s,3:l,4:d},m={0:i,1:o,2:c,3:u,4:f};t.exports=function(e,t,n,r,i){let a;if(!(`filterType`in r)||r.filterType===-1)a=[0,1,2,3,4];else if(typeof r.filterType==`number`)a=[r.filterType];else throw Error(`unrecognised filter types`);r.bitDepth===16&&(i*=2);let o=t*i,s=0,c=0,l=Buffer.alloc((o+1)*n),u=a[0];for(let t=0;t<n;t++){if(a.length>1){let t=1/0;for(let n=0;n<a.length;n++){let r=m[a[n]](e,c,o,i);r<t&&(u=a[n],t=r)}}l[s]=u,s++,p[u](e,c,o,l,s,i),s+=o,c+=o}return l}})),ht=C(((e,t)=>{let n=st(),r=ct(),i=pt(),a=mt(),o=w(`zlib`),s=t.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32768,e.deflateLevel=e.deflateLevel==null?9:e.deflateLevel,e.deflateStrategy=e.deflateStrategy==null?3:e.deflateStrategy,e.inputHasAlpha=e.inputHasAlpha==null||e.inputHasAlpha,e.deflateFactory=e.deflateFactory||o.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType=typeof e.colorType==`number`?e.colorType:n.COLORTYPE_COLOR_ALPHA,e.inputColorType=typeof e.inputColorType==`number`?e.inputColorType:n.COLORTYPE_COLOR_ALPHA,[n.COLORTYPE_GRAYSCALE,n.COLORTYPE_COLOR,n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(e.colorType)===-1)throw Error(`option color type:`+e.colorType+` is not supported at present`);if([n.COLORTYPE_GRAYSCALE,n.COLORTYPE_COLOR,n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(e.inputColorType)===-1)throw Error(`option input color type:`+e.inputColorType+` is not supported at present`);if(e.bitDepth!==8&&e.bitDepth!==16)throw Error(`option bit depth:`+e.bitDepth+` is not supported at present`)};s.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},s.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},s.prototype.filterData=function(e,t,r){let o=i(e,t,r,this._options),s=n.COLORTYPE_TO_BPP_MAP[this._options.colorType];return a(o,t,r,this._options,s)},s.prototype._packChunk=function(e,t){let n=t?t.length:0,i=Buffer.alloc(n+12);return i.writeUInt32BE(n,0),i.writeUInt32BE(e,4),t&&t.copy(i,8),i.writeInt32BE(r.crc32(i.slice(4,i.length-4)),i.length-4),i},s.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*n.GAMMA_DIVISION),0),this._packChunk(n.TYPE_gAMA,t)},s.prototype.packIHDR=function(e,t){let r=Buffer.alloc(13);return r.writeUInt32BE(e,0),r.writeUInt32BE(t,4),r[8]=this._options.bitDepth,r[9]=this._options.colorType,r[10]=0,r[11]=0,r[12]=0,this._packChunk(n.TYPE_IHDR,r)},s.prototype.packIDAT=function(e){return this._packChunk(n.TYPE_IDAT,e)},s.prototype.packIEND=function(){return this._packChunk(n.TYPE_IEND,null)}})),gt=C(((e,t)=>{let n=w(`util`),r=w(`stream`),i=st(),a=ht(),o=t.exports=function(e){r.call(this);let t=e||{};this._packer=new a(t),this._deflate=this._packer.createDeflate(),this.readable=!0};n.inherits(o,r),o.prototype.pack=function(e,t,n,r){this.emit(`data`,Buffer.from(i.PNG_SIGNATURE)),this.emit(`data`,this._packer.packIHDR(t,n)),r&&this.emit(`data`,this._packer.packGAMA(r));let a=this._packer.filterData(e,t,n);this._deflate.on(`error`,this.emit.bind(this,`error`)),this._deflate.on(`data`,function(e){this.emit(`data`,this._packer.packIDAT(e))}.bind(this)),this._deflate.on(`end`,function(){this.emit(`data`,this._packer.packIEND()),this.emit(`end`)}.bind(this)),this._deflate.end(a)}})),_t=C(((e,t)=>{let n=w(`assert`).ok,r=w(`zlib`),i=w(`util`),a=w(`buffer`).kMaxLength;function o(e){if(!(this instanceof o))return new o(e);e&&e.chunkSize<r.Z_MIN_CHUNK&&(e.chunkSize=r.Z_MIN_CHUNK),r.Inflate.call(this,e),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&e.maxLength!=null&&(this._maxLength=e.maxLength)}function s(e){return new o(e)}function c(e,t){t&&process.nextTick(t),e._handle&&=(e._handle.close(),null)}o.prototype._processChunk=function(e,t,i){if(typeof i==`function`)return r.Inflate._processChunk.call(this,e,t,i);let o=this,s=e&&e.length,l=this._chunkSize-this._offset,u=this._maxLength,d=0,f=[],p=0,m;this.on(`error`,function(e){m=e});function h(e,t){if(o._hadError)return;let r=l-t;if(n(r>=0,`have should not go down`),r>0){let e=o._buffer.slice(o._offset,o._offset+r);if(o._offset+=r,e.length>u&&(e=e.slice(0,u)),f.push(e),p+=e.length,u-=e.length,u===0)return!1}return(t===0||o._offset>=o._chunkSize)&&(l=o._chunkSize,o._offset=0,o._buffer=Buffer.allocUnsafe(o._chunkSize)),t===0&&(d+=s-e,s=e,!0)}n(this._handle,`zlib binding closed`);let g;do g=this._handle.writeSync(t,e,d,s,this._buffer,this._offset,l),g||=this._writeState;while(!this._hadError&&h(g[0],g[1]));if(this._hadError)throw m;if(p>=a)throw c(this),RangeError(`Cannot create final Buffer. It would be larger than 0x`+a.toString(16)+` bytes`);let _=Buffer.concat(f,p);return c(this),_},i.inherits(o,r.Inflate);function l(e,t){if(typeof t==`string`&&(t=Buffer.from(t)),!(t instanceof Buffer))throw TypeError(`Not a string or buffer`);let n=e._finishFlushFlag;return n??=r.Z_FINISH,e._processChunk(t,n)}function u(e,t){return l(new o(t),e)}t.exports=e=u,e.Inflate=o,e.createInflate=s,e.inflateSync=u})),vt=C(((e,t)=>{let n=t.exports=function(e){this._buffer=e,this._reads=[]};n.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})},n.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}if(this._reads.length>0)throw Error(`There are some read requests waitng on finished stream`);if(this._buffer.length>0)throw Error(`unrecognised content at end of stream`)}})),yt=C((e=>{let t=vt(),n=at();e.process=function(e,r){let i=[],a=new t(e);return new n(r,{read:a.read.bind(a),write:function(e){i.push(e)},complete:function(){}}).start(),a.process(),Buffer.concat(i)}})),bt=C(((e,t)=>{let n=!0,r=w(`zlib`),i=_t();r.deflateSync||(n=!1);let a=vt(),o=yt(),s=lt(),c=ut(),l=dt();t.exports=function(e,t){if(!n)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let u;function d(e){u=e}let f;function p(e){f=e}function m(e){f.transColor=e}function h(e){f.palette=e}function g(){f.alpha=!0}let _;function v(e){_=e}let ee=[];function y(e){ee.push(e)}let te=new a(e);if(new s(t,{read:te.read.bind(te),error:d,metadata:p,gamma:v,palette:h,transColor:m,inflateData:y,simpleTransparency:g}).start(),te.process(),u)throw u;let ne=Buffer.concat(ee);ee.length=0;let b;if(f.interlace)b=r.inflateSync(ne);else{let e=((f.width*f.bpp*f.depth+7>>3)+1)*f.height;b=i(ne,{chunkSize:e,maxLength:e})}if(ne=null,!b||!b.length)throw Error(`bad png - invalid inflate data response`);let re=o.process(b,f);ne=null;let x=c.dataToBitMap(re,f);re=null;let ie=l(x,f,t.skipRescale);return f.data=ie,f.gamma=_||0,f}})),xt=C(((e,t)=>{let n=!0,r=w(`zlib`);r.deflateSync||(n=!1);let i=st(),a=ht();t.exports=function(e,t){if(!n)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let o=new a(t||{}),s=[];s.push(Buffer.from(i.PNG_SIGNATURE)),s.push(o.packIHDR(e.width,e.height)),e.gamma&&s.push(o.packGAMA(e.gamma));let c=o.filterData(e.data,e.width,e.height),l=r.deflateSync(c,o.getDeflateOptions());if(c=null,!l||!l.length)throw Error(`bad png - invalid compressed data response`);return s.push(o.packIDAT(l)),s.push(o.packIEND()),Buffer.concat(s)}})),St=C((e=>{let t=bt(),n=xt();e.read=function(e,n){return t(e,n||{})},e.write=function(e,t){return n(e,t)}})),Ct=C((e=>{let t=w(`util`),n=w(`stream`),r=ft(),i=gt(),a=St(),o=e.PNG=function(e){n.call(this),e||={},this.width=e.width|0,this.height=e.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new r(e),this._parser.on(`error`,this.emit.bind(this,`error`)),this._parser.on(`close`,this._handleClose.bind(this)),this._parser.on(`metadata`,this._metadata.bind(this)),this._parser.on(`gamma`,this._gamma.bind(this)),this._parser.on(`parsed`,function(e){this.data=e,this.emit(`parsed`,e)}.bind(this)),this._packer=new i(e),this._packer.on(`data`,this.emit.bind(this,`data`)),this._packer.on(`end`,this.emit.bind(this,`end`)),this._parser.on(`close`,this._handleClose.bind(this)),this._packer.on(`error`,this.emit.bind(this,`error`))};t.inherits(o,n),o.sync=a,o.prototype.pack=function(){return!this.data||!this.data.length?(this.emit(`error`,`No data provided`),this):(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this)},o.prototype.parse=function(e,t){if(t){let e,n;e=function(e){this.removeListener(`error`,n),this.data=e,t(null,this)}.bind(this),n=function(n){this.removeListener(`parsed`,e),t(n,null)}.bind(this),this.once(`parsed`,e),this.once(`error`,n)}return this.end(e),this},o.prototype.write=function(e){return this._parser.write(e),!0},o.prototype.end=function(e){this._parser.end(e)},o.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit(`metadata`,e)},o.prototype._gamma=function(e){this.gamma=e},o.prototype._handleClose=function(){!this._parser.writable&&!this._packer.readable&&this.emit(`close`)},o.bitblt=function(e,t,n,r,i,a,o,s){if(n|=0,r|=0,i|=0,a|=0,o|=0,s|=0,n>e.width||r>e.height||n+i>e.width||r+a>e.height)throw Error(`bitblt reading outside image`);if(o>t.width||s>t.height||o+i>t.width||s+a>t.height)throw Error(`bitblt writing outside image`);for(let c=0;c<a;c++)e.data.copy(t.data,(s+c)*t.width+o<<2,(r+c)*e.width+n<<2,(r+c)*e.width+n+i<<2)},o.prototype.bitblt=function(e,t,n,r,i,a,s){return o.bitblt(this,e,t,n,r,i,a,s),this},o.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++){let r=e.width*t+n<<2;for(let t=0;t<3;t++){let n=e.data[r+t]/255;n**=1/2.2/e.gamma,e.data[r+t]=Math.round(n*255)}}e.gamma=0}},o.prototype.adjustGamma=function(){o.adjustGamma(this)}}));Object.freeze({status:`aborted`});function O(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}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 wt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Tt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};const Et={};function Dt(e){return e&&Object.assign(Et,e),Et}function Ot(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 kt(e,t){return typeof t==`bigint`?t.toString():t}function At(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function jt(e){return e==null}function Mt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Nt(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}const Pt=Symbol(`evaluating`);function k(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Pt)return r===void 0&&(r=Pt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ft(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function It(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Lt(e){return JSON.stringify(e)}function Rt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const zt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Bt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Vt=At(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Ht(e){if(Bt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Bt(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Ut(e){return Ht(e)?{...e}:Array.isArray(e)?[...e]:e}const Wt=new Set([`string`,`number`,`symbol`]);function Gt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Kt(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 qt(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const Jt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Yt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Kt(e,It(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Ft(this,`shape`,e),e},checks:[]}))}function Xt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Kt(e,It(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Ft(this,`shape`,r),r},checks:[]}))}function Zt(e,t){if(!Ht(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Kt(e,It(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Ft(this,`shape`,n),n}}))}function Qt(e,t){if(!Ht(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Kt(e,It(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Ft(this,`shape`,n),n}}))}function $t(e,t){return Kt(e,It(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Ft(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function en(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Kt(t,It(t._zod.def,{get shape(){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 Ft(this,`shape`,i),i},checks:[]}))}function tn(e,t,n){return Kt(t,It(t._zod.def,{get shape(){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 Ft(this,`shape`,i),i}}))}function nn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function rn(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function an(e){return typeof e==`string`?e:e?.message}function on(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=an(e.inst?._zod.def?.error?.(e))??an(t?.error?.(e))??an(n.customError?.(e))??an(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function sn(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function cn(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const ln=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,kt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},un=O(`$ZodError`,ln),dn=O(`$ZodError`,ln,{Parent:Error});function fn(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 pn(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}const mn=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 wt;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>on(e,a,Dt())));throw zt(t,i?.callee),t}return o.value},hn=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=>on(e,a,Dt())));throw zt(t,i?.callee),t}return o.value},gn=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 wt;return a.issues.length?{success:!1,error:new(e??un)(a.issues.map(e=>on(e,i,Dt())))}:{success:!0,data:a.value}},_n=gn(dn),vn=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=>on(e,i,Dt())))}:{success:!0,data:a.value}},yn=vn(dn),bn=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return mn(e)(t,n,i)},xn=e=>(t,n,r)=>mn(e)(t,n,r),Sn=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return hn(e)(t,n,i)},Cn=e=>async(t,n,r)=>hn(e)(t,n,r),wn=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return gn(e)(t,n,i)},Tn=e=>(t,n,r)=>gn(e)(t,n,r),En=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return vn(e)(t,n,i)},Dn=e=>async(t,n,r)=>vn(e)(t,n,r),On=/^[cC][^\s-]{8,}$/,kn=/^[0-9a-z]+$/,An=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,jn=/^[0-9a-vA-V]{20}$/,Mn=/^[A-Za-z0-9]{27}$/,Nn=/^[a-zA-Z0-9_-]{21}$/,Pn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Fn=/^([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})$/,In=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|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ln=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Rn(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const zn=/^(?:(?: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])$/,Bn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Vn=/^((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])$/,Hn=/^(([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])$/,Un=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Wn=/^[A-Za-z0-9_-]*$/,Gn=/^\+[1-9]\d{6,14}$/,Kn=`(?:(?:\\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])))`,qn=RegExp(`^${Kn}$`);function Jn(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 Yn(e){return RegExp(`^${Jn(e)}$`)}function Xn(e){let t=Jn({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Kn}T(?:${r})$`)}const Zn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Qn=/^-?\d+$/,$n=/^-?\d+(?:\.\d+)?$/,er=/^[^A-Z]*$/,tr=/^[^a-z]*$/,j=O(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),nr={number:`number`,bigint:`bigint`,object:`date`},rr=O(`$ZodCheckLessThan`,(e,t)=>{j.init(e,t);let n=nr[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:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ir=O(`$ZodCheckGreaterThan`,(e,t)=>{j.init(e,t);let n=nr[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:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ar=O(`$ZodCheckMultipleOf`,(e,t)=>{j.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):Nt(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})}}),or=O(`$ZodCheckNumberFormat`,(e,t)=>{j.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Jt[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=Qn)}),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`,continue:!1,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,inclusive:!0,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,inclusive:!0,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,inclusive:!0,inst:e,continue:!t.abort})}}),sr=O(`$ZodCheckMaxLength`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!jt(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=sn(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),cr=O(`$ZodCheckMinLength`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!jt(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=sn(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lr=O(`$ZodCheckLengthEquals`,(e,t)=>{var n;j.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!jt(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=sn(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})}}),ur=O(`$ZodCheckStringFormat`,(e,t)=>{var n,r;j.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=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=()=>{})}),dr=O(`$ZodCheckRegex`,(e,t)=>{ur.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})}}),fr=O(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=er,ur.init(e,t)}),pr=O(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=tr,ur.init(e,t)}),mr=O(`$ZodCheckIncludes`,(e,t)=>{j.init(e,t);let n=Gt(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??=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})}}),hr=O(`$ZodCheckStartsWith`,(e,t)=>{j.init(e,t);let n=RegExp(`^${Gt(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=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})}}),gr=O(`$ZodCheckEndsWith`,(e,t)=>{j.init(e,t);let n=RegExp(`.*${Gt(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=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})}}),_r=O(`$ZodCheckOverwrite`,(e,t)=>{j.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var vr=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(`
|
|
8
7
|
`).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(`
|
|
9
|
-
`))}};const
|
|
8
|
+
`))}};const yr={major:4,minor:3,patch:6},M=O(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yr;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=nn(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 wt;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=nn(e,t))});else{if(e.issues.length===t)continue;r||=nn(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(nn(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new wt;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new wt;return o.then(e=>t(e,r,a))}return t(o,r,a)}}k(e,`~standard`,()=>({validate:t=>{try{let n=_n(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return yn(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),br=O(`$ZodString`,(e,t)=>{M.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Zn(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}}),N=O(`$ZodStringFormat`,(e,t)=>{ur.init(e,t),br.init(e,t)}),xr=O(`$ZodGUID`,(e,t)=>{t.pattern??=Fn,N.init(e,t)}),Sr=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??=In(e)}else t.pattern??=In();N.init(e,t)}),Cr=O(`$ZodEmail`,(e,t)=>{t.pattern??=Ln,N.init(e,t)}),wr=O(`$ZodURL`,(e,t)=>{N.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.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=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Tr=O(`$ZodEmoji`,(e,t)=>{t.pattern??=Rn(),N.init(e,t)}),Er=O(`$ZodNanoID`,(e,t)=>{t.pattern??=Nn,N.init(e,t)}),Dr=O(`$ZodCUID`,(e,t)=>{t.pattern??=On,N.init(e,t)}),Or=O(`$ZodCUID2`,(e,t)=>{t.pattern??=kn,N.init(e,t)}),kr=O(`$ZodULID`,(e,t)=>{t.pattern??=An,N.init(e,t)}),Ar=O(`$ZodXID`,(e,t)=>{t.pattern??=jn,N.init(e,t)}),jr=O(`$ZodKSUID`,(e,t)=>{t.pattern??=Mn,N.init(e,t)}),Mr=O(`$ZodISODateTime`,(e,t)=>{t.pattern??=Xn(t),N.init(e,t)}),Nr=O(`$ZodISODate`,(e,t)=>{t.pattern??=qn,N.init(e,t)}),Pr=O(`$ZodISOTime`,(e,t)=>{t.pattern??=Yn(t),N.init(e,t)}),Fr=O(`$ZodISODuration`,(e,t)=>{t.pattern??=Pn,N.init(e,t)}),Ir=O(`$ZodIPv4`,(e,t)=>{t.pattern??=zn,N.init(e,t),e._zod.bag.format=`ipv4`}),Lr=O(`$ZodIPv6`,(e,t)=>{t.pattern??=Bn,N.init(e,t),e._zod.bag.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})}}}),Rr=O(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Vn,N.init(e,t)}),zr=O(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Hn,N.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Br(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Vr=O(`$ZodBase64`,(e,t)=>{t.pattern??=Un,N.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Br(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Hr(e){if(!Wn.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Br(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const Ur=O(`$ZodBase64URL`,(e,t)=>{t.pattern??=Wn,N.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Hr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Wr=O(`$ZodE164`,(e,t)=>{t.pattern??=Gn,N.init(e,t)});function Gr(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 Kr=O(`$ZodJWT`,(e,t)=>{N.init(e,t),e._zod.check=n=>{Gr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),qr=O(`$ZodNumber`,(e,t)=>{M.init(e,t),e._zod.pattern=e._zod.bag.pattern??$n,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}}),Jr=O(`$ZodNumberFormat`,(e,t)=>{or.init(e,t),qr.init(e,t)}),Yr=O(`$ZodUnknown`,(e,t)=>{M.init(e,t),e._zod.parse=e=>e}),Xr=O(`$ZodNever`,(e,t)=>{M.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Zr(e,t,n){e.issues.length&&t.issues.push(...rn(n,e.issues)),t.value[n]=e.value}const Qr=O(`$ZodArray`,(e,t)=>{M.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=>Zr(t,n,e))):Zr(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function $r(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...rn(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function ei(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=qt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ti(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>$r(e,n,i,t,u))):$r(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const ni=O(`$ZodObject`,(e,t)=>{if(M.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=At(()=>ei(t));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]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Bt,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>$r(n,t,e,s,r))):$r(i,t,e,s,r)}return i?ti(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),ri=O(`$ZodObjectJIT`,(e,t)=>{ni.init(e,t);let n=e._zod.parse,r=At(()=>ei(t)),i=e=>{let t=new vr([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Lt(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 n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Lt(r),s=e[r]?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),s?t.write(`
|
|
10
9
|
if (${n}.issues.length) {
|
|
11
10
|
if (${o} in input) {
|
|
12
11
|
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
@@ -40,9 +39,9 @@ import{createRequire as e}from"node:module";import{formatWithOptions as t,parseA
|
|
|
40
39
|
newResult[${o}] = ${n}.value;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=It,s=!Ct.jitless,c=s&&Lt.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Xr([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function $r(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Zt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>en(e,r,wt())))}),t)}const ei=E(`$ZodUnion`,(e,t)=>{M.init(e,t),D(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),D(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),D(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),D(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=>kt(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>$r(t,i,e,a)):$r(s,i,e,a)}}),ti=E(`$ZodIntersection`,(e,t)=>{M.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])=>ri(e,t,n)):ri(e,i,a)}});function ni(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Rt(e)&&Rt(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=ni(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=ni(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 ri(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Zt(e))return e;let o=ni(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const ii=E(`$ZodRecord`,(e,t)=>{M.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Rt(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);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(...Qt(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Qt(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}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(typeof o==`string`&&Jn.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>en(e,r,wt())),input:o,path:[o],inst:e});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(...Qt(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Qt(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ai=E(`$ZodEnum`,(e,t)=>{M.init(e,t);let n=Tt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Bt.has(typeof e)).map(e=>typeof e==`string`?Vt(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),oi=E(`$ZodLiteral`,(e,t)=>{if(M.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Vt(e):e?Vt(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),si=E(`$ZodTransform`,(e,t)=>{M.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new St(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new xt;return n.value=i,n}});function ci(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const li=E(`$ZodOptional`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,D(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),D(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${kt(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>ci(t,e.value)):ci(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),ui=E(`$ZodExactOptional`,(e,t)=>{li.init(e,t),D(e._zod,`values`,()=>t.innerType._zod.values),D(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),di=E(`$ZodNullable`,(e,t)=>{M.init(e,t),D(e._zod,`optin`,()=>t.innerType._zod.optin),D(e._zod,`optout`,()=>t.innerType._zod.optout),D(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${kt(e.source)}|null)$`):void 0}),D(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),fi=E(`$ZodDefault`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,D(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(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=>pi(e,t)):pi(r,t)}});function pi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const mi=E(`$ZodPrefault`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,D(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),hi=E(`$ZodNonOptional`,(e,t)=>{M.init(e,t),D(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=>gi(t,e)):gi(i,e)}});function gi(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 _i=E(`$ZodCatch`,(e,t)=>{M.init(e,t),D(e._zod,`optin`,()=>t.innerType._zod.optin),D(e._zod,`optout`,()=>t.innerType._zod.optout),D(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(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=>en(e,n,wt()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>en(e,n,wt()))},input:e.value}),e.issues=[]),e)}}),vi=E(`$ZodPipe`,(e,t)=>{M.init(e,t),D(e._zod,`values`,()=>t.in._zod.values),D(e._zod,`optin`,()=>t.in._zod.optin),D(e._zod,`optout`,()=>t.out._zod.optout),D(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>yi(e,t.in,n)):yi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>yi(e,t.out,n)):yi(r,t.out,n)}});function yi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const bi=E(`$ZodReadonly`,(e,t)=>{M.init(e,t),D(e._zod,`propValues`,()=>t.innerType._zod.propValues),D(e._zod,`values`,()=>t.innerType._zod.values),D(e._zod,`optin`,()=>t.innerType?._zod?.optin),D(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(xi):xi(r)}});function xi(e){return e.value=Object.freeze(e.value),e}const Si=E(`$ZodCustom`,(e,t)=>{j.init(e,t),M.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=>Ci(t,n,r,e));Ci(i,n,r,e)}});function Ci(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(nn(e))}}var wi,Ti=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let 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)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ei(){return new Ti}(wi=globalThis).__zod_globalRegistry??(wi.__zod_globalRegistry=Ei());const Di=globalThis.__zod_globalRegistry;function Oi(e,t){return new e({type:`string`,...A(t)})}function ki(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...A(t)})}function Ai(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...A(t)})}function ji(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...A(t)})}function Mi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...A(t)})}function Ni(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...A(t)})}function Pi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...A(t)})}function Fi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...A(t)})}function Ii(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...A(t)})}function Li(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...A(t)})}function Ri(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...A(t)})}function zi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...A(t)})}function Bi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...A(t)})}function Vi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...A(t)})}function Hi(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...A(t)})}function Ui(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...A(t)})}function Wi(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...A(t)})}function Gi(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...A(t)})}function Ki(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...A(t)})}function qi(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...A(t)})}function Ji(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...A(t)})}function Yi(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...A(t)})}function Xi(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...A(t)})}function Zi(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...A(t)})}function Qi(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...A(t)})}function $i(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...A(t)})}function ea(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...A(t)})}function ta(e,t){return new e({type:`number`,checks:[],...A(t)})}function na(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...A(t)})}function ra(e){return new e({type:`unknown`})}function ia(e,t){return new e({type:`never`,...A(t)})}function aa(e,t){return new Qn({check:`less_than`,...A(t),value:e,inclusive:!1})}function oa(e,t){return new Qn({check:`less_than`,...A(t),value:e,inclusive:!0})}function sa(e,t){return new $n({check:`greater_than`,...A(t),value:e,inclusive:!1})}function ca(e,t){return new $n({check:`greater_than`,...A(t),value:e,inclusive:!0})}function la(e,t){return new er({check:`multiple_of`,...A(t),value:e})}function ua(e,t){return new nr({check:`max_length`,...A(t),maximum:e})}function da(e,t){return new rr({check:`min_length`,...A(t),minimum:e})}function fa(e,t){return new ir({check:`length_equals`,...A(t),length:e})}function pa(e,t){return new or({check:`string_format`,format:`regex`,...A(t),pattern:e})}function ma(e){return new sr({check:`string_format`,format:`lowercase`,...A(e)})}function ha(e){return new cr({check:`string_format`,format:`uppercase`,...A(e)})}function ga(e,t){return new lr({check:`string_format`,format:`includes`,...A(t),includes:e})}function _a(e,t){return new ur({check:`string_format`,format:`starts_with`,...A(t),prefix:e})}function va(e,t){return new dr({check:`string_format`,format:`ends_with`,...A(t),suffix:e})}function ya(e){return new fr({check:`overwrite`,tx:e})}function ba(e){return ya(t=>t.normalize(e))}function xa(){return ya(e=>e.trim())}function Sa(){return ya(e=>e.toLowerCase())}function Ca(){return ya(e=>e.toUpperCase())}function wa(){return ya(e=>Pt(e))}function Ta(e,t,n){return new e({type:`array`,element:t,...A(n)})}function Ea(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...A(n)})}function Da(e){let t=Oa(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(nn(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(nn(r))}},e(n.value,n)));return t}function Oa(e,t){let n=new j({check:`custom`,...A(t)});return n._zod.check=e,n}function ka(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Di,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function P(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,P(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&F(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Aa(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
42
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Bt,s=!Et.jitless,c=s&&Vt.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?ti([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function ii(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!nn(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>on(e,r,Dt())))}),t)}const ai=O(`$ZodUnion`,(e,t)=>{M.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=>Mt(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>ii(t,i,e,a)):ii(s,i,e,a)}}),oi=O(`$ZodIntersection`,(e,t)=>{M.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])=>ci(e,t,n)):ci(e,i,a)}});function si(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ht(e)&&Ht(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=si(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=si(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 ci(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),nn(e))return e;let o=si(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const li=O(`$ZodRecord`,(e,t)=>{M.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Ht(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);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(...rn(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...rn(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}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(typeof o==`string`&&$n.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>on(e,r,Dt())),input:o,path:[o],inst:e});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(...rn(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...rn(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ui=O(`$ZodEnum`,(e,t)=>{M.init(e,t);let n=Ot(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>Wt.has(typeof e)).map(e=>typeof e==`string`?Gt(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),di=O(`$ZodLiteral`,(e,t)=>{if(M.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Gt(e):e?Gt(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),fi=O(`$ZodTransform`,(e,t)=>{M.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Tt(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new wt;return n.value=i,n}});function pi(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const mi=O(`$ZodOptional`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,k(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),k(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Mt(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>pi(t,e.value)):pi(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),hi=O(`$ZodExactOptional`,(e,t)=>{mi.init(e,t),k(e._zod,`values`,()=>t.innerType._zod.values),k(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),gi=O(`$ZodNullable`,(e,t)=>{M.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(`^(${Mt(e.source)}|null)$`):void 0}),k(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),_i=O(`$ZodDefault`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,k(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(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=>vi(e,t)):vi(r,t)}});function vi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const yi=O(`$ZodPrefault`,(e,t)=>{M.init(e,t),e._zod.optin=`optional`,k(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),bi=O(`$ZodNonOptional`,(e,t)=>{M.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=>xi(t,e)):xi(i,e)}});function xi(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 Si=O(`$ZodCatch`,(e,t)=>{M.init(e,t),k(e._zod,`optin`,()=>t.innerType._zod.optin),k(e._zod,`optout`,()=>t.innerType._zod.optout),k(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(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=>on(e,n,Dt()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>on(e,n,Dt()))},input:e.value}),e.issues=[]),e)}}),Ci=O(`$ZodPipe`,(e,t)=>{M.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),k(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>wi(e,t.in,n)):wi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>wi(e,t.out,n)):wi(r,t.out,n)}});function wi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Ti=O(`$ZodReadonly`,(e,t)=>{M.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)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ei):Ei(r)}});function Ei(e){return e.value=Object.freeze(e.value),e}const Di=O(`$ZodCustom`,(e,t)=>{j.init(e,t),M.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=>Oi(t,n,r,e));Oi(i,n,r,e)}});function Oi(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(cn(e))}}var ki,Ai=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let 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)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function ji(){return new Ai}(ki=globalThis).__zod_globalRegistry??(ki.__zod_globalRegistry=ji());const Mi=globalThis.__zod_globalRegistry;function Ni(e,t){return new e({type:`string`,...A(t)})}function Pi(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...A(t)})}function Fi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...A(t)})}function Ii(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...A(t)})}function Li(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...A(t)})}function Ri(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...A(t)})}function zi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...A(t)})}function Bi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...A(t)})}function Vi(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...A(t)})}function Hi(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...A(t)})}function Ui(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...A(t)})}function Wi(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...A(t)})}function Gi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...A(t)})}function Ki(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...A(t)})}function qi(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...A(t)})}function Ji(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...A(t)})}function Yi(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...A(t)})}function Xi(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...A(t)})}function Zi(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...A(t)})}function Qi(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...A(t)})}function $i(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...A(t)})}function ea(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...A(t)})}function ta(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...A(t)})}function na(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...A(t)})}function ra(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...A(t)})}function ia(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...A(t)})}function aa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...A(t)})}function oa(e,t){return new e({type:`number`,checks:[],...A(t)})}function sa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...A(t)})}function ca(e){return new e({type:`unknown`})}function la(e,t){return new e({type:`never`,...A(t)})}function ua(e,t){return new rr({check:`less_than`,...A(t),value:e,inclusive:!1})}function da(e,t){return new rr({check:`less_than`,...A(t),value:e,inclusive:!0})}function fa(e,t){return new ir({check:`greater_than`,...A(t),value:e,inclusive:!1})}function pa(e,t){return new ir({check:`greater_than`,...A(t),value:e,inclusive:!0})}function ma(e,t){return new ar({check:`multiple_of`,...A(t),value:e})}function ha(e,t){return new sr({check:`max_length`,...A(t),maximum:e})}function ga(e,t){return new cr({check:`min_length`,...A(t),minimum:e})}function _a(e,t){return new lr({check:`length_equals`,...A(t),length:e})}function va(e,t){return new dr({check:`string_format`,format:`regex`,...A(t),pattern:e})}function ya(e){return new fr({check:`string_format`,format:`lowercase`,...A(e)})}function ba(e){return new pr({check:`string_format`,format:`uppercase`,...A(e)})}function xa(e,t){return new mr({check:`string_format`,format:`includes`,...A(t),includes:e})}function Sa(e,t){return new hr({check:`string_format`,format:`starts_with`,...A(t),prefix:e})}function Ca(e,t){return new gr({check:`string_format`,format:`ends_with`,...A(t),suffix:e})}function wa(e){return new _r({check:`overwrite`,tx:e})}function Ta(e){return wa(t=>t.normalize(e))}function Ea(){return wa(e=>e.trim())}function Da(){return wa(e=>e.toLowerCase())}function Oa(){return wa(e=>e.toUpperCase())}function ka(){return wa(e=>Rt(e))}function Aa(e,t,n){return new e({type:`array`,element:t,...A(n)})}function ja(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...A(n)})}function Ma(e){let t=Na(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(cn(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(cn(r))}},e(n.value,n)));return t}function Na(e,t){let n=new j({check:`custom`,...A(t)});return n._zod.check=e,n}function Pa(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Mi,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function P(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,P(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&F(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Fa(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
44
43
|
|
|
45
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function ja(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Na(t,`input`,e.processors),output:Na(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function F(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return F(r.element,n);if(r.type===`set`)return F(r.valueType,n);if(r.type===`lazy`)return F(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return F(r.innerType,n);if(r.type===`intersection`)return F(r.left,n)||F(r.right,n);if(r.type===`record`||r.type===`map`)return F(r.keyType,n)||F(r.valueType,n);if(r.type===`pipe`)return F(r.in,n)||F(r.out,n);if(r.type===`object`){for(let e in r.shape)if(F(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(F(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(F(e,n))return!0;return!!(r.rest&&F(r.rest,n))}return!1}const Ma=(e,t={})=>n=>{let r=ka({...n,processors:t});return P(e,r),Aa(r,e),ja(r,e)},Na=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ka({...i??{},target:a,io:t,processors:n});return P(e,o),Aa(o,e),ja(o,e)},Pa={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Fa=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Pa[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Ia=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},La=(e,t,n,r)=>{n.not={}},Ra=(e,t,n,r)=>{let i=e._zod.def,a=Tt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},za=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Ba=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Va=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Ha=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=P(a.element,t,{...r,path:[...r.path,`items`]})},Ua=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=P(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=P(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Wa=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>P(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ga=(e,t,n,r)=>{let i=e._zod.def,a=P(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=P(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Ka=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=P(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=P(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=P(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},qa=(e,t,n,r)=>{let i=e._zod.def,a=P(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ja=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ya=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Xa=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Za=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Qa=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;P(a,t,r);let o=t.seen.get(e);o.ref=a},$a=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},eo=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},to=E(`ZodISODateTime`,(e,t)=>{Dr.init(e,t),z.init(e,t)});function no(e){return Zi(to,e)}const ro=E(`ZodISODate`,(e,t)=>{Or.init(e,t),z.init(e,t)});function io(e){return Qi(ro,e)}const ao=E(`ZodISOTime`,(e,t)=>{kr.init(e,t),z.init(e,t)});function oo(e){return $i(ao,e)}const so=E(`ZodISODuration`,(e,t)=>{Ar.init(e,t),z.init(e,t)});function co(e){return ea(so,e)}const lo=(e,t)=>{an.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>cn(e,t)},flatten:{value:t=>sn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Et,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Et,2)}},isEmpty:{get(){return e.issues.length===0}}})};E(`ZodError`,lo);const I=E(`ZodError`,lo,{Parent:Error}),uo=ln(I),fo=un(I),po=dn(I),mo=pn(I),ho=hn(I),go=gn(I),_o=_n(I),vo=vn(I),yo=yn(I),bo=bn(I),xo=xn(I),So=Sn(I),L=E(`ZodType`,(e,t)=>(M.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Na(e,`input`),output:Na(e,`output`)}}),e.toJSONSchema=Ma(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(O(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>k(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>uo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>po(e,t,n),e.parseAsync=async(t,n)=>fo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>mo(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>ho(e,t,n),e.decode=(t,n)=>go(e,t,n),e.encodeAsync=async(t,n)=>_o(e,t,n),e.decodeAsync=async(t,n)=>vo(e,t,n),e.safeEncode=(t,n)=>yo(e,t,n),e.safeDecode=(t,n)=>bo(e,t,n),e.safeEncodeAsync=async(t,n)=>xo(e,t,n),e.safeDecodeAsync=async(t,n)=>So(e,t,n),e.refine=(t,n)=>e.check(Ms(t,n)),e.superRefine=t=>e.check(Ns(t)),e.overwrite=t=>e.check(ya(t)),e.optional=()=>ms(e),e.exactOptional=()=>gs(e),e.nullable=()=>vs(e),e.nullish=()=>ms(vs(e)),e.nonoptional=t=>ws(e,t),e.array=()=>Qo(e),e.or=t=>ns([e,t]),e.and=t=>is(e,t),e.transform=t=>Os(e,fs(t)),e.default=t=>bs(e,t),e.prefault=t=>Ss(e,t),e.catch=t=>Es(e,t),e.pipe=t=>Os(e,t),e.readonly=()=>As(e),e.describe=t=>{let n=e.clone();return Di.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return Di.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Di.get(e);let n=e.clone();return Di.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),Co=E(`_ZodString`,(e,t)=>{hr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fa(e,t,n,r);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(pa(...t)),e.includes=(...t)=>e.check(ga(...t)),e.startsWith=(...t)=>e.check(_a(...t)),e.endsWith=(...t)=>e.check(va(...t)),e.min=(...t)=>e.check(da(...t)),e.max=(...t)=>e.check(ua(...t)),e.length=(...t)=>e.check(fa(...t)),e.nonempty=(...t)=>e.check(da(1,...t)),e.lowercase=t=>e.check(ma(t)),e.uppercase=t=>e.check(ha(t)),e.trim=()=>e.check(xa()),e.normalize=(...t)=>e.check(ba(...t)),e.toLowerCase=()=>e.check(Sa()),e.toUpperCase=()=>e.check(Ca()),e.slugify=()=>e.check(wa())}),wo=E(`ZodString`,(e,t)=>{hr.init(e,t),Co.init(e,t),e.email=t=>e.check(ki(To,t)),e.url=t=>e.check(Fi(Oo,t)),e.jwt=t=>e.check(Xi(Uo,t)),e.emoji=t=>e.check(Ii(ko,t)),e.guid=t=>e.check(Ai(Eo,t)),e.uuid=t=>e.check(ji(Do,t)),e.uuidv4=t=>e.check(Mi(Do,t)),e.uuidv6=t=>e.check(Ni(Do,t)),e.uuidv7=t=>e.check(Pi(Do,t)),e.nanoid=t=>e.check(Li(Ao,t)),e.guid=t=>e.check(Ai(Eo,t)),e.cuid=t=>e.check(Ri(jo,t)),e.cuid2=t=>e.check(zi(Mo,t)),e.ulid=t=>e.check(Bi(No,t)),e.base64=t=>e.check(qi(Bo,t)),e.base64url=t=>e.check(Ji(Vo,t)),e.xid=t=>e.check(Vi(Po,t)),e.ksuid=t=>e.check(Hi(Fo,t)),e.ipv4=t=>e.check(Ui(Io,t)),e.ipv6=t=>e.check(Wi(Lo,t)),e.cidrv4=t=>e.check(Gi(Ro,t)),e.cidrv6=t=>e.check(Ki(zo,t)),e.e164=t=>e.check(Yi(Ho,t)),e.datetime=t=>e.check(no(t)),e.date=t=>e.check(io(t)),e.time=t=>e.check(oo(t)),e.duration=t=>e.check(co(t))});function R(e){return Oi(wo,e)}const z=E(`ZodStringFormat`,(e,t)=>{N.init(e,t),Co.init(e,t)}),To=E(`ZodEmail`,(e,t)=>{vr.init(e,t),z.init(e,t)}),Eo=E(`ZodGUID`,(e,t)=>{gr.init(e,t),z.init(e,t)}),Do=E(`ZodUUID`,(e,t)=>{_r.init(e,t),z.init(e,t)}),Oo=E(`ZodURL`,(e,t)=>{yr.init(e,t),z.init(e,t)}),ko=E(`ZodEmoji`,(e,t)=>{br.init(e,t),z.init(e,t)}),Ao=E(`ZodNanoID`,(e,t)=>{xr.init(e,t),z.init(e,t)}),jo=E(`ZodCUID`,(e,t)=>{Sr.init(e,t),z.init(e,t)}),Mo=E(`ZodCUID2`,(e,t)=>{Cr.init(e,t),z.init(e,t)}),No=E(`ZodULID`,(e,t)=>{wr.init(e,t),z.init(e,t)}),Po=E(`ZodXID`,(e,t)=>{Tr.init(e,t),z.init(e,t)}),Fo=E(`ZodKSUID`,(e,t)=>{Er.init(e,t),z.init(e,t)}),Io=E(`ZodIPv4`,(e,t)=>{jr.init(e,t),z.init(e,t)}),Lo=E(`ZodIPv6`,(e,t)=>{Mr.init(e,t),z.init(e,t)}),Ro=E(`ZodCIDRv4`,(e,t)=>{Nr.init(e,t),z.init(e,t)}),zo=E(`ZodCIDRv6`,(e,t)=>{Pr.init(e,t),z.init(e,t)}),Bo=E(`ZodBase64`,(e,t)=>{Ir.init(e,t),z.init(e,t)}),Vo=E(`ZodBase64URL`,(e,t)=>{Rr.init(e,t),z.init(e,t)}),Ho=E(`ZodE164`,(e,t)=>{zr.init(e,t),z.init(e,t)}),Uo=E(`ZodJWT`,(e,t)=>{Vr.init(e,t),z.init(e,t)}),Wo=E(`ZodNumber`,(e,t)=>{Hr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ia(e,t,n,r),e.gt=(t,n)=>e.check(sa(t,n)),e.gte=(t,n)=>e.check(ca(t,n)),e.min=(t,n)=>e.check(ca(t,n)),e.lt=(t,n)=>e.check(aa(t,n)),e.lte=(t,n)=>e.check(oa(t,n)),e.max=(t,n)=>e.check(oa(t,n)),e.int=t=>e.check(Ko(t)),e.safe=t=>e.check(Ko(t)),e.positive=t=>e.check(sa(0,t)),e.nonnegative=t=>e.check(ca(0,t)),e.negative=t=>e.check(aa(0,t)),e.nonpositive=t=>e.check(oa(0,t)),e.multipleOf=(t,n)=>e.check(la(t,n)),e.step=(t,n)=>e.check(la(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 B(e){return ta(Wo,e)}const Go=E(`ZodNumberFormat`,(e,t)=>{Ur.init(e,t),Wo.init(e,t)});function Ko(e){return na(Go,e)}const qo=E(`ZodUnknown`,(e,t)=>{Wr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Jo(){return ra(qo)}const Yo=E(`ZodNever`,(e,t)=>{Gr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>La(e,t,n,r)});function Xo(e){return ia(Yo,e)}const Zo=E(`ZodArray`,(e,t)=>{qr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ha(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(da(t,n)),e.nonempty=t=>e.check(da(1,t)),e.max=(t,n)=>e.check(ua(t,n)),e.length=(t,n)=>e.check(fa(t,n)),e.unwrap=()=>e.element});function Qo(e,t){return Ta(Zo,e,t)}const $o=E(`ZodObject`,(e,t)=>{Qr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ua(e,t,n,r),D(e,`shape`,()=>t.shape),e.keyof=()=>cs(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Jo()}),e.loose=()=>e.clone({...e._zod.def,catchall:Jo()}),e.strict=()=>e.clone({...e._zod.def,catchall:Xo()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Kt(e,t),e.safeExtend=t=>qt(e,t),e.merge=t=>Jt(e,t),e.pick=t=>Wt(e,t),e.omit=t=>Gt(e,t),e.partial=(...t)=>Yt(ps,e,t[0]),e.required=(...t)=>Xt(Cs,e,t[0])});function V(e,t){let n={type:`object`,shape:e??{},...A(t)};return new $o(n)}function es(e,t){return new $o({type:`object`,shape:e,catchall:Xo(),...A(t)})}const ts=E(`ZodUnion`,(e,t)=>{ei.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wa(e,t,n,r),e.options=t.options});function ns(e,t){return new ts({type:`union`,options:e,...A(t)})}const rs=E(`ZodIntersection`,(e,t)=>{ti.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ga(e,t,n,r)});function is(e,t){return new rs({type:`intersection`,left:e,right:t})}const as=E(`ZodRecord`,(e,t)=>{ii.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ka(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function os(e,t,n){return new as({type:`record`,keyType:e,valueType:t,...A(n)})}const ss=E(`ZodEnum`,(e,t)=>{ai.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ra(e,t,n,r),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 ss({...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 ss({...t,checks:[],...A(r),entries:i})}});function cs(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new ss({type:`enum`,entries:n,...A(t)})}const ls=E(`ZodLiteral`,(e,t)=>{oi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>za(e,t,n,r),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 us(e,t){return new ls({type:`literal`,values:Array.isArray(e)?e:[e],...A(t)})}const ds=E(`ZodTransform`,(e,t)=>{si.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Va(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new St(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(nn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(nn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function fs(e){return new ds({type:`transform`,transform:e})}const ps=E(`ZodOptional`,(e,t)=>{li.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ms(e){return new ps({type:`optional`,innerType:e})}const hs=E(`ZodExactOptional`,(e,t)=>{ui.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gs(e){return new hs({type:`optional`,innerType:e})}const _s=E(`ZodNullable`,(e,t)=>{di.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vs(e){return new _s({type:`nullable`,innerType:e})}const ys=E(`ZodDefault`,(e,t)=>{fi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ya(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function bs(e,t){return new ys({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():zt(t)}})}const xs=E(`ZodPrefault`,(e,t)=>{mi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ss(e,t){return new xs({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():zt(t)}})}const Cs=E(`ZodNonOptional`,(e,t)=>{hi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ja(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ws(e,t){return new Cs({type:`nonoptional`,innerType:e,...A(t)})}const Ts=E(`ZodCatch`,(e,t)=>{_i.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Za(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Es(e,t){return new Ts({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Ds=E(`ZodPipe`,(e,t)=>{vi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qa(e,t,n,r),e.in=t.in,e.out=t.out});function Os(e,t){return new Ds({type:`pipe`,in:e,out:t})}const ks=E(`ZodReadonly`,(e,t)=>{bi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$a(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function As(e){return new ks({type:`readonly`,innerType:e})}const js=E(`ZodCustom`,(e,t)=>{Si.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ba(e,t,n,r)});function Ms(e,t={}){return Ea(js,e,t)}function Ns(e){return Da(e)}const Ps=10485760,Fs=R().max(4096),H=R().min(1).max(512),Is=B().int().min(0).max(2**53-1),Ls=B().min(0).max(1),Rs=es({name:H,width:B().int().positive().max(16384),height:B().int().positive().max(16384)}),zs=es({pixel:Ls,ratio:Ls}),Bs=es({id:H,browser:H,browserVersion:H,orchestratorRuntime:H,operatingSystem:H,architecture:H,deviceScaleFactor:B().positive().max(8),locale:H,timezone:H,colorScheme:cs([`light`,`dark`]),reducedMotion:cs([`reduce`,`no-preference`]),frozenTime:H,randomSeed:B().int().min(0).max(2**53-1),fontsFingerprint:H,network:es({mode:us(`allowlist`),allowedDomains:Qo(H).max(100),webRtc:us(`disabled`)})}),Vs=es({id:H,storyId:H,title:Fs,name:Fs,viewport:Rs,status:cs([`unchanged`,`changed`,`added`,`removed`,`error`]),baseImage:Fs.optional(),headImage:Fs.optional(),diffImage:Fs.optional(),changedPixels:Is.optional(),diffRatio:Ls.optional(),threshold:zs.optional(),error:Fs.optional()}),Hs=es({version:us(1),baseRevision:H,headRevision:H,environment:Bs,createdAt:H,threshold:zs,summary:es({total:Is,unchanged:Is,changed:Is,added:Is,removed:Is,errors:Is}),entries:os(R(),Vs)}).superRefine((e,t)=>{let n=Object.entries(e.entries);if(n.length>2e4){t.addIssue({code:`custom`,message:`Report contains more than 20000 entries`,path:[`entries`]});return}for(let[e,r]of n)e!==r.id&&t.addIssue({code:`custom`,message:`Entry key must match entry.id`,path:[`entries`,e,`id`]});let r={unchanged:0,changed:0,added:0,removed:0,error:0};for(let t of Object.values(e.entries))r[t.status]+=1;(e.summary.total!==n.length||e.summary.unchanged!==r.unchanged||e.summary.changed!==r.changed||e.summary.added!==r.added||e.summary.removed!==r.removed||e.summary.errors!==r.error)&&t.addIssue({code:`custom`,message:`Report summary does not match its entries`,path:[`summary`]})});function Us(e){let t=Hs.safeParse(e);if(!t.success){let e=t.error.issues[0],n=e?.path.length?` at ${e.path.join(`.`)}`:``;throw Error(`Invalid Kapture report${n}: ${e?.message??`unknown error`}`)}return t.data}const Ws=Pe({meta:{name:`github`,description:`Publish and approve GitHub visual reviews`},subCommands:{report:Pe({meta:{name:`report`,description:`Publish a trusted Kapture PR report and commit status`},args:{report:{type:`string`,required:!0,description:`Path to untrusted report.json`},"report-url":{type:`string`,description:`HTTPS URL for the full report or workflow run`},"status-context":{type:`string`,default:`Kapture Visual Review`,description:`GitHub commit status context`}},async run({args:e}){try{let t=process.env.GITHUB_TOKEN;if(!t)throw Error(`GITHUB_TOKEN is required`);let n=u(e.report),r=await y(n);if(!r.isFile()||r.size>10485760)throw Error(`Kapture report must be a file no larger than ${Ps} bytes`);let i;try{i=JSON.parse(await v(n,`utf8`))}catch{throw Error(`Kapture report does not contain valid JSON`)}let a=Us(i),o=ut(await lt()),s=$e(e[`status-context`]),c=Qe(e[`report-url`]),l=await _t(new ct(t,o.repository),o,a,s,c);if(await yt({status:l.status,"changed-count":l.changedCount,"comment-id":l.commentId,"report-digest":l.reportDigest}),l.status===`error`)throw Error(`${a.summary.errors} visual capture error(s)`)}catch(e){throw await yt({status:`error`}),e}}}),approve:bt}});function Gs(e,t,n,r,i,a={}){let{threshold:o=.1,alpha:s=.1,aaColor:c=[255,255,0],diffColor:l=[255,0,0],includeAA:u,diffColorAlt:d,diffMask:f}=a;if(!Ks(e)||!Ks(t)||n&&!Ks(n))throw Error(`Image data: Uint8Array, Uint8ClampedArray or Buffer expected.`);if(e.length!==t.length||n&&n.length!==e.length)throw Error(`Image sizes do not match.`);if(e.length!==r*i*4)throw Error(`Image data size does not match width/height.`);let p=r*i,m=new Uint32Array(e.buffer,e.byteOffset,p),h=new Uint32Array(t.buffer,t.byteOffset,p),g=!0;for(let e=0;e<p;e++)if(m[e]!==h[e]){g=!1;break}if(g){if(n&&!f)for(let t=0;t<p;t++)Zs(e,4*t,s,n);return 0}let _=35215*o*o,[v,ee,y]=c,[b,te,ne]=l,[re,ie,ae]=d||l,x=0;for(let a=0;a<i;a++)for(let o=0;o<r;o++){let c=a*r+o,l=c*4,d=m[c]===h[c]?0:Ys(e,t,l,l,!1);if(Math.abs(d)>_){let s=qs(e,o,a,r,i,m,h)||qs(t,o,a,r,i,h,m);!u&&s?n&&!f&&Xs(n,l,v,ee,y):(n&&(d<0?Xs(n,l,re,ie,ae):Xs(n,l,b,te,ne)),x++)}else n&&!f&&Zs(e,l,s,n)}return x}function Ks(e){return ArrayBuffer.isView(e)&&e.BYTES_PER_ELEMENT===1}function qs(e,t,n,r,i,a,o){let s=Math.max(t-1,0),c=Math.max(n-1,0),l=Math.min(t+1,r-1),u=Math.min(n+1,i-1),d=n*r+t,f=+(t===s||t===l||n===c||n===u),p=0,m=0,h=0,g=0,_=0,v=0;for(let i=s;i<=l;i++)for(let a=c;a<=u;a++){if(i===t&&a===n)continue;let o=Ys(e,e,d*4,(a*r+i)*4,!0);if(o===0){if(f++,f>2)return!1}else o<p?(p=o,h=i,g=a):o>m&&(m=o,_=i,v=a)}return p===0||m===0?!1:Js(a,h,g,r,i)&&Js(o,h,g,r,i)||Js(a,_,v,r,i)&&Js(o,_,v,r,i)}function Js(e,t,n,r,i){let a=Math.max(t-1,0),o=Math.max(n-1,0),s=Math.min(t+1,r-1),c=Math.min(n+1,i-1),l=e[n*r+t],u=+(t===a||t===s||n===o||n===c);for(let i=a;i<=s;i++)for(let a=o;a<=c;a++)if((i!==t||a!==n)&&(u+=+(l===e[a*r+i]),u>2))return!0;return!1}function Ys(e,t,n,r,i){let a=e[n],o=e[n+1],s=e[n+2],c=e[n+3],l=t[r],u=t[r+1],d=t[r+2],f=t[r+3],p=a-l,m=o-u,h=s-d,g=c-f;if(!p&&!m&&!h&&!g)return 0;if(c<255||f<255){let e=48+n%2*159,t=48+159*((n/1.618033988749895|0)%2),r=48+159*((n/2.618033988749895|0)%2);p=(a*c-l*f-e*g)/255,m=(o*c-u*f-t*g)/255,h=(s*c-d*f-r*g)/255}let _=p*.29889531+m*.58662247+h*.11448223;if(i)return _;let v=p*.59597799-m*.2741761-h*.32180189,ee=p*.21147017-m*.52261711+h*.31114694,y=.5053*_*_+.299*v*v+.1957*ee*ee;return _>0?-y:y}function Xs(e,t,n,r,i){e[t+0]=n,e[t+1]=r,e[t+2]=i,e[t+3]=255}function Zs(e,t,n,r){let i=255+(e[t]*.29889531+e[t+1]*.58662247+e[t+2]*.11448223-255)*n*e[t+3]/255;Xs(r,t,i,i,i)}var Qs=S(((e,t)=>{let n=C(`util`),r=C(`stream`),i=t.exports=function(){r.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding=`utf8`,this.writable=!0};n.inherits(i,r),i.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit(`drain`))}.bind(this))},i.prototype.write=function(e,t){if(!this.writable)return this.emit(`error`,Error(`Stream not writable`)),!1;let n;return n=Buffer.isBuffer(e)?e:Buffer.from(e,t||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&this._reads.length===0&&(this._paused=!0),this.writable&&!this._paused},i.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(this._buffers.length===0?this._end():(this._buffers.push(null),this._process()))},i.prototype.destroySoon=i.prototype.end,i.prototype._end=function(){this._reads.length>0&&this.emit(`error`,Error(`Unexpected end of input`)),this.destroy()},i.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit(`close`))},i.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))},i.prototype._processRead=function(e){this._reads.shift();let t=0,n=0,r=Buffer.alloc(e.length);for(;t<e.length;){let i=this._buffers[n++],a=Math.min(i.length,e.length-t);i.copy(r,t,0,a),t+=a,a!==i.length&&(this._buffers[--n]=i.slice(a))}n>0&&this._buffers.splice(0,n),this._buffered-=e.length,e.func.call(this,r)},i.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit(`error`,e)}}})),$s=S((e=>{let t=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];e.getImagePasses=function(e,n){let r=[],i=e%8,a=n%8,o=(e-i)/8,s=(n-a)/8;for(let e=0;e<t.length;e++){let n=t[e],c=o*n.x.length,l=s*n.y.length;for(let e=0;e<n.x.length&&n.x[e]<i;e++)c++;for(let e=0;e<n.y.length&&n.y[e]<a;e++)l++;c>0&&l>0&&r.push({width:c,height:l,index:e})}return r},e.getInterlaceIterator=function(e){return function(n,r,i){let a=n%t[i].x.length,o=(n-a)/t[i].x.length*8+t[i].x[a],s=r%t[i].y.length,c=(r-s)/t[i].y.length*8+t[i].y[s];return o*4+c*e*4}}})),ec=S(((e,t)=>{t.exports=function(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}})),tc=S(((e,t)=>{let n=$s(),r=ec();function i(e,t,n){let r=e*t;return n!==8&&(r=Math.ceil(r/(8/n))),r}let a=t.exports=function(e,t){let r=e.width,a=e.height,o=e.interlace,s=e.bpp,c=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],o){let e=n.getImagePasses(r,a);for(let t=0;t<e.length;t++)this._images.push({byteWidth:i(e[t].width,s,c),height:e[t].height,lineIndex:0})}else this._images.push({byteWidth:i(r,s,c),height:a,lineIndex:0});this._xComparison=c===8?s:c===16?s*2:1};a.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},a.prototype._unFilterType1=function(e,t,n){let r=this._xComparison,i=r-1;for(let a=0;a<n;a++){let n=e[1+a],o=a>i?t[a-r]:0;t[a]=n+o}},a.prototype._unFilterType2=function(e,t,n){let r=this._lastLine;for(let i=0;i<n;i++){let n=e[1+i],a=r?r[i]:0;t[i]=n+a}},a.prototype._unFilterType3=function(e,t,n){let r=this._xComparison,i=r-1,a=this._lastLine;for(let o=0;o<n;o++){let n=e[1+o],s=a?a[o]:0,c=o>i?t[o-r]:0,l=Math.floor((c+s)/2);t[o]=n+l}},a.prototype._unFilterType4=function(e,t,n){let i=this._xComparison,a=i-1,o=this._lastLine;for(let s=0;s<n;s++){let n=e[1+s],c=o?o[s]:0,l=s>a?t[s-i]:0,u=s>a&&o?o[s-i]:0,d=r(l,c,u);t[s]=n+d}},a.prototype._reverseFilterLine=function(e){let t=e[0],n,r=this._images[this._imageIndex],i=r.byteWidth;if(t===0)n=e.slice(1,i+1);else switch(n=Buffer.alloc(i),t){case 1:this._unFilterType1(e,n,i);break;case 2:this._unFilterType2(e,n,i);break;case 3:this._unFilterType3(e,n,i);break;case 4:this._unFilterType4(e,n,i);break;default:throw Error(`Unrecognised filter type - `+t)}this.write(n),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=n,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}})),nc=S(((e,t)=>{let n=C(`util`),r=Qs(),i=tc(),a=t.exports=function(e){r.call(this);let t=[],n=this;this._filter=new i(e,{read:this.read.bind(this),write:function(e){t.push(e)},complete:function(){n.emit(`complete`,Buffer.concat(t))}}),this._filter.start()};n.inherits(a,r)})),rc=S(((e,t)=>{t.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}})),ic=S(((e,t)=>{let n=[];(function(){for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;n[e]=t}})();let r=t.exports=function(){this._crc=-1};r.prototype.write=function(e){for(let t=0;t<e.length;t++)this._crc=n[(this._crc^e[t])&255]^this._crc>>>8;return!0},r.prototype.crc32=function(){return this._crc^-1},r.crc32=function(e){let t=-1;for(let r=0;r<e.length;r++)t=n[(t^e[r])&255]^t>>>8;return t^-1}})),ac=S(((e,t)=>{let n=rc(),r=ic(),i=t.exports=function(e,t){this._options=e,e.checkCRC=e.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[n.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[n.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[n.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[n.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[n.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[n.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};i.prototype.start=function(){this.read(n.PNG_SIGNATURE.length,this._parseSignature.bind(this))},i.prototype._parseSignature=function(e){let t=n.PNG_SIGNATURE;for(let n=0;n<t.length;n++)if(e[n]!==t[n]){this.error(Error(`Invalid file signature`));return}this.read(8,this._parseChunkBegin.bind(this))},i.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),i=e.readUInt32BE(4),a=``;for(let t=4;t<8;t++)a+=String.fromCharCode(e[t]);let o=!!(e[4]&32);if(!this._hasIHDR&&i!==n.TYPE_IHDR){this.error(Error(`Expected IHDR on beggining`));return}if(this._crc=new r,this._crc.write(Buffer.from(a)),this._chunks[i])return this._chunks[i](t);if(!o){this.error(Error(`Unsupported critical chunk type `+a));return}this.read(t+4,this._skipChunk.bind(this))},i.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},i.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),n=this._crc.crc32();if(this._options.checkCRC&&n!==t){this.error(Error(`Crc error - `+t+` - `+n));return}this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))},i.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),r=e.readUInt32BE(4),i=e[8],a=e[9],o=e[10],s=e[11],c=e[12];if(i!==8&&i!==4&&i!==2&&i!==1&&i!==16){this.error(Error(`Unsupported bit depth `+i));return}if(!(a in n.COLORTYPE_TO_BPP_MAP)){this.error(Error(`Unsupported color type`));return}if(o!==0){this.error(Error(`Unsupported compression method`));return}if(s!==0){this.error(Error(`Unsupported filter method`));return}if(c!==0&&c!==1){this.error(Error(`Unsupported interlace method`));return}this._colorType=a;let l=n.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:r,depth:i,interlace:!!c,palette:!!(a&n.COLORTYPE_PALETTE),color:!!(a&n.COLORTYPE_COLOR),alpha:!!(a&n.COLORTYPE_ALPHA),bpp:l,colorType:a}),this._handleChunkEnd()},i.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))},i.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let n=0;n<t;n++)this._palette.push([e[n*3],e[n*3+1],e[n*3+2],255]);this.palette(this._palette),this._handleChunkEnd()},i.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))},i.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===n.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error(`Transparency chunk must be after palette`));return}if(e.length>this._palette.length){this.error(Error(`More transparent colors than palette size`));return}for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===n.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===n.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()},i.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))},i.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/n.GAMMA_DIVISION),this._handleChunkEnd()},i.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))},i.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===n.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error(`Expected palette not found`);this.inflateData(t);let r=e-t.length;r>0?this._handleIDAT(r):this._handleChunkEnd()},i.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))},i.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}})),oc=S((e=>{let t=$s(),n=[function(){},function(e,t,n,r){if(r===t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=255},function(e,t,n,r){if(r+1>=t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=t[r+1]},function(e,t,n,r){if(r+2>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=255},function(e,t,n,r){if(r+3>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=t[r+3]}],r=[function(){},function(e,t,n,r){let i=t[0];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=r},function(e,t,n){let r=t[0];e[n]=r,e[n+1]=r,e[n+2]=r,e[n+3]=t[1]},function(e,t,n,r){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=r},function(e,t,n){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=t[3]}];function i(e,t){let n=[],r=0;function i(){if(r===e.length)throw Error(`Ran out of data`);let i=e[r];r++;let a,o,s,c,l,u,d,f;switch(t){default:throw Error(`unrecognised depth`);case 16:d=e[r],r++,n.push((i<<8)+d);break;case 4:d=i&15,f=i>>4,n.push(f,d);break;case 2:l=i&3,u=i>>2&3,d=i>>4&3,f=i>>6&3,n.push(f,d,u,l);break;case 1:a=i&1,o=i>>1&1,s=i>>2&1,c=i>>3&1,l=i>>4&1,u=i>>5&1,d=i>>6&1,f=i>>7&1,n.push(f,d,u,l,c,s,o,a)}}return{get:function(e){for(;n.length<e;)i();let t=n.slice(0,e);return n=n.slice(e),t},resetAfterLine:function(){n.length=0},end:function(){if(r!==e.length)throw Error(`extra data found`)}}}function a(e,t,r,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++)for(let c=0;c<s;c++){let s=r(c,e,l);n[i](t,a,s,o),o+=i}return o}function o(e,t,n,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++){for(let c=0;c<s;c++){let s=a.get(i),u=n(c,e,l);r[i](t,s,u,o)}a.resetAfterLine()}}e.dataToBitMap=function(e,n){let r=n.width,s=n.height,c=n.depth,l=n.bpp,u=n.interlace,d;c!==8&&(d=i(e,c));let f;f=c<=8?Buffer.alloc(r*s*4):new Uint16Array(r*s*4);let p=2**c-1,m=0,h,g;if(u)h=t.getImagePasses(r,s),g=t.getInterlaceIterator(r,s);else{let e=0;g=function(){let t=e;return e+=4,t},h=[{width:r,height:s}]}for(let t=0;t<h.length;t++)c===8?m=a(h[t],f,g,l,e,m):o(h[t],f,g,l,d,p);if(c===8){if(m!==e.length)throw Error(`extra data found`)}else d.end();return f}})),sc=S(((e,t)=>{function n(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=i[e[a]];if(!n)throw Error(`index `+e[a]+` not in palette`);for(let e=0;e<4;e++)t[a+e]=n[e];a+=4}}function r(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=!1;if(i.length===1?i[0]===e[a]&&(n=!0):i[0]===e[a]&&i[1]===e[a+1]&&i[2]===e[a+2]&&(n=!0),n)for(let e=0;e<4;e++)t[a+e]=0;a+=4}}function i(e,t,n,r,i){let a=2**i-1,o=0;for(let i=0;i<r;i++)for(let r=0;r<n;r++){for(let n=0;n<4;n++)t[o+n]=Math.floor(e[o+n]*255/a+.5);o+=4}}t.exports=function(e,t,a=!1){let o=t.depth,s=t.width,c=t.height,l=t.colorType,u=t.transColor,d=t.palette,f=e;return l===3?n(e,f,s,c,d):(u&&r(e,f,s,c,u),o!==8&&!a&&(o===16&&(f=Buffer.alloc(s*c*4)),i(e,f,s,c,o))),f}})),cc=S(((e,t)=>{let n=C(`util`),r=C(`zlib`),i=Qs(),a=nc(),o=ac(),s=oc(),c=sc(),l=t.exports=function(e){i.call(this),this._parser=new o(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,`gamma`),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};n.inherits(l,i),l.prototype._handleError=function(e){this.emit(`error`,e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on(`error`,function(){})),this.errord=!0},l.prototype._inflateData=function(e){if(!this._inflate){if(this._bitmapInfo.interlace)this._inflate=r.createInflate(),this._inflate.on(`error`,this.emit.bind(this,`error`)),this._filter.on(`complete`,this._complete.bind(this)),this._inflate.pipe(this._filter);else{let e=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,t=Math.max(e,r.Z_MIN_CHUNK);this._inflate=r.createInflate({chunkSize:t});let n=e,i=this.emit.bind(this,`error`);this._inflate.on(`error`,function(e){n&&i(e)}),this._filter.on(`complete`,this._complete.bind(this));let a=this._filter.write.bind(this._filter);this._inflate.on(`data`,function(e){n&&(e.length>n&&(e=e.slice(0,n)),n-=e.length,a(e))}),this._inflate.on(`end`,this._filter.end.bind(this._filter))}}this._inflate.write(e)},l.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new a(this._bitmapInfo)},l.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e},l.prototype._handlePalette=function(e){this._bitmapInfo.palette=e},l.prototype._simpleTransparency=function(){this._metaData.alpha=!0},l.prototype._headersFinished=function(){this.emit(`metadata`,this._metaData)},l.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit(`error`,`No Inflate block`))},l.prototype._complete=function(e){if(this.errord)return;let t;try{let n=s.dataToBitMap(e,this._bitmapInfo);t=c(n,this._bitmapInfo,this._options.skipRescale),n=null}catch(e){this._handleError(e);return}this.emit(`parsed`,t)}})),lc=S(((e,t)=>{let n=rc();t.exports=function(e,t,r,i){let a=[n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(i.colorType)!==-1;if(i.colorType===i.inputColorType){let t=(function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]!==256})();if(i.bitDepth===8||i.bitDepth===16&&t)return e}let o=i.bitDepth===16?new Uint16Array(e.buffer):e,s=255,c=n.COLORTYPE_TO_BPP_MAP[i.inputColorType];c===4&&!i.inputHasAlpha&&(c=3);let l=n.COLORTYPE_TO_BPP_MAP[i.colorType];i.bitDepth===16&&(s=65535,l*=2);let u=Buffer.alloc(t*r*l),d=0,f=0,p=i.bgColor||{};p.red===void 0&&(p.red=s),p.green===void 0&&(p.green=s),p.blue===void 0&&(p.blue=s);function m(){let e,t,r,c=s;switch(i.inputColorType){case n.COLORTYPE_COLOR_ALPHA:c=o[d+3],e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_COLOR:e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_ALPHA:c=o[d+1],e=o[d],t=e,r=e;break;case n.COLORTYPE_GRAYSCALE:e=o[d],t=e,r=e;break;default:throw Error(`input color type:`+i.inputColorType+` is not supported at present`)}return i.inputHasAlpha&&(a||(c/=s,e=Math.min(Math.max(Math.round((1-c)*p.red+c*e),0),s),t=Math.min(Math.max(Math.round((1-c)*p.green+c*t),0),s),r=Math.min(Math.max(Math.round((1-c)*p.blue+c*r),0),s))),{red:e,green:t,blue:r,alpha:c}}for(let e=0;e<r;e++)for(let e=0;e<t;e++){let e=m(o,d);switch(i.colorType){case n.COLORTYPE_COLOR_ALPHA:case n.COLORTYPE_COLOR:i.bitDepth===8?(u[f]=e.red,u[f+1]=e.green,u[f+2]=e.blue,a&&(u[f+3]=e.alpha)):(u.writeUInt16BE(e.red,f),u.writeUInt16BE(e.green,f+2),u.writeUInt16BE(e.blue,f+4),a&&u.writeUInt16BE(e.alpha,f+6));break;case n.COLORTYPE_ALPHA:case n.COLORTYPE_GRAYSCALE:{let t=(e.red+e.green+e.blue)/3;i.bitDepth===8?(u[f]=t,a&&(u[f+1]=e.alpha)):(u.writeUInt16BE(t,f),a&&u.writeUInt16BE(e.alpha,f+2));break}default:throw Error(`unrecognised color Type `+i.colorType)}d+=c,f+=l}return u}})),uc=S(((e,t)=>{let n=ec();function r(e,t,n,r,i){for(let a=0;a<n;a++)r[i+a]=e[t+a]}function i(e,t,n){let r=0,i=t+n;for(let n=t;n<i;n++)r+=Math.abs(e[n]);return r}function a(e,t,n,r,i,a){for(let o=0;o<n;o++){let n=o>=a?e[t+o-a]:0,s=e[t+o]-n;r[i+o]=s}}function o(e,t,n,r){let i=0;for(let a=0;a<n;a++){let n=a>=r?e[t+a-r]:0,o=e[t+a]-n;i+=Math.abs(o)}return i}function s(e,t,n,r,i){for(let a=0;a<n;a++){let o=t>0?e[t+a-n]:0,s=e[t+a]-o;r[i+a]=s}}function c(e,t,n){let r=0,i=t+n;for(let a=t;a<i;a++){let i=t>0?e[a-n]:0,o=e[a]-i;r+=Math.abs(o)}return r}function l(e,t,n,r,i,a){for(let o=0;o<n;o++){let s=o>=a?e[t+o-a]:0,c=t>0?e[t+o-n]:0,l=e[t+o]-(s+c>>1);r[i+o]=l}}function u(e,t,n,r){let i=0;for(let a=0;a<n;a++){let o=a>=r?e[t+a-r]:0,s=t>0?e[t+a-n]:0,c=e[t+a]-(o+s>>1);i+=Math.abs(c)}return i}function d(e,t,r,i,a,o){for(let s=0;s<r;s++){let c=s>=o?e[t+s-o]:0,l=t>0?e[t+s-r]:0,u=t>0&&s>=o?e[t+s-(r+o)]:0,d=e[t+s]-n(c,l,u);i[a+s]=d}}function f(e,t,r,i){let a=0;for(let o=0;o<r;o++){let s=o>=i?e[t+o-i]:0,c=t>0?e[t+o-r]:0,l=t>0&&o>=i?e[t+o-(r+i)]:0,u=e[t+o]-n(s,c,l);a+=Math.abs(u)}return a}let p={0:r,1:a,2:s,3:l,4:d},m={0:i,1:o,2:c,3:u,4:f};t.exports=function(e,t,n,r,i){let a;if(!(`filterType`in r)||r.filterType===-1)a=[0,1,2,3,4];else if(typeof r.filterType==`number`)a=[r.filterType];else throw Error(`unrecognised filter types`);r.bitDepth===16&&(i*=2);let o=t*i,s=0,c=0,l=Buffer.alloc((o+1)*n),u=a[0];for(let t=0;t<n;t++){if(a.length>1){let t=1/0;for(let n=0;n<a.length;n++){let r=m[a[n]](e,c,o,i);r<t&&(u=a[n],t=r)}}l[s]=u,s++,p[u](e,c,o,l,s,i),s+=o,c+=o}return l}})),dc=S(((e,t)=>{let n=rc(),r=ic(),i=lc(),a=uc(),o=C(`zlib`),s=t.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32768,e.deflateLevel=e.deflateLevel==null?9:e.deflateLevel,e.deflateStrategy=e.deflateStrategy==null?3:e.deflateStrategy,e.inputHasAlpha=e.inputHasAlpha==null||e.inputHasAlpha,e.deflateFactory=e.deflateFactory||o.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType=typeof e.colorType==`number`?e.colorType:n.COLORTYPE_COLOR_ALPHA,e.inputColorType=typeof e.inputColorType==`number`?e.inputColorType:n.COLORTYPE_COLOR_ALPHA,[n.COLORTYPE_GRAYSCALE,n.COLORTYPE_COLOR,n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(e.colorType)===-1)throw Error(`option color type:`+e.colorType+` is not supported at present`);if([n.COLORTYPE_GRAYSCALE,n.COLORTYPE_COLOR,n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(e.inputColorType)===-1)throw Error(`option input color type:`+e.inputColorType+` is not supported at present`);if(e.bitDepth!==8&&e.bitDepth!==16)throw Error(`option bit depth:`+e.bitDepth+` is not supported at present`)};s.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},s.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},s.prototype.filterData=function(e,t,r){let o=i(e,t,r,this._options),s=n.COLORTYPE_TO_BPP_MAP[this._options.colorType];return a(o,t,r,this._options,s)},s.prototype._packChunk=function(e,t){let n=t?t.length:0,i=Buffer.alloc(n+12);return i.writeUInt32BE(n,0),i.writeUInt32BE(e,4),t&&t.copy(i,8),i.writeInt32BE(r.crc32(i.slice(4,i.length-4)),i.length-4),i},s.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*n.GAMMA_DIVISION),0),this._packChunk(n.TYPE_gAMA,t)},s.prototype.packIHDR=function(e,t){let r=Buffer.alloc(13);return r.writeUInt32BE(e,0),r.writeUInt32BE(t,4),r[8]=this._options.bitDepth,r[9]=this._options.colorType,r[10]=0,r[11]=0,r[12]=0,this._packChunk(n.TYPE_IHDR,r)},s.prototype.packIDAT=function(e){return this._packChunk(n.TYPE_IDAT,e)},s.prototype.packIEND=function(){return this._packChunk(n.TYPE_IEND,null)}})),fc=S(((e,t)=>{let n=C(`util`),r=C(`stream`),i=rc(),a=dc(),o=t.exports=function(e){r.call(this);let t=e||{};this._packer=new a(t),this._deflate=this._packer.createDeflate(),this.readable=!0};n.inherits(o,r),o.prototype.pack=function(e,t,n,r){this.emit(`data`,Buffer.from(i.PNG_SIGNATURE)),this.emit(`data`,this._packer.packIHDR(t,n)),r&&this.emit(`data`,this._packer.packGAMA(r));let a=this._packer.filterData(e,t,n);this._deflate.on(`error`,this.emit.bind(this,`error`)),this._deflate.on(`data`,function(e){this.emit(`data`,this._packer.packIDAT(e))}.bind(this)),this._deflate.on(`end`,function(){this.emit(`data`,this._packer.packIEND()),this.emit(`end`)}.bind(this)),this._deflate.end(a)}})),pc=S(((e,t)=>{let n=C(`assert`).ok,r=C(`zlib`),i=C(`util`),a=C(`buffer`).kMaxLength;function o(e){if(!(this instanceof o))return new o(e);e&&e.chunkSize<r.Z_MIN_CHUNK&&(e.chunkSize=r.Z_MIN_CHUNK),r.Inflate.call(this,e),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&e.maxLength!=null&&(this._maxLength=e.maxLength)}function s(e){return new o(e)}function c(e,t){t&&process.nextTick(t),e._handle&&=(e._handle.close(),null)}o.prototype._processChunk=function(e,t,i){if(typeof i==`function`)return r.Inflate._processChunk.call(this,e,t,i);let o=this,s=e&&e.length,l=this._chunkSize-this._offset,u=this._maxLength,d=0,f=[],p=0,m;this.on(`error`,function(e){m=e});function h(e,t){if(o._hadError)return;let r=l-t;if(n(r>=0,`have should not go down`),r>0){let e=o._buffer.slice(o._offset,o._offset+r);if(o._offset+=r,e.length>u&&(e=e.slice(0,u)),f.push(e),p+=e.length,u-=e.length,u===0)return!1}return(t===0||o._offset>=o._chunkSize)&&(l=o._chunkSize,o._offset=0,o._buffer=Buffer.allocUnsafe(o._chunkSize)),t===0&&(d+=s-e,s=e,!0)}n(this._handle,`zlib binding closed`);let g;do g=this._handle.writeSync(t,e,d,s,this._buffer,this._offset,l),g||=this._writeState;while(!this._hadError&&h(g[0],g[1]));if(this._hadError)throw m;if(p>=a)throw c(this),RangeError(`Cannot create final Buffer. It would be larger than 0x`+a.toString(16)+` bytes`);let _=Buffer.concat(f,p);return c(this),_},i.inherits(o,r.Inflate);function l(e,t){if(typeof t==`string`&&(t=Buffer.from(t)),!(t instanceof Buffer))throw TypeError(`Not a string or buffer`);let n=e._finishFlushFlag;return n??=r.Z_FINISH,e._processChunk(t,n)}function u(e,t){return l(new o(t),e)}t.exports=e=u,e.Inflate=o,e.createInflate=s,e.inflateSync=u})),mc=S(((e,t)=>{let n=t.exports=function(e){this._buffer=e,this._reads=[]};n.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})},n.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}if(this._reads.length>0)throw Error(`There are some read requests waitng on finished stream`);if(this._buffer.length>0)throw Error(`unrecognised content at end of stream`)}})),hc=S((e=>{let t=mc(),n=tc();e.process=function(e,r){let i=[],a=new t(e);return new n(r,{read:a.read.bind(a),write:function(e){i.push(e)},complete:function(){}}).start(),a.process(),Buffer.concat(i)}})),gc=S(((e,t)=>{let n=!0,r=C(`zlib`),i=pc();r.deflateSync||(n=!1);let a=mc(),o=hc(),s=ac(),c=oc(),l=sc();t.exports=function(e,t){if(!n)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let u;function d(e){u=e}let f;function p(e){f=e}function m(e){f.transColor=e}function h(e){f.palette=e}function g(){f.alpha=!0}let _;function v(e){_=e}let ee=[];function y(e){ee.push(e)}let b=new a(e);if(new s(t,{read:b.read.bind(b),error:d,metadata:p,gamma:v,palette:h,transColor:m,inflateData:y,simpleTransparency:g}).start(),b.process(),u)throw u;let te=Buffer.concat(ee);ee.length=0;let ne;if(f.interlace)ne=r.inflateSync(te);else{let e=((f.width*f.bpp*f.depth+7>>3)+1)*f.height;ne=i(te,{chunkSize:e,maxLength:e})}if(te=null,!ne||!ne.length)throw Error(`bad png - invalid inflate data response`);let re=o.process(ne,f);te=null;let ie=c.dataToBitMap(re,f);re=null;let ae=l(ie,f,t.skipRescale);return f.data=ae,f.gamma=_||0,f}})),_c=S(((e,t)=>{let n=!0,r=C(`zlib`);r.deflateSync||(n=!1);let i=rc(),a=dc();t.exports=function(e,t){if(!n)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let o=new a(t||{}),s=[];s.push(Buffer.from(i.PNG_SIGNATURE)),s.push(o.packIHDR(e.width,e.height)),e.gamma&&s.push(o.packGAMA(e.gamma));let c=o.filterData(e.data,e.width,e.height),l=r.deflateSync(c,o.getDeflateOptions());if(c=null,!l||!l.length)throw Error(`bad png - invalid compressed data response`);return s.push(o.packIDAT(l)),s.push(o.packIEND()),Buffer.concat(s)}})),vc=S((e=>{let t=gc(),n=_c();e.read=function(e,n){return t(e,n||{})},e.write=function(e,t){return n(e,t)}})),yc=S((e=>{let t=C(`util`),n=C(`stream`),r=cc(),i=fc(),a=vc(),o=e.PNG=function(e){n.call(this),e||={},this.width=e.width|0,this.height=e.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new r(e),this._parser.on(`error`,this.emit.bind(this,`error`)),this._parser.on(`close`,this._handleClose.bind(this)),this._parser.on(`metadata`,this._metadata.bind(this)),this._parser.on(`gamma`,this._gamma.bind(this)),this._parser.on(`parsed`,function(e){this.data=e,this.emit(`parsed`,e)}.bind(this)),this._packer=new i(e),this._packer.on(`data`,this.emit.bind(this,`data`)),this._packer.on(`end`,this.emit.bind(this,`end`)),this._parser.on(`close`,this._handleClose.bind(this)),this._packer.on(`error`,this.emit.bind(this,`error`))};t.inherits(o,n),o.sync=a,o.prototype.pack=function(){return!this.data||!this.data.length?(this.emit(`error`,`No data provided`),this):(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this)},o.prototype.parse=function(e,t){if(t){let e,n;e=function(e){this.removeListener(`error`,n),this.data=e,t(null,this)}.bind(this),n=function(n){this.removeListener(`parsed`,e),t(n,null)}.bind(this),this.once(`parsed`,e),this.once(`error`,n)}return this.end(e),this},o.prototype.write=function(e){return this._parser.write(e),!0},o.prototype.end=function(e){this._parser.end(e)},o.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit(`metadata`,e)},o.prototype._gamma=function(e){this.gamma=e},o.prototype._handleClose=function(){!this._parser.writable&&!this._packer.readable&&this.emit(`close`)},o.bitblt=function(e,t,n,r,i,a,o,s){if(n|=0,r|=0,i|=0,a|=0,o|=0,s|=0,n>e.width||r>e.height||n+i>e.width||r+a>e.height)throw Error(`bitblt reading outside image`);if(o>t.width||s>t.height||o+i>t.width||s+a>t.height)throw Error(`bitblt writing outside image`);for(let c=0;c<a;c++)e.data.copy(t.data,(s+c)*t.width+o<<2,(r+c)*e.width+n<<2,(r+c)*e.width+n+i<<2)},o.prototype.bitblt=function(e,t,n,r,i,a,s){return o.bitblt(this,e,t,n,r,i,a,s),this},o.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++){let r=e.width*t+n<<2;for(let t=0;t<3;t++){let n=e.data[r+t]/255;n**=1/2.2/e.gamma,e.data[r+t]=Math.round(n*255)}}e.gamma=0}},o.prototype.adjustGamma=function(){o.adjustGamma(this)}}))(),bc=class{session;namespace;initScriptPath;timezone;locale;deviceScaleFactor;allowedDomains;timeoutMs;bin;constructor(e){this.session=e.session,this.namespace=e.namespace,this.initScriptPath=e.initScriptPath,this.timezone=e.timezone,this.locale=e.locale,this.deviceScaleFactor=e.deviceScaleFactor,this.allowedDomains=e.allowedDomains,this.timeoutMs=e.timeoutMs??3e4,this.bin=wc()}open(e){return this.execVoid([`open`,e])}setViewport(e){return this.execVoid([`set`,`viewport`,String(e.width),String(e.height)])}setMedia(e,t){let n=[`set`,`media`,e];return t&&n.push(`reduced-motion`),this.execVoid(n)}async evaluate(e){let t=await this.exec([`eval`,e]),n=JSON.parse(t);if(n.success===!1)throw Error(n.error??`agent-browser eval failed`);return n.data&&typeof n.data==`object`&&`result`in n.data?n.data.result:n.data===void 0?n.result===void 0?n:n.result:n.data}screenshot(e,t){return this.execVoid([`screenshot`,...t.fullPage?[`--full`]:[],e])}close(){return this.execVoid([`close`])}async execVoid(e){let t=await this.exec(e);try{let n=JSON.parse(t);if(n.success===!1)throw Error(n.error??`agent-browser command failed: ${e.join(` `)}`)}catch(e){if(e instanceof SyntaxError)return;throw e}}exec(e){let t=[`--session`,this.session,`--namespace`,this.namespace,`--init-script`,this.initScriptPath,`--allowed-domains`,this.allowedDomains.join(`,`),`--args`,`--force-device-scale-factor=${this.deviceScaleFactor},--lang=${this.locale}`,`--json`,...e];return new Promise((n,i)=>{let a=r(this.bin,t,{env:{...process.env,LANG:`${this.locale}.UTF-8`,TZ:this.timezone},stdio:[`ignore`,`pipe`,`pipe`]}),o=[],s=[];a.stdout.on(`data`,e=>o.push(e)),a.stderr.on(`data`,e=>s.push(e));let c=setTimeout(()=>{a.kill(),i(Error(`agent-browser timed out after ${this.timeoutMs}ms: ${e.join(` `)}`))},this.timeoutMs);a.once(`error`,e=>{clearTimeout(c),i(e)}),a.once(`close`,e=>{clearTimeout(c);let t=Buffer.concat(o).toString(`utf8`).trim(),r=Buffer.concat(s).toString(`utf8`).trim();if(e!==0){i(Error(`agent-browser failed (${e}): ${r||t}`));return}n(t)})})}};async function xc(){let e=wc(),[t,n]=await Promise.all([Cc(e,[`--version`]),Cc(e,[`doctor`,`--json`])]);return Sc(t,n)}function Sc(e,t){let n;try{n=JSON.parse(t)}catch(e){throw Error(`agent-browser doctor did not return valid JSON`,{cause:e})}let r=(n.checks?.find(e=>e.id===`chrome.installed`&&e.status===`pass`)?.message)?.split(` at `)[0];if(!r?.match(/^Google Chrome for Testing \d+\.\d+\.\d+\.\d+$/))throw Error(`Kapture requires an exact installed Google Chrome for Testing version`);return`${e}; ${r}`}function Cc(e,t){return new Promise((n,i)=>{let a=r(e,t,{stdio:[`ignore`,`pipe`,`pipe`]}),o=[];a.stdout.on(`data`,e=>o.push(e)),a.once(`error`,i),a.once(`close`,e=>{if(e!==0)return i(Error(`agent-browser ${t.join(` `)} failed (${e})`));n(Buffer.concat(o).toString(`utf8`).trim())})})}function wc(){try{let t=e(import.meta.url),n=t.resolve(`agent-browser/package.json`),r=a(n),i=t(n),o=typeof i.bin==`string`?i.bin:i.bin?.[`agent-browser`]??`bin/agent-browser.js`;return u(r,o)}catch{return`agent-browser`}}async function Tc(e,t){await e.setMedia(t.colorScheme,t.reducedMotion===`reduce`);let n=JSON.stringify({id:t.id,browserMajor:t.browserVersion.match(/Chrome(?: for Testing)? (\d+)/)?.[1],locale:t.locale,timezone:t.timezone,deviceScaleFactor:t.deviceScaleFactor,colorScheme:t.colorScheme,reducedMotion:t.reducedMotion,frozenTimestamp:Date.parse(t.frozenTime)});return e.evaluate(`(async () => {
|
|
44
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Ia(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Ra(t,`input`,e.processors),output:Ra(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function F(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return F(r.element,n);if(r.type===`set`)return F(r.valueType,n);if(r.type===`lazy`)return F(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return F(r.innerType,n);if(r.type===`intersection`)return F(r.left,n)||F(r.right,n);if(r.type===`record`||r.type===`map`)return F(r.keyType,n)||F(r.valueType,n);if(r.type===`pipe`)return F(r.in,n)||F(r.out,n);if(r.type===`object`){for(let e in r.shape)if(F(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(F(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(F(e,n))return!0;return!!(r.rest&&F(r.rest,n))}return!1}const La=(e,t={})=>n=>{let r=Pa({...n,processors:t});return P(e,r),Fa(r,e),Ia(r,e)},Ra=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Pa({...i??{},target:a,io:t,processors:n});return P(e,o),Fa(o,e),Ia(o,e)},za={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ba=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=za[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Va=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},Ha=(e,t,n,r)=>{n.not={}},Ua=(e,t,n,r)=>{let i=e._zod.def,a=Ot(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Wa=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},Ga=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ka=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},qa=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=P(a.element,t,{...r,path:[...r.path,`items`]})},Ja=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=P(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=P(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ya=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>P(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Xa=(e,t,n,r)=>{let i=e._zod.def,a=P(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=P(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Za=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=P(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=P(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=P(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Qa=(e,t,n,r)=>{let i=e._zod.def,a=P(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},$a=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},eo=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},to=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},no=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},ro=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;P(a,t,r);let o=t.seen.get(e);o.ref=a},io=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},ao=(e,t,n,r)=>{let i=e._zod.def;P(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},oo=O(`ZodISODateTime`,(e,t)=>{Mr.init(e,t),z.init(e,t)});function so(e){return na(oo,e)}const co=O(`ZodISODate`,(e,t)=>{Nr.init(e,t),z.init(e,t)});function lo(e){return ra(co,e)}const uo=O(`ZodISOTime`,(e,t)=>{Pr.init(e,t),z.init(e,t)});function fo(e){return ia(uo,e)}const po=O(`ZodISODuration`,(e,t)=>{Fr.init(e,t),z.init(e,t)});function mo(e){return aa(po,e)}const ho=(e,t)=>{un.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>pn(e,t)},flatten:{value:t=>fn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,kt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,kt,2)}},isEmpty:{get(){return e.issues.length===0}}})};O(`ZodError`,ho);const I=O(`ZodError`,ho,{Parent:Error}),go=mn(I),_o=hn(I),vo=gn(I),yo=vn(I),bo=bn(I),xo=xn(I),So=Sn(I),Co=Cn(I),wo=wn(I),To=Tn(I),Eo=En(I),Do=Dn(I),L=O(`ZodType`,(e,t)=>(M.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Ra(e,`input`),output:Ra(e,`output`)}}),e.toJSONSchema=La(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(It(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>Kt(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>go(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>vo(e,t,n),e.parseAsync=async(t,n)=>_o(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>yo(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>bo(e,t,n),e.decode=(t,n)=>xo(e,t,n),e.encodeAsync=async(t,n)=>So(e,t,n),e.decodeAsync=async(t,n)=>Co(e,t,n),e.safeEncode=(t,n)=>wo(e,t,n),e.safeDecode=(t,n)=>To(e,t,n),e.safeEncodeAsync=async(t,n)=>Eo(e,t,n),e.safeDecodeAsync=async(t,n)=>Do(e,t,n),e.refine=(t,n)=>e.check(Ls(t,n)),e.superRefine=t=>e.check(Rs(t)),e.overwrite=t=>e.check(wa(t)),e.optional=()=>ys(e),e.exactOptional=()=>xs(e),e.nullable=()=>Cs(e),e.nullish=()=>ys(Cs(e)),e.nonoptional=t=>ks(e,t),e.array=()=>rs(e),e.or=t=>ss([e,t]),e.and=t=>ls(e,t),e.transform=t=>Ns(e,_s(t)),e.default=t=>Ts(e,t),e.prefault=t=>Ds(e,t),e.catch=t=>js(e,t),e.pipe=t=>Ns(e,t),e.readonly=()=>Fs(e),e.describe=t=>{let n=e.clone();return Mi.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return Mi.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return Mi.get(e);let n=e.clone();return Mi.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),Oo=O(`_ZodString`,(e,t)=>{br.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ba(e,t,n,r);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(va(...t)),e.includes=(...t)=>e.check(xa(...t)),e.startsWith=(...t)=>e.check(Sa(...t)),e.endsWith=(...t)=>e.check(Ca(...t)),e.min=(...t)=>e.check(ga(...t)),e.max=(...t)=>e.check(ha(...t)),e.length=(...t)=>e.check(_a(...t)),e.nonempty=(...t)=>e.check(ga(1,...t)),e.lowercase=t=>e.check(ya(t)),e.uppercase=t=>e.check(ba(t)),e.trim=()=>e.check(Ea()),e.normalize=(...t)=>e.check(Ta(...t)),e.toLowerCase=()=>e.check(Da()),e.toUpperCase=()=>e.check(Oa()),e.slugify=()=>e.check(ka())}),ko=O(`ZodString`,(e,t)=>{br.init(e,t),Oo.init(e,t),e.email=t=>e.check(Pi(Ao,t)),e.url=t=>e.check(Bi(No,t)),e.jwt=t=>e.check(ta(Jo,t)),e.emoji=t=>e.check(Vi(Po,t)),e.guid=t=>e.check(Fi(jo,t)),e.uuid=t=>e.check(Ii(Mo,t)),e.uuidv4=t=>e.check(Li(Mo,t)),e.uuidv6=t=>e.check(Ri(Mo,t)),e.uuidv7=t=>e.check(zi(Mo,t)),e.nanoid=t=>e.check(Hi(Fo,t)),e.guid=t=>e.check(Fi(jo,t)),e.cuid=t=>e.check(Ui(Io,t)),e.cuid2=t=>e.check(Wi(Lo,t)),e.ulid=t=>e.check(Gi(Ro,t)),e.base64=t=>e.check(Qi(Go,t)),e.base64url=t=>e.check($i(Ko,t)),e.xid=t=>e.check(Ki(zo,t)),e.ksuid=t=>e.check(qi(Bo,t)),e.ipv4=t=>e.check(Ji(Vo,t)),e.ipv6=t=>e.check(Yi(Ho,t)),e.cidrv4=t=>e.check(Xi(Uo,t)),e.cidrv6=t=>e.check(Zi(Wo,t)),e.e164=t=>e.check(ea(qo,t)),e.datetime=t=>e.check(so(t)),e.date=t=>e.check(lo(t)),e.time=t=>e.check(fo(t)),e.duration=t=>e.check(mo(t))});function R(e){return Ni(ko,e)}const z=O(`ZodStringFormat`,(e,t)=>{N.init(e,t),Oo.init(e,t)}),Ao=O(`ZodEmail`,(e,t)=>{Cr.init(e,t),z.init(e,t)}),jo=O(`ZodGUID`,(e,t)=>{xr.init(e,t),z.init(e,t)}),Mo=O(`ZodUUID`,(e,t)=>{Sr.init(e,t),z.init(e,t)}),No=O(`ZodURL`,(e,t)=>{wr.init(e,t),z.init(e,t)}),Po=O(`ZodEmoji`,(e,t)=>{Tr.init(e,t),z.init(e,t)}),Fo=O(`ZodNanoID`,(e,t)=>{Er.init(e,t),z.init(e,t)}),Io=O(`ZodCUID`,(e,t)=>{Dr.init(e,t),z.init(e,t)}),Lo=O(`ZodCUID2`,(e,t)=>{Or.init(e,t),z.init(e,t)}),Ro=O(`ZodULID`,(e,t)=>{kr.init(e,t),z.init(e,t)}),zo=O(`ZodXID`,(e,t)=>{Ar.init(e,t),z.init(e,t)}),Bo=O(`ZodKSUID`,(e,t)=>{jr.init(e,t),z.init(e,t)}),Vo=O(`ZodIPv4`,(e,t)=>{Ir.init(e,t),z.init(e,t)}),Ho=O(`ZodIPv6`,(e,t)=>{Lr.init(e,t),z.init(e,t)}),Uo=O(`ZodCIDRv4`,(e,t)=>{Rr.init(e,t),z.init(e,t)}),Wo=O(`ZodCIDRv6`,(e,t)=>{zr.init(e,t),z.init(e,t)}),Go=O(`ZodBase64`,(e,t)=>{Vr.init(e,t),z.init(e,t)}),Ko=O(`ZodBase64URL`,(e,t)=>{Ur.init(e,t),z.init(e,t)}),qo=O(`ZodE164`,(e,t)=>{Wr.init(e,t),z.init(e,t)}),Jo=O(`ZodJWT`,(e,t)=>{Kr.init(e,t),z.init(e,t)}),Yo=O(`ZodNumber`,(e,t)=>{qr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Va(e,t,n,r),e.gt=(t,n)=>e.check(fa(t,n)),e.gte=(t,n)=>e.check(pa(t,n)),e.min=(t,n)=>e.check(pa(t,n)),e.lt=(t,n)=>e.check(ua(t,n)),e.lte=(t,n)=>e.check(da(t,n)),e.max=(t,n)=>e.check(da(t,n)),e.int=t=>e.check(Zo(t)),e.safe=t=>e.check(Zo(t)),e.positive=t=>e.check(fa(0,t)),e.nonnegative=t=>e.check(pa(0,t)),e.negative=t=>e.check(ua(0,t)),e.nonpositive=t=>e.check(da(0,t)),e.multipleOf=(t,n)=>e.check(ma(t,n)),e.step=(t,n)=>e.check(ma(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 B(e){return oa(Yo,e)}const Xo=O(`ZodNumberFormat`,(e,t)=>{Jr.init(e,t),Yo.init(e,t)});function Zo(e){return sa(Xo,e)}const Qo=O(`ZodUnknown`,(e,t)=>{Yr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function $o(){return ca(Qo)}const es=O(`ZodNever`,(e,t)=>{Xr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ha(e,t,n,r)});function ts(e){return la(es,e)}const ns=O(`ZodArray`,(e,t)=>{Qr.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qa(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(ga(t,n)),e.nonempty=t=>e.check(ga(1,t)),e.max=(t,n)=>e.check(ha(t,n)),e.length=(t,n)=>e.check(_a(t,n)),e.unwrap=()=>e.element});function rs(e,t){return Aa(ns,e,t)}const is=O(`ZodObject`,(e,t)=>{ri.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ja(e,t,n,r),k(e,`shape`,()=>t.shape),e.keyof=()=>ps(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:$o()}),e.loose=()=>e.clone({...e._zod.def,catchall:$o()}),e.strict=()=>e.clone({...e._zod.def,catchall:ts()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Zt(e,t),e.safeExtend=t=>Qt(e,t),e.merge=t=>$t(e,t),e.pick=t=>Yt(e,t),e.omit=t=>Xt(e,t),e.partial=(...t)=>en(vs,e,t[0]),e.required=(...t)=>tn(Os,e,t[0])});function V(e,t){let n={type:`object`,shape:e??{},...A(t)};return new is(n)}function as(e,t){return new is({type:`object`,shape:e,catchall:ts(),...A(t)})}const os=O(`ZodUnion`,(e,t)=>{ai.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ya(e,t,n,r),e.options=t.options});function ss(e,t){return new os({type:`union`,options:e,...A(t)})}const cs=O(`ZodIntersection`,(e,t)=>{oi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xa(e,t,n,r)});function ls(e,t){return new cs({type:`intersection`,left:e,right:t})}const us=O(`ZodRecord`,(e,t)=>{li.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Za(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ds(e,t,n){return new us({type:`record`,keyType:e,valueType:t,...A(n)})}const fs=O(`ZodEnum`,(e,t)=>{ui.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ua(e,t,n,r),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 fs({...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 fs({...t,checks:[],...A(r),entries:i})}});function ps(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new fs({type:`enum`,entries:n,...A(t)})}const ms=O(`ZodLiteral`,(e,t)=>{di.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wa(e,t,n,r),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 hs(e,t){return new ms({type:`literal`,values:Array.isArray(e)?e:[e],...A(t)})}const gs=O(`ZodTransform`,(e,t)=>{fi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ka(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Tt(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(cn(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(cn(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function _s(e){return new gs({type:`transform`,transform:e})}const vs=O(`ZodOptional`,(e,t)=>{mi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ys(e){return new vs({type:`optional`,innerType:e})}const bs=O(`ZodExactOptional`,(e,t)=>{hi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ao(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xs(e){return new bs({type:`optional`,innerType:e})}const Ss=O(`ZodNullable`,(e,t)=>{gi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Cs(e){return new Ss({type:`nullable`,innerType:e})}const ws=O(`ZodDefault`,(e,t)=>{_i.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ts(e,t){return new ws({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ut(t)}})}const Es=O(`ZodPrefault`,(e,t)=>{yi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ds(e,t){return new Es({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ut(t)}})}const Os=O(`ZodNonOptional`,(e,t)=>{bi.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$a(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ks(e,t){return new Os({type:`nonoptional`,innerType:e,...A(t)})}const As=O(`ZodCatch`,(e,t)=>{Si.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>no(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function js(e,t){return new As({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Ms=O(`ZodPipe`,(e,t)=>{Ci.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ro(e,t,n,r),e.in=t.in,e.out=t.out});function Ns(e,t){return new Ms({type:`pipe`,in:e,out:t})}const Ps=O(`ZodReadonly`,(e,t)=>{Ti.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>io(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Fs(e){return new Ps({type:`readonly`,innerType:e})}const Is=O(`ZodCustom`,(e,t)=>{Di.init(e,t),L.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ga(e,t,n,r)});function Ls(e,t={}){return ja(Is,e,t)}function Rs(e){return Ma(e)}var zs=Ct(),Bs=class{session;namespace;initScriptPath;timezone;locale;deviceScaleFactor;allowedDomains;timeoutMs;bin;constructor(e){this.session=e.session,this.namespace=e.namespace,this.initScriptPath=e.initScriptPath,this.timezone=e.timezone,this.locale=e.locale,this.deviceScaleFactor=e.deviceScaleFactor,this.allowedDomains=e.allowedDomains,this.timeoutMs=e.timeoutMs??3e4,this.bin=Ws()}open(e){return this.execVoid([`open`,e])}setViewport(e){return this.execVoid([`set`,`viewport`,String(e.width),String(e.height)])}setMedia(e,t){let n=[`set`,`media`,e];return t&&n.push(`reduced-motion`),this.execVoid(n)}async evaluate(e){let t=await this.exec([`eval`,e]),n=JSON.parse(t);if(n.success===!1)throw Error(n.error??`agent-browser eval failed`);return n.data&&typeof n.data==`object`&&`result`in n.data?n.data.result:n.data===void 0?n.result===void 0?n:n.result:n.data}screenshot(e,t){return this.execVoid([`screenshot`,...t.fullPage?[`--full`]:[],e])}close(){return this.execVoid([`close`])}async execVoid(e){let t=await this.exec(e);try{let n=JSON.parse(t);if(n.success===!1)throw Error(n.error??`agent-browser command failed: ${e.join(` `)}`)}catch(e){if(e instanceof SyntaxError)return;throw e}}exec(e){let t=[`--session`,this.session,`--namespace`,this.namespace,`--init-script`,this.initScriptPath,`--allowed-domains`,this.allowedDomains.join(`,`),`--args`,`--force-device-scale-factor=${this.deviceScaleFactor},--lang=${this.locale}`,`--json`,...e];return new Promise((n,i)=>{let a=r(this.bin,t,{env:{...process.env,LANG:`${this.locale}.UTF-8`,TZ:this.timezone},stdio:[`ignore`,`pipe`,`pipe`]}),o=[],s=[];a.stdout.on(`data`,e=>o.push(e)),a.stderr.on(`data`,e=>s.push(e));let c=setTimeout(()=>{a.kill(),i(Error(`agent-browser timed out after ${this.timeoutMs}ms: ${e.join(` `)}`))},this.timeoutMs);a.once(`error`,e=>{clearTimeout(c),i(e)}),a.once(`close`,e=>{clearTimeout(c);let t=Buffer.concat(o).toString(`utf8`).trim(),r=Buffer.concat(s).toString(`utf8`).trim();if(e!==0){i(Error(`agent-browser failed (${e}): ${r||t}`));return}n(t)})})}};async function Vs(){let e=Ws(),[t,n]=await Promise.all([Us(e,[`--version`]),Us(e,[`doctor`,`--json`])]);return Hs(t,n)}function Hs(e,t){let n;try{n=JSON.parse(t)}catch(e){throw Error(`agent-browser doctor did not return valid JSON`,{cause:e})}let r=(n.checks?.find(e=>e.id===`chrome.installed`&&e.status===`pass`)?.message)?.split(` at `)[0];if(!r?.match(/^Google Chrome for Testing \d+\.\d+\.\d+\.\d+$/))throw Error(`Kapture requires an exact installed Google Chrome for Testing version`);return`${e}; ${r}`}function Us(e,t){return new Promise((n,i)=>{let a=r(e,t,{stdio:[`ignore`,`pipe`,`pipe`]}),o=[];a.stdout.on(`data`,e=>o.push(e)),a.once(`error`,i),a.once(`close`,e=>{if(e!==0)return i(Error(`agent-browser ${t.join(` `)} failed (${e})`));n(Buffer.concat(o).toString(`utf8`).trim())})})}function Ws(){try{let t=e(import.meta.url),n=t.resolve(`agent-browser/package.json`),r=a(n),i=t(n),o=typeof i.bin==`string`?i.bin:i.bin?.[`agent-browser`]??`bin/agent-browser.js`;return d(r,o)}catch{return`agent-browser`}}async function Gs(e,t){await e.setMedia(t.colorScheme,t.reducedMotion===`reduce`);let n=JSON.stringify({id:t.id,browserMajor:t.browserVersion.match(/Chrome(?: for Testing)? (\d+)/)?.[1],locale:t.locale,timezone:t.timezone,deviceScaleFactor:t.deviceScaleFactor,colorScheme:t.colorScheme,reducedMotion:t.reducedMotion,frozenTimestamp:Date.parse(t.frozenTime)});return e.evaluate(`(async () => {
|
|
46
45
|
const expected = ${n};
|
|
47
46
|
const actual = {
|
|
48
47
|
id: window.__KAPTURE_ENVIRONMENT__?.id,
|
|
@@ -70,25 +69,61 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
70
69
|
"; actual=" + JSON.stringify(actual));
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
72
|
+
const selectorList = value => {
|
|
73
|
+
if (typeof value === "string") return value.trim() ? [value] : [];
|
|
74
|
+
if (!Array.isArray(value)) return [];
|
|
75
|
+
return value.filter(selector => typeof selector === "string" && selector.trim());
|
|
76
|
+
};
|
|
77
|
+
const uniqueSelectors = values => [...new Set(values)];
|
|
78
|
+
let completedRenderKey = null;
|
|
79
|
+
let completedSince = 0;
|
|
80
|
+
|
|
81
|
+
const renderHasSettled = render => {
|
|
82
|
+
if (!render) return true;
|
|
83
|
+
if (!render.story || render.notYetRendered) return false;
|
|
84
|
+
if (render.phase === "finished") return true;
|
|
85
|
+
// Storybook versions before the finished/afterEach phase can stop at
|
|
86
|
+
// completed. Requiring it to remain terminal avoids accepting the brief
|
|
87
|
+
// completed phase before modern Storybook starts project/story afterEach.
|
|
88
|
+
if (render.phase === "completed") {
|
|
89
|
+
const key = String(render.renderId ?? "legacy-completed");
|
|
90
|
+
if (completedRenderKey !== key) {
|
|
91
|
+
completedRenderKey = key;
|
|
92
|
+
completedSince = performance.now();
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return performance.now() - completedSince >= 50;
|
|
96
|
+
}
|
|
97
|
+
completedRenderKey = null;
|
|
98
|
+
completedSince = 0;
|
|
99
|
+
return render.phase == null;
|
|
100
|
+
};
|
|
75
101
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
102
|
+
const readStoryMetadata = () => {
|
|
103
|
+
const runtimeValue = window.__KAPTURE_STORY__;
|
|
104
|
+
const runtime = runtimeValue?.ready ? runtimeValue : null;
|
|
79
105
|
const storyId = new URL(location.href).searchParams.get("id");
|
|
80
106
|
const renders = window.__STORYBOOK_PREVIEW__?.storyRenders ?? [];
|
|
81
107
|
const render = renders.find(candidate => candidate.id === storyId) ?? renders[0];
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
108
|
+
if (runtimeValue && !runtime) return null;
|
|
109
|
+
if (!runtime && (!render?.story || render.notYetRendered)) return null;
|
|
110
|
+
if (!renderHasSettled(render)) return null;
|
|
111
|
+
|
|
112
|
+
// Always read Storybook parameters as well as the optional Kapture
|
|
113
|
+
// decorator bridge. This keeps Chromatic compatibility additive even
|
|
114
|
+
// when an older decorator only exposes parameters.kapture.
|
|
115
|
+
const storyParameters = render?.story?.parameters ?? {};
|
|
116
|
+
const configured = {
|
|
117
|
+
...(storyParameters.kapture ?? {}),
|
|
118
|
+
...(runtime?.parameters ?? {}),
|
|
119
|
+
};
|
|
85
120
|
const chromatic = storyParameters.chromatic ?? {};
|
|
86
121
|
const viewportOptions = storyParameters.viewport?.options ?? {};
|
|
87
122
|
const chromaticViewportNames = Object.values(chromatic.modes ?? {})
|
|
88
123
|
.map(mode => mode?.viewport)
|
|
89
124
|
.filter(Boolean);
|
|
90
125
|
const requestedViewports = configured.viewports ?? chromaticViewportNames;
|
|
91
|
-
const viewports = requestedViewports.map(value => {
|
|
126
|
+
const viewports = (Array.isArray(requestedViewports) ? requestedViewports : []).map(value => {
|
|
92
127
|
if (typeof value === "object" && value && Number.isFinite(value.width) && Number.isFinite(value.height)) {
|
|
93
128
|
return value;
|
|
94
129
|
}
|
|
@@ -100,6 +135,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
100
135
|
height: Number.parseInt(option.styles.height, 10),
|
|
101
136
|
};
|
|
102
137
|
});
|
|
138
|
+
const chromaticAnimation = chromatic.pauseAnimationAtEnd === false
|
|
139
|
+
? "start"
|
|
140
|
+
: chromatic.pauseAnimationAtEnd === true
|
|
141
|
+
? "end"
|
|
142
|
+
: undefined;
|
|
103
143
|
return {
|
|
104
144
|
ready: true,
|
|
105
145
|
parameters: {
|
|
@@ -108,7 +148,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
108
148
|
viewports: viewports.length > 0 ? viewports : undefined,
|
|
109
149
|
cropToViewport: configured.cropToViewport ?? chromatic.cropToViewport,
|
|
110
150
|
delayMs: configured.delayMs ?? chromatic.delay,
|
|
111
|
-
animation: configured.animation ??
|
|
151
|
+
animation: configured.animation ?? chromaticAnimation,
|
|
152
|
+
ignoreSelectors: uniqueSelectors([
|
|
153
|
+
'[data-chromatic="ignore"]',
|
|
154
|
+
".chromatic-ignore",
|
|
155
|
+
...selectorList(chromatic.ignoreSelectors),
|
|
156
|
+
...selectorList(configured.ignoreSelectors),
|
|
157
|
+
]),
|
|
112
158
|
diff: {
|
|
113
159
|
pixel: configured.diff?.pixel ?? chromatic.diffThreshold,
|
|
114
160
|
ratio: configured.diff?.ratio,
|
|
@@ -117,72 +163,246 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
117
163
|
};
|
|
118
164
|
};
|
|
119
165
|
|
|
120
|
-
const
|
|
166
|
+
const metadataDeadline = performance.now() + 10000;
|
|
121
167
|
while (!readStoryMetadata()?.ready) {
|
|
122
|
-
if (performance.now() >
|
|
168
|
+
if (performance.now() > metadataDeadline) {
|
|
169
|
+
throw new Error("Kapture Storybook metadata did not become ready or finish lifecycle hooks");
|
|
170
|
+
}
|
|
123
171
|
await new Promise(resolve => setTimeout(resolve, 20));
|
|
124
172
|
}
|
|
125
173
|
|
|
126
174
|
const metadata = readStoryMetadata();
|
|
127
175
|
const parameters = metadata.parameters || {};
|
|
176
|
+
const resolveWaitFor = value => {
|
|
177
|
+
if (!value) return null;
|
|
178
|
+
if (typeof value === "string") {
|
|
179
|
+
if (!value.trim()) throw new Error("Kapture waitFor selector must not be empty");
|
|
180
|
+
return { selector: value, state: "attached", timeoutMs: 10000 };
|
|
181
|
+
}
|
|
182
|
+
if (typeof value !== "object" || typeof value.selector !== "string" || !value.selector.trim()) {
|
|
183
|
+
throw new Error("Kapture waitFor must be a CSS selector or an options object with selector");
|
|
184
|
+
}
|
|
185
|
+
const state = value.state ?? "attached";
|
|
186
|
+
if (!["attached", "visible", "hidden", "detached"].includes(state)) {
|
|
187
|
+
throw new Error("Unknown Kapture waitFor state: " + state);
|
|
188
|
+
}
|
|
189
|
+
const timeoutMs = value.timeoutMs ?? 10000;
|
|
190
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
|
|
191
|
+
throw new Error("Kapture waitFor timeoutMs must be a non-negative number");
|
|
192
|
+
}
|
|
193
|
+
return { selector: value.selector, state, timeoutMs };
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const query = (selector, purpose) => {
|
|
197
|
+
try {
|
|
198
|
+
return document.querySelector(selector);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
throw new Error("Invalid Kapture " + purpose + " selector " + JSON.stringify(selector) + ": " + error.message);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const queryAll = (selector, purpose) => {
|
|
204
|
+
try {
|
|
205
|
+
return Array.from(document.querySelectorAll(selector));
|
|
206
|
+
} catch (error) {
|
|
207
|
+
throw new Error("Invalid Kapture " + purpose + " selector " + JSON.stringify(selector) + ": " + error.message);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const isVisible = element => {
|
|
211
|
+
if (!element) return false;
|
|
212
|
+
const style = getComputedStyle(element);
|
|
213
|
+
const rect = element.getBoundingClientRect();
|
|
214
|
+
return style.display !== "none" && style.visibility !== "hidden" &&
|
|
215
|
+
style.visibility !== "collapse" && rect.width > 0 && rect.height > 0;
|
|
216
|
+
};
|
|
217
|
+
const waitFor = resolveWaitFor(parameters.waitFor);
|
|
218
|
+
if (waitFor) {
|
|
219
|
+
const waitDeadline = performance.now() + waitFor.timeoutMs;
|
|
220
|
+
while (true) {
|
|
221
|
+
const element = query(waitFor.selector, "waitFor");
|
|
222
|
+
const satisfied = waitFor.state === "attached"
|
|
223
|
+
? Boolean(element)
|
|
224
|
+
: waitFor.state === "detached"
|
|
225
|
+
? !element
|
|
226
|
+
: waitFor.state === "visible"
|
|
227
|
+
? isVisible(element)
|
|
228
|
+
: !element || !isVisible(element);
|
|
229
|
+
if (satisfied) break;
|
|
230
|
+
if (performance.now() > waitDeadline) {
|
|
231
|
+
throw new Error("Timed out waiting for " + waitFor.selector + " to be " + waitFor.state +
|
|
232
|
+
" after " + waitFor.timeoutMs + "ms");
|
|
233
|
+
}
|
|
234
|
+
await new Promise(resolve => setTimeout(resolve, 20));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const waitForAssets = async () => {
|
|
239
|
+
await document.fonts.ready;
|
|
240
|
+
await Promise.all(Array.from(document.images).map(image => {
|
|
241
|
+
if (image.complete) return Promise.resolve();
|
|
242
|
+
return new Promise(resolve => {
|
|
243
|
+
image.addEventListener("load", resolve, { once: true });
|
|
244
|
+
image.addEventListener("error", resolve, { once: true });
|
|
245
|
+
});
|
|
246
|
+
}));
|
|
247
|
+
};
|
|
248
|
+
await waitForAssets();
|
|
249
|
+
const delayMs = parameters.delayMs ?? 300;
|
|
250
|
+
if (!Number.isFinite(delayMs) || delayMs < 0) {
|
|
251
|
+
throw new Error("Kapture delayMs must be a non-negative number");
|
|
252
|
+
}
|
|
253
|
+
if (delayMs > 0) await new Promise(resolve => setTimeout(resolve, delayMs));
|
|
254
|
+
// A story may attach images/fonts while waitFor or delay is in progress.
|
|
255
|
+
await waitForAssets();
|
|
256
|
+
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
257
|
+
|
|
128
258
|
const style = document.createElement("style");
|
|
129
259
|
style.dataset.kapture = "hermetic";
|
|
130
260
|
style.textContent = [
|
|
131
261
|
"*,*::before,*::after{caret-color:transparent!important;transition:none!important;}",
|
|
262
|
+
(parameters.animation ?? "end") === "disabled"
|
|
263
|
+
? "*,*::before,*::after{animation:none!important;}"
|
|
264
|
+
: "",
|
|
132
265
|
"*{cursor:none!important;}",
|
|
133
266
|
"::-webkit-scrollbar{display:none!important;}",
|
|
134
|
-
"html{scrollbar-width:none!important;}",
|
|
267
|
+
"html{scrollbar-width:none!important;scroll-behavior:auto!important;}",
|
|
135
268
|
].join("");
|
|
136
269
|
document.head.appendChild(style);
|
|
137
270
|
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
271
|
+
const freezeAnimations = () => {
|
|
272
|
+
const animationMode = parameters.animation ?? "end";
|
|
273
|
+
for (const animation of document.getAnimations()) {
|
|
274
|
+
try {
|
|
275
|
+
if (animationMode === "disabled") {
|
|
276
|
+
animation.cancel();
|
|
277
|
+
} else {
|
|
278
|
+
animation.pause();
|
|
279
|
+
if (animationMode === "start") {
|
|
280
|
+
animation.currentTime = 0;
|
|
281
|
+
} else if (typeof animationMode === "object") {
|
|
282
|
+
animation.currentTime = animationMode.atMs;
|
|
283
|
+
} else {
|
|
284
|
+
const endTime = animation.effect?.getComputedTiming()?.endTime;
|
|
285
|
+
animation.currentTime = Number.isFinite(endTime) ? endTime : 0;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
} catch {
|
|
289
|
+
try { animation.pause(); } catch {}
|
|
151
290
|
}
|
|
152
|
-
} catch {
|
|
153
|
-
animation.pause();
|
|
154
291
|
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
292
|
+
};
|
|
293
|
+
const applyMasks = () => {
|
|
294
|
+
for (const selector of selectorList(parameters.mask)) {
|
|
295
|
+
for (const element of queryAll(selector, "mask")) {
|
|
296
|
+
element.style.setProperty("visibility", "hidden", "important");
|
|
297
|
+
}
|
|
160
298
|
}
|
|
161
|
-
}
|
|
299
|
+
};
|
|
162
300
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
301
|
+
// Finalize only after every readiness wait. Repeating after two frames
|
|
302
|
+
// catches animations and masked nodes created by late layout effects.
|
|
303
|
+
freezeAnimations();
|
|
304
|
+
applyMasks();
|
|
305
|
+
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
306
|
+
freezeAnimations();
|
|
307
|
+
applyMasks();
|
|
308
|
+
|
|
309
|
+
const requiredFonts = Array.isArray(parameters.requiredFonts) ? parameters.requiredFonts : [];
|
|
310
|
+
if (requiredFonts.length > 0) {
|
|
311
|
+
const canvas = document.createElement("canvas");
|
|
312
|
+
canvas.width = 192;
|
|
313
|
+
canvas.height = 96;
|
|
314
|
+
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
315
|
+
if (!context) throw new Error("Kapture could not create a canvas for requiredFonts diagnostics");
|
|
316
|
+
const genericFamilies = new Set([
|
|
317
|
+
"serif", "sans-serif", "monospace", "cursive", "fantasy", "system-ui",
|
|
318
|
+
]);
|
|
319
|
+
const renderFingerprint = (text, prefix, family) => {
|
|
320
|
+
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
321
|
+
context.fillStyle = "#000";
|
|
322
|
+
context.textBaseline = "alphabetic";
|
|
323
|
+
context.font = prefix + family;
|
|
324
|
+
context.fillText(text, 8, 72);
|
|
325
|
+
const pixels = context.getImageData(0, 0, canvas.width, canvas.height).data;
|
|
326
|
+
let fingerprint = "";
|
|
327
|
+
for (let index = 3; index < pixels.length; index += 4) {
|
|
328
|
+
if (pixels[index] !== 0) fingerprint += index + ":" + pixels[index] + ";";
|
|
329
|
+
}
|
|
330
|
+
return fingerprint;
|
|
331
|
+
};
|
|
332
|
+
const missing = [];
|
|
333
|
+
for (const value of requiredFonts) {
|
|
334
|
+
const requirement = typeof value === "string"
|
|
335
|
+
? { family: value, text: "BESbswy 0123456789" }
|
|
336
|
+
: value;
|
|
337
|
+
if (!requirement || typeof requirement.text !== "string" || !requirement.text.trim()) {
|
|
338
|
+
throw new Error("Kapture requiredFonts entries need non-empty text");
|
|
339
|
+
}
|
|
340
|
+
const inheritedFamily = getComputedStyle(document.body).fontFamily || "sans-serif";
|
|
341
|
+
const family = typeof requirement.family === "string" && requirement.family.trim()
|
|
342
|
+
? requirement.family.trim()
|
|
343
|
+
: inheritedFamily;
|
|
344
|
+
const text = requirement.text;
|
|
345
|
+
const prefix = (requirement.style ?? "normal") + " " + (requirement.weight ?? "400") + " 64px ";
|
|
346
|
+
try { await document.fonts.load(prefix + family, text); } catch {}
|
|
347
|
+
|
|
348
|
+
let familyAvailable = true;
|
|
349
|
+
if (requirement.family && !genericFamilies.has(family.toLowerCase())) {
|
|
350
|
+
const withMonospace = renderFingerprint(text, prefix, family + ", monospace");
|
|
351
|
+
const withSerif = renderFingerprint(text, prefix, family + ", serif");
|
|
352
|
+
familyAvailable = withMonospace !== renderFingerprint(text, prefix, "monospace") ||
|
|
353
|
+
withSerif !== renderFingerprint(text, prefix, "serif");
|
|
354
|
+
}
|
|
355
|
+
const segmenter = typeof Intl.Segmenter === "function"
|
|
356
|
+
? new Intl.Segmenter(undefined, { granularity: "grapheme" })
|
|
357
|
+
: null;
|
|
358
|
+
const glyphs = segmenter
|
|
359
|
+
? Array.from(segmenter.segment(text), part => part.segment)
|
|
360
|
+
: Array.from(text);
|
|
361
|
+
const missingGlyphs = glyphs.filter(glyph => {
|
|
362
|
+
if (!glyph.trim()) return false;
|
|
363
|
+
const actualGlyph = renderFingerprint(glyph, prefix, family);
|
|
364
|
+
const missingGlyph = renderFingerprint("\u0378", prefix, family);
|
|
365
|
+
return !actualGlyph || actualGlyph === missingGlyph;
|
|
366
|
+
});
|
|
367
|
+
if (!familyAvailable || !document.fonts.check(prefix + family, text) || missingGlyphs.length > 0) {
|
|
368
|
+
missing.push((requirement.family ? family : "document font fallback") +
|
|
369
|
+
" for " + JSON.stringify(missingGlyphs.join("") || text));
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
if (missing.length > 0) {
|
|
373
|
+
throw new Error("Kapture required fonts are unavailable or missing requested glyphs: " + missing.join(", "));
|
|
167
374
|
}
|
|
168
375
|
}
|
|
169
376
|
|
|
170
|
-
|
|
171
|
-
await Promise.all(Array.from(document.images).map(image => {
|
|
172
|
-
if (image.complete) return Promise.resolve();
|
|
173
|
-
return new Promise(resolve => {
|
|
174
|
-
image.addEventListener("load", resolve, { once: true });
|
|
175
|
-
image.addEventListener("error", resolve, { once: true });
|
|
176
|
-
});
|
|
177
|
-
}));
|
|
377
|
+
window.scrollTo({ top: 0, left: 0, behavior: "instant" });
|
|
178
378
|
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
379
|
+
if (window.scrollX !== 0 || window.scrollY !== 0) {
|
|
380
|
+
throw new Error("Kapture could not reset the document scroll position before capture");
|
|
381
|
+
}
|
|
382
|
+
freezeAnimations();
|
|
383
|
+
applyMasks();
|
|
384
|
+
const ignoredRegions = [];
|
|
385
|
+
const seenRegions = new Set();
|
|
386
|
+
for (const selector of selectorList(parameters.ignoreSelectors)) {
|
|
387
|
+
for (const element of queryAll(selector, "ignore")) {
|
|
388
|
+
const rect = element.getBoundingClientRect();
|
|
389
|
+
const left = Math.max(0, Math.floor((rect.left + window.scrollX) * window.devicePixelRatio));
|
|
390
|
+
const top = Math.max(0, Math.floor((rect.top + window.scrollY) * window.devicePixelRatio));
|
|
391
|
+
const right = Math.max(0, Math.ceil((rect.right + window.scrollX) * window.devicePixelRatio));
|
|
392
|
+
const bottom = Math.max(0, Math.ceil((rect.bottom + window.scrollY) * window.devicePixelRatio));
|
|
393
|
+
if (right <= left || bottom <= top) continue;
|
|
394
|
+
const region = { x: left, y: top, width: right - left, height: bottom - top };
|
|
395
|
+
const key = [region.x, region.y, region.width, region.height].join(":");
|
|
396
|
+
if (!seenRegions.has(key)) {
|
|
397
|
+
seenRegions.add(key);
|
|
398
|
+
ignoredRegions.push(region);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return { ...metadata, ignoredRegions };
|
|
403
|
+
})()`)}const Ks={name:`default`,width:1280,height:800},qs={pixel:.2,ratio:0};async function Js(e,t,n,r,i){let[o,s]=await Promise.all([y(e),y(t)]),c=zs.PNG.sync.read(o),l=zs.PNG.sync.read(s),u=Math.max(c.width,l.width),d=Math.max(c.height,l.height),f=Xs(c,u,d),p=Xs(l,u,d),m=Ys(f,p,i?.base??[],i?.head??[]),h=new zs.PNG({width:u,height:d}),g=Ye(f.data,p.data,h.data,u,d,{threshold:r,includeAA:!1}),v=u*d-m;return await _(a(n),{recursive:!0}),await x(n,zs.PNG.sync.write(h)),{changedPixels:g,totalPixels:v,diffRatio:v===0?0:g/v}}function Ys(e,t,n,r){if(n.length===0||r.length===0)return 0;let{width:i,height:a}=e,o=new Uint8Array(i*a);for(let e of n)for(let t of r){let n=Math.max(0,e.x,t.x),r=Math.max(0,e.y,t.y),s=Math.min(i,e.x+e.width,t.x+t.width),c=Math.min(a,e.y+e.height,t.y+t.height);if(!(s<=n||c<=r))for(let e=r;e<c;e+=1)o.fill(1,e*i+n,e*i+s)}let s=0;for(let n=0;n<o.length;n+=1){if(o[n]===0)continue;s+=1;let r=n*4;e.data.fill(0,r,r+4),t.data.fill(0,r,r+4)}return s}function Xs(e,t,n){if(e.width===t&&e.height===n)return e;let r=new zs.PNG({width:t,height:n}),i=e.width*4;for(let n=0;n<e.height;n+=1){let a=n*i;r.data.set(e.data.subarray(a,a+i),n*t*4)}return r}function Zs(e){return ie(`sha256`).update(JSON.stringify(e)).digest(`hex`).slice(0,16)}function Qs(e){let t=[...e.allowedDomains??[`127.0.0.1`,`localhost`]].sort(),n=process.versions.bun,r={browser:`chromium`,browserVersion:e.browserVersion,orchestratorRuntime:e.orchestratorRuntime??(n?`bun ${n}`:`node ${process.version}`),operatingSystem:`${se()}-${ce()}`,architecture:oe(),deviceScaleFactor:e.deviceScaleFactor??1,locale:e.locale??`ko-KR`,timezone:e.timezone??`Asia/Seoul`,colorScheme:e.colorScheme??`light`,reducedMotion:e.reducedMotion??`reduce`,frozenTime:e.frozenTime??`2026-01-01T00:00:00.000Z`,randomSeed:e.randomSeed??20260101,fontsFingerprint:e.fontsFingerprint??`storybook-bundled-fonts-v1`,network:{mode:`allowlist`,allowedDomains:t,webRtc:`disabled`}};return{id:Zs(r),...r}}function $s(e,t){if(e.id!==t.id||JSON.stringify(e)!==JSON.stringify(t))throw Error(`Kapture environment mismatch: base=${e.id}, head=${t.id}. Base and head must be captured with the exact same environment contract.`)}async function ec(){try{let e=(await tc()).split(`
|
|
184
404
|
`).filter(Boolean).sort().join(`
|
|
185
|
-
`);return`fontconfig:${
|
|
405
|
+
`);return`fontconfig:${ie(`sha256`).update(e).digest(`hex`)}`}catch{return`fontconfig-unavailable:${se()}-${ce()}`}}function tc(){return new Promise((e,t)=>{let n=r(`fc-list`,[`--format`,`%{file}|%{family}|%{style}\\n`],{stdio:[`ignore`,`pipe`,`ignore`]}),i=[];n.stdout.on(`data`,e=>i.push(e)),n.once(`error`,t),n.once(`close`,n=>{if(n!==0)return t(Error(`fc-list failed (${n})`));e(Buffer.concat(i).toString(`utf8`))})})}function nc(e){let t=Date.parse(e.frozenTime);if(!Number.isFinite(t))throw Error(`Invalid frozenTime: ${e.frozenTime}`);return`(() => {
|
|
186
406
|
const NativeDate = globalThis.Date;
|
|
187
407
|
const frozenTimestamp = ${t};
|
|
188
408
|
class KaptureDate extends NativeDate {
|
|
@@ -208,73 +428,74 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
208
428
|
configurable: false,
|
|
209
429
|
writable: false,
|
|
210
430
|
});
|
|
211
|
-
})();`}async function Ic(e){let{baseManifest:t,headManifest:n,baseRoot:r,headRoot:i,outputDir:a,threshold:o}=e;Mc(t.environment,n.environment),await ee(s(a,`images`),{recursive:!0,force:!0}),await _(s(a,`images`),{recursive:!0});let c=[...new Set([...Object.keys(t.snapshots),...Object.keys(n.snapshots)])].sort(),l={};for(let e of c){let s=t.snapshots[e],c=n.snapshots[e];l[e]=await Lc({id:e,base:s,head:c,baseRoot:r,headRoot:i,outputDir:a,threshold:o})}let u=Object.values(l),d={version:1,baseRevision:t.revision,headRevision:n.revision,environment:t.environment,createdAt:new Date().toISOString(),threshold:o,summary:{total:u.length,unchanged:u.filter(e=>e.status===`unchanged`).length,changed:u.filter(e=>e.status===`changed`).length,added:u.filter(e=>e.status===`added`).length,removed:u.filter(e=>e.status===`removed`).length,errors:u.filter(e=>e.status===`error`).length},entries:l};return await b(s(a,`report.json`),`${JSON.stringify(d,null,2)}\n`),d}async function Lc(e){let{id:t,base:n,head:r,baseRoot:a,headRoot:o,outputDir:c,threshold:l}=e,u=r??n;if(!u)throw Error(`Snapshot ${t} has no base or head record`);let d={id:t,storyId:u.storyId,title:u.title,name:u.name,viewport:u.viewport},f={...l,...r?.threshold??n?.threshold};if(n?.error||r?.error)return{...d,status:`error`,threshold:f,error:[n?.error,r?.error].filter(Boolean).join(` | `)};if(!n&&r)return{...d,status:`added`,threshold:f,headImage:await Rc(`head`,r,o,c)};if(n&&!r)return{...d,status:`removed`,threshold:f,baseImage:await Rc(`base`,n,a,c)};if(!n||!r)throw Error(`Invalid manifest pair for ${t}`);if(n.viewport.width!==r.viewport.width||n.viewport.height!==r.viewport.height)return{...d,status:`error`,threshold:f,error:`Viewport contract differs: base=${n.viewport.width}x${n.viewport.height}, head=${r.viewport.width}x${r.viewport.height}`};if(n.sha256===r.sha256)return{...d,status:`unchanged`,threshold:f};let p=`images/diff/${i(n.imageFile)}`;try{let e=await Oc(s(a,n.imageFile),s(o,r.imageFile),s(c,p),f.pixel);if(e.diffRatio<=f.ratio)return{...d,status:`unchanged`,threshold:f,changedPixels:e.changedPixels,diffRatio:e.diffRatio};let[t,i]=await Promise.all([Rc(`base`,n,a,c),Rc(`head`,r,o,c)]);return{...d,status:`changed`,threshold:f,baseImage:t,headImage:i,diffImage:p,changedPixels:e.changedPixels,diffRatio:e.diffRatio}}catch(e){return{...d,status:`error`,threshold:f,error:e instanceof Error?e.message:String(e)}}}async function Rc(e,t,n,r){let a=`images/${e}/${i(t.imageFile)}`;return await _(s(r,`images`,e),{recursive:!0}),await h(s(n,t.imageFile),s(r,a)),a}const zc={".css":`text/css; charset=utf-8`,".html":`text/html; charset=utf-8`,".ico":`image/x-icon`,".jpeg":`image/jpeg`,".jpg":`image/jpeg`,".js":`text/javascript; charset=utf-8`,".json":`application/json; charset=utf-8`,".mjs":`text/javascript; charset=utf-8`,".png":`image/png`,".svg":`image/svg+xml`,".woff":`font/woff`,".woff2":`font/woff2`};async function Bc(e){let t=u(e),n=ae(async(e,n)=>{try{let r=decodeURIComponent(new URL(e.url??`/`,`http://localhost`).pathname),i=u(t,`.${r}`);if(i!==t&&!i.startsWith(`${t}${d}`)){n.writeHead(403).end(`Forbidden`);return}let a=i;(await y(a)).isDirectory()&&(a=u(a,`index.html`));let s=await v(a);n.writeHead(200,{"cache-control":`no-store`,"content-type":zc[o(a)]??`application/octet-stream`}),n.end(s)}catch{n.writeHead(404).end(`Not found`)}});await Vc(n);let r=n.address();if(!r||typeof r==`string`)throw Error(`Static server has no TCP address`);return{url:`http://127.0.0.1:${r.port}/`,close:()=>Hc(n)}}function Vc(e){return new Promise((t,n)=>{e.once(`error`,n),e.listen(0,`127.0.0.1`,()=>{e.off(`error`,n),t()})})}function Hc(e){return new Promise((t,n)=>{e.close(e=>e?n(e):t())})}async function Uc(e){let t=await v(e);return f(`sha256`).update(t).digest(`hex`)}function Wc(e){return`${e.replace(/[^a-zA-Z0-9._-]/g,`-`)}.png`}const Gc=V({name:R(),width:B(),height:B()}),Kc=V({id:R(),browser:R(),browserVersion:R(),orchestratorRuntime:R(),operatingSystem:R(),architecture:R(),deviceScaleFactor:B(),locale:R(),timezone:R(),colorScheme:cs([`light`,`dark`]),reducedMotion:cs([`reduce`,`no-preference`]),frozenTime:R(),randomSeed:B(),fontsFingerprint:R(),network:V({mode:us(`allowlist`),allowedDomains:Qo(R()),webRtc:us(`disabled`)})});V({version:us(1),revision:R(),environment:Kc,createdAt:R(),snapshots:os(R(),V({id:R(),storyId:R(),title:R(),name:R(),viewport:Gc,imageFile:R(),sha256:R(),capturedAt:R(),durationMs:B(),threshold:V({pixel:B().optional(),ratio:B().optional()}).optional(),error:R().optional()}))});async function qc(e,t){await _(a(e),{recursive:!0}),await b(e,`${JSON.stringify(t,null,2)}\n`)}const Jc=V({id:R().min(1),title:R(),name:R(),type:cs([`story`,`docs`])}),Yc=V({v:B(),entries:os(R(),Jc)});async function Xc(e){let t=await fetch(new URL(`index.json`,$c(e)));if(!t.ok)throw Error(`Failed to read Storybook index (${t.status}) from ${e}`);return Yc.parse(await t.json())}function Zc(e){return Object.values(e.entries).filter(e=>e.type===`story`).sort((e,t)=>e.id.localeCompare(t.id))}function Qc(e,t){let n=new URL(`iframe.html`,$c(e));return n.searchParams.set(`id`,t),n.searchParams.set(`viewMode`,`story`),n.toString()}function $c(e){return e.endsWith(`/`)?e:`${e}/`}async function el(e){let t=u(e.outputDir),n=s(t,`capture`,`base`),r=s(t,`capture`,`head`),i=s(t,`report`);await ee(t,{recursive:!0,force:!0}),await Promise.all([_(s(n,`images`),{recursive:!0}),_(s(r,`images`),{recursive:!0}),_(i,{recursive:!0})]);let a=jc({browserVersion:await xc(),fontsFingerprint:await Nc(),frozenTime:e.frozenTime,randomSeed:e.randomSeed,locale:e.locale,timezone:e.timezone}),o=s(t,`hermetic-init.js`);await b(o,Fc(a));let c=`kapture-${process.pid}-${Date.now()}`,[l,d]=await Promise.all([Bc(e.baseDir),Bc(e.headDir)]);try{let[t,u]=await Promise.all([Xc(l.url),Xc(d.url)]),f=nl(Zc(t),Zc(u)),p=tl(e.baseRevision,a),m=tl(e.headRevision,a),h=Math.max(1,Math.min(e.workers??4,f.length||1)),g=[...f],_=Array.from({length:h},(t,n)=>e.driverFactory?e.driverFactory(n,{namespace:c,initScriptPath:o,environment:a}):new bc({session:`worker-${n}`,namespace:c,initScriptPath:o,timezone:a.timezone,locale:a.locale,deviceScaleFactor:a.deviceScaleFactor,allowedDomains:a.network.allowedDomains}));try{await Promise.all(_.map(async e=>{for(;g.length>0;){let t=g.shift();if(!t)return;await rl({driver:e,pair:t,baseUrl:l.url,headUrl:d.url,baseOutput:n,headOutput:r,baseManifest:p,headManifest:m,environment:a})}}))}finally{await Promise.allSettled(_.map(e=>e.close()))}return await Promise.all([qc(s(n,`manifest.json`),p),qc(s(r,`manifest.json`),m)]),{baseManifest:p,headManifest:m,report:await Ic({baseManifest:p,headManifest:m,baseRoot:n,headRoot:r,outputDir:i,threshold:{...Dc,...e.threshold}})}}finally{await Promise.allSettled([l.close(),d.close()])}}function tl(e,t){return{version:1,revision:e,environment:t,createdAt:new Date().toISOString(),snapshots:{}}}function nl(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));return[...new Set([...n.keys(),...r.keys()])].sort().map(e=>({id:e,base:n.get(e),head:r.get(e)}))}async function rl(e){let{driver:t,pair:n}=e,r=n.base?await il(t,e.baseUrl,n.base,e.environment).catch(cl):void 0,i=n.head?await il(t,e.headUrl,n.head,e.environment).catch(cl):void 0;if(r instanceof Error&&sl(e.baseManifest,n.base,r),i instanceof Error&&sl(e.headManifest,n.head,i),r instanceof Error||i instanceof Error)return;let a=r instanceof Error?void 0:r?.parameters,o=i instanceof Error?void 0:i?.parameters,s=al(a,o,!!n.base,!!n.head);for(let r of s)n.base&&a&&!a.disabled&&r.base&&await ol({driver:t,story:n.base,baseUrl:e.baseUrl,outputRoot:e.baseOutput,manifest:e.baseManifest,viewport:r.base,cropToViewport:a.cropToViewport,threshold:a.diff}),n.head&&o&&!o.disabled&&r.head&&await ol({driver:t,story:n.head,baseUrl:e.headUrl,outputRoot:e.headOutput,manifest:e.headManifest,viewport:r.head,cropToViewport:o.cropToViewport,threshold:o.diff})}async function il(e,t,n,r){await e.setViewport(Ec),await e.open(Qc(t,n.id));let i=await Tc(e,r);if(!i||i.ready!==!0||typeof i.parameters!=`object`)throw Error(`Storybook returned invalid Kapture runtime metadata`);return i}function al(e,t,n=!0,r=!0){let i=!n||e?.disabled?[]:e?.viewports??[Ec],a=!r||t?.disabled?[]:t?.viewports??[Ec],o=new Map(i.map(e=>[e.name,e])),s=new Map(a.map(e=>[e.name,e]));return[...new Set([...o.keys(),...s.keys()])].sort().map(e=>({base:o.get(e),head:s.get(e)}))}async function ol(e){let{driver:t,story:n,baseUrl:r,outputRoot:i,manifest:a,viewport:o,cropToViewport:c,threshold:u}=e,d=`${n.id}@${o.name}`,f=s(`images`,Wc(d)),p=s(i,f),m=performance.now();try{await t.setViewport(o),await t.open(Qc(r,n.id)),await Tc(t,a.environment),await t.screenshot(p,{fullPage:c!==!0}),a.snapshots[d]={id:d,storyId:n.id,title:n.title,name:n.name,viewport:o,imageFile:l(i,p),sha256:await Uc(p),capturedAt:new Date().toISOString(),durationMs:Math.round(performance.now()-m),threshold:u}}catch(e){a.snapshots[d]={id:d,storyId:n.id,title:n.title,name:n.name,viewport:o,imageFile:f,sha256:``,capturedAt:new Date().toISOString(),durationMs:Math.round(performance.now()-m),threshold:u,error:e instanceof Error?e.message:String(e)}}}function sl(e,t,n){let r=`${t.id}@metadata`;e.snapshots[r]={id:r,storyId:t.id,title:t.title,name:t.name,viewport:Ec,imageFile:``,sha256:``,capturedAt:new Date().toISOString(),durationMs:0,error:n.message}}function cl(e){return e instanceof Error?e:Error(String(e))}async function ll(e,t){if(!(await y(e)).isDirectory())throw Error(`Dashboard build is not a directory: ${e}`);await g(e,t,{recursive:!0,force:!0});let n=u(t,`index.html`),r=u(t,`report.json`),[i,a]=await Promise.all([v(n,`utf8`),v(r,`utf8`)]),o=ul(i,/<link\b[^>]*\brel=["']stylesheet["'][^>]*\bhref=["']([^"']+)["'][^>]*>/i,`stylesheet`),s=ul(i,/<script\b[^>]*\bsrc=["']([^"']+)["'][^>]*><\/script>/i,`module script`),[c,l]=await Promise.all([dl(t,o.url),dl(t,s.url)]),d=fl(c,o.url),f=`<script id="kapture-report-data" type="application/json">${a.trim().replaceAll(`<`,`\\u003c`)}<\/script>\n<script data-kapture-dashboard>"use strict";\n${l.replace(/<\/script/gi,`<\\/script`)}<\/script>`,p=i.replace(o.tag,()=>`<style>${d}</style>`).replace(s.tag,``);if(!p.includes(`</body>`))throw Error(`Dashboard index is missing its closing body tag`);let m=p.replace(`</body>`,()=>`${f}\n</body>`);await b(n,m)}function ul(e,t,n){let r=e.match(t);if(!r?.[1])throw Error(`Dashboard index is missing its ${n}`);return{tag:r[0],url:r[1]}}async function dl(e,t){if(/^[a-z]+:/i.test(t)||t.startsWith(`/`)||t.includes(`?`))throw Error(`Dashboard asset must be a relative local path: ${t}`);let n=u(e),r=u(n,t);if(!r.startsWith(`${n}${d}`))throw Error(`Dashboard asset resolves outside the report directory: ${t}`);return v(r,`utf8`)}function fl(e,t){let n=c.dirname(t);return e.replace(/url\((["']?)(\.\/[^"')]+)\1\)/g,(e,t,r)=>{let i=c.join(n,r);return`url(${t}${i.startsWith(`.`)?i:`./${i}`}${t})`})}const U={silent:-1/0,fatal:0,error:0,warn:1,log:2,info:3,success:3,fail:3,ready:3,start:3,box:3,debug:4,trace:5,verbose:1/0},pl={silent:{level:-1},fatal:{level:U.fatal},error:{level:U.error},warn:{level:U.warn},log:{level:U.log},info:{level:U.info},success:{level:U.success},fail:{level:U.fail},ready:{level:U.info},start:{level:U.info},box:{level:U.info},debug:{level:U.debug},trace:{level:U.trace},verbose:{level:U.verbose}};function ml(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function hl(e,t,n=`.`,r){if(!ml(t))return hl(e,{},n,r);let i=Object.assign({},t);for(let t in e){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:ml(a)&&ml(i[t])?hl(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function gl(e){return(...t)=>t.reduce((t,n)=>hl(t,n,``,e),{})}const _l=gl();function vl(e){return Object.prototype.toString.call(e)===`[object Object]`}function yl(e){return!(!vl(e)||!e.message&&!e.args||e.stack)}let bl=!1;const xl=[];var W=class e{options;_lastLog;_mockFn;constructor(e={}){let t=e.types||pl;this.options=_l({...e,defaults:{...e.defaults},level:Sl(e.level,t),reporters:[...e.reporters||[]]},{types:pl,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}});for(let e in t){let n={type:e,...this.options.defaults,...t[e]};this[e]=this._wrapLogFn(n),this[e].raw=this._wrapLogFn(n,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(e){this.options.level=Sl(e,this.options.types,this.options.level)}prompt(e,t){if(!this.options.prompt)throw Error(`prompt is not supported!`);return this.options.prompt(e,t)}create(t){let n=new e({...this.options,...t});return this._mockFn&&n.mockTypes(this._mockFn),n}withDefaults(e){return this.create({...this.options,defaults:{...this.options.defaults,...e}})}withTag(e){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+`:`+e:e})}addReporter(e){return this.options.reporters.push(e),this}removeReporter(e){if(e){let t=this.options.reporters.indexOf(e);if(t!==-1)return this.options.reporters.splice(t,1)}else this.options.reporters.splice(0);return this}setReporters(e){return this.options.reporters=Array.isArray(e)?e:[e],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(let e in this.options.types)console[`__`+e]||(console[`__`+e]=console[e]),console[e]=this[e].raw}restoreConsole(){for(let e in this.options.types)console[`__`+e]&&(console[e]=console[`__`+e],delete console[`__`+e])}wrapStd(){this._wrapStream(this.options.stdout,`log`),this._wrapStream(this.options.stderr,`log`)}_wrapStream(e,t){e&&(e.__write||=e.write,e.write=e=>{this[t].raw(String(e).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(e){e&&e.__write&&(e.write=e.__write,delete e.__write)}pauseLogs(){bl=!0}resumeLogs(){bl=!1;let e=xl.splice(0);for(let t of e)t[0]._logFn(t[1],t[2])}mockTypes(e){let t=e||this.options.mockFn;if(this._mockFn=t,typeof t==`function`)for(let e in this.options.types)this[e]=t(e,this.options.types[e])||this[e],this[e].raw=this[e]}_wrapLogFn(e,t){return(...n)=>{if(bl){xl.push([this,e,n,t]);return}return this._logFn(e,n,t)}}_logFn(e,t,n){if((e.level||0)>this.level)return!1;let r={date:new Date,args:[],...e,level:Sl(e.level,this.options.types)};!n&&t.length===1&&yl(t[0])?Object.assign(r,t[0]):r.args=[...t],r.message&&(r.args.unshift(r.message),delete r.message),r.additional&&(Array.isArray(r.additional)||(r.additional=r.additional.split(`
|
|
431
|
+
})();`}const rc=[`baseImage`,`headImage`,`diffImage`],ic=/^[0-9a-f]{64}$/;function ac(e){let t=new Set;for(let n of Object.values(e.entries))for(let e of rc){let r=n[e];r&&t.add(r)}return[...t].sort(dc)}function oc(e){return lc({report:cc(e)})}function sc(e,t){let n=ac(e),r=new Set(n),i=new Map;for(let e of t){if(!e.path||!ic.test(e.sha256))throw Error(`Invalid report image digest for ${e.path||`<empty path>`}`);if(i.has(e.path))throw Error(`Duplicate report image digest for ${e.path}`);i.set(e.path,e.sha256)}for(let e of n)if(!i.has(e))throw Error(`Missing report image digest for ${e}`);for(let e of i.keys())if(!r.has(e))throw Error(`Unexpected report image digest for ${e}`);return lc({report:cc(e),images:n.map(e=>({path:e,sha256:i.get(e)}))})}function cc(e){let{contentDigest:t,...n}=e;return n}function lc(e){return ie(`sha256`).update(JSON.stringify(uc(e))).digest(`hex`)}function uc(e){return Array.isArray(e)?e.map(uc):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0).sort(([e],[t])=>dc(e,t)).map(([e,t])=>[e,uc(t)]))}function dc(e,t){return e<t?-1:+(e>t)}async function fc(e){let t=await y(e);return ie(`sha256`).update(t).digest(`hex`)}function pc(e){return`${e.replace(/[^a-zA-Z0-9._-]/g,`-`)}.png`}async function mc(e){let{baseManifest:t,headManifest:n,baseRoot:r,headRoot:i,outputDir:a,threshold:o}=e;$s(t.environment,n.environment),await b(c(a,`images`),{recursive:!0,force:!0}),await _(c(a,`images`),{recursive:!0});let s=[...new Set([...Object.keys(t.snapshots),...Object.keys(n.snapshots)])].sort(),l={};for(let e of s){let s=t.snapshots[e],c=n.snapshots[e];l[e]=await hc({id:e,base:s,head:c,baseRoot:r,headRoot:i,outputDir:a,threshold:o})}let u=Object.values(l),d={version:1,baseRevision:t.revision,headRevision:n.revision,environment:t.environment,createdAt:new Date().toISOString(),threshold:o,summary:{total:u.length,unchanged:u.filter(e=>e.status===`unchanged`).length,changed:u.filter(e=>e.status===`changed`).length,added:u.filter(e=>e.status===`added`).length,removed:u.filter(e=>e.status===`removed`).length,errors:u.filter(e=>e.status===`error`).length},entries:l},f=[];for(let e of ac(d))f.push({path:e,sha256:await fc(c(a,e))});return d.contentDigest=sc(d,f),await x(c(a,`report.json`),`${JSON.stringify(d,null,2)}\n`),d}async function hc(e){let{id:t,base:n,head:r,baseRoot:a,headRoot:o,outputDir:s,threshold:l}=e,u=r??n;if(!u)throw Error(`Snapshot ${t} has no base or head record`);let d={id:t,storyId:u.storyId,title:u.title,name:u.name,viewport:u.viewport},f={...l,...r?.threshold??n?.threshold};if(n?.error||r?.error)return{...d,status:`error`,threshold:f,error:[n?.error,r?.error].filter(Boolean).join(` | `)};if(!n&&r)return{...d,status:`added`,threshold:f,headImage:await gc(`head`,r,o,s)};if(n&&!r)return{...d,status:`removed`,threshold:f,baseImage:await gc(`base`,n,a,s)};if(!n||!r)throw Error(`Invalid manifest pair for ${t}`);if(n.viewport.width!==r.viewport.width||n.viewport.height!==r.viewport.height)return{...d,status:`error`,threshold:f,error:`Viewport contract differs: base=${n.viewport.width}x${n.viewport.height}, head=${r.viewport.width}x${r.viewport.height}`};if(n.sha256===r.sha256)return{...d,status:`unchanged`,threshold:f};let p=`images/diff/${i(n.imageFile)}`;try{let e=await Js(c(a,n.imageFile),c(o,r.imageFile),c(s,p),f.pixel,{base:n.ignoredRegions??[],head:r.ignoredRegions??[]});if(e.diffRatio<=f.ratio)return{...d,status:`unchanged`,threshold:f,changedPixels:e.changedPixels,diffRatio:e.diffRatio};let[t,i]=await Promise.all([gc(`base`,n,a,s),gc(`head`,r,o,s)]);return{...d,status:`changed`,threshold:f,baseImage:t,headImage:i,diffImage:p,changedPixels:e.changedPixels,diffRatio:e.diffRatio}}catch(e){return{...d,status:`error`,threshold:f,error:e instanceof Error?e.message:String(e)}}}async function gc(e,t,n,r){let a=`images/${e}/${i(t.imageFile)}`;return await _(c(r,`images`,e),{recursive:!0}),await m(c(n,t.imageFile),c(r,a)),a}const _c={".css":`text/css; charset=utf-8`,".html":`text/html; charset=utf-8`,".ico":`image/x-icon`,".jpeg":`image/jpeg`,".jpg":`image/jpeg`,".js":`text/javascript; charset=utf-8`,".json":`application/json; charset=utf-8`,".mjs":`text/javascript; charset=utf-8`,".png":`image/png`,".svg":`image/svg+xml`,".woff":`font/woff`,".woff2":`font/woff2`};async function vc(e){let t=await te(d(e)),n=le(async(e,n)=>{try{let r=decodeURIComponent(new URL(e.url??`/`,`http://localhost`).pathname),i=d(t,`.${r}`);if(!yc(t,i)){n.writeHead(403).end(`Forbidden`);return}let a=await te(i);if(!yc(t,a)){n.writeHead(403).end(`Forbidden`);return}if((await re(a)).isDirectory()&&(a=await te(d(a,`index.html`)),!yc(t,a))){n.writeHead(403).end(`Forbidden`);return}let s=await y(a);n.writeHead(200,{"cache-control":`no-store`,"content-type":_c[o(a)]??`application/octet-stream`}),n.end(s)}catch{n.writeHead(404).end(`Not found`)}});await bc(n);let r=n.address();if(!r||typeof r==`string`)throw Error(`Static server has no TCP address`);return{url:`http://127.0.0.1:${r.port}/`,close:()=>xc(n)}}function yc(e,t){return t===e||t.startsWith(`${e}${f}`)}function bc(e){return new Promise((t,n)=>{e.once(`error`,n),e.listen(0,`127.0.0.1`,()=>{e.off(`error`,n),t()})})}function xc(e){return new Promise((t,n)=>{e.close(e=>e?n(e):t())})}const Sc=V({name:R(),width:B(),height:B()}),Cc=V({id:R(),browser:R(),browserVersion:R(),orchestratorRuntime:R(),operatingSystem:R(),architecture:R(),deviceScaleFactor:B(),locale:R(),timezone:R(),colorScheme:ps([`light`,`dark`]),reducedMotion:ps([`reduce`,`no-preference`]),frozenTime:R(),randomSeed:B(),fontsFingerprint:R(),network:V({mode:hs(`allowlist`),allowedDomains:rs(R()),webRtc:hs(`disabled`)})});V({version:hs(1),revision:R(),environment:Cc,createdAt:R(),snapshots:ds(R(),V({id:R(),storyId:R(),title:R(),name:R(),viewport:Sc,imageFile:R(),sha256:R(),capturedAt:R(),durationMs:B(),ignoredRegions:rs(V({x:B().int().nonnegative(),y:B().int().nonnegative(),width:B().int().positive(),height:B().int().positive()})).optional(),threshold:V({pixel:B().optional(),ratio:B().optional()}).optional(),error:R().optional()}))});async function wc(e,t){await _(a(e),{recursive:!0}),await x(e,`${JSON.stringify(t,null,2)}\n`)}const Tc=V({id:R().min(1),title:R(),name:R(),type:ps([`story`,`docs`])}),Ec=V({v:B(),entries:ds(R(),Tc)});async function Dc(e){let t=await fetch(new URL(`index.json`,Ac(e)));if(!t.ok)throw Error(`Failed to read Storybook index (${t.status}) from ${e}`);return Ec.parse(await t.json())}function Oc(e){return Object.values(e.entries).filter(e=>e.type===`story`).sort((e,t)=>e.id.localeCompare(t.id))}function kc(e,t){let n=new URL(`iframe.html`,Ac(e));return n.searchParams.set(`id`,t),n.searchParams.set(`viewMode`,`story`),n.toString()}function Ac(e){return e.endsWith(`/`)?e:`${e}/`}async function jc(e){let t=d(e.outputDir),n=c(t,`capture`,`base`),r=c(t,`capture`,`head`),i=c(t,`report`);await b(t,{recursive:!0,force:!0}),await Promise.all([_(c(n,`images`),{recursive:!0}),_(c(r,`images`),{recursive:!0}),_(i,{recursive:!0})]);let a=Qs({browserVersion:await Vs(),fontsFingerprint:await ec(),frozenTime:e.frozenTime,randomSeed:e.randomSeed,locale:e.locale,timezone:e.timezone}),o=c(t,`hermetic-init.js`);await x(o,nc(a));let s=`kapture-${process.pid}-${Date.now()}`,[l,u]=await Promise.all([vc(e.baseDir),vc(e.headDir)]);try{let[t,d]=await Promise.all([Dc(l.url),Dc(u.url)]),f=Nc(Oc(t),Oc(d)),p=Mc(e.baseRevision,a),m=Mc(e.headRevision,a),h=Math.max(1,Math.min(e.workers??4,f.length||1)),g=[...f],_=Array.from({length:h},(t,n)=>e.driverFactory?e.driverFactory(n,{namespace:s,initScriptPath:o,environment:a}):new Bs({session:`worker-${n}`,namespace:s,initScriptPath:o,timezone:a.timezone,locale:a.locale,deviceScaleFactor:a.deviceScaleFactor,allowedDomains:a.network.allowedDomains}));try{await Promise.all(_.map(async e=>{for(;g.length>0;){let t=g.shift();if(!t)return;await Pc({driver:e,pair:t,baseUrl:l.url,headUrl:u.url,baseOutput:n,headOutput:r,baseManifest:p,headManifest:m,environment:a})}}))}finally{await Promise.allSettled(_.map(e=>e.close()))}return await Promise.all([wc(c(n,`manifest.json`),p),wc(c(r,`manifest.json`),m)]),{baseManifest:p,headManifest:m,report:await mc({baseManifest:p,headManifest:m,baseRoot:n,headRoot:r,outputDir:i,threshold:{...qs,...e.threshold}})}}finally{await Promise.allSettled([l.close(),u.close()])}}function Mc(e,t){return{version:1,revision:e,environment:t,createdAt:new Date().toISOString(),snapshots:{}}}function Nc(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));return[...new Set([...n.keys(),...r.keys()])].sort().map(e=>({id:e,base:n.get(e),head:r.get(e)}))}async function Pc(e){let{driver:t,pair:n}=e,r=n.base?await Fc(t,e.baseUrl,n.base,e.environment).catch(zc):void 0,i=n.head?await Fc(t,e.headUrl,n.head,e.environment).catch(zc):void 0;if(r instanceof Error&&Rc(e.baseManifest,n.base,r),i instanceof Error&&Rc(e.headManifest,n.head,i),r instanceof Error||i instanceof Error)return;let a=r instanceof Error?void 0:r?.parameters,o=i instanceof Error?void 0:i?.parameters,s=Ic(a,o,!!n.base,!!n.head);for(let r of s)n.base&&a&&!a.disabled&&r.base&&await Lc({driver:t,story:n.base,baseUrl:e.baseUrl,outputRoot:e.baseOutput,manifest:e.baseManifest,viewport:r.base,cropToViewport:a.cropToViewport,threshold:a.diff}),n.head&&o&&!o.disabled&&r.head&&await Lc({driver:t,story:n.head,baseUrl:e.headUrl,outputRoot:e.headOutput,manifest:e.headManifest,viewport:r.head,cropToViewport:o.cropToViewport,threshold:o.diff})}async function Fc(e,t,n,r){await e.setViewport(Ks),await e.open(kc(t,n.id));let i=await Gs(e,r);if(!i||i.ready!==!0||typeof i.parameters!=`object`)throw Error(`Storybook returned invalid Kapture runtime metadata`);return i}function Ic(e,t,n=!0,r=!0){let i=!n||e?.disabled?[]:e?.viewports??[Ks],a=!r||t?.disabled?[]:t?.viewports??[Ks],o=new Map(i.map(e=>[e.name,e])),s=new Map(a.map(e=>[e.name,e]));return[...new Set([...o.keys(),...s.keys()])].sort().map(e=>({base:o.get(e),head:s.get(e)}))}async function Lc(e){let{driver:t,story:n,baseUrl:r,outputRoot:i,manifest:a,viewport:o,cropToViewport:s,threshold:l}=e,d=`${n.id}@${o.name}`,f=c(`images`,pc(d)),p=c(i,f),m=performance.now();try{await t.setViewport(o),await t.open(kc(r,n.id));let e=await Gs(t,a.environment);await t.screenshot(p,{fullPage:s!==!0}),a.snapshots[d]={id:d,storyId:n.id,title:n.title,name:n.name,viewport:o,imageFile:u(i,p),sha256:await fc(p),capturedAt:new Date().toISOString(),durationMs:Math.round(performance.now()-m),ignoredRegions:e.ignoredRegions.length>0?e.ignoredRegions:void 0,threshold:l}}catch(e){a.snapshots[d]={id:d,storyId:n.id,title:n.title,name:n.name,viewport:o,imageFile:f,sha256:``,capturedAt:new Date().toISOString(),durationMs:Math.round(performance.now()-m),threshold:l,error:e instanceof Error?e.message:String(e)}}}function Rc(e,t,n){let r=`${t.id}@metadata`;e.snapshots[r]={id:r,storyId:t.id,title:t.title,name:t.name,viewport:Ks,imageFile:``,sha256:``,capturedAt:new Date().toISOString(),durationMs:0,error:n.message}}function zc(e){return e instanceof Error?e:Error(String(e))}async function Bc(e,t){if(!(await re(e)).isDirectory())throw Error(`Dashboard build is not a directory: ${e}`);await h(e,t,{recursive:!0,force:!0});let n=d(t,`index.html`),r=d(t,`report.json`),[i,a]=await Promise.all([y(n,`utf8`),y(r,`utf8`)]),o=Vc(i,/<link\b[^>]*\brel=["']stylesheet["'][^>]*\bhref=["']([^"']+)["'][^>]*>/i,`stylesheet`),s=Vc(i,/<script\b[^>]*\bsrc=["']([^"']+)["'][^>]*><\/script>/i,`module script`),[c,l]=await Promise.all([Hc(t,o.url),Hc(t,s.url)]),u=Uc(c,o.url),f=`<script id="kapture-report-data" type="application/json">${a.trim().replaceAll(`<`,`\\u003c`)}<\/script>\n<script data-kapture-dashboard>"use strict";\n${l.replace(/<\/script/gi,`<\\/script`)}<\/script>`,p=i.replace(o.tag,()=>`<style>${u}</style>`).replace(s.tag,``);if(!p.includes(`</body>`))throw Error(`Dashboard index is missing its closing body tag`);let m=p.replace(`</body>`,()=>`${f}\n</body>`);await x(n,m)}function Vc(e,t,n){let r=e.match(t);if(!r?.[1])throw Error(`Dashboard index is missing its ${n}`);return{tag:r[0],url:r[1]}}async function Hc(e,t){if(/^[a-z]+:/i.test(t)||t.startsWith(`/`)||t.includes(`?`))throw Error(`Dashboard asset must be a relative local path: ${t}`);let n=d(e),r=d(n,t);if(!r.startsWith(`${n}${f}`))throw Error(`Dashboard asset resolves outside the report directory: ${t}`);return y(r,`utf8`)}function Uc(e,t){let n=l.dirname(t);return e.replace(/url\((["']?)(\.\/[^"')]+)\1\)/g,(e,t,r)=>{let i=l.join(n,r);return`url(${t}${i.startsWith(`.`)?i:`./${i}`}${t})`})}const Wc=`<!-- kapture-report:`,Gc={error:0,removed:1,changed:2,added:3,unchanged:4};function Kc(e){return e.contentDigest??oc(e)}function qc(e){return`${Wc}${Buffer.from(JSON.stringify(e)).toString(`base64url`)} -->`}function Jc(e){let t=e.indexOf(Wc);if(t<0)return null;let n=t+20,r=e.indexOf(` -->`,n);if(r<0)return null;try{let t=JSON.parse(Buffer.from(e.slice(n,r),`base64url`).toString());return t.version!==2||!Zc(t.baseSha)||!Zc(t.headSha)||!/^[0-9a-f]{64}$/.test(t.digest)||![`clean`,`changed`,`error`].includes(t.status)||t.reportUrl!==void 0&&Qc(t.reportUrl)!==t.reportUrl?null:t}catch{return null}}function Yc(e,t,n=`Kapture Visual Review`){let{summary:r}=e,i=r.changed+r.added+r.removed,a=new Set(Object.values(e.entries).map(e=>e.storyId)).size,o=rl(n,100),s=[qc(t),`## ${o}`,``,r.errors>0?`❌ **${r.errors}개의 실행 오류**를 해결해 주세요.`:i===0?`✅ 시각적 변경이 없습니다.`:`🔍 **${i}개의 시각적 변경**을 검토해 주세요.`,``,`**${a}개 스토리 · ${r.total}개 스냅샷 비교**`,``,`- 동일 ${r.unchanged} · 변경 ${r.changed} · 추가 ${r.added} · 삭제 ${r.removed} · 오류 ${r.errors}`,`- 환경 \`${al(e.environment.id)}\` · base \`${sl(e.baseRevision)}\` → head \`${sl(e.headRevision)}\``];if(t.reportUrl){let e=ol(t.reportUrl)?`전체 비교 리포트 다운로드`:`전체 비교 리포트 열기`;s.push(``,`[${e}](${t.reportUrl})`)}let c=Object.values(e.entries).filter(e=>e.status!==`unchanged`).sort(tl),l=c.slice(0,20);for(let e of[`error`,`removed`,`changed`,`added`]){let t=c.filter(t=>t.status===e),n=l.filter(t=>t.status===e);if(n.length!==0){s.push(``,`### ${nl(e)} (${t.length})`,``);for(let e of n)s.push(el(e))}}let u=c.length-l.length;return u>0&&s.push(``,`그 외 ${u}개 항목은 전체 비교 리포트에서 확인해 주세요.`),r.errors>0?s.push(``,`⚠️ 캡처 또는 비교 오류를 해결해야 합니다. 승인할 수 없습니다.`):i>0&&s.push(``,`전체 head 빌드를 승인하려면 쓰기 권한이 있는 리뷰어가 다음 명령을 남겨 주세요.`,``,`\`/kapture approve ${e.headRevision} ${t.digest}\``),`${s.join(`
|
|
432
|
+
`)}\n`}function Xc(e){let t=e.trim().match(/^\/kapture\s+approve\s+([0-9a-f]{40})\s+([0-9a-f]{64})$/i);return!t?.[1]||!t[2]?null:{headSha:t[1].toLowerCase(),reportDigest:t[2].toLowerCase()}}function Zc(e){return/^[0-9a-f]{40}$/i.test(e)}function Qc(e){if(!e)return;if(e.length>2048)throw Error(`Report URL is too long`);let t;try{t=new URL(e)}catch{throw Error(`Report URL must be a valid HTTPS URL`)}if(t.protocol!==`https:`||t.username||t.password)throw Error(`Report URL must be an HTTPS URL without credentials`);return t.toString().replace(/\(/g,`%28`).replace(/\)/g,`%29`).replace(/\[/g,`%5B`).replace(/\]/g,`%5D`)}function $c(e){let t=il(e).replace(/\s+/g,` `).trim();if(!t||t.length>100)throw Error(`Status context must contain between 1 and 100 characters`);return t}function el(e){let t=`**${rl(e.title)} / ${rl(e.name)}** · ${rl(e.viewport.name)}`;return e.status===`error`?`- ${t} — ${rl(e.error??`캡처 또는 비교에 실패했습니다.`,180)}`:e.status===`removed`?`- ${t} — head Storybook에서 찾을 수 없음`:e.status===`added`?`- ${t} — 새 스냅샷`:`- ${t}`}function tl(e,t){let n=Gc[e.status]-Gc[t.status];return n===0?`${e.title}/${e.name}/${e.viewport.name}`.localeCompare(`${t.title}/${t.name}/${t.viewport.name}`):n}function nl(e){return e===`error`?`🚨 실행 오류`:e===`removed`?`⚠️ 삭제된 스냅샷`:e===`changed`?`🔍 시각 변경`:`➕ 추가된 스냅샷`}function rl(e,t=240){let n=il(e).replace(/\s+/g,` `).trim();return(n.length>t?`${n.slice(0,t-3)}...`:n).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\\/g,`\\\\`).replace(/([`*_[\]{}|])/g,`\\$1`).replace(/@/g,`@`)}function il(e){return Array.from(e,e=>{let t=e.codePointAt(0)??0;return t<=31||t===127?` `:e}).join(``)}function al(e){return e.replace(/`/g,`ˋ`).replace(/[\r\n]/g,` `)}function ol(e){return e.includes(`/actions/runs/`)&&e.includes(`/artifacts/`)}function sl(e){return e.slice(0,8)}var cl=class{#e;#t;constructor(e,t){if(!e)throw Error(`GITHUB_TOKEN is required`);this.#e=e,this.#t=t}async setReviewStatus(e,t,n,r,i){await this.#r(`POST`,`/statuses/${encodeURIComponent(e)}`,{state:t,description:n.slice(0,140),context:r,target_url:i})}async postOrUpdateReportComment(e,t){let n=(await this.#n(e)).find(e=>e.user?.login===`github-actions[bot]`&&e.body?.includes(`<!-- kapture-report:`));return n?(await this.#r(`PATCH`,`/issues/comments/${n.id}`,{body:t})).id:this.createIssueComment(e,t)}async findCurrentReportMarker(e,t,n){let r=await this.#n(e);for(let e of r.reverse()){if(e.user?.login!==`github-actions[bot]`||!e.body)continue;let r=Jc(e.body);if(r?.baseSha===t&&r.headSha===n)return r}return null}async assertWritePermission(e){let t=await this.#r(`GET`,`/collaborators/${encodeURIComponent(e)}/permission`);if(!t.permission||![`admin`,`maintain`,`write`].includes(t.permission))throw Error(`@${e} does not have write permission for this repository`)}async getPullRequest(e){return this.#r(`GET`,`/pulls/${e}`)}async createIssueComment(e,t){return(await this.#r(`POST`,`/issues/${e}/comments`,{body:t})).id}async#n(e){let t=[];for(let n=1;n<=10;n+=1){let r=await this.#r(`GET`,`/issues/${e}/comments?per_page=100&page=${n}`);if(t.push(...r),r.length<100)break}return t}async#r(e,t,n){let{owner:r,repo:i}=this.#t,a=`/repos/${encodeURIComponent(r)}/${encodeURIComponent(i)}${t}`,o=await fetch(`https://api.github.com${a}`,{method:e,headers:{Accept:`application/vnd.github+json`,Authorization:`Bearer ${this.#e}`,"X-GitHub-Api-Version":`2022-11-28`,"User-Agent":`kapture-cli`,...n?{"Content-Type":`application/json`}:{}},body:n?JSON.stringify(n):void 0});if(!o.ok)throw Error(`GitHub API ${e} ${t} failed with status ${o.status}`);return await o.json()}};async function ll(){let e=process.env.GITHUB_EVENT_PATH;if(!e)throw Error(`GITHUB_EVENT_PATH is required`);let t=await re(e);if(!t.isFile()||t.size>10485760)throw Error(`GitHub event payload is missing or too large`);try{return JSON.parse(await y(e,`utf8`))}catch{throw Error(`GITHUB_EVENT_PATH does not contain valid JSON`)}}function ul(e){let t=gl(e,`GitHub event payload`);if(t.action!==`completed`)throw Error(`Kapture report must run for a completed workflow_run event`);let n=gl(t.workflow_run,`workflow_run`);if(n.event!==`pull_request`)throw Error(`Kapture report only accepts workflow_run events created by pull_request`);let r=pl(n.head_sha,`workflow_run.head_sha`),i=n.pull_requests;if(!Array.isArray(i)||i.length!==1)throw Error(`workflow_run must identify exactly one pull request`);let a=gl(i[0],`workflow_run.pull_requests[0]`);return{repository:fl(t),issueNumber:ml(a.number,`pull request number`),headSha:r}}function dl(e){let t=gl(e,`GitHub event payload`);if(t.action!==`created`)throw Error(`Kapture approval only accepts newly created issue comments`);let n=gl(t.issue,`issue`);if(!n.pull_request)throw Error(`Kapture approval must be posted on a pull request`);let r=Xc(hl(gl(t.comment,`comment`).body));if(!r)throw Error(`Expected /kapture approve <full-head-sha> <64-character-report-digest>`);let i=hl(gl(t.sender,`sender`).login);if(!/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/.test(i))throw Error(`GitHub event contains an invalid sender login`);return{repository:fl(t),issueNumber:ml(n.number,`pull request number`),headSha:r.headSha,reportDigest:r.reportDigest,sender:i}}function fl(e){let t=hl(gl(e.repository,`repository`).full_name).match(/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)$/);if(!t?.[1]||!t[2])throw Error(`GitHub event contains an invalid repository`);return{owner:t[1],repo:t[2]}}function pl(e,t){let n=hl(e).toLowerCase();if(!Zc(n))throw Error(`${t} must be a full 40-character SHA`);return n}function ml(e,t){if(typeof e!=`number`||!Number.isInteger(e)||e<=0)throw Error(`${t} must be a positive integer`);return e}function hl(e){if(typeof e!=`string`)throw Error(`GitHub event contains an invalid string value`);return e}function gl(e,t){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`${t} must be an object`);return e}async function _l(e,t,n){let r=yl(n.baseRevision,`Report base`),i=yl(n.headRevision,`Report head`);if(i!==t.headSha)throw Error(`Report head ${n.headRevision} does not match workflow head ${t.headSha}`);let a=await e.getPullRequest(t.issueNumber);if(a.number!==t.issueNumber)throw Error(`GitHub returned PR #${a.number} instead of requested PR #${t.issueNumber}`);let o=yl(a.head.sha,`Current PR head`),s=yl(a.base.sha,`Current PR base`);if(o!==i)throw Error(`Report head ${n.headRevision} is stale; current PR head is ${a.head.sha}`);if(s!==r)throw Error(`Report base ${n.baseRevision} is stale; current PR base is ${a.base.sha}`);return a}async function vl(e,t,n,r,i){if(await _l(e,t,n),!n.contentDigest)throw Error("GitHub report publishing requires an image-bound contentDigest; run `kapture report build` first");let a=Kc(n),o=n.summary.changed+n.summary.added+n.summary.removed,s=n.summary.errors>0?`error`:o>0?`changed`:`clean`,c={version:2,baseSha:n.baseRevision.toLowerCase(),headSha:n.headRevision.toLowerCase(),digest:a,status:s,reportUrl:i},l=s===`error`?`failure`:s===`changed`?`pending`:`success`,u=s===`error`?`${n.summary.errors} visual capture error(s)`:s===`changed`?`${o} visual change(s) require approval`:`No visual changes`;await e.setReviewStatus(t.headSha,`pending`,`Publishing verified visual report`,r,i);let d=await e.postOrUpdateReportComment(t.issueNumber,Yc(n,c,r));return await e.setReviewStatus(t.headSha,l,u,r,i),{status:s,changedCount:o,commentId:d,reportDigest:a}}function yl(e,t){if(!Zc(e))throw Error(`${t} ${e} must be a full 40-character SHA`);return e.toLowerCase()}async function bl(e,t,n){await e.assertWritePermission(t.sender);let r=await e.getPullRequest(t.issueNumber),i=yl(r.base.sha,`Current PR base`),a=yl(r.head.sha,`Current PR head`);if(r.number!==t.issueNumber||a!==t.headSha)throw Error(`Approval SHA ${t.headSha} is stale; current PR head is ${r.head.sha}`);let o=await e.findCurrentReportMarker(t.issueNumber,i,a);if(!o)throw Error(`No Kapture report exists for current base ${i} and head ${a}`);if(o.status!==`changed`)throw Error(`Kapture report for ${t.headSha} is not eligible for approval (${o.status})`);if(o.digest!==t.reportDigest)throw Error(`Approval digest ${t.reportDigest} does not match current report ${o.digest}`);await e.setReviewStatus(t.headSha,`pending`,`Applying approval by @${t.sender}`,n,o.reportUrl);let s=await e.findCurrentReportMarker(t.issueNumber,i,a);if(!s||s.digest!==t.reportDigest||s.status!==`changed`)throw Error(`Kapture report changed while approval was being applied; retry approval`);return await e.setReviewStatus(t.headSha,`success`,`Approved by @${t.sender}`,n,o.reportUrl),await e.createIssueComment(t.issueNumber,`✅ @${t.sender} 님이 Kapture 리포트 \`${o.digest.slice(0,12)}\`를 승인했습니다.`),{status:`approved`,reportDigest:o.digest}}async function xl(e){let t=process.env.GITHUB_OUTPUT;if(!t)return;let n=[];for(let[t,r]of Object.entries(e)){let e=String(r),i=`kapture_${ae()}`;n.push(`${t}<<${i}\n${e}\n${i}\n`)}await p(t,n.join(``),`utf8`)}const Sl=D({meta:{name:`approve`,description:`Approve the current full-SHA Kapture report`},args:{"status-context":{type:`string`,default:`Kapture Visual Review`,description:`GitHub commit status context`}},async run({args:e}){try{let t=process.env.GITHUB_TOKEN;if(!t)throw Error(`GITHUB_TOKEN is required`);let n=dl(await ll()),r=await bl(new cl(t,n.repository),n,$c(e[`status-context`]));await xl({status:r.status,"report-digest":r.reportDigest})}catch(e){throw await xl({status:`error`}),e}}}),Cl=10485760,wl=R().max(4096),H=R().min(1).max(512),Tl=B().int().min(0).max(2**53-1),El=B().min(0).max(1),Dl=as({name:H,width:B().int().positive().max(16384),height:B().int().positive().max(16384)}),Ol=as({pixel:El,ratio:El}),kl=as({id:H,browser:H,browserVersion:H,orchestratorRuntime:H,operatingSystem:H,architecture:H,deviceScaleFactor:B().positive().max(8),locale:H,timezone:H,colorScheme:ps([`light`,`dark`]),reducedMotion:ps([`reduce`,`no-preference`]),frozenTime:H,randomSeed:B().int().min(0).max(2**53-1),fontsFingerprint:H,network:as({mode:hs(`allowlist`),allowedDomains:rs(H).max(100),webRtc:hs(`disabled`)})}),Al=as({id:H,storyId:H,title:wl,name:wl,viewport:Dl,status:ps([`unchanged`,`changed`,`added`,`removed`,`error`]),baseImage:wl.optional(),headImage:wl.optional(),diffImage:wl.optional(),changedPixels:Tl.optional(),diffRatio:El.optional(),threshold:Ol.optional(),error:wl.optional()}),jl=as({version:hs(1),contentDigest:R().regex(/^[0-9a-f]{64}$/).optional(),baseRevision:H,headRevision:H,environment:kl,createdAt:H,threshold:Ol,summary:as({total:Tl,unchanged:Tl,changed:Tl,added:Tl,removed:Tl,errors:Tl}),entries:ds(R(),Al)}).superRefine((e,t)=>{let n=Object.entries(e.entries);if(n.length>2e4){t.addIssue({code:`custom`,message:`Report contains more than 20000 entries`,path:[`entries`]});return}for(let[e,r]of n)e!==r.id&&t.addIssue({code:`custom`,message:`Entry key must match entry.id`,path:[`entries`,e,`id`]});let r={unchanged:0,changed:0,added:0,removed:0,error:0};for(let t of Object.values(e.entries))r[t.status]+=1;(e.summary.total!==n.length||e.summary.unchanged!==r.unchanged||e.summary.changed!==r.changed||e.summary.added!==r.added||e.summary.removed!==r.removed||e.summary.errors!==r.error)&&t.addIssue({code:`custom`,message:`Report summary does not match its entries`,path:[`summary`]})});function Ml(e){let t=jl.safeParse(e);if(!t.success){let e=t.error.issues[0],n=e?.path.length?` at ${e.path.join(`.`)}`:``;throw Error(`Invalid Kapture report${n}: ${e?.message??`unknown error`}`)}return t.data}async function Nl(e){let t=d(e),n=await re(t);if(!n.isFile()||n.size>10485760)throw Error(`Kapture report must be a file no larger than ${Cl} bytes`);let r;try{r=JSON.parse(await y(t,`utf8`))}catch{throw Error(`Kapture report does not contain valid JSON`)}return Ml(r)}const Pl=D({meta:{name:`report`,description:`Publish a trusted Kapture PR report and commit status`},args:{report:{type:`string`,required:!0,description:`Path to image-bound trusted report.json`},"report-url":{type:`string`,description:`HTTPS URL for the full report or workflow run`},"status-context":{type:`string`,default:`Kapture Visual Review`,description:`GitHub commit status context`}},async run({args:e}){try{let t=process.env.GITHUB_TOKEN;if(!t)throw Error(`GITHUB_TOKEN is required`);let n=await Nl(e.report),r=ul(await ll()),i=$c(e[`status-context`]),a=Qc(e[`report-url`]),o=await vl(new cl(t,r.repository),r,n,i,a);if(await xl({status:o.status,"changed-count":o.changedCount,"comment-id":o.commentId,"report-digest":o.reportDigest}),o.status===`error`)throw Error(`${n.summary.errors} visual capture error(s)`)}catch(e){throw await xl({status:`error`}),e}}}),Fl=D({meta:{name:`github`,description:`Verify, publish, and approve GitHub visual reviews`},subCommands:{verify:D({meta:{name:`verify`,description:`Verify that a Kapture report matches the current pull request`},args:{report:{type:`string`,required:!0,description:`Path to untrusted report.json`}},async run({args:e}){let t=process.env.GITHUB_TOKEN;if(!t)throw Error(`GITHUB_TOKEN is required`);let n=await Nl(e.report),r=ul(await ll());await _l(new cl(t,r.repository),r,n)}}),report:Pl,approve:Sl}}),U={silent:-1/0,fatal:0,error:0,warn:1,log:2,info:3,success:3,fail:3,ready:3,start:3,box:3,debug:4,trace:5,verbose:1/0},Il={silent:{level:-1},fatal:{level:U.fatal},error:{level:U.error},warn:{level:U.warn},log:{level:U.log},info:{level:U.info},success:{level:U.success},fail:{level:U.fail},ready:{level:U.info},start:{level:U.info},box:{level:U.info},debug:{level:U.debug},trace:{level:U.trace},verbose:{level:U.verbose}};function Ll(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function Rl(e,t,n=`.`,r){if(!Ll(t))return Rl(e,{},n,r);let i=Object.assign({},t);for(let t in e){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:Ll(a)&&Ll(i[t])?Rl(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function zl(e){return(...t)=>t.reduce((t,n)=>Rl(t,n,``,e),{})}const Bl=zl();function Vl(e){return Object.prototype.toString.call(e)===`[object Object]`}function Hl(e){return!(!Vl(e)||!e.message&&!e.args||e.stack)}let Ul=!1;const Wl=[];var W=class e{options;_lastLog;_mockFn;constructor(e={}){let t=e.types||Il;this.options=Bl({...e,defaults:{...e.defaults},level:Gl(e.level,t),reporters:[...e.reporters||[]]},{types:Il,throttle:1e3,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}});for(let e in t){let n={type:e,...this.options.defaults,...t[e]};this[e]=this._wrapLogFn(n),this[e].raw=this._wrapLogFn(n,!0)}this.options.mockFn&&this.mockTypes(),this._lastLog={}}get level(){return this.options.level}set level(e){this.options.level=Gl(e,this.options.types,this.options.level)}prompt(e,t){if(!this.options.prompt)throw Error(`prompt is not supported!`);return this.options.prompt(e,t)}create(t){let n=new e({...this.options,...t});return this._mockFn&&n.mockTypes(this._mockFn),n}withDefaults(e){return this.create({...this.options,defaults:{...this.options.defaults,...e}})}withTag(e){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+`:`+e:e})}addReporter(e){return this.options.reporters.push(e),this}removeReporter(e){if(e){let t=this.options.reporters.indexOf(e);if(t!==-1)return this.options.reporters.splice(t,1)}else this.options.reporters.splice(0);return this}setReporters(e){return this.options.reporters=Array.isArray(e)?e:[e],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(let e in this.options.types)console[`__`+e]||(console[`__`+e]=console[e]),console[e]=this[e].raw}restoreConsole(){for(let e in this.options.types)console[`__`+e]&&(console[e]=console[`__`+e],delete console[`__`+e])}wrapStd(){this._wrapStream(this.options.stdout,`log`),this._wrapStream(this.options.stderr,`log`)}_wrapStream(e,t){e&&(e.__write||=e.write,e.write=e=>{this[t].raw(String(e).trim())})}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(e){e&&e.__write&&(e.write=e.__write,delete e.__write)}pauseLogs(){Ul=!0}resumeLogs(){Ul=!1;let e=Wl.splice(0);for(let t of e)t[0]._logFn(t[1],t[2])}mockTypes(e){let t=e||this.options.mockFn;if(this._mockFn=t,typeof t==`function`)for(let e in this.options.types)this[e]=t(e,this.options.types[e])||this[e],this[e].raw=this[e]}_wrapLogFn(e,t){return(...n)=>{if(Ul){Wl.push([this,e,n,t]);return}return this._logFn(e,n,t)}}_logFn(e,t,n){if((e.level||0)>this.level)return!1;let r={date:new Date,args:[],...e,level:Gl(e.level,this.options.types)};!n&&t.length===1&&Hl(t[0])?Object.assign(r,t[0]):r.args=[...t],r.message&&(r.args.unshift(r.message),delete r.message),r.additional&&(Array.isArray(r.additional)||(r.additional=r.additional.split(`
|
|
212
433
|
`)),r.args.push(`
|
|
213
434
|
`+r.additional.join(`
|
|
214
|
-
`)),delete r.additional),r.type=typeof r.type==`string`?r.type.toLowerCase():`log`,r.tag=typeof r.tag==`string`?r.tag:``;let i=(e=!1)=>{let t=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&t>0){let e=[...this._lastLog.object.args];t>1&&e.push(`(repeated ${t} times)`),this._log({...this._lastLog.object,args:e}),this._lastLog.count=1}e&&(this._lastLog.object=r,this._log(r))};clearTimeout(this._lastLog.timeout);let a=this._lastLog.time&&r.date?r.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=r.date,a<this.options.throttle)try{let e=JSON.stringify([r.type,r.tag,r.args]),t=this._lastLog.serialized===e;if(this._lastLog.serialized=e,t&&(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin)){this._lastLog.timeout=setTimeout(i,this.options.throttle);return}}catch{}i(!0)}_log(e){for(let t of this.options.reporters)t.log(e,{options:this.options})}};function
|
|
435
|
+
`)),delete r.additional),r.type=typeof r.type==`string`?r.type.toLowerCase():`log`,r.tag=typeof r.tag==`string`?r.tag:``;let i=(e=!1)=>{let t=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&t>0){let e=[...this._lastLog.object.args];t>1&&e.push(`(repeated ${t} times)`),this._log({...this._lastLog.object,args:e}),this._lastLog.count=1}e&&(this._lastLog.object=r,this._log(r))};clearTimeout(this._lastLog.timeout);let a=this._lastLog.time&&r.date?r.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=r.date,a<this.options.throttle)try{let e=JSON.stringify([r.type,r.tag,r.args]),t=this._lastLog.serialized===e;if(this._lastLog.serialized=e,t&&(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin)){this._lastLog.timeout=setTimeout(i,this.options.throttle);return}}catch{}i(!0)}_log(e){for(let t of this.options.reporters)t.log(e,{options:this.options})}};function Gl(e,t={},n=3){return e===void 0?n:typeof e==`number`?e:t[e]&&t[e].level!==void 0?t[e].level:n}W.prototype.add=W.prototype.addReporter,W.prototype.remove=W.prototype.removeReporter,W.prototype.clear=W.prototype.removeReporter,W.prototype.withScope=W.prototype.withTag,W.prototype.mock=W.prototype.mockTypes,W.prototype.pause=W.prototype.pauseLogs,W.prototype.resume=W.prototype.resumeLogs;function Kl(e={}){return new W(e)}function ql(e,t){let n=process.cwd()+f;return e.split(`
|
|
215
436
|
`).splice(t.split(`
|
|
216
|
-
`).length).map(e=>e.trim().replace(`file://`,``).replace(n,``))}function
|
|
437
|
+
`).length).map(e=>e.trim().replace(`file://`,``).replace(n,``))}function Jl(e,t){return(t.__write||t.write).call(t,e)}const Yl=e=>e?`[${e}]`:``;var Xl=class{formatStack(e,t,n){let r=` `.repeat((n?.errorLevel||0)+1);return r+ql(e,t).join(`
|
|
217
438
|
${r}`)}formatError(e,n){let r=e.message??t(n,e),i=e.stack?this.formatStack(e.stack,r,n):``,a=n?.errorLevel||0,o=a>0?`${` `.repeat(a)}[cause]: `:``,s=e.cause?`
|
|
218
439
|
|
|
219
440
|
`+this.formatError(e.cause,{...n,errorLevel:a+1}):``;return o+r+`
|
|
220
441
|
`+i+s}formatArgs(e,n){let r=e.map(e=>e&&typeof e.stack==`string`?this.formatError(e,n):e);return t(n,...r)}formatDate(e,t){return t.date?e.toLocaleTimeString():``}filterAndJoin(e){return e.filter(Boolean).join(` `)}formatLogObj(e,t){let n=this.formatArgs(e.args,t);return e.type===`box`?`
|
|
221
|
-
`+[
|
|
442
|
+
`+[Yl(e.tag),e.title&&e.title,...n.split(`
|
|
222
443
|
`)].filter(Boolean).map(e=>` > `+e).join(`
|
|
223
444
|
`)+`
|
|
224
|
-
`:this.filterAndJoin([
|
|
225
|
-
`,e.level<2?t.options.stderr||process.stderr:t.options.stdout||process.stdout)}};const{env:
|
|
226
|
-
`),i=[],a=
|
|
227
|
-
`)}var
|
|
445
|
+
`:this.filterAndJoin([Yl(e.type),Yl(e.tag),n])}log(e,t){return Jl(this.formatLogObj(e,{columns:t.options.stdout.columns||0,...t.options.formatOptions})+`
|
|
446
|
+
`,e.level<2?t.options.stderr||process.stderr:t.options.stdout||process.stdout)}};const{env:Zl={},argv:Ql=[],platform:$l=``}=typeof process>`u`?{}:process,eu=`NO_COLOR`in Zl||Ql.includes(`--no-color`),tu=`FORCE_COLOR`in Zl||Ql.includes(`--color`),nu=$l===`win32`,ru=Zl.TERM===`dumb`,iu=me&&me.isatty&&me.isatty(1)&&Zl.TERM&&!ru,au=`CI`in Zl&&(`GITHUB_ACTIONS`in Zl||`GITLAB_CI`in Zl||`CIRCLECI`in Zl),ou=!eu&&(tu||nu&&!ru||iu||au);function su(e,t,n,r,i=t.slice(0,Math.max(0,e))+r,a=t.slice(Math.max(0,e+n.length)),o=a.indexOf(n)){return i+(o<0?a:su(o,a,n,r))}function cu(e,t,n,r,i){return e<0?n+t+r:n+su(e,t,r,i)+r}function lu(e,t,n=e,r=e.length+1){return i=>i||i!==``&&i!==void 0?cu((``+i).indexOf(t,r),i,e,t,n):``}function G(e,t,n){return lu(`\x1B[${e}m`,`\x1B[${t}m`,n)}const uu={reset:G(0,0),bold:G(1,22,`\x1B[22m\x1B[1m`),dim:G(2,22,`\x1B[22m\x1B[2m`),italic:G(3,23),underline:G(4,24),inverse:G(7,27),hidden:G(8,28),strikethrough:G(9,29),black:G(30,39),red:G(31,39),green:G(32,39),yellow:G(33,39),blue:G(34,39),magenta:G(35,39),cyan:G(36,39),white:G(37,39),gray:G(90,39),bgBlack:G(40,49),bgRed:G(41,49),bgGreen:G(42,49),bgYellow:G(43,49),bgBlue:G(44,49),bgMagenta:G(45,49),bgCyan:G(46,49),bgWhite:G(47,49),blackBright:G(90,39),redBright:G(91,39),greenBright:G(92,39),yellowBright:G(93,39),blueBright:G(94,39),magentaBright:G(95,39),cyanBright:G(96,39),whiteBright:G(97,39),bgBlackBright:G(100,49),bgRedBright:G(101,49),bgGreenBright:G(102,49),bgYellowBright:G(103,49),bgBlueBright:G(104,49),bgMagentaBright:G(105,49),bgCyanBright:G(106,49),bgWhiteBright:G(107,49)};function du(e=ou){return e?uu:Object.fromEntries(Object.keys(uu).map(e=>[e,String]))}const K=du();function fu(e,t=`reset`){return K[e]||K[t]}const pu=[String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);function mu(e){return e.replace(new RegExp(pu,`g`),``)}const hu={solid:{tl:`┌`,tr:`┐`,bl:`└`,br:`┘`,h:`─`,v:`│`},double:{tl:`╔`,tr:`╗`,bl:`╚`,br:`╝`,h:`═`,v:`║`},doubleSingle:{tl:`╓`,tr:`╖`,bl:`╙`,br:`╜`,h:`─`,v:`║`},doubleSingleRounded:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`,h:`─`,v:`║`},singleThick:{tl:`┏`,tr:`┓`,bl:`┗`,br:`┛`,h:`━`,v:`┃`},singleDouble:{tl:`╒`,tr:`╕`,bl:`╘`,br:`╛`,h:`═`,v:`│`},singleDoubleRounded:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`,h:`═`,v:`│`},rounded:{tl:`╭`,tr:`╮`,bl:`╰`,br:`╯`,h:`─`,v:`│`}},gu={borderColor:`white`,borderStyle:`rounded`,valign:`center`,padding:2,marginLeft:1,marginTop:1,marginBottom:1};function _u(e,t={}){let n={...t,style:{...gu,...t.style}},r=e.split(`
|
|
447
|
+
`),i=[],a=fu(n.style.borderColor),o={...typeof n.style.borderStyle==`string`?hu[n.style.borderStyle]||hu.solid:n.style.borderStyle};if(a)for(let e in o)o[e]=a(o[e]);let s=n.style.padding%2==0?n.style.padding:n.style.padding+1,c=r.length+s,l=Math.max(...r.map(e=>mu(e).length),n.title?mu(n.title).length:0)+s,u=l+s,d=n.style.marginLeft>0?` `.repeat(n.style.marginLeft):``;if(n.style.marginTop>0&&i.push(``.repeat(n.style.marginTop)),n.title){let e=a?a(n.title):n.title,t=o.h.repeat(Math.floor((l-mu(n.title).length)/2)),r=o.h.repeat(l-mu(n.title).length-mu(t).length+s);i.push(`${d}${o.tl}${t}${e}${r}${o.tr}`)}else i.push(`${d}${o.tl}${o.h.repeat(u)}${o.tr}`);let f=n.style.valign===`center`?Math.floor((c-r.length)/2):n.style.valign===`top`?c-r.length-s:c-r.length;for(let e=0;e<c;e++)if(e<f||e>=f+r.length)i.push(`${d}${o.v}${` `.repeat(u)}${o.v}`);else{let t=r[e-f],n=` `.repeat(s),a=` `.repeat(l-mu(t).length);i.push(`${d}${o.v}${n}${t}${a}${o.v}`)}return i.push(`${d}${o.bl}${o.h.repeat(u)}${o.br}`),n.style.marginBottom>0&&i.push(``.repeat(n.style.marginBottom)),i.join(`
|
|
448
|
+
`)}var vu=ye({kCancel:()=>Vd,prompt:()=>Mu});function yu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function bu(){if(Pu)return Nu;Pu=1;let e={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};return Nu={cursor:e,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(t){let n=``;for(let r=0;r<t;r++)n+=this.line+(r<t-1?e.up():``);return t&&(n+=e.left),n}},beep:`\x07`},Nu}function xu(){if(Iu)return Fu.exports;Iu=1;let e=process||{},t=e.argv||[],n=e.env||{},r=!(n.NO_COLOR||t.includes(`--no-color`))&&(!!n.FORCE_COLOR||t.includes(`--color`)||e.platform===`win32`||(e.stdout||{}).isTTY&&n.TERM!==`dumb`||!!n.CI),i=(e,t,n=e)=>r=>{let i=``+r,o=i.indexOf(t,e.length);return~o?e+a(i,t,n,o)+t:e+i+t},a=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},o=(e=r)=>{let t=e?i:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};return Fu.exports=o(),Fu.exports.createColors=o,Fu.exports}function Su({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}function Cu(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Lu,``)}function wu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function Tu(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Cu(e),e.length===0))return 0;e=e.replace(Hu(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(Bu.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}function Eu(){let e=new Map;for(let[t,n]of Object.entries(Y)){for(let[t,r]of Object.entries(n))Y[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=Y[t],e.set(r[0],r[1]);Object.defineProperty(Y,t,{value:n,enumerable:!1})}return Object.defineProperty(Y,"codes",{value:e,enumerable:!1}),Y.color.close=`\x1B[39m`,Y.bgColor.close=`\x1B[49m`,Y.color.ansi=Wu(),Y.color.ansi256=Gu(),Y.color.ansi16m=Ku(),Y.bgColor.ansi=Wu(Uu),Y.bgColor.ansi256=Gu(Uu),Y.bgColor.ansi16m=Ku(Uu),Object.defineProperties(Y,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>Y.rgbToAnsi256(...Y.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>Y.ansi256ToAnsi(Y.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>Y.ansi256ToAnsi(Y.hexToAnsi256(e)),enumerable:!1}}),Y}function Du(e,t,n){return String(e).normalize().replace(/\r\n/g,`
|
|
228
449
|
`).split(`
|
|
229
|
-
`).map(e=>
|
|
230
|
-
`)}function
|
|
450
|
+
`).map(e=>cd(e,t,n)).join(`
|
|
451
|
+
`)}function Ou(e,t){if(typeof e==`string`)return ld.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Ou(n,t))return!0;return!1}function ku(e,t){if(e===t)return;let n=e.split(`
|
|
231
452
|
`),r=t.split(`
|
|
232
|
-
`),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}function su(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function cu(){return x.platform===`win32`?!!x.env.CI||!!x.env.WT_SESSION||!!x.env.TERMINUS_SUBLIME||x.env.ConEmuTask===`{cmd::Cmder}`||x.env.TERM_PROGRAM===`Terminus-Sublime`||x.env.TERM_PROGRAM===`vscode`||x.env.TERM===`xterm-256color`||x.env.TERM===`alacritty`||x.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:x.env.TERM!==`linux`}async function lu(e,t={}){let n=e=>{if(typeof e!=`symbol`||e.toString()!==`Symbol(clack:cancel)`)return e;switch(t.cancel){case`reject`:{let e=Error(`Prompt cancelled.`);throw e.name=`ConsolaPromptCancelledError`,Error.captureStackTrace&&Error.captureStackTrace(e,lu),e}case`undefined`:return;case`null`:return null;case`symbol`:return vd;default:case`default`:return t.default??t.initial}};if(!t.type||t.type===`text`)return await md({message:e,defaultValue:t.default,placeholder:t.placeholder,initialValue:t.initial}).then(n);if(t.type===`confirm`)return await hd({message:e,initialValue:t.initial}).then(n);if(t.type===`select`)return await gd({message:e,options:t.options.map(e=>typeof e==`string`?{value:e,label:e}:e),initialValue:t.initial}).then(n);if(t.type===`multiselect`)return await _d({message:e,options:t.options.map(e=>typeof e==`string`?{value:e,label:e}:e),required:t.required,initialValues:t.initial}).then(n);throw Error(`Unknown prompt type: ${t.type}`)}var uu,du,q,fu,pu,J,mu,hu,gu,_u,vu,yu,bu,xu,Su,Cu,Y,wu,Tu,Eu,Du,Ou,ku,Au,ju,Mu,Nu,Pu,Fu,Iu,Lu,Ru,zu,Bu,Vu,Hu,Uu,X,Wu,Gu,Ku,qu,Ju,Yu,Xu,Zu,Qu,$u,ed,td,Z,nd,rd,id,ad,Q,od,sd,cd,ld,ud,dd,fd,pd,md,hd,gd,_d,vd,yd=fe((()=>{q=Zl(),fu={exports:{}},J=Xl(Ql()),mu=$l(),hu={exports:{}},(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-+(u==2)){if(o+u<=i)a+=l;else break}o+=u}return a}})(hu),gu=hu.exports,_u=tu(gu),vu=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},yu=tu(vu),bu=10,xu=(e=0)=>t=>`\x1B[${t+e}m`,Su=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Cu=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,Y={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Object.keys(Y.modifier),wu=Object.keys(Y.color),Tu=Object.keys(Y.bgColor),[...wu,...Tu],Eu=ru(),Du=new Set([`\x1B`,``]),Ou=39,ku=`\x07`,Au=`[`,ju=`]`,Mu=`m`,Nu=`${ju}8;;`,Pu=e=>`${Du.values().next().value}${Au}${e}${Mu}`,Fu=e=>`${Du.values().next().value}${Nu}${e}${ku}`,Iu=e=>e.split(` `).map(e=>nu(e)),Lu=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=nu(eu(e[e.length-1]));for(let[t,s]of r.entries()){let c=nu(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),Du.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(Nu)),i){a?s===ku&&(i=!1,a=!1):s===Mu&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Ru=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(nu(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},zu=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=Iu(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=nu(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),Lu(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){Lu(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){Lu(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>Ru(e)));let c=[...s.join(`
|
|
233
|
-
`)];for(let[e,t]of c.entries()){if(r+=t,
|
|
234
|
-
`?(a&&(r+=
|
|
235
|
-
`&&(i&&n&&(r+=
|
|
236
|
-
`),
|
|
237
|
-
`).length-1;this.output.write(q.cursor.move(-999,e*-1))}render(){let e=
|
|
453
|
+
`),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}function Au(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function ju(){return S.platform===`win32`?!!S.env.CI||!!S.env.WT_SESSION||!!S.env.TERMINUS_SUBLIME||S.env.ConEmuTask===`{cmd::Cmder}`||S.env.TERM_PROGRAM===`Terminus-Sublime`||S.env.TERM_PROGRAM===`vscode`||S.env.TERM===`xterm-256color`||S.env.TERM===`alacritty`||S.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:S.env.TERM!==`linux`}async function Mu(e,t={}){let n=e=>{if(typeof e!=`symbol`||e.toString()!==`Symbol(clack:cancel)`)return e;switch(t.cancel){case`reject`:{let e=Error(`Prompt cancelled.`);throw e.name=`ConsolaPromptCancelledError`,Error.captureStackTrace&&Error.captureStackTrace(e,Mu),e}case`undefined`:return;case`null`:return null;case`symbol`:return Vd;default:case`default`:return t.default??t.initial}};if(!t.type||t.type===`text`)return await Ld({message:e,defaultValue:t.default,placeholder:t.placeholder,initialValue:t.initial}).then(n);if(t.type===`confirm`)return await Rd({message:e,initialValue:t.initial}).then(n);if(t.type===`select`)return await zd({message:e,options:t.options.map(e=>typeof e==`string`?{value:e,label:e}:e),initialValue:t.initial}).then(n);if(t.type===`multiselect`)return await Bd({message:e,options:t.options.map(e=>typeof e==`string`?{value:e,label:e}:e),required:t.required,initialValues:t.initial}).then(n);throw Error(`Unknown prompt type: ${t.type}`)}var Nu,Pu,q,Fu,Iu,J,Lu,Ru,zu,Bu,Vu,Hu,Uu,Wu,Gu,Ku,Y,qu,Ju,Yu,Xu,Zu,Qu,$u,ed,td,nd,rd,id,ad,od,sd,cd,ld,ud,dd,fd,X,pd,md,hd,gd,_d,vd,yd,bd,xd,Sd,Cd,wd,Z,Td,Ed,Dd,Od,Q,kd,Ad,jd,Md,Nd,Pd,Fd,Id,Ld,Rd,zd,Bd,Vd,Hd=ve((()=>{q=bu(),Fu={exports:{}},J=yu(xu()),Lu=Su(),Ru={exports:{}},(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-+(u==2)){if(o+u<=i)a+=l;else break}o+=u}return a}})(Ru),zu=Ru.exports,Bu=wu(zu),Vu=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},Hu=wu(Vu),Uu=10,Wu=(e=0)=>t=>`\x1B[${t+e}m`,Gu=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Ku=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,Y={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Object.keys(Y.modifier),qu=Object.keys(Y.color),Ju=Object.keys(Y.bgColor),[...qu,...Ju],Yu=Eu(),Xu=new Set([`\x1B`,``]),Zu=39,Qu=`\x07`,$u=`[`,ed=`]`,td=`m`,nd=`${ed}8;;`,rd=e=>`${Xu.values().next().value}${$u}${e}${td}`,id=e=>`${Xu.values().next().value}${nd}${e}${Qu}`,ad=e=>e.split(` `).map(e=>Tu(e)),od=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=Tu(Cu(e[e.length-1]));for(let[t,s]of r.entries()){let c=Tu(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),Xu.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(nd)),i){a?s===Qu&&(i=!1,a=!1):s===td&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},sd=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(Tu(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},cd=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=ad(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=Tu(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),od(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){od(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){od(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>sd(e)));let c=[...s.join(`
|
|
454
|
+
`)];for(let[e,t]of c.entries()){if(r+=t,Xu.has(t)){let{groups:t}=RegExp(`(?:\\${$u}(?<code>\\d+)m|\\${nd}(?<uri>.*)${Qu})`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===Zu?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=Yu.codes.get(Number(i));c[e+1]===`
|
|
455
|
+
`?(a&&(r+=id(``)),i&&n&&(r+=rd(n))):t===`
|
|
456
|
+
`&&(i&&n&&(r+=rd(i)),a&&(r+=id(a)))}return r},ld={actions:new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]])},globalThis.process.platform.startsWith(`win`),ud=Symbol(`clack:cancel`),dd=Object.defineProperty,fd=(e,t,n)=>t in e?dd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,X=(e,t,n)=>(fd(e,typeof t==`symbol`?t:t+``,n),n),pd=class{constructor(e,t=!0){X(this,`input`),X(this,`output`),X(this,`_abortSignal`),X(this,`rl`),X(this,`opts`),X(this,`_render`),X(this,`_track`,!1),X(this,`_prevFrame`,``),X(this,`_subscribers`,new Map),X(this,`_cursor`,0),X(this,`state`,`initial`),X(this,`error`,``),X(this,`value`);let{input:n=fe,output:r=pe,render:i,signal:a,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise((e,t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(ud);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}let n=new he(0);n._write=(e,t,n)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,``),this._cursor=this.rl?.cursor??0,this.emit(`value`,this.value)),n()},this.input.pipe(n),this.rl=ge.createInterface({input:this.input,output:n,tabSize:2,prompt:``,escapeCodeTimeout:50}),ge.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on(`keypress`,this.onKeypress),Au(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(q.cursor.show),this.output.off(`resize`,this.render),Au(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(q.cursor.show),this.output.off(`resize`,this.render),Au(this.input,!1),e(ud)})})}onKeypress(e,t){if(this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&ld.aliases.has(t.name)&&this.emit(`cursor`,ld.aliases.get(t.name)),ld.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),e===` `&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit(`value`,this.opts.placeholder))),e&&this.emit(`key`,e.toLowerCase()),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state=`error`,this.rl?.write(this.value))}this.state!==`error`&&(this.state=`submit`)}Ou([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
|
|
457
|
+
`),Au(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Du(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
458
|
+
`).length-1;this.output.write(q.cursor.move(-999,e*-1))}render(){let e=Du(this._render(this)??``,process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(q.cursor.hide);else{let t=ku(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(q.cursor.move(0,n)),this.output.write(q.erase.lines(1));let r=e.split(`
|
|
238
459
|
`);this.output.write(r[n]),this._prevFrame=e,this.output.write(q.cursor.move(0,r.length-n-1));return}if(t&&t?.length>1){let n=t[0];this.output.write(q.cursor.move(0,n)),this.output.write(q.erase.down());let r=e.split(`
|
|
239
460
|
`).slice(n);this.output.write(r.join(`
|
|
240
|
-
`)),this._prevFrame=e;return}this.output.write(q.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},
|
|
241
|
-
${
|
|
461
|
+
`)),this._prevFrame=e;return}this.output.write(q.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},md=class extends pd{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`value`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(q.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},hd=Object.defineProperty,gd=(e,t,n)=>t in e?hd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_d=(e,t,n)=>(gd(e,typeof t==`symbol`?t:t+``,n),n),vd=class extends pd{constructor(e){super(e,!1),_d(this,`options`),_d(this,`cursor`,0),this.options=e.options,this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`key`,e=>{e===`a`&&this.toggleAll()}),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue()}})}get _value(){return this.options[this.cursor].value}toggleAll(){let e=this.value.length===this.options.length;this.value=e?[]:this.options.map(e=>e.value)}toggleValue(){let e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}},yd=Object.defineProperty,bd=(e,t,n)=>t in e?yd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xd=(e,t,n)=>(bd(e,typeof t==`symbol`?t:t+``,n),n),Sd=class extends pd{constructor(e){super(e,!1),xd(this,`options`),xd(this,`cursor`,0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},Cd=class extends pd{get valueWithCursor(){if(this.state===`submit`)return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let e=this.value.slice(0,this.cursor),[t,...n]=this.value.slice(this.cursor);return`${e}${J.inverse(t)}${n.join(``)}`}get cursor(){return this._cursor}constructor(e){super(e),this.on(`finalize`,()=>{this.value||=e.defaultValue})}},wd=ju(),Z=(e,t)=>wd?e:t,Td=Z(`❯`,`>`),Ed=Z(`■`,`x`),Dd=Z(`▲`,`x`),Od=Z(`✔`,`√`),Q=Z(``),kd=Z(``),Ad=Z(`●`,`>`),jd=Z(`○`,` `),Md=Z(`◻`,`[•]`),Nd=Z(`◼`,`[+]`),Pd=Z(`◻`,`[ ]`),Fd=e=>{switch(e){case`initial`:case`active`:return J.cyan(Td);case`cancel`:return J.red(Ed);case`error`:return J.yellow(Dd);case`submit`:return J.green(Od)}},Id=e=>{let{cursor:t,options:n,style:r}=e,i=e.maxItems??1/0,a=Math.max(process.stdout.rows-4,0),o=Math.min(a,Math.max(i,5)),s=0;t>=s+o-3?s=Math.max(Math.min(t-o+3,n.length-o),0):t<s+2&&(s=Math.max(t-2,0));let c=o<n.length&&s>0,l=o<n.length&&s+o<n.length;return n.slice(s,s+o).map((e,n,i)=>{let a=n===0&&c,o=n===i.length-1&&l;return a||o?J.dim(`...`):r(e,n+s===t)})},Ld=e=>new Cd({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${J.gray(Q)}
|
|
462
|
+
${Fd(this.state)} ${e.message}
|
|
242
463
|
`,n=e.placeholder?J.inverse(e.placeholder[0])+J.dim(e.placeholder.slice(1)):J.inverse(J.hidden(`_`)),r=this.value?this.valueWithCursor:n;switch(this.state){case`error`:return`${t.trim()}
|
|
243
464
|
${J.yellow(Q)} ${r}
|
|
244
|
-
${J.yellow(
|
|
465
|
+
${J.yellow(kd)} ${J.yellow(this.error)}
|
|
245
466
|
`;case`submit`:return`${t}${J.gray(Q)} ${J.dim(this.value||e.placeholder)}`;case`cancel`:return`${t}${J.gray(Q)} ${J.strikethrough(J.dim(this.value??``))}${this.value?.trim()?`
|
|
246
467
|
${J.gray(Q)}`:``}`;default:return`${t}${J.cyan(Q)} ${r}
|
|
247
|
-
${J.cyan(
|
|
248
|
-
`}}}).prompt(),
|
|
249
|
-
${
|
|
468
|
+
${J.cyan(kd)}
|
|
469
|
+
`}}}).prompt(),Rd=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new md({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${J.gray(Q)}
|
|
470
|
+
${Fd(this.state)} ${e.message}
|
|
250
471
|
`,i=this.value?t:n;switch(this.state){case`submit`:return`${r}${J.gray(Q)} ${J.dim(i)}`;case`cancel`:return`${r}${J.gray(Q)} ${J.strikethrough(J.dim(i))}
|
|
251
|
-
${J.gray(Q)}`;default:return`${r}${J.cyan(Q)} ${this.value?`${J.green(
|
|
252
|
-
${J.cyan(
|
|
253
|
-
`}}}).prompt()},
|
|
254
|
-
${
|
|
472
|
+
${J.gray(Q)}`;default:return`${r}${J.cyan(Q)} ${this.value?`${J.green(Ad)} ${t}`:`${J.dim(jd)} ${J.dim(t)}`} ${J.dim(`/`)} ${this.value?`${J.dim(jd)} ${J.dim(n)}`:`${J.green(Ad)} ${n}`}
|
|
473
|
+
${J.cyan(kd)}
|
|
474
|
+
`}}}).prompt()},zd=e=>{let t=(e,t)=>{let n=e.label??String(e.value);switch(t){case`selected`:return`${J.dim(n)}`;case`active`:return`${J.green(Ad)} ${n} ${e.hint?J.dim(`(${e.hint})`):``}`;case`cancelled`:return`${J.strikethrough(J.dim(n))}`;default:return`${J.dim(jd)} ${J.dim(n)}`}};return new Sd({options:e.options,initialValue:e.initialValue,render(){let n=`${J.gray(Q)}
|
|
475
|
+
${Fd(this.state)} ${e.message}
|
|
255
476
|
`;switch(this.state){case`submit`:return`${n}${J.gray(Q)} ${t(this.options[this.cursor],`selected`)}`;case`cancel`:return`${n}${J.gray(Q)} ${t(this.options[this.cursor],`cancelled`)}
|
|
256
|
-
${J.gray(Q)}`;default:return`${n}${J.cyan(Q)} ${
|
|
477
|
+
${J.gray(Q)}`;default:return`${n}${J.cyan(Q)} ${Id({cursor:this.cursor,options:this.options,maxItems:e.maxItems,style:(e,n)=>t(e,n?`active`:`inactive`)}).join(`
|
|
257
478
|
${J.cyan(Q)} `)}
|
|
258
|
-
${J.cyan(
|
|
259
|
-
`}}}).prompt()},
|
|
479
|
+
${J.cyan(kd)}
|
|
480
|
+
`}}}).prompt()},Bd=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${J.cyan(Md)} ${n} ${e.hint?J.dim(`(${e.hint})`):``}`:t===`selected`?`${J.green(Nd)} ${J.dim(n)}`:t===`cancelled`?`${J.strikethrough(J.dim(n))}`:t===`active-selected`?`${J.green(Nd)} ${n} ${e.hint?J.dim(`(${e.hint})`):``}`:t===`submitted`?`${J.dim(n)}`:`${J.dim(Pd)} ${J.dim(n)}`};return new vd({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
|
|
260
481
|
${J.reset(J.dim(`Press ${J.gray(J.bgWhite(J.inverse(` space `)))} to select, ${J.gray(J.bgWhite(J.inverse(` enter `)))} to submit`))}`},render(){let n=`${J.gray(Q)}
|
|
261
|
-
${
|
|
482
|
+
${Fd(this.state)} ${e.message}
|
|
262
483
|
`,r=(e,n)=>{let r=this.value.includes(e.value);return n&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,n?`active`:`inactive`)};switch(this.state){case`submit`:return`${n}${J.gray(Q)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`submitted`)).join(J.dim(`, `))||J.dim(`none`)}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`cancelled`)).join(J.dim(`, `));return`${n}${J.gray(Q)} ${e.trim()?`${e}
|
|
263
484
|
${J.gray(Q)}`:``}`}case`error`:{let t=this.error.split(`
|
|
264
|
-
`).map((e,t)=>t===0?`${J.yellow(
|
|
265
|
-
`);return`${n+J.yellow(Q)} ${
|
|
485
|
+
`).map((e,t)=>t===0?`${J.yellow(kd)} ${J.yellow(e)}`:` ${e}`).join(`
|
|
486
|
+
`);return`${n+J.yellow(Q)} ${Id({options:this.options,cursor:this.cursor,maxItems:e.maxItems,style:r}).join(`
|
|
266
487
|
${J.yellow(Q)} `)}
|
|
267
488
|
${t}
|
|
268
|
-
`}default:return`${n}${J.cyan(Q)} ${
|
|
489
|
+
`}default:return`${n}${J.cyan(Q)} ${Id({options:this.options,cursor:this.cursor,maxItems:e.maxItems,style:r}).join(`
|
|
269
490
|
${J.cyan(Q)} `)}
|
|
270
|
-
${J.cyan(
|
|
271
|
-
`}}}).prompt()},`${J.gray(Q)}`,vd=Symbol.for(`cancel`)}));const bd=Object.create(null),xd=e=>globalThis.process?.env||import.meta.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?bd:globalThis),Sd=new Proxy(bd,{get(e,t){return xd()[t]??bd[t]},has(e,t){return t in xd()||t in bd},set(e,t,n){let r=xd(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=xd(!0);return delete n[t],!0},ownKeys(){let e=xd(!0);return Object.keys(e)}}),Cd=typeof process<`u`&&process.env&&process.env.NODE_ENV||``,wd=[[`APPVEYOR`],[`AWS_AMPLIFY`,`AWS_APP_ID`,{ci:!0}],[`AZURE_PIPELINES`,`SYSTEM_TEAMFOUNDATIONCOLLECTIONURI`],[`AZURE_STATIC`,`INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN`],[`APPCIRCLE`,`AC_APPCIRCLE`],[`BAMBOO`,`bamboo_planKey`],[`BITBUCKET`,`BITBUCKET_COMMIT`],[`BITRISE`,`BITRISE_IO`],[`BUDDY`,`BUDDY_WORKSPACE_ID`],[`BUILDKITE`],[`CIRCLE`,`CIRCLECI`],[`CIRRUS`,`CIRRUS_CI`],[`CLOUDFLARE_PAGES`,`CF_PAGES`,{ci:!0}],[`CODEBUILD`,`CODEBUILD_BUILD_ARN`],[`CODEFRESH`,`CF_BUILD_ID`],[`DRONE`],[`DRONE`,`DRONE_BUILD_EVENT`],[`DSARI`],[`GITHUB_ACTIONS`],[`GITLAB`,`GITLAB_CI`],[`GITLAB`,`CI_MERGE_REQUEST_ID`],[`GOCD`,`GO_PIPELINE_LABEL`],[`LAYERCI`],[`HUDSON`,`HUDSON_URL`],[`JENKINS`,`JENKINS_URL`],[`MAGNUM`],[`NETLIFY`],[`NETLIFY`,`NETLIFY_LOCAL`,{ci:!1}],[`NEVERCODE`],[`RENDER`],[`SAIL`,`SAILCI`],[`SEMAPHORE`],[`SCREWDRIVER`],[`SHIPPABLE`],[`SOLANO`,`TDDIUM`],[`STRIDER`],[`TEAMCITY`,`TEAMCITY_VERSION`],[`TRAVIS`],[`VERCEL`,`NOW_BUILDER`],[`VERCEL`,`VERCEL`,{ci:!1}],[`VERCEL`,`VERCEL_ENV`,{ci:!1}],[`APPCENTER`,`APPCENTER_BUILD_ID`],[`CODESANDBOX`,`CODESANDBOX_SSE`,{ci:!1}],[`CODESANDBOX`,`CODESANDBOX_HOST`,{ci:!1}],[`STACKBLITZ`],[`STORMKIT`],[`CLEAVR`],[`ZEABUR`],[`CODESPHERE`,`CODESPHERE_APP_ID`,{ci:!0}],[`RAILWAY`,`RAILWAY_PROJECT_ID`],[`RAILWAY`,`RAILWAY_SERVICE_ID`],[`DENO-DEPLOY`,`DENO_DEPLOYMENT_ID`],[`FIREBASE_APP_HOSTING`,`FIREBASE_APP_HOSTING`,{ci:!0}]];function Td(){if(globalThis.process?.env)for(let e of wd){let t=e[1]||e[0];if(globalThis.process?.env[t])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL===`/bin/jsh`&&globalThis.process?.versions?.webcontainer?{name:`stackblitz`,ci:!1}:{name:``,ci:!1}}const Ed=Td();Ed.name;function Dd(e){return e?e!==`false`:!1}const Od=globalThis.process?.platform||``,kd=Dd(Sd.CI)||Ed.ci!==!1,Ad=Dd(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY),jd=Dd(Sd.DEBUG),Md=Cd===`test`||Dd(Sd.TEST);Sd.MINIMAL;const Nd=/^win/i.test(Od);!Dd(Sd.NO_COLOR)&&(Dd(Sd.FORCE_COLOR)||(Ad||Nd)&&Sd.TERM);const Pd=(globalThis.process?.versions?.node||``).replace(/^v/,``)||null;Number(Pd?.split(`.`)[0]);const Fd=globalThis.process||Object.create(null),Id={versions:{}};new Proxy(Fd,{get(e,t){if(t===`env`)return Sd;if(t in e)return e[t];if(t in Id)return Id[t]}});const Ld=globalThis.process?.release?.name===`node`,Rd=!!globalThis.Bun||!!globalThis.process?.versions?.bun,zd=!!globalThis.Deno,Bd=!!globalThis.fastly,Vd=!!globalThis.Netlify,Hd=!!globalThis.EdgeRuntime,Ud=globalThis.navigator?.userAgent===`Cloudflare-Workers`,Wd=[[Vd,`netlify`],[Hd,`edge-light`],[Ud,`workerd`],[Bd,`fastly`],[zd,`deno`],[Rd,`bun`],[Ld,`node`]];function Gd(){let e=Wd.find(e=>e[0]);if(e)return{name:e[1]}}Gd()?.name;function Kd({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}const qd=Kd();function Jd(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(qd,``)}function Yd(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}function Xd(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function Zd(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101631&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129673||e>=129679&&e<=129734||e>=129742&&e<=129756||e>=129759&&e<=129769||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}function Qd(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function $d(e,{ambiguousAsWide:t=!1}={}){return Qd(e),Xd(e)||Zd(e)||t&&Yd(e)?2:1}const ef=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,tf=globalThis.Intl?.Segmenter?new Intl.Segmenter:{segment:e=>e.split(``)},nf=/^\p{Default_Ignorable_Code_Point}$/u;function rf(e,t={}){if(typeof e!=`string`||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t;if(r||(e=Jd(e)),e.length===0)return 0;let i=0,a={ambiguousAsWide:!n};for(let{segment:t}of tf.segment(e)){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159)&&!(e>=8203&&e<=8207||e===65279)&&!(e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071)&&!(e>=55296&&e<=57343)&&!(e>=65024&&e<=65039)&&!nf.test(t)){if(ef().test(t)){i+=2;continue}i+=$d(e,a)}}return i}function af(){let{env:e}=x,{TERM:t,TERM_PROGRAM:n}=e;return x.platform===`win32`?!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask===`{cmd::Cmder}`||n===`Terminus-Sublime`||n===`vscode`||t===`xterm-256color`||t===`alacritty`||t===`rxvt-unicode`||t===`rxvt-unicode-256color`||e.TERMINAL_EMULATOR===`JetBrains-JediTerm`:t!==`linux`}const of={info:`cyan`,fail:`red`,success:`green`,ready:`green`,start:`magenta`},sf={0:`red`,1:`yellow`},cf=af(),$=(e,t)=>cf?e:t,lf={error:$(`✖`,`×`),fatal:$(`✖`,`×`),ready:$(`✔`,`√`),warn:$(`⚠`,`‼`),info:$(`ℹ`,`i`),success:$(`✔`,`√`),debug:$(`⚙`,`D`),trace:$(`→`,`→`),fail:$(`✖`,`×`),start:$(`◐`,`o`),log:``};function uf(e){return typeof Intl!=`object`||!Intl.Segmenter?Gl(e).length:rf(e)}var df=class extends Dl{formatStack(e,t,n){let r=` `.repeat((n?.errorLevel||0)+1);return`
|
|
272
|
-
${r}`+
|
|
273
|
-
${r}`)}formatType(e,t,n){let r=
|
|
274
|
-
`);if(e.type===`box`)return
|
|
491
|
+
${J.cyan(kd)}
|
|
492
|
+
`}}}).prompt()},`${J.gray(Q)}`,Vd=Symbol.for(`cancel`)}));const Ud=Object.create(null),Wd=e=>globalThis.process?.env||import.meta.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?Ud:globalThis),Gd=new Proxy(Ud,{get(e,t){return Wd()[t]??Ud[t]},has(e,t){return t in Wd()||t in Ud},set(e,t,n){let r=Wd(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=Wd(!0);return delete n[t],!0},ownKeys(){let e=Wd(!0);return Object.keys(e)}}),Kd=typeof process<`u`&&process.env&&process.env.NODE_ENV||``,qd=[[`APPVEYOR`],[`AWS_AMPLIFY`,`AWS_APP_ID`,{ci:!0}],[`AZURE_PIPELINES`,`SYSTEM_TEAMFOUNDATIONCOLLECTIONURI`],[`AZURE_STATIC`,`INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN`],[`APPCIRCLE`,`AC_APPCIRCLE`],[`BAMBOO`,`bamboo_planKey`],[`BITBUCKET`,`BITBUCKET_COMMIT`],[`BITRISE`,`BITRISE_IO`],[`BUDDY`,`BUDDY_WORKSPACE_ID`],[`BUILDKITE`],[`CIRCLE`,`CIRCLECI`],[`CIRRUS`,`CIRRUS_CI`],[`CLOUDFLARE_PAGES`,`CF_PAGES`,{ci:!0}],[`CODEBUILD`,`CODEBUILD_BUILD_ARN`],[`CODEFRESH`,`CF_BUILD_ID`],[`DRONE`],[`DRONE`,`DRONE_BUILD_EVENT`],[`DSARI`],[`GITHUB_ACTIONS`],[`GITLAB`,`GITLAB_CI`],[`GITLAB`,`CI_MERGE_REQUEST_ID`],[`GOCD`,`GO_PIPELINE_LABEL`],[`LAYERCI`],[`HUDSON`,`HUDSON_URL`],[`JENKINS`,`JENKINS_URL`],[`MAGNUM`],[`NETLIFY`],[`NETLIFY`,`NETLIFY_LOCAL`,{ci:!1}],[`NEVERCODE`],[`RENDER`],[`SAIL`,`SAILCI`],[`SEMAPHORE`],[`SCREWDRIVER`],[`SHIPPABLE`],[`SOLANO`,`TDDIUM`],[`STRIDER`],[`TEAMCITY`,`TEAMCITY_VERSION`],[`TRAVIS`],[`VERCEL`,`NOW_BUILDER`],[`VERCEL`,`VERCEL`,{ci:!1}],[`VERCEL`,`VERCEL_ENV`,{ci:!1}],[`APPCENTER`,`APPCENTER_BUILD_ID`],[`CODESANDBOX`,`CODESANDBOX_SSE`,{ci:!1}],[`CODESANDBOX`,`CODESANDBOX_HOST`,{ci:!1}],[`STACKBLITZ`],[`STORMKIT`],[`CLEAVR`],[`ZEABUR`],[`CODESPHERE`,`CODESPHERE_APP_ID`,{ci:!0}],[`RAILWAY`,`RAILWAY_PROJECT_ID`],[`RAILWAY`,`RAILWAY_SERVICE_ID`],[`DENO-DEPLOY`,`DENO_DEPLOYMENT_ID`],[`FIREBASE_APP_HOSTING`,`FIREBASE_APP_HOSTING`,{ci:!0}]];function Jd(){if(globalThis.process?.env)for(let e of qd){let t=e[1]||e[0];if(globalThis.process?.env[t])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL===`/bin/jsh`&&globalThis.process?.versions?.webcontainer?{name:`stackblitz`,ci:!1}:{name:``,ci:!1}}const Yd=Jd();Yd.name;function Xd(e){return e?e!==`false`:!1}const Zd=globalThis.process?.platform||``,Qd=Xd(Gd.CI)||Yd.ci!==!1,$d=Xd(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY),ef=Xd(Gd.DEBUG),tf=Kd===`test`||Xd(Gd.TEST);Gd.MINIMAL;const nf=/^win/i.test(Zd);!Xd(Gd.NO_COLOR)&&(Xd(Gd.FORCE_COLOR)||($d||nf)&&Gd.TERM);const rf=(globalThis.process?.versions?.node||``).replace(/^v/,``)||null;Number(rf?.split(`.`)[0]);const af=globalThis.process||Object.create(null),of={versions:{}};new Proxy(af,{get(e,t){if(t===`env`)return Gd;if(t in e)return e[t];if(t in of)return of[t]}});const sf=globalThis.process?.release?.name===`node`,cf=!!globalThis.Bun||!!globalThis.process?.versions?.bun,lf=!!globalThis.Deno,uf=!!globalThis.fastly,df=!!globalThis.Netlify,ff=!!globalThis.EdgeRuntime,pf=globalThis.navigator?.userAgent===`Cloudflare-Workers`,mf=[[df,`netlify`],[ff,`edge-light`],[pf,`workerd`],[uf,`fastly`],[lf,`deno`],[cf,`bun`],[sf,`node`]];function hf(){let e=mf.find(e=>e[0]);if(e)return{name:e[1]}}hf()?.name;function gf({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}const _f=gf();function vf(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(_f,``)}function yf(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}function bf(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function xf(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101631&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129673||e>=129679&&e<=129734||e>=129742&&e<=129756||e>=129759&&e<=129769||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}function Sf(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Cf(e,{ambiguousAsWide:t=!1}={}){return Sf(e),bf(e)||xf(e)||t&&yf(e)?2:1}const wf=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,Tf=globalThis.Intl?.Segmenter?new Intl.Segmenter:{segment:e=>e.split(``)},Ef=/^\p{Default_Ignorable_Code_Point}$/u;function Df(e,t={}){if(typeof e!=`string`||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t;if(r||(e=vf(e)),e.length===0)return 0;let i=0,a={ambiguousAsWide:!n};for(let{segment:t}of Tf.segment(e)){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159)&&!(e>=8203&&e<=8207||e===65279)&&!(e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071)&&!(e>=55296&&e<=57343)&&!(e>=65024&&e<=65039)&&!Ef.test(t)){if(wf().test(t)){i+=2;continue}i+=Cf(e,a)}}return i}function Of(){let{env:e}=S,{TERM:t,TERM_PROGRAM:n}=e;return S.platform===`win32`?!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask===`{cmd::Cmder}`||n===`Terminus-Sublime`||n===`vscode`||t===`xterm-256color`||t===`alacritty`||t===`rxvt-unicode`||t===`rxvt-unicode-256color`||e.TERMINAL_EMULATOR===`JetBrains-JediTerm`:t!==`linux`}const kf={info:`cyan`,fail:`red`,success:`green`,ready:`green`,start:`magenta`},Af={0:`red`,1:`yellow`},jf=Of(),$=(e,t)=>jf?e:t,Mf={error:$(`✖`,`×`),fatal:$(`✖`,`×`),ready:$(`✔`,`√`),warn:$(`⚠`,`‼`),info:$(`ℹ`,`i`),success:$(`✔`,`√`),debug:$(`⚙`,`D`),trace:$(`→`,`→`),fail:$(`✖`,`×`),start:$(`◐`,`o`),log:``};function Nf(e){return typeof Intl!=`object`||!Intl.Segmenter?mu(e).length:Df(e)}var Pf=class extends Xl{formatStack(e,t,n){let r=` `.repeat((n?.errorLevel||0)+1);return`
|
|
493
|
+
${r}`+ql(e,t).map(e=>` `+e.replace(/^at +/,e=>K.gray(e)).replace(/\((.+)\)/,(e,t)=>`(${K.cyan(t)})`)).join(`
|
|
494
|
+
${r}`)}formatType(e,t,n){let r=kf[e.type]||Af[e.level]||`gray`;if(t)return Lf(r)(K.black(` ${e.type.toUpperCase()} `));let i=typeof Mf[e.type]==`string`?Mf[e.type]:e.icon||e.type;return i?If(r)(i):``}formatLogObj(e,t){let[n,...r]=this.formatArgs(e.args,t).split(`
|
|
495
|
+
`);if(e.type===`box`)return _u(Ff(n+(r.length>0?`
|
|
275
496
|
`+r.join(`
|
|
276
|
-
`):``)),{title:e.title?
|
|
497
|
+
`):``)),{title:e.title?Ff(e.title):void 0,style:e.style});let i=this.formatDate(e.date,t),a=i&&K.gray(i),o=e.badge??e.level<2,s=this.formatType(e,o,t),c=e.tag?K.gray(e.tag):``,l,u=this.filterAndJoin([s,Ff(n)]),d=this.filterAndJoin(t.columns?[c,a]:[c]),f=(t.columns||0)-Nf(u)-Nf(d)-2;if(l=f>0&&(t.columns||0)>=80?u+` `.repeat(f)+d:(d?`${K.gray(`[${d}]`)} `:``)+u,l+=Ff(r.length>0?`
|
|
277
498
|
`+r.join(`
|
|
278
499
|
`):``),e.type===`trace`){let t=Error(`Trace: `+e.message);l+=this.formatStack(t.stack||``,t.message)}return o?`
|
|
279
500
|
`+l+`
|
|
280
|
-
`:l}};function ff(e){return e.replace(/`([^`]+)`/gm,(e,t)=>K.cyan(t)).replace(/\s+_([^_]+)_\s+/gm,(e,t)=>` ${K.underline(t)} `)}function pf(e=`white`){return K[e]||K.white}function mf(e=`bgWhite`){return K[`bg${e[0].toUpperCase()}${e.slice(1)}`]||K.bgWhite}function hf(e={}){let t=gf();return process.env.CONSOLA_LEVEL&&(t=Number.parseInt(process.env.CONSOLA_LEVEL)??t),Cl({level:t,defaults:{level:t},stdout:process.stdout,stderr:process.stderr,prompt:(...e)=>Promise.resolve().then(()=>(yd(),Yl)).then(t=>t.prompt(...e)),reporters:e.reporters||[e.fancy??!(kd||Md)?new df:new Dl],...e})}function gf(){return jd?U.debug:Md?U.warn:U.info}const _f=hf(),vf=Pe({meta:{name:`test`,description:`Capture and compare base/head Storybooks in one hermetic browser environment`},args:{"base-dir":{type:`string`,required:!0,description:`Built base Storybook directory`},"head-dir":{type:`string`,required:!0,description:`Built head Storybook directory`},"base-revision":{type:`string`,required:!0,description:`Base Git revision`},"head-revision":{type:`string`,required:!0,description:`Head Git revision`},output:{type:`string`,default:`.kapture`,description:`Output directory`},workers:{type:`string`,default:`4`,description:`Persistent browser worker count`},"pixel-threshold":{type:`string`,default:`0.2`,description:`Pixel color threshold`},"max-diff-ratio":{type:`string`,default:`0`,description:`Allowed changed-pixel ratio`},"frozen-time":{type:`string`,default:`2026-01-01T00:00:00.000Z`,description:`ISO time exposed to stories`},"random-seed":{type:`string`,default:`20260101`,description:`Math.random seed`},"dashboard-dir":{type:`string`,description:`Dashboard build directory (defaults to the CLI embedded dashboard)`}},async run({args:e}){let t=yf(e.workers,`workers`),n=bf(e[`pixel-threshold`],`pixel-threshold`),r=bf(e[`max-diff-ratio`],`max-diff-ratio`),i=yf(e[`random-seed`],`random-seed`);_f.start(`Capturing base and head Storybooks in one hermetic environment…`);let o=await el({baseDir:u(e[`base-dir`]),headDir:u(e[`head-dir`]),baseRevision:e[`base-revision`],headRevision:e[`head-revision`],outputDir:u(e.output),workers:t,threshold:{pixel:n,ratio:r},frozenTime:e[`frozen-time`],randomSeed:i});await ll(e[`dashboard-dir`]?u(e[`dashboard-dir`]):u(a(te(import.meta.url)),`dashboard`),u(e.output,`report`));let{summary:s}=o.report;_f.success(`${s.total} snapshots: ${s.changed} changed, ${s.added} added, ${s.removed} removed, ${s.unchanged} unchanged, ${s.errors} errors`),_f.info(`Environment: ${o.report.environment.id}`),_f.info(`Report: ${u(e.output,`report`,`report.json`)}`),s.errors>0&&(process.exitCode=2)}});function yf(e,t){let n=Number.parseInt(e,10);if(!Number.isInteger(n)||n<=0)throw Error(`${t} must be a positive integer`);return n}function bf(e,t){let n=Number.parseFloat(e);if(!Number.isFinite(n)||n<0||n>1)throw Error(`${t} must be between 0 and 1`);return n}const xf=Pe({meta:{name:`validate`,description:`Validate a Kapture report as a CI gate`},args:{report:{type:`string`,required:!0,description:`Path to report.json`},"fail-on-diff":{type:`boolean`,default:!1,description:`Exit 1 when visual changes require review`}},async run({args:e}){let t=u(e.report),n=await y(t);if(!n.isFile()||n.size>10485760)throw Error(`Kapture report must be a file no larger than ${Ps} bytes`);let r=Us(JSON.parse(await v(t,`utf8`)));if(r.summary.errors>0){_f.error(`${r.summary.errors} capture or comparison error(s)`),process.exitCode=2;return}let i=r.summary.changed+r.summary.added+r.summary.removed;if(i>0&&e[`fail-on-diff`]){_f.warn(`${i} visual change(s) require human approval`),process.exitCode=1;return}_f.success(i>0?`${i} visual change(s) detected`:`No visual changes`)}});Be(Pe({meta:{name:`kapture`,version:Ve,description:`Hermetic Storybook visual review`},subCommands:{test:vf,validate:xf,browser:Ue,github:Ws}}));export{};
|
|
501
|
+
`:l}};function Ff(e){return e.replace(/`([^`]+)`/gm,(e,t)=>K.cyan(t)).replace(/\s+_([^_]+)_\s+/gm,(e,t)=>` ${K.underline(t)} `)}function If(e=`white`){return K[e]||K.white}function Lf(e=`bgWhite`){return K[`bg${e[0].toUpperCase()}${e.slice(1)}`]||K.bgWhite}function Rf(e={}){let t=zf();return process.env.CONSOLA_LEVEL&&(t=Number.parseInt(process.env.CONSOLA_LEVEL)??t),Kl({level:t,defaults:{level:t},stdout:process.stdout,stderr:process.stderr,prompt:(...e)=>Promise.resolve().then(()=>(Hd(),vu)).then(t=>t.prompt(...e)),reporters:e.reporters||[e.fancy??!(Qd||tf)?new Pf:new Xl],...e})}function zf(){return ef?U.debug:tf?U.warn:U.info}const Bf=Rf(),Vf=Buffer.from([137,80,78,71,13,10,26,10]),Hf=new Set([`acTL`,`fcTL`,`fdAT`]),Uf=[`baseImage`,`headImage`,`diffImage`],Wf=D({meta:{name:`build`,description:`Rebuild a trusted static report from an untrusted Kapture artifact`},args:{input:{type:`string`,required:!0,description:`Untrusted artifact report directory containing report.json and images`},output:{type:`string`,required:!0,description:`New directory for the trusted static report`}},async run({args:e}){let t=await Gf({inputDir:e.input,outputDir:e.output});Bf.success(`Trusted report: ${t.report.summary.total} snapshots, ${t.imageCount} verified PNGs (${t.imageBytes} bytes)`),Bf.info(`Output: ${t.outputDir}`)}});async function Gf(e){let t=d(e.inputDir),n=d(e.outputDir);if(await ep(t),rp(t,n))throw Error(`Trusted report output must be outside the untrusted input directory`);await tp(n);let r=Kf(await np(t,`report.json`,Cl)),i=qf(r);if(i.length>6e4)throw Error(`Report references more than 60000 PNG images`);let o=e.dashboardDir?d(e.dashboardDir):d(a(de(import.meta.url)),`dashboard`),s=a(n);await _(s,{recursive:!0});let c=await v(`${s}${f}.kapture-report-`),l=new Map,u=[],p=0;try{for(let e of i){let n=await np(t,e.relativePath,26214400);if(p+=n.byteLength,p>536870912)throw Error(`Referenced PNGs exceed 536870912 total bytes`);l.set(e.relativePath,Zf(n,e.relativePath)),u.push({path:e.relativePath,sha256:ie(`sha256`).update(n).digest(`hex`)});let r=d(c,e.relativePath);await _(a(r),{recursive:!0}),await x(r,n,{flag:`wx`})}$f(r,l);let e=sc(r,u);if(r.contentDigest&&r.contentDigest!==e)throw Error(`Report content digest does not match its referenced PNGs: expected ${r.contentDigest}, calculated ${e}`);r.contentDigest=e,await x(d(c,`report.json`),`${JSON.stringify(r)}\n`,{flag:`wx`}),await Bc(o,c),await ne(c,n)}catch(e){throw await b(c,{recursive:!0,force:!0}),e}return{report:r,outputDir:n,imageCount:i.length,imageBytes:p}}function Kf(e){let t;try{t=JSON.parse(e.toString(`utf8`))}catch{throw Error(`Input report.json does not contain valid JSON`)}return Ml(t)}function qf(e){let t=new Map;for(let n of Object.values(e.entries)){let e=Jf(n.status);for(let r of Uf){let i=n[r];if(e.has(r)&&!i)throw Error(`Report entry ${n.id} is missing ${r} for status ${n.status}`);if(!e.has(r)&&i)throw Error(`Report entry ${n.id} cannot contain ${r} for status ${n.status}`);if(!i)continue;let a=Xf(i,Yf(r),n.id),o=t.get(a);if(o&&o.entryId!==n.id)throw Error(`Report entries ${o.entryId} and ${n.id} reference the same PNG: ${a}`);t.set(a,{relativePath:a,entryId:n.id})}}return[...t.values()]}function Jf(e){return e===`changed`?new Set(Uf):e===`added`?new Set([`headImage`]):e===`removed`?new Set([`baseImage`]):new Set}function Yf(e){return e===`baseImage`?`base`:e===`headImage`?`head`:`diff`}function Xf(e,t,n){let r=`images/${t}/`,i=e.slice(r.length);if(!e.startsWith(r)||!i||i.includes(`/`)||i.includes(`\\`)||i.length>255||!/^[a-zA-Z0-9][a-zA-Z0-9._-]*\.png$/.test(i))throw Error(`Report entry ${n} has an invalid ${t} PNG path: ${e}`);return e}function Zf(e,t){if(e.byteLength<33||!e.subarray(0,8).equals(Vf))throw Error(`Referenced image is not a PNG: ${t}`);let n=e.readUInt32BE(8),r=e.toString(`ascii`,12,16);if(n!==13||r!==`IHDR`)throw Error(`Referenced PNG has an invalid IHDR chunk: ${t}`);let i=e.readUInt32BE(16),a=e.readUInt32BE(20);if(i<1||a<1||i>16384||a>32768||i*a>33554432)throw Error(`Referenced PNG dimensions are outside the supported limits: ${t} (${i}x${a})`);Qf(e,t);try{let t=zs.PNG.sync.read(e,{checkCRC:!0,skipRescale:!0});if(t.width!==i||t.height!==a)throw Error(`decoded dimensions differ from IHDR`)}catch{throw Error(`Referenced PNG cannot be decoded safely: ${t}`)}return{width:i,height:a}}function Qf(e,t){let n=Vf.byteLength,r=!1;for(;n+12<=e.byteLength;){let i=e.readUInt32BE(n),a=e.toString(`ascii`,n+4,n+8),o=n+12+i;if(o>e.byteLength)throw Error(`Referenced PNG has an invalid chunk boundary: ${t}`);if(Hf.has(a))throw Error(`Animated PNG is not supported in a static report: ${t}`);if(n=o,a===`IEND`){r=!0;break}}if(!r||n!==e.byteLength)throw Error(`Referenced PNG has an invalid chunk structure: ${t}`)}function $f(e,t){for(let n of Object.values(e.entries)){if(n.status!==`changed`||!n.baseImage||!n.headImage||!n.diffImage)continue;let e=t.get(n.baseImage),r=t.get(n.headImage),i=t.get(n.diffImage);if(!e||!r||!i)throw Error(`Report entry ${n.id} is missing validated PNG dimensions`);let a=Math.max(e.width,r.width),o=Math.max(e.height,r.height);if(i.width!==a||i.height!==o)throw Error(`Report entry ${n.id} diff PNG must match the padded comparison canvas ${a}x${o}`);if(n.changedPixels!==void 0&&n.changedPixels>a*o)throw Error(`Report entry ${n.id} changedPixels exceeds its diff PNG pixel count`)}}async function ep(e){let t;try{t=await g(e)}catch(t){throw ip(t)?Error(`Input report directory does not exist: ${e}`):t}if(t.isSymbolicLink()||!t.isDirectory())throw Error(`Input report path must be a real directory, not a symbolic link`)}async function tp(e){try{await g(e)}catch(e){if(ip(e))return;throw e}throw Error(`Trusted report output already exists: ${e}`)}async function np(e,t,n){if(s(t)||t.includes(`\\`))throw Error(`Input file must be a normalized relative path: ${t}`);let r=t.split(`/`),i=e;for(let[e,n]of r.entries()){if(!n||n===`.`||n===`..`)throw Error(`Input file must be a normalized relative path: ${t}`);i=d(i,n);let a;try{a=await g(i)}catch(e){throw ip(e)?Error(`Referenced input file does not exist: ${t}`):e}if(a.isSymbolicLink())throw Error(`Referenced input path cannot contain a symbolic link: ${t}`);let o=e===r.length-1;if(!o&&!a.isDirectory()||o&&!a.isFile())throw Error(`Referenced input path is not a regular file: ${t}`)}let a=ue.O_RDONLY|(ue.O_NOFOLLOW??0),o=await ee(i,a);try{let e=await o.stat();if(!e.isFile()||e.size>n)throw Error(`Input file exceeds ${n} bytes: ${t}`);let r=Buffer.alloc(e.size),i=0;for(;i<r.byteLength;){let{bytesRead:e}=await o.read(r,i,r.byteLength-i,i);if(e===0)throw Error(`Input file changed while being read: ${t}`);i+=e}let a=Buffer.alloc(1),{bytesRead:s}=await o.read(a,0,1,r.byteLength);if(s>0)throw Error(`Input file changed while being read: ${t}`);return r}finally{await o.close()}}function rp(e,t){let n=u(e,t);return n===``||!n.startsWith(`..${f}`)&&n!==`..`&&!s(n)}function ip(e){return typeof e==`object`&&!!e&&`code`in e&&e.code===`ENOENT`}const ap=D({meta:{name:`report`,description:`Build trusted static Kapture reports`},subCommands:{build:Wf}}),op=D({meta:{name:`test`,description:`Capture and compare base/head Storybooks in one hermetic browser environment`},args:{"base-dir":{type:`string`,required:!0,description:`Built base Storybook directory`},"head-dir":{type:`string`,required:!0,description:`Built head Storybook directory`},"base-revision":{type:`string`,required:!0,description:`Base Git revision`},"head-revision":{type:`string`,required:!0,description:`Head Git revision`},output:{type:`string`,default:`.kapture`,description:`Output directory`},workers:{type:`string`,default:`4`,description:`Persistent browser worker count`},"pixel-threshold":{type:`string`,default:`0.2`,description:`Pixel color threshold`},"max-diff-ratio":{type:`string`,default:`0`,description:`Allowed changed-pixel ratio`},"frozen-time":{type:`string`,default:`2026-01-01T00:00:00.000Z`,description:`ISO time exposed to stories`},"random-seed":{type:`string`,default:`20260101`,description:`Math.random seed`},"dashboard-dir":{type:`string`,description:`Dashboard build directory (defaults to the CLI embedded dashboard)`}},async run({args:e}){let t=sp(e.workers,`workers`),n=cp(e[`pixel-threshold`],`pixel-threshold`),r=cp(e[`max-diff-ratio`],`max-diff-ratio`),i=sp(e[`random-seed`],`random-seed`);Bf.start(`Capturing base and head Storybooks in one hermetic environment…`);let o=await jc({baseDir:d(e[`base-dir`]),headDir:d(e[`head-dir`]),baseRevision:e[`base-revision`],headRevision:e[`head-revision`],outputDir:d(e.output),workers:t,threshold:{pixel:n,ratio:r},frozenTime:e[`frozen-time`],randomSeed:i});await Bc(e[`dashboard-dir`]?d(e[`dashboard-dir`]):d(a(de(import.meta.url)),`dashboard`),d(e.output,`report`));let{summary:s}=o.report;Bf.success(`${s.total} snapshots: ${s.changed} changed, ${s.added} added, ${s.removed} removed, ${s.unchanged} unchanged, ${s.errors} errors`),Bf.info(`Environment: ${o.report.environment.id}`),Bf.info(`Report: ${d(e.output,`report`,`report.json`)}`),s.errors>0&&(process.exitCode=2)}});function sp(e,t){let n=Number.parseInt(e,10);if(!Number.isInteger(n)||n<=0)throw Error(`${t} must be a positive integer`);return n}function cp(e,t){let n=Number.parseFloat(e);if(!Number.isFinite(n)||n<0||n>1)throw Error(`${t} must be between 0 and 1`);return n}const lp=D({meta:{name:`validate`,description:`Validate a Kapture report as a CI gate`},args:{report:{type:`string`,required:!0,description:`Path to report.json`},"fail-on-diff":{type:`boolean`,default:!1,description:`Exit 1 when visual changes require review`}},async run({args:e}){let t=d(e.report),n=await re(t);if(!n.isFile()||n.size>10485760)throw Error(`Kapture report must be a file no larger than ${Cl} bytes`);let r=Ml(JSON.parse(await y(t,`utf8`)));if(r.summary.errors>0){Bf.error(`${r.summary.errors} capture or comparison error(s)`),process.exitCode=2;return}let i=r.summary.changed+r.summary.added+r.summary.removed;if(i>0&&e[`fail-on-diff`]){Bf.warn(`${i} visual change(s) require human approval`),process.exitCode=1;return}Bf.success(i>0?`${i} visual change(s) detected`:`No visual changes`)}});Ge(D({meta:{name:`kapture`,version:Ke,description:`Hermetic Storybook visual review`},subCommands:{test:op,validate:lp,browser:Je,report:ap,github:Fl}}));export{};
|