| 3807 | }; |
| 3808 | |
| 3809 | const ensureSourceOption = (id, label = '') => { |
| 3810 | const sourceId = String(id || '').trim(); |
| 3811 | if (!sourceId) return; |
| 3812 | const existing = (state.sourceOptions || []).find((s) => String(s.id || '') === sourceId); |
| 3813 | if (existing) return; |
| 3814 | const sourceLabel = String(label || sourceId); |
| 3815 | state.sourceOptions = [...(state.sourceOptions || []), { id: sourceId, label: sourceLabel }]; |
| 3816 | }; |
| 3817 | |
| 3818 | const renderSourceOptions = (preferredId = '') => { |
| 3819 | if (!sourceIdEl) return; |