1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,664963,(e,t,s)=>{"use strict";Object.defineProperty(s,"__esModule",{value:!0}),s.pluralize=f,s.singularize=m,s.inflect=function(e,t,s,n){return isNaN(t)?e:1===t?h(e,r,i,s):h(e,o,i,n)},s.camelize=g,s.underscore=x,s.humanize=v,s.capitalize=y,s.dasherize=b,s.titleize=w,s.demodulize=E,s.tableize=S,s.classify=_,s.foreignKey=C,s.ordinalize=j,s.transform=function(e,t){let s=t.length;for(let i=0;i<s;i++){let s=T[t[i]];s&&(e=s(e))}return e};let i=["accommodation","adulthood","advertising","advice","aggression","aid","air","aircraft","alcohol","anger","applause","arithmetic","assistance","athletics","bacon","baggage","beef","biology","blood","botany","bread","butter","carbon","cardboard","cash","chalk","chaos","chess","crossroads","countryside","dancing","deer","dignity","dirt","dust","economics","education","electricity","engineering","enjoyment","envy","equipment","ethics","evidence","evolution","fame","fiction","flour","flu","food","fuel","fun","furniture","gallows","garbage","garlic","genetics","gold","golf","gossip","gratitude","grief","guilt","gymnastics","happiness","hardware","harm","hate","hatred","health","heat","help","homework","honesty","honey","hospitality","housework","humour","hunger","hydrogen","ice","importance","inflation","information","innocence","iron","irony","jam","jewelry","judo","karate","knowledge","lack","laughter","lava","leather","leisure","lightning","linguine","linguini","linguistics","literature","litter","livestock","logic","loneliness","luck","luggage","macaroni","machinery","magic","management","mankind","marble","mathematics","mayonnaise","measles","methane","milk","minus","money","mud","music","mumps","nature","news","nitrogen","nonsense","nurture","nutrition","obedience","obesity","oxygen","pasta","patience","physics","poetry","pollution","poverty","pride","psychology","publicity","punctuation","quartz","racism","relaxation","reliability","research","respect","revenge","rice","rubbish","rum","safety","scenery","seafood","seaside","series","shame","sheep","shopping","sleep","smoke","smoking","snow","soap","software","soil","spaghetti","species","steam","stuff","stupidity","sunshine","symmetry","tennis","thirst","thunder","timber","traffic","transportation","trust","underwear","unemployment","unity","validity","veal","vegetation","vegetarianism","vengeance","violence","vitality","warmth","wealth","weather","welfare","wheat","wildlife","wisdom","yoga","zinc","zoology"],n={plural:{men:RegExp("^(m|wom)en$","gi"),people:/(pe)ople$/gi,children:/(child)ren$/gi,tia:/([ti])a$/gi,analyses:RegExp("((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$","gi"),databases:/(database)s$/gi,drives:/(drive)s$/gi,hives:RegExp("(hi|ti)ves$","gi"),curves:/(curve)s$/gi,lrves:/([lr])ves$/gi,aves:/([a])ves$/gi,foves:RegExp("([^fo])ves$","gi"),movies:/(m)ovies$/gi,aeiouyies:RegExp("([^aeiouy]|qu)ies$","gi"),series:/(s)eries$/gi,xes:RegExp("(x|ch|ss|sh)es$","gi"),mice:RegExp("([m|l])ice$","gi"),buses:/(bus)es$/gi,oes:/(o)es$/gi,shoes:/(shoe)s$/gi,crises:RegExp("(cris|ax|test)es$","gi"),octopuses:RegExp("(octop|vir)uses$","gi"),aliases:RegExp("(alias|canvas|status|campus)es$","gi"),summonses:RegExp("^(summons|bonus)es$","gi"),oxen:RegExp("^(ox)en","gi"),matrices:/(matr)ices$/gi,vertices:RegExp("(vert|ind)ices$","gi"),feet:RegExp("^feet$","gi"),teeth:RegExp("^teeth$","gi"),geese:RegExp("^geese$","gi"),quizzes:/(quiz)zes$/gi,whereases:RegExp("^(whereas)es$","gi"),criteria:RegExp("^(criteri)a$","gi"),genera:RegExp("^genera$","gi"),ss:/ss$/gi,s:/s$/gi},singular:{man:RegExp("^(m|wom)an$","gi"),person:/(pe)rson$/gi,child:/(child)$/gi,drive:/(drive)$/gi,ox:RegExp("^(ox)$","gi"),axis:RegExp("(ax|test)is$","gi"),octopus:RegExp("(octop|vir)us$","gi"),alias:RegExp("(alias|status|canvas|campus)$","gi"),summons:RegExp("^(summons|bonus)$","gi"),bus:/(bu)s$/gi,buffalo:RegExp("(buffal|tomat|potat)o$","gi"),tium:/([ti])um$/gi,sis:/sis$/gi,ffe:RegExp("(?:([^f])fe|([lr])f)$","gi"),focus:RegExp("^(focus)$","gi"),hive:RegExp("(hi|ti)ve$","gi"),aeiouyy:RegExp("([^aeiouy]|qu)y$","gi"),x:RegExp("(x|ch|ss|sh)$","gi"),matrix:/(matr)ix$/gi,vertex:RegExp("(vert|ind)ex$","gi"),mouse:RegExp("([m|l])ouse$","gi"),foot:RegExp("^foot$","gi"),tooth:RegExp("^tooth$","gi"),goose:RegExp("^goose$","gi"),quiz:/(quiz)$/gi,whereas:RegExp("^(whereas)$","gi"),criterion:RegExp("^(criteri)on$","gi"),genus:RegExp("^genus$","gi"),s:/s$/gi,common:/$/gi}},o=[[n.plural.men],[n.plural.people],[n.plural.children],[n.plural.tia],[n.plural.analyses],[n.plural.databases],[n.plural.drives],[n.plural.hives],[n.plural.curves],[n.plural.lrves],[n.plural.foves],[n.plural.aeiouyies],[n.plural.series],[n.plural.movies],[n.plural.xes],[n.plural.mice],[n.plural.buses],[n.plural.oes],[n.plural.shoes],[n.plural.crises],[n.plural.octopuses],[n.plural.aliases],[n.plural.summonses],[n.plural.oxen],[n.plural.matrices],[n.plural.feet],[n.plural.teeth],[n.plural.geese],[n.plural.quizzes],[n.plural.whereases],[n.plural.criteria],[n.plural.genera],[n.singular.man,"$1en"],[n.singular.person,"$1ople"],[n.singular.child,"$1ren"],[n.singular.drive,"$1s"],[n.singular.ox,"$1en"],[n.singular.axis,"$1es"],[n.singular.octopus,"$1uses"],[n.singular.alias,"$1es"],[n.singular.summons,"$1es"],[n.singular.bus,"$1ses"],[n.singular.buffalo,"$1oes"],[n.singular.tium,"$1a"],[n.singular.sis,"ses"],[n.singular.ffe,"$1$2ves"],[n.singular.focus,"$1es"],[n.singular.hive,"$1ves"],[n.singular.aeiouyy,"$1ies"],[n.singular.matrix,"$1ices"],[n.singular.vertex,"$1ices"],[n.singular.x,"$1es"],[n.singular.mouse,"$1ice"],[n.singular.foot,"feet"],[n.singular.tooth,"teeth"],[n.singular.goose,"geese"],[n.singular.quiz,"$1zes"],[n.singular.whereas,"$1es"],[n.singular.criterion,"$1a"],[n.singular.genus,"genera"],[n.singular.s,"s"],[n.singular.common,"s"]],r=[[n.singular.man],[n.singular.person],[n.singular.child],[n.singular.drive],[n.singular.ox],[n.singular.axis
1],[n.singular.octopus],[n.singular.alias],[n.singular.summons],[n.singular.bus],[n.singular.buffalo],[n.singular.tium],[n.singular.sis],[n.singular.ffe],[n.singular.focus],[n.singular.hive],[n.singular.aeiouyy],[n.singular.x],[n.singular.matrix],[n.singular.mouse],[n.singular.foot],[n.singular.tooth],[n.singular.goose],[n.singular.quiz],[n.singular.whereas],[n.singular.criterion],[n.singular.genus],[n.plural.men,"$1an"],[n.plural.people,"$1rson"],[n.plural.children,"$1"],[n.plural.databases,"$1"],[n.plural.drives,"$1"],[n.plural.genera,"genus"],[n.plural.criteria,"$1on"],[n.plural.tia,"$1um"],[n.plural.analyses,"$1$2sis"],[n.plural.hives,"$1ve"],[n.plural.curves,"$1"],[n.plural.lrves,"$1f"],[n.plural.aves,"$1ve"],[n.plural.foves,"$1fe"],[n.plural.movies,"$1ovie"],[n.plural.aeiouyies,"$1y"],[n.plural.series,"$1eries"],[n.plural.xes,"$1"],[n.plural.mice,"$1ouse"],[n.plural.buses,"$1"],[n.plural.oes,"$1"],[n.plural.shoes,"$1"],[n.plural.crises,"$1is"],[n.plural.octopuses,"$1us"],[n.plural.aliases,"$1"],[n.plural.summonses,"$1"],[n.plural.oxen,"$1"],[n.plural.matrices,"$1ix"],[n.plural.vertices,"$1ex"],[n.plural.feet,"foot"],[n.plural.teeth,"tooth"],[n.plural.geese,"goose"],[n.plural.quizzes,"$1"],[n.plural.whereases,"$1"],[n.plural.ss,"ss"],[n.plural.s,""]],a=["and","or","nor","a","an","the","so","but","to","of","at","by","from","into","on","onto","off","out","in","over","with","for"],l=RegExp("(_ids|_id)$","g"),u=/_/g,c=RegExp("[ _]","g"),d=/([A-Z])/g,p=RegExp("^_");function h(e,t,s,i){if(i)return i;if(s.includes(e.toLocaleLowerCase()))return e;for(let s of t)if(e.match(s[0])){if(void 0!==s[1])return e.replace(s[0],s[1]);break}return e}function f(e,t){return h(e,o,i,t)}function m(e,t){return h(e,r,i,t)}function g(e,t){let s,i,n,o,r=e.split("/"),a=r.length;for(let e=0;e<a;e++){for(s=r[e].split("_"),i=0,n=s.length;i<n;i++)0!==i&&(s[i]=s[i].toLowerCase()),o=s[i].charAt(0),o=t&&0===e&&0===i?o.toLowerCase():o.toUpperCase(),s[i]=o+s[i].substring(1);r[e]=s.join("")}return r.join("::")}function x(e,t){if(t&&e===e.toUpperCase())return e;let s=e.split("::"),i=s.length;for(let e=0;e<i;e++)s[e]=s[e].replace(d,"_$1"),s[e]=s[e].replace(p,"");return s.join("/").toLowerCase()}function v(e,t){return e=(e=(e=e.toLowerCase()).replace(l,"")).replace(u," "),t||(e=y(e)),e}function y(e){return(e=e.toLowerCase()).substring(0,1).toUpperCase()+e.substring(1)}function b(e){return e.replace(c,"-")}function w(e){let t,s,i=(e=e.toLowerCase().replace(u," ")).split(" "),n=i.length;for(let e=0;e<n;e++){s=(t=i[e].split("-")).length;for(let e=0;e<s;e++)0>a.indexOf(t[e].toLowerCase())&&(t[e]=y(t[e]));i[e]=t.join("-")}return(e=i.join(" ")).substring(0,1).toUpperCase()+e.substring(1)}function E(e){let t=e.split("::");return t[t.length-1]}function S(e){return f(e=x(e))}function _(e){return m(e=g(e))}function C(e,t){return x(e=E(e))+(t?"":"_")+"id"}function j(e){let t=e.split(" "),s=t.length;for(let e=0;e<s;e++)if(!isNaN(parseInt(t[e],10))){let s=t[e].substring(t[e].length-2),i=t[e].substring(t[e].length-1),n="th";"11"!=s&&"12"!=s&&"13"!=s&&("1"===i?n="st":"2"===i?n="nd":"3"===i&&(n="rd")),t[e]+=n}return t.join(" ")}let T={pluralize:f,singularize:m,camelize:g,underscore:x,humanize:v,capitalize:y,dasherize:b,titleize:w,demodulize:E,tableize:S,classify:_,foreignKey:C,ordinalize:j}},378864,(e,t,s)=>{"use strict";var i=e.r(191788),n=e.r(890979),o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=n.useSyncExternalStore,a=i.useRef,l=i.useEffect,u=i.useMemo,c=i.useDebugValue;s.useSyncExternalStoreWithSelector=function(e,t,s,i,n){var d=a(null);if(null===d.current){var p={hasValue:!1,value:null};d.current=p}else p=d.current;var h=r(e,(d=u(function(){function e(e){if(!l){if(l=!0,r=e,e=i(e),void 0!==n&&p.hasValue){var t=p.value;if(n(t,e))return a=t}return a=e}if(t=a,o(r,e))return t;var s=i(e);return void 0!==n&&n(t,s)?(r=e,t):(r=e,a=s)}var r,a,l=!1,u=void 0===s?null:s;return[function(){return e(t())},null===u?void 0:function(){return e(u())}]},[t,s,i,n]))[0],d[1]);return l(function(){p.hasValue=!0,p.value=h},[h]),c(h),h}},191604,(e,t,s)=>{"use strict";
1t.exports=e.r(378864)},890861,e=>{"use strict";let t,s,i,n;var o=e.i(391398),r=e.i(239381),a=e.i(275250),l=e.i(697953),u=e.i(203828),c=e.i(869436);function d({onClick:e}){return(0,o.jsx)("div",{className:"flex justify-center items-center pt-4",children:(0,o.jsxs)("div",{className:"relative group rounded-lg cursor-pointer p-10",onClick:()=>{(0,c.trackEvent)("Load Page of Memes",{location:"Manual - Load More Button"}),e()},children:[(0,o.jsx)("div",{className:"bg-black/10 absolute inset-0 rounded-lg hidden group-hover:block"}),(0,o.jsx)("span",{className:"fa-solid fa-plus text-5xl text-secondary"})]})})}var p=e.i(594677),h=e.i(228649),f=e.i(781377),m=e.i(957791),g=e.i(191788),x=e.i(776438),v=e.i(862095),y=e.i(426406),b=e.i(850023),w=e.i(512079),E=e.i(572132),S=e.i(760675),_=e.i(199832),C=e.i(97011),j=e.i(594146),T=e.i(420993),k=e.i(600742);function I({onClick:e,onSelectFiles:t,onPaste:s,dragActiveClass:i}){let n=(0,g.useRef)(null);return(0,o.jsxs)("div",{className:(0,C.twMerge)("transition-all flex flex-col items-center bg-default hover:bg-secondary","gap-2 relative overflow-hidden rounded-lg shadow ","border border-secondary border-dashed px-4 py-4 cursor-pointer text-sm",i),onClick:()=>e?e():n?.current?.click(),children:[(0,o.jsx)("input",{type:"file",ref:n,accept:`${_.supportedImageContentType},${_.supportedVideoContentTypes}`,multiple:!0,className:"hidden",onChange:e=>{t&&e.target.files?.length&&t(e.target.files)}}),(0,o.jsx)("label",{htmlFor:"file-upload",className:"relative cursor-pointer rounded-md font-semibold",children:(0,o.jsx)("span",{children:"Upload Memes"})}),(0,o.jsx)("i",{className:"block fa-duotone fa-image text-purple-lighter fa-2xl my-4"}),(0,o.jsx)("div",{className:"w-full flex flex-col items-center justify-center",children:(0,o.jsx)("span",{className:"max-sm:hidden",children:"Drag & drop your files or"})}),(0,o.jsx)(S.default,{horizantalFullWidth:!0,color:"secondary",className:"bg-tertiary",placeholder:"Paste Image or URL",inputClassName:"text-center",onClick:e=>{e.preventDefault(),e.stopPropagation()},onPaste:e=>{e.preventDefault(),e.stopPropagation(),s?.(e)}}),(0,o.jsxs)(j.default,{color:"gray",size:"xs",textCenter:!0,children:["Recommended Size 300x200px",(0,o.jsx)("br",{}),"Maximum file size 10MB"]})]})}function U({depot:e,onClose:t,disablePaste:s,disableFileDrop:i}){let{isSignedIn:n}=(0,E.useMeContext)(),{uploadFiles:r,finishedUploading:a,abortUploads:l,uploads:c,reset:d,stateMaps:p,aborted:h}=(0,v.default)({depot:e}),f=(0,g.useCallback)(e=>{r(Array.from(e),{keepPrevious:!0})},[r]),{dragActive:S,handleDrag:_,handleDrop:C}=(0,m.default)(e=>{n&&f(Array.from(e))},{disabled:i||!!c.length}),j=(0,x.default)(e=>{f([e])}),U=(0,g.useCallback)(e=>{s||!n||c.length||j(e)},[s,n,j,c.length]);(0,g.useEffect)(()=>(document.addEventListener("paste",U),document.addEventListener("dragenter",_),document.addEventListener("dragover",_),document.addEventListener("dragleave",_),document.addEventListener("drop",C),()=>{document.removeEventListener("paste",U),document.removeEventListener("dragenter",_),document.removeEventListener("dragover",_),document.removeEventListener("dragleave",_),document.removeEventListener("drop",C)}),[U,_,C]);let A=(0,w.useConfirmPromptModal)(),M=(0,g.useCallback)(()=>{a||!c.length?(t(),d()):A({title:"Stop Upload",body:"Are you sure? This will cause all active uploads to stop.",cancelLabel:"Nevermind",confirmLabel:"I'm sure",onClick:async()=>{await l(),d(),t()}})},[a,c.length,t,d,A,l]),{route:P,query:$}=(0,u.useRouter)();return n?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(k.default,{show:!h&&!!c.length,onClose:M,children:(0,o.jsxs)("div",{className:"relative sm:h-auto sm:rounded-2xl sm:shadow-xl sm:w-[450px] h-full flex flex-col overflow-hidden p-6 space-y-4",children:[(0,o.jsxs)("div",{className:"space-y-1 mb-1",children:[(0,o.jsx)("p",{className:"font-medium",children:"Uploading memes"}),(0,o.jsx)("p",{className:"text-secondary text-sm",children:"Use the area below to upload your memes"})]}),(0,o.jsx)(T.default,{uploads:c,finished:a,uploadFiles:f,stateMaps:p,onClose:M,skipDepotSelect:!0,depot:e})]})}),S&&(0,o.jsx)("div",{className:"fixed inset-0 bg-black/90 z-50"}),(0,o.jsx)(I,{onSelectFiles:e=>f(Array.from(e)),onPaste:U,dragActiveClass:S&&"z-100"})]}):(0,o.jsx)(b.default,{trigger:e=>(0,o.jsx)(I,{onClick:e}),children:(0,o.jsx)(y.default,{title:"Just a Second, Stranger!",description:"If you want to start adding to the world's greatest memebase in the clouds, you need an account.",redirectUrl:P.replace("[depotSlug]",$.depotSlug)})})}var A=e.i(902732),M=e.i(776547),P=e.i(950323),$=e.i(470696),O=e.i(636023),R=e.i(126019),N=e.i(889340),L=e.i(687378),D=e.i(754149),F=e.i(234991),B=e.i(32862),z=e.i(41158);function W({depot:e,memes:t,onClose:s=L.default}){let{query:i}=(0,u.useRouter)(),n=i.slug,r=n?t.find(e=>e.slug===n):void 0,[a,l]=(0,g.useState)([]),c=a.length,d=a.length===t.length,{theme:p}=(0,B.useClientContext)(),{moderate:h,saving:m}=function(e){let[t,s]=(0,g.useState)(!1);return{moderate:(0,g.useCallback)(async(t,i)=>{try{s(!0),await M.default.post(`/api/depots/${e.slug}/moderate-memes`,{memeSlugs:i,approve:t},{onErrorTracking:"Meme - Approve/Reject Moderation - Error"})}catch(e){}s(!1)},[e.slug]),saving:t}}(e),x=(0,g.useCallback)(async e=>{await h(e,a),s()},[h,s,a]);return(0,o.jsx)(k.default,{show:t.length>0,onClose:s,children:(0,o.jsxs)(o.Fragment,{children:[r&&(0,o.jsx)(f.default,{depot:e,meme:r,memes:t}),(0,o.jsxs)("div",{className:"relative p-4 overflow-hidden flex flex-col",children:[(0,o.jsx)("p",{className:"text-default font-medium text-normal",children:"Approve Meme Submissions"}),(0,o.jsx)("p",{className:"text-secondary text-sm pb-4",children:"Select meme submissions to approve to your depot."}),(0,o.jsxs)("div",{className:"flex items-center space-x-2 cursor-pointer pb-2",onClick:()=>l(d?[]:t.map(e=>e.slug)),children:[(0,o.jsx)("input",{id:"comments","aria-describedby":"
1comments-description",name:"comments",type:"checkbox",checked:d,onChange:e=>{e.stopPropagation(),l(d?[]:t.map(e=>e.slug))},className:"h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-600 cursor-pointer"}),(0,o.jsxs)("p",{className:"text-default text-sm",children:["Select all (",t.length,")"]})]}),(0,o.jsx)("div",{className:"flex-1 p-2 rounded-md bg-default sm:w-[500px] md:w-[700px] lg:w-[800px] overflow-auto items-center gap-2 sm:gap-4 grid grid-cols-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-3 2xl:grid-cols-4",children:t.map(t=>{var s;let n,r;return(0,o.jsxs)("div",{className:(0,C.twMerge)("flex-1 relative shadow-sm border rounded-lg p-2 cursor-pointer",a.includes(t.slug)?"border-secondary bg-secondary/30":"border-secondary/50"),onClick:()=>l(a.includes(t.slug)?(0,D.default)(a,t.slug):[...a,t.slug]),children:[(0,o.jsx)("div",{className:"overflow-hidden pb-4",children:(0,o.jsxs)(z.default,{href:{query:{...i,depotSlug:t.depot.slug,slug:t.slug}},as:`/d/${e.slug}/${t.slug}`,shallow:!0,className:"relative block h-40 cursor-zoom-in",onClick:e=>e.stopPropagation(),children:[t.type===$.MemeType.VIDEO&&(0,o.jsx)("div",{className:"absolute inset-0 flex justify-center items-center z-10 opacity-90",children:(0,o.jsx)("i",{className:"fa-duotone fa-circle-play text-5xl bg-tertiary rounded-full"})}),(0,o.jsx)(R.default,{placeholder:"blur",blurDataURL:t.blur_data_url||(0,F.getBlankImagePixels)(p),src:t.cf_asset_id,alt:t.title,sizes:"(max-width: 640px) 50vw, 25vw",loader:(0,N.autoImageLoader)(t,!0),className:"overflow-hidden object-contain",fill:!0})]})}),(0,o.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,o.jsxs)("div",{className:"flex-1 space-y-1",children:[(0,o.jsxs)("p",{className:"text-default text-sm font-semibold leading-none",children:["by"," ",t.uploader.username||`User #${t.uploader.uuid}`]}),(0,o.jsx)("p",{className:"text-default text-sm leading-none",children:(s=new Date(t.created_at),n=new Intl.RelativeTimeFormat("en",{numeric:"auto"}),r=Math.round((new Date(s).getTime()-new Date().getTime())/864e5),n.format(r,"day"))})]}),(0,o.jsx)(z.default,{href:`/d/${e.slug}/${t.slug}`,target:"_blank",onClick:e=>{e.stopPropagation()},children:(0,o.jsx)("i",{className:"fa-regular fa-external-link text-link transition-all"})})]})]},t.slug)})}),(0,o.jsxs)("div",{className:"mt-5 sm:mt-6 gap-2 flex max-sm:flex-col justify-end",children:[(0,o.jsx)(O.default,{size:"md",label:c?`Reject ${c} ${1===a.length?"Meme":"Memes"}`:"Reject",color:"red",icon:"fa-xmark",disabled:!c||m,onClick:()=>x(!1)}),(0,o.jsx)(O.default,{size:"md",label:c?`Approve ${c} ${1===a.length?"Meme":"Memes"}`:"Approve",color:"primary",icon:"fa-check",disabled:!c||m,onClick:()=>x(!0)})]})]})]})})}function K({depot:e,reloadMemes:t}){let{memes:s,reload:i,isLoading:n}=function(e){let{isDepotOwner:t}=(0,E.useMeContext)(),{data:s,mutate:i,isLoading:n}=(0,P.default)(t(e.slug)&&e.require_moderation?`/api/depots/${e.slug}/pending-memes`:null,M.default);return{memes:s?s.memes:[],reload:i,isLoading:n}}(e),r=(0,g.useCallback)(async()=>{await Promise.all([t(),i()])},[i,t]),a=s.length;return(0,o.jsxs)("div",{className:"bg-secondary border border-dashed border-tertiary relative overflow-hidden rounded-lg shadow px-3 py-3 space-y-3",children:[(0,o.jsxs)("div",{className:"flex flex-col items-center justify-center py-2.5 px-1 space-y-2",children:[(0,o.jsx)("span",{className:"block fa-solid fa-clock-rotate-left text-amber-500 text-3xl"}),n?(0,o.jsxs)("p",{className:"text-center text-sm text-secondary",children:["Loading ",(0,o.jsx)("i",{className:"fa-spinner fa-spin fa-regular"})]}):(0,o.jsxs)("p",{className:"text-center text-sm text-amber-600",children:["There ",1===a?"is ":"are ",(0,o.jsxs)("span",{className:"font-medium",children:[a," ",1===a?"meme ":"memes "]}),"pending your approval"]})]}),(0,o.jsx)(b.default,{trigger:e=>(0,o.jsx)(O.default,{size:"md",onClick:e,label:"View Submissions",color:"primary",fullWidth:!0}),onClose:r,onOpenUrlQueryParam:"reviewingMemes",children:(0,o.jsx)(W,{depot:e,memes:s})})]})}var V=e.i(718317),q=e.i(80784);async function H(e){return await M.default.post(e)}function G({depot:e,mobile:t}){let{subscribed:s,subscribing:i,subscribe:n}=function(e){let{isDepotSubscriber:t}=(0,E.useMeContext)(),[s,i]=(0,g.useState)(!1),n=(0,g.useMemo)(()=>t(e.slug),[t,e.slug]),o=n?`/api/depots/${e.slug}/unsubscribe`:`/api/depots/${e.slug}/subscribe`,{trigger:r}=(0,V.default)(o,H,{revalidate:!1}),{mutate:a}=(0,q.useSWRConfig)();return{subscribed:n,subscribing:s,subscribe:(0,g.useCallback)(async()=>{i(!0);try{let e=await r();e&&await Promise.all([a("/api/users/me"),a(`/api/depots/${e.depot.slug}`)])}catch(e){}i(!1)},[r,a])}}(e),{isSignedIn:r}=(0,E.useMeContext)(),a=(0,g.useCallback)(()=>{(0,c.trackEvent)(s?"Unfavorited from Depot":"Favorited to Depot",{...(0,c.analyticsDepotProps)(e)}),n()},[e,n,s]),{query:l,pathname:d}=(0,u.useRouter)(),p=l.depotSlug;return e.is_private?null:(0,o.jsx)(b.default,{trackEvent:{name:"Clicked Subscribe to Depot (when logged out)",properties:{...(0,c.analyticsDepotProps)(e)}},trigger:e=>(0,o.jsx)(O.default,{onClick:r?a:e,label:t?void 0:s?"Favorited":"Favorite",icon:"fa-heart",iconType:s?"fa-solid":"fa-regular",disabled:i,loading:i,color:"primary",size:"md"}),children:(0,o.jsx)(y.default,{title:"Sign up to Favorite to this Depot",description:"Favoriting Depots is a great way to catalog and share all your favorite memes.",redirectUrl:d.replace("[depotSlug]",p),autoCloseOnAuth:!0})})}var Y=e.i(293938),Q=e.i(717469),J=e.i(509095),X=e.i(664963);let Z=Intl.NumberFormat("en",{notation:"compact"});function ee({depot:e,showViewCount:t}){return(0,o.jsx)("div",{className:"flex max-sm:flex-center-col gap-4",children:(0,o.jsxs)("div",{className:"flex gap-4",children:[(0,o.jsxs)("span",{className:"max-sm:text-center text-secondary font-light",children:[(0,o.jsx)("p",{className:"font-bold",children:Z.format(e.meme_count)}
1)," ",(0,X.inflect)("Memes",e.meme_count)]}),t&&(0,o.jsxs)("span",{className:"max-sm:text-center text-secondary font-light",children:[(0,o.jsx)("p",{className:"font-bold",children:Z.format(e.total_view_count)})," ",(0,X.inflect)("Views",e.total_view_count)]})]})})}function et({depot:e}){return[e.web,e.twitter,e.tiktok,e.instagram].filter(F.nonNullable).length?(0,o.jsxs)("div",{className:"max-sm:text-center",children:[e.web&&(0,o.jsx)(O.default,{href:`https://${e.web}`,icon:"fa-globe",color:"link",size:"lg",newTab:!0}),e.twitter&&(0,o.jsx)(O.default,{href:`https://twitter.com/${e.twitter}`,icon:"fa-x-twitter",iconType:"fa-brands",color:"link",size:"lg",newTab:!0}),e.tiktok&&(0,o.jsx)(O.default,{href:`https://tiktok.com/${e.tiktok}`,icon:"fa-tiktok",iconType:"fa-brands",color:"link",size:"lg",newTab:!0}),e.instagram&&(0,o.jsx)(O.default,{href:`https://instagram.com/${e.instagram}`,icon:"fa-instagram",iconType:"fa-brands",color:"link",size:"lg",newTab:!0})]}):null}var es=e.i(317009),ei=e.i(386547),en=e.i(346582);function eo({depot:e,isDepotOwner:t}){let s=(0,g.useRef)(null),i=(0,J.toCollabType)(e),{me:n,isAdmin:r}=(0,E.useMeContext)(),a=(0,es.default)(e),l=(0,o.jsx)(Y.default,{depot:e,restrictSlugChange:e.is_favorites||e.is_created||e.is_staging||e.is_internal||e.is_template}),u=(t||r)&&!e.is_created&&!e.is_internal&&!e.is_staging&&!e.is_template&&!e.is_favorites,d=!t&&!e.is_created,p=t||!e.is_private&&!e.is_created&&!e.is_staging&&!e.is_internal&&!e.is_template&&!e.is_favorites;return(0,o.jsx)("div",{ref:s,className:"flex flex-col lg:flex-row gap-6",children:(0,o.jsxs)("div",{className:"flex flex-1 gap-4 max-sm:flex-col items-center",children:[(0,o.jsx)("div",{className:(0,C.twMerge)("relative",u&&!e.cf_asset_id&&"cursor-pointer transition-all duration-200 ease-in-out hover:scale-105 active:scale-95 z-20"),children:e.cf_asset_id&&e.blur_data_url?(0,o.jsx)("div",{className:"bg-primary p-8 h-32 w-32 sm:h-36 sm:w-36 relative rounded-full overflow-hidden flex border-8 border-primary z-10",children:(0,o.jsx)(R.default,{placeholder:"blur",blurDataURL:e.blur_data_url,src:e.cf_asset_id,alt:a,loader:N.default,className:"object-cover",fill:!0,sizes:"(max-width: 240px) 100vw, (max-width: 640px) 50vw, (max-width: 1024px) 33vw, 25vw"})}):(0,o.jsx)(b.default,{trackEvent:{name:"Edit Meme Depot Details - Start",properties:{...(0,c.analyticsDepotProps)(e)}},trigger:e=>(0,o.jsxs)("div",{className:"relative",onClick:u?e:L.default,children:[(0,o.jsx)("div",{className:"bg-primary-dark p-8 h-32 w-32 sm:h-36 sm:w-36 relative rounded-full overflow-hidden flex items-center justify-center border-8 border-primary z-10",children:(0,o.jsx)("i",{className:"fa-regular fa-camera text-primary-darker text-5xl sm:text-6xl relative"})}),u&&(0,o.jsx)("div",{className:"absolute right-2 bottom-2 sm:right-2 z-10 bg-primary border-4 border-primary-dark px-3 py-1 rounded-xl shadow-xl",children:(0,o.jsx)("i",{className:"fa-solid fa-pencil text-secondary text-sm"})})]}),children:l})}),(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsx)(et,{depot:e}),(0,o.jsxs)("div",{className:"sm:pl-2 space-y-6",children:[(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"flex items-center max-sm:flex-col-reverse gap-2 w-full",children:[(0,o.jsx)("div",{className:"flex gap-4 items-center",children:(0,o.jsxs)(j.default,{size:"heading",children:[a," ",n&&e.user.uuid===n.uuid&&(0,o.jsxs)(o.Fragment,{children:[i===J.CollabType.PRIVATE&&(0,o.jsx)("span",{className:"fa-light fa-lock fa-sm","data-tooltip-content":"This Depot is Private. Only you, as the owner, can view and add memes.","data-tooltip-id":"tooltip","data-tooltip-place":"bottom"}),i===J.CollabType.PUBLIC&&(0,o.jsx)("span",{className:"fa-light fa-globe fa-sm","data-tooltip-content":"This Depot is Public. Anyone can view but only you, as the owner, can add memes.","data-tooltip-id":"tooltip","data-tooltip-place":"bottom"}),i===J.CollabType.MODERATED&&(0,o.jsx)("span",{className:"fa-light fa-shield-check fa-sm","data-tooltip-content":"This Depot is Moderated. Anyone can view, but you as the owner, need to approve them before they are added.","data-tooltip-id":"tooltip","data-tooltip-place":"bottom"}),i===J.CollabType.OPEN&&(0,o.jsx)("span",{className:"fa-light fa-users fa-sm","data-tooltip-content":"This Depot is Open. Anyone can view or add memes.","data-tooltip-id":"tooltip","data-tooltip-place":"bottom"})]})]})}),u&&(0,o.jsx)(b.default,{trackEvent:{name:"Edit Meme Depot Details - Start",properties:{...(0,c.analyticsDepotProps)(e)}},trigger:e=>(0,o.jsx)(O.default,{onClick:e,label:"Edit Depot",icon:"fa-pen-to-square",color:"primary",size:"md",iconClassName:"fa-lg",textOnly:!0}),onOpenUrlQueryParam:"depotEdit",children:l})]}),(0,o.jsxs)("div",{className:"flex max-sm:justify-center gap-1 w-full",children:["by",(0,o.jsxs)(z.default,{href:(0,ei.getUserLink)(e.user),className:"text-primary-lightest hover:text-primary transition-all",children:["@",e.user.username||e.user.uuid,e.user.is_pro&&(0,o.jsx)(en.default,{className:"w-3.5 h-3.5 ml-1"})]})]})]}),(0,o.jsx)(ee,{depot:e,showViewCount:p}),(0,o.jsxs)("div",{className:"flex max-sm:flex-col gap-2",children:[d&&(0,o.jsx)(G,{depot:e}),(0,o.jsx)(Q.default,{depot:e,trigger:(e,t)=>(0,o.jsx)(O.default,{as:"div",label:"Share",iconType:"fa-solid",icon:"fa-share",size:"md",fullWidth:!0,outlineOnly:d,color:"primary",onClick:t})})]})]})]})]})})}function er({onClick:e}){return(0,o.jsx)("div",{className:(0,C.twMerge)("transition-all flex flex-col items-center justify-center bg-default hover:bg-secondary text-sm text-secondary","gap-4 relative overflow-hidden rounded-lg shadow","border border-secondary border-dashed px-4 py-4 cursor-pointer"),onClick:e,children:(0,o.jsxs)("div",{className:"w-full leading-6",children:[(0,o.jsx)("p",{className:"relative cursor-pointer rounded-md text-center font-semibold",children:"Already have existing memes?"}),(0,o.jsxs)("p",{className:"bg-tertiary rounded p-2 text-center font-medium outline-none cursor-pointer mt-2",children:["Import from ",(0,o.jsx)("i",{className:"fa-brands fa-x-twitter"})]})]})})}function ea(){let{isSignedIn:e}=(0,E.useMeContext)(),{route:t,query:s}=(0,u.useRouter)();return e?(0,o.jsx)(z.default,{href:"/api/oauth2/auth?skipDepotSelect=true",children:(0,o.jsx)(er,{})}):(0,o.jsx)(b.default,{trigger:e=>(0,o.jsx)(er,{onClick:e}),children:(0,o.jsx)(y.default,{title:"Sign In to Upload Memes",description:"Only Memedepot users can Upload Memes",redirectUrl:t.replace("[depotSlug]",s.depotSlug)})})}var el=e.i(184100);let eu=[{label:"All",types:[]},{label:"GIFs",types:[$.MemeType.GIF]},{label:"Images",types:[$.MemeType.IMAGE,$.MemeType.COPYPASTA]},{label:"Videos",types:[$.MemeType.VIDEO]}];function ec({setActiveTab:e,depot:t}){let[s,i]=(0,g.useState)(0),{applyType:n,clearTypes:r,types:a}=(0,A.useSearchStateContext)(),l=(0,g.useCallback)(e=>{!a.length&&!e.length||e.length&&e.every(e=>
1a.includes(e))&&e.length===a.length||(r(),e.forEach(e=>n(e)))},[n,r,a]);return(0,g.useEffect)(()=>{a.length?1===a.length?("GIF"===a[0]&&i(1),"VIDEO"===a[0]&&i(3),i(2)):3===a.length?i(0):2===a.length&&(a.includes("IMAGE")&&a.includes("COPYPASTA")||i(0)):i(0)},[]),(0,o.jsx)(el.default,{selectedIndex:s,tabButtons:eu,onChange:t=>{i(t),l(eu[t].types),e("MEMES")}})}function ed({type:e,onDelete:t}){return(0,o.jsx)(O.default,{size:"xxs","data-tooltip-id":"tooltip","data-tooltip-content":"Remove Search Filter",onClick:s=>{s.stopPropagation(),t(e)},label:F.MEME_TYPE_LABEL[e],iconPlacement:"after",icon:"fa-times",iconType:"fa-solid",border:"secondary"})}var ep=e.i(578584),eh=e.i(441243),ef=e.i(463044),em=e.i(730943),eg=e.i(872016),ex=e.i(759146),ev=e.i(829672),ey=e.i(160374),eb=e.i(626171),ew=e.i(880150),eE=e.i(993481),eS=e.i(71147),e_=e.i(373483),eC=e.i(264728),ej=e.i(215067),eT=e.i(468327),ek=e.i(587264),eI=e.i(476925),eU=e.i(941888),eA=e.i(855367),eM=e.i(780795),eP=e.i(675565);function e$(e){let t=(0,g.useRef)({value:"",selectionStart:null,selectionEnd:null});return(0,eP.useEventListener)(e,"blur",e=>{let s=e.target;eA.isHTMLInputElement(s)&&(t.current={value:s.value,selectionStart:s.selectionStart,selectionEnd:s.selectionEnd})}),(0,eE.useEvent)(()=>{if(!(0,eM.isActiveElement)(e)&&eA.isHTMLInputElement(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==t.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:s,selectionEnd:i}=t.current;null!==s&&null!==i&&e.setSelectionRange(s,i)}t.current={value:"",selectionStart:null,selectionEnd:null}}})}var eO=e.i(399030),eR=e.i(104067),eN=e.i(608404),eL=e.i(156833),eD=e.i(798294),eF=e.i(880281),eB=e.i(439048),ez=e.i(651358),eW=e.i(760360),eK=e.i(315503),eV=e.i(128708),eq=e.i(448714),eH=e.i(196061),eG=e.i(896694),eY=e.i(331774),eQ=e.i(459778),eJ=e.i(636832),eX=e.i(387706),eZ=e.i(760004),e0=e.i(426417),e1=e.i(855251),e2=e.i(774664),e6=e.i(472381),e8=e.i(78270),e3=e.i(709769),e4=e.i(622898),e5=e.i(962750),e9=e.i(214929),e7=e.i(161614),te=e.i(565383),tt=Object.defineProperty,ts=(e,t,s)=>{let i;return(i="symbol"!=typeof t?t+"":t)in e?tt(e,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[i]=s,s},ti=((t=ti||{})[t.Open=0]="Open",t[t.Closed=1]="Closed",t),tn=((s=tn||{})[s.Single=0]="Single",s[s.Multi=1]="Multi",s),to=((i=to||{})[i.Pointer=0]="Pointer",i[i.Focus=1]="Focus",i[i.Other=2]="Other",i),tr=((n=tr||{})[n.OpenCombobox=0]="OpenCombobox",n[n.CloseCombobox=1]="CloseCombobox",n[n.GoToOption=2]="GoToOption",n[n.SetTyping=3]="SetTyping",n[n.RegisterOption=4]="RegisterOption",n[n.UnregisterOption=5]="UnregisterOption",n[n.DefaultToFirstOption=6]="DefaultToFirstOption",n[n.SetActivationTrigger=7]="SetActivationTrigger",n[n.UpdateVirtualConfiguration=8]="UpdateVirtualConfiguration",n[n.SetInputElement=9]="SetInputElement",n[n.SetButtonElement=10]="SetButtonElement",n[n.SetOptionsElement=11]="SetOptionsElement",n[n.MarkInputAsMoved=12]="MarkInputAsMoved",n);function ta(e,t=e=>e){let s=null!==e.activeOptionIndex?e.options[e.activeOptionIndex]:null,i=t(e.options.slice()),n=i.length>0&&null!==i[0].dataRef.current.order?i.sort((e,t)=>e.dataRef.current.order-t.dataRef.current.order):(0,te.sortByDomNode)(i,e=>e.dataRef.current.domRef.current),o=s?n.indexOf(s):null;return -1===o&&(o=null),{options:n,activeOptionIndex:o}}let tl={1(e){var t;if(null!=(t=e.dataRef.current)&&t.disabled||1===e.comboboxState)return e;let s=e.inputElement?e7.ElementPositionState.Tracked((0,e7.computeVisualPosition)(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:s,__demoMode:!1}},0(e){var t,s;if(null!=(t=e.dataRef.current)&&t.disabled||0===e.comboboxState)return e;if(null!=(s=e.dataRef.current)&&s.value){let t=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(-1!==t)return{...e,activeOptionIndex:t,comboboxState:0,__demoMode:!1,inputPositionState:e7.ElementPositionState.Idle}}return{...e,comboboxState:0,inputPositionState:e7.ElementPositionState.Idle,__demoMode:!1}},3:(e,t)=>e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping},2(e,t){var s,i,n,o;if(null!=(s=e.dataRef.current)&&s.disabled||e.optionsElement&&!(null!=(i=e.dataRef.current)&&i.optionsPropsRef.current.static)&&1===e.comboboxState)return e;if(e.virtual){let{options:s,disabled:i}=e.virtual,o=t.focus===eX.Focus.Specific?t.idx:(0,eX.calculateActiveIndex)(t,{resolveItems:()=>s,resolveActiveIndex:()=>{var t,n;
1return null!=(n=null!=(t=e.activeOptionIndex)?t:s.findIndex(e=>!i(e)))?n:null},resolveDisabled:i,resolveId(){throw Error("Function not implemented.")}}),r=null!=(n=t.trigger)?n:2;return e.activeOptionIndex===o&&e.activationTrigger===r?e:{...e,activeOptionIndex:o,activationTrigger:r,isTyping:!1,__demoMode:!1}}let r=ta(e);if(null===r.activeOptionIndex){let e=r.options.findIndex(e=>!e.dataRef.current.disabled);-1!==e&&(r.activeOptionIndex=e)}let a=t.focus===eX.Focus.Specific?t.idx:(0,eX.calculateActiveIndex)(t,{resolveItems:()=>r.options,resolveActiveIndex:()=>r.activeOptionIndex,resolveId:e=>e.id,resolveDisabled:e=>e.dataRef.current.disabled}),l=null!=(o=t.trigger)?o:2;return e.activeOptionIndex===a&&e.activationTrigger===l?e:{...e,...r,isTyping:!1,activeOptionIndex:a,activationTrigger:l,__demoMode:!1}},4:(e,t)=>{var s,i,n,o;if(null!=(s=e.dataRef.current)&&s.virtual)return{...e,options:[...e.options,t.payload]};let r=t.payload,a=ta(e,e=>(e.push(r),e));null===e.activeOptionIndex&&null!=(n=(i=e.dataRef.current).isSelected)&&n.call(i,t.payload.dataRef.current.value)&&(a.activeOptionIndex=a.options.indexOf(r));let l={...e,...a,activationTrigger:2};return null!=(o=e.dataRef.current)&&o.__demoMode&&void 0===e.dataRef.current.value&&(l.activeOptionIndex=0),l},5:(e,t)=>{var s;if(null!=(s=e.dataRef.current)&&s.virtual)return{...e,options:e.options.filter(e=>e.id!==t.id)};let i=ta(e,e=>{let s=e.findIndex(e=>e.id===t.id);return -1!==s&&e.splice(s,1),e});return{...e,...i,activationTrigger:2}},6:(e,t)=>e.defaultToFirstOption===t.value?e:{...e,defaultToFirstOption:t.value},7:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},8:(e,t)=>
1{var s,i;if(null===e.virtual)return{...e,virtual:{options:t.options,disabled:null!=(s=t.disabled)?s:()=>!1}};if(e.virtual.options===t.options&&e.virtual.disabled===t.disabled)return e;let n=e.activeOptionIndex;if(null!==e.activeOptionIndex){let s=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);n=-1!==s?s:null}return{...e,activeOptionIndex:n,virtual:{options:t.options,disabled:null!=(i=t.disabled)?i:()=>!1}}},9:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},10:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},11:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},12:e=>"Tracked"!==e.inputPositionState.kind?e:{...e,inputPositionState:e7.ElementPositionState.Moved}};class tu extends e9.Machine{constructor(e){super(e),ts(this,"actions",{onChange:e=>{let{onChange:t,compare:s,mode:i,value:n}=this.state.dataRef.current;return(0,e0.match)(i,{0:()=>null==t?void 0:t(e),1:()=>{let i=n.slice(),o=i.findIndex(t=>s(t,e));return -1===o?i.push(e):i.splice(o,1),null==t?void 0:t(i)}})},registerOption:(e,t)=>(this.send({type:4,payload:{id:e,dataRef:t}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(t.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:e})}),goToOption:(e,t)=>(this.send({type:6,value:!1}),this.send({type:2,...e,trigger:t})),setIsTyping:e=>{this.send({type:3,isTyping:e})},closeCombobox:()=>{var e,t;this.send({type:1}),this.send({type:6,value:!1}),null==(t=(e=this.state.dataRef.current).onClose)||t.call(e)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:e=>{this.send({type:7,trigger:e})},selectActiveOption:()=>{let e=this.selectors.activeOptionIndex(this.state);if(null!==e){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[e]);else{let{dataRef:t}=this.state.options[e];this.actions.onChange(t.current.value)}this.actions.goToOption({focus:eX.Focus.Specific,idx:e})}},setInputElement:e=>{this.send({type:9,element:e})},setButtonElement:e=>{this.send({type:10,element:e})},setOptionsElement:e=>{this.send({type:11,element:e})}}),ts(this,"selectors",{activeDescendantId:e=>{var t,s;let i=this.selectors.activeOptionIndex(e);if(null!==i)return e.virtual?null==(s=e.options.find(t=>!t.dataRef.current.disabled&&e.dataRef.current.compare(t.dataRef.current.value,e.virtual.options[i])))?void 0:s.id:null==(t=e.options[i])?void 0:t.id},activeOptionIndex:e=>{if(e.defaultToFirstOption&&null===e.activeOptionIndex&&(e.virtual?e.virtual.options.length>0:e.options.length>0)){if(e.virtual){let{options:t,disabled:s}=e.virtual,i=t.findIndex(e=>{var t;return!(null!=(t=null==s?void 0:s(e))&&t)});if(-1!==i)return i}let t=e.options.findIndex(e=>!e.dataRef.current.disabled);if(-1!==t)return t}return e.activeOptionIndex},activeOption:e=>{var t,s;let i=this.selectors.activeOptionIndex(e);return null===i?null:e.virtual?e.virtual.options[null!=i?i:0]:null!=(s=null==(t=e.options[i])?void 0:t.dataRef.current.value)?s:null},isActive:(e,t,s)=>{var i;let n=this.selectors.activeOptionIndex(e);return null!==n&&(e.virtual?n===e.dataRef.current.calculateIndex(t):(null==(i=e.options[n])?void 0:i.id)===s)},shouldScrollIntoView:(e,t,s)=>!(e.virtual||e.__demoMode||0!==e.comboboxState||0===e.activationTrigger||!this.selectors.isActive(e,t,s)),didInputMove:e=>"Moved"===e.inputPositionState.kind});{let e=this.state.id,t=eY.stackMachines.get(null);this.disposables.add(t.on(eY.ActionTypes.Push,s=>{t.selectors.isTop(s,e)||0!==this.state.comboboxState||this.actions.closeCombobox()})),this.on(0,()=>t.actions.push(e)),this.on(1,()=>t.actions.pop(e))}this.disposables.group(e=>{this.on(1,t=>{t.inputElement&&(e.dispose(),e.add((0,e7.detectMovement)(t.inputElement,t.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:e,virtual:t=null,__demoMode:s=!1}){var i;return new tu({id:e,dataRef:{current:{}},comboboxState:+!s,isTyping:!1,options:[],virtual:t?{options:t.options,disabled:null!=(i=t.disabled)?i:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:s,inputPositionState:e7.ElementPositionState.Idle})}reduce(e,t){return(0,e0.match)(t.type,tl,e,t)}}var tc=e.i(721867);let td=(0,g.createContext)(null);function tp(e){let t=(0,g.useContext)(td);if(null===t){let t=Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,th),t}return t}function th({id:e,virtual:t=null,__demoMode:s=!1}){let i=(0,g.useMemo)(()=>tu.new({id:e,virtual:t,__demoMode:s}),[]);return(0,tc.useOnUnmount)(()=>i.dispose()),i}let tf=(0,g.createContext)(null);function tm(e){let t=(0,g.useContext)(tf);if(null===t){let t=Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,tm),t}return t}tf.displayName="ComboboxDataContext";let tg=(0,g.createContext)(null);function tx(e){let t=tp("VirtualProvider"),{options:s}=tm("VirtualProvider").virtual,i=(0,eQ.useSlice)(t,e=>e.optionsElement),[n,o]=(0,g.useMemo)(()=>
1{if(!i)return[0,0];let e=window.getComputedStyle(i);return[parseFloat(e.paddingBlockStart||e.paddingTop),parseFloat(e.paddingBlockEnd||e.paddingBottom)]},[i]),r=(0,ef.useVirtualizer)({enabled:0!==s.length,scrollPaddingStart:n,scrollPaddingEnd:o,count:s.length,estimateSize:()=>40,getScrollElement:()=>t.state.optionsElement,overscan:12}),[a,l]=(0,g.useState)(0);(0,eC.useIsoMorphicEffect)(()=>{l(e=>e+1)},[s]);let u=r.getVirtualItems(),c=(0,eQ.useSlice)(t,e=>e.activationTrigger===to.Pointer),d=(0,eQ.useSlice)(t,t.selectors.activeOptionIndex);return 0===u.length?null:g.default.createElement(tg.Provider,{value:r},g.default.createElement("div",{style:{position:"relative",width:"100%",height:`${r.getTotalSize()}px`},ref:e=>{e&&(c||null!==d&&s.length>d&&r.scrollToIndex(d))}},u.map(t=>{var i;return g.default.createElement(g.Fragment,{key:t.key},g.default.cloneElement(null==(i=e.children)?void 0:i.call(e,{...e.slot,option:s[t.index]}),{key:`${a}-${t.key}`,"data-index":t.index,"aria-setsize":s.length,"aria-posinset":t.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${t.start}px)`,overflowAnchor:"none"}}))})))}let tv=g.Fragment,ty=e2.RenderFeatures.RenderStrategy|e2.RenderFeatures.Static,tb=(0,e2.forwardRefWithAs)(function(e,t){let s=(0,g.useId)(),i=(0,eW.useDisabled)(),{value:n,defaultValue:o,onChange:r,form:a,name:l,by:u,invalid:c=!1,disabled:d=i||!1,onClose:p,__demoMode:h=!1,multiple:f=!1,immediate:m=!1,virtual:x=null,nullable:v,...y}=e,b=(0,ey.useDefaultValue)(o),[w=f?[]:void 0,E]=(0,ev.useControllable)(n,r,b),S=th({id:s,virtual:x,__demoMode:h}),_=(0,g.useRef)({static:!1,hold:!1}),C=(0,ex.useByComparator)(u),j=(0,eE.useEvent)(e=>x?null===u?x.options.indexOf(e):x.options.findIndex(t=>C(t,e)):S.state.options.findIndex(t=>C(t.dataRef.current.value,e))),T=(0,g.useCallback)(e=>(0,e0.match)(U.mode,{[tn.Multi]:()=>w.some(t=>C(t,e)),[tn.Single]:()=>C(w,e)}),[w]),k=(0,eQ.useSlice)(S,e=>e.virtual),I=(0,eE.useEvent)(()=>null==p?void 0:p()),U=(0,g.useMemo)(()=>({__demoMode:h,immediate:m,optionsPropsRef:_,value:w,defaultValue:b,disabled:d,invalid:c,mode:f?tn.Multi:tn.Single,virtual:x?k:null,onChange:E,isSelected:T,calculateIndex:j,compare:C,onClose:I}),[h,m,_,w,b,d,c,f,x,k,E,T,j,C,I]);(0,eC.useIsoMorphicEffect)(()=>{var e;x&&S.send({type:tr.UpdateVirtualConfiguration,options:x.options,disabled:null!=(e=x.disabled)?e:null})},[x,null==x?void 0:x.options,null==x?void 0:x.disabled]),(0,eC.useIsoMorphicEffect)(()=>{S.state.dataRef.current=U},[U]);let[A,M,P,$]=(0,eQ.useSlice)(S,e=>[e.comboboxState,e.buttonElement,e.inputElement,e.optionsElement]),O=eY.stackMachines.get(null),R=(0,eQ.useSlice)(O,(0,g.useCallback)(e=>O.selectors.isTop(e,s),[O,s]));(0,ek.useOutsideClick)(R,[M,P,$],()=>S.actions.closeCombobox());let N=(0,eQ.useSlice)(S,S.selectors.activeOptionIndex),L=(0,eQ.useSlice)(S,S.selectors.activeOption),D=(0,eN.useSlot)({open:A===ti.Open,disabled:d,invalid:c,activeIndex:N,activeOption:L,value:w}),[F,B]=(0,e3.useLabels)(),z=(0,g.useCallback)(()=>{if(void 0!==b)return null==E?void 0:E(b)},[E,b]),W=(0,e2.useRender)();return g.default.createElement(B,{value:F,props:{htmlFor:null==P?void 0:P.id},slot:{open:A===ti.Open,disabled:d}},g.default.createElement(eK.FloatingProvider,null,g.default.createElement(tf.Provider,{value:U},g.default.createElement(td.Provider,{value:S},g.default.createElement(eG.OpenClosedProvider,{value:(0,e0.match)(A,{[ti.Open]:eG.State.Open,[ti.Closed]:eG.State.Closed})},null!=l&&g.default.createElement(eV.FormFields,{disabled:d,data:null!=w?{[l]:w}:{},form:a,onReset:z}),W({ourProps:null===t?{}:{ref:t},theirProps:y,slot:D,defaultTag:tv,name:"Combobox"}))))))}),tw=(0,e2.forwardRefWithAs)(function(e,t){let s=tp("Combobox.Button"),i=tm("Combobox.Button"),[n,o]=(0,g.useState)(null),r=(0,eL.useSyncRefs)(t,o,s.actions.setButtonElement),a=(0,g.useId)(),{id:l=`headlessui-combobox-button-${a}`,disabled:u=i.disabled||!1,autoFocus:c=!1,...d}=e,[p,h,f]=(0,eQ.useSlice)(s,e=>[e.comboboxState,e.inputElement,e.optionsElement]),m=e$(h),x=p===ti.Open;(0,eU.useQuickRelease)(x,{trigger:n,action:(0,g.useCallback)(e=>{if(null!=n&&n.contains(e.target)||null!=h&&h.contains(e.target))return eU.Action.Ignore;let t=e.target.closest('[role="option"]:not([data-disabled])');return eA.isHTMLElement(t)?eU.Action.Select(t):null!=f&&f.contains(e.target)?eU.Action.Ignore:eU.Action.Close},[n,h,f]),close:s.actions.closeCombobox,select:s.actions.selectActiveOption});let v=(0,eE.useEvent)(e=>{switch(e.key){case e8.Keys.Space:case e8.Keys.Enter:e.preventDefault(),e.stopPropagation(),s.state.comboboxState===ti.
1Closed&&(0,em.flushSync)(()=>s.actions.openCombobox()),m();return;case e8.Keys.ArrowDown:e.preventDefault(),e.stopPropagation(),s.state.comboboxState===ti.Closed&&((0,em.flushSync)(()=>s.actions.openCombobox()),s.state.dataRef.current.value||s.actions.goToOption({focus:eX.Focus.First})),m();return;case e8.Keys.ArrowUp:e.preventDefault(),e.stopPropagation(),s.state.comboboxState===ti.Closed&&((0,em.flushSync)(()=>s.actions.openCombobox()),s.state.dataRef.current.value||s.actions.goToOption({focus:eX.Focus.Last})),m();return;case e8.Keys.Escape:if(s.state.comboboxState!==ti.Open)return;e.preventDefault(),s.state.optionsElement&&!i.optionsPropsRef.current.static&&e.stopPropagation(),(0,em.flushSync)(()=>s.actions.closeCombobox()),m();return;default:return}}),y=(0,eS.useHandleToggle)(()=>{s.state.comboboxState===ti.Open?s.actions.closeCombobox():s.actions.openCombobox(),m()}),b=(0,e3.useLabelledBy)([l]),{isFocusVisible:w,focusProps:E}=(0,ep.useFocusRing)({autoFocus:c}),{isHovered:S,hoverProps:_}=(0,eh.useHover)({isDisabled:u}),{pressed:C,pressProps:j}=(0,eg.useActivePress)({disabled:u}),T=(0,eN.useSlot)({open:p===ti.Open,active:C||p===ti.Open,disabled:u,invalid:i.invalid,value:i.value,hover:S,focus:w}),k=(0,e2.mergeProps)({ref:r,id:l,type:(0,eO.useResolveButtonType)(e,n),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":null==f?void 0:f.id,"aria-expanded":p===ti.Open,"aria-labelledby":b,disabled:u||void 0,autoFocus:c,onKeyDown:v},y,E,_,j);return(0,e2.useRender)()({ourProps:k,theirProps:d,slot:T,defaultTag:"button",name:"Combobox.Button"})}),tE=(0,e2.forwardRefWithAs)(function(e,t){var s,i;let n=tp("Combobox.Input"),o=tm("Combobox.Input"),r=(0,g.useId)(),a=(0,eH.useProvidedId)(),{id:l=a||`headlessui-combobox-input-${r}`,onChange:u,displayValue:c,disabled:d=o.disabled||!1,autoFocus:p=!1,type:h="text",...f}=e,m=(0,g.useRef)(null),x=(0,eL.useSyncRefs)(m,t,(0,eK.useFloatingReference)(),n.actions.setInputElement),[v,y]=(0,eQ.useSlice)(n,e=>[e.comboboxState,e.isTyping]),b=(0,eb.useDisposables)(),w=(0,eE.useEvent)(()=>{n.actions.onChange(null),n.state.optionsElement&&(n.state.optionsElement.scrollTop=0),n.actions.goToOption({focus:eX.Focus.Nothing})}),E=(0,g.useMemo)(()=>{var e;return"function"==typeof c&&void 0!==o.value?null!=(e=c(o.value))?e:"":"string"==typeof o.value?o.value:""},[o.value,c]);(0,ez.useWatch)(([e,t],[s,i])=>{if(n.state.isTyping)return;let o=m.current;o&&((i===ti.Open&&t===ti.Closed||e!==s)&&(o.value=e),requestAnimationFrame(()=>{if(n.state.isTyping||!o||(0,eM.isActiveElement)(o))return;let{selectionStart:e,selectionEnd:t}=o;0===Math.abs((null!=t?t:0)-(null!=e?e:0))&&0===e&&o.setSelectionRange(o.value.length,o.value.length)}))},[E,v,y]),(0,ez.useWatch)(([e],[t])=>{if(e===ti.Open&&t===ti.Closed){if(n.state.isTyping)return;let e=m.current;if(!e)return;let t=e.value,{selectionStart:s,selectionEnd:i,selectionDirection:o}=e;e.value="",e.value=t,null!==o?e.setSelectionRange(s,i,o):e.setSelectionRange(s,i)}},[v]);let S=(0,g.useRef)(!1),_=(0,eE.useEvent)(()=>{S.current=!0}),C=(0,eE.useEvent)(()=>{b.nextFrame(()=>{S.current=!1})}),j=(0,eE.useEvent)(e=>{switch(n.actions.setIsTyping(!0),e.key){case e8.Keys.Enter:if(n.state.comboboxState!==ti.Open||S.current)return;if(e.preventDefault(),e.stopPropagation(),null===n.selectors.activeOptionIndex(n.state))return void n.actions.closeCombobox();n.actions.selectActiveOption(),o.mode===tn.Single&&n.actions.closeCombobox();break;case e8.Keys.ArrowDown:return e.preventDefault(),e.stopPropagation(),(0,e0.match)(n.state.comboboxState,{[ti.Open]:()=>n.actions.goToOption({focus:eX.Focus.Next}),[ti.Closed]:()=>n.actions.openCombobox()});case e8.Keys.ArrowUp:return e.preventDefault(),e.stopPropagation(),(0,e0.match)(n.state.comboboxState,{[ti.Open]:()=>n.actions.goToOption({focus:eX.Focus.Previous}),[ti.Closed]:()=>{(0,em.flushSync)(()=>n.actions.openCombobox()),o.value||n.actions.goToOption({focus:eX.Focus.Last})}});case e8.Keys.Home:if(n.state.comboboxState===ti.Closed||e.shiftKey)break;return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:eX.Focus.First});case e8.Keys.PageUp:return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:eX.Focus.First});
1case e8.Keys.End:if(n.state.comboboxState===ti.Closed||e.shiftKey)break;return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:eX.Focus.Last});case e8.Keys.PageDown:return e.preventDefault(),e.stopPropagation(),n.actions.goToOption({focus:eX.Focus.Last});case e8.Keys.Escape:return n.state.comboboxState!==ti.Open?void 0:(e.preventDefault(),n.state.optionsElement&&!o.optionsPropsRef.current.static&&e.stopPropagation(),o.mode===tn.Single&&null===o.value&&w(),n.actions.closeCombobox());case e8.Keys.Tab:if(n.actions.setIsTyping(!1),n.state.comboboxState!==ti.Open)return;o.mode===tn.Single&&n.state.activationTrigger!==to.Focus&&n.actions.selectActiveOption(),n.actions.closeCombobox()}}),T=(0,eE.useEvent)(e=>{null==u||u(e),o.mode===tn.Single&&""===e.target.value&&w(),n.actions.openCombobox()}),k=(0,eE.useEvent)(e=>{var t,s,i;let r=null!=(t=e.relatedTarget)?t:eJ.history.find(t=>t!==e.currentTarget);if(!(null!=(s=n.state.optionsElement)&&s.contains(r))&&!(null!=(i=n.state.buttonElement)&&i.contains(r))&&n.state.comboboxState===ti.Open)return e.preventDefault(),o.mode===tn.Single&&null===o.value&&w(),n.actions.closeCombobox()}),I=(0,eE.useEvent)(e=>{var t,s,i;let r=null!=(t=e.relatedTarget)?t:eJ.history.find(t=>t!==e.currentTarget);null!=(s=n.state.buttonElement)&&s.contains(r)||null!=(i=n.state.optionsElement)&&i.contains(r)||o.disabled||o.immediate&&n.state.comboboxState!==ti.Open&&b.microTask(()=>{(0,em.flushSync)(()=>n.actions.openCombobox()),n.actions.setActivationTrigger(to.Focus)})}),U=(0,e3.useLabelledBy)(),A=(0,e6.useDescribedBy)(),{isFocused:M,focusProps:P}=(0,ep.useFocusRing)({autoFocus:p}),{isHovered:$,hoverProps:O}=(0,eh.useHover)({isDisabled:d}),R=(0,eQ.useSlice)(n,e=>e.optionsElement),N=(0,eN.useSlot)({open:v===ti.Open,disabled:d,invalid:o.invalid,hover:$,focus:M,autofocus:p}),L=(0,e2.mergeProps)({ref:x,id:l,role:"combobox",type:h,"aria-controls":null==R?void 0:R.id,"aria-expanded":v===ti.Open,"aria-activedescendant":(0,eQ.useSlice)(n,n.selectors.activeDescendantId),"aria-labelledby":U,"aria-describedby":A,"aria-autocomplete":"list",defaultValue:null!=(i=null!=(s=e.defaultValue)?s:void 0!==o.defaultValue?null==c?void 0:c(o.defaultValue):null)?i:o.defaultValue,disabled:d||void 0,autoFocus:p,onCompositionStart:_,onCompositionEnd:C,onKeyDown:j,onChange:T,onFocus:I,onBlur:k},P,O);return(0,e2.useRender)()({ourProps:L,theirProps:f,slot:N,defaultTag:"input",name:"Combobox.Input"})}),tS=e3.Label,t_=(0,e2.forwardRefWithAs)(function(e,t){var s,i,n;let o=(0,g.useId)(),{id:r=`headlessui-combobox-options-${o}`,hold:a=!1,anchor:l,portal:u=!1,modal:c=!0,transition:d=!1,...p}=e,h=tp("Combobox.Options"),f=tm("Combobox.Options"),m=(0,eK.useResolvedAnchor)(l);m&&(u=!0);let[x,v]=(0,eK.useFloatingPanel)(m),[y,b]=(0,g.useState)(null),w=(0,eK.useFloatingPanelProps)(),E=(0,eL.useSyncRefs)(t,m?x:null,h.actions.setOptionsElement,b),[S,_,C,j,T]=(0,eQ.useSlice)(h,e=>[e.comboboxState,e.inputElement,e.buttonElement,e.optionsElement,e.activationTrigger]),k=(0,eI.useOwnerDocument)(_||C),I=(0,eI.useOwnerDocument)(j),U=(0,eG.useOpenClosed)(),[A,M]=(0,eF.useTransition)(d,y,null!==U?(U&eG.State.Open)===eG.State.Open:S===ti.Open);(0,eT.useOnDisappear)(A,_,h.actions.closeCombobox);let P=!f.__demoMode&&c&&S===ti.Open;(0,eR.useScrollLock)(P,I);let $=!f.__demoMode&&c&&S===ti.Open;(0,e_.useInertOthers)($,{allowed:(0,g.useCallback)(()=>[_,C,j],[_,C,j])});let O=!(0,eQ.useSlice)(h,h.selectors.didInputMove)&&A;(0,eC.useIsoMorphicEffect)(()=>{var t;f.optionsPropsRef.current.static=null!=(t=e.static)&&t},[f.optionsPropsRef,e.static]),(0,eC.useIsoMorphicEffect)(()=>{f.optionsPropsRef.current.hold=a},[f.optionsPropsRef,a]),(0,eB.useTreeWalker)(S===ti.Open,{container:j,accept:e=>"option"===e.getAttribute("role")?NodeFilter.FILTER_REJECT:e.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT,walk(e){e.setAttribute("role","none")}});let R=(0,e3.useLabelledBy)([null==C?void 0:C.id]),N=(0,eN.useSlot)({open:S===ti.Open,option:void 0}),L=(0,eE.useEvent)(()=>{h.actions.setActivationTrigger(to.Pointer)}),D=(0,eE.useEvent)(e=>{e.preventDefault(),h.actions.setActivationTrigger(to.Pointer)}),F=(0,e2.mergeProps)(m?w():{},{"aria-labelledby":R,role:"listbox","aria-multiselectable":f.mode===tn.Multi||void 0,id:r,ref:E,style:{...p.style,...v,"--input-width":(0,ew.useElementSize)(A,_,!0).width,"--button-width":(0,ew.useElementSize)(A,C,!0).width},onWheel:T===to.Pointer?void 0:L,onMouseDown:D,...(0,eF.transitionDataAttributes)(M)}),B=A&&S===ti.Closed&&!e.static,z=(0,eq.useFrozenData)(B,null==(s=f.virtual)?void 0:s.options),W=(0,eq.useFrozenData)(B,f.value),K=(0,g.useCallback)(e=>f.compare(W,e),[f.compare,W]),V=(0,g.useMemo)(()=>
1{if(!f.virtual)return f;if(void 0===z)throw Error("Missing `options` in virtual mode");return z!==f.virtual.options?{...f,virtual:{...f.virtual,options:z}}:f},[f,z,null==(i=f.virtual)?void 0:i.options]);f.virtual&&Object.assign(p,{children:g.default.createElement(tf.Provider,{value:V},g.default.createElement(tx,{slot:N},p.children))});let q=(0,e2.useRender)(),H=(0,g.useMemo)(()=>f.mode===tn.Multi?f:{...f,isSelected:K},[f,K]);return g.default.createElement(e5.Portal,{enabled:!!u&&(e.static||A),ownerDocument:k},g.default.createElement(tf.Provider,{value:H},q({ourProps:F,theirProps:{...p,children:g.default.createElement(eq.Frozen,{freeze:B},"function"==typeof p.children?null==(n=p.children)?void 0:n.call(p,N):p.children)},slot:N,defaultTag:"div",features:ty,visible:O,name:"Combobox.Options"})))}),tC=(0,e2.forwardRefWithAs)(function(e,t){var s,i,n;let o=tm("Combobox.Option"),r=tp("Combobox.Option"),a=(0,g.useId)(),{id:l=`headlessui-combobox-option-${a}`,value:u,disabled:c=null!=(n=null==(i=null==(s=o.virtual)?void 0:s.disabled)?void 0:i.call(s,u))&&n,order:d=null,...p}=e,[h]=(0,eQ.useSlice)(r,e=>[e.inputElement]),f=e$(h),m=(0,eQ.useSlice)(r,(0,g.useCallback)(e=>r.selectors.isActive(e,u,l),[u,l])),x=o.isSelected(u),v=(0,g.useRef)(null),y=(0,ej.useLatestValue)({disabled:c,value:u,domRef:v,order:d}),b=(0,g.useContext)(tg),w=(0,eL.useSyncRefs)(t,v,b?b.measureElement:null),E=(0,eE.useEvent)(()=>{r.actions.setIsTyping(!1),r.actions.onChange(u)});(0,eC.useIsoMorphicEffect)(()=>r.actions.registerOption(l,y),[y,l]);let S=(0,eQ.useSlice)(r,(0,g.useCallback)(e=>r.selectors.shouldScrollIntoView(e,u,l),[u,l]));(0,eC.useIsoMorphicEffect)(()=>{if(S)return(0,eZ.disposables)().requestAnimationFrame(()=>{var e,t;null==(t=null==(e=v.current)?void 0:e.scrollIntoView)||t.call(e,{block:"nearest"})})},[S,v]);let _=(0,eE.useEvent)(e=>{e.preventDefault(),e.button===e4.MouseButton.Left&&(c||(E(),(0,e1.isMobile)()||requestAnimationFrame(()=>f()),o.mode===tn.Single&&r.actions.closeCombobox()))}),C=(0,eE.useEvent)(()=>{if(c)return r.actions.goToOption({focus:eX.Focus.Nothing});let e=o.calculateIndex(u);r.actions.goToOption({focus:eX.Focus.Specific,idx:e})}),j=(0,eD.useTrackedPointer)(),T=(0,eE.useEvent)(e=>j.update(e)),k=(0,eE.useEvent)(e=>{if(!j.wasMoved(e)||c||m&&r.state.activationTrigger===to.Pointer)return;let t=o.calculateIndex(u);r.actions.goToOption({focus:eX.Focus.Specific,idx:t},to.Pointer)}),I=(0,eE.useEvent)(e=>{j.wasMoved(e)&&(c||m&&(o.optionsPropsRef.current.hold||r.state.activationTrigger===to.Pointer&&r.actions.goToOption({focus:eX.Focus.Nothing})))}),U=(0,eN.useSlot)({active:m,focus:m,selected:x,disabled:c});return(0,e2.useRender)()({ourProps:{id:l,ref:w,role:"option",tabIndex:!0===c?void 0:-1,"aria-disabled":!0===c||void 0,"aria-selected":x,disabled:void 0,onMouseDown:_,onFocus:C,onPointerEnter:T,onMouseEnter:T,onPointerMove:k,onMouseMove:k,onPointerLeave:I,onMouseLeave:I},theirProps:p,slot:U,defaultTag:"div",name:"Combobox.Option"})}),tj=Object.assign(tb,{Input:tE,Button:tw,Label:tS,Options:t_,Option:tC});var tT=e.i(276733),tk=e.i(651589);function tI({depot:e,autoFocusInput:t=!1}){let{tags:s,applyTag:i,removeTag:n,types:r,applyType:a,removeType:l,labels:u,applyLabel:c,removeLabel:d,query:p,setQuery:h,clear:f}=(0,A.useSearchStateContext)(),m=r.length+s.length+u.length,x=(0,g.useMemo)(()=>!!p||!!m,[p,m]),v=(0,g.useRef)(null),y=(0,g.useCallback)(e=>{if(!e.shiftKey&&v.current){if("Enter"===e.key)v.current?.blur();else if("Escape"===e.key)v.current?.blur();else if("Backspace"===e.key&&0===v.current.selectionStart&&0===v.current.selectionEnd){let e=u.length?u[u.length-1]:null;if(e)return void d(e);let t=s.length?s[s.length-1]:null;if(t)return void n(t);let i=r.length?r[r.length-1]:null;if(i)return void l(i)}}},[u,d,n,l,s,r]),b=(0,g.useCallback)(e=>{e&&e.forEach(e=>{"type"===e.__typename?(a(e.type),h("")):"tag"===e.__typename?(i(e.tag),h("")):"label"===e.__typename&&(c(e.label),h(""))})},[c,i,a,h]),{data:w}=function(e){let{tags:t,types:s,labels:i,query:n}=(0,A.useSearchStateContext)();return{data:(0,g.useMemo)(()=>[{label:"Media Types",results:[{__typename:"type",label:F.MEME_TYPE_LABEL[$.MemeType.IMAGE],type:$.MemeType.IMAGE,count:e?.counts[$.MemeType.IMAGE]||0},{__typename:"type",label:F.MEME_TYPE_LABEL[$.MemeType.GIF],type:$.MemeType.GIF,count:e?.counts[$.MemeType.GIF]||0},{__typename:"type",label:F.MEME_TYPE_LABEL[$.MemeType.VIDEO],type:$.MemeType.VIDEO,count:e?.counts[$.MemeType.VIDEO]||0},{__typename:"type",label:F.MEME_TYPE_LABEL[$.MemeType.COPYPASTA],type:$.MemeType.COPYPASTA,count:e?.counts[$.MemeType.COPYPASTA]||0}].filter(e=>e.label.toLowerCase().includes(n.toLowerCase())).filter(e=>!s.includes(e.type))},{label:"Tags",icon:"fa-regular fa-tag",results:e.tags.map(e=>({__typename:"tag",tag:e.tag,label:e.tag,count:e.cardinality})).filter(e=>e.label.toLowerCase().includes(n.toLowerCase())).filter(e=>!t.includes(e.tag))},{label:"Labels",icon:"fa-solid fa-wand-magic-sparkles",results:e.labels.map(e=>({__typename:"label",label:e.label,count:e.cardinality})).filter(e=>e.label.toLowerCase().includes(n.toLowerCase())).filter(e=>!i.includes(e.label))}].filter(e=>e.results&&e.results.length>0),[e,s,t,i,n])}}(e),E=!!e;return(0,o.jsxs)("div",{className:"w-full flex max-md:flex-col justify-end relative gap-2",children:[(0,o.jsx)("div",{className:"min-h-8 shrink-0",children:!!m&&(0,o.jsx)(O.default,{label:`${m} Filters`,rounded:"full",iconPlacement:"after",color:"secondary",icon:"fa-times",className:"h-full max-md:w-full","data-tooltip-id":"tooltip","data-tooltip-content":"Remove Filters",onClick:()=>{f({keepQuery:!0})}})}),(0,o.jsx)(tj,{onChange:b,value:[],multiple:!0,immediate:!0,children:({open:i})=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:(0,C.twMerge)("w-full md:w-96","relative flex-center space-x-1 bg-site-secondary","border hover:border-secondary focus-within:border-secondary","px-4 py-2 rounded-full shadow cursor-pointer",(x||i)&&"bg-secondary"),children:[(0,o.jsx)(tE,{ref:v,autoFocus:t,placeholder:"Search for memes in this depot",className:"w-full outline-none bg-transparent",value:p,onChange:e=>h(e.target.value),onKeyDown:y,onFocus:()=>{v.current?.select()}}),(0,o.jsx)("div",{className:"text-secondary w-5",onClick:()=>{f()},children:x&&(0,o.jsx)("span",{className:"fa-solid fa-xmark cursor-pointer"})}),(0,o.jsx)(tw,{className:"pl-2",children:(0,o.jsx)("span",{className:"fa-solid fa-chevron-down text-secondary"})})]}),i&&E&&(0,o.jsxs)(t_,{className:"md:ml-6 max-md:px-4 absolute w-full md:w-96 z-4000 bg-default space-y-2 rounded-lg",anchor:{to:"bottom",gap:12,offset:0},children:[!!m&&(0,o.jsxs)("div",{className:(0,C.twMerge)("transition-all border border-secondary rounded-lg max-h-36 overflow-auto bg-secondary shadow-lg relative"),children:[(0,o.jsx)("p",{className:"px-2 py-1 bg-tertiary font-semibold text-sm sticky top-0",children:"Selected Filters"}),(0,o.jsxs)("div",{className:"flex flex-wrap gap-2 p-2",children:[r.map(e=>(0,o.jsx)(ed,{type:e,onDelete:l},`type-${e}`)),s.map(e=>(0,o.jsx)(tT.default,{tag:e,context:"searchbar",onDelete:n},`tag-${e}`)),u.map(e=>(0,o.jsx)(tk.default,{label:e,context:"searchbar",onDelete:d},`label-${e}`))]})]}),(0,o.jsx)("div",{className:"min-h-6 py-1 bg-secondary border border-secondary overflow-hidden rounded-lg relative",children:(0,o.jsxs)("div",{className:"max-h-60 h-full overflow-auto",children:[p.trim()&&!!e&&(0,o.jsxs)("span",{className:"block truncate font-normal cursor-default select-none py-2 px-4 border-b border-secondary",children:[`Search titles & text for "${p}"`,(0,o.jsx)("i",{className:"fa-solid fa-turn-down-left ml-2"})]}),w.map(e=>(0,o.jsxs)("div",{children:[(0,o.jsxs)("p",{className:"px-2 py-1 bg-secondary font-semibold text-sm sticky top-0 z-4000",children:[e.label,e.icon&&(0,o.jsx)("span",{className:(0,C.twMerge)(e.icon,"pl-2")})]}),(0,o.jsx)("div",{className:"p-2 flex flex-wrap gap-2",children:e.results.map(e=>(0,o.jsx)(tC,{className:(0,C.twMerge)("relative cursor-default select-none"),value:e,children:(0,o.jsx)(O.default,{color:"secondary",size:"xs",label:e.label,children:(0,o.jsxs)("span",{className:"font-light text-[12px] ml-1",children:["(",e.count,")"]})})},e.label))})]},`results-section-${e.label}`)),!w.length&&(0,o.jsx)("p",{className:"px-2 py-3 text-secondary text-xs text-center",children:"Nothing left to filter on"})]})})]})]})})]})}var tU=e.i(82815);function tA({depot:e,fallback:t,myDepotMeme:s}){let{query:i}=(0,u.useRouter)(),n=i.slug,r=i.depotEdit,c=i.reviewingMemes,m=i.uploadingMemes,x=i.withdrawFundsModal,{tags:v,types:y,labels:b,text:w}=(0,A.useSearchStateContext)(),{trackMemeInView:S}=(0,tU.default)(),[_,T]=(0,g.useState)("MEMES"),{memes:k,isLoadingMore:I,canLoadNextPage:M,loadNextPage:P,reload:$}=(0,h.default)(t,{depotSlug:e.slug,tagFilter:v,typeFilter:y,labelFilter:b,textFilter:w}),R=n?s&&n===s.slug?s:k.find(e=>e.slug===n):void 0,{isSignedIn:N,isAdmin:L,isDepotOwner:D}=(0,E.useMeContext)(),F=D(e.slug),z=D(e.slug)||L,W=!e.is_created&&(N&&(L||F||e.anyone_can_upload)||e.anyone_can_upload),{device:V}=(0,B.useClientContext)(),{isMobile:q}=V,[H,G]=(0,g.useState)(!1);return(0,o.jsxs)("main",{className:"w-full py-5 max-w-7xl px-4 xl:px-0 mx-auto",children:[R&&!c&&(0,o.jsx)(f.default,{depot:e,meme:R,memes:k}),(0,o.jsx)(O.default,{href:"/",icon:"fa-arrow-left",label:"Back to Depots",textOnly:!0,size:"md"}),(0,o.jsx)("div",{className:"mt-4 mb-4 sm:mb-8",children:(0,o.jsx)(eo,{depot:e,isDepotOwner:F})}),W&&q&&(0,o.jsxs)("div",{className:"space-y-4",children:[(0,o.jsxs)("div",{className:"bg-purple-darkest p-4 rounded-xl flex items-center justify-between w-full cursor-pointer",onClick:()=>G(!H),children:[(0,o.jsxs)("div",{className:"space-x-2 flex-center",children:[(0,o.jsx)("i",{className:"fa-image fa-duotone text-purple-lighter fa-xl"}),(0,o.jsx)("p",{className:"font-medium",children:"Upload Memes"})]}),(0,o.jsx)(O.default,{icon:H?"fa-circle-minus":"fa-circle-plus",color:"link",textOnly:!0,iconType:"fa-solid",label:H?"Collapse":" ",iconPlacement:"after"})]}),(0,o.jsxs)("div",{className:(0,C.twMerge)("relative max-h-96 transition-all duration-300 ease-in-out overflow-hidden",H?"":"max-md:max-h-0"),children:[(0,o.jsx)("div",{className:"mb-4",children:(0,o.jsx)(U,{depot:e,onClose:$,disableFileDrop:!!r||!!m,disablePaste:!!r||!!m||!!x})}),(0,o.jsx)("div",{className:"mb-4",children:(0,o.jsx)(ea,{})})]})]}),(0,o.jsxs)("div",{className:"mb-4 flex max-md:flex-col-reverse justify-between items-center gap-2 overflow-hidden",children:[(0,o.jsx)(ec,{setActiveTab:T,depot:e}),(0,o.jsx)(tI,{depot:e})]}),"MEMES"===_&&(0,o.jsxs)(o.Fragment,{children:[!e.meme_count&&(0,o.jsx)(j.default,{className:"mb-4",children:"This depot has 0 memes"}),(0,o.jsxs)(a.default,{loadNextPage:P,children:[W&&!q&&(0,o.jsx)(U,{depot:e,onClose:$,disableFileDrop:!!r||!!m,disablePaste:!!r||!!m||!!x}),W&&!q&&(0,o.jsx)(ea,{}),F&&e.require_moderation&&e.pending_meme_count>0&&(0,o.jsx)(K,{depot:e,reloadMemes:$}),e.is_favorites&&s&&(0,o.jsx)(l.default,{depot:e,meme:s,hasEditPermission:!1,canAction:!1},"favorite"),k.map(t=>(0,o.jsx)(l.default,{depot:e,meme:t,hasEditPermission:z,canAction:t.mod_approved,trackWhenInViewFn:e=>S(e)},t.slug))]}),I&&(0,o.jsx)(p.default,{text:"Hang on, loading some more memes..."}),M&&(0,o.jsx)(d,{onClick:P})]})]})}var tM=e.i(276025),tP=e.i(771231),t$=e.i(350461);globalThis.EventTarget&&globalThis.Event||console.error(` 2 PartySocket requires a global 'EventTarget' class to be available! 3 You can polyfill this global by adding this to your code before any partysocket imports: 4 5 \`\`\` 6 import 'partysocket/event-target-polyfill'; 7 \`\`\` 8 Please file an issue at https://github.com/partykit/partykit if you're still having trouble. 9`);
9var tO=class extends Event{message;error;constructor(e,t){super("error",t),this.message=e.message,this.error=e}},tR=class extends Event{code;reason;wasClean=!0;constructor(e=1e3,t="",s){super("close",s),this.code=e,this.reason=t}},tN=void 0!==t$.default&&void 0!==t$.default.versions?.node&&"u"<typeof document?function(e){return"data"in e?new MessageEvent(e.type,e):"code"in e||"reason"in e?new tR(e.code||1999,e.reason||"unknown reason",e):"error"in e?new tO(e.error,e):new Event(e.type,e)}:function(e){return new e.constructor(e.type,e)},tL={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+4e3*Math.random(),minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0},tD=!1,tF=class e extends EventTarget{_ws;_retryCount=-1;_uptimeTimeout;_connectTimeout;_shouldReconnect=!0;_connectLock=!1;_binaryType="blob";_closeCalled=!1;_messageQueue=[];_debugLogger=console.log.bind(console);_url;_protocols;_options;constructor(e,t,s={}){super(),this._url=e,this._protocols=t,this._options=s,this._options.startClosed&&(this._shouldReconnect=!1),this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return e.CONNECTING}get OPEN(){return e.OPEN}get CLOSING(){return e.CLOSING}get CLOSED(){return e.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((e,t)=>("string"==typeof t?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e),0)+(this._ws?this._ws.bufferedAmount:0)}get extensions(){return this._ws?this._ws.extensions:""}get protocol(){return this._ws?this._ws.protocol:""}get readyState(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING}get url(){return this._ws?this._ws.url:""}get shouldReconnect(){return this._shouldReconnect}onclose=null;onerror=null;onmessage=null;onopen=null;close(e=1e3,t){(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),this._ws)?this._ws.readyState===this.CLOSED?this._debug("close: already closed"):this._ws.close(e,t):this._debug("close enqueued: no ws instance")}reconnect(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,this._ws&&this._ws.readyState!==this.CLOSED&&this._disconnect(e,t),this._connect()}send(e){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",e),this._ws.send(e);else{let{maxEnqueuedMessages:t=tL.maxEnqueuedMessages}=this._options;this._messageQueue.length<t&&(this._debug("enqueue",e),this._messageQueue.push(e))}}_debug(...e){this._options.debug&&this._debugLogger("RWS>",...e)}_getNextDelay(){let{reconnectionDelayGrowFactor:e=tL.reconnectionDelayGrowFactor,minReconnectionDelay:t=tL.minReconnectionDelay,maxReconnectionDelay:s=tL.maxReconnectionDelay}=this._options,i=0;return this._retryCount>0&&(i=t*Math.pow(e,this._retryCount-1))>s&&(i=s),this._debug("next delay",i),i}_wait(){return new Promise(e=>{setTimeout(e,this._getNextDelay())})}_getNextProtocols(e){if(!e)return Promise.resolve(null);if("string"==typeof e||Array.isArray(e))return Promise.resolve(e);if("function"==typeof e){let t=e();if(!t)return Promise.resolve(null);if("string"==typeof t||Array.isArray(t))return Promise.resolve(t);if(t.then)return t}throw Error("Invalid protocols")}_getNextUrl(e){if("string"==typeof e)return Promise.resolve(e);if("function"==typeof e){let t=e();if("string"==typeof t)return Promise.resolve(t);if(t.then)return t}throw Error("Invalid URL")}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;
9let{maxRetries:e=tL.maxRetries,connectionTimeout:t=tL.connectionTimeout}=this._options;this._retryCount>=e?this._debug("max retries reached",this._retryCount,">=",e):(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),this._wait().then(()=>Promise.all([this._getNextUrl(this._url),this._getNextProtocols(this._protocols||null)])).then(([e,s])=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&"u"<typeof WebSocket&&!tD&&(console.error(`\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket. 10 11For example, if you're using node.js, run \`npm install ws\`, and then in your code: 12 13import PartySocket from 'partysocket'; 14import WS from 'ws'; 15 16const partysocket = new PartySocket({ 17 host: "127.0.0.1:1999", 18 room: "test-room", 19 WebSocket: WS 20}); 21 22`),tD=!0);let i=this._options.WebSocket||WebSocket;this._debug("connect",{url:e,protocols:s}),this._ws=s?new i(e,s):new i(e),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)}).catch(e=>{this._connectLock=!1,this._handleError(new tO(Error(e.message),this))}))}_handleTimeout(){this._debug("timeout event"),this._handleError(new tO(Error("TIMEOUT"),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{this._ws.close(e,t),this._handleClose(new tR(e,t,this))}catch(e){}}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_handleOpen=e=>{this._debug("open event");let{minUptime:t=tL.minUptime}=this._options;if(clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),!this._ws)throw Error("WebSocket is not defined");this._ws.binaryType=this._binaryType,this._messageQueue.forEach(e=>this._ws?.send(e)),this._messageQueue=[],this.onopen&&this.onopen(e),this.dispatchEvent(tN(e))};_handleMessage=e=>{this._debug("message event"),this.onmessage&&this.onmessage(e),this.dispatchEvent(tN(e))};_handleError=e=>{this._debug("error event",e.message),this._disconnect(void 0,"TIMEOUT"===e.message?"timeout":void 0),this.onerror&&this.onerror(e),this._debug("exec error listeners"),this.dispatchEvent(tN(e)),this._connect()};_handleClose=e=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(tN(e))};_removeListeners(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))}_addListeners(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}},tB=e=>null!==e[1]&&void 0!==e[1];function tz(e,t,s={}){let{host:i,path:n,protocol:o,room:r,party:a,query:l}=e,u=i.replace(/^(http|https|ws|wss):\/\//,"");if(u.endsWith("/")&&(u=u.slice(0,-1)),n&&n.startsWith("/"))throw Error("path must not start with a slash");let c=n?`/${n}`:"",d=o||(u.startsWith("localhost:")||u.startsWith("127.0.0.1:")||u.startsWith("192.168.")||u.startsWith("10.")||u.startsWith("172.")&&u.split(".")[1]>="16"&&u.split(".")[1]<="31"||u.startsWith("[::ffff:7f00:1]:")?t:t+"s"),p=`${d}://${u}/${a?`parties/${a}`:"party"}/${r}${c}`,h=(e={})=>`${p}?${new URLSearchParams([...Object.entries(s),...Object.entries(e).filter(tB)])}`;return{host:u,path:c,room:r,name:a??"main",protocol:d,partyUrl:p,urlProvider:"function"==typeof l?async()=>h(await l()):h(l)}}var tW=class extends tF{constructor(e){const t=tK(e);super(t.urlProvider,t.protocols,t.socketOptions),this.partySocketOptions=e,this.setWSProperties(t)}_pk;_pkurl;name;room;host;path;updateProperties(e){let t=tK({...this.partySocketOptions,...e,host:e.host??this.host,room:e.room??this.room,path:e.path??this.path});this._url=t.urlProvider,this._protocols=t.protocols,this._options=t.socketOptions,this.setWSProperties(t)}setWSProperties(e){let{_pk:t,_pkurl:s,name:i,room:n,host:o,path:r}=e;this._pk=t,this._pkurl=s,this.name=i,this.room=n,this.host=o,this.path=r}reconnect(e,t){if(!this.room||!this.host)throw Error("The room and host must be set before connecting, use `updateProperties` method to set them or pass them to the constructor.");super.reconnect(e,t)}get id(){return this._pk}get roomUrl(){return this._pkurl}static async fetch(e,t){let s=tz(e,"http"),i="string"==typeof s.urlProvider?s.urlProvider:await s.urlProvider();return(e.fetch??fetch)(i,t)}};function tK(e){let{id:t,host:s,path:i,party:n,room:o,protocol:r,query:a,protocols:l,...u}=e,c=t||function(){if("u">typeof crypto&&crypto.randomUUID)return crypto.randomUUID();let e=new Date().getTime(),t="u">typeof performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){let i=16*Math.random();return e>0?(i=(e+i)%16|0,e=Math.floor(e/16)):(i=(t+i)%16|0,t=Math.floor(t/16)),("x"===s?i:3&i|8).toString(16)})}(),d=tz(e,"ws",{_pk:c});return{_pk:c,_pkurl:d.partyUrl,name:d.name,room:d.room,host:d.host,path:d.path,protocols:l,socketOptions:u,urlProvider:d.urlProvider}}let tV=new TextEncoder;
22function tq(e,t,s){let i=t,n=i+s,o=[],r="";for(;i<n;){let t=e[i++];if((128&t)==0)o.push(t);else if((224&t)==192){let s=63&e[i++];o.push((31&t)<<6|s)}else if((240&t)==224){let s=63&e[i++],n=63&e[i++];o.push((31&t)<<12|s<<6|n)}else if((248&t)==240){let s=(7&t)<<18|(63&e[i++])<<12|(63&e[i++])<<6|63&e[i++];s>65535&&(s-=65536,o.push(s>>>10&1023|55296),s=56320|1023&s),o.push(s)}else o.push(t);o.length>=4096&&(r+=String.fromCharCode(...o),o.length=0)}return o.length>0&&(r+=String.fromCharCode(...o)),r}let tH=new TextDecoder;class tG{type;data;constructor(e,t){this.type=e,this.data=t}}class tY extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Object.create(tY.prototype)),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:tY.name})}}function tQ(e,t,s){let i=Math.floor(s/0x100000000);e.setUint32(t,i),e.setUint32(t+4,s)}function tJ(e,t){return 0x100000000*e.getInt32(t)+e.getUint32(t+4)}let tX={type:-1,encode:function(e){if(!(e instanceof Date))return null;{let t,s,i,n;return function({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=0x3ffffffff)if(0===t&&e<=0xffffffff){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t}else{let s=e/0x100000000,i=new Uint8Array(8),n=new DataView(i.buffer);return n.setUint32(0,t<<2|3&s),n.setUint32(4,0|e),i}{let s=new Uint8Array(12),i=new DataView(s.buffer);return i.setUint32(0,t),tQ(i,4,e),s}}((s=Math.floor((t=e.getTime())/1e3),n=Math.floor((i=(t-1e3*s)*1e6)/1e9),{sec:s+n,nsec:i-1e9*n}))}},decode:function(e){let t=function(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:{let e=t.getUint32(0);return{sec:(3&e)*0x100000000+t.getUint32(4),nsec:e>>>2}}case 12:return{sec:tJ(t,4),nsec:t.getUint32(0)};default:throw new tY(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}(e);return new Date(1e3*t.sec+t.nsec/1e6)}};class tZ{static defaultCodec=new tZ;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(tX)}register({type:e,encode:t,decode:s}){if(e>=0)this.encoders[e]=t,this.decoders[e]=s;else{let i=-1-e;this.builtInEncoders[i]=t,this.builtInDecoders[i]=s}}tryToEncode(e,t){for(let s=0;s<this.builtInEncoders.length;s++){let i=this.builtInEncoders[s];if(null!=i){let n=i(e,t);if(null!=n)return new tG(-1-s,n)}}for(let s=0;s<this.encoders.length;s++){let i=this.encoders[s];if(null!=i){let n=i(e,t);if(null!=n)return new tG(s,n)}}return e instanceof tG?e:null}decode(e,t,s){let i=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return i?i(e,t,s):new tG(t,e)}}function t0(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer||"u">typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer?new Uint8Array(e):Uint8Array.from(e)}class t1{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??tZ.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??100,this.initialBufferSize=e?.initialBufferSize??2048,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new t1({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw Error(`Too deep objects in depth ${t}`);null==e?this.encodeNil():"boolean"==typeof e?this.encodeBoolean(e):"number"==typeof e?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):"str
22ing"==typeof e?this.encodeString(e):this.useBigInt64&&"bigint"==typeof e?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(2*t)}resizeBuffer(e){let t=new ArrayBuffer(e),s=new Uint8Array(t),i=new DataView(t);s.set(this.bytes),this.view=i,this.bytes=s}encodeNil(){this.writeU8(192)}encodeBoolean(e){!1===e?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<0x100000000?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-0x80000000?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<0x100000000)this.writeU8(219),this.writeU32(e);else throw Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let t=function(e){let t=e.length,s=0,i=0;for(;i<t;){let n=e.charCodeAt(i++);if((0xffffff80&n)==0){s++;continue}if((0xfffff800&n)==0)s+=2;else{if(n>=55296&&n<=56319&&i<t){let t=e.charCodeAt(i);(64512&t)==56320&&(++i,n=((1023&n)<<10)+(1023&t)+65536)}(0xffff0000&n)==0?s+=3:s+=4}}return s}(e);this.ensureBufferSizeToWrite(5+t),this.writeStringHeader(t),function(e,t,s){if(e.length>50)tV.encodeInto(e,t.subarray(s));else!function(e,t,s){let i=e.length,n=s,o=0;for(;o<i;){let s=e.charCodeAt(o++);if((0xffffff80&s)==0){t[n++]=s;continue}if((0xfffff800&s)==0)t[n++]=s>>6&31|192;else{if(s>=55296&&s<=56319&&o<i){let t=e.charCodeAt(o);(64512&t)==56320&&(++o,s=((1023&s)<<10)+(1023&t)+65536)}(0xffff0000&s)==0?t[n++]=s>>12&15|224:(t[n++]=s>>18&7|240,t[n++]=s>>12&63|128),t[n++]=s>>6&63|128}t[n++]=63&s|128}}(e,t,s)}(e,this.bytes,this.pos),this.pos+=t}encodeObject(e,t){let s=this.extensionCodec.tryToEncode(e,this.context);if(null!=s)this.encodeExtension(s);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if("object"==typeof e)this.encodeMap(e,t);else throw Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<0x100000000)this.writeU8(198),this.writeU32(t);else throw Error(`Too large binary: ${t}`);let s=t0(e);this.writeU8a(s)}encodeArray(e,t){let s=e.length;if(s<16)this.writeU8(144+s);else if(s<65536)this.writeU8(220),this.writeU16(s);else if(s<0x100000000)this.writeU8(221),this.writeU32(s);else throw Error(`Too large array: ${s}`);for(let s of e)this.doEncode(s,t+1)}countWithoutUndefined(e,t){let s=0;for(let i of t)void 0!==e[i]&&s++;return s}encodeMap(e,t){let s=Object.keys(e);this.sortKeys&&s.sort();let i=this.ignoreUndefined?this.countWithoutUndefined(e,s):s.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<0x100000000)this.writeU8(223),this.writeU32(i);else throw Error(`Too large map object: ${i}`);for(let i of s){let s=e[i];this.ignoreUndefined&&void 0===s||(this.encodeString(i),this.doEncode(s,t+1))}}encodeExtension(e){if("function"==typeof e.data){let t=e.data(this.pos+6),s=t.length;if(s>=0x100000000)throw Error(`Too large extension object: ${s}`);this.writeU8(201),this.writeU32(s),this.writeI8(e.type),this.writeU8a(t);return}let t=e.data.length;if(1===t)this.writeU8(212);else if(2===t)this.writeU8(213);else if(4===t)this.writeU8(214);else if(8===t)this.writeU8(215);else if(16===t)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<0x100000000)this.writeU8(201),this.writeU32(t);else throw Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){var t,s;this.ensureBufferSizeToWrite(8),t=this.view,s=this.pos,t.setUint32(s,e/0x100000000),t.setUint32(s+4,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),tQ(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}}function t2(e){return`${e<0?"-":""}0x${Math.abs(e).toString(16).padStart(2,"0")}`}let t6="array",t8="map_key",t3="map_value",t4=e=>{if("string"==typeof e||"number"==typeof e)return e;throw new tY("The type of key must be string or number but "+typeof e)};class t5{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=t6,t.position=0,t.size=e,t.array=Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=t8,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){return this.stackHeadPosition++,this.stackHeadPosition===this.stack.length&&this.stack.push({type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null}),this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw Error("Invalid stack state. Released state is not on top of the stack.");e.type===t6&&(e.size=0,e.array=void 0,e.position=0,e.type=void 0),(e.type===t8||e.type===t3)&&(e.size=0,e.map=void 0,e.readCount=0,e.type=void 0),this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}let t9=new DataView(new ArrayBuffer(0)),t7=new Uint8Array(t9.buffer);try{t9.getInt8(0)}catch(e){if(!(e instanceof RangeError))throw Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}
22let se=RangeError("Insufficient data"),st=new class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=16,t=16){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let e=0;e<this.maxKeyLength;e++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,s){let i=this.caches[s-1];e:for(let n of i){let i=n.bytes;for(let n=0;n<s;n++)if(i[n]!==e[t+n])continue e;return n.str}return null}store(e,t){let s=this.caches[e.length-1],i={bytes:e,str:t};s.length>=this.maxLengthPerKey?s[Math.random()*s.length|0]=i:s.push(i)}decode(e,t,s){let i=this.find(e,t,s);if(null!=i)return this.hit++,i;this.miss++;let n=tq(e,t,s),o=Uint8Array.prototype.slice.call(e,t,t+s);return this.store(o,n),n}};class ss{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=t9;bytes=t7;headByte=-1;stack=new t5;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??tZ.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??0xffffffff,this.maxBinLength=e?.maxBinLength??0xffffffff,this.maxArrayLength=e?.maxArrayLength??0xffffffff,this.maxMapLength=e?.maxMapLength??0xffffffff,this.maxExtLength=e?.maxExtLength??0xffffffff,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:st,this.mapKeyConverter=e?.mapKeyConverter??t4}clone(){return new ss({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=-1,this.stack.reset()}setBuffer(e){let t=t0(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(-1!==this.headByte||this.hasRemaining(1)){let t=this.bytes.subarray(this.pos),s=t0(e),i=new Uint8Array(t.length+s.length);i.set(t),i.set(s,t.length),this.setBuffer(i)}else this.setBuffer(e)}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:s}=this;return RangeError(`Extra ${t.byteLength-s} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){let t=this.clone();yield*t.decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{let t;this.entered=!0;let s=!1;for await(let i of e){if(s)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(i);try{t=this.doDecodeSync(),s=!0}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}if(s){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return t}let{headByte:i,pos:n,totalPos:o}=this;throw RangeError(`Insufficient data in parsing ${t2(i)} at ${o} (${n} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async *decodeMultiAsync(e,t){if(this.entered){let s=this.clone();yield*s.decodeMultiAsync(e,t);return}try{this.entered=!0;let s=t,i=-1;for await(let n of e){if(t&&0===i)throw this.createExtraByteError(this.totalPos);this.appendBuffer(n),s&&(i=this.readArraySize(),s=!1,this.complete());try{for(;yield this.doDecodeSync(),0!=--i;);}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){t:for(;;){let e,t=this.readHeadByte();if(t>=224)e=t-256;else if(t<192)if(t<128)e=t;else if(t<144){let s=t-128;if(0!==s){this.pushMapState(s),this.complete();continue}e={}}else if(t<160){let s=t-144;if(0!==s){this.pushArrayState(s),this.complete();continue}e=[]}else{let s=t-160;e=this.decodeString(s,0)}else if(192===t)e=null;else if(194===t)e=!1;else if(195===t)e=!0;else if(202===t)e=this.readF32();else if(203===t)e=this.readF64();else if(204===t)e=this.readU8();else if(205===t)e=this.readU16();else if(206===t)e=this.readU32();else if(207===t)e=this.useBigInt64?this.readU64AsBigInt():this.readU64();else if(208===t)e=this.readI8();else if(209===t)e=this.readI16();else if(210===t)e=this.readI32();else if(211===t)e=this.useBigInt64?this.readI64AsBigInt():this.readI64();else if(217===t){let t=this.lookU8();e=this.decodeString(t,1)}else if(218===t){let t=this.lookU16();e=this.decodeString(t,2)}else if(219===t){let t=this.lookU32();e=this.decodeString(t,4)}else if(220===t){let t=this.readU16();if(0!==t){this.pushArrayState(t),this.complete();continue}e=[]}else if(221===t){let t=this.readU32();if(0!==t){this.pushArrayState(t),this.complete();continue}e=[]}else if(222===t){let t=this.readU16();if(0!==t){this.pushMapState(t),this.complete();continue}e={}}else if(223===t){let t=this.readU32();if(0!==t){this.pushMapState(t),this.complete();continue}e={}}else if(196===t){let t=this.lookU8();e=this.decodeBinary(t,1)}else if(197===t){let t=this.lookU16();e=this.decodeBinary(t,2)}else if(198===t){let t=this.lookU32();e=this.decodeBinary(t,4)}else if(212===t)e=this.decodeExtension(1,0);else if(213===t)e=this.decodeExtension(2,0);else if(214===t)e=this.decodeExtension(4,0);else if(215===t)e=this.decodeExtension(8,0);else if(216===t)e=this.decodeExtension(16,0);else if(199===t){let t=this.lookU8();e=this.decodeExtension(t,1)}else if(200===t){let t=this.lookU16();e=this.decodeExtension(t,2)}else if(201===t){let t=this.lookU32();e=this.decodeExtension(t,4)}else throw new tY(`Unrecognized type byte: ${t2(t)}`);this.complete();let s=this.stack;for(;s.length>0;){let t=s.top();if(t.type===t6)if(t.array[t.position]=e,t.position++,t.position===t.size)e=t.array,s.release(t);else continue t;else if(t.type===t8){if("__proto__"===e)throw new tY("The key __proto__ is not allowed");t.key=this.mapKeyConverter(e),t.type=t3;continue t}else if(t.map[t.key]=e,t.readCount++,t.readCount===t.size)e=t.map,s.release(t);else{t.key=null,t.type=t8;continue t}}return e}}readHeadByte(){return -1===this.headByte&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=-1}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new tY(`Unrecognized array type byte: ${t2(e)}`)}}pushMapState(e){if(e>this.maxMapLength)throw new tY(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new tY(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){let s;if(e>this.maxStrLength)throw new tY(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw se;let i=this.pos+t;return s=this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?this.keyDecoder.decode(this.bytes,i,e):function(e,t,s){let i;if(!(s>
22200))return tq(e,t,s);return i=e.subarray(t,t+s),tH.decode(i)}(this.bytes,i,e),this.pos+=t+e,s}stateIsMapKey(){return this.stack.length>0&&this.stack.top().type===t8}decodeBinary(e,t){if(e>this.maxBinLength)throw new tY(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw se;let s=this.pos+t,i=this.bytes.subarray(s,s+e);return this.pos+=t+e,i}decodeExtension(e,t){if(e>this.maxExtLength)throw new tY(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let s=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,s,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){var e,t;let s=(e=this.view,t=this.pos,0x100000000*e.getUint32(t)+e.getUint32(t+4));return this.pos+=8,s}readI64(){let e=tJ(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}}var si=e.i(863782);let sn="Anonymous",so=si.object({x:si.number(),y:si.number(),pointer:si.union([si.literal("mouse"),si.literal("touch")])}),sr=si.object({name:si.string(),cursor:so.optional().nullable(),message:si.string().optional().nullable(),spotlightColor:si.string().optional(),uuid:si.string().optional().nullable(),image:si.string().optional().nullable(),passCount:si.number().optional().nullable()}),sa=si.object({country:si.string().nullable()}),sl=si.object({presence:sr,metadata:sa}),su=si.discriminatedUnion("type",[si.object({type:si.literal("syncExisting"),users:si.record(sl)}),si.object({type:si.literal("updateUsers"),add:si.record(sl).optional(),presence:si.record(sr).optional(),remove:si.array(si.string()).optional()})]),sc=si.object({type:si.literal("updatePresence"),presence:sr});function sd(e){var t;return t=sc.parse(e),new t1(void 0).encodeSharedRef(t)}let sp={get url(){return`file://${e.P("node_modules/zustand/esm/vanilla.mjs")}`}},sh=e=>{let t,s=new Set,i=(e,i)=>{let n="function"==typeof e?e(t):e;if(!Object.is(n,t)){let e=t;t=(null!=i?i:"object"!=typeof n||null===n)?n:Object.assign({},t,n),s.forEach(s=>s(t,e))}},n=()=>t,o={setState:i,getState:n,getInitialState:()=>r,subscribe:e=>(s.add(e),()=>s.delete(e)),destroy:()=>{(sp.env?sp.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),s.clear()}},r=t=e(i,n,o);return o};var sf=e.i(191604);let sm={get url(){return`file://${e.P("node_modules/zustand/esm/index.mjs")}`}},{useDebugValue:sg}=g.default,{useSyncExternalStoreWithSelector:sx}=sf.default,sv=!1,sy=e=>{(sm.env?sm.env.MODE:void 0)!=="production"&&"function"!=typeof e&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");let t="function"==typeof e?e?sh(e):sh:e,s=(e,s)=>(function(e,t=e=>e,s){(sm.env?sm.env.MODE:void 0)!=="production"&&s&&!sv&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),sv=!0);let i=sx(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,s);return sg(i),i})(t,e,s);return Object.assign(s,t),s},sb=e=>e?sy(e):sy,sw=sb(e=>({myId:null,myself:null,setMyId:t=>e({myId:t}),synced:!1,setSynced:t=>e({synced:t}),pendingUpdate:null,clearPendingUpdate:()=>e({pendingUpdate:null}),updatePresence:t=>e(e=>{if(!e.myself)return{};let s={...e.myself.presence,...t};return{myself:{...e.myself,presence:s}
22,pendingUpdate:s}}),otherUsers:new Map,setUsers:t=>e(e=>{let s=new Map;return t.forEach((t,i)=>{i!==e.myId&&s.set(i,t)}),{myself:e.myId?t.get(e.myId):null,otherUsers:s}}),addUser:(t,s)=>{e(e=>{if(t===e.myId)return{};let i=new Map(e.otherUsers);return i.set(t,s),{otherUsers:i}})},removeUser:t=>{e(e=>{if(t===e.myId)return{};let s=new Map(e.otherUsers);return s.delete(t),{otherUsers:s}})},updateUser:(t,s)=>{e(e=>{if(t===e.myId)return{};let i=new Map(e.otherUsers),n=i.get(t);return n&&i.set(t,{...n,presence:s}),{otherUsers:i}})}})),sE=(0,g.createContext)({});function sS(e){let{setMyId:t,setUsers:s,addUser:i,updateUser:n,removeUser:r,pendingUpdate:a,clearPendingUpdate:l,synced:u,setSynced:c}=sw(),d=async e=>{let o=e.data instanceof Blob?"string"==typeof(u=await e.data.arrayBuffer())?JSON.parse(u):new ss(void 0).decode(u):JSON.parse(e.data),a=su.safeParse(o);if(!a.success)return;let l=a.data;switch(l.type){case"syncExisting":t(p.id),s(new Map(Object.entries(l.users))),c(!0);break;case"updateUsers":var u;if("updateUsers"===l.type){if(l.add)for(let[e,t]of Object.entries(l.add))i(e,t);if(l.presence)for(let[e,t]of Object.entries(l.presence))n(e,t);if(l.remove)for(let e of l.remove)r(e)}}},p=function(e){let t,{host:s,...i}=e,n=function({options:e,createSocket:t,createSocketMemoKey:s}){let i=s(e),n=(0,g.useMemo)(()=>e,[i]),[o,r]=(0,g.useState)(()=>t({...n,startClosed:!0})),a=(0,g.useRef)(null),l=(0,g.useRef)(t);return l.current=t,(0,g.useEffect)(()=>{if(a.current!==o)return a.current||!0===n.startClosed||o.reconnect(),a.current=o,()=>{o.close()};r(l.current({...n,startClosed:!1}))},[o,n]),o}({options:{host:s||("u">typeof window?window.location.host:"dummy-domain.com"),...i},createSocket:e=>new tW(e),createSocketMemoKey:e=>JSON.stringify([e.query,e.id,e.host,e.room,e.party,e.path,e.protocol,e.protocols,e.startClosed,e.minUptime,e.maxRetries,e.connectionTimeout,e.maxEnqueuedMessages,e.maxReconnectionDelay,e.minReconnectionDelay,e.reconnectionDelayGrowFactor,e.debug])});return(t=(0,g.useRef)(e)).current=e,(0,g.useEffect)(()=>{let e=e=>t.current?.onOpen?.(e),s=e=>t.current?.onMessage?.(e),i=e=>t.current?.onClose?.(e),o=e=>t.current?.onError?.(e);return n.addEventListener("open",e),n.addEventListener("close",i),n.addEventListener("error",o),n.addEventListener("message",s),()=>{n.removeEventListener("open",e),n.removeEventListener("close",i),n.removeEventListener("error",o),n.removeEventListener("message",s)}},[n]),n}({host:"https://memedepot.kdsbatra.partykit.dev",party:"depot_cursor",room:e.room,query:{name:e.presence.name,image:e.presence.image,uuid:e.presence.uuid,passCount:e.presence.passCount?.toString()||"0",secret:"taBgnQRXqCSFly1m5xdCogdJkjOnQn2c",from:window.location.href},onMessage:d,onClose:e=>console.warn("Socket closed:",e),onError:e=>console.error("Socket error:",e)});return(0,g.useEffect)(()=>{if(p&&(t(p.id),!u)){let t={type:"updatePresence",presence:e.presence};p.send(sd(t))}},[e.presence,t,u,p]),(0,g.useEffect)(()=>{a&&p&&(p.send(sd({type:"updatePresence",presence:a})),l())},[p,a,l]),(0,o.jsx)(sE.Provider,{value:{},children:e.children})}let s_=sb(()=>({myId:null,myself:null,otherUsers:new Map,within:"window",cursorWidth:32,cursorHeight:32})),sC={src:e.i(441764).default,width:152,height:148,blurWidth:8,blurHeight:8,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAABE0lEQVR42gEIAff+AAAAAAAtKy0qnnKdnett5/LSeNDVKicqJwAAAAAAAAAAAB8eHxuecZ6e9Efr/vpB6//oTeP5cFBwbwMDAwIAAAAAAMqKycjtSub2/Drs//Jx6f/TrtH/jnqNziwsKywCAgIBAPJ37vv6Oev/6mHg/9mw1v+Qjo3/c1tN/Y+AddA3NjY2ALGPsK3sW+f20qDQ/pGPj/96Wkj/pk0N/5NSH/5cWVeCABoaGhdYSVhVmZKZ1HZeUP+nTxD/xVsE/4pSKP5pZ2aKAAAAAAACAgIBSkpKS5SAceKVSxH/l1Md/6hXE/6PfG3fAAAAAAAAAAAABQUFBGRjY2mRi4bPnpiUxJx9YvSCd26z+Ep4CUFagoUAAAAASUVORK5CYII="};function sj({className:e}){return(0,o.jsx)("i",{className:(0,C.twMerge)("fa-solid fa-ticket-simple text-blue-gradient",e)})}function sT({user:e,width:t,height:s,isMe:i}
22){let n={x:e.presence.cursor?.x,y:e.presence.cursor?.y,pointer:e.presence.cursor?.pointer,message:e.presence.message??null,imageUrl:e.presence.image},r=e.presence.uuid&&!i,a=(0,C.twMerge)("relative flex-center",r&&"cursor-pointer pointer-events-auto"),l=(0,o.jsx)(R.default,{src:n.imageUrl||sC,alt:`Image for ${e.presence.name}`,width:t,height:s,className:(0,C.twMerge)("object-cover rounded",!n.imageUrl&&"p-1")}),u=r?(0,o.jsx)(z.default,{href:(0,ei.getUserLink)({username:e.presence.name!==sn?e.presence.name:null,uuid:e.presence.uuid||""}),className:a,"data-tooltip-id":"tooltip","data-tooltip-content":`${e.presence.name} (x${e.presence.passCount??0})`,children:l}):(0,o.jsx)("div",{className:a,"data-tooltip-id":"tooltip","data-tooltip-content":`${e.presence.name} (x${e.presence.passCount??0})`,children:l});return(0,o.jsxs)("div",{className:(0,C.twMerge)("absolute z-1000 overflow-hidden flex-center gap-2 shadow-lg","rounded-b-xl rounded-tr-xl px-2 py-1",i?"bg-primary":"bg-tertiary transition-all duration-75"),style:{transform:`translate(${n.x}px, ${n.y}px)`},children:[u,(0,o.jsxs)("div",{children:[(0,o.jsxs)("p",{className:"text-xs text-secondary",children:[e.presence.name," (",e.presence.passCount??0," ",(0,o.jsx)(sj,{}),"):"]}),(0,o.jsx)("span",{children:n.message})]})]})}function sk({user:e,width:t,height:s,isMe:i}
22){let n={x:e.presence.cursor?.x,y:e.presence.cursor?.y,pointer:e.presence.cursor?.pointer,message:e.presence.message??null,imageUrl:e.presence.image},r=!!e.presence.uuid&&!i,a=(0,C.twMerge)("flex-center",r&&"cursor-pointer pointer-events-auto"),l=(0,o.jsx)(R.default,{src:n.imageUrl||sC,alt:`Image for ${e.presence.name}`,width:t,height:s,className:(0,C.twMerge)("object-cover rounded",!n.imageUrl&&"p-1")}),u=r?(0,o.jsx)(z.default,{href:(0,ei.getUserLink)({username:e.presence.name!==sn?e.presence.name:null,uuid:e.presence.uuid||""}),className:a,"data-tooltip-id":"tooltip","data-tooltip-content":`${e.presence.name} (x${e.presence.passCount??0})`,children:l}):(0,o.jsx)("div",{className:a,"data-tooltip-id":"tooltip","data-tooltip-content":`${e.presence.name} (x${e.presence.passCount??0})`,children:l});return(0,o.jsx)("div",{className:(0,C.twMerge)("absolute z-1000 overflow-hidden flex-center gap-2 shadow-lg","rounded-b-full rounded-tr-full relative",i?"bg-primary":"bg-tertiary transition-all duration-75"),style:{transform:`translate(${n.x}px, ${n.y}px)`,width:t,height:s},children:u})}function sI({showChat:e,...t}){return e&&t.user.presence.message?(0,o.jsx)(sT,{...t}):(0,o.jsx)(sk,{...t})}function sU({showChat:e=!1}){let{device:{isMobile:t}}=(0,B.useClientContext)(),{otherUsers:s,cursorHeight:i,cursorWidth:n,within:r,mySelf:a}=s_(e=>({otherUsers:Array.from(e.otherUsers.entries()),cursorWidth:e.cursorWidth,cursorHeight:e.cursorHeight,within:e.within,mySelf:e.myself})),l=(0,g.useCallback)((e,t)=>t?e+5*Number(t):e,[]);return(0,o.jsxs)("div",{className:(0,C.twMerge)("window"===r?"fixed":"absolute","
22inset-0 pointer-events-none overflow-clip z-1000"),children:[a&&(t||!!a.presence.message?.length)&&(0,o.jsx)(sI,{user:a,showChat:e,width:l(n,a.presence.passCount),height:l(i,a.presence.passCount),isMe:!0},a.presence.uuid),s.map(([t,s])=>s.presence?.cursor?(0,o.jsx)(sI,{showChat:e,user:s,width:l(n,s.presence.passCount),height:l(i,s.presence.passCount)},t):null)]})}var sA=e.i(96932),sM=e.i(401846),sP=e.i(50702);function s$(){let[e,t]=(0,g.useState)(!1),{device:{isMobile:s}}=(0,B.useClientContext)(),[i,n]=(0,g.useState)(""),{updatePresence:r,showReplyCTA:a}=sw(e=>{let t=Array.from(e.otherUsers.values()),s=!1;for(let e of t)if(e.presence?.message){s=!0;break}return{updatePresence:e.updatePresence,showReplyCTA:s}}),{resetShortcutLock:l}=(0,sM.default)("Backslash",()=>{e||(t(!0),n(""))}),u=g.useMemo(()=>({timeLimitMS:15e3,onComplete:()=>{t(!1),n(""),l()},disabled:!e||!i.length}),[e,i.length,l]),{reset:c,percent:d}=(0,sA.useTimer)(u),p=(0,g.useCallback)(s=>{(e||i.length)&&(c(),"Escape"===s.key?i.length?n(""):(t(!1),l()):"Enter"===s.key&&(t(!1),l()))},[e,i.length,l,c]);return((0,g.useEffect)(()=>(document.addEventListener("keydown",p),()=>{document.removeEventListener("keydown",p)}),[p]),(0,g.useEffect)(()=>{r({message:i.length>0?i:null})},[i,r]),a&&!e)?(0,o.jsx)(O.default,{color:"primary",rounded:"full",className:"border border-default/10 fixed z-1000 bottom-16 sm:bottom-20 right-4",onClick:()=>{t(!0)},label:s?"Reply":"Press \\ to Reply"}):e?(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)("div",{className:"bg-primary border border-default/20 fixed z-1000 bottom-16 sm:bottom-20 right-4 py-1.5 px-3 rounded-xl shadow-lg text-white space-y-1",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,o.jsx)(S.default,{autoFocus:!0,color:"transparent",placeholder:"Enter message here...",onChange:t=>{if(!e)return;let s=t.target.value;c(),n(e=>e.length<48||s.length<=e.length?s:e)},value:i}),(0,o.jsxs)("div",{className:"relative h-8 w-8",children:[(0,o.jsx)(sP.default,{circular:!0,percentage:d}),(0,o.jsx)("div",{className:"absolute inset-0.5",children:(0,o.jsx)(O.default,{onClick:()=>{c(),t(!1),n("")},rounded:"full",icon:"fa-times"})})]})]}),(0,o.jsxs)("span",{className:"text-xs text-secondary flex justify-between gap-1",children:[!s&&(0,o.jsxs)("p",{className:i.length?"":"text-red-300",children:["ESC to ",i.length?"clear":"close"]}),s&&(0,o.jsx)("span",{children:"Drag to move message"}),(0,o.jsxs)("p",{children:["(",i.length," / ",48,")"]})]})]})}):(0,o.jsx)(o.Fragment,{children:(0,o.jsx)(O.default,{color:"primary",rounded:"full",className:"border border-default/10 fixed z-1000 bottom-16 sm:bottom-20 right-4",onClick:()=>{t(!0)},label:s?"Chat":"Press \\ to Chat"})})}function sO(){return!function(e="window",{cursorWidth:t=32,cursorHeight:s=32}={}){let{screen:i,documentDimensions:n}=(0,B.useClientContext)(),{myId:o,myself:r,otherUsers:a,updatePresence:l}=sw(e=>({myId:e.myId,myself:e.myself,otherUsers:e.otherUsers,updatePresence:e.updatePresence})),[u,c]=(0,g.useState)(null),[d,p]=(0,g.useState)(null);(0,g.useEffect)(()=>{let t=t=>{c({x:t.clientX,y:t.clientY,pointer:"mouse"}),"document"===e&&p({x:t.pageX,y:t.pageY,pointer:"mouse"})};window.addEventListener("mousemove",t);let s=t=>{c({x:t.touches[0].clientX,y:t.touches[0].clientY,pointer:"touch"}),"document"===e&&p({x:t.touches[0].pageX,y:t.touches[0].pageY,pointer:"touch"})};window.addEventListener("touchmove",s);let i=()=>{c(null),"document"===e&&p(null)};return window.addEventListener("touchend",i),()=>{window.removeEventListener("mousemove",t),window.removeEventListener("touchmove",s),window.removeEventListener("touchend",i)}},[e]),(0,g.useEffect)(()=>{if("document"!==e)return;let t=()=>{let e=window.scrollX||document.documentElement.scrollLeft,t=window.scrollY||document.documentElement.scrollTop;p(()=>u?{...u,x:u.x+e,y:u.y+t}:null)};return window.addEventListener("scroll",t),t(),()=>{window.removeEventListener("scroll",t)}},[e,u]),(0,g.useEffect)(()=>{let t="window"===e?i:n,s="window"===e?u:d;
22null!==s&&i.width&&i.width?l({cursor:{x:s.x/t.width,y:s.y/t.height,pointer:s.pointer}}):l({cursor:null})},[u,d,i,n,l,e]);let h=t=>{let s="window"===e?i:n,o=t.presence?.cursor?{...t.presence.cursor,x:t.presence.cursor.x*s.width,y:t.presence.cursor.y*s.height}:null;return{...t,presence:{...t.presence,cursor:o}}};(0,g.useEffect)(()=>{let i=r?h(r):null,n=new Map;a.forEach((e,t)=>{n.set(t,h(e))}),s_.setState({myId:o,myself:i,otherUsers:n,within:e,cursorHeight:s,cursorWidth:t})})}("document"),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(sU,{showChat:!0}),(0,o.jsx)(s$,{})]})}function sR({children:e,roomId:t,disable:s,context:i}){let{me:n}=(0,E.useMeContext)();if(s);else if("presenceCursor"===i)return(0,o.jsxs)(sS,{room:t,presence:{name:n?.username||"Anonymous",image:n?.avatar_url,uuid:n?.uuid||void 0},children:[e,(0,o.jsx)(sO,{})]});return e}var sN=e.i(552760);function sL({depot:e,fallback:t,myDepotMeme:s}){let{isDepotOwner:i,me:n}=(0,E.useMeContext)(),a=(0,es.default)(e),{data:l}=(0,P.default)(`/api/depots/${e.slug}`,M.default,{fallbackData:{depot:e}}),u=l?.depot||e,{trackEntityViews:c}=(0,tU.default)();(0,g.useEffect)(()=>{c("depot",[u.slug])},[]);let d=!!n?.admin,p=(0,sN.default)(u);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(tM.NextSeo,{title:`Meme Depot - ${a}`,description:`Browse the best memes from ${a} depot`,canonical:`https://memedepot.com/d/${u.slug}`,openGraph:{images:u.cf_asset_id&&u.aspect_ratio?[{url:`${(0,N.publicImageUrl)(u.cf_asset_id,!0)}?${new Date().getTime()}`,width:1366,height:1366/u.aspect_ratio,alt:`${u.label} Cover Photo`,type:"image/jpeg"}]:[]},twitter:{handle:"@memedepot",site:"memedepot.com",cardType:"summary_large_image"},additionalMetaTags:u.cf_asset_id?[{name:"twitter:image",content:`${(0,N.publicImageUrl)(u.cf_asset_id,!0)}?${new Date().getTime()}`||"https://memedepot.com/alt-logo.png"},{name:"twitter:image:alt",content:`${a} Cover Photo`}]:[]}),(0,o.jsxs)(sR,{context:"presenceCursor",roomId:u.slug,disable:!0,children:[(0,o.jsx)(r.default,{}),"denied"===p&&(0,o.jsx)(tP.default,{}),(d||"allowed"===p)&&(0,o.jsx)(tA,{fallback:t,depot:u,myDepotMeme:s})]})]})}e.s(["NO_DEPOT_FOUND_REDIRECT",0,{redirect:{permanent:!1,destination:"/d/no-such-depot"}},"__N_SSP",()=>!0,"default",()=>sL],890861)},507273,(e,t,s)=>{let i="/d/[depotSlug]";(window.__NEXT_P=window.__NEXT_P||[]).push([i,()=>e.r(890861)]),t.hot&&t.hot.dispose(function(){window.__NEXT_P.push([i])})}]);
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.