`;
const close = () => {
overlay.remove();
this._settingsModalOpen = false;
};
overlay.addEventListener('click', (event) => {
if (event.target === overlay) close();
});
const $ = (role) => overlay.querySelector(`[data-role="${role}"]`);
// Pre-fill from current settings
Promise.all([
this.context.settings.get('provider'),
this.context.settings.get('model'),
this.context.settings.get('baseUrl'),
this.context.settings.get('apiKey'),
this.context.settings.get('temperature'),
]).then(([provider, model, baseUrl, apiKey, temperature]) => {
if (provider) $('provider').value = provider;
if (model) $('model').value = model;
if (baseUrl) $('baseUrl').value = baseUrl;
if (apiKey) $('apiKey').value = apiKey;
if (temperature !== undefined && temperature !== null) {
$('temperature').value = temperature;
}
});
$('cancel').addEventListener('click', close);
$('save').addEventListener('click', async () => {
await this.context.settings.set('provider', $('provider').value);
await this.context.settings.set('model', $('model').value.trim());
await this.context.settings.set('baseUrl', $('baseUrl').value.trim());
await this.context.settings.set('apiKey', $('apiKey').value.trim());
await this.context.settings.set('temperature', parseFloat($('temperature').value) || 0.7);
await this._refreshStatus();
close();
});
document.body.appendChild(overlay);
}
deactivate() {
/* no long-lived timers to clean up */
}
}
module.exports = { Plugin: AiAssistantPlugin };