try{let e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`1685ef6b-811d-4a41-88a0-a3a6e58506c5`,e._sentryDebugIdIdentifier=`sentry-dbid-1685ef6b-811d-4a41-88a0-a3a6e58506c5`)}catch{}import{o as e}from"./rolldown-runtime-nx40z1zs.js";import{$c as t,Ag as n,Qc as r,Qm as i,Yh as a,Zm as o,_r as s,al as c,gg as l,jg as u,ng as d,nl as f,uh as p}from"./entry.client-mpghtlrl.js";import{b as m,f as h,m as g,p as _,y as v}from"./LibraryPage-h9vymy6t.js";import{n as y,s as b,t as x}from"./useLibraryFilterStrings-dlxionln.js";import{n as S,t as C}from"./filterLabels-mk737m82.js";import{t as w}from"./TagDropdown-ja19iptp.js";var T=n(),E=e(u()),D=d(),O=Object.freeze([]),k=(0,E.memo)(e=>{let t=(0,T.c)(10),{category:n,categoryLabel:r,items:i,selectedIds:a,triggerCountLabel:o,triggerAriaLabel:s,onSelectionChange:c}=e,l;t[0]!==c||t[1]!==n?(l=e=>{c(n,e)},t[0]=c,t[1]=n,t[2]=l):l=t[2];let u=l,d;return t[3]!==o||t[4]!==s||t[5]!==r||t[6]!==i||t[7]!==a||t[8]!==u?(d=(0,D.jsx)(w,{triggerLabel:o,triggerAriaLabel:s,menuLabel:r,items:i,selectedIds:a,selectionMode:`multiple`,commitStrategy:`immediate`,portal:!0,onSelectionChange:u}),t[3]=o,t[4]=s,t[5]=r,t[6]=i,t[7]=a,t[8]=u,t[9]=d):d=t[9],d});k.displayName=`FilterTagDropdown`;var A=s(e=>{let t=(0,T.c)(25),{selectedTags:n,filterLabels:r,shouldShowFresnoTags:i,isNativeAvailable:a,availableProviders:o,hiddenFilterCategories:s,onSelectionChange:c}=e,{locCategories:l}=x(),{locFilterCount:u,locFilterCategoryAriaLabel:d}=v(),f=S(),p,h;t[0]!==r||t[1]!==i||t[2]!==a?(h=j(`access`,r,i,a),t[0]=r,t[1]=i,t[2]=a,t[3]=h):h=t[3],p=h;let _=p,y,b;t[4]!==r||t[5]!==i||t[6]!==a?(b=j(`playState`,r,i,a),t[4]=r,t[5]=i,t[6]=a,t[7]=b):b=t[7],y=b;let C=y,w,E;t[8]!==o||t[9]!==f?(E=M(o,f),t[8]=o,t[9]=f,t[10]=E):E=t[10],w=E;let A=w,N,P;t[11]!==A||t[12]!==_||t[13]!==C?(P={platform:A,access:_,playState:C},t[11]=A,t[12]=_,t[13]=C,t[14]=P):P=t[14],N=P;let F=N,I;t[15]!==s||t[16]!==F||t[17]!==l||t[18]!==n||t[19]!==u||t[20]!==d||t[21]!==c?(I=g.map(e=>{if(s.has(e))return null;let t=F[e];if(t.length===0)return null;let r=l[e](),i=n[e]??O,a=i.length;return(0,D.jsx)(k,{category:e,categoryLabel:r,items:t,selectedIds:i,triggerCountLabel:a>0?`${r} ${u(a)}`:r,triggerAriaLabel:d(r,a),onSelectionChange:c},e)}),t[15]=s,t[16]=F,t[17]=l,t[18]=n,t[19]=u,t[20]=d,t[21]=c,t[22]=I):I=t[22];let L;return t[23]===I?L=t[24]:(L=(0,D.jsx)(`div`,{className:m,children:I}),t[23]=I,t[24]=L),L},()=>{let{library:e,experimentation:n,nativeGameCatalog:s}=o(),{trackUserAction:c}=i(),{data:u}=l(n.queries.featureGates.getOptions()),d=u?.enableFresno??!1,f=u?.enableFresnoDiscovery??!1,m=d&&f,{data:g}=l(s.queries.isNativeAvailable.getOptions()),{data:_}=l(e.queries.selectedTags.getOptions()),{data:v}=l(e.queries.availableProviders.getOptions()),{data:y}=l(e.queries.hiddenFilterCategories.getOptions()),{mutate:x}=a(e.mutations.setSelectedTagsForCategory),S=h(),C=(0,E.useRef)(_??b);C.current=_??b;let w=(0,E.useCallback)((e,n)=>{let r=t({...C.current,[e]:n});x({category:e,tags:n});let i=Object.entries(r).reduce((e,[t,n])=>(n.length>0&&e.push({filterType:t,selectedFilterValues:n}),e),[]);c(p.FilterSetChanged,{filterSet:i},`Press`,{location:`TagDropdown`})},[x,c]);return{selectedTags:_??b,filterLabels:S,shouldShowFresnoTags:m,isNativeAvailable:g??!1,availableProviders:v??[],hiddenFilterCategories:y??r,onSelectionChange:w}});function j(e,t,n,r){let i=_[e]??[],a=[];for(let o of i){if(!n&&f[e]?.includes(o)||!r&&c[e]?.includes(o))continue;let i=t.get(o);i!==void 0&&a.push({id:o,label:i})}return a}function M(e,t){return e.map(e=>({id:e,label:C(e,t)})).sort((e,t)=>e.id===`grts-catalog-provider`?-1:t.id===`grts-catalog-provider`?1:y(e.label,t.label))}export{A as FilterTagsDropdownRowConnection};