<div>
    <div class="row">
        <div class="col-md-12 grid-margin stretch-card">
            <div class="card">
                <div class="card-header m-0">
                    <div class="d-flex align-items-center justify-content-between">
                        <h4 class="card-title m-0">Procesos Registrados</h4>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('procesos.create')): ?>
                            <a href="<?php echo e(route('procesos.create')); ?>" class="btn btn-primary">
                                Nuevo Proceso
                            </a>
                        <?php endif; ?>
                    </div>
                </div>
                <div class="card-body performane-indicator-card">
                    <h4 class="card-title">Filtros de Búsqueda: </h4>
                        
                    <div class="row">
                        
                        <div class="col-md-6">
                            <label for="search" class="form-label">Código/Descripción/Nurej</label>
                            <input type="text" id="search" wire:model.live.debounce.300ms="search" placeholder="Buscar proceso..." class="form-control">
                        </div>

                        
                        <div class="col-md-2">
                            <label for="departamento" class="form-label">Departamento</label>
                            <select id="departamento" wire:model.live="departamento_id" class="form-select">
                                <option value="">Todos los departamentos</option>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $departamentos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $departamento): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                                    <option value="<?php echo e($departamento->cod_depto); ?>"><?php echo e($departamento->depto_nombre); ?></option>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                            </select>
                        </div>

                        <div class="col-md-2">
                            <label class="form-label">Tipo de Delito</label>
                            <div wire:ignore>
                                <select id="tipo_delito" class="form-select">
                                    <option value="">Todos los tipos</option>
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $tiposDelito; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tipo): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                                        <option value="<?php echo e($tipo->id); ?>"><?php echo e($tipo->nombre); ?></option>
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                                </select>
                            </div>
                        </div>

                        <div class="col-md-2">
                            <label class="form-label">Tipo de Proceso</label>
                            <div wire:ignore>
                                <select id="tipo_proceso" class="form-select" >
                                    <option value="">Todos los tipos</option>
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $tiposProceso; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tipoP): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                                        <option value="<?php echo e($tipoP->id); ?>"><?php echo e($tipoP->nombre); ?></option>
                                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                                </select>
                            </div>
                        </div>
                    </div>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($search): ?>
                        <span class="badge badge-outline-dark" style="font-size: 0.875rem;">
                            Código/Descrip/Nurej: "<?php echo e($search); ?>"
                            <a href="#" wire:click.prevent="$set('search', '')" class="text-white ml-1">✖</a>
                        </span>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($departamento_id): ?>
                        <span class="badge badge-outline-dark" style="font-size: 0.875rem;">
                            Departamento: "<?php echo e($this->departamentoNombre); ?>"
                            <a href="#" wire:click.prevent="$set('departamento_id', '')" class="text-white ml-1">✖</a>
                        </span>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($tipo_delito_id): ?>
                        <span class="badge badge-outline-dark" style="font-size: 0.875rem;">
                            Tipo Delito: "<?php echo e($this->tipoDelitoNombre); ?>"
                            <a href="#" wire:click.prevent="$set('tipo_delito_id', '')" class="text-white ml-1">✖</a>
                        </span>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($tipo_proceso_id): ?>
                        <span class="badge badge-outline-dark" style="font-size: 0.875rem;">
                            Tipo Proceso: "<?php echo e($this->tipoProcesoNombre); ?>"
                            <a href="#" wire:click.prevent="$set('tipo_proceso_id', '')" class="text-white ml-1">✖</a>
                        </span>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($search || $tipo_delito_id || $departamento_id || $tipo_proceso_id): ?>
                        <button wire:click="limpiarFiltros" class="btn btn-sm btn-outline-danger ml-2">Quitar Filtros</button>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                    <hr>
                    <div class="table-responsive">
                        <div class="d-flex justify-content-end mb-3">
                            <button wire:click="exportarExcel"
                                    wire:loading.attr="disabled"
                                    class="btn btn-outline-success btn-icon-text btn-sm">
                                <i class="fa fa-file-excel-o"></i> Exportar Excel
                            </button>
                            <button wire:click="exportPdf"
                                    wire:loading.attr="disabled"
                                    class="btn btn-outline-danger btn-sm">
                                <i class="fa fa-file-pdf-o"></i> Exportar PDF
                            </button>

                        </div>

                        <table class="table table-hover table-sm" width="100%">
                            <thead>
                                <tr>
                                    <th class="text-center">Acciones</th>
                                    <th wire:click="sortBy('fecha_inicio')" class="text-center">
                                        <div class="flex items-center">
                                            Fecha Inicio
                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($sortField === 'fecha_inicio'): ?>
                                                <i class="fa fa-sort-<?php echo e($sortDirection === 'asc' ? 'up' : 'down'); ?> ml-2 text-blue-600"></i>
                                            <?php else: ?>
                                                <i class="fa fa-sort ml-2 text-gray-400"></i>
                                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                        </div>
                                    </th>
                                    <th wire:click="sortBy('codigo_proceso')" class="text-center">
                                        <div class="flex items-center">
                                            Código
                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($sortField === 'codigo_proceso'): ?>
                                                <i class="fa fa-sort-<?php echo e($sortDirection === 'asc' ? 'up' : 'down'); ?> ml-2 text-blue-600"></i>
                                            <?php else: ?>
                                                <i class="fa fa-sort ml-2 text-gray-400"></i>
                                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                        </div>
                                    </th>
                                    <th class="text-center">Descripción</th>
                                    <th wire:click="sortBy('ciudad_id')" class="text-center">
                                        <div class="flex items-center">
                                            Departamento
                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($sortField === 'ciudad_id'): ?>
                                                <i class="fa fa-sort-<?php echo e($sortDirection === 'asc' ? 'up' : 'down'); ?> ml-2 text-blue-600"></i>
                                            <?php else: ?>
                                                <i class="fa fa-sort ml-2 text-gray-400"></i>
                                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                        </div>
                                    </th>
                                    <th class="text-center">Requerimientos</th>
                                    <th class="text-center">Juzgado</th>
                                    <th class="text-center">Tipo de Delito</th>
                                    <th class="text-center">Tipo de Proceso</th>
                                    <th class="text-center">Estado</th>
                                    <th class="text-center">Daño Economico</th>
                                    <th class="text-center">Registrado Por</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $procesos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index=>$proceso): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                                    <tr>
                                        <td class="text-center">
                                            <button class="btn btn-primary btn-sm dropdown-toggle" type="button" id="dropdownMenuButton<?php echo e($index); ?>" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Acciones </button>
                                            <div class="dropdown-menu" aria-labelledby="dropdownMenuButton<?php echo e($index); ?>">
                                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('seguimientos.create')): ?><a class="dropdown-item mb-2" href="<?php echo e(route('seguimientos.create', $proceso)); ?>">Seguimiento</a><?php endif; ?>
                                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('requerimientos.create')): ?><a class="dropdown-item mb-2" href="<?php echo e(route('requerimientos.create', $proceso)); ?>">Requerimiento</a><?php endif; ?>
                                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('procesos.edit')): ?><a class="dropdown-item mb-2" href="<?php echo e(route('procesos.edit', $proceso)); ?>">Editar</a><?php endif; ?>
                                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('asignaciones.create')): ?><a class="dropdown-item mb-2"
                                                    data-bs-toggle="modal"
                                                    data-bs-target="#modalAsignar"
                                                    onclick="setProceso(<?php echo e($proceso->id); ?>)">Asignación</a>
                                                <?php endif; ?>
                                                <a class="dropdown-item mb-2" href="<?php echo e(route('procesos.pdf', $proceso)); ?>" target="_blank">Ver Historial</a>
                                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('procesos.destroy')): ?><a href="<?php echo e(route('procesos.destroy', $proceso->id)); ?>" class="dropdown-item mb-2" data-confirm-delete="true">Eliminar</a><?php endif; ?>
                                            </div>
                                        </td>
                                        <td class="text-center"><?php echo e(date('d/m/Y', strtotime($proceso->fecha_inicio))); ?></td>
                                        <td class="text-center"><?php echo e($proceso->codigo_proceso); ?> <br>
                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(count($proceso->asignaciones) > 0): ?>
                                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $proceso->asignaciones; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $asignacion): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                                                    <small class="text-primary"><?php echo e($asignacion->abogado->name); ?></small><br>
                                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                                            <?php else: ?>
                                                <small class="text-danger">Sin asignar</small>
                                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                        </td>
                                        <td><?php echo e(Str::limit($proceso->descripcion_proceso, 50)); ?></td>
                                        <td class="text-center">
                                            <?php echo e($proceso->ciudad->depto_nombre ?? 'N/A'); ?> <br>
                                            <?php echo e($proceso->ciudad->ciudad_nombre ?? 'N/A'); ?>

                                        </td>
                                        <td class="text-center">
                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(count($proceso->requerimientos) > 0): ?>
                                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $proceso->requerimientos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $requerimiento): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoop($loop->index); ?><?php endif; ?>
                                                    <small class="text-dark"><?php echo e(date('d/m/Y', strtotime($requerimiento->fecha))); ?> - <?php echo e($requerimiento->motivo); ?></small><br>
                                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                                            <?php else: ?>
                                                <small class="text-danger">Sin requerimientos</small>
                                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                        </td>
                                        <td><?php echo e($proceso->juzgado); ?></td>
                                        <td class="text-center"><?php echo e($proceso->tipo_delito->nombre ?? 'N/A'); ?></td>
                                        <td class="text-center"><?php echo e($proceso->tipo_proceso->nombre ?? 'N/A'); ?></td>
                                        <td class="text-center">
                                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($proceso->seguimientos->isEmpty()): ?>
                                                <span class="badge bg-secondary">SIN SEGUIMIENTO</span>
                                            <?php else: ?>
                                                <span class="badge 
                                                    <?php if($proceso->seguimientos->last()->estado->nombre=='EN PROCESO'): ?> bg-primary
                                                    <?php elseif($proceso->seguimientos->last()->estado->nombre=='SUSPENDIDA'): ?> bg-warning
                                                    <?php else: ?> bg-success <?php endif; ?>">
                                                    <?php echo e($proceso->seguimientos->last()->estado->nombre); ?>

                                                </span>
                                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                                        </td>
                                        <td class="text-center"><?php echo e(number_format($proceso->daño_economico, 2)); ?></td>
                                        <td class="text-center"><?php echo e($proceso->usuario->name); ?></td>
                                    </tr>
                                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::endLoop(); ?><?php endif; ?><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::closeLoop(); ?><?php endif; ?>
                                    <tr>
                                        <td colspan="11" class="px-6 py-12 text-center">
                                            <div class="text-gray-400">
                                                <i class="fas fa-folder-open text-6xl mb-4"></i>
                                                <p class="text-lg font-medium">No se encontraron procesos</p>
                                                <p class="text-sm">Intenta ajustar los filtros o crear un nuevo proceso</p>
                                            </div>
                                        </td>
                                    </tr>
                                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                            </tbody>
                        </table>
                    </div>

                    
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($procesos->hasPages()): ?>
                        <div class="mt-2">
                            <?php echo e($procesos->links(data: ['scrollTo' => false])); ?>

                        </div>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>
            </div>
        </div>
    </div>
    <?php echo $__env->make('procesos._modal_asignacion', ['abogados' => $abogados], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    <script>
        function setProceso(id) {
            document.getElementById('proceso_id').value = id;
        }
        document.addEventListener('livewire:init', function () {

            function initSelect2() {
                $('#tipo_delito').select2({
                    placeholder: 'Todos los tipos',
                    allowClear: true
                });

                $('#tipo_proceso').select2({
                    placeholder: 'Todos los tipos',
                    allowClear: true
                });

                // Enviar valor a Livewire
                $('#tipo_delito').on('change', function () {
                    window.Livewire.find('<?php echo e($_instance->getId()); ?>').set('tipo_delito_id', $(this).val());
                });

                $('#tipo_proceso').on('change', function () {
                    window.Livewire.find('<?php echo e($_instance->getId()); ?>').set('tipo_proceso_id', $(this).val());
                });
            }

            initSelect2();

            // 🔥 Clave: cada vez que Livewire renderiza
            Livewire.hook('message.processed', () => {
                initSelect2();

                // 🔥 Restaurar el valor seleccionado
                $('#tipo_delito').val(window.Livewire.find('<?php echo e($_instance->getId()); ?>').tipo_delito_id).trigger('change.select2');
                $('#tipo_proceso').val(window.Livewire.find('<?php echo e($_instance->getId()); ?>').tipo_proceso_id).trigger('change.select2');
            });

            Livewire.on('limpiar-selects', () => {
                $('#tipo_delito').val(null).trigger('change.select2');
                $('#tipo_proceso').val(null).trigger('change.select2');
            });
        });
    </script>
</div>
<?php /**PATH /var/www/html/lexflow/resources/views/livewire/procesos/index.blade.php ENDPATH**/ ?>