er.currentNodeId++;
  jsonInput.value = JSON.stringify(builder.build(), null, 2);
 } catch (error) {
  console.error(JSON.stringify({
   type: 'error',
   message: error.message,
   stack: error.stack
  }, null, 2));
 }
}

function downloadJson() {
 const content = jsonInput.value;
 const blob = new Blob([content], { type: 'application/json' });
 const url = URL.createObjectURL(blob);
 const a = document.createElement('a');
 a.href = url;
 a.download = 'workflow.json';
 document.body.appendChild(a);
 a.clic