import{j as e,B as w}from"./Button.BVfR1y85.js";import{R as v,r as L}from"./index.eCxJ45ll.js";import{T as E,L as N,G as A,a as $,b as B,C as F,c as _,d as H,e as M,f as O,D as V,g as W,h as Z,i as q,j as S,S as z,k as I}from"./index.DGdw5tfb.js";import{C as m,a as D}from"./Content.CYLxURqU.js";import{b as J,c as K,e as u,T as P,a as k}from"./ToolbarContent.CAAHjZHW.js";import{S as Q}from"./SearchInput.CQ7aDztp.js";import{s as R,a as U}from"./index.CAChmxYj.js";import{L as x}from"./Label.CM_es7Cu.js";/* empty css                        */import"./divider.BP4XR7uq.js";import"./index.BQFV5hT1.js";import"./angle-down-icon.Dqz5ba9D.js";import"./PageContext.BUbWpNW2.js";import"./resizeObserver.BgQpxO8W.js";const X=({galleryItemCount:o,searchTerm:l,setSearchTerm:r,layoutView:a,setLayoutView:t,placeholderText:i="Search by name",countText:s=" items"})=>e.jsx(J,{isSticky:!0,children:e.jsxs(K,{children:[e.jsx(u,{children:e.jsx(Q,{value:l,placeholder:i,onChange:(n,c)=>{r(c)}})}),l&&e.jsx(u,{children:e.jsx(w,{variant:"link",onClick:()=>r(""),children:"Reset"})}),e.jsx(u,{children:e.jsxs(P,{children:[e.jsx(k,{icon:e.jsx(E,{}),"aria-label":"grid icon button",isSelected:a==="grid",onChange:()=>t("grid")}),e.jsx(k,{icon:e.jsx(N,{}),"aria-label":"list icon button",isSelected:a==="list",onChange:()=>t("list")})]})}),e.jsx(u,{variant:"pagination",gap:{default:"gapMd",md:"gapNone"},style:{"--pf-v6-c-toolbar__item--MinWidth":"max-content"},className:"pf-m-align-self-center",children:e.jsxs(m,{isEditorial:!0,component:D.small,children:[o,s]})})]})}),Y=({section:o,galleryItems:l,hasGridText:r,hasGridImages:a})=>e.jsx(A,{hasGutter:!0,children:l.map(({name:t,img:i,data:s},n)=>{const c=s.link||`/${o}/${t}`,j=s.summary.replace(/<a[^>]*>([^<]+)<\/a>/gm,"$1"),{code:d}=$.convertToReactComponent(`<>${j}</>`),h=new Function("React",d);return e.jsx(B,{span:4,children:e.jsxs(F,{id:t,isClickable:!0,children:[e.jsx(_,{selectableActions:{to:c,selectableActionId:`${t}-input`,selectableActionAriaLabelledby:t,name:`clickable-card-${n}`},children:e.jsx(H,{children:R(t)})}),(a||r)&&e.jsxs(M,{children:[a&&i&&e.jsx("img",{src:i.src,alt:`${t} illustration`}),r&&e.jsx(m,{isEditorial:!0,children:e.jsx(m,{component:"p",children:h(v)})})]}),s.label&&e.jsxs(O,{children:[s.label==="beta"&&e.jsx(x,{color:"blue",isCompact:!0,children:"Beta"}),s.label==="deprecated"&&e.jsx(x,{color:"grey",isCompact:!0,children:"Deprecated"}),s.label==="demo"&&e.jsx(x,{color:"purple",isCompact:!0,children:"Demo"})]})]},n)},n)})}),ee=({section:o,galleryItems:l,hasListText:r,hasListImages:a})=>e.jsx(V,{onSelectDataListItem:()=>{},"aria-label":"gallery-list",children:l.map(({name:t,img:i,data:s},n)=>{const c=s.link||`/${o}/${t}`,j=s.summary.replace(/<a[^>]*>([^<]+)<\/a>/gm,"$1"),{code:d}=$.convertToReactComponent(`<>${j}</>`),h=new Function("React",d);return e.jsx("a",{href:c,className:"ws-section-gallery-item",children:e.jsx(W,{children:e.jsx(Z,{children:e.jsx(q,{dataListCells:[a&&i&&e.jsx(S,{width:1,children:e.jsx("div",{children:e.jsx("img",{src:i.src,alt:`${t} illustration`})})},"illustration"),e.jsxs(S,{width:5,children:[e.jsxs(z,{className:r?"pf-v6-u-mb-md":void 0,children:[e.jsx(I,{isFilled:!0,children:e.jsx(m,{isEditorial:!0,children:e.jsx(m,{component:D.h2,children:e.jsx("span",{children:R(t)})})})}),e.jsxs(I,{children:[s.label==="beta"&&e.jsx(x,{color:"blue",isCompact:!0,children:"Beta"}),s.label==="deprecated"&&e.jsx(x,{color:"grey",isCompact:!0,children:"Deprecated"}),s.label==="demo"&&e.jsx(x,{color:"purple",isCompact:!0,children:"Demo"})]})]}),r&&e.jsx(m,{isEditorial:!0,children:e.jsx(m,{component:"p",children:h(v)})})]},"text-description")]})})})},n)})}),he=({illustrations:o,section:l,galleryItemsData:r,placeholderText:a,countText:t,initialLayout:i="grid",hasGridText:s=!1,hasGridImages:n=!1,hasListText:c=!1,hasListImages:j=!1})=>{const[d,h]=L.useState(""),[g,T]=L.useState(i),C=Object.entries(r).map(([p,b])=>({name:p,img:o?o[U(p)]:void 0,data:b})).sort((p,b)=>p.name.localeCompare(b.name)),y=/[^A-Z0-9]+/gi,G=d.replace(y,""),f=C.filter(p=>new RegExp(G).test(p.name.replace(y,"")));return e.jsxs("div",{className:"ws-section-gallery",children:[e.jsx(X,{galleryItemCount:C.length,searchTerm:d,setSearchTerm:h,layoutView:g,setLayoutView:T,placeholderText:a,countText:t}),g==="grid"&&e.jsx(Y,{section:l,galleryItems:f,hasGridText:s,hasGridImages:n}),g==="list"&&e.jsx(ee,{section:l,galleryItems:f,hasListText:c,hasListImages:j})]})};export{he as SectionGallery};
