docstr: Configure JupyterChart's offline behavior
  
  Parameters
  ----------
  offline: bool
      If True, configure JupyterChart to operate in offline mode where JavaScript
      dependencies are loaded from vl-convert.
      If False, configure it to operate in online mode where JavaScript dependencies
      are loaded from CDN dynamically. This is the default behavior.
docstr_tok: ["Configure","JupyterChart","'s","offline","behavior","Parameters","--","--","--","--","--","offline",":","bool","If","True",",","configure","JupyterChart","to","operate","in","offline","mode","where","JavaScript","dependencies","are","loaded","from","vl-convert",".","If","False",",","configure","it","to","operate","in","online","mode","where","JavaScript","dependencies","are","loaded","from","CDN","dynamically",".","This","is","the","default","behavior","."]
code: def enable_offline(cls, offline: bool = True):
      """
      Configure JupyterChart's offline behavior
  
      Parameters
      ----------
      offline: bool
          If True, configure JupyterChart to operate in offline mode where JavaScript
          dependencies are loaded from vl-convert.
          If False, configure it to operate in online mode where JavaScript dependencies
          are loaded from CDN dynamically. This is the default behavior.
      """
      from altair.utils._importers import (
          import_vl_convert,
          vl_version_for_vl_convert,
      )
  
      if offline:
          if cls._is_offline:
              # Already offline
              return
  
          vlc = import_vl_convert()
  
          src_lines = load_js_src().split("\n")
  
          # Remove leading lines with only whitespace, comments, or imports
          while src_lines and (
              len(src_lines[0].strip()) == 0
              or src_lines[0].startswith("import")
              or src_lines[0].startswith("//")
          ):
              src_lines.pop(0)
  
          src = "\n".join(src_lines)
  
          # vl-convert's javascript_bundle function creates a self-contained JavaScript bundle
          # for JavaScript snippets that import from a small set of dependencies that
          # vl-convert includes. To see the available imports and their imported names, run
          #       import vl_convert as vlc
          #       help(vlc.javascript_bundle)
          bundled_src = vlc.javascript_bundle(
              src, vl_version=vl_version_for_vl_convert()
          )
          cls._esm = bundled_src
          cls._is_offline = True
      else:
          cls._esm = load_js_src()
          cls._is_offline = False
  
imports: import json
  import anywidget
  import traitlets
  import pathlib
  from typing import Any, Set, Optional
  import altair
  from altair.utils._vegafusion_data import using_vegafusion, compile_to_vegafusion_chart_state
  from altair import TopLevelSpec
  from altair.utils.selection import IndexSelection, PointSelection, IntervalSelection
label_desc: Use image node_id 1 for calling the JupyterChart obj's underlying member method code with example usage: obj.enable_offline(cls, offline) without return types