1import{r as p,j as o}from"./jsx-runtime-kF-aRxYe.js";import{l as m}from"./lWrap-Jt5rHUnd.js";import{C as W}from"./Checkbox-CFxPz56J.js";import{c as $}from"./classArr-BJpvUMjH.js";import{u as S}from"./useTranslation-vq6sm7dQ.js";import{u as G}from"./useMedia-KmVP3FfB.js";import{T as x}from"./Trans-DxFqbbXX.js";import{h as B,u as Y,f as J}from"./userStore-C_dDgx32.js";import{s as z}from"./sanitizeString-BqG6zJxT.js";import{u as q}from"./useCustomFetcher-CUKVJuXq.js";import{r as A}from"./removeObjectEmptyValue-DwaZTYhp.js";import{f as L}from"./components-B0up9rt8.js";const Q=({checked:e,label:t,name:r,onChange:s})=>{const l=p.useRef(null),{t:n}=S();return p.useEffect(()=>{l.current&&typeof e=="boolean"&&(l.current.checked=e)},[e]),o.jsxs("label",{"data-testid":"filter-radio",className:"flex items-center justify-between md:justify-normal",children:[o.jsx("input",{ref:l,name:r,type:"radio",className:$("order-2 md:order-1","appearance-none","flex-shrink-0","h-6 w-6","border border-solid border-c4s-gray-200 rounded-full","bg-transparent","checked:shadow-[inset_0_0_0_4px_#ffffff]","md:checked:shadow-[inset_0_0_0_4px_#110c1a]","checked:border-c4s-purple-600 checked:before:bg-c4s-purple-600 checked:bg-none checked:bg-c4s-purple-600","hover:checked:bg-c4s-purple-600","focus:checked:bg-c4s-purple-600","transition duration-100","cursor-pointer"),onClick:()=>s(!0)}),o.jsx("span",{className:"peer-checked/field:text-c4s-purple-primary peer-checked/field:md:text-white ml-2 block text-sm peer-checked/field:md:font-medium md:text-white cursor-pointer order-1 md:order-2",children:typeof t=="string"?n(t):t})]})};var h=(e=>(e[e.Checkbox=0]="Checkbox",e[e.Radio=1]="Radio",e))(h||{}),v=(e=>(e.Year="1y",e.Month="30d",e.Week="7d",e.Day="24h",e.All="All",e))(v||{}),F=(e=>(e.MP4="mp4",e.WMV="wmv",e.AVI="avi",e.MOV="mov",e))(F||{}),N=(e=>(e.SD="sd",e.HD="hd",e["4K"]="4k",e))(N||{}),_=(e=>(e.onSale="on_sale",e.Under10="0-10",e.Under25="10-25",e.Under50="25-50",e.Under100="50-100",e.From100="100+",e))(_||{}),k=(e=>(e.Under5="0-5",e.Under10="5-10",e.Under15="10-15",e.Under30="15-30",e.From30="30+",e))(k||{}),O=(e=>(e.STRAIGHT="1",e.GAY="2",e.LESBIAN="3",e.TRANS="5",e))(O||{});function X({type:e,options:t,open:r,onChange:s,filterValue:l,filterGroup:n}){const i=e===h.Checkbox?W:Q,a=p.useRef(null),[f,u]=p.useState(0);return p.useEffect(()=>{a.current&&setTimeout(()=>{a.current&&u(a.current.scrollHeight+24)},0)},[]),o.jsx("div",{style:r&&f?{height:f}:{},className:$("transition-all ease-in-out duration-300",r?"overflow-y-auto":"h-0 opacity-0 overflow-y-hidden pointer-events-none"),children:o.jsx("fieldset",{ref:a,className:"my-2 md:mb-0 space-y-2 px-6 pb-4 md:p-4 md:border-gray-600 md:border rounded-md",children:t.map(d=>o.jsx(i,{swapContentOrder:!0,label:d.label,name:n,checked:l.some(c=>c===d.value),onChange:c=>s(d.value,c)},d.value))})})}const Z=({text:e="Clear",onClick:t,testId:r})=>o.jsx("button",{"data-testid":r,className:"underline text-base text-c4s-purple-600",onClick:t,children:e}),ee=({title:e,count:t,open:r,onChangeVisibility:s,onClearFilter:l})=>o.jsx(o.Fragment,{children:o.jsxs("h3",{"data-testid":"filter-section-title",className:"filter-heading inline-flex justify-between w-full",children:[o.jsxs("button",{type:"button",className:"flex text-white active active:outline-none focus:outline-none",onClick:s,children:[o.jsx("div",{className:$(!r&&"rotate-180","flex self-start control-toggle transition duration-300"),children:o.jsx("i",{className:$("icon-arrow-down text-white text-xl")})}),o.jsxs("div",{className:"flex font-medium text-white text-base ml-2",children:[e,!!t&&o.jsxs("span",{"data-testid":"filter-section-count",className:"ml-1",children:["(",t,")"]})]})]}),!!t&&l&&o.jsx(Z,{testId:"filter-section-clear",onClick:l})]})});function I({title:e,type:t,options:r,onFilterChange:s,filterValue:l,filterGroup:n}){const[i,a]=p.useState(!0),f=l||[],u=()=>{s("",!1)};return o.jsxs("div",{className:"items-center focus:outline-none md:mt-2",children:[o.jsx("div",{className:"hidden md:flex",children:o.jsx(ee,{title:e,count:t===h.Checkbox?f.length:0,open:i,onChangeVisibility:()=>{a(d=>!d)},onClearFilter:t===h.Checkbox?u:void 0})}),o.jsx(X,{filterGroup:n,filterValue:f,type:t,options:r,open:i,onChange:s})]})}const U=[{value:O.STRAIGHT,label:m("Straight")},{value:O.GAY,label:m("Gay")},{value:O.LESBIAN,label:m("Lesbian")},{value:O.TRANS,label:m("Trans")}
1],he=({filterValue:e,onChange:t})=>{const{t:r}=S();return o.jsx(I,{title:r("Content Preference"),filterValue:e||[],type:h.Checkbox,options:U,onFilterChange:t})},te="dropdown-sort-options",R=[{value:v.All,label:m("filter##All")},{value:v.Day,label:m("filter##Day")},{value:v.Week,label:m("filter##Week")},{value:v.Month,label:m("filter##Month")},{value:v.Year,label:m("filter##Year")}],ge=({filterValue:e,onChange:t})=>{const s=G()?"desktop":"mobile",{t:l}=S();return o.jsx(I,{title:l("Date Added"),filterGroup:`${te}-${s}`,filterValue:(e||[]).length?e:[v.All],type:h.Radio,options:R,onFilterChange:(n,i)=>n===v.All?t((e==null?void 0:e[0])||"",!1):t(n,i)},s)},V=[{value:k.Under5,label:e=>o.jsx(x,{i18nKey:"filter##Under {{limit}} Mins",values:{limit:"5"},lang:e}),shortLabel:"0-5 Min"},{value:k.Under10,label:e=>o.jsx(x,{i18nKey:"filter##{{start}} to {{end}} Mins",values:{start:"5",end:"10"},lang:e}),shortLabel:"5-10 Min"},{value:k.Under15,label:e=>o.jsx(x,{i18nKey:"filter##{{start}} to {{end}} Mins",values:{start:"10",end:"15"},lang:e}),shortLabel:"10-15 Min"},{value:k.Under30,label:e=>o.jsx(x,{i18nKey:"filter##{{start}} to {{end}} Mins",values:{start:"15",end:"30"},lang:e}),shortLabel:"15-30 Min"},{value:k.From30,label:e=>o.jsx(x,{i18nKey:"filter##{{num}} Mins",values:{num:"30+"},lang:e}),shortLabel:"30+ Min"}],ve=({filterValue:e,onChange:t})=>{const{t:r,i18n:s}=S(),l=p.useMemo(()=>V.map(n=>({...n,label:n.label(s.language)})),[s.language]);return o.jsx(I,{title:r("Duration"),filterValue:e||[],type:h.Checkbox,options:l,onFilterChange:t})},K=[{value:F.MP4,label:"MP4"},{value:F.WMV,label:"WMV"},{value:F.AVI,label:"AVI"},{value:F.MOV,label:"MOV"}],ye=({filterValue:e,onChange:t})=>{const{t:r}=S();return o.jsx(I,{title:r("Format"),filterValue:e||[],type:h.Checkbox,options:K,onFilterChange:t})},P=[{value:_.onSale,label:e=>o.jsx(x,{i18nKey:"On Sale",lang:e})},{value:_.Under10,label:e=>o.jsx(x,{i18nKey:"filter##Under {{limit}}",values:{limit:"$10"},lang:e}),shortLabel:"$0-10"},{value:_.Under25,label:e=>o.jsx(x,{i18nKey:"filter##{{start}} to {{end}}",values:{start:"$10",end:"$25"},lang:e}),shortLabel:"$10-25"},{value:_.Under50,label:e=>o.jsx(x,{i18nKey:"filter##{{start}} to {{end}}",values:{start:"$25",end:"$50"},lang:e}),shortLabel:"$25-50"},{value:_.Under100,label:e=>o.jsx(x,{i18nKey:"filter##{{start}} to {{end}}",values:{start:"$50",end:"$100"},lang:e}),shortLabel:"$50-100"},{value:_.From100,label:"$100+"}],_e=({filterValue:e,onChange:t})=>{const{t:r,i18n:s}=S(),l=p.useMemo(()=>P.map(n=>({...n,label:typeof n.label=="string"?n.label:n.label(s.language)})),[s.language]);return o.jsx(I,{title:r("Price"),filterValue:e||[],type:h.Checkbox,options:l,onFilterChange:t})},D=[{value:N.SD,label:"SD"},{value:N.HD,label:"HD"},{value:N["4K"],label:"4K"}],Se=({filterValue:e,onChange:t})=>{const{t:r}=S();return o.jsx(I,{title:r("Resolution"),filterValue:e||[],type:h.Checkbox,options:D,onFilterChange:t})};var w=(e=>(e.MostRecent="mostrecent",e.MostPopular="bestmatch",e))(w||{});const je=[{value:"mostrecent",label:m("Most Recent")},{value:"bestmatch",label:m("Most Popular")}],ke=[...R,...V,...P,...D,...K,...U],Ie=(e,t,r=w.MostPopular)=>{var d;const s=e.split("/");let l=t,n=s.lastIndexOf("filters");const i=((d=s[n+1])==null?void 0:d.indexOf("cp"))??-1,a=s.lastIndexOf("category");if(i>-1||a>-1){const c=i>-1?s[n+1].slice(i+2).split("-")[0].split("_"):[],g=(l==null?void 0:l.indexOf("cp"))??-1,b=g>-1?l.slice(g+2).split("-")[0].split("_"):[];if(a!==-1){const y=c.includes(s[a+1]),C=b.includes(s[a+1]);if(y&&!C)s[a+1]="0";else if(!y&&!C&&s[a+1]!=="0"&&!isNaN(Number(s[a+1])))if(b.push(s[a+1]),t)if(g>-1)l=`${l.slice(0,g+2)}${[b.join("_"),...s[n+1].slice(i+2).split("-").slice(1)].join("-")}`;else{const j=l.split("-");j.push(`cp${b.join("_")}`),l=j.join("-")}else l=`cp${b.join("_")}`}}const f=s.lastIndexOf("sortclips"),u=!l&&(f===-1||s[f+1]===r);if(s.lastIndexOf("sortstudios")<0&&!u)s.push("sortstudios"),s.push("bestmatch");else if(u&&s.lastIndexOf("sortstudios")>=0){const c=s.lastIndexOf("sortstudios");s.splice(c,2)}if(s.lastIndexOf("sortclips")<0&&!u)s.splice(s.lastIndexOf("sortstudios")+2,0,"s
1ortclips",r||"bestmatch");else if(u&&s.lastIndexOf("sortclips")>=0){const c=s.lastIndexOf("sortclips");s.splice(c,2)}if(s.lastIndexOf("sortcategories")<0&&!u)s.splice(s.lastIndexOf("sortclips")+2,0,"sortcategories","bestmatch");else if(u&&s.lastIndexOf("sortcategories")>=0){const c=s.lastIndexOf("sortcategories");s.splice(c,2)}return n=s.lastIndexOf("filters"),n>=0?l?s[n+1]=l:s.splice(n,s[n+1]?2:1):l!=null&&l.length&&(s.push("filters"),s.push(l)),s.join("/")},se=e=>{let t=[];return e.date&&t.push("d"+e.date),e.format&&(t=[...t,"f"+e.format.sort().join("_and_")]),e.resolution&&(t=[...t,"r"+e.resolution.sort().join("_and_")]),e.price&&(t=[...t,"p"+e.price.sort().map(r=>r.replace("-","_")).join("_and_")]),e.duration&&(t=[...t,"l"+e.duration.sort().map(r=>r.replace("-","_")).join("_and_")]),e.category_id&&(t=[...t,(e.category_id.length>0?"cp":"")+e.category_id.join("_")]),e.content_preference&&(t=[...t,"o"+e.content_preference.sort().join("_and_")]),e.performer_id&&(t=[...t,(e.performer_id.length>0?"ap":"")+e.performer_id.join("_")]),t.join("-")},Ce=e=>e.split("-").reduce((r,s)=>{let l,n;switch(s[0]){case"d":l="date",n=[s.slice(1)];break;case"f":l="format",n=s.slice(1).split("_and_");break;case"r":l="resolution",n=s.slice(1).split("_and_");break;case"o":l="content_preference",n=s.slice(1).split("_and_");break;case"p":l="price",n=s.slice(1).split("_and_").map(i=>i!=="on_sale"?i.replace("_","-"):i);break;case"l":l="duration",n=s.slice(1).split("_and_").map(i=>i.replace("_","-"));break;case"c":s[1]==="p"&&(l="category_id",n=s.slice(2).split("_"));break;case"a":s[1]==="p"&&(l="performer_id",n=s.slice(2).split("_"));break}return l?{...r,[l]:n}:r},{date:null,format:null,duration:null,resolution:null,price:null,content_preference:null}),Fe=e=>{const{store:t}=B();return p.useCallback(r=>{const s=z((typeof r.keyword>"u"?t.keyword:r.keyword)||""),l=typeof r.category>"u"?t.category:r.category,n=typeof r.clipsPage>"u"?t.clipsPage:r.clipsPage,i=typeof r.clipsSort>"u"?t.clipsSort:r.clipsSort,a=se((typeof r.filters>"u"?t.filters:r.filters)||{});return`/clips/search${s?`/${s}`:""}${Number(l)||s||n&&n!=1?`/category/${l||0}/storesPage/1/clipsPage/${n||1}`:""}${i!==(e||w.MostPopular)||a?`/sortstudios/bestmatch/sortclips/${i||e||w.MostPopular}/sortcategories/bestmatch${a?`/filters/${a}`:""}`:""}`},[t])},E=(e,t)=>t.find(r=>r.filter===e.filter&&r.categoryLabels.length===e.categoryLabels.length&&r.categoryLabels.every(s=>e.categoryLabels.includes(s))&&e.keyword==r.keyword&&e.categoryId==r.categoryId),re=(e,t)=>!!E(e,t),Oe=(e,t)=>{if(re(e,t))return!1;let r=t;return r.length>=25?r=[e,...r.slice(0,24)]:r=[e,...r],r},Me=(e,t)=>{let r=t;const s=E(e,r);return s?(r=[...t],r.splice(r.indexOf(s),1),r):!1},le=e=>(e==null?void 0:e.map(t=>{var r,s;return{name:(t==null?void 0:t.keyword)||((r=t.categoryLabels)==null?void 0:r[0])||((s=t.performerNames)==null?void 0:s[0])||"Saved Filter Search",parameters:{filter:t==null?void 0:t.filter,category_labels:(t==null?void 0:t.categoryLabels)||[],performer_names:(t==null?void 0:t.performerNames)||[],text:t==null?void 0:t.keyword,...(t==null?void 0:t.categoryId)&&{category_id:t.categoryId},sort:t==null?void 0:t.sort}}}))||[],Ne=()=>{const{store:{user:e}}=Y(),{store:t,setStore:r}=J(),[s,l]=p.useState(t),[n,i]=p.useState(!1),a=L(),f=q();p.useEffect(()=>{e&&a.load("/api/saved-searches")},[]),p.useEffect(()=>{var d,c,g,b,y;if(a.state==="idle"&&a.data&&(d=a.data)!=null&&d.success&&(c=a.data)!=null&&c.savedSearches)if(t.length){const C=[...t,...(g=a.data)==null?void 0:g.savedSearches].filter((j,M,T)=>M===T.findIndex(H=>JSON.stringify(A(H))===JSON.stringify(A(j))));u(C).then(j=>{var M;l(j?C:(M=a.data)==null?void 0:M.savedSearches)})}else l((b=a.data)==null?void 0:b.savedSearches),r((y=a.data)==null?void 0:y.savedSearches)},[a]);const u=d=>(i(!0),new Promise(async(c,g)=>{try{const b=JSON.stringify({searches:le(d)});f.submit({body:b},"/api/saved-searches",{method:"PUT"}).then(y=>{c(y.success),i(!1)})}catch{g(!1),i(!1)}}));return{userSavedSearches:s,updateUserSavedSearches:u,isLoading:n}};export{Z as C,ge as D,X as F,_e as P,Se as R,w as S,Fe as a,Ce as b,ke as c,h as d,se as e,Oe as f,Ie as g,ye as h,re as i,he as j,ve as k,O as l,Me as r,je as s,Ne as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.