Please do not use ChatGPT to transcribe any code, it's harmful.
For example here you can see how it scattered catch {} everywhere instead of using idiomatic try for cases where you do not want to explictely handle errors.
catch {} means "i don't care if this failed, let's just continue as if nothing happened".
The unnescessary use of optionals makes the code more complex and offsets some problems to runtime.
Unlearning is harder than learning from scratch. Please browse language reference, checkout ziglings and other zig tutorials