Storing large web app state in URL using pako

How to store and share complex application state in URLs using pako compression, discovered from Mermaid Live Editor's approach to making diagrams shareable.