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