import { api } from '../../lib/api.mjs';
const PRIORITIES = ['low', 'normal', 'high', 'urgent'];
class ProfileForm extends HTMLElement {
#onSave = null;
connectedCallback() {
if (!this.shadowRoot) {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = ``;
}
}
open(profile, onSave) {
this.#onSave = onSave;
const isEdit = !!profile;
const d = this.shadowRoot.querySelector('dialog');
d.innerHTML = `
${isEdit ? `
Active
` : ''}
Default Steps
${(profile?.steps || []).length === 0
? '
No steps yet — add steps below
'
: (profile?.steps || []).map((s, i) => this.#stepRowHTML(s, i)).join('')}
`;
if (window.lucide) lucide.createIcons({ root: d });
// Local step state (not saved until the profile save)
const profileId = profile?.id || null;
let pendingSteps = (profile?.steps || []).map(s => ({ ...s }));
const renderSteps = () => {
const list = d.querySelector('#step-list');
const empty = pendingSteps.length === 0;
list.innerHTML = empty
? '