import { arrow_right } from "pn-design-assets/pn-assets/icons";
import { createComponent, createDocumentation, } from "../../../globals/documentation/story";
import docs from "./pn-versa-card-docs.json";
const { argTypes, textContent } = createDocumentation(docs);
const meta = {
    title: 'Components/Cards/Versa card',
    parameters: {
        docs: { description: { story: textContent } },
    },
    args: {
        // Wrapper sizing
        size: 'onequarterwidth',
        // Content props
        label: 'Example label',
        heading: 'Example heading',
        headingLevel: 'h3',
        preamble: 'Example preamble',
        imageSrc: 'https://www.postnord.se/siteassets/vi-tar-saker-framat---kampanjsida/paketbox3.jpg',
        imageAlt: 'Versa card image',
        // Slot content (optional)
        rteHtml: '<p>Lorem ipsum dolor sit amet, <a href="#">consectetur</a> adipiscing elit.</p>',
        ctaHtml: `<pn-button class="pn-button" appearance="light" target="_blank" href="google.com"> Read More </pn-button> <a class="versa-card-cta-link-animated"> Läs mer här <pn-icon icon='${arrow_right}' > </pn-icon> `,
        // Modifier props (Stencil @Prop)        
        hasImageCover: false,
        imageGrow: false,
        horizontal: false,
        imgAlignment: 'left',
        roundImage: false,
        center: false,
        alignMiddle: false,
        cardColor: 'white',
        opacity: 85,
    },
    argTypes: {
        ...argTypes,
        // Slots
        rteHtml: { control: 'text', description: 'Injected into slot="rte".' },
        ctaHtml: { control: 'text', description: 'Injected into slot="cta".' },
        imageSrc: { control: 'text', description: 'Image URL for the image slot.' },
        imageAlt: { control: 'text', description: 'Alt text for the image slot.' },
        // Wrapper sizing
        size: {
            control: 'radio',
            options: ['default', 'halfwidth', 'onethirdwidth', 'onequarterwidth'],
            description: 'Adds a parent wrapper class for `.halfwidth` / `.onequarterwidth` selectors in SCSS.',
        },
        // Story-only data attribute
        cardColor: {
            control: { type: 'select' },
            options: [
                'none',
                'white',
                'blue25',
                'blue50',
                'blue400',
                'blue900',
                'coral25',
                'coral50',
                'green25',
                'green50',
            ],
            description: 'Sets the data-card-color attribute on pn-versa-card.',
        },
        opacity: {
            control: { type: 'range', min: 0, max: 100, step: 5 },
        },
        imgAlignment: {
            control: 'select',
            options: ['left', 'right'],
            description: 'Sets the image to the right side of the card.',
        },
        roundImage: {
            control: 'boolean',
            description: 'Adds rounded image styling to the card.',
        },
        headingLevel: {
            control: 'select',
            options: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
            description: 'Sets the heading level for the card heading.',
        },
        transparentBackground: {
            control: 'boolean',
            description: 'If true, applies reduced opacity to the card background to allow content behind the card to show through.',
        },
    },
};
export default meta;
function buildCard(args) {
    const { rteHtml, ctaHtml, size: _size, cardColor, ...componentArgs } = args;
    const { imageSrc, imageAlt, } = args;
    const el = createComponent('pn-versa-card', componentArgs);
    if (cardColor) {
        if (cardColor === 'none') {
            el.setAttribute('data-card-color', '');
        }
        else {
            el.setAttribute('data-card-color', cardColor);
        }
    }
    if (rteHtml?.trim()) {
        const rte = document.createElement('div');
        rte.slot = 'rte';
        rte.innerHTML = rteHtml;
        el.appendChild(rte);
    }
    if (ctaHtml?.trim()) {
        const cta = document.createElement('div');
        cta.slot = 'cta';
        cta.innerHTML = ctaHtml;
        el.appendChild(cta);
    }
    if (imageSrc) {
        const media = document.createElement('div');
        media.slot = 'image';
        const picture = document.createElement('picture');
        const img = document.createElement('img');
        img.src = imageSrc;
        if (imageAlt) {
            img.alt = imageAlt;
        }
        picture.appendChild(img);
        media.appendChild(picture);
        el.appendChild(media);
    }
    return el;
}
/**
 * One card, constrained by wrapper class, and centered on the page.
 */
function renderCenteredQuarter(args) {
    const wrapper = document.createElement('div');
    if (args.size && args.size !== 'default') {
        wrapper.className = args.size;
    }
    wrapper.style.marginInline = 'auto';
    wrapper.style.display = 'block';
    wrapper.style.maxWidth = '420px';
    wrapper.appendChild(buildCard(args));
    return wrapper;
}
function renderCenteredRow(items, size, columns) {
    const wrapper = document.createElement('div');
    if (size !== 'default') {
        wrapper.className = size;
    }
    wrapper.style.display = 'flex';
    wrapper.style.justifyContent = 'center';
    wrapper.style.width = '100%';
    wrapper.style.height = '100%';
    const row = document.createElement('div');
    row.style.display = 'flex';
    row.style.gap = '24px';
    row.style.alignItems = 'stretch';
    row.style.height = '100%';
    items.forEach((item) => {
        const col = document.createElement('div');
        col.style.flex = `0 1 ${100 / columns}%`;
        col.style.display = 'flex';
        const card = buildCard(item);
        card.style.flex = '1';
        col.appendChild(card);
        row.appendChild(col);
    });
    wrapper.appendChild(row);
    return wrapper;
}
/* -----------------------------
   Stories
--------------------------------*/
export const OneCardCenteredQuarterPlayGround = {
    name: 'Playground (all controls enabled, for testing purposes)',
    render: (args) => renderCenteredRow([
        {
            ...args,
            rteHtml: '<p>Lorem ipsum dolor sit amet, <a href="#">consectetur</a> adipiscing elit. ipsum sodales tincidunt tincidunt nec nisi. Sed ante mauris, tempus sit amet dictum a, ornare tincidunt ex.</p> <blockquote> This is a blockquote example.This is a blockquote example.This is a blockquote example.This is a blockquote example. </blockquote>',
        },
    ], 'onethirdwidth', 1),
    parameters: {
        controls: {
            exclude: [],
        },
    },
};
export const OneCardCenteredQuarterDefault = {
    name: 'Background, Image, Label, Heading, Preamble, RTE, CTA)',
    render: (args) => renderCenteredQuarter(args),
    args: {
        label: 'Test',
        heading: 'Heading',
        preamble: 'Here goes the preamble for this block',
        rteHtml: '<p>Lorem ipsum dolor sit amet, <a href="#">consectetur</a> adipiscing elit. ipsum sodales tincidunt tincidunt nec nisi. Sed ante mauris, tempus sit amet dictum a, ornare tincidunt ex.</p>',
        ctaHtml: `<pn-button class="btn btn-secondary">Click me</pn-button>`,
        cardColor: 'blue25',
    },
    parameters: {
        controls: {
            include: ['hasBg', 'label', 'heading', 'headingLevel', 'preamble', 'imageSrc', 'cardColor'],
        },
    },
};
export const OneCardRoundedImage = {
    name: 'RoundedImage, Label, Heading, Preamble, RTE, CTA, Alignment)',
    render: (args) => renderCenteredQuarter(args),
    args: {
        roundImage: true,
        center: false,
        label: 'Test',
        heading: 'Heading',
        preamble: 'Here goes the preamble for this block',
        rteHtml: '<p>Lorem ipsum dolor sit amet, <a href="#">consectetur</a> adipiscing elit. ipsum sodales tincidunt tincidunt nec nisi. Sed ante mauris, tempus sit amet dictum a, ornare tincidunt ex.</p>',
    },
    parameters: {
        controls: {
            include: ['label', 'heading', 'preamble', 'imageSrc', 'center', 'hasBg', 'cardColor', 'headingLevel'],
        },
    },
};
export const OneCardCenteredQuarterImageCoverText = {
    name: 'Background, Image, Label, Heading, Preamble, RTE, CTA)',
    render: (args) => renderCenteredQuarter(args),
    args: {
        hasImageCover: true,
        label: 'Test',
        heading: 'Heading',
        preamble: 'Here goes the preamble for this block',
        rteHtml: '<p>Lorem ipsum dolor sit amet, <a href="#">consectetur</a> adipiscing elit. ipsum sodales tincidunt tincidunt nec nisi. Sed ante mauris, tempus sit amet dictum a, ornare tincidunt ex.</p>',
        ctaHtml: `<pn-button class="btn btn-secondary">Click me</pn-button> <a target="_blank" href="google.com" class= "versa-card-cta-link-animated" > Read More<pn- icon icon='${arrow_right}' > </pn-icon></a > `,
        cardColor: 'blue25',
    },
    parameters: {
        controls: {
            include: ['hasBg', 'label', 'heading', 'preamble', 'imageSrc', 'opacity', 'cardColor', 'center'],
        },
    },
};
export const ThreeCardsCenteredQuarter = {
    name: 'Three cards, centered, with background and image (for layout testing)',
    parameters: {
        controls: {
            include: ['imageSrc'],
        },
    },
    render: (args) => renderCenteredRow([
        {
            ...args,
            cardColor: 'blue25',
            label: 'Card 1',
            rteHtml: '<p>Lorem ipsum dolor sit amet, <a href="#">consectetur</a> adipiscing elit. ipsum sodales tincidunt tincidunt nec nisi. Sed ante mauris, tempus sit amet dictum a, ornare tincidunt ex.</p>',
        },
        {
            ...args,
            label: 'Card 2',
            heading: 'I am a card with no modifier',
        },
        {
            ...args,
            hasImageCover: true,
            center: true,
            cardColor: 'blue25',
            label: 'This is a card with image cover and image cover text',
            preamble: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ante mauris, tempus sit amet dictum a, ornare tincidunt ex.',
            heading: 'I am a card with image cover and image cover text',
            ctaHtml: '',
        },
    ], 'onethirdwidth', 3),
};
export const TwoCardsHorizontalAlignMiddle = {
    name: 'Two cards, horizontal, aligned middle, with background and image (for layout testing)',
    parameters: {
        controls: {
            include: ['hasBg', 'label', 'heading', 'preamble', 'imageSrc', 'imgAlignment', 'roundImage', 'cardColor'],
        },
    },
    render: (args) => renderCenteredRow([
        {
            ...args,
            cardColor: 'blue25',
            horizontal: true,
            alignMiddle: true,
            rteHtml: '<p>These actions help us lower emissions while maintaining reliable service across the region. PostNord is continuously exploring and adopting new technologies that strengthen our operational capabilities and help us deliver better value to customers across the Nordic region.</p>',
        },
        {
            ...args,
            preamble: '',
            center: true,
            roundImage: true,
            horizontal: false,
            alignMiddle: true,
            rteHtml: '<p>Excellent operational stability 24/7. Deliveries completely aligned with business needs. Response to disruptions is predictive and swift with total transparency</p>',
            ctaHtml: `<pn-button class="btn btn-secondary">Click me</pn-button> <a target="_blank" href="google.com" class= "versa-card-cta-link-animated" > Read More<pn- icon icon='${arrow_right}' > </pn-icon></a > `,
        },
    ], 'halfwidth', 1),
};
export const OneCardCenteredQuarterDefaultHorizontal = {
    name: 'Horizontal Background, Image, Label, Heading, Preamble, RTE, CTA)',
    parameters: {
        controls: {
            include: ['hasBg', 'label', 'heading', 'preamble', 'imageSrc', 'imgAlignment', 'roundImage', 'cardColor'],
        },
    },
    render: (args) => renderCenteredRow([
        {
            ...args,
            horizontal: true,
            rteHtml: '<p>Lorem ipsum dolor sit amet, <a href="#">consectetur</a> adipiscing elit. ipsum sodales tincidunt tincidunt nec nisi. Sed ante mauris, tempus sit amet dictum a, ornare tincidunt ex.</p>',
            ctaHtml: `<pn-button class="btn btn-primary">Click me</pn-button> <a target="_blank" href="google.com" class=""> Read More <pn-icon icon='${arrow_right}' > </pn-icon></a>`,
        },
    ], 'halfwidth', 1),
};
export const OneCardCenteredQuarterTransparentBackground = {
    name: 'Horizontal Transparent Background (Image, Label, Heading, Preamble, RTE, CTA)',
    parameters: {
        controls: {
            include: [
                'hasBg',
                'transparentBackground',
                'label',
                'heading',
                'preamble',
                'imageSrc',
                'imageAlt',
                'imgAlignment',
                'roundImage',
                'cardColor',
            ],
        },
    },
    render: (args) => {
        const wrapper = document.createElement('div');
        wrapper.style.background = 'linear-gradient(135deg, #fff 0%, #000 100%)';
        wrapper.style.padding = '64px 0';
        const row = renderCenteredRow([
            {
                ...args,
                horizontal: true,
                rteHtml: `
                        <p>This card demonstrates a <strong>10% transparent background</strong>.
                        The gradient behind the card should be visible through the background.</p>
                    `,
                ctaHtml: `
                        <pn-button class="btn btn-primary">Click me</pn-button>
                        <a target="_blank" href="https://google.com">
                            Read More <pn-icon icon='${arrow_right}'></pn-icon>
                        </a>
                    `,
            },
        ], 'halfwidth', 1);
        wrapper.appendChild(row);
        return wrapper;
    },
    args: {
        transparentBackground: true,
        label: 'Story demo',
        heading: 'Transparent background card',
        preamble: 'The card background is slightly transparent while content remains opaque.',
        imgAlignment: 'left',
        roundImage: false,
        cardColor: 'white',
    },
};
//# sourceMappingURL=pn-versa-card.stories.js.map
