<nav-bar title="{{pageTitle}}" />

<view class="md-page">
    <view class="md-main">
        <!-- 打印预览卡 -->
        <preview-card
            id="previewCard"
            showRefresh="{{true}}"
            showFavorite="{{true}}"
            favorited="{{isPreviewFavorite}}"
            bind:canvas-ready="onCanvasReady"
            bind:refresh="onPreviewRefresh"
            bind:favorite="onPreviewFavorite" />

        <!-- 子选项（当前类型有模式切换时显示） -->
        <view wx:if="{{showActions}}" class="md-section">
            <text class="md-section-title">{{actionsTitle}}</text>
            <view
                class="md-chip-row {{currentActions.length > 3 ? 'md-chip-row--wrap' : ''}}">
                <view
                    wx:for="{{currentActions}}"
                    wx:key="value"
                    class="md-chip {{currentMode === item.value ? 'md-chip--active' : ''}}"
                    data-value="{{item.value}}"
                    hover-class="md-chip--pressed"
                    hover-start-time="0"
                    hover-stay-time="70"
                    bindtap="onSelectMode">
                    {{item.label}}
                </view>
            </view>
        </view>

        <!-- 数字选择网格（numberFind 专用） -->
        <view wx:if="{{showNumberGrid}}" class="md-section">
            <text class="md-section-title">选择数字</text>
            <view class="md-number-grid">
                <view
                    wx:for="{{numberList}}"
                    wx:key="*this"
                    class="md-number-cell {{selectedNumber === item ? 'md-number-cell--active' : ''}}"
                    data-number="{{item}}"
                    hover-class="md-number-cell--pressed"
                    hover-start-time="0"
                    hover-stay-time="70"
                    bindtap="onSelectNumber">
                    <text class="md-number-text">{{item}}</text>
                </view>
            </view>
        </view>

        <!-- 练习类型选择（2列卡片网格） -->
        <view class="md-section">
            <text class="md-section-title">练习类型</text>
            <view class="md-type-grid">
                <view
                    wx:for="{{typeList}}"
                    wx:key="id"
                    class="md-type-card {{selectedTypeId === item.id ? 'md-type-card--active' : ''}}"
                    data-id="{{item.id}}"
                    hover-class="md-type-card--pressed"
                    hover-start-time="0"
                    hover-stay-time="70"
                    bindtap="onSelectType">
                    <text class="md-type-card__icon">{{item.icon}}</text>
                    <text class="md-type-card__label">{{item.title}}</text>
                </view>
            </view>
        </view>

        <!-- 随机生成按钮
        <view
            class="md-shuffle-btn"
            hover-class="md-shuffle-btn--hover"
            hover-start-time="0"
            hover-stay-time="70"
            bindtap="onRandom">
            <toy-icon
                name="refresh"
                size="40rpx"
                color="#605b50"
                custom-class="md-shuffle-btn__icon" />
            <text class="md-shuffle-btn__text">随机生成</text>
        </view> -->

        <!-- 广告位 -->
        <draw-ad type="mathDraw"></draw-ad>
    </view>
</view>

<!-- 底部操作栏 -->
<preview-footer-actions
    disabled="{{!hasContent}}"
    bind:primary="exportToPrint"
    bind:secondary="onShare" />

<debug-publish-tools
    wx:if="{{isDevEnv && hasContent}}"
    id="debugPublishTools"
    visible="{{debugPublishVisible}}"
    loading="{{debugPublishLoading}}"
    meta="{{debugPublishMeta}}"
    bind:open="onOpenDebugPublish"
    bind:close="onCloseDebugPublish"
    bind:confirm="onConfirmDebugPublish" />

<!-- 分享引导弹窗 -->
<share-guide-popup
    show="{{showShareDialog}}"
    bind:onClose="onCloseShareDialog"
    bind:onShareSuccess="onShareSuccess" />
