{t('actions.rules')} ({rules.length})
{ showAddForm = !showAddForm; if (showAddForm) resetNewRule(); }} class="text-xs px-2 py-1 bg-[var(--color-primary)] text-[var(--color-primary-foreground)] rounded hover:opacity-90"> {showAddForm ? t('common.cancel') : t('actions.addRule')}
{#if loading}
{t('common.loading')}...
{/if} {#if showAddForm}
{t('actions.ruleName')}
{#if actionType === 'auto_organize'} {@render criteriaFields(newRule.rule_config)} {/if}
{submitting ? t('common.loading') : t('actions.addRule')}
{/if} {#each rules as rule}
expandedRule = expandedRule === rule.id ? null : rule.id} class="flex items-center gap-2 text-sm font-medium text-left flex-1">
{rule.name || t('actions.unnamedRule')}
toggleRule(rule)} class="text-xs px-1.5 py-0.5 rounded {rule.enabled ? 'bg-green-100 text-green-800' : 'bg-gray-100 text-gray-600'}"> {rule.enabled ? t('actions.on') : t('actions.off')}
deleteRule(rule.id)} variant="danger" size={16} />
{#if expandedRule === rule.id}
{t('actions.ruleName')}
{#if actionType === 'auto_organize'} {@render criteriaFields(rule.rule_config)} {/if}
updateRule(rule)} class="text-xs px-3 py-1.5 bg-[var(--color-primary)] text-[var(--color-primary-foreground)] rounded hover:opacity-90"> {t('common.save')}
{/if}
{/each} {#if rules.length === 0 && !loading && !showAddForm}
{t('actions.noRules')}
{/if}
{#snippet criteriaFields(ruleConfig: any)}
{t('actions.criteria')}
{#if personItems.length > 0}
{t('actions.persons')}
{ ruleConfig.criteria.person_names = ids.map(id => people.find(p => p.id === id)?.name || id); }} />
{/if}
{t('actions.searchQuery')}
{t('actions.assetType')}:
{#each ['all', 'image', 'video'] as at}
{ ruleConfig.criteria.asset_type = at; }} class="accent-[var(--color-primary)]" /> {at}
{/each}
{t('actions.dateFrom')}
{t('actions.dateTo')}
{t('actions.favoritesOnly')}
{t('actions.targetAlbum')}
{#if albumItems.length > 0}
{t('actions.selectAlbum')}
{ ruleConfig.target_album_names = ids.map(id => albums.find(a => a.id === id)?.name || id); }} />
{:else}
{t('actions.albumId')}
{/if}
{t('actions.createAlbumIfMissing')}
{#if ruleConfig.create_album_if_missing}
{t('actions.newAlbumName')}
{/if}
{/snippet}