path = r"plugins\core.image-interrogate\ui\src\ImageInterrogateView.tsx"

with open(path, "r", encoding="utf-8") as f:
    lines = f.readlines()

print("Total lines:", len(lines))

# We want to identify all function, state, and variable declarations
# and check if they are present in lines 1-1680 (0-indexed: 0-1679)
# and also if they are present in lines 1681-2144 (0-indexed: 1680-2143).
top_decls = []
mid_decls = []

for i, line in enumerate(lines):
    line_strip = line.strip()
    if any(k in line_strip for k in ["const [", "function ", "const handle", "async function"]):
        if len(line_strip) < 120:
            if i < 1680:
                top_decls.append((i+1, line_strip))
            elif i >= 1680 and i < 2144:
                mid_decls.append((i+1, line_strip))

print("\n--- Declarations in top region (1 to 1680) ---")
for line_num, decl in top_decls[:40]:
    print(f"Line {line_num}: {decl}")
if len(top_decls) > 40:
    print(f"... and {len(top_decls) - 40} more")

print("\n--- Declarations in duplicate region (1681 to 2144) ---")
for line_num, decl in mid_decls:
    print(f"Line {line_num}: {decl}")
