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.
- package/dist/amp/cc-safety-net.ts +40 -40
- package/dist/bin/cc-safety-net.js +106 -88
- package/dist/chunks/{index-9s8cwhj0.js → index-3k09xczv.js} +39 -39
- package/dist/index.js +1 -1
- package/dist/openclaw/cc-safety-net/index.js +40 -40
- package/dist/openclaw/cc-safety-net/openclaw.plugin.json +1 -1
- package/dist/openclaw/cc-safety-net/package.json +1 -1
- package/dist/pi/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// cc-safety-net managed OpenClaw plugin. Do not edit. Reinstall with: npx -y cc-safety-net install --openclaw
|
|
2
|
-
// version: 2.0.
|
|
3
|
-
var
|
|
4
|
-
`).filter((Y)=>Y.trim()).map(
|
|
5
|
-
`,{encoding:"utf-8",mode:384}),hK(q,W.now)}catch{}}function S6($,J){return{value:$.slice(0,J),truncated:$.length>J}}function gK($=process.env.CC_SAFETY_NET_AUDIT_HOME||process.env.HOME){let J=$||
|
|
2
|
+
// version: 2.0.3
|
|
3
|
+
var NM=Object.defineProperty;var FM=($)=>$;function VM($,J){this[$]=FM.bind(null,J)}var B2=($,J)=>{for(var Q in J)NM($,Q,{get:J[Q],enumerable:!0,configurable:!0,set:VM.bind(J,Q)})};var OK={id:"cc-safety-net",name:"CC Safety Net",description:"Block destructive commands and secret-file access before OpenClaw runs a tool."};import{randomBytes as ZO}from"node:crypto";import{appendFileSync as LO,mkdirSync as MO}from"node:fs";import{homedir as OO,userInfo as NO}from"node:os";import{isAbsolute as FO,join as RJ}from"node:path";var _M=[/\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 DM(J)}function DM($){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 _M)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 SK,readdirSync as eM,readFileSync as fK,rmdirSync as $O,statSync as TK,unlinkSync as JO,utimesSync as QO,writeFileSync as XO}from"node:fs";import{dirname as YO,join as l2}from"node:path";var R6=30,HJ=1,ZJ=365;function I6($){if(typeof $!=="number"||!Number.isInteger($))return 30;if($<1)return 1;return $>365?365:$}import{homedir as yM}from"node:os";import{dirname as l0,isAbsolute as xM,join as p0,relative as uM,resolve as P0,sep as mM}from"node:path";import{closeSync as zM,constants as NK,fstatSync as RM,fsyncSync as DE,lstatSync as FK,mkdirSync as zE,openSync as IM,readdirSync as RE,readFileSync as jM,realpathSync as j6,renameSync as IE,rmdirSync as jE,statSync as bM,unlinkSync as bE,writeFileSync as PE}from"node:fs";import{isAbsolute as VK,join as _K,normalize as PM,parse as AM,relative as LJ,resolve as MJ,sep as OJ}from"node:path";var EM=Symbol("PolicyFilesystemScope"),CM=Symbol("PolicyFilesystemTarget"),SM=NK.O_NOFOLLOW??0;class W1 extends Error{constructor($){super(`Unable to access ${$} filesystem safely.`);this.name="PolicyFilesystemError"}}function m0($,J){return{[EM]:!0,root:MJ($),label:J}}function DK($,J){let Q=PM(J);if(J===""||VK(J)||Q===".."||Q.startsWith(`..${OJ}`))throw new W1($.label);return{[CM]:!0,scope:$,relativePath:Q,path:_K($.root,Q)}}function b0($,J){let Q=LJ($.root,MJ(J));return DK($,Q)}function P6($,J="rules policy"){let Q=MJ($),X=AM(Q).dir;return DK(m0(X,J),LJ(X,Q))}function q2($){try{if(!b6($,!1).exists)return null;let Q=IM($.path,NK.O_RDONLY|SM);try{let X=RM(Q);if(!X.isFile())throw new W1($.scope.label);let Y=jM(Q,"utf-8"),W=FK($.path);if(!W.isFile()||W.isSymbolicLink()||X.dev!==W.dev||X.ino!==W.ino)throw new W1($.scope.label);return b6($,!1),Y}finally{zM(Q)}}catch(J){vM($.scope.label,J)}}function zK($,J){if($.path===J.path)return!0;try{if(!b6($,!1).exists||!b6(J,!1).exists)return!1;return j6($.path)===j6(J.path)}catch(Q){if(Q instanceof W1)throw Q;throw new W1($.scope.label)}}function b6($,J,Q="file"){let X=TM($.scope);if(!X)return{exists:!1};let Y=$.relativePath.split(OJ);for(let W of Y.keys()){let K=_K($.scope.root,...Y.slice(0,W+1)),B=RK(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);wM(X,j6(K),$.scope.label)}return{exists:!0}}function TM($){if(!RK($.root))return null;if(!bM($.root).isDirectory())throw new W1($.label);return j6($.root)}function wM($,J,Q){let X=LJ($,J);if(X===".."||X.startsWith(`..${OJ}`)||VK(X))throw new W1(Q)}function RK($){try{return FK($)}catch(J){if(fM(J)&&J.code==="ENOENT")return null;throw J}}function vM($,J){if(J instanceof W1)throw J;throw new W1($)}function fM($){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 IK=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)#(.+)$/;var hM=/^[A-Za-z0-9._-]+$/,kM=".cc-safety-net/rules".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),gM="rulebook.json".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),jK=new RegExp(`^${kM}/(${Y0.source.slice(1,-1)})/${gM}$`);function bK($){return`.cc-safety-net/rules/${$}/rulebook.json`}function o4($){if(E6($))try{return A6($),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 A6($){if($.startsWith("github:"))throw Error(`Invalid rulebook source: ${$}`);let J=$.match(IK);if(!J?.[1]||!J[2]||!J[3])throw Error(`Invalid GitHub rulebook source: ${$}`);let[Q,X,...Y]=J[3].split("/");if(!Q||!hM.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:bK(X),name:X}}function E6($){return IK.test($)}var AK="rule.json",C6="policy.json",lM="rule.lock";var EK=".cc-safety-net",pM="rules",PK="cache",cM="CC_SAFETY_NET_HOME",c0="`cc-safety-net rule sync`";function dM($){return P0($??process.cwd(),FJ)}function rM($){return p0(dM($),AK)}function U2($){return $?.userConfigDir??($?.userConfigPath?l0($.userConfigPath):p0(iM(),pM))}function iM(){let $=process.env[cM];return $?P0($):p0(yM(),EK)}function oM($){return p0(U2($),AK)}function n4($){return p0(l0($),lM)}function CK($){let J=$.userConfigPath??oM($),Q=$.projectConfigPath??rM($.cwd),X=nM(J,$),Y=sM(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 nM($,J){let Q=J.userConfigPath?l0(l0(P0(J.userConfigPath))):l0(P0(J.userConfigDir??U2(J)));return m0(Q,"user policy")}function sM($,J){let Q=P0(J.cwd??process.cwd()),X=P0($),Y=uM(Q,X);if(Y!==".."&&!Y.startsWith(`..${mM}`)&&!xM(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(tM(J),"rulebooks",`${aM($)}--${Q.slice(0,12)}`,NJ)}function _J($,J){let Q=J;return{cacheConfigDir:$,cwd:J.cwd,global:Q.global}}function aM($){return($.kind==="github"&&$.display_ref?`${$.owner}/${$.repo}#${$.display_ref}/${$.name}`:$.spec).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"rulebook"}function tM($){let J=$?.cacheConfigDir??U2($),Q=$;if(Q&&!Q.global&&Q.cwd&&P0(J)===P0(Q.cwd))return p0(P0(Q.cwd),EK,PK);return p0(l0(J),PK)}var zJ=86400000,WO=".last-prune",KO=/^\d{4}-\d{2}$/,BO=/^((\d{4}-\d{2})-\d{2})-.+\.jsonl$/,wK=($)=>Math.floor($/zJ);function qO($){try{let J=l2(YO(U2($)),C6),Q=JSON.parse(fK(J,"utf-8"));return I6(Q?.audit?.retention_days)}catch{return R6}}function hK($,J=()=>new Date){try{let Q=J().getTime();if(!TK($,{throwIfNoEntry:!1})?.isDirectory())return;let X=l2($,WO),Y=TK(X,{throwIfNoEntry:!1})?.mtimeMs;if(Y!==void 0&&wK(Y)===wK(Q))return;let W=Q-qO()*zJ,K=new Date(Q).toISOString().slice(0,7);for(let B of DJ($)){if(B.isDirectory()){UO(l2($,B.name),W,K);continue}if(B.isFile()&&B.name.endsWith(".jsonl"))GO(l2($,B.name),W)}XO(X,"",{mode:384}),QO(X,Q/1000,Q/1000)}catch{}}function UO($,J,Q){for(let X of DJ($)){if(!X.isDirectory()||!KO.test(X.name))continue;let Y=l2($,X.name);for(let W of DJ(Y)){if(!W.isFile())continue;let K=BO.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;kK(l2(Y,W.name))}if(X.name!==Q)vK(Y)}vK($)}function GO($,J){try{let Q=SK($);if(Q.mtimeMs>=J)return;let X=fK($,"utf-8").split(`
|
|
4
|
+
`).filter((Y)=>Y.trim()).map(HO);if(X.length===0)return;if(X.some((Y)=>Y===void 0||Y>=J))return;if(SK($).mtimeMs!==Q.mtimeMs)return;kK($)}catch{}}function HO($){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 eM($,{withFileTypes:!0,encoding:"utf8"})}catch{return[]}}function kK($){try{JO($)}catch{}}function vK($){try{$O($)}catch{}}var VO="2.0.3",_O=1e4,DO=2000,zO=256,RO=32768;function IO($){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 jO($){return($??"").replace(/[^A-Za-z0-9]/g,"-").slice(0,180)||"no-cwd"}function IJ($,J,Q,X,Y,W={}){let K=IO($);if(!K)return;let B=W.homeDir??gK();if(!B)return;let q=bO(B);if(!q)return;try{let U=(W.now??(()=>new Date))().toISOString(),G=S6(j0(J),_O),H=S6(j0(Q),DO),L=W.toolName?S6(j0(W.toolName),zO):void 0,Z=Y===null?void 0:S6(j0(Y),RO),M=RJ(q,jO(Z?.value??null),U.slice(0,7));MO(M,{recursive:!0,mode:448});let O=RJ(M,`${U.slice(0,10)}-${K}.jsonl`),V={ts:U,id:(W.createId??(()=>ZO(8).toString("hex")))(),v:VO,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};LO(O,`${JSON.stringify(V)}
|
|
5
|
+
`,{encoding:"utf-8",mode:384}),hK(q,W.now)}catch{}}function S6($,J){return{value:$.slice(0,J),truncated:$.length>J}}function gK($=process.env.CC_SAFETY_NET_AUDIT_HOME||process.env.HOME){let J=$||OO()||NO().homedir;return J&&FO(J)?J:null}function bO($=gK()){return $?RJ($,".cc-safety-net","logs"):null}function xK($,J,Q,X=!0,Y){if(J.decision.kind==="allow"){if(!Q||$.route.kind!=="command")return;let B=yK($);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?yK($):"");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 yK($){return"command"in $?$.command??"":""}function uK($,J,Q){if(!$)return;let X;try{X=J()}catch{return}if(typeof X!=="string"||!X.trim())return;IJ(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 mK($,J,Q){let X;try{X=J()}catch{return}if(typeof X!=="string"||!X.trim())return;IJ(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 vO,statSync as fO}from"node:fs";import{isAbsolute as pK,relative as hO,resolve as kO,sep as gO}from"node:path";import{dirname as PO,isAbsolute as AO,parse as EO,sep as CO}from"node: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=AO(J)?TO(J):"",Y=X||$;for(let W of wO(X?J.slice(X.length):J)){if(W===""||W===".")continue;if(W===".."){Y=PO(Y);continue}let K=SO(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 SO($,J){return $.endsWith("/")||$.endsWith("\\")?`${$}${J}`:`${$}${CO}${J}`}function TO($){return EO($).root}function wO($){let J=process.platform==="win32"?/[\\/]+/:/\/+/;return $.split(J)}function T6($,J){if(G2($))return;let Q=J.flatMap((Y)=>lK(Y));if(!Q[0])return;let X=lK(pK($)?$:kO(Q[0],$))[0];if(!X)return;return Q.some((Y)=>cK(X,Y))?X:void 0}function lK($){try{let J=vO($);return fO(J).isDirectory()?[J]:[]}catch{return[]}}function cK($,J){let Q=hO(J,$);return Q===""||Q!==".."&&!Q.startsWith(`..${gO}`)&&!pK(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.",dK="CC Safety Net could not validate the command because its structure exceeds safe analysis limits.",w6="CC Safety Net failed closed because command analysis failed unexpectedly. This is not caused by your command. Report it to the user.";function iK($){let{reason:J,command:Q,segment:X,toolName:Y}=$,W=$.maxLen??200,K=$.redact??((q)=>q),B=`BLOCKED by CC Safety Net
|
|
6
6
|
|
|
7
7
|
Reason: ${K(J)}`;if($.ruleId)B+=`
|
|
8
8
|
|
|
@@ -16,51 +16,51 @@ Segment: ${rK(q,W)}`}if($.configWarning)B+=`
|
|
|
16
16
|
|
|
17
17
|
Config warning: ${K($.configWarning)}`;return B+=`
|
|
18
18
|
|
|
19
|
-
${
|
|
20
|
-
`;break;case"t":J+="\t";break;case"b":J+="\b";break;default:J+=`\\${Y}`;break}Q++}return J}function XB($,J){try{let Q=d0($,J,i0);return qB(Q)?Q:null}catch{return null}}function qB($){try{return t4($).isDirectory()}catch{return!1}}function
|
|
21
|
-
`||$==="\r"||$==="\u2028"||$==="\u2029"}function e($,J,Q){if(J+Q.length>K1($))return!1;for(let X=0;X<Q.length;X++)if(I($,J+X)!==Q[X])return!1;return!0}function
|
|
22
|
-
`||$===";"||$==="&"||$==="|"}function d2($){return $==="|"||$===";"}function p6($,J,Q){let X=fJ($,Q);if(J==="rm")return
|
|
23
|
-
`)J=!0,W++;continue}let B=
|
|
24
|
-
`||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=UB($,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=UB($,Y,W);if(Q||=q.recursive,X||=q.force,Q&&X)return!0}Y=-1}continue}if(Y<0)Y=W}return!1}function
|
|
25
|
-
`,B++;if(q)Q=!1,X=!1;J=!0,Y=B;continue}if(!J){Y++;continue}if(e($,Y,"--")&&(Y===0||t(I($,Y-1)))&&(!I($,Y+2)||t(I($,Y+2))||L1(I($,Y+2)))){J=!1,Q=!1,X=!1,Y+=2;continue}if(Q||=e($,Y,"--recursive")&&C0($,Y+11)||kJ($,Y,"recursive"),X||=e($,Y,"--force")&&C0($,Y+7)||kJ($,Y,"force"),Q&&X)return!0;Y++}return!1}function kJ($,J,Q){if(!e($,J,"--"))return!1;let X=0;while(X<=Q.length){let Y=I($,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 LN($,J){let Q=J,X=!1,Y=!1;while(Q<K1($)){while(t(I($,Q)))Q++;let W=Q;while(Q<K1($)&&!t(I($,Q)))Q++;if(I($,W)!=="-"||Q-W===2&&e($,W,"--"))return!1;let K=HB($,W,"recursive"),B=HB($,W,"force");if(X&&B||Y&&K)return!0;if(X||=K,Y||=B,I($,W+1)==="-")continue;let q=ON($,W,Q);if(q.combined||X&&q.forceAtBoundary||Y&&q.recursiveAtBoundary)return!0;X||=q.recursive,Y||=q.force}return!1}function HB($,J,Q){return e($,J,`--${Q}`)&&C0($,J+Q.length+2)||kJ($,J,Q)}function MN($,J){if(J>0&&Z2(I($,J-1)))return-1;let Q=J;if(I($,Q)==="\\")Q++;if(I($,Q)!=="r")return-1;if(Q++,I($,Q)==="\\")Q++;if(I($,Q)!=="m"||!t(I($,Q+1)))return-1;return Q+1}function ON($,J,Q){let X=!1,Y=!1,W=!1,K=!1,B=!1;if(I($,J)!=="-")return{recursive:X,force:Y,recursiveAtBoundary:W,forceAtBoundary:K,combined:B};let q="";for(let U=J+1;U<Q;U++){let G=I($,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 ZB($,J,Q){return X3($,"reset",d2,!0,(X)=>I($,X)==="-"&&r2($,X,J,Q)?!0:X)}function NN($){return X3($,"clean",d2,!0,(J)=>{if(I($,J)!=="-")return J;if(r2($,J,"--fo","rce"))return!0;let Q=Q3($,J,d2);for(let X=J+1;X<Q;X++)if(I($,X)==="f")return!0;return Q-1})}function d6($,J,Q){if(!E0($,J,"git"))return null;let X=J+3;if(!t(I($,X)))return{commandEnd:-1,next:X};while(t(I($,X)))X++;while(X<K1($)){if(L1(I($,X)))return{commandEnd:-1,next:X};let Y=Q3($,X,L1);if(E0($,X,Q))return{commandEnd:X+Q.length,next:Y};if(I($,X)!=="-")return{commandEnd:-1,next:Y};let W=Y-X===2&&e($,X,"--"),K=FN($,X,Y);X=Y;while(t(I($,X)))X++;if(W)return{commandEnd:E0($,X,Q)?X+Q.length:-1,next:Q3($,X,L1)};if(!K)continue;if(X>=K1($)||L1(I($,X)))return{commandEnd:-1,next:X};X=Q3($,X,L1);while(t(I($,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 LB($,{command:"checkout",longPrefix:"--fo",longOptional:"rce",shortFlag:"f",excludedShortStarts:"bBU"})}function _N($){return X3($,"push",d2,!0,(J)=>{if(I($,J)!=="-")return J;if(I($,J+1)==="f"&&!Z2(I($,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(I($,J))&&I($,J+1)==="+"&&J+2<K1($)&&!L1(I($,J+2))&&!t(I($,J+2)))return!0;if(I($,J)===":"&&I($,J+1)==="+")return!0;return J})}function zN($){return X3($,"push",L1,!1,(J)=>{if(I($,J)==="-"&&r2($,J,"--de","lete"))return!0;if(t(I($,J))&&I($,J+1)===":"&&J+2<K1($)&&!t(I($,J+2))&&!L1(I($,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(I($,Y))){if(Q&&X)return!0;J=!1,Q=!1,X=!1;continue}if(!J){let B=d6($,Y,"branch");if(B){J=B.commandEnd>=0,Y=Math.max(Y,(J?B.commandEnd:B.next)-1);continue}}if(!J||I($,Y)!=="-")continue;let W=Q3($,Y,L1),K=IN($,Y,W);if(Q||=K.deletion,X||=K.force,Q&&X)return!0;Y=W-1}return!1}function IN($,J,Q){let X=!1,Y=!1;for(let W=J;W<Q;W++){if(I($,W)!=="-")continue;if(r2($,W,"--de","lete"))X=!0;if(r2($,W,"--fo","rce"))Y=!0;if(I($,W+1)==="-")continue;let K=W+1,B=!1,q=!1,U=!1;while(K<Q&&jN(I($,K))){let G=I($,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 jN($){if(!$)return!1;let J=$.charCodeAt(0);return J>=65&&J<=90||J>=97&&J<=122}function bN($){return LB($,{command:"tag",longPrefix:"--de",longOptional:"lete",shortFlag:"d",excludedShortStarts:""})}function LB($,J){let Q=[{outerActive:!1,shortActive:!1,hasShortFlag:!1,depth:0,quote:"",escaped:!1}];for(let X=0;X<K1($);X++){let Y=I($,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==="$"&&I($,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=d6($,X,J.command);if(B){W.outerActive=B.commandEnd>=0&&t(I($,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(I($,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=I($,K),q=Q(B);if(!W&&!q){let U=d6($,K,J);if(U){W=U.commandEnd>=0&&(!X||t(I($,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(I($,G)))W=!1;K=U}if(q)W=!1}return!1}function PN($){let J=!1;for(let Q=0;Q<K1($);Q++){if(hJ(I($,Q))){if(J)return!0;J=!1;continue}if(!J){let X=d6($,Q,"restore");if(X){J=X.commandEnd>=0,Q=Math.max(Q,(J?X.commandEnd:X.next)-1);continue}}if(J&&I($,Q)==="-"&&I($,Q+1)==="-"&&(e($,Q+2,"staged")||e($,Q+2,"help")))J=!1}return J}function MB($,J){let Q=!1;for(let X=0;X<K1($);X++){let Y=I($,X),W=J?hJ(Y):L1(Y);if(Q&&t(Y)&&I($,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(I($,X))&&!Q(I($,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&&I($,Y)===X[W];W++)Y++;return C0($,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"],r6=new Set(AN),i6=[{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(i6.map(($)=>[$.id,$.intent])),NB=new Set(i6.filter(($)=>$.catastrophic).map(($)=>$.id));function z($,J){return{id:$,reason:J,intent:EN.get($)??"manual_only"}}function k($,J){if(!$)return null;if(NB.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(NB.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 FB($,J){return Object.freeze(Object.fromEntries(i6.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 VB($,J){return Object.freeze({...$,effectiveDestructiveCommandRules:FB($,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)C1(J,B);if((K.regex?.test(B)??!1)||K.scan&&c6(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 CN=/^[A-Za-z_][A-Za-z0-9_]*=/;function DB($,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 zB(J.nodes,X,W)}function zB($,J,Q){return $.every((X)=>{if(X.kind==="connector")return!0;if(X.kind==="group"||X.kind==="function")return zB(X.body.nodes,J,Q);if(X.kind==="unknown")return!Q.loose.test(X.source);return SN(X,J,Q)})}function SN($,J,Q){if($.nested.some((Y)=>Q.loose.test(Y.source)))return!1;let X=$.words.findIndex((Y)=>!CN.test(Y.text));return $.words.every((Y,W)=>Y===J||_B(Y.raw,Q.anchored,W!==X))&&$.redirections.every((Y)=>(!Y.heredoc||Y.heredoc.quotedDelimiter||!Q.loose.test(Y.heredoc.body))&&(!Y.target||_B(Y.target.raw,Q.anchored,!0)))}function _B($,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 RB=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 o6(){return{derivedTokens:0}}function K0($,J){if(!Number.isSafeInteger($.derivedTokens)||$.derivedTokens<0||$.derivedTokens>RB.maxDerivedTokens||!Number.isSafeInteger(J)||J<0||J>RB.maxDerivedTokens-$.derivedTokens)throw new m1;$.derivedTokens+=J}import{isAbsolute as TN,resolve as bB}from"node:path";var PB=64;function W3($,J,Q){let X=TN($)?bB($):J?bB(J,$):void 0;if(!X)return;try{return J1(X,Q)}catch{return X}}function AB($){return!["/dev","/proc","/sys"].some((J)=>$===J||$.startsWith(`${J}/`))}function i($){return l($).toLowerCase()}function l($){return $.split(/[\\/]/).pop()?.replace(/\.exe$/i,"")??$}var n6=10,i2=20,M2=/^[a-zA-Z][a-zA-Z0-9_-]*$/,o2=256,H1=new Set(["bash","sh","zsh","ksh","dash","fish","csh","tcsh"]),EB=new Set(["python","python3","python2","node","ruby","perl"]),CB=/^python(?:[23](?:\.\d+)*)?$/,s6=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 O2="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.",a6=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 t6($){return $9($).code}function e6($){return $9($).sources}function TB($){return mN.get(Q9($))??[]}function $9($){let J=Q9($[0]??"");if(!a6.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),M=Z||$[W+1];if(M!==void 0)X.push({tokenIndex:Z?W:W+1,kind:"module-file",value:M});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),M=Z||$[W+1];if(Y&&=M!==void 0,M!==void 0)X.push({tokenIndex:Z?W:W+1,kind:"module-file",value:M});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(`
|
|
26
|
-
`))||null,sources:X?U:[],optionsOpen:X&&K}}function
|
|
27
|
-
`;function K3($,J){if(B0($,J))return!0;if(!$.has("TMPDIR"))return!1;return!gJ($.get("TMPDIR")??"",J)}function
|
|
28
|
-
`;if($==="r")return"\r";if($==="t")return"\t";if($==="v")return"\v";if($==="_")return" ";if($==="#"||$==="$"||$==='"'||$==="'")return $;if($==="\\")return"\\";return}function
|
|
29
|
-
`||$==="\r"||$==="\f"||$==="\v"}function B3($,J,Q){if(J==="")return null;if(!$&&!mB(J))return null;let X=mB(J)?
|
|
30
|
-
`||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 pJ($,J,Q,X){let Y=[],W=J;for(let K of X){let B=W,q=!1;while(W<Q){let U=
|
|
31
|
-
`&&$[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 oB($){return/[\s;&|<>)]/u.test($)||$==="`"}function
|
|
19
|
+
${yO($.intent??"manual_only")}`,B}function yO($){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 rK($,J){return $.length>J?`${$.slice(0,J)}...`:$}function oK($,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 jJ($={}){return{reason:w6,intent:"stop_and_explain",command:$.command,segment:$.segment??$.command,toolName:$.toolName}}function nK($){return iK({...$,redact:j0})}function sK($){return j0($ instanceof Error?$.message:String($))}import{basename as xO,dirname as uO,join as aK}from"node:path";var v6=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 f6=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 h6($,J){return bJ($,0,J)}function bJ($,J,Q){let X="",Y=0;while(Y<$.length){if($[Y]!=="$"){X+=$[Y],Y++;continue}if($[Y+1]==="{"){let K=PJ($,Y+2),B=mO($,Y,J);if(B===null){if(f6.has(K))throw new o1;X+=$.slice(Y);break}let q=$.slice(Y,B+1);X+=lO(q,J,Q),Y=B+1;continue}let W=PJ($,Y+1);if(!W){X+="$",Y++;continue}X+=AJ(W,Q)??`$${W}`,Y+=W.length+1}return X}function mO($,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>v6.maxEnvironmentExpansionDepth)throw new o1;Y++;continue}if($[Y]!=="}")continue;if(X--,X===0)return Y}return null}function lO($,J,Q){let X=$.slice(2,-1),Y=PJ(X,0);if(!Y)return $;let W=X.slice(Y.length);if(!W)return AJ(Y,Q)??$;let K=[":-",":+",":=",":?","-","+","=","?"].find((U)=>W.startsWith(U));if(!K){if(f6.has(Y))throw new o1;return $}if(!f6.has(Y))return $;if(K.endsWith("="))throw new o1;let B=AJ(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??"":bJ(W.slice(K.length),J+1,Q);return q?bJ(W.slice(K.length),J+1,Q):""}function PJ($,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>v6.maxRealpathAttempts||Q.processedCandidateBytes>v6.maxProcessedCandidateBytes)throw new o1;let K=J.realpath(W);if(K!==null){let q=Y.length===0?K:aK(K,...Y.reverse());return Q.resolvedPaths.set($,q),q}let B=uO(W);if(B===W){let q=Y.length===0?W:aK(W,...Y.reverse());return Q.resolvedPaths.set($,q),q}if(Y.length>=v6.maxMissingSuffixComponents)throw new o1;Y.push(xO(W)),W=B}}function AJ($,J){if(!f6.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 k6($,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 sO,readFileSync as u6,realpathSync as e4,statSync as t4}from"node:fs";import{dirname as TJ,isAbsolute as wJ,join as m6,resolve as l6}from"node:path";import{lstatSync as pO,realpathSync as cO}from"node:fs";import{homedir as dO,tmpdir as rO}from"node:os";var i0={realpath:($)=>{try{return cO($)}catch{return null}},entryKind:($)=>{let J=pO($,{throwIfNoEntry:!1});if(!J)return"missing";return J.isSymbolicLink()?"symlink":"present"}};function c2(){return process.env.HOME||dO()}function E0(){return{env:new Map(Object.entries(process.env).flatMap(([$,J])=>J===void 0?[]:[[$,J]])),home:c2(),tmpdir:rO(),paths:i0}}var EJ=["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE"],iO=new Set(EJ);var tK=new Set(["GIT_CONFIG_GLOBAL","GIT_CONFIG_NOSYSTEM","GIT_CONFIG_SYSTEM","HOME","XDG_CONFIG_HOME"]),g6=new Set(["GIT_SSH_COMMAND","GIT_SSH","GIT_SSH_VARIANT"]),oO=/^([A-Za-z_][A-Za-z0-9_]*)\+=/;function nO($){return iO.has($)}function a4($){return $==="GIT_CONFIG_COUNT"||$==="GIT_CONFIG_PARAMETERS"||/^GIT_CONFIG_(KEY|VALUE)_\d+$/.test($)}function CJ($){return nO($)||tK.has($)||g6.has($)||a4($)}function u1($,J,Q){return Q?.has($)?Q.get($):J.get($)}function y6($,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 x6($,J,Q){let Y=$.match(oO)?.[1];if(!Y||!CJ(Y))return null;let W=$.indexOf("=");return{name:Y,value:`${u1(Y,J,Q)??""}${$.slice(W+1)}`}}function eK($){return JB($,g6)}function $B($){return JB($,tK)}function JB($,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 YB($,J){return EJ.some((Q)=>J?.has(Q)||$.has(Q))}function WB($,J){if(!J)return{gitCwd:null,hasExplicitGitContext:!1};let Q;try{Q=e4(l6(J))}catch{return{gitCwd:null,hasExplicitGitContext:!1}}if(!qB(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=XB(Q,K);if(!B)return{gitCwd:null,hasExplicitGitContext:X};Q=B,Y+=2;continue}if(W.startsWith("-C")&&W.length>2){let K=XB(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 KB($){let J=GN($);if(!J)return!1;try{let Q=sO(J);if(Q.isSymbolicLink()||!Q.isFile())return!1;let X=vJ(J);if(!X?.commonDir)return!1;if(!eO(X.gitDir,J))return!1;return $N(X.gitDir,TJ(J))}catch{return!1}}function vJ($){try{let J=aO($);if(!J)return null;let Q=e4(wJ(J)?J:l6(TJ($),J));if(!t4(Q).isDirectory())return null;return{gitDir:Q,commonDir:tO(Q)}}catch{return null}}function aO($){let J=u6($,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(!J.startsWith("gitdir:"))return null;return J.slice(7).trim()||null}function tO($){try{let J=u6(m6($,"commondir"),"utf-8").split(/\r?\n/,1)[0]?.trim();if(!J)return null;let Q=e4(wJ(J)?J:l6($,J));return t4(Q).isDirectory()?Q:null}catch{return null}}function eO($,J){let Q=JN($);return Q===null?!1:BB($,Q,J)}function $N($,J){let Q=QN($);return Q===null?!0:BB($,Q,J)}function JN($){let J=m6($,"gitdir");if(!SJ(J))return null;let Q=u6(J,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";return Q===""?null:Q}function QN($){let J=m6($,"config.worktree");return SJ(J)?BN(J):null}function BB($,J,Q){return YN(XN($,J),Q)}function XN($,J){return wJ(J)?J:l6($,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 QB($)===QB(J)}function QB($){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=u6($,"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+=`
|
|
20
|
+
`;break;case"t":J+="\t";break;case"b":J+="\b";break;default:J+=`\\${Y}`;break}Q++}return J}function XB($,J){try{let Q=d0($,J,i0);return qB(Q)?Q:null}catch{return null}}function qB($){try{return t4($).isDirectory()}catch{return!1}}function GN($){try{return $3(e4($))}catch{return null}}function $3($){let J=$;while(!0){let Q=m6(J,".git");if(SJ(Q))return Q;let X=TJ(J);if(X===J)return null;J=X}}function fJ($,J){return{value:$,work:J}}function I($,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 C1($,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 hJ($){return $===`
|
|
21
|
+
`||$==="\r"||$==="\u2028"||$==="\u2029"}function e($,J,Q){if(J+Q.length>K1($))return!1;for(let X=0;X<Q.length;X++)if(I($,J+X)!==Q[X])return!1;return!0}function C0($,J,Q){return!Z2(I($,J-1))&&e($,J,Q)&&!Z2(I($,J+Q.length))}function S0($,J){return Z2(I($,J-1))!==Z2(I($,J))}function L1($){return $===`
|
|
22
|
+
`||$===";"||$==="&"||$==="|"}function d2($){return $==="|"||$===";"}function p6($,J,Q){let X=fJ($,Q);if(J==="rm")return HN(X);if(J==="dd")return LN(X);return MB(X,!0)}function c6($,J,Q){let X=fJ($,Q);if(J==="rm")return MN(X);if(J==="reset-hard")return ZB(X,"--ha","rd");if(J==="reset-merge")return ZB(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 RN(X);if(J==="push-delete")return IN(X);if(J==="branch")return jN(X);if(J==="tag")return AN(X);if(J==="restore")return EN(X);return MB(X,!1)}function HN($){let J=!1,Q=!1,X=!1,Y=-1;for(let W=0;W<=K1($);W++){let K=I($,W);if(!J){let q=I($,W+2);if(C0($,W,"rm")&&t(q)&&q!==`
|
|
23
|
+
`)J=!0,W++;continue}let B=ZN($,W);if(K===`
|
|
24
|
+
`||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=UB($,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=UB($,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(I($,J)!=="\\"||I($,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 UB($,J,Q){if(GB($,J,Q,"recursive"))return{recursive:!0,force:!1};if(GB($,J,Q,"force"))return{recursive:!1,force:!0};if(I($,J)!=="-"||I($,J+1)==="-")return{recursive:!1,force:!1};let X=!1,Y=!1;for(let W=J+1;W<Q;W++){let K=I($,W);X||=K==="r"||K==="R",Y||=K==="f"||K==="F"}return{recursive:X,force:Y}}function GB($,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(I($,J+W+2)!==X[W])return!1;return!0}function LN($){let J=!1;for(let Q=0;Q<K1($);Q++){if(L1(I($,Q))){J=!1;continue}if(C0($,Q,"dd")){J=!0,Q++;continue}if(!J||!C0($,Q,"of")||!e($,Q,"of=/dev/"))continue;let X=Q+8;if(X<K1($)&&!t(I($,X))&&I($,X)!=="'"&&I($,X)!=='"')return!0}return!1}function MN($){let J=!1,Q=!1,X=!1;for(let Y=0;Y<=K1($);){let W=I($,Y);if(Y===K1($)||L1(W)){J=!1,Q=!1,X=!1,Y++;continue}let K=NN($,Y);if(K>=0){if(ON($,K))return!0;let B=K,q=!1;while(t(I($,B)))q||=I($,B)===`
|
|
25
|
+
`,B++;if(q)Q=!1,X=!1;J=!0,Y=B;continue}if(!J){Y++;continue}if(e($,Y,"--")&&(Y===0||t(I($,Y-1)))&&(!I($,Y+2)||t(I($,Y+2))||L1(I($,Y+2)))){J=!1,Q=!1,X=!1,Y+=2;continue}if(Q||=e($,Y,"--recursive")&&S0($,Y+11)||kJ($,Y,"recursive"),X||=e($,Y,"--force")&&S0($,Y+7)||kJ($,Y,"force"),Q&&X)return!0;Y++}return!1}function kJ($,J,Q){if(!e($,J,"--"))return!1;let X=0;while(X<=Q.length){let Y=I($,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 ON($,J){let Q=J,X=!1,Y=!1;while(Q<K1($)){while(t(I($,Q)))Q++;let W=Q;while(Q<K1($)&&!t(I($,Q)))Q++;if(I($,W)!=="-"||Q-W===2&&e($,W,"--"))return!1;let K=HB($,W,"recursive"),B=HB($,W,"force");if(X&&B||Y&&K)return!0;if(X||=K,Y||=B,I($,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 HB($,J,Q){return e($,J,`--${Q}`)&&S0($,J+Q.length+2)||kJ($,J,Q)}function NN($,J){if(J>0&&Z2(I($,J-1)))return-1;let Q=J;if(I($,Q)==="\\")Q++;if(I($,Q)!=="r")return-1;if(Q++,I($,Q)==="\\")Q++;if(I($,Q)!=="m"||!t(I($,Q+1)))return-1;return Q+1}function FN($,J,Q){let X=!1,Y=!1,W=!1,K=!1,B=!1;if(I($,J)!=="-")return{recursive:X,force:Y,recursiveAtBoundary:W,forceAtBoundary:K,combined:B};let q="";for(let U=J+1;U<Q;U++){let G=I($,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 ZB($,J,Q){return X3($,"reset",d2,!0,(X)=>I($,X)==="-"&&r2($,X,J,Q)?!0:X)}function VN($){return X3($,"clean",d2,!0,(J)=>{if(I($,J)!=="-")return J;if(r2($,J,"--fo","rce"))return!0;let Q=Q3($,J,d2);for(let X=J+1;X<Q;X++)if(I($,X)==="f")return!0;return Q-1})}function d6($,J,Q){if(!C0($,J,"git"))return null;let X=J+3;if(!t(I($,X)))return{commandEnd:-1,next:X};while(t(I($,X)))X++;while(X<K1($)){if(L1(I($,X)))return{commandEnd:-1,next:X};let Y=Q3($,X,L1);if(C0($,X,Q))return{commandEnd:X+Q.length,next:Y};if(I($,X)!=="-")return{commandEnd:-1,next:Y};let W=Y-X===2&&e($,X,"--"),K=_N($,X,Y);X=Y;while(t(I($,X)))X++;if(W)return{commandEnd:C0($,X,Q)?X+Q.length:-1,next:Q3($,X,L1)};if(!K)continue;if(X>=K1($)||L1(I($,X)))return{commandEnd:-1,next:X};X=Q3($,X,L1);while(t(I($,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 LB($,{command:"checkout",longPrefix:"--fo",longOptional:"rce",shortFlag:"f",excludedShortStarts:"bBU"})}function zN($){return X3($,"push",d2,!0,(J)=>{if(I($,J)!=="-")return J;if(I($,J+1)==="f"&&!Z2(I($,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 RN($){return X3($,"push",L1,!1,(J)=>{if(t(I($,J))&&I($,J+1)==="+"&&J+2<K1($)&&!L1(I($,J+2))&&!t(I($,J+2)))return!0;if(I($,J)===":"&&I($,J+1)==="+")return!0;return J})}function IN($){return X3($,"push",L1,!1,(J)=>{if(I($,J)==="-"&&r2($,J,"--de","lete"))return!0;if(t(I($,J))&&I($,J+1)===":"&&J+2<K1($)&&!t(I($,J+2))&&!L1(I($,J+2)))return!0;return J})}function jN($){let J=!1,Q=!1,X=!1;for(let Y=0;Y<=K1($);Y++){if(Y===K1($)||L1(I($,Y))){if(Q&&X)return!0;J=!1,Q=!1,X=!1;continue}if(!J){let B=d6($,Y,"branch");if(B){J=B.commandEnd>=0,Y=Math.max(Y,(J?B.commandEnd:B.next)-1);continue}}if(!J||I($,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(I($,W)!=="-")continue;if(r2($,W,"--de","lete"))X=!0;if(r2($,W,"--fo","rce"))Y=!0;if(I($,W+1)==="-")continue;let K=W+1,B=!1,q=!1,U=!1;while(K<Q&&PN(I($,K))){let G=I($,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 PN($){if(!$)return!1;let J=$.charCodeAt(0);return J>=65&&J<=90||J>=97&&J<=122}function AN($){return LB($,{command:"tag",longPrefix:"--de",longOptional:"lete",shortFlag:"d",excludedShortStarts:""})}function LB($,J){let Q=[{outerActive:!1,shortActive:!1,hasShortFlag:!1,depth:0,quote:"",escaped:!1}];for(let X=0;X<K1($);X++){let Y=I($,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==="$"&&I($,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=d6($,X,J.command);if(B){W.outerActive=B.commandEnd>=0&&t(I($,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(I($,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=I($,K),q=Q(B);if(!W&&!q){let U=d6($,K,J);if(U){W=U.commandEnd>=0&&(!X||t(I($,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(I($,G)))W=!1;K=U}if(q)W=!1}return!1}function EN($){let J=!1;for(let Q=0;Q<K1($);Q++){if(hJ(I($,Q))){if(J)return!0;J=!1;continue}if(!J){let X=d6($,Q,"restore");if(X){J=X.commandEnd>=0,Q=Math.max(Q,(J?X.commandEnd:X.next)-1);continue}}if(J&&I($,Q)==="-"&&I($,Q+1)==="-"&&(e($,Q+2,"staged")||e($,Q+2,"help")))J=!1}return J}function MB($,J){let Q=!1;for(let X=0;X<K1($);X++){let Y=I($,X),W=J?hJ(Y):L1(Y);if(Q&&t(Y)&&I($,X+1)==="-"&&C0($,X+2,"delete"))return!0;if(W){Q=!1;continue}if(C0($,X,"find"))Q=!0,X+=3}return!1}function Q3($,J,Q){let X=J;while(X<K1($)&&!t(I($,X))&&!Q(I($,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&&I($,Y)===X[W];W++)Y++;return S0($,Y)?Y:-1}function r2($,J,Q,X){return OB($,J,Q,X)>=0}var CN=["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"],r6=new Set(CN),i6=[{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"}],SN=new Map(i6.map(($)=>[$.id,$.intent])),NB=new Set(i6.filter(($)=>$.catastrophic).map(($)=>$.id));function z($,J){return{id:$,reason:J,intent:SN.get($)??"manual_only"}}function k($,J){if(!$)return null;if(NB.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(NB.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 FB($,J){return Object.freeze(Object.fromEntries(i6.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 VB($,J){return Object.freeze({...$,effectiveDestructiveCommandRules:FB($,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)C1(J,B);if((K.regex?.test(B)??!1)||K.scan&&c6(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 DB($,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 zB(J.nodes,X,W)}function zB($,J,Q){return $.every((X)=>{if(X.kind==="connector")return!0;if(X.kind==="group"||X.kind==="function")return zB(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||_B(Y.raw,Q.anchored,W!==X))&&$.redirections.every((Y)=>(!Y.heredoc||Y.heredoc.quotedDelimiter||!Q.loose.test(Y.heredoc.body))&&(!Y.target||_B(Y.target.raw,Q.anchored,!0)))}function _B($,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 RB=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 o6(){return{derivedTokens:0}}function K0($,J){if(!Number.isSafeInteger($.derivedTokens)||$.derivedTokens<0||$.derivedTokens>RB.maxDerivedTokens||!Number.isSafeInteger(J)||J<0||J>RB.maxDerivedTokens-$.derivedTokens)throw new m1;$.derivedTokens+=J}import{isAbsolute as vN,resolve as bB}from"node:path";var PB=64;function W3($,J,Q){let X=vN($)?bB($):J?bB(J,$):void 0;if(!X)return;try{return J1(X,Q)}catch{return X}}function AB($){return!["/dev","/proc","/sys"].some((J)=>$===J||$.startsWith(`${J}/`))}function i($){return l($).toLowerCase()}function l($){return $.split(/[\\/]/).pop()?.replace(/\.exe$/i,"")??$}var n6=10,i2=20,M2=/^[a-zA-Z][a-zA-Z0-9_-]*$/,o2=256,H1=new Set(["bash","sh","zsh","ksh","dash","fish","csh","tcsh"]),EB=new Set(["python","python3","python2","node","ruby","perl"]),CB=/^python(?:[23](?:\.\d+)*)?$/,s6=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 O2="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.",a6=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 t6($){return $9($).code}function e6($){return $9($).sources}function TB($){return pN.get(Q9($))??[]}function $9($){let J=Q9($[0]??"");if(!a6.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),M=Z||$[W+1];if(M!==void 0)X.push({tokenIndex:Z?W:W+1,kind:"module-file",value:M});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),M=Z||$[W+1];if(Y&&=M!==void 0,M!==void 0)X.push({tokenIndex:Z?W:W+1,kind:"module-file",value:M});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(`
|
|
26
|
+
`))||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 S1($){return a6.has(Q9($))}function J9($,J){return Q9($)==="node"&&/^\s*console\.(?:log|info|warn|error)\(\s*(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*')\s*\)\s*;?\s*$/.test(J)}function Q9($){let J=l($).toLowerCase();return CB.test(J)?"python":J}function dN($,J){return a6.get($)?.has(J)??!1}function rN($){return a6.get($)?.has("--eval")??!1}function s2($,J){let Q=nN($,J);if(!SB(Q,J))return!1;C1(J,Q);let X=oN(Q);if(SB(X,J))return!0;return C1(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(p6($,"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(C1(J,$),X.test($))return!0;if(p6($,"dd",J))return!0;for(let X of[/\bmkfs(?:\.[A-Za-z0-9_-]+)?\s+\/dev\/[^\s'"]+/,/\bshred\b\s+/])if(C1(J,$),X.test($))return!0;if(p6($,"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 C1(J,$),Q.some((Y)=>c6(Y,X))})}function nN($,J){return C1(J,$),$.replace(lN,"")}var f=Object.freeze({maxChildAnalyses:1024,maxDerivedTokens:16384,maxDerivedBytes:1048576,maxPlaceholderReplacements:16384}),wB="Parallel command expands beyond CC Safety Net's analysis limits. Reduce the template or explicit argument list and retry.";class Y9 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 vB(){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(X9($.childAnalyses,Q,f.maxChildAnalyses)||X9($.derivedTokens,X,f.maxDerivedTokens)||X9($.derivedBytes,Y,f.maxDerivedBytes)||X9($.placeholderReplacements,W,f.maxPlaceholderReplacements))throw new Y9;$.childAnalyses+=Q,$.derivedTokens+=X,$.derivedBytes+=Y,$.placeholderReplacements+=W}function X9($,J,Q){return!Number.isSafeInteger($)||$<0||$>Q||!Number.isSafeInteger(J)||J<0||J>Q-$}import{isAbsolute as FQ,normalize as J_,parse as Q_,posix as tq,resolve as Q4,sep as NQ}from"node:path";import{isAbsolute as sN,join as fB,normalize as gB,parse as aN,sep as hB}from"node:path";var tN=["/tmp","/var/tmp","/private/tmp","/private/var/tmp"],eN=`
|
|
27
|
+
`;function K3($,J){if(B0($,J))return!0;if(!$.has("TMPDIR"))return!1;return!gJ($.get("TMPDIR")??"",J)}function T0($,J){if($.has("TMPDIR"))return gJ($.get("TMPDIR")??"",J);let Q=yJ($,J);if(Q===void 0)return!0;return gJ(Q,J)}function yJ($,J){return uB($,J,"TMPDIR")}function gJ($,J){if(!$)return!1;if(JF($))return!1;return xJ($,J)}function B0($,J){let Q=uB($,J,"IFS");return Q!==void 0&&Q!==""&&Q!==eN}function xJ($,J){let Q=W9($,J.paths);return Q!==null&&xB(J).some((X)=>XF(Q,X))}function yB($,J){let Q=W9($,J.paths);return Q!==null&&xB(J).includes(Q)}var kB=new WeakMap;function xB($){let J=kB.get($);if(J)return J;let Q=$F($);return kB.set($,Q),Q}function $F($){let J=tN.map((X)=>W9(X,$.paths)??gB(X)),Q=W9($.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 uB($,J,Q){return $.has(Q)?$.get(Q):J.env.get(Q)}function QF($){return/^\/(?:private\/)?var\/folders\/[^/]{2}\/[^/]+\/T$/.test($)}function W9($,J){try{let Q=gB($);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=fB(W,Y[K]??"");if(J.entryKind(B)==="missing")return fB(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(hB)?J:`${J}${hB}`;return $.startsWith(Q)}import{statSync as rV}from"node:fs";import{isAbsolute as lq,join as iV,relative as pq}from"node:path";import{isAbsolute as mB,parse as YF}from"node:path";var cB=/^[A-Za-z_][A-Za-z0-9_]*=/,WF=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}/,dB=131072,KF=16384;function q0($){if(!cB.test($))return null;let J=$.indexOf("=");return{name:$.slice(0,J),value:$.slice(J+1)}}function K9($){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 rB($){let J=$.toLowerCase();return $.includes("=")||J==="sudo"||J==="env"||J==="command"||J==="builtin"}function N2($,J,Q,X){if(!rB(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=pB(W),L=K9(W);for(let[M,O]of L.envAssignments)K.set(M,O),B.set(M,O);if(W=L.words,W.length===0)break;while(W.length>0&&a2(W).includes("=")&&!BF(W)){let M=qF(a2(W),B,J.env)??x6(a2(W),J.env,B);if(M)K.set(M.name,M.value),B.set(M.name,M.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 M=GF(W,J.paths,q);if(W=M.words,M.cwd!==void 0)q=M.cwd}if(Z==="env"){let M=LF(W,q,B,J);if(M.unverifiableEnvSplit)return{words:W,envAssignments:K,cwd:q,unverifiableEnvSplit:!0,rewritten:lB(W,Y)};if(W=M.words,M.cwd!==void 0)q=M.cwd;for(let[O,V]of M.envAssignments)K.set(O,V),B.set(O,V)}if(Z==="command")W=_F(W);if(Z==="builtin")W=W.slice(s1(W,1)==="--"?2:1);if(pB(W)===H)break}let U=K9(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:lB(U.words,Y)}}function lB($,J){return $.some((Q)=>!J.has(Q))}function pB($){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 cB.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=MF(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 MF($,J,Q,X,Y,W,K,B){let q=Q!==void 0?OF(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 OF($,J,Q,X){if($.length>dB)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>dB)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 O=$.slice(H).match(WF);if(!O?.[1]||!U(J(O[1])))return{tokens:null,limited:q};H+=O[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 M=FF(Z);if(M===void 0||!U(M))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`
|
|
28
|
+
`;if($==="r")return"\r";if($==="t")return"\t";if($==="v")return"\v";if($==="_")return" ";if($==="#"||$==="$"||$==='"'||$==="'")return $;if($==="\\")return"\\";return}function VF($){return $===" "||$==="\t"||$===`
|
|
29
|
+
`||$==="\r"||$==="\f"||$==="\v"}function B3($,J,Q){if(J==="")return null;if(!$&&!mB(J))return null;let X=mB(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 uJ($,J,Q).tokens}function uJ($,J,Q,X){if(!rB($[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 mV,normalize as lV,resolve as uq}from"node:path";function B9(){return[]}function q9(){return[]}function U9(){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)=>R1(J)))})}function G9($,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 H9($){let J=[];return{parts:J,push:(Q,X,Y)=>zF(J,$,Q,X,Y)}}function mJ($){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 mJ({text:X,raw:$.slice(J,Q),span:{start:J,end:Q},provenance:Y,quoted:W,...K?{parts:K}:{}})}function R1($){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:R1(J.body)});return Object.freeze({...J,span:Object.freeze(J.span)})}))})}function lJ($,J,Q){if(J>=Q||oB($[J]??""))return null;let X="",Y=!1,W=!1,K=J;while(K<Q&&!oB($[K]??"")){let B=$[K]??"";if(B==="'"){Y=!0;let q=iB($,K+1,Q,"'");X+=q.text,W||=!q.closed,K=q.next;continue}if(B==='"'){Y=!0;let q=iB($,K+1,Q,'"');X+=q.text,W||=!q.closed,K=q.next;continue}if(B==="\\"){Y=!0;let q=$[K+1];if(!q||q===`
|
|
30
|
+
`||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 pJ($,J,Q,X){let Y=[],W=J;for(let K of X){let B=W,q=!1;while(W<Q){let U=RF($,W,Q);if((K.stripTabs?U.text.replace(/^\t+/,""):U.text)===K.delimiter){K.attach({body:K.stripTabs?IF($.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 iB($,J,Q,X){let Y="",W=J;while(W<Q&&$[W]!==`
|
|
31
|
+
`&&$[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 oB($){return/[\s;&|<>)]/u.test($)||$==="`"}function RF($,J,Q){let X=J;while(X<Q&&$[X]!==`
|
|
32
32
|
`&&$[X]!=="\r")X++;let Y=X>=Q?Q:$[X]==="\r"&&$[X+1]===`
|
|
33
|
-
`?X+2:X+1;return{text:$.slice(J,X),contentEnd:X,next:Y}}function
|
|
33
|
+
`?X+2:X+1;return{text:$.slice(J,X),contentEnd:X,next:Y}}function IF($){return $.replace(/(^|\r\n?|\n)\t+/g,"$1")}var eB=new Set(["&&","||","|","|&"]);function $q($,J,Q){let X={start:0,end:$.length};if($.length>Q.maxInputLength)return R1({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 R1({kind:"program",dialect:J,source:$,span:X,status:F9(Y.issues,Y.limited),issues:Y.issues,nodes:Y.nodes})}function M9($,J,Q,X,Y,W,K,B){let q=B9(),U=q9(),G=U9(),H=[],L=()=>{if(G.words.length===0&&G.redirections.length===0)return;let M={start:G.start,end:G.end},O=G.words.map((V)=>V.text);G9(q,G,{kind:"command",dialect:X,source:$.slice(M.start,M.end),span:M,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):O.join(" ")})},Z=J;while(Z<Q){let M=$[Z];if(!M)break;if(B&&M===B)return L(),tB(q,U),{nodes:q,issues:U,next:Z+1,closed:!0,limited:!1,pendingHeredocs:H};if(N9(M)){if(M===`
|
|
34
34
|
`||M==="\r"){L();let E=M==="\r"&&$[Z+1]===`
|
|
35
35
|
`?Z+2:Z+1,_=q.at(-1);if(_?.kind!=="connector"||!eB.has(_.operator))q.push(Object.freeze({kind:"connector",operator:$.slice(Z,E),span:Object.freeze({start:Z,end:E})}));if(H.length>0){let j=pJ($,E,Q,H.splice(0));U.push(...j.issues),Z=j.next;continue}Z=E;continue}Z++;continue}if(M==="#"){while(Z<Q&&$[Z]!==`
|
|
36
|
-
`&&$[Z]!=="\r")Z++;continue}let O=G.start===-1?
|
|
37
|
-
`){q+=2;continue}B+=F,q+=2;continue}let V=M==="$"||M==="<"||M===">"||M==="`"?iJ($,q,Q,X,Y,W,K):null;if(V){let F=Jq(V,H,L);if(Z||=F.limited,G=q3(G,F.provenance),q=F.next,Z)break;continue}if(M==="$"){let F=Yq($,q,Q,B,G);B=F.text,G=F.provenance,q=F.next;continue}if(M==="*"||M==="?"||M==="[")G=q3(G,"glob");B+=M,q++}return{word:t2($,J,q,B,G,U,G==="literal"?void 0:
|
|
36
|
+
`&&$[Z]!=="\r")Z++;continue}let O=G.start===-1?lF($,Z,Q):void 0;if(O){if(dJ(q,U,Z),K>=Y.maxDepth)return e2(q,U,Z,"depth-limit",Y.maxDepth);if(!cJ(W))return e2(q,U,Z,"word-limit",Y.maxWords);let E=M9($,O.braceIndex+1,Q,X,Y,W,K+1,"}"),_=E.next,j={start:O.braceIndex+1,end:E.closed?_-1:_},P=nB($,X,j,E);if(q.push({kind:"function",name:O.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 L9(q,U,E.next);if(!E.closed)U.push({code:"unclosed-function-body",message:"function body is not closed",span:{start:O.braceIndex,end:_}});Z=_;continue}let V=O9($,Z);if(V){if(L(),!qq(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(M===")"){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:M,span:{start:Z,end:Z+1}}),Z++;continue}if((M==="("||M==="{"&&SF($,Z,Q))&&G.start===-1){if(dJ(q,U,Z),K>=Y.maxDepth)return e2(q,U,Z,"depth-limit",Y.maxDepth);let E=M==="("?")":"}",_=M9($,Z+1,Q,X,Y,W,K+1,E),j=_.next,P={start:Z+1,end:_.closed?j-1:j},C=nB($,X,P,_);if(q.push({kind:"group",style:M==="("?"subshell":"brace",span:{start:Z,end:j},body:C}),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:j}});if(H.push(..._.pendingHeredocs),_.limited)return L9(q,U,_.next);if(!_.closed)U.push({code:M==="("?"unclosed-subshell":"unclosed-brace-group",message:`${M} group is not closed`,span:{start:Z,end:j}});Z=j;continue}let F=(M==="<"||M===">")&&$[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 j=_===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 C=$[P],T=P>Z+F.length&&C==="#",y=!C||N9(C)||!!O9($,P)||C===B||C===")"||T||(C==="<"||C===">")&&$[P+1]!=="(",x=F==="<<"||F==="<<-"?lJ($,P,Q):void 0,c=x?{word:t2($,P,x.next,x.delimiter,"literal",x.quoted),nested:[],issues:[],next:x.next,limited:!1}:!y?rJ($,P,Q,X,Y,W,K):void 0;if(c){if(U.push(...c.issues),c.limited)return L9(q,U,c.next);if(!cJ(W))return e2(q,U,c.next,"word-limit",Y.maxWords)}let V1=c?.next??Z+F.length,S={kind:"redirection",operator:F,span:{start:j,end:V1},..._===void 0?{}:{fd:_},...c?{target:c.word}:{}};if(G.redirections.push(S),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:j,end:V1},attach:(m)=>{S.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)dJ(q,U,Z);let b=rJ($,Z,Q,X,Y,W,K);if(U.push(...b.issues),b.limited)return L9(q,U,b.next);let R=vF(G.words)?yF($,b.word,W.max-W.used,Y.maxDepth,Y.maxInputLength):void 0;if(R?.limitCode)return e2(q,U,b.next,R.limitCode,R.limitCode==="word-limit"?Y.maxWords:R.limitCode==="depth-limit"?Y.maxDepth:Y.maxInputLength);let A=R?.words??[b.word];for(let E of A){if(!cJ(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(),tB(q,U),U.push(...pF(H)),{nodes:q,issues:U,next:Z,closed:B===void 0,limited:!1,pendingHeredocs:[]}}function nB($,J,Q,X){return{kind:"program",dialect:J,source:$.slice(Q.start,Q.end),span:Q,status:F9(X.issues,X.limited),issues:X.issues,nodes:X.nodes}}function rJ($,J,Q,X,Y,W,K){let B="",q=J,U=!1,G="literal",H=[],L=[],Z=!1;while(q<Q){let M=$[q],O=(M==="<"||M===">")&&$[q+1]==="(";if(!M||N9(M)||(M===";"||M==="|"||M==="&")&&O9($,q)||(M==="<"||M===">")&&!O)break;if(M===")")break;if(M==="'"){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(M==='"'){U=!0;let F=jF($,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(M==="\\"){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===`
|
|
37
|
+
`){q+=2;continue}B+=F,q+=2;continue}let V=M==="$"||M==="<"||M===">"||M==="`"?iJ($,q,Q,X,Y,W,K):null;if(V){let F=Jq(V,H,L);if(Z||=F.limited,G=q3(G,F.provenance),q=F.next,Z)break;continue}if(M==="$"){let F=Yq($,q,Q,B,G);B=F.text,G=F.provenance,q=F.next;continue}if(M==="*"||M==="?"||M==="[")G=q3(G,"glob");B+=M,q++}return{word:t2($,J,q,B,G,U,G==="literal"?void 0:CF($,J,q)),nested:H,issues:L,next:q,limited:Z}}function jF($,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 O=$[L+1]??"";if(O===`
|
|
38
38
|
`){L+=2;continue}if(O==="\r"&&$[L+2]===`
|
|
39
|
-
`){L+=3;continue}B+=["$","`",'"',"\\"].includes(O)?O:`\\${O}`,L+=2;continue}if($.startsWith("$((",L)){let O=oJ($,L+3,Q,"))"),V=O===-1?Q:O+2;if(B+=$.slice(L,V),O===-1)G.push({code:"unclosed-arithmetic",message:"$(( substitution is not closed",span:{start:L,end:V}});L=V;continue}let M=iJ($,L,Q,X,Y,W,K);if(M){let O=Jq(M,U,G);if(L=O.next,H||=O.limited,q=q3(q,O.provenance),H)return{text:B,provenance:q,nested:U,issues:G,next:L,limited:H};continue}if(Z==="$"){let O=Yq($,L,Q,B,q);B=O.text,q=O.provenance,L=O.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 iJ($,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=oJ($,J+H,Q,L),M=Z===-1?Q:Z,O=Z===-1?Q:Z+L.length;if(K>=Y.maxDepth)return{program:
|
|
39
|
+
`){L+=3;continue}B+=["$","`",'"',"\\"].includes(O)?O:`\\${O}`,L+=2;continue}if($.startsWith("$((",L)){let O=oJ($,L+3,Q,"))"),V=O===-1?Q:O+2;if(B+=$.slice(L,V),O===-1)G.push({code:"unclosed-arithmetic",message:"$(( substitution is not closed",span:{start:L,end:V}});L=V;continue}let M=iJ($,L,Q,X,Y,W,K);if(M){let O=Jq(M,U,G);if(L=O.next,H||=O.limited,q=q3(q,O.provenance),H)return{text:B,provenance:q,nested:U,issues:G,next:L,limited:H};continue}if(Z==="$"){let O=Yq($,L,Q,B,q);B=O.text,q=O.provenance,L=O.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 iJ($,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=oJ($,J+H,Q,L),M=Z===-1?Q:Z,O=Z===-1?Q:Z+L.length;if(K>=Y.maxDepth)return{program:mF($,J+H,M,X,"depth-limit"),next:O,provenance:B?"arithmetic":"command-substitution"};if(B){let R=[],A=[],E=!1,_=J+H;while(_<M){let j=iJ($,_,M,X,Y,W,K+1);if(!j){_++;continue}if(R.push(...j.program.nodes),A.push(...j.program.issues),E||=j.program.status==="limited",_=j.next,E)break}if(Z===-1)A.push({code:"unclosed-arithmetic",message:"$(( substitution is not closed",span:{start:J,end:O}});return{program:R1({kind:"program",dialect:X,source:$.slice(J+H,M),span:{start:J+H,end:M},status:F9(A,E),issues:A,nodes:R}),next:O,provenance:"arithmetic"}}let V=M9($,J+H,M,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:O}}]:[],b=(G||U)&&U3(V.nodes)?[{code:"unsupported-heredoc-context",message:"heredocs are supported only in ordinary commands and $(...) substitutions",span:{start:J,end:O}}]:[];return{program:R1({kind:"program",dialect:X,source:$.slice(J+H,M),span:{start:J+H,end:M},status:F9([...V.issues,...F,...b],V.limited),issues:[...V.issues,...F,...b],nodes:V.nodes}),next:O,provenance:B?"arithmetic":"command-substitution"}}function Jq($,J,Q){return J.push($.program),Q.push(...$.program.issues),{provenance:$.provenance,next:$.next,limited:$.program.status==="limited"}}function oJ($,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
40
|
`||q==="\r")&&K.length>0){let G=q==="\r"&&$[B+1]===`
|
|
41
|
-
`?B+2:B+1,H=pJ($,G,Q,K.splice(0));if(!H.terminated)return-1;B=H.next-1;continue}let U=Qq($,B,J,Q,W);if(U!==null){B=U;continue}if(!W.double&&$.startsWith("$((",B)){let G=
|
|
42
|
-
`&&$[K+1]!=="\r")K++;return K}function O9($,J){let Q=$[J];if(Q===";")return";";if(Q==="&")return $[J+1]==="&"?"&&":"&";if(Q==="|")return $[J+1]==="|"?"||":$[J+1]==="&"?"|&":"|";return null}function
|
|
43
|
-
`],["r","\r"],["t","\t"],["v","\v"],["\\","\\"],["'","'"],['"','"']]);if(Y.has(X))return{text:Y.get(X)??X,next:J+1};if(X==="x")return Z9($,J+1,Q,16,2,J+1);if(X==="u")return Z9($,J+1,Q,16,4,J+1);if(X==="U")return Z9($,J+1,Q,16,8,J+1);if(/[0-7]/.test(X))return Z9($,J,Q,8,3,J+1);return{text:X,next:J+1}}function Z9($,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:"�",next:q,invalidCodePoint:U}:{text:String.fromCodePoint(U),next:q}}function F9($,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 Yq($,J,Q,X,Y){let W=Xq($,J,Q);return{text:X+$.slice(J,W),provenance:q3(Y,"variable"),next:W}}function
|
|
41
|
+
`?B+2:B+1,H=pJ($,G,Q,K.splice(0));if(!H.terminated)return-1;B=H.next-1;continue}let U=Qq($,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=lJ($,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=Qq($,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 Qq($,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]!==`
|
|
42
|
+
`&&$[K+1]!=="\r")K++;return K}function O9($,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 N9($){let J=$.charCodeAt(0);if(J===32||J>=9&&J<=13)return!0;if(J<128)return!1;return/\s/u.test($)}function Xq($,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",`
|
|
43
|
+
`],["r","\r"],["t","\t"],["v","\v"],["\\","\\"],["'","'"],['"','"']]);if(Y.has(X))return{text:Y.get(X)??X,next:J+1};if(X==="x")return Z9($,J+1,Q,16,2,J+1);if(X==="u")return Z9($,J+1,Q,16,4,J+1);if(X==="U")return Z9($,J+1,Q,16,8,J+1);if(/[0-7]/.test(X))return Z9($,J,Q,8,3,J+1);return{text:X,next:J+1}}function Z9($,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:"�",next:q,invalidCodePoint:U}:{text:String.fromCodePoint(U),next:q}}function F9($,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 Yq($,J,Q,X,Y){let W=Xq($,J,Q);return{text:X+$.slice(J,W),provenance:q3(Y,"variable"),next:W}}function CF($,J,Q){let X=H9($),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,M=U?"))":L?"`":")",O=oJ($,B+Z,Q,M),V=O===-1?Q:O+M.length;X.push(Y,B,"literal"),X.push(B,V,U?"arithmetic":"command-substitution"),B=V,Y=V;continue}if(q==="$"){let Z=Xq($,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 SF($,J,Q){return J+1>=Q||N9($[J+1]??"")||O9($,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 Wq($,J,Q,X){if($.provenance!=="literal"||!$.raw.includes("{"))return;let Y=[$.raw],W=$.raw.length,K=0;while(!0){let q=Y.findIndex((M)=>aB(M));if(q===-1)break;if(++K>Q)return{limited:!0};let U=Y[q]??"",G=aB(U);if(!G||G.kind==="range")return{limited:!0};let H=G.start+U.length-G.end,L=G.alternatives.reduce((M,O)=>M+H+O.length,0);if(W-U.length+L>X||Y.length-1+G.alternatives.length>J)return{limited:!0};let Z=Kq(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)=>sB(V));if(U===-1)break;if(++B>X)return{limitCode:"depth-limit"};let G=W[U]??"",H=sB(G);if(!H)break;let L=H.start+G.length-H.end,Z=H.alternatives.filter((V)=>L+V.length>0),M=Z.reduce((V,F)=>V+L+F.length,0);if(K-G.length+M>Y)return{limitCode:"brace-expansion-limit"};if(W.length-1+Z.length>Q)return{limitCode:"word-limit"};let O=Kq(G,{...H,alternatives:Z});W.splice(U,1,...O),K+=M-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 sB($){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:Bq($,Q)}}function aB($){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:Bq($,Q)}}function Kq($,J){return J.alternatives.map((Q)=>`${$.slice(0,J.start)}${Q}${$.slice(J.end)}`)}function Bq($,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=rJ(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 R1({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 L9($,J,Q){return{nodes:$,issues:J,next:Q,closed:!1,limited:!0,pendingHeredocs:[]}}function cJ($){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 qq($){return $?.kind==="command"||$?.kind==="group"||$?.kind==="function"}function tB($,J){let Q=$.at(-1);if(Q?.kind!=="connector"||!eB.has(Q.operator))return;J.push({code:"missing-command-after-connector",message:`connector ${Q.operator} requires a following command`,span:Q.span})}function dJ($,J,Q){if(!qq($.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 Uq=new Set(["remove-item","ri","del","erase","rd","rmdir"]),Gq=["-rec","-for","-path","-literalpath","-whatif"],V9={maxInputLength:131072,maxWords:16384,maxDepth:64};function Hq($){let J=$.toLowerCase().replaceAll("`","");if(![...Uq].some((X)=>J.includes(X))&&!(J.includes("rm")&&Gq.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&&Uq.has(Q))return!0;if(Q!=="rm")return!1;return $.slice(J+1).some((X)=>{let Y=X.toLowerCase().split(":",1)[0]??"";return Gq.some((W)=>Y.startsWith(W))})}function Zq($,J){let Q={start:0,end:$.length};if($.length>J.maxInputLength)return R1({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=eJ($,0,$.length,J,0);return R1({kind:"program",dialect:"powershell",source:$,span:Q,status:nF(X.issues,X.limited),issues:X.issues,nodes:X.nodes})}function eJ($,J,Q,X,Y,W=!1){let K=B9(),B=q9(),q=U9(),U=0,G=!1,H=()=>{if(q.words.length===0&&q.redirections.length===0)return;let Z={start:q.start,end:q.end};G9(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((M)=>M.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 M=Oq($,L,Q,X.maxDepth);if(M){if(M.issue)B.push(M.issue);if(M.limited)return H(),{nodes:K,issues:B,next:M.next,closed:!1,words:U,limited:!0};L=M.next;continue}if(/\s/.test(Z)){if(Z==="\r"||Z===`
|
|
44
44
|
`){H();let F=Z==="\r"&&$[L+1]===`
|
|
45
|
-
`?L+2:L+1;K.push(nJ($,L,F)),L=F;continue}L++;continue}let O=$Q($,L);if(O){H(),K.push(nJ($,L,L+O.length)),L+=O.length;continue}if(Z==="{"){if(H(),Y>=X.maxDepth)return B.push(Mq(L,X.maxDepth)),{nodes:K,issues:B,next:Q,closed:!1,words:U,limited:!0};let F=eJ($,L+1,Q,X,Y+1,!0),b=F.closed?F.next-1:F.next,R=R1({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:R})),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(nJ($,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 R=b<Q?sJ($,b,Q,X,Y):void 0,A=R?.next??F;if(q.redirections.push(Object.freeze({kind:"redirection",operator:$.slice(L,F),span:Object.freeze({start:L,end:A}),...R?{target:R.word}:{}})),R)B.push(...R.issues),q.nested.push(...R.nested),U+=R.words,G||=R.limited;q.end=A,L=A;continue}if(Z===","){q.start=q.start===-1?L:q.start,q.words.push(mJ({text:",",raw:",",span:{start:L,end:L+1},provenance:"literal",quoted:!1})),q.end=++L;continue}let V=sJ($,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 sJ($,J,Q,X,Y){let W="",K="literal",B=!1,q=[],U=[],G=0,H=!1,L=(M)=>{let O=
|
|
45
|
+
`?L+2:L+1;K.push(nJ($,L,F)),L=F;continue}L++;continue}let O=$Q($,L);if(O){H(),K.push(nJ($,L,L+O.length)),L+=O.length;continue}if(Z==="{"){if(H(),Y>=X.maxDepth)return B.push(Mq(L,X.maxDepth)),{nodes:K,issues:B,next:Q,closed:!1,words:U,limited:!0};let F=eJ($,L+1,Q,X,Y+1,!0),b=F.closed?F.next-1:F.next,R=R1({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:R})),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(nJ($,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 R=b<Q?sJ($,b,Q,X,Y):void 0,A=R?.next??F;if(q.redirections.push(Object.freeze({kind:"redirection",operator:$.slice(L,F),span:Object.freeze({start:L,end:A}),...R?{target:R.word}:{}})),R)B.push(...R.issues),q.nested.push(...R.nested),U+=R.words,G||=R.limited;q.end=A,L=A;continue}if(Z===","){q.start=q.start===-1?L:q.start,q.words.push(mJ({text:",",raw:",",span:{start:L,end:L+1},provenance:"literal",quoted:!1})),q.end=++L;continue}let V=sJ($,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 sJ($,J,Q,X,Y){let W="",K="literal",B=!1,q=[],U=[],G=0,H=!1,L=(M)=>{let O=rF($,M,Q,X,Y);return W+=$.slice(M,O.next),U.push(O.program),q.push(...O.program.issues),G+=aJ(O.program),H||=O.program.status==="limited",K="command-substitution",O.next},Z=J;while(Z<Q){let M=$[Z];if(!M||/\s/.test(M)||$Q($,Z)||M===">"||M==="<"||M==="#")break;if(M===",")break;if(M==="`"){let O=$[Z+1];if(!O){q.push({code:"trailing-escape",message:"PowerShell escape has no following character",span:{start:Z,end:Z+1}}),Z++;break}W+=O,Z+=2;continue}if($.startsWith("$(",Z)){Z=L(Z);continue}if(M==="'"){B=!0,Z++;let O=!1;while(Z<$.length){if($[Z]==="'"&&$[Z+1]==="'"){W+="'",Z+=2;continue}if($[Z]==="'"){O=!0,Z++;break}W+=$[Z]??"",Z++}if(!O)q.push({code:"unclosed-single-quote",message:"single-quoted word is not closed",span:{start:J,end:$.length}});continue}if(M==='"'){B=!0;let O=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:O,end:$.length}});continue}if(M==="$")K=$[Z+1]==="("?"command-substitution":"variable";if(M==="@"&&Z===J)K="variable";W+=M,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=Lq($,J+2,Q),K=W===-1?Q:W,B=W===-1?Q:W+1;if(Y>=X.maxDepth)return{program:R1({kind:"program",dialect:"powershell",source:$.slice(J+2,K),span:{start:J+2,end:K},status:"limited",issues:[Mq(J,X.maxDepth)],nodes:[]}),next:B};let q=eJ($,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:R1({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 Lq($,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 aJ($){let J=0;for(let Q of $.nodes){if(Q.kind==="group")J+=aJ(Q.body);if(Q.kind==="command"){J+=Q.words.length;for(let X of Q.nested)J+=aJ(X)}}return J}function iF($,J,Q){let X=H9($),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=Lq($,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 Mq($,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===`
|
|
46
46
|
`){K(),X+=B==="\r"&&$[X+1]===`
|
|
47
47
|
`?2:1;continue}if(/\s/.test(B??"")){X++;continue}let q=Oq($,X,Math.min($.length,V9.maxInputLength),V9.maxDepth);if(q){W||=!!q.issue||q.limited,X=q.next;continue}let U=$Q($,X);if(U){K(),X+=U.length;continue}if(B==="{"||B==="}"){K(),X++;continue}let G=sJ($,X,Math.min($.length,V9.maxInputLength),V9,0);if(G.word.text)Q.push(G.word.text);for(let H of G.nested)J.push(...tJ(H));Y++,X=G.next>X?G.next:X+1}return K(),{commands:J,invalidComment:W}}function tJ($){return $.nodes.flatMap((J)=>{if(J.kind==="group")return tJ(J.body);if(J.kind!=="command")return[];return[J.words.map((Q)=>Q.text),...J.nested.flatMap(tJ)]})}function $Q($,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]!==`
|
|
48
|
-
`)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
|
|
49
|
-
`||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=/[*@#?$!_-]/,QQ=Object.freeze([]),eF=Object.freeze([]),$V=256;function Dq($,J){let Q=J.status==="complete"?new Set(YQ(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 z9("unclosed-quote",X,QQ);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 z9("structural-limit",X,QQ);if(Y.invalid)return z9("invalid",X,QQ);return z9("complete",X,W,Y.assignmentFallbacks)}function z9($,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?R9("{"):t1("("),...H3($.body,B),...K?[W?R9("}"):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:[...Nq($,X),R9(";"),...H3(Y,{...X,depth:X.depth+1}),R9(";")]},...Fq($,J,Q,X)]}return[{start:$.span.start,entries:Nq($,X)},...Fq($,J,Q,X)]}function Nq($,J){return[...$.words.map((Q)=>({start:Q.span.start,entries:Rq(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?Rq($.target,J,Q,!0):[],W=Y[0],K=W?.kind==="word"?W.text:void 0;return[...$.fd===void 0?[]:[WQ(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 Fq($,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=[WQ(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:[...zq(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:zq(Q.source.slice(X.span.end,$.span.end),Q)}]}function zq($,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 Rq($,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(WQ(K));K="",B=!1};for(let U of $.parts){if(U.provenance!=="command-substitution"&&U.provenance!=="arithmetic"){for(let Z of XQ(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+=XQ(Z,{single:!1,double:!0},Q.flags).map((M)=>typeof M==="string"?M:M.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 XQ($,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=Vq($,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=Vq($,K,J,Q);Y+=q.text,K=q.next;continue}W||=B==="*"||B==="?",Y+=B,K++}return[...X,{text:Y,glob:W}]}function Vq($,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=XQ(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 R9($){return Object.freeze({kind:"operator",operator:$,boundary:!0})}function WQ($){return Object.freeze({kind:"word",text:$})}function BV($){if($==="<<"||$==="<<<")return"here-data";if($==="<"||$==="<&")return"file-read";return"file-write"}function YQ($){return $.nodes.flatMap((J,Q)=>{if(J.kind==="group"||J.kind==="function")return YQ(J.body);if(J.kind!=="command")return[];let X=J.nested.flatMap((K)=>YQ(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=D9($);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(_q)&&!$.redirections.some((Q)=>_q(Q.target))}function _q($){return $?.parts.some((J)=>J.provenance==="command-substitution"&&J.raw.startsWith(">("))??!1}import{types as HV}from"node:util";var ZV=new Set(["findbyname","glob","grep","grepsearch","listdir","listpermissions","ls","read","readfile","readurlcontent","searchweb","view","viewfile"]),LV=new Set(["command","diff","input","patch","patchtext"]),Iq=new TextEncoder,MV=new TextDecoder,OV=/\s/,NV=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 FV($){return $.replace(/[-_\s]/g,"").toLowerCase()}function j9($){return ZV.has(FV($))}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(Cq(K))?[B]:q});return Q.ancestors.delete(Y.object),W}function Cq($){return $.replace(/-/g,"_").toLowerCase()}function GQ($){return Sq($,!0,{nodes:0,keys:0,stringBytes:0,ancestors:new Set},1).flatMap(_V)}function Sq($,J,Q,X){let Y=Tq($,Q,X);if(typeof $==="string")return J?[$]:[];if(!Y)return[];let W=Y.entries.flatMap(([K,B])=>Sq(B,Y.array?J:LV.has(Cq(K)),Q,X+1));return Q.ancestors.delete(Y.object),W}function VV($,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(VV($,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 _V($){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=DV(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(...KQ(U));continue}if(Y)continue;if(U.startsWith("diff --git ")){J.push(...KQ(U));continue}if(U.startsWith("--- ")){let G=Q[q+1]??"";if(!G.startsWith("+++ "))continue;J.push(...qQ(I9(U.slice(4),!0),I9(G.slice(4),!0))),q++;continue}if(!X)J.push(...KQ(U))}return J}function DV($){let J=/^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec($);if(!J)return null;return{oldLines:Number(J[1]??1),newLines:Number(J[2]??1)}}function KQ($){let J=/^\*\*\* (?:Add|Update|Delete) File: (.+)$/.exec($);if(J?.[1])return Aq(J[1]);let Q=/^\*\*\* Move to: (.+)$/.exec($);if(Q?.[1])return Aq(Q[1]);if($.startsWith("diff --git "))return zV($.slice(11));let X=/^--- (.+)$/.exec($);if(X?.[1])return Pq(X[1]);let Y=/^\+\+\+ (.+)$/.exec($);if(Y?.[1])return Pq(Y[1]);let W=/^(?:rename|copy) (?:from|to) (.+)$/.exec($);if(W?.[1])return EV(W[1]);return[]}function zV($){let J=RV($);if(J.length===2&&J[0]&&J[1])return qQ(J[0],J[1]);let Q=IV($);return Q?qQ($.slice(Q.oldStart,Q.oldEnd),$.slice(Q.newStart,Q.newEnd)):[]}function RV($){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 IV($){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>NV)U0();if(jV($,J,W,Y,Q))return{oldStart:J,oldEnd:W,newStart:Y,newEnd:Q}}return null}function jV($,J,Q,X,Y){if(BQ($,J,Q,X,Y))return!0;let W=jq($,"/",J,Q),K=jq($,"/",X,Y);if(W<=J||K<=X)return!1;if(BQ($,J,W,X,K))return!1;return BQ($,W+1,Q,K+1,Y)}function BQ($,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&&OV.test($)}function vq($,J,Q){let X=[],Y=J+1;while(Y<$.length){let W=$[Y]??"";if(W===Q)return{value:MV.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(bV(K[0]??""))),Y+=2}return null}function bV($){return{a:"\x07",b:"\b",f:"\f",n:`
|
|
50
|
-
`,r:"\r",t:"\t",v:"\v"}[$]??$}function PV($){return L3(CV($))}function qQ($,J){if($==="/dev/null")return bq(J);if(J==="/dev/null")return bq($);if($.startsWith("a/")&&J.startsWith("b/"))return[$.slice(2),J.slice(2)].flatMap(L3);let Q=AV($,J)??($===J?fq($):null);return[$,J,...Q?[Q]:[]].flatMap(L3)}function bq($){let J=fq($);return[$,...J?[J]:[]].flatMap(L3)}function fq($){let J=$.indexOf("/");return J>0&&J<$.length-1?$.slice(J+1):null}function AV($,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 Pq($){return PV(I9($,!0))}function EV($){return L3(I9($,!1))}function I9($,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 CV($){return $.startsWith("a/")||$.startsWith("b/")?$.slice(2):$}function L3($){return $===""||$==="/dev/null"?[]:[$]}function Aq($){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"]),SV=new Set([...gq,"pattern"]),TV=Object.freeze([]),yq={parseCommand:a1,projectShellSyntax:Dq};class n0 extends Error{name="StructuralShellSyntaxLimitError";constructor(){super("Structural command analysis limit exceeded.")}}function b9($,J={}){let Q=wV({...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(vV($)),store:Q})}function w1($,J){return $.commands.find((Q)=>Q.usages.includes(J))}function G0($){if(!$.includes("$"))return $;return h6($,A0())}function wV($={}){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:TV,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 vV($){let J=$.route.kind==="grep"?gq:$.route.kind==="glob"?SV: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 fV=new Map([["bash",new Set(["O","o"])],["dash",new Set(["o"])],["ksh",new Set(["o"])],["sh",new Set(["o"])],["zsh",new Set(["o"])]]),hV=new Map([["zsh",new Set(["o"])]]),kV=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=kV.get($);if(yV(X,K))continue;if(!K?.has(X))continue;if(J[Q+1]===void 0)return null;Q++;continue}let Y=gV($,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 gV($,J){let Q=fV.get($),X=hV.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 yV($,J){return J!==void 0&&[...J].some((Q)=>$.startsWith(`${Q}=`))}var mV=new Set(["-S","--suffix"]);function P9($,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=lV(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 M3($){return $.length>0&&$.every((J)=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(J))}function O1($,J,Q){let X=Q.environment.home,Y=h6($.trim(),Q.environment).replace(/\\/g,"/");if(!Y)return"";let W=Y==="~"?X:Y.startsWith("~/")?uq(X,Y.slice(2)):Y;return J1(uV(xV(W)?W:uq(J,W)),Q.environment.paths,Q).replace(/\\/g,"/")}function A9($){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&&mV.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 lV($,J,Q,X){let Y=M3($)?new Map([...J.variables,...pV($,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 pV($,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(j9($.invocation.toolName))return null;let K=$.paths.find((B)=>nV(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=P9(Y.shell,X,Q,{findSegmentTarget:(K,B)=>aV(K,B,J,Q),isRedirectionTarget:(K,B)=>sV(K,B.cwd,J,Q),findMalformedTarget:()=>null,normalizeCwd:O1});return W?{target:W}:null}function LQ($,J=H2(A0())){if(typeof $!=="string"||!$)return null;let Q=$3(O1($,$,J));if(!Q)return null;try{let X=O1(Q,$,J),Y=cV(Q),W=Y.isFile()?X:null,K=Y.isFile()?vJ(Q):null,B=(Y.isDirectory()?[X]:[K?.gitDir,K?.commonDir]).flatMap((U)=>U?[H0(O1(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(dV(U,"hooks"));return[G,H0(O1(G,$,J))]}))])})}catch{return null}}function _2($,J,Q,X,Y,W=!1){if(!Q)return!1;let K=H0(O1($,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?E9(G,B):rV(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)=>E9(q,K))}function rV($,J){let Q=pq(J,$);if(Q===""||Q.startsWith("..")||lq(Q))return!1;return!Q.split(/[\\/]/)[0]?.startsWith(".")}function iV($,J,Q,X){return _2($,J,Q,!0,X)}function oV($,J,Q,X){if(!Q)return!1;return ZQ(H0(O1($,J,X)),Q)}function nV($,J,Q,X){if(!Q)return!1;return dq($,J,Q,X,Q.entry)}function sV($,J,Q,X){if(!Q)return!1;return dq($,J,Q,X,Q.markerFile)}function dq($,J,Q,X,Y){let W=H0(O1($,J,X));return W===Y||iq(W,Q)}function rq($,J,Q,X){if(!Q)return!1;return Q.hooksDirectories.some((Y)=>$.some((W)=>E9(Y,H0(O1(W,J,X)))))}function ZQ($,J){return $===J.entry||J.directories.includes($)||iq($,J)}function iq($,J){return J.hooksDirectories.some((Q)=>E9($,Q))}function mq($){return[$.entry,...$.directories,...$.hooksDirectories]}function E9($,J){let Q=pq(J,$);return Q===""||!/^\.\.(?:[\\/]|$)/.test(Q)&&!lq(Q)}function H0($){return process.platform==="win32"?$.toLowerCase():$}function aV($,J,Q,X){if(M3($))return null;let Y=l1([...$],X.environment);if(l(Y[0]??"").toLowerCase()!=="mv")return null;let W=A9(Y.slice(1)),K=W.sources.find((B)=>iV(f1(B,J.variables),J.cwd,Q,X));if(K)return K;return W.destination&&oV(f1(W.destination,J.variables),J.cwd,Q,X)?W.destination:null}import{isAbsolute as sq,normalize as tV,sep as MQ}from"node:path";var oq=process.platform==="win32";function O3($,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=O3($.trim(),J);if(!sq(Q))return"must be an absolute path or start with ~/";return T9(Q,J)}function S9($,J){if(typeof $!=="string"||$.trim()==="")return"must be a non-empty path string";let Q=O3($.trim().replace(/^\$(?:\{HOME\}|HOME(?=\/|$))/,"~"),J);if(!sq(Q))return null;if(T9(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 T9($,J){let Q=nq($),X=nq(J);if(Q===X)return"cannot be the home directory";let Y=Q.endsWith(MQ)?Q:`${Q}${MQ}`;if(X.startsWith(Y))return"cannot contain the home directory";return null}function nq($){let J=tV($);if(oq)J=J.replace(/\//g,"\\").toLowerCase();if(J.length>(oq?3:1)&&J.endsWith(MQ))J=J.slice(0,-1);return J}var J_=process.platform==="win32",aq=64,Q_=16384;function N3($){let J=Wq($,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:X_($)}}function X_($){let J=$.parts.filter((Q)=>Q.provenance==="variable"&&/\$(?:TMPDIR(?![A-Za-z0-9_])|\{TMPDIR\})/.test(Q.raw));return J.length>0&&J.every((Q)=>Y_($.raw,Q.span.start-$.span.start))}function Y_($,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:U_($.allowPaths,J,Q,X),protectedGitMetadata:$.protectedGitMetadata,pathCanonicalizationContext:X}}function e1($,J,Q={}){let X=Q.targetIsLiteral??!1;if(!X&&J.tmpdirWordSplittingUnsafe&&!Q.tmpdirWordSplittingProtected&&H_($))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(W_($,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(K_($,J.trustTmpdirVar,J.posixShell,Y,X,Q.tmpdirWordSplittingProtected??!1,J.trustedTmpdirValue,J.environment))return{kind:"temp_target"};if(Y)return{kind:"dynamic_target"};if(G_($,J,X))return{kind:"temp_target"};let W=J.anchoredCwd;if(W){if(!Q.skipHomeCwd&&O_(W,J.environment.home,J.environment.paths,J.pathCanonicalizationContext))return{kind:"home_cwd_target"};if(!Q.skipCwdSelf&&N_($,J.resolvedCwd??W,J.environment.paths,J.pathCanonicalizationContext))return{kind:"cwd_self_target"};if(F_($,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(q_(W))return!1;if(yB(W,J.environment))return!1;return![J.anchoredCwd,J.resolvedCwd].some((K)=>V_(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 W_($,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=I1(J1(Y,J.environment.paths,J.pathCanonicalizationContext));if(W===$_(W).root)return!0;return W===I1(J1(J.environment.home,J.environment.paths,J.pathCanonicalizationContext))}catch{return!1}}function I1($){let J=eV($);if(J_){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 K_($,J,Q,X,Y,W,K,B){let q=$.trim();if($U(q))return!1;if(!X&&xJ(q,B))return!0;return(J||W&&K)&&Q&&!Y&&B_(q,Q)}function B_($,J){return["$TMPDIR","${TMPDIR}"].some((Q)=>{if($===Q)return!0;if(!$.startsWith(`${Q}/`))return!1;return!JU($.slice(Q.length+1),J)})}function q_($){let J=/^(?:\$TMPDIR|\$\{TMPDIR\})(?:\/(.*))?$/.exec($);if(!J)return!1;return tq.normalize(`/${J[1]??""}`)==="/"}function $U($){return $.split(/[\\/]+/).includes("..")}function U_($,J,Q,X){if(!$?.length)return[];return $.flatMap((Y)=>{let W=O3(Y.trim(),J);if(!FQ(W))return[];try{let K=J1(W,Q,X);if(T9(K,J1(J,Q,X)))return[];return[I1(K)]}catch{return[]}})}function G_($,J,Q){if(J.allowRoots.length===0)return!1;let X=$.trim();if($U(X))return!1;let Y=Q?X:O3(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=I1(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 H_($){return/\$(?:TMPDIR(?![A-Za-z0-9_])|\{TMPDIR\})/.test($)}function JU($,J=!1){return $.includes("$")||$.includes("`")||Z_($)||J&&L_($)}function Z_($){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 L_($){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==="{"&&M_($,Q)||(X==="+"||X==="@"||X==="!")&&$[Q+1]==="(")return!0}return!1}function M_($,J){let Q=$.indexOf("}",J+1);if(Q===-1)return!1;let X=$.slice(J+1,Q);return X.includes(",")||X.includes("..")}function O_($,J,Q,X){try{return I1(J1($,Q,X))===I1(J1(J,Q,X))}catch{try{return I1($)===I1(J)}catch{return!1}}}function N_($,J,Q,X){if($==="."||$==="./"||$===".\\")return!0;try{return I1(J1(Q4(J,$),Q,X))===I1(J1(J,Q,X))}catch{try{return I1(Q4(J,$))===I1(J)}catch{return!1}}}function F_($,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 OQ($,J,W,K)}catch{return!1}if($.startsWith("./")||$.startsWith(".\\")||!$.includes("/")&&!$.includes("\\"))try{return OQ(Q4(B,$),J,W,K)}catch{return!1}if($.startsWith("../"))return!1;try{return OQ(Q4(B,$),J,W,K)}catch{return!1}}function OQ($,J,Q,X){try{return QU(J1($,Q,X),J1(J,Q,X))}catch{return!1}}function V_($,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=I1($),X=I1(J);return Q.startsWith(`${X}${NQ}`)||Q===X}var __=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.",D_="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.",z_="PowerShell Remove-Item -Recurse -Force in home directory is dangerous. Change to a project directory first.",R_="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 I_($.words.map((Y)=>({kind:"word",text:Y.text,dynamic:Y.provenance!=="literal"})),J,X,Q.policy)}function I_($,J,Q,X){let Y=$.filter((q)=>q.kind==="word"),W=b_(Y),K=Y[W];if(!K||!__.has(f_(K.text)))return null;let B=j_(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",R_);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=h_(e1(DQ(q.text),Q),Q,X);if(U)return U}return null}function j_($){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(P_(q))continue;if(K){J.push(_Q(q)),W=W||q.dynamic;continue}if(q.text==="--"){K=!0;continue}let U=E_(q.text);if(!U){J.push(_Q(q)),W=W||q.dynamic;continue}if(C_(U.name)){let G=U.value?A_(U.value,q):$[++B];if(G?.kind==="word")J.push(_Q(G)),W=W||G.dynamic;else W=!0;continue}if(S_(U.name)){Q=!0;continue}if(T_(U.name)){X=!0;continue}if(w_(U.name))Y=v_(U.value)}return{targets:J,recursive:Q,force:X,whatIfProtected:Y,hasDynamicTarget:W}}function b_($){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 P_($){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 A_($,J){return{kind:"word",text:$,dynamic:J.kind==="word"&&(J.dynamic||$.includes("$"))}}function E_($){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 C_($){return"path".startsWith($)||"literalpath".startsWith($)}function S_($){return"recurse".startsWith($)}function T_($){return $.length>=2&&"force".startsWith($)}function w_($){return $==="wi"||"whatif".startsWith($)}function v_($){if($===void 0||$==="")return!0;let J=$.toLowerCase();return J==="$true"||J==="true"}function f_($){return $.toLowerCase()}function h_($,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",z_);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",D_);case"outside_anchored_cwd":return z("powershell.remove-item-recursive-force-outside-cwd",XU)}}import{normalize as r9}from"node:path";var h1=new Set(["awk","gawk","nawk","mawk"]),k_=new Set(["-e","--source"]),g_=new Set(["-F","-v","--assign","--field-separator"]),BU=new Set(["-f","--file"]),y_=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"}],x_="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 f9($,J,Q){let X=!1;for(let Y of u_($)){let W=m_(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",x_):null}function RQ($){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&&k_.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&&(g_.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 RQ($).sources}function u_($){return V3($).filter((J)=>J.kind!=="program-file").map((J)=>J.value)}function m_($,J){C1(J,$);let Q=$.includes("system")?IQ($,J):null,X=l_($,J);if(!Q&&!X)return null;return{dynamic:!!Q?.dynamic||!!X?.dynamic,commands:[...Q?.commands??[],...X?.commands??[]]}}function IQ($,J){C1(J,$);let Q=[],X=!1,Y=!1,W=0;while(W<$.length){let K=$[W];if(K==='"'||K==="'"){W=v9($,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=w9($,W);if($[q]!=="(")continue;q=w9($,q+1);let U=$[q];if(U!=='"'&&U!=="'"){X=!0,Y=!0;continue}let G=v9($,q,U);if(!G){X=!0,Y=!0;continue}if(q=w9($,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 l_($,J){C1(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=v9($,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(`;
|
|
51
|
-
{}`.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=w9($,H);if(zQ($,L,"getline")){Y=!0;let Z=
|
|
52
|
-
}#`.includes(X)}function v9($,J,Q){let X="",Y=!1;for(let W=J+1;W<$.length;W++){let K=$[W];if(!K)break;if(Y){let B=
|
|
53
|
-
`,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
|
|
54
|
-
`,J);return Q===-1?$.length:Q+1}function GU($,J){let Q=o_($,J);if(Q===-1)return!0;if("{([,;!~=".includes($[Q]??""))return!0;let X=Q;while(F3($[X-1]))X--;return y_.has($.slice(X,Q+1))}function o_($,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"]),n_=new Set(["sudo","env","command","builtin"]),s_=new Set(["git","busybox",...ZU,...H1,...EB,...h1]);function h9($,J){let Q=$[0];if(!Q||!J.transparentWrappers.includes(l(Q)))return null;let X=l(Q),Y=$[1]==="--"?2:1,W=a_($,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 a_($,J,Q,X){let Y=$[1]==="--",W=[];for(let K=J;K<$.length;K++){let B=$[K];if(!B)continue;if(l(B)!==Q&&t_(B,X))W.push(K);else if(s6.has(i(B)))break;if(Y)break}return W}function t_($,J){let Q=l($),X=i($);return X==="git"||Q==="busybox"||_3($)||ZU.has(Q)||J.transparentWrappers.includes(Q)||H1.has(X)||$==="$SHELL"||S1(X)||h1.has(X)||J.rules.some((Y)=>Y.command===Q)}function _3($){return n_.has($.toLowerCase())}function LU($){let J=i($);return s_.has(J)||S1(J)}function $0($,J){let Q=J.policy??{rules:[],transparentWrappers:[]};return jQ([...$],J.environment,J.cwd,J.cwd,new Map,new Map(J.envAssignments??[]),Q,{iterations:0},!1)}function*jQ($,J,Q,X,Y,W,K,B,q){let U=uJ($,J,Q,W);if(U.unverifiableEnvSplit)throw new L2;for(let[Z,M]of U.envAssignments)W.set(Z,M),Y.set(Z,M);let{tokens:G,cwd:H}=U;if(_3(G[0]??""))throw new m1;let L=h9(G,K);if(L){for(let Z of[L.childIndex,...L.alternativeChildIndices])MU(B),yield*jQ(Z===L.childIndex?L.tokens:[...G.slice(Z)],J,H,X,new Map(Y),new Map(W),K,B,!0);return}if($D(G)){MU(B),yield*jQ([...G.slice(1)],J,H,X,Y,W,K,B,q);return}yield e_(G,H,X,Y,W,q)}function e_($,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 MU($){if($.iterations>=i2)throw new m1;$.iterations++}function $D($){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 OU($){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 JD="find -delete permanently removes files. Use -print first to preview.",QD="find -exec rm -rf is dangerous. Use explicit file list instead.",XD=new Set(["-exec","-execdir","-ok","-okdir"]),YD=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 k9($,J){let Q=$.map(h),X=WD($,Q,J);if(X)return X;if(y9(Q,1)&&!BD($,Q,J)){let K=k(z("find.delete",JD),J.policy);if(K)return K}let Y=J.derivedCommandWorkBudget??o6(),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=UD(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 WD($,J,Q){if(!y9(J,1)&&!AQ(J,Q.environment))return null;let Y=g9($)??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(KD(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 KD($){return $.some((J,Q)=>{if(!["-name","-iname"].includes(J))return!1;return $[Q+1]?.toLowerCase()==="hooks"})}function BD($,J,Q){if(J.includes("-L")||J.includes("-f")||J.includes("-follow"))return!1;let X=g9($);if(!X)return!1;let Y=Q.envAssignments??new Map,W=yJ(Y,Q.environment),K=Q.trustedTmpdirValue??S0(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:qD(H,W),targetIsLiteral:G.expandedTargets!==void 0||G.targetIsLiteral,tmpdirWordSplittingProtected:G.tmpdirWordSplittingProtected}))})}function qD($,J){if(!J)return $;return $.replace(/^(?:\$TMPDIR|\$\{TMPDIR\})/,()=>J)}function g9($){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 UD($,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",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 y9($,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 YD.get($)??(/^-newer[A-Za-z]{2}$/.test($)?1:0)}function v0($){return $!==void 0&&XD.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 GD=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 j1($){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=HD(X.entries);if(Y.size===0)return{blockedReason:X.blockedReason,expanded:!1,tokens:$};let W=$,K=!1;for(let B=0;B<GD;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=ND(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 HD($){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=LD(J,Q);return{blockedReason:W.blockedReason,entries:[...W.entries,...ZD($,J,Q)]}}function ZD($,J,Q){let X=[],Y=1;while(Y<$.length){let W=$[Y];if(!W||W==="--"||!W.startsWith("-"))return X;if(W==="-c"){let K=CQ($[Y+1]);if(K)X.push(K);Y+=2;continue}if(W.startsWith("-c")&&W.length>2){let K=CQ(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 LD($,J){let Q=MD($,J),X=OD($,J);return{blockedReason:Q===null||X===null?EQ:null,entries:[...Q??[],...X??[]]}}function MD($,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=CQ(W);if(!K)return null;X.push(K)}return X}function OD($,J){let Q=y6($,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 CQ($){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 ND($){let J=$?.trimStart();if(!J||J.startsWith("!"))return null;return z3(J)}var FD="git checkout -- discards uncommitted changes permanently. Use 'git stash' first.",VD="git checkout --force discards uncommitted changes. Use 'git stash' first.",_D="git checkout <ref> -- <path> overwrites working tree with ref version. Use 'git stash' first.",DD="git checkout --pathspec-from-file can overwrite multiple files. Use 'git stash' first.",zD="git checkout with multiple positional args may overwrite files. Use 'git switch' for branches or 'git restore' for files.",RD="git switch --discard-changes discards uncommitted changes. Use 'git stash' first.",ID="git switch --force discards uncommitted changes. Use 'git stash' first.",jD="git restore discards uncommitted changes. Use 'git stash' first, or use --staged to only unstage.",bD="git restore --worktree explicitly discards working tree changes. Use 'git stash' first.",PD="git reset --hard destroys all uncommitted changes permanently. Use 'git stash' first.",AD="git reset --merge can lose uncommitted changes. Use 'git stash' first.",ED="git clean -f removes untracked files permanently. Use 'git clean -n' to preview first.",CD="git push --force destroys remote history. Use --force-with-lease for safer force push.",SD="git push deletes remote refs. Ask the user to run it manually if deletion is intended.",TD="git push --mirror can force-update and delete remote refs. Ask the user to run it manually if mirror push is intended.",wD="git branch -D force-deletes without merge check. Use -d for safe delete.",vD="git rebase --abort discards rebase conflict resolutions. Use 'git status' first.",fD="git merge --abort discards merge conflict resolutions. Use 'git status' first.",hD="git tag -d permanently deletes tags. Ask the user to run it manually if deletion is intended.",kD="git reflog delete removes recovery history. Ask the user to run it manually if deletion is intended.",gD="git stash drop permanently deletes stashed changes. Consider 'git stash list' first.",yD="git stash clear deletes ALL stashed changes permanently. Use 'git stash list' to review; ask the user to run it manually if intended.",xD="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"]),SQ=new Set(["-b","-B","-U"]),TQ=new Set(["-c","-C"]),uD=new Set(["--source","--conflict","--unified","--inter-hunk-context"]),mD=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 IU($){let{subcommand:J,rest:Q}=J0($);if(!J)return null;switch(J.toLowerCase()){case"checkout":return z2(lD(Q));case"switch":return z2(pD(Q));case"restore":return z2(dD(Q));case"reset":return iD(Q);case"clean":return z2(nD(Q));case"push":return R2(sD(Q));case"branch":return R2(eD(Q));case"stash":return R2(Yz(Q));case"worktree":return R2(Wz(Q));case"rebase":return z2($z(Q));case"merge":return z2(Jz(Q));case"tag":return R2(Qz(Q));case"reflog":return R2(Xz(Q));default:return null}}function z2($){return $?{...$,localDiscard:!0}:null}function R2($){return $?{...$,localDiscard:!1}:null}function lD($){let{index:J,before:Q}=j1($),X=v1(Q,{shortOptsWithValue:SQ});if(Q.some((W)=>a(W,"--force"))||X.has("-f"))return z("git.checkout-force",VD);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",DD)}if(J!==-1){if(Q.some((K)=>!K.startsWith("-")))return z("git.checkout-ref-path",_D);return z("git.checkout-double-dash",FD)}if(cD($).length>=2)return z("git.checkout-ambiguous",zD);return null}function pD($){let{before:J}=j1($);if(J.some((X)=>a(X,"--discard-changes")))return z("git.switch-discard-changes",RD);let Q=v1(J,{shortOptsWithValue:TQ});if(J.some((X)=>a(X,"--force"))||Q.has("-f"))return z("git.switch-force",ID);return null}function cD($){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("--")&&!mD.has(X)&&!DU.has(X)&&!zU.has(X))Q++;else Q++;else J.push(X),Q++}return J}function dD($){let J=rD($);if(J.isTerminal||!J.hasPathspec&&!J.hasPatch||!J.hasWorktree)return null;return J.hasExplicitLocation?z("git.restore-worktree",bD):z("git.restore-unstaged",jD)}function rD($){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(uD.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 iD($){let J=null;for(let Q of $){if(a(Q,"--hard")){J=z("git.reset-hard",PD);break}if(a(Q,"--merge")){J=z("git.reset-merge",AD);break}}if(!J)return null;return oD($)?R2(J):z2(J)}function oD($){for(let J of $){if(J==="--")return!1;if(!J.startsWith("-"))return!0}return!1}function nD($){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",ED);return null}function sD($){let{before:J,after:Q}=j1($),X=v1(J);if(J.some((K)=>a(K,"--mirror")))return z("git.push-mirror",TD);if(J.some((K)=>a(K,"--force"))||X.has("-f")||RU(J,Q).some(aD))return z("git.push-force",CD);if(J.some((K)=>a(K,"--delete"))||X.has("-d")||RU(J,Q).some(tD))return z("git.push-delete",SD);return null}function RU($,J){return[...$.filter((Q)=>Q!==""&&!Q.startsWith("-")),...J]}function aD($){return $.startsWith("+")||$.includes(":+")}function tD($){return $.length>1&&$.startsWith(":")}function eD($){let{before:J}=j1($),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",wD);return null}function $z($){let{before:J}=j1($);return J.some((Q)=>a(Q,"--abort"))?z("git.rebase-abort",vD):null}function Jz($){let{before:J}=j1($);return J.some((Q)=>a(Q,"--abort"))?z("git.merge-abort",fD):null}function Qz($){let{before:J}=j1($);return v1(J).has("-d")||J.some((X)=>a(X,"--delete"))?z("git.tag-delete",hD):null}function Xz($){return $[0]==="delete"?z("git.reflog-delete",kD):null}function Yz($){for(let J of $){if(J==="drop")return z("git.stash-drop",gD);if(J==="clear")return z("git.stash-clear",yD)}return null}function Wz($){let{before:J}=j1($);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",xD);return null}import{execFileSync as Kz}from"node:child_process";import{existsSync as vQ,readFileSync as fQ}from"node:fs";import{dirname as Bz,isAbsolute as PU,join as wQ,resolve as AU}from"node:path";var qz=["/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=Uz($,J,Q);if(Y!==null)return Y;let W=Gz(J,Q);if(W!==null)return W;if($B(Q))return!0;return Hz(X)}function Uz($,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=jU($[Y+1]);if(K!==null)X=K;Y+=2;continue}if(W.startsWith("-c")&&W.length>2){let K=jU(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 Gz($,J){if(u1("GIT_CONFIG_PARAMETERS",$,J)!==void 0)return!0;let Q=y6($,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=R3(K)}return X}function Hz($,J=Lz()){let Q=Zz($);if(Q===null||Q)return!0;if(J===null)return!0;try{let X=Kz(J,["config","--get","submodule.recurse"],{cwd:$,encoding:"utf8",env:Mz(process.env),stdio:["ignore","pipe","ignore"]}).trim();return R3(X)}catch(X){return!Oz(X)}}function Zz($){let J=Nz($);if(J===null)return null;for(let Q of J){if(!vQ(Q))continue;if(_z(Q))return!0}return!1}function Lz(){for(let $ of qz)if(vQ($))return $;return null}function Mz($){let J={...$};for(let Q of Object.keys(J))if(a4(Q))delete J[Q];return J}function Oz($){return typeof $==="object"&&$!==null&&"status"in $&&$.status===1}function Nz($){let J=$3($);if(J===null)return null;let Q=Fz(J);if(Q===null)return null;let X=Vz(Q);if(X===null)return null;return[wQ(X,"config"),wQ(Q,"config.worktree")]}function Fz($){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(Bz($),X)}catch{return null}}function Vz($){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 _z($){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(Dz(Q)&&q==="path")return!0;if(Q==="submodule"&&q==="recurse")X=R3(U)}return X}function Dz($){return $==="include"||$.startsWith("includeif ")}function jU($){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 R3(X)}function R3($){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||R3(W)}function hQ($){return $==="include.path"||$.startsWith("includeif.")&&$.endsWith(".path")}function CU($,J,Q){if(!J.localDiscard||!Q.worktreeMode||YB(Q.env,Q.envAssignments))return null;let X=WB($,Q.cwd);if(!X.gitCwd||X.hasExplicitGitContext)return null;if(!KB(X.gitCwd))return null;if(zz($,Q,X.gitCwd))return null;return{originalReason:J.reason,gitCwd:X.gitCwd}}function zz($,J,Q){let{subcommand:X,rest:Y}=J0($),W=X?.toLowerCase();if(J.dynamicArguments||Rz(Y)||EU($,J.env,J.envAssignments,Q)||bz(Y)||Iz(W,Y))return!0;return W==="clean"&&Pz(Y)>1}function Rz($){return $.some((J)=>/[$*?[]/.test(J))}function Iz($,J){if($==="checkout"){let{before:Q}=j1(J),X=v1(Q,{shortOptsWithValue:SQ}),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}=j1(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")||jz(K))||X.has("-C");return Y&&W}return!1}function jz($){let J=$.split("=",1)[0]??$;return J==="--force-create"||J.length>=9&&"--force-create".startsWith(J)}function bz($){return $.some((J)=>J.startsWith("--recurse-sub"))}function Pz($){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 Az="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.",Ez=new Set(["clone","fetch","pull","push","ls-remote","submodule"]);function X4($,J){return SU($.map(h),J)}function SU($,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((eK(J.envAssignments)||VU($,J.env,J.envAssignments))&&Cz(W))return z("git.ssh-env",Az);let K=IU(W);if(!K)return null;if(X.expanded||X.blockedReason)return K;let B=CU($,K,J);if(!B)return K;return Q?.(B),null}function TU($,J){let Q=null;return{match:SU($.map(h),J,(Y)=>{Q=Y}),relaxation:Q}}function Cz($){let{subcommand:J,rest:Q}=J0($),X=J?.toLowerCase();if(!X)return!1;if(Ez.has(X))return!0;if(X==="archive")return j1(Q).before.some((Y)=>a(Y,"--remote"));return X==="remote"&&Sz(Q)}function Sz($){return $.find((J)=>!Tz(J))?.toLowerCase()==="update"}function Tz($){return $==="-v"||a($,"--verbose")||a($,"--no-verbose")}import{isAbsolute as zR}from"node:path";var wU="rm -rf outside cwd is blocked. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",wz="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.",vz="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.",fz="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=OU(X),K=kz($);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 hz(U,Q,G)){let L=vU(H,Q,J.policy),Z=k(L,J.policy);if(Z)return Z}}}return null}function hz($,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 kz($){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",vz);case"home_cwd_target":return z("rm.recursive-force-home-cwd",fz);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",wz);return null;case"outside_anchored_cwd":return z("rm.recursive-force-outside-cwd",wU)}}var gz={bash:["O","o"],dash:["o"],ksh:["o"],sh:["o"],zsh:["o"]},kU=new Set(["--init-file","--rcfile"]),yz=["--init-file","--rcfile"],xz=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=uz($,J),X=xz.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 uz($,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?yz.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(!gz[$]?.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"},I2={kind:"dynamic"},mz=new Set(["<","<<","<<-","<<<","<&","<>"]),uU=/\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*))/g,lz=/^(?:[0-9]+|[@*])$/,pz=F2.maxWords,cz=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
|
|
48
|
+
`)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 nJ($,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"&&Hq($.slice(0,Q.maxInputLength)))return Zq($,Q);return $q($,"posix",Q)}function JQ($,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 _9($,J){return $?.provenance==="literal"&&!$.quoted&&$.raw===J&&$.text===J}function D9($){let J=_9($.words[0],"time")?1:0,Q=J===1&&_9($.words[J],"-p")?J+1:J,X=J===1&&_9($.words[Q],"--")?Q+1:Q,Y=_9($.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===`
|
|
49
|
+
`||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=/[*@#?$!_-]/,QQ=Object.freeze([]),JV=Object.freeze([]),QV=256;function Dq($,J){let Q=J.status==="complete"?new Set(YQ(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 z9("unclosed-quote",X,QQ);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 z9("structural-limit",X,QQ);if(Y.invalid)return z9("invalid",X,QQ);return z9("complete",X,W,Y.assignmentFallbacks)}function z9($,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?R9("{"):t1("("),...H3($.body,B),...K?[W?R9("}"):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:[...Nq($,X),R9(";"),...H3(Y,{...X,depth:X.depth+1}),R9(";")]},...Fq($,J,Q,X)]}return[{start:$.span.start,entries:Nq($,X)},...Fq($,J,Q,X)]}function Nq($,J){return[...$.words.map((Q)=>({start:Q.span.start,entries:Rq(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?Rq($.target,J,Q,!0):[],W=Y[0],K=W?.kind==="word"?W.text:void 0;return[...$.fd===void 0?[]:[WQ(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 Fq($,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=[WQ(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:[...zq(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:zq(Q.source.slice(X.span.end,$.span.end),Q)}]}function zq($,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 Rq($,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(WQ(K));K="",B=!1};for(let U of $.parts){if(U.provenance!=="command-substitution"&&U.provenance!=="arithmetic"){for(let Z of XQ(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+=XQ(Z,{single:!1,double:!0},Q.flags).map((M)=>typeof M==="string"?M:M.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 XQ($,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=Vq($,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=Vq($,K,J,Q);Y+=q.text,K=q.next;continue}W||=B==="*"||B==="?",Y+=B,K++}return[...X,{text:Y,glob:W}]}function Vq($,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=XQ(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 R9($){return Object.freeze({kind:"operator",operator:$,boundary:!0})}function WQ($){return Object.freeze({kind:"word",text:$})}function UV($){if($==="<<"||$==="<<<")return"here-data";if($==="<"||$==="<&")return"file-read";return"file-write"}function YQ($){return $.nodes.flatMap((J,Q)=>{if(J.kind==="group"||J.kind==="function")return YQ(J.body);if(J.kind!=="command")return[];let X=J.nested.flatMap((K)=>YQ(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=D9($);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(_q)&&!$.redirections.some((Q)=>_q(Q.target))}function _q($){return $?.parts.some((J)=>J.provenance==="command-substitution"&&J.raw.startsWith(">("))??!1}import{types as LV}from"node:util";var MV=new Set(["findbyname","glob","grep","grepsearch","listdir","listpermissions","ls","read","readfile","readurlcontent","searchweb","view","viewfile"]),OV=new Set(["command","diff","input","patch","patchtext"]),Iq=new TextEncoder,NV=new TextDecoder,FV=/\s/,VV=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 _V($){return $.replace(/[-_\s]/g,"").toLowerCase()}function j9($){return MV.has(_V($))}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(Cq(K))?[B]:q});return Q.ancestors.delete(Y.object),W}function Cq($){return $.replace(/-/g,"_").toLowerCase()}function GQ($){return Sq($,!0,{nodes:0,keys:0,stringBytes:0,ancestors:new Set},1).flatMap(zV)}function Sq($,J,Q,X){let Y=Tq($,Q,X);if(typeof $==="string")return J?[$]:[];if(!Y)return[];let W=Y.entries.flatMap(([K,B])=>Sq(B,Y.array?J:OV.has(Cq(K)),Q,X+1));return Q.ancestors.delete(Y.object),W}function DV($,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(DV($,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 zV($){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=RV(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(...KQ(U));continue}if(Y)continue;if(U.startsWith("diff --git ")){J.push(...KQ(U));continue}if(U.startsWith("--- ")){let G=Q[q+1]??"";if(!G.startsWith("+++ "))continue;J.push(...qQ(I9(U.slice(4),!0),I9(G.slice(4),!0))),q++;continue}if(!X)J.push(...KQ(U))}return J}function RV($){let J=/^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec($);if(!J)return null;return{oldLines:Number(J[1]??1),newLines:Number(J[2]??1)}}function KQ($){let J=/^\*\*\* (?:Add|Update|Delete) File: (.+)$/.exec($);if(J?.[1])return Aq(J[1]);let Q=/^\*\*\* Move to: (.+)$/.exec($);if(Q?.[1])return Aq(Q[1]);if($.startsWith("diff --git "))return IV($.slice(11));let X=/^--- (.+)$/.exec($);if(X?.[1])return Pq(X[1]);let Y=/^\+\+\+ (.+)$/.exec($);if(Y?.[1])return Pq(Y[1]);let W=/^(?:rename|copy) (?:from|to) (.+)$/.exec($);if(W?.[1])return SV(W[1]);return[]}function IV($){let J=jV($);if(J.length===2&&J[0]&&J[1])return qQ(J[0],J[1]);let Q=bV($);return Q?qQ($.slice(Q.oldStart,Q.oldEnd),$.slice(Q.newStart,Q.newEnd)):[]}function jV($){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 bV($){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>VV)U0();if(PV($,J,W,Y,Q))return{oldStart:J,oldEnd:W,newStart:Y,newEnd:Q}}return null}function PV($,J,Q,X,Y){if(BQ($,J,Q,X,Y))return!0;let W=jq($,"/",J,Q),K=jq($,"/",X,Y);if(W<=J||K<=X)return!1;if(BQ($,J,W,X,K))return!1;return BQ($,W+1,Q,K+1,Y)}function BQ($,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&&FV.test($)}function vq($,J,Q){let X=[],Y=J+1;while(Y<$.length){let W=$[Y]??"";if(W===Q)return{value:NV.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(AV(K[0]??""))),Y+=2}return null}function AV($){return{a:"\x07",b:"\b",f:"\f",n:`
|
|
50
|
+
`,r:"\r",t:"\t",v:"\v"}[$]??$}function EV($){return L3(TV($))}function qQ($,J){if($==="/dev/null")return bq(J);if(J==="/dev/null")return bq($);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 bq($){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 Pq($){return EV(I9($,!0))}function SV($){return L3(I9($,!1))}function I9($,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 TV($){return $.startsWith("a/")||$.startsWith("b/")?$.slice(2):$}function L3($){return $===""||$==="/dev/null"?[]:[$]}function Aq($){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"]),wV=new Set([...gq,"pattern"]),vV=Object.freeze([]),yq={parseCommand:a1,projectShellSyntax:Dq};class n0 extends Error{name="StructuralShellSyntaxLimitError";constructor(){super("Structural command analysis limit exceeded.")}}function b9($,J={}){let Q=fV({...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(hV($)),store:Q})}function w1($,J){return $.commands.find((Q)=>Q.usages.includes(J))}function G0($){if(!$.includes("$"))return $;return h6($,E0())}function fV($={}){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:vV,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 hV($){let J=$.route.kind==="grep"?gq:$.route.kind==="glob"?wV: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 kV=new Map([["bash",new Set(["O","o"])],["dash",new Set(["o"])],["ksh",new Set(["o"])],["sh",new Set(["o"])],["zsh",new Set(["o"])]]),gV=new Map([["zsh",new Set(["o"])]]),yV=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=yV.get($);if(uV(X,K))continue;if(!K?.has(X))continue;if(J[Q+1]===void 0)return null;Q++;continue}let Y=xV($,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 xV($,J){let Q=kV.get($),X=gV.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 uV($,J){return J!==void 0&&[...J].some((Q)=>$.startsWith(`${Q}=`))}var pV=new Set(["-S","--suffix"]);function P9($,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=cV(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 M3($){return $.length>0&&$.every((J)=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(J))}function O1($,J,Q){let X=Q.environment.home,Y=h6($.trim(),Q.environment).replace(/\\/g,"/");if(!Y)return"";let W=Y==="~"?X:Y.startsWith("~/")?uq(X,Y.slice(2)):Y;return J1(lV(mV(W)?W:uq(J,W)),Q.environment.paths,Q).replace(/\\/g,"/")}function A9($){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&&pV.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 cV($,J,Q,X){let Y=M3($)?new Map([...J.variables,...dV($,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 dV($,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(j9($.invocation.toolName))return null;let K=$.paths.find((B)=>aV(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=P9(Y.shell,X,Q,{findSegmentTarget:(K,B)=>eV(K,B,J,Q),isRedirectionTarget:(K,B)=>tV(K,B.cwd,J,Q),findMalformedTarget:()=>null,normalizeCwd:O1});return W?{target:W}:null}function LQ($,J=H2(E0())){if(typeof $!=="string"||!$)return null;let Q=$3(O1($,$,J));if(!Q)return null;try{let X=O1(Q,$,J),Y=rV(Q),W=Y.isFile()?X:null,K=Y.isFile()?vJ(Q):null,B=(Y.isDirectory()?[X]:[K?.gitDir,K?.commonDir]).flatMap((U)=>U?[H0(O1(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(iV(U,"hooks"));return[G,H0(O1(G,$,J))]}))])})}catch{return null}}function _2($,J,Q,X,Y,W=!1){if(!Q)return!1;let K=H0(O1($,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?E9(G,B):oV(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)=>E9(q,K))}function oV($,J){let Q=pq(J,$);if(Q===""||Q.startsWith("..")||lq(Q))return!1;return!Q.split(/[\\/]/)[0]?.startsWith(".")}function nV($,J,Q,X){return _2($,J,Q,!0,X)}function sV($,J,Q,X){if(!Q)return!1;return ZQ(H0(O1($,J,X)),Q)}function aV($,J,Q,X){if(!Q)return!1;return dq($,J,Q,X,Q.entry)}function tV($,J,Q,X){if(!Q)return!1;return dq($,J,Q,X,Q.markerFile)}function dq($,J,Q,X,Y){let W=H0(O1($,J,X));return W===Y||iq(W,Q)}function rq($,J,Q,X){if(!Q)return!1;return Q.hooksDirectories.some((Y)=>$.some((W)=>E9(Y,H0(O1(W,J,X)))))}function ZQ($,J){return $===J.entry||J.directories.includes($)||iq($,J)}function iq($,J){return J.hooksDirectories.some((Q)=>E9($,Q))}function mq($){return[$.entry,...$.directories,...$.hooksDirectories]}function E9($,J){let Q=pq(J,$);return Q===""||!/^\.\.(?:[\\/]|$)/.test(Q)&&!lq(Q)}function H0($){return process.platform==="win32"?$.toLowerCase():$}function eV($,J,Q,X){if(M3($))return null;let Y=l1([...$],X.environment);if(l(Y[0]??"").toLowerCase()!=="mv")return null;let W=A9(Y.slice(1)),K=W.sources.find((B)=>nV(f1(B,J.variables),J.cwd,Q,X));if(K)return K;return W.destination&&sV(f1(W.destination,J.variables),J.cwd,Q,X)?W.destination:null}import{isAbsolute as sq,normalize as $_,sep as MQ}from"node:path";var oq=process.platform==="win32";function O3($,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=O3($.trim(),J);if(!sq(Q))return"must be an absolute path or start with ~/";return T9(Q,J)}function S9($,J){if(typeof $!=="string"||$.trim()==="")return"must be a non-empty path string";let Q=O3($.trim().replace(/^\$(?:\{HOME\}|HOME(?=\/|$))/,"~"),J);if(!sq(Q))return null;if(T9(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 T9($,J){let Q=nq($),X=nq(J);if(Q===X)return"cannot be the home directory";let Y=Q.endsWith(MQ)?Q:`${Q}${MQ}`;if(X.startsWith(Y))return"cannot contain the home directory";return null}function nq($){let J=$_($);if(oq)J=J.replace(/\//g,"\\").toLowerCase();if(J.length>(oq?3:1)&&J.endsWith(MQ))J=J.slice(0,-1);return J}var X_=process.platform==="win32",aq=64,Y_=16384;function N3($){let J=Wq($,aq,aq,Y_);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:W_($)}}function W_($){let J=$.parts.filter((Q)=>Q.provenance==="variable"&&/\$(?:TMPDIR(?![A-Za-z0-9_])|\{TMPDIR\})/.test(Q.raw));return J.length>0&&J.every((Q)=>K_($.raw,Q.span.start-$.span.start))}function K_($,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:H_($.allowPaths,J,Q,X),protectedGitMetadata:$.protectedGitMetadata,pathCanonicalizationContext:X}}function e1($,J,Q={}){let X=Q.targetIsLiteral??!1;if(!X&&J.tmpdirWordSplittingUnsafe&&!Q.tmpdirWordSplittingProtected&&L_($))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(B_($,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(q_($,J.trustTmpdirVar,J.posixShell,Y,X,Q.tmpdirWordSplittingProtected??!1,J.trustedTmpdirValue,J.environment))return{kind:"temp_target"};if(Y)return{kind:"dynamic_target"};if(Z_($,J,X))return{kind:"temp_target"};let W=J.anchoredCwd;if(W){if(!Q.skipHomeCwd&&F_(W,J.environment.home,J.environment.paths,J.pathCanonicalizationContext))return{kind:"home_cwd_target"};if(!Q.skipCwdSelf&&V_($,J.resolvedCwd??W,J.environment.paths,J.pathCanonicalizationContext))return{kind:"cwd_self_target"};if(__($,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(G_(W))return!1;if(yB(W,J.environment))return!1;return![J.anchoredCwd,J.resolvedCwd].some((K)=>D_(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 B_($,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=I1(J1(Y,J.environment.paths,J.pathCanonicalizationContext));if(W===Q_(W).root)return!0;return W===I1(J1(J.environment.home,J.environment.paths,J.pathCanonicalizationContext))}catch{return!1}}function I1($){let J=J_($);if(X_){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 q_($,J,Q,X,Y,W,K,B){let q=$.trim();if($U(q))return!1;if(!X&&xJ(q,B))return!0;return(J||W&&K)&&Q&&!Y&&U_(q,Q)}function U_($,J){return["$TMPDIR","${TMPDIR}"].some((Q)=>{if($===Q)return!0;if(!$.startsWith(`${Q}/`))return!1;return!JU($.slice(Q.length+1),J)})}function G_($){let J=/^(?:\$TMPDIR|\$\{TMPDIR\})(?:\/(.*))?$/.exec($);if(!J)return!1;return tq.normalize(`/${J[1]??""}`)==="/"}function $U($){return $.split(/[\\/]+/).includes("..")}function H_($,J,Q,X){if(!$?.length)return[];return $.flatMap((Y)=>{let W=O3(Y.trim(),J);if(!FQ(W))return[];try{let K=J1(W,Q,X);if(T9(K,J1(J,Q,X)))return[];return[I1(K)]}catch{return[]}})}function Z_($,J,Q){if(J.allowRoots.length===0)return!1;let X=$.trim();if($U(X))return!1;let Y=Q?X:O3(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=I1(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 L_($){return/\$(?:TMPDIR(?![A-Za-z0-9_])|\{TMPDIR\})/.test($)}function JU($,J=!1){return $.includes("$")||$.includes("`")||M_($)||J&&O_($)}function M_($){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 O_($){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==="{"&&N_($,Q)||(X==="+"||X==="@"||X==="!")&&$[Q+1]==="(")return!0}return!1}function N_($,J){let Q=$.indexOf("}",J+1);if(Q===-1)return!1;let X=$.slice(J+1,Q);return X.includes(",")||X.includes("..")}function F_($,J,Q,X){try{return I1(J1($,Q,X))===I1(J1(J,Q,X))}catch{try{return I1($)===I1(J)}catch{return!1}}}function V_($,J,Q,X){if($==="."||$==="./"||$===".\\")return!0;try{return I1(J1(Q4(J,$),Q,X))===I1(J1(J,Q,X))}catch{try{return I1(Q4(J,$))===I1(J)}catch{return!1}}}function __($,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 OQ($,J,W,K)}catch{return!1}if($.startsWith("./")||$.startsWith(".\\")||!$.includes("/")&&!$.includes("\\"))try{return OQ(Q4(B,$),J,W,K)}catch{return!1}if($.startsWith("../"))return!1;try{return OQ(Q4(B,$),J,W,K)}catch{return!1}}function OQ($,J,Q,X){try{return QU(J1($,Q,X),J1(J,Q,X))}catch{return!1}}function D_($,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=I1($),X=I1(J);return Q.startsWith(`${X}${NQ}`)||Q===X}var z_=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.",I_="PowerShell Remove-Item -Recurse -Force in home directory is dangerous. Change to a project directory first.",j_="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 b_($.words.map((Y)=>({kind:"word",text:Y.text,dynamic:Y.provenance!=="literal"})),J,X,Q.policy)}function b_($,J,Q,X){let Y=$.filter((q)=>q.kind==="word"),W=A_(Y),K=Y[W];if(!K||!z_.has(k_(K.text)))return null;let B=P_(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",j_);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=g_(e1(DQ(q.text),Q),Q,X);if(U)return U}return null}function P_($){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(E_(q))continue;if(K){J.push(_Q(q)),W=W||q.dynamic;continue}if(q.text==="--"){K=!0;continue}let U=S_(q.text);if(!U){J.push(_Q(q)),W=W||q.dynamic;continue}if(T_(U.name)){let G=U.value?C_(U.value,q):$[++B];if(G?.kind==="word")J.push(_Q(G)),W=W||G.dynamic;else W=!0;continue}if(w_(U.name)){Q=!0;continue}if(v_(U.name)){X=!0;continue}if(f_(U.name))Y=h_(U.value)}return{targets:J,recursive:Q,force:X,whatIfProtected:Y,hasDynamicTarget:W}}function A_($){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 E_($){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 C_($,J){return{kind:"word",text:$,dynamic:J.kind==="word"&&(J.dynamic||$.includes("$"))}}function S_($){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 T_($){return"path".startsWith($)||"literalpath".startsWith($)}function w_($){return"recurse".startsWith($)}function v_($){return $.length>=2&&"force".startsWith($)}function f_($){return $==="wi"||"whatif".startsWith($)}function h_($){if($===void 0||$==="")return!0;let J=$.toLowerCase();return J==="$true"||J==="true"}function k_($){return $.toLowerCase()}function g_($,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",I_);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 r9}from"node:path";var h1=new Set(["awk","gawk","nawk","mawk"]),y_=new Set(["-e","--source"]),x_=new Set(["-F","-v","--assign","--field-separator"]),BU=new Set(["-f","--file"]),u_=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"}],m_="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 f9($,J,Q){let X=!1;for(let Y of l_($)){let W=p_(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",m_):null}function RQ($){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&&y_.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&&(x_.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 RQ($).sources}function l_($){return V3($).filter((J)=>J.kind!=="program-file").map((J)=>J.value)}function p_($,J){C1(J,$);let Q=$.includes("system")?IQ($,J):null,X=c_($,J);if(!Q&&!X)return null;return{dynamic:!!Q?.dynamic||!!X?.dynamic,commands:[...Q?.commands??[],...X?.commands??[]]}}function IQ($,J){C1(J,$);let Q=[],X=!1,Y=!1,W=0;while(W<$.length){let K=$[W];if(K==='"'||K==="'"){W=v9($,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=w9($,W);if($[q]!=="(")continue;q=w9($,q+1);let U=$[q];if(U!=='"'&&U!=="'"){X=!0,Y=!0;continue}let G=v9($,q,U);if(!G){X=!0,Y=!0;continue}if(q=w9($,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 c_($,J){C1(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=v9($,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(`;
|
|
51
|
+
{}`.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=w9($,H);if(zQ($,L,"getline")){Y=!0;let Z=i_(K,q,U);if(Z===null)X=!0;else Q.push(Z);U=H,W=H;continue}if(n_(K,B)){Y=!0;let Z=r_($,L);if(!Z){X=!0,U=H,W=H;continue}if(!d_($,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 w9($,J){let Q=J;while(/\s/.test($[Q]??""))Q++;return Q}function d_($,J){let Q=J;while(/[\t\f\v\r ]/.test($[Q]??""))Q++;let X=$[Q];return!X||`;
|
|
52
|
+
}#`.includes(X)}function v9($,J,Q){let X="",Y=!1;for(let W=J+1;W<$.length;W++){let K=$[W];if(!K)break;if(Y){let B=o_($,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 r_($,J){let Q=$[J];if(Q!=='"'&&Q!=="'")return null;return v9($,J,Q)}function i_($,J,Q){if(!J)return null;return J.startIndex>=$&&J.endIndex===Q?J.value:null}function o_($,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:`
|
|
53
|
+
`,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 n_($,J){return J!==null&&J>=$}function UU($,J){let Q=$.indexOf(`
|
|
54
|
+
`,J);return Q===-1?$.length:Q+1}function GU($,J){let Q=s_($,J);if(Q===-1)return!0;if("{([,;!~=".includes($[Q]??""))return!0;let X=Q;while(F3($[X-1]))X--;return u_.has($.slice(X,Q+1))}function s_($,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"]),a_=new Set(["sudo","env","command","builtin"]),t_=new Set(["git","busybox",...ZU,...H1,...EB,...h1]);function h9($,J){let Q=$[0];if(!Q||!J.transparentWrappers.includes(l(Q)))return null;let X=l(Q),Y=$[1]==="--"?2:1,W=e_($,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 e_($,J,Q,X){let Y=$[1]==="--",W=[];for(let K=J;K<$.length;K++){let B=$[K];if(!B)continue;if(l(B)!==Q&&$D(B,X))W.push(K);else if(s6.has(i(B)))break;if(Y)break}return W}function $D($,J){let Q=l($),X=i($);return X==="git"||Q==="busybox"||_3($)||ZU.has(Q)||J.transparentWrappers.includes(Q)||H1.has(X)||$==="$SHELL"||S1(X)||h1.has(X)||J.rules.some((Y)=>Y.command===Q)}function _3($){return a_.has($.toLowerCase())}function LU($){let J=i($);return t_.has(J)||S1(J)}function $0($,J){let Q=J.policy??{rules:[],transparentWrappers:[]};return jQ([...$],J.environment,J.cwd,J.cwd,new Map,new Map(J.envAssignments??[]),Q,{iterations:0},!1)}function*jQ($,J,Q,X,Y,W,K,B,q){let U=uJ($,J,Q,W);if(U.unverifiableEnvSplit)throw new L2;for(let[Z,M]of U.envAssignments)W.set(Z,M),Y.set(Z,M);let{tokens:G,cwd:H}=U;if(_3(G[0]??""))throw new m1;let L=h9(G,K);if(L){for(let Z of[L.childIndex,...L.alternativeChildIndices])MU(B),yield*jQ(Z===L.childIndex?L.tokens:[...G.slice(Z)],J,H,X,new Map(Y),new Map(W),K,B,!0);return}if(QD(G)){MU(B),yield*jQ([...G.slice(1)],J,H,X,Y,W,K,B,q);return}yield JD(G,H,X,Y,W,q)}function JD($,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 MU($){if($.iterations>=i2)throw new m1;$.iterations++}function QD($){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 OU($){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 XD="find -delete permanently removes files. Use -print first to preview.",YD="find -exec rm -rf is dangerous. Use explicit file list instead.",WD=new Set(["-exec","-execdir","-ok","-okdir"]),KD=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 k9($,J){let Q=$.map(h),X=BD($,Q,J);if(X)return X;if(y9(Q,1)&&!UD($,Q,J)){let K=k(z("find.delete",XD),J.policy);if(K)return K}let Y=J.derivedCommandWorkBudget??o6(),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=HD(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 BD($,J,Q){if(!y9(J,1)&&!AQ(J,Q.environment))return null;let Y=g9($)??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(qD(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 qD($){return $.some((J,Q)=>{if(!["-name","-iname"].includes(J))return!1;return $[Q+1]?.toLowerCase()==="hooks"})}function UD($,J,Q){if(J.includes("-L")||J.includes("-f")||J.includes("-follow"))return!1;let X=g9($);if(!X)return!1;let Y=Q.envAssignments??new Map,W=yJ(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:GD(H,W),targetIsLiteral:G.expandedTargets!==void 0||G.targetIsLiteral,tmpdirWordSplittingProtected:G.tmpdirWordSplittingProtected}))})}function GD($,J){if(!J)return $;return $.replace(/^(?:\$TMPDIR|\$\{TMPDIR\})/,()=>J)}function g9($){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 HD($,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",YD);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 y9($,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 KD.get($)??(/^-newer[A-Za-z]{2}$/.test($)?1:0)}function f0($){return $!==void 0&&WD.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 ZD=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 j1($){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=LD(X.entries);if(Y.size===0)return{blockedReason:X.blockedReason,expanded:!1,tokens:$};let W=$,K=!1;for(let B=0;B<ZD;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=VD(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 LD($){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=OD(J,Q);return{blockedReason:W.blockedReason,entries:[...W.entries,...MD($,J,Q)]}}function MD($,J,Q){let X=[],Y=1;while(Y<$.length){let W=$[Y];if(!W||W==="--"||!W.startsWith("-"))return X;if(W==="-c"){let K=CQ($[Y+1]);if(K)X.push(K);Y+=2;continue}if(W.startsWith("-c")&&W.length>2){let K=CQ(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 OD($,J){let Q=ND($,J),X=FD($,J);return{blockedReason:Q===null||X===null?EQ:null,entries:[...Q??[],...X??[]]}}function ND($,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=CQ(W);if(!K)return null;X.push(K)}return X}function FD($,J){let Q=y6($,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 CQ($){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 VD($){let J=$?.trimStart();if(!J||J.startsWith("!"))return null;return z3(J)}var _D="git checkout -- discards uncommitted changes permanently. Use 'git stash' first.",DD="git checkout --force discards uncommitted changes. Use 'git stash' first.",zD="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.",ID="git checkout with multiple positional args may overwrite files. Use 'git switch' for branches or 'git restore' for files.",jD="git switch --discard-changes discards uncommitted changes. Use 'git stash' first.",bD="git switch --force discards uncommitted changes. Use 'git stash' first.",PD="git restore discards uncommitted changes. Use 'git stash' first, or use --staged to only unstage.",AD="git restore --worktree explicitly discards working tree changes. Use 'git stash' first.",ED="git reset --hard destroys all uncommitted changes permanently. Use 'git stash' first.",CD="git reset --merge can lose uncommitted changes. Use 'git stash' first.",SD="git clean -f removes untracked files permanently. Use 'git clean -n' to preview first.",TD="git push --force destroys remote history. Use --force-with-lease for safer force push.",wD="git push deletes remote refs. Ask the user to run it manually if deletion is intended.",vD="git push --mirror can force-update and delete remote refs. Ask the user to run it manually if mirror push is intended.",fD="git branch -D force-deletes without merge check. Use -d for safe delete.",hD="git rebase --abort discards rebase conflict resolutions. Use 'git status' first.",kD="git merge --abort discards merge conflict resolutions. Use 'git status' first.",gD="git tag -d permanently deletes tags. Ask the user to run it manually if deletion is intended.",yD="git reflog delete removes recovery history. Ask the user to run it manually if deletion is intended.",xD="git stash drop permanently deletes stashed changes. Consider 'git stash list' first.",uD="git stash clear deletes ALL stashed changes permanently. Use 'git stash list' to review; ask the user to run it manually if intended.",mD="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"]),SQ=new Set(["-b","-B","-U"]),TQ=new Set(["-c","-C"]),lD=new Set(["--source","--conflict","--unified","--inter-hunk-context"]),pD=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 IU($){let{subcommand:J,rest:Q}=J0($);if(!J)return null;switch(J.toLowerCase()){case"checkout":return z2(cD(Q));case"switch":return z2(dD(Q));case"restore":return z2(iD(Q));case"reset":return nD(Q);case"clean":return z2(aD(Q));case"push":return R2(tD(Q));case"branch":return R2(Jz(Q));case"stash":return R2(Kz(Q));case"worktree":return R2(Bz(Q));case"rebase":return z2(Qz(Q));case"merge":return z2(Xz(Q));case"tag":return R2(Yz(Q));case"reflog":return R2(Wz(Q));default:return null}}function z2($){return $?{...$,localDiscard:!0}:null}function R2($){return $?{...$,localDiscard:!1}:null}function cD($){let{index:J,before:Q}=j1($),X=v1(Q,{shortOptsWithValue:SQ});if(Q.some((W)=>a(W,"--force"))||X.has("-f"))return z("git.checkout-force",DD);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",zD);return z("git.checkout-double-dash",_D)}if(rD($).length>=2)return z("git.checkout-ambiguous",ID);return null}function dD($){let{before:J}=j1($);if(J.some((X)=>a(X,"--discard-changes")))return z("git.switch-discard-changes",jD);let Q=v1(J,{shortOptsWithValue:TQ});if(J.some((X)=>a(X,"--force"))||Q.has("-f"))return z("git.switch-force",bD);return null}function rD($){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("--")&&!pD.has(X)&&!DU.has(X)&&!zU.has(X))Q++;else Q++;else J.push(X),Q++}return J}function iD($){let J=oD($);if(J.isTerminal||!J.hasPathspec&&!J.hasPatch||!J.hasWorktree)return null;return J.hasExplicitLocation?z("git.restore-worktree",AD):z("git.restore-unstaged",PD)}function oD($){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(lD.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 nD($){let J=null;for(let Q of $){if(a(Q,"--hard")){J=z("git.reset-hard",ED);break}if(a(Q,"--merge")){J=z("git.reset-merge",CD);break}}if(!J)return null;return sD($)?R2(J):z2(J)}function sD($){for(let J of $){if(J==="--")return!1;if(!J.startsWith("-"))return!0}return!1}function aD($){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",SD);return null}function tD($){let{before:J,after:Q}=j1($),X=v1(J);if(J.some((K)=>a(K,"--mirror")))return z("git.push-mirror",vD);if(J.some((K)=>a(K,"--force"))||X.has("-f")||RU(J,Q).some(eD))return z("git.push-force",TD);if(J.some((K)=>a(K,"--delete"))||X.has("-d")||RU(J,Q).some($z))return z("git.push-delete",wD);return null}function RU($,J){return[...$.filter((Q)=>Q!==""&&!Q.startsWith("-")),...J]}function eD($){return $.startsWith("+")||$.includes(":+")}function $z($){return $.length>1&&$.startsWith(":")}function Jz($){let{before:J}=j1($),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",fD);return null}function Qz($){let{before:J}=j1($);return J.some((Q)=>a(Q,"--abort"))?z("git.rebase-abort",hD):null}function Xz($){let{before:J}=j1($);return J.some((Q)=>a(Q,"--abort"))?z("git.merge-abort",kD):null}function Yz($){let{before:J}=j1($);return v1(J).has("-d")||J.some((X)=>a(X,"--delete"))?z("git.tag-delete",gD):null}function Wz($){return $[0]==="delete"?z("git.reflog-delete",yD):null}function Kz($){for(let J of $){if(J==="drop")return z("git.stash-drop",xD);if(J==="clear")return z("git.stash-clear",uD)}return null}function Bz($){let{before:J}=j1($);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",mD);return null}import{execFileSync as qz}from"node:child_process";import{existsSync as vQ,readFileSync as fQ}from"node:fs";import{dirname as Uz,isAbsolute as PU,join as wQ,resolve as AU}from"node:path";var Gz=["/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=Hz($,J,Q);if(Y!==null)return Y;let W=Zz(J,Q);if(W!==null)return W;if($B(Q))return!0;return Lz(X)}function Hz($,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=jU($[Y+1]);if(K!==null)X=K;Y+=2;continue}if(W.startsWith("-c")&&W.length>2){let K=jU(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 Zz($,J){if(u1("GIT_CONFIG_PARAMETERS",$,J)!==void 0)return!0;let Q=y6($,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=R3(K)}return X}function Lz($,J=Oz()){let Q=Mz($);if(Q===null||Q)return!0;if(J===null)return!0;try{let X=qz(J,["config","--get","submodule.recurse"],{cwd:$,encoding:"utf8",env:Nz(process.env),stdio:["ignore","pipe","ignore"]}).trim();return R3(X)}catch(X){return!Fz(X)}}function Mz($){let J=Vz($);if(J===null)return null;for(let Q of J){if(!vQ(Q))continue;if(zz(Q))return!0}return!1}function Oz(){for(let $ of Gz)if(vQ($))return $;return null}function Nz($){let J={...$};for(let Q of Object.keys(J))if(a4(Q))delete J[Q];return J}function Fz($){return typeof $==="object"&&$!==null&&"status"in $&&$.status===1}function Vz($){let J=$3($);if(J===null)return null;let Q=_z(J);if(Q===null)return null;let X=Dz(Q);if(X===null)return null;return[wQ(X,"config"),wQ(Q,"config.worktree")]}function _z($){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(Uz($),X)}catch{return null}}function Dz($){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 zz($){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=R3(U)}return X}function Rz($){return $==="include"||$.startsWith("includeif ")}function jU($){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 R3(X)}function R3($){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||R3(W)}function hQ($){return $==="include.path"||$.startsWith("includeif.")&&$.endsWith(".path")}function CU($,J,Q){if(!J.localDiscard||!Q.worktreeMode||YB(Q.env,Q.envAssignments))return null;let X=WB($,Q.cwd);if(!X.gitCwd||X.hasExplicitGitContext)return null;if(!KB(X.gitCwd))return null;if(Iz($,Q,X.gitCwd))return null;return{originalReason:J.reason,gitCwd:X.gitCwd}}function Iz($,J,Q){let{subcommand:X,rest:Y}=J0($),W=X?.toLowerCase();if(J.dynamicArguments||jz(Y)||EU($,J.env,J.envAssignments,Q)||Az(Y)||bz(W,Y))return!0;return W==="clean"&&Ez(Y)>1}function jz($){return $.some((J)=>/[$*?[]/.test(J))}function bz($,J){if($==="checkout"){let{before:Q}=j1(J),X=v1(Q,{shortOptsWithValue:SQ}),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}=j1(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")||Pz(K))||X.has("-C");return Y&&W}return!1}function Pz($){let J=$.split("=",1)[0]??$;return J==="--force-create"||J.length>=9&&"--force-create".startsWith(J)}function Az($){return $.some((J)=>J.startsWith("--recurse-sub"))}function Ez($){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 Cz="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.",Sz=new Set(["clone","fetch","pull","push","ls-remote","submodule"]);function X4($,J){return SU($.map(h),J)}function SU($,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((eK(J.envAssignments)||VU($,J.env,J.envAssignments))&&Tz(W))return z("git.ssh-env",Cz);let K=IU(W);if(!K)return null;if(X.expanded||X.blockedReason)return K;let B=CU($,K,J);if(!B)return K;return Q?.(B),null}function TU($,J){let Q=null;return{match:SU($.map(h),J,(Y)=>{Q=Y}),relaxation:Q}}function Tz($){let{subcommand:J,rest:Q}=J0($),X=J?.toLowerCase();if(!X)return!1;if(Sz.has(X))return!0;if(X==="archive")return j1(Q).before.some((Y)=>a(Y,"--remote"));return X==="remote"&&wz(Q)}function wz($){return $.find((J)=>!vz(J))?.toLowerCase()==="update"}function vz($){return $==="-v"||a($,"--verbose")||a($,"--no-verbose")}import{isAbsolute as IR}from"node:path";var wU="rm -rf outside cwd is blocked. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",fz="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.",hz="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.",kz="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=OU(X),K=yz($);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 gz(U,Q,G)){let L=vU(H,Q,J.policy),Z=k(L,J.policy);if(Z)return Z}}}return null}function gz($,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 yz($){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",hz);case"home_cwd_target":return z("rm.recursive-force-home-cwd",kz);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",fz);return null;case"outside_anchored_cwd":return z("rm.recursive-force-outside-cwd",wU)}}var xz={bash:["O","o"],dash:["o"],ksh:["o"],sh:["o"],zsh:["o"]},kU=new Set(["--init-file","--rcfile"]),uz=["--init-file","--rcfile"],mz=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=lz($,J),X=mz.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 lz($,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?uz.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(!xz[$]?.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"},I2={kind:"dynamic"},pz=new Set(["<","<<","<<-","<<<","<&","<>"]),uU=/\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*))/g,cz=/^(?:[0-9]+|[@*])$/,dz=F2.maxWords,rz=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
|
|
55
55
|
`)return`${X.join(`
|
|
56
56
|
`)}
|
|
57
57
|
`;if(Q.includes("%")||/\\(?![\\nrt])/.test(Q))return;return Q.replaceAll("\\n",`
|
|
58
|
-
`).replaceAll("\\r","\r").replaceAll("\\t","\t").replaceAll("\\\\","\\")}function W4($){let J=I3($[1])==="--"?2:1;if($.length<=J)return a0;let Q=$.slice(J);if(!Q.every(u9))return I2;return{kind:"literal",source:Q.map(h).join(" ")}}function lU($){let J=I3($[1])==="--"?2:1,Q=$[J],X=I3(Q);if(Q===void 0||$.length<=J+1||X==="-"||X===""||X==="-l"||X==="-p")return a0;if(!u9(Q))return I2;return{kind:"literal",source:X}}function x9($,J){let Q=
|
|
59
|
-
`}}function
|
|
58
|
+
`).replaceAll("\\r","\r").replaceAll("\\t","\t").replaceAll("\\\\","\\")}function W4($){let J=I3($[1])==="--"?2:1;if($.length<=J)return a0;let Q=$.slice(J);if(!Q.every(u9))return I2;return{kind:"literal",source:Q.map(h).join(" ")}}function lU($){let J=I3($[1])==="--"?2:1,Q=$[J],X=I3(Q);if(Q===void 0||$.length<=J+1||X==="-"||X===""||X==="-l"||X==="-p")return a0;if(!u9(Q))return I2;return{kind:"literal",source:X}}function x9($,J){let Q=iz($);if(Q===-1)return a0;let X=oz(J);if(!X)return a0;let Y=[],W=X.command?.length??0;for(let K of X.references){let B=sz(K,$,Q,X.ifs);if(!B)return I2;if(W+=B.reduce((q,U)=>q+U.length+3,0),Y.length+B.length>dz||W>rz)return I2;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(tz)].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)&&pz.has(W.operator)).at(-1);if(Y){if(Y.operator==="<<"||Y.operator==="<<-")return a0;if(Y.operator!=="<<<"||Y.target?.provenance!=="literal")return I2;return{kind:"literal",source:Y.target.text}}if(!Q)return a0;return X===void 0?I2:{kind:"literal",source:X}}function M0($){let J=L0($.map(h)).scriptIndex;if(J===null)return a0;let Q=$[J],X=I3(Q);return k6(Q,X)?{kind:"literal",source:X}:I2}function iz($){return L0($.map(h)).commandIndex??-1}function oz($){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(nz);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]??"":`
|
|
59
|
+
`}}function nz($){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 sz($,J,Q,X){let Y=J.slice(Q+2);if($.parameter==="@")return $.quoted?kQ(Y):az(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&&!u9(W))return;let K=I3(W);return $.quoted?[K]:gQ(K,X)}function kQ($){return $.every(u9)?$.map(h):void 0}function az($,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===`
|
|
60
60
|
`)return $.trim().split(/\s+/).filter(Boolean);if(J.length!==1)return;return J===" "||J==="\t"||J===`
|
|
61
|
-
`?$.trim().split(/\s+/).filter(Boolean):$.split(J).filter(Boolean)}function u9($){if(!$)return!0;return $.provenance==="unknown"?!/[$`]/.test(h($)):$.provenance==="literal"}function I3($){return $?h($):""}function sz($){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;JR(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(j3(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=az($,Q,J);if(W===null)return!1;if(W===-1)return!0;return cU($.slice(W),J)}function az($,J,Q){let X=i($[J]?.text??"");if(X==="command")return tz($,J+1);if(X==="exec")return ez($,J+1);if(X==="env")return $R($,J+1,Q);return null}function tz($,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 ez($,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 $R($,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 j3($[X+1],Q)?-1:X+2;if(W.startsWith("-S")||W.startsWith("--split-string="))return j3(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 JR($,J){if(!$.words.every((Q)=>q0(Q.text)!==null))return;for(let Q of $.words){let X=q0(Q.text);if(!X)continue;if(j3(Q,J))J.add(X.name)}}function j3($,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&&(lz.test(Y)||J.has(Y))}))}function xU($,J){return!!$&&($.parts.some((Q)=>Q.provenance!=="literal"&&Q.provenance!=="variable")||j3($,J))}var QR=new Set(["-c","-C","--git-dir","--work-tree","--namespace","--config-env"]),XR=new Set(["-c","-H","-l","--config","--context","--host","--log-level","--tlscacert","--tlscert","--tlskey"]),YR=new Set;function dU($){if($==="git")return QR;if($==="docker")return XR;return YR}function M1($,J){if($.length===0||J.length===0)return null;let Q=i($[0]??""),X=v1($);for(let Y of J){if(!WR(Q,Y.command))continue;if(!KR(Q,$,Y.subcommand))continue;if(qR($,new Set(Y.block_args),X))return{id:`custom.${Y.name}`,reason:`[${Y.name}] ${Y.reason}`,intent:Y.intent??"manual_only"}}return null}function WR($,J){return $===i(J)}function KR($,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("=")&&BR($,W,Q,X))return!0;continue}return K===Q}return!1}function BR($,J,Q,X){let Y=$[J+1];if(!Y||Y.startsWith("-"))return!1;return rU($,J+2,Q,X)}function qR($,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 O0(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=M0(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(f9($,(W)=>J.analyzeNested?J.analyzeNested(W,{effectiveCwd:J.cwd,envAssignments:J.envAssignments}):null),J.policy)??M1($,J.policy?.rules??[])??O0(Q,J);if(S1(Y)){let W=t6($);if(!W)return O0(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(J9(Y,W))return O0(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",O2),J.policy)??O0(Q,J);return O0(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:S0(J.envAssignments,J.environment),protectedGitMetadata:J.protectedGitMetadata,policy:J.policy}),J.policy)??(W&&Q.dynamicRmInput?O0(Q,J):null)??(W?UR(Q,J):null)}if(Y==="find")return k9(p($),{...J,derivedCommandWorkBudget:J.derivedCommandWorkBudget,analyzeTokens:(W,K)=>t0(W,{...J,cwd:K??void 0,derivedCommandWorkBudget:J.derivedCommandWorkBudget},Q)})??M1($,J.policy?.rules??[])??O0(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)??M1($,J.policy?.rules??[])??O0(Q,J);return M1($,J.policy?.rules??[])??O0(Q,J)}function B4($,J){return $.shellDynamicMatch?k($.shellDynamicMatch,J.policy):null}function O0($,J){return $.dynamicSourceInput&&$.dynamicSourceMatch?k($.dynamicSourceMatch,J.policy):null}function UR($,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.",GR="__CC_SAFETY_NET_XARGS_INPUT__",m9="__CC_SAFETY_NET_XARGS_INTERPRETER_INPUT__",l9="rm",HR=/(?:^|[;&|]\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,ZR=/(?:^|[;&|]\s*)\s*eval\b((?:\\.|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\\'";&|\r\n])*)/g,LR=/\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)(?:[^}]*)\})/g,MR=/^(?:[0-9]+|[@*])$/,OR=new Set(["branch","checkout","clean","push","reset","restore","switch","tag"]);function nU($,J){let Q=$.map(h),{childStart:X,replacementToken:Y}=j2(Q),W=Q.slice(X),K=z("xargs.shell-dynamic",mQ);if(FR(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=NR(q,Y,J.policy?.rules??[]);if(Z)return Z;if(B.head==="git"){let O=Y===null?[...q,GR]:q,V=Y!==null&&(q.some((b)=>b.includes(Y))||Array.from(B.envAssignments.values()).some((b)=>b.includes(Y))),F=t0(O,{...J,cwd:B.cwd,envAssignments:B.envAssignments,worktreeMode:Y===null||V?!1:J.worktreeMode});if(F)return F}let M=M1(q,J.policy?.rules??[]);if(M)return M}return null}function NR($,J,Q){if(Q.length===0)return null;if(J===null){for(let Y of Q){let W=M1([...$,...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=M1($.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&&VR($,Q))return!0;let B=Z0($);if(!B){let q=M0(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 _R(B,Q,X)}if(S1(J))return iU($,Q,$9,TB(J));if(h1.has(J))return iU($,Q,RQ,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 DR($,Q,W,K);if(J==="git"){let B=J0($);return Q===null?B.subcommand===null:(B.subcommand?.includes(Q)??!1)||B.subcommand!==null&&OR.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([...$,m9]).sources.some((q)=>q.value===m9);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}${m9}`]:[],...q.valueForm==="equals-or-separate"?[`${q.selector}=${m9}`]:[]]),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 FR($,J,Q){if($.length===0||($[0]??"").toLowerCase()==="command")return!1;let X=new Set(Array.from($0($,Q),(W)=>W.head)),Y=J===null?[...$,l9]:$.map((W,K)=>K===0?W:W.replaceAll(J,l9));return Array.from($0(Y,Q)).some((W)=>W.head===l9&&!X.has(l9))}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 VR($,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 _R($,J,Q){let X=new Set(J===null?[]:Array.from(Q).filter(([,Y])=>Y.includes(J)).map(([Y])=>Y));for(let Y of $.matchAll(HR))if(oU(Y,X))return!0;for(let Y of $.matchAll(ZR))for(let W of(Y[1]??"").matchAll(LR))if(oU(W,X))return!0;return xQ($,X)}function oU($,J){let Q=$[1]??$[2];return Q!==void 0&&(MR.test(Q)||J.has(Q))}function DR($,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 j2($){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.",RR="parallel without a command reads executable commands from dynamic input. Use an explicit command template or ::: arguments instead.",IR="parallel command construction cannot be verified safely. Use the default ::: separator, literal arguments, and built-in replacement strings.",jR=/\{[^{}\s]*\}/,qG=/\{\}|\{-?\d+\}/g,bR=new Set(["branch","checkout","clean","merge","push","rebase","reflog","reset","restore","stash","switch","tag","worktree"]),PR=["e","f","source","file","-e","-f","--source","--file"],AR=["c","e","eval","m","r","Mmodule","import","require","-c","-e","-m","-r","--eval","--import","--require"],ER=new Set(["-L","-d","-n","--delay","--delimiter","--header","--joblog","--jl","--max-args","--max-lines","--nice","--results","--result","--res","--tagstring","--timeout"]),CR=new Set(["--arg-file","--colsep","--rpl","--arg-sep","--arg-file-sep"]),$G=new Set(["-S","--sshlogin","--slf","--sshloginfile"]),SR=new Set(["--workdir","--wd"]),JG="__CC_SAFETY_NET_PARALLEL_SOURCE__",TR=new TextEncoder,c9=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 O=P2(J);if(O)return O}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 O=P2(J);if(O)return O}if(U){let O=xR(J);if(O)return O}if(H!==void 0&&B){let O=P2(J);if(O)return O}let Z=cR(H,J.cwd,J.environment.paths);if(Z===null){let O=P2(J);if(O)return O}let M=B?{...J,cwd:void 0,originalCwd:void 0}:Z===null||Z===void 0||Z===J.cwd?J:{...J,cwd:Z};if(L){let O=[...$0(W,M)];if((O.length===0?dQ(q,J.envAssignments,new Map).values:O.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 O=K.map((F)=>F[0]??"");T1(J.budget,cQ(O));let V=FG(M.envAssignments,M.cwd,B);return _1(O,(F)=>J.analyzeNested(F,V))}return _1($0(W,M),(O)=>wR(O,Y,J,M))}function wR($,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,M=B&&Z,O=FG($.envAssignments,$.wrapperCwd,K||M);if(H1.has($.head)){let F=()=>{if(!W||Y.length===0)return null;return T1(Q.budget,p9(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,(C)=>Q.analyzeNested(N0(b,C),O))}if(s(b)){if(Y.length>0)return T1(Q.budget,KG(b,Y)),_1(Y,(T)=>Q.analyzeNested(N0(b,T),O));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 C=P?t0(P,G,{dynamicInput:B,shellDynamicMatch:z("parallel.shell-dynamic",P3),rmDynamicMatch:z("parallel.rm-recursive-force-dynamic",b3)}):null;if(C)return C;return Q.analyzeNested(b,O)}let A=!L&&(!W||Y.length>0)?(Y.length>0?Y:[void 0]).map((P)=>x9(p(P===void 0?U:W?U.map((C)=>N0(C,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,O));T1(Q.budget,mR(YG(b),uR(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 j=Q.analyzeNested(b,O);if(j)return j;if(!_){let P=BG(H,Y,X,K);if(P)return P}if(Z)return b2(Q);return null}let R=M0(p(U));if(R.kind==="dynamic"||R.kind==="literal"&&s(R.source))return b2(Q)??F();if(R.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((j)=>j[0]===void 0?[]:[j[0]]);return T1(Q.budget,cQ(_)),_1(_,(j)=>Q.analyzeNested(j,O))}if(Z||B)return b2(Q)??F();return null}if($.head==="rm"&&w0(U)){if(W&&Y.length>0)return T1(Q.budget,p9(U,Y,"rm")),_1(Y,(b)=>pQ(U.map((R)=>rQ(R,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,R)=>{if(R===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?p9(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],R=z("parallel.shell-dynamic",P3),A=B&&$.head==="find"?yR(b,X):null,E=HG(b,B,Q.policy?.rules??[],Q.budget)??A?.customResult??null,_=i($.head),j=B&&(_==="rm"&&iQ(b)||_==="xargs"&&ZG(b)||A?.rmOptions===!0),P=B&&(j||A?.executedSource===!0||A===null&&GG(b,_)),C=t0(b,{...G,worktreeMode:K||B||Z?!1:Q.worktreeMode},{dynamicInput:B||Z,dynamicRmInput:j,dynamicSourceInput:E!==null||P,shellDynamicMatch:R,dynamicSourceMatch:R,rmDynamicMatch:z("parallel.rm-recursive-force-dynamic",b3)});if(P){let T=k(R,Q.policy);if(T)return T}return C??E??M1(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 hR($);if(J==="git")return vR($);if(J==="find")return!0;if(h1.has(J))return QG($,PR,V3);if(S1(J))return QG($,AR,e6);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 vR($){if(fR($))return!0;let J=J0($);if(J.subcommand===null||s(J.subcommand))return!0;if(!bR.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 fR($){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 hR($){if(c1($))return!1;let J=Z0($);if(J!==null)return s(J);let Q=M0(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,kR($,Y,W)),!W)return _1(Y,(K)=>M1([...$,...K.subcommand?[K.subcommand]:[],...K.block_args],[K]));return _1(Y,(K)=>{let B=new Set([K.subcommand,...K.block_args].flatMap((q)=>q?gR($,q):[]));return _1(B,(q)=>M1($.map((U)=>N0(U,[q])),[K]))})}function kR($,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 gR($,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 yR($,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(j2($).childStart);return i(J[0]??"")==="rm"&&iQ(J)}function d9($,J){return(Q)=>k(z($,J),Q.policy)}var b2=d9("parallel.shell-dynamic",P3),xR=d9("parallel.command-stream-dynamic",RR),P2=d9("parallel.command-stream-dynamic",IR),XG=d9("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:S0(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 p9([$],J,"generic")}function p9($,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)=>OG(q,Q))),W=b1(Y.occurrences,J.length,f.maxPlaceholderReplacements);if(W>f.maxPlaceholderReplacements)return{childAnalyses:J.length,derivedTokens:X,placeholderReplacements:W};if(MG(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 MG($,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 uR($,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)=>lR(OG(G.value,"generic"),G.frequency))),q=b1(B.occurrences,X,f.maxPlaceholderReplacements);if(q>f.maxPlaceholderReplacements)return{childAnalyses:W,placeholderReplacements:q};if(MG(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 mR($,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 OG($,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))],c9),X++,W=K.index+K[0].length}return{occurrences:X,fixedBytes:X===0?q4($):U1([Y,q4($.slice(W))],c9)}}function lR($,J){return{occurrences:b1($.occurrences,J,f.maxPlaceholderReplacements),fixedBytes:b1($.fixedBytes,J,c9)}}function NG($){return{occurrences:U1($.map((J)=>J.occurrences),f.maxPlaceholderReplacements),fixedBytes:U1($.map((J)=>J.fixedBytes),c9)}}function U4($,J=f.maxDerivedBytes){return U1($.map(q4),J)}function q4($){return TR.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()),pR(X)}function pR($){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 jR.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((O)=>O==="::::"||O==="::::+"||O===":::+"),G=[];while(J<$.length){let O=$[J];if(O===void 0)break;if(O===":::"){Y=J;break}if(O==="--"){let A=bQ($,J+1);Q.push(...A.templateTokens),X=J+1,Y=A.markerIndex;break}if(!O.startsWith("-")){let A=bQ($,J);Q.push(...A.templateTokens),X=J,Y=A.markerIndex;break}let V=$[J+1],F=O.indexOf("="),b=F===-1?O:O.slice(0,F),R=F===-1?void 0:O.slice(F+1);if(O==="--dry-run"){B=!0,J++;continue}if(O==="-I"||O.startsWith("-I")&&O.length>2){U||=(O==="-I"?V:O.slice(2))!=="{}",J+=O==="-I"?2:1;continue}if(O==="--replace"||O==="-i"){U=!0,J+=2;continue}if(b==="--replace"||O.startsWith("-i")&&O.length>2){let A=b==="--replace"?R:O.slice(2);U||=A!==""&&A!=="{}",J++;continue}if(O==="-a"||CR.has(b)){U=!0,J+=R===void 0?2:1;continue}if(O==="--pipe"||O==="--pipepart"){K=!0,J++;continue}if(b==="--env"){G.push(...rR(R??V)),J+=R===void 0?2:1;continue}if($G.has(b)||O.startsWith("-S")&&O.length>2){W=!0,J+=$G.has(O)?2:1;continue}if(SR.has(b)){let A=R??V;if(A===void 0||A===":::"||A==="--"){U=!0,J++;continue}q=A,U||=R!==void 0&&A==="",J+=R===void 0?2:1;continue}if(O.startsWith("-j")&&O.length>2&&/^\d+$/.test(O.slice(2))){J++;continue}if(O.startsWith("--")&&R!==void 0){J++;continue}if(ER.has(O)){if(V===void 0||V===":::"||V==="--"){U=!0,J++;continue}J+=2;continue}J+=O==="-j"||O==="--jobs"?2:1}U||=Q.some(B?oQ:_G);let H=[];if(Y!==-1){let O=[];for(let V=Y+1;V<$.length;V++){let F=$[V];if(F===":::"){H.push(O),O=[];continue}if(F!==void 0)O.push(F)}H.push(O)}let L=dR(H),Z=Q.some(s),M=Q.length===0&&Y===-1;return{template:Q,jobs:L,childStart:X,templateHasPlaceholder:Z,runsRemotely:W,usesStdin:K||Y===-1,envNames:G,readsCommandsFromInput:M,unsupported:U,workdir:q,dryRun:B}}function cR($,J,Q){if($===void 0)return;if($==="..."||/[{}$`*?~[]/.test($))return null;if(!J&&!zR($))return null;try{return d0(J??$,$,Q)}catch{return null}}function dR($){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 rR($){return($??"").split(",").map((J)=>J.trim()).filter(Boolean)}function RG($){return zG($).childStart}var iR="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.",oR=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 jG($,J,Q,X=!1,Y){let W=JQ($,J)&&q1(Y,"shell.dynamic-executable",X)?z("shell.dynamic-executable",iR):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=sR(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&&oR.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)&&aR(J)?k(z("shell.dynamic-structure",nQ),Y):null;if(K==="xargs")return IG($,J.slice(j2(J.map(h)).childStart),"xargs",Q,X,Y);if(K==="parallel")return IG($,J.slice(RG(J.map(h))),"parallel",Q,X,Y);return null}function IG($,J,Q,X,Y,W){if(J.length===0)return null;let K=nR(J,X);if(JQ($,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 nR($,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 sR($){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 aR($){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!k6(J[Q.tokenIndex],Q.value)})}var tR="dd writing to a /dev device can destroy a disk or partition. Run device writes manually after confirming the target.",eR="mkfs formatting a /dev device erases everything on it. Run the format manually after confirming the target.",$I="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",tR);if(($==="mkfs"||$.startsWith("mkfs."))&&Q.some((X)=>X.startsWith("/dev/")))return z("mkfs.device",eR);if($==="shred"&&Q.length>0)return z("shred.target",$I);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:S0($.envAssignments,$.options.environment),protectedGitMetadata:$.options.protectedGitMetadata,policy:$.options.policy})},{heads:new Set(["git"]),analyze:($)=>X4($.words,eQ($))},{heads:new Set(["find"]),analyze:($)=>k9($.words,{environment:$.options.environment,cwd:$.cwd,originalCwd:$.originalCwd,strict:$.options.strict,allowTmpdirVar:$.allowTmpdirVar,tmpdirWordSplittingUnsafe:B0($.envAssignments,$.options.environment),trustedTmpdirValue:S0($.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=(S)=>S.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=K9($);if(U.envAssignments.size>0)X?.recordSegment({type:"env-strip",input:W($),envVars:Object.fromEntries([...U.envAssignments.keys()].map((S)=>[S,"<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 S=W(U.words);X.recordSegment({type:"leading-tokens-stripped",input:S,removed:S.slice(0,S.length-H.length),output:L})}let M=new Map([...Q.envAssignments??[],...U.envAssignments,...G.envAssignments]),O=L[0];if(!O)return null;if(_3(O))throw new m1;let V=i(O),F=G.cwd===null?void 0:G.cwd??B,b=G.cwd===null?void 0:q,R=G.cwd===void 0?Q.effectiveCwd:G.cwd,A=!K3(M,Q.environment),E=jG(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 _=h9(L,Q.policy);if(_){for(let S of[_.childIndex,..._.alternativeChildIndices]){CG(Z.wrapperNormalizationBudget);let m=H.slice(S);X?.recordSegment({type:"transparent-wrapper",wrapper:_.wrapper,output:W(m)});let X1=A3(m,J,{...Z,effectiveCwd:R,envAssignments:M});if(X1)return X1}return null}let j=V==="eval"?W4(H):V==="trap"?lU(H):void 0;if(j?.kind==="dynamic")return d1(X);if(j?.kind==="literal"){X?.recordSegment({type:"recurse",reason:V==="eval"?"shell-eval":"shell-trap",innerCommand:j.source,depth:J+1});let S=Q.analyzeNested(j.source,{effectiveCwd:R,envAssignments:M,functionDefinitions:Q.functionDefinitions});if(S)return S}if(hG(O,V)){if(c1(L))return null;let S=JI(L,M,R,Q,X,J);if(S)return S;let m=Z0(L);if(m){let m2=x9(H,m);if(m2.kind==="dynamic")return d1(X);let GJ=m2.kind==="literal"?m2.source:m,LK=QI(GJ);X?.recordSegment({type:"shell-wrapper",wrapper:V,innerCommand:LK}),X?.recordSegment({type:"recurse",reason:"shell-wrapper",innerCommand:LK,depth:J+1});let MK=Q.analyzeNested(GJ,{effectiveCwd:R,envAssignments:M});if(MK)return MK;return K4(GJ)?d1(X):null}let X1=M0(H);if(X1.kind==="dynamic")return d1(X);if(X1.kind==="literal")return o9(X1.source,R,M,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:R,envAssignments:M})}if(V==="source"||V==="."){let S=L[1]==="-p"?2:null;if(S!==null){let m2=Q.commandView?H[S]:void 0;if(!m2)return null;if(m2.provenance!=="literal")return d1(X)}let m=S===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 o9(Z1.text,R,M,Q,X,J)}if(h1.has(V)){if(Q.strict&&tQ(V3(L),H))return d1(X);let S=f9(L,(X1)=>A2(Q.analyzeNested(X1,{effectiveCwd:R,envAssignments:M}))),m=k(S,Q.policy);if(m)return X?.recordSegment({type:"rule-check",ruleModule:"awk",ruleFunction:"analyzeAwkSystemCalls",matched:!0,reason:m.reason}),f0(m)}if(S1(V)){if(Q.strict&&tQ(e6(L),H))return d1(X);let S=t6(L);if(S){let m=q1(Q.policy,"interpreter.one-liner-paranoid",!!Q.paranoidInterpreters);if(X?.recordSegment({type:"interpreter",interpreter:V,codeArg:S,paranoidBlocked:m}),m){let Z1=k(z("interpreter.one-liner-paranoid",n2),Q.policy);if(Z1)return f0(Z1)}if(J9(V,S))return null;X?.recordSegment({type:"recurse",reason:"interpreter",innerCommand:S,depth:J+1});let X1=Q.analyzeNested(S,{effectiveCwd:R,envAssignments:M});if(X1&&X1.ruleId!=="raw-text.dangerous-command"&&(X1.reason!==r0||$4(S)))return X1;if(s2(S,Q.scanWork)){let Z1=k(z("interpreter.dangerous-command",O2),Q.policy);if(Z1)return X?.recordSegment({type:"dangerous-text",token:S,matched:!0,reason:O2}),f0(Z1)}X=void 0}}if(V==="busybox"&&L.length>1)return CG(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:R,envAssignments:M});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 C=X===Z.trace?Z:{...Z,trace:X},T={words:H,head:V,cwd:F,originalCwd:b,envAssignments:M,allowTmpdirVar:A,dynamicArguments:G.words.some((S)=>S.provenance==="command-substitution"),depth:J,effectiveCwd:R,options:C,analyzeChildTokens:(S,m)=>A2(A3(p(S),J+1,{...C,commandView:void 0,effectiveCwd:m,envAssignments:M}))??M1(S,C.policy.rules)},y=vG(V);if(V==="rm"||V==="xargs"||V==="parallel")X?.recordSegment({type:"tmpdir-check",tmpdirValue:M.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=SG(x?x.match:y?.(T)??null,Q.policy);if(X)XI(T,c,x?.relaxation??null);if(c)return f0(c);let V1=y!==void 0;if(!V1)if(!s6.has(V)){let S=X?[]:void 0;for(let m=1;m<L.length;m++){let X1=L[m];if(!X1)continue;S?.push(X1);let Z1=SG(YI(T,L,m),Q.policy);if(Z1)return X?.recordSegment({type:"fallback-scan",tokensScanned:S??[],embeddedCommandFound:i(X1)}),f0(Z1)}X?.recordSegment({type:"fallback-scan",tokensScanned:S??[]})}else X?.recordSegment({type:"fallback-scan",tokensScanned:[]});else X?.recordSegment({type:"fallback-scan",tokensScanned:[]});if(J===0||!V1){let S=M1(L,Q.policy.rules);if(X?.recordSegment({type:"custom-rules-check",rulesChecked:Q.policy.rules.length>0,matched:!!S,reason:S?.reason}),S)return f0(S)}else X?.recordSegment({type:"custom-rules-check",rulesChecked:!1,matched:!1});return null}function JI($,J,Q,X,Y,W){let K=gU($);if(K.argvSource?.kind==="absent")return d1(Y);if(K.argvSourceApplies&&K.argvSource){let q=o9(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 o9(B,Q,J,X,Y,W,!0)}function o9($,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 QI($){let J=$[0];return $.length>=2&&(J==='"'||J==="'")&&$.at(-1)===J?$.slice(1,-1):$}function XI($,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 CG($){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 YI($,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=WI($,Q,Y);if(W)return W}return null}function WI($,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(M0(p(q)).kind==="dynamic")return fG();return i9($,Q)}let G=$.options.analyzeNested(U,{effectiveCwd:Q.wrapperCwd===void 0?$.effectiveCwd:Q.wrapperCwd,envAssignments:Q.envAssignments});return G?A2(G):i9($,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 i9($,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)??i9($,Q)}function i9($,J){return J.wrappedByTransparent?M1(J.tokens,$.options.policy.rules):null}function SG($,J){return $?.id.startsWith("custom.")?$:k($,J)}var KI=/^\s*(?:\$\(\s*)?[({]*\s*(?:command\s+|builtin\s+)?(?:cd|pushd|popd)(?:\s|$)/,BI=new Set(["cd","chdir","pop-location","popd","push-location","pushd","set-location","sl"]);function qI($,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 KI.test($.join(" "))}function kG($,J,Q,X){if($.dialect==="powershell"){let B=UI($.words,X);if(B.kind==="none")return;if(!J||B.kind==="unknown")return null;return TG(LI(B.target),J,Q.paths)}let Y=$.words.map(h);if(!qI(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 MI(d0(J,$,Q),J,Q)?J:null}catch{return null}}function UI($,J){let Q=GI($[0])?1:0,X=$[Q];if(!HI(X,Q===1))return{kind:"none"};let Y=X.text.toLowerCase(),W=Y.split(/[\\/]/).pop()??Y;if(!BI.has(W))return{kind:"none"};if(Y!==W||W==="pop-location"||W==="popd")return{kind:"unknown"};return ZI($.slice(Q+1),J)}function GI($){return $?.provenance==="literal"&&!$.quoted&&$.raw===$.text&&($.text==="&"||$.text===".")}function HI($,J){return $?.provenance==="literal"&&(J||!$.quoted&&$.raw===$.text)}function ZI($,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 LI($){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=OI($);return l1([...X],J,Q)}function MI($,J,Q){let X=Q.realpath($),Y=Q.realpath(J);if(X===null||Y===null)return r9($)===r9(J);return r9(X)===r9(Y)}function OI($){let J=0;while(J<$.length){let Q=$[J];if(Q==="{"||Q==="("||Q==="$(")J++;else break}return $.slice(J)}var E3="TMPDIR",C3="IFS",NI=/^([A-Za-z_][A-Za-z0-9_]*)\+=/,$7=/^[A-Za-z_][A-Za-z0-9_]*$/;function uG($,J){let Q=zI($,J);return{env:$,effectiveEnvAssignments:Q,shellAssignments:new Map,exportedNames:RI($,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=FI($,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=CI($,Y);if(q.allexport!==null)J.allexport=q.allexport;if(q.keywordExport!==null)J.keywordExport=q.keywordExport;return}if(X==="unset"){let q=PI($,Y);if(q===null)return;for(let U of $.slice(q))bI(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=AI($,Y);if(q===null)return;for(let U of $.slice(q))II(J,U);return}let B=EI($,Y);if(B===null)return;for(let q of $.slice(B.operandsStart))jI(J,q,B.exports,X==="readonly"?W:void 0)}function pG($,J){if(!J.keywordExport)return J.effectiveEnvAssignments;let Q=null,X=a9(J);for(let Y of $){let W=s9(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 FI($,J){let Q=new Map,X=0;while(X<$.length){let B=$[X];if(!B)return null;let q=s9(B,a9(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=VI($,W);if(!q)return null;W=q.commandIndex,K=q.command;continue}let B=_I($,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 VI($,J){return cG($,J,(Q)=>{if(Q==="-p")return"skip";return Q==="-v"||Q==="-V"?"abort":"stop"})}function _I($,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 s9($,J,Q){return q0($)??DI($,J,Q)}function DI($,J,Q){let X=x6($,Q,J);if(X)return X;let Y=$.match(NI)?.[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 n9($){return $===E3||$===C3||CJ($)}function a9($,J){return new Map([...$.effectiveEnvAssignments??[],...$.shellAssignments,...[...J?.values()??[]].map((Q)=>[Q.name,Q.value])])}function zI($,J){let Q=[...g6,E3,C3].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 RI($,J){let Q=new Set;for(let X of $.keys())if(n9(X))Q.add(X);for(let X of J?.keys()??[])if(n9(X))Q.add(X);return Q}function xG($,J){if($.shellAssignments.set(J.name,J.value),J.name===E3||J.name===C3||$.allexport||$.exportedNames.has(J.name))e0($,J)}function e0($,J){let Q=new Map($.effectiveEnvAssignments??[]);Q.set(J.name,J.value),$.effectiveEnvAssignments=Q}function II($,J){let Q=s9(J,a9($),$.env);if(Q){$.shellAssignments.set(Q.name,Q.value),$.exportedNames.add(Q.name),e0($,Q);return}if($7.test(J))dG($,J)}function jI($,J,Q,X){let Y=s9(J,a9($),$.env);if(Y){if($.shellAssignments.set(Y.name,Y.value),Q)$.exportedNames.add(Y.name),e0($,Y);else if(Y.name===E3||Y.name===C3||$.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 bI($,J){if(!n9(J)&&!$7.test(J))return;if($.shellAssignments.set(J,""),$.exportedNames.delete(J),!n9(J)||J===E3||J===C3||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 PI($,J){return rG($,J,(Q)=>Q==="-v")}function AI($,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 EI($,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 CI($,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 SI="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.",TI=64;function W7($,J,Q,X){let Y=Q.derivedCommandWorkBudget===void 0,W=Q.parallelBudget===void 0;try{return wI($,J,{...Q,derivedCommandWorkBudget:Q.derivedCommandWorkBudget??o6(),parallelBudget:Q.parallelBudget??vB()},X)}catch(K){let B=K instanceof L2?jB:K instanceof m1&&Y?IB:K instanceof Y9&&W?wB: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 wI($,J,Q,X){if(J>=n6)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 $$(Y,J,{...Q,rootProgram:Y},K,[{effectiveCwd:B,shellGitContextState:q,literalHeredocFiles:new Map(Q.literalHeredocFiles),functionDefinitions:new Map(Q.functionDefinitions)}]).result}function $$($,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=vI($,q,U,B,H),Z=B==="&&"||B==="||",M=Z?K:void 0,O=B==="&&"?M?.success??W:B==="||"?M?.failure??W:W,V=B==="||"?M?.success??[]:[],F=B==="&&"?M?.failure??[]:[],b=Z||G4(H);if(U.kind==="function"){let C=O.flatMap((y)=>{let x=S3(y);return x.functionDefinitions.set(U.name,U.body),J7(y,[x],L,H==="&",G4(H))}),T=Q7(C,[],V,F,B,H);W=T.states,K=T.conditionalStates,B=void 0;continue}if(U.kind==="group"){let C=[],T=[];for(let x of O){let c=$$(U.body,J,Q,X,[S3(x)]);if(c.result)return c;if(C.push(...J7(x,c.states,L,H==="&",G4(H))),b)T.push(x,...L?c.states.map((V1)=>t9(x,V1)):c.states)}let y=Q7(C,T,V,F,B,H);W=y.states,K=y.conditionalStates,B=void 0;continue}if(U.kind!=="command")continue;let R=Q.trace?.flattenNested?Q.trace.currentSegmentIndex:Q.trace?.allocateSegment(),A=$.nodes[q-2],E=J$(B)&&A?.kind==="command"?mU(A)??hI(A):void 0,_=[],j=[];for(let C of O){let T=kI(U,J,Q,X,[S3(C)]);if(T.result)return{result:T.result,states:W};let y=$.dialect==="powershell"?T.states:T.states.map((x)=>t9(C,x));for(let x of y){let c=S3(x),V1=xI(U,J,Q.trace?{...Q,trace:eG(Q.trace,R)}:Q,X,c,J$(B),E);if(V1)return{result:V1,states:W};let S=tI(U,c.functionDefinitions);if(S)K0(Q.derivedCommandWorkBudget,Q$(S));let m=S?J+1>=n6?X7(U.displayText,Q,[c]):$$(S,J+1,Q,X,[c]):{result:null,states:[c]};if(m.result)return m;if(_.push(...J7(C,m.states,L,H==="&",G4(H))),b)j.push(C),j.push(...m.states.map((X1)=>L?t9(C,X1):X1))}}let P=Q7(_,j,V,F,B,H);W=P.states,K=P.conditionalStates,B=void 0}return{result:null,states:W}}function vI($,J,Q,X,Y){if(Q.kind==="group"&&Q.style==="subshell")return!0;if($.dialect==="posix"&&(J$(X)||J$(Y)))return!0;if(Y==="&")return!0;return $.dialect==="powershell"&&Q.kind==="group"&&Q.style==="brace"&&fI($,J)}function J7($,J,Q,X,Y){let W=Q?J.map((B)=>t9($,B)):[...J],K=Y?W.flatMap((B)=>T3($.literalHeredocFiles,B.literalHeredocFiles)?[B]:[{...B,literalHeredocFiles:new Map($.literalHeredocFiles)},B]):W;return X?[$,...K]:K}function t9($,J){return{...$,literalHeredocFiles:new Map(J.literalHeredocFiles)}}function fI($,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(gI(Q))return!0;return Q.source.replaceAll(/\s/g,"").toLowerCase()==="if($false)"}function J$($){return $==="|"||$==="|&"}function hI($){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:e9([...Q,...$]),failure:e9([...X,...J])},B=G4(W)?K:void 0;return{states:G4(Y)||B?e9([...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 kI($,J,Q,X,Y){let W=$.nested.map((K)=>({program:K,depth:J}));if($.dialect==="powershell"){let K=yI($);if(K){if(J+1>=n6)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,Q$(B)),W.push({program:B,depth:J+1})}}return iG(W,Q,X,Y)}function gI($){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=$$(W.program,W.depth,J,Q,[S3(B)]);if(q.result)return q;K.push(...q.states)}Y=e9(K)}return{result:null,states:Y}}function yI($){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 Q$($){return $.nodes.reduce((J,Q)=>J+(Q.kind==="command"?Q.words.length+Q.nested.reduce((X,Y)=>X+Q$(Y),0):Q.kind==="group"||Q.kind==="function"?Q$(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 xI($,J,Q,X,Y,W,K){let B=rI($);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,Jj(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 $j(U,Z)}if(q.length===1&&q[0]?.includes(" ")&&!$.dynamicExecutable){let Z=k(Y3(q[0],Q.scanWork),Q.policy),M=Z!==null&&!Q.strict&&DB($,Q.rootProgram,Q.scanWork);if(Z&&!M)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,M)=>{let O=M&&Object.hasOwn(M,"effectiveCwd")?M.effectiveCwd:Y.effectiveCwd,V=W7(Z,J+1,{...Q,derivedCommandWorkBudget:Q.derivedCommandWorkBudget,effectiveCwd:O,envAssignments:M?.envAssignments??G,literalHeredocFiles:Y.literalHeredocFiles,functionDefinitions:M?.functionDefinitions,worktreeMode:M?.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=iI($,J,Q,X??new Map,W);if(K)return K;return $H($,Q,"after-consumer",W.environment.paths),Q.literalHeredocFiles.clear(),lI($,J,Q,W.environment.paths),sI($,Q,Y,W.environment,W.trace),null}var uI=new Set([">>","<>"]);function $H($,J,Q,X){for(let W of $.redirections){if(!(Q==="before-consumer"?mI(W):uI.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 mI($){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 lI($,J,Q,X){if(J)return;let Y=$.redirections.find((W)=>W.operator==="<<"||W.operator==="<<-")?.heredoc;if(!Y?.quotedDelimiter)return;for(let W of pI($)){let K=W3(W.text,Q.effectiveCwd,X);if(!K||!AB(K))continue;if(!Q.literalHeredocFiles.has(K)&&Q.literalHeredocFiles.size>=PB)throw new m1;Q.literalHeredocFiles.set(K,Y.body)}}function pI($){let J=dI($.redirections)?.target,Q=sG(J)?[J]:[];if(k1($.words[0],"cat"))return cI($.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 cI($){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 dI($){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 rI($){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 SI;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 iI($,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(nI($,W,Q,X,Y))return null;let B=oI($,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(`
|
|
62
|
-
`):$.source,Y);return q?{...q,segment:$.displayText}:null}function oI($,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"||!S1(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",O2),Q.policy);if(!q)return null;return Q.trace?.recordSegment({type:"dangerous-text",token:K,matched:!0,reason:q.reason}),q}function nI($,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 sI($,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 S3($){return{effectiveCwd:$.effectiveCwd,shellGitContextState:mG($.shellGitContextState),literalHeredocFiles:new Map($.literalHeredocFiles),functionDefinitions:new Map($.functionDefinitions)}}function e9($){let J=[];for(let Q of $){if(!J.some((X)=>aI(X,Q)))J.push(Q);if(J.length>TI)throw new m1}return J}function aI($,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)&&eI($.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 tI($,J){let Q=D9($);return Q===void 0?void 0:J.get(Q)}function eI($,J){return $.size===J.size&&[...$].every((Q)=>J.has(Q))}function $j($,J){if(!J)return null;return{reason:J.reason,segment:$,ruleId:J.id,intent:J.intent}}function Jj($,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"}},X$=["standard","strict","paranoid"];function Qj($){return{failClosed:$==="strict"||$==="paranoid",paranoidRm:$==="paranoid",paranoidInterpreters:$==="paranoid"}}function Xj($,J){if(!J)return $;return X$.indexOf(J)>X$.indexOf($)?J:$}function Yj(){let $=G7(B1.level);if($===void 0||$==="")return;if(X$.includes($))return $;console.error(`CC Safety Net: ignored invalid ${B1.level.name}=${JSON.stringify($.slice(0,40))}. Use ${X$.join(", ")}.`);return}function Wj($){if($===void 0||$==="all")return"all";if($==="blocked")return"blocked";return"invalid"}function B7(){return Wj(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=Yj(),X=Xj(J,Q),Y=Qj(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:VB($.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"node:path";function Y$($,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 Ok,existsSync as ZP,mkdirSync as Nk,readFileSync as LP}from"node:fs";import{dirname as MP,join as OP}from"node:path";import{createRequire as eb}from"node:module";var oW={};B2(oW,{z:()=>QJ,xor:()=>EZ,xid:()=>aH,void:()=>RZ,uuidv7:()=>pH,uuidv6:()=>lH,uuidv4:()=>mH,uuid:()=>uH,util:()=>w,url:()=>cH,uppercase:()=>I4,unknown:()=>k2,union:()=>i8,undefined:()=>DZ,ulid:()=>sH,uint64:()=>VZ,uint32:()=>OZ,tuple:()=>VW,trim:()=>C4,treeifyError:()=>H$,transform:()=>n8,toUpperCase:()=>T4,toLowerCase:()=>S4,toJSONSchema:()=>s3,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:()=>j8,safeEncode:()=>R8,safeDecodeAsync:()=>b8,safeDecode:()=>I8,registry:()=>i3,regexes:()=>y1,regex:()=>z4,refine:()=>cW,record:()=>_W,readonly:()=>yW,property:()=>U8,promise:()=>lZ,prettifyError:()=>Z$,preprocess:()=>aZ,prefault:()=>TW,positive:()=>W8,pipe:()=>W6,partialRecord:()=>SZ,parseAsync:()=>O8,parse:()=>M8,overwrite:()=>Q0,optional:()=>X6,object:()=>bZ,number:()=>QW,nullish:()=>gZ,nullable:()=>Y6,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:()=>R4,looseRecord:()=>TZ,looseObject:()=>AZ,locales:()=>r3,literal:()=>hZ,length:()=>h2,lazy:()=>mW,ksuid:()=>tH,keyof:()=>jZ,jwt:()=>BZ,json:()=>sZ,iso:()=>J6,ipv6:()=>JZ,ipv4:()=>eH,intersection:()=>NW,int64:()=>FZ,int32:()=>MZ,int:()=>A8,instanceof:()=>oZ,includes:()=>j4,httpUrl:()=>dH,hostname:()=>UZ,hex:()=>GZ,hash:()=>HZ,guid:()=>xH,gte:()=>D1,gt:()=>_0,globalRegistry:()=>E1,getErrorMap:()=>$L,function:()=>pZ,fromJSONSchema:()=>iW,formatError:()=>O4,float64:()=>LZ,float32:()=>ZZ,flattenError:()=>M4,file:()=>kZ,exactOptional:()=>PW,enum:()=>o8,endsWith:()=>P4,encodeAsync:()=>D8,encode:()=>V8,emoji:()=>rH,email:()=>yH,e164:()=>KZ,discriminatedUnion:()=>CZ,describe:()=>rZ,default:()=>ob,decodeAsync:()=>z8,decode:()=>_8,date:()=>IZ,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:()=>q6,any:()=>zZ,_function:()=>pZ,_default:()=>CW,_ZodString:()=>E8,ZodXor:()=>LW,ZodXID:()=>h8,ZodVoid:()=>HW,ZodUnknown:()=>UW,ZodUnion:()=>G6,ZodUndefined:()=>WW,ZodUUID:()=>R0,ZodURL:()=>K6,ZodULID:()=>f8,ZodType:()=>g,ZodTuple:()=>FW,ZodTransform:()=>jW,ZodTemplateLiteral:()=>xW,ZodSymbol:()=>YW,ZodSuccess:()=>vW,ZodStringFormat:()=>r,ZodString:()=>x4,ZodSet:()=>zW,ZodRecord:()=>H6,ZodRealError:()=>z1,ZodReadonly:()=>gW,ZodPromise:()=>lW,ZodPrefault:()=>SW,ZodPipe:()=>t8,ZodOptional:()=>s8,ZodObject:()=>U6,ZodNumberFormat:()=>g2,ZodNumber:()=>m4,ZodNullable:()=>AW,ZodNull:()=>KW,ZodNonOptional:()=>a8,ZodNever:()=>GW,ZodNanoID:()=>T8,ZodNaN:()=>kW,ZodMap:()=>DW,ZodMAC:()=>JW,ZodLiteral:()=>RW,ZodLazy:()=>uW,ZodKSUID:()=>k8,ZodJWT:()=>c8,ZodIssueCode:()=>tZ,ZodIntersection:()=>OW,ZodISOTime:()=>e3,ZodISODuration:()=>$6,ZodISODateTime:()=>a3,ZodISODate:()=>t3,ZodIPv6:()=>y8,ZodIPv4:()=>g8,ZodGUID:()=>Q6,ZodFunction:()=>pW,ZodFirstPartyTypeKind:()=>$J,ZodFile:()=>IW,ZodExactOptional:()=>bW,ZodError:()=>gH,ZodEnum:()=>y4,ZodEmoji:()=>S8,ZodEmail:()=>C8,ZodE164:()=>p8,ZodDiscriminatedUnion:()=>MW,ZodDefault:()=>EW,ZodDate:()=>B6,ZodCustomStringFormat:()=>u4,ZodCustom:()=>Z6,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:()=>RZ,uuidv7:()=>pH,uuidv6:()=>lH,uuidv4:()=>mH,uuid:()=>uH,util:()=>w,url:()=>cH,uppercase:()=>I4,unknown:()=>k2,union:()=>i8,undefined:()=>DZ,ulid:()=>sH,uint64:()=>VZ,uint32:()=>OZ,tuple:()=>VW,trim:()=>C4,treeifyError:()=>H$,transform:()=>n8,toUpperCase:()=>T4,toLowerCase:()=>S4,toJSONSchema:()=>s3,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:()=>j8,safeEncode:()=>R8,safeDecodeAsync:()=>b8,safeDecode:()=>I8,registry:()=>i3,regexes:()=>y1,regex:()=>z4,refine:()=>cW,record:()=>_W,readonly:()=>yW,property:()=>U8,promise:()=>lZ,prettifyError:()=>Z$,preprocess:()=>aZ,prefault:()=>TW,positive:()=>W8,pipe:()=>W6,partialRecord:()=>SZ,parseAsync:()=>O8,parse:()=>M8,overwrite:()=>Q0,optional:()=>X6,object:()=>bZ,number:()=>QW,nullish:()=>gZ,nullable:()=>Y6,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:()=>R4,looseRecord:()=>TZ,looseObject:()=>AZ,locales:()=>r3,literal:()=>hZ,length:()=>h2,lazy:()=>mW,ksuid:()=>tH,keyof:()=>jZ,jwt:()=>BZ,json:()=>sZ,iso:()=>J6,ipv6:()=>JZ,ipv4:()=>eH,intersection:()=>NW,int64:()=>FZ,int32:()=>MZ,int:()=>A8,instanceof:()=>oZ,includes:()=>j4,httpUrl:()=>dH,hostname:()=>UZ,hex:()=>GZ,hash:()=>HZ,guid:()=>xH,gte:()=>D1,gt:()=>_0,globalRegistry:()=>E1,getErrorMap:()=>$L,function:()=>pZ,fromJSONSchema:()=>iW,formatError:()=>O4,float64:()=>LZ,float32:()=>ZZ,flattenError:()=>M4,file:()=>kZ,exactOptional:()=>PW,enum:()=>o8,endsWith:()=>P4,encodeAsync:()=>D8,encode:()=>V8,emoji:()=>rH,email:()=>yH,e164:()=>KZ,discriminatedUnion:()=>CZ,describe:()=>rZ,decodeAsync:()=>z8,decode:()=>_8,date:()=>IZ,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:()=>q6,any:()=>zZ,_function:()=>pZ,_default:()=>CW,_ZodString:()=>E8,ZodXor:()=>LW,ZodXID:()=>h8,ZodVoid:()=>HW,ZodUnknown:()=>UW,ZodUnion:()=>G6,ZodUndefined:()=>WW,ZodUUID:()=>R0,ZodURL:()=>K6,ZodULID:()=>f8,ZodType:()=>g,ZodTuple:()=>FW,ZodTransform:()=>jW,ZodTemplateLiteral:()=>xW,ZodSymbol:()=>YW,ZodSuccess:()=>vW,ZodStringFormat:()=>r,ZodString:()=>x4,ZodSet:()=>zW,ZodRecord:()=>H6,ZodRealError:()=>z1,ZodReadonly:()=>gW,ZodPromise:()=>lW,ZodPrefault:()=>SW,ZodPipe:()=>t8,ZodOptional:()=>s8,ZodObject:()=>U6,ZodNumberFormat:()=>g2,ZodNumber:()=>m4,ZodNullable:()=>AW,ZodNull:()=>KW,ZodNonOptional:()=>a8,ZodNever:()=>GW,ZodNanoID:()=>T8,ZodNaN:()=>kW,ZodMap:()=>DW,ZodMAC:()=>JW,ZodLiteral:()=>RW,ZodLazy:()=>uW,ZodKSUID:()=>k8,ZodJWT:()=>c8,ZodIssueCode:()=>tZ,ZodIntersection:()=>OW,ZodISOTime:()=>e3,ZodISODuration:()=>$6,ZodISODateTime:()=>a3,ZodISODate:()=>t3,ZodIPv6:()=>y8,ZodIPv4:()=>g8,ZodGUID:()=>Q6,ZodFunction:()=>pW,ZodFirstPartyTypeKind:()=>$J,ZodFile:()=>IW,ZodExactOptional:()=>bW,ZodError:()=>gH,ZodEnum:()=>y4,ZodEmoji:()=>S8,ZodEmail:()=>C8,ZodE164:()=>p8,ZodDiscriminatedUnion:()=>MW,ZodDefault:()=>EW,ZodDate:()=>B6,ZodCustomStringFormat:()=>u4,ZodCustom:()=>Z6,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:()=>s3,toDotPath:()=>UH,safeParseAsync:()=>I7,safeParse:()=>R7,safeEncodeAsync:()=>yj,safeEncode:()=>kj,safeDecodeAsync:()=>xj,safeDecode:()=>gj,registry:()=>i3,regexes:()=>y1,process:()=>n,prettifyError:()=>Z$,parseAsync:()=>M$,parse:()=>L$,meta:()=>GY,locales:()=>r3,isValidJWT:()=>EH,isValidBase64URL:()=>AH,isValidBase64:()=>yX,initializeContext:()=>h4,globalRegistry:()=>E1,globalConfig:()=>w3,formatError:()=>O4,flattenError:()=>M4,finalize:()=>g4,extractDefs:()=>k4,encodeAsync:()=>fj,encode:()=>wj,describe:()=>UY,decodeAsync:()=>hj,decode:()=>vj,createToJSONSchemaMethod:()=>ZY,createStandardJSONSchemaMethod:()=>G8,config:()=>Y1,clone:()=>N1,_xor:()=>Nb,_xid:()=>o$,_void:()=>$Y,_uuidv7:()=>l$,_uuidv6:()=>m$,_uuidv4:()=>u$,_uuid:()=>x$,_url:()=>n3,_uppercase:()=>I4,_unknown:()=>t5,_union:()=>Ob,_undefined:()=>n5,_ulid:()=>i$,_uint64:()=>i5,_uint32:()=>m5,_tuple:()=>_b,_trim:()=>C4,_transform:()=>Pb,_toUpperCase:()=>T4,_toLowerCase:()=>S4,_templateLiteral:()=>hb,_symbol:()=>o5,_superRefine:()=>qY,_success:()=>Tb,_stringbool:()=>HY,_stringFormat:()=>v4,_string:()=>E5,_startsWith:()=>b4,_slugify:()=>w4,_size:()=>v2,_set:()=>Rb,_safeParseAsync:()=>_4,_safeParse:()=>V4,_safeEncodeAsync:()=>z$,_safeEncode:()=>_$,_safeDecodeAsync:()=>R$,_safeDecode:()=>D$,_regex:()=>z4,_refine:()=>BY,_record:()=>Db,_readonly:()=>fb,_property:()=>U8,_promise:()=>gb,_positive:()=>W8,_pipe:()=>vb,_parseAsync:()=>F4,_parse:()=>N4,_overwrite:()=>Q0,_optional:()=>Ab,_number:()=>h5,_nullable:()=>Eb,_null:()=>s5,_normalize:()=>E4,_nonpositive:()=>B8,_nonoptional:()=>Sb,_nonnegative:()=>q8,_never:()=>e5,_negative:()=>K8,_nativeEnum:()=>jb,_nanoid:()=>c$,_nan:()=>XY,_multipleOf:()=>Y2,_minSize:()=>D0,_minLength:()=>g0,_min:()=>D1,_mime:()=>A4,_maxSize:()=>W2,_maxLength:()=>f2,_max:()=>x1,_map:()=>zb,_mac:()=>S5,_lte:()=>x1,_lt:()=>V0,_lowercase:()=>R4,_literal:()=>bb,_length:()=>h2,_lazy:()=>kb,_ksuid:()=>n$,_jwt:()=>X8,_isoTime:()=>v5,_isoDuration:()=>f5,_isoDateTime:()=>T5,_isoDate:()=>w5,_ipv6:()=>a$,_ipv4:()=>s$,_intersection:()=>Vb,_int64:()=>r5,_int32:()=>u5,_int:()=>g5,_includes:()=>j4,_guid:()=>o3,_gte:()=>D1,_gt:()=>_0,_float64:()=>x5,_float32:()=>y5,_file:()=>WY,_enum:()=>Ib,_endsWith:()=>P4,_encodeAsync:()=>F$,_encode:()=>O$,_emoji:()=>p$,_email:()=>y$,_e164:()=>Q8,_discriminatedUnion:()=>Fb,_default:()=>Cb,_decodeAsync:()=>V$,_decode:()=>N$,_date:()=>JY,_custom:()=>KY,_cuid2:()=>r$,_cuid:()=>d$,_coercedString:()=>C5,_coercedNumber:()=>k5,_coercedDate:()=>QY,_coercedBoolean:()=>p5,_coercedBigint:()=>d5,_cidrv6:()=>e$,_cidrv4:()=>t$,_check:()=>vH,_catch:()=>wb,_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:()=>c3,$ZodUndefined:()=>iX,$ZodUUID:()=>_X,$ZodURL:()=>zX,$ZodULID:()=>PX,$ZodType:()=>v,$ZodTuple:()=>f$,$ZodTransform:()=>H5,$ZodTemplateLiteral:()=>R5,$ZodSymbol:()=>rX,$ZodSuccess:()=>F5,$ZodStringFormat:()=>d,$ZodString:()=>w2,$ZodSet:()=>B5,$ZodRegistry:()=>A5,$ZodRecord:()=>W5,$ZodRealError:()=>A1,$ZodReadonly:()=>z5,$ZodPromise:()=>j5,$ZodPrefault:()=>O5,$ZodPipe:()=>D5,$ZodOptional:()=>h$,$ZodObjectJIT:()=>J5,$ZodObject:()=>TH,$ZodNumberFormat:()=>cX,$ZodNumber:()=>w$,$ZodNullable:()=>L5,$ZodNull:()=>oX,$ZodNonOptional:()=>N5,$ZodNever:()=>aX,$ZodNanoID:()=>IX,$ZodNaN:()=>_5,$ZodMap:()=>K5,$ZodMAC:()=>hX,$ZodLiteral:()=>U5,$ZodLazy:()=>b5,$ZodKSUID:()=>EX,$ZodJWT:()=>lX,$ZodIntersection:()=>Y5,$ZodISOTime:()=>TX,$ZodISODuration:()=>wX,$ZodISODateTime:()=>CX,$ZodISODate:()=>SX,$ZodIPv6:()=>fX,$ZodIPv4:()=>vX,$ZodGUID:()=>VX,$ZodFunction:()=>I5,$ZodFile:()=>G5,$ZodExactOptional:()=>Z5,$ZodError:()=>x3,$ZodEnum:()=>q5,$ZodEncodeError:()=>C2,$ZodEmoji:()=>RX,$ZodEmail:()=>DX,$ZodE164:()=>mX,$ZodDiscriminatedUnion:()=>X5,$ZodDefault:()=>M5,$ZodDate:()=>eX,$ZodCustomStringFormat:()=>pX,$ZodCustom:()=>P5,$ZodCodec:()=>d3,$ZodCheckUpperCase:()=>UX,$ZodCheckStringFormat:()=>D4,$ZodCheckStartsWith:()=>HX,$ZodCheckSizeEquals:()=>XX,$ZodCheckRegex:()=>BX,$ZodCheckProperty:()=>LX,$ZodCheckOverwrite:()=>OX,$ZodCheckNumberFormat:()=>e7,$ZodCheckMultipleOf:()=>t7,$ZodCheckMinSize:()=>QX,$ZodCheckMinLength:()=>WX,$ZodCheckMimeType:()=>MX,$ZodCheckMaxSize:()=>JX,$ZodCheckMaxLength:()=>YX,$ZodCheckLowerCase:()=>qX,$ZodCheckLessThan:()=>j$,$ZodCheckLengthEquals:()=>KX,$ZodCheckIncludes:()=>GX,$ZodCheckGreaterThan:()=>b$,$ZodCheckEndsWith:()=>ZX,$ZodCheckBigIntFormat:()=>$X,$ZodCheck:()=>o,$ZodCatch:()=>V5,$ZodCUID2:()=>bX,$ZodCUID:()=>jX,$ZodCIDRv6:()=>gX,$ZodCIDRv4:()=>kX,$ZodBoolean:()=>p3,$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 C2 extends Error{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}}var w3={};function Y1($){if($)Object.assign(w3,$);return w3}var w={};B2(w,{unwrapMessage:()=>v3,uint8ArrayToHex:()=>Sj,uint8ArrayToBase64url:()=>Ej,uint8ArrayToBase64:()=>KH,stringifyPrimitive:()=>G$,slugify:()=>M7,shallowClone:()=>N7,safeExtend:()=>Rj,required:()=>bj,randomString:()=>Oj,propertyKeyTypes:()=>k3,promiseAllObject:()=>Mj,primitiveTypes:()=>F7,prefixIssues:()=>g1,pick:()=>_j,partial:()=>jj,parsedType:()=>z7,optionalKeys:()=>V7,omit:()=>Dj,objectClone:()=>Hj,numKeys:()=>Nj,nullish:()=>$2,normalizeParams:()=>D,mergeDefs:()=>k0,merge:()=>Ij,jsonStringifyReplacer:()=>H4,joinValues:()=>B$,issue:()=>L4,isPlainObject:()=>Q2,isObject:()=>S2,hexToUint8Array:()=>Cj,getSizableOrigin:()=>g3,getParsedType:()=>Fj,getLengthableOrigin:()=>y3,getEnumValues:()=>f3,getElementAtPath:()=>Lj,floatSafeRemainder:()=>L7,finalizeIssue:()=>P1,extend:()=>zj,escapeRegex:()=>r1,esc:()=>q$,defineLazy:()=>u,createTransparentProxy:()=>Vj,cloneDef:()=>Zj,clone:()=>N1,cleanRegex:()=>h3,cleanEnum:()=>Pj,captureStackTrace:()=>U$,cached:()=>Z4,base64urlToUint8Array:()=>Aj,base64ToUint8Array:()=>WH,assignProp:()=>J2,assertNotEqual:()=>Bj,assertNever:()=>Uj,assertIs:()=>qj,assertEqual:()=>Kj,assert:()=>Gj,allowsEval:()=>O7,aborted:()=>X2,NUMBER_FORMAT_RANGES:()=>_7,Class:()=>BH,BIGINT_FORMAT_RANGES:()=>D7});function Kj($){return $}function Bj($){return $}function qj($){}function Uj($){throw Error("Unexpected value in exhaustive check")}function Gj($){}function f3($){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 h3($){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 Hj($){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 Zj($){return k0($._zod.def)}function Lj($,J){if(!J)return $;return J.reduce((Q,X)=>Q?.[X],$)}function Mj($){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 Oj($=10){let Q="";for(let X=0;X<$;X++)Q+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Q}function q$($){return JSON.stringify($)}function M7($){return $.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var U$="captureStackTrace"in Error?Error.captureStackTrace:(...$)=>{};function S2($){return typeof $==="object"&&$!==null&&!Array.isArray($)}var O7=Z4(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch($){return!1}});function Q2($){if(S2($)===!1)return!1;let J=$.constructor;if(J===void 0)return!0;if(typeof J!=="function")return!0;let Q=J.prototype;if(S2(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 Nj($){let J=0;for(let Q in $)if(Object.prototype.hasOwnProperty.call($,Q))J++;return J}var Fj=($)=>{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}`)}},k3=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 Vj($){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 _j($,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 Dj($,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 zj($,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 Rj($,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 Ij($,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 jj($,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 bj($,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 v3($){return typeof $==="string"?$:$?.message}function P1($,J,Q){let X={...$,path:$.path??[]};if(!$.message){let Y=v3($.inst?._zod.def?.error?.($))??v3(J?.error?.($))??v3(Q.customError?.($))??v3(Q.localeError?.($))??"Invalid input";X.message=Y}if(delete X.inst,delete X.continue,!J?.reportInput)delete X.input;return X}function g3($){if($ instanceof Set)return"set";if($ instanceof Map)return"map";if($ instanceof File)return"file";return"unknown"}function y3($){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 Pj($){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 Aj($){let J=$.replace(/-/g,"+").replace(/_/g,"/"),Q="=".repeat((4-J.length%4)%4);return WH(J+Q)}function Ej($){return KH($).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Cj($){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 Sj($){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})},x3=N("$ZodError",qH),A1=N("$ZodError",qH,{Parent:Error});function M4($,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 O4($,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(`✖ ${X.message}`),X.path?.length)J.push(` → at ${UH(X.path)}`);return J.join(`
|
|
63
|
-
`)}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},M$=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($??x3)(W.issues.map((K)=>P1(K,Y,Y1())))}:{success:!0,data:W.value}},R7=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}},I7=_4(A1),O$=($)=>(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return N4($)(J,Q,Y)},wj=O$(A1),N$=($)=>(J,Q,X)=>{return N4($)(J,Q,X)},vj=N$(A1),F$=($)=>async(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return F4($)(J,Q,Y)},fj=F$(A1),V$=($)=>async(J,Q,X)=>{return F4($)(J,Q,X)},hj=V$(A1),_$=($)=>(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return V4($)(J,Q,Y)},kj=_$(A1),D$=($)=>(J,Q,X)=>{return V4($)(J,Q,X)},gj=D$(A1),z$=($)=>async(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return _4($)(J,Q,Y)},yj=z$(A1),R$=($)=>async(J,Q,X)=>{return _4($)(J,Q,X)},xj=R$(A1);var y1={};B2(y1,{xid:()=>A7,uuid7:()=>pj,uuid6:()=>lj,uuid4:()=>mj,uuid:()=>T2,uppercase:()=>a7,unicodeEmail:()=>GH,undefined:()=>n7,ulid:()=>P7,time:()=>l7,string:()=>c7,sha512_hex:()=>Gb,sha512_base64url:()=>Zb,sha512_base64:()=>Hb,sha384_hex:()=>Bb,sha384_base64url:()=>Ub,sha384_base64:()=>qb,sha256_hex:()=>Yb,sha256_base64url:()=>Kb,sha256_base64:()=>Wb,sha1_hex:()=>Jb,sha1_base64url:()=>Xb,sha1_base64:()=>Qb,rfc5322Email:()=>dj,number:()=>u3,null:()=>o7,nanoid:()=>C7,md5_hex:()=>tj,md5_base64url:()=>$b,md5_base64:()=>ej,mac:()=>k7,lowercase:()=>s7,ksuid:()=>E7,ipv6:()=>h7,ipv4:()=>f7,integer:()=>r7,idnEmail:()=>rj,html5Email:()=>cj,hostname:()=>nj,hex:()=>aj,guid:()=>T7,extendedDuration:()=>uj,emoji:()=>v7,email:()=>w7,e164:()=>u7,duration:()=>S7,domain:()=>sj,datetime:()=>p7,date:()=>m7,cuid2:()=>b7,cuid:()=>j7,cidrv6:()=>y7,cidrv4:()=>g7,browserEmail:()=>ij,boolean:()=>i7,bigint:()=>d7,base64url:()=>I$,base64:()=>x7});var j7=/^[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}$/,C7=/^[a-zA-Z0-9_-]{21}$/,S7=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,uj=/^[-+]?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})$`)},mj=T2(4),lj=T2(6),pj=T2(7),w7=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,cj=/^[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])?)*$/,dj=/^(([^<>()\[\]\\.,;:\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,rj=GH,ij=/^[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])?)*$/,oj="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function v7(){return new RegExp(oj,"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}=))?$/,I$=/^[A-Za-z0-9_-]*$/,nj=/^(?=.{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])?)*\.?$/,sj=/^([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+$/,u3=/^-?\d+(?:\.\d+)?$/,i7=/^(?:true|false)$/i,o7=/^null$/i;var n7=/^undefined$/i;var s7=/^[^A-Z]*$/,a7=/^[^a-z]*$/,aj=/^[0-9a-fA-F]*$/;function m3($,J){return new RegExp(`^[A-Za-z0-9+/]{${$}}${J}$`)}function l3($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var tj=/^[0-9a-fA-F]{32}$/,ej=m3(22,"=="),$b=l3(22),Jb=/^[0-9a-fA-F]{40}$/,Qb=m3(27,"="),Xb=l3(27),Yb=/^[0-9a-fA-F]{64}$/,Wb=m3(43,"="),Kb=l3(43),Bb=/^[0-9a-fA-F]{96}$/,qb=m3(64,""),Ub=l3(64),Gb=/^[0-9a-fA-F]{128}$/,Hb=m3(86,"=="),Zb=l3(86);var o=N("$ZodCheck",($,J)=>{var Q;$._zod??($._zod={}),$._zod.def=J,(Q=$._zod).onattach??(Q.onattach=[])}),MH={number:"number",bigint:"bigint",object:"date"},j$=N("$ZodCheckLessThan",($,J)=>{o.init($,J);let Q=MH[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=MH[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:g3(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:g3(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:g3(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=y3(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=y3(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=y3(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}}),MX=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})}}),OX=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(`
|
|
61
|
+
`?$.trim().split(/\s+/).filter(Boolean):$.split(J).filter(Boolean)}function u9($){if(!$)return!0;return $.provenance==="unknown"?!/[$`]/.test(h($)):$.provenance==="literal"}function I3($){return $?h($):""}function tz($){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;XR(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(j3(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=ez($,Q,J);if(W===null)return!1;if(W===-1)return!0;return cU($.slice(W),J)}function ez($,J,Q){let X=i($[J]?.text??"");if(X==="command")return $R($,J+1);if(X==="exec")return JR($,J+1);if(X==="env")return QR($,J+1,Q);return null}function $R($,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 JR($,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 QR($,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 j3($[X+1],Q)?-1:X+2;if(W.startsWith("-S")||W.startsWith("--split-string="))return j3(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 XR($,J){if(!$.words.every((Q)=>q0(Q.text)!==null))return;for(let Q of $.words){let X=q0(Q.text);if(!X)continue;if(j3(Q,J))J.add(X.name)}}function j3($,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&&(cz.test(Y)||J.has(Y))}))}function xU($,J){return!!$&&($.parts.some((Q)=>Q.provenance!=="literal"&&Q.provenance!=="variable")||j3($,J))}var YR=new Set(["-c","-C","--git-dir","--work-tree","--namespace","--config-env"]),WR=new Set(["-c","-H","-l","--config","--context","--host","--log-level","--tlscacert","--tlscert","--tlskey"]),KR=new Set;function dU($){if($==="git")return YR;if($==="docker")return WR;return KR}function M1($,J){if($.length===0||J.length===0)return null;let Q=i($[0]??""),X=v1($);for(let Y of J){if(!BR(Q,Y.command))continue;if(!qR(Q,$,Y.subcommand))continue;if(GR($,new Set(Y.block_args),X))return{id:`custom.${Y.name}`,reason:`[${Y.name}] ${Y.reason}`,intent:Y.intent??"manual_only"}}return null}function BR($,J){return $===i(J)}function qR($,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("=")&&UR($,W,Q,X))return!0;continue}return K===Q}return!1}function UR($,J,Q,X){let Y=$[J+1];if(!Y||Y.startsWith("-"))return!1;return rU($,J+2,Q,X)}function GR($,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 O0(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=M0(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(f9($,(W)=>J.analyzeNested?J.analyzeNested(W,{effectiveCwd:J.cwd,envAssignments:J.envAssignments}):null),J.policy)??M1($,J.policy?.rules??[])??O0(Q,J);if(S1(Y)){let W=t6($);if(!W)return O0(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(J9(Y,W))return O0(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",O2),J.policy)??O0(Q,J);return O0(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?O0(Q,J):null)??(W?HR(Q,J):null)}if(Y==="find")return k9(p($),{...J,derivedCommandWorkBudget:J.derivedCommandWorkBudget,analyzeTokens:(W,K)=>t0(W,{...J,cwd:K??void 0,derivedCommandWorkBudget:J.derivedCommandWorkBudget},Q)})??M1($,J.policy?.rules??[])??O0(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)??M1($,J.policy?.rules??[])??O0(Q,J);return M1($,J.policy?.rules??[])??O0(Q,J)}function B4($,J){return $.shellDynamicMatch?k($.shellDynamicMatch,J.policy):null}function O0($,J){return $.dynamicSourceInput&&$.dynamicSourceMatch?k($.dynamicSourceMatch,J.policy):null}function HR($,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.",ZR="__CC_SAFETY_NET_XARGS_INPUT__",m9="__CC_SAFETY_NET_XARGS_INTERPRETER_INPUT__",l9="rm",LR=/(?:^|[;&|]\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,MR=/(?:^|[;&|]\s*)\s*eval\b((?:\\.|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\\'";&|\r\n])*)/g,OR=/\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)(?:[^}]*)\})/g,NR=/^(?:[0-9]+|[@*])$/,FR=new Set(["branch","checkout","clean","push","reset","restore","switch","tag"]);function nU($,J){let Q=$.map(h),{childStart:X,replacementToken:Y}=j2(Q),W=Q.slice(X),K=z("xargs.shell-dynamic",mQ);if(_R(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=VR(q,Y,J.policy?.rules??[]);if(Z)return Z;if(B.head==="git"){let O=Y===null?[...q,ZR]:q,V=Y!==null&&(q.some((b)=>b.includes(Y))||Array.from(B.envAssignments.values()).some((b)=>b.includes(Y))),F=t0(O,{...J,cwd:B.cwd,envAssignments:B.envAssignments,worktreeMode:Y===null||V?!1:J.worktreeMode});if(F)return F}let M=M1(q,J.policy?.rules??[]);if(M)return M}return null}function VR($,J,Q){if(Q.length===0)return null;if(J===null){for(let Y of Q){let W=M1([...$,...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=M1($.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&&DR($,Q))return!0;let B=Z0($);if(!B){let q=M0(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 zR(B,Q,X)}if(S1(J))return iU($,Q,$9,TB(J));if(h1.has(J))return iU($,Q,RQ,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 RR($,Q,W,K);if(J==="git"){let B=J0($);return Q===null?B.subcommand===null:(B.subcommand?.includes(Q)??!1)||B.subcommand!==null&&FR.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([...$,m9]).sources.some((q)=>q.value===m9);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}${m9}`]:[],...q.valueForm==="equals-or-separate"?[`${q.selector}=${m9}`]:[]]),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 _R($,J,Q){if($.length===0||($[0]??"").toLowerCase()==="command")return!1;let X=new Set(Array.from($0($,Q),(W)=>W.head)),Y=J===null?[...$,l9]:$.map((W,K)=>K===0?W:W.replaceAll(J,l9));return Array.from($0(Y,Q)).some((W)=>W.head===l9&&!X.has(l9))}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 DR($,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 zR($,J,Q){let X=new Set(J===null?[]:Array.from(Q).filter(([,Y])=>Y.includes(J)).map(([Y])=>Y));for(let Y of $.matchAll(LR))if(oU(Y,X))return!0;for(let Y of $.matchAll(MR))for(let W of(Y[1]??"").matchAll(OR))if(oU(W,X))return!0;return xQ($,X)}function oU($,J){let Q=$[1]??$[2];return Q!==void 0&&(NR.test(Q)||J.has(Q))}function RR($,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 j2($){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.",jR="parallel without a command reads executable commands from dynamic input. Use an explicit command template or ::: arguments instead.",bR="parallel command construction cannot be verified safely. Use the default ::: separator, literal arguments, and built-in replacement strings.",PR=/\{[^{}\s]*\}/,qG=/\{\}|\{-?\d+\}/g,AR=new Set(["branch","checkout","clean","merge","push","rebase","reflog","reset","restore","stash","switch","tag","worktree"]),ER=["e","f","source","file","-e","-f","--source","--file"],CR=["c","e","eval","m","r","Mmodule","import","require","-c","-e","-m","-r","--eval","--import","--require"],SR=new Set(["-L","-d","-n","--delay","--delimiter","--header","--joblog","--jl","--max-args","--max-lines","--nice","--results","--result","--res","--tagstring","--timeout"]),TR=new Set(["--arg-file","--colsep","--rpl","--arg-sep","--arg-file-sep"]),$G=new Set(["-S","--sshlogin","--slf","--sshloginfile"]),wR=new Set(["--workdir","--wd"]),JG="__CC_SAFETY_NET_PARALLEL_SOURCE__",vR=new TextEncoder,c9=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 O=P2(J);if(O)return O}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 O=P2(J);if(O)return O}if(U){let O=mR(J);if(O)return O}if(H!==void 0&&B){let O=P2(J);if(O)return O}let Z=rR(H,J.cwd,J.environment.paths);if(Z===null){let O=P2(J);if(O)return O}let M=B?{...J,cwd:void 0,originalCwd:void 0}:Z===null||Z===void 0||Z===J.cwd?J:{...J,cwd:Z};if(L){let O=[...$0(W,M)];if((O.length===0?dQ(q,J.envAssignments,new Map).values:O.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 O=K.map((F)=>F[0]??"");T1(J.budget,cQ(O));let V=FG(M.envAssignments,M.cwd,B);return _1(O,(F)=>J.analyzeNested(F,V))}return _1($0(W,M),(O)=>fR(O,Y,J,M))}function fR($,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,M=B&&Z,O=FG($.envAssignments,$.wrapperCwd,K||M);if(H1.has($.head)){let F=()=>{if(!W||Y.length===0)return null;return T1(Q.budget,p9(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,(C)=>Q.analyzeNested(N0(b,C),O))}if(s(b)){if(Y.length>0)return T1(Q.budget,KG(b,Y)),_1(Y,(T)=>Q.analyzeNested(N0(b,T),O));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 C=P?t0(P,G,{dynamicInput:B,shellDynamicMatch:z("parallel.shell-dynamic",P3),rmDynamicMatch:z("parallel.rm-recursive-force-dynamic",b3)}):null;if(C)return C;return Q.analyzeNested(b,O)}let A=!L&&(!W||Y.length>0)?(Y.length>0?Y:[void 0]).map((P)=>x9(p(P===void 0?U:W?U.map((C)=>N0(C,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,O));T1(Q.budget,pR(YG(b),lR(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 j=Q.analyzeNested(b,O);if(j)return j;if(!_){let P=BG(H,Y,X,K);if(P)return P}if(Z)return b2(Q);return null}let R=M0(p(U));if(R.kind==="dynamic"||R.kind==="literal"&&s(R.source))return b2(Q)??F();if(R.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((j)=>j[0]===void 0?[]:[j[0]]);return T1(Q.budget,cQ(_)),_1(_,(j)=>Q.analyzeNested(j,O))}if(Z||B)return b2(Q)??F();return null}if($.head==="rm"&&v0(U)){if(W&&Y.length>0)return T1(Q.budget,p9(U,Y,"rm")),_1(Y,(b)=>pQ(U.map((R)=>rQ(R,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,R)=>{if(R===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?p9(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],R=z("parallel.shell-dynamic",P3),A=B&&$.head==="find"?uR(b,X):null,E=HG(b,B,Q.policy?.rules??[],Q.budget)??A?.customResult??null,_=i($.head),j=B&&(_==="rm"&&iQ(b)||_==="xargs"&&ZG(b)||A?.rmOptions===!0),P=B&&(j||A?.executedSource===!0||A===null&&GG(b,_)),C=t0(b,{...G,worktreeMode:K||B||Z?!1:Q.worktreeMode},{dynamicInput:B||Z,dynamicRmInput:j,dynamicSourceInput:E!==null||P,shellDynamicMatch:R,dynamicSourceMatch:R,rmDynamicMatch:z("parallel.rm-recursive-force-dynamic",b3)});if(P){let T=k(R,Q.policy);if(T)return T}return C??E??M1(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 gR($);if(J==="git")return hR($);if(J==="find")return!0;if(h1.has(J))return QG($,ER,V3);if(S1(J))return QG($,CR,e6);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 hR($){if(kR($))return!0;let J=J0($);if(J.subcommand===null||s(J.subcommand))return!0;if(!AR.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 kR($){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 gR($){if(c1($))return!1;let J=Z0($);if(J!==null)return s(J);let Q=M0(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,yR($,Y,W)),!W)return _1(Y,(K)=>M1([...$,...K.subcommand?[K.subcommand]:[],...K.block_args],[K]));return _1(Y,(K)=>{let B=new Set([K.subcommand,...K.block_args].flatMap((q)=>q?xR($,q):[]));return _1(B,(q)=>M1($.map((U)=>N0(U,[q])),[K]))})}function yR($,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 xR($,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 uR($,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(j2($).childStart);return i(J[0]??"")==="rm"&&iQ(J)}function d9($,J){return(Q)=>k(z($,J),Q.policy)}var b2=d9("parallel.shell-dynamic",P3),mR=d9("parallel.command-stream-dynamic",jR),P2=d9("parallel.command-stream-dynamic",bR),XG=d9("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 p9([$],J,"generic")}function p9($,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)=>OG(q,Q))),W=b1(Y.occurrences,J.length,f.maxPlaceholderReplacements);if(W>f.maxPlaceholderReplacements)return{childAnalyses:J.length,derivedTokens:X,placeholderReplacements:W};if(MG(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 MG($,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 lR($,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)=>cR(OG(G.value,"generic"),G.frequency))),q=b1(B.occurrences,X,f.maxPlaceholderReplacements);if(q>f.maxPlaceholderReplacements)return{childAnalyses:W,placeholderReplacements:q};if(MG(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 pR($,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 OG($,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))],c9),X++,W=K.index+K[0].length}return{occurrences:X,fixedBytes:X===0?q4($):U1([Y,q4($.slice(W))],c9)}}function cR($,J){return{occurrences:b1($.occurrences,J,f.maxPlaceholderReplacements),fixedBytes:b1($.fixedBytes,J,c9)}}function NG($){return{occurrences:U1($.map((J)=>J.occurrences),f.maxPlaceholderReplacements),fixedBytes:U1($.map((J)=>J.fixedBytes),c9)}}function U4($,J=f.maxDerivedBytes){return U1($.map(q4),J)}function q4($){return vR.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()),dR(X)}function dR($){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 PR.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((O)=>O==="::::"||O==="::::+"||O===":::+"),G=[];while(J<$.length){let O=$[J];if(O===void 0)break;if(O===":::"){Y=J;break}if(O==="--"){let A=bQ($,J+1);Q.push(...A.templateTokens),X=J+1,Y=A.markerIndex;break}if(!O.startsWith("-")){let A=bQ($,J);Q.push(...A.templateTokens),X=J,Y=A.markerIndex;break}let V=$[J+1],F=O.indexOf("="),b=F===-1?O:O.slice(0,F),R=F===-1?void 0:O.slice(F+1);if(O==="--dry-run"){B=!0,J++;continue}if(O==="-I"||O.startsWith("-I")&&O.length>2){U||=(O==="-I"?V:O.slice(2))!=="{}",J+=O==="-I"?2:1;continue}if(O==="--replace"||O==="-i"){U=!0,J+=2;continue}if(b==="--replace"||O.startsWith("-i")&&O.length>2){let A=b==="--replace"?R:O.slice(2);U||=A!==""&&A!=="{}",J++;continue}if(O==="-a"||TR.has(b)){U=!0,J+=R===void 0?2:1;continue}if(O==="--pipe"||O==="--pipepart"){K=!0,J++;continue}if(b==="--env"){G.push(...oR(R??V)),J+=R===void 0?2:1;continue}if($G.has(b)||O.startsWith("-S")&&O.length>2){W=!0,J+=$G.has(O)?2:1;continue}if(wR.has(b)){let A=R??V;if(A===void 0||A===":::"||A==="--"){U=!0,J++;continue}q=A,U||=R!==void 0&&A==="",J+=R===void 0?2:1;continue}if(O.startsWith("-j")&&O.length>2&&/^\d+$/.test(O.slice(2))){J++;continue}if(O.startsWith("--")&&R!==void 0){J++;continue}if(SR.has(O)){if(V===void 0||V===":::"||V==="--"){U=!0,J++;continue}J+=2;continue}J+=O==="-j"||O==="--jobs"?2:1}U||=Q.some(B?oQ:_G);let H=[];if(Y!==-1){let O=[];for(let V=Y+1;V<$.length;V++){let F=$[V];if(F===":::"){H.push(O),O=[];continue}if(F!==void 0)O.push(F)}H.push(O)}let L=iR(H),Z=Q.some(s),M=Q.length===0&&Y===-1;return{template:Q,jobs:L,childStart:X,templateHasPlaceholder:Z,runsRemotely:W,usesStdin:K||Y===-1,envNames:G,readsCommandsFromInput:M,unsupported:U,workdir:q,dryRun:B}}function rR($,J,Q){if($===void 0)return;if($==="..."||/[{}$`*?~[]/.test($))return null;if(!J&&!IR($))return null;try{return d0(J??$,$,Q)}catch{return null}}function iR($){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 oR($){return($??"").split(",").map((J)=>J.trim()).filter(Boolean)}function RG($){return zG($).childStart}var nR="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.",sR=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 jG($,J,Q,X=!1,Y){let W=JQ($,J)&&q1(Y,"shell.dynamic-executable",X)?z("shell.dynamic-executable",nR):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=tR(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&&sR.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)&&eR(J)?k(z("shell.dynamic-structure",nQ),Y):null;if(K==="xargs")return IG($,J.slice(j2(J.map(h)).childStart),"xargs",Q,X,Y);if(K==="parallel")return IG($,J.slice(RG(J.map(h))),"parallel",Q,X,Y);return null}function IG($,J,Q,X,Y,W){if(J.length===0)return null;let K=aR(J,X);if(JQ($,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 aR($,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 tR($){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 eR($){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!k6(J[Q.tokenIndex],Q.value)})}var $I="dd writing to a /dev device can destroy a disk or partition. Run device writes manually after confirming the target.",JI="mkfs formatting a /dev device erases everything on it. Run the format manually after confirming the target.",QI="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",$I);if(($==="mkfs"||$.startsWith("mkfs."))&&Q.some((X)=>X.startsWith("/dev/")))return z("mkfs.device",JI);if($==="shred"&&Q.length>0)return z("shred.target",QI);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:($)=>k9($.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=(S)=>S.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=K9($);if(U.envAssignments.size>0)X?.recordSegment({type:"env-strip",input:W($),envVars:Object.fromEntries([...U.envAssignments.keys()].map((S)=>[S,"<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 S=W(U.words);X.recordSegment({type:"leading-tokens-stripped",input:S,removed:S.slice(0,S.length-H.length),output:L})}let M=new Map([...Q.envAssignments??[],...U.envAssignments,...G.envAssignments]),O=L[0];if(!O)return null;if(_3(O))throw new m1;let V=i(O),F=G.cwd===null?void 0:G.cwd??B,b=G.cwd===null?void 0:q,R=G.cwd===void 0?Q.effectiveCwd:G.cwd,A=!K3(M,Q.environment),E=jG(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 _=h9(L,Q.policy);if(_){for(let S of[_.childIndex,..._.alternativeChildIndices]){CG(Z.wrapperNormalizationBudget);let m=H.slice(S);X?.recordSegment({type:"transparent-wrapper",wrapper:_.wrapper,output:W(m)});let X1=A3(m,J,{...Z,effectiveCwd:R,envAssignments:M});if(X1)return X1}return null}let j=V==="eval"?W4(H):V==="trap"?lU(H):void 0;if(j?.kind==="dynamic")return d1(X);if(j?.kind==="literal"){X?.recordSegment({type:"recurse",reason:V==="eval"?"shell-eval":"shell-trap",innerCommand:j.source,depth:J+1});let S=Q.analyzeNested(j.source,{effectiveCwd:R,envAssignments:M,functionDefinitions:Q.functionDefinitions});if(S)return S}if(hG(O,V)){if(c1(L))return null;let S=XI(L,M,R,Q,X,J);if(S)return S;let m=Z0(L);if(m){let m2=x9(H,m);if(m2.kind==="dynamic")return d1(X);let GJ=m2.kind==="literal"?m2.source:m,LK=YI(GJ);X?.recordSegment({type:"shell-wrapper",wrapper:V,innerCommand:LK}),X?.recordSegment({type:"recurse",reason:"shell-wrapper",innerCommand:LK,depth:J+1});let MK=Q.analyzeNested(GJ,{effectiveCwd:R,envAssignments:M});if(MK)return MK;return K4(GJ)?d1(X):null}let X1=M0(H);if(X1.kind==="dynamic")return d1(X);if(X1.kind==="literal")return o9(X1.source,R,M,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:R,envAssignments:M})}if(V==="source"||V==="."){let S=L[1]==="-p"?2:null;if(S!==null){let m2=Q.commandView?H[S]:void 0;if(!m2)return null;if(m2.provenance!=="literal")return d1(X)}let m=S===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 o9(Z1.text,R,M,Q,X,J)}if(h1.has(V)){if(Q.strict&&tQ(V3(L),H))return d1(X);let S=f9(L,(X1)=>A2(Q.analyzeNested(X1,{effectiveCwd:R,envAssignments:M}))),m=k(S,Q.policy);if(m)return X?.recordSegment({type:"rule-check",ruleModule:"awk",ruleFunction:"analyzeAwkSystemCalls",matched:!0,reason:m.reason}),h0(m)}if(S1(V)){if(Q.strict&&tQ(e6(L),H))return d1(X);let S=t6(L);if(S){let m=q1(Q.policy,"interpreter.one-liner-paranoid",!!Q.paranoidInterpreters);if(X?.recordSegment({type:"interpreter",interpreter:V,codeArg:S,paranoidBlocked:m}),m){let Z1=k(z("interpreter.one-liner-paranoid",n2),Q.policy);if(Z1)return h0(Z1)}if(J9(V,S))return null;X?.recordSegment({type:"recurse",reason:"interpreter",innerCommand:S,depth:J+1});let X1=Q.analyzeNested(S,{effectiveCwd:R,envAssignments:M});if(X1&&X1.ruleId!=="raw-text.dangerous-command"&&(X1.reason!==r0||$4(S)))return X1;if(s2(S,Q.scanWork)){let Z1=k(z("interpreter.dangerous-command",O2),Q.policy);if(Z1)return X?.recordSegment({type:"dangerous-text",token:S,matched:!0,reason:O2}),h0(Z1)}X=void 0}}if(V==="busybox"&&L.length>1)return CG(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:R,envAssignments:M});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 C=X===Z.trace?Z:{...Z,trace:X},T={words:H,head:V,cwd:F,originalCwd:b,envAssignments:M,allowTmpdirVar:A,dynamicArguments:G.words.some((S)=>S.provenance==="command-substitution"),depth:J,effectiveCwd:R,options:C,analyzeChildTokens:(S,m)=>A2(A3(p(S),J+1,{...C,commandView:void 0,effectiveCwd:m,envAssignments:M}))??M1(S,C.policy.rules)},y=vG(V);if(V==="rm"||V==="xargs"||V==="parallel")X?.recordSegment({type:"tmpdir-check",tmpdirValue:M.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=SG(x?x.match:y?.(T)??null,Q.policy);if(X)WI(T,c,x?.relaxation??null);if(c)return h0(c);let V1=y!==void 0;if(!V1)if(!s6.has(V)){let S=X?[]:void 0;for(let m=1;m<L.length;m++){let X1=L[m];if(!X1)continue;S?.push(X1);let Z1=SG(KI(T,L,m),Q.policy);if(Z1)return X?.recordSegment({type:"fallback-scan",tokensScanned:S??[],embeddedCommandFound:i(X1)}),h0(Z1)}X?.recordSegment({type:"fallback-scan",tokensScanned:S??[]})}else X?.recordSegment({type:"fallback-scan",tokensScanned:[]});else X?.recordSegment({type:"fallback-scan",tokensScanned:[]});if(J===0||!V1){let S=M1(L,Q.policy.rules);if(X?.recordSegment({type:"custom-rules-check",rulesChecked:Q.policy.rules.length>0,matched:!!S,reason:S?.reason}),S)return h0(S)}else X?.recordSegment({type:"custom-rules-check",rulesChecked:!1,matched:!1});return null}function XI($,J,Q,X,Y,W){let K=gU($);if(K.argvSource?.kind==="absent")return d1(Y);if(K.argvSourceApplies&&K.argvSource){let q=o9(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 o9(B,Q,J,X,Y,W,!0)}function o9($,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 YI($){let J=$[0];return $.length>=2&&(J==='"'||J==="'")&&$.at(-1)===J?$.slice(1,-1):$}function WI($,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 CG($){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 KI($,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=BI($,Q,Y);if(W)return W}return null}function BI($,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(M0(p(q)).kind==="dynamic")return fG();return i9($,Q)}let G=$.options.analyzeNested(U,{effectiveCwd:Q.wrapperCwd===void 0?$.effectiveCwd:Q.wrapperCwd,envAssignments:Q.envAssignments});return G?A2(G):i9($,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 i9($,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)??i9($,Q)}function i9($,J){return J.wrappedByTransparent?M1(J.tokens,$.options.policy.rules):null}function SG($,J){return $?.id.startsWith("custom.")?$:k($,J)}var qI=/^\s*(?:\$\(\s*)?[({]*\s*(?:command\s+|builtin\s+)?(?:cd|pushd|popd)(?:\s|$)/,UI=new Set(["cd","chdir","pop-location","popd","push-location","pushd","set-location","sl"]);function GI($,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 qI.test($.join(" "))}function kG($,J,Q,X){if($.dialect==="powershell"){let B=HI($.words,X);if(B.kind==="none")return;if(!J||B.kind==="unknown")return null;return TG(OI(B.target),J,Q.paths)}let Y=$.words.map(h);if(!GI(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 NI(d0(J,$,Q),J,Q)?J:null}catch{return null}}function HI($,J){let Q=ZI($[0])?1:0,X=$[Q];if(!LI(X,Q===1))return{kind:"none"};let Y=X.text.toLowerCase(),W=Y.split(/[\\/]/).pop()??Y;if(!UI.has(W))return{kind:"none"};if(Y!==W||W==="pop-location"||W==="popd")return{kind:"unknown"};return MI($.slice(Q+1),J)}function ZI($){return $?.provenance==="literal"&&!$.quoted&&$.raw===$.text&&($.text==="&"||$.text===".")}function LI($,J){return $?.provenance==="literal"&&(J||!$.quoted&&$.raw===$.text)}function MI($,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 OI($){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=FI($);return l1([...X],J,Q)}function NI($,J,Q){let X=Q.realpath($),Y=Q.realpath(J);if(X===null||Y===null)return r9($)===r9(J);return r9(X)===r9(Y)}function FI($){let J=0;while(J<$.length){let Q=$[J];if(Q==="{"||Q==="("||Q==="$(")J++;else break}return $.slice(J)}var E3="TMPDIR",C3="IFS",VI=/^([A-Za-z_][A-Za-z0-9_]*)\+=/,$7=/^[A-Za-z_][A-Za-z0-9_]*$/;function uG($,J){let Q=II($,J);return{env:$,effectiveEnvAssignments:Q,shellAssignments:new Map,exportedNames:jI($,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=_I($,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=TI($,Y);if(q.allexport!==null)J.allexport=q.allexport;if(q.keywordExport!==null)J.keywordExport=q.keywordExport;return}if(X==="unset"){let q=EI($,Y);if(q===null)return;for(let U of $.slice(q))AI(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=CI($,Y);if(q===null)return;for(let U of $.slice(q))bI(J,U);return}let B=SI($,Y);if(B===null)return;for(let q of $.slice(B.operandsStart))PI(J,q,B.exports,X==="readonly"?W:void 0)}function pG($,J){if(!J.keywordExport)return J.effectiveEnvAssignments;let Q=null,X=a9(J);for(let Y of $){let W=s9(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 _I($,J){let Q=new Map,X=0;while(X<$.length){let B=$[X];if(!B)return null;let q=s9(B,a9(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=DI($,W);if(!q)return null;W=q.commandIndex,K=q.command;continue}let B=zI($,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 DI($,J){return cG($,J,(Q)=>{if(Q==="-p")return"skip";return Q==="-v"||Q==="-V"?"abort":"stop"})}function zI($,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 s9($,J,Q){return q0($)??RI($,J,Q)}function RI($,J,Q){let X=x6($,Q,J);if(X)return X;let Y=$.match(VI)?.[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 n9($){return $===E3||$===C3||CJ($)}function a9($,J){return new Map([...$.effectiveEnvAssignments??[],...$.shellAssignments,...[...J?.values()??[]].map((Q)=>[Q.name,Q.value])])}function II($,J){let Q=[...g6,E3,C3].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 jI($,J){let Q=new Set;for(let X of $.keys())if(n9(X))Q.add(X);for(let X of J?.keys()??[])if(n9(X))Q.add(X);return Q}function xG($,J){if($.shellAssignments.set(J.name,J.value),J.name===E3||J.name===C3||$.allexport||$.exportedNames.has(J.name))e0($,J)}function e0($,J){let Q=new Map($.effectiveEnvAssignments??[]);Q.set(J.name,J.value),$.effectiveEnvAssignments=Q}function bI($,J){let Q=s9(J,a9($),$.env);if(Q){$.shellAssignments.set(Q.name,Q.value),$.exportedNames.add(Q.name),e0($,Q);return}if($7.test(J))dG($,J)}function PI($,J,Q,X){let Y=s9(J,a9($),$.env);if(Y){if($.shellAssignments.set(Y.name,Y.value),Q)$.exportedNames.add(Y.name),e0($,Y);else if(Y.name===E3||Y.name===C3||$.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 AI($,J){if(!n9(J)&&!$7.test(J))return;if($.shellAssignments.set(J,""),$.exportedNames.delete(J),!n9(J)||J===E3||J===C3||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 EI($,J){return rG($,J,(Q)=>Q==="-v")}function CI($,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 SI($,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 TI($,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 wI="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.",vI=64;function W7($,J,Q,X){let Y=Q.derivedCommandWorkBudget===void 0,W=Q.parallelBudget===void 0;try{return fI($,J,{...Q,derivedCommandWorkBudget:Q.derivedCommandWorkBudget??o6(),parallelBudget:Q.parallelBudget??vB()},X)}catch(K){let B=K instanceof L2?jB:K instanceof m1&&Y?IB:K instanceof Y9&&W?wB: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 fI($,J,Q,X){if(J>=n6)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 $$(Y,J,{...Q,rootProgram:Y},K,[{effectiveCwd:B,shellGitContextState:q,literalHeredocFiles:new Map(Q.literalHeredocFiles),functionDefinitions:new Map(Q.functionDefinitions)}]).result}function $$($,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=hI($,q,U,B,H),Z=B==="&&"||B==="||",M=Z?K:void 0,O=B==="&&"?M?.success??W:B==="||"?M?.failure??W:W,V=B==="||"?M?.success??[]:[],F=B==="&&"?M?.failure??[]:[],b=Z||G4(H);if(U.kind==="function"){let C=O.flatMap((y)=>{let x=S3(y);return x.functionDefinitions.set(U.name,U.body),J7(y,[x],L,H==="&",G4(H))}),T=Q7(C,[],V,F,B,H);W=T.states,K=T.conditionalStates,B=void 0;continue}if(U.kind==="group"){let C=[],T=[];for(let x of O){let c=$$(U.body,J,Q,X,[S3(x)]);if(c.result)return c;if(C.push(...J7(x,c.states,L,H==="&",G4(H))),b)T.push(x,...L?c.states.map((V1)=>t9(x,V1)):c.states)}let y=Q7(C,T,V,F,B,H);W=y.states,K=y.conditionalStates,B=void 0;continue}if(U.kind!=="command")continue;let R=Q.trace?.flattenNested?Q.trace.currentSegmentIndex:Q.trace?.allocateSegment(),A=$.nodes[q-2],E=J$(B)&&A?.kind==="command"?mU(A)??gI(A):void 0,_=[],j=[];for(let C of O){let T=yI(U,J,Q,X,[S3(C)]);if(T.result)return{result:T.result,states:W};let y=$.dialect==="powershell"?T.states:T.states.map((x)=>t9(C,x));for(let x of y){let c=S3(x),V1=mI(U,J,Q.trace?{...Q,trace:eG(Q.trace,R)}:Q,X,c,J$(B),E);if(V1)return{result:V1,states:W};let S=$j(U,c.functionDefinitions);if(S)K0(Q.derivedCommandWorkBudget,Q$(S));let m=S?J+1>=n6?X7(U.displayText,Q,[c]):$$(S,J+1,Q,X,[c]):{result:null,states:[c]};if(m.result)return m;if(_.push(...J7(C,m.states,L,H==="&",G4(H))),b)j.push(C),j.push(...m.states.map((X1)=>L?t9(C,X1):X1))}}let P=Q7(_,j,V,F,B,H);W=P.states,K=P.conditionalStates,B=void 0}return{result:null,states:W}}function hI($,J,Q,X,Y){if(Q.kind==="group"&&Q.style==="subshell")return!0;if($.dialect==="posix"&&(J$(X)||J$(Y)))return!0;if(Y==="&")return!0;return $.dialect==="powershell"&&Q.kind==="group"&&Q.style==="brace"&&kI($,J)}function J7($,J,Q,X,Y){let W=Q?J.map((B)=>t9($,B)):[...J],K=Y?W.flatMap((B)=>T3($.literalHeredocFiles,B.literalHeredocFiles)?[B]:[{...B,literalHeredocFiles:new Map($.literalHeredocFiles)},B]):W;return X?[$,...K]:K}function t9($,J){return{...$,literalHeredocFiles:new Map(J.literalHeredocFiles)}}function kI($,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(xI(Q))return!0;return Q.source.replaceAll(/\s/g,"").toLowerCase()==="if($false)"}function J$($){return $==="|"||$==="|&"}function gI($){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:e9([...Q,...$]),failure:e9([...X,...J])},B=G4(W)?K:void 0;return{states:G4(Y)||B?e9([...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 yI($,J,Q,X,Y){let W=$.nested.map((K)=>({program:K,depth:J}));if($.dialect==="powershell"){let K=uI($);if(K){if(J+1>=n6)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,Q$(B)),W.push({program:B,depth:J+1})}}return iG(W,Q,X,Y)}function xI($){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=$$(W.program,W.depth,J,Q,[S3(B)]);if(q.result)return q;K.push(...q.states)}Y=e9(K)}return{result:null,states:Y}}function uI($){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 Q$($){return $.nodes.reduce((J,Q)=>J+(Q.kind==="command"?Q.words.length+Q.nested.reduce((X,Y)=>X+Q$(Y),0):Q.kind==="group"||Q.kind==="function"?Q$(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 mI($,J,Q,X,Y,W,K){let B=oI($);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,Xj(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 Qj(U,Z)}if(q.length===1&&q[0]?.includes(" ")&&!$.dynamicExecutable){let Z=k(Y3(q[0],Q.scanWork),Q.policy),M=Z!==null&&!Q.strict&&DB($,Q.rootProgram,Q.scanWork);if(Z&&!M)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,M)=>{let O=M&&Object.hasOwn(M,"effectiveCwd")?M.effectiveCwd:Y.effectiveCwd,V=W7(Z,J+1,{...Q,derivedCommandWorkBudget:Q.derivedCommandWorkBudget,effectiveCwd:O,envAssignments:M?.envAssignments??G,literalHeredocFiles:Y.literalHeredocFiles,functionDefinitions:M?.functionDefinitions,worktreeMode:M?.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=nI($,J,Q,X??new Map,W);if(K)return K;return $H($,Q,"after-consumer",W.environment.paths),Q.literalHeredocFiles.clear(),cI($,J,Q,W.environment.paths),tI($,Q,Y,W.environment,W.trace),null}var lI=new Set([">>","<>"]);function $H($,J,Q,X){for(let W of $.redirections){if(!(Q==="before-consumer"?pI(W):lI.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 pI($){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 cI($,J,Q,X){if(J)return;let Y=$.redirections.find((W)=>W.operator==="<<"||W.operator==="<<-")?.heredoc;if(!Y?.quotedDelimiter)return;for(let W of dI($)){let K=W3(W.text,Q.effectiveCwd,X);if(!K||!AB(K))continue;if(!Q.literalHeredocFiles.has(K)&&Q.literalHeredocFiles.size>=PB)throw new m1;Q.literalHeredocFiles.set(K,Y.body)}}function dI($){let J=iI($.redirections)?.target,Q=sG(J)?[J]:[];if(k1($.words[0],"cat"))return rI($.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 rI($){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 iI($){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 oI($){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 wI;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 nI($,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(aI($,W,Q,X,Y))return null;let B=sI($,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(`
|
|
62
|
+
`):$.source,Y);return q?{...q,segment:$.displayText}:null}function sI($,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"||!S1(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",O2),Q.policy);if(!q)return null;return Q.trace?.recordSegment({type:"dangerous-text",token:K,matched:!0,reason:q.reason}),q}function aI($,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 tI($,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 S3($){return{effectiveCwd:$.effectiveCwd,shellGitContextState:mG($.shellGitContextState),literalHeredocFiles:new Map($.literalHeredocFiles),functionDefinitions:new Map($.functionDefinitions)}}function e9($){let J=[];for(let Q of $){if(!J.some((X)=>eI(X,Q)))J.push(Q);if(J.length>vI)throw new m1}return J}function eI($,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)&&Jj($.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 $j($,J){let Q=D9($);return Q===void 0?void 0:J.get(Q)}function Jj($,J){return $.size===J.size&&[...$].every((Q)=>J.has(Q))}function Qj($,J){if(!J)return null;return{reason:J.reason,segment:$,ruleId:J.id,intent:J.intent}}function Xj($,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"}},X$=["standard","strict","paranoid"];function Yj($){return{failClosed:$==="strict"||$==="paranoid",paranoidRm:$==="paranoid",paranoidInterpreters:$==="paranoid"}}function Wj($,J){if(!J)return $;return X$.indexOf(J)>X$.indexOf($)?J:$}function Kj(){let $=G7(B1.level);if($===void 0||$==="")return;if(X$.includes($))return $;console.error(`CC Safety Net: ignored invalid ${B1.level.name}=${JSON.stringify($.slice(0,40))}. Use ${X$.join(", ")}.`);return}function Bj($){if($===void 0||$==="all")return"all";if($==="blocked")return"blocked";return"invalid"}function B7(){return Bj(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=Kj(),X=Wj(J,Q),Y=Yj(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:VB($.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"node:path";function Y$($,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 Ok,existsSync as MP,mkdirSync as Nk,readFileSync as OP}from"node:fs";import{dirname as NP,join as FP}from"node:path";import{createRequire as JP}from"node:module";var oW={};B2(oW,{z:()=>QJ,xor:()=>EZ,xid:()=>aH,void:()=>RZ,uuidv7:()=>pH,uuidv6:()=>lH,uuidv4:()=>mH,uuid:()=>uH,util:()=>w,url:()=>cH,uppercase:()=>I4,unknown:()=>k2,union:()=>i8,undefined:()=>DZ,ulid:()=>sH,uint64:()=>VZ,uint32:()=>OZ,tuple:()=>VW,trim:()=>C4,treeifyError:()=>H$,transform:()=>n8,toUpperCase:()=>T4,toLowerCase:()=>S4,toJSONSchema:()=>s3,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:()=>j8,safeEncode:()=>R8,safeDecodeAsync:()=>b8,safeDecode:()=>I8,registry:()=>i3,regexes:()=>y1,regex:()=>z4,refine:()=>cW,record:()=>_W,readonly:()=>yW,property:()=>U8,promise:()=>lZ,prettifyError:()=>Z$,preprocess:()=>aZ,prefault:()=>TW,positive:()=>W8,pipe:()=>W6,partialRecord:()=>SZ,parseAsync:()=>O8,parse:()=>M8,overwrite:()=>Q0,optional:()=>X6,object:()=>bZ,number:()=>QW,nullish:()=>gZ,nullable:()=>Y6,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:()=>R4,looseRecord:()=>TZ,looseObject:()=>AZ,locales:()=>r3,literal:()=>hZ,length:()=>h2,lazy:()=>mW,ksuid:()=>tH,keyof:()=>jZ,jwt:()=>BZ,json:()=>sZ,iso:()=>J6,ipv6:()=>JZ,ipv4:()=>eH,intersection:()=>NW,int64:()=>FZ,int32:()=>MZ,int:()=>A8,instanceof:()=>oZ,includes:()=>j4,httpUrl:()=>dH,hostname:()=>UZ,hex:()=>GZ,hash:()=>HZ,guid:()=>xH,gte:()=>D1,gt:()=>_0,globalRegistry:()=>E1,getErrorMap:()=>$L,function:()=>pZ,fromJSONSchema:()=>iW,formatError:()=>O4,float64:()=>LZ,float32:()=>ZZ,flattenError:()=>M4,file:()=>kZ,exactOptional:()=>PW,enum:()=>o8,endsWith:()=>P4,encodeAsync:()=>D8,encode:()=>V8,emoji:()=>rH,email:()=>yH,e164:()=>KZ,discriminatedUnion:()=>CZ,describe:()=>rZ,default:()=>sb,decodeAsync:()=>z8,decode:()=>_8,date:()=>IZ,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:()=>q6,any:()=>zZ,_function:()=>pZ,_default:()=>CW,_ZodString:()=>E8,ZodXor:()=>LW,ZodXID:()=>h8,ZodVoid:()=>HW,ZodUnknown:()=>UW,ZodUnion:()=>G6,ZodUndefined:()=>WW,ZodUUID:()=>R0,ZodURL:()=>K6,ZodULID:()=>f8,ZodType:()=>g,ZodTuple:()=>FW,ZodTransform:()=>jW,ZodTemplateLiteral:()=>xW,ZodSymbol:()=>YW,ZodSuccess:()=>vW,ZodStringFormat:()=>r,ZodString:()=>x4,ZodSet:()=>zW,ZodRecord:()=>H6,ZodRealError:()=>z1,ZodReadonly:()=>gW,ZodPromise:()=>lW,ZodPrefault:()=>SW,ZodPipe:()=>t8,ZodOptional:()=>s8,ZodObject:()=>U6,ZodNumberFormat:()=>g2,ZodNumber:()=>m4,ZodNullable:()=>AW,ZodNull:()=>KW,ZodNonOptional:()=>a8,ZodNever:()=>GW,ZodNanoID:()=>T8,ZodNaN:()=>kW,ZodMap:()=>DW,ZodMAC:()=>JW,ZodLiteral:()=>RW,ZodLazy:()=>uW,ZodKSUID:()=>k8,ZodJWT:()=>c8,ZodIssueCode:()=>tZ,ZodIntersection:()=>OW,ZodISOTime:()=>e3,ZodISODuration:()=>$6,ZodISODateTime:()=>a3,ZodISODate:()=>t3,ZodIPv6:()=>y8,ZodIPv4:()=>g8,ZodGUID:()=>Q6,ZodFunction:()=>pW,ZodFirstPartyTypeKind:()=>$J,ZodFile:()=>IW,ZodExactOptional:()=>bW,ZodError:()=>gH,ZodEnum:()=>y4,ZodEmoji:()=>S8,ZodEmail:()=>C8,ZodE164:()=>p8,ZodDiscriminatedUnion:()=>MW,ZodDefault:()=>EW,ZodDate:()=>B6,ZodCustomStringFormat:()=>u4,ZodCustom:()=>Z6,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:()=>RZ,uuidv7:()=>pH,uuidv6:()=>lH,uuidv4:()=>mH,uuid:()=>uH,util:()=>w,url:()=>cH,uppercase:()=>I4,unknown:()=>k2,union:()=>i8,undefined:()=>DZ,ulid:()=>sH,uint64:()=>VZ,uint32:()=>OZ,tuple:()=>VW,trim:()=>C4,treeifyError:()=>H$,transform:()=>n8,toUpperCase:()=>T4,toLowerCase:()=>S4,toJSONSchema:()=>s3,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:()=>j8,safeEncode:()=>R8,safeDecodeAsync:()=>b8,safeDecode:()=>I8,registry:()=>i3,regexes:()=>y1,regex:()=>z4,refine:()=>cW,record:()=>_W,readonly:()=>yW,property:()=>U8,promise:()=>lZ,prettifyError:()=>Z$,preprocess:()=>aZ,prefault:()=>TW,positive:()=>W8,pipe:()=>W6,partialRecord:()=>SZ,parseAsync:()=>O8,parse:()=>M8,overwrite:()=>Q0,optional:()=>X6,object:()=>bZ,number:()=>QW,nullish:()=>gZ,nullable:()=>Y6,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:()=>R4,looseRecord:()=>TZ,looseObject:()=>AZ,locales:()=>r3,literal:()=>hZ,length:()=>h2,lazy:()=>mW,ksuid:()=>tH,keyof:()=>jZ,jwt:()=>BZ,json:()=>sZ,iso:()=>J6,ipv6:()=>JZ,ipv4:()=>eH,intersection:()=>NW,int64:()=>FZ,int32:()=>MZ,int:()=>A8,instanceof:()=>oZ,includes:()=>j4,httpUrl:()=>dH,hostname:()=>UZ,hex:()=>GZ,hash:()=>HZ,guid:()=>xH,gte:()=>D1,gt:()=>_0,globalRegistry:()=>E1,getErrorMap:()=>$L,function:()=>pZ,fromJSONSchema:()=>iW,formatError:()=>O4,float64:()=>LZ,float32:()=>ZZ,flattenError:()=>M4,file:()=>kZ,exactOptional:()=>PW,enum:()=>o8,endsWith:()=>P4,encodeAsync:()=>D8,encode:()=>V8,emoji:()=>rH,email:()=>yH,e164:()=>KZ,discriminatedUnion:()=>CZ,describe:()=>rZ,decodeAsync:()=>z8,decode:()=>_8,date:()=>IZ,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:()=>q6,any:()=>zZ,_function:()=>pZ,_default:()=>CW,_ZodString:()=>E8,ZodXor:()=>LW,ZodXID:()=>h8,ZodVoid:()=>HW,ZodUnknown:()=>UW,ZodUnion:()=>G6,ZodUndefined:()=>WW,ZodUUID:()=>R0,ZodURL:()=>K6,ZodULID:()=>f8,ZodType:()=>g,ZodTuple:()=>FW,ZodTransform:()=>jW,ZodTemplateLiteral:()=>xW,ZodSymbol:()=>YW,ZodSuccess:()=>vW,ZodStringFormat:()=>r,ZodString:()=>x4,ZodSet:()=>zW,ZodRecord:()=>H6,ZodRealError:()=>z1,ZodReadonly:()=>gW,ZodPromise:()=>lW,ZodPrefault:()=>SW,ZodPipe:()=>t8,ZodOptional:()=>s8,ZodObject:()=>U6,ZodNumberFormat:()=>g2,ZodNumber:()=>m4,ZodNullable:()=>AW,ZodNull:()=>KW,ZodNonOptional:()=>a8,ZodNever:()=>GW,ZodNanoID:()=>T8,ZodNaN:()=>kW,ZodMap:()=>DW,ZodMAC:()=>JW,ZodLiteral:()=>RW,ZodLazy:()=>uW,ZodKSUID:()=>k8,ZodJWT:()=>c8,ZodIssueCode:()=>tZ,ZodIntersection:()=>OW,ZodISOTime:()=>e3,ZodISODuration:()=>$6,ZodISODateTime:()=>a3,ZodISODate:()=>t3,ZodIPv6:()=>y8,ZodIPv4:()=>g8,ZodGUID:()=>Q6,ZodFunction:()=>pW,ZodFirstPartyTypeKind:()=>$J,ZodFile:()=>IW,ZodExactOptional:()=>bW,ZodError:()=>gH,ZodEnum:()=>y4,ZodEmoji:()=>S8,ZodEmail:()=>C8,ZodE164:()=>p8,ZodDiscriminatedUnion:()=>MW,ZodDefault:()=>EW,ZodDate:()=>B6,ZodCustomStringFormat:()=>u4,ZodCustom:()=>Z6,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:()=>s3,toDotPath:()=>UH,safeParseAsync:()=>I7,safeParse:()=>R7,safeEncodeAsync:()=>uj,safeEncode:()=>yj,safeDecodeAsync:()=>mj,safeDecode:()=>xj,registry:()=>i3,regexes:()=>y1,process:()=>n,prettifyError:()=>Z$,parseAsync:()=>M$,parse:()=>L$,meta:()=>GY,locales:()=>r3,isValidJWT:()=>EH,isValidBase64URL:()=>AH,isValidBase64:()=>yX,initializeContext:()=>h4,globalRegistry:()=>E1,globalConfig:()=>w3,formatError:()=>O4,flattenError:()=>M4,finalize:()=>g4,extractDefs:()=>k4,encodeAsync:()=>kj,encode:()=>fj,describe:()=>UY,decodeAsync:()=>gj,decode:()=>hj,createToJSONSchemaMethod:()=>ZY,createStandardJSONSchemaMethod:()=>G8,config:()=>Y1,clone:()=>N1,_xor:()=>Vb,_xid:()=>o$,_void:()=>$Y,_uuidv7:()=>l$,_uuidv6:()=>m$,_uuidv4:()=>u$,_uuid:()=>x$,_url:()=>n3,_uppercase:()=>I4,_unknown:()=>t5,_union:()=>Fb,_undefined:()=>n5,_ulid:()=>i$,_uint64:()=>i5,_uint32:()=>m5,_tuple:()=>zb,_trim:()=>C4,_transform:()=>Eb,_toUpperCase:()=>T4,_toLowerCase:()=>S4,_templateLiteral:()=>gb,_symbol:()=>o5,_superRefine:()=>qY,_success:()=>vb,_stringbool:()=>HY,_stringFormat:()=>v4,_string:()=>E5,_startsWith:()=>b4,_slugify:()=>w4,_size:()=>v2,_set:()=>jb,_safeParseAsync:()=>_4,_safeParse:()=>V4,_safeEncodeAsync:()=>z$,_safeEncode:()=>_$,_safeDecodeAsync:()=>R$,_safeDecode:()=>D$,_regex:()=>z4,_refine:()=>BY,_record:()=>Rb,_readonly:()=>kb,_property:()=>U8,_promise:()=>xb,_positive:()=>W8,_pipe:()=>hb,_parseAsync:()=>F4,_parse:()=>N4,_overwrite:()=>Q0,_optional:()=>Cb,_number:()=>h5,_nullable:()=>Sb,_null:()=>s5,_normalize:()=>E4,_nonpositive:()=>B8,_nonoptional:()=>wb,_nonnegative:()=>q8,_never:()=>e5,_negative:()=>K8,_nativeEnum:()=>Pb,_nanoid:()=>c$,_nan:()=>XY,_multipleOf:()=>Y2,_minSize:()=>D0,_minLength:()=>y0,_min:()=>D1,_mime:()=>A4,_maxSize:()=>W2,_maxLength:()=>f2,_max:()=>x1,_map:()=>Ib,_mac:()=>S5,_lte:()=>x1,_lt:()=>V0,_lowercase:()=>R4,_literal:()=>Ab,_length:()=>h2,_lazy:()=>yb,_ksuid:()=>n$,_jwt:()=>X8,_isoTime:()=>v5,_isoDuration:()=>f5,_isoDateTime:()=>T5,_isoDate:()=>w5,_ipv6:()=>a$,_ipv4:()=>s$,_intersection:()=>Db,_int64:()=>r5,_int32:()=>u5,_int:()=>g5,_includes:()=>j4,_guid:()=>o3,_gte:()=>D1,_gt:()=>_0,_float64:()=>x5,_float32:()=>y5,_file:()=>WY,_enum:()=>bb,_endsWith:()=>P4,_encodeAsync:()=>F$,_encode:()=>O$,_emoji:()=>p$,_email:()=>y$,_e164:()=>Q8,_discriminatedUnion:()=>_b,_default:()=>Tb,_decodeAsync:()=>V$,_decode:()=>N$,_date:()=>JY,_custom:()=>KY,_cuid2:()=>r$,_cuid:()=>d$,_coercedString:()=>C5,_coercedNumber:()=>k5,_coercedDate:()=>QY,_coercedBoolean:()=>p5,_coercedBigint:()=>d5,_cidrv6:()=>e$,_cidrv4:()=>t$,_check:()=>vH,_catch:()=>fb,_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:()=>c3,$ZodUndefined:()=>iX,$ZodUUID:()=>_X,$ZodURL:()=>zX,$ZodULID:()=>PX,$ZodType:()=>v,$ZodTuple:()=>f$,$ZodTransform:()=>H5,$ZodTemplateLiteral:()=>R5,$ZodSymbol:()=>rX,$ZodSuccess:()=>F5,$ZodStringFormat:()=>d,$ZodString:()=>w2,$ZodSet:()=>B5,$ZodRegistry:()=>A5,$ZodRecord:()=>W5,$ZodRealError:()=>A1,$ZodReadonly:()=>z5,$ZodPromise:()=>j5,$ZodPrefault:()=>O5,$ZodPipe:()=>D5,$ZodOptional:()=>h$,$ZodObjectJIT:()=>J5,$ZodObject:()=>TH,$ZodNumberFormat:()=>cX,$ZodNumber:()=>w$,$ZodNullable:()=>L5,$ZodNull:()=>oX,$ZodNonOptional:()=>N5,$ZodNever:()=>aX,$ZodNanoID:()=>IX,$ZodNaN:()=>_5,$ZodMap:()=>K5,$ZodMAC:()=>hX,$ZodLiteral:()=>U5,$ZodLazy:()=>b5,$ZodKSUID:()=>EX,$ZodJWT:()=>lX,$ZodIntersection:()=>Y5,$ZodISOTime:()=>TX,$ZodISODuration:()=>wX,$ZodISODateTime:()=>CX,$ZodISODate:()=>SX,$ZodIPv6:()=>fX,$ZodIPv4:()=>vX,$ZodGUID:()=>VX,$ZodFunction:()=>I5,$ZodFile:()=>G5,$ZodExactOptional:()=>Z5,$ZodError:()=>x3,$ZodEnum:()=>q5,$ZodEncodeError:()=>C2,$ZodEmoji:()=>RX,$ZodEmail:()=>DX,$ZodE164:()=>mX,$ZodDiscriminatedUnion:()=>X5,$ZodDefault:()=>M5,$ZodDate:()=>eX,$ZodCustomStringFormat:()=>pX,$ZodCustom:()=>P5,$ZodCodec:()=>d3,$ZodCheckUpperCase:()=>UX,$ZodCheckStringFormat:()=>D4,$ZodCheckStartsWith:()=>HX,$ZodCheckSizeEquals:()=>XX,$ZodCheckRegex:()=>BX,$ZodCheckProperty:()=>LX,$ZodCheckOverwrite:()=>OX,$ZodCheckNumberFormat:()=>e7,$ZodCheckMultipleOf:()=>t7,$ZodCheckMinSize:()=>QX,$ZodCheckMinLength:()=>WX,$ZodCheckMimeType:()=>MX,$ZodCheckMaxSize:()=>JX,$ZodCheckMaxLength:()=>YX,$ZodCheckLowerCase:()=>qX,$ZodCheckLessThan:()=>j$,$ZodCheckLengthEquals:()=>KX,$ZodCheckIncludes:()=>GX,$ZodCheckGreaterThan:()=>b$,$ZodCheckEndsWith:()=>ZX,$ZodCheckBigIntFormat:()=>$X,$ZodCheck:()=>o,$ZodCatch:()=>V5,$ZodCUID2:()=>bX,$ZodCUID:()=>jX,$ZodCIDRv6:()=>gX,$ZodCIDRv4:()=>kX,$ZodBoolean:()=>p3,$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 C2 extends Error{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}}var w3={};function Y1($){if($)Object.assign(w3,$);return w3}var w={};B2(w,{unwrapMessage:()=>v3,uint8ArrayToHex:()=>wj,uint8ArrayToBase64url:()=>Sj,uint8ArrayToBase64:()=>KH,stringifyPrimitive:()=>G$,slugify:()=>M7,shallowClone:()=>N7,safeExtend:()=>jj,required:()=>Aj,randomString:()=>Fj,propertyKeyTypes:()=>k3,promiseAllObject:()=>Nj,primitiveTypes:()=>F7,prefixIssues:()=>g1,pick:()=>zj,partial:()=>Pj,parsedType:()=>z7,optionalKeys:()=>V7,omit:()=>Rj,objectClone:()=>Lj,numKeys:()=>Vj,nullish:()=>$2,normalizeParams:()=>D,mergeDefs:()=>g0,merge:()=>bj,jsonStringifyReplacer:()=>H4,joinValues:()=>B$,issue:()=>L4,isPlainObject:()=>Q2,isObject:()=>S2,hexToUint8Array:()=>Tj,getSizableOrigin:()=>g3,getParsedType:()=>_j,getLengthableOrigin:()=>y3,getEnumValues:()=>f3,getElementAtPath:()=>Oj,floatSafeRemainder:()=>L7,finalizeIssue:()=>P1,extend:()=>Ij,escapeRegex:()=>r1,esc:()=>q$,defineLazy:()=>u,createTransparentProxy:()=>Dj,cloneDef:()=>Mj,clone:()=>N1,cleanRegex:()=>h3,cleanEnum:()=>Ej,captureStackTrace:()=>U$,cached:()=>Z4,base64urlToUint8Array:()=>Cj,base64ToUint8Array:()=>WH,assignProp:()=>J2,assertNotEqual:()=>Uj,assertNever:()=>Hj,assertIs:()=>Gj,assertEqual:()=>qj,assert:()=>Zj,allowsEval:()=>O7,aborted:()=>X2,NUMBER_FORMAT_RANGES:()=>_7,Class:()=>BH,BIGINT_FORMAT_RANGES:()=>D7});function qj($){return $}function Uj($){return $}function Gj($){}function Hj($){throw Error("Unexpected value in exhaustive check")}function Zj($){}function f3($){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 h3($){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 Lj($){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 Mj($){return g0($._zod.def)}function Oj($,J){if(!J)return $;return J.reduce((Q,X)=>Q?.[X],$)}function Nj($){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 Fj($=10){let Q="";for(let X=0;X<$;X++)Q+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Q}function q$($){return JSON.stringify($)}function M7($){return $.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var U$="captureStackTrace"in Error?Error.captureStackTrace:(...$)=>{};function S2($){return typeof $==="object"&&$!==null&&!Array.isArray($)}var O7=Z4(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch($){return!1}});function Q2($){if(S2($)===!1)return!1;let J=$.constructor;if(J===void 0)return!0;if(typeof J!=="function")return!0;let Q=J.prototype;if(S2(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 Vj($){let J=0;for(let Q in $)if(Object.prototype.hasOwnProperty.call($,Q))J++;return J}var _j=($)=>{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}`)}},k3=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 Dj($){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 zj($,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 Rj($,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 Ij($,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 jj($,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 bj($,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 Pj($,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 Aj($,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 v3($){return typeof $==="string"?$:$?.message}function P1($,J,Q){let X={...$,path:$.path??[]};if(!$.message){let Y=v3($.inst?._zod.def?.error?.($))??v3(J?.error?.($))??v3(Q.customError?.($))??v3(Q.localeError?.($))??"Invalid input";X.message=Y}if(delete X.inst,delete X.continue,!J?.reportInput)delete X.input;return X}function g3($){if($ instanceof Set)return"set";if($ instanceof Map)return"map";if($ instanceof File)return"file";return"unknown"}function y3($){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 Ej($){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 Cj($){let J=$.replace(/-/g,"+").replace(/_/g,"/"),Q="=".repeat((4-J.length%4)%4);return WH(J+Q)}function Sj($){return KH($).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Tj($){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 wj($){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})},x3=N("$ZodError",qH),A1=N("$ZodError",qH,{Parent:Error});function M4($,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 O4($,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(`✖ ${X.message}`),X.path?.length)J.push(` → at ${UH(X.path)}`);return J.join(`
|
|
63
|
+
`)}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},M$=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($??x3)(W.issues.map((K)=>P1(K,Y,Y1())))}:{success:!0,data:W.value}},R7=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}},I7=_4(A1),O$=($)=>(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return N4($)(J,Q,Y)},fj=O$(A1),N$=($)=>(J,Q,X)=>{return N4($)(J,Q,X)},hj=N$(A1),F$=($)=>async(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return F4($)(J,Q,Y)},kj=F$(A1),V$=($)=>async(J,Q,X)=>{return F4($)(J,Q,X)},gj=V$(A1),_$=($)=>(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return V4($)(J,Q,Y)},yj=_$(A1),D$=($)=>(J,Q,X)=>{return V4($)(J,Q,X)},xj=D$(A1),z$=($)=>async(J,Q,X)=>{let Y=X?Object.assign(X,{direction:"backward"}):{direction:"backward"};return _4($)(J,Q,Y)},uj=z$(A1),R$=($)=>async(J,Q,X)=>{return _4($)(J,Q,X)},mj=R$(A1);var y1={};B2(y1,{xid:()=>A7,uuid7:()=>dj,uuid6:()=>cj,uuid4:()=>pj,uuid:()=>T2,uppercase:()=>a7,unicodeEmail:()=>GH,undefined:()=>n7,ulid:()=>P7,time:()=>l7,string:()=>c7,sha512_hex:()=>Zb,sha512_base64url:()=>Mb,sha512_base64:()=>Lb,sha384_hex:()=>Ub,sha384_base64url:()=>Hb,sha384_base64:()=>Gb,sha256_hex:()=>Kb,sha256_base64url:()=>qb,sha256_base64:()=>Bb,sha1_hex:()=>Xb,sha1_base64url:()=>Wb,sha1_base64:()=>Yb,rfc5322Email:()=>ij,number:()=>u3,null:()=>o7,nanoid:()=>C7,md5_hex:()=>$b,md5_base64url:()=>Qb,md5_base64:()=>Jb,mac:()=>k7,lowercase:()=>s7,ksuid:()=>E7,ipv6:()=>h7,ipv4:()=>f7,integer:()=>r7,idnEmail:()=>oj,html5Email:()=>rj,hostname:()=>aj,hex:()=>ej,guid:()=>T7,extendedDuration:()=>lj,emoji:()=>v7,email:()=>w7,e164:()=>u7,duration:()=>S7,domain:()=>tj,datetime:()=>p7,date:()=>m7,cuid2:()=>b7,cuid:()=>j7,cidrv6:()=>y7,cidrv4:()=>g7,browserEmail:()=>nj,boolean:()=>i7,bigint:()=>d7,base64url:()=>I$,base64:()=>x7});var j7=/^[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}$/,C7=/^[a-zA-Z0-9_-]{21}$/,S7=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,lj=/^[-+]?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})$`)},pj=T2(4),cj=T2(6),dj=T2(7),w7=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,rj=/^[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])?)*$/,ij=/^(([^<>()\[\]\\.,;:\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,oj=GH,nj=/^[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])?)*$/,sj="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function v7(){return new RegExp(sj,"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}=))?$/,I$=/^[A-Za-z0-9_-]*$/,aj=/^(?=.{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])?)*\.?$/,tj=/^([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+$/,u3=/^-?\d+(?:\.\d+)?$/,i7=/^(?:true|false)$/i,o7=/^null$/i;var n7=/^undefined$/i;var s7=/^[^A-Z]*$/,a7=/^[^a-z]*$/,ej=/^[0-9a-fA-F]*$/;function m3($,J){return new RegExp(`^[A-Za-z0-9+/]{${$}}${J}$`)}function l3($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var $b=/^[0-9a-fA-F]{32}$/,Jb=m3(22,"=="),Qb=l3(22),Xb=/^[0-9a-fA-F]{40}$/,Yb=m3(27,"="),Wb=l3(27),Kb=/^[0-9a-fA-F]{64}$/,Bb=m3(43,"="),qb=l3(43),Ub=/^[0-9a-fA-F]{96}$/,Gb=m3(64,""),Hb=l3(64),Zb=/^[0-9a-fA-F]{128}$/,Lb=m3(86,"=="),Mb=l3(86);var o=N("$ZodCheck",($,J)=>{var Q;$._zod??($._zod={}),$._zod.def=J,(Q=$._zod).onattach??(Q.onattach=[])}),MH={number:"number",bigint:"bigint",object:"date"},j$=N("$ZodCheckLessThan",($,J)=>{o.init($,J);let Q=MH[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=MH[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:g3(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:g3(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:g3(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=y3(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=y3(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=y3(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}}),MX=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})}}),OX=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(`
|
|
64
64
|
`).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(`
|
|
65
65
|
`))}}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=R7($,Y);return W.success?{value:W.data}:{issues:W.error?.issues}}catch(W){return I7($,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})}}}),RX=N("$ZodEmoji",($,J)=>{J.pattern??(J.pattern=v7()),d.init($,J)}),IX=N("$ZodNanoID",($,J)=>{J.pattern??(J.pattern=C7),d.init($,J)}),jX=N("$ZodCUID",($,J)=>{J.pattern??(J.pattern=j7),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)}),CX=N("$ZodISODateTime",($,J)=>{J.pattern??(J.pattern=p7(J)),d.init($,J)}),SX=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=S7),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(!I$.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=I$),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??u3,$._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)}),p3=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 CH($){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 SH($,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(()=>CH(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=S2,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],M=Z._zod.optout==="optional",O=Z._zod.run({value:U[L],issues:[]},q);if(O instanceof Promise)G.push(O.then((V)=>T$(V,B,L,U,M)));else T$(O,B,L,U,M)}if(!W)return G.length?Promise.all(G).then(()=>B):B;return SH(G,U,B,q,X.value,$)}}),J5=N("$ZodObjectJIT",($,J)=>{TH.init($,J);let Q=$._zod.parse,X=Z4(()=>CH(J)),Y=(L)=>{let Z=new P$(["shape","payload","ctx"]),M=X.value,O=(R)=>{let A=q$(R);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 R of M.keys)V[R]=`key_${F++}`;Z.write("const newResult = {};");for(let R of M.keys){let A=V[R],E=q$(R),j=L[R]?._zod?.optout==="optional";if(Z.write(`const ${A} = ${O(R)};`),j)Z.write(`
|
|
66
66
|
if (${A}.issues.length) {
|
|
@@ -96,6 +96,6 @@ ${kO($.intent??"manual_only")}`,B}function kO($){switch($){case"hard_stop":retur
|
|
|
96
96
|
newResult[${E}] = ${A}.value;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
`)}Z.write("payload.value = newResult;"),Z.write("return payload;");let b=Z.compile();return(R,A)=>b(L,R,A)},W,K=S2,B=!w3.jitless,U=B&&O7.value,G=J.catchall,H;$._zod.parse=(L,Z)=>{H??(H=X.value);let M=L.value;if(!K(M))return L.issues.push({expected:"object",code:"invalid_type",input:M,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 SH([],M,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 c3=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)=>h3(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)=>{c3.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,c3.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(!S2(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"&&u3.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(k3.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(k3.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=f3(J.entries),X=new Set(Q);$._zod.values=X,$._zod.pattern=new RegExp(`^(${Q.filter((Y)=>k3.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 C2($.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 RH($,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(`^(${h3(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)=>RH(W,Q.value));return RH(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(`^(${h3(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)}}),M5=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)=>IH(W,J));return IH(Y,J)}});function IH($,J){if($.value===void 0)$.value=J.defaultValue;return $}var O5=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)=>jH(W,$));return jH(Y,$)}});function jH($,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 C2("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 d3=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)=>C$(K,J,X));return C$(W,J,X)}else{let W=J.out._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>C$(K,J,X));return C$(W,J,X)}}});function C$($,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)=>S$($,W,J.out,Q));return S$($,Y,J.out,Q)}else{let Y=J.reverseTransform($.value,$);if(Y instanceof Promise)return Y.then((W)=>S$($,W,J.in,Q));return S$($,Y,J.in,Q)}}function S$($,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 R5=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}}),I5=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 M$($._def.input,X):X,W=await Reflect.apply(Q,this,Y);if($._def.output)return await M$($._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})},$}),j5=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 r3={};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 i3(){return new A5}(wH=globalThis).__zod_globalRegistry??(wH.__zod_globalRegistry=i3());var E1=globalThis.__zod_globalRegistry;function E5($,J){return new $({type:"string",...D(J)})}function C5($,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 o3($,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 n3($,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 S5($,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 j$({check:"less_than",...D(J),value:$,inclusive:!1})}function x1($,J){return new j$({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 R4($){return new qX({check:"string_format",format:"lowercase",...D($)})}function I4($){return new UX({check:"string_format",format:"uppercase",...D($)})}function j4($,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 MX({check:"mime_type",mime:$,...D(J)})}function Q0($){return new OX({check:"overwrite",tx:$})}function E4($){return Q0((J)=>J.normalize($))}function C4(){return Q0(($)=>$.trim())}function S4(){return Q0(($)=>$.toLowerCase())}function T4(){return Q0(($)=>$.toUpperCase())}function w4(){return Q0(($)=>M7($))}function YY($,J,Q){return new $({type:"array",element:J,...D(Q)})}function Ob($,J,Q){return new $({type:"union",options:J,...D(Q)})}function Nb($,J,Q){return new $({type:"union",options:J,inclusive:!1,...D(Q)})}function Fb($,J,Q,X){return new $({type:"union",options:Q,discriminator:J,...D(X)})}function Vb($,J,Q){return new $({type:"intersection",left:J,right:Q})}function _b($,J,Q,X){let Y=Q instanceof v;return new $({type:"tuple",items:J,rest:Y?Q:null,...D(Y?X:Q)})}function Db($,J,Q,X){return new $({type:"record",keyType:J,valueType:Q,...D(X)})}function zb($,J,Q,X){return new $({type:"map",keyType:J,valueType:Q,...D(X)})}function Rb($,J,Q){return new $({type:"set",valueType:J,...D(Q)})}function Ib($,J,Q){let X=Array.isArray(J)?Object.fromEntries(J.map((Y)=>[Y,Y])):J;return new $({type:"enum",entries:X,...D(Q)})}function jb($,J,Q){return new $({type:"enum",entries:J,...D(Q)})}function bb($,J,Q){return new $({type:"literal",values:Array.isArray(J)?J:[J],...D(Q)})}function WY($,J){return new $({type:"file",...D(J)})}function Pb($,J){return new $({type:"transform",transform:J})}function Ab($,J){return new $({type:"optional",innerType:J})}function Eb($,J){return new $({type:"nullable",innerType:J})}function Cb($,J,Q){return new $({type:"default",innerType:J,get defaultValue(){return typeof Q==="function"?Q():N7(Q)}})}function Sb($,J,Q){return new $({type:"nonoptional",innerType:J,...D(Q)})}function Tb($,J){return new $({type:"success",innerType:J})}function wb($,J,Q){return new $({type:"catch",innerType:J,catchValue:typeof Q==="function"?Q:()=>Q})}function vb($,J,Q){return new $({type:"pipe",in:J,out:Q})}function fb($,J){return new $({type:"readonly",innerType:J})}function hb($,J,Q){return new $({type:"template_literal",parts:J,...D(Q)})}function kb($,J){return new $({type:"lazy",getter:J})}function gb($,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??d3,q=$.Boolean??p3,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,M)=>{let O=Z;if(Q.case!=="sensitive")O=O.toLowerCase();if(W.has(O))return!0;else if(K.has(O))return!1;else return M.issues.push({code:"invalid_value",expected:"stringbool",values:[...W,...K],input:M.value,inst:L,continue:!1}),{}},reverseTransform:(Z,M)=>{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 yb={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=yb[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}))]}},MY=($,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},OY=($,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={}},RY=($,J,Q,X)=>{},IY=($,J,Q,X)=>{},jY=($,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=f3(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},CY=($,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)},SY=($,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:MY,boolean:OY,bigint:NY,symbol:FY,null:VY,undefined:_Y,void:DY,never:zY,any:RY,unknown:IY,date:jY,enum:bY,literal:PY,nan:AY,template_literal:EY,file:CY,success:SY,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 s3($,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 J6={};B2(J6,{time:()=>eY,duration:()=>$W,datetime:()=>aY,date:()=>tY,ZodISOTime:()=>e3,ZodISODuration:()=>$6,ZodISODateTime:()=>a3,ZodISODate:()=>t3});var a3=N("ZodISODateTime",($,J)=>{CX.init($,J),r.init($,J)});function aY($){return T5(a3,$)}var t3=N("ZodISODate",($,J)=>{SX.init($,J),r.init($,J)});function tY($){return w5(t3,$)}var e3=N("ZodISOTime",($,J)=>{TX.init($,J),r.init($,J)});function eY($){return v5(e3,$)}var $6=N("ZodISODuration",($,J)=>{wX.init($,J),r.init($,J)});function $W($){return f5($6,$)}var kH=($,J)=>{x3.init($,J),$.name="ZodError",Object.defineProperties($,{format:{value:(Q)=>O4($,Q)},flatten:{value:(Q)=>M4($,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 M8=N4(z1),O8=F4(z1),N8=V4(z1),F8=_4(z1),V8=O$(z1),_8=N$(z1),D8=F$(z1),z8=V$(z1),R8=_$(z1),I8=D$(z1),j8=z$(z1),b8=R$(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)=>M8($,Q,X,{callee:$.parse}),$.safeParse=(Q,X)=>N8($,Q,X),$.parseAsync=async(Q,X)=>O8($,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)=>R8($,Q,X),$.safeDecode=(Q,X)=>I8($,Q,X),$.safeEncodeAsync=async(Q,X)=>j8($,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=()=>X6($),$.exactOptional=()=>PW($),$.nullable=()=>Y6($),$.nullish=()=>X6(Y6($)),$.nonoptional=(Q)=>wW($,Q),$.array=()=>q6($),$.or=(Q)=>i8([$,Q]),$.and=(Q)=>NW($,Q),$.transform=(Q)=>W6($,n8(Q)),$.default=(Q)=>CW($,Q),$.prefault=(Q)=>TW($,Q),$.catch=(Q)=>hW($,Q),$.pipe=(Q)=>W6($,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(j4(...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(R4(X)),$.uppercase=(X)=>$.check(I4(X)),$.trim=()=>$.check(C4()),$.normalize=(...X)=>$.check(E4(...X)),$.toLowerCase=()=>$.check(S4()),$.toUpperCase=()=>$.check(T4()),$.slugify=()=>$.check(w4())}),x4=N("ZodString",($,J)=>{w2.init($,J),E8.init($,J),$.email=(Q)=>$.check(y$(C8,Q)),$.url=(Q)=>$.check(n3(K6,Q)),$.jwt=(Q)=>$.check(X8(c8,Q)),$.emoji=(Q)=>$.check(p$(S8,Q)),$.guid=(Q)=>$.check(o3(Q6,Q)),$.uuid=(Q)=>$.check(x$(R0,Q)),$.uuidv4=(Q)=>$.check(u$(R0,Q)),$.uuidv6=(Q)=>$.check(m$(R0,Q)),$.uuidv7=(Q)=>$.check(l$(R0,Q)),$.nanoid=(Q)=>$.check(c$(T8,Q)),$.guid=(Q)=>$.check(o3(Q6,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)}),C8=N("ZodEmail",($,J)=>{DX.init($,J),r.init($,J)});function yH($){return y$(C8,$)}var Q6=N("ZodGUID",($,J)=>{VX.init($,J),r.init($,J)});function xH($){return o3(Q6,$)}var R0=N("ZodUUID",($,J)=>{_X.init($,J),r.init($,J)});function uH($){return x$(R0,$)}function mH($){return u$(R0,$)}function lH($){return m$(R0,$)}function pH($){return l$(R0,$)}var K6=N("ZodURL",($,J)=>{zX.init($,J),r.init($,J)});function cH($){return n3(K6,$)}function dH($){return n3(K6,{protocol:/^https?$/,hostname:y1.domain,...w.normalizeParams($)})}var S8=N("ZodEmoji",($,J)=>{RX.init($,J),r.init($,J)});function rH($){return p$(S8,$)}var T8=N("ZodNanoID",($,J)=>{IX.init($,J),r.init($,J)});function iH($){return c$(T8,$)}var w8=N("ZodCUID",($,J)=>{jX.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 S5(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)=>MY($,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 MZ($){return u5(g2,$)}function OZ($){return m5(g2,$)}var l4=N("ZodBoolean",($,J)=>{p3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>OY($,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)=>RY($,Q,X,Y)});function zZ(){return a5(qW)}var UW=N("ZodUnknown",($,J)=>{sX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>IY($,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 RZ($){return $Y(HW,$)}var B6=N("ZodDate",($,J)=>{eX.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>jY($,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 IZ($){return JY(B6,$)}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 q6($,J){return YY(ZW,$,J)}function jZ($){let J=$._zod.def.shape;return o8(Object.keys(J))}var U6=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 U6(Q)}function PZ($,J){return new U6({type:"object",shape:$,catchall:r8(),...w.normalizeParams(J)})}function AZ($,J){return new U6({type:"object",shape:$,catchall:k2(),...w.normalizeParams(J)})}var G6=N("ZodUnion",($,J)=>{c3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>Z8($,Q,X,Y),$.options=J.options});function i8($,J){return new G6({type:"union",options:$,...w.normalizeParams(J)})}var LW=N("ZodXor",($,J)=>{G6.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 MW=N("ZodDiscriminatedUnion",($,J)=>{G6.init($,J),X5.init($,J)});function CZ($,J,Q){return new MW({type:"union",options:J,discriminator:$,...w.normalizeParams(Q)})}var OW=N("ZodIntersection",($,J)=>{Y5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>yY($,Q,X,Y)});function NW($,J){return new OW({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 H6=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 H6({type:"record",keyType:$,valueType:J,...w.normalizeParams(Q)})}function SZ($,J,Q){let X=N1($);return X._zod.values=void 0,new H6({type:"record",keyType:X,valueType:J,...w.normalizeParams(Q)})}function TZ($,J,Q){return new H6({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 RW=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 RW({type:"literal",values:Array.isArray($)?$:[$],...w.normalizeParams(J)})}var IW=N("ZodFile",($,J)=>{G5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>CY($,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(IW,$)}var jW=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 C2($.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 jW({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 X6($){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 Y6($){return new AW({type:"nullable",innerType:$})}function gZ($){return X6(Y6($))}var EW=N("ZodDefault",($,J)=>{M5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>pY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function CW($,J){return new EW({type:"default",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var SW=N("ZodPrefault",($,J)=>{O5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>cY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function TW($,J){return new SW({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)=>SY($,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 W6($,J){return new t8({type:"pipe",in:$,out:J})}var e8=N("ZodCodec",($,J)=>{t8.init($,J),d3.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)=>{R5.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)=>{j5.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)=>{I5.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??q6(k2()),output:$?.output??k2()})}var Z6=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(Z6,$??(()=>!0),J)}function cW($,J={}){return BY(Z6,$,J)}function dW($){return qY($)}var rZ=UY,iZ=GY;function oZ($,J={}){let Q=new Z6({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(),q6(J),_W(P8(),J)])});return J}function aZ($,J){return W6(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 lb=()=>{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:lb()}}var iW=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")};var JJ={};B2(JJ,{string:()=>pb,number:()=>cb,date:()=>ib,boolean:()=>db,bigint:()=>rb});function pb($){return C5(x4,$)}function cb($){return k5(m4,$)}function db($){return p5(l4,$)}function rb($){return d5(p4,$)}function ib($){return QY(B6,$)}Y1(rW());var ob=QJ;var JL=Object.freeze(["hard_stop","use_alternative","scope_down","manual_only","stop_and_explain"]);var L6=64,QL="Rule config exceeds CC Safety Net's safe source limit.";var ch=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."},nb=[".bak",".backup",".copy",".disabled",".old",".orig",".save",".tmp"],sb=[{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"]},...sb.flatMap(($)=>nb.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"}],ab=[".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(($)=>ab.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]:[])),tb=YL.map(($)=>$.id),WJ=new Set(tb);var Yk=eb(import.meta.url),KL,$P=Array(L6+1).fill("over-limit"),BL=/^[^/]+\/[^/]+$/,JP=/^sha256:[a-f0-9]{64}$/,KJ=`must be an integer between ${HJ} and ${ZJ}`,QP=["version","rules","overrides","transparent_wrappers"],XP=["version","safety","workflow","destructive_command_protection","secret_protection","audit"];function qL($){if(!i1($)||!Array.isArray($.rules)||$.rules.length<=L6)return $;return{$schema:$.$schema,version:$.version,rules:$P,overrides:$.overrides,transparent_wrappers:$.transparent_wrappers}}function YP(){let $=oW,J=(_)=>{let j=$.superRefine(_);return j._zod.def.when=()=>!0,j},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(M2,"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(L6,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=(_,j)=>{if(!i1(_))return;if(Array.isArray(_.rules)&&_.rules.length<=L6){let C=new Set;_.rules.forEach((T,y)=>{if(typeof T!=="string"||T==="")return;if(T.trim()===""){j.addIssue({code:"custom",message:"must be a non-empty rulebook source string",path:["rules",y]});return}let x=o4(T);if(x){j.addIssue({code:"custom",message:x,path:["rules",y]});return}if(C.has(T)){j.addIssue({code:"custom",message:`duplicate rulebook source "${T}"`,path:["rules",y]});return}C.add(T)})}if(i1(_.overrides))for(let C of Object.keys(_.overrides)){if(BL.test(C))continue;j.addIssue({code:"custom",message:"must use <rulebook-name>/<rule-name>",path:["overrides",C]})}if(!Array.isArray(_.transparent_wrappers))return;let P=new Set;_.transparent_wrappers.forEach((C,T)=>{if(typeof C!=="string"||!M2.test(C))return;if(P.has(C)){j.addIssue({code:"custom",message:`duplicate command "${C}"`,path:["transparent_wrappers",T]});return}if(LU(C)){j.addIssue({code:"custom",message:`reserved command "${C}" cannot be a wrapper`,path:["transparent_wrappers",T]});return}P.add(C)})},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=(_,j)=>$.intersection($.record($.string().refine((P)=>_.has(P),{error:(P)=>`unknown ${j} 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((j,P)=>{if(!Array.isArray(j))return;let C=c2();j.forEach((T,y)=>{if(typeof T!=="string")return;let x=_(T,C);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(r6,"destructive command").optional(),allow_paths:L(C9).optional()}).optional(),secret_protection:$.strictObject({enabled:$.boolean().optional(),overrides:H(WJ,"secret protection").optional(),deny_paths:L(S9).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()}),M=(_)=>{let j=(y,x)=>_==="legacy"?y:x,P=j("must match pattern (letters, numbers, hyphens, underscores)","must match command pattern"),C=`required non-empty string up to ${o2} characters`,T=$.looseObject({name:$.string({error:"required string"}).regex(Y0,j("must match pattern (letters, numbers, hyphens, underscores; max 64 chars)","must match rule name pattern")),command:$.string({error:j("required string","required string matching command pattern")}).regex(M2,j(P,"required string matching command pattern")),subcommand:$.string({error:j("must be a string if provided","must match command pattern")}).regex(M2,P).optional(),block_args:$.array($.string({error:j("must be a string","must be a non-empty string")}).refine((y)=>y!=="",{error:j("must not be empty","must be a non-empty string")}),{error:j("required array","required non-empty array")}).refine((y)=>y.length>0,{error:j("must have at least one element","required non-empty array")}),reason:$.string({error:j("required string",C)}).refine((y)=>y!=="",{error:j("must not be empty",C)}).refine((y)=>y.length<=o2,{error:j(`must be at most ${o2} characters`,C)}),intent:Q.optional()},{error:"must be an object"});return $.array(T,{error:j("must be an array","required array")}).check(J((y,x)=>{if(!Array.isArray(y))return;let c=new Set;y.forEach((V1,S)=>{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:[S,"name"]});return}c.add(m.toLowerCase())})}))},O=$.looseObject({version:$.literal(1),rules:M("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((_,j)=>{if(!i1(_))return;if(_.expect!=="blocked"||typeof _.rule==="string")return;j.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(M2,"must match command pattern"),{error:"required array"}).check(J((_,j)=>{if(!Array.isArray(_))return;let P=new Set;_.forEach((C,T)=>{if(typeof C!=="string"||!M2.test(C))return;if(P.has(C)){j.addIssue({code:"custom",message:`duplicate command "${C}"`,path:[T]});return}P.add(C)})})),rules:M("rulebook"),tests:$.array(F,{error:"must be an array if provided"}).optional()}).check(J((_,j)=>{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;j.addIssue({code:"custom",message:`blocked fixture references unknown rule "${y}"`,path:["tests"]})}}if(!Array.isArray(_.allowed_commands)||!Array.isArray(_.rules))return;let C=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"||C.has(x))return;j.addIssue({code:"custom",message:`"${x}" must be listed in allowed_commands`,path:["rules",y,"command"]})})})),R=$.string({error:"required string"}).refine((_)=>_.trim()!=="",{error:"required string"}),A=$.looseObject({spec:R,name:R,version:R,digest:$.string({error:"required sha256 digest"}).regex(JP,"required sha256 digest")},{error:"must be an object"}),E=$.looseObject({rulebooks:$.array($.intersection(A,$.discriminatedUnion("kind",[$.object({kind:$.literal("local-directory"),path:R}),$.object({kind:$.literal("github"),owner:R,repo:R,ref:R,commit:R,path:R,display_ref:$.unknown().optional()})],{error:(_)=>{if(!i1(_.input))return"must be an object";let j=_.input.kind;return typeof j==="string"?`unknown kind "${j}"`:"required string"}})))});return{RulesConfigSchema:q,RulesConfigDiagnosticSchema:U,RuleOverrideSchema:X,UserPolicySchema:Z,LegacyConfigSchema:O,RulebookSchema:b,RulesLockfileSchema:E}}function O6(){return KL??=YP(),KL}function UL(){return O6().RulesConfigSchema}function WP(){return O6().UserPolicySchema}function GL(){return O6().RulebookSchema}function HL(){return O6().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=O6().RulesConfigDiagnosticSchema.safeParse($);if(J.success)return{errors:[],sources:new Set(J.data.rules)};return{errors:c4(OL(J.error.issues,QP)),sources:UP($,J.error.issues)}}function LL($){let J=WP().safeParse($);if(J.success)return[];return c4(OL(J.error.issues,XP)," ")}function c4($,J=": ",Q=" "){return[...new Set($.flatMap((X)=>ML(X,J,Q,[])))]}function ML($,J,Q,X){let Y=[...X,...$.path],W=qP(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)=>ML(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}${KP($)}`]}function KP($){if($.code==="invalid_value")return`must be ${BP($.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 BP($){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 qP($){return $.map((J,Q)=>{if(typeof J==="number")return`[${J}]`;return Q===0?String(J):`.${String(J)}`}).join("")}function OL($,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 UP($,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 GP($){return ZL($)}function QK($){try{let J=q2(HP($));if(J===null)return{config:null,errors:[]};if(!J.trim())return{config:null,errors:["Config file is empty"]};let Q=JSON.parse(J),X=GP(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 HP($){return typeof $==="string"?P6($):$}var NP=new Set(["standard","strict","paranoid"]),FP={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:R6}};function XK($){return OP(MP(U2($)),C6)}function FL($={}){let J=RP(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 VP($){if(!y0($))return zP();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:NP.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,r6),allow_paths:DP(Y.allow_paths)},secret_protection:{enabled:typeof W.enabled==="boolean"?W.enabled:!0,overrides:NL(W.overrides,WJ),deny_paths:_P(W.deny_paths)},audit:{retention_days:I6(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 _P($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>S9(Q,J)===null)}function DP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>C9(Q,J)===null)}function y0($){return!!$&&typeof $==="object"&&!Array.isArray($)}function zP(){return structuredClone(FP)}function RP($){let J=IP();if(!ZP($))return{policy:J,errors:[]};try{let Q=LP($,"utf-8");if(!Q.trim())return{policy:J,errors:[`${$}: Config file is empty`],fallback:"defaults"};let X=JSON.parse(Q),Y=LL(X),W=jP(VP(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 IP(){return{safety:{},worktreeMode:!1,destructiveCommandProtectionEnabled:!0,destructiveCommandRuleOverrides:{},destructiveCommandAllowPaths:[],secretProtection:{enabled:!0,disabledRules:VL({}),denyPaths:[]}}}function jP($){return{safety:bP($.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 bP($){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.",PP=new Set(["[","cat","file","grep","head","jq","less","ls","more","rg","sed","stat","tail","test","wc"]);function IL($){let J=H2(A0()),Q=wP($.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"||j9($.invocation.toolName),$.invocation.context.executionCwd,Q,J)}function _L($,J,Q,X,Y){if(J)return null;let W=$.find((K)=>N6(K,Q,X,Y));return W?{target:W}:null}function DL($,J,Q,X){let Y=P9($,J,X,{findSegmentTarget:(W,K)=>AP(W,K,Q,X)?.target??null,isRedirectionTarget:(W,K)=>N6(W,K.cwd,Q,X),findMalformedTarget:(W)=>TP(W,J,Q,X)?.target??null,normalizeCwd:O1});return Y?{target:Y}:null}function AP($,J,Q,X){if(M3($))return null;let Y=X.environment,W=l1([...$],Y),K=l(W[0]??"").toLowerCase(),B=W.slice(1);if(K==="rm"&&EP(B)){let q=CP(B).find((U)=>zL(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(K==="find"){if(y9(W,1)||AQ(W,Y)){let U=(g9(p(W))??p(["."])).find((G)=>{let H=f1(G.text,J.variables);return N6(H,J.cwd,Q,X)||zL(H,J.cwd,Q,X)})?.text;if(U)return{target:U}}}if(K==="mv"){let q=A9(B).sources.find((U)=>vP(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(SP($,Y))return null;for(let q of $)for(let U of jL(q))if(N6(f1(U,J.variables),J.cwd,Q,X))return{target:U};return null}function EP($){return $.some((J)=>J==="--recursive"||J.startsWith("-")&&!J.startsWith("--")&&/[rR]/.test(J.slice(1)))}function CP($){let J=$.indexOf("--");if(J!==-1)return[...$.slice(0,J).filter((Q)=>!Q.startsWith("-")),...$.slice(J+1)];return $.filter((Q)=>!Q.startsWith("-"))}function SP($,J){let Q=l1([...$],J);if(Q.length===0)return!1;let X=l(Q[0]??"").toLowerCase();if(!PP.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 TP($,J,Q,X){for(let Y of $.split(/\s+/))for(let W of jL(Y))if(N6(W,J,Q,X))return{target:W};return null}function jL($){let J=$.trim().replace(/^['"]|['"]$/g,""),Q=J.indexOf("=");return Q===-1||Q===J.length-1?[J]:[J,J.slice(Q+1)]}function wP($,J){let Q=O1(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 N6($,J,Q,X){return d4(O1($,J,X))===Q.file}function zL($,J,Q,X){return Q.directoryAndAncestors.has(d4(O1($,J,X)))}function vP($,J,Q,X){let Y=d4(O1($,J,X));return Y===Q.file||Q.directoryAndAncestors.has(Y)}function d4($){return process.platform==="win32"?$.toLowerCase():$}import{homedir as fP}from"node:os";import{isAbsolute as KK,resolve as vL}from"node:path";import{fileURLToPath as hP}from"node:url";var fL="Access to a sensitive path is not allowed.",hL=new Set(["echo","printf"]),kP=new Set(["find"]),gP=new Set(["-exec","-execdir"]),yP=new Set([";","+"]),xP=new Set(["-delete","-exec","-execdir","-fls","-fprint","-fprint0","-fprintf","-ok","-okdir"]),uP=new Set(["-name","-iname","-path","-ipath","-wholename","-iwholename","-samefile"]),mP=new Set(["python","python2","python3","node","deno","bun","ruby","perl","php","rscript","osascript","bash","sh","zsh","dash","ksh"]),lP=new Set(["node","bun"]),pP=new Set(["bun","child_process","deno","dotenv","fs","subprocess"]),cP=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"]),dP=new Set(["src/cli/cc-safety-net.ts","dist/bin/cc-safety-net.js"]),rP=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"])]]),iP=new Set(["grep","rg"]),bL="f",PL="file",oP="files",nP=new Set(["e","f"]),sP=new Set(["regexp","file"]),aP=new Set(["e","f","A","B","C","m"]),tP=new Set(["regexp","file","after-context","before-context","context","max-count"]),eP=new Set(["|","|&"]),WK="__CC_SAFETY_NET_PIPE_INPUT__",gL=new Set(["bash","sh","zsh","dash","ksh"]),$A=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(yA(K,J,Q?.denyPaths??[],X,W))return{target:K,ruleId:"secret.deny-path"};if(Y&&!Y.has(K))continue;let B=kA(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&&JA($))return null;return K}function JA($){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)=>xP.has(K))}function EL($,J={}){if($.invocation.route.kind==="command"){let X=w1($,"input-candidate");return X?_6(X.shell,$.store,J):[]}if($.invocation.route.kind!=="unknown")return $.paths.map((X)=>X.raw);let Q=w1($,"input-candidate");return[...Q?_6(Q.shell,$.store,J):[],...$.paths.map((X)=>X.raw)]}function _6($,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,...zA(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(...CL(W,Y,J,Q));W=eP.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(...CL(W,Y,J,Q))}return X}function BJ($,J,Q){let X=HA($),Y=i4($);if(Y.length===0)return X;let W=Y[0]??"",K=y2(W).toLowerCase(),B=Y.slice(1),q=QA(W,K,B);if(q)return[...X,...q];if(hL.has(K))return X;if(iP.has(K))return[...X,...CA(B)];if(kP.has(K))return[...X,...ZA(B,J,Q)];if(h1.has(K))return[...X,...B.flatMap((U)=>SL("awk",U)),...B.flatMap((U)=>MA(U,J,Q)),...B.flatMap(OA)];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,...LA(K,B,Q)]}return[...X,...B.flatMap((U)=>SL(K,U))]}function QA($,J,Q){let X=J==="cc-safety-net"&&Q[0]==="explain",Y=(J==="bun"||J==="node")&&XA(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 XA($){let J=$?.replaceAll("\\","/");return[...dP].some((Q)=>J===Q||J?.endsWith(`/${Q}`))}function CL($,J,Q,X){if(qA(J,Q,X))return YA($);let Y=UA(J);if(Y===null)return[];return WA($).flatMap((W)=>gL.has(Y)?_6(Q.getShellSyntax(W),Q,X):pL(W))}function YA($){let J=i4($);if(J.length===0)return[];let Q=y2(J[0]??"").toLowerCase();if(!hL.has(Q))return[];return J.slice(1)}function WA($){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 KA(X);return[]}function KA($){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)=>BA(J,X.slice(W*Q,(W+1)*Q)))}function BA($,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,`
|
|
100
|
-
`).replace(/\\t/g,"\t").replace(/\\r/g,"\r")}function qA($,J,Q){let X=i4($);if(X.length===0||y2(X[0]??"").toLowerCase()!=="xargs")return!1;let Y=j2(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 UA($){let J=i4($);if(J.length===0)return null;let Q=y2(J[0]??"").toLowerCase();if(!
|
|
101
|
-
`||K==="\r"))return null;if(K!==X)continue;Q=W,Y=!0;break}if(!Y)return null}return J.join("")}function FA($,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 VA($){for(let J of $.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/g)){let Q=J[0],X=J.index;if(pP.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)=>cP.has(W)))continue;if(Y.length>1)return!0;if(_A($,X)===".")return!0;if(DA($,X+Q.length)==="(")return!0}return!1}function _A($,J){for(let Q=J-1;Q>=0;Q--)if(!/\s/.test($[Q]??""))return $[Q];return}function DA($,J){for(let Q=J;Q<$.length;Q++)if(!/\s/.test($[Q]??""))return $[Q];return}function zA($,J,Q){return PA($).flatMap((X)=>{let Y=J.getShellSyntax(X);if(Y.status==="invalid")return[];return[..._6(Y,J,Q),...RA(Y)?IA(Y):[]]})}function RA($){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 IA($){return $.entries.flatMap((J)=>J.kind==="word"?[G0(J.text)]:J.kind==="redirection"&&J.target?[G0(J.target)]:[]).flatMap(cL)}function cL($){let J=bA($);if(J===null)return[];let Q=Buffer.from(J,"base64").toString("utf8");if(Q===""||jA(Q))return[];return Buffer.from(Q,"utf8").toString("base64").replace(/=+$/g,"")===J.replace(/=+$/g,"")?[Q]:[]}function jA($){return Array.from($).some((J)=>{let Q=J.charCodeAt(0);return Q<32||Q===127})}function bA($){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 PA($){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=AA($,X+1);if(W!==null)J.push(W.body),X=W.endIndex;continue}if(!Q.inSingle&&Y==="`"){let W=EA($,X);if(W!==null)J.push(W.body),X=W.endIndex}}return J}function AA($,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 EA($,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 CA($){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===oP)Y=!0;if(sP.has(H))X=!0;if(L!==void 0){if(H===PL)J.push(L);continue}if(tP.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 M=0;M<H.length;M++){let O=H[M]??"";if(nP.has(O))X=!0;if(aP.has(O)){L=O,Z=H.slice(M+1);break}}if(L!=="")if(Z.length>0){if(L===bL)J.push(Z)}else{let M=$[q+1];if(L===bL&&M!==void 0)J.push(M);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 SA=new Set(["id_rsa.pub","id_ed25519.pub","id_ecdsa.pub"]),TA=".env.",wA=new Set([".env.example",".env.sample",".env.template",".env.defaults"]),vA=[".env.example.",".env.sample."],fA=new Set(["node_modules","__pycache__"]),hA=[["vendor","bundle"],["vendor","cache"]];function kA($,J,Q,X){let Y=u0($,J,X);if(!Y)return null;let W=G1(Y.split("/").pop()??""),K=G1(Y);if(wA.has(W)||vA.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=gA(Y,J,Q,X);if(B)return B;if(SA.has(W))return null;for(let U of nW)if(W===U.basename&&x0(U.id,Q))return U.id;if(W.startsWith(TA)&&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(xA(K))return null;if(!W.includes(".")&&M6.pattern.test(W)&&x0(M6.id,Q))return M6.id;let q=uA(W,Q);if(q)return q;return null}function gA($,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"])||V6($,"~/.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"])||F6($,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()?V6($,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"])||F6($,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"])||F6($,W,["credentials"])||F6($,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)=>V6($,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()?V6($,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"]))||F6($,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()?V6($,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 F6($,J,Q){return Q.some((X)=>qJ(G1($),G1(F1(J,X))))}function V6($,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 yA($,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 xA($){let J=$.split("/");return J.some((Q)=>fA.has(Q))||hA.some(([Q,X])=>J.some((Y,W)=>Y===Q&&J[W+1]===X))}function uA($,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??fP(),X=Q?r4(J1(Q,i0,J)):"",Y=r4(mA(G0($)));return{home:X,normalized:Y}}function mA($){if(!$.trim().toLowerCase().startsWith("file:"))return $;try{return hP($)}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"node: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 lA($){if(!pA($))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=lA($);if(J.errors.length>0)throw Error(J.errors.join("; "));return $}function pA($){return!!$&&typeof $==="object"&&!Array.isArray($)}function UK($){if(E6($.spec))return rA($);return dA($)}function dA($){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 rA($){let J=o4($.spec);if(J)return J;let Q=A6($.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"?P6($):$);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 iA}from"node:crypto";var Pg=Object.freeze({timeoutMs:15000,metadataBytes:524288,commitBytes:262144,treeBytes:16777216,rawBytes:4194304});function $M($){return`sha256:${iA("sha256").update($).digest("hex")}`}function WM($={}){let J=CK($),Q=!1;try{Q=zK(J.userConfigTarget,J.projectConfigTarget)}catch(L){if(L instanceof W1)return aA(J,L.message);throw L}let X=QK(J.userConfigTarget),Y=Q?{config:null,errors:[]}:QK(J.projectConfigTarget),W=YM(J.userConfigPath,X.errors),K=YM(J.projectConfigPath,Y.errors),B=new Set,q=X.config?JM(X.config,J.userLockPath,UJ(J.userConfigPath),$,"user",J.userScope,B):D6(),U=Y.config?JM(Y.config,J.projectLockPath,UJ(J.projectConfigPath),$,"project",J.projectScope,B):D6(),G=X.config?.overrides??{},H=Y.config?.overrides??{};return{rules:[...QM(q.rules,G),...QM(U.rules,H)],transparent_wrappers:nA(X.config,Y.config),rulebooks:[...q.rulebooks,...U.rulebooks],errors:[...W,...K,...q.errors,...U.errors],warnings:[...q.warnings,...U.warnings,...q.canValidateOverrides?XM(G,q.knownRuleIds,J.userConfigPath):[],...q.canValidateOverrides?sA(H,q.knownRuleIds,J.projectConfigPath):[],...U.canValidateOverrides?XM(H,U.knownRuleIds,J.projectConfigPath):[]],userConfig:X.config??void 0,projectConfig:Y.config??void 0,...J}}function JM($,J,Q,X,Y,W=m0(UJ(UJ(Q)),Y==="user"?"user policy":"project policy"),K=new Set){let B;try{B=j0(W,J)}catch(V){if(V instanceof W1)return{...D6(),errors:[V.message],canValidateOverrides:!1};throw V}let q=eL(B);if(q.errors.length>0)return{...D6(),errors:q.errors,canValidateOverrides:!1};let U=q.lock;if(!U&&$.rules.length>0)return{...D6(),errors:[`missing lockfile ${J}; run ${c0}`],canValidateOverrides:!1};let G=U?.rulebooks??[],H=new Map(G.map((V)=>[V.spec,V])),L=[],Z=[],M=$.rules.flatMap((V)=>{let F=H.get(V);if(!F)return L.push(`missing lock entry for ${V}; run ${c0}`),[];let b=oA(F,Q,X,W);if(b.errors.length>0||!b.rulebook)return L.push(...b.errors),[];let R=b.rulebook;if(K.has(R.name))return Z.push(`duplicate active rulebook name "${R.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(R.name),[{rules:R.rules.map((A)=>({...A,name:`${R.name}/${A.name}`})),rulebook:{source:Y,spec:F.spec,name:R.name,version:R.version,rules:R.rules.map((A)=>`${R.name}/${A.name}`)}}]}),O=M.flatMap((V)=>V.rules);return{rules:O,rulebooks:M.map((V)=>V.rulebook),entries:G,knownRuleIds:new Set(O.map((V)=>V.name)),errors:L,warnings:Z,canValidateOverrides:L.length===0}}function oA($,J,Q,X){let Y=VJ($,_J(J,Q)),W;try{W=q2(j0(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($M(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 nA($,J){return[...new Set([...$?.transparent_wrappers??[],...J?.transparent_wrappers??[]])]}function QM($,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 XM($,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 sA($,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 YM($,J){return J.map((Q)=>Q.startsWith("Unable to access ")?Q:`${$}: ${Q}`)}function aA($,J){return{rules:[],transparent_wrappers:[],rulebooks:[],errors:[J],warnings:[],userConfigPath:$.userConfigPath,projectConfigPath:$.projectConfigPath,userLockPath:$.userLockPath,projectLockPath:$.projectLockPath}}function D6(){return{rules:[],rulebooks:[],entries:[],knownRuleIds:new Set,errors:[],warnings:[],canValidateOverrides:!0}}function KM($={}){let J=WM($),Q=FL($),X={rules:J.rules,transparentWrappers:J.transparent_wrappers,safety:XE(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}),...JE(B.spec)?{source:B.spec}:{}}:{},...q&&typeof q==="object"?{override:Object.freeze({type:"reason",reason:q.reason})}:{}})]})));return QE(X,tA(J,Q),W)}function tA($,J){let Q=$E(J);if($.errors.length===0&&$.warnings.length===0&&!Q)return;return{diagnostics:[...$.errors,...$.warnings,...J.errors],reason:YE($.errors.length>0?eA($.errors):void 0,$.warnings.length>0?GK($.warnings.join("; ")):void 0,Q)}}function eA($){return`${GK($.join("; "))} Those rule sources are not active; every other rule and all built-in protections still apply`}function $E($){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 JE($){return/^(?:[A-Za-z0-9_.-]+$|https:\/\/github\.com\/|github:|gh:|[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:#|$))/.test($)}function QE($,J,Q=Object.freeze({})){let X=BM(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 XE($){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 BM($){if(typeof $!=="object"||$===null)return $;for(let J of Object.values($))BM(J);return Object.freeze($)}function YE(...$){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 WE={findPolicyMutation:IL,findGitMetadataMutation:cq,resolveGitMetadata:LQ,loadPolicySnapshot:KM,findSensitiveTarget:yL,analyzeCommand:XH,getModes:U7};function qM($,J={}){let Q={...WE,...J.dependencies},X=qE($),Y=z6($)?$.command:X,W=x2("policy-protection",Y,()=>b9($,J.factParserDependencies)),K=w1(W,"declared-command");if(z6($)&&$.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:dK,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,...KE(G)},M=H.secretProtection.enabled===!1?null:x2("secret-protection",Y,()=>Q.findSensitiveTarget(W,H.secretProtection,{strict:z6($)?L.strict:void 0}));if(M){let V=Y??M.target;return{stage:"secret-protection",...Z,decision:{kind:"deny",reason:fL,intent:"hard_stop",ruleId:M.ruleId,evidence:[{kind:"command",command:V,segment:M.target},{kind:"path",target:M.target}]}}}if(!z6($))return{stage:"non-command",...Z,decision:{kind:"allow"}};if(!$.command||$.command.trim()==="")return{...HK("command-validation",Y),...Z};let O=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},BE(W),W.store)});if(O)return{stage:"command-analysis",...Z,decision:O};return{stage:"command-analysis",...Z,decision:{kind:"allow"}}}function KE($){if($.state==="ready")return{};return{configFallback:{reason:$.reason}}}function BE($){return w1($,"declared-command")?.program}function qE($){try{return J4($.input)}catch(J){let Q=z6($)?$.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:w6,intent:"stop_and_explain",evidence:J?[{kind:"command",command:J,segment:J}]:[]}}}function z6($){return $.route.kind==="command"}function GM($,J){try{let Q=qM($,J.guard);return UM($,Q,J),Q}catch(Q){if(!(Q instanceof K2))throw Q;throw UM($,Q.evaluation,J,!(Q.cause instanceof T0),{stage:Q.stage,errorCode:UE(Q.cause)}),Q}}function UM($,J,Q,X=!0,Y){uK(xK($,J,Q.guard?.auditAllowed??!1,X,Y),Q.audit.getSessionId,{agent:Q.audit.agent,shape:Q.audit.shape,homeDir:Q.audit.homeDir})}function UE($){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 ZM="exec",GE=new Set(["auto","gateway"]);function LM($){$.on("before_tool_call",HE($),{matcher:[ZM],priority:50})}function HE($,J={}){return(Q,X)=>{if(X.abortSignal?.aborted)return ZK(jJ());let Y=ZE(Q,X,$);if(!Y)return;let W=()=>X.sessionId??X.sessionKey;if("malformed"in Y)return mK(Y.denial,W,{agent:"openclaw",toolName:Y.denial.toolName,cwd:Y.cwd}),ZK(Y.denial);try{let K=GM(Y,{guard:{auditAllowed:B7(),dependencies:J.guardDependencies},audit:{agent:"openclaw",getSessionId:W}});return HM(K,K.stage!=="config-state")}catch(K){if(!(K instanceof K2))throw K;if(h0(B1.debug))console.error(`CC Safety Net debug: openclaw before_tool_call analysis failed: ${sK(K.cause)}`);return HM(K.evaluation,!0)}}}function ZE($,J,Q){if(!$||typeof $!=="object")return u2(null);let X=$.toolName;if(typeof X!=="string"||X.trim()==="")return u2(null);if(X!==ZM)return;let Y=$.params;if(!Y||typeof Y!=="object"||Array.isArray(Y))return u2(null,X);let W=Y,K=W.command;if(typeof K!=="string"||K.trim()==="")return u2(null,X);if(W.host!==void 0&&!GE.has(W.host))return u2(null,X,K);let B=LE(Q,J.agentId);if(!B)return u2(null,X,K);let q=ME(B,W);if(!q)return u2(B,X,K,typeof W.workdir==="string"?W.workdir:void 0);return Y$(X,W,{kind:"command",shell:"auto"},{configCwd:B,executionCwd:q},K)}function LE($,J){if(typeof J!=="string"||J.trim()==="")return;try{let Q=$.runtime.agent.resolveAgentWorkspaceDir($.config,J);if(typeof Q!=="string"||Q.trim()==="")return;return T6(".",[Q])}catch{return}}function ME($,J){if(!Object.hasOwn(J,"workdir")||J.workdir===void 0)return $;let Q=J.workdir;if(typeof Q!=="string"||Q.trim()==="")return;return T6(Q,[$])}function u2($,J,Q,X){return{malformed:!0,denial:jJ({command:Q,segment:X,toolName:J}),cwd:$}}function HM($,J){let Q=oK($,{includeEvidence:J});return Q?ZK(Q):void 0}function ZK($){return{block:!0,blockReason:nK($)}}var Dy={...OK,register:LM};export{Dy as default};
|
|
99
|
+
`)}Z.write("payload.value = newResult;"),Z.write("return payload;");let b=Z.compile();return(R,A)=>b(L,R,A)},W,K=S2,B=!w3.jitless,U=B&&O7.value,G=J.catchall,H;$._zod.parse=(L,Z)=>{H??(H=X.value);let M=L.value;if(!K(M))return L.issues.push({expected:"object",code:"invalid_type",input:M,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 SH([],M,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 c3=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)=>h3(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)=>{c3.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,c3.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(!S2(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"&&u3.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(k3.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(k3.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=f3(J.entries),X=new Set(Q);$._zod.values=X,$._zod.pattern=new RegExp(`^(${Q.filter((Y)=>k3.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 C2($.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 RH($,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(`^(${h3(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)=>RH(W,Q.value));return RH(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(`^(${h3(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)}}),M5=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)=>IH(W,J));return IH(Y,J)}});function IH($,J){if($.value===void 0)$.value=J.defaultValue;return $}var O5=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)=>jH(W,$));return jH(Y,$)}});function jH($,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 C2("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 d3=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)=>C$(K,J,X));return C$(W,J,X)}else{let W=J.out._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>C$(K,J,X));return C$(W,J,X)}}});function C$($,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)=>S$($,W,J.out,Q));return S$($,Y,J.out,Q)}else{let Y=J.reverseTransform($.value,$);if(Y instanceof Promise)return Y.then((W)=>S$($,W,J.in,Q));return S$($,Y,J.in,Q)}}function S$($,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 R5=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}}),I5=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 M$($._def.input,X):X,W=await Reflect.apply(Q,this,Y);if($._def.output)return await M$($._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})},$}),j5=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 r3={};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 i3(){return new A5}(wH=globalThis).__zod_globalRegistry??(wH.__zod_globalRegistry=i3());var E1=globalThis.__zod_globalRegistry;function E5($,J){return new $({type:"string",...D(J)})}function C5($,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 o3($,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 n3($,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 S5($,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 j$({check:"less_than",...D(J),value:$,inclusive:!1})}function x1($,J){return new j$({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 R4($){return new qX({check:"string_format",format:"lowercase",...D($)})}function I4($){return new UX({check:"string_format",format:"uppercase",...D($)})}function j4($,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 MX({check:"mime_type",mime:$,...D(J)})}function Q0($){return new OX({check:"overwrite",tx:$})}function E4($){return Q0((J)=>J.normalize($))}function C4(){return Q0(($)=>$.trim())}function S4(){return Q0(($)=>$.toLowerCase())}function T4(){return Q0(($)=>$.toUpperCase())}function w4(){return Q0(($)=>M7($))}function YY($,J,Q){return new $({type:"array",element:J,...D(Q)})}function Fb($,J,Q){return new $({type:"union",options:J,...D(Q)})}function Vb($,J,Q){return new $({type:"union",options:J,inclusive:!1,...D(Q)})}function _b($,J,Q,X){return new $({type:"union",options:Q,discriminator:J,...D(X)})}function Db($,J,Q){return new $({type:"intersection",left:J,right:Q})}function zb($,J,Q,X){let Y=Q instanceof v;return new $({type:"tuple",items:J,rest:Y?Q:null,...D(Y?X:Q)})}function Rb($,J,Q,X){return new $({type:"record",keyType:J,valueType:Q,...D(X)})}function Ib($,J,Q,X){return new $({type:"map",keyType:J,valueType:Q,...D(X)})}function jb($,J,Q){return new $({type:"set",valueType:J,...D(Q)})}function bb($,J,Q){let X=Array.isArray(J)?Object.fromEntries(J.map((Y)=>[Y,Y])):J;return new $({type:"enum",entries:X,...D(Q)})}function Pb($,J,Q){return new $({type:"enum",entries:J,...D(Q)})}function Ab($,J,Q){return new $({type:"literal",values:Array.isArray(J)?J:[J],...D(Q)})}function WY($,J){return new $({type:"file",...D(J)})}function Eb($,J){return new $({type:"transform",transform:J})}function Cb($,J){return new $({type:"optional",innerType:J})}function Sb($,J){return new $({type:"nullable",innerType:J})}function Tb($,J,Q){return new $({type:"default",innerType:J,get defaultValue(){return typeof Q==="function"?Q():N7(Q)}})}function wb($,J,Q){return new $({type:"nonoptional",innerType:J,...D(Q)})}function vb($,J){return new $({type:"success",innerType:J})}function fb($,J,Q){return new $({type:"catch",innerType:J,catchValue:typeof Q==="function"?Q:()=>Q})}function hb($,J,Q){return new $({type:"pipe",in:J,out:Q})}function kb($,J){return new $({type:"readonly",innerType:J})}function gb($,J,Q){return new $({type:"template_literal",parts:J,...D(Q)})}function yb($,J){return new $({type:"lazy",getter:J})}function xb($,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??d3,q=$.Boolean??p3,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,M)=>{let O=Z;if(Q.case!=="sensitive")O=O.toLowerCase();if(W.has(O))return!0;else if(K.has(O))return!1;else return M.issues.push({code:"invalid_value",expected:"stringbool",values:[...W,...K],input:M.value,inst:L,continue:!1}),{}},reverseTransform:(Z,M)=>{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 ub={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=ub[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}))]}},MY=($,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},OY=($,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={}},RY=($,J,Q,X)=>{},IY=($,J,Q,X)=>{},jY=($,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=f3(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},CY=($,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)},SY=($,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:MY,boolean:OY,bigint:NY,symbol:FY,null:VY,undefined:_Y,void:DY,never:zY,any:RY,unknown:IY,date:jY,enum:bY,literal:PY,nan:AY,template_literal:EY,file:CY,success:SY,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 s3($,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 J6={};B2(J6,{time:()=>eY,duration:()=>$W,datetime:()=>aY,date:()=>tY,ZodISOTime:()=>e3,ZodISODuration:()=>$6,ZodISODateTime:()=>a3,ZodISODate:()=>t3});var a3=N("ZodISODateTime",($,J)=>{CX.init($,J),r.init($,J)});function aY($){return T5(a3,$)}var t3=N("ZodISODate",($,J)=>{SX.init($,J),r.init($,J)});function tY($){return w5(t3,$)}var e3=N("ZodISOTime",($,J)=>{TX.init($,J),r.init($,J)});function eY($){return v5(e3,$)}var $6=N("ZodISODuration",($,J)=>{wX.init($,J),r.init($,J)});function $W($){return f5($6,$)}var kH=($,J)=>{x3.init($,J),$.name="ZodError",Object.defineProperties($,{format:{value:(Q)=>O4($,Q)},flatten:{value:(Q)=>M4($,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 M8=N4(z1),O8=F4(z1),N8=V4(z1),F8=_4(z1),V8=O$(z1),_8=N$(z1),D8=F$(z1),z8=V$(z1),R8=_$(z1),I8=D$(z1),j8=z$(z1),b8=R$(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)=>M8($,Q,X,{callee:$.parse}),$.safeParse=(Q,X)=>N8($,Q,X),$.parseAsync=async(Q,X)=>O8($,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)=>R8($,Q,X),$.safeDecode=(Q,X)=>I8($,Q,X),$.safeEncodeAsync=async(Q,X)=>j8($,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=()=>X6($),$.exactOptional=()=>PW($),$.nullable=()=>Y6($),$.nullish=()=>X6(Y6($)),$.nonoptional=(Q)=>wW($,Q),$.array=()=>q6($),$.or=(Q)=>i8([$,Q]),$.and=(Q)=>NW($,Q),$.transform=(Q)=>W6($,n8(Q)),$.default=(Q)=>CW($,Q),$.prefault=(Q)=>TW($,Q),$.catch=(Q)=>hW($,Q),$.pipe=(Q)=>W6($,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(j4(...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(R4(X)),$.uppercase=(X)=>$.check(I4(X)),$.trim=()=>$.check(C4()),$.normalize=(...X)=>$.check(E4(...X)),$.toLowerCase=()=>$.check(S4()),$.toUpperCase=()=>$.check(T4()),$.slugify=()=>$.check(w4())}),x4=N("ZodString",($,J)=>{w2.init($,J),E8.init($,J),$.email=(Q)=>$.check(y$(C8,Q)),$.url=(Q)=>$.check(n3(K6,Q)),$.jwt=(Q)=>$.check(X8(c8,Q)),$.emoji=(Q)=>$.check(p$(S8,Q)),$.guid=(Q)=>$.check(o3(Q6,Q)),$.uuid=(Q)=>$.check(x$(R0,Q)),$.uuidv4=(Q)=>$.check(u$(R0,Q)),$.uuidv6=(Q)=>$.check(m$(R0,Q)),$.uuidv7=(Q)=>$.check(l$(R0,Q)),$.nanoid=(Q)=>$.check(c$(T8,Q)),$.guid=(Q)=>$.check(o3(Q6,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)}),C8=N("ZodEmail",($,J)=>{DX.init($,J),r.init($,J)});function yH($){return y$(C8,$)}var Q6=N("ZodGUID",($,J)=>{VX.init($,J),r.init($,J)});function xH($){return o3(Q6,$)}var R0=N("ZodUUID",($,J)=>{_X.init($,J),r.init($,J)});function uH($){return x$(R0,$)}function mH($){return u$(R0,$)}function lH($){return m$(R0,$)}function pH($){return l$(R0,$)}var K6=N("ZodURL",($,J)=>{zX.init($,J),r.init($,J)});function cH($){return n3(K6,$)}function dH($){return n3(K6,{protocol:/^https?$/,hostname:y1.domain,...w.normalizeParams($)})}var S8=N("ZodEmoji",($,J)=>{RX.init($,J),r.init($,J)});function rH($){return p$(S8,$)}var T8=N("ZodNanoID",($,J)=>{IX.init($,J),r.init($,J)});function iH($){return c$(T8,$)}var w8=N("ZodCUID",($,J)=>{jX.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 S5(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)=>MY($,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 MZ($){return u5(g2,$)}function OZ($){return m5(g2,$)}var l4=N("ZodBoolean",($,J)=>{p3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>OY($,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)=>RY($,Q,X,Y)});function zZ(){return a5(qW)}var UW=N("ZodUnknown",($,J)=>{sX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>IY($,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 RZ($){return $Y(HW,$)}var B6=N("ZodDate",($,J)=>{eX.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>jY($,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 IZ($){return JY(B6,$)}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 q6($,J){return YY(ZW,$,J)}function jZ($){let J=$._zod.def.shape;return o8(Object.keys(J))}var U6=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 U6(Q)}function PZ($,J){return new U6({type:"object",shape:$,catchall:r8(),...w.normalizeParams(J)})}function AZ($,J){return new U6({type:"object",shape:$,catchall:k2(),...w.normalizeParams(J)})}var G6=N("ZodUnion",($,J)=>{c3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>Z8($,Q,X,Y),$.options=J.options});function i8($,J){return new G6({type:"union",options:$,...w.normalizeParams(J)})}var LW=N("ZodXor",($,J)=>{G6.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 MW=N("ZodDiscriminatedUnion",($,J)=>{G6.init($,J),X5.init($,J)});function CZ($,J,Q){return new MW({type:"union",options:J,discriminator:$,...w.normalizeParams(Q)})}var OW=N("ZodIntersection",($,J)=>{Y5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>yY($,Q,X,Y)});function NW($,J){return new OW({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 H6=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 H6({type:"record",keyType:$,valueType:J,...w.normalizeParams(Q)})}function SZ($,J,Q){let X=N1($);return X._zod.values=void 0,new H6({type:"record",keyType:X,valueType:J,...w.normalizeParams(Q)})}function TZ($,J,Q){return new H6({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 RW=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 RW({type:"literal",values:Array.isArray($)?$:[$],...w.normalizeParams(J)})}var IW=N("ZodFile",($,J)=>{G5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>CY($,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(IW,$)}var jW=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 C2($.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 jW({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 X6($){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 Y6($){return new AW({type:"nullable",innerType:$})}function gZ($){return X6(Y6($))}var EW=N("ZodDefault",($,J)=>{M5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>pY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function CW($,J){return new EW({type:"default",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var SW=N("ZodPrefault",($,J)=>{O5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>cY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function TW($,J){return new SW({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)=>SY($,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 W6($,J){return new t8({type:"pipe",in:$,out:J})}var e8=N("ZodCodec",($,J)=>{t8.init($,J),d3.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)=>{R5.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)=>{j5.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)=>{I5.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??q6(k2()),output:$?.output??k2()})}var Z6=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(Z6,$??(()=>!0),J)}function cW($,J={}){return BY(Z6,$,J)}function dW($){return qY($)}var rZ=UY,iZ=GY;function oZ($,J={}){let Q=new Z6({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(),q6(J),_W(P8(),J)])});return J}function aZ($,J){return W6(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 cb=()=>{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:cb()}}var iW=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")};var JJ={};B2(JJ,{string:()=>db,number:()=>rb,date:()=>nb,boolean:()=>ib,bigint:()=>ob});function db($){return C5(x4,$)}function rb($){return k5(m4,$)}function ib($){return p5(l4,$)}function ob($){return d5(p4,$)}function nb($){return QY(B6,$)}Y1(rW());var sb=QJ;var JL=Object.freeze(["hard_stop","use_alternative","scope_down","manual_only","stop_and_explain"]);var L6=64,QL="Rule config exceeds CC Safety Net's safe source limit.";var ch=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."},ab=[".bak",".backup",".copy",".disabled",".old",".orig",".save",".tmp"],tb=[{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"]},...tb.flatMap(($)=>ab.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"}],eb=[".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(($)=>eb.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]:[])),$P=YL.map(($)=>$.id),WJ=new Set($P);var Yk=JP(import.meta.url),KL,QP=Array(L6+1).fill("over-limit"),BL=/^[^/]+\/[^/]+$/,XP=/^sha256:[a-f0-9]{64}$/,KJ=`must be an integer between ${HJ} and ${ZJ}`,YP=["version","rules","overrides","transparent_wrappers"],WP=["version","safety","workflow","destructive_command_protection","secret_protection","audit"];function qL($){if(!i1($)||!Array.isArray($.rules)||$.rules.length<=L6)return $;return{$schema:$.$schema,version:$.version,rules:QP,overrides:$.overrides,transparent_wrappers:$.transparent_wrappers}}function KP(){let $=oW,J=(_)=>{let j=$.superRefine(_);return j._zod.def.when=()=>!0,j},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(M2,"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(L6,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=(_,j)=>{if(!i1(_))return;if(Array.isArray(_.rules)&&_.rules.length<=L6){let C=new Set;_.rules.forEach((T,y)=>{if(typeof T!=="string"||T==="")return;if(T.trim()===""){j.addIssue({code:"custom",message:"must be a non-empty rulebook source string",path:["rules",y]});return}let x=o4(T);if(x){j.addIssue({code:"custom",message:x,path:["rules",y]});return}if(C.has(T)){j.addIssue({code:"custom",message:`duplicate rulebook source "${T}"`,path:["rules",y]});return}C.add(T)})}if(i1(_.overrides))for(let C of Object.keys(_.overrides)){if(BL.test(C))continue;j.addIssue({code:"custom",message:"must use <rulebook-name>/<rule-name>",path:["overrides",C]})}if(!Array.isArray(_.transparent_wrappers))return;let P=new Set;_.transparent_wrappers.forEach((C,T)=>{if(typeof C!=="string"||!M2.test(C))return;if(P.has(C)){j.addIssue({code:"custom",message:`duplicate command "${C}"`,path:["transparent_wrappers",T]});return}if(LU(C)){j.addIssue({code:"custom",message:`reserved command "${C}" cannot be a wrapper`,path:["transparent_wrappers",T]});return}P.add(C)})},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=(_,j)=>$.intersection($.record($.string().refine((P)=>_.has(P),{error:(P)=>`unknown ${j} 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((j,P)=>{if(!Array.isArray(j))return;let C=c2();j.forEach((T,y)=>{if(typeof T!=="string")return;let x=_(T,C);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(r6,"destructive command").optional(),allow_paths:L(C9).optional()}).optional(),secret_protection:$.strictObject({enabled:$.boolean().optional(),overrides:H(WJ,"secret protection").optional(),deny_paths:L(S9).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()}),M=(_)=>{let j=(y,x)=>_==="legacy"?y:x,P=j("must match pattern (letters, numbers, hyphens, underscores)","must match command pattern"),C=`required non-empty string up to ${o2} characters`,T=$.looseObject({name:$.string({error:"required string"}).regex(Y0,j("must match pattern (letters, numbers, hyphens, underscores; max 64 chars)","must match rule name pattern")),command:$.string({error:j("required string","required string matching command pattern")}).regex(M2,j(P,"required string matching command pattern")),subcommand:$.string({error:j("must be a string if provided","must match command pattern")}).regex(M2,P).optional(),block_args:$.array($.string({error:j("must be a string","must be a non-empty string")}).refine((y)=>y!=="",{error:j("must not be empty","must be a non-empty string")}),{error:j("required array","required non-empty array")}).refine((y)=>y.length>0,{error:j("must have at least one element","required non-empty array")}),reason:$.string({error:j("required string",C)}).refine((y)=>y!=="",{error:j("must not be empty",C)}).refine((y)=>y.length<=o2,{error:j(`must be at most ${o2} characters`,C)}),intent:Q.optional()},{error:"must be an object"});return $.array(T,{error:j("must be an array","required array")}).check(J((y,x)=>{if(!Array.isArray(y))return;let c=new Set;y.forEach((V1,S)=>{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:[S,"name"]});return}c.add(m.toLowerCase())})}))},O=$.looseObject({version:$.literal(1),rules:M("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((_,j)=>{if(!i1(_))return;if(_.expect!=="blocked"||typeof _.rule==="string")return;j.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(M2,"must match command pattern"),{error:"required array"}).check(J((_,j)=>{if(!Array.isArray(_))return;let P=new Set;_.forEach((C,T)=>{if(typeof C!=="string"||!M2.test(C))return;if(P.has(C)){j.addIssue({code:"custom",message:`duplicate command "${C}"`,path:[T]});return}P.add(C)})})),rules:M("rulebook"),tests:$.array(F,{error:"must be an array if provided"}).optional()}).check(J((_,j)=>{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;j.addIssue({code:"custom",message:`blocked fixture references unknown rule "${y}"`,path:["tests"]})}}if(!Array.isArray(_.allowed_commands)||!Array.isArray(_.rules))return;let C=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"||C.has(x))return;j.addIssue({code:"custom",message:`"${x}" must be listed in allowed_commands`,path:["rules",y,"command"]})})})),R=$.string({error:"required string"}).refine((_)=>_.trim()!=="",{error:"required string"}),A=$.looseObject({spec:R,name:R,version:R,digest:$.string({error:"required sha256 digest"}).regex(XP,"required sha256 digest")},{error:"must be an object"}),E=$.looseObject({rulebooks:$.array($.intersection(A,$.discriminatedUnion("kind",[$.object({kind:$.literal("local-directory"),path:R}),$.object({kind:$.literal("github"),owner:R,repo:R,ref:R,commit:R,path:R,display_ref:$.unknown().optional()})],{error:(_)=>{if(!i1(_.input))return"must be an object";let j=_.input.kind;return typeof j==="string"?`unknown kind "${j}"`:"required string"}})))});return{RulesConfigSchema:q,RulesConfigDiagnosticSchema:U,RuleOverrideSchema:X,UserPolicySchema:Z,LegacyConfigSchema:O,RulebookSchema:b,RulesLockfileSchema:E}}function O6(){return KL??=KP(),KL}function UL(){return O6().RulesConfigSchema}function BP(){return O6().UserPolicySchema}function GL(){return O6().RulebookSchema}function HL(){return O6().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=O6().RulesConfigDiagnosticSchema.safeParse($);if(J.success)return{errors:[],sources:new Set(J.data.rules)};return{errors:c4(OL(J.error.issues,YP)),sources:HP($,J.error.issues)}}function LL($){let J=BP().safeParse($);if(J.success)return[];return c4(OL(J.error.issues,WP)," ")}function c4($,J=": ",Q=" "){return[...new Set($.flatMap((X)=>ML(X,J,Q,[])))]}function ML($,J,Q,X){let Y=[...X,...$.path],W=GP(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)=>ML(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}${qP($)}`]}function qP($){if($.code==="invalid_value")return`must be ${UP($.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 UP($){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 GP($){return $.map((J,Q)=>{if(typeof J==="number")return`[${J}]`;return Q===0?String(J):`.${String(J)}`}).join("")}function OL($,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 HP($,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 ZP($){return ZL($)}function QK($){try{let J=q2(LP($));if(J===null)return{config:null,errors:[]};if(!J.trim())return{config:null,errors:["Config file is empty"]};let Q=JSON.parse(J),X=ZP(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 LP($){return typeof $==="string"?P6($):$}var VP=new Set(["standard","strict","paranoid"]),_P={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:R6}};function XK($){return FP(NP(U2($)),C6)}function _L($={}){let J=IP(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(!I0($))return RP();let J=I0($.safety)?$.safety:{},Q=I0(J.overrides)?J.overrides:{},X=I0($.workflow)?$.workflow:{},Y=I0($.destructive_command_protection)?$.destructive_command_protection:{},W=I0($.secret_protection)?$.secret_protection:{};return{version:1,safety:{level:VP.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,r6),allow_paths:zP(Y.allow_paths)},secret_protection:{enabled:typeof W.enabled==="boolean"?W.enabled:!0,overrides:FL(W.overrides,WJ),deny_paths:DP(W.deny_paths)},audit:{retention_days:I6(I0($.audit)?$.audit.retention_days:void 0)}}}function FL($,J){if(!I0($))return{};return Object.fromEntries(Object.entries($).flatMap(([Q,X])=>J.has(Q)&&(X==="on"||X==="off")?[[Q,X]]:[]))}function DP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>S9(Q,J)===null)}function zP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>C9(Q,J)===null)}function I0($){return!!$&&typeof $==="object"&&!Array.isArray($)}function RP(){return structuredClone(_P)}function IP($){let J=jP();if(!MP($)){let Q=globalThis.__CC_SAFETY_NET_EMBEDDED_POLICY__;if(!I0(Q))return{policy:J,errors:[]};return{policy:VL(NL(Q)),errors:[]}}try{let Q=OP($,"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:I0(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 jP(){return{safety:{},worktreeMode:!1,destructiveCommandProtectionEnabled:!0,destructiveCommandRuleOverrides:{},destructiveCommandAllowPaths:[],secretProtection:{enabled:!0,disabledRules:DL({}),denyPaths:[]}}}function VL($){return{safety:bP($.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 bP($){return{level:$.level,overrides:{failClosed:$.overrides.fail_closed,paranoidRm:$.overrides.paranoid_rm,paranoidInterpreters:$.overrides.paranoid_interpreters}}}var jL="This path contains the protected policy config and you must not modify or delete it.",PP=new Set(["[","cat","file","grep","head","jq","less","ls","more","rg","sed","stat","tail","test","wc"]);function bL($){let J=H2(E0()),Q=wP($.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?RL(X.shell,$.invocation.context.executionCwd,Q,J):null;if($.invocation.route.kind==="unknown"&&X){let Y=RL(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"||j9($.invocation.toolName),$.invocation.context.executionCwd,Q,J)}function zL($,J,Q,X,Y){if(J)return null;let W=$.find((K)=>N6(K,Q,X,Y));return W?{target:W}:null}function RL($,J,Q,X){let Y=P9($,J,X,{findSegmentTarget:(W,K)=>AP(W,K,Q,X)?.target??null,isRedirectionTarget:(W,K)=>N6(W,K.cwd,Q,X),findMalformedTarget:(W)=>TP(W,J,Q,X)?.target??null,normalizeCwd:O1});return Y?{target:Y}:null}function AP($,J,Q,X){if(M3($))return null;let Y=X.environment,W=l1([...$],Y),K=l(W[0]??"").toLowerCase(),B=W.slice(1);if(K==="rm"&&EP(B)){let q=CP(B).find((U)=>IL(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(K==="find"){if(y9(W,1)||AQ(W,Y)){let U=(g9(p(W))??p(["."])).find((G)=>{let H=f1(G.text,J.variables);return N6(H,J.cwd,Q,X)||IL(H,J.cwd,Q,X)})?.text;if(U)return{target:U}}}if(K==="mv"){let q=A9(B).sources.find((U)=>vP(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(SP($,Y))return null;for(let q of $)for(let U of PL(q))if(N6(f1(U,J.variables),J.cwd,Q,X))return{target:U};return null}function EP($){return $.some((J)=>J==="--recursive"||J.startsWith("-")&&!J.startsWith("--")&&/[rR]/.test(J.slice(1)))}function CP($){let J=$.indexOf("--");if(J!==-1)return[...$.slice(0,J).filter((Q)=>!Q.startsWith("-")),...$.slice(J+1)];return $.filter((Q)=>!Q.startsWith("-"))}function SP($,J){let Q=l1([...$],J);if(Q.length===0)return!1;let X=l(Q[0]??"").toLowerCase();if(!PP.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 TP($,J,Q,X){for(let Y of $.split(/\s+/))for(let W of PL(Y))if(N6(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 wP($,J){let Q=O1(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 N6($,J,Q,X){return d4(O1($,J,X))===Q.file}function IL($,J,Q,X){return Q.directoryAndAncestors.has(d4(O1($,J,X)))}function vP($,J,Q,X){let Y=d4(O1($,J,X));return Y===Q.file||Q.directoryAndAncestors.has(Y)}function d4($){return process.platform==="win32"?$.toLowerCase():$}import{homedir as fP}from"node:os";import{isAbsolute as KK,resolve as hL}from"node:path";import{fileURLToPath as hP}from"node:url";var kL="Access to a sensitive path is not allowed.",gL=new Set(["echo","printf"]),kP=new Set(["find"]),gP=new Set(["-exec","-execdir"]),yP=new Set([";","+"]),xP=new Set(["-delete","-exec","-execdir","-fls","-fprint","-fprint0","-fprintf","-ok","-okdir"]),uP=new Set(["-name","-iname","-path","-ipath","-wholename","-iwholename","-samefile"]),mP=new Set(["python","python2","python3","node","deno","bun","ruby","perl","php","rscript","osascript","bash","sh","zsh","dash","ksh"]),lP=new Set(["node","bun"]),pP=new Set(["bun","child_process","deno","dotenv","fs","subprocess"]),cP=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"]),dP=new Set(["src/cli/cc-safety-net.ts","dist/bin/cc-safety-net.js"]),rP=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"])]]),iP=new Set(["grep","rg"]),AL="f",EL="file",oP="files",nP=new Set(["e","f"]),sP=new Set(["regexp","file"]),aP=new Set(["e","f","A","B","C","m"]),tP=new Set(["regexp","file","after-context","before-context","context","max-count"]),eP=new Set(["|","|&"]),WK="__CC_SAFETY_NET_PIPE_INPUT__",xL=new Set(["bash","sh","zsh","dash","ksh"]),$A=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 CL($,J,Q,X,Y){let W=s4();for(let K of $){if(yA(K,J,Q?.denyPaths??[],X,W))return{target:K,ruleId:"secret.deny-path"};if(Y&&!Y.has(K))continue;let B=kA(K,J,Q,W);if(B)return{target:K,ruleId:B}}return null}function uL($,J,Q={}){let X=SL($),Y=CL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd),W=Y?.ruleId!=="secret.deny-path"&&Q.strict===!1?SL($,{refineJavaScriptInlineData:!0}):X,K=W.length===X.length?Y:CL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd,new Set(W));if(K?.ruleId!=="secret.deny-path"&&Q.strict===!1&&JA($))return null;return K}function JA($){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)=>xP.has(K))}function SL($,J={}){if($.invocation.route.kind==="command"){let X=w1($,"input-candidate");return X?_6(X.shell,$.store,J):[]}if($.invocation.route.kind!=="unknown")return $.paths.map((X)=>X.raw);let Q=w1($,"input-candidate");return[...Q?_6(Q.shell,$.store,J):[],...$.paths.map((X)=>X.raw)]}function _6($,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,...zA(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=eP.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=HA($),Y=i4($);if(Y.length===0)return X;let W=Y[0]??"",K=y2(W).toLowerCase(),B=Y.slice(1),q=QA(W,K,B);if(q)return[...X,...q];if(gL.has(K))return X;if(iP.has(K))return[...X,...CA(B)];if(kP.has(K))return[...X,...ZA(B,J,Q)];if(h1.has(K))return[...X,...B.flatMap((U)=>wL("awk",U)),...B.flatMap((U)=>MA(U,J,Q)),...B.flatMap(OA)];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,...LA(K,B,Q)]}return[...X,...B.flatMap((U)=>wL(K,U))]}function QA($,J,Q){let X=J==="cc-safety-net"&&Q[0]==="explain",Y=(J==="bun"||J==="node")&&XA(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 XA($){let J=$?.replaceAll("\\","/");return[...dP].some((Q)=>J===Q||J?.endsWith(`/${Q}`))}function TL($,J,Q,X){if(qA(J,Q,X))return YA($);let Y=UA(J);if(Y===null)return[];return WA($).flatMap((W)=>xL.has(Y)?_6(Q.getShellSyntax(W),Q,X):dL(W))}function YA($){let J=i4($);if(J.length===0)return[];let Q=y2(J[0]??"").toLowerCase();if(!gL.has(Q))return[];return J.slice(1)}function WA($){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 KA(X);return[]}function KA($){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)=>BA(J,X.slice(W*Q,(W+1)*Q)))}function BA($,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,`
|
|
100
|
+
`).replace(/\\t/g,"\t").replace(/\\r/g,"\r")}function qA($,J,Q){let X=i4($);if(X.length===0||y2(X[0]??"").toLowerCase()!=="xargs")return!1;let Y=j2(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 UA($){let J=i4($);if(J.length===0)return null;let Q=y2(J[0]??"").toLowerCase();if(!pL(Q))return null;return GA(Q,J.slice(1))?Q:null}function GA($,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($A.get(Q)?.has(Y))X++;continue}return!1}return!0}function lL($){return/^python\d/.test($)?"python":$}function HA($){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 ZA($,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(!gP.has($[W]??""))continue;let K=$.slice(W+1),B=K.findIndex((G)=>yP.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(!uP.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 mP.has($)||/^python\d/.test($)}function LA($,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 rP.get(J[J.length-1]??"")?.has(lL($))??!1}function MA($,J,Q){if(!$.includes("system"))return[];return IQ($)?.commands.flatMap((X)=>_6(J.getShellSyntax(X),J,Q))??[]}function OA($){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||!lP.has($)||X.length===0)return X;let Y=NA(J);return Y!==null&&!VA(Y)?[]:X}function NA($){let J=$.split("");for(let Q=0;Q<$.length;Q++){let X=$[Q];if(X!=="'"&&X!=='"'&&X!=="`")continue;if(X==="`"&&FA($,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===`
|
|
101
|
+
`||K==="\r"))return null;if(K!==X)continue;Q=W,Y=!0;break}if(!Y)return null}return J.join("")}function FA($,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 VA($){for(let J of $.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/g)){let Q=J[0],X=J.index;if(pP.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)=>cP.has(W)))continue;if(Y.length>1)return!0;if(_A($,X)===".")return!0;if(DA($,X+Q.length)==="(")return!0}return!1}function _A($,J){for(let Q=J-1;Q>=0;Q--)if(!/\s/.test($[Q]??""))return $[Q];return}function DA($,J){for(let Q=J;Q<$.length;Q++)if(!/\s/.test($[Q]??""))return $[Q];return}function zA($,J,Q){return PA($).flatMap((X)=>{let Y=J.getShellSyntax(X);if(Y.status==="invalid")return[];return[..._6(Y,J,Q),...RA(Y)?IA(Y):[]]})}function RA($){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 IA($){return $.entries.flatMap((J)=>J.kind==="word"?[G0(J.text)]:J.kind==="redirection"&&J.target?[G0(J.target)]:[]).flatMap(rL)}function rL($){let J=bA($);if(J===null)return[];let Q=Buffer.from(J,"base64").toString("utf8");if(Q===""||jA(Q))return[];return Buffer.from(Q,"utf8").toString("base64").replace(/=+$/g,"")===J.replace(/=+$/g,"")?[Q]:[]}function jA($){return Array.from($).some((J)=>{let Q=J.charCodeAt(0);return Q<32||Q===127})}function bA($){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 PA($){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=AA($,X+1);if(W!==null)J.push(W.body),X=W.endIndex;continue}if(!Q.inSingle&&Y==="`"){let W=EA($,X);if(W!==null)J.push(W.body),X=W.endIndex}}return J}function AA($,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 EA($,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 CA($){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===oP)Y=!0;if(sP.has(H))X=!0;if(L!==void 0){if(H===EL)J.push(L);continue}if(tP.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 M=0;M<H.length;M++){let O=H[M]??"";if(nP.has(O))X=!0;if(aP.has(O)){L=O,Z=H.slice(M+1);break}}if(L!=="")if(Z.length>0){if(L===AL)J.push(Z)}else{let M=$[q+1];if(L===AL&&M!==void 0)J.push(M);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 SA=new Set(["id_rsa.pub","id_ed25519.pub","id_ecdsa.pub"]),TA=".env.",wA=new Set([".env.example",".env.sample",".env.template",".env.defaults"]),vA=[".env.example.",".env.sample."],fA=new Set(["node_modules","__pycache__"]),hA=[["vendor","bundle"],["vendor","cache"]];function kA($,J,Q,X){let Y=u0($,J,X);if(!Y)return null;let W=G1(Y.split("/").pop()??""),K=G1(Y);if(wA.has(W)||vA.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=gA(Y,J,Q,X);if(B)return B;if(SA.has(W))return null;for(let U of nW)if(W===U.basename&&x0(U.id,Q))return U.id;if(W.startsWith(TA)&&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(xA(K))return null;if(!W.includes(".")&&M6.pattern.test(W)&&x0(M6.id,Q))return M6.id;let q=uA(W,Q);if(q)return q;return null}function gA($,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"])||V6($,"~/.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"])||F6($,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()?V6($,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"])||F6($,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"])||F6($,W,["credentials"])||F6($,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)=>V6($,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()?V6($,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"]))||F6($,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()?V6($,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 F6($,J,Q){return Q.some((X)=>qJ(G1($),G1(F1(J,X))))}function V6($,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 yA($,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 xA($){let J=$.split("/");return J.some((Q)=>fA.has(Q))||hA.some(([Q,X])=>J.some((Y,W)=>Y===Q&&J[W+1]===X))}function uA($,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??fP(),X=Q?r4(J1(Q,i0,J)):"",Y=r4(mA(G0($)));return{home:X,normalized:Y}}function mA($){if(!$.trim().toLowerCase().startsWith("file:"))return $;try{return hP($)}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"node: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 $M($){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 lA($){if(!pA($))return{errors:["Rulebook must be an object"],ruleNames:new Set};if(!$M($))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=lA($);if(J.errors.length>0)throw Error(J.errors.join("; "));return $}function pA($){return!!$&&typeof $==="object"&&!Array.isArray($)}function UK($){if(E6($.spec))return rA($);return dA($)}function dA($){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 rA($){let J=o4($.spec);if(J)return J;let Q=A6($.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 JM($){let J=typeof $==="string"?$:$.path;try{let Q=q2(typeof $==="string"?P6($):$);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 iA}from"node:crypto";var Pg=Object.freeze({timeoutMs:15000,metadataBytes:524288,commitBytes:262144,treeBytes:16777216,rawBytes:4194304});function QM($){return`sha256:${iA("sha256").update($).digest("hex")}`}function BM($={}){let J=CK($),Q=!1;try{Q=zK(J.userConfigTarget,J.projectConfigTarget)}catch(L){if(L instanceof W1)return aA(J,L.message);throw L}let X=QK(J.userConfigTarget),Y=Q?{config:null,errors:[]}:QK(J.projectConfigTarget),W=KM(J.userConfigPath,X.errors),K=KM(J.projectConfigPath,Y.errors),B=new Set,q=X.config?XM(X.config,J.userLockPath,UJ(J.userConfigPath),$,"user",J.userScope,B):D6(),U=Y.config?XM(Y.config,J.projectLockPath,UJ(J.projectConfigPath),$,"project",J.projectScope,B):D6(),G=X.config?.overrides??{},H=Y.config?.overrides??{};return{rules:[...YM(q.rules,G),...YM(U.rules,H)],transparent_wrappers:nA(X.config,Y.config),rulebooks:[...q.rulebooks,...U.rulebooks],errors:[...W,...K,...q.errors,...U.errors],warnings:[...q.warnings,...U.warnings,...q.canValidateOverrides?WM(G,q.knownRuleIds,J.userConfigPath):[],...q.canValidateOverrides?sA(H,q.knownRuleIds,J.projectConfigPath):[],...U.canValidateOverrides?WM(H,U.knownRuleIds,J.projectConfigPath):[]],userConfig:X.config??void 0,projectConfig:Y.config??void 0,...J}}function XM($,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{...D6(),errors:[V.message],canValidateOverrides:!1};throw V}let q=JM(B);if(q.errors.length>0)return{...D6(),errors:q.errors,canValidateOverrides:!1};let U=q.lock;if(!U&&$.rules.length>0)return{...D6(),errors:[`missing lockfile ${J}; run ${c0}`],canValidateOverrides:!1};let G=U?.rulebooks??[],H=new Map(G.map((V)=>[V.spec,V])),L=[],Z=[],M=$.rules.flatMap((V)=>{let F=H.get(V);if(!F)return L.push(`missing lock entry for ${V}; run ${c0}`),[];let b=oA(F,Q,X,W);if(b.errors.length>0||!b.rulebook)return L.push(...b.errors),[];let R=b.rulebook;if(K.has(R.name))return Z.push(`duplicate active rulebook name "${R.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(R.name),[{rules:R.rules.map((A)=>({...A,name:`${R.name}/${A.name}`})),rulebook:{source:Y,spec:F.spec,name:R.name,version:R.version,rules:R.rules.map((A)=>`${R.name}/${A.name}`)}}]}),O=M.flatMap((V)=>V.rules);return{rules:O,rulebooks:M.map((V)=>V.rulebook),entries:G,knownRuleIds:new Set(O.map((V)=>V.name)),errors:L,warnings:Z,canValidateOverrides:L.length===0}}function oA($,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(QM(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 nA($,J){return[...new Set([...$?.transparent_wrappers??[],...J?.transparent_wrappers??[]])]}function YM($,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 WM($,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 sA($,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 KM($,J){return J.map((Q)=>Q.startsWith("Unable to access ")?Q:`${$}: ${Q}`)}function aA($,J){return{rules:[],transparent_wrappers:[],rulebooks:[],errors:[J],warnings:[],userConfigPath:$.userConfigPath,projectConfigPath:$.projectConfigPath,userLockPath:$.userLockPath,projectLockPath:$.projectLockPath}}function D6(){return{rules:[],rulebooks:[],entries:[],knownRuleIds:new Set,errors:[],warnings:[],canValidateOverrides:!0}}function qM($={}){let J=BM($),Q=_L($),X={rules:J.rules,transparentWrappers:J.transparent_wrappers,safety:XE(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}),...JE(B.spec)?{source:B.spec}:{}}:{},...q&&typeof q==="object"?{override:Object.freeze({type:"reason",reason:q.reason})}:{}})]})));return QE(X,tA(J,Q),W)}function tA($,J){let Q=$E(J);if($.errors.length===0&&$.warnings.length===0&&!Q)return;return{diagnostics:[...$.errors,...$.warnings,...J.errors],reason:YE($.errors.length>0?eA($.errors):void 0,$.warnings.length>0?GK($.warnings.join("; ")):void 0,Q)}}function eA($){return`${GK($.join("; "))} Those rule sources are not active; every other rule and all built-in protections still apply`}function $E($){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 JE($){return/^(?:[A-Za-z0-9_.-]+$|https:\/\/github\.com\/|github:|gh:|[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:#|$))/.test($)}function QE($,J,Q=Object.freeze({})){let X=UM(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 XE($){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 UM($){if(typeof $!=="object"||$===null)return $;for(let J of Object.values($))UM(J);return Object.freeze($)}function YE(...$){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 WE={findPolicyMutation:bL,findGitMetadataMutation:cq,resolveGitMetadata:LQ,loadPolicySnapshot:qM,findSensitiveTarget:uL,analyzeCommand:XH,getModes:U7};function GM($,J={}){let Q={...WE,...J.dependencies},X=qE($),Y=z6($)?$.command:X,W=x2("policy-protection",Y,()=>b9($,J.factParserDependencies)),K=w1(W,"declared-command");if(z6($)&&$.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:dK,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:jL,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,...KE(G)},M=H.secretProtection.enabled===!1?null:x2("secret-protection",Y,()=>Q.findSensitiveTarget(W,H.secretProtection,{strict:z6($)?L.strict:void 0}));if(M){let V=Y??M.target;return{stage:"secret-protection",...Z,decision:{kind:"deny",reason:kL,intent:"hard_stop",ruleId:M.ruleId,evidence:[{kind:"command",command:V,segment:M.target},{kind:"path",target:M.target}]}}}if(!z6($))return{stage:"non-command",...Z,decision:{kind:"allow"}};if(!$.command||$.command.trim()==="")return{...HK("command-validation",Y),...Z};let O=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},BE(W),W.store)});if(O)return{stage:"command-analysis",...Z,decision:O};return{stage:"command-analysis",...Z,decision:{kind:"allow"}}}function KE($){if($.state==="ready")return{};return{configFallback:{reason:$.reason}}}function BE($){return w1($,"declared-command")?.program}function qE($){try{return J4($.input)}catch(J){let Q=z6($)?$.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:w6,intent:"stop_and_explain",evidence:J?[{kind:"command",command:J,segment:J}]:[]}}}function z6($){return $.route.kind==="command"}function ZM($,J){try{let Q=GM($,J.guard);return HM($,Q,J),Q}catch(Q){if(!(Q instanceof K2))throw Q;throw HM($,Q.evaluation,J,!(Q.cause instanceof w0),{stage:Q.stage,errorCode:UE(Q.cause)}),Q}}function HM($,J,Q,X=!0,Y){uK(xK($,J,Q.guard?.auditAllowed??!1,X,Y),Q.audit.getSessionId,{agent:Q.audit.agent,shape:Q.audit.shape,homeDir:Q.audit.homeDir})}function UE($){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 MM="exec",GE=new Set(["auto","gateway"]);function OM($){$.on("before_tool_call",HE($),{matcher:[MM],priority:50})}function HE($,J={}){return(Q,X)=>{if(X.abortSignal?.aborted)return ZK(jJ());let Y=ZE(Q,X,$);if(!Y)return;let W=()=>X.sessionId??X.sessionKey;if("malformed"in Y)return mK(Y.denial,W,{agent:"openclaw",toolName:Y.denial.toolName,cwd:Y.cwd}),ZK(Y.denial);try{let K=ZM(Y,{guard:{auditAllowed:B7(),dependencies:J.guardDependencies},audit:{agent:"openclaw",getSessionId:W}});return LM(K,K.stage!=="config-state")}catch(K){if(!(K instanceof K2))throw K;if(k0(B1.debug))console.error(`CC Safety Net debug: openclaw before_tool_call analysis failed: ${sK(K.cause)}`);return LM(K.evaluation,!0)}}}function ZE($,J,Q){if(!$||typeof $!=="object")return u2(null);let X=$.toolName;if(typeof X!=="string"||X.trim()==="")return u2(null);if(X!==MM)return;let Y=$.params;if(!Y||typeof Y!=="object"||Array.isArray(Y))return u2(null,X);let W=Y,K=W.command;if(typeof K!=="string"||K.trim()==="")return u2(null,X);if(W.host!==void 0&&!GE.has(W.host))return u2(null,X,K);let B=LE(Q,J.agentId);if(!B)return u2(null,X,K);let q=ME(B,W);if(!q)return u2(B,X,K,typeof W.workdir==="string"?W.workdir:void 0);return Y$(X,W,{kind:"command",shell:"auto"},{configCwd:B,executionCwd:q},K)}function LE($,J){if(typeof J!=="string"||J.trim()==="")return;try{let Q=$.runtime.agent.resolveAgentWorkspaceDir($.config,J);if(typeof Q!=="string"||Q.trim()==="")return;return T6(".",[Q])}catch{return}}function ME($,J){if(!Object.hasOwn(J,"workdir")||J.workdir===void 0)return $;let Q=J.workdir;if(typeof Q!=="string"||Q.trim()==="")return;return T6(Q,[$])}function u2($,J,Q,X){return{malformed:!0,denial:jJ({command:Q,segment:X,toolName:J}),cwd:$}}function LM($,J){let Q=oK($,{includeEvidence:J});return Q?ZK(Q):void 0}function ZK($){return{block:!0,blockReason:nK($)}}var Dy={...OK,register:OM};export{Dy as default};
|