oxlint-plugin-react-doctor 0.9.13-dev.ff7dd67 → 0.9.14-dev.922616f

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.
@@ -0,0 +1,28 @@
1
+ import{KEYS as e}from"eslint-visitor-keys";import{parseSync as t,rawTransferSupported as n,visitorKeys as r}from"oxc-parser";import*as i from"node:fs";import{readFileSync as a}from"node:fs";import*as o from"node:path";const s=[[`nextjs`,`Next.js`,`NEXT_PUBLIC_*`],[`vite`,`Vite`,`VITE_*`],[`tanstack-start`,`TanStack Start`,`VITE_*`],[`cra`,`Create React App`,`REACT_APP_*`],[`gatsby`,`Gatsby`,`GATSBY_*`]],c=e=>{for(let[t,n,r]of s)if(e(t))return`Move secrets to server-only code. In ${n}, only \`${r}\` env vars are exposed to the browser, and they must not contain secrets`},l=e=>e(`nextjs:static-export`)?`Avoid redirects inside useEffect — they flash the wrong page first. Use an event handler (e.g. onClick), or call redirect() from next/navigation during render (it prerenders a client-side redirect under output: "export"). Middleware and getServerSideProps redirects aren't available in a static export.`:void 0,u=[{key:`react-hooks-js/set-state-in-render`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/immutability`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/refs`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/purity`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/hooks`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/set-state-in-effect`,source:`react-compiler`,severity:`warn`},{key:`react-hooks-js/globals`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/error-boundaries`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/preserve-manual-memoization`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/unsupported-syntax`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/component-hook-factories`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/static-components`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/use-memo`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/void-use-memo`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/incompatible-library`,source:`react-compiler`,severity:`error`},{key:`react-hooks-js/todo`,source:`react-compiler`,severity:`error`}],d=Object.fromEntries(u.map(e=>[e.key,e.severity])),f=new Set(`width.height.min-width.max-width.min-height.max-height.top.right.bottom.left.padding.padding-top.padding-right.padding-bottom.padding-left.margin.margin-top.margin-right.margin-bottom.margin-left.border-width.border-top-width.border-right-width.border-bottom-width.border-left-width.line-height.column-width`.split(`.`)),p=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,`padding`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`margin`,`marginTop`,`marginRight`,`marginBottom`,`marginLeft`,`borderWidth`,`fontSize`,`lineHeight`,`gap`]),m=new Set([`animate`,`initial`,`exit`,`whileHover`,`whileTap`,`whileFocus`,`whileDrag`,`whileInView`]),h=/blur\((\d+(?:\.\d+)?)px\)/,ee=new Set([`requestAnimationFrame`,`setInterval`]),te=new Set([`framer-motion`,`motion`]),g=new Set([`bounce`,`elastic`,`wobble`,`jiggle`,`spring`]),ne={base:`3.0.0`,textLayoutGuard:`3.0.1`,aria:`6.2.0`,cursor:`6.7.0`,concurrent:`6.7.0`,renderToString:`6.8.0`,modernHooks:`7.0.0`,suspendTerminal:`7.1.0`},_=[`ink-ctrl-c-handler-requires-exit-option`,`ink-newline-inside-text`,`ink-no-bare-process-exit`,`ink-no-direct-raw-mode`,`ink-no-dom-host-elements`,`ink-no-dom-router`,`ink-no-focus-in-render`,`ink-no-layout-inside-text`,`ink-no-live-hooks-in-render-to-string`,`ink-no-measure-element-in-render`,`ink-no-multiple-static`,`ink-no-raw-text`,`ink-no-repeated-render`,`ink-prefer-use-animation`,`ink-prefer-use-paste`,`ink-static-is-append-only`,`ink-static-requires-key`,`ink-suspense-requires-concurrent`,`ink-use-reactive-window-size`,`ink-use-string-width-for-cursor`,`ink-use-suspend-terminal`,`ink-valid-aria-semantics`],re=[`@react-router/dev`,`react-router-dom`,`react-router`],ie=[`Component`,`element`,`lazy`],ae=[`action`,`clientAction`,`clientLoader`,`loader`],oe=`react-router-csp-nonce-consistency.react-router-descendant-routes-require-splat.react-router-guard-aborted-handle-error.react-router-internal-route-anchor.react-router-loader-fetch-forwards-signal.react-router-loader-parallel-fetch.react-router-nested-route-requires-outlet.react-router-no-catch-middleware-next.react-router-no-client-module-in-server-render.react-router-no-duplicate-route-id.react-router-no-empty-leaf-route.react-router-no-invalid-absolute-child-path.react-router-no-invalid-lazy-route-properties.react-router-no-invalid-splat-path.react-router-no-loader-request-body.react-router-no-middleware-response-body-consumption.react-router-no-multiple-blockers.react-router-no-multiple-middleware-next.react-router-no-multiple-set-search-params-in-tick.react-router-no-navigate-in-render.react-router-no-nested-router.react-router-no-redirect-in-try-catch.react-router-no-route-module-environment-suffix.react-router-no-router-in-render.react-router-no-session-mutation-in-loader.react-router-no-static-cookie-expires.react-router-no-unsynchronized-search-params-mutation.react-router-no-use-loader-data-in-error-ui.react-router-prefer-route-lazy.react-router-require-root-error-boundary.react-router-resource-link-requires-reload.react-router-return-navigation-promise-in-transition.react-router-server-middleware-return-response.react-router-session-mutation-requires-commit.react-router-v8-no-meta-data-field.react-router-v8-no-react-router-dom-import.react-router-v8-no-removed-future-flags.react-router-valid-route-object`.split(`.`),se=new Set([`@react-router/cloudflare`,`@react-router/node`,`react-router/dom`,`react-router-dom`,`react-router`]),ce=new Set([`flash`,`set`,`unset`]),le=new Set([`createCookieSessionStorage`,`createFileSessionStorage`,`createMemorySessionStorage`,`createSessionStorage`,`createWorkersKVSessionStorage`]),ue=new Set([`createBrowserRouter`,`createHashRouter`,`createMemoryRouter`]),de=new Set([`append`,`delete`,`set`,`sort`]),fe=new Set([`caseSensitive`,`children`,`id`,`index`,`lazy`,`path`]),pe=new Set([`arrayBuffer`,`blob`,`bytes`,`formData`,`json`,`text`]),me=new Set([`unstable_previewServerPrerendering`,`v8_middleware`,`v8_passThroughRequests`,`v8_splitRouteModules`,`v8_trailingSlashAwareDataRequests`,`v8_viteEnvironmentApi`]),he=new Set([`BrowserRouter`,`HashRouter`,`MemoryRouter`,`Router`,`RouterProvider`]),ge=new Set([..._,`client-passive-event-listeners`,`effect-needs-cleanup`,`anchor-target-exists`,`exhaustive-deps`,`no-barrel-import`,`nextjs-async-dynamic-api-not-awaited`,`nextjs-missing-metadata`,`nextjs-no-img-element`,`nextjs-no-use-search-params-without-suspense`,`no-dynamic-import-path`,`no-full-lodash-import`,`no-hydration-branch-on-browser-global`,`no-img-without-dimensions`,`no-indeterminate-attribute`,`no-loading-flag-reset-outside-finally`,`no-locale-format-in-render`,`no-match-media-in-state-initializer`,`no-create-ref-in-function-component`,`no-reset-all-state-on-prop-change`,`no-side-effect-in-state-updater-function`,`no-adjust-state-on-prop-change`,`no-derived-state`,`no-derived-state-effect`,`no-event-handler`,`no-initialize-state`,`no-mutating-reducer-state`,`only-export-components`,`no-unguarded-browser-global-at-module-scope`,`no-unguarded-browser-global-in-render-or-hook-init`,`window-open-without-noopener`,`prefer-dynamic-import`,`rendering-hydration-mismatch-time`,`rendering-hydration-no-flicker`,`remotion-calculate-metadata-fetch-signal`,`remotion-deterministic-randomness`,`remotion-no-css-animation`,`remotion-no-css-transition`,`remotion-no-css-url-assets`,`remotion-no-native-media-elements`,`remotion-no-next-image`,`rerender-memo-with-default-value`,`rn-no-legacy-shadow-styles`,`rn-no-raw-text`,`rn-prefer-expo-image`,`rn-style-prefer-boxshadow`,...oe]),_e=new Set([`implements`,`returnType`,`superTypeArguments`,`superTypeParameters`,`typeAnnotation`,`typeArguments`,`typeParameters`]),ve={...r,...e,ArrayPattern:[`decorators`,...e.ArrayPattern],AssignmentPattern:[`decorators`,...e.AssignmentPattern],ClassDeclaration:[`decorators`,...e.ClassDeclaration],ClassExpression:[`decorators`,...e.ClassExpression],Identifier:[`decorators`,...e.Identifier],MethodDefinition:[`decorators`,...e.MethodDefinition],ObjectPattern:[`decorators`,...e.ObjectPattern],PropertyDefinition:[`decorators`,...e.PropertyDefinition],RestElement:[`decorators`,...e.RestElement]},ye=new Map,be=e=>e.filter(e=>e!==`parent`&&!_e.has(e)),xe=e=>{let t=ye.get(e.type);if(t)return t;let n=ve[e.type];if(!n)return be(Object.keys(e));let r=be(n);return ye.set(e.type,r),r},v=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,y=e=>e!=null&&(e.type===`ArrowFunctionExpression`||e.type===`FunctionExpression`||e.type===`FunctionDeclaration`),b=(e,t)=>typeof e==`object`&&!!e&&e.type===t,Se=e=>e===`var`||e===`function`,Ce=e=>{let t=e;for(;t;){if(t.kind===`module`||t.kind===`function`||t.kind===`arrow-function`||t.kind===`method`)return t;t=t.parent}return e},we=(e,t,n,r)=>{let i={id:r.nextScopeId++,kind:e,node:t,parent:n,children:[],symbols:[],references:[],symbolsByName:new Map};return n&&n.children.push(i),i},Te=(e,t,n)=>{let r=we(e,t,n.currentScope,n);return n.scopeStack.push(r),n.currentScope=r,n.ownScopeForNode.set(t,r),r},Ee=e=>{e.scopeStack.pop();let t=e.scopeStack[e.scopeStack.length-1];if(!t)throw Error(`scope stack underflow`);e.currentScope=t},x=(e,t,n)=>{let r={id:t.nextSymbolId++,name:n.name,kind:n.kind,bindingIdentifier:n.bindingIdentifier,declarationNode:n.declarationNode,scope:e,initializer:n.initializer,references:[]};return e.symbols.push(r),e.symbolsByName.set(n.name,r),t.symbolByBindingIdentifier.set(n.bindingIdentifier,r),r},S=(e,t,n,r,i,a)=>{if(b(e,`Identifier`)){x(n,r,{name:e.name,kind:i,bindingIdentifier:e,declarationNode:a,initializer:t});return}if(b(e,`ObjectPattern`)){for(let o of e.properties)if(b(o,`Property`)){let e=o.value;S(e,b(e,`AssignmentPattern`)?e.right:t,n,r,i,a)}else b(o,`RestElement`)&&S(o.argument,t,n,r,i,a);return}if(b(e,`ArrayPattern`)){for(let o of e.elements)o&&S(o,b(o,`AssignmentPattern`)?o.right??null:t,n,r,i,a);return}if(b(e,`AssignmentPattern`)){S(e.left,e.right??null,n,r,i,a);return}b(e,`RestElement`)&&S(e.argument,null,n,r,i,a)},De=(e,t,n)=>{let r={id:e.nextReferenceId++,identifier:t,resolvedSymbol:null,flag:n,scope:e.currentScope};e.currentScope.references.push(r),e.referenceByIdentifier.set(t,r)},Oe=e=>e.parent?y(e.parent):!1,ke=e=>e.parent!==null&&e.parent!==void 0&&e.parent.type===`CatchClause`,Ae=(e,t)=>{if(!b(e,`VariableDeclaration`))return;let n=e.kind===`var`?`var`:e.kind===`let`?`let`:e.kind===`const`?`const`:`using`,r=Se(n)?Ce(t.currentScope):t.currentScope;for(let i of e.declarations){let e=i,a=i.init??null;S(i.id,a,r,t,n,e)}},je=(e,t)=>{b(e,`FunctionDeclaration`)&&e.id&&x(Ce(t.currentScope),t,{name:e.id.name,kind:`function`,bindingIdentifier:e.id,declarationNode:e,initializer:e})},Me=(e,t)=>{b(e,`ClassDeclaration`)&&e.id&&x(t.currentScope,t,{name:e.id.name,kind:`class`,bindingIdentifier:e.id,declarationNode:e,initializer:e})},Ne=(e,t)=>{if(!b(e,`ImportDeclaration`))return;let n=Ce(t.currentScope);for(let r of e.specifiers){let e=r.local;b(e,`Identifier`)&&x(n,t,{name:e.name,kind:`import`,bindingIdentifier:e,declarationNode:r,initializer:r})}},Pe=(e,t)=>{if(e.type!==`TSImportEqualsDeclaration`&&e.type!==`TSEnumDeclaration`&&e.type!==`TSTypeAliasDeclaration`&&e.type!==`TSInterfaceDeclaration`&&e.type!==`TSModuleDeclaration`)return;let n=e.id;if(!n||!b(n,`Identifier`))return;let r=e.type===`TSImportEqualsDeclaration`?`ts-import-equals`:e.type===`TSEnumDeclaration`?`ts-enum`:e.type===`TSTypeAliasDeclaration`?`ts-type-alias`:e.type===`TSInterfaceDeclaration`?`ts-interface`:`ts-module`;x(Ce(t.currentScope),t,{name:n.name,kind:r,bindingIdentifier:n,declarationNode:e,initializer:null})},Fe=(e,t,n)=>{for(let r of e)S(r,null,t,n,`parameter`,r)},Ie=e=>!(!b(e,`BlockStatement`)||Oe(e)||ke(e)||e.parent&&e.parent.type===`TSModuleDeclaration`),Le=e=>{let t=e.parent;if(!t)return!1;if(t.type===`JSXMemberExpression`)return t.object===e;if(t.type===`JSXNamespacedName`)return!1;let n=e.name.charCodeAt(0);return!(n>=97&&n<=122)},Re=e=>{let t=e.parent;if(!t)return!1;switch(t.type){case`MemberExpression`:return t.property===e&&!t.computed;case`Property`:return t.key===e&&!t.computed&&!t.shorthand;case`MethodDefinition`:case`PropertyDefinition`:return t.key===e&&!t.computed;case`JSXAttribute`:return t.name===e;case`ImportSpecifier`:return t.imported===e;case`ExportSpecifier`:return t.exported===e&&t.local!==t.exported;case`LabeledStatement`:case`BreakStatement`:case`ContinueStatement`:return t.label===e;default:return!1}},ze=e=>{let t=e.parent;if(!t)return`read`;switch(t.type){case`AssignmentExpression`:return t.left===e?t.operator===`=`?`write`:`read-write`:`read`;case`UpdateExpression`:return`read-write`;case`ForInStatement`:case`ForOfStatement`:return t.left===e?`write`:`read`;default:return`read`}},Be=(e,t)=>{t.nodeScope.set(e,t.currentScope)},Ve=(e,t,n)=>{let r=Te(e,t,n);return Be(t,n),r},He=(e,t,n)=>{if(e.type===`AssignmentPattern`){He(e.left,t,n);let r=e.right??null;r&&C(r,t,n);return}if(e.type===`ObjectPattern`){for(let r of e.properties){let e=r;if(e.type===`RestElement`){He(e.argument,t,n);continue}if(e.type!==`Property`)continue;let i=e;i.computed&&C(i.key,t,n),He(i.value,t,n)}return}if(e.type===`ArrayPattern`){for(let r of e.elements)r&&He(r,t,n);return}e.type===`RestElement`&&He(e.argument,t,n)},C=(e,t,n)=>{if(e.type===`ArrowFunctionExpression`||e.type===`FunctionExpression`||e.type===`FunctionDeclaration`){e.type===`FunctionDeclaration`&&e.id&&je(e,t);let n=e.params??[],r=t.currentScope;for(let e of n)if(!(!(`decorators`in e)||!Array.isArray(e.decorators)))for(let n of e.decorators)v(n)&&C(n,t,r);Be(e,t);let i=Te(e.type===`ArrowFunctionExpression`?`arrow-function`:`function`,e,t);(e.type===`FunctionExpression`||e.type===`FunctionDeclaration`)&&e.id&&x(i,t,{name:e.id.name,kind:`function`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),Fe(n,i,t);for(let e of n)He(e,t,r);let a=e.body;a&&C(a,t,r),Ee(t);return}if(e.type===`ClassDeclaration`||e.type===`ClassExpression`){if(e.type===`ClassDeclaration`&&e.id&&Me(e,t),Array.isArray(e.decorators))for(let n of e.decorators)v(n)&&C(n,t,null);let n=Ve(`class`,e,t);e.type===`ClassExpression`&&e.id&&x(n,t,{name:e.id.name,kind:`class`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),e.superClass&&C(e.superClass,t,n),e.body&&C(e.body,t,n),Ee(t);return}if(e.type===`CatchClause`){let n=Ve(`catch`,e,t);e.param&&S(e.param,null,n,t,`catch-clause-parameter`,e),e.body&&C(e.body,t,n),Ee(t);return}if(e.type===`ForStatement`||e.type===`ForInStatement`||e.type===`ForOfStatement`){Ve(`for`,e,t),Ue(e,t),Ee(t);return}if(e.type===`SwitchStatement`){let n=Ve(`switch`,e,t);e.discriminant&&C(e.discriminant,t,n);for(let r of e.cases)C(r,t,n);Ee(t);return}if(e.type===`TSModuleDeclaration`){let n=Ve(`ts-module`,e,t);if(e.id&&b(e.id,`Identifier`)){let r=e.id;x(Ce(n.parent??t.currentScope),t,{name:r.name,kind:`ts-module`,bindingIdentifier:r,declarationNode:e,initializer:null})}e.body&&C(e.body,t,n),Ee(t);return}if(e.type===`TSEnumDeclaration`){Pe(e,t);let n=Ve(`ts-enum`,e,t),r=e.members??[];for(let e of r)C(e,t,n);Ee(t);return}if(e.type===`BlockStatement`&&Ie(e)){let n=Ve(`block`,e,t);for(let r of e.body)C(r,t,n);Ee(t);return}switch(t.currentScope!==n&&Be(e,t),e.type){case`VariableDeclaration`:Ae(e,t);break;case`ImportDeclaration`:Ne(e,t);break;case`TSImportEqualsDeclaration`:case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:Pe(e,t);break}(e.type===`Identifier`||e.type===`JSXIdentifier`)&&!t.symbolByBindingIdentifier.has(e)&&!Re(e)&&(e.type===`JSXIdentifier`?Le(e)&&De(t,e,ze(e)):De(t,e,ze(e))),Ue(e,t)},Ue=(e,t)=>{let n=e,r=t.currentScope;for(let i of xe(e)){let e=n[i];if(Array.isArray(e))for(let n of e)v(n)&&C(n,t,r);else v(e)&&C(e,t,r)}},We=e=>{let t=e=>{for(let t of e.references){let n=t.identifier.name;if(typeof n!=`string`)continue;let r=e;for(;r;){let e=r.symbolsByName.get(n);if(e){t.resolvedSymbol=e,e.references.push(t);break}r=r.parent}}for(let n of e.children)t(n)};t(e)},Ge=e=>{let t={id:0,kind:`module`,node:e,parent:null,children:[],symbols:[],references:[],symbolsByName:new Map},n={nextScopeId:1,nextSymbolId:0,nextReferenceId:0,currentScope:t,scopeStack:[t],rootScope:t,nodeScope:new WeakMap,ownScopeForNode:new WeakMap,symbolByBindingIdentifier:new WeakMap,referenceByIdentifier:new WeakMap};if(n.nodeScope.set(e,t),n.ownScopeForNode.set(e,t),e.type===`Program`)for(let r of e.body)C(r,n,t);else C(e,n,t);return We(t),{rootScope:t,scopeFor:e=>{let r=e;for(;r;){let e=n.nodeScope.get(r);if(e)return e;r=r.parent??null}return t},ownScopeFor:e=>n.ownScopeForNode.get(e)??null,symbolFor:e=>{let t=n.referenceByIdentifier.get(e);return t?t.resolvedSymbol:n.symbolByBindingIdentifier.get(e)||null},referenceFor:e=>n.referenceByIdentifier.get(e)??null,isGlobalReference:e=>{let t=n.referenceByIdentifier.get(e);return t?t.resolvedSymbol===null:!1}}},Ke=(e,t)=>{let n=e;for(;n;){if(n===t)return!0;n=n.parent}return!1},qe=`(?:tsx?|jsx?|mts|mjs)`,Je=RegExp(`/page\\.${qe}$`),Ye=RegExp(`/(page|layout)\\.${qe}$`),Xe=[`layout.tsx`,`layout.jsx`,`layout.ts`,`layout.js`,`layout.mts`,`layout.mjs`],Ze=[`metadata`,`generateMetadata`],Qe=/\/(?:(?:\((?:dashboard|admin|settings|account|internal|manage|console|portal|auth|onboarding|app|ee|protected)\))|(?:dashboard|admin|settings|account|internal|manage|console|portal))\//i,$e=new Set([`redirect`,`permanentRedirect`,`notFound`,`forbidden`,`unauthorized`]),et=new Set([`revalidateTag`,`revalidatePath`,`expireTag`,`expirePath`,`unstable_expireTag`,`unstable_expirePath`]),tt=/fonts\.googleapis\.com/,nt=/polyfill\.io|polyfill\.min\.js|cdn\.polyfill/,rt=RegExp(`/route\\.${qe}$`),it=/\/(?:cron|jobs\/cron)(?:\/|$)/i,at=new Set([`logout`,`log-out`,`signout`,`sign-out`,`unsubscribe`,`delete`,`remove`,`revoke`,`cancel`,`deactivate`]),ot=RegExp(`/(error|global-error)\\.${qe}$`),st=RegExp(`/global-error\\.${qe}$`),ct=new Set([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`OPTIONS`,`HEAD`]),lt=/google-analytics\.com|googletagmanager\.com\/gtag/,ut=RegExp(`/(opengraph-image|twitter-image)\\d*\\.${qe}$`),dt=1024,ft=2e6,pt=1e3,mt=new Set([`expo`,`expo-router`,`@expo/cli`,`@expo/metro-config`,`@expo/metro-runtime`]),ht=new Set([`react-native`,`react-native-tvos`,...mt,`react-native-windows`,`react-native-macos`]),gt=[`@react-native/`,`@react-native-`],_t=e=>mt.has(e),vt=e=>{if(ht.has(e))return!0;for(let t of gt)if(e.startsWith(t))return!0;return!1};let w=null;const yt=e=>{w?.existencePaths.add(e)},T=e=>{w?.contentPaths.add(e)},bt=()=>w!==null,xt=e=>{let t=w,n={existencePaths:new Set,contentPaths:new Set};w=n;try{return{value:e(),trace:n}}finally{if(w=t,t!==null){for(let e of n.existencePaths)t.existencePaths.add(e);for(let e of n.contentPaths)t.contentPaths.add(e)}}},St=e=>{if(w!==null){for(let t of e.existencePaths)w.existencePaths.add(t);for(let t of e.contentPaths)w.contentPaths.add(t)}},Ct=e=>xt(e).trace,wt=new Map,Tt=new Map;let Et=0;const Dt=()=>{wt.clear(),Tt.clear(),Et+=1},Ot=()=>Et,kt=e=>{if(!e)return null;let t=o.dirname(e),n=wt.get(t);if(n!==void 0){if(bt()){let e=t;for(;yt(o.join(e,`package.json`)),e!==n;){let t=o.dirname(e);if(t===e)break;e=t}}return n}let r=t;for(;;){let e=o.join(r,`package.json`);yt(e);let n=!1;try{n=i.statSync(e,{throwIfNoEntry:!1})?.isFile()??!1}catch{n=!1}if(n)return wt.set(t,r),r;let a=o.dirname(r);if(a===r)return wt.set(t,null),null;r=a}},At=e=>{let t=kt(e);return t?jt(t):null},jt=e=>{let t=Tt.get(e);if(t!==void 0&&!bt())return t;let n=o.join(e,`package.json`);if(T(n),t!==void 0)return t;let r=null;try{let e=JSON.parse(i.readFileSync(n,`utf-8`));typeof e==`object`&&e&&(r=e)}catch{r=null}return Tt.set(e,r),r},Mt=new Set([`next`,`vite`,`react-scripts`,`gatsby`,`@remix-run/react`,`@remix-run/node`,`@docusaurus/core`,`@docusaurus/preset-classic`,`@storybook/react`,`@storybook/react-vite`,`@storybook/react-webpack5`,`@storybook/nextjs`,`@storybook/web-components`,`storybook`,`react-dom`,`@vitejs/plugin-react`,`@vitejs/plugin-react-swc`]),Nt=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`],Pt=function*(e){for(let t of Nt){let n=e[t];if(n)for(let e of Object.keys(n))yield e}},Ft=e=>{if(typeof e[`react-native`]==`string`)return!0;for(let t of Pt(e))if(vt(t))return!0;return!1},It=e=>{for(let t of Pt(e))if(_t(t))return!0;return!1},Lt=e=>{for(let t of Pt(e))if(Mt.has(t))return!0;return!1},Rt=e=>Nt.some(t=>{let n=e[t];return typeof n==`object`&&!!n&&Object.keys(n).length>0}),zt=(e,t)=>Nt.some(n=>{let r=e[n];return typeof r==`object`&&!!r&&Object.prototype.propertyIsEnumerable.call(r,t)}),Bt=new WeakMap,Vt=e=>{let t=At(e);if(!t)return`unknown`;let n=Bt.get(t);if(n!==void 0)return n;let r;return r=It(t)?`expo`:Ft(t)?`react-native`:Lt(t)?`web`:Rt(t)?`neutral`:`unknown`,Bt.set(t,r),r},Ht=e=>b(e,`Identifier`)?e.name:b(e,`Literal`)&&typeof e.value==`string`?e.value:null,Ut=e=>{if(b(e,`ImportSpecifier`)){let t=e.imported;return b(t,`Identifier`)?t.name:b(t,`Literal`)&&typeof t.value==`string`?t.value:null}return b(e,`ImportDefaultSpecifier`)?`default`:null},Wt=(e,t)=>{if(!b(e,`ExportNamedDeclaration`)||!e.source||e.exportKind===`type`)return null;let n=e.source.value;if(typeof n!=`string`)return null;for(let r of e.specifiers??[]){let e=Gt(r,t,n);if(e)return e}return null},Gt=(e,t,n)=>{if(!b(e,`ExportSpecifier`)||e.exportKind===`type`||Ht(e.exported)!==t)return null;let r=Ht(e.local);return r?{importedName:r,source:n}:null},Kt=(e,t)=>{if(!b(e,`ExportAllDeclaration`)||!e.source||e.exportKind===`type`||e.exported)return null;let n=e.source.value;return typeof n==`string`?{importedName:t,source:n}:null},qt=(e,t)=>{if(!b(e,`Program`))return[];let n=[];for(let r of e.body??[]){let e=Wt(r,t);if(e)return[e];let i=Kt(r,t);i&&n.push(i)}return n},Jt=new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`,`TSNonNullExpression`,`TSInstantiationExpression`,`ChainExpression`]),E=e=>{let t=e;for(;;)switch(t.type){case`ParenthesizedExpression`:case`TSAsExpression`:case`TSSatisfiesExpression`:case`TSTypeAssertion`:case`TSNonNullExpression`:case`TSInstantiationExpression`:case`ChainExpression`:if(!(`expression`in t)||!t.expression)return t;t=t.expression;break;default:return t}},Yt=(e,t)=>{if(!b(e,`Program`))return null;let n=new Map,r=new Map,i=null,a=null,o=e=>{for(let t of e.declarations??[])b(t,`VariableDeclarator`)&&(!b(t.id,`Identifier`)||!t.init||n.set(t.id.name,E(t.init)))};for(let t of e.body??[]){if(b(t,`ImportDeclaration`)){if(t.importKind===`type`)continue;for(let e of t.specifiers??[])b(e,`ImportSpecifier`)&&e.importKind===`type`||(b(e,`ImportDefaultSpecifier`)||b(e,`ImportNamespaceSpecifier`)||b(e,`ImportSpecifier`))&&b(e.local,`Identifier`)&&n.set(e.local.name,e.local);continue}if(b(t,`VariableDeclaration`)){o(t);continue}if(b(t,`FunctionDeclaration`)&&t.id){n.set(t.id.name,t);continue}if(b(t,`ExportNamedDeclaration`)){if(t.exportKind===`type`)continue;let e=t.declaration;if(e&&b(e,`VariableDeclaration`)){o(e);for(let t of e.declarations??[])b(t,`VariableDeclarator`)&&b(t.id,`Identifier`)&&r.set(t.id.name,t.id.name)}else e&&b(e,`FunctionDeclaration`)&&e.id&&(n.set(e.id.name,e),r.set(e.id.name,e.id.name));if(t.source)continue;for(let e of t.specifiers??[]){if(!b(e,`ExportSpecifier`)||e.exportKind===`type`)continue;let t=b(e.local,`Identifier`)?e.local.name:null,n=null;b(e.exported,`Identifier`)?n=e.exported.name:b(e.exported,`Literal`)&&typeof e.exported.value==`string`&&(n=e.exported.value),t&&n&&r.set(n,t)}continue}if(!b(t,`ExportDefaultDeclaration`))continue;let e=t.declaration;e&&(b(e,`Identifier`)?a=e.name:((b(e,`FunctionDeclaration`)||b(e,`ClassDeclaration`))&&e.id&&n.set(e.id.name,e),i=E(e)))}if(t===`default`){if(i)return i;if(a){let e=n.get(a);if(e)return e}}let s=r.get(t);return s?n.get(s)??null:null},Xt=e=>{let t=(e,n)=>{let r=e;r.parent=n,r.range==null&&typeof r.start==`number`&&typeof r.end==`number`&&(r.range=[r.start,r.end]);let i=e;for(let n in i){if(n===`parent`||!Object.hasOwn(i,n))continue;let r=i[n];if(Array.isArray(r))for(let n=0;n<r.length;n+=1){let i=r[n];v(i)&&t(i,e)}else v(r)&&t(r,e)}};t(e,null)},Zt={".ts":`ts`,".tsx":`tsx`,".js":`js`,".jsx":`jsx`,".mjs":`js`,".cjs":`js`,".mts":`ts`,".cts":`ts`},Qt=e=>Zt[o.extname(e).toLowerCase()]??`tsx`;let $t=process.platform!==`win32`&&n();const en=(e,t)=>({astType:`ts`,lang:Qt(e),experimentalRawTransfer:t}),tn=(e,n)=>{if($t)try{return t(e,n,en(e,!0))}catch{$t=!1}return t(e,n,en(e,!1))},nn=({filename:e,sourceText:t,shouldAttachParentReferences:n=!0})=>{try{let r=tn(e,t);if(r.errors.some(e=>e.severity===`Error`))return null;let i=r.program;return n&&Xt(i),i}catch{return null}},rn=new Map,an=(e,t)=>{if(rn.delete(e),rn.set(e,t),rn.size>256){let e=rn.keys().next().value;e!==void 0&&rn.delete(e)}},on=e=>{e.endsWith(`.d.ts`)||e.endsWith(`.d.mts`)||e.endsWith(`.d.cts`)||T(e);let t;try{t=i.statSync(e,{throwIfNoEntry:!1})}catch{return null}if(!t?.isFile()||t.size>2e6)return null;let n=rn.get(e);if(n&&n.mtimeMs===t.mtimeMs&&n.size===t.size)return an(e,n),n.program;if(e.endsWith(`.d.ts`)||e.endsWith(`.d.mts`)||e.endsWith(`.d.cts`))return an(e,{mtimeMs:t.mtimeMs,size:t.size,program:null}),null;let r;try{r=i.readFileSync(e,`utf8`)}catch{return an(e,{mtimeMs:t.mtimeMs,size:t.size,program:null}),null}let a=nn({filename:e,sourceText:r});return an(e,{mtimeMs:t.mtimeMs,size:t.size,program:a}),a},sn=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.mts`,`.cts`],cn=[`import`,`default`,`module`,`browser`,`require`],ln=[`module`,`main`,`browser`],un={isDirectory:!0,isFile:!1},dn={isDirectory:!1,isFile:!0},fn={isDirectory:!1,isFile:!1},pn=new Map,mn=new Map,hn=e=>{yt(e);let t=pn.get(e);if(t)return t;let n=fn;try{let t=i.statSync(e,{throwIfNoEntry:!1});t?.isFile()?n=dn:t?.isDirectory()&&(n=un)}catch{return pn.set(e,fn),fn}return pn.set(e,n),n},gn=e=>hn(e).isFile?e:null,_n=e=>hn(e).isDirectory?e:null,vn=e=>{let t=o.extname(e);if(!sn.includes(t))return sn.map(t=>`${e}${t}`);let n=e.slice(0,-t.length);return t===`.js`?[e,`${n}.ts`,`${n}.tsx`,`${n}.jsx`]:t===`.jsx`?[e,`${n}.tsx`]:t===`.mjs`?[e,`${n}.mts`]:t===`.cjs`?[e,`${n}.cts`]:[e]},yn=e=>typeof e==`object`&&!!e,bn=e=>{if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=bn(t);if(e)return e}return null}if(!yn(e))return null;for(let t of cn){let n=bn(e[t]);if(n)return n}return null},xn=e=>{let t=e.exports;return t?bn(t)||(yn(t)?bn(t[`.`]):null):null},Sn=e=>{T(e);let t=mn.get(e);if(t!==void 0)return t;let n;try{n=JSON.parse(i.readFileSync(e,`utf8`))}catch{n=null}return mn.set(e,n),n},Cn=e=>Tn(e)||Tn(o.join(e,`index`)),wn=e=>{let t=_n(e);if(!t)return null;let n=Sn(o.join(t,`package.json`));if(!n)return null;let r=xn(n)??ln.map(e=>n[e]).find(e=>typeof e==`string`);return r?Cn(o.resolve(t,r)):null},Tn=e=>{let t=gn(e);if(t)return t;for(let t of vn(e)){let e=gn(t);if(e)return e}return null},En=e=>Tn(e)||wn(e)||Tn(o.join(e,`index`)),Dn=(e,t)=>En(o.resolve(o.dirname(e),t)),On=()=>{pn.clear(),mn.clear()},kn=[`tsconfig.json`,`jsconfig.json`],An=e=>typeof e==`object`&&!!e,jn=e=>{let t=``,n=!1,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=e[a+1];if(r){o===`
2
+ `&&(r=!1,t+=o);continue}if(i){o===`*`&&s===`/`&&(i=!1,a++);continue}if(n){t+=o,o===`\\`?(t+=s??``,a++):o===`"`&&(n=!1);continue}if(o===`"`){n=!0,t+=o;continue}if(o===`/`&&s===`/`){r=!0,a++;continue}if(o===`/`&&s===`*`){i=!0,a++;continue}t+=o}return t.replace(/,(\s*[}\]])/g,`$1`)},Mn=(e,t)=>{T(e),t.push(e);let n;try{n=i.readFileSync(e,`utf8`)}catch{return null}try{let e=JSON.parse(jn(n));return An(e)?e:null}catch{return null}},Nn=(e,t)=>{let n=e.endsWith(`.json`)?e:`${e}.json`;return e.startsWith(`./`)||e.startsWith(`../`)?o.resolve(t,n):o.join(t,`node_modules`,n)},Pn=e=>{let t=new Map;if(!An(e))return t;for(let[n,r]of Object.entries(e)){if(!Array.isArray(r))continue;let e=r.filter(e=>typeof e==`string`);e.length>0&&t.set(n,e)}return t},Fn=(e,t,n)=>{let r=Mn(e,n);if(!r)return null;let i=o.dirname(e),a=An(r.compilerOptions)?r.compilerOptions:{},s=typeof a.baseUrl==`string`?a.baseUrl:null,c=s!==null,l=s===null?i:o.resolve(i,s);if(An(a.paths))return{baseAbsolutePath:l,hasExplicitBaseUrl:c,paths:Pn(a.paths)};if(typeof r.extends==`string`&&t<8){let e=Nn(r.extends,i),a=e?Fn(e,t+1,n):null;if(a)return a}return c?{baseAbsolutePath:l,hasExplicitBaseUrl:c,paths:new Map}:null},In=new Map,Ln=new Map,Rn=e=>{T(e);let t;try{t=i.statSync(e,{throwIfNoEntry:!1})}catch{t=void 0}if(t===void 0)return{config:null,probedContentPaths:new Set([e])};let n=In.get(e);if(n&&n.mtimeMs===t.mtimeMs){for(let e of n.probedChainPaths)T(e);return{config:n.config,probedContentPaths:new Set(n.probedChainPaths)}}let r=[],a=Fn(e,0,r);return In.set(e,{mtimeMs:t.mtimeMs,config:a,probedChainPaths:r}),{config:a,probedContentPaths:new Set(r)}},zn=(e,t,n)=>{let r=new Set(t.probedContentPaths),i=n;for(let n=e.length-1;n>=0;n--){let a=e[n];i++;for(let e of a.probedContentPaths)r.add(e);Ln.set(a.directory,{config:t.config,directoryCount:i,probedContentPaths:new Set(r)})}},Bn=e=>{let t=Ln.get(e);if(t!==void 0){for(let e of t.probedContentPaths)T(e);return t.config}let n=[],r=e;for(let e=0;e<30;e++){let t=Ln.get(r),i=30-e;if(t!==void 0&&t.directoryCount<=i){for(let e of t.probedContentPaths)T(e);return zn(n,t,t.directoryCount),t.config}let a=new Set;for(let e of kn){let t=Rn(o.join(r,e));for(let e of t.probedContentPaths)a.add(e);if(t.config)return n.push({directory:r,probedContentPaths:a}),zn(n,{config:t.config,probedContentPaths:new Set},0),t.config}n.push({directory:r,probedContentPaths:a});let s=o.dirname(r);if(s===r)return zn(n,{config:null,probedContentPaths:new Set},0),null;r=s}let i=new Set;for(let e of n)for(let t of e.probedContentPaths)i.add(t);return Ln.set(e,{config:null,directoryCount:n.length,probedContentPaths:i}),null},Vn=(e,t)=>{let n=t.indexOf(`*`);if(n===-1)return e===t?``:null;let r=t.slice(0,n),i=t.slice(n+1);return e.length>=r.length+i.length&&e.startsWith(r)&&e.endsWith(i)?e.slice(r.length,e.length-i.length):null},Hn=(e,t)=>{let n=Bn(o.dirname(e));if(!n)return null;let r=null,i=``,a=-1;for(let e of n.paths.keys()){let n=Vn(t,e);if(n===null)continue;let o=e.indexOf(`*`),s=o===-1?e.length:o;s>a&&(r=e,i=n,a=s)}if(r)for(let e of n.paths.get(r)??[]){let t=e.replaceAll(`*`,i),r=En(o.resolve(n.baseAbsolutePath,t));if(r)return r}return n.hasExplicitBaseUrl?En(o.resolve(n.baseAbsolutePath,t)):null},Un=()=>{In.clear(),Ln.clear()},Wn=(e,t)=>o.isAbsolute(t)?null:t.startsWith(`.`)?Dn(e,t):Hn(e,t),Gn=new Map,Kn=()=>{Gn.clear()},qn=(e,t,n)=>{if(n.size>=4||n.has(e))return null;n.add(e);let r=on(e);if(!r)return null;let i=Yt(r,t);if(i)return{filePath:e,exportedNode:i,programNode:r};let a=new Map;for(let i of qt(r,t)){let t=Wn(e,i.source);if(!t)continue;let r=qn(t,i.importedName,new Set(n));r&&a.set(r.exportedNode,r)}return a.size===1?a.values().next().value??null:null},Jn=(e,t,n)=>Yn(e,t,n)?.functionNode??null,Yn=(e,t,n)=>{let r=D(e,t,n);return!r||!y(r.exportedNode)?null:{filePath:r.filePath,functionNode:r.exportedNode,programNode:r.programNode}},D=(e,t,n)=>{if(!bt()){let r=Wn(e,t);return r?qn(r,n,new Set):null}let r=`${e}\0${t}\0${n}`,i=Gn.get(r);if(i!==void 0){for(let e of i.trace.contentPaths)T(e);for(let e of i.trace.existencePaths)yt(e);return i.result}let a=xt(()=>{let r=Wn(e,t);return r?qn(r,n,new Set):null});return Gn.set(r,{result:a.value,trace:a.trace}),a.value},Xn=(e,t)=>{let n=e,r=ve[e.type];if(r!==void 0){for(let e=r.length-1;e>=0;--e){let i=n[r[e]];if(Array.isArray(i))for(let e=i.length-1;e>=0;--e){let n=i[e];v(n)&&t.push(n)}else v(i)&&t.push(i)}return}let i=Object.keys(n);for(let e=i.length-1;e>=0;--e){let r=i[e];if(r===`parent`)continue;let a=n[r];if(Array.isArray(a))for(let e=a.length-1;e>=0;--e){let n=a[e];v(n)&&t.push(n)}else v(a)&&t.push(a)}},Zn=(e,t)=>{let n=e,r=ve[e.type];if(r!==void 0){for(let e=0;e<r.length;e+=1){let i=n[r[e]];if(Array.isArray(i))for(let e=0;e<i.length;e+=1){let n=i[e];v(n)&&t(n)}else v(i)&&t(i)}return}for(let e in n){if(e===`parent`||!Object.hasOwn(n,e))continue;let r=n[e];if(Array.isArray(r))for(let e=0;e<r.length;e+=1){let n=r[e];v(n)&&t(n)}else v(r)&&t(r)}},O=(e,t)=>{if(!e||typeof e!=`object`)return;let n=[e];for(;n.length>0;){let e=n.pop();e===void 0||t(e)===!1||Xn(e,n)}},Qn=({absoluteFilePath:e,staticImports:t,program:n})=>{let r=new Set;if(O(n,e=>{if(e.type!==`JSXOpeningElement`)return;let t=e.name;if(t){if(t.type===`JSXIdentifier`){let e=t.name;typeof e==`string`&&r.add(e)}else if(t.type===`JSXMemberExpression`){let e=t.property;e?.type===`JSXIdentifier`&&typeof e.name==`string`&&r.add(e.name)}else if(t.type===`JSXNamespacedName`){let e=t.namespace;typeof e?.name==`string`&&r.add(e.name)}}}),r.size!==0)for(let n of t)for(let t of n.entries){let{importName:i}=t;if(i.kind===`NamespaceObject`||!r.has(t.localName.value))continue;let a=i.kind===`Default`?`default`:i.name;a&&Jn(e,n.moduleRequest.value,a)}},$n=e=>e.replace(/^type\s+/,``).trim(),er=(e,t)=>e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>{let n=t||e.startsWith(`type `),[r,i]=e.split(/\s+as\s+/),a=$n(r??``);return{localName:a,exportedName:$n(i??a),isTypeOnly:n}}),tr=/\/\*[\s\S]*?\*\//g,nr=/^\s*\/\/.*$/gm,rr=e=>e.replace(tr,``).replace(nr,``),ir=/^\s*export\s+default\b/m,ar=/^\s*export\s+(?:declare\s+)?(?:(?:async\s+)?function|(?:abstract\s+)?class|const|let|var|enum|interface|type)\s+([\w$]+)/gm,or=/^\s*export\s+(?:type\s+)?\{([\s\S]*?)\}(?:\s+from\s+["'][^"']+["'])?\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,sr=e=>{let t=rr(e),n=new Set;ir.test(t)&&n.add(`default`);for(let e of t.matchAll(ar))e[1]&&n.add(e[1]);for(let e of t.matchAll(or)){let t=e[1]??``;for(let e of er(t,!1))n.add(e.exportedName)}return n},cr=new Map,lr=(e,t)=>{T(e);try{let n=i.statSync(e,{throwIfNoEntry:!1});if(n===void 0)return!1;let r=cr.get(e);if(r&&r.mtimeMs===n.mtimeMs&&r.size===n.size)return r.exportedNames.has(t);let a=sr(i.readFileSync(e,`utf8`));return cr.set(e,{mtimeMs:n.mtimeMs,size:n.size,exportedNames:a}),a.has(t)}catch{return!1}},ur=(e,t)=>{let n=e.replaceAll(`\\`,`/`),r=o.dirname(n);for(let e=0;e<30;e++){for(let e of Xe){let i=o.join(r,e);if(i.replaceAll(`\\`,`/`)!==n&&t(i))return!0}let e=o.dirname(r);if(o.basename(r)===`app`&&o.basename(e)!==`app`||e===r)break;r=e}return!1},dr=e=>ur(e,e=>Ze.some(t=>lr(e,t))),k=e=>{if(!b(e,`ImportSpecifier`))return;let t=e.imported;if(b(t,`Identifier`))return t.name;if(b(t,`Literal`)&&typeof t.value==`string`)return t.value},fr=e=>b(e,`JSXIdentifier`)?e.name===`Suspense`:b(e,`JSXMemberExpression`)&&b(e.property,`JSXIdentifier`)&&e.property.name===`Suspense`,pr=e=>{let t=!1;return O(e,e=>{if(t)return!1;if(b(e,`JSXOpeningElement`)&&fr(e.name)||b(e,`ImportDeclaration`)&&e.source?.value===`react`&&(e.specifiers??[]).some(e=>b(e,`ImportSpecifier`)&&k(e)===`Suspense`))return t=!0,!1}),t},mr=e=>ur(e,e=>{let t=on(e);return!!(t&&pr(t))}),hr=e=>{if(b(e,`ImportDeclaration`)){if(e.importKind===`type`||e.specifiers.length>0&&e.specifiers.every(e=>b(e,`ImportSpecifier`)&&e.importKind===`type`))return null}else if(b(e,`ExportNamedDeclaration`)){if(e.exportKind===`type`||!e.source||e.specifiers.length>0&&e.specifiers.every(e=>b(e,`ExportSpecifier`)&&e.exportKind===`type`))return null}else if(b(e,`ExportAllDeclaration`)){if(e.exportKind===`type`)return null}else return null;return e.source&&typeof e.source.value==`string`?e.source.value:null},A=e=>{let t=e.property;return!e.computed&&b(t,`Identifier`)?t.name:e.computed&&b(t,`Literal`)?typeof t.value==`string`?t.value:null:e.computed&&b(t,`TemplateLiteral`)&&t.expressions.length===0?t.quasis[0]?.value.cooked??t.quasis[0]?.value.raw??null:null},gr=/^index\.(?:[cm]?[jt]sx?|mjs)$/,_r=/^\s*import\s+(type\s+)?(?!["'])([^;]*?)\s+from\s+["']([^"']+)["']\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,vr=/^\s*export\s+(type\s+)?(?:\*(?:\s+as\s+([\w$]+))?|\{([\s\S]*?)\})\s+from\s+["']([^"']+)["']\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,yr=/^\s*export\s+(type\s+)?\{([\s\S]*?)\}\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,br=new Map,xr=e=>gr.test(o.basename(e)),Sr=()=>({isBarrel:!1,exportsByName:new Map,starExportSources:[]}),Cr=(e,t)=>{e.set(t.localName,{...t,didExport:!1})},wr=(e,t,n,r)=>{for(let i of er(e,n))Cr(r,{localName:i.exportedName,importedName:i.localName,source:t,isTypeOnly:i.isTypeOnly})},Tr=(e,t,n,r)=>{let i=e.trim(),a=i.match(/(?:^|,\s*)\*\s+as\s+([\w$]+)/);a?.[1]&&Cr(r,{localName:a[1],importedName:`*`,source:t,isTypeOnly:n});let o=i.match(/\{([\s\S]*?)\}/);o?.[1]&&wr(o[1],t,n,r);let s=i.split(`,`)[0]?.trim();s&&!s.startsWith(`{`)&&!s.startsWith(`*`)&&Cr(r,{localName:s,importedName:`default`,source:t,isTypeOnly:n})},Er=(e,t,n,r)=>{let i=e.replace(_r,(e,n,r,i)=>(Tr(r,i,!!n,t),``));return i=i.replace(vr,(e,t,i,a,o)=>{let s=!!t;if(i)return n.set(i,{exportedName:i,importedName:`*`,source:o,isTypeOnly:s}),``;if(a){for(let e of er(a,s))n.set(e.exportedName,{exportedName:e.exportedName,importedName:e.localName,source:o,isTypeOnly:e.isTypeOnly});return``}return r.push(o),``}),i=i.replace(yr,(e,r,i)=>{for(let a of er(i,!!r)){let r=t.get(a.localName);if(!r)return e;r.didExport=!0,n.set(a.exportedName,{exportedName:a.exportedName,importedName:r.importedName,source:r.source,isTypeOnly:a.isTypeOnly||r.isTypeOnly})}return``}),i},Dr=e=>{for(let t of e.values())if(!t.isTypeOnly&&!t.didExport)return!0;return!1},Or=e=>{let t=rr(e).trim();if(!t)return Sr();let n=new Map,r=new Map,i=[];return Er(t,n,r,i).trim()||Dr(n)?Sr():{isBarrel:r.size>0||i.length>0,exportsByName:r,starExportSources:i}},kr=e=>{if(!xr(e))return Sr();T(e);let t;try{t=i.statSync(e,{throwIfNoEntry:!1})??null}catch{t=null}let n=br.get(e);if(n!==void 0&&t!==null&&n.mtimeMs===t.mtimeMs&&n.size===t.size)return n.moduleInfo;if(t===null)return Sr();let r=Sr();try{r=Or(i.readFileSync(e,`utf8`))}catch{r=Sr()}return br.set(e,{mtimeMs:t.mtimeMs,size:t.size,moduleInfo:r}),r},Ar=e=>kr(e).isBarrel,jr=o.join(`android`,`gradle.properties`),Mr=/^\s*newArchEnabled\s*=\s*false\s*$/m,Nr=[`app.config.ts`,`app.config.js`,`app.config.cjs`,`app.config.mjs`],Pr=[`app.config.json`,`app.json`],Fr=new WeakMap,Ir=e=>{T(o.join(e,jr));for(let t of Nr)yt(o.join(e,t));for(let t of Pr)T(o.join(e,t))},Lr=e=>{try{return i.readFileSync(e,`utf-8`)}catch{return null}},Rr=e=>{let t=e.dependencies?.[`react-native`]??e.devDependencies?.[`react-native`];return typeof t==`string`?t:null},zr=e=>{let t=e.match(/(?:^|[^\d.])0\.(\d+)/);return t?Number.parseInt(t[1],10):null},Br=e=>{let t=Lr(o.join(e,jr));return t!==null&&Mr.test(t)},Vr=e=>{for(let t of Nr)if(i.existsSync(o.join(e,t)))return!1;for(let t of Pr){let n=Lr(o.join(e,t));if(n===null)continue;let r;try{r=JSON.parse(n)}catch{continue}if(typeof r!=`object`||!r)continue;let i=Object.getOwnPropertyDescriptor(r,`expo`)?.value;if(!(typeof i!=`object`||!i)&&Object.getOwnPropertyDescriptor(i,`newArchEnabled`)?.value===!1)return!0}return!1},Hr=(e,t)=>{let n=Rr(t);if(n!==null){let e=zr(n);if(e!==null&&e<76)return!0}return Br(e)||Vr(e)},Ur=e=>{let t=kt(e);if(!t)return!1;let n=At(e);if(!n)return!1;Ir(t);let r=Fr.get(n);if(r!==void 0)return r;let i=Hr(t,n);return Fr.set(n,i),i},Wr=new Map;let Gr=Ot();const Kr=e=>{let t=e.match(/^(\d+)(?:\.(\d+))?(?:\.(\d+))?(-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/);return t?{major:Number(t[1]),minor:Number(t[2]??0),patch:Number(t[3]??0),isPrerelease:!!t[4]}:null},qr=(e,t)=>e.major-t.major||e.minor-t.minor||e.patch-t.patch||Number(t.isPrerelease)-Number(e.isPrerelease),Jr=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t||/^(?:catalog|file|git|https?|link|npm|workspace):/.test(t)||/^(?:latest|next|\*)$/.test(t))return null;let n=[];for(let e of t.split(`||`)){let t=e.trim();if(/^<(?!=)/.test(t)||/^<=/.test(t))return null;let r=t.match(/\d+(?:\.\d+)?(?:\.\d+)?(?:-[0-9A-Za-z.-]+)?/)?.[0];if(!r)return null;let i=Kr(r);if(!i)return null;n.push(i)}return n.reduce((e,t)=>qr(t,e)<0?t:e)},Yr=e=>Jr(e.dependencies?.ink??e.devDependencies?.ink??e.peerDependencies?.ink??e.optionalDependencies?.ink),Xr=e=>{let t=e;for(;;){let e=jt(o.join(t,`node_modules`,`ink`));if(e)return{didFindPackage:!0,version:typeof e.version==`string`?Kr(e.version):null};let n=o.dirname(t);if(n===t)return{didFindPackage:!1,version:null};t=n}},Zr=e=>{let t=Xr(e);if(t.didFindPackage)return t.version;let n=jt(e);return n?Yr(n):null},Qr=e=>{if(!e)return null;let t=kt(o.resolve(e));if(!t)return null;let n=Ot();n!==Gr&&(Wr.clear(),Gr=n);let r=Wr.get(t);if(r)return St(r.trace),r.version;let{value:i,trace:a}=xt(()=>Zr(t));return Wr.set(t,{version:i,trace:a}),i},$r=(e,t)=>{let n=Qr(e),r=Kr(t);return!!(n&&r&&qr(n,r)>=0)},ei=new Set([`@monaco-editor/react`,`monaco-editor`,`recharts`,`@react-pdf/renderer`,`react-quill`,`@codemirror/view`,`@codemirror/state`,`chart.js`,`react-chartjs-2`,`@toast-ui/editor`,`draft-js`,`mermaid`]),ti=new Set([`fetch`,`ky`,`got`,`wretch`,`ofetch`]),ni=new Set([`axios`,`ky`,`got`,`ofetch`,`wretch`,`request`]),ri=new Set([`create`,`insert`,`insertInto`,`update`,`upsert`,`delete`,`remove`,`destroy`,`set`,`append`]),ii=new Set([`POST`,`PUT`,`DELETE`,`PATCH`]),ai=new Set([`Map`,`Set`,`WeakMap`,`WeakSet`,`Headers`,`URLSearchParams`,`FormData`,`Response`,`NextResponse`]),oi=new Set([`Response`,`NextResponse`]),si=new Set([`json`,`redirect`,`next`,`rewrite`,`error`]),ci=new Set([`wheel`,`mousewheel`,`touchstart`,`touchmove`]),li=new Set([`defer`,`async`]),ui=new Set([`text/javascript`,`application/javascript`,`module`]),di=new Set([`setTimeout`,`setInterval`,`requestAnimationFrame`,`requestIdleCallback`,`queueMicrotask`]),fi=new Set([`setInterval`,`setTimeout`]),pi=new Set([`clearInterval`,`clearTimeout`]),mi=new Set([`WebSocket`,`EventSource`,`BroadcastChannel`,`RTCPeerConnection`]),hi=new Set([`location`,`window`,`document`,`navigator`,`history`,`screen`,`performance`]),gi=new Set([`IntersectionObserver`,`MutationObserver`,`ResizeObserver`,`PerformanceObserver`]),_i=new Set([`blur`,`canPlayType`,`focus`,`getBoundingClientRect`,`getClientRects`,`measure`,`measureInWindow`,`measureLayout`,`scroll`,`scrollBy`,`scrollIntoView`,`scrollTo`,`select`,`setRangeText`,`setSelectionRange`]),vi=new Set([`localStorage`,`sessionStorage`]),yi=new Set([`index`,`idx`,`i`]),bi=new Set([`react`,`react-dom`,`preact/compat`,`preact/hooks`,`@wordpress/element`]),xi=new Set([`next`,`next-themes`,`@remix-run/react`,`swr`,`zustand`,`jotai`,`recoil`,`wouter`,`framer-motion`,`@apollo/client`,`urql`,`usehooks-ts`]),Si=new Set([`useState`,`useMemo`,`useRef`]),Ci=new Set([`Click`,`Change`,`Input`,`Blur`,`Focus`]),wi=new Set([`Boolean`,`String`,`Number`,`Array`,`Object`,`parseInt`,`parseFloat`]),Ti=/^set[A-Z]/,Ei=/^render[A-Z]/,Di=/^[A-Z]/,Oi=/^on[A-Z]/,ki=/^use[A-Z]/,Ai=/^(?:on|handle)[A-Z]/,ji=new Set([`useEffect`,`useLayoutEffect`]),Mi=new Set([`useEffect`,`useLayoutEffect`,`useMemo`,`useCallback`]),Ni=new Set([`use`,`useState`,`useRef`,`useMemo`,`useCallback`,`useReducer`,`useContext`,`useEffect`,`useLayoutEffect`,`useInsertionEffect`,`useImperativeHandle`,`useSyncExternalStore`,`useDeferredValue`,`useTransition`,`useId`,`useDebugValue`]),Pi=new Set([`memo`,`forwardRef`,`React.memo`,`React.forwardRef`]),Fi=new Set([`useMemo`,`useCallback`]),Ii=new Set([`memo`,`forwardRef`,`observer`,`lazy`]),Li=new Set([`subscribe`,`addEventListener`,`addListener`,`on`,`watch`,`listen`,`sub`]),Ri=new Set([`subscribe`,`sub`,`listen`]),zi=new Set([`unsubscribe`,`removeEventListener`,`removeListener`,`off`,`unwatch`,`unlisten`,`unsub`,`abort`,`disconnect`,`unobserve`,`close`]),Bi=new Set([`remove`,`cleanup`,`dispose`,`destroy`,`stop`,`teardown`]),Vi=new Set([...zi,`cleanup`,`dispose`,`destroy`,`teardown`]),Hi=new Set([...Li,`connect`,`disconnect`,`open`,`close`,`fetch`,`post`,`put`,`patch`]),Ui=new Set([`get`,`head`,`options`,`delete`]),Wi=new Set([...ti,...di]),Gi=new Set([...ti,`post`,`put`,`patch`,`navigate`,`navigateTo`,`showNotification`,`toast`,`alert`,`confirm`,`logVisit`,`captureEvent`]),Ki=new Set([`post`,`put`,`patch`,`delete`,`navigate`,`capture`,`track`,`logEvent`]),qi=new Set([`push`,`replace`]),Ji=new Set([`router`,`navigation`,`navigator`,`history`,`location`]),j=(e,t={})=>{if(!b(e,`Property`)&&!b(e,`MethodDefinition`)&&!b(e,`PropertyDefinition`)&&!b(e,`MemberExpression`))return null;let n=b(e,`MemberExpression`)?e.property:e.key;if(e.computed)return t.allowComputedString&&b(n,`Literal`)&&typeof n.value==`string`?n.value:t.allowComputedString&&t.stringifyNonStringLiterals&&b(n,`Literal`)?String(n.value):t.allowComputedString&&b(n,`TemplateLiteral`)&&n.expressions.length===0?n.quasis[0]?.value.cooked??n.quasis[0]?.value.raw??null:null;if(b(n,`Identifier`))return n.name;if(b(n,`Literal`)){if(typeof n.value==`string`)return n.value;if(t.stringifyNonStringLiterals)return String(n.value)}return null},M=(e,t,n=!1)=>{if(e.type!==`Identifier`&&e.type!==`JSXIdentifier`)return null;let r=null,i=t.symbolFor(e);for(;i?.kind===`const`;){if(!i.initializer||i.declarationNode.type!==`VariableDeclarator`)return null;if(i.declarationNode.id!==i.bindingIdentifier)return n?i:null;let e=E(i.initializer);if(e.type!==`Identifier`)return i;if(r?.has(i.id))return null;r||=new Set,r.add(i.id),i=t.symbolFor(e)}return i},Yi={},Xi=new WeakMap,Zi=(e,t)=>typeof e==`string`?e===t:e.has(t),Qi=e=>{let t=Xi.get(e);if(t)return t;let n=e.declarationNode.parent,r=!!(e.kind===`import`&&n&&n.type===`ImportDeclaration`&&typeof n.source.value==`string`&&bi.has(n.source.value)),i={importedName:r?k(e.declarationNode):void 0,isReactImport:r};return Xi.set(e,i),i},$i=e=>Qi(e).isReactImport,ea=(e,t,n,r)=>{if(e.type!==`Identifier`)return!1;let i=r?M(e,n):n.symbolFor(e);if(!i)return!1;let a=Qi(i);return!!(a.isReactImport&&a.importedName&&Zi(t,a.importedName))},ta=(e,t)=>{let n=M(e,t);if(!n)return!1;let r=Qi(n);return r.isReactImport?n.declarationNode.type===`ImportDefaultSpecifier`||n.declarationNode.type===`ImportNamespaceSpecifier`||r.importedName===`default`:!1},na=(e,t,n)=>e.type===`Identifier`?ta(e,t)?!0:!!(n.allowGlobalReactNamespace&&e.name===`React`&&t.isGlobalReference(e)):!1,ra=(e,t,n,r)=>{let i=n.symbolFor(e);if(!i||i.kind!==`const`||!i.initializer||i.declarationNode.type!==`VariableDeclarator`)return!1;let a=i.declarationNode.id;if(a.type!==`ObjectPattern`)return!1;for(let e of a.properties){if(e.type!==`Property`||e.value!==i.bindingIdentifier)continue;let a=j(e);return!!(a&&Zi(t,a)&&na(E(i.initializer),n,r))}return!1},ia=(e,t,n,r=Yi)=>e.type===`CallExpression`?aa(e.callee,t,n,r):!1,aa=(e,t,n,r,i)=>{let a=E(e);if(r.resolveConditionalAliases&&a.type===`ConditionalExpression`)return aa(a.consequent,t,n,r,new Set(i))&&aa(a.alternate,t,n,r,new Set(i));if(a.type===`Identifier`){if(ea(a,t,n,!!r.resolveNamedAliases)||r.resolveNamedAliases&&ra(a,t,n,r))return!0;if(r.resolveConditionalAliases){let e=n.symbolFor(a);if(e?.kind===`const`&&e.initializer&&!i?.has(e.id)){let a=i??new Set;return a.add(e.id),aa(e.initializer,t,n,r,a)}}return!!(r.allowUnboundBareCalls&&Zi(t,a.name)&&n.isGlobalReference(a))}return a.type!==`MemberExpression`||!Zi(t,A(a)??``)?!1:na(E(a.object),n,r)},N=e=>e.includes(`\\`)?e.replaceAll(`\\`,`/`):e,oa=e=>{let t=new Set(e);if(t.size!==1)return null;let[n]=t;return n??null},sa=(e,t,n,r)=>{let i=Dn(e,n);return i?ca(i,t,new Set(r))||(lr(i,t)?i:null):null},ca=(e,t,n=new Set)=>{if(n.has(e))return null;n.add(e);let r=kr(e);if(!r.isBarrel)return null;let i=r.exportsByName.get(t);if(i){let t=Dn(e,i.source);return t?ca(t,i.importedName,n)??t:null}return t===`default`?null:oa(r.starExportSources.map(r=>sa(e,t,r,n)).filter(e=>!!e))},la=(e,t,n)=>{let r=D(e,t,n);return r?{filePath:r.filePath,node:r.exportedNode,programNode:r.programNode,kind:y(r.exportedNode)?`function`:`initializer`}:null},P=e=>{let t=e;for(;t.parent&&Jt.has(t.parent.type);)t=t.parent;return t},ua=(e,t)=>{if(!b(e,`ArrowFunctionExpression`)&&!b(e,`FunctionExpression`)&&!b(e,`FunctionDeclaration`))return null;let n=e.params[0],r=b(n,`AssignmentPattern`)?n.left:n;if(b(r,`ObjectPattern`)){let e=r.properties.find(e=>b(e,`Property`)&&j(e,{allowComputedString:!0})===`children`);if(!e||!b(e,`Property`))return null;let n=b(e.value,`AssignmentPattern`)?e.value.left:e.value;if(!b(n,`Identifier`))return null;let i=t.symbolFor(n);return!i||i.references.length===0||i.references.some(e=>e.flag!==`read`)?null:i.references.map(e=>e.identifier)}if(!b(r,`Identifier`))return null;let i=t.symbolFor(r);if(!i||i.references.length===0)return null;let a=[];for(let e of i.references){if(e.flag!==`read`)return null;let t=[],n=P(e.identifier);for(;n.parent&&b(n.parent,`MemberExpression`)&&n.parent.object===n;){let e=A(n.parent);if(!e)return null;t.push(e),n=P(n.parent)}if(t[0]!==`children`){if(t.length===0)return null;continue}if(t.length!==1)return null;a.push(n)}return a.length>0?a:null},F=e=>{let t=e.parent;for(;t;){if(y(t))return t;t=t.parent??null}return null},da=e=>{let t=e;for(;t;){if(b(t,`Program`))return t;t=t.parent??null}return null},fa=e=>{let t=new Map,n=e.body??[];for(let e of n){if(e.type!==`ImportDeclaration`||!(`source`in e)||!e.source)continue;let n=e.source.value;if(typeof n==`string`&&!(!(`specifiers`in e)||!Array.isArray(e.specifiers)))for(let r of e.specifiers){if(!(`local`in r)||!r.local)continue;let e=r.local;if(typeof e.name==`string`){if(r.type===`ImportDefaultSpecifier`)t.set(e.name,{source:n,imported:null,isDefault:!0,isNamespace:!1});else if(r.type===`ImportNamespaceSpecifier`)t.set(e.name,{source:n,imported:null,isDefault:!1,isNamespace:!0});else if(r.type===`ImportSpecifier`){let i=r.imported,a=i?.name??(typeof i?.value==`string`?i.value:null);t.set(e.name,{source:n,imported:a,isDefault:!1,isNamespace:!1})}}}}return t},pa=new WeakMap,ma=e=>{let t=da(e);if(!t)return null;let n=pa.get(t);return n||(n=fa(t),pa.set(t,n)),n},ha=(e,t)=>{let n=ma(e);if(!n)return!1;for(let e of n.values())if(t.includes(e.source))return!0;return!1},ga=(e,t,n)=>{let r=ma(e);if(!r)return!1;let i=r.get(t);return i?i.source===n:!1},_a=(e,t,n)=>{let r=ma(e);if(!r)return!1;let i=r.get(t);return i?i.isNamespace&&i.source===n:!1},va=(e,t,n)=>{let r=ma(e);if(!r)return!1;let i=r.get(t);return i?i.isDefault&&i.source===n:!1},ya=(e,t,n)=>{let r=ma(e);if(!r)return null;let i=r.get(t);return!i||i.source!==n?null:i.imported},ba=(e,t)=>{let n=ma(e);return n?n.get(t)?.source??null:null},xa=(e,t)=>{let n=ma(e)?.get(t);return n?n.isNamespace?{source:n.source,exportedName:null,isNamespace:!0}:{source:n.source,exportedName:n.isDefault?`default`:n.imported,isNamespace:!1}:null},Sa=e=>{let t=e,n=t.parent;for(;n&&E(n)===e;)t=n,n=t.parent;return n&&b(n,`AssignmentExpression`)&&n.operator===`=`&&n.left===t?n.right:null},Ca=e=>{let t=e.range?.[0];return typeof t==`number`?t:null},wa=new Set([`let`,`var`]),Ta=new Set([`ConditionalExpression`,`LogicalExpression`]),Ea=new WeakMap,Da=(e,t,n)=>{let r=e.parent??null;for(;r&&n.blockOf(r)===t;){if(Ta.has(r.type))return!0;r=r.parent??null}return!1},Oa=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),ka=(e,t)=>{let n=new Set(e);for(let e of t)e.isConditionalWithinBlock||(n=new Set),n.add(e);return n},Aa=(e,t,n)=>{let r=F(t);if(F(e.bindingIdentifier)!==r||!r)return[];let i=n.cfgFor(r);if(!i)return[];let a=i.blockOf(t);if(!a)return[];let o=Ca(t),s=Ca(e.bindingIdentifier);if(o===null||s===null)return[];let c=new Map,l=(e,t,n)=>{let r=i.blockOf(t);if(!r)return;let a=c.get(r)??[];a.push({expression:e,position:n,isConditionalWithinBlock:Da(t,r,i)}),c.set(r,a)};e.initializer&&l(e.initializer,e.bindingIdentifier,s);for(let t of e.references){let e=Ca(t.identifier);if(t.flag===`read`||F(t.identifier)!==r||e===null||e>=o)continue;let n=Sa(t.identifier);n&&l(n,t.identifier,e)}for(let e of c.values())e.sort((e,t)=>e.position-t.position);let u=new Map,d=new Map,f=new Set([i.entry]),p=[i.entry];for(;p.length>0;){let e=p.pop();if(!e)break;for(let t of e.successors)f.has(t.to)||(f.add(t.to),p.push(t.to))}if(!f.has(a))return[];let m=!0;for(;m;){m=!1;for(let e of i.blocks){if(!f.has(e))continue;let t=new Set;for(let n of e.predecessors)if(f.has(n.from))for(let e of d.get(n.from)??[])t.add(e);let n=ka(t,c.get(e)??[]),r=u.get(e)??new Set,i=d.get(e)??new Set;(!Oa(t,r)||!Oa(n,i))&&(u.set(e,t),d.set(e,n),m=!0)}}let h=(c.get(a)??[]).filter(e=>e.position<o);return[...ka(u.get(a)??new Set,h)].map(e=>e.expression)},ja=(e,t,n)=>{if(!wa.has(e.kind))return e.initializer?[e.initializer]:[];if(!n)return[];let r=Ea.get(n);r||(r=new WeakMap,Ea.set(n,r));let i=r.get(e);i||(i=new WeakMap,r.set(e,i));let a=i.get(t);if(a)return a;let o=Aa(e,t,n);return i.set(t,o),o},Ma=e=>{if(!y(e)||!b(e.body,`BlockStatement`))return[];let t=[];return O(e.body,n=>{if(n!==e.body&&(y(n)||b(n,`ClassDeclaration`)||b(n,`ClassExpression`)))return!1;b(n,`ReturnStatement`)&&t.push(n)}),t},I=e=>{if(b(e,`ReturnStatement`)||b(e,`ThrowStatement`))return!0;if(b(e,`IfStatement`)){if(b(e.test,`Literal`)){let t=e.test.value?e.consequent:e.alternate;return t?I(t):!1}return!!(e.alternate&&I(e.consequent)&&I(e.alternate))}if(b(e,`TryStatement`))return e.finalizer&&I(e.finalizer)?!0:I(e.block)?e.handler?I(e.handler.body):!0:!1;if(b(e,`DoWhileStatement`))return I(e.body);if(b(e,`WhileStatement`)){let t=e.test;return!!(b(t,`Literal`)&&t.value&&I(e.body))}if(b(e,`ForStatement`)){let t=e.test;return!!((!t||b(t,`Literal`)&&t.value)&&I(e.body))}return b(e,`BlockStatement`)?e.body.some(e=>I(e)):!1},Na=new Set([`let`,`var`]),Pa=e=>!y(e)||!e.body?[]:b(e.body,`BlockStatement`)?Ma(e).flatMap(e=>e.argument?[e.argument]:[]):[e.body],Fa=e=>{if(!y(e)||!b(e.body,`BlockStatement`))return!1;let t=!1;return O(e.body,n=>{if(t||n!==e.body&&y(n))return!1;b(n,`ReturnStatement`)&&!n.argument&&(t=!0)}),t},Ia=(e,t,n,r=`some`)=>{let i=new Set,a=new Set,o,s=e=>{if(a.has(e))return!1;a.add(e);try{let t=Pa(e);return r===`every`&&y(e)&&b(e.body,`BlockStatement`)&&(!I(e.body)||Fa(e))?!1:t.length>0&&(r===`every`?t.every(o):t.some(o))}finally{a.delete(e)}};o=a=>{let l=E(a);if(i.has(l))return!1;i.add(l);try{if(t(l))return!0;if(b(l,`Identifier`)){let t=e.symbolFor(l);if(!t||t.kind!==`const`&&!Na.has(t.kind))return!1;let i=ja(t,l,n),a=e=>{let t=E(e);return!y(t)&&o(t)};return r===`every`?i.length>0&&i.every(a):i.some(a)}if(b(l,`CallExpression`)){if(l.arguments.length!==0||!b(l.callee,`Identifier`))return!1;let t=e.symbolFor(l.callee);if(!t||t.kind!==`const`&&t.kind!==`function`)return!1;let n=t.initializer?E(t.initializer):null,r=null;return y(n)?r=n:y(t.declarationNode)&&(r=t.declarationNode),!r||r.async||r.generator||r.params.length!==0?!1:s(r)}return b(l,`ConditionalExpression`)?c(l.consequent,l.alternate):b(l,`LogicalExpression`)?c(l.left,l.right):!1}finally{i.delete(l)}};let c=(e,t)=>{let n=[o(e),o(t)];return r===`every`?n.every(Boolean):n.some(Boolean)};return{expressionMatches:o,functionMatches:s}},La=(e,t,n,r,i=`some`)=>Ia(t,n,r,i).functionMatches(e),Ra=(e,t,n,r,i)=>{let a=i.cfgFor(e),o=a?.blockOf(t);if(!a||!o)return!1;let s=new Set(Ma(e).flatMap(e=>{if(!e.argument||!Ia(n,r,i,`every`).expressionMatches(e.argument))return[];let t=a.blockOf(e.argument);return t?[t]:[]}));if(s.size===0)return!1;let c=new Set([o]),l=[o];for(;l.length>0;){let e=l.pop();if(!e)break;if(!s.has(e))for(let t of e.successors){if(t.to===a.exit)return!1;c.has(t.to)||(c.add(t.to),l.push(t.to))}}return!0},za=e=>b(e,`Program`)?e.range[1]:e.range[0],Ba=new WeakMap,Va=(e,t)=>{t.push(...e.symbols);for(let n of e.children)Va(n,t)},Ha=e=>{let t=new Map,n=[];Va(e.rootScope,n);for(let r of n){let n=M(r.bindingIdentifier,e);if(!n)continue;let i=t.get(n.id)??[];i.push(r),t.set(n.id,i)}return t},Ua=(e,t)=>{let n=M(e,t);if(!n)return[];let r=Ba.get(t);return r||(r=Ha(t),Ba.set(t,r)),r.get(n.id)??[]},Wa=e=>{let t=e.expressions??[],n=e.quasis??[];if(t.length!==0||n.length!==1)return null;let r=n[0]?.value;return r?.cooked??r?.raw??null},L=(e,t,n={})=>{let r=j(e,{allowComputedString:!0,stringifyNonStringLiterals:n.stringifyNonStringLiterals});if(r!==null||!b(e,`Property`)&&!b(e,`MethodDefinition`)&&!b(e,`PropertyDefinition`)&&!b(e,`MemberExpression`)||!e.computed)return r;let i=E(b(e,`MemberExpression`)?e.property:e.key);if(!b(i,`Identifier`))return null;let a=M(i,t);if(a?.kind!==`const`||!a.initializer)return null;let o=E(a.initializer);return b(o,`Literal`)?typeof o.value==`string`?o.value:n.allowConstNumericLiteral&&typeof o.value==`number`?String(o.value):null:n.allowConstTemplateLiteral&&b(o,`TemplateLiteral`)?Wa(o):null},Ga=new Set([`CatchClause`,`ConditionalExpression`,`DoWhileStatement`,`ForInStatement`,`ForOfStatement`,`ForStatement`,`IfStatement`,`LogicalExpression`,`SwitchCase`,`SwitchStatement`,`TryStatement`,`WhileStatement`]),Ka=(e,t)=>{let n=e.parent??null;for(;n&&n!==t;){if(Ga.has(n.type))return!1;n=n.parent??null}return n===t},qa=e=>F(e)??da(e),Ja=e=>{let t=P(e),n=t.parent;return!!(n&&b(n,`VariableDeclarator`)&&n.init===t&&n.parent&&b(n.parent,`VariableDeclaration`)&&n.parent.kind===`const`)},Ya=e=>{let t=P(e),n=t.parent;return!!(n&&(b(n,`AssignmentExpression`)&&n.left===t||b(n,`UpdateExpression`)&&n.argument===t||b(n,`UnaryExpression`)&&n.operator===`delete`&&n.argument===t))},Xa=e=>{let t=P(e),n=t.parent;return n&&b(n,`MemberExpression`)&&E(n.object)===t?n:null},Za=(e,t,n,r,i)=>{if(i<=0||!b(e,`ObjectExpression`))return null;for(let a of e.properties.toReversed()){if(!b(a,`Property`))return null;let e=L(a,n);if(e===null)return null;if(e===t)return a.kind===`init`?R(a.value,n,r,i-1):null}return null},Qa=(e,t,n,r,i)=>{if(i<=0||!b(e,`ObjectExpression`))return[];let a=[],o=new Set;for(let s of e.properties){if(!b(s,`Property`))continue;let e=L(s,n),c=s.kind===`init`||s.kind===`get`?R(s.value,n,new Set(r),i-1):null;e===t?(a=c?[c]:[],o.clear(),c&&o.add(c)):e===null&&c&&!o.has(c)&&(a.push(c),o.add(c))}return a},$a=(e,t,n,r,i)=>{if(i<=0||!b(e,`ClassDeclaration`)&&!b(e,`ClassExpression`))return null;for(let a of e.body.body.toReversed()){if(!b(a,`MethodDefinition`)&&!b(a,`PropertyDefinition`)||!a.static)continue;let e=L(a,n);if(e===null)return null;if(e===t)return b(a,`MethodDefinition`)&&a.kind!==`method`?null:a.value?R(a.value,n,r,i-1):null}return null},eo=(e,t,n,r,i)=>{if(i<=0||!b(e,`ClassDeclaration`)&&!b(e,`ClassExpression`))return[];let a=[],o=new Set;for(let s of e.body.body){if(!b(s,`MethodDefinition`)&&!b(s,`PropertyDefinition`)||!s.static)continue;let e=L(s,n),c=s.value&&(!b(s,`MethodDefinition`)||s.kind===`method`||s.kind===`get`)?R(s.value,n,new Set(r),i-1):null;e===t?(a=c?[c]:[],o.clear(),c&&o.add(c)):e===null&&c&&!o.has(c)&&(a.push(c),o.add(c))}return a},to=(e,t,n,r,i,a,o,s)=>{let c=qa(t);if(s<=0||!c||!b(e,`Identifier`))return{exactFunction:null,possibleFunctions:[]};let l=[];for(let r of Ua(e,a))for(let e of r.references){let r=e.identifier;if(r.range[0]>=t.range[0]||Ja(r))continue;let i=Xa(r);if(!i){qa(r)===c&&l.push({assignedExpression:null,isDefinite:!1,offset:r.range[0]});continue}if(!Ya(i)||qa(i)!==c)continue;let o=L(i,a),s=P(i).parent,u=s&&b(s,`AssignmentExpression`)&&s.operator===`=`?s.right:null;if(o===null){l.push({assignedExpression:u,isDefinite:!1,offset:i.range[0]});continue}if(o===n){if(!s||!b(s,`AssignmentExpression`)||s.operator!==`=`||!Ka(i,c)){l.push({assignedExpression:u,isDefinite:!1,offset:i.range[0]});continue}l.push({assignedExpression:u,isDefinite:!0,offset:s.range[0]})}}l.sort((e,t)=>e.offset-t.offset);let u=r,d=i,f=new Set(i);for(let e of l){let t=e.assignedExpression?R(e.assignedExpression,a,new Set(o),s-1):null;if(e.isDefinite){u=t,d=t?[t]:[],f.clear(),t&&f.add(t);continue}u=null,t&&!f.has(t)&&(d.push(t),f.add(t))}return{exactFunction:u,possibleFunctions:d}},no=(e,t,n,r)=>{if(r<=0||!b(e,`MemberExpression`))return{exactFunction:null,possibleFunctions:[]};let i=A(e);if(i===null)return{exactFunction:null,possibleFunctions:[]};let a=E(e.object);if(b(a,`ObjectExpression`))return{exactFunction:Za(a,i,t,n,r),possibleFunctions:Qa(a,i,t,n,r)};if(b(a,`ClassExpression`))return{exactFunction:$a(a,i,t,n,r),possibleFunctions:eo(a,i,t,n,r)};if(!b(a,`Identifier`))return{exactFunction:null,possibleFunctions:[]};let o=M(a,t);if(!o||n.has(o.id))return{exactFunction:null,possibleFunctions:[]};n.add(o.id);let s=null,c=[];if(o.kind===`const`&&o.initializer){let e=E(o.initializer);s=Za(e,i,t,n,r),c=Qa(e,i,t,n,r)}else o.kind===`class`&&o.initializer&&(s=$a(o.initializer,i,t,n,r),c=eo(o.initializer,i,t,n,r));return to(a,e,i,s,c,t,n,r)},ro=(e,t,n,r)=>{if(r<=0)return[];let i=E(e);if(b(i,`CallExpression`)){let e=E(i.callee);return b(e,`MemberExpression`)&&A(e)===`bind`?ro(e.object,t,n,r-1):[]}if(b(i,`MemberExpression`)){let e=A(i);return e===`call`||e===`apply`?ro(i.object,t,n,r-1):no(i,t,n,r).possibleFunctions}let a=R(i,t,n,r);return a?[a]:[]},R=(e,t,n,r)=>{let i=E(e);if(y(i))return i;if(r<=0)return null;if(b(i,`CallExpression`)){let e=E(i.callee);return b(e,`MemberExpression`)&&A(e)===`bind`?R(e.object,t,n,r-1):null}if(b(i,`MemberExpression`)){let e=A(i);return e===`call`||e===`apply`?R(i.object,t,n,r-1):no(i,t,n,r).exactFunction}if(!b(i,`Identifier`))return null;let a=M(i,t);return!a||n.has(a.id)?null:(n.add(a.id),a.kind===`function`?!a.references.some(e=>e.flag!==`read`)&&y(a.declarationNode)?a.declarationNode:null:a.kind!==`const`||!a.initializer?null:R(a.initializer,t,n,r-1))},io=(e,t)=>R(e,t,new Set,15),ao=(e,t)=>ro(e,t,new Set,15),oo=new WeakMap,so=(e,t)=>{let n=E(e);return b(n,`Identifier`)?t.symbolFor(n):null},co=(e,t)=>{let n=P(e),r=n.parent;return!r||!b(r,`AssignmentExpression`)||r.operator!==`=`||r.left!==n?null:so(r.right,t)},lo=e=>{let t=P(e),n=t.parent;return n&&b(n,`VariableDeclarator`)&&n.init===t&&(b(n.id,`Identifier`)||b(n.id,`ObjectPattern`))?!0:!!(n&&b(n,`AssignmentExpression`)&&n.operator===`=`&&n.right===t&&b(E(n.left),`Identifier`))},uo=(e,t,n)=>{if(e.initializer&&b(e.declarationNode,`VariableDeclarator`)&&e.declarationNode.id===e.bindingIdentifier){let r=so(e.initializer,n);if(r&&t.has(r.id))return!0}return e.references.some(e=>{let r=co(e.identifier,n);return!!(r&&t.has(r.id))})},fo=(e,t)=>{let n=M(e,t);if(!n)return[];let r=oo.get(t);r||(r=new Map,oo.set(t,r));let i=r.get(n.id);if(i)return i;let a=[],o=[t.rootScope];for(;o.length>0;){let e=o.pop();e&&(a.push(...e.symbols),o.push(...e.children))}let s=new Set([n.id]),c=!0;for(;c;){c=!1;for(let e of a)s.has(e.id)||uo(e,s,t)&&(s.add(e.id),c=!0)}let l=a.filter(e=>s.has(e.id));return r.set(n.id,l),l},po=e=>{let t=e;for(;t;){if(y(t)||b(t,`Program`))return t;t=t.parent??null}return null},mo=new WeakMap,ho=(e,t)=>{let n=mo.get(t);if(!n){let r=new Map,i=new Map,a=da(e);a&&O(a,e=>{if(!b(e,`CallExpression`))return;let n=E(e.callee),a=b(n,`Identifier`)?t.symbolFor(n):null,o=a?i.get(a.id):void 0;o===void 0&&(o=ao(e.callee,t),a&&i.set(a.id,o));for(let t of o){let n=r.get(t)??[];n.push(e),r.set(t,n)}}),n=r,mo.set(t,n)}return n.get(e)??[]},go=new WeakMap,_o=(e,t)=>{let n=go.get(t);if(n===void 0){let e=null;O(t,n=>{b(n,`AwaitExpression`)&&F(n)===t&&(e===null||n.range[0]<e)&&(e=n.range[0])}),n=e,go.set(t,n)}return n===null||e.range[0]<n},vo=(e,t,n,r=new Set,i=null,a)=>{if(r.has(e)||!y(e)||e.generator||i!==null&&!Ka(i,e)||i!==null&&a!==void 0&&!a(i)||i!==null&&e.async&&!_o(i,e))return[];r.add(e);let o=po(t);return o?ho(e,n).flatMap(e=>{let s=po(e);return!s||i!==null&&!Ka(e,s)||i!==null&&a!==void 0&&!a(e)?[]:s===o?e.range[0]<za(t)?[[e.range[0]]]:[]:y(s)?vo(s,t,n,new Set(r),i===null?null:e,a).map(t=>[...t,e.range[0]]):[]}):[]},yo=(e,t,n,r=new Set,i=null)=>vo(e,t,n,r,i).length>0,bo=e=>{let t=e.parent;return t?b(t,`AssignmentExpression`)?t.left===e:(b(t,`UpdateExpression`)||b(t,`UnaryExpression`)&&t.operator===`delete`)&&t.argument===e:!1},xo=e=>{let t=e.parent;for(;t&&E(t)===e;)t=t.parent;return!t||!b(t,`MemberExpression`)||E(t.object)!==e||!bo(t)?null:t},So=(e,t,n)=>{let r=xo(e);return r&&L(r,n)===t?r:null},Co=(e,t,n,r)=>e.references.some(e=>{let i=So(e.identifier,t,r);if(!i)return!1;let a=po(i),o=po(n);return!a||!o||!Ka(i,a)?!1:a===o?i.range[0]<za(n):y(a)&&yo(a,n,r)}),wo=e=>{if(lo(e))return!0;let t=P(e),n=t.parent;return!!(n&&b(n,`MemberExpression`)&&E(n.object)===t)},To=e=>{if(lo(e))return!0;let t=P(e),n=t.parent;if(!n||!b(n,`MemberExpression`)||E(n.object)!==t)return!1;let r=P(n),i=r.parent;return!(i&&b(i,`CallExpression`)&&i.callee===r)},Eo=(e,t,n)=>b(e,`Identifier`)?fo(e,n).some(e=>e.references.some(e=>{let r=xo(e.identifier);if(!r)return!1;let i=L(r,n);return i===null||i===t})):!1,Do=(e,t,n)=>{let r=po(e),i=po(t);return!r||!i?!0:r===i?e.range[0]<za(t):y(r)?yo(r,t,n):!0},Oo=(e,t,n,r)=>b(e,`Identifier`)?fo(e,r).some(e=>e.references.some(e=>{let i=xo(e.identifier);if(!i||!Do(i,n,r))return!1;let a=L(i,r);return a===null||a===t})):!1,ko=(e,t,n)=>b(e,`Identifier`)?Eo(e,t,n)?!0:fo(e,n).some(e=>e.references.some(e=>!wo(e.identifier))):!1,Ao=(e,t,n,r)=>b(e,`Identifier`)?Oo(e,t,n,r)?!0:fo(e,r).some(e=>e.references.some(e=>!To(e.identifier)&&Do(e.identifier,n,r))):!1,jo=(e,t)=>{let n=E(e);if(!b(n,`CallExpression`))return!1;let r=E(n.callee);if(!b(r,`MemberExpression`))return!1;let i=A(r);if(i===null)return!1;let a=E(r.object);return b(a,`Identifier`)&&Eo(a,i,t)},Mo=(e,t,n,r)=>b(e,`Identifier`)?Ua(e,r).some(e=>Co(e,t,n,r)):!1,No=(e,t,n,r={})=>{let i=F(e);return i===F(t)?e.range[0]>=za(t)||r.requireSynchronousWrite&&(!i||!Ka(e,i)||r.isSynchronousNode!==void 0&&!r.isSynchronousNode(e))?[]:[[e.range[0]]]:i?r.requireSynchronousWrite?vo(i,t,n,new Set,e,r.isSynchronousNode).map(t=>[...t,e.range[0]]):vo(i,t,n).map(t=>[...t,e.range[0]]):r.requireSynchronousWrite?[]:[[-1/0,e.range[0]]]},Po=(e,t,n,r={})=>No(e,t,n,r).length>0,z=(e,t,n,r={})=>e.references.some(e=>e.flag===`read`?!1:Po(e.identifier,t,n,r)),Fo=(e,t)=>{if(!b(e,`CallExpression`))return!1;let n=E(e.callee);if(b(n,`Identifier`)){let e=t.symbolFor(n);return!!(e&&!z(e,n,t))}if(!b(n,`MemberExpression`))return!1;let r=A(n),i=E(n.object);return!!(r&&b(i,`Identifier`)&&!Mo(i,r,n,t))},Io=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`ClassDeclaration`,`ClassExpression`]),Lo={allowGlobalReactNamespace:!1,allowUnboundBareCalls:!1},Ro=new Set([`lodash/sortBy`,`lodash/sortBy.js`,`lodash-es/sortBy`,`lodash-es/sortBy.js`]),zo=e=>b(e,`TSArrayType`)||b(e,`TSTupleType`)?!0:b(e,`TSTypeReference`)?b(e.typeName,`Identifier`)&&(e.typeName.name===`Array`||e.typeName.name===`ReadonlyArray`):!1,Bo=e=>{if(!b(e,`Identifier`))return!1;let t=e.typeAnnotation;return!!(t&&b(t,`TSTypeAnnotation`)&&zo(t.typeAnnotation))},Vo=(e,t)=>{if(!b(e,`CallExpression`))return!1;let n=E(e.callee);if(!b(n,`Identifier`))return!1;let r=t.symbolFor(n);if(!r||z(r,n,t)||!b(r.declarationNode,`ImportDefaultSpecifier`)&&!b(r.declarationNode,`ImportSpecifier`))return!1;let i=xa(n,n.name);return!i||i.isNamespace?!1:Ro.has(i.source)&&i.exportedName===`default`?!0:(i.source===`lodash`||i.source===`lodash-es`)&&i.exportedName===`sortBy`},Ho=(e,t,n,r=new Set)=>{let i=E(e);if(b(i,`ArrayExpression`)||Vo(i,t))return!0;if(!b(i,`Identifier`))return!1;let a=t.symbolFor(i);return!a||r.has(a.id)||z(a,n,t)?!1:Bo(a.bindingIdentifier)?!0:a.initializer?(r.add(a.id),Ho(a.initializer,t,n,r)):!1},Uo=(e,t)=>{if(!b(e,`CallExpression`))return!1;let n=E(e.callee);if(!b(n,`MemberExpression`)||A(n)!==`map`)return!1;let r=E(n.object);return Ho(r,t,e)?!(b(r,`Identifier`)&&Mo(r,`map`,e,t)):!1},Wo=(e,t)=>{if(e.type!==`ArrowFunctionExpression`&&e.type!==`FunctionExpression`)return!1;let n=e.parent;return b(n,`CallExpression`)?ia(n,`useMemo`,t,{resolveNamedAliases:!0})&&Fo(n,t)?n.arguments[0]===e:n.arguments.some(t=>t===e)&&Uo(n,t):!1},Go=(e,t)=>Io.has(e.type)&&!Wo(e,t),Ko=(e,t)=>e.type===`JSXElement`||e.type===`JSXFragment`||ia(e,`createElement`,t,Lo)||qo(e,t),qo=(e,t)=>{if(!b(e,`CallExpression`))return!1;let n=E(e.callee);if(b(n,`Identifier`))return t.symbolFor(n)?.kind===`import`&&ya(n,n.name,`react-dom`)===`createPortal`;if(!b(n,`MemberExpression`)||n.computed||!b(n.object,`Identifier`)||!b(n.property,`Identifier`)||n.property.name!==`createPortal`)return!1;let r=t.symbolFor(n.object);return!r||r.kind!==`import`?!1:va(n.object,n.object.name,`react-dom`)||_a(n.object,n.object.name,`react-dom`)},Jo=(e,t)=>{let n=!1;return O(e,r=>{if(n||r!==e&&Go(r,t))return!1;if(Ko(r,t))return n=!0,!1}),n},Yo=new WeakMap,Xo=(e,t,n)=>{let r=Yo.get(e);if(r&&r.scopes===t&&r.controlFlow===n)return r.hasRenderOutput;let i=La(e,t,e=>Jo(e,t),n);return Yo.set(e,{scopes:t,controlFlow:n,hasRenderOutput:i}),i},Zo=e=>b(e,`JSXIdentifier`)?e.name:b(e,`JSXNamespacedName`)?`${e.namespace.name}:${e.name.name}`:null,Qo=new Set([`Component`,`PureComponent`]),$o=(e,t,n,r)=>{let i=E(e);if(b(i,`MemberExpression`)){let e=A(i),n=E(i.object);return!!(e&&Qo.has(e)&&b(n,`Identifier`)&&!Mo(n,e,i,t)&&ta(n,t))}if(b(i,`ClassExpression`))return es(i,t,n,r);if(!b(i,`Identifier`))return!1;let a=t.symbolFor(i);if(!a||r.has(a.id)||z(a,i,t))return!1;if(r.add(a.id),$i(a)){let e=k(a.declarationNode);return!!(e&&Qo.has(e))}return b(a.declarationNode,`ClassDeclaration`)||b(a.declarationNode,`ClassExpression`)?es(a.declarationNode,t,n,r):!!(a.kind===`const`&&a.initializer&&$o(a.initializer,t,n,r))},es=(e,t,n=new Set,r=new Set)=>!b(e,`ClassDeclaration`)&&!b(e,`ClassExpression`)||n.has(e)||!e.superClass?!1:(n.add(e),$o(e.superClass,t,n,r)),ts=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`MethodDefinition`,`Program`]),ns=e=>{let t=e;for(;t;){if(ts.has(t.type))return t;t=t.parent??null}return null},rs=(e,t)=>{if(t!==`let`&&t!==`const`)return ns(e);let n=e.parent;for(;n;){if(n.type===`BlockStatement`){let t=n.parent;return t&&(t.type===`FunctionDeclaration`||t.type===`FunctionExpression`||t.type===`ArrowFunctionExpression`||t.type===`MethodDefinition`)?ns(e):n}if(ts.has(n.type))return n;n=n.parent??null}return null},is=(e,t,n,r)=>{if(b(e,`Identifier`)){let i=r.get(e.name)??[];i.push({bindingIdentifier:e,initializer:t,scopeOwner:n}),r.set(e.name,i);return}if(b(e,`ObjectPattern`)){for(let t of e.properties)if(b(t,`Property`)){let e=t.value;is(e,b(e,`AssignmentPattern`)?e.right:null,n,r)}else b(t,`RestElement`)&&is(t.argument,null,n,r);return}if(b(e,`ArrayPattern`)){for(let t of e.elements)t&&is(t,b(t,`AssignmentPattern`)?t.right??null:null,n,r);return}if(b(e,`AssignmentPattern`)){is(e.left,e.right??null,n,r);return}b(e,`RestElement`)&&is(e.argument,null,n,r)},as=e=>{let t=new Map;return O(e,e=>{switch(e.type){case`VariableDeclarator`:{let n=e.parent,r=rs(e,n?.type===`VariableDeclaration`?n.kind:void 0);r&&is(e.id,e.init??null,r,t);break}case`FunctionDeclaration`:case`FunctionExpression`:case`ArrowFunctionExpression`:if(e.type!==`ArrowFunctionExpression`&&e.id){let n=e.parent?ns(e.parent):null;if(n){let r=t.get(e.id.name)??[];r.push({bindingIdentifier:e.id,initializer:e,scopeOwner:n}),t.set(e.id.name,r)}}for(let n of e.params)is(n,null,e,t);break;case`ClassDeclaration`:case`ClassExpression`:{if(!e.id)break;let n=e.parent?ns(e.parent):null;if(n){let r=t.get(e.id.name)??[];r.push({bindingIdentifier:e.id,initializer:e,scopeOwner:n}),t.set(e.id.name,r)}break}case`ImportDeclaration`:{let n=ns(e);if(!n)break;for(let r of e.specifiers){let e=r.local;if(e&&b(e,`Identifier`)){let i=t.get(e.name)??[];i.push({bindingIdentifier:e,initializer:r,scopeOwner:n}),t.set(e.name,i)}}break}case`TSImportEqualsDeclaration`:case`TSEnumDeclaration`:case`TSModuleDeclaration`:{let n=e.id;if(n?.type===`Identifier`){let r=ns(e);if(r){let e=t.get(n.name)??[];e.push({bindingIdentifier:n,initializer:null,scopeOwner:r}),t.set(n.name,e)}}break}}}),t},os=new WeakMap,ss=new WeakMap,cs=e=>{let t=da(e);if(!t)return null;let n=os.get(t);return n||(n=as(t),os.set(t,n)),n},ls=(e,t,n)=>{let r=cs(e);if(!r)return null;let i=r.get(t);if(!i||i.length===0)return null;let a=i[0];if(i.length===1&&a){let t=e;for(;t;){if(t===a.scopeOwner)return a;t=t.parent??null}return null}let o=e;for(;o;){let t=null;for(let r of i)if(r.scopeOwner===o){if(t===null){t=r;continue}if(n?.preferInitializerBeforeReference){let n=!!(r.initializer&&(b(r.initializer,`FunctionDeclaration`)||r.bindingIdentifier.range[0]<e.range[0]));if(n!==!!(t.initializer&&(b(t.initializer,`FunctionDeclaration`)||t.bindingIdentifier.range[0]<e.range[0]))){n&&(t=r);continue}}(r.initializer!==null||t.initializer===null)&&(t=r)}if(t)return t;o=o.parent??null}return null},us=(e,t,n)=>{let r=ss.get(e),i;if(!r)i={},ss.set(e,{primaryBindingName:t,primaryLookup:i});else if(r.primaryBindingName===t)i=r.primaryLookup;else{let e=r.additionalLookups;e||(e=new Map,r.additionalLookups=e);let n=e.get(t);n?i=n:(i={},e.set(t,i))}let a=n?.preferInitializerBeforeReference?`preferredResult`:`defaultResult`;if(a in i)return i[a]??null;let o=ls(e,t,n);return i[a]=o,o},ds=e=>Di.test(e),fs=e=>{let t=us(e,e.name);if(!t?.initializer)return null;let n=t.bindingIdentifier.parent;if(!n||!b(n,`VariableDeclarator`)||n.id!==t.bindingIdentifier)return null;let r=n.parent;if(!r||!b(r,`VariableDeclaration`)||r.kind!==`const`)return null;let i=E(t.initializer);return b(i,`Literal`)&&typeof i.value==`string`?i.value:null},ps=e=>b(e,`JSXIdentifier`)?e.name:b(e,`JSXMemberExpression`)?`${ps(e.object)}.${e.property.name}`:b(e,`JSXNamespacedName`)?`${e.namespace.name}:${e.name.name}`:``,ms=e=>{let t=e.name;return b(t,`JSXIdentifier`)?ds(t.name)?fs(t)??t.name:t.name:ps(t)},hs=(e,t)=>{if(!b(e.name,`JSXIdentifier`))return!1;let n=ms(e);if(n[0]===n[0]?.toLowerCase())return!0;let r=new Set,i=e=>{let n=P(e);if(b(n,`Literal`))return typeof n.value==`string`;if(b(n,`Identifier`)||b(n,`JSXIdentifier`)){let e=t.symbolFor(n);if(!e||e.kind!==`const`||!e.initializer||r.has(e.id))return!1;r.add(e.id);let a=i(e.initializer);return r.delete(e.id),a}return b(n,`ConditionalExpression`)?i(n.consequent)&&i(n.alternate):!1};return i(e.name)},gs=(e,t,n=new Set)=>{if(!e)return null;let r=E(e);if(y(r))return r;if(b(r,`Identifier`)){let e=t.symbolFor(r);return!e||n.has(e.id)||!e.initializer||z(e,r,t)?null:(n.add(e.id),gs(e.initializer,t,n))}if(!b(r,`CallExpression`)||!ia(r,`memo`,t,{resolveNamedAliases:!0})&&!ia(r,`forwardRef`,t,{resolveNamedAliases:!0}))return null;let i=r.arguments[0];return!i||b(i,`SpreadElement`)?null:gs(i,t,n)},_s=(e,t)=>{let n=P(e);if(!y(n)||n.async||n.generator)return!1;let r=n.parent;if(!r||!b(r,`JSXExpressionContainer`))return!1;let i=r.parent;if(!i||!b(i,`JSXAttribute`)||Zo(i.name)!==`ref`)return!1;let a=i.parent;return!!(a&&b(a,`JSXOpeningElement`)&&hs(a,t))},vs=(e,t)=>t.every((t,n)=>e[n]===t),ys=e=>{let t=P(e);for(;t.parent&&b(t.parent,`MemberExpression`)&&t.parent.object===t;){if(!A(t.parent))return null;t=P(t.parent)}return t},bs=(e,t,n,r)=>{if(t.length!==n.length+1||!vs(t,n)||t[n.length]!==`current`)return!1;let i=ys(e),a=i?.parent;if(!i||!a||!b(a,`AssignmentExpression`)||a.operator!==`=`||a.left!==i)return!1;let o=F(e);if(!o)return!1;if(_s(o,r))return!0;if(!y(o)||o.async||o.generator)return!1;let s=F(o);if(!s||!_s(s,r))return!1;let c=P(o),l=c.parent;return!!(b(l,`ReturnStatement`)&&l.argument===c&&F(l)===s||b(s,`ArrowFunctionExpression`)&&s.body===c)},xs=(e,t)=>{if(!b(e,`JSXOpeningElement`))return!1;let n=e.name;if(b(n,`JSXIdentifier`)){if(!t)return n.name===`Fragment`;let e=M(n,t);return e?$i(e)&&k(e.declarationNode)===`Fragment`:n.name===`Fragment`&&t.isGlobalReference(n)}return b(n,`JSXMemberExpression`)?!b(n.object,`JSXIdentifier`)||n.property.name!==`Fragment`?!1:t?ta(n.object,t)?!0:n.object.name===`React`&&t.isGlobalReference(n.object):n.object.name===`React`:!1},Ss=(e,t,n,r,i)=>{let a=P(e),o=a.parent;if(!o)return!1;if(b(o,`ReturnStatement`)&&o.argument===a)return F(o)===t;if(b(o,`ArrowFunctionExpression`)&&o.body===a)return o===t;if(b(o,`JSXFragment`)&&o.children.some(e=>e===a)||b(o,`JSXElement`)&&o.children.some(e=>e===a)&&(hs(o.openingElement,n)||xs(o.openingElement,n)||i.doesCustomElementRenderChildren?.(o.openingElement)))return Ss(o,t,n,r,i);if(b(o,`JSXExpressionContainer`)&&o.expression===a&&o.parent&&(b(o.parent,`JSXFragment`)||b(o.parent,`JSXElement`)&&(hs(o.parent.openingElement,n)||xs(o.parent.openingElement,n)||i.doesCustomElementRenderChildren?.(o.parent.openingElement))))return Ss(o.parent,t,n,r,i);if(b(o,`ConditionalExpression`)&&(o.consequent===a||o.alternate===a)||b(o,`LogicalExpression`)&&(o.left===a||o.right===a)||b(o,`ArrayExpression`)&&o.elements.some(e=>e===a))return Ss(o,t,n,r,i);if(!b(o,`VariableDeclarator`)||o.init!==a||!b(o.id,`Identifier`))return!1;let s=n.symbolFor(o.id);if(!s||s.kind!==`const`||s.references.length===0||r.has(s.id))return!1;r.add(s.id);let c=s.references.every(e=>e.flag===`read`&&Ss(e.identifier,t,n,r,i));return r.delete(s.id),c},Cs=(e,t,n={})=>Ss(e,F(e),t,new Set,n),ws=(e,t)=>t.every((t,n)=>e[n]===t),Ts=(e,t)=>ws(e,t)||ws(t,e),Es=e=>y(e)&&b(e.body,`BlockStatement`)&&e.body.body.length===0,Ds=(e,t,n)=>ia(e,t,n,{resolveNamedAliases:!0}),Os=(e,t,n=new Set)=>b(e,`ObjectExpression`)?e.properties.every(e=>{if(b(e,`SpreadElement`)){let r=P(e.argument);if(b(r,`ObjectExpression`))return Os(r,t,n);if(!b(r,`Identifier`))return!1;let i=t.symbolFor(r);if(!i||i.kind!==`const`||n.has(i.id)||!b(i.initializer,`ObjectExpression`))return!1;n.add(i.id);let a=Os(i.initializer,t,n);return n.delete(i.id),a}return b(e,`Property`)?!y(e.value)||Es(e.value):!1}):!1,ks=e=>A(e)||(e.computed&&b(e.property,`Literal`)&&typeof e.property.value==`number`&&Number.isSafeInteger(e.property.value)&&e.property.value>=0?String(e.property.value):null),As=e=>{let t=[],n=P(e);for(;n.parent&&b(n.parent,`MemberExpression`)&&n.parent.object===n;){let e=ks(n.parent);if(!e)return null;t.push(e),n=P(n.parent)}return{expression:n,propertyPath:t}},js=(e,t,n)=>{let r=n.environmentsByProgram.get(e);if(r)return r;let i={filename:t,program:e,scopes:Ge(e)};return n.environmentsByProgram.set(e,i),i},Ms=(e,t,n=new Set)=>{let r=P(e);if(b(r,`Identifier`)){let e=t.symbolFor(r);return!e||!e.initializer||n.has(e.id)||z(e,r,t)?!1:(n.add(e.id),Ms(e.initializer,t,n))}if(!b(r,`CallExpression`))return!1;if(Ds(r,`forwardRef`,t))return!0;if(!Ds(r,`memo`,t))return!1;let i=r.arguments[0];return!i||b(i,`SpreadElement`)?!1:Ms(i,t,n)},Ns=(e,t)=>{let n=js(e.programNode,e.filePath,t),r=gs(e.exportedNode,n.scopes);return r?{environment:n,functionNode:r,isForwardRef:Ms(e.exportedNode,n.scopes)}:null},Ps=(e,t,n)=>{if(!b(e,`Identifier`)&&!b(e,`JSXIdentifier`))return null;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`){if(z(r,e,t.scopes))return null;let n=gs(r.initializer,t.scopes);return n?{environment:t,functionNode:n,isForwardRef:!!(r.initializer&&Ms(r.initializer,t.scopes))}:null}let i=xa(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return null;let a=D(t.filename,i.source,i.exportedName);return a?Ns(a,n):null},Fs=(e,t,n)=>{if(b(e,`JSXIdentifier`))return Ps(e,t,n);if(!b(e,`JSXMemberExpression`)||!b(e.object,`JSXIdentifier`))return null;let r=xa(e.object,e.object.name);if(!r?.isNamespace)return null;let i=D(t.filename,r.source,e.property.name);return i?Ns(i,n):null},Is=(e,t,n=new Set)=>{let r=P(e);if(b(r,`Identifier`)){let e=t.scopes.symbolFor(r);return!e||!e.initializer||n.has(e.id)||z(e,r,t.scopes)?!1:(n.add(e.id),Is(e.initializer,t,n))}return es(r,t.scopes)},Ls=(e,t,n)=>{if(!b(e,`JSXIdentifier`))return!1;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`)return z(r,e,t.scopes)?!1:!!(r.initializer&&Is(r.initializer,t));let i=xa(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return!1;let a=D(t.filename,i.source,i.exportedName);if(!a)return!1;let o=js(a.programNode,a.filePath,n);return Is(a.exportedNode,o)},Rs=(e,t)=>{if(!e)return null;let n=P(e);return!b(n,`ClassDeclaration`)&&!b(n,`ClassExpression`)||!Is(n,t)?null:{classNode:n,environment:t}},zs=(e,t,n)=>{if(!b(e,`JSXIdentifier`))return null;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`)return z(r,e,t.scopes)?null:Rs(r.initializer,t);let i=xa(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return null;let a=D(t.filename,i.source,i.exportedName);if(!a)return null;let o=js(a.programNode,a.filePath,n);return Rs(a.exportedNode,o)},Bs=(e,t,n)=>{let r=[...t],i=P(e);for(;i.parent;){let e=i.parent;if(b(e,`ArrayExpression`)){if(e.elements.some(e=>e&&b(e,`SpreadElement`)))return null;let t=e.elements.findIndex(e=>e===i);if(t<0)return null;r.unshift(String(t)),i=P(e);continue}if(b(e,`Property`)&&e.value===i){let t=j(e,{allowComputedString:!0}),a=e.parent;if(!t||!a||!Os(a,n.scopes))return null;r.unshift(t),i=P(a);continue}if(b(e,`ConditionalExpression`)&&(e.consequent===i||e.alternate===i)||b(e,`LogicalExpression`)&&(e.left===i||e.right===i)){i=P(e);continue}if(b(e,`VariableDeclarator`)&&e.init===i&&b(e.id,`Identifier`)){let t=n.scopes.symbolFor(e.id);return!t||t.kind!==`const`?null:{environment:n,propertyPath:r,symbol:t}}if(b(e,`AssignmentExpression`)&&e.operator===`=`&&e.right===i&&b(e.left,`MemberExpression`)){let t=[],i=e.left;for(;b(i,`MemberExpression`);){let e=ks(i);if(!e)return null;t.unshift(e),i=P(i.object)}if(!b(i,`Identifier`))return null;let a=n.scopes.symbolFor(i);return!a||a.kind!==`const`?null:{environment:n,originWriteReference:i,propertyPath:[...t,...r],symbol:a}}return null}return null},Vs=(e,t,n,r,i)=>{if(b(e,`AssignmentPattern`))return Vs(e.left,t,n,r,i);if(b(e,`Identifier`)){let a=n.scopes.symbolFor(e);return!!(a&&nc({environment:n,propertyPath:t,symbol:a},r,i-1))}if(!b(e,`ObjectPattern`)||t.length===0)return!1;let[a,...o]=t;for(let t of e.properties){if(!b(t,`Property`))continue;let e=j(t,{allowComputedString:!0});if(!e)return!1;if(e===a)return Vs(t.value,o,n,r,i)}let s=e.properties.find(e=>b(e,`RestElement`));return s?Vs(s.argument,t,n,r,i):!0},Hs=(e,t)=>{let n=e.arguments[0];return!n||b(n,`SpreadElement`)?!1:Ds(e,`createElement`,t.scopes)?b(n,`Literal`)&&typeof n.value==`string`:!Ds(e,`cloneElement`,t.scopes)||!b(n,`JSXElement`)?!1:hs(n.openingElement,t.scopes)},Us=(e,t,n,r,i)=>{if(t.length>0)return!1;let a=e.parent;if(!a||!b(a,`Property`)||a.value!==e||j(a,{allowComputedString:!0})!==`ref`)return!1;let o=a.parent;if(!o||!b(o,`ObjectExpression`))return!1;let s=o.parent;return!(!s||!b(s,`CallExpression`)||s.arguments[1]!==o||!Hs(s,n)||!B(s,n,r,i))},Ws=(e,t,n,r,i)=>{if(i<=0||!y(e.functionNode)||e.functionNode.async||e.functionNode.generator)return!1;let a=e.functionNode.params[t];return!!(a&&Vs(a,n,e.environment,r,i))},Gs=e=>{if(!b(e,`MemberExpression`)||A(e)!==`children`)return!1;let t=P(e.object);return!!(b(t,`MemberExpression`)&&A(t)===`props`&&b(P(t.object),`ThisExpression`))},Ks=(e,t)=>{if(!b(e,`JSXOpeningElement`)||!b(e.name,`JSXMemberExpression`)||e.name.property.name!==`Provider`||!b(e.name.object,`JSXIdentifier`))return!1;let n=t.scopes.symbolFor(e.name.object);return!!(n?.kind===`const`&&n.initializer&&b(n.initializer,`CallExpression`)&&Ds(n.initializer,`createContext`,t.scopes))},B=(e,t,n,r)=>Cs(e,t.scopes,{doesCustomElementRenderChildren:e=>Ys(e,t,n,r-1)}),qs=(e,t,n)=>{let{functionNode:r}=e;if(n<=0||t.activeRenderedChildrenComponents.has(r)||!b(r,`ArrowFunctionExpression`)&&!b(r,`FunctionExpression`)&&!b(r,`FunctionDeclaration`)||r.async||r.generator)return!1;let i=ua(r,e.environment.scopes);if(!i)return!1;t.activeRenderedChildrenComponents.add(r);let a=i.every(r=>B(r,e.environment,t,n));return t.activeRenderedChildrenComponents.delete(r),a},Js=(e,t,n)=>{let{classNode:r,environment:i}=e;if(n<=0||t.activeRenderedChildrenComponents.has(r)||!b(r,`ClassDeclaration`)&&!b(r,`ClassExpression`))return!1;let a=r.body.body.find(e=>b(e,`MethodDefinition`)&&!e.computed&&b(e.key,`Identifier`)&&e.key.name===`render`);if(!a||!b(a,`MethodDefinition`))return!1;let o=[];if(O(r,e=>{Gs(e)&&o.push(e)}),o.length===0)return!1;t.activeRenderedChildrenComponents.add(r);let s=o.every(e=>F(e)===a.value&&B(e,i,t,n));return t.activeRenderedChildrenComponents.delete(r),s},Ys=(e,t,n,r)=>{if(r<=0||!b(e,`JSXOpeningElement`))return!1;if(Ks(e,t))return!0;let i=Fs(e.name,t,n);if(i)return qs(i,n,r);let a=zs(e.name,t,n);return!!(a&&Js(a,n,r))},Xs=(e,t,n,r,i)=>{let a=Zo(e.name),o=e.parent;if(!a||!o||!b(o,`JSXOpeningElement`))return!1;let s=o.parent;if(!s||!b(s,`JSXElement`)||!B(s,n,r,i))return!1;if(hs(o,n.scopes))return a===`ref`&&t.length===0;if(b(o.name,`JSXIdentifier`)&&a===`ref`&&t.length===0&&Ls(o.name,n,r))return!0;let c=Fs(o.name,n,r);return c?a===`ref`&&c.isForwardRef?Ws(c,1,t,r,i):Ws(c,0,[a,...t],r,i):!1},Zs=(e,t,n,r,i,a)=>{let o=e.arguments.findIndex(e=>e===t);if(o<0)return!1;if(o===0&&b(e.callee,`Identifier`)&&e.callee.name===`Boolean`&&r.scopes.isGlobalReference(e.callee))return!0;if(o===0&&Ds(e,`useImperativeHandle`,r.scopes))return n.length===0;if(o===1&&n.length===1&&n[0]===`ref`&&Hs(e,r)&&B(e,r,i,a))return!0;let s=P(e.callee);if(y(s))return Xo(s,r.scopes)&&!B(e,r,i,a)?!1:Ws({environment:r,functionNode:s,isForwardRef:!1},o,n,i,a);if(!b(e.callee,`Identifier`))return!1;let c=Ps(e.callee,r,i);return!!(c&&(!Xo(c.functionNode,c.environment.scopes)||B(e,r,i,a))&&Ws(c,o,n,i,a))},Qs=(e,t,n,r,i)=>{let a;if(t.length===1&&t[0]===`ref`)a=e.parent;else if(t.length===0){let t=e.parent;if(!t||!b(t,`Property`)||t.value!==e||j(t,{allowComputedString:!0})!==`ref`)return!1;a=t.parent?.parent}if(!a||!b(a,`JSXSpreadAttribute`))return!1;let o=a.parent;if(!o||!b(o,`JSXOpeningElement`))return!1;let s=o.parent;return!!(hs(o,n.scopes)&&s&&b(s,`JSXElement`)&&B(s,n,r,i))},$s=(e,t,n,r,i)=>{let a=P(e),o=a.parent;if(!o)return!1;if(b(o,`ExpressionStatement`)||b(o,`UnaryExpression`)&&o.operator===`void`&&o.argument===a)return!0;if(t.length===0&&b(o,`BinaryExpression`)&&(o.operator===`===`||o.operator===`!==`||o.operator===`==`||o.operator===`!=`)){let e=o.left===a?o.right:o.left;return!!(b(a,`Identifier`)&&b(e,`Identifier`)&&n.scopes.symbolFor(a)?.id===n.scopes.symbolFor(e)?.id)}if(Qs(a,t,n,r,i)||Us(a,t,n,r,i)||t.length>0&&(b(o,`LogicalExpression`)&&o.left===a||b(o,`ConditionalExpression`)&&o.test===a||b(o,`IfStatement`)&&o.test===a||b(o,`UnaryExpression`)&&o.operator===`!`&&o.argument===a))return!0;if(b(o,`JSXExpressionContainer`)&&o.expression===a){let e=o.parent;return!!(e&&b(e,`JSXAttribute`)&&Xs(e,t,n,r,i))}if(b(o,`CallExpression`))return Zs(o,a,t,n,r,i);if(b(o,`VariableDeclarator`)&&o.init===a&&!b(o.id,`Identifier`))return Vs(o.id,t,n,r,i);let s=Bs(a,t,n);return!!(s&&nc(s,r,i-1))},ec=e=>{let t=e.parent;return t&&b(t,`VariableDeclarator`)&&t.init===e&&b(t.id,`Identifier`)?t.id:(b(e,`FunctionDeclaration`)||b(e,`FunctionExpression`))&&e.id?e.id:null},tc=(e,t,n)=>{if(!e||!t||!y(e)||e.async||e.generator)return!1;let r=ec(e);if(!r||((b(e,`FunctionDeclaration`)||b(e,`FunctionExpression`))&&e.id===r?F(e):F(r))!==t)return!1;let i=b(e,`FunctionDeclaration`)?n.ownScopeFor(t)?.symbolsByName.get(r.name):n.symbolFor(r);return!!(i&&i.references.length>0&&i.references.every(e=>{let r=P(e.identifier),i=r.parent;return!!(i&&b(i,`CallExpression`)&&i.callee===r&&F(i)===t&&Cs(i,n))}))},nc=(e,t,n)=>{if(n<=0)return!1;let r=`${e.environment.filename}:${e.symbol.id}:${e.propertyPath.join(`.`)}`;if(t.activePaths.has(r))return!1;t.activePaths.add(r);let i=F(e.symbol.bindingIdentifier),a=e.symbol.references.every(r=>{if(r.identifier===e.originWriteReference)return!0;let a=r.identifier.parent;if(a&&b(a,`Property`)&&!a.computed&&a.key===r.identifier&&a.value!==r.identifier)return!0;let o=As(r.identifier);if(!o)return!1;if(!Ts(o.propertyPath,e.propertyPath))return!0;let s=F(r.identifier);if(s!==i&&!tc(s,i,e.environment.scopes))return!!bs(r.identifier,o.propertyPath,e.propertyPath,e.environment.scopes);if(r.flag!==`read`)return!1;if(ws(o.propertyPath,e.propertyPath)){if(o.propertyPath.length>e.propertyPath.length){let t=o.expression.parent;return!!(o.propertyPath.length===e.propertyPath.length+1&&o.propertyPath[e.propertyPath.length]===`current`&&t&&b(t,`UnaryExpression`)&&t.operator===`void`&&t.argument===o.expression)}return $s(o.expression,[],e.environment,t,n)}return $s(o.expression,e.propertyPath.slice(o.propertyPath.length),e.environment,t,n)});return t.activePaths.delete(r),a},rc=(e,t,n)=>{if(!t)return!1;let r=da(e);if(!r)return!1;let i={filename:t,program:r,scopes:n},a={activePaths:new Set,activeRenderedChildrenComponents:new WeakSet,environmentsByProgram:new WeakMap([[r,i]])},o=Bs(e,[],i);return o?nc(o,a,12):$s(e,[],i,a,12)},ic=e=>{let t=[];for(let n of e)for(let e of n.entries){if(e.importName.kind===`NamespaceObject`)continue;let r=e.importName.kind===`Default`?`default`:e.importName.name??null;r!==null&&t.push({source:n.moduleRequest.value,exportedName:r})}return t},ac=({absoluteFilePath:e,staticImports:t})=>{let n=!1;for(let r of t){let t=r.moduleRequest.value;if(!t.startsWith(`.`))continue;let i=r.entries.filter(e=>!e.isType);if(i.length===0)continue;let a=Dn(e,t);if(!(!a||!Ar(a))){n||(n=!0,Vt(e));for(let e of i){let t=e.importName.kind===`Default`?`default`:e.importName.name;t&&ca(a,t)}}}},oc=({absoluteFilePath:e})=>{Je.test(e)&&(Qe.test(e)||dr(e))},sc=({absoluteFilePath:e,staticImports:t})=>{if(Ye.test(e)&&!mr(e))for(let n of ic(t))Jn(e,n.source,n.exportedName)},V=({absoluteFilePath:e,staticImports:t})=>{for(let n of ic(t))Jn(e,n.source,n.exportedName)},cc=({absoluteFilePath:e,staticImports:t})=>{for(let n of ic(t))D(e,n.source,n.exportedName)},lc=(e,t,n,r)=>{let i=n.get(t);if(!(i!==void 0&&i<=r)){n.set(t,r);for(let i of e.body??[]){let e=hr(i);if(!e)continue;let a=Wn(t,e);if(!a||r>=8)continue;let o=r+1,s=n.get(a);if(s!==void 0&&s<=o)continue;let c=on(a);if(!c){n.set(a,o);continue}lc(c,a,n,o)}}},uc=e=>{cc(e);let t=e.getProgram(),n=!1;O(t,e=>{if(n)return!1;if(!b(e,`CallExpression`))return;let t=E(e.callee);if(!b(t,`MemberExpression`))return;let r=A(t);n=r===`add`||r===`set`}),n&&lc(t,e.absoluteFilePath,new Map,0)},dc=({absoluteFilePath:e,staticImports:t})=>{for(let n of ic(t))la(e,n.source,n.exportedName)},fc=e=>{let t=[];for(let n of e.body??[]){if(n.type!==`ImportDeclaration`)continue;let e=n.source?.value;if(typeof e==`string`){for(let r of n.specifiers??[])if(r.type===`ImportDefaultSpecifier`)t.push({source:e,exportedName:`default`});else if(r.type===`ImportSpecifier`){let n=r.imported,i=null;typeof n?.name==`string`?i=n.name:typeof n?.value==`string`&&(i=n.value),i&&t.push({source:e,exportedName:i})}}}return t},pc=({absoluteFilePath:e,staticImports:t},n,r=()=>!0,i=()=>!0)=>{let a=new Map,o=(e,t,n)=>{if(!((a.get(e)??-1)>=n)){a.set(e,n);for(let a of fc(t)){let t=D(e,a.source,a.exportedName);!t||n===0||!r(t)||!i(t.filePath)||o(t.filePath,t.programNode,n-1)}}};for(let a of ic(t)){let t=D(e,a.source,a.exportedName);!t||!r(t)||!i(t.filePath)||o(t.filePath,t.programNode,n)}},mc=e=>{pc(e,4)},hc=({absoluteFilePath:e,sourceText:t,getProgram:n})=>{if(!t.includes(`createRef`)&&!t.includes(`\\u`))return;let r=n();Xt(r);let i=Ge(r);O(r,t=>{!b(t,`CallExpression`)||!ia(t,`createRef`,i,{allowGlobalReactNamespace:!0,allowUnboundBareCalls:!0,resolveNamedAliases:!0})||rc(t,e,i)})},gc=({absoluteFilePath:e,sourceText:t,staticImports:n,getProgram:r})=>{let i=new Set,a=new Set;for(let e of n)if(e.moduleRequest.value===`react`)for(let t of e.entries){let{importName:e}=t;e.kind===`Name`&&e.name===`useReducer`?i.add(t.localName.value):(e.kind===`Default`||e.kind===`NamespaceObject`)&&a.add(t.localName.value)}if(!(i.size>0||a.size>0&&(t.includes(`useReducer`)||t.includes(`\\u`))))return;let o=r(),s=e=>{if(e?.type!==`Identifier`)return null;let{name:t}=e;return typeof t==`string`?t:null},c=e=>{let t=s(e);if(t!==null)return i.has(t);if(e.type!==`MemberExpression`)return!1;let n=e,r=s(n.object);return r!==null&&a.has(r)&&s(n.property)===`useReducer`},l=new Set;if(O(o,e=>{if(e.type!==`CallExpression`)return;let t=e;if(!t.callee||!c(t.callee))return;let n=t.arguments?.[0];if(!n)return;let r=s(E(n));r!==null&&l.add(r)}),l.size!==0)for(let t of n)for(let n of t.entries){if(n.importName.kind===`NamespaceObject`||!l.has(n.localName.value))continue;let r=n.importName.kind===`Default`?`default`:n.importName.name;r&&Jn(e,t.moduleRequest.value,r)}},_c=({absoluteFilePath:e,staticImports:t,getProgram:n})=>{Vt(e),Qn({absoluteFilePath:e,staticImports:t,program:n()})},H=({absoluteFilePath:e})=>{Vt(e)},vc=e=>{H(e),dc(e)},yc=e=>{H(e),pc(e,1/0,e=>y(e.exportedNode),e=>!e.split(/[\\/]/).includes(`node_modules`))},bc=({absoluteFilePath:e})=>{Ur(e)},xc=({absoluteFilePath:e})=>{Qr(e)},Sc=e=>{xc(e),Qn({absoluteFilePath:e.absoluteFilePath,staticImports:e.staticImports,program:e.getProgram()})},Cc=new Map([..._.map(e=>[e,xc]),[`ink-no-raw-text`,Sc],[`client-passive-event-listeners`,V],[`effect-needs-cleanup`,V],[`exhaustive-deps`,mc],[`no-barrel-import`,ac],[`nextjs-async-dynamic-api-not-awaited`,H],[`nextjs-missing-metadata`,oc],[`nextjs-no-use-search-params-without-suspense`,sc],[`no-dynamic-import-path`,H],[`no-full-lodash-import`,H],[`no-hydration-branch-on-browser-global`,vc],[`no-indeterminate-attribute`,H],[`no-locale-format-in-render`,H],[`no-match-media-in-state-initializer`,H],[`no-create-ref-in-function-component`,hc],[`no-adjust-state-on-prop-change`,V],[`no-derived-state`,V],[`no-derived-state-effect`,V],[`no-event-handler`,V],[`no-initialize-state`,V],[`no-reset-all-state-on-prop-change`,V],[`no-mutating-reducer-state`,gc],[`no-side-effect-in-state-updater-function`,uc],[`no-unguarded-browser-global-at-module-scope`,dc],[`no-unguarded-browser-global-in-render-or-hook-init`,yc],[`prefer-dynamic-import`,H],[`rendering-hydration-mismatch-time`,H],[`rendering-hydration-no-flicker`,V],[`rerender-memo-with-default-value`,mc],[`rn-no-legacy-shadow-styles`,bc],[`rn-no-raw-text`,_c],[`rn-prefer-expo-image`,H],[`rn-style-prefer-boxshadow`,bc],...oe.map(e=>[e,H])]),wc=new Set([`anchor-target-exists`,`nextjs-no-img-element`,`no-img-without-dimensions`,`no-loading-flag-reset-outside-finally`,`only-export-components`,`remotion-calculate-metadata-fetch-signal`,`remotion-deterministic-randomness`,`remotion-no-css-animation`,`remotion-no-css-transition`,`remotion-no-css-url-assets`,`remotion-no-native-media-elements`,`remotion-no-next-image`,`window-open-without-noopener`]),Tc=e=>{let t=new Set;for(let n of e.ruleIds){let e=Cc.get(n);if(!e)return null;t.add(e)}let n=N(e.absoluteFilePath),r,i;try{let t=tn(n,e.sourceText);if(t.errors.some(e=>e.severity===`Error`))return null;r=t.module.staticImports;let a;i=()=>(a??=t.program,a)}catch{return null}let a={absoluteFilePath:n,sourceText:e.sourceText,staticImports:r,getProgram:i};return Ct(()=>{for(let e of t)e(a)})},Ec={},Dc=(e,t,n)=>!e||e.length===0?!1:e.every(e=>b(e,t)&&e[n]===`type`),Oc=e=>e.importKind===`type`||Dc(e.specifiers,`ImportSpecifier`,`importKind`),kc=new Set([`solid-js`,`solid-js/web`,`solid-js/store`,`solid-js/h`,`solid-js/html`,`@builder.io/qwik`,`@builder.io/qwik-city`,`@builder.io/qwik-react`,`voby`,`vidode`]),Ac=[`solid-js`,`@builder.io/qwik`],jc=[`react`,`react-dom`,`preact`],Mc=new WeakMap,Nc=new WeakMap,Pc=(e,t)=>t.some(t=>e===t||e.startsWith(`${t}/`)),Fc=e=>{let t=Mc.get(e);if(t)return t;let n=!1,r=!1,i=!1;for(let t of e.body){if(i||O(t,e=>{if(i)return!1;if(b(e,`JSXOpeningElement`)&&Lc(e))return i=!0,!1}),!b(t,`ImportDeclaration`))continue;let e=t;if(Oc(e))continue;let a=e.source,o=a&&typeof a.value==`string`?a.value:null;o&&((kc.has(o)||Pc(o,Ac))&&(n=!0),Pc(o,jc)&&(r=!0))}let a={hasNonReactMarker:i,hasNonReactRuntime:n,hasReactRuntime:r};return Mc.set(e,a),a},Ic=e=>{let t=Fc(e);return t.hasNonReactRuntime&&!t.hasReactRuntime},Lc=e=>{let t=Nc.get(e);if(t!==void 0)return t;let n=!1;for(let t of e.attributes){if(!b(t,`JSXAttribute`)||!b(t.name,`JSXIdentifier`))continue;let e=t.name.name;if(e===`classList`&&b(t.value,`JSXExpressionContainer`)&&b(t.value.expression,`ObjectExpression`)||e.startsWith(`class:`)||e.startsWith(`bind:`)){n=!0;break}}return Nc.set(e,n),n},Rc=new Set(`/playground/./playgrounds/./examples/./example/./demo/./demos/./sandbox/./sandboxes/./specs/./spec/./integration/./it/./perf/./scripts/./cli/./bin/./tooling/./tools/./codemods/./codemod/./migrations/./migration/./generators/./generator/./runbooks/./devtools/./internal-tools/./seeds/./seed/./dev-seeder/`.split(`.`)),zc=new Set,Bc=[`/test/`,`/tests/`,`/testing/`,`/__tests__/`,`/__test__/`,`/__fixtures__/`,`/fixtures/`,`/__mocks__/`,`/mocks/`,`/testUtils/`,`/test-utils/`,`/test-stubs/`,`/testutils/`,`/cypress/`,`/playwright/`,`/.storybook/`,`/.dumi/`,`/stories/`,`/__stories__/`,...Rc,`/e2e/`,`/e2e-tests/`,`/integration-tests/`,`/benchmarks/`,`/benchmark/`,`/__benchmarks__/`,`/perf-tests/`],Vc=[`.test.`,`.spec.`,`.cy.`,`.stories.`,`.story.`,`.bench.`,`.benchmark.`,`.e2e.`,`.integration-spec.`,`.int-spec.`,`.mock.`,`.mocks.`,`.fixture.`],Hc=new Set(`setuptests.js,setuptests.ts,setuptests.jsx,setuptests.tsx,setupvitest.js,setupvitest.ts,setupvitest.jsx,setupvitest.tsx,setupjest.js,setupjest.ts,vitest.setup.js,vitest.setup.ts,vitest.setup.mjs,vitest.config.ts,vitest.config.js,vitest.config.mts,vitest.config.mjs,jest.setup.js,jest.setup.ts,jest.setup.jsx,jest.setup.tsx,jest.config.js,jest.config.ts,jest.config.mjs,playwright.config.ts,playwright.config.js,cypress.config.ts,cypress.config.js,karma.conf.js,karma.conf.ts,vite.config.ts,vite.config.js,vite.config.mts,vite.config.mjs,webpack.config.ts,webpack.config.js,webpack.config.mjs,rollup.config.ts,rollup.config.js,rollup.config.mjs,esbuild.config.ts,esbuild.config.js,esbuild.config.mjs,tsup.config.ts,tsup.config.js,tsup.config.mjs,rsbuild.config.ts,rsbuild.config.js,rspack.config.ts,rspack.config.js,next.config.ts,next.config.js,next.config.mjs,remix.config.js,remix.config.ts,astro.config.ts,astro.config.js,astro.config.mjs,tailwind.config.ts,tailwind.config.js,tailwind.config.mjs,postcss.config.ts,postcss.config.js,postcss.config.mjs,biome.config.ts,biome.config.js,drizzle.config.ts,drizzle.config.js,prisma.config.ts,prisma.config.js,knip.config.ts,knip.config.js,knip.config.mjs,lint-staged.config.js,lint-staged.config.mjs`.split(`,`)),Uc=[`/src/`,`/app/`,`/lib/`,`/components/`,`/pages/`,`/features/`,`/modules/`,`/packages/`,`/apps/`,`/frontend/`,`/client/`],Wc=Bc.filter(e=>e.startsWith(`/.`)),Gc=e=>{let t=-1;for(let n of Uc){let r=e.lastIndexOf(n);r>t&&(t=r)}return t<0?e:e.slice(t)};let Kc,qc=!1,Jc,Yc=!1;const Xc=e=>e?e===Kc?qc:(Kc=e,qc=$c(e),qc):!1,Zc=e=>{if(!e)return!1;if(e===Jc)return Yc;Jc=e;let t=e.replaceAll(`\\`,`/`),n=t.startsWith(`/`)?t:`/${t}`;return Yc=$c(n,Uc.some(e=>n.includes(e))?Rc:zc),Yc},Qc=(e,t)=>e?$c(e,t):!1,$c=(e,t=zc)=>{let n=e.replaceAll(`\\`,`/`),r=n.lastIndexOf(`/`),i=r===-1?n:n.slice(r+1);if(Hc.has(i.toLowerCase()))return!0;for(let e of Vc)if(i.includes(e))return!0;let a=n.startsWith(`/`)?n:`/${n}`;for(let e of Wc)if(!t.has(e)&&a.includes(e))return!0;let o=Gc(n);for(let e of Bc)if(!t.has(e)&&(e.startsWith(`/.`)?n:o).includes(e))return!0;return!1},el=(e,t=Xc)=>n=>t(n.filename)?Ec:e(n),tl=e=>{let t=e?.[`react-doctor`];return typeof t!=`object`||!t||Array.isArray(t)?null:t},nl=(e,t)=>Object.getOwnPropertyDescriptor(e,t)?.value,rl=(e,t)=>{let n=tl(e);if(!n)return;let r=nl(n,t);return typeof r==`string`?r:void 0},il=(e,t)=>{let n=tl(e);if(!n)return;let r=nl(n,t);return typeof r==`number`&&Number.isFinite(r)?r:void 0},al=new WeakMap,ol=(e,t)=>{let n=nl(e,t);if(Array.isArray(n))return n.filter(e=>typeof e==`string`&&e.length>0)},sl=(e,t)=>{let n=tl(e);if(!n)return;let r=al.get(n);if(r||(r=new Map,al.set(n,r)),r.has(t))return r.get(t);let i=ol(n,t);return r.set(t,i),i},cl=(e,t)=>sl(e,t)??[],ll=(e,t)=>cl(e,`capabilities`).includes(t),ul=(e,t)=>{let n=tl(e);return!n||nl(n,`capabilities`)===void 0?!0:ll(e,t)},dl=(e,t)=>!t?.some(t=>ll(e,t)),fl=(e,t)=>n=>dl(n.settings,t)?e(n):Ec,pl=e=>(t=>{let n=e(t),r=!1,i=!1,a={};for(let e in n){if(!Object.hasOwn(n,e))continue;let t=n[e];if(typeof t!=`function`){a[e]=t;continue}let o=e.charAt(0);if(o<`A`||o>`Z`){a[e]=t;continue}if(e===`Program`){a.Program=e=>{let n=Fc(e);i=n.hasReactRuntime,r=!n.hasReactRuntime&&(n.hasNonReactRuntime||n.hasNonReactMarker),t(e)};continue}if(e===`JSXOpeningElement`){a.JSXOpeningElement=e=>{!i&&!r&&Lc(e)&&(r=!0),!r&&t(e)};continue}a[e]=e=>{r||t(e)}}return`Program`in a||(a.Program=e=>{let t=Fc(e);i=t.hasReactRuntime,r=!t.hasReactRuntime&&(t.hasNonReactRuntime||t.hasNonReactMarker)}),a}),U=e=>{if(!(`create`in e))return{...e,create:()=>Ec};let t=e.tags,n=e.create,r=t?.includes(`test-noise`)&&!t?.includes(`migration-hint`);return t?.includes(`react-jsx-only`)&&(n=pl(n)),r&&(n=el(n,Zc)),e.disabledWhen&&(n=fl(n,e.disabledWhen)),n===e.create?e:{...e,create:n}};let ml;const hl=e=>{let t=[0];for(let n=0;n<e.length;n+=1){let r=e[n];if(r===`\r`&&e[n+1]===`
3
+ `){n+=1,t.push(n+1);continue}(r===`\r`||r===`
4
+ `||r===`\u2028`||r===`\u2029`)&&t.push(n+1)}return t},gl=e=>{if(ml?.content===e)return ml.lineStartOffsets;let t=hl(e);return ml={content:e,lineStartOffsets:t},t},W=(e,t)=>{if(Number.isNaN(t)||t<0)return{line:1,column:1};let n=gl(e),r=Math.min(Math.trunc(t),e.length),i=0,a=n.length-1;for(;i<a;){let e=i+a+1>>1;n[e]<=r?i=e:a=e-1}return{line:i+1,column:r-n[i]+1}},_l=(e,t)=>W(e,e.search(t)),vl=/\.(?:[cm]?[jt]sx?|json|jsonc|map|html?|mdx?|ya?ml|toml|sql|rules|env|txt|log|svg|xml|pem|key|crt|cert|pub|py|php)$/i,yl=/(?:^|\/)\.env(?:\.|$)/,bl=/\.(?:[cm]?[jt]sx?)$/i,xl=/\.(?:[cm]?[jt]sx?|py|php)$/i,Sl=/\.(?:[cm]?[jt]sx?|py)$/i,Cl=/(?:^|\/)(?:api|backend|server|servers|middleware|route|routes|functions|lambdas|workers)(?:\/|$)|(?:^|\/)[^/]+\.server\.[cm]?[jt]sx?$/i,wl=/(?:^|\/)(?:__fixtures__|__mocks__|__tests__|__integration__|fixtures|mocks|test|tests|testdata|test-data|e2e|playwright|cypress|specs?)(?:\/|$)|^(?:test|spec)-[^/]+\.[cm]?[jt]sx?$|\.(?:test|spec|e2e|e2e-spec|integration-test|fixture|fixtures|stories|story)\.[cm]?[jt]sx?$|(?:^|\/)(?:playwright|cypress|vitest|jest|karma)[^/]*\.conf(?:ig)?\.[cm]?[jt]s$|(?:^|\/)(?:test_[^/]+|[^/]+_test|conftest)\.py$|\.env\.[^/]*(?:test|e2e)[^/]*$/i,Tl=/(?:^|\/)(?:vite|next|nuxt|astro|remix|webpack|rollup|rspack|rsbuild|esbuild|tsup|metro|expo|babel|tailwind|postcss|svelte|farm|parcel|snowpack)[^/]*\.config\.[cm]?[jt]sx?$/i,El=/(?:^|\/)scripts(?:\/|$)/i,Dl=/(?:^|\/)(?:examples?|tutorials?|demos?|samples?|playgrounds?)(?:\/|$)/i,Ol=/(?:^|\/)(?:README|CHANGELOG|CONTRIBUTING|PUBLISHING|DOCS)\.mdx?$|\.mdx?$/i,kl=/(?:^|\/)(?:generated|__generated__|dist|build|coverage|out|storybook-static|vendor|vendors|third[-_]?party|libraries)(?:\/|$)|(?:^|\/)\.next\/|(?:^|\/)\.yarn\/|(?:^|\/)public\/(?:chunks?|assets?|build|dist|static)\/|(?:generated|\.gen)\.[cm]?[jt]sx?$|@\d+\.\d+\.\d+(?:[-.][\w.]+)?\.[cm]?js$|[.-]min\.[cm]?js$|\.asm\.js$|(?:^|\/)[\w-]+[.@-]\d+\.\d+\.\d+(?:[-.][\w.]+)?\//i,Al=/\.(iife|umd|global|min)\.js$/i,jl=[/(?:^|\/)\.next\/static\//,/(?:^|\/)\.output\/public\//,/(?:^|\/)build\/static\//,/(?:^|\/)dist\/assets\//,/(?:^|\/)public\//,/(?:^|\/)out\//,/(?:^|\/)storybook-static\//],Ml=/\b(?:exec|execSync|spawn|child_process|eval|new Function|vm\.run|readFile|writeFile|fs\.read|fs\.write|fetch|axios|http\.request|sandbox|runCode|executeCode)\b/,Nl=new Set([`.next`,`.output`]),Pl=e=>{let t=e.split(`/`);for(let e=0;e<t.length;e+=1)if(Nl.has(t[e])&&(t[e]===`.next`&&t[e+1]===`dev`||t[e+1]===`server`&&e+2<t.length))return!0;return!1},Fl=(e,t)=>Pl(e)?!1:t||e.endsWith(`.map`)?!0:jl.some(t=>t.test(e)),Il=e=>/(?:^|\/)(?:package\.json|Dockerfile|docker-compose\.ya?ml|\.github\/workflows\/[^/]+\.ya?ml|vercel\.json|next\.config\.[cm]?[jt]s|netlify\.toml)$/i.test(e),Ll=new Map,Rl=(e,t)=>{let n=Ll.get(t);n||(n=new Map,Ll.set(t,n));let r=n.get(e);if(r!==void 0)return r;let i=t.test(e)&&!wl.test(e)&&!El.test(e)&&!Ol.test(e)&&!kl.test(e);return n.set(e,i),i},G=e=>/\.d\.[cm]?[jt]s$/i.test(e)?!1:Rl(e,bl),zl=/<script\b|on(?:load|error|click|mouseover)\s*=/i,Bl=/dangerouslyAllowSVG\s*:\s*true/i,Vl=/<(?:object|embed|iframe)\b[^>]+(?:data|src)=["'][^"']+\.svg(?:\?[^"']*)?["']/i,Hl=U({id:`active-static-asset`,title:`Executable SVG exposure`,severity:`warn`,recommendation:"Prefer `<img>` for SVG images; if SVG must be served directly, use attachment disposition and a CSP that blocks scripts and objects.",scan:e=>{let t=[];if(e.relativePath.endsWith(`.svg`)&&Fl(e.relativePath,e.isGeneratedBundle)){if(zl.test(e.content)){let n=_l(e.content,zl);t.push({message:`A browser-reachable SVG contains script or event-handler code.`,line:n.line,column:n.column,severity:`error`,title:`Active SVG in public assets`,help:`Serve untrusted SVG as downloads, sanitize it, or isolate it on a cookieless asset origin with a restrictive CSP.`})}return t}if(!G(e.relativePath)&&!Il(e.relativePath))return t;let n=[Bl,Vl].find(t=>t.test(e.content));if(n!==void 0){let r=_l(e.content,n);t.push({message:`The app enables or embeds SVG in an executable browser context.`,line:r.line,column:r.column})}return t}}),Ul=e=>/(?:^|\/)(?:firestore\.rules|storage\.rules|database\.rules\.json)$/.test(e),Wl=/\s/,Gl=/[\p{ID_Continue}$]/u,Kl=/["'`/]/g,ql=/["'`/{}]/g,Jl=/["\\\n]/g,Yl=/['\\\n]/g,Xl=/[`\\$\n]/g,Zl=new Set([`return`,`typeof`,`case`,`in`,`of`,`new`,`delete`,`void`,`instanceof`,`do`,`else`,`yield`,`await`,`throw`]),Ql=()=>{let e=[],t=[],n=-1,r=-1,i=()=>{n<0||(e.push(n),t.push(r),n=-1,r=-1)},a=(e,t)=>{if(e===r){r=t;return}if(e<r){r=Math.max(r,t);return}i(),n=e,r=t};return{blank:e=>a(e,e+1),blankSpan:a,isBlanked:i=>{if(i>=n&&i<r)return!0;for(let n=e.length-1;n>=0;--n)if(!(e[n]>i))return t[n]>i;return!1},apply:n=>{if(i(),e.length===0)return n;let r=[],a=0;for(let i=0;i<e.length;i+=1)r.push(n.slice(a,e[i]),` `.repeat(t[i]-e[i])),a=t[i];return r.push(n.slice(a)),r.join(``)}}},$l=(e,t,n)=>{let r=n=>t.isBlanked(n)?` `:e[n],i=n-1;for(;i>=0&&Wl.test(r(i));)--i;if(i<0)return!0;let a=r(i),o=i>0?r(i-1):``;if(Gl.test(a)){let t=i;for(;t>0&&Gl.test(r(t-1));)--t;return t>0&&r(t-1)===`.`?!1:Zl.has(e.slice(t,i+1))}return a===`<`?!1:a===`>`?o===`=`:a===`+`||a===`-`?o!==a:a===`!`?!(Gl.test(o)||o===`)`||o===`]`):!(a===`)`||a===`]`||a===`}`||a===`"`||a===`'`||a==="`")},eu=(e,t)=>{let n=t+1,r=!1;for(;n<e.length;){let t=e[n];if(t===`\\`){n+=2;continue}if(t===`
5
+ `)return null;if(t===`[`)r=!0;else if(t===`]`)r=!1;else if(t===`/`&&!r)return e[n+1]===`/`?null:n+1;n+=1}return null},tu=(e,t,n)=>{for(let r=t+1;r<e.length;r+=1){let t=e.charCodeAt(r);if(t===92){r+=1;continue}if(t===n)return!1;if(Wl.test(e[r]))return!0}return!1},nu=(e,t)=>{let n=e.length,r=Ql(),i=-1,a=!1,o=[],s=0,c=t=>{t>=n||e.charCodeAt(t)===10||r.blank(t)};for(;s<n;){if(i===-1){let t=o.length>0?ql:Kl;t.lastIndex=s;let n=t.exec(e);if(n===null)break;s=n.index}else{let t=i===34?Jl:i===39?Yl:Xl;t.lastIndex=s;let o=t.exec(e),c=o===null?n:o.index;if(a&&c>s&&r.blankSpan(s,c),s=c,o===null)break}let l=e.charCodeAt(s),u=e.charCodeAt(s+1);if(i!==-1){if(l===92){a&&(c(s),c(s+1)),s+=2;continue}if(l===10&&i!==96){i=-1,s+=1;continue}if(l===i){i=-1,s+=1;continue}if(t&&i===96&&l===36&&u===123){o.push(0),i=-1,s+=2;continue}a&&c(s),s+=1;continue}if(l===34||l===39){i=l,a=t&&tu(e,s,l),s+=1;continue}if(l===96){i=96,a=t,s+=1;continue}if(l===47&&u===47){for(;s<n&&e.charCodeAt(s)!==10;)r.blank(s),s+=1;continue}if(l===47&&u===42){for(;s<n;){if(e.charCodeAt(s)===42&&e.charCodeAt(s+1)===47){r.blank(s),r.blank(s+1),s+=2;break}c(s),s+=1}continue}if(l===47){let n=$l(e,r,s)?eu(e,s):null;if(n!==null){if(t)for(let e=s+1;e<n-1;e+=1)c(e);s=n;continue}}if(o.length>0){let e=o.length-1;l===123?o[e]+=1:l===125&&(o[e]===0?(o.pop(),i=96,a=t):--o[e])}s+=1}return r.apply(e)},ru=e=>e.includes(`//`)||e.includes(`/*`)?nu(e,!1):e,iu=e=>nu(e,!0),au=new WeakMap,ou=new WeakMap,su=(e,t=!1)=>{if(!bl.test(e.relativePath)&&!Ul(e.relativePath))return e.content;let n=t?ou:au,r=n.get(e);if(r!==void 0)return r;let i=t?iu(e.content):ru(e.content);return n.set(e,i),i},K=({shouldScan:e,pattern:t,requireAll:n,suppressWhen:r,ignoreStringLiterals:i,message:a})=>o=>{if(!e(o))return[];let s=su(o,i);if(n!==void 0&&!n.every(e=>e.test(s)))return[];let c=-1;if(t instanceof RegExp)c=s.search(t);else for(let e=0;e<t.length&&(c=s.search(t[e]),!(c>=0));e+=1);if(c<0||r!==void 0&&r.test(s))return[];let{line:l,column:u}=W(s,c);return[{message:a,line:l,column:u}]},cu=/\b(?:tool\s*\(\s*\{|createTool\s*\(|defineTool\s*\(|new\s+(?:DynamicTool|StructuredTool)\s*\()/,lu=/\b(?:tool|createTool|defineTool|DynamicTool|StructuredTool)\b/,uu=/(?:^|\/)(?:agents?|tools?|mcp)(?:\/|$)|(?:agent|tool|mcp)[^/]*\.[cm]?[jt]sx?$/i,du=U({id:`agent-tool-capability-risk`,defaultEnabled:!1,title:`Agent tool exposes dangerous capability`,severity:`warn`,recommendation:`Treat tool inputs as prompt-injection controlled. Validate arguments, scope permissions per call, and avoid exposing shell/file/network primitives directly to agents.`,scan:K({shouldScan:e=>G(e.relativePath)&&uu.test(e.relativePath)&&lu.test(e.content)&&Ml.test(e.content),pattern:cu,requireAll:[Ml],ignoreStringLiterals:!0,message:`An agent-callable tool appears to expose network, filesystem, shell, or code-execution capability.`})}),fu=U({id:`artifact-baas-authority-surface`,defaultEnabled:!1,title:`BaaS authority map shipped in browser artifact`,severity:`warn`,recommendation:`Client BaaS config is often public, but shipped collection names plus owner, role, tenant, or admin fields give attackers a precise authorization map. Verify rules/RLS enforce every boundary server-side.`,scan:K({shouldScan:e=>Fl(e.relativePath,e.isGeneratedBundle),pattern:/\b(?:collection\s*\(\s*["'](?:boosts|sessions|sessions_admin|users|orgs|candidateJobs|conversations|documents|profiles)|from\s*\(\s*["'](?:users|profiles|documents|organizations|memberships)|creatorID|creatorId|providerId|ghostOrg|ownerId|orgId|tenantId|workspaceId|isAdmin|SuperAdmin)\b/i,requireAll:[/\b(?:initializeApp|firebase|firestore|getFirestore)\b[\s\S]{0,700}\b(?:apiKey|authDomain|projectId|databaseURL|storageBucket)\b|\b(?:apiKey|authDomain|projectId|databaseURL|storageBucket)\b[\s\S]{0,700}\b(?:firebase|firestore|getFirestore|initializeApp)\b|\bcreateClient\b[\s\S]{0,700}\b(?:supabase|SUPABASE_URL)\b|\b(?:supabase|SUPABASE_URL)\b[\s\S]{0,700}\bcreateClient\b/i],message:`A browser artifact exposes Firebase/Supabase config together with sensitive collections or authorization fields.`})}),pu=new Set([`auth`,`getSession`,`getServerSession`,`getUser`,`requireAuth`,`checkAuth`,`verifyAuth`,`authenticate`,`currentUser`,`getAuth`,`validateSession`]),mu=/^auth(?:n|z|ed|enticate[ds]?|enticating|entication|orize[ds]?|orizing|orization|orizer)?$/,hu=new Set([`signedin`,`loggedin`,`signin`]),gu=new Set([`require`,`ensure`,`assert`,`verify`,`validate`,`check`,`protect`,`enforce`,`guard`,`gate`,`restrict`,`is`,`has`,`can`,`must`]),_u=new Set([`get`,`fetch`,`load`,`read`,`resolve`,`retrieve`,`use`]),vu=new Set([`current`,`my`,`own`]),yu=new Set([`session`,`sessions`,`login`,`admin`,`admins`,`superadmin`,`superuser`,`role`,`roles`,`permission`,`permissions`,`jwt`,`identity`,`principal`,`credential`,`credentials`]),bu=new Set([`user`,`users`,`account`,`accounts`,`token`,`tokens`,`access`,`me`,`viewer`,`caller`,`subject`,`scope`,`scopes`]),xu=new Set([`getUser`]),Su=/(?:^|[._])(?:auth|authn|authz|clerk|session|jwt|firebase|supabase|nextauth|kinde|workos|stytch|descope|cognito|propelauth|lucia)/i,Cu=[/^sk_live_/,/^sk_test_/,/^AKIA[0-9A-Z]{16}$/,/^ghp_[a-zA-Z0-9]{36}$/,/^gho_[a-zA-Z0-9]{36}$/,/^github_pat_/,/^glpat-/,/^xox[bporas]-/,/^sk-[a-zA-Z0-9]{32,}$/],wu=[/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/,/\bAWS_SECRET_ACCESS_KEY\s*[:=]\s*["']?[A-Za-z0-9/+=]{35,}["']?/,/\bgithub_pat_[A-Za-z0-9_]{30,}\b/,/\bgh[pousr]_[A-Za-z0-9]{30,}\b/,/\bglpat-[A-Za-z0-9_-]{20,}\b/,/\bxox[baprs]-[A-Za-z0-9-]{20,}\b/,/\bsk_(?:live|test)_[A-Za-z0-9]{16,}\b/,/\brk_(?:live|test)_[A-Za-z0-9]{16,}\b/,/\bsk-[A-Za-z0-9_-]{32,}\b/,/\bsk-ant-api\d{2}-[A-Za-z0-9_-]{20,}\b/,/\blin_(?:api|oauth)_[A-Za-z0-9]{20,}\b/,/\bvercel_[A-Za-z0-9]{20,}\b/,/\bsntrys_[A-Za-z0-9_-]{20,}\b/,/\bkey-[a-f0-9]{32}\b/i,/\bnpm_[A-Za-z0-9]{30,}\b/,/\bSG\.[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}\b/,/https:\/\/hooks\.slack\.com\/services\/T[A-Z0-9]+\/B[A-Z0-9]+\/[A-Za-z0-9]+/,/https:\/\/discord(?:app)?\.com\/api\/webhooks\/\d+\/[A-Za-z0-9_-]+/,/\bsb_secret_[A-Za-z0-9_]{20,}\b/,/\bservice_role\b/i,/"private_key"\s*:\s*"-----BEGIN PRIVATE KEY-----/,/-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----/,/\b(?:postgres|mysql|mongodb(?:\+srv)?|redis):\/\/[^:\s/@]+:(?!(?:pass(?:word)?|my[a-z]*pass(?:word)?|mysecretpassword|myusername|postgres|mysql|redis|root|admin|minioadmin|secret|example|changeme|change_me|test|guest|placeholder|default|user(?:name)?|x{3,}|\*{2,}|\$\{[^}]*\}|\$[A-Z_]+|<[^>]*>|%[\w.]+%|\{\{[^}]*\}\})@)[^@\s/]+@(?!(?:localhost|127\.0\.0\.1|0\.0\.0\.0|host\.docker\.internal)(?:[:/\s]|$))[^\s:/@]*\./i],Tu=/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{16,}\b/,Eu=/\b(?:NEXT_PUBLIC|VITE|REACT_APP|EXPO_PUBLIC)_[A-Z0-9_]*(?:SECRET|TOKEN|PASSWORD|PRIVATE|DATABASE_URL|SERVICE_ROLE|AWS_ACCESS_KEY|AWS_SECRET)[A-Z0-9_]*\b/i,Du=/\b(?:process\s*\.\s*env|import\s*\.\s*meta\s*\.\s*env|window\.__[A-Z0-9_]*ENV[A-Z0-9_]*__|__[A-Z0-9_]*ENV[A-Z0-9_]*__)\b/,Ou=/\b(?:(?:process|window)\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->))|import\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->|meta\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->)))))/,ku=/\b(?:DATABASE_URL|AWS_SECRET_ACCESS_KEY|AWS_ACCESS_KEY_ID|MAILGUN_API_KEY|SALESFORCE_CLIENT_SECRET|OKTA_CLIENT_SECRET|SESSION_SECRET|COOKIE_SECRET|PRIVATE_KEY|SERVICE_ROLE)\b/,Au=/(?:SENTRY_DSN|PUBLIC_KEY|(?:^|_)PUBLIC_TOKEN$|PUBLISHABLE|ANON_KEY|POSTHOG_(?:PROJECT_)?TOKEN|POSTHOG_KEY|TLDRAW_LICENSE_KEY|CLERK_PUBLISHABLE_KEY|ALGOLIA_SEARCH_KEY|GC_API_KEY|GOOGLE_MAPS_API_KEY|MAPBOX_TOKEN|MIXPANEL_TOKEN|FACEBOOK_CLIENT_TOKEN|(?:NEXT_PUBLIC|VITE|REACT_APP|EXPO_PUBLIC)_(?:DISABLE|ENABLE|ALLOW|REQUIRE)_)|(?:TOKEN|SECRET|PASSWORD|PRIVATE)_(?:KIND|TYPE|URL|URI|ENDPOINT|HEADER|NAME)$/i,ju=[/^appl_/,/^goog_/,/^amzn_/,/^strp_/,/^pk_(?:live|test)_/,/^sb_publishable_/,/^phc_/,/^public-token-(?:live|test)-/,/^pk\.eyJ/],Mu=[/^[\s._\-*\u2022xX]{8,}$/,/(?:\.{3,}|\u2026|[*\u2022]{3,})/,/(?:^|[_\-\s])(?:your|redacted|masked|placeholder|replace[_\-\s]?me|changeme)(?:$|[_\-\s])/i,/<[^>]*(?:auth|credential|key|password|secret|token|your|redacted|placeholder|masked)[^>]*>/i,/\[[^\]]*(?:auth|credential|key|password|secret|token|your|redacted|placeholder|masked)[^\]]*\]/i,/\{[^}]*(?:auth|credential|key|password|secret|token|your|redacted|placeholder|masked)[^}]*\}/i],Nu=[/(?:^|[_\-\s])(?:example|sample|dummy)(?:$|[_\-\s])/i],Pu=/(?:placeholder|example|sample|dummy|masked|redacted|mask)/i,Fu=/(?:api_?key|secret|token|password|credential|auth(?!or(?!i[sz])))/i,Iu=/(?:^|\/)[^/]+\.config\.[cm]?[jt]s$/,Lu=/(?:^|\/)(?:\.[a-z-]+rc|[a-z-]+\.rc)\.[cm]?[jt]s$/,Ru=/(?:^|\/)[^/]+\.(?:test|spec|stories|story|fixture|fixtures)\.[cm]?[jt]sx?$/,zu=/(?:^|\/)[^/]+\.server\.[cm]?[jt]sx?$/,Bu=/(?:^|\/)(?:middleware|proxy|route)\.[cm]?[jt]sx?$/,Vu=/(?:^|\/)pages\/api\/.+\.[cm]?[jt]sx?$/,Hu=/(?:^|\/)[^/]+\.(?:client|browser|web)\.[cm]?[jt]sx?$/,Uu=/(?:^|\/)(?:src\/)?(?:main|index|[Aa]pp|client)\.[cm]?[jt]sx?$/,Wu=new Set([`backend`,`functions`,`lambdas`,`lambda`,`middleware`,`server`,`servers`]),Gu=new Set([`api`,`backend`,`edge`,`function`,`functions`,`lambda`,`lambdas`,`server`,`servers`,`worker`,`workers`]),Ku=new Set([`__fixtures__`,`__mocks__`,`__tests__`,`fixtures`,`mocks`,`test`,`tests`]),qu=new Set([`bin`,`config`,`configs`,`script`,`scripts`,`tooling`,`tools`]),Ju=new Set([`components`,`features`,`hooks`,`pages`,`ui`,`views`,`widgets`]),Yu=new Set(`alert.modal.label.text.title.name.id.url.path.route.page.param.field.column.header.placeholder.prefix.description.type.icon.class.style.variant.event.action.status.state.mode.flag.option.config.message.error.display.view.component.element.container.wrapper.button.link.input.select.dialog.menu.form.step.index.count.length.role.scope.context.provider.ref.handler.query.schema.constant`.split(`.`)),Xu=new Set([`start`,`end`]),q=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),Zu=new RegExp(Eu.source,`gi`),Qu=e=>{for(let t of e.matchAll(Zu)){let e=t[0]??``;if(!Au.test(e))return new RegExp(q(e))}},$u=e=>Du.test(e)&&ku.test(e),ed=/\.(?:[cm]?[jt]sx?)$/i,td=/\/\/|\/\*|<!--/,nd=new Set([`\r`,`
6
+ `,`\u2028`,`\u2029`]),rd=e=>{let t=0;for(;t<e.length;){let n=e.indexOf(`-->`,t);if(n===-1)return!1;let r=n-1;for(;r>=0&&!nd.has(e[r]??``)&&e[r]?.trim()===``;)--r;if(r<0||nd.has(e[r]??``))return!0;t=n+3}return!1},id=(e,n)=>{if(!ed.test(e)||!n.startsWith(`#!`)&&!td.test(n)&&!rd(n))return n;try{let r=t(e,n,{astType:`ts`,lang:Qt(e)});if(r.errors.some(e=>e.severity===`Error`))return;let i=n.search(/[\r\n\u2028\u2029]/),a=[...n.startsWith(`#!`)?[{start:0,end:i===-1?n.length:i}]:[],...r.comments];if(a.length===0)return n;let o=[],s=0;for(let e of a)o.push(n.slice(s,e.start)),o.push(n.slice(e.start,e.end).replace(/[^\r\n\u2028\u2029]/g,` `)),s=e.end;return o.push(n.slice(s)),o.join(``)}catch{return}},ad=/\.map$/i,od=/\s/,sd=/[^\r\n\u2028\u2029]/g,J=(e,t)=>{let n=t;for(;n<e.length&&od.test(e[n]??``);)n+=1;return n},cd=(e,t)=>{if(e[t]!==`"`)return;let n=t+1;for(;n<e.length;){if(e[n]===`\\`){n+=2;continue}if(e[n]===`"`)return n+1;n+=1}},ld=(e,t)=>{let n=J(e,t);if(e[n]===`"`)return cd(e,n);if(e[n]!==`[`&&e[n]!==`{`){let t=n;for(;t<e.length&&![`,`,`]`,`}`].includes(e[t]??``);)t+=1;return t}let r=[e[n]===`[`?`]`:`}`],i=n+1;for(;i<e.length&&r.length>0;){if(e[i]===`"`){let t=cd(e,i);if(t===void 0)return;i=t;continue}e[i]===`[`&&r.push(`]`),e[i]===`{`&&r.push(`}`),e[i]===r.at(-1)&&r.pop(),i+=1}return r.length===0?i:void 0},ud=(e,t)=>{let n=J(e,0);if(e[n]!==`{`)return;n=J(e,n+1);let r;for(;n<e.length&&e[n]!==`}`;){let i=cd(e,n);if(i===void 0)return;let a=JSON.parse(e.slice(n,i));if(n=J(e,i),e[n]!==`:`)return;if(n=J(e,n+1),a===t){if(r!==void 0)return;r=n}let o=ld(e,n);if(o===void 0)return;if(n=J(e,o),e[n]===`,`){n=J(e,n+1);continue}if(e[n]!==`}`)return}return r},dd=(e,t,n)=>{let r=J(e,t);if(e[r]!==`[`)return;r=J(e,r+1);let i=[];for(let t of n){if(typeof t==`string`){let t=cd(e,r);if(t===void 0)return;i.push({start:r,end:t}),r=t}else if(t===null&&e.startsWith(`null`,r))i.push({start:r,end:r+4}),r+=4;else return;if(r=J(e,r),e[r]===`,`){r=J(e,r+1);continue}}return e[r]===`]`?i:void 0},fd=(e,t)=>`${e}/${t}`.split(/[\\/]/).includes(`node_modules`),pd=(e,t)=>{if(!ad.test(e)||!t.includes(`"sourcesContent"`))return t;try{let e=JSON.parse(t);if(typeof e!=`object`||!e||Array.isArray(e))return t;let n=Reflect.get(e,`sources`),r=Reflect.get(e,`sourcesContent`),i=Reflect.get(e,`sourceRoot`);if(!Array.isArray(n)||!n.every(e=>typeof e==`string`)||!Array.isArray(r)||n.length!==r.length||i!==void 0&&typeof i!=`string`)return t;let a=ud(t,`sourcesContent`);if(a===void 0)return t;let o=dd(t,a,r);if(o===void 0)return t;let s=i??``,c=[],l=0;for(let[e,r]of n.entries()){if(!fd(s,r))continue;let n=o[e];if(n===void 0)return t;c.push(t.slice(l,n.start)),c.push(t.slice(n.start,n.end).replace(sd,` `)),l=n.end}return l===0?t:(c.push(t.slice(l)),c.join(``))}catch{return t}},md=(e,t,n)=>{if(Ol.test(e.relativePath)||!Fl(e.relativePath,e.isGeneratedBundle))return[];let r=t(e.content);if(r===void 0)return[];let i=_l(e.content,r);return[{message:n,line:i.line,column:i.column}]},hd=`A browser artifact contains server-secret environment names or a full environment dump shape.`,gd=e=>Qu(e)??($u(e)?ku:void 0),_d=U({id:`artifact-env-leak`,title:`Server env leaked to browser artifact`,severity:`error`,recommendation:`Treat public env prefixes as publication, not secrecy; keep secret env vars server-only and rebuild after rotating leaked keys.`,scan:e=>{let t=pd(e.relativePath,e.content),n=t===e.content?e:{...e,content:t},r=!1,i=md(n,e=>{let t=Qu(e);if(t)return r=!0,t;if(ku.test(e))return Du.test(e)?(r=!0,ku):Ou.test(e)?ku:void 0},hd);if(i.length===0)return i;let a=r?i:md(n,gd,hd),o=id(n.relativePath,n.content);return o===void 0?i:o===n.content?a:md({...n,content:o},gd,hd)}}),vd=U({id:`artifact-secret-leak`,title:`Secret shipped in browser artifact`,severity:`error`,recommendation:`Remove the secret from client bundles/static assets, rotate it, and route privileged service calls through server-only code.`,scan:e=>md(e,e=>wu.find(t=>t.test(e)),`A browser-delivered artifact contains a secret-looking credential value.`)}),yd=/(?:npm|pnpm|yarn|bun)\s+(?:install|ci)\b(?:(?!--ignore-scripts)[\s\S]){0,700}\bsecrets\.[A-Z0-9_]+|\bsecrets\.[A-Z0-9_]+(?:(?!--ignore-scripts)[\s\S]){0,700}(?:npm|pnpm|yarn|bun)\s+(?:install|ci)\b/i,bd=/(?:npm|pnpm|yarn|bun)\s+(?:install|ci)\b/i,xd=/\bsecrets\.[A-Z0-9_]+/,Sd=/--ignore-scripts\b/,Cd=`The build or install pipeline can execute package lifecycle code while CI secrets may be present.`,wd=e=>/(?:^|\/)\.github\/workflows\/[^/]+\.ya?ml$/i.test(e),Td=e=>{let t=e.split(`
7
+ `),n=[],r=[],i,a,o;for(let e=0;e<t.length;e+=1){let s=t[e],c=s.trim();if(c===``||c.startsWith(`#`))continue;let l=s.length-s.trimStart().length;if(i!==void 0&&l<=i&&(i=void 0,a=void 0,o=void 0),i===void 0){/^steps:\s*(?:#.*)?$/.test(c)?i=l:n.push(s);continue}if((c===`-`||c.startsWith(`- `))&&(a===void 0||l===a)){a=l,o={startLineIndex:e,lines:[s]},r.push(o);continue}o===void 0?n.push(s):o.lines.push(s)}let s=xd.test(n.join(`
8
+ `));for(let e of r){let t=e.lines.join(`
9
+ `);if(!bd.test(t)||Sd.test(t)||!s&&!xd.test(t))continue;let n=Math.max(e.lines.findIndex(e=>bd.test(e)),0),r=e.lines[n].search(bd);return[{message:Cd,line:e.startLineIndex+n+1,column:(r===-1?0:r)+1}]}return[]},Ed=K({shouldScan:e=>Il(e.relativePath)&&!e.relativePath.endsWith(`package.json`)&&!wd(e.relativePath),pattern:yd,message:Cd}),Dd=U({id:`build-pipeline-secret-boundary`,title:`Build pipeline runs code near secrets`,severity:`warn`,recommendation:`Run dependency installs with scripts disabled before exposing secrets, isolate untrusted build code, and move signing/deploy authority into a narrow privileged step.`,scan:e=>wd(e.relativePath)?Td(e.content):Ed(e)}),Od=U({id:`clickjacking-redirect-risk`,title:`Redirect or frame boundary risk`,severity:`warn`,recommendation:"Allowlist redirect origins/paths, set `frame-ancestors` for privileged pages, and avoid URL-prefilled privileged dialogs.",scan:K({shouldScan:e=>G(e.relativePath)||Il(e.relativePath),pattern:/\bredirect\s*\((?!\s*(?:await\s+)?[\w$]*(?:safe|valid|sanitiz|allowlist|whitelist)[\w$]*\s*\()[^)'"`\n]*\b(?:searchParams\.get|nextUrl\.searchParams|returnTo|callbackUrl|continue|next)\b|<iframe\b[\s\S]{0,700}(?:\b(?:next=|continue=|redirect=|redirect_uri|userstoinvite|sharingaction|\.\.)|[?&](?:amp;)?role=)|frame-ancestors\s+(?:\*|'self'\s+\*)|X-Frame-Options["']?\s*:\s*["']?ALLOW/i,message:`Redirect or framing configuration may let attacker-controlled URLs chain into privileged UI or clickjacking.`})}),kd=e=>/(?:^|\/)(?:tools?|scripts?)\/|(?:^|\/)management\/commands\/|(?:^|\/)(?:build|make|gulpfile|gruntfile)\.[cm]?[jt]s$/i.test(e),Ad=e=>Rl(e,xl),jd=String.raw`(?:req\.|request\.|params\.|query\.|body\.|searchParams|\$_(?:GET|POST|REQUEST))`,Md=String.raw`(?:(?<![.\w$])(?:exec(?:Sync)?|system|passthru|proc_open|shell_exec)|\b(?:os\.system|subprocess\.(?:run|Popen|call)|(?:child_process|childProcess|cp)\.exec\w*))`,Nd=String.raw`(?:(?<![.\w$])spawn(?:Sync)?|\b(?:child_process|childProcess|cp)\.spawn\w*)`,Pd=String.raw`['"](?:sh|bash|zsh|dash|ksh|cmd(?:\.exe)?|powershell(?:\.exe)?|pwsh)['"]`,Fd=String.raw`['"](?:-c|/c|-Command)['"]`,Id=U({id:`command-execution-input-risk`,title:`Command execution uses caller-shaped input`,severity:`error`,recommendation:`Avoid shell execution for caller-controlled values. Use fixed commands, argument arrays, strict allowlists, and no shell interpolation.`,scan:K({shouldScan:e=>Ad(e.relativePath)&&!kd(e.relativePath),pattern:[new RegExp(String.raw`${Md}\s*\([^)]{0,220}(?:${jd}|shell\s*=\s*true|f['"\`][^'"\`]*\{)`,`i`),new RegExp(String.raw`${Nd}\s*\((?:[^,)]{0,120}?${jd}|\s*${Pd}\s*,\s*\[\s*${Fd}\s*,[^\]]{0,220}${jd}|(?=[^)]{0,220}shell\s*[:=]\s*true)[^)]{0,220}${jd})`,`i`)],message:`Command execution appears to include request, query, body, or shell-interpolated input.`})}),Ld=U({id:`cors-cookie-trust-risk`,title:`Broad cookie or credentialed CORS trust`,severity:`warn`,recommendation:`Keep auth cookies host-only and HttpOnly, avoid credentialed CORS for less-trusted docs/vendor origins, and isolate documentation domains from app sessions.`,scan:K({shouldScan:e=>G(e.relativePath)||Il(e.relativePath),pattern:/Access-Control-Allow-Credentials["']?\s*[:,]\s*["']?true[\s\S]{0,700}Access-Control-Allow-Origin["']?\s*[:,]\s*["']?(?:\*|https:\/\/docs\.|https:\/\/.*mintlify)|\b(?:session|auth|token|jwt)[^=\n]{0,80}(?:=[^;\n]{0,120};[^=\n]{0,80})?\bDomain=\./i,message:`Credentialed CORS or broad auth-cookie scope can make a docs/custom-domain XSS become account compromise.`})}),Rd=(e,t)=>{let n=e[t],r=n===`(`?`)`:n===`{`?`}`:n===`[`?`]`:``;if(r===``)return-1;let i=0,a=null;for(let o=t;o<e.length;o+=1){let t=e[o];if(a!==null){t===`\\`?o+=1:t===a&&(a=null);continue}if(t===`"`||t===`'`||t==="`")a=t;else if(t===n)i+=1;else if(t===r&&(--i,i===0))return o}return-1},zd=e=>`end`in e&&typeof e.end==`number`?e.end:-1,Y=e=>`start`in e&&typeof e.start==`number`?e.start:-1,Bd=e=>{let t=E(e);for(;b(t,`SequenceExpression`);){let e=t.expressions.at(-1);if(!e)break;t=E(e)}return t},Vd=e=>{if(e.kind!==`import`)return null;let t=e.declarationNode.parent;return b(t,`ImportDeclaration`)?t:null},Hd=e=>{let t=[],n=new Map;for(let r of e){let e=`${r.truthiness}:${r.nullishness}`,i=n.get(r.expression);i?.has(e)||(i?i.add(e):n.set(r.expression,new Set([e])),t.push(r))}return t},Ud=e=>b(e,`JSXElement`)||b(e,`JSXFragment`)||b(e,`ArrayExpression`)||b(e,`ObjectExpression`)||b(e,`ArrowFunctionExpression`)||b(e,`FunctionExpression`)||b(e,`ClassExpression`)||b(e,`NewExpression`)?{expression:e,truthiness:`truthy`,nullishness:`non-nullish`}:b(e,`Literal`)?e.value===null?{expression:e,truthiness:`falsy`,nullishness:`nullish`}:{expression:e,truthiness:e.value?`truthy`:`falsy`,nullishness:`non-nullish`}:b(e,`UnaryExpression`)&&e.operator===`void`?{expression:e,truthiness:`falsy`,nullishness:`nullish`}:{expression:e,truthiness:`unknown`,nullishness:`unknown`},Wd=e=>{let t=Bd(e);if(b(t,`ConditionalExpression`)){let e=Wd(t.test);return e.every(e=>e.truthiness===`truthy`)?Wd(t.consequent):e.every(e=>e.truthiness===`falsy`)?Wd(t.alternate):Hd([...Wd(t.consequent),...Wd(t.alternate)])}if(!b(t,`LogicalExpression`))return[Ud(t)];let n=Wd(t.left),r=Wd(t.right),i=[];for(let e of n){if(t.operator===`&&`){e.truthiness!==`truthy`&&i.push(e.truthiness===`falsy`?e:{...e,truthiness:`falsy`}),e.truthiness!==`falsy`&&i.push(...r);continue}if(t.operator===`||`){e.truthiness!==`falsy`&&i.push(e.truthiness===`truthy`?e:{...e,truthiness:`truthy`,nullishness:`non-nullish`}),e.truthiness!==`truthy`&&i.push(...r);continue}e.nullishness!==`nullish`&&i.push(e.nullishness===`non-nullish`?e:{...e,nullishness:`non-nullish`}),e.nullishness!==`non-nullish`&&i.push(...r)}return Hd(i)},Gd=e=>{let t=[],n=new Set;for(let r of Wd(e))n.has(r.expression)||(n.add(r.expression),t.push(r.expression));return t},Kd=new Set([`assign`,`defineProperties`,`defineProperty`]),qd=new Set([`defineProperty`,`set`]),Jd=new WeakMap,Yd=e=>{let t=P(e);for(;t.parent;){let e=t.parent;if(!b(e,`MemberExpression`)||e.object!==t)break;t=P(e)}return t},X=e=>{let t=e;for(;t;){if(y(t)||b(t,`Program`))return t;t=t.parent}return e},Z=(e,t)=>{if(b(e,`ReturnStatement`)||b(e,`ThrowStatement`)||b(e,`BreakStatement`)||t&&b(e,`ContinueStatement`))return!0;if(b(e,`BlockStatement`))return e.body.some(e=>Z(e,t));if(!b(e,`IfStatement`))return!1;if(b(e.test,`Literal`)){let n=e.test.value?e.consequent:e.alternate;return n?Z(n,t):!1}return!!(e.alternate&&Z(e.consequent,t)&&Z(e.alternate,t))},Xd=e=>Z(e,!0),Zd=(e,t)=>{let n=t.indexOf(e);return n>0&&t.slice(0,n).some(Xd)},Qd=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if((b(e,`BlockStatement`)||b(e,`Program`))&&Zd(n,e.body)||(b(e,`WhileStatement`)&&b(e.test,`Literal`)&&!e.test.value||b(e,`ForStatement`)&&e.test&&b(e.test,`Literal`)&&!e.test.value)&&e.body===n||b(e,`SwitchCase`)&&Zd(n,e.consequent)||b(e,`IfStatement`)&&b(e.test,`Literal`)&&(e.test.value===!1&&e.consequent===n||e.test.value===!0&&e.alternate===n)||b(e,`ConditionalExpression`)&&b(e.test,`Literal`)&&(e.test.value===!1&&e.consequent===n||e.test.value===!0&&e.alternate===n)||b(e,`LogicalExpression`)&&e.right===n&&b(e.left,`Literal`)&&(e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value))return!0;n=e}return!1},$d=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(b(e,`IfStatement`)&&(!b(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||b(e,`ConditionalExpression`)&&(!b(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||b(e,`LogicalExpression`)&&e.right===n&&(!b(e.left,`Literal`)||e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value)||b(e,`DoWhileStatement`)&&!(e.body===n&&b(e.test,`Literal`)&&!e.test.value)||b(e,`ForStatement`)||b(e,`ForInStatement`)||b(e,`ForOfStatement`)&&e.right!==n||b(e,`WhileStatement`)||b(e,`SwitchCase`)||b(e,`CatchClause`)||b(e,`TryStatement`)&&e.block===n||(b(e,`CallExpression`)||b(e,`MemberExpression`))&&e.optional)return!0;n=e}return!1},ef=(e,t)=>{let n=E(e);if(b(n,`Literal`))return!1;if(b(n,`Identifier`)){if(t.isGlobalReference(n)&&(n.name===`undefined`||n.name===`NaN`||n.name===`Infinity`))return!1;let e=t.symbolFor(n);return e?e.kind===`var`||e.kind===`function`||e.kind===`parameter`||e.kind===`import`?!1:Y(e.declarationNode)>Y(n):!0}if(b(n,`ArrayExpression`))return n.elements.some(e=>e?b(e,`SpreadElement`)?!0:ef(e,t):!1);if(b(n,`ObjectExpression`))return n.properties.length>0;if(b(n,`TemplateLiteral`))return n.expressions.length>0;if(b(n,`UnaryExpression`)){let e=E(n.argument);return n.operator===`typeof`&&b(e,`Identifier`)&&!t.symbolFor(e)?!1:ef(e,t)?!0:n.operator===`void`||n.operator===`typeof`||n.operator===`!`?!1:!(b(e,`Literal`)&&(typeof e.value==`number`||typeof e.value==`string`))}return!0},tf=(e,t,n)=>{let r=e;for(;r.parent&&r.parent!==t;)r=r.parent;let i=t.body.findIndex(e=>e===r);return r.parent!==t||i<=0?!1:t.body.slice(0,i).some(e=>b(e,`EmptyStatement`)?!1:b(e,`ExpressionStatement`)?ef(e.expression,n):b(e,`VariableDeclaration`)?e.declarations.some(e=>!b(e.id,`Identifier`)||!!(e.init&&ef(e.init,n))):!0)},nf=(e,t)=>b(e,`AwaitExpression`)?ef(e.argument,t):!1,rf=(e,t,n)=>{let r=e;for(;r.parent&&r!==t;){let t=r.parent;if(b(t,`IfStatement`)&&(!b(t.test,`Literal`)||t.test.value===!0&&t.alternate===r||t.test.value===!1&&t.consequent===r)||b(t,`ConditionalExpression`)&&(!b(t.test,`Literal`)||t.test.value===!0&&t.alternate===r||t.test.value===!1&&t.consequent===r)||b(t,`LogicalExpression`)&&t.right===r&&(!b(t.left,`Literal`)||t.operator===`&&`&&!t.left.value||t.operator===`||`&&t.left.value)||b(t,`WhileStatement`)&&(!b(t.test,`Literal`)||!t.test.value)||b(t,`ForStatement`)&&t.test&&(!b(t.test,`Literal`)||!t.test.value)||b(t,`ForInStatement`)||b(t,`ForOfStatement`)||b(t,`SwitchCase`)||b(t,`CatchClause`)||b(t,`TryStatement`)&&t.block===r&&b(r,`BlockStatement`)&&(tf(e,r,n)||nf(e,n))||(b(t,`CallExpression`)||b(t,`MemberExpression`))&&t.optional)return!0;r=t}return!1},af=(e,t)=>{let n=e;for(;n;){if(n===t)return!0;n=n.parent}return!1},of=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(b(e,`IfStatement`)&&(!b(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||b(e,`ConditionalExpression`)&&(!b(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||b(e,`LogicalExpression`)&&e.right===n&&(!b(e.left,`Literal`)||e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value)||b(e,`ForStatement`)||b(e,`ForInStatement`)||b(e,`ForOfStatement`)||b(e,`WhileStatement`)||b(e,`SwitchCase`)||b(e,`CatchClause`)||b(e,`TryStatement`)&&e.block===n||(b(e,`CallExpression`)||b(e,`MemberExpression`))&&e.optional)return n;n=e}return null},sf=e=>b(e,`AwaitExpression`)||b(e,`YieldExpression`)?e.argument?zd(e.argument):zd(e):b(e,`ForOfStatement`)?zd(e.right):Y(e),cf=(e,t,n)=>{if(Y(t)<sf(e))return!1;let r=of(e,n);return!!(r&&af(t,r))},lf=e=>{let t=Jd.get(e);if(t)return t;let n=(t,n,r)=>{let i=E(t);if(!b(i,`MemberExpression`))return!1;let a=E(i.object);return!!(b(a,`Identifier`)&&a.name===n&&e.isGlobalReference(a)&&r.has(A(i)??``))},r=e=>{let t=E(e);if(!b(t,`ObjectExpression`))return null;let n=new Set;for(let e of t.properties){if(!b(e,`Property`))return null;let t=j(e,{allowComputedString:!0});if(t===null)return null;n.add(t)}return n},i=e=>{let t=Yd(e),i=t.parent;if(i){if(b(i,`AssignmentExpression`)&&i.left===t||b(i,`UpdateExpression`)&&i.argument===t||b(i,`UnaryExpression`)&&i.operator===`delete`){if(!b(t,`MemberExpression`))return null;let e=A(t);return e===null?null:new Set([e])}if(!(!b(i,`CallExpression`)||i.arguments[0]!==t)){if(n(i.callee,`Object`,Kd)){let e=E(i.callee);if(!b(e,`MemberExpression`))return;let t=A(e);if(t===`assign`){let e=i.arguments.slice(1).map(r);return e.some(e=>e===null)?null:new Set(e.flatMap(e=>[...e??[]]))}if(t===`defineProperties`){let e=i.arguments[1];return e?r(e):null}let n=i.arguments[1];return n&&b(n,`Literal`)&&typeof n.value==`string`?new Set([n.value]):null}if(n(i.callee,`Reflect`,qd)){let e=i.arguments[1];return e&&b(e,`Literal`)&&typeof e.value==`string`?new Set([e.value]):null}}}},a=e=>{let t=P(e),n=t.parent;if(b(n,`ForOfStatement`)&&n.right===t)return n.await||Z(n.body,!1);let r=n;if(!b(r,`MemberExpression`)||r.object!==t||A(r)!==`next`)return!1;let i=P(r);return!!(b(i.parent,`CallExpression`)&&i.parent.callee===i)},o=e=>{let t=P(e),n=t.parent;return b(n,`ForOfStatement`)&&!n.await&&n.right===t&&!Z(n.body,!1)?!0:!!(b(n,`SpreadElement`)&&n.parent&&!b(n.parent,`ObjectExpression`))},s=e=>{let t=P(e),n=t.parent;if(!b(n,`ForOfStatement`)||n.await||n.right!==t||Z(n.body,!1))return[];let r=X(n.body),i=new Set;return O(n.body,e=>{if(X(e)!==r||!b(e,`BreakStatement`))return;let a=e;if(e.label){for(;a?.parent;){let t=a.parent;if(b(t,`LabeledStatement`)&&t.label.name===e.label.name){af(n,t.body)&&i.add(t);return}a=t}return}for(;a?.parent;){let e=a.parent;if(b(e,`ForStatement`)||b(e,`ForInStatement`)||b(e,`ForOfStatement`)||b(e,`WhileStatement`)||b(e,`DoWhileStatement`)||b(e,`SwitchStatement`)){b(e,`ForOfStatement`)&&e.right===t&&i.add(e);return}a=e}}),[...i]},c=t=>{let n=E(t.callee),r=null;if(y(n))r=n;else if(b(n,`Identifier`)){let t=M(n,e);if(t?.kind===`function`&&y(t.declarationNode))r=t.declarationNode;else if(t?.kind===`const`&&t.initializer){let e=E(t.initializer);y(e)&&(r=e)}}return r&&y(r)?r:null},l=e=>{let t=c(e);return!t||!y(t)?null:t.generator?a(e)||o(e)?t:null:t},u=[],d=new Map;O(e.rootScope.node,t=>{if(b(t,`CallExpression`)){let e=X(t),n=l(t);n&&!Qd(t,e)&&u.push({argumentCall:t,call:t,conditionalExitTargets:y(n)&&n.generator?s(t):[],owner:e,targetOwner:n,yieldCount:y(n)&&n.generator&&a(t)?1:null})}if(!b(t,`Identifier`))return;let n=i(t);if(n===void 0)return;let r=M(t,e);if(!r)return;let o=X(t);if(Qd(t,o))return;let c=d.get(r.id)??[];c.push({node:t,owner:o,propertyNames:n,symbolId:r.id}),d.set(r.id,c)});let f=t=>{let n=X(t),r=Y(t),i=new Set,a=(e,t)=>{for(let n of u)n.owner!==e||Y(n.call)>=t||i.has(n.targetOwner)||(i.add(n.targetOwner),a(n.targetOwner,1/0))};return a(n,r),b(n,`Program`)||a(e.rootScope.node,1/0),i},p=e=>{if(b(e,`Program`))return 1/0;let t=u.find(t=>b(t.owner,`Program`)&&t.targetOwner===e);return t?Y(t.call):1/0},m=new Map;for(let e of u){let t=m.get(e.owner)??[];t.push(e),m.set(e.owner,t)}let h=new WeakMap,ee=(e,t)=>{let n=h.get(e)?.get(t);if(n!==void 0)return n;let r=[e],i=new Set,a=!1;for(;r.length>0;){let e=r.pop();if(!(!e||i.has(e))){if(e===t){a=!0;break}i.add(e);for(let t of m.get(e)??[])r.push(t.targetOwner)}}let o=h.get(e)??new WeakMap;return o.set(t,a),h.set(e,o),a},te=(e,t)=>{let n=new Set,r=e;for(;r?.parent&&r!==t;){let t=r.parent,i=b(t,`DoWhileStatement`)&&b(t.test,`Literal`)&&!t.test.value,a=b(t,`ForStatement`)||b(t,`ForInStatement`)||b(t,`ForOfStatement`)||b(t,`WhileStatement`)||b(t,`DoWhileStatement`)?t.body:null,o=e;for(;a&&b(a,`BlockStatement`)&&o&&o.parent!==a;)o=o.parent??null;let s=a&&b(a,`BlockStatement`)&&o?a.body.findIndex(e=>e===o):-1,c=!!(a&&b(a,`BlockStatement`)&&s>=0&&a.body.slice(s+1).some(e=>Z(e,!1)));a&&!i&&!c&&n.add(t),r=t}return n},g=(e,t,n)=>{let r=te(e,n);return r.size===0?!1:[...te(t,n)].some(e=>r.has(e))},ne=new WeakMap,_=e=>{let t=ne.get(e);if(t)return t;let n=new Map;for(let t of u){if(!ee(t.targetOwner,e))continue;let r=n.get(t.owner)??[];r.push(t),n.set(t.owner,r)}return ne.set(e,n),n},re=(e,t)=>{let n=_(e),r=_(t);for(let[e,t]of n){let n=r.get(e);if(n){for(let r of t)for(let t of n)if(r!==t&&(Y(r.call)<Y(t.call)||y(e)||g(r.call,t.call,e)))return!0}}return!1},ie=e=>{let t=X(e);if(b(t,`Program`))return!1;let n=u.filter(e=>b(e.owner,`Program`)&&ee(e.targetOwner,t));return n.length===0?!1:n.length!==1||n[0]?.targetOwner!==t},ae=e=>{let t=Yd(e.node),n=t.parent;return!!(b(t,`Identifier`)&&n&&(b(n,`AssignmentExpression`)&&n.left===t||b(n,`UpdateExpression`)&&n.argument===t))},oe=(t,n)=>{let r=E(t);if(b(r,`Identifier`)){let t=M(r,e);return t&&n.has(t.id)?n.get(t.id)??!1:null}if(b(r,`SequenceExpression`)){let e=r.expressions.at(-1);return e?oe(e,n):null}if(b(r,`ConditionalExpression`)){let e=oe(r.consequent,n),t=oe(r.alternate,n);return e===null&&t===null?null:e===null||t===null?!0:e||t}if(b(r,`LogicalExpression`)){let e=oe(r.left,n),t=oe(r.right,n);return e===null?t===null?null:!0:r.operator===`&&`?t:e}return null},se=(e,t)=>{let n=Yd(e.node).parent;if(!n||!b(n,`AssignmentExpression`)){t.delete(e.symbolId);return}let r=t.get(e.symbolId)??!1,i=null;n.operator===`||=`||n.operator===`??=`?i=r:(n.operator===`=`||n.operator===`&&=`)&&(i=oe(n.right,t));let a=$d(e.node,e.owner);i===null?a?t.set(e.symbolId,!0):t.delete(e.symbolId):t.set(e.symbolId,a&&r||i)},ce=(t,n)=>{if(!y(t.targetOwner))return n;let r=new Map(n);for(let[i,a]of t.targetOwner.params.entries()){let o=b(a,`AssignmentPattern`)?a.left:a;if(!b(o,`Identifier`))continue;let s=t.argumentCall.arguments[i],c=s&&!b(s,`SpreadElement`)?E(s):null,l=null;if(b(a,`AssignmentPattern`)&&(!c||b(c,`Identifier`)&&c.name===`undefined`&&e.isGlobalReference(c)||b(c,`UnaryExpression`)&&c.operator===`void`)&&b(a,`AssignmentPattern`)?l=E(a.right):c&&(l=c),!b(l,`Identifier`))continue;let u=M(l,e);if(!u||!n.has(u.id))continue;let d=e.symbolFor(o);d&&r.set(d.id,n.get(u.id)??!1)}return r},le=(t,n)=>{if(!y(t.targetOwner))return{conditionalSuspensions:[],conditionalStartIndex:1/0,cutoffIndex:1/0};let r=new Set;t.targetOwner.async&&(r.add(`AwaitExpression`),r.add(`ForOfStatement`));let i=t.conditionalExitTargets.some(e=>!n||!af(n,e));(t.yieldCount!==null||i)&&r.add(`YieldExpression`);let a=[],o=1/0,s=1/0,c=0;return O(t.targetOwner.body,n=>{if(X(n)!==t.targetOwner||Qd(n,t.targetOwner)||!(r.has(n.type)&&(!b(n,`ForOfStatement`)||n.await)))return;let l=b(n,`YieldExpression`)&&n.argument?E(n.argument):null;if(b(n,`YieldExpression`)&&n.delegate&&l&&(b(l,`ArrayExpression`)&&l.elements.length===0||b(l,`Literal`)&&l.value===``))return;let u=sf(n);if(b(n,`YieldExpression`)){if(c+=1,i&&c>=1){o=Math.min(o,u);return}if(t.yieldCount===null||c>t.yieldCount)return}rf(n,t.targetOwner,e)?(a.push(n),o=Math.min(o,u)):s=Math.min(s,u)}),{conditionalSuspensions:a,conditionalStartIndex:Math.min(o,s),cutoffIndex:s}},ue=(e,t,n)=>{let r=(e,t,i)=>{if(t.has(e.targetOwner))return!1;let a=new Set(t);a.add(e.targetOwner);let o=new Map(ce(e,i)),s=le(e),c=[...[...o.keys()].flatMap(e=>d.get(e)??[]).filter(t=>t.owner===e.targetOwner).map(e=>({event:e,index:Y(e.node)})),...u.filter(t=>t.owner===e.targetOwner).map(e=>({call:e,index:Y(e.call)}))].sort((e,t)=>e.index-t.index);for(let t of c){if(t.index>=s.cutoffIndex)break;let i=`event`in t?t.event.node:t.call.call;if(!s.conditionalSuspensions.some(t=>cf(t,i,e.targetOwner))){if(`event`in t){if(!o.has(t.event.symbolId))continue;if(ae(t.event)){se(t.event,o);continue}if(n===null||t.event.propertyNames===null||t.event.propertyNames.has(n))return!0;continue}if(r(t.call,a,o))return!0}}return!1};return r(e,new Set,t)},de={getEventsBefore:(t,n)=>{let r=[],i=(e,t,a,o,s,c,l)=>{if(s.has(e))return;let f=new Set(s);f.add(e);let p=new Map(l),m=[...[...p.keys()].flatMap(e=>d.get(e)??[]).filter(t=>t.owner===e).map(e=>({event:e,index:Y(e.node)})),...u.filter(t=>t.owner===e).map(e=>({call:e,index:Y(e.call)}))].sort((e,t)=>e.index-t.index);for(let s of m){if(s.index>=t)break;let l=`event`in s?s.event.node:s.call.call;if(o.some(t=>cf(t,l,e)))continue;if(`event`in s){if(!p.has(s.event.symbolId))continue;let e=!!(c||p.get(s.event.symbolId)||$d(s.event.node,s.event.owner)||s.index>a);if(ae(s.event)){se(s.event,p);continue}r.push({isConditional:e,node:s.event.node});continue}let u=le(s.call,n);i(s.call.targetOwner,u.cutoffIndex,u.conditionalStartIndex,u.conditionalSuspensions,f,c||$d(s.call.call,s.call.owner)||s.index>a,ce(s.call,p))}},a=X(n),o=new Map([[t.id,!1]]);return b(a,`Program`)||i(e.rootScope.node,p(a),1/0,[],new Set,!1,o),i(a,Y(n),1/0,[],new Set,!1,o),r},getOutermostTarget:Yd,isGlobalNamespaceMethod:n,isExecutionOrderAmbiguous:ie,isMutationOrderAmbiguous:(e,t,n)=>{let r=X(t),i=Y(t);if((d.get(e.id)??[]).some(e=>n!==null&&e.propertyNames!==null&&!e.propertyNames.has(n)?!1:e.owner===r?Y(e.node)>=i&&(y(r)||g(e.node,t,r)):b(e.owner,`Program`)?(_(r).get(e.owner)??[]).some(t=>g(e.node,t.call,e.owner)):ee(e.owner,r)||re(e.owner,r)))return!0;let a=new Map([[e.id,!1]]);return u.some(e=>e.owner===r&&Y(e.call)>=i&&g(e.call,t,r)&&ue(e,a,n))},isMutatedBefore:(e,t,n)=>{let r=d.get(e.id);if(!r)return!1;let i=Y(t),a=X(t),o=f(t);return r.some(e=>n!==null&&e.propertyNames!==null&&!e.propertyNames.has(n)?!1:e.owner===a?Y(e.node)<i:b(e.owner,`Program`)&&!b(a,`Program`)?Y(e.node)<p(a):o.has(e.owner))}};return Jd.set(e,de),de},uf=(e,t)=>t===`katex`?e===`katex`||e.startsWith(`katex/`):e===t,df=(e,t,n)=>{let r=E(e);if(!b(r,`CallExpression`))return!1;let i=E(r.callee),a=r.arguments[0];return!!(b(i,`Identifier`)&&i.name===`require`&&n.isGlobalReference(i)&&a&&b(a,`Literal`)&&typeof a.value==`string`&&uf(a.value,t))},ff=(e,t)=>{if(e.kind!==`ts-import-equals`)return!1;let n=e.declarationNode;if(!b(n,`TSImportEqualsDeclaration`))return!1;let r=n.moduleReference;return!!(b(r,`TSExternalModuleReference`)&&b(r.expression,`Literal`)&&typeof r.expression.value==`string`&&uf(r.expression.value,t))},pf=(e,t)=>{let n=E(e);return!!(b(n,`AwaitExpression`)&&b(n.argument,`ImportExpression`)&&b(n.argument.source,`Literal`)&&typeof n.argument.source.value==`string`&&uf(n.argument.source.value,t))},mf=(e,t,n,r,i)=>{let a=M(E(e),i),o=lf(i);if(!a||o.isExecutionOrderAmbiguous(r)||o.isMutationOrderAmbiguous(a,r,n)||o.isMutatedBefore(a,r,n))return null;let s=Vd(a);if(typeof s?.source.value==`string`&&uf(s.source.value,t))return b(a.declarationNode,`ImportDefaultSpecifier`)||b(a.declarationNode,`ImportNamespaceSpecifier`)||k(a.declarationNode)===`default`?a:null;if(ff(a,t))return a;if(a.kind!==`const`||!a.initializer)return null;let c=E(a.initializer);return df(c,t,i)||b(c,`MemberExpression`)&&A(c)===`default`&&(df(c.object,t,i)||pf(c.object,t))||pf(c,t)?a:null},hf=(e,t,n,r,i)=>{let a=M(E(e),i);if(!a)return null;let o=Vd(a),s=lf(i);return typeof o?.source.value!=`string`||!uf(o.source.value,t)||k(a.declarationNode)!==n||s.isExecutionOrderAmbiguous(r)||s.isMutationOrderAmbiguous(a,r,null)||s.isMutatedBefore(a,r,null)?null:a},gf=(e,t,n)=>mf(e,`katex`,`renderToString`,t,n)!==null||df(e,`katex`,n),_f=(e,t,n)=>{if(hf(e,`katex`,`renderToString`,t,n))return!0;let r=E(e);if(!b(r,`Identifier`))return!1;let i=n.referenceFor(r)?.resolvedSymbol;if(!i||i.kind!==`const`||!i.initializer||lf(n).isMutatedBefore(i,t,null))return!1;let a=E(i.initializer),o=i.bindingIdentifier.parent;return b(o,`Property`)&&j(o,{allowComputedString:!0})===`renderToString`?gf(a,i.declarationNode,n):b(a,`MemberExpression`)&&A(a)===`renderToString`&&gf(a.object,i.declarationNode,n)?!0:b(a,`Identifier`)?_f(a,i.declarationNode,n):!1},vf=(e,t)=>{let n=E(e);if(b(n,`Identifier`)){if(!/katex/i.test(n.name))return!1;let e=t.referenceFor(n)?.resolvedSymbol;return!!(e&&e.kind!==`parameter`&&e.kind!==`let`)}if(!b(n,`MemberExpression`)||A(n)!==`renderToString`)return!1;let r=E(n.object);if(!b(r,`Identifier`)||!/katex/i.test(r.name))return!1;let i=t.referenceFor(r)?.resolvedSymbol;if(!i)return!1;if(i.kind===`import`){if(!uf(String(Vd(i)?.source.value??``),`katex`))return!0;let e=lf(t);return e.isExecutionOrderAmbiguous(n)||e.isMutationOrderAmbiguous(i,n,`renderToString`)?!1:e.isMutatedBefore(i,n,`renderToString`)}if(i.kind===`parameter`||i.kind===`let`||i.kind===`var`)return!0;if(i.kind!==`const`||!i.initializer)return!1;let a=E(i.initializer);if(b(a,`ObjectExpression`))return!0;if(b(a,`CallExpression`)){let e=E(a.callee);return b(e,`Identifier`)&&e.name===`require`}return b(a,`AwaitExpression`)&&b(a.argument,`ImportExpression`)},yf=(e,t)=>{let n=E(e);if(!b(n,`ObjectExpression`))return null;let r;for(let e of n.properties){if(!b(e,`Property`)){r=null;continue}let n=j(e,{allowComputedString:!0});if(n===null){r=null;continue}n===t&&(r=e.kind===`init`?e.value:null)}return r},bf=e=>{let t=E(e);if(!b(t,`ObjectExpression`))return null;for(let e of t.properties){if(!b(e,`Property`))return null;let t=j(e,{allowComputedString:!0});if(t===null||t===`get`||t===`set`)return null}return yf(t,`value`)},xf=new WeakMap,Sf=(e,t)=>{let n=E(e);return b(n,`Identifier`)?n.name===`undefined`&&t.isGlobalReference(n):b(n,`Literal`)&&!n.value},Cf=(e,t,n)=>{let r=bf(t);return r===null?`trusted`:r===void 0?e:Sf(r,n)?`untrusted`:`trusted`},wf=(e,t)=>e===t?e:e===`trusted`||t===`trusted`?`trusted`:e===`unsupported`||t===`unsupported`?`unsupported`:`untrusted`,Tf=(e,t,n,r)=>{let i=lf(n),a=i.getOutermostTarget(t),o=a.parent;if(!o)return`unsupported`;if(b(o,`AssignmentExpression`)&&o.left===a){if(!b(a,`MemberExpression`))return`unsupported`;let t=A(a);return t===null?`trusted`:t===`trust`?Sf(o.right,n)?`untrusted`:`trusted`:e}if(b(o,`UnaryExpression`)&&o.operator===`delete`){if(!b(a,`MemberExpression`))return`unsupported`;let t=A(a);return t===null?`trusted`:t===`trust`?`absent`:e}if(b(o,`UpdateExpression`)){if(!b(a,`MemberExpression`))return`unsupported`;let t=A(a);return t===`trust`||t===null?`trusted`:e}if(!b(o,`CallExpression`)||o.arguments[0]!==a)return`unsupported`;if(i.isGlobalNamespaceMethod(o.callee,`Object`,Kd)){let t=E(o.callee);if(!b(t,`MemberExpression`))return`unsupported`;let i=A(t);if(i===`assign`){let t=e;for(let e of o.arguments.slice(1)){let i=Ef(e,e,n,new Set(r));i!==`absent`&&(t=i)}return t}if(i===`defineProperties`){let t=o.arguments[1];if(!t)return`unsupported`;let r=yf(t,`trust`);return r===null?`trusted`:r===void 0?e:Cf(e,r,n)}let a=o.arguments[1];if(!a||!b(a,`Literal`)||typeof a.value!=`string`)return`trusted`;if(a.value!==`trust`)return e;let s=o.arguments[2];return s?Cf(e,s,n):`unsupported`}if(i.isGlobalNamespaceMethod(o.callee,`Reflect`,qd)){let t=E(o.callee);if(!b(t,`MemberExpression`))return`unsupported`;let r=A(t),i=o.arguments[1];if(!i||!b(i,`Literal`)||typeof i.value!=`string`)return`trusted`;if(i.value!==`trust`)return e;let a=o.arguments[2];return a?r===`defineProperty`?Cf(e,a,n):Sf(a,n)?`untrusted`:`trusted`:`unsupported`}return`unsupported`},Ef=(e,t,n,r)=>{if(e===void 0)return`absent`;let i=E(e);if(b(i,`Identifier`)){if(i.name===`undefined`&&n.isGlobalReference(i))return`absent`;let e=M(i,n);if(!e||e.kind!==`const`||!e.initializer||r.has(e.id))return`unsupported`;let a=new Set(r);a.add(e.id);let o=lf(n);if(o.isMutationOrderAmbiguous(e,t,`trust`))return`unsupported`;let s=Ef(e.initializer,t,n,a);for(let r of o.getEventsBefore(e,t)){let e=Tf(s,r.node,n,a);s=r.isConditional?wf(s,e):e}return s}if(!b(i,`ObjectExpression`))return`unsupported`;let a=`absent`;for(let e of i.properties){if(b(e,`SpreadElement`)){let t=Ef(e.argument,e.argument,n,new Set(r));t!==`absent`&&(a=t===`unsupported`?`trusted`:t);continue}if(!b(e,`Property`)){a=`trusted`;continue}let t=j(e,{allowComputedString:!0});if(t===null){a=`trusted`;continue}t===`trust`&&(a=Sf(e.value,n)?`untrusted`:`trusted`)}return a},Df=(e,t,n)=>{let r=xf.get(e),i=new Map(r);for(let[e,n]of t)i.set(e,n);xf.set(e,i);try{return n()}finally{r?xf.set(e,r):xf.delete(e)}},Of=(e,t,n,r)=>{let i=e?E(e):void 0;if(i&&b(i,`Identifier`)){let e=n.referenceFor(i)?.resolvedSymbol,t=e?xf.get(n)?.get(e.id):void 0;if(t)return t}let a=Ef(e,t,n,r);return{isSafe:a===`absent`||a===`untrusted`}},kf={containsKatex:!1,isConclusive:!0,isSafe:!0,isSafeInAttributeContext:!0},Af={containsKatex:!1,isConclusive:!0,isSafe:!0,isSafeInAttributeContext:!1},Q={containsKatex:!1,isConclusive:!1,isSafe:!1,isSafeInAttributeContext:!1},jf={containsKatex:!0,isConclusive:!1,isSafe:!1,isSafeInAttributeContext:!1},Mf={containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1},Nf=new WeakMap,Pf=new WeakMap,Ff=(e,t,n)=>{Nf.set(e,t),Pf.set(e,n)},If=e=>({containsKatex:e.some(e=>e.containsKatex),isConclusive:e.every(e=>e.isSafe)?e.filter(e=>e.containsKatex).every(e=>e.isConclusive):e.some(e=>e.containsKatex&&e.isConclusive&&!e.isSafe)||e.some(e=>e.containsKatex&&e.isConclusive)&&e.some(e=>!e.containsKatex&&!e.isSafe),isSafe:e.every(e=>e.isSafe),isSafeInAttributeContext:e.every(e=>e.isSafeInAttributeContext)}),Lf=(e,t)=>{let n=E(e);if(!b(n,`ObjectExpression`))return{isKnown:!1,value:null};let r=!0,i=null;for(let e of n.properties){if(!b(e,`Property`)){r=!1,i=null;continue}let n=j(e,{allowComputedString:!0});n===null?(r=!1,i=null):n===t&&(r=!0,i=e.value)}return{isKnown:r,value:i}},Rf=(e,t)=>{let n=E(e);if(b(n,`Identifier`)){let e=M(n,t);return!!(e&&e.kind===`import`&&Vd(e)?.source.value===`react`&&k(e.declarationNode)===`useMemo`)}if(!b(n,`MemberExpression`)||A(n)!==`useMemo`)return!1;let r=M(E(n.object),t);return!!(r&&r.kind===`import`&&Vd(r)?.source.value===`react`&&(b(r.declarationNode,`ImportDefaultSpecifier`)||b(r.declarationNode,`ImportNamespaceSpecifier`)||k(r.declarationNode)===`default`))},zf=(e,t)=>{let n=e=>{let r=E(e);if(b(r,`Identifier`)){let e=M(r,t);return!e||e.kind!==`const`||!e.initializer||e.references.some(e=>e.flag!==`read`)?null:n(e.initializer)}return!b(r,`Literal`)||!(`regex`in r)||!r.regex?null:r.regex},r=e=>{let t=E(e);if(!y(t))return null;if(!b(t.body,`BlockStatement`))return t.body;if(t.body.body.length!==1)return null;let n=t.body.body[0];return n&&b(n,`ReturnStatement`)?n.argument:null},i=e=>{let n=E(e);if(!y(n)||n.params.length!==1)return!1;let i=n.params[0],a=r(n);if(!i||!b(i,`Identifier`)||!a||!b(a,`MemberExpression`)||!a.computed||!b(E(a.property),`Identifier`))return!1;let o=E(a.property);if(t.referenceFor(o)?.resolvedSymbol!==t.symbolFor(i)||!b(E(a.object),`Identifier`))return!1;let s=M(E(a.object),t);if(!s||s.kind!==`const`||!s.initializer||s.references.some(e=>e.flag!==`read`))return!1;let c=Lf(s.initializer,`<`);if(!c.isKnown||!c.value||!b(E(c.value),`Literal`))return!1;let l=E(c.value);return b(l,`Literal`)?typeof l.value==`string`&&!l.value.includes(`<`)&&!l.value.includes(`$`):!1},a=E(e),o=!1;for(;b(a,`CallExpression`);){let e=E(a.callee);if(!b(e,`MemberExpression`))return!1;let t=A(e);if(t!==`replace`&&t!==`replaceAll`)return!1;let r=a.arguments[0],s=a.arguments[1];if(!r||!s||!(b(s,`Literal`)&&typeof s.value==`string`&&!s.value.includes(`<`)&&!s.value.includes(`$`))&&!i(s))return!1;let c=n(r),l=t===`replaceAll`&&b(r,`Literal`)&&r.value===`<`,u=!!c?.flags.includes(`g`)&&(c?.pattern===`<`||/^\[[^\]]*<[^\]]*\]$/.test(c?.pattern??``));(l||u)&&(o=!0),a=E(e.object)}return!o||!b(a,`Identifier`)?!1:t.referenceFor(a)?.resolvedSymbol?.kind===`parameter`},Bf=(e,t)=>{let n=E(e.callee);return b(n,`MemberExpression`)&&A(n)===`sanitize`&&(mf(n.object,`dompurify`,`sanitize`,e,t)||mf(n.object,`isomorphic-dompurify`,`sanitize`,e,t))?Af:b(n,`MemberExpression`)&&A(n)===`escape`&&mf(n.object,`html-escaper`,`escape`,e,t)||hf(n,`html-escaper`,`escape`,e,t)?kf:hf(n,`dompurify`,`sanitize`,e,t)||hf(n,`isomorphic-dompurify`,`sanitize`,e,t)?Af:null},Vf=(e,t)=>{if(!t.isSafe)return null;let n=E(e.callee);if(!b(n,`MemberExpression`))return null;let r=A(n);if((r===`trim`||r===`trimEnd`||r===`trimStart`)&&e.arguments.length===0)return t;if(r!==`replace`&&r!==`replaceAll`)return null;let i=e.arguments[1];return!i||!b(i,`Literal`)||typeof i.value!=`string`||i.value.includes(`<`)?null:{containsKatex:t.containsKatex,isConclusive:t.isConclusive,isSafe:!0,isSafeInAttributeContext:t.isSafeInAttributeContext&&!/[&>"']/.test(i.value)}},Hf=e=>{let t=e.toLowerCase();for(let e of[`script`,`style`,`textarea`,`title`])if(t.lastIndexOf(`<${e}`)>t.lastIndexOf(`</${e}`))return`raw-text`;let n=e.lastIndexOf(`<`);if(n<=e.lastIndexOf(`>`))return`text`;let r=e.slice(n+1),i=null;for(let e=0;e<r.length;e+=1){let t=r[e];(t===`"`||t===`'`)&&r[e-1]!==`\\`&&(i===t?i=null:i===null&&(i=t))}return i===null?`unsafe-tag`:`attribute`},Uf=(e,t,n,r)=>{let i=e.expressions.map(e=>$(e,t,new Set(n),r)),a=``,o=!0;for(let t=0;t<i.length;t+=1){a+=e.quasis[t]?.value.raw??``;let n=Hf(a),r=i[t]??Q;n===`text`?o&&=r.isSafe:n===`attribute`?o&&=r.isSafeInAttributeContext:o=!1}return{containsKatex:i.some(e=>e.containsKatex),isConclusive:o?i.filter(e=>e.containsKatex).every(e=>e.isConclusive):i.some(e=>e.containsKatex&&e.isConclusive&&!e.isSafe)||i.some(e=>e.containsKatex&&e.isConclusive)&&i.some(e=>!e.containsKatex&&!e.isSafe),isSafe:o,isSafeInAttributeContext:!1}},Wf=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(b(e,`BlockStatement`)){let t=e.body.findIndex(e=>e===n);if(t>0&&e.body.slice(0,t).some(e=>I(e)))return!0}if(b(e,`SwitchCase`)){let t=e.consequent.findIndex(e=>e===n);if(t>0&&e.consequent.slice(0,t).some(e=>I(e)))return!0}if(b(e,`IfStatement`)&&b(e.test,`Literal`)){let t=e.alternate,r=e.consequent,i=!!e.test.value;if(!i&&r===n||i&&t===n)return!0}if(b(e,`WhileStatement`)&&e.body===n){let t=e.test;if(b(t,`Literal`)&&!t.value)return!0}if(b(e,`ForStatement`)&&e.body===n){let t=e.test;if(t&&b(t,`Literal`)&&!t.value)return!0}n=e}return!1},Gf=(e,t,n,r=new Map)=>{if(!y(e))return Q;if(!b(e.body,`BlockStatement`))return $(e.body,t,n,r);let i=e.body,a=[];return O(i,e=>{if(e!==i&&y(e))return!1;if(b(e,`ReturnStatement`))return Wf(e,i)||a.push(e.argument?$(e.argument,t,new Set(n),r):kf),!1}),a.length===0?kf:If(a)},Kf=(e,t,n,r,i=new Map)=>{if(!y(e))return Q;let a=[];if(!b(e.body,`BlockStatement`))a.push(e.body);else{let t=e.body;O(t,e=>{if(e!==t&&y(e))return!1;b(e,`ReturnStatement`)&&e.argument&&!Wf(e,t)&&a.push(e.argument)})}return a.length===0?Q:If(a.map(e=>{let a=Lf(e,t);if(a.isKnown&&a.value!==null)return $(a.value,n,new Set(r),i);let o=E(e);return b(o,`CallExpression`)?Yf(o,n,t)??Q:Q}))},qf=(e,t)=>{let n=E(e);if(!b(n,`Identifier`))return null;let r=M(n,t);if(!r||r.references.some(e=>e.flag!==`read`))return null;if(r.kind===`function`&&y(r.declarationNode))return{functionNode:r.declarationNode,symbol:r};if(r.kind!==`const`||!r.initializer)return null;let i=E(r.initializer);return y(i)?{functionNode:i,symbol:r}:null},Jf=(e,t,n,r)=>{let i=new Map;if(!y(e))return i;let a=(e,t)=>e===void 0||b(e,`Identifier`)&&e.name===`undefined`&&t.isGlobalReference(e)||b(e,`UnaryExpression`)&&e.operator===`void`,o=(e,t,n,a)=>a?Df(r,i,()=>Of(e,t,n,new Set)):Of(e,t,n,new Set);for(let[s,c]of e.params.entries()){let e=t.arguments[s],l=b(c,`AssignmentPattern`)&&a(e,n),u=l&&b(c,`AssignmentPattern`)?c.right:e,d=l?r:n,f=l?c:t,p=b(c,`AssignmentPattern`)?c.left:c;if(b(p,`Identifier`)){let e=r.symbolFor(p);if(!e||e.references.some(e=>e.flag!==`read`))continue;i.set(e.id,o(u,f,d,l));continue}if(!(!b(p,`ObjectPattern`)||!u))for(let e of p.properties){if(!b(e,`Property`))continue;let t=j(e,{allowComputedString:!0});if(t===null)continue;let n=Lf(u,t),s=b(e.value,`AssignmentPattern`)?e.value.left:e.value;if(!b(s,`Identifier`))continue;let c=r.symbolFor(s);if(!n.isKnown||!c||c.references.some(e=>e.flag!==`read`))continue;let l=b(e.value,`AssignmentPattern`)&&(n.value===null||a(n.value??void 0,d)),p=l&&b(e.value,`AssignmentPattern`)?e.value.right:n.value??void 0,m=l?r:d,h=l?e:f;i.set(c.id,o(p,h,m,l))}}return i},Yf=(e,t,n)=>{let r=E(e.callee);if(!b(r,`Identifier`))return null;let i=M(r,t);if(!i||i.kind!==`import`)return null;let a=Vd(i),o=k(i.declarationNode),s=Nf.get(t),c=a?.source.value,l=Pf.get(t)??0;if(!s||typeof c!=`string`||!o||l>=2)return null;let u=Yn(s,c,o);if(!u||!y(u.functionNode))return null;let d=Ge(u.programNode);return Ff(d,u.filePath,l+1),Df(d,Jf(u.functionNode,e,t,d),()=>n?Kf(u.functionNode,n,d,new Set):Gf(u.functionNode,d,new Set))},Xf=(e,t,n,r)=>{if(!b(e,`CallExpression`))return Q;let i=E(e.callee);if(b(i,`MemberExpression`)&&A(i)===`get`){let e=E(i.object);if(b(e,`Identifier`)){let i=M(e,t),a=i?.initializer?E(i.initializer):null,o=a&&b(a,`NewExpression`)?E(a.callee):null;if(i?.kind===`const`&&a&&b(a,`NewExpression`)&&b(o,`Identifier`)&&o.name===`Map`&&t.isGlobalReference(o)&&!n.has(i.id)){let e=new Set(n);e.add(i.id);let a=[],o=!1;for(let n of i.references){let i=n.identifier.parent;if(n.flag!==`read`||!i||!b(i,`MemberExpression`)||i.object!==n.identifier){o=!0;break}let s=A(i);if(s===`size`)continue;let c=i.parent;if(!c||!b(c,`CallExpression`)||c.callee!==i){o=!0;break}if(![`get`,`has`,`keys`,`values`,`entries`,`clear`,`delete`].includes(s??``)){if(s!==`set`||!c.arguments[1]){o=!0;break}a.push($(c.arguments[1],t,new Set(e),r))}}if(!o&&a.length>0)return If(a)}}}if(b(i,`MemberExpression`)&&A(i)===`renderToString`&&gf(i.object,e,t)||_f(i,e,t))return{containsKatex:!0,isConclusive:!0,isSafe:Of(e.arguments[1],e,t,new Set).isSafe,isSafeInAttributeContext:!1};let a=Yf(e,t);if(a?.containsKatex)return a;let o=qf(i,t);if(o&&!n.has(o.symbol.id)){let i=new Set(n);i.add(o.symbol.id);let a=e.arguments.map(e=>{let i=E(e);return y(i)?Gf(i,t,new Set(n),r):$(i,t,new Set(n),r)}),s=new Map,c=!1;if(y(o.functionNode))for(let[e,n]of o.functionNode.params.entries()){if(!b(n,`Identifier`))continue;let r=t.symbolFor(n),i=a[e],o=r?.references.every(e=>e.flag===`read`);r&&i&&o&&s.set(r.id,i),i?.containsKatex&&r&&!o&&(c=!0)}let l=Df(t,Jf(o.functionNode,e,t,t),()=>Gf(o.functionNode,t,i,s));return!a.some(e=>e.containsKatex)||l.containsKatex?l:c?jf:Mf}if(vf(i,t))return{containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1};if(b(i,`MemberExpression`)){let a=$(i.object,t,new Set(n),r);if(a.containsKatex)return Vf(e,a)||(a.isConclusive?{containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1}:jf)}let s=Bf(e,t);if(s)return s;if(zf(e,t))return Af;if(Rf(i,t)){let i=e.arguments[0];if(!i)return Q;let a=E(i);if(y(a))return Gf(a,t,new Set(n),r);let o=qf(a,t);if(!o||n.has(o.symbol.id))return Q;let s=new Set(n);return s.add(o.symbol.id),Gf(o.functionNode,t,s,r)}return e.arguments.some(e=>{let i=E(e);return(y(i)?Gf(i,t,new Set(n),r):$(i,t,new Set(n),r)).containsKatex})?jf:Q},Zf=(e,t)=>{let n=Bd(e);if(b(n,`Literal`))return!!n.value;if(b(n,`Identifier`)&&(n.name===`undefined`||n.name===`NaN`)&&t.isGlobalReference(n))return!1;if(b(n,`TemplateLiteral`)){let e=Wa(n);return e===null?null:!!e}if(b(n,`ArrayExpression`)||b(n,`ObjectExpression`)||b(n,`ArrowFunctionExpression`)||b(n,`FunctionExpression`)||b(n,`ClassExpression`)||b(n,`NewExpression`)||b(n,`JSXElement`)||b(n,`JSXFragment`))return!0;if(b(n,`UnaryExpression`)){if(n.operator===`void`)return!1;if(n.operator===`typeof`)return!0;if(n.operator===`!`){let e=Zf(n.argument,t);return e===null?null:!e}}return null},$=(e,t,n,r=new Map)=>{let i=E(e);if(b(i,`Literal`)||b(i,`UnaryExpression`)&&i.operator===`void`)return kf;if(b(i,`Identifier`)){if((i.name===`undefined`||i.name===`NaN`)&&t.isGlobalReference(i))return kf;let e=t.referenceFor(i)?.resolvedSymbol,a=e?r.get(e.id):void 0;if(a)return a;if(!e||n.has(e.id))return Q;let o=new Set(n);if(o.add(e.id),e.kind===`let`||e.kind===`var`){let n=[];e.initializer&&n.push(e.initializer);for(let t of e.references){if(t.flag===`read`)continue;let e=Sa(t.identifier);if(!e)return Q;n.push(e)}return n.length===0?Q:If(n.map(e=>$(e,t,new Set(o),r)))}return e.kind!==`const`||!e.initializer?Q:$(e.initializer,t,o,r)}if(b(i,`CallExpression`))return Xf(i,t,n,r);if(b(i,`MemberExpression`)){let e=A(i),a=E(i.object);if(e&&b(a,`Identifier`)){let i=t.referenceFor(a)?.resolvedSymbol,o=i?.initializer?E(i.initializer):null;if(i?.kind===`const`&&o&&b(o,`CallExpression`)){if(Rf(o.callee,t)){let i=o.arguments[0],a=i?E(i):null;if(a&&y(a)){let i=Kf(a,e,t,new Set(n),r);if(i.containsKatex)return i}}let i=Yf(o,t,e);if(i?.containsKatex)return i}}return Q}if(b(i,`TemplateLiteral`))return Uf(i,t,n,r);if(b(i,`ConditionalExpression`)){let e=Zf(i.test,t);return e===null?If([$(i.consequent,t,new Set(n),r),$(i.alternate,t,new Set(n),r)]):$(e?i.consequent:i.alternate,t,new Set(n),r)}if(b(i,`LogicalExpression`)){let e=i.operator===`??`?null:Zf(i.left,t);if(e!==null)return $(i.operator===`&&`?e?i.right:i.left:e?i.left:i.right,t,new Set(n),r);let a=Gd(i);if(a.length===1)return $(a[0]??i,t,new Set(n),r);let o=[i.left,i.right].map(e=>$(e,t,new Set(n),r));return{...i.operator===`&&`?o[1]??Q:If(a.map(e=>$(e,t,new Set(n),r))),containsKatex:o.some(e=>e.containsKatex)}}if(b(i,`BinaryExpression`)&&i.operator===`+`)return If([$(i.left,t,new Set(n),r),$(i.right,t,new Set(n),r)]);if(b(i,`SequenceExpression`)){let e=i.expressions.at(-1);return e?$(e,t,n,r):Q}return Q},Qf=e=>{let t=null;if(b(e,`JSXAttribute`)&&b(e.name,`JSXIdentifier`)&&e.name.name===`dangerouslySetInnerHTML`&&b(e.value,`JSXExpressionContainer`)&&b(e.value.expression,`ObjectExpression`)&&(t=e.value.expression),b(e,`Property`)&&j(e,{allowComputedString:!0})===`dangerouslySetInnerHTML`&&b(E(e.value),`ObjectExpression`)&&(t=E(e.value)),!b(t,`ObjectExpression`))return null;let n=null;for(let e of t.properties){if(b(e,`SpreadElement`)){n=null;continue}if(!b(e,`Property`)){n=null;continue}let t=j(e,{allowComputedString:!0});if(t===null){n=null;continue}t===`__html`&&(n=e.value)}return n},$f=(e,t)=>{let n=nn({filename:t,sourceText:e});if(n===null)return[];let r=Ge(n);Ff(r,t,0);let i=[];return O(n,e=>{let t=Qf(e);if(t===null)return;let n=$(t,r,new Set);if(!n.containsKatex)return;let a=Y(e),o=zd(e);a<0||o<0||i.push({endIndex:o,proof:n,startIndex:a})}),i},ep=/dangerouslySetInnerHTML|(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\(|\bdocument\.write(?:ln)?\s*\(|\.(?:createContextualFragment|setHTMLUnsafe)\s*\(/,tp=/(?:__html\s*:|(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\(\s*[^,]*,|\bdocument\.write(?:ln)?\s*\(|\.(?:createContextualFragment|setHTMLUnsafe)\s*\()\s*([\s\S]*)/,np=/searchParams|query|params|request|req\.|response\.|await|fetch|props\.|children|(?:user|untrusted|unsafe|raw|comment|message|cms|remote|external)\.|(?:user|untrusted|unsafe|raw|comment|message|cms|remote|external|content|profile|signature|subtitle)\w*(?:html|markup)|(?:html|markup)\w*(?:input|payload)|\b(?:load|read|receive|decode)\w*\s*\(|\bget\w*(?:Html|Markup|Content|Page|Message)\b|\blocation\b|document\.cookie|\breferrer\b|\blocalStorage\b|\bsessionStorage\b|URLSearchParams|window\.name/i,rp=/^(?:"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`[^`$]*`)\s*(?:\/\/[^\n]*)?\s*(?:[;,})\n]|$)/,ip=/^[A-Z][A-Z0-9_]*\s*(?:\/\/[^\n]*)?\s*(?:[;,})\n]|$)/,ap=/^[\w$]+(?:\??\.[\w$]+)*\??\.(?:inner|outer)HTML\b/,op=/\b(?:DOMPurify|sanitize\w*|purify|(?:escape|encode)[A-Za-z]*(?:Html|HTML|Entit\w*)|insane|xss)\b|(?<!un)safe|(?<!un)saniti[sz]/i,sp=/[:=]\s*[^\n;]*\b(?:DOMPurify\b|sanitize\w*\s*\(|purify\w*\s*\()/i,cp=/=\s*[\w$.?[\]]*\.(?:inner|outer)HTML\s*(?:[;,)\n]|$)/,lp=/process\.env/,up=/\b(?:t|i18n|translate|formatMessage|intl)\s*[.(]/,dp=/^(?:[\w$.]+\.)?(?:toHtml|render[A-Za-z]*(?:Html|HTML)|renderToString|renderToStaticMarkup|codeToHtml|codeToHast|highlight[A-Za-z]*)\s*\(/,fp=/\b(?:shiki|prism|hljs|highlightjs|getHighlighter|codeToHtml|codeToHast|refractor|lowlight|starry-night)\b|highlight\.js/i,pp=/[:=]\s*[^\n;]*(?:\b(?:katex|shiki|hljs|prism|mermaid)\b|hast-util-to-html|renderHtmlFromRichText|(?:toHtml|render[A-Za-z]*(?:Html|HTML)|renderToString|renderToStaticMarkup|codeToHtml|codeToHast)\s*\()/i,mp=/\b(?:(?:katex|shiki|hljs|prism|mermaid|highlighter)[\w$]*\.(?:render\w*|highlight\w*|codeTo(?:Html|Hast))|(?:toHtml|render(?:Html|HTML)[A-Za-z]*|render[A-Za-z]*(?:Html|HTML)|renderToString|renderToStaticMarkup|codeToHtml|codeToHast|highlight[A-Za-z]*))\s*\(/i,hp=/^[\w$]+\s*(?:[;,})\n]|$)/,gp=/^[\w$]+\s*(?:\|\||\?\?)\s*(?:"[^"\n]*"|'[^'\n]*'|`[^`$]*`)\s*(?:[;,})\n]|$)/,_p=/^[\w$]+(?:\.[\w$]+|\[[^\]]*\])+\s*(?:[;,})\n]|$)/,vp=/<style\b[^<>]*$/,yp=/(?:^|\/)emails(?:\/|$)|email[-_.]templates?(?:\/|$)|RawHtml|[A-Za-z]*[Ee]mail[A-Za-z]*\.(?:t|j)sx?/i,bp=/(?:^|\/)\.[\w-]+\//,xp=/(?<!un)saniti[sz]e?d?[\w-]*\.[cm]?[jt]sx?$/i,Sp=/(?:^|[^\w$.])([\w$]+(?:\.[\w$]+)*)(?:(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\()/,Cp=/\b(?:appendChild|append|prepend|before|after|replaceWith|replaceChild|replaceChildren|insertBefore|insertAdjacentElement)\s*\(/,wp=5e3,Tp=e=>{if(!e.startsWith("`"))return null;let t=e.indexOf("`",1);if(t<0||t>wp)return null;let n=e.slice(1,t).match(/\$\{[^}]*\}/g);return n===null?``:n.join(` `)},Ep=(e,t,n)=>{let r=Np(e,t,n);return r===null?null:n.slice(r.initializerStartIndex,r.initializerStartIndex+wp)},Dp=e=>{if(!/^["']/.test(e))return!1;let t=e.replace(/"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'/g,``),n=t.search(/[;,})\]]/),r=n>=0?t.slice(0,n):t;return/^[\s+]*$/.test(r)},Op=(e,t)=>{let n=t.includes(`createElement`),r=t.includes(`createHTMLDocument`);if(!n&&!r)return!1;let i=q(e),a=q(e.split(`.`)[0]??e);if(RegExp(`\\b${a}\\s*=\\s*[^\\n;]*(?:getElementById|querySelector|getElementsBy|\\.current\\b|document\\.(?:body|head|documentElement))`).test(t))return!1;if(n&&(RegExp(`${i}\\s*=\\s*document\\.createElement\\(\\s*["'\`]template["'\`]`).test(t)||RegExp(`${a}\\s*=\\s*[^\\n;]*\\bcreateElement\\(\\s*["'\`](?:style|textarea)["'\`]`).test(t))||r&&RegExp(`${a}\\s*=\\s*[^\\n;]*\\bcreateHTMLDocument\\s*\\(`).test(t))return!0;if(!n||!RegExp(`${a}\\s*=\\s*[^\\n;]*\\bcreateElement\\s*\\(`).test(t))return!1;let o=RegExp(`${Cp.source}[^)]*\\b${a}\\b`),s=RegExp(`\\breturn\\b[^\\n]*\\b${a}\\b(?!\\s*\\.\\s*(?:textContent|innerText|innerHTML|outerHTML))`);return o.test(t)||s.test(t)?!1:RegExp(`\\b${a}\\.(?:textContent|innerText|querySelector|querySelectorAll|children|childNodes)\\b`).test(t)},kp=e=>{let t=[],n=``,r=0,i=null;for(let a=0;a<e.length;a+=1){let o=e[a];if(i!==null){n+=o,o===i&&e[a-1]!==`\\`&&(i=null);continue}if(o===`"`||o===`'`||o==="`"){i=o,n+=o;continue}if(o===`(`||o===`[`||o===`{`?r+=1:(o===`)`||o===`]`||o===`}`)&&--r,o===`+`&&r===0&&e[a-1]!==`+`&&e[a+1]!==`+`){t.push(n),n=``;continue}n+=o}return t.push(n),t},Ap=e=>{let t=e.replace(/[;}]\s*$/,``).trim();if(!t.includes(`+`))return!1;let n=[];for(let e of kp(t)){let t=e.trim();t.length>0&&n.push(t)}return n.length<2?!1:n.every(e=>{let t=e.replace(/\(\s*([\w$]+(?:\??\.[\w$]+)*)\s+as\s+[^)]*\)/g,`$1`);return ap.test(t)?!np.test(t.replace(ap,``)):!1})},jp=(e,t)=>{let n=0,r=null;for(let i=t;i<e.length;i+=1){let t=e[i];if(r!==null){t===r&&e[i-1]!==`\\`&&(r=null);continue}if(t===`"`||t===`'`||t==="`"){r=t;continue}if(t===`{`&&(n+=1),t===`}`&&(--n,n===0))return i}return e.length},Mp=(e,t)=>{let n=[],r=null,i=!1,a=!1;for(let o=0;o<t;o+=1){let t=e[o],s=e[o+1];if(i){t===`
10
+ `&&(i=!1);continue}if(a){t===`*`&&s===`/`&&(a=!1,o+=1);continue}if(r!==null){t===r&&e[o-1]!==`\\`&&(r=null);continue}if(t===`/`&&s===`/`){i=!0,o+=1;continue}if(t===`/`&&s===`*`){a=!0,o+=1;continue}if(t===`"`||t===`'`||t==="`"){r=t;continue}t===`{`&&n.push(o),t===`}`&&n.pop()}let o=n.at(-1);return o===void 0?e.length:jp(e,o)},Np=(e,t,n)=>{let r=RegExp(`(const|let|var)\\s+${q(e)}\\s*(?::[^=\\n]*)?=\\s*([^;\\n]+)`,`g`),i=null,a=-1;for(let e of n.matchAll(r)){let r=e.index;if(r===void 0||r>=t||r<=a||Mp(n,r)<t)continue;a=r;let o=e[2];o!==void 0&&(i={declarationIndex:r,initializer:o,initializerStartIndex:r+e[0].length-o.length,isImmutable:e[1]===`const`})}return i},Pp=(e,t,n,r)=>{if(t.isImmutable)return!0;let i=r.slice(t.initializerStartIndex+t.initializer.length,n);return!RegExp(`(?:^|[^\\w$.])${q(e)}\\s*=(?!=)`).test(i)},Fp=(e,t,n)=>{if(!/highlight/i.test(e))return!1;let r=e.match(/^([\w$]+)/)?.[1];if(r===void 0)return!1;let i=Np(r,n,t);return i===null?/highlighted/i.test(e)||fp.test(t):Pp(r,i,n,t)&&mp.test(i.initializer)},Ip=(e,t,n,r=new Set)=>{let i=e.trim(),a=kp(i);if(a.length>1)return a.every(e=>Ip(e,t,n,r));let o=[...i.matchAll(/\$\{([^}]*)\}/g)].flatMap(e=>e[1]===void 0?[]:[e[1]]);if(o.length>1)return o.every(e=>Ip(e,t,n,r));let s=i.match(/^([\w$]+)(?:(?:\??\.[\w$]+)|(?:\[\s*(?:"[^"\n]*"|'[^'\n]*'|\d+)\s*\]))*$/)?.[1];if(s&&!r.has(s)){let e=Np(s,n,t);if(e&&Pp(s,e,n,t)){let n=new Set(r);return n.add(s),Ip(e.initializer,t,e.initializerStartIndex,n)}}return!!(rp.test(`${i};`)||ip.test(`${i};`)||op.test(i)||lp.test(i)||up.test(i)||dp.test(i)||Fp(i,t,n))},Lp=(e,t,n,r,i=new Set)=>{let a=e.trim().match(/^([\w$]+)$/)?.[1];if(!a)return!1;if(a===t)return!0;if(i.has(a))return!1;let o=Np(a,n,r);if(!o?.isImmutable)return!1;let s=new Set(i);return s.add(a),Lp(o.initializer,t,o.initializerStartIndex,r,s)},Rp=(e,t,n)=>{let r=n.slice(Math.max(0,t-wp),t),i=q(e);return RegExp(`(?:function\\s+[\\w$]+|(?:const|let|var)\\s+[\\w$]+\\s*=)\\s*\\(\\s*\\{[^}]*\\b${i}\\b[^}]*\\}`).test(r)},zp=(e,t,n)=>{let r=[/function\s+([\w$]+)\s*\(([^)]*)\)\s*\{/g,/(?:const|let|var)\s+([\w$]+)\s*=\s*(?:async\s*)?\(([^)]*)\)\s*=>\s*\{/g],i=null,a=-1;for(let o of r)for(let r of n.matchAll(o)){let o=r.index;if(o===void 0||o>=t||o<a)continue;let s=jp(n,o+r[0].lastIndexOf(`{`));if(s<t)continue;let c=(r[2]??``).split(`,`).findIndex(t=>t.trim().match(/^(?:\.\.\.)?([\w$]+)/)?.[1]===e);if(c<0)continue;a=o;let l=r[1]??``;i={bodyEndIndex:s,declarationNameIndex:o+r[0].indexOf(l),functionName:l,parameterIndex:c}}return i},Bp=e=>{let t=[],n=0,r=0,i=null;for(let a=0;a<e.length;a+=1){let o=e[a];if(i!==null){o===i&&e[a-1]!==`\\`&&(i=null);continue}if(o===`"`||o===`'`||o==="`"){i=o;continue}(o===`(`||o===`[`||o===`{`)&&(r+=1),(o===`)`||o===`]`||o===`}`)&&--r,o===`,`&&r===0&&(t.push(e.slice(n,a).trim()),n=a+1)}return t.push(e.slice(n).trim()),t},Vp=(e,t,n,r=new Set)=>{let i=e.trim().match(/^([\w$]+)$/)?.[1];if(i===void 0||r.has(i))return!1;if(zp(i,t,n)!==null)return!0;let a=Np(i,t,n);if(!a||!Pp(i,a,t,n))return!1;let o=new Set(r);return o.add(i),Vp(a.initializer,a.initializerStartIndex,n,o)},Hp=(e,t,n,r,i)=>{let a=e.trim();if(Ip(a,t,n))return!1;let o=a.match(/^([\w$]+)(?:\.|\s*(?:(?:\|\||\?\?)|[;,})\n]|$))/)?.[1];if(o===void 0)return np.test(a);if(Rp(o,n,t))return!0;if(r.has(o))return!1;r.add(o);let s=Np(o,n,t),c=zp(o,n,t);if(s!==null&&(c===null||s.declarationIndex>c.declarationNameIndex))return Pp(o,s,n,t)&&Ip(s.initializer,t,s.initializerStartIndex)?!1:!Pp(o,s,n,t)||Hp(s.initializer,t,s.initializerStartIndex,r,i)?!0:Vp(s.initializer,s.initializerStartIndex,t)?!1:np.test(a);if(c!==null&&c.functionName.length>0){let e=RegExp(`\\b${q(c.functionName)}\\s*\\(`,`g`),n=!1;for(let a of t.matchAll(e)){if(a.index===c.declarationNameIndex||i.has(a.index))continue;let e=a.index+a[0].lastIndexOf(`(`),s=Rd(t,e);if(s<0)continue;let l=Bp(t.slice(e+1,s))[c.parameterIndex];if(l===void 0||a.index>=c.declarationNameIndex&&a.index<=c.bodyEndIndex&&Lp(l,o,a.index,t))continue;n=!0;let u=new Set(r);u.delete(o);let d=new Set(i);if(d.add(a.index),Hp(l,t,a.index,u,d))return!0}if(n)return!1;let s=t.slice(Math.max(0,c.declarationNameIndex-48),c.declarationNameIndex);return/\bexport\s+(?:(?:default\s+)?(?:async\s+)?function|const|let|var)\s+$/.test(s)?!0:np.test(a)}return np.test(a)},Up=U({id:`dangerous-html-sink`,title:`HTML injection sink with dynamic content`,severity:`warn`,recommendation:`Prefer rendering structured React nodes. If HTML is required, sanitize with a well-reviewed sanitizer and keep the trust boundary close to the sink.`,scan:e=>{if(e.isGeneratedBundle||!G(e.relativePath)||yp.test(e.relativePath)||bp.test(e.relativePath)||xp.test(e.relativePath)||!ep.test(e.content))return[];let t=$f(e.content,e.absolutePath),n=[],r=e.content.split(`
11
+ `);for(let i=0;i<r.length;i+=1){let a=r[i]??``;if(!ep.test(a))continue;let o=a.slice(0,a.search(ep)).replace(/"[^"]*"|'[^']*'|`[^`]*`/g,``);if(/(?:^|[^:])\/\//.test(o)||/^\s*[/*]/.test(a))continue;let s=r.slice(i,i+1+4).join(`
12
+ `),c=tp.exec(s);if(c===null)continue;let l=(c[1]??``).trimStart(),u=l.slice(0,300),d=u.search(/[;}]/),f=d>=0?u.slice(0,d+1):u,p=r.slice(0,i).join(`
13
+ `).length+ +(i>0)+a.search(ep),m=t.find(e=>p>=e.startIndex&&p<e.endIndex)?.proof;if(m?.isConclusive&&m.isSafe)continue;let h=m?.isConclusive===!0;if(rp.test(f)||ip.test(f))continue;if(ap.test(f)&&!f.includes(`+`)){let e=f.replace(ap,``);if(!np.test(e))continue}if(Ap(f))continue;let ee=tp.exec(r.slice(i,i+1+60).join(`
14
+ `))?.[1]?.trimStart(),te=Tp(ee??l),g=hp.test(f)||_p.test(f)||gp.test(f)?f.match(/^[\w$]+/)?.[0]:void 0;if(te===null&&g!==void 0&&hp.test(f)&&zp(g,p,e.content)===null){let t=Ep(g,p,e.content);if(t!==null){if(Dp(t))continue;te=Tp(t)}}if(te===``)continue;let ne=te??f,_=kp(ne).length>1||(te?.match(/\$\{/g)?.length??0)>1;if(!h&&!_&&op.test(ne)||!_&&lp.test(ne)||!_&&up.test(ne)||!h&&!Hp(ne,e.content,p,new Set,new Set)||!h&&dp.test(f)||!h&&Fp(f,e.content,p))continue;if(g!==void 0){let t=q(g),n=Np(g,p,e.content),r=n?.initializer;if(!(r!==void 0&&(kp(r).length>1||(r.match(/\$\{/g)?.length??0)>1))){let i=RegExp(`\\b${t}\\b\\s*${pp.source}`,`i`);if(!h&&(r===void 0?i.test(e.content):n!==null&&Pp(g,n,p,e.content)&&mp.test(r)))continue;let a=RegExp(`\\b${t}\\b\\s*${sp.source}`,`i`);if(!h&&(r===void 0?a.test(e.content):n!==null&&Pp(g,n,p,e.content)&&sp.test(`=${r}`)))continue}if(RegExp(`\\b${t}\\b\\s*${cp.source}`).test(e.content)||RegExp(`highlight[\\w$]*\\s*\\.map\\(\\s*(?:async\\s+)?\\(?\\s*${t}\\b`,`i`).test(e.content)&&fp.test(e.content))continue}if(_p.test(f)){let t=f.match(/\.([\w$]+)\s*(?:[;,})\n]|$)/)?.[1];if(t!==void 0&&RegExp(`\\b${q(t)}\\s*:\\s*${up.source}`).test(e.content))continue}let re=Sp.exec(a),ie=re?.[1]??re?.[2];if(ie!==void 0&&Op(ie,e.content))continue;let ae=r.slice(Math.max(0,i-5),i+1).join(`
15
+ `).slice(0,-a.length+a.search(ep));vp.test(ae)||n.push({message:`HTML is injected from a dynamic-looking source, which can become XSS if the value is user-controlled or unsanitized.`,line:i+1,column:a.search(/\S/)+1})}return n}}),Wp=e=>!(!G(e)||Cl.test(e)||Tl.test(e)),Gp=/firebase|firestore|supabase|\b(?:setDoc|addDoc)\s*\(/i,Kp=U({id:`firebase-client-owned-authz-field`,title:`Client writes authorization field`,severity:`error`,recommendation:`Derive authority fields on the server or enforce them in Firebase/Supabase rules; never trust client-provided owner, org, or role values.`,scan:K({shouldScan:e=>Wp(e.relativePath)&&(Gp.test(e.content)||Gp.test(e.relativePath)),pattern:/(?:\b(?:setDoc|updateDoc|addDoc)\s*\(|(?:\b(?:firebase|firestore|getFirestore)\b|\bcollection\s*\(|\.collection\s*\()[\s\S]{0,500}\.(?:set|update|add)\s*\()(?:[^;'"`]|'[^'\n]*'|"[^"\n]*"|`[^`]*`){0,700}\b(?:ownerId|ownerID|creatorId|creatorID|providerId|providerID|orgId|orgID|tenantId|tenantID|workspaceId|workspaceID|ghostOrg|role|roles|isAdmin)\b/i,message:`Client code writes an ownership, tenant, or role field that should be server-owned and immutable.`})}),qp=U({id:`firebase-permissive-rules`,title:`Permissive Firebase security rule`,severity:`error`,recommendation:"Bind every read/write to `request.auth.uid`, immutable ownership, and tenant membership instead of treating sign-in as authorization.",scan:K({shouldScan:e=>Ul(e.relativePath),pattern:/allow\s+(?:read|write|create|update|delete|list|get|read,\s*write)\s*:\s*if\s+(?:true|request\.auth\s*!=\s*null)\s*;?/i,message:`Firebase rules grant broad access to everyone or to any signed-in user, which is the Chattr/Firewreck failure mode.`})}),Jp=U({id:`firebase-query-filter-as-auth`,defaultEnabled:!1,title:`Firestore query filter used as authorization`,severity:`warn`,recommendation:"Make sure Firestore rules compare the requested document against `request.auth.uid` and trusted membership data.",scan:K({shouldScan:e=>Wp(e.relativePath),pattern:/\.where\s*\(\s*["'](?:uid|userId|userID|ownerId|ownerID|orgId|orgID|tenantId|tenantID|role)["']\s*,\s*["']==["']/i,message:`Firestore query code filters by an auth-shaped field; filtering is not authorization unless rules enforce the same boundary.`})}),Yp=/api\.github\.com|github\.com|gitlab\.com|bitbucket\.org/gi,Xp=/\$\{([^}]*)\}/g,Zp=/\b(?:params|searchParams|query|req|request|input|payload)\s*[.[]|\buntrusted|\bdecodeURI\w*/,Qp=/encodeURIComponent\s*\(/,$p=/^\s*[\w$]+\.toString\(\)\s*$/,em=U({id:`git-provider-url-injection-risk`,title:`Git provider URL built from interpolation`,severity:`warn`,recommendation:`Validate owner, repo, org, and branch identifiers against strict slugs and build URLs with URL/path encoders instead of raw interpolation.`,scan:e=>{if(!G(e.relativePath))return[];let t=[];for(let n of e.content.matchAll(Yp)){let r=e.content.slice(n.index,n.index+200),i=r.indexOf("`"),a=i>=0?r.slice(0,i):r;if(!Array.from(a.matchAll(Xp)).some(e=>{let t=e[1]??``;return Zp.test(t)&&!Qp.test(t)&&!$p.test(t)}))continue;let o=W(e.content,n.index);t.push({message:`GitHub/GitLab/Bitbucket URL construction interpolates path components that may be attacker-controlled.`,line:o.line,column:o.column});break}return t}}),tm=/child_process|childProcess|execa|subprocess|Deno\.run/,nm=/(?:\b(?:eval|new\s+Function|vm\.runIn\w*)|(?<![.\w$])(?:exec(?:File)?(?:Sync)?|spawn(?:Sync)?)|\b(?:child_process|childProcess|cp)\.(?:exec|spawn)\w*)\s*\([^;]{0,200}(?<!["'])\b(?:exif|metadata|manifest|preset|plugin|upload|drop(?:ped|s)?\b|archive|zip|unzip|untar)(?!\w*["'])/,rm=/(?:\b(?:eval|new\s+Function|vm\.runIn\w*)|\b(?:child_process|childProcess|cp)\.(?:exec|spawn)\w*)\s*\([^;]{0,200}(?<!["'])\b(?:exif|metadata|manifest|preset|plugin|upload|drop(?:ped|s)?\b|archive|zip|unzip|untar)(?!\w*["'])/,im=`Imported metadata, uploads, or plugin manifests appear to reach code execution.`,am=K({shouldScan:()=>!0,pattern:nm,ignoreStringLiterals:!0,message:im}),om=K({shouldScan:()=>!0,pattern:rm,ignoreStringLiterals:!0,message:im}),sm=U({id:`import-metadata-execution-risk`,title:`Imported metadata reaches code execution`,severity:`error`,recommendation:`Parse imported metadata as data with strict schemas; do not evaluate EXIF, manifests, presets, dropped files, or archives.`,scan:e=>G(e.relativePath)?tm.test(e.content)?am(e):om(e):[]}),cm=/createHash\s*\(\s*["'](?:md5|sha1)["']|\bmd5\s*\(/gi,lm=/\b(?:password|token|secret|signature|signing|auth|credential|session|cookie|csrf|api.?key)\b/i,um=/(?<!cipher\.)\bcreate(?:Cipher|Decipher)\s*\(/,dm=/\bcreate(?:Cipher|Decipher)iv\s*\(\s*["'](?:des|des3|des-?ede3?|rc4|rc2|bf|blowfish)\b/i,fm=/\b(?:DES|RC4|Blowfish)\b/,pm=/\b(?:cipher|decipher|encrypt|decrypt|crypto)\b/i,mm=/[A-Za-z_$][\w$.]{0,100}signature[\w$]*(?:\([^)]*\))?\s*(?:===?|!==?)\s*[A-Za-z_$][\w$.]*(?:\([^)]*\))?|[A-Za-z_$][\w$.]{0,100}(?:\([^)]*\))?\s*(?:===?|!==?)\s*[A-Za-z_$][\w$.]{0,100}signature[\w$]*(?:\([^)]*\))?/i,hm=/(?:===?|!==?)\s*[A-Z](?:[a-z]|[A-Z0-9_]*\b(?!\s*[.(]))|^[A-Z](?:[a-z]|[A-Z0-9_]*\b(?!\s*[.(]))[\w$.]*(?:\([^)]*\))?\s*(?:===?|!==?)/,gm=/signature(?:Method|Type|Status|Algorithm|Kind|Mode|Version)\b/i,_m=/(?:===?|!==?)\s*(?:true|false|null|undefined)\b/,vm=/\.(?:length|size|byteLength)\s*(?:===?|!==?)|\.(?:length|size|byteLength)\s*$/,ym=/\bcrypto\b|createH(?:mac|ash)|createSign|createVerify|\bsubtle\b|\bhmac\b|\bdigest\b|\bsha-?(?:1|256|384|512)\b|\bmd5\b|\bwebhook|x-(?:hub-)?signature/i,bm=/\.[cm]?[jt]sx$/i,xm=/timingSafeEqual|timing.?safe/i,Sm=/gravatar|digest[-_ ]?auth|oauth[-_ ]?1|pkcs#?12|smime|\b_id\b|\betag\b|checksum|cache[-_ ]?key|fingerprint/i,Cm=/token|secret|password|nonce|salt|csrf|credential|otp/i,wm=/(?:focus|render|refresh|remount|redraw|animation|layout|cache|update)[-_]?nonce/i,Tm=/Math\.random\s*\(/g,Em=/createHash|md5|cipher|encrypt|decrypt|crypto|signature|Math\.random/i,Dm=(e,t,n,r)=>{for(let i of e.matchAll(t)){let t=e.slice(Math.max(0,i.index-250),i.index+250);if(n.test(t)&&!r?.test(t))return i.index}return-1},Om=(e,t,n,r)=>{for(let i of e.matchAll(t)){let t=e.lastIndexOf(`
16
+ `,i.index)+1,a=e.indexOf(`
17
+ `,i.index),o=a<0?e.length:a,s=e.slice(t,o);if(!r.test(s)&&n.test(s))return i.index}return-1},km=U({id:`insecure-crypto-risk`,title:`Weak cryptography in security context`,severity:`warn`,recommendation:"Use modern primitives, `crypto.randomBytes` / Web Crypto randomness, and timing-safe comparisons for signatures, digests, tokens, and auth material.",scan:e=>{if(!G(e.relativePath)||Dl.test(e.relativePath)||Sm.test(e.relativePath)||!Em.test(e.content))return[];let t=su(e),n=Dm(t,cm,lm,Sm);if(n<0&&(n=t.search(dm)),n<0&&(n=t.search(um)),n<0&&pm.test(t)&&(n=t.search(fm)),n<0&&!xm.test(t)&&!bm.test(e.relativePath)&&ym.test(t)){let e=mm.exec(t);e!==null&&!hm.test(e[0])&&!gm.test(e[0])&&!_m.test(e[0])&&!vm.test(e[0])&&(n=e.index)}if(n<0&&(n=Om(t,Tm,Cm,wm)),n<0)return[];let r=W(t,n);return[{message:`Code uses weak hashes, deprecated ciphers, timing-unsafe comparisons, or Math.random in a security-shaped context.`,line:r.line,column:r.column}]}}),Am=`(?<![A-Za-z0-9])(?:session|sess|sid|connect\\.sid|auth|jwt|access[_-]?token|refresh[_-]?token|id[_-]?token)(?![A-Za-z0-9])`,jm=`[\`"'][^\`"']*?${Am}[^\`"']*[\`"']`,Mm=RegExp(`(?:\\.cookies\\.set|cookies\\(\\s*\\)\\.set|\\.cookie)\\s*\\(\\s*${jm}`,`gi`),Nm=/httpOnly\s*:\s*false\b/i,Pm=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`/g,Fm=e=>{let t=e.split(``),n=0,r=null;for(;n<e.length;){let i=e[n];if(r!==null){if(i===`\\`){n+=2;continue}i===r?r=null:i!==`
18
+ `&&(t[n]=` `),n+=1;continue}(i===`"`||i===`'`||i==="`")&&(r=i),n+=1}return t.join(``)},Im=/cookie\s*:\s*\{/gi,Lm=RegExp(`document\\.cookie\\s*=\\s*[\`"'][^\`"'=;]*?${Am}[^\`"'=;]*=`,`gi`),Rm=e=>{if(e.trim().length===0)return 0;let t=0,n=null,r=1;for(let i=0;i<e.length;i+=1){let a=e[i];if(n!==null){a===`\\`?i+=1:a===n&&(n=null);continue}a===`"`||a===`'`||a==="`"?n=a:a===`(`||a===`[`||a===`{`?t+=1:a===`)`||a===`]`||a===`}`?--t:a===`,`&&t===0&&(r+=1)}return r},zm=(e,t,n,r,i)=>{t.lastIndex=0;for(let a=t.exec(e);a!==null;a=t.exec(e)){if(!r(a.index,a[0]))continue;let t=W(e,a.index);i.push({message:n,line:t.line,column:t.column})}},Bm=U({id:`insecure-session-cookie`,title:`Auth cookie missing HttpOnly protection`,severity:`warn`,recommendation:"Set auth/session cookies server-side with `httpOnly: true`, `secure: true`, and `sameSite`. Cookies set via `document.cookie` or with `httpOnly: false` are readable by any XSS payload and can be stolen.",scan:e=>{if(!G(e.relativePath))return[];let t=su(e);if(!/cookie/i.test(t))return[];let n=[],r=`An auth/session cookie is exposed to JavaScript (set via document.cookie, with httpOnly: false, or without cookie options), letting an XSS payload steal it.`;Mm.lastIndex=0;for(let e=Mm.exec(t);e!==null;e=Mm.exec(t)){let i=e.index+e[0].lastIndexOf(`(`),a=Rd(t,i);if(a<0)continue;let o=t.slice(i+1,a),s=Rm(o)<3,c=o.replace(Pm,``);if(!s&&!Nm.test(c))continue;let l=W(t,e.index);n.push({message:r,line:l.line,column:l.column})}let i=Fm(t);Im.lastIndex=0;for(let e=Im.exec(i);e!==null;e=Im.exec(i)){let t=e.index+e[0].length-1,a=Rd(i,t),o=a>=0?i.slice(t,a):i.slice(t,t+400);if(!Nm.test(o))continue;let s=W(i,e.index);n.push({message:r,line:s.line,column:s.column})}return zm(t,Lm,r,()=>!0,n),n}}),Vm=/\b(?:alg|algorithms?)\s*:\s*\[?\s*["'`]none["'`]/gi,Hm=(e,t)=>{let n=null,r=[];for(let i=0;i<t;i+=1){let t=e[i];if(n==="`"){t===`\\`?i+=1:t==="`"?n=null:t===`$`&&e[i+1]===`{`&&(r.push(0),n=null,i+=1);continue}if(n!==null){t===`\\`?i+=1:t===n&&(n=null);continue}if(t===`"`||t===`'`||t==="`")n=t;else if(r.length>0){let e=r.length-1;t===`{`?r[e]+=1:t===`}`&&(r[e]===0?(r.pop(),n="`"):--r[e])}}return n!==null},Um=U({id:`jwt-insecure-verification`,title:`JWT verified with the 'none' algorithm`,severity:`error`,recommendation:"Never accept the `none` algorithm; it disables signature verification and lets any forged token through. Pin the real algorithm(s) explicitly (`jwt.verify(token, key, { algorithms: ['RS256'] })`).",scan:e=>{if(!G(e.relativePath))return[];let t=su(e);if(!/\bjwt\b|jsonwebtoken|\bjose\b/i.test(t))return[];let n=[];Vm.lastIndex=0;for(let e=Vm.exec(t);e!==null;e=Vm.exec(t)){if(Hm(t,e.index))continue;let r=W(t,e.index);n.push({message:`JWT is configured with the 'none' algorithm, which disables signature verification, so any forged token is accepted.`,line:r.line,column:r.column})}return n}}),Wm=/PRIVATE KEY|SSH_PRIVATE_KEY|GPG_PRIVATE_KEY|DEPLOY_KEY|SIGNING_KEY/i,Gm=U({id:`key-lifecycle-risk`,title:`Long-lived key material in repository`,severity:`error`,committedFilesOnly:!0,recommendation:`Remove private keys from source, rotate exposed credentials, prefer short-lived deploy credentials, and document revocation/expiry for release keys.`,scan:K({shouldScan:e=>!wl.test(e.relativePath)&&!Ol.test(e.relativePath)&&Wm.test(e.content),pattern:/(?<!(?:placeholder|example|sample|dummy|fake)[\s\S]{0,40})-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----(?:\s|\\r|\\n)*[A-Za-z0-9+/=][A-Za-z0-9+/=\s]{38,}(?![^-]{0,160}\.\.\.)|\b(?:SSH_PRIVATE_KEY|GPG_PRIVATE_KEY|DEPLOY_KEY|SIGNING_KEY)\b\s*[:=]\s*["'][^"'\n]{16,}["']/i,message:`Private or long-lived release key material appears in the repository.`})}),Km=U({id:`local-rpc-native-bridge-risk`,title:`Weak localhost native bridge boundary`,severity:`warn`,recommendation:`Use exact origin allowlists after URL parsing, per-request nonces, narrow methods, and never expose install/update commands to arbitrary web pages.`,scan:K({shouldScan:e=>G(e.relativePath),pattern:/\b(?:Access-Control-Allow-Origin|websocket|WebSocket|(?:127\.0\.0\.1|localhost)(?=[\s\S]{0,700}\b(?:UpdateApp|InstallApp)\b)|(?:127\.0\.0\.1|localhost)[\s\S]{0,350}\b(?:onmessage|message|request|req)\b)\b[\s\S]{0,700}(?:\b(?:UpdateApp|InstallApp|child_process)\b|(?<![.\w$])(?:exec(?:File)?(?:Sync)?|spawn(?:Sync)?)\s*\()/i,message:`Code appears to bridge browser code to localhost/native capabilities with weak origin or update/install checks.`})}),qm=/\bfrom\s+["']@modelcontextprotocol\/sdk[^"']*["']|\bMcpServer\b|\bMcpAgent\b/,Jm=/@modelcontextprotocol\/sdk|\bMcpServer\b|\bMcpAgent\b/,Ym=/\bserver\.\s*tool\s*\(|\bregisterTool\s*\(|\bsetRequestHandler\s*\(\s*CallToolRequestSchema/,Xm=/\b(?:tool|registerTool|setRequestHandler)\b/,Zm=U({id:`mcp-tool-capability-risk`,defaultEnabled:!1,title:`MCP tool exposes dangerous capability`,severity:`warn`,recommendation:`MCP tool calls run with the connecting client's authority. Validate inputs, enforce per-tool authorization, and avoid raw filesystem/shell/network access where possible.`,scan:K({shouldScan:e=>G(e.relativePath)&&Jm.test(e.content)&&Xm.test(e.content)&&Ml.test(e.content),pattern:Ym,requireAll:[qm,Ml],ignoreStringLiterals:!0,message:`An MCP tool/resource/prompt handler appears to expose file, shell, network, or code-execution capability.`})}),Qm=U({id:`mdx-ssr-execution-risk`,title:`Server-rendered MDX can execute code`,severity:`warn`,recommendation:`Use a constrained compiler for untrusted content, disable expressions/raw HTML, sandbox renderers, and avoid caching attacker-controlled output across tenants.`,scan:K({shouldScan:e=>G(e.relativePath),pattern:/(?:@mdx-js\/mdx|next-mdx-remote|\b(?:MDXRemote|compileMDX|evaluateMdx)\b)[\s\S]{0,700}\b(?:repo\b|customer|tenant|user[-_]?(?:content|markdown|mdx|input|provided|generated|submitted)|untrusted|searchParams|req\.|request\.|fetch\s*\(|prisma\.|db\.|database|rehypeRaw|allowDangerousHtml)/i,message:`MDX/markdown rendering code may evaluate user or repository content during SSR or static generation.`})}),$m=U({id:`nosql-injection-risk`,title:`NoSQL query accepts operator-shaped input`,severity:`warn`,recommendation:"Coerce scalar fields before querying, reject operator keys from client input, and avoid `$where` or request-derived regexes.",scan:K({shouldScan:e=>Rl(e.relativePath,Sl),pattern:/\$where\s*['"]?\s*:\s*(?:f?['"`][^'"`]{0,200}\$\{|function|f['"])|\.find\s*\(\s*JSON\.parse\s*\(\s*(?:req|request)\.|\.aggregate\s*\(\s*\[?\s*\{[^}]{0,400}\$where|\bnew\s+RegExp\s*\(\s*(?:req|request)\.|\$regex['"]?\s*:\s*(?:req|request)\./i,message:"Code appears to pass raw JSON, regex, or `$where` style input into a NoSQL query."})}),eh=[...wu.filter(e=>!e.test(`service_role`)),Tu],th=U({id:`package-metadata-secret`,title:`Secret-like package metadata`,severity:`warn`,recommendation:`Keep secrets out of package metadata and generated reports; they are often published to registries, logs, or browser artifacts.`,scan:e=>{if(!e.relativePath.endsWith(`package.json`))return[];let t=Qu(e.content)??eh.find(t=>t.test(e.content));if(t===void 0)return[];let n=_l(e.content,t);return[{message:`Package metadata contains secret-like values or public env secret names.`,line:n.line,column:n.column}]}}),nh=U({id:`path-traversal-risk`,title:`Filesystem path uses caller input`,severity:`warn`,recommendation:`Resolve paths against a fixed base directory, reject traversal after normalization, and map user-visible identifiers to server-owned paths.`,scan:K({shouldScan:e=>G(e.relativePath)&&!kd(e.relativePath),pattern:/\b(?:readFile|readFileSync|writeFile|writeFileSync)\s*\(\s*(?:req\.|request\.|params\.|query\.|body\.|parsed\.|`[^`]*(?<![-./\w$'"`])(?:req\.|request\.|params\.|query\.|body\.))|\bpath\.(?:join|resolve)\s*\([^)]*(?<![-./\w$'"`])(?<!basename\(\s{0,4})(?:req\.|request\.|params\.|query\.|body\.|parsed\.)/,message:`Filesystem access appears to use request, query, params, or body data as part of the path.`})}),rh=/\b(?:repoUrl|updateUrl|UpdateApp|InstallApp|auto.?updater?|installer|curl(?!\s+(?:-T\b|--upload-file\b))|wget)\b[\s\S]{0,250}(?:\.(?:zip|exe|dmg|appimage|msi|deb|rpm)\b|\.tar\.gz\b|\|\s*(?:bash|sh)\b)/i,ih=/\b(?:curl|wget)\b(?=(?:[^\r\n]|\\\r?\n)*https?:\/\/)(?:[^\r\n]|\\\r?\n)*?\|\s*(?:bash|sh)\b/i,ah=/sha(?:256|512|1)sum|--checksum|checksum=|EXPECTED_SHA|gpg\s+--verify|\.sha(?:256|512)\b/i,oh=/\b(?:child_process|childProcess|execa|os\.system|subprocess\.|Deno\.run|autoUpdater|electron-updater)\b|\b(?:exec(?:File)?(?:Sync)?|spawn(?:Sync)?)\s*\(/,sh=/.\/\.github\/workflows\//i,ch=/(?:^|\/)[\w-]+[.@-]\d+\.\d+\.\d+(?:[-.][\w.]+)?\//,lh=e=>Il(e)&&!sh.test(e)&&!ch.test(e)&&!Dl.test(e),uh=U({id:`plugin-update-trust-risk`,title:`Plugin or updater trust boundary risk`,severity:`warn`,recommendation:`Require signed updates/plugins, pin trusted repositories, verify hashes before execution, and keep custom repository installs behind explicit warnings.`,scan:e=>{if(!G(e.relativePath)&&!lh(e.relativePath))return[];let t=su(e),n=ih.test(t);if(!n&&!rh.test(t))return[];let r=n?ih:rh;if(ah.test(t)||bl.test(e.relativePath)&&!oh.test(t))return[];let i=_l(t,r);return[{message:`Code appears to download, install, update, or execute plugin/updater content across a trust boundary.`,line:i.line,column:i.column}]}}),dh=/origin(?!al)|\.source\s*[!=]==?/i,fh=/\b(?:event|e|evt|msg|message)\.data\b/,ph=/\b(?:const|let|var)\s+[^;=]*=\s*$/,mh=/port\d?\b|worker|channel|broadcast|socket|\bws\b|\bsse\b|eventsource|^_?self\.|^source\./i,hh=String.raw`=\s*new\s+(?:EventSource|WebSocket|Worker|SharedWorker|BroadcastChannel|MessageChannel)\b`,gh=(e,t)=>{let n=/^[\w$]+/.exec(e)?.[0];return n===void 0?!1:RegExp(`(?<![\\w$.])${q(n)}\\s*${hh}`).test(t)},_h=(e,t)=>{let n=/^[\w$]+/.exec(e)?.[0];return n===void 0?!1:RegExp(`(?:^|[(,{;]\\s*)${q(n)}\\s*[?!]?\\s*:\\s*(?:Worker|SharedWorker|MessagePort|BroadcastChannel|WebSocket|EventSource)\\b`,`m`).test(t)},vh=/worker/i,yh=(e,t)=>{let n=Y(t),r=zd(t);return n<0||r<0?``:e.slice(n,r)},bh=(e,t)=>{if(t.type===`CallExpression`){let n=v(t.callee)?yh(e,t.callee):``;if(!n.endsWith(`addEventListener`))return null;let r=t.arguments[0];return v(r)&&r.type===`Literal`&&r.value===`message`?n:null}if(t.type===`AssignmentExpression`&&v(t.left)){let n=yh(e,t.left);return n.endsWith(`.onmessage`)?n:null}return null},xh=U({id:`postmessage-origin-risk`,title:`postMessage handler without origin check`,severity:`warn`,recommendation:"Validate `event.origin` against an exact allowlist before using `event.data`, especially when an iframe or parent window can be attacker-controlled.",scan:e=>{if(!G(e.relativePath)||vh.test(e.relativePath))return[];let t=e.content.includes(`onmessage`),n=e.content.includes(`addEventListener`)&&(e.content.includes(`message`)||e.content.includes(`\\`));if(!t&&!n)return[];let r=nn({filename:e.absolutePath,sourceText:e.content,shouldAttachParentReferences:!1});if(r===null)return[];let i=[];return O(r,t=>{let n=bh(e.content,t);if(n===null||mh.test(n)||gh(n,e.content)||_h(n,e.content))return;let r=yh(e.content,t),a=r.search(fh);if(a<0)return;let o=r.search(dh);if(o>=0&&(ph.test(r.slice(0,a))||o<a))return;let s=W(e.content,Y(t));i.push({message:`A message event handler reads cross-window messages without an obvious origin check.`,line:s.line,column:s.column})}),i}}),Sh=/(?:^|\/)(?:locales?|i18n|lang|langs|translations?)\//i,Ch=/(?:^|\/)(?:\.env(?:\.[^/]*)?|(?:debug|crash|trace|stack[-_]?trace|report|dump|phpinfo)(?:[-_.][^/]*)?\.(?:txt|log|json|html?)|[^/]+\.log)$/i,wh=e=>Fl(e,Al.test(e))&&!Sh.test(e)&&Ch.test(e),Th=U({id:`public-debug-artifact`,title:`Public debug artifact`,severity:`warn`,recommendation:`Remove debug artifacts from public output; logs and dumps often reveal source paths, internal routes, tokens, or environment snapshots.`,scan:e=>{if(!wh(e.relativePath))return[];let t={message:`A browser-reachable debug, log, dump, report, or env artifact is present.`,line:1,column:1};return[wu.some(t=>t.test(e.content))?{...t,severity:`error`}:t]}}),Eh=/(?:^|\/)docs?\//i,Dh=U({id:`public-env-secret-name`,title:`Secret-like public env variable`,severity:`warn`,recommendation:`Public env prefixes are inlined into browser bundles. Rename public values to non-secret names, and keep tokens, passwords, private keys, and service-role credentials server-only.`,scan:e=>{if(!Wp(e.relativePath)||Eh.test(e.relativePath))return[];let t=Qu(e.content);if(t===void 0)return[];let n=_l(e.content,t);return[{message:`Client code references a public env variable whose name looks like a secret or privileged credential.`,line:n.line,column:n.column}]}}),Oh=`(?:"[^"\\n]{0,200}"|'[^'\\n]{0,200}'|\`[^\`$]{0,200}\`)`,kh=`\\s*\\(?\\s*(?:${Oh}|(?:[\\w\$]+(?:\\.[\\w\$]+)*\\.escape(?:Id|Literal|Identifier)|(?:[\\w\$]+\\.)*(?:connection|conn|client|pool|db|mysql|sqlstring|knex)\\.escape)\\s*\\([^()]{0,200}\\))\\s*\\)?`,Ah=U({id:`raw-sql-injection-risk`,title:`Raw SQL built outside parameter binding`,severity:`warn`,recommendation:`Keep user input in driver parameters or ORM bind variables. Avoid unsafe/raw SQL helpers and string interpolation for queries.`,scan:K({shouldScan:e=>Ad(e.relativePath),pattern:[/\$queryRawUnsafe\s*\(/,/\$executeRawUnsafe\s*\(/,/\bPrisma\.raw\s*\((?!\s*(?:["'][^"'\n]*["']\s*[,)]|`[^`$]*`))/,/\bsql\.\s*(?:raw|unsafe)\s*\((?!\s*(?:["'][^"'\n]*["']\s*[,)]|`[^`$]*`))/,/\b(?:client|pool|conn)\.query\s*\(\s*['"`]\s*(?:SELECT|INSERT|UPDATE|DELETE)\b[^)]{0,400}\$\{(?!\s*[\w$.]*(?:sanitiz|escape|quote)[\w$]*\s*\()/i,RegExp(`\\.query\\s*\\(\\s*${Oh}(?:\\s*\\+${kh})*\\s*\\+(?!${kh})`,`i`),/\.(?:where|orderBy|having)Raw\s*\((?!\s*(?:["'][^"'\n]*["']\s*[,)]|`[^`$]*`))/,/\bcursor\.execute\s*\(\s*f['"]/,/\bcursor\.execute\s*\(\s*(?:"[^"]{0,400}"|'[^']{0,400}')\s*(?:%|\.format\s*\(|\+)/,/\b(?:engine|session)\.execute\s*\(\s*(?:text\s*\(\s*)?f['"]/,/\$[\w]+->(?:query|exec|prepare|executeQuery|executeStatement|createQuery|createNativeQuery)\s*\(\s*(?:"[^"]{0,400}"|'[^']{0,400}')\s*\.\s*\$/,/mysqli_query\s*\(\s*[^,]+,\s*(?:"[^"]{0,400}"|'[^']{0,400}')\s*\.\s*\$/],message:`Code uses a raw SQL escape hatch or string-built query shape that can bypass parameter binding.`})}),jh=e=>yl.test(e)||/(?:^|\/)\.npmrc$/.test(e)||/(?:^|\/)[^/]*(?:credential|credentials|service-account|serviceAccount|firebase-admin|google-service-account|gcp-service-account)[^/]*\.(?:json|env|pem|key)$/i.test(e),Mh=e=>/(?:^|\/)\.env(?:\.[^./]+)*\.(?:example|sample|template|dist|defaults?)$|(?:^|\/)[^/]*(?:example|sample|template)[^/]*\.(?:env|json|pem|key)$/i.test(e),Nh=U({id:`repository-secret-file`,title:`Secret file checked into repository`,severity:`error`,committedFilesOnly:!0,recommendation:`Remove committed env files, service-account credentials, npm auth tokens, and webhook URLs; rotate exposed values and keep only redacted examples in source.`,scan:e=>{if(!jh(e.relativePath)||Mh(e.relativePath)||wl.test(e.relativePath))return[];let t=wu.find(t=>t.test(e.content))??Qu(e.content);if(t===void 0)return[];let n=_l(e.content,t);return[{message:`A repository credential/config file contains secret-looking values.`,line:n.line,column:n.column}]}}),Ph=`(?:req|request|ctx\\.req|ctx\\.request)\\.(?:body|query|params)|await\\s+(?:req|request)\\.json\\(\\s*\\)`,Fh=U({id:`request-body-mass-assignment`,title:`Request input spread without field allowlist`,severity:`warn`,recommendation:"Assign explicit, allowlisted fields (or validate with a strict schema and no `.passthrough()`) instead of spreading/merging request input. Otherwise the client can set ownership, role, or price columns (mass assignment) or pollute the prototype.",scan:K({shouldScan:e=>G(e.relativePath),pattern:[RegExp(`\\.\\.\\.\\s*(?:${Ph})`,`i`),RegExp(`(?:Object\\.assign\\s*\\(|_\\.(?:merge|mergeWith|defaultsDeep)\\s*\\(|(?:^|[^.\\w])(?:merge|defaultsDeep)\\s*\\()[\\s\\S]{0,80}?(?:${Ph})`,`i`)],message:`Request input is spread or merged into an object without a field allowlist, enabling mass assignment (client-set owner/role/price fields) or prototype pollution.`})}),Ih=U({id:`secret-in-fallback`,title:`Hardcoded secret fallback for env var`,severity:`error`,recommendation:"Remove the literal fallback and fail closed (throw when the variable is unset). The hardcoded value is a committed secret, and the `??`/`||` default makes the app run with it in any environment that forgot to set the var.",scan:K({shouldScan:e=>G(e.relativePath),pattern:/\bprocess\.env\.(?!(?:(?:(?:NEXT|EXPO|GATSBY|NUXT|REACT_APP|VITE)_)?PUBLIC_[A-Z0-9_]*(?<!_SECRET)(?<!_PRIVATE_KEY)(?<!_PASSWORD)(?<!_PASSWD)|[A-Z0-9_]*(?:PUBLISHABLE|ANON)_KEY)(?![A-Z0-9_]))[A-Z][A-Z0-9_]*(?:SECRET|TOKEN|PASSWORD|PASSWD|PRIVATE_KEY|API_?KEY|APIKEY|ACCESS_KEY|CLIENT_SECRET|CREDENTIAL|SIGNING_KEY|ENCRYPTION_KEY|WEBHOOK_SECRET|SERVICE_ROLE)[A-Z0-9_]*(?<!_(?:NAME|HEADER|ENDPOINT|URL|URI|ID|PREFIX|SUFFIX|PARAM|PARAMS|FIELD|ISSUER|AUDIENCE|ALGORITHM|ALG|REGION|BUCKET|HOST|HOSTNAME|PORT|PATH|VERSION|SCOPE|TYPE|FORMAT|EXPIRY|TTL))\s*(?:\?\?|\|\|)\s*(["'`])(?![0-9]+["'`])(?![a-z][a-z0-9]*(?:[_-][a-z0-9]+)*[_-](?:token|secret|key|password|passwd|credential)s?["'`])(?![\w-]{0,12}0{8,}["'`])(?!test test test test test test test test test test test junk["'`])(?!(?:changeme|change[_-]?me|placeholder|your[_-]|example|sample|dummy|development|local|todo|replace[_-]?me|https?:\/\/|x{3,}|\*{3,}))[^"'`\n]{8,}\1/i,message:`A secret env var has a hardcoded string fallback: the literal is a committed secret and the app fails open (uses it) when the variable is unset.`})}),Lh=(e,t)=>{let n=null;if(b(e,`Program`)?n=e.body:(b(e,`FunctionDeclaration`)||b(e,`FunctionExpression`)||b(e,`ArrowFunctionExpression`))&&b(e.body,`BlockStatement`)&&(n=e.body.body),n===null)return!1;for(let e of n){if(!b(e,`ExpressionStatement`)||e.directive===void 0)return!1;if(e.directive===t)return!0}return!1},Rh=(e,t=`source.tsx`)=>{let n=nn({filename:t,sourceText:e,shouldAttachParentReferences:!1});return n===null?!1:Lh(n,`use server`)},zh=K({shouldScan:e=>Wp(e.relativePath),pattern:/\b(?:ownerId|ownerID|creatorId|creatorID|userId|userID|uid|providerId|providerID|orgId|orgID|tenantId|tenantID|teamId|teamID|workspaceId|workspaceID|ghostOrg|role|roles|isAdmin|admin)\b/,requireAll:[/\b(?:supabase\b|\.from\s*\(\s*["'][^"']+["']\s*\))[\s\S]{0,700}\b(?:insert|upsert|update)\s*\(\s*(?:\{|\[?\s*\{)[\s\S]{0,700}\b(?:ownerId|creatorId|userId|orgId|tenantId|role|isAdmin)\b/i],message:`Client Supabase code appears to write user, tenant, owner, or role fields that should be enforced by RLS.`}),Bh=U({id:`supabase-client-owned-authz-field`,title:`Client writes Supabase authorization field`,severity:`error`,recommendation:"Use RLS policies based on `auth.uid()` and server-owned membership rows; do not trust client-provided owner, org, or role columns.",scan:e=>{let t=zh(e);return t.length===0?t:Rh(e.content,e.relativePath)?[]:t}}),Vh=e=>/(?:^|\/)supabase\/(?:migrations|schemas)\//.test(e),Hh=e=>e.endsWith(`.sql`)||Vh(e),Uh=/^\$[A-Za-z_]?\w*\$/,Wh=new Set([`do`,`plpgsql`,`sql`,`plpython3u`,`plpythonu`,`plperl`,`plperlu`,`plv8`]),Gh=(e,t)=>{let n=t-1;for(;n>=0&&/\s/.test(e[n]??``);)--n;let r=n;for(;r>=0&&/[A-Za-z0-9_]/.test(e[r]??``);)--r;return e.slice(r+1,n+1).toLowerCase()},Kh=(e,t,n,r)=>{let i=n,a=!1;for(;i<r;){let n=e[i];if(n===`;`){a=!1,i+=1;continue}if(/[A-Za-z_]/.test(n)){let t=i;for(;t<r&&/[A-Za-z0-9_]/.test(e[t]??``);)t+=1;e.slice(i,t).toLowerCase()===`execute`&&(a=!0),i=t;continue}if(n===`'`){let n=a;for(n||(t[i]=` `),i+=1;i<r;){if(e[i]===`'`){if(e[i+1]===`'`){n||(t[i]=` `,t[i+1]=` `),i+=2;continue}n||(t[i]=` `),i+=1;break}!n&&e[i]!==`
19
+ `&&(t[i]=` `),i+=1}continue}if(n===`"`){for(i+=1;i<r;){if(e[i]===`"`){if(e[i+1]===`"`){i+=2;continue}i+=1;break}i+=1}continue}if(n===`-`&&e[i+1]===`-`){for(;i<r&&e[i]!==`
20
+ `;)t[i]=` `,i+=1;continue}if(n===`/`&&e[i+1]===`*`){for(;i<r;){if(e[i]===`*`&&e[i+1]===`/`){t[i]=` `,t[i+1]=` `,i+=2;break}e[i]!==`
21
+ `&&(t[i]=` `),i+=1}continue}i+=1}},qh=e=>{let t=e.split(``),n=0;for(;n<e.length;){let r=e[n];if(r===`-`&&e[n+1]===`-`){for(;n<e.length&&e[n]!==`
22
+ `;)t[n]=` `,n+=1;continue}if(r===`/`&&e[n+1]===`*`){for(;n<e.length;){if(e[n]===`*`&&e[n+1]===`/`){t[n]=` `,t[n+1]=` `,n+=2;break}e[n]!==`
23
+ `&&(t[n]=` `),n+=1}continue}if(r===`'`){for(t[n]=` `,n+=1;n<e.length;){if(e[n]===`'`){if(e[n+1]===`'`){t[n]=` `,t[n+1]=` `,n+=2;continue}t[n]=` `,n+=1;break}e[n]!==`
24
+ `&&(t[n]=` `),n+=1}continue}if(r===`$`){let r=Uh.exec(e.slice(n));if(r!==null){let i=r[0],a=e.indexOf(i,n+i.length),o=a<0?e.length:a+i.length,s=Gh(e,n);if(Wh.has(s))Kh(e,t,n+i.length,o);else for(let r=n;r<o;r+=1)e[r]!==`
25
+ `&&(t[r]=` `);n=o;continue}}if(r===`"`){for(n+=1;n<e.length;){if(e[n]===`"`){if(e[n+1]===`"`){n+=2;continue}n+=1;break}n+=1}continue}n+=1}return t.join(``)},Jh=/disable\s+row\s+level\s+security/i,Yh=/auth\.role\(\)\s*=\s*["']service_role["']/i,Xh=/create\s+policy/gi,Zh=/;|create\s+policy/i,Qh=/\b(?:using|with\s+check)\s*\(\s*true\s*\)/i,$h=/\bfor\s+select\b/i,eg=/\bto\s+([\s\S]+?)(?=\s+(?:using|with\s+check|as|for)\b|;|$)/i,tg=new Set([`service_role`,`postgres`,`supabase_admin`]),ng=e=>{let t=eg.exec(e);if(t===null)return!1;let n=t[1].split(`,`).map(e=>e.trim().replace(/["'`]/g,``).toLowerCase()).filter(Boolean);return n.length>0&&n.every(e=>tg.has(e))},rg=(e,t)=>Yh.test(t)?!0:!Qh.test(e)||$h.test(e)?!1:!ng(e),ig=U({id:`supabase-rls-policy-risk`,title:`Permissive Supabase RLS policy`,severity:`error`,recommendation:"Keep public-read policies explicit, but gate inserts, updates, deletes, and service-role bypasses behind `auth.uid()` plus trusted tenant membership.",scan:e=>{if(!Hh(e.relativePath))return[];let t=qh(e.content),n=t.search(Jh);Xh.lastIndex=0;for(let r=Xh.exec(t);r!==null;r=Xh.exec(t)){let i=r.index+r[0].length,a=t.slice(i).search(Zh),o=a<0?t.length:i+a;if(rg(t.slice(r.index,o),e.content.slice(r.index,o))){(n<0||r.index<n)&&(n=r.index);break}}if(n<0)return[];let{line:r,column:i}=W(t,n);return[{message:`Supabase policy SQL disables RLS, permits writes broadly, or references a service-role bypass.`,line:r,column:i}]}}),ag=/create\s+(?:unlogged\s+)?table\s+(?:if\s+not\s+exists\s+)?(?!["`]?(?:auth|storage|realtime|vault|extensions|graphql|graphql_public|pgbouncer|net|supabase_functions|supabase_migrations|cron|pgsodium|pgmq|information_schema|pg_catalog|pg_temp|private|internal)["`]?\s*\.)(?:["`]?public["`]?\s*\.\s*)?["`]?([A-Za-z_][\w$]*)["`]?(?:\s*\(|\s+as\b)/gi,og=/alter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?(?:["`]?public["`]?\s*\.\s*)?["`]?([A-Za-z_][\w$]*)["`]?\s+(?:force\s+)?enable\s+row\s+level\s+security/gi,sg=/\benable\s+row\s+level\s+security\b/gi,cg=e=>{let t=new Map,n=0;for(let r of e.matchAll(og)){let e=r[1];e!==void 0&&(n+=1,t.set(e.toLowerCase(),r.index))}return{lastEnableIndexByTable:t,staticEnableCount:n}},lg=(e,t)=>(e.match(sg)?.length??0)>t,ug=U({id:`supabase-table-missing-rls`,title:`Supabase table created without Row Level Security`,severity:`error`,recommendation:"Enable RLS in the same migration (`alter table <name> enable row level security;`) and add `auth.uid()`-scoped policies for select/insert/update/delete. A public table without RLS is fully readable and writable with the public anon key.",scan:e=>{if(!Vh(e.relativePath))return[];let t=qh(e.content);if(!/create\s+(?:unlogged\s+)?table/i.test(t))return[];let n=[],{lastEnableIndexByTable:r,staticEnableCount:i}=cg(t);if(lg(t,i))return[];ag.lastIndex=0;for(let e=ag.exec(t);e!==null;e=ag.exec(t)){let i=e[1];if(i===void 0)continue;let a=r.get(i.toLowerCase());if(a!==void 0&&a>=e.index)continue;let o=W(t,e.index);n.push({message:`Supabase migration creates a public table but never enables Row Level Security, leaving every row exposed to the anon key.`,line:o.line,column:o.column})}return n}}),dg=U({id:`svg-filter-clickjacking-risk`,title:`SVG-filtered iframe clickjacking primitive`,severity:`warn`,recommendation:"Avoid filtering cross-origin iframes. Use `frame-ancestors` on sensitive pages and keep SVG filters away from embedded privileged UI.",scan:K({shouldScan:e=>G(e.relativePath),pattern:/<iframe\b(?:=>|[^>]){0,300}\bfilter\s*:\s*["']?url\(#|filter\s*:\s*url\(#[\s\S]{0,700}<iframe\b|<fe(?:DisplacementMap|ColorMatrix|Composite|Tile|Morphology)\b[\s\S]{0,700}<iframe\b/i,message:`An iframe is rendered through an SVG/CSS filter, which can support advanced clickjacking or visual exfiltration tricks.`})}),fg=e=>G(e)?Cl.test(e)?!0:/(?:^|\/)(?:middleware|route)\.[cm]?[jt]sx?$/.test(e):!1,pg=U({id:`tenant-static-proxy-risk`,title:`Tenant-controlled static asset proxy`,severity:`warn`,recommendation:`Bind tenant identity to the trusted host or authenticated org, canonicalize after decoding, reject traversal, and never let one tenant choose another tenant's asset prefix.`,scan:K({shouldScan:e=>fg(e.relativePath),pattern:/\b(?:fetch|path\.join|getObject\w*|GetObjectCommand|getSignedUrl|createReadStream)\s*\([^;]{0,200}(?:\$\{[^}]{0,100}\b(?:tenant|subdomain|workspace|hostPattern|(?<!\.)organization(?:Id|Slug)?)\b|\b(?:tenant|subdomain|workspace)(?:Id|Slug|Name)?\b\s*[,)+\].])/i,message:`Route code appears to compose tenant or subdomain input into a static/CDN/object-store fetch path.`})}),mg=[/dangerouslySetInnerHTML\s*=\s*\{\{\s*__html\s*:[\s\S]{0,300}?\bJSON\.stringify\s*\(/gi,/<script\b[^>]*>(?:(?!<\/script>)[\s\S]){0,300}?\bJSON\.stringify\s*\(/gi],hg=/\$\{|["'`]\s*\+\s*$/,gg=/^\s*\{(?!\{)/,_g=/"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'/g,vg=/\b(?:true|false|null)\b|[\d.]+(?:e[+-]?\d+)?/gi,yg=e=>{if(e.includes("`")||e.includes("${"))return!1;let t=e.replace(_g,``).replace(vg,``);return!/[A-Za-z_$]/.test(t)},bg=/^[\s)]*\.replace\s*\([^)]*(?:\\u003[cC]|&lt;|<)/,xg=/(?:\b(?:escapeHtml|escapeJSON|escapeJson|htmlEscape|jsesc)|(?<![.\w])(?:serialize|serializeJavascript|devalue|uneval|superjson))\s*\(\s*$/i,Sg=/\bJSON\.stringify\s*\($/i,Cg=U({id:`unsafe-json-in-html`,title:`Unescaped JSON in HTML or script sink`,severity:`warn`,recommendation:'JSON.stringify does not HTML-escape, so a `<\/script>` (or `<`) in the data breaks out and becomes XSS. Use an HTML-safe serializer (serialize-javascript, devalue) or escape `<`, `>`, and `&`, or pass data via a JSON `<script type="application/json">` read with JSON.parse.',scan:e=>{if(!G(e.relativePath))return[];let t=su(e);if(!t.includes(`JSON.stringify`))return[];let n=[],r=new Set;for(let[e,i]of mg.entries()){i.lastIndex=0;for(let a=i.exec(t);a!==null;a=i.exec(t)){let i=a[0].replace(Sg,``);if(xg.test(i))continue;if(e===1){let e=t.indexOf(`>`,a.index),n=a[0].search(/\bJSON\.stringify\s*\($/i);if(e>=0&&n>=0){let r=t.slice(e+1,a.index+n);if(!hg.test(r)||gg.test(r))continue}}let o=a.index+a[0].length-1,s=Rd(t,o);if(s>=0){let e=t.slice(s+1,s+1+160);if(bg.test(e)||yg(t.slice(o+1,s)))continue}if(r.has(a.index))continue;r.add(a.index);let c=W(t,a.index);n.push({message:"JSON.stringify is embedded in HTML/script markup without HTML-escaping; data containing `<\/script>` or `<` breaks out and becomes XSS.",line:c.line,column:c.column})}}return n}}),wg=/(?:(?<![.\w$])fetch|\baxios\.\s*(?:get|post|put|delete|head)|\bgot|\bgot\.\s*(?:get|post))\s*\(\s*([^,)]+)/,Tg=/\b(?:url|targetUrl|callbackUrl|redirectUrl|webhookUrl|companyUrl|websiteUrl|domainUrl|imageUrl|fetchUrl|next|return_to|returnTo|destination|location)\b/i,Eg=/\breq\.|\brequest\.(?:query|body|params|nextUrl)|\bsearchParams\b|\bparams\.|\bbody\.|\bquery\./,Dg=/\bredirect\s*:\s*["'](?:manual|error)["']/,Og=/\b(params|body|query)\./g,kg=(e,t)=>RegExp(`(?:const|let|var)\\s+${e}\\s*(?::[^=;\\n]{0,80})?=\\s*new\\s+URLSearchParams\\b`).test(t),Ag=(e,t)=>{let n=e.replace(Og,(e,n)=>kg(n,t)?``:e);return Eg.test(n)},jg=(e,t)=>{if(Ag(e,t))return!0;let n=/^[\w$]+$/.exec(e.trim());if(n===null)return!1;let r=RegExp(`(?:const|let|var)[^=;\\n]{0,80}\\b${n[0]}\\b[^=;\\n]{0,80}=([^;\\n]*)`,`g`);for(let e of t.matchAll(r)){let n=e[1]??``;if(/\breq\.|\brequest\.|\bsearchParams\b|\$_(?:GET|POST|REQUEST)/.test(n)||Ag(n,t))return!0}return!1},Mg=U({id:`untrusted-redirect-following`,title:`Server fetch follows redirects for caller-shaped URL`,severity:`warn`,recommendation:'Use `redirect: "manual"` or equivalent and re-validate every redirect target before following it to avoid SSRF redirect bypasses.',scan:e=>{if(!fg(e.relativePath)||!wg.test(e.content))return[];let t=[],n=e.content.split(`
26
+ `);for(let r=0;r<n.length;r+=1){let i=n[r]??``,a=i.match(wg),o=a?.[1]??``;if(!a||!Tg.test(o)||!jg(o,e.content))continue;let s=n.slice(r,r+5).join(`
27
+ `);Dg.test(s)||t.push({message:`Server-side fetch code appears to follow redirects for a URL shaped like caller-controlled input.`,line:r+1,column:i.search(/\S/)+1})}return t}}),Ng=U({id:`url-prefilled-privileged-action`,title:`URL pre-fills a privileged action`,severity:`warn`,recommendation:`Require server-side validation and explicit confirmation for URL-sourced invite, role, permission, redirect, or sharing parameters.`,scan:K({shouldScan:e=>Wp(e.relativePath),pattern:/(?<!(?:safe|valid|sanitiz|relativ|allowlist|whitelist|parse|normaliz)[\w$]*\(\s*(?:new\s+)?(?:[\w$]+\s*\.\s*){0,4})\b(?:searchParams|useSearchParams\s*\(\s*\)|URLSearchParams\s*\([^)]{0,120}\))(?:[?!])?\.get(?:All)?\s*\(\s*["'](?:userstoinvite|role|permission|sharingaction|invite|admin|next|continue|returnTo|redirect_uri|callbackUrl)["']|\bsearchParams\.(?:userstoinvite|role|permission|sharingaction|invite|admin|returnTo|redirect_uri|callbackUrl)\b/i,message:`Client code reads sensitive action state from the URL, which can pre-fill invites, roles, redirects, or sharing flows with attacker values.`})}),Pg=/(?:^|\/)[^/]*webhook[^/]*\/|(?:^|\/)[^/]*webhook[^/]*\.[cm]?[jt]s$|\bwebhook\b/i,Fg=/\b(?:export\s+(?:async\s+)?function\s+POST|export\s+const\s+(?:POST|handler|webhook)|webhookHandler|webhookRoute)\b/i,Ig=RegExp(`verifySignature|verify.*signature|verify\\w*(?:Webhook|Auth)|constructEvent|createHmac|timingSafeEqual|svix|webhookSecret|stripe\\.webhooks|["'][\\w-]*signature["']|\\b[A-Za-z]{0,40}(?:verif|valid|check|assert|authenticat|compare|guard)[A-Za-z]{0,40}(?:secret|signature|hmac|webhook|digest)[A-Za-z]{0,40}\\s*\\(`,`i`),Lg=/webhook[\s_-]?ur[il]\w*/gi,Rg=/process\.env\.\w*WEBHOOK_URL|\b(?:send|post|dispatch|publish|notify)\w*Webhook/,zg=/\b(?:req|request)\b/,Bg=/\/\/[^\n]*|\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`(?:\\.|[^`\\])*`/g,Vg=U({id:`webhook-signature-risk`,title:`Webhook handler lacks signature verification`,severity:`warn`,recommendation:`Verify provider signatures before parsing or acting on webhook bodies. Use provider SDK helpers or HMAC verification with timing-safe comparison.`,scan:K({shouldScan:e=>{if(!G(e.relativePath)||Rg.test(e.content))return!1;let t=e.content.replace(Bg,``).replace(Lg,``);return Pg.test(e.relativePath)||Pg.test(t)},pattern:Fg,requireAll:[zg],suppressWhen:Ig,message:`Webhook handler code does not show an obvious signature verification step.`})}),Hg=/\.[cm]?[jt]sx?$/i,Ug=/\.d\.[cm]?[jt]s$/i,Wg=/\.mdx$/i,Gg=/\.html?$/i,Kg=new Set([`.angular`,`.astro`,`.cache`,`.contentlayer`,`.docusaurus`,`.expo`,`.git`,`.next`,`.nuxt`,`.output`,`.svelte-kit`,`.turbo`,`.vercel`,`build`,`coverage`,`dist`,`node_modules`,`out`,`storybook-static`]),qg=new WeakMap,Jg=e=>{let t=qg.get(e);if(t)return t;let n=Ge(e);return qg.set(e,n),n},Yg=e=>{let t=[],n=[],r=[e],a=!1;for(;r.length>0;){let e=r.pop();if(!e)continue;let s;try{s=i.readdirSync(e,{withFileTypes:!0})}catch{return null}for(let i of s){let s=o.join(e,i.name),c=Kg.has(i.name)||i.name.startsWith(`.`)&&i.name!==`.dumi`&&i.name!==`.storybook`;if(!(i.isSymbolicLink()&&c)){if(i.isSymbolicLink())return null;if(i.isDirectory()){if(c)continue;r.push(s);continue}if(!(!i.isFile()||Xc(s))){if(Wg.test(i.name)){a=!0;continue}if(Gg.test(i.name)){n.push(N(s));continue}Hg.test(i.name)&&(Ug.test(i.name)||t.push(N(s)))}}}}return{sourceFilePaths:t,htmlFilePaths:n,hasOpaqueMdxConsumerSurface:a}},Xg=(e,t)=>{for(let n of e){let e;try{e=i.readFileSync(n,`utf8`)}catch{return!0}for(let n of t)if(e.includes(`"${n}"`)||e.includes(`'${n}'`))return!0}return!1},Zg=e=>{if(b(e,`ImportDeclaration`))return Oc(e)?null:typeof e.source.value==`string`?e.source.value:null;if(b(e,`ExportNamedDeclaration`))return e.exportKind===`type`||Dc(e.specifiers,`ExportSpecifier`,`exportKind`)?null:e.source&&typeof e.source.value==`string`?e.source.value:null;if(b(e,`ExportAllDeclaration`))return e.exportKind===`type`?null:typeof e.source.value==`string`?e.source.value:null;if(b(e,`ImportExpression`))return b(e.source,`Literal`)&&typeof e.source.value==`string`?e.source.value:null;if(b(e,`CallExpression`)&&b(e.callee,`Identifier`)&&e.callee.name===`require`&&e.arguments.length===1){let t=e.arguments[0];return t&&b(t,`Literal`)&&typeof t.value==`string`?t.value:null}return null},Qg=(e,t,n,r)=>{O(e.programNode,i=>{let a=Zg(i);if(!a)return;let o=Wn(e.filePath,a);if(!o){r.add(a);return}let s=N(o);n.set(i,s);let c=t.get(s)??new Set;c.add(e),t.set(s,c)})},$g=({rootDirectory:e,currentFilePath:t,currentProgramNode:n,currentScopes:r,requiredModuleSources:i=[],knownModuleSources:a})=>{if(i.length>0&&a!==void 0&&!i.some(e=>a.includes(e)))return null;let o=Yg(e);if(!o||i.length>0&&a===void 0&&!Xg(o.sourceFilePaths,i))return null;let s=new Map;for(let e of o.sourceFilePaths){if(e===t){s.set(e,{filePath:e,programNode:n,scopes:r});continue}let i=on(e);if(!i||!b(i,`Program`))return null;s.set(e,{filePath:e,programNode:i,scopes:Jg(i)})}let c=new Map,l=new WeakMap,u=new Set;for(let e of s.values())Qg(e,c,l,u);return{modulesByFilePath:s,htmlFilePaths:o.htmlFilePaths,consumerModulesByFilePath:c,resolvedSourcePathByNode:l,unresolvedRuntimeSources:u,hasOpaqueMdxConsumerSurface:o.hasOpaqueMdxConsumerSurface}},e_=e=>{if(!e)return null;let t=E(e);return!b(t,`Literal`)||typeof t.value!=`boolean`?null:t.value},t_=(e,t,n={})=>{let r=n.maximumConstAliases===void 0?4:n.maximumConstAliases,i=n.shouldFoldStaticConditions??!1,a=n.shouldKeepKnownValues??!1,o=[],s=[{expression:e,remainingConstAliases:r,resolvingSymbols:new Set}];for(;s.length>0;){let e=s.pop();if(!e)continue;let n=E(e.expression);if(b(n,`Literal`)){if(typeof n.value!=`string`){if(a)continue;return null}o.push(n.value);continue}if(b(n,`TemplateLiteral`)){let e=Wa(n);if(e===null){if(a)continue;return null}o.push(e);continue}if(b(n,`ConditionalExpression`)){let t=i?e_(n.test):null;if(t!==null){s.push({expression:t?n.consequent:n.alternate,remainingConstAliases:e.remainingConstAliases,resolvingSymbols:e.resolvingSymbols});continue}s.push({expression:n.alternate,remainingConstAliases:e.remainingConstAliases,resolvingSymbols:new Set(e.resolvingSymbols)}),s.push({expression:n.consequent,remainingConstAliases:e.remainingConstAliases,resolvingSymbols:new Set(e.resolvingSymbols)});continue}if(a&&b(n,`LogicalExpression`)&&(n.operator===`??`||n.operator===`||`)){s.push({expression:n.right,remainingConstAliases:e.remainingConstAliases,resolvingSymbols:new Set(e.resolvingSymbols)}),s.push({expression:n.left,remainingConstAliases:e.remainingConstAliases,resolvingSymbols:new Set(e.resolvingSymbols)});continue}if(b(n,`Identifier`)){let r=t.referenceFor(n)?.resolvedSymbol;if(!r||r.kind!==`const`||!r.initializer||!b(r.declarationNode,`VariableDeclarator`)||r.declarationNode.id!==r.bindingIdentifier||e.remainingConstAliases===0||e.resolvingSymbols.has(r)){if(a)continue;return null}e.resolvingSymbols.add(r),s.push({expression:r.initializer,remainingConstAliases:e.remainingConstAliases===null?null:e.remainingConstAliases-1,resolvingSymbols:e.resolvingSymbols});continue}if(!a)return null}return o.length>0?o:null},n_=(e,t,n={})=>t_(e,t,n),r_=(e,t)=>t_(e,t,{shouldKeepKnownValues:!0}),i_=(e,t,n,r,i=!1)=>{let a=e.value;return a?b(a,`Literal`)?typeof a.value==`string`?[a.value]:null:b(a,`JSXExpressionContainer`)?n_(a.expression,t,{maximumConstAliases:n,shouldFoldStaticConditions:r,shouldKeepKnownValues:i}):null:null},a_=(e,t)=>i_(e,t,4,!1),o_=(e,t)=>i_(e,t,null,!0),s_=(e,t)=>i_(e,t,4,!1,!0),c_=(e,t)=>{let n=o.relative(t,e);return n===``||!n.startsWith(`..${o.sep}`)&&n!==`..`&&!o.isAbsolute(n)},l_={attribute:null,expression:null,isPresent:!1,isUnknown:!1},u_={attribute:null,expression:null,isPresent:!1,isUnknown:!0},d_=(e,t,n)=>{for(let r=e.properties.length-1;r>=0;--r){let i=e.properties[r];if(!i)return u_;if(b(i,`SpreadElement`)){if(!b(i.argument,`ObjectExpression`))return u_;let e=d_(i.argument,t,n);if(e.isPresent||e.isUnknown)return e;continue}if(!b(i,`Property`))return u_;let a=j(i,{allowComputedString:!0});if(!a)return u_;if((n?a:a.toLowerCase())===t)return{attribute:null,expression:i.value,isPresent:!0,isUnknown:!1}}return l_},f_=(e,t,n=!0)=>{let r=n?t:t.toLowerCase();for(let t=e.length-1;t>=0;--t){let i=e[t];if(!i)return u_;if(b(i,`JSXSpreadAttribute`)){if(!b(i.argument,`ObjectExpression`))return u_;let e=d_(i.argument,r,n);if(e.isPresent||e.isUnknown)return e;continue}if(!b(i,`JSXAttribute`))continue;let a=Zo(i.name);if((n?a:a?.toLowerCase())===r)return{attribute:i,expression:null,isPresent:!0,isUnknown:!1}}return l_},p_=/(?<attributeName>[^\s"'<>/=]+)(?:\s*=\s*(?:"(?<doubleQuoted>[^"]*)"|'(?<singleQuoted>[^']*)'|(?<unquoted>[^\s"'=<>`]+)))?/g,m_=/<!--[\s\S]*?-->|(?<skippedContentOpeningTag><(?<skippedContentTag>script|style|textarea|title|xmp|iframe|noembed|noframes|plaintext|template)\b(?:"[^"]*"|'[^']*'|[^'"<>])*?>)[\s\S]*?(?:<\/\k<skippedContentTag>\s*>|$)|(?<openingTag><[A-Za-z][\w:-]*(?:"[^"]*"|'[^']*'|[^'"<>])*>)/gi,h_=new Map,g_=(e,t,n)=>{if(!e.isPresent)return;let r=e.attribute?s_(e.attribute,t):e.expression?r_(e.expression,t):null;for(let e of r??[]){let t=e?.trim();t&&n.add(t)}},__=(e,t,n)=>{for(let r of e.properties){if(b(r,`SpreadElement`)){b(r.argument,`ObjectExpression`)&&__(r.argument,t,n);continue}if(b(r,`Property`)&&j(r,{allowComputedString:!0})?.toLowerCase()===`id`)for(let e of r_(r.value,t)??[]){let t=e.trim();t&&n.add(t)}}},v_=e=>{let t=e.parent;for(b(t,`JSXElement`)&&t.openingElement===e&&(t=t.parent);t;){if(b(t,`JSXElement`)&&ms(t.openingElement)===`template`)return!0;t=t.parent}return!1},y_=(e,t,n)=>{O(e,e=>{if(!b(e,`JSXOpeningElement`)||v_(e))return;let r=f_(e.attributes,`id`,!1);if(r.isUnknown){for(let r of e.attributes)g_(f_([r],`id`,!1),t,n),b(r,`JSXSpreadAttribute`)&&b(r.argument,`ObjectExpression`)&&__(r.argument,t,n);return}g_(r,t,n)})},b_=(e,t)=>{for(let n of e.matchAll(m_)){let e=n.groups?.skippedContentOpeningTag??n.groups?.openingTag;if(e)for(let n of e.matchAll(p_)){if(n.groups?.attributeName?.toLowerCase()!==`id`)continue;let e=n.groups?.doubleQuoted??n.groups?.singleQuoted??n.groups?.unquoted??``;e.trim()&&t.add(e.trim())}}},x_=e=>{if(!o.isAbsolute(e.currentFilePath))return null;let t=e.configuredRootDirectory?N(e.configuredRootDirectory):null;return!t||!c_(e.currentFilePath,t)?null:t},S_=()=>{h_.clear()},C_=e=>{let t=new Set;y_(e.currentProgramNode,e.currentScopes,t);let n=x_(e);if(!n)return t;if(h_.has(n)){let e=h_.get(n);return e?new Set([...e,...t]):null}let r=$g({rootDirectory:n,currentFilePath:N(e.currentFilePath),currentProgramNode:e.currentProgramNode,currentScopes:e.currentScopes});if(!r)return h_.set(n,null),null;let a=new Set;for(let e of r.modulesByFilePath.values())y_(e.programNode,e.scopes,a);try{for(let e of r.htmlFilePaths)b_(i.readFileSync(e,`utf8`),a)}catch{return h_.set(n,null),null}return h_.set(n,a),new Set([...a,...t])},w_=new Map,T_=()=>{w_.clear()},E_=e=>{let t=w_.get(e);if(t!==void 0)return t;let n;try{n=i.realpathSync(e)}catch{n=e}return w_.set(e,n),n},D_=(e,t,n)=>{if(t===void 0||t.length===0)return!1;let r=N(E_(e)),i=N(t);if(n&&r===i)return!0;let a=i.endsWith(`/`)?i:`${i}/`;return r.startsWith(a)},O_=/webpackIgnore\s*:\s*true|@vite-ignore/,k_=new Map,A_=()=>{k_.clear()},j_=e=>{if(!e)return null;let t=k_.get(e);if(t!==void 0)return t===!1?null:t;let n=!1;try{let t=a(e,`utf8`);O_.test(t)&&(n=t)}catch{n=!1}return k_.set(e,n),n===!1?null:n},M_=()=>{A_(),Kn(),Dt(),On(),T_(),S_(),Un()},N_=e=>vl.test(e)||yl.test(e),P_=e=>{let t=Al.test(e);return jh(e)||Hh(e)||Ul(e)||Il(e)?{bucket:`priority`,isGeneratedBundleByName:t}:Fl(e,t)?{bucket:`artifact`,isGeneratedBundleByName:t}:N_(e)?{bucket:`other`,isGeneratedBundleByName:t}:null},F_=(e,t)=>t||N_(e)||Il(e)||jh(e),I_=[`nextjs`,`astro`,`vite`,`cra`,`remix`,`gatsby`,`expo`,`react-native`,`tanstack-start`,`preact`,`unknown`];export{qd as $,nt as $i,ca as $n,oi as $r,Qc as $t,Th as A,u as Aa,jt as Ai,io as An,Ei as Ar,Wu as At,Um as B,it as Bi,Ca as Bn,ci as Br,Fu as Bt,Bh as C,ee as Ca,Ut as Ci,Do as Cn,yi as Cr,Ju as Ct,Nh as D,f as Da,zt as Di,Eo as Dn,Oi as Dr,Cu as Dt,Fh as E,p as Ea,Rt as Ei,Ao as En,xi as Er,Vu as Et,$m as F,vt as Fi,La as Fn,Di as Fr,Ru as Ft,Jp as G,Qe as Gi,ha as Gn,fi as Gr,il as Gt,km as H,st as Hi,xa as Hn,mi as Hr,du as Ht,Qm as I,ft as Ii,Ra as In,ui as Ir,qu as It,Up as J,$e as Ji,_a as Jn,ni as Jr,rl as Jt,qp as K,Ze as Ki,va as Kn,pi as Kr,sl as Kt,Zm as L,dt as Li,I as Ln,_i as Lr,Iu as Lt,uh as M,l as Ma,yt as Mi,L as Mn,Si as Mr,zu as Mt,nh as N,c as Na,ht as Ni,Wa as Nn,Li as Nr,Gu as Nt,Ah as O,m as Oa,kt as Oi,Oo as On,Pi as Or,Pu as Ot,th as P,gt as Pi,za as Pn,wi as Pr,Ku as Pt,Kd as Q,Ye as Qi,la as Qn,si as Qr,Xc as Qt,Km as R,pt as Ri,Ma as Rn,gi as Rr,Lu as Rt,ig as S,ne as Sa,qt as Si,Po as Sn,ki as Sr,Hu as St,Ih as T,g as Ta,Vt as Ti,ko as Tn,Ji as Tr,Yu as Tt,sm as U,lt as Ui,ba as Un,vi as Ur,Hl as Ut,Bm as V,ot as Vi,Sa as Vn,li as Vr,fu as Vt,em as W,tt as Wi,ya as Wn,di as Wr,U as Wt,yf as X,ut as Xi,F as Xn,ii as Xr,ul as Xt,bf as Y,qe as Yi,da as Yn,ei as Yr,ll as Yt,lf as Z,Je as Zi,P as Zn,ri as Zr,el as Zt,Mg as _,se as _a,Dn as _i,Xo as _n,Hi as _r,mu as _t,O_ as a,y as aa,hr as ai,wc as an,j as ar,Id as at,dg as b,le as ba,Jt as bi,No as bn,Ai as br,ju as bt,C_ as c,_e as ca,k as ci,xs as cn,Vi as cr,vd as ct,o_ as d,ue as da,O as di,hs as dn,ji as dr,pu as dt,rt as ea,ai as ei,Ic as en,N as er,Gd as et,a_ as f,fe as fa,Xn as fi,ms as fn,qi as fr,_u as ft,Ng as g,pe as ga,Wn as gi,Zo as gn,Wi as gr,yu as gt,Vg as h,ae as ha,D as hi,es as hn,Ui as hr,hu as ht,M_ as i,b as ia,A as ii,Cc as in,M as ir,Ld as it,xh as j,d as ja,T as ji,Ka as jn,Ti as jr,Bu as jt,Dh as k,te as ka,At as ki,Mo as kn,bi as kr,Xu as kt,f_ as l,ge as la,dr as li,_s as ln,Ri as lr,_d as lt,$g as m,ie as ma,Yn as mi,us as mn,Ki as mr,vu as mt,P_ as n,Ge as na,Ur as ni,Oc as nn,ia as nr,Bd as nt,j_ as o,v as oa,mr as oi,Tc as on,Bi as or,Od as ot,e_ as p,re as pa,Jn as pi,ds as pn,Gi as pr,Su as pt,Kp as q,at as qi,ga as qn,ti as qr,cl as qt,F_ as r,Ke as ra,kr as ri,Ec as rn,ta as rr,Y as rt,D_ as s,ve as sa,pr as si,rc as sn,Ni as sr,Dd as st,I_ as t,ct as ta,$r as ti,Dc as tn,$i as tr,Vd as tt,c_ as u,he as ua,Zn as ui,gs as un,Ii as ur,gu as ut,Cg as v,de as va,on as vi,qo as vn,Ci as vr,bu as vt,Lh as w,h as wa,Ht as wi,jo as wn,Fi as wr,Nu as wt,ug as x,me as xa,E as xi,z as xn,Mi as xr,Uu as xt,pg as y,ce as ya,Yt as yi,Fo as yn,zi as yr,xu as yt,Gm as z,et as zi,ja as zn,hi as zr,Mu as zt};
28
+ //# sourceMappingURL=capability-43d6SuoY.js.map