$pagePath = "C:\Users\a931627\Documents\stadtwerke-saas-analysis\innungsapp\apps\admin\.next\server\app\superadmin\page.js" $outPath = "C:\Users\a931627\Documents\stadtwerke-saas-analysis\innungsapp\apps\admin\app\superadmin\actions.ts" $text = Get-Content -Raw $pagePath $sourceMarker = "sourceURL=webpack-internal:///(ssr)/./app/superadmin/actions.ts" $idxSource = $text.IndexOf($sourceMarker) if ($idxSource -lt 0) { throw 'sourceURL marker not found' } $mapPrefix = "sourceMappingURL=data:application/json;charset=utf-8;base64," $idxMapStart = $text.LastIndexOf($mapPrefix, $idxSource) if ($idxMapStart -lt 0) { throw 'source map prefix not found' } $endMarker = "\\n//# sourceURL=webpack-internal:///(ssr)/./app/superadmin/actions.ts" $idxMapEnd = $text.IndexOf($endMarker, $idxMapStart) if ($idxMapEnd -lt 0) { throw 'source map end marker not found' } $base64Start = $idxMapStart + $mapPrefix.Length $base64 = $text.Substring($base64Start, $idxMapEnd - $base64Start) $json = [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($base64)) $map = $json | ConvertFrom-Json if (-not $map.sourcesContent -or $map.sourcesContent.Count -lt 1) { throw 'No sourcesContent in map payload' } $source = $map.sourcesContent[0] [System.IO.File]::WriteAllText($outPath, $source, [System.Text.UTF8Encoding]::new($false)) Write-Host 'Recovered actions.ts from source map payload'