oxlint-plugin-react-doctor 0.9.14 → 0.9.15-dev.23d6160
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capability-C-TekoQd.js +28 -0
- package/dist/core.d.ts +1090 -2
- package/dist/core.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -12
- package/dist/react-native-dependency-names-waW0owVD.d.ts +333 -0
- package/package.json +1 -1
- package/dist/capability-B77oYtFw.js +0 -28
- package/dist/core-C6Vno47R.d.ts +0 -1419
|
@@ -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\)/,g=new Set([`requestAnimationFrame`,`setInterval`]),_=new Set([`framer-motion`,`motion`]),v=new Set([`bounce`,`elastic`,`wobble`,`jiggle`,`spring`]),y={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`},ee=[`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`],te=[`@react-router/dev`,`react-router-dom`,`react-router`],ne=[`Component`,`element`,`lazy`],re=[`action`,`clientAction`,`clientLoader`,`loader`],ie=`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(`.`),ae=new Set([`@react-router/cloudflare`,`@react-router/node`,`react-router/dom`,`react-router-dom`,`react-router`]),oe=new Set([`flash`,`set`,`unset`]),se=new Set([`createCookieSessionStorage`,`createFileSessionStorage`,`createMemorySessionStorage`,`createSessionStorage`,`createWorkersKVSessionStorage`]),ce=new Set([`createBrowserRouter`,`createHashRouter`,`createMemoryRouter`]),le=new Set([`append`,`delete`,`set`,`sort`]),ue=new Set([`caseSensitive`,`children`,`id`,`index`,`lazy`,`path`]),de=new Set([`arrayBuffer`,`blob`,`bytes`,`formData`,`json`,`text`]),fe=new Set([`unstable_previewServerPrerendering`,`v8_middleware`,`v8_passThroughRequests`,`v8_splitRouteModules`,`v8_trailingSlashAwareDataRequests`,`v8_viteEnvironmentApi`]),pe=new Set([`BrowserRouter`,`HashRouter`,`MemoryRouter`,`Router`,`RouterProvider`]),me=new Set([...ee,`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`,`server-sequential-independent-await`,`rn-no-legacy-shadow-styles`,`rn-no-raw-text`,`rn-prefer-expo-image`,`rn-style-prefer-boxshadow`,...ie]),he=new Set([`implements`,`returnType`,`superTypeArguments`,`superTypeParameters`,`typeAnnotation`,`typeArguments`,`typeParameters`]),ge={...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]},_e=new Map,ve=e=>e.filter(e=>e!==`parent`&&!he.has(e)),ye=e=>{let t=_e.get(e.type);if(t)return t;let n=ge[e.type];if(!n)return ve(Object.keys(e));let r=ve(n);return _e.set(e.type,r),r},b=e=>typeof e==`object`&&!!e&&typeof e.type==`string`,x=e=>e!=null&&(e.type===`ArrowFunctionExpression`||e.type===`FunctionExpression`||e.type===`FunctionDeclaration`),S=(e,t)=>typeof e==`object`&&!!e&&e.type===t,be=e=>e===`var`||e===`function`,xe=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},Se=(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},Ce=(e,t,n)=>{let r=Se(e,t,n.currentScope,n);return n.scopeStack.push(r),n.currentScope=r,n.ownScopeForNode.set(t,r),r},we=e=>{e.scopeStack.pop();let t=e.scopeStack[e.scopeStack.length-1];if(!t)throw Error(`scope stack underflow`);e.currentScope=t},Te=(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},Ee=(e,t,n,r,i,a)=>{if(S(e,`Identifier`)){Te(n,r,{name:e.name,kind:i,bindingIdentifier:e,declarationNode:a,initializer:t});return}if(S(e,`ObjectPattern`)){for(let o of e.properties)if(S(o,`Property`)){let e=o.value;Ee(e,S(e,`AssignmentPattern`)?e.right:t,n,r,i,a)}else S(o,`RestElement`)&&Ee(o.argument,t,n,r,i,a);return}if(S(e,`ArrayPattern`)){for(let o of e.elements)o&&Ee(o,S(o,`AssignmentPattern`)?o.right??null:t,n,r,i,a);return}if(S(e,`AssignmentPattern`)){Ee(e.left,e.right??null,n,r,i,a);return}S(e,`RestElement`)&&Ee(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?x(e.parent):!1,ke=e=>e.parent!==null&&e.parent!==void 0&&e.parent.type===`CatchClause`,Ae=(e,t)=>{if(!S(e,`VariableDeclaration`))return;let n=e.kind===`var`?`var`:e.kind===`let`?`let`:e.kind===`const`?`const`:`using`,r=be(n)?xe(t.currentScope):t.currentScope;for(let i of e.declarations){let e=i,a=i.init??null;Ee(i.id,a,r,t,n,e)}},je=(e,t)=>{S(e,`FunctionDeclaration`)&&e.id&&Te(xe(t.currentScope),t,{name:e.id.name,kind:`function`,bindingIdentifier:e.id,declarationNode:e,initializer:e})},Me=(e,t)=>{S(e,`ClassDeclaration`)&&e.id&&Te(t.currentScope,t,{name:e.id.name,kind:`class`,bindingIdentifier:e.id,declarationNode:e,initializer:e})},Ne=(e,t)=>{if(!S(e,`ImportDeclaration`))return;let n=xe(t.currentScope);for(let r of e.specifiers){let e=r.local;S(e,`Identifier`)&&Te(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||!S(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`;Te(xe(t.currentScope),t,{name:n.name,kind:r,bindingIdentifier:n,declarationNode:e,initializer:null})},Fe=(e,t,n)=>{for(let r of e)Ee(r,null,t,n,`parameter`,r)},Ie=e=>!(!S(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=Ce(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)b(n)&&C(n,t,r);Be(e,t);let i=Ce(e.type===`ArrowFunctionExpression`?`arrow-function`:`function`,e,t);(e.type===`FunctionExpression`||e.type===`FunctionDeclaration`)&&e.id&&Te(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),we(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)b(n)&&C(n,t,null);let n=Ve(`class`,e,t);e.type===`ClassExpression`&&e.id&&Te(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),we(t);return}if(e.type===`CatchClause`){let n=Ve(`catch`,e,t);e.param&&Ee(e.param,null,n,t,`catch-clause-parameter`,e),e.body&&C(e.body,t,n),we(t);return}if(e.type===`ForStatement`||e.type===`ForInStatement`||e.type===`ForOfStatement`){Ve(`for`,e,t),Ue(e,t),we(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);we(t);return}if(e.type===`TSModuleDeclaration`){let n=Ve(`ts-module`,e,t);if(e.id&&S(e.id,`Identifier`)){let r=e.id;Te(xe(n.parent??t.currentScope),t,{name:r.name,kind:`ts-module`,bindingIdentifier:r,declarationNode:e,initializer:null})}e.body&&C(e.body,t,n),we(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);we(t);return}if(e.type===`BlockStatement`&&Ie(e)){let n=Ve(`block`,e,t);for(let r of e.body)C(r,t,n);we(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 ye(e)){let e=n[i];if(Array.isArray(e))for(let n of e)b(n)&&C(n,t,r);else b(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=1024,Je=2e6,Ye=1e3,w=e=>{let t=e.parent;for(;t;){if(x(t))return t;t=t.parent??null}return null},Xe=e=>S(e,`Identifier`)?e.name:S(e,`Literal`)&&typeof e.value==`string`?e.value:null,Ze=e=>{if(S(e,`ImportSpecifier`)){let t=e.imported;return S(t,`Identifier`)?t.name:S(t,`Literal`)&&typeof t.value==`string`?t.value:null}return S(e,`ImportDefaultSpecifier`)?`default`:null},Qe=(e,t)=>{if(!S(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=$e(r,t,n);if(e)return e}return null},$e=(e,t,n)=>{if(!S(e,`ExportSpecifier`)||e.exportKind===`type`||Xe(e.exported)!==t)return null;let r=Xe(e.local);return r?{importedName:r,source:n}:null},et=(e,t)=>{if(!S(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},tt=(e,t)=>{if(!S(e,`Program`))return[];let n=[];for(let r of e.body??[]){let e=Qe(r,t);if(e)return[e];let i=et(r,t);i&&n.push(i)}return n},T=(e,t)=>{if(e){if(S(e,`Identifier`)){t.add(e.name);return}if(S(e,`AssignmentPattern`)){T(e.left,t);return}if(S(e,`RestElement`)){T(e.argument,t);return}if(S(e,`ArrayPattern`)){for(let n of e.elements??[])T(n,t);return}if(S(e,`ObjectPattern`))for(let n of e.properties??[]){if(S(n,`RestElement`)){T(n.argument,t);continue}S(n,`Property`)&&T(n.value,t)}}},nt=(e,t,n)=>{if(e&&!S(e,`Identifier`)){if(S(e,`AssignmentPattern`)){E(e.right,t,n),nt(e.left,t,n);return}if(S(e,`RestElement`)){nt(e.argument,t,n);return}if(S(e,`ArrayPattern`)){for(let r of e.elements??[])nt(r,t,n);return}if(S(e,`ObjectPattern`))for(let r of e.properties??[]){if(S(r,`RestElement`)){nt(r.argument,t,n);continue}S(r,`Property`)&&(r.computed&&E(r.key,t,n),nt(r.value,t,n))}}},rt=(e,t,n)=>{if(!S(e,`FunctionDeclaration`)&&!S(e,`FunctionExpression`)&&!S(e,`ArrowFunctionExpression`))return;let r=new Set(n);for(let t of e.params??[])T(t,r);for(let n of e.params??[])nt(n,t,r);E(e.body,t,r)},E=(e,t,n)=>{if(!e)return;if(S(e,`Identifier`)){n.has(e.name)||t.add(e.name);return}if(S(e,`MemberExpression`)){E(e.object,t,n),e.computed&&E(e.property,t,n);return}if(S(e,`Property`)){e.computed&&E(e.key,t,n),E(e.value,t,n);return}if(S(e,`FunctionDeclaration`)||S(e,`FunctionExpression`)||S(e,`ArrowFunctionExpression`)){rt(e,t,n);return}if(S(e,`TSAsExpression`)||S(e,`TSSatisfiesExpression`)||S(e,`TSTypeAssertion`)||S(e,`TSNonNullExpression`)||S(e,`TSInstantiationExpression`)){E(e.expression,t,n);return}if(typeof e.type==`string`&&e.type.startsWith(`TS`))return;let r=e;for(let e of Object.keys(r)){if(e===`parent`||he.has(e))continue;let i=r[e];if(Array.isArray(i))for(let e of i)b(e)&&E(e,t,n);else b(i)&&E(i,t,n)}},it=(e,t)=>E(e,t,new Set),at=e=>{let t=[],n=new Set;if(S(e,`VariableDeclaration`))for(let r of e.declarations??[])S(r.init,`AwaitExpression`)&&(r.init.argument&&t.push(r.init.argument),T(r.id,n));else if(S(e,`ExpressionStatement`)){let r=e.expression;S(r,`AwaitExpression`)?r.argument&&t.push(r.argument):S(r,`AssignmentExpression`)&&S(r.right,`AwaitExpression`)&&(r.right.argument&&t.push(r.right.argument),S(r.left,`Identifier`)&&n.add(r.left.name))}else S(e,`ReturnStatement`)&&S(e.argument,`AwaitExpression`)?e.argument.argument&&t.push(e.argument.argument):S(e,`ForOfStatement`)&&e.await&&(e.right&&t.push(e.right),T(S(e.left,`VariableDeclaration`)?e.left.declarations?.[0]?.id??null:e.left,n));return t.length===0?null:{awaitedExpressions:t,boundNames:[...n]}},ot=(e,t)=>{if(S(e,`VariableDeclaration`))for(let n of e.declarations??[])T(n.id,t)},st=(e,t,n)=>{let r=new Map,i=[];for(let a of e.body??[]){let e=at(a);if(!e){let e=new Set;if(ot(a,e),e.size===0)continue;let t=new Set;it(a,t);let n=new Set;for(let e of t)for(let t of r.get(e)??[])n.add(t);if(n.size===0)continue;for(let t of e)r.set(t,n);continue}if(n&&!e.awaitedExpressions.every(e=>n(e))){r.clear(),i.length=0;continue}let o=new Set;for(let t of e.awaitedExpressions)it(t,o);let s=new Set;for(let e of o)for(let t of r.get(e)??[])s.add(t);if(i.filter((e,t)=>!s.has(t)).length+1>=t)return a;let c=i.length;i.push(s);let l=new Set(s);l.add(c);for(let t of e.boundNames)r.set(t,l)}return null},ct=e=>{if(e.kind!==`import`)return null;let t=e.declarationNode.parent;return S(t,`ImportDeclaration`)?t:null},lt=new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`,`TSNonNullExpression`,`TSInstantiationExpression`,`ChainExpression`]),D=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}},O=e=>{let t=e;for(;t.parent&<.has(t.parent.type);)t=t.parent;return t},ut=e=>{if(S(e,`FunctionDeclaration`)&&S(e.id,`Identifier`))return e.id;let t=O(e),n=t.parent;return S(n,`VariableDeclarator`)&&n.init===t&&S(n.id,`Identifier`)?n.id:null},k=e=>{let t=e.property;return!e.computed&&S(t,`Identifier`)?t.name:e.computed&&S(t,`Literal`)?typeof t.value==`string`?t.value:null:e.computed&&S(t,`TemplateLiteral`)&&t.expressions.length===0?t.quasis[0]?.value.cooked??t.quasis[0]?.value.raw??null:null},dt=e=>{let t=O(e);return!!(t.parent&&S(t.parent,`AwaitExpression`)&&t.parent.argument===t)},A=(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=D(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},ft=(e,t)=>{if(!x(e)||e.async||!S(e.body,`BlockStatement`))return!1;let[n,r,i,a,o]=e.body.body.toReversed();if(!S(o,`VariableDeclaration`)||o.kind!==`const`||o.declarations.length!==1||!S(a,`IfStatement`)||a.alternate||!S(i,`VariableDeclaration`)||i.kind!==`const`||i.declarations.length!==1||!S(r,`ExpressionStatement`)||!S(n,`ReturnStatement`))return!1;let s=o.declarations[0],c=i.declarations[0];if(!s?.init||!c?.init||!n.argument)return!1;let l=D(s.init),u=D(r.expression);if(!S(l,`CallExpression`)||!S(u,`CallExpression`)||!S(l.callee,`MemberExpression`)||!S(u.callee,`MemberExpression`)||l.optional||u.optional||l.callee.optional||u.callee.optional||k(l.callee)!==`get`||k(u.callee)!==`set`||l.arguments.length!==1||u.arguments.length!==2)return!1;let d=A(l.callee.object,t);if(d?.kind!==`const`||!d.initializer||w(d.bindingIdentifier)||A(u.callee.object,t)!==d)return!1;let f=D(d.initializer);if(!S(f,`NewExpression`)||!S(f.callee,`Identifier`)||![`Map`,`WeakMap`].includes(f.callee.name)||!t.isGlobalReference(f.callee)||f.arguments.length!==0)return!1;let p=a.consequent;if(S(p,`BlockStatement`)){if(p.body.length!==1)return!1;p=p.body[0]}let m=t.symbolFor(s.id),h=t.symbolFor(c.id),g=l.arguments[0],_=u.arguments[0],v=u.arguments[1];if(!m||!h||!S(p,`ReturnStatement`)||!p.argument||!g||!_||!v||t.symbolFor(D(a.test))!==m||t.symbolFor(D(p.argument))!==m||t.symbolFor(D(v))!==h||t.symbolFor(D(n.argument))!==h)return!1;let y=A(D(g),t);if(!y||y.references.some(e=>e.flag!==`read`)||y.kind!==`parameter`||w(y.bindingIdentifier)!==e||A(D(_),t)!==y)return!1;let ee=l.callee.object,te=u.callee.object;return d.references.every(e=>e.flag===`read`&&(e.identifier===ee||e.identifier===te))},pt=e=>{let t=e;for(;t;){if(S(t,`Program`))return t;t=t.parent??null}return null},mt=new WeakMap,ht=(e,t)=>{t.push(...e.symbols);for(let n of e.children)ht(n,t)},gt=e=>{let t=new Map,n=[];ht(e.rootScope,n);for(let r of n){let n=A(r.bindingIdentifier,e);if(!n)continue;let i=t.get(n.id)??[];i.push(r),t.set(n.id,i)}return t},_t=(e,t)=>{let n=A(e,t);if(!n)return[];let r=mt.get(t);return r||(r=gt(t),mt.set(t,r)),r.get(n.id)??[]},j=(e,t={})=>{if(!S(e,`Property`)&&!S(e,`MethodDefinition`)&&!S(e,`PropertyDefinition`)&&!S(e,`MemberExpression`))return null;let n=S(e,`MemberExpression`)?e.property:e.key;if(e.computed)return t.allowComputedString&&S(n,`Literal`)&&typeof n.value==`string`?n.value:t.allowComputedString&&t.stringifyNonStringLiterals&&S(n,`Literal`)?String(n.value):t.allowComputedString&&S(n,`TemplateLiteral`)&&n.expressions.length===0?n.quasis[0]?.value.cooked??n.quasis[0]?.value.raw??null:null;if(S(n,`Identifier`))return n.name;if(S(n,`Literal`)){if(typeof n.value==`string`)return n.value;if(t.stringifyNonStringLiterals)return String(n.value)}return null},vt=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},M=(e,t,n={})=>{let r=j(e,{allowComputedString:!0,stringifyNonStringLiterals:n.stringifyNonStringLiterals});if(r!==null||!S(e,`Property`)&&!S(e,`MethodDefinition`)&&!S(e,`PropertyDefinition`)&&!S(e,`MemberExpression`)||!e.computed)return r;let i=D(S(e,`MemberExpression`)?e.property:e.key);if(!S(i,`Identifier`))return null;let a=A(i,t);if(a?.kind!==`const`||!a.initializer)return null;let o=D(a.initializer);return S(o,`Literal`)?typeof o.value==`string`?o.value:n.allowConstNumericLiteral&&typeof o.value==`number`?String(o.value):null:n.allowConstTemplateLiteral&&S(o,`TemplateLiteral`)?vt(o):null},yt=e=>{if(!x(e))return null;if(!S(e.body,`BlockStatement`))return e.body;if(e.body.body.length!==1)return null;let t=e.body.body[0];return S(t,`ReturnStatement`)&&t.argument?t.argument:null},bt=new Set([`CatchClause`,`ConditionalExpression`,`DoWhileStatement`,`ForInStatement`,`ForOfStatement`,`ForStatement`,`IfStatement`,`LogicalExpression`,`SwitchCase`,`SwitchStatement`,`TryStatement`,`WhileStatement`]),xt=(e,t)=>{let n=e.parent??null;for(;n&&n!==t;){if(bt.has(n.type))return!1;n=n.parent??null}return n===t},St=e=>w(e)??pt(e),Ct=e=>{let t=O(e),n=t.parent;return!!(n&&S(n,`VariableDeclarator`)&&n.init===t&&n.parent&&S(n.parent,`VariableDeclaration`)&&n.parent.kind===`const`)},wt=e=>{let t=O(e),n=t.parent;return!!(n&&(S(n,`AssignmentExpression`)&&n.left===t||S(n,`UpdateExpression`)&&n.argument===t||S(n,`UnaryExpression`)&&n.operator===`delete`&&n.argument===t))},Tt=e=>{let t=O(e),n=t.parent;return n&&S(n,`MemberExpression`)&&D(n.object)===t?n:null},Et=(e,t,n,r,i)=>{if(i<=0||!S(e,`ObjectExpression`))return null;for(let a of e.properties.toReversed()){if(!S(a,`Property`))return null;let e=M(a,n);if(e===null)return null;if(e===t)return a.kind===`init`?N(a.value,n,r,i-1):null}return null},Dt=(e,t,n,r,i)=>{if(i<=0||!S(e,`ObjectExpression`))return[];let a=[],o=new Set;for(let s of e.properties){if(!S(s,`Property`))continue;let e=M(s,n),c=s.kind===`init`||s.kind===`get`?N(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},Ot=(e,t,n,r,i)=>{if(i<=0||!S(e,`ClassDeclaration`)&&!S(e,`ClassExpression`))return null;for(let a of e.body.body.toReversed()){if(!S(a,`MethodDefinition`)&&!S(a,`PropertyDefinition`)||!a.static)continue;let e=M(a,n);if(e===null)return null;if(e===t)return S(a,`MethodDefinition`)&&a.kind!==`method`?null:a.value?N(a.value,n,r,i-1):null}return null},kt=(e,t,n,r,i)=>{if(i<=0||!S(e,`ClassDeclaration`)&&!S(e,`ClassExpression`))return[];let a=[],o=new Set;for(let s of e.body.body){if(!S(s,`MethodDefinition`)&&!S(s,`PropertyDefinition`)||!s.static)continue;let e=M(s,n),c=s.value&&(!S(s,`MethodDefinition`)||s.kind===`method`||s.kind===`get`)?N(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},At=(e,t,n,r,i,a,o,s)=>{let c=St(t);if(s<=0||!c||!S(e,`Identifier`))return{exactFunction:null,possibleFunctions:[]};let l=[];for(let r of _t(e,a))for(let e of r.references){let r=e.identifier;if(r.range[0]>=t.range[0]||Ct(r))continue;let i=Tt(r);if(!i){St(r)===c&&l.push({assignedExpression:null,isDefinite:!1,offset:r.range[0]});continue}if(!wt(i)||St(i)!==c)continue;let o=M(i,a),s=O(i).parent,u=s&&S(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||!S(s,`AssignmentExpression`)||s.operator!==`=`||!xt(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?N(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}},jt=(e,t,n,r)=>{if(r<=0||!S(e,`MemberExpression`))return{exactFunction:null,possibleFunctions:[]};let i=k(e);if(i===null)return{exactFunction:null,possibleFunctions:[]};let a=D(e.object);if(S(a,`ObjectExpression`))return{exactFunction:Et(a,i,t,n,r),possibleFunctions:Dt(a,i,t,n,r)};if(S(a,`ClassExpression`))return{exactFunction:Ot(a,i,t,n,r),possibleFunctions:kt(a,i,t,n,r)};if(!S(a,`Identifier`))return{exactFunction:null,possibleFunctions:[]};let o=A(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=D(o.initializer);s=Et(e,i,t,n,r),c=Dt(e,i,t,n,r)}else o.kind===`class`&&o.initializer&&(s=Ot(o.initializer,i,t,n,r),c=kt(o.initializer,i,t,n,r));return At(a,e,i,s,c,t,n,r)},Mt=(e,t,n,r)=>{if(r<=0)return[];let i=D(e);if(S(i,`CallExpression`)){let e=D(i.callee);return S(e,`MemberExpression`)&&k(e)===`bind`?Mt(e.object,t,n,r-1):[]}if(S(i,`MemberExpression`)){let e=k(i);return e===`call`||e===`apply`?Mt(i.object,t,n,r-1):jt(i,t,n,r).possibleFunctions}let a=N(i,t,n,r);return a?[a]:[]},N=(e,t,n,r)=>{let i=D(e);if(x(i))return i;if(r<=0)return null;if(S(i,`CallExpression`)){let e=D(i.callee);if(S(e,`MemberExpression`)&&k(e)===`bind`)return N(e.object,t,n,r-1);if(!i.arguments.every(e=>S(e,`Literal`)))return null;let a=N(e,t,n,r-1);if(!x(a)||a.async||a.generator||!a.params.every(e=>S(e,`Identifier`)))return null;let o=yt(a),s=o&&D(o);return x(s)?s:null}if(S(i,`MemberExpression`)){let e=k(i);return e===`call`||e===`apply`?N(i.object,t,n,r-1):jt(i,t,n,r).exactFunction}if(!S(i,`Identifier`))return null;let a=A(i,t);return!a||n.has(a.id)?null:(n.add(a.id),a.kind===`function`?!a.references.some(e=>e.flag!==`read`)&&x(a.declarationNode)?a.declarationNode:null:a.kind!==`const`||!a.initializer?null:N(a.initializer,t,n,r-1))},Nt=(e,t)=>N(e,t,new Set,15),Pt=(e,t)=>Mt(e,t,new Set,15),Ft=(e,t)=>{if(!S(e,`CallExpression`)||!S(e.callee,`MemberExpression`)||k(e.callee)!==`join`)return!1;let n=D(e.callee.object);for(let e=0;e<15;e++){if(S(n,`ArrayExpression`))return!0;if(S(n,`Identifier`)){let e=A(n,t);if(!e?.initializer||e.references.some(e=>e.flag!==`read`))return!1;n=D(e.initializer);continue}if(!S(n,`CallExpression`))return!1;let e=D(n.callee);if(S(e,`MemberExpression`)&&[`map`,`filter`,`slice`].includes(k(e)??``)){n=D(e.object);continue}let r=Nt(e,t);return!!(x(r)&&!r.async&&S(r.returnType,`TSTypeAnnotation`)&&S(r.returnType.typeAnnotation,`TSArrayType`))}return!1},It=(e,t)=>{if(!S(e,`Program`))return null;let n=new Map,r=new Map,i=null,a=null,o=e=>{for(let t of e.declarations??[])S(t,`VariableDeclarator`)&&(!S(t.id,`Identifier`)||!t.init||n.set(t.id.name,D(t.init)))};for(let t of e.body??[]){if(S(t,`ImportDeclaration`)){if(t.importKind===`type`)continue;for(let e of t.specifiers??[])S(e,`ImportSpecifier`)&&e.importKind===`type`||(S(e,`ImportDefaultSpecifier`)||S(e,`ImportNamespaceSpecifier`)||S(e,`ImportSpecifier`))&&S(e.local,`Identifier`)&&n.set(e.local.name,e.local);continue}if(S(t,`VariableDeclaration`)){o(t);continue}if(S(t,`FunctionDeclaration`)&&t.id){n.set(t.id.name,t);continue}if(S(t,`ExportNamedDeclaration`)){if(t.exportKind===`type`)continue;let e=t.declaration;if(e&&S(e,`VariableDeclaration`)){o(e);for(let t of e.declarations??[])S(t,`VariableDeclarator`)&&S(t.id,`Identifier`)&&r.set(t.id.name,t.id.name)}else e&&S(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(!S(e,`ExportSpecifier`)||e.exportKind===`type`)continue;let t=S(e.local,`Identifier`)?e.local.name:null,n=null;S(e.exported,`Identifier`)?n=e.exported.name:S(e.exported,`Literal`)&&typeof e.exported.value==`string`&&(n=e.exported.value),t&&n&&r.set(n,t)}continue}if(!S(t,`ExportDefaultDeclaration`))continue;let e=t.declaration;e&&(S(e,`Identifier`)?a=e.name:((S(e,`FunctionDeclaration`)||S(e,`ClassDeclaration`))&&e.id&&n.set(e.id.name,e),i=D(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},Lt=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];b(i)&&t(i,e)}else b(r)&&t(r,e)}};t(e,null)};let P=null;const Rt=e=>{P?.existencePaths.add(e)},F=e=>{P?.contentPaths.add(e)},zt=()=>P!==null,Bt=e=>{let t=P,n={existencePaths:new Set,contentPaths:new Set};P=n;try{return{value:e(),trace:n}}finally{if(P=t,t!==null){for(let e of n.existencePaths)t.existencePaths.add(e);for(let e of n.contentPaths)t.contentPaths.add(e)}}},Vt=e=>{if(P!==null){for(let t of e.existencePaths)P.existencePaths.add(t);for(let t of e.contentPaths)P.contentPaths.add(t)}},Ht=e=>Bt(e).trace,Ut={".ts":`ts`,".tsx":`tsx`,".js":`js`,".jsx":`jsx`,".mjs":`js`,".cjs":`js`,".mts":`ts`,".cts":`ts`},Wt=e=>Ut[o.extname(e).toLowerCase()]??`tsx`;let Gt=process.platform!==`win32`&&n();const Kt=(e,t)=>({astType:`ts`,lang:Wt(e),experimentalRawTransfer:t}),qt=(e,n)=>{if(Gt)try{return t(e,n,Kt(e,!0))}catch{Gt=!1}return t(e,n,Kt(e,!1))},Jt=({filename:e,sourceText:t,shouldAttachParentReferences:n=!0})=>{try{let r=qt(e,t);if(r.errors.some(e=>e.severity===`Error`))return null;let i=r.program;return n&&Lt(i),i}catch{return null}},Yt=new Map,Xt=(e,t)=>{if(Yt.delete(e),Yt.set(e,t),Yt.size>256){let e=Yt.keys().next().value;e!==void 0&&Yt.delete(e)}},Zt=e=>{e.endsWith(`.d.ts`)||e.endsWith(`.d.mts`)||e.endsWith(`.d.cts`)||F(e);let t;try{t=i.statSync(e,{throwIfNoEntry:!1})}catch{return null}if(!t?.isFile()||t.size>2e6)return null;let n=Yt.get(e);if(n&&n.mtimeMs===t.mtimeMs&&n.size===t.size)return Xt(e,n),n.program;if(e.endsWith(`.d.ts`)||e.endsWith(`.d.mts`)||e.endsWith(`.d.cts`))return Xt(e,{mtimeMs:t.mtimeMs,size:t.size,program:null}),null;let r;try{r=i.readFileSync(e,`utf8`)}catch{return Xt(e,{mtimeMs:t.mtimeMs,size:t.size,program:null}),null}let a=Jt({filename:e,sourceText:r});return Xt(e,{mtimeMs:t.mtimeMs,size:t.size,program:a}),a},Qt=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.mts`,`.cts`],$t=[`import`,`default`,`module`,`browser`,`require`],en=[`module`,`main`,`browser`],tn={isDirectory:!0,isFile:!1},nn={isDirectory:!1,isFile:!0},rn={isDirectory:!1,isFile:!1},an=new Map,on=new Map,sn=e=>{Rt(e);let t=an.get(e);if(t)return t;let n=rn;try{let t=i.statSync(e,{throwIfNoEntry:!1});t?.isFile()?n=nn:t?.isDirectory()&&(n=tn)}catch{return an.set(e,rn),rn}return an.set(e,n),n},cn=e=>sn(e).isFile?e:null,ln=e=>sn(e).isDirectory?e:null,un=e=>{let t=o.extname(e);if(!Qt.includes(t))return Qt.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]},dn=e=>typeof e==`object`&&!!e,fn=e=>{if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=fn(t);if(e)return e}return null}if(!dn(e))return null;for(let t of $t){let n=fn(e[t]);if(n)return n}return null},pn=e=>{let t=e.exports;return t?fn(t)||(dn(t)?fn(t[`.`]):null):null},mn=e=>{F(e);let t=on.get(e);if(t!==void 0)return t;let n;try{n=JSON.parse(i.readFileSync(e,`utf8`))}catch{n=null}return on.set(e,n),n},hn=e=>_n(e)||_n(o.join(e,`index`)),gn=e=>{let t=ln(e);if(!t)return null;let n=mn(o.join(t,`package.json`));if(!n)return null;let r=pn(n)??en.map(e=>n[e]).find(e=>typeof e==`string`);return r?hn(o.resolve(t,r)):null},_n=e=>{let t=cn(e);if(t)return t;for(let t of un(e)){let e=cn(t);if(e)return e}return null},vn=e=>_n(e)||gn(e)||_n(o.join(e,`index`)),yn=(e,t)=>vn(o.resolve(o.dirname(e),t)),bn=()=>{an.clear(),on.clear()},xn=[`tsconfig.json`,`jsconfig.json`],Sn=e=>typeof e==`object`&&!!e,Cn=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`)},wn=(e,t)=>{F(e),t.push(e);let n;try{n=i.readFileSync(e,`utf8`)}catch{return null}try{let e=JSON.parse(Cn(n));return Sn(e)?e:null}catch{return null}},Tn=(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)},En=e=>{let t=new Map;if(!Sn(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},Dn=(e,t,n)=>{let r=wn(e,n);if(!r)return null;let i=o.dirname(e),a=Sn(r.compilerOptions)?r.compilerOptions:{},s=typeof a.baseUrl==`string`?a.baseUrl:null,c=s!==null,l=s===null?i:o.resolve(i,s);if(Sn(a.paths))return{baseAbsolutePath:l,hasExplicitBaseUrl:c,paths:En(a.paths)};if(typeof r.extends==`string`&&t<8){let e=Tn(r.extends,i),a=e?Dn(e,t+1,n):null;if(a)return a}return c?{baseAbsolutePath:l,hasExplicitBaseUrl:c,paths:new Map}:null},On=new Map,kn=new Map,An=e=>{F(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=On.get(e);if(n&&n.mtimeMs===t.mtimeMs){for(let e of n.probedChainPaths)F(e);return{config:n.config,probedContentPaths:new Set(n.probedChainPaths)}}let r=[],a=Dn(e,0,r);return On.set(e,{mtimeMs:t.mtimeMs,config:a,probedChainPaths:r}),{config:a,probedContentPaths:new Set(r)}},jn=(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);kn.set(a.directory,{config:t.config,directoryCount:i,probedContentPaths:new Set(r)})}},Mn=e=>{let t=kn.get(e);if(t!==void 0){for(let e of t.probedContentPaths)F(e);return t.config}let n=[],r=e;for(let e=0;e<30;e++){let t=kn.get(r),i=30-e;if(t!==void 0&&t.directoryCount<=i){for(let e of t.probedContentPaths)F(e);return jn(n,t,t.directoryCount),t.config}let a=new Set;for(let e of xn){let t=An(o.join(r,e));for(let e of t.probedContentPaths)a.add(e);if(t.config)return n.push({directory:r,probedContentPaths:a}),jn(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 jn(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 kn.set(e,{config:null,directoryCount:n.length,probedContentPaths:i}),null},Nn=(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},Pn=(e,t)=>{let n=Mn(o.dirname(e));if(!n)return null;let r=null,i=``,a=-1;for(let e of n.paths.keys()){let n=Nn(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=vn(o.resolve(n.baseAbsolutePath,t));if(r)return r}return n.hasExplicitBaseUrl?vn(o.resolve(n.baseAbsolutePath,t)):null},Fn=()=>{On.clear(),kn.clear()},In=(e,t)=>o.isAbsolute(t)?null:t.startsWith(`.`)?yn(e,t):Pn(e,t),Ln=new Map,Rn=()=>{Ln.clear()},zn=(e,t,n)=>{if(n.size>=4||n.has(e))return null;n.add(e);let r=Zt(e);if(!r)return null;let i=It(r,t);if(i)return{filePath:e,exportedNode:i,programNode:r};let a=new Map;for(let i of tt(r,t)){let t=In(e,i.source);if(!t)continue;let r=zn(t,i.importedName,new Set(n));r&&a.set(r.exportedNode,r)}return a.size===1?a.values().next().value??null:null},Bn=(e,t,n)=>Vn(e,t,n)?.functionNode??null,Vn=(e,t,n)=>{let r=I(e,t,n);return!r||!x(r.exportedNode)?null:{filePath:r.filePath,functionNode:r.exportedNode,programNode:r.programNode}},I=(e,t,n)=>{if(!zt()){let r=In(e,t);return r?zn(r,n,new Set):null}let r=`${e}\0${t}\0${n}`,i=Ln.get(r);if(i!==void 0){for(let e of i.trace.contentPaths)F(e);for(let e of i.trace.existencePaths)Rt(e);return i.result}let a=Bt(()=>{let r=In(e,t);return r?zn(r,n,new Set):null});return Ln.set(r,{result:a.value,trace:a.trace}),a.value},Hn=(e,t)=>{let n=e,r=ge[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];b(n)&&t.push(n)}else b(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];b(n)&&t.push(n)}else b(a)&&t.push(a)}},Un=(e,t)=>{let n=e,r=ge[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];b(n)&&t(n)}else b(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];b(n)&&t(n)}else b(r)&&t(r)}},L=(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||Hn(e,n)}},Wn=new WeakMap,Gn=new Set([`TSStringKeyword`,`TSNumberKeyword`,`TSBooleanKeyword`]),Kn=new Set([`String`,`Number`,`Boolean`]),qn=(e,t,n)=>{let r=[],i=15,a=(e,t,n,o,s,c)=>{let l=e=>{let r=A(D(e),o);return!r||r.references.some(e=>e.flag!==`read`)?null:t.has(r.bindingIdentifier)?t.get(r.bindingIdentifier)??null:n&&w(r.bindingIdentifier)===n?null:r.bindingIdentifier};L(e,e=>{if(x(e)||S(e,`ClassDeclaration`)||S(e,`ClassExpression`))return!1;if(c&&S(e,`AwaitExpression`)&&!S(D(e.argument),`CallExpression`)&&r.push({binding:e,member:null,inputs:[],crossFile:!0}),!S(e,`CallExpression`))return;let n=D(e.callee);if(e.optional||S(n,`MemberExpression`)&&n.optional)return c&&r.push({binding:e,member:null,inputs:[],crossFile:!0}),!1;let u=e.arguments.map(l),d=S(n,`MemberExpression`)?D(n.object):n,f=A(d,o),p=S(n,`Identifier`)&&(f?.kind===`function`||x(f?.initializer))?Nt(n,o):null,m=o,h=s,g=c;if(f?.kind===`import`){let e=S(n,`MemberExpression`)?k(n):null,t=f.declarationNode,a=ct(f),o=null;if(S(t,`ImportNamespaceSpecifier`)?o=e:S(n,`Identifier`)&&(o=Ze(t)),s&&i>0&&o&&a&&a.importKind!==`type`&&(!S(t,`ImportSpecifier`)||t.importKind!==`type`)){i--;let e=Vn(s,a.source.value,o);e&&(p=e.functionNode,m=Wn.get(e.programNode)??Ge(e.programNode),Wn.set(e.programNode,m),h=e.filePath,g=!0)}!p&&!c&&(S(n,`Identifier`)||e!==null)&&r.push({binding:f.bindingIdentifier,member:e,inputs:u})}else if(!c&&S(n,`MemberExpression`)&&k(n)===`get`&&f?.kind===`const`&&f.initializer){let e=D(f.initializer);if(S(e,`NewExpression`)&&S(e.callee,`Identifier`)&&(e.callee.name===`Map`||e.callee.name===`WeakMap`)&&o.isGlobalReference(e.callee)){let e=l(d);e&&r.push({binding:e,member:`get`,inputs:[u[0]??null]})}}if(g&&p){let t=ut(p),n=t?m.symbolFor(t):null;if(n&&(n.kind!==`const`&&n.kind!==`function`||n.references.some(e=>e.flag!==`read`)))return r.push({binding:e,member:null,inputs:[],crossFile:!0}),!1}if(g&&p&&ft(p,m))return r.push({binding:p,member:null,inputs:u,crossFile:!0}),!1;if(!x(p)||i<=0){c&&(i<=0||f?.kind===`import`||dt(e)||S(e.parent,`ReturnStatement`)&&!Ft(e,o)&&!(S(n,`Identifier`)&&Kn.has(n.name)&&o.isGlobalReference(n))||S(n,`Identifier`)&&n.name===`fetch`&&o.isGlobalReference(n))&&r.push({binding:e,member:null,inputs:[],crossFile:!0});return}if(c&&!p.async&&!dt(e)&&(!S(e.parent,`ReturnStatement`)||S(p.returnType,`TSTypeAnnotation`)&&Gn.has(p.returnType.typeAnnotation.type)))return;i--;let _=new Map(t);for(let[e,t]of p.params.entries()){let n=m.symbolFor(t);n&&_.set(n.bindingIdentifier,u[e]??null)}a(p.body,_,p,m,h,g)})};for(let r of at(e)?.awaitedExpressions??[])a(r,new Map,null,t,n,!1);return r},Jn=(e,t,n,r)=>{let i=qn(e,n,r);if(i.length===0)return!1;let a=qn(t,n,r),o=e=>i.some(t=>t.binding===e.binding&&t.member===e.member&&t.inputs.length>0&&t.inputs.length===e.inputs.length&&t.inputs.every((t,n)=>t!==null&&t===e.inputs[n]));return a.some(o)&&(!a.some(e=>e.crossFile)||a.every(o))},Yn=`(?:tsx?|jsx?|mts|mjs)`,Xn=RegExp(`/page\\.${Yn}$`),Zn=RegExp(`/(page|layout)\\.${Yn}$`),Qn=[`layout.tsx`,`layout.jsx`,`layout.ts`,`layout.js`,`layout.mts`,`layout.mjs`],$n=[`metadata`,`generateMetadata`],er=/\/(?:(?:\((?:dashboard|admin|settings|account|internal|manage|console|portal|auth|onboarding|app|ee|protected)\))|(?:dashboard|admin|settings|account|internal|manage|console|portal))\//i,tr=new Set([`redirect`,`permanentRedirect`,`notFound`,`forbidden`,`unauthorized`]),nr=new Set([`revalidateTag`,`revalidatePath`,`expireTag`,`expirePath`,`unstable_expireTag`,`unstable_expirePath`]),rr=/fonts\.googleapis\.com/,ir=/polyfill\.io|polyfill\.min\.js|cdn\.polyfill/,ar=RegExp(`/route\\.${Yn}$`),or=/\/(?:cron|jobs\/cron)(?:\/|$)/i,sr=new Set([`logout`,`log-out`,`signout`,`sign-out`,`unsubscribe`,`delete`,`remove`,`revoke`,`cancel`,`deactivate`]),cr=RegExp(`/(error|global-error)\\.${Yn}$`),lr=RegExp(`/global-error\\.${Yn}$`),ur=new Set([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`OPTIONS`,`HEAD`]),dr=/google-analytics\.com|googletagmanager\.com\/gtag/,fr=RegExp(`/(opengraph-image|twitter-image)\\d*\\.${Yn}$`),pr=new Set([`expo`,`expo-router`,`@expo/cli`,`@expo/metro-config`,`@expo/metro-runtime`]),mr=new Set([`react-native`,`react-native-tvos`,...pr,`react-native-windows`,`react-native-macos`]),hr=[`@react-native/`,`@react-native-`],gr=e=>pr.has(e),_r=e=>{if(mr.has(e))return!0;for(let t of hr)if(e.startsWith(t))return!0;return!1},vr=new Map,yr=new Map;let br=0;const xr=()=>{vr.clear(),yr.clear(),br+=1},Sr=()=>br,Cr=e=>{if(!e)return null;let t=o.dirname(e),n=vr.get(t);if(n!==void 0){if(zt()){let e=t;for(;Rt(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`);Rt(e);let n=!1;try{n=i.statSync(e,{throwIfNoEntry:!1})?.isFile()??!1}catch{n=!1}if(n)return vr.set(t,r),r;let a=o.dirname(r);if(a===r)return vr.set(t,null),null;r=a}},wr=e=>{let t=Cr(e);return t?Tr(t):null},Tr=e=>{let t=yr.get(e);if(t!==void 0&&!zt())return t;let n=o.join(e,`package.json`);if(F(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 yr.set(e,r),r},Er=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`]),Dr=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`],Or=function*(e){for(let t of Dr){let n=e[t];if(n)for(let e of Object.keys(n))yield e}},kr=e=>{if(typeof e[`react-native`]==`string`)return!0;for(let t of Or(e))if(_r(t))return!0;return!1},Ar=e=>{for(let t of Or(e))if(gr(t))return!0;return!1},jr=e=>{for(let t of Or(e))if(Er.has(t))return!0;return!1},Mr=e=>Dr.some(t=>{let n=e[t];return typeof n==`object`&&!!n&&Object.keys(n).length>0}),Nr=(e,t)=>Dr.some(n=>{let r=e[n];return typeof r==`object`&&!!r&&Object.prototype.propertyIsEnumerable.call(r,t)}),Pr=new WeakMap,Fr=e=>{let t=wr(e);if(!t)return`unknown`;let n=Pr.get(t);if(n!==void 0)return n;let r;return r=Ar(t)?`expo`:kr(t)?`react-native`:jr(t)?`web`:Mr(t)?`neutral`:`unknown`,Pr.set(t,r),r},Ir=({absoluteFilePath:e,staticImports:t,program:n})=>{let r=new Set;if(L(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&&Bn(e,n.moduleRequest.value,a)}},Lr=e=>e.replace(/^type\s+/,``).trim(),Rr=(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=Lr(r??``);return{localName:a,exportedName:Lr(i??a),isTypeOnly:n}}),zr=/\/\*[\s\S]*?\*\//g,Br=/^\s*\/\/.*$/gm,Vr=e=>e.replace(zr,``).replace(Br,``),Hr=/^\s*export\s+default\b/m,Ur=/^\s*export\s+(?:declare\s+)?(?:(?:async\s+)?function|(?:abstract\s+)?class|const|let|var|enum|interface|type)\s+([\w$]+)/gm,Wr=/^\s*export\s+(?:type\s+)?\{([\s\S]*?)\}(?:\s+from\s+["'][^"']+["'])?\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,Gr=e=>{let t=Vr(e),n=new Set;Hr.test(t)&&n.add(`default`);for(let e of t.matchAll(Ur))e[1]&&n.add(e[1]);for(let e of t.matchAll(Wr)){let t=e[1]??``;for(let e of Rr(t,!1))n.add(e.exportedName)}return n},Kr=new Map,qr=(e,t)=>{F(e);try{let n=i.statSync(e,{throwIfNoEntry:!1});if(n===void 0)return!1;let r=Kr.get(e);if(r&&r.mtimeMs===n.mtimeMs&&r.size===n.size)return r.exportedNames.has(t);let a=Gr(i.readFileSync(e,`utf8`));return Kr.set(e,{mtimeMs:n.mtimeMs,size:n.size,exportedNames:a}),a.has(t)}catch{return!1}},Jr=(e,t)=>{let n=e.replaceAll(`\\`,`/`),r=o.dirname(n);for(let e=0;e<30;e++){for(let e of Qn){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},Yr=e=>Jr(e,e=>$n.some(t=>qr(e,t))),R=e=>{if(!S(e,`ImportSpecifier`))return;let t=e.imported;if(S(t,`Identifier`))return t.name;if(S(t,`Literal`)&&typeof t.value==`string`)return t.value},Xr=e=>S(e,`JSXIdentifier`)?e.name===`Suspense`:S(e,`JSXMemberExpression`)&&S(e.property,`JSXIdentifier`)&&e.property.name===`Suspense`,Zr=e=>{let t=!1;return L(e,e=>{if(t)return!1;if(S(e,`JSXOpeningElement`)&&Xr(e.name)||S(e,`ImportDeclaration`)&&e.source?.value===`react`&&(e.specifiers??[]).some(e=>S(e,`ImportSpecifier`)&&R(e)===`Suspense`))return t=!0,!1}),t},Qr=e=>Jr(e,e=>{let t=Zt(e);return!!(t&&Zr(t))}),$r=e=>{if(S(e,`ImportDeclaration`)){if(e.importKind===`type`||e.specifiers.length>0&&e.specifiers.every(e=>S(e,`ImportSpecifier`)&&e.importKind===`type`))return null}else if(S(e,`ExportNamedDeclaration`)){if(e.exportKind===`type`||!e.source||e.specifiers.length>0&&e.specifiers.every(e=>S(e,`ExportSpecifier`)&&e.exportKind===`type`))return null}else if(S(e,`ExportAllDeclaration`)){if(e.exportKind===`type`)return null}else return null;return e.source&&typeof e.source.value==`string`?e.source.value:null},ei=/^index\.(?:[cm]?[jt]sx?|mjs)$/,ti=/^\s*import\s+(type\s+)?(?!["'])([^;]*?)\s+from\s+["']([^"']+)["']\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,ni=/^\s*export\s+(type\s+)?(?:\*(?:\s+as\s+([\w$]+))?|\{([\s\S]*?)\})\s+from\s+["']([^"']+)["']\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,ri=/^\s*export\s+(type\s+)?\{([\s\S]*?)\}\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,ii=new Map,ai=e=>ei.test(o.basename(e)),oi=()=>({isBarrel:!1,exportsByName:new Map,starExportSources:[]}),si=(e,t)=>{e.set(t.localName,{...t,didExport:!1})},ci=(e,t,n,r)=>{for(let i of Rr(e,n))si(r,{localName:i.exportedName,importedName:i.localName,source:t,isTypeOnly:i.isTypeOnly})},li=(e,t,n,r)=>{let i=e.trim(),a=i.match(/(?:^|,\s*)\*\s+as\s+([\w$]+)/);a?.[1]&&si(r,{localName:a[1],importedName:`*`,source:t,isTypeOnly:n});let o=i.match(/\{([\s\S]*?)\}/);o?.[1]&&ci(o[1],t,n,r);let s=i.split(`,`)[0]?.trim();s&&!s.startsWith(`{`)&&!s.startsWith(`*`)&&si(r,{localName:s,importedName:`default`,source:t,isTypeOnly:n})},ui=(e,t,n,r)=>{let i=e.replace(ti,(e,n,r,i)=>(li(r,i,!!n,t),``));return i=i.replace(ni,(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 Rr(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(ri,(e,r,i)=>{for(let a of Rr(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},di=e=>{for(let t of e.values())if(!t.isTypeOnly&&!t.didExport)return!0;return!1},fi=e=>{let t=Vr(e).trim();if(!t)return oi();let n=new Map,r=new Map,i=[];return ui(t,n,r,i).trim()||di(n)?oi():{isBarrel:r.size>0||i.length>0,exportsByName:r,starExportSources:i}},pi=e=>{if(!ai(e))return oi();F(e);let t;try{t=i.statSync(e,{throwIfNoEntry:!1})??null}catch{t=null}let n=ii.get(e);if(n!==void 0&&t!==null&&n.mtimeMs===t.mtimeMs&&n.size===t.size)return n.moduleInfo;if(t===null)return oi();let r=oi();try{r=fi(i.readFileSync(e,`utf8`))}catch{r=oi()}return ii.set(e,{mtimeMs:t.mtimeMs,size:t.size,moduleInfo:r}),r},mi=e=>pi(e).isBarrel,hi=o.join(`android`,`gradle.properties`),gi=/^\s*newArchEnabled\s*=\s*false\s*$/m,_i=[`app.config.ts`,`app.config.js`,`app.config.cjs`,`app.config.mjs`],vi=[`app.config.json`,`app.json`],yi=new WeakMap,bi=e=>{F(o.join(e,hi));for(let t of _i)Rt(o.join(e,t));for(let t of vi)F(o.join(e,t))},xi=e=>{try{return i.readFileSync(e,`utf-8`)}catch{return null}},Si=e=>{let t=e.dependencies?.[`react-native`]??e.devDependencies?.[`react-native`];return typeof t==`string`?t:null},Ci=e=>{let t=e.match(/(?:^|[^\d.])0\.(\d+)/);return t?Number.parseInt(t[1],10):null},wi=e=>{let t=xi(o.join(e,hi));return t!==null&&gi.test(t)},Ti=e=>{for(let t of _i)if(i.existsSync(o.join(e,t)))return!1;for(let t of vi){let n=xi(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},Ei=(e,t)=>{let n=Si(t);if(n!==null){let e=Ci(n);if(e!==null&&e<76)return!0}return wi(e)||Ti(e)},Di=e=>{let t=Cr(e);if(!t)return!1;let n=wr(e);if(!n)return!1;bi(t);let r=yi.get(n);if(r!==void 0)return r;let i=Ei(t,n);return yi.set(n,i),i},Oi=new Map;let ki=Sr();const Ai=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},ji=(e,t)=>e.major-t.major||e.minor-t.minor||e.patch-t.patch||Number(t.isPrerelease)-Number(e.isPrerelease),Mi=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=Ai(r);if(!i)return null;n.push(i)}return n.reduce((e,t)=>ji(t,e)<0?t:e)},Ni=e=>Mi(e.dependencies?.ink??e.devDependencies?.ink??e.peerDependencies?.ink??e.optionalDependencies?.ink),Pi=e=>{let t=e;for(;;){let e=Tr(o.join(t,`node_modules`,`ink`));if(e)return{didFindPackage:!0,version:typeof e.version==`string`?Ai(e.version):null};let n=o.dirname(t);if(n===t)return{didFindPackage:!1,version:null};t=n}},Fi=e=>{let t=Pi(e);if(t.didFindPackage)return t.version;let n=Tr(e);return n?Ni(n):null},Ii=e=>{if(!e)return null;let t=Cr(o.resolve(e));if(!t)return null;let n=Sr();n!==ki&&(Oi.clear(),ki=n);let r=Oi.get(t);if(r)return Vt(r.trace),r.version;let{value:i,trace:a}=Bt(()=>Fi(t));return Oi.set(t,{version:i,trace:a}),i},Li=(e,t)=>{let n=Ii(e),r=Ai(t);return!!(n&&r&&ji(n,r)>=0)},Ri=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`]),zi=new Set([`fetch`,`ky`,`got`,`wretch`,`ofetch`]),Bi=new Set([`axios`,`ky`,`got`,`ofetch`,`wretch`,`request`]),Vi=new Set([`create`,`insert`,`insertInto`,`update`,`upsert`,`delete`,`remove`,`destroy`,`set`,`append`]),Hi=new Set([`POST`,`PUT`,`DELETE`,`PATCH`]),Ui=new Set([`Map`,`Set`,`WeakMap`,`WeakSet`,`Headers`,`URLSearchParams`,`FormData`,`Response`,`NextResponse`]),Wi=new Set([`Response`,`NextResponse`]),Gi=new Set([`json`,`redirect`,`next`,`rewrite`,`error`]),Ki=new Set([`wheel`,`mousewheel`,`touchstart`,`touchmove`]),qi=new Set([`defer`,`async`]),Ji=new Set([`text/javascript`,`application/javascript`,`module`]),Yi=new Set([`setTimeout`,`setInterval`,`requestAnimationFrame`,`requestIdleCallback`,`queueMicrotask`]),Xi=new Set([`setInterval`,`setTimeout`]),Zi=new Set([`clearInterval`,`clearTimeout`]),Qi=new Set([`WebSocket`,`EventSource`,`BroadcastChannel`,`RTCPeerConnection`]),$i=new Set([`location`,`window`,`document`,`navigator`,`history`,`screen`,`performance`]),ea=new Set([`IntersectionObserver`,`MutationObserver`,`ResizeObserver`,`PerformanceObserver`]),ta=new Set([`blur`,`canPlayType`,`focus`,`getBoundingClientRect`,`getClientRects`,`measure`,`measureInWindow`,`measureLayout`,`scroll`,`scrollBy`,`scrollIntoView`,`scrollTo`,`select`,`setRangeText`,`setSelectionRange`]),na=new Set([`localStorage`,`sessionStorage`]),ra=new Set([`index`,`idx`,`i`]),ia=new Set([`react`,`react-dom`,`preact/compat`,`preact/hooks`,`@wordpress/element`]),aa=new Set([`next`,`next-themes`,`@remix-run/react`,`swr`,`zustand`,`jotai`,`recoil`,`wouter`,`framer-motion`,`@apollo/client`,`urql`,`usehooks-ts`]),oa=new Set([`useState`,`useMemo`,`useRef`]),sa=new Set([`Click`,`Change`,`Input`,`Blur`,`Focus`]),ca=new Set([`Boolean`,`String`,`Number`,`Array`,`Object`,`parseInt`,`parseFloat`]),la=/^set[A-Z]/,ua=/^render[A-Z]/,da=/^[A-Z]/,fa=/^on[A-Z]/,pa=/^use[A-Z]/,ma=/^(?:on|handle)[A-Z]/,ha=new Set([`useEffect`,`useLayoutEffect`]),ga=new Set([`useEffect`,`useLayoutEffect`,`useMemo`,`useCallback`]),_a=new Set([`use`,`useState`,`useRef`,`useMemo`,`useCallback`,`useReducer`,`useContext`,`useEffect`,`useLayoutEffect`,`useInsertionEffect`,`useImperativeHandle`,`useSyncExternalStore`,`useDeferredValue`,`useTransition`,`useId`,`useDebugValue`]),va=new Set([`memo`,`forwardRef`,`React.memo`,`React.forwardRef`]),ya=new Set([`useMemo`,`useCallback`]),ba=new Set([`memo`,`forwardRef`,`observer`,`lazy`]),xa=new Set([`subscribe`,`addEventListener`,`addListener`,`on`,`watch`,`listen`,`sub`]),Sa=new Set([`subscribe`,`sub`,`listen`]),Ca=new Set([`unsubscribe`,`removeEventListener`,`removeListener`,`off`,`unwatch`,`unlisten`,`unsub`,`abort`,`disconnect`,`unobserve`,`close`]),wa=new Set([`remove`,`cleanup`,`dispose`,`destroy`,`stop`,`teardown`]),Ta=new Set([...Ca,`cleanup`,`dispose`,`destroy`,`teardown`]),Ea=new Set([...xa,`connect`,`disconnect`,`open`,`close`,`fetch`,`post`,`put`,`patch`]),Da=new Set([`get`,`head`,`options`,`delete`]),Oa=new Set([...zi,...Yi]),ka=new Set([...zi,`post`,`put`,`patch`,`navigate`,`navigateTo`,`showNotification`,`toast`,`alert`,`confirm`,`logVisit`,`captureEvent`]),Aa=new Set([`post`,`put`,`patch`,`delete`,`navigate`,`capture`,`track`,`logEvent`]),ja=new Set([`push`,`replace`]),Ma=new Set([`router`,`navigation`,`navigator`,`history`,`location`]),Na={},Pa=new WeakMap,Fa=(e,t)=>typeof e==`string`?e===t:e.has(t),Ia=e=>{let t=Pa.get(e);if(t)return t;let n=e.declarationNode.parent,r=!!(e.kind===`import`&&n&&n.type===`ImportDeclaration`&&typeof n.source.value==`string`&&ia.has(n.source.value)),i={importedName:r?R(e.declarationNode):void 0,isReactImport:r};return Pa.set(e,i),i},La=e=>Ia(e).isReactImport,Ra=(e,t,n,r)=>{if(e.type!==`Identifier`)return!1;let i=r?A(e,n):n.symbolFor(e);if(!i)return!1;let a=Ia(i);return!!(a.isReactImport&&a.importedName&&Fa(t,a.importedName))},za=(e,t)=>{let n=A(e,t);if(!n)return!1;let r=Ia(n);return r.isReactImport?n.declarationNode.type===`ImportDefaultSpecifier`||n.declarationNode.type===`ImportNamespaceSpecifier`||r.importedName===`default`:!1},Ba=(e,t,n)=>e.type===`Identifier`?za(e,t)?!0:!!(n.allowGlobalReactNamespace&&e.name===`React`&&t.isGlobalReference(e)):!1,Va=(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&&Fa(t,a)&&Ba(D(i.initializer),n,r))}return!1},Ha=(e,t,n,r=Na)=>e.type===`CallExpression`?Ua(e.callee,t,n,r):!1,Ua=(e,t,n,r,i)=>{let a=D(e);if(r.resolveConditionalAliases&&a.type===`ConditionalExpression`)return Ua(a.consequent,t,n,r,new Set(i))&&Ua(a.alternate,t,n,r,new Set(i));if(a.type===`Identifier`){if(Ra(a,t,n,!!r.resolveNamedAliases)||r.resolveNamedAliases&&Va(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),Ua(e.initializer,t,n,r,a)}}return!!(r.allowUnboundBareCalls&&Fa(t,a.name)&&n.isGlobalReference(a))}return a.type!==`MemberExpression`||!Fa(t,k(a)??``)?!1:Ba(D(a.object),n,r)},z=e=>e.includes(`\\`)?e.replaceAll(`\\`,`/`):e,Wa=e=>{let t=new Set(e);if(t.size!==1)return null;let[n]=t;return n??null},Ga=(e,t,n,r)=>{let i=yn(e,n);return i?Ka(i,t,new Set(r))||(qr(i,t)?i:null):null},Ka=(e,t,n=new Set)=>{if(n.has(e))return null;n.add(e);let r=pi(e);if(!r.isBarrel)return null;let i=r.exportsByName.get(t);if(i){let t=yn(e,i.source);return t?Ka(t,i.importedName,n)??t:null}return t===`default`?null:Wa(r.starExportSources.map(r=>Ga(e,t,r,n)).filter(e=>!!e))},qa=(e,t,n)=>{let r=I(e,t,n);return r?{filePath:r.filePath,node:r.exportedNode,programNode:r.programNode,kind:x(r.exportedNode)?`function`:`initializer`}:null},Ja=(e,t)=>{if(!S(e,`ArrowFunctionExpression`)&&!S(e,`FunctionExpression`)&&!S(e,`FunctionDeclaration`))return null;let n=e.params[0],r=S(n,`AssignmentPattern`)?n.left:n;if(S(r,`ObjectPattern`)){let e=r.properties.find(e=>S(e,`Property`)&&j(e,{allowComputedString:!0})===`children`);if(!e||!S(e,`Property`))return null;let n=S(e.value,`AssignmentPattern`)?e.value.left:e.value;if(!S(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(!S(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=O(e.identifier);for(;n.parent&&S(n.parent,`MemberExpression`)&&n.parent.object===n;){let e=k(n.parent);if(!e)return null;t.push(e),n=O(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},Ya=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},Xa=new WeakMap,Za=e=>{let t=pt(e);if(!t)return null;let n=Xa.get(t);return n||(n=Ya(t),Xa.set(t,n)),n},Qa=(e,t)=>{let n=Za(e);if(!n)return!1;for(let e of n.values())if(t.includes(e.source))return!0;return!1},$a=(e,t,n)=>{let r=Za(e);if(!r)return!1;let i=r.get(t);return i?i.source===n:!1},eo=(e,t,n)=>{let r=Za(e);if(!r)return!1;let i=r.get(t);return i?i.isNamespace&&i.source===n:!1},to=(e,t,n)=>{let r=Za(e);if(!r)return!1;let i=r.get(t);return i?i.isDefault&&i.source===n:!1},no=(e,t,n)=>{let r=Za(e);if(!r)return null;let i=r.get(t);return!i||i.source!==n?null:i.imported},ro=(e,t)=>{let n=Za(e);return n?n.get(t)?.source??null:null},io=(e,t)=>{let n=Za(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},ao=e=>{let t=e,n=t.parent;for(;n&&D(n)===e;)t=n,n=t.parent;return n&&S(n,`AssignmentExpression`)&&n.operator===`=`&&n.left===t?n.right:null},oo=e=>{let t=e.range?.[0];return typeof t==`number`?t:null},so=new Set([`let`,`var`]),co=new Set([`ConditionalExpression`,`LogicalExpression`]),lo=new WeakMap,uo=(e,t,n)=>{let r=e.parent??null;for(;r&&n.blockOf(r)===t;){if(co.has(r.type))return!0;r=r.parent??null}return!1},fo=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),po=(e,t)=>{let n=new Set(e);for(let e of t)e.isConditionalWithinBlock||(n=new Set),n.add(e);return n},mo=(e,t,n)=>{let r=w(t);if(w(e.bindingIdentifier)!==r||!r)return[];let i=n.cfgFor(r);if(!i)return[];let a=i.blockOf(t);if(!a)return[];let o=oo(t),s=oo(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:uo(t,r,i)}),c.set(r,a)};e.initializer&&l(e.initializer,e.bindingIdentifier,s);for(let t of e.references){let e=oo(t.identifier);if(t.flag===`read`||w(t.identifier)!==r||e===null||e>=o)continue;let n=ao(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=po(t,c.get(e)??[]),r=u.get(e)??new Set,i=d.get(e)??new Set;(!fo(t,r)||!fo(n,i))&&(u.set(e,t),d.set(e,n),m=!0)}}let h=(c.get(a)??[]).filter(e=>e.position<o);return[...po(u.get(a)??new Set,h)].map(e=>e.expression)},ho=(e,t,n)=>{if(!so.has(e.kind))return e.initializer?[e.initializer]:[];if(!n)return[];let r=lo.get(n);r||(r=new WeakMap,lo.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=mo(e,t,n);return i.set(t,o),o},go=e=>{if(!x(e)||!S(e.body,`BlockStatement`))return[];let t=[];return L(e.body,n=>{if(n!==e.body&&(x(n)||S(n,`ClassDeclaration`)||S(n,`ClassExpression`)))return!1;S(n,`ReturnStatement`)&&t.push(n)}),t},B=e=>{if(S(e,`ReturnStatement`)||S(e,`ThrowStatement`))return!0;if(S(e,`IfStatement`)){if(S(e.test,`Literal`)){let t=e.test.value?e.consequent:e.alternate;return t?B(t):!1}return!!(e.alternate&&B(e.consequent)&&B(e.alternate))}if(S(e,`TryStatement`))return e.finalizer&&B(e.finalizer)?!0:B(e.block)?e.handler?B(e.handler.body):!0:!1;if(S(e,`DoWhileStatement`))return B(e.body);if(S(e,`WhileStatement`)){let t=e.test;return!!(S(t,`Literal`)&&t.value&&B(e.body))}if(S(e,`ForStatement`)){let t=e.test;return!!((!t||S(t,`Literal`)&&t.value)&&B(e.body))}return S(e,`BlockStatement`)?e.body.some(e=>B(e)):!1},_o=new Set([`let`,`var`]),vo=e=>!x(e)||!e.body?[]:S(e.body,`BlockStatement`)?go(e).flatMap(e=>e.argument?[e.argument]:[]):[e.body],yo=e=>{if(!x(e)||!S(e.body,`BlockStatement`))return!1;let t=!1;return L(e.body,n=>{if(t||n!==e.body&&x(n))return!1;S(n,`ReturnStatement`)&&!n.argument&&(t=!0)}),t},bo=(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=vo(e);return r===`every`&&x(e)&&S(e.body,`BlockStatement`)&&(!B(e.body)||yo(e))?!1:t.length>0&&(r===`every`?t.every(o):t.some(o))}finally{a.delete(e)}};o=a=>{let l=D(a);if(i.has(l))return!1;i.add(l);try{if(t(l))return!0;if(S(l,`Identifier`)){let t=e.symbolFor(l);if(!t||t.kind!==`const`&&!_o.has(t.kind))return!1;let i=ho(t,l,n),a=e=>{let t=D(e);return!x(t)&&o(t)};return r===`every`?i.length>0&&i.every(a):i.some(a)}if(S(l,`CallExpression`)){if(l.arguments.length!==0||!S(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?D(t.initializer):null,r=null;return x(n)?r=n:x(t.declarationNode)&&(r=t.declarationNode),!r||r.async||r.generator||r.params.length!==0?!1:s(r)}return S(l,`ConditionalExpression`)?c(l.consequent,l.alternate):S(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}},xo=(e,t,n,r,i=`some`)=>bo(t,n,r,i).functionMatches(e),So=(e,t,n,r,i)=>{let a=i.cfgFor(e),o=a?.blockOf(t);if(!a||!o)return!1;let s=new Set(go(e).flatMap(e=>{if(!e.argument||!bo(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},Co=e=>S(e,`Program`)?e.range[1]:e.range[0],wo=new WeakMap,To=(e,t)=>{let n=D(e);return S(n,`Identifier`)?t.symbolFor(n):null},Eo=(e,t)=>{let n=O(e),r=n.parent;return!r||!S(r,`AssignmentExpression`)||r.operator!==`=`||r.left!==n?null:To(r.right,t)},Do=e=>{let t=O(e),n=t.parent;return n&&S(n,`VariableDeclarator`)&&n.init===t&&(S(n.id,`Identifier`)||S(n.id,`ObjectPattern`))?!0:!!(n&&S(n,`AssignmentExpression`)&&n.operator===`=`&&n.right===t&&S(D(n.left),`Identifier`))},Oo=(e,t,n)=>{if(e.initializer&&S(e.declarationNode,`VariableDeclarator`)&&e.declarationNode.id===e.bindingIdentifier){let r=To(e.initializer,n);if(r&&t.has(r.id))return!0}return e.references.some(e=>{let r=Eo(e.identifier,n);return!!(r&&t.has(r.id))})},ko=(e,t)=>{let n=A(e,t);if(!n)return[];let r=wo.get(t);r||(r=new Map,wo.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)||Oo(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},Ao=e=>{let t=e;for(;t;){if(x(t)||S(t,`Program`))return t;t=t.parent??null}return null},jo=new WeakMap,Mo=(e,t)=>{let n=jo.get(t);if(!n){let r=new Map,i=new Map,a=pt(e);a&&L(a,e=>{if(!S(e,`CallExpression`))return;let n=D(e.callee),a=S(n,`Identifier`)?t.symbolFor(n):null,o=a?i.get(a.id):void 0;o===void 0&&(o=Pt(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,jo.set(t,n)}return n.get(e)??[]},No=new WeakMap,Po=(e,t)=>{let n=No.get(t);if(n===void 0){let e=null;L(t,n=>{S(n,`AwaitExpression`)&&w(n)===t&&(e===null||n.range[0]<e)&&(e=n.range[0])}),n=e,No.set(t,n)}return n===null||e.range[0]<n},Fo=(e,t,n,r=new Set,i=null,a)=>{if(r.has(e)||!x(e)||e.generator||i!==null&&!xt(i,e)||i!==null&&a!==void 0&&!a(i)||i!==null&&e.async&&!Po(i,e))return[];r.add(e);let o=Ao(t);return o?Mo(e,n).flatMap(e=>{let s=Ao(e);return!s||i!==null&&!xt(e,s)||i!==null&&a!==void 0&&!a(e)?[]:s===o?e.range[0]<Co(t)?[[e.range[0]]]:[]:x(s)?Fo(s,t,n,new Set(r),i===null?null:e,a).map(t=>[...t,e.range[0]]):[]}):[]},Io=(e,t,n,r=new Set,i=null)=>Fo(e,t,n,r,i).length>0,Lo=e=>{let t=e.parent;return t?S(t,`AssignmentExpression`)?t.left===e:(S(t,`UpdateExpression`)||S(t,`UnaryExpression`)&&t.operator===`delete`)&&t.argument===e:!1},Ro=e=>{let t=e.parent;for(;t&&D(t)===e;)t=t.parent;return!t||!S(t,`MemberExpression`)||D(t.object)!==e||!Lo(t)?null:t},zo=(e,t,n)=>{let r=Ro(e);return r&&M(r,n)===t?r:null},Bo=(e,t,n,r)=>e.references.some(e=>{let i=zo(e.identifier,t,r);if(!i)return!1;let a=Ao(i),o=Ao(n);return!a||!o||!xt(i,a)?!1:a===o?i.range[0]<Co(n):x(a)&&Io(a,n,r)}),Vo=e=>{if(Do(e))return!0;let t=O(e),n=t.parent;return!!(n&&S(n,`MemberExpression`)&&D(n.object)===t)},Ho=e=>{if(Do(e))return!0;let t=O(e),n=t.parent;if(!n||!S(n,`MemberExpression`)||D(n.object)!==t)return!1;let r=O(n),i=r.parent;return!(i&&S(i,`CallExpression`)&&i.callee===r)},Uo=(e,t,n)=>S(e,`Identifier`)?ko(e,n).some(e=>e.references.some(e=>{let r=Ro(e.identifier);if(!r)return!1;let i=M(r,n);return i===null||i===t})):!1,Wo=(e,t,n)=>{let r=Ao(e),i=Ao(t);return!r||!i?!0:r===i?e.range[0]<Co(t):x(r)?Io(r,t,n):!0},Go=(e,t,n,r)=>S(e,`Identifier`)?ko(e,r).some(e=>e.references.some(e=>{let i=Ro(e.identifier);if(!i||!Wo(i,n,r))return!1;let a=M(i,r);return a===null||a===t})):!1,Ko=(e,t,n)=>S(e,`Identifier`)?Uo(e,t,n)?!0:ko(e,n).some(e=>e.references.some(e=>!Vo(e.identifier))):!1,qo=(e,t,n,r)=>S(e,`Identifier`)?Go(e,t,n,r)?!0:ko(e,r).some(e=>e.references.some(e=>!Ho(e.identifier)&&Wo(e.identifier,n,r))):!1,Jo=(e,t)=>{let n=D(e);if(!S(n,`CallExpression`))return!1;let r=D(n.callee);if(!S(r,`MemberExpression`))return!1;let i=k(r);if(i===null)return!1;let a=D(r.object);return S(a,`Identifier`)&&Uo(a,i,t)},Yo=(e,t,n,r)=>S(e,`Identifier`)?_t(e,r).some(e=>Bo(e,t,n,r)):!1,Xo=(e,t,n,r={})=>{let i=w(e);return i===w(t)?e.range[0]>=Co(t)||r.requireSynchronousWrite&&(!i||!xt(e,i)||r.isSynchronousNode!==void 0&&!r.isSynchronousNode(e))?[]:[[e.range[0]]]:i?r.requireSynchronousWrite?Fo(i,t,n,new Set,e,r.isSynchronousNode).map(t=>[...t,e.range[0]]):Fo(i,t,n).map(t=>[...t,e.range[0]]):r.requireSynchronousWrite?[]:[[-1/0,e.range[0]]]},Zo=(e,t,n,r={})=>Xo(e,t,n,r).length>0,V=(e,t,n,r={})=>e.references.some(e=>e.flag===`read`?!1:Zo(e.identifier,t,n,r)),Qo=(e,t)=>{if(!S(e,`CallExpression`))return!1;let n=D(e.callee);if(S(n,`Identifier`)){let e=t.symbolFor(n);return!!(e&&!V(e,n,t))}if(!S(n,`MemberExpression`))return!1;let r=k(n),i=D(n.object);return!!(r&&S(i,`Identifier`)&&!Yo(i,r,n,t))},$o=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`ClassDeclaration`,`ClassExpression`]),es={allowGlobalReactNamespace:!1,allowUnboundBareCalls:!1},ts=new Set([`lodash/sortBy`,`lodash/sortBy.js`,`lodash-es/sortBy`,`lodash-es/sortBy.js`]),ns=e=>S(e,`TSArrayType`)||S(e,`TSTupleType`)?!0:S(e,`TSTypeReference`)?S(e.typeName,`Identifier`)&&(e.typeName.name===`Array`||e.typeName.name===`ReadonlyArray`):!1,rs=e=>{if(!S(e,`Identifier`))return!1;let t=e.typeAnnotation;return!!(t&&S(t,`TSTypeAnnotation`)&&ns(t.typeAnnotation))},is=(e,t)=>{if(!S(e,`CallExpression`))return!1;let n=D(e.callee);if(!S(n,`Identifier`))return!1;let r=t.symbolFor(n);if(!r||V(r,n,t)||!S(r.declarationNode,`ImportDefaultSpecifier`)&&!S(r.declarationNode,`ImportSpecifier`))return!1;let i=io(n,n.name);return!i||i.isNamespace?!1:ts.has(i.source)&&i.exportedName===`default`?!0:(i.source===`lodash`||i.source===`lodash-es`)&&i.exportedName===`sortBy`},as=(e,t,n,r=new Set)=>{let i=D(e);if(S(i,`ArrayExpression`)||is(i,t))return!0;if(!S(i,`Identifier`))return!1;let a=t.symbolFor(i);return!a||r.has(a.id)||V(a,n,t)?!1:rs(a.bindingIdentifier)?!0:a.initializer?(r.add(a.id),as(a.initializer,t,n,r)):!1},os=(e,t)=>{if(!S(e,`CallExpression`))return!1;let n=D(e.callee);if(!S(n,`MemberExpression`)||k(n)!==`map`)return!1;let r=D(n.object);return as(r,t,e)?!(S(r,`Identifier`)&&Yo(r,`map`,e,t)):!1},ss=(e,t)=>{if(e.type!==`ArrowFunctionExpression`&&e.type!==`FunctionExpression`)return!1;let n=e.parent;return S(n,`CallExpression`)?Ha(n,`useMemo`,t,{resolveNamedAliases:!0})&&Qo(n,t)?n.arguments[0]===e:n.arguments.some(t=>t===e)&&os(n,t):!1},cs=(e,t)=>$o.has(e.type)&&!ss(e,t),ls=(e,t)=>e.type===`JSXElement`||e.type===`JSXFragment`||Ha(e,`createElement`,t,es)||us(e,t),us=(e,t)=>{if(!S(e,`CallExpression`))return!1;let n=D(e.callee);if(S(n,`Identifier`))return t.symbolFor(n)?.kind===`import`&&no(n,n.name,`react-dom`)===`createPortal`;if(!S(n,`MemberExpression`)||n.computed||!S(n.object,`Identifier`)||!S(n.property,`Identifier`)||n.property.name!==`createPortal`)return!1;let r=t.symbolFor(n.object);return!r||r.kind!==`import`?!1:to(n.object,n.object.name,`react-dom`)||eo(n.object,n.object.name,`react-dom`)},ds=(e,t)=>{let n=!1;return L(e,r=>{if(n||r!==e&&cs(r,t))return!1;if(ls(r,t))return n=!0,!1}),n},fs=new WeakMap,ps=(e,t,n)=>{let r=fs.get(e);if(r&&r.scopes===t&&r.controlFlow===n)return r.hasRenderOutput;let i=xo(e,t,e=>ds(e,t),n);return fs.set(e,{scopes:t,controlFlow:n,hasRenderOutput:i}),i},ms=e=>S(e,`JSXIdentifier`)?e.name:S(e,`JSXNamespacedName`)?`${e.namespace.name}:${e.name.name}`:null,hs=new Set([`Component`,`PureComponent`]),gs=(e,t,n,r)=>{let i=D(e);if(S(i,`MemberExpression`)){let e=k(i),n=D(i.object);return!!(e&&hs.has(e)&&S(n,`Identifier`)&&!Yo(n,e,i,t)&&za(n,t))}if(S(i,`ClassExpression`))return _s(i,t,n,r);if(!S(i,`Identifier`))return!1;let a=t.symbolFor(i);if(!a||r.has(a.id)||V(a,i,t))return!1;if(r.add(a.id),La(a)){let e=R(a.declarationNode);return!!(e&&hs.has(e))}return S(a.declarationNode,`ClassDeclaration`)||S(a.declarationNode,`ClassExpression`)?_s(a.declarationNode,t,n,r):!!(a.kind===`const`&&a.initializer&&gs(a.initializer,t,n,r))},_s=(e,t,n=new Set,r=new Set)=>!S(e,`ClassDeclaration`)&&!S(e,`ClassExpression`)||n.has(e)||!e.superClass?!1:(n.add(e),gs(e.superClass,t,n,r)),vs=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`MethodDefinition`,`Program`]),ys=e=>{let t=e;for(;t;){if(vs.has(t.type))return t;t=t.parent??null}return null},bs=(e,t)=>{if(t!==`let`&&t!==`const`)return ys(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`)?ys(e):n}if(vs.has(n.type))return n;n=n.parent??null}return null},xs=(e,t,n,r)=>{if(S(e,`Identifier`)){let i=r.get(e.name)??[];i.push({bindingIdentifier:e,initializer:t,scopeOwner:n}),r.set(e.name,i);return}if(S(e,`ObjectPattern`)){for(let t of e.properties)if(S(t,`Property`)){let e=t.value;xs(e,S(e,`AssignmentPattern`)?e.right:null,n,r)}else S(t,`RestElement`)&&xs(t.argument,null,n,r);return}if(S(e,`ArrayPattern`)){for(let t of e.elements)t&&xs(t,S(t,`AssignmentPattern`)?t.right??null:null,n,r);return}if(S(e,`AssignmentPattern`)){xs(e.left,e.right??null,n,r);return}S(e,`RestElement`)&&xs(e.argument,null,n,r)},Ss=e=>{let t=new Map;return L(e,e=>{switch(e.type){case`VariableDeclarator`:{let n=e.parent,r=bs(e,n?.type===`VariableDeclaration`?n.kind:void 0);r&&xs(e.id,e.init??null,r,t);break}case`FunctionDeclaration`:case`FunctionExpression`:case`ArrowFunctionExpression`:if(e.type!==`ArrowFunctionExpression`&&e.id){let n=e.parent?ys(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)xs(n,null,e,t);break;case`ClassDeclaration`:case`ClassExpression`:{if(!e.id)break;let n=e.parent?ys(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=ys(e);if(!n)break;for(let r of e.specifiers){let e=r.local;if(e&&S(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=ys(e);if(r){let e=t.get(n.name)??[];e.push({bindingIdentifier:n,initializer:null,scopeOwner:r}),t.set(n.name,e)}}break}}}),t},Cs=new WeakMap,ws=new WeakMap,Ts=e=>{let t=pt(e);if(!t)return null;let n=Cs.get(t);return n||(n=Ss(t),Cs.set(t,n)),n},Es=(e,t,n)=>{let r=Ts(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&&(S(r.initializer,`FunctionDeclaration`)||r.bindingIdentifier.range[0]<e.range[0]));if(n!==!!(t.initializer&&(S(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},Ds=(e,t,n)=>{let r=ws.get(e),i;if(!r)i={},ws.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=Es(e,t,n);return i[a]=o,o},Os=e=>da.test(e),ks=e=>{let t=Ds(e,e.name);if(!t?.initializer)return null;let n=t.bindingIdentifier.parent;if(!n||!S(n,`VariableDeclarator`)||n.id!==t.bindingIdentifier)return null;let r=n.parent;if(!r||!S(r,`VariableDeclaration`)||r.kind!==`const`)return null;let i=D(t.initializer);return S(i,`Literal`)&&typeof i.value==`string`?i.value:null},As=e=>S(e,`JSXIdentifier`)?e.name:S(e,`JSXMemberExpression`)?`${As(e.object)}.${e.property.name}`:S(e,`JSXNamespacedName`)?`${e.namespace.name}:${e.name.name}`:``,js=e=>{let t=e.name;return S(t,`JSXIdentifier`)?Os(t.name)?ks(t)??t.name:t.name:As(t)},Ms=(e,t)=>{if(!S(e.name,`JSXIdentifier`))return!1;let n=js(e);if(n[0]===n[0]?.toLowerCase())return!0;let r=new Set,i=e=>{let n=O(e);if(S(n,`Literal`))return typeof n.value==`string`;if(S(n,`Identifier`)||S(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 S(n,`ConditionalExpression`)?i(n.consequent)&&i(n.alternate):!1};return i(e.name)},Ns=(e,t,n=new Set)=>{if(!e)return null;let r=D(e);if(x(r))return r;if(S(r,`Identifier`)){let e=t.symbolFor(r);return!e||n.has(e.id)||!e.initializer||V(e,r,t)?null:(n.add(e.id),Ns(e.initializer,t,n))}if(!S(r,`CallExpression`)||!Ha(r,`memo`,t,{resolveNamedAliases:!0})&&!Ha(r,`forwardRef`,t,{resolveNamedAliases:!0}))return null;let i=r.arguments[0];return!i||S(i,`SpreadElement`)?null:Ns(i,t,n)},Ps=(e,t)=>{let n=O(e);if(!x(n)||n.async||n.generator)return!1;let r=n.parent;if(!r||!S(r,`JSXExpressionContainer`))return!1;let i=r.parent;if(!i||!S(i,`JSXAttribute`)||ms(i.name)!==`ref`)return!1;let a=i.parent;return!!(a&&S(a,`JSXOpeningElement`)&&Ms(a,t))},Fs=(e,t)=>t.every((t,n)=>e[n]===t),Is=e=>{let t=O(e);for(;t.parent&&S(t.parent,`MemberExpression`)&&t.parent.object===t;){if(!k(t.parent))return null;t=O(t.parent)}return t},Ls=(e,t,n,r)=>{if(t.length!==n.length+1||!Fs(t,n)||t[n.length]!==`current`)return!1;let i=Is(e),a=i?.parent;if(!i||!a||!S(a,`AssignmentExpression`)||a.operator!==`=`||a.left!==i)return!1;let o=w(e);if(!o)return!1;if(Ps(o,r))return!0;if(!x(o)||o.async||o.generator)return!1;let s=w(o);if(!s||!Ps(s,r))return!1;let c=O(o),l=c.parent;return!!(S(l,`ReturnStatement`)&&l.argument===c&&w(l)===s||S(s,`ArrowFunctionExpression`)&&s.body===c)},Rs=(e,t)=>{if(!S(e,`JSXOpeningElement`))return!1;let n=e.name;if(S(n,`JSXIdentifier`)){if(!t)return n.name===`Fragment`;let e=A(n,t);return e?La(e)&&R(e.declarationNode)===`Fragment`:n.name===`Fragment`&&t.isGlobalReference(n)}return S(n,`JSXMemberExpression`)?!S(n.object,`JSXIdentifier`)||n.property.name!==`Fragment`?!1:t?za(n.object,t)?!0:n.object.name===`React`&&t.isGlobalReference(n.object):n.object.name===`React`:!1},zs=(e,t,n,r,i)=>{let a=O(e),o=a.parent;if(!o)return!1;if(S(o,`ReturnStatement`)&&o.argument===a)return w(o)===t;if(S(o,`ArrowFunctionExpression`)&&o.body===a)return o===t;if(S(o,`JSXFragment`)&&o.children.some(e=>e===a)||S(o,`JSXElement`)&&o.children.some(e=>e===a)&&(Ms(o.openingElement,n)||Rs(o.openingElement,n)||i.doesCustomElementRenderChildren?.(o.openingElement)))return zs(o,t,n,r,i);if(S(o,`JSXExpressionContainer`)&&o.expression===a&&o.parent&&(S(o.parent,`JSXFragment`)||S(o.parent,`JSXElement`)&&(Ms(o.parent.openingElement,n)||Rs(o.parent.openingElement,n)||i.doesCustomElementRenderChildren?.(o.parent.openingElement))))return zs(o.parent,t,n,r,i);if(S(o,`ConditionalExpression`)&&(o.consequent===a||o.alternate===a)||S(o,`LogicalExpression`)&&(o.left===a||o.right===a)||S(o,`ArrayExpression`)&&o.elements.some(e=>e===a))return zs(o,t,n,r,i);if(!S(o,`VariableDeclarator`)||o.init!==a||!S(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`&&zs(e.identifier,t,n,r,i));return r.delete(s.id),c},Bs=(e,t,n={})=>zs(e,w(e),t,new Set,n),Vs=(e,t)=>t.every((t,n)=>e[n]===t),Hs=(e,t)=>Vs(e,t)||Vs(t,e),Us=e=>x(e)&&S(e.body,`BlockStatement`)&&e.body.body.length===0,Ws=(e,t,n)=>Ha(e,t,n,{resolveNamedAliases:!0}),Gs=(e,t,n=new Set)=>S(e,`ObjectExpression`)?e.properties.every(e=>{if(S(e,`SpreadElement`)){let r=O(e.argument);if(S(r,`ObjectExpression`))return Gs(r,t,n);if(!S(r,`Identifier`))return!1;let i=t.symbolFor(r);if(!i||i.kind!==`const`||n.has(i.id)||!S(i.initializer,`ObjectExpression`))return!1;n.add(i.id);let a=Gs(i.initializer,t,n);return n.delete(i.id),a}return S(e,`Property`)?!x(e.value)||Us(e.value):!1}):!1,Ks=e=>k(e)||(e.computed&&S(e.property,`Literal`)&&typeof e.property.value==`number`&&Number.isSafeInteger(e.property.value)&&e.property.value>=0?String(e.property.value):null),qs=e=>{let t=[],n=O(e);for(;n.parent&&S(n.parent,`MemberExpression`)&&n.parent.object===n;){let e=Ks(n.parent);if(!e)return null;t.push(e),n=O(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},Ys=(e,t,n=new Set)=>{let r=O(e);if(S(r,`Identifier`)){let e=t.symbolFor(r);return!e||!e.initializer||n.has(e.id)||V(e,r,t)?!1:(n.add(e.id),Ys(e.initializer,t,n))}if(!S(r,`CallExpression`))return!1;if(Ws(r,`forwardRef`,t))return!0;if(!Ws(r,`memo`,t))return!1;let i=r.arguments[0];return!i||S(i,`SpreadElement`)?!1:Ys(i,t,n)},Xs=(e,t)=>{let n=Js(e.programNode,e.filePath,t),r=Ns(e.exportedNode,n.scopes);return r?{environment:n,functionNode:r,isForwardRef:Ys(e.exportedNode,n.scopes)}:null},Zs=(e,t,n)=>{if(!S(e,`Identifier`)&&!S(e,`JSXIdentifier`))return null;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`){if(V(r,e,t.scopes))return null;let n=Ns(r.initializer,t.scopes);return n?{environment:t,functionNode:n,isForwardRef:!!(r.initializer&&Ys(r.initializer,t.scopes))}:null}let i=io(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return null;let a=I(t.filename,i.source,i.exportedName);return a?Xs(a,n):null},Qs=(e,t,n)=>{if(S(e,`JSXIdentifier`))return Zs(e,t,n);if(!S(e,`JSXMemberExpression`)||!S(e.object,`JSXIdentifier`))return null;let r=io(e.object,e.object.name);if(!r?.isNamespace)return null;let i=I(t.filename,r.source,e.property.name);return i?Xs(i,n):null},$s=(e,t,n=new Set)=>{let r=O(e);if(S(r,`Identifier`)){let e=t.scopes.symbolFor(r);return!e||!e.initializer||n.has(e.id)||V(e,r,t.scopes)?!1:(n.add(e.id),$s(e.initializer,t,n))}return _s(r,t.scopes)},ec=(e,t,n)=>{if(!S(e,`JSXIdentifier`))return!1;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`)return V(r,e,t.scopes)?!1:!!(r.initializer&&$s(r.initializer,t));let i=io(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return!1;let a=I(t.filename,i.source,i.exportedName);if(!a)return!1;let o=Js(a.programNode,a.filePath,n);return $s(a.exportedNode,o)},tc=(e,t)=>{if(!e)return null;let n=O(e);return!S(n,`ClassDeclaration`)&&!S(n,`ClassExpression`)||!$s(n,t)?null:{classNode:n,environment:t}},nc=(e,t,n)=>{if(!S(e,`JSXIdentifier`))return null;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`)return V(r,e,t.scopes)?null:tc(r.initializer,t);let i=io(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return null;let a=I(t.filename,i.source,i.exportedName);if(!a)return null;let o=Js(a.programNode,a.filePath,n);return tc(a.exportedNode,o)},rc=(e,t,n)=>{let r=[...t],i=O(e);for(;i.parent;){let e=i.parent;if(S(e,`ArrayExpression`)){if(e.elements.some(e=>e&&S(e,`SpreadElement`)))return null;let t=e.elements.findIndex(e=>e===i);if(t<0)return null;r.unshift(String(t)),i=O(e);continue}if(S(e,`Property`)&&e.value===i){let t=j(e,{allowComputedString:!0}),a=e.parent;if(!t||!a||!Gs(a,n.scopes))return null;r.unshift(t),i=O(a);continue}if(S(e,`ConditionalExpression`)&&(e.consequent===i||e.alternate===i)||S(e,`LogicalExpression`)&&(e.left===i||e.right===i)){i=O(e);continue}if(S(e,`VariableDeclarator`)&&e.init===i&&S(e.id,`Identifier`)){let t=n.scopes.symbolFor(e.id);return!t||t.kind!==`const`?null:{environment:n,propertyPath:r,symbol:t}}if(S(e,`AssignmentExpression`)&&e.operator===`=`&&e.right===i&&S(e.left,`MemberExpression`)){let t=[],i=e.left;for(;S(i,`MemberExpression`);){let e=Ks(i);if(!e)return null;t.unshift(e),i=O(i.object)}if(!S(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},ic=(e,t,n,r,i)=>{if(S(e,`AssignmentPattern`))return ic(e.left,t,n,r,i);if(S(e,`Identifier`)){let a=n.scopes.symbolFor(e);return!!(a&&bc({environment:n,propertyPath:t,symbol:a},r,i-1))}if(!S(e,`ObjectPattern`)||t.length===0)return!1;let[a,...o]=t;for(let t of e.properties){if(!S(t,`Property`))continue;let e=j(t,{allowComputedString:!0});if(!e)return!1;if(e===a)return ic(t.value,o,n,r,i)}let s=e.properties.find(e=>S(e,`RestElement`));return s?ic(s.argument,t,n,r,i):!0},ac=(e,t)=>{let n=e.arguments[0];return!n||S(n,`SpreadElement`)?!1:Ws(e,`createElement`,t.scopes)?S(n,`Literal`)&&typeof n.value==`string`:!Ws(e,`cloneElement`,t.scopes)||!S(n,`JSXElement`)?!1:Ms(n.openingElement,t.scopes)},oc=(e,t,n,r,i)=>{if(t.length>0)return!1;let a=e.parent;if(!a||!S(a,`Property`)||a.value!==e||j(a,{allowComputedString:!0})!==`ref`)return!1;let o=a.parent;if(!o||!S(o,`ObjectExpression`))return!1;let s=o.parent;return!(!s||!S(s,`CallExpression`)||s.arguments[1]!==o||!ac(s,n)||!uc(s,n,r,i))},sc=(e,t,n,r,i)=>{if(i<=0||!x(e.functionNode)||e.functionNode.async||e.functionNode.generator)return!1;let a=e.functionNode.params[t];return!!(a&&ic(a,n,e.environment,r,i))},cc=e=>{if(!S(e,`MemberExpression`)||k(e)!==`children`)return!1;let t=O(e.object);return!!(S(t,`MemberExpression`)&&k(t)===`props`&&S(O(t.object),`ThisExpression`))},lc=(e,t)=>{if(!S(e,`JSXOpeningElement`)||!S(e.name,`JSXMemberExpression`)||e.name.property.name!==`Provider`||!S(e.name.object,`JSXIdentifier`))return!1;let n=t.scopes.symbolFor(e.name.object);return!!(n?.kind===`const`&&n.initializer&&S(n.initializer,`CallExpression`)&&Ws(n.initializer,`createContext`,t.scopes))},uc=(e,t,n,r)=>Bs(e,t.scopes,{doesCustomElementRenderChildren:e=>pc(e,t,n,r-1)}),dc=(e,t,n)=>{let{functionNode:r}=e;if(n<=0||t.activeRenderedChildrenComponents.has(r)||!S(r,`ArrowFunctionExpression`)&&!S(r,`FunctionExpression`)&&!S(r,`FunctionDeclaration`)||r.async||r.generator)return!1;let i=Ja(r,e.environment.scopes);if(!i)return!1;t.activeRenderedChildrenComponents.add(r);let a=i.every(r=>uc(r,e.environment,t,n));return t.activeRenderedChildrenComponents.delete(r),a},fc=(e,t,n)=>{let{classNode:r,environment:i}=e;if(n<=0||t.activeRenderedChildrenComponents.has(r)||!S(r,`ClassDeclaration`)&&!S(r,`ClassExpression`))return!1;let a=r.body.body.find(e=>S(e,`MethodDefinition`)&&!e.computed&&S(e.key,`Identifier`)&&e.key.name===`render`);if(!a||!S(a,`MethodDefinition`))return!1;let o=[];if(L(r,e=>{cc(e)&&o.push(e)}),o.length===0)return!1;t.activeRenderedChildrenComponents.add(r);let s=o.every(e=>w(e)===a.value&&uc(e,i,t,n));return t.activeRenderedChildrenComponents.delete(r),s},pc=(e,t,n,r)=>{if(r<=0||!S(e,`JSXOpeningElement`))return!1;if(lc(e,t))return!0;let i=Qs(e.name,t,n);if(i)return dc(i,n,r);let a=nc(e.name,t,n);return!!(a&&fc(a,n,r))},mc=(e,t,n,r,i)=>{let a=ms(e.name),o=e.parent;if(!a||!o||!S(o,`JSXOpeningElement`))return!1;let s=o.parent;if(!s||!S(s,`JSXElement`)||!uc(s,n,r,i))return!1;if(Ms(o,n.scopes))return a===`ref`&&t.length===0;if(S(o.name,`JSXIdentifier`)&&a===`ref`&&t.length===0&&ec(o.name,n,r))return!0;let c=Qs(o.name,n,r);return c?a===`ref`&&c.isForwardRef?sc(c,1,t,r,i):sc(c,0,[a,...t],r,i):!1},hc=(e,t,n,r,i,a)=>{let o=e.arguments.findIndex(e=>e===t);if(o<0)return!1;if(o===0&&S(e.callee,`Identifier`)&&e.callee.name===`Boolean`&&r.scopes.isGlobalReference(e.callee))return!0;if(o===0&&Ws(e,`useImperativeHandle`,r.scopes))return n.length===0;if(o===1&&n.length===1&&n[0]===`ref`&&ac(e,r)&&uc(e,r,i,a))return!0;let s=O(e.callee);if(x(s))return ps(s,r.scopes)&&!uc(e,r,i,a)?!1:sc({environment:r,functionNode:s,isForwardRef:!1},o,n,i,a);if(!S(e.callee,`Identifier`))return!1;let c=Zs(e.callee,r,i);return!!(c&&(!ps(c.functionNode,c.environment.scopes)||uc(e,r,i,a))&&sc(c,o,n,i,a))},gc=(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||!S(t,`Property`)||t.value!==e||j(t,{allowComputedString:!0})!==`ref`)return!1;a=t.parent?.parent}if(!a||!S(a,`JSXSpreadAttribute`))return!1;let o=a.parent;if(!o||!S(o,`JSXOpeningElement`))return!1;let s=o.parent;return!!(Ms(o,n.scopes)&&s&&S(s,`JSXElement`)&&uc(s,n,r,i))},_c=(e,t,n,r,i)=>{let a=O(e),o=a.parent;if(!o)return!1;if(S(o,`ExpressionStatement`)||S(o,`UnaryExpression`)&&o.operator===`void`&&o.argument===a)return!0;if(t.length===0&&S(o,`BinaryExpression`)&&(o.operator===`===`||o.operator===`!==`||o.operator===`==`||o.operator===`!=`)){let e=o.left===a?o.right:o.left;return!!(S(a,`Identifier`)&&S(e,`Identifier`)&&n.scopes.symbolFor(a)?.id===n.scopes.symbolFor(e)?.id)}if(gc(a,t,n,r,i)||oc(a,t,n,r,i)||t.length>0&&(S(o,`LogicalExpression`)&&o.left===a||S(o,`ConditionalExpression`)&&o.test===a||S(o,`IfStatement`)&&o.test===a||S(o,`UnaryExpression`)&&o.operator===`!`&&o.argument===a))return!0;if(S(o,`JSXExpressionContainer`)&&o.expression===a){let e=o.parent;return!!(e&&S(e,`JSXAttribute`)&&mc(e,t,n,r,i))}if(S(o,`CallExpression`))return hc(o,a,t,n,r,i);if(S(o,`VariableDeclarator`)&&o.init===a&&!S(o.id,`Identifier`))return ic(o.id,t,n,r,i);let s=rc(a,t,n);return!!(s&&bc(s,r,i-1))},vc=e=>{let t=e.parent;return t&&S(t,`VariableDeclarator`)&&t.init===e&&S(t.id,`Identifier`)?t.id:(S(e,`FunctionDeclaration`)||S(e,`FunctionExpression`))&&e.id?e.id:null},yc=(e,t,n)=>{if(!e||!t||!x(e)||e.async||e.generator)return!1;let r=vc(e);if(!r||((S(e,`FunctionDeclaration`)||S(e,`FunctionExpression`))&&e.id===r?w(e):w(r))!==t)return!1;let i=S(e,`FunctionDeclaration`)?n.ownScopeFor(t)?.symbolsByName.get(r.name):n.symbolFor(r);return!!(i&&i.references.length>0&&i.references.every(e=>{let r=O(e.identifier),i=r.parent;return!!(i&&S(i,`CallExpression`)&&i.callee===r&&w(i)===t&&Bs(i,n))}))},bc=(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=w(e.symbol.bindingIdentifier),a=e.symbol.references.every(r=>{if(r.identifier===e.originWriteReference)return!0;let a=r.identifier.parent;if(a&&S(a,`Property`)&&!a.computed&&a.key===r.identifier&&a.value!==r.identifier)return!0;let o=qs(r.identifier);if(!o)return!1;if(!Hs(o.propertyPath,e.propertyPath))return!0;let s=w(r.identifier);if(s!==i&&!yc(s,i,e.environment.scopes))return!!Ls(r.identifier,o.propertyPath,e.propertyPath,e.environment.scopes);if(r.flag!==`read`)return!1;if(Vs(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&&S(t,`UnaryExpression`)&&t.operator===`void`&&t.argument===o.expression)}return _c(o.expression,[],e.environment,t,n)}return _c(o.expression,e.propertyPath.slice(o.propertyPath.length),e.environment,t,n)});return t.activePaths.delete(r),a},xc=(e,t,n)=>{if(!t)return!1;let r=pt(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=rc(e,[],i);return o?bc(o,a,12):_c(e,[],i,a,12)},Sc=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},Cc=({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=yn(e,t);if(!(!a||!mi(a))){n||(n=!0,Fr(e));for(let e of i){let t=e.importName.kind===`Default`?`default`:e.importName.name;t&&Ka(a,t)}}}},wc=({absoluteFilePath:e})=>{Xn.test(e)&&(er.test(e)||Yr(e))},Tc=({absoluteFilePath:e,staticImports:t})=>{if(Zn.test(e)&&!Qr(e))for(let n of Sc(t))Bn(e,n.source,n.exportedName)},H=({absoluteFilePath:e,staticImports:t})=>{for(let n of Sc(t))Bn(e,n.source,n.exportedName)},Ec=({absoluteFilePath:e,staticImports:t})=>{for(let n of Sc(t))I(e,n.source,n.exportedName)},Dc=(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=$r(i);if(!e)continue;let a=In(t,e);if(!a||r>=8)continue;let o=r+1,s=n.get(a);if(s!==void 0&&s<=o)continue;let c=Zt(a);if(!c){n.set(a,o);continue}Dc(c,a,n,o)}}},Oc=e=>{Ec(e);let t=e.getProgram(),n=!1;L(t,e=>{if(n)return!1;if(!S(e,`CallExpression`))return;let t=D(e.callee);if(!S(t,`MemberExpression`))return;let r=k(t);n=r===`add`||r===`set`}),n&&Dc(t,e.absoluteFilePath,new Map,0)},kc=({absoluteFilePath:e,staticImports:t})=>{for(let n of Sc(t))qa(e,n.source,n.exportedName)},Ac=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},jc=({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 Ac(t)){let t=I(e,a.source,a.exportedName);!t||n===0||!r(t)||!i(t.filePath)||o(t.filePath,t.programNode,n-1)}}};for(let a of Sc(t)){let t=I(e,a.source,a.exportedName);!t||!r(t)||!i(t.filePath)||o(t.filePath,t.programNode,n)}},Mc=e=>{let t=e.getProgram();Lt(t);let n=Ge(t);L(t,t=>{if(S(t,`BlockStatement`))for(let[r,i]of t.body.entries()){let a=t.body[r+1];!S(i,`VariableDeclaration`)||!S(a,`VariableDeclaration`)||Jn(i,a,n,e.absoluteFilePath)}})},Nc=e=>{jc(e,4)},Pc=({absoluteFilePath:e,sourceText:t,getProgram:n})=>{if(!t.includes(`createRef`)&&!t.includes(`\\u`))return;let r=n();Lt(r);let i=Ge(r);L(r,t=>{!S(t,`CallExpression`)||!Ha(t,`createRef`,i,{allowGlobalReactNamespace:!0,allowUnboundBareCalls:!0,resolveNamedAliases:!0})||xc(t,e,i)})},Fc=({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(L(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(D(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&&Bn(e,t.moduleRequest.value,r)}},Ic=({absoluteFilePath:e,staticImports:t,getProgram:n})=>{Fr(e),Ir({absoluteFilePath:e,staticImports:t,program:n()})},U=({absoluteFilePath:e})=>{Fr(e)},Lc=e=>{U(e),kc(e)},Rc=e=>{U(e),jc(e,1/0,e=>x(e.exportedNode),e=>!e.split(/[\\/]/).includes(`node_modules`))},zc=({absoluteFilePath:e})=>{Di(e)},Bc=({absoluteFilePath:e})=>{Ii(e)},Vc=e=>{Bc(e),Ir({absoluteFilePath:e.absoluteFilePath,staticImports:e.staticImports,program:e.getProgram()})},Hc=new Map([...ee.map(e=>[e,Bc]),[`ink-no-raw-text`,Vc],[`client-passive-event-listeners`,H],[`effect-needs-cleanup`,H],[`exhaustive-deps`,Nc],[`no-barrel-import`,Cc],[`nextjs-async-dynamic-api-not-awaited`,U],[`nextjs-missing-metadata`,wc],[`nextjs-no-use-search-params-without-suspense`,Tc],[`no-dynamic-import-path`,U],[`no-full-lodash-import`,U],[`no-hydration-branch-on-browser-global`,Lc],[`no-indeterminate-attribute`,U],[`no-locale-format-in-render`,U],[`no-match-media-in-state-initializer`,U],[`no-create-ref-in-function-component`,Pc],[`no-adjust-state-on-prop-change`,H],[`no-derived-state`,H],[`no-derived-state-effect`,H],[`no-event-handler`,H],[`no-initialize-state`,H],[`no-reset-all-state-on-prop-change`,H],[`no-mutating-reducer-state`,Fc],[`no-side-effect-in-state-updater-function`,Oc],[`no-unguarded-browser-global-at-module-scope`,kc],[`no-unguarded-browser-global-in-render-or-hook-init`,Rc],[`prefer-dynamic-import`,U],[`rendering-hydration-mismatch-time`,U],[`rendering-hydration-no-flicker`,H],[`rerender-memo-with-default-value`,Nc],[`server-sequential-independent-await`,Mc],[`rn-no-legacy-shadow-styles`,zc],[`rn-no-raw-text`,Ic],[`rn-prefer-expo-image`,U],[`rn-style-prefer-boxshadow`,zc],...ie.map(e=>[e,U])]),Uc=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`]),Wc=e=>{let t=new Set;for(let n of e.ruleIds){let e=Hc.get(n);if(!e)return null;t.add(e)}let n=z(e.absoluteFilePath),r,i;try{let t=qt(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 Ht(()=>{for(let e of t)e(a)})},Gc={},Kc=(e,t,n)=>!e||e.length===0?!1:e.every(e=>S(e,t)&&e[n]===`type`),qc=e=>e.importKind===`type`||Kc(e.specifiers,`ImportSpecifier`,`importKind`),Jc=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`]),Yc=[`solid-js`,`@builder.io/qwik`],Xc=[`react`,`react-dom`,`preact`],Zc=new WeakMap,Qc=new WeakMap,$c=(e,t)=>t.some(t=>e===t||e.startsWith(`${t}/`)),el=e=>{let t=Zc.get(e);if(t)return t;let n=!1,r=!1,i=!1,a=!1,o=!1,s=!1;for(let t of e.body){if(i||L(t,e=>{if(i)return!1;if(S(e,`JSXOpeningElement`)&&tl(e))return i=!0,!1;S(e,`JSXOpeningElement`)&&S(e.name,`JSXIdentifier`)&&/^[a-z]/.test(e.name.name)&&e.attributes.some(e=>S(e,`JSXAttribute`)&&ms(e.name)===`class`)&&(s=!0)}),!S(t,`ImportDeclaration`))continue;let e=t,c=e.source,l=c&&typeof c.value==`string`?c.value:null;if(l){if(l===`solid-js`)for(let t of e.specifiers){if(!S(t,`ImportSpecifier`)||e.importKind!==`type`&&t.importKind!==`type`)continue;let n=R(t);n===`Component`&&(a=!0),n===`JSX`&&(o=!0)}qc(e)||((Jc.has(l)||$c(l,Yc))&&(n=!0),$c(l,Xc)&&(r=!0))}}let c={hasNonReactMarker:i||a||o&&s,hasNonReactRuntime:n,hasReactRuntime:r};return Zc.set(e,c),c},tl=e=>{let t=Qc.get(e);if(t!==void 0)return t;let n=!1;for(let t of e.attributes){if(!S(t,`JSXAttribute`))continue;let r=ms(t.name);if(r&&(r===`classList`&&S(t.value,`JSXExpressionContainer`)&&S(t.value.expression,`ObjectExpression`)||S(e.name,`JSXIdentifier`)&&/^[a-z]/.test(e.name.name)&&(r.startsWith(`class:`)||r.startsWith(`bind:`)||r.startsWith(`on:`)||r.startsWith(`oncapture:`)))){n=!0;break}}return Qc.set(e,n),n},nl=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(`.`)),rl=new Set,il=[`/test/`,`/tests/`,`/testing/`,`/__tests__/`,`/__test__/`,`/__fixtures__/`,`/fixtures/`,`/__mocks__/`,`/mocks/`,`/testUtils/`,`/test-utils/`,`/test-stubs/`,`/testutils/`,`/cypress/`,`/playwright/`,`/.storybook/`,`/.dumi/`,`/stories/`,`/__stories__/`,...nl,`/e2e/`,`/e2e-tests/`,`/integration-tests/`,`/benchmarks/`,`/benchmark/`,`/__benchmarks__/`,`/perf-tests/`],al=[`.test.`,`.spec.`,`.cy.`,`.stories.`,`.story.`,`.bench.`,`.benchmark.`,`.e2e.`,`.integration-spec.`,`.int-spec.`,`.mock.`,`.mocks.`,`.fixture.`],ol=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(`,`)),sl=[`/src/`,`/app/`,`/lib/`,`/components/`,`/pages/`,`/features/`,`/modules/`,`/packages/`,`/apps/`,`/frontend/`,`/client/`],cl=il.filter(e=>e.startsWith(`/.`)),ll=e=>{let t=-1;for(let n of sl){let r=e.lastIndexOf(n);r>t&&(t=r)}return t<0?e:e.slice(t)};let ul,dl=!1,fl,pl=!1;const ml=e=>e?e===ul?dl:(ul=e,dl=_l(e),dl):!1,hl=e=>{if(!e)return!1;if(e===fl)return pl;fl=e;let t=e.replaceAll(`\\`,`/`),n=t.startsWith(`/`)?t:`/${t}`;return pl=_l(n,sl.some(e=>n.includes(e))?nl:rl),pl},gl=(e,t)=>e?_l(e,t):!1,_l=(e,t=rl)=>{let n=e.replaceAll(`\\`,`/`),r=n.lastIndexOf(`/`),i=r===-1?n:n.slice(r+1);if(ol.has(i.toLowerCase()))return!0;for(let e of al)if(i.includes(e))return!0;let a=n.startsWith(`/`)?n:`/${n}`;for(let e of cl)if(!t.has(e)&&a.includes(e))return!0;let o=ll(n);for(let e of il)if(!t.has(e)&&(e.startsWith(`/.`)?n:o).includes(e))return!0;return!1},vl=(e,t=ml)=>n=>t(n.filename)?Gc:e(n),yl=e=>{let t=e?.[`react-doctor`];return typeof t!=`object`||!t||Array.isArray(t)?null:t},bl=(e,t)=>Object.getOwnPropertyDescriptor(e,t)?.value,xl=(e,t)=>{let n=yl(e);if(!n)return;let r=bl(n,t);return typeof r==`string`?r:void 0},Sl=(e,t)=>{let n=yl(e);if(!n)return;let r=bl(n,t);return typeof r==`number`&&Number.isFinite(r)?r:void 0},Cl=new WeakMap,wl=(e,t)=>{let n=bl(e,t);if(Array.isArray(n))return n.filter(e=>typeof e==`string`&&e.length>0)},Tl=(e,t)=>{let n=yl(e);if(!n)return;let r=Cl.get(n);if(r||(r=new Map,Cl.set(n,r)),r.has(t))return r.get(t);let i=wl(n,t);return r.set(t,i),i},El=(e,t)=>Tl(e,t)??[],Dl=(e,t)=>El(e,`capabilities`).includes(t),Ol=(e,t)=>{let n=yl(e);return!n||bl(n,`capabilities`)===void 0?!0:Dl(e,t)},kl=(e,t)=>!t?.some(t=>Dl(e,t)),Al=(e,t)=>n=>kl(n.settings,t)?e(n):Gc,jl=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=el(e);i=n.hasReactRuntime,r=!n.hasReactRuntime&&(n.hasNonReactRuntime||n.hasNonReactMarker),!r&&t(e)};continue}if(e===`JSXOpeningElement`){a.JSXOpeningElement=e=>{!i&&!r&&tl(e)&&(r=!0),!r&&t(e)};continue}a[e]=e=>{r||t(e)}}return`Program`in a||(a.Program=e=>{let t=el(e);i=t.hasReactRuntime,r=!t.hasReactRuntime&&(t.hasNonReactRuntime||t.hasNonReactMarker)}),a}),W=e=>{if(!(`create`in e))return{...e,create:()=>Gc};let t=e.tags,n=e.create,r=t?.includes(`test-noise`)&&!t?.includes(`migration-hint`);return t?.includes(`react-jsx-only`)&&(n=jl(n)),r&&(n=vl(n,hl)),e.disabledWhen&&(n=Al(n,e.disabledWhen)),n===e.create?e:{...e,create:n}};let Ml;const Nl=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},Pl=e=>{if(Ml?.content===e)return Ml.lineStartOffsets;let t=Nl(e);return Ml={content:e,lineStartOffsets:t},t},G=(e,t)=>{if(Number.isNaN(t)||t<0)return{line:1,column:1};let n=Pl(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}},Fl=(e,t)=>G(e,e.search(t)),Il=/\.(?:[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,Ll=/(?:^|\/)\.env(?:\.|$)/,Rl=/\.(?:[cm]?[jt]sx?)$/i,zl=/\.(?:[cm]?[jt]sx?|py|php)$/i,Bl=/\.(?:[cm]?[jt]sx?|py)$/i,Vl=/(?:^|\/)(?:api|backend|server|servers|middleware|route|routes|functions|lambdas|workers)(?:\/|$)|(?:^|\/)[^/]+\.server\.[cm]?[jt]sx?$/i,Hl=/(?:^|\/)(?:__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,Ul=/(?:^|\/)(?: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,Wl=/(?:^|\/)scripts(?:\/|$)/i,Gl=/(?:^|\/)(?:examples?|tutorials?|demos?|samples?|playgrounds?)(?:\/|$)/i,Kl=/(?:^|\/)(?:README|CHANGELOG|CONTRIBUTING|PUBLISHING|DOCS)\.mdx?$|\.mdx?$/i,ql=/(?:^|\/)(?: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,Jl=/\.(iife|umd|global|min)\.js$/i,Yl=[/(?:^|\/)\.next\/static\//,/(?:^|\/)\.output\/public\//,/(?:^|\/)build\/static\//,/(?:^|\/)dist\/assets\//,/(?:^|\/)public\//,/(?:^|\/)out\//,/(?:^|\/)storybook-static\//],Xl=/\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/,Zl=new Set([`.next`,`.output`]),Ql=e=>{let t=e.split(`/`);for(let e=0;e<t.length;e+=1)if(Zl.has(t[e])&&(t[e]===`.next`&&t[e+1]===`dev`||t[e+1]===`server`&&e+2<t.length))return!0;return!1},$l=(e,t)=>Ql(e)?!1:t||e.endsWith(`.map`)?!0:Yl.some(t=>t.test(e)),eu=e=>/(?:^|\/)(?:package\.json|Dockerfile|docker-compose\.ya?ml|\.github\/workflows\/[^/]+\.ya?ml|vercel\.json|next\.config\.[cm]?[jt]s|netlify\.toml)$/i.test(e),tu=new Map,nu=(e,t)=>{let n=tu.get(t);n||(n=new Map,tu.set(t,n));let r=n.get(e);if(r!==void 0)return r;let i=t.test(e)&&!Hl.test(e)&&!Wl.test(e)&&!Kl.test(e)&&!ql.test(e);return n.set(e,i),i},K=e=>/\.d\.[cm]?[jt]s$/i.test(e)?!1:nu(e,Rl),ru=/<script\b|on(?:load|error|click|mouseover)\s*=/i,iu=/dangerouslyAllowSVG\s*:\s*true/i,au=/<(?:object|embed|iframe)\b[^>]+(?:data|src)=["'][^"']+\.svg(?:\?[^"']*)?["']/i,ou=W({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`)&&$l(e.relativePath,e.isGeneratedBundle)){if(ru.test(e.content)){let n=Fl(e.content,ru);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(!K(e.relativePath)&&!eu(e.relativePath))return t;let n=[iu,au].find(t=>t.test(e.content));if(n!==void 0){let r=Fl(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}}),su=e=>/(?:^|\/)(?:firestore\.rules|storage\.rules|database\.rules\.json)$/.test(e),cu=/\s/,lu=/[\p{ID_Continue}$]/u,uu=/["'`/]/g,du=/["'`/{}]/g,fu=/["\\\n]/g,pu=/['\\\n]/g,mu=/[`\\$\n]/g,hu=new Set([`return`,`typeof`,`case`,`in`,`of`,`new`,`delete`,`void`,`instanceof`,`do`,`else`,`yield`,`await`,`throw`]),gu=()=>{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(``)}}},_u=(e,t,n)=>{let r=n=>t.isBlanked(n)?` `:e[n],i=n-1;for(;i>=0&&cu.test(r(i));)--i;if(i<0)return!0;let a=r(i),o=i>0?r(i-1):``;if(lu.test(a)){let t=i;for(;t>0&&lu.test(r(t-1));)--t;return t>0&&r(t-1)===`.`?!1:hu.has(e.slice(t,i+1))}return a===`<`?!1:a===`>`?o===`=`:a===`+`||a===`-`?o!==a:a===`!`?!(lu.test(o)||o===`)`||o===`]`):!(a===`)`||a===`]`||a===`}`||a===`"`||a===`'`||a==="`")},vu=(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},yu=(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(cu.test(e[r]))return!0}return!1},bu=(e,t)=>{let n=e.length,r=gu(),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?du:uu;t.lastIndex=s;let n=t.exec(e);if(n===null)break;s=n.index}else{let t=i===34?fu:i===39?pu:mu;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&&yu(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=_u(e,r,s)?vu(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)},xu=e=>e.includes(`//`)||e.includes(`/*`)?bu(e,!1):e,Su=e=>bu(e,!0),Cu=new WeakMap,wu=new WeakMap,Tu=(e,t=!1)=>{if(!Rl.test(e.relativePath)&&!su(e.relativePath))return e.content;let n=t?wu:Cu,r=n.get(e);if(r!==void 0)return r;let i=t?Su(e.content):xu(e.content);return n.set(e,i),i},q=({shouldScan:e,pattern:t,requireAll:n,suppressWhen:r,ignoreStringLiterals:i,message:a})=>o=>{if(!e(o))return[];let s=Tu(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}=G(s,c);return[{message:a,line:l,column:u}]},Eu=/\b(?:tool\s*\(\s*\{|createTool\s*\(|defineTool\s*\(|new\s+(?:DynamicTool|StructuredTool)\s*\()/,Du=/\b(?:tool|createTool|defineTool|DynamicTool|StructuredTool)\b/,Ou=/(?:^|\/)(?:agents?|tools?|mcp)(?:\/|$)|(?:agent|tool|mcp)[^/]*\.[cm]?[jt]sx?$/i,ku=W({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:q({shouldScan:e=>K(e.relativePath)&&Ou.test(e.relativePath)&&Du.test(e.content)&&Xl.test(e.content),pattern:Eu,requireAll:[Xl],ignoreStringLiterals:!0,message:`An agent-callable tool appears to expose network, filesystem, shell, or code-execution capability.`})}),Au=W({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:q({shouldScan:e=>$l(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.`})}),ju=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)?$/,Nu=new Set([`signedin`,`loggedin`,`signin`]),Pu=new Set([`require`,`ensure`,`assert`,`verify`,`validate`,`check`,`protect`,`enforce`,`guard`,`gate`,`restrict`,`is`,`has`,`can`,`must`]),Fu=new Set([`get`,`fetch`,`load`,`read`,`resolve`,`retrieve`,`use`]),Iu=new Set([`current`,`my`,`own`]),Lu=new Set([`session`,`sessions`,`login`,`admin`,`admins`,`superadmin`,`superuser`,`role`,`roles`,`permission`,`permissions`,`jwt`,`identity`,`principal`,`credential`,`credentials`]),Ru=new Set([`user`,`users`,`account`,`accounts`,`token`,`tokens`,`access`,`me`,`viewer`,`caller`,`subject`,`scope`,`scopes`]),zu=new Set([`getUser`]),Bu=/(?:^|[._])(?:auth|authn|authz|clerk|session|jwt|firebase|supabase|nextauth|kinde|workos|stytch|descope|cognito|propelauth|lucia)/i,Vu=[/^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,}$/],Hu=[/\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],Uu=/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{16,}\b/,Wu=/\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,Gu=/\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/,Ku=/\b(?:(?:process|window)\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->))|import\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->|meta\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->)))))/,qu=/\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/,Ju=/(?: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,Yu=[/^appl_/,/^goog_/,/^amzn_/,/^strp_/,/^pk_(?:live|test)_/,/^sb_publishable_/,/^phc_/,/^public-token-(?:live|test)-/,/^pk\.eyJ/],Xu=[/^[\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],Zu=[/(?:^|[_\-\s])(?:example|sample|dummy)(?:$|[_\-\s])/i],Qu=/(?:placeholder|example|sample|dummy|masked|redacted|mask)/i,$u=/(?:api_?key|secret|token|password|credential|auth(?!or(?!i[sz])))/i,ed=/(?:^|\/)[^/]+\.config\.[cm]?[jt]s$/,td=/(?:^|\/)(?:\.[a-z-]+rc|[a-z-]+\.rc)\.[cm]?[jt]s$/,nd=/(?:^|\/)[^/]+\.(?:test|spec|stories|story|fixture|fixtures)\.[cm]?[jt]sx?$/,rd=/(?:^|\/)[^/]+\.server\.[cm]?[jt]sx?$/,id=/(?:^|\/)(?:middleware|proxy|route)\.[cm]?[jt]sx?$/,ad=/(?:^|\/)pages\/api\/.+\.[cm]?[jt]sx?$/,od=/(?:^|\/)[^/]+\.(?:client|browser|web)\.[cm]?[jt]sx?$/,sd=/(?:^|\/)(?:src\/)?(?:main|index|[Aa]pp|client)\.[cm]?[jt]sx?$/,cd=new Set([`backend`,`functions`,`lambdas`,`lambda`,`middleware`,`server`,`servers`]),ld=new Set([`api`,`backend`,`edge`,`function`,`functions`,`lambda`,`lambdas`,`server`,`servers`,`worker`,`workers`]),ud=new Set([`__fixtures__`,`__mocks__`,`__tests__`,`fixtures`,`mocks`,`test`,`tests`]),dd=new Set([`bin`,`config`,`configs`,`script`,`scripts`,`tooling`,`tools`]),fd=new Set([`components`,`features`,`hooks`,`pages`,`ui`,`views`,`widgets`]),pd=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(`.`)),md=new Set([`start`,`end`]),J=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),hd=new RegExp(Wu.source,`gi`),gd=e=>{for(let t of e.matchAll(hd)){let e=t[0]??``;if(!Ju.test(e))return new RegExp(J(e))}},_d=e=>Gu.test(e)&&qu.test(e),vd=/\.(?:[cm]?[jt]sx?)$/i,yd=/\/\/|\/\*|<!--/,bd=new Set([`\r`,`
|
|
6
|
+
`,`\u2028`,`\u2029`]),xd=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&&!bd.has(e[r]??``)&&e[r]?.trim()===``;)--r;if(r<0||bd.has(e[r]??``))return!0;t=n+3}return!1},Sd=(e,n)=>{if(!vd.test(e)||!n.startsWith(`#!`)&&!yd.test(n)&&!xd(n))return n;try{let r=t(e,n,{astType:`ts`,lang:Wt(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}},Cd=/\.map$/i,wd=/\s/,Td=/[^\r\n\u2028\u2029]/g,Y=(e,t)=>{let n=t;for(;n<e.length&&wd.test(e[n]??``);)n+=1;return n},Ed=(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}},Dd=(e,t)=>{let n=Y(e,t);if(e[n]===`"`)return Ed(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=Ed(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},Od=(e,t)=>{let n=Y(e,0);if(e[n]!==`{`)return;n=Y(e,n+1);let r;for(;n<e.length&&e[n]!==`}`;){let i=Ed(e,n);if(i===void 0)return;let a=JSON.parse(e.slice(n,i));if(n=Y(e,i),e[n]!==`:`)return;if(n=Y(e,n+1),a===t){if(r!==void 0)return;r=n}let o=Dd(e,n);if(o===void 0)return;if(n=Y(e,o),e[n]===`,`){n=Y(e,n+1);continue}if(e[n]!==`}`)return}return r},kd=(e,t,n)=>{let r=Y(e,t);if(e[r]!==`[`)return;r=Y(e,r+1);let i=[];for(let t of n){if(typeof t==`string`){let t=Ed(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=Y(e,r),e[r]===`,`){r=Y(e,r+1);continue}}return e[r]===`]`?i:void 0},Ad=(e,t)=>`${e}/${t}`.split(/[\\/]/).includes(`node_modules`),jd=(e,t)=>{if(!Cd.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=Od(t,`sourcesContent`);if(a===void 0)return t;let o=kd(t,a,r);if(o===void 0)return t;let s=i??``,c=[],l=0;for(let[e,r]of n.entries()){if(!Ad(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(Td,` `)),l=n.end}return l===0?t:(c.push(t.slice(l)),c.join(``))}catch{return t}},Md=(e,t,n)=>{if(Kl.test(e.relativePath)||!$l(e.relativePath,e.isGeneratedBundle))return[];let r=t(e.content);if(r===void 0)return[];let i=Fl(e.content,r);return[{message:n,line:i.line,column:i.column}]},Nd=`A browser artifact contains server-secret environment names or a full environment dump shape.`,Pd=e=>gd(e)??(_d(e)?qu:void 0),Fd=W({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=jd(e.relativePath,e.content),n=t===e.content?e:{...e,content:t},r=!1,i=Md(n,e=>{let t=gd(e);if(t)return r=!0,t;if(qu.test(e))return Gu.test(e)?(r=!0,qu):Ku.test(e)?qu:void 0},Nd);if(i.length===0)return i;let a=r?i:Md(n,Pd,Nd),o=Sd(n.relativePath,n.content);return o===void 0?i:o===n.content?a:Md({...n,content:o},Pd,Nd)}}),Id=W({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=>Hu.find(t=>t.test(e)),`A browser-delivered artifact contains a secret-looking credential value.`)}),Ld=/(?: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,Rd=/(?:npm|pnpm|yarn|bun)\s+(?:install|ci)\b/i,zd=/\bsecrets\.[A-Z0-9_]+/,Bd=/--ignore-scripts\b/,Vd=`The build or install pipeline can execute package lifecycle code while CI secrets may be present.`,Hd=e=>/(?:^|\/)\.github\/workflows\/[^/]+\.ya?ml$/i.test(e),Ud=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=zd.test(n.join(`
|
|
8
|
+
`));for(let e of r){let t=e.lines.join(`
|
|
9
|
+
`);if(!Rd.test(t)||Bd.test(t)||!s&&!zd.test(t))continue;let n=Math.max(e.lines.findIndex(e=>Rd.test(e)),0),r=e.lines[n].search(Rd);return[{message:Vd,line:e.startLineIndex+n+1,column:(r===-1?0:r)+1}]}return[]},Wd=q({shouldScan:e=>eu(e.relativePath)&&!e.relativePath.endsWith(`package.json`)&&!Hd(e.relativePath),pattern:Ld,message:Vd}),Gd=W({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=>Hd(e.relativePath)?Ud(e.content):Wd(e)}),Kd=W({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:q({shouldScan:e=>K(e.relativePath)||eu(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.`})}),qd=e=>/(?:^|\/)(?:tools?|scripts?)\/|(?:^|\/)management\/commands\/|(?:^|\/)(?:build|make|gulpfile|gruntfile)\.[cm]?[jt]s$/i.test(e),Jd=e=>nu(e,zl),Yd=String.raw`(?:req\.|request\.|params\.|query\.|body\.|searchParams|\$_(?:GET|POST|REQUEST))`,Xd=String.raw`(?:(?<![.\w$])(?:exec(?:Sync)?|system|passthru|proc_open|shell_exec)|\b(?:os\.system|subprocess\.(?:run|Popen|call)|(?:child_process|childProcess|cp)\.exec\w*))`,Zd=String.raw`(?:(?<![.\w$])spawn(?:Sync)?|\b(?:child_process|childProcess|cp)\.spawn\w*)`,Qd=String.raw`['"](?:sh|bash|zsh|dash|ksh|cmd(?:\.exe)?|powershell(?:\.exe)?|pwsh)['"]`,$d=String.raw`['"](?:-c|/c|-Command)['"]`,ef=W({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:q({shouldScan:e=>Jd(e.relativePath)&&!qd(e.relativePath),pattern:[new RegExp(String.raw`${Xd}\s*\([^)]{0,220}(?:${Yd}|shell\s*=\s*true|f['"\`][^'"\`]*\{)`,`i`),new RegExp(String.raw`${Zd}\s*\((?:[^,)]{0,120}?${Yd}|\s*${Qd}\s*,\s*\[\s*${$d}\s*,[^\]]{0,220}${Yd}|(?=[^)]{0,220}shell\s*[:=]\s*true)[^)]{0,220}${Yd})`,`i`)],message:`Command execution appears to include request, query, body, or shell-interpolated input.`})}),tf=W({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:q({shouldScan:e=>K(e.relativePath)||eu(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.`})}),nf=(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},rf=e=>`end`in e&&typeof e.end==`number`?e.end:-1,X=e=>`start`in e&&typeof e.start==`number`?e.start:-1,af=e=>{let t=D(e);for(;S(t,`SequenceExpression`);){let e=t.expressions.at(-1);if(!e)break;t=D(e)}return t},of=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},sf=e=>S(e,`JSXElement`)||S(e,`JSXFragment`)||S(e,`ArrayExpression`)||S(e,`ObjectExpression`)||S(e,`ArrowFunctionExpression`)||S(e,`FunctionExpression`)||S(e,`ClassExpression`)||S(e,`NewExpression`)?{expression:e,truthiness:`truthy`,nullishness:`non-nullish`}:S(e,`Literal`)?e.value===null?{expression:e,truthiness:`falsy`,nullishness:`nullish`}:{expression:e,truthiness:e.value?`truthy`:`falsy`,nullishness:`non-nullish`}:S(e,`UnaryExpression`)&&e.operator===`void`?{expression:e,truthiness:`falsy`,nullishness:`nullish`}:{expression:e,truthiness:`unknown`,nullishness:`unknown`},cf=e=>{let t=af(e);if(S(t,`ConditionalExpression`)){let e=cf(t.test);return e.every(e=>e.truthiness===`truthy`)?cf(t.consequent):e.every(e=>e.truthiness===`falsy`)?cf(t.alternate):of([...cf(t.consequent),...cf(t.alternate)])}if(!S(t,`LogicalExpression`))return[sf(t)];let n=cf(t.left),r=cf(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 of(i)},lf=e=>{let t=[],n=new Set;for(let r of cf(e))n.has(r.expression)||(n.add(r.expression),t.push(r.expression));return t},uf=new Set([`assign`,`defineProperties`,`defineProperty`]),df=new Set([`defineProperty`,`set`]),ff=new WeakMap,pf=e=>{let t=O(e);for(;t.parent;){let e=t.parent;if(!S(e,`MemberExpression`)||e.object!==t)break;t=O(e)}return t},Z=e=>{let t=e;for(;t;){if(x(t)||S(t,`Program`))return t;t=t.parent}return e},mf=(e,t)=>{if(S(e,`ReturnStatement`)||S(e,`ThrowStatement`)||S(e,`BreakStatement`)||t&&S(e,`ContinueStatement`))return!0;if(S(e,`BlockStatement`))return e.body.some(e=>mf(e,t));if(!S(e,`IfStatement`))return!1;if(S(e.test,`Literal`)){let n=e.test.value?e.consequent:e.alternate;return n?mf(n,t):!1}return!!(e.alternate&&mf(e.consequent,t)&&mf(e.alternate,t))},hf=e=>mf(e,!0),gf=(e,t)=>{let n=t.indexOf(e);return n>0&&t.slice(0,n).some(hf)},_f=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if((S(e,`BlockStatement`)||S(e,`Program`))&&gf(n,e.body)||(S(e,`WhileStatement`)&&S(e.test,`Literal`)&&!e.test.value||S(e,`ForStatement`)&&e.test&&S(e.test,`Literal`)&&!e.test.value)&&e.body===n||S(e,`SwitchCase`)&&gf(n,e.consequent)||S(e,`IfStatement`)&&S(e.test,`Literal`)&&(e.test.value===!1&&e.consequent===n||e.test.value===!0&&e.alternate===n)||S(e,`ConditionalExpression`)&&S(e.test,`Literal`)&&(e.test.value===!1&&e.consequent===n||e.test.value===!0&&e.alternate===n)||S(e,`LogicalExpression`)&&e.right===n&&S(e.left,`Literal`)&&(e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value))return!0;n=e}return!1},vf=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(S(e,`IfStatement`)&&(!S(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||S(e,`ConditionalExpression`)&&(!S(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||S(e,`LogicalExpression`)&&e.right===n&&(!S(e.left,`Literal`)||e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value)||S(e,`DoWhileStatement`)&&!(e.body===n&&S(e.test,`Literal`)&&!e.test.value)||S(e,`ForStatement`)||S(e,`ForInStatement`)||S(e,`ForOfStatement`)&&e.right!==n||S(e,`WhileStatement`)||S(e,`SwitchCase`)||S(e,`CatchClause`)||S(e,`TryStatement`)&&e.block===n||(S(e,`CallExpression`)||S(e,`MemberExpression`))&&e.optional)return!0;n=e}return!1},yf=(e,t)=>{let n=D(e);if(S(n,`Literal`))return!1;if(S(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:X(e.declarationNode)>X(n):!0}if(S(n,`ArrayExpression`))return n.elements.some(e=>e?S(e,`SpreadElement`)?!0:yf(e,t):!1);if(S(n,`ObjectExpression`))return n.properties.length>0;if(S(n,`TemplateLiteral`))return n.expressions.length>0;if(S(n,`UnaryExpression`)){let e=D(n.argument);return n.operator===`typeof`&&S(e,`Identifier`)&&!t.symbolFor(e)?!1:yf(e,t)?!0:n.operator===`void`||n.operator===`typeof`||n.operator===`!`?!1:!(S(e,`Literal`)&&(typeof e.value==`number`||typeof e.value==`string`))}return!0},bf=(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=>S(e,`EmptyStatement`)?!1:S(e,`ExpressionStatement`)?yf(e.expression,n):S(e,`VariableDeclaration`)?e.declarations.some(e=>!S(e.id,`Identifier`)||!!(e.init&&yf(e.init,n))):!0)},xf=(e,t)=>S(e,`AwaitExpression`)?yf(e.argument,t):!1,Sf=(e,t,n)=>{let r=e;for(;r.parent&&r!==t;){let t=r.parent;if(S(t,`IfStatement`)&&(!S(t.test,`Literal`)||t.test.value===!0&&t.alternate===r||t.test.value===!1&&t.consequent===r)||S(t,`ConditionalExpression`)&&(!S(t.test,`Literal`)||t.test.value===!0&&t.alternate===r||t.test.value===!1&&t.consequent===r)||S(t,`LogicalExpression`)&&t.right===r&&(!S(t.left,`Literal`)||t.operator===`&&`&&!t.left.value||t.operator===`||`&&t.left.value)||S(t,`WhileStatement`)&&(!S(t.test,`Literal`)||!t.test.value)||S(t,`ForStatement`)&&t.test&&(!S(t.test,`Literal`)||!t.test.value)||S(t,`ForInStatement`)||S(t,`ForOfStatement`)||S(t,`SwitchCase`)||S(t,`CatchClause`)||S(t,`TryStatement`)&&t.block===r&&S(r,`BlockStatement`)&&(bf(e,r,n)||xf(e,n))||(S(t,`CallExpression`)||S(t,`MemberExpression`))&&t.optional)return!0;r=t}return!1},Cf=(e,t)=>{let n=e;for(;n;){if(n===t)return!0;n=n.parent}return!1},wf=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(S(e,`IfStatement`)&&(!S(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||S(e,`ConditionalExpression`)&&(!S(e.test,`Literal`)||e.test.value===!0&&e.alternate===n||e.test.value===!1&&e.consequent===n)||S(e,`LogicalExpression`)&&e.right===n&&(!S(e.left,`Literal`)||e.operator===`&&`&&!e.left.value||e.operator===`||`&&e.left.value)||S(e,`ForStatement`)||S(e,`ForInStatement`)||S(e,`ForOfStatement`)||S(e,`WhileStatement`)||S(e,`SwitchCase`)||S(e,`CatchClause`)||S(e,`TryStatement`)&&e.block===n||(S(e,`CallExpression`)||S(e,`MemberExpression`))&&e.optional)return n;n=e}return null},Tf=e=>S(e,`AwaitExpression`)||S(e,`YieldExpression`)?e.argument?rf(e.argument):rf(e):S(e,`ForOfStatement`)?rf(e.right):X(e),Ef=(e,t,n)=>{if(X(t)<Tf(e))return!1;let r=wf(e,n);return!!(r&&Cf(t,r))},Df=e=>{let t=ff.get(e);if(t)return t;let n=(t,n,r)=>{let i=D(t);if(!S(i,`MemberExpression`))return!1;let a=D(i.object);return!!(S(a,`Identifier`)&&a.name===n&&e.isGlobalReference(a)&&r.has(k(i)??``))},r=e=>{let t=D(e);if(!S(t,`ObjectExpression`))return null;let n=new Set;for(let e of t.properties){if(!S(e,`Property`))return null;let t=j(e,{allowComputedString:!0});if(t===null)return null;n.add(t)}return n},i=e=>{let t=pf(e),i=t.parent;if(i){if(S(i,`AssignmentExpression`)&&i.left===t||S(i,`UpdateExpression`)&&i.argument===t||S(i,`UnaryExpression`)&&i.operator===`delete`){if(!S(t,`MemberExpression`))return null;let e=k(t);return e===null?null:new Set([e])}if(!(!S(i,`CallExpression`)||i.arguments[0]!==t)){if(n(i.callee,`Object`,uf)){let e=D(i.callee);if(!S(e,`MemberExpression`))return;let t=k(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&&S(n,`Literal`)&&typeof n.value==`string`?new Set([n.value]):null}if(n(i.callee,`Reflect`,df)){let e=i.arguments[1];return e&&S(e,`Literal`)&&typeof e.value==`string`?new Set([e.value]):null}}}},a=e=>{let t=O(e),n=t.parent;if(S(n,`ForOfStatement`)&&n.right===t)return n.await||mf(n.body,!1);let r=n;if(!S(r,`MemberExpression`)||r.object!==t||k(r)!==`next`)return!1;let i=O(r);return!!(S(i.parent,`CallExpression`)&&i.parent.callee===i)},o=e=>{let t=O(e),n=t.parent;return S(n,`ForOfStatement`)&&!n.await&&n.right===t&&!mf(n.body,!1)?!0:!!(S(n,`SpreadElement`)&&n.parent&&!S(n.parent,`ObjectExpression`))},s=e=>{let t=O(e),n=t.parent;if(!S(n,`ForOfStatement`)||n.await||n.right!==t||mf(n.body,!1))return[];let r=Z(n.body),i=new Set;return L(n.body,e=>{if(Z(e)!==r||!S(e,`BreakStatement`))return;let a=e;if(e.label){for(;a?.parent;){let t=a.parent;if(S(t,`LabeledStatement`)&&t.label.name===e.label.name){Cf(n,t.body)&&i.add(t);return}a=t}return}for(;a?.parent;){let e=a.parent;if(S(e,`ForStatement`)||S(e,`ForInStatement`)||S(e,`ForOfStatement`)||S(e,`WhileStatement`)||S(e,`DoWhileStatement`)||S(e,`SwitchStatement`)){S(e,`ForOfStatement`)&&e.right===t&&i.add(e);return}a=e}}),[...i]},c=t=>{let n=D(t.callee),r=null;if(x(n))r=n;else if(S(n,`Identifier`)){let t=A(n,e);if(t?.kind===`function`&&x(t.declarationNode))r=t.declarationNode;else if(t?.kind===`const`&&t.initializer){let e=D(t.initializer);x(e)&&(r=e)}}return r&&x(r)?r:null},l=e=>{let t=c(e);return!t||!x(t)?null:t.generator?a(e)||o(e)?t:null:t},u=[],d=new Map;L(e.rootScope.node,t=>{if(S(t,`CallExpression`)){let e=Z(t),n=l(t);n&&!_f(t,e)&&u.push({argumentCall:t,call:t,conditionalExitTargets:x(n)&&n.generator?s(t):[],owner:e,targetOwner:n,yieldCount:x(n)&&n.generator&&a(t)?1:null})}if(!S(t,`Identifier`))return;let n=i(t);if(n===void 0)return;let r=A(t,e);if(!r)return;let o=Z(t);if(_f(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=Z(t),r=X(t),i=new Set,a=(e,t)=>{for(let n of u)n.owner!==e||X(n.call)>=t||i.has(n.targetOwner)||(i.add(n.targetOwner),a(n.targetOwner,1/0))};return a(n,r),S(n,`Program`)||a(e.rootScope.node,1/0),i},p=e=>{if(S(e,`Program`))return 1/0;let t=u.find(t=>S(t.owner,`Program`)&&t.targetOwner===e);return t?X(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,g=(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},_=(e,t)=>{let n=new Set,r=e;for(;r?.parent&&r!==t;){let t=r.parent,i=S(t,`DoWhileStatement`)&&S(t.test,`Literal`)&&!t.test.value,a=S(t,`ForStatement`)||S(t,`ForInStatement`)||S(t,`ForOfStatement`)||S(t,`WhileStatement`)||S(t,`DoWhileStatement`)?t.body:null,o=e;for(;a&&S(a,`BlockStatement`)&&o&&o.parent!==a;)o=o.parent??null;let s=a&&S(a,`BlockStatement`)&&o?a.body.findIndex(e=>e===o):-1,c=!!(a&&S(a,`BlockStatement`)&&s>=0&&a.body.slice(s+1).some(e=>mf(e,!1)));a&&!i&&!c&&n.add(t),r=t}return n},v=(e,t,n)=>{let r=_(e,n);return r.size===0?!1:[..._(t,n)].some(e=>r.has(e))},y=new WeakMap,ee=e=>{let t=y.get(e);if(t)return t;let n=new Map;for(let t of u){if(!g(t.targetOwner,e))continue;let r=n.get(t.owner)??[];r.push(t),n.set(t.owner,r)}return y.set(e,n),n},te=(e,t)=>{let n=ee(e),r=ee(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&&(X(r.call)<X(t.call)||x(e)||v(r.call,t.call,e)))return!0}}return!1},ne=e=>{let t=Z(e);if(S(t,`Program`))return!1;let n=u.filter(e=>S(e.owner,`Program`)&&g(e.targetOwner,t));return n.length===0?!1:n.length!==1||n[0]?.targetOwner!==t},re=e=>{let t=pf(e.node),n=t.parent;return!!(S(t,`Identifier`)&&n&&(S(n,`AssignmentExpression`)&&n.left===t||S(n,`UpdateExpression`)&&n.argument===t))},ie=(t,n)=>{let r=D(t);if(S(r,`Identifier`)){let t=A(r,e);return t&&n.has(t.id)?n.get(t.id)??!1:null}if(S(r,`SequenceExpression`)){let e=r.expressions.at(-1);return e?ie(e,n):null}if(S(r,`ConditionalExpression`)){let e=ie(r.consequent,n),t=ie(r.alternate,n);return e===null&&t===null?null:e===null||t===null?!0:e||t}if(S(r,`LogicalExpression`)){let e=ie(r.left,n),t=ie(r.right,n);return e===null?t===null?null:!0:r.operator===`&&`?t:e}return null},ae=(e,t)=>{let n=pf(e.node).parent;if(!n||!S(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=ie(n.right,t));let a=vf(e.node,e.owner);i===null?a?t.set(e.symbolId,!0):t.delete(e.symbolId):t.set(e.symbolId,a&&r||i)},oe=(t,n)=>{if(!x(t.targetOwner))return n;let r=new Map(n);for(let[i,a]of t.targetOwner.params.entries()){let o=S(a,`AssignmentPattern`)?a.left:a;if(!S(o,`Identifier`))continue;let s=t.argumentCall.arguments[i],c=s&&!S(s,`SpreadElement`)?D(s):null,l=null;if(S(a,`AssignmentPattern`)&&(!c||S(c,`Identifier`)&&c.name===`undefined`&&e.isGlobalReference(c)||S(c,`UnaryExpression`)&&c.operator===`void`)&&S(a,`AssignmentPattern`)?l=D(a.right):c&&(l=c),!S(l,`Identifier`))continue;let u=A(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},se=(t,n)=>{if(!x(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||!Cf(n,e));(t.yieldCount!==null||i)&&r.add(`YieldExpression`);let a=[],o=1/0,s=1/0,c=0;return L(t.targetOwner.body,n=>{if(Z(n)!==t.targetOwner||_f(n,t.targetOwner)||!(r.has(n.type)&&(!S(n,`ForOfStatement`)||n.await)))return;let l=S(n,`YieldExpression`)&&n.argument?D(n.argument):null;if(S(n,`YieldExpression`)&&n.delegate&&l&&(S(l,`ArrayExpression`)&&l.elements.length===0||S(l,`Literal`)&&l.value===``))return;let u=Tf(n);if(S(n,`YieldExpression`)){if(c+=1,i&&c>=1){o=Math.min(o,u);return}if(t.yieldCount===null||c>t.yieldCount)return}Sf(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}},ce=(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(oe(e,i)),s=se(e),c=[...[...o.keys()].flatMap(e=>d.get(e)??[]).filter(t=>t.owner===e.targetOwner).map(e=>({event:e,index:X(e.node)})),...u.filter(t=>t.owner===e.targetOwner).map(e=>({call:e,index:X(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=>Ef(t,i,e.targetOwner))){if(`event`in t){if(!o.has(t.event.symbolId))continue;if(re(t.event)){ae(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)},le={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:X(e.node)})),...u.filter(t=>t.owner===e).map(e=>({call:e,index:X(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=>Ef(t,l,e)))continue;if(`event`in s){if(!p.has(s.event.symbolId))continue;let e=!!(c||p.get(s.event.symbolId)||vf(s.event.node,s.event.owner)||s.index>a);if(re(s.event)){ae(s.event,p);continue}r.push({isConditional:e,node:s.event.node});continue}let u=se(s.call,n);i(s.call.targetOwner,u.cutoffIndex,u.conditionalStartIndex,u.conditionalSuspensions,f,c||vf(s.call.call,s.call.owner)||s.index>a,oe(s.call,p))}},a=Z(n),o=new Map([[t.id,!1]]);return S(a,`Program`)||i(e.rootScope.node,p(a),1/0,[],new Set,!1,o),i(a,X(n),1/0,[],new Set,!1,o),r},getOutermostTarget:pf,isGlobalNamespaceMethod:n,isExecutionOrderAmbiguous:ne,isMutationOrderAmbiguous:(e,t,n)=>{let r=Z(t),i=X(t);if((d.get(e.id)??[]).some(e=>n!==null&&e.propertyNames!==null&&!e.propertyNames.has(n)?!1:e.owner===r?X(e.node)>=i&&(x(r)||v(e.node,t,r)):S(e.owner,`Program`)?(ee(r).get(e.owner)??[]).some(t=>v(e.node,t.call,e.owner)):g(e.owner,r)||te(e.owner,r)))return!0;let a=new Map([[e.id,!1]]);return u.some(e=>e.owner===r&&X(e.call)>=i&&v(e.call,t,r)&&ce(e,a,n))},isMutatedBefore:(e,t,n)=>{let r=d.get(e.id);if(!r)return!1;let i=X(t),a=Z(t),o=f(t);return r.some(e=>n!==null&&e.propertyNames!==null&&!e.propertyNames.has(n)?!1:e.owner===a?X(e.node)<i:S(e.owner,`Program`)&&!S(a,`Program`)?X(e.node)<p(a):o.has(e.owner))}};return ff.set(e,le),le},Of=(e,t)=>t===`katex`?e===`katex`||e.startsWith(`katex/`):e===t,kf=(e,t,n)=>{let r=D(e);if(!S(r,`CallExpression`))return!1;let i=D(r.callee),a=r.arguments[0];return!!(S(i,`Identifier`)&&i.name===`require`&&n.isGlobalReference(i)&&a&&S(a,`Literal`)&&typeof a.value==`string`&&Of(a.value,t))},Af=(e,t)=>{if(e.kind!==`ts-import-equals`)return!1;let n=e.declarationNode;if(!S(n,`TSImportEqualsDeclaration`))return!1;let r=n.moduleReference;return!!(S(r,`TSExternalModuleReference`)&&S(r.expression,`Literal`)&&typeof r.expression.value==`string`&&Of(r.expression.value,t))},jf=(e,t)=>{let n=D(e);return!!(S(n,`AwaitExpression`)&&S(n.argument,`ImportExpression`)&&S(n.argument.source,`Literal`)&&typeof n.argument.source.value==`string`&&Of(n.argument.source.value,t))},Mf=(e,t,n,r,i)=>{let a=A(D(e),i),o=Df(i);if(!a||o.isExecutionOrderAmbiguous(r)||o.isMutationOrderAmbiguous(a,r,n)||o.isMutatedBefore(a,r,n))return null;let s=ct(a);if(typeof s?.source.value==`string`&&Of(s.source.value,t))return S(a.declarationNode,`ImportDefaultSpecifier`)||S(a.declarationNode,`ImportNamespaceSpecifier`)||R(a.declarationNode)===`default`?a:null;if(Af(a,t))return a;if(a.kind!==`const`||!a.initializer)return null;let c=D(a.initializer);return kf(c,t,i)||S(c,`MemberExpression`)&&k(c)===`default`&&(kf(c.object,t,i)||jf(c.object,t))||jf(c,t)?a:null},Nf=(e,t,n,r,i)=>{let a=A(D(e),i);if(!a)return null;let o=ct(a),s=Df(i);return typeof o?.source.value!=`string`||!Of(o.source.value,t)||R(a.declarationNode)!==n||s.isExecutionOrderAmbiguous(r)||s.isMutationOrderAmbiguous(a,r,null)||s.isMutatedBefore(a,r,null)?null:a},Pf=(e,t,n)=>Mf(e,`katex`,`renderToString`,t,n)!==null||kf(e,`katex`,n),Ff=(e,t,n)=>{if(Nf(e,`katex`,`renderToString`,t,n))return!0;let r=D(e);if(!S(r,`Identifier`))return!1;let i=n.referenceFor(r)?.resolvedSymbol;if(!i||i.kind!==`const`||!i.initializer||Df(n).isMutatedBefore(i,t,null))return!1;let a=D(i.initializer),o=i.bindingIdentifier.parent;return S(o,`Property`)&&j(o,{allowComputedString:!0})===`renderToString`?Pf(a,i.declarationNode,n):S(a,`MemberExpression`)&&k(a)===`renderToString`&&Pf(a.object,i.declarationNode,n)?!0:S(a,`Identifier`)?Ff(a,i.declarationNode,n):!1},If=(e,t)=>{let n=D(e);if(S(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(!S(n,`MemberExpression`)||k(n)!==`renderToString`)return!1;let r=D(n.object);if(!S(r,`Identifier`)||!/katex/i.test(r.name))return!1;let i=t.referenceFor(r)?.resolvedSymbol;if(!i)return!1;if(i.kind===`import`){if(!Of(String(ct(i)?.source.value??``),`katex`))return!0;let e=Df(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=D(i.initializer);if(S(a,`ObjectExpression`))return!0;if(S(a,`CallExpression`)){let e=D(a.callee);return S(e,`Identifier`)&&e.name===`require`}return S(a,`AwaitExpression`)&&S(a.argument,`ImportExpression`)},Lf=(e,t)=>{let n=D(e);if(!S(n,`ObjectExpression`))return null;let r;for(let e of n.properties){if(!S(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},Rf=e=>{let t=D(e);if(!S(t,`ObjectExpression`))return null;for(let e of t.properties){if(!S(e,`Property`))return null;let t=j(e,{allowComputedString:!0});if(t===null||t===`get`||t===`set`)return null}return Lf(t,`value`)},zf=new WeakMap,Bf=(e,t)=>{let n=D(e);return S(n,`Identifier`)?n.name===`undefined`&&t.isGlobalReference(n):S(n,`Literal`)&&!n.value},Vf=(e,t,n)=>{let r=Rf(t);return r===null?`trusted`:r===void 0?e:Bf(r,n)?`untrusted`:`trusted`},Hf=(e,t)=>e===t?e:e===`trusted`||t===`trusted`?`trusted`:e===`unsupported`||t===`unsupported`?`unsupported`:`untrusted`,Uf=(e,t,n,r)=>{let i=Df(n),a=i.getOutermostTarget(t),o=a.parent;if(!o)return`unsupported`;if(S(o,`AssignmentExpression`)&&o.left===a){if(!S(a,`MemberExpression`))return`unsupported`;let t=k(a);return t===null?`trusted`:t===`trust`?Bf(o.right,n)?`untrusted`:`trusted`:e}if(S(o,`UnaryExpression`)&&o.operator===`delete`){if(!S(a,`MemberExpression`))return`unsupported`;let t=k(a);return t===null?`trusted`:t===`trust`?`absent`:e}if(S(o,`UpdateExpression`)){if(!S(a,`MemberExpression`))return`unsupported`;let t=k(a);return t===`trust`||t===null?`trusted`:e}if(!S(o,`CallExpression`)||o.arguments[0]!==a)return`unsupported`;if(i.isGlobalNamespaceMethod(o.callee,`Object`,uf)){let t=D(o.callee);if(!S(t,`MemberExpression`))return`unsupported`;let i=k(t);if(i===`assign`){let t=e;for(let e of o.arguments.slice(1)){let i=Wf(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=Lf(t,`trust`);return r===null?`trusted`:r===void 0?e:Vf(e,r,n)}let a=o.arguments[1];if(!a||!S(a,`Literal`)||typeof a.value!=`string`)return`trusted`;if(a.value!==`trust`)return e;let s=o.arguments[2];return s?Vf(e,s,n):`unsupported`}if(i.isGlobalNamespaceMethod(o.callee,`Reflect`,df)){let t=D(o.callee);if(!S(t,`MemberExpression`))return`unsupported`;let r=k(t),i=o.arguments[1];if(!i||!S(i,`Literal`)||typeof i.value!=`string`)return`trusted`;if(i.value!==`trust`)return e;let a=o.arguments[2];return a?r===`defineProperty`?Vf(e,a,n):Bf(a,n)?`untrusted`:`trusted`:`unsupported`}return`unsupported`},Wf=(e,t,n,r)=>{if(e===void 0)return`absent`;let i=D(e);if(S(i,`Identifier`)){if(i.name===`undefined`&&n.isGlobalReference(i))return`absent`;let e=A(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=Df(n);if(o.isMutationOrderAmbiguous(e,t,`trust`))return`unsupported`;let s=Wf(e.initializer,t,n,a);for(let r of o.getEventsBefore(e,t)){let e=Uf(s,r.node,n,a);s=r.isConditional?Hf(s,e):e}return s}if(!S(i,`ObjectExpression`))return`unsupported`;let a=`absent`;for(let e of i.properties){if(S(e,`SpreadElement`)){let t=Wf(e.argument,e.argument,n,new Set(r));t!==`absent`&&(a=t===`unsupported`?`trusted`:t);continue}if(!S(e,`Property`)){a=`trusted`;continue}let t=j(e,{allowComputedString:!0});if(t===null){a=`trusted`;continue}t===`trust`&&(a=Bf(e.value,n)?`untrusted`:`trusted`)}return a},Gf=(e,t,n)=>{let r=zf.get(e),i=new Map(r);for(let[e,n]of t)i.set(e,n);zf.set(e,i);try{return n()}finally{r?zf.set(e,r):zf.delete(e)}},Kf=(e,t,n,r)=>{let i=e?D(e):void 0;if(i&&S(i,`Identifier`)){let e=n.referenceFor(i)?.resolvedSymbol,t=e?zf.get(n)?.get(e.id):void 0;if(t)return t}let a=Wf(e,t,n,r);return{isSafe:a===`absent`||a===`untrusted`}},qf={containsKatex:!1,isConclusive:!0,isSafe:!0,isSafeInAttributeContext:!0},Jf={containsKatex:!1,isConclusive:!0,isSafe:!0,isSafeInAttributeContext:!1},Q={containsKatex:!1,isConclusive:!1,isSafe:!1,isSafeInAttributeContext:!1},Yf={containsKatex:!0,isConclusive:!1,isSafe:!1,isSafeInAttributeContext:!1},Xf={containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1},Zf=new WeakMap,Qf=new WeakMap,$f=(e,t,n)=>{Zf.set(e,t),Qf.set(e,n)},ep=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)}),tp=(e,t)=>{let n=D(e);if(!S(n,`ObjectExpression`))return{isKnown:!1,value:null};let r=!0,i=null;for(let e of n.properties){if(!S(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}},np=(e,t)=>{let n=D(e);if(S(n,`Identifier`)){let e=A(n,t);return!!(e&&e.kind===`import`&&ct(e)?.source.value===`react`&&R(e.declarationNode)===`useMemo`)}if(!S(n,`MemberExpression`)||k(n)!==`useMemo`)return!1;let r=A(D(n.object),t);return!!(r&&r.kind===`import`&&ct(r)?.source.value===`react`&&(S(r.declarationNode,`ImportDefaultSpecifier`)||S(r.declarationNode,`ImportNamespaceSpecifier`)||R(r.declarationNode)===`default`))},rp=(e,t)=>{let n=e=>{let r=D(e);if(S(r,`Identifier`)){let e=A(r,t);return!e||e.kind!==`const`||!e.initializer||e.references.some(e=>e.flag!==`read`)?null:n(e.initializer)}return!S(r,`Literal`)||!(`regex`in r)||!r.regex?null:r.regex},r=e=>{let t=D(e);if(!x(t))return null;if(!S(t.body,`BlockStatement`))return t.body;if(t.body.body.length!==1)return null;let n=t.body.body[0];return n&&S(n,`ReturnStatement`)?n.argument:null},i=e=>{let n=D(e);if(!x(n)||n.params.length!==1)return!1;let i=n.params[0],a=r(n);if(!i||!S(i,`Identifier`)||!a||!S(a,`MemberExpression`)||!a.computed||!S(D(a.property),`Identifier`))return!1;let o=D(a.property);if(t.referenceFor(o)?.resolvedSymbol!==t.symbolFor(i)||!S(D(a.object),`Identifier`))return!1;let s=A(D(a.object),t);if(!s||s.kind!==`const`||!s.initializer||s.references.some(e=>e.flag!==`read`))return!1;let c=tp(s.initializer,`<`);if(!c.isKnown||!c.value||!S(D(c.value),`Literal`))return!1;let l=D(c.value);return S(l,`Literal`)?typeof l.value==`string`&&!l.value.includes(`<`)&&!l.value.includes(`$`):!1},a=D(e),o=!1;for(;S(a,`CallExpression`);){let e=D(a.callee);if(!S(e,`MemberExpression`))return!1;let t=k(e);if(t!==`replace`&&t!==`replaceAll`)return!1;let r=a.arguments[0],s=a.arguments[1];if(!r||!s||!(S(s,`Literal`)&&typeof s.value==`string`&&!s.value.includes(`<`)&&!s.value.includes(`$`))&&!i(s))return!1;let c=n(r),l=t===`replaceAll`&&S(r,`Literal`)&&r.value===`<`,u=!!c?.flags.includes(`g`)&&(c?.pattern===`<`||/^\[[^\]]*<[^\]]*\]$/.test(c?.pattern??``));(l||u)&&(o=!0),a=D(e.object)}return!o||!S(a,`Identifier`)?!1:t.referenceFor(a)?.resolvedSymbol?.kind===`parameter`},ip=(e,t)=>{let n=D(e.callee);return S(n,`MemberExpression`)&&k(n)===`sanitize`&&(Mf(n.object,`dompurify`,`sanitize`,e,t)||Mf(n.object,`isomorphic-dompurify`,`sanitize`,e,t))?Jf:S(n,`MemberExpression`)&&k(n)===`escape`&&Mf(n.object,`html-escaper`,`escape`,e,t)||Nf(n,`html-escaper`,`escape`,e,t)?qf:Nf(n,`dompurify`,`sanitize`,e,t)||Nf(n,`isomorphic-dompurify`,`sanitize`,e,t)?Jf:null},ap=(e,t)=>{if(!t.isSafe)return null;let n=D(e.callee);if(!S(n,`MemberExpression`))return null;let r=k(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||!S(i,`Literal`)||typeof i.value!=`string`||i.value.includes(`<`)?null:{containsKatex:t.containsKatex,isConclusive:t.isConclusive,isSafe:!0,isSafeInAttributeContext:t.isSafeInAttributeContext&&!/[&>"']/.test(i.value)}},op=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`},sp=(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=op(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}},cp=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if(S(e,`BlockStatement`)){let t=e.body.findIndex(e=>e===n);if(t>0&&e.body.slice(0,t).some(e=>B(e)))return!0}if(S(e,`SwitchCase`)){let t=e.consequent.findIndex(e=>e===n);if(t>0&&e.consequent.slice(0,t).some(e=>B(e)))return!0}if(S(e,`IfStatement`)&&S(e.test,`Literal`)){let t=e.alternate,r=e.consequent,i=!!e.test.value;if(!i&&r===n||i&&t===n)return!0}if(S(e,`WhileStatement`)&&e.body===n){let t=e.test;if(S(t,`Literal`)&&!t.value)return!0}if(S(e,`ForStatement`)&&e.body===n){let t=e.test;if(t&&S(t,`Literal`)&&!t.value)return!0}n=e}return!1},lp=(e,t,n,r=new Map)=>{if(!x(e))return Q;if(!S(e.body,`BlockStatement`))return $(e.body,t,n,r);let i=e.body,a=[];return L(i,e=>{if(e!==i&&x(e))return!1;if(S(e,`ReturnStatement`))return cp(e,i)||a.push(e.argument?$(e.argument,t,new Set(n),r):qf),!1}),a.length===0?qf:ep(a)},up=(e,t,n,r,i=new Map)=>{if(!x(e))return Q;let a=[];if(!S(e.body,`BlockStatement`))a.push(e.body);else{let t=e.body;L(t,e=>{if(e!==t&&x(e))return!1;S(e,`ReturnStatement`)&&e.argument&&!cp(e,t)&&a.push(e.argument)})}return a.length===0?Q:ep(a.map(e=>{let a=tp(e,t);if(a.isKnown&&a.value!==null)return $(a.value,n,new Set(r),i);let o=D(e);return S(o,`CallExpression`)?pp(o,n,t)??Q:Q}))},dp=(e,t)=>{let n=D(e);if(!S(n,`Identifier`))return null;let r=A(n,t);if(!r||r.references.some(e=>e.flag!==`read`))return null;if(r.kind===`function`&&x(r.declarationNode))return{functionNode:r.declarationNode,symbol:r};if(r.kind!==`const`||!r.initializer)return null;let i=D(r.initializer);return x(i)?{functionNode:i,symbol:r}:null},fp=(e,t,n,r)=>{let i=new Map;if(!x(e))return i;let a=(e,t)=>e===void 0||S(e,`Identifier`)&&e.name===`undefined`&&t.isGlobalReference(e)||S(e,`UnaryExpression`)&&e.operator===`void`,o=(e,t,n,a)=>a?Gf(r,i,()=>Kf(e,t,n,new Set)):Kf(e,t,n,new Set);for(let[s,c]of e.params.entries()){let e=t.arguments[s],l=S(c,`AssignmentPattern`)&&a(e,n),u=l&&S(c,`AssignmentPattern`)?c.right:e,d=l?r:n,f=l?c:t,p=S(c,`AssignmentPattern`)?c.left:c;if(S(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(!(!S(p,`ObjectPattern`)||!u))for(let e of p.properties){if(!S(e,`Property`))continue;let t=j(e,{allowComputedString:!0});if(t===null)continue;let n=tp(u,t),s=S(e.value,`AssignmentPattern`)?e.value.left:e.value;if(!S(s,`Identifier`))continue;let c=r.symbolFor(s);if(!n.isKnown||!c||c.references.some(e=>e.flag!==`read`))continue;let l=S(e.value,`AssignmentPattern`)&&(n.value===null||a(n.value??void 0,d)),p=l&&S(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},pp=(e,t,n)=>{let r=D(e.callee);if(!S(r,`Identifier`))return null;let i=A(r,t);if(!i||i.kind!==`import`)return null;let a=ct(i),o=R(i.declarationNode),s=Zf.get(t),c=a?.source.value,l=Qf.get(t)??0;if(!s||typeof c!=`string`||!o||l>=2)return null;let u=Vn(s,c,o);if(!u||!x(u.functionNode))return null;let d=Ge(u.programNode);return $f(d,u.filePath,l+1),Gf(d,fp(u.functionNode,e,t,d),()=>n?up(u.functionNode,n,d,new Set):lp(u.functionNode,d,new Set))},mp=(e,t,n,r)=>{if(!S(e,`CallExpression`))return Q;let i=D(e.callee);if(S(i,`MemberExpression`)&&k(i)===`get`){let e=D(i.object);if(S(e,`Identifier`)){let i=A(e,t),a=i?.initializer?D(i.initializer):null,o=a&&S(a,`NewExpression`)?D(a.callee):null;if(i?.kind===`const`&&a&&S(a,`NewExpression`)&&S(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||!S(i,`MemberExpression`)||i.object!==n.identifier){o=!0;break}let s=k(i);if(s===`size`)continue;let c=i.parent;if(!c||!S(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 ep(a)}}}if(S(i,`MemberExpression`)&&k(i)===`renderToString`&&Pf(i.object,e,t)||Ff(i,e,t))return{containsKatex:!0,isConclusive:!0,isSafe:Kf(e.arguments[1],e,t,new Set).isSafe,isSafeInAttributeContext:!1};let a=pp(e,t);if(a?.containsKatex)return a;let o=dp(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=D(e);return x(i)?lp(i,t,new Set(n),r):$(i,t,new Set(n),r)}),s=new Map,c=!1;if(x(o.functionNode))for(let[e,n]of o.functionNode.params.entries()){if(!S(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=Gf(t,fp(o.functionNode,e,t,t),()=>lp(o.functionNode,t,i,s));return!a.some(e=>e.containsKatex)||l.containsKatex?l:c?Yf:Xf}if(If(i,t))return{containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1};if(S(i,`MemberExpression`)){let a=$(i.object,t,new Set(n),r);if(a.containsKatex)return ap(e,a)||(a.isConclusive?{containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1}:Yf)}let s=ip(e,t);if(s)return s;if(rp(e,t))return Jf;if(np(i,t)){let i=e.arguments[0];if(!i)return Q;let a=D(i);if(x(a))return lp(a,t,new Set(n),r);let o=dp(a,t);if(!o||n.has(o.symbol.id))return Q;let s=new Set(n);return s.add(o.symbol.id),lp(o.functionNode,t,s,r)}return e.arguments.some(e=>{let i=D(e);return(x(i)?lp(i,t,new Set(n),r):$(i,t,new Set(n),r)).containsKatex})?Yf:Q},hp=(e,t)=>{let n=af(e);if(S(n,`Literal`))return!!n.value;if(S(n,`Identifier`)&&(n.name===`undefined`||n.name===`NaN`)&&t.isGlobalReference(n))return!1;if(S(n,`TemplateLiteral`)){let e=vt(n);return e===null?null:!!e}if(S(n,`ArrayExpression`)||S(n,`ObjectExpression`)||S(n,`ArrowFunctionExpression`)||S(n,`FunctionExpression`)||S(n,`ClassExpression`)||S(n,`NewExpression`)||S(n,`JSXElement`)||S(n,`JSXFragment`))return!0;if(S(n,`UnaryExpression`)){if(n.operator===`void`)return!1;if(n.operator===`typeof`)return!0;if(n.operator===`!`){let e=hp(n.argument,t);return e===null?null:!e}}return null},$=(e,t,n,r=new Map)=>{let i=D(e);if(S(i,`Literal`)||S(i,`UnaryExpression`)&&i.operator===`void`)return qf;if(S(i,`Identifier`)){if((i.name===`undefined`||i.name===`NaN`)&&t.isGlobalReference(i))return qf;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=ao(t.identifier);if(!e)return Q;n.push(e)}return n.length===0?Q:ep(n.map(e=>$(e,t,new Set(o),r)))}return e.kind!==`const`||!e.initializer?Q:$(e.initializer,t,o,r)}if(S(i,`CallExpression`))return mp(i,t,n,r);if(S(i,`MemberExpression`)){let e=k(i),a=D(i.object);if(e&&S(a,`Identifier`)){let i=t.referenceFor(a)?.resolvedSymbol,o=i?.initializer?D(i.initializer):null;if(i?.kind===`const`&&o&&S(o,`CallExpression`)){if(np(o.callee,t)){let i=o.arguments[0],a=i?D(i):null;if(a&&x(a)){let i=up(a,e,t,new Set(n),r);if(i.containsKatex)return i}}let i=pp(o,t,e);if(i?.containsKatex)return i}}return Q}if(S(i,`TemplateLiteral`))return sp(i,t,n,r);if(S(i,`ConditionalExpression`)){let e=hp(i.test,t);return e===null?ep([$(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(S(i,`LogicalExpression`)){let e=i.operator===`??`?null:hp(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=lf(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:ep(a.map(e=>$(e,t,new Set(n),r))),containsKatex:o.some(e=>e.containsKatex)}}if(S(i,`BinaryExpression`)&&i.operator===`+`)return ep([$(i.left,t,new Set(n),r),$(i.right,t,new Set(n),r)]);if(S(i,`SequenceExpression`)){let e=i.expressions.at(-1);return e?$(e,t,n,r):Q}return Q},gp=e=>{let t=null;if(S(e,`JSXAttribute`)&&S(e.name,`JSXIdentifier`)&&e.name.name===`dangerouslySetInnerHTML`&&S(e.value,`JSXExpressionContainer`)&&S(e.value.expression,`ObjectExpression`)&&(t=e.value.expression),S(e,`Property`)&&j(e,{allowComputedString:!0})===`dangerouslySetInnerHTML`&&S(D(e.value),`ObjectExpression`)&&(t=D(e.value)),!S(t,`ObjectExpression`))return null;let n=null;for(let e of t.properties){if(S(e,`SpreadElement`)){n=null;continue}if(!S(e,`Property`)){n=null;continue}let t=j(e,{allowComputedString:!0});if(t===null){n=null;continue}t===`__html`&&(n=e.value)}return n},_p=(e,t)=>{let n=Jt({filename:t,sourceText:e});if(n===null)return[];let r=Ge(n);$f(r,t,0);let i=[];return L(n,e=>{let t=gp(e);if(t===null)return;let n=$(t,r,new Set);if(!n.containsKatex)return;let a=X(e),o=rf(e);a<0||o<0||i.push({endIndex:o,proof:n,startIndex:a})}),i},vp=/dangerouslySetInnerHTML|(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\(|\bdocument\.write(?:ln)?\s*\(|\.(?:createContextualFragment|setHTMLUnsafe)\s*\(/,yp=/(?:__html\s*:|(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\(\s*[^,]*,|\bdocument\.write(?:ln)?\s*\(|\.(?:createContextualFragment|setHTMLUnsafe)\s*\()\s*([\s\S]*)/,bp=/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,xp=/^(?:"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`[^`$]*`)\s*(?:\/\/[^\n]*)?\s*(?:[;,})\n]|$)/,Sp=/^[A-Z][A-Z0-9_]*\s*(?:\/\/[^\n]*)?\s*(?:[;,})\n]|$)/,Cp=/^[\w$]+(?:\??\.[\w$]+)*\??\.(?:inner|outer)HTML\b/,wp=/\b(?:DOMPurify|sanitize\w*|purify|(?:escape|encode)[A-Za-z]*(?:Html|HTML|Entit\w*)|insane|xss)\b|(?<!un)safe|(?<!un)saniti[sz]/i,Tp=/[:=]\s*[^\n;]*\b(?:DOMPurify\b|sanitize\w*\s*\(|purify\w*\s*\()/i,Ep=/=\s*[\w$.?[\]]*\.(?:inner|outer)HTML\s*(?:[;,)\n]|$)/,Dp=/process\.env/,Op=/\b(?:t|i18n|translate|formatMessage|intl)\s*[.(]/,kp=/^(?:[\w$.]+\.)?(?:toHtml|render[A-Za-z]*(?:Html|HTML)|renderToString|renderToStaticMarkup|codeToHtml|codeToHast|highlight[A-Za-z]*)\s*\(/,Ap=/\b(?:shiki|prism|hljs|highlightjs|getHighlighter|codeToHtml|codeToHast|refractor|lowlight|starry-night)\b|highlight\.js/i,jp=/[:=]\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,Np=/^[\w$]+\s*(?:[;,})\n]|$)/,Pp=/^[\w$]+\s*(?:\|\||\?\?)\s*(?:"[^"\n]*"|'[^'\n]*'|`[^`$]*`)\s*(?:[;,})\n]|$)/,Fp=/^[\w$]+(?:\.[\w$]+|\[[^\]]*\])+\s*(?:[;,})\n]|$)/,Ip=/<style\b[^<>]*$/,Lp=/(?:^|\/)emails(?:\/|$)|email[-_.]templates?(?:\/|$)|RawHtml|[A-Za-z]*[Ee]mail[A-Za-z]*\.(?:t|j)sx?/i,Rp=/(?:^|\/)\.[\w-]+\//,zp=/(?<!un)saniti[sz]e?d?[\w-]*\.[cm]?[jt]sx?$/i,Bp=/(?:^|[^\w$.])([\w$]+(?:\.[\w$]+)*)(?:(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\()/,Vp=/\b(?:appendChild|append|prepend|before|after|replaceWith|replaceChild|replaceChildren|insertBefore|insertAdjacentElement)\s*\(/,Hp=5e3,Up=e=>{if(!e.startsWith("`"))return null;let t=e.indexOf("`",1);if(t<0||t>Hp)return null;let n=e.slice(1,t).match(/\$\{[^}]*\}/g);return n===null?``:n.join(` `)},Wp=(e,t,n)=>{let r=Zp(e,t,n);return r===null?null:n.slice(r.initializerStartIndex,r.initializerStartIndex+Hp)},Gp=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)},Kp=(e,t)=>{let n=t.includes(`createElement`),r=t.includes(`createHTMLDocument`);if(!n&&!r)return!1;let i=J(e),a=J(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(`${Vp.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)},qp=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},Jp=e=>{let t=e.replace(/[;}]\s*$/,``).trim();if(!t.includes(`+`))return!1;let n=[];for(let e of qp(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 Cp.test(t)?!bp.test(t.replace(Cp,``)):!1})},Yp=(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},Xp=(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:Yp(e,o)},Zp=(e,t,n)=>{let r=RegExp(`(const|let|var)\\s+${J(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||Xp(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},Qp=(e,t,n,r)=>{if(t.isImmutable)return!0;let i=r.slice(t.initializerStartIndex+t.initializer.length,n);return!RegExp(`(?:^|[^\\w$.])${J(e)}\\s*=(?!=)`).test(i)},$p=(e,t,n)=>{if(!/highlight/i.test(e))return!1;let r=e.match(/^([\w$]+)/)?.[1];if(r===void 0)return!1;let i=Zp(r,n,t);return i===null?/highlighted/i.test(e)||Ap.test(t):Qp(r,i,n,t)&&Mp.test(i.initializer)},em=(e,t,n,r=new Set)=>{let i=e.trim(),a=qp(i);if(a.length>1)return a.every(e=>em(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=>em(e,t,n,r));let s=i.match(/^([\w$]+)(?:(?:\??\.[\w$]+)|(?:\[\s*(?:"[^"\n]*"|'[^'\n]*'|\d+)\s*\]))*$/)?.[1];if(s&&!r.has(s)){let e=Zp(s,n,t);if(e&&Qp(s,e,n,t)){let n=new Set(r);return n.add(s),em(e.initializer,t,e.initializerStartIndex,n)}}return!!(xp.test(`${i};`)||Sp.test(`${i};`)||wp.test(i)||Dp.test(i)||Op.test(i)||kp.test(i)||$p(i,t,n))},tm=(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=Zp(a,n,r);if(!o?.isImmutable)return!1;let s=new Set(i);return s.add(a),tm(o.initializer,t,o.initializerStartIndex,r,s)},nm=(e,t,n)=>{let r=n.slice(Math.max(0,t-Hp),t),i=J(e);return RegExp(`(?:function\\s+[\\w$]+|(?:const|let|var)\\s+[\\w$]+\\s*=)\\s*\\(\\s*\\{[^}]*\\b${i}\\b[^}]*\\}`).test(r)},rm=(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=Yp(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},im=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},am=(e,t,n,r=new Set)=>{let i=e.trim().match(/^([\w$]+)$/)?.[1];if(i===void 0||r.has(i))return!1;if(rm(i,t,n)!==null)return!0;let a=Zp(i,t,n);if(!a||!Qp(i,a,t,n))return!1;let o=new Set(r);return o.add(i),am(a.initializer,a.initializerStartIndex,n,o)},om=(e,t,n,r,i)=>{let a=e.trim();if(em(a,t,n))return!1;let o=a.match(/^([\w$]+)(?:\.|\s*(?:(?:\|\||\?\?)|[;,})\n]|$))/)?.[1];if(o===void 0)return bp.test(a);if(nm(o,n,t))return!0;if(r.has(o))return!1;r.add(o);let s=Zp(o,n,t),c=rm(o,n,t);if(s!==null&&(c===null||s.declarationIndex>c.declarationNameIndex))return Qp(o,s,n,t)&&em(s.initializer,t,s.initializerStartIndex)?!1:!Qp(o,s,n,t)||om(s.initializer,t,s.initializerStartIndex,r,i)?!0:am(s.initializer,s.initializerStartIndex,t)?!1:bp.test(a);if(c!==null&&c.functionName.length>0){let e=RegExp(`\\b${J(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=nf(t,e);if(s<0)continue;let l=im(t.slice(e+1,s))[c.parameterIndex];if(l===void 0||a.index>=c.declarationNameIndex&&a.index<=c.bodyEndIndex&&tm(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),om(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:bp.test(a)}return bp.test(a)},sm=W({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||!K(e.relativePath)||Lp.test(e.relativePath)||Rp.test(e.relativePath)||zp.test(e.relativePath)||!vp.test(e.content))return[];let t=_p(e.content,e.absolutePath),n=[],r=e.content.split(`
|
|
11
|
+
`);for(let i=0;i<r.length;i+=1){let a=r[i]??``;if(!vp.test(a))continue;let o=a.slice(0,a.search(vp)).replace(/"[^"]*"|'[^']*'|`[^`]*`/g,``);if(/(?:^|[^:])\/\//.test(o)||/^\s*[/*]/.test(a))continue;let s=r.slice(i,i+1+4).join(`
|
|
12
|
+
`),c=yp.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(vp),m=t.find(e=>p>=e.startIndex&&p<e.endIndex)?.proof;if(m?.isConclusive&&m.isSafe)continue;let h=m?.isConclusive===!0;if(xp.test(f)||Sp.test(f))continue;if(Cp.test(f)&&!f.includes(`+`)){let e=f.replace(Cp,``);if(!bp.test(e))continue}if(Jp(f))continue;let g=yp.exec(r.slice(i,i+1+60).join(`
|
|
14
|
+
`))?.[1]?.trimStart(),_=Up(g??l),v=Np.test(f)||Fp.test(f)||Pp.test(f)?f.match(/^[\w$]+/)?.[0]:void 0;if(_===null&&v!==void 0&&Np.test(f)&&rm(v,p,e.content)===null){let t=Wp(v,p,e.content);if(t!==null){if(Gp(t))continue;_=Up(t)}}if(_===``)continue;let y=_??f,ee=qp(y).length>1||(_?.match(/\$\{/g)?.length??0)>1;if(!h&&!ee&&wp.test(y)||!ee&&Dp.test(y)||!ee&&Op.test(y)||!h&&!om(y,e.content,p,new Set,new Set)||!h&&kp.test(f)||!h&&$p(f,e.content,p))continue;if(v!==void 0){let t=J(v),n=Zp(v,p,e.content),r=n?.initializer;if(!(r!==void 0&&(qp(r).length>1||(r.match(/\$\{/g)?.length??0)>1))){let i=RegExp(`\\b${t}\\b\\s*${jp.source}`,`i`);if(!h&&(r===void 0?i.test(e.content):n!==null&&Qp(v,n,p,e.content)&&Mp.test(r)))continue;let a=RegExp(`\\b${t}\\b\\s*${Tp.source}`,`i`);if(!h&&(r===void 0?a.test(e.content):n!==null&&Qp(v,n,p,e.content)&&Tp.test(`=${r}`)))continue}if(RegExp(`\\b${t}\\b\\s*${Ep.source}`).test(e.content)||RegExp(`highlight[\\w$]*\\s*\\.map\\(\\s*(?:async\\s+)?\\(?\\s*${t}\\b`,`i`).test(e.content)&&Ap.test(e.content))continue}if(Fp.test(f)){let t=f.match(/\.([\w$]+)\s*(?:[;,})\n]|$)/)?.[1];if(t!==void 0&&RegExp(`\\b${J(t)}\\s*:\\s*${Op.source}`).test(e.content))continue}let te=Bp.exec(a),ne=te?.[1]??te?.[2];if(ne!==void 0&&Kp(ne,e.content))continue;let re=r.slice(Math.max(0,i-5),i+1).join(`
|
|
15
|
+
`).slice(0,-a.length+a.search(vp));Ip.test(re)||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}}),cm=e=>!(!K(e)||Vl.test(e)||Ul.test(e)),lm=/firebase|firestore|supabase|\b(?:setDoc|addDoc)\s*\(/i,um=W({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:q({shouldScan:e=>cm(e.relativePath)&&(lm.test(e.content)||lm.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.`})}),dm=W({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:q({shouldScan:e=>su(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.`})}),fm=W({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:q({shouldScan:e=>cm(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.`})}),pm=/api\.github\.com|github\.com|gitlab\.com|bitbucket\.org/gi,mm=/\$\{([^}]*)\}/g,hm=/\b(?:params|searchParams|query|req|request|input|payload)\s*[.[]|\buntrusted|\bdecodeURI\w*/,gm=/encodeURIComponent\s*\(/,_m=/^\s*[\w$]+\.toString\(\)\s*$/,vm=W({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(!K(e.relativePath))return[];let t=[];for(let n of e.content.matchAll(pm)){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(mm)).some(e=>{let t=e[1]??``;return hm.test(t)&&!gm.test(t)&&!_m.test(t)}))continue;let o=G(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}}),ym=/child_process|childProcess|execa|subprocess|Deno\.run/,bm=/(?:\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*["'])/,xm=/(?:\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*["'])/,Sm=`Imported metadata, uploads, or plugin manifests appear to reach code execution.`,Cm=q({shouldScan:()=>!0,pattern:bm,ignoreStringLiterals:!0,message:Sm}),wm=q({shouldScan:()=>!0,pattern:xm,ignoreStringLiterals:!0,message:Sm}),Tm=W({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=>K(e.relativePath)?ym.test(e.content)?Cm(e):wm(e):[]}),Em=/createHash\s*\(\s*["'](?:md5|sha1)["']|\bmd5\s*\(/gi,Dm=/\b(?:password|token|secret|signature|signing|auth|credential|session|cookie|csrf|api.?key)\b/i,Om=/(?<!cipher\.)\bcreate(?:Cipher|Decipher)\s*\(/,km=/\bcreate(?:Cipher|Decipher)iv\s*\(\s*["'](?:des|des3|des-?ede3?|rc4|rc2|bf|blowfish)\b/i,Am=/\b(?:DES|RC4|Blowfish)\b/,jm=/\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,Nm=/(?:===?|!==?)\s*[A-Z](?:[a-z]|[A-Z0-9_]*\b(?!\s*[.(]))|^[A-Z](?:[a-z]|[A-Z0-9_]*\b(?!\s*[.(]))[\w$.]*(?:\([^)]*\))?\s*(?:===?|!==?)/,Pm=/signature(?:Method|Type|Status|Algorithm|Kind|Mode|Version)\b/i,Fm=/(?:===?|!==?)\s*(?:true|false|null|undefined)\b/,Im=/\.(?:length|size|byteLength)\s*(?:===?|!==?)|\.(?:length|size|byteLength)\s*$/,Lm=/\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,Rm=/\.[cm]?[jt]sx$/i,zm=/timingSafeEqual|timing.?safe/i,Bm=/gravatar|digest[-_ ]?auth|oauth[-_ ]?1|pkcs#?12|smime|\b_id\b|\betag\b|checksum|cache[-_ ]?key|fingerprint/i,Vm=/token|secret|password|nonce|salt|csrf|credential|otp/i,Hm=/(?:focus|render|refresh|remount|redraw|animation|layout|cache|update)[-_]?nonce/i,Um=/Math\.random\s*\(/g,Wm=/createHash|md5|cipher|encrypt|decrypt|crypto|signature|Math\.random/i,Gm=(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},Km=(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},qm=W({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(!K(e.relativePath)||Gl.test(e.relativePath)||Bm.test(e.relativePath)||!Wm.test(e.content))return[];let t=Tu(e),n=Gm(t,Em,Dm,Bm);if(n<0&&(n=t.search(km)),n<0&&(n=t.search(Om)),n<0&&jm.test(t)&&(n=t.search(Am)),n<0&&!zm.test(t)&&!Rm.test(e.relativePath)&&Lm.test(t)){let e=Mm.exec(t);e!==null&&!Nm.test(e[0])&&!Pm.test(e[0])&&!Fm.test(e[0])&&!Im.test(e[0])&&(n=e.index)}if(n<0&&(n=Km(t,Um,Vm,Hm)),n<0)return[];let r=G(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}]}}),Jm=`(?<![A-Za-z0-9])(?:session|sess|sid|connect\\.sid|auth|jwt|access[_-]?token|refresh[_-]?token|id[_-]?token)(?![A-Za-z0-9])`,Ym=`[\`"'][^\`"']*?${Jm}[^\`"']*[\`"']`,Xm=RegExp(`(?:\\.cookies\\.set|cookies\\(\\s*\\)\\.set|\\.cookie)\\s*\\(\\s*${Ym}`,`gi`),Zm=/httpOnly\s*:\s*false\b/i,Qm=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`/g,$m=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(``)},eh=/cookie\s*:\s*\{/gi,th=RegExp(`document\\.cookie\\s*=\\s*[\`"'][^\`"'=;]*?${Jm}[^\`"'=;]*=`,`gi`),nh=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},rh=(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=G(e,a.index);i.push({message:n,line:t.line,column:t.column})}},ih=W({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(!K(e.relativePath))return[];let t=Tu(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.`;Xm.lastIndex=0;for(let e=Xm.exec(t);e!==null;e=Xm.exec(t)){let i=e.index+e[0].lastIndexOf(`(`),a=nf(t,i);if(a<0)continue;let o=t.slice(i+1,a),s=nh(o)<3,c=o.replace(Qm,``);if(!s&&!Zm.test(c))continue;let l=G(t,e.index);n.push({message:r,line:l.line,column:l.column})}let i=$m(t);eh.lastIndex=0;for(let e=eh.exec(i);e!==null;e=eh.exec(i)){let t=e.index+e[0].length-1,a=nf(i,t),o=a>=0?i.slice(t,a):i.slice(t,t+400);if(!Zm.test(o))continue;let s=G(i,e.index);n.push({message:r,line:s.line,column:s.column})}return rh(t,th,r,()=>!0,n),n}}),ah=/\b(?:alg|algorithms?)\s*:\s*\[?\s*["'`]none["'`]/gi,oh=(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},sh=W({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(!K(e.relativePath))return[];let t=Tu(e);if(!/\bjwt\b|jsonwebtoken|\bjose\b/i.test(t))return[];let n=[];ah.lastIndex=0;for(let e=ah.exec(t);e!==null;e=ah.exec(t)){if(oh(t,e.index))continue;let r=G(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}}),ch=/PRIVATE KEY|SSH_PRIVATE_KEY|GPG_PRIVATE_KEY|DEPLOY_KEY|SIGNING_KEY/i,lh=W({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:q({shouldScan:e=>!Hl.test(e.relativePath)&&!Kl.test(e.relativePath)&&ch.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.`})}),uh=W({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:q({shouldScan:e=>K(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.`})}),dh=/\bfrom\s+["']@modelcontextprotocol\/sdk[^"']*["']|\bMcpServer\b|\bMcpAgent\b/,fh=/@modelcontextprotocol\/sdk|\bMcpServer\b|\bMcpAgent\b/,ph=/\bserver\.\s*tool\s*\(|\bregisterTool\s*\(|\bsetRequestHandler\s*\(\s*CallToolRequestSchema/,mh=/\b(?:tool|registerTool|setRequestHandler)\b/,hh=W({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:q({shouldScan:e=>K(e.relativePath)&&fh.test(e.content)&&mh.test(e.content)&&Xl.test(e.content),pattern:ph,requireAll:[dh,Xl],ignoreStringLiterals:!0,message:`An MCP tool/resource/prompt handler appears to expose file, shell, network, or code-execution capability.`})}),gh=W({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:q({shouldScan:e=>K(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.`})}),_h=W({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:q({shouldScan:e=>nu(e.relativePath,Bl),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."})}),vh=[...Hu.filter(e=>!e.test(`service_role`)),Uu],yh=W({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=gd(e.content)??vh.find(t=>t.test(e.content));if(t===void 0)return[];let n=Fl(e.content,t);return[{message:`Package metadata contains secret-like values or public env secret names.`,line:n.line,column:n.column}]}}),bh=W({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:q({shouldScan:e=>K(e.relativePath)&&!qd(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.`})}),xh=/\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,Sh=/\b(?:curl|wget)\b(?=(?:[^\r\n]|\\\r?\n)*https?:\/\/)(?:[^\r\n]|\\\r?\n)*?\|\s*(?:bash|sh)\b/i,Ch=/sha(?:256|512|1)sum|--checksum|checksum=|EXPECTED_SHA|gpg\s+--verify|\.sha(?:256|512)\b/i,wh=/\b(?:child_process|childProcess|execa|os\.system|subprocess\.|Deno\.run|autoUpdater|electron-updater)\b|\b(?:exec(?:File)?(?:Sync)?|spawn(?:Sync)?)\s*\(/,Th=/.\/\.github\/workflows\//i,Eh=/(?:^|\/)[\w-]+[.@-]\d+\.\d+\.\d+(?:[-.][\w.]+)?\//,Dh=e=>eu(e)&&!Th.test(e)&&!Eh.test(e)&&!Gl.test(e),Oh=W({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(!K(e.relativePath)&&!Dh(e.relativePath))return[];let t=Tu(e),n=Sh.test(t);if(!n&&!xh.test(t))return[];let r=n?Sh:xh;if(Ch.test(t)||Rl.test(e.relativePath)&&!wh.test(t))return[];let i=Fl(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}]}}),kh=/origin(?!al)|\.source\s*[!=]==?/i,Ah=/\b(?:event|e|evt|msg|message)\.data\b/,jh=/\b(?:const|let|var)\s+[^;=]*=\s*$/,Mh=/port\d?\b|worker|channel|broadcast|socket|\bws\b|\bsse\b|eventsource|^_?self\.|^source\./i,Nh=String.raw`=\s*new\s+(?:EventSource|WebSocket|Worker|SharedWorker|BroadcastChannel|MessageChannel)\b`,Ph=(e,t)=>{let n=/^[\w$]+/.exec(e)?.[0];return n===void 0?!1:RegExp(`(?<![\\w$.])${J(n)}\\s*${Nh}`).test(t)},Fh=(e,t)=>{let n=/^[\w$]+/.exec(e)?.[0];return n===void 0?!1:RegExp(`(?:^|[(,{;]\\s*)${J(n)}\\s*[?!]?\\s*:\\s*(?:Worker|SharedWorker|MessagePort|BroadcastChannel|WebSocket|EventSource)\\b`,`m`).test(t)},Ih=/worker/i,Lh=(e,t)=>{let n=X(t),r=rf(t);return n<0||r<0?``:e.slice(n,r)},Rh=(e,t)=>{if(t.type===`CallExpression`){let n=b(t.callee)?Lh(e,t.callee):``;if(!n.endsWith(`addEventListener`))return null;let r=t.arguments[0];return b(r)&&r.type===`Literal`&&r.value===`message`?n:null}if(t.type===`AssignmentExpression`&&b(t.left)){let n=Lh(e,t.left);return n.endsWith(`.onmessage`)?n:null}return null},zh=W({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(!K(e.relativePath)||Ih.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=Jt({filename:e.absolutePath,sourceText:e.content,shouldAttachParentReferences:!1});if(r===null)return[];let i=[];return L(r,t=>{let n=Rh(e.content,t);if(n===null||Mh.test(n)||Ph(n,e.content)||Fh(n,e.content))return;let r=Lh(e.content,t),a=r.search(Ah);if(a<0)return;let o=r.search(kh);if(o>=0&&(jh.test(r.slice(0,a))||o<a))return;let s=G(e.content,X(t));i.push({message:`A message event handler reads cross-window messages without an obvious origin check.`,line:s.line,column:s.column})}),i}}),Bh=/(?:^|\/)(?:locales?|i18n|lang|langs|translations?)\//i,Vh=/(?:^|\/)(?:\.env(?:\.[^/]*)?|(?:debug|crash|trace|stack[-_]?trace|report|dump|phpinfo)(?:[-_.][^/]*)?\.(?:txt|log|json|html?)|[^/]+\.log)$/i,Hh=e=>$l(e,Jl.test(e))&&!Bh.test(e)&&Vh.test(e),Uh=W({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(!Hh(e.relativePath))return[];let t={message:`A browser-reachable debug, log, dump, report, or env artifact is present.`,line:1,column:1};return[Hu.some(t=>t.test(e.content))?{...t,severity:`error`}:t]}}),Wh=/(?:^|\/)docs?\//i,Gh=W({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(!cm(e.relativePath)||Wh.test(e.relativePath))return[];let t=gd(e.content);if(t===void 0)return[];let n=Fl(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}]}}),Kh=`(?:"[^"\\n]{0,200}"|'[^'\\n]{0,200}'|\`[^\`$]{0,200}\`)`,qh=`\\s*\\(?\\s*(?:${Kh}|(?:[\\w\$]+(?:\\.[\\w\$]+)*\\.escape(?:Id|Literal|Identifier)|(?:[\\w\$]+\\.)*(?:connection|conn|client|pool|db|mysql|sqlstring|knex)\\.escape)\\s*\\([^()]{0,200}\\))\\s*\\)?`,Jh=W({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:q({shouldScan:e=>Jd(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*${Kh}(?:\\s*\\+${qh})*\\s*\\+(?!${qh})`,`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.`})}),Yh=e=>Ll.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),Xh=e=>/(?:^|\/)\.env(?:\.[^./]+)*\.(?:example|sample|template|dist|defaults?)$|(?:^|\/)[^/]*(?:example|sample|template)[^/]*\.(?:env|json|pem|key)$/i.test(e),Zh=W({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(!Yh(e.relativePath)||Xh(e.relativePath)||Hl.test(e.relativePath))return[];let t=Hu.find(t=>t.test(e.content))??gd(e.content);if(t===void 0)return[];let n=Fl(e.content,t);return[{message:`A repository credential/config file contains secret-looking values.`,line:n.line,column:n.column}]}}),Qh=`(?:req|request|ctx\\.req|ctx\\.request)\\.(?:body|query|params)|await\\s+(?:req|request)\\.json\\(\\s*\\)`,$h=W({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:q({shouldScan:e=>K(e.relativePath),pattern:[RegExp(`\\.\\.\\.\\s*(?:${Qh})`,`i`),RegExp(`(?:Object\\.assign\\s*\\(|_\\.(?:merge|mergeWith|defaultsDeep)\\s*\\(|(?:^|[^.\\w])(?:merge|defaultsDeep)\\s*\\()[\\s\\S]{0,80}?(?:${Qh})`,`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.`})}),eg=W({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:q({shouldScan:e=>K(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.`})}),tg=(e,t)=>{let n=null;if(S(e,`Program`)?n=e.body:(S(e,`FunctionDeclaration`)||S(e,`FunctionExpression`)||S(e,`ArrowFunctionExpression`))&&S(e.body,`BlockStatement`)&&(n=e.body.body),n===null)return!1;for(let e of n){if(!S(e,`ExpressionStatement`)||e.directive===void 0)return!1;if(e.directive===t)return!0}return!1},ng=(e,t=`source.tsx`)=>{let n=Jt({filename:t,sourceText:e,shouldAttachParentReferences:!1});return n===null?!1:tg(n,`use server`)},rg=q({shouldScan:e=>cm(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.`}),ig=W({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=rg(e);return t.length===0?t:ng(e.content,e.relativePath)?[]:t}}),ag=e=>/(?:^|\/)supabase\/(?:migrations|schemas)\//.test(e),og=e=>e.endsWith(`.sql`)||ag(e),sg=/^\$[A-Za-z_]?\w*\$/,cg=new Set([`do`,`plpgsql`,`sql`,`plpython3u`,`plpythonu`,`plperl`,`plperlu`,`plv8`]),lg=(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()},ug=(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}},dg=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=sg.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=lg(e,n);if(cg.has(s))ug(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(``)},fg=/disable\s+row\s+level\s+security/i,pg=/auth\.role\(\)\s*=\s*["']service_role["']/i,mg=/create\s+policy/gi,hg=/;|create\s+policy/i,gg=/\b(?:using|with\s+check)\s*\(\s*true\s*\)/i,_g=/\bfor\s+select\b/i,vg=/\bto\s+([\s\S]+?)(?=\s+(?:using|with\s+check|as|for)\b|;|$)/i,yg=new Set([`service_role`,`postgres`,`supabase_admin`]),bg=e=>{let t=vg.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=>yg.has(e))},xg=(e,t)=>pg.test(t)?!0:!gg.test(e)||_g.test(e)?!1:!bg(e),Sg=W({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(!og(e.relativePath))return[];let t=dg(e.content),n=t.search(fg);mg.lastIndex=0;for(let r=mg.exec(t);r!==null;r=mg.exec(t)){let i=r.index+r[0].length,a=t.slice(i).search(hg),o=a<0?t.length:i+a;if(xg(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}=G(t,n);return[{message:`Supabase policy SQL disables RLS, permits writes broadly, or references a service-role bypass.`,line:r,column:i}]}}),Cg=/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,wg=/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,Tg=/\benable\s+row\s+level\s+security\b/gi,Eg=e=>{let t=new Map,n=0;for(let r of e.matchAll(wg)){let e=r[1];e!==void 0&&(n+=1,t.set(e.toLowerCase(),r.index))}return{lastEnableIndexByTable:t,staticEnableCount:n}},Dg=(e,t)=>(e.match(Tg)?.length??0)>t,Og=W({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(!ag(e.relativePath))return[];let t=dg(e.content);if(!/create\s+(?:unlogged\s+)?table/i.test(t))return[];let n=[],{lastEnableIndexByTable:r,staticEnableCount:i}=Eg(t);if(Dg(t,i))return[];Cg.lastIndex=0;for(let e=Cg.exec(t);e!==null;e=Cg.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=G(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}}),kg=W({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:q({shouldScan:e=>K(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.`})}),Ag=e=>K(e)?Vl.test(e)?!0:/(?:^|\/)(?:middleware|route)\.[cm]?[jt]sx?$/.test(e):!1,jg=W({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:q({shouldScan:e=>Ag(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],Ng=/\$\{|["'`]\s*\+\s*$/,Pg=/^\s*\{(?!\{)/,Fg=/"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'/g,Ig=/\b(?:true|false|null)\b|[\d.]+(?:e[+-]?\d+)?/gi,Lg=e=>{if(e.includes("`")||e.includes("${"))return!1;let t=e.replace(Fg,``).replace(Ig,``);return!/[A-Za-z_$]/.test(t)},Rg=/^[\s)]*\.replace\s*\([^)]*(?:\\u003[cC]|<|<)/,zg=/(?:\b(?:escapeHtml|escapeJSON|escapeJson|htmlEscape|jsesc)|(?<![.\w])(?:serialize|serializeJavascript|devalue|uneval|superjson))\s*\(\s*$/i,Bg=/\bJSON\.stringify\s*\($/i,Vg=W({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(!K(e.relativePath))return[];let t=Tu(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(Bg,``);if(zg.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(!Ng.test(r)||Pg.test(r))continue}}let o=a.index+a[0].length-1,s=nf(t,o);if(s>=0){let e=t.slice(s+1,s+1+160);if(Rg.test(e)||Lg(t.slice(o+1,s)))continue}if(r.has(a.index))continue;r.add(a.index);let c=G(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}}),Hg=/(?:(?<![.\w$])fetch|\baxios\.\s*(?:get|post|put|delete|head)|\bgot|\bgot\.\s*(?:get|post))\s*\(\s*([^,)]+)/,Ug=/\b(?:url|targetUrl|callbackUrl|redirectUrl|webhookUrl|companyUrl|websiteUrl|domainUrl|imageUrl|fetchUrl|next|return_to|returnTo|destination|location)\b/i,Wg=/\breq\.|\brequest\.(?:query|body|params|nextUrl)|\bsearchParams\b|\bparams\.|\bbody\.|\bquery\./,Gg=/\bredirect\s*:\s*["'](?:manual|error)["']/,Kg=/\b(params|body|query)\./g,qg=(e,t)=>RegExp(`(?:const|let|var)\\s+${e}\\s*(?::[^=;\\n]{0,80})?=\\s*new\\s+URLSearchParams\\b`).test(t),Jg=(e,t)=>{let n=e.replace(Kg,(e,n)=>qg(n,t)?``:e);return Wg.test(n)},Yg=(e,t)=>{if(Jg(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)||Jg(n,t))return!0}return!1},Xg=W({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(!Ag(e.relativePath)||!Hg.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(Hg),o=a?.[1]??``;if(!a||!Ug.test(o)||!Yg(o,e.content))continue;let s=n.slice(r,r+5).join(`
|
|
27
|
+
`);Gg.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}}),Zg=W({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:q({shouldScan:e=>cm(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.`})}),Qg=/(?:^|\/)[^/]*webhook[^/]*\/|(?:^|\/)[^/]*webhook[^/]*\.[cm]?[jt]s$|\bwebhook\b/i,$g=/\b(?:export\s+(?:async\s+)?function\s+POST|export\s+const\s+(?:POST|handler|webhook)|webhookHandler|webhookRoute)\b/i,e_=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`),t_=/webhook[\s_-]?ur[il]\w*/gi,n_=/process\.env\.\w*WEBHOOK_URL|\b(?:send|post|dispatch|publish|notify)\w*Webhook/,r_=/\b(?:req|request)\b/,i_=/\/\/[^\n]*|\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`(?:\\.|[^`\\])*`/g,a_=W({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:q({shouldScan:e=>{if(!K(e.relativePath)||n_.test(e.content))return!1;let t=e.content.replace(i_,``).replace(t_,``);return Qg.test(e.relativePath)||Qg.test(t)},pattern:$g,requireAll:[r_],suppressWhen:e_,message:`Webhook handler code does not show an obvious signature verification step.`})}),o_=/\.[cm]?[jt]sx?$/i,s_=/\.d\.[cm]?[jt]s$/i,c_=/\.mdx$/i,l_=/\.html?$/i,u_=new Set([`.angular`,`.astro`,`.cache`,`.contentlayer`,`.docusaurus`,`.expo`,`.git`,`.next`,`.nuxt`,`.output`,`.svelte-kit`,`.turbo`,`.vercel`,`build`,`coverage`,`dist`,`node_modules`,`out`,`storybook-static`]),d_=new WeakMap,f_=e=>{let t=d_.get(e);if(t)return t;let n=Ge(e);return d_.set(e,n),n},p_=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=u_.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()||ml(s))){if(c_.test(i.name)){a=!0;continue}if(l_.test(i.name)){n.push(z(s));continue}o_.test(i.name)&&(s_.test(i.name)||t.push(z(s)))}}}}return{sourceFilePaths:t,htmlFilePaths:n,hasOpaqueMdxConsumerSurface:a}},m_=(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},h_=e=>{if(S(e,`ImportDeclaration`))return qc(e)?null:typeof e.source.value==`string`?e.source.value:null;if(S(e,`ExportNamedDeclaration`))return e.exportKind===`type`||Kc(e.specifiers,`ExportSpecifier`,`exportKind`)?null:e.source&&typeof e.source.value==`string`?e.source.value:null;if(S(e,`ExportAllDeclaration`))return e.exportKind===`type`?null:typeof e.source.value==`string`?e.source.value:null;if(S(e,`ImportExpression`))return S(e.source,`Literal`)&&typeof e.source.value==`string`?e.source.value:null;if(S(e,`CallExpression`)&&S(e.callee,`Identifier`)&&e.callee.name===`require`&&e.arguments.length===1){let t=e.arguments[0];return t&&S(t,`Literal`)&&typeof t.value==`string`?t.value:null}return null},g_=(e,t,n,r)=>{L(e.programNode,i=>{let a=h_(i);if(!a)return;let o=In(e.filePath,a);if(!o){r.add(a);return}let s=z(o);n.set(i,s);let c=t.get(s)??new Set;c.add(e),t.set(s,c)})},__=({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=p_(e);if(!o||i.length>0&&a===void 0&&!m_(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=Zt(e);if(!i||!S(i,`Program`))return null;s.set(e,{filePath:e,programNode:i,scopes:f_(i)})}let c=new Map,l=new WeakMap,u=new Set;for(let e of s.values())g_(e,c,l,u);return{modulesByFilePath:s,htmlFilePaths:o.htmlFilePaths,consumerModulesByFilePath:c,resolvedSourcePathByNode:l,unresolvedRuntimeSources:u,hasOpaqueMdxConsumerSurface:o.hasOpaqueMdxConsumerSurface}},v_=e=>{if(!e)return null;let t=D(e);return!S(t,`Literal`)||typeof t.value!=`boolean`?null:t.value},y_=(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=D(e.expression);if(S(n,`Literal`)){if(typeof n.value!=`string`){if(a)continue;return null}o.push(n.value);continue}if(S(n,`TemplateLiteral`)){let e=vt(n);if(e===null){if(a)continue;return null}o.push(e);continue}if(S(n,`ConditionalExpression`)){let t=i?v_(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&&S(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(S(n,`Identifier`)){let r=t.referenceFor(n)?.resolvedSymbol;if(!r||r.kind!==`const`||!r.initializer||!S(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},b_=(e,t,n={})=>y_(e,t,n),x_=(e,t)=>y_(e,t,{shouldKeepKnownValues:!0}),S_=(e,t,n,r,i=!1)=>{let a=e.value;return a?S(a,`Literal`)?typeof a.value==`string`?[a.value]:null:S(a,`JSXExpressionContainer`)?b_(a.expression,t,{maximumConstAliases:n,shouldFoldStaticConditions:r,shouldKeepKnownValues:i}):null:null},C_=(e,t)=>S_(e,t,4,!1),w_=(e,t)=>S_(e,t,null,!0),T_=(e,t)=>S_(e,t,4,!1,!0),E_=(e,t)=>{let n=o.relative(t,e);return n===``||!n.startsWith(`..${o.sep}`)&&n!==`..`&&!o.isAbsolute(n)},D_={attribute:null,expression:null,isPresent:!1,isUnknown:!1},O_={attribute:null,expression:null,isPresent:!1,isUnknown:!0},k_=(e,t,n)=>{for(let r=e.properties.length-1;r>=0;--r){let i=e.properties[r];if(!i)return O_;if(S(i,`SpreadElement`)){if(!S(i.argument,`ObjectExpression`))return O_;let e=k_(i.argument,t,n);if(e.isPresent||e.isUnknown)return e;continue}if(!S(i,`Property`))return O_;let a=j(i,{allowComputedString:!0});if(!a)return O_;if((n?a:a.toLowerCase())===t)return{attribute:null,expression:i.value,isPresent:!0,isUnknown:!1}}return D_},A_=(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 O_;if(S(i,`JSXSpreadAttribute`)){if(!S(i.argument,`ObjectExpression`))return O_;let e=k_(i.argument,r,n);if(e.isPresent||e.isUnknown)return e;continue}if(!S(i,`JSXAttribute`))continue;let a=ms(i.name);if((n?a:a?.toLowerCase())===r)return{attribute:i,expression:null,isPresent:!0,isUnknown:!1}}return D_},j_=/(?<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,N_=new Map,P_=(e,t,n)=>{if(!e.isPresent)return;let r=e.attribute?T_(e.attribute,t):e.expression?x_(e.expression,t):null;for(let e of r??[]){let t=e?.trim();t&&n.add(t)}},F_=(e,t,n)=>{for(let r of e.properties){if(S(r,`SpreadElement`)){S(r.argument,`ObjectExpression`)&&F_(r.argument,t,n);continue}if(S(r,`Property`)&&j(r,{allowComputedString:!0})?.toLowerCase()===`id`)for(let e of x_(r.value,t)??[]){let t=e.trim();t&&n.add(t)}}},I_=e=>{let t=e.parent;for(S(t,`JSXElement`)&&t.openingElement===e&&(t=t.parent);t;){if(S(t,`JSXElement`)&&js(t.openingElement)===`template`)return!0;t=t.parent}return!1},L_=(e,t,n)=>{L(e,e=>{if(!S(e,`JSXOpeningElement`)||I_(e))return;let r=A_(e.attributes,`id`,!1);if(r.isUnknown){for(let r of e.attributes)P_(A_([r],`id`,!1),t,n),S(r,`JSXSpreadAttribute`)&&S(r.argument,`ObjectExpression`)&&F_(r.argument,t,n);return}P_(r,t,n)})},R_=(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(j_)){if(n.groups?.attributeName?.toLowerCase()!==`id`)continue;let e=n.groups?.doubleQuoted??n.groups?.singleQuoted??n.groups?.unquoted??``;e.trim()&&t.add(e.trim())}}},z_=e=>{if(!o.isAbsolute(e.currentFilePath))return null;let t=e.configuredRootDirectory?z(e.configuredRootDirectory):null;return!t||!E_(e.currentFilePath,t)?null:t},B_=()=>{N_.clear()},V_=e=>{let t=new Set;L_(e.currentProgramNode,e.currentScopes,t);let n=z_(e);if(!n)return t;if(N_.has(n)){let e=N_.get(n);return e?new Set([...e,...t]):null}let r=__({rootDirectory:n,currentFilePath:z(e.currentFilePath),currentProgramNode:e.currentProgramNode,currentScopes:e.currentScopes});if(!r)return N_.set(n,null),null;let a=new Set;for(let e of r.modulesByFilePath.values())L_(e.programNode,e.scopes,a);try{for(let e of r.htmlFilePaths)R_(i.readFileSync(e,`utf8`),a)}catch{return N_.set(n,null),null}return N_.set(n,a),new Set([...a,...t])},H_=new Map,U_=()=>{H_.clear()},W_=e=>{let t=H_.get(e);if(t!==void 0)return t;let n;try{n=i.realpathSync(e)}catch{n=e}return H_.set(e,n),n},G_=(e,t,n)=>{if(t===void 0||t.length===0)return!1;let r=z(W_(e)),i=z(t);if(n&&r===i)return!0;let a=i.endsWith(`/`)?i:`${i}/`;return r.startsWith(a)},K_=/webpackIgnore\s*:\s*true|@vite-ignore/,q_=new Map,J_=()=>{q_.clear()},Y_=e=>{if(!e)return null;let t=q_.get(e);if(t!==void 0)return t===!1?null:t;let n=!1;try{let t=a(e,`utf8`);K_.test(t)&&(n=t)}catch{n=!1}return q_.set(e,n),n===!1?null:n},X_=()=>{J_(),Rn(),xr(),bn(),U_(),B_(),Fn()},Z_=e=>Il.test(e)||Ll.test(e),Q_=e=>{let t=Jl.test(e);return Yh(e)||og(e)||su(e)||eu(e)?{bucket:`priority`,isGeneratedBundleByName:t}:$l(e,t)?{bucket:`artifact`,isGeneratedBundleByName:t}:Z_(e)?{bucket:`other`,isGeneratedBundleByName:t}:null},$_=(e,t)=>t||Z_(e)||eu(e)||Yh(e),ev=[`nextjs`,`astro`,`vite`,`cra`,`remix`,`gatsby`,`expo`,`react-native`,`tanstack-start`,`preact`,`unknown`];export{df as $,ct as $i,Ta as $n,Yr as $r,Kc as $t,Uh as A,g as Aa,Bn as Ai,bo as An,$i as Ar,id as At,sh as B,c as Ba,xt as Bi,no as Bn,Ri as Br,Au as Bt,ig as C,de as Ca,ir as Ci,Jo as Cn,oa as Cr,Zu as Ct,Zh as D,se as Da,Un as Di,Go as Dn,Ji as Dr,Qu as Dt,$h as E,oe as Ea,Jn as Ei,Uo as En,da as Er,Vu as Et,_h as F,m as Fa,Zt as Fi,ho as Fn,Yi as Fr,dd as Ft,fm as G,pt as Gi,qa as Gn,Ui as Gr,Tl as Gt,qm as H,M as Hi,to as Hn,Vi as Hr,ou as Ht,gh as I,_ as Ia,F as Ii,oo as In,Xi as Ir,ed as It,sm as J,k as Ji,La as Jn,pi as Jr,Dl as Jt,dm as K,A as Ki,Ka as Kn,Li as Kr,El as Kt,hh as L,u as La,Rt as Li,ao as Ln,Zi as Lr,td as Lt,Oh as M,v as Ma,I as Mi,So as Mn,qi as Mr,ld as Mt,bh as N,p as Na,In as Ni,B as Nn,Qi as Nr,ud as Nt,Jh as O,fe as Oa,L as Oi,Yo as On,ta as Or,md as Ot,yh as P,f as Pa,yn as Pi,go as Pn,na as Pr,nd as Pt,uf as Q,D as Qi,_a as Qn,R as Qr,gl as Qt,uh as R,d as Ra,It as Ri,io as Rn,zi as Rr,Xu as Rt,Sg as S,re as Sa,Zn as Si,Wo as Sn,la as Sr,fd as St,eg as T,le as Ta,ur as Ti,qo as Tn,ca as Tr,ad as Tt,Tm as U,vt as Ui,$a as Un,Gi as Ur,W as Ut,ih as V,yt as Vi,Qa as Vn,Hi as Vr,ku as Vt,vm as W,j as Wi,eo as Wn,Wi as Wr,Sl as Wt,Lf as X,O as Xi,za as Xn,Qr as Xr,vl as Xt,Rf as Y,ut as Yi,Ha as Yn,$r as Yr,Ol as Yt,Df as Z,lt as Zi,wa as Zn,Zr,ml as Zt,Xg as _,pe as _a,sr as _i,ss as _n,aa as _r,Ru as _t,K_ as a,Xe as aa,Tr as ai,xc as an,Aa as ar,Kd as at,kg as b,te as ba,fr as bi,V as bn,ia as br,sd as bt,V_ as c,qe as ca,_r as ci,Ns as cn,Ea as cr,Fd as ct,w_ as d,Ke as da,cr as di,Os as dn,ma as dr,Fu as dt,st as ea,Fr as ei,qc as en,Sa as er,lf as et,C_ as f,S as fa,lr as fi,Ds as fn,ga as fr,Bu as ft,Zg as g,me as ga,$n as gi,us as gn,Ma as gr,Mu as gt,a_ as h,ge as ha,er as hi,ps as hn,ya as hr,Lu as ht,X_ as i,Ze as ia,wr as ii,Wc as in,ka as ir,ef as it,zh as j,h as ja,Vn as ji,xo as jn,Ki as jr,rd as jt,Gh as k,y as ka,Hn as ki,Co as kn,ea as kr,cd as kt,A_ as l,Ye as la,nr as li,Ms as ln,sa as lr,Pu as lt,__ as m,b as ma,rr as mi,ms as mn,ra as mr,Nu as mt,Q_ as n,T as na,Nr as ni,Hc as nn,ha as nr,X as nt,Y_ as o,w as oa,mr as oi,Rs as on,Da as or,Gd as ot,v_ as p,x as pa,dr as pi,_s as pn,pa as pr,Iu as pt,um as q,dt as qi,z as qn,Di as qr,xl as qt,$_ as r,tt as ra,Cr as ri,Uc as rn,ja as rr,tf as rt,G_ as s,Je as sa,hr as si,Ps as sn,Oa as sr,Id as st,ev as t,it as ta,Mr as ti,Gc as tn,ba as tr,af as tt,E_ as u,Ge as ua,or as ui,js as un,Ca as ur,ju as ut,Vg as v,ce as va,tr as vi,Qo as vn,fa as vr,zu as vt,tg as w,ae as wa,ar as wi,Ko as wn,xa as wr,pd as wt,Og as x,ne as xa,Xn as xi,Zo as xn,ua as xr,od as xt,jg as y,ue as ya,Yn as yi,Xo as yn,va as yr,Yu as yt,lh as z,l as za,Nt as zi,ro as zn,Bi as zr,$u as zt};
|
|
28
|
+
//# sourceMappingURL=capability-C-TekoQd.js.map
|