<?php
    $document = is_array($document ?? null) ? $document : [];
    $details = is_array($details ?? null) ? $details : [];
    $fiscalSettings = is_array($fiscalSettings ?? null) ? $fiscalSettings : [];
    $dianResolution = is_array($dianResolution ?? null) ? $dianResolution : [];
    $factusConfigured = (bool) ($factusConfigured ?? false);
    $ticketSize = in_array(($ticketSize ?? '80mm'), ['58mm', '80mm'], true) ? $ticketSize : '80mm';

    $docType = (string) ($document['tipo_documento'] ?? 'factura');
    $docLabel = $docType === 'nota_credito'
        ? 'NOTA CREDITO'
        : ($docType === 'nota_debito' ? 'NOTA DEBITO' : 'FACTURA');

    $subtotal = (float) ($document['subtotal'] ?? 0);
    $discount = (float) ($document['venta_descuento'] ?? 0);
    $taxes = (float) ($document['impuestos'] ?? 0);
    $total = (float) ($document['total'] ?? 0);
    $paid = (float) ($document['total_pagado'] ?? 0);
    $paymentMethods = trim((string) ($document['metodos_pago'] ?? ''));
    $cufe = trim((string) ($document['cufe'] ?? ''));
    $qrPath = trim((string) ($document['qr_path'] ?? ''));

    $resolutionNumber = trim((string) ($dianResolution['numero_resolucion'] ?? ($fiscalSettings['resolucion_dian'] ?? '')));
    $resolutionPrefix = trim((string) ($dianResolution['prefijo'] ?? ''));
    $resolutionRangeFrom = trim((string) ($dianResolution['rango_desde'] ?? ''));
    $resolutionRangeTo = trim((string) ($dianResolution['rango_hasta'] ?? ''));
    $resolutionDateFromRaw = trim((string) ($dianResolution['fecha_desde'] ?? ''));
    $resolutionDateToRaw = trim((string) ($dianResolution['fecha_hasta'] ?? ''));
    $resolutionDateFrom = $resolutionDateFromRaw;
    $resolutionDateTo = $resolutionDateToRaw;
    if ($resolutionDateFromRaw !== '' && ($ts = strtotime($resolutionDateFromRaw))) {
        $resolutionDateFrom = date('Y/m/d', $ts);
    }
    if ($resolutionDateToRaw !== '' && ($ts = strtotime($resolutionDateToRaw))) {
        $resolutionDateTo = date('Y/m/d', $ts);
    }

    $fiscalRegime = trim((string) ($fiscalSettings['regimen_fiscal'] ?? ''));
    $fiscalActivity = trim((string) ($fiscalSettings['actividad_economica'] ?? ''));
    $isVatResponsible = trim((string) ($fiscalSettings['responsable_iva'] ?? '0')) === '1';

    $saleDateRaw = trim((string) ($document['fecha_emision'] ?? ''));
    $saleDate = $saleDateRaw;
    $saleTime = '';
    if ($saleDateRaw !== '' && ($timestamp = strtotime($saleDateRaw))) {
        $saleDate = date('d/m/Y', $timestamp);
        $saleTime = date('H:i', $timestamp);
    }

    $lineItems = [];
    $taxSummary = [];
    $totalItems = 0.0;
    $lineTaxTotal = 0.0;
    $lineNetBaseTotal = 0.0;
    $lineGrossTotal = 0.0;
    $lineDiscountTotal = 0.0;
    foreach ($details as $line) {
        $lineQty = (float) ($line['cantidad'] ?? 0);
        $lineUnitPrice = (float) ($line['precio_unitario'] ?? 0);
        $lineGross = round($lineQty * $lineUnitPrice, 2);
        $lineTax = (float) ($line['impuesto'] ?? 0);
        $lineTotal = (float) ($line['total_linea'] ?? 0);
        $lineBase = max(0.0, $lineTotal - $lineTax);
        $lineDiscount = max(0.0, round($lineGross - $lineBase, 2));

        $lineGrossTotal += $lineGross;
        $lineNetBaseTotal += $lineBase;
        $lineTaxTotal += $lineTax;
        $lineDiscountTotal += $lineDiscount;
        $totalItems += $lineQty;

        $lineItems[] = [
            'descripcion' => (string) ($line['descripcion'] ?? ''),
            'cantidad' => $lineQty,
            'gross' => $lineGross,
            'base' => $lineBase,
            'impuesto' => $lineTax,
            'descuento' => $lineDiscount,
            'total' => $lineTotal,
        ];

        if ($lineTax <= 0.0001) {
            continue;
        }

        $rate = $lineBase > 0.0001 ? round(($lineTax / $lineBase) * 100, 2) : 0.0;
        $rateKey = number_format($rate, 2, '.', '');
        if (! isset($taxSummary[$rateKey])) {
            $taxSummary[$rateKey] = ['base' => 0.0, 'impuesto' => 0.0, 'tasa' => $rate];
        }
        $taxSummary[$rateKey]['base'] += $lineBase;
        $taxSummary[$rateKey]['impuesto'] += $lineTax;
    }
    ksort($taxSummary, SORT_NATURAL);

    $discountLabel = $discount > 0.0001 ? $discount : $lineDiscountTotal;
    $taxableBase = max(0.0, round($subtotal - $discountLabel, 2));
    $computedTotal = round($taxableBase + $taxes, 2);
    $finalTotal = abs($computedTotal - $total) <= 0.02 ? $total : $computedTotal;
    $itemsLabel = (int) round($totalItems) > 0 ? (int) round($totalItems) : count($details);
    $hasFeEvidence = $cufe !== '' || $qrPath !== '';
    $showResolutionBlock = ($resolutionNumber !== '' || $resolutionPrefix !== '' || $resolutionRangeFrom !== '');

    $widthMm = $ticketSize === '58mm' ? '58mm' : '80mm';
    $bodyFont = $ticketSize === '58mm' ? '10px' : '11px';
    $compactFont = $ticketSize === '58mm' ? '9px' : '10px';
    $totalFont = $ticketSize === '58mm' ? '15px' : '17px';
    $taxGrid = $ticketSize === '58mm' ? '34px 48px 36px 1fr' : '44px 56px 44px 1fr';
?>
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Ticket <?php echo e($document['numero'] ?? ''); ?></title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 18px 12px;
            background: #f4f6f8;
            color: #111827;
        }
        .actions {
            width: <?php echo e($widthMm); ?>;
            max-width: 100%;
            margin: 0 auto 14px;
            display: flex;
            justify-content: space-between;
            gap: 8px;
        }
        .btn {
            border: 1px solid #d1d5db;
            background: #fff;
            color: #111827;
            border-radius: 6px;
            padding: 6px 10px;
            font-size: 13px;
            text-decoration: none;
            cursor: pointer;
        }
        .btn-primary { background: #111827; border-color: #111827; color: #fff; }

        .ticket-shell {
            width: <?php echo e($widthMm); ?>;
            max-width: 100%;
            margin: 0 auto;
            background: #fff;
            border: 1px solid #e5e7eb;
            border-radius: 8px;
            padding: 12px 10px;
        }

        .ticket-wrap {
            font-family: "Courier New", Courier, monospace;
            font-size: <?php echo e($bodyFont); ?>;
            line-height: 1.3;
            color: #111;
        }
        .ticket-divider, .ticket-divider-thin {
            border-top: 1px dashed #333;
            margin: 6px 0;
        }
        .ticket-divider-thin { border-top-color: #777; margin: 4px 0; }
        .ticket-center { text-align: center; }
        .ticket-title {
            text-transform: uppercase;
            font-weight: 700;
            letter-spacing: 0.3px;
        }
        .ticket-row {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: 8px;
        }
        .ticket-row-value { text-align: right; white-space: nowrap; }
        .ticket-compact { font-size: <?php echo e($compactFont); ?>; }
        .ticket-products-head {
            display: grid;
            grid-template-columns: 1fr auto;
            gap: 8px;
            font-weight: 700;
            text-transform: uppercase;
        }
        .ticket-product { margin-bottom: 4px; }
        .ticket-product-desc { display: block; word-break: break-word; }
        .ticket-product-meta {
            margin-top: 1px;
            font-size: <?php echo e($ticketSize === '58mm' ? '8px' : '9px'); ?>;
            color: #333;
        }
        .ticket-save {
            text-align: center;
            font-weight: 800;
            font-size: <?php echo e($ticketSize === '58mm' ? '13px' : '15px'); ?>;
            margin: 8px 0 3px;
        }
        .ticket-total-block { text-align: center; margin: 4px 0; }
        .ticket-total-label {
            font-size: <?php echo e($compactFont); ?>;
            text-transform: uppercase;
            letter-spacing: 0.3px;
        }
        .ticket-total-value {
            font-size: <?php echo e($totalFont); ?>;
            font-weight: 800;
            line-height: 1.15;
        }
        .ticket-tax-head, .ticket-tax-row {
            display: grid;
            grid-template-columns: <?php echo e($taxGrid); ?>;
            gap: 6px;
            align-items: baseline;
        }
        .ticket-tax-head { font-weight: 700; text-transform: uppercase; }
        .ticket-tax-row span:nth-child(2),
        .ticket-tax-row span:nth-child(4) { text-align: right; }
        .ticket-tax-row span { white-space: nowrap; }
        .ticket-footer-title {
            text-transform: uppercase;
            font-weight: 700;
            text-align: center;
            letter-spacing: 0.25px;
        }
        .ticket-footer-block {
            font-size: <?php echo e($compactFont); ?>;
            line-height: 1.25;
        }
        .ticket-footer-line { margin: 1px 0; }
        .ticket-footer-line-cufe {
            word-break: break-all;
            overflow-wrap: anywhere;
            line-height: 1.2;
        }
        .ticket-qrcode {
            margin: 7px auto 5px;
            width: <?php echo e($ticketSize === '58mm' ? '82px' : '108px'); ?>;
            height: <?php echo e($ticketSize === '58mm' ? '82px' : '108px'); ?>;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .ticket-qrcode img {
            max-width: 100%;
            max-height: 100%;
            object-fit: contain;
            image-rendering: pixelated;
        }
        .ticket-muted { color: #333; }

        @media print {
            @page {
                size: <?php echo e($widthMm); ?> auto;
                margin: 2mm;
            }
            body { background: #fff; padding: 0; }
            .actions { display: none; }
            .ticket-shell {
                border: 0;
                border-radius: 0;
                padding: 0;
                width: <?php echo e($widthMm); ?>;
            }
        }
    </style>
</head>
<body>
    <div class="actions">
        <a class="btn" href="<?php echo e(url('ventas/'.(int) ($document['venta_id'] ?? 0))); ?>">Volver</a>
        <button class="btn btn-primary" type="button" onclick="window.print()">Imprimir</button>
    </div>

    <div class="ticket-shell">
        <div class="ticket-wrap">
            <div class="ticket-center ticket-compact">
                <strong><?php echo e($document['empresa_nombre'] ?? 'Veltrix POS'); ?></strong><br>
                NIT: <?php echo e($document['empresa_nit'] ?? '-'); ?><br>
                <?php echo e($document['empresa_direccion'] ?? '-'); ?><br>
                Tel: <?php echo e($document['empresa_telefono'] ?? '-'); ?><br>
                Local: <?php echo e($document['sucursal_nombre'] ?? 'Sucursal general'); ?>

            </div>

            <div class="ticket-divider"></div>

            <div class="ticket-title ticket-center"><?php echo e($docLabel); ?></div>
            <div class="ticket-divider-thin"></div>
            <div class="ticket-compact">
                <div class="ticket-row"><span>Ticket</span><span class="ticket-row-value"><?php echo e($document['numero'] ?? '-'); ?></span></div>
                <div class="ticket-row"><span>Fecha</span><span class="ticket-row-value"><?php echo e($saleDate !== '' ? $saleDate : '-'); ?></span></div>
                <div class="ticket-row"><span>Hora</span><span class="ticket-row-value"><?php echo e($saleTime !== '' ? $saleTime : '-'); ?></span></div>
                <div class="ticket-row"><span>Cajero</span><span class="ticket-row-value"><?php echo e($document['cajero'] ?? '-'); ?></span></div>
                <div class="ticket-row"><span>Cliente</span><span class="ticket-row-value"><?php echo e($document['cliente_documento'] !== '' ? $document['cliente_documento'] : '-'); ?></span></div>
                <div class="ticket-center"><?php echo e($document['cliente_nombre'] ?? 'Consumidor final'); ?></div>
            </div>

            <div class="ticket-divider"></div>

            <div class="ticket-products-head">
                <span>Descripcion</span>
                <span>Importe</span>
            </div>
            <div class="ticket-divider-thin"></div>

            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $lineItems; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $line): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                <div class="ticket-product">
                    <div class="ticket-row">
                        <span class="ticket-product-desc">
                            <?php echo e(number_format((float) $line['cantidad'], 2, '.', '')); ?>x
                            <?php echo e($line['descripcion']); ?>

                        </span>
                        <span class="ticket-row-value"><?php echo e(money((float) $line['total'])); ?></span>
                    </div>
                    <div class="ticket-product-meta">
                        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if((float) $line['descuento'] > 0.0001): ?>
                            Desc: -<?php echo e(money((float) $line['descuento'])); ?> |
                        <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        IVA: <?php echo e(money((float) $line['impuesto'])); ?> |
                        Bruto: <?php echo e(money((float) $line['gross'])); ?>

                    </div>
                </div>
            <?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; ?>
                <div class="ticket-center">Sin lineas registradas</div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

            <div class="ticket-divider"></div>

            <div class="ticket-row"><span>Subtotal bruto</span><span class="ticket-row-value"><?php echo e(money($subtotal)); ?></span></div>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($discountLabel > 0.0001): ?>
                <div class="ticket-save">AHORRO: -<?php echo e(money($discountLabel)); ?></div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            <div class="ticket-row"><span>Base gravable</span><span class="ticket-row-value"><?php echo e(money($taxableBase)); ?></span></div>
            <div class="ticket-row"><span>IVA</span><span class="ticket-row-value"><?php echo e(money($taxes)); ?></span></div>

            <div class="ticket-total-block">
                <div class="ticket-total-label">Total</div>
                <div class="ticket-total-value"><?php echo e(money($finalTotal)); ?></div>
                <div class="ticket-compact"><?php echo e($itemsLabel); ?> articulos</div>
            </div>

            <div class="ticket-divider"></div>

            <div class="ticket-title ticket-center">Pago</div>
            <div class="ticket-divider-thin"></div>
            <div class="ticket-row">
                <span><?php echo e($paymentMethods !== '' ? $paymentMethods : 'Sin metodo'); ?></span>
                <span class="ticket-row-value"><?php echo e(money($paid > 0 ? $paid : $finalTotal)); ?></span>
            </div>

            <div class="ticket-divider"></div>
            <div class="ticket-tax-head ticket-compact">
                <span>Tasa</span>
                <span>Importe</span>
                <span>Tipo</span>
                <span>Base IVA excl.</span>
            </div>
            <div class="ticket-divider-thin"></div>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(! empty($taxSummary)): ?>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::openLoop(); ?><?php endif; ?><?php $__currentLoopData = $taxSummary; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><?php \Livewire\Features\SupportCompiledWireKeys\SupportCompiledWireKeys::startLoopIteration(); ?><?php endif; ?>
                    <div class="ticket-tax-row ticket-compact">
                        <span>IVA</span>
                        <span><?php echo e(money((float) $row['impuesto'])); ?></span>
                        <span><?php echo e(number_format((float) $row['tasa'], 0, ',', '.')); ?>%</span>
                        <span><?php echo e(money((float) $row['base'])); ?></span>
                    </div>
                <?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: ?>
                <div class="ticket-tax-row ticket-compact">
                    <span>IVA</span>
                    <span><?php echo e(money(0)); ?></span>
                    <span>0%</span>
                    <span><?php echo e(money(0)); ?></span>
                </div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

            <div class="ticket-divider"></div>

            <div class="ticket-compact">
                <div class="ticket-row"><span>Impuestos</span><span class="ticket-row-value"><?php echo e(money($taxes)); ?></span></div>
                <div class="ticket-row"><span>Estado</span><span class="ticket-row-value"><?php echo e($document['estado'] ?? 'emitida'); ?></span></div>
            </div>

            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($showResolutionBlock): ?>
                <div class="ticket-divider"></div>
                <div class="ticket-footer-title">Autorizacion numeracion de facturacion</div>
                <div class="ticket-footer-block">
                    <div class="ticket-footer-line"><strong>Numero:</strong> <?php echo e($resolutionNumber !== '' ? $resolutionNumber : 'Sin configurar'); ?></div>
                    <div class="ticket-footer-line"><strong>Numeracion:</strong> <?php echo e($resolutionNumber !== '' ? 'AUTORIZADA' : 'PENDIENTE CONFIGURACION'); ?></div>
                    <div class="ticket-footer-line">
                        <strong>Rango:</strong>
                        desde <?php echo e(($resolutionPrefix ?: '').($resolutionRangeFrom !== '' ? $resolutionRangeFrom : '?')); ?>

                        hasta <?php echo e(($resolutionPrefix ?: '').($resolutionRangeTo !== '' ? $resolutionRangeTo : '?')); ?>

                    </div>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($resolutionDateFrom !== '' || $resolutionDateTo !== ''): ?>
                        <div class="ticket-footer-line"><strong>Vigencia:</strong> desde <?php echo e($resolutionDateFrom !== '' ? $resolutionDateFrom : '-'); ?></div>
                        <div class="ticket-footer-line">hasta <?php echo e($resolutionDateTo !== '' ? $resolutionDateTo : '-'); ?></div>
                    <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </div>
                <div class="ticket-divider-thin"></div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

            <div class="ticket-center ticket-footer-block ticket-muted">
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($fiscalRegime !== ''): ?>
                    <div class="ticket-footer-line">Regimen fiscal: <?php echo e($fiscalRegime); ?></div>
                <?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($fiscalActivity !== ''): ?>
                    <div class="ticket-footer-line">Actividad economica: <?php echo e($fiscalActivity); ?></div>
                <?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($isVatResponsible): ?>
                    <div class="ticket-footer-line">Responsable de IVA</div>
                <?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($cufe !== ''): ?>
                    <div class="ticket-footer-line ticket-footer-line-cufe"><strong>CUFE:</strong> <?php echo e($cufe); ?></div>
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>

            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($qrPath !== ''): ?>
                <div class="ticket-qrcode">
                    <img src="<?php echo e(Str::startsWith($qrPath, ['http://', 'https://']) ? $qrPath : asset(ltrim($qrPath, '/'))); ?>" alt="QR Factura electronica">
                </div>
            <?php elseif($cufe !== ''): ?>
                <div class="ticket-qrcode">
                    <img src="https://quickchart.io/qr?size=220&text=<?php echo e(urlencode($cufe)); ?>" alt="QR Factura electronica">
                </div>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>

            <div class="ticket-center ticket-footer-block">
                <div class="ticket-divider-thin"></div>
                Gracias por su compra<br>
                <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($hasFeEvidence): ?>
                    Consulte su factura electronica en su portal.
                <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
            </div>
        </div>
    </div>

    <script>
        window.addEventListener('load', () => {
            setTimeout(() => window.print(), 250);
        });
    </script>
</body>
</html>
<?php /**PATH /Applications/XAMPP/xamppfiles/htdocs/veltrix-v2/resources/views/modules/pos/ticket.blade.php ENDPATH**/ ?>