cc-safety-net 2.0.0 → 2.0.3

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.
@@ -1,9 +1,9 @@
1
1
  // cc-safety-net managed Amp plugin. Do not edit. Reinstall with: npx -y cc-safety-net install --amp
2
- // version: 2.0.0
2
+ // version: 2.0.3
3
3
  // @bun
4
- var OO=Object.defineProperty;var MO=($)=>$;function NO($,J){this[$]=MO.bind(null,J)}var B2=($,J)=>{for(var Q in J)OO($,Q,{get:J[Q],enumerable:!0,configurable:!0,set:NO.bind(J,Q)})};import{randomBytes as GM}from"crypto";import{appendFileSync as HM,mkdirSync as ZM}from"fs";import{homedir as LM,userInfo as OM}from"os";import{isAbsolute as MM,join as IJ}from"path";var FO=[/\bgh[pousr]_[A-Za-z0-9]{20,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,/\bglpat-[A-Za-z0-9_-]{20,}\b/g,/\bxox[abeprs]-[A-Za-z0-9-]{20,}\b/g,/\bnpm_[A-Za-z0-9_]{20,}\b/g,/\bpypi-[A-Za-z0-9_-]{20,}\b/g,/\b[rs]k_(?:live|test)_[A-Za-z0-9_]{20,}\b/g,/\bsk-[A-Za-z0-9_-]{20,}\b/g,/\bsk_[A-Za-z0-9]{20,}\b/g,/\bgsk_[A-Za-z0-9]{52,}\b/g,/\bxai-[A-Za-z0-9_-]{80,}\b/g,/\bpplx-[A-Za-z0-9_-]{20,}\b/g,/\bbastn_[A-Za-z0-9]{16,}\b/g,/\btgp_v1_[A-Za-z0-9_-]{43,}\b/g,/\bflp_[A-Za-z0-9]{10,}\b/g,/\bwfr_[A-Za-z0-9]{20,}\b/g,/\bfwp?_[A-Za-z0-9_-]{20,}\b/g,/\btp-[A-Za-z0-9_-]{20,}\b/g,/\bpsk-[A-Za-z0-9_-]{8,}-[A-Za-z0-9_-]{8,}\b/g,/\b[a-f0-9]{32}\.[A-Za-z0-9]{16}\b/g];function j0($){let J=$.replace(/\b((?:DATABASE|POSTGRES|POSTGRESQL|MYSQL|MARIADB|REDIS|MONGO(?:DB)?|DB)_DSN|CONNECTION_STRING)=("[^"]*"|'[^']*'|[^\s]+(?:\s+[A-Z_][A-Z0-9_]*=[^\s]+)*)/gi,"$1=<redacted>").replace(/\b((?:DATABASE|POSTGRES|POSTGRESQL|MYSQL|MARIADB|REDIS|MONGO(?:DB)?|DB)_(?:URL|URI|CONNECTION_STRING))=("[^"]*"|'[^']*'|[^\s]+)/gi,"$1=<redacted>").replace(/\b([A-Z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASS|KEY|CREDENTIALS)[A-Z0-9_]*)=("[^"]*"|'[^']*'|[^\s]+)/gi,"$1=<redacted>");return VO(J)}function VO($){let J=$.replace(/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/gi,"<redacted>").replace(/((?:(['"])(?:authorization|cookie|x-api-key|api-key)\2|(?:authorization|cookie|x-api-key|api-key))\s*:\s*)(['"])(?:\\[^\r\n]|(?!\3)[^\\\r\n])*\3/gi,"$1$3<redacted>$3").replace(/(['"]?\s*(?:authorization|cookie|x-api-key|api-key)\s*:(?!\s*(?:"<redacted>"|'<redacted>'))\s*)([^'"\r\n]+)(['"]?)/gi,"$1<redacted>$3").replace(/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/:@]+):([^\s@/]+)@/gi,"$1<redacted>:<redacted>@").replace(/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+)@/gi,"$1<redacted>@").replace(/(^|[\s?&;|])((?:x-amz-signature|x-goog-signature|sig|signature)=)(?:"[^"\r\n]*"|'[^'\r\n]*'|[^&#\s'"`;|<>()]*)/gi,"$1$2<redacted>").replace(/(^|\s)((?:-u|--user)(?:\s+|=))([^\s:]+):([^\s]+)/g,"$1$2<redacted>:<redacted>");for(let Q of FO)J=J.replace(Q,"<redacted>");return J.replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\b/g,"<redacted>").replace(/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,"<redacted>")}import{lstatSync as EK,readdirSync as aO,readFileSync as wK,rmdirSync as tO,statSync as SK,unlinkSync as eO,utimesSync as $M,writeFileSync as JM}from"fs";import{dirname as QM,join as l2}from"path";var j6=30,HJ=1,ZJ=365;function R6($){if(typeof $!=="number"||!Number.isInteger($))return 30;if($<1)return 1;return $>365?365:$}import{homedir as kO}from"os";import{dirname as l0,isAbsolute as gO,join as p0,relative as yO,resolve as b0,sep as xO}from"path";import{closeSync as _O,constants as OK,fstatSync as DO,fsyncSync as AE,lstatSync as MK,mkdirSync as EE,openSync as zO,readdirSync as SE,readFileSync as IO,realpathSync as b6,renameSync as CE,rmdirSync as TE,statSync as jO,unlinkSync as wE,writeFileSync as vE}from"fs";import{isAbsolute as NK,join as FK,normalize as RO,parse as bO,relative as LJ,resolve as OJ,sep as MJ}from"path";var PO=Symbol("PolicyFilesystemScope"),AO=Symbol("PolicyFilesystemTarget"),EO=OK.O_NOFOLLOW??0;class W1 extends Error{constructor($){super(`Unable to access ${$} filesystem safely.`);this.name="PolicyFilesystemError"}}function m0($,J){return{[PO]:!0,root:OJ($),label:J}}function VK($,J){let Q=RO(J);if(J===""||NK(J)||Q===".."||Q.startsWith(`..${MJ}`))throw new W1($.label);return{[AO]:!0,scope:$,relativePath:Q,path:FK($.root,Q)}}function R0($,J){let Q=LJ($.root,OJ(J));return VK($,Q)}function A6($,J="rules policy"){let Q=OJ($),X=bO(Q).dir;return VK(m0(X,J),LJ(X,Q))}function q2($){try{if(!P6($,!1).exists)return null;let Q=zO($.path,OK.O_RDONLY|EO);try{let X=DO(Q);if(!X.isFile())throw new W1($.scope.label);let Y=IO(Q,"utf-8"),W=MK($.path);if(!W.isFile()||W.isSymbolicLink()||X.dev!==W.dev||X.ino!==W.ino)throw new W1($.scope.label);return P6($,!1),Y}finally{_O(Q)}}catch(J){TO($.scope.label,J)}}function _K($,J){if($.path===J.path)return!0;try{if(!P6($,!1).exists||!P6(J,!1).exists)return!1;return b6($.path)===b6(J.path)}catch(Q){if(Q instanceof W1)throw Q;throw new W1($.scope.label)}}function P6($,J,Q="file"){let X=SO($.scope);if(!X)return{exists:!1};let Y=$.relativePath.split(MJ);for(let W of Y.keys()){let K=FK($.scope.root,...Y.slice(0,W+1)),B=DK(K);if(!B){if(W===Y.length-1&&J)return{exists:!1};return{exists:!1}}if(B.isSymbolicLink())throw new W1($.scope.label);if(W<Y.length-1&&!B.isDirectory())throw new W1($.scope.label);if(W===Y.length-1&&(Q==="file"?!B.isFile():!B.isDirectory()))throw new W1($.scope.label);CO(X,b6(K),$.scope.label)}return{exists:!0}}function SO($){if(!DK($.root))return null;if(!jO($.root).isDirectory())throw new W1($.label);return b6($.root)}function CO($,J,Q){let X=LJ($,J);if(X===".."||X.startsWith(`..${MJ}`)||NK(X))throw new W1(Q)}function DK($){try{return MK($)}catch(J){if(wO(J)&&J.code==="ENOENT")return null;throw J}}function TO($,J){if(J instanceof W1)throw J;throw new W1($)}function wO($){return $ instanceof Error&&"code"in $}var Y0=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/,NJ="rulebook.json",FJ=".cc-safety-net/rules";var zK=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)#(.+)$/;var vO=/^[A-Za-z0-9._-]+$/,fO=".cc-safety-net/rules".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),hO="rulebook.json".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),IK=new RegExp(`^${fO}/(${Y0.source.slice(1,-1)})/${hO}$`);function jK($){return`.cc-safety-net/rules/${$}/rulebook.json`}function o4($){if(S6($))try{return E6($),null}catch(J){return J instanceof Error?J.message:String(J)}return Y0.test($)?null:`Local rulebook sources must be bare names matching ${Y0}: ${$}`}function E6($){if($.startsWith("github:"))throw Error(`Invalid rulebook source: ${$}`);let J=$.match(zK);if(!J?.[1]||!J[2]||!J[3])throw Error(`Invalid GitHub rulebook source: ${$}`);let[Q,X,...Y]=J[3].split("/");if(!Q||!vO.test(Q))throw Error(`GitHub rulebook refs must be a single path segment: ${$}`);if(!X||Y.length>0||!Y0.test(X))throw Error(`GitHub rulebook sources must be owner/repo#ref/<rulebook-name>: ${$}`);return{owner:J[1],repo:J[2],ref:Q,path:jK(X),name:X}}function S6($){return zK.test($)}var bK="rule.json",C6="policy.json",uO="rule.lock";var PK=".cc-safety-net",mO="rules",RK="cache",lO="CC_SAFETY_NET_HOME",c0="`cc-safety-net rule sync`";function pO($){return b0($??process.cwd(),FJ)}function cO($){return p0(pO($),bK)}function U2($){return $?.userConfigDir??($?.userConfigPath?l0($.userConfigPath):p0(dO(),mO))}function dO(){let $=process.env[lO];return $?b0($):p0(kO(),PK)}function rO($){return p0(U2($),bK)}function n4($){return p0(l0($),uO)}function AK($){let J=$.userConfigPath??rO($),Q=$.projectConfigPath??cO($.cwd),X=iO(J,$),Y=oO(Q,$);return{userConfigPath:J,projectConfigPath:Q,userLockPath:n4(J),projectLockPath:n4(Q),userScope:X,projectScope:Y,userConfigTarget:R0(X,J),projectConfigTarget:R0(Y,Q),userLockTarget:R0(X,n4(J)),projectLockTarget:R0(Y,n4(Q))}}function iO($,J){let Q=J.userConfigPath?l0(l0(b0(J.userConfigPath))):l0(b0(J.userConfigDir??U2(J)));return m0(Q,"user policy")}function oO($,J){let Q=b0(J.cwd??process.cwd()),X=b0($),Y=yO(Q,X);if(Y!==".."&&!Y.startsWith(`..${xO}`)&&!gO(Y))return m0(Q,"project policy");return m0(l0(l0(X)),"project policy")}function VJ($,J){let Q=$.digest.startsWith("sha256:")?$.digest.slice(7):$.digest;return p0(sO(J),"rulebooks",`${nO($)}--${Q.slice(0,12)}`,NJ)}function _J($,J){let Q=J;return{cacheConfigDir:$,cwd:J.cwd,global:Q.global}}function nO($){return($.kind==="github"&&$.display_ref?`${$.owner}/${$.repo}#${$.display_ref}/${$.name}`:$.spec).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"rulebook"}function sO($){let J=$?.cacheConfigDir??U2($),Q=$;if(Q&&!Q.global&&Q.cwd&&b0(J)===b0(Q.cwd))return p0(b0(Q.cwd),PK,RK);return p0(l0(J),RK)}var zJ=86400000,XM=".last-prune",YM=/^\d{4}-\d{2}$/,WM=/^((\d{4}-\d{2})-\d{2})-.+\.jsonl$/,CK=($)=>Math.floor($/zJ);function KM($){try{let J=l2(QM(U2($)),C6),Q=JSON.parse(wK(J,"utf-8"));return R6(Q?.audit?.retention_days)}catch{return j6}}function vK($,J=()=>new Date){try{let Q=J().getTime();if(!SK($,{throwIfNoEntry:!1})?.isDirectory())return;let X=l2($,XM),Y=SK(X,{throwIfNoEntry:!1})?.mtimeMs;if(Y!==void 0&&CK(Y)===CK(Q))return;let W=Q-KM()*zJ,K=new Date(Q).toISOString().slice(0,7);for(let B of DJ($)){if(B.isDirectory()){BM(l2($,B.name),W,K);continue}if(B.isFile()&&B.name.endsWith(".jsonl"))qM(l2($,B.name),W)}JM(X,"",{mode:384}),$M(X,Q/1000,Q/1000)}catch{}}function BM($,J,Q){for(let X of DJ($)){if(!X.isDirectory()||!YM.test(X.name))continue;let Y=l2($,X.name);for(let W of DJ(Y)){if(!W.isFile())continue;let K=WM.exec(W.name);if(!K||K[2]!==X.name)continue;let B=Date.parse(`${K[1]}T00:00:00.000Z`)+zJ;if(!Number.isFinite(B)||B>=J)continue;fK(l2(Y,W.name))}if(X.name!==Q)TK(Y)}TK($)}function qM($,J){try{let Q=EK($);if(Q.mtimeMs>=J)return;let X=wK($,"utf-8").split(`
5
- `).filter((Y)=>Y.trim()).map(UM);if(X.length===0)return;if(X.some((Y)=>Y===void 0||Y>=J))return;if(EK($).mtimeMs!==Q.mtimeMs)return;fK($)}catch{}}function UM($){try{let J=JSON.parse($).ts,Q=typeof J==="string"?Date.parse(J):Number.NaN;return Number.isFinite(Q)?Q:void 0}catch{return}}function DJ($){try{return aO($,{withFileTypes:!0,encoding:"utf8"})}catch{return[]}}function fK($){try{eO($)}catch{}}function TK($){try{tO($)}catch{}}var NM="2.0.0",FM=1e4,VM=2000,_M=256,DM=32768;function zM($){let J=$.trim();if(!J)return null;let Q=J.replace(/[^A-Za-z0-9_.-]+/g,"_");if(Q=Q.replace(/^[._-]+|[._-]+$/g,"").slice(0,128),!Q||Q==="."||Q==="..")return null;return Q}function IM($){return($??"").replace(/[^A-Za-z0-9]/g,"-").slice(0,180)||"no-cwd"}function jJ($,J,Q,X,Y,W={}){let K=zM($);if(!K)return;let B=W.homeDir??hK();if(!B)return;let q=jM(B);if(!q)return;try{let U=(W.now??(()=>new Date))().toISOString(),G=T6(j0(J),FM),H=T6(j0(Q),VM),L=W.toolName?T6(j0(W.toolName),_M):void 0,Z=Y===null?void 0:T6(j0(Y),DM),O=IJ(q,IM(Z?.value??null),U.slice(0,7));ZM(O,{recursive:!0,mode:448});let M=IJ(O,`${U.slice(0,10)}-${K}.jsonl`),V={ts:U,id:(W.createId??(()=>GM(8).toString("hex")))(),v:NM,sessionId:K,decision:W.decision??"deny",agent:W.agent,shape:W.shape,level:W.level,configFallback:W.configFallback,toolName:L?.value,command:G.value,segment:H.value,...G.truncated||H.truncated||L?.truncated||Z?.truncated?{truncated:!0}:{},reason:X,ruleId:W.ruleId,intent:W.intent,failureStage:W.failureStage,errorCode:W.errorCode,cwd:Z?.value??null};HM(M,`${JSON.stringify(V)}
6
- `,{encoding:"utf-8",mode:384}),vK(q,W.now)}catch{}}function T6($,J){return{value:$.slice(0,J),truncated:$.length>J}}function hK($=process.env.CC_SAFETY_NET_AUDIT_HOME||process.env.HOME){let J=$||LM()||OM().homedir;return J&&MM(J)?J:null}function jM($=hK()){return $?IJ($,".cc-safety-net","logs"):null}function gK($,J,Q,X=!0,Y){if(J.decision.kind==="allow"){if(!Q||$.route.kind!=="command")return;let B=kK($);return{decision:"allow",command:B,segment:B,reason:"allowed",cwd:$.context.executionCwd,toolName:$.toolName,level:J.level,...J.configFallback?{configFallback:!0}:{}}}let W=J.decision.evidence.find((B)=>B.kind==="command"),K=W?.command??(X?kK($):"");return{decision:"deny",command:K,segment:W?.segment??K,reason:J.decision.reason,cwd:$.context.executionCwd,toolName:$.toolName,level:J.level,...J.configFallback?{configFallback:!0}:{},ruleId:J.decision.ruleId,intent:J.decision.intent,failureStage:Y?.stage,errorCode:Y?.errorCode}}function kK($){return"command"in $?$.command??"":""}function yK($,J,Q){if(!$)return;let X;try{X=J()}catch{return}if(typeof X!=="string"||!X.trim())return;jJ(X,$.command,$.segment,$.reason,$.cwd,{homeDir:Q.homeDir,decision:$.decision,agent:Q.agent,shape:Q.shape,level:$.level,configFallback:$.configFallback,toolName:$.toolName,ruleId:$.ruleId,intent:$.intent,failureStage:$.failureStage,errorCode:$.errorCode})}function xK($,J,Q){let X;try{X=J()}catch{return}if(typeof X!=="string"||!X.trim())return;jJ(X,$.command??"",$.segment??$.command??"",$.reason,Q.cwd??null,{homeDir:Q.homeDir,decision:"deny",agent:Q.agent,shape:Q.shape,toolName:Q.toolName??$.toolName,ruleId:$.ruleId,intent:$.intent})}import{realpathSync as TM,statSync as wM}from"fs";import{isAbsolute as mK,relative as vM,resolve as fM,sep as hM}from"path";import{dirname as RM,isAbsolute as bM,parse as PM,sep as AM}from"path";function G2($,J=process.platform){if(J!=="win32")return!1;return($[0]==="/"||$[0]==="\\")&&($[1]==="/"||$[1]==="\\")}function d0($,J,Q){if(G2(J))throw Error("Unsupported Windows namespace path");let X=bM(J)?SM(J):"",Y=X||$;for(let W of CM(X?J.slice(X.length):J)){if(W===""||W===".")continue;if(W===".."){Y=RM(Y);continue}let K=EM(Y,W),B=Q.entryKind(K),q=B==="symlink"?Q.realpath(K):K;if(B==="missing"||q===null)throw Error(`Cannot resolve path component: ${K}`);Y=q}return Y}function EM($,J){return $.endsWith("/")||$.endsWith("\\")?`${$}${J}`:`${$}${AM}${J}`}function SM($){return PM($).root}function CM($){let J=process.platform==="win32"?/[\\/]+/:/\/+/;return $.split(J)}function w6($,J){if(G2($))return;let Q=J.flatMap((Y)=>uK(Y));if(!Q[0])return;let X=uK(mK($)?$:fM(Q[0],$))[0];if(!X)return;return Q.some((Y)=>lK(X,Y))?X:void 0}function uK($){try{let J=TM($);return wM(J).isDirectory()?[J]:[]}catch{return[]}}function lK($,J){let Q=vM(J,$);return Q===""||Q!==".."&&!Q.startsWith(`..${hM}`)&&!mK(Q)}var r0="Command could not be safely analyzed (strict mode). Simplify the command and retry, or ask the user to verify.",P0="Command exceeds maximum recursion depth and cannot be safely analyzed. Flatten the nesting and retry.",pK="CC Safety Net could not validate the command because its structure exceeds safe analysis limits.",v6="CC Safety Net failed closed because command analysis failed unexpectedly. This is not caused by your command. Report it to the user.";function dK($){let{reason:J,command:Q,segment:X,toolName:Y}=$,W=$.maxLen??200,K=$.redact??((q)=>q),B=`BLOCKED by CC Safety Net
4
+ var NO=Object.defineProperty;var FO=($)=>$;function VO($,J){this[$]=FO.bind(null,J)}var B2=($,J)=>{for(var Q in J)NO($,Q,{get:J[Q],enumerable:!0,configurable:!0,set:VO.bind(J,Q)})};import{randomBytes as ZM}from"crypto";import{appendFileSync as LM,mkdirSync as OM}from"fs";import{homedir as MM,userInfo as NM}from"os";import{isAbsolute as FM,join as IJ}from"path";var _O=[/\bgh[pousr]_[A-Za-z0-9]{20,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,/\bglpat-[A-Za-z0-9_-]{20,}\b/g,/\bxox[abeprs]-[A-Za-z0-9-]{20,}\b/g,/\bnpm_[A-Za-z0-9_]{20,}\b/g,/\bpypi-[A-Za-z0-9_-]{20,}\b/g,/\b[rs]k_(?:live|test)_[A-Za-z0-9_]{20,}\b/g,/\bsk-[A-Za-z0-9_-]{20,}\b/g,/\bsk_[A-Za-z0-9]{20,}\b/g,/\bgsk_[A-Za-z0-9]{52,}\b/g,/\bxai-[A-Za-z0-9_-]{80,}\b/g,/\bpplx-[A-Za-z0-9_-]{20,}\b/g,/\bbastn_[A-Za-z0-9]{16,}\b/g,/\btgp_v1_[A-Za-z0-9_-]{43,}\b/g,/\bflp_[A-Za-z0-9]{10,}\b/g,/\bwfr_[A-Za-z0-9]{20,}\b/g,/\bfwp?_[A-Za-z0-9_-]{20,}\b/g,/\btp-[A-Za-z0-9_-]{20,}\b/g,/\bpsk-[A-Za-z0-9_-]{8,}-[A-Za-z0-9_-]{8,}\b/g,/\b[a-f0-9]{32}\.[A-Za-z0-9]{16}\b/g];function R0($){let J=$.replace(/\b((?:DATABASE|POSTGRES|POSTGRESQL|MYSQL|MARIADB|REDIS|MONGO(?:DB)?|DB)_DSN|CONNECTION_STRING)=("[^"]*"|'[^']*'|[^\s]+(?:\s+[A-Z_][A-Z0-9_]*=[^\s]+)*)/gi,"$1=<redacted>").replace(/\b((?:DATABASE|POSTGRES|POSTGRESQL|MYSQL|MARIADB|REDIS|MONGO(?:DB)?|DB)_(?:URL|URI|CONNECTION_STRING))=("[^"]*"|'[^']*'|[^\s]+)/gi,"$1=<redacted>").replace(/\b([A-Z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASS|KEY|CREDENTIALS)[A-Z0-9_]*)=("[^"]*"|'[^']*'|[^\s]+)/gi,"$1=<redacted>");return DO(J)}function DO($){let J=$.replace(/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/gi,"<redacted>").replace(/((?:(['"])(?:authorization|cookie|x-api-key|api-key)\2|(?:authorization|cookie|x-api-key|api-key))\s*:\s*)(['"])(?:\\[^\r\n]|(?!\3)[^\\\r\n])*\3/gi,"$1$3<redacted>$3").replace(/(['"]?\s*(?:authorization|cookie|x-api-key|api-key)\s*:(?!\s*(?:"<redacted>"|'<redacted>'))\s*)([^'"\r\n]+)(['"]?)/gi,"$1<redacted>$3").replace(/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/:@]+):([^\s@/]+)@/gi,"$1<redacted>:<redacted>@").replace(/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+)@/gi,"$1<redacted>@").replace(/(^|[\s?&;|])((?:x-amz-signature|x-goog-signature|sig|signature)=)(?:"[^"\r\n]*"|'[^'\r\n]*'|[^&#\s'"`;|<>()]*)/gi,"$1$2<redacted>").replace(/(^|\s)((?:-u|--user)(?:\s+|=))([^\s:]+):([^\s]+)/g,"$1$2<redacted>:<redacted>");for(let Q of _O)J=J.replace(Q,"<redacted>");return J.replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\b/g,"<redacted>").replace(/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,"<redacted>")}import{lstatSync as EK,readdirSync as eO,readFileSync as wK,rmdirSync as $M,statSync as SK,unlinkSync as JM,utimesSync as QM,writeFileSync as XM}from"fs";import{dirname as YM,join as l2}from"path";var j6=30,HJ=1,ZJ=365;function R6($){if(typeof $!=="number"||!Number.isInteger($))return 30;if($<1)return 1;return $>365?365:$}import{homedir as yO}from"os";import{dirname as l0,isAbsolute as xO,join as p0,relative as uO,resolve as P0,sep as mO}from"path";import{closeSync as zO,constants as OK,fstatSync as IO,fsyncSync as AE,lstatSync as MK,mkdirSync as EE,openSync as jO,readdirSync as SE,readFileSync as RO,realpathSync as b6,renameSync as CE,rmdirSync as TE,statSync as bO,unlinkSync as wE,writeFileSync as vE}from"fs";import{isAbsolute as NK,join as FK,normalize as PO,parse as AO,relative as LJ,resolve as OJ,sep as MJ}from"path";var EO=Symbol("PolicyFilesystemScope"),SO=Symbol("PolicyFilesystemTarget"),CO=OK.O_NOFOLLOW??0;class W1 extends Error{constructor($){super(`Unable to access ${$} filesystem safely.`);this.name="PolicyFilesystemError"}}function m0($,J){return{[EO]:!0,root:OJ($),label:J}}function VK($,J){let Q=PO(J);if(J===""||NK(J)||Q===".."||Q.startsWith(`..${MJ}`))throw new W1($.label);return{[SO]:!0,scope:$,relativePath:Q,path:FK($.root,Q)}}function b0($,J){let Q=LJ($.root,OJ(J));return VK($,Q)}function A6($,J="rules policy"){let Q=OJ($),X=AO(Q).dir;return VK(m0(X,J),LJ(X,Q))}function q2($){try{if(!P6($,!1).exists)return null;let Q=jO($.path,OK.O_RDONLY|CO);try{let X=IO(Q);if(!X.isFile())throw new W1($.scope.label);let Y=RO(Q,"utf-8"),W=MK($.path);if(!W.isFile()||W.isSymbolicLink()||X.dev!==W.dev||X.ino!==W.ino)throw new W1($.scope.label);return P6($,!1),Y}finally{zO(Q)}}catch(J){vO($.scope.label,J)}}function _K($,J){if($.path===J.path)return!0;try{if(!P6($,!1).exists||!P6(J,!1).exists)return!1;return b6($.path)===b6(J.path)}catch(Q){if(Q instanceof W1)throw Q;throw new W1($.scope.label)}}function P6($,J,Q="file"){let X=TO($.scope);if(!X)return{exists:!1};let Y=$.relativePath.split(MJ);for(let W of Y.keys()){let K=FK($.scope.root,...Y.slice(0,W+1)),B=DK(K);if(!B){if(W===Y.length-1&&J)return{exists:!1};return{exists:!1}}if(B.isSymbolicLink())throw new W1($.scope.label);if(W<Y.length-1&&!B.isDirectory())throw new W1($.scope.label);if(W===Y.length-1&&(Q==="file"?!B.isFile():!B.isDirectory()))throw new W1($.scope.label);wO(X,b6(K),$.scope.label)}return{exists:!0}}function TO($){if(!DK($.root))return null;if(!bO($.root).isDirectory())throw new W1($.label);return b6($.root)}function wO($,J,Q){let X=LJ($,J);if(X===".."||X.startsWith(`..${MJ}`)||NK(X))throw new W1(Q)}function DK($){try{return MK($)}catch(J){if(fO(J)&&J.code==="ENOENT")return null;throw J}}function vO($,J){if(J instanceof W1)throw J;throw new W1($)}function fO($){return $ instanceof Error&&"code"in $}var Y0=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/,NJ="rulebook.json",FJ=".cc-safety-net/rules";var zK=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)#(.+)$/;var hO=/^[A-Za-z0-9._-]+$/,kO=".cc-safety-net/rules".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),gO="rulebook.json".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),IK=new RegExp(`^${kO}/(${Y0.source.slice(1,-1)})/${gO}$`);function jK($){return`.cc-safety-net/rules/${$}/rulebook.json`}function o4($){if(S6($))try{return E6($),null}catch(J){return J instanceof Error?J.message:String(J)}return Y0.test($)?null:`Local rulebook sources must be bare names matching ${Y0}: ${$}`}function E6($){if($.startsWith("github:"))throw Error(`Invalid rulebook source: ${$}`);let J=$.match(zK);if(!J?.[1]||!J[2]||!J[3])throw Error(`Invalid GitHub rulebook source: ${$}`);let[Q,X,...Y]=J[3].split("/");if(!Q||!hO.test(Q))throw Error(`GitHub rulebook refs must be a single path segment: ${$}`);if(!X||Y.length>0||!Y0.test(X))throw Error(`GitHub rulebook sources must be owner/repo#ref/<rulebook-name>: ${$}`);return{owner:J[1],repo:J[2],ref:Q,path:jK(X),name:X}}function S6($){return zK.test($)}var bK="rule.json",C6="policy.json",lO="rule.lock";var PK=".cc-safety-net",pO="rules",RK="cache",cO="CC_SAFETY_NET_HOME",c0="`cc-safety-net rule sync`";function dO($){return P0($??process.cwd(),FJ)}function rO($){return p0(dO($),bK)}function U2($){return $?.userConfigDir??($?.userConfigPath?l0($.userConfigPath):p0(iO(),pO))}function iO(){let $=process.env[cO];return $?P0($):p0(yO(),PK)}function oO($){return p0(U2($),bK)}function n4($){return p0(l0($),lO)}function AK($){let J=$.userConfigPath??oO($),Q=$.projectConfigPath??rO($.cwd),X=nO(J,$),Y=sO(Q,$);return{userConfigPath:J,projectConfigPath:Q,userLockPath:n4(J),projectLockPath:n4(Q),userScope:X,projectScope:Y,userConfigTarget:b0(X,J),projectConfigTarget:b0(Y,Q),userLockTarget:b0(X,n4(J)),projectLockTarget:b0(Y,n4(Q))}}function nO($,J){let Q=J.userConfigPath?l0(l0(P0(J.userConfigPath))):l0(P0(J.userConfigDir??U2(J)));return m0(Q,"user policy")}function sO($,J){let Q=P0(J.cwd??process.cwd()),X=P0($),Y=uO(Q,X);if(Y!==".."&&!Y.startsWith(`..${mO}`)&&!xO(Y))return m0(Q,"project policy");return m0(l0(l0(X)),"project policy")}function VJ($,J){let Q=$.digest.startsWith("sha256:")?$.digest.slice(7):$.digest;return p0(tO(J),"rulebooks",`${aO($)}--${Q.slice(0,12)}`,NJ)}function _J($,J){let Q=J;return{cacheConfigDir:$,cwd:J.cwd,global:Q.global}}function aO($){return($.kind==="github"&&$.display_ref?`${$.owner}/${$.repo}#${$.display_ref}/${$.name}`:$.spec).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"rulebook"}function tO($){let J=$?.cacheConfigDir??U2($),Q=$;if(Q&&!Q.global&&Q.cwd&&P0(J)===P0(Q.cwd))return p0(P0(Q.cwd),PK,RK);return p0(l0(J),RK)}var zJ=86400000,WM=".last-prune",KM=/^\d{4}-\d{2}$/,BM=/^((\d{4}-\d{2})-\d{2})-.+\.jsonl$/,CK=($)=>Math.floor($/zJ);function qM($){try{let J=l2(YM(U2($)),C6),Q=JSON.parse(wK(J,"utf-8"));return R6(Q?.audit?.retention_days)}catch{return j6}}function vK($,J=()=>new Date){try{let Q=J().getTime();if(!SK($,{throwIfNoEntry:!1})?.isDirectory())return;let X=l2($,WM),Y=SK(X,{throwIfNoEntry:!1})?.mtimeMs;if(Y!==void 0&&CK(Y)===CK(Q))return;let W=Q-qM()*zJ,K=new Date(Q).toISOString().slice(0,7);for(let B of DJ($)){if(B.isDirectory()){UM(l2($,B.name),W,K);continue}if(B.isFile()&&B.name.endsWith(".jsonl"))GM(l2($,B.name),W)}XM(X,"",{mode:384}),QM(X,Q/1000,Q/1000)}catch{}}function UM($,J,Q){for(let X of DJ($)){if(!X.isDirectory()||!KM.test(X.name))continue;let Y=l2($,X.name);for(let W of DJ(Y)){if(!W.isFile())continue;let K=BM.exec(W.name);if(!K||K[2]!==X.name)continue;let B=Date.parse(`${K[1]}T00:00:00.000Z`)+zJ;if(!Number.isFinite(B)||B>=J)continue;fK(l2(Y,W.name))}if(X.name!==Q)TK(Y)}TK($)}function GM($,J){try{let Q=EK($);if(Q.mtimeMs>=J)return;let X=wK($,"utf-8").split(`
5
+ `).filter((Y)=>Y.trim()).map(HM);if(X.length===0)return;if(X.some((Y)=>Y===void 0||Y>=J))return;if(EK($).mtimeMs!==Q.mtimeMs)return;fK($)}catch{}}function HM($){try{let J=JSON.parse($).ts,Q=typeof J==="string"?Date.parse(J):Number.NaN;return Number.isFinite(Q)?Q:void 0}catch{return}}function DJ($){try{return eO($,{withFileTypes:!0,encoding:"utf8"})}catch{return[]}}function fK($){try{JM($)}catch{}}function TK($){try{$M($)}catch{}}var VM="2.0.3",_M=1e4,DM=2000,zM=256,IM=32768;function jM($){let J=$.trim();if(!J)return null;let Q=J.replace(/[^A-Za-z0-9_.-]+/g,"_");if(Q=Q.replace(/^[._-]+|[._-]+$/g,"").slice(0,128),!Q||Q==="."||Q==="..")return null;return Q}function RM($){return($??"").replace(/[^A-Za-z0-9]/g,"-").slice(0,180)||"no-cwd"}function jJ($,J,Q,X,Y,W={}){let K=jM($);if(!K)return;let B=W.homeDir??hK();if(!B)return;let q=bM(B);if(!q)return;try{let U=(W.now??(()=>new Date))().toISOString(),G=T6(R0(J),_M),H=T6(R0(Q),DM),L=W.toolName?T6(R0(W.toolName),zM):void 0,Z=Y===null?void 0:T6(R0(Y),IM),O=IJ(q,RM(Z?.value??null),U.slice(0,7));OM(O,{recursive:!0,mode:448});let M=IJ(O,`${U.slice(0,10)}-${K}.jsonl`),V={ts:U,id:(W.createId??(()=>ZM(8).toString("hex")))(),v:VM,sessionId:K,decision:W.decision??"deny",agent:W.agent,shape:W.shape,level:W.level,configFallback:W.configFallback,toolName:L?.value,command:G.value,segment:H.value,...G.truncated||H.truncated||L?.truncated||Z?.truncated?{truncated:!0}:{},reason:X,ruleId:W.ruleId,intent:W.intent,failureStage:W.failureStage,errorCode:W.errorCode,cwd:Z?.value??null};LM(M,`${JSON.stringify(V)}
6
+ `,{encoding:"utf-8",mode:384}),vK(q,W.now)}catch{}}function T6($,J){return{value:$.slice(0,J),truncated:$.length>J}}function hK($=process.env.CC_SAFETY_NET_AUDIT_HOME||process.env.HOME){let J=$||MM()||NM().homedir;return J&&FM(J)?J:null}function bM($=hK()){return $?IJ($,".cc-safety-net","logs"):null}function gK($,J,Q,X=!0,Y){if(J.decision.kind==="allow"){if(!Q||$.route.kind!=="command")return;let B=kK($);return{decision:"allow",command:B,segment:B,reason:"allowed",cwd:$.context.executionCwd,toolName:$.toolName,level:J.level,...J.configFallback?{configFallback:!0}:{}}}let W=J.decision.evidence.find((B)=>B.kind==="command"),K=W?.command??(X?kK($):"");return{decision:"deny",command:K,segment:W?.segment??K,reason:J.decision.reason,cwd:$.context.executionCwd,toolName:$.toolName,level:J.level,...J.configFallback?{configFallback:!0}:{},ruleId:J.decision.ruleId,intent:J.decision.intent,failureStage:Y?.stage,errorCode:Y?.errorCode}}function kK($){return"command"in $?$.command??"":""}function yK($,J,Q){if(!$)return;let X;try{X=J()}catch{return}if(typeof X!=="string"||!X.trim())return;jJ(X,$.command,$.segment,$.reason,$.cwd,{homeDir:Q.homeDir,decision:$.decision,agent:Q.agent,shape:Q.shape,level:$.level,configFallback:$.configFallback,toolName:$.toolName,ruleId:$.ruleId,intent:$.intent,failureStage:$.failureStage,errorCode:$.errorCode})}function xK($,J,Q){let X;try{X=J()}catch{return}if(typeof X!=="string"||!X.trim())return;jJ(X,$.command??"",$.segment??$.command??"",$.reason,Q.cwd??null,{homeDir:Q.homeDir,decision:"deny",agent:Q.agent,shape:Q.shape,toolName:Q.toolName??$.toolName,ruleId:$.ruleId,intent:$.intent})}import{realpathSync as vM,statSync as fM}from"fs";import{isAbsolute as mK,relative as hM,resolve as kM,sep as gM}from"path";import{dirname as PM,isAbsolute as AM,parse as EM,sep as SM}from"path";function G2($,J=process.platform){if(J!=="win32")return!1;return($[0]==="/"||$[0]==="\\")&&($[1]==="/"||$[1]==="\\")}function d0($,J,Q){if(G2(J))throw Error("Unsupported Windows namespace path");let X=AM(J)?TM(J):"",Y=X||$;for(let W of wM(X?J.slice(X.length):J)){if(W===""||W===".")continue;if(W===".."){Y=PM(Y);continue}let K=CM(Y,W),B=Q.entryKind(K),q=B==="symlink"?Q.realpath(K):K;if(B==="missing"||q===null)throw Error(`Cannot resolve path component: ${K}`);Y=q}return Y}function CM($,J){return $.endsWith("/")||$.endsWith("\\")?`${$}${J}`:`${$}${SM}${J}`}function TM($){return EM($).root}function wM($){let J=process.platform==="win32"?/[\\/]+/:/\/+/;return $.split(J)}function w6($,J){if(G2($))return;let Q=J.flatMap((Y)=>uK(Y));if(!Q[0])return;let X=uK(mK($)?$:kM(Q[0],$))[0];if(!X)return;return Q.some((Y)=>lK(X,Y))?X:void 0}function uK($){try{let J=vM($);return fM(J).isDirectory()?[J]:[]}catch{return[]}}function lK($,J){let Q=hM(J,$);return Q===""||Q!==".."&&!Q.startsWith(`..${gM}`)&&!mK(Q)}var r0="Command could not be safely analyzed (strict mode). Simplify the command and retry, or ask the user to verify.",A0="Command exceeds maximum recursion depth and cannot be safely analyzed. Flatten the nesting and retry.",pK="CC Safety Net could not validate the command because its structure exceeds safe analysis limits.",v6="CC Safety Net failed closed because command analysis failed unexpectedly. This is not caused by your command. Report it to the user.";function dK($){let{reason:J,command:Q,segment:X,toolName:Y}=$,W=$.maxLen??200,K=$.redact??((q)=>q),B=`BLOCKED by CC Safety Net
7
7
 
8
8
  Reason: ${K(J)}`;if($.ruleId)B+=`
9
9
 
@@ -17,51 +17,51 @@ Segment: ${cK(q,W)}`}if($.configWarning)B+=`
17
17
 
18
18
  Config warning: ${K($.configWarning)}`;return B+=`
19
19
 
20
- ${kM($.intent??"manual_only")}`,B}function kM($){switch($){case"hard_stop":return"Do not retry this operation or attempt any workaround (other tools, flags, or paths). Report the block to the user and continue with the rest of the task.";case"use_alternative":return"Do not retry the blocked form. Continue the task using the safer alternative described above.";case"scope_down":return"Retry with a narrower, explicit target as described above. Escalate to the user if the broad operation is truly required.";case"manual_only":return"If this operation is truly needed, ask the user for explicit permission and have them run the command manually.";case"stop_and_explain":return"Do not brute-force variants. Simplify or restructure the command so it can be analyzed, or report the block to the user."}}function cK($,J){return $.length>J?`${$.slice(0,J)}...`:$}function rK($,J){if($.decision.kind!=="deny")return;let Q=J.includeEvidence?$.decision.evidence.find((X)=>X.kind==="command"):void 0;return{reason:$.decision.reason,ruleId:$.decision.ruleId,intent:$.decision.intent,command:Q?.command,segment:Q?.segment,toolName:J.toolName,...$.configFallback?{configWarning:$.configFallback.reason}:{}}}function iK($={}){return{reason:v6,intent:"stop_and_explain",command:$.command,segment:$.segment??$.command,toolName:$.toolName}}function oK($){return dK({...$,redact:j0})}function nK($){return j0($ instanceof Error?$.message:String($))}import{basename as gM,dirname as yM,join as sK}from"path";var f6=Object.freeze({maxEnvironmentExpansionDepth:64,maxMissingSuffixComponents:256,maxRealpathAttempts:1024,maxProcessedCandidateBytes:4194304});class o1 extends Error{name="PathCanonicalizationLimitError";constructor(){super("Path canonicalization work limit exceeded.")}}function s4(){return{realpathAttempts:0,processedCandidateBytes:0,resolvedPaths:new Map}}function H2($){return{...s4(),environment:$}}var h6=new Set(["CC_SAFETY_NET_HOME","CLAUDE_CONFIG_DIR","CODEX_HOME","COPILOT_HOME","GEMINI_CLI_HOME","HOME","KIMI_CODE_HOME","KIMI_SHARE_DIR","OPENCODE_CONFIG","OPENCODE_CONFIG_DIR","PI_CODING_AGENT_DIR","ProgramData","TMPDIR","XDG_CONFIG_HOME","XDG_DATA_HOME"]);function k6($,J){return RJ($,0,J)}function RJ($,J,Q){let X="",Y=0;while(Y<$.length){if($[Y]!=="$"){X+=$[Y],Y++;continue}if($[Y+1]==="{"){let K=bJ($,Y+2),B=xM($,Y,J);if(B===null){if(h6.has(K))throw new o1;X+=$.slice(Y);break}let q=$.slice(Y,B+1);X+=uM(q,J,Q),Y=B+1;continue}let W=bJ($,Y+1);if(!W){X+="$",Y++;continue}X+=PJ(W,Q)??`$${W}`,Y+=W.length+1}return X}function xM($,J,Q){let X=1;for(let Y=J+2;Y<$.length;Y++){if($[Y]==="\\"){Y++;continue}if($[Y]==="$"&&$[Y+1]==="{"){if(X++,Q+X>f6.maxEnvironmentExpansionDepth)throw new o1;Y++;continue}if($[Y]!=="}")continue;if(X--,X===0)return Y}return null}function uM($,J,Q){let X=$.slice(2,-1),Y=bJ(X,0);if(!Y)return $;let W=X.slice(Y.length);if(!W)return PJ(Y,Q)??$;let K=[":-",":+",":=",":?","-","+","=","?"].find((U)=>W.startsWith(U));if(!K){if(h6.has(Y))throw new o1;return $}if(!h6.has(Y))return $;if(K.endsWith("="))throw new o1;let B=PJ(Y,Q),q=K.startsWith(":")?B!==null&&B!=="":B!==null;if(K.endsWith("?")&&!q)throw new o1;if(K.endsWith("-")||K.endsWith("?"))return q?B??"":RJ(W.slice(K.length),J+1,Q);return q?RJ(W.slice(K.length),J+1,Q):""}function bJ($,J){if(!/[A-Za-z_]/.test($[J]??""))return"";let Q=J+1;while(/[A-Za-z0-9_]/.test($[Q]??""))Q++;return $.slice(J,Q)}function J1($,J,Q=s4()){if(!$)return $;let X=Q.resolvedPaths.get($);if(X!==void 0)return X;let Y=[],W=$;while(!0){if(Q.realpathAttempts++,Q.processedCandidateBytes+=Buffer.byteLength(W),Q.realpathAttempts>f6.maxRealpathAttempts||Q.processedCandidateBytes>f6.maxProcessedCandidateBytes)throw new o1;let K=J.realpath(W);if(K!==null){let q=Y.length===0?K:sK(K,...Y.reverse());return Q.resolvedPaths.set($,q),q}let B=yM(W);if(B===W){let q=Y.length===0?W:sK(W,...Y.reverse());return Q.resolvedPaths.set($,q),q}if(Y.length>=f6.maxMissingSuffixComponents)throw new o1;Y.push(gM(W)),W=B}}function PJ($,J){if(!h6.has($))return null;if($==="HOME")return J.env.get("HOME")??J.home;return J.env.get($)??null}function h($){return $.provenance==="command-substitution"?$.raw:$.text}function p2($,J){return $==="posix"?J:p(J.map((Q)=>Q.text))}function g6($,J){return $&&$.provenance!=="unknown"?$.provenance==="literal":!/[$`*?[\]]/.test(J)}function p($){return $.map((J)=>({kind:"word",text:J,raw:J,span:{start:0,end:0},provenance:"unknown",quoted:!1,parts:[]}))}import{existsSync as SJ,lstatSync as oM,readFileSync as m6,realpathSync as e4,statSync as t4}from"fs";import{dirname as CJ,isAbsolute as TJ,join as l6,resolve as p6}from"path";import{lstatSync as mM,realpathSync as lM}from"fs";import{homedir as pM,tmpdir as cM}from"os";var i0={realpath:($)=>{try{return lM($)}catch{return null}},entryKind:($)=>{let J=mM($,{throwIfNoEntry:!1});if(!J)return"missing";return J.isSymbolicLink()?"symlink":"present"}};function c2(){return process.env.HOME||pM()}function A0(){return{env:new Map(Object.entries(process.env).flatMap(([$,J])=>J===void 0?[]:[[$,J]])),home:c2(),tmpdir:cM(),paths:i0}}var AJ=["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE"],dM=new Set(AJ);var aK=new Set(["GIT_CONFIG_GLOBAL","GIT_CONFIG_NOSYSTEM","GIT_CONFIG_SYSTEM","HOME","XDG_CONFIG_HOME"]),y6=new Set(["GIT_SSH_COMMAND","GIT_SSH","GIT_SSH_VARIANT"]),rM=/^([A-Za-z_][A-Za-z0-9_]*)\+=/;function iM($){return dM.has($)}function a4($){return $==="GIT_CONFIG_COUNT"||$==="GIT_CONFIG_PARAMETERS"||/^GIT_CONFIG_(KEY|VALUE)_\d+$/.test($)}function EJ($){return iM($)||aK.has($)||y6.has($)||a4($)}function u1($,J,Q){return Q?.has($)?Q.get($):J.get($)}function x6($,J){let Q=u1("GIT_CONFIG_COUNT",$,J);if(Q===void 0)return{state:"absent"};if(Q==="")return{state:"valid",count:0};if(!/^\d+$/.test(Q))return{state:"invalid"};let X=Number(Q);return Number.isSafeInteger(X)&&X<=1024?{state:"valid",count:X}:{state:"invalid"}}function u6($,J,Q){let Y=$.match(rM)?.[1];if(!Y||!EJ(Y))return null;let W=$.indexOf("=");return{name:Y,value:`${u1(Y,J,Q)??""}${$.slice(W+1)}`}}function tK($){return $B($,y6)}function eK($){return $B($,aK)}function $B($,J){if(!$)return!1;for(let Q of $.keys())if(J.has(Q))return!0;return!1}var W0=new Set(["-c","-C","--git-dir","--work-tree","--namespace","--super-prefix","--config-env"]);function XB($,J){return AJ.some((Q)=>J?.has(Q)||$.has(Q))}function YB($,J){if(!J)return{gitCwd:null,hasExplicitGitContext:!1};let Q;try{Q=e4(p6(J))}catch{return{gitCwd:null,hasExplicitGitContext:!1}}if(!BB(Q))return{gitCwd:null,hasExplicitGitContext:!1};let X=!1,Y=1;while(Y<$.length){let W=$[Y];if(!W)break;if(W==="--")break;if(!W.startsWith("-"))break;if(W==="-C"){let K=$[Y+1];if(!K)return{gitCwd:null,hasExplicitGitContext:X};let B=QB(Q,K);if(!B)return{gitCwd:null,hasExplicitGitContext:X};Q=B,Y+=2;continue}if(W.startsWith("-C")&&W.length>2){let K=QB(Q,W.slice(2));if(!K)return{gitCwd:null,hasExplicitGitContext:X};Q=K,Y++;continue}if(W==="--git-dir"||W==="--work-tree"){X=!0,Y+=2;continue}if(W.startsWith("--git-dir=")||W.startsWith("--work-tree=")){X=!0,Y++;continue}if(W0.has(W))Y+=2;else if(W.startsWith("-c")&&W.length>2)Y++;else Y++}return{gitCwd:Q,hasExplicitGitContext:X}}function WB($){let J=qN($);if(!J)return!1;try{let Q=oM(J);if(Q.isSymbolicLink()||!Q.isFile())return!1;let X=wJ(J);if(!X?.commonDir)return!1;if(!aM(X.gitDir,J))return!1;return tM(X.gitDir,CJ(J))}catch{return!1}}function wJ($){try{let J=nM($);if(!J)return null;let Q=e4(TJ(J)?J:p6(CJ($),J));if(!t4(Q).isDirectory())return null;return{gitDir:Q,commonDir:sM(Q)}}catch{return null}}function nM($){let J=m6($,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(!J.startsWith("gitdir:"))return null;return J.slice(7).trim()||null}function sM($){try{let J=m6(l6($,"commondir"),"utf-8").split(/\r?\n/,1)[0]?.trim();if(!J)return null;let Q=e4(TJ(J)?J:p6($,J));return t4(Q).isDirectory()?Q:null}catch{return null}}function aM($,J){let Q=eM($);return Q===null?!1:KB($,Q,J)}function tM($,J){let Q=$N($);return Q===null?!0:KB($,Q,J)}function eM($){let J=l6($,"gitdir");if(!SJ(J))return null;let Q=m6(J,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";return Q===""?null:Q}function $N($){let J=l6($,"config.worktree");return SJ(J)?WN(J):null}function KB($,J,Q){return QN(JN($,J),Q)}function JN($,J){return TJ(J)?J:p6($,J)}function QN($,J){try{return XN($,J)}catch{return!1}}function XN($,J){try{let Q=t4($),X=t4(J);if(Q.ino!==0&&X.ino!==0&&Q.dev===X.dev&&Q.ino===X.ino)return!0}catch{}return JB($)===JB(J)}function JB($){return YN(e4.native($))}function YN($){let J=$.replace(/^\\\\\?\\UNC\\/i,"//").replace(/^\\\\\?\\/i,"");if(J=J.replace(/\\/g,"/"),J.length>1&&J.endsWith("/"))J=J.slice(0,-1);return process.platform==="win32"?J.toLowerCase():J}function WN($){let J=m6($,"utf-8"),Q=!1,X=null;for(let Y of J.split(/\r?\n/)){let W=Y.trim();if(W===""||W.startsWith("#")||W.startsWith(";"))continue;if(W.startsWith("[")){Q=/^\[core\]$/i.test(W);continue}if(!Q)continue;let K=W.match(/^worktree\s*=\s*(.*)$/i);if(K)X=KN(K[1]??"")}return X}function KN($){let J=$.trim();if(!J.startsWith('"')||!J.endsWith('"'))return J;return BN(J.slice(1,-1))}function BN($){let J="";for(let Q=0;Q<$.length;Q++){let X=$[Q];if(X!=="\\"){J+=X;continue}let Y=$[Q+1];if(Y===void 0){J+=X;continue}switch(Y){case"\\":case'"':J+=Y;break;case"n":J+=`
21
- `;break;case"t":J+="\t";break;case"b":J+="\b";break;default:J+=`\\${Y}`;break}Q++}return J}function QB($,J){try{let Q=d0($,J,i0);return BB(Q)?Q:null}catch{return null}}function BB($){try{return t4($).isDirectory()}catch{return!1}}function qN($){try{return $3(e4($))}catch{return null}}function $3($){let J=$;while(!0){let Q=l6(J,".git");if(SJ(Q))return Q;let X=CJ(J);if(X===J)return null;J=X}}function vJ($,J){return{value:$,work:J}}function j($,J){if($.work)$.work.units=Math.min(Number.MAX_SAFE_INTEGER,$.work.units+1);return $.value[J]}function K1($){return $.value.length}function J3($,J,Q=1){if($)$.units=Math.min(Number.MAX_SAFE_INTEGER,$.units+J.length*Q)}function S1($,J){J3($,J)}function Z2($){if(!$)return!1;let J=$.charCodeAt(0);return J>=48&&J<=57||J>=65&&J<=90||J===95||J>=97&&J<=122}function t($){if(!$)return!1;let J=$.charCodeAt(0);return J===9||J===10||J===11||J===12||J===13||J===32||J===160||J===65279||J===5760||J>=8192&&J<=8202||J===8232||J===8233||J===8239||J===8287||J===12288}function fJ($){return $===`
22
- `||$==="\r"||$==="\u2028"||$==="\u2029"}function e($,J,Q){if(J+Q.length>K1($))return!1;for(let X=0;X<Q.length;X++)if(j($,J+X)!==Q[X])return!1;return!0}function E0($,J,Q){return!Z2(j($,J-1))&&e($,J,Q)&&!Z2(j($,J+Q.length))}function S0($,J){return Z2(j($,J-1))!==Z2(j($,J))}function L1($){return $===`
23
- `||$===";"||$==="&"||$==="|"}function d2($){return $==="|"||$===";"}function c6($,J,Q){let X=vJ($,Q);if(J==="rm")return UN(X);if(J==="dd")return HN(X);return LB(X,!0)}function d6($,J,Q){let X=vJ($,Q);if(J==="rm")return ZN(X);if(J==="reset-hard")return HB(X,"--ha","rd");if(J==="reset-merge")return HB(X,"--me","rge");if(J==="clean")return NN(X);if(J==="checkout")return VN(X);if(J==="push-force")return _N(X);if(J==="push-refspec")return DN(X);if(J==="push-delete")return zN(X);if(J==="branch")return IN(X);if(J==="tag")return bN(X);if(J==="restore")return PN(X);return LB(X,!1)}function UN($){let J=!1,Q=!1,X=!1,Y=-1;for(let W=0;W<=K1($);W++){let K=j($,W);if(!J){let q=j($,W+2);if(E0($,W,"rm")&&t(q)&&q!==`
24
- `)J=!0,W++;continue}let B=GN($,W);if(K===`
25
- `||B!==-1){if(J=!1,Q=!1,X=!1,Y=-1,B!==-1)W=B-1;continue}if(K===";"||K==="&"||K==="|"||W===K1($)){if(Y>=0){let q=qB($,Y,W);Q||=q.recursive,X||=q.force}if(Q&&X)return!0;J=!1,Q=!1,X=!1,Y=-1;continue}if(t(K)){if(Y>=0){if(e($,Y,"--")&&W-Y===2)J=!1,Q=!1,X=!1;else{let q=qB($,Y,W);if(Q||=q.recursive,X||=q.force,Q&&X)return!0}Y=-1}continue}if(Y<0)Y=W}return!1}function GN($,J){if(j($,J)!=="\\"||j($,J-1)==="\\")return-1;if(e($,J,String.raw`\n`))return J+2;if(e($,J,String.raw`\x0a`)||e($,J,String.raw`\x0A`))return J+5;if(e($,J,String.raw`\u000a`)||e($,J,String.raw`\u000A`))return J+7;return e($,J,String.raw`\012`)?J+4:-1}function qB($,J,Q){if(UB($,J,Q,"recursive"))return{recursive:!0,force:!1};if(UB($,J,Q,"force"))return{recursive:!1,force:!0};if(j($,J)!=="-"||j($,J+1)==="-")return{recursive:!1,force:!1};let X=!1,Y=!1;for(let W=J+1;W<Q;W++){let K=j($,W);X||=K==="r"||K==="R",Y||=K==="f"||K==="F"}return{recursive:X,force:Y}}function UB($,J,Q,X){let Y=Q-J-2;if(Y<1||Y>X.length||!e($,J,"--"))return!1;for(let W=0;W<Y;W++)if(j($,J+W+2)!==X[W])return!1;return!0}function HN($){let J=!1;for(let Q=0;Q<K1($);Q++){if(L1(j($,Q))){J=!1;continue}if(E0($,Q,"dd")){J=!0,Q++;continue}if(!J||!E0($,Q,"of")||!e($,Q,"of=/dev/"))continue;let X=Q+8;if(X<K1($)&&!t(j($,X))&&j($,X)!=="'"&&j($,X)!=='"')return!0}return!1}function ZN($){let J=!1,Q=!1,X=!1;for(let Y=0;Y<=K1($);){let W=j($,Y);if(Y===K1($)||L1(W)){J=!1,Q=!1,X=!1,Y++;continue}let K=ON($,Y);if(K>=0){if(LN($,K))return!0;let B=K,q=!1;while(t(j($,B)))q||=j($,B)===`
26
- `,B++;if(q)Q=!1,X=!1;J=!0,Y=B;continue}if(!J){Y++;continue}if(e($,Y,"--")&&(Y===0||t(j($,Y-1)))&&(!j($,Y+2)||t(j($,Y+2))||L1(j($,Y+2)))){J=!1,Q=!1,X=!1,Y+=2;continue}if(Q||=e($,Y,"--recursive")&&S0($,Y+11)||hJ($,Y,"recursive"),X||=e($,Y,"--force")&&S0($,Y+7)||hJ($,Y,"force"),Q&&X)return!0;Y++}return!1}function hJ($,J,Q){if(!e($,J,"--"))return!1;let X=0;while(X<=Q.length){let Y=j($,J+X+2);if(!Y||t(Y)||L1(Y))break;if(Y!==Q[X])return!1;X++}return X>0&&S0($,J+X+2)}function LN($,J){let Q=J,X=!1,Y=!1;while(Q<K1($)){while(t(j($,Q)))Q++;let W=Q;while(Q<K1($)&&!t(j($,Q)))Q++;if(j($,W)!=="-"||Q-W===2&&e($,W,"--"))return!1;let K=GB($,W,"recursive"),B=GB($,W,"force");if(X&&B||Y&&K)return!0;if(X||=K,Y||=B,j($,W+1)==="-")continue;let q=MN($,W,Q);if(q.combined||X&&q.forceAtBoundary||Y&&q.recursiveAtBoundary)return!0;X||=q.recursive,Y||=q.force}return!1}function GB($,J,Q){return e($,J,`--${Q}`)&&S0($,J+Q.length+2)||hJ($,J,Q)}function ON($,J){if(J>0&&Z2(j($,J-1)))return-1;let Q=J;if(j($,Q)==="\\")Q++;if(j($,Q)!=="r")return-1;if(Q++,j($,Q)==="\\")Q++;if(j($,Q)!=="m"||!t(j($,Q+1)))return-1;return Q+1}function MN($,J,Q){let X=!1,Y=!1,W=!1,K=!1,B=!1;if(j($,J)!=="-")return{recursive:X,force:Y,recursiveAtBoundary:W,forceAtBoundary:K,combined:B};let q="";for(let U=J+1;U<Q;U++){let G=j($,U)??"",H=(G==="r"||G==="f")&&S0($,U+1);X||=G==="r",Y||=G==="f",W||=G==="r"&&H,K||=G==="f"&&H,B||=(q==="r"&&G==="f"||q==="f"&&G==="r")&&H,q=G}return{recursive:X,force:Y,recursiveAtBoundary:W,forceAtBoundary:K,combined:B}}function HB($,J,Q){return X3($,"reset",d2,!0,(X)=>j($,X)==="-"&&r2($,X,J,Q)?!0:X)}function NN($){return X3($,"clean",d2,!0,(J)=>{if(j($,J)!=="-")return J;if(r2($,J,"--fo","rce"))return!0;let Q=Q3($,J,d2);for(let X=J+1;X<Q;X++)if(j($,X)==="f")return!0;return Q-1})}function r6($,J,Q){if(!E0($,J,"git"))return null;let X=J+3;if(!t(j($,X)))return{commandEnd:-1,next:X};while(t(j($,X)))X++;while(X<K1($)){if(L1(j($,X)))return{commandEnd:-1,next:X};let Y=Q3($,X,L1);if(E0($,X,Q))return{commandEnd:X+Q.length,next:Y};if(j($,X)!=="-")return{commandEnd:-1,next:Y};let W=Y-X===2&&e($,X,"--"),K=FN($,X,Y);X=Y;while(t(j($,X)))X++;if(W)return{commandEnd:E0($,X,Q)?X+Q.length:-1,next:Q3($,X,L1)};if(!K)continue;if(X>=K1($)||L1(j($,X)))return{commandEnd:-1,next:X};X=Q3($,X,L1);while(t(j($,X)))X++}return{commandEnd:-1,next:X}}function FN($,J,Q){for(let X of W0)if(Q-J===X.length&&e($,J,X))return!0;return!1}function VN($){return ZB($,{command:"checkout",longPrefix:"--fo",longOptional:"rce",shortFlag:"f",excludedShortStarts:"bBU"})}function _N($){return X3($,"push",d2,!0,(J)=>{if(j($,J)!=="-")return J;if(j($,J+1)==="f"&&!Z2(j($,J+2))&&!e($,J+2,"-with-lease"))return!0;let Q=OB($,J,"--fo","rce");if(Q>=0&&!e($,Q,"-with-lease"))return!0;return J})}function DN($){return X3($,"push",L1,!1,(J)=>{if(t(j($,J))&&j($,J+1)==="+"&&J+2<K1($)&&!L1(j($,J+2))&&!t(j($,J+2)))return!0;if(j($,J)===":"&&j($,J+1)==="+")return!0;return J})}function zN($){return X3($,"push",L1,!1,(J)=>{if(j($,J)==="-"&&r2($,J,"--de","lete"))return!0;if(t(j($,J))&&j($,J+1)===":"&&J+2<K1($)&&!t(j($,J+2))&&!L1(j($,J+2)))return!0;return J})}function IN($){let J=!1,Q=!1,X=!1;for(let Y=0;Y<=K1($);Y++){if(Y===K1($)||L1(j($,Y))){if(Q&&X)return!0;J=!1,Q=!1,X=!1;continue}if(!J){let B=r6($,Y,"branch");if(B){J=B.commandEnd>=0,Y=Math.max(Y,(J?B.commandEnd:B.next)-1);continue}}if(!J||j($,Y)!=="-")continue;let W=Q3($,Y,L1),K=jN($,Y,W);if(Q||=K.deletion,X||=K.force,Q&&X)return!0;Y=W-1}return!1}function jN($,J,Q){let X=!1,Y=!1;for(let W=J;W<Q;W++){if(j($,W)!=="-")continue;if(r2($,W,"--de","lete"))X=!0;if(r2($,W,"--fo","rce"))Y=!0;if(j($,W+1)==="-")continue;let K=W+1,B=!1,q=!1,U=!1;while(K<Q&&RN(j($,K))){let G=j($,K);B||=G==="d"||G==="D",q||=G==="f",U||=G==="D",K++}if(!S0($,K))continue;X||=B,Y||=q||U}return{deletion:X,force:Y}}function RN($){if(!$)return!1;let J=$.charCodeAt(0);return J>=65&&J<=90||J>=97&&J<=122}function bN($){return ZB($,{command:"tag",longPrefix:"--de",longOptional:"lete",shortFlag:"d",excludedShortStarts:""})}function ZB($,J){let Q=[{outerActive:!1,shortActive:!1,hasShortFlag:!1,depth:0,quote:"",escaped:!1}];for(let X=0;X<K1($);X++){let Y=j($,X),W=Q[Q.length-1];if(!W)return!1;let K=W.escaped;if(W.escaped=!K&&W.quote!=="'"&&Y==="\\",!K&&Y==="'"&&W.quote!=='"')W.quote=W.quote==="'"?"":"'";if(!K&&Y==='"'&&W.quote!=="'")W.quote=W.quote==='"'?"":'"';if(Y==="$"&&j($,X+1)==="("&&(Q.length===1||!K&&W.quote!=="'")){Q.push({outerActive:!1,shortActive:!1,hasShortFlag:!1,depth:1,quote:"",escaped:!1}),X++;continue}if(!K&&!W.quote&&Q.length>1&&Y==="("){W.depth++;continue}if(!K&&!W.quote&&Q.length>1&&Y===")"){if(W.depth--,W.depth===0)Q.pop();continue}if(t(Y))W.shortActive=!1,W.hasShortFlag=!1;if(!W.outerActive){let B=r6($,X,J.command);if(B){W.outerActive=B.commandEnd>=0&&t(j($,B.commandEnd)),W.shortActive=!1,W.hasShortFlag=!1,X=Math.max(X,(W.outerActive?B.commandEnd:B.next)-1);continue}}if(W.outerActive&&Y==="-"){if(r2($,X,J.longPrefix,J.longOptional))return!0;W.shortActive||=!J.excludedShortStarts.includes(j($,X+1)??"")}if(W.hasShortFlag||=W.shortActive&&Y===J.shortFlag,W.hasShortFlag&&S0($,X+1))return!0;if(d2(Y))W.outerActive=!1}return!1}function X3($,J,Q,X,Y){let W=!1;for(let K=0;K<K1($);K++){let B=j($,K),q=Q(B);if(!W&&!q){let U=r6($,K,J);if(U){W=U.commandEnd>=0&&(!X||t(j($,U.commandEnd))),K=Math.max(K,(W?U.commandEnd:U.next)-1);continue}}if(W){let U=Y(K);if(U===!0)return!0;for(let G=K;G<=U;G++)if(Q(j($,G)))W=!1;K=U}if(q)W=!1}return!1}function PN($){let J=!1;for(let Q=0;Q<K1($);Q++){if(fJ(j($,Q))){if(J)return!0;J=!1;continue}if(!J){let X=r6($,Q,"restore");if(X){J=X.commandEnd>=0,Q=Math.max(Q,(J?X.commandEnd:X.next)-1);continue}}if(J&&j($,Q)==="-"&&j($,Q+1)==="-"&&(e($,Q+2,"staged")||e($,Q+2,"help")))J=!1}return J}function LB($,J){let Q=!1;for(let X=0;X<K1($);X++){let Y=j($,X),W=J?fJ(Y):L1(Y);if(Q&&t(Y)&&j($,X+1)==="-"&&E0($,X+2,"delete"))return!0;if(W){Q=!1;continue}if(E0($,X,"find"))Q=!0,X+=3}return!1}function Q3($,J,Q){let X=J;while(X<K1($)&&!t(j($,X))&&!Q(j($,X)))X++;return X}function OB($,J,Q,X){if(!e($,J,Q))return-1;let Y=J+Q.length;for(let W=0;W<X.length&&j($,Y)===X[W];W++)Y++;return S0($,Y)?Y:-1}function r2($,J,Q,X){return OB($,J,Q,X)>=0}var AN=["git.ssh-env","git.alias-config","git.checkout-force","git.checkout-double-dash","git.checkout-ref-path","git.checkout-pathspec-from-file","git.checkout-ambiguous","git.switch-discard-changes","git.switch-force","git.restore-worktree","git.restore-unstaged","git.reset-hard","git.reset-merge","git.clean-force","git.push-force","git.push-delete","git.push-mirror","git.branch-force-delete","git.rebase-abort","git.merge-abort","git.tag-delete","git.reflog-delete","git.stash-drop","git.stash-clear","git.worktree-remove-force","rm.recursive-force-root-or-home","rm.git-metadata","rm.recursive-force-dynamic-target","rm.recursive-force-home-cwd","rm.recursive-force-cwd-self","rm.recursive-force-outside-cwd","rm.recursive-force-paranoid","powershell.remove-item-root-or-home","powershell.remove-item-recursive-force-root-or-home","powershell.remove-item-git-metadata","powershell.remove-item-recursive-force-dynamic-target","powershell.remove-item-recursive-force-home-cwd","powershell.remove-item-recursive-force-cwd-self","powershell.remove-item-recursive-force-outside-cwd","powershell.remove-item-recursive-force-paranoid","powershell.remove-item-pipeline-dynamic-target","find.delete","find.delete-git-metadata","find.exec-rm-recursive-force","dd.device-write","mkfs.device","shred.target","interpreter.dangerous-command","interpreter.one-liner-paranoid","awk.system-dynamic","xargs.rm-recursive-force-dynamic","xargs.shell-dynamic","parallel.rm-recursive-force-dynamic","parallel.shell-dynamic","parallel.command-stream-dynamic","shell.dynamic-structure","shell.dynamic-executable","raw-text.dangerous-command"],i6=new Set(AN),o6=[{id:"git.ssh-env",category:"Git",label:"Git SSH environment override",description:"Blocks Git network operations with SSH environment overrides.",example:'GIT_SSH_COMMAND="./ssh-wrapper" git push',intent:"manual_only"},{id:"git.alias-config",category:"Git",label:"Git command-line alias",description:"Blocks command-line Git aliases that cannot be safely resolved.",example:"git -c alias.wipe='!rm -rf /' wipe",intent:"manual_only"},{id:"git.checkout-force",category:"Git",label:"Git checkout force",description:"Blocks forced checkout operations that discard local changes.",example:"git checkout --force main",intent:"use_alternative"},{id:"git.checkout-double-dash",category:"Git",label:"Git checkout path restore",description:"Blocks checkout path restores after --.",example:"git checkout -- src/app.ts",intent:"use_alternative"},{id:"git.checkout-ref-path",category:"Git",label:"Git checkout ref and path",description:"Blocks checkout forms that mix a ref and path restore.",example:"git checkout HEAD -- src/app.ts",intent:"use_alternative"},{id:"git.checkout-pathspec-from-file",category:"Git",label:"Git checkout pathspec file",description:"Blocks checkout pathspec loading from a file.",example:"git checkout --pathspec-from-file=paths.txt",intent:"use_alternative"},{id:"git.checkout-ambiguous",category:"Git",label:"Git checkout ambiguous targets",description:"Blocks ambiguous checkout arguments that may restore paths.",example:"git checkout main src/app.ts",intent:"use_alternative"},{id:"git.switch-discard-changes",category:"Git",label:"Git switch discard changes",description:"Blocks branch switches that explicitly discard local changes.",example:"git switch --discard-changes main",intent:"use_alternative"},{id:"git.switch-force",category:"Git",label:"Git switch force",description:"Blocks forced branch switches.",example:"git switch --force main",intent:"use_alternative"},{id:"git.restore-worktree",category:"Git",label:"Git restore worktree",description:"Blocks worktree restore operations.",example:"git restore --worktree src/app.ts",intent:"use_alternative"},{id:"git.restore-unstaged",category:"Git",label:"Git restore unstaged",description:"Blocks unstaged restore operations.",example:"git restore src/app.ts",intent:"use_alternative"},{id:"git.reset-hard",category:"Git",label:"Git reset hard",description:"Blocks hard resets.",example:"git reset --hard",intent:"use_alternative"},{id:"git.reset-merge",category:"Git",label:"Git reset merge",description:"Blocks merge resets.",example:"git reset --merge",intent:"use_alternative"},{id:"git.clean-force",category:"Git",label:"Git clean force",description:"Blocks forced clean operations.",example:"git clean -fd",intent:"use_alternative"},{id:"git.push-force",category:"Git",label:"Git push force",description:"Blocks force pushes.",example:"git push --force origin main",intent:"use_alternative"},{id:"git.push-delete",category:"Git",label:"Git push delete",description:"Blocks remote ref deletion through push.",example:"git push --delete origin old-branch",intent:"manual_only"},{id:"git.push-mirror",category:"Git",label:"Git push mirror",description:"Blocks mirror pushes that can force-update or delete remote refs.",example:"git push --mirror origin",intent:"manual_only"},{id:"git.branch-force-delete",category:"Git",label:"Git branch force delete",description:"Blocks forced branch deletion.",example:"git branch -D old-branch",intent:"use_alternative"},{id:"git.rebase-abort",category:"Git",label:"Git rebase abort",description:"Blocks rebase abort operations.",example:"git rebase --abort",intent:"use_alternative"},{id:"git.merge-abort",category:"Git",label:"Git merge abort",description:"Blocks merge abort operations.",example:"git merge --abort",intent:"use_alternative"},{id:"git.tag-delete",category:"Git",label:"Git tag delete",description:"Blocks tag deletion.",example:"git tag --delete v1.0.0",intent:"manual_only"},{id:"git.reflog-delete",category:"Git",label:"Git reflog delete",description:"Blocks reflog deletion.",example:"git reflog delete HEAD@{1}",intent:"manual_only"},{id:"git.stash-drop",category:"Git",label:"Git stash drop",description:"Blocks dropping stash entries.",example:"git stash drop stash@{0}",intent:"use_alternative"},{id:"git.stash-clear",category:"Git",label:"Git stash clear",description:"Blocks clearing all stash entries.",example:"git stash clear",intent:"manual_only"},{id:"git.worktree-remove-force",category:"Git",label:"Git worktree force remove",description:"Blocks forced worktree removal.",example:"git worktree remove --force ../feature",intent:"use_alternative"},{id:"rm.recursive-force-root-or-home",category:"Filesystem",label:"rm -rf root or home",description:"Blocks recursive forced removal of root or home paths.",example:"rm -rf /",intent:"hard_stop",catastrophic:!0},{id:"rm.git-metadata",category:"Filesystem",label:"rm Git metadata",description:"Blocks removal of protected Git metadata and hooks.",example:"rm -rf .git",intent:"hard_stop",catastrophic:!0},{id:"rm.recursive-force-dynamic-target",category:"Filesystem",label:"rm -rf dynamic target",description:"Blocks recursive forced removal with dynamic targets in strict mode.",example:'rm -rf "$target"',intent:"scope_down",activationCapability:"fail_closed"},{id:"rm.recursive-force-home-cwd",category:"Filesystem",label:"rm -rf from home cwd",description:"Blocks recursive forced removal while working in home.",example:'cd "$HOME" && rm -rf build',intent:"scope_down"},{id:"rm.recursive-force-cwd-self",category:"Filesystem",label:"rm -rf current directory",description:"Blocks recursive forced removal of the current directory.",example:"rm -rf .",intent:"scope_down"},{id:"rm.recursive-force-outside-cwd",category:"Filesystem",label:"rm -rf outside cwd",description:"Blocks recursive forced removal outside the original cwd.",example:"rm -rf ../outside",intent:"scope_down"},{id:"rm.recursive-force-paranoid",category:"Filesystem",label:"rm -rf paranoid mode",description:"Blocks non-temp recursive forced removal when paranoid rm is enabled.",example:"rm -rf ./cache",intent:"scope_down",activationCapability:"paranoid_rm"},{id:"powershell.remove-item-root-or-home",category:"PowerShell",label:"Remove-Item root or home",description:"Blocks PowerShell Remove-Item targeting root or home paths.",example:"Remove-Item C:\\",intent:"hard_stop",catastrophic:!0},{id:"powershell.remove-item-recursive-force-root-or-home",category:"PowerShell",label:"Remove-Item recursive force root or home",description:"Blocks recursive forced PowerShell removal of root or home paths.",example:"Remove-Item C:\\ -Recurse -Force",intent:"hard_stop",catastrophic:!0},{id:"powershell.remove-item-git-metadata",category:"PowerShell",label:"Remove-Item Git metadata",description:"Blocks PowerShell removal of protected Git metadata and hooks.",example:"Remove-Item .git -Recurse -Force",intent:"hard_stop",catastrophic:!0},{id:"powershell.remove-item-recursive-force-dynamic-target",category:"PowerShell",label:"Remove-Item recursive force dynamic target",description:"Blocks recursive forced PowerShell removal with dynamic targets in strict mode.",example:"Remove-Item $target -Recurse -Force",intent:"scope_down",activationCapability:"fail_closed"},{id:"powershell.remove-item-recursive-force-home-cwd",category:"PowerShell",label:"Remove-Item recursive force from home cwd",description:"Blocks recursive forced PowerShell removal while working in home.",example:"Set-Location $HOME; Remove-Item ./build -Recurse -Force",intent:"scope_down"},{id:"powershell.remove-item-recursive-force-cwd-self",category:"PowerShell",label:"Remove-Item recursive force current directory",description:"Blocks recursive forced PowerShell removal of the current directory.",example:"Remove-Item . -Recurse -Force",intent:"scope_down"},{id:"powershell.remove-item-recursive-force-outside-cwd",category:"PowerShell",label:"Remove-Item recursive force outside cwd",description:"Blocks recursive forced PowerShell removal outside the original cwd.",example:"Remove-Item ../outside -Recurse -Force",intent:"scope_down"},{id:"powershell.remove-item-recursive-force-paranoid",category:"PowerShell",label:"Remove-Item recursive force paranoid mode",description:"Blocks non-temp recursive forced PowerShell removal when paranoid rm is enabled.",example:"Remove-Item ./cache -Recurse -Force",intent:"scope_down",activationCapability:"paranoid_rm"},{id:"powershell.remove-item-pipeline-dynamic-target",category:"PowerShell",label:"Remove-Item pipeline dynamic target",description:"Blocks PowerShell Remove-Item with unverifiable pipeline input in strict mode.",example:"Get-ChildItem . -Recurse | Remove-Item -Force",intent:"scope_down",activationCapability:"fail_closed"},{id:"find.delete",category:"Filesystem",label:"find delete",description:"Blocks unsafe find -delete operations.",example:"find . -delete",intent:"scope_down"},{id:"find.delete-git-metadata",category:"Filesystem",label:"find delete Git metadata",description:"Blocks find -delete operations selecting protected Git metadata and hooks.",example:"find .git -delete",intent:"hard_stop",catastrophic:!0},{id:"find.exec-rm-recursive-force",category:"Filesystem",label:"find exec rm -rf",description:"Blocks find -exec rm -rf operations.",example:"find . -exec rm -rf {} +",intent:"scope_down"},{id:"dd.device-write",category:"Filesystem",label:"dd device write",description:"Blocks dd writing to a /dev device.",example:"dd if=/dev/zero of=/dev/sda",intent:"manual_only"},{id:"mkfs.device",category:"Filesystem",label:"mkfs device format",description:"Blocks mkfs formatting a /dev device.",example:"mkfs.ext4 /dev/sda1",intent:"manual_only"},{id:"shred.target",category:"Filesystem",label:"shred target",description:"Blocks shred against any target, including shred --help and shred --version.",example:"shred -u secret.txt",intent:"use_alternative"},{id:"interpreter.dangerous-command",category:"Execution",label:"Interpreter dangerous command",description:"Blocks interpreter one-liners containing dangerous commands.",example:`python -c "import os; os.system('rm -rf /')"`,intent:"use_alternative"},{id:"interpreter.one-liner-paranoid",category:"Execution",label:"Interpreter one-liner paranoid mode",description:"Blocks interpreter one-liners when paranoid interpreters is enabled.",example:'python -c "print(1)"',intent:"use_alternative",activationCapability:"paranoid_interpreters"},{id:"awk.system-dynamic",category:"Execution",label:"Awk dynamic system call",description:"Blocks awk system calls that cannot be safely analyzed.",example:"awk '{ system($0) }'",intent:"stop_and_explain"},{id:"xargs.rm-recursive-force-dynamic",category:"Execution",label:"xargs dynamic rm -rf",description:"Blocks xargs rm -rf with dynamic input.",example:"printf / | xargs rm -rf",intent:"scope_down"},{id:"xargs.shell-dynamic",category:"Execution",label:"xargs dynamic shell",description:"Blocks xargs shell execution with dynamic input.",example:"xargs r$(printf m) -rf",intent:"scope_down"},{id:"parallel.rm-recursive-force-dynamic",category:"Execution",label:"parallel dynamic rm -rf",description:"Blocks parallel rm -rf with dynamic input.",example:"printf / | parallel rm -rf",intent:"scope_down"},{id:"parallel.shell-dynamic",category:"Execution",label:"parallel dynamic shell",description:"Blocks parallel shell execution with dynamic input.",example:"parallel r$(printf m) -rf ::: child",intent:"scope_down"},{id:"parallel.command-stream-dynamic",category:"Execution",label:"parallel dynamic command stream",description:"Blocks parallel command streams from dynamic input.",example:"parallel --dry-run",intent:"scope_down"},{id:"shell.dynamic-structure",category:"Execution",label:"Dynamic command structure",description:"Blocks guarded subcommands and options assembled from substitution output in strict mode.",example:"git reset $(printf --hard)",intent:"stop_and_explain",activationCapability:"fail_closed"},{id:"shell.dynamic-executable",category:"Execution",label:"Dynamic executable name",description:"Blocks executable names assembled from command substitution output in strict mode.",example:"$(printf r)m -rf /",intent:"manual_only",activationCapability:"fail_closed"},{id:"raw-text.dangerous-command",category:"Execution",label:"Raw text dangerous command",description:"Blocks dangerous commands detected in raw command text.",example:"git reset --hard 'unterminated",intent:"stop_and_explain"}],EN=new Map(o6.map(($)=>[$.id,$.intent])),MB=new Set(o6.filter(($)=>$.catastrophic).map(($)=>$.id));function z($,J){return{id:$,reason:J,intent:EN.get($)??"manual_only"}}function k($,J){if(!$)return null;if(MB.has($.id))return $;if(J?.destructiveCommandProtectionEnabled===!1)return null;let Q=J?.effectiveDestructiveCommandRules?.[$.id];if(Q)return Q.enabled?$:null;return J?.destructiveCommandRuleOverrides[$.id]==="off"?null:$}function q1($,J,Q){if(MB.has(J))return!0;if($?.destructiveCommandProtectionEnabled===!1)return!1;let X=$?.effectiveDestructiveCommandRules?.[J];if(X)return X.enabled;let Y=$?.destructiveCommandRuleOverrides[J];return Y?Y==="on":Q}function NB($,J){return Object.freeze(Object.fromEntries(o6.map((Q)=>{let X=Q.activationCapability?J[Q.activationCapability]:void 0,Y=X?.enabled??!0,W=$.destructiveCommandRuleOverrides[Q.id],K=Q.catastrophic?{enabled:!0,inheritedEnabled:!0,changesInherited:!1,source:"catastrophic",...W?{override:W}:{}}:$.destructiveCommandProtectionEnabled?W?{enabled:W==="on",inheritedEnabled:Y,changesInherited:W==="on"!==Y,source:"rule_override",...Q.activationCapability?{activationCapability:Q.activationCapability}:{},override:W}:{enabled:Y,inheritedEnabled:Y,changesInherited:!1,source:X?.source??"built_in_default",...Q.activationCapability?{activationCapability:Q.activationCapability}:{}}:{enabled:!1,inheritedEnabled:Y,changesInherited:!1,source:"master_disabled",...Q.activationCapability?{activationCapability:Q.activationCapability}:{},...W?{override:W}:{}};return[Q.id,Object.freeze(K)]})))}function FB($,J){return Object.freeze({...$,effectiveDestructiveCommandRules:NB($,J)})}function Y3($,J){J3(J,$,2);let Q=$.toLowerCase(),X=Q.trimStart(),Y=X.startsWith("echo ")||X.startsWith("rg "),W=[{scan:"rm",label:"rm -rf"},{scan:"reset-hard",label:"git reset --hard"},{scan:"reset-merge",label:"git reset --merge"},{scan:"clean",label:"git clean -f"},{scan:"checkout",label:"git checkout --force"},{scan:"push-force",label:"git push --force"},{scan:"push-refspec",label:"git push --force"},{scan:"push-delete",label:"git push delete"},{scan:"branch",label:"git branch -D",caseSensitive:!0},{scan:"tag",label:"git tag -d"},{regex:/\bgit\s+stash\s+(drop|clear)\b/,label:"git stash drop/clear"},{regex:/\bgit\s+checkout\s+--\s/,label:"git checkout --"},{scan:"restore",label:"git restore without --staged"},{scan:"find",label:"find -delete",skipForEchoRg:!0},{regex:/\bdd\b[^\n|;&]*\bof=\/dev\/\S/,label:"dd of=/dev/",skipForEchoRg:!0},{regex:/\bmkfs(?:\.[a-z0-9_-]+)?\s+\/dev\/\S/,label:"mkfs /dev/",skipForEchoRg:!0},{regex:/\bshred\b\s+\S/,label:"shred",skipForEchoRg:!0}];for(let K of W){if(K.skipForEchoRg&&Y)continue;let B=K.caseSensitive?$:Q;if(K.regex)S1(J,B);if((K.regex?.test(B)??!1)||K.scan&&d6(B,K.scan,J))return z("raw-text.dangerous-command",`Unparseable command text contains a destructive pattern (${K.label}). Rewrite as a plain, parseable command so it can be analyzed.`)}return null}var SN=/^[A-Za-z_][A-Za-z0-9_]*=/;function _B($,J,Q){let X=$.words[0];if(!J||!X||$.words.length!==1||$.dialect!=="posix")return!1;if(!X.quoted||X.provenance!=="literal")return!1;let Y=/^([A-Za-z_][A-Za-z0-9_]*)=/.exec(X.text)?.[1];if(!Y)return!1;J3(Q,J.source,2);let W={anchored:new RegExp(`^\\$\\{?${Y}(?![A-Za-z0-9_])`),loose:new RegExp(`\\$\\{?${Y}(?![A-Za-z0-9_])`)};return DB(J.nodes,X,W)}function DB($,J,Q){return $.every((X)=>{if(X.kind==="connector")return!0;if(X.kind==="group"||X.kind==="function")return DB(X.body.nodes,J,Q);if(X.kind==="unknown")return!Q.loose.test(X.source);return CN(X,J,Q)})}function CN($,J,Q){if($.nested.some((Y)=>Q.loose.test(Y.source)))return!1;let X=$.words.findIndex((Y)=>!SN.test(Y.text));return $.words.every((Y,W)=>Y===J||VB(Y.raw,Q.anchored,W!==X))&&$.redirections.every((Y)=>(!Y.heredoc||Y.heredoc.quotedDelimiter||!Q.loose.test(Y.heredoc.body))&&(!Y.target||VB(Y.target.raw,Q.anchored,!0)))}function VB($,J,Q){let X=!1,Y=!1;for(let W=0;W<$.length;W++){let K=$[W];if(K==="\\"&&!X){W++;continue}if(!Y&&K==="'"){X=!X;continue}if(!X&&K==='"'){Y=!Y;continue}if(X||K!=="$")continue;if(!J.test($.slice(W)))continue;if(!Y||!Q)return!1}return!0}var zB=Object.freeze({maxDerivedTokens:16384}),IB="Command analysis exceeds CC Safety Net's derived-command work limit. Reduce nested or embedded command complexity and retry.",jB="env -S split-string variables cannot be resolved safely. Use literal values or expand the command explicitly.";class m1 extends Error{constructor(){super("Command analysis exceeds CC Safety Net's derived-command work limit. Reduce nested or embedded command complexity and retry.");this.name="DerivedCommandWorkLimitError"}}class L2 extends Error{constructor(){super("env -S split-string variables cannot be resolved safely. Use literal values or expand the command explicitly.");this.name="EnvSplitStringExpansionError"}}function n6(){return{derivedTokens:0}}function K0($,J){if(!Number.isSafeInteger($.derivedTokens)||$.derivedTokens<0||$.derivedTokens>zB.maxDerivedTokens||!Number.isSafeInteger(J)||J<0||J>zB.maxDerivedTokens-$.derivedTokens)throw new m1;$.derivedTokens+=J}import{isAbsolute as TN,resolve as RB}from"path";var bB=64;function W3($,J,Q){let X=TN($)?RB($):J?RB(J,$):void 0;if(!X)return;try{return J1(X,Q)}catch{return X}}function PB($){return!["/dev","/proc","/sys"].some((J)=>$===J||$.startsWith(`${J}/`))}function i($){return l($).toLowerCase()}function l($){return $.split(/[\\/]/).pop()?.replace(/\.exe$/i,"")??$}var s6=10,i2=20,O2=/^[a-zA-Z][a-zA-Z0-9_-]*$/,o2=256,H1=new Set(["bash","sh","zsh","ksh","dash","fish","csh","tcsh"]),AB=new Set(["python","python3","python2","node","ruby","perl"]),EB=/^python(?:[23](?:\.\d+)*)?$/,a6=new Set(["echo","printf","cat","head","tail","less","more","grep","rg","ag","ack","sed","awk","cut","tr","sort","uniq","wc","tee","man","help","info","type","which","whereis","whatis","apropos","file","stat","ls","ll","dir","tree","pwd","date","cal","uptime","whoami","id","groups","hostname","uname","env","printenv","set","export","alias","history","jobs","fg","bg","test","true","false","read","return","exit","break","continue","shift","wait","trap","basename","dirname","realpath","readlink","md5sum","sha256sum","base64","xxd","od","hexdump","strings","diff","cmp","comm","join","paste","column","fmt","fold","nl","pr","expand","unexpand","rev","tac","shuf","seq","yes","sleep","logger","write","wall","mesg","notify-send"]);var M2="Interpreter code contains a dangerous command. Run the underlying command directly so it can be analyzed, or use the safer alternative for that command.",n2="Interpreter one-liners are blocked by the active safety policy. Write the code to a script file and run it, or run the equivalent shell command directly.",t6=new Map([["python",new Set(["-c"])],["node",new Set(["-e","--eval"])],["ruby",new Set(["-e"])],["perl",new Set(["-e","-E"])]]),wN=new Set(["-p","--print"]),vN=new Map([["python",new Set(["c"])],["node",new Set(["e"])],["ruby",new Set(["e"])],["perl",new Set(["e","E"])]]),fN=new Map([["python",new Set(["W","X"])],["node",new Set(["C","r"])],["ruby",new Set(["C","E","F","I","r"])],["perl",new Set(["F","I","M","m"])]]),hN=new Map([["ruby",new Set(["0","K","W","x"])],["perl",new Set(["0","C","D","V","d","i","l","x"])]]),kN=new Map([["python",new Set(["m"])]]),gN=new Map([["node",new Set(["--allow-fs-read","--allow-fs-write","--conditions","--cpu-prof-dir","--cpu-prof-interval","--cpu-prof-name","--debug-port","--diagnostic-dir","--disable-proto","--disable-warning","--dns-result-order","--env-file","--env-file-if-exists","--experimental-package-map","--experimental-test-isolation","--experimental-test-tag-filter","--heap-prof-dir","--heap-prof-interval","--heap-prof-name","--heapsnapshot-near-heap-limit","--heapsnapshot-signal","--icu-data-dir","--input-type","--inspect-port","--inspect-publish-uid","--localstorage-file","--max-http-header-size","--max-old-space-size-percentage","--network-family-autoselection-attempt-timeout","--openssl-config","--redirect-warnings","--report-dir","--report-directory","--report-filename","--report-signal","--secure-heap","--secure-heap-min","--test-concurrency","--test-coverage-branches","--test-coverage-exclude","--test-coverage-functions","--test-coverage-include","--test-coverage-lines","--test-global-setup","--test-isolation","--test-name-pattern","--test-random-seed","--test-reporter","--test-reporter-destination","--test-rerun-failures","--test-shard","--test-skip-pattern","--test-timeout","--title","--tls-cipher-list","--tls-keylog","--trace-event-categories","--trace-event-file-pattern","--trace-require-module","--unhandled-rejections","--use-largepages","--v8-pool-size","--watch-kill-signal"])],["python",new Set(["--check-hash-based-pycs"])],["ruby",new Set(["--backtrace-limit","--crash-report","--disable","--enable","--encoding","--external-encoding","--internal-encoding","--parser"])]]),yN=new Set(["always","default","never"]),xN=new Set(["--backtrace-limit","--crash-report","--disable","--enable"]),uN=/\\\r?\n/g,mN=new Map([["python",[{selector:"-c",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-m",kind:"module-file",valueForm:"attached-or-separate"}]],["node",[{selector:"-e",kind:"inline-code",valueForm:"separate-only"},{selector:"--eval",kind:"inline-code",valueForm:"equals-or-separate"},{selector:"-p",kind:"inline-code",valueForm:"separate-only"},{selector:"--print",kind:"inline-code",valueForm:"separate-only"},{selector:"-r",kind:"module-file",valueForm:"separate-only"},{selector:"--require",kind:"module-file",valueForm:"equals-or-separate"},{selector:"--import",kind:"module-file",valueForm:"equals-or-separate"},{selector:"--loader",kind:"module-file",valueForm:"equals-or-separate"},{selector:"--experimental-loader",kind:"module-file",valueForm:"equals-or-separate"}]],["ruby",[{selector:"-e",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-r",kind:"module-file",valueForm:"attached-or-separate"}]],["perl",[{selector:"-e",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-E",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-M",kind:"module-file",valueForm:"attached-only"},{selector:"-m",kind:"module-file",valueForm:"attached-only"}]]]);function e6($){return J9($).code}function $9($){return J9($).sources}function CB($){return mN.get(X9($))??[]}function J9($){let J=X9($[0]??"");if(!t6.has(J))return{code:null,sources:[],optionsOpen:!1};let Q=[],X=[],Y=!0;for(let W=1;W<$.length;W++){let K=$[W];if(K===void 0)break;if(K==="--")return n1(J,Q,X,Y,$[W+1]===void 0?void 0:W+1,$[W+1]);if(K===""||K==="-"||!K.startsWith("-"))return n1(J,Q,X,Y,W,K);if(J==="node"&&wN.has(K)){let H=$[W+1];if(H===void 0)return n1(J,Q,X,Y);if(H.startsWith("-"))continue;Q.push({tokenIndex:W+1,value:H}),X.push({tokenIndex:W+1,kind:"inline-code",value:H}),W++;continue}if(pN(J,K)){let H=$[W+1];if(H===void 0)return n1(J,Q,X,Y);if(Q.push({tokenIndex:W+1,value:H}),X.push({tokenIndex:W+1,kind:"inline-code",value:H}),J==="python")return n1(J,Q,X,Y);W++;continue}let B=/^--eval=(.*)$/s.exec(K);if(cN(J)&&B){let H=B[1]??"";Q.push({tokenIndex:W,value:H}),X.push({tokenIndex:W,kind:"inline-code",value:H});continue}if(J==="node"){let H=lN(K);if(H){if(H.attached){if(Y&&=H.value!=="",H.value!=="")X.push({tokenIndex:W,kind:"module-file",value:H.value});continue}let L=$[W+1];if(L===void 0||L.startsWith("-"))return Y=!1,n1(J,Q,X,Y);X.push({tokenIndex:W+1,kind:"module-file",value:L}),W++;continue}}if(J==="python"&&K.startsWith("--check-hash-based-pycs=")||J==="node"&&(K==="--conditions="||K==="--diagnostic-dir="||K==="--title=")||J==="ruby"&&(K==="--disable="||K==="--enable="))return n1(J,Q,X,Y);if(gN.get(J)?.has(K)){let H=$[W+1];if(H===void 0||H.startsWith("-")&&!(J==="ruby"&&xN.has(K))||J==="python"&&!yN.has(H))return n1(J,Q,X,Y);W++;continue}if(K.startsWith("--"))continue;let q,U=!1;for(let H=1;H<K.length;H++){let L=K[H];if(L===void 0)break;if(kN.get(J)?.has(L)){let Z=K.slice(H+1),O=Z||$[W+1];if(O!==void 0)X.push({tokenIndex:Z?W:W+1,kind:"module-file",value:O});return n1(J,Q,X,Y)}if(vN.get(J)?.has(L)){q=K.slice(H+1)||$[W+1],U=H+1===K.length;break}if(J==="node"&&L==="r"){if(K==="-r"){let Z=$[W+1];if(Y&&=Z!==void 0&&!Z.startsWith("-"),Y&&Z!==void 0)X.push({tokenIndex:W+1,kind:"module-file",value:Z});W++}else Y=!1;break}if(J==="ruby"&&L==="r"){let Z=K.slice(H+1),O=Z||$[W+1];if(Y&&=O!==void 0,O!==void 0)X.push({tokenIndex:Z?W:W+1,kind:"module-file",value:O});if(!Z)W++;break}if(J==="perl"&&(L==="M"||L==="m")){let Z=K.slice(H+1);if(Z)X.push({tokenIndex:W,kind:"module-file",value:Z});else if(Y=!1,H+1===K.length)W++;break}if(fN.get(J)?.has(L)){if(H+1===K.length)W++;break}if(hN.get(J)?.has(L)&&H+1<K.length)break}if(q===void 0)continue;let G=U?W+1:W;if(Q.push({tokenIndex:G,value:q}),X.push({tokenIndex:G,kind:"inline-code",value:q}),J==="python")return n1(J,Q,X,Y);if(U)W++}return n1(J,Q,X,Y,void 0,void 0,!0)}function n1($,J,Q,X,Y,W,K=!1){let B=$==="node"?J.slice(-1):J,q=new Set(B.map((G)=>G.tokenIndex)),U=Q.filter((G)=>G.kind!=="inline-code"||q.has(G.tokenIndex));if(X&&J.length===0&&Y!==void 0&&W!==void 0)U.push({tokenIndex:Y,kind:"main-script",value:W});return{code:($==="node"?B[0]?.value:B.map((G)=>G.value).join(`
27
- `))||null,sources:X?U:[],optionsOpen:X&&K}}function lN($){for(let J of["--import","--loader","--experimental-loader","--require"]){if($===J)return{attached:!1,value:""};if($.startsWith(`${J}=`))return{attached:!0,value:$.slice(J.length+1)}}return}function C1($){return t6.has(X9($))}function Q9($,J){return X9($)==="node"&&/^\s*console\.(?:log|info|warn|error)\(\s*(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*')\s*\)\s*;?\s*$/.test(J)}function X9($){let J=l($).toLowerCase();return EB.test(J)?"python":J}function pN($,J){return t6.get($)?.has(J)??!1}function cN($){return t6.get($)?.has("--eval")??!1}function s2($,J){let Q=iN($,J);if(!SB(Q,J))return!1;S1(J,Q);let X=rN(Q);if(SB(X,J))return!0;return S1(J,X),dN.test(X)}var dN=/`|%x|\b(?:system|exec|spawn|popen|subprocess|child_process|open3|eval|fork|qx)/i;function rN($){let J=[],Q=0,X=0;while(X<$.length){let Y=$[X];if(Y!=="'"&&Y!=='"'){X++;continue}let W=$.startsWith(Y.repeat(3),X)?Y.repeat(3):Y,K=X+W.length;while(K<$.length&&!$.startsWith(W,K))K+=$[K]==="\\"?2:1;if(K>=$.length)break;J.push($.slice(Q,X)," "),X=K+W.length,Q=X}return J.push($.slice(Q)),J.join("")}function SB($,J){if(c6($,"rm",J))return!0;for(let X of[/\bgit[^\S\n]+reset[^\S\n]+--ha(?:r(?:d)?)?\b/,/\bgit[^\S\n]+reset[^\S\n]+--me(?:r(?:g(?:e)?)?)?\b/,/\bgit[^\S\n]+checkout[^\S\n]+--[^\S\n]/,/\bgit[^\S\n]+clean[^\S\n]+(-[^\s]*f[^\s]*|--fo(?:r(?:c(?:e)?)?)?)\b/,/\bgit[^\S\n]+stash[^\S\n]+(drop|clear)\b/])if(S1(J,$),X.test($))return!0;if(c6($,"dd",J))return!0;for(let X of[/\bmkfs(?:\.[A-Za-z0-9_-]+)?\s+\/dev\/[^\s'"]+/,/\bshred\b\s+/])if(S1(J,$),X.test($))return!0;if(c6($,"find",J))return!0;let Q=$.split(/[\n\r\u2028\u2029]/);return["reset-hard","reset-merge","clean","checkout","push-force","push-refspec","push-delete","branch","tag","restore"].some((X)=>{return S1(J,$),Q.some((Y)=>d6(Y,X))})}function iN($,J){return S1(J,$),$.replace(uN,"")}var f=Object.freeze({maxChildAnalyses:1024,maxDerivedTokens:16384,maxDerivedBytes:1048576,maxPlaceholderReplacements:16384}),TB="Parallel command expands beyond CC Safety Net's analysis limits. Reduce the template or explicit argument list and retry.";class W9 extends Error{constructor(){super("Parallel command expands beyond CC Safety Net's analysis limits. Reduce the template or explicit argument list and retry.");this.name="ParallelAnalysisLimitError"}}function wB(){return{childAnalyses:0,derivedTokens:0,derivedBytes:0,placeholderReplacements:0}}function T1($,J){let Q=J.childAnalyses??0,X=J.derivedTokens??0,Y=J.derivedBytes??0,W=J.placeholderReplacements??0;if(Y9($.childAnalyses,Q,f.maxChildAnalyses)||Y9($.derivedTokens,X,f.maxDerivedTokens)||Y9($.derivedBytes,Y,f.maxDerivedBytes)||Y9($.placeholderReplacements,W,f.maxPlaceholderReplacements))throw new W9;$.childAnalyses+=Q,$.derivedTokens+=X,$.derivedBytes+=Y,$.placeholderReplacements+=W}function Y9($,J,Q){return!Number.isSafeInteger($)||$<0||$>Q||!Number.isSafeInteger(J)||J<0||J>Q-$}import{isAbsolute as FQ,normalize as X_,parse as Y_,posix as tq,resolve as Q4,sep as NQ}from"path";import{isAbsolute as oN,join as vB,normalize as kB,parse as nN,sep as fB}from"path";var sN=["/tmp","/var/tmp","/private/tmp","/private/var/tmp"],aN=`
28
- `;function K3($,J){if(B0($,J))return!0;if(!$.has("TMPDIR"))return!1;return!kJ($.get("TMPDIR")??"",J)}function C0($,J){if($.has("TMPDIR"))return kJ($.get("TMPDIR")??"",J);let Q=gJ($,J);if(Q===void 0)return!0;return kJ(Q,J)}function gJ($,J){return xB($,J,"TMPDIR")}function kJ($,J){if(!$)return!1;if(eN($))return!1;return yJ($,J)}function B0($,J){let Q=xB($,J,"IFS");return Q!==void 0&&Q!==""&&Q!==aN}function yJ($,J){let Q=K9($,J.paths);return Q!==null&&yB(J).some((X)=>JF(Q,X))}function gB($,J){let Q=K9($,J.paths);return Q!==null&&yB(J).includes(Q)}var hB=new WeakMap;function yB($){let J=hB.get($);if(J)return J;let Q=tN($);return hB.set($,Q),Q}function tN($){let J=sN.map((X)=>K9(X,$.paths)??kB(X)),Q=K9($.tmpdir,$.paths);if(!Q)return J;if(process.platform==="win32")return[...J,Q];if(process.platform==="darwin"&&$F(Q))return[...J,Q];return J}function eN($){return/[\s$`*?[]/.test($)||/\{[^{}]*(?:,|\.\.)[^{}]*\}/.test($)||/[+@!]\([^)]*\)/.test($)}function xB($,J,Q){return $.has(Q)?$.get(Q):J.env.get(Q)}function $F($){return/^\/(?:private\/)?var\/folders\/[^/]{2}\/[^/]+\/T$/.test($)}function K9($,J){try{let Q=kB($);if(!oN(Q))return Q;let X=nN(Q).root,Y=Q.slice(X.length).split(/[\\/]+/).filter(Boolean),W=X;for(let K=0;K<Y.length;K++){let B=vB(W,Y[K]??"");if(J.entryKind(B)==="missing")return vB(B,...Y.slice(K+1));let q=J.realpath(B);if(q===null)return null;W=q}return W}catch{return null}}function JF($,J){if($===J)return!0;let Q=J.endsWith(fB)?J:`${J}${fB}`;return $.startsWith(Q)}import{statSync as oV}from"fs";import{isAbsolute as lq,join as nV,relative as pq}from"path";import{isAbsolute as uB,parse as QF}from"path";var pB=/^[A-Za-z_][A-Za-z0-9_]*=/,XF=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}/,cB=131072,YF=16384;function q0($){if(!pB.test($))return null;let J=$.indexOf("=");return{name:$.slice(0,J),value:$.slice(J+1)}}function B9($){let J=new Map,Q=0;while(Q<$.length){let X=$[Q];if(!X)break;let Y=q0(h(X));if(!Y)break;J.set(Y.name,Y.value),Q++}return{words:$.slice(Q),envAssignments:J}}function dB($){let J=$.toLowerCase();return $.includes("=")||J==="sudo"||J==="env"||J==="command"||J==="builtin"}function N2($,J,Q,X){if(!dB(a2($)))return{words:$,envAssignments:new Map,cwd:Q,rewritten:!1};let Y=new Set($),W=$,K=new Map,B=new Map(X??[]),q=Q;for(let G=0;G<i2;G++){let H=lB(W),L=B9(W);for(let[O,M]of L.envAssignments)K.set(O,M),B.set(O,M);if(W=L.words,W.length===0)break;while(W.length>0&&a2(W).includes("=")&&!WF(W)){let O=KF(a2(W),B,J.env)??u6(a2(W),J.env,B);if(O)K.set(O.name,O.value),B.set(O.name,O.value);W=W.slice(1)}if(W.length===0)break;let Z=a2(W).toLowerCase();if(Z!=="sudo"&&Z!=="env"&&Z!=="command"&&Z!=="builtin")break;if(Z==="sudo"){let O=qF(W,J.paths,q);if(W=O.words,O.cwd!==void 0)q=O.cwd}if(Z==="env"){let O=HF(W,q,B,J);if(O.unverifiableEnvSplit)return{words:W,envAssignments:K,cwd:q,unverifiableEnvSplit:!0,rewritten:mB(W,Y)};if(W=O.words,O.cwd!==void 0)q=O.cwd;for(let[M,V]of O.envAssignments)K.set(M,V),B.set(M,V)}if(Z==="command")W=FF(W);if(Z==="builtin")W=W.slice(s1(W,1)==="--"?2:1);if(lB(W)===H)break}let U=B9(W);for(let[G,H]of U.envAssignments)K.set(G,H),B.set(G,H);return{words:U.words,envAssignments:K,cwd:q,rewritten:mB(U.words,Y)}}function mB($,J){return $.some((Q)=>!J.has(Q))}function lB($){return $.map(h).join(" ")}function a2($){let J=$[0];return J?h(J):""}function s1($,J){let Q=$[J];return Q?h(Q):void 0}function WF($){return pB.test(a2($))}function KF($,J,Q){if(!$.startsWith("TMPDIR+="))return null;return{name:"TMPDIR",value:`${J.get("TMPDIR")??Q.get("TMPDIR")??""}${$.slice(8)}`}}var BF=new Set(["-u","-g","-C","-D","-h","-p","-r","-t","-T","-U"]);function qF($,J,Q){let X=1,Y=Q;while(X<$.length){let W=s1($,X);if(!W)break;if(W==="--")return{words:$.slice(X+1),cwd:Y};if(!W.startsWith("-"))break;if(W==="-D"||W==="--chdir"){let K=s1($,X+1);Y=K?B3(Y,K,J):null,X+=2;continue}if(W.startsWith("--chdir=")){Y=B3(Y,W.slice(8),J),X++;continue}if(W.startsWith("-D")&&W.length>2){Y=B3(Y,W.slice(2),J),X++;continue}if(W==="-i"||W==="--login"){Y=null,X++;continue}if(BF.has(W)){X+=2;continue}X++}return{words:$.slice(X),cwd:Y}}var UF=new Set(["-i","-0","--null"]),GF=new Set(["-u","--unset","-C","--chdir","-S","--split-string","-P"]);function HF($,J,Q,X){let Y=new Map,W=J,K=$,B=new Set,q=1;while(q<K.length){let U=s1(K,q);if(!U)break;if(U==="--")return{words:K.slice(q+1),envAssignments:Y,cwd:W};if(U==="-i"||U==="--ignore-environment"||U==="-"){Y.clear();for(let H of Q.keys())Y.set(H,"");Y.set("TMPDIR",""),q++;continue}if(UF.has(U)){q++;continue}if(U==="-u"||U==="--unset"){let H=s1(K,q+1);if(H!==void 0)B.add(H),Y.set(H,"");q+=2;continue}if(U.startsWith("-u")&&U.length>2&&!U.startsWith("-u=")){let H=U.slice(2);B.add(H),Y.set(H,""),q++;continue}if(U.startsWith("--unset=")){let H=U.slice(8);B.add(H),Y.set(H,""),q++;continue}let G=U==="-S"||U==="--split-string"?{value:s1(K,q+1),consumed:2}:U.startsWith("-S")&&U.length>2?{value:U.slice(2),consumed:1}:U.startsWith("--split-string=")?{value:U.slice(15),consumed:1}:null;if(G){let H=ZF(K,q,G.value,G.consumed,Q,B,W,X.env);if(H.done)return H.result;K=H.expanded,W=H.currentCwd,q=H.nextIndex;continue}if(GF.has(U)){if(U==="-C"||U==="--chdir"){let H=s1(K,q+1);W=H?B3(W,H,X.paths):null}q+=2;continue}if(U.startsWith("-u=")){q++;continue}if(U.startsWith("-C")&&U.length>2||U.startsWith("--chdir=")){let H=U.startsWith("--chdir=")?U.slice(8):U.startsWith("-C=")?U.slice(3):U.slice(2);W=B3(W,H,X.paths),q++;continue}if(U.startsWith("-P")){q++;continue}if(U.startsWith("-")){q++;continue}if(!q0(U))break;while(q<K.length){let H=q0(s1(K,q)??"");if(!H)break;Y.set(H.name,H.value),q++}if(s1(K,q)==="--")q++;return{words:K.slice(q),envAssignments:Y,cwd:W}}return{words:K.slice(q),envAssignments:Y,cwd:W}}function ZF($,J,Q,X,Y,W,K,B){let q=Q!==void 0?LF(Q,Y,W,B):{tokens:null,unverifiableEnvSplit:!1};if(q.unverifiableEnvSplit)return{done:!0,result:{words:$,envAssignments:new Map,cwd:K,unverifiableEnvSplit:!0}};if(!q.tokens)return{done:!1,expanded:$,currentCwd:null,nextIndex:J+X};return{done:!1,expanded:[...$.slice(0,J),...p(q.tokens),...$.slice(J+X)],currentCwd:K,nextIndex:J}}function LF($,J,Q,X){if($.length>cB)return{tokens:null,unverifiableEnvSplit:!0};let Y=OF($,(W)=>{if(Q.has(W))return"";if(J.has(W))return J.get(W)??"";return X.get(W)??""});return{tokens:Y.tokens,unverifiableEnvSplit:Y.limited}}function OF($,J){let Q=[],X=[],Y=0,W=!1,K=!1,B=!1,q=!1,U=(H)=>{if(Y+H.length>cB)return q=!0,!1;return X.push(H),Y+=H.length,W=!0,!0},G=()=>{if(!W)return!0;if(Q.length>=YF)return q=!0,!1;return Q.push(X.join("")),X=[],W=!1,!0};for(let H=0;H<$.length;H++){let L=$[H]??"";if(L==="'"&&!B){K=!K,W=!0;continue}if(L==='"'&&!K){B=!B,W=!0;continue}if(!K&&!B&&NF(L)){if(!G())return{tokens:null,limited:q};continue}if(!K&&!B&&L==="#"&&!W)break;if(L==="$"&&!K){let M=$.slice(H).match(XF);if(!M?.[1]||!U(J(M[1])))return{tokens:null,limited:q};H+=M[0].length-1;continue}if(L!=="\\"){if(!U(L))return{tokens:null,limited:q};continue}let Z=$[H+1];if(Z===void 0)return{tokens:null,limited:q};if(K&&Z!=="'"&&Z!=="\\"){if(!U("\\"))return{tokens:null,limited:q};continue}if(Z==="c"){if(B)return{tokens:null,limited:q};break}if(Z==="_"&&!K&&!B){if(!G())return{tokens:null,limited:q};H++;continue}let O=MF(Z);if(O===void 0||!U(O))return{tokens:null,limited:q};H++}if(K||B||!G())return{tokens:null,limited:q};return{tokens:Q,limited:!1}}function MF($){if($==="f")return"\f";if($==="n")return`
29
- `;if($==="r")return"\r";if($==="t")return"\t";if($==="v")return"\v";if($==="_")return" ";if($==="#"||$==="$"||$==='"'||$==="'")return $;if($==="\\")return"\\";return}function NF($){return $===" "||$==="\t"||$===`
30
- `||$==="\r"||$==="\f"||$==="\v"}function B3($,J,Q){if(J==="")return null;if(!$&&!uB(J))return null;let X=uB(J)?QF(J).root:Q.realpath($??"/");if(X===null)return null;try{return d0(X,J,Q)}catch{return null}}function FF($){if(s1($,1)==="-v")return[...p(["type"]),...$.slice(2)];let J=1;while(J<$.length){let Q=s1($,J);if(!Q)break;if(Q==="-p"||Q==="-v"||Q==="-V"){J++;continue}if(Q==="--")return $.slice(J+1);if(Q.startsWith("-")&&!Q.startsWith("--")&&Q.length>1){if(!/^[pvV]+$/.test(Q.slice(1)))break;J++;continue}break}return $.slice(J)}function l1($,J,Q){return xJ($,J,Q).tokens}function xJ($,J,Q,X){if(!dB($[0]??""))return{tokens:[...$],envAssignments:new Map,cwd:Q};let Y=N2(p($),J,Q,X);return{tokens:Y.words.map(h),envAssignments:Y.envAssignments,cwd:Y.cwd,unverifiableEnvSplit:Y.unverifiableEnvSplit}}import{isAbsolute as pV,normalize as cV,resolve as uq}from"path";function q9(){return[]}function U9(){return[]}function G9(){return{words:[],redirections:[],nested:[],start:-1,end:-1,reset(){this.words=[],this.redirections=[],this.nested=[],this.start=-1,this.end=-1}}}function VF($){return Object.freeze({...$,span:Object.freeze($.span),words:Object.freeze($.words),redirections:Object.freeze($.redirections.map((J)=>Object.freeze({...J,span:Object.freeze(J.span),...J.heredoc?{heredoc:Object.freeze({...J.heredoc,bodySpan:Object.freeze(J.heredoc.bodySpan),terminatorSpan:Object.freeze(J.heredoc.terminatorSpan)})}:{}}))),nested:Object.freeze($.nested.map((J)=>I1(J)))})}function H9($,J,Q){$.push(Q),J.reset()}function _F($,J,Q,X,Y){if(X<=Q)return;$.push({raw:J.slice(Q,X),span:{start:Q,end:X},provenance:Y})}function Z9($){let J=[];return{parts:J,push:(Q,X,Y)=>_F(J,$,Q,X,Y)}}function uJ($){let J=$.parts??[{raw:$.raw,span:$.span,provenance:$.provenance}];return Object.freeze({kind:"word",...$,span:Object.freeze($.span),parts:Object.freeze(J.map((Q)=>Object.freeze({...Q,span:Object.freeze(Q.span)})))})}function t2($,J,Q,X,Y,W,K){return uJ({text:X,raw:$.slice(J,Q),span:{start:J,end:Q},provenance:Y,quoted:W,...K?{parts:K}:{}})}function I1($){return Object.freeze({...$,span:Object.freeze($.span),issues:Object.freeze($.issues.map((J)=>Object.freeze({...J,span:Object.freeze(J.span)}))),nodes:Object.freeze($.nodes.map((J)=>{if(J.kind==="command")return VF(J);if(J.kind==="group"||J.kind==="function")return Object.freeze({...J,span:Object.freeze(J.span),body:I1(J.body)});return Object.freeze({...J,span:Object.freeze(J.span)})}))})}function mJ($,J,Q){if(J>=Q||iB($[J]??""))return null;let X="",Y=!1,W=!1,K=J;while(K<Q&&!iB($[K]??"")){let B=$[K]??"";if(B==="'"){Y=!0;let q=rB($,K+1,Q,"'");X+=q.text,W||=!q.closed,K=q.next;continue}if(B==='"'){Y=!0;let q=rB($,K+1,Q,'"');X+=q.text,W||=!q.closed,K=q.next;continue}if(B==="\\"){Y=!0;let q=$[K+1];if(!q||q===`
31
- `||q==="\r"){W=!0;break}X+=q,K+=2;continue}if(B==="`"||$.startsWith("$(",K)||$.startsWith("${",K)||$.startsWith("<(",K)||$.startsWith(">(",K))W=!0;X+=B,K++}return{delimiter:X,quoted:Y,next:K,span:{start:J,end:K},ambiguous:W}}function lJ($,J,Q,X){let Y=[],W=J;for(let K of X){let B=W,q=!1;while(W<Q){let U=DF($,W,Q);if((K.stripTabs?U.text.replace(/^\t+/,""):U.text)===K.delimiter){K.attach({body:K.stripTabs?zF($.slice(B,W)):$.slice(B,W),delimiter:K.delimiter,quotedDelimiter:K.quotedDelimiter,stripTabs:K.stripTabs,bodySpan:{start:B,end:W},terminatorSpan:{start:W,end:U.contentEnd}}),W=U.next,q=!0;break}if(U.next<=W)break;W=U.next}if(q)continue;return Y.push({code:"unterminated-heredoc",message:`heredoc delimiter ${K.delimiter} was not found`,span:K.declarationSpan}),{next:Q,issues:Y,terminated:!1}}return{next:W,issues:Y,terminated:!0}}function rB($,J,Q,X){let Y="",W=J;while(W<Q&&$[W]!==`
32
- `&&$[W]!=="\r"){let K=$[W]??"";if(K===X)return{text:Y,next:W+1,closed:!0};if(X==='"'&&K==="\\"&&$[W+1]){let B=$[W+1]??"";Y+=["$","`",'"',"\\"].includes(B)?B:`\\${B}`,W+=2;continue}Y+=K,W++}return{text:Y,next:W,closed:!1}}function iB($){return/[\s;&|<>)]/u.test($)||$==="`"}function DF($,J,Q){let X=J;while(X<Q&&$[X]!==`
20
+ ${yM($.intent??"manual_only")}`,B}function yM($){switch($){case"hard_stop":return"Do not retry this operation or attempt any workaround (other tools, flags, or paths). Report the block to the user and continue with the rest of the task.";case"use_alternative":return"Do not retry the blocked form. Continue the task using the safer alternative described above.";case"scope_down":return"Retry with a narrower, explicit target as described above. Escalate to the user if the broad operation is truly required.";case"manual_only":return"If this operation is truly needed, ask the user for explicit permission and have them run the command manually.";case"stop_and_explain":return"Do not brute-force variants. Simplify or restructure the command so it can be analyzed, or report the block to the user."}}function cK($,J){return $.length>J?`${$.slice(0,J)}...`:$}function rK($,J){if($.decision.kind!=="deny")return;let Q=J.includeEvidence?$.decision.evidence.find((X)=>X.kind==="command"):void 0;return{reason:$.decision.reason,ruleId:$.decision.ruleId,intent:$.decision.intent,command:Q?.command,segment:Q?.segment,toolName:J.toolName,...$.configFallback?{configWarning:$.configFallback.reason}:{}}}function iK($={}){return{reason:v6,intent:"stop_and_explain",command:$.command,segment:$.segment??$.command,toolName:$.toolName}}function oK($){return dK({...$,redact:R0})}function nK($){return R0($ instanceof Error?$.message:String($))}import{basename as xM,dirname as uM,join as sK}from"path";var f6=Object.freeze({maxEnvironmentExpansionDepth:64,maxMissingSuffixComponents:256,maxRealpathAttempts:1024,maxProcessedCandidateBytes:4194304});class o1 extends Error{name="PathCanonicalizationLimitError";constructor(){super("Path canonicalization work limit exceeded.")}}function s4(){return{realpathAttempts:0,processedCandidateBytes:0,resolvedPaths:new Map}}function H2($){return{...s4(),environment:$}}var h6=new Set(["CC_SAFETY_NET_HOME","CLAUDE_CONFIG_DIR","CODEX_HOME","COPILOT_HOME","GEMINI_CLI_HOME","HOME","KIMI_CODE_HOME","KIMI_SHARE_DIR","OPENCODE_CONFIG","OPENCODE_CONFIG_DIR","PI_CODING_AGENT_DIR","ProgramData","TMPDIR","XDG_CONFIG_HOME","XDG_DATA_HOME"]);function k6($,J){return RJ($,0,J)}function RJ($,J,Q){let X="",Y=0;while(Y<$.length){if($[Y]!=="$"){X+=$[Y],Y++;continue}if($[Y+1]==="{"){let K=bJ($,Y+2),B=mM($,Y,J);if(B===null){if(h6.has(K))throw new o1;X+=$.slice(Y);break}let q=$.slice(Y,B+1);X+=lM(q,J,Q),Y=B+1;continue}let W=bJ($,Y+1);if(!W){X+="$",Y++;continue}X+=PJ(W,Q)??`$${W}`,Y+=W.length+1}return X}function mM($,J,Q){let X=1;for(let Y=J+2;Y<$.length;Y++){if($[Y]==="\\"){Y++;continue}if($[Y]==="$"&&$[Y+1]==="{"){if(X++,Q+X>f6.maxEnvironmentExpansionDepth)throw new o1;Y++;continue}if($[Y]!=="}")continue;if(X--,X===0)return Y}return null}function lM($,J,Q){let X=$.slice(2,-1),Y=bJ(X,0);if(!Y)return $;let W=X.slice(Y.length);if(!W)return PJ(Y,Q)??$;let K=[":-",":+",":=",":?","-","+","=","?"].find((U)=>W.startsWith(U));if(!K){if(h6.has(Y))throw new o1;return $}if(!h6.has(Y))return $;if(K.endsWith("="))throw new o1;let B=PJ(Y,Q),q=K.startsWith(":")?B!==null&&B!=="":B!==null;if(K.endsWith("?")&&!q)throw new o1;if(K.endsWith("-")||K.endsWith("?"))return q?B??"":RJ(W.slice(K.length),J+1,Q);return q?RJ(W.slice(K.length),J+1,Q):""}function bJ($,J){if(!/[A-Za-z_]/.test($[J]??""))return"";let Q=J+1;while(/[A-Za-z0-9_]/.test($[Q]??""))Q++;return $.slice(J,Q)}function J1($,J,Q=s4()){if(!$)return $;let X=Q.resolvedPaths.get($);if(X!==void 0)return X;let Y=[],W=$;while(!0){if(Q.realpathAttempts++,Q.processedCandidateBytes+=Buffer.byteLength(W),Q.realpathAttempts>f6.maxRealpathAttempts||Q.processedCandidateBytes>f6.maxProcessedCandidateBytes)throw new o1;let K=J.realpath(W);if(K!==null){let q=Y.length===0?K:sK(K,...Y.reverse());return Q.resolvedPaths.set($,q),q}let B=uM(W);if(B===W){let q=Y.length===0?W:sK(W,...Y.reverse());return Q.resolvedPaths.set($,q),q}if(Y.length>=f6.maxMissingSuffixComponents)throw new o1;Y.push(xM(W)),W=B}}function PJ($,J){if(!h6.has($))return null;if($==="HOME")return J.env.get("HOME")??J.home;return J.env.get($)??null}function h($){return $.provenance==="command-substitution"?$.raw:$.text}function p2($,J){return $==="posix"?J:p(J.map((Q)=>Q.text))}function g6($,J){return $&&$.provenance!=="unknown"?$.provenance==="literal":!/[$`*?[\]]/.test(J)}function p($){return $.map((J)=>({kind:"word",text:J,raw:J,span:{start:0,end:0},provenance:"unknown",quoted:!1,parts:[]}))}import{existsSync as SJ,lstatSync as sM,readFileSync as m6,realpathSync as e4,statSync as t4}from"fs";import{dirname as CJ,isAbsolute as TJ,join as l6,resolve as p6}from"path";import{lstatSync as pM,realpathSync as cM}from"fs";import{homedir as dM,tmpdir as rM}from"os";var i0={realpath:($)=>{try{return cM($)}catch{return null}},entryKind:($)=>{let J=pM($,{throwIfNoEntry:!1});if(!J)return"missing";return J.isSymbolicLink()?"symlink":"present"}};function c2(){return process.env.HOME||dM()}function E0(){return{env:new Map(Object.entries(process.env).flatMap(([$,J])=>J===void 0?[]:[[$,J]])),home:c2(),tmpdir:rM(),paths:i0}}var AJ=["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE"],iM=new Set(AJ);var aK=new Set(["GIT_CONFIG_GLOBAL","GIT_CONFIG_NOSYSTEM","GIT_CONFIG_SYSTEM","HOME","XDG_CONFIG_HOME"]),y6=new Set(["GIT_SSH_COMMAND","GIT_SSH","GIT_SSH_VARIANT"]),oM=/^([A-Za-z_][A-Za-z0-9_]*)\+=/;function nM($){return iM.has($)}function a4($){return $==="GIT_CONFIG_COUNT"||$==="GIT_CONFIG_PARAMETERS"||/^GIT_CONFIG_(KEY|VALUE)_\d+$/.test($)}function EJ($){return nM($)||aK.has($)||y6.has($)||a4($)}function u1($,J,Q){return Q?.has($)?Q.get($):J.get($)}function x6($,J){let Q=u1("GIT_CONFIG_COUNT",$,J);if(Q===void 0)return{state:"absent"};if(Q==="")return{state:"valid",count:0};if(!/^\d+$/.test(Q))return{state:"invalid"};let X=Number(Q);return Number.isSafeInteger(X)&&X<=1024?{state:"valid",count:X}:{state:"invalid"}}function u6($,J,Q){let Y=$.match(oM)?.[1];if(!Y||!EJ(Y))return null;let W=$.indexOf("=");return{name:Y,value:`${u1(Y,J,Q)??""}${$.slice(W+1)}`}}function tK($){return $B($,y6)}function eK($){return $B($,aK)}function $B($,J){if(!$)return!1;for(let Q of $.keys())if(J.has(Q))return!0;return!1}var W0=new Set(["-c","-C","--git-dir","--work-tree","--namespace","--super-prefix","--config-env"]);function XB($,J){return AJ.some((Q)=>J?.has(Q)||$.has(Q))}function YB($,J){if(!J)return{gitCwd:null,hasExplicitGitContext:!1};let Q;try{Q=e4(p6(J))}catch{return{gitCwd:null,hasExplicitGitContext:!1}}if(!BB(Q))return{gitCwd:null,hasExplicitGitContext:!1};let X=!1,Y=1;while(Y<$.length){let W=$[Y];if(!W)break;if(W==="--")break;if(!W.startsWith("-"))break;if(W==="-C"){let K=$[Y+1];if(!K)return{gitCwd:null,hasExplicitGitContext:X};let B=QB(Q,K);if(!B)return{gitCwd:null,hasExplicitGitContext:X};Q=B,Y+=2;continue}if(W.startsWith("-C")&&W.length>2){let K=QB(Q,W.slice(2));if(!K)return{gitCwd:null,hasExplicitGitContext:X};Q=K,Y++;continue}if(W==="--git-dir"||W==="--work-tree"){X=!0,Y+=2;continue}if(W.startsWith("--git-dir=")||W.startsWith("--work-tree=")){X=!0,Y++;continue}if(W0.has(W))Y+=2;else if(W.startsWith("-c")&&W.length>2)Y++;else Y++}return{gitCwd:Q,hasExplicitGitContext:X}}function WB($){let J=GN($);if(!J)return!1;try{let Q=sM(J);if(Q.isSymbolicLink()||!Q.isFile())return!1;let X=wJ(J);if(!X?.commonDir)return!1;if(!eM(X.gitDir,J))return!1;return $N(X.gitDir,CJ(J))}catch{return!1}}function wJ($){try{let J=aM($);if(!J)return null;let Q=e4(TJ(J)?J:p6(CJ($),J));if(!t4(Q).isDirectory())return null;return{gitDir:Q,commonDir:tM(Q)}}catch{return null}}function aM($){let J=m6($,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(!J.startsWith("gitdir:"))return null;return J.slice(7).trim()||null}function tM($){try{let J=m6(l6($,"commondir"),"utf-8").split(/\r?\n/,1)[0]?.trim();if(!J)return null;let Q=e4(TJ(J)?J:p6($,J));return t4(Q).isDirectory()?Q:null}catch{return null}}function eM($,J){let Q=JN($);return Q===null?!1:KB($,Q,J)}function $N($,J){let Q=QN($);return Q===null?!0:KB($,Q,J)}function JN($){let J=l6($,"gitdir");if(!SJ(J))return null;let Q=m6(J,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";return Q===""?null:Q}function QN($){let J=l6($,"config.worktree");return SJ(J)?BN(J):null}function KB($,J,Q){return YN(XN($,J),Q)}function XN($,J){return TJ(J)?J:p6($,J)}function YN($,J){try{return WN($,J)}catch{return!1}}function WN($,J){try{let Q=t4($),X=t4(J);if(Q.ino!==0&&X.ino!==0&&Q.dev===X.dev&&Q.ino===X.ino)return!0}catch{}return JB($)===JB(J)}function JB($){return KN(e4.native($))}function KN($){let J=$.replace(/^\\\\\?\\UNC\\/i,"//").replace(/^\\\\\?\\/i,"");if(J=J.replace(/\\/g,"/"),J.length>1&&J.endsWith("/"))J=J.slice(0,-1);return process.platform==="win32"?J.toLowerCase():J}function BN($){let J=m6($,"utf-8"),Q=!1,X=null;for(let Y of J.split(/\r?\n/)){let W=Y.trim();if(W===""||W.startsWith("#")||W.startsWith(";"))continue;if(W.startsWith("[")){Q=/^\[core\]$/i.test(W);continue}if(!Q)continue;let K=W.match(/^worktree\s*=\s*(.*)$/i);if(K)X=qN(K[1]??"")}return X}function qN($){let J=$.trim();if(!J.startsWith('"')||!J.endsWith('"'))return J;return UN(J.slice(1,-1))}function UN($){let J="";for(let Q=0;Q<$.length;Q++){let X=$[Q];if(X!=="\\"){J+=X;continue}let Y=$[Q+1];if(Y===void 0){J+=X;continue}switch(Y){case"\\":case'"':J+=Y;break;case"n":J+=`
21
+ `;break;case"t":J+="\t";break;case"b":J+="\b";break;default:J+=`\\${Y}`;break}Q++}return J}function QB($,J){try{let Q=d0($,J,i0);return BB(Q)?Q:null}catch{return null}}function BB($){try{return t4($).isDirectory()}catch{return!1}}function GN($){try{return $3(e4($))}catch{return null}}function $3($){let J=$;while(!0){let Q=l6(J,".git");if(SJ(Q))return Q;let X=CJ(J);if(X===J)return null;J=X}}function vJ($,J){return{value:$,work:J}}function j($,J){if($.work)$.work.units=Math.min(Number.MAX_SAFE_INTEGER,$.work.units+1);return $.value[J]}function K1($){return $.value.length}function J3($,J,Q=1){if($)$.units=Math.min(Number.MAX_SAFE_INTEGER,$.units+J.length*Q)}function S1($,J){J3($,J)}function Z2($){if(!$)return!1;let J=$.charCodeAt(0);return J>=48&&J<=57||J>=65&&J<=90||J===95||J>=97&&J<=122}function t($){if(!$)return!1;let J=$.charCodeAt(0);return J===9||J===10||J===11||J===12||J===13||J===32||J===160||J===65279||J===5760||J>=8192&&J<=8202||J===8232||J===8233||J===8239||J===8287||J===12288}function fJ($){return $===`
22
+ `||$==="\r"||$==="\u2028"||$==="\u2029"}function e($,J,Q){if(J+Q.length>K1($))return!1;for(let X=0;X<Q.length;X++)if(j($,J+X)!==Q[X])return!1;return!0}function S0($,J,Q){return!Z2(j($,J-1))&&e($,J,Q)&&!Z2(j($,J+Q.length))}function C0($,J){return Z2(j($,J-1))!==Z2(j($,J))}function L1($){return $===`
23
+ `||$===";"||$==="&"||$==="|"}function d2($){return $==="|"||$===";"}function c6($,J,Q){let X=vJ($,Q);if(J==="rm")return HN(X);if(J==="dd")return LN(X);return LB(X,!0)}function d6($,J,Q){let X=vJ($,Q);if(J==="rm")return ON(X);if(J==="reset-hard")return HB(X,"--ha","rd");if(J==="reset-merge")return HB(X,"--me","rge");if(J==="clean")return VN(X);if(J==="checkout")return DN(X);if(J==="push-force")return zN(X);if(J==="push-refspec")return IN(X);if(J==="push-delete")return jN(X);if(J==="branch")return RN(X);if(J==="tag")return AN(X);if(J==="restore")return EN(X);return LB(X,!1)}function HN($){let J=!1,Q=!1,X=!1,Y=-1;for(let W=0;W<=K1($);W++){let K=j($,W);if(!J){let q=j($,W+2);if(S0($,W,"rm")&&t(q)&&q!==`
24
+ `)J=!0,W++;continue}let B=ZN($,W);if(K===`
25
+ `||B!==-1){if(J=!1,Q=!1,X=!1,Y=-1,B!==-1)W=B-1;continue}if(K===";"||K==="&"||K==="|"||W===K1($)){if(Y>=0){let q=qB($,Y,W);Q||=q.recursive,X||=q.force}if(Q&&X)return!0;J=!1,Q=!1,X=!1,Y=-1;continue}if(t(K)){if(Y>=0){if(e($,Y,"--")&&W-Y===2)J=!1,Q=!1,X=!1;else{let q=qB($,Y,W);if(Q||=q.recursive,X||=q.force,Q&&X)return!0}Y=-1}continue}if(Y<0)Y=W}return!1}function ZN($,J){if(j($,J)!=="\\"||j($,J-1)==="\\")return-1;if(e($,J,String.raw`\n`))return J+2;if(e($,J,String.raw`\x0a`)||e($,J,String.raw`\x0A`))return J+5;if(e($,J,String.raw`\u000a`)||e($,J,String.raw`\u000A`))return J+7;return e($,J,String.raw`\012`)?J+4:-1}function qB($,J,Q){if(UB($,J,Q,"recursive"))return{recursive:!0,force:!1};if(UB($,J,Q,"force"))return{recursive:!1,force:!0};if(j($,J)!=="-"||j($,J+1)==="-")return{recursive:!1,force:!1};let X=!1,Y=!1;for(let W=J+1;W<Q;W++){let K=j($,W);X||=K==="r"||K==="R",Y||=K==="f"||K==="F"}return{recursive:X,force:Y}}function UB($,J,Q,X){let Y=Q-J-2;if(Y<1||Y>X.length||!e($,J,"--"))return!1;for(let W=0;W<Y;W++)if(j($,J+W+2)!==X[W])return!1;return!0}function LN($){let J=!1;for(let Q=0;Q<K1($);Q++){if(L1(j($,Q))){J=!1;continue}if(S0($,Q,"dd")){J=!0,Q++;continue}if(!J||!S0($,Q,"of")||!e($,Q,"of=/dev/"))continue;let X=Q+8;if(X<K1($)&&!t(j($,X))&&j($,X)!=="'"&&j($,X)!=='"')return!0}return!1}function ON($){let J=!1,Q=!1,X=!1;for(let Y=0;Y<=K1($);){let W=j($,Y);if(Y===K1($)||L1(W)){J=!1,Q=!1,X=!1,Y++;continue}let K=NN($,Y);if(K>=0){if(MN($,K))return!0;let B=K,q=!1;while(t(j($,B)))q||=j($,B)===`
26
+ `,B++;if(q)Q=!1,X=!1;J=!0,Y=B;continue}if(!J){Y++;continue}if(e($,Y,"--")&&(Y===0||t(j($,Y-1)))&&(!j($,Y+2)||t(j($,Y+2))||L1(j($,Y+2)))){J=!1,Q=!1,X=!1,Y+=2;continue}if(Q||=e($,Y,"--recursive")&&C0($,Y+11)||hJ($,Y,"recursive"),X||=e($,Y,"--force")&&C0($,Y+7)||hJ($,Y,"force"),Q&&X)return!0;Y++}return!1}function hJ($,J,Q){if(!e($,J,"--"))return!1;let X=0;while(X<=Q.length){let Y=j($,J+X+2);if(!Y||t(Y)||L1(Y))break;if(Y!==Q[X])return!1;X++}return X>0&&C0($,J+X+2)}function MN($,J){let Q=J,X=!1,Y=!1;while(Q<K1($)){while(t(j($,Q)))Q++;let W=Q;while(Q<K1($)&&!t(j($,Q)))Q++;if(j($,W)!=="-"||Q-W===2&&e($,W,"--"))return!1;let K=GB($,W,"recursive"),B=GB($,W,"force");if(X&&B||Y&&K)return!0;if(X||=K,Y||=B,j($,W+1)==="-")continue;let q=FN($,W,Q);if(q.combined||X&&q.forceAtBoundary||Y&&q.recursiveAtBoundary)return!0;X||=q.recursive,Y||=q.force}return!1}function GB($,J,Q){return e($,J,`--${Q}`)&&C0($,J+Q.length+2)||hJ($,J,Q)}function NN($,J){if(J>0&&Z2(j($,J-1)))return-1;let Q=J;if(j($,Q)==="\\")Q++;if(j($,Q)!=="r")return-1;if(Q++,j($,Q)==="\\")Q++;if(j($,Q)!=="m"||!t(j($,Q+1)))return-1;return Q+1}function FN($,J,Q){let X=!1,Y=!1,W=!1,K=!1,B=!1;if(j($,J)!=="-")return{recursive:X,force:Y,recursiveAtBoundary:W,forceAtBoundary:K,combined:B};let q="";for(let U=J+1;U<Q;U++){let G=j($,U)??"",H=(G==="r"||G==="f")&&C0($,U+1);X||=G==="r",Y||=G==="f",W||=G==="r"&&H,K||=G==="f"&&H,B||=(q==="r"&&G==="f"||q==="f"&&G==="r")&&H,q=G}return{recursive:X,force:Y,recursiveAtBoundary:W,forceAtBoundary:K,combined:B}}function HB($,J,Q){return X3($,"reset",d2,!0,(X)=>j($,X)==="-"&&r2($,X,J,Q)?!0:X)}function VN($){return X3($,"clean",d2,!0,(J)=>{if(j($,J)!=="-")return J;if(r2($,J,"--fo","rce"))return!0;let Q=Q3($,J,d2);for(let X=J+1;X<Q;X++)if(j($,X)==="f")return!0;return Q-1})}function r6($,J,Q){if(!S0($,J,"git"))return null;let X=J+3;if(!t(j($,X)))return{commandEnd:-1,next:X};while(t(j($,X)))X++;while(X<K1($)){if(L1(j($,X)))return{commandEnd:-1,next:X};let Y=Q3($,X,L1);if(S0($,X,Q))return{commandEnd:X+Q.length,next:Y};if(j($,X)!=="-")return{commandEnd:-1,next:Y};let W=Y-X===2&&e($,X,"--"),K=_N($,X,Y);X=Y;while(t(j($,X)))X++;if(W)return{commandEnd:S0($,X,Q)?X+Q.length:-1,next:Q3($,X,L1)};if(!K)continue;if(X>=K1($)||L1(j($,X)))return{commandEnd:-1,next:X};X=Q3($,X,L1);while(t(j($,X)))X++}return{commandEnd:-1,next:X}}function _N($,J,Q){for(let X of W0)if(Q-J===X.length&&e($,J,X))return!0;return!1}function DN($){return ZB($,{command:"checkout",longPrefix:"--fo",longOptional:"rce",shortFlag:"f",excludedShortStarts:"bBU"})}function zN($){return X3($,"push",d2,!0,(J)=>{if(j($,J)!=="-")return J;if(j($,J+1)==="f"&&!Z2(j($,J+2))&&!e($,J+2,"-with-lease"))return!0;let Q=OB($,J,"--fo","rce");if(Q>=0&&!e($,Q,"-with-lease"))return!0;return J})}function IN($){return X3($,"push",L1,!1,(J)=>{if(t(j($,J))&&j($,J+1)==="+"&&J+2<K1($)&&!L1(j($,J+2))&&!t(j($,J+2)))return!0;if(j($,J)===":"&&j($,J+1)==="+")return!0;return J})}function jN($){return X3($,"push",L1,!1,(J)=>{if(j($,J)==="-"&&r2($,J,"--de","lete"))return!0;if(t(j($,J))&&j($,J+1)===":"&&J+2<K1($)&&!t(j($,J+2))&&!L1(j($,J+2)))return!0;return J})}function RN($){let J=!1,Q=!1,X=!1;for(let Y=0;Y<=K1($);Y++){if(Y===K1($)||L1(j($,Y))){if(Q&&X)return!0;J=!1,Q=!1,X=!1;continue}if(!J){let B=r6($,Y,"branch");if(B){J=B.commandEnd>=0,Y=Math.max(Y,(J?B.commandEnd:B.next)-1);continue}}if(!J||j($,Y)!=="-")continue;let W=Q3($,Y,L1),K=bN($,Y,W);if(Q||=K.deletion,X||=K.force,Q&&X)return!0;Y=W-1}return!1}function bN($,J,Q){let X=!1,Y=!1;for(let W=J;W<Q;W++){if(j($,W)!=="-")continue;if(r2($,W,"--de","lete"))X=!0;if(r2($,W,"--fo","rce"))Y=!0;if(j($,W+1)==="-")continue;let K=W+1,B=!1,q=!1,U=!1;while(K<Q&&PN(j($,K))){let G=j($,K);B||=G==="d"||G==="D",q||=G==="f",U||=G==="D",K++}if(!C0($,K))continue;X||=B,Y||=q||U}return{deletion:X,force:Y}}function PN($){if(!$)return!1;let J=$.charCodeAt(0);return J>=65&&J<=90||J>=97&&J<=122}function AN($){return ZB($,{command:"tag",longPrefix:"--de",longOptional:"lete",shortFlag:"d",excludedShortStarts:""})}function ZB($,J){let Q=[{outerActive:!1,shortActive:!1,hasShortFlag:!1,depth:0,quote:"",escaped:!1}];for(let X=0;X<K1($);X++){let Y=j($,X),W=Q[Q.length-1];if(!W)return!1;let K=W.escaped;if(W.escaped=!K&&W.quote!=="'"&&Y==="\\",!K&&Y==="'"&&W.quote!=='"')W.quote=W.quote==="'"?"":"'";if(!K&&Y==='"'&&W.quote!=="'")W.quote=W.quote==='"'?"":'"';if(Y==="$"&&j($,X+1)==="("&&(Q.length===1||!K&&W.quote!=="'")){Q.push({outerActive:!1,shortActive:!1,hasShortFlag:!1,depth:1,quote:"",escaped:!1}),X++;continue}if(!K&&!W.quote&&Q.length>1&&Y==="("){W.depth++;continue}if(!K&&!W.quote&&Q.length>1&&Y===")"){if(W.depth--,W.depth===0)Q.pop();continue}if(t(Y))W.shortActive=!1,W.hasShortFlag=!1;if(!W.outerActive){let B=r6($,X,J.command);if(B){W.outerActive=B.commandEnd>=0&&t(j($,B.commandEnd)),W.shortActive=!1,W.hasShortFlag=!1,X=Math.max(X,(W.outerActive?B.commandEnd:B.next)-1);continue}}if(W.outerActive&&Y==="-"){if(r2($,X,J.longPrefix,J.longOptional))return!0;W.shortActive||=!J.excludedShortStarts.includes(j($,X+1)??"")}if(W.hasShortFlag||=W.shortActive&&Y===J.shortFlag,W.hasShortFlag&&C0($,X+1))return!0;if(d2(Y))W.outerActive=!1}return!1}function X3($,J,Q,X,Y){let W=!1;for(let K=0;K<K1($);K++){let B=j($,K),q=Q(B);if(!W&&!q){let U=r6($,K,J);if(U){W=U.commandEnd>=0&&(!X||t(j($,U.commandEnd))),K=Math.max(K,(W?U.commandEnd:U.next)-1);continue}}if(W){let U=Y(K);if(U===!0)return!0;for(let G=K;G<=U;G++)if(Q(j($,G)))W=!1;K=U}if(q)W=!1}return!1}function EN($){let J=!1;for(let Q=0;Q<K1($);Q++){if(fJ(j($,Q))){if(J)return!0;J=!1;continue}if(!J){let X=r6($,Q,"restore");if(X){J=X.commandEnd>=0,Q=Math.max(Q,(J?X.commandEnd:X.next)-1);continue}}if(J&&j($,Q)==="-"&&j($,Q+1)==="-"&&(e($,Q+2,"staged")||e($,Q+2,"help")))J=!1}return J}function LB($,J){let Q=!1;for(let X=0;X<K1($);X++){let Y=j($,X),W=J?fJ(Y):L1(Y);if(Q&&t(Y)&&j($,X+1)==="-"&&S0($,X+2,"delete"))return!0;if(W){Q=!1;continue}if(S0($,X,"find"))Q=!0,X+=3}return!1}function Q3($,J,Q){let X=J;while(X<K1($)&&!t(j($,X))&&!Q(j($,X)))X++;return X}function OB($,J,Q,X){if(!e($,J,Q))return-1;let Y=J+Q.length;for(let W=0;W<X.length&&j($,Y)===X[W];W++)Y++;return C0($,Y)?Y:-1}function r2($,J,Q,X){return OB($,J,Q,X)>=0}var SN=["git.ssh-env","git.alias-config","git.checkout-force","git.checkout-double-dash","git.checkout-ref-path","git.checkout-pathspec-from-file","git.checkout-ambiguous","git.switch-discard-changes","git.switch-force","git.restore-worktree","git.restore-unstaged","git.reset-hard","git.reset-merge","git.clean-force","git.push-force","git.push-delete","git.push-mirror","git.branch-force-delete","git.rebase-abort","git.merge-abort","git.tag-delete","git.reflog-delete","git.stash-drop","git.stash-clear","git.worktree-remove-force","rm.recursive-force-root-or-home","rm.git-metadata","rm.recursive-force-dynamic-target","rm.recursive-force-home-cwd","rm.recursive-force-cwd-self","rm.recursive-force-outside-cwd","rm.recursive-force-paranoid","powershell.remove-item-root-or-home","powershell.remove-item-recursive-force-root-or-home","powershell.remove-item-git-metadata","powershell.remove-item-recursive-force-dynamic-target","powershell.remove-item-recursive-force-home-cwd","powershell.remove-item-recursive-force-cwd-self","powershell.remove-item-recursive-force-outside-cwd","powershell.remove-item-recursive-force-paranoid","powershell.remove-item-pipeline-dynamic-target","find.delete","find.delete-git-metadata","find.exec-rm-recursive-force","dd.device-write","mkfs.device","shred.target","interpreter.dangerous-command","interpreter.one-liner-paranoid","awk.system-dynamic","xargs.rm-recursive-force-dynamic","xargs.shell-dynamic","parallel.rm-recursive-force-dynamic","parallel.shell-dynamic","parallel.command-stream-dynamic","shell.dynamic-structure","shell.dynamic-executable","raw-text.dangerous-command"],i6=new Set(SN),o6=[{id:"git.ssh-env",category:"Git",label:"Git SSH environment override",description:"Blocks Git network operations with SSH environment overrides.",example:'GIT_SSH_COMMAND="./ssh-wrapper" git push',intent:"manual_only"},{id:"git.alias-config",category:"Git",label:"Git command-line alias",description:"Blocks command-line Git aliases that cannot be safely resolved.",example:"git -c alias.wipe='!rm -rf /' wipe",intent:"manual_only"},{id:"git.checkout-force",category:"Git",label:"Git checkout force",description:"Blocks forced checkout operations that discard local changes.",example:"git checkout --force main",intent:"use_alternative"},{id:"git.checkout-double-dash",category:"Git",label:"Git checkout path restore",description:"Blocks checkout path restores after --.",example:"git checkout -- src/app.ts",intent:"use_alternative"},{id:"git.checkout-ref-path",category:"Git",label:"Git checkout ref and path",description:"Blocks checkout forms that mix a ref and path restore.",example:"git checkout HEAD -- src/app.ts",intent:"use_alternative"},{id:"git.checkout-pathspec-from-file",category:"Git",label:"Git checkout pathspec file",description:"Blocks checkout pathspec loading from a file.",example:"git checkout --pathspec-from-file=paths.txt",intent:"use_alternative"},{id:"git.checkout-ambiguous",category:"Git",label:"Git checkout ambiguous targets",description:"Blocks ambiguous checkout arguments that may restore paths.",example:"git checkout main src/app.ts",intent:"use_alternative"},{id:"git.switch-discard-changes",category:"Git",label:"Git switch discard changes",description:"Blocks branch switches that explicitly discard local changes.",example:"git switch --discard-changes main",intent:"use_alternative"},{id:"git.switch-force",category:"Git",label:"Git switch force",description:"Blocks forced branch switches.",example:"git switch --force main",intent:"use_alternative"},{id:"git.restore-worktree",category:"Git",label:"Git restore worktree",description:"Blocks worktree restore operations.",example:"git restore --worktree src/app.ts",intent:"use_alternative"},{id:"git.restore-unstaged",category:"Git",label:"Git restore unstaged",description:"Blocks unstaged restore operations.",example:"git restore src/app.ts",intent:"use_alternative"},{id:"git.reset-hard",category:"Git",label:"Git reset hard",description:"Blocks hard resets.",example:"git reset --hard",intent:"use_alternative"},{id:"git.reset-merge",category:"Git",label:"Git reset merge",description:"Blocks merge resets.",example:"git reset --merge",intent:"use_alternative"},{id:"git.clean-force",category:"Git",label:"Git clean force",description:"Blocks forced clean operations.",example:"git clean -fd",intent:"use_alternative"},{id:"git.push-force",category:"Git",label:"Git push force",description:"Blocks force pushes.",example:"git push --force origin main",intent:"use_alternative"},{id:"git.push-delete",category:"Git",label:"Git push delete",description:"Blocks remote ref deletion through push.",example:"git push --delete origin old-branch",intent:"manual_only"},{id:"git.push-mirror",category:"Git",label:"Git push mirror",description:"Blocks mirror pushes that can force-update or delete remote refs.",example:"git push --mirror origin",intent:"manual_only"},{id:"git.branch-force-delete",category:"Git",label:"Git branch force delete",description:"Blocks forced branch deletion.",example:"git branch -D old-branch",intent:"use_alternative"},{id:"git.rebase-abort",category:"Git",label:"Git rebase abort",description:"Blocks rebase abort operations.",example:"git rebase --abort",intent:"use_alternative"},{id:"git.merge-abort",category:"Git",label:"Git merge abort",description:"Blocks merge abort operations.",example:"git merge --abort",intent:"use_alternative"},{id:"git.tag-delete",category:"Git",label:"Git tag delete",description:"Blocks tag deletion.",example:"git tag --delete v1.0.0",intent:"manual_only"},{id:"git.reflog-delete",category:"Git",label:"Git reflog delete",description:"Blocks reflog deletion.",example:"git reflog delete HEAD@{1}",intent:"manual_only"},{id:"git.stash-drop",category:"Git",label:"Git stash drop",description:"Blocks dropping stash entries.",example:"git stash drop stash@{0}",intent:"use_alternative"},{id:"git.stash-clear",category:"Git",label:"Git stash clear",description:"Blocks clearing all stash entries.",example:"git stash clear",intent:"manual_only"},{id:"git.worktree-remove-force",category:"Git",label:"Git worktree force remove",description:"Blocks forced worktree removal.",example:"git worktree remove --force ../feature",intent:"use_alternative"},{id:"rm.recursive-force-root-or-home",category:"Filesystem",label:"rm -rf root or home",description:"Blocks recursive forced removal of root or home paths.",example:"rm -rf /",intent:"hard_stop",catastrophic:!0},{id:"rm.git-metadata",category:"Filesystem",label:"rm Git metadata",description:"Blocks removal of protected Git metadata and hooks.",example:"rm -rf .git",intent:"hard_stop",catastrophic:!0},{id:"rm.recursive-force-dynamic-target",category:"Filesystem",label:"rm -rf dynamic target",description:"Blocks recursive forced removal with dynamic targets in strict mode.",example:'rm -rf "$target"',intent:"scope_down",activationCapability:"fail_closed"},{id:"rm.recursive-force-home-cwd",category:"Filesystem",label:"rm -rf from home cwd",description:"Blocks recursive forced removal while working in home.",example:'cd "$HOME" && rm -rf build',intent:"scope_down"},{id:"rm.recursive-force-cwd-self",category:"Filesystem",label:"rm -rf current directory",description:"Blocks recursive forced removal of the current directory.",example:"rm -rf .",intent:"scope_down"},{id:"rm.recursive-force-outside-cwd",category:"Filesystem",label:"rm -rf outside cwd",description:"Blocks recursive forced removal outside the original cwd.",example:"rm -rf ../outside",intent:"scope_down"},{id:"rm.recursive-force-paranoid",category:"Filesystem",label:"rm -rf paranoid mode",description:"Blocks non-temp recursive forced removal when paranoid rm is enabled.",example:"rm -rf ./cache",intent:"scope_down",activationCapability:"paranoid_rm"},{id:"powershell.remove-item-root-or-home",category:"PowerShell",label:"Remove-Item root or home",description:"Blocks PowerShell Remove-Item targeting root or home paths.",example:"Remove-Item C:\\",intent:"hard_stop",catastrophic:!0},{id:"powershell.remove-item-recursive-force-root-or-home",category:"PowerShell",label:"Remove-Item recursive force root or home",description:"Blocks recursive forced PowerShell removal of root or home paths.",example:"Remove-Item C:\\ -Recurse -Force",intent:"hard_stop",catastrophic:!0},{id:"powershell.remove-item-git-metadata",category:"PowerShell",label:"Remove-Item Git metadata",description:"Blocks PowerShell removal of protected Git metadata and hooks.",example:"Remove-Item .git -Recurse -Force",intent:"hard_stop",catastrophic:!0},{id:"powershell.remove-item-recursive-force-dynamic-target",category:"PowerShell",label:"Remove-Item recursive force dynamic target",description:"Blocks recursive forced PowerShell removal with dynamic targets in strict mode.",example:"Remove-Item $target -Recurse -Force",intent:"scope_down",activationCapability:"fail_closed"},{id:"powershell.remove-item-recursive-force-home-cwd",category:"PowerShell",label:"Remove-Item recursive force from home cwd",description:"Blocks recursive forced PowerShell removal while working in home.",example:"Set-Location $HOME; Remove-Item ./build -Recurse -Force",intent:"scope_down"},{id:"powershell.remove-item-recursive-force-cwd-self",category:"PowerShell",label:"Remove-Item recursive force current directory",description:"Blocks recursive forced PowerShell removal of the current directory.",example:"Remove-Item . -Recurse -Force",intent:"scope_down"},{id:"powershell.remove-item-recursive-force-outside-cwd",category:"PowerShell",label:"Remove-Item recursive force outside cwd",description:"Blocks recursive forced PowerShell removal outside the original cwd.",example:"Remove-Item ../outside -Recurse -Force",intent:"scope_down"},{id:"powershell.remove-item-recursive-force-paranoid",category:"PowerShell",label:"Remove-Item recursive force paranoid mode",description:"Blocks non-temp recursive forced PowerShell removal when paranoid rm is enabled.",example:"Remove-Item ./cache -Recurse -Force",intent:"scope_down",activationCapability:"paranoid_rm"},{id:"powershell.remove-item-pipeline-dynamic-target",category:"PowerShell",label:"Remove-Item pipeline dynamic target",description:"Blocks PowerShell Remove-Item with unverifiable pipeline input in strict mode.",example:"Get-ChildItem . -Recurse | Remove-Item -Force",intent:"scope_down",activationCapability:"fail_closed"},{id:"find.delete",category:"Filesystem",label:"find delete",description:"Blocks unsafe find -delete operations.",example:"find . -delete",intent:"scope_down"},{id:"find.delete-git-metadata",category:"Filesystem",label:"find delete Git metadata",description:"Blocks find -delete operations selecting protected Git metadata and hooks.",example:"find .git -delete",intent:"hard_stop",catastrophic:!0},{id:"find.exec-rm-recursive-force",category:"Filesystem",label:"find exec rm -rf",description:"Blocks find -exec rm -rf operations.",example:"find . -exec rm -rf {} +",intent:"scope_down"},{id:"dd.device-write",category:"Filesystem",label:"dd device write",description:"Blocks dd writing to a /dev device.",example:"dd if=/dev/zero of=/dev/sda",intent:"manual_only"},{id:"mkfs.device",category:"Filesystem",label:"mkfs device format",description:"Blocks mkfs formatting a /dev device.",example:"mkfs.ext4 /dev/sda1",intent:"manual_only"},{id:"shred.target",category:"Filesystem",label:"shred target",description:"Blocks shred against any target, including shred --help and shred --version.",example:"shred -u secret.txt",intent:"use_alternative"},{id:"interpreter.dangerous-command",category:"Execution",label:"Interpreter dangerous command",description:"Blocks interpreter one-liners containing dangerous commands.",example:`python -c "import os; os.system('rm -rf /')"`,intent:"use_alternative"},{id:"interpreter.one-liner-paranoid",category:"Execution",label:"Interpreter one-liner paranoid mode",description:"Blocks interpreter one-liners when paranoid interpreters is enabled.",example:'python -c "print(1)"',intent:"use_alternative",activationCapability:"paranoid_interpreters"},{id:"awk.system-dynamic",category:"Execution",label:"Awk dynamic system call",description:"Blocks awk system calls that cannot be safely analyzed.",example:"awk '{ system($0) }'",intent:"stop_and_explain"},{id:"xargs.rm-recursive-force-dynamic",category:"Execution",label:"xargs dynamic rm -rf",description:"Blocks xargs rm -rf with dynamic input.",example:"printf / | xargs rm -rf",intent:"scope_down"},{id:"xargs.shell-dynamic",category:"Execution",label:"xargs dynamic shell",description:"Blocks xargs shell execution with dynamic input.",example:"xargs r$(printf m) -rf",intent:"scope_down"},{id:"parallel.rm-recursive-force-dynamic",category:"Execution",label:"parallel dynamic rm -rf",description:"Blocks parallel rm -rf with dynamic input.",example:"printf / | parallel rm -rf",intent:"scope_down"},{id:"parallel.shell-dynamic",category:"Execution",label:"parallel dynamic shell",description:"Blocks parallel shell execution with dynamic input.",example:"parallel r$(printf m) -rf ::: child",intent:"scope_down"},{id:"parallel.command-stream-dynamic",category:"Execution",label:"parallel dynamic command stream",description:"Blocks parallel command streams from dynamic input.",example:"parallel --dry-run",intent:"scope_down"},{id:"shell.dynamic-structure",category:"Execution",label:"Dynamic command structure",description:"Blocks guarded subcommands and options assembled from substitution output in strict mode.",example:"git reset $(printf --hard)",intent:"stop_and_explain",activationCapability:"fail_closed"},{id:"shell.dynamic-executable",category:"Execution",label:"Dynamic executable name",description:"Blocks executable names assembled from command substitution output in strict mode.",example:"$(printf r)m -rf /",intent:"manual_only",activationCapability:"fail_closed"},{id:"raw-text.dangerous-command",category:"Execution",label:"Raw text dangerous command",description:"Blocks dangerous commands detected in raw command text.",example:"git reset --hard 'unterminated",intent:"stop_and_explain"}],CN=new Map(o6.map(($)=>[$.id,$.intent])),MB=new Set(o6.filter(($)=>$.catastrophic).map(($)=>$.id));function z($,J){return{id:$,reason:J,intent:CN.get($)??"manual_only"}}function k($,J){if(!$)return null;if(MB.has($.id))return $;if(J?.destructiveCommandProtectionEnabled===!1)return null;let Q=J?.effectiveDestructiveCommandRules?.[$.id];if(Q)return Q.enabled?$:null;return J?.destructiveCommandRuleOverrides[$.id]==="off"?null:$}function q1($,J,Q){if(MB.has(J))return!0;if($?.destructiveCommandProtectionEnabled===!1)return!1;let X=$?.effectiveDestructiveCommandRules?.[J];if(X)return X.enabled;let Y=$?.destructiveCommandRuleOverrides[J];return Y?Y==="on":Q}function NB($,J){return Object.freeze(Object.fromEntries(o6.map((Q)=>{let X=Q.activationCapability?J[Q.activationCapability]:void 0,Y=X?.enabled??!0,W=$.destructiveCommandRuleOverrides[Q.id],K=Q.catastrophic?{enabled:!0,inheritedEnabled:!0,changesInherited:!1,source:"catastrophic",...W?{override:W}:{}}:$.destructiveCommandProtectionEnabled?W?{enabled:W==="on",inheritedEnabled:Y,changesInherited:W==="on"!==Y,source:"rule_override",...Q.activationCapability?{activationCapability:Q.activationCapability}:{},override:W}:{enabled:Y,inheritedEnabled:Y,changesInherited:!1,source:X?.source??"built_in_default",...Q.activationCapability?{activationCapability:Q.activationCapability}:{}}:{enabled:!1,inheritedEnabled:Y,changesInherited:!1,source:"master_disabled",...Q.activationCapability?{activationCapability:Q.activationCapability}:{},...W?{override:W}:{}};return[Q.id,Object.freeze(K)]})))}function FB($,J){return Object.freeze({...$,effectiveDestructiveCommandRules:NB($,J)})}function Y3($,J){J3(J,$,2);let Q=$.toLowerCase(),X=Q.trimStart(),Y=X.startsWith("echo ")||X.startsWith("rg "),W=[{scan:"rm",label:"rm -rf"},{scan:"reset-hard",label:"git reset --hard"},{scan:"reset-merge",label:"git reset --merge"},{scan:"clean",label:"git clean -f"},{scan:"checkout",label:"git checkout --force"},{scan:"push-force",label:"git push --force"},{scan:"push-refspec",label:"git push --force"},{scan:"push-delete",label:"git push delete"},{scan:"branch",label:"git branch -D",caseSensitive:!0},{scan:"tag",label:"git tag -d"},{regex:/\bgit\s+stash\s+(drop|clear)\b/,label:"git stash drop/clear"},{regex:/\bgit\s+checkout\s+--\s/,label:"git checkout --"},{scan:"restore",label:"git restore without --staged"},{scan:"find",label:"find -delete",skipForEchoRg:!0},{regex:/\bdd\b[^\n|;&]*\bof=\/dev\/\S/,label:"dd of=/dev/",skipForEchoRg:!0},{regex:/\bmkfs(?:\.[a-z0-9_-]+)?\s+\/dev\/\S/,label:"mkfs /dev/",skipForEchoRg:!0},{regex:/\bshred\b\s+\S/,label:"shred",skipForEchoRg:!0}];for(let K of W){if(K.skipForEchoRg&&Y)continue;let B=K.caseSensitive?$:Q;if(K.regex)S1(J,B);if((K.regex?.test(B)??!1)||K.scan&&d6(B,K.scan,J))return z("raw-text.dangerous-command",`Unparseable command text contains a destructive pattern (${K.label}). Rewrite as a plain, parseable command so it can be analyzed.`)}return null}var TN=/^[A-Za-z_][A-Za-z0-9_]*=/;function _B($,J,Q){let X=$.words[0];if(!J||!X||$.words.length!==1||$.dialect!=="posix")return!1;if(!X.quoted||X.provenance!=="literal")return!1;let Y=/^([A-Za-z_][A-Za-z0-9_]*)=/.exec(X.text)?.[1];if(!Y)return!1;J3(Q,J.source,2);let W={anchored:new RegExp(`^\\$\\{?${Y}(?![A-Za-z0-9_])`),loose:new RegExp(`\\$\\{?${Y}(?![A-Za-z0-9_])`)};return DB(J.nodes,X,W)}function DB($,J,Q){return $.every((X)=>{if(X.kind==="connector")return!0;if(X.kind==="group"||X.kind==="function")return DB(X.body.nodes,J,Q);if(X.kind==="unknown")return!Q.loose.test(X.source);return wN(X,J,Q)})}function wN($,J,Q){if($.nested.some((Y)=>Q.loose.test(Y.source)))return!1;let X=$.words.findIndex((Y)=>!TN.test(Y.text));return $.words.every((Y,W)=>Y===J||VB(Y.raw,Q.anchored,W!==X))&&$.redirections.every((Y)=>(!Y.heredoc||Y.heredoc.quotedDelimiter||!Q.loose.test(Y.heredoc.body))&&(!Y.target||VB(Y.target.raw,Q.anchored,!0)))}function VB($,J,Q){let X=!1,Y=!1;for(let W=0;W<$.length;W++){let K=$[W];if(K==="\\"&&!X){W++;continue}if(!Y&&K==="'"){X=!X;continue}if(!X&&K==='"'){Y=!Y;continue}if(X||K!=="$")continue;if(!J.test($.slice(W)))continue;if(!Y||!Q)return!1}return!0}var zB=Object.freeze({maxDerivedTokens:16384}),IB="Command analysis exceeds CC Safety Net's derived-command work limit. Reduce nested or embedded command complexity and retry.",jB="env -S split-string variables cannot be resolved safely. Use literal values or expand the command explicitly.";class m1 extends Error{constructor(){super("Command analysis exceeds CC Safety Net's derived-command work limit. Reduce nested or embedded command complexity and retry.");this.name="DerivedCommandWorkLimitError"}}class L2 extends Error{constructor(){super("env -S split-string variables cannot be resolved safely. Use literal values or expand the command explicitly.");this.name="EnvSplitStringExpansionError"}}function n6(){return{derivedTokens:0}}function K0($,J){if(!Number.isSafeInteger($.derivedTokens)||$.derivedTokens<0||$.derivedTokens>zB.maxDerivedTokens||!Number.isSafeInteger(J)||J<0||J>zB.maxDerivedTokens-$.derivedTokens)throw new m1;$.derivedTokens+=J}import{isAbsolute as vN,resolve as RB}from"path";var bB=64;function W3($,J,Q){let X=vN($)?RB($):J?RB(J,$):void 0;if(!X)return;try{return J1(X,Q)}catch{return X}}function PB($){return!["/dev","/proc","/sys"].some((J)=>$===J||$.startsWith(`${J}/`))}function i($){return l($).toLowerCase()}function l($){return $.split(/[\\/]/).pop()?.replace(/\.exe$/i,"")??$}var s6=10,i2=20,O2=/^[a-zA-Z][a-zA-Z0-9_-]*$/,o2=256,H1=new Set(["bash","sh","zsh","ksh","dash","fish","csh","tcsh"]),AB=new Set(["python","python3","python2","node","ruby","perl"]),EB=/^python(?:[23](?:\.\d+)*)?$/,a6=new Set(["echo","printf","cat","head","tail","less","more","grep","rg","ag","ack","sed","awk","cut","tr","sort","uniq","wc","tee","man","help","info","type","which","whereis","whatis","apropos","file","stat","ls","ll","dir","tree","pwd","date","cal","uptime","whoami","id","groups","hostname","uname","env","printenv","set","export","alias","history","jobs","fg","bg","test","true","false","read","return","exit","break","continue","shift","wait","trap","basename","dirname","realpath","readlink","md5sum","sha256sum","base64","xxd","od","hexdump","strings","diff","cmp","comm","join","paste","column","fmt","fold","nl","pr","expand","unexpand","rev","tac","shuf","seq","yes","sleep","logger","write","wall","mesg","notify-send"]);var M2="Interpreter code contains a dangerous command. Run the underlying command directly so it can be analyzed, or use the safer alternative for that command.",n2="Interpreter one-liners are blocked by the active safety policy. Write the code to a script file and run it, or run the equivalent shell command directly.",t6=new Map([["python",new Set(["-c"])],["node",new Set(["-e","--eval"])],["ruby",new Set(["-e"])],["perl",new Set(["-e","-E"])]]),fN=new Set(["-p","--print"]),hN=new Map([["python",new Set(["c"])],["node",new Set(["e"])],["ruby",new Set(["e"])],["perl",new Set(["e","E"])]]),kN=new Map([["python",new Set(["W","X"])],["node",new Set(["C","r"])],["ruby",new Set(["C","E","F","I","r"])],["perl",new Set(["F","I","M","m"])]]),gN=new Map([["ruby",new Set(["0","K","W","x"])],["perl",new Set(["0","C","D","V","d","i","l","x"])]]),yN=new Map([["python",new Set(["m"])]]),xN=new Map([["node",new Set(["--allow-fs-read","--allow-fs-write","--conditions","--cpu-prof-dir","--cpu-prof-interval","--cpu-prof-name","--debug-port","--diagnostic-dir","--disable-proto","--disable-warning","--dns-result-order","--env-file","--env-file-if-exists","--experimental-package-map","--experimental-test-isolation","--experimental-test-tag-filter","--heap-prof-dir","--heap-prof-interval","--heap-prof-name","--heapsnapshot-near-heap-limit","--heapsnapshot-signal","--icu-data-dir","--input-type","--inspect-port","--inspect-publish-uid","--localstorage-file","--max-http-header-size","--max-old-space-size-percentage","--network-family-autoselection-attempt-timeout","--openssl-config","--redirect-warnings","--report-dir","--report-directory","--report-filename","--report-signal","--secure-heap","--secure-heap-min","--test-concurrency","--test-coverage-branches","--test-coverage-exclude","--test-coverage-functions","--test-coverage-include","--test-coverage-lines","--test-global-setup","--test-isolation","--test-name-pattern","--test-random-seed","--test-reporter","--test-reporter-destination","--test-rerun-failures","--test-shard","--test-skip-pattern","--test-timeout","--title","--tls-cipher-list","--tls-keylog","--trace-event-categories","--trace-event-file-pattern","--trace-require-module","--unhandled-rejections","--use-largepages","--v8-pool-size","--watch-kill-signal"])],["python",new Set(["--check-hash-based-pycs"])],["ruby",new Set(["--backtrace-limit","--crash-report","--disable","--enable","--encoding","--external-encoding","--internal-encoding","--parser"])]]),uN=new Set(["always","default","never"]),mN=new Set(["--backtrace-limit","--crash-report","--disable","--enable"]),lN=/\\\r?\n/g,pN=new Map([["python",[{selector:"-c",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-m",kind:"module-file",valueForm:"attached-or-separate"}]],["node",[{selector:"-e",kind:"inline-code",valueForm:"separate-only"},{selector:"--eval",kind:"inline-code",valueForm:"equals-or-separate"},{selector:"-p",kind:"inline-code",valueForm:"separate-only"},{selector:"--print",kind:"inline-code",valueForm:"separate-only"},{selector:"-r",kind:"module-file",valueForm:"separate-only"},{selector:"--require",kind:"module-file",valueForm:"equals-or-separate"},{selector:"--import",kind:"module-file",valueForm:"equals-or-separate"},{selector:"--loader",kind:"module-file",valueForm:"equals-or-separate"},{selector:"--experimental-loader",kind:"module-file",valueForm:"equals-or-separate"}]],["ruby",[{selector:"-e",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-r",kind:"module-file",valueForm:"attached-or-separate"}]],["perl",[{selector:"-e",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-E",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-M",kind:"module-file",valueForm:"attached-only"},{selector:"-m",kind:"module-file",valueForm:"attached-only"}]]]);function e6($){return J9($).code}function $9($){return J9($).sources}function CB($){return pN.get(X9($))??[]}function J9($){let J=X9($[0]??"");if(!t6.has(J))return{code:null,sources:[],optionsOpen:!1};let Q=[],X=[],Y=!0;for(let W=1;W<$.length;W++){let K=$[W];if(K===void 0)break;if(K==="--")return n1(J,Q,X,Y,$[W+1]===void 0?void 0:W+1,$[W+1]);if(K===""||K==="-"||!K.startsWith("-"))return n1(J,Q,X,Y,W,K);if(J==="node"&&fN.has(K)){let H=$[W+1];if(H===void 0)return n1(J,Q,X,Y);if(H.startsWith("-"))continue;Q.push({tokenIndex:W+1,value:H}),X.push({tokenIndex:W+1,kind:"inline-code",value:H}),W++;continue}if(dN(J,K)){let H=$[W+1];if(H===void 0)return n1(J,Q,X,Y);if(Q.push({tokenIndex:W+1,value:H}),X.push({tokenIndex:W+1,kind:"inline-code",value:H}),J==="python")return n1(J,Q,X,Y);W++;continue}let B=/^--eval=(.*)$/s.exec(K);if(rN(J)&&B){let H=B[1]??"";Q.push({tokenIndex:W,value:H}),X.push({tokenIndex:W,kind:"inline-code",value:H});continue}if(J==="node"){let H=cN(K);if(H){if(H.attached){if(Y&&=H.value!=="",H.value!=="")X.push({tokenIndex:W,kind:"module-file",value:H.value});continue}let L=$[W+1];if(L===void 0||L.startsWith("-"))return Y=!1,n1(J,Q,X,Y);X.push({tokenIndex:W+1,kind:"module-file",value:L}),W++;continue}}if(J==="python"&&K.startsWith("--check-hash-based-pycs=")||J==="node"&&(K==="--conditions="||K==="--diagnostic-dir="||K==="--title=")||J==="ruby"&&(K==="--disable="||K==="--enable="))return n1(J,Q,X,Y);if(xN.get(J)?.has(K)){let H=$[W+1];if(H===void 0||H.startsWith("-")&&!(J==="ruby"&&mN.has(K))||J==="python"&&!uN.has(H))return n1(J,Q,X,Y);W++;continue}if(K.startsWith("--"))continue;let q,U=!1;for(let H=1;H<K.length;H++){let L=K[H];if(L===void 0)break;if(yN.get(J)?.has(L)){let Z=K.slice(H+1),O=Z||$[W+1];if(O!==void 0)X.push({tokenIndex:Z?W:W+1,kind:"module-file",value:O});return n1(J,Q,X,Y)}if(hN.get(J)?.has(L)){q=K.slice(H+1)||$[W+1],U=H+1===K.length;break}if(J==="node"&&L==="r"){if(K==="-r"){let Z=$[W+1];if(Y&&=Z!==void 0&&!Z.startsWith("-"),Y&&Z!==void 0)X.push({tokenIndex:W+1,kind:"module-file",value:Z});W++}else Y=!1;break}if(J==="ruby"&&L==="r"){let Z=K.slice(H+1),O=Z||$[W+1];if(Y&&=O!==void 0,O!==void 0)X.push({tokenIndex:Z?W:W+1,kind:"module-file",value:O});if(!Z)W++;break}if(J==="perl"&&(L==="M"||L==="m")){let Z=K.slice(H+1);if(Z)X.push({tokenIndex:W,kind:"module-file",value:Z});else if(Y=!1,H+1===K.length)W++;break}if(kN.get(J)?.has(L)){if(H+1===K.length)W++;break}if(gN.get(J)?.has(L)&&H+1<K.length)break}if(q===void 0)continue;let G=U?W+1:W;if(Q.push({tokenIndex:G,value:q}),X.push({tokenIndex:G,kind:"inline-code",value:q}),J==="python")return n1(J,Q,X,Y);if(U)W++}return n1(J,Q,X,Y,void 0,void 0,!0)}function n1($,J,Q,X,Y,W,K=!1){let B=$==="node"?J.slice(-1):J,q=new Set(B.map((G)=>G.tokenIndex)),U=Q.filter((G)=>G.kind!=="inline-code"||q.has(G.tokenIndex));if(X&&J.length===0&&Y!==void 0&&W!==void 0)U.push({tokenIndex:Y,kind:"main-script",value:W});return{code:($==="node"?B[0]?.value:B.map((G)=>G.value).join(`
27
+ `))||null,sources:X?U:[],optionsOpen:X&&K}}function cN($){for(let J of["--import","--loader","--experimental-loader","--require"]){if($===J)return{attached:!1,value:""};if($.startsWith(`${J}=`))return{attached:!0,value:$.slice(J.length+1)}}return}function C1($){return t6.has(X9($))}function Q9($,J){return X9($)==="node"&&/^\s*console\.(?:log|info|warn|error)\(\s*(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*')\s*\)\s*;?\s*$/.test(J)}function X9($){let J=l($).toLowerCase();return EB.test(J)?"python":J}function dN($,J){return t6.get($)?.has(J)??!1}function rN($){return t6.get($)?.has("--eval")??!1}function s2($,J){let Q=nN($,J);if(!SB(Q,J))return!1;S1(J,Q);let X=oN(Q);if(SB(X,J))return!0;return S1(J,X),iN.test(X)}var iN=/`|%x|\b(?:system|exec|spawn|popen|subprocess|child_process|open3|eval|fork|qx)/i;function oN($){let J=[],Q=0,X=0;while(X<$.length){let Y=$[X];if(Y!=="'"&&Y!=='"'){X++;continue}let W=$.startsWith(Y.repeat(3),X)?Y.repeat(3):Y,K=X+W.length;while(K<$.length&&!$.startsWith(W,K))K+=$[K]==="\\"?2:1;if(K>=$.length)break;J.push($.slice(Q,X)," "),X=K+W.length,Q=X}return J.push($.slice(Q)),J.join("")}function SB($,J){if(c6($,"rm",J))return!0;for(let X of[/\bgit[^\S\n]+reset[^\S\n]+--ha(?:r(?:d)?)?\b/,/\bgit[^\S\n]+reset[^\S\n]+--me(?:r(?:g(?:e)?)?)?\b/,/\bgit[^\S\n]+checkout[^\S\n]+--[^\S\n]/,/\bgit[^\S\n]+clean[^\S\n]+(-[^\s]*f[^\s]*|--fo(?:r(?:c(?:e)?)?)?)\b/,/\bgit[^\S\n]+stash[^\S\n]+(drop|clear)\b/])if(S1(J,$),X.test($))return!0;if(c6($,"dd",J))return!0;for(let X of[/\bmkfs(?:\.[A-Za-z0-9_-]+)?\s+\/dev\/[^\s'"]+/,/\bshred\b\s+/])if(S1(J,$),X.test($))return!0;if(c6($,"find",J))return!0;let Q=$.split(/[\n\r\u2028\u2029]/);return["reset-hard","reset-merge","clean","checkout","push-force","push-refspec","push-delete","branch","tag","restore"].some((X)=>{return S1(J,$),Q.some((Y)=>d6(Y,X))})}function nN($,J){return S1(J,$),$.replace(lN,"")}var f=Object.freeze({maxChildAnalyses:1024,maxDerivedTokens:16384,maxDerivedBytes:1048576,maxPlaceholderReplacements:16384}),TB="Parallel command expands beyond CC Safety Net's analysis limits. Reduce the template or explicit argument list and retry.";class W9 extends Error{constructor(){super("Parallel command expands beyond CC Safety Net's analysis limits. Reduce the template or explicit argument list and retry.");this.name="ParallelAnalysisLimitError"}}function wB(){return{childAnalyses:0,derivedTokens:0,derivedBytes:0,placeholderReplacements:0}}function T1($,J){let Q=J.childAnalyses??0,X=J.derivedTokens??0,Y=J.derivedBytes??0,W=J.placeholderReplacements??0;if(Y9($.childAnalyses,Q,f.maxChildAnalyses)||Y9($.derivedTokens,X,f.maxDerivedTokens)||Y9($.derivedBytes,Y,f.maxDerivedBytes)||Y9($.placeholderReplacements,W,f.maxPlaceholderReplacements))throw new W9;$.childAnalyses+=Q,$.derivedTokens+=X,$.derivedBytes+=Y,$.placeholderReplacements+=W}function Y9($,J,Q){return!Number.isSafeInteger($)||$<0||$>Q||!Number.isSafeInteger(J)||J<0||J>Q-$}import{isAbsolute as FQ,normalize as W_,parse as K_,posix as tq,resolve as Q4,sep as NQ}from"path";import{isAbsolute as sN,join as vB,normalize as kB,parse as aN,sep as fB}from"path";var tN=["/tmp","/var/tmp","/private/tmp","/private/var/tmp"],eN=`
28
+ `;function K3($,J){if(B0($,J))return!0;if(!$.has("TMPDIR"))return!1;return!kJ($.get("TMPDIR")??"",J)}function T0($,J){if($.has("TMPDIR"))return kJ($.get("TMPDIR")??"",J);let Q=gJ($,J);if(Q===void 0)return!0;return kJ(Q,J)}function gJ($,J){return xB($,J,"TMPDIR")}function kJ($,J){if(!$)return!1;if(JF($))return!1;return yJ($,J)}function B0($,J){let Q=xB($,J,"IFS");return Q!==void 0&&Q!==""&&Q!==eN}function yJ($,J){let Q=K9($,J.paths);return Q!==null&&yB(J).some((X)=>XF(Q,X))}function gB($,J){let Q=K9($,J.paths);return Q!==null&&yB(J).includes(Q)}var hB=new WeakMap;function yB($){let J=hB.get($);if(J)return J;let Q=$F($);return hB.set($,Q),Q}function $F($){let J=tN.map((X)=>K9(X,$.paths)??kB(X)),Q=K9($.tmpdir,$.paths);if(!Q)return J;if(process.platform==="win32")return[...J,Q];if(process.platform==="darwin"&&QF(Q))return[...J,Q];return J}function JF($){return/[\s$`*?[]/.test($)||/\{[^{}]*(?:,|\.\.)[^{}]*\}/.test($)||/[+@!]\([^)]*\)/.test($)}function xB($,J,Q){return $.has(Q)?$.get(Q):J.env.get(Q)}function QF($){return/^\/(?:private\/)?var\/folders\/[^/]{2}\/[^/]+\/T$/.test($)}function K9($,J){try{let Q=kB($);if(!sN(Q))return Q;let X=aN(Q).root,Y=Q.slice(X.length).split(/[\\/]+/).filter(Boolean),W=X;for(let K=0;K<Y.length;K++){let B=vB(W,Y[K]??"");if(J.entryKind(B)==="missing")return vB(B,...Y.slice(K+1));let q=J.realpath(B);if(q===null)return null;W=q}return W}catch{return null}}function XF($,J){if($===J)return!0;let Q=J.endsWith(fB)?J:`${J}${fB}`;return $.startsWith(Q)}import{statSync as sV}from"fs";import{isAbsolute as lq,join as aV,relative as pq}from"path";import{isAbsolute as uB,parse as YF}from"path";var pB=/^[A-Za-z_][A-Za-z0-9_]*=/,WF=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}/,cB=131072,KF=16384;function q0($){if(!pB.test($))return null;let J=$.indexOf("=");return{name:$.slice(0,J),value:$.slice(J+1)}}function B9($){let J=new Map,Q=0;while(Q<$.length){let X=$[Q];if(!X)break;let Y=q0(h(X));if(!Y)break;J.set(Y.name,Y.value),Q++}return{words:$.slice(Q),envAssignments:J}}function dB($){let J=$.toLowerCase();return $.includes("=")||J==="sudo"||J==="env"||J==="command"||J==="builtin"}function N2($,J,Q,X){if(!dB(a2($)))return{words:$,envAssignments:new Map,cwd:Q,rewritten:!1};let Y=new Set($),W=$,K=new Map,B=new Map(X??[]),q=Q;for(let G=0;G<i2;G++){let H=lB(W),L=B9(W);for(let[O,M]of L.envAssignments)K.set(O,M),B.set(O,M);if(W=L.words,W.length===0)break;while(W.length>0&&a2(W).includes("=")&&!BF(W)){let O=qF(a2(W),B,J.env)??u6(a2(W),J.env,B);if(O)K.set(O.name,O.value),B.set(O.name,O.value);W=W.slice(1)}if(W.length===0)break;let Z=a2(W).toLowerCase();if(Z!=="sudo"&&Z!=="env"&&Z!=="command"&&Z!=="builtin")break;if(Z==="sudo"){let O=GF(W,J.paths,q);if(W=O.words,O.cwd!==void 0)q=O.cwd}if(Z==="env"){let O=LF(W,q,B,J);if(O.unverifiableEnvSplit)return{words:W,envAssignments:K,cwd:q,unverifiableEnvSplit:!0,rewritten:mB(W,Y)};if(W=O.words,O.cwd!==void 0)q=O.cwd;for(let[M,V]of O.envAssignments)K.set(M,V),B.set(M,V)}if(Z==="command")W=_F(W);if(Z==="builtin")W=W.slice(s1(W,1)==="--"?2:1);if(lB(W)===H)break}let U=B9(W);for(let[G,H]of U.envAssignments)K.set(G,H),B.set(G,H);return{words:U.words,envAssignments:K,cwd:q,rewritten:mB(U.words,Y)}}function mB($,J){return $.some((Q)=>!J.has(Q))}function lB($){return $.map(h).join(" ")}function a2($){let J=$[0];return J?h(J):""}function s1($,J){let Q=$[J];return Q?h(Q):void 0}function BF($){return pB.test(a2($))}function qF($,J,Q){if(!$.startsWith("TMPDIR+="))return null;return{name:"TMPDIR",value:`${J.get("TMPDIR")??Q.get("TMPDIR")??""}${$.slice(8)}`}}var UF=new Set(["-u","-g","-C","-D","-h","-p","-r","-t","-T","-U"]);function GF($,J,Q){let X=1,Y=Q;while(X<$.length){let W=s1($,X);if(!W)break;if(W==="--")return{words:$.slice(X+1),cwd:Y};if(!W.startsWith("-"))break;if(W==="-D"||W==="--chdir"){let K=s1($,X+1);Y=K?B3(Y,K,J):null,X+=2;continue}if(W.startsWith("--chdir=")){Y=B3(Y,W.slice(8),J),X++;continue}if(W.startsWith("-D")&&W.length>2){Y=B3(Y,W.slice(2),J),X++;continue}if(W==="-i"||W==="--login"){Y=null,X++;continue}if(UF.has(W)){X+=2;continue}X++}return{words:$.slice(X),cwd:Y}}var HF=new Set(["-i","-0","--null"]),ZF=new Set(["-u","--unset","-C","--chdir","-S","--split-string","-P"]);function LF($,J,Q,X){let Y=new Map,W=J,K=$,B=new Set,q=1;while(q<K.length){let U=s1(K,q);if(!U)break;if(U==="--")return{words:K.slice(q+1),envAssignments:Y,cwd:W};if(U==="-i"||U==="--ignore-environment"||U==="-"){Y.clear();for(let H of Q.keys())Y.set(H,"");Y.set("TMPDIR",""),q++;continue}if(HF.has(U)){q++;continue}if(U==="-u"||U==="--unset"){let H=s1(K,q+1);if(H!==void 0)B.add(H),Y.set(H,"");q+=2;continue}if(U.startsWith("-u")&&U.length>2&&!U.startsWith("-u=")){let H=U.slice(2);B.add(H),Y.set(H,""),q++;continue}if(U.startsWith("--unset=")){let H=U.slice(8);B.add(H),Y.set(H,""),q++;continue}let G=U==="-S"||U==="--split-string"?{value:s1(K,q+1),consumed:2}:U.startsWith("-S")&&U.length>2?{value:U.slice(2),consumed:1}:U.startsWith("--split-string=")?{value:U.slice(15),consumed:1}:null;if(G){let H=OF(K,q,G.value,G.consumed,Q,B,W,X.env);if(H.done)return H.result;K=H.expanded,W=H.currentCwd,q=H.nextIndex;continue}if(ZF.has(U)){if(U==="-C"||U==="--chdir"){let H=s1(K,q+1);W=H?B3(W,H,X.paths):null}q+=2;continue}if(U.startsWith("-u=")){q++;continue}if(U.startsWith("-C")&&U.length>2||U.startsWith("--chdir=")){let H=U.startsWith("--chdir=")?U.slice(8):U.startsWith("-C=")?U.slice(3):U.slice(2);W=B3(W,H,X.paths),q++;continue}if(U.startsWith("-P")){q++;continue}if(U.startsWith("-")){q++;continue}if(!q0(U))break;while(q<K.length){let H=q0(s1(K,q)??"");if(!H)break;Y.set(H.name,H.value),q++}if(s1(K,q)==="--")q++;return{words:K.slice(q),envAssignments:Y,cwd:W}}return{words:K.slice(q),envAssignments:Y,cwd:W}}function OF($,J,Q,X,Y,W,K,B){let q=Q!==void 0?MF(Q,Y,W,B):{tokens:null,unverifiableEnvSplit:!1};if(q.unverifiableEnvSplit)return{done:!0,result:{words:$,envAssignments:new Map,cwd:K,unverifiableEnvSplit:!0}};if(!q.tokens)return{done:!1,expanded:$,currentCwd:null,nextIndex:J+X};return{done:!1,expanded:[...$.slice(0,J),...p(q.tokens),...$.slice(J+X)],currentCwd:K,nextIndex:J}}function MF($,J,Q,X){if($.length>cB)return{tokens:null,unverifiableEnvSplit:!0};let Y=NF($,(W)=>{if(Q.has(W))return"";if(J.has(W))return J.get(W)??"";return X.get(W)??""});return{tokens:Y.tokens,unverifiableEnvSplit:Y.limited}}function NF($,J){let Q=[],X=[],Y=0,W=!1,K=!1,B=!1,q=!1,U=(H)=>{if(Y+H.length>cB)return q=!0,!1;return X.push(H),Y+=H.length,W=!0,!0},G=()=>{if(!W)return!0;if(Q.length>=KF)return q=!0,!1;return Q.push(X.join("")),X=[],W=!1,!0};for(let H=0;H<$.length;H++){let L=$[H]??"";if(L==="'"&&!B){K=!K,W=!0;continue}if(L==='"'&&!K){B=!B,W=!0;continue}if(!K&&!B&&VF(L)){if(!G())return{tokens:null,limited:q};continue}if(!K&&!B&&L==="#"&&!W)break;if(L==="$"&&!K){let M=$.slice(H).match(WF);if(!M?.[1]||!U(J(M[1])))return{tokens:null,limited:q};H+=M[0].length-1;continue}if(L!=="\\"){if(!U(L))return{tokens:null,limited:q};continue}let Z=$[H+1];if(Z===void 0)return{tokens:null,limited:q};if(K&&Z!=="'"&&Z!=="\\"){if(!U("\\"))return{tokens:null,limited:q};continue}if(Z==="c"){if(B)return{tokens:null,limited:q};break}if(Z==="_"&&!K&&!B){if(!G())return{tokens:null,limited:q};H++;continue}let O=FF(Z);if(O===void 0||!U(O))return{tokens:null,limited:q};H++}if(K||B||!G())return{tokens:null,limited:q};return{tokens:Q,limited:!1}}function FF($){if($==="f")return"\f";if($==="n")return`
29
+ `;if($==="r")return"\r";if($==="t")return"\t";if($==="v")return"\v";if($==="_")return" ";if($==="#"||$==="$"||$==='"'||$==="'")return $;if($==="\\")return"\\";return}function VF($){return $===" "||$==="\t"||$===`
30
+ `||$==="\r"||$==="\f"||$==="\v"}function B3($,J,Q){if(J==="")return null;if(!$&&!uB(J))return null;let X=uB(J)?YF(J).root:Q.realpath($??"/");if(X===null)return null;try{return d0(X,J,Q)}catch{return null}}function _F($){if(s1($,1)==="-v")return[...p(["type"]),...$.slice(2)];let J=1;while(J<$.length){let Q=s1($,J);if(!Q)break;if(Q==="-p"||Q==="-v"||Q==="-V"){J++;continue}if(Q==="--")return $.slice(J+1);if(Q.startsWith("-")&&!Q.startsWith("--")&&Q.length>1){if(!/^[pvV]+$/.test(Q.slice(1)))break;J++;continue}break}return $.slice(J)}function l1($,J,Q){return xJ($,J,Q).tokens}function xJ($,J,Q,X){if(!dB($[0]??""))return{tokens:[...$],envAssignments:new Map,cwd:Q};let Y=N2(p($),J,Q,X);return{tokens:Y.words.map(h),envAssignments:Y.envAssignments,cwd:Y.cwd,unverifiableEnvSplit:Y.unverifiableEnvSplit}}import{isAbsolute as dV,normalize as rV,resolve as uq}from"path";function q9(){return[]}function U9(){return[]}function G9(){return{words:[],redirections:[],nested:[],start:-1,end:-1,reset(){this.words=[],this.redirections=[],this.nested=[],this.start=-1,this.end=-1}}}function DF($){return Object.freeze({...$,span:Object.freeze($.span),words:Object.freeze($.words),redirections:Object.freeze($.redirections.map((J)=>Object.freeze({...J,span:Object.freeze(J.span),...J.heredoc?{heredoc:Object.freeze({...J.heredoc,bodySpan:Object.freeze(J.heredoc.bodySpan),terminatorSpan:Object.freeze(J.heredoc.terminatorSpan)})}:{}}))),nested:Object.freeze($.nested.map((J)=>I1(J)))})}function H9($,J,Q){$.push(Q),J.reset()}function zF($,J,Q,X,Y){if(X<=Q)return;$.push({raw:J.slice(Q,X),span:{start:Q,end:X},provenance:Y})}function Z9($){let J=[];return{parts:J,push:(Q,X,Y)=>zF(J,$,Q,X,Y)}}function uJ($){let J=$.parts??[{raw:$.raw,span:$.span,provenance:$.provenance}];return Object.freeze({kind:"word",...$,span:Object.freeze($.span),parts:Object.freeze(J.map((Q)=>Object.freeze({...Q,span:Object.freeze(Q.span)})))})}function t2($,J,Q,X,Y,W,K){return uJ({text:X,raw:$.slice(J,Q),span:{start:J,end:Q},provenance:Y,quoted:W,...K?{parts:K}:{}})}function I1($){return Object.freeze({...$,span:Object.freeze($.span),issues:Object.freeze($.issues.map((J)=>Object.freeze({...J,span:Object.freeze(J.span)}))),nodes:Object.freeze($.nodes.map((J)=>{if(J.kind==="command")return DF(J);if(J.kind==="group"||J.kind==="function")return Object.freeze({...J,span:Object.freeze(J.span),body:I1(J.body)});return Object.freeze({...J,span:Object.freeze(J.span)})}))})}function mJ($,J,Q){if(J>=Q||iB($[J]??""))return null;let X="",Y=!1,W=!1,K=J;while(K<Q&&!iB($[K]??"")){let B=$[K]??"";if(B==="'"){Y=!0;let q=rB($,K+1,Q,"'");X+=q.text,W||=!q.closed,K=q.next;continue}if(B==='"'){Y=!0;let q=rB($,K+1,Q,'"');X+=q.text,W||=!q.closed,K=q.next;continue}if(B==="\\"){Y=!0;let q=$[K+1];if(!q||q===`
31
+ `||q==="\r"){W=!0;break}X+=q,K+=2;continue}if(B==="`"||$.startsWith("$(",K)||$.startsWith("${",K)||$.startsWith("<(",K)||$.startsWith(">(",K))W=!0;X+=B,K++}return{delimiter:X,quoted:Y,next:K,span:{start:J,end:K},ambiguous:W}}function lJ($,J,Q,X){let Y=[],W=J;for(let K of X){let B=W,q=!1;while(W<Q){let U=IF($,W,Q);if((K.stripTabs?U.text.replace(/^\t+/,""):U.text)===K.delimiter){K.attach({body:K.stripTabs?jF($.slice(B,W)):$.slice(B,W),delimiter:K.delimiter,quotedDelimiter:K.quotedDelimiter,stripTabs:K.stripTabs,bodySpan:{start:B,end:W},terminatorSpan:{start:W,end:U.contentEnd}}),W=U.next,q=!0;break}if(U.next<=W)break;W=U.next}if(q)continue;return Y.push({code:"unterminated-heredoc",message:`heredoc delimiter ${K.delimiter} was not found`,span:K.declarationSpan}),{next:Q,issues:Y,terminated:!1}}return{next:W,issues:Y,terminated:!0}}function rB($,J,Q,X){let Y="",W=J;while(W<Q&&$[W]!==`
32
+ `&&$[W]!=="\r"){let K=$[W]??"";if(K===X)return{text:Y,next:W+1,closed:!0};if(X==='"'&&K==="\\"&&$[W+1]){let B=$[W+1]??"";Y+=["$","`",'"',"\\"].includes(B)?B:`\\${B}`,W+=2;continue}Y+=K,W++}return{text:Y,next:W,closed:!1}}function iB($){return/[\s;&|<>)]/u.test($)||$==="`"}function IF($,J,Q){let X=J;while(X<Q&&$[X]!==`
33
33
  `&&$[X]!=="\r")X++;let Y=X>=Q?Q:$[X]==="\r"&&$[X+1]===`
34
- `?X+2:X+1;return{text:$.slice(J,X),contentEnd:X,next:Y}}function zF($){return $.replace(/(^|\r\n?|\n)\t+/g,"$1")}var tB=new Set(["&&","||","|","|&"]);function eB($,J,Q){let X={start:0,end:$.length};if($.length>Q.maxInputLength)return I1({kind:"program",dialect:J,source:$,span:X,status:"limited",issues:[{code:"input-limit",message:`command exceeds ${Q.maxInputLength} UTF-16 code units`,span:X}],nodes:[]});let Y=M9($,0,$.length,J,Q,{used:0,max:Q.maxWords},0);return I1({kind:"program",dialect:J,source:$,span:X,status:V9(Y.issues,Y.limited),issues:Y.issues,nodes:Y.nodes})}function M9($,J,Q,X,Y,W,K,B){let q=q9(),U=U9(),G=G9(),H=[],L=()=>{if(G.words.length===0&&G.redirections.length===0)return;let O={start:G.start,end:G.end},M=G.words.map((V)=>V.text);H9(q,G,{kind:"command",dialect:X,source:$.slice(O.start,O.end),span:O,words:G.words,redirections:G.redirections,nested:G.nested,dynamicExecutable:G.words[0]?.provenance==="command-substitution",displayText:U.length>0&&q.length===0?$.slice(J,Q):M.join(" ")})},Z=J;while(Z<Q){let O=$[Z];if(!O)break;if(B&&O===B)return L(),aB(q,U),{nodes:q,issues:U,next:Z+1,closed:!0,limited:!1,pendingHeredocs:H};if(F9(O)){if(O===`
34
+ `?X+2:X+1;return{text:$.slice(J,X),contentEnd:X,next:Y}}function jF($){return $.replace(/(^|\r\n?|\n)\t+/g,"$1")}var tB=new Set(["&&","||","|","|&"]);function eB($,J,Q){let X={start:0,end:$.length};if($.length>Q.maxInputLength)return I1({kind:"program",dialect:J,source:$,span:X,status:"limited",issues:[{code:"input-limit",message:`command exceeds ${Q.maxInputLength} UTF-16 code units`,span:X}],nodes:[]});let Y=M9($,0,$.length,J,Q,{used:0,max:Q.maxWords},0);return I1({kind:"program",dialect:J,source:$,span:X,status:V9(Y.issues,Y.limited),issues:Y.issues,nodes:Y.nodes})}function M9($,J,Q,X,Y,W,K,B){let q=q9(),U=U9(),G=G9(),H=[],L=()=>{if(G.words.length===0&&G.redirections.length===0)return;let O={start:G.start,end:G.end},M=G.words.map((V)=>V.text);H9(q,G,{kind:"command",dialect:X,source:$.slice(O.start,O.end),span:O,words:G.words,redirections:G.redirections,nested:G.nested,dynamicExecutable:G.words[0]?.provenance==="command-substitution",displayText:U.length>0&&q.length===0?$.slice(J,Q):M.join(" ")})},Z=J;while(Z<Q){let O=$[Z];if(!O)break;if(B&&O===B)return L(),aB(q,U),{nodes:q,issues:U,next:Z+1,closed:!0,limited:!1,pendingHeredocs:H};if(F9(O)){if(O===`
35
35
  `||O==="\r"){L();let E=O==="\r"&&$[Z+1]===`
36
36
  `?Z+2:Z+1,_=q.at(-1);if(_?.kind!=="connector"||!tB.has(_.operator))q.push(Object.freeze({kind:"connector",operator:$.slice(Z,E),span:Object.freeze({start:Z,end:E})}));if(H.length>0){let R=lJ($,E,Q,H.splice(0));U.push(...R.issues),Z=R.next;continue}Z=E;continue}Z++;continue}if(O==="#"){while(Z<Q&&$[Z]!==`
37
- `&&$[Z]!=="\r")Z++;continue}let M=G.start===-1?uF($,Z,Q):void 0;if(M){if(cJ(q,U,Z),K>=Y.maxDepth)return e2(q,U,Z,"depth-limit",Y.maxDepth);if(!pJ(W))return e2(q,U,Z,"word-limit",Y.maxWords);let E=M9($,M.braceIndex+1,Q,X,Y,W,K+1,"}"),_=E.next,R={start:M.braceIndex+1,end:E.closed?_-1:_},P=oB($,X,R,E);if(q.push({kind:"function",name:M.name,span:{start:Z,end:_},body:P}),U.push(...E.issues),E.pendingHeredocs.length>0||U3(E.nodes))U.push({code:"unsupported-heredoc-context",message:"heredocs attached inside function bodies are not supported safely",span:{start:Z,end:_}});if(H.push(...E.pendingHeredocs),E.limited)return O9(q,U,E.next);if(!E.closed)U.push({code:"unclosed-function-body",message:"function body is not closed",span:{start:M.braceIndex,end:_}});Z=_;continue}let V=N9($,Z);if(V){if(L(),!Bq(q.at(-1)))U.push({code:"unexpected-connector",message:`connector ${V} has no preceding command`,span:{start:Z,end:Z+V.length}});q.push(Object.freeze({kind:"connector",operator:V,span:Object.freeze({start:Z,end:Z+V.length})})),Z+=V.length;continue}if(O===")"){L(),U.push({code:"unexpected-closing-delimiter",message:"closing parenthesis has no matching opening parenthesis",span:{start:Z,end:Z+1}}),q.push({kind:"unknown",source:O,span:{start:Z,end:Z+1}}),Z++;continue}if((O==="("||O==="{"&&EF($,Z,Q))&&G.start===-1){if(cJ(q,U,Z),K>=Y.maxDepth)return e2(q,U,Z,"depth-limit",Y.maxDepth);let E=O==="("?")":"}",_=M9($,Z+1,Q,X,Y,W,K+1,E),R=_.next,P={start:Z+1,end:_.closed?R-1:R},S=oB($,X,P,_);if(q.push({kind:"group",style:O==="("?"subshell":"brace",span:{start:Z,end:R},body:S}),U.push(..._.issues),_.pendingHeredocs.length>0||U3(_.nodes))U.push({code:"unsupported-heredoc-context",message:"heredocs attached inside command groups are not supported safely",span:{start:Z,end:R}});if(H.push(..._.pendingHeredocs),_.limited)return O9(q,U,_.next);if(!_.closed)U.push({code:O==="("?"unclosed-subshell":"unclosed-brace-group",message:`${O} group is not closed`,span:{start:Z,end:R}});Z=R;continue}let F=(O==="<"||O===">")&&$[Z+1]!=="("?RF($,Z):null;if(F){let E=G.words.at(-1),_=E&&E.span.end===Z&&/^[0-9]+$/.test(E.raw)?Number(E.raw):void 0;if(_!==void 0)G.words.pop();let R=_===void 0?Z:E?.span.start??Z;G.start=G.start===-1?Z:G.start;let P=Z+F.length;while(P<Q&&/[ \t]/.test($[P]??""))P++;let S=$[P],T=P>Z+F.length&&S==="#",y=!S||F9(S)||!!N9($,P)||S===B||S===")"||T||(S==="<"||S===">")&&$[P+1]!=="(",x=F==="<<"||F==="<<-"?mJ($,P,Q):void 0,c=x?{word:t2($,P,x.next,x.delimiter,"literal",x.quoted),nested:[],issues:[],next:x.next,limited:!1}:!y?dJ($,P,Q,X,Y,W,K):void 0;if(c){if(U.push(...c.issues),c.limited)return O9(q,U,c.next);if(!pJ(W))return e2(q,U,c.next,"word-limit",Y.maxWords)}let V1=c?.next??Z+F.length,C={kind:"redirection",operator:F,span:{start:R,end:V1},..._===void 0?{}:{fd:_},...c?{target:c.word}:{}};if(G.redirections.push(C),F==="<<"||F==="<<-")if(!x)U.push({code:"missing-heredoc-delimiter",message:"heredoc redirection requires a delimiter word",span:{start:Z,end:Z+F.length}});else{if(x.ambiguous||x.delimiter.length===0)U.push({code:"ambiguous-heredoc-delimiter",message:"heredoc delimiter cannot be determined safely",span:x.span});H.push({delimiter:x.delimiter,quotedDelimiter:x.quoted,stripTabs:F==="<<-",declarationSpan:{start:R,end:V1},attach:(m)=>{C.heredoc=m}})}else if(!c)U.push({code:"missing-redirection-target",message:`redirection ${F} requires a target word`,span:{start:Z,end:Z+F.length}});if(c)G.nested.push(...c.nested);G.end=V1,Z=V1;continue}if(G.start===-1)cJ(q,U,Z);let b=dJ($,Z,Q,X,Y,W,K);if(U.push(...b.issues),b.limited)return O9(q,U,b.next);let I=TF(G.words)?kF($,b.word,W.max-W.used,Y.maxDepth,Y.maxInputLength):void 0;if(I?.limitCode)return e2(q,U,b.next,I.limitCode,I.limitCode==="word-limit"?Y.maxWords:I.limitCode==="depth-limit"?Y.maxDepth:Y.maxInputLength);let A=I?.words??[b.word];for(let E of A){if(!pJ(W))return e2(q,U,b.next,"word-limit",Y.maxWords);G.words.push(E)}G.start=G.start===-1?Z:G.start,G.end=b.next,G.nested.push(...b.nested),Z=b.next>Z?b.next:Z+1}return L(),aB(q,U),U.push(...mF(H)),{nodes:q,issues:U,next:Z,closed:B===void 0,limited:!1,pendingHeredocs:[]}}function oB($,J,Q,X){return{kind:"program",dialect:J,source:$.slice(Q.start,Q.end),span:Q,status:V9(X.issues,X.limited),issues:X.issues,nodes:X.nodes}}function dJ($,J,Q,X,Y,W,K){let B="",q=J,U=!1,G="literal",H=[],L=[],Z=!1;while(q<Q){let O=$[q],M=(O==="<"||O===">")&&$[q+1]==="(";if(!O||F9(O)||(O===";"||O==="|"||O==="&")&&N9($,q)||(O==="<"||O===">")&&!M)break;if(O===")")break;if(O==="'"){U=!0;let F=$.indexOf("'",q+1);if(F===-1||F>=Q){B+=$.slice(q+1,Q),L.push({code:"unclosed-single-quote",message:"single-quoted word is not closed",span:{start:q,end:Q}}),q=Q;break}B+=$.slice(q+1,F),q=F+1;continue}if(O==='"'){U=!0;let F=IF($,q,Q,X,Y,W,K);if(B+=F.text,H.push(...F.nested),L.push(...F.issues),Z||=F.limited,G=q3(G,F.provenance),q=F.next,Z)break;continue}if($.startsWith("$'",q)){U=!0;let F=bF($,q+2,Q);if(B+=F.text,L.push(...F.issues),!F.closed)L.push({code:"unclosed-ansi-c-quote",message:"ANSI-C quoted word is not closed",span:{start:q,end:Q}});q=F.next;continue}if(O==="\\"){let F=$[q+1];if(!F){L.push({code:"trailing-escape",message:"escape has no following character",span:{start:q,end:q+1}}),q++;break}if(F===`
38
- `){q+=2;continue}B+=F,q+=2;continue}let V=O==="$"||O==="<"||O===">"||O==="`"?rJ($,q,Q,X,Y,W,K):null;if(V){let F=$q(V,H,L);if(Z||=F.limited,G=q3(G,F.provenance),q=F.next,Z)break;continue}if(O==="$"){let F=Xq($,q,Q,B,G);B=F.text,G=F.provenance,q=F.next;continue}if(O==="*"||O==="?"||O==="[")G=q3(G,"glob");B+=O,q++}return{word:t2($,J,q,B,G,U,G==="literal"?void 0:AF($,J,q)),nested:H,issues:L,next:q,limited:Z}}function IF($,J,Q,X,Y,W,K){let B="",q="literal",U=[],G=[],H=!1,L=J+1;while(L<Q){let Z=$[L];if(Z==='"')return{text:B,provenance:q,nested:U,issues:G,next:L+1,limited:H};if(Z==="\\"&&$[L+1]){let M=$[L+1]??"";if(M===`
37
+ `&&$[Z]!=="\r")Z++;continue}let M=G.start===-1?lF($,Z,Q):void 0;if(M){if(cJ(q,U,Z),K>=Y.maxDepth)return e2(q,U,Z,"depth-limit",Y.maxDepth);if(!pJ(W))return e2(q,U,Z,"word-limit",Y.maxWords);let E=M9($,M.braceIndex+1,Q,X,Y,W,K+1,"}"),_=E.next,R={start:M.braceIndex+1,end:E.closed?_-1:_},P=oB($,X,R,E);if(q.push({kind:"function",name:M.name,span:{start:Z,end:_},body:P}),U.push(...E.issues),E.pendingHeredocs.length>0||U3(E.nodes))U.push({code:"unsupported-heredoc-context",message:"heredocs attached inside function bodies are not supported safely",span:{start:Z,end:_}});if(H.push(...E.pendingHeredocs),E.limited)return O9(q,U,E.next);if(!E.closed)U.push({code:"unclosed-function-body",message:"function body is not closed",span:{start:M.braceIndex,end:_}});Z=_;continue}let V=N9($,Z);if(V){if(L(),!Bq(q.at(-1)))U.push({code:"unexpected-connector",message:`connector ${V} has no preceding command`,span:{start:Z,end:Z+V.length}});q.push(Object.freeze({kind:"connector",operator:V,span:Object.freeze({start:Z,end:Z+V.length})})),Z+=V.length;continue}if(O===")"){L(),U.push({code:"unexpected-closing-delimiter",message:"closing parenthesis has no matching opening parenthesis",span:{start:Z,end:Z+1}}),q.push({kind:"unknown",source:O,span:{start:Z,end:Z+1}}),Z++;continue}if((O==="("||O==="{"&&CF($,Z,Q))&&G.start===-1){if(cJ(q,U,Z),K>=Y.maxDepth)return e2(q,U,Z,"depth-limit",Y.maxDepth);let E=O==="("?")":"}",_=M9($,Z+1,Q,X,Y,W,K+1,E),R=_.next,P={start:Z+1,end:_.closed?R-1:R},S=oB($,X,P,_);if(q.push({kind:"group",style:O==="("?"subshell":"brace",span:{start:Z,end:R},body:S}),U.push(..._.issues),_.pendingHeredocs.length>0||U3(_.nodes))U.push({code:"unsupported-heredoc-context",message:"heredocs attached inside command groups are not supported safely",span:{start:Z,end:R}});if(H.push(..._.pendingHeredocs),_.limited)return O9(q,U,_.next);if(!_.closed)U.push({code:O==="("?"unclosed-subshell":"unclosed-brace-group",message:`${O} group is not closed`,span:{start:Z,end:R}});Z=R;continue}let F=(O==="<"||O===">")&&$[Z+1]!=="("?PF($,Z):null;if(F){let E=G.words.at(-1),_=E&&E.span.end===Z&&/^[0-9]+$/.test(E.raw)?Number(E.raw):void 0;if(_!==void 0)G.words.pop();let R=_===void 0?Z:E?.span.start??Z;G.start=G.start===-1?Z:G.start;let P=Z+F.length;while(P<Q&&/[ \t]/.test($[P]??""))P++;let S=$[P],T=P>Z+F.length&&S==="#",y=!S||F9(S)||!!N9($,P)||S===B||S===")"||T||(S==="<"||S===">")&&$[P+1]!=="(",x=F==="<<"||F==="<<-"?mJ($,P,Q):void 0,c=x?{word:t2($,P,x.next,x.delimiter,"literal",x.quoted),nested:[],issues:[],next:x.next,limited:!1}:!y?dJ($,P,Q,X,Y,W,K):void 0;if(c){if(U.push(...c.issues),c.limited)return O9(q,U,c.next);if(!pJ(W))return e2(q,U,c.next,"word-limit",Y.maxWords)}let V1=c?.next??Z+F.length,C={kind:"redirection",operator:F,span:{start:R,end:V1},..._===void 0?{}:{fd:_},...c?{target:c.word}:{}};if(G.redirections.push(C),F==="<<"||F==="<<-")if(!x)U.push({code:"missing-heredoc-delimiter",message:"heredoc redirection requires a delimiter word",span:{start:Z,end:Z+F.length}});else{if(x.ambiguous||x.delimiter.length===0)U.push({code:"ambiguous-heredoc-delimiter",message:"heredoc delimiter cannot be determined safely",span:x.span});H.push({delimiter:x.delimiter,quotedDelimiter:x.quoted,stripTabs:F==="<<-",declarationSpan:{start:R,end:V1},attach:(m)=>{C.heredoc=m}})}else if(!c)U.push({code:"missing-redirection-target",message:`redirection ${F} requires a target word`,span:{start:Z,end:Z+F.length}});if(c)G.nested.push(...c.nested);G.end=V1,Z=V1;continue}if(G.start===-1)cJ(q,U,Z);let b=dJ($,Z,Q,X,Y,W,K);if(U.push(...b.issues),b.limited)return O9(q,U,b.next);let I=vF(G.words)?yF($,b.word,W.max-W.used,Y.maxDepth,Y.maxInputLength):void 0;if(I?.limitCode)return e2(q,U,b.next,I.limitCode,I.limitCode==="word-limit"?Y.maxWords:I.limitCode==="depth-limit"?Y.maxDepth:Y.maxInputLength);let A=I?.words??[b.word];for(let E of A){if(!pJ(W))return e2(q,U,b.next,"word-limit",Y.maxWords);G.words.push(E)}G.start=G.start===-1?Z:G.start,G.end=b.next,G.nested.push(...b.nested),Z=b.next>Z?b.next:Z+1}return L(),aB(q,U),U.push(...pF(H)),{nodes:q,issues:U,next:Z,closed:B===void 0,limited:!1,pendingHeredocs:[]}}function oB($,J,Q,X){return{kind:"program",dialect:J,source:$.slice(Q.start,Q.end),span:Q,status:V9(X.issues,X.limited),issues:X.issues,nodes:X.nodes}}function dJ($,J,Q,X,Y,W,K){let B="",q=J,U=!1,G="literal",H=[],L=[],Z=!1;while(q<Q){let O=$[q],M=(O==="<"||O===">")&&$[q+1]==="(";if(!O||F9(O)||(O===";"||O==="|"||O==="&")&&N9($,q)||(O==="<"||O===">")&&!M)break;if(O===")")break;if(O==="'"){U=!0;let F=$.indexOf("'",q+1);if(F===-1||F>=Q){B+=$.slice(q+1,Q),L.push({code:"unclosed-single-quote",message:"single-quoted word is not closed",span:{start:q,end:Q}}),q=Q;break}B+=$.slice(q+1,F),q=F+1;continue}if(O==='"'){U=!0;let F=RF($,q,Q,X,Y,W,K);if(B+=F.text,H.push(...F.nested),L.push(...F.issues),Z||=F.limited,G=q3(G,F.provenance),q=F.next,Z)break;continue}if($.startsWith("$'",q)){U=!0;let F=AF($,q+2,Q);if(B+=F.text,L.push(...F.issues),!F.closed)L.push({code:"unclosed-ansi-c-quote",message:"ANSI-C quoted word is not closed",span:{start:q,end:Q}});q=F.next;continue}if(O==="\\"){let F=$[q+1];if(!F){L.push({code:"trailing-escape",message:"escape has no following character",span:{start:q,end:q+1}}),q++;break}if(F===`
38
+ `){q+=2;continue}B+=F,q+=2;continue}let V=O==="$"||O==="<"||O===">"||O==="`"?rJ($,q,Q,X,Y,W,K):null;if(V){let F=$q(V,H,L);if(Z||=F.limited,G=q3(G,F.provenance),q=F.next,Z)break;continue}if(O==="$"){let F=Xq($,q,Q,B,G);B=F.text,G=F.provenance,q=F.next;continue}if(O==="*"||O==="?"||O==="[")G=q3(G,"glob");B+=O,q++}return{word:t2($,J,q,B,G,U,G==="literal"?void 0:SF($,J,q)),nested:H,issues:L,next:q,limited:Z}}function RF($,J,Q,X,Y,W,K){let B="",q="literal",U=[],G=[],H=!1,L=J+1;while(L<Q){let Z=$[L];if(Z==='"')return{text:B,provenance:q,nested:U,issues:G,next:L+1,limited:H};if(Z==="\\"&&$[L+1]){let M=$[L+1]??"";if(M===`
39
39
  `){L+=2;continue}if(M==="\r"&&$[L+2]===`
40
- `){L+=3;continue}B+=["$","`",'"',"\\"].includes(M)?M:`\\${M}`,L+=2;continue}if($.startsWith("$((",L)){let M=iJ($,L+3,Q,"))"),V=M===-1?Q:M+2;if(B+=$.slice(L,V),M===-1)G.push({code:"unclosed-arithmetic",message:"$(( substitution is not closed",span:{start:L,end:V}});L=V;continue}let O=rJ($,L,Q,X,Y,W,K);if(O){let M=$q(O,U,G);if(L=M.next,H||=M.limited,q=q3(q,M.provenance),H)return{text:B,provenance:q,nested:U,issues:G,next:L,limited:H};continue}if(Z==="$"){let M=Xq($,L,Q,B,q);B=M.text,q=M.provenance,L=M.next;continue}B+=Z??"",L++}return G.push({code:"unclosed-double-quote",message:"double-quoted word is not closed",span:{start:J,end:Q}}),{text:B,provenance:q,nested:U,issues:G,next:Q,limited:H}}function rJ($,J,Q,X,Y,W,K){let B=$.startsWith("$((",J),q=$.startsWith("$(",J)&&!B,U=($.startsWith("<(",J)||$.startsWith(">(",J))&&!0,G=$[J]==="`";if(!B&&!q&&!U&&!G)return null;let H=B?3:G?1:2,L=B?"))":G?"`":")",Z=iJ($,J+H,Q,L),O=Z===-1?Q:Z,M=Z===-1?Q:Z+L.length;if(K>=Y.maxDepth)return{program:xF($,J+H,O,X,"depth-limit"),next:M,provenance:B?"arithmetic":"command-substitution"};if(B){let I=[],A=[],E=!1,_=J+H;while(_<O){let R=rJ($,_,O,X,Y,W,K+1);if(!R){_++;continue}if(I.push(...R.program.nodes),A.push(...R.program.issues),E||=R.program.status==="limited",_=R.next,E)break}if(Z===-1)A.push({code:"unclosed-arithmetic",message:"$(( substitution is not closed",span:{start:J,end:M}});return{program:I1({kind:"program",dialect:X,source:$.slice(J+H,O),span:{start:J+H,end:O},status:V9(A,E),issues:A,nodes:I}),next:M,provenance:"arithmetic"}}let V=M9($,J+H,O,X,Y,W,K+1),F=Z===-1?[{code:B?"unclosed-arithmetic":"unclosed-command-substitution",message:`${$.slice(J,J+H)} substitution is not closed`,span:{start:J,end:M}}]:[],b=(G||U)&&U3(V.nodes)?[{code:"unsupported-heredoc-context",message:"heredocs are supported only in ordinary commands and $(...) substitutions",span:{start:J,end:M}}]:[];return{program:I1({kind:"program",dialect:X,source:$.slice(J+H,O),span:{start:J+H,end:O},status:V9([...V.issues,...F,...b],V.limited),issues:[...V.issues,...F,...b],nodes:V.nodes}),next:M,provenance:B?"arithmetic":"command-substitution"}}function $q($,J,Q){return J.push($.program),Q.push(...$.program.issues),{provenance:$.provenance,next:$.next,limited:$.program.status==="limited"}}function iJ($,J,Q,X){if(X==="`"){for(let B=J;B<Q;B++)if($[B]==="\\")B++;else if($[B]==="`")return B;return-1}let Y=1,W={single:!1,double:!1},K=[];for(let B=J;B<Q;B++){let q=$[B];if((q===`
40
+ `){L+=3;continue}B+=["$","`",'"',"\\"].includes(M)?M:`\\${M}`,L+=2;continue}if($.startsWith("$((",L)){let M=iJ($,L+3,Q,"))"),V=M===-1?Q:M+2;if(B+=$.slice(L,V),M===-1)G.push({code:"unclosed-arithmetic",message:"$(( substitution is not closed",span:{start:L,end:V}});L=V;continue}let O=rJ($,L,Q,X,Y,W,K);if(O){let M=$q(O,U,G);if(L=M.next,H||=M.limited,q=q3(q,M.provenance),H)return{text:B,provenance:q,nested:U,issues:G,next:L,limited:H};continue}if(Z==="$"){let M=Xq($,L,Q,B,q);B=M.text,q=M.provenance,L=M.next;continue}B+=Z??"",L++}return G.push({code:"unclosed-double-quote",message:"double-quoted word is not closed",span:{start:J,end:Q}}),{text:B,provenance:q,nested:U,issues:G,next:Q,limited:H}}function rJ($,J,Q,X,Y,W,K){let B=$.startsWith("$((",J),q=$.startsWith("$(",J)&&!B,U=($.startsWith("<(",J)||$.startsWith(">(",J))&&!0,G=$[J]==="`";if(!B&&!q&&!U&&!G)return null;let H=B?3:G?1:2,L=B?"))":G?"`":")",Z=iJ($,J+H,Q,L),O=Z===-1?Q:Z,M=Z===-1?Q:Z+L.length;if(K>=Y.maxDepth)return{program:mF($,J+H,O,X,"depth-limit"),next:M,provenance:B?"arithmetic":"command-substitution"};if(B){let I=[],A=[],E=!1,_=J+H;while(_<O){let R=rJ($,_,O,X,Y,W,K+1);if(!R){_++;continue}if(I.push(...R.program.nodes),A.push(...R.program.issues),E||=R.program.status==="limited",_=R.next,E)break}if(Z===-1)A.push({code:"unclosed-arithmetic",message:"$(( substitution is not closed",span:{start:J,end:M}});return{program:I1({kind:"program",dialect:X,source:$.slice(J+H,O),span:{start:J+H,end:O},status:V9(A,E),issues:A,nodes:I}),next:M,provenance:"arithmetic"}}let V=M9($,J+H,O,X,Y,W,K+1),F=Z===-1?[{code:B?"unclosed-arithmetic":"unclosed-command-substitution",message:`${$.slice(J,J+H)} substitution is not closed`,span:{start:J,end:M}}]:[],b=(G||U)&&U3(V.nodes)?[{code:"unsupported-heredoc-context",message:"heredocs are supported only in ordinary commands and $(...) substitutions",span:{start:J,end:M}}]:[];return{program:I1({kind:"program",dialect:X,source:$.slice(J+H,O),span:{start:J+H,end:O},status:V9([...V.issues,...F,...b],V.limited),issues:[...V.issues,...F,...b],nodes:V.nodes}),next:M,provenance:B?"arithmetic":"command-substitution"}}function $q($,J,Q){return J.push($.program),Q.push(...$.program.issues),{provenance:$.provenance,next:$.next,limited:$.program.status==="limited"}}function iJ($,J,Q,X){if(X==="`"){for(let B=J;B<Q;B++)if($[B]==="\\")B++;else if($[B]==="`")return B;return-1}let Y=1,W={single:!1,double:!1},K=[];for(let B=J;B<Q;B++){let q=$[B];if((q===`
41
41
  `||q==="\r")&&K.length>0){let G=q==="\r"&&$[B+1]===`
42
- `?B+2:B+1,H=lJ($,G,Q,K.splice(0));if(!H.terminated)return-1;B=H.next-1;continue}let U=Jq($,B,J,Q,W);if(U!==null){B=U;continue}if(!W.double&&$.startsWith("$((",B)){let G=jF($,B+3,Q);if(G===-1)return-1;B=G+1;continue}if(X===")"&&!W.double&&q==="<"&&$[B+1]==="<"&&$[B+2]!=="<"){let G=$[B+2]==="-",H=B+(G?3:2);while(H<Q&&/[ \t]/.test($[H]??""))H++;let L=mJ($,H,Q);if(L){K.push({delimiter:L.delimiter,quotedDelimiter:L.quoted,stripTabs:G,declarationSpan:{start:B,end:L.next},attach:()=>{return}}),B=L.next-1;continue}}if($.startsWith("$(",B)&&!$.startsWith("$((",B)){Y++,B++;continue}if(q==="("&&!W.double)Y++;if(q===")"&&!W.double){if(Y--,Y===0)return X==="))"&&$[B+1]!==")"?-1:B}}return-1}function jF($,J,Q){let X=1,Y={single:!1,double:!1};for(let W=J;W<Q;W++){let K=$[W],B=Jq($,W,J,Q,Y);if(B!==null){W=B;continue}if($.startsWith("$(",W)&&!$.startsWith("$((",W)){X++,W++;continue}if(K==="("&&!Y.double)X++;if(K!==")"||Y.double)continue;if(X--,X===0)return $[W+1]===")"?W:-1}return-1}function Jq($,J,Q,X,Y){let W=$[J];if(W==="\\"&&!Y.single)return J+1;if(!Y.double&&W==="'")Y.single=!Y.single;if(!Y.single&&W==='"')Y.double=!Y.double;if(Y.single)return J;if(Y.double||W!=="#"||!lF($,J,Q))return null;let K=J;while(K+1<X&&$[K+1]!==`
43
- `&&$[K+1]!=="\r")K++;return K}function N9($,J){let Q=$[J];if(Q===";")return";";if(Q==="&")return $[J+1]==="&"?"&&":"&";if(Q==="|")return $[J+1]==="|"?"||":$[J+1]==="&"?"|&":"|";return null}function RF($,J){let Q=$[J];if(Q===">"){if($[J+1]===">")return">>";if($[J+1]==="&")return">&";return $[J+1]==="|"?">|":">"}if(Q!=="<")return null;if($.startsWith("<<<",J))return"<<<";if($.startsWith("<<-",J))return"<<-";if($[J+1]==="<")return"<<";if($[J+1]==="&")return"<&";if($[J+1]===">")return"<>";return"<"}function F9($){let J=$.charCodeAt(0);if(J===32||J>=9&&J<=13)return!0;if(J<128)return!1;return/\s/u.test($)}function Qq($,J,Q){if($[J+1]==="{"){let Y=$.indexOf("}",J+2);return Y===-1||Y>=Q?Q:Y+1}let X=J+1;while(X<Q&&/[A-Za-z0-9_?@#$!*-]/.test($[X]??""))X++;return X===J+1?J+1:X}function bF($,J,Q){let X="",Y=[],W=J;while(W<Q){let K=$[W];if(K==="'")return{text:X,next:W+1,closed:!0,issues:Y};if(K!=="\\"){X+=K??"",W++;continue}let B=PF($,W+1,Q);if(X+=B.text,B.invalidCodePoint!==void 0)Y.push({code:"invalid-ansi-c-code-point",message:`ANSI-C escape is not a valid Unicode scalar value: ${B.invalidCodePoint}`,span:{start:W,end:B.next}});W=B.next}return{text:X,next:Q,closed:!1,issues:Y}}function PF($,J,Q){let X=$[J];if(!X||J>=Q)return{text:"\\",next:J};let Y=new Map([["a","\x07"],["b","\b"],["e","\x1B"],["E","\x1B"],["f","\f"],["n",`
44
- `],["r","\r"],["t","\t"],["v","\v"],["\\","\\"],["'","'"],['"','"']]);if(Y.has(X))return{text:Y.get(X)??X,next:J+1};if(X==="x")return L9($,J+1,Q,16,2,J+1);if(X==="u")return L9($,J+1,Q,16,4,J+1);if(X==="U")return L9($,J+1,Q,16,8,J+1);if(/[0-7]/.test(X))return L9($,J,Q,8,3,J+1);return{text:X,next:J+1}}function L9($,J,Q,X,Y,W){let K=X===16?/[0-9a-fA-F]/:/[0-7]/,B="",q=J;while(q<Q&&B.length<Y&&K.test($[q]??""))B+=$[q],q++;if(!B)return{text:$[W-1]??"",next:W};let U=Number.parseInt(B,X);return U>1114111||U>=55296&&U<=57343?{text:"\uFFFD",next:q,invalidCodePoint:U}:{text:String.fromCodePoint(U),next:q}}function V9($,J=!1){if(J)return"limited";if($.some((Q)=>Q.code==="invalid-ansi-c-code-point"||Q.code==="missing-heredoc-delimiter"||Q.code==="ambiguous-heredoc-delimiter"||Q.code==="unterminated-heredoc"||Q.code==="unsupported-heredoc-context"))return"invalid";return $.length>0?"partial":"complete"}function Xq($,J,Q,X,Y){let W=Qq($,J,Q);return{text:X+$.slice(J,W),provenance:q3(Y,"variable"),next:W}}function AF($,J,Q){let X=Z9($),Y=J,W=!1,K=!1,B=J;while(B<Q){let q=$[B];if(q==="\\"&&!W){B+=2;continue}if(!K&&q==="'"){W=!W,B++;continue}if(!W&&q==='"'){K=!K,B++;continue}if(W){B++;continue}let U=$.startsWith("$((",B),G=$.startsWith("$(",B)&&!U,H=!K&&($.startsWith("<(",B)||$.startsWith(">(",B)),L=q==="`";if(U||G||H||L){let Z=U?3:L?1:2,O=U?"))":L?"`":")",M=iJ($,B+Z,Q,O),V=M===-1?Q:M+O.length;X.push(Y,B,"literal"),X.push(B,V,U?"arithmetic":"command-substitution"),B=V,Y=V;continue}if(q==="$"){let Z=Qq($,B,Q);if(Z>B+1){X.push(Y,B,"literal"),X.push(B,Z,"variable"),B=Z,Y=Z;continue}}if(!K&&(q==="*"||q==="?"||q==="[")){X.push(Y,B,"literal"),X.push(B,B+1,"glob"),B++,Y=B;continue}B++}return X.push(Y,Q,"literal"),X.parts}function q3($,J){if(J==="command-substitution"||$==="command-substitution")return"command-substitution";if(J==="arithmetic"||$==="arithmetic")return"arithmetic";if(J==="variable"||$==="variable")return"variable";if(J==="glob"||$==="glob")return"glob";return $}function EF($,J,Q){return J+1>=Q||F9($[J+1]??"")||N9($,J+1)!==null}var SF=new Set(["-u","--unset","-C","--chdir","-S","--split-string","-P"]),CF=new Set(["-u","-g","-C","-D","-h","-p","-r","-t","-T","-U"]);function TF($){let J=0;while(J<=$.length){while(/^[A-Za-z_][A-Za-z0-9_]*=/.test($[J]?.text??""))J++;if(J===$.length)return!0;let Q=wF($,J);if(Q===void 0||Q===null)return!1;J=Q}return!1}function wF($,J){let Q=$[J]?.text.toLowerCase();if(Q==="command")return vF($,J);if(Q==="env")return fF($,J);if(Q==="sudo")return hF($,J);return}function vF($,J){if($[J+1]?.text==="-v")return null;for(let Q=J+1;Q<$.length;Q++){let X=$[Q]?.text??"";if(X==="--")return Q+1;if(X==="-p"||X==="-v"||X==="-V"||/^-[pvV]+$/.test(X))continue;return Q}return $.length}function fF($,J){for(let Q=J+1;Q<$.length;Q++){let X=$[Q]?.text??"";if(X==="--")return Q+1;if(SF.has(X)){if($[Q+1]===void 0)return null;Q++;continue}if(X.startsWith("-u=")||X.startsWith("--unset=")||X.startsWith("-C")&&X.length>2||X.startsWith("--chdir=")||X.startsWith("-S")&&X.length>2||X.startsWith("--split-string=")||X.startsWith("-P"))continue;if(X.startsWith("-")||/^[A-Za-z_][A-Za-z0-9_]*=/.test(X))continue;return Q}return $.length}function hF($,J){for(let Q=J+1;Q<$.length;Q++){let X=$[Q]?.text??"";if(X==="--")return Q+1;if(CF.has(X)){if($[Q+1]===void 0)return null;Q++;continue}if(X.startsWith("-"))continue;return Q}return $.length}function Yq($,J,Q,X){if($.provenance!=="literal"||!$.raw.includes("{"))return;let Y=[$.raw],W=$.raw.length,K=0;while(!0){let q=Y.findIndex((O)=>sB(O));if(q===-1)break;if(++K>Q)return{limited:!0};let U=Y[q]??"",G=sB(U);if(!G||G.kind==="range")return{limited:!0};let H=G.start+U.length-G.end,L=G.alternatives.reduce((O,M)=>O+H+M.length,0);if(W-U.length+L>X||Y.length-1+G.alternatives.length>J)return{limited:!0};let Z=Wq(U,G);Y.splice(q,1,...Z),W+=L-U.length}if(K===0)return;let B=Y.map((q)=>yF(q,Q));if(B.some((q)=>q===null))return{limited:!0};return{words:[...new Set(B.filter((q)=>q!==null&&q!==""))]}}function kF($,J,Q,X,Y){if(J.provenance!=="literal"||J.quoted||J.raw!==J.text||!J.raw.includes("{"))return;let W=[J.text],K=J.text.length,B=0;while(!0){let U=W.findIndex((V)=>nB(V));if(U===-1)break;if(++B>X)return{limitCode:"depth-limit"};let G=W[U]??"",H=nB(G);if(!H)break;let L=H.start+G.length-H.end,Z=H.alternatives.filter((V)=>L+V.length>0),O=Z.reduce((V,F)=>V+L+F.length,0);if(K-G.length+O>Y)return{limitCode:"brace-expansion-limit"};if(W.length-1+Z.length>Q)return{limitCode:"word-limit"};let M=Wq(G,{...H,alternatives:Z});W.splice(U,1,...M),K+=O-G.length}let q=W.filter((U)=>U.length>0);if(B===0)return;return{words:q.map((U)=>t2($,J.span.start,J.span.end,U,"literal",!1))}}function nB($){let J=[],Q;for(let X=0;X<$.length;X++){let Y=$[X];if(Y==="{"){J.push({start:X,commas:[]});continue}if(Y===","&&J.length>0){J.at(-1)?.commas.push(X);continue}if(Y!=="}"||J.length===0)continue;let W=J.pop();if(!W||W.commas.length===0)continue;if(!Q||W.start<Q.start)Q={start:W.start,end:X+1,commas:W.commas}}if(!Q)return;return{start:Q.start,end:Q.end,alternatives:Kq($,Q)}}function sB($){let J=[],Q,X=null,Y=!1;for(let W=0;W<$.length;W++){let K=$[W];if(Y){Y=!1;continue}if(K==="\\"&&X!=="'"){Y=!0;continue}if(K===X){X=null;continue}if(X===null&&(K==="'"||K==='"')){X=K;continue}if(X!==null)continue;if(K==="{"){J.push({start:W,commas:[]});continue}if(K===","&&J.length>0){J.at(-1)?.commas.push(W);continue}if(K!=="}"||J.length===0)continue;let B=J.pop();if(!B)continue;let q=B.commas.length>0?{kind:"alternatives",start:B.start,end:W+1,commas:B.commas}:gF($.slice(B.start+1,W))?{kind:"range",start:B.start,end:W+1}:void 0;if(q&&(!Q||q.start<Q.start))Q=q}if(!Q||Q.kind==="range")return Q;return{kind:Q.kind,start:Q.start,end:Q.end,alternatives:Kq($,Q)}}function Wq($,J){return J.alternatives.map((Q)=>`${$.slice(0,J.start)}${Q}${$.slice(J.end)}`)}function Kq($,J){let Q=[J.start,...J.commas,J.end-1];return Q.slice(0,-1).map((X,Y)=>$.slice(X+1,Q[Y+1]))}function gF($){return/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test($)||/^[A-Za-z]\.\.[A-Za-z](?:\.\.-?\d+)?$/.test($)}function yF($,J){let Q=`x${$}`,X=dJ(Q,0,Q.length,"posix",{maxInputLength:Q.length,maxWords:1,maxDepth:J},{used:0,max:1},0);if(X.limited||X.issues.length>0||X.next!==Q.length||X.word.provenance!=="literal")return null;return X.word.text.slice(1)}function xF($,J,Q,X,Y){return I1({kind:"program",dialect:X,source:$.slice(J,Q),span:{start:J,end:Q},status:"limited",issues:[{code:Y,message:"command structure exceeds parser limit",span:{start:J,end:Q}}],nodes:[]})}function e2($,J,Q,X,Y){return{nodes:$,issues:[...J,{code:X,message:`command structure exceeds parser limit ${Y}`,span:{start:Q,end:Q}}],next:Q,closed:!1,limited:!0,pendingHeredocs:[]}}function O9($,J,Q){return{nodes:$,issues:J,next:Q,closed:!1,limited:!0,pendingHeredocs:[]}}function pJ($){return $.used++,$.used<=$.max}function uF($,J,Q){let X=/^([A-Za-z_][A-Za-z0-9_]*)[ \t]*\([ \t]*\)[ \t]*\{/.exec($.slice(J,Q)),Y=X?.[1];if(!X||!Y)return;return{name:Y,braceIndex:J+X[0].lastIndexOf("{")}}function U3($){return $.some((J)=>{if(J.kind==="command")return J.redirections.some((Q)=>Q.heredoc)||J.nested.some((Q)=>U3(Q.nodes));return(J.kind==="group"||J.kind==="function")&&U3(J.body.nodes)})}function mF($){return $.map((J)=>({code:"unterminated-heredoc",message:`heredoc delimiter ${J.delimiter} was not found`,span:J.declarationSpan}))}function Bq($){return $?.kind==="command"||$?.kind==="group"||$?.kind==="function"}function aB($,J){let Q=$.at(-1);if(Q?.kind!=="connector"||!tB.has(Q.operator))return;J.push({code:"missing-command-after-connector",message:`connector ${Q.operator} requires a following command`,span:Q.span})}function cJ($,J,Q){if(!Bq($.at(-1)))return;J.push({code:"missing-command-connector",message:"adjacent commands require a connector",span:{start:Q,end:Q+1}})}function lF($,J,Q){return J===Q||/[\s;&|()]/u.test($[J-1]??"")}var qq=new Set(["remove-item","ri","del","erase","rd","rmdir"]),Uq=["-rec","-for","-path","-literalpath","-whatif"],_9={maxInputLength:131072,maxWords:16384,maxDepth:64};function Gq($){let J=$.toLowerCase().replaceAll("`","");if(![...qq].some((X)=>J.includes(X))&&!(J.includes("rm")&&Uq.some((X)=>J.includes(X)))&&!J.includes("<#"))return!1;let Q=rF($);return Q.invalidComment||Q.commands.some(pF)}function pF($){let J=$[0]==="&"||$[0]==="."?1:0,Q=$[J]?.toLowerCase();if(Q&&qq.has(Q))return!0;if(Q!=="rm")return!1;return $.slice(J+1).some((X)=>{let Y=X.toLowerCase().split(":",1)[0]??"";return Uq.some((W)=>Y.startsWith(W))})}function Hq($,J){let Q={start:0,end:$.length};if($.length>J.maxInputLength)return I1({kind:"program",dialect:"powershell",source:$,span:Q,status:"limited",issues:[{code:"input-limit",message:`command exceeds ${J.maxInputLength} UTF-16 code units`,span:Q}],nodes:[]});let X=tJ($,0,$.length,J,0);return I1({kind:"program",dialect:"powershell",source:$,span:Q,status:iF(X.issues,X.limited),issues:X.issues,nodes:X.nodes})}function tJ($,J,Q,X,Y,W=!1){let K=q9(),B=U9(),q=G9(),U=0,G=!1,H=()=>{if(q.words.length===0&&q.redirections.length===0)return;let Z={start:q.start,end:q.end};H9(K,q,{kind:"command",dialect:"powershell",source:$.slice(Z.start,Z.end),span:Z,words:q.words,redirections:q.redirections,nested:q.nested,dynamicExecutable:q.words[0]?.provenance!=="literal",displayText:q.words.map((O)=>O.text).join(" ")})},L=J;while(L<Q){let Z=$[L];if(!Z)break;if(W&&Z==="}")return H(),{nodes:K,issues:B,next:L+1,closed:!0,words:U,limited:G};let O=Oq($,L,Q,X.maxDepth);if(O){if(O.issue)B.push(O.issue);if(O.limited)return H(),{nodes:K,issues:B,next:O.next,closed:!1,words:U,limited:!0};L=O.next;continue}if(/\s/.test(Z)){if(Z==="\r"||Z===`
42
+ `?B+2:B+1,H=lJ($,G,Q,K.splice(0));if(!H.terminated)return-1;B=H.next-1;continue}let U=Jq($,B,J,Q,W);if(U!==null){B=U;continue}if(!W.double&&$.startsWith("$((",B)){let G=bF($,B+3,Q);if(G===-1)return-1;B=G+1;continue}if(X===")"&&!W.double&&q==="<"&&$[B+1]==="<"&&$[B+2]!=="<"){let G=$[B+2]==="-",H=B+(G?3:2);while(H<Q&&/[ \t]/.test($[H]??""))H++;let L=mJ($,H,Q);if(L){K.push({delimiter:L.delimiter,quotedDelimiter:L.quoted,stripTabs:G,declarationSpan:{start:B,end:L.next},attach:()=>{return}}),B=L.next-1;continue}}if($.startsWith("$(",B)&&!$.startsWith("$((",B)){Y++,B++;continue}if(q==="("&&!W.double)Y++;if(q===")"&&!W.double){if(Y--,Y===0)return X==="))"&&$[B+1]!==")"?-1:B}}return-1}function bF($,J,Q){let X=1,Y={single:!1,double:!1};for(let W=J;W<Q;W++){let K=$[W],B=Jq($,W,J,Q,Y);if(B!==null){W=B;continue}if($.startsWith("$(",W)&&!$.startsWith("$((",W)){X++,W++;continue}if(K==="("&&!Y.double)X++;if(K!==")"||Y.double)continue;if(X--,X===0)return $[W+1]===")"?W:-1}return-1}function Jq($,J,Q,X,Y){let W=$[J];if(W==="\\"&&!Y.single)return J+1;if(!Y.double&&W==="'")Y.single=!Y.single;if(!Y.single&&W==='"')Y.double=!Y.double;if(Y.single)return J;if(Y.double||W!=="#"||!cF($,J,Q))return null;let K=J;while(K+1<X&&$[K+1]!==`
43
+ `&&$[K+1]!=="\r")K++;return K}function N9($,J){let Q=$[J];if(Q===";")return";";if(Q==="&")return $[J+1]==="&"?"&&":"&";if(Q==="|")return $[J+1]==="|"?"||":$[J+1]==="&"?"|&":"|";return null}function PF($,J){let Q=$[J];if(Q===">"){if($[J+1]===">")return">>";if($[J+1]==="&")return">&";return $[J+1]==="|"?">|":">"}if(Q!=="<")return null;if($.startsWith("<<<",J))return"<<<";if($.startsWith("<<-",J))return"<<-";if($[J+1]==="<")return"<<";if($[J+1]==="&")return"<&";if($[J+1]===">")return"<>";return"<"}function F9($){let J=$.charCodeAt(0);if(J===32||J>=9&&J<=13)return!0;if(J<128)return!1;return/\s/u.test($)}function Qq($,J,Q){if($[J+1]==="{"){let Y=$.indexOf("}",J+2);return Y===-1||Y>=Q?Q:Y+1}let X=J+1;while(X<Q&&/[A-Za-z0-9_?@#$!*-]/.test($[X]??""))X++;return X===J+1?J+1:X}function AF($,J,Q){let X="",Y=[],W=J;while(W<Q){let K=$[W];if(K==="'")return{text:X,next:W+1,closed:!0,issues:Y};if(K!=="\\"){X+=K??"",W++;continue}let B=EF($,W+1,Q);if(X+=B.text,B.invalidCodePoint!==void 0)Y.push({code:"invalid-ansi-c-code-point",message:`ANSI-C escape is not a valid Unicode scalar value: ${B.invalidCodePoint}`,span:{start:W,end:B.next}});W=B.next}return{text:X,next:Q,closed:!1,issues:Y}}function EF($,J,Q){let X=$[J];if(!X||J>=Q)return{text:"\\",next:J};let Y=new Map([["a","\x07"],["b","\b"],["e","\x1B"],["E","\x1B"],["f","\f"],["n",`
44
+ `],["r","\r"],["t","\t"],["v","\v"],["\\","\\"],["'","'"],['"','"']]);if(Y.has(X))return{text:Y.get(X)??X,next:J+1};if(X==="x")return L9($,J+1,Q,16,2,J+1);if(X==="u")return L9($,J+1,Q,16,4,J+1);if(X==="U")return L9($,J+1,Q,16,8,J+1);if(/[0-7]/.test(X))return L9($,J,Q,8,3,J+1);return{text:X,next:J+1}}function L9($,J,Q,X,Y,W){let K=X===16?/[0-9a-fA-F]/:/[0-7]/,B="",q=J;while(q<Q&&B.length<Y&&K.test($[q]??""))B+=$[q],q++;if(!B)return{text:$[W-1]??"",next:W};let U=Number.parseInt(B,X);return U>1114111||U>=55296&&U<=57343?{text:"\uFFFD",next:q,invalidCodePoint:U}:{text:String.fromCodePoint(U),next:q}}function V9($,J=!1){if(J)return"limited";if($.some((Q)=>Q.code==="invalid-ansi-c-code-point"||Q.code==="missing-heredoc-delimiter"||Q.code==="ambiguous-heredoc-delimiter"||Q.code==="unterminated-heredoc"||Q.code==="unsupported-heredoc-context"))return"invalid";return $.length>0?"partial":"complete"}function Xq($,J,Q,X,Y){let W=Qq($,J,Q);return{text:X+$.slice(J,W),provenance:q3(Y,"variable"),next:W}}function SF($,J,Q){let X=Z9($),Y=J,W=!1,K=!1,B=J;while(B<Q){let q=$[B];if(q==="\\"&&!W){B+=2;continue}if(!K&&q==="'"){W=!W,B++;continue}if(!W&&q==='"'){K=!K,B++;continue}if(W){B++;continue}let U=$.startsWith("$((",B),G=$.startsWith("$(",B)&&!U,H=!K&&($.startsWith("<(",B)||$.startsWith(">(",B)),L=q==="`";if(U||G||H||L){let Z=U?3:L?1:2,O=U?"))":L?"`":")",M=iJ($,B+Z,Q,O),V=M===-1?Q:M+O.length;X.push(Y,B,"literal"),X.push(B,V,U?"arithmetic":"command-substitution"),B=V,Y=V;continue}if(q==="$"){let Z=Qq($,B,Q);if(Z>B+1){X.push(Y,B,"literal"),X.push(B,Z,"variable"),B=Z,Y=Z;continue}}if(!K&&(q==="*"||q==="?"||q==="[")){X.push(Y,B,"literal"),X.push(B,B+1,"glob"),B++,Y=B;continue}B++}return X.push(Y,Q,"literal"),X.parts}function q3($,J){if(J==="command-substitution"||$==="command-substitution")return"command-substitution";if(J==="arithmetic"||$==="arithmetic")return"arithmetic";if(J==="variable"||$==="variable")return"variable";if(J==="glob"||$==="glob")return"glob";return $}function CF($,J,Q){return J+1>=Q||F9($[J+1]??"")||N9($,J+1)!==null}var TF=new Set(["-u","--unset","-C","--chdir","-S","--split-string","-P"]),wF=new Set(["-u","-g","-C","-D","-h","-p","-r","-t","-T","-U"]);function vF($){let J=0;while(J<=$.length){while(/^[A-Za-z_][A-Za-z0-9_]*=/.test($[J]?.text??""))J++;if(J===$.length)return!0;let Q=fF($,J);if(Q===void 0||Q===null)return!1;J=Q}return!1}function fF($,J){let Q=$[J]?.text.toLowerCase();if(Q==="command")return hF($,J);if(Q==="env")return kF($,J);if(Q==="sudo")return gF($,J);return}function hF($,J){if($[J+1]?.text==="-v")return null;for(let Q=J+1;Q<$.length;Q++){let X=$[Q]?.text??"";if(X==="--")return Q+1;if(X==="-p"||X==="-v"||X==="-V"||/^-[pvV]+$/.test(X))continue;return Q}return $.length}function kF($,J){for(let Q=J+1;Q<$.length;Q++){let X=$[Q]?.text??"";if(X==="--")return Q+1;if(TF.has(X)){if($[Q+1]===void 0)return null;Q++;continue}if(X.startsWith("-u=")||X.startsWith("--unset=")||X.startsWith("-C")&&X.length>2||X.startsWith("--chdir=")||X.startsWith("-S")&&X.length>2||X.startsWith("--split-string=")||X.startsWith("-P"))continue;if(X.startsWith("-")||/^[A-Za-z_][A-Za-z0-9_]*=/.test(X))continue;return Q}return $.length}function gF($,J){for(let Q=J+1;Q<$.length;Q++){let X=$[Q]?.text??"";if(X==="--")return Q+1;if(wF.has(X)){if($[Q+1]===void 0)return null;Q++;continue}if(X.startsWith("-"))continue;return Q}return $.length}function Yq($,J,Q,X){if($.provenance!=="literal"||!$.raw.includes("{"))return;let Y=[$.raw],W=$.raw.length,K=0;while(!0){let q=Y.findIndex((O)=>sB(O));if(q===-1)break;if(++K>Q)return{limited:!0};let U=Y[q]??"",G=sB(U);if(!G||G.kind==="range")return{limited:!0};let H=G.start+U.length-G.end,L=G.alternatives.reduce((O,M)=>O+H+M.length,0);if(W-U.length+L>X||Y.length-1+G.alternatives.length>J)return{limited:!0};let Z=Wq(U,G);Y.splice(q,1,...Z),W+=L-U.length}if(K===0)return;let B=Y.map((q)=>uF(q,Q));if(B.some((q)=>q===null))return{limited:!0};return{words:[...new Set(B.filter((q)=>q!==null&&q!==""))]}}function yF($,J,Q,X,Y){if(J.provenance!=="literal"||J.quoted||J.raw!==J.text||!J.raw.includes("{"))return;let W=[J.text],K=J.text.length,B=0;while(!0){let U=W.findIndex((V)=>nB(V));if(U===-1)break;if(++B>X)return{limitCode:"depth-limit"};let G=W[U]??"",H=nB(G);if(!H)break;let L=H.start+G.length-H.end,Z=H.alternatives.filter((V)=>L+V.length>0),O=Z.reduce((V,F)=>V+L+F.length,0);if(K-G.length+O>Y)return{limitCode:"brace-expansion-limit"};if(W.length-1+Z.length>Q)return{limitCode:"word-limit"};let M=Wq(G,{...H,alternatives:Z});W.splice(U,1,...M),K+=O-G.length}let q=W.filter((U)=>U.length>0);if(B===0)return;return{words:q.map((U)=>t2($,J.span.start,J.span.end,U,"literal",!1))}}function nB($){let J=[],Q;for(let X=0;X<$.length;X++){let Y=$[X];if(Y==="{"){J.push({start:X,commas:[]});continue}if(Y===","&&J.length>0){J.at(-1)?.commas.push(X);continue}if(Y!=="}"||J.length===0)continue;let W=J.pop();if(!W||W.commas.length===0)continue;if(!Q||W.start<Q.start)Q={start:W.start,end:X+1,commas:W.commas}}if(!Q)return;return{start:Q.start,end:Q.end,alternatives:Kq($,Q)}}function sB($){let J=[],Q,X=null,Y=!1;for(let W=0;W<$.length;W++){let K=$[W];if(Y){Y=!1;continue}if(K==="\\"&&X!=="'"){Y=!0;continue}if(K===X){X=null;continue}if(X===null&&(K==="'"||K==='"')){X=K;continue}if(X!==null)continue;if(K==="{"){J.push({start:W,commas:[]});continue}if(K===","&&J.length>0){J.at(-1)?.commas.push(W);continue}if(K!=="}"||J.length===0)continue;let B=J.pop();if(!B)continue;let q=B.commas.length>0?{kind:"alternatives",start:B.start,end:W+1,commas:B.commas}:xF($.slice(B.start+1,W))?{kind:"range",start:B.start,end:W+1}:void 0;if(q&&(!Q||q.start<Q.start))Q=q}if(!Q||Q.kind==="range")return Q;return{kind:Q.kind,start:Q.start,end:Q.end,alternatives:Kq($,Q)}}function Wq($,J){return J.alternatives.map((Q)=>`${$.slice(0,J.start)}${Q}${$.slice(J.end)}`)}function Kq($,J){let Q=[J.start,...J.commas,J.end-1];return Q.slice(0,-1).map((X,Y)=>$.slice(X+1,Q[Y+1]))}function xF($){return/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test($)||/^[A-Za-z]\.\.[A-Za-z](?:\.\.-?\d+)?$/.test($)}function uF($,J){let Q=`x${$}`,X=dJ(Q,0,Q.length,"posix",{maxInputLength:Q.length,maxWords:1,maxDepth:J},{used:0,max:1},0);if(X.limited||X.issues.length>0||X.next!==Q.length||X.word.provenance!=="literal")return null;return X.word.text.slice(1)}function mF($,J,Q,X,Y){return I1({kind:"program",dialect:X,source:$.slice(J,Q),span:{start:J,end:Q},status:"limited",issues:[{code:Y,message:"command structure exceeds parser limit",span:{start:J,end:Q}}],nodes:[]})}function e2($,J,Q,X,Y){return{nodes:$,issues:[...J,{code:X,message:`command structure exceeds parser limit ${Y}`,span:{start:Q,end:Q}}],next:Q,closed:!1,limited:!0,pendingHeredocs:[]}}function O9($,J,Q){return{nodes:$,issues:J,next:Q,closed:!1,limited:!0,pendingHeredocs:[]}}function pJ($){return $.used++,$.used<=$.max}function lF($,J,Q){let X=/^([A-Za-z_][A-Za-z0-9_]*)[ \t]*\([ \t]*\)[ \t]*\{/.exec($.slice(J,Q)),Y=X?.[1];if(!X||!Y)return;return{name:Y,braceIndex:J+X[0].lastIndexOf("{")}}function U3($){return $.some((J)=>{if(J.kind==="command")return J.redirections.some((Q)=>Q.heredoc)||J.nested.some((Q)=>U3(Q.nodes));return(J.kind==="group"||J.kind==="function")&&U3(J.body.nodes)})}function pF($){return $.map((J)=>({code:"unterminated-heredoc",message:`heredoc delimiter ${J.delimiter} was not found`,span:J.declarationSpan}))}function Bq($){return $?.kind==="command"||$?.kind==="group"||$?.kind==="function"}function aB($,J){let Q=$.at(-1);if(Q?.kind!=="connector"||!tB.has(Q.operator))return;J.push({code:"missing-command-after-connector",message:`connector ${Q.operator} requires a following command`,span:Q.span})}function cJ($,J,Q){if(!Bq($.at(-1)))return;J.push({code:"missing-command-connector",message:"adjacent commands require a connector",span:{start:Q,end:Q+1}})}function cF($,J,Q){return J===Q||/[\s;&|()]/u.test($[J-1]??"")}var qq=new Set(["remove-item","ri","del","erase","rd","rmdir"]),Uq=["-rec","-for","-path","-literalpath","-whatif"],_9={maxInputLength:131072,maxWords:16384,maxDepth:64};function Gq($){let J=$.toLowerCase().replaceAll("`","");if(![...qq].some((X)=>J.includes(X))&&!(J.includes("rm")&&Uq.some((X)=>J.includes(X)))&&!J.includes("<#"))return!1;let Q=oF($);return Q.invalidComment||Q.commands.some(dF)}function dF($){let J=$[0]==="&"||$[0]==="."?1:0,Q=$[J]?.toLowerCase();if(Q&&qq.has(Q))return!0;if(Q!=="rm")return!1;return $.slice(J+1).some((X)=>{let Y=X.toLowerCase().split(":",1)[0]??"";return Uq.some((W)=>Y.startsWith(W))})}function Hq($,J){let Q={start:0,end:$.length};if($.length>J.maxInputLength)return I1({kind:"program",dialect:"powershell",source:$,span:Q,status:"limited",issues:[{code:"input-limit",message:`command exceeds ${J.maxInputLength} UTF-16 code units`,span:Q}],nodes:[]});let X=tJ($,0,$.length,J,0);return I1({kind:"program",dialect:"powershell",source:$,span:Q,status:nF(X.issues,X.limited),issues:X.issues,nodes:X.nodes})}function tJ($,J,Q,X,Y,W=!1){let K=q9(),B=U9(),q=G9(),U=0,G=!1,H=()=>{if(q.words.length===0&&q.redirections.length===0)return;let Z={start:q.start,end:q.end};H9(K,q,{kind:"command",dialect:"powershell",source:$.slice(Z.start,Z.end),span:Z,words:q.words,redirections:q.redirections,nested:q.nested,dynamicExecutable:q.words[0]?.provenance!=="literal",displayText:q.words.map((O)=>O.text).join(" ")})},L=J;while(L<Q){let Z=$[L];if(!Z)break;if(W&&Z==="}")return H(),{nodes:K,issues:B,next:L+1,closed:!0,words:U,limited:G};let O=Oq($,L,Q,X.maxDepth);if(O){if(O.issue)B.push(O.issue);if(O.limited)return H(),{nodes:K,issues:B,next:O.next,closed:!1,words:U,limited:!0};L=O.next;continue}if(/\s/.test(Z)){if(Z==="\r"||Z===`
45
45
  `){H();let F=Z==="\r"&&$[L+1]===`
46
- `?L+2:L+1;K.push(oJ($,L,F)),L=F;continue}L++;continue}let M=eJ($,L);if(M){H(),K.push(oJ($,L,L+M.length)),L+=M.length;continue}if(Z==="{"){if(H(),Y>=X.maxDepth)return B.push(Lq(L,X.maxDepth)),{nodes:K,issues:B,next:Q,closed:!1,words:U,limited:!0};let F=tJ($,L+1,Q,X,Y+1,!0),b=F.closed?F.next-1:F.next,I=I1({kind:"program",dialect:"powershell",source:$.slice(L+1,b),span:{start:L+1,end:b},status:F.limited?"limited":F.issues.length>0?"partial":"complete",issues:F.issues,nodes:F.nodes});if(K.push(Object.freeze({kind:"group",style:"brace",span:Object.freeze({start:L,end:F.next}),body:I})),B.push(...F.issues),!F.closed)B.push({code:"unclosed-script-block",message:"PowerShell script block is not closed",span:{start:L,end:F.next}});U+=F.words,G||=F.limited,L=F.next;continue}if(Z==="}"){H(),K.push(oJ($,L,L+1)),L++;continue}if(Z===">"||Z==="<"){q.start=q.start===-1?L:q.start;let F=$[L+1]===Z?L+2:L+1,b=F;while(/[ \t]/.test($[b]??""))b++;let I=b<Q?nJ($,b,Q,X,Y):void 0,A=I?.next??F;if(q.redirections.push(Object.freeze({kind:"redirection",operator:$.slice(L,F),span:Object.freeze({start:L,end:A}),...I?{target:I.word}:{}})),I)B.push(...I.issues),q.nested.push(...I.nested),U+=I.words,G||=I.limited;q.end=A,L=A;continue}if(Z===","){q.start=q.start===-1?L:q.start,q.words.push(uJ({text:",",raw:",",span:{start:L,end:L+1},provenance:"literal",quoted:!1})),q.end=++L;continue}let V=nJ($,L,Q,X,Y);if(q.start=q.start===-1?L:q.start,q.end=V.next,q.words.push(V.word),B.push(...V.issues),q.nested.push(...V.nested),U+=1+V.words,G||=V.limited,U>X.maxWords)return B.push({code:"word-limit",message:`command exceeds ${X.maxWords} words`,span:{start:L,end:V.next}}),H(),{nodes:K,issues:B,next:V.next,closed:!1,words:U,limited:!0};L=V.next>L?V.next:L+1}return H(),{nodes:K,issues:B,next:L,closed:!W,words:U,limited:G}}function nJ($,J,Q,X,Y){let W="",K="literal",B=!1,q=[],U=[],G=0,H=!1,L=(O)=>{let M=cF($,O,Q,X,Y);return W+=$.slice(O,M.next),U.push(M.program),q.push(...M.program.issues),G+=sJ(M.program),H||=M.program.status==="limited",K="command-substitution",M.next},Z=J;while(Z<Q){let O=$[Z];if(!O||/\s/.test(O)||eJ($,Z)||O===">"||O==="<"||O==="#")break;if(O===",")break;if(O==="`"){let M=$[Z+1];if(!M){q.push({code:"trailing-escape",message:"PowerShell escape has no following character",span:{start:Z,end:Z+1}}),Z++;break}W+=M,Z+=2;continue}if($.startsWith("$(",Z)){Z=L(Z);continue}if(O==="'"){B=!0,Z++;let M=!1;while(Z<$.length){if($[Z]==="'"&&$[Z+1]==="'"){W+="'",Z+=2;continue}if($[Z]==="'"){M=!0,Z++;break}W+=$[Z]??"",Z++}if(!M)q.push({code:"unclosed-single-quote",message:"single-quoted word is not closed",span:{start:J,end:$.length}});continue}if(O==='"'){B=!0;let M=Z++,V=!1;while(Z<Q){let F=$[Z];if(F==="`"&&$[Z+1]){W+=$[Z+1],Z+=2;continue}if(F==='"'){V=!0,Z++;break}if($.startsWith("$(",Z)){Z=L(Z);continue}if(F==="$")K=$[Z+1]==="("?"command-substitution":"variable";W+=F??"",Z++}if(!V)q.push({code:"unclosed-double-quote",message:"double-quoted word is not closed",span:{start:M,end:$.length}});continue}if(O==="$")K=$[Z+1]==="("?"command-substitution":"variable";if(O==="@"&&Z===J)K="variable";W+=O,Z++}return{word:t2($,J,Z,W,K,B,K==="literal"?void 0:dF($,J,Z)),next:Z,issues:q,nested:U,words:G,limited:H}}function cF($,J,Q,X,Y){let W=Zq($,J+2,Q),K=W===-1?Q:W,B=W===-1?Q:W+1;if(Y>=X.maxDepth)return{program:I1({kind:"program",dialect:"powershell",source:$.slice(J+2,K),span:{start:J+2,end:K},status:"limited",issues:[Lq(J,X.maxDepth)],nodes:[]}),next:B};let q=tJ($,J+2,K,X,Y+1),U=W===-1?[{code:"unclosed-command-subexpression",message:"PowerShell command subexpression is not closed",span:{start:J,end:B}}]:[];return{program:I1({kind:"program",dialect:"powershell",source:$.slice(J+2,K),span:{start:J+2,end:K},status:q.limited?"limited":q.issues.length+U.length>0?"partial":"complete",issues:[...q.issues,...U],nodes:q.nodes}),next:B}}function Zq($,J,Q){let X=1,Y=!1,W=!1;for(let K=J;K<Q;K++){let B=$[K];if(B==="`"){K++;continue}if(!W&&B==="'"){if(Y&&$[K+1]==="'"){K++;continue}Y=!Y;continue}if(!Y&&B==='"'){W=!W;continue}if(Y)continue;if($.startsWith("$(",K)){X++,K++;continue}if(!W&&B==="(")X++;if(B!==")")continue;if(X--,X===0)return K}return-1}function sJ($){let J=0;for(let Q of $.nodes){if(Q.kind==="group")J+=sJ(Q.body);if(Q.kind==="command"){J+=Q.words.length;for(let X of Q.nested)J+=sJ(X)}}return J}function dF($,J,Q){let X=Z9($),Y=J,W=!1,K=J;while(K<Q){let B=$[K];if(B==="`"){K+=2;continue}if(B==="'"){if(W&&$[K+1]==="'"){K+=2;continue}W=!W,K++;continue}if(W){K++;continue}if($.startsWith("$(",K)){let q=Zq($,K+2,Q),U=q===-1?Q:q+1;X.push(Y,K,"literal"),X.push(K,U,"command-substitution"),K=U,Y=U;continue}if(B==="$"||B==="@"&&K===J){let q=K+1;if($[q]==="{"){let U=$.indexOf("}",q+1);q=U===-1||U>=Q?Q:U+1}else while(q<Q&&/[A-Za-z0-9_:?]/.test($[q]??""))q++;X.push(Y,K,"literal"),X.push(K,q,"variable"),K=q,Y=q;continue}K++}return X.push(Y,Q,"literal"),X.parts}function Lq($,J){return{code:"depth-limit",message:`command structure exceeds parser limit ${J}`,span:{start:$,end:$}}}function rF($){let J=[],Q=[],X=0,Y=0,W=!1,K=()=>{if(Q.length>0)J.push(Q);Q=[]};while(X<$.length&&X<131072&&Y<16384){let B=$[X];if(B==="\r"||B===`
46
+ `?L+2:L+1;K.push(oJ($,L,F)),L=F;continue}L++;continue}let M=eJ($,L);if(M){H(),K.push(oJ($,L,L+M.length)),L+=M.length;continue}if(Z==="{"){if(H(),Y>=X.maxDepth)return B.push(Lq(L,X.maxDepth)),{nodes:K,issues:B,next:Q,closed:!1,words:U,limited:!0};let F=tJ($,L+1,Q,X,Y+1,!0),b=F.closed?F.next-1:F.next,I=I1({kind:"program",dialect:"powershell",source:$.slice(L+1,b),span:{start:L+1,end:b},status:F.limited?"limited":F.issues.length>0?"partial":"complete",issues:F.issues,nodes:F.nodes});if(K.push(Object.freeze({kind:"group",style:"brace",span:Object.freeze({start:L,end:F.next}),body:I})),B.push(...F.issues),!F.closed)B.push({code:"unclosed-script-block",message:"PowerShell script block is not closed",span:{start:L,end:F.next}});U+=F.words,G||=F.limited,L=F.next;continue}if(Z==="}"){H(),K.push(oJ($,L,L+1)),L++;continue}if(Z===">"||Z==="<"){q.start=q.start===-1?L:q.start;let F=$[L+1]===Z?L+2:L+1,b=F;while(/[ \t]/.test($[b]??""))b++;let I=b<Q?nJ($,b,Q,X,Y):void 0,A=I?.next??F;if(q.redirections.push(Object.freeze({kind:"redirection",operator:$.slice(L,F),span:Object.freeze({start:L,end:A}),...I?{target:I.word}:{}})),I)B.push(...I.issues),q.nested.push(...I.nested),U+=I.words,G||=I.limited;q.end=A,L=A;continue}if(Z===","){q.start=q.start===-1?L:q.start,q.words.push(uJ({text:",",raw:",",span:{start:L,end:L+1},provenance:"literal",quoted:!1})),q.end=++L;continue}let V=nJ($,L,Q,X,Y);if(q.start=q.start===-1?L:q.start,q.end=V.next,q.words.push(V.word),B.push(...V.issues),q.nested.push(...V.nested),U+=1+V.words,G||=V.limited,U>X.maxWords)return B.push({code:"word-limit",message:`command exceeds ${X.maxWords} words`,span:{start:L,end:V.next}}),H(),{nodes:K,issues:B,next:V.next,closed:!1,words:U,limited:!0};L=V.next>L?V.next:L+1}return H(),{nodes:K,issues:B,next:L,closed:!W,words:U,limited:G}}function nJ($,J,Q,X,Y){let W="",K="literal",B=!1,q=[],U=[],G=0,H=!1,L=(O)=>{let M=rF($,O,Q,X,Y);return W+=$.slice(O,M.next),U.push(M.program),q.push(...M.program.issues),G+=sJ(M.program),H||=M.program.status==="limited",K="command-substitution",M.next},Z=J;while(Z<Q){let O=$[Z];if(!O||/\s/.test(O)||eJ($,Z)||O===">"||O==="<"||O==="#")break;if(O===",")break;if(O==="`"){let M=$[Z+1];if(!M){q.push({code:"trailing-escape",message:"PowerShell escape has no following character",span:{start:Z,end:Z+1}}),Z++;break}W+=M,Z+=2;continue}if($.startsWith("$(",Z)){Z=L(Z);continue}if(O==="'"){B=!0,Z++;let M=!1;while(Z<$.length){if($[Z]==="'"&&$[Z+1]==="'"){W+="'",Z+=2;continue}if($[Z]==="'"){M=!0,Z++;break}W+=$[Z]??"",Z++}if(!M)q.push({code:"unclosed-single-quote",message:"single-quoted word is not closed",span:{start:J,end:$.length}});continue}if(O==='"'){B=!0;let M=Z++,V=!1;while(Z<Q){let F=$[Z];if(F==="`"&&$[Z+1]){W+=$[Z+1],Z+=2;continue}if(F==='"'){V=!0,Z++;break}if($.startsWith("$(",Z)){Z=L(Z);continue}if(F==="$")K=$[Z+1]==="("?"command-substitution":"variable";W+=F??"",Z++}if(!V)q.push({code:"unclosed-double-quote",message:"double-quoted word is not closed",span:{start:M,end:$.length}});continue}if(O==="$")K=$[Z+1]==="("?"command-substitution":"variable";if(O==="@"&&Z===J)K="variable";W+=O,Z++}return{word:t2($,J,Z,W,K,B,K==="literal"?void 0:iF($,J,Z)),next:Z,issues:q,nested:U,words:G,limited:H}}function rF($,J,Q,X,Y){let W=Zq($,J+2,Q),K=W===-1?Q:W,B=W===-1?Q:W+1;if(Y>=X.maxDepth)return{program:I1({kind:"program",dialect:"powershell",source:$.slice(J+2,K),span:{start:J+2,end:K},status:"limited",issues:[Lq(J,X.maxDepth)],nodes:[]}),next:B};let q=tJ($,J+2,K,X,Y+1),U=W===-1?[{code:"unclosed-command-subexpression",message:"PowerShell command subexpression is not closed",span:{start:J,end:B}}]:[];return{program:I1({kind:"program",dialect:"powershell",source:$.slice(J+2,K),span:{start:J+2,end:K},status:q.limited?"limited":q.issues.length+U.length>0?"partial":"complete",issues:[...q.issues,...U],nodes:q.nodes}),next:B}}function Zq($,J,Q){let X=1,Y=!1,W=!1;for(let K=J;K<Q;K++){let B=$[K];if(B==="`"){K++;continue}if(!W&&B==="'"){if(Y&&$[K+1]==="'"){K++;continue}Y=!Y;continue}if(!Y&&B==='"'){W=!W;continue}if(Y)continue;if($.startsWith("$(",K)){X++,K++;continue}if(!W&&B==="(")X++;if(B!==")")continue;if(X--,X===0)return K}return-1}function sJ($){let J=0;for(let Q of $.nodes){if(Q.kind==="group")J+=sJ(Q.body);if(Q.kind==="command"){J+=Q.words.length;for(let X of Q.nested)J+=sJ(X)}}return J}function iF($,J,Q){let X=Z9($),Y=J,W=!1,K=J;while(K<Q){let B=$[K];if(B==="`"){K+=2;continue}if(B==="'"){if(W&&$[K+1]==="'"){K+=2;continue}W=!W,K++;continue}if(W){K++;continue}if($.startsWith("$(",K)){let q=Zq($,K+2,Q),U=q===-1?Q:q+1;X.push(Y,K,"literal"),X.push(K,U,"command-substitution"),K=U,Y=U;continue}if(B==="$"||B==="@"&&K===J){let q=K+1;if($[q]==="{"){let U=$.indexOf("}",q+1);q=U===-1||U>=Q?Q:U+1}else while(q<Q&&/[A-Za-z0-9_:?]/.test($[q]??""))q++;X.push(Y,K,"literal"),X.push(K,q,"variable"),K=q,Y=q;continue}K++}return X.push(Y,Q,"literal"),X.parts}function Lq($,J){return{code:"depth-limit",message:`command structure exceeds parser limit ${J}`,span:{start:$,end:$}}}function oF($){let J=[],Q=[],X=0,Y=0,W=!1,K=()=>{if(Q.length>0)J.push(Q);Q=[]};while(X<$.length&&X<131072&&Y<16384){let B=$[X];if(B==="\r"||B===`
47
47
  `){K(),X+=B==="\r"&&$[X+1]===`
48
48
  `?2:1;continue}if(/\s/.test(B??"")){X++;continue}let q=Oq($,X,Math.min($.length,_9.maxInputLength),_9.maxDepth);if(q){W||=!!q.issue||q.limited,X=q.next;continue}let U=eJ($,X);if(U){K(),X+=U.length;continue}if(B==="{"||B==="}"){K(),X++;continue}let G=nJ($,X,Math.min($.length,_9.maxInputLength),_9,0);if(G.word.text)Q.push(G.word.text);for(let H of G.nested)J.push(...aJ(H));Y++,X=G.next>X?G.next:X+1}return K(),{commands:J,invalidComment:W}}function aJ($){return $.nodes.flatMap((J)=>{if(J.kind==="group")return aJ(J.body);if(J.kind!=="command")return[];return[J.words.map((Q)=>Q.text),...J.nested.flatMap(aJ)]})}function eJ($,J){for(let Q of["&&","||",";","|"])if($.startsWith(Q,J))return Q;return null}function Oq($,J,Q,X){if($[J]==="#"&&$[J+1]!==">"){let K=J+1;while(K<Q&&$[K]!=="\r"&&$[K]!==`
49
- `)K++;return{next:K,limited:!1}}if(!$.startsWith("<#",J))return null;let Y=1,W=J+2;while(W<Q){if($.startsWith("<#",W)){if(Y++,Y>X)return{next:Q,issue:{code:"comment-depth-limit",message:`PowerShell block comment exceeds nesting limit ${X}`,span:{start:J,end:W+2}},limited:!0};W+=2;continue}if($.startsWith("#>",W)){if(Y--,W+=2,Y===0)return{next:W,limited:!1};continue}W++}return{next:Q,issue:{code:"unclosed-block-comment",message:"PowerShell block comment is not closed",span:{start:J,end:Q}},limited:!1}}function iF($,J){if(J)return"limited";if($.some((Q)=>Q.code==="unclosed-block-comment"))return"invalid";return $.length>0?"partial":"complete"}function oJ($,J,Q){return Object.freeze({kind:"connector",operator:$.slice(J,Q),span:Object.freeze({start:J,end:Q})})}var F2=Object.freeze({maxInputLength:131072,maxWords:16384,maxDepth:64});function a1($,J="auto",Q=F2){if(J==="powershell"||J==="auto"&&Gq($.slice(0,Q.maxInputLength)))return Hq($,Q);return eB($,"posix",Q)}function $Q($,J){if($!=="powershell")return J[0]?.provenance==="command-substitution";let Q=J[0]?.text==="&"||J[0]?.text==="."?1:0,X=J[Q]?.provenance;return X!==void 0&&X!=="literal"}var oF=/^[A-Za-z_][A-Za-z0-9_]*=/;function D9($,J){return $?.provenance==="literal"&&!$.quoted&&$.raw===J&&$.text===J}function z9($){let J=D9($.words[0],"time")?1:0,Q=J===1&&D9($.words[J],"-p")?J+1:J,X=J===1&&D9($.words[Q],"--")?Q+1:Q,Y=D9($.words[X],"!")?X+1:X,W=$.words.slice(Y).find((K)=>!oF.test(K.text));return W?.provenance==="literal"?W.text:void 0}function G3($,J){if(J.escaped)return J.escaped=!1,!0;if($==="\\"&&!J.inSingle)return J.escaped=!0,!0;if($==="'"&&!J.inDouble)return J.inSingle=!J.inSingle,!0;if($==='"'&&!J.inSingle)return J.inDouble=!J.inDouble,!0;return!1}function $4($){let J={inSingle:!1,inDouble:!1,escaped:!1};for(let Q of nF($))G3(Q,J);return J.inSingle||J.inDouble}function nF($){let J="",Q={inSingle:!1,inDouble:!1,escaped:!1},X=!1,Y=!0;for(let W=0;W<$.length;W++){let K=$[W];if(!K)break;if(X){if(K===`
50
- `||K==="\r")J+=K,X=!1,Q.escaped=!1;continue}if(K==="#"&&!Q.inSingle&&!Q.inDouble&&Y){X=!0;continue}if(J+=K,!Q.inSingle&&!Q.inDouble&&!Q.escaped)Y=/[\s;&|()<>]/.test(K);G3(K,Q)}return J}var sF=new Set(["&&","||","|&","|","&",";"]),aF=new Set(["<<","<<<",">|"]),tF=/[*@#?$!_-]/,JQ=Object.freeze([]),eF=Object.freeze([]),$V=256;function _q($,J){let Q=J.status==="complete"?new Set(XQ(J)):new Set,X=[...Q].reduce((K,B)=>K.slice(0,B.start)+" ".repeat(B.end-B.start)+K.slice(B.end),$);if($4(X))return I9("unclosed-quote",X,JQ);let Y={invalid:!1,limited:!1,expansions:0,assignmentFallbacks:[]},W=H3(J,{source:X,suppressed:Q,flags:Y,depth:0,functions:new Map});if(Y.limited)return I9("structural-limit",X,JQ);if(Y.invalid)return I9("invalid",X,JQ);return I9("complete",X,W,Y.assignmentFallbacks)}function I9($,J,Q,X=eF){return Object.freeze({status:$,source:J,entries:Object.freeze(Q),assignmentFallbacks:Object.freeze(X)})}function H3($,J){return $.nodes.flatMap((Q,X)=>JV(Q,$,X,J)).sort((Q,X)=>Q.start-X.start).flatMap((Q)=>[...Q.entries])}function JV($,J,Q,X){if($.kind==="connector")return[{start:$.span.start,entries:[t1(KV($.operator))]}];if($.kind==="unknown")return[{start:$.span.start,entries:[t1($.source)]}];if($.kind==="function")return X.functions.set($.name,$.body),[];if($.kind==="group"){let W=$.style!=="subshell",K=X.source[$.span.end-1]===(W?"}":")"),B=W?X:{...X,functions:new Map(X.functions)};return[{start:$.span.start,entries:[W?j9("{"):t1("("),...H3($.body,B),...K?[W?j9("}"):t1(")")]:[]]}]}let Y=qV($,X.functions);if(Y){if(X.depth>=F2.maxDepth||++X.flags.expansions>$V)return X.flags.limited=!0,[];return[{start:$.span.start,entries:[...Mq($,X),j9(";"),...H3(Y,{...X,depth:X.depth+1}),j9(";")]},...Nq($,J,Q,X)]}return[{start:$.span.start,entries:Mq($,X)},...Nq($,J,Q,X)]}function Mq($,J){return[...$.words.map((Q)=>({start:Q.span.start,entries:zq(Q,$,J,!1)})),...$.redirections.map((Q)=>({start:Q.span.start,entries:QV(Q,$,J)}))].sort((Q,X)=>Q.start-X.start).flatMap((Q)=>Q.entries)}function QV($,J,Q){let X=$.operator==="<<-"?"<<":$.operator,Y=$.target?zq($.target,J,Q,!0):[],W=Y[0],K=W?.kind==="word"?W.text:void 0;return[...$.fd===void 0?[]:[YQ(String($.fd))],Object.freeze({kind:"redirection",operator:X,role:BV(X),targetOrder:aF.has(X)?"legacy-segment":"immediate",...K===void 0?{}:{target:K}}),...K===void 0?Y:Y.slice(1)]}function Nq($,J,Q,X){let Y=$.redirections.filter((W)=>W.operator==="<<"||W.operator==="<<-");return[...Y.flatMap((W)=>{let K=W.heredoc;if(!K)return[];let B=[YQ(K.delimiter),.../[\r\n]/.test(X.source[K.terminatorSpan.end]??"")?[t1(";")]:[]];if(X.suppressed.has(K.bodySpan))return[{start:K.bodySpan.start,entries:B}];return[{start:K.bodySpan.start,entries:[...Dq(X.source.slice(K.bodySpan.start,K.bodySpan.end),X),...B]}]}),...Y.some((W)=>!W.heredoc&&W.target)?XV(J,Q,X):[]]}function XV($,J,Q){let X=$.nodes.slice(J+1).find((Y)=>Y.kind==="connector");if(!X||X.span.end>=$.span.end)return[];return[{start:X.span.end,entries:Dq(Q.source.slice(X.span.end,$.span.end),Q)}]}function Dq($,J){if(J.depth>=F2.maxDepth)return J.flags.limited=!0,[];let Q=a1($,"posix");if(Q.status==="limited")return J.flags.limited=!0,[];let X={invalid:!1,limited:!1,expansions:J.flags.expansions,assignmentFallbacks:J.flags.assignmentFallbacks},Y=H3(Q,{source:$,suppressed:new Set,flags:X,depth:J.depth+1,functions:new Map});return J.flags.limited||=X.limited,J.flags.expansions=X.expansions,Y}function zq($,J,Q,X){let Y=[],W={single:!1,double:!1},K="",B=!1,q=()=>{if(B&&!X)Y.push(t1("glob"));else if(K!==""||$.quoted&&Y.length===0)Y.push(YQ(K));K="",B=!1};for(let U of $.parts){if(U.provenance!=="command-substitution"&&U.provenance!=="arithmetic"){for(let Z of QQ(U.raw,W,Q.flags)){if(typeof Z==="string"){q(),Y.push(t1(Z));continue}K+=Z.text,B||=Z.glob}continue}if(W.double){let Z=Q.source.slice(U.span.start,U.span.end);K+=QQ(Z,{single:!1,double:!0},Q.flags).map((O)=>typeof O==="string"?O:O.text).join("");continue}let G=J.nested.find((Z)=>Z.span.start>=U.span.start&&Z.span.end<=U.span.end),H=G?H3(G,Q):[];if(U.raw.startsWith("`")){K+="${}",q(),Y.push(...H);continue}if(U.raw.startsWith("<(")||U.raw.startsWith(">(")){q(),Y.push(U.raw.startsWith("<(")?t1("<("):Object.freeze({kind:"redirection",operator:">",role:"file-write",targetOrder:"immediate"}),...H,...U.raw.endsWith(")")?[t1(")")]:[]);continue}let L=U.raw.startsWith("$((")?2:1;K+="${}",q(),Y.push(...Array.from({length:L},()=>t1("(")),...H,...U.raw.endsWith(")".repeat(L))?Array.from({length:L},()=>t1(")")):[])}return q(),Y}function QQ($,J,Q){let X=[],Y="",W=!1,K=0;while(K<$.length){let B=$[K]??"";if(!J.single&&!J.double&&(B==="("||B===")")){X.push({text:Y,glob:W},B),Y="",W=!1,K++;continue}if(J.single){if(B==="'")J.single=!1;else Y+=B;K++;continue}if(J.double){if(B==='"'){J.double=!1,K++;continue}if(B==="\\"){let q=$[K+1]??"";Y+=['"',"\\","$"].includes(q)?q:`\\${q}`,K+=2;continue}if(B==="$"){let q=Fq($,K,J,Q);Y+=q.text,K=q.next;continue}Y+=B,K++;continue}if(B==="'"||B==='"'){J.single=B==="'",J.double=B==='"',K++;continue}if(B==="\\"){let q=$[K+1]??"";W||=q==="*"||q==="?",Y+=q,K+=2;continue}if(B==="$"){let q=Fq($,K,J,Q);Y+=q.text,K=q.next;continue}W||=B==="*"||B==="?",Y+=B,K++}return[...X,{text:Y,glob:W}]}function Fq($,J,Q,X){let Y=$[J+1];if(Y==="{"){let K=WV($,J+2);if(K===-1)return X.invalid=!0,{text:"",next:$.length};let B=$.slice(J,K+1);return YV(B,Q,X),{text:B,next:K+1}}if(Y!==void 0&&tF.test(Y))return{text:`\${${Y}}`,next:J+2};let W=/^\w*/.exec($.slice(J+1))?.[0]??"";return{text:`\${${W}}`,next:J+1+W.length}}function YV($,J,Q){let X=$.slice(2,-1),Y=/^[A-Za-z_][A-Za-z0-9_]*/.exec(X)?.[0];if(!Y)return;let W=X.slice(Y.length),K=[":=","="].find((q)=>W.startsWith(q));if(!K)return;let B=QQ(W.slice(K.length),{...J},Q);Q.assignmentFallbacks.push(...B.flatMap((q)=>typeof q==="string"||!q.text?[]:[q.text]))}function WV($,J){let Q=1,X=J;while(Q>0&&X<$.length){if($[X]==="{"&&$[X-1]==="$")Q++;else if($[X]==="}")Q--;X++}return Q===0?X-1:-1}function KV($){return/^[\r\n]+$/.test($)?";":$}function t1($){return Object.freeze({kind:"operator",operator:$,boundary:sF.has($)})}function j9($){return Object.freeze({kind:"operator",operator:$,boundary:!0})}function YQ($){return Object.freeze({kind:"word",text:$})}function BV($){if($==="<<"||$==="<<<")return"here-data";if($==="<"||$==="<&")return"file-read";return"file-write"}function XQ($){return $.nodes.flatMap((J,Q)=>{if(J.kind==="group"||J.kind==="function")return XQ(J.body);if(J.kind!=="command")return[];let X=J.nested.flatMap((K)=>XQ(K)),Y=$.nodes[Q+1];if(Y?.kind==="connector"&&(Y.operator==="|"||Y.operator==="|&")||!GV(J))return X;return[...X,...J.redirections.flatMap((K)=>K.heredoc?.quotedDelimiter?[K.heredoc.bodySpan]:[])]})}function qV($,J){let Q=z9($);return Q===void 0?void 0:J.get(Q)}function o0($,J){return $!==void 0&&$.provenance==="literal"&&!$.quoted&&$.raw===$.text&&$.text===J}function UV($){if(o0($.words[0],"git"))return o0($.words[1],"commit");if(!o0($.words[0],"gh")||!o0($.words[2],"create"))return!1;return o0($.words[1],"pr")||o0($.words[1],"issue")}function GV($){return(o0($.words[0],"cat")||o0($.words[0],"tee")||UV($))&&!$.words.some(Vq)&&!$.redirections.some((Q)=>Vq(Q.target))}function Vq($){return $?.parts.some((J)=>J.provenance==="command-substitution"&&J.raw.startsWith(">("))??!1}import{types as HV}from"util";var ZV=new Set(["applypatch","patch"]),LV=new Set(["create","edit","listdir","listpermissions","ls","multiedit","multireplacefilecontent","notebookedit","read","readfile","readurlcontent","replacefilecontent","searchweb","strreplaceeditor","view","viewfile","write","writefile","writetofile"]),OV=new Set(["grep","grepsearch","rg"]),MV=new Set(["findbyname","glob"]),NV=new Set(["findbyname","glob","grep","grepsearch","listdir","listpermissions","ls","read","readfile","readurlcontent","searchweb","view","viewfile"]),FV=new Set(["command","diff","input","patch","patchtext"]),Iq=new TextEncoder,VV=new TextDecoder,_V=/\s/,DV=64;class T0 extends Error{name="ToolInputLimitError";constructor(){super("tool input traversal limit exceeded")}}var Z3=Object.freeze({maxDepth:64,maxNodes:1e4,maxKeys:1e4,maxStringBytes:1048576,maxAggregateStringBytes:4194304});function Aq($){return $.replace(/[-_\s]/g,"").toLowerCase()}function b9($){return NV.has(Aq($))}function qQ($){let J=Aq($);if(ZV.has(J))return"patch";if(OV.has(J))return"grep";if(MV.has(J))return"glob";if(LV.has(J))return"path";return"unknown"}function J4($){if(!$||typeof $!=="object")return;wq($);let J=Object.getOwnPropertyDescriptor($,"command");if(!J){if("command"in $)U0();return}if(J.get||J.set)U0();let Q=J.value;return typeof Q==="string"&&Q!==""?Q:void 0}function UQ($,J){return Eq($,J,{nodes:0,keys:0,stringBytes:0,ancestors:new Set},1)}function Eq($,J,Q,X){let Y=Tq($,Q,X);if(!Y)return[];let W=Y.entries.flatMap(([K,B])=>{let q=Eq(B,J,Q,X+1);return typeof B==="string"&&J.has(Sq(K))?[B]:q});return Q.ancestors.delete(Y.object),W}function Sq($){return $.replace(/-/g,"_").toLowerCase()}function GQ($){return Cq($,!0,{nodes:0,keys:0,stringBytes:0,ancestors:new Set},1).flatMap(IV)}function Cq($,J,Q,X){let Y=Tq($,Q,X);if(typeof $==="string")return J?[$]:[];if(!Y)return[];let W=Y.entries.flatMap(([K,B])=>Cq(B,Y.array?J:FV.has(Sq(K)),Q,X+1));return Q.ancestors.delete(Y.object),W}function zV($,J,Q){if(J.nodes++,$!==null&&typeof $==="object"&&Q>Z3.maxDepth||J.nodes>Z3.maxNodes)U0();if(typeof $!=="string")return;let X=Buffer.byteLength($);if(J.stringBytes+=X,X>Z3.maxStringBytes||J.stringBytes>Z3.maxAggregateStringBytes)U0()}function Tq($,J,Q){if(zV($,J,Q),!$||typeof $!=="object")return null;let X=wq($);if(J.ancestors.has($))U0();let Y=Reflect.ownKeys($);if(J.keys+=Y.length,J.keys>Z3.maxKeys)U0();let W=Y.flatMap((K)=>{let B=Object.getOwnPropertyDescriptor($,K);if(!B||B.get||B.set)U0();return typeof K==="string"&&B.enumerable?[[K,B.value]]:[]});return J.ancestors.add($),{object:$,array:X,entries:W}}function wq($){if(HV.isProxy($))U0();let J=Array.isArray($),Q=Object.getPrototypeOf($);if(J&&Q!==Array.prototype||!J&&Q!==Object.prototype&&Q!==null)U0();return J}function U0(){throw new T0}function IV($){let J=[],Q=$.split(/\r?\n/),X=!1,Y=!1,W=null,K=null,B=()=>{Y=!1,W=null,K=null};for(let q=0;q<Q.length;q++){let U=Q[q]??"";if(U==="*** Begin Patch"){X=!0,B();continue}if(U==="*** End Patch"){X=!1,B();continue}if(U.startsWith("@@")){let G=jV(U);if(Y=!0,W=G?.oldLines??null,K=G?.newLines??null,W===0&&K===0)B();continue}if(Y&&W!==null&&K!==null){let G=U.startsWith(" ")||U.startsWith("-")?1:0,H=U.startsWith(" ")||U.startsWith("+")?1:0;if(W=Math.max(0,W-G),K=Math.max(0,K-H),W===0&&K===0)B();continue}if(U.startsWith("*** ")){B(),J.push(...WQ(U));continue}if(Y)continue;if(U.startsWith("diff --git ")){J.push(...WQ(U));continue}if(U.startsWith("--- ")){let G=Q[q+1]??"";if(!G.startsWith("+++ "))continue;J.push(...BQ(R9(U.slice(4),!0),R9(G.slice(4),!0))),q++;continue}if(!X)J.push(...WQ(U))}return J}function jV($){let J=/^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec($);if(!J)return null;return{oldLines:Number(J[1]??1),newLines:Number(J[2]??1)}}function WQ($){let J=/^\*\*\* (?:Add|Update|Delete) File: (.+)$/.exec($);if(J?.[1])return Pq(J[1]);let Q=/^\*\*\* Move to: (.+)$/.exec($);if(Q?.[1])return Pq(Q[1]);if($.startsWith("diff --git "))return RV($.slice(11));let X=/^--- (.+)$/.exec($);if(X?.[1])return bq(X[1]);let Y=/^\+\+\+ (.+)$/.exec($);if(Y?.[1])return bq(Y[1]);let W=/^(?:rename|copy) (?:from|to) (.+)$/.exec($);if(W?.[1])return TV(W[1]);return[]}function RV($){let J=bV($);if(J.length===2&&J[0]&&J[1])return BQ(J[0],J[1]);let Q=PV($);return Q?BQ($.slice(Q.oldStart,Q.oldEnd),$.slice(Q.newStart,Q.newEnd)):[]}function bV($){let J=[],Q=0;while(Q<$.length&&J.length<2){while(V2($[Q]))Q++;if(Q>=$.length)break;let X=$[Q]==='"'||$[Q]==="'"?$[Q]:void 0;if(!X){let W=Q;while(Q<$.length&&!V2($[Q]))Q++;J.push($.slice(W,Q));continue}let Y=vq($,Q,X);if(!Y)return[];J.push(Y.value),Q=Y.end}while(V2($[Q]))Q++;return Q===$.length?J:[]}function PV($){let J=0;while(J<$.length&&V2($[J]))J++;let Q=$.length;while(Q>J&&V2($[Q-1]))Q--;let X=0,Y=J;while(Y<Q){if(!V2($[Y])){Y++;continue}let W=Y;while(Y<Q&&V2($[Y]))Y++;if(W===J||Y===Q)continue;if(X++,X>DV)U0();if(AV($,J,W,Y,Q))return{oldStart:J,oldEnd:W,newStart:Y,newEnd:Q}}return null}function AV($,J,Q,X,Y){if(KQ($,J,Q,X,Y))return!0;let W=jq($,"/",J,Q),K=jq($,"/",X,Y);if(W<=J||K<=X)return!1;if(KQ($,J,W,X,K))return!1;return KQ($,W+1,Q,K+1,Y)}function KQ($,J,Q,X,Y){if(Q-J!==Y-X)return!1;for(let W=0;W<Q-J;W++)if($[J+W]!==$[X+W])return!1;return!0}function jq($,J,Q,X){for(let Y=Q;Y<X;Y++)if($[Y]===J)return Y;return-1}function V2($){return $!==void 0&&_V.test($)}function vq($,J,Q){let X=[],Y=J+1;while(Y<$.length){let W=$[Y]??"";if(W===Q)return{value:VV.decode(Uint8Array.from(X)),end:Y+1};if(W!=="\\"||Q==="'"){X.push(...Iq.encode(W)),Y++;continue}let K=$.slice(Y+1),B=/^[0-7]{1,3}/.exec(K)?.[0];if(B){X.push(Number.parseInt(B,8)),Y+=B.length+1;continue}X.push(...Iq.encode(EV(K[0]??""))),Y+=2}return null}function EV($){return{a:"\x07",b:"\b",f:"\f",n:`
51
- `,r:"\r",t:"\t",v:"\v"}[$]??$}function SV($){return L3(wV($))}function BQ($,J){if($==="/dev/null")return Rq(J);if(J==="/dev/null")return Rq($);if($.startsWith("a/")&&J.startsWith("b/"))return[$.slice(2),J.slice(2)].flatMap(L3);let Q=CV($,J)??($===J?fq($):null);return[$,J,...Q?[Q]:[]].flatMap(L3)}function Rq($){let J=fq($);return[$,...J?[J]:[]].flatMap(L3)}function fq($){let J=$.indexOf("/");return J>0&&J<$.length-1?$.slice(J+1):null}function CV($,J){let Q=$.indexOf("/"),X=J.indexOf("/");if(Q<1||X<1)return null;if($.slice(0,Q)===J.slice(0,X))return null;let Y=$.slice(Q+1);return Y===J.slice(X+1)?Y:null}function bq($){return SV(R9($,!0))}function TV($){return L3(R9($,!1))}function R9($,J){let Q=$.trim(),X=Q[0]==='"'||Q[0]==="'"?Q[0]:void 0;if(X){let Y=vq(Q,0,X);if(Y&&(J||Q.slice(Y.end).trim()===""))return Y.value}return J?Q.split("\t",1)[0]?.trim()??"":Q}function wV($){return $.startsWith("a/")||$.startsWith("b/")?$.slice(2):$}function L3($){return $===""||$==="/dev/null"?[]:[$]}function Pq($){let J=$.split("\t",1)[0]?.trim().replace(/^['"]|['"]$/g,"")??"";return J===""||J==="/dev/null"?[]:[J]}var kq=new Set(["absolutepath","directorypath","directory_path","file","file_path","filepath","include","notebook_path","path","searchdirectory","search_directory","searchpath","targetfile","target_file"]),gq=new Set([...kq,"glob"]),fV=new Set([...gq,"pattern"]),hV=Object.freeze([]),yq={parseCommand:a1,projectShellSyntax:_q};class n0 extends Error{name="StructuralShellSyntaxLimitError";constructor(){super("Structural command analysis limit exceeded.")}}function P9($,J={}){let Q=kV({...yq,...J}),X=J4($.input),Y=[];if(($.route.kind==="command"||$.route.kind==="unknown")&&X)Y.push({usage:"input-candidate",source:X});if($.route.kind==="command"&&"command"in $&&$.command)Y.push({usage:"declared-command",source:$.command});let W=Y.reduce((K,B)=>{let q=K.findIndex((H)=>H.source===B.source);if(q!==-1){let H=K[q];if(!H)return K;return K[q]=hq({...H,usages:[...H.usages,B.usage]}),K}let U=$.route.kind==="command"?$.route.shell:"posix",G=Q.getCommandProgram(B.source,U);return K.push(hq({usages:[B.usage],source:B.source,program:G,views:HQ(G),uncertainties:G.issues,shell:Q.getShellSyntax(B.source,G)})),K},[]);return Object.freeze({invocation:Object.freeze({toolName:$.toolName,route:Object.freeze({...$.route}),context:Object.freeze({...$.context,...$.context.policyConfigCwds?{policyConfigCwds:Object.freeze([...$.context.policyConfigCwds])}:{}})}),commands:Object.freeze(W),paths:Object.freeze(gV($)),store:Q})}function w1($,J){return $.commands.find((Q)=>Q.usages.includes(J))}function G0($){if(!$.includes("$"))return $;return k6($,A0())}function kV($={}){let J={...yq,...$},Q=new Map,X=new Map,Y=new WeakMap,W=(B,q)=>{let U=`${q}\x00${B}`,G=X.get(U);if(G)return G;let H=J.parseCommand(B,q);return X.set(U,H),H};return Object.freeze({getShellSyntax:(B,q)=>{if(q&&q.source!==B)throw TypeError("Shell syntax source does not match command program source.");let U=q??W(B,"posix");if(U.status==="limited"){let L=Y.get(U);if(L)return L;let Z=Object.freeze({status:"structural-limit",source:B,entries:hV,assignmentFallbacks:Object.freeze([])});return Y.set(U,Z),Z}let G=Q.get(B);if(G)return G;let H=J.projectShellSyntax(B,U);return Q.set(B,H),H},getCommandProgram:W})}function hq($){return Object.freeze({...$,usages:Object.freeze([...$.usages]),views:Object.freeze([...$.views]),uncertainties:Object.freeze([...$.uncertainties])})}function HQ($){return Object.freeze($.nodes.flatMap((J)=>{if(J.kind==="group")return[...HQ(J.body)];if(J.kind!=="command")return[];return[...J.nested.flatMap((Q)=>[...HQ(Q)]),J]}))}function gV($){let J=$.route.kind==="grep"?gq:$.route.kind==="glob"?fV:kq,Q=$.route.kind==="grep"||$.route.kind==="glob"?"read":$.route.kind==="patch"?"write":"unknown";return[...UQ($.input,J).map((X)=>Object.freeze({raw:X,role:"tool-path",access:Q})),...$.route.kind==="patch"?GQ($.input).map((X)=>Object.freeze({raw:X,role:"patch-target",access:"write"})):[]]}function v1($,J){let Q=new Set,X=!1;for(let Y of $){if(Y==="--"){X=!0;continue}if(X)continue;if(Y.startsWith("-")&&!Y.startsWith("--")&&Y.length>1)for(let W=1;W<Y.length;W++){let K=Y[W];if(!K||!/[a-zA-Z]/.test(K))break;let B=`-${K}`;if(Q.add(B),J?.shortOptsWithValue?.has(B))break}}return Q}var yV=new Map([["bash",new Set(["O","o"])],["dash",new Set(["o"])],["ksh",new Set(["o"])],["sh",new Set(["o"])],["zsh",new Set(["o"])]]),xV=new Map([["zsh",new Set(["o"])]]),uV=new Map([["bash",new Set(["--init-file","--rcfile"])]]);function xq($,J){for(let Q=0;Q<J.length;Q++){let X=J[Q];if(X===void 0||X==="--"||X==="-"||X[0]!=="-"&&X[0]!=="+")return null;if(X.startsWith("--")){let K=uV.get($);if(lV(X,K))continue;if(!K?.has(X))continue;if(J[Q+1]===void 0)return null;Q++;continue}let Y=mV($,X);if(Y.commandSelected)return J[Q+Y.followingValues+1]??null;let W=J[Q+1];if($==="ksh"&&(X==="-o"||X==="+o")&&W!==void 0&&W[0]!=="-"&&W[0]!=="+")Q++;Q+=Y.followingValues}return null}function mV($,J){let Q=yV.get($),X=xV.get($),Y=!1,W=0;for(let K=1;K<J.length;K++){let B=J[K];if(B===void 0)break;if(J[0]==="-"&&B==="c")Y=!0;if($==="ksh"&&B==="o"){if(K+1<J.length){let q=J.slice(K+1);if(!Y&&J[0]==="-"&&q==="c")continue;if(!Y&&J[0]==="-"&&q[0]==="-"&&q.endsWith("c"))Y=!0;break}if(Y)W++;continue}if(!Q?.has(B))continue;if(X?.has(B)&&K+1<J.length)break;W++}return{commandSelected:Y,followingValues:W}}function lV($,J){return J!==void 0&&[...J].some((Q)=>$.startsWith(`${Q}=`))}var dV=new Set(["-S","--suffix"]);function A9($,J,Q,X){if($.status==="structural-limit")throw new n0;if($.status!=="complete")return X.findMalformedTarget($.source);let Y={cwd:J,variables:new Map},W=[];for(let K of $.entries){if(K.kind==="operator"){if(!K.boundary)continue;let B=X.findSegmentTarget(W,Y);if(B)return B;Y=rV(W,Y,Q,X.normalizeCwd),W=[];continue}if(K.kind==="redirection"){if(K.role==="file-write"&&K.target&&X.isRedirectionTarget(f1(K.target,Y.variables),Y))return K.target;continue}W.push(K.text)}return X.findSegmentTarget(W,Y)}function f1($,J){return $.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)(:?[-+])([^}]*)\}/g,(Q,X,Y,W)=>{let K=J.get(X);if(K===void 0)return Q;let B=Y.startsWith(":")?K!=="":!0;if(Y.endsWith("-"))return B?K:f1(W,J);return B?f1(W,J):""}).replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(Q,X)=>J.get(X)??Q).replace(/\$([A-Za-z_][A-Za-z0-9_]*)/g,(Q,X)=>J.get(X)??Q)}function O3($){return $.length>0&&$.every((J)=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(J))}function M1($,J,Q){let X=Q.environment.home,Y=k6($.trim(),Q.environment).replace(/\\/g,"/");if(!Y)return"";let W=Y==="~"?X:Y.startsWith("~/")?uq(X,Y.slice(2)):Y;return J1(cV(pV(W)?W:uq(J,W)),Q.environment.paths,Q).replace(/\\/g,"/")}function E9($){let J=[],Q=null,X=!1;for(let Y=0;Y<$.length;Y++){let W=$[Y];if(W===void 0)break;if(!X&&W==="--"){X=!0;continue}if(!X&&(W==="-t"||W==="--target-directory")){Q=$[++Y]??null;continue}if(!X&&W.startsWith("--target-directory=")){Q=W.slice(19);continue}if(!X&&W.startsWith("-t")&&W.length>2){Q=W.slice(2);continue}if(!X&&dV.has(W)){Y++;continue}if(!X&&(W.startsWith("--suffix=")||W.startsWith("--backup=")))continue;if(!X&&W.startsWith("-"))continue;J.push(W)}return Q?{sources:J,destination:Q}:{sources:J.slice(0,-1),destination:J.at(-1)??null}}function rV($,J,Q,X){let Y=O3($)?new Map([...J.variables,...iV($,J.variables)]):J.variables,W=l1([...$],Q.environment),K=l(W[0]??"").toLowerCase()==="cd"?W[1]:void 0;return{cwd:!K||K==="-"?J.cwd:X(f1(K,Y),J.cwd,Q),variables:Y}}function iV($,J){return $.flatMap((Q)=>{let X=/^([A-Za-z_][A-Za-z0-9_]*)(.*)$/.exec(Q),Y=X?.[2]?.startsWith("=")?X[2].slice(1):void 0;return X?.[1]!==void 0&&Y!==void 0?[[X[1],f1(Y,J)]]:[]})}var p1="Git metadata and hooks are protected. Ask the user before modifying them.";function cq($,J=LQ($.invocation.context.executionCwd)){let Q=H2(A0()),X=$.invocation.context.executionCwd;if(!J)return null;if($.invocation.route.kind==="patch"||$.invocation.route.kind==="path"||$.invocation.route.kind==="unknown"){if(b9($.invocation.toolName))return null;let K=$.paths.find((B)=>eV(B.raw,X,J,Q))?.raw;return K?{target:K}:null}if($.invocation.route.kind!=="command")return null;let Y=w1($,"input-candidate");if(!Y)return null;let W=A9(Y.shell,X,Q,{findSegmentTarget:(K,B)=>J_(K,B,J,Q),isRedirectionTarget:(K,B)=>$_(K,B.cwd,J,Q),findMalformedTarget:()=>null,normalizeCwd:M1});return W?{target:W}:null}function LQ($,J=H2(A0())){if(typeof $!=="string"||!$)return null;let Q=$3(M1($,$,J));if(!Q)return null;try{let X=M1(Q,$,J),Y=oV(Q),W=Y.isFile()?X:null,K=Y.isFile()?wJ(Q):null,B=(Y.isDirectory()?[X]:[K?.gitDir,K?.commonDir]).flatMap((U)=>U?[H0(M1(U,$,J))]:[]),q=[...new Set(Y.isDirectory()?[H0(Q.replace(/\\/g,"/")),...B]:B)];return Object.freeze({entry:H0(X),markerFile:W?H0(W):null,directories:Object.freeze(q),hooksDirectories:Object.freeze([...new Set(q.flatMap((U)=>{let G=H0(nV(U,"hooks"));return[G,H0(M1(G,$,J))]}))])})}catch{return null}}function _2($,J,Q,X,Y,W=!1){if(!Q)return!1;let K=H0(M1($,J,Y)),B=K.replace(/(\/\.?\*+)+$/,"");if(B!==K&&B!==""){if(ZQ(B,Q))return!0;let q=W||K.slice(B.length).includes("/."),U=(G)=>q?S9(G,B):sV(G,B);if(Q.markerFile&&U(Q.markerFile))return!0;return X&&mq(Q).some(U)}if(ZQ(K,Q))return!0;return X&&mq(Q).some((q)=>S9(q,K))}function sV($,J){let Q=pq(J,$);if(Q===""||Q.startsWith("..")||lq(Q))return!1;return!Q.split(/[\\/]/)[0]?.startsWith(".")}function aV($,J,Q,X){return _2($,J,Q,!0,X)}function tV($,J,Q,X){if(!Q)return!1;return ZQ(H0(M1($,J,X)),Q)}function eV($,J,Q,X){if(!Q)return!1;return dq($,J,Q,X,Q.entry)}function $_($,J,Q,X){if(!Q)return!1;return dq($,J,Q,X,Q.markerFile)}function dq($,J,Q,X,Y){let W=H0(M1($,J,X));return W===Y||iq(W,Q)}function rq($,J,Q,X){if(!Q)return!1;return Q.hooksDirectories.some((Y)=>$.some((W)=>S9(Y,H0(M1(W,J,X)))))}function ZQ($,J){return $===J.entry||J.directories.includes($)||iq($,J)}function iq($,J){return J.hooksDirectories.some((Q)=>S9($,Q))}function mq($){return[$.entry,...$.directories,...$.hooksDirectories]}function S9($,J){let Q=pq(J,$);return Q===""||!/^\.\.(?:[\\/]|$)/.test(Q)&&!lq(Q)}function H0($){return process.platform==="win32"?$.toLowerCase():$}function J_($,J,Q,X){if(O3($))return null;let Y=l1([...$],X.environment);if(l(Y[0]??"").toLowerCase()!=="mv")return null;let W=E9(Y.slice(1)),K=W.sources.find((B)=>aV(f1(B,J.variables),J.cwd,Q,X));if(K)return K;return W.destination&&tV(f1(W.destination,J.variables),J.cwd,Q,X)?W.destination:null}import{isAbsolute as sq,normalize as Q_,sep as OQ}from"path";var oq=process.platform==="win32";function M3($,J){if($==="~")return J;if($.startsWith("~/"))return`${J}${$.slice(1)}`;return $}function C9($,J){if(typeof $!=="string"||$.trim()==="")return"must be a non-empty path string";let Q=M3($.trim(),J);if(!sq(Q))return"must be an absolute path or start with ~/";return w9(Q,J)}function T9($,J){if(typeof $!=="string"||$.trim()==="")return"must be a non-empty path string";let Q=M3($.trim().replace(/^\$(?:\{HOME\}|HOME(?=\/|$))/,"~"),J);if(!sq(Q))return null;if(w9(Q,J)===null)return null;return"cannot be the home directory or a path above it (this would block every command the agent runs)"}function w9($,J){let Q=nq($),X=nq(J);if(Q===X)return"cannot be the home directory";let Y=Q.endsWith(OQ)?Q:`${Q}${OQ}`;if(X.startsWith(Y))return"cannot contain the home directory";return null}function nq($){let J=Q_($);if(oq)J=J.replace(/\//g,"\\").toLowerCase();if(J.length>(oq?3:1)&&J.endsWith(OQ))J=J.slice(0,-1);return J}var W_=process.platform==="win32",aq=64,K_=16384;function N3($){let J=Yq($,aq,aq,K_);return{expandedTargets:J&&"words"in J?J.words:void 0,unsafeBraceExpansion:J!==void 0&&"limited"in J,targetIsLiteral:J===void 0&&$.provenance==="literal"&&($.quoted||$.raw!==$.text),tmpdirWordSplittingProtected:B_($)}}function B_($){let J=$.parts.filter((Q)=>Q.provenance==="variable"&&/\$(?:TMPDIR(?![A-Za-z0-9_])|\{TMPDIR\})/.test(Q.raw));return J.length>0&&J.every((Q)=>q_($.raw,Q.span.start-$.span.start))}function q_($,J){let Q=null,X=!1;for(let Y=0;Y<J;Y++){let W=$[Y];if(X){X=!1;continue}if(W==="\\"&&Q!=="'"){X=!0;continue}if(Q===W){Q=null;continue}if(Q===null&&(W==="'"||W==='"'))Q=W}return Q==='"'}function D2($){let J=$.environment.home,Q=$.environment.paths,X=H2($.environment);return{anchoredCwd:$.originalCwd??$.cwd??null,resolvedCwd:$.cwd??null,strict:$.strict??!1,paranoid:$.paranoid??!1,trustTmpdirVar:$.allowTmpdirVar??!0,posixShell:$.posixShell??!1,tmpdirWordSplittingUnsafe:$.tmpdirWordSplittingUnsafe??!1,trustedTmpdirValue:$.trustedTmpdirValue??$.allowTmpdirVar??!0,environment:$.environment,allowRoots:L_($.allowPaths,J,Q,X),protectedGitMetadata:$.protectedGitMetadata,pathCanonicalizationContext:X}}function e1($,J,Q={}){let X=Q.targetIsLiteral??!1;if(!X&&J.tmpdirWordSplittingUnsafe&&!Q.tmpdirWordSplittingProtected&&M_($))return{kind:"outside_anchored_cwd"};let Y=!X&&JU($,J.posixShell);if(G2($))return{kind:"outside_anchored_cwd"};if(VQ($,X))return{kind:"root_or_home_target"};if(U_($,J))return{kind:"root_or_home_target"};if(J.resolvedCwd&&_2($,J.resolvedCwd,J.protectedGitMetadata,!0,J.pathCanonicalizationContext,!J.posixShell))return{kind:"git_metadata_target"};if(G_($,J.trustTmpdirVar,J.posixShell,Y,X,Q.tmpdirWordSplittingProtected??!1,J.trustedTmpdirValue,J.environment))return{kind:"temp_target"};if(Y)return{kind:"dynamic_target"};if(O_($,J,X))return{kind:"temp_target"};let W=J.anchoredCwd;if(W){if(!Q.skipHomeCwd&&__(W,J.environment.home,J.environment.paths,J.pathCanonicalizationContext))return{kind:"home_cwd_target"};if(!Q.skipCwdSelf&&D_($,J.resolvedCwd??W,J.environment.paths,J.pathCanonicalizationContext))return{kind:"cwd_self_target"};if(z_($,W,J.resolvedCwd??W,Y,X,J.environment.paths,J.pathCanonicalizationContext))return{kind:"within_anchored_cwd"}}return{kind:"outside_anchored_cwd"}}function eq($,J,Q={}){let{containmentTarget:X,...Y}=Q;if(e1($,J,Y).kind!=="temp_target")return!1;let W=$.trim();if(Z_(W))return!1;if(gB(W,J.environment))return!1;return![J.anchoredCwd,J.resolvedCwd].some((K)=>I_(X??W,K,J.environment.paths,J.pathCanonicalizationContext))}function VQ($,J=!1){let Q=$.trim(),X=tq.normalize(Q),Y=Q.replace(/\\/g,"/"),W=X==="/"?X:X.replace(/\/+$/,"");if(W==="/"||W.startsWith("/")&&W.slice(1).split("/").every((K)=>/^\*+$/.test(K)))return!0;if(/^[A-Za-z]:\/+\*?$/.test(Y)||/^\/\/[^/]+\/+[^/]+(?:\/+\*?)?$/.test(Y))return!0;if(!J&&(X==="~"||X==="~/"||X==="~/*"))return!0;if(!J&&(X==="$HOME"||X==="$HOME/"||X==="$HOME/*"))return!0;if(!J&&(X==="${HOME}"||X==="${HOME}/"||X==="${HOME}/*"))return!0;return!1}function U_($,J){let Q=$.trim(),X=Q.endsWith("/*")?Q.slice(0,-2):Q;if(!X)return!1;try{let Y=FQ(X)?X:J.resolvedCwd?Q4(J.resolvedCwd,X):null;if(!Y)return!1;let W=j1(J1(Y,J.environment.paths,J.pathCanonicalizationContext));if(W===Y_(W).root)return!0;return W===j1(J1(J.environment.home,J.environment.paths,J.pathCanonicalizationContext))}catch{return!1}}function j1($){let J=X_($);if(W_){if(J=J.replace(/\//g,"\\").toLowerCase(),J.length>3&&J.endsWith("\\"))J=J.slice(0,-1);return J}if(J.length>1&&J.endsWith("/"))J=J.slice(0,-1);return J}function G_($,J,Q,X,Y,W,K,B){let q=$.trim();if($U(q))return!1;if(!X&&yJ(q,B))return!0;return(J||W&&K)&&Q&&!Y&&H_(q,Q)}function H_($,J){return["$TMPDIR","${TMPDIR}"].some((Q)=>{if($===Q)return!0;if(!$.startsWith(`${Q}/`))return!1;return!JU($.slice(Q.length+1),J)})}function Z_($){let J=/^(?:\$TMPDIR|\$\{TMPDIR\})(?:\/(.*))?$/.exec($);if(!J)return!1;return tq.normalize(`/${J[1]??""}`)==="/"}function $U($){return $.split(/[\\/]+/).includes("..")}function L_($,J,Q,X){if(!$?.length)return[];return $.flatMap((Y)=>{let W=M3(Y.trim(),J);if(!FQ(W))return[];try{let K=J1(W,Q,X);if(w9(K,J1(J,Q,X)))return[];return[j1(K)]}catch{return[]}})}function O_($,J,Q){if(J.allowRoots.length===0)return!1;let X=$.trim();if($U(X))return!1;let Y=Q?X:M3(X,J.environment.home),W=J.resolvedCwd??J.anchoredCwd,K=FQ(Y)?Y:W?Q4(W,Y):null;if(!K)return!1;try{let B=j1(J1(K,J.environment.paths,J.pathCanonicalizationContext));return J.allowRoots.some((q)=>B===q||B.startsWith(q.endsWith(NQ)?q:`${q}${NQ}`))}catch{return!1}}function M_($){return/\$(?:TMPDIR(?![A-Za-z0-9_])|\{TMPDIR\})/.test($)}function JU($,J=!1){return $.includes("$")||$.includes("`")||N_($)||J&&F_($)}function N_($){let J=!1;for(let Q of $){if(J){J=!1;continue}if(Q==="\\"){J=!0;continue}if(Q==="*"||Q==="?"||Q==="[")return!0}return!1}function F_($){let J=!1;for(let Q=0;Q<$.length;Q++){let X=$[Q];if(J){J=!1;continue}if(X==="\\"){J=!0;continue}if(X==="{"&&V_($,Q)||(X==="+"||X==="@"||X==="!")&&$[Q+1]==="(")return!0}return!1}function V_($,J){let Q=$.indexOf("}",J+1);if(Q===-1)return!1;let X=$.slice(J+1,Q);return X.includes(",")||X.includes("..")}function __($,J,Q,X){try{return j1(J1($,Q,X))===j1(J1(J,Q,X))}catch{try{return j1($)===j1(J)}catch{return!1}}}function D_($,J,Q,X){if($==="."||$==="./"||$===".\\")return!0;try{return j1(J1(Q4(J,$),Q,X))===j1(J1(J,Q,X))}catch{try{return j1(Q4(J,$))===j1(J)}catch{return!1}}}function z_($,J,Q,X,Y,W,K){let B=Q??J;if(!Y&&($.startsWith("~")||$.startsWith("$HOME")||$.startsWith("${HOME}")))return!1;if(X)return!1;if($.startsWith("/")||/^[A-Za-z]:[\\/]/.test($))try{return MQ($,J,W,K)}catch{return!1}if($.startsWith("./")||$.startsWith(".\\")||!$.includes("/")&&!$.includes("\\"))try{return MQ(Q4(B,$),J,W,K)}catch{return!1}if($.startsWith("../"))return!1;try{return MQ(Q4(B,$),J,W,K)}catch{return!1}}function MQ($,J,Q,X){try{return QU(J1($,Q,X),J1(J,Q,X))}catch{return!1}}function I_($,J,Q,X){if(!J)return!1;try{return QU(J1(J,Q,X),J1($,Q,X))}catch{return!0}}function QU($,J){let Q=j1($),X=j1(J);return Q.startsWith(`${X}${NQ}`)||Q===X}var j_=new Set(["remove-item","ri","del","erase","rd","rm","rmdir"]),XU="PowerShell Remove-Item -Recurse -Force outside cwd is blocked. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",R_="PowerShell Remove-Item -Recurse -Force for non-temporary paths is blocked by the active safety policy. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",YU="PowerShell Remove-Item target contains variables or pipeline input that cannot be verified safely. Use literal paths within cwd.",WU="PowerShell Remove-Item targeting root or home directory is extremely dangerous and always blocked.",b_="PowerShell Remove-Item -Recurse -Force in home directory is dangerous. Change to a project directory first.",P_="PowerShell Remove-Item receives pipeline input that cannot be verified safely. Use explicit literal paths within cwd.";function KU($,J,Q,X=D2({...Q,allowPaths:Q.policy?.destructiveCommandAllowPaths})){return A_($.words.map((Y)=>({kind:"word",text:Y.text,dynamic:Y.provenance!=="literal"})),J,X,Q.policy)}function A_($,J,Q,X){let Y=$.filter((q)=>q.kind==="word"),W=S_(Y),K=Y[W];if(!K||!j_.has(y_(K.text)))return null;let B=E_(Y.slice(W+1));if(B.whatIfProtected)return null;if(q1(X,"powershell.remove-item-pipeline-dynamic-target",Q.strict)&&J&&(B.targets.length===0||B.recursive))return z("powershell.remove-item-pipeline-dynamic-target",P_);for(let q of B.targets)if(!G2(q.text)&&VQ(DQ(q.text)))return z(B.recursive&&B.force?"powershell.remove-item-recursive-force-root-or-home":"powershell.remove-item-root-or-home",WU);for(let q of B.targets)if(Q.resolvedCwd&&_2(DQ(q.text),Q.resolvedCwd,Q.protectedGitMetadata,B.recursive,Q.pathCanonicalizationContext,!0))return z("powershell.remove-item-git-metadata",p1);if(!B.recursive||!B.force)return null;if(q1(X,"powershell.remove-item-recursive-force-dynamic-target",Q.strict)&&(B.hasDynamicTarget||B.targets.length===0))return z("powershell.remove-item-recursive-force-dynamic-target",YU);for(let q of B.targets){let U=x_(e1(DQ(q.text),Q),Q,X);if(U)return U}return null}function E_($){let J=[],Q=!1,X=!1,Y=!1,W=!1,K=!1;for(let B=0;B<$.length;B++){let q=$[B];if(!q||q.kind!=="word")continue;if(C_(q))continue;if(K){J.push(_Q(q)),W=W||q.dynamic;continue}if(q.text==="--"){K=!0;continue}let U=w_(q.text);if(!U){J.push(_Q(q)),W=W||q.dynamic;continue}if(v_(U.name)){let G=U.value?T_(U.value,q):$[++B];if(G?.kind==="word")J.push(_Q(G)),W=W||G.dynamic;else W=!0;continue}if(f_(U.name)){Q=!0;continue}if(h_(U.name)){X=!0;continue}if(k_(U.name))Y=g_(U.value)}return{targets:J,recursive:Q,force:X,whatIfProtected:Y,hasDynamicTarget:W}}function S_($){let J=$[0];if(J?.kind==="word"&&J.text==="&"||J?.text===".")return $.length>1?1:0;return 0}function _Q($){return{text:$.kind==="word"?$.text:"",dynamic:$.kind==="word"&&$.dynamic}}function C_($){return $.kind==="word"&&$.text===","}function DQ($){let J=$.replace(/\\/g,"/"),Q=/^\$env:(?:userprofile|home)(?=$|\/)/i.exec(J);return Q?`$HOME${J.slice(Q[0].length)}`:J}function T_($,J){return{kind:"word",text:$,dynamic:J.kind==="word"&&(J.dynamic||$.includes("$"))}}function w_($){if(!$.startsWith("-")||$==="-")return null;let J=$.slice(1),Q=J.indexOf(":");if(Q===-1)return{name:J.toLowerCase()};return{name:J.slice(0,Q).toLowerCase(),value:J.slice(Q+1)}}function v_($){return"path".startsWith($)||"literalpath".startsWith($)}function f_($){return"recurse".startsWith($)}function h_($){return $.length>=2&&"force".startsWith($)}function k_($){return $==="wi"||"whatif".startsWith($)}function g_($){if($===void 0||$==="")return!0;let J=$.toLowerCase();return J==="$true"||J==="true"}function y_($){return $.toLowerCase()}function x_($,J,Q){switch($.kind){case"root_or_home_target":return z("powershell.remove-item-recursive-force-root-or-home",WU);case"git_metadata_target":return z("powershell.remove-item-git-metadata",p1);case"temp_target":return null;case"dynamic_target":if(!q1(Q,"powershell.remove-item-recursive-force-dynamic-target",J.strict))return null;return z("powershell.remove-item-recursive-force-dynamic-target",YU);case"home_cwd_target":return z("powershell.remove-item-recursive-force-home-cwd",b_);case"cwd_self_target":return z("powershell.remove-item-recursive-force-cwd-self",XU);case"within_anchored_cwd":if(!q1(Q,"powershell.remove-item-recursive-force-paranoid",J.paranoid))return null;return z("powershell.remove-item-recursive-force-paranoid",R_);case"outside_anchored_cwd":return z("powershell.remove-item-recursive-force-outside-cwd",XU)}}import{normalize as i9}from"path";var h1=new Set(["awk","gawk","nawk","mawk"]),u_=new Set(["-e","--source"]),m_=new Set(["-F","-v","--assign","--field-separator"]),BU=new Set(["-f","--file"]),l_=new Set(["print","printf","return"]),qU=[{selector:"-e",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"--source",kind:"inline-code",valueForm:"equals-or-separate"},{selector:"-f",kind:"program-file",valueForm:"attached-or-separate"},{selector:"--file",kind:"program-file",valueForm:"equals-or-separate"}],p_="Detected awk system(), pipe, or getline command with dynamic command that cannot be safely analyzed. Use a literal command or process the data without system(), pipes, or getline.";function h9($,J,Q){let X=!1;for(let Y of c_($)){let W=d_(Y,Q);if(!W)continue;for(let K of W.commands){let B=J(K);if(B)return B;if(K.includes("{}")||/[$`]/.test(K))X=!0}X||=W.dynamic}return X?z("awk.system-dynamic",p_):null}function IQ($){let J=[],Q=!1,X=!1,Y=!0,W=!0;for(let K=1;K<$.length;K++){let B=$[K];if(B===void 0)break;if(Y&&B==="--"){Y=!1;continue}if(Y&&u_.has(B)){Q=!0;let q=$[K+1];if(q!==void 0)J.push({tokenIndex:K+1,kind:"inline-code",value:q});else W=!1;K++;continue}if(Y&&B.startsWith("--source=")){Q=!0,J.push({tokenIndex:K,kind:"inline-code",value:B.slice(9)});continue}if(Y&&B.startsWith("-e")&&B.length>2){Q=!0,J.push({tokenIndex:K,kind:"inline-code",value:B.slice(2)});continue}if(Y&&(m_.has(B)||BU.has(B))){if(BU.has(B)){X=!0;let q=$[K+1];if(q!==void 0)J.push({tokenIndex:K+1,kind:"program-file",value:q});else W=!1}else if($[K+1]===void 0)W=!1;K++;continue}if(Y&&(B.startsWith("-F")||B.startsWith("-v")&&B.slice(2).includes("=")))continue;if(Y&&B.startsWith("-f")&&B.length>2){X=!0,J.push({tokenIndex:K,kind:"program-file",value:B.slice(2)});continue}if(Y&&(B.startsWith("--assign=")||B.startsWith("--field-separator=")))continue;if(Y&&B.startsWith("--file=")){X=!0,J.push({tokenIndex:K,kind:"program-file",value:B.slice(7)});continue}if(Y&&B.startsWith("-")&&B!=="-")continue;if(Y=!1,!Q&&!X)J.push({tokenIndex:K,kind:"main-program",value:B});return{sources:J,optionsOpen:!1}}return{sources:W?J:[],optionsOpen:Y&&W}}function V3($){return IQ($).sources}function c_($){return V3($).filter((J)=>J.kind!=="program-file").map((J)=>J.value)}function d_($,J){S1(J,$);let Q=$.includes("system")?jQ($,J):null,X=r_($,J);if(!Q&&!X)return null;return{dynamic:!!Q?.dynamic||!!X?.dynamic,commands:[...Q?.commands??[],...X?.commands??[]]}}function jQ($,J){S1(J,$);let Q=[],X=!1,Y=!1,W=0;while(W<$.length){let K=$[W];if(K==='"'||K==="'"){W=f9($,W,K)?.endIndex??W+1;continue}if(K==="#"){W=UU($,W+1);continue}if(K==="/"&&GU($,W)){W=HU($,W+1)??W+1;continue}if(!$.startsWith("system",W)){W++;continue}let B=W;if(W+=6,F3($[B-1])||F3($[W]))continue;let q=v9($,W);if($[q]!=="(")continue;q=v9($,q+1);let U=$[q];if(U!=='"'&&U!=="'"){X=!0,Y=!0;continue}let G=f9($,q,U);if(!G){X=!0,Y=!0;continue}if(q=v9($,G.endIndex),X=!0,$[q]!==")"){Y=!0,W=G.endIndex;continue}Q.push(G.value),W=q+1}if(!X)return null;return{dynamic:Y,commands:Q}}function r_($,J){S1(J,$);let Q=[],X=!1,Y=!1,W=0,K=0,B=null,q=null,U=0;while(W<$.length){let G=$[W];if(!G)break;if(G==='"'||G==="'"){let Z=f9($,W,G);if(Z&&U===K)q={...Z,startIndex:W};U=Z?.endIndex??W+1,W=Z?.endIndex??W+1;continue}if(G==="#"){W=UU($,W+1),K=W,B=null,q=null,U=W;continue}if(G==="/"&&GU($,W)){let Z=HU($,W+1);U=Z??W+1,W=Z??W+1;continue}if(`;
52
- {}`.includes(G)){W++,K=W,B=null,q=null,U=W;continue}if(B===null&&(zQ($,W,"print")||zQ($,W,"printf")))B=W;if(G!=="|"||$[W-1]==="|"||$[W+1]==="|"){if(!/\s/.test(G))U=W+1;W++;continue}let H=$[W+1]==="&"?W+2:W+1,L=v9($,H);if(zQ($,L,"getline")){Y=!0;let Z=n_(K,q,U);if(Z===null)X=!0;else Q.push(Z);U=H,W=H;continue}if(a_(K,B)){Y=!0;let Z=o_($,L);if(!Z){X=!0,U=H,W=H;continue}if(!i_($,Z.endIndex)){X=!0,U=Z.endIndex,W=Z.endIndex;continue}Q.push(Z.value),U=Z.endIndex,W=Z.endIndex;continue}U=H,W++}if(!Y)return null;return{dynamic:X,commands:Q}}function F3($){return!!$&&/[A-Za-z0-9_]/.test($)}function v9($,J){let Q=J;while(/\s/.test($[Q]??""))Q++;return Q}function i_($,J){let Q=J;while(/[\t\f\v\r ]/.test($[Q]??""))Q++;let X=$[Q];return!X||`;
53
- }#`.includes(X)}function f9($,J,Q){let X="",Y=!1;for(let W=J+1;W<$.length;W++){let K=$[W];if(!K)break;if(Y){let B=s_($,W);if(!B)return null;X+=B.value,W=B.endIndex,Y=!1;continue}if(K==="\\"){Y=!0;continue}if(K===Q)return{value:X,endIndex:W+1};X+=K}return null}function o_($,J){let Q=$[J];if(Q!=='"'&&Q!=="'")return null;return f9($,J,Q)}function n_($,J,Q){if(!J)return null;return J.startIndex>=$&&J.endIndex===Q?J.value:null}function s_($,J){let Q=$[J];if(!Q)return null;if(Q==="x"){let Y=$.slice(J+1,J+3);if(!/^[0-9A-Fa-f]{2}$/.test(Y))return null;return{value:String.fromCharCode(Number.parseInt(Y,16)),endIndex:J+2}}if(/[0-7]/.test(Q)){let Y=/^[0-7]{1,3}/.exec($.slice(J));if(!Y)return null;return{value:String.fromCharCode(Number.parseInt(Y[0],8)),endIndex:J+Y[0].length-1}}return{value:{a:"\x07",b:"\b",f:"\f",n:`
54
- `,r:"\r",t:"\t",v:"\v"}[Q]??Q,endIndex:J}}function zQ($,J,Q){return $.startsWith(Q,J)&&!F3($[J-1])&&!F3($[J+Q.length])}function a_($,J){return J!==null&&J>=$}function UU($,J){let Q=$.indexOf(`
55
- `,J);return Q===-1?$.length:Q+1}function GU($,J){let Q=t_($,J);if(Q===-1)return!0;if("{([,;!~=".includes($[Q]??""))return!0;let X=Q;while(F3($[X-1]))X--;return l_.has($.slice(X,Q+1))}function t_($,J){for(let Q=J-1;Q>=0;Q--)if(!/\s/.test($[Q]??""))return Q;return-1}function HU($,J){let Q=!1;for(let X=J;X<$.length;X++){let Y=$[X];if(!Y)break;if(Q){Q=!1;continue}if(Y==="\\"){Q=!0;continue}if(Y==="/")return X+1}return null}var ZU=new Set(["rm","find","xargs","parallel"]),e_=new Set(["sudo","env","command","builtin"]),$D=new Set(["git","busybox",...ZU,...H1,...AB,...h1]);function k9($,J){let Q=$[0];if(!Q||!J.transparentWrappers.includes(l(Q)))return null;let X=l(Q),Y=$[1]==="--"?2:1,W=JD($,Y,X,J),K=W[0];if(K===void 0)return null;return{wrapper:X,tokens:[...$.slice(K)],childIndex:K,alternativeChildIndices:W.slice(1)}}function JD($,J,Q,X){let Y=$[1]==="--",W=[];for(let K=J;K<$.length;K++){let B=$[K];if(!B)continue;if(l(B)!==Q&&QD(B,X))W.push(K);else if(a6.has(i(B)))break;if(Y)break}return W}function QD($,J){let Q=l($),X=i($);return X==="git"||Q==="busybox"||_3($)||ZU.has(Q)||J.transparentWrappers.includes(Q)||H1.has(X)||$==="$SHELL"||C1(X)||h1.has(X)||J.rules.some((Y)=>Y.command===Q)}function _3($){return e_.has($.toLowerCase())}function LU($){let J=i($);return $D.has(J)||C1(J)}function $0($,J){let Q=J.policy??{rules:[],transparentWrappers:[]};return RQ([...$],J.environment,J.cwd,J.cwd,new Map,new Map(J.envAssignments??[]),Q,{iterations:0},!1)}function*RQ($,J,Q,X,Y,W,K,B,q){let U=xJ($,J,Q,W);if(U.unverifiableEnvSplit)throw new L2;for(let[Z,O]of U.envAssignments)W.set(Z,O),Y.set(Z,O);let{tokens:G,cwd:H}=U;if(_3(G[0]??""))throw new m1;let L=k9(G,K);if(L){for(let Z of[L.childIndex,...L.alternativeChildIndices])OU(B),yield*RQ(Z===L.childIndex?L.tokens:[...G.slice(Z)],J,H,X,new Map(Y),new Map(W),K,B,!0);return}if(YD(G)){OU(B),yield*RQ([...G.slice(1)],J,H,X,Y,W,K,B,q);return}yield XD(G,H,X,Y,W,q)}function XD($,J,Q,X,Y,W){return{tokens:$,cwd:J===null?void 0:J??Q,wrapperCwd:J,wrapperEnvAssignments:X,envAssignments:Y,head:l($[0]??"").toLowerCase(),wrappedByTransparent:W}}function OU($){if($.iterations>=i2)throw new m1;$.iterations++}function YD($){return l($[0]??"").toLowerCase()==="busybox"&&$.length>1}function bQ($,J){let Q=[],X=J;while(X<$.length){let Y=$[X];if(Y===void 0||Y===":::")break;Q.push(Y),X++}return{markerIndex:X<$.length&&$[X]===":::"?X:-1,templateTokens:Q}}function w0($){let J=!1,Q=!1;for(let X of $){if(X==="--")break;if(X==="-r"||X==="-R"||PQ(X,"recursive"))J=!0;else if(X==="-f"||PQ(X,"force"))Q=!0;else if(X.startsWith("-")&&!X.startsWith("--")){if(X.includes("r")||X.includes("R"))J=!0;if(X.includes("f"))Q=!0}}return J&&Q}function MU($){let J=$.indexOf("--");return $.slice(1,J===-1?void 0:J).some((Q)=>PQ(Q,"recursive")||/^-[A-Za-z]+$/.test(Q)&&/[rR]/.test(Q.slice(1)))}function PQ($,J){return $.length>2&&$.startsWith("--")&&J.startsWith($.slice(2))}var WD="find -delete permanently removes files. Use -print first to preview.",KD="find -exec rm -rf is dangerous. Use explicit file list instead.",BD=new Set(["-exec","-execdir","-ok","-okdir"]),qD=new Map([...["-Bmin","-Bnewer","-Btime","-amin","-anewer","-atime","-cmin","-cnewer","-context","-ctime","-f","-flags","-fprint","-fprint0","-fls","-fstype","-gid","-group","-ilname","-iname","-inum","-ipath","-iwholename","-iregex","-links","-lname","-maxdepth","-mindepth","-mmin","-mnewer","-mtime","-name","-newer","-newerXY","-newermt","-path","-perm","-printf","-regex","-samefile","-size","-type","-uid","-used","-user","-wholename","-xattrname","-xtype"].map(($)=>[$,1]),["-fprintf",2]]);function g9($,J){let Q=$.map(h),X=UD($,Q,J);if(X)return X;if(x9(Q,1)&&!HD($,Q,J)){let K=k(z("find.delete",WD),J.policy);if(K)return K}let Y=J.derivedCommandWorkBudget??n6(),W=0;while(W<Q.length){let K=Q[W],B=s0(K??"");if(B>0){W+=B+1;continue}if(!v0(K)){W++;continue}K0(Y,Q.length-W-1);let q=D3(Q,W);W=q.nextIndex;let U=LD(q.tokens,J.environment);if(U){let Z=k(U,J.policy);if(Z)return Z}let G=K==="-execdir"||K==="-okdir",H=J.analyzeTokens?J.analyzeTokens(q.tokens,G?null:J.cwd):J.analyzeNested?J.analyzeNested(q.tokens.join(" "),{effectiveCwd:G?void 0:J.cwd,envAssignments:J.envAssignments}):null,L=H?.id.startsWith("custom.")?H:k(H,J.policy);if(L)return L}return null}function UD($,J,Q){if(!x9(J,1)&&!AQ(J,Q.environment))return null;let Y=y9($)??p(["."]),W=D2({...Q,allowPaths:Q.policy?.destructiveCommandAllowPaths,posixShell:!0});for(let K of Y){let B=N3(K);for(let q of B.expandedTargets??[h(K)]){let U=e1(q,W,{targetIsLiteral:B.expandedTargets!==void 0||B.targetIsLiteral,tmpdirWordSplittingProtected:B.tmpdirWordSplittingProtected});if(U.kind==="root_or_home_target")return z("rm.recursive-force-root-or-home","rm -rf targeting root or home directory is extremely dangerous and always blocked.");if(U.kind==="git_metadata_target")return z("find.delete-git-metadata",p1)}}if(GD(J)&&W.resolvedCwd&&rq(Y.map(h),W.resolvedCwd,W.protectedGitMetadata,W.pathCanonicalizationContext))return z("find.delete-git-metadata",p1);return null}function AQ($,J){let Q=0;while(Q<$.length){if(!v0($[Q])){Q++;continue}let X=D3($,Q),Y=l1([...X.tokens],J),W=l(Y[0]??"").toLowerCase();if((W==="rm"||W==="rmdir")&&Y.some((K)=>K.includes("{}")))return!0;Q=X.nextIndex}return!1}function GD($){return $.some((J,Q)=>{if(!["-name","-iname"].includes(J))return!1;return $[Q+1]?.toLowerCase()==="hooks"})}function HD($,J,Q){if(J.includes("-L")||J.includes("-f")||J.includes("-follow"))return!1;let X=y9($);if(!X)return!1;let Y=Q.envAssignments??new Map,W=gJ(Y,Q.environment),K=Q.trustedTmpdirValue??C0(Y,Q.environment),B=Q.allowTmpdirVar??!K3(Y,Q.environment),q=D2({environment:Q.environment,protectedGitMetadata:Q.protectedGitMetadata,cwd:Q.cwd,originalCwd:Q.originalCwd,strict:Q.strict,allowTmpdirVar:B&&K&&Boolean(W),allowPaths:Q.policy?.destructiveCommandAllowPaths,posixShell:!0,tmpdirWordSplittingUnsafe:Q.tmpdirWordSplittingUnsafe??B0(Y,Q.environment),trustedTmpdirValue:K});return X.every((U)=>{let G=N3(U);if(G.unsafeBraceExpansion)return!1;return(G.expandedTargets??[h(U)]).every((H)=>eq(H,q,{containmentTarget:ZD(H,W),targetIsLiteral:G.expandedTargets!==void 0||G.targetIsLiteral,tmpdirWordSplittingProtected:G.tmpdirWordSplittingProtected}))})}function ZD($,J){if(!J)return $;return $.replace(/^(?:\$TMPDIR|\$\{TMPDIR\})/,()=>J)}function y9($){let J=(Y)=>{let W=$[Y];return W?h(W):void 0},Q=1;while(J(Q)==="-H"||J(Q)==="-P")Q++;if(J(Q)==="--")Q++;let X=[];while(Q<$.length){let Y=J(Q),W=$[Q];if(!Y||!W||Y.startsWith("-")||["!","(",")"].includes(Y))break;X.push(W),Q++}return X.length>0?X:null}function LD($,J){let Q=l1([...$],J);if(Q.length===0)return null;let X=l(Q[0]??"");if(X==="busybox"&&Q.length>1)Q=Q.slice(1),X=l(Q[0]??"");if(X==="rm"&&w0(Q))return z("find.exec-rm-recursive-force",KD);return null}function D3($,J){let Q=J+1;while(Q<$.length&&$[Q]!==";"&&!($[Q]==="+"&&$[Q-1]==="{}"))Q++;return{tokens:$.slice(J+1,Q),nextIndex:Math.min(Q+1,$.length)}}function x9($,J){let Q=J;while(Q<$.length){let X=$[Q];if(!X){Q++;continue}if(v0(X)){Q=D3($,Q).nextIndex;continue}let Y=s0(X);if(Y>0){Q+=Y+1;continue}if(X==="-delete")return!0;Q++}return!1}function s0($){return qD.get($)??(/^-newer[A-Za-z]{2}$/.test($)?1:0)}function v0($){return $!==void 0&&BD.has($)}function z3($){let J=a1($,"posix");if(J.status!=="complete"||J.nodes.length!==1)return null;let Q=J.nodes[0];if(Q?.kind!=="command")return null;if(Q.redirections.length>0||Q.nested.length>0)return null;if(Q.words.some((X)=>X.provenance==="command-substitution"))return null;return Q.words.map((X)=>X.text)}var OD=5,EQ="Git aliases supplied through command-line or environment config can hide or execute commands. Run git without Git alias overrides, or ask the user to run it manually.";function R1($){let J=$.indexOf("--");if(J===-1)return{index:-1,before:$,after:[]};return{index:J,before:$.slice(0,J),after:$.slice(J+1)}}function FU($,J,Q){let X=_U($,J,Q),Y=MD(X.entries);if(Y.size===0)return{blockedReason:X.blockedReason,expanded:!1,tokens:$};let W=$,K=!1;for(let B=0;B<OD;B++){let{subcommand:q,rest:U}=J0(W),G=q?.toLowerCase();if(!G||!Y.has(G))return{blockedReason:X.blockedReason,expanded:K,tokens:W};let H=Y.get(G),L=DD(H);if(L===null||L.length===0)return{blockedReason:EQ,expanded:!0,tokens:W};W=["git",...L,...U],K=!0}return{blockedReason:EQ,expanded:!0,tokens:W}}function VU($,J,Q){return _U($,J,Q).entries.some((X)=>X.key.toLowerCase()==="core.sshcommand")}function J0($){if($.length===0)return{subcommand:null,rest:[]};let J=$[0];if((J?l(J).toLowerCase():null)!=="git")return{subcommand:null,rest:[]};let X=1;while(X<$.length){let Y=$[X];if(!Y)break;if(Y==="--"){let W=$[X+1];if(W&&!W.startsWith("-"))return{subcommand:W,rest:$.slice(X+2)};return{subcommand:null,rest:$.slice(X+1)}}if(Y.startsWith("-"))if(W0.has(Y))X+=2;else if(Y.startsWith("-c")&&Y.length>2)X++;else if(Y.startsWith("-C")&&Y.length>2)X++;else X++;else return{subcommand:Y,rest:$.slice(X+1)}}return{subcommand:null,rest:[]}}function MD($){let J=new Map;for(let Q of $){let X=Q.key.toLowerCase();if(!X.startsWith("alias."))continue;let Y=X.slice(6);if(Y!=="")J.set(Y,Q.value)}return J}function _U($,J,Q){if($.length===0)return{blockedReason:null,entries:[]};let X=$[0];if((X?l(X).toLowerCase():null)!=="git")return{blockedReason:null,entries:[]};let W=FD(J,Q);return{blockedReason:W.blockedReason,entries:[...W.entries,...ND($,J,Q)]}}function ND($,J,Q){let X=[],Y=1;while(Y<$.length){let W=$[Y];if(!W||W==="--"||!W.startsWith("-"))return X;if(W==="-c"){let K=SQ($[Y+1]);if(K)X.push(K);Y+=2;continue}if(W.startsWith("-c")&&W.length>2){let K=SQ(W.slice(2));if(K)X.push(K);Y++;continue}if(W==="--config-env"){let K=NU($[Y+1],J,Q);if(K)X.push(K);Y+=2;continue}if(W.startsWith("--config-env=")){let K=NU(W.slice(13),J,Q);if(K)X.push(K);Y++;continue}if(W0.has(W)){Y+=2;continue}Y++}return X}function FD($,J){let Q=VD($,J),X=_D($,J);return{blockedReason:Q===null||X===null?EQ:null,entries:[...Q??[],...X??[]]}}function VD($,J){let Q=u1("GIT_CONFIG_PARAMETERS",$,J);if(Q===void 0)return[];let X=[],Y=z3(Q);if(!Y)return null;for(let W of Y){let K=SQ(W);if(!K)return null;X.push(K)}return X}function _D($,J){let Q=x6($,J);if(Q.state==="absent")return[];if(Q.state==="invalid")return null;let X=[];for(let Y=0;Y<Q.count;Y++){let W=u1(`GIT_CONFIG_KEY_${Y}`,$,J)?.trim(),K=u1(`GIT_CONFIG_VALUE_${Y}`,$,J);if(!W||K===void 0)return null;X.push({key:W,value:K})}return X}function SQ($){if(!$)return null;let J=$.indexOf("=");return{key:(J===-1?$:$.slice(0,J)).trim(),value:J===-1?void 0:$.slice(J+1)}}function NU($,J,Q){let X=$?.indexOf("=")??-1;if(!$||X===-1)return null;return{key:$.slice(0,X).trim(),value:u1($.slice(X+1),J,Q)}}function DD($){let J=$?.trimStart();if(!J||J.startsWith("!"))return null;return z3(J)}var zD="git checkout -- discards uncommitted changes permanently. Use 'git stash' first.",ID="git checkout --force discards uncommitted changes. Use 'git stash' first.",jD="git checkout <ref> -- <path> overwrites working tree with ref version. Use 'git stash' first.",RD="git checkout --pathspec-from-file can overwrite multiple files. Use 'git stash' first.",bD="git checkout with multiple positional args may overwrite files. Use 'git switch' for branches or 'git restore' for files.",PD="git switch --discard-changes discards uncommitted changes. Use 'git stash' first.",AD="git switch --force discards uncommitted changes. Use 'git stash' first.",ED="git restore discards uncommitted changes. Use 'git stash' first, or use --staged to only unstage.",SD="git restore --worktree explicitly discards working tree changes. Use 'git stash' first.",CD="git reset --hard destroys all uncommitted changes permanently. Use 'git stash' first.",TD="git reset --merge can lose uncommitted changes. Use 'git stash' first.",wD="git clean -f removes untracked files permanently. Use 'git clean -n' to preview first.",vD="git push --force destroys remote history. Use --force-with-lease for safer force push.",fD="git push deletes remote refs. Ask the user to run it manually if deletion is intended.",hD="git push --mirror can force-update and delete remote refs. Ask the user to run it manually if mirror push is intended.",kD="git branch -D force-deletes without merge check. Use -d for safe delete.",gD="git rebase --abort discards rebase conflict resolutions. Use 'git status' first.",yD="git merge --abort discards merge conflict resolutions. Use 'git status' first.",xD="git tag -d permanently deletes tags. Ask the user to run it manually if deletion is intended.",uD="git reflog delete removes recovery history. Ask the user to run it manually if deletion is intended.",mD="git stash drop permanently deletes stashed changes. Consider 'git stash list' first.",lD="git stash clear deletes ALL stashed changes permanently. Use 'git stash list' to review; ask the user to run it manually if intended.",pD="git worktree remove --force can delete uncommitted changes. Remove --force flag.",DU=new Set(["-b","-B","--orphan","--conflict","--inter-hunk-context","--pathspec-from-file","--unified"]),zU=new Set(["--recurse-submodules","--track","-t"]),CQ=new Set(["-b","-B","-U"]),TQ=new Set(["-c","-C"]),cD=new Set(["--source","--conflict","--unified","--inter-hunk-context"]),dD=new Set(["-q","--quiet","--no-quiet","-f","--force","--no-force","-d","--detach","--no-detach","-m","--merge","--no-merge","-p","--patch","--no-patch","--guess","--no-guess","--overlay","--no-overlay","--ours","--theirs","--ignore-skip-worktree-bits","--no-ignore-skip-worktree-bits","--no-track","--overwrite-ignore","--no-overwrite-ignore","--ignore-other-worktrees","--no-ignore-other-worktrees","--progress","--no-progress","--pathspec-file-nul","--no-pathspec-file-nul","--no-recurse-submodules"]);function a($,J){let Q=$.split("=",1)[0]??$;return Q.length>=4&&J.startsWith(Q)&&Q.startsWith("--")&&Q.slice(2).length>=2}function jU($){let{subcommand:J,rest:Q}=J0($);if(!J)return null;switch(J.toLowerCase()){case"checkout":return z2(rD(Q));case"switch":return z2(iD(Q));case"restore":return z2(nD(Q));case"reset":return aD(Q);case"clean":return z2(eD(Q));case"push":return I2($z(Q));case"branch":return I2(Xz(Q));case"stash":return I2(qz(Q));case"worktree":return I2(Uz(Q));case"rebase":return z2(Yz(Q));case"merge":return z2(Wz(Q));case"tag":return I2(Kz(Q));case"reflog":return I2(Bz(Q));default:return null}}function z2($){return $?{...$,localDiscard:!0}:null}function I2($){return $?{...$,localDiscard:!1}:null}function rD($){let{index:J,before:Q}=R1($),X=v1(Q,{shortOptsWithValue:CQ});if(Q.some((W)=>a(W,"--force"))||X.has("-f"))return z("git.checkout-force",ID);for(let W of $){if(W==="-b"||W==="-B"||W==="--orphan")return null;if(a(W,"--pathspec-from-file"))return z("git.checkout-pathspec-from-file",RD)}if(J!==-1){if(Q.some((K)=>!K.startsWith("-")))return z("git.checkout-ref-path",jD);return z("git.checkout-double-dash",zD)}if(oD($).length>=2)return z("git.checkout-ambiguous",bD);return null}function iD($){let{before:J}=R1($);if(J.some((X)=>a(X,"--discard-changes")))return z("git.switch-discard-changes",PD);let Q=v1(J,{shortOptsWithValue:TQ});if(J.some((X)=>a(X,"--force"))||Q.has("-f"))return z("git.switch-force",AD);return null}function oD($){let J=[],Q=0;while(Q<$.length){let X=$[Q];if(!X)break;if(X==="--")break;if(X.startsWith("-"))if(DU.has(X))Q+=2;else if(X.startsWith("--")&&X.includes("="))Q++;else if(zU.has(X)){let Y=$[Q+1];if(Y&&!Y.startsWith("-")&&(X==="--recurse-submodules"||X==="--track"||X==="-t"))if((X==="--recurse-submodules"?["checkout","on-demand"]:["direct","inherit"]).includes(Y))Q+=2;else Q++;else Q++}else if(X.startsWith("--")&&!dD.has(X)&&!DU.has(X)&&!zU.has(X))Q++;else Q++;else J.push(X),Q++}return J}function nD($){let J=sD($);if(J.isTerminal||!J.hasPathspec&&!J.hasPatch||!J.hasWorktree)return null;return J.hasExplicitLocation?z("git.restore-worktree",SD):z("git.restore-unstaged",ED)}function sD($){let J=!1,Q=!1,X=!0,Y=!1,W=(K)=>{if(!Y)X=!1,Y=!0;if(K!==void 0)X=K};for(let K=0;K<$.length;K++){let B=$[K];if(B===void 0)break;if(B==="--"){J||=K+1<$.length;break}if(B==="--pathspec-from-file"){J=!0,K++;continue}if(B.startsWith("--pathspec-from-file=")){J=!0;continue}if(B==="-h"||B==="--help"||B==="--version")return{hasPathspec:J,hasPatch:Q,hasWorktree:X,hasExplicitLocation:Y,isTerminal:!0};if(B==="--staged"){W();continue}if(B==="--no-staged"){W();continue}if(B==="--worktree"){W(!0);continue}if(B==="--no-worktree"){W(!1);continue}if(B==="--patch"){Q=!0;continue}if(B==="--no-patch"){Q=!1;continue}if(cD.has(B)){K++;continue}if(B.startsWith("--"))continue;if(B==="-"){J=!0;continue}if(!B.startsWith("-")){J=!0;continue}for(let q=1;q<B.length;q++){let U=B.charAt(q);if(U==="h")return{hasPathspec:J,hasPatch:Q,hasWorktree:X,hasExplicitLocation:Y,isTerminal:!0};if(U==="S"){W();continue}if(U==="W"){W(!0);continue}if(U==="p"){Q=!0;continue}if(U==="s"||U==="U"){if(q===B.length-1)K++;break}}}return{hasPathspec:J,hasPatch:Q,hasWorktree:X,hasExplicitLocation:Y,isTerminal:!1}}function aD($){let J=null;for(let Q of $){if(a(Q,"--hard")){J=z("git.reset-hard",CD);break}if(a(Q,"--merge")){J=z("git.reset-merge",TD);break}}if(!J)return null;return tD($)?I2(J):z2(J)}function tD($){for(let J of $){if(J==="--")return!1;if(!J.startsWith("-"))return!0}return!1}function eD($){for(let Q of $)if(Q==="-n"||a(Q,"--dry-run"))return null;let J=v1($.filter((Q)=>Q!=="--"));if($.some((Q)=>a(Q,"--force"))||J.has("-f"))return z("git.clean-force",wD);return null}function $z($){let{before:J,after:Q}=R1($),X=v1(J);if(J.some((K)=>a(K,"--mirror")))return z("git.push-mirror",hD);if(J.some((K)=>a(K,"--force"))||X.has("-f")||IU(J,Q).some(Jz))return z("git.push-force",vD);if(J.some((K)=>a(K,"--delete"))||X.has("-d")||IU(J,Q).some(Qz))return z("git.push-delete",fD);return null}function IU($,J){return[...$.filter((Q)=>Q!==""&&!Q.startsWith("-")),...J]}function Jz($){return $.startsWith("+")||$.includes(":+")}function Qz($){return $.length>1&&$.startsWith(":")}function Xz($){let{before:J}=R1($),Q=v1(J),X=Q.has("-D")||Q.has("-d")||J.some((W)=>a(W,"--delete")),Y=Q.has("-D")||Q.has("-f")||J.some((W)=>a(W,"--force"));if(X&&Y)return z("git.branch-force-delete",kD);return null}function Yz($){let{before:J}=R1($);return J.some((Q)=>a(Q,"--abort"))?z("git.rebase-abort",gD):null}function Wz($){let{before:J}=R1($);return J.some((Q)=>a(Q,"--abort"))?z("git.merge-abort",yD):null}function Kz($){let{before:J}=R1($);return v1(J).has("-d")||J.some((X)=>a(X,"--delete"))?z("git.tag-delete",xD):null}function Bz($){return $[0]==="delete"?z("git.reflog-delete",uD):null}function qz($){for(let J of $){if(J==="drop")return z("git.stash-drop",mD);if(J==="clear")return z("git.stash-clear",lD)}return null}function Uz($){let{before:J}=R1($);if(!J.includes("remove"))return null;let X=v1(J);if(J.some((Y)=>a(Y,"--force"))||X.has("-f"))return z("git.worktree-remove-force",pD);return null}import{execFileSync as Gz}from"child_process";import{existsSync as vQ,readFileSync as fQ}from"fs";import{dirname as Hz,isAbsolute as PU,join as wQ,resolve as AU}from"path";var Zz=["/usr/bin/git","/usr/local/bin/git","/opt/homebrew/bin/git","C:\\Program Files\\Git\\cmd\\git.exe","C:\\Program Files\\Git\\bin\\git.exe"];function EU($,J,Q,X){let Y=Lz($,J,Q);if(Y!==null)return Y;let W=Oz(J,Q);if(W!==null)return W;if(eK(Q))return!0;return Mz(X)}function Lz($,J,Q){let X=null,Y=1;while(Y<$.length){let W=$[Y];if(!W||W==="--")return X;if(!W.startsWith("-"))return X;if(W==="-c"){let K=RU($[Y+1]);if(K!==null)X=K;Y+=2;continue}if(W.startsWith("-c")&&W.length>2){let K=RU(W.slice(2));if(K!==null)X=K;Y++;continue}if(W==="--config-env"){let K=bU($[Y+1],J,Q);if(K!==null)X=K;Y+=2;continue}if(W.startsWith("--config-env=")){let K=bU(W.slice(13),J,Q);if(K!==null)X=K;Y++;continue}if(W0.has(W))Y+=2;else Y++}return X}function Oz($,J){if(u1("GIT_CONFIG_PARAMETERS",$,J)!==void 0)return!0;let Q=x6($,J);if(Q.state==="absent")return null;if(Q.state==="invalid")return!0;let X=null;for(let Y=0;Y<Q.count;Y++){let W=u1(`GIT_CONFIG_KEY_${Y}`,$,J),K=u1(`GIT_CONFIG_VALUE_${Y}`,$,J);if(!W?.trim()||K===void 0)return!0;let B=W.trim().toLowerCase();if(hQ(B))return!0;if(B!=="submodule.recurse")continue;X=I3(K)}return X}function Mz($,J=Fz()){let Q=Nz($);if(Q===null||Q)return!0;if(J===null)return!0;try{let X=Gz(J,["config","--get","submodule.recurse"],{cwd:$,encoding:"utf8",env:Vz(process.env),stdio:["ignore","pipe","ignore"]}).trim();return I3(X)}catch(X){return!_z(X)}}function Nz($){let J=Dz($);if(J===null)return null;for(let Q of J){if(!vQ(Q))continue;if(jz(Q))return!0}return!1}function Fz(){for(let $ of Zz)if(vQ($))return $;return null}function Vz($){let J={...$};for(let Q of Object.keys(J))if(a4(Q))delete J[Q];return J}function _z($){return typeof $==="object"&&$!==null&&"status"in $&&$.status===1}function Dz($){let J=$3($);if(J===null)return null;let Q=zz(J);if(Q===null)return null;let X=Iz(Q);if(X===null)return null;return[wQ(X,"config"),wQ(Q,"config.worktree")]}function zz($){try{let Q=fQ($,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(!Q.startsWith("gitdir:"))return $;let X=Q.slice(7).trim();if(X==="")return null;return PU(X)?X:AU(Hz($),X)}catch{return null}}function Iz($){let J=wQ($,"commondir");if(!vQ(J))return $;try{let Q=fQ(J,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(Q==="")return null;return PU(Q)?Q:AU($,Q)}catch{return null}}function jz($){let J;try{J=fQ($,"utf-8")}catch{return!0}let Q="",X=!1;for(let Y of J.split(/\r?\n/)){let W=Y.trim();if(W===""||W.startsWith("#")||W.startsWith(";"))continue;let K=W.match(/^\[([^\]]+)\]$/);if(K){Q=K[1]?.trim().toLowerCase()??"";continue}let B=W.indexOf("="),q=(B===-1?W:W.slice(0,B)).trim().toLowerCase(),U=B===-1?"true":W.slice(B+1).trim();if(Rz(Q)&&q==="path")return!0;if(Q==="submodule"&&q==="recurse")X=I3(U)}return X}function Rz($){return $==="include"||$.startsWith("includeif ")}function RU($){if(!$)return null;let J=$.indexOf("="),Q=(J===-1?$:$.slice(0,J)).toLowerCase();if(hQ(Q))return!0;if(Q!=="submodule.recurse")return null;let X=J===-1?"true":$.slice(J+1).toLowerCase();return I3(X)}function I3($){let J=$.toLowerCase();return J!=="false"&&J!=="no"&&J!=="off"&&J!=="0"}function bU($,J,Q){let X=$?.indexOf("=")??-1;if(!$||X===-1)return null;let Y=$.slice(0,X).toLowerCase();if(hQ(Y))return!0;if(Y!=="submodule.recurse")return null;let W=u1($.slice(X+1),J,Q);return W===void 0||I3(W)}function hQ($){return $==="include.path"||$.startsWith("includeif.")&&$.endsWith(".path")}function SU($,J,Q){if(!J.localDiscard||!Q.worktreeMode||XB(Q.env,Q.envAssignments))return null;let X=YB($,Q.cwd);if(!X.gitCwd||X.hasExplicitGitContext)return null;if(!WB(X.gitCwd))return null;if(bz($,Q,X.gitCwd))return null;return{originalReason:J.reason,gitCwd:X.gitCwd}}function bz($,J,Q){let{subcommand:X,rest:Y}=J0($),W=X?.toLowerCase();if(J.dynamicArguments||Pz(Y)||EU($,J.env,J.envAssignments,Q)||Sz(Y)||Az(W,Y))return!0;return W==="clean"&&Cz(Y)>1}function Pz($){return $.some((J)=>/[$*?[]/.test(J))}function Az($,J){if($==="checkout"){let{before:Q}=R1(J),X=v1(Q,{shortOptsWithValue:CQ}),Y=Q.some((K)=>a(K,"--force"))||X.has("-f"),W=X.has("-B")||Q.some((K)=>K==="-B"||K.startsWith("-B"));return Y&&W}if($==="switch"){let{before:Q}=R1(J),X=v1(Q,{shortOptsWithValue:TQ}),Y=Q.some((K)=>a(K,"--force"))||Q.some((K)=>a(K,"--discard-changes"))||X.has("-f"),W=Q.some((K)=>K==="-C"||K.startsWith("-C")||Ez(K))||X.has("-C");return Y&&W}return!1}function Ez($){let J=$.split("=",1)[0]??$;return J==="--force-create"||J.length>=9&&"--force-create".startsWith(J)}function Sz($){return $.some((J)=>J.startsWith("--recurse-sub"))}function Cz($){let J=0;for(let Q of $){if(Q==="--force"){J++;continue}if(Q.startsWith("-")&&!Q.startsWith("--")){for(let X of Q.slice(1))if(X==="f")J++}}return J}var Tz="Git SSH environment overrides can execute arbitrary commands during network operations. Run git without GIT_SSH/GIT_SSH_COMMAND overrides, or ask the user to run it manually.",wz=new Set(["clone","fetch","pull","push","ls-remote","submodule"]);function X4($,J){return CU($.map(h),J)}function CU($,J,Q){let X=FU($,J.env,J.envAssignments),Y=J.policy?.destructiveCommandRuleOverrides["git.alias-config"]==="off";if(X.blockedReason&&!Y)return z("git.alias-config",X.blockedReason);let W=X.tokens;if((tK(J.envAssignments)||VU($,J.env,J.envAssignments))&&vz(W))return z("git.ssh-env",Tz);let K=jU(W);if(!K)return null;if(X.expanded||X.blockedReason)return K;let B=SU($,K,J);if(!B)return K;return Q?.(B),null}function TU($,J){let Q=null;return{match:CU($.map(h),J,(Y)=>{Q=Y}),relaxation:Q}}function vz($){let{subcommand:J,rest:Q}=J0($),X=J?.toLowerCase();if(!X)return!1;if(wz.has(X))return!0;if(X==="archive")return R1(Q).before.some((Y)=>a(Y,"--remote"));return X==="remote"&&fz(Q)}function fz($){return $.find((J)=>!hz(J))?.toLowerCase()==="update"}function hz($){return $==="-v"||a($,"--verbose")||a($,"--no-verbose")}import{isAbsolute as bI}from"path";var wU="rm -rf outside cwd is blocked. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",kz="rm -rf for non-temporary paths is blocked by the active safety policy. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",gz="rm -rf target contains shell variables that cannot be verified safely. Use literal paths within cwd, /tmp, /var/tmp, or $TMPDIR.",fU="rm -rf targeting root or home directory is extremely dangerous and always blocked.",yz="rm -rf in home directory is dangerous. Change to a project directory first.";function Y4($,J){let Q=D2({...J,allowPaths:J.policy?.destructiveCommandAllowPaths,posixShell:!0}),X=$.map(h),Y=w0(X),W=MU(X),K=uz($);for(let B of K){let q=N3(B.word);if(Y&&q.unsafeBraceExpansion){let U=k(vU({kind:"outside_anchored_cwd"},Q,J.policy),J.policy);if(U)return U;continue}for(let U of q.expandedTargets??[B.text]){let G={targetIsLiteral:q.expandedTargets!==void 0||q.targetIsLiteral,tmpdirWordSplittingProtected:q.tmpdirWordSplittingProtected};if(!W&&Q.resolvedCwd&&_2(U,Q.resolvedCwd,Q.protectedGitMetadata,W,Q.pathCanonicalizationContext))return z("rm.git-metadata",p1);if(W&&!Y){let H=e1(U,Q,G);if(H.kind==="root_or_home_target")return z("rm.recursive-force-root-or-home",fU);if(H.kind==="git_metadata_target")return z("rm.git-metadata",p1);continue}if(!Y)continue;for(let H of xz(U,Q,G)){let L=vU(H,Q,J.policy),Z=k(L,J.policy);if(Z)return Z}}}return null}function xz($,J,Q){let X=e1($,J,Q);if(X.kind==="cwd_self_target")return[X,e1($,J,{...Q,skipCwdSelf:!0})];if(X.kind!=="home_cwd_target")return[X];let Y=e1($,J,{...Q,skipHomeCwd:!0});if(Y.kind!=="cwd_self_target")return[X,Y];return[X,Y,e1($,J,{...Q,skipHomeCwd:!0,skipCwdSelf:!0})]}function uz($){let J=[],Q=!1;for(let X of $.slice(1)){let Y=h(X);if(!Y)continue;if(Y==="--"){Q=!0;continue}if(Q){J.push({text:Y,word:X});continue}if(!Y.startsWith("-"))J.push({text:Y,word:X})}return J}function vU($,J,Q){switch($.kind){case"root_or_home_target":return z("rm.recursive-force-root-or-home",fU);case"git_metadata_target":return z("rm.git-metadata",p1);case"temp_target":return null;case"dynamic_target":if(!q1(Q,"rm.recursive-force-dynamic-target",J.strict))return null;return z("rm.recursive-force-dynamic-target",gz);case"home_cwd_target":return z("rm.recursive-force-home-cwd",yz);case"cwd_self_target":return z("rm.recursive-force-cwd-self",wU);case"within_anchored_cwd":if(q1(Q,"rm.recursive-force-paranoid",J.paranoid))return z("rm.recursive-force-paranoid",kz);return null;case"outside_anchored_cwd":return z("rm.recursive-force-outside-cwd",wU)}}var mz={bash:["O","o"],dash:["o"],ksh:["o"],sh:["o"],zsh:["o"]},kU=new Set(["--init-file","--rcfile"]),lz=["--init-file","--rcfile"],pz=new Map([["bash","BASH_ENV"],["dash","ENV"],["ksh","ENV"],["sh","ENV"]]);function Z0($){for(let J=1;J<$.length;J++){let Q=$[J];if(!Q)continue;if(Q==="-c")return hU($,J,!0);if(Q.startsWith("-")&&Q.includes("c")&&!Q.startsWith("--")){let X=hU($,J,!1);if(X!==null)return X}}return null}function c1($){let J=l($[0]??"").toLowerCase();if(J==="zsh"||J==="ksh")return L0($).syntaxCheck;let Q=!1;for(let X of $.slice(1)){if(X==="--")return Q;if(X.startsWith("+")&&!X.startsWith("++")){if(X.slice(1).includes("n"))Q=!1;continue}if(!X.startsWith("-")||X.startsWith("--"))return Q;let Y=X.slice(1);if(Y.includes("n"))Q=!0;if(Y.includes("c"))return Q}return Q}function hU($,J,Q){if($[J+1]==="--")return $[J+2]||null;let X=$[J+1];if(!X||!Q&&X.startsWith("-"))return null;return X}function gU($){let J=l($[0]??"").toLowerCase(),Q=cz($,J),X=pz.get(J)??null,Y=Q.argvSource?.kind!=="absent";return{argvSource:J==="bash"?Q.argvSource:null,argvSourceApplies:J==="bash"&&Q.interactive&&Q.argvSource?.kind==="literal",envName:X,envSourceApplies:Y&&(X==="BASH_ENV"?!Q.interactive:X==="ENV"&&Q.interactive)}}function cz($,J){let Q=L0($),X=Q.commandIndex??Q.scriptIndex??$.length,Y=[],W=!1,K=!0;for(let B=1;B<X;B++){let q=$[B];if(q===void 0||q==="--"||q==="-"||q[0]!=="-"&&q[0]!=="+")break;if(q.startsWith("--")){if(J==="bash"&&K?lz.find((L)=>q===L):void 0){let L=$[B+1];Y.push(L===void 0?{kind:"absent"}:{kind:"literal",value:L}),B++;continue}let H=q.split("=",1)[0]??q;if(J==="bash"&&kU.has(H)&&!q.includes("="))B++;continue}if(J==="bash")K=!1;let U=yU(J,q,$[B+1],"startup");if(U.interactive)W=q[0]==="-";B+=U.followingValues}return{argvSource:Y.at(-1)??null,interactive:W}}function yU($,J,Q,X){let Y=!1,W=0,K=!1,B=!1,q=!1;for(let U=1;U<J.length;U++){let G=J[U];if(G===void 0)break;if($==="ksh"&&G==="o"&&U+1<J.length){if(X==="argv"){let H=J.slice(U+1);if(J[0]==="-"&&(H==="c"||H[0]==="-"&&H.endsWith("c")))K=!0}break}if($==="ksh"&&G==="o"&&U+1===J.length&&(Q?.startsWith("-")||Q?.startsWith("+")))break;if($==="zsh"&&G==="o"&&U+1<J.length)break;if(X==="startup"&&G==="i")Y=J[0]==="-";if(X==="argv"&&J[0]==="-"&&G==="c")K=!0;if(X==="argv"&&G==="n")q=J[0]==="-";if(X==="argv"&&G==="s")B=J[0]==="-";if(!mz[$]?.includes(G))continue;if(U+1===J.length)W++;break}return{interactive:Y,followingValues:W,commandSelected:K,stdinMode:B,syntaxCheck:q}}function L0($){let J=l($[0]??"").toLowerCase(),Q=!1,X=!1,Y=!1;for(let W=1;W<$.length;W++){let K=$[W];if(K===void 0)break;if(K==="--"){let q=Q&&$[W+1]!==void 0?W+1:null;return{command:q===null?null:$[q]??null,commandIndex:q,scriptIndex:!Q&&!X&&$[W+1]!==void 0?W+1:null,readsStdinAsCommands:!Q&&(X||$[W+1]===void 0),syntaxCheck:Y}}if(K==="-"||K[0]!=="-"&&K[0]!=="+")return{command:Q?K:null,commandIndex:Q?W:null,scriptIndex:!Q&&!X&&K!=="-"?W:null,readsStdinAsCommands:!Q&&(X||K==="-"),syntaxCheck:Y};if(K.startsWith("--")){let q=K.split("=",1)[0]??K;if(J==="bash"&&kU.has(q)&&!K.includes("="))W++;continue}let B=yU(J,K,$[W+1],"argv");if(B.commandSelected)Q=!0;if(B.syntaxCheck)Y=!0;if(B.stdinMode)X=!0;W+=B.followingValues}return{command:null,commandIndex:null,scriptIndex:null,readsStdinAsCommands:!Q,syntaxCheck:Y}}var a0={kind:"none"},j2={kind:"dynamic"},dz=new Set(["<","<<","<<-","<<<","<&","<>"]),uU=/\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*))/g,rz=/^(?:[0-9]+|[@*])$/,iz=F2.maxWords,oz=F2.maxInputLength;function mU($){if(!$||l(i($.words[0]?.text??""))!=="printf")return;if($.words.some((Y)=>Y.provenance!=="literal"))return;let J=$.words.slice($.words[1]?.text==="--"?2:1),Q=J[0]?.text;if(Q===void 0)return"";let X=J.slice(1).map((Y)=>Y.text);if(Q==="%s")return X.join("");if(Q==="%s\\n"||Q===`%s
49
+ `)K++;return{next:K,limited:!1}}if(!$.startsWith("<#",J))return null;let Y=1,W=J+2;while(W<Q){if($.startsWith("<#",W)){if(Y++,Y>X)return{next:Q,issue:{code:"comment-depth-limit",message:`PowerShell block comment exceeds nesting limit ${X}`,span:{start:J,end:W+2}},limited:!0};W+=2;continue}if($.startsWith("#>",W)){if(Y--,W+=2,Y===0)return{next:W,limited:!1};continue}W++}return{next:Q,issue:{code:"unclosed-block-comment",message:"PowerShell block comment is not closed",span:{start:J,end:Q}},limited:!1}}function nF($,J){if(J)return"limited";if($.some((Q)=>Q.code==="unclosed-block-comment"))return"invalid";return $.length>0?"partial":"complete"}function oJ($,J,Q){return Object.freeze({kind:"connector",operator:$.slice(J,Q),span:Object.freeze({start:J,end:Q})})}var F2=Object.freeze({maxInputLength:131072,maxWords:16384,maxDepth:64});function a1($,J="auto",Q=F2){if(J==="powershell"||J==="auto"&&Gq($.slice(0,Q.maxInputLength)))return Hq($,Q);return eB($,"posix",Q)}function $Q($,J){if($!=="powershell")return J[0]?.provenance==="command-substitution";let Q=J[0]?.text==="&"||J[0]?.text==="."?1:0,X=J[Q]?.provenance;return X!==void 0&&X!=="literal"}var sF=/^[A-Za-z_][A-Za-z0-9_]*=/;function D9($,J){return $?.provenance==="literal"&&!$.quoted&&$.raw===J&&$.text===J}function z9($){let J=D9($.words[0],"time")?1:0,Q=J===1&&D9($.words[J],"-p")?J+1:J,X=J===1&&D9($.words[Q],"--")?Q+1:Q,Y=D9($.words[X],"!")?X+1:X,W=$.words.slice(Y).find((K)=>!sF.test(K.text));return W?.provenance==="literal"?W.text:void 0}function G3($,J){if(J.escaped)return J.escaped=!1,!0;if($==="\\"&&!J.inSingle)return J.escaped=!0,!0;if($==="'"&&!J.inDouble)return J.inSingle=!J.inSingle,!0;if($==='"'&&!J.inSingle)return J.inDouble=!J.inDouble,!0;return!1}function $4($){let J={inSingle:!1,inDouble:!1,escaped:!1};for(let Q of aF($))G3(Q,J);return J.inSingle||J.inDouble}function aF($){let J="",Q={inSingle:!1,inDouble:!1,escaped:!1},X=!1,Y=!0;for(let W=0;W<$.length;W++){let K=$[W];if(!K)break;if(X){if(K===`
50
+ `||K==="\r")J+=K,X=!1,Q.escaped=!1;continue}if(K==="#"&&!Q.inSingle&&!Q.inDouble&&Y){X=!0;continue}if(J+=K,!Q.inSingle&&!Q.inDouble&&!Q.escaped)Y=/[\s;&|()<>]/.test(K);G3(K,Q)}return J}var tF=new Set(["&&","||","|&","|","&",";"]),eF=new Set(["<<","<<<",">|"]),$V=/[*@#?$!_-]/,JQ=Object.freeze([]),JV=Object.freeze([]),QV=256;function _q($,J){let Q=J.status==="complete"?new Set(XQ(J)):new Set,X=[...Q].reduce((K,B)=>K.slice(0,B.start)+" ".repeat(B.end-B.start)+K.slice(B.end),$);if($4(X))return I9("unclosed-quote",X,JQ);let Y={invalid:!1,limited:!1,expansions:0,assignmentFallbacks:[]},W=H3(J,{source:X,suppressed:Q,flags:Y,depth:0,functions:new Map});if(Y.limited)return I9("structural-limit",X,JQ);if(Y.invalid)return I9("invalid",X,JQ);return I9("complete",X,W,Y.assignmentFallbacks)}function I9($,J,Q,X=JV){return Object.freeze({status:$,source:J,entries:Object.freeze(Q),assignmentFallbacks:Object.freeze(X)})}function H3($,J){return $.nodes.flatMap((Q,X)=>XV(Q,$,X,J)).sort((Q,X)=>Q.start-X.start).flatMap((Q)=>[...Q.entries])}function XV($,J,Q,X){if($.kind==="connector")return[{start:$.span.start,entries:[t1(qV($.operator))]}];if($.kind==="unknown")return[{start:$.span.start,entries:[t1($.source)]}];if($.kind==="function")return X.functions.set($.name,$.body),[];if($.kind==="group"){let W=$.style!=="subshell",K=X.source[$.span.end-1]===(W?"}":")"),B=W?X:{...X,functions:new Map(X.functions)};return[{start:$.span.start,entries:[W?j9("{"):t1("("),...H3($.body,B),...K?[W?j9("}"):t1(")")]:[]]}]}let Y=GV($,X.functions);if(Y){if(X.depth>=F2.maxDepth||++X.flags.expansions>QV)return X.flags.limited=!0,[];return[{start:$.span.start,entries:[...Mq($,X),j9(";"),...H3(Y,{...X,depth:X.depth+1}),j9(";")]},...Nq($,J,Q,X)]}return[{start:$.span.start,entries:Mq($,X)},...Nq($,J,Q,X)]}function Mq($,J){return[...$.words.map((Q)=>({start:Q.span.start,entries:zq(Q,$,J,!1)})),...$.redirections.map((Q)=>({start:Q.span.start,entries:YV(Q,$,J)}))].sort((Q,X)=>Q.start-X.start).flatMap((Q)=>Q.entries)}function YV($,J,Q){let X=$.operator==="<<-"?"<<":$.operator,Y=$.target?zq($.target,J,Q,!0):[],W=Y[0],K=W?.kind==="word"?W.text:void 0;return[...$.fd===void 0?[]:[YQ(String($.fd))],Object.freeze({kind:"redirection",operator:X,role:UV(X),targetOrder:eF.has(X)?"legacy-segment":"immediate",...K===void 0?{}:{target:K}}),...K===void 0?Y:Y.slice(1)]}function Nq($,J,Q,X){let Y=$.redirections.filter((W)=>W.operator==="<<"||W.operator==="<<-");return[...Y.flatMap((W)=>{let K=W.heredoc;if(!K)return[];let B=[YQ(K.delimiter),.../[\r\n]/.test(X.source[K.terminatorSpan.end]??"")?[t1(";")]:[]];if(X.suppressed.has(K.bodySpan))return[{start:K.bodySpan.start,entries:B}];return[{start:K.bodySpan.start,entries:[...Dq(X.source.slice(K.bodySpan.start,K.bodySpan.end),X),...B]}]}),...Y.some((W)=>!W.heredoc&&W.target)?WV(J,Q,X):[]]}function WV($,J,Q){let X=$.nodes.slice(J+1).find((Y)=>Y.kind==="connector");if(!X||X.span.end>=$.span.end)return[];return[{start:X.span.end,entries:Dq(Q.source.slice(X.span.end,$.span.end),Q)}]}function Dq($,J){if(J.depth>=F2.maxDepth)return J.flags.limited=!0,[];let Q=a1($,"posix");if(Q.status==="limited")return J.flags.limited=!0,[];let X={invalid:!1,limited:!1,expansions:J.flags.expansions,assignmentFallbacks:J.flags.assignmentFallbacks},Y=H3(Q,{source:$,suppressed:new Set,flags:X,depth:J.depth+1,functions:new Map});return J.flags.limited||=X.limited,J.flags.expansions=X.expansions,Y}function zq($,J,Q,X){let Y=[],W={single:!1,double:!1},K="",B=!1,q=()=>{if(B&&!X)Y.push(t1("glob"));else if(K!==""||$.quoted&&Y.length===0)Y.push(YQ(K));K="",B=!1};for(let U of $.parts){if(U.provenance!=="command-substitution"&&U.provenance!=="arithmetic"){for(let Z of QQ(U.raw,W,Q.flags)){if(typeof Z==="string"){q(),Y.push(t1(Z));continue}K+=Z.text,B||=Z.glob}continue}if(W.double){let Z=Q.source.slice(U.span.start,U.span.end);K+=QQ(Z,{single:!1,double:!0},Q.flags).map((O)=>typeof O==="string"?O:O.text).join("");continue}let G=J.nested.find((Z)=>Z.span.start>=U.span.start&&Z.span.end<=U.span.end),H=G?H3(G,Q):[];if(U.raw.startsWith("`")){K+="${}",q(),Y.push(...H);continue}if(U.raw.startsWith("<(")||U.raw.startsWith(">(")){q(),Y.push(U.raw.startsWith("<(")?t1("<("):Object.freeze({kind:"redirection",operator:">",role:"file-write",targetOrder:"immediate"}),...H,...U.raw.endsWith(")")?[t1(")")]:[]);continue}let L=U.raw.startsWith("$((")?2:1;K+="${}",q(),Y.push(...Array.from({length:L},()=>t1("(")),...H,...U.raw.endsWith(")".repeat(L))?Array.from({length:L},()=>t1(")")):[])}return q(),Y}function QQ($,J,Q){let X=[],Y="",W=!1,K=0;while(K<$.length){let B=$[K]??"";if(!J.single&&!J.double&&(B==="("||B===")")){X.push({text:Y,glob:W},B),Y="",W=!1,K++;continue}if(J.single){if(B==="'")J.single=!1;else Y+=B;K++;continue}if(J.double){if(B==='"'){J.double=!1,K++;continue}if(B==="\\"){let q=$[K+1]??"";Y+=['"',"\\","$"].includes(q)?q:`\\${q}`,K+=2;continue}if(B==="$"){let q=Fq($,K,J,Q);Y+=q.text,K=q.next;continue}Y+=B,K++;continue}if(B==="'"||B==='"'){J.single=B==="'",J.double=B==='"',K++;continue}if(B==="\\"){let q=$[K+1]??"";W||=q==="*"||q==="?",Y+=q,K+=2;continue}if(B==="$"){let q=Fq($,K,J,Q);Y+=q.text,K=q.next;continue}W||=B==="*"||B==="?",Y+=B,K++}return[...X,{text:Y,glob:W}]}function Fq($,J,Q,X){let Y=$[J+1];if(Y==="{"){let K=BV($,J+2);if(K===-1)return X.invalid=!0,{text:"",next:$.length};let B=$.slice(J,K+1);return KV(B,Q,X),{text:B,next:K+1}}if(Y!==void 0&&$V.test(Y))return{text:`\${${Y}}`,next:J+2};let W=/^\w*/.exec($.slice(J+1))?.[0]??"";return{text:`\${${W}}`,next:J+1+W.length}}function KV($,J,Q){let X=$.slice(2,-1),Y=/^[A-Za-z_][A-Za-z0-9_]*/.exec(X)?.[0];if(!Y)return;let W=X.slice(Y.length),K=[":=","="].find((q)=>W.startsWith(q));if(!K)return;let B=QQ(W.slice(K.length),{...J},Q);Q.assignmentFallbacks.push(...B.flatMap((q)=>typeof q==="string"||!q.text?[]:[q.text]))}function BV($,J){let Q=1,X=J;while(Q>0&&X<$.length){if($[X]==="{"&&$[X-1]==="$")Q++;else if($[X]==="}")Q--;X++}return Q===0?X-1:-1}function qV($){return/^[\r\n]+$/.test($)?";":$}function t1($){return Object.freeze({kind:"operator",operator:$,boundary:tF.has($)})}function j9($){return Object.freeze({kind:"operator",operator:$,boundary:!0})}function YQ($){return Object.freeze({kind:"word",text:$})}function UV($){if($==="<<"||$==="<<<")return"here-data";if($==="<"||$==="<&")return"file-read";return"file-write"}function XQ($){return $.nodes.flatMap((J,Q)=>{if(J.kind==="group"||J.kind==="function")return XQ(J.body);if(J.kind!=="command")return[];let X=J.nested.flatMap((K)=>XQ(K)),Y=$.nodes[Q+1];if(Y?.kind==="connector"&&(Y.operator==="|"||Y.operator==="|&")||!ZV(J))return X;return[...X,...J.redirections.flatMap((K)=>K.heredoc?.quotedDelimiter?[K.heredoc.bodySpan]:[])]})}function GV($,J){let Q=z9($);return Q===void 0?void 0:J.get(Q)}function o0($,J){return $!==void 0&&$.provenance==="literal"&&!$.quoted&&$.raw===$.text&&$.text===J}function HV($){if(o0($.words[0],"git"))return o0($.words[1],"commit");if(!o0($.words[0],"gh")||!o0($.words[2],"create"))return!1;return o0($.words[1],"pr")||o0($.words[1],"issue")}function ZV($){return(o0($.words[0],"cat")||o0($.words[0],"tee")||HV($))&&!$.words.some(Vq)&&!$.redirections.some((Q)=>Vq(Q.target))}function Vq($){return $?.parts.some((J)=>J.provenance==="command-substitution"&&J.raw.startsWith(">("))??!1}import{types as LV}from"util";var OV=new Set(["applypatch","patch"]),MV=new Set(["create","edit","listdir","listpermissions","ls","multiedit","multireplacefilecontent","notebookedit","read","readfile","readurlcontent","replacefilecontent","searchweb","strreplaceeditor","view","viewfile","write","writefile","writetofile"]),NV=new Set(["grep","grepsearch","rg"]),FV=new Set(["findbyname","glob"]),VV=new Set(["findbyname","glob","grep","grepsearch","listdir","listpermissions","ls","read","readfile","readurlcontent","searchweb","view","viewfile"]),_V=new Set(["command","diff","input","patch","patchtext"]),Iq=new TextEncoder,DV=new TextDecoder,zV=/\s/,IV=64;class w0 extends Error{name="ToolInputLimitError";constructor(){super("tool input traversal limit exceeded")}}var Z3=Object.freeze({maxDepth:64,maxNodes:1e4,maxKeys:1e4,maxStringBytes:1048576,maxAggregateStringBytes:4194304});function Aq($){return $.replace(/[-_\s]/g,"").toLowerCase()}function b9($){return VV.has(Aq($))}function qQ($){let J=Aq($);if(OV.has(J))return"patch";if(NV.has(J))return"grep";if(FV.has(J))return"glob";if(MV.has(J))return"path";return"unknown"}function J4($){if(!$||typeof $!=="object")return;wq($);let J=Object.getOwnPropertyDescriptor($,"command");if(!J){if("command"in $)U0();return}if(J.get||J.set)U0();let Q=J.value;return typeof Q==="string"&&Q!==""?Q:void 0}function UQ($,J){return Eq($,J,{nodes:0,keys:0,stringBytes:0,ancestors:new Set},1)}function Eq($,J,Q,X){let Y=Tq($,Q,X);if(!Y)return[];let W=Y.entries.flatMap(([K,B])=>{let q=Eq(B,J,Q,X+1);return typeof B==="string"&&J.has(Sq(K))?[B]:q});return Q.ancestors.delete(Y.object),W}function Sq($){return $.replace(/-/g,"_").toLowerCase()}function GQ($){return Cq($,!0,{nodes:0,keys:0,stringBytes:0,ancestors:new Set},1).flatMap(RV)}function Cq($,J,Q,X){let Y=Tq($,Q,X);if(typeof $==="string")return J?[$]:[];if(!Y)return[];let W=Y.entries.flatMap(([K,B])=>Cq(B,Y.array?J:_V.has(Sq(K)),Q,X+1));return Q.ancestors.delete(Y.object),W}function jV($,J,Q){if(J.nodes++,$!==null&&typeof $==="object"&&Q>Z3.maxDepth||J.nodes>Z3.maxNodes)U0();if(typeof $!=="string")return;let X=Buffer.byteLength($);if(J.stringBytes+=X,X>Z3.maxStringBytes||J.stringBytes>Z3.maxAggregateStringBytes)U0()}function Tq($,J,Q){if(jV($,J,Q),!$||typeof $!=="object")return null;let X=wq($);if(J.ancestors.has($))U0();let Y=Reflect.ownKeys($);if(J.keys+=Y.length,J.keys>Z3.maxKeys)U0();let W=Y.flatMap((K)=>{let B=Object.getOwnPropertyDescriptor($,K);if(!B||B.get||B.set)U0();return typeof K==="string"&&B.enumerable?[[K,B.value]]:[]});return J.ancestors.add($),{object:$,array:X,entries:W}}function wq($){if(LV.isProxy($))U0();let J=Array.isArray($),Q=Object.getPrototypeOf($);if(J&&Q!==Array.prototype||!J&&Q!==Object.prototype&&Q!==null)U0();return J}function U0(){throw new w0}function RV($){let J=[],Q=$.split(/\r?\n/),X=!1,Y=!1,W=null,K=null,B=()=>{Y=!1,W=null,K=null};for(let q=0;q<Q.length;q++){let U=Q[q]??"";if(U==="*** Begin Patch"){X=!0,B();continue}if(U==="*** End Patch"){X=!1,B();continue}if(U.startsWith("@@")){let G=bV(U);if(Y=!0,W=G?.oldLines??null,K=G?.newLines??null,W===0&&K===0)B();continue}if(Y&&W!==null&&K!==null){let G=U.startsWith(" ")||U.startsWith("-")?1:0,H=U.startsWith(" ")||U.startsWith("+")?1:0;if(W=Math.max(0,W-G),K=Math.max(0,K-H),W===0&&K===0)B();continue}if(U.startsWith("*** ")){B(),J.push(...WQ(U));continue}if(Y)continue;if(U.startsWith("diff --git ")){J.push(...WQ(U));continue}if(U.startsWith("--- ")){let G=Q[q+1]??"";if(!G.startsWith("+++ "))continue;J.push(...BQ(R9(U.slice(4),!0),R9(G.slice(4),!0))),q++;continue}if(!X)J.push(...WQ(U))}return J}function bV($){let J=/^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec($);if(!J)return null;return{oldLines:Number(J[1]??1),newLines:Number(J[2]??1)}}function WQ($){let J=/^\*\*\* (?:Add|Update|Delete) File: (.+)$/.exec($);if(J?.[1])return Pq(J[1]);let Q=/^\*\*\* Move to: (.+)$/.exec($);if(Q?.[1])return Pq(Q[1]);if($.startsWith("diff --git "))return PV($.slice(11));let X=/^--- (.+)$/.exec($);if(X?.[1])return bq(X[1]);let Y=/^\+\+\+ (.+)$/.exec($);if(Y?.[1])return bq(Y[1]);let W=/^(?:rename|copy) (?:from|to) (.+)$/.exec($);if(W?.[1])return vV(W[1]);return[]}function PV($){let J=AV($);if(J.length===2&&J[0]&&J[1])return BQ(J[0],J[1]);let Q=EV($);return Q?BQ($.slice(Q.oldStart,Q.oldEnd),$.slice(Q.newStart,Q.newEnd)):[]}function AV($){let J=[],Q=0;while(Q<$.length&&J.length<2){while(V2($[Q]))Q++;if(Q>=$.length)break;let X=$[Q]==='"'||$[Q]==="'"?$[Q]:void 0;if(!X){let W=Q;while(Q<$.length&&!V2($[Q]))Q++;J.push($.slice(W,Q));continue}let Y=vq($,Q,X);if(!Y)return[];J.push(Y.value),Q=Y.end}while(V2($[Q]))Q++;return Q===$.length?J:[]}function EV($){let J=0;while(J<$.length&&V2($[J]))J++;let Q=$.length;while(Q>J&&V2($[Q-1]))Q--;let X=0,Y=J;while(Y<Q){if(!V2($[Y])){Y++;continue}let W=Y;while(Y<Q&&V2($[Y]))Y++;if(W===J||Y===Q)continue;if(X++,X>IV)U0();if(SV($,J,W,Y,Q))return{oldStart:J,oldEnd:W,newStart:Y,newEnd:Q}}return null}function SV($,J,Q,X,Y){if(KQ($,J,Q,X,Y))return!0;let W=jq($,"/",J,Q),K=jq($,"/",X,Y);if(W<=J||K<=X)return!1;if(KQ($,J,W,X,K))return!1;return KQ($,W+1,Q,K+1,Y)}function KQ($,J,Q,X,Y){if(Q-J!==Y-X)return!1;for(let W=0;W<Q-J;W++)if($[J+W]!==$[X+W])return!1;return!0}function jq($,J,Q,X){for(let Y=Q;Y<X;Y++)if($[Y]===J)return Y;return-1}function V2($){return $!==void 0&&zV.test($)}function vq($,J,Q){let X=[],Y=J+1;while(Y<$.length){let W=$[Y]??"";if(W===Q)return{value:DV.decode(Uint8Array.from(X)),end:Y+1};if(W!=="\\"||Q==="'"){X.push(...Iq.encode(W)),Y++;continue}let K=$.slice(Y+1),B=/^[0-7]{1,3}/.exec(K)?.[0];if(B){X.push(Number.parseInt(B,8)),Y+=B.length+1;continue}X.push(...Iq.encode(CV(K[0]??""))),Y+=2}return null}function CV($){return{a:"\x07",b:"\b",f:"\f",n:`
51
+ `,r:"\r",t:"\t",v:"\v"}[$]??$}function TV($){return L3(fV($))}function BQ($,J){if($==="/dev/null")return Rq(J);if(J==="/dev/null")return Rq($);if($.startsWith("a/")&&J.startsWith("b/"))return[$.slice(2),J.slice(2)].flatMap(L3);let Q=wV($,J)??($===J?fq($):null);return[$,J,...Q?[Q]:[]].flatMap(L3)}function Rq($){let J=fq($);return[$,...J?[J]:[]].flatMap(L3)}function fq($){let J=$.indexOf("/");return J>0&&J<$.length-1?$.slice(J+1):null}function wV($,J){let Q=$.indexOf("/"),X=J.indexOf("/");if(Q<1||X<1)return null;if($.slice(0,Q)===J.slice(0,X))return null;let Y=$.slice(Q+1);return Y===J.slice(X+1)?Y:null}function bq($){return TV(R9($,!0))}function vV($){return L3(R9($,!1))}function R9($,J){let Q=$.trim(),X=Q[0]==='"'||Q[0]==="'"?Q[0]:void 0;if(X){let Y=vq(Q,0,X);if(Y&&(J||Q.slice(Y.end).trim()===""))return Y.value}return J?Q.split("\t",1)[0]?.trim()??"":Q}function fV($){return $.startsWith("a/")||$.startsWith("b/")?$.slice(2):$}function L3($){return $===""||$==="/dev/null"?[]:[$]}function Pq($){let J=$.split("\t",1)[0]?.trim().replace(/^['"]|['"]$/g,"")??"";return J===""||J==="/dev/null"?[]:[J]}var kq=new Set(["absolutepath","directorypath","directory_path","file","file_path","filepath","include","notebook_path","path","searchdirectory","search_directory","searchpath","targetfile","target_file"]),gq=new Set([...kq,"glob"]),kV=new Set([...gq,"pattern"]),gV=Object.freeze([]),yq={parseCommand:a1,projectShellSyntax:_q};class n0 extends Error{name="StructuralShellSyntaxLimitError";constructor(){super("Structural command analysis limit exceeded.")}}function P9($,J={}){let Q=yV({...yq,...J}),X=J4($.input),Y=[];if(($.route.kind==="command"||$.route.kind==="unknown")&&X)Y.push({usage:"input-candidate",source:X});if($.route.kind==="command"&&"command"in $&&$.command)Y.push({usage:"declared-command",source:$.command});let W=Y.reduce((K,B)=>{let q=K.findIndex((H)=>H.source===B.source);if(q!==-1){let H=K[q];if(!H)return K;return K[q]=hq({...H,usages:[...H.usages,B.usage]}),K}let U=$.route.kind==="command"?$.route.shell:"posix",G=Q.getCommandProgram(B.source,U);return K.push(hq({usages:[B.usage],source:B.source,program:G,views:HQ(G),uncertainties:G.issues,shell:Q.getShellSyntax(B.source,G)})),K},[]);return Object.freeze({invocation:Object.freeze({toolName:$.toolName,route:Object.freeze({...$.route}),context:Object.freeze({...$.context,...$.context.policyConfigCwds?{policyConfigCwds:Object.freeze([...$.context.policyConfigCwds])}:{}})}),commands:Object.freeze(W),paths:Object.freeze(xV($)),store:Q})}function w1($,J){return $.commands.find((Q)=>Q.usages.includes(J))}function G0($){if(!$.includes("$"))return $;return k6($,E0())}function yV($={}){let J={...yq,...$},Q=new Map,X=new Map,Y=new WeakMap,W=(B,q)=>{let U=`${q}\x00${B}`,G=X.get(U);if(G)return G;let H=J.parseCommand(B,q);return X.set(U,H),H};return Object.freeze({getShellSyntax:(B,q)=>{if(q&&q.source!==B)throw TypeError("Shell syntax source does not match command program source.");let U=q??W(B,"posix");if(U.status==="limited"){let L=Y.get(U);if(L)return L;let Z=Object.freeze({status:"structural-limit",source:B,entries:gV,assignmentFallbacks:Object.freeze([])});return Y.set(U,Z),Z}let G=Q.get(B);if(G)return G;let H=J.projectShellSyntax(B,U);return Q.set(B,H),H},getCommandProgram:W})}function hq($){return Object.freeze({...$,usages:Object.freeze([...$.usages]),views:Object.freeze([...$.views]),uncertainties:Object.freeze([...$.uncertainties])})}function HQ($){return Object.freeze($.nodes.flatMap((J)=>{if(J.kind==="group")return[...HQ(J.body)];if(J.kind!=="command")return[];return[...J.nested.flatMap((Q)=>[...HQ(Q)]),J]}))}function xV($){let J=$.route.kind==="grep"?gq:$.route.kind==="glob"?kV:kq,Q=$.route.kind==="grep"||$.route.kind==="glob"?"read":$.route.kind==="patch"?"write":"unknown";return[...UQ($.input,J).map((X)=>Object.freeze({raw:X,role:"tool-path",access:Q})),...$.route.kind==="patch"?GQ($.input).map((X)=>Object.freeze({raw:X,role:"patch-target",access:"write"})):[]]}function v1($,J){let Q=new Set,X=!1;for(let Y of $){if(Y==="--"){X=!0;continue}if(X)continue;if(Y.startsWith("-")&&!Y.startsWith("--")&&Y.length>1)for(let W=1;W<Y.length;W++){let K=Y[W];if(!K||!/[a-zA-Z]/.test(K))break;let B=`-${K}`;if(Q.add(B),J?.shortOptsWithValue?.has(B))break}}return Q}var uV=new Map([["bash",new Set(["O","o"])],["dash",new Set(["o"])],["ksh",new Set(["o"])],["sh",new Set(["o"])],["zsh",new Set(["o"])]]),mV=new Map([["zsh",new Set(["o"])]]),lV=new Map([["bash",new Set(["--init-file","--rcfile"])]]);function xq($,J){for(let Q=0;Q<J.length;Q++){let X=J[Q];if(X===void 0||X==="--"||X==="-"||X[0]!=="-"&&X[0]!=="+")return null;if(X.startsWith("--")){let K=lV.get($);if(cV(X,K))continue;if(!K?.has(X))continue;if(J[Q+1]===void 0)return null;Q++;continue}let Y=pV($,X);if(Y.commandSelected)return J[Q+Y.followingValues+1]??null;let W=J[Q+1];if($==="ksh"&&(X==="-o"||X==="+o")&&W!==void 0&&W[0]!=="-"&&W[0]!=="+")Q++;Q+=Y.followingValues}return null}function pV($,J){let Q=uV.get($),X=mV.get($),Y=!1,W=0;for(let K=1;K<J.length;K++){let B=J[K];if(B===void 0)break;if(J[0]==="-"&&B==="c")Y=!0;if($==="ksh"&&B==="o"){if(K+1<J.length){let q=J.slice(K+1);if(!Y&&J[0]==="-"&&q==="c")continue;if(!Y&&J[0]==="-"&&q[0]==="-"&&q.endsWith("c"))Y=!0;break}if(Y)W++;continue}if(!Q?.has(B))continue;if(X?.has(B)&&K+1<J.length)break;W++}return{commandSelected:Y,followingValues:W}}function cV($,J){return J!==void 0&&[...J].some((Q)=>$.startsWith(`${Q}=`))}var iV=new Set(["-S","--suffix"]);function A9($,J,Q,X){if($.status==="structural-limit")throw new n0;if($.status!=="complete")return X.findMalformedTarget($.source);let Y={cwd:J,variables:new Map},W=[];for(let K of $.entries){if(K.kind==="operator"){if(!K.boundary)continue;let B=X.findSegmentTarget(W,Y);if(B)return B;Y=oV(W,Y,Q,X.normalizeCwd),W=[];continue}if(K.kind==="redirection"){if(K.role==="file-write"&&K.target&&X.isRedirectionTarget(f1(K.target,Y.variables),Y))return K.target;continue}W.push(K.text)}return X.findSegmentTarget(W,Y)}function f1($,J){return $.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)(:?[-+])([^}]*)\}/g,(Q,X,Y,W)=>{let K=J.get(X);if(K===void 0)return Q;let B=Y.startsWith(":")?K!=="":!0;if(Y.endsWith("-"))return B?K:f1(W,J);return B?f1(W,J):""}).replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(Q,X)=>J.get(X)??Q).replace(/\$([A-Za-z_][A-Za-z0-9_]*)/g,(Q,X)=>J.get(X)??Q)}function O3($){return $.length>0&&$.every((J)=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(J))}function M1($,J,Q){let X=Q.environment.home,Y=k6($.trim(),Q.environment).replace(/\\/g,"/");if(!Y)return"";let W=Y==="~"?X:Y.startsWith("~/")?uq(X,Y.slice(2)):Y;return J1(rV(dV(W)?W:uq(J,W)),Q.environment.paths,Q).replace(/\\/g,"/")}function E9($){let J=[],Q=null,X=!1;for(let Y=0;Y<$.length;Y++){let W=$[Y];if(W===void 0)break;if(!X&&W==="--"){X=!0;continue}if(!X&&(W==="-t"||W==="--target-directory")){Q=$[++Y]??null;continue}if(!X&&W.startsWith("--target-directory=")){Q=W.slice(19);continue}if(!X&&W.startsWith("-t")&&W.length>2){Q=W.slice(2);continue}if(!X&&iV.has(W)){Y++;continue}if(!X&&(W.startsWith("--suffix=")||W.startsWith("--backup=")))continue;if(!X&&W.startsWith("-"))continue;J.push(W)}return Q?{sources:J,destination:Q}:{sources:J.slice(0,-1),destination:J.at(-1)??null}}function oV($,J,Q,X){let Y=O3($)?new Map([...J.variables,...nV($,J.variables)]):J.variables,W=l1([...$],Q.environment),K=l(W[0]??"").toLowerCase()==="cd"?W[1]:void 0;return{cwd:!K||K==="-"?J.cwd:X(f1(K,Y),J.cwd,Q),variables:Y}}function nV($,J){return $.flatMap((Q)=>{let X=/^([A-Za-z_][A-Za-z0-9_]*)(.*)$/.exec(Q),Y=X?.[2]?.startsWith("=")?X[2].slice(1):void 0;return X?.[1]!==void 0&&Y!==void 0?[[X[1],f1(Y,J)]]:[]})}var p1="Git metadata and hooks are protected. Ask the user before modifying them.";function cq($,J=LQ($.invocation.context.executionCwd)){let Q=H2(E0()),X=$.invocation.context.executionCwd;if(!J)return null;if($.invocation.route.kind==="patch"||$.invocation.route.kind==="path"||$.invocation.route.kind==="unknown"){if(b9($.invocation.toolName))return null;let K=$.paths.find((B)=>J_(B.raw,X,J,Q))?.raw;return K?{target:K}:null}if($.invocation.route.kind!=="command")return null;let Y=w1($,"input-candidate");if(!Y)return null;let W=A9(Y.shell,X,Q,{findSegmentTarget:(K,B)=>X_(K,B,J,Q),isRedirectionTarget:(K,B)=>Q_(K,B.cwd,J,Q),findMalformedTarget:()=>null,normalizeCwd:M1});return W?{target:W}:null}function LQ($,J=H2(E0())){if(typeof $!=="string"||!$)return null;let Q=$3(M1($,$,J));if(!Q)return null;try{let X=M1(Q,$,J),Y=sV(Q),W=Y.isFile()?X:null,K=Y.isFile()?wJ(Q):null,B=(Y.isDirectory()?[X]:[K?.gitDir,K?.commonDir]).flatMap((U)=>U?[H0(M1(U,$,J))]:[]),q=[...new Set(Y.isDirectory()?[H0(Q.replace(/\\/g,"/")),...B]:B)];return Object.freeze({entry:H0(X),markerFile:W?H0(W):null,directories:Object.freeze(q),hooksDirectories:Object.freeze([...new Set(q.flatMap((U)=>{let G=H0(aV(U,"hooks"));return[G,H0(M1(G,$,J))]}))])})}catch{return null}}function _2($,J,Q,X,Y,W=!1){if(!Q)return!1;let K=H0(M1($,J,Y)),B=K.replace(/(\/\.?\*+)+$/,"");if(B!==K&&B!==""){if(ZQ(B,Q))return!0;let q=W||K.slice(B.length).includes("/."),U=(G)=>q?S9(G,B):tV(G,B);if(Q.markerFile&&U(Q.markerFile))return!0;return X&&mq(Q).some(U)}if(ZQ(K,Q))return!0;return X&&mq(Q).some((q)=>S9(q,K))}function tV($,J){let Q=pq(J,$);if(Q===""||Q.startsWith("..")||lq(Q))return!1;return!Q.split(/[\\/]/)[0]?.startsWith(".")}function eV($,J,Q,X){return _2($,J,Q,!0,X)}function $_($,J,Q,X){if(!Q)return!1;return ZQ(H0(M1($,J,X)),Q)}function J_($,J,Q,X){if(!Q)return!1;return dq($,J,Q,X,Q.entry)}function Q_($,J,Q,X){if(!Q)return!1;return dq($,J,Q,X,Q.markerFile)}function dq($,J,Q,X,Y){let W=H0(M1($,J,X));return W===Y||iq(W,Q)}function rq($,J,Q,X){if(!Q)return!1;return Q.hooksDirectories.some((Y)=>$.some((W)=>S9(Y,H0(M1(W,J,X)))))}function ZQ($,J){return $===J.entry||J.directories.includes($)||iq($,J)}function iq($,J){return J.hooksDirectories.some((Q)=>S9($,Q))}function mq($){return[$.entry,...$.directories,...$.hooksDirectories]}function S9($,J){let Q=pq(J,$);return Q===""||!/^\.\.(?:[\\/]|$)/.test(Q)&&!lq(Q)}function H0($){return process.platform==="win32"?$.toLowerCase():$}function X_($,J,Q,X){if(O3($))return null;let Y=l1([...$],X.environment);if(l(Y[0]??"").toLowerCase()!=="mv")return null;let W=E9(Y.slice(1)),K=W.sources.find((B)=>eV(f1(B,J.variables),J.cwd,Q,X));if(K)return K;return W.destination&&$_(f1(W.destination,J.variables),J.cwd,Q,X)?W.destination:null}import{isAbsolute as sq,normalize as Y_,sep as OQ}from"path";var oq=process.platform==="win32";function M3($,J){if($==="~")return J;if($.startsWith("~/"))return`${J}${$.slice(1)}`;return $}function C9($,J){if(typeof $!=="string"||$.trim()==="")return"must be a non-empty path string";let Q=M3($.trim(),J);if(!sq(Q))return"must be an absolute path or start with ~/";return w9(Q,J)}function T9($,J){if(typeof $!=="string"||$.trim()==="")return"must be a non-empty path string";let Q=M3($.trim().replace(/^\$(?:\{HOME\}|HOME(?=\/|$))/,"~"),J);if(!sq(Q))return null;if(w9(Q,J)===null)return null;return"cannot be the home directory or a path above it (this would block every command the agent runs)"}function w9($,J){let Q=nq($),X=nq(J);if(Q===X)return"cannot be the home directory";let Y=Q.endsWith(OQ)?Q:`${Q}${OQ}`;if(X.startsWith(Y))return"cannot contain the home directory";return null}function nq($){let J=Y_($);if(oq)J=J.replace(/\//g,"\\").toLowerCase();if(J.length>(oq?3:1)&&J.endsWith(OQ))J=J.slice(0,-1);return J}var B_=process.platform==="win32",aq=64,q_=16384;function N3($){let J=Yq($,aq,aq,q_);return{expandedTargets:J&&"words"in J?J.words:void 0,unsafeBraceExpansion:J!==void 0&&"limited"in J,targetIsLiteral:J===void 0&&$.provenance==="literal"&&($.quoted||$.raw!==$.text),tmpdirWordSplittingProtected:U_($)}}function U_($){let J=$.parts.filter((Q)=>Q.provenance==="variable"&&/\$(?:TMPDIR(?![A-Za-z0-9_])|\{TMPDIR\})/.test(Q.raw));return J.length>0&&J.every((Q)=>G_($.raw,Q.span.start-$.span.start))}function G_($,J){let Q=null,X=!1;for(let Y=0;Y<J;Y++){let W=$[Y];if(X){X=!1;continue}if(W==="\\"&&Q!=="'"){X=!0;continue}if(Q===W){Q=null;continue}if(Q===null&&(W==="'"||W==='"'))Q=W}return Q==='"'}function D2($){let J=$.environment.home,Q=$.environment.paths,X=H2($.environment);return{anchoredCwd:$.originalCwd??$.cwd??null,resolvedCwd:$.cwd??null,strict:$.strict??!1,paranoid:$.paranoid??!1,trustTmpdirVar:$.allowTmpdirVar??!0,posixShell:$.posixShell??!1,tmpdirWordSplittingUnsafe:$.tmpdirWordSplittingUnsafe??!1,trustedTmpdirValue:$.trustedTmpdirValue??$.allowTmpdirVar??!0,environment:$.environment,allowRoots:M_($.allowPaths,J,Q,X),protectedGitMetadata:$.protectedGitMetadata,pathCanonicalizationContext:X}}function e1($,J,Q={}){let X=Q.targetIsLiteral??!1;if(!X&&J.tmpdirWordSplittingUnsafe&&!Q.tmpdirWordSplittingProtected&&F_($))return{kind:"outside_anchored_cwd"};let Y=!X&&JU($,J.posixShell);if(G2($))return{kind:"outside_anchored_cwd"};if(VQ($,X))return{kind:"root_or_home_target"};if(H_($,J))return{kind:"root_or_home_target"};if(J.resolvedCwd&&_2($,J.resolvedCwd,J.protectedGitMetadata,!0,J.pathCanonicalizationContext,!J.posixShell))return{kind:"git_metadata_target"};if(Z_($,J.trustTmpdirVar,J.posixShell,Y,X,Q.tmpdirWordSplittingProtected??!1,J.trustedTmpdirValue,J.environment))return{kind:"temp_target"};if(Y)return{kind:"dynamic_target"};if(N_($,J,X))return{kind:"temp_target"};let W=J.anchoredCwd;if(W){if(!Q.skipHomeCwd&&z_(W,J.environment.home,J.environment.paths,J.pathCanonicalizationContext))return{kind:"home_cwd_target"};if(!Q.skipCwdSelf&&I_($,J.resolvedCwd??W,J.environment.paths,J.pathCanonicalizationContext))return{kind:"cwd_self_target"};if(j_($,W,J.resolvedCwd??W,Y,X,J.environment.paths,J.pathCanonicalizationContext))return{kind:"within_anchored_cwd"}}return{kind:"outside_anchored_cwd"}}function eq($,J,Q={}){let{containmentTarget:X,...Y}=Q;if(e1($,J,Y).kind!=="temp_target")return!1;let W=$.trim();if(O_(W))return!1;if(gB(W,J.environment))return!1;return![J.anchoredCwd,J.resolvedCwd].some((K)=>R_(X??W,K,J.environment.paths,J.pathCanonicalizationContext))}function VQ($,J=!1){let Q=$.trim(),X=tq.normalize(Q),Y=Q.replace(/\\/g,"/"),W=X==="/"?X:X.replace(/\/+$/,"");if(W==="/"||W.startsWith("/")&&W.slice(1).split("/").every((K)=>/^\*+$/.test(K)))return!0;if(/^[A-Za-z]:\/+\*?$/.test(Y)||/^\/\/[^/]+\/+[^/]+(?:\/+\*?)?$/.test(Y))return!0;if(!J&&(X==="~"||X==="~/"||X==="~/*"))return!0;if(!J&&(X==="$HOME"||X==="$HOME/"||X==="$HOME/*"))return!0;if(!J&&(X==="${HOME}"||X==="${HOME}/"||X==="${HOME}/*"))return!0;return!1}function H_($,J){let Q=$.trim(),X=Q.endsWith("/*")?Q.slice(0,-2):Q;if(!X)return!1;try{let Y=FQ(X)?X:J.resolvedCwd?Q4(J.resolvedCwd,X):null;if(!Y)return!1;let W=j1(J1(Y,J.environment.paths,J.pathCanonicalizationContext));if(W===K_(W).root)return!0;return W===j1(J1(J.environment.home,J.environment.paths,J.pathCanonicalizationContext))}catch{return!1}}function j1($){let J=W_($);if(B_){if(J=J.replace(/\//g,"\\").toLowerCase(),J.length>3&&J.endsWith("\\"))J=J.slice(0,-1);return J}if(J.length>1&&J.endsWith("/"))J=J.slice(0,-1);return J}function Z_($,J,Q,X,Y,W,K,B){let q=$.trim();if($U(q))return!1;if(!X&&yJ(q,B))return!0;return(J||W&&K)&&Q&&!Y&&L_(q,Q)}function L_($,J){return["$TMPDIR","${TMPDIR}"].some((Q)=>{if($===Q)return!0;if(!$.startsWith(`${Q}/`))return!1;return!JU($.slice(Q.length+1),J)})}function O_($){let J=/^(?:\$TMPDIR|\$\{TMPDIR\})(?:\/(.*))?$/.exec($);if(!J)return!1;return tq.normalize(`/${J[1]??""}`)==="/"}function $U($){return $.split(/[\\/]+/).includes("..")}function M_($,J,Q,X){if(!$?.length)return[];return $.flatMap((Y)=>{let W=M3(Y.trim(),J);if(!FQ(W))return[];try{let K=J1(W,Q,X);if(w9(K,J1(J,Q,X)))return[];return[j1(K)]}catch{return[]}})}function N_($,J,Q){if(J.allowRoots.length===0)return!1;let X=$.trim();if($U(X))return!1;let Y=Q?X:M3(X,J.environment.home),W=J.resolvedCwd??J.anchoredCwd,K=FQ(Y)?Y:W?Q4(W,Y):null;if(!K)return!1;try{let B=j1(J1(K,J.environment.paths,J.pathCanonicalizationContext));return J.allowRoots.some((q)=>B===q||B.startsWith(q.endsWith(NQ)?q:`${q}${NQ}`))}catch{return!1}}function F_($){return/\$(?:TMPDIR(?![A-Za-z0-9_])|\{TMPDIR\})/.test($)}function JU($,J=!1){return $.includes("$")||$.includes("`")||V_($)||J&&__($)}function V_($){let J=!1;for(let Q of $){if(J){J=!1;continue}if(Q==="\\"){J=!0;continue}if(Q==="*"||Q==="?"||Q==="[")return!0}return!1}function __($){let J=!1;for(let Q=0;Q<$.length;Q++){let X=$[Q];if(J){J=!1;continue}if(X==="\\"){J=!0;continue}if(X==="{"&&D_($,Q)||(X==="+"||X==="@"||X==="!")&&$[Q+1]==="(")return!0}return!1}function D_($,J){let Q=$.indexOf("}",J+1);if(Q===-1)return!1;let X=$.slice(J+1,Q);return X.includes(",")||X.includes("..")}function z_($,J,Q,X){try{return j1(J1($,Q,X))===j1(J1(J,Q,X))}catch{try{return j1($)===j1(J)}catch{return!1}}}function I_($,J,Q,X){if($==="."||$==="./"||$===".\\")return!0;try{return j1(J1(Q4(J,$),Q,X))===j1(J1(J,Q,X))}catch{try{return j1(Q4(J,$))===j1(J)}catch{return!1}}}function j_($,J,Q,X,Y,W,K){let B=Q??J;if(!Y&&($.startsWith("~")||$.startsWith("$HOME")||$.startsWith("${HOME}")))return!1;if(X)return!1;if($.startsWith("/")||/^[A-Za-z]:[\\/]/.test($))try{return MQ($,J,W,K)}catch{return!1}if($.startsWith("./")||$.startsWith(".\\")||!$.includes("/")&&!$.includes("\\"))try{return MQ(Q4(B,$),J,W,K)}catch{return!1}if($.startsWith("../"))return!1;try{return MQ(Q4(B,$),J,W,K)}catch{return!1}}function MQ($,J,Q,X){try{return QU(J1($,Q,X),J1(J,Q,X))}catch{return!1}}function R_($,J,Q,X){if(!J)return!1;try{return QU(J1(J,Q,X),J1($,Q,X))}catch{return!0}}function QU($,J){let Q=j1($),X=j1(J);return Q.startsWith(`${X}${NQ}`)||Q===X}var b_=new Set(["remove-item","ri","del","erase","rd","rm","rmdir"]),XU="PowerShell Remove-Item -Recurse -Force outside cwd is blocked. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",P_="PowerShell Remove-Item -Recurse -Force for non-temporary paths is blocked by the active safety policy. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",YU="PowerShell Remove-Item target contains variables or pipeline input that cannot be verified safely. Use literal paths within cwd.",WU="PowerShell Remove-Item targeting root or home directory is extremely dangerous and always blocked.",A_="PowerShell Remove-Item -Recurse -Force in home directory is dangerous. Change to a project directory first.",E_="PowerShell Remove-Item receives pipeline input that cannot be verified safely. Use explicit literal paths within cwd.";function KU($,J,Q,X=D2({...Q,allowPaths:Q.policy?.destructiveCommandAllowPaths})){return S_($.words.map((Y)=>({kind:"word",text:Y.text,dynamic:Y.provenance!=="literal"})),J,X,Q.policy)}function S_($,J,Q,X){let Y=$.filter((q)=>q.kind==="word"),W=T_(Y),K=Y[W];if(!K||!b_.has(u_(K.text)))return null;let B=C_(Y.slice(W+1));if(B.whatIfProtected)return null;if(q1(X,"powershell.remove-item-pipeline-dynamic-target",Q.strict)&&J&&(B.targets.length===0||B.recursive))return z("powershell.remove-item-pipeline-dynamic-target",E_);for(let q of B.targets)if(!G2(q.text)&&VQ(DQ(q.text)))return z(B.recursive&&B.force?"powershell.remove-item-recursive-force-root-or-home":"powershell.remove-item-root-or-home",WU);for(let q of B.targets)if(Q.resolvedCwd&&_2(DQ(q.text),Q.resolvedCwd,Q.protectedGitMetadata,B.recursive,Q.pathCanonicalizationContext,!0))return z("powershell.remove-item-git-metadata",p1);if(!B.recursive||!B.force)return null;if(q1(X,"powershell.remove-item-recursive-force-dynamic-target",Q.strict)&&(B.hasDynamicTarget||B.targets.length===0))return z("powershell.remove-item-recursive-force-dynamic-target",YU);for(let q of B.targets){let U=m_(e1(DQ(q.text),Q),Q,X);if(U)return U}return null}function C_($){let J=[],Q=!1,X=!1,Y=!1,W=!1,K=!1;for(let B=0;B<$.length;B++){let q=$[B];if(!q||q.kind!=="word")continue;if(w_(q))continue;if(K){J.push(_Q(q)),W=W||q.dynamic;continue}if(q.text==="--"){K=!0;continue}let U=f_(q.text);if(!U){J.push(_Q(q)),W=W||q.dynamic;continue}if(h_(U.name)){let G=U.value?v_(U.value,q):$[++B];if(G?.kind==="word")J.push(_Q(G)),W=W||G.dynamic;else W=!0;continue}if(k_(U.name)){Q=!0;continue}if(g_(U.name)){X=!0;continue}if(y_(U.name))Y=x_(U.value)}return{targets:J,recursive:Q,force:X,whatIfProtected:Y,hasDynamicTarget:W}}function T_($){let J=$[0];if(J?.kind==="word"&&J.text==="&"||J?.text===".")return $.length>1?1:0;return 0}function _Q($){return{text:$.kind==="word"?$.text:"",dynamic:$.kind==="word"&&$.dynamic}}function w_($){return $.kind==="word"&&$.text===","}function DQ($){let J=$.replace(/\\/g,"/"),Q=/^\$env:(?:userprofile|home)(?=$|\/)/i.exec(J);return Q?`$HOME${J.slice(Q[0].length)}`:J}function v_($,J){return{kind:"word",text:$,dynamic:J.kind==="word"&&(J.dynamic||$.includes("$"))}}function f_($){if(!$.startsWith("-")||$==="-")return null;let J=$.slice(1),Q=J.indexOf(":");if(Q===-1)return{name:J.toLowerCase()};return{name:J.slice(0,Q).toLowerCase(),value:J.slice(Q+1)}}function h_($){return"path".startsWith($)||"literalpath".startsWith($)}function k_($){return"recurse".startsWith($)}function g_($){return $.length>=2&&"force".startsWith($)}function y_($){return $==="wi"||"whatif".startsWith($)}function x_($){if($===void 0||$==="")return!0;let J=$.toLowerCase();return J==="$true"||J==="true"}function u_($){return $.toLowerCase()}function m_($,J,Q){switch($.kind){case"root_or_home_target":return z("powershell.remove-item-recursive-force-root-or-home",WU);case"git_metadata_target":return z("powershell.remove-item-git-metadata",p1);case"temp_target":return null;case"dynamic_target":if(!q1(Q,"powershell.remove-item-recursive-force-dynamic-target",J.strict))return null;return z("powershell.remove-item-recursive-force-dynamic-target",YU);case"home_cwd_target":return z("powershell.remove-item-recursive-force-home-cwd",A_);case"cwd_self_target":return z("powershell.remove-item-recursive-force-cwd-self",XU);case"within_anchored_cwd":if(!q1(Q,"powershell.remove-item-recursive-force-paranoid",J.paranoid))return null;return z("powershell.remove-item-recursive-force-paranoid",P_);case"outside_anchored_cwd":return z("powershell.remove-item-recursive-force-outside-cwd",XU)}}import{normalize as i9}from"path";var h1=new Set(["awk","gawk","nawk","mawk"]),l_=new Set(["-e","--source"]),p_=new Set(["-F","-v","--assign","--field-separator"]),BU=new Set(["-f","--file"]),c_=new Set(["print","printf","return"]),qU=[{selector:"-e",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"--source",kind:"inline-code",valueForm:"equals-or-separate"},{selector:"-f",kind:"program-file",valueForm:"attached-or-separate"},{selector:"--file",kind:"program-file",valueForm:"equals-or-separate"}],d_="Detected awk system(), pipe, or getline command with dynamic command that cannot be safely analyzed. Use a literal command or process the data without system(), pipes, or getline.";function h9($,J,Q){let X=!1;for(let Y of r_($)){let W=i_(Y,Q);if(!W)continue;for(let K of W.commands){let B=J(K);if(B)return B;if(K.includes("{}")||/[$`]/.test(K))X=!0}X||=W.dynamic}return X?z("awk.system-dynamic",d_):null}function IQ($){let J=[],Q=!1,X=!1,Y=!0,W=!0;for(let K=1;K<$.length;K++){let B=$[K];if(B===void 0)break;if(Y&&B==="--"){Y=!1;continue}if(Y&&l_.has(B)){Q=!0;let q=$[K+1];if(q!==void 0)J.push({tokenIndex:K+1,kind:"inline-code",value:q});else W=!1;K++;continue}if(Y&&B.startsWith("--source=")){Q=!0,J.push({tokenIndex:K,kind:"inline-code",value:B.slice(9)});continue}if(Y&&B.startsWith("-e")&&B.length>2){Q=!0,J.push({tokenIndex:K,kind:"inline-code",value:B.slice(2)});continue}if(Y&&(p_.has(B)||BU.has(B))){if(BU.has(B)){X=!0;let q=$[K+1];if(q!==void 0)J.push({tokenIndex:K+1,kind:"program-file",value:q});else W=!1}else if($[K+1]===void 0)W=!1;K++;continue}if(Y&&(B.startsWith("-F")||B.startsWith("-v")&&B.slice(2).includes("=")))continue;if(Y&&B.startsWith("-f")&&B.length>2){X=!0,J.push({tokenIndex:K,kind:"program-file",value:B.slice(2)});continue}if(Y&&(B.startsWith("--assign=")||B.startsWith("--field-separator=")))continue;if(Y&&B.startsWith("--file=")){X=!0,J.push({tokenIndex:K,kind:"program-file",value:B.slice(7)});continue}if(Y&&B.startsWith("-")&&B!=="-")continue;if(Y=!1,!Q&&!X)J.push({tokenIndex:K,kind:"main-program",value:B});return{sources:J,optionsOpen:!1}}return{sources:W?J:[],optionsOpen:Y&&W}}function V3($){return IQ($).sources}function r_($){return V3($).filter((J)=>J.kind!=="program-file").map((J)=>J.value)}function i_($,J){S1(J,$);let Q=$.includes("system")?jQ($,J):null,X=o_($,J);if(!Q&&!X)return null;return{dynamic:!!Q?.dynamic||!!X?.dynamic,commands:[...Q?.commands??[],...X?.commands??[]]}}function jQ($,J){S1(J,$);let Q=[],X=!1,Y=!1,W=0;while(W<$.length){let K=$[W];if(K==='"'||K==="'"){W=f9($,W,K)?.endIndex??W+1;continue}if(K==="#"){W=UU($,W+1);continue}if(K==="/"&&GU($,W)){W=HU($,W+1)??W+1;continue}if(!$.startsWith("system",W)){W++;continue}let B=W;if(W+=6,F3($[B-1])||F3($[W]))continue;let q=v9($,W);if($[q]!=="(")continue;q=v9($,q+1);let U=$[q];if(U!=='"'&&U!=="'"){X=!0,Y=!0;continue}let G=f9($,q,U);if(!G){X=!0,Y=!0;continue}if(q=v9($,G.endIndex),X=!0,$[q]!==")"){Y=!0,W=G.endIndex;continue}Q.push(G.value),W=q+1}if(!X)return null;return{dynamic:Y,commands:Q}}function o_($,J){S1(J,$);let Q=[],X=!1,Y=!1,W=0,K=0,B=null,q=null,U=0;while(W<$.length){let G=$[W];if(!G)break;if(G==='"'||G==="'"){let Z=f9($,W,G);if(Z&&U===K)q={...Z,startIndex:W};U=Z?.endIndex??W+1,W=Z?.endIndex??W+1;continue}if(G==="#"){W=UU($,W+1),K=W,B=null,q=null,U=W;continue}if(G==="/"&&GU($,W)){let Z=HU($,W+1);U=Z??W+1,W=Z??W+1;continue}if(`;
52
+ {}`.includes(G)){W++,K=W,B=null,q=null,U=W;continue}if(B===null&&(zQ($,W,"print")||zQ($,W,"printf")))B=W;if(G!=="|"||$[W-1]==="|"||$[W+1]==="|"){if(!/\s/.test(G))U=W+1;W++;continue}let H=$[W+1]==="&"?W+2:W+1,L=v9($,H);if(zQ($,L,"getline")){Y=!0;let Z=a_(K,q,U);if(Z===null)X=!0;else Q.push(Z);U=H,W=H;continue}if(e_(K,B)){Y=!0;let Z=s_($,L);if(!Z){X=!0,U=H,W=H;continue}if(!n_($,Z.endIndex)){X=!0,U=Z.endIndex,W=Z.endIndex;continue}Q.push(Z.value),U=Z.endIndex,W=Z.endIndex;continue}U=H,W++}if(!Y)return null;return{dynamic:X,commands:Q}}function F3($){return!!$&&/[A-Za-z0-9_]/.test($)}function v9($,J){let Q=J;while(/\s/.test($[Q]??""))Q++;return Q}function n_($,J){let Q=J;while(/[\t\f\v\r ]/.test($[Q]??""))Q++;let X=$[Q];return!X||`;
53
+ }#`.includes(X)}function f9($,J,Q){let X="",Y=!1;for(let W=J+1;W<$.length;W++){let K=$[W];if(!K)break;if(Y){let B=t_($,W);if(!B)return null;X+=B.value,W=B.endIndex,Y=!1;continue}if(K==="\\"){Y=!0;continue}if(K===Q)return{value:X,endIndex:W+1};X+=K}return null}function s_($,J){let Q=$[J];if(Q!=='"'&&Q!=="'")return null;return f9($,J,Q)}function a_($,J,Q){if(!J)return null;return J.startIndex>=$&&J.endIndex===Q?J.value:null}function t_($,J){let Q=$[J];if(!Q)return null;if(Q==="x"){let Y=$.slice(J+1,J+3);if(!/^[0-9A-Fa-f]{2}$/.test(Y))return null;return{value:String.fromCharCode(Number.parseInt(Y,16)),endIndex:J+2}}if(/[0-7]/.test(Q)){let Y=/^[0-7]{1,3}/.exec($.slice(J));if(!Y)return null;return{value:String.fromCharCode(Number.parseInt(Y[0],8)),endIndex:J+Y[0].length-1}}return{value:{a:"\x07",b:"\b",f:"\f",n:`
54
+ `,r:"\r",t:"\t",v:"\v"}[Q]??Q,endIndex:J}}function zQ($,J,Q){return $.startsWith(Q,J)&&!F3($[J-1])&&!F3($[J+Q.length])}function e_($,J){return J!==null&&J>=$}function UU($,J){let Q=$.indexOf(`
55
+ `,J);return Q===-1?$.length:Q+1}function GU($,J){let Q=$D($,J);if(Q===-1)return!0;if("{([,;!~=".includes($[Q]??""))return!0;let X=Q;while(F3($[X-1]))X--;return c_.has($.slice(X,Q+1))}function $D($,J){for(let Q=J-1;Q>=0;Q--)if(!/\s/.test($[Q]??""))return Q;return-1}function HU($,J){let Q=!1;for(let X=J;X<$.length;X++){let Y=$[X];if(!Y)break;if(Q){Q=!1;continue}if(Y==="\\"){Q=!0;continue}if(Y==="/")return X+1}return null}var ZU=new Set(["rm","find","xargs","parallel"]),JD=new Set(["sudo","env","command","builtin"]),QD=new Set(["git","busybox",...ZU,...H1,...AB,...h1]);function k9($,J){let Q=$[0];if(!Q||!J.transparentWrappers.includes(l(Q)))return null;let X=l(Q),Y=$[1]==="--"?2:1,W=XD($,Y,X,J),K=W[0];if(K===void 0)return null;return{wrapper:X,tokens:[...$.slice(K)],childIndex:K,alternativeChildIndices:W.slice(1)}}function XD($,J,Q,X){let Y=$[1]==="--",W=[];for(let K=J;K<$.length;K++){let B=$[K];if(!B)continue;if(l(B)!==Q&&YD(B,X))W.push(K);else if(a6.has(i(B)))break;if(Y)break}return W}function YD($,J){let Q=l($),X=i($);return X==="git"||Q==="busybox"||_3($)||ZU.has(Q)||J.transparentWrappers.includes(Q)||H1.has(X)||$==="$SHELL"||C1(X)||h1.has(X)||J.rules.some((Y)=>Y.command===Q)}function _3($){return JD.has($.toLowerCase())}function LU($){let J=i($);return QD.has(J)||C1(J)}function $0($,J){let Q=J.policy??{rules:[],transparentWrappers:[]};return RQ([...$],J.environment,J.cwd,J.cwd,new Map,new Map(J.envAssignments??[]),Q,{iterations:0},!1)}function*RQ($,J,Q,X,Y,W,K,B,q){let U=xJ($,J,Q,W);if(U.unverifiableEnvSplit)throw new L2;for(let[Z,O]of U.envAssignments)W.set(Z,O),Y.set(Z,O);let{tokens:G,cwd:H}=U;if(_3(G[0]??""))throw new m1;let L=k9(G,K);if(L){for(let Z of[L.childIndex,...L.alternativeChildIndices])OU(B),yield*RQ(Z===L.childIndex?L.tokens:[...G.slice(Z)],J,H,X,new Map(Y),new Map(W),K,B,!0);return}if(KD(G)){OU(B),yield*RQ([...G.slice(1)],J,H,X,Y,W,K,B,q);return}yield WD(G,H,X,Y,W,q)}function WD($,J,Q,X,Y,W){return{tokens:$,cwd:J===null?void 0:J??Q,wrapperCwd:J,wrapperEnvAssignments:X,envAssignments:Y,head:l($[0]??"").toLowerCase(),wrappedByTransparent:W}}function OU($){if($.iterations>=i2)throw new m1;$.iterations++}function KD($){return l($[0]??"").toLowerCase()==="busybox"&&$.length>1}function bQ($,J){let Q=[],X=J;while(X<$.length){let Y=$[X];if(Y===void 0||Y===":::")break;Q.push(Y),X++}return{markerIndex:X<$.length&&$[X]===":::"?X:-1,templateTokens:Q}}function v0($){let J=!1,Q=!1;for(let X of $){if(X==="--")break;if(X==="-r"||X==="-R"||PQ(X,"recursive"))J=!0;else if(X==="-f"||PQ(X,"force"))Q=!0;else if(X.startsWith("-")&&!X.startsWith("--")){if(X.includes("r")||X.includes("R"))J=!0;if(X.includes("f"))Q=!0}}return J&&Q}function MU($){let J=$.indexOf("--");return $.slice(1,J===-1?void 0:J).some((Q)=>PQ(Q,"recursive")||/^-[A-Za-z]+$/.test(Q)&&/[rR]/.test(Q.slice(1)))}function PQ($,J){return $.length>2&&$.startsWith("--")&&J.startsWith($.slice(2))}var BD="find -delete permanently removes files. Use -print first to preview.",qD="find -exec rm -rf is dangerous. Use explicit file list instead.",UD=new Set(["-exec","-execdir","-ok","-okdir"]),GD=new Map([...["-Bmin","-Bnewer","-Btime","-amin","-anewer","-atime","-cmin","-cnewer","-context","-ctime","-f","-flags","-fprint","-fprint0","-fls","-fstype","-gid","-group","-ilname","-iname","-inum","-ipath","-iwholename","-iregex","-links","-lname","-maxdepth","-mindepth","-mmin","-mnewer","-mtime","-name","-newer","-newerXY","-newermt","-path","-perm","-printf","-regex","-samefile","-size","-type","-uid","-used","-user","-wholename","-xattrname","-xtype"].map(($)=>[$,1]),["-fprintf",2]]);function g9($,J){let Q=$.map(h),X=HD($,Q,J);if(X)return X;if(x9(Q,1)&&!LD($,Q,J)){let K=k(z("find.delete",BD),J.policy);if(K)return K}let Y=J.derivedCommandWorkBudget??n6(),W=0;while(W<Q.length){let K=Q[W],B=s0(K??"");if(B>0){W+=B+1;continue}if(!f0(K)){W++;continue}K0(Y,Q.length-W-1);let q=D3(Q,W);W=q.nextIndex;let U=MD(q.tokens,J.environment);if(U){let Z=k(U,J.policy);if(Z)return Z}let G=K==="-execdir"||K==="-okdir",H=J.analyzeTokens?J.analyzeTokens(q.tokens,G?null:J.cwd):J.analyzeNested?J.analyzeNested(q.tokens.join(" "),{effectiveCwd:G?void 0:J.cwd,envAssignments:J.envAssignments}):null,L=H?.id.startsWith("custom.")?H:k(H,J.policy);if(L)return L}return null}function HD($,J,Q){if(!x9(J,1)&&!AQ(J,Q.environment))return null;let Y=y9($)??p(["."]),W=D2({...Q,allowPaths:Q.policy?.destructiveCommandAllowPaths,posixShell:!0});for(let K of Y){let B=N3(K);for(let q of B.expandedTargets??[h(K)]){let U=e1(q,W,{targetIsLiteral:B.expandedTargets!==void 0||B.targetIsLiteral,tmpdirWordSplittingProtected:B.tmpdirWordSplittingProtected});if(U.kind==="root_or_home_target")return z("rm.recursive-force-root-or-home","rm -rf targeting root or home directory is extremely dangerous and always blocked.");if(U.kind==="git_metadata_target")return z("find.delete-git-metadata",p1)}}if(ZD(J)&&W.resolvedCwd&&rq(Y.map(h),W.resolvedCwd,W.protectedGitMetadata,W.pathCanonicalizationContext))return z("find.delete-git-metadata",p1);return null}function AQ($,J){let Q=0;while(Q<$.length){if(!f0($[Q])){Q++;continue}let X=D3($,Q),Y=l1([...X.tokens],J),W=l(Y[0]??"").toLowerCase();if((W==="rm"||W==="rmdir")&&Y.some((K)=>K.includes("{}")))return!0;Q=X.nextIndex}return!1}function ZD($){return $.some((J,Q)=>{if(!["-name","-iname"].includes(J))return!1;return $[Q+1]?.toLowerCase()==="hooks"})}function LD($,J,Q){if(J.includes("-L")||J.includes("-f")||J.includes("-follow"))return!1;let X=y9($);if(!X)return!1;let Y=Q.envAssignments??new Map,W=gJ(Y,Q.environment),K=Q.trustedTmpdirValue??T0(Y,Q.environment),B=Q.allowTmpdirVar??!K3(Y,Q.environment),q=D2({environment:Q.environment,protectedGitMetadata:Q.protectedGitMetadata,cwd:Q.cwd,originalCwd:Q.originalCwd,strict:Q.strict,allowTmpdirVar:B&&K&&Boolean(W),allowPaths:Q.policy?.destructiveCommandAllowPaths,posixShell:!0,tmpdirWordSplittingUnsafe:Q.tmpdirWordSplittingUnsafe??B0(Y,Q.environment),trustedTmpdirValue:K});return X.every((U)=>{let G=N3(U);if(G.unsafeBraceExpansion)return!1;return(G.expandedTargets??[h(U)]).every((H)=>eq(H,q,{containmentTarget:OD(H,W),targetIsLiteral:G.expandedTargets!==void 0||G.targetIsLiteral,tmpdirWordSplittingProtected:G.tmpdirWordSplittingProtected}))})}function OD($,J){if(!J)return $;return $.replace(/^(?:\$TMPDIR|\$\{TMPDIR\})/,()=>J)}function y9($){let J=(Y)=>{let W=$[Y];return W?h(W):void 0},Q=1;while(J(Q)==="-H"||J(Q)==="-P")Q++;if(J(Q)==="--")Q++;let X=[];while(Q<$.length){let Y=J(Q),W=$[Q];if(!Y||!W||Y.startsWith("-")||["!","(",")"].includes(Y))break;X.push(W),Q++}return X.length>0?X:null}function MD($,J){let Q=l1([...$],J);if(Q.length===0)return null;let X=l(Q[0]??"");if(X==="busybox"&&Q.length>1)Q=Q.slice(1),X=l(Q[0]??"");if(X==="rm"&&v0(Q))return z("find.exec-rm-recursive-force",qD);return null}function D3($,J){let Q=J+1;while(Q<$.length&&$[Q]!==";"&&!($[Q]==="+"&&$[Q-1]==="{}"))Q++;return{tokens:$.slice(J+1,Q),nextIndex:Math.min(Q+1,$.length)}}function x9($,J){let Q=J;while(Q<$.length){let X=$[Q];if(!X){Q++;continue}if(f0(X)){Q=D3($,Q).nextIndex;continue}let Y=s0(X);if(Y>0){Q+=Y+1;continue}if(X==="-delete")return!0;Q++}return!1}function s0($){return GD.get($)??(/^-newer[A-Za-z]{2}$/.test($)?1:0)}function f0($){return $!==void 0&&UD.has($)}function z3($){let J=a1($,"posix");if(J.status!=="complete"||J.nodes.length!==1)return null;let Q=J.nodes[0];if(Q?.kind!=="command")return null;if(Q.redirections.length>0||Q.nested.length>0)return null;if(Q.words.some((X)=>X.provenance==="command-substitution"))return null;return Q.words.map((X)=>X.text)}var ND=5,EQ="Git aliases supplied through command-line or environment config can hide or execute commands. Run git without Git alias overrides, or ask the user to run it manually.";function R1($){let J=$.indexOf("--");if(J===-1)return{index:-1,before:$,after:[]};return{index:J,before:$.slice(0,J),after:$.slice(J+1)}}function FU($,J,Q){let X=_U($,J,Q),Y=FD(X.entries);if(Y.size===0)return{blockedReason:X.blockedReason,expanded:!1,tokens:$};let W=$,K=!1;for(let B=0;B<ND;B++){let{subcommand:q,rest:U}=J0(W),G=q?.toLowerCase();if(!G||!Y.has(G))return{blockedReason:X.blockedReason,expanded:K,tokens:W};let H=Y.get(G),L=ID(H);if(L===null||L.length===0)return{blockedReason:EQ,expanded:!0,tokens:W};W=["git",...L,...U],K=!0}return{blockedReason:EQ,expanded:!0,tokens:W}}function VU($,J,Q){return _U($,J,Q).entries.some((X)=>X.key.toLowerCase()==="core.sshcommand")}function J0($){if($.length===0)return{subcommand:null,rest:[]};let J=$[0];if((J?l(J).toLowerCase():null)!=="git")return{subcommand:null,rest:[]};let X=1;while(X<$.length){let Y=$[X];if(!Y)break;if(Y==="--"){let W=$[X+1];if(W&&!W.startsWith("-"))return{subcommand:W,rest:$.slice(X+2)};return{subcommand:null,rest:$.slice(X+1)}}if(Y.startsWith("-"))if(W0.has(Y))X+=2;else if(Y.startsWith("-c")&&Y.length>2)X++;else if(Y.startsWith("-C")&&Y.length>2)X++;else X++;else return{subcommand:Y,rest:$.slice(X+1)}}return{subcommand:null,rest:[]}}function FD($){let J=new Map;for(let Q of $){let X=Q.key.toLowerCase();if(!X.startsWith("alias."))continue;let Y=X.slice(6);if(Y!=="")J.set(Y,Q.value)}return J}function _U($,J,Q){if($.length===0)return{blockedReason:null,entries:[]};let X=$[0];if((X?l(X).toLowerCase():null)!=="git")return{blockedReason:null,entries:[]};let W=_D(J,Q);return{blockedReason:W.blockedReason,entries:[...W.entries,...VD($,J,Q)]}}function VD($,J,Q){let X=[],Y=1;while(Y<$.length){let W=$[Y];if(!W||W==="--"||!W.startsWith("-"))return X;if(W==="-c"){let K=SQ($[Y+1]);if(K)X.push(K);Y+=2;continue}if(W.startsWith("-c")&&W.length>2){let K=SQ(W.slice(2));if(K)X.push(K);Y++;continue}if(W==="--config-env"){let K=NU($[Y+1],J,Q);if(K)X.push(K);Y+=2;continue}if(W.startsWith("--config-env=")){let K=NU(W.slice(13),J,Q);if(K)X.push(K);Y++;continue}if(W0.has(W)){Y+=2;continue}Y++}return X}function _D($,J){let Q=DD($,J),X=zD($,J);return{blockedReason:Q===null||X===null?EQ:null,entries:[...Q??[],...X??[]]}}function DD($,J){let Q=u1("GIT_CONFIG_PARAMETERS",$,J);if(Q===void 0)return[];let X=[],Y=z3(Q);if(!Y)return null;for(let W of Y){let K=SQ(W);if(!K)return null;X.push(K)}return X}function zD($,J){let Q=x6($,J);if(Q.state==="absent")return[];if(Q.state==="invalid")return null;let X=[];for(let Y=0;Y<Q.count;Y++){let W=u1(`GIT_CONFIG_KEY_${Y}`,$,J)?.trim(),K=u1(`GIT_CONFIG_VALUE_${Y}`,$,J);if(!W||K===void 0)return null;X.push({key:W,value:K})}return X}function SQ($){if(!$)return null;let J=$.indexOf("=");return{key:(J===-1?$:$.slice(0,J)).trim(),value:J===-1?void 0:$.slice(J+1)}}function NU($,J,Q){let X=$?.indexOf("=")??-1;if(!$||X===-1)return null;return{key:$.slice(0,X).trim(),value:u1($.slice(X+1),J,Q)}}function ID($){let J=$?.trimStart();if(!J||J.startsWith("!"))return null;return z3(J)}var jD="git checkout -- discards uncommitted changes permanently. Use 'git stash' first.",RD="git checkout --force discards uncommitted changes. Use 'git stash' first.",bD="git checkout <ref> -- <path> overwrites working tree with ref version. Use 'git stash' first.",PD="git checkout --pathspec-from-file can overwrite multiple files. Use 'git stash' first.",AD="git checkout with multiple positional args may overwrite files. Use 'git switch' for branches or 'git restore' for files.",ED="git switch --discard-changes discards uncommitted changes. Use 'git stash' first.",SD="git switch --force discards uncommitted changes. Use 'git stash' first.",CD="git restore discards uncommitted changes. Use 'git stash' first, or use --staged to only unstage.",TD="git restore --worktree explicitly discards working tree changes. Use 'git stash' first.",wD="git reset --hard destroys all uncommitted changes permanently. Use 'git stash' first.",vD="git reset --merge can lose uncommitted changes. Use 'git stash' first.",fD="git clean -f removes untracked files permanently. Use 'git clean -n' to preview first.",hD="git push --force destroys remote history. Use --force-with-lease for safer force push.",kD="git push deletes remote refs. Ask the user to run it manually if deletion is intended.",gD="git push --mirror can force-update and delete remote refs. Ask the user to run it manually if mirror push is intended.",yD="git branch -D force-deletes without merge check. Use -d for safe delete.",xD="git rebase --abort discards rebase conflict resolutions. Use 'git status' first.",uD="git merge --abort discards merge conflict resolutions. Use 'git status' first.",mD="git tag -d permanently deletes tags. Ask the user to run it manually if deletion is intended.",lD="git reflog delete removes recovery history. Ask the user to run it manually if deletion is intended.",pD="git stash drop permanently deletes stashed changes. Consider 'git stash list' first.",cD="git stash clear deletes ALL stashed changes permanently. Use 'git stash list' to review; ask the user to run it manually if intended.",dD="git worktree remove --force can delete uncommitted changes. Remove --force flag.",DU=new Set(["-b","-B","--orphan","--conflict","--inter-hunk-context","--pathspec-from-file","--unified"]),zU=new Set(["--recurse-submodules","--track","-t"]),CQ=new Set(["-b","-B","-U"]),TQ=new Set(["-c","-C"]),rD=new Set(["--source","--conflict","--unified","--inter-hunk-context"]),iD=new Set(["-q","--quiet","--no-quiet","-f","--force","--no-force","-d","--detach","--no-detach","-m","--merge","--no-merge","-p","--patch","--no-patch","--guess","--no-guess","--overlay","--no-overlay","--ours","--theirs","--ignore-skip-worktree-bits","--no-ignore-skip-worktree-bits","--no-track","--overwrite-ignore","--no-overwrite-ignore","--ignore-other-worktrees","--no-ignore-other-worktrees","--progress","--no-progress","--pathspec-file-nul","--no-pathspec-file-nul","--no-recurse-submodules"]);function a($,J){let Q=$.split("=",1)[0]??$;return Q.length>=4&&J.startsWith(Q)&&Q.startsWith("--")&&Q.slice(2).length>=2}function jU($){let{subcommand:J,rest:Q}=J0($);if(!J)return null;switch(J.toLowerCase()){case"checkout":return z2(oD(Q));case"switch":return z2(nD(Q));case"restore":return z2(aD(Q));case"reset":return eD(Q);case"clean":return z2(Jz(Q));case"push":return I2(Qz(Q));case"branch":return I2(Wz(Q));case"stash":return I2(Gz(Q));case"worktree":return I2(Hz(Q));case"rebase":return z2(Kz(Q));case"merge":return z2(Bz(Q));case"tag":return I2(qz(Q));case"reflog":return I2(Uz(Q));default:return null}}function z2($){return $?{...$,localDiscard:!0}:null}function I2($){return $?{...$,localDiscard:!1}:null}function oD($){let{index:J,before:Q}=R1($),X=v1(Q,{shortOptsWithValue:CQ});if(Q.some((W)=>a(W,"--force"))||X.has("-f"))return z("git.checkout-force",RD);for(let W of $){if(W==="-b"||W==="-B"||W==="--orphan")return null;if(a(W,"--pathspec-from-file"))return z("git.checkout-pathspec-from-file",PD)}if(J!==-1){if(Q.some((K)=>!K.startsWith("-")))return z("git.checkout-ref-path",bD);return z("git.checkout-double-dash",jD)}if(sD($).length>=2)return z("git.checkout-ambiguous",AD);return null}function nD($){let{before:J}=R1($);if(J.some((X)=>a(X,"--discard-changes")))return z("git.switch-discard-changes",ED);let Q=v1(J,{shortOptsWithValue:TQ});if(J.some((X)=>a(X,"--force"))||Q.has("-f"))return z("git.switch-force",SD);return null}function sD($){let J=[],Q=0;while(Q<$.length){let X=$[Q];if(!X)break;if(X==="--")break;if(X.startsWith("-"))if(DU.has(X))Q+=2;else if(X.startsWith("--")&&X.includes("="))Q++;else if(zU.has(X)){let Y=$[Q+1];if(Y&&!Y.startsWith("-")&&(X==="--recurse-submodules"||X==="--track"||X==="-t"))if((X==="--recurse-submodules"?["checkout","on-demand"]:["direct","inherit"]).includes(Y))Q+=2;else Q++;else Q++}else if(X.startsWith("--")&&!iD.has(X)&&!DU.has(X)&&!zU.has(X))Q++;else Q++;else J.push(X),Q++}return J}function aD($){let J=tD($);if(J.isTerminal||!J.hasPathspec&&!J.hasPatch||!J.hasWorktree)return null;return J.hasExplicitLocation?z("git.restore-worktree",TD):z("git.restore-unstaged",CD)}function tD($){let J=!1,Q=!1,X=!0,Y=!1,W=(K)=>{if(!Y)X=!1,Y=!0;if(K!==void 0)X=K};for(let K=0;K<$.length;K++){let B=$[K];if(B===void 0)break;if(B==="--"){J||=K+1<$.length;break}if(B==="--pathspec-from-file"){J=!0,K++;continue}if(B.startsWith("--pathspec-from-file=")){J=!0;continue}if(B==="-h"||B==="--help"||B==="--version")return{hasPathspec:J,hasPatch:Q,hasWorktree:X,hasExplicitLocation:Y,isTerminal:!0};if(B==="--staged"){W();continue}if(B==="--no-staged"){W();continue}if(B==="--worktree"){W(!0);continue}if(B==="--no-worktree"){W(!1);continue}if(B==="--patch"){Q=!0;continue}if(B==="--no-patch"){Q=!1;continue}if(rD.has(B)){K++;continue}if(B.startsWith("--"))continue;if(B==="-"){J=!0;continue}if(!B.startsWith("-")){J=!0;continue}for(let q=1;q<B.length;q++){let U=B.charAt(q);if(U==="h")return{hasPathspec:J,hasPatch:Q,hasWorktree:X,hasExplicitLocation:Y,isTerminal:!0};if(U==="S"){W();continue}if(U==="W"){W(!0);continue}if(U==="p"){Q=!0;continue}if(U==="s"||U==="U"){if(q===B.length-1)K++;break}}}return{hasPathspec:J,hasPatch:Q,hasWorktree:X,hasExplicitLocation:Y,isTerminal:!1}}function eD($){let J=null;for(let Q of $){if(a(Q,"--hard")){J=z("git.reset-hard",wD);break}if(a(Q,"--merge")){J=z("git.reset-merge",vD);break}}if(!J)return null;return $z($)?I2(J):z2(J)}function $z($){for(let J of $){if(J==="--")return!1;if(!J.startsWith("-"))return!0}return!1}function Jz($){for(let Q of $)if(Q==="-n"||a(Q,"--dry-run"))return null;let J=v1($.filter((Q)=>Q!=="--"));if($.some((Q)=>a(Q,"--force"))||J.has("-f"))return z("git.clean-force",fD);return null}function Qz($){let{before:J,after:Q}=R1($),X=v1(J);if(J.some((K)=>a(K,"--mirror")))return z("git.push-mirror",gD);if(J.some((K)=>a(K,"--force"))||X.has("-f")||IU(J,Q).some(Xz))return z("git.push-force",hD);if(J.some((K)=>a(K,"--delete"))||X.has("-d")||IU(J,Q).some(Yz))return z("git.push-delete",kD);return null}function IU($,J){return[...$.filter((Q)=>Q!==""&&!Q.startsWith("-")),...J]}function Xz($){return $.startsWith("+")||$.includes(":+")}function Yz($){return $.length>1&&$.startsWith(":")}function Wz($){let{before:J}=R1($),Q=v1(J),X=Q.has("-D")||Q.has("-d")||J.some((W)=>a(W,"--delete")),Y=Q.has("-D")||Q.has("-f")||J.some((W)=>a(W,"--force"));if(X&&Y)return z("git.branch-force-delete",yD);return null}function Kz($){let{before:J}=R1($);return J.some((Q)=>a(Q,"--abort"))?z("git.rebase-abort",xD):null}function Bz($){let{before:J}=R1($);return J.some((Q)=>a(Q,"--abort"))?z("git.merge-abort",uD):null}function qz($){let{before:J}=R1($);return v1(J).has("-d")||J.some((X)=>a(X,"--delete"))?z("git.tag-delete",mD):null}function Uz($){return $[0]==="delete"?z("git.reflog-delete",lD):null}function Gz($){for(let J of $){if(J==="drop")return z("git.stash-drop",pD);if(J==="clear")return z("git.stash-clear",cD)}return null}function Hz($){let{before:J}=R1($);if(!J.includes("remove"))return null;let X=v1(J);if(J.some((Y)=>a(Y,"--force"))||X.has("-f"))return z("git.worktree-remove-force",dD);return null}import{execFileSync as Zz}from"child_process";import{existsSync as vQ,readFileSync as fQ}from"fs";import{dirname as Lz,isAbsolute as PU,join as wQ,resolve as AU}from"path";var Oz=["/usr/bin/git","/usr/local/bin/git","/opt/homebrew/bin/git","C:\\Program Files\\Git\\cmd\\git.exe","C:\\Program Files\\Git\\bin\\git.exe"];function EU($,J,Q,X){let Y=Mz($,J,Q);if(Y!==null)return Y;let W=Nz(J,Q);if(W!==null)return W;if(eK(Q))return!0;return Fz(X)}function Mz($,J,Q){let X=null,Y=1;while(Y<$.length){let W=$[Y];if(!W||W==="--")return X;if(!W.startsWith("-"))return X;if(W==="-c"){let K=RU($[Y+1]);if(K!==null)X=K;Y+=2;continue}if(W.startsWith("-c")&&W.length>2){let K=RU(W.slice(2));if(K!==null)X=K;Y++;continue}if(W==="--config-env"){let K=bU($[Y+1],J,Q);if(K!==null)X=K;Y+=2;continue}if(W.startsWith("--config-env=")){let K=bU(W.slice(13),J,Q);if(K!==null)X=K;Y++;continue}if(W0.has(W))Y+=2;else Y++}return X}function Nz($,J){if(u1("GIT_CONFIG_PARAMETERS",$,J)!==void 0)return!0;let Q=x6($,J);if(Q.state==="absent")return null;if(Q.state==="invalid")return!0;let X=null;for(let Y=0;Y<Q.count;Y++){let W=u1(`GIT_CONFIG_KEY_${Y}`,$,J),K=u1(`GIT_CONFIG_VALUE_${Y}`,$,J);if(!W?.trim()||K===void 0)return!0;let B=W.trim().toLowerCase();if(hQ(B))return!0;if(B!=="submodule.recurse")continue;X=I3(K)}return X}function Fz($,J=_z()){let Q=Vz($);if(Q===null||Q)return!0;if(J===null)return!0;try{let X=Zz(J,["config","--get","submodule.recurse"],{cwd:$,encoding:"utf8",env:Dz(process.env),stdio:["ignore","pipe","ignore"]}).trim();return I3(X)}catch(X){return!zz(X)}}function Vz($){let J=Iz($);if(J===null)return null;for(let Q of J){if(!vQ(Q))continue;if(bz(Q))return!0}return!1}function _z(){for(let $ of Oz)if(vQ($))return $;return null}function Dz($){let J={...$};for(let Q of Object.keys(J))if(a4(Q))delete J[Q];return J}function zz($){return typeof $==="object"&&$!==null&&"status"in $&&$.status===1}function Iz($){let J=$3($);if(J===null)return null;let Q=jz(J);if(Q===null)return null;let X=Rz(Q);if(X===null)return null;return[wQ(X,"config"),wQ(Q,"config.worktree")]}function jz($){try{let Q=fQ($,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(!Q.startsWith("gitdir:"))return $;let X=Q.slice(7).trim();if(X==="")return null;return PU(X)?X:AU(Lz($),X)}catch{return null}}function Rz($){let J=wQ($,"commondir");if(!vQ(J))return $;try{let Q=fQ(J,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(Q==="")return null;return PU(Q)?Q:AU($,Q)}catch{return null}}function bz($){let J;try{J=fQ($,"utf-8")}catch{return!0}let Q="",X=!1;for(let Y of J.split(/\r?\n/)){let W=Y.trim();if(W===""||W.startsWith("#")||W.startsWith(";"))continue;let K=W.match(/^\[([^\]]+)\]$/);if(K){Q=K[1]?.trim().toLowerCase()??"";continue}let B=W.indexOf("="),q=(B===-1?W:W.slice(0,B)).trim().toLowerCase(),U=B===-1?"true":W.slice(B+1).trim();if(Pz(Q)&&q==="path")return!0;if(Q==="submodule"&&q==="recurse")X=I3(U)}return X}function Pz($){return $==="include"||$.startsWith("includeif ")}function RU($){if(!$)return null;let J=$.indexOf("="),Q=(J===-1?$:$.slice(0,J)).toLowerCase();if(hQ(Q))return!0;if(Q!=="submodule.recurse")return null;let X=J===-1?"true":$.slice(J+1).toLowerCase();return I3(X)}function I3($){let J=$.toLowerCase();return J!=="false"&&J!=="no"&&J!=="off"&&J!=="0"}function bU($,J,Q){let X=$?.indexOf("=")??-1;if(!$||X===-1)return null;let Y=$.slice(0,X).toLowerCase();if(hQ(Y))return!0;if(Y!=="submodule.recurse")return null;let W=u1($.slice(X+1),J,Q);return W===void 0||I3(W)}function hQ($){return $==="include.path"||$.startsWith("includeif.")&&$.endsWith(".path")}function SU($,J,Q){if(!J.localDiscard||!Q.worktreeMode||XB(Q.env,Q.envAssignments))return null;let X=YB($,Q.cwd);if(!X.gitCwd||X.hasExplicitGitContext)return null;if(!WB(X.gitCwd))return null;if(Az($,Q,X.gitCwd))return null;return{originalReason:J.reason,gitCwd:X.gitCwd}}function Az($,J,Q){let{subcommand:X,rest:Y}=J0($),W=X?.toLowerCase();if(J.dynamicArguments||Ez(Y)||EU($,J.env,J.envAssignments,Q)||Tz(Y)||Sz(W,Y))return!0;return W==="clean"&&wz(Y)>1}function Ez($){return $.some((J)=>/[$*?[]/.test(J))}function Sz($,J){if($==="checkout"){let{before:Q}=R1(J),X=v1(Q,{shortOptsWithValue:CQ}),Y=Q.some((K)=>a(K,"--force"))||X.has("-f"),W=X.has("-B")||Q.some((K)=>K==="-B"||K.startsWith("-B"));return Y&&W}if($==="switch"){let{before:Q}=R1(J),X=v1(Q,{shortOptsWithValue:TQ}),Y=Q.some((K)=>a(K,"--force"))||Q.some((K)=>a(K,"--discard-changes"))||X.has("-f"),W=Q.some((K)=>K==="-C"||K.startsWith("-C")||Cz(K))||X.has("-C");return Y&&W}return!1}function Cz($){let J=$.split("=",1)[0]??$;return J==="--force-create"||J.length>=9&&"--force-create".startsWith(J)}function Tz($){return $.some((J)=>J.startsWith("--recurse-sub"))}function wz($){let J=0;for(let Q of $){if(Q==="--force"){J++;continue}if(Q.startsWith("-")&&!Q.startsWith("--")){for(let X of Q.slice(1))if(X==="f")J++}}return J}var vz="Git SSH environment overrides can execute arbitrary commands during network operations. Run git without GIT_SSH/GIT_SSH_COMMAND overrides, or ask the user to run it manually.",fz=new Set(["clone","fetch","pull","push","ls-remote","submodule"]);function X4($,J){return CU($.map(h),J)}function CU($,J,Q){let X=FU($,J.env,J.envAssignments),Y=J.policy?.destructiveCommandRuleOverrides["git.alias-config"]==="off";if(X.blockedReason&&!Y)return z("git.alias-config",X.blockedReason);let W=X.tokens;if((tK(J.envAssignments)||VU($,J.env,J.envAssignments))&&hz(W))return z("git.ssh-env",vz);let K=jU(W);if(!K)return null;if(X.expanded||X.blockedReason)return K;let B=SU($,K,J);if(!B)return K;return Q?.(B),null}function TU($,J){let Q=null;return{match:CU($.map(h),J,(Y)=>{Q=Y}),relaxation:Q}}function hz($){let{subcommand:J,rest:Q}=J0($),X=J?.toLowerCase();if(!X)return!1;if(fz.has(X))return!0;if(X==="archive")return R1(Q).before.some((Y)=>a(Y,"--remote"));return X==="remote"&&kz(Q)}function kz($){return $.find((J)=>!gz(J))?.toLowerCase()==="update"}function gz($){return $==="-v"||a($,"--verbose")||a($,"--no-verbose")}import{isAbsolute as AI}from"path";var wU="rm -rf outside cwd is blocked. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",yz="rm -rf for non-temporary paths is blocked by the active safety policy. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",xz="rm -rf target contains shell variables that cannot be verified safely. Use literal paths within cwd, /tmp, /var/tmp, or $TMPDIR.",fU="rm -rf targeting root or home directory is extremely dangerous and always blocked.",uz="rm -rf in home directory is dangerous. Change to a project directory first.";function Y4($,J){let Q=D2({...J,allowPaths:J.policy?.destructiveCommandAllowPaths,posixShell:!0}),X=$.map(h),Y=v0(X),W=MU(X),K=lz($);for(let B of K){let q=N3(B.word);if(Y&&q.unsafeBraceExpansion){let U=k(vU({kind:"outside_anchored_cwd"},Q,J.policy),J.policy);if(U)return U;continue}for(let U of q.expandedTargets??[B.text]){let G={targetIsLiteral:q.expandedTargets!==void 0||q.targetIsLiteral,tmpdirWordSplittingProtected:q.tmpdirWordSplittingProtected};if(!W&&Q.resolvedCwd&&_2(U,Q.resolvedCwd,Q.protectedGitMetadata,W,Q.pathCanonicalizationContext))return z("rm.git-metadata",p1);if(W&&!Y){let H=e1(U,Q,G);if(H.kind==="root_or_home_target")return z("rm.recursive-force-root-or-home",fU);if(H.kind==="git_metadata_target")return z("rm.git-metadata",p1);continue}if(!Y)continue;for(let H of mz(U,Q,G)){let L=vU(H,Q,J.policy),Z=k(L,J.policy);if(Z)return Z}}}return null}function mz($,J,Q){let X=e1($,J,Q);if(X.kind==="cwd_self_target")return[X,e1($,J,{...Q,skipCwdSelf:!0})];if(X.kind!=="home_cwd_target")return[X];let Y=e1($,J,{...Q,skipHomeCwd:!0});if(Y.kind!=="cwd_self_target")return[X,Y];return[X,Y,e1($,J,{...Q,skipHomeCwd:!0,skipCwdSelf:!0})]}function lz($){let J=[],Q=!1;for(let X of $.slice(1)){let Y=h(X);if(!Y)continue;if(Y==="--"){Q=!0;continue}if(Q){J.push({text:Y,word:X});continue}if(!Y.startsWith("-"))J.push({text:Y,word:X})}return J}function vU($,J,Q){switch($.kind){case"root_or_home_target":return z("rm.recursive-force-root-or-home",fU);case"git_metadata_target":return z("rm.git-metadata",p1);case"temp_target":return null;case"dynamic_target":if(!q1(Q,"rm.recursive-force-dynamic-target",J.strict))return null;return z("rm.recursive-force-dynamic-target",xz);case"home_cwd_target":return z("rm.recursive-force-home-cwd",uz);case"cwd_self_target":return z("rm.recursive-force-cwd-self",wU);case"within_anchored_cwd":if(q1(Q,"rm.recursive-force-paranoid",J.paranoid))return z("rm.recursive-force-paranoid",yz);return null;case"outside_anchored_cwd":return z("rm.recursive-force-outside-cwd",wU)}}var pz={bash:["O","o"],dash:["o"],ksh:["o"],sh:["o"],zsh:["o"]},kU=new Set(["--init-file","--rcfile"]),cz=["--init-file","--rcfile"],dz=new Map([["bash","BASH_ENV"],["dash","ENV"],["ksh","ENV"],["sh","ENV"]]);function Z0($){for(let J=1;J<$.length;J++){let Q=$[J];if(!Q)continue;if(Q==="-c")return hU($,J,!0);if(Q.startsWith("-")&&Q.includes("c")&&!Q.startsWith("--")){let X=hU($,J,!1);if(X!==null)return X}}return null}function c1($){let J=l($[0]??"").toLowerCase();if(J==="zsh"||J==="ksh")return L0($).syntaxCheck;let Q=!1;for(let X of $.slice(1)){if(X==="--")return Q;if(X.startsWith("+")&&!X.startsWith("++")){if(X.slice(1).includes("n"))Q=!1;continue}if(!X.startsWith("-")||X.startsWith("--"))return Q;let Y=X.slice(1);if(Y.includes("n"))Q=!0;if(Y.includes("c"))return Q}return Q}function hU($,J,Q){if($[J+1]==="--")return $[J+2]||null;let X=$[J+1];if(!X||!Q&&X.startsWith("-"))return null;return X}function gU($){let J=l($[0]??"").toLowerCase(),Q=rz($,J),X=dz.get(J)??null,Y=Q.argvSource?.kind!=="absent";return{argvSource:J==="bash"?Q.argvSource:null,argvSourceApplies:J==="bash"&&Q.interactive&&Q.argvSource?.kind==="literal",envName:X,envSourceApplies:Y&&(X==="BASH_ENV"?!Q.interactive:X==="ENV"&&Q.interactive)}}function rz($,J){let Q=L0($),X=Q.commandIndex??Q.scriptIndex??$.length,Y=[],W=!1,K=!0;for(let B=1;B<X;B++){let q=$[B];if(q===void 0||q==="--"||q==="-"||q[0]!=="-"&&q[0]!=="+")break;if(q.startsWith("--")){if(J==="bash"&&K?cz.find((L)=>q===L):void 0){let L=$[B+1];Y.push(L===void 0?{kind:"absent"}:{kind:"literal",value:L}),B++;continue}let H=q.split("=",1)[0]??q;if(J==="bash"&&kU.has(H)&&!q.includes("="))B++;continue}if(J==="bash")K=!1;let U=yU(J,q,$[B+1],"startup");if(U.interactive)W=q[0]==="-";B+=U.followingValues}return{argvSource:Y.at(-1)??null,interactive:W}}function yU($,J,Q,X){let Y=!1,W=0,K=!1,B=!1,q=!1;for(let U=1;U<J.length;U++){let G=J[U];if(G===void 0)break;if($==="ksh"&&G==="o"&&U+1<J.length){if(X==="argv"){let H=J.slice(U+1);if(J[0]==="-"&&(H==="c"||H[0]==="-"&&H.endsWith("c")))K=!0}break}if($==="ksh"&&G==="o"&&U+1===J.length&&(Q?.startsWith("-")||Q?.startsWith("+")))break;if($==="zsh"&&G==="o"&&U+1<J.length)break;if(X==="startup"&&G==="i")Y=J[0]==="-";if(X==="argv"&&J[0]==="-"&&G==="c")K=!0;if(X==="argv"&&G==="n")q=J[0]==="-";if(X==="argv"&&G==="s")B=J[0]==="-";if(!pz[$]?.includes(G))continue;if(U+1===J.length)W++;break}return{interactive:Y,followingValues:W,commandSelected:K,stdinMode:B,syntaxCheck:q}}function L0($){let J=l($[0]??"").toLowerCase(),Q=!1,X=!1,Y=!1;for(let W=1;W<$.length;W++){let K=$[W];if(K===void 0)break;if(K==="--"){let q=Q&&$[W+1]!==void 0?W+1:null;return{command:q===null?null:$[q]??null,commandIndex:q,scriptIndex:!Q&&!X&&$[W+1]!==void 0?W+1:null,readsStdinAsCommands:!Q&&(X||$[W+1]===void 0),syntaxCheck:Y}}if(K==="-"||K[0]!=="-"&&K[0]!=="+")return{command:Q?K:null,commandIndex:Q?W:null,scriptIndex:!Q&&!X&&K!=="-"?W:null,readsStdinAsCommands:!Q&&(X||K==="-"),syntaxCheck:Y};if(K.startsWith("--")){let q=K.split("=",1)[0]??K;if(J==="bash"&&kU.has(q)&&!K.includes("="))W++;continue}let B=yU(J,K,$[W+1],"argv");if(B.commandSelected)Q=!0;if(B.syntaxCheck)Y=!0;if(B.stdinMode)X=!0;W+=B.followingValues}return{command:null,commandIndex:null,scriptIndex:null,readsStdinAsCommands:!Q,syntaxCheck:Y}}var a0={kind:"none"},j2={kind:"dynamic"},iz=new Set(["<","<<","<<-","<<<","<&","<>"]),uU=/\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*))/g,oz=/^(?:[0-9]+|[@*])$/,nz=F2.maxWords,sz=F2.maxInputLength;function mU($){if(!$||l(i($.words[0]?.text??""))!=="printf")return;if($.words.some((Y)=>Y.provenance!=="literal"))return;let J=$.words.slice($.words[1]?.text==="--"?2:1),Q=J[0]?.text;if(Q===void 0)return"";let X=J.slice(1).map((Y)=>Y.text);if(Q==="%s")return X.join("");if(Q==="%s\\n"||Q===`%s
56
56
  `)return`${X.join(`
57
57
  `)}
58
58
  `;if(Q.includes("%")||/\\(?![\\nrt])/.test(Q))return;return Q.replaceAll("\\n",`
59
- `).replaceAll("\\r","\r").replaceAll("\\t","\t").replaceAll("\\\\","\\")}function W4($){let J=j3($[1])==="--"?2:1;if($.length<=J)return a0;let Q=$.slice(J);if(!Q.every(m9))return j2;return{kind:"literal",source:Q.map(h).join(" ")}}function lU($){let J=j3($[1])==="--"?2:1,Q=$[J],X=j3(Q);if(Q===void 0||$.length<=J+1||X==="-"||X===""||X==="-l"||X==="-p")return a0;if(!m9(Q))return j2;return{kind:"literal",source:X}}function u9($,J){let Q=nz($);if(Q===-1)return a0;let X=sz(J);if(!X)return a0;let Y=[],W=X.command?.length??0;for(let K of X.references){let B=tz(K,$,Q,X.ifs);if(!B)return j2;if(W+=B.reduce((q,U)=>q+U.length+3,0),Y.length+B.length>iz||W>oz)return j2;Y.push(...B)}if(X.command==="eval")return{kind:"literal",source:Y.join(" ")};if(Y.length===0||/\s/.test(Y[0]??""))return{kind:"literal",source:""};return{kind:"literal",source:[X.command,X.command&&X.optionTerminator?"--":null,...Y.map($I)].filter((K)=>K!==null).join(" ")}}function pU($,J,Q,X){if(!L0($.map(h)).readsStdinAsCommands)return a0;let Y=J.filter((W)=>(W.fd===void 0||W.fd===0)&&dz.has(W.operator)).at(-1);if(Y){if(Y.operator==="<<"||Y.operator==="<<-")return a0;if(Y.operator!=="<<<"||Y.target?.provenance!=="literal")return j2;return{kind:"literal",source:Y.target.text}}if(!Q)return a0;return X===void 0?j2:{kind:"literal",source:X}}function O0($){let J=L0($.map(h)).scriptIndex;if(J===null)return a0;let Q=$[J],X=j3(Q);return g6(Q,X)?{kind:"literal",source:X}:j2}function nz($){return L0($.map(h)).commandIndex??-1}function sz($){let J=/^IFS=(?:'([^']*)'|"([^"]*)"|([^;\s]*))\s*;\s*(.+)$/.exec($.trim()),Q=J?.[4]??$.trim(),X=/^(\.|bash|command|dash|exec|eval|ksh|sh|source|zsh)(?:\s+(--))?\s+(.+)$/.exec(Q),Y=(X?.[3]??Q).split(/\s+/).map(az);if(Y.length===0||Y.some((W)=>W===null))return null;return{command:X?.[1]??null,optionTerminator:X?.[2]!==void 0,references:Y.filter((W)=>!!W),ifs:J?J[1]??J[2]??J[3]??"":`
60
- `}}function az($){let J=/^"\$(?:([0-9]+|[@*])|\{([0-9]+|[@*])\})"$/.exec($),Q=/^\$(?:([0-9]+|[@*])|\{([0-9]+|[@*])\})$/.exec($),X=J??Q;if(!X)return null;let Y=X[1]??X[2];return{parameter:Y==="@"||Y==="*"?Y:Number(Y),quoted:J!==null}}function tz($,J,Q,X){let Y=J.slice(Q+2);if($.parameter==="@")return $.quoted?kQ(Y):ez(Y,X);if($.parameter==="*"){let B=kQ(Y);if(!B)return;let q=B.join(X[0]??"");return $.quoted?[q]:gQ(q,X)}let W=J[Q+1+$.parameter];if(W&&!m9(W))return;let K=j3(W);return $.quoted?[K]:gQ(K,X)}function kQ($){return $.every(m9)?$.map(h):void 0}function ez($,J){let Q=kQ($);if(!Q)return;let X=Q.map((Y)=>gQ(Y,J));return X.some((Y)=>Y===void 0)?void 0:X.flatMap((Y)=>Y??[])}function gQ($,J){if(["*","?","[","]"].some((Q)=>$.includes(Q)))return;if(J==="")return $===""?[]:[$];if(J===`
59
+ `).replaceAll("\\r","\r").replaceAll("\\t","\t").replaceAll("\\\\","\\")}function W4($){let J=j3($[1])==="--"?2:1;if($.length<=J)return a0;let Q=$.slice(J);if(!Q.every(m9))return j2;return{kind:"literal",source:Q.map(h).join(" ")}}function lU($){let J=j3($[1])==="--"?2:1,Q=$[J],X=j3(Q);if(Q===void 0||$.length<=J+1||X==="-"||X===""||X==="-l"||X==="-p")return a0;if(!m9(Q))return j2;return{kind:"literal",source:X}}function u9($,J){let Q=az($);if(Q===-1)return a0;let X=tz(J);if(!X)return a0;let Y=[],W=X.command?.length??0;for(let K of X.references){let B=$I(K,$,Q,X.ifs);if(!B)return j2;if(W+=B.reduce((q,U)=>q+U.length+3,0),Y.length+B.length>nz||W>sz)return j2;Y.push(...B)}if(X.command==="eval")return{kind:"literal",source:Y.join(" ")};if(Y.length===0||/\s/.test(Y[0]??""))return{kind:"literal",source:""};return{kind:"literal",source:[X.command,X.command&&X.optionTerminator?"--":null,...Y.map(QI)].filter((K)=>K!==null).join(" ")}}function pU($,J,Q,X){if(!L0($.map(h)).readsStdinAsCommands)return a0;let Y=J.filter((W)=>(W.fd===void 0||W.fd===0)&&iz.has(W.operator)).at(-1);if(Y){if(Y.operator==="<<"||Y.operator==="<<-")return a0;if(Y.operator!=="<<<"||Y.target?.provenance!=="literal")return j2;return{kind:"literal",source:Y.target.text}}if(!Q)return a0;return X===void 0?j2:{kind:"literal",source:X}}function O0($){let J=L0($.map(h)).scriptIndex;if(J===null)return a0;let Q=$[J],X=j3(Q);return g6(Q,X)?{kind:"literal",source:X}:j2}function az($){return L0($.map(h)).commandIndex??-1}function tz($){let J=/^IFS=(?:'([^']*)'|"([^"]*)"|([^;\s]*))\s*;\s*(.+)$/.exec($.trim()),Q=J?.[4]??$.trim(),X=/^(\.|bash|command|dash|exec|eval|ksh|sh|source|zsh)(?:\s+(--))?\s+(.+)$/.exec(Q),Y=(X?.[3]??Q).split(/\s+/).map(ez);if(Y.length===0||Y.some((W)=>W===null))return null;return{command:X?.[1]??null,optionTerminator:X?.[2]!==void 0,references:Y.filter((W)=>!!W),ifs:J?J[1]??J[2]??J[3]??"":`
60
+ `}}function ez($){let J=/^"\$(?:([0-9]+|[@*])|\{([0-9]+|[@*])\})"$/.exec($),Q=/^\$(?:([0-9]+|[@*])|\{([0-9]+|[@*])\})$/.exec($),X=J??Q;if(!X)return null;let Y=X[1]??X[2];return{parameter:Y==="@"||Y==="*"?Y:Number(Y),quoted:J!==null}}function $I($,J,Q,X){let Y=J.slice(Q+2);if($.parameter==="@")return $.quoted?kQ(Y):JI(Y,X);if($.parameter==="*"){let B=kQ(Y);if(!B)return;let q=B.join(X[0]??"");return $.quoted?[q]:gQ(q,X)}let W=J[Q+1+$.parameter];if(W&&!m9(W))return;let K=j3(W);return $.quoted?[K]:gQ(K,X)}function kQ($){return $.every(m9)?$.map(h):void 0}function JI($,J){let Q=kQ($);if(!Q)return;let X=Q.map((Y)=>gQ(Y,J));return X.some((Y)=>Y===void 0)?void 0:X.flatMap((Y)=>Y??[])}function gQ($,J){if(["*","?","[","]"].some((Q)=>$.includes(Q)))return;if(J==="")return $===""?[]:[$];if(J===`
61
61
  `)return $.trim().split(/\s+/).filter(Boolean);if(J.length!==1)return;return J===" "||J==="\t"||J===`
62
- `?$.trim().split(/\s+/).filter(Boolean):$.split(J).filter(Boolean)}function m9($){if(!$)return!0;return $.provenance==="unknown"?!/[$`]/.test(h($)):$.provenance==="literal"}function j3($){return $?h($):""}function $I($){return`'${$.replaceAll("'",`'"'"'`)}'`}function xQ($,J){return yQ(a1($,"posix"),J)}function K4($){return xQ($,new Set(Array.from($.matchAll(uU)).flatMap((J)=>{let Q=J[1]??J[2];return Q===void 0?[]:[Q]})))}function yQ($,J){if($.status==="invalid"||$.status==="limited")return!1;let Q=new Set(J);for(let X of $.nodes){if(X.kind==="group"){if(yQ(X.body,Q))return!0;continue}if(X.kind!=="command")continue;if(X.nested.some((Y)=>yQ(Y,Q))||cU(X.words,Q))return!0;WI(X,Q)}return!1}function cU($,J){let Q=$.findIndex((K)=>q0(K.text)===null);if(Q===-1)return!1;let X=$[Q];if(!X)return!1;if(R3(X,J))return!0;let Y=i(X.text);if(Y==="source"||Y==="."){let K=$[Q+1]?.text==="--"?Q+2:Q+1;return xU($[K],J)}if(H1.has(Y)){let K=$.slice(Q),B=L0(K.map((U)=>U.text)),q=B.commandIndex??B.scriptIndex;return!B.syntaxCheck&&q!==null&&xU(K[q],J)}let W=JI($,Q,J);if(W===null)return!1;if(W===-1)return!0;return cU($.slice(W),J)}function JI($,J,Q){let X=i($[J]?.text??"");if(X==="command")return QI($,J+1);if(X==="exec")return XI($,J+1);if(X==="env")return YI($,J+1,Q);return null}function QI($,J){for(let Q=J;Q<$.length;Q++){let X=$[Q]?.text??"";if(X==="--")return $[Q+1]?Q+1:null;if(/^-[p]*[vV][pvV]*$/.test(X))return null;if(/^-p+$/.test(X))continue;return Q}return null}function XI($,J){for(let Q=J;Q<$.length;Q++){let X=$[Q]?.text??"";if(X==="--")return $[Q+1]?Q+1:null;if(X==="-a"){Q++;continue}if(/^-a.+/.test(X)||/^-[cl]+$/.test(X))continue;return Q}return null}function YI($,J,Q){for(let X=J;X<$.length;X++){let Y=$[X],W=Y?.text??"";if(W==="--")return $[X+1]?X+1:null;if(W==="-S"||W==="--split-string")return R3($[X+1],Q)?-1:X+2;if(W.startsWith("-S")||W.startsWith("--split-string="))return R3(Y,Q)?-1:X+1;if(W==="-u"||W==="--unset"||W==="-C"||W==="--chdir"||W==="-P"){X++;continue}if(W==="-i"||W==="-0"||W==="--null"||W.startsWith("-u=")||W.startsWith("--unset=")||W.startsWith("-C")||W.startsWith("--chdir=")||W.startsWith("-P"))continue;if(W.startsWith("-"))continue;if(q0(W))continue;return X}return null}function WI($,J){if(!$.words.every((Q)=>q0(Q.text)!==null))return;for(let Q of $.words){let X=q0(Q.text);if(!X)continue;if(R3(Q,J))J.add(X.name)}}function R3($,J){if(!$)return!1;return $.parts.filter((Q)=>Q.provenance==="variable").some((Q)=>Array.from(Q.raw.matchAll(uU)).some((X)=>{let Y=X[1]??X[2];return Y!==void 0&&(rz.test(Y)||J.has(Y))}))}function xU($,J){return!!$&&($.parts.some((Q)=>Q.provenance!=="literal"&&Q.provenance!=="variable")||R3($,J))}var KI=new Set(["-c","-C","--git-dir","--work-tree","--namespace","--config-env"]),BI=new Set(["-c","-H","-l","--config","--context","--host","--log-level","--tlscacert","--tlscert","--tlskey"]),qI=new Set;function dU($){if($==="git")return KI;if($==="docker")return BI;return qI}function O1($,J){if($.length===0||J.length===0)return null;let Q=i($[0]??""),X=v1($);for(let Y of J){if(!UI(Q,Y.command))continue;if(!GI(Q,$,Y.subcommand))continue;if(ZI($,new Set(Y.block_args),X))return{id:`custom.${Y.name}`,reason:`[${Y.name}] ${Y.reason}`,intent:Y.intent??"manual_only"}}return null}function UI($,J){return $===i(J)}function GI($,J,Q){if(!Q)return!0;return rU(J,1,Q,dU($))}function rU($,J,Q,X){let Y=!1;for(let W=J;W<$.length;W++){let K=$[W];if(!K)continue;if(Y){Y=!1;continue}if(K==="--"){let B=$[W+1];if(B&&!B.startsWith("-"))return B===Q;return!1}if(X.has(K)){Y=!0;continue}if(K.startsWith("-")){if(!K.includes("=")&&HI($,W,Q,X))return!0;continue}return K===Q}return!1}function HI($,J,Q,X){let Y=$[J+1];if(!Y||Y.startsWith("-"))return!1;return rU($,J+2,Q,X)}function ZI($,J,Q){for(let X of $)if(J.has(X))return!0;for(let X of Q)if(J.has(X))return!0;return!1}function t0($,J,Q={}){if($.length===0)return null;let X=$[0];if(!X)return null;let Y=i(X);if(Y==="eval"){let W=W4(p($));if(W.kind==="dynamic")return B4(Q,J);if(W.kind==="literal"&&J.analyzeNested){let K=J.analyzeNested(W.source,{effectiveCwd:J.cwd,envAssignments:J.envAssignments});if(K)return K}return M0(Q,J)}if(H1.has(Y)){if(c1($))return null;let W=Z0($);if(W){if(Q.dynamicSourceInput??Q.dynamicInput){let q=B4(Q,J);if(q)return q}if(K4(W)){let q=B4(Q,J);if(q)return q}if(!J.analyzeNested)return null;let B=J.analyzeNested(W,{effectiveCwd:J.cwd,envAssignments:J.envAssignments});if(B)return B;return null}let K=O0(p($));if(K.kind==="dynamic")return B4(Q,J);if(K.kind==="literal"){if(Q.dynamicSourceInput)return B4(Q,J);return null}if(Q.dynamicSourceInput??Q.dynamicInput)return B4(Q,J);return null}if(h1.has(Y))return k(h9($,(W)=>J.analyzeNested?J.analyzeNested(W,{effectiveCwd:J.cwd,envAssignments:J.envAssignments}):null),J.policy)??O1($,J.policy?.rules??[])??M0(Q,J);if(C1(Y)){let W=e6($);if(!W)return M0(Q,J);if(q1(J.policy,"interpreter.one-liner-paranoid",!!J.paranoidInterpreters)){let B=k(z("interpreter.one-liner-paranoid",n2),J.policy);if(B)return B}if(Q9(Y,W))return M0(Q,J);let K=J.analyzeNested?.(W,{effectiveCwd:J.cwd,envAssignments:J.envAssignments});if(K&&K.id!=="raw-text.dangerous-command"&&(K.reason!==r0||$4(W)))return K;if(s2(W,J.scanWork))return k(z("interpreter.dangerous-command",M2),J.policy)??M0(Q,J);return M0(Q,J)}if(Y==="rm"||Y==="rmdir"){let W=Y==="rm"&&(w0($)||Q.dynamicRmInput);return k(Y4(p($),{environment:J.environment,cwd:J.cwd,originalCwd:J.originalCwd,strict:J.strict,paranoid:J.paranoidRm,allowTmpdirVar:J.allowTmpdirVar,tmpdirWordSplittingUnsafe:B0(J.envAssignments,J.environment),trustedTmpdirValue:C0(J.envAssignments,J.environment),protectedGitMetadata:J.protectedGitMetadata,policy:J.policy}),J.policy)??(W&&Q.dynamicRmInput?M0(Q,J):null)??(W?LI(Q,J):null)}if(Y==="find")return g9(p($),{...J,derivedCommandWorkBudget:J.derivedCommandWorkBudget,analyzeTokens:(W,K)=>t0(W,{...J,cwd:K??void 0,derivedCommandWorkBudget:J.derivedCommandWorkBudget},Q)})??O1($,J.policy?.rules??[])??M0(Q,J);if(Y==="git")return k(X4(p($),{env:J.environment.env,cwd:J.cwd,envAssignments:J.envAssignments,policy:J.policy,worktreeMode:Q.dynamicInput?!1:J.worktreeMode}),J.policy)??O1($,J.policy?.rules??[])??M0(Q,J);return O1($,J.policy?.rules??[])??M0(Q,J)}function B4($,J){return $.shellDynamicMatch?k($.shellDynamicMatch,J.policy):null}function M0($,J){return $.dynamicSourceInput&&$.dynamicSourceMatch?k($.dynamicSourceMatch,J.policy):null}function LI($,J){return $.dynamicInput&&$.rmDynamicMatch?k($.rmDynamicMatch,J.policy):null}var uQ="xargs rm -rf with dynamic input is dangerous. Use explicit file list instead.",mQ="xargs dynamic input can supply arbitrary executable command source. Use an explicit child command and arguments instead.",OI="__CC_SAFETY_NET_XARGS_INPUT__",l9="__CC_SAFETY_NET_XARGS_INTERPRETER_INPUT__",p9="rm",MI=/(?:^|[;&|]\s*|\b(?:eval|source)\s+|\b(?:ba|da|z|k)?sh\s+-c\s+)\s*["']?\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)(?:[^}]*)\})/g,NI=/(?:^|[;&|]\s*)\s*eval\b((?:\\.|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\\'";&|\r\n])*)/g,FI=/\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)(?:[^}]*)\})/g,VI=/^(?:[0-9]+|[@*])$/,_I=new Set(["branch","checkout","clean","push","reset","restore","switch","tag"]);function nU($,J){let Q=$.map(h),{childStart:X,replacementToken:Y}=R2(Q),W=Q.slice(X),K=z("xargs.shell-dynamic",mQ);if(zI(W,Y,J)&&k(K,J.policy))return k(K,J.policy);for(let B of $0(W,J)){let q=B.tokens,U=Y!==null&&q[0]!==W[0]&&(q[0]?.includes(Y)??!1)?k(K,J.policy):null;if(U)return U;let G=eU(q,Y,B.wrapperEnvAssignments),H=B.head==="rm"&&Y!==null&&aU(q,Y),L=t0(q,{...J,cwd:B.cwd,envAssignments:B.envAssignments},{dynamicInput:G,dynamicSourceInput:H||sU(q,B.head,Y,B.wrapperEnvAssignments,G,J.scanWork,J.environment),dynamicRmInput:H,shellDynamicMatch:K,dynamicSourceMatch:K,rmDynamicMatch:z("xargs.rm-recursive-force-dynamic",uQ)});if(L)return L;let Z=DI(q,Y,J.policy?.rules??[]);if(Z)return Z;if(B.head==="git"){let M=Y===null?[...q,OI]:q,V=Y!==null&&(q.some((b)=>b.includes(Y))||Array.from(B.envAssignments.values()).some((b)=>b.includes(Y))),F=t0(M,{...J,cwd:B.cwd,envAssignments:B.envAssignments,worktreeMode:Y===null||V?!1:J.worktreeMode});if(F)return F}let O=O1(q,J.policy?.rules??[]);if(O)return O}return null}function DI($,J,Q){if(Q.length===0)return null;if(J===null){for(let Y of Q){let W=O1([...$,...Y.subcommand?[Y.subcommand]:[],...Y.block_args],Q);if(W)return W}return null}let X=new Set(Q.flatMap((Y)=>[Y.subcommand,...Y.block_args].flatMap((W)=>W?$.flatMap((K)=>lQ(K,J,W)):[])));for(let Y of X){let W=O1($.map((K)=>K.replaceAll(J,Y)),Q);if(W)return W}return null}function lQ($,J,Q){let X=$.indexOf(J);if(X===-1||$.indexOf(J,X+J.length)!==-1)return[];let Y=$.slice(0,X),W=$.slice(X+J.length);return Q.startsWith(Y)&&Q.endsWith(W)?[Q.slice(Y.length,Q.length-W.length)]:[]}function sU($,J,Q,X,Y,W,K){if(H1.has(J)){if(c1($))return!1;if(Q!==null&&II($,Q))return!0;let B=Z0($);if(!B){let q=O0(p($));if(q.kind==="literal")return Q!==null&&q.source.includes(Q);return q.kind==="none"&&Y}if(Q!==null&&B.includes(Q))return!0;if(Y3(B,W))return!0;return jI(B,Q,X)}if(C1(J))return iU($,Q,J9,CB(J));if(h1.has(J))return iU($,Q,IQ,qU);if(J==="eval"){let B=W4(p($));if(B.kind==="dynamic")return!0;if(Q!==null)return B.kind==="literal"&&B.source.includes(Q);return Y}if(J==="find")return RI($,Q,W,K);if(J==="git"){let B=J0($);return Q===null?B.subcommand===null:(B.subcommand?.includes(Q)??!1)||B.subcommand!==null&&_I.has(B.subcommand.toLowerCase())&&tU(B.rest,Q).some((q)=>q.includes(Q))}return!1}function iU($,J,Q,X){let Y=Q($);if(J===null)return Y.optionsOpen||Q([...$,l9]).sources.some((q)=>q.value===l9);if(Y.sources.some((q)=>q.value.includes(J)))return!0;let W=new Set(Y.sources.map((q)=>`${q.tokenIndex}\x00${q.kind}\x00${q.value}`)),K=X.flatMap((q)=>[q.selector,...q.valueForm==="attached-only"||q.valueForm==="attached-or-separate"?[`${q.selector}${l9}`]:[],...q.valueForm==="equals-or-separate"?[`${q.selector}=${l9}`]:[]]),B=new Set(K.flatMap((q)=>$.flatMap((U)=>lQ(U,J,q))));return Array.from(B).some((q)=>Q($.map((U)=>U.replaceAll(J,q))).sources.some((U)=>!W.has(`${U.tokenIndex}\x00${U.kind}\x00${U.value}`)))}function zI($,J,Q){if($.length===0||($[0]??"").toLowerCase()==="command")return!1;let X=new Set(Array.from($0($,Q),(W)=>W.head)),Y=J===null?[...$,p9]:$.map((W,K)=>K===0?W:W.replaceAll(J,p9));return Array.from($0(Y,Q)).some((W)=>W.head===p9&&!X.has(p9))}function aU($,J){return tU($.slice(1),J).some((Q)=>Q.includes(J)&&(Q.startsWith("-")||Q.startsWith(J)))}function tU($,J){let Q=$.findIndex((X)=>X==="--"&&!X.includes(J));return Q===-1?$:$.slice(0,Q)}function eU($,J,Q){if(J===null)return!0;return $.some((X)=>X.includes(J))||Array.from(Q.values()).some((X)=>X.includes(J))}function II($,J){let Q=L0($);if(Q.commandIndex!==null&&($[Q.commandIndex]??"").includes(J)||Q.scriptIndex!==null&&($[Q.scriptIndex]??"").includes(J))return!0;return["-c","-nc","-cn",`--${J}`,J].some((Y)=>$.some((W,K)=>{if(K===0||!W.includes(J))return!1;return lQ(W,J,Y).some((q)=>{let U=$.map((H,L)=>L===K?H.replaceAll(J,q):H),G=L0(U);if(G.commandIndex===null&&G.scriptIndex===null)return!1;if(Q.commandIndex===null&&G.commandIndex!==null)return!0;if(Q.scriptIndex===null&&G.scriptIndex!==null)return!0;if(G.commandIndex!==null&&(U[G.commandIndex]??"").includes(q))return!0;return G.scriptIndex!==null&&(U[G.scriptIndex]??"").includes(q)})}))}function jI($,J,Q){let X=new Set(J===null?[]:Array.from(Q).filter(([,Y])=>Y.includes(J)).map(([Y])=>Y));for(let Y of $.matchAll(MI))if(oU(Y,X))return!0;for(let Y of $.matchAll(NI))for(let W of(Y[1]??"").matchAll(FI))if(oU(W,X))return!0;return xQ($,X)}function oU($,J){let Q=$[1]??$[2];return Q!==void 0&&(VI.test(Q)||J.has(Q))}function RI($,J,Q,X){if(J===null)return!0;let Y=!1,W=0;for(let K=1;K<$.length;K++){let B=$[K]??"";if(!Y&&!B.startsWith("-")&&B!=="!"&&B!=="("){if(B.indexOf(J)===0)return!0;continue}if(Y=!0,W>0){W--;continue}if(v0(B)){let U=D3($,K);K=U.nextIndex-1;for(let G of $0(U.tokens,{environment:X,cwd:void 0})){let H=eU(G.tokens,J,G.wrapperEnvAssignments);if(G.head==="rm"&&aU(G.tokens,J)||sU(G.tokens,G.head,J,G.wrapperEnvAssignments,H,Q,X))return!0}continue}let q=s0(B);if(q>0){if(W=q,B.includes(J))return!0;continue}if(B.includes(J))return!0}return!1}function R2($){let J=new Set(["-L","-n","-P","-s","-a","-E","-R","-S","-e","-d","-J","--max-args","--max-procs","--max-chars","--arg-file","--eof","--delimiter","--max-lines","--process-slot-var"]),Q=null,X=1;while(X<$.length){let Y=$[X];if(!Y)break;if(Y==="--")return{childStart:X+1,replacementToken:Q};if(Y.startsWith("-")){if(Y==="-I"){Q=$[X+1]??"{}",X+=2;continue}if(Y.startsWith("-I")&&Y.length>2){Q=Y.slice(2),X++;continue}if(Y==="--replace"){Q="{}",X++;continue}if(Y.startsWith("--replace=")){let W=Y.slice(10);Q=W===""?"{}":W,X++;continue}if(Y==="-J"){Q=$[X+1]??"{}",X+=2;continue}if(J.has(Y))X+=2;else X++}else return{childStart:X,replacementToken:Q}}return{childStart:$.length,replacementToken:Q}}var b3="parallel rm -rf with dynamic input is dangerous. Use explicit file list instead.",P3="parallel with shell -c can execute arbitrary commands from dynamic input. Run the inner command directly on an explicit file list instead.",PI="parallel without a command reads executable commands from dynamic input. Use an explicit command template or ::: arguments instead.",AI="parallel command construction cannot be verified safely. Use the default ::: separator, literal arguments, and built-in replacement strings.",EI=/\{[^{}\s]*\}/,qG=/\{\}|\{-?\d+\}/g,SI=new Set(["branch","checkout","clean","merge","push","rebase","reflog","reset","restore","stash","switch","tag","worktree"]),CI=["e","f","source","file","-e","-f","--source","--file"],TI=["c","e","eval","m","r","Mmodule","import","require","-c","-e","-m","-r","--eval","--import","--require"],wI=new Set(["-L","-d","-n","--delay","--delimiter","--header","--joblog","--jl","--max-args","--max-lines","--nice","--results","--result","--res","--tagstring","--timeout"]),vI=new Set(["--arg-file","--colsep","--rpl","--arg-sep","--arg-file-sep"]),$G=new Set(["-S","--sshlogin","--slf","--sshloginfile"]),fI=new Set(["--workdir","--wd"]),JG="__CC_SAFETY_NET_PARALLEL_SOURCE__",hI=new TextEncoder,d9=f.maxDerivedBytes+4*f.maxPlaceholderReplacements;function _1($,J){for(let Q of $){let X=J(Q);if(X)return X}return null}function UG($,J){let Q=$.map(h);if((J.envAssignments?.has("PARALLEL")?J.envAssignments.get("PARALLEL"):J.environment.env.get("PARALLEL"))?.trim()){let M=P2(J);if(M)return M}if(Q.length===2&&(Q[1]==="--version"||Q[1]==="--help"))return null;let Y=zG(Q),{template:W,jobs:K,runsRemotely:B,envNames:q,readsCommandsFromInput:U,unsupported:G,workdir:H,dryRun:L}=Y;if(G){let M=P2(J);if(M)return M}if(U){let M=pI(J);if(M)return M}if(H!==void 0&&B){let M=P2(J);if(M)return M}let Z=oI(H,J.cwd,J.environment.paths);if(Z===null){let M=P2(J);if(M)return M}let O=B?{...J,cwd:void 0,originalCwd:void 0}:Z===null||Z===void 0||Z===J.cwd?J:{...J,cwd:Z};if(L){let M=[...$0(W,O)];if((M.length===0?dQ(q,J.envAssignments,new Map).values:M.flatMap((F)=>dQ(q,J.envAssignments,F.envAssignments).values)).some(oQ)){let F=P2(J);if(F)return F}return null}if(W.length===0){if(q.length>0||K.some((F)=>F.length!==1)){let F=P2(J);if(F)return F}let M=K.map((F)=>F[0]??"");T1(J.budget,cQ(M));let V=FG(O.envAssignments,O.cwd,B);return _1(M,(F)=>J.analyzeNested(F,V))}return _1($0(W,O),(M)=>kI(M,Y,J,O))}function kI($,J,Q,X){let{jobs:Y,templateHasPlaceholder:W,runsRemotely:K,usesStdin:B,envNames:q}=J,U=$.tokens,G={...X,cwd:$.cwd,envAssignments:$.envAssignments},H=dQ(q,Q.envAssignments,$.envAssignments);if(H.entries.some((F)=>_G(F.value))){let F=P2(Q);if(F)return F}let L=H.entries.some((F)=>F.hasPlaceholder),Z=W||L,O=B&&Z,M=FG($.envAssignments,$.wrapperCwd,K||O);if(H1.has($.head)){let F=()=>{if(!W||Y.length===0)return null;return T1(Q.budget,c9(U,Y,"generic")),_1(Y,(A)=>t0(U.map((E)=>N0(E,A)),G))};if(c1(U))return F();let b=Z0(U);if(b){if(DG(b)){let P=b2(Q);if(P)return P;if(Y.length===0)return null;return T1(Q.budget,KG(b,Y)),_1(Y,(S)=>Q.analyzeNested(N0(b,S),M))}if(s(b)){if(Y.length>0)return T1(Q.budget,KG(b,Y)),_1(Y,(T)=>Q.analyzeNested(N0(b,T),M));T1(Q.budget,YG(b));let P=z3(b);if(P?.[0]&&i(P[0])==="rm"&&w0(P)){let T=XG(Q);if(T)return T}let S=P?t0(P,G,{dynamicInput:B,shellDynamicMatch:z("parallel.shell-dynamic",P3),rmDynamicMatch:z("parallel.rm-recursive-force-dynamic",b3)}):null;if(S)return S;return Q.analyzeNested(b,M)}let A=!L&&(!W||Y.length>0)?(Y.length>0?Y:[void 0]).map((P)=>u9(p(P===void 0?U:W?U.map((S)=>N0(S,P)):[...U,...P]),b)):[];if(A.some((P)=>P.kind==="dynamic")){let P=b2(Q);if(P)return P}let E=A.flatMap((P)=>P.kind==="literal"?[P.source]:[]);if(E.length>0)return T1(Q.budget,cQ(E)),_1(E,(P)=>Q.analyzeNested(P,M));T1(Q.budget,dI(YG(b),cI(H.entries,Y)));let _=K4(b);if(_&&H.entries.length>0){let P=BG(H,Y,X,K);if(P)return P}if(_){let P=b2(Q);if(P)return P}let R=Q.analyzeNested(b,M);if(R)return R;if(!_){let P=BG(H,Y,X,K);if(P)return P}if(Z)return b2(Q);return null}let I=O0(p(U));if(I.kind==="dynamic"||I.kind==="literal"&&s(I.source))return b2(Q)??F();if(I.kind==="literal")return F();if(Y.length>0){let A=b2(Q);if(A)return A;let E=F();if(E)return E;if(W)return null;let _=Y.flatMap((R)=>R[0]===void 0?[]:[R[0]]);return T1(Q.budget,cQ(_)),_1(_,(R)=>Q.analyzeNested(R,M))}if(Z||B)return b2(Q)??F();return null}if($.head==="rm"&&w0(U)){if(W&&Y.length>0)return T1(Q.budget,c9(U,Y,"rm")),_1(Y,(b)=>pQ(U.map((I)=>rQ(I,b)),$.cwd,X));if(Y.length>0)return T1(Q.budget,WG(U,Y)),_1(Y,(b)=>pQ([...U,...b],$.cwd,X));let F=pQ(U.flatMap((b,I)=>{if(I===0||!s(b))return[b];return b.startsWith("-")?[rQ(b,[""])]:[]}),$.cwd,X);if(F)return F;return XG(Q)}T1(Q.budget,W&&Y.length>0?c9(U,Y,"generic"):Y.length>0?WG(U,Y):LG(U));let V=Y.length>0?Y:[void 0];return _1(V,(F)=>{let b=F===void 0?U:W?U.map((T)=>N0(T,F)):[...U,...F],I=z("parallel.shell-dynamic",P3),A=B&&$.head==="find"?lI(b,X):null,E=HG(b,B,Q.policy?.rules??[],Q.budget)??A?.customResult??null,_=i($.head),R=B&&(_==="rm"&&iQ(b)||_==="xargs"&&ZG(b)||A?.rmOptions===!0),P=B&&(R||A?.executedSource===!0||A===null&&GG(b,_)),S=t0(b,{...G,worktreeMode:K||B||Z?!1:Q.worktreeMode},{dynamicInput:B||Z,dynamicRmInput:R,dynamicSourceInput:E!==null||P,shellDynamicMatch:I,dynamicSourceMatch:I,rmDynamicMatch:z("parallel.rm-recursive-force-dynamic",b3)});if(P){let T=k(I,Q.policy);if(T)return T}return S??E??O1(b,Q.policy?.rules??[])})}function GG($,J){if(s($[0]??""))return!0;if(J==="eval"||J==="source"||J===".")return!0;if(J==="parallel"||J==="xargs")return!0;if(H1.has(J))return xI($);if(J==="git")return gI($);if(J==="find")return!0;if(h1.has(J))return QG($,CI,V3);if(C1(J))return QG($,TI,$9);return!1}function iQ($){let J=$.indexOf("--"),Q=$.slice(1,J===-1?void 0:J);if(!$.some(s))return J===-1;return Q.some((Y)=>s(Y)&&(Y.startsWith("-")||DG(Y)))}function gI($){if(yI($))return!0;let J=J0($);if(J.subcommand===null||s(J.subcommand))return!0;if(!SI.has(J.subcommand.toLowerCase()))return!1;let Q=J.rest.indexOf("--"),X=J.rest.slice(0,Q===-1?void 0:Q);if(!$.some(s))return Q===-1;return X.some(s)}function yI($){for(let J=1;J<$.length;J++){let Q=$[J];if(!Q||Q==="--"||!Q.startsWith("-"))return!1;if(Q==="-c"||Q==="--config-env"){if(s($[J+1]??""))return!0;J++;continue}if(Q.startsWith("-c")&&Q.length>2||Q.startsWith("--config-env=")){if(s(Q))return!0;continue}if(s(Q))return!0}return!1}function xI($){if(c1($))return!1;let J=Z0($);if(J!==null)return s(J);let Q=O0(p($));if(Q.kind==="literal")return s(Q.source);if(Q.kind==="dynamic")return!0;return!$.some(s)}function QG($,J,Q){let X=Q($);if(X.some((W)=>s(W.value)))return!0;if(!$.some(s))return Q([...$,JG]).some((W)=>W.value===JG);let Y=new Set(X.map((W)=>`${W.tokenIndex}\x00${W.kind}\x00${W.value}`));return J.some((W)=>Q($.map((K)=>N0(K,[W]))).some((K)=>!Y.has(`${K.tokenIndex}\x00${K.kind}\x00${K.value}`)))}function HG($,J,Q,X){if(!J||Q.length===0)return null;let Y=Q.filter((K)=>i(K.command)===i($[0]??""));if(Y.length===0)return null;let W=$.some(s);if(T1(X,uI($,Y,W)),!W)return _1(Y,(K)=>O1([...$,...K.subcommand?[K.subcommand]:[],...K.block_args],[K]));return _1(Y,(K)=>{let B=new Set([K.subcommand,...K.block_args].flatMap((q)=>q?mI($,q):[]));return _1(B,(q)=>O1($.map((U)=>N0(U,[q])),[K]))})}function uI($,J,Q){let X=Q?b1(U1(J.map((Y)=>Y.block_args.length+(Y.subcommand?1:0)),f.maxChildAnalyses),2*Math.max($.length,1),f.maxChildAnalyses):J.length;return{childAnalyses:X,derivedTokens:b1(X,$.length,f.maxDerivedTokens)}}function mI($,J){return $.flatMap((Q)=>{let X=[...Q.matchAll(/\{[^{}\s]*\}/g)];if(X.length!==1)return[];let Y=X[0];if(!Y||Y.index===void 0)return[];let W=Q.slice(0,Y.index),K=Q.slice(Y.index+Y[0].length);if(!J.startsWith(W)||!J.endsWith(K))return[J];let B=J.slice(W.length,J.length-K.length);return B!==J?[J,B]:[J]})}function lI($,J){let Q={customResult:null,executedSource:!$.some(s),rmOptions:!1},X=!1,Y=0,W=null,K=()=>{if(!W?.some(s))return;for(let B of $0(W,J))Q.executedSource||=GG(B.tokens,B.head),Q.rmOptions||=B.head==="rm"&&iQ(B.tokens)||B.head==="xargs"&&ZG(B.tokens),Q.customResult??=HG(B.tokens,!0,J.policy?.rules??[],J.budget)};for(let B of $.slice(1)){if(!X&&!B.startsWith("-")&&B!=="!"&&B!=="("){Q.executedSource||=s(B);continue}if(X=!0,W){if(B===";"||B==="+"){K(),W=null;continue}W.push(B);continue}if(Y>0){Y--;continue}if(v0(B)){W=[],Q.executedSource||=s(B);continue}let q=s0(B);if(q>0){Y=q,Q.executedSource||=s(B);continue}Q.executedSource||=s(B)}return K(),Q}function ZG($){let J=$.slice(R2($).childStart);return i(J[0]??"")==="rm"&&iQ(J)}function r9($,J){return(Q)=>k(z($,J),Q.policy)}var b2=r9("parallel.shell-dynamic",P3),pI=r9("parallel.command-stream-dynamic",PI),P2=r9("parallel.command-stream-dynamic",AI),XG=r9("parallel.rm-recursive-force-dynamic",b3);function pQ($,J,Q){return k(Y4(p($),{environment:Q.environment,cwd:J,originalCwd:Q.originalCwd,strict:Q.strict,paranoid:Q.paranoidRm,allowTmpdirVar:Q.allowTmpdirVar,tmpdirWordSplittingUnsafe:B0(Q.envAssignments??new Map,Q.environment),trustedTmpdirValue:C0(Q.envAssignments??new Map,Q.environment),protectedGitMetadata:Q.protectedGitMetadata,policy:Q.policy}),Q.policy)}function cQ($){return{childAnalyses:$.length,derivedTokens:$.length,derivedBytes:U4($)}}function YG($){return LG([$])}function LG($){return{childAnalyses:1,derivedTokens:$.length,derivedBytes:U4($)}}function WG($,J){if(J.length>f.maxChildAnalyses)return{childAnalyses:J.length};return{childAnalyses:J.length,derivedTokens:U1(J.map((Q)=>$.length+Q.length),f.maxDerivedTokens),derivedBytes:U1([b1(U4($),J.length,f.maxDerivedBytes),U1(J.map((Q)=>U4(Q)),f.maxDerivedBytes)],f.maxDerivedBytes)}}function KG($,J){return c9([$],J,"generic")}function c9($,J,Q){if(J.length>f.maxChildAnalyses)return{childAnalyses:J.length};let X=b1($.length,J.length,f.maxDerivedTokens);if(X>f.maxDerivedTokens)return{childAnalyses:J.length,derivedTokens:X};let Y=NG($.map((q)=>MG(q,Q))),W=b1(Y.occurrences,J.length,f.maxPlaceholderReplacements);if(W>f.maxPlaceholderReplacements)return{childAnalyses:J.length,derivedTokens:X,placeholderReplacements:W};if(OG(Y,J,W))return{childAnalyses:J.length,derivedTokens:X,derivedBytes:f.maxDerivedBytes+1,placeholderReplacements:W};let K=Q==="generic"?N0:rQ,B=U1(J.map((q)=>U4($.map((U)=>K(U,q)))),f.maxDerivedBytes);return{childAnalyses:J.length,derivedTokens:X,derivedBytes:B,placeholderReplacements:W}}function OG($,J,Q){let X=f.maxDerivedBytes+4*Q;return U1([b1($.fixedBytes,J.length,X),b1($.occurrences,U1(J.map((Y)=>Y.reduce((W,K)=>Math.max(W,q4(K)),0)),X),X)],X)>X}function cI($,J){let Q=$.filter((G)=>G.hasPlaceholder),X=Math.max(J.length,1),Y=U1(Q.map((G)=>G.frequency),f.maxChildAnalyses),W=b1(Y,X,f.maxChildAnalyses),K=b1(Y,X,f.maxDerivedTokens);if(W>f.maxChildAnalyses||K>f.maxDerivedTokens)return{childAnalyses:W,derivedTokens:K};if(J.length===0)return{childAnalyses:W,derivedTokens:K,derivedBytes:U1(Q.map((G)=>b1(q4(G.value),G.frequency,f.maxDerivedBytes)),f.maxDerivedBytes)};let B=NG(Q.map((G)=>rI(MG(G.value,"generic"),G.frequency))),q=b1(B.occurrences,X,f.maxPlaceholderReplacements);if(q>f.maxPlaceholderReplacements)return{childAnalyses:W,placeholderReplacements:q};if(OG(B,J,q))return{childAnalyses:W,derivedTokens:K,derivedBytes:f.maxDerivedBytes+1,placeholderReplacements:q};let U=U1(Q.map((G)=>b1(U4(J.map((H)=>N0(G.value,H))),G.frequency,f.maxDerivedBytes)),f.maxDerivedBytes);return{childAnalyses:W,derivedTokens:K,derivedBytes:U,placeholderReplacements:q}}function dI($,J){return{childAnalyses:U1([$.childAnalyses??0,J.childAnalyses??0],f.maxChildAnalyses),derivedTokens:U1([$.derivedTokens??0,J.derivedTokens??0],f.maxDerivedTokens),derivedBytes:U1([$.derivedBytes??0,J.derivedBytes??0],f.maxDerivedBytes),placeholderReplacements:U1([$.placeholderReplacements??0,J.placeholderReplacements??0],f.maxPlaceholderReplacements)}}function MG($,J){let Q=J==="generic"?$.matchAll(/\{[^{}\s]*\}/g):$.matchAll(qG),X=0,Y=0,W=0;for(let K of Q){if(X>=f.maxPlaceholderReplacements)return{occurrences:f.maxPlaceholderReplacements+1,fixedBytes:0};Y=U1([Y,q4($.slice(W,K.index))],d9),X++,W=K.index+K[0].length}return{occurrences:X,fixedBytes:X===0?q4($):U1([Y,q4($.slice(W))],d9)}}function rI($,J){return{occurrences:b1($.occurrences,J,f.maxPlaceholderReplacements),fixedBytes:b1($.fixedBytes,J,d9)}}function NG($){return{occurrences:U1($.map((J)=>J.occurrences),f.maxPlaceholderReplacements),fixedBytes:U1($.map((J)=>J.fixedBytes),d9)}}function U4($,J=f.maxDerivedBytes){return U1($.map(q4),J)}function q4($){return hI.encode($).byteLength}function U1($,J){let Q=0;for(let X of $){if(!Number.isSafeInteger(X)||X<0||X>J-Q)return J+1;Q+=X}return Q}function b1($,J,Q){if(!Number.isSafeInteger($)||!Number.isSafeInteger(J)||$<0||J<0||$!==0&&J>Math.floor(Q/$))return Q+1;return $*J}function dQ($,J,Q){let X=[];for(let Y of $){let W=Q.get(Y)??J?.get(Y);if(W!==void 0)X.push(W)}return X.push(...Q.values()),iI(X)}function iI($){let J=new Map;for(let X of $)J.set(X,(J.get(X)??0)+1);let Q=[...J].map(([X,Y])=>({value:X,frequency:Y,hasPlaceholder:s(X)}));return{values:$,entries:Q,byValue:new Map(Q.map((X)=>[X.value,X]))}}function BG($,J,Q,X){return _1($.values,(Y)=>{if(!$.byValue.get(Y)?.hasPlaceholder)return null;let W=J.length>0?J:[void 0];return _1(W,(K)=>{let B=K===void 0?Y:N0(Y,K);return Q.analyzeNested(B,{envAssignments:Q.envAssignments,effectiveCwd:X?null:Q.cwd})})})}function FG($,J,Q){let X={};if($)X.envAssignments=$;if(Q)return X.effectiveCwd=null,X.worktreeMode=!1,X;if(J!==void 0)X.effectiveCwd=J;return Object.keys(X).length>0?X:void 0}function N0($,J){return $.replace(/\{[^{}\s]*\}/g,(Q)=>VG(Q,J))}function rQ($,J){return $.replace(qG,(Q)=>VG(Q,J))}function VG($,J){let Q=/^\{(-?\d+)[^{}\s]*\}$/.exec($)?.[1];if(Q===void 0)return J[0]??"";let X=Number(Q),Y=X>0?X-1:J.length+X;return J[Y]??""}function s($){return EI.test($)}function _G($){if(oQ($))return!0;for(let J of $.matchAll(/\{[^{}\s]*\}/g))if(!/^(?:\{\}|\{-?\d+\})$/.test(J[0]))return!0;return!1}function oQ($){let J=$.indexOf("{=");return J!==-1&&$.indexOf("=}",J+2)!==-1}function DG($){return/^\{[^{}\s]*\}$/.test($)}function zG($){let J=1,Q=[],X=$.length,Y=-1,W=!1,K=!1,B=!1,q,U=$.some((M)=>M==="::::"||M==="::::+"||M===":::+"),G=[];while(J<$.length){let M=$[J];if(M===void 0)break;if(M===":::"){Y=J;break}if(M==="--"){let A=bQ($,J+1);Q.push(...A.templateTokens),X=J+1,Y=A.markerIndex;break}if(!M.startsWith("-")){let A=bQ($,J);Q.push(...A.templateTokens),X=J,Y=A.markerIndex;break}let V=$[J+1],F=M.indexOf("="),b=F===-1?M:M.slice(0,F),I=F===-1?void 0:M.slice(F+1);if(M==="--dry-run"){B=!0,J++;continue}if(M==="-I"||M.startsWith("-I")&&M.length>2){U||=(M==="-I"?V:M.slice(2))!=="{}",J+=M==="-I"?2:1;continue}if(M==="--replace"||M==="-i"){U=!0,J+=2;continue}if(b==="--replace"||M.startsWith("-i")&&M.length>2){let A=b==="--replace"?I:M.slice(2);U||=A!==""&&A!=="{}",J++;continue}if(M==="-a"||vI.has(b)){U=!0,J+=I===void 0?2:1;continue}if(M==="--pipe"||M==="--pipepart"){K=!0,J++;continue}if(b==="--env"){G.push(...sI(I??V)),J+=I===void 0?2:1;continue}if($G.has(b)||M.startsWith("-S")&&M.length>2){W=!0,J+=$G.has(M)?2:1;continue}if(fI.has(b)){let A=I??V;if(A===void 0||A===":::"||A==="--"){U=!0,J++;continue}q=A,U||=I!==void 0&&A==="",J+=I===void 0?2:1;continue}if(M.startsWith("-j")&&M.length>2&&/^\d+$/.test(M.slice(2))){J++;continue}if(M.startsWith("--")&&I!==void 0){J++;continue}if(wI.has(M)){if(V===void 0||V===":::"||V==="--"){U=!0,J++;continue}J+=2;continue}J+=M==="-j"||M==="--jobs"?2:1}U||=Q.some(B?oQ:_G);let H=[];if(Y!==-1){let M=[];for(let V=Y+1;V<$.length;V++){let F=$[V];if(F===":::"){H.push(M),M=[];continue}if(F!==void 0)M.push(F)}H.push(M)}let L=nI(H),Z=Q.some(s),O=Q.length===0&&Y===-1;return{template:Q,jobs:L,childStart:X,templateHasPlaceholder:Z,runsRemotely:W,usesStdin:K||Y===-1,envNames:G,readsCommandsFromInput:O,unsupported:U,workdir:q,dryRun:B}}function oI($,J,Q){if($===void 0)return;if($==="..."||/[{}$`*?~[]/.test($))return null;if(!J&&!bI($))return null;try{return d0(J??$,$,Q)}catch{return null}}function nI($){if($.length===0||$.some((Q)=>Q.length===0))return[];let J=[[]];for(let Q of $){if(Q.length===1){let Y=Q[0];if(Y===void 0)return[];for(let W of J)W.push(Y);continue}let X=[];for(let Y of J)for(let W of Q)if(X.push([...Y,W]),X.length>f.maxChildAnalyses)return X;J=X}return J}function sI($){return($??"").split(",").map((J)=>J.trim()).filter(Boolean)}function IG($){return zG($).childStart}var aI="dynamic command name contains shell substitution output and cannot be verified safely. Use a literal executable name.",nQ="shell substitution output can change guarded command structure and cannot be verified safely. Use literal subcommands and options.",tI=new Set(["branch","checkout","clean","merge","push","rebase","reflog","reset","restore","stash","switch","tag","worktree"]);function aQ($){return $?.parts.some((J)=>J.provenance==="command-substitution")??!1}function sQ($){return $?.parts.some((J)=>J.provenance==="literal"&&J.raw.replace(/^["']/,"").startsWith("-"))??!1}function RG($,J,Q,X=!1,Y){let W=$Q($,J)&&q1(Y,"shell.dynamic-executable",X)?z("shell.dynamic-executable",aI):null;return k(W,Y)??bG($,J,Q,X,Y)}function bG($,J,Q,X,Y){if(J.length<2)return null;let W=J.flatMap((B,q)=>aQ(B)?[q]:[]);if(W.length===0)return null;let K=i(J[0]?.text??"");if(K==="git"){let B=p2($,J),q=$j(B);if(q1(Y,"shell.dynamic-structure",X)&&W.some((H)=>H<=q))return k(z("shell.dynamic-structure",nQ),Y);if(k(X4(B,{env:Q.env}),Y))return null;let U=J[q]?.text.toLowerCase(),G=B.findIndex((H,L)=>L>q&&h(H)==="--");if(q1(Y,"shell.dynamic-structure",X)&&U&&tI.has(U)&&W.some((H)=>H>q&&(G===-1||H<G)))return k(z("shell.dynamic-structure",nQ),Y);return null}if(K==="find")return q1(Y,"shell.dynamic-structure",X)&&Jj(J)?k(z("shell.dynamic-structure",nQ),Y):null;if(K==="xargs")return jG($,J.slice(R2(J.map(h)).childStart),"xargs",Q,X,Y);if(K==="parallel")return jG($,J.slice(IG(J.map(h))),"parallel",Q,X,Y);return null}function jG($,J,Q,X,Y,W){if(J.length===0)return null;let K=eI(J,X);if($Q($,K)){let q=k(z(`${Q}.shell-dynamic`,Q==="xargs"?mQ:P3),W);if(q)return q}let B=bG($,K,X,Y,W);if(B)return B;if(K[0]?.text==="rm"&&K.slice(1).some((q)=>aQ(q)&&sQ(q)))return k(z(`${Q}.rm-recursive-force-dynamic`,Q==="xargs"?uQ:b3),W);return null}function eI($,J){let Q=N2($,J),X=Q.rewritten?p(Q.words.map(h)):Q.words,Y=X[0];return Y&&h(Y)==="busybox"?X.slice(1):X}function $j($){let J=1;while(J<$.length){let Q=$[J],X=Q?h(Q):"";if(W0.has(X)){J+=2;continue}if(X.startsWith("-")){J++;continue}return J}return J}function Jj($){let J=!1,Q=0,X=!1,Y=!1;for(let W=1;W<$.length;W++){let K=$[W];if(!K)continue;let B=aQ(K);if(Q>0){Q--;continue}if(Y){if(K.text===";"||K.text==="+"){Y=!1,J=!0,X=!1;continue}if(B&&(X||sQ(K)))return!0;X=!1;continue}if(!J&&!K.text.startsWith("-")){if(B&&(W>1||sQ(K)))return!0;continue}if(J=!0,B)return!0;let q=s0(K.text);if(q>0){Q=q;continue}if(v0(K.text))Y=!0,X=!0}return!1}function tQ($,J){return $.some((Q)=>{if(Q.value==="-"&&(Q.kind==="main-script"||Q.kind==="program-file"))return!0;return!g6(J[Q.tokenIndex],Q.value)})}var Qj="dd writing to a /dev device can destroy a disk or partition. Run device writes manually after confirming the target.",Xj="mkfs formatting a /dev device erases everything on it. Run the format manually after confirming the target.",Yj="shred permanently destroys the given target. Use rm for ordinary deletes, or run shred manually.";function PG($,J){let Q=J.slice(1);if($==="dd"&&Q.some((X)=>/^of=\/dev\/.+/.test(X)))return z("dd.device-write",Qj);if(($==="mkfs"||$.startsWith("mkfs."))&&Q.some((X)=>X.startsWith("/dev/")))return z("mkfs.device",Xj);if($==="shred"&&Q.length>0)return z("shred.target",Yj);return null}var EG=[{heads:new Set(["rm","rmdir"]),analyze:($)=>Y4($.words,{environment:$.options.environment,cwd:$.cwd,originalCwd:$.originalCwd,strict:$.options.strict,paranoid:$.options.paranoidRm,allowTmpdirVar:$.allowTmpdirVar,tmpdirWordSplittingUnsafe:B0($.envAssignments,$.options.environment),trustedTmpdirValue:C0($.envAssignments,$.options.environment),protectedGitMetadata:$.options.protectedGitMetadata,policy:$.options.policy})},{heads:new Set(["git"]),analyze:($)=>X4($.words,eQ($))},{heads:new Set(["find"]),analyze:($)=>g9($.words,{environment:$.options.environment,cwd:$.cwd,originalCwd:$.originalCwd,strict:$.options.strict,allowTmpdirVar:$.allowTmpdirVar,tmpdirWordSplittingUnsafe:B0($.envAssignments,$.options.environment),trustedTmpdirValue:C0($.envAssignments,$.options.environment),protectedGitMetadata:$.options.protectedGitMetadata,derivedCommandWorkBudget:$.options.derivedCommandWorkBudget,envAssignments:$.envAssignments,policy:$.options.policy,analyzeTokens:$.analyzeChildTokens,analyzeNested:(J,Q)=>A2($.options.analyzeNested(J,Q))})},{heads:new Set(["xargs"]),analyze:($)=>nU($.words,{...AG($),analyzeNested:(J,Q)=>A2($.options.analyzeNested(J,Q))})},{heads:new Set(["parallel"]),analyze:($)=>UG($.words,{...AG($),budget:$.options.parallelBudget,analyzeNested:(J,Q)=>A2($.options.analyzeNested(J,Q))})}];function AG($){return{environment:$.options.environment,cwd:$.cwd,originalCwd:$.originalCwd,strict:$.options.strict,paranoidRm:$.options.paranoidRm,paranoidInterpreters:$.options.paranoidInterpreters,allowTmpdirVar:$.allowTmpdirVar,protectedGitMetadata:$.options.protectedGitMetadata,derivedCommandWorkBudget:$.options.derivedCommandWorkBudget,envAssignments:$.envAssignments,worktreeMode:$.options.worktreeMode,policy:$.options.policy,scanWork:$.options.scanWork}}function A2($){return $?{id:$.ruleId??"",reason:$.reason,intent:$.intent??"manual_only"}:null}function eQ($){return{env:$.options.environment.env,cwd:$.cwd,dynamicArguments:$.dynamicArguments,envAssignments:$.envAssignments,policy:$.options.policy,worktreeMode:$.options.worktreeMode}}var wG="shell execution source cannot be verified safely. Use a literal command string or ask the user to run it manually.";function vG($){return EG.find((J)=>J.heads.has($))?.analyze}function A3($,J,Q){let X=Q.trace;if($.length===0)return null;let Y=Q.commandView?.dialect??"posix",W=(C)=>C.map((m)=>Y==="posix"?h(m):m.text),K=Q.effectiveCwd===null,B=K?void 0:Q.effectiveCwd??Q.cwd,q=K?void 0:Q.cwd,U=B9($);if(U.envAssignments.size>0)X?.recordSegment({type:"env-strip",input:W($),envVars:Object.fromEntries([...U.envAssignments.keys()].map((C)=>[C,"<redacted>"])),output:W(U.words)});let G=N2(U.words,Q.environment,B,new Map([...Q.envAssignments??[],...U.envAssignments]));if(G.unverifiableEnvSplit)throw new L2;let H=G.rewritten?p(W(G.words)):p2(Y,G.words),L=W(H),Z={...Q,wrapperNormalizationBudget:Q.wrapperNormalizationBudget??{iterations:0}};if(X&&U.words.length>H.length){let C=W(U.words);X.recordSegment({type:"leading-tokens-stripped",input:C,removed:C.slice(0,C.length-H.length),output:L})}let O=new Map([...Q.envAssignments??[],...U.envAssignments,...G.envAssignments]),M=L[0];if(!M)return null;if(_3(M))throw new m1;let V=i(M),F=G.cwd===null?void 0:G.cwd??B,b=G.cwd===null?void 0:q,I=G.cwd===void 0?Q.effectiveCwd:G.cwd,A=!K3(O,Q.environment),E=RG(Y,G.words,Q.environment,Q.strict,Q.policy);if(E)return X?.recordSegment({type:"rule-check",ruleModule:"analyze/segment.ts",ruleFunction:"analyzeDynamicCommandStructure",matched:!0,reason:E.reason}),f0(E);let _=k9(L,Q.policy);if(_){for(let C of[_.childIndex,..._.alternativeChildIndices]){SG(Z.wrapperNormalizationBudget);let m=H.slice(C);X?.recordSegment({type:"transparent-wrapper",wrapper:_.wrapper,output:W(m)});let X1=A3(m,J,{...Z,effectiveCwd:I,envAssignments:O});if(X1)return X1}return null}let R=V==="eval"?W4(H):V==="trap"?lU(H):void 0;if(R?.kind==="dynamic")return d1(X);if(R?.kind==="literal"){X?.recordSegment({type:"recurse",reason:V==="eval"?"shell-eval":"shell-trap",innerCommand:R.source,depth:J+1});let C=Q.analyzeNested(R.source,{effectiveCwd:I,envAssignments:O,functionDefinitions:Q.functionDefinitions});if(C)return C}if(hG(M,V)){if(c1(L))return null;let C=Wj(L,O,I,Q,X,J);if(C)return C;let m=Z0(L);if(m){let m2=u9(H,m);if(m2.kind==="dynamic")return d1(X);let GJ=m2.kind==="literal"?m2.source:m,ZK=Kj(GJ);X?.recordSegment({type:"shell-wrapper",wrapper:V,innerCommand:ZK}),X?.recordSegment({type:"recurse",reason:"shell-wrapper",innerCommand:ZK,depth:J+1});let LK=Q.analyzeNested(GJ,{effectiveCwd:I,envAssignments:O});if(LK)return LK;return K4(GJ)?d1(X):null}let X1=O0(H);if(X1.kind==="dynamic")return d1(X);if(X1.kind==="literal")return n9(X1.source,I,O,Q,X,J);let Z1=pU(H,Q.commandView?.redirections??[],Q.hasPipelineInput??!1,Q.literalShellInput);if(Z1.kind==="dynamic")return d1(X);if(Z1.kind==="literal")return X?.recordSegment({type:"recurse",reason:"shell-stdin",innerCommand:Z1.source,depth:J+1}),Q.analyzeNested(Z1.source,{effectiveCwd:I,envAssignments:O})}if(V==="source"||V==="."){let C=L[1]==="-p"?2:null;if(C!==null){let m2=Q.commandView?H[C]:void 0;if(!m2)return null;if(m2.provenance!=="literal")return d1(X)}let m=C===null?1:3,X1=L[m]==="--"?m+1:m,Z1=Q.commandView?H[X1]:void 0;if(!Z1)return null;if(Z1.provenance!=="literal")return d1(X);return n9(Z1.text,I,O,Q,X,J)}if(h1.has(V)){if(Q.strict&&tQ(V3(L),H))return d1(X);let C=h9(L,(X1)=>A2(Q.analyzeNested(X1,{effectiveCwd:I,envAssignments:O}))),m=k(C,Q.policy);if(m)return X?.recordSegment({type:"rule-check",ruleModule:"awk",ruleFunction:"analyzeAwkSystemCalls",matched:!0,reason:m.reason}),f0(m)}if(C1(V)){if(Q.strict&&tQ($9(L),H))return d1(X);let C=e6(L);if(C){let m=q1(Q.policy,"interpreter.one-liner-paranoid",!!Q.paranoidInterpreters);if(X?.recordSegment({type:"interpreter",interpreter:V,codeArg:C,paranoidBlocked:m}),m){let Z1=k(z("interpreter.one-liner-paranoid",n2),Q.policy);if(Z1)return f0(Z1)}if(Q9(V,C))return null;X?.recordSegment({type:"recurse",reason:"interpreter",innerCommand:C,depth:J+1});let X1=Q.analyzeNested(C,{effectiveCwd:I,envAssignments:O});if(X1&&X1.ruleId!=="raw-text.dangerous-command"&&(X1.reason!==r0||$4(C)))return X1;if(s2(C,Q.scanWork)){let Z1=k(z("interpreter.dangerous-command",M2),Q.policy);if(Z1)return X?.recordSegment({type:"dangerous-text",token:C,matched:!0,reason:M2}),f0(Z1)}X=void 0}}if(V==="busybox"&&L.length>1)return SG(Z.wrapperNormalizationBudget),X?.recordSegment({type:"busybox",subcommand:L[1]??"unknown"}),X?.recordSegment({type:"recurse",reason:"busybox",innerCommand:L.slice(1).join(" "),depth:J+1}),A3(H.slice(1),J,{...Z,effectiveCwd:I,envAssignments:O});let P=k(PG(V,L),Q.policy);if(P)return X?.recordSegment({type:"rule-check",ruleModule:"analyze/device.ts",ruleFunction:"analyzeDeviceCommand",matched:!0,reason:P.reason}),f0(P);let S=X===Z.trace?Z:{...Z,trace:X},T={words:H,head:V,cwd:F,originalCwd:b,envAssignments:O,allowTmpdirVar:A,dynamicArguments:G.words.some((C)=>C.provenance==="command-substitution"),depth:J,effectiveCwd:I,options:S,analyzeChildTokens:(C,m)=>A2(A3(p(C),J+1,{...S,commandView:void 0,effectiveCwd:m,envAssignments:O}))??O1(C,S.policy.rules)},y=vG(V);if(V==="rm"||V==="xargs"||V==="parallel")X?.recordSegment({type:"tmpdir-check",tmpdirValue:O.has("TMPDIR")||Q.environment.env.has("TMPDIR")?"<redacted>":null,isOverriddenToNonTemp:!A,allowTmpdirVar:A});let x=X&&V==="git"?TU(T.words,eQ(T)):void 0,c=CG(x?x.match:y?.(T)??null,Q.policy);if(X)Bj(T,c,x?.relaxation??null);if(c)return f0(c);let V1=y!==void 0;if(!V1)if(!a6.has(V)){let C=X?[]:void 0;for(let m=1;m<L.length;m++){let X1=L[m];if(!X1)continue;C?.push(X1);let Z1=CG(qj(T,L,m),Q.policy);if(Z1)return X?.recordSegment({type:"fallback-scan",tokensScanned:C??[],embeddedCommandFound:i(X1)}),f0(Z1)}X?.recordSegment({type:"fallback-scan",tokensScanned:C??[]})}else X?.recordSegment({type:"fallback-scan",tokensScanned:[]});else X?.recordSegment({type:"fallback-scan",tokensScanned:[]});if(J===0||!V1){let C=O1(L,Q.policy.rules);if(X?.recordSegment({type:"custom-rules-check",rulesChecked:Q.policy.rules.length>0,matched:!!C,reason:C?.reason}),C)return f0(C)}else X?.recordSegment({type:"custom-rules-check",rulesChecked:!1,matched:!1});return null}function Wj($,J,Q,X,Y,W){let K=gU($);if(K.argvSource?.kind==="absent")return d1(Y);if(K.argvSourceApplies&&K.argvSource){let q=n9(K.argvSource.value,Q,J,X,Y,W,!0);if(q)return q}if(!K.envSourceApplies||!K.envName)return null;let B=J.get(K.envName);if(!B)return null;return n9(B,Q,J,X,Y,W,!0)}function n9($,J,Q,X,Y,W,K=!1){if(K&&/[$`*?[\]]/.test($))return d1(Y);let B=W3($,J,X.environment.paths),q=B?X.literalHeredocFiles?.get(B):void 0;if(q===void 0)return K?d1(Y):null;return K0(X.derivedCommandWorkBudget,1),Y?.recordSegment({type:"recurse",reason:"heredoc-file",innerCommand:q,depth:W+1}),X.analyzeNested(q,{effectiveCwd:J,envAssignments:Q})}function Kj($){let J=$[0];return $.length>=2&&(J==='"'||J==="'")&&$.at(-1)===J?$.slice(1,-1):$}function Bj($,J,Q){let X={git:["git","analyzeGit"],rm:["analyze/rm.ts","analyzeRm"],find:["analyze/find.ts","analyzeFind"],xargs:["analyze/xargs.ts","analyzeXargs"],parallel:["analyze/parallel.ts","analyzeParallel"]}[$.head];if(!X)return;if($.options.trace?.recordSegment({type:"rule-check",ruleModule:X[0]??"",ruleFunction:X[1]??"",matched:!!J||!!Q,reason:J?.reason??Q?.originalReason}),Q)$.options.trace?.recordSegment({type:"worktree-relaxation",originalReason:Q.originalReason,gitCwd:Q.gitCwd})}function SG($){if($.iterations>=i2)throw new m1;$.iterations++}function f0($){return{reason:$.reason,ruleId:$.id||void 0,intent:$.intent}}function d1($){return $?.recordSegment({type:"error",message:wG}),f0(fG())}function fG(){return{id:"",reason:wG,intent:"stop_and_explain"}}function hG($,J){return H1.has(J)||$==="$SHELL"||$==="${SHELL}"||H1.has(l(J))}function qj($,J,Q){let X=$0(J.slice(Q),{environment:$.options.environment,cwd:$.cwd,envAssignments:$.envAssignments,policy:$.options.policy});for(let Y of X){let W=Uj($,Q,Y);if(W)return W}return null}function Uj($,J,Q){let X=Q.tokens[0];if(!X)return null;let Y=i(X);if(hG(X,Y)){K0($.options.derivedCommandWorkBudget,$.words.length-J);let q=Q.tokens;if(c1(q))return null;let U=Z0(q);if(!U){if(O0(p(q)).kind==="dynamic")return fG();return o9($,Q)}let G=$.options.analyzeNested(U,{effectiveCwd:Q.wrapperCwd===void 0?$.effectiveCwd:Q.wrapperCwd,envAssignments:Q.envAssignments});return G?A2(G):o9($,Q)}let W=vG(Y);if(!W||Y==="xargs"||Y==="parallel"){if(Q.wrappedByTransparent&&$.options.policy.rules.length>0)K0($.options.derivedCommandWorkBudget,$.words.length-J);return o9($,Q)}K0($.options.derivedCommandWorkBudget,$.words.length-J);let K=[Y,...Q.tokens.slice(1)],B={...$,words:p(K),head:Y,cwd:Q.cwd,originalCwd:Q.wrapperCwd===null?void 0:$.originalCwd,envAssignments:Q.envAssignments,allowTmpdirVar:!K3(Q.envAssignments,$.options.environment),effectiveCwd:Q.wrapperCwd===void 0?$.effectiveCwd:Q.wrapperCwd,options:Y==="git"?{...$.options,worktreeMode:!1}:$.options};return W(B)??o9($,Q)}function o9($,J){return J.wrappedByTransparent?O1(J.tokens,$.options.policy.rules):null}function CG($,J){return $?.id.startsWith("custom.")?$:k($,J)}var Gj=/^\s*(?:\$\(\s*)?[({]*\s*(?:command\s+|builtin\s+)?(?:cd|pushd|popd)(?:\s|$)/,Hj=new Set(["cd","chdir","pop-location","popd","push-location","pushd","set-location","sl"]);function Zj($,J){let Q=yG($,J);if(Q.length===0)return!1;let X=Q[gG(Q)];if(X==="cd"||X==="pushd"||X==="popd")return!0;return Gj.test($.join(" "))}function kG($,J,Q,X){if($.dialect==="powershell"){let B=Lj($.words,X);if(B.kind==="none")return;if(!J||B.kind==="unknown")return null;return TG(Fj(B.target),J,Q.paths)}let Y=$.words.map(h);if(!Zj(Y,Q))return;if(!J)return null;let W=yG(Y,Q,J),K=gG(W);if(K===-1||W[K]!=="cd")return null;return TG(W[K+1],J,Q.paths)}function TG($,J,Q){if(!$||$==="-"||$.includes("$")||$.includes("`"))return null;try{return Vj(d0(J,$,Q),J,Q)?J:null}catch{return null}}function Lj($,J){let Q=Oj($[0])?1:0,X=$[Q];if(!Mj(X,Q===1))return{kind:"none"};let Y=X.text.toLowerCase(),W=Y.split(/[\\/]/).pop()??Y;if(!Hj.has(W))return{kind:"none"};if(Y!==W||W==="pop-location"||W==="popd")return{kind:"unknown"};return Nj($.slice(Q+1),J)}function Oj($){return $?.provenance==="literal"&&!$.quoted&&$.raw===$.text&&($.text==="&"||$.text===".")}function Mj($,J){return $?.provenance==="literal"&&(J||!$.quoted&&$.raw===$.text)}function Nj($,J){let Q;for(let X of $){if(X.provenance!=="literal"||Q!==void 0)return{kind:"unknown"};Q=X.text}if(Q!==void 0)return{kind:"target",target:Q};return J===void 0?{kind:"unknown"}:{kind:"target",target:J}}function Fj($){return $.includes("::")?void 0:$.replaceAll("\\","/")}function gG($){let J=0;if($[0]==="builtin"&&$.length>1)J=1;if($[J]!=="time")return J;let Q=J+1;while($[Q]?.startsWith("-"))Q++;return Q}function yG($,J,Q){let X=_j($);return l1([...X],J,Q)}function Vj($,J,Q){let X=Q.realpath($),Y=Q.realpath(J);if(X===null||Y===null)return i9($)===i9(J);return i9(X)===i9(Y)}function _j($){let J=0;while(J<$.length){let Q=$[J];if(Q==="{"||Q==="("||Q==="$(")J++;else break}return $.slice(J)}var E3="TMPDIR",S3="IFS",Dj=/^([A-Za-z_][A-Za-z0-9_]*)\+=/,$7=/^[A-Za-z_][A-Za-z0-9_]*$/;function uG($,J){let Q=bj($,J);return{env:$,effectiveEnvAssignments:Q,shellAssignments:new Map,exportedNames:Pj($,Q),allexport:!1,keywordExport:!1}}function mG($){return{env:$.env,effectiveEnvAssignments:$.effectiveEnvAssignments?new Map($.effectiveEnvAssignments):void 0,shellAssignments:new Map($.shellAssignments),exportedNames:new Set($.exportedNames),allexport:$.allexport,keywordExport:$.keywordExport}}function lG($,J){let Q=zj($,J);if(!Q)return;let{command:X,commandIndex:Y,leadingAssignments:W,prefixAssignmentsPersist:K}=Q;if(X===null){for(let q of W.values())xG(J,q);return}if(K)for(let q of W.values())J.shellAssignments.set(q.name,q.value),J.exportedNames.add(q.name),e0(J,q);if(X==="set"){let q=vj($,Y);if(q.allexport!==null)J.allexport=q.allexport;if(q.keywordExport!==null)J.keywordExport=q.keywordExport;return}if(X==="unset"){let q=Cj($,Y);if(q===null)return;for(let U of $.slice(q))Sj(J,U);return}if(X!=="export"&&X!=="typeset"&&X!=="declare"&&X!=="readonly")return;for(let q of W.values())xG(J,q);if(X==="export"){let q=Tj($,Y);if(q===null)return;for(let U of $.slice(q))Aj(J,U);return}let B=wj($,Y);if(B===null)return;for(let q of $.slice(B.operandsStart))Ej(J,q,B.exports,X==="readonly"?W:void 0)}function pG($,J){if(!J.keywordExport)return J.effectiveEnvAssignments;let Q=null,X=t9(J);for(let Y of $){let W=a9(Y,X,J.env);if(!W)continue;Q??=new Map(J.effectiveEnvAssignments??[]),Q.set(W.name,W.value),X.set(W.name,W.value)}return Q??J.effectiveEnvAssignments}function zj($,J){let Q=new Map,X=0;while(X<$.length){let B=$[X];if(!B)return null;let q=a9(B,t9(J,Q),J.env);if(!q)break;Q.set(q.name,q),X++}if(X>=$.length)return{command:null,commandIndex:X,leadingAssignments:Q,prefixAssignmentsPersist:!1};let Y=X,W=X,K=$[W]??null;while(K==="builtin"||K==="command"||K==="time"){if(K==="builtin"){if(W++,$[W]==="--")W++;K=$[W]??null;continue}if(K==="command"){let q=Ij($,W);if(!q)return null;W=q.commandIndex,K=q.command;continue}let B=jj($,W);if(!B)return null;W=B.commandIndex,K=B.command}if(K===null)return null;return{command:K,commandIndex:W,leadingAssignments:Q,prefixAssignmentsPersist:W===Y&&(K==="unset"||K==="set"||K==="export"||K==="readonly")}}function Ij($,J){return cG($,J,(Q)=>{if(Q==="-p")return"skip";return Q==="-v"||Q==="-V"?"abort":"stop"})}function jj($,J){return cG($,J,(Q)=>Q.startsWith("-")?"skip":"stop")}function cG($,J,Q){let X=J+1;while(X<$.length){let W=$[X];if(!W)return null;if(W==="--"){X++;break}let K=Q(W);if(K==="abort")return null;if(K==="skip"){X++;continue}break}let Y=$[X];return Y?{command:Y,commandIndex:X}:null}function a9($,J,Q){return q0($)??Rj($,J,Q)}function Rj($,J,Q){let X=u6($,Q,J);if(X)return X;let Y=$.match(Dj)?.[1];if(!Y)return null;let W=$.indexOf("=");return{name:Y,value:`${J.has(Y)?J.get(Y):Q.get(Y)??""}${$.slice(W+1)}`}}function s9($){return $===E3||$===S3||EJ($)}function t9($,J){return new Map([...$.effectiveEnvAssignments??[],...$.shellAssignments,...[...J?.values()??[]].map((Q)=>[Q.name,Q.value])])}function bj($,J){let Q=[...y6,E3,S3].map((X)=>{let Y=$.get(X);return Y===void 0?null:[X,Y]}).filter((X)=>X!==null);if(Q.length===0)return J;return new Map([...Q,...J??[]])}function Pj($,J){let Q=new Set;for(let X of $.keys())if(s9(X))Q.add(X);for(let X of J?.keys()??[])if(s9(X))Q.add(X);return Q}function xG($,J){if($.shellAssignments.set(J.name,J.value),J.name===E3||J.name===S3||$.allexport||$.exportedNames.has(J.name))e0($,J)}function e0($,J){let Q=new Map($.effectiveEnvAssignments??[]);Q.set(J.name,J.value),$.effectiveEnvAssignments=Q}function Aj($,J){let Q=a9(J,t9($),$.env);if(Q){$.shellAssignments.set(Q.name,Q.value),$.exportedNames.add(Q.name),e0($,Q);return}if($7.test(J))dG($,J)}function Ej($,J,Q,X){let Y=a9(J,t9($),$.env);if(Y){if($.shellAssignments.set(Y.name,Y.value),Q)$.exportedNames.add(Y.name),e0($,Y);else if(Y.name===E3||Y.name===S3||$.allexport||$.exportedNames.has(Y.name))e0($,Y);return}let W=X?.get(J);if(W){$.exportedNames.add(J),e0($,W);return}if(Q&&$7.test(J))dG($,J)}function dG($,J){$.exportedNames.add(J),e0($,{name:J,value:$.shellAssignments.get(J)??$.effectiveEnvAssignments?.get(J)??$.env.get(J)??""})}function Sj($,J){if(!s9(J)&&!$7.test(J))return;if($.shellAssignments.set(J,""),$.exportedNames.delete(J),!s9(J)||J===E3||J===S3||a4(J)){e0($,{name:J,value:""});return}if(!$.effectiveEnvAssignments?.has(J))return;let Q=new Map($.effectiveEnvAssignments);Q.delete(J),$.effectiveEnvAssignments=Q.size===0?void 0:Q}function Cj($,J){return rG($,J,(Q)=>Q==="-v")}function Tj($,J){return rG($,J,(Q)=>Q==="-p")}function rG($,J,Q){let X=J+1;while(X<$.length){let Y=$[X];if(!Y)return null;if(Y==="--")return X+1;if(Q(Y)){X++;continue}if(Y.startsWith("-"))return null;return X}return X}function wj($,J){let Q=J+1,X=!1;while(Q<$.length){let Y=$[Q];if(!Y)return null;if(Y==="--")return{operandsStart:Q+1,exports:X};if(Y.startsWith("-")){if(Y.slice(1).includes("x"))X=!0;Q++;continue}if(Y.startsWith("+")){if(Y.slice(1).includes("x"))X=!1;Q++;continue}return{operandsStart:Q,exports:X}}return{operandsStart:Q,exports:X}}function vj($,J){let Q={allexport:null,keywordExport:null},X=J+1;while(X<$.length){let Y=$[X];if(!Y)return Q;if(Y==="--")return Q;if(Y==="-o"||Y==="+o"){if($[X+1]==="allexport")Q.allexport=Y==="-o";if($[X+1]==="keyword")Q.keywordExport=Y==="-o";X+=2;continue}if(Y.startsWith("-")&&Y.length>1){let W=Y.slice(1);if(W.includes("a"))Q.allexport=!0;if(W.includes("k"))Q.keywordExport=!0;X++;continue}if(Y.startsWith("+")&&Y.length>1){let W=Y.slice(1);if(W.includes("a"))Q.allexport=!1;if(W.includes("k"))Q.keywordExport=!1;X++;continue}return Q}return Q}var fj="Unquoted heredoc input is not supported safely. Quote the delimiter or ask the user to verify.",E2="This heredoc form or stdin consumer is not supported safely. Use a quoted heredoc with a supported consumer (cat, tee, git apply, git commit, gh pr create, gh issue create), or ask the user to verify.",hj=64;function W7($,J,Q,X){let Y=Q.derivedCommandWorkBudget===void 0,W=Q.parallelBudget===void 0;try{return kj($,J,{...Q,derivedCommandWorkBudget:Q.derivedCommandWorkBudget??n6(),parallelBudget:Q.parallelBudget??wB()},X)}catch(K){let B=K instanceof L2?jB:K instanceof m1&&Y?IB:K instanceof W9&&W?TB:void 0;if(!B)throw K;if(Q.trace?.currentSegmentIndex!==void 0)Q.trace.recordSegment({type:"error",message:B});else Q.trace?.recordGlobal({type:"error",message:B});return{reason:B,segment:$,intent:"stop_and_explain"}}}function kj($,J,Q,X){if(J>=s6)return Q.trace?.recordSegment({type:"error",message:P0}),{reason:P0,segment:$,intent:"stop_and_explain"};let Y=X??Q.factStore?.getCommandProgram($,Q.shell??"auto")??a1($,Q.shell);if(Y.status==="limited")return Q.trace?.recordSegment({type:"error",message:P0}),{reason:P0,segment:$,intent:"stop_and_explain"};if(Y.status==="invalid"){let U=Y.issues.find((G)=>G.code.includes("heredoc"));if(U){if(!Q.strict)return Y7($,Q);let G=`Unsupported heredoc syntax: ${U.message}`;return Q.trace?.recordGlobal({type:"error",message:G}),{reason:G,segment:$,intent:"stop_and_explain"}}return tG($,Q),{reason:r0,segment:$,intent:"stop_and_explain"}}if(Q.strict&&Y.status==="partial")return tG($,Q),{reason:r0,segment:$,intent:"stop_and_explain"};if(Y.issues.some((U)=>U.code.includes("quote"))&&!Q.analyzePartialProgram)return Y7($,Q);let K=Q.cwd,B=Q.effectiveCwd!==void 0?Q.effectiveCwd:Q.cwd,q=uG(Q.environment.env,Q.envAssignments);return J$(Y,J,{...Q,rootProgram:Y},K,[{effectiveCwd:B,shellGitContextState:q,literalHeredocFiles:new Map(Q.literalHeredocFiles),functionDefinitions:new Map(Q.functionDefinitions)}]).result}function J$($,J,Q,X,Y){let W=[...Y],K,B;for(let[q,U]of $.nodes.entries()){if(U.kind==="connector"){B=U.operator;continue}let G=$.nodes[q+1],H=G?.kind==="connector"?G.operator:void 0,L=gj($,q,U,B,H),Z=B==="&&"||B==="||",O=Z?K:void 0,M=B==="&&"?O?.success??W:B==="||"?O?.failure??W:W,V=B==="||"?O?.success??[]:[],F=B==="&&"?O?.failure??[]:[],b=Z||G4(H);if(U.kind==="function"){let S=M.flatMap((y)=>{let x=C3(y);return x.functionDefinitions.set(U.name,U.body),J7(y,[x],L,H==="&",G4(H))}),T=Q7(S,[],V,F,B,H);W=T.states,K=T.conditionalStates,B=void 0;continue}if(U.kind==="group"){let S=[],T=[];for(let x of M){let c=J$(U.body,J,Q,X,[C3(x)]);if(c.result)return c;if(S.push(...J7(x,c.states,L,H==="&",G4(H))),b)T.push(x,...L?c.states.map((V1)=>e9(x,V1)):c.states)}let y=Q7(S,T,V,F,B,H);W=y.states,K=y.conditionalStates,B=void 0;continue}if(U.kind!=="command")continue;let I=Q.trace?.flattenNested?Q.trace.currentSegmentIndex:Q.trace?.allocateSegment(),A=$.nodes[q-2],E=Q$(B)&&A?.kind==="command"?mU(A)??xj(A):void 0,_=[],R=[];for(let S of M){let T=uj(U,J,Q,X,[C3(S)]);if(T.result)return{result:T.result,states:W};let y=$.dialect==="powershell"?T.states:T.states.map((x)=>e9(S,x));for(let x of y){let c=C3(x),V1=pj(U,J,Q.trace?{...Q,trace:eG(Q.trace,I)}:Q,X,c,Q$(B),E);if(V1)return{result:V1,states:W};let C=QR(U,c.functionDefinitions);if(C)K0(Q.derivedCommandWorkBudget,X$(C));let m=C?J+1>=s6?X7(U.displayText,Q,[c]):J$(C,J+1,Q,X,[c]):{result:null,states:[c]};if(m.result)return m;if(_.push(...J7(S,m.states,L,H==="&",G4(H))),b)R.push(S),R.push(...m.states.map((X1)=>L?e9(S,X1):X1))}}let P=Q7(_,R,V,F,B,H);W=P.states,K=P.conditionalStates,B=void 0}return{result:null,states:W}}function gj($,J,Q,X,Y){if(Q.kind==="group"&&Q.style==="subshell")return!0;if($.dialect==="posix"&&(Q$(X)||Q$(Y)))return!0;if(Y==="&")return!0;return $.dialect==="powershell"&&Q.kind==="group"&&Q.style==="brace"&&yj($,J)}function J7($,J,Q,X,Y){let W=Q?J.map((B)=>e9($,B)):[...J],K=Y?W.flatMap((B)=>T3($.literalHeredocFiles,B.literalHeredocFiles)?[B]:[{...B,literalHeredocFiles:new Map($.literalHeredocFiles)},B]):W;return X?[$,...K]:K}function e9($,J){return{...$,literalHeredocFiles:new Map(J.literalHeredocFiles)}}function yj($,J){let Q=[...$.nodes.slice(0,J)].reverse().find((Y)=>Y.kind==="command"||Y.kind==="connector");if(!Q||Q.kind!=="command")return!0;let X=Q.words[0]?.text.toLowerCase();if(X==="&"||X===".")return!1;if(X==="write-output"||X==="function"||X==="start-job")return!0;if(mj(Q))return!0;return Q.source.replaceAll(/\s/g,"").toLowerCase()==="if($false)"}function Q$($){return $==="|"||$==="|&"}function xj($){if($?.dialect!=="powershell")return;if($.words.length===1&&$.words[0]?.quoted&&$.words[0].provenance==="literal")return $.words[0].text;if($.words[0]?.text.toLowerCase()==="write-output"&&$.words.length===2&&$.words[1]?.provenance==="literal")return $.words[1].text;return}function G4($){return $==="&&"||$==="||"}function Q7($,J,Q,X,Y,W){let K={success:$$([...Q,...$]),failure:$$([...X,...J])},B=G4(W)?K:void 0;return{states:G4(Y)||B?$$([...K.success,...K.failure]):K.success,conditionalStates:B}}function eG($,J,Q=$.flattenNested){return{currentSegmentIndex:J,flattenNested:Q,allocateSegment:$.allocateSegment,getNextSegmentIndex:$.getNextSegmentIndex,recordGlobal:$.recordGlobal,recordSegment:(X,Y=J)=>$.recordSegment(X,Y)}}function uj($,J,Q,X,Y){let W=$.nested.map((K)=>({program:K,depth:J}));if($.dialect==="powershell"){let K=lj($);if(K){if(J+1>=s6)return X7(K,Q,Y);let B=a1(K,"powershell");if(B.status==="limited")return X7(K,Q,Y);if(B.status!=="complete")return iG(W,Q,X,Y);K0(Q.derivedCommandWorkBudget,X$(B)),W.push({program:B,depth:J+1})}}return iG(W,Q,X,Y)}function mj($){let J=$.words[0];return J?.provenance==="variable"&&$.words.at(-1)?.text==="="?J.text.toLowerCase():void 0}function iG($,J,Q,X){let Y=[...X];for(let W of $){let K=[];for(let B of Y){let q=J$(W.program,W.depth,J,Q,[C3(B)]);if(q.result)return q;K.push(...q.states)}Y=$$(K)}return{result:null,states:Y}}function lj($){let J=$.words[0]?.provenance==="literal"&&!$.words[0].quoted&&$.words[0].raw===$.words[0].text&&($.words[0].text==="&"||$.words[0].text==="."),Q=J?1:0,X=$.words[Q];if(X?.provenance!=="literal"||!J&&(X.quoted||X.raw!==X.text)||!["iex","invoke-expression"].includes(X.text.toLowerCase()))return;let Y=$.words.slice(Q+1),W=Y[0]&&!Y[0].quoted&&Y[0].raw===Y[0].text&&["-c","-command"].includes(Y[0].text.toLowerCase())?1:0,K=Y[W];return Y.length===W+1&&K?.quoted&&K.provenance==="literal"?K.text:void 0}function X$($){return $.nodes.reduce((J,Q)=>J+(Q.kind==="command"?Q.words.length+Q.nested.reduce((X,Y)=>X+X$(Y),0):Q.kind==="group"||Q.kind==="function"?X$(Q.body):0),0)}function X7($,J,Q){return J.trace?.recordSegment({type:"error",message:P0}),{result:{reason:P0,segment:$,intent:"stop_and_explain"},states:[...Q]}}function pj($,J,Q,X,Y,W,K){let B=sj($);if(B&&Q.strict)return Q.trace?.recordSegment({type:"error",message:B}),{reason:B,segment:$.source,intent:"stop_and_explain"};$H($,Y,"before-consumer",Q.environment.paths);let q=p2($.dialect,$.words).map(h),U=$.displayText,G=pG(q,Y.shellGitContextState);if($.dialect==="powershell"){let Z=k(KU($,W,WR(Q,Y.effectiveCwd)),Q.policy);if(Q.trace?.recordSegment({type:"rule-check",ruleModule:"analyze/powershell/remove-item.ts",ruleFunction:"analyzePowerShellCommandViewMatch",matched:!!Z,reason:Z?.reason}),Z)return YR(U,Z)}if(q.length===1&&q[0]?.includes(" ")&&!$.dynamicExecutable){let Z=k(Y3(q[0],Q.scanWork),Q.policy),O=Z!==null&&!Q.strict&&_B($,Q.rootProgram,Q.scanWork);if(Z&&!O)return Q.trace?.recordSegment({type:"dangerous-text",token:q[0],matched:!0,reason:Z.reason}),{reason:Z.reason,segment:U,ruleId:Z.id,intent:Z.intent};return Q.trace?.recordSegment({type:"dangerous-text",token:q[0],matched:!1}),oG($,B,Y,G,K,Q)}let H=A3($.words,J,{...Q,commandView:$,cwd:X,effectiveCwd:Y.effectiveCwd,envAssignments:G,literalHeredocFiles:Y.literalHeredocFiles,functionDefinitions:Y.functionDefinitions,hasPipelineInput:W,literalShellInput:K,analyzeNested:(Z,O)=>{let M=O&&Object.hasOwn(O,"effectiveCwd")?O.effectiveCwd:Y.effectiveCwd,V=W7(Z,J+1,{...Q,derivedCommandWorkBudget:Q.derivedCommandWorkBudget,effectiveCwd:M,envAssignments:O?.envAssignments??G,literalHeredocFiles:Y.literalHeredocFiles,functionDefinitions:O?.functionDefinitions,worktreeMode:O?.worktreeMode??Q.worktreeMode,trace:Q.trace?eG(Q.trace,Q.trace.currentSegmentIndex,!0):void 0});return V?{reason:V.reason,ruleId:V.ruleId,intent:V.intent}:null}});if(H)return{...H,segment:U};let L=oG($,B,Y,G,K,Q);if(L)return L;return lG(q,Y.shellGitContextState),null}function oG($,J,Q,X,Y,W){let K=aj($,J,Q,X??new Map,W);if(K)return K;return $H($,Q,"after-consumer",W.environment.paths),Q.literalHeredocFiles.clear(),rj($,J,Q,W.environment.paths),$R($,Q,Y,W.environment,W.trace),null}var cj=new Set([">>","<>"]);function $H($,J,Q,X){for(let W of $.redirections){if(!(Q==="before-consumer"?dj(W):cj.has(W.operator)))continue;nG(W.target,J,X)}if(Q!=="before-consumer"||!k1($.words[0],"tee"))return;let Y=JH($.words.slice(1));if(!Y)return;for(let W of Y.operands)nG(W,J,X)}function dj($){if($.operator===">"||$.operator===">|")return!0;return $.operator===">&"&&$.fd===void 0&&$.target?.provenance==="literal"&&!/^(?:[0-9]+|-)$/.test($.target.text)}function nG($,J,Q){let X=$?.provenance==="literal"?W3($.text,J.effectiveCwd,Q):void 0;if(!X)return;J.literalHeredocFiles.delete(X)}function rj($,J,Q,X){if(J)return;let Y=$.redirections.find((W)=>W.operator==="<<"||W.operator==="<<-")?.heredoc;if(!Y?.quotedDelimiter)return;for(let W of ij($)){let K=W3(W.text,Q.effectiveCwd,X);if(!K||!PB(K))continue;if(!Q.literalHeredocFiles.has(K)&&Q.literalHeredocFiles.size>=bB)throw new m1;Q.literalHeredocFiles.set(K,Y.body)}}function ij($){let J=nj($.redirections)?.target,Q=sG(J)?[J]:[];if(k1($.words[0],"cat"))return oj($.words)?Q:[];if(!k1($.words[0],"tee"))return[];let X=JH($.words.slice(1));if(!X||X.append||X.hasUnsupportedOptions||!X.operands.every(sG))return[];return[...X.operands,...Q]}function oj($){let J=!1;for(let Q of $.slice(1)){if(J||Q.provenance!=="literal")return!1;if(Q.text==="--"){J=!0;continue}if(!/^-u+$/.test(Q.text))return!1}return!0}function nj($){let J=$.findLast((Q)=>(Q.fd??([">",">|",">>",">&"].includes(Q.operator)?1:0))===1);return J?.operator===">"||J?.operator===">|"?J:void 0}function JH($){let J=[],Q=!0,X=!1,Y=!1;for(let W of $){if(W.provenance!=="literal")return;if(Q&&k1(W,"--")){Q=!1;continue}if(Q&&!W.quoted&&W.raw===W.text&&/^-[^-]/.test(W.text)){X||=W.text.slice(1).includes("a"),Y||=[...W.text.slice(1)].some((K)=>K!=="a"&&K!=="i");continue}if(Q&&!W.quoted&&W.raw===W.text&&W.text.startsWith("--")){X||=W.text==="--append",Y||=W.text!=="--append"&&W.text!=="--ignore-interrupts";continue}J.push(W)}return{operands:J,append:X,hasUnsupportedOptions:Y}}function sG($){if(!$||$.provenance!=="literal"||$.text.length===0)return!1;if($.quoted||$.raw!==$.text)return!0;return!$.raw.startsWith("~")&&!/[{}]/.test($.raw)}function k1($,J){return $?.text===J&&$.raw===J&&$.provenance==="literal"&&!$.quoted}function sj($){let J=$.redirections.filter((K)=>K.operator==="<<"||K.operator==="<<-");if(J.length===0)return;if(J.length!==1)return E2;let Q=J[0];if(!Q?.heredoc)return E2;if(!Q.heredoc.quotedDelimiter)return fj;if(Q.fd!==void 0&&Q.fd!==0)return E2;if($.redirections.some((K)=>K!==Q&&["<","<<","<<-","<<<","<&","<>"].includes(K.operator)))return E2;let X=$.redirections.some((K)=>K!==Q&&aG(K.target));if(k1($.words[0],"cat"))return X?E2:void 0;if(k1($.words[0],"tee"))return X||$.words.slice(1).some(aG)?E2:void 0;let Y=$.words[0],W=$.words[1];if(k1(Y,"git")&&(k1(W,"apply")||k1(W,"commit")))return;if(k1(Y,"gh")&&(k1(W,"pr")||k1(W,"issue"))&&k1($.words[2],"create"))return;return E2}function aG($){return $?.parts.some((J)=>J.provenance==="command-substitution"&&J.raw.startsWith(">("))??!1}function aj($,J,Q,X,Y){if(!J)return null;let W=$.redirections.filter((U)=>U.operator==="<<"||U.operator==="<<-"),K=W.flatMap((U)=>U.heredoc?[U.heredoc.body]:[]);if(ej($,W,Q,X,Y))return null;let B=tj($,W,Y);if(B!==void 0)return B?{reason:B.reason,segment:$.displayText,ruleId:B.id,intent:B.intent}:null;let q=Y7(K.length===W.length?K.join(`
63
- `):$.source,Y);return q?{...q,segment:$.displayText}:null}function tj($,J,Q){let X=J.length===1?J[0]:void 0;if(!X?.heredoc?.quotedDelimiter||X.fd!==void 0&&X.fd!==0)return;let Y=$.words[0];if(Y?.provenance!=="literal"||!C1(Y.text))return;if(!$.words.slice(1).every((U)=>U.provenance==="literal"&&U.text.startsWith("-")))return;let K=X.heredoc.body,B=q1(Q.policy,"interpreter.one-liner-paranoid",!!Q.paranoidInterpreters);if(Q.trace?.recordSegment({type:"interpreter",interpreter:Y.text,codeArg:K,paranoidBlocked:B}),B){let U=k(z("interpreter.one-liner-paranoid",n2),Q.policy);if(U)return U}if(!s2(K,Q.scanWork))return null;let q=k(z("interpreter.dangerous-command",M2),Q.policy);if(!q)return null;return Q.trace?.recordSegment({type:"dangerous-text",token:K,matched:!0,reason:q.reason}),q}function ej($,J,Q,X,Y){let W=J.length===1?J[0]:void 0;if(!W?.heredoc?.quotedDelimiter||W.fd!==void 0&&W.fd!==0)return!1;let K=N2($.words,Y.environment,Q.effectiveCwd,X),B=K.words.map(h),q=i(B[0]??"");if(K.unverifiableEnvSplit||!H1.has(q)&&!H1.has(l(q)))return!1;return c1(B)}function $R($,J,Q,X,Y){let W=kG($,J.effectiveCwd,X,Q);if(W===null)Y?.recordSegment({type:"cwd-change",segment:$.words.map(h).join(" "),effectiveCwdNowUnknown:!0});if(W!==void 0)J.effectiveCwd=W}function C3($){return{effectiveCwd:$.effectiveCwd,shellGitContextState:mG($.shellGitContextState),literalHeredocFiles:new Map($.literalHeredocFiles),functionDefinitions:new Map($.functionDefinitions)}}function $$($){let J=[];for(let Q of $){if(!J.some((X)=>JR(X,Q)))J.push(Q);if(J.length>hj)throw new m1}return J}function JR($,J){return $.effectiveCwd===J.effectiveCwd&&T3($.literalHeredocFiles,J.literalHeredocFiles)&&T3($.functionDefinitions,J.functionDefinitions)&&T3($.shellGitContextState.effectiveEnvAssignments,J.shellGitContextState.effectiveEnvAssignments)&&T3($.shellGitContextState.shellAssignments,J.shellGitContextState.shellAssignments)&&XR($.shellGitContextState.exportedNames,J.shellGitContextState.exportedNames)&&$.shellGitContextState.allexport===J.shellGitContextState.allexport&&$.shellGitContextState.keywordExport===J.shellGitContextState.keywordExport}function T3($,J){if($===J)return!0;if(!$||!J||$.size!==J.size)return!1;return[...$].every(([Q,X])=>J.get(Q)===X&&J.has(Q))}function QR($,J){let Q=z9($);return Q===void 0?void 0:J.get(Q)}function XR($,J){return $.size===J.size&&[...$].every((Q)=>J.has(Q))}function YR($,J){if(!J)return null;return{reason:J.reason,segment:$,ruleId:J.id,intent:J.intent}}function WR($,J=$.effectiveCwd){let Q=J===null;return{environment:$.environment,cwd:Q?void 0:J??$.cwd,originalCwd:Q?void 0:$.cwd,strict:$.strict,paranoid:$.paranoidRm,allowTmpdirVar:$.allowTmpdirVar,protectedGitMetadata:$.protectedGitMetadata,policy:$.policy}}function Y7($,J){let Q=k(Y3($,J.scanWork),J.policy),X=J.trace?.currentSegmentIndex??J.trace?.allocateSegment(),Y={type:"dangerous-text",token:$,matched:!!Q,reason:Q?.reason};if(J.trace?.recordSegment(Y,X),!Q&&/^(?:cd|pushd)\s/.test($))J.trace?.recordSegment({type:"cwd-change",segment:$,effectiveCwdNowUnknown:!0},X);return Q?{reason:Q.reason,segment:$,ruleId:Q.id,intent:Q.intent}:null}function tG($,J){let Q={type:"strict-unparseable",rawCommand:$,reason:r0};if(J.trace?.currentSegmentIndex===void 0)J.trace?.recordGlobal(Q);else J.trace.recordSegment(Q)}var B1={level:{name:"CC_SAFETY_NET_LEVEL"},strict:{name:"CC_SAFETY_NET_STRICT",legacyName:"SAFETY_NET_STRICT"},paranoid:{name:"CC_SAFETY_NET_PARANOID",legacyName:"SAFETY_NET_PARANOID"},paranoidRm:{name:"CC_SAFETY_NET_PARANOID_RM",legacyName:"SAFETY_NET_PARANOID_RM"},paranoidInterpreters:{name:"CC_SAFETY_NET_PARANOID_INTERPRETERS",legacyName:"SAFETY_NET_PARANOID_INTERPRETERS"},worktree:{name:"CC_SAFETY_NET_WORKTREE",legacyName:"SAFETY_NET_WORKTREE"},debug:{name:"CC_SAFETY_NET_DEBUG"},auditScope:{name:"CC_SAFETY_NET_AUDIT_SCOPE"}},Y$=["standard","strict","paranoid"];function KR($){return{failClosed:$==="strict"||$==="paranoid",paranoidRm:$==="paranoid",paranoidInterpreters:$==="paranoid"}}function BR($,J){if(!J)return $;return Y$.indexOf(J)>Y$.indexOf($)?J:$}function qR(){let $=G7(B1.level);if($===void 0||$==="")return;if(Y$.includes($))return $;console.error(`CC Safety Net: ignored invalid ${B1.level.name}=${JSON.stringify($.slice(0,40))}. Use ${Y$.join(", ")}.`);return}function UR($){if($===void 0||$==="all")return"all";if($==="blocked")return"blocked";return"invalid"}function B7(){return UR(G7(B1.auditScope))==="all"}function q7($){if($.failClosed&&$.paranoidRm&&$.paranoidInterpreters)return"paranoid";if($.failClosed&&!$.paranoidRm&&!$.paranoidInterpreters)return"strict";if(!$.failClosed&&!$.paranoidRm&&!$.paranoidInterpreters)return"standard";return"custom"}function U7($={}){let J=$.safety?.level??"standard",Q=qR(),X=BR(J,Q),Y=KR(X),W={failClosed:X===J?"preset":"environment",paranoidRm:X===J?"preset":"environment",paranoidInterpreters:X===J?"preset":"environment"},K={failClosed:[`policy safety.level=${J}`],paranoidRm:[`policy safety.level=${J}`],paranoidInterpreters:[`policy safety.level=${J}`],worktreeMode:[]};if(X!==J)K.failClosed.push(`env ${B1.level.name}=${Q}`),K.paranoidRm.push(`env ${B1.level.name}=${Q}`),K.paranoidInterpreters.push(`env ${B1.level.name}=${Q}`);if($.safety?.overrides?.failClosed!==void 0)Y.failClosed=$.safety.overrides.failClosed,W.failClosed="capability_override",K.failClosed.push("policy safety.overrides.fail_closed");if($.safety?.overrides?.paranoidRm!==void 0)Y.paranoidRm=$.safety.overrides.paranoidRm,W.paranoidRm="capability_override",K.paranoidRm.push("policy safety.overrides.paranoid_rm");if($.safety?.overrides?.paranoidInterpreters!==void 0)Y.paranoidInterpreters=$.safety.overrides.paranoidInterpreters,W.paranoidInterpreters="capability_override",K.paranoidInterpreters.push("policy safety.overrides.paranoid_interpreters");if(h0(B1.strict))Y.failClosed=!0,W.failClosed="environment",K.failClosed.push(`env ${B1.strict.name}`);if(h0(B1.paranoid))Y.paranoidRm=!0,Y.paranoidInterpreters=!0,W.paranoidRm="environment",W.paranoidInterpreters="environment",K.paranoidRm.push(`env ${B1.paranoid.name}`),K.paranoidInterpreters.push(`env ${B1.paranoid.name}`);if(h0(B1.paranoidRm))Y.paranoidRm=!0,W.paranoidRm="environment",K.paranoidRm.push(`env ${B1.paranoidRm.name}`);if(h0(B1.paranoidInterpreters))Y.paranoidInterpreters=!0,W.paranoidInterpreters="environment",K.paranoidInterpreters.push(`env ${B1.paranoidInterpreters.name}`);let B=!!$.worktreeMode||h0(B1.worktree);if($.worktreeMode)K.worktreeMode.push("policy workflow.worktree_mode");if(h0(B1.worktree))K.worktreeMode.push(`env ${B1.worktree.name}`);return{strict:Y.failClosed,paranoidRm:Y.paranoidRm,paranoidInterpreters:Y.paranoidInterpreters,worktreeMode:B,effectiveLevel:q7(Y),capabilities:{fail_closed:{enabled:Y.failClosed,source:W.failClosed,sources:K.failClosed},paranoid_rm:{enabled:Y.paranoidRm,source:W.paranoidRm,sources:K.paranoidRm},paranoid_interpreters:{enabled:Y.paranoidInterpreters,source:W.paranoidInterpreters,sources:K.paranoidInterpreters}},sources:K}}function h0($){let J=typeof $==="string"?K7($):G7($);return J==="1"||J?.toLowerCase()==="true"}function K7($){return Object.hasOwn(process.env,$)?process.env[$]:void 0}function G7($){let J=K7($.name);if(J!==void 0)return J;if($.legacyName)return K7($.legacyName);return}function QH($){let J=$.effectiveCapabilities,Q=$.strict??J.fail_closed.enabled,X=$.paranoidRm??J.paranoid_rm.enabled,Y=$.paranoidInterpreters??J.paranoid_interpreters.enabled,W={fail_closed:H7(J.fail_closed,$.strict,"strict"),paranoid_rm:H7(J.paranoid_rm,$.paranoidRm,"paranoidRm"),paranoid_interpreters:H7(J.paranoid_interpreters,$.paranoidInterpreters,"paranoidInterpreters")};return{policy:FB($.policySnapshot.policy,W),effectiveCapabilities:W,effectiveLevel:q7({failClosed:Q,paranoidRm:X,paranoidInterpreters:Y}),strict:Q,paranoidRm:X,paranoidInterpreters:Y,worktreeMode:$.worktreeMode??!1}}function H7($,J,Q){if(J===void 0||J===$.enabled)return $;return{enabled:J,source:"capability_override",sources:[...$.sources,`analysis options.${Q}`]}}function XH($,J,Q,X){let Y=W7($,0,{...J,...QH(J),factStore:X},Q);if(!Y)return null;return{kind:"deny",reason:Y.reason,intent:Y.intent??"manual_only",...Y.ruleId?{ruleId:Y.ruleId}:{},evidence:[{kind:"command",command:$,segment:Y.segment}]}}import{dirname as YK}from"path";function w3($,J,Q,X,Y){if(Q.kind!=="command")return{toolName:$,input:J,route:Q,context:X};return{toolName:$,input:J,route:Q,context:X,command:Y}}import{chmodSync as Dk,existsSync as FP,mkdirSync as zk,readFileSync as VP}from"fs";import{dirname as _P,join as DP}from"path";import{createRequire as YP}from"module";var oW={};B2(oW,{z:()=>QJ,xor:()=>EZ,xid:()=>aH,void:()=>IZ,uuidv7:()=>pH,uuidv6:()=>lH,uuidv4:()=>mH,uuid:()=>uH,util:()=>w,url:()=>cH,uppercase:()=>j4,unknown:()=>k2,union:()=>i8,undefined:()=>DZ,ulid:()=>sH,uint64:()=>VZ,uint32:()=>MZ,tuple:()=>VW,trim:()=>S4,treeifyError:()=>H$,transform:()=>n8,toUpperCase:()=>T4,toLowerCase:()=>C4,toJSONSchema:()=>a3,templateLiteral:()=>mZ,symbol:()=>_Z,superRefine:()=>dW,success:()=>yZ,stringbool:()=>nZ,stringFormat:()=>qZ,string:()=>P8,strictObject:()=>PZ,startsWith:()=>b4,slugify:()=>w4,size:()=>v2,setErrorMap:()=>eZ,set:()=>vZ,safeParseAsync:()=>F8,safeParse:()=>N8,safeEncodeAsync:()=>R8,safeEncode:()=>I8,safeDecodeAsync:()=>b8,safeDecode:()=>j8,registry:()=>o3,regexes:()=>y1,regex:()=>z4,refine:()=>cW,record:()=>_W,readonly:()=>yW,property:()=>U8,promise:()=>lZ,prettifyError:()=>Z$,preprocess:()=>aZ,prefault:()=>TW,positive:()=>W8,pipe:()=>K6,partialRecord:()=>CZ,parseAsync:()=>M8,parse:()=>O8,overwrite:()=>Q0,optional:()=>Y6,object:()=>bZ,number:()=>QW,nullish:()=>gZ,nullable:()=>W6,null:()=>BW,normalize:()=>E4,nonpositive:()=>B8,nonoptional:()=>wW,nonnegative:()=>q8,never:()=>r8,negative:()=>K8,nativeEnum:()=>fZ,nanoid:()=>iH,nan:()=>xZ,multipleOf:()=>Y2,minSize:()=>D0,minLength:()=>g0,mime:()=>A4,meta:()=>iZ,maxSize:()=>W2,maxLength:()=>f2,map:()=>wZ,mac:()=>$Z,lte:()=>x1,lt:()=>V0,lowercase:()=>I4,looseRecord:()=>TZ,looseObject:()=>AZ,locales:()=>i3,literal:()=>hZ,length:()=>h2,lazy:()=>mW,ksuid:()=>tH,keyof:()=>RZ,jwt:()=>BZ,json:()=>sZ,iso:()=>Q6,ipv6:()=>JZ,ipv4:()=>eH,intersection:()=>NW,int64:()=>FZ,int32:()=>OZ,int:()=>A8,instanceof:()=>oZ,includes:()=>R4,httpUrl:()=>dH,hostname:()=>UZ,hex:()=>GZ,hash:()=>HZ,guid:()=>xH,gte:()=>D1,gt:()=>_0,globalRegistry:()=>E1,getErrorMap:()=>$L,function:()=>pZ,fromJSONSchema:()=>iW,formatError:()=>M4,float64:()=>LZ,float32:()=>ZZ,flattenError:()=>O4,file:()=>kZ,exactOptional:()=>PW,enum:()=>o8,endsWith:()=>P4,encodeAsync:()=>D8,encode:()=>V8,emoji:()=>rH,email:()=>yH,e164:()=>KZ,discriminatedUnion:()=>SZ,describe:()=>rZ,default:()=>eb,decodeAsync:()=>z8,decode:()=>_8,date:()=>jZ,custom:()=>dZ,cuid2:()=>nH,cuid:()=>oH,core:()=>z0,config:()=>Y1,coerce:()=>JJ,codec:()=>uZ,clone:()=>N1,cidrv6:()=>XZ,cidrv4:()=>QZ,check:()=>cZ,catch:()=>hW,boolean:()=>XW,bigint:()=>NZ,base64url:()=>WZ,base64:()=>YZ,array:()=>U6,any:()=>zZ,_function:()=>pZ,_default:()=>SW,_ZodString:()=>E8,ZodXor:()=>LW,ZodXID:()=>h8,ZodVoid:()=>HW,ZodUnknown:()=>UW,ZodUnion:()=>H6,ZodUndefined:()=>WW,ZodUUID:()=>I0,ZodURL:()=>B6,ZodULID:()=>f8,ZodType:()=>g,ZodTuple:()=>FW,ZodTransform:()=>RW,ZodTemplateLiteral:()=>xW,ZodSymbol:()=>YW,ZodSuccess:()=>vW,ZodStringFormat:()=>r,ZodString:()=>x4,ZodSet:()=>zW,ZodRecord:()=>Z6,ZodRealError:()=>z1,ZodReadonly:()=>gW,ZodPromise:()=>lW,ZodPrefault:()=>CW,ZodPipe:()=>t8,ZodOptional:()=>s8,ZodObject:()=>G6,ZodNumberFormat:()=>g2,ZodNumber:()=>m4,ZodNullable:()=>AW,ZodNull:()=>KW,ZodNonOptional:()=>a8,ZodNever:()=>GW,ZodNanoID:()=>T8,ZodNaN:()=>kW,ZodMap:()=>DW,ZodMAC:()=>JW,ZodLiteral:()=>IW,ZodLazy:()=>uW,ZodKSUID:()=>k8,ZodJWT:()=>c8,ZodIssueCode:()=>tZ,ZodIntersection:()=>MW,ZodISOTime:()=>$6,ZodISODuration:()=>J6,ZodISODateTime:()=>t3,ZodISODate:()=>e3,ZodIPv6:()=>y8,ZodIPv4:()=>g8,ZodGUID:()=>X6,ZodFunction:()=>pW,ZodFirstPartyTypeKind:()=>$J,ZodFile:()=>jW,ZodExactOptional:()=>bW,ZodError:()=>gH,ZodEnum:()=>y4,ZodEmoji:()=>C8,ZodEmail:()=>S8,ZodE164:()=>p8,ZodDiscriminatedUnion:()=>OW,ZodDefault:()=>EW,ZodDate:()=>q6,ZodCustomStringFormat:()=>u4,ZodCustom:()=>L6,ZodCodec:()=>e8,ZodCatch:()=>fW,ZodCUID2:()=>v8,ZodCUID:()=>w8,ZodCIDRv6:()=>u8,ZodCIDRv4:()=>x8,ZodBoolean:()=>l4,ZodBigIntFormat:()=>d8,ZodBigInt:()=>p4,ZodBase64URL:()=>l8,ZodBase64:()=>m8,ZodArray:()=>ZW,ZodAny:()=>qW,TimePrecision:()=>Y8,NEVER:()=>W$,$output:()=>k$,$input:()=>g$,$brand:()=>K$});var QJ={};B2(QJ,{xor:()=>EZ,xid:()=>aH,void:()=>IZ,uuidv7:()=>pH,uuidv6:()=>lH,uuidv4:()=>mH,uuid:()=>uH,util:()=>w,url:()=>cH,uppercase:()=>j4,unknown:()=>k2,union:()=>i8,undefined:()=>DZ,ulid:()=>sH,uint64:()=>VZ,uint32:()=>MZ,tuple:()=>VW,trim:()=>S4,treeifyError:()=>H$,transform:()=>n8,toUpperCase:()=>T4,toLowerCase:()=>C4,toJSONSchema:()=>a3,templateLiteral:()=>mZ,symbol:()=>_Z,superRefine:()=>dW,success:()=>yZ,stringbool:()=>nZ,stringFormat:()=>qZ,string:()=>P8,strictObject:()=>PZ,startsWith:()=>b4,slugify:()=>w4,size:()=>v2,setErrorMap:()=>eZ,set:()=>vZ,safeParseAsync:()=>F8,safeParse:()=>N8,safeEncodeAsync:()=>R8,safeEncode:()=>I8,safeDecodeAsync:()=>b8,safeDecode:()=>j8,registry:()=>o3,regexes:()=>y1,regex:()=>z4,refine:()=>cW,record:()=>_W,readonly:()=>yW,property:()=>U8,promise:()=>lZ,prettifyError:()=>Z$,preprocess:()=>aZ,prefault:()=>TW,positive:()=>W8,pipe:()=>K6,partialRecord:()=>CZ,parseAsync:()=>M8,parse:()=>O8,overwrite:()=>Q0,optional:()=>Y6,object:()=>bZ,number:()=>QW,nullish:()=>gZ,nullable:()=>W6,null:()=>BW,normalize:()=>E4,nonpositive:()=>B8,nonoptional:()=>wW,nonnegative:()=>q8,never:()=>r8,negative:()=>K8,nativeEnum:()=>fZ,nanoid:()=>iH,nan:()=>xZ,multipleOf:()=>Y2,minSize:()=>D0,minLength:()=>g0,mime:()=>A4,meta:()=>iZ,maxSize:()=>W2,maxLength:()=>f2,map:()=>wZ,mac:()=>$Z,lte:()=>x1,lt:()=>V0,lowercase:()=>I4,looseRecord:()=>TZ,looseObject:()=>AZ,locales:()=>i3,literal:()=>hZ,length:()=>h2,lazy:()=>mW,ksuid:()=>tH,keyof:()=>RZ,jwt:()=>BZ,json:()=>sZ,iso:()=>Q6,ipv6:()=>JZ,ipv4:()=>eH,intersection:()=>NW,int64:()=>FZ,int32:()=>OZ,int:()=>A8,instanceof:()=>oZ,includes:()=>R4,httpUrl:()=>dH,hostname:()=>UZ,hex:()=>GZ,hash:()=>HZ,guid:()=>xH,gte:()=>D1,gt:()=>_0,globalRegistry:()=>E1,getErrorMap:()=>$L,function:()=>pZ,fromJSONSchema:()=>iW,formatError:()=>M4,float64:()=>LZ,float32:()=>ZZ,flattenError:()=>O4,file:()=>kZ,exactOptional:()=>PW,enum:()=>o8,endsWith:()=>P4,encodeAsync:()=>D8,encode:()=>V8,emoji:()=>rH,email:()=>yH,e164:()=>KZ,discriminatedUnion:()=>SZ,describe:()=>rZ,decodeAsync:()=>z8,decode:()=>_8,date:()=>jZ,custom:()=>dZ,cuid2:()=>nH,cuid:()=>oH,core:()=>z0,config:()=>Y1,coerce:()=>JJ,codec:()=>uZ,clone:()=>N1,cidrv6:()=>XZ,cidrv4:()=>QZ,check:()=>cZ,catch:()=>hW,boolean:()=>XW,bigint:()=>NZ,base64url:()=>WZ,base64:()=>YZ,array:()=>U6,any:()=>zZ,_function:()=>pZ,_default:()=>SW,_ZodString:()=>E8,ZodXor:()=>LW,ZodXID:()=>h8,ZodVoid:()=>HW,ZodUnknown:()=>UW,ZodUnion:()=>H6,ZodUndefined:()=>WW,ZodUUID:()=>I0,ZodURL:()=>B6,ZodULID:()=>f8,ZodType:()=>g,ZodTuple:()=>FW,ZodTransform:()=>RW,ZodTemplateLiteral:()=>xW,ZodSymbol:()=>YW,ZodSuccess:()=>vW,ZodStringFormat:()=>r,ZodString:()=>x4,ZodSet:()=>zW,ZodRecord:()=>Z6,ZodRealError:()=>z1,ZodReadonly:()=>gW,ZodPromise:()=>lW,ZodPrefault:()=>CW,ZodPipe:()=>t8,ZodOptional:()=>s8,ZodObject:()=>G6,ZodNumberFormat:()=>g2,ZodNumber:()=>m4,ZodNullable:()=>AW,ZodNull:()=>KW,ZodNonOptional:()=>a8,ZodNever:()=>GW,ZodNanoID:()=>T8,ZodNaN:()=>kW,ZodMap:()=>DW,ZodMAC:()=>JW,ZodLiteral:()=>IW,ZodLazy:()=>uW,ZodKSUID:()=>k8,ZodJWT:()=>c8,ZodIssueCode:()=>tZ,ZodIntersection:()=>MW,ZodISOTime:()=>$6,ZodISODuration:()=>J6,ZodISODateTime:()=>t3,ZodISODate:()=>e3,ZodIPv6:()=>y8,ZodIPv4:()=>g8,ZodGUID:()=>X6,ZodFunction:()=>pW,ZodFirstPartyTypeKind:()=>$J,ZodFile:()=>jW,ZodExactOptional:()=>bW,ZodError:()=>gH,ZodEnum:()=>y4,ZodEmoji:()=>C8,ZodEmail:()=>S8,ZodE164:()=>p8,ZodDiscriminatedUnion:()=>OW,ZodDefault:()=>EW,ZodDate:()=>q6,ZodCustomStringFormat:()=>u4,ZodCustom:()=>L6,ZodCodec:()=>e8,ZodCatch:()=>fW,ZodCUID2:()=>v8,ZodCUID:()=>w8,ZodCIDRv6:()=>u8,ZodCIDRv4:()=>x8,ZodBoolean:()=>l4,ZodBigIntFormat:()=>d8,ZodBigInt:()=>p4,ZodBase64URL:()=>l8,ZodBase64:()=>m8,ZodArray:()=>ZW,ZodAny:()=>qW,TimePrecision:()=>Y8,NEVER:()=>W$,$output:()=>k$,$input:()=>g$,$brand:()=>K$});var z0={};B2(z0,{version:()=>NX,util:()=>w,treeifyError:()=>H$,toJSONSchema:()=>a3,toDotPath:()=>UH,safeParseAsync:()=>j7,safeParse:()=>I7,safeEncodeAsync:()=>pR,safeEncode:()=>mR,safeDecodeAsync:()=>cR,safeDecode:()=>lR,registry:()=>o3,regexes:()=>y1,process:()=>n,prettifyError:()=>Z$,parseAsync:()=>O$,parse:()=>L$,meta:()=>GY,locales:()=>i3,isValidJWT:()=>EH,isValidBase64URL:()=>AH,isValidBase64:()=>yX,initializeContext:()=>h4,globalRegistry:()=>E1,globalConfig:()=>v3,formatError:()=>M4,flattenError:()=>O4,finalize:()=>g4,extractDefs:()=>k4,encodeAsync:()=>xR,encode:()=>gR,describe:()=>UY,decodeAsync:()=>uR,decode:()=>yR,createToJSONSchemaMethod:()=>ZY,createStandardJSONSchemaMethod:()=>G8,config:()=>Y1,clone:()=>N1,_xor:()=>zb,_xid:()=>o$,_void:()=>$Y,_uuidv7:()=>l$,_uuidv6:()=>m$,_uuidv4:()=>u$,_uuid:()=>x$,_url:()=>s3,_uppercase:()=>j4,_unknown:()=>t5,_union:()=>Db,_undefined:()=>n5,_ulid:()=>i$,_uint64:()=>i5,_uint32:()=>m5,_tuple:()=>Rb,_trim:()=>S4,_transform:()=>Tb,_toUpperCase:()=>T4,_toLowerCase:()=>C4,_templateLiteral:()=>ub,_symbol:()=>o5,_superRefine:()=>qY,_success:()=>kb,_stringbool:()=>HY,_stringFormat:()=>v4,_string:()=>E5,_startsWith:()=>b4,_slugify:()=>w4,_size:()=>v2,_set:()=>Ab,_safeParseAsync:()=>_4,_safeParse:()=>V4,_safeEncodeAsync:()=>z$,_safeEncode:()=>_$,_safeDecodeAsync:()=>I$,_safeDecode:()=>D$,_regex:()=>z4,_refine:()=>BY,_record:()=>bb,_readonly:()=>xb,_property:()=>U8,_promise:()=>lb,_positive:()=>W8,_pipe:()=>yb,_parseAsync:()=>F4,_parse:()=>N4,_overwrite:()=>Q0,_optional:()=>wb,_number:()=>h5,_nullable:()=>vb,_null:()=>s5,_normalize:()=>E4,_nonpositive:()=>B8,_nonoptional:()=>hb,_nonnegative:()=>q8,_never:()=>e5,_negative:()=>K8,_nativeEnum:()=>Sb,_nanoid:()=>c$,_nan:()=>XY,_multipleOf:()=>Y2,_minSize:()=>D0,_minLength:()=>g0,_min:()=>D1,_mime:()=>A4,_maxSize:()=>W2,_maxLength:()=>f2,_max:()=>x1,_map:()=>Pb,_mac:()=>C5,_lte:()=>x1,_lt:()=>V0,_lowercase:()=>I4,_literal:()=>Cb,_length:()=>h2,_lazy:()=>mb,_ksuid:()=>n$,_jwt:()=>X8,_isoTime:()=>v5,_isoDuration:()=>f5,_isoDateTime:()=>T5,_isoDate:()=>w5,_ipv6:()=>a$,_ipv4:()=>s$,_intersection:()=>jb,_int64:()=>r5,_int32:()=>u5,_int:()=>g5,_includes:()=>R4,_guid:()=>n3,_gte:()=>D1,_gt:()=>_0,_float64:()=>x5,_float32:()=>y5,_file:()=>WY,_enum:()=>Eb,_endsWith:()=>P4,_encodeAsync:()=>F$,_encode:()=>M$,_emoji:()=>p$,_email:()=>y$,_e164:()=>Q8,_discriminatedUnion:()=>Ib,_default:()=>fb,_decodeAsync:()=>V$,_decode:()=>N$,_date:()=>JY,_custom:()=>KY,_cuid2:()=>r$,_cuid:()=>d$,_coercedString:()=>S5,_coercedNumber:()=>k5,_coercedDate:()=>QY,_coercedBoolean:()=>p5,_coercedBigint:()=>d5,_cidrv6:()=>e$,_cidrv4:()=>t$,_check:()=>vH,_catch:()=>gb,_boolean:()=>l5,_bigint:()=>c5,_base64url:()=>J8,_base64:()=>$8,_array:()=>YY,_any:()=>a5,TimePrecision:()=>Y8,NEVER:()=>W$,JSONSchemaGenerator:()=>sY,JSONSchema:()=>fH,Doc:()=>P$,$output:()=>k$,$input:()=>g$,$constructor:()=>N,$brand:()=>K$,$ZodXor:()=>Q5,$ZodXID:()=>AX,$ZodVoid:()=>tX,$ZodUnknown:()=>sX,$ZodUnion:()=>d3,$ZodUndefined:()=>iX,$ZodUUID:()=>_X,$ZodURL:()=>zX,$ZodULID:()=>PX,$ZodType:()=>v,$ZodTuple:()=>f$,$ZodTransform:()=>H5,$ZodTemplateLiteral:()=>I5,$ZodSymbol:()=>rX,$ZodSuccess:()=>F5,$ZodStringFormat:()=>d,$ZodString:()=>w2,$ZodSet:()=>B5,$ZodRegistry:()=>A5,$ZodRecord:()=>W5,$ZodRealError:()=>A1,$ZodReadonly:()=>z5,$ZodPromise:()=>R5,$ZodPrefault:()=>M5,$ZodPipe:()=>D5,$ZodOptional:()=>h$,$ZodObjectJIT:()=>J5,$ZodObject:()=>TH,$ZodNumberFormat:()=>cX,$ZodNumber:()=>w$,$ZodNullable:()=>L5,$ZodNull:()=>oX,$ZodNonOptional:()=>N5,$ZodNever:()=>aX,$ZodNanoID:()=>jX,$ZodNaN:()=>_5,$ZodMap:()=>K5,$ZodMAC:()=>hX,$ZodLiteral:()=>U5,$ZodLazy:()=>b5,$ZodKSUID:()=>EX,$ZodJWT:()=>lX,$ZodIntersection:()=>Y5,$ZodISOTime:()=>TX,$ZodISODuration:()=>wX,$ZodISODateTime:()=>SX,$ZodISODate:()=>CX,$ZodIPv6:()=>fX,$ZodIPv4:()=>vX,$ZodGUID:()=>VX,$ZodFunction:()=>j5,$ZodFile:()=>G5,$ZodExactOptional:()=>Z5,$ZodError:()=>u3,$ZodEnum:()=>q5,$ZodEncodeError:()=>S2,$ZodEmoji:()=>IX,$ZodEmail:()=>DX,$ZodE164:()=>mX,$ZodDiscriminatedUnion:()=>X5,$ZodDefault:()=>O5,$ZodDate:()=>eX,$ZodCustomStringFormat:()=>pX,$ZodCustom:()=>P5,$ZodCodec:()=>r3,$ZodCheckUpperCase:()=>UX,$ZodCheckStringFormat:()=>D4,$ZodCheckStartsWith:()=>HX,$ZodCheckSizeEquals:()=>XX,$ZodCheckRegex:()=>BX,$ZodCheckProperty:()=>LX,$ZodCheckOverwrite:()=>MX,$ZodCheckNumberFormat:()=>e7,$ZodCheckMultipleOf:()=>t7,$ZodCheckMinSize:()=>QX,$ZodCheckMinLength:()=>WX,$ZodCheckMimeType:()=>OX,$ZodCheckMaxSize:()=>JX,$ZodCheckMaxLength:()=>YX,$ZodCheckLowerCase:()=>qX,$ZodCheckLessThan:()=>R$,$ZodCheckLengthEquals:()=>KX,$ZodCheckIncludes:()=>GX,$ZodCheckGreaterThan:()=>b$,$ZodCheckEndsWith:()=>ZX,$ZodCheckBigIntFormat:()=>$X,$ZodCheck:()=>o,$ZodCatch:()=>V5,$ZodCUID2:()=>bX,$ZodCUID:()=>RX,$ZodCIDRv6:()=>gX,$ZodCIDRv4:()=>kX,$ZodBoolean:()=>c3,$ZodBigIntFormat:()=>dX,$ZodBigInt:()=>v$,$ZodBase64URL:()=>uX,$ZodBase64:()=>xX,$ZodAsyncError:()=>F0,$ZodArray:()=>$5,$ZodAny:()=>nX});var W$=Object.freeze({status:"aborted"});function N($,J,Q){function X(B,q){if(!B._zod)Object.defineProperty(B,"_zod",{value:{def:q,constr:K,traits:new Set},enumerable:!1});if(B._zod.traits.has($))return;B._zod.traits.add($),J(B,q);let U=K.prototype,G=Object.keys(U);for(let H=0;H<G.length;H++){let L=G[H];if(!(L in B))B[L]=U[L].bind(B)}}let Y=Q?.Parent??Object;class W extends Y{}Object.defineProperty(W,"name",{value:$});function K(B){var q;let U=Q?.Parent?new W:this;X(U,B),(q=U._zod).deferred??(q.deferred=[]);for(let G of U._zod.deferred)G();return U}return Object.defineProperty(K,"init",{value:X}),Object.defineProperty(K,Symbol.hasInstance,{value:(B)=>{if(Q?.Parent&&B instanceof Q.Parent)return!0;return B?._zod?.traits?.has($)}}),Object.defineProperty(K,"name",{value:$}),K}var K$=Symbol("zod_brand");class F0 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class S2 extends Error{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}}var v3={};function Y1($){if($)Object.assign(v3,$);return v3}var w={};B2(w,{unwrapMessage:()=>f3,uint8ArrayToHex:()=>hR,uint8ArrayToBase64url:()=>vR,uint8ArrayToBase64:()=>KH,stringifyPrimitive:()=>G$,slugify:()=>O7,shallowClone:()=>N7,safeExtend:()=>AR,required:()=>CR,randomString:()=>DR,propertyKeyTypes:()=>g3,promiseAllObject:()=>_R,primitiveTypes:()=>F7,prefixIssues:()=>g1,pick:()=>RR,partial:()=>SR,parsedType:()=>z7,optionalKeys:()=>V7,omit:()=>bR,objectClone:()=>NR,numKeys:()=>zR,nullish:()=>$2,normalizeParams:()=>D,mergeDefs:()=>k0,merge:()=>ER,jsonStringifyReplacer:()=>H4,joinValues:()=>B$,issue:()=>L4,isPlainObject:()=>Q2,isObject:()=>C2,hexToUint8Array:()=>fR,getSizableOrigin:()=>y3,getParsedType:()=>IR,getLengthableOrigin:()=>x3,getEnumValues:()=>h3,getElementAtPath:()=>VR,floatSafeRemainder:()=>L7,finalizeIssue:()=>P1,extend:()=>PR,escapeRegex:()=>r1,esc:()=>q$,defineLazy:()=>u,createTransparentProxy:()=>jR,cloneDef:()=>FR,clone:()=>N1,cleanRegex:()=>k3,cleanEnum:()=>TR,captureStackTrace:()=>U$,cached:()=>Z4,base64urlToUint8Array:()=>wR,base64ToUint8Array:()=>WH,assignProp:()=>J2,assertNotEqual:()=>ZR,assertNever:()=>OR,assertIs:()=>LR,assertEqual:()=>HR,assert:()=>MR,allowsEval:()=>M7,aborted:()=>X2,NUMBER_FORMAT_RANGES:()=>_7,Class:()=>BH,BIGINT_FORMAT_RANGES:()=>D7});function HR($){return $}function ZR($){return $}function LR($){}function OR($){throw Error("Unexpected value in exhaustive check")}function MR($){}function h3($){let J=Object.values($).filter((X)=>typeof X==="number");return Object.entries($).filter(([X,Y])=>J.indexOf(+X)===-1).map(([X,Y])=>Y)}function B$($,J="|"){return $.map((Q)=>G$(Q)).join(J)}function H4($,J){if(typeof J==="bigint")return J.toString();return J}function Z4($){return{get value(){{let Q=$();return Object.defineProperty(this,"value",{value:Q}),Q}throw Error("cached value already set")}}}function $2($){return $===null||$===void 0}function k3($){let J=$.startsWith("^")?1:0,Q=$.endsWith("$")?$.length-1:$.length;return $.slice(J,Q)}function L7($,J){let Q=($.toString().split(".")[1]||"").length,X=J.toString(),Y=(X.split(".")[1]||"").length;if(Y===0&&/\d?e-\d?/.test(X)){let q=X.match(/\d?e-(\d?)/);if(q?.[1])Y=Number.parseInt(q[1])}let W=Q>Y?Q:Y,K=Number.parseInt($.toFixed(W).replace(".","")),B=Number.parseInt(J.toFixed(W).replace(".",""));return K%B/10**W}var YH=Symbol("evaluating");function u($,J,Q){let X=void 0;Object.defineProperty($,J,{get(){if(X===YH)return;if(X===void 0)X=YH,X=Q();return X},set(Y){Object.defineProperty($,J,{value:Y})},configurable:!0})}function NR($){return Object.create(Object.getPrototypeOf($),Object.getOwnPropertyDescriptors($))}function J2($,J,Q){Object.defineProperty($,J,{value:Q,writable:!0,enumerable:!0,configurable:!0})}function k0(...$){let J={};for(let Q of $){let X=Object.getOwnPropertyDescriptors(Q);Object.assign(J,X)}return Object.defineProperties({},J)}function FR($){return k0($._zod.def)}function VR($,J){if(!J)return $;return J.reduce((Q,X)=>Q?.[X],$)}function _R($){let J=Object.keys($),Q=J.map((X)=>$[X]);return Promise.all(Q).then((X)=>{let Y={};for(let W=0;W<J.length;W++)Y[J[W]]=X[W];return Y})}function DR($=10){let Q="";for(let X=0;X<$;X++)Q+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Q}function q$($){return JSON.stringify($)}function O7($){return $.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var U$="captureStackTrace"in Error?Error.captureStackTrace:(...$)=>{};function C2($){return typeof $==="object"&&$!==null&&!Array.isArray($)}var M7=Z4(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch($){return!1}});function Q2($){if(C2($)===!1)return!1;let J=$.constructor;if(J===void 0)return!0;if(typeof J!=="function")return!0;let Q=J.prototype;if(C2(Q)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Q,"isPrototypeOf")===!1)return!1;return!0}function N7($){if(Q2($))return{...$};if(Array.isArray($))return[...$];return $}function zR($){let J=0;for(let Q in $)if(Object.prototype.hasOwnProperty.call($,Q))J++;return J}var IR=($)=>{let J=typeof $;switch(J){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN($)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray($))return"array";if($===null)return"null";if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return"promise";if(typeof Map<"u"&&$ instanceof Map)return"map";if(typeof Set<"u"&&$ instanceof Set)return"set";if(typeof Date<"u"&&$ instanceof Date)return"date";if(typeof File<"u"&&$ instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${J}`)}},g3=new Set(["string","number","symbol"]),F7=new Set(["string","number","bigint","boolean","symbol","undefined"]);function r1($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function N1($,J,Q){let X=new $._zod.constr(J??$._zod.def);if(!J||Q?.parent)X._zod.parent=$;return X}function D($){let J=$;if(!J)return{};if(typeof J==="string")return{error:()=>J};if(J?.message!==void 0){if(J?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");J.error=J.message}if(delete J.message,typeof J.error==="string")return{...J,error:()=>J.error};return J}function jR($){let J;return new Proxy({},{get(Q,X,Y){return J??(J=$()),Reflect.get(J,X,Y)},set(Q,X,Y,W){return J??(J=$()),Reflect.set(J,X,Y,W)},has(Q,X){return J??(J=$()),Reflect.has(J,X)},deleteProperty(Q,X){return J??(J=$()),Reflect.deleteProperty(J,X)},ownKeys(Q){return J??(J=$()),Reflect.ownKeys(J)},getOwnPropertyDescriptor(Q,X){return J??(J=$()),Reflect.getOwnPropertyDescriptor(J,X)},defineProperty(Q,X,Y){return J??(J=$()),Reflect.defineProperty(J,X,Y)}})}function G$($){if(typeof $==="bigint")return $.toString()+"n";if(typeof $==="string")return`"${$}"`;return`${$}`}function V7($){return Object.keys($).filter((J)=>{return $[J]._zod.optin==="optional"&&$[J]._zod.optout==="optional"})}var _7={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},D7={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function RR($,J){let Q=$._zod.def,X=Q.checks;if(X&&X.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let W=k0($._zod.def,{get shape(){let K={};for(let B in J){if(!(B in Q.shape))throw Error(`Unrecognized key: "${B}"`);if(!J[B])continue;K[B]=Q.shape[B]}return J2(this,"shape",K),K},checks:[]});return N1($,W)}function bR($,J){let Q=$._zod.def,X=Q.checks;if(X&&X.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let W=k0($._zod.def,{get shape(){let K={...$._zod.def.shape};for(let B in J){if(!(B in Q.shape))throw Error(`Unrecognized key: "${B}"`);if(!J[B])continue;delete K[B]}return J2(this,"shape",K),K},checks:[]});return N1($,W)}function PR($,J){if(!Q2(J))throw Error("Invalid input to extend: expected a plain object");let Q=$._zod.def.checks;if(Q&&Q.length>0){let W=$._zod.def.shape;for(let K in J)if(Object.getOwnPropertyDescriptor(W,K)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let Y=k0($._zod.def,{get shape(){let W={...$._zod.def.shape,...J};return J2(this,"shape",W),W}});return N1($,Y)}function AR($,J){if(!Q2(J))throw Error("Invalid input to safeExtend: expected a plain object");let Q=k0($._zod.def,{get shape(){let X={...$._zod.def.shape,...J};return J2(this,"shape",X),X}});return N1($,Q)}function ER($,J){let Q=k0($._zod.def,{get shape(){let X={...$._zod.def.shape,...J._zod.def.shape};return J2(this,"shape",X),X},get catchall(){return J._zod.def.catchall},checks:[]});return N1($,Q)}function SR($,J,Q){let Y=J._zod.def.checks;if(Y&&Y.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let K=k0(J._zod.def,{get shape(){let B=J._zod.def.shape,q={...B};if(Q)for(let U in Q){if(!(U in B))throw Error(`Unrecognized key: "${U}"`);if(!Q[U])continue;q[U]=$?new $({type:"optional",innerType:B[U]}):B[U]}else for(let U in B)q[U]=$?new $({type:"optional",innerType:B[U]}):B[U];return J2(this,"shape",q),q},checks:[]});return N1(J,K)}function CR($,J,Q){let X=k0(J._zod.def,{get shape(){let Y=J._zod.def.shape,W={...Y};if(Q)for(let K in Q){if(!(K in W))throw Error(`Unrecognized key: "${K}"`);if(!Q[K])continue;W[K]=new $({type:"nonoptional",innerType:Y[K]})}else for(let K in Y)W[K]=new $({type:"nonoptional",innerType:Y[K]});return J2(this,"shape",W),W}});return N1(J,X)}function X2($,J=0){if($.aborted===!0)return!0;for(let Q=J;Q<$.issues.length;Q++)if($.issues[Q]?.continue!==!0)return!0;return!1}function g1($,J){return J.map((Q)=>{var X;return(X=Q).path??(X.path=[]),Q.path.unshift($),Q})}function f3($){return typeof $==="string"?$:$?.message}function P1($,J,Q){let X={...$,path:$.path??[]};if(!$.message){let Y=f3($.inst?._zod.def?.error?.($))??f3(J?.error?.($))??f3(Q.customError?.($))??f3(Q.localeError?.($))??"Invalid input";X.message=Y}if(delete X.inst,delete X.continue,!J?.reportInput)delete X.input;return X}function y3($){if($ instanceof Set)return"set";if($ instanceof Map)return"map";if($ instanceof File)return"file";return"unknown"}function x3($){if(Array.isArray($))return"array";if(typeof $==="string")return"string";return"unknown"}function z7($){let J=typeof $;switch(J){case"number":return Number.isNaN($)?"nan":"number";case"object":{if($===null)return"null";if(Array.isArray($))return"array";let Q=$;if(Q&&Object.getPrototypeOf(Q)!==Object.prototype&&"constructor"in Q&&Q.constructor)return Q.constructor.name}}return J}function L4(...$){let[J,Q,X]=$;if(typeof J==="string")return{message:J,code:"custom",input:Q,inst:X};return{...J}}function TR($){return Object.entries($).filter(([J,Q])=>{return Number.isNaN(Number.parseInt(J,10))}).map((J)=>J[1])}function WH($){let J=atob($),Q=new Uint8Array(J.length);for(let X=0;X<J.length;X++)Q[X]=J.charCodeAt(X);return Q}function KH($){let J="";for(let Q=0;Q<$.length;Q++)J+=String.fromCharCode($[Q]);return btoa(J)}function wR($){let J=$.replace(/-/g,"+").replace(/_/g,"/"),Q="=".repeat((4-J.length%4)%4);return WH(J+Q)}function vR($){return KH($).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function fR($){let J=$.replace(/^0x/,"");if(J.length%2!==0)throw Error("Invalid hex string length");let Q=new Uint8Array(J.length/2);for(let X=0;X<J.length;X+=2)Q[X/2]=Number.parseInt(J.slice(X,X+2),16);return Q}function hR($){return Array.from($).map((J)=>J.toString(16).padStart(2,"0")).join("")}class BH{constructor(...$){}}var qH=($,J)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:J,enumerable:!1}),$.message=JSON.stringify(J,H4,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},u3=N("$ZodError",qH),A1=N("$ZodError",qH,{Parent:Error});function O4($,J=(Q)=>Q.message){let Q={},X=[];for(let Y of $.issues)if(Y.path.length>0)Q[Y.path[0]]=Q[Y.path[0]]||[],Q[Y.path[0]].push(J(Y));else X.push(J(Y));return{formErrors:X,fieldErrors:Q}}function M4($,J=(Q)=>Q.message){let Q={_errors:[]},X=(Y)=>{for(let W of Y.issues)if(W.code==="invalid_union"&&W.errors.length)W.errors.map((K)=>X({issues:K}));else if(W.code==="invalid_key")X({issues:W.issues});else if(W.code==="invalid_element")X({issues:W.issues});else if(W.path.length===0)Q._errors.push(J(W));else{let K=Q,B=0;while(B<W.path.length){let q=W.path[B];if(B!==W.path.length-1)K[q]=K[q]||{_errors:[]};else K[q]=K[q]||{_errors:[]},K[q]._errors.push(J(W));K=K[q],B++}}};return X($),Q}function H$($,J=(Q)=>Q.message){let Q={errors:[]},X=(Y,W=[])=>{var K,B;for(let q of Y.issues)if(q.code==="invalid_union"&&q.errors.length)q.errors.map((U)=>X({issues:U},q.path));else if(q.code==="invalid_key")X({issues:q.issues},q.path);else if(q.code==="invalid_element")X({issues:q.issues},q.path);else{let U=[...W,...q.path];if(U.length===0){Q.errors.push(J(q));continue}let G=Q,H=0;while(H<U.length){let L=U[H],Z=H===U.length-1;if(typeof L==="string")G.properties??(G.properties={}),(K=G.properties)[L]??(K[L]={errors:[]}),G=G.properties[L];else G.items??(G.items=[]),(B=G.items)[L]??(B[L]={errors:[]}),G=G.items[L];if(Z)G.errors.push(J(q));H++}}};return X($),Q}function UH($){let J=[],Q=$.map((X)=>typeof X==="object"?X.key:X);for(let X of Q)if(typeof X==="number")J.push(`[${X}]`);else if(typeof X==="symbol")J.push(`[${JSON.stringify(String(X))}]`);else if(/[^\w$]/.test(X))J.push(`[${JSON.stringify(X)}]`);else{if(J.length)J.push(".");J.push(X)}return J.join("")}function Z$($){let J=[],Q=[...$.issues].sort((X,Y)=>(X.path??[]).length-(Y.path??[]).length);for(let X of Q)if(J.push(`\u2716 ${X.message}`),X.path?.length)J.push(` \u2192 at ${UH(X.path)}`);return J.join(`
64
- `)}var N4=($)=>(J,Q,X,Y)=>{let W=X?Object.assign(X,{async:!1}):{async:!1},K=J._zod.run({value:Q,issues:[]},W);if(K instanceof Promise)throw new F0;if(K.issues.length){let B=new(Y?.Err??$)(K.issues.map((q)=>P1(q,W,Y1())));throw U$(B,Y?.callee),B}return K.value},L$=N4(A1),F4=($)=>async(J,Q,X,Y)=>{let W=X?Object.assign(X,{async:!0}):{async:!0},K=J._zod.run({value:Q,issues:[]},W);if(K instanceof Promise)K=await K;if(K.issues.length){let B=new(Y?.Err??$)(K.issues.map((q)=>P1(q,W,Y1())));throw U$(B,Y?.callee),B}return K.value},O$=F4(A1),V4=($)=>(J,Q,X)=>{let Y=X?{...X,async:!1}:{async:!1},W=J._zod.run({value:Q,issues:[]},Y);if(W instanceof Promise)throw new F0;return W.issues.length?{success:!1,error:new($??u3)(W.issues.map((K)=>P1(K,Y,Y1())))}:{success:!0,data:W.value}},I7=V4(A1),_4=($)=>async(J,Q,X)=>{let Y=X?Object.assign(X,{async:!0}):{async:!0},W=J._zod.run({value:Q,issues:[]},Y);if(W instanceof Promise)W=await W;return W.issues.length?{success:!1,error:new $(W.issues.map((K)=>P1(K,Y,Y1())))}:{success:!0,data:W.value}},j7=_4(A1),M$=($)=>(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return N4($)(J,Q,Y)},gR=M$(A1),N$=($)=>(J,Q,X)=>{return N4($)(J,Q,X)},yR=N$(A1),F$=($)=>async(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return F4($)(J,Q,Y)},xR=F$(A1),V$=($)=>async(J,Q,X)=>{return F4($)(J,Q,X)},uR=V$(A1),_$=($)=>(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return V4($)(J,Q,Y)},mR=_$(A1),D$=($)=>(J,Q,X)=>{return V4($)(J,Q,X)},lR=D$(A1),z$=($)=>async(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return _4($)(J,Q,Y)},pR=z$(A1),I$=($)=>async(J,Q,X)=>{return _4($)(J,Q,X)},cR=I$(A1);var y1={};B2(y1,{xid:()=>A7,uuid7:()=>oR,uuid6:()=>iR,uuid4:()=>rR,uuid:()=>T2,uppercase:()=>a7,unicodeEmail:()=>GH,undefined:()=>n7,ulid:()=>P7,time:()=>l7,string:()=>c7,sha512_hex:()=>Mb,sha512_base64url:()=>Fb,sha512_base64:()=>Nb,sha384_hex:()=>Zb,sha384_base64url:()=>Ob,sha384_base64:()=>Lb,sha256_hex:()=>Ub,sha256_base64url:()=>Hb,sha256_base64:()=>Gb,sha1_hex:()=>Kb,sha1_base64url:()=>qb,sha1_base64:()=>Bb,rfc5322Email:()=>sR,number:()=>m3,null:()=>o7,nanoid:()=>S7,md5_hex:()=>Xb,md5_base64url:()=>Wb,md5_base64:()=>Yb,mac:()=>k7,lowercase:()=>s7,ksuid:()=>E7,ipv6:()=>h7,ipv4:()=>f7,integer:()=>r7,idnEmail:()=>aR,html5Email:()=>nR,hostname:()=>$b,hex:()=>Qb,guid:()=>T7,extendedDuration:()=>dR,emoji:()=>v7,email:()=>w7,e164:()=>u7,duration:()=>C7,domain:()=>Jb,datetime:()=>p7,date:()=>m7,cuid2:()=>b7,cuid:()=>R7,cidrv6:()=>y7,cidrv4:()=>g7,browserEmail:()=>tR,boolean:()=>i7,bigint:()=>d7,base64url:()=>j$,base64:()=>x7});var R7=/^[cC][^\s-]{8,}$/,b7=/^[0-9a-z]+$/,P7=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,A7=/^[0-9a-vA-V]{20}$/,E7=/^[A-Za-z0-9]{27}$/,S7=/^[a-zA-Z0-9_-]{21}$/,C7=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,dR=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,T7=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,T2=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},rR=T2(4),iR=T2(6),oR=T2(7),w7=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nR=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,sR=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,GH=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,aR=GH,tR=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,eR="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function v7(){return new RegExp(eR,"u")}var f7=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,h7=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,k7=($)=>{let J=r1($??":");return new RegExp(`^(?:[0-9A-F]{2}${J}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${J}){5}[0-9a-f]{2}$`)},g7=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,y7=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,x7=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,j$=/^[A-Za-z0-9_-]*$/,$b=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Jb=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,u7=/^\+[1-9]\d{6,14}$/,HH="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",m7=new RegExp(`^${HH}$`);function ZH($){return typeof $.precision==="number"?$.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":$.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${$.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function l7($){return new RegExp(`^${ZH($)}$`)}function p7($){let J=ZH({precision:$.precision}),Q=["Z"];if($.local)Q.push("");if($.offset)Q.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let X=`${J}(?:${Q.join("|")})`;return new RegExp(`^${HH}T(?:${X})$`)}var c7=($)=>{let J=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${J}$`)},d7=/^-?\d+n?$/,r7=/^-?\d+$/,m3=/^-?\d+(?:\.\d+)?$/,i7=/^(?:true|false)$/i,o7=/^null$/i;var n7=/^undefined$/i;var s7=/^[^A-Z]*$/,a7=/^[^a-z]*$/,Qb=/^[0-9a-fA-F]*$/;function l3($,J){return new RegExp(`^[A-Za-z0-9+/]{${$}}${J}$`)}function p3($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var Xb=/^[0-9a-fA-F]{32}$/,Yb=l3(22,"=="),Wb=p3(22),Kb=/^[0-9a-fA-F]{40}$/,Bb=l3(27,"="),qb=p3(27),Ub=/^[0-9a-fA-F]{64}$/,Gb=l3(43,"="),Hb=p3(43),Zb=/^[0-9a-fA-F]{96}$/,Lb=l3(64,""),Ob=p3(64),Mb=/^[0-9a-fA-F]{128}$/,Nb=l3(86,"=="),Fb=p3(86);var o=N("$ZodCheck",($,J)=>{var Q;$._zod??($._zod={}),$._zod.def=J,(Q=$._zod).onattach??(Q.onattach=[])}),OH={number:"number",bigint:"bigint",object:"date"},R$=N("$ZodCheckLessThan",($,J)=>{o.init($,J);let Q=OH[typeof J.value];$._zod.onattach.push((X)=>{let Y=X._zod.bag,W=(J.inclusive?Y.maximum:Y.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(J.value<W)if(J.inclusive)Y.maximum=J.value;else Y.exclusiveMaximum=J.value}),$._zod.check=(X)=>{if(J.inclusive?X.value<=J.value:X.value<J.value)return;X.issues.push({origin:Q,code:"too_big",maximum:typeof J.value==="object"?J.value.getTime():J.value,input:X.value,inclusive:J.inclusive,inst:$,continue:!J.abort})}}),b$=N("$ZodCheckGreaterThan",($,J)=>{o.init($,J);let Q=OH[typeof J.value];$._zod.onattach.push((X)=>{let Y=X._zod.bag,W=(J.inclusive?Y.minimum:Y.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(J.value>W)if(J.inclusive)Y.minimum=J.value;else Y.exclusiveMinimum=J.value}),$._zod.check=(X)=>{if(J.inclusive?X.value>=J.value:X.value>J.value)return;X.issues.push({origin:Q,code:"too_small",minimum:typeof J.value==="object"?J.value.getTime():J.value,input:X.value,inclusive:J.inclusive,inst:$,continue:!J.abort})}}),t7=N("$ZodCheckMultipleOf",($,J)=>{o.init($,J),$._zod.onattach.push((Q)=>{var X;(X=Q._zod.bag).multipleOf??(X.multipleOf=J.value)}),$._zod.check=(Q)=>{if(typeof Q.value!==typeof J.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof Q.value==="bigint"?Q.value%J.value===BigInt(0):L7(Q.value,J.value)===0)return;Q.issues.push({origin:typeof Q.value,code:"not_multiple_of",divisor:J.value,input:Q.value,inst:$,continue:!J.abort})}}),e7=N("$ZodCheckNumberFormat",($,J)=>{o.init($,J),J.format=J.format||"float64";let Q=J.format?.includes("int"),X=Q?"int":"number",[Y,W]=_7[J.format];$._zod.onattach.push((K)=>{let B=K._zod.bag;if(B.format=J.format,B.minimum=Y,B.maximum=W,Q)B.pattern=r7}),$._zod.check=(K)=>{let B=K.value;if(Q){if(!Number.isInteger(B)){K.issues.push({expected:X,format:J.format,code:"invalid_type",continue:!1,input:B,inst:$});return}if(!Number.isSafeInteger(B)){if(B>0)K.issues.push({input:B,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:X,inclusive:!0,continue:!J.abort});else K.issues.push({input:B,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:X,inclusive:!0,continue:!J.abort});return}}if(B<Y)K.issues.push({origin:"number",input:B,code:"too_small",minimum:Y,inclusive:!0,inst:$,continue:!J.abort});if(B>W)K.issues.push({origin:"number",input:B,code:"too_big",maximum:W,inclusive:!0,inst:$,continue:!J.abort})}}),$X=N("$ZodCheckBigIntFormat",($,J)=>{o.init($,J);let[Q,X]=D7[J.format];$._zod.onattach.push((Y)=>{let W=Y._zod.bag;W.format=J.format,W.minimum=Q,W.maximum=X}),$._zod.check=(Y)=>{let W=Y.value;if(W<Q)Y.issues.push({origin:"bigint",input:W,code:"too_small",minimum:Q,inclusive:!0,inst:$,continue:!J.abort});if(W>X)Y.issues.push({origin:"bigint",input:W,code:"too_big",maximum:X,inclusive:!0,inst:$,continue:!J.abort})}}),JX=N("$ZodCheckMaxSize",($,J)=>{var Q;o.init($,J),(Q=$._zod.def).when??(Q.when=(X)=>{let Y=X.value;return!$2(Y)&&Y.size!==void 0}),$._zod.onattach.push((X)=>{let Y=X._zod.bag.maximum??Number.POSITIVE_INFINITY;if(J.maximum<Y)X._zod.bag.maximum=J.maximum}),$._zod.check=(X)=>{let Y=X.value;if(Y.size<=J.maximum)return;X.issues.push({origin:y3(Y),code:"too_big",maximum:J.maximum,inclusive:!0,input:Y,inst:$,continue:!J.abort})}}),QX=N("$ZodCheckMinSize",($,J)=>{var Q;o.init($,J),(Q=$._zod.def).when??(Q.when=(X)=>{let Y=X.value;return!$2(Y)&&Y.size!==void 0}),$._zod.onattach.push((X)=>{let Y=X._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(J.minimum>Y)X._zod.bag.minimum=J.minimum}),$._zod.check=(X)=>{let Y=X.value;if(Y.size>=J.minimum)return;X.issues.push({origin:y3(Y),code:"too_small",minimum:J.minimum,inclusive:!0,input:Y,inst:$,continue:!J.abort})}}),XX=N("$ZodCheckSizeEquals",($,J)=>{var Q;o.init($,J),(Q=$._zod.def).when??(Q.when=(X)=>{let Y=X.value;return!$2(Y)&&Y.size!==void 0}),$._zod.onattach.push((X)=>{let Y=X._zod.bag;Y.minimum=J.size,Y.maximum=J.size,Y.size=J.size}),$._zod.check=(X)=>{let Y=X.value,W=Y.size;if(W===J.size)return;let K=W>J.size;X.issues.push({origin:y3(Y),...K?{code:"too_big",maximum:J.size}:{code:"too_small",minimum:J.size},inclusive:!0,exact:!0,input:X.value,inst:$,continue:!J.abort})}}),YX=N("$ZodCheckMaxLength",($,J)=>{var Q;o.init($,J),(Q=$._zod.def).when??(Q.when=(X)=>{let Y=X.value;return!$2(Y)&&Y.length!==void 0}),$._zod.onattach.push((X)=>{let Y=X._zod.bag.maximum??Number.POSITIVE_INFINITY;if(J.maximum<Y)X._zod.bag.maximum=J.maximum}),$._zod.check=(X)=>{let Y=X.value;if(Y.length<=J.maximum)return;let K=x3(Y);X.issues.push({origin:K,code:"too_big",maximum:J.maximum,inclusive:!0,input:Y,inst:$,continue:!J.abort})}}),WX=N("$ZodCheckMinLength",($,J)=>{var Q;o.init($,J),(Q=$._zod.def).when??(Q.when=(X)=>{let Y=X.value;return!$2(Y)&&Y.length!==void 0}),$._zod.onattach.push((X)=>{let Y=X._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(J.minimum>Y)X._zod.bag.minimum=J.minimum}),$._zod.check=(X)=>{let Y=X.value;if(Y.length>=J.minimum)return;let K=x3(Y);X.issues.push({origin:K,code:"too_small",minimum:J.minimum,inclusive:!0,input:Y,inst:$,continue:!J.abort})}}),KX=N("$ZodCheckLengthEquals",($,J)=>{var Q;o.init($,J),(Q=$._zod.def).when??(Q.when=(X)=>{let Y=X.value;return!$2(Y)&&Y.length!==void 0}),$._zod.onattach.push((X)=>{let Y=X._zod.bag;Y.minimum=J.length,Y.maximum=J.length,Y.length=J.length}),$._zod.check=(X)=>{let Y=X.value,W=Y.length;if(W===J.length)return;let K=x3(Y),B=W>J.length;X.issues.push({origin:K,...B?{code:"too_big",maximum:J.length}:{code:"too_small",minimum:J.length},inclusive:!0,exact:!0,input:X.value,inst:$,continue:!J.abort})}}),D4=N("$ZodCheckStringFormat",($,J)=>{var Q,X;if(o.init($,J),$._zod.onattach.push((Y)=>{let W=Y._zod.bag;if(W.format=J.format,J.pattern)W.patterns??(W.patterns=new Set),W.patterns.add(J.pattern)}),J.pattern)(Q=$._zod).check??(Q.check=(Y)=>{if(J.pattern.lastIndex=0,J.pattern.test(Y.value))return;Y.issues.push({origin:"string",code:"invalid_format",format:J.format,input:Y.value,...J.pattern?{pattern:J.pattern.toString()}:{},inst:$,continue:!J.abort})});else(X=$._zod).check??(X.check=()=>{})}),BX=N("$ZodCheckRegex",($,J)=>{D4.init($,J),$._zod.check=(Q)=>{if(J.pattern.lastIndex=0,J.pattern.test(Q.value))return;Q.issues.push({origin:"string",code:"invalid_format",format:"regex",input:Q.value,pattern:J.pattern.toString(),inst:$,continue:!J.abort})}}),qX=N("$ZodCheckLowerCase",($,J)=>{J.pattern??(J.pattern=s7),D4.init($,J)}),UX=N("$ZodCheckUpperCase",($,J)=>{J.pattern??(J.pattern=a7),D4.init($,J)}),GX=N("$ZodCheckIncludes",($,J)=>{o.init($,J);let Q=r1(J.includes),X=new RegExp(typeof J.position==="number"?`^.{${J.position}}${Q}`:Q);J.pattern=X,$._zod.onattach.push((Y)=>{let W=Y._zod.bag;W.patterns??(W.patterns=new Set),W.patterns.add(X)}),$._zod.check=(Y)=>{if(Y.value.includes(J.includes,J.position))return;Y.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:J.includes,input:Y.value,inst:$,continue:!J.abort})}}),HX=N("$ZodCheckStartsWith",($,J)=>{o.init($,J);let Q=new RegExp(`^${r1(J.prefix)}.*`);J.pattern??(J.pattern=Q),$._zod.onattach.push((X)=>{let Y=X._zod.bag;Y.patterns??(Y.patterns=new Set),Y.patterns.add(Q)}),$._zod.check=(X)=>{if(X.value.startsWith(J.prefix))return;X.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:J.prefix,input:X.value,inst:$,continue:!J.abort})}}),ZX=N("$ZodCheckEndsWith",($,J)=>{o.init($,J);let Q=new RegExp(`.*${r1(J.suffix)}$`);J.pattern??(J.pattern=Q),$._zod.onattach.push((X)=>{let Y=X._zod.bag;Y.patterns??(Y.patterns=new Set),Y.patterns.add(Q)}),$._zod.check=(X)=>{if(X.value.endsWith(J.suffix))return;X.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:J.suffix,input:X.value,inst:$,continue:!J.abort})}});function LH($,J,Q){if($.issues.length)J.issues.push(...g1(Q,$.issues))}var LX=N("$ZodCheckProperty",($,J)=>{o.init($,J),$._zod.check=(Q)=>{let X=J.schema._zod.run({value:Q.value[J.property],issues:[]},{});if(X instanceof Promise)return X.then((Y)=>LH(Y,Q,J.property));LH(X,Q,J.property);return}}),OX=N("$ZodCheckMimeType",($,J)=>{o.init($,J);let Q=new Set(J.mime);$._zod.onattach.push((X)=>{X._zod.bag.mime=J.mime}),$._zod.check=(X)=>{if(Q.has(X.value.type))return;X.issues.push({code:"invalid_value",values:J.mime,input:X.value.type,inst:$,continue:!J.abort})}}),MX=N("$ZodCheckOverwrite",($,J)=>{o.init($,J),$._zod.check=(Q)=>{Q.value=J.tx(Q.value)}});class P${constructor($=[]){if(this.content=[],this.indent=0,this)this.args=$}indented($){this.indent+=1,$(this),this.indent-=1}write($){if(typeof $==="function"){$(this,{execution:"sync"}),$(this,{execution:"async"});return}let Q=$.split(`
62
+ `?$.trim().split(/\s+/).filter(Boolean):$.split(J).filter(Boolean)}function m9($){if(!$)return!0;return $.provenance==="unknown"?!/[$`]/.test(h($)):$.provenance==="literal"}function j3($){return $?h($):""}function QI($){return`'${$.replaceAll("'",`'"'"'`)}'`}function xQ($,J){return yQ(a1($,"posix"),J)}function K4($){return xQ($,new Set(Array.from($.matchAll(uU)).flatMap((J)=>{let Q=J[1]??J[2];return Q===void 0?[]:[Q]})))}function yQ($,J){if($.status==="invalid"||$.status==="limited")return!1;let Q=new Set(J);for(let X of $.nodes){if(X.kind==="group"){if(yQ(X.body,Q))return!0;continue}if(X.kind!=="command")continue;if(X.nested.some((Y)=>yQ(Y,Q))||cU(X.words,Q))return!0;BI(X,Q)}return!1}function cU($,J){let Q=$.findIndex((K)=>q0(K.text)===null);if(Q===-1)return!1;let X=$[Q];if(!X)return!1;if(R3(X,J))return!0;let Y=i(X.text);if(Y==="source"||Y==="."){let K=$[Q+1]?.text==="--"?Q+2:Q+1;return xU($[K],J)}if(H1.has(Y)){let K=$.slice(Q),B=L0(K.map((U)=>U.text)),q=B.commandIndex??B.scriptIndex;return!B.syntaxCheck&&q!==null&&xU(K[q],J)}let W=XI($,Q,J);if(W===null)return!1;if(W===-1)return!0;return cU($.slice(W),J)}function XI($,J,Q){let X=i($[J]?.text??"");if(X==="command")return YI($,J+1);if(X==="exec")return WI($,J+1);if(X==="env")return KI($,J+1,Q);return null}function YI($,J){for(let Q=J;Q<$.length;Q++){let X=$[Q]?.text??"";if(X==="--")return $[Q+1]?Q+1:null;if(/^-[p]*[vV][pvV]*$/.test(X))return null;if(/^-p+$/.test(X))continue;return Q}return null}function WI($,J){for(let Q=J;Q<$.length;Q++){let X=$[Q]?.text??"";if(X==="--")return $[Q+1]?Q+1:null;if(X==="-a"){Q++;continue}if(/^-a.+/.test(X)||/^-[cl]+$/.test(X))continue;return Q}return null}function KI($,J,Q){for(let X=J;X<$.length;X++){let Y=$[X],W=Y?.text??"";if(W==="--")return $[X+1]?X+1:null;if(W==="-S"||W==="--split-string")return R3($[X+1],Q)?-1:X+2;if(W.startsWith("-S")||W.startsWith("--split-string="))return R3(Y,Q)?-1:X+1;if(W==="-u"||W==="--unset"||W==="-C"||W==="--chdir"||W==="-P"){X++;continue}if(W==="-i"||W==="-0"||W==="--null"||W.startsWith("-u=")||W.startsWith("--unset=")||W.startsWith("-C")||W.startsWith("--chdir=")||W.startsWith("-P"))continue;if(W.startsWith("-"))continue;if(q0(W))continue;return X}return null}function BI($,J){if(!$.words.every((Q)=>q0(Q.text)!==null))return;for(let Q of $.words){let X=q0(Q.text);if(!X)continue;if(R3(Q,J))J.add(X.name)}}function R3($,J){if(!$)return!1;return $.parts.filter((Q)=>Q.provenance==="variable").some((Q)=>Array.from(Q.raw.matchAll(uU)).some((X)=>{let Y=X[1]??X[2];return Y!==void 0&&(oz.test(Y)||J.has(Y))}))}function xU($,J){return!!$&&($.parts.some((Q)=>Q.provenance!=="literal"&&Q.provenance!=="variable")||R3($,J))}var qI=new Set(["-c","-C","--git-dir","--work-tree","--namespace","--config-env"]),UI=new Set(["-c","-H","-l","--config","--context","--host","--log-level","--tlscacert","--tlscert","--tlskey"]),GI=new Set;function dU($){if($==="git")return qI;if($==="docker")return UI;return GI}function O1($,J){if($.length===0||J.length===0)return null;let Q=i($[0]??""),X=v1($);for(let Y of J){if(!HI(Q,Y.command))continue;if(!ZI(Q,$,Y.subcommand))continue;if(OI($,new Set(Y.block_args),X))return{id:`custom.${Y.name}`,reason:`[${Y.name}] ${Y.reason}`,intent:Y.intent??"manual_only"}}return null}function HI($,J){return $===i(J)}function ZI($,J,Q){if(!Q)return!0;return rU(J,1,Q,dU($))}function rU($,J,Q,X){let Y=!1;for(let W=J;W<$.length;W++){let K=$[W];if(!K)continue;if(Y){Y=!1;continue}if(K==="--"){let B=$[W+1];if(B&&!B.startsWith("-"))return B===Q;return!1}if(X.has(K)){Y=!0;continue}if(K.startsWith("-")){if(!K.includes("=")&&LI($,W,Q,X))return!0;continue}return K===Q}return!1}function LI($,J,Q,X){let Y=$[J+1];if(!Y||Y.startsWith("-"))return!1;return rU($,J+2,Q,X)}function OI($,J,Q){for(let X of $)if(J.has(X))return!0;for(let X of Q)if(J.has(X))return!0;return!1}function t0($,J,Q={}){if($.length===0)return null;let X=$[0];if(!X)return null;let Y=i(X);if(Y==="eval"){let W=W4(p($));if(W.kind==="dynamic")return B4(Q,J);if(W.kind==="literal"&&J.analyzeNested){let K=J.analyzeNested(W.source,{effectiveCwd:J.cwd,envAssignments:J.envAssignments});if(K)return K}return M0(Q,J)}if(H1.has(Y)){if(c1($))return null;let W=Z0($);if(W){if(Q.dynamicSourceInput??Q.dynamicInput){let q=B4(Q,J);if(q)return q}if(K4(W)){let q=B4(Q,J);if(q)return q}if(!J.analyzeNested)return null;let B=J.analyzeNested(W,{effectiveCwd:J.cwd,envAssignments:J.envAssignments});if(B)return B;return null}let K=O0(p($));if(K.kind==="dynamic")return B4(Q,J);if(K.kind==="literal"){if(Q.dynamicSourceInput)return B4(Q,J);return null}if(Q.dynamicSourceInput??Q.dynamicInput)return B4(Q,J);return null}if(h1.has(Y))return k(h9($,(W)=>J.analyzeNested?J.analyzeNested(W,{effectiveCwd:J.cwd,envAssignments:J.envAssignments}):null),J.policy)??O1($,J.policy?.rules??[])??M0(Q,J);if(C1(Y)){let W=e6($);if(!W)return M0(Q,J);if(q1(J.policy,"interpreter.one-liner-paranoid",!!J.paranoidInterpreters)){let B=k(z("interpreter.one-liner-paranoid",n2),J.policy);if(B)return B}if(Q9(Y,W))return M0(Q,J);let K=J.analyzeNested?.(W,{effectiveCwd:J.cwd,envAssignments:J.envAssignments});if(K&&K.id!=="raw-text.dangerous-command"&&(K.reason!==r0||$4(W)))return K;if(s2(W,J.scanWork))return k(z("interpreter.dangerous-command",M2),J.policy)??M0(Q,J);return M0(Q,J)}if(Y==="rm"||Y==="rmdir"){let W=Y==="rm"&&(v0($)||Q.dynamicRmInput);return k(Y4(p($),{environment:J.environment,cwd:J.cwd,originalCwd:J.originalCwd,strict:J.strict,paranoid:J.paranoidRm,allowTmpdirVar:J.allowTmpdirVar,tmpdirWordSplittingUnsafe:B0(J.envAssignments,J.environment),trustedTmpdirValue:T0(J.envAssignments,J.environment),protectedGitMetadata:J.protectedGitMetadata,policy:J.policy}),J.policy)??(W&&Q.dynamicRmInput?M0(Q,J):null)??(W?MI(Q,J):null)}if(Y==="find")return g9(p($),{...J,derivedCommandWorkBudget:J.derivedCommandWorkBudget,analyzeTokens:(W,K)=>t0(W,{...J,cwd:K??void 0,derivedCommandWorkBudget:J.derivedCommandWorkBudget},Q)})??O1($,J.policy?.rules??[])??M0(Q,J);if(Y==="git")return k(X4(p($),{env:J.environment.env,cwd:J.cwd,envAssignments:J.envAssignments,policy:J.policy,worktreeMode:Q.dynamicInput?!1:J.worktreeMode}),J.policy)??O1($,J.policy?.rules??[])??M0(Q,J);return O1($,J.policy?.rules??[])??M0(Q,J)}function B4($,J){return $.shellDynamicMatch?k($.shellDynamicMatch,J.policy):null}function M0($,J){return $.dynamicSourceInput&&$.dynamicSourceMatch?k($.dynamicSourceMatch,J.policy):null}function MI($,J){return $.dynamicInput&&$.rmDynamicMatch?k($.rmDynamicMatch,J.policy):null}var uQ="xargs rm -rf with dynamic input is dangerous. Use explicit file list instead.",mQ="xargs dynamic input can supply arbitrary executable command source. Use an explicit child command and arguments instead.",NI="__CC_SAFETY_NET_XARGS_INPUT__",l9="__CC_SAFETY_NET_XARGS_INTERPRETER_INPUT__",p9="rm",FI=/(?:^|[;&|]\s*|\b(?:eval|source)\s+|\b(?:ba|da|z|k)?sh\s+-c\s+)\s*["']?\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)(?:[^}]*)\})/g,VI=/(?:^|[;&|]\s*)\s*eval\b((?:\\.|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\\'";&|\r\n])*)/g,_I=/\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)(?:[^}]*)\})/g,DI=/^(?:[0-9]+|[@*])$/,zI=new Set(["branch","checkout","clean","push","reset","restore","switch","tag"]);function nU($,J){let Q=$.map(h),{childStart:X,replacementToken:Y}=R2(Q),W=Q.slice(X),K=z("xargs.shell-dynamic",mQ);if(jI(W,Y,J)&&k(K,J.policy))return k(K,J.policy);for(let B of $0(W,J)){let q=B.tokens,U=Y!==null&&q[0]!==W[0]&&(q[0]?.includes(Y)??!1)?k(K,J.policy):null;if(U)return U;let G=eU(q,Y,B.wrapperEnvAssignments),H=B.head==="rm"&&Y!==null&&aU(q,Y),L=t0(q,{...J,cwd:B.cwd,envAssignments:B.envAssignments},{dynamicInput:G,dynamicSourceInput:H||sU(q,B.head,Y,B.wrapperEnvAssignments,G,J.scanWork,J.environment),dynamicRmInput:H,shellDynamicMatch:K,dynamicSourceMatch:K,rmDynamicMatch:z("xargs.rm-recursive-force-dynamic",uQ)});if(L)return L;let Z=II(q,Y,J.policy?.rules??[]);if(Z)return Z;if(B.head==="git"){let M=Y===null?[...q,NI]:q,V=Y!==null&&(q.some((b)=>b.includes(Y))||Array.from(B.envAssignments.values()).some((b)=>b.includes(Y))),F=t0(M,{...J,cwd:B.cwd,envAssignments:B.envAssignments,worktreeMode:Y===null||V?!1:J.worktreeMode});if(F)return F}let O=O1(q,J.policy?.rules??[]);if(O)return O}return null}function II($,J,Q){if(Q.length===0)return null;if(J===null){for(let Y of Q){let W=O1([...$,...Y.subcommand?[Y.subcommand]:[],...Y.block_args],Q);if(W)return W}return null}let X=new Set(Q.flatMap((Y)=>[Y.subcommand,...Y.block_args].flatMap((W)=>W?$.flatMap((K)=>lQ(K,J,W)):[])));for(let Y of X){let W=O1($.map((K)=>K.replaceAll(J,Y)),Q);if(W)return W}return null}function lQ($,J,Q){let X=$.indexOf(J);if(X===-1||$.indexOf(J,X+J.length)!==-1)return[];let Y=$.slice(0,X),W=$.slice(X+J.length);return Q.startsWith(Y)&&Q.endsWith(W)?[Q.slice(Y.length,Q.length-W.length)]:[]}function sU($,J,Q,X,Y,W,K){if(H1.has(J)){if(c1($))return!1;if(Q!==null&&RI($,Q))return!0;let B=Z0($);if(!B){let q=O0(p($));if(q.kind==="literal")return Q!==null&&q.source.includes(Q);return q.kind==="none"&&Y}if(Q!==null&&B.includes(Q))return!0;if(Y3(B,W))return!0;return bI(B,Q,X)}if(C1(J))return iU($,Q,J9,CB(J));if(h1.has(J))return iU($,Q,IQ,qU);if(J==="eval"){let B=W4(p($));if(B.kind==="dynamic")return!0;if(Q!==null)return B.kind==="literal"&&B.source.includes(Q);return Y}if(J==="find")return PI($,Q,W,K);if(J==="git"){let B=J0($);return Q===null?B.subcommand===null:(B.subcommand?.includes(Q)??!1)||B.subcommand!==null&&zI.has(B.subcommand.toLowerCase())&&tU(B.rest,Q).some((q)=>q.includes(Q))}return!1}function iU($,J,Q,X){let Y=Q($);if(J===null)return Y.optionsOpen||Q([...$,l9]).sources.some((q)=>q.value===l9);if(Y.sources.some((q)=>q.value.includes(J)))return!0;let W=new Set(Y.sources.map((q)=>`${q.tokenIndex}\x00${q.kind}\x00${q.value}`)),K=X.flatMap((q)=>[q.selector,...q.valueForm==="attached-only"||q.valueForm==="attached-or-separate"?[`${q.selector}${l9}`]:[],...q.valueForm==="equals-or-separate"?[`${q.selector}=${l9}`]:[]]),B=new Set(K.flatMap((q)=>$.flatMap((U)=>lQ(U,J,q))));return Array.from(B).some((q)=>Q($.map((U)=>U.replaceAll(J,q))).sources.some((U)=>!W.has(`${U.tokenIndex}\x00${U.kind}\x00${U.value}`)))}function jI($,J,Q){if($.length===0||($[0]??"").toLowerCase()==="command")return!1;let X=new Set(Array.from($0($,Q),(W)=>W.head)),Y=J===null?[...$,p9]:$.map((W,K)=>K===0?W:W.replaceAll(J,p9));return Array.from($0(Y,Q)).some((W)=>W.head===p9&&!X.has(p9))}function aU($,J){return tU($.slice(1),J).some((Q)=>Q.includes(J)&&(Q.startsWith("-")||Q.startsWith(J)))}function tU($,J){let Q=$.findIndex((X)=>X==="--"&&!X.includes(J));return Q===-1?$:$.slice(0,Q)}function eU($,J,Q){if(J===null)return!0;return $.some((X)=>X.includes(J))||Array.from(Q.values()).some((X)=>X.includes(J))}function RI($,J){let Q=L0($);if(Q.commandIndex!==null&&($[Q.commandIndex]??"").includes(J)||Q.scriptIndex!==null&&($[Q.scriptIndex]??"").includes(J))return!0;return["-c","-nc","-cn",`--${J}`,J].some((Y)=>$.some((W,K)=>{if(K===0||!W.includes(J))return!1;return lQ(W,J,Y).some((q)=>{let U=$.map((H,L)=>L===K?H.replaceAll(J,q):H),G=L0(U);if(G.commandIndex===null&&G.scriptIndex===null)return!1;if(Q.commandIndex===null&&G.commandIndex!==null)return!0;if(Q.scriptIndex===null&&G.scriptIndex!==null)return!0;if(G.commandIndex!==null&&(U[G.commandIndex]??"").includes(q))return!0;return G.scriptIndex!==null&&(U[G.scriptIndex]??"").includes(q)})}))}function bI($,J,Q){let X=new Set(J===null?[]:Array.from(Q).filter(([,Y])=>Y.includes(J)).map(([Y])=>Y));for(let Y of $.matchAll(FI))if(oU(Y,X))return!0;for(let Y of $.matchAll(VI))for(let W of(Y[1]??"").matchAll(_I))if(oU(W,X))return!0;return xQ($,X)}function oU($,J){let Q=$[1]??$[2];return Q!==void 0&&(DI.test(Q)||J.has(Q))}function PI($,J,Q,X){if(J===null)return!0;let Y=!1,W=0;for(let K=1;K<$.length;K++){let B=$[K]??"";if(!Y&&!B.startsWith("-")&&B!=="!"&&B!=="("){if(B.indexOf(J)===0)return!0;continue}if(Y=!0,W>0){W--;continue}if(f0(B)){let U=D3($,K);K=U.nextIndex-1;for(let G of $0(U.tokens,{environment:X,cwd:void 0})){let H=eU(G.tokens,J,G.wrapperEnvAssignments);if(G.head==="rm"&&aU(G.tokens,J)||sU(G.tokens,G.head,J,G.wrapperEnvAssignments,H,Q,X))return!0}continue}let q=s0(B);if(q>0){if(W=q,B.includes(J))return!0;continue}if(B.includes(J))return!0}return!1}function R2($){let J=new Set(["-L","-n","-P","-s","-a","-E","-R","-S","-e","-d","-J","--max-args","--max-procs","--max-chars","--arg-file","--eof","--delimiter","--max-lines","--process-slot-var"]),Q=null,X=1;while(X<$.length){let Y=$[X];if(!Y)break;if(Y==="--")return{childStart:X+1,replacementToken:Q};if(Y.startsWith("-")){if(Y==="-I"){Q=$[X+1]??"{}",X+=2;continue}if(Y.startsWith("-I")&&Y.length>2){Q=Y.slice(2),X++;continue}if(Y==="--replace"){Q="{}",X++;continue}if(Y.startsWith("--replace=")){let W=Y.slice(10);Q=W===""?"{}":W,X++;continue}if(Y==="-J"){Q=$[X+1]??"{}",X+=2;continue}if(J.has(Y))X+=2;else X++}else return{childStart:X,replacementToken:Q}}return{childStart:$.length,replacementToken:Q}}var b3="parallel rm -rf with dynamic input is dangerous. Use explicit file list instead.",P3="parallel with shell -c can execute arbitrary commands from dynamic input. Run the inner command directly on an explicit file list instead.",EI="parallel without a command reads executable commands from dynamic input. Use an explicit command template or ::: arguments instead.",SI="parallel command construction cannot be verified safely. Use the default ::: separator, literal arguments, and built-in replacement strings.",CI=/\{[^{}\s]*\}/,qG=/\{\}|\{-?\d+\}/g,TI=new Set(["branch","checkout","clean","merge","push","rebase","reflog","reset","restore","stash","switch","tag","worktree"]),wI=["e","f","source","file","-e","-f","--source","--file"],vI=["c","e","eval","m","r","Mmodule","import","require","-c","-e","-m","-r","--eval","--import","--require"],fI=new Set(["-L","-d","-n","--delay","--delimiter","--header","--joblog","--jl","--max-args","--max-lines","--nice","--results","--result","--res","--tagstring","--timeout"]),hI=new Set(["--arg-file","--colsep","--rpl","--arg-sep","--arg-file-sep"]),$G=new Set(["-S","--sshlogin","--slf","--sshloginfile"]),kI=new Set(["--workdir","--wd"]),JG="__CC_SAFETY_NET_PARALLEL_SOURCE__",gI=new TextEncoder,d9=f.maxDerivedBytes+4*f.maxPlaceholderReplacements;function _1($,J){for(let Q of $){let X=J(Q);if(X)return X}return null}function UG($,J){let Q=$.map(h);if((J.envAssignments?.has("PARALLEL")?J.envAssignments.get("PARALLEL"):J.environment.env.get("PARALLEL"))?.trim()){let M=P2(J);if(M)return M}if(Q.length===2&&(Q[1]==="--version"||Q[1]==="--help"))return null;let Y=zG(Q),{template:W,jobs:K,runsRemotely:B,envNames:q,readsCommandsFromInput:U,unsupported:G,workdir:H,dryRun:L}=Y;if(G){let M=P2(J);if(M)return M}if(U){let M=dI(J);if(M)return M}if(H!==void 0&&B){let M=P2(J);if(M)return M}let Z=sI(H,J.cwd,J.environment.paths);if(Z===null){let M=P2(J);if(M)return M}let O=B?{...J,cwd:void 0,originalCwd:void 0}:Z===null||Z===void 0||Z===J.cwd?J:{...J,cwd:Z};if(L){let M=[...$0(W,O)];if((M.length===0?dQ(q,J.envAssignments,new Map).values:M.flatMap((F)=>dQ(q,J.envAssignments,F.envAssignments).values)).some(oQ)){let F=P2(J);if(F)return F}return null}if(W.length===0){if(q.length>0||K.some((F)=>F.length!==1)){let F=P2(J);if(F)return F}let M=K.map((F)=>F[0]??"");T1(J.budget,cQ(M));let V=FG(O.envAssignments,O.cwd,B);return _1(M,(F)=>J.analyzeNested(F,V))}return _1($0(W,O),(M)=>yI(M,Y,J,O))}function yI($,J,Q,X){let{jobs:Y,templateHasPlaceholder:W,runsRemotely:K,usesStdin:B,envNames:q}=J,U=$.tokens,G={...X,cwd:$.cwd,envAssignments:$.envAssignments},H=dQ(q,Q.envAssignments,$.envAssignments);if(H.entries.some((F)=>_G(F.value))){let F=P2(Q);if(F)return F}let L=H.entries.some((F)=>F.hasPlaceholder),Z=W||L,O=B&&Z,M=FG($.envAssignments,$.wrapperCwd,K||O);if(H1.has($.head)){let F=()=>{if(!W||Y.length===0)return null;return T1(Q.budget,c9(U,Y,"generic")),_1(Y,(A)=>t0(U.map((E)=>N0(E,A)),G))};if(c1(U))return F();let b=Z0(U);if(b){if(DG(b)){let P=b2(Q);if(P)return P;if(Y.length===0)return null;return T1(Q.budget,KG(b,Y)),_1(Y,(S)=>Q.analyzeNested(N0(b,S),M))}if(s(b)){if(Y.length>0)return T1(Q.budget,KG(b,Y)),_1(Y,(T)=>Q.analyzeNested(N0(b,T),M));T1(Q.budget,YG(b));let P=z3(b);if(P?.[0]&&i(P[0])==="rm"&&v0(P)){let T=XG(Q);if(T)return T}let S=P?t0(P,G,{dynamicInput:B,shellDynamicMatch:z("parallel.shell-dynamic",P3),rmDynamicMatch:z("parallel.rm-recursive-force-dynamic",b3)}):null;if(S)return S;return Q.analyzeNested(b,M)}let A=!L&&(!W||Y.length>0)?(Y.length>0?Y:[void 0]).map((P)=>u9(p(P===void 0?U:W?U.map((S)=>N0(S,P)):[...U,...P]),b)):[];if(A.some((P)=>P.kind==="dynamic")){let P=b2(Q);if(P)return P}let E=A.flatMap((P)=>P.kind==="literal"?[P.source]:[]);if(E.length>0)return T1(Q.budget,cQ(E)),_1(E,(P)=>Q.analyzeNested(P,M));T1(Q.budget,iI(YG(b),rI(H.entries,Y)));let _=K4(b);if(_&&H.entries.length>0){let P=BG(H,Y,X,K);if(P)return P}if(_){let P=b2(Q);if(P)return P}let R=Q.analyzeNested(b,M);if(R)return R;if(!_){let P=BG(H,Y,X,K);if(P)return P}if(Z)return b2(Q);return null}let I=O0(p(U));if(I.kind==="dynamic"||I.kind==="literal"&&s(I.source))return b2(Q)??F();if(I.kind==="literal")return F();if(Y.length>0){let A=b2(Q);if(A)return A;let E=F();if(E)return E;if(W)return null;let _=Y.flatMap((R)=>R[0]===void 0?[]:[R[0]]);return T1(Q.budget,cQ(_)),_1(_,(R)=>Q.analyzeNested(R,M))}if(Z||B)return b2(Q)??F();return null}if($.head==="rm"&&v0(U)){if(W&&Y.length>0)return T1(Q.budget,c9(U,Y,"rm")),_1(Y,(b)=>pQ(U.map((I)=>rQ(I,b)),$.cwd,X));if(Y.length>0)return T1(Q.budget,WG(U,Y)),_1(Y,(b)=>pQ([...U,...b],$.cwd,X));let F=pQ(U.flatMap((b,I)=>{if(I===0||!s(b))return[b];return b.startsWith("-")?[rQ(b,[""])]:[]}),$.cwd,X);if(F)return F;return XG(Q)}T1(Q.budget,W&&Y.length>0?c9(U,Y,"generic"):Y.length>0?WG(U,Y):LG(U));let V=Y.length>0?Y:[void 0];return _1(V,(F)=>{let b=F===void 0?U:W?U.map((T)=>N0(T,F)):[...U,...F],I=z("parallel.shell-dynamic",P3),A=B&&$.head==="find"?cI(b,X):null,E=HG(b,B,Q.policy?.rules??[],Q.budget)??A?.customResult??null,_=i($.head),R=B&&(_==="rm"&&iQ(b)||_==="xargs"&&ZG(b)||A?.rmOptions===!0),P=B&&(R||A?.executedSource===!0||A===null&&GG(b,_)),S=t0(b,{...G,worktreeMode:K||B||Z?!1:Q.worktreeMode},{dynamicInput:B||Z,dynamicRmInput:R,dynamicSourceInput:E!==null||P,shellDynamicMatch:I,dynamicSourceMatch:I,rmDynamicMatch:z("parallel.rm-recursive-force-dynamic",b3)});if(P){let T=k(I,Q.policy);if(T)return T}return S??E??O1(b,Q.policy?.rules??[])})}function GG($,J){if(s($[0]??""))return!0;if(J==="eval"||J==="source"||J===".")return!0;if(J==="parallel"||J==="xargs")return!0;if(H1.has(J))return mI($);if(J==="git")return xI($);if(J==="find")return!0;if(h1.has(J))return QG($,wI,V3);if(C1(J))return QG($,vI,$9);return!1}function iQ($){let J=$.indexOf("--"),Q=$.slice(1,J===-1?void 0:J);if(!$.some(s))return J===-1;return Q.some((Y)=>s(Y)&&(Y.startsWith("-")||DG(Y)))}function xI($){if(uI($))return!0;let J=J0($);if(J.subcommand===null||s(J.subcommand))return!0;if(!TI.has(J.subcommand.toLowerCase()))return!1;let Q=J.rest.indexOf("--"),X=J.rest.slice(0,Q===-1?void 0:Q);if(!$.some(s))return Q===-1;return X.some(s)}function uI($){for(let J=1;J<$.length;J++){let Q=$[J];if(!Q||Q==="--"||!Q.startsWith("-"))return!1;if(Q==="-c"||Q==="--config-env"){if(s($[J+1]??""))return!0;J++;continue}if(Q.startsWith("-c")&&Q.length>2||Q.startsWith("--config-env=")){if(s(Q))return!0;continue}if(s(Q))return!0}return!1}function mI($){if(c1($))return!1;let J=Z0($);if(J!==null)return s(J);let Q=O0(p($));if(Q.kind==="literal")return s(Q.source);if(Q.kind==="dynamic")return!0;return!$.some(s)}function QG($,J,Q){let X=Q($);if(X.some((W)=>s(W.value)))return!0;if(!$.some(s))return Q([...$,JG]).some((W)=>W.value===JG);let Y=new Set(X.map((W)=>`${W.tokenIndex}\x00${W.kind}\x00${W.value}`));return J.some((W)=>Q($.map((K)=>N0(K,[W]))).some((K)=>!Y.has(`${K.tokenIndex}\x00${K.kind}\x00${K.value}`)))}function HG($,J,Q,X){if(!J||Q.length===0)return null;let Y=Q.filter((K)=>i(K.command)===i($[0]??""));if(Y.length===0)return null;let W=$.some(s);if(T1(X,lI($,Y,W)),!W)return _1(Y,(K)=>O1([...$,...K.subcommand?[K.subcommand]:[],...K.block_args],[K]));return _1(Y,(K)=>{let B=new Set([K.subcommand,...K.block_args].flatMap((q)=>q?pI($,q):[]));return _1(B,(q)=>O1($.map((U)=>N0(U,[q])),[K]))})}function lI($,J,Q){let X=Q?b1(U1(J.map((Y)=>Y.block_args.length+(Y.subcommand?1:0)),f.maxChildAnalyses),2*Math.max($.length,1),f.maxChildAnalyses):J.length;return{childAnalyses:X,derivedTokens:b1(X,$.length,f.maxDerivedTokens)}}function pI($,J){return $.flatMap((Q)=>{let X=[...Q.matchAll(/\{[^{}\s]*\}/g)];if(X.length!==1)return[];let Y=X[0];if(!Y||Y.index===void 0)return[];let W=Q.slice(0,Y.index),K=Q.slice(Y.index+Y[0].length);if(!J.startsWith(W)||!J.endsWith(K))return[J];let B=J.slice(W.length,J.length-K.length);return B!==J?[J,B]:[J]})}function cI($,J){let Q={customResult:null,executedSource:!$.some(s),rmOptions:!1},X=!1,Y=0,W=null,K=()=>{if(!W?.some(s))return;for(let B of $0(W,J))Q.executedSource||=GG(B.tokens,B.head),Q.rmOptions||=B.head==="rm"&&iQ(B.tokens)||B.head==="xargs"&&ZG(B.tokens),Q.customResult??=HG(B.tokens,!0,J.policy?.rules??[],J.budget)};for(let B of $.slice(1)){if(!X&&!B.startsWith("-")&&B!=="!"&&B!=="("){Q.executedSource||=s(B);continue}if(X=!0,W){if(B===";"||B==="+"){K(),W=null;continue}W.push(B);continue}if(Y>0){Y--;continue}if(f0(B)){W=[],Q.executedSource||=s(B);continue}let q=s0(B);if(q>0){Y=q,Q.executedSource||=s(B);continue}Q.executedSource||=s(B)}return K(),Q}function ZG($){let J=$.slice(R2($).childStart);return i(J[0]??"")==="rm"&&iQ(J)}function r9($,J){return(Q)=>k(z($,J),Q.policy)}var b2=r9("parallel.shell-dynamic",P3),dI=r9("parallel.command-stream-dynamic",EI),P2=r9("parallel.command-stream-dynamic",SI),XG=r9("parallel.rm-recursive-force-dynamic",b3);function pQ($,J,Q){return k(Y4(p($),{environment:Q.environment,cwd:J,originalCwd:Q.originalCwd,strict:Q.strict,paranoid:Q.paranoidRm,allowTmpdirVar:Q.allowTmpdirVar,tmpdirWordSplittingUnsafe:B0(Q.envAssignments??new Map,Q.environment),trustedTmpdirValue:T0(Q.envAssignments??new Map,Q.environment),protectedGitMetadata:Q.protectedGitMetadata,policy:Q.policy}),Q.policy)}function cQ($){return{childAnalyses:$.length,derivedTokens:$.length,derivedBytes:U4($)}}function YG($){return LG([$])}function LG($){return{childAnalyses:1,derivedTokens:$.length,derivedBytes:U4($)}}function WG($,J){if(J.length>f.maxChildAnalyses)return{childAnalyses:J.length};return{childAnalyses:J.length,derivedTokens:U1(J.map((Q)=>$.length+Q.length),f.maxDerivedTokens),derivedBytes:U1([b1(U4($),J.length,f.maxDerivedBytes),U1(J.map((Q)=>U4(Q)),f.maxDerivedBytes)],f.maxDerivedBytes)}}function KG($,J){return c9([$],J,"generic")}function c9($,J,Q){if(J.length>f.maxChildAnalyses)return{childAnalyses:J.length};let X=b1($.length,J.length,f.maxDerivedTokens);if(X>f.maxDerivedTokens)return{childAnalyses:J.length,derivedTokens:X};let Y=NG($.map((q)=>MG(q,Q))),W=b1(Y.occurrences,J.length,f.maxPlaceholderReplacements);if(W>f.maxPlaceholderReplacements)return{childAnalyses:J.length,derivedTokens:X,placeholderReplacements:W};if(OG(Y,J,W))return{childAnalyses:J.length,derivedTokens:X,derivedBytes:f.maxDerivedBytes+1,placeholderReplacements:W};let K=Q==="generic"?N0:rQ,B=U1(J.map((q)=>U4($.map((U)=>K(U,q)))),f.maxDerivedBytes);return{childAnalyses:J.length,derivedTokens:X,derivedBytes:B,placeholderReplacements:W}}function OG($,J,Q){let X=f.maxDerivedBytes+4*Q;return U1([b1($.fixedBytes,J.length,X),b1($.occurrences,U1(J.map((Y)=>Y.reduce((W,K)=>Math.max(W,q4(K)),0)),X),X)],X)>X}function rI($,J){let Q=$.filter((G)=>G.hasPlaceholder),X=Math.max(J.length,1),Y=U1(Q.map((G)=>G.frequency),f.maxChildAnalyses),W=b1(Y,X,f.maxChildAnalyses),K=b1(Y,X,f.maxDerivedTokens);if(W>f.maxChildAnalyses||K>f.maxDerivedTokens)return{childAnalyses:W,derivedTokens:K};if(J.length===0)return{childAnalyses:W,derivedTokens:K,derivedBytes:U1(Q.map((G)=>b1(q4(G.value),G.frequency,f.maxDerivedBytes)),f.maxDerivedBytes)};let B=NG(Q.map((G)=>oI(MG(G.value,"generic"),G.frequency))),q=b1(B.occurrences,X,f.maxPlaceholderReplacements);if(q>f.maxPlaceholderReplacements)return{childAnalyses:W,placeholderReplacements:q};if(OG(B,J,q))return{childAnalyses:W,derivedTokens:K,derivedBytes:f.maxDerivedBytes+1,placeholderReplacements:q};let U=U1(Q.map((G)=>b1(U4(J.map((H)=>N0(G.value,H))),G.frequency,f.maxDerivedBytes)),f.maxDerivedBytes);return{childAnalyses:W,derivedTokens:K,derivedBytes:U,placeholderReplacements:q}}function iI($,J){return{childAnalyses:U1([$.childAnalyses??0,J.childAnalyses??0],f.maxChildAnalyses),derivedTokens:U1([$.derivedTokens??0,J.derivedTokens??0],f.maxDerivedTokens),derivedBytes:U1([$.derivedBytes??0,J.derivedBytes??0],f.maxDerivedBytes),placeholderReplacements:U1([$.placeholderReplacements??0,J.placeholderReplacements??0],f.maxPlaceholderReplacements)}}function MG($,J){let Q=J==="generic"?$.matchAll(/\{[^{}\s]*\}/g):$.matchAll(qG),X=0,Y=0,W=0;for(let K of Q){if(X>=f.maxPlaceholderReplacements)return{occurrences:f.maxPlaceholderReplacements+1,fixedBytes:0};Y=U1([Y,q4($.slice(W,K.index))],d9),X++,W=K.index+K[0].length}return{occurrences:X,fixedBytes:X===0?q4($):U1([Y,q4($.slice(W))],d9)}}function oI($,J){return{occurrences:b1($.occurrences,J,f.maxPlaceholderReplacements),fixedBytes:b1($.fixedBytes,J,d9)}}function NG($){return{occurrences:U1($.map((J)=>J.occurrences),f.maxPlaceholderReplacements),fixedBytes:U1($.map((J)=>J.fixedBytes),d9)}}function U4($,J=f.maxDerivedBytes){return U1($.map(q4),J)}function q4($){return gI.encode($).byteLength}function U1($,J){let Q=0;for(let X of $){if(!Number.isSafeInteger(X)||X<0||X>J-Q)return J+1;Q+=X}return Q}function b1($,J,Q){if(!Number.isSafeInteger($)||!Number.isSafeInteger(J)||$<0||J<0||$!==0&&J>Math.floor(Q/$))return Q+1;return $*J}function dQ($,J,Q){let X=[];for(let Y of $){let W=Q.get(Y)??J?.get(Y);if(W!==void 0)X.push(W)}return X.push(...Q.values()),nI(X)}function nI($){let J=new Map;for(let X of $)J.set(X,(J.get(X)??0)+1);let Q=[...J].map(([X,Y])=>({value:X,frequency:Y,hasPlaceholder:s(X)}));return{values:$,entries:Q,byValue:new Map(Q.map((X)=>[X.value,X]))}}function BG($,J,Q,X){return _1($.values,(Y)=>{if(!$.byValue.get(Y)?.hasPlaceholder)return null;let W=J.length>0?J:[void 0];return _1(W,(K)=>{let B=K===void 0?Y:N0(Y,K);return Q.analyzeNested(B,{envAssignments:Q.envAssignments,effectiveCwd:X?null:Q.cwd})})})}function FG($,J,Q){let X={};if($)X.envAssignments=$;if(Q)return X.effectiveCwd=null,X.worktreeMode=!1,X;if(J!==void 0)X.effectiveCwd=J;return Object.keys(X).length>0?X:void 0}function N0($,J){return $.replace(/\{[^{}\s]*\}/g,(Q)=>VG(Q,J))}function rQ($,J){return $.replace(qG,(Q)=>VG(Q,J))}function VG($,J){let Q=/^\{(-?\d+)[^{}\s]*\}$/.exec($)?.[1];if(Q===void 0)return J[0]??"";let X=Number(Q),Y=X>0?X-1:J.length+X;return J[Y]??""}function s($){return CI.test($)}function _G($){if(oQ($))return!0;for(let J of $.matchAll(/\{[^{}\s]*\}/g))if(!/^(?:\{\}|\{-?\d+\})$/.test(J[0]))return!0;return!1}function oQ($){let J=$.indexOf("{=");return J!==-1&&$.indexOf("=}",J+2)!==-1}function DG($){return/^\{[^{}\s]*\}$/.test($)}function zG($){let J=1,Q=[],X=$.length,Y=-1,W=!1,K=!1,B=!1,q,U=$.some((M)=>M==="::::"||M==="::::+"||M===":::+"),G=[];while(J<$.length){let M=$[J];if(M===void 0)break;if(M===":::"){Y=J;break}if(M==="--"){let A=bQ($,J+1);Q.push(...A.templateTokens),X=J+1,Y=A.markerIndex;break}if(!M.startsWith("-")){let A=bQ($,J);Q.push(...A.templateTokens),X=J,Y=A.markerIndex;break}let V=$[J+1],F=M.indexOf("="),b=F===-1?M:M.slice(0,F),I=F===-1?void 0:M.slice(F+1);if(M==="--dry-run"){B=!0,J++;continue}if(M==="-I"||M.startsWith("-I")&&M.length>2){U||=(M==="-I"?V:M.slice(2))!=="{}",J+=M==="-I"?2:1;continue}if(M==="--replace"||M==="-i"){U=!0,J+=2;continue}if(b==="--replace"||M.startsWith("-i")&&M.length>2){let A=b==="--replace"?I:M.slice(2);U||=A!==""&&A!=="{}",J++;continue}if(M==="-a"||hI.has(b)){U=!0,J+=I===void 0?2:1;continue}if(M==="--pipe"||M==="--pipepart"){K=!0,J++;continue}if(b==="--env"){G.push(...tI(I??V)),J+=I===void 0?2:1;continue}if($G.has(b)||M.startsWith("-S")&&M.length>2){W=!0,J+=$G.has(M)?2:1;continue}if(kI.has(b)){let A=I??V;if(A===void 0||A===":::"||A==="--"){U=!0,J++;continue}q=A,U||=I!==void 0&&A==="",J+=I===void 0?2:1;continue}if(M.startsWith("-j")&&M.length>2&&/^\d+$/.test(M.slice(2))){J++;continue}if(M.startsWith("--")&&I!==void 0){J++;continue}if(fI.has(M)){if(V===void 0||V===":::"||V==="--"){U=!0,J++;continue}J+=2;continue}J+=M==="-j"||M==="--jobs"?2:1}U||=Q.some(B?oQ:_G);let H=[];if(Y!==-1){let M=[];for(let V=Y+1;V<$.length;V++){let F=$[V];if(F===":::"){H.push(M),M=[];continue}if(F!==void 0)M.push(F)}H.push(M)}let L=aI(H),Z=Q.some(s),O=Q.length===0&&Y===-1;return{template:Q,jobs:L,childStart:X,templateHasPlaceholder:Z,runsRemotely:W,usesStdin:K||Y===-1,envNames:G,readsCommandsFromInput:O,unsupported:U,workdir:q,dryRun:B}}function sI($,J,Q){if($===void 0)return;if($==="..."||/[{}$`*?~[]/.test($))return null;if(!J&&!AI($))return null;try{return d0(J??$,$,Q)}catch{return null}}function aI($){if($.length===0||$.some((Q)=>Q.length===0))return[];let J=[[]];for(let Q of $){if(Q.length===1){let Y=Q[0];if(Y===void 0)return[];for(let W of J)W.push(Y);continue}let X=[];for(let Y of J)for(let W of Q)if(X.push([...Y,W]),X.length>f.maxChildAnalyses)return X;J=X}return J}function tI($){return($??"").split(",").map((J)=>J.trim()).filter(Boolean)}function IG($){return zG($).childStart}var eI="dynamic command name contains shell substitution output and cannot be verified safely. Use a literal executable name.",nQ="shell substitution output can change guarded command structure and cannot be verified safely. Use literal subcommands and options.",$j=new Set(["branch","checkout","clean","merge","push","rebase","reflog","reset","restore","stash","switch","tag","worktree"]);function aQ($){return $?.parts.some((J)=>J.provenance==="command-substitution")??!1}function sQ($){return $?.parts.some((J)=>J.provenance==="literal"&&J.raw.replace(/^["']/,"").startsWith("-"))??!1}function RG($,J,Q,X=!1,Y){let W=$Q($,J)&&q1(Y,"shell.dynamic-executable",X)?z("shell.dynamic-executable",eI):null;return k(W,Y)??bG($,J,Q,X,Y)}function bG($,J,Q,X,Y){if(J.length<2)return null;let W=J.flatMap((B,q)=>aQ(B)?[q]:[]);if(W.length===0)return null;let K=i(J[0]?.text??"");if(K==="git"){let B=p2($,J),q=Qj(B);if(q1(Y,"shell.dynamic-structure",X)&&W.some((H)=>H<=q))return k(z("shell.dynamic-structure",nQ),Y);if(k(X4(B,{env:Q.env}),Y))return null;let U=J[q]?.text.toLowerCase(),G=B.findIndex((H,L)=>L>q&&h(H)==="--");if(q1(Y,"shell.dynamic-structure",X)&&U&&$j.has(U)&&W.some((H)=>H>q&&(G===-1||H<G)))return k(z("shell.dynamic-structure",nQ),Y);return null}if(K==="find")return q1(Y,"shell.dynamic-structure",X)&&Xj(J)?k(z("shell.dynamic-structure",nQ),Y):null;if(K==="xargs")return jG($,J.slice(R2(J.map(h)).childStart),"xargs",Q,X,Y);if(K==="parallel")return jG($,J.slice(IG(J.map(h))),"parallel",Q,X,Y);return null}function jG($,J,Q,X,Y,W){if(J.length===0)return null;let K=Jj(J,X);if($Q($,K)){let q=k(z(`${Q}.shell-dynamic`,Q==="xargs"?mQ:P3),W);if(q)return q}let B=bG($,K,X,Y,W);if(B)return B;if(K[0]?.text==="rm"&&K.slice(1).some((q)=>aQ(q)&&sQ(q)))return k(z(`${Q}.rm-recursive-force-dynamic`,Q==="xargs"?uQ:b3),W);return null}function Jj($,J){let Q=N2($,J),X=Q.rewritten?p(Q.words.map(h)):Q.words,Y=X[0];return Y&&h(Y)==="busybox"?X.slice(1):X}function Qj($){let J=1;while(J<$.length){let Q=$[J],X=Q?h(Q):"";if(W0.has(X)){J+=2;continue}if(X.startsWith("-")){J++;continue}return J}return J}function Xj($){let J=!1,Q=0,X=!1,Y=!1;for(let W=1;W<$.length;W++){let K=$[W];if(!K)continue;let B=aQ(K);if(Q>0){Q--;continue}if(Y){if(K.text===";"||K.text==="+"){Y=!1,J=!0,X=!1;continue}if(B&&(X||sQ(K)))return!0;X=!1;continue}if(!J&&!K.text.startsWith("-")){if(B&&(W>1||sQ(K)))return!0;continue}if(J=!0,B)return!0;let q=s0(K.text);if(q>0){Q=q;continue}if(f0(K.text))Y=!0,X=!0}return!1}function tQ($,J){return $.some((Q)=>{if(Q.value==="-"&&(Q.kind==="main-script"||Q.kind==="program-file"))return!0;return!g6(J[Q.tokenIndex],Q.value)})}var Yj="dd writing to a /dev device can destroy a disk or partition. Run device writes manually after confirming the target.",Wj="mkfs formatting a /dev device erases everything on it. Run the format manually after confirming the target.",Kj="shred permanently destroys the given target. Use rm for ordinary deletes, or run shred manually.";function PG($,J){let Q=J.slice(1);if($==="dd"&&Q.some((X)=>/^of=\/dev\/.+/.test(X)))return z("dd.device-write",Yj);if(($==="mkfs"||$.startsWith("mkfs."))&&Q.some((X)=>X.startsWith("/dev/")))return z("mkfs.device",Wj);if($==="shred"&&Q.length>0)return z("shred.target",Kj);return null}var EG=[{heads:new Set(["rm","rmdir"]),analyze:($)=>Y4($.words,{environment:$.options.environment,cwd:$.cwd,originalCwd:$.originalCwd,strict:$.options.strict,paranoid:$.options.paranoidRm,allowTmpdirVar:$.allowTmpdirVar,tmpdirWordSplittingUnsafe:B0($.envAssignments,$.options.environment),trustedTmpdirValue:T0($.envAssignments,$.options.environment),protectedGitMetadata:$.options.protectedGitMetadata,policy:$.options.policy})},{heads:new Set(["git"]),analyze:($)=>X4($.words,eQ($))},{heads:new Set(["find"]),analyze:($)=>g9($.words,{environment:$.options.environment,cwd:$.cwd,originalCwd:$.originalCwd,strict:$.options.strict,allowTmpdirVar:$.allowTmpdirVar,tmpdirWordSplittingUnsafe:B0($.envAssignments,$.options.environment),trustedTmpdirValue:T0($.envAssignments,$.options.environment),protectedGitMetadata:$.options.protectedGitMetadata,derivedCommandWorkBudget:$.options.derivedCommandWorkBudget,envAssignments:$.envAssignments,policy:$.options.policy,analyzeTokens:$.analyzeChildTokens,analyzeNested:(J,Q)=>A2($.options.analyzeNested(J,Q))})},{heads:new Set(["xargs"]),analyze:($)=>nU($.words,{...AG($),analyzeNested:(J,Q)=>A2($.options.analyzeNested(J,Q))})},{heads:new Set(["parallel"]),analyze:($)=>UG($.words,{...AG($),budget:$.options.parallelBudget,analyzeNested:(J,Q)=>A2($.options.analyzeNested(J,Q))})}];function AG($){return{environment:$.options.environment,cwd:$.cwd,originalCwd:$.originalCwd,strict:$.options.strict,paranoidRm:$.options.paranoidRm,paranoidInterpreters:$.options.paranoidInterpreters,allowTmpdirVar:$.allowTmpdirVar,protectedGitMetadata:$.options.protectedGitMetadata,derivedCommandWorkBudget:$.options.derivedCommandWorkBudget,envAssignments:$.envAssignments,worktreeMode:$.options.worktreeMode,policy:$.options.policy,scanWork:$.options.scanWork}}function A2($){return $?{id:$.ruleId??"",reason:$.reason,intent:$.intent??"manual_only"}:null}function eQ($){return{env:$.options.environment.env,cwd:$.cwd,dynamicArguments:$.dynamicArguments,envAssignments:$.envAssignments,policy:$.options.policy,worktreeMode:$.options.worktreeMode}}var wG="shell execution source cannot be verified safely. Use a literal command string or ask the user to run it manually.";function vG($){return EG.find((J)=>J.heads.has($))?.analyze}function A3($,J,Q){let X=Q.trace;if($.length===0)return null;let Y=Q.commandView?.dialect??"posix",W=(C)=>C.map((m)=>Y==="posix"?h(m):m.text),K=Q.effectiveCwd===null,B=K?void 0:Q.effectiveCwd??Q.cwd,q=K?void 0:Q.cwd,U=B9($);if(U.envAssignments.size>0)X?.recordSegment({type:"env-strip",input:W($),envVars:Object.fromEntries([...U.envAssignments.keys()].map((C)=>[C,"<redacted>"])),output:W(U.words)});let G=N2(U.words,Q.environment,B,new Map([...Q.envAssignments??[],...U.envAssignments]));if(G.unverifiableEnvSplit)throw new L2;let H=G.rewritten?p(W(G.words)):p2(Y,G.words),L=W(H),Z={...Q,wrapperNormalizationBudget:Q.wrapperNormalizationBudget??{iterations:0}};if(X&&U.words.length>H.length){let C=W(U.words);X.recordSegment({type:"leading-tokens-stripped",input:C,removed:C.slice(0,C.length-H.length),output:L})}let O=new Map([...Q.envAssignments??[],...U.envAssignments,...G.envAssignments]),M=L[0];if(!M)return null;if(_3(M))throw new m1;let V=i(M),F=G.cwd===null?void 0:G.cwd??B,b=G.cwd===null?void 0:q,I=G.cwd===void 0?Q.effectiveCwd:G.cwd,A=!K3(O,Q.environment),E=RG(Y,G.words,Q.environment,Q.strict,Q.policy);if(E)return X?.recordSegment({type:"rule-check",ruleModule:"analyze/segment.ts",ruleFunction:"analyzeDynamicCommandStructure",matched:!0,reason:E.reason}),h0(E);let _=k9(L,Q.policy);if(_){for(let C of[_.childIndex,..._.alternativeChildIndices]){SG(Z.wrapperNormalizationBudget);let m=H.slice(C);X?.recordSegment({type:"transparent-wrapper",wrapper:_.wrapper,output:W(m)});let X1=A3(m,J,{...Z,effectiveCwd:I,envAssignments:O});if(X1)return X1}return null}let R=V==="eval"?W4(H):V==="trap"?lU(H):void 0;if(R?.kind==="dynamic")return d1(X);if(R?.kind==="literal"){X?.recordSegment({type:"recurse",reason:V==="eval"?"shell-eval":"shell-trap",innerCommand:R.source,depth:J+1});let C=Q.analyzeNested(R.source,{effectiveCwd:I,envAssignments:O,functionDefinitions:Q.functionDefinitions});if(C)return C}if(hG(M,V)){if(c1(L))return null;let C=Bj(L,O,I,Q,X,J);if(C)return C;let m=Z0(L);if(m){let m2=u9(H,m);if(m2.kind==="dynamic")return d1(X);let GJ=m2.kind==="literal"?m2.source:m,ZK=qj(GJ);X?.recordSegment({type:"shell-wrapper",wrapper:V,innerCommand:ZK}),X?.recordSegment({type:"recurse",reason:"shell-wrapper",innerCommand:ZK,depth:J+1});let LK=Q.analyzeNested(GJ,{effectiveCwd:I,envAssignments:O});if(LK)return LK;return K4(GJ)?d1(X):null}let X1=O0(H);if(X1.kind==="dynamic")return d1(X);if(X1.kind==="literal")return n9(X1.source,I,O,Q,X,J);let Z1=pU(H,Q.commandView?.redirections??[],Q.hasPipelineInput??!1,Q.literalShellInput);if(Z1.kind==="dynamic")return d1(X);if(Z1.kind==="literal")return X?.recordSegment({type:"recurse",reason:"shell-stdin",innerCommand:Z1.source,depth:J+1}),Q.analyzeNested(Z1.source,{effectiveCwd:I,envAssignments:O})}if(V==="source"||V==="."){let C=L[1]==="-p"?2:null;if(C!==null){let m2=Q.commandView?H[C]:void 0;if(!m2)return null;if(m2.provenance!=="literal")return d1(X)}let m=C===null?1:3,X1=L[m]==="--"?m+1:m,Z1=Q.commandView?H[X1]:void 0;if(!Z1)return null;if(Z1.provenance!=="literal")return d1(X);return n9(Z1.text,I,O,Q,X,J)}if(h1.has(V)){if(Q.strict&&tQ(V3(L),H))return d1(X);let C=h9(L,(X1)=>A2(Q.analyzeNested(X1,{effectiveCwd:I,envAssignments:O}))),m=k(C,Q.policy);if(m)return X?.recordSegment({type:"rule-check",ruleModule:"awk",ruleFunction:"analyzeAwkSystemCalls",matched:!0,reason:m.reason}),h0(m)}if(C1(V)){if(Q.strict&&tQ($9(L),H))return d1(X);let C=e6(L);if(C){let m=q1(Q.policy,"interpreter.one-liner-paranoid",!!Q.paranoidInterpreters);if(X?.recordSegment({type:"interpreter",interpreter:V,codeArg:C,paranoidBlocked:m}),m){let Z1=k(z("interpreter.one-liner-paranoid",n2),Q.policy);if(Z1)return h0(Z1)}if(Q9(V,C))return null;X?.recordSegment({type:"recurse",reason:"interpreter",innerCommand:C,depth:J+1});let X1=Q.analyzeNested(C,{effectiveCwd:I,envAssignments:O});if(X1&&X1.ruleId!=="raw-text.dangerous-command"&&(X1.reason!==r0||$4(C)))return X1;if(s2(C,Q.scanWork)){let Z1=k(z("interpreter.dangerous-command",M2),Q.policy);if(Z1)return X?.recordSegment({type:"dangerous-text",token:C,matched:!0,reason:M2}),h0(Z1)}X=void 0}}if(V==="busybox"&&L.length>1)return SG(Z.wrapperNormalizationBudget),X?.recordSegment({type:"busybox",subcommand:L[1]??"unknown"}),X?.recordSegment({type:"recurse",reason:"busybox",innerCommand:L.slice(1).join(" "),depth:J+1}),A3(H.slice(1),J,{...Z,effectiveCwd:I,envAssignments:O});let P=k(PG(V,L),Q.policy);if(P)return X?.recordSegment({type:"rule-check",ruleModule:"analyze/device.ts",ruleFunction:"analyzeDeviceCommand",matched:!0,reason:P.reason}),h0(P);let S=X===Z.trace?Z:{...Z,trace:X},T={words:H,head:V,cwd:F,originalCwd:b,envAssignments:O,allowTmpdirVar:A,dynamicArguments:G.words.some((C)=>C.provenance==="command-substitution"),depth:J,effectiveCwd:I,options:S,analyzeChildTokens:(C,m)=>A2(A3(p(C),J+1,{...S,commandView:void 0,effectiveCwd:m,envAssignments:O}))??O1(C,S.policy.rules)},y=vG(V);if(V==="rm"||V==="xargs"||V==="parallel")X?.recordSegment({type:"tmpdir-check",tmpdirValue:O.has("TMPDIR")||Q.environment.env.has("TMPDIR")?"<redacted>":null,isOverriddenToNonTemp:!A,allowTmpdirVar:A});let x=X&&V==="git"?TU(T.words,eQ(T)):void 0,c=CG(x?x.match:y?.(T)??null,Q.policy);if(X)Uj(T,c,x?.relaxation??null);if(c)return h0(c);let V1=y!==void 0;if(!V1)if(!a6.has(V)){let C=X?[]:void 0;for(let m=1;m<L.length;m++){let X1=L[m];if(!X1)continue;C?.push(X1);let Z1=CG(Gj(T,L,m),Q.policy);if(Z1)return X?.recordSegment({type:"fallback-scan",tokensScanned:C??[],embeddedCommandFound:i(X1)}),h0(Z1)}X?.recordSegment({type:"fallback-scan",tokensScanned:C??[]})}else X?.recordSegment({type:"fallback-scan",tokensScanned:[]});else X?.recordSegment({type:"fallback-scan",tokensScanned:[]});if(J===0||!V1){let C=O1(L,Q.policy.rules);if(X?.recordSegment({type:"custom-rules-check",rulesChecked:Q.policy.rules.length>0,matched:!!C,reason:C?.reason}),C)return h0(C)}else X?.recordSegment({type:"custom-rules-check",rulesChecked:!1,matched:!1});return null}function Bj($,J,Q,X,Y,W){let K=gU($);if(K.argvSource?.kind==="absent")return d1(Y);if(K.argvSourceApplies&&K.argvSource){let q=n9(K.argvSource.value,Q,J,X,Y,W,!0);if(q)return q}if(!K.envSourceApplies||!K.envName)return null;let B=J.get(K.envName);if(!B)return null;return n9(B,Q,J,X,Y,W,!0)}function n9($,J,Q,X,Y,W,K=!1){if(K&&/[$`*?[\]]/.test($))return d1(Y);let B=W3($,J,X.environment.paths),q=B?X.literalHeredocFiles?.get(B):void 0;if(q===void 0)return K?d1(Y):null;return K0(X.derivedCommandWorkBudget,1),Y?.recordSegment({type:"recurse",reason:"heredoc-file",innerCommand:q,depth:W+1}),X.analyzeNested(q,{effectiveCwd:J,envAssignments:Q})}function qj($){let J=$[0];return $.length>=2&&(J==='"'||J==="'")&&$.at(-1)===J?$.slice(1,-1):$}function Uj($,J,Q){let X={git:["git","analyzeGit"],rm:["analyze/rm.ts","analyzeRm"],find:["analyze/find.ts","analyzeFind"],xargs:["analyze/xargs.ts","analyzeXargs"],parallel:["analyze/parallel.ts","analyzeParallel"]}[$.head];if(!X)return;if($.options.trace?.recordSegment({type:"rule-check",ruleModule:X[0]??"",ruleFunction:X[1]??"",matched:!!J||!!Q,reason:J?.reason??Q?.originalReason}),Q)$.options.trace?.recordSegment({type:"worktree-relaxation",originalReason:Q.originalReason,gitCwd:Q.gitCwd})}function SG($){if($.iterations>=i2)throw new m1;$.iterations++}function h0($){return{reason:$.reason,ruleId:$.id||void 0,intent:$.intent}}function d1($){return $?.recordSegment({type:"error",message:wG}),h0(fG())}function fG(){return{id:"",reason:wG,intent:"stop_and_explain"}}function hG($,J){return H1.has(J)||$==="$SHELL"||$==="${SHELL}"||H1.has(l(J))}function Gj($,J,Q){let X=$0(J.slice(Q),{environment:$.options.environment,cwd:$.cwd,envAssignments:$.envAssignments,policy:$.options.policy});for(let Y of X){let W=Hj($,Q,Y);if(W)return W}return null}function Hj($,J,Q){let X=Q.tokens[0];if(!X)return null;let Y=i(X);if(hG(X,Y)){K0($.options.derivedCommandWorkBudget,$.words.length-J);let q=Q.tokens;if(c1(q))return null;let U=Z0(q);if(!U){if(O0(p(q)).kind==="dynamic")return fG();return o9($,Q)}let G=$.options.analyzeNested(U,{effectiveCwd:Q.wrapperCwd===void 0?$.effectiveCwd:Q.wrapperCwd,envAssignments:Q.envAssignments});return G?A2(G):o9($,Q)}let W=vG(Y);if(!W||Y==="xargs"||Y==="parallel"){if(Q.wrappedByTransparent&&$.options.policy.rules.length>0)K0($.options.derivedCommandWorkBudget,$.words.length-J);return o9($,Q)}K0($.options.derivedCommandWorkBudget,$.words.length-J);let K=[Y,...Q.tokens.slice(1)],B={...$,words:p(K),head:Y,cwd:Q.cwd,originalCwd:Q.wrapperCwd===null?void 0:$.originalCwd,envAssignments:Q.envAssignments,allowTmpdirVar:!K3(Q.envAssignments,$.options.environment),effectiveCwd:Q.wrapperCwd===void 0?$.effectiveCwd:Q.wrapperCwd,options:Y==="git"?{...$.options,worktreeMode:!1}:$.options};return W(B)??o9($,Q)}function o9($,J){return J.wrappedByTransparent?O1(J.tokens,$.options.policy.rules):null}function CG($,J){return $?.id.startsWith("custom.")?$:k($,J)}var Zj=/^\s*(?:\$\(\s*)?[({]*\s*(?:command\s+|builtin\s+)?(?:cd|pushd|popd)(?:\s|$)/,Lj=new Set(["cd","chdir","pop-location","popd","push-location","pushd","set-location","sl"]);function Oj($,J){let Q=yG($,J);if(Q.length===0)return!1;let X=Q[gG(Q)];if(X==="cd"||X==="pushd"||X==="popd")return!0;return Zj.test($.join(" "))}function kG($,J,Q,X){if($.dialect==="powershell"){let B=Mj($.words,X);if(B.kind==="none")return;if(!J||B.kind==="unknown")return null;return TG(_j(B.target),J,Q.paths)}let Y=$.words.map(h);if(!Oj(Y,Q))return;if(!J)return null;let W=yG(Y,Q,J),K=gG(W);if(K===-1||W[K]!=="cd")return null;return TG(W[K+1],J,Q.paths)}function TG($,J,Q){if(!$||$==="-"||$.includes("$")||$.includes("`"))return null;try{return Dj(d0(J,$,Q),J,Q)?J:null}catch{return null}}function Mj($,J){let Q=Nj($[0])?1:0,X=$[Q];if(!Fj(X,Q===1))return{kind:"none"};let Y=X.text.toLowerCase(),W=Y.split(/[\\/]/).pop()??Y;if(!Lj.has(W))return{kind:"none"};if(Y!==W||W==="pop-location"||W==="popd")return{kind:"unknown"};return Vj($.slice(Q+1),J)}function Nj($){return $?.provenance==="literal"&&!$.quoted&&$.raw===$.text&&($.text==="&"||$.text===".")}function Fj($,J){return $?.provenance==="literal"&&(J||!$.quoted&&$.raw===$.text)}function Vj($,J){let Q;for(let X of $){if(X.provenance!=="literal"||Q!==void 0)return{kind:"unknown"};Q=X.text}if(Q!==void 0)return{kind:"target",target:Q};return J===void 0?{kind:"unknown"}:{kind:"target",target:J}}function _j($){return $.includes("::")?void 0:$.replaceAll("\\","/")}function gG($){let J=0;if($[0]==="builtin"&&$.length>1)J=1;if($[J]!=="time")return J;let Q=J+1;while($[Q]?.startsWith("-"))Q++;return Q}function yG($,J,Q){let X=zj($);return l1([...X],J,Q)}function Dj($,J,Q){let X=Q.realpath($),Y=Q.realpath(J);if(X===null||Y===null)return i9($)===i9(J);return i9(X)===i9(Y)}function zj($){let J=0;while(J<$.length){let Q=$[J];if(Q==="{"||Q==="("||Q==="$(")J++;else break}return $.slice(J)}var E3="TMPDIR",S3="IFS",Ij=/^([A-Za-z_][A-Za-z0-9_]*)\+=/,$7=/^[A-Za-z_][A-Za-z0-9_]*$/;function uG($,J){let Q=Aj($,J);return{env:$,effectiveEnvAssignments:Q,shellAssignments:new Map,exportedNames:Ej($,Q),allexport:!1,keywordExport:!1}}function mG($){return{env:$.env,effectiveEnvAssignments:$.effectiveEnvAssignments?new Map($.effectiveEnvAssignments):void 0,shellAssignments:new Map($.shellAssignments),exportedNames:new Set($.exportedNames),allexport:$.allexport,keywordExport:$.keywordExport}}function lG($,J){let Q=jj($,J);if(!Q)return;let{command:X,commandIndex:Y,leadingAssignments:W,prefixAssignmentsPersist:K}=Q;if(X===null){for(let q of W.values())xG(J,q);return}if(K)for(let q of W.values())J.shellAssignments.set(q.name,q.value),J.exportedNames.add(q.name),e0(J,q);if(X==="set"){let q=hj($,Y);if(q.allexport!==null)J.allexport=q.allexport;if(q.keywordExport!==null)J.keywordExport=q.keywordExport;return}if(X==="unset"){let q=wj($,Y);if(q===null)return;for(let U of $.slice(q))Tj(J,U);return}if(X!=="export"&&X!=="typeset"&&X!=="declare"&&X!=="readonly")return;for(let q of W.values())xG(J,q);if(X==="export"){let q=vj($,Y);if(q===null)return;for(let U of $.slice(q))Sj(J,U);return}let B=fj($,Y);if(B===null)return;for(let q of $.slice(B.operandsStart))Cj(J,q,B.exports,X==="readonly"?W:void 0)}function pG($,J){if(!J.keywordExport)return J.effectiveEnvAssignments;let Q=null,X=t9(J);for(let Y of $){let W=a9(Y,X,J.env);if(!W)continue;Q??=new Map(J.effectiveEnvAssignments??[]),Q.set(W.name,W.value),X.set(W.name,W.value)}return Q??J.effectiveEnvAssignments}function jj($,J){let Q=new Map,X=0;while(X<$.length){let B=$[X];if(!B)return null;let q=a9(B,t9(J,Q),J.env);if(!q)break;Q.set(q.name,q),X++}if(X>=$.length)return{command:null,commandIndex:X,leadingAssignments:Q,prefixAssignmentsPersist:!1};let Y=X,W=X,K=$[W]??null;while(K==="builtin"||K==="command"||K==="time"){if(K==="builtin"){if(W++,$[W]==="--")W++;K=$[W]??null;continue}if(K==="command"){let q=Rj($,W);if(!q)return null;W=q.commandIndex,K=q.command;continue}let B=bj($,W);if(!B)return null;W=B.commandIndex,K=B.command}if(K===null)return null;return{command:K,commandIndex:W,leadingAssignments:Q,prefixAssignmentsPersist:W===Y&&(K==="unset"||K==="set"||K==="export"||K==="readonly")}}function Rj($,J){return cG($,J,(Q)=>{if(Q==="-p")return"skip";return Q==="-v"||Q==="-V"?"abort":"stop"})}function bj($,J){return cG($,J,(Q)=>Q.startsWith("-")?"skip":"stop")}function cG($,J,Q){let X=J+1;while(X<$.length){let W=$[X];if(!W)return null;if(W==="--"){X++;break}let K=Q(W);if(K==="abort")return null;if(K==="skip"){X++;continue}break}let Y=$[X];return Y?{command:Y,commandIndex:X}:null}function a9($,J,Q){return q0($)??Pj($,J,Q)}function Pj($,J,Q){let X=u6($,Q,J);if(X)return X;let Y=$.match(Ij)?.[1];if(!Y)return null;let W=$.indexOf("=");return{name:Y,value:`${J.has(Y)?J.get(Y):Q.get(Y)??""}${$.slice(W+1)}`}}function s9($){return $===E3||$===S3||EJ($)}function t9($,J){return new Map([...$.effectiveEnvAssignments??[],...$.shellAssignments,...[...J?.values()??[]].map((Q)=>[Q.name,Q.value])])}function Aj($,J){let Q=[...y6,E3,S3].map((X)=>{let Y=$.get(X);return Y===void 0?null:[X,Y]}).filter((X)=>X!==null);if(Q.length===0)return J;return new Map([...Q,...J??[]])}function Ej($,J){let Q=new Set;for(let X of $.keys())if(s9(X))Q.add(X);for(let X of J?.keys()??[])if(s9(X))Q.add(X);return Q}function xG($,J){if($.shellAssignments.set(J.name,J.value),J.name===E3||J.name===S3||$.allexport||$.exportedNames.has(J.name))e0($,J)}function e0($,J){let Q=new Map($.effectiveEnvAssignments??[]);Q.set(J.name,J.value),$.effectiveEnvAssignments=Q}function Sj($,J){let Q=a9(J,t9($),$.env);if(Q){$.shellAssignments.set(Q.name,Q.value),$.exportedNames.add(Q.name),e0($,Q);return}if($7.test(J))dG($,J)}function Cj($,J,Q,X){let Y=a9(J,t9($),$.env);if(Y){if($.shellAssignments.set(Y.name,Y.value),Q)$.exportedNames.add(Y.name),e0($,Y);else if(Y.name===E3||Y.name===S3||$.allexport||$.exportedNames.has(Y.name))e0($,Y);return}let W=X?.get(J);if(W){$.exportedNames.add(J),e0($,W);return}if(Q&&$7.test(J))dG($,J)}function dG($,J){$.exportedNames.add(J),e0($,{name:J,value:$.shellAssignments.get(J)??$.effectiveEnvAssignments?.get(J)??$.env.get(J)??""})}function Tj($,J){if(!s9(J)&&!$7.test(J))return;if($.shellAssignments.set(J,""),$.exportedNames.delete(J),!s9(J)||J===E3||J===S3||a4(J)){e0($,{name:J,value:""});return}if(!$.effectiveEnvAssignments?.has(J))return;let Q=new Map($.effectiveEnvAssignments);Q.delete(J),$.effectiveEnvAssignments=Q.size===0?void 0:Q}function wj($,J){return rG($,J,(Q)=>Q==="-v")}function vj($,J){return rG($,J,(Q)=>Q==="-p")}function rG($,J,Q){let X=J+1;while(X<$.length){let Y=$[X];if(!Y)return null;if(Y==="--")return X+1;if(Q(Y)){X++;continue}if(Y.startsWith("-"))return null;return X}return X}function fj($,J){let Q=J+1,X=!1;while(Q<$.length){let Y=$[Q];if(!Y)return null;if(Y==="--")return{operandsStart:Q+1,exports:X};if(Y.startsWith("-")){if(Y.slice(1).includes("x"))X=!0;Q++;continue}if(Y.startsWith("+")){if(Y.slice(1).includes("x"))X=!1;Q++;continue}return{operandsStart:Q,exports:X}}return{operandsStart:Q,exports:X}}function hj($,J){let Q={allexport:null,keywordExport:null},X=J+1;while(X<$.length){let Y=$[X];if(!Y)return Q;if(Y==="--")return Q;if(Y==="-o"||Y==="+o"){if($[X+1]==="allexport")Q.allexport=Y==="-o";if($[X+1]==="keyword")Q.keywordExport=Y==="-o";X+=2;continue}if(Y.startsWith("-")&&Y.length>1){let W=Y.slice(1);if(W.includes("a"))Q.allexport=!0;if(W.includes("k"))Q.keywordExport=!0;X++;continue}if(Y.startsWith("+")&&Y.length>1){let W=Y.slice(1);if(W.includes("a"))Q.allexport=!1;if(W.includes("k"))Q.keywordExport=!1;X++;continue}return Q}return Q}var kj="Unquoted heredoc input is not supported safely. Quote the delimiter or ask the user to verify.",E2="This heredoc form or stdin consumer is not supported safely. Use a quoted heredoc with a supported consumer (cat, tee, git apply, git commit, gh pr create, gh issue create), or ask the user to verify.",gj=64;function W7($,J,Q,X){let Y=Q.derivedCommandWorkBudget===void 0,W=Q.parallelBudget===void 0;try{return yj($,J,{...Q,derivedCommandWorkBudget:Q.derivedCommandWorkBudget??n6(),parallelBudget:Q.parallelBudget??wB()},X)}catch(K){let B=K instanceof L2?jB:K instanceof m1&&Y?IB:K instanceof W9&&W?TB:void 0;if(!B)throw K;if(Q.trace?.currentSegmentIndex!==void 0)Q.trace.recordSegment({type:"error",message:B});else Q.trace?.recordGlobal({type:"error",message:B});return{reason:B,segment:$,intent:"stop_and_explain"}}}function yj($,J,Q,X){if(J>=s6)return Q.trace?.recordSegment({type:"error",message:A0}),{reason:A0,segment:$,intent:"stop_and_explain"};let Y=X??Q.factStore?.getCommandProgram($,Q.shell??"auto")??a1($,Q.shell);if(Y.status==="limited")return Q.trace?.recordSegment({type:"error",message:A0}),{reason:A0,segment:$,intent:"stop_and_explain"};if(Y.status==="invalid"){let U=Y.issues.find((G)=>G.code.includes("heredoc"));if(U){if(!Q.strict)return Y7($,Q);let G=`Unsupported heredoc syntax: ${U.message}`;return Q.trace?.recordGlobal({type:"error",message:G}),{reason:G,segment:$,intent:"stop_and_explain"}}return tG($,Q),{reason:r0,segment:$,intent:"stop_and_explain"}}if(Q.strict&&Y.status==="partial")return tG($,Q),{reason:r0,segment:$,intent:"stop_and_explain"};if(Y.issues.some((U)=>U.code.includes("quote"))&&!Q.analyzePartialProgram)return Y7($,Q);let K=Q.cwd,B=Q.effectiveCwd!==void 0?Q.effectiveCwd:Q.cwd,q=uG(Q.environment.env,Q.envAssignments);return J$(Y,J,{...Q,rootProgram:Y},K,[{effectiveCwd:B,shellGitContextState:q,literalHeredocFiles:new Map(Q.literalHeredocFiles),functionDefinitions:new Map(Q.functionDefinitions)}]).result}function J$($,J,Q,X,Y){let W=[...Y],K,B;for(let[q,U]of $.nodes.entries()){if(U.kind==="connector"){B=U.operator;continue}let G=$.nodes[q+1],H=G?.kind==="connector"?G.operator:void 0,L=xj($,q,U,B,H),Z=B==="&&"||B==="||",O=Z?K:void 0,M=B==="&&"?O?.success??W:B==="||"?O?.failure??W:W,V=B==="||"?O?.success??[]:[],F=B==="&&"?O?.failure??[]:[],b=Z||G4(H);if(U.kind==="function"){let S=M.flatMap((y)=>{let x=C3(y);return x.functionDefinitions.set(U.name,U.body),J7(y,[x],L,H==="&",G4(H))}),T=Q7(S,[],V,F,B,H);W=T.states,K=T.conditionalStates,B=void 0;continue}if(U.kind==="group"){let S=[],T=[];for(let x of M){let c=J$(U.body,J,Q,X,[C3(x)]);if(c.result)return c;if(S.push(...J7(x,c.states,L,H==="&",G4(H))),b)T.push(x,...L?c.states.map((V1)=>e9(x,V1)):c.states)}let y=Q7(S,T,V,F,B,H);W=y.states,K=y.conditionalStates,B=void 0;continue}if(U.kind!=="command")continue;let I=Q.trace?.flattenNested?Q.trace.currentSegmentIndex:Q.trace?.allocateSegment(),A=$.nodes[q-2],E=Q$(B)&&A?.kind==="command"?mU(A)??mj(A):void 0,_=[],R=[];for(let S of M){let T=lj(U,J,Q,X,[C3(S)]);if(T.result)return{result:T.result,states:W};let y=$.dialect==="powershell"?T.states:T.states.map((x)=>e9(S,x));for(let x of y){let c=C3(x),V1=dj(U,J,Q.trace?{...Q,trace:eG(Q.trace,I)}:Q,X,c,Q$(B),E);if(V1)return{result:V1,states:W};let C=YR(U,c.functionDefinitions);if(C)K0(Q.derivedCommandWorkBudget,X$(C));let m=C?J+1>=s6?X7(U.displayText,Q,[c]):J$(C,J+1,Q,X,[c]):{result:null,states:[c]};if(m.result)return m;if(_.push(...J7(S,m.states,L,H==="&",G4(H))),b)R.push(S),R.push(...m.states.map((X1)=>L?e9(S,X1):X1))}}let P=Q7(_,R,V,F,B,H);W=P.states,K=P.conditionalStates,B=void 0}return{result:null,states:W}}function xj($,J,Q,X,Y){if(Q.kind==="group"&&Q.style==="subshell")return!0;if($.dialect==="posix"&&(Q$(X)||Q$(Y)))return!0;if(Y==="&")return!0;return $.dialect==="powershell"&&Q.kind==="group"&&Q.style==="brace"&&uj($,J)}function J7($,J,Q,X,Y){let W=Q?J.map((B)=>e9($,B)):[...J],K=Y?W.flatMap((B)=>T3($.literalHeredocFiles,B.literalHeredocFiles)?[B]:[{...B,literalHeredocFiles:new Map($.literalHeredocFiles)},B]):W;return X?[$,...K]:K}function e9($,J){return{...$,literalHeredocFiles:new Map(J.literalHeredocFiles)}}function uj($,J){let Q=[...$.nodes.slice(0,J)].reverse().find((Y)=>Y.kind==="command"||Y.kind==="connector");if(!Q||Q.kind!=="command")return!0;let X=Q.words[0]?.text.toLowerCase();if(X==="&"||X===".")return!1;if(X==="write-output"||X==="function"||X==="start-job")return!0;if(pj(Q))return!0;return Q.source.replaceAll(/\s/g,"").toLowerCase()==="if($false)"}function Q$($){return $==="|"||$==="|&"}function mj($){if($?.dialect!=="powershell")return;if($.words.length===1&&$.words[0]?.quoted&&$.words[0].provenance==="literal")return $.words[0].text;if($.words[0]?.text.toLowerCase()==="write-output"&&$.words.length===2&&$.words[1]?.provenance==="literal")return $.words[1].text;return}function G4($){return $==="&&"||$==="||"}function Q7($,J,Q,X,Y,W){let K={success:$$([...Q,...$]),failure:$$([...X,...J])},B=G4(W)?K:void 0;return{states:G4(Y)||B?$$([...K.success,...K.failure]):K.success,conditionalStates:B}}function eG($,J,Q=$.flattenNested){return{currentSegmentIndex:J,flattenNested:Q,allocateSegment:$.allocateSegment,getNextSegmentIndex:$.getNextSegmentIndex,recordGlobal:$.recordGlobal,recordSegment:(X,Y=J)=>$.recordSegment(X,Y)}}function lj($,J,Q,X,Y){let W=$.nested.map((K)=>({program:K,depth:J}));if($.dialect==="powershell"){let K=cj($);if(K){if(J+1>=s6)return X7(K,Q,Y);let B=a1(K,"powershell");if(B.status==="limited")return X7(K,Q,Y);if(B.status!=="complete")return iG(W,Q,X,Y);K0(Q.derivedCommandWorkBudget,X$(B)),W.push({program:B,depth:J+1})}}return iG(W,Q,X,Y)}function pj($){let J=$.words[0];return J?.provenance==="variable"&&$.words.at(-1)?.text==="="?J.text.toLowerCase():void 0}function iG($,J,Q,X){let Y=[...X];for(let W of $){let K=[];for(let B of Y){let q=J$(W.program,W.depth,J,Q,[C3(B)]);if(q.result)return q;K.push(...q.states)}Y=$$(K)}return{result:null,states:Y}}function cj($){let J=$.words[0]?.provenance==="literal"&&!$.words[0].quoted&&$.words[0].raw===$.words[0].text&&($.words[0].text==="&"||$.words[0].text==="."),Q=J?1:0,X=$.words[Q];if(X?.provenance!=="literal"||!J&&(X.quoted||X.raw!==X.text)||!["iex","invoke-expression"].includes(X.text.toLowerCase()))return;let Y=$.words.slice(Q+1),W=Y[0]&&!Y[0].quoted&&Y[0].raw===Y[0].text&&["-c","-command"].includes(Y[0].text.toLowerCase())?1:0,K=Y[W];return Y.length===W+1&&K?.quoted&&K.provenance==="literal"?K.text:void 0}function X$($){return $.nodes.reduce((J,Q)=>J+(Q.kind==="command"?Q.words.length+Q.nested.reduce((X,Y)=>X+X$(Y),0):Q.kind==="group"||Q.kind==="function"?X$(Q.body):0),0)}function X7($,J,Q){return J.trace?.recordSegment({type:"error",message:A0}),{result:{reason:A0,segment:$,intent:"stop_and_explain"},states:[...Q]}}function dj($,J,Q,X,Y,W,K){let B=tj($);if(B&&Q.strict)return Q.trace?.recordSegment({type:"error",message:B}),{reason:B,segment:$.source,intent:"stop_and_explain"};$H($,Y,"before-consumer",Q.environment.paths);let q=p2($.dialect,$.words).map(h),U=$.displayText,G=pG(q,Y.shellGitContextState);if($.dialect==="powershell"){let Z=k(KU($,W,BR(Q,Y.effectiveCwd)),Q.policy);if(Q.trace?.recordSegment({type:"rule-check",ruleModule:"analyze/powershell/remove-item.ts",ruleFunction:"analyzePowerShellCommandViewMatch",matched:!!Z,reason:Z?.reason}),Z)return KR(U,Z)}if(q.length===1&&q[0]?.includes(" ")&&!$.dynamicExecutable){let Z=k(Y3(q[0],Q.scanWork),Q.policy),O=Z!==null&&!Q.strict&&_B($,Q.rootProgram,Q.scanWork);if(Z&&!O)return Q.trace?.recordSegment({type:"dangerous-text",token:q[0],matched:!0,reason:Z.reason}),{reason:Z.reason,segment:U,ruleId:Z.id,intent:Z.intent};return Q.trace?.recordSegment({type:"dangerous-text",token:q[0],matched:!1}),oG($,B,Y,G,K,Q)}let H=A3($.words,J,{...Q,commandView:$,cwd:X,effectiveCwd:Y.effectiveCwd,envAssignments:G,literalHeredocFiles:Y.literalHeredocFiles,functionDefinitions:Y.functionDefinitions,hasPipelineInput:W,literalShellInput:K,analyzeNested:(Z,O)=>{let M=O&&Object.hasOwn(O,"effectiveCwd")?O.effectiveCwd:Y.effectiveCwd,V=W7(Z,J+1,{...Q,derivedCommandWorkBudget:Q.derivedCommandWorkBudget,effectiveCwd:M,envAssignments:O?.envAssignments??G,literalHeredocFiles:Y.literalHeredocFiles,functionDefinitions:O?.functionDefinitions,worktreeMode:O?.worktreeMode??Q.worktreeMode,trace:Q.trace?eG(Q.trace,Q.trace.currentSegmentIndex,!0):void 0});return V?{reason:V.reason,ruleId:V.ruleId,intent:V.intent}:null}});if(H)return{...H,segment:U};let L=oG($,B,Y,G,K,Q);if(L)return L;return lG(q,Y.shellGitContextState),null}function oG($,J,Q,X,Y,W){let K=ej($,J,Q,X??new Map,W);if(K)return K;return $H($,Q,"after-consumer",W.environment.paths),Q.literalHeredocFiles.clear(),oj($,J,Q,W.environment.paths),QR($,Q,Y,W.environment,W.trace),null}var rj=new Set([">>","<>"]);function $H($,J,Q,X){for(let W of $.redirections){if(!(Q==="before-consumer"?ij(W):rj.has(W.operator)))continue;nG(W.target,J,X)}if(Q!=="before-consumer"||!k1($.words[0],"tee"))return;let Y=JH($.words.slice(1));if(!Y)return;for(let W of Y.operands)nG(W,J,X)}function ij($){if($.operator===">"||$.operator===">|")return!0;return $.operator===">&"&&$.fd===void 0&&$.target?.provenance==="literal"&&!/^(?:[0-9]+|-)$/.test($.target.text)}function nG($,J,Q){let X=$?.provenance==="literal"?W3($.text,J.effectiveCwd,Q):void 0;if(!X)return;J.literalHeredocFiles.delete(X)}function oj($,J,Q,X){if(J)return;let Y=$.redirections.find((W)=>W.operator==="<<"||W.operator==="<<-")?.heredoc;if(!Y?.quotedDelimiter)return;for(let W of nj($)){let K=W3(W.text,Q.effectiveCwd,X);if(!K||!PB(K))continue;if(!Q.literalHeredocFiles.has(K)&&Q.literalHeredocFiles.size>=bB)throw new m1;Q.literalHeredocFiles.set(K,Y.body)}}function nj($){let J=aj($.redirections)?.target,Q=sG(J)?[J]:[];if(k1($.words[0],"cat"))return sj($.words)?Q:[];if(!k1($.words[0],"tee"))return[];let X=JH($.words.slice(1));if(!X||X.append||X.hasUnsupportedOptions||!X.operands.every(sG))return[];return[...X.operands,...Q]}function sj($){let J=!1;for(let Q of $.slice(1)){if(J||Q.provenance!=="literal")return!1;if(Q.text==="--"){J=!0;continue}if(!/^-u+$/.test(Q.text))return!1}return!0}function aj($){let J=$.findLast((Q)=>(Q.fd??([">",">|",">>",">&"].includes(Q.operator)?1:0))===1);return J?.operator===">"||J?.operator===">|"?J:void 0}function JH($){let J=[],Q=!0,X=!1,Y=!1;for(let W of $){if(W.provenance!=="literal")return;if(Q&&k1(W,"--")){Q=!1;continue}if(Q&&!W.quoted&&W.raw===W.text&&/^-[^-]/.test(W.text)){X||=W.text.slice(1).includes("a"),Y||=[...W.text.slice(1)].some((K)=>K!=="a"&&K!=="i");continue}if(Q&&!W.quoted&&W.raw===W.text&&W.text.startsWith("--")){X||=W.text==="--append",Y||=W.text!=="--append"&&W.text!=="--ignore-interrupts";continue}J.push(W)}return{operands:J,append:X,hasUnsupportedOptions:Y}}function sG($){if(!$||$.provenance!=="literal"||$.text.length===0)return!1;if($.quoted||$.raw!==$.text)return!0;return!$.raw.startsWith("~")&&!/[{}]/.test($.raw)}function k1($,J){return $?.text===J&&$.raw===J&&$.provenance==="literal"&&!$.quoted}function tj($){let J=$.redirections.filter((K)=>K.operator==="<<"||K.operator==="<<-");if(J.length===0)return;if(J.length!==1)return E2;let Q=J[0];if(!Q?.heredoc)return E2;if(!Q.heredoc.quotedDelimiter)return kj;if(Q.fd!==void 0&&Q.fd!==0)return E2;if($.redirections.some((K)=>K!==Q&&["<","<<","<<-","<<<","<&","<>"].includes(K.operator)))return E2;let X=$.redirections.some((K)=>K!==Q&&aG(K.target));if(k1($.words[0],"cat"))return X?E2:void 0;if(k1($.words[0],"tee"))return X||$.words.slice(1).some(aG)?E2:void 0;let Y=$.words[0],W=$.words[1];if(k1(Y,"git")&&(k1(W,"apply")||k1(W,"commit")))return;if(k1(Y,"gh")&&(k1(W,"pr")||k1(W,"issue"))&&k1($.words[2],"create"))return;return E2}function aG($){return $?.parts.some((J)=>J.provenance==="command-substitution"&&J.raw.startsWith(">("))??!1}function ej($,J,Q,X,Y){if(!J)return null;let W=$.redirections.filter((U)=>U.operator==="<<"||U.operator==="<<-"),K=W.flatMap((U)=>U.heredoc?[U.heredoc.body]:[]);if(JR($,W,Q,X,Y))return null;let B=$R($,W,Y);if(B!==void 0)return B?{reason:B.reason,segment:$.displayText,ruleId:B.id,intent:B.intent}:null;let q=Y7(K.length===W.length?K.join(`
63
+ `):$.source,Y);return q?{...q,segment:$.displayText}:null}function $R($,J,Q){let X=J.length===1?J[0]:void 0;if(!X?.heredoc?.quotedDelimiter||X.fd!==void 0&&X.fd!==0)return;let Y=$.words[0];if(Y?.provenance!=="literal"||!C1(Y.text))return;if(!$.words.slice(1).every((U)=>U.provenance==="literal"&&U.text.startsWith("-")))return;let K=X.heredoc.body,B=q1(Q.policy,"interpreter.one-liner-paranoid",!!Q.paranoidInterpreters);if(Q.trace?.recordSegment({type:"interpreter",interpreter:Y.text,codeArg:K,paranoidBlocked:B}),B){let U=k(z("interpreter.one-liner-paranoid",n2),Q.policy);if(U)return U}if(!s2(K,Q.scanWork))return null;let q=k(z("interpreter.dangerous-command",M2),Q.policy);if(!q)return null;return Q.trace?.recordSegment({type:"dangerous-text",token:K,matched:!0,reason:q.reason}),q}function JR($,J,Q,X,Y){let W=J.length===1?J[0]:void 0;if(!W?.heredoc?.quotedDelimiter||W.fd!==void 0&&W.fd!==0)return!1;let K=N2($.words,Y.environment,Q.effectiveCwd,X),B=K.words.map(h),q=i(B[0]??"");if(K.unverifiableEnvSplit||!H1.has(q)&&!H1.has(l(q)))return!1;return c1(B)}function QR($,J,Q,X,Y){let W=kG($,J.effectiveCwd,X,Q);if(W===null)Y?.recordSegment({type:"cwd-change",segment:$.words.map(h).join(" "),effectiveCwdNowUnknown:!0});if(W!==void 0)J.effectiveCwd=W}function C3($){return{effectiveCwd:$.effectiveCwd,shellGitContextState:mG($.shellGitContextState),literalHeredocFiles:new Map($.literalHeredocFiles),functionDefinitions:new Map($.functionDefinitions)}}function $$($){let J=[];for(let Q of $){if(!J.some((X)=>XR(X,Q)))J.push(Q);if(J.length>gj)throw new m1}return J}function XR($,J){return $.effectiveCwd===J.effectiveCwd&&T3($.literalHeredocFiles,J.literalHeredocFiles)&&T3($.functionDefinitions,J.functionDefinitions)&&T3($.shellGitContextState.effectiveEnvAssignments,J.shellGitContextState.effectiveEnvAssignments)&&T3($.shellGitContextState.shellAssignments,J.shellGitContextState.shellAssignments)&&WR($.shellGitContextState.exportedNames,J.shellGitContextState.exportedNames)&&$.shellGitContextState.allexport===J.shellGitContextState.allexport&&$.shellGitContextState.keywordExport===J.shellGitContextState.keywordExport}function T3($,J){if($===J)return!0;if(!$||!J||$.size!==J.size)return!1;return[...$].every(([Q,X])=>J.get(Q)===X&&J.has(Q))}function YR($,J){let Q=z9($);return Q===void 0?void 0:J.get(Q)}function WR($,J){return $.size===J.size&&[...$].every((Q)=>J.has(Q))}function KR($,J){if(!J)return null;return{reason:J.reason,segment:$,ruleId:J.id,intent:J.intent}}function BR($,J=$.effectiveCwd){let Q=J===null;return{environment:$.environment,cwd:Q?void 0:J??$.cwd,originalCwd:Q?void 0:$.cwd,strict:$.strict,paranoid:$.paranoidRm,allowTmpdirVar:$.allowTmpdirVar,protectedGitMetadata:$.protectedGitMetadata,policy:$.policy}}function Y7($,J){let Q=k(Y3($,J.scanWork),J.policy),X=J.trace?.currentSegmentIndex??J.trace?.allocateSegment(),Y={type:"dangerous-text",token:$,matched:!!Q,reason:Q?.reason};if(J.trace?.recordSegment(Y,X),!Q&&/^(?:cd|pushd)\s/.test($))J.trace?.recordSegment({type:"cwd-change",segment:$,effectiveCwdNowUnknown:!0},X);return Q?{reason:Q.reason,segment:$,ruleId:Q.id,intent:Q.intent}:null}function tG($,J){let Q={type:"strict-unparseable",rawCommand:$,reason:r0};if(J.trace?.currentSegmentIndex===void 0)J.trace?.recordGlobal(Q);else J.trace.recordSegment(Q)}var B1={level:{name:"CC_SAFETY_NET_LEVEL"},strict:{name:"CC_SAFETY_NET_STRICT",legacyName:"SAFETY_NET_STRICT"},paranoid:{name:"CC_SAFETY_NET_PARANOID",legacyName:"SAFETY_NET_PARANOID"},paranoidRm:{name:"CC_SAFETY_NET_PARANOID_RM",legacyName:"SAFETY_NET_PARANOID_RM"},paranoidInterpreters:{name:"CC_SAFETY_NET_PARANOID_INTERPRETERS",legacyName:"SAFETY_NET_PARANOID_INTERPRETERS"},worktree:{name:"CC_SAFETY_NET_WORKTREE",legacyName:"SAFETY_NET_WORKTREE"},debug:{name:"CC_SAFETY_NET_DEBUG"},auditScope:{name:"CC_SAFETY_NET_AUDIT_SCOPE"}},Y$=["standard","strict","paranoid"];function qR($){return{failClosed:$==="strict"||$==="paranoid",paranoidRm:$==="paranoid",paranoidInterpreters:$==="paranoid"}}function UR($,J){if(!J)return $;return Y$.indexOf(J)>Y$.indexOf($)?J:$}function GR(){let $=G7(B1.level);if($===void 0||$==="")return;if(Y$.includes($))return $;console.error(`CC Safety Net: ignored invalid ${B1.level.name}=${JSON.stringify($.slice(0,40))}. Use ${Y$.join(", ")}.`);return}function HR($){if($===void 0||$==="all")return"all";if($==="blocked")return"blocked";return"invalid"}function B7(){return HR(G7(B1.auditScope))==="all"}function q7($){if($.failClosed&&$.paranoidRm&&$.paranoidInterpreters)return"paranoid";if($.failClosed&&!$.paranoidRm&&!$.paranoidInterpreters)return"strict";if(!$.failClosed&&!$.paranoidRm&&!$.paranoidInterpreters)return"standard";return"custom"}function U7($={}){let J=$.safety?.level??"standard",Q=GR(),X=UR(J,Q),Y=qR(X),W={failClosed:X===J?"preset":"environment",paranoidRm:X===J?"preset":"environment",paranoidInterpreters:X===J?"preset":"environment"},K={failClosed:[`policy safety.level=${J}`],paranoidRm:[`policy safety.level=${J}`],paranoidInterpreters:[`policy safety.level=${J}`],worktreeMode:[]};if(X!==J)K.failClosed.push(`env ${B1.level.name}=${Q}`),K.paranoidRm.push(`env ${B1.level.name}=${Q}`),K.paranoidInterpreters.push(`env ${B1.level.name}=${Q}`);if($.safety?.overrides?.failClosed!==void 0)Y.failClosed=$.safety.overrides.failClosed,W.failClosed="capability_override",K.failClosed.push("policy safety.overrides.fail_closed");if($.safety?.overrides?.paranoidRm!==void 0)Y.paranoidRm=$.safety.overrides.paranoidRm,W.paranoidRm="capability_override",K.paranoidRm.push("policy safety.overrides.paranoid_rm");if($.safety?.overrides?.paranoidInterpreters!==void 0)Y.paranoidInterpreters=$.safety.overrides.paranoidInterpreters,W.paranoidInterpreters="capability_override",K.paranoidInterpreters.push("policy safety.overrides.paranoid_interpreters");if(k0(B1.strict))Y.failClosed=!0,W.failClosed="environment",K.failClosed.push(`env ${B1.strict.name}`);if(k0(B1.paranoid))Y.paranoidRm=!0,Y.paranoidInterpreters=!0,W.paranoidRm="environment",W.paranoidInterpreters="environment",K.paranoidRm.push(`env ${B1.paranoid.name}`),K.paranoidInterpreters.push(`env ${B1.paranoid.name}`);if(k0(B1.paranoidRm))Y.paranoidRm=!0,W.paranoidRm="environment",K.paranoidRm.push(`env ${B1.paranoidRm.name}`);if(k0(B1.paranoidInterpreters))Y.paranoidInterpreters=!0,W.paranoidInterpreters="environment",K.paranoidInterpreters.push(`env ${B1.paranoidInterpreters.name}`);let B=!!$.worktreeMode||k0(B1.worktree);if($.worktreeMode)K.worktreeMode.push("policy workflow.worktree_mode");if(k0(B1.worktree))K.worktreeMode.push(`env ${B1.worktree.name}`);return{strict:Y.failClosed,paranoidRm:Y.paranoidRm,paranoidInterpreters:Y.paranoidInterpreters,worktreeMode:B,effectiveLevel:q7(Y),capabilities:{fail_closed:{enabled:Y.failClosed,source:W.failClosed,sources:K.failClosed},paranoid_rm:{enabled:Y.paranoidRm,source:W.paranoidRm,sources:K.paranoidRm},paranoid_interpreters:{enabled:Y.paranoidInterpreters,source:W.paranoidInterpreters,sources:K.paranoidInterpreters}},sources:K}}function k0($){let J=typeof $==="string"?K7($):G7($);return J==="1"||J?.toLowerCase()==="true"}function K7($){return Object.hasOwn(process.env,$)?process.env[$]:void 0}function G7($){let J=K7($.name);if(J!==void 0)return J;if($.legacyName)return K7($.legacyName);return}function QH($){let J=$.effectiveCapabilities,Q=$.strict??J.fail_closed.enabled,X=$.paranoidRm??J.paranoid_rm.enabled,Y=$.paranoidInterpreters??J.paranoid_interpreters.enabled,W={fail_closed:H7(J.fail_closed,$.strict,"strict"),paranoid_rm:H7(J.paranoid_rm,$.paranoidRm,"paranoidRm"),paranoid_interpreters:H7(J.paranoid_interpreters,$.paranoidInterpreters,"paranoidInterpreters")};return{policy:FB($.policySnapshot.policy,W),effectiveCapabilities:W,effectiveLevel:q7({failClosed:Q,paranoidRm:X,paranoidInterpreters:Y}),strict:Q,paranoidRm:X,paranoidInterpreters:Y,worktreeMode:$.worktreeMode??!1}}function H7($,J,Q){if(J===void 0||J===$.enabled)return $;return{enabled:J,source:"capability_override",sources:[...$.sources,`analysis options.${Q}`]}}function XH($,J,Q,X){let Y=W7($,0,{...J,...QH(J),factStore:X},Q);if(!Y)return null;return{kind:"deny",reason:Y.reason,intent:Y.intent??"manual_only",...Y.ruleId?{ruleId:Y.ruleId}:{},evidence:[{kind:"command",command:$,segment:Y.segment}]}}import{dirname as YK}from"path";function w3($,J,Q,X,Y){if(Q.kind!=="command")return{toolName:$,input:J,route:Q,context:X};return{toolName:$,input:J,route:Q,context:X,command:Y}}import{chmodSync as Dk,existsSync as _P,mkdirSync as zk,readFileSync as DP}from"fs";import{dirname as zP,join as IP}from"path";import{createRequire as KP}from"module";var oW={};B2(oW,{z:()=>QJ,xor:()=>EZ,xid:()=>aH,void:()=>IZ,uuidv7:()=>pH,uuidv6:()=>lH,uuidv4:()=>mH,uuid:()=>uH,util:()=>w,url:()=>cH,uppercase:()=>j4,unknown:()=>k2,union:()=>i8,undefined:()=>DZ,ulid:()=>sH,uint64:()=>VZ,uint32:()=>MZ,tuple:()=>VW,trim:()=>S4,treeifyError:()=>H$,transform:()=>n8,toUpperCase:()=>T4,toLowerCase:()=>C4,toJSONSchema:()=>a3,templateLiteral:()=>mZ,symbol:()=>_Z,superRefine:()=>dW,success:()=>yZ,stringbool:()=>nZ,stringFormat:()=>qZ,string:()=>P8,strictObject:()=>PZ,startsWith:()=>b4,slugify:()=>w4,size:()=>v2,setErrorMap:()=>eZ,set:()=>vZ,safeParseAsync:()=>F8,safeParse:()=>N8,safeEncodeAsync:()=>R8,safeEncode:()=>I8,safeDecodeAsync:()=>b8,safeDecode:()=>j8,registry:()=>o3,regexes:()=>y1,regex:()=>z4,refine:()=>cW,record:()=>_W,readonly:()=>yW,property:()=>U8,promise:()=>lZ,prettifyError:()=>Z$,preprocess:()=>aZ,prefault:()=>TW,positive:()=>W8,pipe:()=>K6,partialRecord:()=>CZ,parseAsync:()=>M8,parse:()=>O8,overwrite:()=>Q0,optional:()=>Y6,object:()=>bZ,number:()=>QW,nullish:()=>gZ,nullable:()=>W6,null:()=>BW,normalize:()=>E4,nonpositive:()=>B8,nonoptional:()=>wW,nonnegative:()=>q8,never:()=>r8,negative:()=>K8,nativeEnum:()=>fZ,nanoid:()=>iH,nan:()=>xZ,multipleOf:()=>Y2,minSize:()=>D0,minLength:()=>y0,mime:()=>A4,meta:()=>iZ,maxSize:()=>W2,maxLength:()=>f2,map:()=>wZ,mac:()=>$Z,lte:()=>x1,lt:()=>V0,lowercase:()=>I4,looseRecord:()=>TZ,looseObject:()=>AZ,locales:()=>i3,literal:()=>hZ,length:()=>h2,lazy:()=>mW,ksuid:()=>tH,keyof:()=>RZ,jwt:()=>BZ,json:()=>sZ,iso:()=>Q6,ipv6:()=>JZ,ipv4:()=>eH,intersection:()=>NW,int64:()=>FZ,int32:()=>OZ,int:()=>A8,instanceof:()=>oZ,includes:()=>R4,httpUrl:()=>dH,hostname:()=>UZ,hex:()=>GZ,hash:()=>HZ,guid:()=>xH,gte:()=>D1,gt:()=>_0,globalRegistry:()=>E1,getErrorMap:()=>$L,function:()=>pZ,fromJSONSchema:()=>iW,formatError:()=>M4,float64:()=>LZ,float32:()=>ZZ,flattenError:()=>O4,file:()=>kZ,exactOptional:()=>PW,enum:()=>o8,endsWith:()=>P4,encodeAsync:()=>D8,encode:()=>V8,emoji:()=>rH,email:()=>yH,e164:()=>KZ,discriminatedUnion:()=>SZ,describe:()=>rZ,default:()=>JP,decodeAsync:()=>z8,decode:()=>_8,date:()=>jZ,custom:()=>dZ,cuid2:()=>nH,cuid:()=>oH,core:()=>z0,config:()=>Y1,coerce:()=>JJ,codec:()=>uZ,clone:()=>N1,cidrv6:()=>XZ,cidrv4:()=>QZ,check:()=>cZ,catch:()=>hW,boolean:()=>XW,bigint:()=>NZ,base64url:()=>WZ,base64:()=>YZ,array:()=>U6,any:()=>zZ,_function:()=>pZ,_default:()=>SW,_ZodString:()=>E8,ZodXor:()=>LW,ZodXID:()=>h8,ZodVoid:()=>HW,ZodUnknown:()=>UW,ZodUnion:()=>H6,ZodUndefined:()=>WW,ZodUUID:()=>I0,ZodURL:()=>B6,ZodULID:()=>f8,ZodType:()=>g,ZodTuple:()=>FW,ZodTransform:()=>RW,ZodTemplateLiteral:()=>xW,ZodSymbol:()=>YW,ZodSuccess:()=>vW,ZodStringFormat:()=>r,ZodString:()=>x4,ZodSet:()=>zW,ZodRecord:()=>Z6,ZodRealError:()=>z1,ZodReadonly:()=>gW,ZodPromise:()=>lW,ZodPrefault:()=>CW,ZodPipe:()=>t8,ZodOptional:()=>s8,ZodObject:()=>G6,ZodNumberFormat:()=>g2,ZodNumber:()=>m4,ZodNullable:()=>AW,ZodNull:()=>KW,ZodNonOptional:()=>a8,ZodNever:()=>GW,ZodNanoID:()=>T8,ZodNaN:()=>kW,ZodMap:()=>DW,ZodMAC:()=>JW,ZodLiteral:()=>IW,ZodLazy:()=>uW,ZodKSUID:()=>k8,ZodJWT:()=>c8,ZodIssueCode:()=>tZ,ZodIntersection:()=>MW,ZodISOTime:()=>$6,ZodISODuration:()=>J6,ZodISODateTime:()=>t3,ZodISODate:()=>e3,ZodIPv6:()=>y8,ZodIPv4:()=>g8,ZodGUID:()=>X6,ZodFunction:()=>pW,ZodFirstPartyTypeKind:()=>$J,ZodFile:()=>jW,ZodExactOptional:()=>bW,ZodError:()=>gH,ZodEnum:()=>y4,ZodEmoji:()=>C8,ZodEmail:()=>S8,ZodE164:()=>p8,ZodDiscriminatedUnion:()=>OW,ZodDefault:()=>EW,ZodDate:()=>q6,ZodCustomStringFormat:()=>u4,ZodCustom:()=>L6,ZodCodec:()=>e8,ZodCatch:()=>fW,ZodCUID2:()=>v8,ZodCUID:()=>w8,ZodCIDRv6:()=>u8,ZodCIDRv4:()=>x8,ZodBoolean:()=>l4,ZodBigIntFormat:()=>d8,ZodBigInt:()=>p4,ZodBase64URL:()=>l8,ZodBase64:()=>m8,ZodArray:()=>ZW,ZodAny:()=>qW,TimePrecision:()=>Y8,NEVER:()=>W$,$output:()=>k$,$input:()=>g$,$brand:()=>K$});var QJ={};B2(QJ,{xor:()=>EZ,xid:()=>aH,void:()=>IZ,uuidv7:()=>pH,uuidv6:()=>lH,uuidv4:()=>mH,uuid:()=>uH,util:()=>w,url:()=>cH,uppercase:()=>j4,unknown:()=>k2,union:()=>i8,undefined:()=>DZ,ulid:()=>sH,uint64:()=>VZ,uint32:()=>MZ,tuple:()=>VW,trim:()=>S4,treeifyError:()=>H$,transform:()=>n8,toUpperCase:()=>T4,toLowerCase:()=>C4,toJSONSchema:()=>a3,templateLiteral:()=>mZ,symbol:()=>_Z,superRefine:()=>dW,success:()=>yZ,stringbool:()=>nZ,stringFormat:()=>qZ,string:()=>P8,strictObject:()=>PZ,startsWith:()=>b4,slugify:()=>w4,size:()=>v2,setErrorMap:()=>eZ,set:()=>vZ,safeParseAsync:()=>F8,safeParse:()=>N8,safeEncodeAsync:()=>R8,safeEncode:()=>I8,safeDecodeAsync:()=>b8,safeDecode:()=>j8,registry:()=>o3,regexes:()=>y1,regex:()=>z4,refine:()=>cW,record:()=>_W,readonly:()=>yW,property:()=>U8,promise:()=>lZ,prettifyError:()=>Z$,preprocess:()=>aZ,prefault:()=>TW,positive:()=>W8,pipe:()=>K6,partialRecord:()=>CZ,parseAsync:()=>M8,parse:()=>O8,overwrite:()=>Q0,optional:()=>Y6,object:()=>bZ,number:()=>QW,nullish:()=>gZ,nullable:()=>W6,null:()=>BW,normalize:()=>E4,nonpositive:()=>B8,nonoptional:()=>wW,nonnegative:()=>q8,never:()=>r8,negative:()=>K8,nativeEnum:()=>fZ,nanoid:()=>iH,nan:()=>xZ,multipleOf:()=>Y2,minSize:()=>D0,minLength:()=>y0,mime:()=>A4,meta:()=>iZ,maxSize:()=>W2,maxLength:()=>f2,map:()=>wZ,mac:()=>$Z,lte:()=>x1,lt:()=>V0,lowercase:()=>I4,looseRecord:()=>TZ,looseObject:()=>AZ,locales:()=>i3,literal:()=>hZ,length:()=>h2,lazy:()=>mW,ksuid:()=>tH,keyof:()=>RZ,jwt:()=>BZ,json:()=>sZ,iso:()=>Q6,ipv6:()=>JZ,ipv4:()=>eH,intersection:()=>NW,int64:()=>FZ,int32:()=>OZ,int:()=>A8,instanceof:()=>oZ,includes:()=>R4,httpUrl:()=>dH,hostname:()=>UZ,hex:()=>GZ,hash:()=>HZ,guid:()=>xH,gte:()=>D1,gt:()=>_0,globalRegistry:()=>E1,getErrorMap:()=>$L,function:()=>pZ,fromJSONSchema:()=>iW,formatError:()=>M4,float64:()=>LZ,float32:()=>ZZ,flattenError:()=>O4,file:()=>kZ,exactOptional:()=>PW,enum:()=>o8,endsWith:()=>P4,encodeAsync:()=>D8,encode:()=>V8,emoji:()=>rH,email:()=>yH,e164:()=>KZ,discriminatedUnion:()=>SZ,describe:()=>rZ,decodeAsync:()=>z8,decode:()=>_8,date:()=>jZ,custom:()=>dZ,cuid2:()=>nH,cuid:()=>oH,core:()=>z0,config:()=>Y1,coerce:()=>JJ,codec:()=>uZ,clone:()=>N1,cidrv6:()=>XZ,cidrv4:()=>QZ,check:()=>cZ,catch:()=>hW,boolean:()=>XW,bigint:()=>NZ,base64url:()=>WZ,base64:()=>YZ,array:()=>U6,any:()=>zZ,_function:()=>pZ,_default:()=>SW,_ZodString:()=>E8,ZodXor:()=>LW,ZodXID:()=>h8,ZodVoid:()=>HW,ZodUnknown:()=>UW,ZodUnion:()=>H6,ZodUndefined:()=>WW,ZodUUID:()=>I0,ZodURL:()=>B6,ZodULID:()=>f8,ZodType:()=>g,ZodTuple:()=>FW,ZodTransform:()=>RW,ZodTemplateLiteral:()=>xW,ZodSymbol:()=>YW,ZodSuccess:()=>vW,ZodStringFormat:()=>r,ZodString:()=>x4,ZodSet:()=>zW,ZodRecord:()=>Z6,ZodRealError:()=>z1,ZodReadonly:()=>gW,ZodPromise:()=>lW,ZodPrefault:()=>CW,ZodPipe:()=>t8,ZodOptional:()=>s8,ZodObject:()=>G6,ZodNumberFormat:()=>g2,ZodNumber:()=>m4,ZodNullable:()=>AW,ZodNull:()=>KW,ZodNonOptional:()=>a8,ZodNever:()=>GW,ZodNanoID:()=>T8,ZodNaN:()=>kW,ZodMap:()=>DW,ZodMAC:()=>JW,ZodLiteral:()=>IW,ZodLazy:()=>uW,ZodKSUID:()=>k8,ZodJWT:()=>c8,ZodIssueCode:()=>tZ,ZodIntersection:()=>MW,ZodISOTime:()=>$6,ZodISODuration:()=>J6,ZodISODateTime:()=>t3,ZodISODate:()=>e3,ZodIPv6:()=>y8,ZodIPv4:()=>g8,ZodGUID:()=>X6,ZodFunction:()=>pW,ZodFirstPartyTypeKind:()=>$J,ZodFile:()=>jW,ZodExactOptional:()=>bW,ZodError:()=>gH,ZodEnum:()=>y4,ZodEmoji:()=>C8,ZodEmail:()=>S8,ZodE164:()=>p8,ZodDiscriminatedUnion:()=>OW,ZodDefault:()=>EW,ZodDate:()=>q6,ZodCustomStringFormat:()=>u4,ZodCustom:()=>L6,ZodCodec:()=>e8,ZodCatch:()=>fW,ZodCUID2:()=>v8,ZodCUID:()=>w8,ZodCIDRv6:()=>u8,ZodCIDRv4:()=>x8,ZodBoolean:()=>l4,ZodBigIntFormat:()=>d8,ZodBigInt:()=>p4,ZodBase64URL:()=>l8,ZodBase64:()=>m8,ZodArray:()=>ZW,ZodAny:()=>qW,TimePrecision:()=>Y8,NEVER:()=>W$,$output:()=>k$,$input:()=>g$,$brand:()=>K$});var z0={};B2(z0,{version:()=>NX,util:()=>w,treeifyError:()=>H$,toJSONSchema:()=>a3,toDotPath:()=>UH,safeParseAsync:()=>j7,safeParse:()=>I7,safeEncodeAsync:()=>dR,safeEncode:()=>pR,safeDecodeAsync:()=>rR,safeDecode:()=>cR,registry:()=>o3,regexes:()=>y1,process:()=>n,prettifyError:()=>Z$,parseAsync:()=>O$,parse:()=>L$,meta:()=>GY,locales:()=>i3,isValidJWT:()=>EH,isValidBase64URL:()=>AH,isValidBase64:()=>yX,initializeContext:()=>h4,globalRegistry:()=>E1,globalConfig:()=>v3,formatError:()=>M4,flattenError:()=>O4,finalize:()=>g4,extractDefs:()=>k4,encodeAsync:()=>mR,encode:()=>xR,describe:()=>UY,decodeAsync:()=>lR,decode:()=>uR,createToJSONSchemaMethod:()=>ZY,createStandardJSONSchemaMethod:()=>G8,config:()=>Y1,clone:()=>N1,_xor:()=>jb,_xid:()=>o$,_void:()=>$Y,_uuidv7:()=>l$,_uuidv6:()=>m$,_uuidv4:()=>u$,_uuid:()=>x$,_url:()=>s3,_uppercase:()=>j4,_unknown:()=>t5,_union:()=>Ib,_undefined:()=>n5,_ulid:()=>i$,_uint64:()=>i5,_uint32:()=>m5,_tuple:()=>Pb,_trim:()=>S4,_transform:()=>vb,_toUpperCase:()=>T4,_toLowerCase:()=>C4,_templateLiteral:()=>lb,_symbol:()=>o5,_superRefine:()=>qY,_success:()=>yb,_stringbool:()=>HY,_stringFormat:()=>v4,_string:()=>E5,_startsWith:()=>b4,_slugify:()=>w4,_size:()=>v2,_set:()=>Sb,_safeParseAsync:()=>_4,_safeParse:()=>V4,_safeEncodeAsync:()=>z$,_safeEncode:()=>_$,_safeDecodeAsync:()=>I$,_safeDecode:()=>D$,_regex:()=>z4,_refine:()=>BY,_record:()=>Ab,_readonly:()=>mb,_property:()=>U8,_promise:()=>cb,_positive:()=>W8,_pipe:()=>ub,_parseAsync:()=>F4,_parse:()=>N4,_overwrite:()=>Q0,_optional:()=>fb,_number:()=>h5,_nullable:()=>hb,_null:()=>s5,_normalize:()=>E4,_nonpositive:()=>B8,_nonoptional:()=>gb,_nonnegative:()=>q8,_never:()=>e5,_negative:()=>K8,_nativeEnum:()=>Tb,_nanoid:()=>c$,_nan:()=>XY,_multipleOf:()=>Y2,_minSize:()=>D0,_minLength:()=>y0,_min:()=>D1,_mime:()=>A4,_maxSize:()=>W2,_maxLength:()=>f2,_max:()=>x1,_map:()=>Eb,_mac:()=>C5,_lte:()=>x1,_lt:()=>V0,_lowercase:()=>I4,_literal:()=>wb,_length:()=>h2,_lazy:()=>pb,_ksuid:()=>n$,_jwt:()=>X8,_isoTime:()=>v5,_isoDuration:()=>f5,_isoDateTime:()=>T5,_isoDate:()=>w5,_ipv6:()=>a$,_ipv4:()=>s$,_intersection:()=>bb,_int64:()=>r5,_int32:()=>u5,_int:()=>g5,_includes:()=>R4,_guid:()=>n3,_gte:()=>D1,_gt:()=>_0,_float64:()=>x5,_float32:()=>y5,_file:()=>WY,_enum:()=>Cb,_endsWith:()=>P4,_encodeAsync:()=>F$,_encode:()=>M$,_emoji:()=>p$,_email:()=>y$,_e164:()=>Q8,_discriminatedUnion:()=>Rb,_default:()=>kb,_decodeAsync:()=>V$,_decode:()=>N$,_date:()=>JY,_custom:()=>KY,_cuid2:()=>r$,_cuid:()=>d$,_coercedString:()=>S5,_coercedNumber:()=>k5,_coercedDate:()=>QY,_coercedBoolean:()=>p5,_coercedBigint:()=>d5,_cidrv6:()=>e$,_cidrv4:()=>t$,_check:()=>vH,_catch:()=>xb,_boolean:()=>l5,_bigint:()=>c5,_base64url:()=>J8,_base64:()=>$8,_array:()=>YY,_any:()=>a5,TimePrecision:()=>Y8,NEVER:()=>W$,JSONSchemaGenerator:()=>sY,JSONSchema:()=>fH,Doc:()=>P$,$output:()=>k$,$input:()=>g$,$constructor:()=>N,$brand:()=>K$,$ZodXor:()=>Q5,$ZodXID:()=>AX,$ZodVoid:()=>tX,$ZodUnknown:()=>sX,$ZodUnion:()=>d3,$ZodUndefined:()=>iX,$ZodUUID:()=>_X,$ZodURL:()=>zX,$ZodULID:()=>PX,$ZodType:()=>v,$ZodTuple:()=>f$,$ZodTransform:()=>H5,$ZodTemplateLiteral:()=>I5,$ZodSymbol:()=>rX,$ZodSuccess:()=>F5,$ZodStringFormat:()=>d,$ZodString:()=>w2,$ZodSet:()=>B5,$ZodRegistry:()=>A5,$ZodRecord:()=>W5,$ZodRealError:()=>A1,$ZodReadonly:()=>z5,$ZodPromise:()=>R5,$ZodPrefault:()=>M5,$ZodPipe:()=>D5,$ZodOptional:()=>h$,$ZodObjectJIT:()=>J5,$ZodObject:()=>TH,$ZodNumberFormat:()=>cX,$ZodNumber:()=>w$,$ZodNullable:()=>L5,$ZodNull:()=>oX,$ZodNonOptional:()=>N5,$ZodNever:()=>aX,$ZodNanoID:()=>jX,$ZodNaN:()=>_5,$ZodMap:()=>K5,$ZodMAC:()=>hX,$ZodLiteral:()=>U5,$ZodLazy:()=>b5,$ZodKSUID:()=>EX,$ZodJWT:()=>lX,$ZodIntersection:()=>Y5,$ZodISOTime:()=>TX,$ZodISODuration:()=>wX,$ZodISODateTime:()=>SX,$ZodISODate:()=>CX,$ZodIPv6:()=>fX,$ZodIPv4:()=>vX,$ZodGUID:()=>VX,$ZodFunction:()=>j5,$ZodFile:()=>G5,$ZodExactOptional:()=>Z5,$ZodError:()=>u3,$ZodEnum:()=>q5,$ZodEncodeError:()=>S2,$ZodEmoji:()=>IX,$ZodEmail:()=>DX,$ZodE164:()=>mX,$ZodDiscriminatedUnion:()=>X5,$ZodDefault:()=>O5,$ZodDate:()=>eX,$ZodCustomStringFormat:()=>pX,$ZodCustom:()=>P5,$ZodCodec:()=>r3,$ZodCheckUpperCase:()=>UX,$ZodCheckStringFormat:()=>D4,$ZodCheckStartsWith:()=>HX,$ZodCheckSizeEquals:()=>XX,$ZodCheckRegex:()=>BX,$ZodCheckProperty:()=>LX,$ZodCheckOverwrite:()=>MX,$ZodCheckNumberFormat:()=>e7,$ZodCheckMultipleOf:()=>t7,$ZodCheckMinSize:()=>QX,$ZodCheckMinLength:()=>WX,$ZodCheckMimeType:()=>OX,$ZodCheckMaxSize:()=>JX,$ZodCheckMaxLength:()=>YX,$ZodCheckLowerCase:()=>qX,$ZodCheckLessThan:()=>R$,$ZodCheckLengthEquals:()=>KX,$ZodCheckIncludes:()=>GX,$ZodCheckGreaterThan:()=>b$,$ZodCheckEndsWith:()=>ZX,$ZodCheckBigIntFormat:()=>$X,$ZodCheck:()=>o,$ZodCatch:()=>V5,$ZodCUID2:()=>bX,$ZodCUID:()=>RX,$ZodCIDRv6:()=>gX,$ZodCIDRv4:()=>kX,$ZodBoolean:()=>c3,$ZodBigIntFormat:()=>dX,$ZodBigInt:()=>v$,$ZodBase64URL:()=>uX,$ZodBase64:()=>xX,$ZodAsyncError:()=>F0,$ZodArray:()=>$5,$ZodAny:()=>nX});var W$=Object.freeze({status:"aborted"});function N($,J,Q){function X(B,q){if(!B._zod)Object.defineProperty(B,"_zod",{value:{def:q,constr:K,traits:new Set},enumerable:!1});if(B._zod.traits.has($))return;B._zod.traits.add($),J(B,q);let U=K.prototype,G=Object.keys(U);for(let H=0;H<G.length;H++){let L=G[H];if(!(L in B))B[L]=U[L].bind(B)}}let Y=Q?.Parent??Object;class W extends Y{}Object.defineProperty(W,"name",{value:$});function K(B){var q;let U=Q?.Parent?new W:this;X(U,B),(q=U._zod).deferred??(q.deferred=[]);for(let G of U._zod.deferred)G();return U}return Object.defineProperty(K,"init",{value:X}),Object.defineProperty(K,Symbol.hasInstance,{value:(B)=>{if(Q?.Parent&&B instanceof Q.Parent)return!0;return B?._zod?.traits?.has($)}}),Object.defineProperty(K,"name",{value:$}),K}var K$=Symbol("zod_brand");class F0 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class S2 extends Error{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}}var v3={};function Y1($){if($)Object.assign(v3,$);return v3}var w={};B2(w,{unwrapMessage:()=>f3,uint8ArrayToHex:()=>gR,uint8ArrayToBase64url:()=>hR,uint8ArrayToBase64:()=>KH,stringifyPrimitive:()=>G$,slugify:()=>O7,shallowClone:()=>N7,safeExtend:()=>SR,required:()=>wR,randomString:()=>IR,propertyKeyTypes:()=>g3,promiseAllObject:()=>zR,primitiveTypes:()=>F7,prefixIssues:()=>g1,pick:()=>PR,partial:()=>TR,parsedType:()=>z7,optionalKeys:()=>V7,omit:()=>AR,objectClone:()=>VR,numKeys:()=>jR,nullish:()=>$2,normalizeParams:()=>D,mergeDefs:()=>g0,merge:()=>CR,jsonStringifyReplacer:()=>H4,joinValues:()=>B$,issue:()=>L4,isPlainObject:()=>Q2,isObject:()=>C2,hexToUint8Array:()=>kR,getSizableOrigin:()=>y3,getParsedType:()=>RR,getLengthableOrigin:()=>x3,getEnumValues:()=>h3,getElementAtPath:()=>DR,floatSafeRemainder:()=>L7,finalizeIssue:()=>P1,extend:()=>ER,escapeRegex:()=>r1,esc:()=>q$,defineLazy:()=>u,createTransparentProxy:()=>bR,cloneDef:()=>_R,clone:()=>N1,cleanRegex:()=>k3,cleanEnum:()=>vR,captureStackTrace:()=>U$,cached:()=>Z4,base64urlToUint8Array:()=>fR,base64ToUint8Array:()=>WH,assignProp:()=>J2,assertNotEqual:()=>OR,assertNever:()=>NR,assertIs:()=>MR,assertEqual:()=>LR,assert:()=>FR,allowsEval:()=>M7,aborted:()=>X2,NUMBER_FORMAT_RANGES:()=>_7,Class:()=>BH,BIGINT_FORMAT_RANGES:()=>D7});function LR($){return $}function OR($){return $}function MR($){}function NR($){throw Error("Unexpected value in exhaustive check")}function FR($){}function h3($){let J=Object.values($).filter((X)=>typeof X==="number");return Object.entries($).filter(([X,Y])=>J.indexOf(+X)===-1).map(([X,Y])=>Y)}function B$($,J="|"){return $.map((Q)=>G$(Q)).join(J)}function H4($,J){if(typeof J==="bigint")return J.toString();return J}function Z4($){return{get value(){{let Q=$();return Object.defineProperty(this,"value",{value:Q}),Q}throw Error("cached value already set")}}}function $2($){return $===null||$===void 0}function k3($){let J=$.startsWith("^")?1:0,Q=$.endsWith("$")?$.length-1:$.length;return $.slice(J,Q)}function L7($,J){let Q=($.toString().split(".")[1]||"").length,X=J.toString(),Y=(X.split(".")[1]||"").length;if(Y===0&&/\d?e-\d?/.test(X)){let q=X.match(/\d?e-(\d?)/);if(q?.[1])Y=Number.parseInt(q[1])}let W=Q>Y?Q:Y,K=Number.parseInt($.toFixed(W).replace(".","")),B=Number.parseInt(J.toFixed(W).replace(".",""));return K%B/10**W}var YH=Symbol("evaluating");function u($,J,Q){let X=void 0;Object.defineProperty($,J,{get(){if(X===YH)return;if(X===void 0)X=YH,X=Q();return X},set(Y){Object.defineProperty($,J,{value:Y})},configurable:!0})}function VR($){return Object.create(Object.getPrototypeOf($),Object.getOwnPropertyDescriptors($))}function J2($,J,Q){Object.defineProperty($,J,{value:Q,writable:!0,enumerable:!0,configurable:!0})}function g0(...$){let J={};for(let Q of $){let X=Object.getOwnPropertyDescriptors(Q);Object.assign(J,X)}return Object.defineProperties({},J)}function _R($){return g0($._zod.def)}function DR($,J){if(!J)return $;return J.reduce((Q,X)=>Q?.[X],$)}function zR($){let J=Object.keys($),Q=J.map((X)=>$[X]);return Promise.all(Q).then((X)=>{let Y={};for(let W=0;W<J.length;W++)Y[J[W]]=X[W];return Y})}function IR($=10){let Q="";for(let X=0;X<$;X++)Q+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Q}function q$($){return JSON.stringify($)}function O7($){return $.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var U$="captureStackTrace"in Error?Error.captureStackTrace:(...$)=>{};function C2($){return typeof $==="object"&&$!==null&&!Array.isArray($)}var M7=Z4(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch($){return!1}});function Q2($){if(C2($)===!1)return!1;let J=$.constructor;if(J===void 0)return!0;if(typeof J!=="function")return!0;let Q=J.prototype;if(C2(Q)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Q,"isPrototypeOf")===!1)return!1;return!0}function N7($){if(Q2($))return{...$};if(Array.isArray($))return[...$];return $}function jR($){let J=0;for(let Q in $)if(Object.prototype.hasOwnProperty.call($,Q))J++;return J}var RR=($)=>{let J=typeof $;switch(J){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN($)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray($))return"array";if($===null)return"null";if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return"promise";if(typeof Map<"u"&&$ instanceof Map)return"map";if(typeof Set<"u"&&$ instanceof Set)return"set";if(typeof Date<"u"&&$ instanceof Date)return"date";if(typeof File<"u"&&$ instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${J}`)}},g3=new Set(["string","number","symbol"]),F7=new Set(["string","number","bigint","boolean","symbol","undefined"]);function r1($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function N1($,J,Q){let X=new $._zod.constr(J??$._zod.def);if(!J||Q?.parent)X._zod.parent=$;return X}function D($){let J=$;if(!J)return{};if(typeof J==="string")return{error:()=>J};if(J?.message!==void 0){if(J?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");J.error=J.message}if(delete J.message,typeof J.error==="string")return{...J,error:()=>J.error};return J}function bR($){let J;return new Proxy({},{get(Q,X,Y){return J??(J=$()),Reflect.get(J,X,Y)},set(Q,X,Y,W){return J??(J=$()),Reflect.set(J,X,Y,W)},has(Q,X){return J??(J=$()),Reflect.has(J,X)},deleteProperty(Q,X){return J??(J=$()),Reflect.deleteProperty(J,X)},ownKeys(Q){return J??(J=$()),Reflect.ownKeys(J)},getOwnPropertyDescriptor(Q,X){return J??(J=$()),Reflect.getOwnPropertyDescriptor(J,X)},defineProperty(Q,X,Y){return J??(J=$()),Reflect.defineProperty(J,X,Y)}})}function G$($){if(typeof $==="bigint")return $.toString()+"n";if(typeof $==="string")return`"${$}"`;return`${$}`}function V7($){return Object.keys($).filter((J)=>{return $[J]._zod.optin==="optional"&&$[J]._zod.optout==="optional"})}var _7={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},D7={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function PR($,J){let Q=$._zod.def,X=Q.checks;if(X&&X.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let W=g0($._zod.def,{get shape(){let K={};for(let B in J){if(!(B in Q.shape))throw Error(`Unrecognized key: "${B}"`);if(!J[B])continue;K[B]=Q.shape[B]}return J2(this,"shape",K),K},checks:[]});return N1($,W)}function AR($,J){let Q=$._zod.def,X=Q.checks;if(X&&X.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let W=g0($._zod.def,{get shape(){let K={...$._zod.def.shape};for(let B in J){if(!(B in Q.shape))throw Error(`Unrecognized key: "${B}"`);if(!J[B])continue;delete K[B]}return J2(this,"shape",K),K},checks:[]});return N1($,W)}function ER($,J){if(!Q2(J))throw Error("Invalid input to extend: expected a plain object");let Q=$._zod.def.checks;if(Q&&Q.length>0){let W=$._zod.def.shape;for(let K in J)if(Object.getOwnPropertyDescriptor(W,K)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let Y=g0($._zod.def,{get shape(){let W={...$._zod.def.shape,...J};return J2(this,"shape",W),W}});return N1($,Y)}function SR($,J){if(!Q2(J))throw Error("Invalid input to safeExtend: expected a plain object");let Q=g0($._zod.def,{get shape(){let X={...$._zod.def.shape,...J};return J2(this,"shape",X),X}});return N1($,Q)}function CR($,J){let Q=g0($._zod.def,{get shape(){let X={...$._zod.def.shape,...J._zod.def.shape};return J2(this,"shape",X),X},get catchall(){return J._zod.def.catchall},checks:[]});return N1($,Q)}function TR($,J,Q){let Y=J._zod.def.checks;if(Y&&Y.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let K=g0(J._zod.def,{get shape(){let B=J._zod.def.shape,q={...B};if(Q)for(let U in Q){if(!(U in B))throw Error(`Unrecognized key: "${U}"`);if(!Q[U])continue;q[U]=$?new $({type:"optional",innerType:B[U]}):B[U]}else for(let U in B)q[U]=$?new $({type:"optional",innerType:B[U]}):B[U];return J2(this,"shape",q),q},checks:[]});return N1(J,K)}function wR($,J,Q){let X=g0(J._zod.def,{get shape(){let Y=J._zod.def.shape,W={...Y};if(Q)for(let K in Q){if(!(K in W))throw Error(`Unrecognized key: "${K}"`);if(!Q[K])continue;W[K]=new $({type:"nonoptional",innerType:Y[K]})}else for(let K in Y)W[K]=new $({type:"nonoptional",innerType:Y[K]});return J2(this,"shape",W),W}});return N1(J,X)}function X2($,J=0){if($.aborted===!0)return!0;for(let Q=J;Q<$.issues.length;Q++)if($.issues[Q]?.continue!==!0)return!0;return!1}function g1($,J){return J.map((Q)=>{var X;return(X=Q).path??(X.path=[]),Q.path.unshift($),Q})}function f3($){return typeof $==="string"?$:$?.message}function P1($,J,Q){let X={...$,path:$.path??[]};if(!$.message){let Y=f3($.inst?._zod.def?.error?.($))??f3(J?.error?.($))??f3(Q.customError?.($))??f3(Q.localeError?.($))??"Invalid input";X.message=Y}if(delete X.inst,delete X.continue,!J?.reportInput)delete X.input;return X}function y3($){if($ instanceof Set)return"set";if($ instanceof Map)return"map";if($ instanceof File)return"file";return"unknown"}function x3($){if(Array.isArray($))return"array";if(typeof $==="string")return"string";return"unknown"}function z7($){let J=typeof $;switch(J){case"number":return Number.isNaN($)?"nan":"number";case"object":{if($===null)return"null";if(Array.isArray($))return"array";let Q=$;if(Q&&Object.getPrototypeOf(Q)!==Object.prototype&&"constructor"in Q&&Q.constructor)return Q.constructor.name}}return J}function L4(...$){let[J,Q,X]=$;if(typeof J==="string")return{message:J,code:"custom",input:Q,inst:X};return{...J}}function vR($){return Object.entries($).filter(([J,Q])=>{return Number.isNaN(Number.parseInt(J,10))}).map((J)=>J[1])}function WH($){let J=atob($),Q=new Uint8Array(J.length);for(let X=0;X<J.length;X++)Q[X]=J.charCodeAt(X);return Q}function KH($){let J="";for(let Q=0;Q<$.length;Q++)J+=String.fromCharCode($[Q]);return btoa(J)}function fR($){let J=$.replace(/-/g,"+").replace(/_/g,"/"),Q="=".repeat((4-J.length%4)%4);return WH(J+Q)}function hR($){return KH($).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function kR($){let J=$.replace(/^0x/,"");if(J.length%2!==0)throw Error("Invalid hex string length");let Q=new Uint8Array(J.length/2);for(let X=0;X<J.length;X+=2)Q[X/2]=Number.parseInt(J.slice(X,X+2),16);return Q}function gR($){return Array.from($).map((J)=>J.toString(16).padStart(2,"0")).join("")}class BH{constructor(...$){}}var qH=($,J)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:J,enumerable:!1}),$.message=JSON.stringify(J,H4,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},u3=N("$ZodError",qH),A1=N("$ZodError",qH,{Parent:Error});function O4($,J=(Q)=>Q.message){let Q={},X=[];for(let Y of $.issues)if(Y.path.length>0)Q[Y.path[0]]=Q[Y.path[0]]||[],Q[Y.path[0]].push(J(Y));else X.push(J(Y));return{formErrors:X,fieldErrors:Q}}function M4($,J=(Q)=>Q.message){let Q={_errors:[]},X=(Y)=>{for(let W of Y.issues)if(W.code==="invalid_union"&&W.errors.length)W.errors.map((K)=>X({issues:K}));else if(W.code==="invalid_key")X({issues:W.issues});else if(W.code==="invalid_element")X({issues:W.issues});else if(W.path.length===0)Q._errors.push(J(W));else{let K=Q,B=0;while(B<W.path.length){let q=W.path[B];if(B!==W.path.length-1)K[q]=K[q]||{_errors:[]};else K[q]=K[q]||{_errors:[]},K[q]._errors.push(J(W));K=K[q],B++}}};return X($),Q}function H$($,J=(Q)=>Q.message){let Q={errors:[]},X=(Y,W=[])=>{var K,B;for(let q of Y.issues)if(q.code==="invalid_union"&&q.errors.length)q.errors.map((U)=>X({issues:U},q.path));else if(q.code==="invalid_key")X({issues:q.issues},q.path);else if(q.code==="invalid_element")X({issues:q.issues},q.path);else{let U=[...W,...q.path];if(U.length===0){Q.errors.push(J(q));continue}let G=Q,H=0;while(H<U.length){let L=U[H],Z=H===U.length-1;if(typeof L==="string")G.properties??(G.properties={}),(K=G.properties)[L]??(K[L]={errors:[]}),G=G.properties[L];else G.items??(G.items=[]),(B=G.items)[L]??(B[L]={errors:[]}),G=G.items[L];if(Z)G.errors.push(J(q));H++}}};return X($),Q}function UH($){let J=[],Q=$.map((X)=>typeof X==="object"?X.key:X);for(let X of Q)if(typeof X==="number")J.push(`[${X}]`);else if(typeof X==="symbol")J.push(`[${JSON.stringify(String(X))}]`);else if(/[^\w$]/.test(X))J.push(`[${JSON.stringify(X)}]`);else{if(J.length)J.push(".");J.push(X)}return J.join("")}function Z$($){let J=[],Q=[...$.issues].sort((X,Y)=>(X.path??[]).length-(Y.path??[]).length);for(let X of Q)if(J.push(`\u2716 ${X.message}`),X.path?.length)J.push(` \u2192 at ${UH(X.path)}`);return J.join(`
64
+ `)}var N4=($)=>(J,Q,X,Y)=>{let W=X?Object.assign(X,{async:!1}):{async:!1},K=J._zod.run({value:Q,issues:[]},W);if(K instanceof Promise)throw new F0;if(K.issues.length){let B=new(Y?.Err??$)(K.issues.map((q)=>P1(q,W,Y1())));throw U$(B,Y?.callee),B}return K.value},L$=N4(A1),F4=($)=>async(J,Q,X,Y)=>{let W=X?Object.assign(X,{async:!0}):{async:!0},K=J._zod.run({value:Q,issues:[]},W);if(K instanceof Promise)K=await K;if(K.issues.length){let B=new(Y?.Err??$)(K.issues.map((q)=>P1(q,W,Y1())));throw U$(B,Y?.callee),B}return K.value},O$=F4(A1),V4=($)=>(J,Q,X)=>{let Y=X?{...X,async:!1}:{async:!1},W=J._zod.run({value:Q,issues:[]},Y);if(W instanceof Promise)throw new F0;return W.issues.length?{success:!1,error:new($??u3)(W.issues.map((K)=>P1(K,Y,Y1())))}:{success:!0,data:W.value}},I7=V4(A1),_4=($)=>async(J,Q,X)=>{let Y=X?Object.assign(X,{async:!0}):{async:!0},W=J._zod.run({value:Q,issues:[]},Y);if(W instanceof Promise)W=await W;return W.issues.length?{success:!1,error:new $(W.issues.map((K)=>P1(K,Y,Y1())))}:{success:!0,data:W.value}},j7=_4(A1),M$=($)=>(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return N4($)(J,Q,Y)},xR=M$(A1),N$=($)=>(J,Q,X)=>{return N4($)(J,Q,X)},uR=N$(A1),F$=($)=>async(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return F4($)(J,Q,Y)},mR=F$(A1),V$=($)=>async(J,Q,X)=>{return F4($)(J,Q,X)},lR=V$(A1),_$=($)=>(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return V4($)(J,Q,Y)},pR=_$(A1),D$=($)=>(J,Q,X)=>{return V4($)(J,Q,X)},cR=D$(A1),z$=($)=>async(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return _4($)(J,Q,Y)},dR=z$(A1),I$=($)=>async(J,Q,X)=>{return _4($)(J,Q,X)},rR=I$(A1);var y1={};B2(y1,{xid:()=>A7,uuid7:()=>sR,uuid6:()=>nR,uuid4:()=>oR,uuid:()=>T2,uppercase:()=>a7,unicodeEmail:()=>GH,undefined:()=>n7,ulid:()=>P7,time:()=>l7,string:()=>c7,sha512_hex:()=>Fb,sha512_base64url:()=>_b,sha512_base64:()=>Vb,sha384_hex:()=>Ob,sha384_base64url:()=>Nb,sha384_base64:()=>Mb,sha256_hex:()=>Hb,sha256_base64url:()=>Lb,sha256_base64:()=>Zb,sha1_hex:()=>qb,sha1_base64url:()=>Gb,sha1_base64:()=>Ub,rfc5322Email:()=>tR,number:()=>m3,null:()=>o7,nanoid:()=>S7,md5_hex:()=>Wb,md5_base64url:()=>Bb,md5_base64:()=>Kb,mac:()=>k7,lowercase:()=>s7,ksuid:()=>E7,ipv6:()=>h7,ipv4:()=>f7,integer:()=>r7,idnEmail:()=>eR,html5Email:()=>aR,hostname:()=>Qb,hex:()=>Yb,guid:()=>T7,extendedDuration:()=>iR,emoji:()=>v7,email:()=>w7,e164:()=>u7,duration:()=>C7,domain:()=>Xb,datetime:()=>p7,date:()=>m7,cuid2:()=>b7,cuid:()=>R7,cidrv6:()=>y7,cidrv4:()=>g7,browserEmail:()=>$b,boolean:()=>i7,bigint:()=>d7,base64url:()=>j$,base64:()=>x7});var R7=/^[cC][^\s-]{8,}$/,b7=/^[0-9a-z]+$/,P7=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,A7=/^[0-9a-vA-V]{20}$/,E7=/^[A-Za-z0-9]{27}$/,S7=/^[a-zA-Z0-9_-]{21}$/,C7=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,iR=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,T7=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,T2=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},oR=T2(4),nR=T2(6),sR=T2(7),w7=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,aR=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,tR=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,GH=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,eR=GH,$b=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Jb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function v7(){return new RegExp(Jb,"u")}var f7=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,h7=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,k7=($)=>{let J=r1($??":");return new RegExp(`^(?:[0-9A-F]{2}${J}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${J}){5}[0-9a-f]{2}$`)},g7=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,y7=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,x7=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,j$=/^[A-Za-z0-9_-]*$/,Qb=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Xb=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,u7=/^\+[1-9]\d{6,14}$/,HH="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",m7=new RegExp(`^${HH}$`);function ZH($){return typeof $.precision==="number"?$.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":$.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${$.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function l7($){return new RegExp(`^${ZH($)}$`)}function p7($){let J=ZH({precision:$.precision}),Q=["Z"];if($.local)Q.push("");if($.offset)Q.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let X=`${J}(?:${Q.join("|")})`;return new RegExp(`^${HH}T(?:${X})$`)}var c7=($)=>{let J=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${J}$`)},d7=/^-?\d+n?$/,r7=/^-?\d+$/,m3=/^-?\d+(?:\.\d+)?$/,i7=/^(?:true|false)$/i,o7=/^null$/i;var n7=/^undefined$/i;var s7=/^[^A-Z]*$/,a7=/^[^a-z]*$/,Yb=/^[0-9a-fA-F]*$/;function l3($,J){return new RegExp(`^[A-Za-z0-9+/]{${$}}${J}$`)}function p3($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var Wb=/^[0-9a-fA-F]{32}$/,Kb=l3(22,"=="),Bb=p3(22),qb=/^[0-9a-fA-F]{40}$/,Ub=l3(27,"="),Gb=p3(27),Hb=/^[0-9a-fA-F]{64}$/,Zb=l3(43,"="),Lb=p3(43),Ob=/^[0-9a-fA-F]{96}$/,Mb=l3(64,""),Nb=p3(64),Fb=/^[0-9a-fA-F]{128}$/,Vb=l3(86,"=="),_b=p3(86);var o=N("$ZodCheck",($,J)=>{var Q;$._zod??($._zod={}),$._zod.def=J,(Q=$._zod).onattach??(Q.onattach=[])}),OH={number:"number",bigint:"bigint",object:"date"},R$=N("$ZodCheckLessThan",($,J)=>{o.init($,J);let Q=OH[typeof J.value];$._zod.onattach.push((X)=>{let Y=X._zod.bag,W=(J.inclusive?Y.maximum:Y.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(J.value<W)if(J.inclusive)Y.maximum=J.value;else Y.exclusiveMaximum=J.value}),$._zod.check=(X)=>{if(J.inclusive?X.value<=J.value:X.value<J.value)return;X.issues.push({origin:Q,code:"too_big",maximum:typeof J.value==="object"?J.value.getTime():J.value,input:X.value,inclusive:J.inclusive,inst:$,continue:!J.abort})}}),b$=N("$ZodCheckGreaterThan",($,J)=>{o.init($,J);let Q=OH[typeof J.value];$._zod.onattach.push((X)=>{let Y=X._zod.bag,W=(J.inclusive?Y.minimum:Y.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(J.value>W)if(J.inclusive)Y.minimum=J.value;else Y.exclusiveMinimum=J.value}),$._zod.check=(X)=>{if(J.inclusive?X.value>=J.value:X.value>J.value)return;X.issues.push({origin:Q,code:"too_small",minimum:typeof J.value==="object"?J.value.getTime():J.value,input:X.value,inclusive:J.inclusive,inst:$,continue:!J.abort})}}),t7=N("$ZodCheckMultipleOf",($,J)=>{o.init($,J),$._zod.onattach.push((Q)=>{var X;(X=Q._zod.bag).multipleOf??(X.multipleOf=J.value)}),$._zod.check=(Q)=>{if(typeof Q.value!==typeof J.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof Q.value==="bigint"?Q.value%J.value===BigInt(0):L7(Q.value,J.value)===0)return;Q.issues.push({origin:typeof Q.value,code:"not_multiple_of",divisor:J.value,input:Q.value,inst:$,continue:!J.abort})}}),e7=N("$ZodCheckNumberFormat",($,J)=>{o.init($,J),J.format=J.format||"float64";let Q=J.format?.includes("int"),X=Q?"int":"number",[Y,W]=_7[J.format];$._zod.onattach.push((K)=>{let B=K._zod.bag;if(B.format=J.format,B.minimum=Y,B.maximum=W,Q)B.pattern=r7}),$._zod.check=(K)=>{let B=K.value;if(Q){if(!Number.isInteger(B)){K.issues.push({expected:X,format:J.format,code:"invalid_type",continue:!1,input:B,inst:$});return}if(!Number.isSafeInteger(B)){if(B>0)K.issues.push({input:B,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:X,inclusive:!0,continue:!J.abort});else K.issues.push({input:B,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:X,inclusive:!0,continue:!J.abort});return}}if(B<Y)K.issues.push({origin:"number",input:B,code:"too_small",minimum:Y,inclusive:!0,inst:$,continue:!J.abort});if(B>W)K.issues.push({origin:"number",input:B,code:"too_big",maximum:W,inclusive:!0,inst:$,continue:!J.abort})}}),$X=N("$ZodCheckBigIntFormat",($,J)=>{o.init($,J);let[Q,X]=D7[J.format];$._zod.onattach.push((Y)=>{let W=Y._zod.bag;W.format=J.format,W.minimum=Q,W.maximum=X}),$._zod.check=(Y)=>{let W=Y.value;if(W<Q)Y.issues.push({origin:"bigint",input:W,code:"too_small",minimum:Q,inclusive:!0,inst:$,continue:!J.abort});if(W>X)Y.issues.push({origin:"bigint",input:W,code:"too_big",maximum:X,inclusive:!0,inst:$,continue:!J.abort})}}),JX=N("$ZodCheckMaxSize",($,J)=>{var Q;o.init($,J),(Q=$._zod.def).when??(Q.when=(X)=>{let Y=X.value;return!$2(Y)&&Y.size!==void 0}),$._zod.onattach.push((X)=>{let Y=X._zod.bag.maximum??Number.POSITIVE_INFINITY;if(J.maximum<Y)X._zod.bag.maximum=J.maximum}),$._zod.check=(X)=>{let Y=X.value;if(Y.size<=J.maximum)return;X.issues.push({origin:y3(Y),code:"too_big",maximum:J.maximum,inclusive:!0,input:Y,inst:$,continue:!J.abort})}}),QX=N("$ZodCheckMinSize",($,J)=>{var Q;o.init($,J),(Q=$._zod.def).when??(Q.when=(X)=>{let Y=X.value;return!$2(Y)&&Y.size!==void 0}),$._zod.onattach.push((X)=>{let Y=X._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(J.minimum>Y)X._zod.bag.minimum=J.minimum}),$._zod.check=(X)=>{let Y=X.value;if(Y.size>=J.minimum)return;X.issues.push({origin:y3(Y),code:"too_small",minimum:J.minimum,inclusive:!0,input:Y,inst:$,continue:!J.abort})}}),XX=N("$ZodCheckSizeEquals",($,J)=>{var Q;o.init($,J),(Q=$._zod.def).when??(Q.when=(X)=>{let Y=X.value;return!$2(Y)&&Y.size!==void 0}),$._zod.onattach.push((X)=>{let Y=X._zod.bag;Y.minimum=J.size,Y.maximum=J.size,Y.size=J.size}),$._zod.check=(X)=>{let Y=X.value,W=Y.size;if(W===J.size)return;let K=W>J.size;X.issues.push({origin:y3(Y),...K?{code:"too_big",maximum:J.size}:{code:"too_small",minimum:J.size},inclusive:!0,exact:!0,input:X.value,inst:$,continue:!J.abort})}}),YX=N("$ZodCheckMaxLength",($,J)=>{var Q;o.init($,J),(Q=$._zod.def).when??(Q.when=(X)=>{let Y=X.value;return!$2(Y)&&Y.length!==void 0}),$._zod.onattach.push((X)=>{let Y=X._zod.bag.maximum??Number.POSITIVE_INFINITY;if(J.maximum<Y)X._zod.bag.maximum=J.maximum}),$._zod.check=(X)=>{let Y=X.value;if(Y.length<=J.maximum)return;let K=x3(Y);X.issues.push({origin:K,code:"too_big",maximum:J.maximum,inclusive:!0,input:Y,inst:$,continue:!J.abort})}}),WX=N("$ZodCheckMinLength",($,J)=>{var Q;o.init($,J),(Q=$._zod.def).when??(Q.when=(X)=>{let Y=X.value;return!$2(Y)&&Y.length!==void 0}),$._zod.onattach.push((X)=>{let Y=X._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(J.minimum>Y)X._zod.bag.minimum=J.minimum}),$._zod.check=(X)=>{let Y=X.value;if(Y.length>=J.minimum)return;let K=x3(Y);X.issues.push({origin:K,code:"too_small",minimum:J.minimum,inclusive:!0,input:Y,inst:$,continue:!J.abort})}}),KX=N("$ZodCheckLengthEquals",($,J)=>{var Q;o.init($,J),(Q=$._zod.def).when??(Q.when=(X)=>{let Y=X.value;return!$2(Y)&&Y.length!==void 0}),$._zod.onattach.push((X)=>{let Y=X._zod.bag;Y.minimum=J.length,Y.maximum=J.length,Y.length=J.length}),$._zod.check=(X)=>{let Y=X.value,W=Y.length;if(W===J.length)return;let K=x3(Y),B=W>J.length;X.issues.push({origin:K,...B?{code:"too_big",maximum:J.length}:{code:"too_small",minimum:J.length},inclusive:!0,exact:!0,input:X.value,inst:$,continue:!J.abort})}}),D4=N("$ZodCheckStringFormat",($,J)=>{var Q,X;if(o.init($,J),$._zod.onattach.push((Y)=>{let W=Y._zod.bag;if(W.format=J.format,J.pattern)W.patterns??(W.patterns=new Set),W.patterns.add(J.pattern)}),J.pattern)(Q=$._zod).check??(Q.check=(Y)=>{if(J.pattern.lastIndex=0,J.pattern.test(Y.value))return;Y.issues.push({origin:"string",code:"invalid_format",format:J.format,input:Y.value,...J.pattern?{pattern:J.pattern.toString()}:{},inst:$,continue:!J.abort})});else(X=$._zod).check??(X.check=()=>{})}),BX=N("$ZodCheckRegex",($,J)=>{D4.init($,J),$._zod.check=(Q)=>{if(J.pattern.lastIndex=0,J.pattern.test(Q.value))return;Q.issues.push({origin:"string",code:"invalid_format",format:"regex",input:Q.value,pattern:J.pattern.toString(),inst:$,continue:!J.abort})}}),qX=N("$ZodCheckLowerCase",($,J)=>{J.pattern??(J.pattern=s7),D4.init($,J)}),UX=N("$ZodCheckUpperCase",($,J)=>{J.pattern??(J.pattern=a7),D4.init($,J)}),GX=N("$ZodCheckIncludes",($,J)=>{o.init($,J);let Q=r1(J.includes),X=new RegExp(typeof J.position==="number"?`^.{${J.position}}${Q}`:Q);J.pattern=X,$._zod.onattach.push((Y)=>{let W=Y._zod.bag;W.patterns??(W.patterns=new Set),W.patterns.add(X)}),$._zod.check=(Y)=>{if(Y.value.includes(J.includes,J.position))return;Y.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:J.includes,input:Y.value,inst:$,continue:!J.abort})}}),HX=N("$ZodCheckStartsWith",($,J)=>{o.init($,J);let Q=new RegExp(`^${r1(J.prefix)}.*`);J.pattern??(J.pattern=Q),$._zod.onattach.push((X)=>{let Y=X._zod.bag;Y.patterns??(Y.patterns=new Set),Y.patterns.add(Q)}),$._zod.check=(X)=>{if(X.value.startsWith(J.prefix))return;X.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:J.prefix,input:X.value,inst:$,continue:!J.abort})}}),ZX=N("$ZodCheckEndsWith",($,J)=>{o.init($,J);let Q=new RegExp(`.*${r1(J.suffix)}$`);J.pattern??(J.pattern=Q),$._zod.onattach.push((X)=>{let Y=X._zod.bag;Y.patterns??(Y.patterns=new Set),Y.patterns.add(Q)}),$._zod.check=(X)=>{if(X.value.endsWith(J.suffix))return;X.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:J.suffix,input:X.value,inst:$,continue:!J.abort})}});function LH($,J,Q){if($.issues.length)J.issues.push(...g1(Q,$.issues))}var LX=N("$ZodCheckProperty",($,J)=>{o.init($,J),$._zod.check=(Q)=>{let X=J.schema._zod.run({value:Q.value[J.property],issues:[]},{});if(X instanceof Promise)return X.then((Y)=>LH(Y,Q,J.property));LH(X,Q,J.property);return}}),OX=N("$ZodCheckMimeType",($,J)=>{o.init($,J);let Q=new Set(J.mime);$._zod.onattach.push((X)=>{X._zod.bag.mime=J.mime}),$._zod.check=(X)=>{if(Q.has(X.value.type))return;X.issues.push({code:"invalid_value",values:J.mime,input:X.value.type,inst:$,continue:!J.abort})}}),MX=N("$ZodCheckOverwrite",($,J)=>{o.init($,J),$._zod.check=(Q)=>{Q.value=J.tx(Q.value)}});class P${constructor($=[]){if(this.content=[],this.indent=0,this)this.args=$}indented($){this.indent+=1,$(this),this.indent-=1}write($){if(typeof $==="function"){$(this,{execution:"sync"}),$(this,{execution:"async"});return}let Q=$.split(`
65
65
  `).filter((W)=>W),X=Math.min(...Q.map((W)=>W.length-W.trimStart().length)),Y=Q.map((W)=>W.slice(X)).map((W)=>" ".repeat(this.indent*2)+W);for(let W of Y)this.content.push(W)}compile(){let $=Function,J=this?.args,X=[...(this?.content??[""]).map((Y)=>` ${Y}`)];return new $(...J,X.join(`
66
66
  `))}}var NX={major:4,minor:3,patch:5};var v=N("$ZodType",($,J)=>{var Q;$??($={}),$._zod.def=J,$._zod.bag=$._zod.bag||{},$._zod.version=NX;let X=[...$._zod.def.checks??[]];if($._zod.traits.has("$ZodCheck"))X.unshift($);for(let Y of X)for(let W of Y._zod.onattach)W($);if(X.length===0)(Q=$._zod).deferred??(Q.deferred=[]),$._zod.deferred?.push(()=>{$._zod.run=$._zod.parse});else{let Y=(K,B,q)=>{let U=X2(K),G;for(let H of B){if(H._zod.def.when){if(!H._zod.def.when(K))continue}else if(U)continue;let L=K.issues.length,Z=H._zod.check(K);if(Z instanceof Promise&&q?.async===!1)throw new F0;if(G||Z instanceof Promise)G=(G??Promise.resolve()).then(async()=>{if(await Z,K.issues.length===L)return;if(!U)U=X2(K,L)});else{if(K.issues.length===L)continue;if(!U)U=X2(K,L)}}if(G)return G.then(()=>{return K});return K},W=(K,B,q)=>{if(X2(K))return K.aborted=!0,K;let U=Y(B,X,q);if(U instanceof Promise){if(q.async===!1)throw new F0;return U.then((G)=>$._zod.parse(G,q))}return $._zod.parse(U,q)};$._zod.run=(K,B)=>{if(B.skipChecks)return $._zod.parse(K,B);if(B.direction==="backward"){let U=$._zod.parse({value:K.value,issues:[]},{...B,skipChecks:!0});if(U instanceof Promise)return U.then((G)=>{return W(G,K,B)});return W(U,K,B)}let q=$._zod.parse(K,B);if(q instanceof Promise){if(B.async===!1)throw new F0;return q.then((U)=>Y(U,X,B))}return Y(q,X,B)}}u($,"~standard",()=>({validate:(Y)=>{try{let W=I7($,Y);return W.success?{value:W.data}:{issues:W.error?.issues}}catch(W){return j7($,Y).then((K)=>K.success?{value:K.data}:{issues:K.error?.issues})}},vendor:"zod",version:1}))}),w2=N("$ZodString",($,J)=>{v.init($,J),$._zod.pattern=[...$?._zod.bag?.patterns??[]].pop()??c7($._zod.bag),$._zod.parse=(Q,X)=>{if(J.coerce)try{Q.value=String(Q.value)}catch(Y){}if(typeof Q.value==="string")return Q;return Q.issues.push({expected:"string",code:"invalid_type",input:Q.value,inst:$}),Q}}),d=N("$ZodStringFormat",($,J)=>{D4.init($,J),w2.init($,J)}),VX=N("$ZodGUID",($,J)=>{J.pattern??(J.pattern=T7),d.init($,J)}),_X=N("$ZodUUID",($,J)=>{if(J.version){let X={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[J.version];if(X===void 0)throw Error(`Invalid UUID version: "${J.version}"`);J.pattern??(J.pattern=T2(X))}else J.pattern??(J.pattern=T2());d.init($,J)}),DX=N("$ZodEmail",($,J)=>{J.pattern??(J.pattern=w7),d.init($,J)}),zX=N("$ZodURL",($,J)=>{d.init($,J),$._zod.check=(Q)=>{try{let X=Q.value.trim(),Y=new URL(X);if(J.hostname){if(J.hostname.lastIndex=0,!J.hostname.test(Y.hostname))Q.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:J.hostname.source,input:Q.value,inst:$,continue:!J.abort})}if(J.protocol){if(J.protocol.lastIndex=0,!J.protocol.test(Y.protocol.endsWith(":")?Y.protocol.slice(0,-1):Y.protocol))Q.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:J.protocol.source,input:Q.value,inst:$,continue:!J.abort})}if(J.normalize)Q.value=Y.href;else Q.value=X;return}catch(X){Q.issues.push({code:"invalid_format",format:"url",input:Q.value,inst:$,continue:!J.abort})}}}),IX=N("$ZodEmoji",($,J)=>{J.pattern??(J.pattern=v7()),d.init($,J)}),jX=N("$ZodNanoID",($,J)=>{J.pattern??(J.pattern=S7),d.init($,J)}),RX=N("$ZodCUID",($,J)=>{J.pattern??(J.pattern=R7),d.init($,J)}),bX=N("$ZodCUID2",($,J)=>{J.pattern??(J.pattern=b7),d.init($,J)}),PX=N("$ZodULID",($,J)=>{J.pattern??(J.pattern=P7),d.init($,J)}),AX=N("$ZodXID",($,J)=>{J.pattern??(J.pattern=A7),d.init($,J)}),EX=N("$ZodKSUID",($,J)=>{J.pattern??(J.pattern=E7),d.init($,J)}),SX=N("$ZodISODateTime",($,J)=>{J.pattern??(J.pattern=p7(J)),d.init($,J)}),CX=N("$ZodISODate",($,J)=>{J.pattern??(J.pattern=m7),d.init($,J)}),TX=N("$ZodISOTime",($,J)=>{J.pattern??(J.pattern=l7(J)),d.init($,J)}),wX=N("$ZodISODuration",($,J)=>{J.pattern??(J.pattern=C7),d.init($,J)}),vX=N("$ZodIPv4",($,J)=>{J.pattern??(J.pattern=f7),d.init($,J),$._zod.bag.format="ipv4"}),fX=N("$ZodIPv6",($,J)=>{J.pattern??(J.pattern=h7),d.init($,J),$._zod.bag.format="ipv6",$._zod.check=(Q)=>{try{new URL(`http://[${Q.value}]`)}catch{Q.issues.push({code:"invalid_format",format:"ipv6",input:Q.value,inst:$,continue:!J.abort})}}}),hX=N("$ZodMAC",($,J)=>{J.pattern??(J.pattern=k7(J.delimiter)),d.init($,J),$._zod.bag.format="mac"}),kX=N("$ZodCIDRv4",($,J)=>{J.pattern??(J.pattern=g7),d.init($,J)}),gX=N("$ZodCIDRv6",($,J)=>{J.pattern??(J.pattern=y7),d.init($,J),$._zod.check=(Q)=>{let X=Q.value.split("/");try{if(X.length!==2)throw Error();let[Y,W]=X;if(!W)throw Error();let K=Number(W);if(`${K}`!==W)throw Error();if(K<0||K>128)throw Error();new URL(`http://[${Y}]`)}catch{Q.issues.push({code:"invalid_format",format:"cidrv6",input:Q.value,inst:$,continue:!J.abort})}}});function yX($){if($==="")return!0;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}var xX=N("$ZodBase64",($,J)=>{J.pattern??(J.pattern=x7),d.init($,J),$._zod.bag.contentEncoding="base64",$._zod.check=(Q)=>{if(yX(Q.value))return;Q.issues.push({code:"invalid_format",format:"base64",input:Q.value,inst:$,continue:!J.abort})}});function AH($){if(!j$.test($))return!1;let J=$.replace(/[-_]/g,(X)=>X==="-"?"+":"/"),Q=J.padEnd(Math.ceil(J.length/4)*4,"=");return yX(Q)}var uX=N("$ZodBase64URL",($,J)=>{J.pattern??(J.pattern=j$),d.init($,J),$._zod.bag.contentEncoding="base64url",$._zod.check=(Q)=>{if(AH(Q.value))return;Q.issues.push({code:"invalid_format",format:"base64url",input:Q.value,inst:$,continue:!J.abort})}}),mX=N("$ZodE164",($,J)=>{J.pattern??(J.pattern=u7),d.init($,J)});function EH($,J=null){try{let Q=$.split(".");if(Q.length!==3)return!1;let[X]=Q;if(!X)return!1;let Y=JSON.parse(atob(X));if("typ"in Y&&Y?.typ!=="JWT")return!1;if(!Y.alg)return!1;if(J&&(!("alg"in Y)||Y.alg!==J))return!1;return!0}catch{return!1}}var lX=N("$ZodJWT",($,J)=>{d.init($,J),$._zod.check=(Q)=>{if(EH(Q.value,J.alg))return;Q.issues.push({code:"invalid_format",format:"jwt",input:Q.value,inst:$,continue:!J.abort})}}),pX=N("$ZodCustomStringFormat",($,J)=>{d.init($,J),$._zod.check=(Q)=>{if(J.fn(Q.value))return;Q.issues.push({code:"invalid_format",format:J.format,input:Q.value,inst:$,continue:!J.abort})}}),w$=N("$ZodNumber",($,J)=>{v.init($,J),$._zod.pattern=$._zod.bag.pattern??m3,$._zod.parse=(Q,X)=>{if(J.coerce)try{Q.value=Number(Q.value)}catch(K){}let Y=Q.value;if(typeof Y==="number"&&!Number.isNaN(Y)&&Number.isFinite(Y))return Q;let W=typeof Y==="number"?Number.isNaN(Y)?"NaN":!Number.isFinite(Y)?"Infinity":void 0:void 0;return Q.issues.push({expected:"number",code:"invalid_type",input:Y,inst:$,...W?{received:W}:{}}),Q}}),cX=N("$ZodNumberFormat",($,J)=>{e7.init($,J),w$.init($,J)}),c3=N("$ZodBoolean",($,J)=>{v.init($,J),$._zod.pattern=i7,$._zod.parse=(Q,X)=>{if(J.coerce)try{Q.value=Boolean(Q.value)}catch(W){}let Y=Q.value;if(typeof Y==="boolean")return Q;return Q.issues.push({expected:"boolean",code:"invalid_type",input:Y,inst:$}),Q}}),v$=N("$ZodBigInt",($,J)=>{v.init($,J),$._zod.pattern=d7,$._zod.parse=(Q,X)=>{if(J.coerce)try{Q.value=BigInt(Q.value)}catch(Y){}if(typeof Q.value==="bigint")return Q;return Q.issues.push({expected:"bigint",code:"invalid_type",input:Q.value,inst:$}),Q}}),dX=N("$ZodBigIntFormat",($,J)=>{$X.init($,J),v$.init($,J)}),rX=N("$ZodSymbol",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(typeof Y==="symbol")return Q;return Q.issues.push({expected:"symbol",code:"invalid_type",input:Y,inst:$}),Q}}),iX=N("$ZodUndefined",($,J)=>{v.init($,J),$._zod.pattern=n7,$._zod.values=new Set([void 0]),$._zod.optin="optional",$._zod.optout="optional",$._zod.parse=(Q,X)=>{let Y=Q.value;if(typeof Y>"u")return Q;return Q.issues.push({expected:"undefined",code:"invalid_type",input:Y,inst:$}),Q}}),oX=N("$ZodNull",($,J)=>{v.init($,J),$._zod.pattern=o7,$._zod.values=new Set([null]),$._zod.parse=(Q,X)=>{let Y=Q.value;if(Y===null)return Q;return Q.issues.push({expected:"null",code:"invalid_type",input:Y,inst:$}),Q}}),nX=N("$ZodAny",($,J)=>{v.init($,J),$._zod.parse=(Q)=>Q}),sX=N("$ZodUnknown",($,J)=>{v.init($,J),$._zod.parse=(Q)=>Q}),aX=N("$ZodNever",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{return Q.issues.push({expected:"never",code:"invalid_type",input:Q.value,inst:$}),Q}}),tX=N("$ZodVoid",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(typeof Y>"u")return Q;return Q.issues.push({expected:"void",code:"invalid_type",input:Y,inst:$}),Q}}),eX=N("$ZodDate",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{if(J.coerce)try{Q.value=new Date(Q.value)}catch(B){}let Y=Q.value,W=Y instanceof Date;if(W&&!Number.isNaN(Y.getTime()))return Q;return Q.issues.push({expected:"date",code:"invalid_type",input:Y,...W?{received:"Invalid Date"}:{},inst:$}),Q}});function NH($,J,Q){if($.issues.length)J.issues.push(...g1(Q,$.issues));J.value[Q]=$.value}var $5=N("$ZodArray",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!Array.isArray(Y))return Q.issues.push({expected:"array",code:"invalid_type",input:Y,inst:$}),Q;Q.value=Array(Y.length);let W=[];for(let K=0;K<Y.length;K++){let B=Y[K],q=J.element._zod.run({value:B,issues:[]},X);if(q instanceof Promise)W.push(q.then((U)=>NH(U,Q,K)));else NH(q,Q,K)}if(W.length)return Promise.all(W).then(()=>Q);return Q}});function T$($,J,Q,X,Y){if($.issues.length){if(Y&&!(Q in X))return;J.issues.push(...g1(Q,$.issues))}if($.value===void 0){if(Q in X)J.value[Q]=void 0}else J.value[Q]=$.value}function SH($){let J=Object.keys($.shape);for(let X of J)if(!$.shape?.[X]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${X}": expected a Zod schema`);let Q=V7($.shape);return{...$,keys:J,keySet:new Set(J),numKeys:J.length,optionalKeys:new Set(Q)}}function CH($,J,Q,X,Y,W){let K=[],B=Y.keySet,q=Y.catchall._zod,U=q.def.type,G=q.optout==="optional";for(let H in J){if(B.has(H))continue;if(U==="never"){K.push(H);continue}let L=q.run({value:J[H],issues:[]},X);if(L instanceof Promise)$.push(L.then((Z)=>T$(Z,Q,H,J,G)));else T$(L,Q,H,J,G)}if(K.length)Q.issues.push({code:"unrecognized_keys",keys:K,input:J,inst:W});if(!$.length)return Q;return Promise.all($).then(()=>{return Q})}var TH=N("$ZodObject",($,J)=>{if(v.init($,J),!Object.getOwnPropertyDescriptor(J,"shape")?.get){let B=J.shape;Object.defineProperty(J,"shape",{get:()=>{let q={...B};return Object.defineProperty(J,"shape",{value:q}),q}})}let X=Z4(()=>SH(J));u($._zod,"propValues",()=>{let B=J.shape,q={};for(let U in B){let G=B[U]._zod;if(G.values){q[U]??(q[U]=new Set);for(let H of G.values)q[U].add(H)}}return q});let Y=C2,W=J.catchall,K;$._zod.parse=(B,q)=>{K??(K=X.value);let U=B.value;if(!Y(U))return B.issues.push({expected:"object",code:"invalid_type",input:U,inst:$}),B;B.value={};let G=[],H=K.shape;for(let L of K.keys){let Z=H[L],O=Z._zod.optout==="optional",M=Z._zod.run({value:U[L],issues:[]},q);if(M instanceof Promise)G.push(M.then((V)=>T$(V,B,L,U,O)));else T$(M,B,L,U,O)}if(!W)return G.length?Promise.all(G).then(()=>B):B;return CH(G,U,B,q,X.value,$)}}),J5=N("$ZodObjectJIT",($,J)=>{TH.init($,J);let Q=$._zod.parse,X=Z4(()=>SH(J)),Y=(L)=>{let Z=new P$(["shape","payload","ctx"]),O=X.value,M=(I)=>{let A=q$(I);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};Z.write("const input = payload.value;");let V=Object.create(null),F=0;for(let I of O.keys)V[I]=`key_${F++}`;Z.write("const newResult = {};");for(let I of O.keys){let A=V[I],E=q$(I),R=L[I]?._zod?.optout==="optional";if(Z.write(`const ${A} = ${M(I)};`),R)Z.write(`
67
67
  if (${A}.issues.length) {
@@ -97,6 +97,6 @@ ${kM($.intent??"manual_only")}`,B}function kM($){switch($){case"hard_stop":retur
97
97
  newResult[${E}] = ${A}.value;
98
98
  }
99
99
 
100
- `)}Z.write("payload.value = newResult;"),Z.write("return payload;");let b=Z.compile();return(I,A)=>b(L,I,A)},W,K=C2,B=!v3.jitless,U=B&&M7.value,G=J.catchall,H;$._zod.parse=(L,Z)=>{H??(H=X.value);let O=L.value;if(!K(O))return L.issues.push({expected:"object",code:"invalid_type",input:O,inst:$}),L;if(B&&U&&Z?.async===!1&&Z.jitless!==!0){if(!W)W=Y(J.shape);if(L=W(L,Z),!G)return L;return CH([],O,L,Z,H,$)}return Q(L,Z)}});function FH($,J,Q,X){for(let W of $)if(W.issues.length===0)return J.value=W.value,J;let Y=$.filter((W)=>!X2(W));if(Y.length===1)return J.value=Y[0].value,Y[0];return J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:$.map((W)=>W.issues.map((K)=>P1(K,X,Y1())))}),J}var d3=N("$ZodUnion",($,J)=>{v.init($,J),u($._zod,"optin",()=>J.options.some((Y)=>Y._zod.optin==="optional")?"optional":void 0),u($._zod,"optout",()=>J.options.some((Y)=>Y._zod.optout==="optional")?"optional":void 0),u($._zod,"values",()=>{if(J.options.every((Y)=>Y._zod.values))return new Set(J.options.flatMap((Y)=>Array.from(Y._zod.values)));return}),u($._zod,"pattern",()=>{if(J.options.every((Y)=>Y._zod.pattern)){let Y=J.options.map((W)=>W._zod.pattern);return new RegExp(`^(${Y.map((W)=>k3(W.source)).join("|")})$`)}return});let Q=J.options.length===1,X=J.options[0]._zod.run;$._zod.parse=(Y,W)=>{if(Q)return X(Y,W);let K=!1,B=[];for(let q of J.options){let U=q._zod.run({value:Y.value,issues:[]},W);if(U instanceof Promise)B.push(U),K=!0;else{if(U.issues.length===0)return U;B.push(U)}}if(!K)return FH(B,Y,$,W);return Promise.all(B).then((q)=>{return FH(q,Y,$,W)})}});function VH($,J,Q,X){let Y=$.filter((W)=>W.issues.length===0);if(Y.length===1)return J.value=Y[0].value,J;if(Y.length===0)J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:$.map((W)=>W.issues.map((K)=>P1(K,X,Y1())))});else J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:[],inclusive:!1});return J}var Q5=N("$ZodXor",($,J)=>{d3.init($,J),J.inclusive=!1;let Q=J.options.length===1,X=J.options[0]._zod.run;$._zod.parse=(Y,W)=>{if(Q)return X(Y,W);let K=!1,B=[];for(let q of J.options){let U=q._zod.run({value:Y.value,issues:[]},W);if(U instanceof Promise)B.push(U),K=!0;else B.push(U)}if(!K)return VH(B,Y,$,W);return Promise.all(B).then((q)=>{return VH(q,Y,$,W)})}}),X5=N("$ZodDiscriminatedUnion",($,J)=>{J.inclusive=!1,d3.init($,J);let Q=$._zod.parse;u($._zod,"propValues",()=>{let Y={};for(let W of J.options){let K=W._zod.propValues;if(!K||Object.keys(K).length===0)throw Error(`Invalid discriminated union option at index "${J.options.indexOf(W)}"`);for(let[B,q]of Object.entries(K)){if(!Y[B])Y[B]=new Set;for(let U of q)Y[B].add(U)}}return Y});let X=Z4(()=>{let Y=J.options,W=new Map;for(let K of Y){let B=K._zod.propValues?.[J.discriminator];if(!B||B.size===0)throw Error(`Invalid discriminated union option at index "${J.options.indexOf(K)}"`);for(let q of B){if(W.has(q))throw Error(`Duplicate discriminator value "${String(q)}"`);W.set(q,K)}}return W});$._zod.parse=(Y,W)=>{let K=Y.value;if(!C2(K))return Y.issues.push({code:"invalid_type",expected:"object",input:K,inst:$}),Y;let B=X.value.get(K?.[J.discriminator]);if(B)return B._zod.run(Y,W);if(J.unionFallback)return Q(Y,W);return Y.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:J.discriminator,input:K,path:[J.discriminator],inst:$}),Y}}),Y5=N("$ZodIntersection",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value,W=J.left._zod.run({value:Y,issues:[]},X),K=J.right._zod.run({value:Y,issues:[]},X);if(W instanceof Promise||K instanceof Promise)return Promise.all([W,K]).then(([q,U])=>{return _H(Q,q,U)});return _H(Q,W,K)}});function FX($,J){if($===J)return{valid:!0,data:$};if($ instanceof Date&&J instanceof Date&&+$===+J)return{valid:!0,data:$};if(Q2($)&&Q2(J)){let Q=Object.keys(J),X=Object.keys($).filter((W)=>Q.indexOf(W)!==-1),Y={...$,...J};for(let W of X){let K=FX($[W],J[W]);if(!K.valid)return{valid:!1,mergeErrorPath:[W,...K.mergeErrorPath]};Y[W]=K.data}return{valid:!0,data:Y}}if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return{valid:!1,mergeErrorPath:[]};let Q=[];for(let X=0;X<$.length;X++){let Y=$[X],W=J[X],K=FX(Y,W);if(!K.valid)return{valid:!1,mergeErrorPath:[X,...K.mergeErrorPath]};Q.push(K.data)}return{valid:!0,data:Q}}return{valid:!1,mergeErrorPath:[]}}function _H($,J,Q){let X=new Map,Y;for(let B of J.issues)if(B.code==="unrecognized_keys"){Y??(Y=B);for(let q of B.keys){if(!X.has(q))X.set(q,{});X.get(q).l=!0}}else $.issues.push(B);for(let B of Q.issues)if(B.code==="unrecognized_keys")for(let q of B.keys){if(!X.has(q))X.set(q,{});X.get(q).r=!0}else $.issues.push(B);let W=[...X].filter(([,B])=>B.l&&B.r).map(([B])=>B);if(W.length&&Y)$.issues.push({...Y,keys:W});if(X2($))return $;let K=FX(J.value,Q.value);if(!K.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(K.mergeErrorPath)}`);return $.value=K.data,$}var f$=N("$ZodTuple",($,J)=>{v.init($,J);let Q=J.items;$._zod.parse=(X,Y)=>{let W=X.value;if(!Array.isArray(W))return X.issues.push({input:W,inst:$,expected:"tuple",code:"invalid_type"}),X;X.value=[];let K=[],B=[...Q].reverse().findIndex((G)=>G._zod.optin!=="optional"),q=B===-1?0:Q.length-B;if(!J.rest){let G=W.length>Q.length,H=W.length<q-1;if(G||H)return X.issues.push({...G?{code:"too_big",maximum:Q.length,inclusive:!0}:{code:"too_small",minimum:Q.length},input:W,inst:$,origin:"array"}),X}let U=-1;for(let G of Q){if(U++,U>=W.length){if(U>=q)continue}let H=G._zod.run({value:W[U],issues:[]},Y);if(H instanceof Promise)K.push(H.then((L)=>A$(L,X,U)));else A$(H,X,U)}if(J.rest){let G=W.slice(Q.length);for(let H of G){U++;let L=J.rest._zod.run({value:H,issues:[]},Y);if(L instanceof Promise)K.push(L.then((Z)=>A$(Z,X,U)));else A$(L,X,U)}}if(K.length)return Promise.all(K).then(()=>X);return X}});function A$($,J,Q){if($.issues.length)J.issues.push(...g1(Q,$.issues));J.value[Q]=$.value}var W5=N("$ZodRecord",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!Q2(Y))return Q.issues.push({expected:"record",code:"invalid_type",input:Y,inst:$}),Q;let W=[],K=J.keyType._zod.values;if(K){Q.value={};let B=new Set;for(let U of K)if(typeof U==="string"||typeof U==="number"||typeof U==="symbol"){B.add(typeof U==="number"?U.toString():U);let G=J.valueType._zod.run({value:Y[U],issues:[]},X);if(G instanceof Promise)W.push(G.then((H)=>{if(H.issues.length)Q.issues.push(...g1(U,H.issues));Q.value[U]=H.value}));else{if(G.issues.length)Q.issues.push(...g1(U,G.issues));Q.value[U]=G.value}}let q;for(let U in Y)if(!B.has(U))q=q??[],q.push(U);if(q&&q.length>0)Q.issues.push({code:"unrecognized_keys",input:Y,inst:$,keys:q})}else{Q.value={};for(let B of Reflect.ownKeys(Y)){if(B==="__proto__")continue;let q=J.keyType._zod.run({value:B,issues:[]},X);if(q instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof B==="string"&&m3.test(B)&&q.issues.length&&q.issues.some((H)=>H.code==="invalid_type"&&H.expected==="number")){let H=J.keyType._zod.run({value:Number(B),issues:[]},X);if(H instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(H.issues.length===0)q=H}if(q.issues.length){if(J.mode==="loose")Q.value[B]=Y[B];else Q.issues.push({code:"invalid_key",origin:"record",issues:q.issues.map((H)=>P1(H,X,Y1())),input:B,path:[B],inst:$});continue}let G=J.valueType._zod.run({value:Y[B],issues:[]},X);if(G instanceof Promise)W.push(G.then((H)=>{if(H.issues.length)Q.issues.push(...g1(B,H.issues));Q.value[q.value]=H.value}));else{if(G.issues.length)Q.issues.push(...g1(B,G.issues));Q.value[q.value]=G.value}}}if(W.length)return Promise.all(W).then(()=>Q);return Q}}),K5=N("$ZodMap",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!(Y instanceof Map))return Q.issues.push({expected:"map",code:"invalid_type",input:Y,inst:$}),Q;let W=[];Q.value=new Map;for(let[K,B]of Y){let q=J.keyType._zod.run({value:K,issues:[]},X),U=J.valueType._zod.run({value:B,issues:[]},X);if(q instanceof Promise||U instanceof Promise)W.push(Promise.all([q,U]).then(([G,H])=>{DH(G,H,Q,K,Y,$,X)}));else DH(q,U,Q,K,Y,$,X)}if(W.length)return Promise.all(W).then(()=>Q);return Q}});function DH($,J,Q,X,Y,W,K){if($.issues.length)if(g3.has(typeof X))Q.issues.push(...g1(X,$.issues));else Q.issues.push({code:"invalid_key",origin:"map",input:Y,inst:W,issues:$.issues.map((B)=>P1(B,K,Y1()))});if(J.issues.length)if(g3.has(typeof X))Q.issues.push(...g1(X,J.issues));else Q.issues.push({origin:"map",code:"invalid_element",input:Y,inst:W,key:X,issues:J.issues.map((B)=>P1(B,K,Y1()))});Q.value.set($.value,J.value)}var B5=N("$ZodSet",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!(Y instanceof Set))return Q.issues.push({input:Y,inst:$,expected:"set",code:"invalid_type"}),Q;let W=[];Q.value=new Set;for(let K of Y){let B=J.valueType._zod.run({value:K,issues:[]},X);if(B instanceof Promise)W.push(B.then((q)=>zH(q,Q)));else zH(B,Q)}if(W.length)return Promise.all(W).then(()=>Q);return Q}});function zH($,J){if($.issues.length)J.issues.push(...$.issues);J.value.add($.value)}var q5=N("$ZodEnum",($,J)=>{v.init($,J);let Q=h3(J.entries),X=new Set(Q);$._zod.values=X,$._zod.pattern=new RegExp(`^(${Q.filter((Y)=>g3.has(typeof Y)).map((Y)=>typeof Y==="string"?r1(Y):Y.toString()).join("|")})$`),$._zod.parse=(Y,W)=>{let K=Y.value;if(X.has(K))return Y;return Y.issues.push({code:"invalid_value",values:Q,input:K,inst:$}),Y}}),U5=N("$ZodLiteral",($,J)=>{if(v.init($,J),J.values.length===0)throw Error("Cannot create literal schema with no valid values");let Q=new Set(J.values);$._zod.values=Q,$._zod.pattern=new RegExp(`^(${J.values.map((X)=>typeof X==="string"?r1(X):X?r1(X.toString()):String(X)).join("|")})$`),$._zod.parse=(X,Y)=>{let W=X.value;if(Q.has(W))return X;return X.issues.push({code:"invalid_value",values:J.values,input:W,inst:$}),X}}),G5=N("$ZodFile",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(Y instanceof File)return Q;return Q.issues.push({expected:"file",code:"invalid_type",input:Y,inst:$}),Q}}),H5=N("$ZodTransform",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{if(X.direction==="backward")throw new S2($.constructor.name);let Y=J.transform(Q.value,Q);if(X.async)return(Y instanceof Promise?Y:Promise.resolve(Y)).then((K)=>{return Q.value=K,Q});if(Y instanceof Promise)throw new F0;return Q.value=Y,Q}});function IH($,J){if($.issues.length&&J===void 0)return{issues:[],value:void 0};return $}var h$=N("$ZodOptional",($,J)=>{v.init($,J),$._zod.optin="optional",$._zod.optout="optional",u($._zod,"values",()=>{return J.innerType._zod.values?new Set([...J.innerType._zod.values,void 0]):void 0}),u($._zod,"pattern",()=>{let Q=J.innerType._zod.pattern;return Q?new RegExp(`^(${k3(Q.source)})?$`):void 0}),$._zod.parse=(Q,X)=>{if(J.innerType._zod.optin==="optional"){let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>IH(W,Q.value));return IH(Y,Q.value)}if(Q.value===void 0)return Q;return J.innerType._zod.run(Q,X)}}),Z5=N("$ZodExactOptional",($,J)=>{h$.init($,J),u($._zod,"values",()=>J.innerType._zod.values),u($._zod,"pattern",()=>J.innerType._zod.pattern),$._zod.parse=(Q,X)=>{return J.innerType._zod.run(Q,X)}}),L5=N("$ZodNullable",($,J)=>{v.init($,J),u($._zod,"optin",()=>J.innerType._zod.optin),u($._zod,"optout",()=>J.innerType._zod.optout),u($._zod,"pattern",()=>{let Q=J.innerType._zod.pattern;return Q?new RegExp(`^(${k3(Q.source)}|null)$`):void 0}),u($._zod,"values",()=>{return J.innerType._zod.values?new Set([...J.innerType._zod.values,null]):void 0}),$._zod.parse=(Q,X)=>{if(Q.value===null)return Q;return J.innerType._zod.run(Q,X)}}),O5=N("$ZodDefault",($,J)=>{v.init($,J),$._zod.optin="optional",u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);if(Q.value===void 0)return Q.value=J.defaultValue,Q;let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>jH(W,J));return jH(Y,J)}});function jH($,J){if($.value===void 0)$.value=J.defaultValue;return $}var M5=N("$ZodPrefault",($,J)=>{v.init($,J),$._zod.optin="optional",u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);if(Q.value===void 0)Q.value=J.defaultValue;return J.innerType._zod.run(Q,X)}}),N5=N("$ZodNonOptional",($,J)=>{v.init($,J),u($._zod,"values",()=>{let Q=J.innerType._zod.values;return Q?new Set([...Q].filter((X)=>X!==void 0)):void 0}),$._zod.parse=(Q,X)=>{let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>RH(W,$));return RH(Y,$)}});function RH($,J){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:J});return $}var F5=N("$ZodSuccess",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{if(X.direction==="backward")throw new S2("ZodSuccess");let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>{return Q.value=W.issues.length===0,Q});return Q.value=Y.issues.length===0,Q}}),V5=N("$ZodCatch",($,J)=>{v.init($,J),u($._zod,"optin",()=>J.innerType._zod.optin),u($._zod,"optout",()=>J.innerType._zod.optout),u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>{if(Q.value=W.value,W.issues.length)Q.value=J.catchValue({...Q,error:{issues:W.issues.map((K)=>P1(K,X,Y1()))},input:Q.value}),Q.issues=[];return Q});if(Q.value=Y.value,Y.issues.length)Q.value=J.catchValue({...Q,error:{issues:Y.issues.map((W)=>P1(W,X,Y1()))},input:Q.value}),Q.issues=[];return Q}}),_5=N("$ZodNaN",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{if(typeof Q.value!=="number"||!Number.isNaN(Q.value))return Q.issues.push({input:Q.value,inst:$,expected:"nan",code:"invalid_type"}),Q;return Q}}),D5=N("$ZodPipe",($,J)=>{v.init($,J),u($._zod,"values",()=>J.in._zod.values),u($._zod,"optin",()=>J.in._zod.optin),u($._zod,"optout",()=>J.out._zod.optout),u($._zod,"propValues",()=>J.in._zod.propValues),$._zod.parse=(Q,X)=>{if(X.direction==="backward"){let W=J.out._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>E$(K,J.in,X));return E$(W,J.in,X)}let Y=J.in._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>E$(W,J.out,X));return E$(Y,J.out,X)}});function E$($,J,Q){if($.issues.length)return $.aborted=!0,$;return J._zod.run({value:$.value,issues:$.issues},Q)}var r3=N("$ZodCodec",($,J)=>{v.init($,J),u($._zod,"values",()=>J.in._zod.values),u($._zod,"optin",()=>J.in._zod.optin),u($._zod,"optout",()=>J.out._zod.optout),u($._zod,"propValues",()=>J.in._zod.propValues),$._zod.parse=(Q,X)=>{if((X.direction||"forward")==="forward"){let W=J.in._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>S$(K,J,X));return S$(W,J,X)}else{let W=J.out._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>S$(K,J,X));return S$(W,J,X)}}});function S$($,J,Q){if($.issues.length)return $.aborted=!0,$;if((Q.direction||"forward")==="forward"){let Y=J.transform($.value,$);if(Y instanceof Promise)return Y.then((W)=>C$($,W,J.out,Q));return C$($,Y,J.out,Q)}else{let Y=J.reverseTransform($.value,$);if(Y instanceof Promise)return Y.then((W)=>C$($,W,J.in,Q));return C$($,Y,J.in,Q)}}function C$($,J,Q,X){if($.issues.length)return $.aborted=!0,$;return Q._zod.run({value:J,issues:$.issues},X)}var z5=N("$ZodReadonly",($,J)=>{v.init($,J),u($._zod,"propValues",()=>J.innerType._zod.propValues),u($._zod,"values",()=>J.innerType._zod.values),u($._zod,"optin",()=>J.innerType?._zod?.optin),u($._zod,"optout",()=>J.innerType?._zod?.optout),$._zod.parse=(Q,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then(bH);return bH(Y)}});function bH($){return $.value=Object.freeze($.value),$}var I5=N("$ZodTemplateLiteral",($,J)=>{v.init($,J);let Q=[];for(let X of J.parts)if(typeof X==="object"&&X!==null){if(!X._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...X._zod.traits].shift()}`);let Y=X._zod.pattern instanceof RegExp?X._zod.pattern.source:X._zod.pattern;if(!Y)throw Error(`Invalid template literal part: ${X._zod.traits}`);let W=Y.startsWith("^")?1:0,K=Y.endsWith("$")?Y.length-1:Y.length;Q.push(Y.slice(W,K))}else if(X===null||F7.has(typeof X))Q.push(r1(`${X}`));else throw Error(`Invalid template literal part: ${X}`);$._zod.pattern=new RegExp(`^${Q.join("")}$`),$._zod.parse=(X,Y)=>{if(typeof X.value!=="string")return X.issues.push({input:X.value,inst:$,expected:"string",code:"invalid_type"}),X;if($._zod.pattern.lastIndex=0,!$._zod.pattern.test(X.value))return X.issues.push({input:X.value,inst:$,code:"invalid_format",format:J.format??"template_literal",pattern:$._zod.pattern.source}),X;return X}}),j5=N("$ZodFunction",($,J)=>{return v.init($,J),$._def=J,$._zod.def=J,$.implement=(Q)=>{if(typeof Q!=="function")throw Error("implement() must be called with a function");return function(...X){let Y=$._def.input?L$($._def.input,X):X,W=Reflect.apply(Q,this,Y);if($._def.output)return L$($._def.output,W);return W}},$.implementAsync=(Q)=>{if(typeof Q!=="function")throw Error("implementAsync() must be called with a function");return async function(...X){let Y=$._def.input?await O$($._def.input,X):X,W=await Reflect.apply(Q,this,Y);if($._def.output)return await O$($._def.output,W);return W}},$._zod.parse=(Q,X)=>{if(typeof Q.value!=="function")return Q.issues.push({code:"invalid_type",expected:"function",input:Q.value,inst:$}),Q;if($._def.output&&$._def.output._zod.def.type==="promise")Q.value=$.implementAsync(Q.value);else Q.value=$.implement(Q.value);return Q},$.input=(...Q)=>{let X=$.constructor;if(Array.isArray(Q[0]))return new X({type:"function",input:new f$({type:"tuple",items:Q[0],rest:Q[1]}),output:$._def.output});return new X({type:"function",input:Q[0],output:$._def.output})},$.output=(Q)=>{return new $.constructor({type:"function",input:$._def.input,output:Q})},$}),R5=N("$ZodPromise",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{return Promise.resolve(Q.value).then((Y)=>J.innerType._zod.run({value:Y,issues:[]},X))}}),b5=N("$ZodLazy",($,J)=>{v.init($,J),u($._zod,"innerType",()=>J.getter()),u($._zod,"pattern",()=>$._zod.innerType?._zod?.pattern),u($._zod,"propValues",()=>$._zod.innerType?._zod?.propValues),u($._zod,"optin",()=>$._zod.innerType?._zod?.optin??void 0),u($._zod,"optout",()=>$._zod.innerType?._zod?.optout??void 0),$._zod.parse=(Q,X)=>{return $._zod.innerType._zod.run(Q,X)}}),P5=N("$ZodCustom",($,J)=>{o.init($,J),v.init($,J),$._zod.parse=(Q,X)=>{return Q},$._zod.check=(Q)=>{let X=Q.value,Y=J.fn(X);if(Y instanceof Promise)return Y.then((W)=>PH(W,Q,X,$));PH(Y,Q,X,$);return}});function PH($,J,Q,X){if(!$){let Y={code:"custom",input:Q,inst:X,path:[...X._zod.def.path??[]],continue:!X._zod.def.abort};if(X._zod.def.params)Y.params=X._zod.def.params;J.issues.push(L4(Y))}}var i3={};var wH,k$=Symbol("ZodOutput"),g$=Symbol("ZodInput");class A5{constructor(){this._map=new WeakMap,this._idmap=new Map}add($,...J){let Q=J[0];if(this._map.set($,Q),Q&&typeof Q==="object"&&"id"in Q)this._idmap.set(Q.id,$);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove($){let J=this._map.get($);if(J&&typeof J==="object"&&"id"in J)this._idmap.delete(J.id);return this._map.delete($),this}get($){let J=$._zod.parent;if(J){let Q={...this.get(J)??{}};delete Q.id;let X={...Q,...this._map.get($)};return Object.keys(X).length?X:void 0}return this._map.get($)}has($){return this._map.has($)}}function o3(){return new A5}(wH=globalThis).__zod_globalRegistry??(wH.__zod_globalRegistry=o3());var E1=globalThis.__zod_globalRegistry;function E5($,J){return new $({type:"string",...D(J)})}function S5($,J){return new $({type:"string",coerce:!0,...D(J)})}function y$($,J){return new $({type:"string",format:"email",check:"string_format",abort:!1,...D(J)})}function n3($,J){return new $({type:"string",format:"guid",check:"string_format",abort:!1,...D(J)})}function x$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,...D(J)})}function u$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...D(J)})}function m$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...D(J)})}function l$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...D(J)})}function s3($,J){return new $({type:"string",format:"url",check:"string_format",abort:!1,...D(J)})}function p$($,J){return new $({type:"string",format:"emoji",check:"string_format",abort:!1,...D(J)})}function c$($,J){return new $({type:"string",format:"nanoid",check:"string_format",abort:!1,...D(J)})}function d$($,J){return new $({type:"string",format:"cuid",check:"string_format",abort:!1,...D(J)})}function r$($,J){return new $({type:"string",format:"cuid2",check:"string_format",abort:!1,...D(J)})}function i$($,J){return new $({type:"string",format:"ulid",check:"string_format",abort:!1,...D(J)})}function o$($,J){return new $({type:"string",format:"xid",check:"string_format",abort:!1,...D(J)})}function n$($,J){return new $({type:"string",format:"ksuid",check:"string_format",abort:!1,...D(J)})}function s$($,J){return new $({type:"string",format:"ipv4",check:"string_format",abort:!1,...D(J)})}function a$($,J){return new $({type:"string",format:"ipv6",check:"string_format",abort:!1,...D(J)})}function C5($,J){return new $({type:"string",format:"mac",check:"string_format",abort:!1,...D(J)})}function t$($,J){return new $({type:"string",format:"cidrv4",check:"string_format",abort:!1,...D(J)})}function e$($,J){return new $({type:"string",format:"cidrv6",check:"string_format",abort:!1,...D(J)})}function $8($,J){return new $({type:"string",format:"base64",check:"string_format",abort:!1,...D(J)})}function J8($,J){return new $({type:"string",format:"base64url",check:"string_format",abort:!1,...D(J)})}function Q8($,J){return new $({type:"string",format:"e164",check:"string_format",abort:!1,...D(J)})}function X8($,J){return new $({type:"string",format:"jwt",check:"string_format",abort:!1,...D(J)})}var Y8={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function T5($,J){return new $({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...D(J)})}function w5($,J){return new $({type:"string",format:"date",check:"string_format",...D(J)})}function v5($,J){return new $({type:"string",format:"time",check:"string_format",precision:null,...D(J)})}function f5($,J){return new $({type:"string",format:"duration",check:"string_format",...D(J)})}function h5($,J){return new $({type:"number",checks:[],...D(J)})}function k5($,J){return new $({type:"number",coerce:!0,checks:[],...D(J)})}function g5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"safeint",...D(J)})}function y5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"float32",...D(J)})}function x5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"float64",...D(J)})}function u5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"int32",...D(J)})}function m5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"uint32",...D(J)})}function l5($,J){return new $({type:"boolean",...D(J)})}function p5($,J){return new $({type:"boolean",coerce:!0,...D(J)})}function c5($,J){return new $({type:"bigint",...D(J)})}function d5($,J){return new $({type:"bigint",coerce:!0,...D(J)})}function r5($,J){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...D(J)})}function i5($,J){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...D(J)})}function o5($,J){return new $({type:"symbol",...D(J)})}function n5($,J){return new $({type:"undefined",...D(J)})}function s5($,J){return new $({type:"null",...D(J)})}function a5($){return new $({type:"any"})}function t5($){return new $({type:"unknown"})}function e5($,J){return new $({type:"never",...D(J)})}function $Y($,J){return new $({type:"void",...D(J)})}function JY($,J){return new $({type:"date",...D(J)})}function QY($,J){return new $({type:"date",coerce:!0,...D(J)})}function XY($,J){return new $({type:"nan",...D(J)})}function V0($,J){return new R$({check:"less_than",...D(J),value:$,inclusive:!1})}function x1($,J){return new R$({check:"less_than",...D(J),value:$,inclusive:!0})}function _0($,J){return new b$({check:"greater_than",...D(J),value:$,inclusive:!1})}function D1($,J){return new b$({check:"greater_than",...D(J),value:$,inclusive:!0})}function W8($){return _0(0,$)}function K8($){return V0(0,$)}function B8($){return x1(0,$)}function q8($){return D1(0,$)}function Y2($,J){return new t7({check:"multiple_of",...D(J),value:$})}function W2($,J){return new JX({check:"max_size",...D(J),maximum:$})}function D0($,J){return new QX({check:"min_size",...D(J),minimum:$})}function v2($,J){return new XX({check:"size_equals",...D(J),size:$})}function f2($,J){return new YX({check:"max_length",...D(J),maximum:$})}function g0($,J){return new WX({check:"min_length",...D(J),minimum:$})}function h2($,J){return new KX({check:"length_equals",...D(J),length:$})}function z4($,J){return new BX({check:"string_format",format:"regex",...D(J),pattern:$})}function I4($){return new qX({check:"string_format",format:"lowercase",...D($)})}function j4($){return new UX({check:"string_format",format:"uppercase",...D($)})}function R4($,J){return new GX({check:"string_format",format:"includes",...D(J),includes:$})}function b4($,J){return new HX({check:"string_format",format:"starts_with",...D(J),prefix:$})}function P4($,J){return new ZX({check:"string_format",format:"ends_with",...D(J),suffix:$})}function U8($,J,Q){return new LX({check:"property",property:$,schema:J,...D(Q)})}function A4($,J){return new OX({check:"mime_type",mime:$,...D(J)})}function Q0($){return new MX({check:"overwrite",tx:$})}function E4($){return Q0((J)=>J.normalize($))}function S4(){return Q0(($)=>$.trim())}function C4(){return Q0(($)=>$.toLowerCase())}function T4(){return Q0(($)=>$.toUpperCase())}function w4(){return Q0(($)=>O7($))}function YY($,J,Q){return new $({type:"array",element:J,...D(Q)})}function Db($,J,Q){return new $({type:"union",options:J,...D(Q)})}function zb($,J,Q){return new $({type:"union",options:J,inclusive:!1,...D(Q)})}function Ib($,J,Q,X){return new $({type:"union",options:Q,discriminator:J,...D(X)})}function jb($,J,Q){return new $({type:"intersection",left:J,right:Q})}function Rb($,J,Q,X){let Y=Q instanceof v;return new $({type:"tuple",items:J,rest:Y?Q:null,...D(Y?X:Q)})}function bb($,J,Q,X){return new $({type:"record",keyType:J,valueType:Q,...D(X)})}function Pb($,J,Q,X){return new $({type:"map",keyType:J,valueType:Q,...D(X)})}function Ab($,J,Q){return new $({type:"set",valueType:J,...D(Q)})}function Eb($,J,Q){let X=Array.isArray(J)?Object.fromEntries(J.map((Y)=>[Y,Y])):J;return new $({type:"enum",entries:X,...D(Q)})}function Sb($,J,Q){return new $({type:"enum",entries:J,...D(Q)})}function Cb($,J,Q){return new $({type:"literal",values:Array.isArray(J)?J:[J],...D(Q)})}function WY($,J){return new $({type:"file",...D(J)})}function Tb($,J){return new $({type:"transform",transform:J})}function wb($,J){return new $({type:"optional",innerType:J})}function vb($,J){return new $({type:"nullable",innerType:J})}function fb($,J,Q){return new $({type:"default",innerType:J,get defaultValue(){return typeof Q==="function"?Q():N7(Q)}})}function hb($,J,Q){return new $({type:"nonoptional",innerType:J,...D(Q)})}function kb($,J){return new $({type:"success",innerType:J})}function gb($,J,Q){return new $({type:"catch",innerType:J,catchValue:typeof Q==="function"?Q:()=>Q})}function yb($,J,Q){return new $({type:"pipe",in:J,out:Q})}function xb($,J){return new $({type:"readonly",innerType:J})}function ub($,J,Q){return new $({type:"template_literal",parts:J,...D(Q)})}function mb($,J){return new $({type:"lazy",getter:J})}function lb($,J){return new $({type:"promise",innerType:J})}function KY($,J,Q){let X=D(Q);return X.abort??(X.abort=!0),new $({type:"custom",check:"custom",fn:J,...X})}function BY($,J,Q){return new $({type:"custom",check:"custom",fn:J,...D(Q)})}function qY($){let J=vH((Q)=>{return Q.addIssue=(X)=>{if(typeof X==="string")Q.issues.push(L4(X,Q.value,J._zod.def));else{let Y=X;if(Y.fatal)Y.continue=!1;Y.code??(Y.code="custom"),Y.input??(Y.input=Q.value),Y.inst??(Y.inst=J),Y.continue??(Y.continue=!J._zod.def.abort),Q.issues.push(L4(Y))}},$(Q.value,Q)});return J}function vH($,J){let Q=new o({check:"custom",...D(J)});return Q._zod.check=$,Q}function UY($){let J=new o({check:"describe"});return J._zod.onattach=[(Q)=>{let X=E1.get(Q)??{};E1.add(Q,{...X,description:$})}],J._zod.check=()=>{},J}function GY($){let J=new o({check:"meta"});return J._zod.onattach=[(Q)=>{let X=E1.get(Q)??{};E1.add(Q,{...X,...$})}],J._zod.check=()=>{},J}function HY($,J){let Q=D(J),X=Q.truthy??["true","1","yes","on","y","enabled"],Y=Q.falsy??["false","0","no","off","n","disabled"];if(Q.case!=="sensitive")X=X.map((Z)=>typeof Z==="string"?Z.toLowerCase():Z),Y=Y.map((Z)=>typeof Z==="string"?Z.toLowerCase():Z);let W=new Set(X),K=new Set(Y),B=$.Codec??r3,q=$.Boolean??c3,G=new($.String??w2)({type:"string",error:Q.error}),H=new q({type:"boolean",error:Q.error}),L=new B({type:"pipe",in:G,out:H,transform:(Z,O)=>{let M=Z;if(Q.case!=="sensitive")M=M.toLowerCase();if(W.has(M))return!0;else if(K.has(M))return!1;else return O.issues.push({code:"invalid_value",expected:"stringbool",values:[...W,...K],input:O.value,inst:L,continue:!1}),{}},reverseTransform:(Z,O)=>{if(Z===!0)return X[0]||"true";else return Y[0]||"false"},error:Q.error});return L}function v4($,J,Q,X={}){let Y=D(X),W={...D(X),check:"string_format",type:"string",format:J,fn:typeof Q==="function"?Q:(B)=>Q.test(B),...Y};if(Q instanceof RegExp)W.pattern=Q;return new $(W)}var f4=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")},ZY=()=>f4,G8=()=>f4,h4=f4,n=f4,k4=f4,g4=f4;var pb={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},LY=($,J,Q,X)=>{let Y=Q;Y.type="string";let{minimum:W,maximum:K,format:B,patterns:q,contentEncoding:U}=$._zod.bag;if(typeof W==="number")Y.minLength=W;if(typeof K==="number")Y.maxLength=K;if(B){if(Y.format=pb[B]??B,Y.format==="")delete Y.format;if(B==="time")delete Y.format}if(U)Y.contentEncoding=U;if(q&&q.size>0){let G=[...q];if(G.length===1)Y.pattern=G[0].source;else if(G.length>1)Y.allOf=[...G.map((H)=>({...J.target==="draft-07"||J.target==="draft-04"||J.target==="openapi-3.0"?{type:"string"}:{},pattern:H.source}))]}},OY=($,J,Q,X)=>{let Y=Q,{minimum:W,maximum:K,format:B,multipleOf:q,exclusiveMaximum:U,exclusiveMinimum:G}=$._zod.bag;if(typeof B==="string"&&B.includes("int"))Y.type="integer";else Y.type="number";if(typeof G==="number")if(J.target==="draft-04"||J.target==="openapi-3.0")Y.minimum=G,Y.exclusiveMinimum=!0;else Y.exclusiveMinimum=G;if(typeof W==="number"){if(Y.minimum=W,typeof G==="number"&&J.target!=="draft-04")if(G>=W)delete Y.minimum;else delete Y.exclusiveMinimum}if(typeof U==="number")if(J.target==="draft-04"||J.target==="openapi-3.0")Y.maximum=U,Y.exclusiveMaximum=!0;else Y.exclusiveMaximum=U;if(typeof K==="number"){if(Y.maximum=K,typeof U==="number"&&J.target!=="draft-04")if(U<=K)delete Y.maximum;else delete Y.exclusiveMaximum}if(typeof q==="number")Y.multipleOf=q},MY=($,J,Q,X)=>{Q.type="boolean"},NY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},FY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},VY=($,J,Q,X)=>{if(J.target==="openapi-3.0")Q.type="string",Q.nullable=!0,Q.enum=[null];else Q.type="null"},_Y=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},DY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},zY=($,J,Q,X)=>{Q.not={}},IY=($,J,Q,X)=>{},jY=($,J,Q,X)=>{},RY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},bY=($,J,Q,X)=>{let Y=$._zod.def,W=h3(Y.entries);if(W.every((K)=>typeof K==="number"))Q.type="number";if(W.every((K)=>typeof K==="string"))Q.type="string";Q.enum=W},PY=($,J,Q,X)=>{let Y=$._zod.def,W=[];for(let K of Y.values)if(K===void 0){if(J.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof K==="bigint")if(J.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else W.push(Number(K));else W.push(K);if(W.length===0);else if(W.length===1){let K=W[0];if(Q.type=K===null?"null":typeof K,J.target==="draft-04"||J.target==="openapi-3.0")Q.enum=[K];else Q.const=K}else{if(W.every((K)=>typeof K==="number"))Q.type="number";if(W.every((K)=>typeof K==="string"))Q.type="string";if(W.every((K)=>typeof K==="boolean"))Q.type="boolean";if(W.every((K)=>K===null))Q.type="null";Q.enum=W}},AY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},EY=($,J,Q,X)=>{let Y=Q,W=$._zod.pattern;if(!W)throw Error("Pattern not found in template literal");Y.type="string",Y.pattern=W.source},SY=($,J,Q,X)=>{let Y=Q,W={type:"string",format:"binary",contentEncoding:"binary"},{minimum:K,maximum:B,mime:q}=$._zod.bag;if(K!==void 0)W.minLength=K;if(B!==void 0)W.maxLength=B;if(q)if(q.length===1)W.contentMediaType=q[0],Object.assign(Y,W);else Object.assign(Y,W),Y.anyOf=q.map((U)=>({contentMediaType:U}));else Object.assign(Y,W)},CY=($,J,Q,X)=>{Q.type="boolean"},TY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},wY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},vY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},fY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},hY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},kY=($,J,Q,X)=>{let Y=Q,W=$._zod.def,{minimum:K,maximum:B}=$._zod.bag;if(typeof K==="number")Y.minItems=K;if(typeof B==="number")Y.maxItems=B;Y.type="array",Y.items=n(W.element,J,{...X,path:[...X.path,"items"]})},gY=($,J,Q,X)=>{let Y=Q,W=$._zod.def;Y.type="object",Y.properties={};let K=W.shape;for(let U in K)Y.properties[U]=n(K[U],J,{...X,path:[...X.path,"properties",U]});let B=new Set(Object.keys(K)),q=new Set([...B].filter((U)=>{let G=W.shape[U]._zod;if(J.io==="input")return G.optin===void 0;else return G.optout===void 0}));if(q.size>0)Y.required=Array.from(q);if(W.catchall?._zod.def.type==="never")Y.additionalProperties=!1;else if(!W.catchall){if(J.io==="output")Y.additionalProperties=!1}else if(W.catchall)Y.additionalProperties=n(W.catchall,J,{...X,path:[...X.path,"additionalProperties"]})},Z8=($,J,Q,X)=>{let Y=$._zod.def,W=Y.inclusive===!1,K=Y.options.map((B,q)=>n(B,J,{...X,path:[...X.path,W?"oneOf":"anyOf",q]}));if(W)Q.oneOf=K;else Q.anyOf=K},yY=($,J,Q,X)=>{let Y=$._zod.def,W=n(Y.left,J,{...X,path:[...X.path,"allOf",0]}),K=n(Y.right,J,{...X,path:[...X.path,"allOf",1]}),B=(U)=>("allOf"in U)&&Object.keys(U).length===1,q=[...B(W)?W.allOf:[W],...B(K)?K.allOf:[K]];Q.allOf=q},xY=($,J,Q,X)=>{let Y=Q,W=$._zod.def;Y.type="array";let K=J.target==="draft-2020-12"?"prefixItems":"items",B=J.target==="draft-2020-12"?"items":J.target==="openapi-3.0"?"items":"additionalItems",q=W.items.map((L,Z)=>n(L,J,{...X,path:[...X.path,K,Z]})),U=W.rest?n(W.rest,J,{...X,path:[...X.path,B,...J.target==="openapi-3.0"?[W.items.length]:[]]}):null;if(J.target==="draft-2020-12"){if(Y.prefixItems=q,U)Y.items=U}else if(J.target==="openapi-3.0"){if(Y.items={anyOf:q},U)Y.items.anyOf.push(U);if(Y.minItems=q.length,!U)Y.maxItems=q.length}else if(Y.items=q,U)Y.additionalItems=U;let{minimum:G,maximum:H}=$._zod.bag;if(typeof G==="number")Y.minItems=G;if(typeof H==="number")Y.maxItems=H},uY=($,J,Q,X)=>{let Y=Q,W=$._zod.def;Y.type="object";let K=W.keyType,q=K._zod.bag?.patterns;if(W.mode==="loose"&&q&&q.size>0){let G=n(W.valueType,J,{...X,path:[...X.path,"patternProperties","*"]});Y.patternProperties={};for(let H of q)Y.patternProperties[H.source]=G}else{if(J.target==="draft-07"||J.target==="draft-2020-12")Y.propertyNames=n(W.keyType,J,{...X,path:[...X.path,"propertyNames"]});Y.additionalProperties=n(W.valueType,J,{...X,path:[...X.path,"additionalProperties"]})}let U=K._zod.values;if(U){let G=[...U].filter((H)=>typeof H==="string"||typeof H==="number");if(G.length>0)Y.required=G}},mY=($,J,Q,X)=>{let Y=$._zod.def,W=n(Y.innerType,J,X),K=J.seen.get($);if(J.target==="openapi-3.0")K.ref=Y.innerType,Q.nullable=!0;else Q.anyOf=[W,{type:"null"}]},lY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType},pY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType,Q.default=JSON.parse(JSON.stringify(Y.defaultValue))},cY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);if(W.ref=Y.innerType,J.io==="input")Q._prefault=JSON.parse(JSON.stringify(Y.defaultValue))},dY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType;let K;try{K=Y.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}Q.default=K},rY=($,J,Q,X)=>{let Y=$._zod.def,W=J.io==="input"?Y.in._zod.def.type==="transform"?Y.out:Y.in:Y.out;n(W,J,X);let K=J.seen.get($);K.ref=W},iY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType,Q.readOnly=!0},oY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType},L8=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType},nY=($,J,Q,X)=>{let Y=$._zod.innerType;n(Y,J,X);let W=J.seen.get($);W.ref=Y},H8={string:LY,number:OY,boolean:MY,bigint:NY,symbol:FY,null:VY,undefined:_Y,void:DY,never:zY,any:IY,unknown:jY,date:RY,enum:bY,literal:PY,nan:AY,template_literal:EY,file:SY,success:CY,custom:TY,function:wY,transform:vY,map:fY,set:hY,array:kY,object:gY,union:Z8,intersection:yY,tuple:xY,record:uY,nullable:mY,nonoptional:lY,default:pY,prefault:cY,catch:dY,pipe:rY,readonly:iY,promise:oY,optional:L8,lazy:nY};function a3($,J){if("_idmap"in $){let X=$,Y=h4({...J,processors:H8}),W={};for(let q of X._idmap.entries()){let[U,G]=q;n(G,Y)}let K={},B={registry:X,uri:J?.uri,defs:W};Y.external=B;for(let q of X._idmap.entries()){let[U,G]=q;k4(Y,G),K[U]=g4(Y,G)}if(Object.keys(W).length>0){let q=Y.target==="draft-2020-12"?"$defs":"definitions";K.__shared={[q]:W}}return{schemas:K}}let Q=h4({...J,processors:H8});return n($,Q),k4(Q,$),g4(Q,$)}class sY{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter($){this.ctx.counter=$}get seen(){return this.ctx.seen}constructor($){let J=$?.target??"draft-2020-12";if(J==="draft-4")J="draft-04";if(J==="draft-7")J="draft-07";this.ctx=h4({processors:H8,target:J,...$?.metadata&&{metadata:$.metadata},...$?.unrepresentable&&{unrepresentable:$.unrepresentable},...$?.override&&{override:$.override},...$?.io&&{io:$.io}})}process($,J={path:[],schemaPath:[]}){return n($,this.ctx,J)}emit($,J){if(J){if(J.cycles)this.ctx.cycles=J.cycles;if(J.reused)this.ctx.reused=J.reused;if(J.external)this.ctx.external=J.external}k4(this.ctx,$);let Q=g4(this.ctx,$),{"~standard":X,...Y}=Q;return Y}}var fH={};var Q6={};B2(Q6,{time:()=>eY,duration:()=>$W,datetime:()=>aY,date:()=>tY,ZodISOTime:()=>$6,ZodISODuration:()=>J6,ZodISODateTime:()=>t3,ZodISODate:()=>e3});var t3=N("ZodISODateTime",($,J)=>{SX.init($,J),r.init($,J)});function aY($){return T5(t3,$)}var e3=N("ZodISODate",($,J)=>{CX.init($,J),r.init($,J)});function tY($){return w5(e3,$)}var $6=N("ZodISOTime",($,J)=>{TX.init($,J),r.init($,J)});function eY($){return v5($6,$)}var J6=N("ZodISODuration",($,J)=>{wX.init($,J),r.init($,J)});function $W($){return f5(J6,$)}var kH=($,J)=>{u3.init($,J),$.name="ZodError",Object.defineProperties($,{format:{value:(Q)=>M4($,Q)},flatten:{value:(Q)=>O4($,Q)},addIssue:{value:(Q)=>{$.issues.push(Q),$.message=JSON.stringify($.issues,H4,2)}},addIssues:{value:(Q)=>{$.issues.push(...Q),$.message=JSON.stringify($.issues,H4,2)}},isEmpty:{get(){return $.issues.length===0}}})},gH=N("ZodError",kH),z1=N("ZodError",kH,{Parent:Error});var O8=N4(z1),M8=F4(z1),N8=V4(z1),F8=_4(z1),V8=M$(z1),_8=N$(z1),D8=F$(z1),z8=V$(z1),I8=_$(z1),j8=D$(z1),R8=z$(z1),b8=I$(z1);var g=N("ZodType",($,J)=>{return v.init($,J),Object.assign($["~standard"],{jsonSchema:{input:G8($,"input"),output:G8($,"output")}}),$.toJSONSchema=ZY($,{}),$.def=J,$.type=J.type,Object.defineProperty($,"_def",{value:J}),$.check=(...Q)=>{return $.clone(w.mergeDefs(J,{checks:[...J.checks??[],...Q.map((X)=>typeof X==="function"?{_zod:{check:X,def:{check:"custom"},onattach:[]}}:X)]}),{parent:!0})},$.with=$.check,$.clone=(Q,X)=>N1($,Q,X),$.brand=()=>$,$.register=(Q,X)=>{return Q.add($,X),$},$.parse=(Q,X)=>O8($,Q,X,{callee:$.parse}),$.safeParse=(Q,X)=>N8($,Q,X),$.parseAsync=async(Q,X)=>M8($,Q,X,{callee:$.parseAsync}),$.safeParseAsync=async(Q,X)=>F8($,Q,X),$.spa=$.safeParseAsync,$.encode=(Q,X)=>V8($,Q,X),$.decode=(Q,X)=>_8($,Q,X),$.encodeAsync=async(Q,X)=>D8($,Q,X),$.decodeAsync=async(Q,X)=>z8($,Q,X),$.safeEncode=(Q,X)=>I8($,Q,X),$.safeDecode=(Q,X)=>j8($,Q,X),$.safeEncodeAsync=async(Q,X)=>R8($,Q,X),$.safeDecodeAsync=async(Q,X)=>b8($,Q,X),$.refine=(Q,X)=>$.check(cW(Q,X)),$.superRefine=(Q)=>$.check(dW(Q)),$.overwrite=(Q)=>$.check(Q0(Q)),$.optional=()=>Y6($),$.exactOptional=()=>PW($),$.nullable=()=>W6($),$.nullish=()=>Y6(W6($)),$.nonoptional=(Q)=>wW($,Q),$.array=()=>U6($),$.or=(Q)=>i8([$,Q]),$.and=(Q)=>NW($,Q),$.transform=(Q)=>K6($,n8(Q)),$.default=(Q)=>SW($,Q),$.prefault=(Q)=>TW($,Q),$.catch=(Q)=>hW($,Q),$.pipe=(Q)=>K6($,Q),$.readonly=()=>yW($),$.describe=(Q)=>{let X=$.clone();return E1.add(X,{description:Q}),X},Object.defineProperty($,"description",{get(){return E1.get($)?.description},configurable:!0}),$.meta=(...Q)=>{if(Q.length===0)return E1.get($);let X=$.clone();return E1.add(X,Q[0]),X},$.isOptional=()=>$.safeParse(void 0).success,$.isNullable=()=>$.safeParse(null).success,$.apply=(Q)=>Q($),$}),E8=N("_ZodString",($,J)=>{w2.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>LY($,X,Y,W);let Q=$._zod.bag;$.format=Q.format??null,$.minLength=Q.minimum??null,$.maxLength=Q.maximum??null,$.regex=(...X)=>$.check(z4(...X)),$.includes=(...X)=>$.check(R4(...X)),$.startsWith=(...X)=>$.check(b4(...X)),$.endsWith=(...X)=>$.check(P4(...X)),$.min=(...X)=>$.check(g0(...X)),$.max=(...X)=>$.check(f2(...X)),$.length=(...X)=>$.check(h2(...X)),$.nonempty=(...X)=>$.check(g0(1,...X)),$.lowercase=(X)=>$.check(I4(X)),$.uppercase=(X)=>$.check(j4(X)),$.trim=()=>$.check(S4()),$.normalize=(...X)=>$.check(E4(...X)),$.toLowerCase=()=>$.check(C4()),$.toUpperCase=()=>$.check(T4()),$.slugify=()=>$.check(w4())}),x4=N("ZodString",($,J)=>{w2.init($,J),E8.init($,J),$.email=(Q)=>$.check(y$(S8,Q)),$.url=(Q)=>$.check(s3(B6,Q)),$.jwt=(Q)=>$.check(X8(c8,Q)),$.emoji=(Q)=>$.check(p$(C8,Q)),$.guid=(Q)=>$.check(n3(X6,Q)),$.uuid=(Q)=>$.check(x$(I0,Q)),$.uuidv4=(Q)=>$.check(u$(I0,Q)),$.uuidv6=(Q)=>$.check(m$(I0,Q)),$.uuidv7=(Q)=>$.check(l$(I0,Q)),$.nanoid=(Q)=>$.check(c$(T8,Q)),$.guid=(Q)=>$.check(n3(X6,Q)),$.cuid=(Q)=>$.check(d$(w8,Q)),$.cuid2=(Q)=>$.check(r$(v8,Q)),$.ulid=(Q)=>$.check(i$(f8,Q)),$.base64=(Q)=>$.check($8(m8,Q)),$.base64url=(Q)=>$.check(J8(l8,Q)),$.xid=(Q)=>$.check(o$(h8,Q)),$.ksuid=(Q)=>$.check(n$(k8,Q)),$.ipv4=(Q)=>$.check(s$(g8,Q)),$.ipv6=(Q)=>$.check(a$(y8,Q)),$.cidrv4=(Q)=>$.check(t$(x8,Q)),$.cidrv6=(Q)=>$.check(e$(u8,Q)),$.e164=(Q)=>$.check(Q8(p8,Q)),$.datetime=(Q)=>$.check(aY(Q)),$.date=(Q)=>$.check(tY(Q)),$.time=(Q)=>$.check(eY(Q)),$.duration=(Q)=>$.check($W(Q))});function P8($){return E5(x4,$)}var r=N("ZodStringFormat",($,J)=>{d.init($,J),E8.init($,J)}),S8=N("ZodEmail",($,J)=>{DX.init($,J),r.init($,J)});function yH($){return y$(S8,$)}var X6=N("ZodGUID",($,J)=>{VX.init($,J),r.init($,J)});function xH($){return n3(X6,$)}var I0=N("ZodUUID",($,J)=>{_X.init($,J),r.init($,J)});function uH($){return x$(I0,$)}function mH($){return u$(I0,$)}function lH($){return m$(I0,$)}function pH($){return l$(I0,$)}var B6=N("ZodURL",($,J)=>{zX.init($,J),r.init($,J)});function cH($){return s3(B6,$)}function dH($){return s3(B6,{protocol:/^https?$/,hostname:y1.domain,...w.normalizeParams($)})}var C8=N("ZodEmoji",($,J)=>{IX.init($,J),r.init($,J)});function rH($){return p$(C8,$)}var T8=N("ZodNanoID",($,J)=>{jX.init($,J),r.init($,J)});function iH($){return c$(T8,$)}var w8=N("ZodCUID",($,J)=>{RX.init($,J),r.init($,J)});function oH($){return d$(w8,$)}var v8=N("ZodCUID2",($,J)=>{bX.init($,J),r.init($,J)});function nH($){return r$(v8,$)}var f8=N("ZodULID",($,J)=>{PX.init($,J),r.init($,J)});function sH($){return i$(f8,$)}var h8=N("ZodXID",($,J)=>{AX.init($,J),r.init($,J)});function aH($){return o$(h8,$)}var k8=N("ZodKSUID",($,J)=>{EX.init($,J),r.init($,J)});function tH($){return n$(k8,$)}var g8=N("ZodIPv4",($,J)=>{vX.init($,J),r.init($,J)});function eH($){return s$(g8,$)}var JW=N("ZodMAC",($,J)=>{hX.init($,J),r.init($,J)});function $Z($){return C5(JW,$)}var y8=N("ZodIPv6",($,J)=>{fX.init($,J),r.init($,J)});function JZ($){return a$(y8,$)}var x8=N("ZodCIDRv4",($,J)=>{kX.init($,J),r.init($,J)});function QZ($){return t$(x8,$)}var u8=N("ZodCIDRv6",($,J)=>{gX.init($,J),r.init($,J)});function XZ($){return e$(u8,$)}var m8=N("ZodBase64",($,J)=>{xX.init($,J),r.init($,J)});function YZ($){return $8(m8,$)}var l8=N("ZodBase64URL",($,J)=>{uX.init($,J),r.init($,J)});function WZ($){return J8(l8,$)}var p8=N("ZodE164",($,J)=>{mX.init($,J),r.init($,J)});function KZ($){return Q8(p8,$)}var c8=N("ZodJWT",($,J)=>{lX.init($,J),r.init($,J)});function BZ($){return X8(c8,$)}var u4=N("ZodCustomStringFormat",($,J)=>{pX.init($,J),r.init($,J)});function qZ($,J,Q={}){return v4(u4,$,J,Q)}function UZ($){return v4(u4,"hostname",y1.hostname,$)}function GZ($){return v4(u4,"hex",y1.hex,$)}function HZ($,J){let Q=J?.enc??"hex",X=`${$}_${Q}`,Y=y1[X];if(!Y)throw Error(`Unrecognized hash format: ${X}`);return v4(u4,X,Y,J)}var m4=N("ZodNumber",($,J)=>{w$.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>OY($,X,Y,W),$.gt=(X,Y)=>$.check(_0(X,Y)),$.gte=(X,Y)=>$.check(D1(X,Y)),$.min=(X,Y)=>$.check(D1(X,Y)),$.lt=(X,Y)=>$.check(V0(X,Y)),$.lte=(X,Y)=>$.check(x1(X,Y)),$.max=(X,Y)=>$.check(x1(X,Y)),$.int=(X)=>$.check(A8(X)),$.safe=(X)=>$.check(A8(X)),$.positive=(X)=>$.check(_0(0,X)),$.nonnegative=(X)=>$.check(D1(0,X)),$.negative=(X)=>$.check(V0(0,X)),$.nonpositive=(X)=>$.check(x1(0,X)),$.multipleOf=(X,Y)=>$.check(Y2(X,Y)),$.step=(X,Y)=>$.check(Y2(X,Y)),$.finite=()=>$;let Q=$._zod.bag;$.minValue=Math.max(Q.minimum??Number.NEGATIVE_INFINITY,Q.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,$.maxValue=Math.min(Q.maximum??Number.POSITIVE_INFINITY,Q.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,$.isInt=(Q.format??"").includes("int")||Number.isSafeInteger(Q.multipleOf??0.5),$.isFinite=!0,$.format=Q.format??null});function QW($){return h5(m4,$)}var g2=N("ZodNumberFormat",($,J)=>{cX.init($,J),m4.init($,J)});function A8($){return g5(g2,$)}function ZZ($){return y5(g2,$)}function LZ($){return x5(g2,$)}function OZ($){return u5(g2,$)}function MZ($){return m5(g2,$)}var l4=N("ZodBoolean",($,J)=>{c3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>MY($,Q,X,Y)});function XW($){return l5(l4,$)}var p4=N("ZodBigInt",($,J)=>{v$.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>NY($,X,Y,W),$.gte=(X,Y)=>$.check(D1(X,Y)),$.min=(X,Y)=>$.check(D1(X,Y)),$.gt=(X,Y)=>$.check(_0(X,Y)),$.gte=(X,Y)=>$.check(D1(X,Y)),$.min=(X,Y)=>$.check(D1(X,Y)),$.lt=(X,Y)=>$.check(V0(X,Y)),$.lte=(X,Y)=>$.check(x1(X,Y)),$.max=(X,Y)=>$.check(x1(X,Y)),$.positive=(X)=>$.check(_0(BigInt(0),X)),$.negative=(X)=>$.check(V0(BigInt(0),X)),$.nonpositive=(X)=>$.check(x1(BigInt(0),X)),$.nonnegative=(X)=>$.check(D1(BigInt(0),X)),$.multipleOf=(X,Y)=>$.check(Y2(X,Y));let Q=$._zod.bag;$.minValue=Q.minimum??null,$.maxValue=Q.maximum??null,$.format=Q.format??null});function NZ($){return c5(p4,$)}var d8=N("ZodBigIntFormat",($,J)=>{dX.init($,J),p4.init($,J)});function FZ($){return r5(d8,$)}function VZ($){return i5(d8,$)}var YW=N("ZodSymbol",($,J)=>{rX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>FY($,Q,X,Y)});function _Z($){return o5(YW,$)}var WW=N("ZodUndefined",($,J)=>{iX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>_Y($,Q,X,Y)});function DZ($){return n5(WW,$)}var KW=N("ZodNull",($,J)=>{oX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>VY($,Q,X,Y)});function BW($){return s5(KW,$)}var qW=N("ZodAny",($,J)=>{nX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>IY($,Q,X,Y)});function zZ(){return a5(qW)}var UW=N("ZodUnknown",($,J)=>{sX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>jY($,Q,X,Y)});function k2(){return t5(UW)}var GW=N("ZodNever",($,J)=>{aX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>zY($,Q,X,Y)});function r8($){return e5(GW,$)}var HW=N("ZodVoid",($,J)=>{tX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>DY($,Q,X,Y)});function IZ($){return $Y(HW,$)}var q6=N("ZodDate",($,J)=>{eX.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>RY($,X,Y,W),$.min=(X,Y)=>$.check(D1(X,Y)),$.max=(X,Y)=>$.check(x1(X,Y));let Q=$._zod.bag;$.minDate=Q.minimum?new Date(Q.minimum):null,$.maxDate=Q.maximum?new Date(Q.maximum):null});function jZ($){return JY(q6,$)}var ZW=N("ZodArray",($,J)=>{$5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>kY($,Q,X,Y),$.element=J.element,$.min=(Q,X)=>$.check(g0(Q,X)),$.nonempty=(Q)=>$.check(g0(1,Q)),$.max=(Q,X)=>$.check(f2(Q,X)),$.length=(Q,X)=>$.check(h2(Q,X)),$.unwrap=()=>$.element});function U6($,J){return YY(ZW,$,J)}function RZ($){let J=$._zod.def.shape;return o8(Object.keys(J))}var G6=N("ZodObject",($,J)=>{J5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>gY($,Q,X,Y),w.defineLazy($,"shape",()=>{return J.shape}),$.keyof=()=>o8(Object.keys($._zod.def.shape)),$.catchall=(Q)=>$.clone({...$._zod.def,catchall:Q}),$.passthrough=()=>$.clone({...$._zod.def,catchall:k2()}),$.loose=()=>$.clone({...$._zod.def,catchall:k2()}),$.strict=()=>$.clone({...$._zod.def,catchall:r8()}),$.strip=()=>$.clone({...$._zod.def,catchall:void 0}),$.extend=(Q)=>{return w.extend($,Q)},$.safeExtend=(Q)=>{return w.safeExtend($,Q)},$.merge=(Q)=>w.merge($,Q),$.pick=(Q)=>w.pick($,Q),$.omit=(Q)=>w.omit($,Q),$.partial=(...Q)=>w.partial(s8,$,Q[0]),$.required=(...Q)=>w.required(a8,$,Q[0])});function bZ($,J){let Q={type:"object",shape:$??{},...w.normalizeParams(J)};return new G6(Q)}function PZ($,J){return new G6({type:"object",shape:$,catchall:r8(),...w.normalizeParams(J)})}function AZ($,J){return new G6({type:"object",shape:$,catchall:k2(),...w.normalizeParams(J)})}var H6=N("ZodUnion",($,J)=>{d3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>Z8($,Q,X,Y),$.options=J.options});function i8($,J){return new H6({type:"union",options:$,...w.normalizeParams(J)})}var LW=N("ZodXor",($,J)=>{H6.init($,J),Q5.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>Z8($,Q,X,Y),$.options=J.options});function EZ($,J){return new LW({type:"union",options:$,inclusive:!1,...w.normalizeParams(J)})}var OW=N("ZodDiscriminatedUnion",($,J)=>{H6.init($,J),X5.init($,J)});function SZ($,J,Q){return new OW({type:"union",options:J,discriminator:$,...w.normalizeParams(Q)})}var MW=N("ZodIntersection",($,J)=>{Y5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>yY($,Q,X,Y)});function NW($,J){return new MW({type:"intersection",left:$,right:J})}var FW=N("ZodTuple",($,J)=>{f$.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>xY($,Q,X,Y),$.rest=(Q)=>$.clone({...$._zod.def,rest:Q})});function VW($,J,Q){let X=J instanceof v,Y=X?Q:J;return new FW({type:"tuple",items:$,rest:X?J:null,...w.normalizeParams(Y)})}var Z6=N("ZodRecord",($,J)=>{W5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>uY($,Q,X,Y),$.keyType=J.keyType,$.valueType=J.valueType});function _W($,J,Q){return new Z6({type:"record",keyType:$,valueType:J,...w.normalizeParams(Q)})}function CZ($,J,Q){let X=N1($);return X._zod.values=void 0,new Z6({type:"record",keyType:X,valueType:J,...w.normalizeParams(Q)})}function TZ($,J,Q){return new Z6({type:"record",keyType:$,valueType:J,mode:"loose",...w.normalizeParams(Q)})}var DW=N("ZodMap",($,J)=>{K5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>fY($,Q,X,Y),$.keyType=J.keyType,$.valueType=J.valueType,$.min=(...Q)=>$.check(D0(...Q)),$.nonempty=(Q)=>$.check(D0(1,Q)),$.max=(...Q)=>$.check(W2(...Q)),$.size=(...Q)=>$.check(v2(...Q))});function wZ($,J,Q){return new DW({type:"map",keyType:$,valueType:J,...w.normalizeParams(Q)})}var zW=N("ZodSet",($,J)=>{B5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>hY($,Q,X,Y),$.min=(...Q)=>$.check(D0(...Q)),$.nonempty=(Q)=>$.check(D0(1,Q)),$.max=(...Q)=>$.check(W2(...Q)),$.size=(...Q)=>$.check(v2(...Q))});function vZ($,J){return new zW({type:"set",valueType:$,...w.normalizeParams(J)})}var y4=N("ZodEnum",($,J)=>{q5.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>bY($,X,Y,W),$.enum=J.entries,$.options=Object.values(J.entries);let Q=new Set(Object.keys(J.entries));$.extract=(X,Y)=>{let W={};for(let K of X)if(Q.has(K))W[K]=J.entries[K];else throw Error(`Key ${K} not found in enum`);return new y4({...J,checks:[],...w.normalizeParams(Y),entries:W})},$.exclude=(X,Y)=>{let W={...J.entries};for(let K of X)if(Q.has(K))delete W[K];else throw Error(`Key ${K} not found in enum`);return new y4({...J,checks:[],...w.normalizeParams(Y),entries:W})}});function o8($,J){let Q=Array.isArray($)?Object.fromEntries($.map((X)=>[X,X])):$;return new y4({type:"enum",entries:Q,...w.normalizeParams(J)})}function fZ($,J){return new y4({type:"enum",entries:$,...w.normalizeParams(J)})}var IW=N("ZodLiteral",($,J)=>{U5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>PY($,Q,X,Y),$.values=new Set(J.values),Object.defineProperty($,"value",{get(){if(J.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return J.values[0]}})});function hZ($,J){return new IW({type:"literal",values:Array.isArray($)?$:[$],...w.normalizeParams(J)})}var jW=N("ZodFile",($,J)=>{G5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>SY($,Q,X,Y),$.min=(Q,X)=>$.check(D0(Q,X)),$.max=(Q,X)=>$.check(W2(Q,X)),$.mime=(Q,X)=>$.check(A4(Array.isArray(Q)?Q:[Q],X))});function kZ($){return WY(jW,$)}var RW=N("ZodTransform",($,J)=>{H5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>vY($,Q,X,Y),$._zod.parse=(Q,X)=>{if(X.direction==="backward")throw new S2($.constructor.name);Q.addIssue=(W)=>{if(typeof W==="string")Q.issues.push(w.issue(W,Q.value,J));else{let K=W;if(K.fatal)K.continue=!1;K.code??(K.code="custom"),K.input??(K.input=Q.value),K.inst??(K.inst=$),Q.issues.push(w.issue(K))}};let Y=J.transform(Q.value,Q);if(Y instanceof Promise)return Y.then((W)=>{return Q.value=W,Q});return Q.value=Y,Q}});function n8($){return new RW({type:"transform",transform:$})}var s8=N("ZodOptional",($,J)=>{h$.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>L8($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function Y6($){return new s8({type:"optional",innerType:$})}var bW=N("ZodExactOptional",($,J)=>{Z5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>L8($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function PW($){return new bW({type:"optional",innerType:$})}var AW=N("ZodNullable",($,J)=>{L5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>mY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function W6($){return new AW({type:"nullable",innerType:$})}function gZ($){return Y6(W6($))}var EW=N("ZodDefault",($,J)=>{O5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>pY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function SW($,J){return new EW({type:"default",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var CW=N("ZodPrefault",($,J)=>{M5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>cY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function TW($,J){return new CW({type:"prefault",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var a8=N("ZodNonOptional",($,J)=>{N5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>lY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function wW($,J){return new a8({type:"nonoptional",innerType:$,...w.normalizeParams(J)})}var vW=N("ZodSuccess",($,J)=>{F5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>CY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function yZ($){return new vW({type:"success",innerType:$})}var fW=N("ZodCatch",($,J)=>{V5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>dY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType,$.removeCatch=$.unwrap});function hW($,J){return new fW({type:"catch",innerType:$,catchValue:typeof J==="function"?J:()=>J})}var kW=N("ZodNaN",($,J)=>{_5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>AY($,Q,X,Y)});function xZ($){return XY(kW,$)}var t8=N("ZodPipe",($,J)=>{D5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>rY($,Q,X,Y),$.in=J.in,$.out=J.out});function K6($,J){return new t8({type:"pipe",in:$,out:J})}var e8=N("ZodCodec",($,J)=>{t8.init($,J),r3.init($,J)});function uZ($,J,Q){return new e8({type:"pipe",in:$,out:J,transform:Q.decode,reverseTransform:Q.encode})}var gW=N("ZodReadonly",($,J)=>{z5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>iY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function yW($){return new gW({type:"readonly",innerType:$})}var xW=N("ZodTemplateLiteral",($,J)=>{I5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>EY($,Q,X,Y)});function mZ($,J){return new xW({type:"template_literal",parts:$,...w.normalizeParams(J)})}var uW=N("ZodLazy",($,J)=>{b5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>nY($,Q,X,Y),$.unwrap=()=>$._zod.def.getter()});function mW($){return new uW({type:"lazy",getter:$})}var lW=N("ZodPromise",($,J)=>{R5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>oY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function lZ($){return new lW({type:"promise",innerType:$})}var pW=N("ZodFunction",($,J)=>{j5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>wY($,Q,X,Y)});function pZ($){return new pW({type:"function",input:Array.isArray($?.input)?VW($?.input):$?.input??U6(k2()),output:$?.output??k2()})}var L6=N("ZodCustom",($,J)=>{P5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>TY($,Q,X,Y)});function cZ($){let J=new o({check:"custom"});return J._zod.check=$,J}function dZ($,J){return KY(L6,$??(()=>!0),J)}function cW($,J={}){return BY(L6,$,J)}function dW($){return qY($)}var rZ=UY,iZ=GY;function oZ($,J={}){let Q=new L6({type:"custom",check:"custom",fn:(X)=>X instanceof $,abort:!0,...w.normalizeParams(J)});return Q._zod.bag.Class=$,Q._zod.check=(X)=>{if(!(X.value instanceof $))X.issues.push({code:"invalid_type",expected:$.name,input:X.value,inst:Q,path:[...Q._zod.def.path??[]]})},Q}var nZ=(...$)=>HY({Codec:e8,Boolean:l4,String:x4},...$);function sZ($){let J=mW(()=>{return i8([P8($),QW(),XW(),BW(),U6(J),_W(P8(),J)])});return J}function aZ($,J){return K6(n8($),J)}var tZ={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function eZ($){Y1({customError:$})}function $L(){return Y1().customError}var $J;(function($){})($J||($J={}));var ib=()=>{let $={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function J(Y){return $[Y]??null}let Q={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},X={nan:"NaN"};return(Y)=>{switch(Y.code){case"invalid_type":{let W=X[Y.expected]??Y.expected,K=z7(Y.input),B=X[K]??K;return`Invalid input: expected ${W}, received ${B}`}case"invalid_value":if(Y.values.length===1)return`Invalid input: expected ${G$(Y.values[0])}`;return`Invalid option: expected one of ${B$(Y.values,"|")}`;case"too_big":{let W=Y.inclusive?"<=":"<",K=J(Y.origin);if(K)return`Too big: expected ${Y.origin??"value"} to have ${W}${Y.maximum.toString()} ${K.unit??"elements"}`;return`Too big: expected ${Y.origin??"value"} to be ${W}${Y.maximum.toString()}`}case"too_small":{let W=Y.inclusive?">=":">",K=J(Y.origin);if(K)return`Too small: expected ${Y.origin} to have ${W}${Y.minimum.toString()} ${K.unit}`;return`Too small: expected ${Y.origin} to be ${W}${Y.minimum.toString()}`}case"invalid_format":{let W=Y;if(W.format==="starts_with")return`Invalid string: must start with "${W.prefix}"`;if(W.format==="ends_with")return`Invalid string: must end with "${W.suffix}"`;if(W.format==="includes")return`Invalid string: must include "${W.includes}"`;if(W.format==="regex")return`Invalid string: must match pattern ${W.pattern}`;return`Invalid ${Q[W.format]??Y.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${Y.divisor}`;case"unrecognized_keys":return`Unrecognized key${Y.keys.length>1?"s":""}: ${B$(Y.keys,", ")}`;case"invalid_key":return`Invalid key in ${Y.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${Y.origin}`;default:return"Invalid input"}}};function rW(){return{localeError:ib()}}var iW=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")};var JJ={};B2(JJ,{string:()=>ob,number:()=>nb,date:()=>tb,boolean:()=>sb,bigint:()=>ab});function ob($){return S5(x4,$)}function nb($){return k5(m4,$)}function sb($){return p5(l4,$)}function ab($){return d5(p4,$)}function tb($){return QY(q6,$)}Y1(rW());var eb=QJ;var JL=Object.freeze(["hard_stop","use_alternative","scope_down","manual_only","stop_and_explain"]);var O6=64,QL="Rule config exceeds CC Safety Net's safe source limit.";var nh=Object.freeze({maxSources:64,concurrency:4,maxRequests:131,maxResponseBytes:67108864});var nW=[{id:"secret.basename.env",category:"Basename",label:".env",description:"Blocks exact .env files.",basename:".env"},{id:"secret.basename.npmrc",category:"Basename",label:".npmrc",description:"Blocks npm credential config files.",basename:".npmrc"},{id:"secret.basename.pypirc",category:"Basename",label:".pypirc",description:"Blocks Python package index credential files.",basename:".pypirc"},{id:"secret.basename.netrc",category:"Basename",label:".netrc",description:"Blocks machine login credential files.",basename:".netrc"},{id:"secret.basename.git-credentials",category:"Basename",label:".git-credentials",description:"Blocks Git credential storage files.",basename:".git-credentials"},{id:"secret.basename.id-rsa",category:"Basename",label:"id_rsa",description:"Blocks RSA private key basenames.",basename:"id_rsa"},{id:"secret.basename.id-ed25519",category:"Basename",label:"id_ed25519",description:"Blocks Ed25519 private key basenames.",basename:"id_ed25519"},{id:"secret.basename.id-ecdsa",category:"Basename",label:"id_ecdsa",description:"Blocks ECDSA private key basenames.",basename:"id_ecdsa"},{id:"secret.basename.credentials",category:"Basename",label:"credentials",description:"Blocks generic credentials file basenames.",basename:"credentials"}],XJ={id:"secret.pattern.env-variant",category:"Pattern",label:".env.*",description:"Blocks environment-specific .env variants."},$P=[".bak",".backup",".copy",".disabled",".old",".orig",".save",".tmp"],JP=[{idSlug:"kube-config",label:"~/.kube/config",directoryParts:[".kube"],basename:"config"},{idSlug:"docker-config",label:"~/.docker/config.json",directoryParts:[".docker"],basename:"config.json"}],sW=[{id:"secret.home.ssh",category:"Home path",label:"~/.ssh",description:"Blocks home SSH configuration and key paths.",suffixParts:[".ssh"]},{id:"secret.home.aws",category:"Home path",label:"~/.aws",description:"Blocks home AWS credential and config paths.",suffixParts:[".aws"]},{id:"secret.home.gcp",category:"Home path",label:"~/.gcp",description:"Blocks home GCP credential paths.",suffixParts:[".gcp"]},{id:"secret.home.gcloud-config",category:"Home path",label:"~/.config/gcloud",description:"Blocks home Google Cloud SDK credential paths.",suffixParts:[".config","gcloud"]},{id:"secret.home.kube-config",category:"Home path",label:"~/.kube/config",description:"Blocks home Kubernetes config files.",suffixParts:[".kube","config"]},{id:"secret.home.docker-config",category:"Home path",label:"~/.docker/config.json",description:"Blocks home Docker credential config files.",suffixParts:[".docker","config.json"]},...JP.flatMap(($)=>$P.map((J)=>({id:["secret.home",$.idSlug,J.slice(1)].join("."),category:"Home path",label:[$.label,J].join(""),description:["Blocks home ",$.label,J," credential backup files."].join(""),suffixParts:[...$.directoryParts,[$.basename,J].join("")]}))),{id:"secret.home.gh-hosts",category:"Home path",label:"~/.config/gh/hosts.yml",description:"Blocks GitHub CLI host credential files.",suffixParts:[".config","gh","hosts.yml"]}];var YJ=[{id:"secret.cli.claude-code",category:"Coding CLI credential",label:"Claude Code credentials",paths:["~/.claude/.credentials.json"]},{id:"secret.cli.claude-code.config",category:"Coding CLI config",label:"Claude Code config",paths:["~/.claude/settings.json","~/.claude/settings.local.json","~/.claude.json","<project>/.claude/settings.local.json","<project>/.mcp.json"]},{id:"secret.cli.antigravity",category:"Coding CLI config",label:"Antigravity CLI hook config",paths:["~/.gemini/config/hooks.json","~/.gemini/config/mcp_config.json"]},{id:"secret.cli.codex",category:"Coding CLI credential",label:"Codex credentials",paths:["~/.codex/auth.json","~/.codex/.credentials.json","~/.codex/secrets","~/.codex/.sandbox-secrets"]},{id:"secret.cli.codex.config",category:"Coding CLI config",label:"Codex config",paths:["~/.codex/config.toml","~/.codex/<name>.config.toml"]},{id:"secret.cli.gemini",category:"Coding CLI credential",label:"Gemini CLI credentials",paths:["~/.gemini/oauth_creds.json","~/.gemini/mcp-oauth-tokens.json","~/.gemini/a2a-oauth-tokens.json","~/.gemini/gemini-credentials.json"]},{id:"secret.cli.gemini.config",category:"Coding CLI config",label:"Gemini CLI config",paths:["~/.gemini/settings.json","~/.gemini/google_accounts.json","<project>/.gemini/settings.json","/Library/Application Support/GeminiCli/settings.json","/etc/gemini-cli/settings.json"]},{id:"secret.cli.copilot-cli",category:"Coding CLI credential",label:"GitHub Copilot CLI credentials",paths:["~/.copilot/config.json","~/.copilot/mcp-oauth-config","~/.copilot/mcp-secrets"]},{id:"secret.cli.copilot-cli.config",category:"Coding CLI config",label:"GitHub Copilot CLI config",paths:["~/.copilot/mcp-config.json"]},{id:"secret.cli.kimi-code",category:"Coding CLI credential",label:"Kimi Code credentials",paths:["~/.kimi-code/server.token","~/.kimi-code/credentials","~/.kimi/credentials","~/.kimi/mcp-oauth"]},{id:"secret.cli.kimi-code.config",category:"Coding CLI config",label:"Kimi Code config",paths:["~/.kimi-code/config.toml","~/.kimi-code/mcp.json","~/.kimi/config.toml","~/.kimi/config.json","~/.kimi/config.json.bak","~/.kimi/mcp.json","<project>/.kimi-code/mcp.json"]},{id:"secret.cli.opencode",category:"Coding CLI credential",label:"OpenCode credentials",paths:["~/.local/share/opencode/auth.json","~/.local/share/opencode/mcp-auth.json","~/.local/share/opencode/opencode.db"]},{id:"secret.cli.opencode.config",category:"Coding CLI config",label:"OpenCode config",paths:["~/.config/opencode/opencode.json","~/.config/opencode/opencode.jsonc","/Library/Application Support/opencode/opencode.json","/etc/opencode/opencode.json","<project>/opencode.json","<project>/opencode.jsonc"]},{id:"secret.cli.pi",category:"Coding CLI credential",label:"Pi credentials",paths:["~/.pi/agent/auth.json"]},{id:"secret.cli.pi.config",category:"Coding CLI config",label:"Pi config",paths:["~/.pi/agent/models.json"]},{id:"secret.cli.amp",category:"Coding CLI credential",label:"Amp Code credentials",paths:["~/.local/share/amp/secrets.json","~/.amp/oauth"]},{id:"secret.cli.amp.config",category:"Coding CLI config",label:"Amp Code config",paths:["~/.config/amp/settings.json","~/.config/amp/settings.jsonc","<project>/.amp/settings.json","<project>/.amp/settings.jsonc"]},{id:"secret.cli.cursor",category:"Coding CLI credential",label:"Cursor CLI credentials",paths:["~/.cursor/auth.json","~/.config/cursor/auth.json","~/.cursor/projects/<name>/mcp-auth.json"]},{id:"secret.cli.cursor.config",category:"Coding CLI config",label:"Cursor CLI config",paths:["~/.cursor/mcp.json","<project>/.cursor/mcp.json"]}],XL=[{prefix:"id_rsa",slug:"id-rsa",label:"id_rsa"},{prefix:"id_dsa",slug:"id-dsa",label:"id_dsa"},{prefix:"id_ed25519",slug:"id-ed25519",label:"id_ed25519"},{prefix:"id_ecdsa",slug:"id-ecdsa",label:"id_ecdsa"},{prefix:"credentials",slug:"credentials",label:"credentials"}],QP=[".bak",".backup",".copy",".disabled",".key",".old",".orig",".pem",".save",".tmp"],aW=XL.map(($)=>({id:`secret.variant.${$.slug}.separator`,category:"Variant",label:`${$.label}-* / ${$.label}_*`,description:`Blocks ${$.label} variants with dash or underscore suffixes.`,prefix:$.prefix})),tW=XL.flatMap(($)=>QP.map((J)=>({id:`secret.variant.${$.slug}.${J.slice(1)}`,category:"Variant",label:`${$.label}${J}`,description:`Blocks ${$.label}${J} private credential variants.`,prefix:$.prefix,suffix:J}))),M6={id:"secret.pattern.ssh-key-basename",category:"Pattern",label:"*_(rsa|dsa|ed25519|ecdsa)",description:"Blocks extensionless SSH private key-like basenames.",pattern:/^.*_(rsa|dsa|ed25519|ecdsa)$/},eW=["agilekeychain","asc","bek","cscfg","fve","gnucash","jks","keychain","kwallet","mdf","ovpn","p12","pcap","pem","pfx","pkcs12","psafe3","rdp","sdf","tblk","tpm"].map(($)=>({id:`secret.ext.${$}`,category:"Extension",label:`.${$}`,description:`Blocks files with the .${$} extension.`,extension:$})),$K=[{id:"secret.ext-pattern.key",category:"Extension pattern",label:".key / .keypair",description:"Blocks key and keypair extension patterns.",pattern:/^key(pair)?$/},{id:"secret.ext-pattern.keystore",category:"Extension pattern",label:".keystore / .keyring",description:"Blocks keystore and keyring extension patterns.",pattern:/^key(store|ring)$/},{id:"secret.ext-pattern.kdbx",category:"Extension pattern",label:".kdb / .kdbx",description:"Blocks KeePass database extension patterns.",pattern:/^kdbx?$/}],YL=[...nW,XJ,...sW,...aW,...tW,M6,...eW,...$K,...YJ].map(($)=>({id:$.id,category:$.category,label:$.label,...$.category==="Coding CLI config"?{defaultOff:!0}:{},..."paths"in $?{paths:$.paths}:{description:$.description}})),WL=new Set(YJ.flatMap(($)=>$.category==="Coding CLI config"?[$.id]:[])),XP=YL.map(($)=>$.id),WJ=new Set(XP);var Uk=YP(import.meta.url),KL,WP=Array(O6+1).fill("over-limit"),BL=/^[^/]+\/[^/]+$/,KP=/^sha256:[a-f0-9]{64}$/,KJ=`must be an integer between ${HJ} and ${ZJ}`,BP=["version","rules","overrides","transparent_wrappers"],qP=["version","safety","workflow","destructive_command_protection","secret_protection","audit"];function qL($){if(!i1($)||!Array.isArray($.rules)||$.rules.length<=O6)return $;return{$schema:$.$schema,version:$.version,rules:WP,overrides:$.overrides,transparent_wrappers:$.transparent_wrappers}}function UP(){let $=oW,J=(_)=>{let R=$.superRefine(_);return R._zod.def.when=()=>!0,R},Q=$.enum(JL),X=$.union([$.literal("off"),$.looseObject({reason:$.string({error:"required non-empty string"}).min(1,"required non-empty string").max(o2,`must be at most ${o2} characters`).describe("Replacement block reason"),intent:Q.optional()})],{error:'must be "off" or an object'}).describe("Disable a rule or replace its block reason and intent."),Y=$.string({error:"must be a rulebook source string"}).min(1,"must be a non-empty rulebook source string"),W=$.string({error:"must be a command string"}).regex(O2,"must match command pattern").describe("Command name such as 'git', 'docker', or 'rtk'."),K=$.looseObject({$schema:$.unknown().optional().describe("JSON Schema reference for IDE support"),version:$.literal(1).describe("Schema version (must be 1)"),rules:$.array(Y,{error:"must be an array of rulebook source strings"}).max(O6,QL).default([]).describe("Rulebook source strings such as project-rules or owner/repo#main/team-rules"),overrides:$.record($.string().meta({pattern:BL.source}),X).default({}).describe("Rule overrides by id"),transparent_wrappers:$.array(W,{error:"must be an array of command strings"}).default([]).describe("Commands that transparently execute a visible protected child command")}),B=(_,R)=>{if(!i1(_))return;if(Array.isArray(_.rules)&&_.rules.length<=O6){let S=new Set;_.rules.forEach((T,y)=>{if(typeof T!=="string"||T==="")return;if(T.trim()===""){R.addIssue({code:"custom",message:"must be a non-empty rulebook source string",path:["rules",y]});return}let x=o4(T);if(x){R.addIssue({code:"custom",message:x,path:["rules",y]});return}if(S.has(T)){R.addIssue({code:"custom",message:`duplicate rulebook source "${T}"`,path:["rules",y]});return}S.add(T)})}if(i1(_.overrides))for(let S of Object.keys(_.overrides)){if(BL.test(S))continue;R.addIssue({code:"custom",message:"must use <rulebook-name>/<rule-name>",path:["overrides",S]})}if(!Array.isArray(_.transparent_wrappers))return;let P=new Set;_.transparent_wrappers.forEach((S,T)=>{if(typeof S!=="string"||!O2.test(S))return;if(P.has(S)){R.addIssue({code:"custom",message:`duplicate command "${S}"`,path:["transparent_wrappers",T]});return}if(LU(S)){R.addIssue({code:"custom",message:`reserved command "${S}" cannot be a wrapper`,path:["transparent_wrappers",T]});return}P.add(S)})},q=$.preprocess(qL,K.check($.superRefine(B))),U=$.preprocess(qL,K.check(J(B))),G=$.strictObject({fail_closed:$.boolean().optional(),paranoid_rm:$.boolean().optional(),paranoid_interpreters:$.boolean().optional()}),H=(_,R)=>$.intersection($.record($.string().refine((P)=>_.has(P),{error:(P)=>`unknown ${R} rule id "${String(P.input)}"`}),$.unknown()),$.record($.string(),$.enum(["on","off"]))),L=(_)=>$.array($.string({error:"must be a non-empty path string"}),{error:"must be an array of paths"}).check(J((R,P)=>{if(!Array.isArray(R))return;let S=c2();R.forEach((T,y)=>{if(typeof T!=="string")return;let x=_(T,S);if(x)P.addIssue({code:"custom",message:x,path:[y]})})})),Z=$.strictObject({version:$.literal(1),safety:$.strictObject({level:$.enum(["standard","strict","paranoid"]).optional(),overrides:G.optional()}).optional(),workflow:$.strictObject({worktree_mode:$.boolean().optional()}).optional(),destructive_command_protection:$.strictObject({enabled:$.boolean().optional(),overrides:H(i6,"destructive command").optional(),allow_paths:L(C9).optional()}).optional(),secret_protection:$.strictObject({enabled:$.boolean().optional(),overrides:H(WJ,"secret protection").optional(),deny_paths:L(T9).optional()}).optional(),audit:$.strictObject({retention_days:$.number({error:KJ}).int(KJ).min(HJ,KJ).max(ZJ,KJ).optional().describe("Days of audit log history to keep before the sweep deletes it")}).optional()}),O=(_)=>{let R=(y,x)=>_==="legacy"?y:x,P=R("must match pattern (letters, numbers, hyphens, underscores)","must match command pattern"),S=`required non-empty string up to ${o2} characters`,T=$.looseObject({name:$.string({error:"required string"}).regex(Y0,R("must match pattern (letters, numbers, hyphens, underscores; max 64 chars)","must match rule name pattern")),command:$.string({error:R("required string","required string matching command pattern")}).regex(O2,R(P,"required string matching command pattern")),subcommand:$.string({error:R("must be a string if provided","must match command pattern")}).regex(O2,P).optional(),block_args:$.array($.string({error:R("must be a string","must be a non-empty string")}).refine((y)=>y!=="",{error:R("must not be empty","must be a non-empty string")}),{error:R("required array","required non-empty array")}).refine((y)=>y.length>0,{error:R("must have at least one element","required non-empty array")}),reason:$.string({error:R("required string",S)}).refine((y)=>y!=="",{error:R("must not be empty",S)}).refine((y)=>y.length<=o2,{error:R(`must be at most ${o2} characters`,S)}),intent:Q.optional()},{error:"must be an object"});return $.array(T,{error:R("must be an array","required array")}).check(J((y,x)=>{if(!Array.isArray(y))return;let c=new Set;y.forEach((V1,C)=>{let m=i1(V1)?V1.name:void 0;if(typeof m!=="string")return;if(c.has(m.toLowerCase())){x.addIssue({code:"custom",message:`duplicate rule name "${m}"`,path:[C,"name"]});return}c.add(m.toLowerCase())})}))},M=$.looseObject({version:$.literal(1),rules:O("legacy").optional()}),V="required string matching rule name pattern",F=$.looseObject({command:$.string({error:"required non-empty string"}).refine((_)=>_.trim()!=="",{error:"required non-empty string"}),expect:$.enum(["blocked","allowed"]),rule:$.string({error:"must be a string if provided"}).optional()},{error:"must be an object"}).check(J((_,R)=>{if(!i1(_))return;if(_.expect!=="blocked"||typeof _.rule==="string")return;R.addIssue({code:"custom",message:"required string for blocked fixtures",path:["rule"]})})),b=$.looseObject({name:$.string({error:"required string matching rule name pattern"}).regex(Y0,"required string matching rule name pattern"),version:$.string({error:"required non-empty string"}).refine((_)=>_!=="",{error:"required non-empty string"}),allowed_commands:$.array($.string({error:"must match command pattern"}).regex(O2,"must match command pattern"),{error:"required array"}).check(J((_,R)=>{if(!Array.isArray(_))return;let P=new Set;_.forEach((S,T)=>{if(typeof S!=="string"||!O2.test(S))return;if(P.has(S)){R.addIssue({code:"custom",message:`duplicate command "${S}"`,path:[T]});return}P.add(S)})})),rules:O("rulebook"),tests:$.array(F,{error:"must be an array if provided"}).optional()}).check(J((_,R)=>{if(!i1(_))return;let P=new Set(JK(_));if(Array.isArray(_.tests)){let T=new Set(_.tests.flatMap((y)=>i1(y)&&y.expect==="blocked"&&typeof y.rule==="string"?[y.rule]:[]));for(let y of T){if(P.has(y))continue;R.addIssue({code:"custom",message:`blocked fixture references unknown rule "${y}"`,path:["tests"]})}}if(!Array.isArray(_.allowed_commands)||!Array.isArray(_.rules))return;let S=new Set(_.allowed_commands.filter((T)=>typeof T==="string"));_.rules.forEach((T,y)=>{let x=i1(T)?T.command:void 0;if(typeof x!=="string"||S.has(x))return;R.addIssue({code:"custom",message:`"${x}" must be listed in allowed_commands`,path:["rules",y,"command"]})})})),I=$.string({error:"required string"}).refine((_)=>_.trim()!=="",{error:"required string"}),A=$.looseObject({spec:I,name:I,version:I,digest:$.string({error:"required sha256 digest"}).regex(KP,"required sha256 digest")},{error:"must be an object"}),E=$.looseObject({rulebooks:$.array($.intersection(A,$.discriminatedUnion("kind",[$.object({kind:$.literal("local-directory"),path:I}),$.object({kind:$.literal("github"),owner:I,repo:I,ref:I,commit:I,path:I,display_ref:$.unknown().optional()})],{error:(_)=>{if(!i1(_.input))return"must be an object";let R=_.input.kind;return typeof R==="string"?`unknown kind "${R}"`:"required string"}})))});return{RulesConfigSchema:q,RulesConfigDiagnosticSchema:U,RuleOverrideSchema:X,UserPolicySchema:Z,LegacyConfigSchema:M,RulebookSchema:b,RulesLockfileSchema:E}}function N6(){return KL??=UP(),KL}function UL(){return N6().RulesConfigSchema}function GP(){return N6().UserPolicySchema}function GL(){return N6().RulebookSchema}function HL(){return N6().RulesLockfileSchema}function JK($){let J=i1($)?$.rules:void 0;return(Array.isArray(J)?J:[]).flatMap((Q)=>{let X=i1(Q)?Q.name:void 0;return typeof X==="string"?[X]:[]})}function ZL($){let J=N6().RulesConfigDiagnosticSchema.safeParse($);if(J.success)return{errors:[],sources:new Set(J.data.rules)};return{errors:c4(ML(J.error.issues,BP)),sources:OP($,J.error.issues)}}function LL($){let J=GP().safeParse($);if(J.success)return[];return c4(ML(J.error.issues,qP)," ")}function c4($,J=": ",Q=" "){return[...new Set($.flatMap((X)=>OL(X,J,Q,[])))]}function OL($,J,Q,X){let Y=[...X,...$.path],W=LP(Y);if($.code==="unrecognized_keys")return $.keys.map((K)=>`${W?`${W}.`:""}unknown field "${K}"`);if($.code==="invalid_key")return $.issues.map((K)=>K.message);if($.code==="invalid_union"){let K=$.errors.flat().filter((B)=>B.path.length>0);if(K.length>0)return K.flatMap((B)=>OL(B,J,Q,Y))}if(Y.length===0)return[$.code==="invalid_type"?"Config must be an object":$.message];if(Y.length===1&&($.code==="too_big"||$.code==="too_small")&&$.origin==="array")return[$.message];return[`${W}${Y.length===1?Q:J}${HP($)}`]}function HP($){if($.code==="invalid_value")return`must be ${ZP($.values)}`;if($.code!=="invalid_type"||!$.message.startsWith("Invalid input:"))return $.message;if($.expected==="object"||$.expected==="record")return"must be an object if provided";return $.expected==="boolean"?"must be a boolean":$.message}function ZP($){if($.length>3)return`one of ${$.join(", ")}`;let J=$.map((Q)=>typeof Q==="string"?`"${Q}"`:String(Q));if(J.length<2)return`${J[0]}`;return`${J.slice(0,-1).join(", ")}${J.length>2?",":""} or ${J.at(-1)}`}function LP($){return $.map((J,Q)=>{if(typeof J==="number")return`[${J}]`;return Q===0?String(J):`.${String(J)}`}).join("")}function ML($,J){let Q=$.map((W)=>W.path[1]),X=[...new Set(Q.filter((W)=>typeof W==="string"))],Y=(W,K)=>[W.path.length===0?-1:J.indexOf(String(W.path[0])),typeof K==="number"?K:X.indexOf(String(K)),W.code==="custom"?0:1];return $.map((W,K)=>({issue:W,rank:Y(W,Q[K])})).sort((W,K)=>W.rank[0]-K.rank[0]||W.rank[1]-K.rank[1]||W.rank[2]-K.rank[2]).map((W)=>W.issue)}function OP($,J){let Q=i1($)?$.rules:void 0;if(!Array.isArray(Q))return new Set;if(J.some((Y)=>Y.path.length===1&&Y.path[0]==="rules"))return new Set;let X=new Set(J.filter((Y)=>Y.path[0]==="rules"&&typeof Y.path[1]==="number").map((Y)=>Y.path[1]));return new Set(Q.filter((Y,W)=>typeof Y==="string"&&!X.has(W)))}function i1($){return!!$&&typeof $==="object"&&!Array.isArray($)}function MP($){return ZL($)}function QK($){try{let J=q2(NP($));if(J===null)return{config:null,errors:[]};if(!J.trim())return{config:null,errors:["Config file is empty"]};let Q=JSON.parse(J),X=MP(Q);if(X.errors.length>0)return{config:null,errors:X.errors};let Y=UL().parse(Q);return{config:{version:1,rules:Y.rules??[],overrides:Y.overrides??{},transparent_wrappers:Y.transparent_wrappers??[]},errors:[]}}catch(J){if(J instanceof W1)return{config:null,errors:[J.message]};return{config:null,errors:["Invalid JSON"]}}}function NP($){return typeof $==="string"?A6($):$}var zP=new Set(["standard","strict","paranoid"]),IP={version:1,safety:{level:"standard",overrides:{}},workflow:{worktree_mode:!1},destructive_command_protection:{enabled:!0,overrides:{},allow_paths:[]},secret_protection:{enabled:!0,overrides:{},deny_paths:[]},audit:{retention_days:j6}};function XK($){return DP(_P(U2($)),C6)}function FL($={}){let J=AP(XK($));return{safety:J.policy.safety,worktreeMode:J.policy.worktreeMode,destructiveCommandProtectionEnabled:J.policy.destructiveCommandProtectionEnabled,destructiveCommandRuleOverrides:{...J.policy.destructiveCommandRuleOverrides},destructiveCommandAllowPaths:[...J.policy.destructiveCommandAllowPaths],secretProtection:J.policy.secretProtection,errors:J.errors,...J.fallback?{fallback:J.fallback}:{}}}function jP($){if(!y0($))return PP();let J=y0($.safety)?$.safety:{},Q=y0(J.overrides)?J.overrides:{},X=y0($.workflow)?$.workflow:{},Y=y0($.destructive_command_protection)?$.destructive_command_protection:{},W=y0($.secret_protection)?$.secret_protection:{};return{version:1,safety:{level:zP.has(J.level)?J.level:"standard",overrides:{...typeof Q.fail_closed==="boolean"?{fail_closed:Q.fail_closed}:{},...typeof Q.paranoid_rm==="boolean"?{paranoid_rm:Q.paranoid_rm}:{},...typeof Q.paranoid_interpreters==="boolean"?{paranoid_interpreters:Q.paranoid_interpreters}:{}}},workflow:{worktree_mode:typeof X.worktree_mode==="boolean"?X.worktree_mode:!1},destructive_command_protection:{enabled:typeof Y.enabled==="boolean"?Y.enabled:!0,overrides:NL(Y.overrides,i6),allow_paths:bP(Y.allow_paths)},secret_protection:{enabled:typeof W.enabled==="boolean"?W.enabled:!0,overrides:NL(W.overrides,WJ),deny_paths:RP(W.deny_paths)},audit:{retention_days:R6(y0($.audit)?$.audit.retention_days:void 0)}}}function NL($,J){if(!y0($))return{};return Object.fromEntries(Object.entries($).flatMap(([Q,X])=>J.has(Q)&&(X==="on"||X==="off")?[[Q,X]]:[]))}function RP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>T9(Q,J)===null)}function bP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>C9(Q,J)===null)}function y0($){return!!$&&typeof $==="object"&&!Array.isArray($)}function PP(){return structuredClone(IP)}function AP($){let J=EP();if(!FP($))return{policy:J,errors:[]};try{let Q=VP($,"utf-8");if(!Q.trim())return{policy:J,errors:[`${$}: Config file is empty`],fallback:"defaults"};let X=JSON.parse(Q),Y=LL(X),W=SP(jP(X));if(Y.length>0)return{policy:W,errors:Y.map((K)=>`${$}: ${K}`),fallback:y0(X)?"salvaged":"defaults"};return{policy:W,errors:[]}}catch{return{policy:J,errors:[`${$}: Invalid JSON`],fallback:"defaults"}}}function VL($){let J=Object.entries($),Q=new Set(J.flatMap(([X,Y])=>Y==="on"?[X]:[]));return new Set([...[...WL].filter((X)=>!Q.has(X)),...J.flatMap(([X,Y])=>Y==="off"?[X]:[])])}function EP(){return{safety:{},worktreeMode:!1,destructiveCommandProtectionEnabled:!0,destructiveCommandRuleOverrides:{},destructiveCommandAllowPaths:[],secretProtection:{enabled:!0,disabledRules:VL({}),denyPaths:[]}}}function SP($){return{safety:CP($.safety),worktreeMode:$.workflow.worktree_mode,destructiveCommandProtectionEnabled:$.destructive_command_protection.enabled,destructiveCommandRuleOverrides:{...$.destructive_command_protection.overrides},destructiveCommandAllowPaths:[...$.destructive_command_protection.allow_paths],secretProtection:{enabled:$.secret_protection.enabled,disabledRules:VL($.secret_protection.overrides),denyPaths:[...$.secret_protection.deny_paths]}}}function CP($){return{level:$.level,overrides:{failClosed:$.overrides.fail_closed,paranoidRm:$.overrides.paranoid_rm,paranoidInterpreters:$.overrides.paranoid_interpreters}}}var IL="This path contains the protected policy config and you must not modify or delete it.",TP=new Set(["[","cat","file","grep","head","jq","less","ls","more","rg","sed","stat","tail","test","wc"]);function jL($){let J=H2(A0()),Q=gP($.invocation.context.executionCwd,J);if($.invocation.route.kind==="patch")return _L($.paths.map((Y)=>Y.raw),!1,$.invocation.context.executionCwd,Q,J);let X=w1($,"input-candidate");if($.invocation.route.kind==="command")return X?DL(X.shell,$.invocation.context.executionCwd,Q,J):null;if($.invocation.route.kind==="unknown"&&X){let Y=DL(X.shell,$.invocation.context.executionCwd,Q,J);if(Y)return Y}return _L($.paths.map((Y)=>Y.raw),$.invocation.route.kind==="grep"||$.invocation.route.kind==="glob"||b9($.invocation.toolName),$.invocation.context.executionCwd,Q,J)}function _L($,J,Q,X,Y){if(J)return null;let W=$.find((K)=>F6(K,Q,X,Y));return W?{target:W}:null}function DL($,J,Q,X){let Y=A9($,J,X,{findSegmentTarget:(W,K)=>wP(W,K,Q,X)?.target??null,isRedirectionTarget:(W,K)=>F6(W,K.cwd,Q,X),findMalformedTarget:(W)=>kP(W,J,Q,X)?.target??null,normalizeCwd:M1});return Y?{target:Y}:null}function wP($,J,Q,X){if(O3($))return null;let Y=X.environment,W=l1([...$],Y),K=l(W[0]??"").toLowerCase(),B=W.slice(1);if(K==="rm"&&vP(B)){let q=fP(B).find((U)=>zL(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(K==="find"){if(x9(W,1)||AQ(W,Y)){let U=(y9(p(W))??p(["."])).find((G)=>{let H=f1(G.text,J.variables);return F6(H,J.cwd,Q,X)||zL(H,J.cwd,Q,X)})?.text;if(U)return{target:U}}}if(K==="mv"){let q=E9(B).sources.find((U)=>yP(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(hP($,Y))return null;for(let q of $)for(let U of RL(q))if(F6(f1(U,J.variables),J.cwd,Q,X))return{target:U};return null}function vP($){return $.some((J)=>J==="--recursive"||J.startsWith("-")&&!J.startsWith("--")&&/[rR]/.test(J.slice(1)))}function fP($){let J=$.indexOf("--");if(J!==-1)return[...$.slice(0,J).filter((Q)=>!Q.startsWith("-")),...$.slice(J+1)];return $.filter((Q)=>!Q.startsWith("-"))}function hP($,J){let Q=l1([...$],J);if(Q.length===0)return!1;let X=l(Q[0]??"").toLowerCase();if(!TP.has(X))return!1;if(X!=="sed")return!0;return!Q.slice(1).some((Y)=>Y.startsWith("-i")||Y==="--in-place"||Y.startsWith("--in-place="))}function kP($,J,Q,X){for(let Y of $.split(/\s+/))for(let W of RL(Y))if(F6(W,J,Q,X))return{target:W};return null}function RL($){let J=$.trim().replace(/^['"]|['"]$/g,""),Q=J.indexOf("=");return Q===-1||Q===J.length-1?[J]:[J,J.slice(Q+1)]}function gP($,J){let Q=M1(XK(),$,J),X=YK(Q),Y=new Set;for(let W=X;;W=YK(W))if(Y.add(d4(W)),YK(W)===W)break;return{file:d4(Q),directory:d4(X),directoryAndAncestors:Y}}function F6($,J,Q,X){return d4(M1($,J,X))===Q.file}function zL($,J,Q,X){return Q.directoryAndAncestors.has(d4(M1($,J,X)))}function yP($,J,Q,X){let Y=d4(M1($,J,X));return Y===Q.file||Q.directoryAndAncestors.has(Y)}function d4($){return process.platform==="win32"?$.toLowerCase():$}import{homedir as xP}from"os";import{isAbsolute as KK,resolve as vL}from"path";import{fileURLToPath as uP}from"url";var fL="Access to a sensitive path is not allowed.",hL=new Set(["echo","printf"]),mP=new Set(["find"]),lP=new Set(["-exec","-execdir"]),pP=new Set([";","+"]),cP=new Set(["-delete","-exec","-execdir","-fls","-fprint","-fprint0","-fprintf","-ok","-okdir"]),dP=new Set(["-name","-iname","-path","-ipath","-wholename","-iwholename","-samefile"]),rP=new Set(["python","python2","python3","node","deno","bun","ruby","perl","php","rscript","osascript","bash","sh","zsh","dash","ksh"]),iP=new Set(["node","bun"]),oP=new Set(["bun","child_process","deno","dotenv","fs","subprocess"]),nP=new Set(["append","awk","base64","cat","chmod","chown","connect","copy","cp","database","dd","eval","exec","fetch","file","function","grep","head","include","load","move","mv","open","popen","read","remove","rename","require","rg","rm","sed","shell","source","spawn","strings","system","tail","tar","truncate","unlink","write","xxd","zip"]),kL=new Set(["-c","-e","-r","-E","--eval","--exec"]),sP=new Set(["src/cli/cc-safety-net.ts","dist/bin/cc-safety-net.js"]),aP=new Map([["c",new Set(["bash","sh","zsh","dash","ksh","python"])],["e",new Set(["node","deno","bun","ruby","perl","rscript","osascript"])],["E",new Set(["perl"])],["r",new Set(["php"])]]),tP=new Set(["grep","rg"]),bL="f",PL="file",eP="files",$A=new Set(["e","f"]),JA=new Set(["regexp","file"]),QA=new Set(["e","f","A","B","C","m"]),XA=new Set(["regexp","file","after-context","before-context","context","max-count"]),YA=new Set(["|","|&"]),WK="__CC_SAFETY_NET_PIPE_INPUT__",gL=new Set(["bash","sh","zsh","dash","ksh"]),WA=new Map([["bash",new Set(["-O"])],["sh",new Set(["-O"])],["zsh",new Set(["-o"])],["dash",new Set(["-o"])],["ksh",new Set(["-o"])],["python",new Set(["-W","-X"])],["node",new Set(["-r","--require","--loader","--import","--input-type"])]]);function AL($,J,Q,X,Y){let W=s4();for(let K of $){if(pA(K,J,Q?.denyPaths??[],X,W))return{target:K,ruleId:"secret.deny-path"};if(Y&&!Y.has(K))continue;let B=mA(K,J,Q,W);if(B)return{target:K,ruleId:B}}return null}function yL($,J,Q={}){let X=EL($),Y=AL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd),W=Y?.ruleId!=="secret.deny-path"&&Q.strict===!1?EL($,{refineJavaScriptInlineData:!0}):X,K=W.length===X.length?Y:AL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd,new Set(W));if(K?.ruleId!=="secret.deny-path"&&Q.strict===!1&&KA($))return null;return K}function KA($){if($.invocation.route.kind!=="command")return!1;let J=w1($,"input-candidate")??w1($,"declared-command");if(!J)return!1;if(J.program.nodes.some((K)=>K.kind==="command"&&K.nested.length>0))return!1;let Q=[];for(let K of J.shell.entries){if(K.kind==="operator"&&K.boundary)return!1;if(K.kind==="redirection")return!1;if(K.kind!=="operator")Q.push(G0(K.text))}let X=i4(Q);if(X.length===0)return!1;let Y=y2(X[0]??"").toLowerCase(),W=X.slice(1);if(Y==="test")return W.length===2&&(W[0]==="-e"||W[0]==="-f");if(Y!=="find")return!1;return!W.some((K)=>cP.has(K))}function EL($,J={}){if($.invocation.route.kind==="command"){let X=w1($,"input-candidate");return X?D6(X.shell,$.store,J):[]}if($.invocation.route.kind!=="unknown")return $.paths.map((X)=>X.raw);let Q=w1($,"input-candidate");return[...Q?D6(Q.shell,$.store,J):[],...$.paths.map((X)=>X.raw)]}function D6($,J,Q){if($.status==="structural-limit")throw new n0;if($.status==="unclosed-quote")return[];if($.status==="invalid")throw Error("Unable to parse command for secret protection");let X=[...$.assignmentFallbacks,...PA(G0($.source),J,Q)],Y=[],W=null;for(let K of $.entries){if(K.kind==="operator"){if(!K.boundary)continue;if(Y.length>0){if(X.push(...BJ(Y,J,Q)),W!==null)X.push(...SL(W,Y,J,Q));W=YA.has(K.operator)?Y:null,Y=[]}else W=null;continue}if(K.kind==="redirection"){let B=K.target?G0(K.target):void 0;if(B&&K.targetOrder==="legacy-segment")Y.push(B);else if(B)X.push(B);continue}Y.push(G0(K.text))}if(Y.length>0){if(X.push(...BJ(Y,J,Q)),W!==null)X.push(...SL(W,Y,J,Q))}return X}function BJ($,J,Q){let X=NA($),Y=i4($);if(Y.length===0)return X;let W=Y[0]??"",K=y2(W).toLowerCase(),B=Y.slice(1),q=BA(W,K,B);if(q)return[...X,...q];if(hL.has(K))return X;if(tP.has(K))return[...X,...fA(B)];if(mP.has(K))return[...X,...FA(B,J,Q)];if(h1.has(K))return[...X,...B.flatMap((U)=>CL("awk",U)),...B.flatMap((U)=>_A(U,J,Q)),...B.flatMap(DA)];if(mL(K)){if(gL.has(K)){let U=xq(K,B);if(U!==null&&J.getShellSyntax(U).status==="structural-limit")throw new n0}return[...X,...VA(K,B,Q)]}return[...X,...B.flatMap((U)=>CL(K,U))]}function BA($,J,Q){let X=J==="cc-safety-net"&&Q[0]==="explain",Y=(J==="bun"||J==="node")&&qA(Q[0])&&Q[1]==="explain";if(!X&&!Y)return null;let W=Y?[$,Q[0]??""]:[$],K=Q.slice(Y?2:1);for(let B=0;B<K.length;B++){let q=K[B];if(q==="--json"||q==="--help"||q==="-h")continue;if(q==="--cwd"){let U=K[B+1];if(U&&!U.startsWith("--"))W.push(U);B++;continue}return W}return W}function qA($){let J=$?.replaceAll("\\","/");return[...sP].some((Q)=>J===Q||J?.endsWith(`/${Q}`))}function SL($,J,Q,X){if(LA(J,Q,X))return UA($);let Y=OA(J);if(Y===null)return[];return GA($).flatMap((W)=>gL.has(Y)?D6(Q.getShellSyntax(W),Q,X):pL(W))}function UA($){let J=i4($);if(J.length===0)return[];let Q=y2(J[0]??"").toLowerCase();if(!hL.has(Q))return[];return J.slice(1)}function GA($){let J=i4($);if(J.length===0)return[];let Q=y2(J[0]??"").toLowerCase(),X=J.slice(1);if(Q==="echo"){let Y=X.findIndex((W)=>!/^-[neE]+$/.test(W));return[(Y===-1?[]:X.slice(Y)).join(" ")]}if(Q==="printf")return HA(X);return[]}function HA($){let J=$[0];if(J===void 0)return[];let Q=(J.match(/%%|%[bqs]/g)??[]).filter((Y)=>Y!=="%%").length;if(Q===0||$.length===1)return[xL(J)];let X=$.slice(1);return Array.from({length:Math.ceil(X.length/Q)},(Y,W)=>ZA(J,X.slice(W*Q,(W+1)*Q)))}function ZA($,J){let Q=0;return xL($.replace(/%%|%[bqs]/g,(X)=>{if(X==="%%")return"%";let Y=J[Q]??"";return Q++,Y}))}function xL($){return $.replace(/\\n/g,`
101
- `).replace(/\\t/g,"\t").replace(/\\r/g,"\r")}function LA($,J,Q){let X=i4($);if(X.length===0||y2(X[0]??"").toLowerCase()!=="xargs")return!1;let Y=R2(X),W=X.slice(Y.childStart);if(W.length===0)return!1;if(Y.replacementToken==="")return!1;let K=Y.replacementToken,B=K===null?[...W,WK]:W.map((q)=>q.split(K).join(WK));return BJ(B,J,Q).some((q)=>q.includes(WK))}function OA($){let J=i4($);if(J.length===0)return null;let Q=y2(J[0]??"").toLowerCase();if(!mL(Q))return null;return MA(Q,J.slice(1))?Q:null}function MA($,J){let Q=uL($);for(let X=0;X<J.length;X++){let Y=J[X];if(Y===void 0)break;if(kL.has(Y)||lL($,Y)||/^--(?:eval|exec)=/.test(Y))return!1;if(Y==="-")return!0;if(Y.startsWith("-")){if(Q==="python"&&Y==="-m")return!1;if(WA.get(Q)?.has(Y))X++;continue}return!1}return!0}function uL($){return/^python\d/.test($)?"python":$}function NA($){let J=[];for(let Q of $){if(rL(Q))continue;let X=/^[A-Za-z_][A-Za-z0-9_]*=(.*)$/.exec(Q);if(X===null)break;if(X[1]!==void 0&&X[1]!=="")J.push(X[1])}return J}function CL($,J){if(J==="--")return[];let Q=[],X=J.indexOf("=");if(X>0&&X<J.length-1)Q.push(J.slice(X+1));if(J.startsWith("-"))return Q;if($==="tar"&&/\.(?:tar|tgz|tar\.gz|zip)$/i.test(J))return Q;if($==="zip"&&/\.zip$/i.test(J))return Q;return Q.push(J),Q}function FA($,J,Q){let X=$.findIndex((W)=>W.startsWith("-")||W==="("||W==="!"||W===";"),Y=[...$.slice(0,X===-1?$.length:X)];for(let W=0;W<$.length;W++){if(!lP.has($[W]??""))continue;let K=$.slice(W+1),B=K.findIndex((G)=>pP.has(G)),q=B===-1?K:K.slice(0,B),U=BJ(q,J,Q);if(Y.push(...U.filter((G)=>G!=="{}")),!U.includes("{}"))continue;Y.push(...$.slice(0,W).flatMap((G,H,L)=>{if(!dP.has(G))return[];let Z=L[H+1];return Z===void 0?[]:[Z,Z.replace(/^\*+\//,"").replace(/\/\*+$/g,"").replace(/^\*+/,"").replace(/\*+$/g,"")]}))}return Y}function mL($){return rP.has($)||/^python\d/.test($)}function VA($,J,Q){let X=[];for(let Y=0;Y<J.length;Y++){let W=J[Y];if(W===void 0)break;if(kL.has(W)||lL($,W)){let B=J[Y+1];if(B!==void 0)X.push(...TL($,B,Q)),Y++;continue}let K=/^--(?:eval|exec)=(.*)$/.exec(W);if(K!==null&&K[1]!==void 0){X.push(...TL($,K[1],Q));continue}if(!W.startsWith("-"))X.push(W)}return X}function lL($,J){if(!J.startsWith("-")||J.startsWith("--")||J.length<=2)return!1;return aP.get(J[J.length-1]??"")?.has(uL($))??!1}function _A($,J,Q){if(!$.includes("system"))return[];return jQ($)?.commands.flatMap((X)=>D6(J.getShellSyntax(X),J,Q))??[]}function DA($){return Array.from($.matchAll(/\bgetline(?:\s+[A-Za-z_][A-Za-z0-9_]*)?\s*<\s*"((?:\\.|[^"\\])*)"/g)).map((J)=>J[1]).filter((J)=>J!==void 0&&J!=="")}function pL($){let J=Array.from($.matchAll(/(['"`])((?:\\.|(?!\1).)*)\1/g)).map((X)=>X[2]).filter((X)=>X!==void 0&&X!==""),Q=($.match(/[\w./~@+-]*[./~][\w./~@+-]*/g)??[]).filter((X)=>X!=="process.versions.sqlite"||J.some((Y)=>Y.includes(X)));return[...J,...J.flatMap(cL),...Q]}function TL($,J,Q){let X=pL(J);if(!Q.refineJavaScriptInlineData||!iP.has($)||X.length===0)return X;let Y=zA(J);return Y!==null&&!jA(Y)?[]:X}function zA($){let J=$.split("");for(let Q=0;Q<$.length;Q++){let X=$[Q];if(X!=="'"&&X!=='"'&&X!=="`")continue;if(X==="`"&&IA($,Q))return null;J[Q]=" ";let Y=!1;for(let W=Q+1;W<$.length;W++){let K=$[W];if(J[W]=" ",K==="\\"){if(W++,W<$.length)J[W]=" ";continue}if(X==="`"&&K==="$"&&$[W+1]==="{")return null;if(X!=="`"&&(K===`
102
- `||K==="\r"))return null;if(K!==X)continue;Q=W,Y=!0;break}if(!Y)return null}return J.join("")}function IA($,J){for(let Q=J-1;Q>=0;Q--){let X=$[Q];if(!X||/\s/.test(X))continue;return/[\w$\])]/.test(X)}return!1}function jA($){for(let J of $.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/g)){let Q=J[0],X=J.index;if(oP.has(Q.toLowerCase()))return!0;let Y=Q.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[_$\s]+/).map((W)=>W.toLowerCase());if(!Y.some((W)=>nP.has(W)))continue;if(Y.length>1)return!0;if(RA($,X)===".")return!0;if(bA($,X+Q.length)==="(")return!0}return!1}function RA($,J){for(let Q=J-1;Q>=0;Q--)if(!/\s/.test($[Q]??""))return $[Q];return}function bA($,J){for(let Q=J;Q<$.length;Q++)if(!/\s/.test($[Q]??""))return $[Q];return}function PA($,J,Q){return TA($).flatMap((X)=>{let Y=J.getShellSyntax(X);if(Y.status==="invalid")return[];return[...D6(Y,J,Q),...AA(Y)?EA(Y):[]]})}function AA($){let J=$.entries;for(let Q=0;Q<J.length;Q++){let X=J[Q];if(X?.kind!=="word"||y2(G0(X.text)).toLowerCase()!=="base64")continue;for(let Y=Q+1;Y<J.length;Y++){let W=J[Y];if(W?.kind==="operator")break;if(W?.kind!=="word")continue;let K=G0(W.text);if(K==="--decode"||!K.startsWith("--")&&K.startsWith("-")&&/[dD]/.test(K))return!0}}return!1}function EA($){return $.entries.flatMap((J)=>J.kind==="word"?[G0(J.text)]:J.kind==="redirection"&&J.target?[G0(J.target)]:[]).flatMap(cL)}function cL($){let J=CA($);if(J===null)return[];let Q=Buffer.from(J,"base64").toString("utf8");if(Q===""||SA(Q))return[];return Buffer.from(Q,"utf8").toString("base64").replace(/=+$/g,"")===J.replace(/=+$/g,"")?[Q]:[]}function SA($){return Array.from($).some((J)=>{let Q=J.charCodeAt(0);return Q<32||Q===127})}function CA($){if($.length<8||!/^[A-Za-z0-9+/_-]+={0,2}$/.test($))return null;if(/=/.test($.replace(/=+$/g,"")))return null;let J=$.replace(/=+$/g,"");if(J.length%4===1)return null;return`${J.replace(/-/g,"+").replace(/_/g,"/")}${"=".repeat((4-J.length%4)%4)}`}function TA($){let J=[],Q={inSingle:!1,inDouble:!1,escaped:!1};for(let X=0;X<$.length;X++){let Y=$[X];if(!Y)break;if(G3(Y,Q))continue;if(dL($,X,Q)){let W=wA($,X+1);if(W!==null)J.push(W.body),X=W.endIndex;continue}if(!Q.inSingle&&Y==="`"){let W=vA($,X);if(W!==null)J.push(W.body),X=W.endIndex}}return J}function wA($,J){let Q={inSingle:!1,inDouble:!1,escaped:!1},X=1;for(let Y=J+1;Y<$.length;Y++){let W=$[Y];if(!W)break;if(G3(W,Q))continue;if(dL($,Y,Q)){X++,Y++;continue}if(!Q.inSingle&&!Q.inDouble&&W===")"){if(X--,X===0)return{body:$.slice(J+1,Y),endIndex:Y}}}return null}function vA($,J){let Q=!1;for(let X=J+1;X<$.length;X++){let Y=$[X];if(!Y)break;if(Q){Q=!1;continue}if(Y==="\\"){Q=!0;continue}if(Y==="`")return{body:$.slice(J+1,X),endIndex:X}}return null}function dL($,J,Q){return!Q.inSingle&&$[J]==="$"&&$[J+1]==="("&&$[J+2]!=="("}function fA($){let J=[],Q=[],X=!1,Y=!1,W=!1;for(let q=0;q<$.length;q++){let U=$[q];if(U===void 0)break;if(!W&&U==="--"){W=!0;continue}if(W){Q.push(U);continue}let G=/^--([^=]+)(?:=(.*))?$/.exec(U);if(G!==null){let H=G[1]??"",L=G[2];if(H===eP)Y=!0;if(JA.has(H))X=!0;if(L!==void 0){if(H===PL)J.push(L);continue}if(XA.has(H)){let Z=$[q+1];if(H===PL&&Z!==void 0)J.push(Z);q++}continue}if(U.startsWith("-")&&U.length>1){let H=U.slice(1),L="",Z="";for(let O=0;O<H.length;O++){let M=H[O]??"";if($A.has(M))X=!0;if(QA.has(M)){L=M,Z=H.slice(O+1);break}}if(L!=="")if(Z.length>0){if(L===bL)J.push(Z)}else{let O=$[q+1];if(L===bL&&O!==void 0)J.push(O);q++}continue}Q.push(U)}let B=!X&&!Y?Q.slice(1):Q;return[...J,...B]}function i4($){let J=$.findIndex((Q)=>!rL(Q)&&!/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(Q));return J===-1?[]:[...$.slice(J)]}function rL($){return $==="env"||$==="command"||$==="builtin"||$==="sudo"}var hA=new Set(["id_rsa.pub","id_ed25519.pub","id_ecdsa.pub"]),kA=".env.",gA=new Set([".env.example",".env.sample",".env.template",".env.defaults"]),yA=[".env.example.",".env.sample."],xA=new Set(["node_modules","__pycache__"]),uA=[["vendor","bundle"],["vendor","cache"]];function mA($,J,Q,X){let Y=u0($,J,X);if(!Y)return null;let W=G1(Y.split("/").pop()??""),K=G1(Y);if(gA.has(W)||yA.some((U)=>W.startsWith(U)))return null;for(let U of sW){let G=U.suffixParts.join("/");if((K===`~/${G}`||K.startsWith(`~/${G}/`))&&x0(U.id,Q))return U.id}let B=lA(Y,J,Q,X);if(B)return B;if(hA.has(W))return null;for(let U of nW)if(W===U.basename&&x0(U.id,Q))return U.id;if(W.startsWith(kA)&&x0(XJ.id,Q))return XJ.id;for(let U of aW)if(W.length>U.prefix.length&&W.startsWith(U.prefix)){let G=W.slice(U.prefix.length)[0];if((G==="-"||G==="_")&&x0(U.id,Q))return U.id}for(let U of tW)if(W.length>U.prefix.length&&W.startsWith(U.prefix)){if(W.slice(U.prefix.length)===U.suffix&&x0(U.id,Q))return U.id}if(cA(K))return null;if(!W.includes(".")&&M6.pattern.test(W)&&x0(M6.id,Q))return M6.id;let q=dA(W,Q);if(q)return q;return null}function lA($,J,Q,X){return YJ.find((Y)=>{if(!x0(Y.id,Q))return!1;switch(Y.id){case"secret.cli.claude-code":return $1($,Q1(process.env.CLAUDE_CONFIG_DIR,"~/.claude",J,X),[".credentials.json"]);case"secret.cli.claude-code.config":{let W=G1($).split("/");return $1($,Q1(process.env.CLAUDE_CONFIG_DIR,"~/.claude",J,X),["settings.json","settings.local.json"])||_6($,"~/.claude.json",J,X)||W.at(-1)==="settings.local.json"&&W.at(-2)===".claude"||W.at(-1)===".mcp.json"}case"secret.cli.antigravity":return $1($,u0("~/.gemini/config",J,X),["hooks.json","mcp_config.json"]);case"secret.cli.codex":{let W=Q1(process.env.CODEX_HOME,"~/.codex",J,X);return $1($,W,["auth.json",".credentials.json"])||V6($,W,["secrets",".sandbox-secrets"])}case"secret.cli.codex.config":{let W=Q1(process.env.CODEX_HOME,"~/.codex",J,X),K=G1($).split("/").at(-1)??"";return $1($,W,["config.toml"])||K.endsWith(".config.toml")&&$1($,W,[K])}case"secret.cli.gemini":return $1($,F1(Q1(process.env.GEMINI_CLI_HOME,"~",J,X),".gemini"),["oauth_creds.json","mcp-oauth-tokens.json","a2a-oauth-tokens.json","gemini-credentials.json"]);case"secret.cli.gemini.config":{let W=G1($).split("/"),K=process.env.ProgramData?[F1(Q1(process.env.ProgramData,"",J,X),"gemini-cli")]:[];return $1($,F1(Q1(process.env.GEMINI_CLI_HOME,"~",J,X),".gemini"),["settings.json","google_accounts.json"])||W.at(-1)==="settings.json"&&W.at(-2)===".gemini"||(process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH?.trim()?_6($,process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH,J,X):!1)||["/Library/Application Support/GeminiCli","/etc/gemini-cli",...K].some((B)=>$1($,u0(B,J,X),["settings.json"]))}case"secret.cli.copilot-cli":{let W=Q1(process.env.COPILOT_HOME,"~/.copilot",J,X);return $1($,W,["config.json"])||V6($,W,["mcp-oauth-config","mcp-secrets"])}case"secret.cli.copilot-cli.config":return $1($,Q1(process.env.COPILOT_HOME,"~/.copilot",J,X),["mcp-config.json"]);case"secret.cli.kimi-code":{let W=Q1(process.env.KIMI_CODE_HOME,"~/.kimi-code",J,X),K=Q1(process.env.KIMI_SHARE_DIR,"~/.kimi",J,X);return $1($,W,["server.token"])||V6($,W,["credentials"])||V6($,K,["credentials","mcp-oauth"])}case"secret.cli.kimi-code.config":{let W=["config.toml","mcp.json"],K=G1($).split("/");return K.at(-1)==="mcp.json"&&K.at(-2)===".kimi-code"||$1($,Q1(process.env.KIMI_CODE_HOME,"~/.kimi-code",J,X),W)||$1($,Q1(process.env.KIMI_SHARE_DIR,"~/.kimi",J,X),[...W,"config.json","config.json.bak"])}case"secret.cli.opencode":{let W=F1(Q1(process.env.XDG_DATA_HOME,"~/.local/share",J,X),"opencode"),K=G1($).split("/").at(-1)??"",B=process.env.OPENCODE_DB?.trim(),q=B&&B!==":memory:"?[B,`${B}-wal`,`${B}-shm`]:[];return $1($,W,["auth.json","mcp-auth.json"])||/^opencode(-.+)?\.db(-wal|-shm)?$/.test(K)&&$1($,W,[K])||q.some((U)=>_6($,U,J,X))}case"secret.cli.opencode.config":{let W=process.env.OPENCODE_CONFIG_DIR?Q1(process.env.OPENCODE_CONFIG_DIR,"~/.config/opencode",J,X):F1(Q1(process.env.XDG_CONFIG_HOME,"~/.config",J,X),"opencode"),K=process.env.ProgramData?[F1(Q1(process.env.ProgramData,"",J,X),"opencode")]:[],B=["opencode.json","opencode.jsonc"];return B.includes(G1($).split("/").at(-1)??"")||$1($,W,B)||(process.env.OPENCODE_CONFIG?.trim()?_6($,process.env.OPENCODE_CONFIG,J,X):!1)||["/Library/Application Support/opencode","/etc/opencode",...K].some((q)=>$1($,u0(q,J,X),B))}case"secret.cli.pi":return $1($,Q1(process.env.PI_CODING_AGENT_DIR,"~/.pi/agent",J,X),["auth.json"]);case"secret.cli.pi.config":return $1($,Q1(process.env.PI_CODING_AGENT_DIR,"~/.pi/agent",J,X),["models.json"]);case"secret.cli.amp":{let W=u0("~",J,X);return[F1(Q1(process.env.XDG_DATA_HOME,"~/.local/share",J,X),"amp"),F1(W,".local","share","amp")].some((B)=>$1($,B,["secrets.json"]))||V6($,F1(W,".amp"),["oauth"])}case"secret.cli.amp.config":{let W=["settings.json","settings.jsonc"],K=[F1(Q1(process.env.XDG_CONFIG_HOME,"~/.config",J,X),"amp"),F1(u0("~",J,X),".config","amp")],B=G1($).split("/");return K.some((q)=>$1($,q,W))||B.at(-2)===".amp"&&W.includes(B.at(-1)??"")||(process.env.AMP_SETTINGS_FILE?.trim()?_6($,process.env.AMP_SETTINGS_FILE,J,X):!1)}case"secret.cli.cursor":{let W=F1(Q1(process.env.XDG_CONFIG_HOME,"~/.config",J,X),"cursor"),K=F1(Q1(process.env.CURSOR_DATA_DIR,"~/.cursor",J,X),"projects");return $1($,u0("~/.cursor",J,X),["auth.json"])||$1($,W,["auth.json"])||G1($).split("/").at(-1)==="mcp-auth.json"&&qJ(G1($),G1(K))}case"secret.cli.cursor.config":{let W=G1($).split("/");return W.at(-1)==="mcp.json"&&W.at(-2)===".cursor"}default:return!1}})?.id??null}function Q1($,J,Q,X){return u0($?.trim()?$:J,Q,X)}function $1($,J,Q){return Q.some((X)=>iL($,F1(J,X)))}function V6($,J,Q){return Q.some((X)=>qJ(G1($),G1(F1(J,X))))}function _6($,J,Q,X){return iL($,u0(J,Q,X))}function iL($,J){return G1($)===G1(J)}function F1($,...J){return r4([$,...J].filter(Boolean).join("/"))}function pA($,J,Q,X,Y){if(Q.length===0)return!1;let W=G1(wL($,J,Y));return Q.some((K)=>qJ(W,G1(wL(K,X,Y))))}function cA($){let J=$.split("/");return J.some((Q)=>xA.has(Q))||uA.some(([Q,X])=>J.some((Y,W)=>Y===Q&&J[W+1]===X))}function dA($,J){let Q=$.lastIndexOf("."),X=Q>0&&Q<$.length-1?$.slice(Q+1):"";if(X==="")return null;for(let Y of eW)if(X===Y.extension&&x0(Y.id,J))return Y.id;for(let Y of $K)if(Y.pattern.test(X)&&x0(Y.id,J))return Y.id;return null}function G1($){return $.toLowerCase()}function x0($,J){if(!J?.disabledRules)return!0;if(Array.isArray(J.disabledRules))return!J.disabledRules.includes($);return!J.disabledRules.has($)}function u0($,J,Q){let{home:X,normalized:Y}=oL($,Q);if(!Y)return"";if(!X)return Y;let W=nL(Y,X),K=KK(W)?W:r4(vL(J,W)),B=r4(J1(K,i0,Q));if(!qJ(B,X)){if(KK(W))return B;return B===K?Y:B}let q=B.slice(X.length);return q?`~${q}`:"~"}function wL($,J,Q){let{home:X,normalized:Y}=oL($,Q);if(!Y)return"";let W=X?nL(Y,X):Y;return r4(J1(KK(W)?W:vL(J,W),i0,Q))}function oL($,J){let Q=process.env.HOME??xP(),X=Q?r4(J1(Q,i0,J)):"",Y=r4(rA(G0($)));return{home:X,normalized:Y}}function rA($){if(!$.trim().toLowerCase().startsWith("file:"))return $;try{return uP($)}catch{return $}}function nL($,J){if($==="~")return J;if($.startsWith("~/"))return F1(J,$.slice(2));return $}function r4($){let J=$.trim().replace(/\\/g,"/").replace(/\/{2,}/g,"/").replace(/^\.\//,"");if(J==="/")return J;return J.replace(/\/+$/g,"")}function qJ($,J){return $===J||$.startsWith(J.endsWith("/")?J:`${J}/`)}function y2($){return $.split(/[\\/]/).pop()?.replace(/\.exe$/i,"")??$}import{dirname as UJ}from"path";var sL="Rulebook exceeds CC Safety Net's safe validation limits.",aL="Additional rulebook validation errors were omitted.",X0=Object.freeze({maxAllowedCommands:1024,maxRules:1024,maxTests:2048,maxBlockArgsPerRule:1024,maxTotalBlockArgs:16384,maxStringCodeUnits:1048576,maxAggregateStringCodeUnits:4194304,maxFixtureCommandCodeUnits:131072,maxValidationErrors:64});function tL($){if(BK($.allowed_commands,X0.maxAllowedCommands)||BK($.rules,X0.maxRules)||BK($.tests,X0.maxTests))return!1;let{maxAggregateStringCodeUnits:J,maxTotalBlockArgs:Q}=X0,X=(Y,W=!1)=>{if(typeof Y!=="string")return!0;if(Y.length>X0.maxStringCodeUnits||W&&Y.length>X0.maxFixtureCommandCodeUnits||Y.length>J)return!1;return J-=Y.length,!0};if(!X($.name)||!X($.version)||!X($.description)||!X($.author)||!X($.migrated_from))return!1;if(Array.isArray($.allowed_commands)){for(let Y of $.allowed_commands)if(!X(Y))return!1}if(Array.isArray($.rules))for(let Y of $.rules){if(!Y||typeof Y!=="object")continue;let W=Y;if(!X(W.name)||!X(W.command)||!X(W.subcommand)||!X(W.reason)||!X(W.intent))return!1;if(!Array.isArray(W.block_args))continue;if(W.block_args.length>X0.maxBlockArgsPerRule||W.block_args.length>Q)return!1;Q-=W.block_args.length;for(let K of W.block_args)if(!X(K))return!1}if(Array.isArray($.tests))for(let Y of $.tests){if(!Y||typeof Y!=="object")continue;let W=Y;if(!X(W.command,!0)||!X(W.expect)||!X(W.rule))return!1}return!0}function BK($,J){return Array.isArray($)&&$.length>J}function iA($){if(!oA($))return{errors:["Rulebook must be an object"],ruleNames:new Set};if(!tL($))return{errors:[sL],ruleNames:new Set};let J=GL().safeParse($),Q=[...$.rulebook_version===1?[]:["rulebook_version must be 1"],...J.success?[]:c4(J.error.issues,": ",": ")];return{errors:Q.length>X0.maxValidationErrors?[...Q.slice(0,X0.maxValidationErrors),aL]:Q,ruleNames:new Set(JK($).map((X)=>X.toLowerCase()))}}function qK($){let J=iA($);if(J.errors.length>0)throw Error(J.errors.join("; "));return $}function oA($){return!!$&&typeof $==="object"&&!Array.isArray($)}function UK($){if(S6($.spec))return aA($);return sA($)}function sA($){if(!Y0.test($.spec))return`Local rulebook sources must be bare names matching ${Y0}: ${$.spec}`;if($.kind!=="local-directory")return`lock entry for ${$.spec} must use local-directory kind`;if($.path===$.spec&&$.name===$.spec)return null;return`lock entry for ${$.spec} does not match local source identity`}function aA($){let J=o4($.spec);if(J)return J;let Q=E6($.spec);if($.kind!=="github")return`lock entry for ${$.spec} must use github kind`;if($.owner===Q.owner&&$.repo===Q.repo&&$.ref===Q.ref&&$.path===Q.path&&$.name===Q.name)return null;return`lock entry for ${$.spec} does not match GitHub source identity`}function eL($){let J=typeof $==="string"?$:$.path;try{let Q=q2(typeof $==="string"?A6($):$);if(Q===null)return{lock:null,errors:[]};let X=JSON.parse(Q);if(!X||typeof X!=="object")return{lock:null,errors:[`malformed lockfile ${J}: must be an object`]};let Y=X;if(Y.version!==1||!Array.isArray(Y.rulebooks))return{lock:null,errors:[`malformed lockfile ${J}`]};let W=HL().safeParse(Y),K=Y.rulebooks.flatMap((q,U)=>{let G=W.success?[]:W.error.issues.filter((L)=>L.path[1]===U);if(G.length>0)return c4(G).map((L)=>`${J}: ${L}`);let H=UK(q);return H?[`${J}: rulebooks[${U}]: ${H}`]:[]});if(!W.success||K.length>0)return{lock:null,errors:[`malformed lockfile ${J}`,...K]};return{lock:{version:1,rulebooks:W.data.rulebooks.map((q)=>{if(q.kind==="local-directory")return{spec:q.spec,kind:q.kind,path:q.path,name:q.name,version:q.version,digest:q.digest};let U={spec:q.spec,kind:q.kind,owner:q.owner,repo:q.repo,ref:q.ref,commit:q.commit,path:q.path,name:q.name,version:q.version,digest:q.digest};return typeof q.display_ref==="string"&&q.display_ref!==""?{...U,display_ref:q.display_ref}:U})},errors:[]}}catch(Q){if(Q instanceof W1)return{lock:null,errors:[Q.message]};return{lock:null,errors:["malformed lockfile"]}}}import{createHash as tA}from"crypto";var Tg=Object.freeze({timeoutMs:15000,metadataBytes:524288,commitBytes:262144,treeBytes:16777216,rawBytes:4194304});function $O($){return`sha256:${tA("sha256").update($).digest("hex")}`}function WO($={}){let J=AK($),Q=!1;try{Q=_K(J.userConfigTarget,J.projectConfigTarget)}catch(L){if(L instanceof W1)return QE(J,L.message);throw L}let X=QK(J.userConfigTarget),Y=Q?{config:null,errors:[]}:QK(J.projectConfigTarget),W=YO(J.userConfigPath,X.errors),K=YO(J.projectConfigPath,Y.errors),B=new Set,q=X.config?JO(X.config,J.userLockPath,UJ(J.userConfigPath),$,"user",J.userScope,B):z6(),U=Y.config?JO(Y.config,J.projectLockPath,UJ(J.projectConfigPath),$,"project",J.projectScope,B):z6(),G=X.config?.overrides??{},H=Y.config?.overrides??{};return{rules:[...QO(q.rules,G),...QO(U.rules,H)],transparent_wrappers:$E(X.config,Y.config),rulebooks:[...q.rulebooks,...U.rulebooks],errors:[...W,...K,...q.errors,...U.errors],warnings:[...q.warnings,...U.warnings,...q.canValidateOverrides?XO(G,q.knownRuleIds,J.userConfigPath):[],...q.canValidateOverrides?JE(H,q.knownRuleIds,J.projectConfigPath):[],...U.canValidateOverrides?XO(H,U.knownRuleIds,J.projectConfigPath):[]],userConfig:X.config??void 0,projectConfig:Y.config??void 0,...J}}function JO($,J,Q,X,Y,W=m0(UJ(UJ(Q)),Y==="user"?"user policy":"project policy"),K=new Set){let B;try{B=R0(W,J)}catch(V){if(V instanceof W1)return{...z6(),errors:[V.message],canValidateOverrides:!1};throw V}let q=eL(B);if(q.errors.length>0)return{...z6(),errors:q.errors,canValidateOverrides:!1};let U=q.lock;if(!U&&$.rules.length>0)return{...z6(),errors:[`missing lockfile ${J}; run ${c0}`],canValidateOverrides:!1};let G=U?.rulebooks??[],H=new Map(G.map((V)=>[V.spec,V])),L=[],Z=[],O=$.rules.flatMap((V)=>{let F=H.get(V);if(!F)return L.push(`missing lock entry for ${V}; run ${c0}`),[];let b=eA(F,Q,X,W);if(b.errors.length>0||!b.rulebook)return L.push(...b.errors),[];let I=b.rulebook;if(K.has(I.name))return Z.push(`duplicate active rulebook name "${I.name}" for ${V}; keeping the first and ignoring this one, so its rules are not active; rename one of them, then run ${c0}`),[];return K.add(I.name),[{rules:I.rules.map((A)=>({...A,name:`${I.name}/${A.name}`})),rulebook:{source:Y,spec:F.spec,name:I.name,version:I.version,rules:I.rules.map((A)=>`${I.name}/${A.name}`)}}]}),M=O.flatMap((V)=>V.rules);return{rules:M,rulebooks:O.map((V)=>V.rulebook),entries:G,knownRuleIds:new Set(M.map((V)=>V.name)),errors:L,warnings:Z,canValidateOverrides:L.length===0}}function eA($,J,Q,X){let Y=VJ($,_J(J,Q)),W;try{W=q2(R0(X,Y))}catch(B){if(B instanceof W1)return{rulebook:null,errors:[B.message]};throw B}if(W===null)return{rulebook:null,errors:[`missing cache entry for ${$.spec}; run ${c0}`]};if($O(W)!==$.digest)return{rulebook:null,errors:[`cache digest mismatch for ${$.spec}; run ${c0}`]};let K;try{K=JSON.parse(W)}catch{return{rulebook:null,errors:[`invalid cached rulebook for ${$.spec}`]}}try{qK(K)}catch(B){return{rulebook:null,errors:[`invalid cached rulebook for ${$.spec}: ${B instanceof Error?B.message:"invalid rulebook"}`]}}return{rulebook:K,errors:[]}}function $E($,J){return[...new Set([...$?.transparent_wrappers??[],...J?.transparent_wrappers??[]])]}function QO($,J){return $.flatMap((Q)=>{let X=J[Q.name];if(X==="off")return[];if(X&&typeof X==="object")return[{...Q,intent:X.intent??Q.intent,reason:X.reason}];return[Q]})}function XO($,J,Q){return Object.keys($).filter((X)=>!J.has(X)).map((X)=>`unknown override key "${X}" in ${Q}; only that override is ignored and other overrides and rules keep their configured state; correct or remove it in that file`)}function JE($,J,Q){return Object.keys($).filter((X)=>J.has(X)).map((X)=>`project override cannot target user-scoped rule "${X}" in ${Q}; only that override is ignored and the rule keeps its user-configured state; remove it from that file`)}function YO($,J){return J.map((Q)=>Q.startsWith("Unable to access ")?Q:`${$}: ${Q}`)}function QE($,J){return{rules:[],transparent_wrappers:[],rulebooks:[],errors:[J],warnings:[],userConfigPath:$.userConfigPath,projectConfigPath:$.projectConfigPath,userLockPath:$.userLockPath,projectLockPath:$.projectLockPath}}function z6(){return{rules:[],rulebooks:[],entries:[],knownRuleIds:new Set,errors:[],warnings:[],canValidateOverrides:!0}}function KO($={}){let J=WO($),Q=FL($),X={rules:J.rules,transparentWrappers:J.transparent_wrappers,safety:qE(Q.safety),worktreeMode:Q.worktreeMode,destructiveCommandProtectionEnabled:Q.destructiveCommandProtectionEnabled,destructiveCommandRuleOverrides:{...Q.destructiveCommandRuleOverrides},destructiveCommandAllowPaths:[...Q.destructiveCommandAllowPaths],secretProtection:{enabled:Q.secretProtection.enabled??!0,disabledRules:[...Q.secretProtection.disabledRules??[]],denyPaths:[...Q.secretProtection.denyPaths]}},Y={...J.userConfig?.overrides??{},...J.projectConfig?.overrides??{}},W=Object.freeze(Object.fromEntries(X.rules.map((K)=>{let B=J.rulebooks.find((U)=>U.rules.includes(K.name)),q=Y[K.name];return[K.name,Object.freeze({id:K.name,...B?{rulebook:Object.freeze({name:B.name,version:B.version}),...KE(B.spec)?{source:B.spec}:{}}:{},...q&&typeof q==="object"?{override:Object.freeze({type:"reason",reason:q.reason})}:{}})]})));return BE(X,XE(J,Q),W)}function XE($,J){let Q=WE(J);if($.errors.length===0&&$.warnings.length===0&&!Q)return;return{diagnostics:[...$.errors,...$.warnings,...J.errors],reason:UE($.errors.length>0?YE($.errors):void 0,$.warnings.length>0?GK($.warnings.join("; ")):void 0,Q)}}function YE($){return`${GK($.join("; "))} Those rule sources are not active; every other rule and all built-in protections still apply`}function WE($){if($.errors.length===0)return;let J=$.fallback==="salvaged"?"the salvaged policy with protective defaults":"built-in protective defaults";return`invalid policy config: ${$.errors.join("; ")}. Enforcing ${J}; the invalid values are not active. Fix the policy file manually`}function KE($){return/^(?:[A-Za-z0-9_.-]+$|https:\/\/github\.com\/|github:|gh:|[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:#|$))/.test($)}function BE($,J,Q=Object.freeze({})){let X=BO(structuredClone($));if(!J)return Object.freeze({state:"ready",policy:X,diagnostics:Object.freeze([]),ruleMetadata:Q});return Object.freeze({state:"degraded",policy:X,diagnostics:Object.freeze([...J.diagnostics]),reason:J.reason,ruleMetadata:Q})}function qE($){let J=$.overrides,Q={...J?.failClosed!==void 0?{failClosed:J.failClosed}:{},...J?.paranoidRm!==void 0?{paranoidRm:J.paranoidRm}:{},...J?.paranoidInterpreters!==void 0?{paranoidInterpreters:J.paranoidInterpreters}:{}};return{...$.level!==void 0?{level:$.level}:{},...Object.keys(Q).length>0?{overrides:Q}:{}}}function BO($){if(typeof $!=="object"||$===null)return $;for(let J of Object.values($))BO(J);return Object.freeze($)}function UE(...$){return GK($.filter((J)=>!!J).join("; "))}function GK($){return/[.!?]$/.test($)?$:`${$}.`}class K2 extends Error{stage;evaluation;name="GuardEvaluationError";constructor($,J,Q){super(`CC Safety Net ${$} dependency failed`,{cause:Q});this.stage=$;this.evaluation=J}}var GE={findPolicyMutation:jL,findGitMetadataMutation:cq,resolveGitMetadata:LQ,loadPolicySnapshot:KO,findSensitiveTarget:yL,analyzeCommand:XH,getModes:U7};function qO($,J={}){let Q={...GE,...J.dependencies},X=LE($),Y=I6($)?$.command:X,W=x2("policy-protection",Y,()=>P9($,J.factParserDependencies)),K=w1(W,"declared-command");if(I6($)&&$.command?.trim()&&K?.program.status==="limited")return{stage:"command-analysis",decision:{kind:"deny",reason:P0,intent:"stop_and_explain",evidence:[{kind:"command",command:$.command,segment:$.command}]}};if(w1(W,"input-candidate")?.program.status==="limited")return{stage:"command-validation",decision:{kind:"deny",reason:pK,intent:"stop_and_explain",evidence:[]}};let B=x2("policy-protection",Y,()=>Q.resolveGitMetadata($.context.executionCwd)),q=x2("policy-protection",Y,()=>Q.findPolicyMutation(W));if(q){let V=Y??q.target;return{stage:"policy-protection",decision:{kind:"deny",reason:IL,intent:"hard_stop",evidence:[{kind:"command",command:V,segment:q.target},{kind:"path",target:q.target}]}}}let U=x2("policy-protection",Y,()=>Q.findGitMetadataMutation(W,B));if(U){let V=Y??U.target;return{stage:"policy-protection",decision:{kind:"deny",reason:p1,intent:"hard_stop",evidence:[{kind:"command",command:V,segment:U.target},{kind:"path",target:U.target}]}}}let G=x2("config-load",Y,()=>Q.loadPolicySnapshot({...J.policyOptions,cwd:$.context.configCwd})),H=G.policy,L=Q.getModes(H),Z={level:L.effectiveLevel,...HE(G)},O=H.secretProtection.enabled===!1?null:x2("secret-protection",Y,()=>Q.findSensitiveTarget(W,H.secretProtection,{strict:I6($)?L.strict:void 0}));if(O){let V=Y??O.target;return{stage:"secret-protection",...Z,decision:{kind:"deny",reason:fL,intent:"hard_stop",ruleId:O.ruleId,evidence:[{kind:"command",command:V,segment:O.target},{kind:"path",target:O.target}]}}}if(!I6($))return{stage:"non-command",...Z,decision:{kind:"allow"}};if(!$.command||$.command.trim()==="")return{...HK("command-validation",Y),...Z};let M=x2("command-analysis",Y,()=>{return Q.analyzeCommand($.command,{cwd:$.context.executionCwd,shell:$.route.shell,policySnapshot:G,environment:A0(),protectedGitMetadata:B,effectiveCapabilities:L.capabilities,strict:L.strict,paranoidRm:L.paranoidRm,paranoidInterpreters:L.paranoidInterpreters,worktreeMode:L.worktreeMode},ZE(W),W.store)});if(M)return{stage:"command-analysis",...Z,decision:M};return{stage:"command-analysis",...Z,decision:{kind:"allow"}}}function HE($){if($.state==="ready")return{};return{configFallback:{reason:$.reason}}}function ZE($){return w1($,"declared-command")?.program}function LE($){try{return J4($.input)}catch(J){let Q=I6($)?$.command:void 0;throw new K2("policy-protection",HK("policy-protection",J instanceof T0?void 0:Q),J)}}function x2($,J,Q){try{return Q()}catch(X){throw new K2($,HK($,X instanceof T0?void 0:J),X)}}function HK($,J){return{stage:$,decision:{kind:"deny",reason:v6,intent:"stop_and_explain",evidence:J?[{kind:"command",command:J,segment:J}]:[]}}}function I6($){return $.route.kind==="command"}function GO($,J){try{let Q=qO($,J.guard);return UO($,Q,J),Q}catch(Q){if(!(Q instanceof K2))throw Q;throw UO($,Q.evaluation,J,!(Q.cause instanceof T0),{stage:Q.stage,errorCode:OE(Q.cause)}),Q}}function UO($,J,Q,X=!0,Y){yK(gK($,J,Q.guard?.auditAllowed??!1,X,Y),Q.audit.getSessionId,{agent:Q.audit.agent,shape:Q.audit.shape,homeDir:Q.audit.homeDir})}function OE($){if($ instanceof o1)return"path-canonicalization-limit";if($ instanceof T0)return"tool-input-limit";if($ instanceof n0)return"structural-shell-syntax-limit";return"unexpected-error"}var ZO=NE();function NE($={}){return(J,Q)=>FE(J,Q,$)}function FE($,J,Q){let X=VE($,J),Y=()=>zE($);if("malformed"in X)return xK(X.denial,Y,{agent:"amp",toolName:X.denial.toolName,cwd:X.cwd}),LO(X.denial);try{let W=GO(X,{guard:{auditAllowed:B7(),policyOptions:Q.policyOptions,dependencies:Q.guardDependencies},audit:{agent:"amp",getSessionId:Y}});return HO(W,W.stage!=="config-state")}catch(W){if(!(W instanceof K2))throw W;if(h0(B1.debug))console.error(`CC Safety Net debug: amp tool.call analysis failed: ${nK(W.cause)}`);return HO(W.evaluation,X.route.kind==="command")}}function VE($,J){if(!$||typeof $!=="object")return u2(null);let Q=$;if(typeof Q.tool!=="string"||Q.tool.trim()==="")return u2(null);if(!Q.input||typeof Q.input!=="object")return u2(null,Q.tool);let X=_E(J);if(!X)return u2(null,Q.tool);let Y=DE(J,$);if(!Y.ok)return u2(X,Q.tool);if(!Y.command)return w3(Q.tool,Q.input,{kind:qQ(Q.tool)},{configCwd:X,executionCwd:X},null);if(typeof Y.command.command!=="string"||Y.command.command.trim()==="")return u2(X,Q.tool);let W=typeof Y.command.dir==="string"?w6(Y.command.dir,[X]):X;if(!W)return u2(X,Q.tool,Y.command.command,Y.command.dir);return w3(Q.tool,Q.input,{kind:"command",shell:"posix"},{configCwd:X,executionCwd:W},Y.command.command)}function _E($){let J=$.system.workspaceRoot;if(!J)return;try{let Q=$.helpers.filePathFromURI(J);if(typeof Q!=="string"||Q.trim()==="")return;return w6(".",[Q])}catch{return}}function DE($,J){try{return{ok:!0,command:$.helpers.shellCommandFromToolCall(J)}}catch{return{ok:!1}}}function zE($){if(!$||typeof $!=="object")return;let J=$.thread?.id;return typeof J==="string"&&J.trim()!==""?J:void 0}function u2($,J,Q,X){return{malformed:!0,denial:iK({command:Q,segment:X,toolName:J}),cwd:$}}function HO($,J){let Q=rK($,{includeEvidence:J});return Q?LO(Q):{action:"allow"}}function LO($){return{action:"reject-and-continue",message:oK($)}}function IE($){$.on("tool.call",(J)=>ZO(J,$))}export{IE as default};
100
+ `)}Z.write("payload.value = newResult;"),Z.write("return payload;");let b=Z.compile();return(I,A)=>b(L,I,A)},W,K=C2,B=!v3.jitless,U=B&&M7.value,G=J.catchall,H;$._zod.parse=(L,Z)=>{H??(H=X.value);let O=L.value;if(!K(O))return L.issues.push({expected:"object",code:"invalid_type",input:O,inst:$}),L;if(B&&U&&Z?.async===!1&&Z.jitless!==!0){if(!W)W=Y(J.shape);if(L=W(L,Z),!G)return L;return CH([],O,L,Z,H,$)}return Q(L,Z)}});function FH($,J,Q,X){for(let W of $)if(W.issues.length===0)return J.value=W.value,J;let Y=$.filter((W)=>!X2(W));if(Y.length===1)return J.value=Y[0].value,Y[0];return J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:$.map((W)=>W.issues.map((K)=>P1(K,X,Y1())))}),J}var d3=N("$ZodUnion",($,J)=>{v.init($,J),u($._zod,"optin",()=>J.options.some((Y)=>Y._zod.optin==="optional")?"optional":void 0),u($._zod,"optout",()=>J.options.some((Y)=>Y._zod.optout==="optional")?"optional":void 0),u($._zod,"values",()=>{if(J.options.every((Y)=>Y._zod.values))return new Set(J.options.flatMap((Y)=>Array.from(Y._zod.values)));return}),u($._zod,"pattern",()=>{if(J.options.every((Y)=>Y._zod.pattern)){let Y=J.options.map((W)=>W._zod.pattern);return new RegExp(`^(${Y.map((W)=>k3(W.source)).join("|")})$`)}return});let Q=J.options.length===1,X=J.options[0]._zod.run;$._zod.parse=(Y,W)=>{if(Q)return X(Y,W);let K=!1,B=[];for(let q of J.options){let U=q._zod.run({value:Y.value,issues:[]},W);if(U instanceof Promise)B.push(U),K=!0;else{if(U.issues.length===0)return U;B.push(U)}}if(!K)return FH(B,Y,$,W);return Promise.all(B).then((q)=>{return FH(q,Y,$,W)})}});function VH($,J,Q,X){let Y=$.filter((W)=>W.issues.length===0);if(Y.length===1)return J.value=Y[0].value,J;if(Y.length===0)J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:$.map((W)=>W.issues.map((K)=>P1(K,X,Y1())))});else J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:[],inclusive:!1});return J}var Q5=N("$ZodXor",($,J)=>{d3.init($,J),J.inclusive=!1;let Q=J.options.length===1,X=J.options[0]._zod.run;$._zod.parse=(Y,W)=>{if(Q)return X(Y,W);let K=!1,B=[];for(let q of J.options){let U=q._zod.run({value:Y.value,issues:[]},W);if(U instanceof Promise)B.push(U),K=!0;else B.push(U)}if(!K)return VH(B,Y,$,W);return Promise.all(B).then((q)=>{return VH(q,Y,$,W)})}}),X5=N("$ZodDiscriminatedUnion",($,J)=>{J.inclusive=!1,d3.init($,J);let Q=$._zod.parse;u($._zod,"propValues",()=>{let Y={};for(let W of J.options){let K=W._zod.propValues;if(!K||Object.keys(K).length===0)throw Error(`Invalid discriminated union option at index "${J.options.indexOf(W)}"`);for(let[B,q]of Object.entries(K)){if(!Y[B])Y[B]=new Set;for(let U of q)Y[B].add(U)}}return Y});let X=Z4(()=>{let Y=J.options,W=new Map;for(let K of Y){let B=K._zod.propValues?.[J.discriminator];if(!B||B.size===0)throw Error(`Invalid discriminated union option at index "${J.options.indexOf(K)}"`);for(let q of B){if(W.has(q))throw Error(`Duplicate discriminator value "${String(q)}"`);W.set(q,K)}}return W});$._zod.parse=(Y,W)=>{let K=Y.value;if(!C2(K))return Y.issues.push({code:"invalid_type",expected:"object",input:K,inst:$}),Y;let B=X.value.get(K?.[J.discriminator]);if(B)return B._zod.run(Y,W);if(J.unionFallback)return Q(Y,W);return Y.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:J.discriminator,input:K,path:[J.discriminator],inst:$}),Y}}),Y5=N("$ZodIntersection",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value,W=J.left._zod.run({value:Y,issues:[]},X),K=J.right._zod.run({value:Y,issues:[]},X);if(W instanceof Promise||K instanceof Promise)return Promise.all([W,K]).then(([q,U])=>{return _H(Q,q,U)});return _H(Q,W,K)}});function FX($,J){if($===J)return{valid:!0,data:$};if($ instanceof Date&&J instanceof Date&&+$===+J)return{valid:!0,data:$};if(Q2($)&&Q2(J)){let Q=Object.keys(J),X=Object.keys($).filter((W)=>Q.indexOf(W)!==-1),Y={...$,...J};for(let W of X){let K=FX($[W],J[W]);if(!K.valid)return{valid:!1,mergeErrorPath:[W,...K.mergeErrorPath]};Y[W]=K.data}return{valid:!0,data:Y}}if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return{valid:!1,mergeErrorPath:[]};let Q=[];for(let X=0;X<$.length;X++){let Y=$[X],W=J[X],K=FX(Y,W);if(!K.valid)return{valid:!1,mergeErrorPath:[X,...K.mergeErrorPath]};Q.push(K.data)}return{valid:!0,data:Q}}return{valid:!1,mergeErrorPath:[]}}function _H($,J,Q){let X=new Map,Y;for(let B of J.issues)if(B.code==="unrecognized_keys"){Y??(Y=B);for(let q of B.keys){if(!X.has(q))X.set(q,{});X.get(q).l=!0}}else $.issues.push(B);for(let B of Q.issues)if(B.code==="unrecognized_keys")for(let q of B.keys){if(!X.has(q))X.set(q,{});X.get(q).r=!0}else $.issues.push(B);let W=[...X].filter(([,B])=>B.l&&B.r).map(([B])=>B);if(W.length&&Y)$.issues.push({...Y,keys:W});if(X2($))return $;let K=FX(J.value,Q.value);if(!K.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(K.mergeErrorPath)}`);return $.value=K.data,$}var f$=N("$ZodTuple",($,J)=>{v.init($,J);let Q=J.items;$._zod.parse=(X,Y)=>{let W=X.value;if(!Array.isArray(W))return X.issues.push({input:W,inst:$,expected:"tuple",code:"invalid_type"}),X;X.value=[];let K=[],B=[...Q].reverse().findIndex((G)=>G._zod.optin!=="optional"),q=B===-1?0:Q.length-B;if(!J.rest){let G=W.length>Q.length,H=W.length<q-1;if(G||H)return X.issues.push({...G?{code:"too_big",maximum:Q.length,inclusive:!0}:{code:"too_small",minimum:Q.length},input:W,inst:$,origin:"array"}),X}let U=-1;for(let G of Q){if(U++,U>=W.length){if(U>=q)continue}let H=G._zod.run({value:W[U],issues:[]},Y);if(H instanceof Promise)K.push(H.then((L)=>A$(L,X,U)));else A$(H,X,U)}if(J.rest){let G=W.slice(Q.length);for(let H of G){U++;let L=J.rest._zod.run({value:H,issues:[]},Y);if(L instanceof Promise)K.push(L.then((Z)=>A$(Z,X,U)));else A$(L,X,U)}}if(K.length)return Promise.all(K).then(()=>X);return X}});function A$($,J,Q){if($.issues.length)J.issues.push(...g1(Q,$.issues));J.value[Q]=$.value}var W5=N("$ZodRecord",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!Q2(Y))return Q.issues.push({expected:"record",code:"invalid_type",input:Y,inst:$}),Q;let W=[],K=J.keyType._zod.values;if(K){Q.value={};let B=new Set;for(let U of K)if(typeof U==="string"||typeof U==="number"||typeof U==="symbol"){B.add(typeof U==="number"?U.toString():U);let G=J.valueType._zod.run({value:Y[U],issues:[]},X);if(G instanceof Promise)W.push(G.then((H)=>{if(H.issues.length)Q.issues.push(...g1(U,H.issues));Q.value[U]=H.value}));else{if(G.issues.length)Q.issues.push(...g1(U,G.issues));Q.value[U]=G.value}}let q;for(let U in Y)if(!B.has(U))q=q??[],q.push(U);if(q&&q.length>0)Q.issues.push({code:"unrecognized_keys",input:Y,inst:$,keys:q})}else{Q.value={};for(let B of Reflect.ownKeys(Y)){if(B==="__proto__")continue;let q=J.keyType._zod.run({value:B,issues:[]},X);if(q instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof B==="string"&&m3.test(B)&&q.issues.length&&q.issues.some((H)=>H.code==="invalid_type"&&H.expected==="number")){let H=J.keyType._zod.run({value:Number(B),issues:[]},X);if(H instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(H.issues.length===0)q=H}if(q.issues.length){if(J.mode==="loose")Q.value[B]=Y[B];else Q.issues.push({code:"invalid_key",origin:"record",issues:q.issues.map((H)=>P1(H,X,Y1())),input:B,path:[B],inst:$});continue}let G=J.valueType._zod.run({value:Y[B],issues:[]},X);if(G instanceof Promise)W.push(G.then((H)=>{if(H.issues.length)Q.issues.push(...g1(B,H.issues));Q.value[q.value]=H.value}));else{if(G.issues.length)Q.issues.push(...g1(B,G.issues));Q.value[q.value]=G.value}}}if(W.length)return Promise.all(W).then(()=>Q);return Q}}),K5=N("$ZodMap",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!(Y instanceof Map))return Q.issues.push({expected:"map",code:"invalid_type",input:Y,inst:$}),Q;let W=[];Q.value=new Map;for(let[K,B]of Y){let q=J.keyType._zod.run({value:K,issues:[]},X),U=J.valueType._zod.run({value:B,issues:[]},X);if(q instanceof Promise||U instanceof Promise)W.push(Promise.all([q,U]).then(([G,H])=>{DH(G,H,Q,K,Y,$,X)}));else DH(q,U,Q,K,Y,$,X)}if(W.length)return Promise.all(W).then(()=>Q);return Q}});function DH($,J,Q,X,Y,W,K){if($.issues.length)if(g3.has(typeof X))Q.issues.push(...g1(X,$.issues));else Q.issues.push({code:"invalid_key",origin:"map",input:Y,inst:W,issues:$.issues.map((B)=>P1(B,K,Y1()))});if(J.issues.length)if(g3.has(typeof X))Q.issues.push(...g1(X,J.issues));else Q.issues.push({origin:"map",code:"invalid_element",input:Y,inst:W,key:X,issues:J.issues.map((B)=>P1(B,K,Y1()))});Q.value.set($.value,J.value)}var B5=N("$ZodSet",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!(Y instanceof Set))return Q.issues.push({input:Y,inst:$,expected:"set",code:"invalid_type"}),Q;let W=[];Q.value=new Set;for(let K of Y){let B=J.valueType._zod.run({value:K,issues:[]},X);if(B instanceof Promise)W.push(B.then((q)=>zH(q,Q)));else zH(B,Q)}if(W.length)return Promise.all(W).then(()=>Q);return Q}});function zH($,J){if($.issues.length)J.issues.push(...$.issues);J.value.add($.value)}var q5=N("$ZodEnum",($,J)=>{v.init($,J);let Q=h3(J.entries),X=new Set(Q);$._zod.values=X,$._zod.pattern=new RegExp(`^(${Q.filter((Y)=>g3.has(typeof Y)).map((Y)=>typeof Y==="string"?r1(Y):Y.toString()).join("|")})$`),$._zod.parse=(Y,W)=>{let K=Y.value;if(X.has(K))return Y;return Y.issues.push({code:"invalid_value",values:Q,input:K,inst:$}),Y}}),U5=N("$ZodLiteral",($,J)=>{if(v.init($,J),J.values.length===0)throw Error("Cannot create literal schema with no valid values");let Q=new Set(J.values);$._zod.values=Q,$._zod.pattern=new RegExp(`^(${J.values.map((X)=>typeof X==="string"?r1(X):X?r1(X.toString()):String(X)).join("|")})$`),$._zod.parse=(X,Y)=>{let W=X.value;if(Q.has(W))return X;return X.issues.push({code:"invalid_value",values:J.values,input:W,inst:$}),X}}),G5=N("$ZodFile",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(Y instanceof File)return Q;return Q.issues.push({expected:"file",code:"invalid_type",input:Y,inst:$}),Q}}),H5=N("$ZodTransform",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{if(X.direction==="backward")throw new S2($.constructor.name);let Y=J.transform(Q.value,Q);if(X.async)return(Y instanceof Promise?Y:Promise.resolve(Y)).then((K)=>{return Q.value=K,Q});if(Y instanceof Promise)throw new F0;return Q.value=Y,Q}});function IH($,J){if($.issues.length&&J===void 0)return{issues:[],value:void 0};return $}var h$=N("$ZodOptional",($,J)=>{v.init($,J),$._zod.optin="optional",$._zod.optout="optional",u($._zod,"values",()=>{return J.innerType._zod.values?new Set([...J.innerType._zod.values,void 0]):void 0}),u($._zod,"pattern",()=>{let Q=J.innerType._zod.pattern;return Q?new RegExp(`^(${k3(Q.source)})?$`):void 0}),$._zod.parse=(Q,X)=>{if(J.innerType._zod.optin==="optional"){let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>IH(W,Q.value));return IH(Y,Q.value)}if(Q.value===void 0)return Q;return J.innerType._zod.run(Q,X)}}),Z5=N("$ZodExactOptional",($,J)=>{h$.init($,J),u($._zod,"values",()=>J.innerType._zod.values),u($._zod,"pattern",()=>J.innerType._zod.pattern),$._zod.parse=(Q,X)=>{return J.innerType._zod.run(Q,X)}}),L5=N("$ZodNullable",($,J)=>{v.init($,J),u($._zod,"optin",()=>J.innerType._zod.optin),u($._zod,"optout",()=>J.innerType._zod.optout),u($._zod,"pattern",()=>{let Q=J.innerType._zod.pattern;return Q?new RegExp(`^(${k3(Q.source)}|null)$`):void 0}),u($._zod,"values",()=>{return J.innerType._zod.values?new Set([...J.innerType._zod.values,null]):void 0}),$._zod.parse=(Q,X)=>{if(Q.value===null)return Q;return J.innerType._zod.run(Q,X)}}),O5=N("$ZodDefault",($,J)=>{v.init($,J),$._zod.optin="optional",u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);if(Q.value===void 0)return Q.value=J.defaultValue,Q;let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>jH(W,J));return jH(Y,J)}});function jH($,J){if($.value===void 0)$.value=J.defaultValue;return $}var M5=N("$ZodPrefault",($,J)=>{v.init($,J),$._zod.optin="optional",u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);if(Q.value===void 0)Q.value=J.defaultValue;return J.innerType._zod.run(Q,X)}}),N5=N("$ZodNonOptional",($,J)=>{v.init($,J),u($._zod,"values",()=>{let Q=J.innerType._zod.values;return Q?new Set([...Q].filter((X)=>X!==void 0)):void 0}),$._zod.parse=(Q,X)=>{let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>RH(W,$));return RH(Y,$)}});function RH($,J){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:J});return $}var F5=N("$ZodSuccess",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{if(X.direction==="backward")throw new S2("ZodSuccess");let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>{return Q.value=W.issues.length===0,Q});return Q.value=Y.issues.length===0,Q}}),V5=N("$ZodCatch",($,J)=>{v.init($,J),u($._zod,"optin",()=>J.innerType._zod.optin),u($._zod,"optout",()=>J.innerType._zod.optout),u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>{if(Q.value=W.value,W.issues.length)Q.value=J.catchValue({...Q,error:{issues:W.issues.map((K)=>P1(K,X,Y1()))},input:Q.value}),Q.issues=[];return Q});if(Q.value=Y.value,Y.issues.length)Q.value=J.catchValue({...Q,error:{issues:Y.issues.map((W)=>P1(W,X,Y1()))},input:Q.value}),Q.issues=[];return Q}}),_5=N("$ZodNaN",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{if(typeof Q.value!=="number"||!Number.isNaN(Q.value))return Q.issues.push({input:Q.value,inst:$,expected:"nan",code:"invalid_type"}),Q;return Q}}),D5=N("$ZodPipe",($,J)=>{v.init($,J),u($._zod,"values",()=>J.in._zod.values),u($._zod,"optin",()=>J.in._zod.optin),u($._zod,"optout",()=>J.out._zod.optout),u($._zod,"propValues",()=>J.in._zod.propValues),$._zod.parse=(Q,X)=>{if(X.direction==="backward"){let W=J.out._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>E$(K,J.in,X));return E$(W,J.in,X)}let Y=J.in._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>E$(W,J.out,X));return E$(Y,J.out,X)}});function E$($,J,Q){if($.issues.length)return $.aborted=!0,$;return J._zod.run({value:$.value,issues:$.issues},Q)}var r3=N("$ZodCodec",($,J)=>{v.init($,J),u($._zod,"values",()=>J.in._zod.values),u($._zod,"optin",()=>J.in._zod.optin),u($._zod,"optout",()=>J.out._zod.optout),u($._zod,"propValues",()=>J.in._zod.propValues),$._zod.parse=(Q,X)=>{if((X.direction||"forward")==="forward"){let W=J.in._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>S$(K,J,X));return S$(W,J,X)}else{let W=J.out._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>S$(K,J,X));return S$(W,J,X)}}});function S$($,J,Q){if($.issues.length)return $.aborted=!0,$;if((Q.direction||"forward")==="forward"){let Y=J.transform($.value,$);if(Y instanceof Promise)return Y.then((W)=>C$($,W,J.out,Q));return C$($,Y,J.out,Q)}else{let Y=J.reverseTransform($.value,$);if(Y instanceof Promise)return Y.then((W)=>C$($,W,J.in,Q));return C$($,Y,J.in,Q)}}function C$($,J,Q,X){if($.issues.length)return $.aborted=!0,$;return Q._zod.run({value:J,issues:$.issues},X)}var z5=N("$ZodReadonly",($,J)=>{v.init($,J),u($._zod,"propValues",()=>J.innerType._zod.propValues),u($._zod,"values",()=>J.innerType._zod.values),u($._zod,"optin",()=>J.innerType?._zod?.optin),u($._zod,"optout",()=>J.innerType?._zod?.optout),$._zod.parse=(Q,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then(bH);return bH(Y)}});function bH($){return $.value=Object.freeze($.value),$}var I5=N("$ZodTemplateLiteral",($,J)=>{v.init($,J);let Q=[];for(let X of J.parts)if(typeof X==="object"&&X!==null){if(!X._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...X._zod.traits].shift()}`);let Y=X._zod.pattern instanceof RegExp?X._zod.pattern.source:X._zod.pattern;if(!Y)throw Error(`Invalid template literal part: ${X._zod.traits}`);let W=Y.startsWith("^")?1:0,K=Y.endsWith("$")?Y.length-1:Y.length;Q.push(Y.slice(W,K))}else if(X===null||F7.has(typeof X))Q.push(r1(`${X}`));else throw Error(`Invalid template literal part: ${X}`);$._zod.pattern=new RegExp(`^${Q.join("")}$`),$._zod.parse=(X,Y)=>{if(typeof X.value!=="string")return X.issues.push({input:X.value,inst:$,expected:"string",code:"invalid_type"}),X;if($._zod.pattern.lastIndex=0,!$._zod.pattern.test(X.value))return X.issues.push({input:X.value,inst:$,code:"invalid_format",format:J.format??"template_literal",pattern:$._zod.pattern.source}),X;return X}}),j5=N("$ZodFunction",($,J)=>{return v.init($,J),$._def=J,$._zod.def=J,$.implement=(Q)=>{if(typeof Q!=="function")throw Error("implement() must be called with a function");return function(...X){let Y=$._def.input?L$($._def.input,X):X,W=Reflect.apply(Q,this,Y);if($._def.output)return L$($._def.output,W);return W}},$.implementAsync=(Q)=>{if(typeof Q!=="function")throw Error("implementAsync() must be called with a function");return async function(...X){let Y=$._def.input?await O$($._def.input,X):X,W=await Reflect.apply(Q,this,Y);if($._def.output)return await O$($._def.output,W);return W}},$._zod.parse=(Q,X)=>{if(typeof Q.value!=="function")return Q.issues.push({code:"invalid_type",expected:"function",input:Q.value,inst:$}),Q;if($._def.output&&$._def.output._zod.def.type==="promise")Q.value=$.implementAsync(Q.value);else Q.value=$.implement(Q.value);return Q},$.input=(...Q)=>{let X=$.constructor;if(Array.isArray(Q[0]))return new X({type:"function",input:new f$({type:"tuple",items:Q[0],rest:Q[1]}),output:$._def.output});return new X({type:"function",input:Q[0],output:$._def.output})},$.output=(Q)=>{return new $.constructor({type:"function",input:$._def.input,output:Q})},$}),R5=N("$ZodPromise",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{return Promise.resolve(Q.value).then((Y)=>J.innerType._zod.run({value:Y,issues:[]},X))}}),b5=N("$ZodLazy",($,J)=>{v.init($,J),u($._zod,"innerType",()=>J.getter()),u($._zod,"pattern",()=>$._zod.innerType?._zod?.pattern),u($._zod,"propValues",()=>$._zod.innerType?._zod?.propValues),u($._zod,"optin",()=>$._zod.innerType?._zod?.optin??void 0),u($._zod,"optout",()=>$._zod.innerType?._zod?.optout??void 0),$._zod.parse=(Q,X)=>{return $._zod.innerType._zod.run(Q,X)}}),P5=N("$ZodCustom",($,J)=>{o.init($,J),v.init($,J),$._zod.parse=(Q,X)=>{return Q},$._zod.check=(Q)=>{let X=Q.value,Y=J.fn(X);if(Y instanceof Promise)return Y.then((W)=>PH(W,Q,X,$));PH(Y,Q,X,$);return}});function PH($,J,Q,X){if(!$){let Y={code:"custom",input:Q,inst:X,path:[...X._zod.def.path??[]],continue:!X._zod.def.abort};if(X._zod.def.params)Y.params=X._zod.def.params;J.issues.push(L4(Y))}}var i3={};var wH,k$=Symbol("ZodOutput"),g$=Symbol("ZodInput");class A5{constructor(){this._map=new WeakMap,this._idmap=new Map}add($,...J){let Q=J[0];if(this._map.set($,Q),Q&&typeof Q==="object"&&"id"in Q)this._idmap.set(Q.id,$);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove($){let J=this._map.get($);if(J&&typeof J==="object"&&"id"in J)this._idmap.delete(J.id);return this._map.delete($),this}get($){let J=$._zod.parent;if(J){let Q={...this.get(J)??{}};delete Q.id;let X={...Q,...this._map.get($)};return Object.keys(X).length?X:void 0}return this._map.get($)}has($){return this._map.has($)}}function o3(){return new A5}(wH=globalThis).__zod_globalRegistry??(wH.__zod_globalRegistry=o3());var E1=globalThis.__zod_globalRegistry;function E5($,J){return new $({type:"string",...D(J)})}function S5($,J){return new $({type:"string",coerce:!0,...D(J)})}function y$($,J){return new $({type:"string",format:"email",check:"string_format",abort:!1,...D(J)})}function n3($,J){return new $({type:"string",format:"guid",check:"string_format",abort:!1,...D(J)})}function x$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,...D(J)})}function u$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...D(J)})}function m$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...D(J)})}function l$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...D(J)})}function s3($,J){return new $({type:"string",format:"url",check:"string_format",abort:!1,...D(J)})}function p$($,J){return new $({type:"string",format:"emoji",check:"string_format",abort:!1,...D(J)})}function c$($,J){return new $({type:"string",format:"nanoid",check:"string_format",abort:!1,...D(J)})}function d$($,J){return new $({type:"string",format:"cuid",check:"string_format",abort:!1,...D(J)})}function r$($,J){return new $({type:"string",format:"cuid2",check:"string_format",abort:!1,...D(J)})}function i$($,J){return new $({type:"string",format:"ulid",check:"string_format",abort:!1,...D(J)})}function o$($,J){return new $({type:"string",format:"xid",check:"string_format",abort:!1,...D(J)})}function n$($,J){return new $({type:"string",format:"ksuid",check:"string_format",abort:!1,...D(J)})}function s$($,J){return new $({type:"string",format:"ipv4",check:"string_format",abort:!1,...D(J)})}function a$($,J){return new $({type:"string",format:"ipv6",check:"string_format",abort:!1,...D(J)})}function C5($,J){return new $({type:"string",format:"mac",check:"string_format",abort:!1,...D(J)})}function t$($,J){return new $({type:"string",format:"cidrv4",check:"string_format",abort:!1,...D(J)})}function e$($,J){return new $({type:"string",format:"cidrv6",check:"string_format",abort:!1,...D(J)})}function $8($,J){return new $({type:"string",format:"base64",check:"string_format",abort:!1,...D(J)})}function J8($,J){return new $({type:"string",format:"base64url",check:"string_format",abort:!1,...D(J)})}function Q8($,J){return new $({type:"string",format:"e164",check:"string_format",abort:!1,...D(J)})}function X8($,J){return new $({type:"string",format:"jwt",check:"string_format",abort:!1,...D(J)})}var Y8={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function T5($,J){return new $({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...D(J)})}function w5($,J){return new $({type:"string",format:"date",check:"string_format",...D(J)})}function v5($,J){return new $({type:"string",format:"time",check:"string_format",precision:null,...D(J)})}function f5($,J){return new $({type:"string",format:"duration",check:"string_format",...D(J)})}function h5($,J){return new $({type:"number",checks:[],...D(J)})}function k5($,J){return new $({type:"number",coerce:!0,checks:[],...D(J)})}function g5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"safeint",...D(J)})}function y5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"float32",...D(J)})}function x5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"float64",...D(J)})}function u5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"int32",...D(J)})}function m5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"uint32",...D(J)})}function l5($,J){return new $({type:"boolean",...D(J)})}function p5($,J){return new $({type:"boolean",coerce:!0,...D(J)})}function c5($,J){return new $({type:"bigint",...D(J)})}function d5($,J){return new $({type:"bigint",coerce:!0,...D(J)})}function r5($,J){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...D(J)})}function i5($,J){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...D(J)})}function o5($,J){return new $({type:"symbol",...D(J)})}function n5($,J){return new $({type:"undefined",...D(J)})}function s5($,J){return new $({type:"null",...D(J)})}function a5($){return new $({type:"any"})}function t5($){return new $({type:"unknown"})}function e5($,J){return new $({type:"never",...D(J)})}function $Y($,J){return new $({type:"void",...D(J)})}function JY($,J){return new $({type:"date",...D(J)})}function QY($,J){return new $({type:"date",coerce:!0,...D(J)})}function XY($,J){return new $({type:"nan",...D(J)})}function V0($,J){return new R$({check:"less_than",...D(J),value:$,inclusive:!1})}function x1($,J){return new R$({check:"less_than",...D(J),value:$,inclusive:!0})}function _0($,J){return new b$({check:"greater_than",...D(J),value:$,inclusive:!1})}function D1($,J){return new b$({check:"greater_than",...D(J),value:$,inclusive:!0})}function W8($){return _0(0,$)}function K8($){return V0(0,$)}function B8($){return x1(0,$)}function q8($){return D1(0,$)}function Y2($,J){return new t7({check:"multiple_of",...D(J),value:$})}function W2($,J){return new JX({check:"max_size",...D(J),maximum:$})}function D0($,J){return new QX({check:"min_size",...D(J),minimum:$})}function v2($,J){return new XX({check:"size_equals",...D(J),size:$})}function f2($,J){return new YX({check:"max_length",...D(J),maximum:$})}function y0($,J){return new WX({check:"min_length",...D(J),minimum:$})}function h2($,J){return new KX({check:"length_equals",...D(J),length:$})}function z4($,J){return new BX({check:"string_format",format:"regex",...D(J),pattern:$})}function I4($){return new qX({check:"string_format",format:"lowercase",...D($)})}function j4($){return new UX({check:"string_format",format:"uppercase",...D($)})}function R4($,J){return new GX({check:"string_format",format:"includes",...D(J),includes:$})}function b4($,J){return new HX({check:"string_format",format:"starts_with",...D(J),prefix:$})}function P4($,J){return new ZX({check:"string_format",format:"ends_with",...D(J),suffix:$})}function U8($,J,Q){return new LX({check:"property",property:$,schema:J,...D(Q)})}function A4($,J){return new OX({check:"mime_type",mime:$,...D(J)})}function Q0($){return new MX({check:"overwrite",tx:$})}function E4($){return Q0((J)=>J.normalize($))}function S4(){return Q0(($)=>$.trim())}function C4(){return Q0(($)=>$.toLowerCase())}function T4(){return Q0(($)=>$.toUpperCase())}function w4(){return Q0(($)=>O7($))}function YY($,J,Q){return new $({type:"array",element:J,...D(Q)})}function Ib($,J,Q){return new $({type:"union",options:J,...D(Q)})}function jb($,J,Q){return new $({type:"union",options:J,inclusive:!1,...D(Q)})}function Rb($,J,Q,X){return new $({type:"union",options:Q,discriminator:J,...D(X)})}function bb($,J,Q){return new $({type:"intersection",left:J,right:Q})}function Pb($,J,Q,X){let Y=Q instanceof v;return new $({type:"tuple",items:J,rest:Y?Q:null,...D(Y?X:Q)})}function Ab($,J,Q,X){return new $({type:"record",keyType:J,valueType:Q,...D(X)})}function Eb($,J,Q,X){return new $({type:"map",keyType:J,valueType:Q,...D(X)})}function Sb($,J,Q){return new $({type:"set",valueType:J,...D(Q)})}function Cb($,J,Q){let X=Array.isArray(J)?Object.fromEntries(J.map((Y)=>[Y,Y])):J;return new $({type:"enum",entries:X,...D(Q)})}function Tb($,J,Q){return new $({type:"enum",entries:J,...D(Q)})}function wb($,J,Q){return new $({type:"literal",values:Array.isArray(J)?J:[J],...D(Q)})}function WY($,J){return new $({type:"file",...D(J)})}function vb($,J){return new $({type:"transform",transform:J})}function fb($,J){return new $({type:"optional",innerType:J})}function hb($,J){return new $({type:"nullable",innerType:J})}function kb($,J,Q){return new $({type:"default",innerType:J,get defaultValue(){return typeof Q==="function"?Q():N7(Q)}})}function gb($,J,Q){return new $({type:"nonoptional",innerType:J,...D(Q)})}function yb($,J){return new $({type:"success",innerType:J})}function xb($,J,Q){return new $({type:"catch",innerType:J,catchValue:typeof Q==="function"?Q:()=>Q})}function ub($,J,Q){return new $({type:"pipe",in:J,out:Q})}function mb($,J){return new $({type:"readonly",innerType:J})}function lb($,J,Q){return new $({type:"template_literal",parts:J,...D(Q)})}function pb($,J){return new $({type:"lazy",getter:J})}function cb($,J){return new $({type:"promise",innerType:J})}function KY($,J,Q){let X=D(Q);return X.abort??(X.abort=!0),new $({type:"custom",check:"custom",fn:J,...X})}function BY($,J,Q){return new $({type:"custom",check:"custom",fn:J,...D(Q)})}function qY($){let J=vH((Q)=>{return Q.addIssue=(X)=>{if(typeof X==="string")Q.issues.push(L4(X,Q.value,J._zod.def));else{let Y=X;if(Y.fatal)Y.continue=!1;Y.code??(Y.code="custom"),Y.input??(Y.input=Q.value),Y.inst??(Y.inst=J),Y.continue??(Y.continue=!J._zod.def.abort),Q.issues.push(L4(Y))}},$(Q.value,Q)});return J}function vH($,J){let Q=new o({check:"custom",...D(J)});return Q._zod.check=$,Q}function UY($){let J=new o({check:"describe"});return J._zod.onattach=[(Q)=>{let X=E1.get(Q)??{};E1.add(Q,{...X,description:$})}],J._zod.check=()=>{},J}function GY($){let J=new o({check:"meta"});return J._zod.onattach=[(Q)=>{let X=E1.get(Q)??{};E1.add(Q,{...X,...$})}],J._zod.check=()=>{},J}function HY($,J){let Q=D(J),X=Q.truthy??["true","1","yes","on","y","enabled"],Y=Q.falsy??["false","0","no","off","n","disabled"];if(Q.case!=="sensitive")X=X.map((Z)=>typeof Z==="string"?Z.toLowerCase():Z),Y=Y.map((Z)=>typeof Z==="string"?Z.toLowerCase():Z);let W=new Set(X),K=new Set(Y),B=$.Codec??r3,q=$.Boolean??c3,G=new($.String??w2)({type:"string",error:Q.error}),H=new q({type:"boolean",error:Q.error}),L=new B({type:"pipe",in:G,out:H,transform:(Z,O)=>{let M=Z;if(Q.case!=="sensitive")M=M.toLowerCase();if(W.has(M))return!0;else if(K.has(M))return!1;else return O.issues.push({code:"invalid_value",expected:"stringbool",values:[...W,...K],input:O.value,inst:L,continue:!1}),{}},reverseTransform:(Z,O)=>{if(Z===!0)return X[0]||"true";else return Y[0]||"false"},error:Q.error});return L}function v4($,J,Q,X={}){let Y=D(X),W={...D(X),check:"string_format",type:"string",format:J,fn:typeof Q==="function"?Q:(B)=>Q.test(B),...Y};if(Q instanceof RegExp)W.pattern=Q;return new $(W)}var f4=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")},ZY=()=>f4,G8=()=>f4,h4=f4,n=f4,k4=f4,g4=f4;var db={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},LY=($,J,Q,X)=>{let Y=Q;Y.type="string";let{minimum:W,maximum:K,format:B,patterns:q,contentEncoding:U}=$._zod.bag;if(typeof W==="number")Y.minLength=W;if(typeof K==="number")Y.maxLength=K;if(B){if(Y.format=db[B]??B,Y.format==="")delete Y.format;if(B==="time")delete Y.format}if(U)Y.contentEncoding=U;if(q&&q.size>0){let G=[...q];if(G.length===1)Y.pattern=G[0].source;else if(G.length>1)Y.allOf=[...G.map((H)=>({...J.target==="draft-07"||J.target==="draft-04"||J.target==="openapi-3.0"?{type:"string"}:{},pattern:H.source}))]}},OY=($,J,Q,X)=>{let Y=Q,{minimum:W,maximum:K,format:B,multipleOf:q,exclusiveMaximum:U,exclusiveMinimum:G}=$._zod.bag;if(typeof B==="string"&&B.includes("int"))Y.type="integer";else Y.type="number";if(typeof G==="number")if(J.target==="draft-04"||J.target==="openapi-3.0")Y.minimum=G,Y.exclusiveMinimum=!0;else Y.exclusiveMinimum=G;if(typeof W==="number"){if(Y.minimum=W,typeof G==="number"&&J.target!=="draft-04")if(G>=W)delete Y.minimum;else delete Y.exclusiveMinimum}if(typeof U==="number")if(J.target==="draft-04"||J.target==="openapi-3.0")Y.maximum=U,Y.exclusiveMaximum=!0;else Y.exclusiveMaximum=U;if(typeof K==="number"){if(Y.maximum=K,typeof U==="number"&&J.target!=="draft-04")if(U<=K)delete Y.maximum;else delete Y.exclusiveMaximum}if(typeof q==="number")Y.multipleOf=q},MY=($,J,Q,X)=>{Q.type="boolean"},NY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},FY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},VY=($,J,Q,X)=>{if(J.target==="openapi-3.0")Q.type="string",Q.nullable=!0,Q.enum=[null];else Q.type="null"},_Y=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},DY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},zY=($,J,Q,X)=>{Q.not={}},IY=($,J,Q,X)=>{},jY=($,J,Q,X)=>{},RY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},bY=($,J,Q,X)=>{let Y=$._zod.def,W=h3(Y.entries);if(W.every((K)=>typeof K==="number"))Q.type="number";if(W.every((K)=>typeof K==="string"))Q.type="string";Q.enum=W},PY=($,J,Q,X)=>{let Y=$._zod.def,W=[];for(let K of Y.values)if(K===void 0){if(J.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof K==="bigint")if(J.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else W.push(Number(K));else W.push(K);if(W.length===0);else if(W.length===1){let K=W[0];if(Q.type=K===null?"null":typeof K,J.target==="draft-04"||J.target==="openapi-3.0")Q.enum=[K];else Q.const=K}else{if(W.every((K)=>typeof K==="number"))Q.type="number";if(W.every((K)=>typeof K==="string"))Q.type="string";if(W.every((K)=>typeof K==="boolean"))Q.type="boolean";if(W.every((K)=>K===null))Q.type="null";Q.enum=W}},AY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},EY=($,J,Q,X)=>{let Y=Q,W=$._zod.pattern;if(!W)throw Error("Pattern not found in template literal");Y.type="string",Y.pattern=W.source},SY=($,J,Q,X)=>{let Y=Q,W={type:"string",format:"binary",contentEncoding:"binary"},{minimum:K,maximum:B,mime:q}=$._zod.bag;if(K!==void 0)W.minLength=K;if(B!==void 0)W.maxLength=B;if(q)if(q.length===1)W.contentMediaType=q[0],Object.assign(Y,W);else Object.assign(Y,W),Y.anyOf=q.map((U)=>({contentMediaType:U}));else Object.assign(Y,W)},CY=($,J,Q,X)=>{Q.type="boolean"},TY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},wY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},vY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},fY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},hY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},kY=($,J,Q,X)=>{let Y=Q,W=$._zod.def,{minimum:K,maximum:B}=$._zod.bag;if(typeof K==="number")Y.minItems=K;if(typeof B==="number")Y.maxItems=B;Y.type="array",Y.items=n(W.element,J,{...X,path:[...X.path,"items"]})},gY=($,J,Q,X)=>{let Y=Q,W=$._zod.def;Y.type="object",Y.properties={};let K=W.shape;for(let U in K)Y.properties[U]=n(K[U],J,{...X,path:[...X.path,"properties",U]});let B=new Set(Object.keys(K)),q=new Set([...B].filter((U)=>{let G=W.shape[U]._zod;if(J.io==="input")return G.optin===void 0;else return G.optout===void 0}));if(q.size>0)Y.required=Array.from(q);if(W.catchall?._zod.def.type==="never")Y.additionalProperties=!1;else if(!W.catchall){if(J.io==="output")Y.additionalProperties=!1}else if(W.catchall)Y.additionalProperties=n(W.catchall,J,{...X,path:[...X.path,"additionalProperties"]})},Z8=($,J,Q,X)=>{let Y=$._zod.def,W=Y.inclusive===!1,K=Y.options.map((B,q)=>n(B,J,{...X,path:[...X.path,W?"oneOf":"anyOf",q]}));if(W)Q.oneOf=K;else Q.anyOf=K},yY=($,J,Q,X)=>{let Y=$._zod.def,W=n(Y.left,J,{...X,path:[...X.path,"allOf",0]}),K=n(Y.right,J,{...X,path:[...X.path,"allOf",1]}),B=(U)=>("allOf"in U)&&Object.keys(U).length===1,q=[...B(W)?W.allOf:[W],...B(K)?K.allOf:[K]];Q.allOf=q},xY=($,J,Q,X)=>{let Y=Q,W=$._zod.def;Y.type="array";let K=J.target==="draft-2020-12"?"prefixItems":"items",B=J.target==="draft-2020-12"?"items":J.target==="openapi-3.0"?"items":"additionalItems",q=W.items.map((L,Z)=>n(L,J,{...X,path:[...X.path,K,Z]})),U=W.rest?n(W.rest,J,{...X,path:[...X.path,B,...J.target==="openapi-3.0"?[W.items.length]:[]]}):null;if(J.target==="draft-2020-12"){if(Y.prefixItems=q,U)Y.items=U}else if(J.target==="openapi-3.0"){if(Y.items={anyOf:q},U)Y.items.anyOf.push(U);if(Y.minItems=q.length,!U)Y.maxItems=q.length}else if(Y.items=q,U)Y.additionalItems=U;let{minimum:G,maximum:H}=$._zod.bag;if(typeof G==="number")Y.minItems=G;if(typeof H==="number")Y.maxItems=H},uY=($,J,Q,X)=>{let Y=Q,W=$._zod.def;Y.type="object";let K=W.keyType,q=K._zod.bag?.patterns;if(W.mode==="loose"&&q&&q.size>0){let G=n(W.valueType,J,{...X,path:[...X.path,"patternProperties","*"]});Y.patternProperties={};for(let H of q)Y.patternProperties[H.source]=G}else{if(J.target==="draft-07"||J.target==="draft-2020-12")Y.propertyNames=n(W.keyType,J,{...X,path:[...X.path,"propertyNames"]});Y.additionalProperties=n(W.valueType,J,{...X,path:[...X.path,"additionalProperties"]})}let U=K._zod.values;if(U){let G=[...U].filter((H)=>typeof H==="string"||typeof H==="number");if(G.length>0)Y.required=G}},mY=($,J,Q,X)=>{let Y=$._zod.def,W=n(Y.innerType,J,X),K=J.seen.get($);if(J.target==="openapi-3.0")K.ref=Y.innerType,Q.nullable=!0;else Q.anyOf=[W,{type:"null"}]},lY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType},pY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType,Q.default=JSON.parse(JSON.stringify(Y.defaultValue))},cY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);if(W.ref=Y.innerType,J.io==="input")Q._prefault=JSON.parse(JSON.stringify(Y.defaultValue))},dY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType;let K;try{K=Y.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}Q.default=K},rY=($,J,Q,X)=>{let Y=$._zod.def,W=J.io==="input"?Y.in._zod.def.type==="transform"?Y.out:Y.in:Y.out;n(W,J,X);let K=J.seen.get($);K.ref=W},iY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType,Q.readOnly=!0},oY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType},L8=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType},nY=($,J,Q,X)=>{let Y=$._zod.innerType;n(Y,J,X);let W=J.seen.get($);W.ref=Y},H8={string:LY,number:OY,boolean:MY,bigint:NY,symbol:FY,null:VY,undefined:_Y,void:DY,never:zY,any:IY,unknown:jY,date:RY,enum:bY,literal:PY,nan:AY,template_literal:EY,file:SY,success:CY,custom:TY,function:wY,transform:vY,map:fY,set:hY,array:kY,object:gY,union:Z8,intersection:yY,tuple:xY,record:uY,nullable:mY,nonoptional:lY,default:pY,prefault:cY,catch:dY,pipe:rY,readonly:iY,promise:oY,optional:L8,lazy:nY};function a3($,J){if("_idmap"in $){let X=$,Y=h4({...J,processors:H8}),W={};for(let q of X._idmap.entries()){let[U,G]=q;n(G,Y)}let K={},B={registry:X,uri:J?.uri,defs:W};Y.external=B;for(let q of X._idmap.entries()){let[U,G]=q;k4(Y,G),K[U]=g4(Y,G)}if(Object.keys(W).length>0){let q=Y.target==="draft-2020-12"?"$defs":"definitions";K.__shared={[q]:W}}return{schemas:K}}let Q=h4({...J,processors:H8});return n($,Q),k4(Q,$),g4(Q,$)}class sY{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter($){this.ctx.counter=$}get seen(){return this.ctx.seen}constructor($){let J=$?.target??"draft-2020-12";if(J==="draft-4")J="draft-04";if(J==="draft-7")J="draft-07";this.ctx=h4({processors:H8,target:J,...$?.metadata&&{metadata:$.metadata},...$?.unrepresentable&&{unrepresentable:$.unrepresentable},...$?.override&&{override:$.override},...$?.io&&{io:$.io}})}process($,J={path:[],schemaPath:[]}){return n($,this.ctx,J)}emit($,J){if(J){if(J.cycles)this.ctx.cycles=J.cycles;if(J.reused)this.ctx.reused=J.reused;if(J.external)this.ctx.external=J.external}k4(this.ctx,$);let Q=g4(this.ctx,$),{"~standard":X,...Y}=Q;return Y}}var fH={};var Q6={};B2(Q6,{time:()=>eY,duration:()=>$W,datetime:()=>aY,date:()=>tY,ZodISOTime:()=>$6,ZodISODuration:()=>J6,ZodISODateTime:()=>t3,ZodISODate:()=>e3});var t3=N("ZodISODateTime",($,J)=>{SX.init($,J),r.init($,J)});function aY($){return T5(t3,$)}var e3=N("ZodISODate",($,J)=>{CX.init($,J),r.init($,J)});function tY($){return w5(e3,$)}var $6=N("ZodISOTime",($,J)=>{TX.init($,J),r.init($,J)});function eY($){return v5($6,$)}var J6=N("ZodISODuration",($,J)=>{wX.init($,J),r.init($,J)});function $W($){return f5(J6,$)}var kH=($,J)=>{u3.init($,J),$.name="ZodError",Object.defineProperties($,{format:{value:(Q)=>M4($,Q)},flatten:{value:(Q)=>O4($,Q)},addIssue:{value:(Q)=>{$.issues.push(Q),$.message=JSON.stringify($.issues,H4,2)}},addIssues:{value:(Q)=>{$.issues.push(...Q),$.message=JSON.stringify($.issues,H4,2)}},isEmpty:{get(){return $.issues.length===0}}})},gH=N("ZodError",kH),z1=N("ZodError",kH,{Parent:Error});var O8=N4(z1),M8=F4(z1),N8=V4(z1),F8=_4(z1),V8=M$(z1),_8=N$(z1),D8=F$(z1),z8=V$(z1),I8=_$(z1),j8=D$(z1),R8=z$(z1),b8=I$(z1);var g=N("ZodType",($,J)=>{return v.init($,J),Object.assign($["~standard"],{jsonSchema:{input:G8($,"input"),output:G8($,"output")}}),$.toJSONSchema=ZY($,{}),$.def=J,$.type=J.type,Object.defineProperty($,"_def",{value:J}),$.check=(...Q)=>{return $.clone(w.mergeDefs(J,{checks:[...J.checks??[],...Q.map((X)=>typeof X==="function"?{_zod:{check:X,def:{check:"custom"},onattach:[]}}:X)]}),{parent:!0})},$.with=$.check,$.clone=(Q,X)=>N1($,Q,X),$.brand=()=>$,$.register=(Q,X)=>{return Q.add($,X),$},$.parse=(Q,X)=>O8($,Q,X,{callee:$.parse}),$.safeParse=(Q,X)=>N8($,Q,X),$.parseAsync=async(Q,X)=>M8($,Q,X,{callee:$.parseAsync}),$.safeParseAsync=async(Q,X)=>F8($,Q,X),$.spa=$.safeParseAsync,$.encode=(Q,X)=>V8($,Q,X),$.decode=(Q,X)=>_8($,Q,X),$.encodeAsync=async(Q,X)=>D8($,Q,X),$.decodeAsync=async(Q,X)=>z8($,Q,X),$.safeEncode=(Q,X)=>I8($,Q,X),$.safeDecode=(Q,X)=>j8($,Q,X),$.safeEncodeAsync=async(Q,X)=>R8($,Q,X),$.safeDecodeAsync=async(Q,X)=>b8($,Q,X),$.refine=(Q,X)=>$.check(cW(Q,X)),$.superRefine=(Q)=>$.check(dW(Q)),$.overwrite=(Q)=>$.check(Q0(Q)),$.optional=()=>Y6($),$.exactOptional=()=>PW($),$.nullable=()=>W6($),$.nullish=()=>Y6(W6($)),$.nonoptional=(Q)=>wW($,Q),$.array=()=>U6($),$.or=(Q)=>i8([$,Q]),$.and=(Q)=>NW($,Q),$.transform=(Q)=>K6($,n8(Q)),$.default=(Q)=>SW($,Q),$.prefault=(Q)=>TW($,Q),$.catch=(Q)=>hW($,Q),$.pipe=(Q)=>K6($,Q),$.readonly=()=>yW($),$.describe=(Q)=>{let X=$.clone();return E1.add(X,{description:Q}),X},Object.defineProperty($,"description",{get(){return E1.get($)?.description},configurable:!0}),$.meta=(...Q)=>{if(Q.length===0)return E1.get($);let X=$.clone();return E1.add(X,Q[0]),X},$.isOptional=()=>$.safeParse(void 0).success,$.isNullable=()=>$.safeParse(null).success,$.apply=(Q)=>Q($),$}),E8=N("_ZodString",($,J)=>{w2.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>LY($,X,Y,W);let Q=$._zod.bag;$.format=Q.format??null,$.minLength=Q.minimum??null,$.maxLength=Q.maximum??null,$.regex=(...X)=>$.check(z4(...X)),$.includes=(...X)=>$.check(R4(...X)),$.startsWith=(...X)=>$.check(b4(...X)),$.endsWith=(...X)=>$.check(P4(...X)),$.min=(...X)=>$.check(y0(...X)),$.max=(...X)=>$.check(f2(...X)),$.length=(...X)=>$.check(h2(...X)),$.nonempty=(...X)=>$.check(y0(1,...X)),$.lowercase=(X)=>$.check(I4(X)),$.uppercase=(X)=>$.check(j4(X)),$.trim=()=>$.check(S4()),$.normalize=(...X)=>$.check(E4(...X)),$.toLowerCase=()=>$.check(C4()),$.toUpperCase=()=>$.check(T4()),$.slugify=()=>$.check(w4())}),x4=N("ZodString",($,J)=>{w2.init($,J),E8.init($,J),$.email=(Q)=>$.check(y$(S8,Q)),$.url=(Q)=>$.check(s3(B6,Q)),$.jwt=(Q)=>$.check(X8(c8,Q)),$.emoji=(Q)=>$.check(p$(C8,Q)),$.guid=(Q)=>$.check(n3(X6,Q)),$.uuid=(Q)=>$.check(x$(I0,Q)),$.uuidv4=(Q)=>$.check(u$(I0,Q)),$.uuidv6=(Q)=>$.check(m$(I0,Q)),$.uuidv7=(Q)=>$.check(l$(I0,Q)),$.nanoid=(Q)=>$.check(c$(T8,Q)),$.guid=(Q)=>$.check(n3(X6,Q)),$.cuid=(Q)=>$.check(d$(w8,Q)),$.cuid2=(Q)=>$.check(r$(v8,Q)),$.ulid=(Q)=>$.check(i$(f8,Q)),$.base64=(Q)=>$.check($8(m8,Q)),$.base64url=(Q)=>$.check(J8(l8,Q)),$.xid=(Q)=>$.check(o$(h8,Q)),$.ksuid=(Q)=>$.check(n$(k8,Q)),$.ipv4=(Q)=>$.check(s$(g8,Q)),$.ipv6=(Q)=>$.check(a$(y8,Q)),$.cidrv4=(Q)=>$.check(t$(x8,Q)),$.cidrv6=(Q)=>$.check(e$(u8,Q)),$.e164=(Q)=>$.check(Q8(p8,Q)),$.datetime=(Q)=>$.check(aY(Q)),$.date=(Q)=>$.check(tY(Q)),$.time=(Q)=>$.check(eY(Q)),$.duration=(Q)=>$.check($W(Q))});function P8($){return E5(x4,$)}var r=N("ZodStringFormat",($,J)=>{d.init($,J),E8.init($,J)}),S8=N("ZodEmail",($,J)=>{DX.init($,J),r.init($,J)});function yH($){return y$(S8,$)}var X6=N("ZodGUID",($,J)=>{VX.init($,J),r.init($,J)});function xH($){return n3(X6,$)}var I0=N("ZodUUID",($,J)=>{_X.init($,J),r.init($,J)});function uH($){return x$(I0,$)}function mH($){return u$(I0,$)}function lH($){return m$(I0,$)}function pH($){return l$(I0,$)}var B6=N("ZodURL",($,J)=>{zX.init($,J),r.init($,J)});function cH($){return s3(B6,$)}function dH($){return s3(B6,{protocol:/^https?$/,hostname:y1.domain,...w.normalizeParams($)})}var C8=N("ZodEmoji",($,J)=>{IX.init($,J),r.init($,J)});function rH($){return p$(C8,$)}var T8=N("ZodNanoID",($,J)=>{jX.init($,J),r.init($,J)});function iH($){return c$(T8,$)}var w8=N("ZodCUID",($,J)=>{RX.init($,J),r.init($,J)});function oH($){return d$(w8,$)}var v8=N("ZodCUID2",($,J)=>{bX.init($,J),r.init($,J)});function nH($){return r$(v8,$)}var f8=N("ZodULID",($,J)=>{PX.init($,J),r.init($,J)});function sH($){return i$(f8,$)}var h8=N("ZodXID",($,J)=>{AX.init($,J),r.init($,J)});function aH($){return o$(h8,$)}var k8=N("ZodKSUID",($,J)=>{EX.init($,J),r.init($,J)});function tH($){return n$(k8,$)}var g8=N("ZodIPv4",($,J)=>{vX.init($,J),r.init($,J)});function eH($){return s$(g8,$)}var JW=N("ZodMAC",($,J)=>{hX.init($,J),r.init($,J)});function $Z($){return C5(JW,$)}var y8=N("ZodIPv6",($,J)=>{fX.init($,J),r.init($,J)});function JZ($){return a$(y8,$)}var x8=N("ZodCIDRv4",($,J)=>{kX.init($,J),r.init($,J)});function QZ($){return t$(x8,$)}var u8=N("ZodCIDRv6",($,J)=>{gX.init($,J),r.init($,J)});function XZ($){return e$(u8,$)}var m8=N("ZodBase64",($,J)=>{xX.init($,J),r.init($,J)});function YZ($){return $8(m8,$)}var l8=N("ZodBase64URL",($,J)=>{uX.init($,J),r.init($,J)});function WZ($){return J8(l8,$)}var p8=N("ZodE164",($,J)=>{mX.init($,J),r.init($,J)});function KZ($){return Q8(p8,$)}var c8=N("ZodJWT",($,J)=>{lX.init($,J),r.init($,J)});function BZ($){return X8(c8,$)}var u4=N("ZodCustomStringFormat",($,J)=>{pX.init($,J),r.init($,J)});function qZ($,J,Q={}){return v4(u4,$,J,Q)}function UZ($){return v4(u4,"hostname",y1.hostname,$)}function GZ($){return v4(u4,"hex",y1.hex,$)}function HZ($,J){let Q=J?.enc??"hex",X=`${$}_${Q}`,Y=y1[X];if(!Y)throw Error(`Unrecognized hash format: ${X}`);return v4(u4,X,Y,J)}var m4=N("ZodNumber",($,J)=>{w$.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>OY($,X,Y,W),$.gt=(X,Y)=>$.check(_0(X,Y)),$.gte=(X,Y)=>$.check(D1(X,Y)),$.min=(X,Y)=>$.check(D1(X,Y)),$.lt=(X,Y)=>$.check(V0(X,Y)),$.lte=(X,Y)=>$.check(x1(X,Y)),$.max=(X,Y)=>$.check(x1(X,Y)),$.int=(X)=>$.check(A8(X)),$.safe=(X)=>$.check(A8(X)),$.positive=(X)=>$.check(_0(0,X)),$.nonnegative=(X)=>$.check(D1(0,X)),$.negative=(X)=>$.check(V0(0,X)),$.nonpositive=(X)=>$.check(x1(0,X)),$.multipleOf=(X,Y)=>$.check(Y2(X,Y)),$.step=(X,Y)=>$.check(Y2(X,Y)),$.finite=()=>$;let Q=$._zod.bag;$.minValue=Math.max(Q.minimum??Number.NEGATIVE_INFINITY,Q.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,$.maxValue=Math.min(Q.maximum??Number.POSITIVE_INFINITY,Q.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,$.isInt=(Q.format??"").includes("int")||Number.isSafeInteger(Q.multipleOf??0.5),$.isFinite=!0,$.format=Q.format??null});function QW($){return h5(m4,$)}var g2=N("ZodNumberFormat",($,J)=>{cX.init($,J),m4.init($,J)});function A8($){return g5(g2,$)}function ZZ($){return y5(g2,$)}function LZ($){return x5(g2,$)}function OZ($){return u5(g2,$)}function MZ($){return m5(g2,$)}var l4=N("ZodBoolean",($,J)=>{c3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>MY($,Q,X,Y)});function XW($){return l5(l4,$)}var p4=N("ZodBigInt",($,J)=>{v$.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>NY($,X,Y,W),$.gte=(X,Y)=>$.check(D1(X,Y)),$.min=(X,Y)=>$.check(D1(X,Y)),$.gt=(X,Y)=>$.check(_0(X,Y)),$.gte=(X,Y)=>$.check(D1(X,Y)),$.min=(X,Y)=>$.check(D1(X,Y)),$.lt=(X,Y)=>$.check(V0(X,Y)),$.lte=(X,Y)=>$.check(x1(X,Y)),$.max=(X,Y)=>$.check(x1(X,Y)),$.positive=(X)=>$.check(_0(BigInt(0),X)),$.negative=(X)=>$.check(V0(BigInt(0),X)),$.nonpositive=(X)=>$.check(x1(BigInt(0),X)),$.nonnegative=(X)=>$.check(D1(BigInt(0),X)),$.multipleOf=(X,Y)=>$.check(Y2(X,Y));let Q=$._zod.bag;$.minValue=Q.minimum??null,$.maxValue=Q.maximum??null,$.format=Q.format??null});function NZ($){return c5(p4,$)}var d8=N("ZodBigIntFormat",($,J)=>{dX.init($,J),p4.init($,J)});function FZ($){return r5(d8,$)}function VZ($){return i5(d8,$)}var YW=N("ZodSymbol",($,J)=>{rX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>FY($,Q,X,Y)});function _Z($){return o5(YW,$)}var WW=N("ZodUndefined",($,J)=>{iX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>_Y($,Q,X,Y)});function DZ($){return n5(WW,$)}var KW=N("ZodNull",($,J)=>{oX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>VY($,Q,X,Y)});function BW($){return s5(KW,$)}var qW=N("ZodAny",($,J)=>{nX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>IY($,Q,X,Y)});function zZ(){return a5(qW)}var UW=N("ZodUnknown",($,J)=>{sX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>jY($,Q,X,Y)});function k2(){return t5(UW)}var GW=N("ZodNever",($,J)=>{aX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>zY($,Q,X,Y)});function r8($){return e5(GW,$)}var HW=N("ZodVoid",($,J)=>{tX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>DY($,Q,X,Y)});function IZ($){return $Y(HW,$)}var q6=N("ZodDate",($,J)=>{eX.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>RY($,X,Y,W),$.min=(X,Y)=>$.check(D1(X,Y)),$.max=(X,Y)=>$.check(x1(X,Y));let Q=$._zod.bag;$.minDate=Q.minimum?new Date(Q.minimum):null,$.maxDate=Q.maximum?new Date(Q.maximum):null});function jZ($){return JY(q6,$)}var ZW=N("ZodArray",($,J)=>{$5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>kY($,Q,X,Y),$.element=J.element,$.min=(Q,X)=>$.check(y0(Q,X)),$.nonempty=(Q)=>$.check(y0(1,Q)),$.max=(Q,X)=>$.check(f2(Q,X)),$.length=(Q,X)=>$.check(h2(Q,X)),$.unwrap=()=>$.element});function U6($,J){return YY(ZW,$,J)}function RZ($){let J=$._zod.def.shape;return o8(Object.keys(J))}var G6=N("ZodObject",($,J)=>{J5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>gY($,Q,X,Y),w.defineLazy($,"shape",()=>{return J.shape}),$.keyof=()=>o8(Object.keys($._zod.def.shape)),$.catchall=(Q)=>$.clone({...$._zod.def,catchall:Q}),$.passthrough=()=>$.clone({...$._zod.def,catchall:k2()}),$.loose=()=>$.clone({...$._zod.def,catchall:k2()}),$.strict=()=>$.clone({...$._zod.def,catchall:r8()}),$.strip=()=>$.clone({...$._zod.def,catchall:void 0}),$.extend=(Q)=>{return w.extend($,Q)},$.safeExtend=(Q)=>{return w.safeExtend($,Q)},$.merge=(Q)=>w.merge($,Q),$.pick=(Q)=>w.pick($,Q),$.omit=(Q)=>w.omit($,Q),$.partial=(...Q)=>w.partial(s8,$,Q[0]),$.required=(...Q)=>w.required(a8,$,Q[0])});function bZ($,J){let Q={type:"object",shape:$??{},...w.normalizeParams(J)};return new G6(Q)}function PZ($,J){return new G6({type:"object",shape:$,catchall:r8(),...w.normalizeParams(J)})}function AZ($,J){return new G6({type:"object",shape:$,catchall:k2(),...w.normalizeParams(J)})}var H6=N("ZodUnion",($,J)=>{d3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>Z8($,Q,X,Y),$.options=J.options});function i8($,J){return new H6({type:"union",options:$,...w.normalizeParams(J)})}var LW=N("ZodXor",($,J)=>{H6.init($,J),Q5.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>Z8($,Q,X,Y),$.options=J.options});function EZ($,J){return new LW({type:"union",options:$,inclusive:!1,...w.normalizeParams(J)})}var OW=N("ZodDiscriminatedUnion",($,J)=>{H6.init($,J),X5.init($,J)});function SZ($,J,Q){return new OW({type:"union",options:J,discriminator:$,...w.normalizeParams(Q)})}var MW=N("ZodIntersection",($,J)=>{Y5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>yY($,Q,X,Y)});function NW($,J){return new MW({type:"intersection",left:$,right:J})}var FW=N("ZodTuple",($,J)=>{f$.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>xY($,Q,X,Y),$.rest=(Q)=>$.clone({...$._zod.def,rest:Q})});function VW($,J,Q){let X=J instanceof v,Y=X?Q:J;return new FW({type:"tuple",items:$,rest:X?J:null,...w.normalizeParams(Y)})}var Z6=N("ZodRecord",($,J)=>{W5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>uY($,Q,X,Y),$.keyType=J.keyType,$.valueType=J.valueType});function _W($,J,Q){return new Z6({type:"record",keyType:$,valueType:J,...w.normalizeParams(Q)})}function CZ($,J,Q){let X=N1($);return X._zod.values=void 0,new Z6({type:"record",keyType:X,valueType:J,...w.normalizeParams(Q)})}function TZ($,J,Q){return new Z6({type:"record",keyType:$,valueType:J,mode:"loose",...w.normalizeParams(Q)})}var DW=N("ZodMap",($,J)=>{K5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>fY($,Q,X,Y),$.keyType=J.keyType,$.valueType=J.valueType,$.min=(...Q)=>$.check(D0(...Q)),$.nonempty=(Q)=>$.check(D0(1,Q)),$.max=(...Q)=>$.check(W2(...Q)),$.size=(...Q)=>$.check(v2(...Q))});function wZ($,J,Q){return new DW({type:"map",keyType:$,valueType:J,...w.normalizeParams(Q)})}var zW=N("ZodSet",($,J)=>{B5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>hY($,Q,X,Y),$.min=(...Q)=>$.check(D0(...Q)),$.nonempty=(Q)=>$.check(D0(1,Q)),$.max=(...Q)=>$.check(W2(...Q)),$.size=(...Q)=>$.check(v2(...Q))});function vZ($,J){return new zW({type:"set",valueType:$,...w.normalizeParams(J)})}var y4=N("ZodEnum",($,J)=>{q5.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>bY($,X,Y,W),$.enum=J.entries,$.options=Object.values(J.entries);let Q=new Set(Object.keys(J.entries));$.extract=(X,Y)=>{let W={};for(let K of X)if(Q.has(K))W[K]=J.entries[K];else throw Error(`Key ${K} not found in enum`);return new y4({...J,checks:[],...w.normalizeParams(Y),entries:W})},$.exclude=(X,Y)=>{let W={...J.entries};for(let K of X)if(Q.has(K))delete W[K];else throw Error(`Key ${K} not found in enum`);return new y4({...J,checks:[],...w.normalizeParams(Y),entries:W})}});function o8($,J){let Q=Array.isArray($)?Object.fromEntries($.map((X)=>[X,X])):$;return new y4({type:"enum",entries:Q,...w.normalizeParams(J)})}function fZ($,J){return new y4({type:"enum",entries:$,...w.normalizeParams(J)})}var IW=N("ZodLiteral",($,J)=>{U5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>PY($,Q,X,Y),$.values=new Set(J.values),Object.defineProperty($,"value",{get(){if(J.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return J.values[0]}})});function hZ($,J){return new IW({type:"literal",values:Array.isArray($)?$:[$],...w.normalizeParams(J)})}var jW=N("ZodFile",($,J)=>{G5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>SY($,Q,X,Y),$.min=(Q,X)=>$.check(D0(Q,X)),$.max=(Q,X)=>$.check(W2(Q,X)),$.mime=(Q,X)=>$.check(A4(Array.isArray(Q)?Q:[Q],X))});function kZ($){return WY(jW,$)}var RW=N("ZodTransform",($,J)=>{H5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>vY($,Q,X,Y),$._zod.parse=(Q,X)=>{if(X.direction==="backward")throw new S2($.constructor.name);Q.addIssue=(W)=>{if(typeof W==="string")Q.issues.push(w.issue(W,Q.value,J));else{let K=W;if(K.fatal)K.continue=!1;K.code??(K.code="custom"),K.input??(K.input=Q.value),K.inst??(K.inst=$),Q.issues.push(w.issue(K))}};let Y=J.transform(Q.value,Q);if(Y instanceof Promise)return Y.then((W)=>{return Q.value=W,Q});return Q.value=Y,Q}});function n8($){return new RW({type:"transform",transform:$})}var s8=N("ZodOptional",($,J)=>{h$.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>L8($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function Y6($){return new s8({type:"optional",innerType:$})}var bW=N("ZodExactOptional",($,J)=>{Z5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>L8($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function PW($){return new bW({type:"optional",innerType:$})}var AW=N("ZodNullable",($,J)=>{L5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>mY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function W6($){return new AW({type:"nullable",innerType:$})}function gZ($){return Y6(W6($))}var EW=N("ZodDefault",($,J)=>{O5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>pY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function SW($,J){return new EW({type:"default",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var CW=N("ZodPrefault",($,J)=>{M5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>cY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function TW($,J){return new CW({type:"prefault",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var a8=N("ZodNonOptional",($,J)=>{N5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>lY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function wW($,J){return new a8({type:"nonoptional",innerType:$,...w.normalizeParams(J)})}var vW=N("ZodSuccess",($,J)=>{F5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>CY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function yZ($){return new vW({type:"success",innerType:$})}var fW=N("ZodCatch",($,J)=>{V5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>dY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType,$.removeCatch=$.unwrap});function hW($,J){return new fW({type:"catch",innerType:$,catchValue:typeof J==="function"?J:()=>J})}var kW=N("ZodNaN",($,J)=>{_5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>AY($,Q,X,Y)});function xZ($){return XY(kW,$)}var t8=N("ZodPipe",($,J)=>{D5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>rY($,Q,X,Y),$.in=J.in,$.out=J.out});function K6($,J){return new t8({type:"pipe",in:$,out:J})}var e8=N("ZodCodec",($,J)=>{t8.init($,J),r3.init($,J)});function uZ($,J,Q){return new e8({type:"pipe",in:$,out:J,transform:Q.decode,reverseTransform:Q.encode})}var gW=N("ZodReadonly",($,J)=>{z5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>iY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function yW($){return new gW({type:"readonly",innerType:$})}var xW=N("ZodTemplateLiteral",($,J)=>{I5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>EY($,Q,X,Y)});function mZ($,J){return new xW({type:"template_literal",parts:$,...w.normalizeParams(J)})}var uW=N("ZodLazy",($,J)=>{b5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>nY($,Q,X,Y),$.unwrap=()=>$._zod.def.getter()});function mW($){return new uW({type:"lazy",getter:$})}var lW=N("ZodPromise",($,J)=>{R5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>oY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function lZ($){return new lW({type:"promise",innerType:$})}var pW=N("ZodFunction",($,J)=>{j5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>wY($,Q,X,Y)});function pZ($){return new pW({type:"function",input:Array.isArray($?.input)?VW($?.input):$?.input??U6(k2()),output:$?.output??k2()})}var L6=N("ZodCustom",($,J)=>{P5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>TY($,Q,X,Y)});function cZ($){let J=new o({check:"custom"});return J._zod.check=$,J}function dZ($,J){return KY(L6,$??(()=>!0),J)}function cW($,J={}){return BY(L6,$,J)}function dW($){return qY($)}var rZ=UY,iZ=GY;function oZ($,J={}){let Q=new L6({type:"custom",check:"custom",fn:(X)=>X instanceof $,abort:!0,...w.normalizeParams(J)});return Q._zod.bag.Class=$,Q._zod.check=(X)=>{if(!(X.value instanceof $))X.issues.push({code:"invalid_type",expected:$.name,input:X.value,inst:Q,path:[...Q._zod.def.path??[]]})},Q}var nZ=(...$)=>HY({Codec:e8,Boolean:l4,String:x4},...$);function sZ($){let J=mW(()=>{return i8([P8($),QW(),XW(),BW(),U6(J),_W(P8(),J)])});return J}function aZ($,J){return K6(n8($),J)}var tZ={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function eZ($){Y1({customError:$})}function $L(){return Y1().customError}var $J;(function($){})($J||($J={}));var nb=()=>{let $={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function J(Y){return $[Y]??null}let Q={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},X={nan:"NaN"};return(Y)=>{switch(Y.code){case"invalid_type":{let W=X[Y.expected]??Y.expected,K=z7(Y.input),B=X[K]??K;return`Invalid input: expected ${W}, received ${B}`}case"invalid_value":if(Y.values.length===1)return`Invalid input: expected ${G$(Y.values[0])}`;return`Invalid option: expected one of ${B$(Y.values,"|")}`;case"too_big":{let W=Y.inclusive?"<=":"<",K=J(Y.origin);if(K)return`Too big: expected ${Y.origin??"value"} to have ${W}${Y.maximum.toString()} ${K.unit??"elements"}`;return`Too big: expected ${Y.origin??"value"} to be ${W}${Y.maximum.toString()}`}case"too_small":{let W=Y.inclusive?">=":">",K=J(Y.origin);if(K)return`Too small: expected ${Y.origin} to have ${W}${Y.minimum.toString()} ${K.unit}`;return`Too small: expected ${Y.origin} to be ${W}${Y.minimum.toString()}`}case"invalid_format":{let W=Y;if(W.format==="starts_with")return`Invalid string: must start with "${W.prefix}"`;if(W.format==="ends_with")return`Invalid string: must end with "${W.suffix}"`;if(W.format==="includes")return`Invalid string: must include "${W.includes}"`;if(W.format==="regex")return`Invalid string: must match pattern ${W.pattern}`;return`Invalid ${Q[W.format]??Y.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${Y.divisor}`;case"unrecognized_keys":return`Unrecognized key${Y.keys.length>1?"s":""}: ${B$(Y.keys,", ")}`;case"invalid_key":return`Invalid key in ${Y.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${Y.origin}`;default:return"Invalid input"}}};function rW(){return{localeError:nb()}}var iW=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")};var JJ={};B2(JJ,{string:()=>sb,number:()=>ab,date:()=>$P,boolean:()=>tb,bigint:()=>eb});function sb($){return S5(x4,$)}function ab($){return k5(m4,$)}function tb($){return p5(l4,$)}function eb($){return d5(p4,$)}function $P($){return QY(q6,$)}Y1(rW());var JP=QJ;var JL=Object.freeze(["hard_stop","use_alternative","scope_down","manual_only","stop_and_explain"]);var O6=64,QL="Rule config exceeds CC Safety Net's safe source limit.";var nh=Object.freeze({maxSources:64,concurrency:4,maxRequests:131,maxResponseBytes:67108864});var nW=[{id:"secret.basename.env",category:"Basename",label:".env",description:"Blocks exact .env files.",basename:".env"},{id:"secret.basename.npmrc",category:"Basename",label:".npmrc",description:"Blocks npm credential config files.",basename:".npmrc"},{id:"secret.basename.pypirc",category:"Basename",label:".pypirc",description:"Blocks Python package index credential files.",basename:".pypirc"},{id:"secret.basename.netrc",category:"Basename",label:".netrc",description:"Blocks machine login credential files.",basename:".netrc"},{id:"secret.basename.git-credentials",category:"Basename",label:".git-credentials",description:"Blocks Git credential storage files.",basename:".git-credentials"},{id:"secret.basename.id-rsa",category:"Basename",label:"id_rsa",description:"Blocks RSA private key basenames.",basename:"id_rsa"},{id:"secret.basename.id-ed25519",category:"Basename",label:"id_ed25519",description:"Blocks Ed25519 private key basenames.",basename:"id_ed25519"},{id:"secret.basename.id-ecdsa",category:"Basename",label:"id_ecdsa",description:"Blocks ECDSA private key basenames.",basename:"id_ecdsa"},{id:"secret.basename.credentials",category:"Basename",label:"credentials",description:"Blocks generic credentials file basenames.",basename:"credentials"}],XJ={id:"secret.pattern.env-variant",category:"Pattern",label:".env.*",description:"Blocks environment-specific .env variants."},QP=[".bak",".backup",".copy",".disabled",".old",".orig",".save",".tmp"],XP=[{idSlug:"kube-config",label:"~/.kube/config",directoryParts:[".kube"],basename:"config"},{idSlug:"docker-config",label:"~/.docker/config.json",directoryParts:[".docker"],basename:"config.json"}],sW=[{id:"secret.home.ssh",category:"Home path",label:"~/.ssh",description:"Blocks home SSH configuration and key paths.",suffixParts:[".ssh"]},{id:"secret.home.aws",category:"Home path",label:"~/.aws",description:"Blocks home AWS credential and config paths.",suffixParts:[".aws"]},{id:"secret.home.gcp",category:"Home path",label:"~/.gcp",description:"Blocks home GCP credential paths.",suffixParts:[".gcp"]},{id:"secret.home.gcloud-config",category:"Home path",label:"~/.config/gcloud",description:"Blocks home Google Cloud SDK credential paths.",suffixParts:[".config","gcloud"]},{id:"secret.home.kube-config",category:"Home path",label:"~/.kube/config",description:"Blocks home Kubernetes config files.",suffixParts:[".kube","config"]},{id:"secret.home.docker-config",category:"Home path",label:"~/.docker/config.json",description:"Blocks home Docker credential config files.",suffixParts:[".docker","config.json"]},...XP.flatMap(($)=>QP.map((J)=>({id:["secret.home",$.idSlug,J.slice(1)].join("."),category:"Home path",label:[$.label,J].join(""),description:["Blocks home ",$.label,J," credential backup files."].join(""),suffixParts:[...$.directoryParts,[$.basename,J].join("")]}))),{id:"secret.home.gh-hosts",category:"Home path",label:"~/.config/gh/hosts.yml",description:"Blocks GitHub CLI host credential files.",suffixParts:[".config","gh","hosts.yml"]}];var YJ=[{id:"secret.cli.claude-code",category:"Coding CLI credential",label:"Claude Code credentials",paths:["~/.claude/.credentials.json"]},{id:"secret.cli.claude-code.config",category:"Coding CLI config",label:"Claude Code config",paths:["~/.claude/settings.json","~/.claude/settings.local.json","~/.claude.json","<project>/.claude/settings.local.json","<project>/.mcp.json"]},{id:"secret.cli.antigravity",category:"Coding CLI config",label:"Antigravity CLI hook config",paths:["~/.gemini/config/hooks.json","~/.gemini/config/mcp_config.json"]},{id:"secret.cli.codex",category:"Coding CLI credential",label:"Codex credentials",paths:["~/.codex/auth.json","~/.codex/.credentials.json","~/.codex/secrets","~/.codex/.sandbox-secrets"]},{id:"secret.cli.codex.config",category:"Coding CLI config",label:"Codex config",paths:["~/.codex/config.toml","~/.codex/<name>.config.toml"]},{id:"secret.cli.gemini",category:"Coding CLI credential",label:"Gemini CLI credentials",paths:["~/.gemini/oauth_creds.json","~/.gemini/mcp-oauth-tokens.json","~/.gemini/a2a-oauth-tokens.json","~/.gemini/gemini-credentials.json"]},{id:"secret.cli.gemini.config",category:"Coding CLI config",label:"Gemini CLI config",paths:["~/.gemini/settings.json","~/.gemini/google_accounts.json","<project>/.gemini/settings.json","/Library/Application Support/GeminiCli/settings.json","/etc/gemini-cli/settings.json"]},{id:"secret.cli.copilot-cli",category:"Coding CLI credential",label:"GitHub Copilot CLI credentials",paths:["~/.copilot/config.json","~/.copilot/mcp-oauth-config","~/.copilot/mcp-secrets"]},{id:"secret.cli.copilot-cli.config",category:"Coding CLI config",label:"GitHub Copilot CLI config",paths:["~/.copilot/mcp-config.json"]},{id:"secret.cli.kimi-code",category:"Coding CLI credential",label:"Kimi Code credentials",paths:["~/.kimi-code/server.token","~/.kimi-code/credentials","~/.kimi/credentials","~/.kimi/mcp-oauth"]},{id:"secret.cli.kimi-code.config",category:"Coding CLI config",label:"Kimi Code config",paths:["~/.kimi-code/config.toml","~/.kimi-code/mcp.json","~/.kimi/config.toml","~/.kimi/config.json","~/.kimi/config.json.bak","~/.kimi/mcp.json","<project>/.kimi-code/mcp.json"]},{id:"secret.cli.opencode",category:"Coding CLI credential",label:"OpenCode credentials",paths:["~/.local/share/opencode/auth.json","~/.local/share/opencode/mcp-auth.json","~/.local/share/opencode/opencode.db"]},{id:"secret.cli.opencode.config",category:"Coding CLI config",label:"OpenCode config",paths:["~/.config/opencode/opencode.json","~/.config/opencode/opencode.jsonc","/Library/Application Support/opencode/opencode.json","/etc/opencode/opencode.json","<project>/opencode.json","<project>/opencode.jsonc"]},{id:"secret.cli.pi",category:"Coding CLI credential",label:"Pi credentials",paths:["~/.pi/agent/auth.json"]},{id:"secret.cli.pi.config",category:"Coding CLI config",label:"Pi config",paths:["~/.pi/agent/models.json"]},{id:"secret.cli.amp",category:"Coding CLI credential",label:"Amp Code credentials",paths:["~/.local/share/amp/secrets.json","~/.amp/oauth"]},{id:"secret.cli.amp.config",category:"Coding CLI config",label:"Amp Code config",paths:["~/.config/amp/settings.json","~/.config/amp/settings.jsonc","<project>/.amp/settings.json","<project>/.amp/settings.jsonc"]},{id:"secret.cli.cursor",category:"Coding CLI credential",label:"Cursor CLI credentials",paths:["~/.cursor/auth.json","~/.config/cursor/auth.json","~/.cursor/projects/<name>/mcp-auth.json"]},{id:"secret.cli.cursor.config",category:"Coding CLI config",label:"Cursor CLI config",paths:["~/.cursor/mcp.json","<project>/.cursor/mcp.json"]}],XL=[{prefix:"id_rsa",slug:"id-rsa",label:"id_rsa"},{prefix:"id_dsa",slug:"id-dsa",label:"id_dsa"},{prefix:"id_ed25519",slug:"id-ed25519",label:"id_ed25519"},{prefix:"id_ecdsa",slug:"id-ecdsa",label:"id_ecdsa"},{prefix:"credentials",slug:"credentials",label:"credentials"}],YP=[".bak",".backup",".copy",".disabled",".key",".old",".orig",".pem",".save",".tmp"],aW=XL.map(($)=>({id:`secret.variant.${$.slug}.separator`,category:"Variant",label:`${$.label}-* / ${$.label}_*`,description:`Blocks ${$.label} variants with dash or underscore suffixes.`,prefix:$.prefix})),tW=XL.flatMap(($)=>YP.map((J)=>({id:`secret.variant.${$.slug}.${J.slice(1)}`,category:"Variant",label:`${$.label}${J}`,description:`Blocks ${$.label}${J} private credential variants.`,prefix:$.prefix,suffix:J}))),M6={id:"secret.pattern.ssh-key-basename",category:"Pattern",label:"*_(rsa|dsa|ed25519|ecdsa)",description:"Blocks extensionless SSH private key-like basenames.",pattern:/^.*_(rsa|dsa|ed25519|ecdsa)$/},eW=["agilekeychain","asc","bek","cscfg","fve","gnucash","jks","keychain","kwallet","mdf","ovpn","p12","pcap","pem","pfx","pkcs12","psafe3","rdp","sdf","tblk","tpm"].map(($)=>({id:`secret.ext.${$}`,category:"Extension",label:`.${$}`,description:`Blocks files with the .${$} extension.`,extension:$})),$K=[{id:"secret.ext-pattern.key",category:"Extension pattern",label:".key / .keypair",description:"Blocks key and keypair extension patterns.",pattern:/^key(pair)?$/},{id:"secret.ext-pattern.keystore",category:"Extension pattern",label:".keystore / .keyring",description:"Blocks keystore and keyring extension patterns.",pattern:/^key(store|ring)$/},{id:"secret.ext-pattern.kdbx",category:"Extension pattern",label:".kdb / .kdbx",description:"Blocks KeePass database extension patterns.",pattern:/^kdbx?$/}],YL=[...nW,XJ,...sW,...aW,...tW,M6,...eW,...$K,...YJ].map(($)=>({id:$.id,category:$.category,label:$.label,...$.category==="Coding CLI config"?{defaultOff:!0}:{},..."paths"in $?{paths:$.paths}:{description:$.description}})),WL=new Set(YJ.flatMap(($)=>$.category==="Coding CLI config"?[$.id]:[])),WP=YL.map(($)=>$.id),WJ=new Set(WP);var Uk=KP(import.meta.url),KL,BP=Array(O6+1).fill("over-limit"),BL=/^[^/]+\/[^/]+$/,qP=/^sha256:[a-f0-9]{64}$/,KJ=`must be an integer between ${HJ} and ${ZJ}`,UP=["version","rules","overrides","transparent_wrappers"],GP=["version","safety","workflow","destructive_command_protection","secret_protection","audit"];function qL($){if(!i1($)||!Array.isArray($.rules)||$.rules.length<=O6)return $;return{$schema:$.$schema,version:$.version,rules:BP,overrides:$.overrides,transparent_wrappers:$.transparent_wrappers}}function HP(){let $=oW,J=(_)=>{let R=$.superRefine(_);return R._zod.def.when=()=>!0,R},Q=$.enum(JL),X=$.union([$.literal("off"),$.looseObject({reason:$.string({error:"required non-empty string"}).min(1,"required non-empty string").max(o2,`must be at most ${o2} characters`).describe("Replacement block reason"),intent:Q.optional()})],{error:'must be "off" or an object'}).describe("Disable a rule or replace its block reason and intent."),Y=$.string({error:"must be a rulebook source string"}).min(1,"must be a non-empty rulebook source string"),W=$.string({error:"must be a command string"}).regex(O2,"must match command pattern").describe("Command name such as 'git', 'docker', or 'rtk'."),K=$.looseObject({$schema:$.unknown().optional().describe("JSON Schema reference for IDE support"),version:$.literal(1).describe("Schema version (must be 1)"),rules:$.array(Y,{error:"must be an array of rulebook source strings"}).max(O6,QL).default([]).describe("Rulebook source strings such as project-rules or owner/repo#main/team-rules"),overrides:$.record($.string().meta({pattern:BL.source}),X).default({}).describe("Rule overrides by id"),transparent_wrappers:$.array(W,{error:"must be an array of command strings"}).default([]).describe("Commands that transparently execute a visible protected child command")}),B=(_,R)=>{if(!i1(_))return;if(Array.isArray(_.rules)&&_.rules.length<=O6){let S=new Set;_.rules.forEach((T,y)=>{if(typeof T!=="string"||T==="")return;if(T.trim()===""){R.addIssue({code:"custom",message:"must be a non-empty rulebook source string",path:["rules",y]});return}let x=o4(T);if(x){R.addIssue({code:"custom",message:x,path:["rules",y]});return}if(S.has(T)){R.addIssue({code:"custom",message:`duplicate rulebook source "${T}"`,path:["rules",y]});return}S.add(T)})}if(i1(_.overrides))for(let S of Object.keys(_.overrides)){if(BL.test(S))continue;R.addIssue({code:"custom",message:"must use <rulebook-name>/<rule-name>",path:["overrides",S]})}if(!Array.isArray(_.transparent_wrappers))return;let P=new Set;_.transparent_wrappers.forEach((S,T)=>{if(typeof S!=="string"||!O2.test(S))return;if(P.has(S)){R.addIssue({code:"custom",message:`duplicate command "${S}"`,path:["transparent_wrappers",T]});return}if(LU(S)){R.addIssue({code:"custom",message:`reserved command "${S}" cannot be a wrapper`,path:["transparent_wrappers",T]});return}P.add(S)})},q=$.preprocess(qL,K.check($.superRefine(B))),U=$.preprocess(qL,K.check(J(B))),G=$.strictObject({fail_closed:$.boolean().optional(),paranoid_rm:$.boolean().optional(),paranoid_interpreters:$.boolean().optional()}),H=(_,R)=>$.intersection($.record($.string().refine((P)=>_.has(P),{error:(P)=>`unknown ${R} rule id "${String(P.input)}"`}),$.unknown()),$.record($.string(),$.enum(["on","off"]))),L=(_)=>$.array($.string({error:"must be a non-empty path string"}),{error:"must be an array of paths"}).check(J((R,P)=>{if(!Array.isArray(R))return;let S=c2();R.forEach((T,y)=>{if(typeof T!=="string")return;let x=_(T,S);if(x)P.addIssue({code:"custom",message:x,path:[y]})})})),Z=$.strictObject({version:$.literal(1),safety:$.strictObject({level:$.enum(["standard","strict","paranoid"]).optional(),overrides:G.optional()}).optional(),workflow:$.strictObject({worktree_mode:$.boolean().optional()}).optional(),destructive_command_protection:$.strictObject({enabled:$.boolean().optional(),overrides:H(i6,"destructive command").optional(),allow_paths:L(C9).optional()}).optional(),secret_protection:$.strictObject({enabled:$.boolean().optional(),overrides:H(WJ,"secret protection").optional(),deny_paths:L(T9).optional()}).optional(),audit:$.strictObject({retention_days:$.number({error:KJ}).int(KJ).min(HJ,KJ).max(ZJ,KJ).optional().describe("Days of audit log history to keep before the sweep deletes it")}).optional()}),O=(_)=>{let R=(y,x)=>_==="legacy"?y:x,P=R("must match pattern (letters, numbers, hyphens, underscores)","must match command pattern"),S=`required non-empty string up to ${o2} characters`,T=$.looseObject({name:$.string({error:"required string"}).regex(Y0,R("must match pattern (letters, numbers, hyphens, underscores; max 64 chars)","must match rule name pattern")),command:$.string({error:R("required string","required string matching command pattern")}).regex(O2,R(P,"required string matching command pattern")),subcommand:$.string({error:R("must be a string if provided","must match command pattern")}).regex(O2,P).optional(),block_args:$.array($.string({error:R("must be a string","must be a non-empty string")}).refine((y)=>y!=="",{error:R("must not be empty","must be a non-empty string")}),{error:R("required array","required non-empty array")}).refine((y)=>y.length>0,{error:R("must have at least one element","required non-empty array")}),reason:$.string({error:R("required string",S)}).refine((y)=>y!=="",{error:R("must not be empty",S)}).refine((y)=>y.length<=o2,{error:R(`must be at most ${o2} characters`,S)}),intent:Q.optional()},{error:"must be an object"});return $.array(T,{error:R("must be an array","required array")}).check(J((y,x)=>{if(!Array.isArray(y))return;let c=new Set;y.forEach((V1,C)=>{let m=i1(V1)?V1.name:void 0;if(typeof m!=="string")return;if(c.has(m.toLowerCase())){x.addIssue({code:"custom",message:`duplicate rule name "${m}"`,path:[C,"name"]});return}c.add(m.toLowerCase())})}))},M=$.looseObject({version:$.literal(1),rules:O("legacy").optional()}),V="required string matching rule name pattern",F=$.looseObject({command:$.string({error:"required non-empty string"}).refine((_)=>_.trim()!=="",{error:"required non-empty string"}),expect:$.enum(["blocked","allowed"]),rule:$.string({error:"must be a string if provided"}).optional()},{error:"must be an object"}).check(J((_,R)=>{if(!i1(_))return;if(_.expect!=="blocked"||typeof _.rule==="string")return;R.addIssue({code:"custom",message:"required string for blocked fixtures",path:["rule"]})})),b=$.looseObject({name:$.string({error:"required string matching rule name pattern"}).regex(Y0,"required string matching rule name pattern"),version:$.string({error:"required non-empty string"}).refine((_)=>_!=="",{error:"required non-empty string"}),allowed_commands:$.array($.string({error:"must match command pattern"}).regex(O2,"must match command pattern"),{error:"required array"}).check(J((_,R)=>{if(!Array.isArray(_))return;let P=new Set;_.forEach((S,T)=>{if(typeof S!=="string"||!O2.test(S))return;if(P.has(S)){R.addIssue({code:"custom",message:`duplicate command "${S}"`,path:[T]});return}P.add(S)})})),rules:O("rulebook"),tests:$.array(F,{error:"must be an array if provided"}).optional()}).check(J((_,R)=>{if(!i1(_))return;let P=new Set(JK(_));if(Array.isArray(_.tests)){let T=new Set(_.tests.flatMap((y)=>i1(y)&&y.expect==="blocked"&&typeof y.rule==="string"?[y.rule]:[]));for(let y of T){if(P.has(y))continue;R.addIssue({code:"custom",message:`blocked fixture references unknown rule "${y}"`,path:["tests"]})}}if(!Array.isArray(_.allowed_commands)||!Array.isArray(_.rules))return;let S=new Set(_.allowed_commands.filter((T)=>typeof T==="string"));_.rules.forEach((T,y)=>{let x=i1(T)?T.command:void 0;if(typeof x!=="string"||S.has(x))return;R.addIssue({code:"custom",message:`"${x}" must be listed in allowed_commands`,path:["rules",y,"command"]})})})),I=$.string({error:"required string"}).refine((_)=>_.trim()!=="",{error:"required string"}),A=$.looseObject({spec:I,name:I,version:I,digest:$.string({error:"required sha256 digest"}).regex(qP,"required sha256 digest")},{error:"must be an object"}),E=$.looseObject({rulebooks:$.array($.intersection(A,$.discriminatedUnion("kind",[$.object({kind:$.literal("local-directory"),path:I}),$.object({kind:$.literal("github"),owner:I,repo:I,ref:I,commit:I,path:I,display_ref:$.unknown().optional()})],{error:(_)=>{if(!i1(_.input))return"must be an object";let R=_.input.kind;return typeof R==="string"?`unknown kind "${R}"`:"required string"}})))});return{RulesConfigSchema:q,RulesConfigDiagnosticSchema:U,RuleOverrideSchema:X,UserPolicySchema:Z,LegacyConfigSchema:M,RulebookSchema:b,RulesLockfileSchema:E}}function N6(){return KL??=HP(),KL}function UL(){return N6().RulesConfigSchema}function ZP(){return N6().UserPolicySchema}function GL(){return N6().RulebookSchema}function HL(){return N6().RulesLockfileSchema}function JK($){let J=i1($)?$.rules:void 0;return(Array.isArray(J)?J:[]).flatMap((Q)=>{let X=i1(Q)?Q.name:void 0;return typeof X==="string"?[X]:[]})}function ZL($){let J=N6().RulesConfigDiagnosticSchema.safeParse($);if(J.success)return{errors:[],sources:new Set(J.data.rules)};return{errors:c4(ML(J.error.issues,UP)),sources:NP($,J.error.issues)}}function LL($){let J=ZP().safeParse($);if(J.success)return[];return c4(ML(J.error.issues,GP)," ")}function c4($,J=": ",Q=" "){return[...new Set($.flatMap((X)=>OL(X,J,Q,[])))]}function OL($,J,Q,X){let Y=[...X,...$.path],W=MP(Y);if($.code==="unrecognized_keys")return $.keys.map((K)=>`${W?`${W}.`:""}unknown field "${K}"`);if($.code==="invalid_key")return $.issues.map((K)=>K.message);if($.code==="invalid_union"){let K=$.errors.flat().filter((B)=>B.path.length>0);if(K.length>0)return K.flatMap((B)=>OL(B,J,Q,Y))}if(Y.length===0)return[$.code==="invalid_type"?"Config must be an object":$.message];if(Y.length===1&&($.code==="too_big"||$.code==="too_small")&&$.origin==="array")return[$.message];return[`${W}${Y.length===1?Q:J}${LP($)}`]}function LP($){if($.code==="invalid_value")return`must be ${OP($.values)}`;if($.code!=="invalid_type"||!$.message.startsWith("Invalid input:"))return $.message;if($.expected==="object"||$.expected==="record")return"must be an object if provided";return $.expected==="boolean"?"must be a boolean":$.message}function OP($){if($.length>3)return`one of ${$.join(", ")}`;let J=$.map((Q)=>typeof Q==="string"?`"${Q}"`:String(Q));if(J.length<2)return`${J[0]}`;return`${J.slice(0,-1).join(", ")}${J.length>2?",":""} or ${J.at(-1)}`}function MP($){return $.map((J,Q)=>{if(typeof J==="number")return`[${J}]`;return Q===0?String(J):`.${String(J)}`}).join("")}function ML($,J){let Q=$.map((W)=>W.path[1]),X=[...new Set(Q.filter((W)=>typeof W==="string"))],Y=(W,K)=>[W.path.length===0?-1:J.indexOf(String(W.path[0])),typeof K==="number"?K:X.indexOf(String(K)),W.code==="custom"?0:1];return $.map((W,K)=>({issue:W,rank:Y(W,Q[K])})).sort((W,K)=>W.rank[0]-K.rank[0]||W.rank[1]-K.rank[1]||W.rank[2]-K.rank[2]).map((W)=>W.issue)}function NP($,J){let Q=i1($)?$.rules:void 0;if(!Array.isArray(Q))return new Set;if(J.some((Y)=>Y.path.length===1&&Y.path[0]==="rules"))return new Set;let X=new Set(J.filter((Y)=>Y.path[0]==="rules"&&typeof Y.path[1]==="number").map((Y)=>Y.path[1]));return new Set(Q.filter((Y,W)=>typeof Y==="string"&&!X.has(W)))}function i1($){return!!$&&typeof $==="object"&&!Array.isArray($)}function FP($){return ZL($)}function QK($){try{let J=q2(VP($));if(J===null)return{config:null,errors:[]};if(!J.trim())return{config:null,errors:["Config file is empty"]};let Q=JSON.parse(J),X=FP(Q);if(X.errors.length>0)return{config:null,errors:X.errors};let Y=UL().parse(Q);return{config:{version:1,rules:Y.rules??[],overrides:Y.overrides??{},transparent_wrappers:Y.transparent_wrappers??[]},errors:[]}}catch(J){if(J instanceof W1)return{config:null,errors:[J.message]};return{config:null,errors:["Invalid JSON"]}}}function VP($){return typeof $==="string"?A6($):$}var jP=new Set(["standard","strict","paranoid"]),RP={version:1,safety:{level:"standard",overrides:{}},workflow:{worktree_mode:!1},destructive_command_protection:{enabled:!0,overrides:{},allow_paths:[]},secret_protection:{enabled:!0,overrides:{},deny_paths:[]},audit:{retention_days:j6}};function XK($){return IP(zP(U2($)),C6)}function _L($={}){let J=EP(XK($));return{safety:J.policy.safety,worktreeMode:J.policy.worktreeMode,destructiveCommandProtectionEnabled:J.policy.destructiveCommandProtectionEnabled,destructiveCommandRuleOverrides:{...J.policy.destructiveCommandRuleOverrides},destructiveCommandAllowPaths:[...J.policy.destructiveCommandAllowPaths],secretProtection:J.policy.secretProtection,errors:J.errors,...J.fallback?{fallback:J.fallback}:{}}}function NL($){if(!j0($))return AP();let J=j0($.safety)?$.safety:{},Q=j0(J.overrides)?J.overrides:{},X=j0($.workflow)?$.workflow:{},Y=j0($.destructive_command_protection)?$.destructive_command_protection:{},W=j0($.secret_protection)?$.secret_protection:{};return{version:1,safety:{level:jP.has(J.level)?J.level:"standard",overrides:{...typeof Q.fail_closed==="boolean"?{fail_closed:Q.fail_closed}:{},...typeof Q.paranoid_rm==="boolean"?{paranoid_rm:Q.paranoid_rm}:{},...typeof Q.paranoid_interpreters==="boolean"?{paranoid_interpreters:Q.paranoid_interpreters}:{}}},workflow:{worktree_mode:typeof X.worktree_mode==="boolean"?X.worktree_mode:!1},destructive_command_protection:{enabled:typeof Y.enabled==="boolean"?Y.enabled:!0,overrides:FL(Y.overrides,i6),allow_paths:PP(Y.allow_paths)},secret_protection:{enabled:typeof W.enabled==="boolean"?W.enabled:!0,overrides:FL(W.overrides,WJ),deny_paths:bP(W.deny_paths)},audit:{retention_days:R6(j0($.audit)?$.audit.retention_days:void 0)}}}function FL($,J){if(!j0($))return{};return Object.fromEntries(Object.entries($).flatMap(([Q,X])=>J.has(Q)&&(X==="on"||X==="off")?[[Q,X]]:[]))}function bP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>T9(Q,J)===null)}function PP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>C9(Q,J)===null)}function j0($){return!!$&&typeof $==="object"&&!Array.isArray($)}function AP(){return structuredClone(RP)}function EP($){let J=SP();if(!_P($)){let Q=globalThis.__CC_SAFETY_NET_EMBEDDED_POLICY__;if(!j0(Q))return{policy:J,errors:[]};return{policy:VL(NL(Q)),errors:[]}}try{let Q=DP($,"utf-8");if(!Q.trim())return{policy:J,errors:[`${$}: Config file is empty`],fallback:"defaults"};let X=JSON.parse(Q),Y=LL(X),W=VL(NL(X));if(Y.length>0)return{policy:W,errors:Y.map((K)=>`${$}: ${K}`),fallback:j0(X)?"salvaged":"defaults"};return{policy:W,errors:[]}}catch{return{policy:J,errors:[`${$}: Invalid JSON`],fallback:"defaults"}}}function DL($){let J=Object.entries($),Q=new Set(J.flatMap(([X,Y])=>Y==="on"?[X]:[]));return new Set([...[...WL].filter((X)=>!Q.has(X)),...J.flatMap(([X,Y])=>Y==="off"?[X]:[])])}function SP(){return{safety:{},worktreeMode:!1,destructiveCommandProtectionEnabled:!0,destructiveCommandRuleOverrides:{},destructiveCommandAllowPaths:[],secretProtection:{enabled:!0,disabledRules:DL({}),denyPaths:[]}}}function VL($){return{safety:CP($.safety),worktreeMode:$.workflow.worktree_mode,destructiveCommandProtectionEnabled:$.destructive_command_protection.enabled,destructiveCommandRuleOverrides:{...$.destructive_command_protection.overrides},destructiveCommandAllowPaths:[...$.destructive_command_protection.allow_paths],secretProtection:{enabled:$.secret_protection.enabled,disabledRules:DL($.secret_protection.overrides),denyPaths:[...$.secret_protection.deny_paths]}}}function CP($){return{level:$.level,overrides:{failClosed:$.overrides.fail_closed,paranoidRm:$.overrides.paranoid_rm,paranoidInterpreters:$.overrides.paranoid_interpreters}}}var RL="This path contains the protected policy config and you must not modify or delete it.",TP=new Set(["[","cat","file","grep","head","jq","less","ls","more","rg","sed","stat","tail","test","wc"]);function bL($){let J=H2(E0()),Q=gP($.invocation.context.executionCwd,J);if($.invocation.route.kind==="patch")return zL($.paths.map((Y)=>Y.raw),!1,$.invocation.context.executionCwd,Q,J);let X=w1($,"input-candidate");if($.invocation.route.kind==="command")return X?IL(X.shell,$.invocation.context.executionCwd,Q,J):null;if($.invocation.route.kind==="unknown"&&X){let Y=IL(X.shell,$.invocation.context.executionCwd,Q,J);if(Y)return Y}return zL($.paths.map((Y)=>Y.raw),$.invocation.route.kind==="grep"||$.invocation.route.kind==="glob"||b9($.invocation.toolName),$.invocation.context.executionCwd,Q,J)}function zL($,J,Q,X,Y){if(J)return null;let W=$.find((K)=>F6(K,Q,X,Y));return W?{target:W}:null}function IL($,J,Q,X){let Y=A9($,J,X,{findSegmentTarget:(W,K)=>wP(W,K,Q,X)?.target??null,isRedirectionTarget:(W,K)=>F6(W,K.cwd,Q,X),findMalformedTarget:(W)=>kP(W,J,Q,X)?.target??null,normalizeCwd:M1});return Y?{target:Y}:null}function wP($,J,Q,X){if(O3($))return null;let Y=X.environment,W=l1([...$],Y),K=l(W[0]??"").toLowerCase(),B=W.slice(1);if(K==="rm"&&vP(B)){let q=fP(B).find((U)=>jL(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(K==="find"){if(x9(W,1)||AQ(W,Y)){let U=(y9(p(W))??p(["."])).find((G)=>{let H=f1(G.text,J.variables);return F6(H,J.cwd,Q,X)||jL(H,J.cwd,Q,X)})?.text;if(U)return{target:U}}}if(K==="mv"){let q=E9(B).sources.find((U)=>yP(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(hP($,Y))return null;for(let q of $)for(let U of PL(q))if(F6(f1(U,J.variables),J.cwd,Q,X))return{target:U};return null}function vP($){return $.some((J)=>J==="--recursive"||J.startsWith("-")&&!J.startsWith("--")&&/[rR]/.test(J.slice(1)))}function fP($){let J=$.indexOf("--");if(J!==-1)return[...$.slice(0,J).filter((Q)=>!Q.startsWith("-")),...$.slice(J+1)];return $.filter((Q)=>!Q.startsWith("-"))}function hP($,J){let Q=l1([...$],J);if(Q.length===0)return!1;let X=l(Q[0]??"").toLowerCase();if(!TP.has(X))return!1;if(X!=="sed")return!0;return!Q.slice(1).some((Y)=>Y.startsWith("-i")||Y==="--in-place"||Y.startsWith("--in-place="))}function kP($,J,Q,X){for(let Y of $.split(/\s+/))for(let W of PL(Y))if(F6(W,J,Q,X))return{target:W};return null}function PL($){let J=$.trim().replace(/^['"]|['"]$/g,""),Q=J.indexOf("=");return Q===-1||Q===J.length-1?[J]:[J,J.slice(Q+1)]}function gP($,J){let Q=M1(XK(),$,J),X=YK(Q),Y=new Set;for(let W=X;;W=YK(W))if(Y.add(d4(W)),YK(W)===W)break;return{file:d4(Q),directory:d4(X),directoryAndAncestors:Y}}function F6($,J,Q,X){return d4(M1($,J,X))===Q.file}function jL($,J,Q,X){return Q.directoryAndAncestors.has(d4(M1($,J,X)))}function yP($,J,Q,X){let Y=d4(M1($,J,X));return Y===Q.file||Q.directoryAndAncestors.has(Y)}function d4($){return process.platform==="win32"?$.toLowerCase():$}import{homedir as xP}from"os";import{isAbsolute as KK,resolve as hL}from"path";import{fileURLToPath as uP}from"url";var kL="Access to a sensitive path is not allowed.",gL=new Set(["echo","printf"]),mP=new Set(["find"]),lP=new Set(["-exec","-execdir"]),pP=new Set([";","+"]),cP=new Set(["-delete","-exec","-execdir","-fls","-fprint","-fprint0","-fprintf","-ok","-okdir"]),dP=new Set(["-name","-iname","-path","-ipath","-wholename","-iwholename","-samefile"]),rP=new Set(["python","python2","python3","node","deno","bun","ruby","perl","php","rscript","osascript","bash","sh","zsh","dash","ksh"]),iP=new Set(["node","bun"]),oP=new Set(["bun","child_process","deno","dotenv","fs","subprocess"]),nP=new Set(["append","awk","base64","cat","chmod","chown","connect","copy","cp","database","dd","eval","exec","fetch","file","function","grep","head","include","load","move","mv","open","popen","read","remove","rename","require","rg","rm","sed","shell","source","spawn","strings","system","tail","tar","truncate","unlink","write","xxd","zip"]),yL=new Set(["-c","-e","-r","-E","--eval","--exec"]),sP=new Set(["src/cli/cc-safety-net.ts","dist/bin/cc-safety-net.js"]),aP=new Map([["c",new Set(["bash","sh","zsh","dash","ksh","python"])],["e",new Set(["node","deno","bun","ruby","perl","rscript","osascript"])],["E",new Set(["perl"])],["r",new Set(["php"])]]),tP=new Set(["grep","rg"]),AL="f",EL="file",eP="files",$A=new Set(["e","f"]),JA=new Set(["regexp","file"]),QA=new Set(["e","f","A","B","C","m"]),XA=new Set(["regexp","file","after-context","before-context","context","max-count"]),YA=new Set(["|","|&"]),WK="__CC_SAFETY_NET_PIPE_INPUT__",xL=new Set(["bash","sh","zsh","dash","ksh"]),WA=new Map([["bash",new Set(["-O"])],["sh",new Set(["-O"])],["zsh",new Set(["-o"])],["dash",new Set(["-o"])],["ksh",new Set(["-o"])],["python",new Set(["-W","-X"])],["node",new Set(["-r","--require","--loader","--import","--input-type"])]]);function SL($,J,Q,X,Y){let W=s4();for(let K of $){if(pA(K,J,Q?.denyPaths??[],X,W))return{target:K,ruleId:"secret.deny-path"};if(Y&&!Y.has(K))continue;let B=mA(K,J,Q,W);if(B)return{target:K,ruleId:B}}return null}function uL($,J,Q={}){let X=CL($),Y=SL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd),W=Y?.ruleId!=="secret.deny-path"&&Q.strict===!1?CL($,{refineJavaScriptInlineData:!0}):X,K=W.length===X.length?Y:SL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd,new Set(W));if(K?.ruleId!=="secret.deny-path"&&Q.strict===!1&&KA($))return null;return K}function KA($){if($.invocation.route.kind!=="command")return!1;let J=w1($,"input-candidate")??w1($,"declared-command");if(!J)return!1;if(J.program.nodes.some((K)=>K.kind==="command"&&K.nested.length>0))return!1;let Q=[];for(let K of J.shell.entries){if(K.kind==="operator"&&K.boundary)return!1;if(K.kind==="redirection")return!1;if(K.kind!=="operator")Q.push(G0(K.text))}let X=i4(Q);if(X.length===0)return!1;let Y=y2(X[0]??"").toLowerCase(),W=X.slice(1);if(Y==="test")return W.length===2&&(W[0]==="-e"||W[0]==="-f");if(Y!=="find")return!1;return!W.some((K)=>cP.has(K))}function CL($,J={}){if($.invocation.route.kind==="command"){let X=w1($,"input-candidate");return X?D6(X.shell,$.store,J):[]}if($.invocation.route.kind!=="unknown")return $.paths.map((X)=>X.raw);let Q=w1($,"input-candidate");return[...Q?D6(Q.shell,$.store,J):[],...$.paths.map((X)=>X.raw)]}function D6($,J,Q){if($.status==="structural-limit")throw new n0;if($.status==="unclosed-quote")return[];if($.status==="invalid")throw Error("Unable to parse command for secret protection");let X=[...$.assignmentFallbacks,...PA(G0($.source),J,Q)],Y=[],W=null;for(let K of $.entries){if(K.kind==="operator"){if(!K.boundary)continue;if(Y.length>0){if(X.push(...BJ(Y,J,Q)),W!==null)X.push(...TL(W,Y,J,Q));W=YA.has(K.operator)?Y:null,Y=[]}else W=null;continue}if(K.kind==="redirection"){let B=K.target?G0(K.target):void 0;if(B&&K.targetOrder==="legacy-segment")Y.push(B);else if(B)X.push(B);continue}Y.push(G0(K.text))}if(Y.length>0){if(X.push(...BJ(Y,J,Q)),W!==null)X.push(...TL(W,Y,J,Q))}return X}function BJ($,J,Q){let X=NA($),Y=i4($);if(Y.length===0)return X;let W=Y[0]??"",K=y2(W).toLowerCase(),B=Y.slice(1),q=BA(W,K,B);if(q)return[...X,...q];if(gL.has(K))return X;if(tP.has(K))return[...X,...fA(B)];if(mP.has(K))return[...X,...FA(B,J,Q)];if(h1.has(K))return[...X,...B.flatMap((U)=>wL("awk",U)),...B.flatMap((U)=>_A(U,J,Q)),...B.flatMap(DA)];if(pL(K)){if(xL.has(K)){let U=xq(K,B);if(U!==null&&J.getShellSyntax(U).status==="structural-limit")throw new n0}return[...X,...VA(K,B,Q)]}return[...X,...B.flatMap((U)=>wL(K,U))]}function BA($,J,Q){let X=J==="cc-safety-net"&&Q[0]==="explain",Y=(J==="bun"||J==="node")&&qA(Q[0])&&Q[1]==="explain";if(!X&&!Y)return null;let W=Y?[$,Q[0]??""]:[$],K=Q.slice(Y?2:1);for(let B=0;B<K.length;B++){let q=K[B];if(q==="--json"||q==="--help"||q==="-h")continue;if(q==="--cwd"){let U=K[B+1];if(U&&!U.startsWith("--"))W.push(U);B++;continue}return W}return W}function qA($){let J=$?.replaceAll("\\","/");return[...sP].some((Q)=>J===Q||J?.endsWith(`/${Q}`))}function TL($,J,Q,X){if(LA(J,Q,X))return UA($);let Y=OA(J);if(Y===null)return[];return GA($).flatMap((W)=>xL.has(Y)?D6(Q.getShellSyntax(W),Q,X):dL(W))}function UA($){let J=i4($);if(J.length===0)return[];let Q=y2(J[0]??"").toLowerCase();if(!gL.has(Q))return[];return J.slice(1)}function GA($){let J=i4($);if(J.length===0)return[];let Q=y2(J[0]??"").toLowerCase(),X=J.slice(1);if(Q==="echo"){let Y=X.findIndex((W)=>!/^-[neE]+$/.test(W));return[(Y===-1?[]:X.slice(Y)).join(" ")]}if(Q==="printf")return HA(X);return[]}function HA($){let J=$[0];if(J===void 0)return[];let Q=(J.match(/%%|%[bqs]/g)??[]).filter((Y)=>Y!=="%%").length;if(Q===0||$.length===1)return[mL(J)];let X=$.slice(1);return Array.from({length:Math.ceil(X.length/Q)},(Y,W)=>ZA(J,X.slice(W*Q,(W+1)*Q)))}function ZA($,J){let Q=0;return mL($.replace(/%%|%[bqs]/g,(X)=>{if(X==="%%")return"%";let Y=J[Q]??"";return Q++,Y}))}function mL($){return $.replace(/\\n/g,`
101
+ `).replace(/\\t/g,"\t").replace(/\\r/g,"\r")}function LA($,J,Q){let X=i4($);if(X.length===0||y2(X[0]??"").toLowerCase()!=="xargs")return!1;let Y=R2(X),W=X.slice(Y.childStart);if(W.length===0)return!1;if(Y.replacementToken==="")return!1;let K=Y.replacementToken,B=K===null?[...W,WK]:W.map((q)=>q.split(K).join(WK));return BJ(B,J,Q).some((q)=>q.includes(WK))}function OA($){let J=i4($);if(J.length===0)return null;let Q=y2(J[0]??"").toLowerCase();if(!pL(Q))return null;return MA(Q,J.slice(1))?Q:null}function MA($,J){let Q=lL($);for(let X=0;X<J.length;X++){let Y=J[X];if(Y===void 0)break;if(yL.has(Y)||cL($,Y)||/^--(?:eval|exec)=/.test(Y))return!1;if(Y==="-")return!0;if(Y.startsWith("-")){if(Q==="python"&&Y==="-m")return!1;if(WA.get(Q)?.has(Y))X++;continue}return!1}return!0}function lL($){return/^python\d/.test($)?"python":$}function NA($){let J=[];for(let Q of $){if(oL(Q))continue;let X=/^[A-Za-z_][A-Za-z0-9_]*=(.*)$/.exec(Q);if(X===null)break;if(X[1]!==void 0&&X[1]!=="")J.push(X[1])}return J}function wL($,J){if(J==="--")return[];let Q=[],X=J.indexOf("=");if(X>0&&X<J.length-1)Q.push(J.slice(X+1));if(J.startsWith("-"))return Q;if($==="tar"&&/\.(?:tar|tgz|tar\.gz|zip)$/i.test(J))return Q;if($==="zip"&&/\.zip$/i.test(J))return Q;return Q.push(J),Q}function FA($,J,Q){let X=$.findIndex((W)=>W.startsWith("-")||W==="("||W==="!"||W===";"),Y=[...$.slice(0,X===-1?$.length:X)];for(let W=0;W<$.length;W++){if(!lP.has($[W]??""))continue;let K=$.slice(W+1),B=K.findIndex((G)=>pP.has(G)),q=B===-1?K:K.slice(0,B),U=BJ(q,J,Q);if(Y.push(...U.filter((G)=>G!=="{}")),!U.includes("{}"))continue;Y.push(...$.slice(0,W).flatMap((G,H,L)=>{if(!dP.has(G))return[];let Z=L[H+1];return Z===void 0?[]:[Z,Z.replace(/^\*+\//,"").replace(/\/\*+$/g,"").replace(/^\*+/,"").replace(/\*+$/g,"")]}))}return Y}function pL($){return rP.has($)||/^python\d/.test($)}function VA($,J,Q){let X=[];for(let Y=0;Y<J.length;Y++){let W=J[Y];if(W===void 0)break;if(yL.has(W)||cL($,W)){let B=J[Y+1];if(B!==void 0)X.push(...vL($,B,Q)),Y++;continue}let K=/^--(?:eval|exec)=(.*)$/.exec(W);if(K!==null&&K[1]!==void 0){X.push(...vL($,K[1],Q));continue}if(!W.startsWith("-"))X.push(W)}return X}function cL($,J){if(!J.startsWith("-")||J.startsWith("--")||J.length<=2)return!1;return aP.get(J[J.length-1]??"")?.has(lL($))??!1}function _A($,J,Q){if(!$.includes("system"))return[];return jQ($)?.commands.flatMap((X)=>D6(J.getShellSyntax(X),J,Q))??[]}function DA($){return Array.from($.matchAll(/\bgetline(?:\s+[A-Za-z_][A-Za-z0-9_]*)?\s*<\s*"((?:\\.|[^"\\])*)"/g)).map((J)=>J[1]).filter((J)=>J!==void 0&&J!=="")}function dL($){let J=Array.from($.matchAll(/(['"`])((?:\\.|(?!\1).)*)\1/g)).map((X)=>X[2]).filter((X)=>X!==void 0&&X!==""),Q=($.match(/[\w./~@+-]*[./~][\w./~@+-]*/g)??[]).filter((X)=>X!=="process.versions.sqlite"||J.some((Y)=>Y.includes(X)));return[...J,...J.flatMap(rL),...Q]}function vL($,J,Q){let X=dL(J);if(!Q.refineJavaScriptInlineData||!iP.has($)||X.length===0)return X;let Y=zA(J);return Y!==null&&!jA(Y)?[]:X}function zA($){let J=$.split("");for(let Q=0;Q<$.length;Q++){let X=$[Q];if(X!=="'"&&X!=='"'&&X!=="`")continue;if(X==="`"&&IA($,Q))return null;J[Q]=" ";let Y=!1;for(let W=Q+1;W<$.length;W++){let K=$[W];if(J[W]=" ",K==="\\"){if(W++,W<$.length)J[W]=" ";continue}if(X==="`"&&K==="$"&&$[W+1]==="{")return null;if(X!=="`"&&(K===`
102
+ `||K==="\r"))return null;if(K!==X)continue;Q=W,Y=!0;break}if(!Y)return null}return J.join("")}function IA($,J){for(let Q=J-1;Q>=0;Q--){let X=$[Q];if(!X||/\s/.test(X))continue;return/[\w$\])]/.test(X)}return!1}function jA($){for(let J of $.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/g)){let Q=J[0],X=J.index;if(oP.has(Q.toLowerCase()))return!0;let Y=Q.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[_$\s]+/).map((W)=>W.toLowerCase());if(!Y.some((W)=>nP.has(W)))continue;if(Y.length>1)return!0;if(RA($,X)===".")return!0;if(bA($,X+Q.length)==="(")return!0}return!1}function RA($,J){for(let Q=J-1;Q>=0;Q--)if(!/\s/.test($[Q]??""))return $[Q];return}function bA($,J){for(let Q=J;Q<$.length;Q++)if(!/\s/.test($[Q]??""))return $[Q];return}function PA($,J,Q){return TA($).flatMap((X)=>{let Y=J.getShellSyntax(X);if(Y.status==="invalid")return[];return[...D6(Y,J,Q),...AA(Y)?EA(Y):[]]})}function AA($){let J=$.entries;for(let Q=0;Q<J.length;Q++){let X=J[Q];if(X?.kind!=="word"||y2(G0(X.text)).toLowerCase()!=="base64")continue;for(let Y=Q+1;Y<J.length;Y++){let W=J[Y];if(W?.kind==="operator")break;if(W?.kind!=="word")continue;let K=G0(W.text);if(K==="--decode"||!K.startsWith("--")&&K.startsWith("-")&&/[dD]/.test(K))return!0}}return!1}function EA($){return $.entries.flatMap((J)=>J.kind==="word"?[G0(J.text)]:J.kind==="redirection"&&J.target?[G0(J.target)]:[]).flatMap(rL)}function rL($){let J=CA($);if(J===null)return[];let Q=Buffer.from(J,"base64").toString("utf8");if(Q===""||SA(Q))return[];return Buffer.from(Q,"utf8").toString("base64").replace(/=+$/g,"")===J.replace(/=+$/g,"")?[Q]:[]}function SA($){return Array.from($).some((J)=>{let Q=J.charCodeAt(0);return Q<32||Q===127})}function CA($){if($.length<8||!/^[A-Za-z0-9+/_-]+={0,2}$/.test($))return null;if(/=/.test($.replace(/=+$/g,"")))return null;let J=$.replace(/=+$/g,"");if(J.length%4===1)return null;return`${J.replace(/-/g,"+").replace(/_/g,"/")}${"=".repeat((4-J.length%4)%4)}`}function TA($){let J=[],Q={inSingle:!1,inDouble:!1,escaped:!1};for(let X=0;X<$.length;X++){let Y=$[X];if(!Y)break;if(G3(Y,Q))continue;if(iL($,X,Q)){let W=wA($,X+1);if(W!==null)J.push(W.body),X=W.endIndex;continue}if(!Q.inSingle&&Y==="`"){let W=vA($,X);if(W!==null)J.push(W.body),X=W.endIndex}}return J}function wA($,J){let Q={inSingle:!1,inDouble:!1,escaped:!1},X=1;for(let Y=J+1;Y<$.length;Y++){let W=$[Y];if(!W)break;if(G3(W,Q))continue;if(iL($,Y,Q)){X++,Y++;continue}if(!Q.inSingle&&!Q.inDouble&&W===")"){if(X--,X===0)return{body:$.slice(J+1,Y),endIndex:Y}}}return null}function vA($,J){let Q=!1;for(let X=J+1;X<$.length;X++){let Y=$[X];if(!Y)break;if(Q){Q=!1;continue}if(Y==="\\"){Q=!0;continue}if(Y==="`")return{body:$.slice(J+1,X),endIndex:X}}return null}function iL($,J,Q){return!Q.inSingle&&$[J]==="$"&&$[J+1]==="("&&$[J+2]!=="("}function fA($){let J=[],Q=[],X=!1,Y=!1,W=!1;for(let q=0;q<$.length;q++){let U=$[q];if(U===void 0)break;if(!W&&U==="--"){W=!0;continue}if(W){Q.push(U);continue}let G=/^--([^=]+)(?:=(.*))?$/.exec(U);if(G!==null){let H=G[1]??"",L=G[2];if(H===eP)Y=!0;if(JA.has(H))X=!0;if(L!==void 0){if(H===EL)J.push(L);continue}if(XA.has(H)){let Z=$[q+1];if(H===EL&&Z!==void 0)J.push(Z);q++}continue}if(U.startsWith("-")&&U.length>1){let H=U.slice(1),L="",Z="";for(let O=0;O<H.length;O++){let M=H[O]??"";if($A.has(M))X=!0;if(QA.has(M)){L=M,Z=H.slice(O+1);break}}if(L!=="")if(Z.length>0){if(L===AL)J.push(Z)}else{let O=$[q+1];if(L===AL&&O!==void 0)J.push(O);q++}continue}Q.push(U)}let B=!X&&!Y?Q.slice(1):Q;return[...J,...B]}function i4($){let J=$.findIndex((Q)=>!oL(Q)&&!/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(Q));return J===-1?[]:[...$.slice(J)]}function oL($){return $==="env"||$==="command"||$==="builtin"||$==="sudo"}var hA=new Set(["id_rsa.pub","id_ed25519.pub","id_ecdsa.pub"]),kA=".env.",gA=new Set([".env.example",".env.sample",".env.template",".env.defaults"]),yA=[".env.example.",".env.sample."],xA=new Set(["node_modules","__pycache__"]),uA=[["vendor","bundle"],["vendor","cache"]];function mA($,J,Q,X){let Y=u0($,J,X);if(!Y)return null;let W=G1(Y.split("/").pop()??""),K=G1(Y);if(gA.has(W)||yA.some((U)=>W.startsWith(U)))return null;for(let U of sW){let G=U.suffixParts.join("/");if((K===`~/${G}`||K.startsWith(`~/${G}/`))&&x0(U.id,Q))return U.id}let B=lA(Y,J,Q,X);if(B)return B;if(hA.has(W))return null;for(let U of nW)if(W===U.basename&&x0(U.id,Q))return U.id;if(W.startsWith(kA)&&x0(XJ.id,Q))return XJ.id;for(let U of aW)if(W.length>U.prefix.length&&W.startsWith(U.prefix)){let G=W.slice(U.prefix.length)[0];if((G==="-"||G==="_")&&x0(U.id,Q))return U.id}for(let U of tW)if(W.length>U.prefix.length&&W.startsWith(U.prefix)){if(W.slice(U.prefix.length)===U.suffix&&x0(U.id,Q))return U.id}if(cA(K))return null;if(!W.includes(".")&&M6.pattern.test(W)&&x0(M6.id,Q))return M6.id;let q=dA(W,Q);if(q)return q;return null}function lA($,J,Q,X){return YJ.find((Y)=>{if(!x0(Y.id,Q))return!1;switch(Y.id){case"secret.cli.claude-code":return $1($,Q1(process.env.CLAUDE_CONFIG_DIR,"~/.claude",J,X),[".credentials.json"]);case"secret.cli.claude-code.config":{let W=G1($).split("/");return $1($,Q1(process.env.CLAUDE_CONFIG_DIR,"~/.claude",J,X),["settings.json","settings.local.json"])||_6($,"~/.claude.json",J,X)||W.at(-1)==="settings.local.json"&&W.at(-2)===".claude"||W.at(-1)===".mcp.json"}case"secret.cli.antigravity":return $1($,u0("~/.gemini/config",J,X),["hooks.json","mcp_config.json"]);case"secret.cli.codex":{let W=Q1(process.env.CODEX_HOME,"~/.codex",J,X);return $1($,W,["auth.json",".credentials.json"])||V6($,W,["secrets",".sandbox-secrets"])}case"secret.cli.codex.config":{let W=Q1(process.env.CODEX_HOME,"~/.codex",J,X),K=G1($).split("/").at(-1)??"";return $1($,W,["config.toml"])||K.endsWith(".config.toml")&&$1($,W,[K])}case"secret.cli.gemini":return $1($,F1(Q1(process.env.GEMINI_CLI_HOME,"~",J,X),".gemini"),["oauth_creds.json","mcp-oauth-tokens.json","a2a-oauth-tokens.json","gemini-credentials.json"]);case"secret.cli.gemini.config":{let W=G1($).split("/"),K=process.env.ProgramData?[F1(Q1(process.env.ProgramData,"",J,X),"gemini-cli")]:[];return $1($,F1(Q1(process.env.GEMINI_CLI_HOME,"~",J,X),".gemini"),["settings.json","google_accounts.json"])||W.at(-1)==="settings.json"&&W.at(-2)===".gemini"||(process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH?.trim()?_6($,process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH,J,X):!1)||["/Library/Application Support/GeminiCli","/etc/gemini-cli",...K].some((B)=>$1($,u0(B,J,X),["settings.json"]))}case"secret.cli.copilot-cli":{let W=Q1(process.env.COPILOT_HOME,"~/.copilot",J,X);return $1($,W,["config.json"])||V6($,W,["mcp-oauth-config","mcp-secrets"])}case"secret.cli.copilot-cli.config":return $1($,Q1(process.env.COPILOT_HOME,"~/.copilot",J,X),["mcp-config.json"]);case"secret.cli.kimi-code":{let W=Q1(process.env.KIMI_CODE_HOME,"~/.kimi-code",J,X),K=Q1(process.env.KIMI_SHARE_DIR,"~/.kimi",J,X);return $1($,W,["server.token"])||V6($,W,["credentials"])||V6($,K,["credentials","mcp-oauth"])}case"secret.cli.kimi-code.config":{let W=["config.toml","mcp.json"],K=G1($).split("/");return K.at(-1)==="mcp.json"&&K.at(-2)===".kimi-code"||$1($,Q1(process.env.KIMI_CODE_HOME,"~/.kimi-code",J,X),W)||$1($,Q1(process.env.KIMI_SHARE_DIR,"~/.kimi",J,X),[...W,"config.json","config.json.bak"])}case"secret.cli.opencode":{let W=F1(Q1(process.env.XDG_DATA_HOME,"~/.local/share",J,X),"opencode"),K=G1($).split("/").at(-1)??"",B=process.env.OPENCODE_DB?.trim(),q=B&&B!==":memory:"?[B,`${B}-wal`,`${B}-shm`]:[];return $1($,W,["auth.json","mcp-auth.json"])||/^opencode(-.+)?\.db(-wal|-shm)?$/.test(K)&&$1($,W,[K])||q.some((U)=>_6($,U,J,X))}case"secret.cli.opencode.config":{let W=process.env.OPENCODE_CONFIG_DIR?Q1(process.env.OPENCODE_CONFIG_DIR,"~/.config/opencode",J,X):F1(Q1(process.env.XDG_CONFIG_HOME,"~/.config",J,X),"opencode"),K=process.env.ProgramData?[F1(Q1(process.env.ProgramData,"",J,X),"opencode")]:[],B=["opencode.json","opencode.jsonc"];return B.includes(G1($).split("/").at(-1)??"")||$1($,W,B)||(process.env.OPENCODE_CONFIG?.trim()?_6($,process.env.OPENCODE_CONFIG,J,X):!1)||["/Library/Application Support/opencode","/etc/opencode",...K].some((q)=>$1($,u0(q,J,X),B))}case"secret.cli.pi":return $1($,Q1(process.env.PI_CODING_AGENT_DIR,"~/.pi/agent",J,X),["auth.json"]);case"secret.cli.pi.config":return $1($,Q1(process.env.PI_CODING_AGENT_DIR,"~/.pi/agent",J,X),["models.json"]);case"secret.cli.amp":{let W=u0("~",J,X);return[F1(Q1(process.env.XDG_DATA_HOME,"~/.local/share",J,X),"amp"),F1(W,".local","share","amp")].some((B)=>$1($,B,["secrets.json"]))||V6($,F1(W,".amp"),["oauth"])}case"secret.cli.amp.config":{let W=["settings.json","settings.jsonc"],K=[F1(Q1(process.env.XDG_CONFIG_HOME,"~/.config",J,X),"amp"),F1(u0("~",J,X),".config","amp")],B=G1($).split("/");return K.some((q)=>$1($,q,W))||B.at(-2)===".amp"&&W.includes(B.at(-1)??"")||(process.env.AMP_SETTINGS_FILE?.trim()?_6($,process.env.AMP_SETTINGS_FILE,J,X):!1)}case"secret.cli.cursor":{let W=F1(Q1(process.env.XDG_CONFIG_HOME,"~/.config",J,X),"cursor"),K=F1(Q1(process.env.CURSOR_DATA_DIR,"~/.cursor",J,X),"projects");return $1($,u0("~/.cursor",J,X),["auth.json"])||$1($,W,["auth.json"])||G1($).split("/").at(-1)==="mcp-auth.json"&&qJ(G1($),G1(K))}case"secret.cli.cursor.config":{let W=G1($).split("/");return W.at(-1)==="mcp.json"&&W.at(-2)===".cursor"}default:return!1}})?.id??null}function Q1($,J,Q,X){return u0($?.trim()?$:J,Q,X)}function $1($,J,Q){return Q.some((X)=>nL($,F1(J,X)))}function V6($,J,Q){return Q.some((X)=>qJ(G1($),G1(F1(J,X))))}function _6($,J,Q,X){return nL($,u0(J,Q,X))}function nL($,J){return G1($)===G1(J)}function F1($,...J){return r4([$,...J].filter(Boolean).join("/"))}function pA($,J,Q,X,Y){if(Q.length===0)return!1;let W=G1(fL($,J,Y));return Q.some((K)=>qJ(W,G1(fL(K,X,Y))))}function cA($){let J=$.split("/");return J.some((Q)=>xA.has(Q))||uA.some(([Q,X])=>J.some((Y,W)=>Y===Q&&J[W+1]===X))}function dA($,J){let Q=$.lastIndexOf("."),X=Q>0&&Q<$.length-1?$.slice(Q+1):"";if(X==="")return null;for(let Y of eW)if(X===Y.extension&&x0(Y.id,J))return Y.id;for(let Y of $K)if(Y.pattern.test(X)&&x0(Y.id,J))return Y.id;return null}function G1($){return $.toLowerCase()}function x0($,J){if(!J?.disabledRules)return!0;if(Array.isArray(J.disabledRules))return!J.disabledRules.includes($);return!J.disabledRules.has($)}function u0($,J,Q){let{home:X,normalized:Y}=sL($,Q);if(!Y)return"";if(!X)return Y;let W=aL(Y,X),K=KK(W)?W:r4(hL(J,W)),B=r4(J1(K,i0,Q));if(!qJ(B,X)){if(KK(W))return B;return B===K?Y:B}let q=B.slice(X.length);return q?`~${q}`:"~"}function fL($,J,Q){let{home:X,normalized:Y}=sL($,Q);if(!Y)return"";let W=X?aL(Y,X):Y;return r4(J1(KK(W)?W:hL(J,W),i0,Q))}function sL($,J){let Q=process.env.HOME??xP(),X=Q?r4(J1(Q,i0,J)):"",Y=r4(rA(G0($)));return{home:X,normalized:Y}}function rA($){if(!$.trim().toLowerCase().startsWith("file:"))return $;try{return uP($)}catch{return $}}function aL($,J){if($==="~")return J;if($.startsWith("~/"))return F1(J,$.slice(2));return $}function r4($){let J=$.trim().replace(/\\/g,"/").replace(/\/{2,}/g,"/").replace(/^\.\//,"");if(J==="/")return J;return J.replace(/\/+$/g,"")}function qJ($,J){return $===J||$.startsWith(J.endsWith("/")?J:`${J}/`)}function y2($){return $.split(/[\\/]/).pop()?.replace(/\.exe$/i,"")??$}import{dirname as UJ}from"path";var tL="Rulebook exceeds CC Safety Net's safe validation limits.",eL="Additional rulebook validation errors were omitted.",X0=Object.freeze({maxAllowedCommands:1024,maxRules:1024,maxTests:2048,maxBlockArgsPerRule:1024,maxTotalBlockArgs:16384,maxStringCodeUnits:1048576,maxAggregateStringCodeUnits:4194304,maxFixtureCommandCodeUnits:131072,maxValidationErrors:64});function $O($){if(BK($.allowed_commands,X0.maxAllowedCommands)||BK($.rules,X0.maxRules)||BK($.tests,X0.maxTests))return!1;let{maxAggregateStringCodeUnits:J,maxTotalBlockArgs:Q}=X0,X=(Y,W=!1)=>{if(typeof Y!=="string")return!0;if(Y.length>X0.maxStringCodeUnits||W&&Y.length>X0.maxFixtureCommandCodeUnits||Y.length>J)return!1;return J-=Y.length,!0};if(!X($.name)||!X($.version)||!X($.description)||!X($.author)||!X($.migrated_from))return!1;if(Array.isArray($.allowed_commands)){for(let Y of $.allowed_commands)if(!X(Y))return!1}if(Array.isArray($.rules))for(let Y of $.rules){if(!Y||typeof Y!=="object")continue;let W=Y;if(!X(W.name)||!X(W.command)||!X(W.subcommand)||!X(W.reason)||!X(W.intent))return!1;if(!Array.isArray(W.block_args))continue;if(W.block_args.length>X0.maxBlockArgsPerRule||W.block_args.length>Q)return!1;Q-=W.block_args.length;for(let K of W.block_args)if(!X(K))return!1}if(Array.isArray($.tests))for(let Y of $.tests){if(!Y||typeof Y!=="object")continue;let W=Y;if(!X(W.command,!0)||!X(W.expect)||!X(W.rule))return!1}return!0}function BK($,J){return Array.isArray($)&&$.length>J}function iA($){if(!oA($))return{errors:["Rulebook must be an object"],ruleNames:new Set};if(!$O($))return{errors:[tL],ruleNames:new Set};let J=GL().safeParse($),Q=[...$.rulebook_version===1?[]:["rulebook_version must be 1"],...J.success?[]:c4(J.error.issues,": ",": ")];return{errors:Q.length>X0.maxValidationErrors?[...Q.slice(0,X0.maxValidationErrors),eL]:Q,ruleNames:new Set(JK($).map((X)=>X.toLowerCase()))}}function qK($){let J=iA($);if(J.errors.length>0)throw Error(J.errors.join("; "));return $}function oA($){return!!$&&typeof $==="object"&&!Array.isArray($)}function UK($){if(S6($.spec))return aA($);return sA($)}function sA($){if(!Y0.test($.spec))return`Local rulebook sources must be bare names matching ${Y0}: ${$.spec}`;if($.kind!=="local-directory")return`lock entry for ${$.spec} must use local-directory kind`;if($.path===$.spec&&$.name===$.spec)return null;return`lock entry for ${$.spec} does not match local source identity`}function aA($){let J=o4($.spec);if(J)return J;let Q=E6($.spec);if($.kind!=="github")return`lock entry for ${$.spec} must use github kind`;if($.owner===Q.owner&&$.repo===Q.repo&&$.ref===Q.ref&&$.path===Q.path&&$.name===Q.name)return null;return`lock entry for ${$.spec} does not match GitHub source identity`}function JO($){let J=typeof $==="string"?$:$.path;try{let Q=q2(typeof $==="string"?A6($):$);if(Q===null)return{lock:null,errors:[]};let X=JSON.parse(Q);if(!X||typeof X!=="object")return{lock:null,errors:[`malformed lockfile ${J}: must be an object`]};let Y=X;if(Y.version!==1||!Array.isArray(Y.rulebooks))return{lock:null,errors:[`malformed lockfile ${J}`]};let W=HL().safeParse(Y),K=Y.rulebooks.flatMap((q,U)=>{let G=W.success?[]:W.error.issues.filter((L)=>L.path[1]===U);if(G.length>0)return c4(G).map((L)=>`${J}: ${L}`);let H=UK(q);return H?[`${J}: rulebooks[${U}]: ${H}`]:[]});if(!W.success||K.length>0)return{lock:null,errors:[`malformed lockfile ${J}`,...K]};return{lock:{version:1,rulebooks:W.data.rulebooks.map((q)=>{if(q.kind==="local-directory")return{spec:q.spec,kind:q.kind,path:q.path,name:q.name,version:q.version,digest:q.digest};let U={spec:q.spec,kind:q.kind,owner:q.owner,repo:q.repo,ref:q.ref,commit:q.commit,path:q.path,name:q.name,version:q.version,digest:q.digest};return typeof q.display_ref==="string"&&q.display_ref!==""?{...U,display_ref:q.display_ref}:U})},errors:[]}}catch(Q){if(Q instanceof W1)return{lock:null,errors:[Q.message]};return{lock:null,errors:["malformed lockfile"]}}}import{createHash as tA}from"crypto";var Tg=Object.freeze({timeoutMs:15000,metadataBytes:524288,commitBytes:262144,treeBytes:16777216,rawBytes:4194304});function QO($){return`sha256:${tA("sha256").update($).digest("hex")}`}function BO($={}){let J=AK($),Q=!1;try{Q=_K(J.userConfigTarget,J.projectConfigTarget)}catch(L){if(L instanceof W1)return QE(J,L.message);throw L}let X=QK(J.userConfigTarget),Y=Q?{config:null,errors:[]}:QK(J.projectConfigTarget),W=KO(J.userConfigPath,X.errors),K=KO(J.projectConfigPath,Y.errors),B=new Set,q=X.config?XO(X.config,J.userLockPath,UJ(J.userConfigPath),$,"user",J.userScope,B):z6(),U=Y.config?XO(Y.config,J.projectLockPath,UJ(J.projectConfigPath),$,"project",J.projectScope,B):z6(),G=X.config?.overrides??{},H=Y.config?.overrides??{};return{rules:[...YO(q.rules,G),...YO(U.rules,H)],transparent_wrappers:$E(X.config,Y.config),rulebooks:[...q.rulebooks,...U.rulebooks],errors:[...W,...K,...q.errors,...U.errors],warnings:[...q.warnings,...U.warnings,...q.canValidateOverrides?WO(G,q.knownRuleIds,J.userConfigPath):[],...q.canValidateOverrides?JE(H,q.knownRuleIds,J.projectConfigPath):[],...U.canValidateOverrides?WO(H,U.knownRuleIds,J.projectConfigPath):[]],userConfig:X.config??void 0,projectConfig:Y.config??void 0,...J}}function XO($,J,Q,X,Y,W=m0(UJ(UJ(Q)),Y==="user"?"user policy":"project policy"),K=new Set){let B;try{B=b0(W,J)}catch(V){if(V instanceof W1)return{...z6(),errors:[V.message],canValidateOverrides:!1};throw V}let q=JO(B);if(q.errors.length>0)return{...z6(),errors:q.errors,canValidateOverrides:!1};let U=q.lock;if(!U&&$.rules.length>0)return{...z6(),errors:[`missing lockfile ${J}; run ${c0}`],canValidateOverrides:!1};let G=U?.rulebooks??[],H=new Map(G.map((V)=>[V.spec,V])),L=[],Z=[],O=$.rules.flatMap((V)=>{let F=H.get(V);if(!F)return L.push(`missing lock entry for ${V}; run ${c0}`),[];let b=eA(F,Q,X,W);if(b.errors.length>0||!b.rulebook)return L.push(...b.errors),[];let I=b.rulebook;if(K.has(I.name))return Z.push(`duplicate active rulebook name "${I.name}" for ${V}; keeping the first and ignoring this one, so its rules are not active; rename one of them, then run ${c0}`),[];return K.add(I.name),[{rules:I.rules.map((A)=>({...A,name:`${I.name}/${A.name}`})),rulebook:{source:Y,spec:F.spec,name:I.name,version:I.version,rules:I.rules.map((A)=>`${I.name}/${A.name}`)}}]}),M=O.flatMap((V)=>V.rules);return{rules:M,rulebooks:O.map((V)=>V.rulebook),entries:G,knownRuleIds:new Set(M.map((V)=>V.name)),errors:L,warnings:Z,canValidateOverrides:L.length===0}}function eA($,J,Q,X){let Y=VJ($,_J(J,Q)),W;try{W=q2(b0(X,Y))}catch(B){if(B instanceof W1)return{rulebook:null,errors:[B.message]};throw B}if(W===null)return{rulebook:null,errors:[`missing cache entry for ${$.spec}; run ${c0}`]};if(QO(W)!==$.digest)return{rulebook:null,errors:[`cache digest mismatch for ${$.spec}; run ${c0}`]};let K;try{K=JSON.parse(W)}catch{return{rulebook:null,errors:[`invalid cached rulebook for ${$.spec}`]}}try{qK(K)}catch(B){return{rulebook:null,errors:[`invalid cached rulebook for ${$.spec}: ${B instanceof Error?B.message:"invalid rulebook"}`]}}return{rulebook:K,errors:[]}}function $E($,J){return[...new Set([...$?.transparent_wrappers??[],...J?.transparent_wrappers??[]])]}function YO($,J){return $.flatMap((Q)=>{let X=J[Q.name];if(X==="off")return[];if(X&&typeof X==="object")return[{...Q,intent:X.intent??Q.intent,reason:X.reason}];return[Q]})}function WO($,J,Q){return Object.keys($).filter((X)=>!J.has(X)).map((X)=>`unknown override key "${X}" in ${Q}; only that override is ignored and other overrides and rules keep their configured state; correct or remove it in that file`)}function JE($,J,Q){return Object.keys($).filter((X)=>J.has(X)).map((X)=>`project override cannot target user-scoped rule "${X}" in ${Q}; only that override is ignored and the rule keeps its user-configured state; remove it from that file`)}function KO($,J){return J.map((Q)=>Q.startsWith("Unable to access ")?Q:`${$}: ${Q}`)}function QE($,J){return{rules:[],transparent_wrappers:[],rulebooks:[],errors:[J],warnings:[],userConfigPath:$.userConfigPath,projectConfigPath:$.projectConfigPath,userLockPath:$.userLockPath,projectLockPath:$.projectLockPath}}function z6(){return{rules:[],rulebooks:[],entries:[],knownRuleIds:new Set,errors:[],warnings:[],canValidateOverrides:!0}}function qO($={}){let J=BO($),Q=_L($),X={rules:J.rules,transparentWrappers:J.transparent_wrappers,safety:qE(Q.safety),worktreeMode:Q.worktreeMode,destructiveCommandProtectionEnabled:Q.destructiveCommandProtectionEnabled,destructiveCommandRuleOverrides:{...Q.destructiveCommandRuleOverrides},destructiveCommandAllowPaths:[...Q.destructiveCommandAllowPaths],secretProtection:{enabled:Q.secretProtection.enabled??!0,disabledRules:[...Q.secretProtection.disabledRules??[]],denyPaths:[...Q.secretProtection.denyPaths]}},Y={...J.userConfig?.overrides??{},...J.projectConfig?.overrides??{}},W=Object.freeze(Object.fromEntries(X.rules.map((K)=>{let B=J.rulebooks.find((U)=>U.rules.includes(K.name)),q=Y[K.name];return[K.name,Object.freeze({id:K.name,...B?{rulebook:Object.freeze({name:B.name,version:B.version}),...KE(B.spec)?{source:B.spec}:{}}:{},...q&&typeof q==="object"?{override:Object.freeze({type:"reason",reason:q.reason})}:{}})]})));return BE(X,XE(J,Q),W)}function XE($,J){let Q=WE(J);if($.errors.length===0&&$.warnings.length===0&&!Q)return;return{diagnostics:[...$.errors,...$.warnings,...J.errors],reason:UE($.errors.length>0?YE($.errors):void 0,$.warnings.length>0?GK($.warnings.join("; ")):void 0,Q)}}function YE($){return`${GK($.join("; "))} Those rule sources are not active; every other rule and all built-in protections still apply`}function WE($){if($.errors.length===0)return;let J=$.fallback==="salvaged"?"the salvaged policy with protective defaults":"built-in protective defaults";return`invalid policy config: ${$.errors.join("; ")}. Enforcing ${J}; the invalid values are not active. Fix the policy file manually`}function KE($){return/^(?:[A-Za-z0-9_.-]+$|https:\/\/github\.com\/|github:|gh:|[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:#|$))/.test($)}function BE($,J,Q=Object.freeze({})){let X=UO(structuredClone($));if(!J)return Object.freeze({state:"ready",policy:X,diagnostics:Object.freeze([]),ruleMetadata:Q});return Object.freeze({state:"degraded",policy:X,diagnostics:Object.freeze([...J.diagnostics]),reason:J.reason,ruleMetadata:Q})}function qE($){let J=$.overrides,Q={...J?.failClosed!==void 0?{failClosed:J.failClosed}:{},...J?.paranoidRm!==void 0?{paranoidRm:J.paranoidRm}:{},...J?.paranoidInterpreters!==void 0?{paranoidInterpreters:J.paranoidInterpreters}:{}};return{...$.level!==void 0?{level:$.level}:{},...Object.keys(Q).length>0?{overrides:Q}:{}}}function UO($){if(typeof $!=="object"||$===null)return $;for(let J of Object.values($))UO(J);return Object.freeze($)}function UE(...$){return GK($.filter((J)=>!!J).join("; "))}function GK($){return/[.!?]$/.test($)?$:`${$}.`}class K2 extends Error{stage;evaluation;name="GuardEvaluationError";constructor($,J,Q){super(`CC Safety Net ${$} dependency failed`,{cause:Q});this.stage=$;this.evaluation=J}}var GE={findPolicyMutation:bL,findGitMetadataMutation:cq,resolveGitMetadata:LQ,loadPolicySnapshot:qO,findSensitiveTarget:uL,analyzeCommand:XH,getModes:U7};function GO($,J={}){let Q={...GE,...J.dependencies},X=LE($),Y=I6($)?$.command:X,W=x2("policy-protection",Y,()=>P9($,J.factParserDependencies)),K=w1(W,"declared-command");if(I6($)&&$.command?.trim()&&K?.program.status==="limited")return{stage:"command-analysis",decision:{kind:"deny",reason:A0,intent:"stop_and_explain",evidence:[{kind:"command",command:$.command,segment:$.command}]}};if(w1(W,"input-candidate")?.program.status==="limited")return{stage:"command-validation",decision:{kind:"deny",reason:pK,intent:"stop_and_explain",evidence:[]}};let B=x2("policy-protection",Y,()=>Q.resolveGitMetadata($.context.executionCwd)),q=x2("policy-protection",Y,()=>Q.findPolicyMutation(W));if(q){let V=Y??q.target;return{stage:"policy-protection",decision:{kind:"deny",reason:RL,intent:"hard_stop",evidence:[{kind:"command",command:V,segment:q.target},{kind:"path",target:q.target}]}}}let U=x2("policy-protection",Y,()=>Q.findGitMetadataMutation(W,B));if(U){let V=Y??U.target;return{stage:"policy-protection",decision:{kind:"deny",reason:p1,intent:"hard_stop",evidence:[{kind:"command",command:V,segment:U.target},{kind:"path",target:U.target}]}}}let G=x2("config-load",Y,()=>Q.loadPolicySnapshot({...J.policyOptions,cwd:$.context.configCwd})),H=G.policy,L=Q.getModes(H),Z={level:L.effectiveLevel,...HE(G)},O=H.secretProtection.enabled===!1?null:x2("secret-protection",Y,()=>Q.findSensitiveTarget(W,H.secretProtection,{strict:I6($)?L.strict:void 0}));if(O){let V=Y??O.target;return{stage:"secret-protection",...Z,decision:{kind:"deny",reason:kL,intent:"hard_stop",ruleId:O.ruleId,evidence:[{kind:"command",command:V,segment:O.target},{kind:"path",target:O.target}]}}}if(!I6($))return{stage:"non-command",...Z,decision:{kind:"allow"}};if(!$.command||$.command.trim()==="")return{...HK("command-validation",Y),...Z};let M=x2("command-analysis",Y,()=>{return Q.analyzeCommand($.command,{cwd:$.context.executionCwd,shell:$.route.shell,policySnapshot:G,environment:E0(),protectedGitMetadata:B,effectiveCapabilities:L.capabilities,strict:L.strict,paranoidRm:L.paranoidRm,paranoidInterpreters:L.paranoidInterpreters,worktreeMode:L.worktreeMode},ZE(W),W.store)});if(M)return{stage:"command-analysis",...Z,decision:M};return{stage:"command-analysis",...Z,decision:{kind:"allow"}}}function HE($){if($.state==="ready")return{};return{configFallback:{reason:$.reason}}}function ZE($){return w1($,"declared-command")?.program}function LE($){try{return J4($.input)}catch(J){let Q=I6($)?$.command:void 0;throw new K2("policy-protection",HK("policy-protection",J instanceof w0?void 0:Q),J)}}function x2($,J,Q){try{return Q()}catch(X){throw new K2($,HK($,X instanceof w0?void 0:J),X)}}function HK($,J){return{stage:$,decision:{kind:"deny",reason:v6,intent:"stop_and_explain",evidence:J?[{kind:"command",command:J,segment:J}]:[]}}}function I6($){return $.route.kind==="command"}function ZO($,J){try{let Q=GO($,J.guard);return HO($,Q,J),Q}catch(Q){if(!(Q instanceof K2))throw Q;throw HO($,Q.evaluation,J,!(Q.cause instanceof w0),{stage:Q.stage,errorCode:OE(Q.cause)}),Q}}function HO($,J,Q,X=!0,Y){yK(gK($,J,Q.guard?.auditAllowed??!1,X,Y),Q.audit.getSessionId,{agent:Q.audit.agent,shape:Q.audit.shape,homeDir:Q.audit.homeDir})}function OE($){if($ instanceof o1)return"path-canonicalization-limit";if($ instanceof w0)return"tool-input-limit";if($ instanceof n0)return"structural-shell-syntax-limit";return"unexpected-error"}var OO=NE();function NE($={}){return(J,Q)=>FE(J,Q,$)}function FE($,J,Q){let X=VE($,J),Y=()=>zE($);if("malformed"in X)return xK(X.denial,Y,{agent:"amp",toolName:X.denial.toolName,cwd:X.cwd}),MO(X.denial);try{let W=ZO(X,{guard:{auditAllowed:B7(),policyOptions:Q.policyOptions,dependencies:Q.guardDependencies},audit:{agent:"amp",getSessionId:Y}});return LO(W,W.stage!=="config-state")}catch(W){if(!(W instanceof K2))throw W;if(k0(B1.debug))console.error(`CC Safety Net debug: amp tool.call analysis failed: ${nK(W.cause)}`);return LO(W.evaluation,X.route.kind==="command")}}function VE($,J){if(!$||typeof $!=="object")return u2(null);let Q=$;if(typeof Q.tool!=="string"||Q.tool.trim()==="")return u2(null);if(!Q.input||typeof Q.input!=="object")return u2(null,Q.tool);let X=_E(J);if(!X)return u2(null,Q.tool);let Y=DE(J,$);if(!Y.ok)return u2(X,Q.tool);if(!Y.command)return w3(Q.tool,Q.input,{kind:qQ(Q.tool)},{configCwd:X,executionCwd:X},null);if(typeof Y.command.command!=="string"||Y.command.command.trim()==="")return u2(X,Q.tool);let W=typeof Y.command.dir==="string"?w6(Y.command.dir,[X]):X;if(!W)return u2(X,Q.tool,Y.command.command,Y.command.dir);return w3(Q.tool,Q.input,{kind:"command",shell:"posix"},{configCwd:X,executionCwd:W},Y.command.command)}function _E($){let J=$.system.workspaceRoot;if(!J)return;try{let Q=$.helpers.filePathFromURI(J);if(typeof Q!=="string"||Q.trim()==="")return;return w6(".",[Q])}catch{return}}function DE($,J){try{return{ok:!0,command:$.helpers.shellCommandFromToolCall(J)}}catch{return{ok:!1}}}function zE($){if(!$||typeof $!=="object")return;let J=$.thread?.id;return typeof J==="string"&&J.trim()!==""?J:void 0}function u2($,J,Q,X){return{malformed:!0,denial:iK({command:Q,segment:X,toolName:J}),cwd:$}}function LO($,J){let Q=rK($,{includeEvidence:J});return Q?MO(Q):{action:"allow"}}function MO($){return{action:"reject-and-continue",message:oK($)}}function IE($){$.on("tool.call",(J)=>OO(J,$))}export{IE as default};