///|
fn status_class(value : String) -> String {
  if value.contains("block") || value.contains("gated") {
    "is-blocked"
  } else if value.contains("review") || value.contains("caution") {
    "is-review"
  } else {
    "is-ready"
  }
}

///|
fn layer_nav(view : TrustedSquareViewModel) -> String {
  let mut html = ""
  for layer in view.layers {
    let active = if layer.layer_id == view.active_layer_id {
      " active"
    } else {
      ""
    }
    let row =
      $|
    html += row
  }
  html
}

///|
fn terrain_grid(view : TrustedSquareViewModel) -> String {
  let mut html = ""
  for cell in view.terrain_cells {
    let selected = if cell.selected { " selected" } else { "" }
    let row =
      $|
    html += row
  }
  html
}

///|
fn route_list(view : TrustedSquareViewModel) -> String {
  let mut html = ""
  for route in view.routes {
    let selected = if route.selected { " selected" } else { "" }
    let row =
      $|
\{html_escape(route.label)}\{html_escape(route.route_id)}
\{html_escape(route.decision)}
html += row } html } ///| fn fact_list(view : TrustedSquareViewModel) -> String { let mut html = "" for fact in view.inspector_facts { let row = $|
\{html_escape(fact.label)}\{html_escape(fact.evidence_path)}
\{html_escape(fact.value)}
html += row } html } ///| fn blocker_list(view : TrustedSquareViewModel) -> String { if view.blockers.is_empty() { "
  • none
  • " } else { let mut html = "" for blocker in view.blockers { let row = $|
  • \{html_escape(blocker)}
  • html += row } html } } ///| fn motion_contract_panel(contract : TraverseMotionContract) -> String { let html = $|

    motion contract

    \{html_escape(contract.preview_kind)}\{html_escape(contract.contract_id)}
    \{html_escape(contract.status)}
    physics core\{html_escape(contract.physics_core_package)}
    generic
    motion owner\{html_escape(contract.motion_owner_package)}
    \{html_escape(contract.gait_asset_status)}
    simulation\{html_escape(contract.next_action)}
    \{html_escape(contract.simulation_status)}
    html } ///| fn app_styles() -> String { let css = #| css } ///| pub fn render_html(view : TrustedSquareViewModel) -> String { let title = html_escape(view.title) let decision = html_escape(view.scorecard.decision) let next_action = html_escape(view.scorecard.next_action) let source_title = html_escape(view.source_panel.source_title) let source_path = html_escape(view.source_panel.local_source_path) let source_catalog_path = html_escape(view.source_panel.catalog_manifest_path) let source_authority = html_escape(view.source_panel.authority) let source_review = html_escape(view.source_panel.review_status) let view_json = render_json(view).stringify(indent=2) let motion_contract = traverse_motion_contract(view) let motion_contract_json = motion_contract.to_json().stringify(indent=2) let html = $| $| $| $| $| $|MoonMoon - \{title} $|\{app_styles()} $| $| $| $| $|
    $|
    $|

    \{title}

    \{next_action}

    mission \{decision}
    $|
    \{moon_view_panel(view)}
    score\{view.scorecard.score}
    route candidates\{view.scorecard.route_candidates}
    blocked routes\{view.scorecard.blocked_route_candidates}
    energy margin Wh\{view.scorecard.energy_margin_wh}
    $| $|
    \{terrain_grid(view)}
    $|
    $| $|
    $|\{moon_globe_script()} $| $| html } ///| pub fn first_trusted_square_html() -> String { render_html(first_trusted_square_view_model()) } ///| pub fn first_trusted_square_catalog_html( root : String, ) -> Result[String, CatalogBackedViewIssue] { let view = match first_trusted_square_view_model_from_catalog_root(root) { Ok(value) => value Err(error) => return Err(error) } Ok(render_html(view)) }