oxlint-plugin-react-doctor 0.9.5 → 0.9.6
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-DSccjvGM.js +31 -0
- package/dist/core-NYcNjo1f.d.ts +1371 -0
- package/dist/core.d.ts +2 -1045
- package/dist/core.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -14
- package/package.json +1 -1
- package/dist/capability-BAnZaUrt.js +0 -31
- package/dist/react-native-dependency-names-DrsRME-d.d.ts +0 -330
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import{parseSync as e,visitorKeys as t}from"oxc-parser";import{KEYS as n}from"eslint-visitor-keys";import*as r from"node:fs";import*as i from"node:path";const a=[[`nextjs`,`Next.js`,`NEXT_PUBLIC_*`],[`vite`,`Vite`,`VITE_*`],[`tanstack-start`,`TanStack Start`,`VITE_*`],[`cra`,`Create React App`,`REACT_APP_*`],[`gatsby`,`Gatsby`,`GATSBY_*`]],o=e=>{for(let[t,n,r]of a)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`},s=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,c=[{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`}],l=Object.fromEntries(c.map(e=>[e.key,e.severity])),u=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(`.`)),d=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,`padding`,`paddingTop`,`paddingRight`,`paddingBottom`,`paddingLeft`,`margin`,`marginTop`,`marginRight`,`marginBottom`,`marginLeft`,`borderWidth`,`fontSize`,`lineHeight`,`gap`]),f=new Set([`animate`,`initial`,`exit`,`whileHover`,`whileTap`,`whileFocus`,`whileDrag`,`whileInView`]),p=/blur\((\d+(?:\.\d+)?)px\)/,m=new Set([`requestAnimationFrame`,`setInterval`]),h=new Set([`framer-motion`,`motion`]),ee=new Set([`bounce`,`elastic`,`wobble`,`jiggle`,`spring`]),g={base:`3.0.0`,textLayoutGuard:`3.0.1`,aria:`6.2.0`,cursor:`6.7.0`,concurrent:`6.7.0`,renderToString:`6.8.0`,modernHooks:`7.0.0`,suspendTerminal:`7.1.0`},_=[`ink-ctrl-c-handler-requires-exit-option`,`ink-newline-inside-text`,`ink-no-bare-process-exit`,`ink-no-direct-raw-mode`,`ink-no-dom-host-elements`,`ink-no-dom-router`,`ink-no-focus-in-render`,`ink-no-layout-inside-text`,`ink-no-live-hooks-in-render-to-string`,`ink-no-measure-element-in-render`,`ink-no-multiple-static`,`ink-no-raw-text`,`ink-no-repeated-render`,`ink-prefer-use-animation`,`ink-prefer-use-paste`,`ink-static-is-append-only`,`ink-static-requires-key`,`ink-suspense-requires-concurrent`,`ink-use-reactive-window-size`,`ink-use-string-width-for-cursor`,`ink-use-suspend-terminal`,`ink-valid-aria-semantics`],v=[`@react-router/dev`,`react-router-dom`,`react-router`],y=`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(`.`),te=new Set([`@react-router/cloudflare`,`@react-router/node`,`react-router/dom`,`react-router-dom`,`react-router`]),ne=new Set([`flash`,`set`,`unset`]),re=new Set([`createCookieSessionStorage`,`createFileSessionStorage`,`createMemorySessionStorage`,`createSessionStorage`,`createWorkersKVSessionStorage`]),ie=new Set([`createBrowserRouter`,`createHashRouter`,`createMemoryRouter`]),ae=new Set([`append`,`delete`,`set`,`sort`]),oe=new Set([`caseSensitive`,`children`,`id`,`index`,`lazy`,`path`]),se=new Set([`arrayBuffer`,`blob`,`bytes`,`formData`,`json`,`text`]),ce=new Set([`unstable_previewServerPrerendering`,`v8_middleware`,`v8_passThroughRequests`,`v8_splitRouteModules`,`v8_trailingSlashAwareDataRequests`,`v8_viteEnvironmentApi`]),le=new Set([`BrowserRouter`,`HashRouter`,`MemoryRouter`,`Router`,`RouterProvider`]),ue=new Set([..._,`client-passive-event-listeners`,`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`,`remotion-calculate-metadata-fetch-signal`,`remotion-deterministic-randomness`,`remotion-no-css-animation`,`remotion-no-css-transition`,`remotion-no-css-url-assets`,`remotion-no-native-media-elements`,`remotion-no-next-image`,`rerender-memo-with-default-value`,`rn-no-legacy-shadow-styles`,`rn-no-raw-text`,`rn-prefer-expo-image`,`rn-style-prefer-boxshadow`,...y]),de=new Set([`implements`,`returnType`,`superTypeArguments`,`superTypeParameters`,`typeAnnotation`,`typeArguments`,`typeParameters`]),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,fe={...t,...n,ArrayPattern:[`decorators`,...n.ArrayPattern],AssignmentPattern:[`decorators`,...n.AssignmentPattern],ClassDeclaration:[`decorators`,...n.ClassDeclaration],ClassExpression:[`decorators`,...n.ClassExpression],Identifier:[`decorators`,...n.Identifier],MethodDefinition:[`decorators`,...n.MethodDefinition],ObjectPattern:[`decorators`,...n.ObjectPattern],PropertyDefinition:[`decorators`,...n.PropertyDefinition],RestElement:[`decorators`,...n.RestElement]},pe=e=>e===`var`||e===`function`,me=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},he=(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},C=(e,t,n)=>{let r=he(e,t,n.currentScope,n);return n.scopeStack.push(r),n.currentScope=r,n.ownScopeForNode.set(t,r),r},w=e=>{e.scopeStack.pop();let t=e.scopeStack[e.scopeStack.length-1];if(!t)throw Error(`scope stack underflow`);e.currentScope=t},ge=(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},_e=(e,t,n,r,i,a)=>{if(S(e,`Identifier`)){ge(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;_e(e,S(e,`AssignmentPattern`)?e.right:t,n,r,i,a)}else S(o,`RestElement`)&&_e(o.argument,t,n,r,i,a);return}if(S(e,`ArrayPattern`)){for(let o of e.elements)o&&_e(o,S(o,`AssignmentPattern`)?o.right??null:t,n,r,i,a);return}if(S(e,`AssignmentPattern`)){_e(e.left,e.right??null,n,r,i,a);return}S(e,`RestElement`)&&_e(e.argument,null,n,r,i,a)},ve=(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)},ye=e=>e.parent?x(e.parent):!1,be=e=>e.parent!==null&&e.parent!==void 0&&e.parent.type===`CatchClause`,xe=(e,t)=>{if(!S(e,`VariableDeclaration`))return;let n=e.kind===`var`?`var`:e.kind===`let`?`let`:e.kind===`const`?`const`:`using`,r=pe(n)?me(t.currentScope):t.currentScope;for(let i of e.declarations){let e=i,a=i.init??null;_e(i.id,a,r,t,n,e)}},Se=(e,t)=>{S(e,`FunctionDeclaration`)&&e.id&&ge(me(t.currentScope),t,{name:e.id.name,kind:`function`,bindingIdentifier:e.id,declarationNode:e,initializer:e})},Ce=(e,t)=>{S(e,`ClassDeclaration`)&&e.id&&ge(t.currentScope,t,{name:e.id.name,kind:`class`,bindingIdentifier:e.id,declarationNode:e,initializer:e})},we=(e,t)=>{if(!S(e,`ImportDeclaration`))return;let n=me(t.currentScope);for(let r of e.specifiers){let e=r.local;S(e,`Identifier`)&&ge(n,t,{name:e.name,kind:`import`,bindingIdentifier:e,declarationNode:r,initializer:r})}},Te=(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`;ge(me(t.currentScope),t,{name:n.name,kind:r,bindingIdentifier:n,declarationNode:e,initializer:null})},Ee=(e,t,n)=>{for(let r of e)_e(r,null,t,n,`parameter`,r)},De=e=>!(!S(e,`BlockStatement`)||ye(e)||be(e)||e.parent&&e.parent.type===`TSModuleDeclaration`),Oe=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)},ke=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}},Ae=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`}},T=(e,t)=>{t.nodeScope.set(e,t.currentScope)},je=(e,t)=>{if(e.type===`AssignmentPattern`){je(e.left,t);let n=e.right??null;n&&E(n,t);return}if(e.type===`ObjectPattern`){for(let n of e.properties){let e=n;if(e.type===`RestElement`){je(e.argument,t);continue}if(e.type!==`Property`)continue;let r=e;r.computed&&E(r.key,t),je(r.value,t)}return}if(e.type===`ArrayPattern`){for(let n of e.elements)n&&je(n,t);return}e.type===`RestElement`&&je(e.argument,t)},E=(e,t)=>{if(e.type===`ArrowFunctionExpression`||e.type===`FunctionExpression`||e.type===`FunctionDeclaration`){e.type===`FunctionDeclaration`&&e.id&&Se(e,t);let n=e.params??[];for(let e of n)if(!(!(`decorators`in e)||!Array.isArray(e.decorators)))for(let n of e.decorators)b(n)&&E(n,t);T(e,t);let r=C(e.type===`ArrowFunctionExpression`?`arrow-function`:`function`,e,t);(e.type===`FunctionExpression`||e.type===`FunctionDeclaration`)&&e.id&&ge(r,t,{name:e.id.name,kind:`function`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),Ee(n,r,t);for(let e of n)je(e,t);let i=e.body;i&&E(i,t),w(t);return}if(e.type===`ClassDeclaration`||e.type===`ClassExpression`){if(e.type===`ClassDeclaration`&&e.id&&Ce(e,t),Array.isArray(e.decorators))for(let n of e.decorators)b(n)&&E(n,t);let n=C(`class`,e,t);T(e,t),e.type===`ClassExpression`&&e.id&&ge(n,t,{name:e.id.name,kind:`class`,bindingIdentifier:e.id,declarationNode:e,initializer:e}),e.superClass&&E(e.superClass,t),e.body&&E(e.body,t),w(t);return}if(e.type===`CatchClause`){let n=C(`catch`,e,t);T(e,t),e.param&&_e(e.param,null,n,t,`catch-clause-parameter`,e),e.body&&E(e.body,t),w(t);return}if(e.type===`ForStatement`||e.type===`ForInStatement`||e.type===`ForOfStatement`){C(`for`,e,t),T(e,t);let n=e,r=fe[e.type]??Object.keys(n);for(let e of r){if(e===`parent`||de.has(e))continue;let r=n[e];if(Array.isArray(r))for(let e of r)b(e)&&E(e,t);else b(r)&&E(r,t)}w(t);return}if(e.type===`SwitchStatement`){C(`switch`,e,t),T(e,t),e.discriminant&&E(e.discriminant,t);for(let n of e.cases)E(n,t);w(t);return}if(e.type===`TSModuleDeclaration`){let n=C(`ts-module`,e,t);if(T(e,t),e.id&&S(e.id,`Identifier`)){let r=e.id;ge(me(n.parent??t.currentScope),t,{name:r.name,kind:`ts-module`,bindingIdentifier:r,declarationNode:e,initializer:null})}e.body&&E(e.body,t),w(t);return}if(e.type===`TSEnumDeclaration`){Te(e,t),C(`ts-enum`,e,t),T(e,t);let n=e.members??[];for(let e of n)E(e,t);w(t);return}if(e.type===`BlockStatement`&&De(e)){C(`block`,e,t),T(e,t);for(let n of e.body)E(n,t);w(t);return}switch(T(e,t),e.type){case`VariableDeclaration`:xe(e,t);break;case`ImportDeclaration`:we(e,t);break;case`TSImportEqualsDeclaration`:case`TSTypeAliasDeclaration`:case`TSInterfaceDeclaration`:Te(e,t);break}(e.type===`Identifier`||e.type===`JSXIdentifier`)&&!t.symbolByBindingIdentifier.has(e)&&!ke(e)&&(e.type===`JSXIdentifier`?Oe(e)&&ve(t,e,Ae(e)):ve(t,e,Ae(e)));let n=e,r=fe[e.type]??Object.keys(n);for(let e of r){if(e===`parent`||de.has(e))continue;let r=n[e];if(Array.isArray(r))for(let e of r)b(e)&&E(e,t);else b(r)&&E(r,t)}},Me=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)},Ne=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 t of e.body)E(t,n);else E(e,n);return Me(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}}},Pe=(e,t)=>{let n=e;for(;n;){if(n===t)return!0;n=n.parent}return!1},Fe=`(?:tsx?|jsx?|mts|mjs)`,Ie=RegExp(`/page\\.${Fe}$`),Le=RegExp(`/(page|layout)\\.${Fe}$`),Re=[`layout.tsx`,`layout.jsx`,`layout.ts`,`layout.js`,`layout.mts`,`layout.mjs`],ze=[`metadata`,`generateMetadata`],Be=/\/(?:(?:\((?:dashboard|admin|settings|account|internal|manage|console|portal|auth|onboarding|app|ee|protected)\))|(?:dashboard|admin|settings|account|internal|manage|console|portal))\//i,Ve=new Set([`redirect`,`permanentRedirect`,`notFound`,`forbidden`,`unauthorized`]),He=new Set([`revalidateTag`,`revalidatePath`,`expireTag`,`expirePath`,`unstable_expireTag`,`unstable_expirePath`]),Ue=/fonts\.googleapis\.com/,We=/polyfill\.io|polyfill\.min\.js|cdn\.polyfill/,Ge=RegExp(`/route\\.${Fe}$`),Ke=/\/(?:cron|jobs\/cron)(?:\/|$)/i,qe=new Set([`logout`,`log-out`,`signout`,`sign-out`,`unsubscribe`,`delete`,`remove`,`revoke`,`cancel`,`deactivate`]),Je=RegExp(`/(error|global-error)\\.${Fe}$`),Ye=RegExp(`/global-error\\.${Fe}$`),Xe=new Set([`GET`,`POST`,`PUT`,`PATCH`,`DELETE`,`OPTIONS`,`HEAD`]),Ze=/google-analytics\.com|googletagmanager\.com\/gtag/,Qe=RegExp(`/(opengraph-image|twitter-image)\\d*\\.${Fe}$`),$e=1024,et=2e6,tt=1e3,nt=1e3,rt=new Set([`expo`,`expo-router`,`@expo/cli`,`@expo/metro-config`,`@expo/metro-runtime`]),it=new Set([`react-native`,`react-native-tvos`,...rt,`react-native-windows`,`react-native-macos`]),at=[`@react-native/`,`@react-native-`],ot=e=>rt.has(e),st=e=>{if(it.has(e))return!0;for(let t of at)if(e.startsWith(t))return!0;return!1};let ct=null;const lt=e=>{ct?.existencePaths.add(e)},D=e=>{ct?.contentPaths.add(e)},ut=()=>ct!==null,dt=e=>{let t=ct,n={existencePaths:new Set,contentPaths:new Set};ct=n;try{return{value:e(),trace:n}}finally{if(ct=t,t!==null){for(let e of n.existencePaths)t.existencePaths.add(e);for(let e of n.contentPaths)t.contentPaths.add(e)}}},ft=e=>dt(e).trace,pt=new Map,mt=new Map,ht=()=>{pt.clear(),mt.clear()},gt=e=>{if(!e)return null;let t=pt.get(e);if(t!==void 0){if(ut()){let n=i.dirname(e);for(;lt(i.join(n,`package.json`)),n!==t;){let e=i.dirname(n);if(e===n)break;n=e}}return t}let n=i.dirname(e);for(;;){let t=i.join(n,`package.json`);lt(t);let a=!1;try{a=r.statSync(t).isFile()}catch{a=!1}if(a)return pt.set(e,n),n;let o=i.dirname(n);if(o===n)return pt.set(e,null),null;n=o}},_t=e=>{let t=gt(e);return t?vt(t):null},vt=e=>{let t=i.join(e,`package.json`);D(t);let n=mt.get(e);if(n!==void 0)return n;let a=null;try{let e=JSON.parse(r.readFileSync(t,`utf-8`));typeof e==`object`&&e&&(a=e)}catch{a=null}return mt.set(e,a),a},yt=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`]),bt=[`dependencies`,`devDependencies`,`peerDependencies`,`optionalDependencies`],xt=function*(e){for(let t of bt){let n=e[t];if(n)for(let e of Object.keys(n))yield e}},St=e=>{if(typeof e[`react-native`]==`string`)return!0;for(let t of xt(e))if(st(t))return!0;return!1},Ct=e=>{for(let t of xt(e))if(ot(t))return!0;return!1},wt=e=>{for(let t of xt(e))if(yt.has(t))return!0;return!1},Tt=e=>bt.some(t=>{let n=e[t];return typeof n==`object`&&!!n&&Object.keys(n).length>0}),Et=(e,t)=>bt.some(n=>{let r=e[n];return typeof r==`object`&&!!r&&Object.prototype.propertyIsEnumerable.call(r,t)}),Dt=new WeakMap,Ot=e=>{let t=_t(e);if(!t)return`unknown`;let n=Dt.get(t);if(n!==void 0)return n;let r;return r=Ct(t)?`expo`:St(t)?`react-native`:wt(t)?`web`:Tt(t)?`neutral`:`unknown`,Dt.set(t,r),r},kt=new Set([`ParenthesizedExpression`,`TSAsExpression`,`TSSatisfiesExpression`,`TSTypeAssertion`,`TSNonNullExpression`,`TSInstantiationExpression`,`ChainExpression`]),O=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}},At=(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,O(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=O(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},jt=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},Mt=(e,t)=>{if(!S(e,`Program`))return[];let n=[];for(let r of e.body??[]){if(S(r,`ExportNamedDeclaration`)&&r.source){if(r.exportKind===`type`)continue;let e=r.source.value;if(typeof e!=`string`)continue;for(let n of r.specifiers??[]){if(!S(n,`ExportSpecifier`)||n.exportKind===`type`)continue;let r=n.exported;if((S(r,`Identifier`)?r.name:S(r,`Literal`)&&typeof r.value==`string`?r.value:null)!==t)continue;let i=n.local,a=S(i,`Identifier`)?i.name:S(i,`Literal`)&&typeof i.value==`string`?i.value:null;if(a)return[{importedName:a,source:e}]}}if(S(r,`ExportAllDeclaration`)&&r.source){if(r.exportKind===`type`||r.exported)continue;let e=r.source.value;typeof e==`string`&&n.push({importedName:t,source:e})}}return n},Nt=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 of Object.keys(i)){if(n===`parent`)continue;let r=i[n];if(Array.isArray(r))for(let n of r)b(n)&&t(n,e);else b(r)&&t(r,e)}};t(e,null)},Pt={".ts":`ts`,".tsx":`tsx`,".js":`js`,".jsx":`jsx`,".mjs":`js`,".cjs":`js`,".mts":`ts`,".cts":`ts`},Ft=e=>Pt[i.extname(e).toLowerCase()]??`tsx`,It=({filename:t,sourceText:n,shouldAttachParentReferences:r=!0})=>{try{let i=e(t,n,{astType:`ts`,lang:Ft(t)});if(i.errors.some(e=>e.severity===`Error`))return null;let a=i.program;return r&&Nt(a),a}catch{return null}},Lt=new Map,Rt=e=>{e.endsWith(`.d.ts`)||e.endsWith(`.d.mts`)||e.endsWith(`.d.cts`)||D(e);let t;try{t=r.statSync(e)}catch{return null}if(!t.isFile()||t.size>2e6)return null;let n=Lt.get(e);if(n&&n.mtimeMs===t.mtimeMs&&n.size===t.size)return n.program;if(e.endsWith(`.d.ts`)||e.endsWith(`.d.mts`)||e.endsWith(`.d.cts`))return Lt.set(e,{mtimeMs:t.mtimeMs,size:t.size,program:null}),null;let i;try{i=r.readFileSync(e,`utf8`)}catch{return Lt.set(e,{mtimeMs:t.mtimeMs,size:t.size,program:null}),null}let a=It({filename:e,sourceText:i});return Lt.set(e,{mtimeMs:t.mtimeMs,size:t.size,program:a}),a},zt=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.mts`,`.cts`],Bt=[`import`,`default`,`module`,`browser`,`require`],Vt=[`module`,`main`,`browser`],Ht={isDirectory:!0,isFile:!1},Ut={isDirectory:!1,isFile:!0},Wt={isDirectory:!1,isFile:!1},Gt=new Map,Kt=new Map,qt=e=>{lt(e);let t=Gt.get(e);if(t)return t;let n=Wt;try{let t=r.statSync(e);t.isFile()?n=Ut:t.isDirectory()&&(n=Ht)}catch{return Gt.set(e,Wt),Wt}return Gt.set(e,n),n},Jt=e=>qt(e).isFile?e:null,Yt=e=>qt(e).isDirectory?e:null,Xt=e=>{let t=i.extname(e);if(!zt.includes(t))return zt.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]},Zt=e=>typeof e==`object`&&!!e,Qt=e=>{if(typeof e==`string`)return e;if(Array.isArray(e)){for(let t of e){let e=Qt(t);if(e)return e}return null}if(!Zt(e))return null;for(let t of Bt){let n=Qt(e[t]);if(n)return n}return null},$t=e=>{let t=e.exports;return t?Qt(t)||(Zt(t)?Qt(t[`.`]):null):null},en=e=>{D(e);let t=Kt.get(e);if(t!==void 0)return t;let n;try{n=JSON.parse(r.readFileSync(e,`utf8`))}catch{n=null}return Kt.set(e,n),n},tn=e=>rn(e)||rn(i.join(e,`index`)),nn=e=>{let t=Yt(e);if(!t)return null;let n=en(i.join(t,`package.json`));if(!n)return null;let r=$t(n)??Vt.map(e=>n[e]).find(e=>typeof e==`string`);return r?tn(i.resolve(t,r)):null},rn=e=>{let t=Jt(e);if(t)return t;for(let t of Xt(e)){let e=Jt(t);if(e)return e}return null},an=e=>rn(e)||nn(e)||rn(i.join(e,`index`)),on=(e,t)=>an(i.resolve(i.dirname(e),t)),sn=()=>{Gt.clear(),Kt.clear()},cn=[`tsconfig.json`,`jsconfig.json`],ln=e=>typeof e==`object`&&!!e,un=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`)},dn=(e,t)=>{D(e),t.push(e);let n;try{n=r.readFileSync(e,`utf8`)}catch{return null}try{let e=JSON.parse(un(n));return ln(e)?e:null}catch{return null}},fn=(e,t)=>{let n=e.endsWith(`.json`)?e:`${e}.json`;return e.startsWith(`./`)||e.startsWith(`../`)?i.resolve(t,n):i.join(t,`node_modules`,n)},pn=e=>{let t=new Map;if(!ln(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},mn=(e,t,n)=>{let r=dn(e,n);if(!r)return null;let a=i.dirname(e),o=ln(r.compilerOptions)?r.compilerOptions:{},s=typeof o.baseUrl==`string`?o.baseUrl:null,c=s!==null,l=s===null?a:i.resolve(a,s);if(ln(o.paths))return{baseAbsolutePath:l,hasExplicitBaseUrl:c,paths:pn(o.paths)};if(typeof r.extends==`string`&&t<8){let e=fn(r.extends,a),i=e?mn(e,t+1,n):null;if(i)return i}return c?{baseAbsolutePath:l,hasExplicitBaseUrl:c,paths:new Map}:null},hn=new Map,gn=new Map,_n=e=>{D(e);let t;try{t=r.statSync(e)}catch{return{config:null,probedContentPaths:new Set([e])}}let n=hn.get(e);if(n&&n.mtimeMs===t.mtimeMs){for(let e of n.probedChainPaths)D(e);return{config:n.config,probedContentPaths:new Set(n.probedChainPaths)}}let i=[],a=mn(e,0,i);return hn.set(e,{mtimeMs:t.mtimeMs,config:a,probedChainPaths:i}),{config:a,probedContentPaths:new Set(i)}},vn=(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);gn.set(a.directory,{config:t.config,directoryCount:i,probedContentPaths:new Set(r)})}},yn=e=>{let t=gn.get(e);if(t!==void 0){for(let e of t.probedContentPaths)D(e);return t.config}let n=[],r=e;for(let e=0;e<30;e++){let t=gn.get(r),a=30-e;if(t!==void 0&&t.directoryCount<=a){for(let e of t.probedContentPaths)D(e);return vn(n,t,t.directoryCount),t.config}let o=new Set;for(let e of cn){let t=_n(i.join(r,e));for(let e of t.probedContentPaths)o.add(e);if(t.config)return n.push({directory:r,probedContentPaths:o}),vn(n,{config:t.config,probedContentPaths:new Set},0),t.config}n.push({directory:r,probedContentPaths:o});let s=i.dirname(r);if(s===r)return vn(n,{config:null,probedContentPaths:new Set},0),null;r=s}let a=new Set;for(let e of n)for(let t of e.probedContentPaths)a.add(t);return gn.set(e,{config:null,directoryCount:n.length,probedContentPaths:a}),null},bn=(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},xn=(e,t)=>{let n=yn(i.dirname(e));if(!n)return null;let r=null,a=``,o=-1;for(let e of n.paths.keys()){let n=bn(t,e);if(n===null)continue;let i=e.indexOf(`*`),s=i===-1?e.length:i;s>o&&(r=e,a=n,o=s)}if(r)for(let e of n.paths.get(r)??[]){let t=e.replaceAll(`*`,a),r=an(i.resolve(n.baseAbsolutePath,t));if(r)return r}return n.hasExplicitBaseUrl?an(i.resolve(n.baseAbsolutePath,t)):null},Sn=()=>{hn.clear(),gn.clear()},Cn=(e,t)=>i.isAbsolute(t)?null:t.startsWith(`.`)?on(e,t):xn(e,t),wn=new Map,Tn=()=>{wn.clear()},En=(e,t,n)=>{if(n.size>=4||n.has(e))return null;n.add(e);let r=Rt(e);if(!r)return null;let i=At(r,t);if(i)return{filePath:e,exportedNode:i,programNode:r};let a=new Map;for(let i of Mt(r,t)){let t=Cn(e,i.source);if(!t)continue;let r=En(t,i.importedName,new Set(n));r&&a.set(r.exportedNode,r)}return a.size===1?a.values().next().value??null:null},Dn=(e,t,n)=>On(e,t,n)?.functionNode??null,On=(e,t,n)=>{let r=k(e,t,n);return!r||!x(r.exportedNode)?null:{filePath:r.filePath,functionNode:r.exportedNode,programNode:r.programNode}},k=(e,t,n)=>{if(!ut()){let r=Cn(e,t);return r?En(r,n,new Set):null}let r=`${e}\0${t}\0${n}`,i=wn.get(r);if(i!==void 0){for(let e of i.trace.contentPaths)D(e);for(let e of i.trace.existencePaths)lt(e);return i.result}let a=dt(()=>{let r=Cn(e,t);return r?En(r,n,new Set):null});return wn.set(r,{result:a.value,trace:a.trace}),a.value},kn=(e,t)=>{let n=e,r=fe[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)}},An=(e,t)=>{let n=e,r=fe[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)}},A=(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||kn(e,n)}},jn=({absoluteFilePath:e,staticImports:t,program:n})=>{let r=new Set;if(A(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&&Dn(e,n.moduleRequest.value,a)}},Mn=e=>e.replace(/^type\s+/,``).trim(),Nn=(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=Mn(r??``);return{localName:a,exportedName:Mn(i??a),isTypeOnly:n}}),Pn=/\/\*[\s\S]*?\*\//g,Fn=/^\s*\/\/.*$/gm,In=e=>e.replace(Pn,``).replace(Fn,``),Ln=/^\s*export\s+default\b/m,Rn=/^\s*export\s+(?:declare\s+)?(?:(?:async\s+)?function|(?:abstract\s+)?class|const|let|var|enum|interface|type)\s+([\w$]+)/gm,zn=/^\s*export\s+(?:type\s+)?\{([\s\S]*?)\}(?:\s+from\s+["'][^"']+["'])?\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,Bn=e=>{let t=In(e),n=new Set;Ln.test(t)&&n.add(`default`);for(let e of t.matchAll(Rn))e[1]&&n.add(e[1]);for(let e of t.matchAll(zn)){let t=e[1]??``;for(let e of Nn(t,!1))n.add(e.exportedName)}return n},Vn=new Map,Hn=(e,t)=>{D(e);try{let n=r.statSync(e),i=Vn.get(e);if(i&&i.mtimeMs===n.mtimeMs&&i.size===n.size)return i.exportedNames.has(t);let a=Bn(r.readFileSync(e,`utf8`));return Vn.set(e,{mtimeMs:n.mtimeMs,size:n.size,exportedNames:a}),a.has(t)}catch{return!1}},Un=(e,t)=>{let n=e.replaceAll(`\\`,`/`),r=i.dirname(n);for(let e=0;e<30;e++){for(let e of Re){let a=i.join(r,e);if(a.replaceAll(`\\`,`/`)!==n&&t(a))return!0}let e=i.dirname(r);if(i.basename(r)===`app`&&i.basename(e)!==`app`||e===r)break;r=e}return!1},Wn=e=>Un(e,e=>ze.some(t=>Hn(e,t))),j=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},Gn=e=>S(e,`JSXIdentifier`)?e.name===`Suspense`:S(e,`JSXMemberExpression`)&&S(e.property,`JSXIdentifier`)&&e.property.name===`Suspense`,Kn=e=>{let t=!1;return A(e,e=>{if(t)return!1;if(S(e,`JSXOpeningElement`)&&Gn(e.name)||S(e,`ImportDeclaration`)&&e.source?.value===`react`&&(e.specifiers??[]).some(e=>S(e,`ImportSpecifier`)&&j(e)===`Suspense`))return t=!0,!1}),t},qn=e=>Un(e,e=>{let t=Rt(e);return!!(t&&Kn(t))}),Jn=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},M=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},Yn=/^index\.(?:[cm]?[jt]sx?|mjs)$/,Xn=/^\s*import\s+(type\s+)?(?!["'])([^;]*?)\s+from\s+["']([^"']+)["']\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,Zn=/^\s*export\s+(type\s+)?(?:\*(?:\s+as\s+([\w$]+))?|\{([\s\S]*?)\})\s+from\s+["']([^"']+)["']\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,Qn=/^\s*export\s+(type\s+)?\{([\s\S]*?)\}\s*;?\s*(?:(?:\/\/[^\n]*)?\s*)/gm,$n=new Map,er=e=>Yn.test(i.basename(e)),tr=()=>({isBarrel:!1,exportsByName:new Map,starExportSources:[]}),nr=(e,t)=>{e.set(t.localName,{...t,didExport:!1})},rr=(e,t,n,r)=>{for(let i of Nn(e,n))nr(r,{localName:i.exportedName,importedName:i.localName,source:t,isTypeOnly:i.isTypeOnly})},ir=(e,t,n,r)=>{let i=e.trim(),a=i.match(/(?:^|,\s*)\*\s+as\s+([\w$]+)/);a?.[1]&&nr(r,{localName:a[1],importedName:`*`,source:t,isTypeOnly:n});let o=i.match(/\{([\s\S]*?)\}/);o?.[1]&&rr(o[1],t,n,r);let s=i.split(`,`)[0]?.trim();s&&!s.startsWith(`{`)&&!s.startsWith(`*`)&&nr(r,{localName:s,importedName:`default`,source:t,isTypeOnly:n})},ar=(e,t,n,r)=>{let i=e.replace(Xn,(e,n,r,i)=>(ir(r,i,!!n,t),``));return i=i.replace(Zn,(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 Nn(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(Qn,(e,r,i)=>{for(let a of Nn(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},or=e=>{for(let t of e.values())if(!t.isTypeOnly&&!t.didExport)return!0;return!1},sr=e=>{let t=In(e).trim();if(!t)return tr();let n=new Map,r=new Map,i=[];return ar(t,n,r,i).trim()||or(n)?tr():{isBarrel:r.size>0||i.length>0,exportsByName:r,starExportSources:i}},cr=e=>{if(!er(e))return tr();D(e);let t;try{t=r.statSync(e)}catch{t=null}let n=$n.get(e);if(n!==void 0&&t!==null&&n.mtimeMs===t.mtimeMs&&n.size===t.size)return n.moduleInfo;if(t===null)return tr();let i=tr();try{i=sr(r.readFileSync(e,`utf8`))}catch{i=tr()}return $n.set(e,{mtimeMs:t.mtimeMs,size:t.size,moduleInfo:i}),i},lr=e=>cr(e).isBarrel,ur=i.join(`android`,`gradle.properties`),dr=/^\s*newArchEnabled\s*=\s*false\s*$/m,fr=[`app.config.ts`,`app.config.js`,`app.config.cjs`,`app.config.mjs`],pr=[`app.config.json`,`app.json`],mr=new WeakMap,hr=e=>{D(i.join(e,ur));for(let t of fr)lt(i.join(e,t));for(let t of pr)D(i.join(e,t))},gr=e=>{try{return r.readFileSync(e,`utf-8`)}catch{return null}},_r=e=>{let t=e.dependencies?.[`react-native`]??e.devDependencies?.[`react-native`];return typeof t==`string`?t:null},vr=e=>{let t=e.match(/(?:^|[^\d.])0\.(\d+)/);return t?Number.parseInt(t[1],10):null},yr=e=>{let t=gr(i.join(e,ur));return t!==null&&dr.test(t)},br=e=>{for(let t of fr)if(r.existsSync(i.join(e,t)))return!1;for(let t of pr){let n=gr(i.join(e,t));if(n===null)continue;let r;try{r=JSON.parse(n)}catch{continue}if(typeof r!=`object`||!r)continue;let a=Object.getOwnPropertyDescriptor(r,`expo`)?.value;if(!(typeof a!=`object`||!a)&&Object.getOwnPropertyDescriptor(a,`newArchEnabled`)?.value===!1)return!0}return!1},xr=(e,t)=>{let n=_r(t);if(n!==null){let e=vr(n);if(e!==null&&e<76)return!0}return yr(e)||br(e)},Sr=e=>{let t=gt(e);if(!t)return!1;let n=_t(e);if(!n)return!1;hr(t);let r=mr.get(n);if(r!==void 0)return r;let i=xr(t,n);return mr.set(n,i),i},Cr=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},wr=(e,t)=>e.major-t.major||e.minor-t.minor||e.patch-t.patch||Number(t.isPrerelease)-Number(e.isPrerelease),Tr=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=Cr(r);if(!i)return null;n.push(i)}return n.reduce((e,t)=>wr(t,e)<0?t:e)},Er=e=>Tr(e.dependencies?.ink??e.devDependencies?.ink??e.peerDependencies?.ink??e.optionalDependencies?.ink),Dr=e=>{let t=e;for(;;){let e=vt(i.join(t,`node_modules`,`ink`));if(e)return{didFindPackage:!0,version:typeof e.version==`string`?Cr(e.version):null};let n=i.dirname(t);if(n===t)return{didFindPackage:!1,version:null};t=n}},Or=e=>{if(!e)return null;let t=gt(i.resolve(e));if(!t)return null;let n=Dr(t);if(n.didFindPackage)return n.version;let r=vt(t);return r?Er(r):null},kr=(e,t)=>{let n=Or(e),r=Cr(t);return!!(n&&r&&wr(n,r)>=0)},Ar=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`]),jr=new Set([`fetch`,`ky`,`got`,`wretch`,`ofetch`]),Mr=new Set([`axios`,`ky`,`got`,`ofetch`,`wretch`,`request`]),Nr=new Set([`create`,`insert`,`insertInto`,`update`,`upsert`,`delete`,`remove`,`destroy`,`set`,`append`]),Pr=new Set([`POST`,`PUT`,`DELETE`,`PATCH`]),Fr=new Set([`Map`,`Set`,`WeakMap`,`WeakSet`,`Headers`,`URLSearchParams`,`FormData`,`Response`,`NextResponse`]),Ir=new Set([`Response`,`NextResponse`]),Lr=new Set([`json`,`redirect`,`next`,`rewrite`,`error`]),Rr=new Set([`wheel`,`mousewheel`,`touchstart`,`touchmove`]),zr=new Set([`defer`,`async`]),Br=new Set([`text/javascript`,`application/javascript`,`module`]),Vr=new Set([`setTimeout`,`setInterval`,`requestAnimationFrame`,`requestIdleCallback`,`queueMicrotask`]),Hr=new Set([`setInterval`,`setTimeout`]),Ur=new Set([`clearInterval`,`clearTimeout`]),Wr=new Set([`WebSocket`,`EventSource`,`BroadcastChannel`,`RTCPeerConnection`]),Gr=new Set([`location`,`window`,`document`,`navigator`,`history`,`screen`,`performance`]),Kr=new Set([`IntersectionObserver`,`MutationObserver`,`ResizeObserver`,`PerformanceObserver`]),qr=new Set([`blur`,`canPlayType`,`focus`,`getBoundingClientRect`,`getClientRects`,`measure`,`measureInWindow`,`measureLayout`,`scroll`,`scrollBy`,`scrollIntoView`,`scrollTo`,`select`,`setRangeText`,`setSelectionRange`]),Jr=new Set([`localStorage`,`sessionStorage`]),Yr=new Set([`index`,`idx`,`i`]),Xr=new Set([`react`,`react-dom`,`preact/compat`,`preact/hooks`,`@wordpress/element`]),Zr=new Set([`next`,`next-themes`,`@remix-run/react`,`swr`,`zustand`,`jotai`,`recoil`,`wouter`,`framer-motion`,`@apollo/client`,`urql`,`usehooks-ts`]),Qr=/^(?:isLoading|isPending)$/,$r=new Set([`useState`,`useMemo`,`useRef`]),ei=new Set([`Click`,`Change`,`Input`,`Blur`,`Focus`]),ti=new Set([`Boolean`,`String`,`Number`,`Array`,`Object`,`parseInt`,`parseFloat`]),ni=/^set[A-Z]/,ri=/^render[A-Z]/,ii=/^[A-Z]/,ai=/^on[A-Z]/,oi=/^use[A-Z]/,si=/^(?:on|handle)[A-Z]/,ci=new Set([`useEffect`,`useLayoutEffect`]),li=new Set([`useEffect`,`useLayoutEffect`,`useMemo`,`useCallback`]),ui=new Set([`use`,`useState`,`useRef`,`useMemo`,`useCallback`,`useReducer`,`useContext`,`useEffect`,`useLayoutEffect`,`useInsertionEffect`,`useImperativeHandle`,`useSyncExternalStore`,`useDeferredValue`,`useTransition`,`useId`,`useDebugValue`]),di=new Set([`memo`,`forwardRef`,`React.memo`,`React.forwardRef`]),fi=new Set([`useMemo`,`useCallback`]),pi=new Set([`memo`,`forwardRef`,`observer`,`lazy`]),mi=new Set([`subscribe`,`addEventListener`,`addListener`,`on`,`watch`,`listen`,`sub`]),hi=new Set([`subscribe`,`sub`,`listen`]),gi=new Set([`unsubscribe`,`removeEventListener`,`removeListener`,`off`,`unwatch`,`unlisten`,`unsub`,`abort`,`disconnect`,`unobserve`,`close`]),_i=new Set([`remove`,`cleanup`,`dispose`,`destroy`,`stop`,`teardown`]),vi=new Set([...gi,`cleanup`,`dispose`,`destroy`,`teardown`]),yi=new Set([...mi,`connect`,`disconnect`,`open`,`close`,`fetch`,`post`,`put`,`patch`]),bi=new Set([`get`,`head`,`options`,`delete`]),xi=new Set([...jr,...Vr]),Si=new Set([...jr,`post`,`put`,`patch`,`navigate`,`navigateTo`,`showNotification`,`toast`,`alert`,`confirm`,`logVisit`,`captureEvent`]),Ci=new Set([`post`,`put`,`patch`,`delete`,`navigate`,`capture`,`track`,`logEvent`]),wi=new Set([`push`,`replace`]),Ti=new Set([`router`,`navigation`,`navigator`,`history`,`location`]),N=(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},P=(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=O(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},Ei={},Di=new WeakMap,Oi=(e,t)=>typeof e==`string`?e===t:e.has(t),ki=e=>{let t=Di.get(e);if(t)return t;let n=e.declarationNode.parent,r=!!(e.kind===`import`&&n&&n.type===`ImportDeclaration`&&typeof n.source.value==`string`&&Xr.has(n.source.value)),i={importedName:r?j(e.declarationNode):void 0,isReactImport:r};return Di.set(e,i),i},Ai=e=>ki(e).isReactImport,ji=(e,t,n,r)=>{if(e.type!==`Identifier`)return!1;let i=r?P(e,n):n.symbolFor(e);if(!i)return!1;let a=ki(i);return!!(a.isReactImport&&a.importedName&&Oi(t,a.importedName))},Mi=(e,t)=>{let n=P(e,t);if(!n)return!1;let r=ki(n);return r.isReactImport?n.declarationNode.type===`ImportDefaultSpecifier`||n.declarationNode.type===`ImportNamespaceSpecifier`||r.importedName===`default`:!1},Ni=(e,t,n)=>e.type===`Identifier`?Mi(e,t)?!0:!!(n.allowGlobalReactNamespace&&e.name===`React`&&t.isGlobalReference(e)):!1,Pi=(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=N(e);return!!(a&&Oi(t,a)&&Ni(O(i.initializer),n,r))}return!1},Fi=(e,t,n,r=Ei)=>e.type===`CallExpression`?Ii(e.callee,t,n,r):!1,Ii=(e,t,n,r,i)=>{let a=O(e);if(r.resolveConditionalAliases&&a.type===`ConditionalExpression`)return Ii(a.consequent,t,n,r,new Set(i))&&Ii(a.alternate,t,n,r,new Set(i));if(a.type===`Identifier`){if(ji(a,t,n,!!r.resolveNamedAliases)||r.resolveNamedAliases&&Pi(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),Ii(e.initializer,t,n,r,a)}}return!!(r.allowUnboundBareCalls&&Oi(t,a.name)&&n.isGlobalReference(a))}return a.type!==`MemberExpression`||!Oi(t,M(a)??``)?!1:Ni(O(a.object),n,r)},Li=e=>e.includes(`\\`)?e.replaceAll(`\\`,`/`):e,Ri=e=>{let t=new Set(e);if(t.size!==1)return null;let[n]=t;return n??null},zi=(e,t,n,r)=>{let i=on(e,n);return i?Bi(i,t,new Set(r))||(Hn(i,t)?i:null):null},Bi=(e,t,n=new Set)=>{if(n.has(e))return null;n.add(e);let r=cr(e);if(!r.isBarrel)return null;let i=r.exportsByName.get(t);if(i){let t=on(e,i.source);return t?Bi(t,i.importedName,n)??t:null}return t===`default`?null:Ri(r.starExportSources.map(r=>zi(e,t,r,n)).filter(e=>!!e))},Vi=(e,t,n)=>{let r=k(e,t,n);return r?{filePath:r.filePath,node:r.exportedNode,programNode:r.programNode,kind:x(r.exportedNode)?`function`:`initializer`}:null},F=e=>{let t=e;for(;t.parent&&kt.has(t.parent.type);)t=t.parent;return t},Hi=(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`)&&N(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=F(e.identifier);for(;n.parent&&S(n.parent,`MemberExpression`)&&n.parent.object===n;){let e=M(n.parent);if(!e)return null;t.push(e),n=F(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},I=e=>{let t=e.parent;for(;t;){if(x(t))return t;t=t.parent??null}return null},Ui=e=>{let t=e;for(;t;){if(S(t,`Program`))return t;t=t.parent??null}return null},Wi=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},Gi=new WeakMap,Ki=e=>{let t=Ui(e);if(!t)return null;let n=Gi.get(t);return n||(n=Wi(t),Gi.set(t,n)),n},qi=(e,t)=>{let n=Ki(e);if(!n)return!1;for(let e of n.values())if(t.includes(e.source))return!0;return!1},Ji=(e,t,n)=>{let r=Ki(e);if(!r)return!1;let i=r.get(t);return i?i.source===n:!1},Yi=(e,t,n)=>{let r=Ki(e);if(!r)return!1;let i=r.get(t);return i?i.isNamespace&&i.source===n:!1},Xi=(e,t,n)=>{let r=Ki(e);if(!r)return!1;let i=r.get(t);return i?i.isDefault&&i.source===n:!1},Zi=(e,t,n)=>{let r=Ki(e);if(!r)return null;let i=r.get(t);return!i||i.source!==n?null:i.imported},Qi=(e,t)=>{let n=Ki(e);return n?n.get(t)?.source??null:null},$i=(e,t)=>{let n=Ki(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},ea=e=>{let t=e,n=t.parent;for(;n&&O(n)===e;)t=n,n=t.parent;return n&&S(n,`AssignmentExpression`)&&n.operator===`=`&&n.left===t?n.right:null},ta=e=>{let t=e.range?.[0];return typeof t==`number`?t:null},na=new Set([`let`,`var`]),ra=new Set([`ConditionalExpression`,`LogicalExpression`]),ia=new WeakMap,aa=(e,t,n)=>{let r=e.parent??null;for(;r&&n.blockOf(r)===t;){if(ra.has(r.type))return!0;r=r.parent??null}return!1},oa=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e)),sa=(e,t)=>{let n=new Set(e);for(let e of t)e.isConditionalWithinBlock||(n=new Set),n.add(e);return n},ca=(e,t,n)=>{let r=I(t);if(I(e.bindingIdentifier)!==r||!r)return[];let i=n.cfgFor(r);if(!i)return[];let a=i.blockOf(t);if(!a)return[];let o=ta(t),s=ta(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:aa(t,r,i)}),c.set(r,a)};e.initializer&&l(e.initializer,e.bindingIdentifier,s);for(let t of e.references){let e=ta(t.identifier);if(t.flag===`read`||I(t.identifier)!==r||e===null||e>=o)continue;let n=ea(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=sa(t,c.get(e)??[]),r=u.get(e)??new Set,i=d.get(e)??new Set;(!oa(t,r)||!oa(n,i))&&(u.set(e,t),d.set(e,n),m=!0)}}let h=(c.get(a)??[]).filter(e=>e.position<o);return[...sa(u.get(a)??new Set,h)].map(e=>e.expression)},la=(e,t,n)=>{if(!na.has(e.kind))return e.initializer?[e.initializer]:[];if(!n)return[];let r=ia.get(n);r||(r=new WeakMap,ia.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=ca(e,t,n);return i.set(t,o),o},ua=e=>{if(!x(e)||!S(e.body,`BlockStatement`))return[];let t=[];return A(e.body,n=>{if(n!==e.body&&(x(n)||S(n,`ClassDeclaration`)||S(n,`ClassExpression`)))return!1;S(n,`ReturnStatement`)&&t.push(n)}),t},L=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?L(t):!1}return!!(e.alternate&&L(e.consequent)&&L(e.alternate))}if(S(e,`TryStatement`))return e.finalizer&&L(e.finalizer)?!0:L(e.block)?e.handler?L(e.handler.body):!0:!1;if(S(e,`DoWhileStatement`))return L(e.body);if(S(e,`WhileStatement`)){let t=e.test;return!!(S(t,`Literal`)&&t.value&&L(e.body))}if(S(e,`ForStatement`)){let t=e.test;return!!((!t||S(t,`Literal`)&&t.value)&&L(e.body))}return S(e,`BlockStatement`)?e.body.some(e=>L(e)):!1},da=new Set([`let`,`var`]),fa=e=>!x(e)||!e.body?[]:S(e.body,`BlockStatement`)?ua(e).flatMap(e=>e.argument?[e.argument]:[]):[e.body],pa=e=>{if(!x(e)||!S(e.body,`BlockStatement`))return!1;let t=!1;return A(e.body,n=>{if(t||n!==e.body&&x(n))return!1;S(n,`ReturnStatement`)&&!n.argument&&(t=!0)}),t},ma=(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=fa(e);return r===`every`&&x(e)&&S(e.body,`BlockStatement`)&&(!L(e.body)||pa(e))?!1:t.length>0&&(r===`every`?t.every(o):t.some(o))}finally{a.delete(e)}};o=a=>{let l=O(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`&&!da.has(t.kind))return!1;let i=la(t,l,n),a=e=>{let t=O(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?O(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}},ha=(e,t,n,r,i=`some`)=>ma(t,n,r,i).functionMatches(e),ga=(e,t,n,r,i)=>{let a=i.cfgFor(e),o=a?.blockOf(t);if(!a||!o)return!1;let s=new Set(ua(e).flatMap(e=>{if(!e.argument||!ma(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},_a=e=>S(e,`Program`)?e.range[1]:e.range[0],va=new WeakMap,ya=(e,t)=>{t.push(...e.symbols);for(let n of e.children)ya(n,t)},ba=e=>{let t=new Map,n=[];ya(e.rootScope,n);for(let r of n){let n=P(r.bindingIdentifier,e);if(!n)continue;let i=t.get(n.id)??[];i.push(r),t.set(n.id,i)}return t},xa=(e,t)=>{let n=P(e,t);if(!n)return[];let r=va.get(t);return r||(r=ba(t),va.set(t,r)),r.get(n.id)??[]},Sa=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},R=(e,t,n={})=>{let r=N(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=O(S(e,`MemberExpression`)?e.property:e.key);if(!S(i,`Identifier`))return null;let a=P(i,t);if(a?.kind!==`const`||!a.initializer)return null;let o=O(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`)?Sa(o):null},Ca=new Set([`CatchClause`,`ConditionalExpression`,`DoWhileStatement`,`ForInStatement`,`ForOfStatement`,`ForStatement`,`IfStatement`,`LogicalExpression`,`SwitchCase`,`SwitchStatement`,`TryStatement`,`WhileStatement`]),wa=(e,t)=>{let n=e.parent??null;for(;n&&n!==t;){if(Ca.has(n.type))return!1;n=n.parent??null}return n===t},Ta=e=>I(e)??Ui(e),Ea=e=>{let t=F(e),n=t.parent;return!!(n&&S(n,`VariableDeclarator`)&&n.init===t&&n.parent&&S(n.parent,`VariableDeclaration`)&&n.parent.kind===`const`)},Da=e=>{let t=F(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))},Oa=e=>{let t=F(e),n=t.parent;return n&&S(n,`MemberExpression`)&&O(n.object)===t?n:null},ka=(e,t,n,r)=>{if(!S(e,`ObjectExpression`))return null;for(let i of e.properties.toReversed()){if(!S(i,`Property`))return null;let e=R(i,n);if(e===null)return null;if(e===t)return i.kind===`init`?z(i.value,n,r):null}return null},Aa=(e,t,n,r)=>{if(!S(e,`ObjectExpression`))return[];let i=[],a=new Set;for(let o of e.properties){if(!S(o,`Property`))continue;let e=R(o,n),s=o.kind===`init`||o.kind===`get`?z(o.value,n,new Set(r)):null;e===t?(i=s?[s]:[],a.clear(),s&&a.add(s)):e===null&&s&&!a.has(s)&&(i.push(s),a.add(s))}return i},ja=(e,t,n,r)=>{if(!S(e,`ClassDeclaration`)&&!S(e,`ClassExpression`))return null;for(let i of e.body.body.toReversed()){if(!S(i,`MethodDefinition`)&&!S(i,`PropertyDefinition`)||!i.static)continue;let e=R(i,n);if(e===null)return null;if(e===t)return S(i,`MethodDefinition`)&&i.kind!==`method`?null:i.value?z(i.value,n,r):null}return null},Ma=(e,t,n,r)=>{if(!S(e,`ClassDeclaration`)&&!S(e,`ClassExpression`))return[];let i=[],a=new Set;for(let o of e.body.body){if(!S(o,`MethodDefinition`)&&!S(o,`PropertyDefinition`)||!o.static)continue;let e=R(o,n),s=o.value&&(!S(o,`MethodDefinition`)||o.kind===`method`||o.kind===`get`)?z(o.value,n,new Set(r)):null;e===t?(i=s?[s]:[],a.clear(),s&&a.add(s)):e===null&&s&&!a.has(s)&&(i.push(s),a.add(s))}return i},Na=(e,t,n,r,i,a,o)=>{let s=Ta(t);if(!s||!S(e,`Identifier`))return{exactFunction:null,possibleFunctions:[]};let c=[];for(let r of xa(e,a))for(let e of r.references){let r=e.identifier;if(r.range[0]>=t.range[0]||Ea(r))continue;let i=Oa(r);if(!i){Ta(r)===s&&c.push({assignedExpression:null,isDefinite:!1,offset:r.range[0]});continue}if(!Da(i)||Ta(i)!==s)continue;let o=R(i,a),l=F(i).parent,u=l&&S(l,`AssignmentExpression`)&&l.operator===`=`?l.right:null;if(o===null){c.push({assignedExpression:u,isDefinite:!1,offset:i.range[0]});continue}if(o===n){if(!l||!S(l,`AssignmentExpression`)||l.operator!==`=`||!wa(i,s)){c.push({assignedExpression:u,isDefinite:!1,offset:i.range[0]});continue}c.push({assignedExpression:u,isDefinite:!0,offset:l.range[0]})}}c.sort((e,t)=>e.offset-t.offset);let l=r,u=i,d=new Set(i);for(let e of c){let t=e.assignedExpression?z(e.assignedExpression,a,new Set(o)):null;if(e.isDefinite){l=t,u=t?[t]:[],d.clear(),t&&d.add(t);continue}l=null,t&&!d.has(t)&&(u.push(t),d.add(t))}return{exactFunction:l,possibleFunctions:u}},Pa=(e,t,n)=>{if(!S(e,`MemberExpression`))return{exactFunction:null,possibleFunctions:[]};let r=M(e);if(r===null)return{exactFunction:null,possibleFunctions:[]};let i=O(e.object);if(S(i,`ObjectExpression`))return{exactFunction:ka(i,r,t,n),possibleFunctions:Aa(i,r,t,n)};if(S(i,`ClassExpression`))return{exactFunction:ja(i,r,t,n),possibleFunctions:Ma(i,r,t,n)};if(!S(i,`Identifier`))return{exactFunction:null,possibleFunctions:[]};let a=P(i,t);if(!a||n.has(a.id))return{exactFunction:null,possibleFunctions:[]};n.add(a.id);let o=null,s=[];if(a.kind===`const`&&a.initializer){let e=O(a.initializer);o=ka(e,r,t,n),s=Aa(e,r,t,n)}else a.kind===`class`&&a.initializer&&(o=ja(a.initializer,r,t,n),s=Ma(a.initializer,r,t,n));return Na(i,e,r,o,s,t,n)},Fa=(e,t,n)=>{let r=O(e);if(S(r,`CallExpression`)){let e=O(r.callee);return S(e,`MemberExpression`)&&M(e)===`bind`?Fa(e.object,t,n):[]}if(S(r,`MemberExpression`)){let e=M(r);return e===`call`||e===`apply`?Fa(r.object,t,n):Pa(r,t,n).possibleFunctions}let i=z(r,t,n);return i?[i]:[]},z=(e,t,n)=>{let r=O(e);if(x(r))return r;if(S(r,`CallExpression`)){let e=O(r.callee);return S(e,`MemberExpression`)&&M(e)===`bind`?z(e.object,t,n):null}if(S(r,`MemberExpression`)){let e=M(r);return e===`call`||e===`apply`?z(r.object,t,n):Pa(r,t,n).exactFunction}if(!S(r,`Identifier`))return null;let i=P(r,t);return!i||n.has(i.id)?null:(n.add(i.id),i.kind===`function`?!i.references.some(e=>e.flag!==`read`)&&x(i.declarationNode)?i.declarationNode:null:i.kind!==`const`||!i.initializer?null:z(i.initializer,t,n))},Ia=(e,t)=>z(e,t,new Set),La=(e,t)=>Fa(e,t,new Set),Ra=new WeakMap,za=(e,t)=>{let n=O(e);return S(n,`Identifier`)?t.symbolFor(n):null},Ba=(e,t)=>{let n=F(e),r=n.parent;return!r||!S(r,`AssignmentExpression`)||r.operator!==`=`||r.left!==n?null:za(r.right,t)},Va=e=>{let t=F(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(O(n.left),`Identifier`))},Ha=(e,t,n)=>{if(e.initializer&&S(e.declarationNode,`VariableDeclarator`)&&e.declarationNode.id===e.bindingIdentifier){let r=za(e.initializer,n);if(r&&t.has(r.id))return!0}return e.references.some(e=>{let r=Ba(e.identifier,n);return!!(r&&t.has(r.id))})},Ua=(e,t)=>{let n=P(e,t);if(!n)return[];let r=Ra.get(t);r||(r=new Map,Ra.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)||Ha(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},Wa=e=>{let t=e;for(;t;){if(x(t)||S(t,`Program`))return t;t=t.parent??null}return null},Ga=new WeakMap,Ka=(e,t)=>{let n=Ga.get(t);if(!n){let r=new Map,i=new Map,a=Ui(e);a&&A(a,e=>{if(!S(e,`CallExpression`))return;let n=O(e.callee),a=S(n,`Identifier`)?t.symbolFor(n):null,o=a?i.get(a.id):void 0;o===void 0&&(o=La(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,Ga.set(t,n)}return n.get(e)??[]},qa=new WeakMap,Ja=(e,t)=>{let n=qa.get(t);if(n===void 0){let e=null;A(t,n=>{S(n,`AwaitExpression`)&&I(n)===t&&(e===null||n.range[0]<e)&&(e=n.range[0])}),n=e,qa.set(t,n)}return n===null||e.range[0]<n},Ya=(e,t,n,r=new Set,i=null,a)=>{if(r.has(e)||!x(e)||e.generator||i!==null&&!wa(i,e)||i!==null&&a!==void 0&&!a(i)||i!==null&&e.async&&!Ja(i,e))return[];r.add(e);let o=Wa(t);return o?Ka(e,n).flatMap(e=>{let s=Wa(e);return!s||i!==null&&!wa(e,s)||i!==null&&a!==void 0&&!a(e)?[]:s===o?e.range[0]<_a(t)?[[e.range[0]]]:[]:x(s)?Ya(s,t,n,new Set(r),i===null?null:e,a).map(t=>[...t,e.range[0]]):[]}):[]},Xa=(e,t,n,r=new Set,i=null)=>Ya(e,t,n,r,i).length>0,Za=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},Qa=e=>{let t=e.parent;for(;t&&O(t)===e;)t=t.parent;return!t||!S(t,`MemberExpression`)||O(t.object)!==e||!Za(t)?null:t},$a=(e,t,n)=>{let r=Qa(e);return r&&R(r,n)===t?r:null},eo=(e,t,n,r)=>e.references.some(e=>{let i=$a(e.identifier,t,r);if(!i)return!1;let a=Wa(i),o=Wa(n);return!a||!o||!wa(i,a)?!1:a===o?i.range[0]<_a(n):x(a)&&Xa(a,n,r)}),to=e=>{if(Va(e))return!0;let t=F(e),n=t.parent;return!!(n&&S(n,`MemberExpression`)&&O(n.object)===t)},no=e=>{if(Va(e))return!0;let t=F(e),n=t.parent;if(!n||!S(n,`MemberExpression`)||O(n.object)!==t)return!1;let r=F(n),i=r.parent;return!(i&&S(i,`CallExpression`)&&i.callee===r)},ro=(e,t,n)=>S(e,`Identifier`)?Ua(e,n).some(e=>e.references.some(e=>{let r=Qa(e.identifier);if(!r)return!1;let i=R(r,n);return i===null||i===t})):!1,io=(e,t,n)=>{let r=Wa(e),i=Wa(t);return!r||!i?!0:r===i?e.range[0]<_a(t):x(r)?Xa(r,t,n):!0},ao=(e,t,n,r)=>S(e,`Identifier`)?Ua(e,r).some(e=>e.references.some(e=>{let i=Qa(e.identifier);if(!i||!io(i,n,r))return!1;let a=R(i,r);return a===null||a===t})):!1,oo=(e,t,n)=>S(e,`Identifier`)?ro(e,t,n)?!0:Ua(e,n).some(e=>e.references.some(e=>!to(e.identifier))):!1,so=(e,t,n,r)=>S(e,`Identifier`)?ao(e,t,n,r)?!0:Ua(e,r).some(e=>e.references.some(e=>!no(e.identifier)&&io(e.identifier,n,r))):!1,co=(e,t)=>{let n=O(e);if(!S(n,`CallExpression`))return!1;let r=O(n.callee);if(!S(r,`MemberExpression`))return!1;let i=M(r);if(i===null)return!1;let a=O(r.object);return S(a,`Identifier`)&&ro(a,i,t)},lo=(e,t,n,r)=>S(e,`Identifier`)?xa(e,r).some(e=>eo(e,t,n,r)):!1,uo=(e,t,n,r={})=>{let i=I(e);return i===I(t)?e.range[0]>=_a(t)||r.requireSynchronousWrite&&(!i||!wa(e,i)||r.isSynchronousNode!==void 0&&!r.isSynchronousNode(e))?[]:[[e.range[0]]]:i?r.requireSynchronousWrite?Ya(i,t,n,new Set,e,r.isSynchronousNode).map(t=>[...t,e.range[0]]):Ya(i,t,n).map(t=>[...t,e.range[0]]):r.requireSynchronousWrite?[]:[[-1/0,e.range[0]]]},fo=(e,t,n,r={})=>uo(e,t,n,r).length>0,B=(e,t,n,r={})=>e.references.some(e=>e.flag===`read`?!1:fo(e.identifier,t,n,r)),po=(e,t)=>{if(!S(e,`CallExpression`))return!1;let n=O(e.callee);if(S(n,`Identifier`)){let e=t.symbolFor(n);return!!(e&&!B(e,n,t))}if(!S(n,`MemberExpression`))return!1;let r=M(n),i=O(n.object);return!!(r&&S(i,`Identifier`)&&!lo(i,r,n,t))},mo=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`ClassDeclaration`,`ClassExpression`]),ho={allowGlobalReactNamespace:!1,allowUnboundBareCalls:!1},go=new Set([`lodash/sortBy`,`lodash/sortBy.js`,`lodash-es/sortBy`,`lodash-es/sortBy.js`]),_o=e=>S(e,`TSArrayType`)||S(e,`TSTupleType`)?!0:S(e,`TSTypeReference`)?S(e.typeName,`Identifier`)&&(e.typeName.name===`Array`||e.typeName.name===`ReadonlyArray`):!1,vo=e=>{if(!S(e,`Identifier`))return!1;let t=e.typeAnnotation;return!!(t&&S(t,`TSTypeAnnotation`)&&_o(t.typeAnnotation))},yo=(e,t)=>{if(!S(e,`CallExpression`))return!1;let n=O(e.callee);if(!S(n,`Identifier`))return!1;let r=t.symbolFor(n);if(!r||B(r,n,t)||!S(r.declarationNode,`ImportDefaultSpecifier`)&&!S(r.declarationNode,`ImportSpecifier`))return!1;let i=$i(n,n.name);return!i||i.isNamespace?!1:go.has(i.source)&&i.exportedName===`default`?!0:(i.source===`lodash`||i.source===`lodash-es`)&&i.exportedName===`sortBy`},bo=(e,t,n,r=new Set)=>{let i=O(e);if(S(i,`ArrayExpression`)||yo(i,t))return!0;if(!S(i,`Identifier`))return!1;let a=t.symbolFor(i);return!a||r.has(a.id)||B(a,n,t)?!1:vo(a.bindingIdentifier)?!0:a.initializer?(r.add(a.id),bo(a.initializer,t,n,r)):!1},xo=(e,t)=>{if(!S(e,`CallExpression`))return!1;let n=O(e.callee);if(!S(n,`MemberExpression`)||M(n)!==`map`)return!1;let r=O(n.object);return bo(r,t,e)?!(S(r,`Identifier`)&&lo(r,`map`,e,t)):!1},So=(e,t)=>{if(e.type!==`ArrowFunctionExpression`&&e.type!==`FunctionExpression`)return!1;let n=e.parent;return S(n,`CallExpression`)?Fi(n,`useMemo`,t,{resolveNamedAliases:!0})&&po(n,t)?n.arguments[0]===e:n.arguments.some(t=>t===e)&&xo(n,t):!1},Co=(e,t)=>mo.has(e.type)&&!So(e,t),wo=(e,t)=>e.type===`JSXElement`||e.type===`JSXFragment`||Fi(e,`createElement`,t,ho)||To(e,t),To=(e,t)=>{if(!S(e,`CallExpression`))return!1;let n=O(e.callee);if(S(n,`Identifier`))return t.symbolFor(n)?.kind===`import`&&Zi(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:Xi(n.object,n.object.name,`react-dom`)||Yi(n.object,n.object.name,`react-dom`)},Eo=(e,t)=>{let n=!1;return A(e,r=>{if(n||r!==e&&Co(r,t))return!1;if(wo(r,t))return n=!0,!1}),n},Do=new WeakMap,Oo=(e,t,n)=>{let r=Do.get(e);if(r&&r.scopes===t&&r.controlFlow===n)return r.hasRenderOutput;let i=ha(e,t,e=>Eo(e,t),n);return Do.set(e,{scopes:t,controlFlow:n,hasRenderOutput:i}),i},ko=e=>S(e,`JSXIdentifier`)?e.name:S(e,`JSXNamespacedName`)?`${e.namespace.name}:${e.name.name}`:null,Ao=new Set([`Component`,`PureComponent`]),jo=(e,t,n,r)=>{let i=O(e);if(S(i,`MemberExpression`)){let e=M(i),n=O(i.object);return!!(e&&Ao.has(e)&&S(n,`Identifier`)&&!lo(n,e,i,t)&&Mi(n,t))}if(S(i,`ClassExpression`))return Mo(i,t,n,r);if(!S(i,`Identifier`))return!1;let a=t.symbolFor(i);if(!a||r.has(a.id)||B(a,i,t))return!1;if(r.add(a.id),Ai(a)){let e=j(a.declarationNode);return!!(e&&Ao.has(e))}return S(a.declarationNode,`ClassDeclaration`)||S(a.declarationNode,`ClassExpression`)?Mo(a.declarationNode,t,n,r):!!(a.kind===`const`&&a.initializer&&jo(a.initializer,t,n,r))},Mo=(e,t,n=new Set,r=new Set)=>!S(e,`ClassDeclaration`)&&!S(e,`ClassExpression`)||n.has(e)||!e.superClass?!1:(n.add(e),jo(e.superClass,t,n,r)),No=new Set([`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`MethodDefinition`,`Program`]),Po=e=>{let t=e;for(;t;){if(No.has(t.type))return t;t=t.parent??null}return null},Fo=(e,t)=>{if(t!==`let`&&t!==`const`)return Po(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`)?Po(e):n}if(No.has(n.type))return n;n=n.parent??null}return null},Io=(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;Io(e,S(e,`AssignmentPattern`)?e.right:null,n,r)}else S(t,`RestElement`)&&Io(t.argument,null,n,r);return}if(S(e,`ArrayPattern`)){for(let t of e.elements)t&&Io(t,S(t,`AssignmentPattern`)?t.right??null:null,n,r);return}if(S(e,`AssignmentPattern`)){Io(e.left,e.right??null,n,r);return}S(e,`RestElement`)&&Io(e.argument,null,n,r)},Lo=e=>{let t=new Map;return A(e,e=>{switch(e.type){case`VariableDeclarator`:{let n=e.parent,r=Fo(e,n?.type===`VariableDeclaration`?n.kind:void 0);r&&Io(e.id,e.init??null,r,t);break}case`FunctionDeclaration`:case`FunctionExpression`:case`ArrowFunctionExpression`:if(e.type!==`ArrowFunctionExpression`&&e.id){let n=e.parent?Po(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)Io(n,null,e,t);break;case`ClassDeclaration`:case`ClassExpression`:{if(!e.id)break;let n=e.parent?Po(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=Po(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=Po(e);if(r){let e=t.get(n.name)??[];e.push({bindingIdentifier:n,initializer:null,scopeOwner:r}),t.set(n.name,e)}}break}}}),t},Ro=new WeakMap,zo=new WeakMap,Bo=e=>{let t=Ui(e);if(!t)return null;let n=Ro.get(t);return n||(n=Lo(t),Ro.set(t,n)),n},Vo=(e,t,n)=>{let r=Bo(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},Ho=(e,t,n)=>{let r=zo.get(e),i;if(!r)i={},zo.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=Vo(e,t,n);return i[a]=o,o},Uo=e=>ii.test(e),Wo=e=>{let t=Ho(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=O(t.initializer);return S(i,`Literal`)&&typeof i.value==`string`?i.value:null},Go=e=>S(e,`JSXIdentifier`)?e.name:S(e,`JSXMemberExpression`)?`${Go(e.object)}.${e.property.name}`:S(e,`JSXNamespacedName`)?`${e.namespace.name}:${e.name.name}`:``,Ko=e=>{let t=e.name;return S(t,`JSXIdentifier`)?Uo(t.name)?Wo(t)??t.name:t.name:Go(t)},qo=(e,t)=>{if(!S(e.name,`JSXIdentifier`))return!1;let n=Ko(e);if(n[0]===n[0]?.toLowerCase())return!0;let r=new Set,i=e=>{let n=F(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)},Jo=(e,t,n=new Set)=>{if(!e)return null;let r=O(e);if(x(r))return r;if(S(r,`Identifier`)){let e=t.symbolFor(r);return!e||n.has(e.id)||!e.initializer||B(e,r,t)?null:(n.add(e.id),Jo(e.initializer,t,n))}if(!S(r,`CallExpression`)||!Fi(r,`memo`,t,{resolveNamedAliases:!0})&&!Fi(r,`forwardRef`,t,{resolveNamedAliases:!0}))return null;let i=r.arguments[0];return!i||S(i,`SpreadElement`)?null:Jo(i,t,n)},Yo=(e,t)=>{let n=F(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`)||ko(i.name)!==`ref`)return!1;let a=i.parent;return!!(a&&S(a,`JSXOpeningElement`)&&qo(a,t))},Xo=(e,t)=>t.every((t,n)=>e[n]===t),Zo=e=>{let t=F(e);for(;t.parent&&S(t.parent,`MemberExpression`)&&t.parent.object===t;){if(!M(t.parent))return null;t=F(t.parent)}return t},Qo=(e,t,n,r)=>{if(t.length!==n.length+1||!Xo(t,n)||t[n.length]!==`current`)return!1;let i=Zo(e),a=i?.parent;if(!i||!a||!S(a,`AssignmentExpression`)||a.operator!==`=`||a.left!==i)return!1;let o=I(e);if(!o)return!1;if(Yo(o,r))return!0;if(!x(o)||o.async||o.generator)return!1;let s=I(o);if(!s||!Yo(s,r))return!1;let c=F(o),l=c.parent;return!!(S(l,`ReturnStatement`)&&l.argument===c&&I(l)===s||S(s,`ArrowFunctionExpression`)&&s.body===c)},$o=(e,t)=>{if(!S(e,`JSXOpeningElement`))return!1;let n=e.name;if(S(n,`JSXIdentifier`)){if(!t)return n.name===`Fragment`;let e=P(n,t);return e?Ai(e)&&j(e.declarationNode)===`Fragment`:n.name===`Fragment`&&t.isGlobalReference(n)}return S(n,`JSXMemberExpression`)?!S(n.object,`JSXIdentifier`)||n.property.name!==`Fragment`?!1:t?Mi(n.object,t)?!0:n.object.name===`React`&&t.isGlobalReference(n.object):n.object.name===`React`:!1},es=(e,t,n,r,i)=>{let a=F(e),o=a.parent;if(!o)return!1;if(S(o,`ReturnStatement`)&&o.argument===a)return I(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)&&(qo(o.openingElement,n)||$o(o.openingElement,n)||i.doesCustomElementRenderChildren?.(o.openingElement)))return es(o,t,n,r,i);if(S(o,`JSXExpressionContainer`)&&o.expression===a&&o.parent&&(S(o.parent,`JSXFragment`)||S(o.parent,`JSXElement`)&&(qo(o.parent.openingElement,n)||$o(o.parent.openingElement,n)||i.doesCustomElementRenderChildren?.(o.parent.openingElement))))return es(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 es(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`&&es(e.identifier,t,n,r,i));return r.delete(s.id),c},ts=(e,t,n={})=>es(e,I(e),t,new Set,n),ns=(e,t)=>t.every((t,n)=>e[n]===t),rs=(e,t)=>ns(e,t)||ns(t,e),is=e=>x(e)&&S(e.body,`BlockStatement`)&&e.body.body.length===0,as=(e,t,n)=>Fi(e,t,n,{resolveNamedAliases:!0}),os=(e,t,n=new Set)=>S(e,`ObjectExpression`)?e.properties.every(e=>{if(S(e,`SpreadElement`)){let r=F(e.argument);if(S(r,`ObjectExpression`))return os(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=os(i.initializer,t,n);return n.delete(i.id),a}return S(e,`Property`)?!x(e.value)||is(e.value):!1}):!1,ss=e=>M(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),cs=e=>{let t=[],n=F(e);for(;n.parent&&S(n.parent,`MemberExpression`)&&n.parent.object===n;){let e=ss(n.parent);if(!e)return null;t.push(e),n=F(n.parent)}return{expression:n,propertyPath:t}},ls=(e,t,n)=>{let r=n.environmentsByProgram.get(e);if(r)return r;let i={filename:t,program:e,scopes:Ne(e)};return n.environmentsByProgram.set(e,i),i},us=(e,t,n=new Set)=>{let r=F(e);if(S(r,`Identifier`)){let e=t.symbolFor(r);return!e||!e.initializer||n.has(e.id)||B(e,r,t)?!1:(n.add(e.id),us(e.initializer,t,n))}if(!S(r,`CallExpression`))return!1;if(as(r,`forwardRef`,t))return!0;if(!as(r,`memo`,t))return!1;let i=r.arguments[0];return!i||S(i,`SpreadElement`)?!1:us(i,t,n)},ds=(e,t)=>{let n=ls(e.programNode,e.filePath,t),r=Jo(e.exportedNode,n.scopes);return r?{environment:n,functionNode:r,isForwardRef:us(e.exportedNode,n.scopes)}:null},fs=(e,t,n)=>{if(!S(e,`Identifier`)&&!S(e,`JSXIdentifier`))return null;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`){if(B(r,e,t.scopes))return null;let n=Jo(r.initializer,t.scopes);return n?{environment:t,functionNode:n,isForwardRef:!!(r.initializer&&us(r.initializer,t.scopes))}:null}let i=$i(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return null;let a=k(t.filename,i.source,i.exportedName);return a?ds(a,n):null},ps=(e,t,n)=>{if(S(e,`JSXIdentifier`))return fs(e,t,n);if(!S(e,`JSXMemberExpression`)||!S(e.object,`JSXIdentifier`))return null;let r=$i(e.object,e.object.name);if(!r?.isNamespace)return null;let i=k(t.filename,r.source,e.property.name);return i?ds(i,n):null},ms=(e,t,n=new Set)=>{let r=F(e);if(S(r,`Identifier`)){let e=t.scopes.symbolFor(r);return!e||!e.initializer||n.has(e.id)||B(e,r,t.scopes)?!1:(n.add(e.id),ms(e.initializer,t,n))}return Mo(r,t.scopes)},hs=(e,t,n)=>{if(!S(e,`JSXIdentifier`))return!1;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`)return B(r,e,t.scopes)?!1:!!(r.initializer&&ms(r.initializer,t));let i=$i(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return!1;let a=k(t.filename,i.source,i.exportedName);if(!a)return!1;let o=ls(a.programNode,a.filePath,n);return ms(a.exportedNode,o)},gs=(e,t)=>{if(!e)return null;let n=F(e);return!S(n,`ClassDeclaration`)&&!S(n,`ClassExpression`)||!ms(n,t)?null:{classNode:n,environment:t}},_s=(e,t,n)=>{if(!S(e,`JSXIdentifier`))return null;let r=t.scopes.symbolFor(e);if(r&&r.kind!==`import`)return B(r,e,t.scopes)?null:gs(r.initializer,t);let i=$i(e,e.name);if(!i||i.isNamespace||i.exportedName===null)return null;let a=k(t.filename,i.source,i.exportedName);if(!a)return null;let o=ls(a.programNode,a.filePath,n);return gs(a.exportedNode,o)},vs=(e,t,n)=>{let r=[...t],i=F(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=F(e);continue}if(S(e,`Property`)&&e.value===i){let t=N(e,{allowComputedString:!0}),a=e.parent;if(!t||!a||!os(a,n.scopes))return null;r.unshift(t),i=F(a);continue}if(S(e,`ConditionalExpression`)&&(e.consequent===i||e.alternate===i)||S(e,`LogicalExpression`)&&(e.left===i||e.right===i)){i=F(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=ss(i);if(!e)return null;t.unshift(e),i=F(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},ys=(e,t,n,r,i)=>{if(S(e,`AssignmentPattern`))return ys(e.left,t,n,r,i);if(S(e,`Identifier`)){let a=n.scopes.symbolFor(e);return!!(a&&Ps({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=N(t,{allowComputedString:!0});if(!e)return!1;if(e===a)return ys(t.value,o,n,r,i)}let s=e.properties.find(e=>S(e,`RestElement`));return s?ys(s.argument,t,n,r,i):!0},bs=(e,t)=>{let n=e.arguments[0];return!n||S(n,`SpreadElement`)?!1:as(e,`createElement`,t.scopes)?S(n,`Literal`)&&typeof n.value==`string`:!as(e,`cloneElement`,t.scopes)||!S(n,`JSXElement`)?!1:qo(n.openingElement,t.scopes)},xs=(e,t,n,r,i)=>{if(t.length>0)return!1;let a=e.parent;if(!a||!S(a,`Property`)||a.value!==e||N(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||!bs(s,n)||!V(s,n,r,i))},Ss=(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&&ys(a,n,e.environment,r,i))},Cs=e=>{if(!S(e,`MemberExpression`)||M(e)!==`children`)return!1;let t=F(e.object);return!!(S(t,`MemberExpression`)&&M(t)===`props`&&S(F(t.object),`ThisExpression`))},ws=(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`)&&as(n.initializer,`createContext`,t.scopes))},V=(e,t,n,r)=>ts(e,t.scopes,{doesCustomElementRenderChildren:e=>Ds(e,t,n,r-1)}),Ts=(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=Hi(r,e.environment.scopes);if(!i)return!1;t.activeRenderedChildrenComponents.add(r);let a=i.every(r=>V(r,e.environment,t,n));return t.activeRenderedChildrenComponents.delete(r),a},Es=(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(A(r,e=>{Cs(e)&&o.push(e)}),o.length===0)return!1;t.activeRenderedChildrenComponents.add(r);let s=o.every(e=>I(e)===a.value&&V(e,i,t,n));return t.activeRenderedChildrenComponents.delete(r),s},Ds=(e,t,n,r)=>{if(r<=0||!S(e,`JSXOpeningElement`))return!1;if(ws(e,t))return!0;let i=ps(e.name,t,n);if(i)return Ts(i,n,r);let a=_s(e.name,t,n);return!!(a&&Es(a,n,r))},Os=(e,t,n,r,i)=>{let a=ko(e.name),o=e.parent;if(!a||!o||!S(o,`JSXOpeningElement`))return!1;let s=o.parent;if(!s||!S(s,`JSXElement`)||!V(s,n,r,i))return!1;if(qo(o,n.scopes))return a===`ref`&&t.length===0;if(S(o.name,`JSXIdentifier`)&&a===`ref`&&t.length===0&&hs(o.name,n,r))return!0;let c=ps(o.name,n,r);return c?a===`ref`&&c.isForwardRef?Ss(c,1,t,r,i):Ss(c,0,[a,...t],r,i):!1},ks=(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&&as(e,`useImperativeHandle`,r.scopes))return n.length===0;if(o===1&&n.length===1&&n[0]===`ref`&&bs(e,r)&&V(e,r,i,a))return!0;let s=F(e.callee);if(x(s))return Oo(s,r.scopes)&&!V(e,r,i,a)?!1:Ss({environment:r,functionNode:s,isForwardRef:!1},o,n,i,a);if(!S(e.callee,`Identifier`))return!1;let c=fs(e.callee,r,i);return!!(c&&(!Oo(c.functionNode,c.environment.scopes)||V(e,r,i,a))&&Ss(c,o,n,i,a))},As=(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||N(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!!(qo(o,n.scopes)&&s&&S(s,`JSXElement`)&&V(s,n,r,i))},js=(e,t,n,r,i)=>{let a=F(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(As(a,t,n,r,i)||xs(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`)&&Os(e,t,n,r,i))}if(S(o,`CallExpression`))return ks(o,a,t,n,r,i);if(S(o,`VariableDeclarator`)&&o.init===a&&!S(o.id,`Identifier`))return ys(o.id,t,n,r,i);let s=vs(a,t,n);return!!(s&&Ps(s,r,i-1))},Ms=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},Ns=(e,t,n)=>{if(!e||!t||!x(e)||e.async||e.generator)return!1;let r=Ms(e);if(!r||((S(e,`FunctionDeclaration`)||S(e,`FunctionExpression`))&&e.id===r?I(e):I(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=F(e.identifier),i=r.parent;return!!(i&&S(i,`CallExpression`)&&i.callee===r&&I(i)===t&&ts(i,n))}))},Ps=(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=I(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=cs(r.identifier);if(!o)return!1;if(!rs(o.propertyPath,e.propertyPath))return!0;let s=I(r.identifier);if(s!==i&&!Ns(s,i,e.environment.scopes))return!!Qo(r.identifier,o.propertyPath,e.propertyPath,e.environment.scopes);if(r.flag!==`read`)return!1;if(ns(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 js(o.expression,[],e.environment,t,n)}return js(o.expression,e.propertyPath.slice(o.propertyPath.length),e.environment,t,n)});return t.activePaths.delete(r),a},Fs=(e,t,n)=>{if(!t)return!1;let r=Ui(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=vs(e,[],i);return o?Ps(o,a,12):js(e,[],i,a,12)},Is=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},Ls=({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=on(e,t);if(!(!a||!lr(a))){n||(n=!0,Ot(e));for(let e of i){let t=e.importName.kind===`Default`?`default`:e.importName.name;t&&Bi(a,t)}}}},Rs=({absoluteFilePath:e})=>{Ie.test(e)&&(Be.test(e)||Wn(e))},zs=({absoluteFilePath:e,staticImports:t})=>{if(Le.test(e)&&!qn(e))for(let n of Is(t))Dn(e,n.source,n.exportedName)},Bs=({absoluteFilePath:e,staticImports:t})=>{for(let n of Is(t))Dn(e,n.source,n.exportedName)},Vs=({absoluteFilePath:e,staticImports:t})=>{for(let n of Is(t))k(e,n.source,n.exportedName)},Hs=(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=Jn(i);if(!e)continue;let a=Cn(t,e);if(!a||r>=8)continue;let o=r+1,s=n.get(a);if(s!==void 0&&s<=o)continue;let c=Rt(a);if(!c){n.set(a,o);continue}Hs(c,a,n,o)}}},Us=e=>{Vs(e);let t=e.getProgram(),n=!1;A(t,e=>{if(n)return!1;if(!S(e,`CallExpression`))return;let t=O(e.callee);if(!S(t,`MemberExpression`))return;let r=M(t);n=r===`add`||r===`set`}),n&&Hs(t,e.absoluteFilePath,new Map,0)},Ws=({absoluteFilePath:e,staticImports:t})=>{for(let n of Is(t))Vi(e,n.source,n.exportedName)},Gs=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},Ks=({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 Gs(t)){let t=k(e,a.source,a.exportedName);!t||n===0||!r(t)||!i(t.filePath)||o(t.filePath,t.programNode,n-1)}}};for(let a of Is(t)){let t=k(e,a.source,a.exportedName);!t||!r(t)||!i(t.filePath)||o(t.filePath,t.programNode,n)}},qs=e=>{Ks(e,4)},Js=({absoluteFilePath:e,sourceText:t,getProgram:n})=>{if(!t.includes(`createRef`)&&!t.includes(`\\u`))return;let r=n();Nt(r);let i=Ne(r);A(r,t=>{!S(t,`CallExpression`)||!Fi(t,`createRef`,i,{allowGlobalReactNamespace:!0,allowUnboundBareCalls:!0,resolveNamedAliases:!0})||Fs(t,e,i)})},Ys=({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(A(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(O(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&&Dn(e,t.moduleRequest.value,r)}},Xs=({absoluteFilePath:e,staticImports:t,getProgram:n})=>{Ot(e),jn({absoluteFilePath:e,staticImports:t,program:n()})},H=({absoluteFilePath:e})=>{Ot(e)},Zs=e=>{H(e),Ks(e,1/0,e=>x(e.exportedNode),e=>!e.split(/[\\/]/).includes(`node_modules`))},Qs=({absoluteFilePath:e})=>{Sr(e)},$s=({absoluteFilePath:e})=>{Or(e)},ec=e=>{$s(e),jn({absoluteFilePath:e.absoluteFilePath,staticImports:e.staticImports,program:e.getProgram()})},tc=new Map([..._.map(e=>[e,$s]),[`ink-no-raw-text`,ec],[`client-passive-event-listeners`,Bs],[`exhaustive-deps`,qs],[`no-barrel-import`,Ls],[`nextjs-async-dynamic-api-not-awaited`,H],[`nextjs-missing-metadata`,Rs],[`nextjs-no-use-search-params-without-suspense`,zs],[`no-dynamic-import-path`,H],[`no-full-lodash-import`,H],[`no-hydration-branch-on-browser-global`,H],[`no-indeterminate-attribute`,H],[`no-locale-format-in-render`,H],[`no-match-media-in-state-initializer`,H],[`no-create-ref-in-function-component`,Js],[`no-adjust-state-on-prop-change`,Bs],[`no-derived-state`,Bs],[`no-derived-state-effect`,Bs],[`no-event-handler`,Bs],[`no-initialize-state`,Bs],[`no-reset-all-state-on-prop-change`,Bs],[`no-mutating-reducer-state`,Ys],[`no-side-effect-in-state-updater-function`,Us],[`no-unguarded-browser-global-at-module-scope`,Ws],[`no-unguarded-browser-global-in-render-or-hook-init`,Zs],[`prefer-dynamic-import`,H],[`rendering-hydration-mismatch-time`,H],[`rerender-memo-with-default-value`,qs],[`rn-no-legacy-shadow-styles`,Qs],[`rn-no-raw-text`,Xs],[`rn-prefer-expo-image`,H],[`rn-style-prefer-boxshadow`,Qs],...y.map(e=>[e,H])]),nc=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`]),rc=t=>{let n=new Set;for(let e of t.ruleIds){let t=tc.get(e);if(!t)return null;n.add(t)}let r=Li(t.absoluteFilePath),i,a;try{let n=e(r,t.sourceText,{astType:`ts`,lang:Ft(r)});if(n.errors.some(e=>e.severity===`Error`))return null;i=n.module.staticImports;let o;a=()=>(o??=n.program,o)}catch{return null}let o={absoluteFilePath:r,sourceText:t.sourceText,staticImports:i,getProgram:a};return ft(()=>{for(let e of n)e(o)})},ic={},ac=(e,t,n)=>!e||e.length===0?!1:e.every(e=>S(e,t)&&e[n]===`type`),oc=e=>e.importKind===`type`||ac(e.specifiers,`ImportSpecifier`,`importKind`),sc=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`]),cc=[`solid-js`,`@builder.io/qwik`],lc=[`react`,`react-dom`,`preact`],uc=new WeakMap,dc=new WeakMap,fc=(e,t)=>t.some(t=>e===t||e.startsWith(`${t}/`)),pc=e=>{let t=uc.get(e);if(t)return t;let n=!1,r=!1;for(let t of e.body){if(!S(t,`ImportDeclaration`))continue;let e=t;if(oc(e))continue;let i=e.source,a=i&&typeof i.value==`string`?i.value:null;a&&((sc.has(a)||fc(a,cc))&&(n=!0),fc(a,lc)&&(r=!0))}let i={hasNonReactRuntime:n,hasReactRuntime:r};return uc.set(e,i),i},mc=e=>{let t=pc(e);return t.hasNonReactRuntime&&!t.hasReactRuntime},hc=e=>{let t=dc.get(e);if(t!==void 0)return t;let n=!1;for(let t of e.attributes){if(!S(t,`JSXAttribute`)||!S(t.name,`JSXIdentifier`))continue;let e=t.name.name;if(e===`classList`||e.startsWith(`class:`)||e.startsWith(`bind:`)){n=!0;break}}return dc.set(e,n),n},gc=`/test/,/tests/,/testing/,/__tests__/,/__test__/,/__fixtures__/,/fixtures/,/__mocks__/,/mocks/,/testUtils/,/test-utils/,/testutils/,/cypress/,/playwright/,/.storybook/,/.dumi/,/stories/,/__stories__/,/playground/,/playgrounds/,/examples/,/example/,/demo/,/demos/,/sandbox/,/sandboxes/,/e2e/,/e2e-tests/,/specs/,/spec/,/integration-tests/,/integration/,/it/,/benchmarks/,/benchmark/,/__benchmarks__/,/perf/,/perf-tests/,/scripts/,/cli/,/bin/,/tooling/,/tools/,/codemods/,/codemod/,/migrations/,/migration/,/generators/,/generator/,/runbooks/,/devtools/,/internal-tools/,/seeds/,/seed/,/dev-seeder/`.split(`,`),_c=[`.test.`,`.spec.`,`.cy.`,`.stories.`,`.story.`,`.bench.`,`.benchmark.`,`.e2e.`,`.integration-spec.`,`.int-spec.`,`.mock.`,`.mocks.`,`.fixture.`],vc=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(`,`)),yc=[`/src/`,`/app/`,`/lib/`,`/components/`,`/pages/`,`/features/`,`/modules/`,`/packages/`,`/apps/`,`/frontend/`,`/client/`],bc=gc.filter(e=>e.startsWith(`/.`)),xc=e=>{let t=-1;for(let n of yc){let r=e.lastIndexOf(n);r>t&&(t=r)}return t<0?e:e.slice(t)};let Sc,Cc=!1;const wc=e=>e?e===Sc?Cc:(Sc=e,Cc=Ec(e),Cc):!1,Tc=(e,t)=>e?Ec(e,t):!1,Ec=(e,t=new Set)=>{let n=e.replaceAll(`\\`,`/`),r=n.lastIndexOf(`/`),i=r===-1?n:n.slice(r+1);if(vc.has(i.toLowerCase()))return!0;for(let e of _c)if(i.includes(e))return!0;let a=n.startsWith(`/`)?n:`/${n}`;for(let e of bc)if(!t.has(e)&&a.includes(e))return!0;let o=xc(n);for(let e of gc)if(!t.has(e)&&(e.startsWith(`/.`)?n:o).includes(e))return!0;return!1},Dc=e=>t=>wc(t.filename)?ic:e(t),Oc=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=pc(e);i=n.hasReactRuntime,r=n.hasNonReactRuntime&&!n.hasReactRuntime,t(e)};continue}if(e===`JSXOpeningElement`){a.JSXOpeningElement=e=>{!i&&!r&&hc(e)&&(r=!0),!r&&t(e)};continue}a[e]=(...e)=>{r||t(...e)}}return`Program`in a||(a.Program=e=>{let t=pc(e);i=t.hasReactRuntime,r=t.hasNonReactRuntime&&!t.hasReactRuntime}),a}),U=e=>{if(!(`create`in e))return{...e,create:()=>ic};let t=e.tags,n=e.create,r=t?.includes(`test-noise`)&&!t?.includes(`migration-hint`);return t?.includes(`react-jsx-only`)&&(n=Oc(n)),r&&(n=Dc(n)),n===e.create?e:{...e,create:n}};let kc;const Ac=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},jc=e=>{if(kc?.content===e)return kc.lineStartOffsets;let t=Ac(e);return kc={content:e,lineStartOffsets:t},t},W=(e,t)=>{if(Number.isNaN(t)||t<0)return{line:1,column:1};let n=jc(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}},Mc=(e,t)=>W(e,e.search(t)),Nc=/\.(?:[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,Pc=/(?:^|\/)\.env(?:\.|$)/,Fc=/\.(?:[cm]?[jt]sx?)$/i,Ic=/\.(?:[cm]?[jt]sx?|py|php)$/i,Lc=/\.(?:[cm]?[jt]sx?|py)$/i,Rc=/(?:^|\/)(?:api|backend|server|servers|middleware|route|routes|functions|lambdas|workers)(?:\/|$)|(?:^|\/)[^/]+\.server\.[cm]?[jt]sx?$/i,zc=/(?:^|\/)(?:__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,Bc=/(?:^|\/)(?: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,Vc=/(?:^|\/)scripts(?:\/|$)/i,Hc=/(?:^|\/)(?:examples?|tutorials?|demos?|samples?|playgrounds?)(?:\/|$)/i,Uc=/(?:^|\/)(?:README|CHANGELOG|CONTRIBUTING|PUBLISHING|DOCS)\.mdx?$|\.mdx?$/i,Wc=/(?:^|\/)(?: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,Gc=/\.(iife|umd|global|min)\.js$/i,Kc=[/(?:^|\/)\.next\/static\//,/(?:^|\/)\.output\/public\//,/(?:^|\/)build\/static\//,/(?:^|\/)dist\/assets\//,/(?:^|\/)public\//,/(?:^|\/)out\//,/(?:^|\/)storybook-static\//],qc=/\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/,Jc=new Set([`.next`,`.output`]),Yc=e=>{let t=e.split(`/`);for(let e=0;e<t.length;e+=1)if(Jc.has(t[e])&&(t[e]===`.next`&&t[e+1]===`dev`||t[e+1]===`server`&&e+2<t.length))return!0;return!1},Xc=(e,t)=>Yc(e)?!1:t||e.endsWith(`.map`)?!0:Kc.some(t=>t.test(e)),Zc=e=>/(?:^|\/)(?:package\.json|Dockerfile|docker-compose\.ya?ml|\.github\/workflows\/[^/]+\.ya?ml|vercel\.json|next\.config\.[cm]?[jt]s|netlify\.toml)$/i.test(e),Qc=new Map,$c=(e,t)=>{let n=Qc.get(t);n||(n=new Map,Qc.set(t,n));let r=n.get(e);if(r!==void 0)return r;let i=t.test(e)&&!zc.test(e)&&!Vc.test(e)&&!Uc.test(e)&&!Wc.test(e);return n.set(e,i),i},G=e=>/\.d\.[cm]?[jt]s$/i.test(e)?!1:$c(e,Fc),el=/<script\b|on(?:load|error|click|mouseover)\s*=/i,tl=/dangerouslyAllowSVG\s*:\s*true/i,nl=/<(?:object|embed|iframe)\b[^>]+(?:data|src)=["'][^"']+\.svg(?:\?[^"']*)?["']/i,rl=U({id:`active-static-asset`,title:`Executable SVG exposure`,severity:`warn`,recommendation:"Prefer `<img>` for SVG images; if SVG must be served directly, use attachment disposition and a CSP that blocks scripts and objects.",scan:e=>{let t=[];if(e.relativePath.endsWith(`.svg`)&&Xc(e.relativePath,e.isGeneratedBundle)){if(el.test(e.content)){let n=Mc(e.content,el);t.push({message:`A browser-reachable SVG contains script or event-handler code.`,line:n.line,column:n.column,severity:`error`,title:`Active SVG in public assets`,help:`Serve untrusted SVG as downloads, sanitize it, or isolate it on a cookieless asset origin with a restrictive CSP.`})}return t}if(!G(e.relativePath)&&!Zc(e.relativePath))return t;let n=[tl,nl].find(t=>t.test(e.content));if(n!==void 0){let r=Mc(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}}),il=e=>/(?:^|\/)(?:firestore\.rules|storage\.rules|database\.rules\.json)$/.test(e),al=/\s/,ol=/[\p{ID_Continue}$]/u,sl=new Set([`return`,`typeof`,`case`,`in`,`of`,`new`,`delete`,`void`,`instanceof`,`do`,`else`,`yield`,`await`,`throw`]),cl=(e,t,n)=>{let r=n-1;for(;r>=0&&al.test(t[r]);)--r;if(r<0)return!0;let i=t[r],a=r>0?t[r-1]:``;if(ol.test(i)){let n=r;for(;n>0&&ol.test(t[n-1]);)--n;return n>0&&t[n-1]===`.`?!1:sl.has(e.slice(n,r+1))}return i===`<`?!1:i===`>`?a===`=`:i===`+`||i===`-`?a!==i:i===`!`?!(ol.test(a)||a===`)`||a===`]`):!(i===`)`||i===`]`||i===`}`||i===`"`||i===`'`||i==="`")},ll=(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},ul=(e,t,n)=>{for(let r=t+1;r<e.length;r+=1){let t=e[r];if(t===`\\`){r+=1;continue}if(t===n)return!1;if(al.test(t))return!0}return!1},dl=(e,t)=>{let n=null,r=null,i=!1,a=[],o=0,s=t=>{t>=e.length||e[t]===`
|
|
6
|
+
`||(n??=e.split(``),n[t]=` `)};for(;o<e.length;){let c=e[o],l=e[o+1];if(r!==null){if(c===`\\`){i&&(s(o),s(o+1)),o+=2;continue}if(c===`
|
|
7
|
+
`&&r!=="`"){r=null,o+=1;continue}if(c===r){r=null,o+=1;continue}if(t&&r==="`"&&c===`$`&&l===`{`){a.push(0),r=null,o+=2;continue}i&&s(o),o+=1;continue}if(c===`"`||c===`'`){r=c,i=t&&ul(e,o,c),o+=1;continue}if(c==="`"){r="`",i=t,o+=1;continue}if(c===`/`&&l===`/`){for(n??=e.split(``);o<e.length&&e[o]!==`
|
|
8
|
+
`;)n[o]=` `,o+=1;continue}if(c===`/`&&l===`*`){for(n??=e.split(``);o<e.length;){if(e[o]===`*`&&e[o+1]===`/`){n[o]=` `,n[o+1]=` `,o+=2;break}s(o),o+=1}continue}if(c===`/`){let r=cl(e,n??e,o)?ll(e,o):null;if(r!==null){if(t)for(let e=o+1;e<r-1;e+=1)s(e);o=r;continue}}if(a.length>0){let e=a.length-1;c===`{`?a[e]+=1:c===`}`&&(a[e]===0?(a.pop(),r="`",i=t):--a[e])}o+=1}return n?.join(``)??e},fl=e=>e.includes(`//`)||e.includes(`/*`)?dl(e,!1):e,pl=e=>dl(e,!0),ml=new WeakMap,hl=new WeakMap,gl=(e,t=!1)=>{if(!Fc.test(e.relativePath)&&!il(e.relativePath))return e.content;let n=t?hl:ml,r=n.get(e);if(r!==void 0)return r;let i=t?pl(e.content):fl(e.content);return n.set(e,i),i},K=({shouldScan:e,pattern:t,requireAll:n,suppressWhen:r,ignoreStringLiterals:i,message:a})=>o=>{if(!e(o))return[];let s=gl(o,i);if(n!==void 0&&!n.every(e=>e.test(s)))return[];let c=-1;if(t instanceof RegExp)c=s.search(t);else for(let e=0;e<t.length&&(c=s.search(t[e]),!(c>=0));e+=1);if(c<0||r!==void 0&&r.test(s))return[];let{line:l,column:u}=W(s,c);return[{message:a,line:l,column:u}]},_l=/\b(?:tool\s*\(\s*\{|createTool\s*\(|defineTool\s*\(|new\s+(?:DynamicTool|StructuredTool)\s*\()/,vl=/\b(?:tool|createTool|defineTool|DynamicTool|StructuredTool)\b/,yl=/(?:^|\/)(?:agents?|tools?|mcp)(?:\/|$)|(?:agent|tool|mcp)[^/]*\.[cm]?[jt]sx?$/i,bl=U({id:`agent-tool-capability-risk`,title:`Agent tool exposes dangerous capability`,severity:`warn`,recommendation:`Treat tool inputs as prompt-injection controlled. Validate arguments, scope permissions per call, and avoid exposing shell/file/network primitives directly to agents.`,scan:K({shouldScan:e=>G(e.relativePath)&&yl.test(e.relativePath)&&vl.test(e.content)&&qc.test(e.content),pattern:_l,requireAll:[qc],ignoreStringLiterals:!0,message:`An agent-callable tool appears to expose network, filesystem, shell, or code-execution capability.`})}),xl=U({id:`artifact-baas-authority-surface`,title:`BaaS authority map shipped in browser artifact`,severity:`warn`,recommendation:`Client BaaS config is often public, but shipped collection names plus owner, role, tenant, or admin fields give attackers a precise authorization map. Verify rules/RLS enforce every boundary server-side.`,scan:K({shouldScan:e=>Xc(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.`})}),Sl=new Set([`auth`,`getSession`,`getServerSession`,`getUser`,`requireAuth`,`checkAuth`,`verifyAuth`,`authenticate`,`currentUser`,`getAuth`,`validateSession`]),Cl=/^auth(?:n|z|ed|enticate[ds]?|enticating|entication|orize[ds]?|orizing|orization|orizer)?$/,wl=new Set([`signedin`,`loggedin`,`signin`]),Tl=new Set([`require`,`ensure`,`assert`,`verify`,`validate`,`check`,`protect`,`enforce`,`guard`,`gate`,`restrict`,`is`,`has`,`can`,`must`]),El=new Set([`get`,`fetch`,`load`,`read`,`resolve`,`retrieve`,`use`]),Dl=new Set([`current`,`my`,`own`]),Ol=new Set([`session`,`sessions`,`login`,`admin`,`admins`,`superadmin`,`superuser`,`role`,`roles`,`permission`,`permissions`,`jwt`,`identity`,`principal`,`credential`,`credentials`]),kl=new Set([`user`,`users`,`account`,`accounts`,`token`,`tokens`,`access`,`me`,`viewer`,`caller`,`subject`,`scope`,`scopes`]),Al=new Set([`getUser`]),jl=/(?:^|[._])(?:auth|authn|authz|clerk|session|jwt|firebase|supabase|nextauth|kinde|workos|stytch|descope|cognito|propelauth|lucia)/i,Ml=[/^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,}$/],Nl=[/\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],Pl=/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{16,}\b/,Fl=/\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,Il=/\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/,Ll=/\b(?:(?:process|window)\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->))|import\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->|meta\s*(?:\/[*/]|<!--|-->|\.\s*(?:\/[*/]|<!--|-->)))))/,Rl=/\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/,zl=/(?:SENTRY_DSN|PUBLIC_KEY|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,Bl=[/^appl_/,/^goog_/,/^amzn_/,/^strp_/,/^pk_(?:live|test)_/,/^sb_publishable_/,/^phc_/,/^public-token-(?:live|test)-/,/^pk\.eyJ/],Vl=[/^[\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],Hl=[/(?:^|[_\-\s])(?:example|sample|dummy)(?:$|[_\-\s])/i],Ul=/(?:placeholder|example|sample|dummy|masked|redacted|mask)/i,Wl=/(?:api_?key|secret|token|password|credential|auth(?!or(?!i[sz])))/i,Gl=/(?:^|\/)[^/]+\.config\.[cm]?[jt]s$/,Kl=/(?:^|\/)(?:\.[a-z-]+rc|[a-z-]+\.rc)\.[cm]?[jt]s$/,ql=/(?:^|\/)[^/]+\.(?:test|spec|stories|story|fixture|fixtures)\.[cm]?[jt]sx?$/,Jl=/(?:^|\/)[^/]+\.server\.[cm]?[jt]sx?$/,Yl=/(?:^|\/)(?:middleware|proxy|route)\.[cm]?[jt]sx?$/,Xl=/(?:^|\/)pages\/api\/.+\.[cm]?[jt]sx?$/,Zl=/(?:^|\/)[^/]+\.(?:client|browser|web)\.[cm]?[jt]sx?$/,Ql=/(?:^|\/)(?:src\/)?(?:main|index|[Aa]pp|client)\.[cm]?[jt]sx?$/,$l=new Set([`backend`,`functions`,`lambdas`,`lambda`,`middleware`,`server`,`servers`]),eu=new Set([`api`,`backend`,`edge`,`function`,`functions`,`lambda`,`lambdas`,`server`,`servers`,`worker`,`workers`]),tu=new Set([`__fixtures__`,`__mocks__`,`__tests__`,`fixtures`,`mocks`,`test`,`tests`]),nu=new Set([`bin`,`config`,`configs`,`script`,`scripts`,`tooling`,`tools`]),ru=new Set([`components`,`features`,`hooks`,`pages`,`ui`,`views`,`widgets`]),iu=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(`.`)),au=new Set([`start`,`end`]),q=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),ou=new RegExp(Fl.source,`gi`),su=e=>{for(let t of e.matchAll(ou)){let e=t[0]??``;if(!zl.test(e))return new RegExp(q(e))}},cu=e=>Il.test(e)&&Rl.test(e),lu=/\.(?:[cm]?[jt]sx?)$/i,uu=/\/\/|\/\*|<!--/,du=new Set([`\r`,`
|
|
9
|
+
`,`\u2028`,`\u2029`]),fu=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&&!du.has(e[r]??``)&&e[r]?.trim()===``;)--r;if(r<0||du.has(e[r]??``))return!0;t=n+3}return!1},pu=(t,n)=>{if(!lu.test(t)||!n.startsWith(`#!`)&&!uu.test(n)&&!fu(n))return n;try{let r=e(t,n,{astType:`ts`,lang:Ft(t)});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}},mu=(e,t,n)=>{if(Uc.test(e.relativePath)||!Xc(e.relativePath,e.isGeneratedBundle))return[];let r=t(e.content);if(r===void 0)return[];let i=Mc(e.content,r);return[{message:n,line:i.line,column:i.column}]},hu=`A browser artifact contains server-secret environment names or a full environment dump shape.`,gu=e=>su(e)??(cu(e)?Rl:void 0),_u=U({id:`artifact-env-leak`,title:`Server env leaked to browser artifact`,severity:`error`,recommendation:`Treat public env prefixes as publication, not secrecy; keep secret env vars server-only and rebuild after rotating leaked keys.`,scan:e=>{let t=!1,n=mu(e,e=>{let n=su(e);if(n)return t=!0,n;if(Rl.test(e))return Il.test(e)?(t=!0,Rl):Ll.test(e)?Rl:void 0},hu);if(n.length===0)return n;let r=t?n:mu(e,gu,hu),i=pu(e.relativePath,e.content);return i===void 0?n:i===e.content?r:mu({...e,content:i},gu,hu)}}),vu=U({id:`artifact-secret-leak`,title:`Secret shipped in browser artifact`,severity:`error`,recommendation:`Remove the secret from client bundles/static assets, rotate it, and route privileged service calls through server-only code.`,scan:e=>mu(e,e=>Nl.find(t=>t.test(e)),`A browser-delivered artifact contains a secret-looking credential value.`)}),yu=/(?: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,bu=/(?:npm|pnpm|yarn|bun)\s+(?:install|ci)\b/i,xu=/\bsecrets\.[A-Z0-9_]+/,Su=/--ignore-scripts\b/,Cu=`The build or install pipeline can execute package lifecycle code while CI secrets may be present.`,wu=e=>/(?:^|\/)\.github\/workflows\/[^/]+\.ya?ml$/i.test(e),Tu=e=>{let t=e.split(`
|
|
10
|
+
`),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=xu.test(n.join(`
|
|
11
|
+
`));for(let e of r){let t=e.lines.join(`
|
|
12
|
+
`);if(!bu.test(t)||Su.test(t)||!s&&!xu.test(t))continue;let n=Math.max(e.lines.findIndex(e=>bu.test(e)),0),r=e.lines[n].search(bu);return[{message:Cu,line:e.startLineIndex+n+1,column:(r===-1?0:r)+1}]}return[]},Eu=K({shouldScan:e=>Zc(e.relativePath)&&!e.relativePath.endsWith(`package.json`)&&!wu(e.relativePath),pattern:yu,message:Cu}),Du=U({id:`build-pipeline-secret-boundary`,title:`Build pipeline runs code near secrets`,severity:`warn`,recommendation:`Run dependency installs with scripts disabled before exposing secrets, isolate untrusted build code, and move signing/deploy authority into a narrow privileged step.`,scan:e=>wu(e.relativePath)?Tu(e.content):Eu(e)}),Ou=U({id:`clickjacking-redirect-risk`,title:`Redirect or frame boundary risk`,severity:`warn`,recommendation:"Allowlist redirect origins/paths, set `frame-ancestors` for privileged pages, and avoid URL-prefilled privileged dialogs.",scan:K({shouldScan:e=>G(e.relativePath)||Zc(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.`})}),ku=e=>/(?:^|\/)(?:tools?|scripts?)\/|(?:^|\/)management\/commands\/|(?:^|\/)(?:build|make|gulpfile|gruntfile)\.[cm]?[jt]s$/i.test(e),Au=e=>$c(e,Ic),ju=String.raw`(?:req\.|request\.|params\.|query\.|body\.|searchParams|\$_(?:GET|POST|REQUEST))`,Mu=String.raw`(?:(?<![.\w$])(?:exec(?:Sync)?|system|passthru|proc_open|shell_exec)|\b(?:os\.system|subprocess\.(?:run|Popen|call)|(?:child_process|childProcess|cp)\.exec\w*))`,Nu=String.raw`(?:(?<![.\w$])spawn(?:Sync)?|\b(?:child_process|childProcess|cp)\.spawn\w*)`,Pu=String.raw`['"](?:sh|bash|zsh|dash|ksh|cmd(?:\.exe)?|powershell(?:\.exe)?|pwsh)['"]`,Fu=String.raw`['"](?:-c|/c|-Command)['"]`,Iu=U({id:`command-execution-input-risk`,title:`Command execution uses caller-shaped input`,severity:`error`,recommendation:`Avoid shell execution for caller-controlled values. Use fixed commands, argument arrays, strict allowlists, and no shell interpolation.`,scan:K({shouldScan:e=>Au(e.relativePath)&&!ku(e.relativePath),pattern:[new RegExp(String.raw`${Mu}\s*\([^)]{0,220}(?:${ju}|shell\s*=\s*true|f['"\`][^'"\`]*\{)`,`i`),new RegExp(String.raw`${Nu}\s*\((?:[^,)]{0,120}?${ju}|\s*${Pu}\s*,\s*\[\s*${Fu}\s*,[^\]]{0,220}${ju}|(?=[^)]{0,220}shell\s*[:=]\s*true)[^)]{0,220}${ju})`,`i`)],message:`Command execution appears to include request, query, body, or shell-interpolated input.`})}),Lu=U({id:`cors-cookie-trust-risk`,title:`Broad cookie or credentialed CORS trust`,severity:`warn`,recommendation:`Keep auth cookies host-only and HttpOnly, avoid credentialed CORS for less-trusted docs/vendor origins, and isolate documentation domains from app sessions.`,scan:K({shouldScan:e=>G(e.relativePath)||Zc(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.`})}),Ru=(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},zu=e=>`end`in e&&typeof e.end==`number`?e.end:-1,J=e=>`start`in e&&typeof e.start==`number`?e.start:-1,Bu=e=>{let t=O(e);for(;S(t,`SequenceExpression`);){let e=t.expressions.at(-1);if(!e)break;t=O(e)}return t},Vu=e=>{if(e.kind!==`import`)return null;let t=e.declarationNode.parent;return S(t,`ImportDeclaration`)?t:null},Hu=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},Uu=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`},Y=e=>{let t=Bu(e);if(S(t,`ConditionalExpression`)){let e=Y(t.test);return e.every(e=>e.truthiness===`truthy`)?Y(t.consequent):e.every(e=>e.truthiness===`falsy`)?Y(t.alternate):Hu([...Y(t.consequent),...Y(t.alternate)])}if(!S(t,`LogicalExpression`))return[Uu(t)];let n=Y(t.left),r=Y(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 Hu(i)},Wu=e=>{let t=[],n=new Set;for(let r of Y(e))n.has(r.expression)||(n.add(r.expression),t.push(r.expression));return t},Gu=new Set([`assign`,`defineProperties`,`defineProperty`]),Ku=new Set([`defineProperty`,`set`]),qu=new WeakMap,Ju=e=>{let t=F(e);for(;t.parent;){let e=t.parent;if(!S(e,`MemberExpression`)||e.object!==t)break;t=F(e)}return t},X=e=>{let t=e;for(;t;){if(x(t)||S(t,`Program`))return t;t=t.parent}return e},Z=(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=>Z(e,t));if(!S(e,`IfStatement`))return!1;if(S(e.test,`Literal`)){let n=e.test.value?e.consequent:e.alternate;return n?Z(n,t):!1}return!!(e.alternate&&Z(e.consequent,t)&&Z(e.alternate,t))},Yu=e=>Z(e,!0),Xu=(e,t)=>{let n=t.indexOf(e);return n>0&&t.slice(0,n).some(Yu)},Zu=(e,t)=>{let n=e;for(;n.parent&&n!==t;){let e=n.parent;if((S(e,`BlockStatement`)||S(e,`Program`))&&Xu(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`)&&Xu(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},Qu=(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},$u=(e,t)=>{let n=O(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:J(e.declarationNode)>J(n):!0}if(S(n,`ArrayExpression`))return n.elements.some(e=>e?S(e,`SpreadElement`)?!0:$u(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=O(n.argument);return n.operator===`typeof`&&S(e,`Identifier`)&&!t.symbolFor(e)?!1:$u(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},ed=(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`)?$u(e.expression,n):S(e,`VariableDeclaration`)?e.declarations.some(e=>!S(e.id,`Identifier`)||!!(e.init&&$u(e.init,n))):!0)},td=(e,t)=>S(e,`AwaitExpression`)?$u(e.argument,t):!1,nd=(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`)&&(ed(e,r,n)||td(e,n))||(S(t,`CallExpression`)||S(t,`MemberExpression`))&&t.optional)return!0;r=t}return!1},rd=(e,t)=>{let n=e;for(;n;){if(n===t)return!0;n=n.parent}return!1},id=(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},ad=e=>S(e,`AwaitExpression`)||S(e,`YieldExpression`)?e.argument?zu(e.argument):zu(e):S(e,`ForOfStatement`)?zu(e.right):J(e),od=(e,t,n)=>{if(J(t)<ad(e))return!1;let r=id(e,n);return!!(r&&rd(t,r))},sd=e=>{let t=qu.get(e);if(t)return t;let n=(t,n,r)=>{let i=O(t);if(!S(i,`MemberExpression`))return!1;let a=O(i.object);return!!(S(a,`Identifier`)&&a.name===n&&e.isGlobalReference(a)&&r.has(M(i)??``))},r=e=>{let t=O(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=N(e,{allowComputedString:!0});if(t===null)return null;n.add(t)}return n},i=e=>{let t=Ju(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=M(t);return e===null?null:new Set([e])}if(!(!S(i,`CallExpression`)||i.arguments[0]!==t)){if(n(i.callee,`Object`,Gu)){let e=O(i.callee);if(!S(e,`MemberExpression`))return;let t=M(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`,Ku)){let e=i.arguments[1];return e&&S(e,`Literal`)&&typeof e.value==`string`?new Set([e.value]):null}}}},a=e=>{let t=F(e),n=t.parent;if(S(n,`ForOfStatement`)&&n.right===t)return n.await||Z(n.body,!1);let r=n;if(!S(r,`MemberExpression`)||r.object!==t||M(r)!==`next`)return!1;let i=F(r);return!!(S(i.parent,`CallExpression`)&&i.parent.callee===i)},o=e=>{let t=F(e),n=t.parent;return S(n,`ForOfStatement`)&&!n.await&&n.right===t&&!Z(n.body,!1)?!0:!!(S(n,`SpreadElement`)&&n.parent&&!S(n.parent,`ObjectExpression`))},s=e=>{let t=F(e),n=t.parent;if(!S(n,`ForOfStatement`)||n.await||n.right!==t||Z(n.body,!1))return[];let r=X(n.body),i=new Set;return A(n.body,e=>{if(X(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){rd(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=O(t.callee),r=null;if(x(n))r=n;else if(S(n,`Identifier`)){let t=P(n,e);if(t?.kind===`function`&&x(t.declarationNode))r=t.declarationNode;else if(t?.kind===`const`&&t.initializer){let e=O(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;A(e.rootScope.node,t=>{if(S(t,`CallExpression`)){let e=X(t),n=l(t);n&&!Zu(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=P(t,e);if(!r)return;let o=X(t);if(Zu(t,o))return;let c=d.get(r.id)??[];c.push({node:t,owner:o,propertyNames:n,symbolId:r.id}),d.set(r.id,c)});let f=t=>{let n=X(t),r=J(t),i=new Set,a=(e,t)=>{for(let n of u)n.owner!==e||J(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?J(t.call):1/0},m=new Map;for(let e of u){let t=m.get(e.owner)??[];t.push(e),m.set(e.owner,t)}let h=new WeakMap,ee=(e,t)=>{let n=h.get(e)?.get(t);if(n!==void 0)return n;let r=[e],i=new Set,a=!1;for(;r.length>0;){let e=r.pop();if(!(!e||i.has(e))){if(e===t){a=!0;break}i.add(e);for(let t of m.get(e)??[])r.push(t.targetOwner)}}let o=h.get(e)??new WeakMap;return o.set(t,a),h.set(e,o),a},g=(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=>Z(e,!1)));a&&!i&&!c&&n.add(t),r=t}return n},_=(e,t,n)=>{let r=g(e,n);return r.size===0?!1:[...g(t,n)].some(e=>r.has(e))},v=new WeakMap,y=e=>{let t=v.get(e);if(t)return t;let n=new Map;for(let t of u){if(!ee(t.targetOwner,e))continue;let r=n.get(t.owner)??[];r.push(t),n.set(t.owner,r)}return v.set(e,n),n},te=(e,t)=>{let n=y(e),r=y(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&&(J(r.call)<J(t.call)||x(e)||_(r.call,t.call,e)))return!0}}return!1},ne=e=>{let t=X(e);if(S(t,`Program`))return!1;let n=u.filter(e=>S(e.owner,`Program`)&&ee(e.targetOwner,t));return n.length===0?!1:n.length!==1||n[0]?.targetOwner!==t},re=e=>{let t=Ju(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=O(t);if(S(r,`Identifier`)){let t=P(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=Ju(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=Qu(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`)?O(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=O(a.right):c&&(l=c),!S(l,`Identifier`))continue;let u=P(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||!rd(n,e));(t.yieldCount!==null||i)&&r.add(`YieldExpression`);let a=[],o=1/0,s=1/0,c=0;return A(t.targetOwner.body,n=>{if(X(n)!==t.targetOwner||Zu(n,t.targetOwner)||!(r.has(n.type)&&(!S(n,`ForOfStatement`)||n.await)))return;let l=S(n,`YieldExpression`)&&n.argument?O(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=ad(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}nd(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:J(e.node)})),...u.filter(t=>t.owner===e.targetOwner).map(e=>({call:e,index:J(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=>od(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:J(e.node)})),...u.filter(t=>t.owner===e).map(e=>({call:e,index:J(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=>od(t,l,e)))continue;if(`event`in s){if(!p.has(s.event.symbolId))continue;let e=!!(c||p.get(s.event.symbolId)||Qu(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||Qu(s.call.call,s.call.owner)||s.index>a,oe(s.call,p))}},a=X(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,J(n),1/0,[],new Set,!1,o),r},getOutermostTarget:Ju,isGlobalNamespaceMethod:n,isExecutionOrderAmbiguous:ne,isMutationOrderAmbiguous:(e,t,n)=>{let r=X(t),i=J(t);if((d.get(e.id)??[]).some(e=>n!==null&&e.propertyNames!==null&&!e.propertyNames.has(n)?!1:e.owner===r?J(e.node)>=i&&(x(r)||_(e.node,t,r)):S(e.owner,`Program`)?(y(r).get(e.owner)??[]).some(t=>_(e.node,t.call,e.owner)):ee(e.owner,r)||te(e.owner,r)))return!0;let a=new Map([[e.id,!1]]);return u.some(e=>e.owner===r&&J(e.call)>=i&&_(e.call,t,r)&&ce(e,a,n))},isMutatedBefore:(e,t,n)=>{let r=d.get(e.id);if(!r)return!1;let i=J(t),a=X(t),o=f(t);return r.some(e=>n!==null&&e.propertyNames!==null&&!e.propertyNames.has(n)?!1:e.owner===a?J(e.node)<i:S(e.owner,`Program`)&&!S(a,`Program`)?J(e.node)<p(a):o.has(e.owner))}};return qu.set(e,le),le},cd=(e,t)=>t===`katex`?e===`katex`||e.startsWith(`katex/`):e===t,ld=(e,t,n)=>{let r=O(e);if(!S(r,`CallExpression`))return!1;let i=O(r.callee),a=r.arguments[0];return!!(S(i,`Identifier`)&&i.name===`require`&&n.isGlobalReference(i)&&a&&S(a,`Literal`)&&typeof a.value==`string`&&cd(a.value,t))},ud=(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`&&cd(r.expression.value,t))},dd=(e,t)=>{let n=O(e);return!!(S(n,`AwaitExpression`)&&S(n.argument,`ImportExpression`)&&S(n.argument.source,`Literal`)&&typeof n.argument.source.value==`string`&&cd(n.argument.source.value,t))},fd=(e,t,n,r,i)=>{let a=P(O(e),i),o=sd(i);if(!a||o.isExecutionOrderAmbiguous(r)||o.isMutationOrderAmbiguous(a,r,n)||o.isMutatedBefore(a,r,n))return null;let s=Vu(a);if(typeof s?.source.value==`string`&&cd(s.source.value,t))return S(a.declarationNode,`ImportDefaultSpecifier`)||S(a.declarationNode,`ImportNamespaceSpecifier`)||j(a.declarationNode)===`default`?a:null;if(ud(a,t))return a;if(a.kind!==`const`||!a.initializer)return null;let c=O(a.initializer);return ld(c,t,i)||S(c,`MemberExpression`)&&M(c)===`default`&&(ld(c.object,t,i)||dd(c.object,t))||dd(c,t)?a:null},pd=(e,t,n,r,i)=>{let a=P(O(e),i);if(!a)return null;let o=Vu(a),s=sd(i);return typeof o?.source.value!=`string`||!cd(o.source.value,t)||j(a.declarationNode)!==n||s.isExecutionOrderAmbiguous(r)||s.isMutationOrderAmbiguous(a,r,null)||s.isMutatedBefore(a,r,null)?null:a},md=(e,t,n)=>fd(e,`katex`,`renderToString`,t,n)!==null||ld(e,`katex`,n),hd=(e,t,n)=>{if(pd(e,`katex`,`renderToString`,t,n))return!0;let r=O(e);if(!S(r,`Identifier`))return!1;let i=n.referenceFor(r)?.resolvedSymbol;if(!i||i.kind!==`const`||!i.initializer||sd(n).isMutatedBefore(i,t,null))return!1;let a=O(i.initializer),o=i.bindingIdentifier.parent;return S(o,`Property`)&&N(o,{allowComputedString:!0})===`renderToString`?md(a,i.declarationNode,n):S(a,`MemberExpression`)&&M(a)===`renderToString`&&md(a.object,i.declarationNode,n)?!0:S(a,`Identifier`)?hd(a,i.declarationNode,n):!1},gd=(e,t)=>{let n=O(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`)||M(n)!==`renderToString`)return!1;let r=O(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(!cd(String(Vu(i)?.source.value??``),`katex`))return!0;let e=sd(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=O(i.initializer);if(S(a,`ObjectExpression`))return!0;if(S(a,`CallExpression`)){let e=O(a.callee);return S(e,`Identifier`)&&e.name===`require`}return S(a,`AwaitExpression`)&&S(a.argument,`ImportExpression`)},_d=(e,t)=>{let n=O(e);if(!S(n,`ObjectExpression`))return null;let r;for(let e of n.properties){if(!S(e,`Property`)){r=null;continue}let n=N(e,{allowComputedString:!0});if(n===null){r=null;continue}n===t&&(r=e.kind===`init`?e.value:null)}return r},vd=e=>{let t=O(e);if(!S(t,`ObjectExpression`))return null;for(let e of t.properties){if(!S(e,`Property`))return null;let t=N(e,{allowComputedString:!0});if(t===null||t===`get`||t===`set`)return null}return _d(t,`value`)},yd=new WeakMap,bd=(e,t)=>{let n=O(e);return S(n,`Identifier`)?n.name===`undefined`&&t.isGlobalReference(n):S(n,`Literal`)&&!n.value},xd=(e,t,n)=>{let r=vd(t);return r===null?`trusted`:r===void 0?e:bd(r,n)?`untrusted`:`trusted`},Sd=(e,t)=>e===t?e:e===`trusted`||t===`trusted`?`trusted`:e===`unsupported`||t===`unsupported`?`unsupported`:`untrusted`,Cd=(e,t,n,r)=>{let i=sd(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=M(a);return t===null?`trusted`:t===`trust`?bd(o.right,n)?`untrusted`:`trusted`:e}if(S(o,`UnaryExpression`)&&o.operator===`delete`){if(!S(a,`MemberExpression`))return`unsupported`;let t=M(a);return t===null?`trusted`:t===`trust`?`absent`:e}if(S(o,`UpdateExpression`)){if(!S(a,`MemberExpression`))return`unsupported`;let t=M(a);return t===`trust`||t===null?`trusted`:e}if(!S(o,`CallExpression`)||o.arguments[0]!==a)return`unsupported`;if(i.isGlobalNamespaceMethod(o.callee,`Object`,Gu)){let t=O(o.callee);if(!S(t,`MemberExpression`))return`unsupported`;let i=M(t);if(i===`assign`){let t=e;for(let e of o.arguments.slice(1)){let i=wd(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=_d(t,`trust`);return r===null?`trusted`:r===void 0?e:xd(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?xd(e,s,n):`unsupported`}if(i.isGlobalNamespaceMethod(o.callee,`Reflect`,Ku)){let t=O(o.callee);if(!S(t,`MemberExpression`))return`unsupported`;let r=M(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`?xd(e,a,n):bd(a,n)?`untrusted`:`trusted`:`unsupported`}return`unsupported`},wd=(e,t,n,r)=>{if(e===void 0)return`absent`;let i=O(e);if(S(i,`Identifier`)){if(i.name===`undefined`&&n.isGlobalReference(i))return`absent`;let e=P(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=sd(n);if(o.isMutationOrderAmbiguous(e,t,`trust`))return`unsupported`;let s=wd(e.initializer,t,n,a);for(let r of o.getEventsBefore(e,t)){let e=Cd(s,r.node,n,a);s=r.isConditional?Sd(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=wd(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=N(e,{allowComputedString:!0});if(t===null){a=`trusted`;continue}t===`trust`&&(a=bd(e.value,n)?`untrusted`:`trusted`)}return a},Td=(e,t,n)=>{let r=yd.get(e),i=new Map(r);for(let[e,n]of t)i.set(e,n);yd.set(e,i);try{return n()}finally{r?yd.set(e,r):yd.delete(e)}},Ed=(e,t,n,r)=>{let i=e?O(e):void 0;if(i&&S(i,`Identifier`)){let e=n.referenceFor(i)?.resolvedSymbol,t=e?yd.get(n)?.get(e.id):void 0;if(t)return t}let a=wd(e,t,n,r);return{isSafe:a===`absent`||a===`untrusted`}},Dd={containsKatex:!1,isConclusive:!0,isSafe:!0,isSafeInAttributeContext:!0},Od={containsKatex:!1,isConclusive:!0,isSafe:!0,isSafeInAttributeContext:!1},Q={containsKatex:!1,isConclusive:!1,isSafe:!1,isSafeInAttributeContext:!1},kd={containsKatex:!0,isConclusive:!1,isSafe:!1,isSafeInAttributeContext:!1},Ad={containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1},jd=new WeakMap,Md=new WeakMap,Nd=(e,t,n)=>{jd.set(e,t),Md.set(e,n)},Pd=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)}),Fd=(e,t)=>{let n=O(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=N(e,{allowComputedString:!0});n===null?(r=!1,i=null):n===t&&(r=!0,i=e.value)}return{isKnown:r,value:i}},Id=(e,t)=>{let n=O(e);if(S(n,`Identifier`)){let e=P(n,t);return!!(e&&e.kind===`import`&&Vu(e)?.source.value===`react`&&j(e.declarationNode)===`useMemo`)}if(!S(n,`MemberExpression`)||M(n)!==`useMemo`)return!1;let r=P(O(n.object),t);return!!(r&&r.kind===`import`&&Vu(r)?.source.value===`react`&&(S(r.declarationNode,`ImportDefaultSpecifier`)||S(r.declarationNode,`ImportNamespaceSpecifier`)||j(r.declarationNode)===`default`))},Ld=(e,t)=>{let n=O(e),r=!1;for(;S(n,`CallExpression`);){let e=O(n.callee);if(!S(e,`MemberExpression`))return!1;let t=M(e);if(t!==`replace`&&t!==`replaceAll`)return!1;let i=n.arguments[0],a=n.arguments[1];if(!i||!a||!S(a,`Literal`)||typeof a.value!=`string`||a.value.includes(`<`)||a.value.includes(`$`))return!1;if(S(i,`Literal`)){let e=`regex`in i?i.regex:void 0,n=t===`replaceAll`&&i.value===`<`,a=e?.pattern===`<`&&e.flags.includes(`g`);(n||a)&&(r=!0)}n=O(e.object)}return!r||!S(n,`Identifier`)?!1:t.referenceFor(n)?.resolvedSymbol?.kind===`parameter`},Rd=(e,t)=>{let n=O(e.callee);return S(n,`MemberExpression`)&&M(n)===`sanitize`&&(fd(n.object,`dompurify`,`sanitize`,e,t)||fd(n.object,`isomorphic-dompurify`,`sanitize`,e,t))?Od:S(n,`MemberExpression`)&&M(n)===`escape`&&fd(n.object,`html-escaper`,`escape`,e,t)||pd(n,`html-escaper`,`escape`,e,t)?Dd:pd(n,`dompurify`,`sanitize`,e,t)||pd(n,`isomorphic-dompurify`,`sanitize`,e,t)?Od:null},zd=(e,t)=>{if(!t.isSafe)return null;let n=O(e.callee);if(!S(n,`MemberExpression`))return null;let r=M(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)}},Bd=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`},Vd=(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=Bd(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}},Hd=(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=>L(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=>L(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},Ud=(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 A(i,e=>{if(e!==i&&x(e))return!1;if(S(e,`ReturnStatement`))return Hd(e,i)||a.push(e.argument?$(e.argument,t,new Set(n),r):Dd),!1}),a.length===0?Dd:Pd(a)},Wd=(e,t)=>{let n=O(e);if(!S(n,`Identifier`))return null;let r=P(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=O(r.initializer);return x(i)?{functionNode:i,symbol:r}:null},Gd=(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?Td(r,i,()=>Ed(e,t,n,new Set)):Ed(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=N(e,{allowComputedString:!0});if(t===null)continue;let n=Fd(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},Kd=(e,t)=>{let n=O(e.callee);if(!S(n,`Identifier`))return null;let r=P(n,t);if(!r||r.kind!==`import`)return null;let i=Vu(r),a=j(r.declarationNode),o=jd.get(t),s=i?.source.value,c=Md.get(t)??0;if(!o||typeof s!=`string`||!a||c>=2)return null;let l=On(o,s,a);if(!l||!x(l.functionNode))return null;let u=Ne(l.programNode);return Nd(u,l.filePath,c+1),Td(u,Gd(l.functionNode,e,t,u),()=>Ud(l.functionNode,u,new Set))},qd=(e,t,n,r)=>{if(!S(e,`CallExpression`))return Q;let i=O(e.callee);if(S(i,`MemberExpression`)&&M(i)===`renderToString`&&md(i.object,e,t)||hd(i,e,t))return{containsKatex:!0,isConclusive:!0,isSafe:Ed(e.arguments[1],e,t,new Set).isSafe,isSafeInAttributeContext:!1};let a=Kd(e,t);if(a?.containsKatex)return a;let o=Wd(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=O(e);return x(i)?Ud(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=Td(t,Gd(o.functionNode,e,t,t),()=>Ud(o.functionNode,t,i,s));return!a.some(e=>e.containsKatex)||l.containsKatex?l:c?kd:Ad}if(gd(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 zd(e,a)||(a.isConclusive?{containsKatex:!0,isConclusive:!0,isSafe:!1,isSafeInAttributeContext:!1}:kd)}let s=Rd(e,t);if(s)return s;if(Ld(e,t))return Od;if(Id(i,t)){let i=e.arguments[0];if(!i)return Q;let a=O(i);if(x(a))return Ud(a,t,new Set(n),r);let o=Wd(a,t);if(!o||n.has(o.symbol.id))return Q;let s=new Set(n);return s.add(o.symbol.id),Ud(o.functionNode,t,s,r)}return e.arguments.some(e=>{let i=O(e);return(x(i)?Ud(i,t,new Set(n),r):$(i,t,new Set(n),r)).containsKatex})?kd:Q},Jd=(e,t)=>{let n=Bu(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=Sa(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=Jd(n.argument,t);return e===null?null:!e}}return null},$=(e,t,n,r=new Map)=>{let i=O(e);if(S(i,`Literal`)||S(i,`UnaryExpression`)&&i.operator===`void`)return Dd;if(S(i,`Identifier`)){if((i.name===`undefined`||i.name===`NaN`)&&t.isGlobalReference(i))return Dd;let e=t.referenceFor(i)?.resolvedSymbol,a=e?r.get(e.id):void 0;if(a)return a;if(!e||e.kind!==`const`||!e.initializer||n.has(e.id))return Q;let o=new Set(n);return o.add(e.id),$(e.initializer,t,o,r)}if(S(i,`CallExpression`))return qd(i,t,n,r);if(S(i,`TemplateLiteral`))return Vd(i,t,n,r);if(S(i,`ConditionalExpression`)){let e=Jd(i.test,t);return e===null?Pd([$(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:Jd(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=Wu(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:Pd(a.map(e=>$(e,t,new Set(n),r))),containsKatex:o.some(e=>e.containsKatex)}}if(S(i,`BinaryExpression`)&&i.operator===`+`)return Pd([$(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},Yd=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`)&&N(e,{allowComputedString:!0})===`dangerouslySetInnerHTML`&&S(O(e.value),`ObjectExpression`)&&(t=O(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=N(e,{allowComputedString:!0});if(t===null){n=null;continue}t===`__html`&&(n=e.value)}return n},Xd=(e,t)=>{let n=It({filename:t,sourceText:e});if(n===null)return[];let r=Ne(n);Nd(r,t,0);let i=[];return A(n,e=>{let t=Yd(e);if(t===null)return;let n=$(t,r,new Set);if(!n.containsKatex)return;let a=J(e),o=zu(e);a<0||o<0||i.push({endIndex:o,proof:n,startIndex:a})}),i},Zd=/dangerouslySetInnerHTML|(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\(|\bdocument\.write(?:ln)?\s*\(|\.(?:createContextualFragment|setHTMLUnsafe)\s*\(/,Qd=/(?:__html\s*:|(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\(\s*[^,]*,|\bdocument\.write(?:ln)?\s*\(|\.(?:createContextualFragment|setHTMLUnsafe)\s*\()\s*([\s\S]*)/,$d=/searchParams|query|params|request|req\.|response\.|result\.|data\.|await|fetch|props\.|children|content|html|body|text|message|markup|\blocation\b|document\.cookie|\breferrer\b|\blocalStorage\b|\bsessionStorage\b|URLSearchParams|window\.name/i,ef=/^(?:"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`[^`$]*`)\s*(?:\/\/[^\n]*)?\s*(?:[;,})\n]|$)/,tf=/^[A-Z][A-Z0-9_]*\s*(?:\/\/[^\n]*)?\s*(?:[;,})\n]|$)/,nf=/^[\w$]+(?:\??\.[\w$]+)*\??\.(?:inner|outer)HTML\b/,rf=/\b(?:DOMPurify|sanitize\w*|purify|(?:escape|encode)[A-Za-z]*(?:Html|HTML|Entit\w*)|insane|xss)\b|(?<!un)safe|(?<!un)saniti[sz]/i,af=/[:=]\s*[^\n;]*\b(?:DOMPurify\b|sanitize\w*\s*\(|purify\w*\s*\()/i,of=/=\s*[\w$.?[\]]*\.(?:inner|outer)HTML\s*(?:[;,)\n]|$)/,sf=/process\.env/,cf=/\b(?:t|i18n|translate|formatMessage|intl)\s*[.(]/,lf=/^(?:[\w$.]+\.)?(?:toHtml|render[A-Za-z]*(?:Html|HTML)|renderToString|renderToStaticMarkup|codeToHtml|codeToHast|highlight[A-Za-z]*)\s*\(/,uf=/\b(?:shiki|prism|hljs|highlightjs|getHighlighter|codeToHtml|codeToHast|refractor|lowlight|starry-night)\b|highlight\.js/i,df=/[:=]\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,ff=/\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,pf=/^[\w$]+\s*(?:[;,})\n]|$)/,mf=/^[\w$]+\s*(?:\|\||\?\?)\s*(?:"[^"\n]*"|'[^'\n]*'|`[^`$]*`)\s*(?:[;,})\n]|$)/,hf=/^[\w$]+(?:\.[\w$]+|\[[^\]]*\])+\s*(?:[;,})\n]|$)/,gf=/<style\b[^<>]*$/,_f=/(?:^|\/)emails(?:\/|$)|email[-_.]templates?(?:\/|$)|RawHtml|[A-Za-z]*[Ee]mail[A-Za-z]*\.(?:t|j)sx?/i,vf=/(?:^|\/)\.[\w-]+\//,yf=/(?<!un)saniti[sz]e?d?[\w-]*\.[cm]?[jt]sx?$/i,bf=/(?:^|[^\w$.])([\w$]+(?:\.[\w$]+)*)(?:(?:\.(?:inner|outer)HTML|\[\s*["'](?:inner|outer)HTML["']\s*\])\s*[+]?=(?!=)|\.insertAdjacentHTML\s*\()/,xf=/\b(?:appendChild|append|prepend|before|after|replaceWith|replaceChild|replaceChildren|insertBefore|insertAdjacentElement)\s*\(/,Sf=5e3,Cf=e=>{if(!e.startsWith("`"))return null;let t=e.indexOf("`",1);if(t<0||t>Sf)return null;let n=e.slice(1,t).match(/\$\{[^}]*\}/g);return n===null?``:n.join(` `)},wf=(e,t,n)=>{let r=jf(e,t,n);return r===null?null:n.slice(r.initializerStartIndex,r.initializerStartIndex+Sf)},Tf=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)},Ef=(e,t)=>{let n=t.includes(`createElement`),r=t.includes(`createHTMLDocument`);if(!n&&!r)return!1;let i=q(e),a=q(e.split(`.`)[0]??e);if(RegExp(`\\b${a}\\s*=\\s*[^\\n;]*(?:getElementById|querySelector|getElementsBy|\\.current\\b|document\\.(?:body|head|documentElement))`).test(t))return!1;if(n&&(RegExp(`${i}\\s*=\\s*document\\.createElement\\(\\s*["'\`]template["'\`]`).test(t)||RegExp(`${a}\\s*=\\s*[^\\n;]*\\bcreateElement\\(\\s*["'\`](?:style|textarea)["'\`]`).test(t))||r&&RegExp(`${a}\\s*=\\s*[^\\n;]*\\bcreateHTMLDocument\\s*\\(`).test(t))return!0;if(!n||!RegExp(`${a}\\s*=\\s*[^\\n;]*\\bcreateElement\\s*\\(`).test(t))return!1;let o=RegExp(`${xf.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)},Df=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},Of=e=>{let t=e.replace(/[;}]\s*$/,``).trim();if(!t.includes(`+`))return!1;let n=Df(t).map(e=>e.trim()).filter(e=>e.length>0);return n.length<2?!1:n.every(e=>{let t=e.replace(/\(\s*([\w$]+(?:\??\.[\w$]+)*)\s+as\s+[^)]*\)/g,`$1`);return nf.test(t)?!$d.test(t.replace(nf,``)):!1})},kf=(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},Af=(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===`
|
|
13
|
+
`&&(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:kf(e,o)},jf=(e,t,n)=>{let r=RegExp(`(const|let|var)\\s+${q(e)}\\s*(?::[^=\\n]*)?=\\s*([^;\\n]+)`,`g`),i=null,a=-1;for(let e of n.matchAll(r)){let r=e.index;if(r===void 0||r>=t||r<=a||Af(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},Mf=(e,t,n,r)=>{if(t.isImmutable)return!0;let i=r.slice(t.initializerStartIndex+t.initializer.length,n);return!RegExp(`(?:^|[^\\w$.])${q(e)}\\s*=(?!=)`).test(i)},Nf=(e,t,n)=>{if(!/highlight/i.test(e))return!1;let r=e.match(/^([\w$]+)/)?.[1];if(r===void 0)return!1;let i=jf(r,n,t);return i===null?/highlighted/i.test(e)||uf.test(t):Mf(r,i,n,t)&&ff.test(i.initializer)},Pf=(e,t,n,r=new Set)=>{let i=e.trim(),a=Df(i);if(a.length>1)return a.every(e=>Pf(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=>Pf(e,t,n,r));let s=i.match(/^([\w$]+)(?:(?:\??\.[\w$]+)|(?:\[\s*(?:"[^"\n]*"|'[^'\n]*'|\d+)\s*\]))*$/)?.[1];if(s&&!r.has(s)){let e=jf(s,n,t);if(e&&Mf(s,e,n,t)){let n=new Set(r);return n.add(s),Pf(e.initializer,t,e.initializerStartIndex,n)}}return!!(ef.test(`${i};`)||tf.test(`${i};`)||rf.test(i)||sf.test(i)||cf.test(i)||lf.test(i)||Nf(i,t,n))},Ff=(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=jf(a,n,r);if(!o?.isImmutable)return!1;let s=new Set(i);return s.add(a),Ff(o.initializer,t,o.initializerStartIndex,r,s)},If=(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=kf(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},Lf=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},Rf=(e,t,n,r=new Set)=>{let i=e.trim().match(/^([\w$]+)$/)?.[1];if(i===void 0||r.has(i))return!1;if(If(i,t,n)!==null)return!0;let a=jf(i,t,n);if(!a||!Mf(i,a,t,n))return!1;let o=new Set(r);return o.add(i),Rf(a.initializer,a.initializerStartIndex,n,o)},zf=(e,t,n,r,i)=>{let a=e.trim();if(Pf(a,t,n))return!1;let o=a.match(/^([\w$]+)(?:\.|\s*(?:[;,})\n]|$))/)?.[1];if(o===void 0)return $d.test(a);if(r.has(o))return!1;r.add(o);let s=jf(o,n,t),c=If(o,n,t);if(s!==null&&(c===null||s.declarationIndex>c.declarationNameIndex))return Mf(o,s,n,t)&&Pf(s.initializer,t,s.initializerStartIndex)?!1:!Mf(o,s,n,t)||zf(s.initializer,t,s.initializerStartIndex,r,i)?!0:Rf(s.initializer,s.initializerStartIndex,t)?!1:$d.test(a);if(c!==null&&c.functionName.length>0){let e=RegExp(`\\b${q(c.functionName)}\\s*\\(`,`g`),n=!1,s=!0;for(let a of t.matchAll(e)){if(a.index===c.declarationNameIndex||i.has(a.index))continue;let e=a.index+a[0].lastIndexOf(`(`),l=Ru(t,e);if(l<0)continue;let u=Lf(t.slice(e+1,l))[c.parameterIndex];if(u===void 0||a.index>=c.declarationNameIndex&&a.index<=c.bodyEndIndex&&Ff(u,o,a.index,t))continue;n=!0,s&&=Pf(u,t,a.index);let d=new Set(r);d.delete(o);let f=new Set(i);if(f.add(a.index),zf(u,t,a.index,d,f))return!0}return n?!s&&$d.test(a):$d.test(a)}return $d.test(a)},Bf=U({id:`dangerous-html-sink`,title:`HTML injection sink with dynamic content`,severity:`warn`,recommendation:`Prefer rendering structured React nodes. If HTML is required, sanitize with a well-reviewed sanitizer and keep the trust boundary close to the sink.`,scan:e=>{if(e.isGeneratedBundle||!G(e.relativePath)||_f.test(e.relativePath)||vf.test(e.relativePath)||yf.test(e.relativePath)||!Zd.test(e.content))return[];let t=Xd(e.content,e.absolutePath),n=[],r=e.content.split(`
|
|
14
|
+
`);for(let i=0;i<r.length;i+=1){let a=r[i]??``;if(!Zd.test(a))continue;let o=a.slice(0,a.search(Zd)).replace(/"[^"]*"|'[^']*'|`[^`]*`/g,``);if(/(?:^|[^:])\/\//.test(o)||/^\s*[/*]/.test(a))continue;let s=r.slice(i,i+1+4).join(`
|
|
15
|
+
`),c=Qd.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(`
|
|
16
|
+
`).length+ +(i>0)+a.search(Zd),m=t.find(e=>p>=e.startIndex&&p<e.endIndex)?.proof;if(m?.isConclusive&&m.isSafe)continue;let h=m?.isConclusive===!0;if(ef.test(f)||tf.test(f))continue;if(nf.test(f)&&!f.includes(`+`)){let e=f.replace(nf,``);if(!$d.test(e))continue}if(Of(f))continue;let ee=Qd.exec(r.slice(i,i+1+60).join(`
|
|
17
|
+
`))?.[1]?.trimStart(),g=Cf(ee??l),_=pf.test(f)||hf.test(f)||mf.test(f)?f.match(/^[\w$]+/)?.[0]:void 0;if(g===null&&_!==void 0&&pf.test(f)&&If(_,p,e.content)===null){let t=wf(_,p,e.content);if(t!==null){if(Tf(t))continue;g=Cf(t)}}if(g===``)continue;let v=g??f,y=Df(v).length>1||(g?.match(/\$\{/g)?.length??0)>1;if(!h&&!y&&rf.test(v)||!y&&sf.test(v)||!y&&cf.test(v)||!h&&!zf(v,e.content,p,new Set,new Set)||!h&&lf.test(f)||!h&&Nf(f,e.content,p))continue;if(_!==void 0){let t=q(_),n=jf(_,p,e.content),r=n?.initializer;if(!(r!==void 0&&(Df(r).length>1||(r.match(/\$\{/g)?.length??0)>1))){let i=RegExp(`\\b${t}\\b\\s*${df.source}`,`i`);if(!h&&(r===void 0?i.test(e.content):n!==null&&Mf(_,n,p,e.content)&&ff.test(r)))continue;let a=RegExp(`\\b${t}\\b\\s*${af.source}`,`i`);if(!h&&(r===void 0?a.test(e.content):n!==null&&Mf(_,n,p,e.content)&&af.test(`=${r}`)))continue}if(RegExp(`\\b${t}\\b\\s*${of.source}`).test(e.content)||RegExp(`highlight[\\w$]*\\s*\\.map\\(\\s*(?:async\\s+)?\\(?\\s*${t}\\b`,`i`).test(e.content)&&uf.test(e.content))continue}if(hf.test(f)){let t=f.match(/\.([\w$]+)\s*(?:[;,})\n]|$)/)?.[1];if(t!==void 0&&RegExp(`\\b${q(t)}\\s*:\\s*${cf.source}`).test(e.content))continue}let te=bf.exec(a),ne=te?.[1]??te?.[2];if(ne!==void 0&&Ef(ne,e.content))continue;let re=r.slice(Math.max(0,i-5),i+1).join(`
|
|
18
|
+
`).slice(0,-a.length+a.search(Zd));gf.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}}),Vf=e=>!(!G(e)||Rc.test(e)||Bc.test(e)),Hf=/firebase|firestore|supabase|\b(?:setDoc|addDoc)\s*\(/i,Uf=U({id:`firebase-client-owned-authz-field`,title:`Client writes authorization field`,severity:`error`,recommendation:`Derive authority fields on the server or enforce them in Firebase/Supabase rules; never trust client-provided owner, org, or role values.`,scan:K({shouldScan:e=>Vf(e.relativePath)&&(Hf.test(e.content)||Hf.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.`})}),Wf=U({id:`firebase-permissive-rules`,title:`Permissive Firebase security rule`,severity:`error`,recommendation:"Bind every read/write to `request.auth.uid`, immutable ownership, and tenant membership instead of treating sign-in as authorization.",scan:K({shouldScan:e=>il(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.`})}),Gf=U({id:`firebase-query-filter-as-auth`,title:`Firestore query filter used as authorization`,severity:`warn`,recommendation:"Make sure Firestore rules compare the requested document against `request.auth.uid` and trusted membership data.",scan:K({shouldScan:e=>Vf(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.`})}),Kf=/api\.github\.com|github\.com|gitlab\.com|bitbucket\.org/gi,qf=/\$\{([^}]*)\}/g,Jf=/\b(?:params|searchParams|query|req|request|input|payload)\s*[.[]|\buntrusted|\bdecodeURI\w*/,Yf=/encodeURIComponent\s*\(/,Xf=/^\s*[\w$]+\.toString\(\)\s*$/,Zf=U({id:`git-provider-url-injection-risk`,title:`Git provider URL built from interpolation`,severity:`warn`,recommendation:`Validate owner, repo, org, and branch identifiers against strict slugs and build URLs with URL/path encoders instead of raw interpolation.`,scan:e=>{if(!G(e.relativePath))return[];let t=[];for(let n of e.content.matchAll(Kf)){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(qf)).some(e=>{let t=e[1]??``;return Jf.test(t)&&!Yf.test(t)&&!Xf.test(t)}))continue;let o=W(e.content,n.index);t.push({message:`GitHub/GitLab/Bitbucket URL construction interpolates path components that may be attacker-controlled.`,line:o.line,column:o.column});break}return t}}),Qf=/child_process|childProcess|execa|subprocess|Deno\.run/,$f=/(?:\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*["'])/,ep=/(?:\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*["'])/,tp=`Imported metadata, uploads, or plugin manifests appear to reach code execution.`,np=K({shouldScan:()=>!0,pattern:$f,ignoreStringLiterals:!0,message:tp}),rp=K({shouldScan:()=>!0,pattern:ep,ignoreStringLiterals:!0,message:tp}),ip=U({id:`import-metadata-execution-risk`,title:`Imported metadata reaches code execution`,severity:`error`,recommendation:`Parse imported metadata as data with strict schemas; do not evaluate EXIF, manifests, presets, dropped files, or archives.`,scan:e=>G(e.relativePath)?Qf.test(e.content)?np(e):rp(e):[]}),ap=/createHash\s*\(\s*["'](?:md5|sha1)["']|\bmd5\s*\(/gi,op=/\b(?:password|token|secret|signature|signing|auth|credential|session|cookie|csrf|api.?key)\b/i,sp=/(?<!cipher\.)\bcreate(?:Cipher|Decipher)\s*\(/,cp=/\bcreate(?:Cipher|Decipher)iv\s*\(\s*["'](?:des|des3|des-?ede3?|rc4|rc2|bf|blowfish)\b/i,lp=/\b(?:DES|RC4|Blowfish)\b/,up=/\b(?:cipher|decipher|encrypt|decrypt|crypto)\b/i,dp=/[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,fp=/(?:===?|!==?)\s*[A-Z](?:[a-z]|[A-Z0-9_]*\b(?!\s*[.(]))|^[A-Z](?:[a-z]|[A-Z0-9_]*\b(?!\s*[.(]))[\w$.]*(?:\([^)]*\))?\s*(?:===?|!==?)/,pp=/signature(?:Method|Type|Status|Algorithm|Kind|Mode|Version)\b/i,mp=/(?:===?|!==?)\s*(?:true|false|null|undefined)\b/,hp=/\.(?:length|size|byteLength)\s*(?:===?|!==?)|\.(?:length|size|byteLength)\s*$/,gp=/\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,_p=/\.[cm]?[jt]sx$/i,vp=/timingSafeEqual|timing.?safe/i,yp=/gravatar|digest[-_ ]?auth|oauth[-_ ]?1|pkcs#?12|smime|\b_id\b|\betag\b|checksum|cache[-_ ]?key|fingerprint/i,bp=/token|secret|password|nonce|salt|csrf|credential|otp/i,xp=/(?:focus|render|refresh|remount|redraw|animation|layout|cache|update)[-_]?nonce/i,Sp=/Math\.random\s*\(/g,Cp=/createHash|md5|cipher|encrypt|decrypt|crypto|signature|Math\.random/i,wp=(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},Tp=(e,t,n,r)=>{for(let i of e.matchAll(t)){let t=e.lastIndexOf(`
|
|
19
|
+
`,i.index)+1,a=e.indexOf(`
|
|
20
|
+
`,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},Ep=U({id:`insecure-crypto-risk`,title:`Weak cryptography in security context`,severity:`warn`,recommendation:"Use modern primitives, `crypto.randomBytes` / Web Crypto randomness, and timing-safe comparisons for signatures, digests, tokens, and auth material.",scan:e=>{if(!G(e.relativePath)||Hc.test(e.relativePath)||yp.test(e.relativePath)||!Cp.test(e.content))return[];let t=gl(e),n=wp(t,ap,op,yp);if(n<0&&(n=t.search(cp)),n<0&&(n=t.search(sp)),n<0&&up.test(t)&&(n=t.search(lp)),n<0&&!vp.test(t)&&!_p.test(e.relativePath)&&gp.test(t)){let e=dp.exec(t);e!==null&&!fp.test(e[0])&&!pp.test(e[0])&&!mp.test(e[0])&&!hp.test(e[0])&&(n=e.index)}if(n<0&&(n=Tp(t,Sp,bp,xp)),n<0)return[];let r=W(t,n);return[{message:`Code uses weak hashes, deprecated ciphers, timing-unsafe comparisons, or Math.random in a security-shaped context.`,line:r.line,column:r.column}]}}),Dp=`(?<![A-Za-z0-9])(?:session|sess|sid|connect\\.sid|auth|jwt|access[_-]?token|refresh[_-]?token|id[_-]?token)(?![A-Za-z0-9])`,Op=`[\`"'][^\`"']*?${Dp}[^\`"']*[\`"']`,kp=RegExp(`(?:\\.cookies\\.set|cookies\\(\\s*\\)\\.set|\\.cookie)\\s*\\(\\s*${Op}`,`gi`),Ap=/httpOnly\s*:\s*false\b/i,jp=/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`/g,Mp=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!==`
|
|
21
|
+
`&&(t[n]=` `),n+=1;continue}(i===`"`||i===`'`||i==="`")&&(r=i),n+=1}return t.join(``)},Np=/cookie\s*:\s*\{/gi,Pp=RegExp(`document\\.cookie\\s*=\\s*[\`"'][^\`"'=;]*?${Dp}[^\`"'=;]*=`,`gi`),Fp=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},Ip=(e,t,n,r,i)=>{t.lastIndex=0;for(let a=t.exec(e);a!==null;a=t.exec(e)){if(!r(a.index,a[0]))continue;let t=W(e,a.index);i.push({message:n,line:t.line,column:t.column})}},Lp=U({id:`insecure-session-cookie`,title:`Auth cookie missing HttpOnly protection`,severity:`warn`,recommendation:"Set auth/session cookies server-side with `httpOnly: true`, `secure: true`, and `sameSite`. Cookies set via `document.cookie` or with `httpOnly: false` are readable by any XSS payload and can be stolen.",scan:e=>{if(!G(e.relativePath))return[];let t=gl(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.`;kp.lastIndex=0;for(let e=kp.exec(t);e!==null;e=kp.exec(t)){let i=e.index+e[0].lastIndexOf(`(`),a=Ru(t,i);if(a<0)continue;let o=t.slice(i+1,a),s=Fp(o)<3,c=o.replace(jp,``);if(!s&&!Ap.test(c))continue;let l=W(t,e.index);n.push({message:r,line:l.line,column:l.column})}let i=Mp(t);Np.lastIndex=0;for(let e=Np.exec(i);e!==null;e=Np.exec(i)){let t=e.index+e[0].length-1,a=Ru(i,t),o=a>=0?i.slice(t,a):i.slice(t,t+400);if(!Ap.test(o))continue;let s=W(i,e.index);n.push({message:r,line:s.line,column:s.column})}return Ip(t,Pp,r,()=>!0,n),n}}),Rp=/\b(?:alg|algorithms?)\s*:\s*\[?\s*["'`]none["'`]/gi,zp=(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},Bp=U({id:`jwt-insecure-verification`,title:`JWT verified with the 'none' algorithm`,severity:`error`,recommendation:"Never accept the `none` algorithm; it disables signature verification and lets any forged token through. Pin the real algorithm(s) explicitly (`jwt.verify(token, key, { algorithms: ['RS256'] })`).",scan:e=>{if(!G(e.relativePath))return[];let t=gl(e);if(!/\bjwt\b|jsonwebtoken|\bjose\b/i.test(t))return[];let n=[];Rp.lastIndex=0;for(let e=Rp.exec(t);e!==null;e=Rp.exec(t)){if(zp(t,e.index))continue;let r=W(t,e.index);n.push({message:`JWT is configured with the 'none' algorithm, which disables signature verification, so any forged token is accepted.`,line:r.line,column:r.column})}return n}}),Vp=/PRIVATE KEY|SSH_PRIVATE_KEY|GPG_PRIVATE_KEY|DEPLOY_KEY|SIGNING_KEY/i,Hp=U({id:`key-lifecycle-risk`,title:`Long-lived key material in repository`,severity:`error`,committedFilesOnly:!0,recommendation:`Remove private keys from source, rotate exposed credentials, prefer short-lived deploy credentials, and document revocation/expiry for release keys.`,scan:K({shouldScan:e=>!zc.test(e.relativePath)&&!Uc.test(e.relativePath)&&Vp.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.`})}),Up=U({id:`local-rpc-native-bridge-risk`,title:`Weak localhost native bridge boundary`,severity:`warn`,recommendation:`Use exact origin allowlists after URL parsing, per-request nonces, narrow methods, and never expose install/update commands to arbitrary web pages.`,scan:K({shouldScan:e=>G(e.relativePath),pattern:/\b(?:127\.0\.0\.1|localhost|Access-Control-Allow-Origin|websocket|WebSocket)\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.`})}),Wp=/\bfrom\s+["']@modelcontextprotocol\/sdk[^"']*["']|\bMcpServer\b|\bMcpAgent\b/,Gp=/@modelcontextprotocol\/sdk|\bMcpServer\b|\bMcpAgent\b/,Kp=/\bserver\.\s*tool\s*\(|\bregisterTool\s*\(|\bsetRequestHandler\s*\(\s*CallToolRequestSchema/,qp=/\b(?:tool|registerTool|setRequestHandler)\b/,Jp=U({id:`mcp-tool-capability-risk`,title:`MCP tool exposes dangerous capability`,severity:`warn`,recommendation:`MCP tool calls run with the connecting client's authority. Validate inputs, enforce per-tool authorization, and avoid raw filesystem/shell/network access where possible.`,scan:K({shouldScan:e=>G(e.relativePath)&&Gp.test(e.content)&&qp.test(e.content)&&qc.test(e.content),pattern:Kp,requireAll:[Wp,qc],ignoreStringLiterals:!0,message:`An MCP tool/resource/prompt handler appears to expose file, shell, network, or code-execution capability.`})}),Yp=U({id:`mdx-ssr-execution-risk`,title:`Server-rendered MDX can execute code`,severity:`warn`,recommendation:`Use a constrained compiler for untrusted content, disable expressions/raw HTML, sandbox renderers, and avoid caching attacker-controlled output across tenants.`,scan:K({shouldScan:e=>G(e.relativePath),pattern:/(?:@mdx-js\/mdx|next-mdx-remote|\b(?:MDXRemote|compileMDX|evaluateMdx)\b)[\s\S]{0,700}\b(?:repo\b|customer|tenant|user[-_]?(?:content|markdown|mdx|input|provided|generated|submitted)|untrusted|searchParams|req\.|request\.|fetch\s*\(|prisma\.|db\.|database|rehypeRaw|allowDangerousHtml)/i,message:`MDX/markdown rendering code may evaluate user or repository content during SSR or static generation.`})}),Xp=U({id:`nosql-injection-risk`,title:`NoSQL query accepts operator-shaped input`,severity:`warn`,recommendation:"Coerce scalar fields before querying, reject operator keys from client input, and avoid `$where` or request-derived regexes.",scan:K({shouldScan:e=>$c(e.relativePath,Lc),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."})}),Zp=[...Nl.filter(e=>!e.test(`service_role`)),Pl],Qp=U({id:`package-metadata-secret`,title:`Secret-like package metadata`,severity:`warn`,recommendation:`Keep secrets out of package metadata and generated reports; they are often published to registries, logs, or browser artifacts.`,scan:e=>{if(!e.relativePath.endsWith(`package.json`))return[];let t=su(e.content)??Zp.find(t=>t.test(e.content));if(t===void 0)return[];let n=Mc(e.content,t);return[{message:`Package metadata contains secret-like values or public env secret names.`,line:n.line,column:n.column}]}}),$p=U({id:`path-traversal-risk`,title:`Filesystem path uses caller input`,severity:`warn`,recommendation:`Resolve paths against a fixed base directory, reject traversal after normalization, and map user-visible identifiers to server-owned paths.`,scan:K({shouldScan:e=>G(e.relativePath)&&!ku(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.`})}),em=/\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,tm=/sha(?:256|512|1)sum|--checksum|checksum=|EXPECTED_SHA|gpg\s+--verify|\.sha(?:256|512)\b/i,nm=/\b(?:child_process|childProcess|execa|os\.system|subprocess\.|Deno\.run|autoUpdater|electron-updater)\b|\b(?:exec(?:File)?(?:Sync)?|spawn(?:Sync)?)\s*\(/,rm=/.\/\.github\/workflows\//i,im=/(?:^|\/)[\w-]+[.@-]\d+\.\d+\.\d+(?:[-.][\w.]+)?\//,am=e=>Zc(e)&&!rm.test(e)&&!im.test(e)&&!Hc.test(e),om=U({id:`plugin-update-trust-risk`,title:`Plugin or updater trust boundary risk`,severity:`warn`,recommendation:`Require signed updates/plugins, pin trusted repositories, verify hashes before execution, and keep custom repository installs behind explicit warnings.`,scan:e=>{if(!G(e.relativePath)&&!am(e.relativePath))return[];let t=gl(e);if(!em.test(t)||tm.test(t)||Fc.test(e.relativePath)&&!nm.test(t))return[];let n=Mc(t,em);return[{message:`Code appears to download, install, update, or execute plugin/updater content across a trust boundary.`,line:n.line,column:n.column}]}}),sm=/origin(?!al)|\.source\s*[!=]==?/i,cm=/\b(?:event|e|evt|msg|message)\.data\b/,lm=/\b(?:const|let|var)\s+[^;=]*=\s*$/,um=/port\d?\b|worker|channel|broadcast|socket|\bws\b|\bsse\b|eventsource|^_?self\.|^source\./i,dm=String.raw`=\s*new\s+(?:EventSource|WebSocket|Worker|SharedWorker|BroadcastChannel|MessageChannel)\b`,fm=(e,t)=>{let n=/^[\w$]+/.exec(e)?.[0];return n===void 0?!1:RegExp(`(?<![\\w$.])${q(n)}\\s*${dm}`).test(t)},pm=/worker/i,mm=(e,t)=>{let n=J(t),r=zu(t);return n<0||r<0?``:e.slice(n,r)},hm=(e,t)=>{if(t.type===`CallExpression`){let n=b(t.callee)?mm(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=mm(e,t.left);return n.endsWith(`.onmessage`)?n:null}return null},gm=U({id:`postmessage-origin-risk`,title:`postMessage handler without origin check`,severity:`warn`,recommendation:"Validate `event.origin` against an exact allowlist before using `event.data`, especially when an iframe or parent window can be attacker-controlled.",scan:e=>{if(!G(e.relativePath)||pm.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=It({filename:e.absolutePath,sourceText:e.content,shouldAttachParentReferences:!1});if(r===null)return[];let i=[];return A(r,t=>{let n=hm(e.content,t);if(n===null||um.test(n)||fm(n,e.content))return;let r=mm(e.content,t),a=r.search(cm);if(a<0)return;let o=r.search(sm);if(o>=0&&(lm.test(r.slice(0,a))||o<a))return;let s=W(e.content,J(t));i.push({message:`A message event handler reads cross-window messages without an obvious origin check.`,line:s.line,column:s.column})}),i}}),_m=/(?:^|\/)(?:locales?|i18n|lang|langs|translations?)\//i,vm=/(?:^|\/)(?:\.env(?:\.[^/]*)?|(?:debug|crash|trace|stack[-_]?trace|report|dump|phpinfo)(?:[-_.][^/]*)?\.(?:txt|log|json|html?)|[^/]+\.log)$/i,ym=e=>Xc(e,Gc.test(e))&&!_m.test(e)&&vm.test(e),bm=U({id:`public-debug-artifact`,title:`Public debug artifact`,severity:`warn`,recommendation:`Remove debug artifacts from public output; logs and dumps often reveal source paths, internal routes, tokens, or environment snapshots.`,scan:e=>{if(!ym(e.relativePath))return[];let t={message:`A browser-reachable debug, log, dump, report, or env artifact is present.`,line:1,column:1};return[Nl.some(t=>t.test(e.content))?{...t,severity:`error`}:t]}}),xm=/(?:^|\/)docs?\//i,Sm=U({id:`public-env-secret-name`,title:`Secret-like public env variable`,severity:`warn`,recommendation:`Public env prefixes are inlined into browser bundles. Rename public values to non-secret names, and keep tokens, passwords, private keys, and service-role credentials server-only.`,scan:e=>{if(!Vf(e.relativePath)||xm.test(e.relativePath))return[];let t=su(e.content);if(t===void 0)return[];let n=Mc(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}]}}),Cm=`(?:"[^"\\n]{0,200}"|'[^'\\n]{0,200}'|\`[^\`$]{0,200}\`)`,wm=`\\s*\\(?\\s*(?:${Cm}|(?:[\\w\$]+(?:\\.[\\w\$]+)*\\.escape(?:Id|Literal|Identifier)|(?:[\\w\$]+\\.)*(?:connection|conn|client|pool|db|mysql|sqlstring|knex)\\.escape)\\s*\\([^()]{0,200}\\))\\s*\\)?`,Tm=U({id:`raw-sql-injection-risk`,title:`Raw SQL built outside parameter binding`,severity:`warn`,recommendation:`Keep user input in driver parameters or ORM bind variables. Avoid unsafe/raw SQL helpers and string interpolation for queries.`,scan:K({shouldScan:e=>Au(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*${Cm}(?:\\s*\\+${wm})*\\s*\\+(?!${wm})`,`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.`})}),Em=e=>Pc.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),Dm=e=>/(?:^|\/)\.env(?:\.[^./]+)*\.(?:example|sample|template|dist|defaults?)$|(?:^|\/)[^/]*(?:example|sample|template)[^/]*\.(?:env|json|pem|key)$/i.test(e),Om=U({id:`repository-secret-file`,title:`Secret file checked into repository`,severity:`error`,committedFilesOnly:!0,recommendation:`Remove committed env files, service-account credentials, npm auth tokens, and webhook URLs; rotate exposed values and keep only redacted examples in source.`,scan:e=>{if(!Em(e.relativePath)||Dm(e.relativePath)||zc.test(e.relativePath))return[];let t=Nl.find(t=>t.test(e.content))??su(e.content);if(t===void 0)return[];let n=Mc(e.content,t);return[{message:`A repository credential/config file contains secret-looking values.`,line:n.line,column:n.column}]}}),km=`(?:req|request|ctx\\.req|ctx\\.request)\\.(?:body|query|params)|await\\s+(?:req|request)\\.json\\(\\s*\\)`,Am=U({id:`request-body-mass-assignment`,title:`Request input spread without field allowlist`,severity:`warn`,recommendation:"Assign explicit, allowlisted fields (or validate with a strict schema and no `.passthrough()`) instead of spreading/merging request input. Otherwise the client can set ownership, role, or price columns (mass assignment) or pollute the prototype.",scan:K({shouldScan:e=>G(e.relativePath),pattern:[RegExp(`\\.\\.\\.\\s*(?:${km})`,`i`),RegExp(`(?:Object\\.assign\\s*\\(|_\\.(?:merge|mergeWith|defaultsDeep)\\s*\\(|(?:^|[^.\\w])(?:merge|defaultsDeep)\\s*\\()[\\s\\S]{0,80}?(?:${km})`,`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.`})}),jm=U({id:`secret-in-fallback`,title:`Hardcoded secret fallback for env var`,severity:`error`,recommendation:"Remove the literal fallback and fail closed (throw when the variable is unset). The hardcoded value is a committed secret, and the `??`/`||` default makes the app run with it in any environment that forgot to set the var.",scan:K({shouldScan:e=>G(e.relativePath),pattern:/\bprocess\.env\.(?!(?:(?:(?:NEXT|EXPO|GATSBY|NUXT|REACT_APP|VITE)_)?PUBLIC_[A-Z0-9_]*(?<!_SECRET)(?<!_PRIVATE_KEY)(?<!_PASSWORD)(?<!_PASSWD)|[A-Z0-9_]*(?:PUBLISHABLE|ANON)_KEY)(?![A-Z0-9_]))[A-Z][A-Z0-9_]*(?:SECRET|TOKEN|PASSWORD|PASSWD|PRIVATE_KEY|API_?KEY|APIKEY|ACCESS_KEY|CLIENT_SECRET|CREDENTIAL|SIGNING_KEY|ENCRYPTION_KEY|WEBHOOK_SECRET|SERVICE_ROLE)[A-Z0-9_]*(?<!_(?:NAME|HEADER|ENDPOINT|URL|URI|ID|PREFIX|SUFFIX|PARAM|PARAMS|FIELD|ISSUER|AUDIENCE|ALGORITHM|ALG|REGION|BUCKET|HOST|HOSTNAME|PORT|PATH|VERSION|SCOPE|TYPE|FORMAT|EXPIRY|TTL))\s*(?:\?\?|\|\|)\s*(["'`])(?![0-9]+["'`])(?![a-z][a-z0-9]*(?:[_-][a-z0-9]+)*[_-](?:token|secret|key|password|passwd|credential)s?["'`])(?![\w-]{0,12}0{8,}["'`])(?!test test test test test test test test test test test junk["'`])(?!(?:changeme|change[_-]?me|placeholder|your[_-]|example|sample|dummy|development|local|todo|replace[_-]?me|https?:\/\/|x{3,}|\*{3,}))[^"'`\n]{8,}\1/i,message:`A secret env var has a hardcoded string fallback: the literal is a committed secret and the app fails open (uses it) when the variable is unset.`})}),Mm=(e,t)=>{if(!S(e,`Program`))return!1;for(let n of e.body){if(!S(n,`ExpressionStatement`)||n.directive===void 0)return!1;if(n.directive===t)return!0}return!1},Nm=(e,t=`source.tsx`)=>{let n=It({filename:t,sourceText:e,shouldAttachParentReferences:!1});return n===null?!1:Mm(n,`use server`)},Pm=K({shouldScan:e=>Vf(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.`}),Fm=U({id:`supabase-client-owned-authz-field`,title:`Client writes Supabase authorization field`,severity:`error`,recommendation:"Use RLS policies based on `auth.uid()` and server-owned membership rows; do not trust client-provided owner, org, or role columns.",scan:e=>{let t=Pm(e);return t.length===0?t:Nm(e.content,e.relativePath)?[]:t}}),Im=e=>/(?:^|\/)supabase\/(?:migrations|schemas)\//.test(e),Lm=e=>e.endsWith(`.sql`)||Im(e),Rm=/^\$[A-Za-z_]?\w*\$/,zm=new Set([`do`,`plpgsql`,`sql`,`plpython3u`,`plpythonu`,`plperl`,`plperlu`,`plv8`]),Bm=(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()},Vm=(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]!==`
|
|
22
|
+
`&&(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]!==`
|
|
23
|
+
`;)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]!==`
|
|
24
|
+
`&&(t[i]=` `),i+=1}continue}i+=1}},Hm=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]!==`
|
|
25
|
+
`;)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]!==`
|
|
26
|
+
`&&(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]!==`
|
|
27
|
+
`&&(t[n]=` `),n+=1}continue}if(r===`$`){let r=Rm.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=Bm(e,n);if(zm.has(s))Vm(e,t,n+i.length,o);else for(let r=n;r<o;r+=1)e[r]!==`
|
|
28
|
+
`&&(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(``)},Um=/disable\s+row\s+level\s+security/i,Wm=/auth\.role\(\)\s*=\s*["']service_role["']/i,Gm=/create\s+policy/gi,Km=/;|create\s+policy/i,qm=/\b(?:using|with\s+check)\s*\(\s*true\s*\)/i,Jm=/\bfor\s+select\b/i,Ym=/\bto\s+([\s\S]+?)(?=\s+(?:using|with\s+check|as|for)\b|;|$)/i,Xm=new Set([`service_role`,`postgres`,`supabase_admin`]),Zm=e=>{let t=Ym.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=>Xm.has(e))},Qm=(e,t)=>Wm.test(t)?!0:!qm.test(e)||Jm.test(e)?!1:!Zm(e),$m=U({id:`supabase-rls-policy-risk`,title:`Permissive Supabase RLS policy`,severity:`error`,recommendation:"Keep public-read policies explicit, but gate inserts, updates, deletes, and service-role bypasses behind `auth.uid()` plus trusted tenant membership.",scan:e=>{if(!Lm(e.relativePath))return[];let t=Hm(e.content),n=t.search(Um);Gm.lastIndex=0;for(let r=Gm.exec(t);r!==null;r=Gm.exec(t)){let i=r.index+r[0].length,a=t.slice(i).search(Km),o=a<0?t.length:i+a;if(Qm(t.slice(r.index,o),e.content.slice(r.index,o))){(n<0||r.index<n)&&(n=r.index);break}}if(n<0)return[];let{line:r,column:i}=W(t,n);return[{message:`Supabase policy SQL disables RLS, permits writes broadly, or references a service-role bypass.`,line:r,column:i}]}}),eh=/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,th=/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,nh=/\benable\s+row\s+level\s+security\b/gi,rh=e=>{let t=new Map,n=0;for(let r of e.matchAll(th)){let e=r[1];e!==void 0&&(n+=1,t.set(e.toLowerCase(),r.index))}return{lastEnableIndexByTable:t,staticEnableCount:n}},ih=(e,t)=>(e.match(nh)?.length??0)>t,ah=U({id:`supabase-table-missing-rls`,title:`Supabase table created without Row Level Security`,severity:`error`,recommendation:"Enable RLS in the same migration (`alter table <name> enable row level security;`) and add `auth.uid()`-scoped policies for select/insert/update/delete. A public table without RLS is fully readable and writable with the public anon key.",scan:e=>{if(!Im(e.relativePath))return[];let t=Hm(e.content);if(!/create\s+(?:unlogged\s+)?table/i.test(t))return[];let n=[],{lastEnableIndexByTable:r,staticEnableCount:i}=rh(t);if(ih(t,i))return[];eh.lastIndex=0;for(let e=eh.exec(t);e!==null;e=eh.exec(t)){let i=e[1];if(i===void 0)continue;let a=r.get(i.toLowerCase());if(a!==void 0&&a>=e.index)continue;let o=W(t,e.index);n.push({message:`Supabase migration creates a public table but never enables Row Level Security, leaving every row exposed to the anon key.`,line:o.line,column:o.column})}return n}}),oh=U({id:`svg-filter-clickjacking-risk`,title:`SVG-filtered iframe clickjacking primitive`,severity:`warn`,recommendation:"Avoid filtering cross-origin iframes. Use `frame-ancestors` on sensitive pages and keep SVG filters away from embedded privileged UI.",scan:K({shouldScan:e=>G(e.relativePath),pattern:/<iframe\b(?:=>|[^>]){0,300}\bfilter\s*:\s*["']?url\(#|filter\s*:\s*url\(#[\s\S]{0,700}<iframe\b|<fe(?:DisplacementMap|ColorMatrix|Composite|Tile|Morphology)\b[\s\S]{0,700}<iframe\b/i,message:`An iframe is rendered through an SVG/CSS filter, which can support advanced clickjacking or visual exfiltration tricks.`})}),sh=e=>G(e)?Rc.test(e)?!0:/(?:^|\/)(?:middleware|route)\.[cm]?[jt]sx?$/.test(e):!1,ch=U({id:`tenant-static-proxy-risk`,title:`Tenant-controlled static asset proxy`,severity:`warn`,recommendation:`Bind tenant identity to the trusted host or authenticated org, canonicalize after decoding, reject traversal, and never let one tenant choose another tenant's asset prefix.`,scan:K({shouldScan:e=>sh(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.`})}),lh=[/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],uh=/\$\{|["'`]\s*\+\s*$/,dh=/^\s*\{(?!\{)/,fh=/"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'/g,ph=/\b(?:true|false|null)\b|[\d.]+(?:e[+-]?\d+)?/gi,mh=e=>{if(e.includes("`")||e.includes("${"))return!1;let t=e.replace(fh,``).replace(ph,``);return!/[A-Za-z_$]/.test(t)},hh=/^[\s)]*\.replace\s*\([^)]*(?:\\u003[cC]|<|<)/,gh=/(?:\b(?:escapeHtml|escapeJSON|escapeJson|htmlEscape|jsesc)|(?<![.\w])(?:serialize|serializeJavascript|devalue|uneval|superjson))\s*\(\s*$/i,_h=/\bJSON\.stringify\s*\($/i,vh=U({id:`unsafe-json-in-html`,title:`Unescaped JSON in HTML or script sink`,severity:`warn`,recommendation:'JSON.stringify does not HTML-escape, so a `<\/script>` (or `<`) in the data breaks out and becomes XSS. Use an HTML-safe serializer (serialize-javascript, devalue) or escape `<`, `>`, and `&`, or pass data via a JSON `<script type="application/json">` read with JSON.parse.',scan:e=>{if(!G(e.relativePath))return[];let t=gl(e);if(!t.includes(`JSON.stringify`))return[];let n=[],r=new Set;for(let[e,i]of lh.entries()){i.lastIndex=0;for(let a=i.exec(t);a!==null;a=i.exec(t)){let i=a[0].replace(_h,``);if(gh.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(!uh.test(r)||dh.test(r))continue}}let o=a.index+a[0].length-1,s=Ru(t,o);if(s>=0){let e=t.slice(s+1,s+1+160);if(hh.test(e)||mh(t.slice(o+1,s)))continue}if(r.has(a.index))continue;r.add(a.index);let c=W(t,a.index);n.push({message:"JSON.stringify is embedded in HTML/script markup without HTML-escaping; data containing `<\/script>` or `<` breaks out and becomes XSS.",line:c.line,column:c.column})}}return n}}),yh=/(?:(?<![.\w$])fetch|\baxios\.\s*(?:get|post|put|delete|head)|\bgot|\bgot\.\s*(?:get|post))\s*\(\s*([^,)]+)/,bh=/\b(?:url|targetUrl|callbackUrl|redirectUrl|webhookUrl|companyUrl|websiteUrl|domainUrl|imageUrl|fetchUrl|next|return_to|returnTo|destination|location)\b/i,xh=/\breq\.|\brequest\.(?:query|body|params|nextUrl)|\bsearchParams\b|\bparams\.|\bbody\.|\bquery\./,Sh=/\bredirect\s*:\s*["'](?:manual|error)["']/,Ch=/\b(params|body|query)\./g,wh=(e,t)=>RegExp(`(?:const|let|var)\\s+${e}\\s*(?::[^=;\\n]{0,80})?=\\s*new\\s+URLSearchParams\\b`).test(t),Th=(e,t)=>{let n=e.replace(Ch,(e,n)=>wh(n,t)?``:e);return xh.test(n)},Eh=(e,t)=>{if(Th(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)||Th(n,t))return!0}return!1},Dh=U({id:`untrusted-redirect-following`,title:`Server fetch follows redirects for caller-shaped URL`,severity:`warn`,recommendation:'Use `redirect: "manual"` or equivalent and re-validate every redirect target before following it to avoid SSRF redirect bypasses.',scan:e=>{if(!sh(e.relativePath)||!yh.test(e.content))return[];let t=[],n=e.content.split(`
|
|
29
|
+
`);for(let r=0;r<n.length;r+=1){let i=n[r]??``,a=i.match(yh),o=a?.[1]??``;if(!a||!bh.test(o)||!Eh(o,e.content))continue;let s=n.slice(r,r+5).join(`
|
|
30
|
+
`);Sh.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}}),Oh=U({id:`url-prefilled-privileged-action`,title:`URL pre-fills a privileged action`,severity:`warn`,recommendation:`Require server-side validation and explicit confirmation for URL-sourced invite, role, permission, redirect, or sharing parameters.`,scan:K({shouldScan:e=>Vf(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.`})}),kh=/(?:^|\/)[^/]*webhook[^/]*\/|(?:^|\/)[^/]*webhook[^/]*\.[cm]?[jt]s$|\bwebhook\b/i,Ah=/\b(?:export\s+(?:async\s+)?function\s+POST|export\s+const\s+(?:POST|handler|webhook)|webhookHandler|webhookRoute)\b/i,jh=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`),Mh=/webhook[\s_-]?ur[il]\w*/gi,Nh=/process\.env\.\w*WEBHOOK_URL|\b(?:send|post|dispatch|publish|notify)\w*Webhook/,Ph=/\b(?:req|request)\b/,Fh=/\/\/[^\n]*|\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\\n])*"|'(?:\\.|[^'\\\n])*'|`(?:\\.|[^`\\])*`/g,Ih=U({id:`webhook-signature-risk`,title:`Webhook handler lacks signature verification`,severity:`warn`,recommendation:`Verify provider signatures before parsing or acting on webhook bodies. Use provider SDK helpers or HMAC verification with timing-safe comparison.`,scan:K({shouldScan:e=>{if(!G(e.relativePath)||Nh.test(e.content))return!1;let t=e.content.replace(Fh,``).replace(Mh,``);return kh.test(e.relativePath)||kh.test(t)},pattern:Ah,requireAll:[Ph],suppressWhen:jh,message:`Webhook handler code does not show an obvious signature verification step.`})}),Lh=/\.[cm]?[jt]sx?$/i,Rh=/\.d\.[cm]?[jt]s$/i,zh=/\.mdx$/i,Bh=/\.html?$/i,Vh=new Set([`.angular`,`.astro`,`.cache`,`.contentlayer`,`.docusaurus`,`.expo`,`.git`,`.next`,`.nuxt`,`.output`,`.svelte-kit`,`.turbo`,`.vercel`,`build`,`coverage`,`dist`,`node_modules`,`out`,`storybook-static`]),Hh=new WeakMap,Uh=e=>{let t=Hh.get(e);if(t)return t;let n=Ne(e);return Hh.set(e,n),n},Wh=e=>{let t=[],n=[],a=[e],o=!1;for(;a.length>0;){let e=a.pop();if(!e)continue;let s;try{s=r.readdirSync(e,{withFileTypes:!0})}catch{return null}for(let r of s){let s=i.join(e,r.name),c=Vh.has(r.name)||r.name.startsWith(`.`)&&r.name!==`.dumi`&&r.name!==`.storybook`;if(!(r.isSymbolicLink()&&c)){if(r.isSymbolicLink())return null;if(r.isDirectory()){if(c)continue;a.push(s);continue}if(!(!r.isFile()||wc(s))){if(zh.test(r.name)){o=!0;continue}if(Bh.test(r.name)){n.push(Li(s));continue}Lh.test(r.name)&&(Rh.test(r.name)||t.push(Li(s)))}}}}return{sourceFilePaths:t,htmlFilePaths:n,hasOpaqueMdxConsumerSurface:o}},Gh=(e,t)=>{for(let n of e){let e;try{e=r.readFileSync(n,`utf8`)}catch{return!0}for(let n of t)if(e.includes(`"${n}"`)||e.includes(`'${n}'`))return!0}return!1},Kh=e=>{if(S(e,`ImportDeclaration`))return oc(e)?null:typeof e.source.value==`string`?e.source.value:null;if(S(e,`ExportNamedDeclaration`))return e.exportKind===`type`||ac(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},qh=(e,t,n,r)=>{A(e.programNode,i=>{let a=Kh(i);if(!a)return;let o=Cn(e.filePath,a);if(!o){r.add(a);return}let s=Li(o);n.set(i,s);let c=t.get(s)??new Set;c.add(e),t.set(s,c)})},Jh=({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=Wh(e);if(!o||i.length>0&&a===void 0&&!Gh(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=Rt(e);if(!i||!S(i,`Program`))return null;s.set(e,{filePath:e,programNode:i,scopes:Uh(i)})}let c=new Map,l=new WeakMap,u=new Set;for(let e of s.values())qh(e,c,l,u);return{modulesByFilePath:s,htmlFilePaths:o.htmlFilePaths,consumerModulesByFilePath:c,resolvedSourcePathByNode:l,unresolvedRuntimeSources:u,hasOpaqueMdxConsumerSurface:o.hasOpaqueMdxConsumerSurface}},Yh=e=>{if(!e)return null;let t=O(e);return!S(t,`Literal`)||typeof t.value!=`boolean`?null:t.value},Xh=(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=O(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=Sa(n);if(e===null){if(a)continue;return null}o.push(e);continue}if(S(n,`ConditionalExpression`)){let t=i?Yh(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},Zh=(e,t,n={})=>Xh(e,t,n),Qh=(e,t)=>Xh(e,t,{shouldKeepKnownValues:!0}),$h=(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`)?Zh(a.expression,t,{maximumConstAliases:n,shouldFoldStaticConditions:r,shouldKeepKnownValues:i}):null:null},eg=(e,t)=>$h(e,t,4,!1),tg=(e,t)=>$h(e,t,null,!0),ng=(e,t)=>$h(e,t,4,!1,!0),rg=(e,t)=>{let n=i.relative(t,e);return n===``||!n.startsWith(`..${i.sep}`)&&n!==`..`&&!i.isAbsolute(n)},ig={attribute:null,expression:null,isPresent:!1,isUnknown:!1},ag={attribute:null,expression:null,isPresent:!1,isUnknown:!0},og=(e,t,n)=>{for(let r=e.properties.length-1;r>=0;--r){let i=e.properties[r];if(!i)return ag;if(S(i,`SpreadElement`)){if(!S(i.argument,`ObjectExpression`))return ag;let e=og(i.argument,t,n);if(e.isPresent||e.isUnknown)return e;continue}if(!S(i,`Property`))return ag;let a=N(i,{allowComputedString:!0});if(!a)return ag;if((n?a:a.toLowerCase())===t)return{attribute:null,expression:i.value,isPresent:!0,isUnknown:!1}}return ig},sg=(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 ag;if(S(i,`JSXSpreadAttribute`)){if(!S(i.argument,`ObjectExpression`))return ag;let e=og(i.argument,r,n);if(e.isPresent||e.isUnknown)return e;continue}if(!S(i,`JSXAttribute`))continue;let a=ko(i.name);if((n?a:a?.toLowerCase())===r)return{attribute:i,expression:null,isPresent:!0,isUnknown:!1}}return ig},cg=/(?<attributeName>[^\s"'<>/=]+)(?:\s*=\s*(?:"(?<doubleQuoted>[^"]*)"|'(?<singleQuoted>[^']*)'|(?<unquoted>[^\s"'=<>`]+)))?/g,lg=/<!--[\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,ug=new Map,dg=(e,t,n)=>{if(!e.isPresent)return;let r=e.attribute?ng(e.attribute,t):e.expression?Qh(e.expression,t):null;for(let e of r??[]){let t=e?.trim();t&&n.add(t)}},fg=(e,t,n)=>{for(let r of e.properties){if(S(r,`SpreadElement`)){S(r.argument,`ObjectExpression`)&&fg(r.argument,t,n);continue}if(S(r,`Property`)&&N(r,{allowComputedString:!0})?.toLowerCase()===`id`)for(let e of Qh(r.value,t)??[]){let t=e.trim();t&&n.add(t)}}},pg=e=>{let t=e.parent;for(S(t,`JSXElement`)&&t.openingElement===e&&(t=t.parent);t;){if(S(t,`JSXElement`)&&Ko(t.openingElement)===`template`)return!0;t=t.parent}return!1},mg=(e,t,n)=>{A(e,e=>{if(!S(e,`JSXOpeningElement`)||pg(e))return;let r=sg(e.attributes,`id`,!1);if(r.isUnknown){for(let r of e.attributes)dg(sg([r],`id`,!1),t,n),S(r,`JSXSpreadAttribute`)&&S(r.argument,`ObjectExpression`)&&fg(r.argument,t,n);return}dg(r,t,n)})},hg=(e,t)=>{for(let n of e.matchAll(lg)){let e=n.groups?.skippedContentOpeningTag??n.groups?.openingTag;if(e)for(let n of e.matchAll(cg)){if(n.groups?.attributeName?.toLowerCase()!==`id`)continue;let e=n.groups?.doubleQuoted??n.groups?.singleQuoted??n.groups?.unquoted??``;e.trim()&&t.add(e.trim())}}},gg=e=>{if(!i.isAbsolute(e.currentFilePath))return null;let t=e.configuredRootDirectory?Li(e.configuredRootDirectory):null;return!t||!rg(e.currentFilePath,t)?null:t},_g=()=>{ug.clear()},vg=e=>{let t=new Set;mg(e.currentProgramNode,e.currentScopes,t);let n=gg(e);if(!n)return t;if(ug.has(n)){let e=ug.get(n);return e?new Set([...e,...t]):null}let i=Jh({rootDirectory:n,currentFilePath:Li(e.currentFilePath),currentProgramNode:e.currentProgramNode,currentScopes:e.currentScopes});if(!i)return ug.set(n,null),null;let a=new Set;for(let e of i.modulesByFilePath.values())mg(e.programNode,e.scopes,a);try{for(let e of i.htmlFilePaths)hg(r.readFileSync(e,`utf8`),a)}catch{return ug.set(n,null),null}return ug.set(n,a),new Set([...a,...t])},yg=()=>{Tn(),ht(),sn(),_g(),Sn()},bg=e=>Nc.test(e)||Pc.test(e),xg=e=>{let t=Gc.test(e);return Em(e)||Lm(e)||il(e)||Zc(e)?{bucket:`priority`,isGeneratedBundleByName:t}:Xc(e,t)?{bucket:`artifact`,isGeneratedBundleByName:t}:bg(e)?{bucket:`other`,isGeneratedBundleByName:t}:null},Sg=(e,t)=>t||bg(e)||Zc(e)||Em(e),Cg=[`nextjs`,`astro`,`vite`,`cra`,`remix`,`gatsby`,`expo`,`react-native`,`tanstack-start`,`preact`,`unknown`];export{Bu as $,b as $i,vi as $n,Kn as $r,$o as $t,$p as A,tt as Ai,la as An,Kr as Ar,eu as At,ip as B,Ve as Bi,Ui as Bn,Mr as Br,rl as Bt,Am as C,o as Ca,lt as Ci,R as Cn,ni as Cr,Xl as Ct,bm as D,et as Di,ga as Dn,ii as Dr,$l as Dt,Sm as E,st as Ei,ha as En,ti as Er,au as Et,Up as F,Ze as Fi,Zi as Fn,Jr as Fr,Kl as Ft,Bf as G,We as Gi,Li as Gn,Ir as Gr,mc as Gt,Gf as H,Qe as Hi,F as Hn,Pr as Hr,Dc as Ht,Hp as I,Ue as Ii,qi as In,Vr as Ir,Vl as It,sd as J,Ne as Ji,Mi as Jn,Sr as Jr,ic as Jt,vd as K,Ge as Ki,Ai as Kn,Fr as Kr,ac as Kt,Bp as L,Be as Li,Xi as Ln,Hr as Lr,Wl as Lt,Xp as M,Ke as Mi,ea as Mn,Rr as Mr,ql as Mt,Yp as N,Je as Ni,$i as Nn,zr as Nr,nu as Nt,gm as O,nt as Oi,L as On,Br as Or,Yl as Ot,Jp as P,Ye as Pi,Qi as Pn,Wr as Pr,Gl as Pt,Vu as Q,x as Qi,ui as Qn,qn as Qr,Fs as Qt,Lp as R,ze as Ri,Ji as Rn,Ur as Rr,xl as Rt,jm as S,s as Sa,D as Si,wa as Sn,ri as Sr,iu as St,Tm as T,at as Ti,_a as Tn,mi as Tr,Ul as Tt,Wf as U,Ie as Ui,Vi as Un,Nr as Ur,wc as Ut,Zf as V,Fe as Vi,I as Vn,Ar as Vr,U as Vt,Uf as W,Le as Wi,Bi as Wn,Lr as Wr,Tc as Wt,Ku as X,fe as Xi,N as Xn,M as Xr,nc as Xt,Gu as Y,Pe as Yi,P as Yn,cr as Yr,tc as Yt,Wu as Z,S as Zi,_i as Zn,Jn as Zr,rc as Zt,oh as _,u as _a,Tt as _i,so as _n,Ti as _r,Bl as _t,vg as a,v as aa,Dn as ai,Ho as an,Ci as ar,vu as at,Fm as b,c as ba,_t as bi,lo as bn,di as br,ru as bt,tg as c,ae as ca,Cn as ci,Oo as cn,yi as cr,Sl as ct,Jh as d,ce as da,Mt as di,uo as dn,si as dr,Dl as dt,de as ea,j as ei,Yo as en,hi as er,J as et,Ih as f,g as fa,jt as fi,B as fn,li as fr,wl as ft,ch as g,d as ga,Ot as gi,oo as gn,fi as gr,Al as gt,vh as h,ee as ha,O as hi,co as hn,Qr as hr,kl as ht,yg as i,oe as ia,kn as ii,Uo as in,Si as ir,Du as it,Qp as j,He as ji,ta as jn,Gr as jr,tu as jt,om as k,$e as ki,ua as kn,qr as kr,Jl as kt,eg as l,ne as la,on as li,To as ln,ei as lr,El as lt,Dh as m,p as ma,kt as mi,io as mn,Yr as mr,Cl as mt,xg as n,le as na,An as ni,qo as nn,ci as nr,Iu as nt,sg as o,se as oa,On as oi,Mo as on,bi as or,_u as ot,Oh as p,m as pa,At as pi,fo as pn,oi as pr,Ol as pt,_d as q,Xe as qi,Fi as qn,kr as qr,oc as qt,Sg as r,ie as ra,A as ri,Ko as rn,wi as rr,Ou as rt,rg as s,te as sa,k as si,ko as sn,xi as sr,Tl as st,Cg as t,ue as ta,Wn as ti,Jo as tn,pi as tr,Lu as tt,Yh as u,re as ua,Rt as ui,po as un,gi as ur,jl as ut,ah as v,f as va,Et as vi,ro as vn,Zr as vr,Ql as vt,Om as w,it as wi,Sa as wn,$r as wr,Ml as wt,Mm as x,l as xa,vt as xi,Ia as xn,Xr as xr,Hl as xt,$m as y,h as ya,gt as yi,ao as yn,ai as yr,Zl as yt,Ep as z,qe as zi,Yi as zn,jr as zr,bl as zt};
|
|
31
|
+
//# sourceMappingURL=capability-DSccjvGM.js.map
|