<?php if(isset($publicationBoard) && $publicationBoard->channels !== []): ?>
    <section aria-label="Publicação" class="rounded-xl border border-slate-200 bg-white p-6 shadow-sm">
        <div class="flex flex-wrap items-start justify-between gap-3">
            <div>
                <h2 class="text-sm font-semibold uppercase tracking-wide text-slate-500">Publicação</h2>
                <p class="mt-1 text-sm text-slate-600">Cadastre uma vez e acompanhe cada canal.</p>
            </div>

            <?php if($publicationBoard->hasPublishedChannels()): ?>
                <form method="POST" action="<?php echo e(route('publishing.channels.sync', $property)); ?>">
                    <?php echo csrf_field(); ?>
                    <button
                        type="submit"
                        class="rounded-lg border border-slate-300 px-3 py-1.5 text-sm font-medium text-slate-700 hover:bg-slate-50"
                    >
                        Sincronizar publicados
                    </button>
                </form>
            <?php endif; ?>
        </div>

        <ul class="mt-5 space-y-3">
            <?php $__currentLoopData = $publicationBoard->channels; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $channel): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <li class="rounded-lg border border-slate-100 bg-slate-50/60 p-4">
                    <div class="flex flex-wrap items-start justify-between gap-3">
                        <div class="min-w-0 flex-1">
                            <p class="font-medium text-slate-900"><?php echo e($channel->publisherName); ?></p>
                            <?php if($channel->publisherDescription): ?>
                                <p class="mt-0.5 text-sm text-slate-500"><?php echo e($channel->publisherDescription); ?></p>
                            <?php endif; ?>

                            <?php if($channel->lastError && $channel->status->value === 'failed'): ?>
                                <p class="mt-2 text-sm text-red-700"><?php echo e($channel->lastError); ?></p>
                            <?php endif; ?>

                            <?php if($channel->lastSyncedAtLabel()): ?>
                                <p class="mt-2 text-xs text-slate-500">Última sincronização: <?php echo e($channel->lastSyncedAtLabel()); ?></p>
                            <?php endif; ?>
                        </div>

                        <div class="flex flex-wrap items-center gap-2">
                            <?php echo $__env->make('properties.partials.publication-status-badge', ['channel' => $channel], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

                            <?php if($channel->externalUrl): ?>
                                <a
                                    href="<?php echo e($channel->externalUrl); ?>"
                                    target="_blank"
                                    rel="noopener noreferrer"
                                    class="rounded-lg border border-slate-300 px-3 py-1.5 text-sm text-slate-700 hover:bg-white"
                                >
                                    Abrir
                                </a>
                            <?php endif; ?>

                            <?php if($channel->canPublish): ?>
                                <form method="POST" action="<?php echo e(route('publishing.channels.publish', [$property, $channel->publisherId])); ?>">
                                    <?php echo csrf_field(); ?>
                                    <button
                                        type="submit"
                                        class="rounded-lg bg-emerald-600 px-3 py-1.5 text-sm font-semibold text-white hover:bg-emerald-500"
                                    >
                                        Publicar
                                    </button>
                                </form>
                            <?php elseif($channel->canSync): ?>
                                <form method="POST" action="<?php echo e(route('publishing.channels.publish', [$property, $channel->publisherId])); ?>">
                                    <?php echo csrf_field(); ?>
                                    <button
                                        type="submit"
                                        class="rounded-lg border border-emerald-200 px-3 py-1.5 text-sm font-medium text-emerald-800 hover:bg-emerald-50"
                                    >
                                        Atualizar
                                    </button>
                                </form>
                            <?php endif; ?>
                        </div>
                    </div>
                </li>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </ul>
    </section>
<?php endif; ?>
<?php /**PATH /var/www/html/backend/resources/views/properties/partials/publication-board.blade.php ENDPATH**/ ?>