extends VBoxContainer const Brand := preload("res://scripts/ui/medmind_style.gd") const Builder := preload("res://scripts/ui/legal_document_builder.gd") var main: Control var document_content: VBoxContainer var consent: CheckBox var accept_button: Button var status: Label func _ready() -> void: set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) add_theme_constant_override("separation", 14) var tabs := HBoxContainer.new() add_child(tabs) for kind in ["terms", "privacy"]: var button := Button.new() button.text = "Terms of Service" if kind == "terms" else "Privacy Policy" button.pressed.connect(_show_document.bind(kind)) tabs.add_child(button) var scroll := ScrollContainer.new() scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED add_child(scroll) document_content = VBoxContainer.new() document_content.size_flags_horizontal = Control.SIZE_EXPAND_FILL document_content.add_theme_constant_override("separation", 14) scroll.add_child(document_content) consent = CheckBox.new() consent.text = "I agree to the Terms of Service and acknowledge the Privacy Policy." consent.toggled.connect(func(enabled: bool): accept_button.disabled = not enabled) add_child(consent) status = Label.new() status.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART add_child(status) var actions := HBoxContainer.new() actions.alignment = BoxContainer.ALIGNMENT_END add_child(actions) var logout := Button.new() logout.text = "Log out" logout.pressed.connect(_logout) actions.add_child(logout) accept_button = Button.new() accept_button.text = "Agree and continue" accept_button.disabled = true accept_button.pressed.connect(_accept) actions.add_child(accept_button) LegalService.acceptance_succeeded.connect(_on_accepted) LegalService.acceptance_failed.connect(_on_failed) _show_document("terms") func on_show(_payload: Variant = null) -> void: consent.set_pressed_no_signal(false) accept_button.disabled = true status.text = "" func _show_document(kind: String) -> void: Builder.populate(document_content, LegalService.get_document(kind)) func _accept() -> void: accept_button.disabled = true status.text = "Saving your agreement..." LegalService.accept_current() func _on_accepted() -> void: status.text = "" main.show_screen("dashboard") func _on_failed(message: String) -> void: status.text = message accept_button.disabled = not consent.button_pressed func _logout() -> void: AuthState.clear_session() main.show_screen("login")