quirl-cli 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/quirl.mjs +51 -49
  2. package/package.json +1 -1
package/dist/quirl.mjs CHANGED
@@ -182,19 +182,7 @@ if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid
182
182
  `):[m[0],``,...i.split(`
183
183
  `)]:[...Wb(m),``,...i.split(`
184
184
  `)];let g=[...f,...Wb(h),...p.length?[``,...p]:[]];return`${Wb(g).join(`
185
- `)}\n`}const Kb=e=>({content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}),qb=[`database`,`storage`,`service`,`queue`,`auth`,`external_api`,`hosting`,`secrets`,`scheduler`,`network`,`monitoring`,`ai`],Jb=[`endpoint`,`table`,`message`,`file`,`deployment`,`variable`,`job`,`domain`,`function`,`event`,`role`,`model`],Yb=[`runs`,`serves`,`calls`,`uses`,`protects`,`triggers`,`sends_to`],Xb=`spec fields by kind (all optional unless marked):
186
- - endpoint: method*, path*, auth (in words), request, responses
187
- - table: table, columns [{name, type, required, description}]
188
- - function (database function / RPC): arguments, returns, access (who can call it)
189
- - message (queue, email, SMS): channel, topic, fields, example
190
- - file (stored files): pathPattern, contentType, access
191
- - deployment (Cloud Run service, Lambda…): region, url, runtime, trigger, path (folder deployed)
192
- - variable (setting or secret): secret (true/false), environments. NEVER the value.
193
- - job (scheduled): schedule* (cron or words), scheduleText, timeZone, runs
194
- - domain: pointsTo, record
195
- - event (webhook received or event sent): direction (receives|sends), counterpart, fields, example
196
- - role: permissions (list, one line each), assignedTo
197
- - model (AI): modelId*, usedFor, settings, calledFrom (file paths)`,Zb=H(U({relation:W(Yb),to:B().describe(`"endpoint:GET /domains", "variable:STRIPE_KEY", "resource:<name>" or "repo:<name>"`)})).describe(`Links, as [{relation, to}]. relation: runs (deployment → repo), serves (deployment → API resource or endpoint), calls (job/function/deployment → endpoint, function or model), uses (→ variable, model or resource), protects (role → table, endpoint or function), triggers (event → endpoint, job or function), sends_to (→ queue or resource). to: a contract as kind:name ("endpoint:GET /domains", "variable:STRIPE_KEY"), "resource:<name>" or "repo:<name>".`),Qb={resource:B().describe(`The resource's name, provider or id (from list_resources)`),inEnvironment:B().optional().describe(`Its current environment, when the same resource exists in several`)};function $b(e){let t=new Wr(e),n=new yb({name:`quirl`,version:e.version},{instructions:`Quirl is this team's single source of truth for the project: what the product does (capabilities), the words the team uses (glossary), docs, tasks, repos and resources.
185
+ `)}\n`}const Kb=`Quirl is this team's single source of truth for the project: what the product does (capabilities), the words the team uses (glossary), docs, tasks, repos and resources.
198
186
  - Before answering questions about how the product works or what a term means, check Quirl (lookup, search_docs) rather than guessing. list_features and get_feature show what's being built.
199
187
  - Use the glossary's words in code, commits and replies. Refer to items by their ids: capabilities C-12, features F-4, tasks by their number (e.g. Q-1). Don't use deprecated terms.
200
188
  - When you start, finish or get blocked on work, update the task (update_task), and attach branches, commits and pull requests as evidence.
@@ -211,9 +199,21 @@ if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid
211
199
  - Resources hold more than endpoints and tables: deployments (Cloud Run, Lambda), variables (names only, never values), scheduled jobs, domains, database functions, events (webhooks), roles and AI models. See one with get_resource. Record what the code doesn't show with add_contract, correct with update_contract, drop with remove_contract, and connect them with links (a job calls an endpoint, a deployment uses a variable, a role protects a table).
212
200
  - A repo is named after its git remote. To give it another name, set "repoName" in its .quirl/project.json (in a folder of repos, { "path", "name" } in "repos") and run quirl sync; everything linked to it stays. remove_repo takes a repo out of the project, only when the person asks.
213
201
  - If the project has no capabilities yet, offer to read the codebase and draft them with propose_capability.
214
- - If the project briefing isn't already in your context, call quirl_context first.`}),r={p_project:e.project},i=()=>({tool:n.server.getClientVersion()?.name??`mcp`,model:process.env.QUIRL_AGENT_MODEL}),a=e=>async t=>{try{return Kb(await e(t))}catch(e){if(e instanceof Ur)return{...Kb(e.message),isError:!0};throw e}};n.registerTool(`quirl_context`,{title:`Project briefing`,description:`The project briefing: always-loaded docs in full, glossary, capabilities, your open tasks and the list of other docs. Usually already loaded at session start.`,inputSchema:{}},a(async()=>zb(await t.context(e.project)))),n.registerTool(`search_docs`,{title:`Search docs`,description:`Full-text search across the project's docs (README, ADRs, guides, runbooks). Returns matching sections with their content. Use for anything not in the briefing.`,inputSchema:{query:B().describe(`Words to search for, e.g. 'refund approval limits'`),limit:V().int().min(1).max(20).optional()}},a(({query:e,limit:n})=>t.call(`search_docs`,{...r,p_query:e,p_limit:n??6}))),n.registerTool(`read_doc`,{title:`Read a doc`,description:`Read one doc in full, by id, title or source path. source says where it lives: 'quirl' for docs written in Quirl (editable with edit_doc), otherwise the repo or folder it's synced from.`,inputSchema:{doc:B().describe(`Doc id, title or path, e.g. 'docs/adr/004-queues.md'`)}},a(({doc:e})=>t.call(`read_doc`,{...r,p_doc:e})));let o=[`product`,`guideline`,`architecture`,`decision`,`how_to`,`reference`];n.registerTool(`create_doc`,{title:`Write a new doc`,description:`Write a doc in Quirl itself: a PRD, spec or product note with no file behind it. Docs about code that tests or builds rely on belong in their repo, where sync picks them up. Use product for PRDs and specs. Never include secret values.`,inputSchema:{title:B(),body:B().describe(`Markdown. Headings (##, ###) split it into sections edit_doc can change one at a time.`),type:W(o).optional().describe(`Defaults to reference`)}},a(({title:e,body:n,type:a})=>t.call(`create_doc`,{...r,p_title:e,p_body:n,p_type:a??`reference`,p_agent:i()}))),n.registerTool(`edit_doc`,{title:`Edit a doc written in Quirl`,description:`Change one section of a doc written in Quirl, or the whole doc, without rewriting the rest. A section is named by its heading, or by its path when a heading repeats ('Billing > Refunds'). replace swaps the section's text (keeping its heading, unless the new text starts with one); append adds to the end of it. Without a section, replace rewrites the doc and append adds to its end. Docs synced from a repo or folder are changed there instead. The edit fails if the doc changed since it was read, rather than overwriting that change.`,inputSchema:{doc:B().describe(`Doc id or title`),section:B().optional().describe(`Heading text or path, e.g. 'Scope' or 'Billing > Refunds'`),content:B().describe(`Markdown`),mode:W([`replace`,`append`]).optional().describe(`Defaults to replace`),title:B().optional().describe(`A new title for the doc`),type:W(o).optional()}},a(async({doc:e,section:n,content:a,mode:o,title:s,type:c})=>{let l=await t.call(`read_doc`,{...r,p_doc:e});if(!l.editable)throw new Ur(`"${l.title}" comes from ${l.source}. Change it there; sync brings it into Quirl.`);let u;try{u=Gb(l.body,n,a,o??`replace`)}catch(e){throw new Ur(e.message)}return{...await t.call(`update_doc`,{...r,p_doc:l.id,p_title:s??null,p_body:u,p_type:c??null,p_expected_hash:l.contentHash,p_agent:i()}),edited:n??`the whole doc`,sections:Hb(u)}})),n.registerTool(`doc_history`,{title:`A doc's history`,description:`Who changed a doc and when, newest first, with lines added and removed. Pass a version to see what it changed (a diff against the version before), or full to get that version's whole text, e.g. to bring back wording with edit_doc.`,inputSchema:{doc:B().describe(`Doc id or title`),version:V().int().optional(),full:em().optional().describe(`With version: its whole text instead of the diff`)}},a(async({doc:e,version:n,full:i})=>{let a=await t.call(`doc_history`,{...r,p_doc:e,p_limit:n?200:21}),o=a.versions,s=e=>o.find(t=>t.version===e-1);if(n){let e=o.find(e=>e.version===n);if(!e)throw new Ur(`"${a.title}" has no version ${n}; the latest is ${o[0]?.version??0}.`);if(i)return{version:n,title:e.title,body:e.body};let t=s(n);return{version:n,author:e.author??`unknown`,at:e.createdAt,...t&&t.title!==e.title?{renamed:`${t.title} → ${e.title}`}:{},diff:t?Ib(t.body,e.body)||`(no text changes)`:`(first version)`}}return{title:a.title,source:a.source,versions:o.slice(0,20).map(e=>{let t=s(e.version);return{version:e.version,author:e.author??`unknown`,at:e.createdAt,change:t?Pb(Nb(t.body,e.body)):`first version`}})}})),n.registerTool(`archive_doc`,{title:`Archive a doc written in Quirl`,description:`Remove a doc written in Quirl that's no longer true or was a mistake. It's archived and stays in history. Docs synced from a repo or folder are deleted there instead.`,inputSchema:{doc:B().describe(`Doc id or title`),reason:B().optional().describe(`Why, for history`)}},a(({doc:e,reason:n})=>t.call(`archive_doc`,{...r,p_doc:e,p_reason:n??null,p_agent:i()}))),n.registerTool(`lookup`,{title:`Look up a term, capability or contract`,description:`Find glossary terms, capabilities, features and API/table contracts matching a name. Use it to check what a word means here, or the request/response shape of an endpoint or table.`,inputSchema:{query:B().describe(`A term, capability, endpoint or table name, e.g. 'Visit' or 'POST /login'`)}},a(({query:e})=>t.call(`lookup`,{...r,p_query:e})));let s=(e,t,r,i)=>{n.registerTool(e,r,i),n.registerTool(t,{...r,description:`Old name for ${e}; use ${e}. ${r.description}`},i)};s(`list_tasks`,`list_cards`,{title:`List tasks`,description:`List tasks on the board. Defaults to your own tasks that aren't done.`,inputSchema:{onlyMine:em().optional(),includeDone:em().optional()}},a(({onlyMine:e,includeDone:n})=>t.call(`list_cards`,{...r,p_only_mine:e??!0,p_include_done:n??!1})));let c=`Markdown: short paragraphs, and lists for steps or parts, not one long block.`,l=`Kind of work: e.g. Frontend, Backend, Database, Design, DevOps, Testing, Docs, Research. Only tags from the task set are accepted (see tagSets in quirl_context); propose a new value with propose_term (kind tag, tagSet task_work).`,u=B().describe(`Task number, e.g. 'K-104' or '104'`),d=B().optional().describe(`Who does it: "me", a member's email or name (only people on the project), or "none"`);return s(`get_task`,`get_card`,{title:`Get a task`,description:`A task with its feature, docs, dependencies and evidence.`,inputSchema:{task:u.optional(),card:u.optional()}},a(({task:e,card:n})=>t.call(`get_card`,{...r,p_card:e??n}))),s(`create_task`,`create_card`,{title:`Create a task`,description:`Add a task to the board (status: todo). Use it for work you discover that should be tracked. Put it under the feature it serves.`,inputSchema:{title:B(),description:B().optional().describe(`What to do and why. ${c}`),type:W([`feature_work`,`bug`,`chore`,`research`]).optional(),feature:B().optional().describe(`Feature name or id (e.g. F-4) this task belongs to`),tags:H(B()).optional().describe(l),assignee:d.describe(`Who does it: "me" (the default), a member's email or name, or "none"`)}},a(async({title:e,description:n,type:a,feature:o,tags:s,assignee:c})=>{let l=await t.call(`create_card`,{...r,p_title:e,p_description:n??``,p_type:a??`feature_work`,p_feature:o??null,p_agent:i()});return(s?.length||c)&&await t.call(`update_card`,{...r,p_card:l,p_patch:{...s?.length?{tags:s}:{},...c?{assignee:c}:{}},p_agent:i()}),l})),s(`update_task`,`update_card`,{title:`Update a task`,description:`Move a task, mark it blocked (with a reason) or unblocked, assign it, put it under a feature, set its tags, rewrite its title or description, and attach evidence: a branch, commit or pull request. Repos are referenced by name.`,inputSchema:{task:u.optional(),card:u.optional(),assignee:d,status:W([`backlog`,`todo`,`in_progress`,`review`,`done`]).optional(),feature:B().optional().describe(`Feature name or id (e.g. F-4) to put the task under; an empty string takes it off its feature`),title:B().optional(),description:B().optional().describe(`Replaces the description. ${c}`),tags:H(B()).optional().describe(`${l} Replaces the current tags.`),blocked:em().optional(),blockedReason:B().optional(),addBranch:U({repo:B(),name:B()}).optional(),addCommit:U({repo:B(),sha:B(),message:B().optional()}).optional(),addPullRequest:U({repo:B(),number:V().int(),url:B(),state:W([`open`,`merged`,`closed`]).optional()}).optional()}},a(({task:e,card:n,...a})=>t.call(`update_card`,{...r,p_card:e??n,p_patch:a,p_agent:i()}))),n.registerTool(`archive_task`,{title:`Archive a task`,description:`Remove a task that shouldn't be there: a duplicate or a mistake. It's archived and stays in history, and its feature's status is worked out without it. For work that's finished, move it to done instead.`,inputSchema:{task:u,reason:B().optional().describe(`Why, for history`)}},a(({task:e,reason:n})=>t.call(`archive_card`,{...r,p_card:e,p_reason:n??null,p_agent:i()}))),n.registerTool(`propose_term`,{title:`Propose a glossary term`,description:`Suggest a new glossary term. It shows up for approval; it isn't used until a person approves it.`,inputSchema:{term:B(),plain:B().describe(`What it means, for someone non-technical`),technical:B().describe(`What it means in the code`),kind:W([`concept`,`tag`,`name`]).optional(),tagSet:B().optional().describe(`Required for kind 'tag': the set the value belongs to, e.g. feature_change, task_work, capability_audience, capability_kind (see tagSets in quirl_context)`),reason:B().optional()}},a(({term:e,plain:n,technical:a,kind:o,tagSet:s,reason:c})=>t.call(`propose_term`,{...r,p_term:e,p_plain:n,p_technical:a,p_kind:o??`concept`,p_tag_set:s??null,p_reason:c??null,p_agent:i()}))),n.registerTool(`propose_term_retire`,{title:`Retire a glossary term`,description:`Propose retiring a glossary term or tag that's no longer used or was a mistake. With replaceWith, the term stays as one not to say (agents are told the replacement); without it, it's removed. Either way it comes off every capability, task and feature that used it. A person approves it. Built-in tag values can't be retired.`,inputSchema:{term:B().describe(`The term or tag to retire`),replaceWith:B().optional().describe(`An approved term to say instead, if there is one`),reason:B().optional()}},a(({term:e,replaceWith:n,reason:a})=>t.call(`propose_term_retire`,{...r,p_term:e,p_replace_with:n??null,p_reason:a??null,p_agent:i()}))),n.registerTool(`list_flags`,{title:`List flags`,description:`Flags are messages people send about a section of the project: a capability, feature, task, doc or glossary term. Lists open (waiting for an admin) and approved (to act on) flags, or only those with the given status.`,inputSchema:{status:W([`open`,`approved`,`removed`,`done`]).optional()}},a(({status:e})=>t.call(`list_flags`,{...r,p_status:e??null}))),n.registerTool(`decide_flag`,{title:`Approve or remove a flag`,description:`Admins only. Approve a flag so agents act on it at the start of their sessions, or remove it. An approved flag can still be removed. Only do this when the person you work for asks you to.`,inputSchema:{flag:B().describe(`The flag's id, from the briefing or list_flags`),decision:W([`approve`,`remove`])}},a(({flag:e,decision:n})=>t.call(`decide_flag`,{...r,p_flag:e,p_approve:n===`approve`,p_agent:i()}))),n.registerTool(`resolve_flag`,{title:`Mark a flag done`,description:`Mark an approved flag done once you've handled it, so it leaves the briefing. Say briefly what you did.`,inputSchema:{flag:B().describe(`The flag's id, from the briefing or list_flags`),note:B().optional().describe(`What was done, e.g. 'Updated C-12 to mention SMS'`)}},a(({flag:e,note:n})=>t.call(`resolve_flag`,{...r,p_flag:e,p_note:n??null,p_agent:i()}))),n.registerTool(`set_capability_icon`,{title:`Set a capability's icon`,description:`Give a capability an icon that fits what it does; it's shown on the capability's card. Use the same icon a related feature has when one fits both.`,inputSchema:{capability:B().describe(`Capability name or id (e.g. C-12)`),icon:W(Lb)}},a(({capability:e,icon:n})=>t.call(`set_capability_icon`,{...r,p_capability:e,p_icon:n,p_agent:i()}))),n.registerTool(`add_resource`,{title:`Add or fill in a resource`,description:"Record a service the project runs on that `quirl sync` can't see from the code: a hosted database another team runs, a SaaS named only in docs or the console, a staging copy. Sync already finds most things from env templates, docker-compose and client packages, so check Stack first (lookup) and don't add what it found. A resource with the same provider and environment is filled in rather than duplicated: the fields you give are set, and repos and capabilities are added to its links. Never pass URLs with credentials, keys or other secret values.",inputSchema:{name:B().describe(`What the team calls it, e.g. "Postgres", "Stripe"`),type:W(qb),provider:B().optional().describe(`Who runs it, e.g. "Google Cloud SQL", "Stripe". Resources are matched on this. Defaults to the name.`),description:B().optional().describe(`One plain sentence on what the project uses it for`),technical:B().optional().describe(`Technical notes for developers: setup, access, limits`),environment:B().optional().describe(`Defaults to "production"; e.g. "staging"`),repos:H(B()).optional().describe(`Repos that use it, by name`),capabilities:H(B()).optional().describe(`Capabilities that run on it, by name or id (e.g. C-12)`),account:B().optional().describe(`The cloud project, account or team it lives in, e.g. GCP project "domainarium-staging". Sync files deployments, jobs and secrets by it. Never a key.`)}},a(e=>t.call(`add_resource`,{...r,p_name:e.name,p_type:e.type,p_provider:e.provider??null,p_description:e.description??null,p_technical:e.technical??null,p_environment:e.environment??null,p_repos:e.repos??null,p_capabilities:e.capabilities??null,p_account:e.account??null,p_agent:i()}))),n.registerTool(`list_resources`,{title:`List the project's resources`,description:`Every resource on Stack: name, type, provider, environment, whether sync found it or someone added it, the repos that use it, the capabilities that run on it, and the tables and endpoints filed under it (per repo, with a few names). Tables in the wrong database or endpoints under the wrong API: fix with move_contracts.`,inputSchema:{}},a(()=>t.call(`list_resources`,r))),n.registerTool(`update_resource`,{title:`Change a resource`,description:`Correct a resource: rename it, relabel its environment (a scanned one that's really the local docker database becomes 'local'), or change its type, provider, descriptions or links. Only the fields you pass change. repos and capabilities replace its links; use add_resource to add to them. A repo you take off stays off: sync won't link it again until a person adds it back. Sync keeps updating a relabelled resource instead of adding it again. Never pass secret values.`,inputSchema:{...Qb,name:B().optional(),type:W(qb).optional(),provider:B().optional(),environment:B().optional().describe(`e.g. "production", "staging", "dev", "local"`),description:B().optional().describe(`One plain sentence on what the project uses it for`),technical:B().optional().describe(`Notes for developers`),repos:H(B()).optional().describe(`Replaces the repos that use it. Ones left out stay off through later syncs.`),capabilities:H(B()).optional().describe(`Replaces the capabilities that run on it (names or C-12)`),account:B().optional().describe(`The cloud project, account or team it lives in, e.g. GCP project "domainarium-staging". Sync files deployments, jobs and secrets by it. Never a key. Empty clears it.`)}},a(e=>t.call(`update_resource`,{...r,p_resource:e.resource,p_in_environment:e.inEnvironment??null,p_name:e.name??null,p_type:e.type??null,p_provider:e.provider??null,p_environment:e.environment??null,p_description:e.description??null,p_technical:e.technical??null,p_repos:e.repos??null,p_capabilities:e.capabilities??null,p_account:e.account??null,p_agent:i()}))),n.registerTool(`remove_resource`,{title:`Remove a wrong resource`,description:`Remove a resource that isn't one: a false match from sync, a duplicate, something no longer used. It's archived, stays in history, and sync won't add it again. A resource holding endpoints or tables from sync can't be removed; relabel it instead.`,inputSchema:{...Qb,reason:B().optional().describe(`Why it's wrong, for history`)}},a(e=>t.call(`remove_resource`,{...r,p_resource:e.resource,p_in_environment:e.inEnvironment??null,p_reason:e.reason??null,p_agent:i()}))),n.registerTool(`get_resource`,{title:`Get a resource and what it holds`,description:`One resource with everything it holds: endpoints, tables, functions, deployments, variables (names only), jobs, domains, events, roles, models. Each with its fields (spec), whether sync found it or someone added it, and its links (what it runs, calls, uses or protects, and what points at it). Use before adding or changing what a resource holds.`,inputSchema:Qb},a(e=>t.call(`get_resource`,{...r,p_resource:e.resource,p_in_environment:e.inEnvironment??null}))),n.registerTool(`add_contract`,{title:`Add something a resource holds`,description:`Record what the code doesn't show: a Cloud Scheduler job set up in the console, the variables Secret Manager holds (names, never values), a Cloud Run service, the roles the product has, the AI models it calls, a webhook it receives, a domain. Sync finds endpoints and tables from OpenAPI files and migrations, so check get_resource first. What you add stays until someone removes it; if sync later finds the same thing in code, it takes it over. Never pass secret values, keys or URLs with credentials.\n\n${Xb}`,inputSchema:{...Qb,kind:W(Jb),name:B().optional().describe(`e.g. "nightly-invoices", "STRIPE_SECRET_KEY", "admin", "claude-opus-5-5". Endpoints default to "METHOD /path".`),description:B().optional().describe(`One plain sentence: what it is or does`),spec:_m(B(),im()).optional().describe(`The kind's fields; see the list above`),repo:B().optional().describe(`The repo it belongs to, if any`),links:Zb.optional()}},a(e=>t.call(`add_contract`,{...r,p_resource:e.resource,p_in_environment:e.inEnvironment??null,p_kind:e.kind,p_name:e.name??null,p_description:e.description??null,p_spec:e.spec??null,p_repo:e.repo??null,p_links:e.links??null,p_agent:i()}))),n.registerTool(`update_contract`,{title:`Change something a resource holds`,description:`Correct or fill in a contract: its description, its fields, its links. spec is merged: given fields are set, a field set to null is removed. links, when given, replace the links people added (sync's stay). On something sync found (an endpoint from OpenAPI, a table from migrations) only the description and links change here; the rest follows the code. To file it under another resource, use move_contracts.\n\n${Xb}`,inputSchema:{contract:B().describe(`kind:name ("job:nightly-invoices", "endpoint:GET /domains"), a unique name, or its id (from get_resource)`),resource:B().optional().describe(`Its resource, when the name is in several`),inEnvironment:B().optional(),name:B().optional(),description:B().optional(),spec:_m(B(),im()).optional(),links:Zb.optional()}},a(e=>t.call(`update_contract`,{...r,p_contract:e.contract,p_resource:e.resource??null,p_in_environment:e.inEnvironment??null,p_name:e.name??null,p_description:e.description??null,p_spec:e.spec??null,p_links:e.links??null,p_agent:i()}))),n.registerTool(`remove_contract`,{title:`Remove something added to a resource`,description:`Remove a contract someone added that's wrong or gone: a deleted job, a retired variable. It's archived and stays in history. What sync found from code can't be removed here: change the code, or move it with move_contracts if it's filed in the wrong place.`,inputSchema:{contract:B().describe(`kind:name ("variable:OLD_KEY"), a unique name, or its id`),resource:B().optional(),inEnvironment:B().optional(),reason:B().optional().describe(`Why, for history`)}},a(e=>t.call(`remove_contract`,{...r,p_contract:e.contract,p_resource:e.resource??null,p_in_environment:e.inEnvironment??null,p_reason:e.reason??null,p_agent:i()}))),n.registerTool(`move_contracts`,{title:`Move what sync filed to another resource`,description:`Correct where sync filed a repo's tables (which database), endpoints (which API), deployments (which Cloud Run project), jobs, variables, functions, roles or models. Without names, all of the repo's ones of that kind move and later syncs put new ones there too. With names, only those move and sync leaves them there. list_resources shows what's filed where. For deployments in the wrong environment, setting the resource's account (update_resource) also fixes later syncs. With also, they're filed under this resource as well as where they are: the same endpoints served by the dev and the prod API.`,inputSchema:{repo:B().describe(`The repo they come from: name, URL or id`),kind:W([...Jb,`tables`,`endpoints`]),to:B().describe(`The resource they belong to: name, provider or id`),toEnvironment:B().optional().describe(`Its environment, when it exists in several`),names:H(B()).optional().describe(`Only these, e.g. ["bookings"] or ["GET /bookings"]; leave out to move all`),also:em().optional().describe(`Keep them where they are and file them here too, e.g. endpoints served in dev and in prod`)}},a(e=>t.call(`move_contracts`,{...r,p_repo:e.repo,p_kind:e.kind,p_to:e.to,p_in_environment:e.toEnvironment??null,p_names:e.names??null,p_also:e.also??!1,p_agent:i()}))),n.registerTool(`remove_repo`,{title:`Remove a repo`,description:"Remove a repo from the project, for admins: one that's retired, or was imported by mistake. Its dependencies, endpoints, tables and synced docs are archived with it, and it's unlinked from capabilities, tasks and resources. Sync skips it from then on; running `quirl init` in it adds it back. Only on the person's request: confirm with them first. To rename a repo instead, set its name in .quirl/project.json and sync.",inputSchema:{repo:B().describe(`The repo's name, URL or id`),reason:B().optional().describe(`Why it's removed, for history`)}},a(e=>t.call(`remove_repo`,{...r,p_repo:e.repo,p_reason:e.reason??null,p_agent:i()}))),n.registerTool(`list_features`,{title:`List features`,description:`List the project's features with their status, the capability each changes (or createsCapability when it has none), and task counts. Shipped ones are left out unless includeShipped. Check here before requesting a feature.`,inputSchema:{includeShipped:em().optional()}},a(({includeShipped:e})=>t.call(`list_features`,{...r,p_include_shipped:e??!1}))),n.registerTool(`get_feature`,{title:`Get a feature`,description:`A feature with its description, status, the capability it changes (and what that capability does) and its tasks.`,inputSchema:{feature:B().describe(`Feature name or id (e.g. F-4)`)}},a(({feature:e})=>t.call(`get_feature`,{...r,p_feature:e}))),n.registerTool(`request_feature`,{title:`Request a feature`,description:`Request a feature: a change to the product that stakeholders follow on the Features page, usually made of several tasks. Check list_features first so you don't request one twice. It shows as requested straight away and a person accepts or declines it. Put tasks under it with create_task or update_task.`,inputSchema:{name:B().describe(`Short name, e.g. 'Repeat appointments'`),description:B().describe(`What changes for the user, in plain words. Markdown: short paragraphs, and lists for parts`),capability:B().optional().describe(`Capability name or id (e.g. C-12) it changes. Leave it out when the feature creates a new capability`),tags:H(B()).optional().describe(`Kind of change: e.g. New, Improvement, Visual, Fix, Performance, Security, Removal, Internal (the feature_change set in quirl_context)`),reason:B().optional().describe(`Why it's worth doing`),icon:W(Lb).optional().describe(`An icon that fits the feature, shown on its card`)}},a(async({name:e,description:n,capability:a,tags:o,reason:s,icon:c})=>{let l=await t.call(`request_feature`,{...r,p_name:e,p_description:n,p_capability:a??null,p_tags:o??null,p_reason:s??null,p_agent:i()});return c&&l===`requested`&&await t.call(`set_feature_icon`,{...r,p_feature:e,p_icon:c,p_agent:i()}),l})),n.registerTool(`set_feature_icon`,{title:`Set a feature's icon`,description:`Give a feature an icon that fits what it does; it's shown on the feature's card. list_features shows which features have none.`,inputSchema:{feature:B().describe(`Feature name or id (e.g. F-4)`),icon:W(Lb)}},a(({feature:e,icon:n})=>t.call(`set_feature_icon`,{...r,p_feature:e,p_icon:n,p_agent:i()}))),n.registerTool(`update_feature`,{title:`Correct a feature`,description:`Fix a feature's name, description or the capability it changes, e.g. after requesting it with the wrong one. Only the fields you pass change; it shows in the feature's history. Tags: tag_feature; icon: set_feature_icon.`,inputSchema:{feature:B().describe(`Feature name or id (e.g. F-4)`),name:B().optional(),description:B().optional().describe(`What changes for the user, in plain words. Markdown: short paragraphs, and lists for parts`),capability:B().optional().describe(`The capability it changes (name or C-12), or "none" when it creates a new one`)}},a(({feature:e,name:n,description:a,capability:o})=>t.call(`update_feature`,{...r,p_feature:e,p_name:n??null,p_description:a??null,p_capability:o??null,p_agent:i()}))),n.registerTool(`withdraw_feature`,{title:`Withdraw a feature`,description:`Remove a feature that shouldn't be there: a duplicate, a mistake, or an idea dropped before any work. It's archived and stays in history. One that shipped can't be withdrawn; move or archive its tasks first (update_task, archive_task).`,inputSchema:{feature:B().describe(`Feature name or id (e.g. F-4)`),reason:B().optional().describe(`Why, for history`)}},a(({feature:e,reason:n})=>t.call(`withdraw_feature`,{...r,p_feature:e,p_reason:n??null,p_agent:i()}))),n.registerTool(`tag_feature`,{title:`Tag a feature`,description:`Set a feature's kind-of-change tags (replaces the current ones). Only values from the feature_change tag set are accepted.`,inputSchema:{feature:B().describe(`Feature name or id (e.g. F-4)`),tags:H(B()).describe(`Kind of change: e.g. New, Improvement, Visual, Fix, Performance, Security, Removal, Internal`)}},a(({feature:e,tags:n})=>t.call(`tag_feature`,{...r,p_feature:e,p_tags:n,p_agent:i()}))),n.registerTool(`list_capabilities`,{title:`List the capabilities`,description:`Every capability as data: id (C-12), name, status, icon, the capability it's part of, what it does, what it relies on, its tags and the features changing it. Retired ones only with includeRetired.`,inputSchema:{includeRetired:em().optional()}},a(({includeRetired:e})=>t.call(`list_capabilities`,{...r,p_include_retired:e??!1}))),n.registerTool(`propose_capability`,{title:`Propose a capability`,description:"Draft a capability: one thing the product does today, described for a non-technical reader. Use it when the project has none yet (for example right after `quirl init`), when you find one that's missing, or when a feature that creates a new capability ships (pass it in features). Never for something not built yet: request a feature instead. A person approves it before it shows up.",inputSchema:{name:B().describe(`Short name, e.g. 'Online booking'`),whatItDoes:B().describe(`One or two plain sentences, no jargon`),technical:B().optional().describe(`Where it lives in the code and how it works. Markdown: short paragraphs, and lists for parts, not one long block`),features:H(B()).optional().describe(`Feature names or ids (e.g. F-4) that create or change this capability; they're linked to it once it's approved`),reason:B().optional()}},a(({name:e,whatItDoes:n,technical:a,features:o,reason:s})=>t.call(`propose_capability`,{...r,p_name:e,p_what_it_does:n,p_technical:a??``,p_features:o??null,p_reason:s??null,p_agent:i()}))),n.registerTool(`propose_capability_archive`,{title:`Propose archiving a capability`,description:`Suggest retiring a capability that no longer describes what the product does, or that was drafted for something not built yet. Unshipped features linked to it will create a new capability when they ship. A person approves it.`,inputSchema:{capability:B().describe(`Capability name or id (e.g. C-12)`),reason:B().describe(`Why it should go`)}},a(({capability:e,reason:n})=>t.call(`propose_capability_archive`,{...r,p_capability:e,p_reason:n,p_agent:i()}))),n.registerTool(`propose_capability_update`,{title:`Propose a capability correction`,description:`Suggest a corrected name or description for a capability when the code no longer matches it. A person approves it.`,inputSchema:{capability:B().describe(`Capability name or id (e.g. C-12)`),field:W([`name`,`what_it_does`,`technical_description`]),after:B().describe(`The new name, or the corrected text. Markdown: short paragraphs, and lists for parts, not one long block`),reason:B().optional()}},a(({capability:e,field:n,after:a,reason:o})=>t.call(`propose_capability_update`,{...r,p_capability:e,p_field:n,p_after:a,p_reason:o??null,p_agent:i()}))),n.registerTool(`propose_capability_details`,{title:`Propose how a capability works and its connections`,description:`Suggest a capability's 'How it works' steps, its tags (glossary terms of kind 'tag'), the capability it's part of, and its connections: capabilities it relies on, repos, resources it runs on, glossary terms and docs. Each part you pass replaces that part when a person approves it; parts you leave out are kept. Names are matched to existing, approved items. What it relies on draws the arrows on the Home map, so link the steps a user goes through (e.g. invoicing relies on booking).`,inputSchema:{capability:B().describe(`Capability name or id (e.g. C-12)`),howItWorks:H(B()).optional().describe(`3 to 5 plain-language steps, as the user experiences it`),reliesOn:H(U({capability:B().describe(`Capability name or id (e.g. C-12)`),label:B().describe(`How it relies on it, read before the name, e.g. 'extends'`)})).optional(),parent:B().optional().describe(`The capability this one is part of (name or id, e.g. C-2), or 'none' to make it top-level. Parts are listed under their parent instead of on their own`),repos:H(B()).optional().describe(`Repo names`),resources:H(B()).optional().describe(`Resource names it runs on`),terms:H(B()).optional().describe(`Glossary terms`),docs:H(B()).optional().describe(`Doc titles, or <repo>/<path> (e.g. quirl/AGENTS.md) when titles repeat`),tags:H(B()).optional().describe(`Who it's for (Customer, Admin, Developer, Agent) and its kind (Interface, Integration, Data, Automation, Infrastructure, Access and security, AI): the capability tag sets in quirl_context`),reason:B().optional()}},a(({capability:e,howItWorks:n,reliesOn:a,parent:o,repos:s,resources:c,terms:l,docs:u,tags:d,reason:f})=>t.call(`propose_capability_details`,{...r,p_capability:e,p_how_it_works:n??null,p_relies_on:a??null,p_parent:o??null,p_repos:s??null,p_resources:c??null,p_terms:l??null,p_docs:u??null,p_tags:d??null,p_reason:f??null,p_agent:i()}))),n}async function ex(e){await $b(e).connect(new Mb)}const tx=`0.1.13`,nx=process.env.QUIRL_SERVER===`local`?{apiUrl:`http://127.0.0.1:54321`,publishableKey:`sb_publishable_ACJWlzQHlZjBrEguHvfOxg_3BJgxAaH`,appUrl:`http://localhost:5173`}:{apiUrl:`https://dugevhzlzrdtasuibdzr.supabase.co`,publishableKey:`sb_publishable_45P7GyyZoJsN0AO3wfmqNA_CXbx1iCW`,appUrl:`https://app.quirl.io`};function rx(){return{apiUrl:process.env.QUIRL_API_URL??nx.apiUrl,publishableKey:process.env.QUIRL_PUBLISHABLE_KEY??nx.publishableKey,appUrl:process.env.QUIRL_APP_URL??nx.appUrl}}const ix=()=>x(process.env.XDG_CONFIG_HOME??x(h(),`.config`),`quirl`),ax=()=>x(ix(),`credentials.json`);async function ox(){try{return JSON.parse(await u(ax(),`utf8`))}catch{return{}}}async function sx(){return process.env.QUIRL_KEY?{apiUrl:rx().apiUrl,key:process.env.QUIRL_KEY,email:``}:(await ox())[rx().apiUrl]??null}async function cx(e){let t=await ox();t[e.apiUrl]=e,await l(ix(),{recursive:!0,mode:448}),await m(ax(),`${JSON.stringify(t,null,` `)}\n`,{mode:384}),await s(ax(),384)}async function lx(){let e=await ox();delete e[rx().apiUrl],Object.keys(e).length?await m(ax(),`${JSON.stringify(e,null,` `)}\n`,{mode:384}):await f(ax(),{force:!0})}async function ux(){let e=rx();return{apiUrl:e.apiUrl,publishableKey:e.publishableKey,key:(await sx())?.key??``}}function dx(e){return(e.repos??[]).map(e=>typeof e==`string`?{path:e}:e)}function fx(e=process.cwd()){try{return a(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim()}catch{return e}}const px=e=>x(e,`.quirl`,`project.json`);async function mx(e=process.cwd()){let t=e;for(;;)try{return{root:t,link:JSON.parse(await u(px(t),`utf8`))}}catch{let e=y(t);if(e===t)return null;t=e}}async function hx(e,t){await l(x(e,`.quirl`),{recursive:!0}),await m(px(e),`${JSON.stringify(t,null,` `)}\n`)}function gx(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];r===`*`?e[n+1]===`*`?(t+=e[n+2]===`/`?`(?:.*/)?`:`.*`,n+=e[n+2]===`/`?2:1):t+=`[^/]*`:t+=r===`?`?`[^/]`:r.replace(/[.+^${}()|[\]\\]/g,`\\$&`)}return RegExp(`^${t}$`)}function _x(e){let t=[];for(let n of e.split(/\r?\n/)){let e=n.replace(/\s+$/,``);if(!e||e.startsWith(`#`))continue;let r=e.startsWith(`!`);r&&(e=e.slice(1));let i=e.endsWith(`/`);i&&(e=e.slice(0,-1));let a=e.includes(`/`);e=e.replace(/^\//,``);let o=gx(e).source.slice(1,-1);t.push({regex:RegExp(a?`^${o}$`:`^(?:.*/)?${o}$`),negate:r,dirOnly:i})}return t}function vx(e,t){if(!e.length)return!1;let n=t.split(`/`);for(let t=1;t<=n.length;t++){let r=n.slice(0,t).join(`/`),i=t<n.length,a=!1;for(let t of e)(!t.dirOnly||i)&&t.regex.test(r)&&(a=!t.negate);if(a)return!0}return!1}async function yx(e){try{return _x(await u(_.join(e,`.quirlignore`),`utf8`))}catch{return[]}}function bx(e,t){return new Promise(n=>{if(!t.length)return n(/* @__PURE__ */ new Set);i(`git`,[`check-ignore`,`--stdin`,`-z`],{cwd:e,maxBuffer:268435456,timeout:6e4},(e,t)=>n(new Set(String(t??``).split(`\0`).filter(Boolean)))).stdin?.end(`${t.join(`\0`)}\0`)})}const xx=n(i),Sx=/* @__PURE__ */ new Set([`.git`,`node_modules`,`dist`,`build`,`.next`,`vendor`,`.venv`,`venv`,`__pycache__`,`coverage`,`.turbo`,`.svelte-kit`,`.nuxt`,`.output`,`.cache`,`.vercel`,`.pnpm-store`,`fixtures`,`test-fixtures`,`__fixtures__`,`testdata`]),Cx=1048576,wx=2e5;async function Tx(e){let t=[],n=await yx(e),r=(await Dx(e,t)).filter(e=>!vx(n,e.path)),i=await bx(e,r.map(e=>e.path)),a=r.filter(e=>!i.has(e.path)),o=new Map(a.map(e=>[e.path,e]));return{root:e,files:a,warnings:t,file:e=>o.get(e),async readText(e,n=Cx){if(e.size>n)return t.push(`${e.path}: skipped, ${Px(e.size)} is over the ${Px(n)} limit`),null;try{return await u(e.absolutePath,`utf8`)}catch(n){return t.push(`${e.path}: could not be read (${Mx(n)})`),null}}}}async function Ex(e,t){let n=[],r=await yx(e),{stdout:i}=await xx(`git`,[`ls-tree`,`-r`,`-l`,`-z`,`--full-tree`,t],{cwd:e,maxBuffer:268435456,timeout:6e4}),a=[];for(let e of i.split(`\0`)){let t=e.indexOf(` `);if(t===-1)continue;let[i,o,s,c]=e.slice(0,t).trim().split(/\s+/),l=e.slice(t+1);if(o===`blob`&&i!==`120000`&&s&&!l.split(`/`).some(e=>Sx.has(e))&&!vx(r,l)){if(a.length>=wx){n.push(`Stopped after ${wx} files; the rest of the tree was not scanned`);break}a.push({path:l,absolutePath:s,size:Number(c)||0})}}Ox(a);let o=new Map(a.map(e=>[e.path,e]));return{root:e,files:a,warnings:n,file:e=>o.get(e),async readText(t,r=Cx){if(t.size>r)return n.push(`${t.path}: skipped, ${Px(t.size)} is over the ${Px(r)} limit`),null;try{let{stdout:n}=await xx(`git`,[`cat-file`,`blob`,t.absolutePath],{cwd:e,maxBuffer:r+1024,timeout:3e4});return n}catch(e){return n.push(`${t.path}: could not be read (${Mx(e)})`),null}}}}async function Dx(e,t){let n=[],r=[``];for(;r.length>0;){let i=r.pop(),a;try{a=await d(_.join(e,i),{withFileTypes:!0})}catch(e){t.push(`${i||`.`}: folder could not be read (${Mx(e)})`);continue}for(let o of a){let a=i?`${i}/${o.name}`:o.name;if(o.isSymbolicLink())continue;if(o.isDirectory()){!Sx.has(o.name)&&!C(_.join(e,a,`.git`))&&r.push(a);continue}if(!o.isFile())continue;if(n.length>=wx)return t.push(`Stopped after ${wx} files; the rest of the tree was not scanned`),Ox(n);let s=_.join(e,a);try{let e=await c(s);n.push({path:a,absolutePath:s,size:e.size})}catch(e){t.push(`${a}: could not be read (${Mx(e)})`)}}}return Ox(n)}function Ox(e){return e.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path))}function kx(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function Ax(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function jx(e,t){return e?`${e}/${t}`:t}function Mx(e){return Kr(e instanceof Error?e.message:String(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Nx(e){return typeof e==`string`?e:void 0}function Px(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:`${Math.ceil(e/1024)} KB`}async function Fx({hook:e=!1}={}){let t=await mx();if(!t){if(e)return;throw Error("This folder isn't linked to a Quirl project. Run `quirl init`.")}try{let n=await new Wr(await ux()).context(t.link.projectId);process.stdout.write(`${zb(n,e?9500:void 0)}\n`)}catch(n){if(!e)throw n;process.stdout.write(`Quirl project "${t.link.name}": couldn't load the briefing (${Mx(n)}). The quirl MCP tools may still work.\n`)}}const Ix=process.stdout.isTTY&&!process.env.NO_COLOR,Lx=e=>t=>Ix?`\x1b[${e}m${t}\x1b[0m`:t,Rx=Lx(1),Q=Lx(2),zx=Lx(32),Bx=Lx(31),Vx=Lx(36),Hx=e=>console.log(`${zx(`✓`)} ${e}`),Ux=e=>console.log(` ${e}`),Wx=(e,t)=>console.log(`\n${e} ${t}`),Gx=e=>console.log(` ${e}`);function Kx(e){if(!Ix)return Gx(Q(e)),{stop:()=>{}};let t=0,n=setInterval(()=>{process.stdout.write(`\r ${Vx(`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`[t++%10]??``)} ${Q(e)}`)},80);return{stop:()=>{clearInterval(n),process.stdout.write(`\r\x1B[2K`)}}}var qx=class extends Error{};async function Jx(e,t=``){if(!process.stdin.isTTY)return t;let n=w({input:process.stdin,output:process.stdout});try{return(await n.question(e)).trim()||t}finally{n.close()}}async function Yx(e,t){let n=await Jx(`${e} ${Q(t?`[Y/n]`:`[y/N]`)} `,t?`y`:`n`);return/^y/i.test(n)}function Xx(e){if(process.env.QUIRL_NO_BROWSER)return;let t=process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,n=process.platform===`win32`?[`/c`,`start`,``,e]:[e];try{o(t,n,{stdio:`ignore`,detached:!0}).on(`error`,()=>{}).unref()}catch{}}const Zx=`.quirl-export.json`,Qx=e=>e.toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,80)||`untitled`;function $x(e){return`---\n${[[`title`,e.title],[`type`,e.type],[`status`,e.status],[`source`,e.source],[`alwaysLoad`,e.alwaysLoad],[`id`,e.id],[`created`,e.createdAt],[`updated`,e.updatedAt]].map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(`
215
- `)}\n---\n\n`}async function eS({dir:e=`quirl-docs`,all:t=!1}){let n=await mx();if(!n)throw new qx("This folder isn't linked to a Quirl project. Run `quirl init`.");let r=new Wr(await ux()),i=_.resolve(e);Wx(`📤`,`Exporting ${t?`all`:`Quirl-written`} docs from ${Rx(n.link.name)}`);let a=[];for(let e=0;;e+=100){let i=await r.call(`export_docs`,{p_project:n.link.projectId,p_only_quirl:!t,p_offset:e,p_limit:100});if(a.push(...i),i.length<100)break}let o=[],s=/* @__PURE__ */ new Set;await l(i,{recursive:!0});for(let e of a){let t=`${e.type}/${Qx(e.title)}.md`;for(let n=2;s.has(t);n++)t=`${e.type}/${Qx(e.title)}-${n}.md`;s.add(t),await l(_.join(i,e.type),{recursive:!0}),await m(_.join(i,t),$x(e)+e.body.replace(/\n*$/,`
216
- `)),o.push(t)}let c=0;try{let e=JSON.parse(await u(_.join(i,Zx),`utf8`));for(let t of e.files??[])s.has(t)||t.includes(`..`)||(await f(_.join(i,t),{force:!0}),c++)}catch{}await m(_.join(i,Zx),`${JSON.stringify({project:n.link.project,exportedAt:(/* @__PURE__ */ new Date()).toISOString(),all:t,files:o},null,` `)}\n`),Gx(`${zx(`✓`)} ${a.length} ${a.length===1?`doc`:`docs`} written to ${Vx(_.relative(process.cwd(),i)||`.`)}${c?Q(` · ${c} removed`):``}`),t||Gx(Q(`Docs synced from repos are left out; add --all to include them.`)),console.log(``)}async function tS(e,t=3){let n=[],r=async(e,i)=>{if(C(_.join(e,`.git`))&&n.push(e),i>=t)return;let a;try{a=await d(e,{withFileTypes:!0})}catch{return}for(let t of a)!t.isDirectory()||t.name.startsWith(`.`)||Sx.has(t.name)||await r(_.join(e,t.name),i+1)};return await r(_.resolve(e),0),n.sort((e,t)=>e.localeCompare(t))}const nS=`<!-- quirl:start -->`,rS=`<!-- quirl:end -->`,iS=`# quirl: keep the project in sync`;function aS(){try{let e=a(process.platform===`win32`?`where`:`which`,[`quirl`],{stdio:[`ignore`,`pipe`,`ignore`]}).toString();if(!/[\\/]_npx[\\/]/.test(e))return{command:`quirl`,args:[],shell:`quirl`,portable:!0}}catch{}return{command:`npx`,args:[`-y`,`quirl-cli`],shell:`npx -y quirl-cli`,portable:!0}}const oS=[`QUIRL_SERVER`,`QUIRL_API_URL`,`QUIRL_PUBLISHABLE_KEY`,`QUIRL_APP_URL`];function sS(){return Object.fromEntries(oS.flatMap(e=>process.env[e]?[[e,process.env[e]]]:[]))}function cS(){return`${Object.entries(sS()).map(([e,t])=>`${e}="${t}" `).join(``)}${aS().shell}`}async function lS(e){try{return JSON.parse(await u(e,`utf8`))}catch(t){if(t.code===`ENOENT`)return{};throw Error(`${e} isn't valid JSON; fix it and run \`quirl init\` again.`)}}const uS=async(e,t)=>{await l(y(e),{recursive:!0}),await m(e,`${JSON.stringify(t,null,2)}\n`)};async function dS(e){let t=x(e,`.mcp.json`),n=await lS(t),r=aS();n.mcpServers={...n.mcpServers,quirl:{command:r.command,args:[...r.args,`mcp`],...Object.keys(sS()).length?{env:sS()}:{}}},await uS(t,n)}async function fS(e){let t=x(e,`.claude`,`settings.json`),n=await lS(t),r=n.hooks??{},i=`${cS()} context --hook`;r.SessionStart=[...(r.SessionStart??[]).map(e=>({...e,hooks:e.hooks.filter(e=>!/\bcontext --hook$/.test(e.command))})).filter(e=>e.hooks.length),{hooks:[{type:`command`,command:i,timeout:15}]}],n.hooks=r,await uS(t,n)}async function pS(e,t,n=[]){let r=x(e,`CLAUDE.md`),i=``;try{i=await u(r,`utf8`)}catch{}let a=`${nS}
202
+ - If the project briefing isn't already in your context, call quirl_context first.`,qb=e=>({content:[{type:`text`,text:typeof e==`string`?e:JSON.stringify(e,null,2)}]}),Jb=[`database`,`storage`,`service`,`queue`,`auth`,`external_api`,`hosting`,`secrets`,`scheduler`,`network`,`monitoring`,`ai`],Yb=[`endpoint`,`table`,`message`,`file`,`deployment`,`variable`,`job`,`domain`,`function`,`event`,`role`,`model`],Xb=[`runs`,`serves`,`calls`,`uses`,`protects`,`triggers`,`sends_to`],Zb=`spec fields by kind (all optional unless marked):
203
+ - endpoint: method*, path*, auth (in words), request, responses
204
+ - table: table, columns [{name, type, required, description}]
205
+ - function (database function / RPC): arguments, returns, access (who can call it)
206
+ - message (queue, email, SMS): channel, topic, fields, example
207
+ - file (stored files): pathPattern, contentType, access
208
+ - deployment (Cloud Run service, Lambda…): region, url, runtime, trigger, path (folder deployed)
209
+ - variable (setting or secret): secret (true/false), environments. NEVER the value.
210
+ - job (scheduled): schedule* (cron or words), scheduleText, timeZone, runs
211
+ - domain: pointsTo, record
212
+ - event (webhook received or event sent): direction (receives|sends), counterpart, fields, example
213
+ - role: permissions (list, one line each), assignedTo
214
+ - model (AI): modelId*, usedFor, settings, calledFrom (file paths)`,Qb=H(U({relation:W(Xb),to:B().describe(`"endpoint:GET /domains", "variable:STRIPE_KEY", "resource:<name>" or "repo:<name>"`)})).describe(`Links, as [{relation, to}]. relation: runs (deployment → repo), serves (deployment → API resource or endpoint), calls (job/function/deployment → endpoint, function or model), uses (→ variable, model or resource), protects (role → table, endpoint or function), triggers (event → endpoint, job or function), sends_to (→ queue or resource). to: a contract as kind:name ("endpoint:GET /domains", "variable:STRIPE_KEY"), "resource:<name>" or "repo:<name>".`),$b={resource:B().describe(`The resource's name, provider or id (from list_resources)`),inEnvironment:B().optional().describe(`Its current environment, when the same resource exists in several`)};function ex(e){let t=new Wr(e),n=new yb({name:`quirl`,version:e.version},{instructions:e.notice?`${e.notice}\n\n${Kb}`:Kb}),r={p_project:e.project},i=()=>({tool:n.server.getClientVersion()?.name??`mcp`,model:process.env.QUIRL_AGENT_MODEL}),a=e=>async t=>{try{return qb(await e(t))}catch(e){if(e instanceof Ur)return{...qb(e.message),isError:!0};throw e}};n.registerTool(`quirl_context`,{title:`Project briefing`,description:`The project briefing: always-loaded docs in full, glossary, capabilities, your open tasks and the list of other docs. Usually already loaded at session start.`,inputSchema:{}},a(async()=>zb(await t.context(e.project)))),n.registerTool(`search_docs`,{title:`Search docs`,description:`Full-text search across the project's docs (README, ADRs, guides, runbooks). Returns matching sections with their content. Use for anything not in the briefing.`,inputSchema:{query:B().describe(`Words to search for, e.g. 'refund approval limits'`),limit:V().int().min(1).max(20).optional()}},a(({query:e,limit:n})=>t.call(`search_docs`,{...r,p_query:e,p_limit:n??6}))),n.registerTool(`read_doc`,{title:`Read a doc`,description:`Read one doc in full, by id, title or source path. source says where it lives: 'quirl' for docs written in Quirl (editable with edit_doc), otherwise the repo or folder it's synced from.`,inputSchema:{doc:B().describe(`Doc id, title or path, e.g. 'docs/adr/004-queues.md'`)}},a(({doc:e})=>t.call(`read_doc`,{...r,p_doc:e})));let o=[`product`,`guideline`,`architecture`,`decision`,`how_to`,`reference`];n.registerTool(`create_doc`,{title:`Write a new doc`,description:`Write a doc in Quirl itself: a PRD, spec or product note with no file behind it. Docs about code that tests or builds rely on belong in their repo, where sync picks them up. Use product for PRDs and specs. Never include secret values.`,inputSchema:{title:B(),body:B().describe(`Markdown. Headings (##, ###) split it into sections edit_doc can change one at a time.`),type:W(o).optional().describe(`Defaults to reference`)}},a(({title:e,body:n,type:a})=>t.call(`create_doc`,{...r,p_title:e,p_body:n,p_type:a??`reference`,p_agent:i()}))),n.registerTool(`edit_doc`,{title:`Edit a doc written in Quirl`,description:`Change one section of a doc written in Quirl, or the whole doc, without rewriting the rest. A section is named by its heading, or by its path when a heading repeats ('Billing > Refunds'). replace swaps the section's text (keeping its heading, unless the new text starts with one); append adds to the end of it. Without a section, replace rewrites the doc and append adds to its end. Docs synced from a repo or folder are changed there instead. The edit fails if the doc changed since it was read, rather than overwriting that change.`,inputSchema:{doc:B().describe(`Doc id or title`),section:B().optional().describe(`Heading text or path, e.g. 'Scope' or 'Billing > Refunds'`),content:B().describe(`Markdown`),mode:W([`replace`,`append`]).optional().describe(`Defaults to replace`),title:B().optional().describe(`A new title for the doc`),type:W(o).optional()}},a(async({doc:e,section:n,content:a,mode:o,title:s,type:c})=>{let l=await t.call(`read_doc`,{...r,p_doc:e});if(!l.editable)throw new Ur(`"${l.title}" comes from ${l.source}. Change it there; sync brings it into Quirl.`);let u;try{u=Gb(l.body,n,a,o??`replace`)}catch(e){throw new Ur(e.message)}return{...await t.call(`update_doc`,{...r,p_doc:l.id,p_title:s??null,p_body:u,p_type:c??null,p_expected_hash:l.contentHash,p_agent:i()}),edited:n??`the whole doc`,sections:Hb(u)}})),n.registerTool(`doc_history`,{title:`A doc's history`,description:`Who changed a doc and when, newest first, with lines added and removed. Pass a version to see what it changed (a diff against the version before), or full to get that version's whole text, e.g. to bring back wording with edit_doc.`,inputSchema:{doc:B().describe(`Doc id or title`),version:V().int().optional(),full:em().optional().describe(`With version: its whole text instead of the diff`)}},a(async({doc:e,version:n,full:i})=>{let a=await t.call(`doc_history`,{...r,p_doc:e,p_limit:n?200:21}),o=a.versions,s=e=>o.find(t=>t.version===e-1);if(n){let e=o.find(e=>e.version===n);if(!e)throw new Ur(`"${a.title}" has no version ${n}; the latest is ${o[0]?.version??0}.`);if(i)return{version:n,title:e.title,body:e.body};let t=s(n);return{version:n,author:e.author??`unknown`,at:e.createdAt,...t&&t.title!==e.title?{renamed:`${t.title} → ${e.title}`}:{},diff:t?Ib(t.body,e.body)||`(no text changes)`:`(first version)`}}return{title:a.title,source:a.source,versions:o.slice(0,20).map(e=>{let t=s(e.version);return{version:e.version,author:e.author??`unknown`,at:e.createdAt,change:t?Pb(Nb(t.body,e.body)):`first version`}})}})),n.registerTool(`archive_doc`,{title:`Archive a doc written in Quirl`,description:`Remove a doc written in Quirl that's no longer true or was a mistake. It's archived and stays in history. Docs synced from a repo or folder are deleted there instead.`,inputSchema:{doc:B().describe(`Doc id or title`),reason:B().optional().describe(`Why, for history`)}},a(({doc:e,reason:n})=>t.call(`archive_doc`,{...r,p_doc:e,p_reason:n??null,p_agent:i()}))),n.registerTool(`lookup`,{title:`Look up a term, capability or contract`,description:`Find glossary terms, capabilities, features and API/table contracts matching a name. Use it to check what a word means here, or the request/response shape of an endpoint or table.`,inputSchema:{query:B().describe(`A term, capability, endpoint or table name, e.g. 'Visit' or 'POST /login'`)}},a(({query:e})=>t.call(`lookup`,{...r,p_query:e})));let s=(e,t,r,i)=>{n.registerTool(e,r,i),n.registerTool(t,{...r,description:`Old name for ${e}; use ${e}. ${r.description}`},i)};s(`list_tasks`,`list_cards`,{title:`List tasks`,description:`List tasks on the board. Defaults to your own tasks that aren't done.`,inputSchema:{onlyMine:em().optional(),includeDone:em().optional()}},a(({onlyMine:e,includeDone:n})=>t.call(`list_cards`,{...r,p_only_mine:e??!0,p_include_done:n??!1})));let c=`Markdown: short paragraphs, and lists for steps or parts, not one long block.`,l=`Kind of work: e.g. Frontend, Backend, Database, Design, DevOps, Testing, Docs, Research. Only tags from the task set are accepted (see tagSets in quirl_context); propose a new value with propose_term (kind tag, tagSet task_work).`,u=B().describe(`Task number, e.g. 'K-104' or '104'`),d=B().optional().describe(`Who does it: "me", a member's email or name (only people on the project), or "none"`);return s(`get_task`,`get_card`,{title:`Get a task`,description:`A task with its feature, docs, dependencies and evidence.`,inputSchema:{task:u.optional(),card:u.optional()}},a(({task:e,card:n})=>t.call(`get_card`,{...r,p_card:e??n}))),s(`create_task`,`create_card`,{title:`Create a task`,description:`Add a task to the board (status: todo). Use it for work you discover that should be tracked. Put it under the feature it serves.`,inputSchema:{title:B(),description:B().optional().describe(`What to do and why. ${c}`),type:W([`feature_work`,`bug`,`chore`,`research`]).optional(),feature:B().optional().describe(`Feature name or id (e.g. F-4) this task belongs to`),tags:H(B()).optional().describe(l),assignee:d.describe(`Who does it: "me" (the default), a member's email or name, or "none"`)}},a(async({title:e,description:n,type:a,feature:o,tags:s,assignee:c})=>{let l=await t.call(`create_card`,{...r,p_title:e,p_description:n??``,p_type:a??`feature_work`,p_feature:o??null,p_agent:i()});return(s?.length||c)&&await t.call(`update_card`,{...r,p_card:l,p_patch:{...s?.length?{tags:s}:{},...c?{assignee:c}:{}},p_agent:i()}),l})),s(`update_task`,`update_card`,{title:`Update a task`,description:`Move a task, mark it blocked (with a reason) or unblocked, assign it, put it under a feature, set its tags, rewrite its title or description, and attach evidence: a branch, commit or pull request. Repos are referenced by name.`,inputSchema:{task:u.optional(),card:u.optional(),assignee:d,status:W([`backlog`,`todo`,`in_progress`,`review`,`done`]).optional(),feature:B().optional().describe(`Feature name or id (e.g. F-4) to put the task under; an empty string takes it off its feature`),title:B().optional(),description:B().optional().describe(`Replaces the description. ${c}`),tags:H(B()).optional().describe(`${l} Replaces the current tags.`),blocked:em().optional(),blockedReason:B().optional(),addBranch:U({repo:B(),name:B()}).optional(),addCommit:U({repo:B(),sha:B(),message:B().optional()}).optional(),addPullRequest:U({repo:B(),number:V().int(),url:B(),state:W([`open`,`merged`,`closed`]).optional()}).optional()}},a(({task:e,card:n,...a})=>t.call(`update_card`,{...r,p_card:e??n,p_patch:a,p_agent:i()}))),n.registerTool(`archive_task`,{title:`Archive a task`,description:`Remove a task that shouldn't be there: a duplicate or a mistake. It's archived and stays in history, and its feature's status is worked out without it. For work that's finished, move it to done instead.`,inputSchema:{task:u,reason:B().optional().describe(`Why, for history`)}},a(({task:e,reason:n})=>t.call(`archive_card`,{...r,p_card:e,p_reason:n??null,p_agent:i()}))),n.registerTool(`propose_term`,{title:`Propose a glossary term`,description:`Suggest a new glossary term. It shows up for approval; it isn't used until a person approves it.`,inputSchema:{term:B(),plain:B().describe(`What it means, for someone non-technical`),technical:B().describe(`What it means in the code`),kind:W([`concept`,`tag`,`name`]).optional(),tagSet:B().optional().describe(`Required for kind 'tag': the set the value belongs to, e.g. feature_change, task_work, capability_audience, capability_kind (see tagSets in quirl_context)`),reason:B().optional()}},a(({term:e,plain:n,technical:a,kind:o,tagSet:s,reason:c})=>t.call(`propose_term`,{...r,p_term:e,p_plain:n,p_technical:a,p_kind:o??`concept`,p_tag_set:s??null,p_reason:c??null,p_agent:i()}))),n.registerTool(`propose_term_retire`,{title:`Retire a glossary term`,description:`Propose retiring a glossary term or tag that's no longer used or was a mistake. With replaceWith, the term stays as one not to say (agents are told the replacement); without it, it's removed. Either way it comes off every capability, task and feature that used it. A person approves it. Built-in tag values can't be retired.`,inputSchema:{term:B().describe(`The term or tag to retire`),replaceWith:B().optional().describe(`An approved term to say instead, if there is one`),reason:B().optional()}},a(({term:e,replaceWith:n,reason:a})=>t.call(`propose_term_retire`,{...r,p_term:e,p_replace_with:n??null,p_reason:a??null,p_agent:i()}))),n.registerTool(`list_flags`,{title:`List flags`,description:`Flags are messages people send about a section of the project: a capability, feature, task, doc or glossary term. Lists open (waiting for an admin) and approved (to act on) flags, or only those with the given status.`,inputSchema:{status:W([`open`,`approved`,`removed`,`done`]).optional()}},a(({status:e})=>t.call(`list_flags`,{...r,p_status:e??null}))),n.registerTool(`decide_flag`,{title:`Approve or remove a flag`,description:`Admins only. Approve a flag so agents act on it at the start of their sessions, or remove it. An approved flag can still be removed. Only do this when the person you work for asks you to.`,inputSchema:{flag:B().describe(`The flag's id, from the briefing or list_flags`),decision:W([`approve`,`remove`])}},a(({flag:e,decision:n})=>t.call(`decide_flag`,{...r,p_flag:e,p_approve:n===`approve`,p_agent:i()}))),n.registerTool(`resolve_flag`,{title:`Mark a flag done`,description:`Mark an approved flag done once you've handled it, so it leaves the briefing. Say briefly what you did.`,inputSchema:{flag:B().describe(`The flag's id, from the briefing or list_flags`),note:B().optional().describe(`What was done, e.g. 'Updated C-12 to mention SMS'`)}},a(({flag:e,note:n})=>t.call(`resolve_flag`,{...r,p_flag:e,p_note:n??null,p_agent:i()}))),n.registerTool(`set_capability_icon`,{title:`Set a capability's icon`,description:`Give a capability an icon that fits what it does; it's shown on the capability's card. Use the same icon a related feature has when one fits both.`,inputSchema:{capability:B().describe(`Capability name or id (e.g. C-12)`),icon:W(Lb)}},a(({capability:e,icon:n})=>t.call(`set_capability_icon`,{...r,p_capability:e,p_icon:n,p_agent:i()}))),n.registerTool(`add_resource`,{title:`Add or fill in a resource`,description:"Record a service the project runs on that `quirl sync` can't see from the code: a hosted database another team runs, a SaaS named only in docs or the console, a staging copy. Sync already finds most things from env templates, docker-compose and client packages, so check Stack first (lookup) and don't add what it found. A resource with the same provider and environment is filled in rather than duplicated: the fields you give are set, and repos and capabilities are added to its links. Never pass URLs with credentials, keys or other secret values.",inputSchema:{name:B().describe(`What the team calls it, e.g. "Postgres", "Stripe"`),type:W(Jb),provider:B().optional().describe(`Who runs it, e.g. "Google Cloud SQL", "Stripe". Resources are matched on this. Defaults to the name.`),description:B().optional().describe(`One plain sentence on what the project uses it for`),technical:B().optional().describe(`Technical notes for developers: setup, access, limits`),environment:B().optional().describe(`Defaults to "production"; e.g. "staging"`),repos:H(B()).optional().describe(`Repos that use it, by name`),capabilities:H(B()).optional().describe(`Capabilities that run on it, by name or id (e.g. C-12)`),account:B().optional().describe(`The cloud project, account or team it lives in, e.g. GCP project "domainarium-staging". Sync files deployments, jobs and secrets by it. Never a key.`)}},a(e=>t.call(`add_resource`,{...r,p_name:e.name,p_type:e.type,p_provider:e.provider??null,p_description:e.description??null,p_technical:e.technical??null,p_environment:e.environment??null,p_repos:e.repos??null,p_capabilities:e.capabilities??null,p_account:e.account??null,p_agent:i()}))),n.registerTool(`list_resources`,{title:`List the project's resources`,description:`Every resource on Stack: name, type, provider, environment, whether sync found it or someone added it, the repos that use it, the capabilities that run on it, and the tables and endpoints filed under it (per repo, with a few names). Tables in the wrong database or endpoints under the wrong API: fix with move_contracts.`,inputSchema:{}},a(()=>t.call(`list_resources`,r))),n.registerTool(`update_resource`,{title:`Change a resource`,description:`Correct a resource: rename it, relabel its environment (a scanned one that's really the local docker database becomes 'local'), or change its type, provider, descriptions or links. Only the fields you pass change. repos and capabilities replace its links; use add_resource to add to them. A repo you take off stays off: sync won't link it again until a person adds it back. Sync keeps updating a relabelled resource instead of adding it again. Never pass secret values.`,inputSchema:{...$b,name:B().optional(),type:W(Jb).optional(),provider:B().optional(),environment:B().optional().describe(`e.g. "production", "staging", "dev", "local"`),description:B().optional().describe(`One plain sentence on what the project uses it for`),technical:B().optional().describe(`Notes for developers`),repos:H(B()).optional().describe(`Replaces the repos that use it. Ones left out stay off through later syncs.`),capabilities:H(B()).optional().describe(`Replaces the capabilities that run on it (names or C-12)`),account:B().optional().describe(`The cloud project, account or team it lives in, e.g. GCP project "domainarium-staging". Sync files deployments, jobs and secrets by it. Never a key. Empty clears it.`)}},a(e=>t.call(`update_resource`,{...r,p_resource:e.resource,p_in_environment:e.inEnvironment??null,p_name:e.name??null,p_type:e.type??null,p_provider:e.provider??null,p_environment:e.environment??null,p_description:e.description??null,p_technical:e.technical??null,p_repos:e.repos??null,p_capabilities:e.capabilities??null,p_account:e.account??null,p_agent:i()}))),n.registerTool(`remove_resource`,{title:`Remove a wrong resource`,description:`Remove a resource that isn't one: a false match from sync, a duplicate, something no longer used. It's archived, stays in history, and sync won't add it again. A resource holding endpoints or tables from sync can't be removed; relabel it instead.`,inputSchema:{...$b,reason:B().optional().describe(`Why it's wrong, for history`)}},a(e=>t.call(`remove_resource`,{...r,p_resource:e.resource,p_in_environment:e.inEnvironment??null,p_reason:e.reason??null,p_agent:i()}))),n.registerTool(`get_resource`,{title:`Get a resource and what it holds`,description:`One resource with everything it holds: endpoints, tables, functions, deployments, variables (names only), jobs, domains, events, roles, models. Each with its fields (spec), whether sync found it or someone added it, and its links (what it runs, calls, uses or protects, and what points at it). Use before adding or changing what a resource holds.`,inputSchema:$b},a(e=>t.call(`get_resource`,{...r,p_resource:e.resource,p_in_environment:e.inEnvironment??null}))),n.registerTool(`add_contract`,{title:`Add something a resource holds`,description:`Record what the code doesn't show: a Cloud Scheduler job set up in the console, the variables Secret Manager holds (names, never values), a Cloud Run service, the roles the product has, the AI models it calls, a webhook it receives, a domain. Sync finds endpoints and tables from OpenAPI files and migrations, so check get_resource first. What you add stays until someone removes it; if sync later finds the same thing in code, it takes it over. Never pass secret values, keys or URLs with credentials.\n\n${Zb}`,inputSchema:{...$b,kind:W(Yb),name:B().optional().describe(`e.g. "nightly-invoices", "STRIPE_SECRET_KEY", "admin", "claude-opus-5-5". Endpoints default to "METHOD /path".`),description:B().optional().describe(`One plain sentence: what it is or does`),spec:_m(B(),im()).optional().describe(`The kind's fields; see the list above`),repo:B().optional().describe(`The repo it belongs to, if any`),links:Qb.optional()}},a(e=>t.call(`add_contract`,{...r,p_resource:e.resource,p_in_environment:e.inEnvironment??null,p_kind:e.kind,p_name:e.name??null,p_description:e.description??null,p_spec:e.spec??null,p_repo:e.repo??null,p_links:e.links??null,p_agent:i()}))),n.registerTool(`update_contract`,{title:`Change something a resource holds`,description:`Correct or fill in a contract: its description, its fields, its links. spec is merged: given fields are set, a field set to null is removed. links, when given, replace the links people added (sync's stay). On something sync found (an endpoint from OpenAPI, a table from migrations) only the description and links change here; the rest follows the code. To file it under another resource, use move_contracts.\n\n${Zb}`,inputSchema:{contract:B().describe(`kind:name ("job:nightly-invoices", "endpoint:GET /domains"), a unique name, or its id (from get_resource)`),resource:B().optional().describe(`Its resource, when the name is in several`),inEnvironment:B().optional(),name:B().optional(),description:B().optional(),spec:_m(B(),im()).optional(),links:Qb.optional()}},a(e=>t.call(`update_contract`,{...r,p_contract:e.contract,p_resource:e.resource??null,p_in_environment:e.inEnvironment??null,p_name:e.name??null,p_description:e.description??null,p_spec:e.spec??null,p_links:e.links??null,p_agent:i()}))),n.registerTool(`remove_contract`,{title:`Remove something added to a resource`,description:`Remove a contract someone added that's wrong or gone: a deleted job, a retired variable. It's archived and stays in history. What sync found from code can't be removed here: change the code, or move it with move_contracts if it's filed in the wrong place.`,inputSchema:{contract:B().describe(`kind:name ("variable:OLD_KEY"), a unique name, or its id`),resource:B().optional(),inEnvironment:B().optional(),reason:B().optional().describe(`Why, for history`)}},a(e=>t.call(`remove_contract`,{...r,p_contract:e.contract,p_resource:e.resource??null,p_in_environment:e.inEnvironment??null,p_reason:e.reason??null,p_agent:i()}))),n.registerTool(`move_contracts`,{title:`Move what sync filed to another resource`,description:`Correct where sync filed a repo's tables (which database), endpoints (which API), deployments (which Cloud Run project), jobs, variables, functions, roles or models. Without names, all of the repo's ones of that kind move and later syncs put new ones there too. With names, only those move and sync leaves them there. list_resources shows what's filed where. For deployments in the wrong environment, setting the resource's account (update_resource) also fixes later syncs. With also, they're filed under this resource as well as where they are: the same endpoints served by the dev and the prod API.`,inputSchema:{repo:B().describe(`The repo they come from: name, URL or id`),kind:W([...Yb,`tables`,`endpoints`]),to:B().describe(`The resource they belong to: name, provider or id`),toEnvironment:B().optional().describe(`Its environment, when it exists in several`),names:H(B()).optional().describe(`Only these, e.g. ["bookings"] or ["GET /bookings"]; leave out to move all`),also:em().optional().describe(`Keep them where they are and file them here too, e.g. endpoints served in dev and in prod`)}},a(e=>t.call(`move_contracts`,{...r,p_repo:e.repo,p_kind:e.kind,p_to:e.to,p_in_environment:e.toEnvironment??null,p_names:e.names??null,p_also:e.also??!1,p_agent:i()}))),n.registerTool(`remove_repo`,{title:`Remove a repo`,description:"Remove a repo from the project, for admins: one that's retired, or was imported by mistake. Its dependencies, endpoints, tables and synced docs are archived with it, and it's unlinked from capabilities, tasks and resources. Sync skips it from then on; running `quirl init` in it adds it back. Only on the person's request: confirm with them first. To rename a repo instead, set its name in .quirl/project.json and sync.",inputSchema:{repo:B().describe(`The repo's name, URL or id`),reason:B().optional().describe(`Why it's removed, for history`)}},a(e=>t.call(`remove_repo`,{...r,p_repo:e.repo,p_reason:e.reason??null,p_agent:i()}))),n.registerTool(`list_features`,{title:`List features`,description:`List the project's features with their status, the capability each changes (or createsCapability when it has none), and task counts. Shipped ones are left out unless includeShipped. Check here before requesting a feature.`,inputSchema:{includeShipped:em().optional()}},a(({includeShipped:e})=>t.call(`list_features`,{...r,p_include_shipped:e??!1}))),n.registerTool(`get_feature`,{title:`Get a feature`,description:`A feature with its description, status, the capability it changes (and what that capability does) and its tasks.`,inputSchema:{feature:B().describe(`Feature name or id (e.g. F-4)`)}},a(({feature:e})=>t.call(`get_feature`,{...r,p_feature:e}))),n.registerTool(`request_feature`,{title:`Request a feature`,description:`Request a feature: a change to the product that stakeholders follow on the Features page, usually made of several tasks. Check list_features first so you don't request one twice. It shows as requested straight away and a person accepts or declines it. Put tasks under it with create_task or update_task.`,inputSchema:{name:B().describe(`Short name, e.g. 'Repeat appointments'`),description:B().describe(`What changes for the user, in plain words. Markdown: short paragraphs, and lists for parts`),capability:B().optional().describe(`Capability name or id (e.g. C-12) it changes. Leave it out when the feature creates a new capability`),tags:H(B()).optional().describe(`Kind of change: e.g. New, Improvement, Visual, Fix, Performance, Security, Removal, Internal (the feature_change set in quirl_context)`),reason:B().optional().describe(`Why it's worth doing`),icon:W(Lb).optional().describe(`An icon that fits the feature, shown on its card`)}},a(async({name:e,description:n,capability:a,tags:o,reason:s,icon:c})=>{let l=await t.call(`request_feature`,{...r,p_name:e,p_description:n,p_capability:a??null,p_tags:o??null,p_reason:s??null,p_agent:i()});return c&&l===`requested`&&await t.call(`set_feature_icon`,{...r,p_feature:e,p_icon:c,p_agent:i()}),l})),n.registerTool(`set_feature_icon`,{title:`Set a feature's icon`,description:`Give a feature an icon that fits what it does; it's shown on the feature's card. list_features shows which features have none.`,inputSchema:{feature:B().describe(`Feature name or id (e.g. F-4)`),icon:W(Lb)}},a(({feature:e,icon:n})=>t.call(`set_feature_icon`,{...r,p_feature:e,p_icon:n,p_agent:i()}))),n.registerTool(`update_feature`,{title:`Correct a feature`,description:`Fix a feature's name, description or the capability it changes, e.g. after requesting it with the wrong one. Only the fields you pass change; it shows in the feature's history. Tags: tag_feature; icon: set_feature_icon.`,inputSchema:{feature:B().describe(`Feature name or id (e.g. F-4)`),name:B().optional(),description:B().optional().describe(`What changes for the user, in plain words. Markdown: short paragraphs, and lists for parts`),capability:B().optional().describe(`The capability it changes (name or C-12), or "none" when it creates a new one`)}},a(({feature:e,name:n,description:a,capability:o})=>t.call(`update_feature`,{...r,p_feature:e,p_name:n??null,p_description:a??null,p_capability:o??null,p_agent:i()}))),n.registerTool(`withdraw_feature`,{title:`Withdraw a feature`,description:`Remove a feature that shouldn't be there: a duplicate, a mistake, or an idea dropped before any work. It's archived and stays in history. One that shipped can't be withdrawn; move or archive its tasks first (update_task, archive_task).`,inputSchema:{feature:B().describe(`Feature name or id (e.g. F-4)`),reason:B().optional().describe(`Why, for history`)}},a(({feature:e,reason:n})=>t.call(`withdraw_feature`,{...r,p_feature:e,p_reason:n??null,p_agent:i()}))),n.registerTool(`tag_feature`,{title:`Tag a feature`,description:`Set a feature's kind-of-change tags (replaces the current ones). Only values from the feature_change tag set are accepted.`,inputSchema:{feature:B().describe(`Feature name or id (e.g. F-4)`),tags:H(B()).describe(`Kind of change: e.g. New, Improvement, Visual, Fix, Performance, Security, Removal, Internal`)}},a(({feature:e,tags:n})=>t.call(`tag_feature`,{...r,p_feature:e,p_tags:n,p_agent:i()}))),n.registerTool(`list_capabilities`,{title:`List the capabilities`,description:`Every capability as data: id (C-12), name, status, icon, the capability it's part of, what it does, what it relies on, its tags and the features changing it. Retired ones only with includeRetired.`,inputSchema:{includeRetired:em().optional()}},a(({includeRetired:e})=>t.call(`list_capabilities`,{...r,p_include_retired:e??!1}))),n.registerTool(`propose_capability`,{title:`Propose a capability`,description:"Draft a capability: one thing the product does today, described for a non-technical reader. Use it when the project has none yet (for example right after `quirl init`), when you find one that's missing, or when a feature that creates a new capability ships (pass it in features). Never for something not built yet: request a feature instead. A person approves it before it shows up.",inputSchema:{name:B().describe(`Short name, e.g. 'Online booking'`),whatItDoes:B().describe(`One or two plain sentences, no jargon`),technical:B().optional().describe(`Where it lives in the code and how it works. Markdown: short paragraphs, and lists for parts, not one long block`),features:H(B()).optional().describe(`Feature names or ids (e.g. F-4) that create or change this capability; they're linked to it once it's approved`),reason:B().optional()}},a(({name:e,whatItDoes:n,technical:a,features:o,reason:s})=>t.call(`propose_capability`,{...r,p_name:e,p_what_it_does:n,p_technical:a??``,p_features:o??null,p_reason:s??null,p_agent:i()}))),n.registerTool(`propose_capability_archive`,{title:`Propose archiving a capability`,description:`Suggest retiring a capability that no longer describes what the product does, or that was drafted for something not built yet. Unshipped features linked to it will create a new capability when they ship. A person approves it.`,inputSchema:{capability:B().describe(`Capability name or id (e.g. C-12)`),reason:B().describe(`Why it should go`)}},a(({capability:e,reason:n})=>t.call(`propose_capability_archive`,{...r,p_capability:e,p_reason:n,p_agent:i()}))),n.registerTool(`propose_capability_update`,{title:`Propose a capability correction`,description:`Suggest a corrected name or description for a capability when the code no longer matches it. A person approves it.`,inputSchema:{capability:B().describe(`Capability name or id (e.g. C-12)`),field:W([`name`,`what_it_does`,`technical_description`]),after:B().describe(`The new name, or the corrected text. Markdown: short paragraphs, and lists for parts, not one long block`),reason:B().optional()}},a(({capability:e,field:n,after:a,reason:o})=>t.call(`propose_capability_update`,{...r,p_capability:e,p_field:n,p_after:a,p_reason:o??null,p_agent:i()}))),n.registerTool(`propose_capability_details`,{title:`Propose how a capability works and its connections`,description:`Suggest a capability's 'How it works' steps, its tags (glossary terms of kind 'tag'), the capability it's part of, and its connections: capabilities it relies on, repos, resources it runs on, glossary terms and docs. Each part you pass replaces that part when a person approves it; parts you leave out are kept. Names are matched to existing, approved items. What it relies on draws the arrows on the Home map, so link the steps a user goes through (e.g. invoicing relies on booking).`,inputSchema:{capability:B().describe(`Capability name or id (e.g. C-12)`),howItWorks:H(B()).optional().describe(`3 to 5 plain-language steps, as the user experiences it`),reliesOn:H(U({capability:B().describe(`Capability name or id (e.g. C-12)`),label:B().describe(`How it relies on it, read before the name, e.g. 'extends'`)})).optional(),parent:B().optional().describe(`The capability this one is part of (name or id, e.g. C-2), or 'none' to make it top-level. Parts are listed under their parent instead of on their own`),repos:H(B()).optional().describe(`Repo names`),resources:H(B()).optional().describe(`Resource names it runs on`),terms:H(B()).optional().describe(`Glossary terms`),docs:H(B()).optional().describe(`Doc titles, or <repo>/<path> (e.g. quirl/AGENTS.md) when titles repeat`),tags:H(B()).optional().describe(`Who it's for (Customer, Admin, Developer, Agent) and its kind (Interface, Integration, Data, Automation, Infrastructure, Access and security, AI): the capability tag sets in quirl_context`),reason:B().optional()}},a(({capability:e,howItWorks:n,reliesOn:a,parent:o,repos:s,resources:c,terms:l,docs:u,tags:d,reason:f})=>t.call(`propose_capability_details`,{...r,p_capability:e,p_how_it_works:n??null,p_relies_on:a??null,p_parent:o??null,p_repos:s??null,p_resources:c??null,p_terms:l??null,p_docs:u??null,p_tags:d??null,p_reason:f??null,p_agent:i()}))),n}async function tx(e){await ex(e).connect(new Mb)}const nx=`0.1.14`,rx=process.env.QUIRL_SERVER===`local`?{apiUrl:`http://127.0.0.1:54321`,publishableKey:`sb_publishable_ACJWlzQHlZjBrEguHvfOxg_3BJgxAaH`,appUrl:`http://localhost:5173`}:{apiUrl:`https://dugevhzlzrdtasuibdzr.supabase.co`,publishableKey:`sb_publishable_45P7GyyZoJsN0AO3wfmqNA_CXbx1iCW`,appUrl:`https://app.quirl.io`};function ix(){return{apiUrl:process.env.QUIRL_API_URL??rx.apiUrl,publishableKey:process.env.QUIRL_PUBLISHABLE_KEY??rx.publishableKey,appUrl:process.env.QUIRL_APP_URL??rx.appUrl}}const ax=()=>x(process.env.XDG_CONFIG_HOME??x(h(),`.config`),`quirl`),ox=()=>x(ax(),`credentials.json`);async function sx(){try{return JSON.parse(await u(ox(),`utf8`))}catch{return{}}}async function cx(){return process.env.QUIRL_KEY?{apiUrl:ix().apiUrl,key:process.env.QUIRL_KEY,email:``}:(await sx())[ix().apiUrl]??null}async function lx(e){let t=await sx();t[e.apiUrl]=e,await l(ax(),{recursive:!0,mode:448}),await m(ox(),`${JSON.stringify(t,null,` `)}\n`,{mode:384}),await s(ox(),384)}async function ux(){let e=await sx();delete e[ix().apiUrl],Object.keys(e).length?await m(ox(),`${JSON.stringify(e,null,` `)}\n`,{mode:384}):await f(ox(),{force:!0})}async function dx(){let e=ix();return{apiUrl:e.apiUrl,publishableKey:e.publishableKey,key:(await cx())?.key??``}}function fx(e){return(e.repos??[]).map(e=>typeof e==`string`?{path:e}:e)}function px(e=process.cwd()){try{return a(`git`,[`rev-parse`,`--show-toplevel`],{cwd:e,stdio:[`ignore`,`pipe`,`ignore`]}).toString().trim()}catch{return e}}const mx=e=>x(e,`.quirl`,`project.json`);async function hx(e=process.cwd()){let t=e;for(;;)try{return{root:t,link:JSON.parse(await u(mx(t),`utf8`))}}catch{let e=y(t);if(e===t)return null;t=e}}async function gx(e,t){await l(x(e,`.quirl`),{recursive:!0}),await m(mx(e),`${JSON.stringify(t,null,` `)}\n`)}function _x(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];r===`*`?e[n+1]===`*`?(t+=e[n+2]===`/`?`(?:.*/)?`:`.*`,n+=e[n+2]===`/`?2:1):t+=`[^/]*`:t+=r===`?`?`[^/]`:r.replace(/[.+^${}()|[\]\\]/g,`\\$&`)}return RegExp(`^${t}$`)}function vx(e){let t=[];for(let n of e.split(/\r?\n/)){let e=n.replace(/\s+$/,``);if(!e||e.startsWith(`#`))continue;let r=e.startsWith(`!`);r&&(e=e.slice(1));let i=e.endsWith(`/`);i&&(e=e.slice(0,-1));let a=e.includes(`/`);e=e.replace(/^\//,``);let o=_x(e).source.slice(1,-1);t.push({regex:RegExp(a?`^${o}$`:`^(?:.*/)?${o}$`),negate:r,dirOnly:i})}return t}function yx(e,t){if(!e.length)return!1;let n=t.split(`/`);for(let t=1;t<=n.length;t++){let r=n.slice(0,t).join(`/`),i=t<n.length,a=!1;for(let t of e)(!t.dirOnly||i)&&t.regex.test(r)&&(a=!t.negate);if(a)return!0}return!1}async function bx(e){try{return vx(await u(_.join(e,`.quirlignore`),`utf8`))}catch{return[]}}function xx(e,t){return new Promise(n=>{if(!t.length)return n(/* @__PURE__ */ new Set);i(`git`,[`check-ignore`,`--stdin`,`-z`],{cwd:e,maxBuffer:268435456,timeout:6e4},(e,t)=>n(new Set(String(t??``).split(`\0`).filter(Boolean)))).stdin?.end(`${t.join(`\0`)}\0`)})}const Sx=n(i),Cx=/* @__PURE__ */ new Set([`.git`,`node_modules`,`dist`,`build`,`.next`,`vendor`,`.venv`,`venv`,`__pycache__`,`coverage`,`.turbo`,`.svelte-kit`,`.nuxt`,`.output`,`.cache`,`.vercel`,`.pnpm-store`,`fixtures`,`test-fixtures`,`__fixtures__`,`testdata`]),wx=1048576,Tx=2e5;async function Ex(e){let t=[],n=await bx(e),r=(await Ox(e,t)).filter(e=>!yx(n,e.path)),i=await xx(e,r.map(e=>e.path)),a=r.filter(e=>!i.has(e.path)),o=new Map(a.map(e=>[e.path,e]));return{root:e,files:a,warnings:t,file:e=>o.get(e),async readText(e,n=wx){if(e.size>n)return t.push(`${e.path}: skipped, ${Fx(e.size)} is over the ${Fx(n)} limit`),null;try{return await u(e.absolutePath,`utf8`)}catch(n){return t.push(`${e.path}: could not be read (${Nx(n)})`),null}}}}async function Dx(e,t){let n=[],r=await bx(e),{stdout:i}=await Sx(`git`,[`ls-tree`,`-r`,`-l`,`-z`,`--full-tree`,t],{cwd:e,maxBuffer:268435456,timeout:6e4}),a=[];for(let e of i.split(`\0`)){let t=e.indexOf(` `);if(t===-1)continue;let[i,o,s,c]=e.slice(0,t).trim().split(/\s+/),l=e.slice(t+1);if(o===`blob`&&i!==`120000`&&s&&!l.split(`/`).some(e=>Cx.has(e))&&!yx(r,l)){if(a.length>=Tx){n.push(`Stopped after ${Tx} files; the rest of the tree was not scanned`);break}a.push({path:l,absolutePath:s,size:Number(c)||0})}}kx(a);let o=new Map(a.map(e=>[e.path,e]));return{root:e,files:a,warnings:n,file:e=>o.get(e),async readText(t,r=wx){if(t.size>r)return n.push(`${t.path}: skipped, ${Fx(t.size)} is over the ${Fx(r)} limit`),null;try{let{stdout:n}=await Sx(`git`,[`cat-file`,`blob`,t.absolutePath],{cwd:e,maxBuffer:r+1024,timeout:3e4});return n}catch(e){return n.push(`${t.path}: could not be read (${Nx(e)})`),null}}}}async function Ox(e,t){let n=[],r=[``];for(;r.length>0;){let i=r.pop(),a;try{a=await d(_.join(e,i),{withFileTypes:!0})}catch(e){t.push(`${i||`.`}: folder could not be read (${Nx(e)})`);continue}for(let o of a){let a=i?`${i}/${o.name}`:o.name;if(o.isSymbolicLink())continue;if(o.isDirectory()){!Cx.has(o.name)&&!C(_.join(e,a,`.git`))&&r.push(a);continue}if(!o.isFile())continue;if(n.length>=Tx)return t.push(`Stopped after ${Tx} files; the rest of the tree was not scanned`),kx(n);let s=_.join(e,a);try{let e=await c(s);n.push({path:a,absolutePath:s,size:e.size})}catch(e){t.push(`${a}: could not be read (${Nx(e)})`)}}}return kx(n)}function kx(e){return e.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path))}function Ax(e){let t=e.lastIndexOf(`/`);return t===-1?e:e.slice(t+1)}function jx(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function Mx(e,t){return e?`${e}/${t}`:t}function Nx(e){return Kr(e instanceof Error?e.message:String(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Px(e){return typeof e==`string`?e:void 0}function Fx(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:`${Math.ceil(e/1024)} KB`}const Ix=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++)if((n[e]??0)!==(r[e]??0))return(n[e]??0)>(r[e]??0);return!1};async function Lx(){try{let e=await fetch(`https://registry.npmjs.org/quirl-cli/latest`,{signal:AbortSignal.timeout(1500)});if(!e.ok)return null;let{version:t}=await e.json();return t&&Ix(t,`0.1.14`)?t:null}catch{return null}}const Rx=e=>`These Quirl tools are version ${nx}; ${e} is out, so some tools or options may be missing (for example resource types, or kinds move_contracts takes). Tell the person: run \`npx quirl-cli@latest init\` in this repo, then restart Claude Code.`;async function zx({hook:e=!1}={}){let t=await hx();if(!t){if(e)return;throw Error("This folder isn't linked to a Quirl project. Run `quirl init`.")}try{let[n,r]=await Promise.all([new Wr(await dx()).context(t.link.projectId),Lx()]),i=r?`${Rx(r)}\n\n`:``;process.stdout.write(`${i}${zb(n,e?9500-i.length:void 0)}\n`)}catch(n){if(!e)throw n;process.stdout.write(`Quirl project "${t.link.name}": couldn't load the briefing (${Nx(n)}). The quirl MCP tools may still work.\n`)}}const Bx=process.stdout.isTTY&&!process.env.NO_COLOR,Vx=e=>t=>Bx?`\x1b[${e}m${t}\x1b[0m`:t,Hx=Vx(1),Q=Vx(2),Ux=Vx(32),Wx=Vx(31),Gx=Vx(36),Kx=e=>console.log(`${Ux(`✓`)} ${e}`),qx=e=>console.log(` ${e}`),Jx=(e,t)=>console.log(`\n${e} ${t}`),Yx=e=>console.log(` ${e}`);function Xx(e){if(!Bx)return Yx(Q(e)),{stop:()=>{}};let t=0,n=setInterval(()=>{process.stdout.write(`\r ${Gx(`⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`[t++%10]??``)} ${Q(e)}`)},80);return{stop:()=>{clearInterval(n),process.stdout.write(`\r\x1B[2K`)}}}var Zx=class extends Error{};async function Qx(e,t=``){if(!process.stdin.isTTY)return t;let n=w({input:process.stdin,output:process.stdout});try{return(await n.question(e)).trim()||t}finally{n.close()}}async function $x(e,t){let n=await Qx(`${e} ${Q(t?`[Y/n]`:`[y/N]`)} `,t?`y`:`n`);return/^y/i.test(n)}function eS(e){if(process.env.QUIRL_NO_BROWSER)return;let t=process.platform===`darwin`?`open`:process.platform===`win32`?`cmd`:`xdg-open`,n=process.platform===`win32`?[`/c`,`start`,``,e]:[e];try{o(t,n,{stdio:`ignore`,detached:!0}).on(`error`,()=>{}).unref()}catch{}}const tS=`.quirl-export.json`,nS=e=>e.toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,80)||`untitled`;function rS(e){return`---\n${[[`title`,e.title],[`type`,e.type],[`status`,e.status],[`source`,e.source],[`alwaysLoad`,e.alwaysLoad],[`id`,e.id],[`created`,e.createdAt],[`updated`,e.updatedAt]].map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(`
215
+ `)}\n---\n\n`}async function iS({dir:e=`quirl-docs`,all:t=!1}){let n=await hx();if(!n)throw new Zx("This folder isn't linked to a Quirl project. Run `quirl init`.");let r=new Wr(await dx()),i=_.resolve(e);Jx(`📤`,`Exporting ${t?`all`:`Quirl-written`} docs from ${Hx(n.link.name)}`);let a=[];for(let e=0;;e+=100){let i=await r.call(`export_docs`,{p_project:n.link.projectId,p_only_quirl:!t,p_offset:e,p_limit:100});if(a.push(...i),i.length<100)break}let o=[],s=/* @__PURE__ */ new Set;await l(i,{recursive:!0});for(let e of a){let t=`${e.type}/${nS(e.title)}.md`;for(let n=2;s.has(t);n++)t=`${e.type}/${nS(e.title)}-${n}.md`;s.add(t),await l(_.join(i,e.type),{recursive:!0}),await m(_.join(i,t),rS(e)+e.body.replace(/\n*$/,`
216
+ `)),o.push(t)}let c=0;try{let e=JSON.parse(await u(_.join(i,tS),`utf8`));for(let t of e.files??[])s.has(t)||t.includes(`..`)||(await f(_.join(i,t),{force:!0}),c++)}catch{}await m(_.join(i,tS),`${JSON.stringify({project:n.link.project,exportedAt:(/* @__PURE__ */ new Date()).toISOString(),all:t,files:o},null,` `)}\n`),Yx(`${Ux(`✓`)} ${a.length} ${a.length===1?`doc`:`docs`} written to ${Gx(_.relative(process.cwd(),i)||`.`)}${c?Q(` · ${c} removed`):``}`),t||Yx(Q(`Docs synced from repos are left out; add --all to include them.`)),console.log(``)}async function aS(e,t=3){let n=[],r=async(e,i)=>{if(C(_.join(e,`.git`))&&n.push(e),i>=t)return;let a;try{a=await d(e,{withFileTypes:!0})}catch{return}for(let t of a)!t.isDirectory()||t.name.startsWith(`.`)||Cx.has(t.name)||await r(_.join(e,t.name),i+1)};return await r(_.resolve(e),0),n.sort((e,t)=>e.localeCompare(t))}const oS=`<!-- quirl:start -->`,sS=`<!-- quirl:end -->`,cS=`# quirl: keep the project in sync`;function lS(){try{let e=a(process.platform===`win32`?`where`:`which`,[`quirl`],{stdio:[`ignore`,`pipe`,`ignore`]}).toString();if(!/[\\/]_npx[\\/]/.test(e))return{command:`quirl`,args:[],shell:`quirl`,portable:!0}}catch{}return{command:`npx`,args:[`-y`,`quirl-cli@latest`],shell:`npx -y quirl-cli@latest`,portable:!0}}const uS=[`QUIRL_SERVER`,`QUIRL_API_URL`,`QUIRL_PUBLISHABLE_KEY`,`QUIRL_APP_URL`];function dS(){return Object.fromEntries(uS.flatMap(e=>process.env[e]?[[e,process.env[e]]]:[]))}function fS(){return`${Object.entries(dS()).map(([e,t])=>`${e}="${t}" `).join(``)}${lS().shell}`}async function pS(e){try{return JSON.parse(await u(e,`utf8`))}catch(t){if(t.code===`ENOENT`)return{};throw Error(`${e} isn't valid JSON; fix it and run \`quirl init\` again.`)}}const mS=async(e,t)=>{await l(y(e),{recursive:!0}),await m(e,`${JSON.stringify(t,null,2)}\n`)};async function hS(e){let t=x(e,`.mcp.json`),n=await pS(t),r=lS();n.mcpServers={...n.mcpServers,quirl:{command:r.command,args:[...r.args,`mcp`],...Object.keys(dS()).length?{env:dS()}:{}}},await mS(t,n)}async function gS(e){let t=x(e,`.claude`,`settings.json`),n=await pS(t),r=n.hooks??{},i=`${fS()} context --hook`;r.SessionStart=[...(r.SessionStart??[]).map(e=>({...e,hooks:e.hooks.filter(e=>!/\bcontext --hook$/.test(e.command))})).filter(e=>e.hooks.length),{hooks:[{type:`command`,command:i,timeout:15}]}],n.hooks=r,await mS(t,n)}async function _S(e,t,n=[]){let r=x(e,`CLAUDE.md`),i=``;try{i=await u(r,`utf8`)}catch{}let a=`${oS}
217
217
  ## Quirl
218
218
 
219
219
  ${n.length?`This folder holds the repos of the Quirl project **${t}** (${n.join(`, `)}). Quirl is`:`This repo is part of the Quirl project **${t}**,`} the team's source of truth for what the product does. The project briefing (always-loaded docs, glossary, capabilities, your tasks) is loaded at the start of each session. Use the \`quirl\` MCP tools:
@@ -226,24 +226,24 @@ ${n.length?`This folder holds the repos of the Quirl project **${t}** (${n.join(
226
226
  - Capabilities describe only what exists; anything not built yet is a feature. When a feature ships, propose the capability change (\`propose_capability_update\`, or \`propose_capability\` with \`features\` for a new one).
227
227
  - If a capability description or term is wrong or missing, propose a fix (\`propose_capability_update\`, \`propose_term\`) instead of working around it. Retire a term that's no longer used with \`propose_term_retire\`.
228
228
  - After changing docs, dependencies or schemas, run \`quirl sync\` (the pre-push hook does it on push).
229
- ${rS}`,o=RegExp(`${nS}[\\s\\S]*?${rS}`);i=o.test(i)?i.replace(o,a):`${i.trimEnd()}${i.trim()?`
229
+ ${sS}`,o=RegExp(`${oS}[\\s\\S]*?${sS}`);i=o.test(i)?i.replace(o,a):`${i.trimEnd()}${i.trim()?`
230
230
 
231
- `:``}${a}\n`,await m(r,i)}async function mS(e){let t;try{t=a(`git`,[`rev-parse`,`--git-path`,`hooks`],{cwd:e}).toString().trim()}catch{return null}b(t)||(t=x(e,t));let n=x(t,`pre-push`),r=``;try{r=await u(n,`utf8`)}catch{}let i=`${iS}\n${cS()} sync --quiet --source=git_hook || echo "quirl: sync skipped"\n`,o=r.indexOf(iS);if(o>=0){let e=r.indexOf(`
231
+ `:``}${a}\n`,await m(r,i)}async function vS(e){let t;try{t=a(`git`,[`rev-parse`,`--git-path`,`hooks`],{cwd:e}).toString().trim()}catch{return null}b(t)||(t=x(e,t));let n=x(t,`pre-push`),r=``;try{r=await u(n,`utf8`)}catch{}let i=`${cS}\n${fS()} sync --quiet --source=git_hook || echo "quirl: sync skipped"\n`,o=r.indexOf(cS);if(o>=0){let e=r.indexOf(`
232
232
  `,r.indexOf(`
233
- `,o)+1);r=`${r.slice(0,o)}${i}${e>=0?r.slice(e+1):``}`}else r=r?`${r.trimEnd()}\n\n${i}`:`#!/bin/sh\n${i}`;return await l(t,{recursive:!0}),await m(n,r),await s(n,493),n}async function hS({quiet:e=!1}={}){let t=rx(),n=await sx();Wx(`🔑`,Rx(`Sign in to Quirl`)),n&&!e&&Gx(Q(`Already signed in as ${n.email}. Signing in again replaces this machine's key.`));let r=Gr(t.apiUrl,t.publishableKey),i=await r.start(`quirl CLI on ${g()}`),a=`${t.appUrl}/cli/authorize?code=${i.user_code}`;Gx(`Approve this computer in your browser:`),Gx(Vx(a)),Gx(`Check the code matches ${Rx(gS(i.user_code))}`),Xx(a);let o=Kx(`Waiting for you to approve…`),s=Date.now()+6e5;for(;Date.now()<s;){await new Promise(e=>setTimeout(e,2e3));let e=await r.poll(i.request_id,i.poll_secret);if(e.status===`approved`&&e.key){let n=await new Wr({...t,key:e.key}).whoami();return o.stop(),await cx({apiUrl:t.apiUrl,key:e.key,email:n.email}),Gx(`${zx(`✓`)} Signed in as ${Rx(n.email)}`),n}if(e.status!==`pending`)throw o.stop(),new qx(`Sign-in ${e.status}. Run \`quirl login\` again.`)}throw o.stop(),new qx("Sign-in timed out. Run `quirl login` again.")}const gS=e=>`${e.slice(0,4)}-${e.slice(4)}`,_S=/* @__PURE__ */ new Set([`docs`,`doc`,`adr`,`adrs`,`architecture`]),vS=/* @__PURE__ */ new Set([`readme.md`,`contributing.md`,`architecture.md`]),yS=/^(changelog|changes|history|license|licence|copying|notice|code_of_conduct|claude|agents)(\.|$)/i,bS=/\.(md|mdx|markdown)$/i,xS=/* @__PURE__ */ new Set([`tasks`,`todo`,`todos`,`issues`,`tickets`,`inbox`,`archive`,`archived`]),SS=/^(package\.json|pyproject\.toml|requirements\.txt|go\.mod|cargo\.toml|composer\.json|gemfile|pom\.xml|build\.gradle(\.kts)?|mix\.exs|pubspec\.yaml)$/i;async function CS(e){let t=e.file(`.quirl/config.json`);if(!t)return{};let n=await e.readText(t);try{let e=JSON.parse(n??`{}`),t=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):void 0;return{docs:t(e.docs),alwaysLoad:t(e.alwaysLoad)}}catch{return e.warnings.push(`.quirl/config.json: not valid JSON, ignored`),{}}}function wS(e){if(e.files.some(e=>SS.test(kx(e.path))))return!1;let t=e.files.filter(e=>bS.test(e.path)).length;return t>0&&t*2>=e.files.length}async function TS(e,t={}){let n=_x((t.docs??[]).join(`
234
- `)),r=!t.docs&&wS(e),i=t.alwaysLoad?_x(t.alwaysLoad.join(`
235
- `)):null,a=e=>{let t=kx(e);if(!bS.test(t)||yS.test(t))return!1;let i=e.toLowerCase().split(`/`);return e.toLowerCase()===`.github/contributing.md`?!0:i.some(e=>e.startsWith(`.`))?!1:ES(e)||vx(n,e)?!0:r&&!i.slice(0,-1).some(e=>xS.has(e))},o=[];for(let t of e.files){if(!a(t.path))continue;let n=await e.readText(t);if(n===null)continue;let r=DS(n)??kx(t.path).replace(bS,``),s=kS(t.path,r),c;i?(c=vx(i,t.path),c&&n.length>2e4&&e.warnings.push(`${t.path}: listed in alwaysLoad but ${Math.round(n.length/1e3)}k characters; every agent session loads all of it`)):c=AS(t.path,s)&&n.length<=2e4,o.push({path:t.path,title:r,type:s,body:n,alwaysLoadCandidate:c,contentHash:T(`sha256`).update(n).digest(`hex`)})}return o}function ES(e){let t=kx(e);if(!bS.test(t)||yS.test(t))return!1;let n=e.toLowerCase().split(`/`);return n.length===1?vS.has(n[0]??``):e.toLowerCase()===`.github/contributing.md`||n.slice(0,-1).some(e=>_S.has(e))}function DS(e){let t=e.replace(/\r\n/g,`
236
- `),n=/^---\n([\s\S]*?)\n---\n/.exec(t),r=n?.[1]?/^title:\s*["']?(.+?)["']?\s*$/m.exec(n[1]):null;if(r?.[1])return r[1];let i=t.replace(/^(```|~~~)[\s\S]*?^\1.*$/gm,``),a=/^#\s+(.+?)\s*#*\s*$/m.exec(i),o=/^(?!\s*$)([^\n#>].*)\n=+\s*$/m.exec(i),s=a&&o?a.index<o.index?a[1]:o[1]:a?.[1]??o?.[1];return s?OS(s):null}function OS(e){return e.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[`*_]/g,``).trim()}function kS(e,t){let n=`${e} ${t}`.toLowerCase();return/(^|\/)adrs?\//.test(n)||/\bdecision|\badr[-_ ]?\d/.test(n)?`decision`:/guideline|convention|contributing|style ?guide|styleguide|code[-_ ]?style|coding[-_ ]standard/.test(n)?`guideline`:/guide|how[-_ ]?to|setup|set[-_ ]up|getting[-_ ]started|install|tutorial|runbook|playbook/.test(n)?`how_to`:/architecture|design|overview/.test(n)?`architecture`:`reference`}function AS(e,t){if(t===`guideline`)return!0;let n=kx(e).toLowerCase();return/architecture|conventions?|guidelines?|contributing|style-?guide/.test(n)||t===`architecture`&&/overview/.test(n)}const jS=/* @__PURE__ */ new Set([`claude.md`,`agents.md`,`.cursorrules`]);async function MS(e){let t=[];for(let n of e.files){if(!(jS.has(kx(n.path).toLowerCase())||n.path===`.github/copilot-instructions.md`))continue;let r=(await e.readText(n))?.replace(/<!-- quirl:start -->[\s\S]*?<!-- quirl:end -->\n?/,``).trim();r&&t.push({path:n.path,body:r})}return t}const NS=/\.(md|mdx|markdown|txt)$/i,PS=/\.(pdf|docx?|odt|rtf|pages|pptx?|key|xlsx?|numbers)$/i;async function FS(e){let t=[],n=[];for(let r of e.files){if(r.path.split(`/`).some(e=>e.startsWith(`.`)))continue;let i=kx(r.path);if(PS.test(i)){n.push(r.path);continue}if(!NS.test(i)||/^(claude|agents)\.md$/i.test(i))continue;let a=await e.readText(r);if(!a?.trim())continue;let o=i.replace(NS,``),s=(bS.test(i)?DS(a):null)??o,c=kS(r.path,s);t.push({path:r.path,title:s,type:c,body:a,alwaysLoadCandidate:!1,contentHash:T(`sha256`).update(a).digest(`hex`)})}return{docs:t,unsupported:n}}const IS=n(i);async function LS(e,t){try{let{stdout:n}=await IS(`git`,t,{cwd:e,timeout:1e4}),r=n.trim();return r===``?null:r}catch{return null}}async function RS(e){let t=await LS(e,[`symbolic-ref`,`--quiet`,`refs/remotes/origin/HEAD`]),n=[...t?[t.replace(/^refs\/remotes\//,``)]:[],`origin/main`,`origin/master`,`main`,`master`];for(let t of n)if(await LS(e,[`rev-parse`,`--verify`,`--quiet`,`${t}^{commit}`]))return{ref:t,branch:t.replace(/^origin\//,``)};return null}async function zS(e){try{return await IS(`git`,[`fetch`,`--quiet`,`--no-tags`,`origin`],{cwd:e,timeout:6e4}),await IS(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:e,timeout:3e4}).catch(()=>{}),!0}catch{return!1}}async function BS(e,t,n){let r=_.basename(e);if(await LS(e,[`rev-parse`,`--is-inside-work-tree`])!==`true`)return t.push(`Not a git repository (or git is not installed): repo details are empty`),{name:r,provider:null,url:null,defaultBranch:null,headSha:null,lastCommitAt:null,scannedRef:null};let i=n??`HEAD`,[a,o,s,c,l]=await Promise.all([LS(e,[`remote`,`get-url`,`origin`]),LS(e,[`rev-parse`,`--verify`,`--quiet`,`${i}^{commit}`]),LS(e,[`log`,`-1`,`--format=%cI`,i]),LS(e,[`symbolic-ref`,`--quiet`,`refs/remotes/origin/HEAD`]),LS(e,[`symbolic-ref`,`--quiet`,`--short`,`HEAD`])]);o===null&&t.push(`Git repository has no commits yet`),a===null&&t.push(`Git repository has no 'origin' remote`);let u=a?VS(a):null;return a&&!u&&t.push(`Could not read the 'origin' remote URL`),{name:u?.name??r,provider:u?.provider??null,url:u?.url??null,defaultBranch:n?.replace(/^origin\//,``)??c?.replace(/^refs\/remotes\/origin\//,``)??l,headSha:o,scannedRef:n,lastCommitAt:s?new Date(s).toISOString():null}}function VS(e){let t,n,r=/^(?:[^@/]+@)?([^:/]+):(?!\/)(.+)$/.exec(e);if(/^[a-z+]+:\/\//i.test(e)){let r;try{r=new URL(e)}catch{return null}if(r.protocol===`file:`)return null;t=r.hostname,n=r.pathname}else if(r?.[1]&&r[2])t=r[1],n=r[2];else return null;if(n=n.replace(/^\/+/,``).replace(/\/+$/,``).replace(/\.git$/,``),!t||!n)return null;let i=t.toLowerCase(),a=i.includes(`github`)?`github`:i.includes(`gitlab`)?`gitlab`:null;return{name:n.slice(n.lastIndexOf(`/`)+1),provider:a,url:`https://${i}/${n}`}}var HS=class{#e=/* @__PURE__ */ new Map;#t;#n;constructor(e,t){this.#t=e,this.#n=t}add(e,t,n){if(!e||!t)return;let r=this.#e.get(e);r&&(r.direct&&!n||r.direct===n&&US(r.version,t)>=0)||this.#e.set(e,{ecosystem:this.#t,package:e,version:t,direct:n,sourceLockfile:this.#n})}has(e){return this.#e.has(e)}rows(){return[...this.#e.values()].sort((e,t)=>e.package.localeCompare(t.package))}};function US(e,t){let n=e=>e.replace(/^v/,``).split(/[.+-]/),r=n(e),i=n(t);for(let e=0;e<Math.max(r.length,i.length);e++){let t=r[e]??``,n=i[e]??``,a=Number(t),o=Number(n),s=t!==``&&n!==``&&!Number.isNaN(a)&&!Number.isNaN(o)?a-o:t.localeCompare(n);if(s!==0)return s}return 0}function WS(e){let t=/* @__PURE__ */ new Set;if(!Z(e))return t;for(let n of[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`]){let r=e[n];if(Z(r))for(let e of Object.keys(r))t.add(e)}return t}function GS(e){return JSON.parse(e)}function KS(e,t,n){let r=GS(e);if(!Z(r))throw Error(`not a JSON object`);let i=/* @__PURE__ */ new Set;if(n!==null){let e=GS(n);if(Z(e))for(let t of[`require`,`require-dev`]){let n=e[t];if(Z(n))for(let e of Object.keys(n))i.add(e.toLowerCase())}}let a=new HS(`composer`,t);for(let e of[`packages`,`packages-dev`]){let t=r[e];if(Array.isArray(t))for(let e of t){if(!Z(e))continue;let{name:t,version:n}=e;typeof t==`string`&&typeof n==`string`&&a.add(t,n,i.has(t.toLowerCase()))}}return a.rows()}function qS(e,t,n){let r=new HS(`other`,n),i=/* @__PURE__ */ new Set;if(e!==null){let t=!1;for(let n of e.split(/\r?\n/)){let e=n.trim();if(t){if(e.startsWith(`)`)){t=!1;continue}a(e);continue}if(/^require\s*\($/.test(e)){t=!0;continue}let r=/^require\s+(.+)$/.exec(e);r?.[1]&&a(r[1])}}function a(e){let t=/^(\S+)\s+(\S+)(.*)$/.exec(e);if(!t?.[1]||!t[2]||t[1].startsWith(`//`))return;let n=/\/\/\s*indirect\b/.test(t[3]??``);r.add(t[1],t[2],!n),i.add(t[1])}if(t!==null)for(let e of t.split(/\r?\n/)){let[t,n]=e.trim().split(/\s+/);if(!t||!n)continue;let a=n.replace(/\/go\.mod$/,``);i.has(t)||r.add(t,a,!1)}return r.rows()}var $=/* @__PURE__ */ E((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),JS=/* @__PURE__ */ E((e=>{var t=$();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),YS=/* @__PURE__ */ E((e=>{var t=$(),n=JS();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||e&&!a.some(e=>e.startsWith(n))||r.push(`%TAG ${t} ${n}`);return r.join(`
237
- `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),XS=/* @__PURE__ */ E((e=>{var t=$(),n=JS();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=/* @__PURE__ */ new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=/* @__PURE__ */ new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=/* @__PURE__ */ Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),ZS=/* @__PURE__ */ E((e=>{function t(e,n,r,i){if(i&&typeof i==`object`){if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}}return e.call(n,r,i)}e.applyReviver=t})),QS=/* @__PURE__ */ E((e=>{var t=$();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),$S=/* @__PURE__ */ E((e=>{var t=ZS(),n=$(),r=QS();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:/* @__PURE__ */ new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),eC=/* @__PURE__ */ E((e=>{var t=XS(),n=JS(),r=$(),i=$S(),a=QS(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let o;for(let e of i){if(e===this)break;e.anchor===this.source&&(o=e)}if(o&&t){let{anchors:e,doc:n,maxAliasCount:r}=t,i=e.get(o);
233
+ `,o)+1);r=`${r.slice(0,o)}${i}${e>=0?r.slice(e+1):``}`}else r=r?`${r.trimEnd()}\n\n${i}`:`#!/bin/sh\n${i}`;return await l(t,{recursive:!0}),await m(n,r),await s(n,493),n}async function yS({quiet:e=!1}={}){let t=ix(),n=await cx();Jx(`🔑`,Hx(`Sign in to Quirl`)),n&&!e&&Yx(Q(`Already signed in as ${n.email}. Signing in again replaces this machine's key.`));let r=Gr(t.apiUrl,t.publishableKey),i=await r.start(`quirl CLI on ${g()}`),a=`${t.appUrl}/cli/authorize?code=${i.user_code}`;Yx(`Approve this computer in your browser:`),Yx(Gx(a)),Yx(`Check the code matches ${Hx(bS(i.user_code))}`),eS(a);let o=Xx(`Waiting for you to approve…`),s=Date.now()+6e5;for(;Date.now()<s;){await new Promise(e=>setTimeout(e,2e3));let e=await r.poll(i.request_id,i.poll_secret);if(e.status===`approved`&&e.key){let n=await new Wr({...t,key:e.key}).whoami();return o.stop(),await lx({apiUrl:t.apiUrl,key:e.key,email:n.email}),Yx(`${Ux(`✓`)} Signed in as ${Hx(n.email)}`),n}if(e.status!==`pending`)throw o.stop(),new Zx(`Sign-in ${e.status}. Run \`quirl login\` again.`)}throw o.stop(),new Zx("Sign-in timed out. Run `quirl login` again.")}const bS=e=>`${e.slice(0,4)}-${e.slice(4)}`,xS=/* @__PURE__ */ new Set([`docs`,`doc`,`adr`,`adrs`,`architecture`]),SS=/* @__PURE__ */ new Set([`readme.md`,`contributing.md`,`architecture.md`]),CS=/^(changelog|changes|history|license|licence|copying|notice|code_of_conduct|claude|agents)(\.|$)/i,wS=/\.(md|mdx|markdown)$/i,TS=/* @__PURE__ */ new Set([`tasks`,`todo`,`todos`,`issues`,`tickets`,`inbox`,`archive`,`archived`]),ES=/^(package\.json|pyproject\.toml|requirements\.txt|go\.mod|cargo\.toml|composer\.json|gemfile|pom\.xml|build\.gradle(\.kts)?|mix\.exs|pubspec\.yaml)$/i;async function DS(e){let t=e.file(`.quirl/config.json`);if(!t)return{};let n=await e.readText(t);try{let e=JSON.parse(n??`{}`),t=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):void 0;return{docs:t(e.docs),alwaysLoad:t(e.alwaysLoad)}}catch{return e.warnings.push(`.quirl/config.json: not valid JSON, ignored`),{}}}function OS(e){if(e.files.some(e=>ES.test(Ax(e.path))))return!1;let t=e.files.filter(e=>wS.test(e.path)).length;return t>0&&t*2>=e.files.length}async function kS(e,t={}){let n=vx((t.docs??[]).join(`
234
+ `)),r=!t.docs&&OS(e),i=t.alwaysLoad?vx(t.alwaysLoad.join(`
235
+ `)):null,a=e=>{let t=Ax(e);if(!wS.test(t)||CS.test(t))return!1;let i=e.toLowerCase().split(`/`);return e.toLowerCase()===`.github/contributing.md`?!0:i.some(e=>e.startsWith(`.`))?!1:AS(e)||yx(n,e)?!0:r&&!i.slice(0,-1).some(e=>TS.has(e))},o=[];for(let t of e.files){if(!a(t.path))continue;let n=await e.readText(t);if(n===null)continue;let r=jS(n)??Ax(t.path).replace(wS,``),s=NS(t.path,r),c;i?(c=yx(i,t.path),c&&n.length>2e4&&e.warnings.push(`${t.path}: listed in alwaysLoad but ${Math.round(n.length/1e3)}k characters; every agent session loads all of it`)):c=PS(t.path,s)&&n.length<=2e4,o.push({path:t.path,title:r,type:s,body:n,alwaysLoadCandidate:c,contentHash:T(`sha256`).update(n).digest(`hex`)})}return o}function AS(e){let t=Ax(e);if(!wS.test(t)||CS.test(t))return!1;let n=e.toLowerCase().split(`/`);return n.length===1?SS.has(n[0]??``):e.toLowerCase()===`.github/contributing.md`||n.slice(0,-1).some(e=>xS.has(e))}function jS(e){let t=e.replace(/\r\n/g,`
236
+ `),n=/^---\n([\s\S]*?)\n---\n/.exec(t),r=n?.[1]?/^title:\s*["']?(.+?)["']?\s*$/m.exec(n[1]):null;if(r?.[1])return r[1];let i=t.replace(/^(```|~~~)[\s\S]*?^\1.*$/gm,``),a=/^#\s+(.+?)\s*#*\s*$/m.exec(i),o=/^(?!\s*$)([^\n#>].*)\n=+\s*$/m.exec(i),s=a&&o?a.index<o.index?a[1]:o[1]:a?.[1]??o?.[1];return s?MS(s):null}function MS(e){return e.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[`*_]/g,``).trim()}function NS(e,t){let n=`${e} ${t}`.toLowerCase();return/(^|\/)adrs?\//.test(n)||/\bdecision|\badr[-_ ]?\d/.test(n)?`decision`:/guideline|convention|contributing|style ?guide|styleguide|code[-_ ]?style|coding[-_ ]standard/.test(n)?`guideline`:/guide|how[-_ ]?to|setup|set[-_ ]up|getting[-_ ]started|install|tutorial|runbook|playbook/.test(n)?`how_to`:/architecture|design|overview/.test(n)?`architecture`:`reference`}function PS(e,t){if(t===`guideline`)return!0;let n=Ax(e).toLowerCase();return/architecture|conventions?|guidelines?|contributing|style-?guide/.test(n)||t===`architecture`&&/overview/.test(n)}const FS=/* @__PURE__ */ new Set([`claude.md`,`agents.md`,`.cursorrules`]);async function IS(e){let t=[];for(let n of e.files){if(!(FS.has(Ax(n.path).toLowerCase())||n.path===`.github/copilot-instructions.md`))continue;let r=(await e.readText(n))?.replace(/<!-- quirl:start -->[\s\S]*?<!-- quirl:end -->\n?/,``).trim();r&&t.push({path:n.path,body:r})}return t}const LS=/\.(md|mdx|markdown|txt)$/i,RS=/\.(pdf|docx?|odt|rtf|pages|pptx?|key|xlsx?|numbers)$/i;async function zS(e){let t=[],n=[];for(let r of e.files){if(r.path.split(`/`).some(e=>e.startsWith(`.`)))continue;let i=Ax(r.path);if(RS.test(i)){n.push(r.path);continue}if(!LS.test(i)||/^(claude|agents)\.md$/i.test(i))continue;let a=await e.readText(r);if(!a?.trim())continue;let o=i.replace(LS,``),s=(wS.test(i)?jS(a):null)??o,c=NS(r.path,s);t.push({path:r.path,title:s,type:c,body:a,alwaysLoadCandidate:!1,contentHash:T(`sha256`).update(a).digest(`hex`)})}return{docs:t,unsupported:n}}const BS=n(i);async function VS(e,t){try{let{stdout:n}=await BS(`git`,t,{cwd:e,timeout:1e4}),r=n.trim();return r===``?null:r}catch{return null}}async function HS(e){let t=await VS(e,[`symbolic-ref`,`--quiet`,`refs/remotes/origin/HEAD`]),n=[...t?[t.replace(/^refs\/remotes\//,``)]:[],`origin/main`,`origin/master`,`main`,`master`];for(let t of n)if(await VS(e,[`rev-parse`,`--verify`,`--quiet`,`${t}^{commit}`]))return{ref:t,branch:t.replace(/^origin\//,``)};return null}async function US(e){try{return await BS(`git`,[`fetch`,`--quiet`,`--no-tags`,`origin`],{cwd:e,timeout:6e4}),await BS(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:e,timeout:3e4}).catch(()=>{}),!0}catch{return!1}}async function WS(e,t,n){let r=_.basename(e);if(await VS(e,[`rev-parse`,`--is-inside-work-tree`])!==`true`)return t.push(`Not a git repository (or git is not installed): repo details are empty`),{name:r,provider:null,url:null,defaultBranch:null,headSha:null,lastCommitAt:null,scannedRef:null};let i=n??`HEAD`,[a,o,s,c,l]=await Promise.all([VS(e,[`remote`,`get-url`,`origin`]),VS(e,[`rev-parse`,`--verify`,`--quiet`,`${i}^{commit}`]),VS(e,[`log`,`-1`,`--format=%cI`,i]),VS(e,[`symbolic-ref`,`--quiet`,`refs/remotes/origin/HEAD`]),VS(e,[`symbolic-ref`,`--quiet`,`--short`,`HEAD`])]);o===null&&t.push(`Git repository has no commits yet`),a===null&&t.push(`Git repository has no 'origin' remote`);let u=a?GS(a):null;return a&&!u&&t.push(`Could not read the 'origin' remote URL`),{name:u?.name??r,provider:u?.provider??null,url:u?.url??null,defaultBranch:n?.replace(/^origin\//,``)??c?.replace(/^refs\/remotes\/origin\//,``)??l,headSha:o,scannedRef:n,lastCommitAt:s?new Date(s).toISOString():null}}function GS(e){let t,n,r=/^(?:[^@/]+@)?([^:/]+):(?!\/)(.+)$/.exec(e);if(/^[a-z+]+:\/\//i.test(e)){let r;try{r=new URL(e)}catch{return null}if(r.protocol===`file:`)return null;t=r.hostname,n=r.pathname}else if(r?.[1]&&r[2])t=r[1],n=r[2];else return null;if(n=n.replace(/^\/+/,``).replace(/\/+$/,``).replace(/\.git$/,``),!t||!n)return null;let i=t.toLowerCase(),a=i.includes(`github`)?`github`:i.includes(`gitlab`)?`gitlab`:null;return{name:n.slice(n.lastIndexOf(`/`)+1),provider:a,url:`https://${i}/${n}`}}var KS=class{#e=/* @__PURE__ */ new Map;#t;#n;constructor(e,t){this.#t=e,this.#n=t}add(e,t,n){if(!e||!t)return;let r=this.#e.get(e);r&&(r.direct&&!n||r.direct===n&&qS(r.version,t)>=0)||this.#e.set(e,{ecosystem:this.#t,package:e,version:t,direct:n,sourceLockfile:this.#n})}has(e){return this.#e.has(e)}rows(){return[...this.#e.values()].sort((e,t)=>e.package.localeCompare(t.package))}};function qS(e,t){let n=e=>e.replace(/^v/,``).split(/[.+-]/),r=n(e),i=n(t);for(let e=0;e<Math.max(r.length,i.length);e++){let t=r[e]??``,n=i[e]??``,a=Number(t),o=Number(n),s=t!==``&&n!==``&&!Number.isNaN(a)&&!Number.isNaN(o)?a-o:t.localeCompare(n);if(s!==0)return s}return 0}function JS(e){let t=/* @__PURE__ */ new Set;if(!Z(e))return t;for(let n of[`dependencies`,`devDependencies`,`optionalDependencies`,`peerDependencies`]){let r=e[n];if(Z(r))for(let e of Object.keys(r))t.add(e)}return t}function YS(e){return JSON.parse(e)}function XS(e,t,n){let r=YS(e);if(!Z(r))throw Error(`not a JSON object`);let i=/* @__PURE__ */ new Set;if(n!==null){let e=YS(n);if(Z(e))for(let t of[`require`,`require-dev`]){let n=e[t];if(Z(n))for(let e of Object.keys(n))i.add(e.toLowerCase())}}let a=new KS(`composer`,t);for(let e of[`packages`,`packages-dev`]){let t=r[e];if(Array.isArray(t))for(let e of t){if(!Z(e))continue;let{name:t,version:n}=e;typeof t==`string`&&typeof n==`string`&&a.add(t,n,i.has(t.toLowerCase()))}}return a.rows()}function ZS(e,t,n){let r=new KS(`other`,n),i=/* @__PURE__ */ new Set;if(e!==null){let t=!1;for(let n of e.split(/\r?\n/)){let e=n.trim();if(t){if(e.startsWith(`)`)){t=!1;continue}a(e);continue}if(/^require\s*\($/.test(e)){t=!0;continue}let r=/^require\s+(.+)$/.exec(e);r?.[1]&&a(r[1])}}function a(e){let t=/^(\S+)\s+(\S+)(.*)$/.exec(e);if(!t?.[1]||!t[2]||t[1].startsWith(`//`))return;let n=/\/\/\s*indirect\b/.test(t[3]??``);r.add(t[1],t[2],!n),i.add(t[1])}if(t!==null)for(let e of t.split(/\r?\n/)){let[t,n]=e.trim().split(/\s+/);if(!t||!n)continue;let a=n.replace(/\/go\.mod$/,``);i.has(t)||r.add(t,a,!1)}return r.rows()}var $=/* @__PURE__ */ E((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),QS=/* @__PURE__ */ E((e=>{var t=$();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),$S=/* @__PURE__ */ E((e=>{var t=$(),n=QS();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||e&&!a.some(e=>e.startsWith(n))||r.push(`%TAG ${t} ${n}`);return r.join(`
237
+ `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),eC=/* @__PURE__ */ E((e=>{var t=$(),n=QS();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=/* @__PURE__ */ new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=/* @__PURE__ */ new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=/* @__PURE__ */ Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),tC=/* @__PURE__ */ E((e=>{function t(e,n,r,i){if(i&&typeof i==`object`){if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}}return e.call(n,r,i)}e.applyReviver=t})),nC=/* @__PURE__ */ E((e=>{var t=$();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),rC=/* @__PURE__ */ E((e=>{var t=tC(),n=$(),r=nC();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:/* @__PURE__ */ new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),iC=/* @__PURE__ */ E((e=>{var t=eC(),n=QS(),r=$(),i=rC(),a=nC(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let o;for(let e of i){if(e===this)break;e.anchor===this.source&&(o=e)}if(o&&t){let{anchors:e,doc:n,maxAliasCount:r}=t,i=e.get(o);
238
238
  /* istanbul ignore if */
239
- if(i||=(a.toJS(o,null,t),e.get(o)),i?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(r>=0&&(i.count+=1,i.aliasCount===0&&(i.aliasCount=s(n,o,e)),i.count*i.aliasCount>r))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return o}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),tC=/* @__PURE__ */ E((e=>{var t=$(),n=$S(),r=QS();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),nC=/* @__PURE__ */ E((e=>{var t=eC(),n=$(),r=tC();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??(f.anchor=c(e)),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),rC=/* @__PURE__ */ E((e=>{var t=nC(),n=$(),r=$S();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=/* @__PURE__ */ new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:/* @__PURE__ */ new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),iC=/* @__PURE__ */ E((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
239
+ if(i||=(a.toJS(o,null,t),e.get(o)),i?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(r>=0&&(i.count+=1,i.aliasCount===0&&(i.aliasCount=s(n,o,e)),i.count*i.aliasCount>r))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return o}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),aC=/* @__PURE__ */ E((e=>{var t=$(),n=rC(),r=nC();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),oC=/* @__PURE__ */ E((e=>{var t=iC(),n=$(),r=aC();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??(f.anchor=c(e)),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),sC=/* @__PURE__ */ E((e=>{var t=oC(),n=$(),r=rC();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=/* @__PURE__ */ new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:/* @__PURE__ */ new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),cC=/* @__PURE__ */ E((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
240
240
  `)?n(r,t):r.includes(`
241
241
  `)?`
242
- `+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),aC=/* @__PURE__ */ E((e=>{let t=`block`,n=`quoted`;function r(e,r,a=`flow`,{indentAtStart:o,lineWidth:s=80,minContentWidth:c=20,onFold:l,onOverflow:u}={}){if(!s||s<0)return e;s<c&&(c=0);let d=Math.max(1+c,1+s-r.length);if(e.length<=d)return e;let f=[],p={},m=s-r.length;typeof o==`number`&&(o>s-Math.max(2,c)?f.push(0):m=s-o);let h,g,_=!1,v=-1,y=-1,b=-1;a===t&&(v=i(e,v,r.length),v!==-1&&(m=v+d));for(let o;o=e[v+=1];){if(a===n&&o===`\\`){switch(y=v,e[v+1]){case`x`:v+=3;break;case`u`:v+=5;break;case`U`:v+=9;break;default:v+=1}b=v}if(o===`
242
+ `+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),lC=/* @__PURE__ */ E((e=>{let t=`block`,n=`quoted`;function r(e,r,a=`flow`,{indentAtStart:o,lineWidth:s=80,minContentWidth:c=20,onFold:l,onOverflow:u}={}){if(!s||s<0)return e;s<c&&(c=0);let d=Math.max(1+c,1+s-r.length);if(e.length<=d)return e;let f=[],p={},m=s-r.length;typeof o==`number`&&(o>s-Math.max(2,c)?f.push(0):m=s-o);let h,g,_=!1,v=-1,y=-1,b=-1;a===t&&(v=i(e,v,r.length),v!==-1&&(m=v+d));for(let o;o=e[v+=1];){if(a===n&&o===`\\`){switch(y=v,e[v+1]){case`x`:v+=3;break;case`u`:v+=5;break;case`U`:v+=9;break;default:v+=1}b=v}if(o===`
243
243
  `)a===t&&(v=i(e,v,r.length)),m=v+r.length+d,h=void 0;else{if(o===` `&&g&&g!==` `&&g!==`
244
244
  `&&g!==` `){let t=e[v+1];t&&t!==` `&&t!==`
245
245
  `&&t!==` `&&(h=v)}if(v>=m){if(h)f.push(h),m=h+d,h=void 0;else if(a===n){for(;g===` `||g===` `;)g=o,o=e[v+=1],_=!0;let t=v>b+1?v-2:y-1;if(p[t])return e;f.push(t),p[t]=!0,m=t+d,h=void 0}else _=!0}}g=o}if(_&&u&&u(),f.length===0)return e;l&&l();let x=e.slice(0,f[0]);for(let t=0;t<f.length;++t){let i=f[t],o=f[t+1]||e.length;i===0?x=`\n${r}${e.slice(0,o)}`:(a===n&&p[i]&&(x+=`${e[i]}\\`),x+=`\n${r}${e.slice(i+1,o)}`)}return x}function i(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
246
- `);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=r})),oC=/* @__PURE__ */ E((e=>{var t=tC(),n=aC();let r=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),i=e=>/^(%|---|\.\.\.)/m.test(e);function a(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
246
+ `);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=r})),uC=/* @__PURE__ */ E((e=>{var t=aC(),n=lC();let r=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),i=e=>/^(%|---|\.\.\.)/m.test(e);function a(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
247
247
  `){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function o(e,t){let a=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return a;let{implicitKey:o}=t,s=t.options.doubleQuotedMinMultiLineLength,c=t.indent||(i(e)?` `:``),l=``,u=0;for(let e=0,t=a[e];t;t=a[++e])if(t===` `&&a[e+1]===`\\`&&a[e+2]===`n`&&(l+=a.slice(u,e)+`\\ `,e+=1,u=e,t=`\\`),t===`\\`)switch(a[e+1]){case`u`:{l+=a.slice(u,e);let t=a.substr(e+2,4);switch(t){case`0000`:l+=`\\0`;break;case`0007`:l+=`\\a`;break;case`000b`:l+=`\\v`;break;case`001b`:l+=`\\e`;break;case`0085`:l+=`\\N`;break;case`00a0`:l+=`\\_`;break;case`2028`:l+=`\\L`;break;case`2029`:l+=`\\P`;break;default:t.substr(0,2)===`00`?l+=`\\x`+t.substr(2):l+=a.substr(e,6)}e+=5,u=e+1}break;case`n`:if(o||a[e+2]===`"`||a.length<s)e+=1;else{for(l+=a.slice(u,e)+`
248
248
 
249
249
  `;a[e+2]===`\\`&&a[e+3]===`n`&&a[e+4]!==`"`;)l+=`
@@ -261,29 +261,29 @@ if(i||=(a.toJS(o,null,t),e.get(o)),i?.res===void 0)throw ReferenceError(`This sh
261
261
  $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${g}`),i=!1,a=r(u,!0);p!==`folded`&&o!==t.Scalar.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let c=n.foldFlowLines(`${T}${e}${b}`,g,n.FOLD_BLOCK,a);if(!i)return`>${ee}\n${g}${c}`}return s=s.replace(/\n+/g,`$&${g}`),`|${ee}\n${g}${T}${s}${b}`}function d(e,a,o,s){let{type:l,value:d}=e,{actualString:f,implicitKey:p,indent:m,indentStep:h,inFlow:g}=a;if(p&&d.includes(`
262
262
  `)||g&&/[[\]{},]/.test(d))return c(d,a);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(d))return p||g||!d.includes(`
263
263
  `)?c(d,a):u(e,a,o,s);if(!p&&!g&&l!==t.Scalar.PLAIN&&d.includes(`
264
- `))return u(e,a,o,s);if(i(d)){if(m===``)return a.forceBlockIndent=!0,u(e,a,o,s);if(p&&m===h)return c(d,a)}let _=d.replace(/\n+/g,`$&\n${m}`);if(f){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(_),{compat:t,tags:n}=a.doc.schema;if(n.some(e)||t?.some(e))return c(d,a)}return p?_:n.foldFlowLines(_,m,n.FOLD_FLOW,r(a,!1))}function f(e,n,r,i){let{implicitKey:a,inFlow:l}=n,f=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(f.value)&&(p=t.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||l?c(f.value,n):u(f,n,r,i);case t.Scalar.QUOTE_DOUBLE:return o(f.value,n);case t.Scalar.QUOTE_SINGLE:return s(f.value,n);case t.Scalar.PLAIN:return d(f,n,r,i);default:return null}},h=m(p);if(h===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(h=m(r),h===null)throw Error(`Unsupported default string type ${r}`)}return h}e.stringifyString=f})),sC=/* @__PURE__ */ E((e=>{var t=XS(),n=$(),r=iC(),i=oC();function a(e,t){let n=Object.assign({blockQuote:!0,commentString:r.stringifyComment,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:/* @__PURE__ */ new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function o(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function s(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function c(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=/* @__PURE__ */ new Set([e]),e=e.resolve(t.doc)}let c,l=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>c=e});c??=o(t.doc.schema.tags,l);let u=s(l,c,t);u.length>0&&(t.indentAtStart=(t.indentAtStart??0)+u.length+1);let d=typeof c.stringify==`function`?c.stringify(l,t,r,a):n.isScalar(l)?i.stringifyString(l,t,r,a):l.toString(t,r,a);return u?n.isScalar(l)||d[0]===`{`||d[0]===`[`?`${u} ${d}`:`${u}\n${t.indent}${d}`:d}e.createStringifyContext=a,e.stringify=c})),cC=/* @__PURE__ */ E((e=>{var t=$(),n=tC(),r=sC(),i=iC();function a({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:f,options:{commentString:p,indentSeq:m,simpleKeys:h}}=o,g=t.isNode(e)&&e.comment||null;if(h){if(g)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let _=!h&&(!e||g&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!_&&(h||!l),indent:d+f});let v=!1,y=!1,b=r.stringify(e,o,()=>v=!0,()=>y=!0);if(!_&&!o.inFlow&&b.length>1024){if(h)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);_=!0}if(o.inFlow){if(l||a==null)return v&&s&&s(),b===``?`?`:_?`? ${b}`:b}else if(l&&!h||a==null&&_)return b=`? ${b}`,g&&!v?b+=i.lineComment(b,o.indent,p(g)):y&&c&&c(),b;v&&(g=null),_?(g&&(b+=i.lineComment(b,o.indent,p(g))),b=`? ${b}\n${d}:`):(b=`${b}:`,g&&(b+=i.lineComment(b,o.indent,p(g))));let x,S,C;t.isNode(a)?(x=!!a.spaceBefore,S=a.commentBefore,C=a.comment):(x=!1,S=null,C=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!_&&!g&&t.isScalar(a)&&(o.indentAtStart=b.length+1),y=!1,!m&&f.length>=2&&!o.inFlow&&!_&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let w=!1,T=r.stringify(a,o,()=>w=!0,()=>y=!0),ee=` `;if(g||x||S){if(ee=x?`
264
+ `))return u(e,a,o,s);if(i(d)){if(m===``)return a.forceBlockIndent=!0,u(e,a,o,s);if(p&&m===h)return c(d,a)}let _=d.replace(/\n+/g,`$&\n${m}`);if(f){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(_),{compat:t,tags:n}=a.doc.schema;if(n.some(e)||t?.some(e))return c(d,a)}return p?_:n.foldFlowLines(_,m,n.FOLD_FLOW,r(a,!1))}function f(e,n,r,i){let{implicitKey:a,inFlow:l}=n,f=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(f.value)&&(p=t.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||l?c(f.value,n):u(f,n,r,i);case t.Scalar.QUOTE_DOUBLE:return o(f.value,n);case t.Scalar.QUOTE_SINGLE:return s(f.value,n);case t.Scalar.PLAIN:return d(f,n,r,i);default:return null}},h=m(p);if(h===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(h=m(r),h===null)throw Error(`Unsupported default string type ${r}`)}return h}e.stringifyString=f})),dC=/* @__PURE__ */ E((e=>{var t=eC(),n=$(),r=cC(),i=uC();function a(e,t){let n=Object.assign({blockQuote:!0,commentString:r.stringifyComment,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:/* @__PURE__ */ new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function o(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function s(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function c(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=/* @__PURE__ */ new Set([e]),e=e.resolve(t.doc)}let c,l=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>c=e});c??=o(t.doc.schema.tags,l);let u=s(l,c,t);u.length>0&&(t.indentAtStart=(t.indentAtStart??0)+u.length+1);let d=typeof c.stringify==`function`?c.stringify(l,t,r,a):n.isScalar(l)?i.stringifyString(l,t,r,a):l.toString(t,r,a);return u?n.isScalar(l)||d[0]===`{`||d[0]===`[`?`${u} ${d}`:`${u}\n${t.indent}${d}`:d}e.createStringifyContext=a,e.stringify=c})),fC=/* @__PURE__ */ E((e=>{var t=$(),n=aC(),r=dC(),i=cC();function a({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:f,options:{commentString:p,indentSeq:m,simpleKeys:h}}=o,g=t.isNode(e)&&e.comment||null;if(h){if(g)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let _=!h&&(!e||g&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!_&&(h||!l),indent:d+f});let v=!1,y=!1,b=r.stringify(e,o,()=>v=!0,()=>y=!0);if(!_&&!o.inFlow&&b.length>1024){if(h)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);_=!0}if(o.inFlow){if(l||a==null)return v&&s&&s(),b===``?`?`:_?`? ${b}`:b}else if(l&&!h||a==null&&_)return b=`? ${b}`,g&&!v?b+=i.lineComment(b,o.indent,p(g)):y&&c&&c(),b;v&&(g=null),_?(g&&(b+=i.lineComment(b,o.indent,p(g))),b=`? ${b}\n${d}:`):(b=`${b}:`,g&&(b+=i.lineComment(b,o.indent,p(g))));let x,S,C;t.isNode(a)?(x=!!a.spaceBefore,S=a.commentBefore,C=a.comment):(x=!1,S=null,C=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!_&&!g&&t.isScalar(a)&&(o.indentAtStart=b.length+1),y=!1,!m&&f.length>=2&&!o.inFlow&&!_&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let w=!1,T=r.stringify(a,o,()=>w=!0,()=>y=!0),ee=` `;if(g||x||S){if(ee=x?`
265
265
  `:``,S){let e=p(S);ee+=`\n${i.indentComment(e,o.indent)}`}T===``&&!o.inFlow?ee===`
266
266
  `&&C&&(ee=`
267
267
 
268
268
  `):ee+=`\n${o.indent}`}else if(!_&&t.isCollection(a)){let e=T[0],t=T.indexOf(`
269
269
  `),n=t!==-1,r=o.inFlow??a.flow??a.items.length===0;if(n||!r){let r=!1;if(n&&(e===`&`||e===`!`)){let n=T.indexOf(` `);e===`&`&&n!==-1&&n<t&&T[n+1]===`!`&&(n=T.indexOf(` `,n+1)),(n===-1||t<n)&&(r=!0)}r||(ee=`\n${o.indent}`)}}else(T===``||T[0]===`
270
- `)&&(ee=``);return b+=ee+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),lC=/* @__PURE__ */ E((e=>{var t=fe(`process`);function n(e,...t){e===`debug`&&console.log(...t)}function r(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=n,e.warn=r})),uC=/* @__PURE__ */ E((e=>{var t=$(),n=tC();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:a}),stringify:()=>`<<`},i=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function a(e,n,r){let i=s(e,r);if(t.isSeq(i))for(let t of i.items)o(e,n,t);else if(Array.isArray(i))for(let t of i)o(e,n,t);else o(e,n,i)}function o(e,n,r){let i=s(e,r);if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}function s(e,n){return e&&t.isAlias(n)?n.resolve(e.doc,e):n}e.addMergeToJSMap=a,e.isMergeKey=i,e.merge=r})),dC=/* @__PURE__ */ E((e=>{var t=lC(),n=uC(),r=sC(),i=$(),a=QS();function o(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=s(r,n,e),c=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:c,writable:!0,enumerable:!0,configurable:!0}):t[i]=c}}return t}function s(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=/* @__PURE__ */ new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=o})),fC=/* @__PURE__ */ E((e=>{var t=nC(),n=cC(),r=dC(),i=$();function a(e,n,r){return new o(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var o=class e{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return i.isNode(n)&&(n=n.clone(t)),i.isNode(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){let n=t?.mapAsMap?/* @__PURE__ */ new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=o,e.createPair=a})),pC=/* @__PURE__ */ E((e=>{var t=$(),n=sC(),r=iC();function i(e,t,n){return(t.inFlow??e.flow?o:a)(e,t,n)}function a({comment:e,items:i},a,{blockItemPrefix:o,flowChars:c,itemIndent:l,onChompKeep:u,onComment:d}){let{indent:f,options:{commentString:p}}=a,m=Object.assign({},a,{indent:l,type:null}),h=!1,g=[];for(let e=0;e<i.length;++e){let c=i[e],u=null;if(t.isNode(c))!h&&c.spaceBefore&&g.push(``),s(a,g,c.commentBefore,h),c.comment&&(u=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(!h&&e.spaceBefore&&g.push(``),s(a,g,e.commentBefore,h))}h=!1;let d=n.stringify(c,m,()=>u=null,()=>h=!0);u&&(d+=r.lineComment(d,l,p(u))),h&&u&&(h=!1),g.push(o+d)}let _;if(g.length===0)_=c.start+c.end;else{_=g[0];for(let e=1;e<g.length;++e){let t=g[e];_+=t?`\n${f}${t}`:`
270
+ `)&&(ee=``);return b+=ee+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),pC=/* @__PURE__ */ E((e=>{var t=fe(`process`);function n(e,...t){e===`debug`&&console.log(...t)}function r(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=n,e.warn=r})),mC=/* @__PURE__ */ E((e=>{var t=$(),n=aC();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:a}),stringify:()=>`<<`},i=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function a(e,n,r){let i=s(e,r);if(t.isSeq(i))for(let t of i.items)o(e,n,t);else if(Array.isArray(i))for(let t of i)o(e,n,t);else o(e,n,i)}function o(e,n,r){let i=s(e,r);if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}function s(e,n){return e&&t.isAlias(n)?n.resolve(e.doc,e):n}e.addMergeToJSMap=a,e.isMergeKey=i,e.merge=r})),hC=/* @__PURE__ */ E((e=>{var t=pC(),n=mC(),r=dC(),i=$(),a=nC();function o(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=s(r,n,e),c=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:c,writable:!0,enumerable:!0,configurable:!0}):t[i]=c}}return t}function s(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=/* @__PURE__ */ new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=o})),gC=/* @__PURE__ */ E((e=>{var t=oC(),n=fC(),r=hC(),i=$();function a(e,n,r){return new o(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var o=class e{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return i.isNode(n)&&(n=n.clone(t)),i.isNode(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){let n=t?.mapAsMap?/* @__PURE__ */ new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=o,e.createPair=a})),_C=/* @__PURE__ */ E((e=>{var t=$(),n=dC(),r=cC();function i(e,t,n){return(t.inFlow??e.flow?o:a)(e,t,n)}function a({comment:e,items:i},a,{blockItemPrefix:o,flowChars:c,itemIndent:l,onChompKeep:u,onComment:d}){let{indent:f,options:{commentString:p}}=a,m=Object.assign({},a,{indent:l,type:null}),h=!1,g=[];for(let e=0;e<i.length;++e){let c=i[e],u=null;if(t.isNode(c))!h&&c.spaceBefore&&g.push(``),s(a,g,c.commentBefore,h),c.comment&&(u=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(!h&&e.spaceBefore&&g.push(``),s(a,g,e.commentBefore,h))}h=!1;let d=n.stringify(c,m,()=>u=null,()=>h=!0);u&&(d+=r.lineComment(d,l,p(u))),h&&u&&(h=!1),g.push(o+d)}let _;if(g.length===0)_=c.start+c.end;else{_=g[0];for(let e=1;e<g.length;++e){let t=g[e];_+=t?`\n${f}${t}`:`
271
271
  `}}return e?(_+=`
272
272
  `+r.indentComment(p(e),f),d&&d()):h&&u&&u(),_}function o({items:e},i,{flowChars:a,itemIndent:o}){let{indent:c,indentStep:l,flowCollectionPadding:u,options:{commentString:d}}=i;o+=l;let f=Object.assign({},i,{indent:o,inFlow:!0,type:null}),p=!1,m=0,h=[];for(let a=0;a<e.length;++a){let c=e[a],l=null;if(t.isNode(c))c.spaceBefore&&h.push(``),s(i,h,c.commentBefore,!1),c.comment&&(l=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(e.spaceBefore&&h.push(``),s(i,h,e.commentBefore,!1),e.comment&&(p=!0));let n=t.isNode(c.value)?c.value:null;n?(n.comment&&(l=n.comment),n.commentBefore&&(p=!0)):c.value==null&&e?.comment&&(l=e.comment)}l&&(p=!0);let u=n.stringify(c,f,()=>l=null);p||=h.length>m||u.includes(`
273
273
  `),a<e.length-1?u+=`,`:i.options.trailingComma&&(i.options.lineWidth>0&&(p||=h.reduce((e,t)=>e+t.length+2,2)+(u.length+2)>i.options.lineWidth),p&&(u+=`,`)),l&&(u+=r.lineComment(u,o,d(l))),h.push(u),m=h.length}let{start:g,end:_}=a;if(h.length===0)return g+_;if(!p){let e=h.reduce((e,t)=>e+t.length+2,2);p=i.options.lineWidth>0&&e>i.options.lineWidth}if(p){let e=g;for(let t of h)e+=t?`\n${l}${c}${t}`:`
274
- `;return`${e}\n${c}${_}`}return`${g}${u}${h.join(` `)}${u}${_}`}function s({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=i})),mC=/* @__PURE__ */ E((e=>{var t=pC(),n=dC(),r=rC(),i=$(),a=fC(),o=tC();function s(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}e.YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),s=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)s(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))s(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=s(this.items,n.key),c=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(c){let e=this.items.findIndex(e=>c(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=s(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=s(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!s(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?/* @__PURE__ */ new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}},e.findPair=s})),hC=/* @__PURE__ */ E((e=>{var t=$(),n=mC();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),gC=/* @__PURE__ */ E((e=>{var t=nC(),n=pC(),r=rC(),i=$(),a=tC(),o=QS(),s=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=c(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=c(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=c(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=c(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function c(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=s})),_C=/* @__PURE__ */ E((e=>{var t=$(),n=gC();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),vC=/* @__PURE__ */ E((e=>{var t=oC();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),yC=/* @__PURE__ */ E((e=>{var t=tC();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),bC=/* @__PURE__ */ E((e=>{var t=tC();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),xC=/* @__PURE__ */ E((e=>{function t({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}e.stringifyNumber=t})),SC=/* @__PURE__ */ E((e=>{var t=tC(),n=xC();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),CC=/* @__PURE__ */ E((e=>{var t=xC();let n=e=>typeof e==`bigint`||Number.isInteger(e),r=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function i(e,r,i){let{value:a}=e;return n(a)&&a>=0?i+a.toString(r):t.stringifyNumber(e)}e.int={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)},e.intOct={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>r(e,2,8,n),stringify:e=>i(e,8,`0o`)}})),wC=/* @__PURE__ */ E((e=>{var t=hC(),n=yC(),r=_C(),i=vC(),a=bC(),o=SC(),s=CC();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),TC=/* @__PURE__ */ E((e=>{var t=tC(),n=hC(),r=_C();function i(e){return typeof e==`bigint`||Number.isInteger(e)}let a=({value:e})=>JSON.stringify(e),o=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:a},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:a},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:a},{identify:i,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>i(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:a}];e.schema=[n.map,r.seq].concat(o,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),EC=/* @__PURE__ */ E((e=>{var t=fe(`buffer`),n=tC(),r=oC();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
275
- `:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),DC=/* @__PURE__ */ E((e=>{var t=$(),n=fC(),r=tC(),i=gC();function a(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function o(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e)){if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let s={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:a,createNode:o};e.createPairs=o,e.pairs=s,e.resolvePairs=a})),OC=/* @__PURE__ */ E((e=>{var t=$(),n=QS(),r=mC(),i=gC(),a=DC(),o=class e extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=/* @__PURE__ */ new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),kC=/* @__PURE__ */ E((e=>{var t=tC();function n({value:e,source:t},n){return t&&(e?r:i).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}let r={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:n},i={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:n};e.falseTag=i,e.trueTag=r})),AC=/* @__PURE__ */ E((e=>{var t=tC(),n=xC();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),jC=/* @__PURE__ */ E((e=>{var t=xC();let n=e=>typeof e==`bigint`||Number.isInteger(e);function r(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function i(e,r,i){let{value:a}=e;if(n(a)){let e=a.toString(r);return a<0?`-`+i+e.substr(1):i+e}return t.stringifyNumber(e)}let a={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>r(e,2,2,n),stringify:e=>i(e,2,`0b`)},o={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>r(e,1,8,n),stringify:e=>i(e,8,`0`)},s={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},c={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)};e.int=s,e.intBin=a,e.intHex=c,e.intOct=o})),MC=/* @__PURE__ */ E((e=>{var t=$(),n=fC(),r=mC(),i=class e extends r.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),NC=/* @__PURE__ */ E((e=>{var t=xC();function n(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function r(e){let{value:n}=e,r=e=>e;if(typeof n==`bigint`)r=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let i=``;n<0&&(i=`-`,n*=r(-1));let a=r(60),o=[n%a];return n<60?o.unshift(0):(n=(n-o[0])/a,o.unshift(n%a),n>=60&&(n=(n-o[0])/a,o.unshift(n))),i+o.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let i={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>n(e,r),stringify:r},a={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>n(e,!1),stringify:r},o={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(o.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,r,i,a,s,c,l]=t.map(Number),u=t[7]?Number((t[7]+`00`).substr(1,3)):0,d=Date.UTC(r,i-1,a,s||0,c||0,l||0,u),f=t[8];if(f&&f!==`Z`){let e=n(f,!1);Math.abs(e)<30&&(e*=60),d-=6e4*e}return new Date(d)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=a,e.intTime=i,e.timestamp=o})),PC=/* @__PURE__ */ E((e=>{var t=hC(),n=yC(),r=_C(),i=vC(),a=EC(),o=kC(),s=AC(),c=jC(),l=uC(),u=OC(),d=DC(),f=MC(),p=NC();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),FC=/* @__PURE__ */ E((e=>{var t=hC(),n=yC(),r=_C(),i=vC(),a=bC(),o=SC(),s=CC(),c=wC(),l=TC(),u=EC(),d=uC(),f=OC(),p=DC(),m=PC(),h=MC(),g=NC();let _=/* @__PURE__ */ new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function b(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=b})),IC=/* @__PURE__ */ E((e=>{var t=$(),n=hC(),r=_C(),i=vC(),a=FC();let o=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class e{constructor({compat:e,customTags:s,merge:c,resolveKnownTags:l,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof u==`string`&&u||`core`,this.knownTags=l?a.coreKnownTags:{},this.tags=a.getTags(s,this.name,c),this.toStringOptions=f??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof d==`function`?d:d===!0?o:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}})),LC=/* @__PURE__ */ E((e=>{var t=$(),n=sC(),r=iC();function i(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd){if(e.comment){let t=c(e.comment);t.includes(`
274
+ `;return`${e}\n${c}${_}`}return`${g}${u}${h.join(` `)}${u}${_}`}function s({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=i})),vC=/* @__PURE__ */ E((e=>{var t=_C(),n=hC(),r=sC(),i=$(),a=gC(),o=aC();function s(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}e.YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),s=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)s(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))s(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=s(this.items,n.key),c=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(c){let e=this.items.findIndex(e=>c(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=s(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=s(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!s(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?/* @__PURE__ */ new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}},e.findPair=s})),yC=/* @__PURE__ */ E((e=>{var t=$(),n=vC();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),bC=/* @__PURE__ */ E((e=>{var t=oC(),n=_C(),r=sC(),i=$(),a=aC(),o=nC(),s=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=c(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=c(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=c(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=c(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function c(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=s})),xC=/* @__PURE__ */ E((e=>{var t=$(),n=bC();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),SC=/* @__PURE__ */ E((e=>{var t=uC();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),CC=/* @__PURE__ */ E((e=>{var t=aC();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),wC=/* @__PURE__ */ E((e=>{var t=aC();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),TC=/* @__PURE__ */ E((e=>{function t({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}e.stringifyNumber=t})),EC=/* @__PURE__ */ E((e=>{var t=aC(),n=TC();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),DC=/* @__PURE__ */ E((e=>{var t=TC();let n=e=>typeof e==`bigint`||Number.isInteger(e),r=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function i(e,r,i){let{value:a}=e;return n(a)&&a>=0?i+a.toString(r):t.stringifyNumber(e)}e.int={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)},e.intOct={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>r(e,2,8,n),stringify:e=>i(e,8,`0o`)}})),OC=/* @__PURE__ */ E((e=>{var t=yC(),n=CC(),r=xC(),i=SC(),a=wC(),o=EC(),s=DC();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),kC=/* @__PURE__ */ E((e=>{var t=aC(),n=yC(),r=xC();function i(e){return typeof e==`bigint`||Number.isInteger(e)}let a=({value:e})=>JSON.stringify(e),o=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:a},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:a},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:a},{identify:i,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>i(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:a}];e.schema=[n.map,r.seq].concat(o,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),AC=/* @__PURE__ */ E((e=>{var t=fe(`buffer`),n=aC(),r=uC();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
275
+ `:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),jC=/* @__PURE__ */ E((e=>{var t=$(),n=gC(),r=aC(),i=bC();function a(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function o(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e)){if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let s={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:a,createNode:o};e.createPairs=o,e.pairs=s,e.resolvePairs=a})),MC=/* @__PURE__ */ E((e=>{var t=$(),n=nC(),r=vC(),i=bC(),a=jC(),o=class e extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=/* @__PURE__ */ new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),NC=/* @__PURE__ */ E((e=>{var t=aC();function n({value:e,source:t},n){return t&&(e?r:i).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}let r={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:n},i={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:n};e.falseTag=i,e.trueTag=r})),PC=/* @__PURE__ */ E((e=>{var t=aC(),n=TC();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),FC=/* @__PURE__ */ E((e=>{var t=TC();let n=e=>typeof e==`bigint`||Number.isInteger(e);function r(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function i(e,r,i){let{value:a}=e;if(n(a)){let e=a.toString(r);return a<0?`-`+i+e.substr(1):i+e}return t.stringifyNumber(e)}let a={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>r(e,2,2,n),stringify:e=>i(e,2,`0b`)},o={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>r(e,1,8,n),stringify:e=>i(e,8,`0`)},s={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},c={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)};e.int=s,e.intBin=a,e.intHex=c,e.intOct=o})),IC=/* @__PURE__ */ E((e=>{var t=$(),n=gC(),r=vC(),i=class e extends r.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),LC=/* @__PURE__ */ E((e=>{var t=TC();function n(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function r(e){let{value:n}=e,r=e=>e;if(typeof n==`bigint`)r=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let i=``;n<0&&(i=`-`,n*=r(-1));let a=r(60),o=[n%a];return n<60?o.unshift(0):(n=(n-o[0])/a,o.unshift(n%a),n>=60&&(n=(n-o[0])/a,o.unshift(n))),i+o.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let i={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>n(e,r),stringify:r},a={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>n(e,!1),stringify:r},o={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(o.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,r,i,a,s,c,l]=t.map(Number),u=t[7]?Number((t[7]+`00`).substr(1,3)):0,d=Date.UTC(r,i-1,a,s||0,c||0,l||0,u),f=t[8];if(f&&f!==`Z`){let e=n(f,!1);Math.abs(e)<30&&(e*=60),d-=6e4*e}return new Date(d)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=a,e.intTime=i,e.timestamp=o})),RC=/* @__PURE__ */ E((e=>{var t=yC(),n=CC(),r=xC(),i=SC(),a=AC(),o=NC(),s=PC(),c=FC(),l=mC(),u=MC(),d=jC(),f=IC(),p=LC();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),zC=/* @__PURE__ */ E((e=>{var t=yC(),n=CC(),r=xC(),i=SC(),a=wC(),o=EC(),s=DC(),c=OC(),l=kC(),u=AC(),d=mC(),f=MC(),p=jC(),m=RC(),h=IC(),g=LC();let _=/* @__PURE__ */ new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function b(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=b})),BC=/* @__PURE__ */ E((e=>{var t=$(),n=yC(),r=xC(),i=SC(),a=zC();let o=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class e{constructor({compat:e,customTags:s,merge:c,resolveKnownTags:l,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof u==`string`&&u||`core`,this.knownTags=l?a.coreKnownTags:{},this.tags=a.getTags(s,this.name,c),this.toStringOptions=f??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof d==`function`?d:d===!0?o:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}})),VC=/* @__PURE__ */ E((e=>{var t=$(),n=dC(),r=cC();function i(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd){if(e.comment){let t=c(e.comment);t.includes(`
276
276
  `)?(a.push(`...`),a.push(r.indentComment(t,``))):a.push(`... ${t}`)}else a.push(`...`)}else{let t=e.comment;t&&l&&(t=t.replace(/^\n+/,``)),t&&((!l||u)&&a[a.length-1]!==``&&a.push(``),a.push(r.indentComment(c(t),``)))}return a.join(`
277
277
  `)+`
278
- `}e.stringifyDocument=i})),RC=/* @__PURE__ */ E((e=>{var t=eC(),n=rC(),r=$(),i=fC(),a=QS(),o=IC(),s=LC(),c=XS(),l=ZS(),u=nC(),d=YS(),f=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let t=Object.create(e.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=r.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:f}=n??{},{onAnchor:p,setAnchors:m,sourceObjects:h}=c.createNodeAnchors(this,o||`a`),g={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:p,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:h},_=u.createNode(e,f,g);return s&&r.isCollection(_)&&(_.flow=!0),m(),_}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return p(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents!=null&&(this.contents=null,!0):p(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:/* @__PURE__ */ new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function p(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=f})),zC=/* @__PURE__ */ E((e=>{var t=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},n=class extends t{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},r=class extends t{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};e.YAMLError=t,e.YAMLParseError=n,e.YAMLWarning=r,e.prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
279
- `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}}})),BC=/* @__PURE__ */ E((e=>{function t(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:b&&n===`seq-item-ind`||(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}e.resolveProps=t})),VC=/* @__PURE__ */ E((e=>{function t(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
280
- `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let n of e.items){for(let e of n.start)if(e.type===`newline`)return!0;if(n.sep){for(let e of n.sep)if(e.type===`newline`)return!0}if(t(n.key)||t(n.value))return!0}return!1;default:return!0}}e.containsNewline=t})),HC=/* @__PURE__ */ E((e=>{var t=VC();function n(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=n})),UC=/* @__PURE__ */ E((e=>{var t=$();function n(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=n})),WC=/* @__PURE__ */ E((e=>{var t=fC(),n=mC(),r=BC(),i=VC(),a=HC(),o=UC();let s=`All mapping items must start at the same column`;function c({composeNode:e,composeEmptyNode:c},l,u,d,f){let p=new((f?.nodeClass)??n.YAMLMap)(l.schema);l.atRoot&&=!1;let m=u.offset,h=null;for(let n of u.items){let{start:f,key:g,sep:_,value:v}=n,y=r.resolveProps(f,{indicator:`explicit-key-ind`,next:g??_?.[0],offset:m,onError:d,parentIndent:u.indent,startOnNewline:!0}),b=!y.found;if(b){if(g&&(g.type===`block-seq`?d(m,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in g&&g.indent!==u.indent&&d(m,`BAD_INDENT`,s)),!y.anchor&&!y.tag&&!_){h=y.end,y.comment&&(p.comment?p.comment+=`
278
+ `}e.stringifyDocument=i})),HC=/* @__PURE__ */ E((e=>{var t=iC(),n=sC(),r=$(),i=gC(),a=nC(),o=BC(),s=VC(),c=eC(),l=tC(),u=oC(),d=$S(),f=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let t=Object.create(e.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=r.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:f}=n??{},{onAnchor:p,setAnchors:m,sourceObjects:h}=c.createNodeAnchors(this,o||`a`),g={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:p,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:h},_=u.createNode(e,f,g);return s&&r.isCollection(_)&&(_.flow=!0),m(),_}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return p(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents!=null&&(this.contents=null,!0):p(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:/* @__PURE__ */ new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function p(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=f})),UC=/* @__PURE__ */ E((e=>{var t=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},n=class extends t{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},r=class extends t{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};e.YAMLError=t,e.YAMLParseError=n,e.YAMLWarning=r,e.prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
279
+ `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}}})),WC=/* @__PURE__ */ E((e=>{function t(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:b&&n===`seq-item-ind`||(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}e.resolveProps=t})),GC=/* @__PURE__ */ E((e=>{function t(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
280
+ `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let n of e.items){for(let e of n.start)if(e.type===`newline`)return!0;if(n.sep){for(let e of n.sep)if(e.type===`newline`)return!0}if(t(n.key)||t(n.value))return!0}return!1;default:return!0}}e.containsNewline=t})),KC=/* @__PURE__ */ E((e=>{var t=GC();function n(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=n})),qC=/* @__PURE__ */ E((e=>{var t=$();function n(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=n})),JC=/* @__PURE__ */ E((e=>{var t=gC(),n=vC(),r=WC(),i=GC(),a=KC(),o=qC();let s=`All mapping items must start at the same column`;function c({composeNode:e,composeEmptyNode:c},l,u,d,f){let p=new((f?.nodeClass)??n.YAMLMap)(l.schema);l.atRoot&&=!1;let m=u.offset,h=null;for(let n of u.items){let{start:f,key:g,sep:_,value:v}=n,y=r.resolveProps(f,{indicator:`explicit-key-ind`,next:g??_?.[0],offset:m,onError:d,parentIndent:u.indent,startOnNewline:!0}),b=!y.found;if(b){if(g&&(g.type===`block-seq`?d(m,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in g&&g.indent!==u.indent&&d(m,`BAD_INDENT`,s)),!y.anchor&&!y.tag&&!_){h=y.end,y.comment&&(p.comment?p.comment+=`
281
281
  `+y.comment:p.comment=y.comment);continue}(y.newlineAfterProp||i.containsNewline(g))&&d(g??f[f.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else y.found?.indent!==u.indent&&d(m,`BAD_INDENT`,s);l.atKey=!0;let x=y.end,S=g?e(l,g,y,d):c(l,x,f,null,y,d);l.schema.compat&&a.flowIndentCheck(u.indent,g,d),l.atKey=!1,o.mapIncludes(l,p.items,S)&&d(x,`DUPLICATE_KEY`,`Map keys must be unique`);let C=r.resolveProps(_??[],{indicator:`map-value-ind`,next:v,offset:S.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||g.type===`block-scalar`});if(m=C.end,C.found){b&&(v?.type===`block-map`&&!C.hasNewline&&d(m,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),l.options.strict&&y.start<C.found.offset-1024&&d(S.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let r=v?e(l,v,C,d):c(l,m,_,null,C,d);l.schema.compat&&a.flowIndentCheck(u.indent,v,d),m=r.range[2];let i=new t.Pair(S,r);l.options.keepSourceTokens&&(i.srcToken=n),p.items.push(i)}else{b&&d(S.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),C.comment&&(S.comment?S.comment+=`
282
- `+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=c})),GC=/* @__PURE__ */ E((e=>{var t=gC(),n=BC(),r=HC();function i({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new((c?.nodeClass)??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let f=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!f.found){if(f.anchor||f.tag||c)c?.type===`block-seq`?s(f.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=f.end,f.comment&&(l.comment=f.comment);continue}}let p=c?e(a,c,f,s):i(a,f.end,t,null,f,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=p.range[2],l.items.push(p)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=i})),KC=/* @__PURE__ */ E((e=>{function t(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=t})),qC=/* @__PURE__ */ E((e=>{var t=$(),n=fC(),r=mC(),i=gC(),a=KC(),o=BC(),s=VC(),c=UC();let l=`Block collections are not allowed within flow collections`,u=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function d({composeNode:e,composeEmptyNode:d},f,p,m,h){let g=p.start.source===`{`,_=g?`flow map`:`flow sequence`,v=new((h?.nodeClass)??(g?r.YAMLMap:i.YAMLSeq))(f.schema);v.flow=!0;let y=f.atRoot;y&&(f.atRoot=!1),f.atKey&&=!1;let b=p.offset+p.start.source.length;for(let i=0;i<p.items.length;++i){let a=p.items[i],{start:h,key:y,sep:x,value:S}=a,C=o.resolveProps(h,{flow:_,indicator:`explicit-key-ind`,next:y??x?.[0],offset:b,onError:m,parentIndent:p.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!x&&!S){i===0&&C.comma?m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`):i<p.items.length-1&&m(C.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${_}`),C.comment&&(v.comment?v.comment+=`
282
+ `+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=c})),YC=/* @__PURE__ */ E((e=>{var t=bC(),n=WC(),r=KC();function i({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new((c?.nodeClass)??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let f=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!f.found){if(f.anchor||f.tag||c)c?.type===`block-seq`?s(f.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=f.end,f.comment&&(l.comment=f.comment);continue}}let p=c?e(a,c,f,s):i(a,f.end,t,null,f,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=p.range[2],l.items.push(p)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=i})),XC=/* @__PURE__ */ E((e=>{function t(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=t})),ZC=/* @__PURE__ */ E((e=>{var t=$(),n=gC(),r=vC(),i=bC(),a=XC(),o=WC(),s=GC(),c=qC();let l=`Block collections are not allowed within flow collections`,u=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function d({composeNode:e,composeEmptyNode:d},f,p,m,h){let g=p.start.source===`{`,_=g?`flow map`:`flow sequence`,v=new((h?.nodeClass)??(g?r.YAMLMap:i.YAMLSeq))(f.schema);v.flow=!0;let y=f.atRoot;y&&(f.atRoot=!1),f.atKey&&=!1;let b=p.offset+p.start.source.length;for(let i=0;i<p.items.length;++i){let a=p.items[i],{start:h,key:y,sep:x,value:S}=a,C=o.resolveProps(h,{flow:_,indicator:`explicit-key-ind`,next:y??x?.[0],offset:b,onError:m,parentIndent:p.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!x&&!S){i===0&&C.comma?m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`):i<p.items.length-1&&m(C.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${_}`),C.comment&&(v.comment?v.comment+=`
283
283
  `+C.comment:v.comment=C.comment),b=C.end;continue}!g&&f.options.strict&&s.containsNewline(y)&&m(y,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(i===0)C.comma&&m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`);else if(C.comma||m(C.start,`MISSING_CHAR`,`Missing , between ${_} items`),C.comment){let e=``;loop:for(let t of h)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let n=v.items[v.items.length-1];t.isPair(n)&&(n=n.value??n.key),n.comment?n.comment+=`
284
284
  `+e:n.comment=e,C.comment=C.comment.substring(e.length+1)}}if(!g&&!x&&!C.found){let t=S?e(f,S,C,m):d(f,C.end,x,null,C,m);v.items.push(t),b=t.range[2],u(S)&&m(t.range,`BLOCK_IN_FLOW`,l)}else{f.atKey=!0;let t=C.end,i=y?e(f,y,C,m):d(f,t,h,null,C,m);u(y)&&m(i.range,`BLOCK_IN_FLOW`,l),f.atKey=!1;let s=o.resolveProps(x??[],{flow:_,indicator:`map-value-ind`,next:S,offset:i.range[2],onError:m,parentIndent:p.indent,startOnNewline:!1});if(s.found){if(!g&&!C.found&&f.options.strict){if(x)for(let e of x){if(e===s.found)break;if(e.type===`newline`){m(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}C.start<s.found.offset-1024&&m(s.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else S&&(`source`in S&&S.source?.[0]===`:`?m(S,`MISSING_CHAR`,`Missing space after : in ${_}`):m(s.start,`MISSING_CHAR`,`Missing , or : between ${_} items`));let w=S?e(f,S,s,m):s.found?d(f,s.end,x,null,s,m):null;w?u(S)&&m(w.range,`BLOCK_IN_FLOW`,l):s.comment&&(i.comment?i.comment+=`
285
285
  `+s.comment:i.comment=s.comment);let T=new n.Pair(i,w);if(f.options.keepSourceTokens&&(T.srcToken=a),g){let e=v;c.mapIncludes(f,e.items,i)&&m(t,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(T)}else{let e=new r.YAMLMap(f.schema);e.flow=!0,e.items.push(T);let t=(w??i).range;e.range=[i.range[0],t[1],t[2]],v.items.push(e)}b=w?w.range[2]:s.end}}let x=g?`}`:`]`,[S,...C]=p.end,w=b;if(S?.source===x)w=S.offset+S.source.length;else{let e=_[0].toUpperCase()+_.substring(1),t=y?`${e} must end with a ${x}`:`${e} in block collection must be sufficiently indented and end with a ${x}`;m(b,y?`MISSING_CHAR`:`BAD_INDENT`,t),S&&S.source.length!==1&&C.unshift(S)}if(C.length>0){let e=a.resolveEnd(C,w,f.options.strict,m);e.comment&&(v.comment?v.comment+=`
286
- `+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=d})),JC=/* @__PURE__ */ E((e=>{var t=$(),n=tC(),r=mC(),i=gC(),a=WC(),o=GC(),s=qC();function c(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function l(e,a,o,s,l){let u=s.tag,d=u?a.directives.tagName(u.source,e=>l(u,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&u?e.offset>u.offset?e:u:e??u;n&&(!t||t.offset<n.offset)&&l(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let f=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!u||!d||d===`!`||d===r.YAMLMap.tagName&&f===`map`||d===i.YAMLSeq.tagName&&f===`seq`)return c(e,a,o,l,d);let p=a.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!p){let t=a.schema.knownTags[d];if(t?.collection===f)a.schema.tags.push(Object.assign({},t,{default:!1})),p=t;else return t?l(u,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${f} collection, but expects ${t.collection??`scalar`}`,!0):l(u,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${d}`,!0),c(e,a,o,l,d)}let m=c(e,a,o,l,d,p),h=p.resolve?.(m,e=>l(u,`TAG_RESOLVE_FAILED`,e),a.options)??m,g=t.isNode(h)?h:new n.Scalar(h);return g.range=m.range,g.tag=d,p?.format&&(g.format=p.format),g}e.composeCollection=l})),YC=/* @__PURE__ */ E((e=>{var t=tC();function n(e,n,a){let o=n.offset,s=r(n,e.options.strict,a);if(!s)return{value:``,type:null,comment:``,range:[o,o,o]};let c=s.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,l=n.source?i(n.source):[],u=l.length;for(let e=l.length-1;e>=0;--e){let t=l[e][1];if(t===``||t===`\r`)u=e;else break}if(u===0){let e=s.chomp===`+`&&l.length>0?`
286
+ `+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=d})),QC=/* @__PURE__ */ E((e=>{var t=$(),n=aC(),r=vC(),i=bC(),a=JC(),o=YC(),s=ZC();function c(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function l(e,a,o,s,l){let u=s.tag,d=u?a.directives.tagName(u.source,e=>l(u,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&u?e.offset>u.offset?e:u:e??u;n&&(!t||t.offset<n.offset)&&l(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let f=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!u||!d||d===`!`||d===r.YAMLMap.tagName&&f===`map`||d===i.YAMLSeq.tagName&&f===`seq`)return c(e,a,o,l,d);let p=a.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!p){let t=a.schema.knownTags[d];if(t?.collection===f)a.schema.tags.push(Object.assign({},t,{default:!1})),p=t;else return t?l(u,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${f} collection, but expects ${t.collection??`scalar`}`,!0):l(u,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${d}`,!0),c(e,a,o,l,d)}let m=c(e,a,o,l,d,p),h=p.resolve?.(m,e=>l(u,`TAG_RESOLVE_FAILED`,e),a.options)??m,g=t.isNode(h)?h:new n.Scalar(h);return g.range=m.range,g.tag=d,p?.format&&(g.format=p.format),g}e.composeCollection=l})),$C=/* @__PURE__ */ E((e=>{var t=aC();function n(e,n,a){let o=n.offset,s=r(n,e.options.strict,a);if(!s)return{value:``,type:null,comment:``,range:[o,o,o]};let c=s.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,l=n.source?i(n.source):[],u=l.length;for(let e=l.length-1;e>=0;--e){let t=l[e][1];if(t===``||t===`\r`)u=e;else break}if(u===0){let e=s.chomp===`+`&&l.length>0?`
287
287
  `.repeat(Math.max(1,l.length-1)):``,t=o+s.length;return n.source&&(t+=n.source.length),{value:e,type:c,comment:s.comment,range:[o,t,t]}}let d=n.indent+s.indent,f=n.offset+s.length,p=0;for(let t=0;t<u;++t){let[n,r]=l[t];if(r===``||r===`\r`)s.indent===0&&n.length>d&&(d=n.length);else{n.length<d&&a(f+n.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),s.indent===0&&(d=n.length),p=t,d===0&&!e.atRoot&&a(f,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}f+=n.length+r.length+1}for(let e=l.length-1;e>=u;--e)l[e][0].length>d&&(u=e+1);let m=``,h=``,g=!1;for(let e=0;e<p;++e)m+=l[e][0].slice(d)+`
288
288
  `;for(let e=p;e<u;++e){let[n,r]=l[e];f+=n.length+r.length+1;let i=r[r.length-1]===`\r`;
289
289
  /* istanbul ignore if already caught in lexer */
@@ -304,7 +304,7 @@ if(i&&(r=r.slice(0,-1)),r&&n.length<d){let e=`Block scalar lines must not be les
304
304
  /* istanbul ignore if should not happen */
305
305
  if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;
306
306
  /* istanbul ignore next should not happen */
307
- default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function i(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=n})),XC=/* @__PURE__ */ E((e=>{var t=tC(),n=KC();function r(e,r,o){let{offset:c,type:l,source:u,end:d}=e,f,p,m=(e,t,n)=>o(c+e,t,n);switch(l){case`scalar`:f=t.Scalar.PLAIN,p=i(u,m);break;case`single-quoted-scalar`:f=t.Scalar.QUOTE_SINGLE,p=a(u,m);break;case`double-quoted-scalar`:f=t.Scalar.QUOTE_DOUBLE,p=s(u,m);break;
307
+ default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function i(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=n})),ew=/* @__PURE__ */ E((e=>{var t=aC(),n=XC();function r(e,r,o){let{offset:c,type:l,source:u,end:d}=e,f,p,m=(e,t,n)=>o(c+e,t,n);switch(l){case`scalar`:f=t.Scalar.PLAIN,p=i(u,m);break;case`single-quoted-scalar`:f=t.Scalar.QUOTE_SINGLE,p=a(u,m);break;case`double-quoted-scalar`:f=t.Scalar.QUOTE_DOUBLE,p=s(u,m);break;
308
308
  /* istanbul ignore next should not happen */
309
309
  default:return o(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${l}`),{value:``,type:null,comment:``,range:[c,c+u.length,c+u.length]}}let h=c+u.length,g=n.resolveEnd(d,h,r,o);return{value:p,type:f,comment:g.comment,range:[c,h,g.offset]}}function i(e,t){let n=``;switch(e[0]){
310
310
  /* istanbul ignore next should not happen */
@@ -321,10 +321,10 @@ case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;c
321
321
  `);)r===`
322
322
  `&&(n+=`
323
323
  `),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}let l={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
324
- `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function u(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}e.resolveFlowScalar=r})),ZC=/* @__PURE__ */ E((e=>{var t=$(),n=tC(),r=YC(),i=XC();function a(e,a,c,l){let{value:u,type:d,comment:f,range:p}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,l):i.resolveFlowScalar(a,e.options.strict,l),m=c?e.directives.tagName(c.source,e=>l(c,`TAG_RESOLVE_FAILED`,e)):null,h;h=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:m?o(e.schema,u,m,c,l):a.type===`scalar`?s(e,u,a,l):e.schema[t.SCALAR];let g;try{let r=h.resolve(u,e=>l(c??a,`TAG_RESOLVE_FAILED`,e),e.options);g=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);l(c??a,`TAG_RESOLVE_FAILED`,t),g=new n.Scalar(u)}return g.range=p,g.source=u,d&&(g.type=d),m&&(g.tag=m),h.format&&(g.format=h.format),f&&(g.comment=f),g}function o(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r){if(t.default&&t.test)o.push(t);else return t}for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function s({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=a})),QC=/* @__PURE__ */ E((e=>{function t(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=t})),$C=/* @__PURE__ */ E((e=>{var t=eC(),n=$(),r=JC(),i=ZC(),a=KC(),o=QC();let s={composeNode:c,composeEmptyNode:l};function c(e,t,a,o){let c=e.atKey,{spaceBefore:d,comment:f,anchor:p,tag:m}=a,h,g=!0;switch(t.type){case`alias`:h=u(e,t,o),(p||m)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:h=i.composeScalar(e,t,m,o),p&&(h.anchor=p.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{h=r.composeCollection(s,e,t,a,o),p&&(h.anchor=p.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),g=!1}return h??=l(e,t.offset,void 0,null,a,o),p&&h.anchor===``&&o(p,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(h)||typeof h.value!=`string`||h.tag&&h.tag!==`tag:yaml.org,2002:str`)&&o(m??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),d&&(h.spaceBefore=!0),f&&(t.type===`scalar`&&t.source===``?h.comment=f:h.commentBefore=f),e.options.keepSourceTokens&&g&&(h.srcToken=t),h}function l(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let f={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},p=i.composeScalar(e,f,l,d);return c&&(p.anchor=c.source.substring(1),p.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}function u({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=l,e.composeNode=c})),ew=/* @__PURE__ */ E((e=>{var t=RC(),n=$C(),r=KC(),i=BC();function a(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),f=new t.Document(void 0,d),p={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},m=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});m.found&&(f.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!m.hasNewline&&u(m.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),f.contents=c?n.composeNode(p,c,m,u):n.composeEmptyNode(p,m.end,s,null,m,u);let h=f.contents.range[2],g=r.resolveEnd(l,h,!1,u);return g.comment&&(f.comment=g.comment),f.range=[o,h,g.offset],f}e.composeDoc=a})),tw=/* @__PURE__ */ E((e=>{var t=fe(`process`),n=YS(),r=RC(),i=zC(),a=$(),o=ew(),s=KC();function c(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function l(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
324
+ `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function u(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}e.resolveFlowScalar=r})),tw=/* @__PURE__ */ E((e=>{var t=$(),n=aC(),r=$C(),i=ew();function a(e,a,c,l){let{value:u,type:d,comment:f,range:p}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,l):i.resolveFlowScalar(a,e.options.strict,l),m=c?e.directives.tagName(c.source,e=>l(c,`TAG_RESOLVE_FAILED`,e)):null,h;h=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:m?o(e.schema,u,m,c,l):a.type===`scalar`?s(e,u,a,l):e.schema[t.SCALAR];let g;try{let r=h.resolve(u,e=>l(c??a,`TAG_RESOLVE_FAILED`,e),e.options);g=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);l(c??a,`TAG_RESOLVE_FAILED`,t),g=new n.Scalar(u)}return g.range=p,g.source=u,d&&(g.type=d),m&&(g.tag=m),h.format&&(g.format=h.format),f&&(g.comment=f),g}function o(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r){if(t.default&&t.test)o.push(t);else return t}for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function s({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=a})),nw=/* @__PURE__ */ E((e=>{function t(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=t})),rw=/* @__PURE__ */ E((e=>{var t=iC(),n=$(),r=QC(),i=tw(),a=XC(),o=nw();let s={composeNode:c,composeEmptyNode:l};function c(e,t,a,o){let c=e.atKey,{spaceBefore:d,comment:f,anchor:p,tag:m}=a,h,g=!0;switch(t.type){case`alias`:h=u(e,t,o),(p||m)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:h=i.composeScalar(e,t,m,o),p&&(h.anchor=p.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{h=r.composeCollection(s,e,t,a,o),p&&(h.anchor=p.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),g=!1}return h??=l(e,t.offset,void 0,null,a,o),p&&h.anchor===``&&o(p,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(h)||typeof h.value!=`string`||h.tag&&h.tag!==`tag:yaml.org,2002:str`)&&o(m??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),d&&(h.spaceBefore=!0),f&&(t.type===`scalar`&&t.source===``?h.comment=f:h.commentBefore=f),e.options.keepSourceTokens&&g&&(h.srcToken=t),h}function l(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let f={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},p=i.composeScalar(e,f,l,d);return c&&(p.anchor=c.source.substring(1),p.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}function u({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=l,e.composeNode=c})),iw=/* @__PURE__ */ E((e=>{var t=HC(),n=rw(),r=XC(),i=WC();function a(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),f=new t.Document(void 0,d),p={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},m=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});m.found&&(f.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!m.hasNewline&&u(m.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),f.contents=c?n.composeNode(p,c,m,u):n.composeEmptyNode(p,m.end,s,null,m,u);let h=f.contents.range[2],g=r.resolveEnd(l,h,!1,u);return g.comment&&(f.comment=g.comment),f.range=[o,h,g.offset],f}e.composeDoc=a})),aw=/* @__PURE__ */ E((e=>{var t=fe(`process`),n=$S(),r=HC(),i=UC(),a=$(),o=iw(),s=XC();function c(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function l(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
325
325
 
326
326
  `:`
327
- `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}e.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=c(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=l(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=c(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}}})),nw=/* @__PURE__ */ E((e=>{var t=YC(),n=XC(),r=zC(),i=oC();function a(e,i=!0,a){if(e){let o=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,o);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,o)}}return null}function o(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:`newline`,offset:-1,indent:r,source:`
327
+ `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}e.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=c(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=l(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=c(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}}})),ow=/* @__PURE__ */ E((e=>{var t=$C(),n=ew(),r=UC(),i=uC();function a(e,i=!0,a){if(e){let o=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,o);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,o)}}return null}function o(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:`newline`,offset:-1,indent:r,source:`
328
328
  `}];switch(c[0]){case`|`:case`>`:{let e=c.indexOf(`
329
329
  `),t=c.substring(0,e),n=c.substring(e+1)+`
330
330
  `,i=[{type:`block-scalar-header`,offset:o,indent:r,source:t}];return l(i,u)||i.push({type:`newline`,offset:-1,indent:r,source:`
@@ -332,11 +332,11 @@ case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;c
332
332
  `),r=t.substring(0,n),i=t.substring(n+1)+`
333
333
  `;if(e.type===`block-scalar`){let t=e.props[0];if(t.type!==`block-scalar-header`)throw Error(`Invalid block scalar header`);t.source=r,e.source=i}else{let{offset:t}=e,n=`indent`in e?e.indent:-1,a=[{type:`block-scalar-header`,offset:t,indent:n,source:r}];l(a,`end`in e?e.end:void 0)||a.push({type:`newline`,offset:-1,indent:n,source:`
334
334
  `});for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:`block-scalar`,indent:n,props:a,source:i})}}function l(e,t){if(t)for(let n of t)switch(n.type){case`space`:case`comment`:e.push(n);break;case`newline`:return e.push(n),!0}return!1}function u(e,t,n){switch(e.type){case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:e.type=n,e.source=t;break;case`block-scalar`:{let r=e.props.slice(1),i=t.length;e.props[0].type===`block-scalar-header`&&(i-=e.props[0].source.length);for(let e of r)e.offset+=i;delete e.props,Object.assign(e,{type:n,source:t,end:r});break}case`block-map`:case`block-seq`:{let r={type:`newline`,offset:e.offset+t.length,indent:e.indent,source:`
335
- `};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=o,e.resolveAsScalar=a,e.setScalarValue=s})),rw=/* @__PURE__ */ E((e=>{let t=e=>`type`in e?n(e):r(e);function n(e){switch(e.type){case`block-scalar`:{let t=``;for(let r of e.props)t+=n(r);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=r(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=r(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=r(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function r({start:e,key:t,sep:r,value:i}){let a=``;for(let t of e)a+=t.source;if(t&&(a+=n(t)),r)for(let e of r)a+=e.source;return i&&(a+=n(i)),a}e.stringify=t})),iw=/* @__PURE__ */ E((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),a(Object.freeze([]),e,t)}i.BREAK=t,i.SKIP=n,i.REMOVE=r,i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},i.parentCollection=(e,t)=>{let n=i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],a=n?.[r];if(a&&`items`in a)return a;throw Error(`Parent collection not found`)};function a(e,n,i){let o=i(n,e);if(typeof o==`symbol`)return o;for(let s of[`key`,`value`]){let c=n[s];if(c&&`items`in c){for(let n=0;n<c.items.length;++n){let o=a(Object.freeze(e.concat([[s,n]])),c.items[n],i);if(typeof o==`number`)n=o-1;else if(o===t)return t;else o===r&&(c.items.splice(n,1),--n)}typeof o==`function`&&s===`key`&&(o=o(n,e))}}return typeof o==`function`?o(n,e):o}e.visit=i})),aw=/* @__PURE__ */ E((e=>{var t=nw(),n=rw(),r=iw();let i=e=>!!e&&`items`in e,a=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);
335
+ `};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=o,e.resolveAsScalar=a,e.setScalarValue=s})),sw=/* @__PURE__ */ E((e=>{let t=e=>`type`in e?n(e):r(e);function n(e){switch(e.type){case`block-scalar`:{let t=``;for(let r of e.props)t+=n(r);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=r(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=r(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=r(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function r({start:e,key:t,sep:r,value:i}){let a=``;for(let t of e)a+=t.source;if(t&&(a+=n(t)),r)for(let e of r)a+=e.source;return i&&(a+=n(i)),a}e.stringify=t})),cw=/* @__PURE__ */ E((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),a(Object.freeze([]),e,t)}i.BREAK=t,i.SKIP=n,i.REMOVE=r,i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},i.parentCollection=(e,t)=>{let n=i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],a=n?.[r];if(a&&`items`in a)return a;throw Error(`Parent collection not found`)};function a(e,n,i){let o=i(n,e);if(typeof o==`symbol`)return o;for(let s of[`key`,`value`]){let c=n[s];if(c&&`items`in c){for(let n=0;n<c.items.length;++n){let o=a(Object.freeze(e.concat([[s,n]])),c.items[n],i);if(typeof o==`number`)n=o-1;else if(o===t)return t;else o===r&&(c.items.splice(n,1),--n)}typeof o==`function`&&s===`key`&&(o=o(n,e))}}return typeof o==`function`?o(n,e):o}e.visit=i})),lw=/* @__PURE__ */ E((e=>{var t=ow(),n=sw(),r=cw();let i=e=>!!e&&`items`in e,a=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);
336
336
  /* istanbul ignore next */
337
337
  function o(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:return`<FLOW_END>`;case``:return`<SCALAR>`;default:return JSON.stringify(e)}}function s(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
338
338
  `:case`\r
339
- `:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=i,e.isScalar=a,e.prettyToken=o,e.tokenType=s})),ow=/* @__PURE__ */ E((e=>{var t=aw();function n(e){switch(e){case void 0:case` `:case`
339
+ `:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=i,e.isScalar=a,e.prettyToken=o,e.tokenType=s})),uw=/* @__PURE__ */ E((e=>{var t=lw();function n(e){switch(e){case void 0:case` `:case`
340
340
  `:case`\r`:case` `:return!0;default:return!1}}let r=/* @__PURE__ */ new Set(`0123456789ABCDEFabcdef`),i=/* @__PURE__ */ new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),a=/* @__PURE__ */ new Set(`,[]{}`),o=/* @__PURE__ */ new Set(` ,[]{}
341
341
  \r `),s=e=>!e||o.has(e);e.Lexer=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
342
342
  `||t===`\r`&&this.buffer[e+1]===`
@@ -355,7 +355,7 @@ function o(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:re
355
355
  `,t=this.buffer[i+1]):r=i),t===`#`||e&&a.has(t))break;if(o===`
356
356
  `){let e=this.continueScalar(i+1);if(e===-1)break;i=Math.max(i,e-2)}}else{if(e&&a.has(o))break;r=i}return!o&&!this.atEnd?this.setNext(`plain-scalar`):(yield t.SCALAR,yield*this.pushToIndex(r+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(s),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,r=this.charAt(1);if(n(r)||t&&a.has(r)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!n(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(i.has(t))t=this.buffer[++e];else if(t===`%`&&r.has(this.buffer[e+1])&&r.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
357
357
  `?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
358
- `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}})),sw=/* @__PURE__ */ E((e=>{e.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}})),cw=/* @__PURE__ */ E((e=>{var t=fe(`process`),n=aw(),r=ow();function i(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function a(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function o(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function s(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;
358
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}})),dw=/* @__PURE__ */ E((e=>{e.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}})),fw=/* @__PURE__ */ E((e=>{var t=fe(`process`),n=lw(),r=uw();function i(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function a(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function o(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function s(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;
359
359
  /* istanbul ignore next should not happen */
360
360
  default:return[]}}function c(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function l(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function u(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!i(t.start,`explicit-key-ind`)&&!i(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,o(t.value)?t.value.end?l(t.value.end,t.sep):t.value.end=t.sep:l(t.start,t.sep),delete t.sep)}e.Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new r.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,t.env.LOG_TOKENS&&console.log(`|`,n.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=n.tokenType(e);if(!r){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(r===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=r,yield*this.step(),r){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source})}else{if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}
361
361
  /* istanbul ignore next should not happen */
@@ -371,17 +371,19 @@ default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.l
371
371
  /* istanbul ignore else should not happen */
372
372
  n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=c(s(t));u(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
373
373
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
374
- `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),lw=/* @__PURE__ */ E((e=>{var t=tw(),n=RC(),r=zC(),i=lC(),a=$(),o=sw(),s=cw();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),uw=(/* @__PURE__ */ E((e=>{var t=tw(),n=RC(),r=IC(),i=zC(),a=eC(),o=$(),s=fC(),c=tC(),l=mC(),u=gC();aw();var d=ow(),f=sw(),p=cw(),m=lw(),h=JS();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync})))();function dw(e,t){let n=(0,uw.parse)(e,{uniqueKeys:!1});if(!Z(n))throw Error(`not a YAML mapping`);let r=new HS(`npm`,t),i=Z(n.importers)?n.importers:{".":n};for(let e of Object.values(i))if(Z(e))for(let t of[`dependencies`,`devDependencies`,`optionalDependencies`]){let n=e[t];if(Z(n))for(let[e,t]of Object.entries(n)){let n=Z(t)?t.version:t;if(typeof n!=`string`||fw(n))continue;let i=mw(n);i?r.add(i.name,i.version,!0):r.add(e,pw(n),!0)}}for(let e of[`packages`,`snapshots`]){let t=n[e];if(Z(t))for(let e of Object.keys(t)){let t=mw(e);t&&!fw(t.version)&&r.add(t.name,t.version,!1)}}return r.rows()}function fw(e){return/^(link|file|workspace):/.test(e)}function pw(e){return e.replace(/\(.*$/,``).replace(/_(?=[^/]*@).*$/,``)}function mw(e){let t=e.replace(/^\//,``).replace(/\(.*$/,``),n=t.indexOf(`@`,1);if(n>0)return{name:t.slice(0,n),version:pw(t.slice(n+1))};if(!e.startsWith(`/`))return null;let r=t.lastIndexOf(`/`);return r<=0?null:{name:t.slice(0,r),version:pw(t.slice(r+1))}}function hw(e,t){let n=GS(e);if(!Z(n))throw Error(`not a JSON object`);let r=new HS(`npm`,t);if(Z(n.packages)){let e=/* @__PURE__ */ new Set;for(let[t,r]of Object.entries(n.packages))if(!t.includes(`node_modules/`))for(let t of WS(r))e.add(t);for(let[t,i]of Object.entries(n.packages)){let n=t.lastIndexOf(`node_modules/`);if(n===-1||!Z(i)||i.link===!0)continue;let a=t.slice(n+13),o=typeof i.name==`string`?i.name:a;if(typeof i.version!=`string`)continue;let s=t===`node_modules/${a}`;r.add(o,i.version,s&&e.has(a))}return r.rows()}if(Z(n.dependencies)){let e=(t,n)=>{for(let[i,a]of Object.entries(t)){if(!Z(a))continue;let t=a.version;typeof t==`string`&&!fw(t)&&r.add(i,t,n===0&&a.dev!==!0),Z(a.dependencies)&&e(a.dependencies,n+1)}};e(n.dependencies,0)}return r.rows()}function gw(e,t,n){let r=new HS(`npm`,t),i=[],a=!1;for(let t of e.split(/\r?\n/)){if(t===``||t.startsWith(`#`))continue;if(!/^\s/.test(t)&&t.endsWith(`:`)){let e=t.slice(0,-1).split(`,`).map(e=>e.trim().replace(/^"|"$/g,``));a=e.some(e=>/@(workspace|link|file|portal):/.test(e)),i=[...new Set(e.map(_w).filter(e=>e!==null))];continue}let e=/^\s+version:?\s+"?([^"\s]+)"?/.exec(t)?.[1];if(e&&!a){for(let t of i)r.add(t,e,n.has(t));i=[]}}return r.rows()}function _w(e){if(e===`__metadata`)return null;let t=e.indexOf(`@`,1);return t>0?e.slice(0,t):null}async function vw(e,t){let n=Ax(t),r=/* @__PURE__ */ new Set,i=await yw(e,jx(n,`package.json`));for(let e of WS(i))r.add(e);if(!Z(i))return r;let a=i.workspaces,o=(Array.isArray(a)?a:Z(a)&&Array.isArray(a.packages)?a.packages:[]).filter(e=>typeof e==`string`).map(e=>bw(jx(n,e.replace(/^\.\//,``).replace(/\/$/,``))));if(o.length===0)return r;for(let t of e.files){if(!t.path.endsWith(`package.json`))continue;let n=Ax(t.path);if(o.some(e=>e.test(n)))for(let n of WS(await yw(e,t.path)))r.add(n)}return r}async function yw(e,t){let n=e.file(t);if(!n)return null;let r=await e.readText(n);if(r===null)return null;try{return GS(r)}catch{return e.warnings.push(`${t}: not valid JSON, skipped`),null}}function bw(e){let t=e.split(`/`).map(e=>e===`**`?`.*`:e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`[^/]*`)).join(`/`);return RegExp(`^${t}$`)}function xw(e){return e.toLowerCase().replace(/[-_.]+/g,`-`)}function Sw(e,t,n){let r=new HS(`pip`,t),i=!1,a=null,o=null,s=!1,c=()=>{a&&o&&!s&&r.add(a,o,n.has(xw(a))),a=null,o=null,s=!1};for(let t of e.split(/\r?\n/)){if(/^\s*\[{1,2}([^\]]+)\]{1,2}\s*$/.exec(t)){t.trim()===`[[package]]`?(c(),i=!0):i=!1;continue}if(!i)continue;let e=/^\s*(name|version|source)\s*=\s*(.+)$/.exec(t);if(!e)continue;let n=e[2]?.trim()??``;if(e[1]===`source`)s=/\b(editable|virtual)\s*=/.test(n);else{let t=/^"([^"]*)"/.exec(n)?.[1];e[1]===`name`&&t&&(a=t),e[1]===`version`&&t&&(o=t)}}return c(),r.rows()}function Cw(e){let t=/* @__PURE__ */ new Set,n=``,r=null,i=``,a=e=>{let n=/^\s*([A-Za-z0-9][A-Za-z0-9._-]*)/.exec(e)?.[1];n&&t.add(xw(n))},o=()=>{for(let e of i.matchAll(/"([^"]*)"|'([^']*)'/g))a(e[1]??e[2]??``);r=null,i=``},s=e=>e.replace(/"[^"]*"|'[^']*'/g,``).includes(`]`);for(let a of e.split(/\r?\n/)){let e=a.replace(/\s+#.*$/,``);if(r!==null){i+=` ${e}`,s(e)&&o();continue}let c=/^\s*\[([^\]]+)\]\s*$/.exec(e);if(c){n=(c[1]??``).trim();continue}let l=/^\s*"?([A-Za-z0-9_.-]+)"?\s*=\s*(.*)$/.exec(e);if(!l)continue;let u=l[1]??``,d=l[2]??``;n===`tool.poetry.dependencies`||n===`tool.poetry.dev-dependencies`||/^tool\.poetry\.group\.[^.]+\.dependencies$/.test(n)?xw(u)!==`python`&&t.add(xw(u)):(n===`project`&&u===`dependencies`||n===`project.optional-dependencies`||n===`dependency-groups`)&&d.trimStart().startsWith(`[`)&&(r=u,i=d,s(d.trimStart().slice(1))&&o())}return t}function ww(e,t){let n=new HS(`pip`,t),r=0;for(let t of e.split(/\r?\n/)){let e=t.replace(/(^|\s)#.*$/,``).trim();if(e===``||e.startsWith(`-`))continue;let i=/^([A-Za-z0-9][A-Za-z0-9._-]*)\s*(?:\[[^\]]*\])?\s*===?\s*([^\s;,\\]+)/.exec(e);i?.[1]&&i[2]?n.add(i[1],i[2],!0):r++}return{rows:n.rows(),unpinned:r}}async function Tw(e){let t=[];for(let n of e.files)try{let r=await Ew(e,n);r&&t.push(...r)}catch(t){e.warnings.push(`${n.path}: could not be parsed (${Mx(t)})`)}return t}async function Ew(e,t){let n=kx(t.path),r=Ax(t.path),i=t=>t?e.readText(t,52428800):Promise.resolve(null),a=t=>e.file(jx(r,t));switch(n){case`pnpm-lock.yaml`:{let e=await i(t);return e===null?null:dw(e,t.path)}case`package-lock.json`:case`npm-shrinkwrap.json`:{let e=await i(t);return e===null?null:hw(e,t.path)}case`yarn.lock`:{let n=await i(t);return n===null?null:gw(n,t.path,await vw(e,t.path))}case`composer.lock`:{let e=await i(t);return e===null?null:KS(e,t.path,await i(a(`composer.json`)))}case`poetry.lock`:case`uv.lock`:{let e=await i(t);if(e===null)return null;let n=await i(a(`pyproject.toml`)),r=n?Cw(n):/* @__PURE__ */ new Set;return Sw(e,t.path,r)}case`go.sum`:case`go.mod`:return n===`go.mod`&&a(`go.sum`)?null:qS(await i(a(`go.mod`)),n===`go.sum`?await i(t):null,t.path)}if(/^requirements[\w.-]*\.txt$/i.test(n)||/(^|\/)requirements\/[^/]+\.txt$/.test(t.path)){let n=await i(t);if(n===null)return null;let{rows:r,unpinned:a}=ww(n,t.path);return a>0&&e.warnings.push(`${t.path}: ${a} requirement${a===1?``:`s`} without an exact == pin skipped`),r}return null}const Dw={name:`Supabase`,type:`database`,provider:`Supabase Postgres`},Ow={name:`Postgres`,type:`database`,provider:`Postgres`},kw={name:`MySQL`,type:`database`,provider:`MySQL`},Aw={name:`MongoDB`,type:`database`,provider:`MongoDB`},jw={name:`Redis`,type:`database`,provider:`Redis`},Mw={name:`Elasticsearch`,type:`database`,provider:`Elasticsearch`},Nw={name:`AWS S3`,type:`storage`,provider:`AWS S3`},Pw={name:`AWS SQS`,type:`queue`,provider:`AWS SQS`},Fw={name:`AWS`,type:`service`,provider:`AWS`},Iw={name:`MinIO`,type:`storage`,provider:`MinIO`},Lw={name:`Cloudinary`,type:`storage`,provider:`Cloudinary`},Rw={name:`RabbitMQ`,type:`queue`,provider:`RabbitMQ`},zw={name:`Kafka`,type:`queue`,provider:`Kafka`},Bw={name:`Stripe`,type:`external_api`,provider:`Stripe`},Vw={name:`Twilio`,type:`external_api`,provider:`Twilio`},Hw={name:`SendGrid`,type:`service`,provider:`SendGrid`},Uw={name:`Postmark`,type:`service`,provider:`Postmark`},Ww={name:`Resend`,type:`service`,provider:`Resend`},Gw={name:`Mailgun`,type:`service`,provider:`Mailgun`},Kw={name:`Email (SMTP)`,type:`service`,provider:`SMTP`},qw={name:`Firebase`,type:`service`,provider:`Firebase`},Jw={name:`OpenAI`,type:`ai`,provider:`OpenAI`},Yw={name:`Anthropic`,type:`ai`,provider:`Anthropic`},Xw={name:`Sentry`,type:`monitoring`,provider:`Sentry`},Zw={name:`Auth0`,type:`auth`,provider:`Auth0`},Qw={name:`Clerk`,type:`auth`,provider:`Clerk`},$w={name:`Auth.js`,type:`auth`,provider:`Auth.js`},eT={name:`Algolia`,type:`external_api`,provider:`Algolia`},tT={name:`Google Cloud`,type:`service`,provider:`Google Cloud`},nT={name:`Cloud Storage`,type:`storage`,provider:`Google Cloud Storage`},rT={name:`Pub/Sub`,type:`queue`,provider:`Google Cloud Pub/Sub`},iT={name:`BigQuery`,type:`database`,provider:`Google BigQuery`},aT={name:`Firestore`,type:`database`,provider:`Google Firestore`},oT={name:`Secret Manager`,type:`secrets`,provider:`Google Secret Manager`},sT={name:`Gemini`,type:`ai`,provider:`Google Gemini`},cT={name:`Vertex AI`,type:`ai`,provider:`Google Vertex AI`},lT={name:`SerpApi`,type:`external_api`,provider:`SerpApi`},uT={name:`Zyte`,type:`external_api`,provider:`Zyte`},dT={name:`Open Exchange Rates`,type:`external_api`,provider:`Open Exchange Rates`},fT={name:`reCAPTCHA`,type:`external_api`,provider:`Google reCAPTCHA`},pT={name:`DuckDB`,type:`database`,provider:`DuckDB`},mT=[[/^SUPABASE_/,Dw],[/^(DATABASE_URL|POSTGRES_|PG(HOST|USER|PASSWORD|DATABASE|PORT)$)/,Ow],[/^MYSQL_/,kw],[/^MONGO(DB)?_/,Aw],[/^(REDIS_|UPSTASH_REDIS_)/,jw],[/^(ELASTIC(SEARCH)?_)/,Mw],[/^(AWS_)?S3_|_S3_BUCKET$|^AWS_BUCKET/,Nw],[/^(AWS_)?SQS_/,Pw],[/^AWS_(ACCESS_KEY_ID|SECRET_ACCESS_KEY|REGION|DEFAULT_REGION)$/,Fw],[/^MINIO_/,Iw],[/^CLOUDINARY_/,Lw],[/^(RABBITMQ_|AMQP_URL)/,Rw],[/^KAFKA_/,zw],[/^STRIPE_/,Bw],[/^TWILIO_/,Vw],[/^SENDGRID_/,Hw],[/^POSTMARK_/,Uw],[/^RESEND_/,Ww],[/^MAILGUN_/,Gw],[/^SMTP_/,Kw],[/^FIREBASE_/,qw],[/^OPENAI_/,Jw],[/^ANTHROPIC_/,Yw],[/^SENTRY_/,Xw],[/^AUTH0_/,Zw],[/^CLERK_/,Qw],[/^(NEXTAUTH_|AUTH_SECRET$)/,$w],[/^ALGOLIA_/,eT],[/^(GCS_BUCKET|GOOGLE_CLOUD_STORAGE_|GCS_)/,nT],[/^(PUBSUB_|GOOGLE_PUBSUB_)/,rT],[/^BIGQUERY_/,iT],[/^FIRESTORE_/,aT],[/^(GEMINI_|GOOGLE_GENAI_)/,sT],[/^VERTEX(_AI)?_/,cT],[/^(SERPAPI_|SERP_API_)/,lT],[/^ZYTE_/,uT],[/^(OPEN_EXCHANGE_RATES_|OPENEXCHANGERATES_|OXR_)/,dT],[/^RECAPTCHA_/,fT],[/^(GOOGLE_CLOUD_PROJECT|GCP_PROJECT(_ID)?|GCLOUD_PROJECT|GOOGLE_APPLICATION_CREDENTIALS)$/,tT]],hT=[[[`@supabase/supabase-js`,`@supabase/ssr`,`supabase`,`github.com/supabase-community/*`,`supabase/supabase-php`],Dw],[[`pg`,`postgres`,`pg-promise`,`@neondatabase/serverless`,`@vercel/postgres`,`psycopg2`,`psycopg2-binary`,`psycopg`,`asyncpg`,`github.com/jackc/pgx*`,`github.com/lib/pq`],Ow],[[`mysql`,`mysql2`,`pymysql`,`mysqlclient`,`github.com/go-sql-driver/mysql`],kw],[[`mongodb`,`mongoose`,`pymongo`,`motor`,`go.mongodb.org/mongo-driver*`,`mongodb/mongodb`],Aw],[[`redis`,`ioredis`,`@upstash/redis`,`predis/predis`,`github.com/redis/go-redis*`,`github.com/go-redis/redis*`],jw],[[`@elastic/elasticsearch`,`elasticsearch`,`elasticsearch/elasticsearch`],Mw],[[`@aws-sdk/client-s3`,`github.com/aws/aws-sdk-go-v2/service/s3`,`league/flysystem-aws-s3-v3`],Nw],[[`@aws-sdk/client-sqs`,`github.com/aws/aws-sdk-go-v2/service/sqs`],Pw],[[`aws-sdk`,`boto3`,`aws/aws-sdk-php`,`github.com/aws/aws-sdk-go`],Fw],[[`minio`],Iw],[[`cloudinary`,`cloudinary/cloudinary_php`],Lw],[[`amqplib`,`pika`,`php-amqplib/php-amqplib`,`github.com/rabbitmq/amqp091-go`],Rw],[[`kafkajs`,`kafka-python`,`confluent-kafka`,`github.com/segmentio/kafka-go`],zw],[[`stripe`,`@stripe/stripe-js`,`@stripe/react-stripe-js`,`stripe/stripe-php`,`github.com/stripe/stripe-go*`],Bw],[[`twilio`,`twilio/sdk`,`github.com/twilio/twilio-go`],Vw],[[`@sendgrid/`,`sendgrid`,`sendgrid/sendgrid`],Hw],[[`postmark`,`wildbit/postmark-php`],Uw],[[`resend`,`resend/resend-php`],Ww],[[`mailgun.js`,`mailgun/mailgun-php`],Gw],[[`nodemailer`],Kw],[[`firebase`,`firebase-admin`,`firebase-functions`,`kreait/firebase-php`,`firebase.google.com/go*`],qw],[[`openai`,`openai-php/client`,`github.com/sashabaranov/go-openai`],Jw],[[`@anthropic-ai/sdk`,`anthropic`,`github.com/anthropics/anthropic-sdk-go`],Yw],[[`@sentry/`,`sentry-sdk`,`sentry/sentry`,`sentry/sentry-laravel`,`github.com/getsentry/sentry-go`],Xw],[[`@auth0/`,`auth0`,`auth0/auth0-php`],Zw],[[`@clerk/`],Qw],[[`next-auth`,`@auth/`],$w],[[`algoliasearch`,`algolia/algoliasearch-client-php`],eT],[[`@google-cloud/storage`,`google-cloud-storage`,`cloud.google.com/go/storage`],nT],[[`@google-cloud/pubsub`,`google-cloud-pubsub`,`cloud.google.com/go/pubsub*`],rT],[[`@google-cloud/bigquery`,`google-cloud-bigquery`,`cloud.google.com/go/bigquery`],iT],[[`@google-cloud/firestore`,`google-cloud-firestore`,`cloud.google.com/go/firestore`],aT],[[`@google-cloud/secret-manager`,`google-cloud-secret-manager`,`cloud.google.com/go/secretmanager`],oT],[[`@google/genai`,`@google/generative-ai`,`google-genai`,`google-generativeai`],sT],[[`@google-cloud/vertexai`,`google-cloud-aiplatform`,`vertexai`],cT],[[`serpapi`,`google-search-results`],lT],[[`zyte-api`,`scrapy-zyte-api`],uT],[[`open-exchange-rates`],dT],[[`react-google-recaptcha`,`react-google-recaptcha-v3`,`vue-recaptcha`,`vue-recaptcha-v3`,`@google-cloud/recaptcha-enterprise`,`google-cloud-recaptcha-enterprise`,`django-recaptcha`],fT],[[`@google-cloud/`,`google-cloud-*`,`google-auth-library`,`google-auth`,`cloud.google.com/go*`],tT],[[`duckdb`,`@duckdb/`],pT]],gT=[[/^supabase\//,Dw],[/(^|\/)(postgres|postgis|timescaledb)$/,Ow],[/(^|\/)(mysql|mariadb)$/,kw],[/(^|\/)mongo(db)?$/,Aw],[/(^|\/)(redis|redis-stack|valkey)$/,jw],[/(^|\/)(elasticsearch|opensearch)$/,Mw],[/(^|\/)minio$/,Iw],[/(^|\/)rabbitmq$/,Rw],[/(^|\/)(kafka|cp-kafka)$/,zw],[/(^|\/)localstack$/,Fw],[/(^|\/)(cloud-sdk|google-cloud-cli)$/,tT],[/(^|\/)(gcloud-pubsub-emulator|pubsub-emulator)$/,rT],[/(^|\/)fake-gcs-server$/,nT]];function _T(e){return/^\.env(\.[\w-]+)*\.(example|sample|template|dist)$/i.test(e)||/^(example|sample)\.env$/i.test(e)}function vT(e){let t=kx(e);return/^\.gitlab-ci\.ya?ml$/.test(t)||/^cloudbuild\.ya?ml$/.test(t)||t===`bitbucket-pipelines.yml`||/(^|\/)\.github\/workflows\/[^/]+\.ya?ml$/.test(e)}function yT(e){return[...new Set(e.match(/\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\b/g)??[])]}function bT(e){return/^(docker-)?compose([.-][\w.-]+)?\.ya?ml$/i.test(e)}var xT=class{#e=/* @__PURE__ */ new Map;add(e,t){let n=this.#e.get(e.provider);n?n.evidence.includes(t)||n.evidence.push(t):this.#e.set(e.provider,{...e,evidence:[t]})}list(){return[...this.#e.values()].sort((e,t)=>e.name.localeCompare(t.name))}};async function ST(e,t){let n=new xT,r=(e,t)=>{let r=e.replace(/^(NEXT_PUBLIC_|VITE_|PUBLIC_|REACT_APP_|EXPO_PUBLIC_|NUXT_PUBLIC_|NUXT_)/,``),i=mT.find(([e])=>e.test(r));i&&n.add(i[1],t)};for(let t of e.files){let i=kx(t.path);if(_T(i)){let n=await e.readText(t);if(n===null)continue;for(let e of CT(n))r(e,`env: ${e} (${t.path})`)}else if(vT(t.path)){let n=await e.readText(t);if(n===null)continue;for(let e of yT(n))r(e,`pipeline: ${e} (${t.path})`)}else if(bT(i)){let i=await e.readText(t);if(i===null)continue;let a;try{a=(0,uw.parse)(i)}catch(n){e.warnings.push(`${t.path}: could not be parsed (${Mx(n)})`);continue}let o=Z(a)&&Z(a.services)?a.services:{};for(let[e,i]of Object.entries(o)){if(!Z(i))continue;let a=i.environment,o=Array.isArray(a)?a.map(e=>String(e).split(`=`,1)[0]??``):Z(a)?Object.keys(a):[];for(let n of o)r(n,`docker-compose: ${e} env ${n} in ${t.path}`);if(typeof i.image!=`string`)continue;let s=wT(i.image),c=gT.find(([e])=>e.test(s));c&&n.add(c[1],`docker-compose: service ${e} (${i.image}) in ${t.path}`)}}else t.path===`supabase/config.toml`||t.path.endsWith(`/supabase/config.toml`)?n.add(Dw,`file: ${t.path}`):i===`firebase.json`?n.add(qw,`file: ${t.path}`):/^cloudbuild\.ya?ml$/.test(i)&&n.add(tT,`file: ${t.path}`)}for(let e of t){if(!e.direct)continue;let t=hT.find(([t])=>t.some(t=>TT(t,e.package)));t&&n.add(t[1],`dependency: ${e.package} (${e.sourceLockfile})`)}return n.list()}function CT(e){let t=[];for(let n of e.split(/\r?\n/)){let e=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(n);e?.[1]&&t.push(e[1])}return t}function wT(e){let t=e.toLowerCase().replace(/@.*$/,``),n=t.lastIndexOf(`/`),r=t.indexOf(`:`,n+1);r!==-1&&(t=t.slice(0,r));let i=t.split(`/`);return i.length>1&&/[.:]|^localhost$/.test(i[0]??``)&&i.shift(),i[0]===`library`&&i.shift(),i.join(`/`)}function TT(e,t){return e.endsWith(`*`)?t.startsWith(e.slice(0,-1)):e.endsWith(`/`)?t.startsWith(e):t===e}const ET={name:`Supabase Auth`,type:`auth`,provider:`Supabase Auth`},DT={name:`pg_cron`,type:`scheduler`,provider:`pg_cron`},OT={postgres:[Dw,Ow],mysql:[kw]};function kT(e,t){let n=new Map(t.map(e=>[e.provider,e])),r=(e,t)=>{let r=n.get(e.provider);if(r)return r.provider;let i={...e,evidence:[t]};return n.set(e.provider,i),i.provider};for(let t of e){let e=t.sourcePath.slice(0,t.sourcePath.lastIndexOf(`/`)+1),i=/(^|\/)supabase\//i.test(t.sourcePath);if(t.kind===`job`){t.resource===DT.provider&&r(DT,`cron.schedule in ${t.sourcePath}`);continue}if(t.kind!==`table`&&t.kind!==`function`&&t.kind!==`role`)continue;if(t.kind===`role`){let e=[...n.values()].find(e=>e.type===`auth`);if(e){t.resource=e.provider;continue}if(i){t.resource=r(ET,`roles: ${t.sourcePath}`);continue}}if(i){t.resource=r(Dw,`migrations: ${e}`);continue}let a=(t.dialect===`postgres`||t.dialect===`mysql`?OT[t.dialect]:[...OT.postgres,...OT.mysql]).find(e=>n.has(e.provider));a?t.resource=a.provider:t.dialect===`postgres`?t.resource=r(Ow,`migrations: ${e}`):t.dialect===`mysql`&&(t.resource=r(kw,`migrations: ${e}`))}return[...n.values()].sort((e,t)=>e.name.localeCompare(t.name))}const AT=(e,t,n=e)=>({name:e,type:t,provider:n}),jT=AT(`Environment variables`,`secrets`),MT=AT(`GitHub Actions secrets`,`secrets`),NT=AT(`GitHub Actions`,`scheduler`),PT=AT(`Cloud Run`,`hosting`,`Google Cloud Run`),FT=AT(`Cloud Scheduler`,`scheduler`,`Google Cloud Scheduler`),IT=AT(`Vercel`,`hosting`),LT=AT(`Vercel Cron`,`scheduler`),RT=AT(`Netlify`,`hosting`),zT=AT(`Netlify Scheduled Functions`,`scheduler`),BT=AT(`Fly.io`,`hosting`),VT=AT(`AWS Lambda`,`hosting`),HT=AT(`EventBridge schedules`,`scheduler`,`Amazon EventBridge`),UT=AT(`Kubernetes CronJobs`,`scheduler`,`Kubernetes CronJob`),WT=AT(`Kubernetes`,`hosting`);function GT(e){let t={"@hourly":`every hour`,"@daily":`every day at 00:00`,"@midnight":`every day at 00:00`,"@weekly":`every Sunday at 00:00`,"@monthly":`on the 1st of every month at 00:00`,"@yearly":`every year on 1 January at 00:00`,"@annually":`every year on 1 January at 00:00`},n=e.trim();if(t[n])return t[n];let r=n.split(/\s+/);if(r.length!==5)return;let[i=``,a=``,o=``,s=``,c=``]=r,l=e=>/^\*\/(\d+)$/.exec(e)?.[1],u=e=>/^\d+$/.test(e),d=(...e)=>e.every(e=>e===`*`),f=(e,t)=>`${e.padStart(2,`0`)}:${t.padStart(2,`0`)}`;if(i===`*`&&d(a,o,s,c))return`every minute`;if(l(i)&&d(a,o,s,c))return`every ${l(i)} minutes`;if(u(i)&&d(a,o,s,c))return i===`0`?`every hour`:`every hour at :${i.padStart(2,`0`)}`;if(u(i)&&l(a)&&d(o,s,c))return`every ${l(a)} hours`;if(!u(i)||!u(a))return;let p=f(a,i);if(d(o,s,c))return`every day at ${p}`;let m=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`];if(d(o,s)){if(c===`1-5`)return`every weekday at ${p}`;let e=c.split(`,`).map(e=>m[Number(e)]);return e.every(Boolean)?`every ${e.join(` and `)} at ${p}`:void 0}if(u(o)&&d(s,c))return`on day ${o} of every month at ${p}`}function KT(e){let t=/* @__PURE__ */ new Map;for(let n of e.matchAll(/--([\w-]+)(?:[= ]+("[^"]*"|'[^']*'|(?!--)[^\s]+))?/g))t.set(n[1]??``,(n[2]??``).replace(/^["']|["']$/g,``));return t}function qT(e){return(e??``).split(/[,\n]/).map(e=>e.trim()).filter(e=>e.includes(`=`)).map(e=>{let[t=``,n=``]=e.split(`=`,2);return[t.trim(),n.trim()]})}const JT=e=>e.replace(/:[^:/]*$/,``).replace(/^.*\/secrets\//,``),YT=e=>/^projects\/([^/]+)\/secrets\//.exec(e)?.[1],XT=e=>e&&!/[$%{}]/.test(e)?e:void 0,ZT=e=>/^[A-Za-z0-9][\w.-]*$/.test(e);function QT(e){let t=/* @__PURE__ */ new Map;for(let n of e.matchAll(/^[ \t]*(?:export[ \t]+)?([A-Za-z_]\w*)[ \t]*(\?=|::?=|=)[ \t]*(.*)$/gm)){let[,e=``,r,i=``]=n;r===`?=`&&t.has(e)||t.set(e,i.replace(/\s+#.*$/,``).trim().replace(/^(["'])(.*)\1$/,`$2`))}return t}function $T(e,t){let n=e;for(let e=0;e<5&&t.size;e++){let e=n.replace(/\$\{\{\s*env\.(\w+)\s*\}\}|(?<!\$)\$(?:\((\w+)\)|\{(\w+)\}|([A-Za-z_]\w*))/g,(e,n,r,i,a)=>t.get(n??r??i??a)??e);if(e===n)break;n=e}return n}function eE(e){if(!Z(e))return[];let t=(e,t)=>{if(Z(e))for(let[n,r]of Object.entries(e)){let e=Z(r)?r.value:r;(typeof e==`string`||typeof e==`number`)&&t.set(n,String(e))}return t},n=e=>typeof e==`string`?[e]:Array.isArray(e)?e.flatMap(n):[],r=t(e.variables,t(e.env,/* @__PURE__ */ new Map)),i=(t,r=0)=>{let a=n(t.extends).flatMap(t=>{let n=e[t];return Z(n)&&r<5?[i(n,r+1)]:[]}),o={};for(let e of[...a,t])for(let[t,n]of Object.entries(e))o[t]=t===`variables`&&Z(o[t])&&Z(n)?{...o[t],...n}:n;return o};return(Z(e.jobs)?Object.values(e.jobs):Object.entries(e).filter(([e])=>!e.startsWith(`.`)).map(([,e])=>e)).flatMap(e=>{if(!Z(e))return[];let a=i(e),o=t(a.variables,t(a.env,new Map(r))),s=Array.isArray(a.steps)?a.steps:[];for(let e of s)Z(e)&&t(e.env,o);let c=[...n(a.before_script),...n(a.script),...s.flatMap(e=>Z(e)?n(e.run):[])].join(`
375
- `);return c?[{text:c,vars:o}]:[]})}function tE(e,t,n){let r=(0,uw.parseAllDocuments)(n,{merge:!0}).map(e=>e.toJS());for(let n of r)for(let r of eE(n))lE(e,t,$T(r.text,r.vars));lE(e,t,n)}const nE=e=>/(SECRET|TOKEN|PASSWORD|PASSWD|PRIVATE|API_KEY|_KEY$|CREDENTIAL|DSN|AUTH)/i.test(e),rE=/["'`]((?:claude-(?:opus|sonnet|haiku|fable|instant|\d)[\w.-]*)|(?:gpt-(?:\d|4o)[\w.-]*)|(?:o[134](?:-mini|-pro|-preview)?(?:-\d{4}-\d{2}-\d{2})?)|(?:text-embedding-[\w-]+)|(?:gemini-(?:\d|embedding)[\w.-]*)|whisper-1|dall-e-[23]|gpt-image-1)["'`]/g,iE=/\.(?:[cm]?[jt]sx?|py|go|rb|java|kt|cs|php|rs|swift|ya?ml|toml|json)$/i,aE=/(^|\/)(?:package(?:-lock)?\.json|pnpm-lock\.yaml|yarn\.lock|composer\.lock|[^/]*\.lock|tsconfig[^/]*\.json)$|(^|\/)(?:__tests__|tests?|fixtures?|test-fixtures|docs?|examples?|demo|seeds?|mocks?)\//i,oE={run:`Google Cloud Run`,pubsub:`Google Cloud Pub/Sub`,scheduler:`Google Cloud Scheduler`,secrets:`Google Secret Manager`,storage:`Google Cloud Storage`,firestore:`Google Firestore`};var sE=class{resources=/* @__PURE__ */ new Map;projects=/* @__PURE__ */ new Map;usedIn(e,t){if(!t)return;let n=this.projects.get(e)??/* @__PURE__ */ new Set;n.add(t),this.projects.set(e,n)}contracts=[];#e=/* @__PURE__ */ new Map;resource(e,t){let n=this.resources.get(e.provider);return n?n.evidence.includes(t)||n.evidence.push(t):this.resources.set(e.provider,{...e,evidence:[t]}),e.provider}add(e,t){this.contracts.some(e=>e.kind===t.kind&&e.name===t.name)||this.contracts.push({...t,resource:this.resource(e,`${t.kind}: ${t.name} (${t.sourcePath})`)})}variable(e,t,n,r,i){if(!/^[A-Za-z_][\w-]*$/.test(n))return;let a=this.#e.get(n),o=[.../* @__PURE__ */ new Set([...a?.contract.setIn??[],e.name])];if(a&&a.priority<=t){a.contract.setIn=o;return}let s={kind:`variable`,name:n,sourcePath:r,secret:nE(n),...i,setIn:o,resource:this.resource(e,`variable: ${n} (${r})`)};a&&this.contracts.splice(this.contracts.indexOf(a.contract),1),this.contracts.push(s),this.#e.set(n,{contract:s,priority:t})}};function cE(e,t,n,r,i,a,o){if(!ZT(n))return;let s=XT(o),c=s?{project:s}:{},l=[{relation:`runs`,to:`repo:.`}];for(let[n]of i)e.variable(PT,2,n,t,{secret:nE(n),...c}),l.push({relation:`uses`,to:`variable:${n}`});for(let[n,r]of a){let i=JT(r),a=XT(YT(r))??s;e.variable(oT,1,i,t,{secret:!0,...n===i?{}:{envName:n},...a?{project:a}:{}}),l.push({relation:`uses`,to:`variable:${i}`})}e.add(PT,{kind:`deployment`,name:n,sourcePath:t,...r?{region:r}:{},...c,trigger:`HTTP`,links:l})}function lE(e,t,n){let r=n.replace(/\\\r?\n\s*/g,` `),i=XT(/gcloud\s+config\s+set\s+(?:core\/)?project\s+["']?([^\s'"]+)/.exec(r)?.[1]??/CLOUDSDK_CORE_PROJECT\s*[=:]\s*["']?([^\s'"]+)/.exec(r)?.[1]);for(let t of r.matchAll(/gcloud\s+(?:beta\s+|alpha\s+)?([a-z][\w-]*)\b([^\n]*)/g)){let n=XT(KT(t[2]??``).get(`project`))??i;e.usedIn(`Google Cloud`,n);let r=oE[t[1]??``];r&&e.usedIn(r,n)}for(let t of r.matchAll(/firebase\s[^\n]*?(?:--project|-P)[ =]["']?([^\s'"]+)/g))!/emulators:/.test(t[0])&&!/^demo(-|$)/.test(t[1]??``)&&e.usedIn(`Firebase`,XT(t[1]));for(let n of r.matchAll(/gcloud\s+(?:beta\s+)?run\s+deploy\s+["']?([^\s'"`]+)["']?([^\n]*)/g)){let r=KT(n[2]??``);cE(e,t,n[1]??``,r.get(`region`),qT(r.get(`set-env-vars`)??r.get(`update-env-vars`)),qT(r.get(`set-secrets`)??r.get(`update-secrets`)),r.get(`project`)??i)}for(let n of r.matchAll(/gcloud\s+(?:beta\s+)?scheduler\s+jobs\s+(?:create|update)\s+(http|pubsub|app-engine)\s+["']?([^\s'"`]+)["']?([^\n]*)/g)){let r=n[2]??``,a=KT(n[3]??``),o=a.get(`schedule`);if(!o||!ZT(r))continue;let s=[],c=a.get(`uri`),l;try{l=c?new URL(c).pathname:void 0}catch{}l&&s.push({relation:`calls`,to:`endpoint:${(a.get(`http-method`)??`POST`).toUpperCase()} ${l}`});let u=XT(a.get(`project`))??i;e.add(FT,{kind:`job`,name:r,sourcePath:t,schedule:o,...GT(o)?{scheduleText:GT(o)}:{},...a.get(`time-zone`)?{timeZone:a.get(`time-zone`)}:{},...u?{project:u}:{},runs:n[1]===`pubsub`?`Publishes to Pub/Sub topic ${a.get(`topic`)??``}`.trim():c?`Calls ${c.replace(/^https?:\/\/[^/]+/,``)}`:void 0,links:s})}}const uE=(e,t)=>new RegExp(String.raw`\b${t}\s*=\s*"([^"]*)"`).exec(e)?.[1];function dE(e,t,n){let r=/provider\s+"google(?:-beta)?"\s*\{([\s\S]*?)\n\}/.exec(n)?.[1],i=XT(r?uE(r,`project`):void 0);for(let r of n.matchAll(/resource\s+"(google_cloud_scheduler_job|google_cloud_run_service|google_cloud_run_v2_service|google_secret_manager_secret)"\s+"[\w-]+"\s*\{([\s\S]*?)\n\}/g)){let n=r[2]??``,a=XT(uE(n,`project`))??i,o=a?{project:a}:{};if(r[1]===`google_cloud_scheduler_job`){let r=uE(n,`name`),i=uE(n,`schedule`);if(!r||!i)continue;e.add(FT,{kind:`job`,name:r,sourcePath:t,schedule:i,...GT(i)?{scheduleText:GT(i)}:{},...uE(n,`time_zone`)?{timeZone:uE(n,`time_zone`)}:{},...o})}else if(r[1]===`google_secret_manager_secret`){let r=uE(n,`secret_id`);r&&e.variable(oT,1,r,t,{secret:!0,...o})}else{let r=uE(n,`name`);r&&e.add(PT,{kind:`deployment`,name:r,sourcePath:t,...uE(n,`location`)?{region:uE(n,`location`)}:{},...o,trigger:`HTTP`,links:[{relation:`runs`,to:`repo:.`}]})}}}function fE(e,t,n){if(!Z(n))return;let r=typeof n.name==`string`?n.name:kx(t).replace(/\.ya?ml$/,``),i=Z(n.on)?n.on:Z(n.true)?n.true:null,a=Array.isArray(i?.schedule)?i.schedule.flatMap(e=>Z(e)&&typeof e.cron==`string`?[e.cron]:[]):[];for(let n of a)e.add(NT,{kind:`job`,name:a.length>1?`${r} (${n})`:r,sourcePath:t,schedule:n,...GT(n)?{scheduleText:GT(n)}:{},timeZone:`UTC`,runs:`GitHub Actions workflow ${t}`});let o=Z(n.jobs)?Object.values(n.jobs):[];for(let r of o){let i=Z(r)&&Array.isArray(r.steps)?r.steps:[],a=/* @__PURE__ */ new Map;for(let e of[n.env,Z(r)?r.env:void 0])if(Z(e))for(let[t,n]of Object.entries(e))(typeof n==`string`||typeof n==`number`)&&a.set(t,String(n));for(let n of i){if(!Z(n)||typeof n.uses!=`string`||!n.uses.startsWith(`google-github-actions/deploy-cloudrun`)||!Z(n.with))continue;let r=n.with,i=e=>typeof e==`string`?$T(e,a):void 0;cE(e,t,i(r.service)??``,i(r.region),qT(i(r.env_vars)),qT(i(r.secrets)),i(r.project_id))}}}function pE(e,t,n){for(let r of n){if(!Z(r)||!Z(r.metadata))continue;let n=r.metadata.name;if(typeof n!=`string`)continue;let i=Z(r.spec)?r.spec:{};if(r.kind===`CronJob`&&typeof i.schedule==`string`&&String(r.apiVersion??``).startsWith(`batch/`))e.add(UT,{kind:`job`,name:n,sourcePath:t,schedule:i.schedule,...GT(i.schedule)?{scheduleText:GT(i.schedule)}:{},...typeof i.timeZone==`string`?{timeZone:i.timeZone}:{}});else if(r.kind===`Service`&&String(r.apiVersion??``).startsWith(`serving.knative.dev`)){let a=Z(i.template)&&Z(i.template.spec)&&Array.isArray(i.template.spec.containers)?i.template.spec.containers:[],o=[],s=[];for(let e of a)if(Z(e)&&Array.isArray(e.env))for(let t of e.env){if(!Z(t)||typeof t.name!=`string`)continue;let e=Z(t.valueFrom)&&Z(t.valueFrom.secretKeyRef)?t.valueFrom.secretKeyRef.name:void 0;typeof e==`string`?s.push([t.name,e]):o.push([t.name,``])}let c=(Z(r.metadata.labels)?r.metadata.labels:{})[`cloud.googleapis.com/location`];cE(e,t,n,typeof c==`string`?c:void 0,o,s)}else r.kind===`Deployment`&&String(r.apiVersion??``).startsWith(`apps/`)&&e.add(WT,{kind:`deployment`,name:n,sourcePath:t,links:[{relation:`runs`,to:`repo:.`}]})}}const mE=(e,t)=>new RegExp(String.raw`^\s*${t}\s*=\s*["']([^"']+)["']`,`m`).exec(e)?.[1];async function hE(e,t,n){let r=new sE,i=e=>{let t=e.lastIndexOf(`/`);return t>0?kx(e.slice(0,t)):n};for(let t of e.files){let a=kx(t.path),o=t.path,s=()=>e.readText(t);if(_T(a)){let e=await s();if(e===null)continue;let t=/^\.env\.([\w-]+)\./i.exec(a)?.[1];for(let n of CT(e))r.variable(jT,4,n,o,t?{environments:[t]}:{})}else if(/(^|\/)\.github\/workflows\/[^/]+\.ya?ml$/.test(o)){let e=await s();if(e===null)continue;for(let t of e.matchAll(/\$\{\{\s*secrets\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g))t[1]&&t[1]!==`GITHUB_TOKEN`&&r.variable(MT,3,t[1],o,{secret:!0});let t=(0,uw.parseAllDocuments)(e).map(e=>e.toJS());for(let e of t)fE(r,o,e);tE(r,o,e)}else if(/^cloudbuild\.ya?ml$/.test(a)){let e=await s();if(e===null)continue;for(let t of(0,uw.parseAllDocuments)(e).map(e=>e.toJS()))lE(r,o,(Z(t)&&Array.isArray(t.steps)?t.steps:[]).flatMap(e=>Z(e)&&Array.isArray(e.args)?[`${e.entrypoint===`gcloud`||/cloud-sdk/.test(String(e.name))?`gcloud `:``}${e.args.join(` `)}`]:[]).join(`
376
- `));lE(r,o,e)}else if(vT(o)||/\.(sh|bash)$/.test(a)||/^(Makefile|justfile|Taskfile\.ya?ml)$/i.test(a)||a===`package.json`&&!o.includes(`/node_modules/`)){let e=await s();if(e===null)continue;/\.ya?ml$/i.test(a)?tE(r,o,e):lE(r,o,$T(e,QT(e)))}else if(a.endsWith(`.tf`)){let e=await s();e!==null&&dE(r,o,e)}else if(a===`.firebaserc`){let e=await s();if(e===null)continue;try{let t=JSON.parse(e);if(Z(t.projects))for(let e of Object.values(t.projects))typeof e==`string`&&r.usedIn(`Firebase`,XT(e))}catch{}}else if(a===`vercel.json`){let e=await s();if(e===null)continue;r.add(IT,{kind:`deployment`,name:i(o),sourcePath:o,links:[{relation:`runs`,to:`repo:.`}]});try{let t=JSON.parse(e);for(let e of Array.isArray(t.crons)?t.crons:[])Z(e)&&typeof e.path==`string`&&typeof e.schedule==`string`&&r.add(LT,{kind:`job`,name:e.path,sourcePath:o,schedule:e.schedule,...GT(e.schedule)?{scheduleText:GT(e.schedule)}:{},timeZone:`UTC`,links:[{relation:`calls`,to:`endpoint:GET ${e.path.split(`?`)[0]}`}]})}catch{}}else if(a===`netlify.toml`){let e=await s();if(e===null)continue;r.add(RT,{kind:`deployment`,name:i(o),sourcePath:o,...mE(e,`publish`)?{path:mE(e,`publish`)}:{},links:[{relation:`runs`,to:`repo:.`}]});for(let t of e.matchAll(/\[functions\.["']?([\w-]+)["']?\]([^[]*)/g)){let e=mE(t[2]??``,`schedule`);e&&r.add(zT,{kind:`job`,name:t[1]??``,sourcePath:o,schedule:e,...GT(e)?{scheduleText:GT(e)}:{},timeZone:`UTC`,runs:`Netlify function ${t[1]}`})}}else if(a===`fly.toml`){let e=await s();if(e===null)continue;let t=mE(e,`app`);t&&r.add(BT,{kind:`deployment`,name:t,sourcePath:o,...mE(e,`primary_region`)?{region:mE(e,`primary_region`)}:{},links:[{relation:`runs`,to:`repo:.`}]})}else if(/^serverless\.ya?ml$/.test(a)){let e=await s();if(e===null)continue;let t=(0,uw.parseAllDocuments)(e)[0]?.toJS();if(!Z(t)||!Z(t.functions))continue;let i=typeof t.service==`string`?t.service:n,a=Z(t.provider)&&typeof t.provider.region==`string`?t.provider.region:void 0;for(let[e,n]of Object.entries(t.functions)){let t=`${i}-${e}`;r.add(VT,{kind:`deployment`,name:t,sourcePath:o,...a?{region:a}:{},links:[{relation:`runs`,to:`repo:.`}]});let s=Z(n)&&Array.isArray(n.events)?n.events:[];for(let e of s){let n=Z(e)?e.schedule:void 0,i=typeof n==`string`?n:Z(n)&&typeof n.rate==`string`?n.rate:void 0;i&&r.add(HT,{kind:`job`,name:`${t} schedule`,sourcePath:o,schedule:i,runs:`AWS Lambda ${t}`})}}}else if(/\.ya?ml$/.test(a)){let e=await s();if(e===null||!/\bkind:\s*(CronJob|Service|Deployment)\b/.test(e))continue;try{pE(r,o,(0,uw.parseAllDocuments)(e).map(e=>e.toJS()))}catch{}}}let a=new Set(t.map(e=>e.provider)),o=a.has(cT.provider)&&!a.has(sT.provider)?cT:sT,s=/* @__PURE__ */ new Map;for(let t of e.files){if(!iE.test(t.path)||aE.test(t.path)||t.size>3e5)continue;let n=await e.readText(t);if(n!==null)for(let e of n.matchAll(rE)){let n=(e[1]??``).replace(/[.-]+$/,``),r=n.startsWith(`claude-`)?Yw:n.startsWith(`gemini-`)?o:Jw,i=s.get(n)??{kind:r,paths:[]};i.paths.includes(t.path)||i.paths.push(t.path),s.set(n,i)}}for(let[e,{kind:t,paths:n}]of s)r.add(t,{kind:`model`,name:e,sourcePath:n[0]??``,modelId:e,calledFrom:n.slice(0,5)});let c=[...r.resources.values()].map(e=>{let t=r.contracts.filter(t=>t.resource===e.provider);return t.length>0&&t.every(e=>typeof e.project==`string`)?{...e,perProject:!0}:e});return{contracts:r.contracts,resources:c,projects:r.projects}}const gE={ts:`TypeScript`,tsx:`TypeScript`,mts:`TypeScript`,cts:`TypeScript`,js:`JavaScript`,jsx:`JavaScript`,mjs:`JavaScript`,cjs:`JavaScript`,py:`Python`,go:`Go`,rb:`Ruby`,php:`PHP`,java:`Java`,kt:`Kotlin`,kts:`Kotlin`,swift:`Swift`,rs:`Rust`,cs:`C#`,fs:`F#`,c:`C`,h:`C`,cc:`C++`,cpp:`C++`,cxx:`C++`,hpp:`C++`,m:`Objective-C`,mm:`Objective-C++`,scala:`Scala`,dart:`Dart`,ex:`Elixir`,exs:`Elixir`,erl:`Erlang`,clj:`Clojure`,hs:`Haskell`,ml:`OCaml`,lua:`Lua`,r:`R`,pl:`Perl`,groovy:`Groovy`,zig:`Zig`,sol:`Solidity`,sql:`SQL`,sh:`Shell`,bash:`Shell`,zsh:`Shell`,ps1:`PowerShell`,tf:`HCL`,vue:`Vue`,svelte:`Svelte`,astro:`Astro`,html:`HTML`,css:`CSS`,scss:`SCSS`,sass:`SCSS`,less:`Less`};function _E(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=n.path.lastIndexOf(`.`);if(e===-1||e<n.path.lastIndexOf(`/`))continue;let r=gE[n.path.slice(e+1).toLowerCase()];r&&t.set(r,(t.get(r)??0)+1)}return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,5).map(([e])=>e)}const vE=/* @__PURE__ */ new Set([`auth`,`storage`,`realtime`,`_realtime`,`extensions`,`graphql`,`graphql_public`,`supabase_functions`,`supabase_migrations`,`pgsodium`,`pgsodium_masks`,`vault`,`net`,`cron`,`pgbouncer`,`pg_catalog`,`information_schema`]),yE=/^(not|null|default|primary|unique|references|check|constraint|generated|collate|deferrable|initially|identity)$/i;function bE(e){if(!/\.sql$/i.test(e))return!1;let t=e.toLowerCase();return/(^|\/)migrations\//.test(t)||/(^|\/)db\/migrate\//.test(t)}const xE=e=>e.slice(0,e.lastIndexOf(`/`)+1),SE=[[`postgres`,/\b(?:bigserial|serial|jsonb|timestamptz|bytea|tsvector|plpgsql|gen_random_uuid|uuid_generate_v4|create\s+extension|create\s+policy|enable\s+row\s+level\s+security)\b|\$\$|::[a-z_]+/gi],[`mysql`,/\bauto_increment\b|\bengine\s*=|\bunsigned\b|`[^`\n]+`/gi],[`sqlite`,/\bautoincrement\b|\bwithout\s+rowid\b|\bpragma\b/gi]];function CE(e){let t=null,n=0;for(let[r,i]of SE){let a=e.match(i)?.length??0;a>n&&(t=r,n=a)}return t}function wE(e,t){let n=e.toLowerCase();if(!n.endsWith(`.sql`)||bE(e))return!1;let r=n.slice(n.lastIndexOf(`/`)+1);return/seed|fixture|sample|test|demo/.test(r)?!1:/schema|structure/.test(r)||t.has(xE(n))||/(^|\/)docker-entrypoint-initdb\.d\//.test(n)}async function TE(e){let t=/* @__PURE__ */ new Map,n=EE(),r=e.files.filter(e=>bE(e.path)),i=new Set(r.flatMap(e=>{let t=/^(.*\/)?(migrations|db\/migrate)\//.exec(e.path.toLowerCase());return t?[t[1]??``]:[]})),a=e.files.filter(e=>wE(e.path,i)).sort((e,t)=>e.path<t.path?-1:1);r.sort((e,t)=>{let n=e.path.slice(e.path.lastIndexOf(`/`)+1),r=t.path.slice(t.path.lastIndexOf(`/`)+1);return n<r?-1:n>r?1:e.path<t.path?-1:1});let o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let i of[...a,...r]){let r=await e.readText(i);if(r===null)continue;let a=CE(r);a&&(o.set(i.path,a),s.set(a,(s.get(a)??0)+1));for(let a of NE(r))try{VE(a,i.path,t,e.warnings),jE(a,i.path,n)}catch(t){e.warnings.push(`${i.path}: could not read statement "${ZE(a)}" (${Mx(t)})`)}}let c=[...s.entries()].sort((e,t)=>t[1]-e[1])[0]?.[0]??null,l=e=>o.get(e)??c;return{tables:[...t.values()].filter(e=>!vE.has(e.schema)).map(e=>{let t=e.schema===`public`?e.table:`${e.schema}.${e.table}`;return{kind:`table`,name:t,sourcePath:e.sourcePath,table:t,columns:e.columns,dialect:l(e.sourcePath)}}),objects:ME(n,l)}}const EE=()=>({functions:/* @__PURE__ */ new Map,roleEnums:/* @__PURE__ */ new Map,cronJobs:/* @__PURE__ */ new Map});function DE(e){let{schema:t,table:n}=zE(e);return{schema:t,name:t===`public`?n:`${t}.${n}`}}function OE(e,t){let n=0;for(let r=t;r<e.length;r++){let i=e[r];if(i===`(`)n++;else if(i===`)`&&(n--,n===0))return[e.slice(t+1,r),e.slice(r+1)]}return null}const kE=e=>e.replace(/\s+/g,` `).trim(),AE=()=>String.raw`((?:${LE}\s*(?:\([^)]*\))?\s*,?\s*)+)`;function jE(e,t,n){let r=/^create\s+(?:or\s+replace\s+)?function\s+/i.exec(e);if(r){let i=e.indexOf(`(`,r[0].length),a=i>0?OE(e,i):null;if(!a)return;let{schema:o,name:s}=DE(e.slice(r[0].length,i));if(vE.has(o))return;let c=/^\s*returns\s+(setof\s+\S+|table\s*\([\s\S]*?\)(?=\s)|[\w."[\] ]+?)\s+(?:language|as|security|set|stable|immutable|volatile|strict|parallel|cost|leakproof|called|begin)\b/i.exec(a[1])?.[1];if(!c||/^(event_)?trigger$/i.test(c.trim())){n.functions.delete(s);return}let l=n.functions.get(s);n.functions.set(s,{name:s,sourcePath:t,arguments:`(${kE(a[0]).slice(0,300)})`,returns:kE(c),definer:/\bsecurity\s+definer\b/i.test(a[1].split(/\$\w*\$/)[0]??``),callers:l?.callers??/* @__PURE__ */ new Set});return}let i=new RegExp(String.raw`^drop\s+function\s+(?:if\s+exists\s+)?${AE()}`,`i`).exec(e);if(i?.[1]){for(let e of i[1].split(/,(?![^(]*\))/))n.functions.delete(DE(e.replace(/\(.*$/s,``)).name);return}let a=new RegExp(String.raw`^(grant|revoke)\s+execute\s+on\s+function\s+${AE()}\s+(?:to|from)\s+(.+)$`,`is`).exec(e);if(a?.[1]&&a[2]&&a[a.length-1]){let e=(a[a.length-1]??``).split(`,`).map(e=>e.trim().toLowerCase()).filter(e=>e&&e!==`public`);for(let t of a[2].split(/,(?![^(]*\))/)){let r=n.functions.get(DE(t.replace(/\(.*$/s,``)).name);if(r)for(let t of e)a[1].toLowerCase()===`grant`?r.callers.add(t):r.callers.delete(t)}return}let o=new RegExp(String.raw`^create\s+type\s+${LE}\s+as\s+enum\s*\(([^)]*)\)`,`i`).exec(e);if(o?.[1]&&/role/i.test(o[1])){n.roleEnums.set(zE(o[1]).table,{values:[...(o[2]??``).matchAll(/'((?:[^']|'')*)'/g)].map(e=>(e[1]??``).replace(/''/g,`'`)),sourcePath:t});return}let s=new RegExp(String.raw`^alter\s+type\s+${LE}\s+add\s+value\s+(?:if\s+not\s+exists\s+)?'((?:[^']|'')*)'`,`i`).exec(e);if(s?.[1]){let e=n.roleEnums.get(zE(s[1]).table),t=(s[2]??``).replace(/''/g,`'`);e&&!e.values.includes(t)&&e.values.push(t)}else{for(let r of e.matchAll(/cron\.schedule\s*\(\s*'([^']*)'\s*,\s*(?:'([^']*)'\s*,\s*)?(\$\w*\$[\s\S]*?\$\w*\$|'(?:[^']|'')*')/gi)){let[e,i]=r[2]===void 0?[null,r[1]]:[r[1],r[2]];if(!i)continue;let a=/select\s+([\w."]+)\s*\(/i.exec(r[3]??``)?.[1]??null;n.cronJobs.set(e??`pg_cron ${i}`,{schedule:i,sourcePath:t,calls:a?DE(a).name:null})}for(let t of e.matchAll(/cron\.unschedule\s*\(\s*'([^']*)'/gi))n.cronJobs.delete(t[1]??``)}}function ME(e,t){let n=[];for(let r of e.functions.values()){let e=[...r.callers].sort();n.push({kind:`function`,name:r.name,sourcePath:r.sourcePath,dialect:t(r.sourcePath),arguments:r.arguments,returns:r.returns,access:(e.length?`Callable by ${e.join(`, `)}`:`Not granted to any app role`)+(r.definer?`; runs with its owner's rights`:``)})}let r=/* @__PURE__ */ new Map;for(let t of e.roleEnums.values())for(let e of t.values)r.set(e,(r.get(e)??0)+1);for(let[i,a]of e.roleEnums)for(let e of a.values)n.push({kind:`role`,name:(r.get(e)??0)>1?`${e} (${i})`:e,sourcePath:a.sourcePath,dialect:t(a.sourcePath),definedIn:i});for(let[t,r]of e.cronJobs)n.push({kind:`job`,name:t,sourcePath:r.sourcePath,resource:`pg_cron`,schedule:r.schedule,...r.calls?{links:[{relation:`calls`,to:`function:${r.calls}`}]}:{}});return n}function NE(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r],a=e[r+1];if(i===`-`&&a===`-`){let t=e.indexOf(`
377
- `,r);r=t===-1?e.length:t,n+=` `}else if(i===`/`&&a===`*`){let t=1;for(r+=2;r<e.length&&t>0;)e.startsWith(`/*`,r)?(t++,r+=2):e.startsWith(`*/`,r)?(t--,r+=2):r++;n+=` `}else if(i===`'`||i===`"`){let t=r+1;for(;t<e.length;)if(e[t]===i){if(e[t+1]===i)t+=2;else break}else t++;n+=e.slice(r,t+1),r=t+1}else{if(i===`$`){let t=/^\$[A-Za-z_]?[A-Za-z0-9_]*\$/.exec(e.slice(r,r+64))?.[0];if(t){let i=e.indexOf(t,r+t.length),a=i===-1?e.length:i+t.length;n+=e.slice(r,a),r=a;continue}}i===`;`?(n.trim()&&t.push(n.trim()),n=``,r++):(n+=i,r++)}}return n.trim()&&t.push(n.trim()),t.map(e=>e.replace(/\s+/g,` `))}function PE(e){let t=[],n=0,r=null,i=0;for(let a=0;a<e.length;a++){let o=e[a];r?o===r&&(r=null):o===`'`||o===`"`?r=o:o===`(`?n++:o===`)`?n--:o===`,`&&n===0&&(t.push(e.slice(i,a).trim()),i=a+1)}return t.push(e.slice(i).trim()),t.filter(Boolean)}function FE(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n++;continue}if(r===`(`){let r=0,i=n,a=null;for(;i<e.length;i++){let t=e[i];if(a)t===a&&(a=null);else if(t===`'`||t===`"`)a=t;else if(t===`(`)r++;else if(t===`)`&&--r===0)break}t.push(e.slice(n,i+1)),n=i+1;continue}let i=n,a=null;for(;i<e.length;i++){let t=e[i];if(a)t===a&&(a=null);else if(t===`'`||t===`"`)a=t;else if(/\s/.test(t)||t===`(`)break}t.push(e.slice(n,i)),n=i}return t}const IE=String.raw`(?:"(?:[^"]|"")+"|[A-Za-z_][\w$]*)`,LE=String.raw`(${IE}(?:\s*\.\s*${IE})?)`;function RE(e){let t=e.trim();return t.startsWith(`"`)?t.slice(1,-1).replace(/""/g,`"`):t.toLowerCase()}function zE(e){let t=e.match(new RegExp(IE,`g`))??[e];return t.length>=2?{schema:RE(t[0]??``),table:RE(t[1]??``)}:{schema:`public`,table:RE(t[0]??e)}}function BE(e,t){return`${e}.${t}`}function VE(e,t,n,r){if(/^create\s+(?:(?:global|local)\s+)?(?:temp(?:orary)?\s+|unlogged\s+)?table\b/i.test(e)){HE(e,t,n,r);return}let i=new RegExp(String.raw`^alter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?${LE}\s+(.+)$`,`i`).exec(e);if(i?.[1]&&i[2]){YE(zE(i[1]),i[2],t,n,r);return}let a=/^drop\s+table\s+(?:if\s+exists\s+)?(.+?)(?:\s+(?:cascade|restrict))?$/i.exec(e);if(a?.[1])for(let e of PE(a[1])){let{schema:t,table:r}=zE(e);n.delete(BE(t,r))}}function HE(e,t,n,r){let i=new RegExp(String.raw`^create\s+(?:(?:global|local)\s+)?(?:temp(?:orary)?\s+|unlogged\s+)?table\s+(?:if\s+not\s+exists\s+)?${LE}\s*\(`,`i`).exec(e);if(!i?.[1]){r.push(`${t}: skipped a create table statement it couldn't read: "${ZE(e)}"`);return}let{schema:a,table:o}=zE(i[1]),s=i[0].length-1,c=UE(e,s);if(c===-1){r.push(`${t}: unbalanced parentheses in create table ${o}`);return}let l=BE(a,o);if(n.has(l)&&/\bif\s+not\s+exists\b/i.test(e.slice(0,s)))return;let u={schema:a,table:o,sourcePath:t,columns:[]};for(let i of PE(e.slice(s+1,c))){if(/^(constraint|primary\s+key|unique|foreign\s+key|check|exclude|like)\b/i.test(i)){JE(u,i,n);continue}let e=WE(i,n);e?u.columns.push(e):r.push(`${t}: skipped column definition "${ZE(i)}" in ${o}`)}n.set(l,u)}function UE(e,t){let n=0,r=null;for(let i=t;i<e.length;i++){let t=e[i];if(r)t===r&&(r=null);else if(t===`'`||t===`"`)r=t;else if(t===`(`)n++;else if(t===`)`&&--n===0)return i}return-1}function WE(e,t){let n=FE(e),r=n[0];if(!r||n.length<2)return null;let i=1,a=[];for(;i<n.length&&!yE.test(n[i]??``);)a.push(n[i]),i++;if(a.length===0)return null;let o={name:RE(r),type:a.join(` `).replace(/\s+\(/g,`(`).toLowerCase(),required:!1};return GE(o,n.slice(i),t),o}function GE(e,t,n){for(let r=0;r<t.length;r++){let i=t[r]?.toLowerCase(),a=t[r+1]?.toLowerCase();if(i===`not`&&a===`null`)e.required=!0,r++;else if(i===`primary`&&a===`key`)e.primaryKey=!0,e.required=!0,r++;else if(i===`unique`)e.unique=!0;else if(i==="default"){let n=[];for(;r+1<t.length&&!yE.test(t[r+1]??``);)n.push(t[r+1]),r++;n.length>0&&(e.default=KE(n))}else if(i===`references`){let i=t[r+1];if(!i)continue;let a=t[r+2]?.startsWith(`(`)?t[r+2]:void 0;e.references=qE(i,a,n),r+=a?2:1}}}function KE(e){return e.join(` `).replace(/\s+\(/g,`(`)}function qE(e,t,n){let{schema:r,table:i}=zE(e),a=r===`public`?i:`${r}.${i}`,o=t?RE(t.slice(1,-1).split(`,`)[0]??``):null;return o||=n.get(BE(r,i))?.columns.find(e=>e.primaryKey)?.name??`id`,`${a}.${o}`}function JE(e,t,n){let r=t.replace(new RegExp(String.raw`^constraint\s+${IE}\s+`,`i`),``),i=e=>(e??``).split(`,`).map(e=>RE(e)).filter(Boolean),a=/^primary\s+key\s*\(([^)]*)\)/i.exec(r);if(a){for(let t of i(a[1])){let n=e.columns.find(e=>e.name===t);n&&(n.primaryKey=!0,n.required=!0)}return}let o=/^unique\s*(?:nulls\s+(?:not\s+)?distinct\s*)?\(([^)]*)\)/i.exec(r);if(o){let t=i(o[1]),n=t.length===1?e.columns.find(e=>e.name===t[0]):void 0;n&&(n.unique=!0);return}let s=new RegExp(String.raw`^foreign\s+key\s*\(([^)]*)\)\s*references\s+${LE}\s*(\([^)]*\))?`,`i`).exec(r);if(s?.[2]){let t=i(s[1]),r=s[3]?i(s[3].slice(1,-1)):[];t.forEach((t,i)=>{let a=e.columns.find(e=>e.name===t);if(!a)return;let o=r[i];a.references=qE(s[2],o?`(${o})`:void 0,n)})}}function YE(e,t,n,r,i){let a=r.get(BE(e.schema,e.table));if(!a){!vE.has(e.schema)&&/\b(add|drop|alter|rename)\s+column\b/i.test(t)&&i.push(`${n}: alter table ${e.table} before any create table for it, skipped`);return}let o=new RegExp(String.raw`^rename\s+to\s+(${IE})$`,`i`).exec(t);if(o?.[1]){r.delete(BE(a.schema,a.table)),a.table=RE(o[1]),r.set(BE(a.schema,a.table),a);return}let s=new RegExp(String.raw`^rename\s+(?:column\s+)?(${IE})\s+to\s+(${IE})$`,`i`).exec(t);if(s?.[1]&&s[2]){let e=a.columns.find(e=>e.name===RE(s[1]));e&&(e.name=RE(s[2]))}else for(let e of PE(t)){let t=/^add\s+(?:column\s+)?(?:if\s+not\s+exists\s+)?(.+)$/i.exec(e);if(t?.[1]&&!/^add\s+(constraint|primary|unique|foreign|check|exclude)\b/i.test(e)){let o=WE(t[1],r);if(!o){i.push(`${n}: skipped "${ZE(e)}" on ${a.table}`);continue}a.columns.some(e=>e.name===o.name)||a.columns.push(o);continue}let o=/^add\s+(.+)$/i.exec(e);if(o?.[1]){JE(a,o[1],r);continue}let s=new RegExp(String.raw`^drop\s+(?:column\s+)?(?:if\s+exists\s+)?(${IE})`,`i`).exec(e);if(s?.[1]&&!/^drop\s+constraint\b/i.test(e)){let e=RE(s[1]);a.columns=a.columns.filter(t=>t.name!==e);continue}let c=new RegExp(String.raw`^alter\s+(?:column\s+)?(${IE})\s+(.+)$`,`i`).exec(e);if(c?.[1]&&c[2]){let e=a.columns.find(e=>e.name===RE(c[1]));e&&XE(e,c[2])}}}function XE(e,t){if(/^set\s+not\s+null$/i.test(t))e.required=!0;else if(/^drop\s+not\s+null$/i.test(t))e.required=!!e.primaryKey;else if(/^drop\s+default$/i.test(t))delete e.default;else{let n=/^set\s+default\s+(.+)$/i.exec(t);if(n?.[1]){e.default=KE(FE(n[1]));return}let r=/^(?:set\s+data\s+)?type\s+(.+?)(?:\s+(?:using|collate)\s+.*)?$/i.exec(t);r?.[1]&&(e.type=r[1].replace(/\s+\(/g,`(`).toLowerCase())}}function ZE(e){return e.length>60?`${e.slice(0,57)}...`:e}const QE=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`],$E=/^(openapi|swagger)([.-][\w.-]*)?\.(json|ya?ml)$/i,eD=/\.(json|ya?ml)$/i;async function tD(e){let t=[];for(let n of e.files){let r=$E.test(kx(n.path));if(!r&&!eD.test(n.path)||!r&&(n.size>1048576||/(^|\/)[^/]*lock[^/]*$/i.test(n.path)))continue;let i=await e.readText(n,r?10485760:void 0);if(i===null||!r&&!/^\s*["']?(openapi|swagger)["']?\s*:/m.test(i))continue;let a;try{a=/\.json$/i.test(n.path)?JSON.parse(i):(0,uw.parse)(i)}catch(t){e.warnings.push(`${n.path}: OpenAPI file could not be parsed (${Mx(t)})`);continue}!Z(a)||typeof a.openapi!=`string`&&typeof a.swagger!=`string`?r&&e.warnings.push(`${n.path}: no top-level openapi or swagger version, skipped`):t.push(...nD(a,n.path,e.warnings))}return t}function nD(e,t,n){let r=typeof e.swagger==`string`,i=new rD(e,t,n),a=r?e.securityDefinitions:aD(e.components)?.securitySchemes,o=Z(a)?a:{},s=Z(e.paths)?e.paths:{},c=[];for(let[n,a]of Object.entries(s)){let s=i.resolve(a);if(s)for(let a of QE){let l=aD(s[a.toLowerCase()]);if(!l)continue;let u=[...Array.isArray(s.parameters)?s.parameters:[],...Array.isArray(l.parameters)?l.parameters:[]],d=l.security??e.security;c.push({kind:`endpoint`,name:Nx(l.summary)?.trim()||Nx(l.operationId)||`${a} ${n}`,sourcePath:t,method:a,path:n,auth:yD(d,o,i),request:r?uD(u,l,e,i):sD(l.requestBody,i),responses:dD(l,e,r,i)})}}return c}var rD=class{#e;#t;#n;#r=/* @__PURE__ */ new Set;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}resolve(e){let t=e;for(let e=0;e<8;e++){if(!Z(t))return null;let e=t.$ref;if(typeof e!=`string`)return t;t=this.#i(e)}return null}refName(e){if(!Z(e)||typeof e.$ref!=`string`)return null;let t=e.$ref.slice(e.$ref.lastIndexOf(`/`)+1);return t?iD(t):null}#i(e){if(!e.startsWith(`#/`))return this.#r.has(e)||(this.#r.add(e),this.#n.push(`${this.#t}: external $ref "${e}" not followed`)),null;let t=this.#e;for(let n of e.slice(2).split(`/`)){if(!Z(t))break;t=t[iD(n)]}return t===void 0&&!this.#r.has(e)&&(this.#r.add(e),this.#n.push(`${this.#t}: $ref "${e}" points at nothing`)),t}};function iD(e){return decodeURIComponent(e).replace(/~1/g,`/`).replace(/~0/g,`~`)}function aD(e){return Z(e)?e:null}function oD(e){if(!Z(e))return null;let t=Object.entries(e).filter(e=>Z(e[1]));return t.find(([e])=>e===`application/json`)??t.find(([e])=>/json/.test(e))??t[0]??null}function sD(e,t){let n=t.resolve(e),r=n?oD(n.content):null;return r?cD(r[0],r[1],t):null}function cD(e,t,n){let r=t.schema;return{contentType:e,fields:hD(r,n),example:lD(t,n)??vD(r,n,0)}}function lD(e,t){if(e.example!==void 0)return e.example;if(Z(e.examples)){let n=t.resolve(Object.values(e.examples)[0]);if(n&&n.value!==void 0)return n.value}}function uD(e,t,n,r){let i=e.map(e=>r.resolve(e)).filter(e=>e!==null),a=pD(t.consumes)??pD(n.consumes),o=i.find(e=>e.in===`body`);if(o)return{contentType:a??`application/json`,fields:hD(o.schema,r),example:vD(o.schema,r,0)};let s=i.filter(e=>e.in===`formData`);if(s.length===0)return null;let c=s.map(e=>({name:Nx(e.name)??``,type:_D(e,r),required:e.required===!0,...gD(e)}));return{contentType:a??`application/x-www-form-urlencoded`,fields:c,example:Object.fromEntries(s.map(e=>[Nx(e.name)??``,vD(e,r,1)]))}}function dD(e,t,n,r){if(!Z(e.responses))return[];let i=pD(e.produces)??pD(t.produces)??`application/json`,a=[];for(let[t,o]of Object.entries(e.responses)){let e=r.resolve(o);if(!e)continue;let s=null;if(n){if(e.schema!==void 0){let t=aD(e.examples);s={contentType:i,fields:hD(e.schema,r),example:t?.[i]??vD(e.schema,r,0)}}}else{let t=oD(e.content);t&&(s=cD(t[0],t[1],r))}a.push({status:fD(t),description:Nx(e.description)??``,body:s})}return a}function fD(e){let t=e.replace(/x/gi,`0`),n=Number.parseInt(t,10);return Number.isNaN(n)?0:n}function pD(e){return Array.isArray(e)&&typeof e[0]==`string`?e[0]:void 0}function mD(e,t,n=0){let r=t.resolve(e);if(!r||n>8)return r;if(Array.isArray(r.allOf)){let e={},i=[];for(let a of r.allOf){let r=mD(a,t,n+1);r&&(Z(r.properties)&&Object.assign(e,r.properties),Array.isArray(r.required)&&i.push(...r.required.filter(e=>typeof e==`string`)))}return Z(r.properties)&&Object.assign(e,r.properties),Array.isArray(r.required)&&i.push(...r.required.filter(e=>typeof e==`string`)),{...r,type:`object`,properties:e,required:i}}let i=Array.isArray(r.oneOf)?r.oneOf:Array.isArray(r.anyOf)?r.anyOf:null;return i&&i.length>0&&!r.properties?mD(i[0],t,n+1):r}function hD(e,t){let n=mD(e,t);if(n?.type===`array`&&(n=mD(n.items,t)),!n||!Z(n.properties))return[];let r=new Set(Array.isArray(n.required)?n.required:[]);return Object.entries(n.properties).map(([e,n])=>{let i=mD(n,t)??{};return{name:e,type:_D(n,t),required:r.has(e),...gD(i)}})}function gD(e){let t={},n=Nx(e.description)?.trim();return n&&(t.description=n),Array.isArray(e.enum)&&(t.values=e.enum.map(e=>String(e))),t}function _D(e,t,n=0){let r=t.refName(e),i=mD(e,t);if(!i)return r??`unknown`;let a=Array.isArray(i.type)?i.type.filter(e=>e!==`null`).join(` | `):Nx(i.type);return a===`array`?n>8?`array`:`${_D(i.items,t,n+1)}[]`:r&&(a===`object`||a===void 0)?r:Nx(i.format)??a??(i.properties?`object`:`unknown`)}function vD(e,t,n){let r=mD(e,t);if(!r||n>8)return null;if(r.example!==void 0)return r.example;if(Array.isArray(r.enum)&&r.enum.length>0)return r.enum[0];let i=Array.isArray(r.type)?r.type.find(e=>e!==`null`):r.type;if(i===`object`||i===void 0&&Z(r.properties)){let e=Z(r.properties)?r.properties:{};return Object.fromEntries(Object.entries(e).map(([e,r])=>[e,vD(r,t,n+1)]))}switch(i){case`array`:return[vD(r.items,t,n+1)];case`string`:return`string`;case`integer`:case`number`:return 0;case`boolean`:return!1;default:return null}}function yD(e,t,n){if(!Array.isArray(e)||e.length===0)return null;let r=[];for(let i of e){if(!Z(i))continue;let e=Object.keys(i);e.length===0?r.push(`none`):r.push(e.map(e=>bD(e,n.resolve(t[e]))).join(` + `))}let i=[...new Set(r)];return i.length===0||i.length===1&&i[0]===`none`?null:i.map(e=>e===`none`?`no auth`:e).join(` or `)}function bD(e,t){if(!t)return e;switch(Nx(t.type)?.toLowerCase()){case`http`:{let e=Nx(t.scheme)?.toLowerCase();if(e===`bearer`){let e=Nx(t.bearerFormat);return e?`Bearer token (${e})`:`Bearer token`}return e===`basic`?`Basic auth`:`HTTP ${e??`auth`}`}case`basic`:return`Basic auth`;case`apikey`:return`apikey ${Nx(t.in)??`header`} ${Nx(t.name)??e}`;case`oauth2`:return`OAuth2`;case`openidconnect`:return`OpenID Connect`;case`mutualtls`:return`Mutual TLS`;default:return e}}const xD=[`readme.md`,`readme.mdx`,`readme.markdown`,`readme.txt`,`readme`];async function SD(e){let t=e.files.find(e=>!e.path.includes(`/`)&&xD.includes(e.path.toLowerCase()));if(!t)return null;let n=await e.readText(t);return{path:t.path,oneLiner:n===null?null:CD(n)}}function CD(e){let t=e.replace(/\r\n/g,`
374
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),pw=/* @__PURE__ */ E((e=>{var t=aw(),n=HC(),r=UC(),i=pC(),a=$(),o=dw(),s=fw();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),mw=(/* @__PURE__ */ E((e=>{var t=aw(),n=HC(),r=BC(),i=UC(),a=iC(),o=$(),s=gC(),c=aC(),l=vC(),u=bC();lw();var d=uw(),f=dw(),p=fw(),m=pw(),h=QS();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync})))();function hw(e,t){let n=(0,mw.parse)(e,{uniqueKeys:!1});if(!Z(n))throw Error(`not a YAML mapping`);let r=new KS(`npm`,t),i=Z(n.importers)?n.importers:{".":n};for(let e of Object.values(i))if(Z(e))for(let t of[`dependencies`,`devDependencies`,`optionalDependencies`]){let n=e[t];if(Z(n))for(let[e,t]of Object.entries(n)){let n=Z(t)?t.version:t;if(typeof n!=`string`||gw(n))continue;let i=vw(n);i?r.add(i.name,i.version,!0):r.add(e,_w(n),!0)}}for(let e of[`packages`,`snapshots`]){let t=n[e];if(Z(t))for(let e of Object.keys(t)){let t=vw(e);t&&!gw(t.version)&&r.add(t.name,t.version,!1)}}return r.rows()}function gw(e){return/^(link|file|workspace):/.test(e)}function _w(e){return e.replace(/\(.*$/,``).replace(/_(?=[^/]*@).*$/,``)}function vw(e){let t=e.replace(/^\//,``).replace(/\(.*$/,``),n=t.indexOf(`@`,1);if(n>0)return{name:t.slice(0,n),version:_w(t.slice(n+1))};if(!e.startsWith(`/`))return null;let r=t.lastIndexOf(`/`);return r<=0?null:{name:t.slice(0,r),version:_w(t.slice(r+1))}}function yw(e,t){let n=YS(e);if(!Z(n))throw Error(`not a JSON object`);let r=new KS(`npm`,t);if(Z(n.packages)){let e=/* @__PURE__ */ new Set;for(let[t,r]of Object.entries(n.packages))if(!t.includes(`node_modules/`))for(let t of JS(r))e.add(t);for(let[t,i]of Object.entries(n.packages)){let n=t.lastIndexOf(`node_modules/`);if(n===-1||!Z(i)||i.link===!0)continue;let a=t.slice(n+13),o=typeof i.name==`string`?i.name:a;if(typeof i.version!=`string`)continue;let s=t===`node_modules/${a}`;r.add(o,i.version,s&&e.has(a))}return r.rows()}if(Z(n.dependencies)){let e=(t,n)=>{for(let[i,a]of Object.entries(t)){if(!Z(a))continue;let t=a.version;typeof t==`string`&&!gw(t)&&r.add(i,t,n===0&&a.dev!==!0),Z(a.dependencies)&&e(a.dependencies,n+1)}};e(n.dependencies,0)}return r.rows()}function bw(e,t,n){let r=new KS(`npm`,t),i=[],a=!1;for(let t of e.split(/\r?\n/)){if(t===``||t.startsWith(`#`))continue;if(!/^\s/.test(t)&&t.endsWith(`:`)){let e=t.slice(0,-1).split(`,`).map(e=>e.trim().replace(/^"|"$/g,``));a=e.some(e=>/@(workspace|link|file|portal):/.test(e)),i=[...new Set(e.map(xw).filter(e=>e!==null))];continue}let e=/^\s+version:?\s+"?([^"\s]+)"?/.exec(t)?.[1];if(e&&!a){for(let t of i)r.add(t,e,n.has(t));i=[]}}return r.rows()}function xw(e){if(e===`__metadata`)return null;let t=e.indexOf(`@`,1);return t>0?e.slice(0,t):null}async function Sw(e,t){let n=jx(t),r=/* @__PURE__ */ new Set,i=await Cw(e,Mx(n,`package.json`));for(let e of JS(i))r.add(e);if(!Z(i))return r;let a=i.workspaces,o=(Array.isArray(a)?a:Z(a)&&Array.isArray(a.packages)?a.packages:[]).filter(e=>typeof e==`string`).map(e=>ww(Mx(n,e.replace(/^\.\//,``).replace(/\/$/,``))));if(o.length===0)return r;for(let t of e.files){if(!t.path.endsWith(`package.json`))continue;let n=jx(t.path);if(o.some(e=>e.test(n)))for(let n of JS(await Cw(e,t.path)))r.add(n)}return r}async function Cw(e,t){let n=e.file(t);if(!n)return null;let r=await e.readText(n);if(r===null)return null;try{return YS(r)}catch{return e.warnings.push(`${t}: not valid JSON, skipped`),null}}function ww(e){let t=e.split(`/`).map(e=>e===`**`?`.*`:e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*/g,`[^/]*`)).join(`/`);return RegExp(`^${t}$`)}function Tw(e){return e.toLowerCase().replace(/[-_.]+/g,`-`)}function Ew(e,t,n){let r=new KS(`pip`,t),i=!1,a=null,o=null,s=!1,c=()=>{a&&o&&!s&&r.add(a,o,n.has(Tw(a))),a=null,o=null,s=!1};for(let t of e.split(/\r?\n/)){if(/^\s*\[{1,2}([^\]]+)\]{1,2}\s*$/.exec(t)){t.trim()===`[[package]]`?(c(),i=!0):i=!1;continue}if(!i)continue;let e=/^\s*(name|version|source)\s*=\s*(.+)$/.exec(t);if(!e)continue;let n=e[2]?.trim()??``;if(e[1]===`source`)s=/\b(editable|virtual)\s*=/.test(n);else{let t=/^"([^"]*)"/.exec(n)?.[1];e[1]===`name`&&t&&(a=t),e[1]===`version`&&t&&(o=t)}}return c(),r.rows()}function Dw(e){let t=/* @__PURE__ */ new Set,n=``,r=null,i=``,a=e=>{let n=/^\s*([A-Za-z0-9][A-Za-z0-9._-]*)/.exec(e)?.[1];n&&t.add(Tw(n))},o=()=>{for(let e of i.matchAll(/"([^"]*)"|'([^']*)'/g))a(e[1]??e[2]??``);r=null,i=``},s=e=>e.replace(/"[^"]*"|'[^']*'/g,``).includes(`]`);for(let a of e.split(/\r?\n/)){let e=a.replace(/\s+#.*$/,``);if(r!==null){i+=` ${e}`,s(e)&&o();continue}let c=/^\s*\[([^\]]+)\]\s*$/.exec(e);if(c){n=(c[1]??``).trim();continue}let l=/^\s*"?([A-Za-z0-9_.-]+)"?\s*=\s*(.*)$/.exec(e);if(!l)continue;let u=l[1]??``,d=l[2]??``;n===`tool.poetry.dependencies`||n===`tool.poetry.dev-dependencies`||/^tool\.poetry\.group\.[^.]+\.dependencies$/.test(n)?Tw(u)!==`python`&&t.add(Tw(u)):(n===`project`&&u===`dependencies`||n===`project.optional-dependencies`||n===`dependency-groups`)&&d.trimStart().startsWith(`[`)&&(r=u,i=d,s(d.trimStart().slice(1))&&o())}return t}function Ow(e,t){let n=new KS(`pip`,t),r=0;for(let t of e.split(/\r?\n/)){let e=t.replace(/(^|\s)#.*$/,``).trim();if(e===``||e.startsWith(`-`))continue;let i=/^([A-Za-z0-9][A-Za-z0-9._-]*)\s*(?:\[[^\]]*\])?\s*===?\s*([^\s;,\\]+)/.exec(e);i?.[1]&&i[2]?n.add(i[1],i[2],!0):r++}return{rows:n.rows(),unpinned:r}}async function kw(e){let t=[];for(let n of e.files)try{let r=await Aw(e,n);r&&t.push(...r)}catch(t){e.warnings.push(`${n.path}: could not be parsed (${Nx(t)})`)}return t}async function Aw(e,t){let n=Ax(t.path),r=jx(t.path),i=t=>t?e.readText(t,52428800):Promise.resolve(null),a=t=>e.file(Mx(r,t));switch(n){case`pnpm-lock.yaml`:{let e=await i(t);return e===null?null:hw(e,t.path)}case`package-lock.json`:case`npm-shrinkwrap.json`:{let e=await i(t);return e===null?null:yw(e,t.path)}case`yarn.lock`:{let n=await i(t);return n===null?null:bw(n,t.path,await Sw(e,t.path))}case`composer.lock`:{let e=await i(t);return e===null?null:XS(e,t.path,await i(a(`composer.json`)))}case`poetry.lock`:case`uv.lock`:{let e=await i(t);if(e===null)return null;let n=await i(a(`pyproject.toml`)),r=n?Dw(n):/* @__PURE__ */ new Set;return Ew(e,t.path,r)}case`go.sum`:case`go.mod`:return n===`go.mod`&&a(`go.sum`)?null:ZS(await i(a(`go.mod`)),n===`go.sum`?await i(t):null,t.path)}if(/^requirements[\w.-]*\.txt$/i.test(n)||/(^|\/)requirements\/[^/]+\.txt$/.test(t.path)){let n=await i(t);if(n===null)return null;let{rows:r,unpinned:a}=Ow(n,t.path);return a>0&&e.warnings.push(`${t.path}: ${a} requirement${a===1?``:`s`} without an exact == pin skipped`),r}return null}const jw={name:`Supabase`,type:`database`,provider:`Supabase Postgres`},Mw={name:`Postgres`,type:`database`,provider:`Postgres`},Nw={name:`MySQL`,type:`database`,provider:`MySQL`},Pw={name:`MongoDB`,type:`database`,provider:`MongoDB`},Fw={name:`Redis`,type:`database`,provider:`Redis`},Iw={name:`Elasticsearch`,type:`database`,provider:`Elasticsearch`},Lw={name:`AWS S3`,type:`storage`,provider:`AWS S3`},Rw={name:`AWS SQS`,type:`queue`,provider:`AWS SQS`},zw={name:`AWS`,type:`service`,provider:`AWS`},Bw={name:`MinIO`,type:`storage`,provider:`MinIO`},Vw={name:`Cloudinary`,type:`storage`,provider:`Cloudinary`},Hw={name:`RabbitMQ`,type:`queue`,provider:`RabbitMQ`},Uw={name:`Kafka`,type:`queue`,provider:`Kafka`},Ww={name:`Stripe`,type:`external_api`,provider:`Stripe`},Gw={name:`Twilio`,type:`external_api`,provider:`Twilio`},Kw={name:`SendGrid`,type:`service`,provider:`SendGrid`},qw={name:`Postmark`,type:`service`,provider:`Postmark`},Jw={name:`Resend`,type:`service`,provider:`Resend`},Yw={name:`Mailgun`,type:`service`,provider:`Mailgun`},Xw={name:`Email (SMTP)`,type:`service`,provider:`SMTP`},Zw={name:`Firebase`,type:`service`,provider:`Firebase`},Qw={name:`OpenAI`,type:`ai`,provider:`OpenAI`},$w={name:`Anthropic`,type:`ai`,provider:`Anthropic`},eT={name:`Sentry`,type:`monitoring`,provider:`Sentry`},tT={name:`Auth0`,type:`auth`,provider:`Auth0`},nT={name:`Clerk`,type:`auth`,provider:`Clerk`},rT={name:`Auth.js`,type:`auth`,provider:`Auth.js`},iT={name:`Algolia`,type:`external_api`,provider:`Algolia`},aT={name:`Google Cloud`,type:`service`,provider:`Google Cloud`},oT={name:`Cloud Storage`,type:`storage`,provider:`Google Cloud Storage`},sT={name:`Pub/Sub`,type:`queue`,provider:`Google Cloud Pub/Sub`},cT={name:`BigQuery`,type:`database`,provider:`Google BigQuery`},lT={name:`Firestore`,type:`database`,provider:`Google Firestore`},uT={name:`Secret Manager`,type:`secrets`,provider:`Google Secret Manager`},dT={name:`Gemini`,type:`ai`,provider:`Google Gemini`},fT={name:`Vertex AI`,type:`ai`,provider:`Google Vertex AI`},pT={name:`SerpApi`,type:`external_api`,provider:`SerpApi`},mT={name:`Zyte`,type:`external_api`,provider:`Zyte`},hT={name:`Open Exchange Rates`,type:`external_api`,provider:`Open Exchange Rates`},gT={name:`reCAPTCHA`,type:`external_api`,provider:`Google reCAPTCHA`},_T={name:`DuckDB`,type:`database`,provider:`DuckDB`},vT=[[/^SUPABASE_/,jw],[/^(DATABASE_URL|POSTGRES_|PG(HOST|USER|PASSWORD|DATABASE|PORT)$)/,Mw],[/^MYSQL_/,Nw],[/^MONGO(DB)?_/,Pw],[/^(REDIS_|UPSTASH_REDIS_)/,Fw],[/^(ELASTIC(SEARCH)?_)/,Iw],[/^(AWS_)?S3_|_S3_BUCKET$|^AWS_BUCKET/,Lw],[/^(AWS_)?SQS_/,Rw],[/^AWS_(ACCESS_KEY_ID|SECRET_ACCESS_KEY|REGION|DEFAULT_REGION)$/,zw],[/^MINIO_/,Bw],[/^CLOUDINARY_/,Vw],[/^(RABBITMQ_|AMQP_URL)/,Hw],[/^KAFKA_/,Uw],[/^STRIPE_/,Ww],[/^TWILIO_/,Gw],[/^SENDGRID_/,Kw],[/^POSTMARK_/,qw],[/^RESEND_/,Jw],[/^MAILGUN_/,Yw],[/^SMTP_/,Xw],[/^FIREBASE_/,Zw],[/^OPENAI_/,Qw],[/^ANTHROPIC_/,$w],[/^SENTRY_/,eT],[/^AUTH0_/,tT],[/^CLERK_/,nT],[/^(NEXTAUTH_|AUTH_SECRET$)/,rT],[/^ALGOLIA_/,iT],[/^(GCS_BUCKET|GOOGLE_CLOUD_STORAGE_|GCS_)/,oT],[/^(PUBSUB_|GOOGLE_PUBSUB_)/,sT],[/^BIGQUERY_/,cT],[/^FIRESTORE_/,lT],[/^(GEMINI_|GOOGLE_GENAI_)/,dT],[/^VERTEX(_AI)?_/,fT],[/^(SERPAPI_|SERP_API_)/,pT],[/^ZYTE_/,mT],[/^(OPEN_EXCHANGE_RATES_|OPENEXCHANGERATES_|OXR_)/,hT],[/^RECAPTCHA_/,gT],[/^(GOOGLE_CLOUD_PROJECT|GCP_PROJECT(_ID)?|GCLOUD_PROJECT|GOOGLE_APPLICATION_CREDENTIALS)$/,aT]],yT=[[[`@supabase/supabase-js`,`@supabase/ssr`,`supabase`,`github.com/supabase-community/*`,`supabase/supabase-php`],jw],[[`pg`,`postgres`,`pg-promise`,`@neondatabase/serverless`,`@vercel/postgres`,`psycopg2`,`psycopg2-binary`,`psycopg`,`asyncpg`,`github.com/jackc/pgx*`,`github.com/lib/pq`],Mw],[[`mysql`,`mysql2`,`pymysql`,`mysqlclient`,`github.com/go-sql-driver/mysql`],Nw],[[`mongodb`,`mongoose`,`pymongo`,`motor`,`go.mongodb.org/mongo-driver*`,`mongodb/mongodb`],Pw],[[`redis`,`ioredis`,`@upstash/redis`,`predis/predis`,`github.com/redis/go-redis*`,`github.com/go-redis/redis*`],Fw],[[`@elastic/elasticsearch`,`elasticsearch`,`elasticsearch/elasticsearch`],Iw],[[`@aws-sdk/client-s3`,`github.com/aws/aws-sdk-go-v2/service/s3`,`league/flysystem-aws-s3-v3`],Lw],[[`@aws-sdk/client-sqs`,`github.com/aws/aws-sdk-go-v2/service/sqs`],Rw],[[`aws-sdk`,`boto3`,`aws/aws-sdk-php`,`github.com/aws/aws-sdk-go`],zw],[[`minio`],Bw],[[`cloudinary`,`cloudinary/cloudinary_php`],Vw],[[`amqplib`,`pika`,`php-amqplib/php-amqplib`,`github.com/rabbitmq/amqp091-go`],Hw],[[`kafkajs`,`kafka-python`,`confluent-kafka`,`github.com/segmentio/kafka-go`],Uw],[[`stripe`,`@stripe/stripe-js`,`@stripe/react-stripe-js`,`stripe/stripe-php`,`github.com/stripe/stripe-go*`],Ww],[[`twilio`,`twilio/sdk`,`github.com/twilio/twilio-go`],Gw],[[`@sendgrid/`,`sendgrid`,`sendgrid/sendgrid`],Kw],[[`postmark`,`wildbit/postmark-php`],qw],[[`resend`,`resend/resend-php`],Jw],[[`mailgun.js`,`mailgun/mailgun-php`],Yw],[[`nodemailer`],Xw],[[`firebase`,`firebase-admin`,`firebase-functions`,`kreait/firebase-php`,`firebase.google.com/go*`],Zw],[[`openai`,`openai-php/client`,`github.com/sashabaranov/go-openai`],Qw],[[`@anthropic-ai/sdk`,`anthropic`,`github.com/anthropics/anthropic-sdk-go`],$w],[[`@sentry/`,`sentry-sdk`,`sentry/sentry`,`sentry/sentry-laravel`,`github.com/getsentry/sentry-go`],eT],[[`@auth0/`,`auth0`,`auth0/auth0-php`],tT],[[`@clerk/`],nT],[[`next-auth`,`@auth/`],rT],[[`algoliasearch`,`algolia/algoliasearch-client-php`],iT],[[`@google-cloud/storage`,`google-cloud-storage`,`cloud.google.com/go/storage`],oT],[[`@google-cloud/pubsub`,`google-cloud-pubsub`,`cloud.google.com/go/pubsub*`],sT],[[`@google-cloud/bigquery`,`google-cloud-bigquery`,`cloud.google.com/go/bigquery`],cT],[[`@google-cloud/firestore`,`google-cloud-firestore`,`cloud.google.com/go/firestore`],lT],[[`@google-cloud/secret-manager`,`google-cloud-secret-manager`,`cloud.google.com/go/secretmanager`],uT],[[`@google/genai`,`@google/generative-ai`,`google-genai`,`google-generativeai`],dT],[[`@google-cloud/vertexai`,`google-cloud-aiplatform`,`vertexai`],fT],[[`serpapi`,`google-search-results`],pT],[[`zyte-api`,`scrapy-zyte-api`],mT],[[`open-exchange-rates`],hT],[[`react-google-recaptcha`,`react-google-recaptcha-v3`,`vue-recaptcha`,`vue-recaptcha-v3`,`@google-cloud/recaptcha-enterprise`,`google-cloud-recaptcha-enterprise`,`django-recaptcha`],gT],[[`@google-cloud/`,`google-cloud-*`,`google-auth-library`,`google-auth`,`cloud.google.com/go*`],aT],[[`duckdb`,`@duckdb/`],_T]],bT=[[/^supabase\//,jw],[/(^|\/)(postgres|postgis|timescaledb)$/,Mw],[/(^|\/)(mysql|mariadb)$/,Nw],[/(^|\/)mongo(db)?$/,Pw],[/(^|\/)(redis|redis-stack|valkey)$/,Fw],[/(^|\/)(elasticsearch|opensearch)$/,Iw],[/(^|\/)minio$/,Bw],[/(^|\/)rabbitmq$/,Hw],[/(^|\/)(kafka|cp-kafka)$/,Uw],[/(^|\/)localstack$/,zw],[/(^|\/)(cloud-sdk|google-cloud-cli)$/,aT],[/(^|\/)(gcloud-pubsub-emulator|pubsub-emulator)$/,sT],[/(^|\/)fake-gcs-server$/,oT]];function xT(e){return/^\.env(\.[\w-]+)*\.(example|sample|template|dist)$/i.test(e)||/^(example|sample)\.env$/i.test(e)}function ST(e){let t=Ax(e);return/^\.gitlab-ci\.ya?ml$/.test(t)||/^cloudbuild\.ya?ml$/.test(t)||t===`bitbucket-pipelines.yml`||/(^|\/)\.github\/workflows\/[^/]+\.ya?ml$/.test(e)}function CT(e){return[...new Set(e.match(/\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\b/g)??[])]}function wT(e){return/^(docker-)?compose([.-][\w.-]+)?\.ya?ml$/i.test(e)}var TT=class{#e=/* @__PURE__ */ new Map;add(e,t){let n=this.#e.get(e.provider);n?n.evidence.includes(t)||n.evidence.push(t):this.#e.set(e.provider,{...e,evidence:[t]})}list(){return[...this.#e.values()].sort((e,t)=>e.name.localeCompare(t.name))}};async function ET(e,t){let n=new TT,r=(e,t)=>{let r=e.replace(/^(NEXT_PUBLIC_|VITE_|PUBLIC_|REACT_APP_|EXPO_PUBLIC_|NUXT_PUBLIC_|NUXT_)/,``),i=vT.find(([e])=>e.test(r));i&&n.add(i[1],t)};for(let t of e.files){let i=Ax(t.path);if(xT(i)){let n=await e.readText(t);if(n===null)continue;for(let e of DT(n))r(e,`env: ${e} (${t.path})`)}else if(ST(t.path)){let n=await e.readText(t);if(n===null)continue;for(let e of CT(n))r(e,`pipeline: ${e} (${t.path})`)}else if(wT(i)){let i=await e.readText(t);if(i===null)continue;let a;try{a=(0,mw.parse)(i)}catch(n){e.warnings.push(`${t.path}: could not be parsed (${Nx(n)})`);continue}let o=Z(a)&&Z(a.services)?a.services:{};for(let[e,i]of Object.entries(o)){if(!Z(i))continue;let a=i.environment,o=Array.isArray(a)?a.map(e=>String(e).split(`=`,1)[0]??``):Z(a)?Object.keys(a):[];for(let n of o)r(n,`docker-compose: ${e} env ${n} in ${t.path}`);if(typeof i.image!=`string`)continue;let s=OT(i.image),c=bT.find(([e])=>e.test(s));c&&n.add(c[1],`docker-compose: service ${e} (${i.image}) in ${t.path}`)}}else t.path===`supabase/config.toml`||t.path.endsWith(`/supabase/config.toml`)?n.add(jw,`file: ${t.path}`):i===`firebase.json`?n.add(Zw,`file: ${t.path}`):/^cloudbuild\.ya?ml$/.test(i)&&n.add(aT,`file: ${t.path}`)}for(let e of t){if(!e.direct)continue;let t=yT.find(([t])=>t.some(t=>kT(t,e.package)));t&&n.add(t[1],`dependency: ${e.package} (${e.sourceLockfile})`)}return n.list()}function DT(e){let t=[];for(let n of e.split(/\r?\n/)){let e=/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(n);e?.[1]&&t.push(e[1])}return t}function OT(e){let t=e.toLowerCase().replace(/@.*$/,``),n=t.lastIndexOf(`/`),r=t.indexOf(`:`,n+1);r!==-1&&(t=t.slice(0,r));let i=t.split(`/`);return i.length>1&&/[.:]|^localhost$/.test(i[0]??``)&&i.shift(),i[0]===`library`&&i.shift(),i.join(`/`)}function kT(e,t){return e.endsWith(`*`)?t.startsWith(e.slice(0,-1)):e.endsWith(`/`)?t.startsWith(e):t===e}const AT={name:`Supabase Auth`,type:`auth`,provider:`Supabase Auth`},jT={name:`pg_cron`,type:`scheduler`,provider:`pg_cron`},MT={postgres:[jw,Mw],mysql:[Nw]};function NT(e,t){let n=new Map(t.map(e=>[e.provider,e])),r=(e,t)=>{let r=n.get(e.provider);if(r)return r.provider;let i={...e,evidence:[t]};return n.set(e.provider,i),i.provider};for(let t of e){let e=t.sourcePath.slice(0,t.sourcePath.lastIndexOf(`/`)+1),i=/(^|\/)supabase\//i.test(t.sourcePath);if(t.kind===`job`){t.resource===jT.provider&&r(jT,`cron.schedule in ${t.sourcePath}`);continue}if(t.kind!==`table`&&t.kind!==`function`&&t.kind!==`role`)continue;if(t.kind===`role`){let e=[...n.values()].find(e=>e.type===`auth`);if(e){t.resource=e.provider;continue}if(i){t.resource=r(AT,`roles: ${t.sourcePath}`);continue}}if(i){t.resource=r(jw,`migrations: ${e}`);continue}let a=(t.dialect===`postgres`||t.dialect===`mysql`?MT[t.dialect]:[...MT.postgres,...MT.mysql]).find(e=>n.has(e.provider));a?t.resource=a.provider:t.dialect===`postgres`?t.resource=r(Mw,`migrations: ${e}`):t.dialect===`mysql`&&(t.resource=r(Nw,`migrations: ${e}`))}return[...n.values()].sort((e,t)=>e.name.localeCompare(t.name))}const PT=(e,t,n=e)=>({name:e,type:t,provider:n}),FT=PT(`Environment variables`,`secrets`),IT=PT(`GitHub Actions secrets`,`secrets`),LT=PT(`GitHub Actions`,`scheduler`),RT=PT(`Cloud Run`,`hosting`,`Google Cloud Run`),zT=PT(`Cloud Scheduler`,`scheduler`,`Google Cloud Scheduler`),BT=PT(`Vercel`,`hosting`),VT=PT(`Vercel Cron`,`scheduler`),HT=PT(`Netlify`,`hosting`),UT=PT(`Netlify Scheduled Functions`,`scheduler`),WT=PT(`Fly.io`,`hosting`),GT=PT(`AWS Lambda`,`hosting`),KT=PT(`EventBridge schedules`,`scheduler`,`Amazon EventBridge`),qT=PT(`Kubernetes CronJobs`,`scheduler`,`Kubernetes CronJob`),JT=PT(`Kubernetes`,`hosting`);function YT(e){let t={"@hourly":`every hour`,"@daily":`every day at 00:00`,"@midnight":`every day at 00:00`,"@weekly":`every Sunday at 00:00`,"@monthly":`on the 1st of every month at 00:00`,"@yearly":`every year on 1 January at 00:00`,"@annually":`every year on 1 January at 00:00`},n=e.trim();if(t[n])return t[n];let r=n.split(/\s+/);if(r.length!==5)return;let[i=``,a=``,o=``,s=``,c=``]=r,l=e=>/^\*\/(\d+)$/.exec(e)?.[1],u=e=>/^\d+$/.test(e),d=(...e)=>e.every(e=>e===`*`),f=(e,t)=>`${e.padStart(2,`0`)}:${t.padStart(2,`0`)}`;if(i===`*`&&d(a,o,s,c))return`every minute`;if(l(i)&&d(a,o,s,c))return`every ${l(i)} minutes`;if(u(i)&&d(a,o,s,c))return i===`0`?`every hour`:`every hour at :${i.padStart(2,`0`)}`;if(u(i)&&l(a)&&d(o,s,c))return`every ${l(a)} hours`;if(!u(i)||!u(a))return;let p=f(a,i);if(d(o,s,c))return`every day at ${p}`;let m=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`];if(d(o,s)){if(c===`1-5`)return`every weekday at ${p}`;let e=c.split(`,`).map(e=>m[Number(e)]);return e.every(Boolean)?`every ${e.join(` and `)} at ${p}`:void 0}if(u(o)&&d(s,c))return`on day ${o} of every month at ${p}`}function XT(e){let t=/* @__PURE__ */ new Map;for(let n of e.matchAll(/--([\w-]+)(?:[= ]+("[^"]*"|'[^']*'|(?!--)[^\s]+))?/g))t.set(n[1]??``,(n[2]??``).replace(/^["']|["']$/g,``));return t}function ZT(e){return(e??``).split(/[,\n]/).map(e=>e.trim()).filter(e=>e.includes(`=`)).map(e=>{let[t=``,n=``]=e.split(`=`,2);return[t.trim(),n.trim()]})}const QT=e=>e.replace(/:[^:/]*$/,``).replace(/^.*\/secrets\//,``),$T=e=>/^projects\/([^/]+)\/secrets\//.exec(e)?.[1],eE=e=>e&&!/[$%{}]/.test(e)?e:void 0,tE=e=>/^[A-Za-z0-9][\w.-]*$/.test(e);function nE(e){let t=/* @__PURE__ */ new Map;for(let n of e.matchAll(/^[ \t]*(?:export[ \t]+)?([A-Za-z_]\w*)[ \t]*(\?=|::?=|=)[ \t]*(.*)$/gm)){let[,e=``,r,i=``]=n;r===`?=`&&t.has(e)||t.set(e,i.replace(/\s+#.*$/,``).trim().replace(/^(["'])(.*)\1$/,`$2`))}return t}function rE(e,t){let n=e;for(let e=0;e<5&&t.size;e++){let e=n.replace(/\$\{\{\s*env\.(\w+)\s*\}\}|(?<!\$)\$(?:\((\w+)\)|\{(\w+)\}|([A-Za-z_]\w*))/g,(e,n,r,i,a)=>t.get(n??r??i??a)??e);if(e===n)break;n=e}return n}function iE(e){if(!Z(e))return[];let t=(e,t)=>{if(Z(e))for(let[n,r]of Object.entries(e)){let e=Z(r)?r.value:r;(typeof e==`string`||typeof e==`number`)&&t.set(n,String(e))}return t},n=e=>typeof e==`string`?[e]:Array.isArray(e)?e.flatMap(n):[],r=t(e.variables,t(e.env,/* @__PURE__ */ new Map)),i=(t,r=0)=>{let a=n(t.extends).flatMap(t=>{let n=e[t];return Z(n)&&r<5?[i(n,r+1)]:[]}),o={};for(let e of[...a,t])for(let[t,n]of Object.entries(e))o[t]=t===`variables`&&Z(o[t])&&Z(n)?{...o[t],...n}:n;return o};return(Z(e.jobs)?Object.values(e.jobs):Object.entries(e).filter(([e])=>!e.startsWith(`.`)).map(([,e])=>e)).flatMap(e=>{if(!Z(e))return[];let a=i(e),o=t(a.variables,t(a.env,new Map(r))),s=Array.isArray(a.steps)?a.steps:[];for(let e of s)Z(e)&&t(e.env,o);let c=[...n(a.before_script),...n(a.script),...s.flatMap(e=>Z(e)?n(e.run):[])].join(`
375
+ `);return c?[{text:c,vars:o}]:[]})}function aE(e,t,n){let r=(0,mw.parseAllDocuments)(n,{merge:!0}).map(e=>e.toJS());for(let n of r)for(let r of iE(n))pE(e,t,rE(r.text,r.vars));pE(e,t,n)}const oE=e=>/(SECRET|TOKEN|PASSWORD|PASSWD|PRIVATE|API_KEY|_KEY$|CREDENTIAL|DSN|AUTH)/i.test(e),sE=/["'`]((?:claude-(?:opus|sonnet|haiku|fable|instant|\d)[\w.-]*)|(?:gpt-(?:\d|4o)[\w.-]*)|(?:o[134](?:-mini|-pro|-preview)?(?:-\d{4}-\d{2}-\d{2})?)|(?:text-embedding-[\w-]+)|(?:gemini-(?:\d|embedding)[\w.-]*)|whisper-1|dall-e-[23]|gpt-image-1)["'`]/g,cE=/\.(?:[cm]?[jt]sx?|py|go|rb|java|kt|cs|php|rs|swift|ya?ml|toml|json)$/i,lE=/(^|\/)(?:package(?:-lock)?\.json|pnpm-lock\.yaml|yarn\.lock|composer\.lock|[^/]*\.lock|tsconfig[^/]*\.json)$|(^|\/)(?:__tests__|tests?|fixtures?|test-fixtures|docs?|examples?|demo|seeds?|mocks?)\//i,uE={run:`Google Cloud Run`,pubsub:`Google Cloud Pub/Sub`,scheduler:`Google Cloud Scheduler`,secrets:`Google Secret Manager`,storage:`Google Cloud Storage`,firestore:`Google Firestore`};var dE=class{resources=/* @__PURE__ */ new Map;projects=/* @__PURE__ */ new Map;usedIn(e,t){if(!t)return;let n=this.projects.get(e)??/* @__PURE__ */ new Set;n.add(t),this.projects.set(e,n)}contracts=[];#e=/* @__PURE__ */ new Map;resource(e,t){let n=this.resources.get(e.provider);return n?n.evidence.includes(t)||n.evidence.push(t):this.resources.set(e.provider,{...e,evidence:[t]}),e.provider}add(e,t){this.contracts.some(e=>e.kind===t.kind&&e.name===t.name)||this.contracts.push({...t,resource:this.resource(e,`${t.kind}: ${t.name} (${t.sourcePath})`)})}variable(e,t,n,r,i){if(!/^[A-Za-z_][\w-]*$/.test(n))return;let a=this.#e.get(n),o=[.../* @__PURE__ */ new Set([...a?.contract.setIn??[],e.name])];if(a&&a.priority<=t){a.contract.setIn=o;return}let s={kind:`variable`,name:n,sourcePath:r,secret:oE(n),...i,setIn:o,resource:this.resource(e,`variable: ${n} (${r})`)};a&&this.contracts.splice(this.contracts.indexOf(a.contract),1),this.contracts.push(s),this.#e.set(n,{contract:s,priority:t})}};function fE(e,t,n,r,i,a,o){if(!tE(n))return;let s=eE(o),c=s?{project:s}:{},l=[{relation:`runs`,to:`repo:.`}];for(let[n]of i)e.variable(RT,2,n,t,{secret:oE(n),...c}),l.push({relation:`uses`,to:`variable:${n}`});for(let[n,r]of a){let i=QT(r),a=eE($T(r))??s;e.variable(uT,1,i,t,{secret:!0,...n===i?{}:{envName:n},...a?{project:a}:{}}),l.push({relation:`uses`,to:`variable:${i}`})}e.add(RT,{kind:`deployment`,name:n,sourcePath:t,...r?{region:r}:{},...c,trigger:`HTTP`,links:l})}function pE(e,t,n){let r=n.replace(/\\\r?\n\s*/g,` `),i=eE(/gcloud\s+config\s+set\s+(?:core\/)?project\s+["']?([^\s'"]+)/.exec(r)?.[1]??/CLOUDSDK_CORE_PROJECT\s*[=:]\s*["']?([^\s'"]+)/.exec(r)?.[1]);for(let t of r.matchAll(/gcloud\s+(?:beta\s+|alpha\s+)?([a-z][\w-]*)\b([^\n]*)/g)){let n=eE(XT(t[2]??``).get(`project`))??i;e.usedIn(`Google Cloud`,n);let r=uE[t[1]??``];r&&e.usedIn(r,n)}for(let t of r.matchAll(/firebase\s[^\n]*?(?:--project|-P)[ =]["']?([^\s'"]+)/g))!/emulators:/.test(t[0])&&!/^demo(-|$)/.test(t[1]??``)&&e.usedIn(`Firebase`,eE(t[1]));for(let n of r.matchAll(/gcloud\s+(?:beta\s+)?run\s+deploy\s+["']?([^\s'"`]+)["']?([^\n]*)/g)){let r=XT(n[2]??``);fE(e,t,n[1]??``,r.get(`region`),ZT(r.get(`set-env-vars`)??r.get(`update-env-vars`)),ZT(r.get(`set-secrets`)??r.get(`update-secrets`)),r.get(`project`)??i)}for(let n of r.matchAll(/gcloud\s+(?:beta\s+)?scheduler\s+jobs\s+(?:create|update)\s+(http|pubsub|app-engine)\s+["']?([^\s'"`]+)["']?([^\n]*)/g)){let r=n[2]??``,a=XT(n[3]??``),o=a.get(`schedule`);if(!o||!tE(r))continue;let s=[],c=a.get(`uri`),l;try{l=c?new URL(c).pathname:void 0}catch{}l&&s.push({relation:`calls`,to:`endpoint:${(a.get(`http-method`)??`POST`).toUpperCase()} ${l}`});let u=eE(a.get(`project`))??i;e.add(zT,{kind:`job`,name:r,sourcePath:t,schedule:o,...YT(o)?{scheduleText:YT(o)}:{},...a.get(`time-zone`)?{timeZone:a.get(`time-zone`)}:{},...u?{project:u}:{},runs:n[1]===`pubsub`?`Publishes to Pub/Sub topic ${a.get(`topic`)??``}`.trim():c?`Calls ${c.replace(/^https?:\/\/[^/]+/,``)}`:void 0,links:s})}}const mE=(e,t)=>new RegExp(String.raw`\b${t}\s*=\s*"([^"]*)"`).exec(e)?.[1];function hE(e,t,n){let r=/provider\s+"google(?:-beta)?"\s*\{([\s\S]*?)\n\}/.exec(n)?.[1],i=eE(r?mE(r,`project`):void 0);for(let r of n.matchAll(/resource\s+"(google_cloud_scheduler_job|google_cloud_run_service|google_cloud_run_v2_service|google_secret_manager_secret)"\s+"[\w-]+"\s*\{([\s\S]*?)\n\}/g)){let n=r[2]??``,a=eE(mE(n,`project`))??i,o=a?{project:a}:{};if(r[1]===`google_cloud_scheduler_job`){let r=mE(n,`name`),i=mE(n,`schedule`);if(!r||!i)continue;e.add(zT,{kind:`job`,name:r,sourcePath:t,schedule:i,...YT(i)?{scheduleText:YT(i)}:{},...mE(n,`time_zone`)?{timeZone:mE(n,`time_zone`)}:{},...o})}else if(r[1]===`google_secret_manager_secret`){let r=mE(n,`secret_id`);r&&e.variable(uT,1,r,t,{secret:!0,...o})}else{let r=mE(n,`name`);r&&e.add(RT,{kind:`deployment`,name:r,sourcePath:t,...mE(n,`location`)?{region:mE(n,`location`)}:{},...o,trigger:`HTTP`,links:[{relation:`runs`,to:`repo:.`}]})}}}function gE(e,t,n){if(!Z(n))return;let r=typeof n.name==`string`?n.name:Ax(t).replace(/\.ya?ml$/,``),i=Z(n.on)?n.on:Z(n.true)?n.true:null,a=Array.isArray(i?.schedule)?i.schedule.flatMap(e=>Z(e)&&typeof e.cron==`string`?[e.cron]:[]):[];for(let n of a)e.add(LT,{kind:`job`,name:a.length>1?`${r} (${n})`:r,sourcePath:t,schedule:n,...YT(n)?{scheduleText:YT(n)}:{},timeZone:`UTC`,runs:`GitHub Actions workflow ${t}`});let o=Z(n.jobs)?Object.values(n.jobs):[];for(let r of o){let i=Z(r)&&Array.isArray(r.steps)?r.steps:[],a=/* @__PURE__ */ new Map;for(let e of[n.env,Z(r)?r.env:void 0])if(Z(e))for(let[t,n]of Object.entries(e))(typeof n==`string`||typeof n==`number`)&&a.set(t,String(n));for(let n of i){if(!Z(n)||typeof n.uses!=`string`||!n.uses.startsWith(`google-github-actions/deploy-cloudrun`)||!Z(n.with))continue;let r=n.with,i=e=>typeof e==`string`?rE(e,a):void 0;fE(e,t,i(r.service)??``,i(r.region),ZT(i(r.env_vars)),ZT(i(r.secrets)),i(r.project_id))}}}function _E(e,t,n){for(let r of n){if(!Z(r)||!Z(r.metadata))continue;let n=r.metadata.name;if(typeof n!=`string`)continue;let i=Z(r.spec)?r.spec:{};if(r.kind===`CronJob`&&typeof i.schedule==`string`&&String(r.apiVersion??``).startsWith(`batch/`))e.add(qT,{kind:`job`,name:n,sourcePath:t,schedule:i.schedule,...YT(i.schedule)?{scheduleText:YT(i.schedule)}:{},...typeof i.timeZone==`string`?{timeZone:i.timeZone}:{}});else if(r.kind===`Service`&&String(r.apiVersion??``).startsWith(`serving.knative.dev`)){let a=Z(i.template)&&Z(i.template.spec)&&Array.isArray(i.template.spec.containers)?i.template.spec.containers:[],o=[],s=[];for(let e of a)if(Z(e)&&Array.isArray(e.env))for(let t of e.env){if(!Z(t)||typeof t.name!=`string`)continue;let e=Z(t.valueFrom)&&Z(t.valueFrom.secretKeyRef)?t.valueFrom.secretKeyRef.name:void 0;typeof e==`string`?s.push([t.name,e]):o.push([t.name,``])}let c=(Z(r.metadata.labels)?r.metadata.labels:{})[`cloud.googleapis.com/location`];fE(e,t,n,typeof c==`string`?c:void 0,o,s)}else r.kind===`Deployment`&&String(r.apiVersion??``).startsWith(`apps/`)&&e.add(JT,{kind:`deployment`,name:n,sourcePath:t,links:[{relation:`runs`,to:`repo:.`}]})}}const vE=(e,t)=>new RegExp(String.raw`^\s*${t}\s*=\s*["']([^"']+)["']`,`m`).exec(e)?.[1];async function yE(e,t,n){let r=new dE,i=e=>{let t=e.lastIndexOf(`/`);return t>0?Ax(e.slice(0,t)):n};for(let t of e.files){let a=Ax(t.path),o=t.path,s=()=>e.readText(t);if(xT(a)){let e=await s();if(e===null)continue;let t=/^\.env\.([\w-]+)\./i.exec(a)?.[1];for(let n of DT(e))r.variable(FT,4,n,o,t?{environments:[t]}:{})}else if(/(^|\/)\.github\/workflows\/[^/]+\.ya?ml$/.test(o)){let e=await s();if(e===null)continue;for(let t of e.matchAll(/\$\{\{\s*secrets\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g))t[1]&&t[1]!==`GITHUB_TOKEN`&&r.variable(IT,3,t[1],o,{secret:!0});let t=(0,mw.parseAllDocuments)(e).map(e=>e.toJS());for(let e of t)gE(r,o,e);aE(r,o,e)}else if(/^cloudbuild\.ya?ml$/.test(a)){let e=await s();if(e===null)continue;for(let t of(0,mw.parseAllDocuments)(e).map(e=>e.toJS()))pE(r,o,(Z(t)&&Array.isArray(t.steps)?t.steps:[]).flatMap(e=>Z(e)&&Array.isArray(e.args)?[`${e.entrypoint===`gcloud`||/cloud-sdk/.test(String(e.name))?`gcloud `:``}${e.args.join(` `)}`]:[]).join(`
376
+ `));pE(r,o,e)}else if(ST(o)||/\.(sh|bash)$/.test(a)||/^(Makefile|justfile|Taskfile\.ya?ml)$/i.test(a)||a===`package.json`&&!o.includes(`/node_modules/`)){let e=await s();if(e===null)continue;/\.ya?ml$/i.test(a)?aE(r,o,e):pE(r,o,rE(e,nE(e)))}else if(a.endsWith(`.tf`)){let e=await s();e!==null&&hE(r,o,e)}else if(a===`.firebaserc`){let e=await s();if(e===null)continue;try{let t=JSON.parse(e);if(Z(t.projects))for(let e of Object.values(t.projects))typeof e==`string`&&r.usedIn(`Firebase`,eE(e))}catch{}}else if(a===`vercel.json`){let e=await s();if(e===null)continue;r.add(BT,{kind:`deployment`,name:i(o),sourcePath:o,links:[{relation:`runs`,to:`repo:.`}]});try{let t=JSON.parse(e);for(let e of Array.isArray(t.crons)?t.crons:[])Z(e)&&typeof e.path==`string`&&typeof e.schedule==`string`&&r.add(VT,{kind:`job`,name:e.path,sourcePath:o,schedule:e.schedule,...YT(e.schedule)?{scheduleText:YT(e.schedule)}:{},timeZone:`UTC`,links:[{relation:`calls`,to:`endpoint:GET ${e.path.split(`?`)[0]}`}]})}catch{}}else if(a===`netlify.toml`){let e=await s();if(e===null)continue;r.add(HT,{kind:`deployment`,name:i(o),sourcePath:o,...vE(e,`publish`)?{path:vE(e,`publish`)}:{},links:[{relation:`runs`,to:`repo:.`}]});for(let t of e.matchAll(/\[functions\.["']?([\w-]+)["']?\]([^[]*)/g)){let e=vE(t[2]??``,`schedule`);e&&r.add(UT,{kind:`job`,name:t[1]??``,sourcePath:o,schedule:e,...YT(e)?{scheduleText:YT(e)}:{},timeZone:`UTC`,runs:`Netlify function ${t[1]}`})}}else if(a===`fly.toml`){let e=await s();if(e===null)continue;let t=vE(e,`app`);t&&r.add(WT,{kind:`deployment`,name:t,sourcePath:o,...vE(e,`primary_region`)?{region:vE(e,`primary_region`)}:{},links:[{relation:`runs`,to:`repo:.`}]})}else if(/^serverless\.ya?ml$/.test(a)){let e=await s();if(e===null)continue;let t=(0,mw.parseAllDocuments)(e)[0]?.toJS();if(!Z(t)||!Z(t.functions))continue;let i=typeof t.service==`string`?t.service:n,a=Z(t.provider)&&typeof t.provider.region==`string`?t.provider.region:void 0;for(let[e,n]of Object.entries(t.functions)){let t=`${i}-${e}`;r.add(GT,{kind:`deployment`,name:t,sourcePath:o,...a?{region:a}:{},links:[{relation:`runs`,to:`repo:.`}]});let s=Z(n)&&Array.isArray(n.events)?n.events:[];for(let e of s){let n=Z(e)?e.schedule:void 0,i=typeof n==`string`?n:Z(n)&&typeof n.rate==`string`?n.rate:void 0;i&&r.add(KT,{kind:`job`,name:`${t} schedule`,sourcePath:o,schedule:i,runs:`AWS Lambda ${t}`})}}}else if(/\.ya?ml$/.test(a)){let e=await s();if(e===null||!/\bkind:\s*(CronJob|Service|Deployment)\b/.test(e))continue;try{_E(r,o,(0,mw.parseAllDocuments)(e).map(e=>e.toJS()))}catch{}}}let a=new Set(t.map(e=>e.provider)),o=a.has(fT.provider)&&!a.has(dT.provider)?fT:dT,s=/* @__PURE__ */ new Map;for(let t of e.files){if(!cE.test(t.path)||lE.test(t.path)||t.size>3e5)continue;let n=await e.readText(t);if(n!==null)for(let e of n.matchAll(sE)){let n=(e[1]??``).replace(/[.-]+$/,``),r=n.startsWith(`claude-`)?$w:n.startsWith(`gemini-`)?o:Qw,i=s.get(n)??{kind:r,paths:[]};i.paths.includes(t.path)||i.paths.push(t.path),s.set(n,i)}}for(let[e,{kind:t,paths:n}]of s)r.add(t,{kind:`model`,name:e,sourcePath:n[0]??``,modelId:e,calledFrom:n.slice(0,5)});let c=[...r.resources.values()].map(e=>{let t=r.contracts.filter(t=>t.resource===e.provider);return t.length>0&&t.every(e=>typeof e.project==`string`)?{...e,perProject:!0}:e});return{contracts:r.contracts,resources:c,projects:r.projects}}const bE={ts:`TypeScript`,tsx:`TypeScript`,mts:`TypeScript`,cts:`TypeScript`,js:`JavaScript`,jsx:`JavaScript`,mjs:`JavaScript`,cjs:`JavaScript`,py:`Python`,go:`Go`,rb:`Ruby`,php:`PHP`,java:`Java`,kt:`Kotlin`,kts:`Kotlin`,swift:`Swift`,rs:`Rust`,cs:`C#`,fs:`F#`,c:`C`,h:`C`,cc:`C++`,cpp:`C++`,cxx:`C++`,hpp:`C++`,m:`Objective-C`,mm:`Objective-C++`,scala:`Scala`,dart:`Dart`,ex:`Elixir`,exs:`Elixir`,erl:`Erlang`,clj:`Clojure`,hs:`Haskell`,ml:`OCaml`,lua:`Lua`,r:`R`,pl:`Perl`,groovy:`Groovy`,zig:`Zig`,sol:`Solidity`,sql:`SQL`,sh:`Shell`,bash:`Shell`,zsh:`Shell`,ps1:`PowerShell`,tf:`HCL`,vue:`Vue`,svelte:`Svelte`,astro:`Astro`,html:`HTML`,css:`CSS`,scss:`SCSS`,sass:`SCSS`,less:`Less`};function xE(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=n.path.lastIndexOf(`.`);if(e===-1||e<n.path.lastIndexOf(`/`))continue;let r=bE[n.path.slice(e+1).toLowerCase()];r&&t.set(r,(t.get(r)??0)+1)}return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).slice(0,5).map(([e])=>e)}const SE=/* @__PURE__ */ new Set([`auth`,`storage`,`realtime`,`_realtime`,`extensions`,`graphql`,`graphql_public`,`supabase_functions`,`supabase_migrations`,`pgsodium`,`pgsodium_masks`,`vault`,`net`,`cron`,`pgbouncer`,`pg_catalog`,`information_schema`]),CE=/^(not|null|default|primary|unique|references|check|constraint|generated|collate|deferrable|initially|identity)$/i;function wE(e){if(!/\.sql$/i.test(e))return!1;let t=e.toLowerCase();return/(^|\/)migrations\//.test(t)||/(^|\/)db\/migrate\//.test(t)}const TE=e=>e.slice(0,e.lastIndexOf(`/`)+1),EE=[[`postgres`,/\b(?:bigserial|serial|jsonb|timestamptz|bytea|tsvector|plpgsql|gen_random_uuid|uuid_generate_v4|create\s+extension|create\s+policy|enable\s+row\s+level\s+security)\b|\$\$|::[a-z_]+/gi],[`mysql`,/\bauto_increment\b|\bengine\s*=|\bunsigned\b|`[^`\n]+`/gi],[`sqlite`,/\bautoincrement\b|\bwithout\s+rowid\b|\bpragma\b/gi]];function DE(e){let t=null,n=0;for(let[r,i]of EE){let a=e.match(i)?.length??0;a>n&&(t=r,n=a)}return t}function OE(e,t){let n=e.toLowerCase();if(!n.endsWith(`.sql`)||wE(e))return!1;let r=n.slice(n.lastIndexOf(`/`)+1);return/seed|fixture|sample|test|demo/.test(r)?!1:/schema|structure/.test(r)||t.has(TE(n))||/(^|\/)docker-entrypoint-initdb\.d\//.test(n)}async function kE(e){let t=/* @__PURE__ */ new Map,n=AE(),r=e.files.filter(e=>wE(e.path)),i=new Set(r.flatMap(e=>{let t=/^(.*\/)?(migrations|db\/migrate)\//.exec(e.path.toLowerCase());return t?[t[1]??``]:[]})),a=e.files.filter(e=>OE(e.path,i)).sort((e,t)=>e.path<t.path?-1:1);r.sort((e,t)=>{let n=e.path.slice(e.path.lastIndexOf(`/`)+1),r=t.path.slice(t.path.lastIndexOf(`/`)+1);return n<r?-1:n>r?1:e.path<t.path?-1:1});let o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let i of[...a,...r]){let r=await e.readText(i);if(r===null)continue;let a=DE(r);a&&(o.set(i.path,a),s.set(a,(s.get(a)??0)+1));for(let a of LE(r))try{GE(a,i.path,t,e.warnings),FE(a,i.path,n)}catch(t){e.warnings.push(`${i.path}: could not read statement "${tD(a)}" (${Nx(t)})`)}}let c=[...s.entries()].sort((e,t)=>t[1]-e[1])[0]?.[0]??null,l=e=>o.get(e)??c;return{tables:[...t.values()].filter(e=>!SE.has(e.schema)).map(e=>{let t=e.schema===`public`?e.table:`${e.schema}.${e.table}`;return{kind:`table`,name:t,sourcePath:e.sourcePath,table:t,columns:e.columns,dialect:l(e.sourcePath)}}),objects:IE(n,l)}}const AE=()=>({functions:/* @__PURE__ */ new Map,roleEnums:/* @__PURE__ */ new Map,cronJobs:/* @__PURE__ */ new Map});function jE(e){let{schema:t,table:n}=UE(e);return{schema:t,name:t===`public`?n:`${t}.${n}`}}function ME(e,t){let n=0;for(let r=t;r<e.length;r++){let i=e[r];if(i===`(`)n++;else if(i===`)`&&(n--,n===0))return[e.slice(t+1,r),e.slice(r+1)]}return null}const NE=e=>e.replace(/\s+/g,` `).trim(),PE=()=>String.raw`((?:${VE}\s*(?:\([^)]*\))?\s*,?\s*)+)`;function FE(e,t,n){let r=/^create\s+(?:or\s+replace\s+)?function\s+/i.exec(e);if(r){let i=e.indexOf(`(`,r[0].length),a=i>0?ME(e,i):null;if(!a)return;let{schema:o,name:s}=jE(e.slice(r[0].length,i));if(SE.has(o))return;let c=/^\s*returns\s+(setof\s+\S+|table\s*\([\s\S]*?\)(?=\s)|[\w."[\] ]+?)\s+(?:language|as|security|set|stable|immutable|volatile|strict|parallel|cost|leakproof|called|begin)\b/i.exec(a[1])?.[1];if(!c||/^(event_)?trigger$/i.test(c.trim())){n.functions.delete(s);return}let l=n.functions.get(s);n.functions.set(s,{name:s,sourcePath:t,arguments:`(${NE(a[0]).slice(0,300)})`,returns:NE(c),definer:/\bsecurity\s+definer\b/i.test(a[1].split(/\$\w*\$/)[0]??``),callers:l?.callers??/* @__PURE__ */ new Set});return}let i=new RegExp(String.raw`^drop\s+function\s+(?:if\s+exists\s+)?${PE()}`,`i`).exec(e);if(i?.[1]){for(let e of i[1].split(/,(?![^(]*\))/))n.functions.delete(jE(e.replace(/\(.*$/s,``)).name);return}let a=new RegExp(String.raw`^(grant|revoke)\s+execute\s+on\s+function\s+${PE()}\s+(?:to|from)\s+(.+)$`,`is`).exec(e);if(a?.[1]&&a[2]&&a[a.length-1]){let e=(a[a.length-1]??``).split(`,`).map(e=>e.trim().toLowerCase()).filter(e=>e&&e!==`public`);for(let t of a[2].split(/,(?![^(]*\))/)){let r=n.functions.get(jE(t.replace(/\(.*$/s,``)).name);if(r)for(let t of e)a[1].toLowerCase()===`grant`?r.callers.add(t):r.callers.delete(t)}return}let o=new RegExp(String.raw`^create\s+type\s+${VE}\s+as\s+enum\s*\(([^)]*)\)`,`i`).exec(e);if(o?.[1]&&/role/i.test(o[1])){n.roleEnums.set(UE(o[1]).table,{values:[...(o[2]??``).matchAll(/'((?:[^']|'')*)'/g)].map(e=>(e[1]??``).replace(/''/g,`'`)),sourcePath:t});return}let s=new RegExp(String.raw`^alter\s+type\s+${VE}\s+add\s+value\s+(?:if\s+not\s+exists\s+)?'((?:[^']|'')*)'`,`i`).exec(e);if(s?.[1]){let e=n.roleEnums.get(UE(s[1]).table),t=(s[2]??``).replace(/''/g,`'`);e&&!e.values.includes(t)&&e.values.push(t)}else{for(let r of e.matchAll(/cron\.schedule\s*\(\s*'([^']*)'\s*,\s*(?:'([^']*)'\s*,\s*)?(\$\w*\$[\s\S]*?\$\w*\$|'(?:[^']|'')*')/gi)){let[e,i]=r[2]===void 0?[null,r[1]]:[r[1],r[2]];if(!i)continue;let a=/select\s+([\w."]+)\s*\(/i.exec(r[3]??``)?.[1]??null;n.cronJobs.set(e??`pg_cron ${i}`,{schedule:i,sourcePath:t,calls:a?jE(a).name:null})}for(let t of e.matchAll(/cron\.unschedule\s*\(\s*'([^']*)'/gi))n.cronJobs.delete(t[1]??``)}}function IE(e,t){let n=[];for(let r of e.functions.values()){let e=[...r.callers].sort();n.push({kind:`function`,name:r.name,sourcePath:r.sourcePath,dialect:t(r.sourcePath),arguments:r.arguments,returns:r.returns,access:(e.length?`Callable by ${e.join(`, `)}`:`Not granted to any app role`)+(r.definer?`; runs with its owner's rights`:``)})}let r=/* @__PURE__ */ new Map;for(let t of e.roleEnums.values())for(let e of t.values)r.set(e,(r.get(e)??0)+1);for(let[i,a]of e.roleEnums)for(let e of a.values)n.push({kind:`role`,name:(r.get(e)??0)>1?`${e} (${i})`:e,sourcePath:a.sourcePath,dialect:t(a.sourcePath),definedIn:i});for(let[t,r]of e.cronJobs)n.push({kind:`job`,name:t,sourcePath:r.sourcePath,resource:`pg_cron`,schedule:r.schedule,...r.calls?{links:[{relation:`calls`,to:`function:${r.calls}`}]}:{}});return n}function LE(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r],a=e[r+1];if(i===`-`&&a===`-`){let t=e.indexOf(`
377
+ `,r);r=t===-1?e.length:t,n+=` `}else if(i===`/`&&a===`*`){let t=1;for(r+=2;r<e.length&&t>0;)e.startsWith(`/*`,r)?(t++,r+=2):e.startsWith(`*/`,r)?(t--,r+=2):r++;n+=` `}else if(i===`'`||i===`"`){let t=r+1;for(;t<e.length;)if(e[t]===i){if(e[t+1]===i)t+=2;else break}else t++;n+=e.slice(r,t+1),r=t+1}else{if(i===`$`){let t=/^\$[A-Za-z_]?[A-Za-z0-9_]*\$/.exec(e.slice(r,r+64))?.[0];if(t){let i=e.indexOf(t,r+t.length),a=i===-1?e.length:i+t.length;n+=e.slice(r,a),r=a;continue}}i===`;`?(n.trim()&&t.push(n.trim()),n=``,r++):(n+=i,r++)}}return n.trim()&&t.push(n.trim()),t.map(e=>e.replace(/\s+/g,` `))}function RE(e){let t=[],n=0,r=null,i=0;for(let a=0;a<e.length;a++){let o=e[a];r?o===r&&(r=null):o===`'`||o===`"`?r=o:o===`(`?n++:o===`)`?n--:o===`,`&&n===0&&(t.push(e.slice(i,a).trim()),i=a+1)}return t.push(e.slice(i).trim()),t.filter(Boolean)}function zE(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(/\s/.test(r)){n++;continue}if(r===`(`){let r=0,i=n,a=null;for(;i<e.length;i++){let t=e[i];if(a)t===a&&(a=null);else if(t===`'`||t===`"`)a=t;else if(t===`(`)r++;else if(t===`)`&&--r===0)break}t.push(e.slice(n,i+1)),n=i+1;continue}let i=n,a=null;for(;i<e.length;i++){let t=e[i];if(a)t===a&&(a=null);else if(t===`'`||t===`"`)a=t;else if(/\s/.test(t)||t===`(`)break}t.push(e.slice(n,i)),n=i}return t}const BE=String.raw`(?:"(?:[^"]|"")+"|[A-Za-z_][\w$]*)`,VE=String.raw`(${BE}(?:\s*\.\s*${BE})?)`;function HE(e){let t=e.trim();return t.startsWith(`"`)?t.slice(1,-1).replace(/""/g,`"`):t.toLowerCase()}function UE(e){let t=e.match(new RegExp(BE,`g`))??[e];return t.length>=2?{schema:HE(t[0]??``),table:HE(t[1]??``)}:{schema:`public`,table:HE(t[0]??e)}}function WE(e,t){return`${e}.${t}`}function GE(e,t,n,r){if(/^create\s+(?:(?:global|local)\s+)?(?:temp(?:orary)?\s+|unlogged\s+)?table\b/i.test(e)){KE(e,t,n,r);return}let i=new RegExp(String.raw`^alter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?${VE}\s+(.+)$`,`i`).exec(e);if(i?.[1]&&i[2]){$E(UE(i[1]),i[2],t,n,r);return}let a=/^drop\s+table\s+(?:if\s+exists\s+)?(.+?)(?:\s+(?:cascade|restrict))?$/i.exec(e);if(a?.[1])for(let e of RE(a[1])){let{schema:t,table:r}=UE(e);n.delete(WE(t,r))}}function KE(e,t,n,r){let i=new RegExp(String.raw`^create\s+(?:(?:global|local)\s+)?(?:temp(?:orary)?\s+|unlogged\s+)?table\s+(?:if\s+not\s+exists\s+)?${VE}\s*\(`,`i`).exec(e);if(!i?.[1]){r.push(`${t}: skipped a create table statement it couldn't read: "${tD(e)}"`);return}let{schema:a,table:o}=UE(i[1]),s=i[0].length-1,c=qE(e,s);if(c===-1){r.push(`${t}: unbalanced parentheses in create table ${o}`);return}let l=WE(a,o);if(n.has(l)&&/\bif\s+not\s+exists\b/i.test(e.slice(0,s)))return;let u={schema:a,table:o,sourcePath:t,columns:[]};for(let i of RE(e.slice(s+1,c))){if(/^(constraint|primary\s+key|unique|foreign\s+key|check|exclude|like)\b/i.test(i)){QE(u,i,n);continue}let e=JE(i,n);e?u.columns.push(e):r.push(`${t}: skipped column definition "${tD(i)}" in ${o}`)}n.set(l,u)}function qE(e,t){let n=0,r=null;for(let i=t;i<e.length;i++){let t=e[i];if(r)t===r&&(r=null);else if(t===`'`||t===`"`)r=t;else if(t===`(`)n++;else if(t===`)`&&--n===0)return i}return-1}function JE(e,t){let n=zE(e),r=n[0];if(!r||n.length<2)return null;let i=1,a=[];for(;i<n.length&&!CE.test(n[i]??``);)a.push(n[i]),i++;if(a.length===0)return null;let o={name:HE(r),type:a.join(` `).replace(/\s+\(/g,`(`).toLowerCase(),required:!1};return YE(o,n.slice(i),t),o}function YE(e,t,n){for(let r=0;r<t.length;r++){let i=t[r]?.toLowerCase(),a=t[r+1]?.toLowerCase();if(i===`not`&&a===`null`)e.required=!0,r++;else if(i===`primary`&&a===`key`)e.primaryKey=!0,e.required=!0,r++;else if(i===`unique`)e.unique=!0;else if(i==="default"){let n=[];for(;r+1<t.length&&!CE.test(t[r+1]??``);)n.push(t[r+1]),r++;n.length>0&&(e.default=XE(n))}else if(i===`references`){let i=t[r+1];if(!i)continue;let a=t[r+2]?.startsWith(`(`)?t[r+2]:void 0;e.references=ZE(i,a,n),r+=a?2:1}}}function XE(e){return e.join(` `).replace(/\s+\(/g,`(`)}function ZE(e,t,n){let{schema:r,table:i}=UE(e),a=r===`public`?i:`${r}.${i}`,o=t?HE(t.slice(1,-1).split(`,`)[0]??``):null;return o||=n.get(WE(r,i))?.columns.find(e=>e.primaryKey)?.name??`id`,`${a}.${o}`}function QE(e,t,n){let r=t.replace(new RegExp(String.raw`^constraint\s+${BE}\s+`,`i`),``),i=e=>(e??``).split(`,`).map(e=>HE(e)).filter(Boolean),a=/^primary\s+key\s*\(([^)]*)\)/i.exec(r);if(a){for(let t of i(a[1])){let n=e.columns.find(e=>e.name===t);n&&(n.primaryKey=!0,n.required=!0)}return}let o=/^unique\s*(?:nulls\s+(?:not\s+)?distinct\s*)?\(([^)]*)\)/i.exec(r);if(o){let t=i(o[1]),n=t.length===1?e.columns.find(e=>e.name===t[0]):void 0;n&&(n.unique=!0);return}let s=new RegExp(String.raw`^foreign\s+key\s*\(([^)]*)\)\s*references\s+${VE}\s*(\([^)]*\))?`,`i`).exec(r);if(s?.[2]){let t=i(s[1]),r=s[3]?i(s[3].slice(1,-1)):[];t.forEach((t,i)=>{let a=e.columns.find(e=>e.name===t);if(!a)return;let o=r[i];a.references=ZE(s[2],o?`(${o})`:void 0,n)})}}function $E(e,t,n,r,i){let a=r.get(WE(e.schema,e.table));if(!a){!SE.has(e.schema)&&/\b(add|drop|alter|rename)\s+column\b/i.test(t)&&i.push(`${n}: alter table ${e.table} before any create table for it, skipped`);return}let o=new RegExp(String.raw`^rename\s+to\s+(${BE})$`,`i`).exec(t);if(o?.[1]){r.delete(WE(a.schema,a.table)),a.table=HE(o[1]),r.set(WE(a.schema,a.table),a);return}let s=new RegExp(String.raw`^rename\s+(?:column\s+)?(${BE})\s+to\s+(${BE})$`,`i`).exec(t);if(s?.[1]&&s[2]){let e=a.columns.find(e=>e.name===HE(s[1]));e&&(e.name=HE(s[2]))}else for(let e of RE(t)){let t=/^add\s+(?:column\s+)?(?:if\s+not\s+exists\s+)?(.+)$/i.exec(e);if(t?.[1]&&!/^add\s+(constraint|primary|unique|foreign|check|exclude)\b/i.test(e)){let o=JE(t[1],r);if(!o){i.push(`${n}: skipped "${tD(e)}" on ${a.table}`);continue}a.columns.some(e=>e.name===o.name)||a.columns.push(o);continue}let o=/^add\s+(.+)$/i.exec(e);if(o?.[1]){QE(a,o[1],r);continue}let s=new RegExp(String.raw`^drop\s+(?:column\s+)?(?:if\s+exists\s+)?(${BE})`,`i`).exec(e);if(s?.[1]&&!/^drop\s+constraint\b/i.test(e)){let e=HE(s[1]);a.columns=a.columns.filter(t=>t.name!==e);continue}let c=new RegExp(String.raw`^alter\s+(?:column\s+)?(${BE})\s+(.+)$`,`i`).exec(e);if(c?.[1]&&c[2]){let e=a.columns.find(e=>e.name===HE(c[1]));e&&eD(e,c[2])}}}function eD(e,t){if(/^set\s+not\s+null$/i.test(t))e.required=!0;else if(/^drop\s+not\s+null$/i.test(t))e.required=!!e.primaryKey;else if(/^drop\s+default$/i.test(t))delete e.default;else{let n=/^set\s+default\s+(.+)$/i.exec(t);if(n?.[1]){e.default=XE(zE(n[1]));return}let r=/^(?:set\s+data\s+)?type\s+(.+?)(?:\s+(?:using|collate)\s+.*)?$/i.exec(t);r?.[1]&&(e.type=r[1].replace(/\s+\(/g,`(`).toLowerCase())}}function tD(e){return e.length>60?`${e.slice(0,57)}...`:e}const nD=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`],rD=/^(openapi|swagger)([.-][\w.-]*)?\.(json|ya?ml)$/i,iD=/\.(json|ya?ml)$/i;async function aD(e){let t=[];for(let n of e.files){let r=rD.test(Ax(n.path));if(!r&&!iD.test(n.path)||!r&&(n.size>1048576||/(^|\/)[^/]*lock[^/]*$/i.test(n.path)))continue;let i=await e.readText(n,r?10485760:void 0);if(i===null||!r&&!/^\s*["']?(openapi|swagger)["']?\s*:/m.test(i))continue;let a;try{a=/\.json$/i.test(n.path)?JSON.parse(i):(0,mw.parse)(i)}catch(t){e.warnings.push(`${n.path}: OpenAPI file could not be parsed (${Nx(t)})`);continue}!Z(a)||typeof a.openapi!=`string`&&typeof a.swagger!=`string`?r&&e.warnings.push(`${n.path}: no top-level openapi or swagger version, skipped`):t.push(...oD(a,n.path,e.warnings))}return t}function oD(e,t,n){let r=typeof e.swagger==`string`,i=new sD(e,t,n),a=r?e.securityDefinitions:lD(e.components)?.securitySchemes,o=Z(a)?a:{},s=Z(e.paths)?e.paths:{},c=[];for(let[n,a]of Object.entries(s)){let s=i.resolve(a);if(s)for(let a of nD){let l=lD(s[a.toLowerCase()]);if(!l)continue;let u=[...Array.isArray(s.parameters)?s.parameters:[],...Array.isArray(l.parameters)?l.parameters:[]],d=l.security??e.security;c.push({kind:`endpoint`,name:Px(l.summary)?.trim()||Px(l.operationId)||`${a} ${n}`,sourcePath:t,method:a,path:n,auth:kD(d,o,i),request:r?mD(u,l,e,i):dD(l.requestBody,i),responses:hD(l,e,r,i)})}}return c}var sD=class{#e;#t;#n;#r=/* @__PURE__ */ new Set;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}resolve(e){let t=e;for(let e=0;e<8;e++){if(!Z(t))return null;let e=t.$ref;if(typeof e!=`string`)return t;t=this.#i(e)}return null}refName(e){if(!Z(e)||typeof e.$ref!=`string`)return null;let t=e.$ref.slice(e.$ref.lastIndexOf(`/`)+1);return t?cD(t):null}#i(e){if(!e.startsWith(`#/`))return this.#r.has(e)||(this.#r.add(e),this.#n.push(`${this.#t}: external $ref "${e}" not followed`)),null;let t=this.#e;for(let n of e.slice(2).split(`/`)){if(!Z(t))break;t=t[cD(n)]}return t===void 0&&!this.#r.has(e)&&(this.#r.add(e),this.#n.push(`${this.#t}: $ref "${e}" points at nothing`)),t}};function cD(e){return decodeURIComponent(e).replace(/~1/g,`/`).replace(/~0/g,`~`)}function lD(e){return Z(e)?e:null}function uD(e){if(!Z(e))return null;let t=Object.entries(e).filter(e=>Z(e[1]));return t.find(([e])=>e===`application/json`)??t.find(([e])=>/json/.test(e))??t[0]??null}function dD(e,t){let n=t.resolve(e),r=n?uD(n.content):null;return r?fD(r[0],r[1],t):null}function fD(e,t,n){let r=t.schema,i=CD(r,n);return{contentType:e,fields:TD(r,n),...i?{variants:i}:{},example:pD(t,n)??OD(r,n,0)}}function pD(e,t){if(e.example!==void 0)return e.example;if(Z(e.examples)){let n=t.resolve(Object.values(e.examples)[0]);if(n&&n.value!==void 0)return n.value}}function mD(e,t,n,r){let i=e.map(e=>r.resolve(e)).filter(e=>e!==null),a=_D(t.consumes)??_D(n.consumes),o=i.find(e=>e.in===`body`);if(o){let e=CD(o.schema,r);return{contentType:a??`application/json`,fields:TD(o.schema,r),...e?{variants:e}:{},example:OD(o.schema,r,0)}}let s=i.filter(e=>e.in===`formData`);if(s.length===0)return null;let c=s.map(e=>({name:Px(e.name)??``,type:DD(e,r),required:e.required===!0,...ED(e)}));return{contentType:a??`application/x-www-form-urlencoded`,fields:c,example:Object.fromEntries(s.map(e=>[Px(e.name)??``,OD(e,r,1)]))}}function hD(e,t,n,r){if(!Z(e.responses))return[];let i=_D(e.produces)??_D(t.produces)??`application/json`,a=[];for(let[t,o]of Object.entries(e.responses)){let e=r.resolve(o);if(!e)continue;let s=null;if(n){if(e.schema!==void 0){let t=lD(e.examples),n=CD(e.schema,r);s={contentType:i,fields:TD(e.schema,r),...n?{variants:n}:{},example:t?.[i]??OD(e.schema,r,0)}}}else{let t=uD(e.content);t&&(s=fD(t[0],t[1],r))}a.push({status:gD(t),description:Px(e.description)??``,body:s})}return a}function gD(e){let t=e.replace(/x/gi,`0`),n=Number.parseInt(t,10);return Number.isNaN(n)?0:n}function _D(e){return Array.isArray(e)&&typeof e[0]==`string`?e[0]:void 0}function vD(e,t,n=0){let r=t.resolve(e);if(!r||n>8)return r;if(Array.isArray(r.allOf)){let e={},i=[];for(let a of r.allOf){let r=vD(a,t,n+1);r&&(Z(r.properties)&&Object.assign(e,r.properties),Array.isArray(r.required)&&i.push(...r.required.filter(e=>typeof e==`string`)))}return Z(r.properties)&&Object.assign(e,r.properties),Array.isArray(r.required)&&i.push(...r.required.filter(e=>typeof e==`string`)),{...r,type:`object`,properties:e,required:i}}let i=bD(r,t);return i.length>0&&!r.properties?vD(i[0],t,n+1):r}const yD=(e,t)=>e&&e[t]!==void 0?{[t]:e[t]}:{};function bD(e,t){return(Array.isArray(e.oneOf)?e.oneOf:Array.isArray(e.anyOf)?e.anyOf:[]).filter(e=>!xD(t.resolve(e)))}const xD=e=>e?.type===`null`||Array.isArray(e?.enum)&&e.enum.length===1&&e.enum[0]===null;function SD(e,t){let n=t.resolve(e);return n?n.nullable===!0||Array.isArray(n.type)&&n.type.includes(`null`)?!0:(Array.isArray(n.oneOf)?n.oneOf:Array.isArray(n.anyOf)?n.anyOf:[]).some(e=>xD(t.resolve(e))):!1}function CD(e,t){let n=t.resolve(e);if(n?.type===`array`&&(n=t.resolve(n.items)),!n||n.properties)return;let r=bD(n,t);if(!(r.length<2))return r.slice(0,12).map((e,n)=>{let r=vD(e,t),i=Px(r?.description)?.trim();return{name:wD(e,r,t)??`Option ${n+1}`,...i?{description:i}:{},fields:TD(e,t)}})}function wD(e,t,n){let r=Z(t?.properties)?t.properties:{},i=Object.entries(r).flatMap(([e,t])=>{let r=n.resolve(t),i=r?.const??(Array.isArray(r?.enum)&&r.enum.length===1?r.enum[0]:void 0);return i===void 0?[]:[[e,String(i)]]}),a=i.find(([e])=>/^(event|type|kind|status|object)$/i.test(e))??i[0];return a?`${a[0]}: ${a[1]}`:Px(t?.title)??n.refName(e)??void 0}function TD(e,t){let n=vD(e,t);if(n?.type===`array`&&(n=vD(n.items,t)),!n||!Z(n.properties))return[];let r=new Set(Array.isArray(n.required)?n.required:[]);return Object.entries(n.properties).map(([e,n])=>{let i={...vD(n,t)??{},...yD(t.resolve(n),`description`)};return{name:e,type:DD(n,t),required:r.has(e),...SD(n,t)?{nullable:!0}:{},...ED(i)}})}function ED(e){let t={},n=Px(e.description)?.trim();return n&&(t.description=n),Array.isArray(e.enum)?t.values=e.enum.filter(e=>e!==null).map(e=>String(e)):e.const!==void 0&&e.const!==null&&(t.values=[String(e.const)]),t}function DD(e,t,n=0){let r=t.refName(e),i=t.resolve(e),a=i&&!i.properties?bD(i,t):[];if(a.length===1)return DD(a[0],t,n+1);if(a.length>1&&n<=8)return[...new Set(a.map(e=>DD(e,t,n+1)))].slice(0,4).join(` | `);let o=vD(e,t);if(!o)return r??`unknown`;let s=Array.isArray(o.type)?o.type.filter(e=>e!==`null`).join(` | `):Px(o.type)??(o.const!==void 0&&o.const!==null?typeof o.const:void 0);return s===`array`?n>8?`array`:`${DD(o.items,t,n+1)}[]`:r&&(s===`object`||s===void 0)?r:Px(o.format)??s??(o.properties?`object`:`unknown`)}function OD(e,t,n){let r=vD(e,t);if(!r||n>8)return null;if(r.example!==void 0)return r.example;if(Array.isArray(r.enum)&&r.enum.length>0)return r.enum[0];let i=Array.isArray(r.type)?r.type.find(e=>e!==`null`):r.type;if(i===`object`||i===void 0&&Z(r.properties)){let e=Z(r.properties)?r.properties:{};return Object.fromEntries(Object.entries(e).map(([e,r])=>[e,OD(r,t,n+1)]))}switch(i){case`array`:return[OD(r.items,t,n+1)];case`string`:return`string`;case`integer`:case`number`:return 0;case`boolean`:return!1;default:return null}}function kD(e,t,n){if(!Array.isArray(e)||e.length===0)return null;let r=[];for(let i of e){if(!Z(i))continue;let e=Object.keys(i);e.length===0?r.push(`none`):r.push(e.map(e=>AD(e,n.resolve(t[e]))).join(` + `))}let i=[...new Set(r)];return i.length===0||i.length===1&&i[0]===`none`?null:i.map(e=>e===`none`?`no auth`:e).join(` or `)}function AD(e,t){if(!t)return e;switch(Px(t.type)?.toLowerCase()){case`http`:{let e=Px(t.scheme)?.toLowerCase();if(e===`bearer`){let e=Px(t.bearerFormat);return e?`Bearer token (${e})`:`Bearer token`}return e===`basic`?`Basic auth`:`HTTP ${e??`auth`}`}case`basic`:return`Basic auth`;case`apikey`:return`apikey ${Px(t.in)??`header`} ${Px(t.name)??e}`;case`oauth2`:return`OAuth2`;case`openidconnect`:return`OpenID Connect`;case`mutualtls`:return`Mutual TLS`;default:return e}}const jD=[`readme.md`,`readme.mdx`,`readme.markdown`,`readme.txt`,`readme`];async function MD(e){let t=e.files.find(e=>!e.path.includes(`/`)&&jD.includes(e.path.toLowerCase()));if(!t)return null;let n=await e.readText(t);return{path:t.path,oneLiner:n===null?null:ND(n)}}function ND(e){let t=e.replace(/\r\n/g,`
378
378
  `).replace(/^---\n[\s\S]*?\n---\n/,``).replace(/<!--[\s\S]*?-->/g,``).replace(/^(```|~~~)[\s\S]*?^\1.*$/gm,``);for(let e of t.split(/\n\s*\n/)){let t=e.split(`
379
- `).map(e=>e.trim()).filter(Boolean),n=t[0];if(!n||/^(#|=+$|-+$|\||[-*+] |\d+\. |>|<|\[!\[|!\[)/.test(n)||/^ {4}|^\t/.test(e))continue;let r=wD(t.join(` `));if(!(r.length<15||!/[a-z]/i.test(r)))return TD(/^.+?[.!?](?=\s+["'([]?[A-Z]|\s*$)/.exec(r)?.[0]??r,200)}return null}function wD(e){return e.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]*)\]\[[^\]]*\]/g,`$1`).replace(/<[^>]+>/g,``).replace(/`([^`]*)`/g,`$1`).replace(/(\*\*|__)(.*?)\1/g,`$2`).replace(/(^|\W)[*_](\S(?:.*?\S)?)[*_](?=\W|$)/g,`$1$2`).replace(/\s+/g,` `).trim()}function TD(e,t){if(e.length<=t)return e;let n=e.slice(0,t-1),r=n.lastIndexOf(` `);return`${(r>t/2?n.slice(0,r):n).trimEnd()}…`}const ED=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`],DD=/\.(?:[cm]?[jt]sx?)$/i,OD=/(^|\/)(?:__tests__|tests?|spec|e2e|fixtures?|test-fixtures|mocks?|examples?|dist|build|\.next)\//i,kD=/\.(?:test|spec)\.[cm]?[jt]sx?$|(^|\/)test_[^/]*\.py$|_test\.(?:py|go)$/i;function AD(e){let t=e.replace(/<(?:[\w]+:)?([A-Za-z_]\w*)>/g,`{$1}`).replace(/(^|\/):([A-Za-z_]\w*)\??/g,`$1{$2}`).replace(/\[\.\.\.([\w]+)\]/g,`{$1}`).replace(/\[([\w]+)\]/g,`{$1}`).replace(/\{\{([\w]+)\}\}/g,`{$1}`);return t.startsWith(`/`)||(t=`/${t}`),t=t.replace(/\/{2,}/g,`/`),t.length>1?t.replace(/\/$/,``):t}const jD=(...e)=>AD(e.filter(Boolean).join(`/`)),MD=(e,t,n,r,i={})=>({kind:`endpoint`,name:`${e} ${t}`,sourcePath:n,method:e,path:t,auth:null,request:null,responses:[],from:r,...i}),ND=(e,t)=>`${e} ${AD(t).replace(/\{[^}]*\}/g,`{}`).toLowerCase()}`,PD=String.raw`(['"\`])([^'"\`\n]*)['"\`]`;function FD(e,t,n){if(!t.startsWith(`.`))return;let r=e.slice(0,e.lastIndexOf(`/`)+1),i=[];for(let e of`${r}${t}`.split(`/`))e===`..`?i.pop():e!==`.`&&e!==``&&i.push(e);let a=i.join(`/`).replace(/\.[cm]?js$/,``);for(let e of[``,`.ts`,`.tsx`,`.js`,`.mjs`,`.cjs`,`/index.ts`,`/index.js`])if(n.has(a+e))return a+e}function ID(e,t,n){let r=/from\s+['"](?:express|fastify|hono|koa|@koa\/router|koa-router|@hono\/[\w-]+)['"]|require\(\s*['"](?:express|fastify|koa|@koa\/router|koa-router)['"]\s*\)/.test(t),i=/from\s+['"]@nestjs\/common['"]/.test(t);if(!r&&!i)return null;let a={path:e,routes:[],mounts:[],imports:/* @__PURE__ */ new Map};for(let r of t.matchAll(/import\s+(?:(\w+)|\*\s+as\s+(\w+)|\{([^}]*)\})\s+from\s+['"]([^'"]+)['"]/g)){let t=FD(e,r[4]??``,n);if(!t)continue;let i=r[1]??r[2]??``;i&&a.imports.set(i,t);for(let e of(r[3]??``).split(`,`))a.imports.set(e.trim().split(/\s+as\s+/).pop()??``,t)}for(let r of t.matchAll(/(?:const|let|var)\s+(\w+)\s*=\s*require\(\s*['"]([^'"]+)['"]\s*\)/g)){let t=FD(e,r[2]??``,n);t&&r[1]&&a.imports.set(r[1],t)}if(r){let r=/* @__PURE__ */ new Set([`app`,`router`,`server`,`fastify`]);for(let e of t.matchAll(/(?:const|let|var)\s+(\w+)\s*(?::\s*[\w<>.]+)?\s*=\s*(?:express\s*\(|express\.Router\s*\(|Router\s*\(|fastify\s*\(|Fastify\s*\(|new\s+(?:Hono|Router|KoaRouter)\s*\(|createRouter\s*\()/g))e[1]&&r.add(e[1]);let i=[...r].join(`|`);for(let e of t.matchAll(new RegExp(String.raw`\b(?:${i})\s*\.\s*(get|post|put|patch|delete)\s*\(\s*${PD}`,`g`))){let t=e[3]??``;(t.startsWith(`/`)||t===``)&&a.routes.push({method:(e[1]??`get`).toUpperCase(),path:t})}for(let e of t.matchAll(new RegExp(String.raw`\b(?:${i})\s*\.\s*route\s*\(\s*${PD}\s*\)((?:\s*\.\s*(?:get|post|put|patch|delete|all)\s*\([^)]*\)?)+)`,`g`)))for(let t of(e[3]??``).matchAll(/\.\s*(get|post|put|patch|delete)\s*\(/g))a.routes.push({method:(t[1]??`get`).toUpperCase(),path:e[2]??``});for(let r of t.matchAll(new RegExp(String.raw`\b(?:${i})\s*\.\s*(?:use|route)\s*\(\s*${PD}\s*,\s*(?:require\(\s*['"]([^'"]+)['"]\s*\)|(\w+))`,`g`))){let t=r[3]?FD(e,r[3],n):a.imports.get(r[4]??``);t&&a.mounts.push({prefix:r[2]??``,target:t})}for(let e of t.matchAll(/\.register\s*\(\s*(\w+)\s*,\s*\{[^}]*prefix\s*:\s*(['"`])([^'"`]*)\2/g)){let t=a.imports.get(e[1]??``);t&&a.mounts.push({prefix:e[3]??``,target:t})}}if(i)for(let e of t.split(/(?=@Controller\s*\()/).slice(1)){let t=/@Controller\s*\(\s*(?:(['"`])([^'"`]*)\1|\{[^}]*path\s*:\s*(['"`])([^'"`]*)\3)?/.exec(e);for(let n of e.matchAll(/@(Get|Post|Put|Patch|Delete)\s*\(\s*(?:(['"`])([^'"`]*)\2)?\s*\)/g))a.routes.push({method:(n[1]??`Get`).toUpperCase(),path:jD(t?.[2]??t?.[4]??``,n[3]??``)})}return a}function LD(e,t){let n=/(?:^|\/)app\/(.*)\/route\.[cm]?[jt]sx?$/.exec(e),r=/(?:^|\/)pages\/(api\/.*?)(?:\/index)?\.[cm]?[jt]sx?$/.exec(e),i=n?.[1]??r?.[1];if(i===void 0)return[];let a=AD(i.split(`/`).filter(e=>!/^\(.*\)$/.test(e)&&!e.startsWith(`@`)).join(`/`)),o=n?ED.filter(e=>new RegExp(String.raw`export\s+(?:async\s+)?(?:function\s+${e}\b|const\s+${e}\b)|export\s*\{[^}]*\b${e}\b`).test(t)):[...new Set([...t.matchAll(/req\.method\s*={2,3}\s*['"](\w+)['"]/g)].map(e=>(e[1]??``).toUpperCase()))].filter(e=>ED.includes(e));return(o.length?o:[`GET`]).map(t=>MD(t,a,e,`code`))}function RD(e){let t=new Map(e.map(e=>[e.path,e])),n=(t,r=0)=>{if(r>4)return``;for(let i of e)for(let e of i.mounts)if(e.target===t)return jD(n(i.path,r+1),e.prefix);return``},r=[];for(let e of t.values()){let t=n(e.path);for(let n of e.routes)r.push(MD(n.method,jD(t,n.path),e.path,`code`))}return r}function zD(e,t){if(!/\b(?:fastapi|flask)\b/i.test(t))return null;let n={path:e,module:e.replace(/\.py$/,``).replace(/\/__init__$/,``),routes:[],prefixes:/* @__PURE__ */ new Map,includes:[],imports:/* @__PURE__ */ new Map},r=e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``,i=e=>{let t=/^\.+/.exec(e)?.[0].length??0,n=r;for(let e=1;e<t;e++)n=n.slice(0,n.lastIndexOf(`/`));let i=e.slice(t).replace(/\./g,`/`);return t?[n,i].filter(Boolean).join(`/`):i};for(let e of t.matchAll(/^from\s+([\w.]+)\s+import\s+([^\n(]+|\([^)]*\))/gm)){let t=i(e[1]??``);for(let r of(e[2]??``).replace(/[()]/g,``).split(`,`)){let[e=``,i]=r.trim().split(/\s+as\s+/);e&&(n.imports.set(i??e,`${t}/${e}`),n.imports.set(`${i??e}@`,t))}}for(let e of t.matchAll(/^(\w+)\s*=\s*(?:APIRouter|Blueprint)\s*\(([^)]*)\)/gm)){let t=/(?:url_)?prefix\s*=\s*['"]([^'"]*)['"]/.exec(e[2]??``)?.[1];n.prefixes.set(e[1]??``,t??``)}for(let e of t.matchAll(/^(\w+)\s*=\s*(?:FastAPI|Flask)\s*\(/gm))n.prefixes.set(e[1]??``,``);for(let e of t.matchAll(/@(\w+)\.(get|post|put|patch|delete|route|api_route)\s*\(\s*(['"])([^'"]*)\3([^)]*)\)/g)){let t=e[2]??`get`,r=t===`route`||t===`api_route`?(/methods\s*=\s*\[([^\]]*)\]/.exec(e[5]??``)?.[1]?.match(/[A-Za-z]+/g)?.map(e=>e.toUpperCase())??[`GET`]).filter(e=>ED.includes(e)):[t.toUpperCase()];for(let t of r)n.routes.push({router:e[1]??``,method:t,path:e[4]??``})}for(let e of t.matchAll(/(\w+)\.(?:include_router|register_blueprint)\s*\(\s*([\w.]+)([^)]*)\)/g)){let t=/(?:url_)?prefix\s*=\s*['"]([^'"]*)['"]/.exec(e[3]??``)?.[1]??``;n.includes.push({owner:e[1]??``,ref:e[2]??``,prefix:t})}return n}function BD(e){let t=/* @__PURE__ */ new Map;for(let n of e){t.set(n.module,n);let e=n.module.split(`/`);for(let r=1;r<e.length;r++)t.has(e.slice(r).join(`/`))||t.set(e.slice(r).join(`/`),n)}let n=(e,n)=>{let[r=``,i]=n.split(`.`);if(i){let n=e.imports.get(r),a=n?t.get(n):void 0;return a?{file:a,router:i}:void 0}let a=e.imports.get(`${r}@`),o=a?t.get(a):void 0;return o?{file:o,router:r}:e.prefixes.has(r)?{file:e,router:r}:void 0},r=(t,i,a=0)=>{if(a>4)return``;for(let o of e)for(let e of o.includes){let s=n(o,e.ref);if(s?.file===t&&s.router===i)return jD(r(o,e.owner,a+1),o.prefixes.get(e.owner)??``,e.prefix)}return``},i=[];for(let t of e)for(let e of t.routes)i.push(MD(e.method,jD(r(t,e.router),t.prefixes.get(e.router)??``,e.path),t.path,`code`));return i}function VD(e,t){if(!/"github\.com\/(?:gin-gonic\/gin|labstack\/echo|go-chi\/chi|gofiber\/fiber)/.test(t))return[];let n=[];for(let r of t.matchAll(/\b\w+\.(GET|POST|PUT|PATCH|DELETE|Get|Post|Put|Patch|Delete)\s*\(\s*"(\/[^"]*)"/g))n.push(MD((r[1]??`GET`).toUpperCase(),AD(r[2]??`/`),e,`code`));return n}const HD=/(sk_live_|sk_test_|sk-ant-|sk-proj-|AKIA[0-9A-Z]{16}|-----BEGIN|xox[bpas]-|ghp_|eyJ[A-Za-z0-9_-]{10,}\.)/;function UD(e){if(typeof e!=`string`||!e.trim()||e.length>4e3||HD.test(e))return null;let t;try{t=JSON.parse(e)}catch{return null}return{contentType:`application/json`,fields:Z(t)?Object.entries(t).map(([e,t])=>({name:e,type:Array.isArray(t)?`array`:t===null?`null`:typeof t,required:!1})):[],example:t}}function WD(e,t){if(!Z(t)||!Z(t.info)||!Array.isArray(t.item))return[];let n=[],r=(t,i)=>{for(let a of t){if(!Z(a))continue;let t=Z(a.auth)&&typeof a.auth.type==`string`?a.auth.type:i;if(Array.isArray(a.item)){r(a.item,t);continue}let o=a.request;if(!Z(o))continue;let s=String(o.method??`GET`).toUpperCase();if(!ED.includes(s))continue;let c=o.url,l=AD((Z(c)&&Array.isArray(c.path)?c.path.map(String):String(Z(c)?c.raw??``:c??``).replace(/^[a-z]+:\/\/[^/]+|^\{\{[^}]+\}\}/i,``).split(`?`)[0]?.split(`/`)??[]).filter(Boolean).join(`/`)),u=Z(o.auth)&&typeof o.auth.type==`string`?o.auth.type:t,d=Z(o.body)?UD(o.body.raw):null,f=(Array.isArray(a.response)?a.response:[]).flatMap(e=>Z(e)&&typeof e.code==`number`?[{status:e.code,description:typeof e.name==`string`?e.name:``,body:UD(e.body)}]:[]);n.push(MD(s,l,e,`postman`,{name:typeof a.name==`string`&&a.name?a.name:`${s} ${l}`,auth:u&&u!==`noauth`?`${u} auth`:null,request:d,responses:f,...typeof o.description==`string`&&o.description.length<500?{description:o.description}:{}}))}};return r(t.item,Z(t.auth)&&typeof t.auth.type==`string`?t.auth.type:null),n}async function GD(e){let t=new Set(e.files.map(e=>e.path)),n=[],r=[],i=[],a=[];for(let o of e.files){if(o.size>5e5)continue;let s=kx(o.path);if(/\.postman_collection\.json$/i.test(s)){let t=await e.readText(o);if(t===null)continue;try{a.push(...WD(o.path,JSON.parse(t)))}catch{e.warnings.push(`${o.path}: Postman collection could not be parsed`)}}else if(!(OD.test(o.path)||kD.test(o.path))){if(DD.test(s)){let r=await e.readText(o);if(r===null)continue;i.push(...LD(o.path,r));let a=ID(o.path,r,t);a&&n.push(a)}else if(s.endsWith(`.py`)){let t=await e.readText(o);if(t===null)continue;let n=zD(o.path,t);n&&r.push(n)}else if(s.endsWith(`.go`)){let t=await e.readText(o);t!==null&&i.push(...VD(o.path,t))}}}i.push(...RD(n),...BD(r));let o=/* @__PURE__ */ new Set,s=[];for(let e of[...a,...i]){let t=ND(e.method,e.path);o.has(t)||(o.add(t),s.push(e))}return s}const KD={200:`OK`,201:`Created`,202:`Accepted`,204:`No content`,400:`Bad request`,401:`Unauthorized`,403:`Forbidden`,404:`Not found`,409:`Conflict`,422:`Invalid input`,429:`Too many requests`,500:`Server error`,502:`Bad gateway`,503:`Unavailable`};function qD(t){try{let n=e(x(t,`noop.js`))(`typescript`);return typeof n?.createProgram==`function`?n:null}catch{return null}}function JD(e,t){for(let n=t;;n=y(n)){let t=x(n,`tsconfig.json`);if(C(t))return t;if(n===e||y(n)===n)return null}}function YD(e,t,n){let r=/* @__PURE__ */ new Map;for(let e of t){if(e.from!==`code`||!/\.[cm]?tsx?$/.test(e.sourcePath))continue;let t=r.get(e.sourcePath)??[];t.push(e),r.set(e.sourcePath,t)}if(r.size===0)return;let i=/* @__PURE__ */ new Map;for(let t of r.keys()){let n=JD(e,y(x(e,t)))??``;i.set(n,[...i.get(n)??[],t])}let a=!1;for(let[t,o]of i){let i=qD(y(x(e,o[0]??``)));if(!i)a=!0;else try{XD(i,e,t,o,r)}catch(r){n.push(`Endpoint types in ${S(e,t)||`the repo`} could not be read: ${r.message}`)}}a&&n.push(`TypeScript isn't installed in this repo (run your package manager's install), so endpoint request and response types weren't read.`)}function XD(e,t,n,r,i){let a=n?e.getParsedCommandLineOfConfigFile(n,{},{...e.sys,onUnRecoverableConfigFileDiagnostic:()=>{}}):null,o=e.createProgram({rootNames:r.map(e=>x(t,e)),options:{...a?.options??{allowJs:!0,strict:!0},noEmit:!0,skipLibCheck:!0}}),s=new ZD(e,o.getTypeChecker());for(let n of r){let r=o.getSourceFile(x(t,n)),a=i.get(n)??[];if(!r)continue;let c=t=>{let n=s.route(t);if(n){let e=a.filter(e=>e.method===n.method&&(e.path===n.path||n.path!==`/`&&e.path.endsWith(n.path)));if(e.length){let t=s.handler(n.handler);for(let n of e)!n.request&&t.request&&(n.request=t.request),n.responses.length||(n.responses=t.responses)}}e.forEachChild(t,c)};c(r)}}var ZD=class{ts;checker;constructor(e,t){this.ts=e,this.checker=t}route(e){let t=this.ts;if(!t.isCallExpression(e))return;let n=e.expression;if(!t.isPropertyAccessExpression(n))return;let r=n.name.text;if(!/^(get|post|put|patch|delete)$/.test(r))return;let[i]=e.arguments;if(!(e.arguments.length<2||!(t.isStringLiteral(i)||t.isNoSubstitutionTemplateLiteral(i))))return{method:r.toUpperCase(),path:AD(i.text),handler:e.arguments[e.arguments.length-1]}}fn(e,t=0){let n=this.ts;if(!(!e||t>4)){if(n.isArrowFunction(e)||n.isFunctionExpression(e)||n.isFunctionDeclaration(e)||n.isMethodDeclaration(e))return e;if(n.isIdentifier(e)||n.isPropertyAccessExpression(e)){let r=this.checker.getSymbolAtLocation(e);r&&r.flags&n.SymbolFlags.Alias&&(r=this.checker.getAliasedSymbol(r));let i=r?.valueDeclaration??r?.declarations?.[0];return i?n.isVariableDeclaration(i)?this.fn(i.initializer,t+1):this.fn(i,t+1):void 0}if(n.isCallExpression(e)){let n=this.fn(e.expression,t+1),r=n&&this.returned(n);if(r)return r;if(e.arguments.length)return this.fn(e.arguments[e.arguments.length-1],t+1)}}}returned(e){let t=this.ts,n=e.body;if(!n)return;if(!t.isBlock(n)){let e=t.isParenthesizedExpression(n)?n.expression:n;return t.isArrowFunction(e)||t.isFunctionExpression(e)?e:void 0}let r,i=e=>{if(!(r||t.isFunctionLike(e))){if(t.isReturnStatement(e)&&e.expression){let n=e.expression;t.isArrowFunction(n)||t.isFunctionExpression(n)?r=n:t.isIdentifier(n)&&(r=this.fn(n,3))}r||t.forEachChild(e,i)}};return t.forEachChild(n,i),r}handler(e){let t=this.ts,n=this.fn(e),r=/* @__PURE__ */ new Map,i=null;if(!n?.body)return{request:i,responses:[]};let a=(e,t)=>{e===void 0||r.has(e)||r.set(e,{status:e,description:KD[e]??``,body:t})},o=/* @__PURE__ */ new Set,s=(e,n,r,c,l,u)=>{if(o.has(e)||u>2)return!1;o.add(e);let d=!1,f=e=>e===void 0?200:t.isNumericLiteral(e)?Number(e.text):t.isIdentifier(e)?l.get(e.text):void 0,p=o=>{if(t.isCallExpression(o)&&t.isPropertyAccessExpression(o.expression)){let s=o.expression.name.text,l=o.expression.expression;!c&&t.isIdentifier(l)&&l.text===n?s===`json`?a(f(o.arguments[1]),this.payload(o.arguments[0])):(s===`body`||s===`text`||s===`html`)&&a(f(o.arguments[1]),null):!c&&t.isPropertyAccessExpression(l)&&t.isIdentifier(l.expression)&&l.expression.text===n&&l.name.text===`req`&&(s===`json`||s===`valid`&&this.isJsonTarget(o))?(d=!0,i??=this.requestAt(o,e)):c&&s===`json`&&(t.isIdentifier(l)&&l.text===r?a(200,this.payload(o.arguments[0])):t.isCallExpression(l)&&t.isPropertyAccessExpression(l.expression)&&l.expression.name.text===`status`&&t.isIdentifier(l.expression.expression)&&l.expression.expression.text===r&&a(f(l.arguments[0]),this.payload(o.arguments[0])))}if(c&&t.isPropertyAccessExpression(o)&&o.name.text===`body`&&t.isIdentifier(o.expression)&&o.expression.text===n&&(d=!0,i??=this.requestAt(o,e)),t.isCallExpression(o)){let a=c?r:n,f=o.arguments.findIndex(e=>t.isIdentifier(e)&&e.text===a);if(f>=0){let n=this.fn(o.expression),r=n?.parameters?.[f];if(n?.body&&r&&t.isIdentifier(r.name)){let a=/* @__PURE__ */ new Map;if(o.arguments.forEach((e,r)=>{let i=n.parameters[r],o=t.isNumericLiteral(e)?Number(e.text):t.isIdentifier(e)?l.get(e.text):void 0;i&&t.isIdentifier(i.name)&&o!==void 0&&a.set(i.name.text,o)}),s(n,c?``:r.name.text,c?r.name.text:``,c,a,u+1)){d=!0;let t=this.declarationOf(o);!i&&t&&(i=this.readFields(t,e))}}}}t.forEachChild(o,p)};return p(e.body),d},c=n.parameters.map(e=>t.isIdentifier(e.name)?e.name.text:``);return s(n,c[0]??``,c[1]??``,c.length>=2,/* @__PURE__ */ new Map,0),{request:i,responses:[...r.values()].sort((e,t)=>e.status-t.status)}}calls(e,t){let n=this.ts,r=!1,i=e=>{n.isCallExpression(e)&&n.isPropertyAccessExpression(e.expression)&&e.expression.name.text===t&&(r=!0),r||n.forEachChild(e,i)};return i(e),r}isJsonTarget(e){let[t]=e.arguments;return t&&this.ts.isStringLiteral(t)&&t.text===`json`}requestAt(e,t){let n=this.ts,r=e;for(;;){let e=r.parent;if(!e)break;if(n.isAwaitExpression(e)||n.isParenthesizedExpression(e)||n.isNonNullExpression(e))r=e;else if(n.isPropertyAccessExpression(e)&&e.name.text===`catch`&&e.parent&&n.isCallExpression(e.parent))r=e.parent;else break}let i=r.parent;return i&&(n.isAsExpression(i)||n.isTypeAssertionExpression(i))?this.request(this.checker.getTypeFromTypeNode(i.type),i):i&&n.isVariableDeclaration(i)?i.type&&!this.isLoose(this.checker.getTypeFromTypeNode(i.type))?this.request(this.checker.getTypeFromTypeNode(i.type),i):this.request(this.checker.getTypeAtLocation(e),e)||(n.isIdentifier(i.name)?this.parsedFrom(i.name.text,t)??this.handedOn(i.name.text,t)??this.readFields(i,t):this.readFields(i,t)):i&&n.isCallExpression(i)&&i.arguments.includes(r)?this.validated(i):this.request(this.checker.getTypeAtLocation(e),e)}parsedFrom(e,t){let n=this.ts,r=null,i=t=>n.isIdentifier(t)&&t.text===e,a=(e,t)=>{r||(t===0&&n.isAsExpression(e)&&i(e.expression)&&(r=this.request(this.checker.getTypeFromTypeNode(e.type),e)),t===1&&n.isCallExpression(e)&&e.arguments.some(i)&&/parse|validat|decode|assert/i.test(n.isPropertyAccessExpression(e.expression)?e.expression.name.text:e.expression.getText())&&(r=this.validated(e)),r||n.forEachChild(e,e=>a(e,t)))};return a(t.body,0),a(t.body,1),r}handedOn(e,t){let n=this.ts,r=this.checker,i=null,a=t=>{if(!i){if(n.isIdentifier(t)&&t.text===e&&t.parent){let e=t.parent;if(n.isCallExpression(e)&&e.arguments.includes(t)){let e=r.getContextualType(t);e&&(i=this.request(e,t))}else if(n.isSpreadAssignment(e)&&n.isObjectLiteralExpression(e.parent)&&n.isCallExpression(e.parent.parent)){let t=e.parent,a=r.getContextualType(t),o=a&&this.request(a,t);if(o){let a=/* @__PURE__ */ new Set;for(let i of t.properties)if(i!==e){if(n.isSpreadAssignment(i))for(let e of r.getPropertiesOfType(r.getTypeAtLocation(i.expression)))a.add(e.name);else i.name&&n.isIdentifier(i.name)&&a.add(i.name.text)}let s=o.fields.filter(e=>!a.has(e.name));s.length&&(i={...o,fields:s,example:Object.fromEntries(Object.entries(o.example??{}).filter(([e])=>!a.has(e)))})}}}i||n.forEachChild(t,a)}};return a(t.body),i}declarationOf(e){let t=this.ts,n=e;for(;n.parent&&(t.isAwaitExpression(n.parent)||t.isParenthesizedExpression(n.parent)||t.isAsExpression(n.parent));)n=n.parent;return n.parent&&t.isVariableDeclaration(n.parent)?n.parent:void 0}readFields(e,t){let n=this.ts,r=/* @__PURE__ */ new Map,i=(e,t)=>{let n=r.get(e);if(n?n.type!==`unknown`:r.size>=60)return;let i=t&&this.usedAs(t);if(n&&!i)return;let a=i?this.literals(i):null;r.set(e,{name:e,type:i?this.typeName(i,0):`unknown`,required:!1,...a?{values:a}:{}})},a=e=>{let r=[],i=t=>{n.isIdentifier(t)&&t.text===e&&t.parent&&!n.isBindingElement(t.parent)&&r.push(t),n.forEachChild(t,i)};return i(t.body),r},o=e=>{for(let t of e.elements){let e=t.propertyName??t.name;if(!n.isIdentifier(e)&&!n.isStringLiteral(e))continue;let r=n.isIdentifier(t.name)?t.name.text:void 0;i(e.text,void 0);for(let t of r?a(r):[])i(e.text,t)}};if(n.isObjectBindingPattern(e.name))o(e.name);else if(n.isIdentifier(e.name))for(let t of a(e.name.text)){let e=t.parent;n.isPropertyAccessExpression(e)&&e.expression===t?i(e.name.text,e):n.isVariableDeclaration(e)&&e.initializer===t&&n.isObjectBindingPattern(e.name)&&o(e.name)}if(r.size===0)return null;let s=[...r.values()];return{contentType:`application/json`,fields:s,example:Object.fromEntries(s.map(e=>[e.name,e.values?.[0]??(e.type===`string`?`string`:e.type===`number`?0:e.type!==`boolean`&&null)]))}}usedAs(e){let t=this.ts,n=this.checker,r=e.parent,i;if(r&&t.isShorthandPropertyAssignment(r)){let e=n.getContextualType(r.parent),t=e&&n.getPropertyOfType(e,r.name.text);i=t&&n.getTypeOfSymbolAtLocation(t,r)}else i=n.getContextualType(e);return i&&!this.isLoose(i)?i:void 0}validated(e){let t=this.checker.getTypeAtLocation(e);if(this.isLoose(t))return null;let n=this.checker.getPropertyOfType(this.checker.getNonNullableType(t.isUnion?.()?t.types.find(e=>e.getProperty(`data`))??t:t),`data`),r=t.isUnion?.()?t.types.some(e=>e.getProperty(`success`)):t.getProperty?.(`success`);if(n&&r){let t=this.checker.getNonNullableType(this.checker.getTypeOfSymbolAtLocation(n,e));return this.request(t,e)}return this.request(t,e)}request(e,t){let n=this.payloadOfType(e,t);return n&&(n.fields.length||Array.isArray(n.example))?n:null}payload(e){return e?this.payloadOfType(this.checker.getTypeAtLocation(e),e):null}isLoose(e){let t=this.ts.TypeFlags;return!e||!!(e.flags&(t.Any|t.Unknown|t.Never|t.Void|t.Undefined|t.TypeParameter))}payloadOfType(e,t){let n=(e&&this.checker.getAwaitedType?.(e))??e;if(this.isLoose(n))return null;let[r,...i]=this.present(n),a=r&&i.length===0?r:n,o=this.element(a)??a;return{contentType:`application/json`,fields:this.isObject(o)?this.fields(o,t):[],example:this.example(n,t,0)}}element(e){let t=this.checker;if(t.isArrayType?.(e)||t.isTupleType?.(e))return t.getTypeArguments(e)[0]}isObject(e){let t=this.ts.TypeFlags;return e.isUnion?.()?e.types.every(e=>this.isObject(e)):!!(e.flags&(t.Object|t.Intersection))&&!this.element(e)&&!this.isDate(e)}isDate(e){return e.symbol?.name===`Date`}fields(e,t){let n=this.ts;return this.checker.getPropertiesOfType(e).slice(0,60).map(e=>{let r=this.checker.getTypeOfSymbolAtLocation(e,t),i=!!(e.flags&n.SymbolFlags.Optional)||r.isUnion?.()&&r.types.some(e=>e.flags&n.TypeFlags.Undefined),a=this.literals(r),o=n.displayPartsToString(e.getDocumentationComment(this.checker)).trim().split(`
380
- `)[0];return{name:e.name,type:this.typeName(r,0),required:!i,...o?{description:o}:{},...a?{values:a}:{}}})}literals(e){let t=this.present(e),n=t.flatMap(e=>e.isStringLiteral?.()||e.isNumberLiteral?.()?[String(e.value)]:[]);return n.length>1&&n.length===t.length?n:null}present(e){let t=this.ts.TypeFlags;return(e.isUnion?.()?e.types:[e]).filter(e=>!(e.flags&(t.Null|t.Undefined)))}typeName(e,t){let n=this.ts.TypeFlags,r=this.present(e);if(r.length===0)return`null`;if(r.length>1)return r.every(e=>e.flags&n.StringLike)?`string`:r.every(e=>e.flags&n.NumberLike)?`number`:r.every(e=>e.flags&n.BooleanLike)?`boolean`:[...new Set(r.map(e=>this.typeName(e,t+1)))].slice(0,4).join(` | `);let i=r[0];if(i.flags&n.StringLike)return`string`;if(i.flags&n.NumberLike)return`number`;if(i.flags&n.BooleanLike)return`boolean`;if(i.flags&n.BigIntLike)return`integer`;if(this.isDate(i))return`date-time`;let a=this.element(i);if(a)return t>4?`array`:`${this.typeName(a,t+1)}[]`;let o=i.aliasSymbol?.name??i.symbol?.name;return o&&!o.startsWith(`__`)?o:i.flags&n.Object?`object`:this.checker.typeToString(i).slice(0,60)}example(e,t,n){let r=this.ts.TypeFlags,i=this.present(e)[0];if(!i||n>4)return null;if(i.isStringLiteral?.()||i.isNumberLiteral?.())return i.value;if(i.flags&r.StringLike)return`string`;if(i.flags&r.NumberLike)return 0;if(i.flags&r.BooleanLike)return!1;if(this.isDate(i))return`2026-01-01T00:00:00Z`;let a=this.element(i);return a?[this.example(a,t,n+1)]:i.flags&(r.Object|r.Intersection)?Object.fromEntries(this.checker.getPropertiesOfType(i).slice(0,20).map(e=>[e.name,this.example(this.checker.getTypeOfSymbolAtLocation(e,t),t,n+1)])):null}};async function QD(e,{fromDisk:t=!1}={}){let n=_.resolve(e);if(!(await p(n)).isDirectory())throw Error(`${n} is not a folder`);let r=(/* @__PURE__ */ new Date()).toISOString(),i=[],a=t?null:await RS(n);!t&&!a&&C(_.join(n,`.git`))&&i.push(`No main or master branch found: read the files on disk instead`);let o=a?await Ex(n,a.ref):await Tx(n),s=await CS(o),[c,l,u,d,f,m,h,g]=await Promise.all([BS(n,i,a?.ref??null),SD(o),Tw(o),TS(o,s),MS(o),tD(o),TE(o),GD(o)]),v=await ST(o,u),y=await hE(o,v,c.name),b=new Set(v.map(e=>e.provider)),x=kT([...h.tables,...h.objects],[...v,...y.resources.filter(e=>!b.has(e.provider))]).map(e=>{let t=y.projects.get(e.provider);return t?{...e,projects:[...t].sort()}:e}),S=g.filter(e=>!m.some(t=>ND(t.method,t.path)===ND(e.method,e.path)));return YD(n,S,o.warnings),{scannedAt:r,root:n,repo:{...c,languages:_E(o.files),readme:l},dependencies:u,docs:d,agentInstructions:f,contracts:[...m,...S,...h.tables,...h.objects,...y.contracts],resources:x,docsConfig:{alwaysLoad:!!s.alwaysLoad},warnings:[...i,...o.warnings]}}function $D(e){let t=(e,t,n=`${t}s`)=>e?`${e} ${e===1?t:n}`:``;return[t(e.docs,`doc`)+(e.docsChanged&&e.docsChanged<e.docs?` (${e.docsChanged} changed)`:``),t(e.dependencies,`dependency`,`dependencies`),t(e.contracts,`contract`),t(e.resources,`service`)].filter(Boolean).join(` · `)||`nothing to import yet`}function eO(e){let{scannedRef:t,headSha:n}=e.repo;if(!t)return`files on disk`;let r=t.replace(/^origin\//,``);return n?`${r} @ ${n.slice(0,7)}`:r}async function tO(e,t,{quiet:n=!1,source:r=`connector`,name:i,restore:a}={}){await zS(e);let o=await QD(e),s=(i??t.repoName)?.trim();s&&Object.assign(o.repo,{name:s,nameFromConfig:!0}),a&&Object.assign(o.repo,{restore:!0});let c=await new Wr(await ux()).call(`sync_repo`,{p_project:t.projectId,p_snapshot:o,p_source:r});if(!n){Hx(`Synced ${Rx(o.repo.name)} to ${Rx(t.name)} ${Q(`from ${eO(o)}`)}`),Ux(Q($D(c)));for(let e of o.warnings)Ux(Q(`! ${e}`))}return{snapshot:o,result:c}}async function nO(e){return FS(await Tx(e))}const rO=26214400,iO=e=>`${(e/1024/1024).toFixed(1)} MB`;async function aO(e,t,{quiet:n=!1}={}){if(!t.folder)return;let{docs:r,unsupported:i}=await nO(e),a=e=>Buffer.byteLength(e.body),o=r.reduce((e,t)=>e+a(t),0);if(o>rO){let t=/* @__PURE__ */ new Map;for(let e of r){let n=e.path.includes(`/`)?`${e.path.split(`/`)[0]}/`:e.path;t.set(n,(t.get(n)??0)+a(e))}let n=[...t].sort((e,t)=>t[1]-e[1]).slice(0,3).map(([e,t])=>`${e} (${iO(t)})`).join(`, `);throw new qx(`The documents outside the repos add up to ${iO(o)}, over the ${iO(rO)} a sync takes. The biggest: ${n}. List what Quirl should skip in ${x(v(e),`.quirlignore`)}, like .gitignore.`)}let s=new Wr(await ux()),c={p_project:t.projectId,p_folder:t.folder},l=await s.call(`folder_doc_hashes`,c),u=r.filter(e=>l[e.path]!==e.contentHash),d=0;for(let t=0;t<u.length;){let n=[],r=0;for(;t<u.length;){let e=u[t];if(n.length&&r+a(e)>2097152)break;n.push(e),r+=a(e),t++}let i=await s.call(`sync_folder_docs`,{...c,p_folder_name:v(e),p_docs:n});d+=i.docsChanged}let f={...await s.call(`sync_folder_finish`,{...c,p_paths:r.map(e=>e.path)}),docsChanged:d};return n||(Hx(`Synced the documents in ${Rx(`${v(e)}/`)} outside the repos`),Ux(Q(`${f.docs} docs (${f.docsChanged} changed${f.archived?`, ${f.archived} removed`:``})`)),i.length&&Ux(Q(`! ${i.length} PDF/Office files skipped: only markdown and text are read for now`))),f}async function oO(e={}){let t=await mx();if(!t)throw new qx("This folder isn't linked to a Quirl project. Run `quirl init`.");let n=dx(t.link),r=n.length?n.map(e=>({root:x(t.root,e.path),name:e.name})):[{root:t.root,name:void 0}],i=r.length+ +!!t.link.folder,a=0;for(let{root:o,name:s}of r)try{let r=n.length?await mx(o):null,i=s??(r?.root===o?r.link.repoName:void 0);await tO(o,t.link,{...e,name:i})}catch(e){if(a++,i===1)throw e;let n=S(t.root,o)||`.`;console.error(`${Bx(`✗`)} ${n}: ${Mx(e)}`)}if(t.link.folder)try{await aO(t.root,t.link,e)}catch(e){a++,console.error(`${Bx(`✗`)} documents in ${v(t.root)}/: ${Mx(e)}`)}if(a)throw new qx(`${a} of ${i} parts didn't sync.`)}async function sO(e){let t=fx(),n=await tS(t),r=n.length?n:[t],i=r.length>1||r[0]!==t,a=e=>S(t,e)||v(t),o=h(),s=t.startsWith(o)?`~${t.slice(o.length)}`:t;if(console.log(`\n🌀 ${Rx(`Quirl`)} ${Q(`·`)} connecting ${Rx(s)}`),i&&(Wx(`📁`,`Found ${r.length} ${r.length===1?`repo`:`repos`}`),Gx(Q(r.map(a).join(` · `))),!await Yx(` Import all of them into one project?`,!0)))throw new qx("Nothing imported. Run `quirl init` inside the repo you want instead.");let c=!1;if(i&&!n.includes(t)){let{docs:e,unsupported:n}=await nO(t);if(e.length){Wx(`📄`,`Also found ${e.length} ${e.length===1?`document`:`documents`} outside the repos`);for(let t of e.slice(0,8))Gx(Q(t.path));e.length>8&&Gx(Q(`…and ${e.length-8} more`)),n.length&&Gx(Q(`(${n.length} PDF/Office files can't be read yet and are skipped)`)),c=await Yx(` Import them too? Everyone on the project will be able to read them.`,!0)}}await sx()||await hS({quiet:!0});let l=await lO((await new Wr(await ux()).whoami()).projects,e.project??(await mx(t))?.link.project);if(l.role===`stakeholder`)throw new qx(`You're a stakeholder on ${l.name}; ask an admin or dev to run \`quirl init\`.`);let u={project:l.slug,projectId:l.id,name:l.name};Wx(`🔗`,`Linked to ${Rx(l.name)} ${Q(`· ${l.organization}`)}`);let d=e.claude!==!1,f=e.hooks??await Yx(` Sync with Quirl on every git push?`,!0);Wx(`📦`,`Importing docs, dependencies and schemas`);let p=[],m=i?await mx(t):null,g=new Map((m?.root===t?dx(m.link):[]).filter(e=>e.name).map(e=>[e.path,e.name]));for(let e of r){let t=Kx(`Reading ${a(e)}…`);try{let n=await mx(e),r=(n?.root===e?n.link.repoName:void 0)??g.get(a(e));r&&g.set(a(e),r);let i=r?{...u,repoName:r}:u;await hx(e,i);let{snapshot:o,result:s}=await tO(e,i,{quiet:!0,restore:!0});d&&await cO(e,l.name),f&&await mS(e),t.stop(),Gx(`${zx(`✓`)} ${Rx(a(e))} ${Q(`(${eO(o)})`)} ${Q($D(s))}`);for(let e of o.warnings)Gx(Q(` ! ${e}`));p.push(e)}catch(n){t.stop(),Gx(`${Bx(`✗`)} ${Rx(a(e))} ${Mx(n)}`)}}if(!p.length)throw new qx(`No repo was imported.`);if(i){let e=p.map(e=>{let t=g.get(a(e));return t?{path:a(e),name:t}:a(e)}),n=m,r={...u,repos:e,folder:c?n?.root===t&&n.link.folder||ee():void 0};if(await hx(t,r),c)try{let e=await aO(t,r,{quiet:!0});Gx(`${zx(`✓`)} ${Rx(`documents outside the repos`)} ${Q(`${e?.docs??0} docs`)}`)}catch(e){Gx(`${Bx(`✗`)} ${Rx(`documents outside the repos`)} ${Mx(e)}`)}d&&!p.includes(t)&&await cO(t,l.name,p.map(a))}let _=aS().portable;d&&(Wx(`🤖`,`Connected Claude Code`),Gx(Q(`.mcp.json the quirl tools`)),Gx(Q(`.claude/settings.json the briefing, loaded as each session starts`)),Gx(Q(`CLAUDE.md when to use Quirl`))),f&&Wx(`🪝`,`Quirl syncs on every ${Rx(`git push`)}`);let y=r.length-p.length,b=`.quirl .mcp.json .claude/settings.json CLAUDE.md`;Wx(y?`⚠️ `:`🎉`,y?`Done, but ${y} of ${r.length} repos failed. Fix them and run ${Rx(`quirl init`)} again.`:Rx(`All set!`)),Gx(d&&!_?Q(`Don't commit ${b} yet: they point at this checkout until the CLI is installed.`):`${Q(`1.`)} Commit what was added${i?` in each repo`:``}: ${Vx(`git add ${b}`)}`),Gx(`${Q(d&&!_?`→`:`2.`)} Start Claude Code here and approve the ${Rx(`quirl`)} server when it asks.`),i&&!p.includes(t)&&Gx(Q("Run `quirl sync` here to sync every repo at once.")),console.log(``)}async function cO(e,t,n=[]){await dS(e),await fS(e),await pS(e,t,n)}async function lO(e,t){if(!e.length)throw new qx(`You aren't on any Quirl project yet. Ask an admin to invite you.`);if(t){let n=e.find(e=>e.slug===t||e.id===t);if(!n)throw new qx(`No project "${t}" among yours: ${e.map(e=>e.slug).join(`, `)}.`);return n}if(e.length===1)return e[0];Wx(`🗂️ `,`Which project is this part of?`);for(let[t,n]of e.entries())Gx(`${Vx(String(t+1))} ${n.name} ${Q(`· ${n.organization} · ${n.role}`)}`);let n=e[Number(await Jx(` Project [1-${e.length}]: `))-1];if(!n)throw new qx("No project picked. Run `quirl init --project <slug>`.");return n}const uO=`${Rx(`quirl`)} ${Q(tx)}: connect a repo to Quirl
379
+ `).map(e=>e.trim()).filter(Boolean),n=t[0];if(!n||/^(#|=+$|-+$|\||[-*+] |\d+\. |>|<|\[!\[|!\[)/.test(n)||/^ {4}|^\t/.test(e))continue;let r=PD(t.join(` `));if(!(r.length<15||!/[a-z]/i.test(r)))return FD(/^.+?[.!?](?=\s+["'([]?[A-Z]|\s*$)/.exec(r)?.[0]??r,200)}return null}function PD(e){return e.replace(/!\[[^\]]*\]\([^)]*\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]*)\]\[[^\]]*\]/g,`$1`).replace(/<[^>]+>/g,``).replace(/`([^`]*)`/g,`$1`).replace(/(\*\*|__)(.*?)\1/g,`$2`).replace(/(^|\W)[*_](\S(?:.*?\S)?)[*_](?=\W|$)/g,`$1$2`).replace(/\s+/g,` `).trim()}function FD(e,t){if(e.length<=t)return e;let n=e.slice(0,t-1),r=n.lastIndexOf(` `);return`${(r>t/2?n.slice(0,r):n).trimEnd()}…`}const ID=[`GET`,`POST`,`PUT`,`PATCH`,`DELETE`],LD=/\.(?:[cm]?[jt]sx?)$/i,RD=/(^|\/)(?:__tests__|tests?|spec|e2e|fixtures?|test-fixtures|mocks?|examples?|dist|build|\.next)\//i,zD=/\.(?:test|spec)\.[cm]?[jt]sx?$|(^|\/)test_[^/]*\.py$|_test\.(?:py|go)$/i;function BD(e){let t=e.replace(/<(?:[\w]+:)?([A-Za-z_]\w*)>/g,`{$1}`).replace(/(^|\/):([A-Za-z_]\w*)\??/g,`$1{$2}`).replace(/\[\.\.\.([\w]+)\]/g,`{$1}`).replace(/\[([\w]+)\]/g,`{$1}`).replace(/\{\{([\w]+)\}\}/g,`{$1}`);return t.startsWith(`/`)||(t=`/${t}`),t=t.replace(/\/{2,}/g,`/`),t.length>1?t.replace(/\/$/,``):t}const VD=(...e)=>BD(e.filter(Boolean).join(`/`)),HD=(e,t,n,r,i={})=>({kind:`endpoint`,name:`${e} ${t}`,sourcePath:n,method:e,path:t,auth:null,request:null,responses:[],from:r,...i}),UD=(e,t)=>`${e} ${BD(t).replace(/\{[^}]*\}/g,`{}`).toLowerCase()}`,WD=String.raw`(['"\`])([^'"\`\n]*)['"\`]`;function GD(e,t,n){if(!t.startsWith(`.`))return;let r=e.slice(0,e.lastIndexOf(`/`)+1),i=[];for(let e of`${r}${t}`.split(`/`))e===`..`?i.pop():e!==`.`&&e!==``&&i.push(e);let a=i.join(`/`).replace(/\.[cm]?js$/,``);for(let e of[``,`.ts`,`.tsx`,`.js`,`.mjs`,`.cjs`,`/index.ts`,`/index.js`])if(n.has(a+e))return a+e}function KD(e,t,n){let r=/from\s+['"](?:express|fastify|hono|koa|@koa\/router|koa-router|@hono\/[\w-]+)['"]|require\(\s*['"](?:express|fastify|koa|@koa\/router|koa-router)['"]\s*\)/.test(t),i=/from\s+['"]@nestjs\/common['"]/.test(t);if(!r&&!i)return null;let a={path:e,routes:[],mounts:[],imports:/* @__PURE__ */ new Map};for(let r of t.matchAll(/import\s+(?:(\w+)|\*\s+as\s+(\w+)|\{([^}]*)\})\s+from\s+['"]([^'"]+)['"]/g)){let t=GD(e,r[4]??``,n);if(!t)continue;let i=r[1]??r[2]??``;i&&a.imports.set(i,t);for(let e of(r[3]??``).split(`,`))a.imports.set(e.trim().split(/\s+as\s+/).pop()??``,t)}for(let r of t.matchAll(/(?:const|let|var)\s+(\w+)\s*=\s*require\(\s*['"]([^'"]+)['"]\s*\)/g)){let t=GD(e,r[2]??``,n);t&&r[1]&&a.imports.set(r[1],t)}if(r){let r=/* @__PURE__ */ new Set([`app`,`router`,`server`,`fastify`]);for(let e of t.matchAll(/(?:const|let|var)\s+(\w+)\s*(?::\s*[\w<>.]+)?\s*=\s*(?:express\s*\(|express\.Router\s*\(|Router\s*\(|fastify\s*\(|Fastify\s*\(|new\s+(?:Hono|Router|KoaRouter)\s*\(|createRouter\s*\()/g))e[1]&&r.add(e[1]);let i=[...r].join(`|`);for(let e of t.matchAll(new RegExp(String.raw`\b(?:${i})\s*\.\s*(get|post|put|patch|delete)\s*\(\s*${WD}`,`g`))){let t=e[3]??``;(t.startsWith(`/`)||t===``)&&a.routes.push({method:(e[1]??`get`).toUpperCase(),path:t})}for(let e of t.matchAll(new RegExp(String.raw`\b(?:${i})\s*\.\s*route\s*\(\s*${WD}\s*\)((?:\s*\.\s*(?:get|post|put|patch|delete|all)\s*\([^)]*\)?)+)`,`g`)))for(let t of(e[3]??``).matchAll(/\.\s*(get|post|put|patch|delete)\s*\(/g))a.routes.push({method:(t[1]??`get`).toUpperCase(),path:e[2]??``});for(let r of t.matchAll(new RegExp(String.raw`\b(?:${i})\s*\.\s*(?:use|route)\s*\(\s*${WD}\s*,\s*(?:require\(\s*['"]([^'"]+)['"]\s*\)|(\w+))`,`g`))){let t=r[3]?GD(e,r[3],n):a.imports.get(r[4]??``);t&&a.mounts.push({prefix:r[2]??``,target:t})}for(let e of t.matchAll(/\.register\s*\(\s*(\w+)\s*,\s*\{[^}]*prefix\s*:\s*(['"`])([^'"`]*)\2/g)){let t=a.imports.get(e[1]??``);t&&a.mounts.push({prefix:e[3]??``,target:t})}}if(i)for(let e of t.split(/(?=@Controller\s*\()/).slice(1)){let t=/@Controller\s*\(\s*(?:(['"`])([^'"`]*)\1|\{[^}]*path\s*:\s*(['"`])([^'"`]*)\3)?/.exec(e);for(let n of e.matchAll(/@(Get|Post|Put|Patch|Delete)\s*\(\s*(?:(['"`])([^'"`]*)\2)?\s*\)/g))a.routes.push({method:(n[1]??`Get`).toUpperCase(),path:VD(t?.[2]??t?.[4]??``,n[3]??``)})}return a}function qD(e,t){let n=/(?:^|\/)app\/(.*)\/route\.[cm]?[jt]sx?$/.exec(e),r=/(?:^|\/)pages\/(api\/.*?)(?:\/index)?\.[cm]?[jt]sx?$/.exec(e),i=n?.[1]??r?.[1];if(i===void 0)return[];let a=BD(i.split(`/`).filter(e=>!/^\(.*\)$/.test(e)&&!e.startsWith(`@`)).join(`/`)),o=n?ID.filter(e=>new RegExp(String.raw`export\s+(?:async\s+)?(?:function\s+${e}\b|const\s+${e}\b)|export\s*\{[^}]*\b${e}\b`).test(t)):[...new Set([...t.matchAll(/req\.method\s*={2,3}\s*['"](\w+)['"]/g)].map(e=>(e[1]??``).toUpperCase()))].filter(e=>ID.includes(e));return(o.length?o:[`GET`]).map(t=>HD(t,a,e,`code`))}function JD(e){let t=new Map(e.map(e=>[e.path,e])),n=(t,r=0)=>{if(r>4)return``;for(let i of e)for(let e of i.mounts)if(e.target===t)return VD(n(i.path,r+1),e.prefix);return``},r=[];for(let e of t.values()){let t=n(e.path);for(let n of e.routes)r.push(HD(n.method,VD(t,n.path),e.path,`code`))}return r}function YD(e,t){if(!/\b(?:fastapi|flask)\b/i.test(t))return null;let n={path:e,module:e.replace(/\.py$/,``).replace(/\/__init__$/,``),routes:[],prefixes:/* @__PURE__ */ new Map,includes:[],imports:/* @__PURE__ */ new Map},r=e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)):``,i=e=>{let t=/^\.+/.exec(e)?.[0].length??0,n=r;for(let e=1;e<t;e++)n=n.slice(0,n.lastIndexOf(`/`));let i=e.slice(t).replace(/\./g,`/`);return t?[n,i].filter(Boolean).join(`/`):i};for(let e of t.matchAll(/^from\s+([\w.]+)\s+import\s+([^\n(]+|\([^)]*\))/gm)){let t=i(e[1]??``);for(let r of(e[2]??``).replace(/[()]/g,``).split(`,`)){let[e=``,i]=r.trim().split(/\s+as\s+/);e&&(n.imports.set(i??e,`${t}/${e}`),n.imports.set(`${i??e}@`,t))}}for(let e of t.matchAll(/^(\w+)\s*=\s*(?:APIRouter|Blueprint)\s*\(([^)]*)\)/gm)){let t=/(?:url_)?prefix\s*=\s*['"]([^'"]*)['"]/.exec(e[2]??``)?.[1];n.prefixes.set(e[1]??``,t??``)}for(let e of t.matchAll(/^(\w+)\s*=\s*(?:FastAPI|Flask)\s*\(/gm))n.prefixes.set(e[1]??``,``);for(let e of t.matchAll(/@(\w+)\.(get|post|put|patch|delete|route|api_route)\s*\(\s*(['"])([^'"]*)\3([^)]*)\)/g)){let t=e[2]??`get`,r=t===`route`||t===`api_route`?(/methods\s*=\s*\[([^\]]*)\]/.exec(e[5]??``)?.[1]?.match(/[A-Za-z]+/g)?.map(e=>e.toUpperCase())??[`GET`]).filter(e=>ID.includes(e)):[t.toUpperCase()];for(let t of r)n.routes.push({router:e[1]??``,method:t,path:e[4]??``})}for(let e of t.matchAll(/(\w+)\.(?:include_router|register_blueprint)\s*\(\s*([\w.]+)([^)]*)\)/g)){let t=/(?:url_)?prefix\s*=\s*['"]([^'"]*)['"]/.exec(e[3]??``)?.[1]??``;n.includes.push({owner:e[1]??``,ref:e[2]??``,prefix:t})}return n}function XD(e){let t=/* @__PURE__ */ new Map;for(let n of e){t.set(n.module,n);let e=n.module.split(`/`);for(let r=1;r<e.length;r++)t.has(e.slice(r).join(`/`))||t.set(e.slice(r).join(`/`),n)}let n=(e,n)=>{let[r=``,i]=n.split(`.`);if(i){let n=e.imports.get(r),a=n?t.get(n):void 0;return a?{file:a,router:i}:void 0}let a=e.imports.get(`${r}@`),o=a?t.get(a):void 0;return o?{file:o,router:r}:e.prefixes.has(r)?{file:e,router:r}:void 0},r=(t,i,a=0)=>{if(a>4)return``;for(let o of e)for(let e of o.includes){let s=n(o,e.ref);if(s?.file===t&&s.router===i)return VD(r(o,e.owner,a+1),o.prefixes.get(e.owner)??``,e.prefix)}return``},i=[];for(let t of e)for(let e of t.routes)i.push(HD(e.method,VD(r(t,e.router),t.prefixes.get(e.router)??``,e.path),t.path,`code`));return i}function ZD(e,t){if(!/"github\.com\/(?:gin-gonic\/gin|labstack\/echo|go-chi\/chi|gofiber\/fiber)/.test(t))return[];let n=[];for(let r of t.matchAll(/\b\w+\.(GET|POST|PUT|PATCH|DELETE|Get|Post|Put|Patch|Delete)\s*\(\s*"(\/[^"]*)"/g))n.push(HD((r[1]??`GET`).toUpperCase(),BD(r[2]??`/`),e,`code`));return n}const QD=/(sk_live_|sk_test_|sk-ant-|sk-proj-|AKIA[0-9A-Z]{16}|-----BEGIN|xox[bpas]-|ghp_|eyJ[A-Za-z0-9_-]{10,}\.)/;function $D(e){if(typeof e!=`string`||!e.trim()||e.length>4e3||QD.test(e))return null;let t;try{t=JSON.parse(e)}catch{return null}return{contentType:`application/json`,fields:Z(t)?Object.entries(t).map(([e,t])=>({name:e,type:Array.isArray(t)?`array`:t===null?`null`:typeof t,required:!1})):[],example:t}}function eO(e,t){if(!Z(t)||!Z(t.info)||!Array.isArray(t.item))return[];let n=[],r=(t,i)=>{for(let a of t){if(!Z(a))continue;let t=Z(a.auth)&&typeof a.auth.type==`string`?a.auth.type:i;if(Array.isArray(a.item)){r(a.item,t);continue}let o=a.request;if(!Z(o))continue;let s=String(o.method??`GET`).toUpperCase();if(!ID.includes(s))continue;let c=o.url,l=BD((Z(c)&&Array.isArray(c.path)?c.path.map(String):String(Z(c)?c.raw??``:c??``).replace(/^[a-z]+:\/\/[^/]+|^\{\{[^}]+\}\}/i,``).split(`?`)[0]?.split(`/`)??[]).filter(Boolean).join(`/`)),u=Z(o.auth)&&typeof o.auth.type==`string`?o.auth.type:t,d=Z(o.body)?$D(o.body.raw):null,f=(Array.isArray(a.response)?a.response:[]).flatMap(e=>Z(e)&&typeof e.code==`number`?[{status:e.code,description:typeof e.name==`string`?e.name:``,body:$D(e.body)}]:[]);n.push(HD(s,l,e,`postman`,{name:typeof a.name==`string`&&a.name?a.name:`${s} ${l}`,auth:u&&u!==`noauth`?`${u} auth`:null,request:d,responses:f,...typeof o.description==`string`&&o.description.length<500?{description:o.description}:{}}))}};return r(t.item,Z(t.auth)&&typeof t.auth.type==`string`?t.auth.type:null),n}async function tO(e){let t=new Set(e.files.map(e=>e.path)),n=[],r=[],i=[],a=[];for(let o of e.files){if(o.size>5e5)continue;let s=Ax(o.path);if(/\.postman_collection\.json$/i.test(s)){let t=await e.readText(o);if(t===null)continue;try{a.push(...eO(o.path,JSON.parse(t)))}catch{e.warnings.push(`${o.path}: Postman collection could not be parsed`)}}else if(!(RD.test(o.path)||zD.test(o.path))){if(LD.test(s)){let r=await e.readText(o);if(r===null)continue;i.push(...qD(o.path,r));let a=KD(o.path,r,t);a&&n.push(a)}else if(s.endsWith(`.py`)){let t=await e.readText(o);if(t===null)continue;let n=YD(o.path,t);n&&r.push(n)}else if(s.endsWith(`.go`)){let t=await e.readText(o);t!==null&&i.push(...ZD(o.path,t))}}}i.push(...JD(n),...XD(r));let o=/* @__PURE__ */ new Set,s=[];for(let e of[...a,...i]){let t=UD(e.method,e.path);o.has(t)||(o.add(t),s.push(e))}return s}const nO={200:`OK`,201:`Created`,202:`Accepted`,204:`No content`,400:`Bad request`,401:`Unauthorized`,403:`Forbidden`,404:`Not found`,409:`Conflict`,422:`Invalid input`,429:`Too many requests`,500:`Server error`,502:`Bad gateway`,503:`Unavailable`};function rO(t){try{let n=e(x(t,`noop.js`))(`typescript`);return typeof n?.createProgram==`function`?n:null}catch{return null}}function iO(e,t){for(let n=t;;n=y(n)){let t=x(n,`tsconfig.json`);if(C(t))return t;if(n===e||y(n)===n)return null}}function aO(e,t,n){let r=/* @__PURE__ */ new Map;for(let e of t){if(e.from!==`code`||!/\.[cm]?tsx?$/.test(e.sourcePath))continue;let t=r.get(e.sourcePath)??[];t.push(e),r.set(e.sourcePath,t)}if(r.size===0)return;let i=/* @__PURE__ */ new Map;for(let t of r.keys()){let n=iO(e,y(x(e,t)))??``;i.set(n,[...i.get(n)??[],t])}let a=!1;for(let[t,o]of i){let i=rO(y(x(e,o[0]??``)));if(!i)a=!0;else try{oO(i,e,t,o,r)}catch(r){n.push(`Endpoint types in ${S(e,t)||`the repo`} could not be read: ${r.message}`)}}a&&n.push(`TypeScript isn't installed in this repo (run your package manager's install), so endpoint request and response types weren't read.`)}function oO(e,t,n,r,i){let a=n?e.getParsedCommandLineOfConfigFile(n,{},{...e.sys,onUnRecoverableConfigFileDiagnostic:()=>{}}):null,o=e.createProgram({rootNames:r.map(e=>x(t,e)),options:{...a?.options??{allowJs:!0,strict:!0},noEmit:!0,skipLibCheck:!0}}),s=new sO(e,o.getTypeChecker());for(let n of r){let r=o.getSourceFile(x(t,n)),a=i.get(n)??[];if(!r)continue;let c=t=>{let n=s.route(t);if(n){let e=a.filter(e=>e.method===n.method&&(e.path===n.path||n.path!==`/`&&e.path.endsWith(n.path)));if(e.length){let t=s.handler(n.handler);for(let n of e)!n.request&&t.request&&(n.request=t.request),n.responses.length||(n.responses=t.responses)}}e.forEachChild(t,c)};c(r)}}var sO=class{ts;checker;constructor(e,t){this.ts=e,this.checker=t}route(e){let t=this.ts;if(!t.isCallExpression(e))return;let n=e.expression;if(!t.isPropertyAccessExpression(n))return;let r=n.name.text;if(!/^(get|post|put|patch|delete)$/.test(r))return;let[i]=e.arguments;if(!(e.arguments.length<2||!(t.isStringLiteral(i)||t.isNoSubstitutionTemplateLiteral(i))))return{method:r.toUpperCase(),path:BD(i.text),handler:e.arguments[e.arguments.length-1]}}fn(e,t=0){let n=this.ts;if(!(!e||t>4)){if(n.isArrowFunction(e)||n.isFunctionExpression(e)||n.isFunctionDeclaration(e)||n.isMethodDeclaration(e))return e;if(n.isIdentifier(e)||n.isPropertyAccessExpression(e)){let r=this.checker.getSymbolAtLocation(e);r&&r.flags&n.SymbolFlags.Alias&&(r=this.checker.getAliasedSymbol(r));let i=r?.valueDeclaration??r?.declarations?.[0];return i?n.isVariableDeclaration(i)?this.fn(i.initializer,t+1):this.fn(i,t+1):void 0}if(n.isCallExpression(e)){let n=this.fn(e.expression,t+1),r=n&&this.returned(n);if(r)return r;if(e.arguments.length)return this.fn(e.arguments[e.arguments.length-1],t+1)}}}returned(e){let t=this.ts,n=e.body;if(!n)return;if(!t.isBlock(n)){let e=t.isParenthesizedExpression(n)?n.expression:n;return t.isArrowFunction(e)||t.isFunctionExpression(e)?e:void 0}let r,i=e=>{if(!(r||t.isFunctionLike(e))){if(t.isReturnStatement(e)&&e.expression){let n=e.expression;t.isArrowFunction(n)||t.isFunctionExpression(n)?r=n:t.isIdentifier(n)&&(r=this.fn(n,3))}r||t.forEachChild(e,i)}};return t.forEachChild(n,i),r}handler(e){let t=this.ts,n=this.fn(e),r=/* @__PURE__ */ new Map,i=null;if(!n?.body)return{request:i,responses:[]};let a=(e,t)=>{e===void 0||r.has(e)||r.set(e,{status:e,description:nO[e]??``,body:t})},o=/* @__PURE__ */ new Set,s=(e,n,r,c,l,u)=>{if(o.has(e)||u>2)return!1;o.add(e);let d=!1,f=e=>e===void 0?200:t.isNumericLiteral(e)?Number(e.text):t.isIdentifier(e)?l.get(e.text):void 0,p=o=>{if(t.isCallExpression(o)&&t.isPropertyAccessExpression(o.expression)){let s=o.expression.name.text,l=o.expression.expression;!c&&t.isIdentifier(l)&&l.text===n?s===`json`?a(f(o.arguments[1]),this.payload(o.arguments[0])):(s===`body`||s===`text`||s===`html`)&&a(f(o.arguments[1]),null):!c&&t.isPropertyAccessExpression(l)&&t.isIdentifier(l.expression)&&l.expression.text===n&&l.name.text===`req`&&(s===`json`||s===`valid`&&this.isJsonTarget(o))?(d=!0,i??=this.requestAt(o,e)):c&&s===`json`&&(t.isIdentifier(l)&&l.text===r?a(200,this.payload(o.arguments[0])):t.isCallExpression(l)&&t.isPropertyAccessExpression(l.expression)&&l.expression.name.text===`status`&&t.isIdentifier(l.expression.expression)&&l.expression.expression.text===r&&a(f(l.arguments[0]),this.payload(o.arguments[0])))}if(c&&t.isPropertyAccessExpression(o)&&o.name.text===`body`&&t.isIdentifier(o.expression)&&o.expression.text===n&&(d=!0,i??=this.requestAt(o,e)),t.isCallExpression(o)){let a=c?r:n,f=o.arguments.findIndex(e=>t.isIdentifier(e)&&e.text===a);if(f>=0){let n=this.fn(o.expression),r=n?.parameters?.[f];if(n?.body&&r&&t.isIdentifier(r.name)){let a=/* @__PURE__ */ new Map;if(o.arguments.forEach((e,r)=>{let i=n.parameters[r],o=t.isNumericLiteral(e)?Number(e.text):t.isIdentifier(e)?l.get(e.text):void 0;i&&t.isIdentifier(i.name)&&o!==void 0&&a.set(i.name.text,o)}),s(n,c?``:r.name.text,c?r.name.text:``,c,a,u+1)){d=!0;let t=this.declarationOf(o);!i&&t&&(i=this.readFields(t,e))}}}}t.forEachChild(o,p)};return p(e.body),d},c=n.parameters.map(e=>t.isIdentifier(e.name)?e.name.text:``);return s(n,c[0]??``,c[1]??``,c.length>=2,/* @__PURE__ */ new Map,0),{request:i,responses:[...r.values()].sort((e,t)=>e.status-t.status)}}calls(e,t){let n=this.ts,r=!1,i=e=>{n.isCallExpression(e)&&n.isPropertyAccessExpression(e.expression)&&e.expression.name.text===t&&(r=!0),r||n.forEachChild(e,i)};return i(e),r}isJsonTarget(e){let[t]=e.arguments;return t&&this.ts.isStringLiteral(t)&&t.text===`json`}requestAt(e,t){let n=this.ts,r=e;for(;;){let e=r.parent;if(!e)break;if(n.isAwaitExpression(e)||n.isParenthesizedExpression(e)||n.isNonNullExpression(e))r=e;else if(n.isPropertyAccessExpression(e)&&e.name.text===`catch`&&e.parent&&n.isCallExpression(e.parent))r=e.parent;else break}let i=r.parent;return i&&(n.isAsExpression(i)||n.isTypeAssertionExpression(i))?this.request(this.checker.getTypeFromTypeNode(i.type),i):i&&n.isVariableDeclaration(i)?i.type&&!this.isLoose(this.checker.getTypeFromTypeNode(i.type))?this.request(this.checker.getTypeFromTypeNode(i.type),i):this.request(this.checker.getTypeAtLocation(e),e)||(n.isIdentifier(i.name)?this.parsedFrom(i.name.text,t)??this.handedOn(i.name.text,t)??this.readFields(i,t):this.readFields(i,t)):i&&n.isCallExpression(i)&&i.arguments.includes(r)?this.validated(i):this.request(this.checker.getTypeAtLocation(e),e)}parsedFrom(e,t){let n=this.ts,r=null,i=t=>n.isIdentifier(t)&&t.text===e,a=(e,t)=>{r||(t===0&&n.isAsExpression(e)&&i(e.expression)&&(r=this.request(this.checker.getTypeFromTypeNode(e.type),e)),t===1&&n.isCallExpression(e)&&e.arguments.some(i)&&/parse|validat|decode|assert/i.test(n.isPropertyAccessExpression(e.expression)?e.expression.name.text:e.expression.getText())&&(r=this.validated(e)),r||n.forEachChild(e,e=>a(e,t)))};return a(t.body,0),a(t.body,1),r}handedOn(e,t){let n=this.ts,r=this.checker,i=null,a=t=>{if(!i){if(n.isIdentifier(t)&&t.text===e&&t.parent){let e=t.parent;if(n.isCallExpression(e)&&e.arguments.includes(t)){let e=r.getContextualType(t);e&&(i=this.request(e,t))}else if(n.isSpreadAssignment(e)&&n.isObjectLiteralExpression(e.parent)&&n.isCallExpression(e.parent.parent)){let t=e.parent,a=r.getContextualType(t),o=a&&this.request(a,t);if(o){let a=/* @__PURE__ */ new Set;for(let i of t.properties)if(i!==e){if(n.isSpreadAssignment(i))for(let e of r.getPropertiesOfType(r.getTypeAtLocation(i.expression)))a.add(e.name);else i.name&&n.isIdentifier(i.name)&&a.add(i.name.text)}let s=o.fields.filter(e=>!a.has(e.name));s.length&&(i={...o,fields:s,example:Object.fromEntries(Object.entries(o.example??{}).filter(([e])=>!a.has(e)))})}}}i||n.forEachChild(t,a)}};return a(t.body),i}declarationOf(e){let t=this.ts,n=e;for(;n.parent&&(t.isAwaitExpression(n.parent)||t.isParenthesizedExpression(n.parent)||t.isAsExpression(n.parent));)n=n.parent;return n.parent&&t.isVariableDeclaration(n.parent)?n.parent:void 0}readFields(e,t){let n=this.ts,r=/* @__PURE__ */ new Map,i=(e,t)=>{let n=r.get(e);if(n?n.type!==`unknown`:r.size>=60)return;let i=t&&this.usedAs(t);if(n&&!i)return;let a=i?this.literals(i):null;r.set(e,{name:e,type:i?this.typeName(i,0):`unknown`,required:!1,...a?{values:a}:{}})},a=e=>{let r=[],i=t=>{n.isIdentifier(t)&&t.text===e&&t.parent&&!n.isBindingElement(t.parent)&&r.push(t),n.forEachChild(t,i)};return i(t.body),r},o=e=>{for(let t of e.elements){let e=t.propertyName??t.name;if(!n.isIdentifier(e)&&!n.isStringLiteral(e))continue;let r=n.isIdentifier(t.name)?t.name.text:void 0;i(e.text,void 0);for(let t of r?a(r):[])i(e.text,t)}};if(n.isObjectBindingPattern(e.name))o(e.name);else if(n.isIdentifier(e.name))for(let t of a(e.name.text)){let e=t.parent;n.isPropertyAccessExpression(e)&&e.expression===t?i(e.name.text,e):n.isVariableDeclaration(e)&&e.initializer===t&&n.isObjectBindingPattern(e.name)&&o(e.name)}if(r.size===0)return null;let s=[...r.values()];return{contentType:`application/json`,fields:s,example:Object.fromEntries(s.map(e=>[e.name,e.values?.[0]??(e.type===`string`?`string`:e.type===`number`?0:e.type!==`boolean`&&null)]))}}usedAs(e){let t=this.ts,n=this.checker,r=e.parent,i;if(r&&t.isShorthandPropertyAssignment(r)){let e=n.getContextualType(r.parent),t=e&&n.getPropertyOfType(e,r.name.text);i=t&&n.getTypeOfSymbolAtLocation(t,r)}else i=n.getContextualType(e);return i&&!this.isLoose(i)?i:void 0}validated(e){let t=this.checker.getTypeAtLocation(e);if(this.isLoose(t))return null;let n=this.checker.getPropertyOfType(this.checker.getNonNullableType(t.isUnion?.()?t.types.find(e=>e.getProperty(`data`))??t:t),`data`),r=t.isUnion?.()?t.types.some(e=>e.getProperty(`success`)):t.getProperty?.(`success`);if(n&&r){let t=this.checker.getNonNullableType(this.checker.getTypeOfSymbolAtLocation(n,e));return this.request(t,e)}return this.request(t,e)}request(e,t){let n=this.payloadOfType(e,t);return n&&(n.fields.length||Array.isArray(n.example))?n:null}payload(e){return e?this.payloadOfType(this.checker.getTypeAtLocation(e),e):null}isLoose(e){let t=this.ts.TypeFlags;return!e||!!(e.flags&(t.Any|t.Unknown|t.Never|t.Void|t.Undefined|t.TypeParameter))}payloadOfType(e,t){let n=(e&&this.checker.getAwaitedType?.(e))??e;if(this.isLoose(n))return null;let[r,...i]=this.present(n),a=r&&i.length===0?r:n,o=this.element(a)??a,s=this.isObject(o)?this.fields(o,t):[],c=this.present(o),l=c.length>1&&c.every(e=>this.isObject(e))?c.slice(0,12).map((e,n)=>({name:this.variantName(e,t)??`Option ${n+1}`,fields:this.fields(e,t)})):void 0;return{contentType:`application/json`,fields:l?.[0]?.fields??s,...l?{variants:l}:{},example:this.example(n,t,0)}}variantName(e,t){let n=this.checker.getPropertiesOfType(e).flatMap(e=>{let n=this.checker.getTypeOfSymbolAtLocation(e,t);return n.isStringLiteral?.()||n.isNumberLiteral?.()?[[e.name,String(n.value)]]:[]}),r=n.find(([e])=>/^(event|type|kind|status|object)$/i.test(e))??n[0];if(r)return`${r[0]}: ${r[1]}`;let i=e.aliasSymbol?.name??e.symbol?.name;return i&&!i.startsWith(`__`)?i:void 0}element(e){let t=this.checker;if(t.isArrayType?.(e)||t.isTupleType?.(e))return t.getTypeArguments(e)[0]}isObject(e){let t=this.ts.TypeFlags;return e.isUnion?.()?e.types.every(e=>this.isObject(e)):!!(e.flags&(t.Object|t.Intersection))&&!this.element(e)&&!this.isDate(e)}isDate(e){return e.symbol?.name===`Date`}fields(e,t){let n=this.ts;return this.checker.getPropertiesOfType(e).slice(0,60).map(e=>{let r=this.checker.getTypeOfSymbolAtLocation(e,t),i=!!(e.flags&n.SymbolFlags.Optional)||r.isUnion?.()&&r.types.some(e=>e.flags&n.TypeFlags.Undefined),a=this.literals(r),o=r.isUnion?.()&&r.types.some(e=>e.flags&n.TypeFlags.Null),s=n.displayPartsToString(e.getDocumentationComment(this.checker)).trim().split(`
380
+ `)[0];return{name:e.name,type:this.typeName(r,0),required:!i,...o?{nullable:!0}:{},...s?{description:s}:{},...a?{values:a}:{}}})}literals(e){let t=this.present(e),n=t.flatMap(e=>e.isStringLiteral?.()||e.isNumberLiteral?.()?[String(e.value)]:[]);return n.length>0&&n.length===t.length?n:null}present(e){let t=this.ts.TypeFlags;return(e.isUnion?.()?e.types:[e]).filter(e=>!(e.flags&(t.Null|t.Undefined)))}typeName(e,t){let n=this.ts.TypeFlags,r=this.present(e);if(r.length===0)return`null`;if(r.length>1)return r.every(e=>e.flags&n.StringLike)?`string`:r.every(e=>e.flags&n.NumberLike)?`number`:r.every(e=>e.flags&n.BooleanLike)?`boolean`:[...new Set(r.map(e=>this.typeName(e,t+1)))].slice(0,4).join(` | `);let i=r[0];if(i.flags&n.StringLike)return`string`;if(i.flags&n.NumberLike)return`number`;if(i.flags&n.BooleanLike)return`boolean`;if(i.flags&n.BigIntLike)return`integer`;if(this.isDate(i))return`date-time`;let a=this.element(i);if(a)return t>4?`array`:`${this.typeName(a,t+1)}[]`;let o=i.aliasSymbol?.name??i.symbol?.name;return o&&!o.startsWith(`__`)?o:i.flags&n.Object?`object`:this.checker.typeToString(i).slice(0,60)}example(e,t,n){let r=this.ts.TypeFlags,i=this.present(e)[0];if(!i||n>4)return null;if(i.isStringLiteral?.()||i.isNumberLiteral?.())return i.value;if(i.flags&r.StringLike)return`string`;if(i.flags&r.NumberLike)return 0;if(i.flags&r.BooleanLike)return!1;if(this.isDate(i))return`2026-01-01T00:00:00Z`;let a=this.element(i);return a?[this.example(a,t,n+1)]:i.flags&(r.Object|r.Intersection)?Object.fromEntries(this.checker.getPropertiesOfType(i).slice(0,20).map(e=>[e.name,this.example(this.checker.getTypeOfSymbolAtLocation(e,t),t,n+1)])):null}};async function cO(e,{fromDisk:t=!1}={}){let n=_.resolve(e);if(!(await p(n)).isDirectory())throw Error(`${n} is not a folder`);let r=(/* @__PURE__ */ new Date()).toISOString(),i=[],a=t?null:await HS(n);!t&&!a&&C(_.join(n,`.git`))&&i.push(`No main or master branch found: read the files on disk instead`);let o=a?await Dx(n,a.ref):await Ex(n),s=await DS(o),[c,l,u,d,f,m,h,g]=await Promise.all([WS(n,i,a?.ref??null),MD(o),kw(o),kS(o,s),IS(o),aD(o),kE(o),tO(o)]),v=await ET(o,u),y=await yE(o,v,c.name),b=new Set(v.map(e=>e.provider)),x=NT([...h.tables,...h.objects],[...v,...y.resources.filter(e=>!b.has(e.provider))]).map(e=>{let t=y.projects.get(e.provider);return t?{...e,projects:[...t].sort()}:e}),S=g.filter(e=>!m.some(t=>UD(t.method,t.path)===UD(e.method,e.path)));return aO(n,S,o.warnings),{scannedAt:r,root:n,repo:{...c,languages:xE(o.files),readme:l},dependencies:u,docs:d,agentInstructions:f,contracts:[...m,...S,...h.tables,...h.objects,...y.contracts],resources:x,docsConfig:{alwaysLoad:!!s.alwaysLoad},warnings:[...i,...o.warnings]}}function lO(e){let t=(e,t,n=`${t}s`)=>e?`${e} ${e===1?t:n}`:``;return[t(e.docs,`doc`)+(e.docsChanged&&e.docsChanged<e.docs?` (${e.docsChanged} changed)`:``),t(e.dependencies,`dependency`,`dependencies`),t(e.contracts,`contract`),t(e.resources,`service`)].filter(Boolean).join(` · `)||`nothing to import yet`}function uO(e){let{scannedRef:t,headSha:n}=e.repo;if(!t)return`files on disk`;let r=t.replace(/^origin\//,``);return n?`${r} @ ${n.slice(0,7)}`:r}async function dO(e,t,{quiet:n=!1,source:r=`connector`,name:i,restore:a,allowOlder:o}={}){await US(e);let s=await cO(e),c=(i??t.repoName)?.trim();c&&Object.assign(s.repo,{name:c,nameFromConfig:!0}),a&&Object.assign(s.repo,{restore:!0}),Object.assign(s.repo,{cliVersion:nx,...o?{allowOlder:!0}:{}});let l=await new Wr(await dx()).call(`sync_repo`,{p_project:t.projectId,p_snapshot:s,p_source:r});if(!n){Kx(`Synced ${Hx(s.repo.name)} to ${Hx(t.name)} ${Q(`from ${uO(s)}`)}`),qx(Q(lO(l)));for(let e of s.warnings)qx(Q(`! ${e}`))}return{snapshot:s,result:l}}async function fO(e){return zS(await Ex(e))}const pO=26214400,mO=e=>`${(e/1024/1024).toFixed(1)} MB`;async function hO(e,t,{quiet:n=!1}={}){if(!t.folder)return;let{docs:r,unsupported:i}=await fO(e),a=e=>Buffer.byteLength(e.body),o=r.reduce((e,t)=>e+a(t),0);if(o>pO){let t=/* @__PURE__ */ new Map;for(let e of r){let n=e.path.includes(`/`)?`${e.path.split(`/`)[0]}/`:e.path;t.set(n,(t.get(n)??0)+a(e))}let n=[...t].sort((e,t)=>t[1]-e[1]).slice(0,3).map(([e,t])=>`${e} (${mO(t)})`).join(`, `);throw new Zx(`The documents outside the repos add up to ${mO(o)}, over the ${mO(pO)} a sync takes. The biggest: ${n}. List what Quirl should skip in ${x(v(e),`.quirlignore`)}, like .gitignore.`)}let s=new Wr(await dx()),c={p_project:t.projectId,p_folder:t.folder},l=await s.call(`folder_doc_hashes`,c),u=r.filter(e=>l[e.path]!==e.contentHash),d=0;for(let t=0;t<u.length;){let n=[],r=0;for(;t<u.length;){let e=u[t];if(n.length&&r+a(e)>2097152)break;n.push(e),r+=a(e),t++}let i=await s.call(`sync_folder_docs`,{...c,p_folder_name:v(e),p_docs:n});d+=i.docsChanged}let f={...await s.call(`sync_folder_finish`,{...c,p_paths:r.map(e=>e.path)}),docsChanged:d};return n||(Kx(`Synced the documents in ${Hx(`${v(e)}/`)} outside the repos`),qx(Q(`${f.docs} docs (${f.docsChanged} changed${f.archived?`, ${f.archived} removed`:``})`)),i.length&&qx(Q(`! ${i.length} PDF/Office files skipped: only markdown and text are read for now`))),f}async function gO(e={}){let t=await hx();if(!t)throw new Zx("This folder isn't linked to a Quirl project. Run `quirl init`.");let n=fx(t.link),r=n.length?n.map(e=>({root:x(t.root,e.path),name:e.name})):[{root:t.root,name:void 0}],i=r.length+ +!!t.link.folder,a=0;for(let{root:o,name:s}of r)try{let r=n.length?await hx(o):null,i=s??(r?.root===o?r.link.repoName:void 0);await dO(o,t.link,{...e,name:i})}catch(e){if(a++,i===1)throw e;let n=S(t.root,o)||`.`;console.error(`${Wx(`✗`)} ${n}: ${Nx(e)}`)}if(t.link.folder)try{await hO(t.root,t.link,e)}catch(e){a++,console.error(`${Wx(`✗`)} documents in ${v(t.root)}/: ${Nx(e)}`)}if(a)throw new Zx(`${a} of ${i} parts didn't sync.`)}async function _O(e){let t=px(),n=await aS(t),r=n.length?n:[t],i=r.length>1||r[0]!==t,a=e=>S(t,e)||v(t),o=h(),s=t.startsWith(o)?`~${t.slice(o.length)}`:t;if(console.log(`\n🌀 ${Hx(`Quirl`)} ${Q(`·`)} connecting ${Hx(s)}`),i&&(Jx(`📁`,`Found ${r.length} ${r.length===1?`repo`:`repos`}`),Yx(Q(r.map(a).join(` · `))),!await $x(` Import all of them into one project?`,!0)))throw new Zx("Nothing imported. Run `quirl init` inside the repo you want instead.");let c=!1;if(i&&!n.includes(t)){let{docs:e,unsupported:n}=await fO(t);if(e.length){Jx(`📄`,`Also found ${e.length} ${e.length===1?`document`:`documents`} outside the repos`);for(let t of e.slice(0,8))Yx(Q(t.path));e.length>8&&Yx(Q(`…and ${e.length-8} more`)),n.length&&Yx(Q(`(${n.length} PDF/Office files can't be read yet and are skipped)`)),c=await $x(` Import them too? Everyone on the project will be able to read them.`,!0)}}await cx()||await yS({quiet:!0});let l=await yO((await new Wr(await dx()).whoami()).projects,e.project??(await hx(t))?.link.project);if(l.role===`stakeholder`)throw new Zx(`You're a stakeholder on ${l.name}; ask an admin or dev to run \`quirl init\`.`);let u={project:l.slug,projectId:l.id,name:l.name};Jx(`🔗`,`Linked to ${Hx(l.name)} ${Q(`· ${l.organization}`)}`);let d=e.claude!==!1,f=e.hooks??await $x(` Sync with Quirl on every git push?`,!0);Jx(`📦`,`Importing docs, dependencies and schemas`);let p=[],m=i?await hx(t):null,g=new Map((m?.root===t?fx(m.link):[]).filter(e=>e.name).map(e=>[e.path,e.name]));for(let e of r){let t=Xx(`Reading ${a(e)}…`);try{let n=await hx(e),r=(n?.root===e?n.link.repoName:void 0)??g.get(a(e));r&&g.set(a(e),r);let i=r?{...u,repoName:r}:u;await gx(e,i);let{snapshot:o,result:s}=await dO(e,i,{quiet:!0,restore:!0});d&&await vO(e,l.name),f&&await vS(e),t.stop(),Yx(`${Ux(`✓`)} ${Hx(a(e))} ${Q(`(${uO(o)})`)} ${Q(lO(s))}`);for(let e of o.warnings)Yx(Q(` ! ${e}`));p.push(e)}catch(n){t.stop(),Yx(`${Wx(`✗`)} ${Hx(a(e))} ${Nx(n)}`)}}if(!p.length)throw new Zx(`No repo was imported.`);if(i){let e=p.map(e=>{let t=g.get(a(e));return t?{path:a(e),name:t}:a(e)}),n=m,r={...u,repos:e,folder:c?n?.root===t&&n.link.folder||ee():void 0};if(await gx(t,r),c)try{let e=await hO(t,r,{quiet:!0});Yx(`${Ux(`✓`)} ${Hx(`documents outside the repos`)} ${Q(`${e?.docs??0} docs`)}`)}catch(e){Yx(`${Wx(`✗`)} ${Hx(`documents outside the repos`)} ${Nx(e)}`)}d&&!p.includes(t)&&await vO(t,l.name,p.map(a))}let _=lS().portable;d&&(Jx(`🤖`,`Connected Claude Code`),Yx(Q(`.mcp.json the quirl tools`)),Yx(Q(`.claude/settings.json the briefing, loaded as each session starts`)),Yx(Q(`CLAUDE.md when to use Quirl`))),f&&Jx(`🪝`,`Quirl syncs on every ${Hx(`git push`)}`);let y=r.length-p.length,b=`.quirl .mcp.json .claude/settings.json CLAUDE.md`;Jx(y?`⚠️ `:`🎉`,y?`Done, but ${y} of ${r.length} repos failed. Fix them and run ${Hx(`quirl init`)} again.`:Hx(`All set!`)),Yx(d&&!_?Q(`Don't commit ${b} yet: they point at this checkout until the CLI is installed.`):`${Q(`1.`)} Commit what was added${i?` in each repo`:``}: ${Gx(`git add ${b}`)}`),Yx(`${Q(d&&!_?`→`:`2.`)} Start Claude Code here and approve the ${Hx(`quirl`)} server when it asks.`),i&&!p.includes(t)&&Yx(Q("Run `quirl sync` here to sync every repo at once.")),console.log(``)}async function vO(e,t,n=[]){await hS(e),await gS(e),await _S(e,t,n)}async function yO(e,t){if(!e.length)throw new Zx(`You aren't on any Quirl project yet. Ask an admin to invite you.`);if(t){let n=e.find(e=>e.slug===t||e.id===t);if(!n)throw new Zx(`No project "${t}" among yours: ${e.map(e=>e.slug).join(`, `)}.`);return n}if(e.length===1)return e[0];Jx(`🗂️ `,`Which project is this part of?`);for(let[t,n]of e.entries())Yx(`${Gx(String(t+1))} ${n.name} ${Q(`· ${n.organization} · ${n.role}`)}`);let n=e[Number(await Qx(` Project [1-${e.length}]: `))-1];if(!n)throw new Zx("No project picked. Run `quirl init --project <slug>`.");return n}const bO=`${Hx(`quirl`)} ${Q(nx)}: connect a repo to Quirl
381
381
 
382
382
  quirl init [--project <slug>] [--hooks|--no-hooks] [--no-claude]
383
383
  Link this repo, import it, and connect Claude Code
384
- quirl sync Send the latest docs, dependencies and schemas
384
+ quirl sync [--allow-older]
385
+ Send the latest docs, dependencies and schemas
386
+ (--allow-older: even if a newer quirl synced it last)
385
387
  quirl context Print the project briefing agents load
386
388
  quirl export [folder] [--all]
387
389
  Write the docs written in Quirl as markdown files
@@ -390,4 +392,4 @@ n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2
390
392
  quirl logout Forget this machine's key
391
393
  quirl whoami Show who you're signed in as
392
394
  quirl mcp Run the MCP server (used by Claude Code)
393
- `;async function dO(){let[e,...n]=process.argv.slice(2),{values:r,positionals:i}=t({args:n,allowNegative:!0,allowPositionals:!0,options:{all:{type:`boolean`},project:{type:`string`},hooks:{type:`boolean`},claude:{type:`boolean`},quiet:{type:`boolean`},hook:{type:`boolean`},source:{type:`string`}}});switch(e){case`init`:return sO({project:r.project,hooks:r.hooks,claude:r.claude});case`sync`:return oO({quiet:r.quiet,source:r.source});case`export`:return eS({dir:i[0],all:r.all});case`context`:return Fx({hook:r.hook});case`login`:await hS();return;case`logout`:return await lx(),Hx(`Signed out on this machine.`),Ux(Q(`The key still exists until you revoke it under Organization > Access keys in Quirl (${rx().appUrl}).`));case`whoami`:{if(!await sx())throw new qx("Not signed in. Run `quirl login`.");let e=await new Wr(await ux()).whoami();console.log(Rx(e.email));for(let t of e.projects)Ux(`${t.name} ${Q(`${t.slug} · ${t.organization} · ${t.role}`)}`);let t=await mx();t&&Ux(Q(`This folder: ${t.link.name}`));return}case`mcp`:{let e=await mx();if(!e)throw new qx("This folder isn't linked to a Quirl project. Run `quirl init`.");return ex({...await ux(),project:e.link.projectId,version:tx})}case void 0:case`help`:case`--help`:case`-h`:process.stdout.write(uO);return;case`--version`:case`-v`:return console.log(tx);default:throw new qx(`Unknown command "${e}".\n\n${uO}`)}}dO().catch(e=>{let t=e instanceof qx?e.message:Mx(e);console.error(`${Bx(`✗`)} ${t}`),process.exit(1)});export{};
395
+ `;async function xO(){let[e,...n]=process.argv.slice(2),{values:r,positionals:i}=t({args:n,allowNegative:!0,allowPositionals:!0,options:{all:{type:`boolean`},project:{type:`string`},hooks:{type:`boolean`},claude:{type:`boolean`},quiet:{type:`boolean`},hook:{type:`boolean`},source:{type:`string`},"allow-older":{type:`boolean`}}});switch(e){case`init`:return _O({project:r.project,hooks:r.hooks,claude:r.claude});case`sync`:return gO({quiet:r.quiet,source:r.source,allowOlder:r[`allow-older`]});case`export`:return iS({dir:i[0],all:r.all});case`context`:return zx({hook:r.hook});case`login`:await yS();return;case`logout`:return await ux(),Kx(`Signed out on this machine.`),qx(Q(`The key still exists until you revoke it under Organization > Access keys in Quirl (${ix().appUrl}).`));case`whoami`:{if(!await cx())throw new Zx("Not signed in. Run `quirl login`.");let e=await new Wr(await dx()).whoami();console.log(Hx(e.email));for(let t of e.projects)qx(`${t.name} ${Q(`${t.slug} · ${t.organization} · ${t.role}`)}`);let t=await hx();t&&qx(Q(`This folder: ${t.link.name}`));return}case`mcp`:{let e=await hx();if(!e)throw new Zx("This folder isn't linked to a Quirl project. Run `quirl init`.");let t=await Lx();return tx({...await dx(),project:e.link.projectId,version:nx,...t?{notice:Rx(t)}:{}})}case void 0:case`help`:case`--help`:case`-h`:process.stdout.write(bO);return;case`--version`:case`-v`:return console.log(nx);default:throw new Zx(`Unknown command "${e}".\n\n${bO}`)}}xO().catch(e=>{let t=e instanceof Zx?e.message:Nx(e);console.error(`${Wx(`✗`)} ${t}`),process.exit(1)});export{};