public import AppKit @MainActor public enum StackCloseConfirmation { public static func alert(title: String, edited: Bool?) -> NSAlert { let alert = NSAlert() alert.alertStyle = .warning alert.messageText = String(format: UIStrings.text("Close “%@”?"), title) alert.informativeText = UIStrings.text( edited == true ? "This window has unsaved changes. Its app will ask what to save before closing." : edited == false ? "This window has no reported unsaved changes." : "This app doesn't report unsaved changes. It will handle saving when you close the window.") alert.addButton(withTitle: UIStrings.text("Keep Open")) alert.addButton(withTitle: UIStrings.text("Close Window")) return alert } public static func confirm(title: String, edited: Bool?) -> Bool { guard edited != false else { return true } NSApplication.shared.activate() return alert(title: title, edited: edited).runModal() == .alertSecondButtonReturn } }