refactor: split popup.js into proper modules