<?php
    $selectedGroup = $selectedGroup ?? request('group', 'web-hosting');
    $primaryDomainItem = $cart->items->first(fn ($item) => in_array($item->item_type, ['domain_register', 'domain_transfer', 'domain_existing'], true));
    $hasHostingInCart = $cart->items->contains(fn ($item) => $item->item_type === 'hosting');
    $cartDomainNames = $cart->items
        ->filter(fn ($item) => str_starts_with((string) $item->item_type, 'domain_') && $item->domain_name)
        ->pluck('domain_name')
        ->map(fn ($domain) => strtolower((string) $domain))
        ->all();
    $brandCandidates = $primaryDomainItem
        ? array_values(array_filter(
            $pricing->brandProtectionCandidates($primaryDomainItem->domain_name, $cart->currency),
            fn ($domain) => ! in_array(strtolower((string) $domain), $cartDomainNames, true)
        ))
        : [];
?>

<?php if($primaryDomainItem): ?>
    <section id="domain-search" class="order-panel clean-panel zt-brand-protection-panel">
        <div class="section-heading">
            <h2>Protect your brand</h2>
            <p>Secure popular domain extensions to keep competitors away from your name.</p>
        </div>

        <div
            id="zt-brand-protection-list"
            class="zt-brand-protection-list"
            data-operation="register"
            data-max-results="7"
            data-candidates='<?php echo json_encode($brandCandidates, 15, 512) ?>'
        >
            <p class="zt-brand-status" data-brand-protection-status>
                <?php echo e(count($brandCandidates) ? 'Checking available extensions...' : 'No additional supported extensions are available.'); ?>

            </p>
            <div class="zt-brand-domain-grid" data-brand-protection-items></div>
        </div>
    </section>
<?php else: ?>
    <section id="domain-search" class="order-panel clean-panel">
        <div class="section-heading">
            <h2>Domain</h2>
            <p>Search a new domain, transfer a domain, or attach an existing domain.</p>
        </div>

        <form method="GET" action="<?php echo e(route('checkout.index')); ?>#domain-search" class="domain-checkout-search" data-ajax-domain-search>
            <?php echo csrf_field(); ?>
            <input type="hidden" name="step" value="cart">
            <input type="hidden" name="group" value="<?php echo e($selectedGroup); ?>">
            <input type="hidden" name="domain_check" value="1">
            <div class="domain-tabs">
                <label><input type="radio" name="operation" value="register" <?php echo e(request('operation', 'register') === 'register' ? 'checked' : ''); ?>> Register a new domain</label>
                <label><input type="radio" name="operation" value="transfer" <?php echo e(request('operation') === 'transfer' ? 'checked' : ''); ?>> Transfer domain</label>
            </div>
            <div class="domain-input-wrap">
                <input class="input domain-search-input" name="domain_name" value="<?php echo e(request('domain_name')); ?>" placeholder="example.com" required>
                <button class="domain-search-button" type="submit">Search</button>
            </div>
        </form>

        <div id="zt-domain-result">
            <?php echo $__env->make('checkout.partials.domain-result', ['domainResult' => $domainResult ?? null, 'cart' => $cart, 'pricing' => $pricing], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
        </div>

        <?php if($hasHostingInCart): ?>
            <div class="divider-text"><span>or use existing domain</span></div>

            <form method="POST" action="<?php echo e(route('cart.add-domain')); ?>" class="existing-domain-form" data-ajax-cart>
                <?php echo csrf_field(); ?>
                <input type="hidden" name="domain_mode" value="existing">
                <input class="input " name="domain_name" placeholder="yourdomain.com" required>
                <button class="secondary-btn" type="submit">Attach Domain</button>
            </form>
        <?php endif; ?>
    </section>
<?php endif; ?>
<?php /**PATH /home/ovbopdha/public_html/ztcart.eagale.xyz/resources/views/checkout/partials/domain-section.blade.php ENDPATH**/ ?>