@devvit/public-api 0.11.0-next-2024-07-10-032c868ba.0 → 0.11.0-next-2024-07-10-c63149a74.0

Sign up to get free protection for your applications and to get access to all the features.
package/public-api.min.js CHANGED
@@ -1,8 +1,8 @@
1
- var JS=Object.create;var dp=Object.defineProperty;var $S=Object.getOwnPropertyDescriptor;var KS=Object.getOwnPropertyNames;var XS=Object.getPrototypeOf,ZS=Object.prototype.hasOwnProperty;var h=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var YS=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of KS(e))!ZS.call(r,n)&&n!==t&&dp(r,n,{get:()=>e[n],enumerable:!(i=$S(e,n))||i.enumerable});return r};var Dr=(r,e,t)=>(t=r!=null?JS(XS(r)):{},YS(e||!r||!r.__esModule?dp(t,"default",{value:r,enumerable:!0}):t,r));var Jl=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var s=(r,e,t)=>(Jl(r,e,"read from private field"),t?t.call(r):e.get(r)),d=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},l=(r,e,t,i)=>(Jl(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var y=(r,e,t)=>(Jl(r,e,"access private method"),t);var oe=h((wF,lp)=>{lp.exports=function(r){try{return!!r()}catch{return!0}}});var Ta=h((IF,up)=>{var QS=oe();up.exports=!QS(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var $=h((AF,pp)=>{var cp=Ta(),mp=Function.prototype,$l=mp.call,eP=cp&&mp.bind.bind($l,$l);pp.exports=cp?eP:function(r){return function(){return $l.apply(r,arguments)}}});var gp=h((TF,fp)=>{var tP=Math.ceil,rP=Math.floor;fp.exports=Math.trunc||function(e){var t=+e;return(t>0?rP:tP)(t)}});var Ea=h((EF,hp)=>{var iP=gp();hp.exports=function(r){var e=+r;return e!==e||e===0?0:iP(e)}});var ce=h((RF,vp)=>{var Ra=function(r){return r&&r.Math==Math&&r};vp.exports=Ra(typeof globalThis=="object"&&globalThis)||Ra(typeof window=="object"&&window)||Ra(typeof self=="object"&&self)||Ra(typeof global=="object"&&global)||function(){return this}()||Function("return this")()});var _r=h((OF,yp)=>{yp.exports=!1});var Oa=h((FF,kp)=>{var bp=ce(),nP=Object.defineProperty;kp.exports=function(r,e){try{nP(bp,r,{value:e,configurable:!0,writable:!0})}catch{bp[r]=e}return e}});var Fa=h((MF,Pp)=>{var sP=ce(),oP=Oa(),Sp="__core-js_shared__",aP=sP[Sp]||oP(Sp,{});Pp.exports=aP});var Kl=h((LF,xp)=>{var dP=_r(),Cp=Fa();(xp.exports=function(r,e){return Cp[r]||(Cp[r]=e!==void 0?e:{})})("versions",[]).push({version:"3.27.2",mode:dP?"pure":"global",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.27.2/LICENSE",source:"https://github.com/zloirock/core-js"})});var Ma=h((UF,wp)=>{wp.exports=function(r){return r==null}});var La=h((BF,Ip)=>{var lP=Ma(),uP=TypeError;Ip.exports=function(r){if(lP(r))throw uP("Can't call method on "+r);return r}});var Bn=h((DF,Ap)=>{var cP=La(),mP=Object;Ap.exports=function(r){return mP(cP(r))}});var Ce=h((_F,Tp)=>{var pP=$(),fP=Bn(),gP=pP({}.hasOwnProperty);Tp.exports=Object.hasOwn||function(e,t){return gP(fP(e),t)}});var Xl=h((NF,Ep)=>{var hP=$(),vP=0,yP=Math.random(),bP=hP(1 .toString);Ep.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+bP(++vP+yP,36)}});var Op=h((qF,Rp)=>{Rp.exports=typeof navigator<"u"&&String(navigator.userAgent)||""});var _p=h((jF,Dp)=>{var Bp=ce(),Zl=Op(),Fp=Bp.process,Mp=Bp.Deno,Lp=Fp&&Fp.versions||Mp&&Mp.version,Up=Lp&&Lp.v8,He,Ua;Up&&(He=Up.split("."),Ua=He[0]>0&&He[0]<4?1:+(He[0]+He[1]));!Ua&&Zl&&(He=Zl.match(/Edge\/(\d+)/),(!He||He[1]>=74)&&(He=Zl.match(/Chrome\/(\d+)/),He&&(Ua=+He[1])));Dp.exports=Ua});var Yl=h((HF,qp)=>{var Np=_p(),kP=oe();qp.exports=!!Object.getOwnPropertySymbols&&!kP(function(){var r=Symbol();return!String(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Np&&Np<41})});var Ql=h((WF,jp)=>{var SP=Yl();jp.exports=SP&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var xe=h((GF,Wp)=>{var PP=ce(),CP=Kl(),Hp=Ce(),xP=Xl(),wP=Yl(),IP=Ql(),Nr=PP.Symbol,eu=CP("wks"),AP=IP?Nr.for||Nr:Nr&&Nr.withoutSetter||xP;Wp.exports=function(r){return Hp(eu,r)||(eu[r]=wP&&Hp(Nr,r)?Nr[r]:AP("Symbol."+r)),eu[r]}});var zp=h((VF,Vp)=>{var TP=xe(),EP=TP("toStringTag"),Gp={};Gp[EP]="z";Vp.exports=String(Gp)==="[object z]"});var ru=h((zF,Jp)=>{var tu=typeof document=="object"&&document.all,RP=typeof tu>"u"&&tu!==void 0;Jp.exports={all:tu,IS_HTMLDDA:RP}});var K=h((JF,Kp)=>{var $p=ru(),OP=$p.all;Kp.exports=$p.IS_HTMLDDA?function(r){return typeof r=="function"||r===OP}:function(r){return typeof r=="function"}});var Ba=h(($F,Zp)=>{var Xp=$(),FP=Xp({}.toString),MP=Xp("".slice);Zp.exports=function(r){return MP(FP(r),8,-1)}});var Dn=h((KF,Yp)=>{var LP=zp(),UP=K(),Da=Ba(),BP=xe(),DP=BP("toStringTag"),_P=Object,NP=Da(function(){return arguments}())=="Arguments",qP=function(r,e){try{return r[e]}catch{}};Yp.exports=LP?Da:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=qP(e=_P(r),DP))=="string"?t:NP?Da(e):(i=Da(e))=="Object"&&UP(e.callee)?"Arguments":i}});var _n=h((XF,Qp)=>{var jP=Dn(),HP=String;Qp.exports=function(r){if(jP(r)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return HP(r)}});var nu=h((ZF,rf)=>{var iu=$(),WP=Ea(),GP=_n(),VP=La(),zP=iu("".charAt),ef=iu("".charCodeAt),JP=iu("".slice),tf=function(r){return function(e,t){var i=GP(VP(e)),n=WP(t),o=i.length,a,c;return n<0||n>=o?r?"":void 0:(a=ef(i,n),a<55296||a>56319||n+1===o||(c=ef(i,n+1))<56320||c>57343?r?zP(i,n):a:r?JP(i,n,n+2):(a-55296<<10)+(c-56320)+65536)}};rf.exports={codeAt:tf(!1),charAt:tf(!0)}});var of=h((YF,sf)=>{var $P=ce(),KP=K(),nf=$P.WeakMap;sf.exports=KP(nf)&&/native code/.test(String(nf))});var bt=h((QF,lf)=>{var af=K(),df=ru(),XP=df.all;lf.exports=df.IS_HTMLDDA?function(r){return typeof r=="object"?r!==null:af(r)||r===XP}:function(r){return typeof r=="object"?r!==null:af(r)}});var me=h((eM,uf)=>{var ZP=oe();uf.exports=!ZP(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7})});var ou=h((tM,mf)=>{var YP=ce(),cf=bt(),su=YP.document,QP=cf(su)&&cf(su.createElement);mf.exports=function(r){return QP?su.createElement(r):{}}});var au=h((rM,pf)=>{var eC=me(),tC=oe(),rC=ou();pf.exports=!eC&&!tC(function(){return Object.defineProperty(rC("div"),"a",{get:function(){return 7}}).a!=7})});var du=h((iM,ff)=>{var iC=me(),nC=oe();ff.exports=iC&&nC(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42})});var Xe=h((nM,gf)=>{var sC=bt(),oC=String,aC=TypeError;gf.exports=function(r){if(sC(r))return r;throw aC(oC(r)+" is not an object")}});var We=h((sM,hf)=>{var dC=Ta(),_a=Function.prototype.call;hf.exports=dC?_a.bind(_a):function(){return _a.apply(_a,arguments)}});var Nn=h((oM,vf)=>{var lu=ce(),lC=K(),uC=function(r){return lC(r)?r:void 0};vf.exports=function(r,e){return arguments.length<2?uC(lu[r]):lu[r]&&lu[r][e]}});var uu=h((aM,yf)=>{var cC=$();yf.exports=cC({}.isPrototypeOf)});var cu=h((dM,bf)=>{var mC=Nn(),pC=K(),fC=uu(),gC=Ql(),hC=Object;bf.exports=gC?function(r){return typeof r=="symbol"}:function(r){var e=mC("Symbol");return pC(e)&&fC(e.prototype,hC(r))}});var mu=h((lM,kf)=>{var vC=String;kf.exports=function(r){try{return vC(r)}catch{return"Object"}}});var Na=h((uM,Sf)=>{var yC=K(),bC=mu(),kC=TypeError;Sf.exports=function(r){if(yC(r))return r;throw kC(bC(r)+" is not a function")}});var qa=h((cM,Pf)=>{var SC=Na(),PC=Ma();Pf.exports=function(r,e){var t=r[e];return PC(t)?void 0:SC(t)}});var xf=h((mM,Cf)=>{var pu=We(),fu=K(),gu=bt(),CC=TypeError;Cf.exports=function(r,e){var t,i;if(e==="string"&&fu(t=r.toString)&&!gu(i=pu(t,r))||fu(t=r.valueOf)&&!gu(i=pu(t,r))||e!=="string"&&fu(t=r.toString)&&!gu(i=pu(t,r)))return i;throw CC("Can't convert object to primitive value")}});var Tf=h((pM,Af)=>{var xC=We(),wf=bt(),If=cu(),wC=qa(),IC=xf(),AC=xe(),TC=TypeError,EC=AC("toPrimitive");Af.exports=function(r,e){if(!wf(r)||If(r))return r;var t=wC(r,EC),i;if(t){if(e===void 0&&(e="default"),i=xC(t,r,e),!wf(i)||If(i))return i;throw TC("Can't convert object to primitive value")}return e===void 0&&(e="number"),IC(r,e)}});var ja=h((fM,Ef)=>{var RC=Tf(),OC=cu();Ef.exports=function(r){var e=RC(r,"string");return OC(e)?e:e+""}});var Ze=h(Of=>{var FC=me(),MC=au(),LC=du(),Ha=Xe(),Rf=ja(),UC=TypeError,hu=Object.defineProperty,BC=Object.getOwnPropertyDescriptor,vu="enumerable",yu="configurable",bu="writable";Of.f=FC?LC?function(e,t,i){if(Ha(e),t=Rf(t),Ha(i),typeof e=="function"&&t==="prototype"&&"value"in i&&bu in i&&!i[bu]){var n=BC(e,t);n&&n[bu]&&(e[t]=i.value,i={configurable:yu in i?i[yu]:n[yu],enumerable:vu in i?i[vu]:n[vu],writable:!1})}return hu(e,t,i)}:hu:function(e,t,i){if(Ha(e),t=Rf(t),Ha(i),MC)try{return hu(e,t,i)}catch{}if("get"in i||"set"in i)throw UC("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var qr=h((hM,Ff)=>{Ff.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Wa=h((vM,Mf)=>{var DC=me(),_C=Ze(),NC=qr();Mf.exports=DC?function(r,e,t){return _C.f(r,e,NC(1,t))}:function(r,e,t){return r[e]=t,r}});var Ga=h((yM,Uf)=>{var qC=Kl(),jC=Xl(),Lf=qC("keys");Uf.exports=function(r){return Lf[r]||(Lf[r]=jC(r))}});var Va=h((bM,Bf)=>{Bf.exports={}});var jr=h((kM,Nf)=>{var HC=of(),_f=ce(),WC=bt(),GC=Wa(),ku=Ce(),Su=Fa(),VC=Ga(),zC=Va(),Df="Object already initialized",Pu=_f.TypeError,JC=_f.WeakMap,za,qn,Ja,$C=function(r){return Ja(r)?qn(r):za(r,{})},KC=function(r){return function(e){var t;if(!WC(e)||(t=qn(e)).type!==r)throw Pu("Incompatible receiver, "+r+" required");return t}};HC||Su.state?(Ge=Su.state||(Su.state=new JC),Ge.get=Ge.get,Ge.has=Ge.has,Ge.set=Ge.set,za=function(r,e){if(Ge.has(r))throw Pu(Df);return e.facade=r,Ge.set(r,e),e},qn=function(r){return Ge.get(r)||{}},Ja=function(r){return Ge.has(r)}):(er=VC("state"),zC[er]=!0,za=function(r,e){if(ku(r,er))throw Pu(Df);return e.facade=r,GC(r,er,e),e},qn=function(r){return ku(r,er)?r[er]:{}},Ja=function(r){return ku(r,er)});var Ge,er;Nf.exports={set:za,get:qn,has:Ja,enforce:$C,getterFor:KC}});var Cu=h(Hf=>{"use strict";var qf={}.propertyIsEnumerable,jf=Object.getOwnPropertyDescriptor,XC=jf&&!qf.call({1:2},1);Hf.f=XC?function(e){var t=jf(this,e);return!!t&&t.enumerable}:qf});var wu=h((PM,Wf)=>{var ZC=$(),YC=oe(),QC=Ba(),xu=Object,ex=ZC("".split);Wf.exports=YC(function(){return!xu("z").propertyIsEnumerable(0)})?function(r){return QC(r)=="String"?ex(r,""):xu(r)}:xu});var Hr=h((CM,Gf)=>{var tx=wu(),rx=La();Gf.exports=function(r){return tx(rx(r))}});var Iu=h(zf=>{var ix=me(),nx=We(),sx=Cu(),ox=qr(),ax=Hr(),dx=ja(),lx=Ce(),ux=au(),Vf=Object.getOwnPropertyDescriptor;zf.f=ix?Vf:function(e,t){if(e=ax(e),t=dx(t),ux)try{return Vf(e,t)}catch{}if(lx(e,t))return ox(!nx(sx.f,e,t),e[t])}});var Eu=h((wM,$f)=>{var Au=me(),cx=Ce(),Jf=Function.prototype,mx=Au&&Object.getOwnPropertyDescriptor,Tu=cx(Jf,"name"),px=Tu&&function(){}.name==="something",fx=Tu&&(!Au||Au&&mx(Jf,"name").configurable);$f.exports={EXISTS:Tu,PROPER:px,CONFIGURABLE:fx}});var Ou=h((IM,Kf)=>{var gx=$(),hx=K(),Ru=Fa(),vx=gx(Function.toString);hx(Ru.inspectSource)||(Ru.inspectSource=function(r){return vx(r)});Kf.exports=Ru.inspectSource});var Lu=h((AM,Yf)=>{var Mu=$(),yx=oe(),bx=K(),$a=Ce(),Fu=me(),kx=Eu().CONFIGURABLE,Sx=Ou(),Zf=jr(),Px=Zf.enforce,Cx=Zf.get,Xf=String,Ka=Object.defineProperty,xx=Mu("".slice),wx=Mu("".replace),Ix=Mu([].join),Ax=Fu&&!yx(function(){return Ka(function(){},"length",{value:8}).length!==8}),Tx=String(String).split("String"),Ex=Yf.exports=function(r,e,t){xx(Xf(e),0,7)==="Symbol("&&(e="["+wx(Xf(e),/^Symbol\(([^)]*)\)/,"$1")+"]"),t&&t.getter&&(e="get "+e),t&&t.setter&&(e="set "+e),(!$a(r,"name")||kx&&r.name!==e)&&(Fu?Ka(r,"name",{value:e,configurable:!0}):r.name=e),Ax&&t&&$a(t,"arity")&&r.length!==t.arity&&Ka(r,"length",{value:t.arity});try{t&&$a(t,"constructor")&&t.constructor?Fu&&Ka(r,"prototype",{writable:!1}):r.prototype&&(r.prototype=void 0)}catch{}var i=Px(r);return $a(i,"source")||(i.source=Ix(Tx,typeof e=="string"?e:"")),r};Function.prototype.toString=Ex(function(){return bx(this)&&Cx(this).source||Sx(this)},"toString")});var tr=h((TM,Qf)=>{var Rx=K(),Ox=Ze(),Fx=Lu(),Mx=Oa();Qf.exports=function(r,e,t,i){i||(i={});var n=i.enumerable,o=i.name!==void 0?i.name:e;if(Rx(t)&&Fx(t,o,i),i.global)n?r[e]=t:Mx(e,t);else{try{i.unsafe?r[e]&&(n=!0):delete r[e]}catch{}n?r[e]=t:Ox.f(r,e,{value:t,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return r}});var Uu=h((EM,eg)=>{var Lx=Ea(),Ux=Math.max,Bx=Math.min;eg.exports=function(r,e){var t=Lx(r);return t<0?Ux(t+e,0):Bx(t,e)}});var rg=h((RM,tg)=>{var Dx=Ea(),_x=Math.min;tg.exports=function(r){return r>0?_x(Dx(r),9007199254740991):0}});var Xa=h((OM,ig)=>{var Nx=rg();ig.exports=function(r){return Nx(r.length)}});var og=h((FM,sg)=>{var qx=Hr(),jx=Uu(),Hx=Xa(),ng=function(r){return function(e,t,i){var n=qx(e),o=Hx(n),a=jx(i,o),c;if(r&&t!=t){for(;o>a;)if(c=n[a++],c!=c)return!0}else for(;o>a;a++)if((r||a in n)&&n[a]===t)return r||a||0;return!r&&-1}};sg.exports={includes:ng(!0),indexOf:ng(!1)}});var Du=h((MM,dg)=>{var Wx=$(),Bu=Ce(),Gx=Hr(),Vx=og().indexOf,zx=Va(),ag=Wx([].push);dg.exports=function(r,e){var t=Gx(r),i=0,n=[],o;for(o in t)!Bu(zx,o)&&Bu(t,o)&&ag(n,o);for(;e.length>i;)Bu(t,o=e[i++])&&(~Vx(n,o)||ag(n,o));return n}});var Za=h((LM,lg)=>{lg.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var cg=h(ug=>{var Jx=Du(),$x=Za(),Kx=$x.concat("length","prototype");ug.f=Object.getOwnPropertyNames||function(e){return Jx(e,Kx)}});var _u=h(mg=>{mg.f=Object.getOwnPropertySymbols});var fg=h((DM,pg)=>{var Xx=Nn(),Zx=$(),Yx=cg(),Qx=_u(),ew=Xe(),tw=Zx([].concat);pg.exports=Xx("Reflect","ownKeys")||function(e){var t=Yx.f(ew(e)),i=Qx.f;return i?tw(t,i(e)):t}});var vg=h((_M,hg)=>{var gg=Ce(),rw=fg(),iw=Iu(),nw=Ze();hg.exports=function(r,e,t){for(var i=rw(e),n=nw.f,o=iw.f,a=0;a<i.length;a++){var c=i[a];!gg(r,c)&&!(t&&gg(t,c))&&n(r,c,o(e,c))}}});var bg=h((NM,yg)=>{var sw=oe(),ow=K(),aw=/#|\.prototype\./,jn=function(r,e){var t=lw[dw(r)];return t==cw?!0:t==uw?!1:ow(e)?sw(e):!!e},dw=jn.normalize=function(r){return String(r).replace(aw,".").toLowerCase()},lw=jn.data={},uw=jn.NATIVE="N",cw=jn.POLYFILL="P";yg.exports=jn});var Hn=h((qM,kg)=>{var Nu=ce(),mw=Iu().f,pw=Wa(),fw=tr(),gw=Oa(),hw=vg(),vw=bg();kg.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o,a,c,p,f,v;if(i?a=Nu:n?a=Nu[t]||gw(t,{}):a=(Nu[t]||{}).prototype,a)for(c in e){if(f=e[c],r.dontCallGetSet?(v=mw(a,c),p=v&&v.value):p=a[c],o=vw(i?c:t+(n?".":"#")+c,r.forced),!o&&p!==void 0){if(typeof f==typeof p)continue;hw(f,p)}(r.sham||p&&p.sham)&&pw(f,"sham",!0),fw(a,c,f,r)}}});var qu=h((jM,Sg)=>{var yw=Du(),bw=Za();Sg.exports=Object.keys||function(e){return yw(e,bw)}});var Cg=h(Pg=>{var kw=me(),Sw=du(),Pw=Ze(),Cw=Xe(),xw=Hr(),ww=qu();Pg.f=kw&&!Sw?Object.defineProperties:function(e,t){Cw(e);for(var i=xw(t),n=ww(t),o=n.length,a=0,c;o>a;)Pw.f(e,c=n[a++],i[c]);return e}});var wg=h((WM,xg)=>{var Iw=Nn();xg.exports=Iw("document","documentElement")});var Wn=h((GM,Fg)=>{var Aw=Xe(),Tw=Cg(),Ig=Za(),Ew=Va(),Rw=wg(),Ow=ou(),Fw=Ga(),Ag=">",Tg="<",Hu="prototype",Wu="script",Rg=Fw("IE_PROTO"),ju=function(){},Og=function(r){return Tg+Wu+Ag+r+Tg+"/"+Wu+Ag},Eg=function(r){r.write(Og("")),r.close();var e=r.parentWindow.Object;return r=null,e},Mw=function(){var r=Ow("iframe"),e="java"+Wu+":",t;return r.style.display="none",Rw.appendChild(r),r.src=String(e),t=r.contentWindow.document,t.open(),t.write(Og("document.F=Object")),t.close(),t.F},Ya,Qa=function(){try{Ya=new ActiveXObject("htmlfile")}catch{}Qa=typeof document<"u"?document.domain&&Ya?Eg(Ya):Mw():Eg(Ya);for(var r=Ig.length;r--;)delete Qa[Hu][Ig[r]];return Qa()};Ew[Rg]=!0;Fg.exports=Object.create||function(e,t){var i;return e!==null?(ju[Hu]=Aw(e),i=new ju,ju[Hu]=null,i[Rg]=e):i=Qa(),t===void 0?i:Tw.f(i,t)}});var Lg=h((VM,Mg)=>{var Lw=oe();Mg.exports=!Lw(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Vu=h((zM,Bg)=>{var Uw=Ce(),Bw=K(),Dw=Bn(),_w=Ga(),Nw=Lg(),Ug=_w("IE_PROTO"),Gu=Object,qw=Gu.prototype;Bg.exports=Nw?Gu.getPrototypeOf:function(r){var e=Dw(r);if(Uw(e,Ug))return e[Ug];var t=e.constructor;return Bw(t)&&e instanceof t?t.prototype:e instanceof Gu?qw:null}});var Ku=h((JM,Ng)=>{"use strict";var jw=oe(),Hw=K(),Ww=bt(),Gw=Wn(),Dg=Vu(),Vw=tr(),zw=xe(),Jw=_r(),$u=zw("iterator"),_g=!1,st,zu,Ju;[].keys&&(Ju=[].keys(),"next"in Ju?(zu=Dg(Dg(Ju)),zu!==Object.prototype&&(st=zu)):_g=!0);var $w=!Ww(st)||jw(function(){var r={};return st[$u].call(r)!==r});$w?st={}:Jw&&(st=Gw(st));Hw(st[$u])||Vw(st,$u,function(){return this});Ng.exports={IteratorPrototype:st,BUGGY_SAFARI_ITERATORS:_g}});var Gn=h(($M,jg)=>{var Kw=Ze().f,Xw=Ce(),Zw=xe(),qg=Zw("toStringTag");jg.exports=function(r,e,t){r&&!t&&(r=r.prototype),r&&!Xw(r,qg)&&Kw(r,qg,{configurable:!0,value:e})}});var Wr=h((KM,Hg)=>{Hg.exports={}});var Xu=h((XM,Wg)=>{"use strict";var Yw=Ku().IteratorPrototype,Qw=Wn(),eI=qr(),tI=Gn(),rI=Wr(),iI=function(){return this};Wg.exports=function(r,e,t,i){var n=e+" Iterator";return r.prototype=Qw(Yw,{next:eI(+!i,t)}),tI(r,n,!1,!0),rI[n]=iI,r}});var Vg=h((ZM,Gg)=>{var nI=K(),sI=String,oI=TypeError;Gg.exports=function(r){if(typeof r=="object"||nI(r))return r;throw oI("Can't set "+sI(r)+" as a prototype")}});var Jg=h((YM,zg)=>{var aI=$(),dI=Xe(),lI=Vg();zg.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var r=!1,e={},t;try{t=aI(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set),t(e,[]),r=e instanceof Array}catch{}return function(n,o){return dI(n),lI(o),r?t(n,o):n.__proto__=o,n}}():void 0)});var Yu=h((QM,ih)=>{"use strict";var uI=Hn(),cI=We(),ed=_r(),th=Eu(),mI=K(),pI=Xu(),$g=Vu(),Kg=Jg(),fI=Gn(),gI=Wa(),Zu=tr(),hI=xe(),Xg=Wr(),rh=Ku(),vI=th.PROPER,yI=th.CONFIGURABLE,Zg=rh.IteratorPrototype,td=rh.BUGGY_SAFARI_ITERATORS,Vn=hI("iterator"),Yg="keys",zn="values",Qg="entries",eh=function(){return this};ih.exports=function(r,e,t,i,n,o,a){pI(t,e,i);var c=function(E){if(E===n&&k)return k;if(!td&&E in v)return v[E];switch(E){case Yg:return function(){return new t(this,E)};case zn:return function(){return new t(this,E)};case Qg:return function(){return new t(this,E)}}return function(){return new t(this)}},p=e+" Iterator",f=!1,v=r.prototype,m=v[Vn]||v["@@iterator"]||n&&v[n],k=!td&&m||c(n),b=e=="Array"&&v.entries||m,C,x,I;if(b&&(C=$g(b.call(new r)),C!==Object.prototype&&C.next&&(!ed&&$g(C)!==Zg&&(Kg?Kg(C,Zg):mI(C[Vn])||Zu(C,Vn,eh)),fI(C,p,!0,!0),ed&&(Xg[p]=eh))),vI&&n==zn&&m&&m.name!==zn&&(!ed&&yI?gI(v,"name",zn):(f=!0,k=function(){return cI(m,this)})),n)if(x={values:c(zn),keys:o?k:c(Yg),entries:c(Qg)},a)for(I in x)(td||f||!(I in v))&&Zu(v,I,x[I]);else uI({target:e,proto:!0,forced:td||f},x);return(!ed||a)&&v[Vn]!==k&&Zu(v,Vn,k,{name:n}),Xg[e]=k,x}});var Qu=h((eL,nh)=>{nh.exports=function(r,e){return{value:r,done:e}}});var dh=h(()=>{"use strict";var bI=nu().charAt,kI=_n(),oh=jr(),SI=Yu(),sh=Qu(),ah="String Iterator",PI=oh.set,CI=oh.getterFor(ah);SI(String,"String",function(r){PI(this,{type:ah,string:kI(r),index:0})},function(){var e=CI(this),t=e.string,i=e.index,n;return i>=t.length?sh(void 0,!0):(n=bI(t,i),e.index+=n.length,sh(n,!1))})});var ec=h((iL,lh)=>{var xI=oe(),wI=xe(),II=_r(),AI=wI("iterator");lh.exports=!xI(function(){var r=new URL("b?a=1&b=2&c=3","http://a"),e=r.searchParams,t="";return r.pathname="c%20d",e.forEach(function(i,n){e.delete("b"),t+=n+i}),II&&!r.toJSON||!e.sort||r.href!=="http://a/c%20d?a=1&c=3"||e.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!e[AI]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://\u0442\u0435\u0441\u0442").host!=="xn--e1aybc"||new URL("http://a#\u0431").hash!=="#%D0%B1"||t!=="a1c3"||new URL("http://x",void 0).host!=="x"})});var ch=h((nL,uh)=>{var TI=Ba(),EI=$();uh.exports=function(r){if(TI(r)==="Function")return EI(r)}});var rd=h((sL,ph)=>{var mh=ch(),RI=Na(),OI=Ta(),FI=mh(mh.bind);ph.exports=function(r,e){return RI(r),e===void 0?r:OI?FI(r,e):function(){return r.apply(e,arguments)}}});var hh=h((oL,gh)=>{var fh=Lu(),MI=Ze();gh.exports=function(r,e,t){return t.get&&fh(t.get,e,{getter:!0}),t.set&&fh(t.set,e,{setter:!0}),MI.f(r,e,t)}});var tc=h((aL,vh)=>{var LI=uu(),UI=TypeError;vh.exports=function(r,e){if(LI(e,r))return r;throw UI("Incorrect invocation")}});var Sh=h((dL,kh)=>{"use strict";var yh=me(),BI=$(),DI=We(),_I=oe(),rc=qu(),NI=_u(),qI=Cu(),jI=Bn(),HI=wu(),Gr=Object.assign,bh=Object.defineProperty,WI=BI([].concat);kh.exports=!Gr||_I(function(){if(yh&&Gr({b:1},Gr(bh({},"a",{enumerable:!0,get:function(){bh(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var r={},e={},t=Symbol(),i="abcdefghijklmnopqrst";return r[t]=7,i.split("").forEach(function(n){e[n]=n}),Gr({},r)[t]!=7||rc(Gr({},e)).join("")!=i})?function(e,t){for(var i=jI(e),n=arguments.length,o=1,a=NI.f,c=qI.f;n>o;)for(var p=HI(arguments[o++]),f=a?WI(rc(p),a(p)):rc(p),v=f.length,m=0,k;v>m;)k=f[m++],(!yh||DI(c,p,k))&&(i[k]=p[k]);return i}:Gr});var xh=h((lL,Ch)=>{var GI=We(),Ph=Xe(),VI=qa();Ch.exports=function(r,e,t){var i,n;Ph(r);try{if(i=VI(r,"return"),!i){if(e==="throw")throw t;return t}i=GI(i,r)}catch(o){n=!0,i=o}if(e==="throw")throw t;if(n)throw i;return Ph(i),t}});var Ih=h((uL,wh)=>{var zI=Xe(),JI=xh();wh.exports=function(r,e,t,i){try{return i?e(zI(t)[0],t[1]):e(t)}catch(n){JI(r,"throw",n)}}});var Th=h((cL,Ah)=>{var $I=xe(),KI=Wr(),XI=$I("iterator"),ZI=Array.prototype;Ah.exports=function(r){return r!==void 0&&(KI.Array===r||ZI[XI]===r)}});var Lh=h((mL,Mh)=>{var YI=$(),QI=oe(),Eh=K(),eA=Dn(),tA=Nn(),rA=Ou(),Rh=function(){},iA=[],Oh=tA("Reflect","construct"),ic=/^\s*(?:class|function)\b/,nA=YI(ic.exec),sA=!ic.exec(Rh),Jn=function(e){if(!Eh(e))return!1;try{return Oh(Rh,iA,e),!0}catch{return!1}},Fh=function(e){if(!Eh(e))return!1;switch(eA(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return sA||!!nA(ic,rA(e))}catch{return!0}};Fh.sham=!0;Mh.exports=!Oh||QI(function(){var r;return Jn(Jn.call)||!Jn(Object)||!Jn(function(){r=!0})||r})?Fh:Jn});var nc=h((pL,Uh)=>{"use strict";var oA=ja(),aA=Ze(),dA=qr();Uh.exports=function(r,e,t){var i=oA(e);i in r?aA.f(r,i,dA(0,t)):r[i]=t}});var id=h((fL,Dh)=>{var lA=Dn(),Bh=qa(),uA=Ma(),cA=Wr(),mA=xe(),pA=mA("iterator");Dh.exports=function(r){if(!uA(r))return Bh(r,pA)||Bh(r,"@@iterator")||cA[lA(r)]}});var sc=h((gL,_h)=>{var fA=We(),gA=Na(),hA=Xe(),vA=mu(),yA=id(),bA=TypeError;_h.exports=function(r,e){var t=arguments.length<2?yA(r):e;if(gA(t))return hA(fA(t,r));throw bA(vA(r)+" is not iterable")}});var Hh=h((hL,jh)=>{"use strict";var kA=rd(),SA=We(),PA=Bn(),CA=Ih(),xA=Th(),wA=Lh(),IA=Xa(),Nh=nc(),AA=sc(),TA=id(),qh=Array;jh.exports=function(e){var t=PA(e),i=wA(this),n=arguments.length,o=n>1?arguments[1]:void 0,a=o!==void 0;a&&(o=kA(o,n>2?arguments[2]:void 0));var c=TA(t),p=0,f,v,m,k,b,C;if(c&&!(this===qh&&xA(c)))for(k=AA(t,c),b=k.next,v=i?new this:[];!(m=SA(b,k)).done;p++)C=a?CA(k,o,[m.value,p],!0):m.value,Nh(v,p,C);else for(f=IA(t),v=i?new this(f):qh(f);f>p;p++)C=a?o(t[p],p):t[p],Nh(v,p,C);return v.length=p,v}});var oc=h((vL,Gh)=>{var Wh=Uu(),EA=Xa(),RA=nc(),OA=Array,FA=Math.max;Gh.exports=function(r,e,t){for(var i=EA(r),n=Wh(e,i),o=Wh(t===void 0?i:t,i),a=OA(FA(o-n,0)),c=0;n<o;n++,c++)RA(a,c,r[n]);return a.length=c,a}});var Qh=h((yL,Yh)=>{var rr=$(),ac=2147483647,$n=36,Kh=1,uc=26,MA=38,LA=700,UA=72,BA=128,DA="-",_A=/[^\0-\u007E]/,Xh=/[.\u3002\uFF0E\uFF61]/g,Vh="Overflow: input needs wider integers to process",dc=$n-Kh,zh=RangeError,NA=rr(Xh.exec),Vr=Math.floor,lc=String.fromCharCode,Jh=rr("".charCodeAt),Zh=rr([].join),kt=rr([].push),qA=rr("".replace),jA=rr("".split),HA=rr("".toLowerCase),WA=function(r){for(var e=[],t=0,i=r.length;t<i;){var n=Jh(r,t++);if(n>=55296&&n<=56319&&t<i){var o=Jh(r,t++);(o&64512)==56320?kt(e,((n&1023)<<10)+(o&1023)+65536):(kt(e,n),t--)}else kt(e,n)}return e},$h=function(r){return r+22+75*(r<26)},GA=function(r,e,t){var i=0;for(r=t?Vr(r/LA):r>>1,r+=Vr(r/e);r>dc*uc>>1;)r=Vr(r/dc),i+=$n;return Vr(i+(dc+1)*r/(r+MA))},VA=function(r){var e=[];r=WA(r);var t=r.length,i=BA,n=0,o=UA,a,c;for(a=0;a<r.length;a++)c=r[a],c<128&&kt(e,lc(c));var p=e.length,f=p;for(p&&kt(e,DA);f<t;){var v=ac;for(a=0;a<r.length;a++)c=r[a],c>=i&&c<v&&(v=c);var m=f+1;if(v-i>Vr((ac-n)/m))throw zh(Vh);for(n+=(v-i)*m,i=v,a=0;a<r.length;a++){if(c=r[a],c<i&&++n>ac)throw zh(Vh);if(c==i){for(var k=n,b=$n;;){var C=b<=o?Kh:b>=o+uc?uc:b-o;if(k<C)break;var x=k-C,I=$n-C;kt(e,lc($h(C+x%I))),k=Vr(x/I),b+=$n}kt(e,lc($h(k))),o=GA(n,m,f==p),n=0,f++}}n++,i++}return Zh(e,"")};Yh.exports=function(r){var e=[],t=jA(qA(HA(r),Xh,"."),"."),i,n;for(i=0;i<t.length;i++)n=t[i],kt(e,NA(_A,n)?"xn--"+VA(n):n);return Zh(e,".")}});var cc=h((bL,ev)=>{var zA=TypeError;ev.exports=function(r,e){if(r<e)throw zA("Not enough arguments");return r}});var rv=h((kL,tv)=>{var JA=xe(),$A=Wn(),KA=Ze().f,mc=JA("unscopables"),pc=Array.prototype;pc[mc]==null&&KA(pc,mc,{configurable:!0,value:$A(null)});tv.exports=function(r){pc[mc][r]=!0}});var dv=h((SL,av)=>{"use strict";var XA=Hr(),fc=rv(),iv=Wr(),sv=jr(),ZA=Ze().f,YA=Yu(),nd=Qu(),QA=_r(),eT=me(),ov="Array Iterator",tT=sv.set,rT=sv.getterFor(ov);av.exports=YA(Array,"Array",function(r,e){tT(this,{type:ov,target:XA(r),index:0,kind:e})},function(){var r=rT(this),e=r.target,t=r.kind,i=r.index++;return!e||i>=e.length?(r.target=void 0,nd(void 0,!0)):t=="keys"?nd(i,!1):t=="values"?nd(e[i],!1):nd([i,e[i]],!1)},"values");var nv=iv.Arguments=iv.Array;fc("keys");fc("values");fc("entries");if(!QA&&eT&&nv.name!=="values")try{ZA(nv,"name",{value:"values"})}catch{}});var uv=h((PL,lv)=>{var iT=tr();lv.exports=function(r,e,t){for(var i in e)iT(r,i,e[i],t);return r}});var pv=h((CL,mv)=>{var cv=oc(),nT=Math.floor,gc=function(r,e){var t=r.length,i=nT(t/2);return t<8?sT(r,e):oT(r,gc(cv(r,0,i),e),gc(cv(r,i),e),e)},sT=function(r,e){for(var t=r.length,i=1,n,o;i<t;){for(o=i,n=r[i];o&&e(r[o-1],n)>0;)r[o]=r[--o];o!==i++&&(r[o]=n)}return r},oT=function(r,e,t,i){for(var n=e.length,o=t.length,a=0,c=0;a<n||c<o;)r[a+c]=a<n&&c<o?i(e[a],t[c])<=0?e[a++]:t[c++]:a<n?e[a++]:t[c++];return r};mv.exports=gc});var wc=h((xL,Mv)=>{"use strict";dv();var kc=Hn(),Jr=ce(),sd=We(),Ye=$(),aT=me(),wv=ec(),Iv=tr(),dT=uv(),lT=Gn(),uT=Xu(),Cc=jr(),Av=tc(),hc=K(),cT=Ce(),mT=rd(),pT=Dn(),fT=Xe(),Tv=bt(),pe=_n(),gT=Wn(),fv=qr(),Sc=sc(),hT=id(),zr=cc(),vT=xe(),yT=pv(),bT=vT("iterator"),Zn="URLSearchParams",Ev=Zn+"Iterator",Rv=Cc.set,Ve=Cc.getterFor(Zn),kT=Cc.getterFor(Ev),ST=Object.getOwnPropertyDescriptor,xc=function(r){if(!aT)return Jr[r];var e=ST(Jr,r);return e&&e.value},gv=xc("fetch"),ad=xc("Request"),Kn=xc("Headers"),vc=ad&&ad.prototype,hv=Kn&&Kn.prototype,PT=Jr.RegExp,CT=Jr.TypeError,Ov=Jr.decodeURIComponent,xT=Jr.encodeURIComponent,wT=Ye("".charAt),vv=Ye([].join),ir=Ye([].push),Pc=Ye("".replace),IT=Ye([].shift),yv=Ye([].splice),bv=Ye("".split),AT=Ye("".slice),TT=/\+/g,kv=Array(4),ET=function(r){return kv[r-1]||(kv[r-1]=PT("((?:%[\\da-f]{2}){"+r+"})","gi"))},RT=function(r){try{return Ov(r)}catch{return r}},Sv=function(r){var e=Pc(r,TT," "),t=4;try{return Ov(e)}catch{for(;t;)e=Pc(e,ET(t--),RT);return e}},OT=/[!'()~]|%20/g,FT={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},MT=function(r){return FT[r]},Pv=function(r){return Pc(xT(r),OT,MT)},yc=uT(function(e,t){Rv(this,{type:Ev,iterator:Sc(Ve(e).entries),kind:t})},"Iterator",function(){var e=kT(this),t=e.kind,i=e.iterator.next(),n=i.value;return i.done||(i.value=t==="keys"?n.key:t==="values"?n.value:[n.key,n.value]),i},!0),Fv=function(r){this.entries=[],this.url=null,r!==void 0&&(Tv(r)?this.parseObject(r):this.parseQuery(typeof r=="string"?wT(r,0)==="?"?AT(r,1):r:pe(r)))};Fv.prototype={type:Zn,bindURL:function(r){this.url=r,this.update()},parseObject:function(r){var e=hT(r),t,i,n,o,a,c,p;if(e)for(t=Sc(r,e),i=t.next;!(n=sd(i,t)).done;){if(o=Sc(fT(n.value)),a=o.next,(c=sd(a,o)).done||(p=sd(a,o)).done||!sd(a,o).done)throw CT("Expected sequence with length 2");ir(this.entries,{key:pe(c.value),value:pe(p.value)})}else for(var f in r)cT(r,f)&&ir(this.entries,{key:f,value:pe(r[f])})},parseQuery:function(r){if(r)for(var e=bv(r,"&"),t=0,i,n;t<e.length;)i=e[t++],i.length&&(n=bv(i,"="),ir(this.entries,{key:Sv(IT(n)),value:Sv(vv(n,"="))}))},serialize:function(){for(var r=this.entries,e=[],t=0,i;t<r.length;)i=r[t++],ir(e,Pv(i.key)+"="+Pv(i.value));return vv(e,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var dd=function(){Av(this,Xn);var e=arguments.length>0?arguments[0]:void 0;Rv(this,new Fv(e))},Xn=dd.prototype;dT(Xn,{append:function(e,t){zr(arguments.length,2);var i=Ve(this);ir(i.entries,{key:pe(e),value:pe(t)}),i.updateURL()},delete:function(r){zr(arguments.length,1);for(var e=Ve(this),t=e.entries,i=pe(r),n=0;n<t.length;)t[n].key===i?yv(t,n,1):n++;e.updateURL()},get:function(e){zr(arguments.length,1);for(var t=Ve(this).entries,i=pe(e),n=0;n<t.length;n++)if(t[n].key===i)return t[n].value;return null},getAll:function(e){zr(arguments.length,1);for(var t=Ve(this).entries,i=pe(e),n=[],o=0;o<t.length;o++)t[o].key===i&&ir(n,t[o].value);return n},has:function(e){zr(arguments.length,1);for(var t=Ve(this).entries,i=pe(e),n=0;n<t.length;)if(t[n++].key===i)return!0;return!1},set:function(e,t){zr(arguments.length,1);for(var i=Ve(this),n=i.entries,o=!1,a=pe(e),c=pe(t),p=0,f;p<n.length;p++)f=n[p],f.key===a&&(o?yv(n,p--,1):(o=!0,f.value=c));o||ir(n,{key:a,value:c}),i.updateURL()},sort:function(){var e=Ve(this);yT(e.entries,function(t,i){return t.key>i.key?1:-1}),e.updateURL()},forEach:function(e){for(var t=Ve(this).entries,i=mT(e,arguments.length>1?arguments[1]:void 0),n=0,o;n<t.length;)o=t[n++],i(o.value,o.key,this)},keys:function(){return new yc(this,"keys")},values:function(){return new yc(this,"values")},entries:function(){return new yc(this,"entries")}},{enumerable:!0});Iv(Xn,bT,Xn.entries,{name:"entries"});Iv(Xn,"toString",function(){return Ve(this).serialize()},{enumerable:!0});lT(dd,Zn);kc({global:!0,constructor:!0,forced:!wv},{URLSearchParams:dd});!wv&&hc(Kn)&&(Cv=Ye(hv.has),xv=Ye(hv.set),bc=function(r){if(Tv(r)){var e=r.body,t;if(pT(e)===Zn)return t=r.headers?new Kn(r.headers):new Kn,Cv(t,"content-type")||xv(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),gT(r,{body:fv(0,pe(e)),headers:fv(0,t)})}return r},hc(gv)&&kc({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return gv(e,arguments.length>1?bc(arguments[1]):{})}}),hc(ad)&&(od=function(e){return Av(this,vc),new ad(e,arguments.length>1?bc(arguments[1]):{})},vc.constructor=od,od.prototype=vc,kc({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:od})));var Cv,xv,bc,od;Mv.exports={URLSearchParams:dd,getState:Ve}});var Yv=h(()=>{"use strict";dh();var LT=Hn(),jc=me(),UT=ec(),Hc=ce(),Lv=rd(),Ee=$(),pd=tr(),we=hh(),BT=tc(),_c=Ce(),Wc=Sh(),$r=Hh(),ze=oc(),DT=nu().codeAt,_T=Qh(),at=_n(),NT=Gn(),qT=cc(),zv=wc(),Jv=jr(),jT=Jv.set,fd=Jv.getterFor("URL"),HT=zv.URLSearchParams,WT=zv.getState,Yn=Hc.URL,Nc=Hc.TypeError,gd=Hc.parseInt,GT=Math.floor,Uv=Math.pow,Te=Ee("".charAt),Je=Ee(/./.exec),es=Ee([].join),VT=Ee(1 .toString),zT=Ee([].pop),Xr=Ee([].push),Bv=Ee("".replace),JT=Ee([].shift),$T=Ee("".split),rs=Ee("".slice),hd=Ee("".toLowerCase),KT=Ee([].unshift),XT="Invalid authority",Ic="Invalid scheme",nr="Invalid host",Dv="Invalid port",$v=/[a-z]/i,ZT=/[\d+-.a-z]/i,qc=/\d/,YT=/^0x/i,QT=/^[0-7]+$/,e0=/^\d+$/,Kv=/^[\da-f]+$/i,t0=/[\0\t\n\r #%/:<>?@[\\\]^|]/,r0=/[\0\t\n\r #/:<>?@[\\\]^|]/,i0=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,n0=/[\t\n\r]/g,Ie,s0=function(r){var e=$T(r,"."),t,i,n,o,a,c,p;if(e.length&&e[e.length-1]==""&&e.length--,t=e.length,t>4)return r;for(i=[],n=0;n<t;n++){if(o=e[n],o=="")return r;if(a=10,o.length>1&&Te(o,0)=="0"&&(a=Je(YT,o)?16:8,o=rs(o,a==8?1:2)),o==="")c=0;else{if(!Je(a==10?e0:a==8?QT:Kv,o))return r;c=gd(o,a)}Xr(i,c)}for(n=0;n<t;n++)if(c=i[n],n==t-1){if(c>=Uv(256,5-t))return null}else if(c>255)return null;for(p=zT(i),n=0;n<i.length;n++)p+=i[n]*Uv(256,3-n);return p},o0=function(r){var e=[0,0,0,0,0,0,0,0],t=0,i=null,n=0,o,a,c,p,f,v,m,k=function(){return Te(r,n)};if(k()==":"){if(Te(r,1)!=":")return;n+=2,t++,i=t}for(;k();){if(t==8)return;if(k()==":"){if(i!==null)return;n++,t++,i=t;continue}for(o=a=0;a<4&&Je(Kv,k());)o=o*16+gd(k(),16),n++,a++;if(k()=="."){if(a==0||(n-=a,t>6))return;for(c=0;k();){if(p=null,c>0)if(k()=="."&&c<4)n++;else return;if(!Je(qc,k()))return;for(;Je(qc,k());){if(f=gd(k(),10),p===null)p=f;else{if(p==0)return;p=p*10+f}if(p>255)return;n++}e[t]=e[t]*256+p,c++,(c==2||c==4)&&t++}if(c!=4)return;break}else if(k()==":"){if(n++,!k())return}else if(k())return;e[t++]=o}if(i!==null)for(v=t-i,t=7;t!=0&&v>0;)m=e[t],e[t--]=e[i+v-1],e[i+--v]=m;else if(t!=8)return;return e},a0=function(r){for(var e=null,t=1,i=null,n=0,o=0;o<8;o++)r[o]!==0?(n>t&&(e=i,t=n),i=null,n=0):(i===null&&(i=o),++n);return n>t&&(e=i,t=n),e},Qn=function(r){var e,t,i,n;if(typeof r=="number"){for(e=[],t=0;t<4;t++)KT(e,r%256),r=GT(r/256);return es(e,".")}else if(typeof r=="object"){for(e="",i=a0(r),t=0;t<8;t++)n&&r[t]===0||(n&&(n=!1),i===t?(e+=t?":":"::",n=!0):(e+=VT(r[t],16),t<7&&(e+=":")));return"["+e+"]"}return r},md={},Xv=Wc({},md,{" ":1,'"':1,"<":1,">":1,"`":1}),Zv=Wc({},Xv,{"#":1,"?":1,"{":1,"}":1}),Ac=Wc({},Zv,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),St=function(r,e){var t=DT(r,0);return t>32&&t<127&&!_c(e,r)?r:encodeURIComponent(r)},ld={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ts=function(r,e){var t;return r.length==2&&Je($v,Te(r,0))&&((t=Te(r,1))==":"||!e&&t=="|")},_v=function(r){var e;return r.length>1&&ts(rs(r,0,2))&&(r.length==2||(e=Te(r,2))==="/"||e==="\\"||e==="?"||e==="#")},d0=function(r){return r==="."||hd(r)==="%2e"},l0=function(r){return r=hd(r),r===".."||r==="%2e."||r===".%2e"||r==="%2e%2e"},Tc={},Nv={},Ec={},qv={},jv={},Rc={},Hv={},Wv={},ud={},cd={},Oc={},Fc={},Mc={},Lc={},Gv={},Uc={},Kr={},Qe={},Vv={},sr={},ot={},Gc=function(r,e,t){var i=at(r),n,o,a;if(e){if(o=this.parse(i),o)throw Nc(o);this.searchParams=null}else{if(t!==void 0&&(n=new Gc(t,!0)),o=this.parse(i,null,n),o)throw Nc(o);a=WT(new HT),a.bindURL(this),this.searchParams=a}};Gc.prototype={type:"URL",parse:function(r,e,t){var i=this,n=e||Tc,o=0,a="",c=!1,p=!1,f=!1,v,m,k,b;for(r=at(r),e||(i.scheme="",i.username="",i.password="",i.host=null,i.port=null,i.path=[],i.query=null,i.fragment=null,i.cannotBeABaseURL=!1,r=Bv(r,i0,"")),r=Bv(r,n0,""),v=$r(r);o<=v.length;){switch(m=v[o],n){case Tc:if(m&&Je($v,m))a+=hd(m),n=Nv;else{if(e)return Ic;n=Ec;continue}break;case Nv:if(m&&(Je(ZT,m)||m=="+"||m=="-"||m=="."))a+=hd(m);else if(m==":"){if(e&&(i.isSpecial()!=_c(ld,a)||a=="file"&&(i.includesCredentials()||i.port!==null)||i.scheme=="file"&&!i.host))return;if(i.scheme=a,e){i.isSpecial()&&ld[i.scheme]==i.port&&(i.port=null);return}a="",i.scheme=="file"?n=Lc:i.isSpecial()&&t&&t.scheme==i.scheme?n=qv:i.isSpecial()?n=Wv:v[o+1]=="/"?(n=jv,o++):(i.cannotBeABaseURL=!0,Xr(i.path,""),n=Vv)}else{if(e)return Ic;a="",n=Ec,o=0;continue}break;case Ec:if(!t||t.cannotBeABaseURL&&m!="#")return Ic;if(t.cannotBeABaseURL&&m=="#"){i.scheme=t.scheme,i.path=ze(t.path),i.query=t.query,i.fragment="",i.cannotBeABaseURL=!0,n=ot;break}n=t.scheme=="file"?Lc:Rc;continue;case qv:if(m=="/"&&v[o+1]=="/")n=ud,o++;else{n=Rc;continue}break;case jv:if(m=="/"){n=cd;break}else{n=Qe;continue}case Rc:if(i.scheme=t.scheme,m==Ie)i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,i.path=ze(t.path),i.query=t.query;else if(m=="/"||m=="\\"&&i.isSpecial())n=Hv;else if(m=="?")i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,i.path=ze(t.path),i.query="",n=sr;else if(m=="#")i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,i.path=ze(t.path),i.query=t.query,i.fragment="",n=ot;else{i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,i.path=ze(t.path),i.path.length--,n=Qe;continue}break;case Hv:if(i.isSpecial()&&(m=="/"||m=="\\"))n=ud;else if(m=="/")n=cd;else{i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,n=Qe;continue}break;case Wv:if(n=ud,m!="/"||Te(a,o+1)!="/")continue;o++;break;case ud:if(m!="/"&&m!="\\"){n=cd;continue}break;case cd:if(m=="@"){c&&(a="%40"+a),c=!0,k=$r(a);for(var C=0;C<k.length;C++){var x=k[C];if(x==":"&&!f){f=!0;continue}var I=St(x,Ac);f?i.password+=I:i.username+=I}a=""}else if(m==Ie||m=="/"||m=="?"||m=="#"||m=="\\"&&i.isSpecial()){if(c&&a=="")return XT;o-=$r(a).length+1,a="",n=Oc}else a+=m;break;case Oc:case Fc:if(e&&i.scheme=="file"){n=Uc;continue}else if(m==":"&&!p){if(a=="")return nr;if(b=i.parseHost(a),b)return b;if(a="",n=Mc,e==Fc)return}else if(m==Ie||m=="/"||m=="?"||m=="#"||m=="\\"&&i.isSpecial()){if(i.isSpecial()&&a=="")return nr;if(e&&a==""&&(i.includesCredentials()||i.port!==null))return;if(b=i.parseHost(a),b)return b;if(a="",n=Kr,e)return;continue}else m=="["?p=!0:m=="]"&&(p=!1),a+=m;break;case Mc:if(Je(qc,m))a+=m;else if(m==Ie||m=="/"||m=="?"||m=="#"||m=="\\"&&i.isSpecial()||e){if(a!=""){var E=gd(a,10);if(E>65535)return Dv;i.port=i.isSpecial()&&E===ld[i.scheme]?null:E,a=""}if(e)return;n=Kr;continue}else return Dv;break;case Lc:if(i.scheme="file",m=="/"||m=="\\")n=Gv;else if(t&&t.scheme=="file")if(m==Ie)i.host=t.host,i.path=ze(t.path),i.query=t.query;else if(m=="?")i.host=t.host,i.path=ze(t.path),i.query="",n=sr;else if(m=="#")i.host=t.host,i.path=ze(t.path),i.query=t.query,i.fragment="",n=ot;else{_v(es(ze(v,o),""))||(i.host=t.host,i.path=ze(t.path),i.shortenPath()),n=Qe;continue}else{n=Qe;continue}break;case Gv:if(m=="/"||m=="\\"){n=Uc;break}t&&t.scheme=="file"&&!_v(es(ze(v,o),""))&&(ts(t.path[0],!0)?Xr(i.path,t.path[0]):i.host=t.host),n=Qe;continue;case Uc:if(m==Ie||m=="/"||m=="\\"||m=="?"||m=="#"){if(!e&&ts(a))n=Qe;else if(a==""){if(i.host="",e)return;n=Kr}else{if(b=i.parseHost(a),b)return b;if(i.host=="localhost"&&(i.host=""),e)return;a="",n=Kr}continue}else a+=m;break;case Kr:if(i.isSpecial()){if(n=Qe,m!="/"&&m!="\\")continue}else if(!e&&m=="?")i.query="",n=sr;else if(!e&&m=="#")i.fragment="",n=ot;else if(m!=Ie&&(n=Qe,m!="/"))continue;break;case Qe:if(m==Ie||m=="/"||m=="\\"&&i.isSpecial()||!e&&(m=="?"||m=="#")){if(l0(a)?(i.shortenPath(),m!="/"&&!(m=="\\"&&i.isSpecial())&&Xr(i.path,"")):d0(a)?m!="/"&&!(m=="\\"&&i.isSpecial())&&Xr(i.path,""):(i.scheme=="file"&&!i.path.length&&ts(a)&&(i.host&&(i.host=""),a=Te(a,0)+":"),Xr(i.path,a)),a="",i.scheme=="file"&&(m==Ie||m=="?"||m=="#"))for(;i.path.length>1&&i.path[0]==="";)JT(i.path);m=="?"?(i.query="",n=sr):m=="#"&&(i.fragment="",n=ot)}else a+=St(m,Zv);break;case Vv:m=="?"?(i.query="",n=sr):m=="#"?(i.fragment="",n=ot):m!=Ie&&(i.path[0]+=St(m,md));break;case sr:!e&&m=="#"?(i.fragment="",n=ot):m!=Ie&&(m=="'"&&i.isSpecial()?i.query+="%27":m=="#"?i.query+="%23":i.query+=St(m,md));break;case ot:m!=Ie&&(i.fragment+=St(m,Xv));break}o++}},parseHost:function(r){var e,t,i;if(Te(r,0)=="["){if(Te(r,r.length-1)!="]"||(e=o0(rs(r,1,-1)),!e))return nr;this.host=e}else if(this.isSpecial()){if(r=_T(r),Je(t0,r)||(e=s0(r),e===null))return nr;this.host=e}else{if(Je(r0,r))return nr;for(e="",t=$r(r),i=0;i<t.length;i++)e+=St(t[i],md);this.host=e}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme=="file"},includesCredentials:function(){return this.username!=""||this.password!=""},isSpecial:function(){return _c(ld,this.scheme)},shortenPath:function(){var r=this.path,e=r.length;e&&(this.scheme!="file"||e!=1||!ts(r[0],!0))&&r.length--},serialize:function(){var r=this,e=r.scheme,t=r.username,i=r.password,n=r.host,o=r.port,a=r.path,c=r.query,p=r.fragment,f=e+":";return n!==null?(f+="//",r.includesCredentials()&&(f+=t+(i?":"+i:"")+"@"),f+=Qn(n),o!==null&&(f+=":"+o)):e=="file"&&(f+="//"),f+=r.cannotBeABaseURL?a[0]:a.length?"/"+es(a,"/"):"",c!==null&&(f+="?"+c),p!==null&&(f+="#"+p),f},setHref:function(r){var e=this.parse(r);if(e)throw Nc(e);this.searchParams.update()},getOrigin:function(){var r=this.scheme,e=this.port;if(r=="blob")try{return new Zr(r.path[0]).origin}catch{return"null"}return r=="file"||!this.isSpecial()?"null":r+"://"+Qn(this.host)+(e!==null?":"+e:"")},getProtocol:function(){return this.scheme+":"},setProtocol:function(r){this.parse(at(r)+":",Tc)},getUsername:function(){return this.username},setUsername:function(r){var e=$r(at(r));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var t=0;t<e.length;t++)this.username+=St(e[t],Ac)}},getPassword:function(){return this.password},setPassword:function(r){var e=$r(at(r));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var t=0;t<e.length;t++)this.password+=St(e[t],Ac)}},getHost:function(){var r=this.host,e=this.port;return r===null?"":e===null?Qn(r):Qn(r)+":"+e},setHost:function(r){this.cannotBeABaseURL||this.parse(r,Oc)},getHostname:function(){var r=this.host;return r===null?"":Qn(r)},setHostname:function(r){this.cannotBeABaseURL||this.parse(r,Fc)},getPort:function(){var r=this.port;return r===null?"":at(r)},setPort:function(r){this.cannotHaveUsernamePasswordPort()||(r=at(r),r==""?this.port=null:this.parse(r,Mc))},getPathname:function(){var r=this.path;return this.cannotBeABaseURL?r[0]:r.length?"/"+es(r,"/"):""},setPathname:function(r){this.cannotBeABaseURL||(this.path=[],this.parse(r,Kr))},getSearch:function(){var r=this.query;return r?"?"+r:""},setSearch:function(r){r=at(r),r==""?this.query=null:(Te(r,0)=="?"&&(r=rs(r,1)),this.query="",this.parse(r,sr)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var r=this.fragment;return r?"#"+r:""},setHash:function(r){if(r=at(r),r==""){this.fragment=null;return}Te(r,0)=="#"&&(r=rs(r,1)),this.fragment="",this.parse(r,ot)},update:function(){this.query=this.searchParams.serialize()||null}};var Zr=function(e){var t=BT(this,Q),i=qT(arguments.length,1)>1?arguments[1]:void 0,n=jT(t,new Gc(e,!1,i));jc||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},Q=Zr.prototype,Ae=function(r,e){return{get:function(){return fd(this)[r]()},set:e&&function(t){return fd(this)[e](t)},configurable:!0,enumerable:!0}};jc&&(we(Q,"href",Ae("serialize","setHref")),we(Q,"origin",Ae("getOrigin")),we(Q,"protocol",Ae("getProtocol","setProtocol")),we(Q,"username",Ae("getUsername","setUsername")),we(Q,"password",Ae("getPassword","setPassword")),we(Q,"host",Ae("getHost","setHost")),we(Q,"hostname",Ae("getHostname","setHostname")),we(Q,"port",Ae("getPort","setPort")),we(Q,"pathname",Ae("getPathname","setPathname")),we(Q,"search",Ae("getSearch","setSearch")),we(Q,"searchParams",Ae("getSearchParams")),we(Q,"hash",Ae("getHash","setHash")));pd(Q,"toJSON",function(){return fd(this).serialize()},{enumerable:!0});pd(Q,"toString",function(){return fd(this).serialize()},{enumerable:!0});Yn&&(Bc=Yn.createObjectURL,Dc=Yn.revokeObjectURL,Bc&&pd(Zr,"createObjectURL",Lv(Bc,Yn)),Dc&&pd(Zr,"revokeObjectURL",Lv(Dc,Yn)));var Bc,Dc;NT(Zr,"URL");LT({global:!0,constructor:!0,forced:!UT,sham:!jc},{URL:Zr})});var Qv=h(()=>{Yv()});var ey=h(()=>{"use strict";var u0=Hn(),c0=We();u0({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return c0(URL.prototype.toString,this)}})});var ty=h(()=>{wc()});var iy=h((ML,ry)=>{var m0=ce();ry.exports=m0});var sy=h((LL,ny)=>{Qv();ey();ty();var p0=iy();ny.exports=p0.URL});var hm=h((i_,pb)=>{var AE=Object.prototype.toString;pb.exports=function(e){if(e===void 0)return"undefined";if(e===null)return"null";var t=typeof e;if(t==="boolean")return"boolean";if(t==="string")return"string";if(t==="number")return"number";if(t==="symbol")return"symbol";if(t==="function")return FE(e)?"generatorfunction":"function";if(TE(e))return"array";if(UE(e))return"buffer";if(LE(e))return"arguments";if(RE(e))return"date";if(EE(e))return"error";if(OE(e))return"regexp";switch(mb(e)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(ME(e))return"generator";switch(t=AE.call(e),t){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return t.slice(8,-1).toLowerCase().replace(/\s/g,"")};function mb(r){return typeof r.constructor=="function"?r.constructor.name:null}function TE(r){return Array.isArray?Array.isArray(r):r instanceof Array}function EE(r){return r instanceof Error||typeof r.message=="string"&&r.constructor&&typeof r.constructor.stackTraceLimit=="number"}function RE(r){return r instanceof Date?!0:typeof r.toDateString=="function"&&typeof r.getDate=="function"&&typeof r.setDate=="function"}function OE(r){return r instanceof RegExp?!0:typeof r.flags=="string"&&typeof r.ignoreCase=="boolean"&&typeof r.multiline=="boolean"&&typeof r.global=="boolean"}function FE(r,e){return mb(r)==="GeneratorFunction"}function ME(r){return typeof r.throw=="function"&&typeof r.return=="function"&&typeof r.next=="function"}function LE(r){try{if(typeof r.length=="number"&&typeof r.callee=="function")return!0}catch(e){if(e.message.indexOf("callee")!==-1)return!0}return!1}function UE(r){return r.constructor&&typeof r.constructor.isBuffer=="function"?r.constructor.isBuffer(r):!1}});var hb=h((n_,gb)=>{"use strict";var fb=Symbol.prototype.valueOf,BE=hm();function DE(r,e){switch(BE(r)){case"array":return r.slice();case"object":return Object.assign({},r);case"date":return new r.constructor(Number(r));case"map":return new Map(r);case"set":return new Set(r);case"buffer":return jE(r);case"symbol":return HE(r);case"arraybuffer":return NE(r);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return qE(r);case"regexp":return _E(r);case"error":return Object.create(r);default:return r}}function _E(r){let e=r.flags!==void 0?r.flags:/\w+$/.exec(r)||void 0,t=new r.constructor(r.source,e);return t.lastIndex=r.lastIndex,t}function NE(r){let e=new r.constructor(r.byteLength);return new Uint8Array(e).set(new Uint8Array(r)),e}function qE(r,e){return new r.constructor(r.buffer,r.byteOffset,r.length)}function jE(r){let e=r.length,t=Buffer.allocUnsafe?Buffer.allocUnsafe(e):Buffer.from(e);return r.copy(t),t}function HE(r){return fb?Object(fb.call(r)):{}}gb.exports=DE});var yb=h((s_,vb)=>{"use strict";vb.exports=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1}});var Sb=h((o_,kb)=>{"use strict";var WE=yb();function bb(r){return WE(r)===!0&&Object.prototype.toString.call(r)==="[object Object]"}kb.exports=function(e){var t,i;return!(bb(e)===!1||(t=e.constructor,typeof t!="function")||(i=t.prototype,bb(i)===!1)||i.hasOwnProperty("isPrototypeOf")===!1)}});var Cb=h((a_,Pb)=>{"use strict";var GE=hb(),VE=hm(),zE=Sb();function vm(r,e){switch(VE(r)){case"object":return JE(r,e);case"array":return $E(r,e);default:return GE(r)}}function JE(r,e){if(typeof e=="function")return e(r);if(e||zE(r)){let t=new r.constructor;for(let i in r)t[i]=vm(r[i],e);return t}return r}function $E(r,e){let t=new r.constructor(r.length);for(let i=0;i<r.length;i++)t[i]=vm(r[i],e);return t}Pb.exports=vm});var Qd=h((vs,ki)=>{var KE=200,Tm="__lodash_hash_undefined__",Kd=1,Ub=2,Bb=9007199254740991,Hd="[object Arguments]",Sm="[object Array]",XE="[object AsyncFunction]",Db="[object Boolean]",_b="[object Date]",Nb="[object Error]",qb="[object Function]",ZE="[object GeneratorFunction]",Wd="[object Map]",jb="[object Number]",YE="[object Null]",bi="[object Object]",xb="[object Promise]",QE="[object Proxy]",Hb="[object RegExp]",Gd="[object Set]",Wb="[object String]",eR="[object Symbol]",tR="[object Undefined]",Pm="[object WeakMap]",Gb="[object ArrayBuffer]",Vd="[object DataView]",rR="[object Float32Array]",iR="[object Float64Array]",nR="[object Int8Array]",sR="[object Int16Array]",oR="[object Int32Array]",aR="[object Uint8Array]",dR="[object Uint8ClampedArray]",lR="[object Uint16Array]",uR="[object Uint32Array]",cR=/[\\^$.*+?()[\]{}|]/g,mR=/^\[object .+?Constructor\]$/,pR=/^(?:0|[1-9]\d*)$/,q={};q[rR]=q[iR]=q[nR]=q[sR]=q[oR]=q[aR]=q[dR]=q[lR]=q[uR]=!0;q[Hd]=q[Sm]=q[Gb]=q[Db]=q[Vd]=q[_b]=q[Nb]=q[qb]=q[Wd]=q[jb]=q[bi]=q[Hb]=q[Gd]=q[Wb]=q[Pm]=!1;var Vb=typeof global=="object"&&global&&global.Object===Object&&global,fR=typeof self=="object"&&self&&self.Object===Object&&self,ct=Vb||fR||Function("return this")(),zb=typeof vs=="object"&&vs&&!vs.nodeType&&vs,wb=zb&&typeof ki=="object"&&ki&&!ki.nodeType&&ki,Jb=wb&&wb.exports===zb,ym=Jb&&Vb.process,Ib=function(){try{return ym&&ym.binding&&ym.binding("util")}catch{}}(),Ab=Ib&&Ib.isTypedArray;function gR(r,e){for(var t=-1,i=r==null?0:r.length,n=0,o=[];++t<i;){var a=r[t];e(a,t,r)&&(o[n++]=a)}return o}function hR(r,e){for(var t=-1,i=e.length,n=r.length;++t<i;)r[n+t]=e[t];return r}function vR(r,e){for(var t=-1,i=r==null?0:r.length;++t<i;)if(e(r[t],t,r))return!0;return!1}function yR(r,e){for(var t=-1,i=Array(r);++t<r;)i[t]=e(t);return i}function bR(r){return function(e){return r(e)}}function kR(r,e){return r.has(e)}function SR(r,e){return r?.[e]}function PR(r){var e=-1,t=Array(r.size);return r.forEach(function(i,n){t[++e]=[n,i]}),t}function CR(r,e){return function(t){return r(e(t))}}function xR(r){var e=-1,t=Array(r.size);return r.forEach(function(i){t[++e]=i}),t}var wR=Array.prototype,IR=Function.prototype,Xd=Object.prototype,bm=ct["__core-js_shared__"],$b=IR.toString,et=Xd.hasOwnProperty,Tb=function(){var r=/[^.]+$/.exec(bm&&bm.keys&&bm.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}(),Kb=Xd.toString,AR=RegExp("^"+$b.call(et).replace(cR,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Eb=Jb?ct.Buffer:void 0,zd=ct.Symbol,Rb=ct.Uint8Array,Xb=Xd.propertyIsEnumerable,TR=wR.splice,gr=zd?zd.toStringTag:void 0,Ob=Object.getOwnPropertySymbols,ER=Eb?Eb.isBuffer:void 0,RR=CR(Object.keys,Object),Cm=Si(ct,"DataView"),ys=Si(ct,"Map"),xm=Si(ct,"Promise"),wm=Si(ct,"Set"),Im=Si(ct,"WeakMap"),bs=Si(Object,"create"),OR=yr(Cm),FR=yr(ys),MR=yr(xm),LR=yr(wm),UR=yr(Im),Fb=zd?zd.prototype:void 0,km=Fb?Fb.valueOf:void 0;function hr(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var i=r[e];this.set(i[0],i[1])}}function BR(){this.__data__=bs?bs(null):{},this.size=0}function DR(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}function _R(r){var e=this.__data__;if(bs){var t=e[r];return t===Tm?void 0:t}return et.call(e,r)?e[r]:void 0}function NR(r){var e=this.__data__;return bs?e[r]!==void 0:et.call(e,r)}function qR(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=bs&&e===void 0?Tm:e,this}hr.prototype.clear=BR;hr.prototype.delete=DR;hr.prototype.get=_R;hr.prototype.has=NR;hr.prototype.set=qR;function mt(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var i=r[e];this.set(i[0],i[1])}}function jR(){this.__data__=[],this.size=0}function HR(r){var e=this.__data__,t=Zd(e,r);if(t<0)return!1;var i=e.length-1;return t==i?e.pop():TR.call(e,t,1),--this.size,!0}function WR(r){var e=this.__data__,t=Zd(e,r);return t<0?void 0:e[t][1]}function GR(r){return Zd(this.__data__,r)>-1}function VR(r,e){var t=this.__data__,i=Zd(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}mt.prototype.clear=jR;mt.prototype.delete=HR;mt.prototype.get=WR;mt.prototype.has=GR;mt.prototype.set=VR;function vr(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var i=r[e];this.set(i[0],i[1])}}function zR(){this.size=0,this.__data__={hash:new hr,map:new(ys||mt),string:new hr}}function JR(r){var e=Yd(this,r).delete(r);return this.size-=e?1:0,e}function $R(r){return Yd(this,r).get(r)}function KR(r){return Yd(this,r).has(r)}function XR(r,e){var t=Yd(this,r),i=t.size;return t.set(r,e),this.size+=t.size==i?0:1,this}vr.prototype.clear=zR;vr.prototype.delete=JR;vr.prototype.get=$R;vr.prototype.has=KR;vr.prototype.set=XR;function Jd(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new vr;++e<t;)this.add(r[e])}function ZR(r){return this.__data__.set(r,Tm),this}function YR(r){return this.__data__.has(r)}Jd.prototype.add=Jd.prototype.push=ZR;Jd.prototype.has=YR;function Ot(r){var e=this.__data__=new mt(r);this.size=e.size}function QR(){this.__data__=new mt,this.size=0}function eO(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}function tO(r){return this.__data__.get(r)}function rO(r){return this.__data__.has(r)}function iO(r,e){var t=this.__data__;if(t instanceof mt){var i=t.__data__;if(!ys||i.length<KE-1)return i.push([r,e]),this.size=++t.size,this;t=this.__data__=new vr(i)}return t.set(r,e),this.size=t.size,this}Ot.prototype.clear=QR;Ot.prototype.delete=eO;Ot.prototype.get=tO;Ot.prototype.has=rO;Ot.prototype.set=iO;function nO(r,e){var t=$d(r),i=!t&&bO(r),n=!t&&!i&&Am(r),o=!t&&!i&&!n&&ik(r),a=t||i||n||o,c=a?yR(r.length,String):[],p=c.length;for(var f in r)(e||et.call(r,f))&&!(a&&(f=="length"||n&&(f=="offset"||f=="parent")||o&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||fO(f,p)))&&c.push(f);return c}function Zd(r,e){for(var t=r.length;t--;)if(Qb(r[t][0],e))return t;return-1}function sO(r,e,t){var i=e(r);return $d(r)?i:hR(i,t(r))}function Ss(r){return r==null?r===void 0?tR:YE:gr&&gr in Object(r)?mO(r):yO(r)}function Mb(r){return ks(r)&&Ss(r)==Hd}function Zb(r,e,t,i,n){return r===e?!0:r==null||e==null||!ks(r)&&!ks(e)?r!==r&&e!==e:oO(r,e,t,i,Zb,n)}function oO(r,e,t,i,n,o){var a=$d(r),c=$d(e),p=a?Sm:Rt(r),f=c?Sm:Rt(e);p=p==Hd?bi:p,f=f==Hd?bi:f;var v=p==bi,m=f==bi,k=p==f;if(k&&Am(r)){if(!Am(e))return!1;a=!0,v=!1}if(k&&!v)return o||(o=new Ot),a||ik(r)?Yb(r,e,t,i,n,o):uO(r,e,p,t,i,n,o);if(!(t&Kd)){var b=v&&et.call(r,"__wrapped__"),C=m&&et.call(e,"__wrapped__");if(b||C){var x=b?r.value():r,I=C?e.value():e;return o||(o=new Ot),n(x,I,t,i,o)}}return k?(o||(o=new Ot),cO(r,e,t,i,n,o)):!1}function aO(r){if(!rk(r)||hO(r))return!1;var e=ek(r)?AR:mR;return e.test(yr(r))}function dO(r){return ks(r)&&tk(r.length)&&!!q[Ss(r)]}function lO(r){if(!vO(r))return RR(r);var e=[];for(var t in Object(r))et.call(r,t)&&t!="constructor"&&e.push(t);return e}function Yb(r,e,t,i,n,o){var a=t&Kd,c=r.length,p=e.length;if(c!=p&&!(a&&p>c))return!1;var f=o.get(r);if(f&&o.get(e))return f==e;var v=-1,m=!0,k=t&Ub?new Jd:void 0;for(o.set(r,e),o.set(e,r);++v<c;){var b=r[v],C=e[v];if(i)var x=a?i(C,b,v,e,r,o):i(b,C,v,r,e,o);if(x!==void 0){if(x)continue;m=!1;break}if(k){if(!vR(e,function(I,E){if(!kR(k,E)&&(b===I||n(b,I,t,i,o)))return k.push(E)})){m=!1;break}}else if(!(b===C||n(b,C,t,i,o))){m=!1;break}}return o.delete(r),o.delete(e),m}function uO(r,e,t,i,n,o,a){switch(t){case Vd:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case Gb:return!(r.byteLength!=e.byteLength||!o(new Rb(r),new Rb(e)));case Db:case _b:case jb:return Qb(+r,+e);case Nb:return r.name==e.name&&r.message==e.message;case Hb:case Wb:return r==e+"";case Wd:var c=PR;case Gd:var p=i&Kd;if(c||(c=xR),r.size!=e.size&&!p)return!1;var f=a.get(r);if(f)return f==e;i|=Ub,a.set(r,e);var v=Yb(c(r),c(e),i,n,o,a);return a.delete(r),v;case eR:if(km)return km.call(r)==km.call(e)}return!1}function cO(r,e,t,i,n,o){var a=t&Kd,c=Lb(r),p=c.length,f=Lb(e),v=f.length;if(p!=v&&!a)return!1;for(var m=p;m--;){var k=c[m];if(!(a?k in e:et.call(e,k)))return!1}var b=o.get(r);if(b&&o.get(e))return b==e;var C=!0;o.set(r,e),o.set(e,r);for(var x=a;++m<p;){k=c[m];var I=r[k],E=e[k];if(i)var ue=a?i(E,I,k,e,r,o):i(I,E,k,r,e,o);if(!(ue===void 0?I===E||n(I,E,t,i,o):ue)){C=!1;break}x||(x=k=="constructor")}if(C&&!x){var Un=r.constructor,Aa=e.constructor;Un!=Aa&&"constructor"in r&&"constructor"in e&&!(typeof Un=="function"&&Un instanceof Un&&typeof Aa=="function"&&Aa instanceof Aa)&&(C=!1)}return o.delete(r),o.delete(e),C}function Lb(r){return sO(r,PO,pO)}function Yd(r,e){var t=r.__data__;return gO(e)?t[typeof e=="string"?"string":"hash"]:t.map}function Si(r,e){var t=SR(r,e);return aO(t)?t:void 0}function mO(r){var e=et.call(r,gr),t=r[gr];try{r[gr]=void 0;var i=!0}catch{}var n=Kb.call(r);return i&&(e?r[gr]=t:delete r[gr]),n}var pO=Ob?function(r){return r==null?[]:(r=Object(r),gR(Ob(r),function(e){return Xb.call(r,e)}))}:CO,Rt=Ss;(Cm&&Rt(new Cm(new ArrayBuffer(1)))!=Vd||ys&&Rt(new ys)!=Wd||xm&&Rt(xm.resolve())!=xb||wm&&Rt(new wm)!=Gd||Im&&Rt(new Im)!=Pm)&&(Rt=function(r){var e=Ss(r),t=e==bi?r.constructor:void 0,i=t?yr(t):"";if(i)switch(i){case OR:return Vd;case FR:return Wd;case MR:return xb;case LR:return Gd;case UR:return Pm}return e});function fO(r,e){return e=e??Bb,!!e&&(typeof r=="number"||pR.test(r))&&r>-1&&r%1==0&&r<e}function gO(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}function hO(r){return!!Tb&&Tb in r}function vO(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||Xd;return r===t}function yO(r){return Kb.call(r)}function yr(r){if(r!=null){try{return $b.call(r)}catch{}try{return r+""}catch{}}return""}function Qb(r,e){return r===e||r!==r&&e!==e}var bO=Mb(function(){return arguments}())?Mb:function(r){return ks(r)&&et.call(r,"callee")&&!Xb.call(r,"callee")},$d=Array.isArray;function kO(r){return r!=null&&tk(r.length)&&!ek(r)}var Am=ER||xO;function SO(r,e){return Zb(r,e)}function ek(r){if(!rk(r))return!1;var e=Ss(r);return e==qb||e==ZE||e==XE||e==QE}function tk(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=Bb}function rk(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function ks(r){return r!=null&&typeof r=="object"}var ik=Ab?bR(Ab):dO;function PO(r){return kO(r)?nO(r):lO(r)}function CO(){return[]}function xO(){return!1}ki.exports=SO});var _S=h(Il=>{"use strict";Il.byteLength=ZO;Il.toByteArray=QO;Il.fromByteArray=rF;var rt=[],Ne=[],XO=typeof Uint8Array<"u"?Uint8Array:Array,rp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Er=0,BS=rp.length;Er<BS;++Er)rt[Er]=rp[Er],Ne[rp.charCodeAt(Er)]=Er;var Er,BS;Ne["-".charCodeAt(0)]=62;Ne["_".charCodeAt(0)]=63;function DS(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var i=t===e?0:4-t%4;return[t,i]}function ZO(r){var e=DS(r),t=e[0],i=e[1];return(t+i)*3/4-i}function YO(r,e,t){return(e+t)*3/4-t}function QO(r){var e,t=DS(r),i=t[0],n=t[1],o=new XO(YO(r,i,n)),a=0,c=n>0?i-4:i,p;for(p=0;p<c;p+=4)e=Ne[r.charCodeAt(p)]<<18|Ne[r.charCodeAt(p+1)]<<12|Ne[r.charCodeAt(p+2)]<<6|Ne[r.charCodeAt(p+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=e&255;return n===2&&(e=Ne[r.charCodeAt(p)]<<2|Ne[r.charCodeAt(p+1)]>>4,o[a++]=e&255),n===1&&(e=Ne[r.charCodeAt(p)]<<10|Ne[r.charCodeAt(p+1)]<<4|Ne[r.charCodeAt(p+2)]>>2,o[a++]=e>>8&255,o[a++]=e&255),o}function eF(r){return rt[r>>18&63]+rt[r>>12&63]+rt[r>>6&63]+rt[r&63]}function tF(r,e,t){for(var i,n=[],o=e;o<t;o+=3)i=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),n.push(eF(i));return n.join("")}function rF(r){for(var e,t=r.length,i=t%3,n=[],o=16383,a=0,c=t-i;a<c;a+=o)n.push(tF(r,a,a+o>c?c:a+o));return i===1?(e=r[t-1],n.push(rt[e>>2]+rt[e<<4&63]+"==")):i===2&&(e=(r[t-2]<<8)+r[t-1],n.push(rt[e>>10]+rt[e>>4&63]+rt[e<<2&63]+"=")),n.join("")}});var bH=Dr(sy(),1);function g(r,e){if(r==null)throw Error(e??"Expected nonnullish value.")}function or(r,e){if(!r)throw Error(e)}var ee;(function(r){r.COMMENT="t1_",r.ACCOUNT="t2_",r.LINK="t3_",r.MESSAGE="t4_",r.SUBREDDIT="t5_",r.AWARD="t6_"})(ee||(ee={}));function Pt(r){return r.startsWith(ee.COMMENT)}function vd(r){return r.startsWith(ee.ACCOUNT)}function ar(r){return r.startsWith(ee.LINK)}function oy(r){return r.startsWith(ee.MESSAGE)}function ay(r){return r.startsWith(ee.SUBREDDIT)}function dy(r){return r.startsWith(ee.AWARD)}function f0(r){or(Pt(r),`Expected comment id to start with ${ee.COMMENT}, got ${r}}`)}function g0(r){or(vd(r),`Expected account id to start with ${ee.ACCOUNT}, got ${r}}`)}function h0(r){or(ar(r),`Expected link id to start with ${ee.LINK}, got ${r}}`)}function v0(r){or(oy(r),`Expected message id to start with ${ee.MESSAGE}, got ${r}}`)}function y0(r){or(ay(r),`Expected subreddit id to start with ${ee.SUBREDDIT}, got ${r}}`)}function b0(r){or(dy(r),`Expected award id to start with ${ee.AWARD}, got ${r}}`)}function Yr(r){return f0(r),r}function te(r){return g0(r),r}function fe(r){return h0(r),r}function k0(r){return v0(r),r}function Re(r){return y0(r),r}function S0(r){return b0(r),r}function ge(r){if(Pt(r))return Yr(r);if(vd(r))return te(r);if(ar(r))return fe(r);if(oy(r))return k0(r);if(ay(r))return Re(r);if(dy(r))return S0(r);throw new Error(`Expected thing id to start with ${Object.values(ee).join(", ")} got ${r}}`)}function Vc(r){return Pt(r)}import*as P from"@devvit/protos";var yd=class{constructor(e){}};var zc=(t=>(t.Installation="installation",t.App="app",t))(zc||{});function dr(r,e=new Set){for(let t of r){if(t.type==="group"){dr(t.fields,e);continue}let i=t.name;if(e.has(i))throw new Error(`Duplicate field name: ${i}`);e.add(i)}P0(r)}function P0(r){for(let e of r)if(e.type==="string"&&e.isSecret&&e.scope!=="app")throw`Invalid setting: only app settings can be secrets. Add "scope: SettingScope.App" to field "${e.name}"`}var Ct=Object.freeze({INTERVAL:0,FORM:1,STATE:2,CHANNEL:3});var GL=["activity","add-emoji","add","add-media","add-to-feed","admin","align-center","align-left","align-right","all","appearance","approve","archived","aspect-ratio","aspect-rectangle","attach","audio","author","avatar-style","award","back","ban","best","binoculars","block","blockchain","bold","bot","boost","bounce","brand-awareness","browse","browser","cake","calendar","camera","caret-down","caret-left","caret-right","caret-up","chat","chat-group","chat-new","checkbox-dismiss","checkbox","checkmark","chrome","clear","close","closed-captioning","code-block","code-inline","coins-color-old","coins-color","coins","collapse-left","collapse-right","collection","comment","comments","community","contest","controversial","crop","crosspost","crowd-control","custom-feed","customize","day","delete","discover","dismiss-all","distinguish","down-arrow","down","download","downvote","downvotes","drag","drugs","duplicate","edit","effect","embed","emoji","end-live-chat","error","expand-left","expand-right","external","feed-video","filter","format","forward","gif-post","heart","help","hide","history","home","hot","ignore-reports","image-post","inbox","info","invite","italic","join","joined","jump-down","jump-up","karma","keyboard","kick","language","leave","left","link","link-post","list-bulleted","list-numbered","live-chat","live","load","location","lock","logout","loop","mark-read","mask","media-gallery","meme","menu","message","mic","mic-mute","mod","mod-mail","mod-mode","mod-mute","mod-overflow","mod-queue","mod-unmute","music","new","night","notification","notification-frequent","notification-off","nsfw","nsfw-language","nsfw-violence","original","overflow-caret","overflow-horizontal","overflow-vertical","pause","payment","peace","pending-posts","phone","pin","planet","play","poll-post","popular","posts","powerup-color-outline","powerup-fill-color","powerup","predictions","premium","privacy","profile","qa","qr-code","quarantined","quote","r-slash","radio-button","raise-hand","random","ratings-everyone","ratings-mature","ratings-nsfw","ratings-violence","refresh","remove","reply","report","reverse","right","rising","rotate","rotate-image","rpan","rules","safari","save","saved","search","self","send","settings","share-android","share","share-ios","show","side-menu","skipback10","skipforward10","sort-az","sort","sort-price","sort-za","spam","spoiler","sponsored","star","statistics","status-live","sticker","strikethrough","subtract","superscript","swap-camera","swipe-back","swipe-down","swipe","swipe-up","table","tag","tap","telescope","text","text-post","text-size","toggle","tools","top","topic-activism","topic-addictionsupport","topic-advice","topic-animals","topic-anime","topic-art","topic-beauty","topic-business","topic-careers","topic-cars","topic-celebrity","topic-craftsdiy","topic-crypto","topic-culture","topic-diy","topic-entertainment","topic-ethics","topic-family","topic-fashion","topic","topic-fitness","topic-food","topic-funny","topic-gender","topic-health","topic-help","topic-history","topic-hobbies","topic-homegarden","topic-internet","topic-law","topic-learning","topic-lifestyle","topic-marketplace","topic-mature","topic-mensfashion","topic-menshealth","topic-meta","topic-military","topic-movies","topic-music","topic-news","topic-other","topic-outdoors","topic-pets","topic-photography","topic-places","topic-podcasts","topic-politics","topic-programming","topic-reading","topic-religion","topic-science","topic-sexorientation","topic-sports","topic-style","topic-tabletop","topic-technology","topic-television","topic-traumasupport","topic-travel","topic-videogaming","topic-womensfashion","topic-womenshealth","translate","trim","u-slash","unban","undo","unheart","unlock","unmod","unpin","unverified","up-arrow","up","upload","upvote","upvotes","user","user-note","users","vault","verified","video-camera","video-feed","video-live-1","video-live-fill-1","video-live","video-post","video-thread","video-transcription","view-card","view-classic","view-compact","view-grid","views","volume","volume-mute","wallet","warning","wiki-ban","wiki","wiki-unban","world"];import{AppSettingsDefinition as _0,GetFieldsResponse as N0}from"@devvit/protos";import{FormField as lr,FormFieldType as Oe}from"@devvit/protos";function dt(r){return r.map(e=>{switch(e.type){case"string":return C0(e);case"image":return x0(e);case"paragraph":return w0(e);case"number":return I0(e);case"select":return A0(e);case"boolean":return T0(e);case"group":return E0(e);default:throw new Error("Unknown field type.")}})}function C0(r){return lr.fromPartial({defaultValue:{fieldType:Oe.STRING,stringValue:r.defaultValue},disabled:r.disabled,fieldConfig:{stringConfig:{placeholder:r.placeholder}},fieldId:r.name,fieldType:Oe.STRING,helpText:r.helpText,label:r.label,required:r.required,isSecret:r.isSecret})}function x0(r){return lr.fromPartial({disabled:r.disabled,fieldId:r.name,fieldType:Oe.IMAGE,helpText:r.helpText,label:r.label,required:r.required})}function w0(r){return lr.fromPartial({defaultValue:{fieldType:Oe.PARAGRAPH,stringValue:r.defaultValue},disabled:r.disabled,fieldConfig:{paragraphConfig:{lineHeight:r.lineHeight,placeholder:r.placeholder}},fieldId:r.name,fieldType:Oe.PARAGRAPH,helpText:r.helpText,label:r.label,required:r.required})}function I0(r){return lr.fromPartial({defaultValue:{fieldType:Oe.NUMBER,numberValue:r.defaultValue},disabled:r.disabled,fieldConfig:{numberConfig:{}},fieldId:r.name,fieldType:Oe.NUMBER,helpText:r.helpText,label:r.label,required:r.required})}function A0(r){return lr.fromPartial({defaultValue:{fieldType:Oe.SELECTION,selectionValue:{values:r.defaultValue}},disabled:r.disabled,fieldConfig:{selectionConfig:{choices:r.options,multiSelect:r.multiSelect}},fieldId:r.name,fieldType:Oe.SELECTION,helpText:r.helpText,label:r.label,required:r.required})}function T0(r){return lr.fromPartial({defaultValue:{fieldType:Oe.BOOLEAN,boolValue:r.defaultValue},disabled:r.disabled,fieldId:r.name,fieldType:Oe.BOOLEAN,helpText:r.helpText,label:r.label})}function E0(r){return lr.fromPartial({fieldType:Oe.GROUP,fieldConfig:{groupConfig:{fields:dt(r.fields)}},label:r.label,helpText:r.helpText})}function L(r,e){u.prototype[r]=e}import{ValidateFormResponse as D0}from"@devvit/protos";import{RealtimeSubscriptionStatus as uy}from"@devvit/protos";var B=Object.freeze({Actor:"devvit-actor",App:"devvit-app",AppUser:"devvit-app-user",AppViewerAuthToken:"devvit-app-viewer-authorization",Caller:"devvit-caller",CallerPortID:"devvit-caller-port-id",Canary:"devvit-canary",Debug:"devvit-debug",GQLHost:"devvit-gql-host",Installation:"devvit-installation",ModPermissions:"devvit-mod-permissions",R2Auth:"devvit-sec-authorization",R2Host:"devvit-r2-host",RemoteHostname:"devvit-remote-hostname",SettingsUri:"devvit-sec-settings-uri",StreamID:"devvit-stream-id",Subreddit:"devvit-subreddit",TraceID:"devvit-trace-id",User:"devvit-user",Version:"devvit-version",Language:"devvit-accept-language",Timezone:"devvit-accept-timezone",AppDependencies:"devvit-app-dependencies"}),ly;(function(r){r.Blocks="blocks",r.EmitSnapshots="emitSnapshots",r.EmitState="emitState",r.Realtime="realtime",r.Runtime="runtime",r.Surface="surface",r.UseAsync="useAsync"})(ly||(ly={}));function cy(r){function e(t){let n=r.currentHookIndex,o=r.getCurrentComponentState(),a=r.getPreviousComponentState(),c=r.metadata[B.App]?.values[0];g(c,"useChannel - app is missing from Context");let p=r.metadata[B.Installation]?.values[0];g(p,"useChannel - installation is missing from Context");async function f(I){let E=o[n].channel;if(o[n].active)if(o[n].connected)await r.realtime.send(E,I);else throw Error(`Failed to send to channel '${E}'; it is active but not yet connected`);else throw Error(`Cannot send a message over inactive channel: ${E}`)}function v(){if(!o[n].active){let I=o[n].channel;o[n].active=!0,r.addRealtimeChannel(I)}}function m(){if(o[n].active){let I=o[n].channel;o[n].active=!1,r.removeRealtimeChannel(I)}}function k(I){return async()=>{let E;switch(I.status){case uy.REALTIME_SUBSCRIBED:o[n].connected=!0,E=t.onSubscribed?.();break;case uy.REALTIME_UNSUBSCRIBED:o[n].connected=!1,E=t.onUnsubscribed?.();break;default:E=t.onMessage(I.event?.data??{});break}await E}}let b={channel:`${c}:${p}:${t.name}`,active:!1,connected:!1,preventCallback:!1,type:Ct.CHANNEL};n in o?b=o[n]:n in a&&(b=a[n]);let C=r.realtimeEvent;r.isInitialRender?b.active=!1:C&&b.active&&C.event.channel===b.channel&&(b.preventCallback||r.runHook(k(C)),r.rerenderIn(0)),o[n]=b,r.currentHookIndex++;let x=0;return b.active&&b.connected?x=2:b.active&&!b.connected?x=1:!b.active&&b.connected?x=3:!b.active&&!b.connected&&(x=4),{subscribe:v,unsubscribe:m,send:f,status:x}}return e}import{FormFieldType as Qr}from"@devvit/protos";function Jc(r){switch(r.fieldType){case Qr.STRING:return r.stringValue;case Qr.IMAGE:return r.stringValue;case Qr.PARAGRAPH:return r.stringValue;case Qr.NUMBER:return r.numberValue;case Qr.BOOLEAN:return r.boolValue;case Qr.SELECTION:return r.selectionValue?.values??[];default:return}}function xt(r){return Object.keys(r).reduce((e,t)=>{let i=Jc(r[t]);return i!==void 0&&(e[t]=i),e},{})}function my(r){function e(t,i){let n=r.currentHookIndex,o=r.getCurrentComponentKey(),a=r.getCurrentComponentState(),c=r.getPreviousComponentState(),p=`form.hook.${o}.${n}`,f={formKey:p,preventSubmit:!1,type:Ct.FORM};n in a?f=a[n]:n in c&&(f=c[n]),a[n]=f,r.forms.set(p,t);let v=r.formSubmittedEvent;return v&&!f.preventSubmit&&v.formId===p&&r.runHook(async()=>{let m=i(xt(v.results));m&&m instanceof Promise&&await m,r.rerenderIn(0)}),a[n].preventSubmit=!1,r.currentHookIndex++,p}return e}function py(r){function e(t,i){let n=r.currentHookIndex,o=r.getCurrentComponentState(),a=r.getPreviousComponentState(),c=100,p=Math.max(c,i),f={lastRun:void 0,running:!1,preventCallback:!1,type:Ct.INTERVAL};n in o?f=o[n]:n in a&&(f=a[n]);function v(){i<c&&console.error(`useInterval delay must be at least ${c}ms. Your interval of ${i}ms was automatically extended.`);for(let[k,b]of Object.entries(o))if(k!==n.toString()&&b?.type===Ct.INTERVAL&&b?.running)throw new Error("Only one useInterval hook may be running at a time");o[n]={running:!0,lastRun:o[n]?.lastRun??Date.now(),preventCallback:!1,type:Ct.INTERVAL},r.rerenderIn(p)}function m(){o[n].running=!1,o[n].lastRun=void 0,o[n].preventCallback=!1}return r.isEffectRender&&f.running&&(f.preventCallback||(f.lastRun===void 0||f.lastRun+p<Date.now())&&r.runHook(async()=>{let k=t();k&&k instanceof Promise&&await k,f.lastRun=Date.now()}),r.rerenderIn(p)),f.preventCallback=!1,o[n]=f,r.currentHookIndex++,{start:v,stop:m}}return e}function fy(r){function e(t){let i=r.currentHookIndex,n=r.getCurrentComponentState(),o=r.getPreviousComponentState();if(i in n)return r.currentHookIndex++,[n[i],a];if(r.isInitialRender||!(i in o)){let c=t instanceof Function?t():t;if(c instanceof Promise)throw(async()=>{n[i]=await c,r.currentHookIndex=0})();n[i]=c}else n[i]=o[i];function a(c){if(r.isRendering)throw new Error("Cannot call setState while rendering.");n[i]=c instanceof Function?c(n[i]):c}return r.currentHookIndex++,[n[i],a]}return e}var Zc={now(){return new Date}};function gy(r){return`__autocache__${r}`}function hy(r){return`__lock__${r}`}var O0=300,F0=1e3,bd=5e3,$c=3,vy=.1,yy=1e3,M0=3e4;function by(r){if(r.error)throw new Error(r.error);return r.value}var wt,It,Fe,ei,Sd,ky,Pd,Sy,Cd,Py,is,Kc,xd,Cy,wd,xy,ns,Xc,Id,wy,kd=class{constructor(e,t,i=Zc){d(this,Sd);d(this,Pd);d(this,Cd);d(this,is);d(this,xd);d(this,wd);d(this,ns);d(this,Id);d(this,wt,void 0);d(this,It,{});d(this,Fe,void 0);d(this,ei,void 0);l(this,wt,e),l(this,ei,t),l(this,Fe,i)}async cache(e,t){l(this,It,s(this,ei).__cache=s(this,ei).__cache??{}),y(this,Id,wy).call(this,t);let i=y(this,Sd,ky).call(this,t.key);if(i!==void 0)return i;let n=await y(this,ns,Xc).call(this,t.key),o=await y(this,Pd,Sy).call(this,t,n,e);return by(o)}};wt=new WeakMap,It=new WeakMap,Fe=new WeakMap,ei=new WeakMap,Sd=new WeakSet,ky=function(e){let t=s(this,It)[e];if(t){let i=s(this,Fe).now().getTime(),n=t?.error&&t?.errorTime&&t.errorCount<$c&&Math.random()<vy&&t.errorTime+yy<i;if(t?.expires&&t.expires<i&&t.checkedAt+yy<i||n){delete s(this,It)[e];return}else return by(t)}},Pd=new WeakSet,Sy=async function(e,t,i){let n=t?.expires,o=n?y(this,wd,xy).call(this,n):1;return!t||t?.error&&t.errorCount<$c&&vy>Math.random()||o>Math.random()?y(this,Cd,Py).call(this,e,t,i):t},Cd=new WeakSet,Py=async function(e,t,i){let n=hy(e.key),o=s(this,Fe).now().getTime(),a=new Date(o+e.ttl/2);if(await s(this,wt).set(n,"1",{expiration:a,nx:!0}))return y(this,xd,Cy).call(this,e.key,t,i,e.ttl);if(t)return t;{let p=s(this,Fe).now();return y(this,is,Kc).call(this,p,e.key,e.ttl)}},is=new WeakSet,Kc=async function(e,t,i){let n=Math.min(i,F0),o=await y(this,ns,Xc).call(this,t);if(o)return o;if(s(this,Fe).now().getTime()-e.getTime()>=n)throw new Error(`Cache request timed out trying to get data at key: ${t}`);return await new Promise(a=>setTimeout(a,O0)),y(this,is,Kc).call(this,e,t,i)},xd=new WeakSet,Cy=async function(e,t,i,n){let o=s(this,Fe).now().getTime()+n;t=t??{value:null,expires:o,errorCount:0,error:null,errorTime:null,checkedAt:0};try{t.value=await i(),t.error=null,t.errorCount=0,t.errorTime=null}catch(a){t.value=null,t.error=a.message??"Unknown error",t.errorTime=s(this,Fe).now().getTime(),t.errorCount++}return s(this,It)[e]=t,await s(this,wt).set(gy(e),JSON.stringify(t),{expiration:new Date(o+M0)}),t.error&&t.errorCount<$c&&await s(this,wt).del(hy(e)),t},wd=new WeakSet,xy=function(e){let t=s(this,Fe).now().getTime(),i=e-t;return i<0?1:i<1e3?.1:i<2e3?.01:i<3e3?.001:0},ns=new WeakSet,Xc=async function(e){let t=await s(this,wt).get(gy(e));if(t){let i=JSON.parse(t);return i.checkedAt=s(this,Fe).now().getTime(),s(this,It)[e]=i,i}},Id=new WeakSet,wy=function(e){e.ttl<bd&&(console.warn(`Cache TTL cannot be less than ${bd} milliseconds! Updating ttl value of ${e.ttl} to ${bd}.`),e.ttl=bd)};function Iy(r,e,t=Zc){let i=new kd(r,e,t);return i.cache.bind(i)}var ti,ri,Ad,Ay,Td,Ty,ii=class{constructor(){d(this,Ad);d(this,Td);d(this,ti,{});d(this,ri,{});l(this,ti,u.assets),l(this,ri,u.webviewAssets)}getURL(e,t){return typeof e=="string"?y(this,Ad,Ay).call(this,e,t??{webview:!1}):y(this,Td,Ty).call(this,e,t??{webview:!1})}};ti=new WeakMap,ri=new WeakMap,Ad=new WeakSet,Ay=function(e,t){let i=t.webview?s(this,ri)[e]:s(this,ti)[e];if(i)return i;try{return new URL(e.slice(0,e.indexOf(","))),e}catch{return""}},Td=new WeakSet,Ty=function(e,t){let i={},n=[],o=t.webview?s(this,ri):s(this,ti);if(o)for(let a of e)if(o[a])i[a]=o[a];else try{new URL(a.slice(0,a.indexOf(","))),i[a]=a}catch{n.push(a)}else n=e;if(n.length>0)throw new Error(`The following assets were missing from the assets list: ${n.join(", ")}`);return i};var At,ni=class{constructor(e){d(this,At,void 0);l(this,At,e)}async get(e){let{messages:t}=await u.kvStorePlugin.Get({keys:[e]},s(this,At));try{if(t[e])return JSON.parse(t[e])}catch{return}}async put(e,t){let i={};i[e]=JSON.stringify(t),await u.kvStorePlugin.Put({messages:i},s(this,At))}async delete(e){await u.kvStorePlugin.Del({keys:[e]},s(this,At))}async list(){let{keys:e}=await u.kvStorePlugin.List({filter:"*"},s(this,At));return e}};At=new WeakMap;var ss,si=class{constructor(e){d(this,ss,void 0);l(this,ss,e)}async upload(e){let t=await u.mediaPlugin.Upload(e,s(this,ss));if(!t.mediaId)throw new Error("unable to get mediaId via uploads");return Promise.resolve({mediaId:t.mediaId,mediaUrl:t.mediaUrl})}};ss=new WeakMap;var os,oi=class{constructor(e){d(this,os,void 0);l(this,os,e)}async add(e){await u.modLogPlugin.Add(e,s(this,os))}};os=new WeakMap;var as,ai=class{constructor(e){d(this,as,void 0);l(this,as,e)}async send(e,t){await u.realtimePlugin.Send({channel:e,data:t},s(this,as))}};as=new WeakMap;var S,ds,li=class{constructor(e){d(this,S,void 0);d(this,ds,void 0);l(this,S,e),l(this,ds,new Rd(e))}get modMail(){return s(this,ds)}getSubredditById(e){return he.getById(ge(e),s(this,S))}getSubredditByName(e){return he.getByName(e,s(this,S))}addSubredditRemovalReason(e,t){return he.addRemovalReason(e,t.title,t.message,s(this,S))}getSubredditRemovalReasons(e){return he.getRemovalReasons(e,s(this,S))}getCurrentSubreddit(){return he.getFromMetadata(s(this,S))}getPostById(e){return V.getById(ge(e),s(this,S))}submitPost(e){return V.submit(e,s(this,S))}crosspost(e){return V.crosspost(e,s(this,S))}getUserById(e){return w.getById(ge(e),s(this,S))}getCollectionById(e){return di.getCollectionById({collectionId:e},s(this,S))}createCollection(e){return di.create(e,s(this,S))}getCollectionsForSubreddit(e){return di.getCollectionsForSubreddit({subredditId:e},s(this,S))}getUserByUsername(e){return w.getByUsername(e,s(this,S))}getCurrentUser(){return w.getFromMetadata(B.User,s(this,S))}getAppUser(){return w.getFromMetadata(B.AppUser,s(this,S))}getSnoovatarUrl(e){return w.getSnoovatarUrl(e,s(this,S))}getCommentById(e){return X.getById(ge(e),s(this,S))}getComments(e){return X.getComments(e,s(this,S))}getCommentsByUser(e){return X.getCommentsByUser(e,s(this,S))}submitComment(e){return X.submit({...e,id:ge(e.id)},s(this,S))}getControversialPosts(e){return V.getControversialPosts(e,s(this,S))}getTopPosts(e){return V.getTopPosts(e,s(this,S))}getHotPosts(e){return V.getHotPosts(e,s(this,S))}getNewPosts(e){return V.getNewPosts(e,s(this,S))}getRisingPosts(e){return V.getRisingPosts(e,s(this,S))}getPostsByUser(e){return V.getPostsByUser(e,s(this,S))}getCommentsAndPostsByUser(e){return w.getOverview(e,s(this,S))}getModerationLog(e){return Ed(e,s(this,S))}getApprovedUsers(e){return w.getSubredditUsersByType({type:"contributors",...e},s(this,S))}approveUser(e,t){return w.createRelationship({username:e,subredditName:t,type:"contributor"},s(this,S))}removeUser(e,t){return w.removeRelationship({username:e,subredditName:t,type:"contributor"},s(this,S))}getWikiContributors(e){return w.getSubredditUsersByType({type:"wikicontributors",...e},s(this,S))}addWikiContributor(e,t){return w.createRelationship({username:e,subredditName:t,type:"wikicontributor"},s(this,S))}removeWikiContributor(e,t){return w.removeRelationship({username:e,subredditName:t,type:"wikicontributor"},s(this,S))}getBannedUsers(e){return w.getSubredditUsersByType({type:"banned",...e},s(this,S))}banUser(e){return w.createRelationship({username:e.username,subredditName:e.subredditName,type:"banned",banReason:e.reason,banMessage:e.message,note:e.note,duration:e.duration},s(this,S))}unbanUser(e,t){return w.removeRelationship({username:e,subredditName:t,type:"banned"},s(this,S))}getBannedWikiContributors(e){return w.getSubredditUsersByType({type:"wikibanned",...e},s(this,S))}banWikiContributor(e){return w.createRelationship({...e,type:"wikibanned"},s(this,S))}unbanWikiContributor(e,t){return w.removeRelationship({username:e,subredditName:t,type:"wikibanned"},s(this,S))}getModerators(e){return w.getSubredditUsersByType({type:"moderators",...e},s(this,S))}inviteModerator(e){return w.createRelationship({type:"moderator_invite",subredditName:e.subredditName,username:e.subredditName,permissions:e.permissions??[]},s(this,S))}revokeModeratorInvite(e,t){return w.removeRelationship({username:e,subredditName:t,type:"moderator_invite"},s(this,S))}removeModerator(e,t){return w.removeRelationship({type:"moderator",subredditName:t,username:e},s(this,S))}setModeratorPermissions(e,t,i){return w.setModeratorPermissions(e,t,i,s(this,S))}getMutedUsers(e){return w.getSubredditUsersByType({type:"muted",...e},s(this,S))}muteUser(e){return w.createRelationship({...e,type:"muted"},s(this,S))}unmuteUser(e,t){return w.removeRelationship({username:e,subredditName:t,type:"muted"},s(this,S))}getModNotes(e){return Me.get(e,s(this,S))}deleteModNote(e){return Me.delete(e,s(this,S))}addModNote(e){let t={...e,redditId:ge(e.redditId)};return Me.add(t,s(this,S))}addRemovalNote(e){return Me.addRemovalNote(e,s(this,S))}async sendPrivateMessage(e){return ur.send(e,s(this,S))}async sendPrivateMessageAsSubreddit(e){return ur.sendAsSubreddit(e,s(this,S))}async approve(e){if(Pt(e))return X.approve(e,s(this,S));if(ar(e))return V.approve(e,s(this,S));throw new Error("id must start with either t1_ or t3_")}async remove(e,t){if(Pt(e))return X.remove(e,t,s(this,S));if(ar(e))return V.remove(e,t,s(this,S));throw new Error("id must start with either t1_ or t3_")}async getPostFlairTemplates(e){return ae.getPostFlairTemplates(e,s(this,S))}async getUserFlairTemplates(e){return ae.getUserFlairTemplates(e,s(this,S))}async createPostFlairTemplate(e){return ae.createPostFlairTemplate(e,s(this,S))}async createUserFlairTemplate(e){return ae.createUserFlairTemplate(e,s(this,S))}async editFlairTemplate(e){return ae.editFlairTemplate(e,s(this,S))}async deleteFlairTemplate(e,t){return ae.deleteFlairTemplate(e,t,s(this,S))}async setUserFlair(e){return Le.setUserFlair(e,s(this,S))}async removeUserFlair(e,t){return Le.removeUserFlair(e,t,s(this,S))}async setPostFlair(e){return Le.setPostFlair(e,s(this,S))}async removePostFlair(e,t){return Le.removePostFlair(e,fe(t),s(this,S))}async getWidgets(e){return re.getWidgets(e,s(this,S))}async deleteWidget(e,t){return re.delete(e,t,s(this,S))}async addWidget(e){return re.add(e,s(this,S))}async reorderWidgets(e,t){return re.reorder(e,t,s(this,S))}async getWikiPage(e,t){return ve.getPage(e,t,s(this,S))}async getWikiPages(e){return ve.getPages(e,s(this,S))}async createWikiPage(e){return ve.createPage(e,s(this,S))}async updateWikiPage(e){return ve.updatePage(e,s(this,S))}getWikiPageRevisions(e){return ve.getPageRevisions(e,s(this,S))}async revertWikiPage(e,t,i){return ve.revertPage(e,t,i,s(this,S))}async getWikiPageSettings(e,t){return ve.getPageSettings(e,t,s(this,S))}async updateWikiPageSettings(e){return ve.updatePageSettings(e,s(this,S))}async addEditorToWikiPage(e,t,i){return ve.addEditor(e,t,i,s(this,S))}async removeEditorFromWikiPage(e,t,i){return ve.removeEditor(e,t,i,s(this,S))}getMessages(e){return ur.getMessages(e,s(this,S))}markAllMessagesAsRead(){return ur.markAllAsRead(s(this,S))}report(e,t){return u.redditAPIPlugins.LinksAndComments.Report({reason:t.reason,thingId:e.id,srName:e.subredditName,usernames:e.authorName},s(this,S))}getModQueue(e){return he.aboutLocation({...e,location:"modqueue"},s(this,S))}getReports(e){return he.aboutLocation({...e,location:"reports"},s(this,S))}getSpam(e){return he.aboutLocation({...e,location:"spam"},s(this,S))}getUnmoderated(e){return he.aboutLocation({...e,location:"unmoderated"},s(this,S))}getEdited(e){return he.aboutLocation({...e,location:"edited"},s(this,S))}getVaultByAddress(e){return Oy(e,s(this,S))}getVaultByUserId(e){return Fy(ge(e),s(this,S))}getSubredditLeaderboard(e){return Ry(e,s(this,S))}};S=new WeakMap,ds=new WeakMap;import{RedisKeyScope as Yc}from"@devvit/protos";var R,O,F,Qc=class{constructor(e,t,i){d(this,R,void 0);d(this,O,void 0);d(this,F,void 0);l(this,R,e),l(this,O,t),l(this,F,i)}async get(e){return await s(this,R).Get({key:e,transactionId:s(this,O)},s(this,F)),this}async multi(){await s(this,R).Multi(s(this,O),s(this,F))}async set(e,t,i){let n;return i?.expiration&&(n=Math.floor((i.expiration.getTime()-Date.now())/1e3),n<1&&(n=1)),await s(this,R).Set({key:e,value:t,nx:i?.nx===!0,xx:i?.xx===!0,expiration:n||0,transactionId:s(this,O)},s(this,F)),this}async del(...e){return await s(this,R).Del({keys:e,transactionId:s(this,O)},s(this,F)),this}async type(e){return await s(this,R).Type({key:e,transactionId:s(this,O)},s(this,F)),this}async exec(){let e=await s(this,R).Exec(s(this,O),s(this,F)),t=[];for(let i of e.response)i.members?t.push(i.members):i.nil!==void 0?t.push(null):i.num!==void 0?t.push(i.num):i.values!==void 0?t.push(i.values.values):i.str!==void 0&&t.push(i.str);return t}async discard(){await s(this,R).Discard(s(this,O),s(this,F))}async watch(...e){return await s(this,R).Watch({keys:e,transactionId:s(this,O)},s(this,F)),this}async unwatch(){return await s(this,R).Unwatch(s(this,O),s(this,F)),this}async getRange(e,t,i){return await s(this,R).GetRange({key:e,start:t,end:i,transactionId:s(this,O)},s(this,F)),this}async setRange(e,t,i){return await s(this,R).SetRange({key:e,offset:t,value:i,transactionId:s(this,O)},s(this,F)),this}async strlen(e){return await s(this,R).Strlen({key:e,transactionId:s(this,O)},s(this,F)),this}async mget(e){return await s(this,R).MGet({keys:e,transactionId:s(this,O)},s(this,F)),this}async mset(e){let t=Object.entries(e).map(([i,n])=>({key:i,value:n}));return await s(this,R).MSet({kv:t,transactionId:s(this,O)},s(this,F)),this}async incrBy(e,t){return await s(this,R).IncrBy({key:e,value:t,transactionId:s(this,O)},s(this,F)),this}async expire(e,t){return await s(this,R).Expire({key:e,seconds:t,transactionId:s(this,O)},s(this,F)),this}async expireTime(e){return await s(this,R).ExpireTime({key:e,transactionId:s(this,O)},s(this,F)),this}async zAdd(e,...t){return await s(this,R).ZAdd({key:e,members:t,transactionId:s(this,O)},s(this,F)),this}async zScore(e,t){return await s(this,R).ZScore({key:{key:e,transactionId:s(this,O)},member:t},s(this,F)),this}async zRank(e,t){return await s(this,R).ZRank({key:{key:e,transactionId:s(this,O)},member:t},s(this,F)),this}async zIncrBy(e,t,i){return await s(this,R).ZIncrBy({key:e,member:t,value:i,transactionId:s(this,O)},s(this,F)),this}async zScan(e,t,i,n){let o={key:e,cursor:t,pattern:i,count:n,transactionId:s(this,O)};return await s(this,R).ZScan(o,s(this,F)),this}async zCard(e){return await s(this,R).ZCard({key:e,transactionId:s(this,O)},s(this,F)),this}async zRange(e,t,i,n){let o={rev:!1,byLex:!1,byScore:!1,offset:0,count:1e3};return n?.reverse&&(o.rev=n.reverse),n?.by==="lex"?o.byLex=!0:n?.by==="score"&&(o.byScore=!0),await s(this,R).ZRange({key:{key:e,transactionId:s(this,O)},start:t+"",stop:i+"",...o},s(this,F)),this}async zRem(e,t){return await s(this,R).ZRem({key:{key:e,transactionId:s(this,O)},members:t},s(this,F)),this}async zRemRangeByLex(e,t,i){return await s(this,R).ZRemRangeByLex({key:{key:e,transactionId:s(this,O)},min:t,max:i},s(this,F)),this}async zRemRangeByRank(e,t,i){return await s(this,R).ZRemRangeByRank({key:{key:e,transactionId:s(this,O)},start:t,stop:i},s(this,F)),this}async zRemRangeByScore(e,t,i){return await s(this,R).ZRemRangeByScore({key:{key:e,transactionId:s(this,O)},min:t,max:i},s(this,F)),this}async hgetall(e){return await s(this,R).HGetAll({key:e,transactionId:s(this,O)},s(this,F)),this}async hget(e,t){return await s(this,R).HGet({key:e,field:t,transactionId:s(this,O)},s(this,F)),this}async hset(e,t){let i=Object.entries(t).map(([n,o])=>({field:n,value:o}));return await s(this,R).HSet({key:e,fv:i,transactionId:s(this,O)},s(this,F)),this}async hincrby(e,t,i){return await s(this,R).HIncrBy({key:e,field:t,value:i,transactionId:s(this,O)},s(this,F)),this}async hdel(e,t){return await s(this,R).HDel({key:e,fields:t,transactionId:s(this,O)},s(this,F)),this}async hscan(e,t,i,n){let o={key:e,cursor:t,pattern:i,count:n,transactionId:s(this,O)};return await s(this,R).HScan(o,s(this,F)),this}async hkeys(e){return await s(this,R).HKeys({key:e,transactionId:s(this,O)},s(this,F)),this}async hlen(e){return await s(this,R).HLen({key:e,transactionId:s(this,O)},s(this,F)),this}};R=new WeakMap,O=new WeakMap,F=new WeakMap;var M,ui,em=class em{constructor(e,t=void 0,i=Yc.INSTALLATION){d(this,M,void 0);d(this,ui,void 0);l(this,M,e),l(this,ui,t),this.scope=i,this.global=i===Yc.INSTALLATION?new em(s(this,M),s(this,ui),Yc.GLOBAL):this}get storage(){return s(this,ui)||u.redisPlugin}async watch(...e){let t=await this.storage.Watch({keys:e},s(this,M));return new Qc(this.storage,t,s(this,M))}async get(e){let t=await this.storage.Get({key:e,scope:this.scope},s(this,M));return t!==null?t.value??void 0:t}async set(e,t,i){let n;return i?.expiration&&(n=Math.floor((i.expiration.getTime()-Date.now())/1e3),n<1&&(n=1)),(await this.storage.Set({key:e,value:t,nx:i?.nx===!0&&!i.xx,xx:i?.xx===!0&&!i.nx,expiration:n||0,scope:this.scope},s(this,M))).value}async del(...e){await this.storage.Del({keys:e,scope:this.scope},s(this,M))}async incrBy(e,t){return(await this.storage.IncrBy({key:e,value:t,scope:this.scope},s(this,M))).value}async getRange(e,t,i){let n=await this.storage.GetRange({key:e,start:t,end:i,scope:this.scope},s(this,M));return n!==null?n.value:n}async setRange(e,t,i){return(await this.storage.SetRange({key:e,offset:t,value:i,scope:this.scope},s(this,M))).value}async strlen(e){return(await this.storage.Strlen({key:e,scope:this.scope},s(this,M))).value}async expire(e,t){await this.storage.Expire({key:e,seconds:t,scope:this.scope},s(this,M))}async expireTime(e){return(await this.storage.ExpireTime({key:e,scope:this.scope},s(this,M))).value}async zAdd(e,...t){return(await this.storage.ZAdd({key:e,members:t,scope:this.scope},s(this,M))).value}async zRange(e,t,i,n){let o={rev:!1,byLex:!1,byScore:!1,offset:0,count:1e3};return n?.reverse&&(o.rev=n.reverse),n?.by==="lex"?o.byLex=!0:n?.by==="score"?o.byScore=!0:(o.offset=0,o.count=0),(await this.storage.ZRange({key:{key:e},start:t+"",stop:i+"",...o,scope:this.scope},s(this,M))).members}async zRem(e,t){return(await this.storage.ZRem({key:{key:e},members:t,scope:this.scope},s(this,M))).value}async zRemRangeByLex(e,t,i){return(await this.storage.ZRemRangeByLex({key:{key:e},min:t,max:i,scope:this.scope},s(this,M))).value}async zRemRangeByRank(e,t,i){return(await this.storage.ZRemRangeByRank({key:{key:e},start:t,stop:i,scope:this.scope},s(this,M))).value}async zRemRangeByScore(e,t,i){return(await this.storage.ZRemRangeByScore({key:{key:e},min:t,max:i,scope:this.scope},s(this,M))).value}async zScore(e,t){let i=await this.storage.ZScore({key:{key:e},member:t,scope:this.scope},s(this,M));return i!==null?i.value:i}async zRank(e,t){let i=await this.storage.ZRank({key:{key:e},member:t,scope:this.scope},s(this,M));return i!==null?i.value:i}async zIncrBy(e,t,i){let n=await this.storage.ZIncrBy({key:e,member:t,value:i,scope:this.scope},s(this,M));return n!==null?n.value:n}async mget(e){let t=await this.storage.MGet({keys:e,scope:this.scope},s(this,M));return t!==null?t.values.map(i=>i||null):t}async mset(e){let t=Object.entries(e).map(([i,n])=>({key:i,value:n}));await this.storage.MSet({kv:t,scope:this.scope},s(this,M))}async zCard(e){let t=await this.storage.ZCard({key:e,scope:this.scope},s(this,M));return t!==null?t.value:t}async zScan(e,t,i,n){let o={key:e,cursor:t,pattern:i,count:n,scope:this.scope};return await this.storage.ZScan(o,s(this,M))}async type(e){let t=await this.storage.Type({key:e,scope:this.scope},s(this,M));return t!==null?t.value:t}async hget(e,t){let i=await this.storage.HGet({key:e,field:t,scope:this.scope},s(this,M));return i!==null?i.value??void 0:i}async hset(e,t){let i=Object.entries(t).map(([o,a])=>({field:o,value:a}));return(await this.storage.HSet({key:e,fv:i,scope:this.scope},s(this,M))).value}async hgetall(e){let t=await this.storage.HGetAll({key:e,scope:this.scope},s(this,M));return t!==null?t.fieldValues:t}async hdel(e,t){return(await this.storage.HDel({key:e,fields:t,scope:this.scope},s(this,M))).value}async hscan(e,t,i,n){let o={key:e,cursor:t,pattern:i,count:n,scope:this.scope};return await this.storage.HScan(o,s(this,M))}async hkeys(e){let t=await this.storage.HKeys({key:e,scope:this.scope},s(this,M));return t!==null?t.keys:t}async hincrby(e,t,i){return(await this.storage.HIncrBy({key:e,field:t,value:i,scope:this.scope},s(this,M))).value}async hlen(e){return(await this.storage.HLen({key:e,scope:this.scope})).value}};M=new WeakMap,ui=new WeakMap;var ci=em;var cr,mi=class{constructor(e){d(this,cr,void 0);l(this,cr,e)}async runJob(e){return(await u.schedulerPlugin.Schedule({action:{type:e.name,data:e.data},cron:"cron"in e?e.cron:void 0,when:"runAt"in e?e.runAt:void 0},s(this,cr))).id}async cancelJob(e){await u.schedulerPlugin.Cancel({id:e},s(this,cr))}async listJobs(){return(await u.schedulerPlugin.List({after:new Date(0),before:new Date(Date.now()+31536e7)},s(this,cr))).actions.map(t=>(g(t.request?.action,"Scheduled job is malformed"),"when"in t.request&&t.request.when!=null?{id:t.id,name:t.request.action.type,runAt:t.request.when,data:t.request.action.data}:{id:t.id,name:t.request.action.type,cron:t.request.cron??"",data:t.request.action}))}};cr=new WeakMap;var ls,pi=class{constructor(e){d(this,ls,void 0);l(this,ls,e)}async get(e){return(await this.getAll())[e]}async getAll(){let t=await u.settingsPlugin.GetSettings({},s(this,ls));if(!t.installationSettings)throw new Error("Could not get installation settings");if(!t.appSettings)throw new Error("Could not get app settings");return{...My(t.installationSettings.settings,u.installationSettings),...My(t.appSettings.settings,u.appSettings)}}};ls=new WeakMap;function My(r,e){let t=Object.keys(r).reduce((i,n)=>(i[n]=Jc(r[n]),i),{});return e&&Ly(t,e),t}function Ly(r,e){for(let t of e)t.type==="group"?Ly(r,t.fields):!(t.name in r)&&"defaultValue"in t&&(r[t.name]=t.defaultValue)}import{EffectType as tm,Form as L0,ToastAppearance as Uy}from"@devvit/protos";var mr,fi,Od=class{constructor(e){d(this,mr,[]);d(this,fi,void 0);l(this,fi,e)}showForm(e,t){let i=u.formDefinitions.get(e);if(!i&&s(this,fi)){let a=s(this,fi).forms.get(e);a&&(i={form:a,onSubmit:()=>{}})}if(!i)throw new Error("Form does not exist. Make sure you have added it using Devvit.createForm at the root of your app.");let n=i.form instanceof Function?i.form(t??{}):i.form,o=L0.fromPartial({id:e,title:n.title,acceptLabel:n.acceptLabel,cancelLabel:n.cancelLabel,shortDescription:n.description});dr(n.fields),o.fields=dt(n.fields),s(this,mr).push({type:tm.EFFECT_SHOW_FORM,showForm:{form:o}})}showToast(e){let t;e instanceof Object?t={text:e.text,appearance:e.appearance==="success"?Uy.SUCCESS:Uy.NEUTRAL}:t={text:e},s(this,mr).push({type:tm.EFFECT_SHOW_TOAST,showToast:{toast:t}})}navigateTo(e){let t;typeof e=="string"?t=new URL(e).toString():t=new URL(e.permalink,"https://www.reddit.com").toString(),s(this,mr).push({type:tm.EFFECT_NAVIGATE_TO_URL,navigateToUrl:{url:t}})}get __effects(){return s(this,mr)}};mr=new WeakMap,fi=new WeakMap;function Ue({metadata:r,ui:e,hooks:t,reconciler:i}){let n=new oi(r),o=new ni(r),a=new ci(r),c=Iy(a,i?i.state:{}),p=new li(r),f=new mi(r),v=new pi(r),m=e?new Od(i):void 0,k=new si(r),b=new ii,C=new ai(r),x=t&&i?fy(i):void 0,I=t&&i?py(i):void 0,E=t&&i?my(i):void 0,ue=t&&i?cy(i):void 0;return{modLog:n,kvStore:o,redis:a,reddit:p,scheduler:f,settings:v,media:k,assets:b,realtime:C,get useForm(){return E??(()=>{throw new Error("useForm() is unavailable")})},get cache(){return c??(()=>{throw new Error("cache() is unavailable")})},get useState(){return x??(()=>{throw new Error("useState() is unavailable")})},get useInterval(){return I??(()=>{throw new Error("useInterval() is unavailable")})},get useChannel(){return ue??(()=>{throw new Error("useChannel() is unavailable")})},get ui(){if(!m)throw new Error("ui client is not available");return m}}}var By={name:"@devvit/public-api",version:"0.11.0-dev",license:"BSD-3-Clause",repository:{type:"git",url:"https://developers.reddit.com/"},type:"module",exports:{".":"./dist/index.js","./package.json":"./package.json","./*":"./dist/*"},main:"./dist/index.js",files:["dist/**"],scripts:{build:"yarn build:icon-types && yarn build:semantic-colors && tsc && cp -af devvit.tsconfig.json dist/ && yarn build:types && yarn build:min && yarn build:unmin","build:icon-types":"make-icons src/types/icons.ts","build:min":"esbuild --bundle --sourcemap=linked --target=es2020 --format=esm --metafile=dist/meta.min.json --outfile=dist/public-api.min.js --external:@devvit/protos --minify src/index.ts","build:semantic-colors":"node scripts/make-semantic-colors.js","build:types":"api-extractor run && sed -ne '/declare global {/,$ p' src/devvit/Devvit.ts >> dist/public-api.d.ts","build:unmin":"esbuild --bundle --sourcemap=inline --target=es2020 --format=iife --metafile=dist/meta.json --outfile=dist/public-api.iife.js --global-name=devvitPublicAPI src/index.ts",clean:"rm -rf .turbo api-extractor coverage dist src/devvit/internals/semanticColors.ts src/types/icons.ts || :",clobber:"yarn clean && rm -rf node_modules",dev:"tsc -w","dev:build":"chokidar ./src --command 'yarn build' --ignore './src/types/icons.ts' --ignore './src/devvit/internals/semanticColors.ts'",lint:"redlint .","lint:fix":"yarn lint --fix",prepublishOnly:"publish-package-json",test:"yarn test:unit && yarn test:types && yarn test:size","test:size":"filesize","test:types":"tsc --noEmit","test:unit":"vitest run","test:unit-with-coverage":"vitest run --coverage"},types:"./dist/index.d.ts",dependencies:{"@devvit/protos":"0.11.0-dev","@devvit/shared-types":"0.11.0-dev","base64-js":"1.5.1","clone-deep":"4.0.1","core-js":"3.27.2","lodash.isequal":"4.5.0"},devDependencies:{"@ampproject/filesize":"4.3.0","@devvit/eslint-config":"0.11.0-dev","@devvit/repo-tools":"0.11.0-dev","@devvit/tsconfig":"0.11.0-dev","@microsoft/api-extractor":"7.41.0","@reddit/faceplate-ui":"11.3.3","@types/clone-deep":"4.0.1","@types/core-js":"2.5.6","@types/lodash.isequal":"4.5.6","@vitest/coverage-c8":"0.32.0","chokidar-cli":"3.0.0",esbuild:"0.18.12",eslint:"8.9.0",typescript:"5.3.2",vitest:"1.6.0"},publishConfig:{directory:"dist"},filesize:{"dist/public-api.min.js":{gzip:"78 KB",none:"255 KB"}},source:"./src/index.ts"};function de(r,e,t){let i=r[B.Subreddit]?.values[0];g(i,"subreddit is missing from Context");let n=r[B.AppUser]?.values[0];g(n,"appAccountId is missing from Context");let o=r[B.User]?.values[0],a=B0(r);return{appAccountId:n,subredditId:i,userId:o,postId:e,commentId:t,debug:a,toJSON(){return{appAccountId:n,subredditId:i,userId:o,postId:e,commentId:t,debug:a}}}}function B0(r){let e={blocks:void 0,emitSnapshots:void 0,emitState:void 0,realtime:void 0,runtime:void 0,surface:void 0,useAsync:void 0},t={};for(let n in e)t[n.toLowerCase()]=n;let i={};for(let n of(r[B.Debug]?.values??[]).join().split(",")){let[o,a]=n.split("=");o&&(o=o.trim(),a=a?.trim(),o.toLowerCase()in t&&(o=t[o.toLowerCase()]),i[o]??(i[o]=a||`${!0}`))}return r[B.Debug]&&console.info(`[api] @devvit/public-api v${By.version} ${Object.entries(i).map(([n,o])=>`${n}=${o}`).join(" ")}`),{...i,metadata:r}}async function Fd(r,e,t){if(!e)throw new Error("Settings were not defined.");let i=D0.fromPartial({success:!0,errors:{}}),n=xt(r.fieldValues),o=e.flatMap(a=>a.type==="group"?a.fields:a);return await Promise.all(o.map(async a=>{let c=a.name;if(c&&a.type!=="group"&&a.onValidate){let p=n[c],f=a.onValidate,v=Object.assign(Ue({metadata:t}),de(t)),m=await f({value:p,isEditing:r.editing},v);m&&(i.success=!1,i.errors[c]=m)}})),i}async function q0(){if(!u.appSettings)throw new Error("App settings were not defined.");return N0.fromPartial({fields:{fields:dt(u.appSettings)}})}async function j0(r,e){return Fd(r,u.appSettings,e)}function Dy(r){r.provides(_0),L("GetAppSettingsFields",q0),L("ValidateAppForm",j0)}import{CustomPostDefinition as Z0}from"@devvit/protos";import{BlockRenderEventType as pm,EffectType as rb}from"@devvit/protos";var Md={width:288,height:320,scale:1,fontScale:1};function gi(r){return r.__effects}function _y(){let r=new Set;return e=>{let t=e,i=1;for(;r.has(t);)t=`${e}.${i++}`;return r.add(t),t}}import{BlockActionType as mm,BlockAnimationDirection as Ky,BlockAnimationLoopMode as Xy,BlockAnimationType as Zy,BlockAvatarBackground as Yy,BlockAvatarFacing as Qy,BlockAvatarSize as Tt,BlockBorderWidth as Bd,BlockButtonAppearance as Et,BlockButtonSize as nm,BlockFullSnooSize as hi,BlockGap as Dd,BlockHorizontalAlignment as sm,BlockIconSize as _d,BlockImageResizeMode as us,BlockPadding as cs,BlockRadius as ms,BlockSpacerShape as om,BlockSpacerSize as Nd,BlockStackDirection as am,BlockTextOutline as dm,BlockTextOverflow as lm,BlockTextSize as vi,BlockTextStyle as um,BlockTextWeight as eb,BlockType as Be,BlockVerticalAlignment as cm}from"@devvit/protos";var rm={transparent:"transparent",black:"#000000",white:"#ffffff","coolgray-950":"#04090A","coolgray-900":"#0B1416","coolgray-850":"#0F1A1C","coolgray-800":"#131F23","coolgray-750":"#1A282D","coolgray-700":"#223237","coolgray-650":"#2A3C42","coolgray-600":"#33464C","coolgray-550":"#4B6066","coolgray-525":"#576F76","coolgray-500":"#667A80","coolgray-450":"#82959B","coolgray-400":"#A0B0B5","coolgray-350":"#B8C5C9","coolgray-300":"#D2DADD","coolgray-250":"#DAE0E3","coolgray-200":"#E2E7E9","coolgray-150":"#EAEDEF","coolgray-100":"#F2F4F5","coolgray-50":"#F9FAFA","puregray-950":"#080808","puregray-900":"#131313","puregray-850":"#181818","puregray-800":"#1E1E1E","puregray-750":"#272727","puregray-700":"#303030","puregray-650":"#393939","puregray-600":"#434343","puregray-550":"#5C5C5C","puregray-500":"#767676","puregray-450":"#919191","puregray-400":"#ACACAC","puregray-350":"#C3C3C3","puregray-300":"#D6D6D6","puregray-250":"#DDDDDD","puregray-200":"#E4E4E4","puregray-150":"#EBEBEB","puregray-100":"#F2F2F2","puregray-50":"#F8F8F8","orangered-950":"#190600","orangered-900":"#340E00","orangered-800":"#4F1500","orangered-700":"#721F00","orangered-600":"#962900","orangered-500":"#D93A00","orangered-400":"#FE7C53","orangered-300":"#FFBEA6","orangered-200":"#FFD5C6","orangered-100":"#FFEDE5","orangered-50":"#FFF6F3","red-950":"#1C0004","red-900":"#3A0008","red-800":"#58000C","red-700":"#7E0011","red-600":"#A50016","red-500":"#EB001F","red-400":"#FF6E80","red-300":"#FFADB8","red-200":"#FFCCD2","red-100":"#FFEAED","red-50":"#FFF6F7","sakurapink-950":"#1A0011","sakurapink-900":"#360024","sakurapink-800":"#530037","sakurapink-700":"#770051","sakurapink-600":"#9B006A","sakurapink-500":"#E00096","sakurapink-400":"#FF55BD","sakurapink-300":"#FFA5E3","sakurapink-200":"#FFC5EC","sakurapink-100":"#FFE5F9","sakurapink-50":"#FFF3FB","berrypurple-950":"#16001F","berrypurple-900":"#2E0041","berrypurple-800":"#470062","berrypurple-700":"#66008C","berrypurple-600":"#8700B5","berrypurple-500":"#BC0EFF","berrypurple-400":"#D55EFF","berrypurple-300":"#EEA7FF","berrypurple-200":"#F2C8FF","berrypurple-100":"#FBE6FF","berrypurple-50":"#FCF4FF","periwinkle-950":"#0D0B1F","periwinkle-900":"#1A1741","periwinkle-800":"#272262","periwinkle-700":"#372F8C","periwinkle-600":"#453BB5","periwinkle-500":"#6A5CFF","periwinkle-400":"#988EFF","periwinkle-300":"#C3BDFF","periwinkle-200":"#D8D4FF","periwinkle-100":"#ECEAFF","periwinkle-50":"#F7F6FF","alienblue-950":"#000C1D","alienblue-900":"#00183D","alienblue-800":"#00255D","alienblue-700":"#003584","alienblue-600":"#0045AC","alienblue-500":"#1870F4","alienblue-400":"#629FFF","alienblue-300":"#A7CCFF","alienblue-200":"#C6DCFF","alienblue-100":"#E4EFFF","alienblue-50":"#F3F7FF","lightblue-950":"#000D12","lightblue-900":"#001C26","lightblue-800":"#002A3A","lightblue-700":"#003F56","lightblue-600":"#005472","lightblue-500":"#007FAE","lightblue-400":"#47B0DB","lightblue-300":"#95DCFB","lightblue-200":"#B6E9FF","lightblue-100":"#D9F6FF","lightblue-50":"#ECFAFF","mintgreen-950":"#00100E","mintgreen-900":"#001E1B","mintgreen-800":"#002E28","mintgreen-700":"#00443C","mintgreen-600":"#005A4F","mintgreen-500":"#008675","mintgreen-400":"#45B9AB","mintgreen-300":"#96E1D8","mintgreen-200":"#B7ECE5","mintgreen-100":"#DAF7F4","mintgreen-50":"#ECFBF9","kiwigreen-950":"#021000","kiwigreen-900":"#032200","kiwigreen-800":"#053200","kiwigreen-700":"#084A00","kiwigreen-600":"#0A6000","kiwigreen-500":"#0E8A00","kiwigreen-400":"#55BD46","kiwigreen-300":"#A3E398","kiwigreen-200":"#BFEEB8","kiwigreen-100":"#DFF8DB","kiwigreen-50":"#EEFCED","lime-950":"#0C0E00","lime-900":"#1A1F00","lime-800":"#282F00","lime-700":"#3A4501","lime-600":"#4D5A01","lime-500":"#6B7E01","lime-400":"#A1B33B","lime-300":"#CFDB83","lime-200":"#DFE8A6","lime-100":"#EFF4CC","lime-50":"#F7FAE5","yellow-950":"#100D01","yellow-900":"#251E02","yellow-800":"#382D03","yellow-700":"#504104","yellow-600":"#665505","yellow-500":"#8F7407","yellow-400":"#DBAF00","yellow-300":"#FADB61","yellow-200":"#FFE88F","yellow-100":"#FFF2BD","yellow-50":"#FFFAE5","yelloworange-950":"#150C00","yelloworange-900":"#2C1A00","yelloworange-800":"#432700","yelloworange-700":"#623A00","yelloworange-600":"#814C00","yelloworange-500":"#B06400","yelloworange-400":"#FF9C1A","yelloworange-300":"#FFCD7C","yelloworange-200":"#FFDDA8","yelloworange-100":"#FFF0D3","yelloworange-50":"#FFF7EA","poopbrown-950":"#110B04","poopbrown-900":"#29190A","poopbrown-800":"#3B2510","poopbrown-700":"#54371A","poopbrown-600":"#6E4924","poopbrown-500":"#9A6D3F","poopbrown-400":"#CAA075","poopbrown-300":"#EECCAA","poopbrown-200":"#F6DDC3","poopbrown-100":"#FEEEDD","poopbrown-50":"#FEF7EE",pizzaRed:{light:"#ef5350",dark:"#c62828"},"global-brand-orangered":{light:"#FF4500",dark:"#FF4500"},"global-focus":{light:"#47B0DB",dark:"#007FAE"},"interactive-content-disabled":{light:"#0000003f",dark:"#ffffff3f"},"interactive-background-disabled":{light:"#0000000c",dark:"#ffffff0c"},"interactive-pressed":{light:"#00000028",dark:"#ffffff28"},"neutral-content":{light:"#2A3C42",dark:"#B8C5C9"},"neutral-content-disabled":{light:"#D6D6D6",dark:"#303030"},"neutral-content-weak":{light:"#576F76",dark:"#82959B"},"neutral-content-strong":{light:"#0F1A1C",dark:"#F2F4F5"},"neutral-background":{light:"#ffffff",dark:"#0B1416"},"neutral-background-selected":{light:"#EAEDEF",dark:"#1A282D"},"neutral-background-weak":{light:"#F9FAFA",dark:"#04090A"},"neutral-background-medium":{light:"#F8F8F8",dark:"#131313"},"neutral-background-strong":{light:"#ffffff",dark:"#0F1A1C"},"neutral-background-hover":{light:"#F2F4F5",dark:"#131F23"},"neutral-border":{light:"#00000033",dark:"#ffffff33"},"neutral-border-medium":{light:"#0000007f",dark:"#ffffff7f"},"neutral-border-weak":{light:"#00000019",dark:"#ffffff19"},"neutral-border-strong":{light:"#0F1A1C",dark:"#F2F4F5"},primary:{light:"#0045AC",dark:"#629FFF"},"primary-hover":{light:"#003584",dark:"#A7CCFF"},"primary-visited":{light:"#8700B5",dark:"#D55EFF"},"primary-onBackground":{light:"#ffffff",dark:"#ffffff"},"primary-onBackground-selected":{light:"#ffffff",dark:"#000000"},"primary-background":{light:"#0045AC",dark:"#0045AC"},"primary-background-hover":{light:"#003584",dark:"#1870F4"},"primary-background-selected":{light:"#00255D",dark:"#629FFF"},secondary:{light:"#0F1A1C",dark:"#F2F4F5"},"secondary-hover":{light:"#000000",dark:"#ffffff"},"secondary-weak":{light:"#576F76",dark:"#82959B"},"secondary-onBackground":{light:"#000000",dark:"#ffffff"},"secondary-background":{light:"#EAEDEF",dark:"#1A282D"},"secondary-background-hover":{light:"#E2E7E9",dark:"#223237"},"secondary-background-selected":{light:"#D2DADD",dark:"#33464C"},"secondary-plain":{light:"#0F1A1C",dark:"#F2F4F5"},"secondary-plain-hover":{light:"#000000",dark:"#ffffff"},"danger-background":{light:"#EB001F",dark:"#A50016"},"danger-background-disabled":{light:"#FFCCD2",dark:"#3A0008"},"danger-background-hover":{light:"#A50016",dark:"#EB001F"},"danger-onBackground":{light:"#ffffff",dark:"#ffffff"},"danger-content":{light:"#A50016",dark:"#FF6E80"},"danger-content-hover":{light:"#7E0011",dark:"#FFADB8"},"danger-content-default":{light:"#ffffff",dark:"#ffffff"},"brand-background":{light:"#D93A00",dark:"#D93A00"},"brand-onBackground":{light:"#ffffff",dark:"#ffffff"},"brand-background-hover":{light:"#962900",dark:"#962900"},"media-background":{light:"#00000099",dark:"#00000099"},"media-onbackground":{light:"#ffffff",dark:"#ffffff"},"media-onbackground-weak":{light:"#E2E7E9",dark:"#E2E7E9"},"media-background-hover":{light:"#000000cc",dark:"#000000cc"},"media-onbackground-disabled":{light:"#ffffff3f",dark:"#ffffff3f"},"media-border-selected":{light:"#ffffff",dark:"#ffffff"},"media-background-selected":{light:"#000000cc",dark:"#000000cc"},"success-content":{light:"#0A6000",dark:"#55BD46"},"success-hover":{light:"#084A00",dark:"#A3E398"},"success-onBackground":{light:"#ffffff",dark:"#ffffff"},"success-background":{light:"#0E8A00",dark:"#0A6000"},"success-background-hover":{light:"#0A6000",dark:"#0E8A00"},"warning-content":{light:"#665505",dark:"#DBAF00"},"warning-content-hover":{light:"#504104",dark:"#FADB61"},"warning-onBackground":{light:"#000000",dark:"#000000"},"warning-background":{light:"#DBAF00",dark:"#DBAF00"},"warning-background-hover":{light:"#8F7407",dark:"#FADB61"},"upvote-content":{light:"#962900",dark:"#FE7C53"},"upvote-content-weak":{light:"#FF4500",dark:"#FF4500"},"upvote-disabled":{light:"#9629004c",dark:"#FE7C534c"},"upvote-onBackground":{light:"#ffffff",dark:"#ffffff"},"upvote-background":{light:"#D93A00",dark:"#D93A00"},"upvote-background-hover":{light:"#962900",dark:"#962900"},"upvote-background-disabled":{light:"#D93A004c",dark:"#D93A004c"},"downvote-content":{light:"#453BB5",dark:"#988EFF"},"downvote-content-weak":{light:"#6A5CFF",dark:"#6A5CFF"},"downvote-disabled":{light:"#453BB54c",dark:"#988EFF4c"},"downvote-onBackground":{light:"#ffffff",dark:"#ffffff"},"downvote-background":{light:"#6A5CFF",dark:"#453BB5"},"downvote-background-hover":{light:"#453BB5",dark:"#453BB5"},"downvote-background-disabled":{light:"#6A5CFF4c",dark:"#6A5CFF4c"},"brand-gradient-default":{light:"",dark:""},"brand-gradient-default-highlight":{light:"",dark:""},"brand-gradient-hover":{light:"",dark:""},"brand-gradient-hover-highlight":{light:"",dark:""},"brand-gradient-active":{light:"",dark:""},"brand-gradient-active-highlight":{light:"",dark:""},"gradient-media":{light:"",dark:""},"gradient-media-strong":{light:"",dark:""},"transparent-background-hover":{light:"#82959B19",dark:"#667A8019"},"global-black":{light:"#000000",dark:"#000000"},"global-white":{light:"#ffffff",dark:"#ffffff"},"global-orangered":{light:"#D93A00",dark:"#D93A00"},"global-alienblue":{light:"#1870F4",dark:"#1870F4"},"global-darkblue":{light:"#131F23",dark:"#131F23"},"tone-1":{light:"#131313",dark:"#F2F2F2"},"tone-2":{light:"#434343",dark:"#ACACAC"},"tone-3":{light:"#ACACAC",dark:"#434343"},"tone-4":{light:"#E4E4E4",dark:"#303030"},"tone-5":{light:"#F2F2F2",dark:"#1E1E1E"},"tone-6":{light:"#F8F8F8",dark:"#131313"},"tone-7":{light:"#ffffff",dark:"#080808"},"action-upvote":{light:"#D93A00",dark:"#D93A00"},"action-downvote":{light:"#6A5CFF",dark:"#6A5CFF"},"alert-caution":{light:"#8F7407",dark:"#8F7407"},"identity-admin":{light:"#D93A00",dark:"#D93A00"},"identity-moderator":{light:"#0E8A00",dark:"#0E8A00"},"identity-self":{light:"#008675",dark:"#008675"},"identity-coins":{light:"#DBAF00",dark:"#DBAF00"},"category-live":{light:"#D93A00",dark:"#D93A00"},"category-nsfw":{light:"#E00096",dark:"#E00096"},"category-spoiler":{light:"#131313",dark:"#F2F2F2"},"ui-canvas":{light:"#F2F2F2",dark:"#080808"},"ui-modalbackground":{light:"#ffffff",dark:"#0F1A1C"},"avatar-gradient":{light:"",dark:""},"opacity-highlight":{light:"",dark:""},"opacity-08":{light:"#13131314",dark:"#13131314"},"opacity-50":{light:"#0000007f",dark:"#F2F2F27f"},scrim:{light:"#00000099",dark:"#00000099"},"scrim-strong":{light:"#000000cc",dark:"#000000cc"},"scrim-gradient":{light:"",dark:""},online:{light:"#55BD46",dark:"#55BD46"},favorite:{light:"#8F7407",dark:"#DBAF00"}};var Ny={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",transparent:"#FFFFFF00",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},qy=r=>!!r.match(/^(#[0-9a-fA-F]{3,8}).*/),jy=r=>r in rm,im=r=>r in Ny,Hy=r=>!!r.match(/^rgba?\(.*/),Wy=r=>!!r.match(/^hsla?\(.*/),Gy=(r,e="light")=>{if(im(r))return Ld(r);let i=rm[r];return typeof i=="string"?i:i[e]},Ld=r=>Ny[r]??r,Vy=r=>{let[e,t,i,n]=r.replace(/^rgba?\(|\s+|\)$/g,"").split(",");if(!e||!t||!i)return r;let a=[...[e,t,i].map(p=>parseFloat(p))];if(n){let p=parseFloat(n),f=Math.round(p*255);a.push(f)}return`#${a.map(p=>p.toString(16).padStart(2,"0")).join("")}`};import{BlockSizeUnit as H0,BlockStackDirection as zy}from"@devvit/protos";var W0=/^(\d+(?:\.\d+)?)(px|%)?$/,pr=(r,e)=>{if(r==null)return;let t=Ud(r,e);return t!=null?{value:t,unit:H0.SIZE_UNIT_PIXELS}:void 0},$y=(r,e,t,i)=>{if(!r)return e;let n=G0(r.padding,e.fontScale)*2,o=z0(r.border,r.borderColor)*2,a=V0(r.gap),c=e.height;(r.height!=null||r.minHeight!=null||r.maxHeight!=null)&&(c=Jy(r.height,r.minHeight,r.maxHeight,e.height));let f=n+o;t===zy.STACK_VERTICAL&&a&&i>0&&(f=f+a*(i-1));let v=e.width;(r.width!=null||r.minWidth!=null||r.maxWidth!=null)&&(v=Jy(r.width,r.minWidth,r.maxWidth,e.width));let k=n+o;return t===zy.STACK_HORIZONTAL&&a&&i>0&&(k=k+a*(i-1)),{...e,height:c-f,width:v-k}},Ud=(r,e)=>{if(r!=null){if(typeof r=="number")return e*r/100;{let t=r.match(W0);if(t==null)return;let i=Number.parseFloat(t[1]);return t?.at(2)==="%"?e*i/100:i}}},G0=(r,e=1)=>{switch(r){case"xsmall":return 4*e;case"small":return 8*e;case"medium":return 16*e;case"large":return 32*e;default:return 0}},V0=r=>{switch(r){case"small":return 8;case"medium":return 16;case"large":return 32}return 0},z0=(r,e)=>{if(!r&&!e)return 0;switch(r){case"none":return 0;case"thin":return 1;case"thick":return 2;default:return 1}},Jy=(r,e,t,i)=>{let n=Ud(r,i)||0,o=Ud(e,i)||0,a=Ud(t,i)||0,c=Math.min(a,n),p=Math.max(o,n);return Math.max(c,p)};var tb="data-",J0=new Set(["onPress","onMessage"]),$0=new Map([["onPress",mm.ACTION_CLICK],["onMessage",mm.ACTION_WEBVIEW]]),ps,yi=class{constructor(e=()=>{}){d(this,ps,void 0);l(this,ps,e)}createBlocksElementOrThrow({type:e,props:t,children:i},n){let o=this.createBlocksElement({type:e,props:t,children:i},n);if(!o)throw new Error(`Could not create block of type ${e}`);return o}createBlocksElement({type:e,props:t,children:i},n){switch(e){case"blocks":return this.makeRoot(t,n,...i);case"hstack":return this.makeHStack(t,n,...i);case"vstack":return this.makeVStack(t,n,...i);case"zstack":return this.makeZStack(t,n,...i);case"text":return this.makeText(t,n,...i);case"button":return this.makeButton(t,n,...i);case"image":return this.makeImage(t,n);case"spacer":return this.makeSpacer(t,n);case"icon":return this.makeIcon(t,n);case"avatar":return this.makeAvatar(t,n);case"fullsnoo":return this.makeFullSnoo(t,n);case"animation":return this.makeAnimation(t,n);case"webview":return this.makeWebView(t,n);case"__fragment":throw new Error("root fragment is not supported - use 'blocks' instead")}}makeRootHeight(e){switch(e){case"regular":return 320;case"tall":return 512}}makeBlockPadding(e){switch(e){case"none":return cs.PADDING_NONE;case"xsmall":return cs.PADDING_XSMALL;case"small":return cs.PADDING_SMALL;case"medium":return cs.PADDING_MEDIUM;case"large":return cs.PADDING_LARGE}}makeBlockRadius(e){switch(e){case"none":return ms.RADIUS_NONE;case"small":return ms.RADIUS_SMALL;case"medium":return ms.RADIUS_MEDIUM;case"large":return ms.RADIUS_LARGE;case"full":return ms.RADIUS_FULL}}makeBlockGap(e){switch(e){case"none":return Dd.GAP_NONE;case"small":return Dd.GAP_SMALL;case"medium":return Dd.GAP_MEDIUM;case"large":return Dd.GAP_LARGE}}makeBlockAlignment(e){if(e===void 0)return;let t,i;if(e.includes("top")?t=cm.ALIGN_TOP:e.includes("middle")?t=cm.ALIGN_MIDDLE:e.includes("bottom")&&(t=cm.ALIGN_BOTTOM),e.includes("start")?i=sm.ALIGN_START:e.includes("center")?i=sm.ALIGN_CENTER:e.includes("end")&&(i=sm.ALIGN_END),t!==void 0||i!==void 0)return{vertical:t,horizontal:i}}makeBlockBorder(e,t,i,n){if(!e&&!t)return;let o;switch(e){case"none":o=Bd.BORDER_WIDTH_NONE;break;case"thin":o=Bd.BORDER_WIDTH_THIN;break;case"thick":o=Bd.BORDER_WIDTH_THICK;break;default:o=Bd.BORDER_WIDTH_THIN;break}let a=t??"neutral-border-weak",c=this.getThemedColors(a,i,n);return{width:o,color:c?.light,colors:c}}makeBlockTextSize(e){switch(e){case"xsmall":return vi.TEXT_SIZE_XSMALL;case"small":return vi.TEXT_SIZE_SMALL;case"medium":return vi.TEXT_SIZE_MEDIUM;case"large":return vi.TEXT_SIZE_LARGE;case"xlarge":return vi.TEXT_SIZE_XLARGE;case"xxlarge":return vi.TEXT_SIZE_XXLARGE}}makeBlockTextStyle(e){switch(e){case"body":return um.TEXT_STYLE_BODY;case"metadata":return um.TEXT_STYLE_METADATA;case"heading":return um.TEXT_STYLE_HEADING}}makeBlockTextOutline(e){switch(e){case"none":return dm.TEXT_OUTLINE_NONE;case"thin":return dm.TEXT_OUTLINE_THIN;case"thick":return dm.TEXT_OUTLINE_THICK}}makeBlockTextWeight(e){switch(e){case"regular":return eb.TEXT_WEIGHT_REGULAR;case"bold":return eb.TEXT_WEIGHT_BOLD}}makeBlockTextOverflow(e){switch(e){case"clip":return lm.TEXT_OVERFLOW_CLIP;case"ellipsis":return lm.TEXT_OVERFLOW_ELLIPSE}return lm.TEXT_OVERFLOW_ELLIPSE}makeBlockButtonAppearance(e){switch(e){case"secondary":return Et.BUTTON_APPEARANCE_SECONDARY;case"primary":return Et.BUTTON_APPEARANCE_PRIMARY;case"plain":return Et.BUTTON_APPEARANCE_PLAIN;case"bordered":return Et.BUTTON_APPEARANCE_BORDERED;case"media":return Et.BUTTON_APPEARANCE_MEDIA;case"destructive":return Et.BUTTON_APPEARANCE_DESTRUCTIVE;case"caution":return Et.BUTTON_APPEARANCE_CAUTION;case"success":return Et.BUTTON_APPEARANCE_SUCCESS}}makeBlockButtonSize(e){switch(e){case"small":return nm.BUTTON_SIZE_SMALL;case"medium":return nm.BUTTON_SIZE_MEDIUM;case"large":return nm.BUTTON_SIZE_LARGE}}makeBlockImageResizeMode(e){switch(e){case"none":return us.IMAGE_RESIZE_NONE;case"fit":return us.IMAGE_RESIZE_FIT;case"fill":return us.IMAGE_RESIZE_FILL;case"cover":return us.IMAGE_RESIZE_COVER;case"scale-down":return us.IMAGE_RESIZE_SCALE_DOWN}}makeBlockSpacerSize(e){switch(e){case"xsmall":return Nd.SPACER_XSMALL;case"small":return Nd.SPACER_SMALL;case"medium":return Nd.SPACER_MEDIUM;case"large":return Nd.SPACER_LARGE}}makeBlockSpacerShape(e){switch(e){case"invisible":return om.SPACER_INVISIBLE;case"thin":return om.SPACER_THIN;case"square":return om.SPACER_SQUARE}}makeBlockIconSize(e){switch(e){case"xsmall":return _d.ICON_SIZE_XSMALL;case"small":return _d.ICON_SIZE_SMALL;case"medium":return _d.ICON_SIZE_MEDIUM;case"large":return _d.ICON_SIZE_LARGE}}makeBlockAvatarSize(e){switch(e){case"xxsmall":return Tt.AVATAR_SIZE_XXSMALL;case"xsmall":return Tt.AVATAR_SIZE_XSMALL;case"small":return Tt.AVATAR_SIZE_SMALL;case"medium":return Tt.AVATAR_SIZE_MEDIUM;case"large":return Tt.AVATAR_SIZE_LARGE;case"xlarge":return Tt.AVATAR_SIZE_XXLARGE;case"xxlarge":return Tt.AVATAR_SIZE_XXLARGE;case"xxxlarge":return Tt.AVATAR_SIZE_XXXLARGE}}makeBlockAvatarFacing(e){switch(e){case"left":return Qy.AVATAR_FACING_LEFT;case"right":return Qy.AVATAR_FACING_RIGHT}}makeBlockFullSnooSize(e){switch(e){case"xsmall":return hi.FULLSNOO_XSMALL;case"small":return hi.FULLSNOO_SMALL;case"medium":return hi.FULLSNOO_MEDIUM;case"large":return hi.FULLSNOO_LARGE;case"xlarge":return hi.FULLSNOO_XLARGE;case"xxlarge":return hi.FULLSNOO_XXLARGE}}makeBlockAvatarBackground(e){switch(e){case"dark":return Yy.AVATAR_BG_DARK;case"light":return Yy.AVATAR_BG_LIGHT}}makeBlockAnimationType(e){return e==="lottie"||e===void 0?Zy.ANIM_LOTTIE:Zy.UNRECOGNIZED}makeBlockAnimationDirection(e){switch(e){case"backward":return Ky.ANIM_DIR_BACKWARD;case"forward":return Ky.ANIM_DIR_FORWARD}}makeBlockLoopMode(e){switch(e){case"repeat":return Xy.ANIM_LOOP_REPEAT;case"bounce":return Xy.ANIM_LOOP_BOUNCE}}makeBlockSizes(e,t){if(e){let i=e.width!=null||e.minWidth!=null||e.maxWidth!=null,n=e.height!=null||e.minHeight!=null||e.maxHeight!=null;if(i||n||e.grow!=null)return{width:i?{value:pr(e.width,t.width),min:pr(e.minWidth,t.width),max:pr(e.maxWidth,t.width)}:void 0,height:n?{value:pr(e.height,t.height),min:pr(e.minHeight,t.height),max:pr(e.maxHeight,t.height)}:void 0,grow:e.grow}}}getDataSet(e){return Object.keys(e).filter(t=>t.startsWith(tb)).reduce((t,i)=>(t[i.substring(tb.length)]=e[i],t),{})}makeActions(e,t){let i=[],n=this.getDataSet(t);return J0.forEach(o=>{if(o in t){let a=t[o];i.push({type:$0.get(o)??mm.UNRECOGNIZED,id:a.toString(),data:n})}}),i}blockColorToHex(e,t="light"){if(e)return e=e.toLowerCase(),qy(e)?e:jy(e)?Gy(e,t):im(e)?Ld(e):Hy(e)?Vy(e):Wy(e)?e:(console.warn(`Could not parse color: ${e}.`),Ld("red"))}childrenToBlocks(e,t){return e.flatMap(i=>(typeof i!="string"?this.createBlocksElement(i,t):void 0)??[])}getThemedColors(e,t,i){let n=this.blockColorToHex(t,"light"),o=this.blockColorToHex(i,"dark"),a=[];if(e&&(!n||!o)){let c=Array.from(e?.matchAll(/[\w#-]+(?:\([\w\t ,.#-]+\))?/g)??[]);a.push(...c.map(p=>p[0]))}return n||(n=this.blockColorToHex(a?.at(0),"light")),o||(o=this.blockColorToHex(a?.at(1)??a?.at(0),"dark")),n||o?{light:n,dark:o}:void 0}parsePixels(e){return typeof e=="string"?Number(e.slice(0,-2)):e}resolveAssetUrl(e,t){return s(this,ps).call(this)?.getURL(e,t)??e}childrenToString(e){return e.map(t=>t.toString()).join("")}makeRoot(e,t,...i){return this.wrapRoot(e,t,this.childrenToBlocks(i,t))}wrapRoot(e,t,i){return this.makeBlock(Be.BLOCK_ROOT,{},t,{rootConfig:{children:i,height:this.makeRootHeight(u.customPostType?.height??e?.height??"regular")}})}makeStackBlock(e,t,i,n){let o=this.getThemedColors(t?.backgroundColor,t?.lightBackgroundColor,t?.darkBackgroundColor),a=$y(t,i.maxDimensions,e,n.length);return this.makeBlock(Be.BLOCK_STACK,t,i,{stackConfig:{alignment:this.makeBlockAlignment(t?.alignment),backgroundColor:o?.light,backgroundColors:o,border:this.makeBlockBorder(t?.border,t?.borderColor,t?.lightBorderColor,t?.darkBorderColor),children:this.childrenToBlocks(n,{...i,maxDimensions:a}),cornerRadius:this.makeBlockRadius(t?.cornerRadius),direction:e,gap:this.makeBlockGap(t?.gap),padding:this.makeBlockPadding(t?.padding),reverse:t?.reverse}})}makeHStack(e,t,...i){return this.makeStackBlock(am.STACK_HORIZONTAL,e,t,i)}makeVStack(e,t,...i){return this.makeStackBlock(am.STACK_VERTICAL,e,t,i)}makeZStack(e,t,...i){return this.makeStackBlock(am.STACK_DEPTH,e,t,i)}makeText(e,t,...i){let n=this.getThemedColors(e?.color,e?.lightColor,e?.darkColor);return this.makeBlock(Be.BLOCK_TEXT,e,t,{textConfig:{alignment:this.makeBlockAlignment(e?.alignment),color:n?.light,colors:n,outline:this.makeBlockTextOutline(e?.outline),size:this.makeBlockTextSize(e?.size),style:this.makeBlockTextStyle(e?.style),text:this.childrenToString(i),weight:this.makeBlockTextWeight(e?.weight),selectable:e?.selectable,wrap:e?.wrap,overflow:this.makeBlockTextOverflow(e?.overflow)}})}makeButton(e,t,...i){let n=this.getThemedColors(e?.textColor,e?.lightTextColor,e?.darkTextColor);return this.makeBlock(Be.BLOCK_BUTTON,e,t,{buttonConfig:{buttonAppearance:this.makeBlockButtonAppearance(e?.appearance),icon:e?.icon,buttonSize:this.makeBlockButtonSize(e?.size),text:this.childrenToString(i),textColor:n?.light,textColors:n,disabled:e?.disabled}})}makeImage(e,t){return e&&this.makeBlock(Be.BLOCK_IMAGE,e,t,{imageConfig:{description:e?.description,resizeMode:this.makeBlockImageResizeMode(e.resizeMode),url:this.resolveAssetUrl(e.url),width:this.parsePixels(e.imageWidth),height:this.parsePixels(e.imageHeight)}})}makeSpacer(e,t){return this.makeBlock(Be.BLOCK_SPACER,e,t,{spacerConfig:{size:this.makeBlockSpacerSize(e?.size),shape:this.makeBlockSpacerShape(e?.shape)}})}makeIcon(e,t){let i=this.getThemedColors(e?.color,e?.lightColor,e?.darkColor);return e&&this.makeBlock(Be.BLOCK_ICON,e,t,{iconConfig:{icon:e.name,color:i?.light,colors:i,size:this.makeBlockIconSize(e.size)}})}makeAvatar(e,t){return e&&this.makeBlock(Be.BLOCK_AVATAR,e,t,{avatarConfig:{thingId:e.thingId,size:this.makeBlockAvatarSize(e.size),facing:this.makeBlockAvatarFacing(e.facing),background:this.makeBlockAvatarBackground(e.background)}})}makeFullSnoo(e,t){return e&&this.makeBlock(Be.BLOCK_FULLSNOO,e,t,{fullsnooConfig:{userId:e.userId,facing:this.makeBlockAvatarFacing(e.facing),size:this.makeBlockFullSnooSize(e.size)}})}makeAnimation(e,t){return e&&this.makeBlock(Be.BLOCK_ANIMATION,e,t,{animationConfig:{type:this.makeBlockAnimationType(e.type),url:this.resolveAssetUrl(e.url),loop:e.loop,loopMode:this.makeBlockLoopMode(e.loopMode),autoplay:e.autoplay,width:this.parsePixels(e.imageWidth),height:this.parsePixels(e.imageHeight),direction:this.makeBlockAnimationDirection(e.direction),speed:e.speed}})}makeWebView(e,t){return e&&this.makeBlock(Be.BLOCK_WEBVIEW,e,t,{webviewConfig:{url:this.resolveAssetUrl(e.url,{webview:!0}),state:e.state}})}makeBlock(e,t,i,n){return{type:e,sizes:this.makeBlockSizes(t,i.maxDimensions),config:n,actions:(t&&this.makeActions(e,t))??[],id:t?.id,key:t?.key}}ensureRootBlock(e,t){let i=e;if(i.type===Be.BLOCK_ROOT)return i.config?.rootConfig&&u.customPostType?.height&&(i.config.rootConfig.height=this.makeRootHeight(u.customPostType?.height)),i;let n=this.wrapRoot(void 0,t,[i]);if(!n)throw new Error("Could not create root block");return n}};ps=new WeakMap;function ib(r){if(typeof r=="string")throw new Error("Root element cannot be a string")}var nb=r=>{let e="",t=r.props?Object.keys(r.props).map(i=>i==="onPress"?"":`${i}="${r.props[i]}"`).join(" "):"";e+=`<${r.type}${t?" "+t:""}>`;for(let i of r.children)typeof i=="string"?e+=i:e+=nb(i);return e+=`</${r.type}>`,e};function K0(r){return" ".repeat(r)}function X0(r){let e="",t=0,i=r.split(/>\s*</);for(let n=0;n<i.length;n++){let o=i[n];n===0&&(o=o.trim()),n===i.length-1&&(o=o.trim());let a=o.charAt(0)==="/";a&&t--,e+=K0(t),n!==0&&(e+="<"),e+=o,n!==i.length-1&&(e+=`>
2
- `),!a&&o.indexOf("</")===-1&&o.charAt(o.length-1)!=="/"&&t++}return e}var qd,sb,fr,fs,gs,fm,hs,lt=class{constructor(e,t,i,n,o){d(this,qd);d(this,fr);d(this,gs);this.renderState={};this.currentComponentKey=[];this.currentHookIndex=0;this.actions=new Map;this.forms=new Map;this.realtimeChannels=[];this.realtimeUpdated=!1;this.pendingHooks=[];this.isRendering=!1;this.transformer=new yi(()=>this.assets);this.effects=[];d(this,hs,!1);this.component=e,this.event=t,this.state={__renderState:{},...i},this.metadata=n,this.state.__realtimeChannels&&(this.realtimeChannels=this.state.__realtimeChannels);let a=Ue({reconciler:this,hooks:!0,ui:!0,metadata:n});this.cache=a.cache,this.modLog=a.modLog,this.reddit=a.reddit,this.kvStore=a.kvStore,this.redis=a.redis,this.settings=a.settings,this.scheduler=a.scheduler,this.media=a.media,this.assets=a.assets,this.realtime=a.realtime,this.dimensions=o,this.ui=a.ui,this.hooks={useState:a.useState,useInterval:a.useInterval,useForm:a.useForm,useChannel:a.useChannel}}emitEffect(e,t){this.effects.push(t)}async render(){await this.reconcile(),this.isRendering=!0;let e=await this.buildBlocksUI();return this.isRendering=!1,e}makeUniqueActionID(e){let t=e,i=1;for(;this.actions.has(t);)t=`${e}.${i++}`;return t}makeTransformContext(e){return{maxDimensions:e.dimensions??Md}}async reconcile(){let e=y(this,fr,fs).call(this),t={type:this.component,props:e,children:[]},i=await this.processBlock(t);ib(i);let n=this.makeTransformContext(e);if(this.transformer.createBlocksElementOrThrow(i,n),this.isUserActionRender&&this.blockRenderEventId){let o=this.actions.get(this.blockRenderEventId);o&&await o(this.event.data)}for(let o of this.pendingHooks)await o();this.buildNextState(),y(this,qd,sb).call(this)}async buildBlocksUI(){let e=y(this,fr,fs).call(this),t={type:this.component,props:e,children:[]},i=await this.renderElement(e,t),n=this.makeTransformContext(e);return this.transformer.ensureRootBlock(i,n)}async renderElement(e,t){let i=await this.processBlock(t);ib(i),(u.debug.emitSnapshots||e.debug.emitSnapshots)&&console.debug(X0(nb(i))),(u.debug.emitState||e.debug.emitState)&&console.debug(JSON.stringify(this.state,void 0,2));let n=this.makeTransformContext(e);return this.transformer.createBlocksElementOrThrow(i,n)}async processProps(e){let t=e.props??{},i=["onPress","onMessage"];for(let n of i)if(n in t){let o=t[n],a=o?.name,c=this.makeUniqueActionID(`${e.type}.${a??n}`);this.actions.set(c,o),t[n]=c}}async processBlock(e,t=_y(),i=[]){let n=e;if(typeof n.type=="string"){let c=[];for(let m=0;m<n.children.length;m++){let k=n.children[m];k!=null&&c.push(await this.processBlock(k,t,[...i,`${n.type}.${m}`]))}let p=c.flat(),f=y(this,gs,fm).call(this,p);return await this.processProps(n),{type:n.type,props:n.props,children:f}}if(typeof n.type=="function"){let c=t(`${i.length?i.join("."):"root"}.${n.type.name.length?n.type.name:"anonymous"}`);this.currentComponentKey.push(c),this.renderState[c]||(this.renderState[c]={});let p=n.children.flatMap(m=>m),f={...y(this,fr,fs).call(this),...n.props,children:p},v;for(;v===void 0;)try{v=await n.type(f,y(this,fr,fs).call(this))}catch(m){if(m instanceof Promise)v=await m;else throw m}if(!this.isInitialRender){let m=this.getPreviousComponentState();if(Object.keys(m).length!==this.currentHookIndex)throw new Error("Invalid hook call. Hooks can only be called at the top-level of a function component. Make sure that you are not calling hooks inside loops, conditions, or nested functions.")}if(this.currentComponentKey.pop(),this.currentHookIndex=0,typeof v=="object")return this.processBlock(v,t,[...i,n.type.name])}if(typeof n=="string")return n;if(typeof n=="number")return`${n}`;let o=[],a="";return Array.isArray(n)?o=n:typeof n.type>"u"&&n.children&&(o=n.children,a="fragmentChild."),{type:"__fragment",props:void 0,children:await Promise.all(o.flatMap(async(c,p)=>await this.processBlock(c,t,[...i,`${a}${p}`])))}}getCurrentComponentKey(){if(!this.currentComponentKey.at(-1))throw new Error("Current component key is missing");return this.currentComponentKey}getCurrentComponentState(){let e=this.currentComponentKey.at(-1);if(!e)throw new Error("Current component key is missing");return this.renderState[e]}getPreviousComponentState(){let e=this.currentComponentKey.at(-1);if(!e)throw new Error("Current component key is missing");return this.state.__renderState[e]||(this.state.__renderState[e]={}),this.state.__renderState[e]}get isInitialRender(){return this.event?this.event.type===pm.RENDER_INITIAL:!1}get isUserActionRender(){return this.event?this.event.type===pm.RENDER_USER_ACTION:!1}get isEffectRender(){return this.event?this.event.type===pm.RENDER_EFFECT_EVENT:!1}get formSubmittedEvent(){return this.event?this.event.formSubmitted:!1}get blockRenderEventId(){return this.event?this.event.id:!1}get realtimeEvent(){if(!this.event)return!1;let e=this.event.realtimeEvent;return e?.event?.channel?e:!1}runHook(e){this.pendingHooks.push(e)}rerenderIn(e){s(this,hs)||(l(this,hs,!0),this.effects.push({type:rb.EFFECT_RERENDER_UI,rerenderUi:{delaySeconds:e/1e3}}))}addRealtimeChannel(e){this.realtimeChannels.push(e),this.realtimeUpdated=!0}removeRealtimeChannel(e){this.realtimeChannels=this.realtimeChannels.filter(t=>t!==e),this.realtimeUpdated=!0}get realtimeEffect(){return this.realtimeUpdated&&this.realtimeChannels.length>0?[{type:rb.EFFECT_REALTIME_SUB,realtimeSubscriptions:{subscriptionIds:this.realtimeChannels}}]:[]}getEffects(){return[...gi(this.ui),...this.effects,...this.realtimeEffect]}buildNextState(){for(let e of Object.keys(this.renderState))this.renderState[e]=Object.values(this.renderState[e]);this.state={__postData:this.state.__postData,__renderState:this.renderState,__cache:this.state.__cache,...this.realtimeChannels.length>0?{__realtimeChannels:this.realtimeChannels}:{}}}};qd=new WeakSet,sb=function(){this.actions.clear(),this.currentComponentKey=[],this.currentHookIndex=0,this.pendingHooks=[],this.realtimeChannels=[],this.realtimeUpdated=!1},fr=new WeakSet,fs=function(){let e={...de(this.metadata,this.state.__postData?.thingId),modLog:this.modLog,reddit:this.reddit,cache:this.cache,kvStore:this.kvStore,redis:this.redis,settings:this.settings,scheduler:this.scheduler,media:this.media,assets:this.assets,realtime:this.realtime,ui:this.ui,dimensions:this.dimensions,uiEnvironment:{timezone:this.metadata[B.Timezone]?.values[0],locale:this.metadata[B.Language]?.values[0],dimensions:this.dimensions},...this.hooks};return e.debug.effects=this,e},gs=new WeakSet,fm=function(e){let t=[];for(let i of e)typeof i=="string"?t.push(i):i.type==="__fragment"?t.push(...y(this,gs,fm).call(this,i.children)):t.push(i);return t},hs=new WeakMap;async function Y0(r,e){let t=u.customPostType;if(!t)throw new Error("Custom post type not registered");let i=new lt((o,a)=>t.render(a),r.blocks,r.state,e,r.dimensions),n=await i.render();return{state:i.state,blocks:{ui:n},effects:i.getEffects()}}function ob(r){r.provides(Z0),L("RenderPost",Y0)}import{GetFieldsResponse as Q0,InstallationSettingsDefinition as eE}from"@devvit/protos";async function tE(){if(!u.installationSettings)throw new Error("Installation settings were not defined.");return Q0.fromPartial({fields:{fields:dt(u.installationSettings)}})}async function rE(r,e){return Fd(r,u.installationSettings,e)}function ab(r){r.provides(eE),L("GetSettingsFields",tE),L("ValidateForm",rE)}import{ContextActionDefinition as iE,ContextActionDescription as nE,ContextActionResponse as sE}from"@devvit/protos";var db=r=>`menuItem.${r}`;function gm(r){return u.menuItems.find((e,t)=>db(t)===r)}async function oE(r,e){let t=u.menuItems;if(!t.length)throw new Error("No menu items registered.");return{actions:t.map((n,o)=>nE.fromPartial({actionId:db(o),name:n.label,description:n.description,contexts:{subreddit:n.location.includes("subreddit"),post:n.location.includes("post"),comment:n.location.includes("comment")},users:{loggedOut:n.forUserType?.includes("loggedOut"),member:n.forUserType?.includes("member"),moderator:n.forUserType?.includes("moderator")},postFilters:n.postFilter==="currentApp"?{currentApp:!0}:void 0}))}}async function aE(r,e){let t=gm(r.actionId);if(!t)throw new Error(`MenuItem ${r.actionId} not found`);let i=r.comment?.id&&`t1_${r.comment.id}`,n=r.post?.id&&`t3_${r.post.id}`,o=r.subreddit?.id&&`t5_${r.subreddit.id}`,a=i||n||o;g(a,"targetId is missing from ContextActionRequest");let c={targetId:a,location:r.comment?"comment":r.post?"post":"subreddit"},p=Object.assign(Ue({ui:!0,metadata:e}),de(e,n,i),{uiEnvironment:{timezone:e[B.Timezone]?.values[0],locale:e[B.Language]?.values[0]}});return await t.onPress(c,p),sE.fromPartial({effects:gi(p.ui)})}function lb(r){r.provides(iE),L("GetActions",oE),L("OnAction",aE)}function ut(r){return r?r===!0?!0:r.enabled:!1}import{SchedulerHandlerDefinition as dE}from"@devvit/protos";async function lE(r,e){let t=r.type,i=u.scheduledJobHandlers.get(t);if(!i)throw new Error(`Job ${t} not found`);let n={name:t,data:r.data},o=Object.assign(Ue({metadata:e}),de(e));await i(n,o)}function ub(r){r.provides(dE),L("HandleScheduledAction",lE)}import{HandlerResult as uE,OnAppInstallDefinition as cE,OnAppUpgradeDefinition as mE,OnCommentCreateDefinition as pE,OnCommentDeleteDefinition as fE,OnCommentReportDefinition as gE,OnCommentSubmitDefinition as hE,OnCommentUpdateDefinition as vE,OnModActionDefinition as yE,OnModMailDefinition as bE,OnPostCreateDefinition as kE,OnPostDeleteDefinition as SE,OnPostFlairUpdateDefinition as PE,OnPostReportDefinition as CE,OnPostSubmitDefinition as xE,OnPostUpdateDefinition as wE}from"@devvit/protos";var jd;(function(r){function e(o,a){return o.length<=a?o:`${o.slice(0,a-1)}\u2026`}r.ellipsize=e;function t(o){return o[0]==null?o:`${o[0].toLocaleUpperCase()}${o.slice(1)}`}r.capitalize=t;function i(o){return o==null||/^\s*$/.test(o)}r.isBlank=i;function n(o){return o instanceof Error?`${o.stack||o.message||o.name}`:String(o)}r.caughtToString=n})(jd||(jd={}));function ie(r,e){return g(e),async(t,i)=>{let n={...t,type:r},o=Object.assign(Ue({metadata:i}),de(i)),a=await Promise.allSettled(e.map(p=>p(n,o))),c=IE(a);if(c)throw c.err;return uE.fromPartial({})}}function cb(r){for(let e of u.triggerOnEventHandlers.keys())switch(e){case"PostSubmit":r.provides(xE),L("OnPostSubmit",ie("PostSubmit",u.triggerOnEventHandlers.get(e)));break;case"PostCreate":r.provides(kE),L("OnPostCreate",ie("PostCreate",u.triggerOnEventHandlers.get(e)));break;case"PostUpdate":r.provides(wE),L("OnPostUpdate",ie("PostUpdate",u.triggerOnEventHandlers.get(e)));break;case"PostReport":r.provides(CE),L("OnPostReport",ie("PostReport",u.triggerOnEventHandlers.get(e)));break;case"PostDelete":r.provides(SE),L("OnPostDelete",ie("PostDelete",u.triggerOnEventHandlers.get(e)));break;case"PostFlairUpdate":r.provides(PE),L("OnPostFlairUpdate",ie("PostFlairUpdate",u.triggerOnEventHandlers.get(e)));break;case"CommentSubmit":r.provides(hE),L("OnCommentSubmit",ie("CommentSubmit",u.triggerOnEventHandlers.get(e)));break;case"CommentCreate":r.provides(pE),L("OnCommentCreate",ie("CommentCreate",u.triggerOnEventHandlers.get(e)));break;case"CommentUpdate":r.provides(vE),L("OnCommentUpdate",ie("CommentUpdate",u.triggerOnEventHandlers.get(e)));break;case"CommentReport":r.provides(gE),L("OnCommentReport",ie("CommentReport",u.triggerOnEventHandlers.get(e)));break;case"CommentDelete":r.provides(fE),L("OnCommentDelete",ie("CommentDelete",u.triggerOnEventHandlers.get(e)));break;case"AppInstall":r.provides(cE),L("OnAppInstall",ie("AppInstall",u.triggerOnEventHandlers.get(e)));break;case"AppUpgrade":r.provides(mE),L("OnAppUpgrade",ie("AppUpgrade",u.triggerOnEventHandlers.get(e)));break;case"ModAction":r.provides(yE),L("OnModAction",ie("ModAction",u.triggerOnEventHandlers.get(e)));break;case"ModMail":r.provides(bE),L("OnModMail",ie("ModMail",u.triggerOnEventHandlers.get(e)));break;default:throw new Error(`Unknown trigger event: ${e}`)}}function IE(r){let e=r.reduce((t,i)=>i.status==="rejected"?[...t,i.reason]:t,[]);if(e.length!==0)return e.length===1?{err:e[0]}:{err:new Error(e.map(t=>jd.caughtToString(t)).join(`
3
- `))}}var nk=Dr(Cb(),1),sk=Dr(Qd(),1);import{EffectType as wO,UIEventHandlerDefinition as IO}from"@devvit/protos";async function AO(r,e){let t=r.state??{},i=(0,nk.default)(t),n=Ue({ui:!0,metadata:e});if(r.event?.formSubmitted&&r.event.formSubmitted.formId){let p=r.event.formSubmitted.formId;if(p.includes("form.hook.")&&u.customPostType){let b=new lt((C,x)=>u.customPostType?.render(x)??null,r.event,r.state,e,void 0);return await b.reconcile(),{state:b.state,effects:b.getEffects()}}let f=u.formDefinitions.get(p);if(!f)throw new Error(`Form with key ${p} not found`);let v,m;if(i.__contextAction){let{actionId:b,thingId:C}=i.__contextAction,x=gm(b);x?.location==="post"?v=C:x?.location==="comment"&&(m=C)}let k=Object.assign(n,de(e,v,m),{uiEnvironment:{timezone:e[B.Timezone]?.values[0],locale:e[B.Language]?.values[0]}});await f.onSubmit({values:xt(r.event.formSubmitted.results)},k)}else if(r.event?.realtimeEvent){if(u.customPostType){let p=new lt((f,v)=>u.customPostType?.render(v)??null,r.event,r.state,e,void 0);return await p.reconcile(),{state:p.state,effects:p.getEffects()}}}else if(r.event?.toastAction)throw new Error("Toast actions not yet implemented");let o=!(0,sk.default)(t,i),a=gi(n.ui),c=o?[...a,{type:wO.EFFECT_RERENDER_UI,rerenderUi:{delaySeconds:0}}]:a;return{state:i,effects:c}}function ok(r){r.provides(IO),L("HandleUIEvent",AO)}import{CustomPostDefinition as Tk}from"@devvit/protos";var ml=Dr(Qd(),1);import{EffectType as Om,Form as EO,ToastAppearance as lk}from"@devvit/protos";function ak(r){let e=r.match(/form\.hook\.(.+)\.0/);if(e?.[1])return e[1]}var Em=class{constructor(e,t,i){this.state=null;this.hookId=e.hookId,this.form=t,this.onSubmit=i,this.onUIEvent=async n=>{n.formSubmitted&&await i(xt(n.formSubmitted.results))}}};function Rm(r,e){let t=De({namespace:"useForm"},i=>new Em(i,r,e));return TO({id:t.hookId})}function TO(r){return`form.hook.${r.id}.0`}function dk(r,e){let t=ak(e);return r.getHook({id:t})}var Ft,el=class{constructor(e){d(this,Ft,void 0);l(this,Ft,e)}showForm(e,t){let i=dk(s(this,Ft),e);if(!i)throw new Error("Form does not exist. Make sure you have added it using useForm.");let n=i.form instanceof Function?i.form(t??{}):i.form,o=EO.fromPartial({id:e,title:n.title,acceptLabel:n.acceptLabel,cancelLabel:n.cancelLabel,shortDescription:n.description});dr(n.fields),o.fields=dt(n.fields),s(this,Ft).emitEffect(e,{type:Om.EFFECT_SHOW_FORM,showForm:{form:o}})}showToast(e){let t;e instanceof Object?t={text:e.text,appearance:e.appearance==="success"?lk.SUCCESS:lk.NEUTRAL}:t={text:e},s(this,Ft).emitEffect(e.toString(),{type:Om.EFFECT_SHOW_TOAST,showToast:{toast:t}})}navigateTo(e){let t;typeof e=="string"?t=new URL(e).toString():t=new URL(e.permalink,"https://www.reddit.com").toString(),s(this,Ft).emitEffect(t,{type:Om.EFFECT_NAVIGATE_TO_URL,navigateToUrl:{url:t}})}};Ft=new WeakMap;import{EffectType as RO,RealtimeSubscriptionStatus as uk}from"@devvit/protos";var Mt,tt,Lt,br,Ps,Mm,tl=class tl{constructor(e,t){d(this,Ps);d(this,Mt,void 0);d(this,tt,void 0);d(this,Lt,void 0);d(this,br,void 0);l(this,Mt,t.context),l(this,tt,!!t.context._devvitContext?.debug.realtime),l(this,br,e),l(this,Lt,t.invalidate);let i=t.context.meta[B.App]?.values[0];if(!i)throw Error("useChannel missing app ID metadata");let n=t.context.meta[B.Installation]?.values[0];if(!n)throw Error("useChannel missing install ID from metadata");let o=`${i}:${n}:${e.name}`;if(Object.values(s(this,Mt).hooks).filter(c=>c instanceof tl).some(c=>c.state.channel===o))throw Error(`useChannel channel names must be unique; "${o}" duplicated`);this.state={channel:o,connected:!1,subscribed:!1}}async onUIEvent(e){let t=e.realtimeEvent;if(!(!t||!this.state.subscribed))switch(t.status){case uk.REALTIME_SUBSCRIBED:s(this,tt)&&console.debug(`[realtime] "${this.state.channel}" connected`),this.state.connected=!0,s(this,Lt).call(this),await s(this,br).onSubscribed?.();break;case uk.REALTIME_UNSUBSCRIBED:s(this,tt)&&console.debug(`[realtime] "${this.state.channel}" disconnected`),this.state.connected=!1,s(this,Lt).call(this),await s(this,br).onUnsubscribed?.();break;default:s(this,tt)&&console.debug(`[realtime] "${this.state.channel}" received message: ${JSON.stringify(e,void 0,2)}`),s(this,br).onMessage(t.event?.data??{});break}}async send(e){if(s(this,tt)&&console.debug(`[realtime] "${this.state.channel}" send message: ${JSON.stringify(e,void 0,2)}`),!this.state.subscribed||!this.state.connected)throw console.debug(`[realtime] "${this.state.channel}" send failed; channel not connected`),Error(`useChannel send failed; "${this.state.channel}" channel not connected`);await s(this,Mt).devvitContext.realtime.send(this.state.channel,e)}get status(){return this.state.subscribed&&this.state.connected?2:this.state.subscribed&&!this.state.connected?1:!this.state.subscribed&&this.state.connected?3:4}subscribe(){this.state.subscribed||(s(this,tt)&&console.debug(`[realtime] "${this.state.channel}" subscribed`),this.state.subscribed=!0,s(this,Lt).call(this),y(this,Ps,Mm).call(this))}unsubscribe(){this.state.subscribed&&(s(this,tt)&&console.debug(`[realtime] "${this.state.channel}" unsubscribed`),this.state.subscribed=!1,s(this,Lt).call(this),y(this,Ps,Mm).call(this))}};Mt=new WeakMap,tt=new WeakMap,Lt=new WeakMap,br=new WeakMap,Ps=new WeakSet,Mm=function(){let e=Object.values(s(this,Mt).hooks).filter(t=>t instanceof tl&&t.state.subscribed).map(t=>t.state.channel);s(this,Mt).emitEffect(this.state.channel,{type:RO.EFFECT_REALTIME_SUB,realtimeSubscriptions:{subscriptionIds:e}})};var Fm=tl;function Lm(r){if(!r.name||/[^a-zA-Z0-9]/.test(r.name))throw Error("useChannel error: channel names must be nonempty and alphanumeric");let e=`useChannel:${r.name}`;return De({id:e,namespace:e},t=>new Fm(r,t))}import{EffectType as Um}from"@devvit/protos";function ck(r){return typeof r=="object"&&r!==null&&"__deleted"in r}var kr,Pi=class Pi{constructor(e,t){d(this,kr,void 0);this._segments=[];this._hooks={};this._prevHookId="";this._effects={};this._changed={};this._requeueEvents=[];this._rootProps={};this._generated={};this._undeliveredHandlers={};this.request=e,this.meta=t,l(this,kr,e.state??{__cache:{}}),this._rootProps=e.props??{}}get devvitContext(){if(!this._devvitContext)throw new Error("Devvit context not available");return this._devvitContext}set devvitContext(e){this._devvitContext=e}get _changedState(){let e={__cache:s(this,kr).__cache??{}};for(let i in this._changed)e[i]=this._state[i];let t=new Set(Object.keys(this._state));return Object.keys(this._hooks).forEach(i=>{i!=="__cache"&&t.delete(i)}),t.forEach(i=>{if(i==="__cache")return;let n={__deleted:!0};this._state[i]=e[i]=n}),e}get hooks(){return this._hooks}get _state(){return s(this,kr)}set _state(e){this._changed={},this._hooks={},l(this,kr,e)}push(e){this._segments.push({...e,next:0})}pop(){this._segments.pop()}addUndeliveredEventHandler(e,t){this._undeliveredHandlers[e]=t}addGlobalUndeliveredEventHandler(e,t){Pi.addGlobalUndeliveredEventHandler(e,t)}getHook(e){return this._hooks[e.id]}static addGlobalUndeliveredEventHandler(e,t){Pi._staticUndeliveredHandlers[e]=t}async handleUndeliveredEvent(e){let t={...Pi._staticUndeliveredHandlers,...this._undeliveredHandlers};for(let[i,n]of Object.entries(t))await n(e,this)}emitEffect(e,t){this._effects[e]=t}addToRequeueEvents(...e){this._devvitContext?.debug.blocks&&console.debug("[blocks] requeueing events",e);let t=e.reduce((i,n)=>(n.retry?i.retry.push(n):i.normal.push(n),i),{retry:[],normal:[]});this._requeueEvents=[...t.retry,...this._requeueEvents,...t.normal]}get effects(){return Object.values(this._effects)}nextHookId(e){e.key===void 0&&(e.key=this._segments[this._segments.length-1].next+++""),this.push(e);try{let t=[];for(let n=this._segments.length-1;n>=0;n--){let o=this._segments[n];if(o.id){t.unshift(o.id);break}let a=[];o.namespace&&a.push(o.namespace),o.key!==void 0&&o.key!==!1&&a.push(o.key),t.unshift(a.join("-"))}let i=t.join(".");if(this._generated[i]&&!e.shared)throw new Error(`Hook id ${i} already used, cannot register another hook with the same id`);return this._generated[i]=!0,this._prevHookId=i,i}finally{this.pop()}}};kr=new WeakMap,Pi._staticUndeliveredHandlers={};var Ci=Pi;var Ut={};Ci.addGlobalUndeliveredEventHandler("intervals",async(r,e)=>{r.timer&&r.hook&&(delete Ut[r.hook],e.emitEffect("timers",{type:Um.EFFECT_SET_INTERVALS,interval:{intervals:Ut}}))});var Bt,xi,Cs,wi,Bm=class{constructor(e,t,i){d(this,Bt,void 0);d(this,xi,void 0);d(this,Cs,void 0);d(this,wi,void 0);this.state={duration:{seconds:0,nanos:0},running:!1};l(this,xi,i.invalidate),l(this,Bt,i.hookId),l(this,Cs,e),l(this,wi,i.context);let n=Math.floor(t/1e3),o=t%1e3*1e6;this.state.duration={seconds:n,nanos:o}}onStateLoaded(){this.state.running?Ut[s(this,Bt)]={duration:this.state.duration}:delete Ut[s(this,Bt)]}async onUIEvent(e){await s(this,Cs).call(this)}start(){Ut[s(this,Bt)]={duration:this.state.duration},this.state.running=!0,s(this,xi).call(this),s(this,wi).emitEffect("timers",{type:Um.EFFECT_SET_INTERVALS,interval:{intervals:Ut}})}stop(){delete Ut[s(this,Bt)],this.state.running=!1,s(this,xi).call(this),s(this,wi).emitEffect("timers",{type:Um.EFFECT_SET_INTERVALS,interval:{intervals:Ut}})}};Bt=new WeakMap,xi=new WeakMap,Cs=new WeakMap,wi=new WeakMap;function Dm(r,e){return De({namespace:"useInterval"},t=>new Bm(r,e,t))}var Ii=class extends Error{};var Sr,xs,ws,Ai,rl=class{constructor(e,t){this.state={value:null,loading:!1};d(this,Sr,void 0);d(this,xs,void 0);d(this,ws,void 0);d(this,Ai,void 0);l(this,ws,e),l(this,Ai,t.hookId),l(this,Sr,t.invalidate),l(this,xs,t.context)}async onUIEvent(){this.state.value===null&&(this.state.value=await s(this,ws).call(this),this.state.loading=!1,s(this,Sr).call(this))}setter(e){this.state.value=e instanceof Function?e(this.state.value):e,s(this,Sr).call(this)}onStateLoaded(){if(this.state.value===null){this.state.loading=!0,s(this,Sr).call(this);let e={asyncRequest:{requestId:s(this,Ai)},hook:s(this,Ai)};throw s(this,xs).addToRequeueEvents(e),new Ii}}};Sr=new WeakMap,xs=new WeakMap,ws=new WeakMap,Ai=new WeakMap;function OO(r){let e=De({namespace:"useAsyncState"},t=>new rl(r,t));return[e.state.value,e.setter.bind(e)]}function _m(r){let e=De({namespace:"useState"},t=>{let i=r instanceof Function?r():r;return i instanceof Promise?new rl(()=>i,t):{state:{value:i},setter:o=>{e.state.value=o instanceof Function?o(e.state.value):o,t.invalidate()}}});return[e.state.value,e.setter.bind(e)]}var Hm={now(){return new Date}};function mk(r){return`__autocache__${r}`}function pk(r){return`__lock__${r}`}var FO=300,MO=1e3,il=5e3,Nm=3,fk=.1,gk=1e3,LO=3e4;function hk(r){if(r.error)throw new Error(r.error);return r.value}var Dt,_t,_e,Ti,sl,vk,ol,yk,al,bk,Is,qm,dl,kk,ll,Sk,As,jm,ul,Pk,nl=class{constructor(e,t,i=Hm){d(this,sl);d(this,ol);d(this,al);d(this,Is);d(this,dl);d(this,ll);d(this,As);d(this,ul);d(this,Dt,void 0);d(this,_t,{});d(this,_e,void 0);d(this,Ti,void 0);l(this,Dt,e),l(this,Ti,t),l(this,_e,i)}async cache(e,t){var a;(a=s(this,Ti)).__cache??(a.__cache={}),l(this,_t,s(this,Ti).__cache),y(this,ul,Pk).call(this,t);let i=y(this,sl,vk).call(this,t.key);if(i!==void 0)return i;let n=await y(this,As,jm).call(this,t.key),o=await y(this,ol,yk).call(this,t,n,e);return hk(o)}};Dt=new WeakMap,_t=new WeakMap,_e=new WeakMap,Ti=new WeakMap,sl=new WeakSet,vk=function(e){let t=s(this,_t)[e];if(t){let i=s(this,_e).now().getTime(),n=t?.error&&t?.errorTime&&t.errorCount<Nm&&Math.random()<fk&&t.errorTime+gk<i;if(t?.expires&&t.expires<i&&t.checkedAt+gk<i||n){delete s(this,_t)[e];return}else return hk(t)}},ol=new WeakSet,yk=async function(e,t,i){let n=t?.expires,o=n?y(this,ll,Sk).call(this,n):1;return!t||t?.error&&t.errorCount<Nm&&fk>Math.random()||o>Math.random()?y(this,al,bk).call(this,e,t,i):t},al=new WeakSet,bk=async function(e,t,i){let n=pk(e.key),o=s(this,_e).now().getTime(),a=new Date(o+e.ttl/2);if(await s(this,Dt).set(n,"1",{expiration:a,nx:!0}))return y(this,dl,kk).call(this,e.key,t,i,e.ttl);if(t)return t;{let p=s(this,_e).now();return y(this,Is,qm).call(this,p,e.key,e.ttl)}},Is=new WeakSet,qm=async function(e,t,i){let n=Math.min(i,MO),o=await y(this,As,jm).call(this,t);if(o)return o;if(s(this,_e).now().getTime()-e.getTime()>=n)throw new Error(`Cache request timed out trying to get data at key: ${t}`);return await new Promise(a=>setTimeout(a,FO)),y(this,Is,qm).call(this,e,t,i)},dl=new WeakSet,kk=async function(e,t,i,n){let o=s(this,_e).now().getTime()+n;t=t??{value:null,expires:o,errorCount:0,error:null,errorTime:null,checkedAt:0};try{t.value=await i(),t.error=null,t.errorCount=0,t.errorTime=null}catch(a){t.value=null,t.error=a.message??"Unknown error",t.errorTime=s(this,_e).now().getTime(),t.errorCount++}return s(this,_t)[e]=t,await s(this,Dt).set(mk(e),JSON.stringify(t),{expiration:new Date(o+LO)}),t.error&&t.errorCount<Nm&&await s(this,Dt).del(pk(e)),t},ll=new WeakSet,Sk=function(e){let t=s(this,_e).now().getTime(),i=e-t;return i<0?1:i<1e3?.1:i<2e3?.01:i<3e3?.001:0},As=new WeakSet,jm=async function(e){let t=await s(this,Dt).get(mk(e));if(t){let i=JSON.parse(t);return i.checkedAt=s(this,_e).now().getTime(),s(this,_t)[e]=i,i}},ul=new WeakSet,Pk=function(e){e.ttl<il&&(console.warn(`Cache TTL cannot be less than ${il} milliseconds! Updating ttl value of ${e.ttl} to ${il}.`),e.ttl=il)};function Ck(r,e,t=Hm){let i=new nl(r,e,t);return i.cache.bind(i)}var cl=class{buildContext(e,t,i){let n=new oi(i),o=new ni(i),a=new ci(i),c=new li(i),p=new mi(i),f=new pi(i),v=new el(e),m=new si(i),k=new ii,b=new ai(i),C=Ck(a,e._state),x={modLog:n,kvStore:o,redis:a,reddit:c,scheduler:p,settings:f,media:m,assets:k,realtime:b,ui:v,useState:_m,useChannel:Lm,useInterval:Dm,useForm:Rm,cache:C,dimensions:t.env?.dimensions,uiEnvironment:{timezone:i[B.Timezone]?.values[0],locale:i[B.Language]?.values[0],dimensions:t.env?.dimensions}},I=de(i,t.props?.postId);return I.debug.effects=e,{...I,...x}}};var ye=null;function Wm(r){return JSON.parse(JSON.stringify(r))}function UO(r){if(!(r!==""&&!/[-.]/.test(r)))throw new Error(`Hook with namespace '${r}' is invalid. Hook namespaces cannot be empty string or contain dashes/dots because they are used as delimiters internally. Please update the hook namespace and try again.`)}function BO(r){return r.blocking||r.resize?!1:!r.hook}function De(r,e){if(!ye)throw new Error("Hooks can only be declared at the top of a component. You cannot declare hooks outside of components or inside of event handlers. It's almost always a mistake to declare hooks inside of loops or conditionals.");UO(r.namespace);let t=ye.nextHookId(r),i=ye,n={hookId:t,invalidate:()=>{i._changed[t]=!0,i._state[t]=i?._hooks[t]?.state},context:ye},o=ye._state[t]===void 0||ck(ye._state[t]);ye._hooks[t]=ye._hooks[t]??e(n);let a=ye._hooks[t];return o||(a.state=ye._state[t]),a.onStateLoaded?.(),o&&a.state!==void 0&&a.state!==null&&n.invalidate(),a}var DO=null,Ei,hl,Ts,ne,be,Ri,pl,vl,xk,Es,Gm,yl,wk,bl,Ik,Rs,Vm,Os,zm,Oi,fl,Fs,Jm,kl,Ak,gl=class{constructor(e){d(this,ne);d(this,Ri);d(this,vl);d(this,Es);d(this,yl);d(this,bl);d(this,Rs);d(this,Os);d(this,Oi);d(this,Fs);d(this,kl);d(this,Ei,void 0);d(this,hl,new cl);d(this,Ts,new yi(()=>this._latestRenderContext?.devvitContext?.assets));this._latestRenderContext=null;s(this,ne,be)&&console.debug("[blocks] BlocksHandler v1"),l(this,Ei,e),DO=this}async handle(e,t){let i=new Ci(e,t),n=s(this,hl).buildContext(i,e,t);i.devvitContext=n;let o,a=e.events,p=!e.events?.length||a.some(b=>!b.async),f=a.some(b=>b.blocking),v,m,k=[...a];for(s(this,ne,be)&&console.debug("[blocks] starting processing events");a.length>0;){s(this,ne,be)&&console.debug("[blocks] processing events loop iteration",a.length);let b=[];if(!a[0].async)b.push(a.shift());else for(;a[0]?.async;)b.push(a.shift());if(!b.length)throw Error("batch must have at least one event");try{if(b[0].async){let x=Wm(i._state);await y(this,vl,xk).call(this,i,...b),i._state=x}else await y(this,yl,wk).call(this,i,...b)}catch(x){if(s(this,ne,be)&&console.debug("[blocks] caught in handler",x),m){i._state=m._state,i._changed=v,i._effects=m._effects;let I=k.map(E=>{let ue={...E};return ue.retry=!0,ue});i.addToRequeueEvents(...I);break}else throw x}s(this,ne,be)&&console.debug("[blocks] remaining events",i._requeueEvents);let C=[];for(let x of i._requeueEvents){if(!p&&!x.async){s(this,ne,be)&&console.debug("[blocks] NOT reprocessing event in BlocksHandler, sync mismatch A",x),C.push(x);continue}if(p&&x.async&&!f){s(this,ne,be)&&console.debug("[blocks] NOT reprocessing event in BlocksHandler, sync mismatch B",x),C.push(x);continue}s(this,ne,be)&&console.debug("[blocks] reprocessing event in BlocksHandler",x),a.push(x)}i._requeueEvents=C,a.length>0&&(v={...i._changed},m={_state:Wm(i._state),_effects:{...i._effects}},k=[...a])}if(p){let b=Wm(i._state),C=[...i._requeueEvents],x={...i._effects},I=y(this,Rs,Vm).call(this,s(this,Ei),i._rootProps??{},i);if((0,ml.default)(i._state,b)||console.error("[blocks] State was mutated during rendering",i._state,b),(0,ml.default)(i._requeueEvents,C)||console.error("[blocks] Events were mutated during rendering",i._requeueEvents,C),(0,ml.default)(i._effects,x)||console.error("[blocks] Effects were mutated during rendering",i._effects,x),I){let E=y(this,bl,Ik).call(this,i);o=s(this,Ts).createBlocksElementOrThrow(I,E),o=s(this,Ts).ensureRootBlock(o,E)}}return{state:i._changedState,effects:i.effects,blocks:o,events:i._requeueEvents}}};Ei=new WeakMap,hl=new WeakMap,Ts=new WeakMap,ne=new WeakSet,be=function(){return!!this._latestRenderContext?.devvitContext.debug.blocks},Ri=new WeakSet,pl=function(e,...t){e._hooks={},y(this,Rs,Vm).call(this,s(this,Ei),e.request.props??{},e)},vl=new WeakSet,xk=async function(e,...t){y(this,Ri,pl).call(this,e,...t),await Promise.all(t.map(async i=>{if(!i.async)throw new Error("You can't mix main and other queues in one batch. This is likely a platform bug. Please file an issue in the Discord for someone to help! https://discord.com/channels/1050224141732687912/1115441897079574620");await y(this,Es,Gm).call(this,e,i)}))},Es=new WeakSet,Gm=async function(e,t){BO(t)&&console.warn("Received an event in #attemptHook that does not have an associated hook. This will cause the event to be undelivered and may cause bugs. Make sure that event passes a hook field. Event:",{event:t});let i=e._hooks[t.hook];if(i?.onUIEvent)try{await i.onUIEvent(t,e)}catch(n){throw console.error("Error in event handler",n),n}else await e.handleUndeliveredEvent(t)},yl=new WeakSet,wk=async function(e,...t){for(let i of t)s(this,ne,be)&&console.log("[blocks] handling main queue event",i),s(this,ne,be)&&console.log("[blocks] before",e._state),y(this,Ri,pl).call(this,e,i),await y(this,Es,Gm).call(this,e,i),s(this,ne,be)&&console.log("[blocks] after",e._state);y(this,Ri,pl).call(this,e)},bl=new WeakSet,Ik=function(e){return{maxDimensions:e.devvitContext.dimensions??Md}},Rs=new WeakSet,Vm=function(e,t,i){s(this,ne,be)&&console.debug("[blocks] renderRoot"),i._generated={},ye=i,this._latestRenderContext=i;try{let n=y(this,Os,zm).call(this,e,t,i);if(n.length!==1)throw new Error(`There can only be one root element, received: ${n.length}. Please wrap these elements in a <vstack></vstack> or <hstack></hstack> to continue. Fragments cannot be used as a root element.`);let o=n[0];if(o==="[object Promise]")throw new Error('Root elements cannot be asynchronous. To use data from an async endpoint, please use "const [data] = context.useState(async () => {/** your async code */})".');if(typeof o=="string")throw new Error("The root element must return a valid block, not a string. Try wrapping the element in a <text>your content</text> tag to continue.");return o}catch(n){if(n instanceof Ii)return;throw n}finally{ye=null}},Os=new WeakSet,zm=function(e,t,i){i.push({namespace:e.name||"anonymous",...t});try{let n=e(t,i.devvitContext);return y(this,Fs,Jm).call(this,n,i)}finally{i.pop()}},Oi=new WeakSet,fl=function(e,t){return e=e.flat(1/0),e.flatMap((i,n)=>(i&&typeof i=="object"&&"props"in i&&(i.props?.key||(i.props=i.props??{},i.props.key=`${n}`)),y(this,Fs,Jm).call(this,i,t)))},Fs=new WeakSet,Jm=function(e,t){if(Array.isArray(e))return y(this,Oi,fl).call(this,e,t);if(_O(e))if(e.type===void 0){t.push({namespace:"fragment",...e.props});let i=y(this,Oi,fl).call(this,e.children,t);return t.pop(),i}else if(typeof e.type=="function"){let i={...e.props,children:e.children};return y(this,Os,zm).call(this,e.type,i,t)}else{t.push({namespace:e.type,...e.props});let i=y(this,Oi,fl).call(this,e.children,t),n=y(this,kl,Ak).call(this,e.props??{});return t.pop(),[{type:e.type,children:i,props:n}]}else return[(e??"").toString()]},kl=new WeakSet,Ak=function(e){let t={};for(let i in e)if(!(typeof e[i]>"u"))if(typeof e[i]=="function"){let n=De({namespace:i,key:!1},({hookId:o})=>({hookId:o,state:null,onUIEvent:e[i]}));t[i]=n.hookId,"captureHookRef"in e[i]&&e[i].captureHookRef()}else{let n=JSON.parse(JSON.stringify(e[i]));n!=null&&(t[i]=n)}return t};function _O(r){return typeof r=="object"&&r!=null&&"type"in r}var NO=[[Tk,Tk.methods.renderPostContent,(r,e)=>u.customPostType?.render(e)??null]];function qO(r){return async(e,t)=>new gl(r).handle(e,t)}function Ek(r){for(let[e,t,i]of NO)r.provides(e),L(t.name,qO(i))}var Fi,Mi,Ms,Pr,Cr,Li,Ui,xr,Nt,Ls,wr,_,j,z,U=class U extends yd{static configure(e){l(this,Ms,e),ut(e.http)&&y(this,j,z).call(this,P.HTTPDefinition),(ut(e.kvStore)||ut(e.redis))&&(y(this,j,z).call(this,P.KVStoreDefinition),y(this,j,z).call(this,P.RedisAPIDefinition)),ut(e.media)&&y(this,j,z).call(this,P.MediaServiceDefinition),ut(e.modLog)&&y(this,j,z).call(this,P.ModlogDefinition),ut(e.redditAPI)&&(y(this,j,z).call(this,P.FlairDefinition),y(this,j,z).call(this,P.GraphQLDefinition),y(this,j,z).call(this,P.LinksAndCommentsDefinition),y(this,j,z).call(this,P.ListingsDefinition),y(this,j,z).call(this,P.ModerationDefinition),y(this,j,z).call(this,P.ModNoteDefinition),y(this,j,z).call(this,P.NewModmailDefinition),y(this,j,z).call(this,P.PrivateMessagesDefinition),y(this,j,z).call(this,P.SubredditsDefinition),y(this,j,z).call(this,P.PostCollectionsDefinition),y(this,j,z).call(this,P.UsersDefinition),y(this,j,z).call(this,P.WidgetsDefinition),y(this,j,z).call(this,P.WikiDefinition),y(this,j,z).call(this,P.RedditAPIV2Definition)),ut(e.realtime)&&y(this,j,z).call(this,P.RealtimeDefinition)}static addMenuItem(e){s(this,Ui).push(e)}static addCustomPostType(e){l(this,Pr,e)}static createForm(e,t){let i=`form.${s(this,Cr).size}`;return s(this,Cr).set(i,{form:e,onSubmit:t}),i}static addSchedulerJob(e){if(s(this,_)[P.SchedulerDefinition.fullName]||y(this,j,z).call(this,P.SchedulerDefinition),s(this,xr).has(e.name))throw new Error(`Job ${e.name} is already defined`);s(this,xr).set(e.name,e.onRun)}static addSettings(e){dr(e);let t=e.filter(n=>n.type==="group"||!n.scope||n.scope==="installation"),i=e.filter(n=>n.type!=="group"&&n.scope==="app");t.length>0&&l(this,Li,t),i.length>0&&l(this,Fi,i),s(this,_)[P.SettingsDefinition.fullName]||y(this,j,z).call(this,P.SettingsDefinition)}static addTrigger(e){if("events"in e){for(let t of e.events)this.addTrigger({event:t,onEvent:(i,n)=>e.onEvent(i,n)});return this}return s(this,Nt).has(e.event)?s(this,Nt).get(e.event)?.push(e.onEvent):s(this,Nt).set(e.event,[e.onEvent]),U}static get redditAPIPlugins(){if(!ut(s(this,Ms).redditAPI))throw new Error("Reddit API is not enabled. You can enable it by passing `redditAPI: true` to `Devvit.configure`.");return{Flair:s(this,_)[P.FlairDefinition.fullName],GraphQL:s(this,_)[P.GraphQLDefinition.fullName],LinksAndComments:s(this,_)[P.LinksAndCommentsDefinition.fullName],Listings:s(this,_)[P.ListingsDefinition.fullName],Moderation:s(this,_)[P.ModerationDefinition.fullName],ModNote:s(this,_)[P.ModNoteDefinition.fullName],NewModmail:s(this,_)[P.NewModmailDefinition.fullName],PrivateMessages:s(this,_)[P.PrivateMessagesDefinition.fullName],Subreddits:s(this,_)[P.SubredditsDefinition.fullName],PostCollections:s(this,_)[P.PostCollectionsDefinition.fullName],Users:s(this,_)[P.UsersDefinition.fullName],Widgets:s(this,_)[P.WidgetsDefinition.fullName],Wiki:s(this,_)[P.WikiDefinition.fullName]}}static get modLogPlugin(){let e=s(this,_)[P.ModlogDefinition.fullName];if(!e)throw new Error("ModLog is not enabled. You can enable it by passing `modLog: true` to `Devvit.configure`");return e}static get schedulerPlugin(){let e=s(this,_)[P.SchedulerDefinition.fullName];if(!e)throw new Error("Scheduler is not enabled. You can enable it by calling `Devvit.addSchedulerJob` at the top level of your app.");return e}static get kvStorePlugin(){let e=s(this,_)[P.KVStoreDefinition.fullName];if(!e)throw new Error("Key Value Store is not enabled. You can enable it by passing `kvStore: true` to `Devvit.configure`");return e}static get redisPlugin(){let e=s(this,_)[P.RedisAPIDefinition.fullName];if(!e)throw new Error("Redis is not enabled. You can enable it by passing `redis: true` to `Devvit.configure`");return e}static get mediaPlugin(){let e=s(this,_)[P.MediaServiceDefinition.fullName];if(!e)throw new Error("MediaService is not enabled. You can enable it by passing `media: true` to `Devvit.configure`");return e}static get redditapiv2Plugin(){let e=s(this,_)[P.RedditAPIV2Definition.fullName];if(!e)throw new Error("RedditAPIV2 is not enabled. You can enable it by passing `apiV2: true` to `Devvit.configure`");return e}static get settingsPlugin(){let e=s(this,_)[P.SettingsDefinition.fullName];if(!e)throw new Error("Settings must first be configured with `Devvit.addSettings()` before they can be accessed");return e}static get realtimePlugin(){let e=s(this,_)[P.RealtimeDefinition.fullName];if(!e)throw new Error("Realtime is not enabled. You can enable it by passing `realtime: true` to `Devvit.configure`");return e}static get menuItems(){return s(this,Ui)}static get customPostType(){return s(this,Pr)}static get formDefinitions(){return s(this,Cr)}static get scheduledJobHandlers(){return s(this,xr)}static get installationSettings(){return s(this,Li)}static get appSettings(){return s(this,Fi)}static get triggerOnEventHandlers(){return s(this,Nt)}static get assets(){return s(this,Mi)}static get webviewAssets(){return s(this,Ls)}constructor(e){super(e),l(U,Mi,e.assets??{});for(let t in s(U,wr)){let i=s(U,wr)[t];i.handler=e.use(i.def,i.options)}s(U,Ui).length>0&&lb(e),s(U,xr).size>0&&ub(e),s(U,Pr)&&(ob(e),Ek(e)),(s(U,Pr)||s(U,Cr).size>0)&&ok(e),s(U,Li)&&ab(e),s(U,Fi)&&Dy(e),s(U,Nt).size>0&&cb(e),l(U,Mi,e.assets??{}),l(U,Ls,e.webviewAssets??{})}};Fi=new WeakMap,Mi=new WeakMap,Ms=new WeakMap,Pr=new WeakMap,Cr=new WeakMap,Li=new WeakMap,Ui=new WeakMap,xr=new WeakMap,Nt=new WeakMap,Ls=new WeakMap,wr=new WeakMap,_=new WeakMap,j=new WeakSet,z=function(e,t){s(this,wr)[e.fullName]={def:e,options:t??{},handler:void 0};let i={};for(let n of Object.values(e.methods))i[n.name]=(o,a)=>s(this,wr)[e.fullName].handler?.[n.name]?.(n.requestType?.fromPartial(o??{}),a);return s(this,_)[e.fullName]=i,i},d(U,j),U.debug={},d(U,Fi,void 0),d(U,Mi,{}),d(U,Ms,{}),d(U,Pr,void 0),d(U,Cr,new Map),d(U,Li,void 0),d(U,Ui,[]),d(U,xr,new Map),d(U,Nt,new Map),d(U,Ls,{}),d(U,wr,{}),d(U,_,{});var u=U;(e=>{function r(t,i,...n){return{type:t,props:i,children:n}}e.createElement=r})(u||(u={}));function J(r){let e=Object.getOwnPropertyDescriptors(r.constructor.prototype);for(let[t,i]of Object.entries(e))i.get&&Object.defineProperty(r,t,{...i,enumerable:!0})}var $m;(function(r){r[r.bold=1]="bold",r[r.italic=2]="italic",r[r.underline=4]="underline",r[r.strikethrough=8]="strikethrough",r[r.subscript=16]="subscript",r[r.superscript=32]="superscript",r[r.monospace=64]="monospace"})($m||($m={}));var Rk="text",Ok="raw",Fk="br",Mk="link",Lk="c/",Uk="p/",Bk="r/",Dk="u/",_k="@",Nk="spoilertext",qk="par",jk="h",Hk="hr",Wk="blockquote",Gk="code",Vk="li",zk="list",Jk="L",$k="R",Kk="C",Xk="table",Zk="embed",Yk="img",Qk="gif",eS="video";function tS(r){return{e:Qk,id:r.mediaId,...r.caption&&{c:r.caption},...r.blur&&{o:r.blur}}}function rS(r,e){let t={},i=[];return Object.assign(t,Us(t,i),Bs(t,i),Ds(t,i),qs(t,i),js(t,i),Hs(t,i)),e(t),{e:Wk,c:i,...r.author&&{a:r.author}}}function iS(r,e){let t={},i=[];return Object.assign(t,Xm(t,i)),e(t),{e:Gk,c:i,...r.language&&{l:r.language}}}function nS(r){return{e:Lk,t:r.permalink}}function sS(r,e){let t={},i=[];return Object.assign(t,Xm(t,i),Ns(t,i)),e(t),{e:jk,l:r.level,c:i}}function oS(r){return{e:Zk,u:r.sourceUrl,c:r.contentUrl,x:r.width,y:r.height}}function aS(){return{e:Hk}}function dS(r){return{e:Yk,id:r.mediaId,...r.caption&&{c:r.caption},...r.blur&&{o:r.blur}}}function lS(){return{e:Fk}}function uS(r){return{e:Mk,t:r.text,u:r.url,...r.formatting&&{f:r.formatting},...r.tooltip&&{a:r.tooltip}}}function cS(r,e){let t={},i=[];return Object.assign(t,AS(t,i)),e(t),{e:zk,o:r.ordered,c:i}}function mS(r){let e={},t=[];return Object.assign(e,Us(e,t),Bs(e,t),Ds(e,t),Sl(e,t),qs(e,t),js(e,t),Hs(e,t)),r(e),{e:Vk,c:t}}function pS(r){let e={},t=[];return Object.assign(e,Pl(e,t),Ns(e,t),Km(e,t),Zm(e,t),_s(e,t)),r(e),{e:qk,c:t}}function fS(r){return{e:Uk,t:r.permalink}}function gS(r){return{e:Ok,t:r}}function hS(r){let e={},t=[];return Object.assign(e,Pl(e,t),Ns(e,t),Km(e,t)),r(e),{e:Nk,c:t}}function vS(r){return{e:Bk,t:r.subredditName,l:r.showPrefix}}function yS(r){let e={},t=[],i=[];return Object.assign(e,TS(e,t,i)),r(e),{e:Xk,h:t,c:i}}function bS(r){let[e,t]=IS();return r(e),{c:t}}function kS(r,e){let[t,i]=IS();e(t);let n;switch(r.columnAlignment){case"left":n=Jk;break;case"right":n=$k;break;case"center":n=Kk;break}return{...n&&{a:n},...i&&{c:i}}}function SS(r){let e={},t=[];return Object.assign(e,ES(e,t)),r(e),t}function PS(r){return{e:Rk,t:r.text,...r.formatting&&{f:r.formatting}}}function CS(r){return{e:Dk,t:r.username,l:r.showPrefix}}function xS(r){return{e:_k,t:r.username,l:r.showPrefix}}function wS(r){return{e:eS,id:r.mediaId,...r.caption&&{c:r.caption},...r.blur&&{o:r.blur},...r.thumbnail&&{p:r.thumbnail},...r.convertToGif&&{gifify:r.convertToGif}}}function IS(){let r={},e=[];return Object.assign(r,Pl(r,e),Ns(r,e),Zm(r,e),_s(r,e)),[r,e]}function Us(r,e){return{blockQuote(t,i){return e.push(rS(t,i)),r}}}function Bs(r,e){return{codeBlock(t,i){return e.push(iS(t,i)),r}}}function RS(r,e){return{embed(t){return e.push(oS(t)),r}}}function Ds(r,e){return{heading(t,i){return e.push(sS(t,i)),r}}}function Sl(r,e){return{horizontalRule(){return e.push(aS()),r}}}function _s(r,e){return{image(t){return e.push(dS(t)),r},animatedImage(t){return e.push(tS(t)),r}}}function Km(r,e){return{linebreak(){return e.push(lS()),r}}}function Ns(r,e){return{link(t){return e.push(uS(t)),r},commentLink(t){return e.push(nS(t)),r},postLink(t){return e.push(fS(t)),r},subredditLink(t){return e.push(vS(t)),r},userLink(t){return e.push(CS(t)),r},userMention(t){return e.push(xS(t)),r}}}function qs(r,e){return{list(t,i){return e.push(cS(t,i)),r}}}function AS(r,e){return{item(t){return e.push(mS(t)),r}}}function js(r,e){return{paragraph(t){return e.push(pS(t)),r}}}function Xm(r,e){return{rawText(t){return e.push(gS(t)),r}}}function Zm(r,e){return{spoiler(t){return e.push(hS(t)),r}}}function TS(r,e,t){return{headerCell(i,n){return e.push(kS(i,n)),r},row(i){return t.push(SS(i)),r}}}function Hs(r,e){return{table(t){return e.push(yS(t)),r}}}function ES(r,e){return{cell(t){return e.push(bS(t)),r}}}function Pl(r,e){return{text(t){return e.push(PS(t)),r}}}function OS(r,e){return{video(t){return e.push(wS(t)),r}}}var jO=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},HO=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},Cl,Ws=class{constructor(){Cl.set(this,void 0);let e=[];Object.assign(this,js(this,e),Ds(this,e),Sl(this,e),Us(this,e),Bs(this,e),RS(this,e),qs(this,e),Hs(this,e),_s(this,e),OS(this,e)),jO(this,Cl,{document:e},"f")}build(){return JSON.stringify(HO(this,Cl,"f"))}paragraph(e){return this}heading(e,t){return this}horizontalRule(){return this}blockQuote(e,t){return this}codeBlock(e,t){return this}embed(e){return this}list(e,t){return this}table(e){return this}image(e){return this}animatedImage(e){return this}video(e){return this}};Cl=new WeakMap;function Bi(r){let e;return r instanceof Ws?e=r.build():typeof r=="object"?e=JSON.stringify(r):e=r,e}var FS=100,MS=1/0,Ir,Ar,qt,Di,_i,xl,H=class{constructor(e){d(this,_i);d(this,Ir,void 0);d(this,Ar,void 0);d(this,qt,void 0);d(this,Di,!1);this.pageSize=FS;this.limit=MS;this.children=[];J(this),this._fetch=e.fetch,this.pageSize=e.pageSize??FS,this.limit=e.limit??MS,l(this,Ar,e.after),l(this,Ir,e.before),l(this,qt,e.more),e.children&&(this.children=e.children)}get hasMore(){return!s(this,Di)||!!(s(this,Ar)||s(this,Ir)||s(this,qt))}async*[Symbol.asyncIterator](){let e=0;for(;;){if(e===this.children.length)if(this.hasMore){if((await y(this,_i,xl).call(this)).length===0)break}else break;if(yield this.children[e],e++,e===this.limit)break}}setMore(e){l(this,qt,e)}preventInitialFetch(){l(this,Di,!0)}async all(){for(;this.hasMore&&this.children.length<this.limit;)await y(this,_i,xl).call(this);return this.children.slice(0,this.limit)}async get(e){let t=e<=this.limit?e:this.limit;for(;this.hasMore&&this.children.length<t;)await y(this,_i,xl).call(this);return this.children.slice(0,t)}};Ir=new WeakMap,Ar=new WeakMap,qt=new WeakMap,Di=new WeakMap,_i=new WeakSet,xl=async function(){if(!this.hasMore)throw new Error("This listing does not have any more items to load.");let{children:e,before:t,after:i,more:n}=await this._fetch({before:s(this,Ir),after:s(this,Ar),limit:this.pageSize,more:s(this,qt)});return this.children.push(...e),l(this,Ir,t),l(this,Ar,i),l(this,qt,n),l(this,Di,!0),e};function WO(r){try{return!0}catch{return!1}}function GO(r){try{return!0}catch{return!1}}var Gs,Ym,Me=class{constructor(){}static get(e,t){let i=u.redditAPIPlugins.ModNote;return new H({hasMore:!0,before:e.before,limit:e.limit,pageSize:e.limit,fetch:async n=>{let o=await i.GetNotes({subreddit:e.subreddit,user:e.user,filter:e.filter,before:n.before,limit:n.limit},t);return{children:o.modNotes?.map(a=>y(this,Gs,Ym).call(this,a))||[],before:o.hasNextPage?o.endCursor:void 0,hasMore:o.hasNextPage}}})}static async delete(e,t){let i=u.redditAPIPlugins.ModNote,{deleted:n}=await i.DeleteNotes(e,t);return!!n}static async add(e,t){let n=await u.redditAPIPlugins.ModNote.PostNotes(e,t);if(!n?.created)throw new Error("Failed to create mod note");return y(this,Gs,Ym).call(this,n.created)}static async addRemovalNote(e,t){await u.redditAPIPlugins.ModNote.PostRemovalNote(e,t)}};Gs=new WeakSet,Ym=function(e){if(g(e.id,"Mod note ID is null or undefined"),g(e.createdAt,"Mod note createdAt is null or undefined"),g(e.type,"Mod note type is null or undefined"),g(e.subreddit,"Mod note subreddit is null or undefined"),g(e.subredditId,"Mod note subredditId is null or undefined"),g(e.operator,"Mod note operator is null or undefined"),g(e.operatorId,"Mod note operatorId is null or undefined"),g(e.user,"Mod note user is null or undefined"),g(e.userId,"Mod note userId is null or undefined"),g(e.userNoteData,"Mod note userNote is null or undefined"),g(e.modActionData,"Mod note modAction is null or undefined"),!WO(e.userNoteData?.label??""))throw new Error(`Invalid user note label: ${e.userNoteData?.label}`);if(!GO(e.type))throw new Error(`Invalid mod note type: ${e.type}`);return{id:e.id,user:{id:te(e.userId??""),name:e.user},subreddit:{id:Re(e.subredditId??""),name:e.subreddit},operator:{id:te(e.operatorId??""),name:e.operator},createdAt:new Date(e.createdAt*1e3),userNote:{note:e.userNoteData?.note,redditId:ge(e.userNoteData?.redditId??""),label:e.userNoteData?.label},type:e.type}},d(Me,Gs);var jt=class{static queryWithQueryString(e,t){return u.redditAPIPlugins.GraphQL.Query({query:e},t)}static query(e,t,i,n){return u.redditAPIPlugins.GraphQL.PersistedQuery({operationName:e,id:t,variables:i},n)}};var LS=["all","wiki","posts","access","mail","config","flair","channels","chat_config","chat_community","chat_operator"];function VO(r,e,t=!1){let i=t?"%2b":"+";return e.map(n=>(r.includes(n)?i:"-")+n).join(",")}function Qm(r){return VO(r,LS,!0)}function US(r){return r.filter(e=>LS.includes(e))}var zO=(t=>(t.User="USER_FLAIR",t.Post="LINK_FLAIR",t))(zO||{}),Tr,Ni,qi,ji,Hi,Wi,Gi,Vi,zi,Ji,$i,wl,$e=class $e{constructor(e,t,i){d(this,Tr,void 0);d(this,Ni,void 0);d(this,qi,void 0);d(this,ji,void 0);d(this,Hi,void 0);d(this,Wi,void 0);d(this,Gi,void 0);d(this,Vi,void 0);d(this,zi,void 0);d(this,Ji,void 0);J(this),g(e.id),g(e.text),l(this,Tr,e.id),l(this,Ni,t),l(this,qi,e.text),l(this,ji,JO(e.textColor)),l(this,Hi,$O(e.backgroundColor)),l(this,Wi,KO(e.allowableContent)),l(this,Gi,e.modOnly),l(this,Vi,e.maxEmojis),l(this,zi,e.textEditable),l(this,Ji,i)}get id(){return s(this,Tr)}get text(){return s(this,qi)}get textColor(){return s(this,ji)}get backgroundColor(){return s(this,Hi)}get allowableContent(){return s(this,Wi)}get modOnly(){return s(this,Gi)}get maxEmojis(){return s(this,Vi)}get allowUserEdits(){return s(this,zi)}async delete(){return $e.deleteFlairTemplate(s(this,Tr),s(this,Ni),s(this,Ji))}async edit(e){return $e.editFlairTemplate({id:s(this,Tr),subredditName:s(this,Ni),text:e.text??s(this,qi),allowableContent:e.allowableContent??s(this,Wi),backgroundColor:e.backgroundColor??s(this,Hi),maxEmojis:e.maxEmojis??s(this,Vi),modOnly:e.modOnly??s(this,Gi),textColor:e.textColor??s(this,ji),allowUserEdits:e.allowUserEdits??s(this,zi)},s(this,Ji))}static async createPostFlairTemplate(e,t){var i;return y(i=$e,$i,wl).call(i,{...e,flairType:"LINK_FLAIR"},t)}static async createUserFlairTemplate(e,t){var i;return y(i=$e,$i,wl).call(i,{...e,flairType:"USER_FLAIR"},t)}static async editFlairTemplate(e,t){var i;return y(i=$e,$i,wl).call(i,e,t)}static async getPostFlairTemplates(e,t){return(await u.redditAPIPlugins.Flair.LinkFlair({subreddit:e},t)).flair?.map(o=>new $e(o,e,t))||[]}static async getUserFlairTemplates(e,t){return(await u.redditAPIPlugins.Flair.UserFlair({subreddit:e},t)).flair?.map(o=>new $e(o,e,t))||[]}static async deleteFlairTemplate(e,t,i){await u.redditAPIPlugins.Flair.DeleteFlairTemplate({subreddit:e,flairTemplateId:t},i)}};Tr=new WeakMap,Ni=new WeakMap,qi=new WeakMap,ji=new WeakMap,Hi=new WeakMap,Wi=new WeakMap,Gi=new WeakMap,Vi=new WeakMap,zi=new WeakMap,Ji=new WeakMap,$i=new WeakSet,wl=async function(e,t){let{subredditName:i,allowableContent:n="all",backgroundColor:o="transparent",flairType:a="",maxEmojis:c=10,modOnly:p=!1,text:f,textColor:v="dark",allowUserEdits:m=!1,id:k=""}=e;if(p&&m)throw new Error("Cannot have a mod only flair that is editable by users");let C=await u.redditAPIPlugins.Flair.FlairTemplate({subreddit:i,allowableContent:n,backgroundColor:o,flairType:a,maxEmojis:c,modOnly:p,text:f,textColor:v,textEditable:m,flairTemplateId:k,cssClass:"",overrideCss:!1},t);return new $e(C,i,t)},d($e,$i);var ae=$e;function Js(r){return{flairCssClass:r.flairCssClass,user:r.user,flairText:r.flairText}}var Vs,ep,zs,tp,Ht=class Ht{static async getUserFlairBySubreddit(e,t){return u.redditAPIPlugins.Flair.FlairList(e,t)}static setUserFlair(e,t){var i;return y(i=Ht,Vs,ep).call(i,e,t)}static setPostFlair(e,t){var i;return y(i=Ht,Vs,ep).call(i,{...e,postId:fe(e.postId)},t)}static async removePostFlair(e,t,i){var n;return y(n=Ht,zs,tp).call(n,e,t,void 0,i)}static async removeUserFlair(e,t,i){var n;return y(n=Ht,zs,tp).call(n,e,void 0,t,i)}};Vs=new WeakSet,ep=async function(e,t){await u.redditAPIPlugins.Flair.SelectFlair({subreddit:e.subredditName,flairTemplateId:e.flairTemplateId??"",text:e.text??"",name:e.username,link:e.postId,backgroundColor:e.backgroundColor??"",textColor:e.textColor??"dark",cssClass:e.cssClass??"",returnRtjson:"none"},t)},zs=new WeakSet,tp=async function(e,t,i,n){await u.redditAPIPlugins.Flair.SelectFlair({subreddit:e,name:i??"",link:t??"",flairTemplateId:"",backgroundColor:"",text:"",textColor:"",cssClass:"",returnRtjson:"none"},n)},d(Ht,Vs),d(Ht,zs);var Le=Ht;function JO(r){if(g(r,"Flair text color is required"),r==="light"||r==="dark")return r;throw new Error(`Invalid flair text color: ${r}`)}function $O(r){if(g(r,"Flair background color is required"),r==="transparent"||/^#([A-Fa-f0-9]{6})$/.test(r))return r;throw new Error(`Invalid flair background color: ${r}`)}function KO(r){if(r==="all"||r==="text"||r==="emoji")return r;throw new Error(`Invalid allowable content: ${r}`)}import{Block as iF}from"@devvit/protos";var NS=Dr(_S(),1);var Ki,Ks,Xi,Xs,Zs,Ys,Qs,eo,Zi,to,ro,io,no,so,oo,Wt,ao,lo,Rr,Yi,Gt,Qi,en,tn,Or,Vt,zt,rn,Jt,$t,Kt,pt,uo,co,nn,sn,D,N=class N{constructor(e,t){d(this,Ki,void 0);d(this,Ks,void 0);d(this,Xi,void 0);d(this,Xs,void 0);d(this,Zs,void 0);d(this,Ys,void 0);d(this,Qs,void 0);d(this,eo,void 0);d(this,Zi,void 0);d(this,to,void 0);d(this,ro,void 0);d(this,io,void 0);d(this,no,void 0);d(this,so,void 0);d(this,oo,void 0);d(this,Wt,void 0);d(this,ao,void 0);d(this,lo,void 0);d(this,Rr,void 0);d(this,Yi,void 0);d(this,Gt,void 0);d(this,Qi,void 0);d(this,en,void 0);d(this,tn,void 0);d(this,Or,void 0);d(this,Vt,void 0);d(this,zt,void 0);d(this,rn,void 0);d(this,Jt,void 0);d(this,$t,void 0);d(this,Kt,void 0);d(this,pt,void 0);d(this,uo,void 0);d(this,co,void 0);d(this,nn,void 0);d(this,sn,void 0);d(this,D,void 0);J(this),g(e.id,"Post is missing id"),g(e.title,"Post is missing title"),g(e.createdUtc,"Post is missing created date"),g(e.author,"Post is missing author name"),g(e.subreddit,"Post is missing subreddit name"),g(e.subredditId,"Post is missing subreddit id"),g(e.url,"Post is missing url"),g(e.permalink,"Post is missing permalink"),l(this,Ki,fe(`t3_${e.id}`)),l(this,Xi,e.author),l(this,Ks,e.authorFullname?te(e.authorFullname):void 0),l(this,Zs,Re(e.subredditId)),l(this,Ys,e.subreddit),l(this,io,e.score??0),l(this,no,e.numComments??0),l(this,so,e.numReports??0);let i=new Date(0);i.setUTCSeconds(e.createdUtc),l(this,Xs,i),l(this,eo,e.title),l(this,Zi,e.selftext),l(this,to,e.selftextHtml),l(this,ro,e.url),l(this,Qs,e.permalink),e.thumbnail&&e.thumbnail!=="self"&&e.thumbnail!=="nsfw"&&e.thumbnailHeight!=null&&e.thumbnailWidth!=null&&l(this,oo,{url:e.thumbnail,height:e.thumbnailHeight,width:e.thumbnailWidth}),l(this,Wt,e.approved??!1),l(this,ao,e.approvedAtUtc??0),l(this,lo,e.bannedAtUtc??0),l(this,Gt,e.removed??!1),l(this,Qi,e.removedBy),l(this,en,e.removedByCategory),l(this,Rr,e.spam??!1),l(this,Yi,e.stickied??!1),l(this,tn,e.archived??!1),l(this,Or,e.edited??!1),l(this,Vt,e.locked??!1),l(this,zt,e.over18??!1),l(this,rn,e.quarantine??!1),l(this,Jt,e.spoiler),l(this,$t,e.hidden??!1),l(this,Kt,e.ignoreReports??!1),l(this,pt,e.distinguished),l(this,co,e.secureMedia),l(this,nn,(e.modReports??[]).map(([n])=>n)),l(this,sn,(e.userReports??[]).map(([n])=>n)),l(this,D,t),(e.linkFlairBackgroundColor||e.linkFlairCssClass||e.linkFlairText||e.linkFlairType||e.linkFlairTemplateId||e.linkFlairRichtext||e.linkFlairTextColor)&&l(this,uo,{backgroundColor:e.linkFlairBackgroundColor,cssClass:e.linkFlairCssClass,text:e.linkFlairText,type:e.linkFlairType,templateId:e.linkFlairTemplateId,richtext:(e.linkFlairRichtext??[]).map(({e:n,t:o,a,u:c})=>({elementType:n,text:o,emojiRef:a,url:c})),textColor:e.linkFlairTextColor})}get id(){return s(this,Ki)}get authorId(){return s(this,Ks)}get authorName(){return s(this,Xi)}get subredditId(){return s(this,Zs)}get subredditName(){return s(this,Ys)}get permalink(){return s(this,Qs)}get title(){return s(this,eo)}get body(){return s(this,Zi)}get bodyHtml(){return s(this,to)}get url(){return s(this,ro)}get thumbnail(){return s(this,oo)}get createdAt(){return s(this,Xs)}get score(){return s(this,io)}get numberOfComments(){return s(this,no)}get numberOfReports(){return s(this,so)}get approved(){return s(this,Wt)}get approvedAtUtc(){return s(this,ao)}get bannedAtUtc(){return s(this,lo)}get spam(){return s(this,Rr)}get stickied(){return s(this,Yi)}get removed(){return s(this,Gt)}get removedBy(){return s(this,Qi)}get removedByCategory(){return s(this,en)}get archived(){return s(this,tn)}get edited(){return s(this,Or)}get locked(){return s(this,Vt)}get nsfw(){return s(this,zt)}get quarantined(){return s(this,rn)}get spoiler(){return s(this,Jt)}get hidden(){return s(this,$t)}get ignoringReports(){return s(this,Kt)}get distinguishedBy(){return s(this,pt)}get comments(){return X.getComments({postId:this.id},s(this,D))}get flair(){return s(this,uo)}get secureMedia(){return s(this,co)}get userReportReasons(){return s(this,sn)}get modReportReasons(){return s(this,nn)}toJSON(){return{id:this.id,authorId:this.authorId,authorName:this.authorName,subredditId:this.subredditId,subredditName:this.subredditName,permalink:this.permalink,title:this.title,body:this.body,bodyHtml:this.bodyHtml,url:this.url,thumbnail:this.thumbnail,score:this.score,numberOfComments:this.numberOfComments,numberOfReports:this.numberOfReports,createdAt:this.createdAt,approved:this.approved,spam:this.spam,stickied:this.stickied,removed:this.removed,removedBy:s(this,Qi),removedByCategory:s(this,en),archived:this.archived,edited:this.edited,locked:this.locked,nsfw:this.nsfw,quarantined:this.quarantined,spoiler:this.spoiler,hidden:this.hidden,ignoringReports:this.ignoringReports,distinguishedBy:this.distinguishedBy,flair:this.flair,secureMedia:this.secureMedia,modReportReasons:s(this,nn),userReportReasons:s(this,sn)}}isApproved(){return s(this,Wt)}isSpam(){return s(this,Rr)}isStickied(){return s(this,Yi)}isRemoved(){return s(this,Gt)}isArchived(){return s(this,tn)}isEdited(){return s(this,Or)}isLocked(){return s(this,Vt)}isNsfw(){return s(this,zt)}isQuarantined(){return s(this,rn)}isSpoiler(){return s(this,Jt)}isHidden(){return s(this,$t)}isIgnoringReports(){return s(this,Kt)}isDistinguishedBy(){return s(this,pt)}async edit(e){let t=await N.edit({id:this.id,...e},s(this,D));l(this,Zi,t.body),l(this,Or,t.edited)}async addComment(e){return X.submit({id:this.id,...e},s(this,D))}async delete(){return N.delete(this.id,s(this,D))}async approve(){await N.approve(this.id,s(this,D)),l(this,Wt,!0),l(this,Gt,!1)}async remove(e=!1){await N.remove(this.id,e,s(this,D)),l(this,Gt,!0),l(this,Rr,e),l(this,Wt,!1)}async lock(){await N.lock(this.id,s(this,D)),l(this,Vt,!0)}async unlock(){await N.unlock(this.id,s(this,D)),l(this,Vt,!1)}async hide(){await N.hide(this.id,s(this,D)),l(this,$t,!0)}async unhide(){await N.unhide(this.id,s(this,D)),l(this,$t,!1)}async markAsNsfw(){await N.markAsNsfw(this.id,s(this,D)),l(this,zt,!0)}async unmarkAsNsfw(){await N.unmarkAsNsfw(this.id,s(this,D)),l(this,zt,!1)}async markAsSpoiler(){await N.markAsSpoiler(this.id,s(this,D)),l(this,Jt,!0)}async unmarkAsSpoiler(){await N.unmarkAsSpoiler(this.id,s(this,D)),l(this,Jt,!1)}async sticky(e){await N.sticky(this.id,e,s(this,D))}async unsticky(){await N.unsticky(this.id,s(this,D))}async distinguish(){let{distinguishedBy:e}=await N.distinguish(this.id,!1,s(this,D));l(this,pt,e)}async distinguishAsAdmin(){let{distinguishedBy:e}=await N.distinguish(this.id,!0,s(this,D));l(this,pt,e)}async undistinguish(){let{distinguishedBy:e}=await N.undistinguish(this.id,s(this,D));l(this,pt,e)}async ignoreReports(){await N.ignoreReports(this.id,s(this,D)),l(this,Kt,!0)}async unignoreReports(){await N.unignoreReports(this.id,s(this,D)),l(this,Kt,!1)}async getAuthor(){return w.getByUsername(s(this,Xi),s(this,D))}async crosspost(e){return N.crosspost({...e,postId:this.id},s(this,D))}addRemovalNote(e){return Me.addRemovalNote({itemIds:[s(this,Ki)],...e},s(this,D))}static async getById(e,t){let i=u.redditAPIPlugins.LinksAndComments,n=ar(e)?e:`t3_${e}`,o=await i.Info({subreddits:[],thingIds:[n]},t);if(!o.data?.children?.length)throw new Error("could not find post");let a=o.data.children[0];if(!a?.data)throw new Error("could not find post");return new N(a.data,t)}static async submit(e,t){let i=u.redditAPIPlugins.LinksAndComments,n;if("preview"in e){g(t,"Missing metadata in `SubmitPostOptions`");let c=await new lt(()=>e.preview,void 0,{},t,void 0).buildBlocksUI(),p=iF.encode(c).finish();n=await i.Submit({kind:"custom",sr:e.subredditName,richtextJson:(0,NS.fromByteArray)(p),...e},t)}else n=await i.Submit({kind:"kind"in e?e.kind:"url"in e?"link":"self",sr:e.subredditName,richtextJson:"richtext"in e?Bi(e.richtext):void 0,...e},t);if("kind"in e&&["image","video","videogif"].includes(e.kind)&&!n.json?.data?.id&&"url"in e)throw new Error(`Post of ${e.kind} type with ${e.url} is being created asynchronously and should be updated in the subreddit soon.`);if(!n.json?.data?.id||n.json?.errors?.length)throw new Error(`failed to submit post - either post ID is empty or request failed with errors: ${n.json?.errors}`);return N.getById(`t3_${n.json.data.id}`,t)}static async crosspost(e,t){let i=u.redditAPIPlugins.LinksAndComments,{postId:n,subredditName:o,...a}=e,c=await i.Submit({kind:"crosspost",sr:o,crosspostFullname:fe(n),...a},t);if(!c.json?.data?.id||c.json?.errors?.length)throw new Error("failed to crosspost post");return N.getById(`t3_${c.json.data.id}`,t)}static async edit(e,t){let i=u.redditAPIPlugins.LinksAndComments,{id:n}=e,o;if("richtext"in e&&(o=Bi(e.richtext)),(await i.EditUserText({thingId:n,text:"text"in e?e.text:"",richtextJson:o},t)).json?.errors?.length)throw new Error("Failed to edit post");return N.getById(n,t)}static async delete(e,t){await u.redditAPIPlugins.LinksAndComments.Del({id:e},t)}static async approve(e,t){await u.redditAPIPlugins.Moderation.Approve({id:e},t)}static async remove(e,t=!1,i){await u.redditAPIPlugins.Moderation.Remove({id:e,spam:t},i)}static async hide(e,t){await u.redditAPIPlugins.LinksAndComments.Hide({id:e},t)}static async unhide(e,t){await u.redditAPIPlugins.LinksAndComments.Unhide({id:e},t)}static async markAsNsfw(e,t){await u.redditAPIPlugins.LinksAndComments.MarkNSFW({id:e},t)}static async unmarkAsNsfw(e,t){await u.redditAPIPlugins.LinksAndComments.UnmarkNSFW({id:e},t)}static async markAsSpoiler(e,t){await u.redditAPIPlugins.LinksAndComments.Spoiler({id:e},t)}static async unmarkAsSpoiler(e,t){await u.redditAPIPlugins.LinksAndComments.Unspoiler({id:e},t)}static async sticky(e,t,i){await u.redditAPIPlugins.LinksAndComments.SetSubredditSticky({id:e,state:!0,num:t},i)}static async unsticky(e,t){await u.redditAPIPlugins.LinksAndComments.SetSubredditSticky({id:e,state:!1},t)}static async lock(e,t){await u.redditAPIPlugins.LinksAndComments.Lock({id:e},t)}static async unlock(e,t){await u.redditAPIPlugins.LinksAndComments.Unlock({id:e},t)}static async distinguish(e,t,i){let a=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:t?"admin":"yes",sticky:!1},i)).json?.data?.things?.[0]?.data;return g(a),{distinguishedBy:a.distinguished}}static async undistinguish(e,t){let o=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:"no",sticky:!1},t)).json?.data?.things?.[0]?.data;return g(o),{distinguishedBy:o.distinguished}}static async ignoreReports(e,t){await u.redditAPIPlugins.Moderation.IgnoreReports({id:e},t)}static async unignoreReports(e,t){await u.redditAPIPlugins.Moderation.UnignoreReports({id:e},t)}static getControversialPosts(e={},t){return this.getSortedPosts({...e,sort:"controversial"},t)}static getTopPosts(e={},t){return this.getSortedPosts({...e,sort:"top"},t)}static getSortedPosts(e,t){let i=u.redditAPIPlugins.Listings;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async n=>{let o=await i.Sort({show:"all",sort:e.sort,t:e.timeframe,subreddit:e.subredditName,...n},t);return $s(o,t)}})}static getHotPosts(e={location:"GLOBAL"},t){let i=u.redditAPIPlugins.Listings;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async n=>{let o=await i.Hot({g:e.location,show:"all",subreddit:e.subredditName,...n},t);return $s(o,t)}})}static getNewPosts(e,t){let i=u.redditAPIPlugins.Listings;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async n=>{let o=await i.New({show:"all",subreddit:e.subredditName,...n},t);return $s(o,t)}})}static getRisingPosts(e,t){let i=u.redditAPIPlugins.Listings;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async n=>{let o=await i.Rising({show:"all",subreddit:e.subredditName,...n},t);return $s(o,t)}})}static getPostsByUser(e,t){let i=u.redditAPIPlugins.Users;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(n){let o=await i.UserWhere({username:e.username,where:"submitted",...n},t);return $s(o,t)}})}};Ki=new WeakMap,Ks=new WeakMap,Xi=new WeakMap,Xs=new WeakMap,Zs=new WeakMap,Ys=new WeakMap,Qs=new WeakMap,eo=new WeakMap,Zi=new WeakMap,to=new WeakMap,ro=new WeakMap,io=new WeakMap,no=new WeakMap,so=new WeakMap,oo=new WeakMap,Wt=new WeakMap,ao=new WeakMap,lo=new WeakMap,Rr=new WeakMap,Yi=new WeakMap,Gt=new WeakMap,Qi=new WeakMap,en=new WeakMap,tn=new WeakMap,Or=new WeakMap,Vt=new WeakMap,zt=new WeakMap,rn=new WeakMap,Jt=new WeakMap,$t=new WeakMap,Kt=new WeakMap,pt=new WeakMap,uo=new WeakMap,co=new WeakMap,nn=new WeakMap,sn=new WeakMap,D=new WeakMap;var V=N;function $s(r,e){if(!r.data?.children)throw new Error("Listing response is missing children");return{children:r.data.children.map(i=>new V(i.data,e)),before:r.data.before,after:r.data.after}}var mo,on,po,fo,go,ho,vo,Xt,yo,bo,ft,Fr=class Fr{constructor(e,t){d(this,mo,void 0);d(this,on,void 0);d(this,po,void 0);d(this,fo,void 0);d(this,go,void 0);d(this,ho,void 0);d(this,vo,void 0);d(this,Xt,new Map);d(this,yo,void 0);d(this,bo,void 0);d(this,ft,void 0);J(this),g(e.id,"User ID is missing or undefined"),g(e.name,"Username is missing or undefined"),g(e.createdUtc,"User is missing created date"),l(this,mo,te(vd(e.id)?e.id:`t2_${e.id}`)),l(this,on,e.name),l(this,ho,e.over18??!1),l(this,vo,e.isEmployee??!1);let i=new Date(0);if(i.setUTCSeconds(e.createdUtc),l(this,po,i),l(this,fo,e.linkKarma??0),l(this,go,e.commentKarma??0),e.modPermissions)for(let[n,o]of Object.entries(e.modPermissions))s(this,Xt).set(n,US(o));l(this,yo,new URL(e.subreddit?.url??"","https://www.reddit.com").toString()),l(this,bo,e.subreddit?.url??""),l(this,ft,t)}get id(){return s(this,mo)}get username(){return s(this,on)}get createdAt(){return s(this,po)}get linkKarma(){return s(this,fo)}get commentKarma(){return s(this,go)}get nsfw(){return s(this,ho)}get isAdmin(){return s(this,vo)}get modPermissions(){return s(this,Xt)}get url(){return s(this,yo)}get permalink(){return s(this,bo)}toJSON(){return{id:this.id,username:this.username,createdAt:this.createdAt,linkKarma:this.linkKarma,commentKarma:this.commentKarma,nsfw:this.nsfw,modPermissionsBySubreddit:Object.fromEntries(this.modPermissions)}}async getModPermissionsForSubreddit(e){if(s(this,Xt).has(e))return s(this,Xt).get(e);let t=await Fr.getSubredditUsersByType({subredditName:e,type:"moderators",username:this.username},s(this,ft)).all();if(t.length===0)return[];let i=t[0].modPermissions.get(e)??[];return i.length>0&&s(this,Xt).set(e,i),i}getComments(e){return X.getCommentsByUser({username:this.username,...e},s(this,ft))}getPosts(e){return V.getPostsByUser({username:this.username,...e},s(this,ft))}async getUserFlairBySubreddit(e){let t=await Le.getUserFlairBySubreddit({subreddit:e,name:s(this,on)},s(this,ft));return t.users[0]?Js(t.users[0]):void 0}getSnoovatarUrl(){return Fr.getSnoovatarUrl(this.username,s(this,ft))}static async getById(e,t){let o=(await u.redditAPIPlugins.Users.UserDataByAccountIds({ids:e},t))?.users?.[e]?.name;return o==null?void 0:Fr.getByUsername(o,t)}static async getByUsername(e,t){let n=await u.redditAPIPlugins.Users.UserAbout({username:e},t);if(!n.data?.id)throw new Error("failed to get user");return new Fr(n.data,t)}static async getFromMetadata(e,t){g(t);let i=t?.[e]?.values[0];return i?Fr.getById(te(i),t):Promise.resolve(void 0)}static getSubredditUsersByType(e,t){let i=u.redditAPIPlugins.Subreddits;return new H({hasMore:!0,pageSize:e.pageSize,limit:e.limit,after:e.after,before:e.before,fetch:async n=>{let o=await i.AboutWhere({where:e.type,user:e.username,subreddit:e.subredditName,show:"all",...n},t);return sF(o,e.subredditName,t)}})}static async createRelationship(e,t){let i=u.redditAPIPlugins.Users,{type:n,subredditName:o,username:a,permissions:c,...p}=e,f=await i.Friend({type:n,subreddit:o,name:a,permissions:c?Qm(c):void 0,...p},t);if(f.json?.errors?.length)throw new Error(f.json.errors.join(`
1
+ var JS=Object.create;var dp=Object.defineProperty;var $S=Object.getOwnPropertyDescriptor;var KS=Object.getOwnPropertyNames;var XS=Object.getPrototypeOf,ZS=Object.prototype.hasOwnProperty;var h=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var YS=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of KS(e))!ZS.call(r,n)&&n!==t&&dp(r,n,{get:()=>e[n],enumerable:!(i=$S(e,n))||i.enumerable});return r};var Dr=(r,e,t)=>(t=r!=null?JS(XS(r)):{},YS(e||!r||!r.__esModule?dp(t,"default",{value:r,enumerable:!0}):t,r));var Jl=(r,e,t)=>{if(!e.has(r))throw TypeError("Cannot "+t)};var s=(r,e,t)=>(Jl(r,e,"read from private field"),t?t.call(r):e.get(r)),d=(r,e,t)=>{if(e.has(r))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(r):e.set(r,t)},l=(r,e,t,i)=>(Jl(r,e,"write to private field"),i?i.call(r,t):e.set(r,t),t);var y=(r,e,t)=>(Jl(r,e,"access private method"),t);var oe=h((AF,lp)=>{lp.exports=function(r){try{return!!r()}catch{return!0}}});var Ta=h((TF,up)=>{var QS=oe();up.exports=!QS(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")})});var $=h((EF,pp)=>{var cp=Ta(),mp=Function.prototype,$l=mp.call,eP=cp&&mp.bind.bind($l,$l);pp.exports=cp?eP:function(r){return function(){return $l.apply(r,arguments)}}});var gp=h((RF,fp)=>{var tP=Math.ceil,rP=Math.floor;fp.exports=Math.trunc||function(e){var t=+e;return(t>0?rP:tP)(t)}});var Ea=h((OF,hp)=>{var iP=gp();hp.exports=function(r){var e=+r;return e!==e||e===0?0:iP(e)}});var ce=h((FF,vp)=>{var Ra=function(r){return r&&r.Math==Math&&r};vp.exports=Ra(typeof globalThis=="object"&&globalThis)||Ra(typeof window=="object"&&window)||Ra(typeof self=="object"&&self)||Ra(typeof global=="object"&&global)||function(){return this}()||Function("return this")()});var _r=h((MF,yp)=>{yp.exports=!1});var Oa=h((UF,kp)=>{var bp=ce(),nP=Object.defineProperty;kp.exports=function(r,e){try{nP(bp,r,{value:e,configurable:!0,writable:!0})}catch{bp[r]=e}return e}});var Fa=h((LF,Pp)=>{var sP=ce(),oP=Oa(),Sp="__core-js_shared__",aP=sP[Sp]||oP(Sp,{});Pp.exports=aP});var Kl=h((BF,wp)=>{var dP=_r(),Cp=Fa();(wp.exports=function(r,e){return Cp[r]||(Cp[r]=e!==void 0?e:{})})("versions",[]).push({version:"3.27.2",mode:dP?"pure":"global",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.27.2/LICENSE",source:"https://github.com/zloirock/core-js"})});var Ma=h((DF,xp)=>{xp.exports=function(r){return r==null}});var Ua=h((_F,Ip)=>{var lP=Ma(),uP=TypeError;Ip.exports=function(r){if(lP(r))throw uP("Can't call method on "+r);return r}});var Ln=h((NF,Ap)=>{var cP=Ua(),mP=Object;Ap.exports=function(r){return mP(cP(r))}});var Ce=h((qF,Tp)=>{var pP=$(),fP=Ln(),gP=pP({}.hasOwnProperty);Tp.exports=Object.hasOwn||function(e,t){return gP(fP(e),t)}});var Xl=h((jF,Ep)=>{var hP=$(),vP=0,yP=Math.random(),bP=hP(1 .toString);Ep.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+bP(++vP+yP,36)}});var Op=h((HF,Rp)=>{Rp.exports=typeof navigator<"u"&&String(navigator.userAgent)||""});var _p=h((WF,Dp)=>{var Bp=ce(),Zl=Op(),Fp=Bp.process,Mp=Bp.Deno,Up=Fp&&Fp.versions||Mp&&Mp.version,Lp=Up&&Up.v8,He,La;Lp&&(He=Lp.split("."),La=He[0]>0&&He[0]<4?1:+(He[0]+He[1]));!La&&Zl&&(He=Zl.match(/Edge\/(\d+)/),(!He||He[1]>=74)&&(He=Zl.match(/Chrome\/(\d+)/),He&&(La=+He[1])));Dp.exports=La});var Yl=h((GF,qp)=>{var Np=_p(),kP=oe();qp.exports=!!Object.getOwnPropertySymbols&&!kP(function(){var r=Symbol();return!String(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Np&&Np<41})});var Ql=h((VF,jp)=>{var SP=Yl();jp.exports=SP&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var we=h((zF,Wp)=>{var PP=ce(),CP=Kl(),Hp=Ce(),wP=Xl(),xP=Yl(),IP=Ql(),Nr=PP.Symbol,eu=CP("wks"),AP=IP?Nr.for||Nr:Nr&&Nr.withoutSetter||wP;Wp.exports=function(r){return Hp(eu,r)||(eu[r]=xP&&Hp(Nr,r)?Nr[r]:AP("Symbol."+r)),eu[r]}});var zp=h((JF,Vp)=>{var TP=we(),EP=TP("toStringTag"),Gp={};Gp[EP]="z";Vp.exports=String(Gp)==="[object z]"});var ru=h(($F,Jp)=>{var tu=typeof document=="object"&&document.all,RP=typeof tu>"u"&&tu!==void 0;Jp.exports={all:tu,IS_HTMLDDA:RP}});var K=h((KF,Kp)=>{var $p=ru(),OP=$p.all;Kp.exports=$p.IS_HTMLDDA?function(r){return typeof r=="function"||r===OP}:function(r){return typeof r=="function"}});var Ba=h((XF,Zp)=>{var Xp=$(),FP=Xp({}.toString),MP=Xp("".slice);Zp.exports=function(r){return MP(FP(r),8,-1)}});var Bn=h((ZF,Yp)=>{var UP=zp(),LP=K(),Da=Ba(),BP=we(),DP=BP("toStringTag"),_P=Object,NP=Da(function(){return arguments}())=="Arguments",qP=function(r,e){try{return r[e]}catch{}};Yp.exports=UP?Da:function(r){var e,t,i;return r===void 0?"Undefined":r===null?"Null":typeof(t=qP(e=_P(r),DP))=="string"?t:NP?Da(e):(i=Da(e))=="Object"&&LP(e.callee)?"Arguments":i}});var Dn=h((YF,Qp)=>{var jP=Bn(),HP=String;Qp.exports=function(r){if(jP(r)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return HP(r)}});var nu=h((QF,rf)=>{var iu=$(),WP=Ea(),GP=Dn(),VP=Ua(),zP=iu("".charAt),ef=iu("".charCodeAt),JP=iu("".slice),tf=function(r){return function(e,t){var i=GP(VP(e)),n=WP(t),o=i.length,a,c;return n<0||n>=o?r?"":void 0:(a=ef(i,n),a<55296||a>56319||n+1===o||(c=ef(i,n+1))<56320||c>57343?r?zP(i,n):a:r?JP(i,n,n+2):(a-55296<<10)+(c-56320)+65536)}};rf.exports={codeAt:tf(!1),charAt:tf(!0)}});var of=h((eM,sf)=>{var $P=ce(),KP=K(),nf=$P.WeakMap;sf.exports=KP(nf)&&/native code/.test(String(nf))});var bt=h((tM,lf)=>{var af=K(),df=ru(),XP=df.all;lf.exports=df.IS_HTMLDDA?function(r){return typeof r=="object"?r!==null:af(r)||r===XP}:function(r){return typeof r=="object"?r!==null:af(r)}});var me=h((rM,uf)=>{var ZP=oe();uf.exports=!ZP(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7})});var ou=h((iM,mf)=>{var YP=ce(),cf=bt(),su=YP.document,QP=cf(su)&&cf(su.createElement);mf.exports=function(r){return QP?su.createElement(r):{}}});var au=h((nM,pf)=>{var eC=me(),tC=oe(),rC=ou();pf.exports=!eC&&!tC(function(){return Object.defineProperty(rC("div"),"a",{get:function(){return 7}}).a!=7})});var du=h((sM,ff)=>{var iC=me(),nC=oe();ff.exports=iC&&nC(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42})});var Xe=h((oM,gf)=>{var sC=bt(),oC=String,aC=TypeError;gf.exports=function(r){if(sC(r))return r;throw aC(oC(r)+" is not an object")}});var We=h((aM,hf)=>{var dC=Ta(),_a=Function.prototype.call;hf.exports=dC?_a.bind(_a):function(){return _a.apply(_a,arguments)}});var _n=h((dM,vf)=>{var lu=ce(),lC=K(),uC=function(r){return lC(r)?r:void 0};vf.exports=function(r,e){return arguments.length<2?uC(lu[r]):lu[r]&&lu[r][e]}});var uu=h((lM,yf)=>{var cC=$();yf.exports=cC({}.isPrototypeOf)});var cu=h((uM,bf)=>{var mC=_n(),pC=K(),fC=uu(),gC=Ql(),hC=Object;bf.exports=gC?function(r){return typeof r=="symbol"}:function(r){var e=mC("Symbol");return pC(e)&&fC(e.prototype,hC(r))}});var mu=h((cM,kf)=>{var vC=String;kf.exports=function(r){try{return vC(r)}catch{return"Object"}}});var Na=h((mM,Sf)=>{var yC=K(),bC=mu(),kC=TypeError;Sf.exports=function(r){if(yC(r))return r;throw kC(bC(r)+" is not a function")}});var qa=h((pM,Pf)=>{var SC=Na(),PC=Ma();Pf.exports=function(r,e){var t=r[e];return PC(t)?void 0:SC(t)}});var wf=h((fM,Cf)=>{var pu=We(),fu=K(),gu=bt(),CC=TypeError;Cf.exports=function(r,e){var t,i;if(e==="string"&&fu(t=r.toString)&&!gu(i=pu(t,r))||fu(t=r.valueOf)&&!gu(i=pu(t,r))||e!=="string"&&fu(t=r.toString)&&!gu(i=pu(t,r)))return i;throw CC("Can't convert object to primitive value")}});var Tf=h((gM,Af)=>{var wC=We(),xf=bt(),If=cu(),xC=qa(),IC=wf(),AC=we(),TC=TypeError,EC=AC("toPrimitive");Af.exports=function(r,e){if(!xf(r)||If(r))return r;var t=xC(r,EC),i;if(t){if(e===void 0&&(e="default"),i=wC(t,r,e),!xf(i)||If(i))return i;throw TC("Can't convert object to primitive value")}return e===void 0&&(e="number"),IC(r,e)}});var ja=h((hM,Ef)=>{var RC=Tf(),OC=cu();Ef.exports=function(r){var e=RC(r,"string");return OC(e)?e:e+""}});var Ze=h(Of=>{var FC=me(),MC=au(),UC=du(),Ha=Xe(),Rf=ja(),LC=TypeError,hu=Object.defineProperty,BC=Object.getOwnPropertyDescriptor,vu="enumerable",yu="configurable",bu="writable";Of.f=FC?UC?function(e,t,i){if(Ha(e),t=Rf(t),Ha(i),typeof e=="function"&&t==="prototype"&&"value"in i&&bu in i&&!i[bu]){var n=BC(e,t);n&&n[bu]&&(e[t]=i.value,i={configurable:yu in i?i[yu]:n[yu],enumerable:vu in i?i[vu]:n[vu],writable:!1})}return hu(e,t,i)}:hu:function(e,t,i){if(Ha(e),t=Rf(t),Ha(i),MC)try{return hu(e,t,i)}catch{}if("get"in i||"set"in i)throw LC("Accessors not supported");return"value"in i&&(e[t]=i.value),e}});var qr=h((yM,Ff)=>{Ff.exports=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}}});var Wa=h((bM,Mf)=>{var DC=me(),_C=Ze(),NC=qr();Mf.exports=DC?function(r,e,t){return _C.f(r,e,NC(1,t))}:function(r,e,t){return r[e]=t,r}});var Ga=h((kM,Lf)=>{var qC=Kl(),jC=Xl(),Uf=qC("keys");Lf.exports=function(r){return Uf[r]||(Uf[r]=jC(r))}});var Va=h((SM,Bf)=>{Bf.exports={}});var jr=h((PM,Nf)=>{var HC=of(),_f=ce(),WC=bt(),GC=Wa(),ku=Ce(),Su=Fa(),VC=Ga(),zC=Va(),Df="Object already initialized",Pu=_f.TypeError,JC=_f.WeakMap,za,Nn,Ja,$C=function(r){return Ja(r)?Nn(r):za(r,{})},KC=function(r){return function(e){var t;if(!WC(e)||(t=Nn(e)).type!==r)throw Pu("Incompatible receiver, "+r+" required");return t}};HC||Su.state?(Ge=Su.state||(Su.state=new JC),Ge.get=Ge.get,Ge.has=Ge.has,Ge.set=Ge.set,za=function(r,e){if(Ge.has(r))throw Pu(Df);return e.facade=r,Ge.set(r,e),e},Nn=function(r){return Ge.get(r)||{}},Ja=function(r){return Ge.has(r)}):(er=VC("state"),zC[er]=!0,za=function(r,e){if(ku(r,er))throw Pu(Df);return e.facade=r,GC(r,er,e),e},Nn=function(r){return ku(r,er)?r[er]:{}},Ja=function(r){return ku(r,er)});var Ge,er;Nf.exports={set:za,get:Nn,has:Ja,enforce:$C,getterFor:KC}});var Cu=h(Hf=>{"use strict";var qf={}.propertyIsEnumerable,jf=Object.getOwnPropertyDescriptor,XC=jf&&!qf.call({1:2},1);Hf.f=XC?function(e){var t=jf(this,e);return!!t&&t.enumerable}:qf});var xu=h((wM,Wf)=>{var ZC=$(),YC=oe(),QC=Ba(),wu=Object,ew=ZC("".split);Wf.exports=YC(function(){return!wu("z").propertyIsEnumerable(0)})?function(r){return QC(r)=="String"?ew(r,""):wu(r)}:wu});var Hr=h((xM,Gf)=>{var tw=xu(),rw=Ua();Gf.exports=function(r){return tw(rw(r))}});var Iu=h(zf=>{var iw=me(),nw=We(),sw=Cu(),ow=qr(),aw=Hr(),dw=ja(),lw=Ce(),uw=au(),Vf=Object.getOwnPropertyDescriptor;zf.f=iw?Vf:function(e,t){if(e=aw(e),t=dw(t),uw)try{return Vf(e,t)}catch{}if(lw(e,t))return ow(!nw(sw.f,e,t),e[t])}});var Eu=h((AM,$f)=>{var Au=me(),cw=Ce(),Jf=Function.prototype,mw=Au&&Object.getOwnPropertyDescriptor,Tu=cw(Jf,"name"),pw=Tu&&function(){}.name==="something",fw=Tu&&(!Au||Au&&mw(Jf,"name").configurable);$f.exports={EXISTS:Tu,PROPER:pw,CONFIGURABLE:fw}});var Ou=h((TM,Kf)=>{var gw=$(),hw=K(),Ru=Fa(),vw=gw(Function.toString);hw(Ru.inspectSource)||(Ru.inspectSource=function(r){return vw(r)});Kf.exports=Ru.inspectSource});var Uu=h((EM,Yf)=>{var Mu=$(),yw=oe(),bw=K(),$a=Ce(),Fu=me(),kw=Eu().CONFIGURABLE,Sw=Ou(),Zf=jr(),Pw=Zf.enforce,Cw=Zf.get,Xf=String,Ka=Object.defineProperty,ww=Mu("".slice),xw=Mu("".replace),Iw=Mu([].join),Aw=Fu&&!yw(function(){return Ka(function(){},"length",{value:8}).length!==8}),Tw=String(String).split("String"),Ew=Yf.exports=function(r,e,t){ww(Xf(e),0,7)==="Symbol("&&(e="["+xw(Xf(e),/^Symbol\(([^)]*)\)/,"$1")+"]"),t&&t.getter&&(e="get "+e),t&&t.setter&&(e="set "+e),(!$a(r,"name")||kw&&r.name!==e)&&(Fu?Ka(r,"name",{value:e,configurable:!0}):r.name=e),Aw&&t&&$a(t,"arity")&&r.length!==t.arity&&Ka(r,"length",{value:t.arity});try{t&&$a(t,"constructor")&&t.constructor?Fu&&Ka(r,"prototype",{writable:!1}):r.prototype&&(r.prototype=void 0)}catch{}var i=Pw(r);return $a(i,"source")||(i.source=Iw(Tw,typeof e=="string"?e:"")),r};Function.prototype.toString=Ew(function(){return bw(this)&&Cw(this).source||Sw(this)},"toString")});var tr=h((RM,Qf)=>{var Rw=K(),Ow=Ze(),Fw=Uu(),Mw=Oa();Qf.exports=function(r,e,t,i){i||(i={});var n=i.enumerable,o=i.name!==void 0?i.name:e;if(Rw(t)&&Fw(t,o,i),i.global)n?r[e]=t:Mw(e,t);else{try{i.unsafe?r[e]&&(n=!0):delete r[e]}catch{}n?r[e]=t:Ow.f(r,e,{value:t,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return r}});var Lu=h((OM,eg)=>{var Uw=Ea(),Lw=Math.max,Bw=Math.min;eg.exports=function(r,e){var t=Uw(r);return t<0?Lw(t+e,0):Bw(t,e)}});var rg=h((FM,tg)=>{var Dw=Ea(),_w=Math.min;tg.exports=function(r){return r>0?_w(Dw(r),9007199254740991):0}});var Xa=h((MM,ig)=>{var Nw=rg();ig.exports=function(r){return Nw(r.length)}});var og=h((UM,sg)=>{var qw=Hr(),jw=Lu(),Hw=Xa(),ng=function(r){return function(e,t,i){var n=qw(e),o=Hw(n),a=jw(i,o),c;if(r&&t!=t){for(;o>a;)if(c=n[a++],c!=c)return!0}else for(;o>a;a++)if((r||a in n)&&n[a]===t)return r||a||0;return!r&&-1}};sg.exports={includes:ng(!0),indexOf:ng(!1)}});var Du=h((LM,dg)=>{var Ww=$(),Bu=Ce(),Gw=Hr(),Vw=og().indexOf,zw=Va(),ag=Ww([].push);dg.exports=function(r,e){var t=Gw(r),i=0,n=[],o;for(o in t)!Bu(zw,o)&&Bu(t,o)&&ag(n,o);for(;e.length>i;)Bu(t,o=e[i++])&&(~Vw(n,o)||ag(n,o));return n}});var Za=h((BM,lg)=>{lg.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var cg=h(ug=>{var Jw=Du(),$w=Za(),Kw=$w.concat("length","prototype");ug.f=Object.getOwnPropertyNames||function(e){return Jw(e,Kw)}});var _u=h(mg=>{mg.f=Object.getOwnPropertySymbols});var fg=h((NM,pg)=>{var Xw=_n(),Zw=$(),Yw=cg(),Qw=_u(),ex=Xe(),tx=Zw([].concat);pg.exports=Xw("Reflect","ownKeys")||function(e){var t=Yw.f(ex(e)),i=Qw.f;return i?tx(t,i(e)):t}});var vg=h((qM,hg)=>{var gg=Ce(),rx=fg(),ix=Iu(),nx=Ze();hg.exports=function(r,e,t){for(var i=rx(e),n=nx.f,o=ix.f,a=0;a<i.length;a++){var c=i[a];!gg(r,c)&&!(t&&gg(t,c))&&n(r,c,o(e,c))}}});var bg=h((jM,yg)=>{var sx=oe(),ox=K(),ax=/#|\.prototype\./,qn=function(r,e){var t=lx[dx(r)];return t==cx?!0:t==ux?!1:ox(e)?sx(e):!!e},dx=qn.normalize=function(r){return String(r).replace(ax,".").toLowerCase()},lx=qn.data={},ux=qn.NATIVE="N",cx=qn.POLYFILL="P";yg.exports=qn});var jn=h((HM,kg)=>{var Nu=ce(),mx=Iu().f,px=Wa(),fx=tr(),gx=Oa(),hx=vg(),vx=bg();kg.exports=function(r,e){var t=r.target,i=r.global,n=r.stat,o,a,c,p,f,v;if(i?a=Nu:n?a=Nu[t]||gx(t,{}):a=(Nu[t]||{}).prototype,a)for(c in e){if(f=e[c],r.dontCallGetSet?(v=mx(a,c),p=v&&v.value):p=a[c],o=vx(i?c:t+(n?".":"#")+c,r.forced),!o&&p!==void 0){if(typeof f==typeof p)continue;hx(f,p)}(r.sham||p&&p.sham)&&px(f,"sham",!0),fx(a,c,f,r)}}});var qu=h((WM,Sg)=>{var yx=Du(),bx=Za();Sg.exports=Object.keys||function(e){return yx(e,bx)}});var Cg=h(Pg=>{var kx=me(),Sx=du(),Px=Ze(),Cx=Xe(),wx=Hr(),xx=qu();Pg.f=kx&&!Sx?Object.defineProperties:function(e,t){Cx(e);for(var i=wx(t),n=xx(t),o=n.length,a=0,c;o>a;)Px.f(e,c=n[a++],i[c]);return e}});var xg=h((VM,wg)=>{var Ix=_n();wg.exports=Ix("document","documentElement")});var Hn=h((zM,Fg)=>{var Ax=Xe(),Tx=Cg(),Ig=Za(),Ex=Va(),Rx=xg(),Ox=ou(),Fx=Ga(),Ag=">",Tg="<",Hu="prototype",Wu="script",Rg=Fx("IE_PROTO"),ju=function(){},Og=function(r){return Tg+Wu+Ag+r+Tg+"/"+Wu+Ag},Eg=function(r){r.write(Og("")),r.close();var e=r.parentWindow.Object;return r=null,e},Mx=function(){var r=Ox("iframe"),e="java"+Wu+":",t;return r.style.display="none",Rx.appendChild(r),r.src=String(e),t=r.contentWindow.document,t.open(),t.write(Og("document.F=Object")),t.close(),t.F},Ya,Qa=function(){try{Ya=new ActiveXObject("htmlfile")}catch{}Qa=typeof document<"u"?document.domain&&Ya?Eg(Ya):Mx():Eg(Ya);for(var r=Ig.length;r--;)delete Qa[Hu][Ig[r]];return Qa()};Ex[Rg]=!0;Fg.exports=Object.create||function(e,t){var i;return e!==null?(ju[Hu]=Ax(e),i=new ju,ju[Hu]=null,i[Rg]=e):i=Qa(),t===void 0?i:Tx.f(i,t)}});var Ug=h((JM,Mg)=>{var Ux=oe();Mg.exports=!Ux(function(){function r(){}return r.prototype.constructor=null,Object.getPrototypeOf(new r)!==r.prototype})});var Vu=h(($M,Bg)=>{var Lx=Ce(),Bx=K(),Dx=Ln(),_x=Ga(),Nx=Ug(),Lg=_x("IE_PROTO"),Gu=Object,qx=Gu.prototype;Bg.exports=Nx?Gu.getPrototypeOf:function(r){var e=Dx(r);if(Lx(e,Lg))return e[Lg];var t=e.constructor;return Bx(t)&&e instanceof t?t.prototype:e instanceof Gu?qx:null}});var Ku=h((KM,Ng)=>{"use strict";var jx=oe(),Hx=K(),Wx=bt(),Gx=Hn(),Dg=Vu(),Vx=tr(),zx=we(),Jx=_r(),$u=zx("iterator"),_g=!1,st,zu,Ju;[].keys&&(Ju=[].keys(),"next"in Ju?(zu=Dg(Dg(Ju)),zu!==Object.prototype&&(st=zu)):_g=!0);var $x=!Wx(st)||jx(function(){var r={};return st[$u].call(r)!==r});$x?st={}:Jx&&(st=Gx(st));Hx(st[$u])||Vx(st,$u,function(){return this});Ng.exports={IteratorPrototype:st,BUGGY_SAFARI_ITERATORS:_g}});var Wn=h((XM,jg)=>{var Kx=Ze().f,Xx=Ce(),Zx=we(),qg=Zx("toStringTag");jg.exports=function(r,e,t){r&&!t&&(r=r.prototype),r&&!Xx(r,qg)&&Kx(r,qg,{configurable:!0,value:e})}});var Wr=h((ZM,Hg)=>{Hg.exports={}});var Xu=h((YM,Wg)=>{"use strict";var Yx=Ku().IteratorPrototype,Qx=Hn(),eI=qr(),tI=Wn(),rI=Wr(),iI=function(){return this};Wg.exports=function(r,e,t,i){var n=e+" Iterator";return r.prototype=Qx(Yx,{next:eI(+!i,t)}),tI(r,n,!1,!0),rI[n]=iI,r}});var Vg=h((QM,Gg)=>{var nI=K(),sI=String,oI=TypeError;Gg.exports=function(r){if(typeof r=="object"||nI(r))return r;throw oI("Can't set "+sI(r)+" as a prototype")}});var Jg=h((eU,zg)=>{var aI=$(),dI=Xe(),lI=Vg();zg.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var r=!1,e={},t;try{t=aI(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set),t(e,[]),r=e instanceof Array}catch{}return function(n,o){return dI(n),lI(o),r?t(n,o):n.__proto__=o,n}}():void 0)});var Yu=h((tU,ih)=>{"use strict";var uI=jn(),cI=We(),ed=_r(),th=Eu(),mI=K(),pI=Xu(),$g=Vu(),Kg=Jg(),fI=Wn(),gI=Wa(),Zu=tr(),hI=we(),Xg=Wr(),rh=Ku(),vI=th.PROPER,yI=th.CONFIGURABLE,Zg=rh.IteratorPrototype,td=rh.BUGGY_SAFARI_ITERATORS,Gn=hI("iterator"),Yg="keys",Vn="values",Qg="entries",eh=function(){return this};ih.exports=function(r,e,t,i,n,o,a){pI(t,e,i);var c=function(E){if(E===n&&k)return k;if(!td&&E in v)return v[E];switch(E){case Yg:return function(){return new t(this,E)};case Vn:return function(){return new t(this,E)};case Qg:return function(){return new t(this,E)}}return function(){return new t(this)}},p=e+" Iterator",f=!1,v=r.prototype,m=v[Gn]||v["@@iterator"]||n&&v[n],k=!td&&m||c(n),b=e=="Array"&&v.entries||m,C,w,I;if(b&&(C=$g(b.call(new r)),C!==Object.prototype&&C.next&&(!ed&&$g(C)!==Zg&&(Kg?Kg(C,Zg):mI(C[Gn])||Zu(C,Gn,eh)),fI(C,p,!0,!0),ed&&(Xg[p]=eh))),vI&&n==Vn&&m&&m.name!==Vn&&(!ed&&yI?gI(v,"name",Vn):(f=!0,k=function(){return cI(m,this)})),n)if(w={values:c(Vn),keys:o?k:c(Yg),entries:c(Qg)},a)for(I in w)(td||f||!(I in v))&&Zu(v,I,w[I]);else uI({target:e,proto:!0,forced:td||f},w);return(!ed||a)&&v[Gn]!==k&&Zu(v,Gn,k,{name:n}),Xg[e]=k,w}});var Qu=h((rU,nh)=>{nh.exports=function(r,e){return{value:r,done:e}}});var dh=h(()=>{"use strict";var bI=nu().charAt,kI=Dn(),oh=jr(),SI=Yu(),sh=Qu(),ah="String Iterator",PI=oh.set,CI=oh.getterFor(ah);SI(String,"String",function(r){PI(this,{type:ah,string:kI(r),index:0})},function(){var e=CI(this),t=e.string,i=e.index,n;return i>=t.length?sh(void 0,!0):(n=bI(t,i),e.index+=n.length,sh(n,!1))})});var ec=h((sU,lh)=>{var wI=oe(),xI=we(),II=_r(),AI=xI("iterator");lh.exports=!wI(function(){var r=new URL("b?a=1&b=2&c=3","http://a"),e=r.searchParams,t="";return r.pathname="c%20d",e.forEach(function(i,n){e.delete("b"),t+=n+i}),II&&!r.toJSON||!e.sort||r.href!=="http://a/c%20d?a=1&c=3"||e.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!e[AI]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://\u0442\u0435\u0441\u0442").host!=="xn--e1aybc"||new URL("http://a#\u0431").hash!=="#%D0%B1"||t!=="a1c3"||new URL("http://x",void 0).host!=="x"})});var ch=h((oU,uh)=>{var TI=Ba(),EI=$();uh.exports=function(r){if(TI(r)==="Function")return EI(r)}});var rd=h((aU,ph)=>{var mh=ch(),RI=Na(),OI=Ta(),FI=mh(mh.bind);ph.exports=function(r,e){return RI(r),e===void 0?r:OI?FI(r,e):function(){return r.apply(e,arguments)}}});var hh=h((dU,gh)=>{var fh=Uu(),MI=Ze();gh.exports=function(r,e,t){return t.get&&fh(t.get,e,{getter:!0}),t.set&&fh(t.set,e,{setter:!0}),MI.f(r,e,t)}});var tc=h((lU,vh)=>{var UI=uu(),LI=TypeError;vh.exports=function(r,e){if(UI(e,r))return r;throw LI("Incorrect invocation")}});var Sh=h((uU,kh)=>{"use strict";var yh=me(),BI=$(),DI=We(),_I=oe(),rc=qu(),NI=_u(),qI=Cu(),jI=Ln(),HI=xu(),Gr=Object.assign,bh=Object.defineProperty,WI=BI([].concat);kh.exports=!Gr||_I(function(){if(yh&&Gr({b:1},Gr(bh({},"a",{enumerable:!0,get:function(){bh(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var r={},e={},t=Symbol(),i="abcdefghijklmnopqrst";return r[t]=7,i.split("").forEach(function(n){e[n]=n}),Gr({},r)[t]!=7||rc(Gr({},e)).join("")!=i})?function(e,t){for(var i=jI(e),n=arguments.length,o=1,a=NI.f,c=qI.f;n>o;)for(var p=HI(arguments[o++]),f=a?WI(rc(p),a(p)):rc(p),v=f.length,m=0,k;v>m;)k=f[m++],(!yh||DI(c,p,k))&&(i[k]=p[k]);return i}:Gr});var wh=h((cU,Ch)=>{var GI=We(),Ph=Xe(),VI=qa();Ch.exports=function(r,e,t){var i,n;Ph(r);try{if(i=VI(r,"return"),!i){if(e==="throw")throw t;return t}i=GI(i,r)}catch(o){n=!0,i=o}if(e==="throw")throw t;if(n)throw i;return Ph(i),t}});var Ih=h((mU,xh)=>{var zI=Xe(),JI=wh();xh.exports=function(r,e,t,i){try{return i?e(zI(t)[0],t[1]):e(t)}catch(n){JI(r,"throw",n)}}});var Th=h((pU,Ah)=>{var $I=we(),KI=Wr(),XI=$I("iterator"),ZI=Array.prototype;Ah.exports=function(r){return r!==void 0&&(KI.Array===r||ZI[XI]===r)}});var Uh=h((fU,Mh)=>{var YI=$(),QI=oe(),Eh=K(),eA=Bn(),tA=_n(),rA=Ou(),Rh=function(){},iA=[],Oh=tA("Reflect","construct"),ic=/^\s*(?:class|function)\b/,nA=YI(ic.exec),sA=!ic.exec(Rh),zn=function(e){if(!Eh(e))return!1;try{return Oh(Rh,iA,e),!0}catch{return!1}},Fh=function(e){if(!Eh(e))return!1;switch(eA(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return sA||!!nA(ic,rA(e))}catch{return!0}};Fh.sham=!0;Mh.exports=!Oh||QI(function(){var r;return zn(zn.call)||!zn(Object)||!zn(function(){r=!0})||r})?Fh:zn});var nc=h((gU,Lh)=>{"use strict";var oA=ja(),aA=Ze(),dA=qr();Lh.exports=function(r,e,t){var i=oA(e);i in r?aA.f(r,i,dA(0,t)):r[i]=t}});var id=h((hU,Dh)=>{var lA=Bn(),Bh=qa(),uA=Ma(),cA=Wr(),mA=we(),pA=mA("iterator");Dh.exports=function(r){if(!uA(r))return Bh(r,pA)||Bh(r,"@@iterator")||cA[lA(r)]}});var sc=h((vU,_h)=>{var fA=We(),gA=Na(),hA=Xe(),vA=mu(),yA=id(),bA=TypeError;_h.exports=function(r,e){var t=arguments.length<2?yA(r):e;if(gA(t))return hA(fA(t,r));throw bA(vA(r)+" is not iterable")}});var Hh=h((yU,jh)=>{"use strict";var kA=rd(),SA=We(),PA=Ln(),CA=Ih(),wA=Th(),xA=Uh(),IA=Xa(),Nh=nc(),AA=sc(),TA=id(),qh=Array;jh.exports=function(e){var t=PA(e),i=xA(this),n=arguments.length,o=n>1?arguments[1]:void 0,a=o!==void 0;a&&(o=kA(o,n>2?arguments[2]:void 0));var c=TA(t),p=0,f,v,m,k,b,C;if(c&&!(this===qh&&wA(c)))for(k=AA(t,c),b=k.next,v=i?new this:[];!(m=SA(b,k)).done;p++)C=a?CA(k,o,[m.value,p],!0):m.value,Nh(v,p,C);else for(f=IA(t),v=i?new this(f):qh(f);f>p;p++)C=a?o(t[p],p):t[p],Nh(v,p,C);return v.length=p,v}});var oc=h((bU,Gh)=>{var Wh=Lu(),EA=Xa(),RA=nc(),OA=Array,FA=Math.max;Gh.exports=function(r,e,t){for(var i=EA(r),n=Wh(e,i),o=Wh(t===void 0?i:t,i),a=OA(FA(o-n,0)),c=0;n<o;n++,c++)RA(a,c,r[n]);return a.length=c,a}});var Qh=h((kU,Yh)=>{var rr=$(),ac=2147483647,Jn=36,Kh=1,uc=26,MA=38,UA=700,LA=72,BA=128,DA="-",_A=/[^\0-\u007E]/,Xh=/[.\u3002\uFF0E\uFF61]/g,Vh="Overflow: input needs wider integers to process",dc=Jn-Kh,zh=RangeError,NA=rr(Xh.exec),Vr=Math.floor,lc=String.fromCharCode,Jh=rr("".charCodeAt),Zh=rr([].join),kt=rr([].push),qA=rr("".replace),jA=rr("".split),HA=rr("".toLowerCase),WA=function(r){for(var e=[],t=0,i=r.length;t<i;){var n=Jh(r,t++);if(n>=55296&&n<=56319&&t<i){var o=Jh(r,t++);(o&64512)==56320?kt(e,((n&1023)<<10)+(o&1023)+65536):(kt(e,n),t--)}else kt(e,n)}return e},$h=function(r){return r+22+75*(r<26)},GA=function(r,e,t){var i=0;for(r=t?Vr(r/UA):r>>1,r+=Vr(r/e);r>dc*uc>>1;)r=Vr(r/dc),i+=Jn;return Vr(i+(dc+1)*r/(r+MA))},VA=function(r){var e=[];r=WA(r);var t=r.length,i=BA,n=0,o=LA,a,c;for(a=0;a<r.length;a++)c=r[a],c<128&&kt(e,lc(c));var p=e.length,f=p;for(p&&kt(e,DA);f<t;){var v=ac;for(a=0;a<r.length;a++)c=r[a],c>=i&&c<v&&(v=c);var m=f+1;if(v-i>Vr((ac-n)/m))throw zh(Vh);for(n+=(v-i)*m,i=v,a=0;a<r.length;a++){if(c=r[a],c<i&&++n>ac)throw zh(Vh);if(c==i){for(var k=n,b=Jn;;){var C=b<=o?Kh:b>=o+uc?uc:b-o;if(k<C)break;var w=k-C,I=Jn-C;kt(e,lc($h(C+w%I))),k=Vr(w/I),b+=Jn}kt(e,lc($h(k))),o=GA(n,m,f==p),n=0,f++}}n++,i++}return Zh(e,"")};Yh.exports=function(r){var e=[],t=jA(qA(HA(r),Xh,"."),"."),i,n;for(i=0;i<t.length;i++)n=t[i],kt(e,NA(_A,n)?"xn--"+VA(n):n);return Zh(e,".")}});var cc=h((SU,ev)=>{var zA=TypeError;ev.exports=function(r,e){if(r<e)throw zA("Not enough arguments");return r}});var rv=h((PU,tv)=>{var JA=we(),$A=Hn(),KA=Ze().f,mc=JA("unscopables"),pc=Array.prototype;pc[mc]==null&&KA(pc,mc,{configurable:!0,value:$A(null)});tv.exports=function(r){pc[mc][r]=!0}});var dv=h((CU,av)=>{"use strict";var XA=Hr(),fc=rv(),iv=Wr(),sv=jr(),ZA=Ze().f,YA=Yu(),nd=Qu(),QA=_r(),eT=me(),ov="Array Iterator",tT=sv.set,rT=sv.getterFor(ov);av.exports=YA(Array,"Array",function(r,e){tT(this,{type:ov,target:XA(r),index:0,kind:e})},function(){var r=rT(this),e=r.target,t=r.kind,i=r.index++;return!e||i>=e.length?(r.target=void 0,nd(void 0,!0)):t=="keys"?nd(i,!1):t=="values"?nd(e[i],!1):nd([i,e[i]],!1)},"values");var nv=iv.Arguments=iv.Array;fc("keys");fc("values");fc("entries");if(!QA&&eT&&nv.name!=="values")try{ZA(nv,"name",{value:"values"})}catch{}});var uv=h((wU,lv)=>{var iT=tr();lv.exports=function(r,e,t){for(var i in e)iT(r,i,e[i],t);return r}});var pv=h((xU,mv)=>{var cv=oc(),nT=Math.floor,gc=function(r,e){var t=r.length,i=nT(t/2);return t<8?sT(r,e):oT(r,gc(cv(r,0,i),e),gc(cv(r,i),e),e)},sT=function(r,e){for(var t=r.length,i=1,n,o;i<t;){for(o=i,n=r[i];o&&e(r[o-1],n)>0;)r[o]=r[--o];o!==i++&&(r[o]=n)}return r},oT=function(r,e,t,i){for(var n=e.length,o=t.length,a=0,c=0;a<n||c<o;)r[a+c]=a<n&&c<o?i(e[a],t[c])<=0?e[a++]:t[c++]:a<n?e[a++]:t[c++];return r};mv.exports=gc});var xc=h((IU,Mv)=>{"use strict";dv();var kc=jn(),Jr=ce(),sd=We(),Ye=$(),aT=me(),xv=ec(),Iv=tr(),dT=uv(),lT=Wn(),uT=Xu(),Cc=jr(),Av=tc(),hc=K(),cT=Ce(),mT=rd(),pT=Bn(),fT=Xe(),Tv=bt(),pe=Dn(),gT=Hn(),fv=qr(),Sc=sc(),hT=id(),zr=cc(),vT=we(),yT=pv(),bT=vT("iterator"),Xn="URLSearchParams",Ev=Xn+"Iterator",Rv=Cc.set,Ve=Cc.getterFor(Xn),kT=Cc.getterFor(Ev),ST=Object.getOwnPropertyDescriptor,wc=function(r){if(!aT)return Jr[r];var e=ST(Jr,r);return e&&e.value},gv=wc("fetch"),ad=wc("Request"),$n=wc("Headers"),vc=ad&&ad.prototype,hv=$n&&$n.prototype,PT=Jr.RegExp,CT=Jr.TypeError,Ov=Jr.decodeURIComponent,wT=Jr.encodeURIComponent,xT=Ye("".charAt),vv=Ye([].join),ir=Ye([].push),Pc=Ye("".replace),IT=Ye([].shift),yv=Ye([].splice),bv=Ye("".split),AT=Ye("".slice),TT=/\+/g,kv=Array(4),ET=function(r){return kv[r-1]||(kv[r-1]=PT("((?:%[\\da-f]{2}){"+r+"})","gi"))},RT=function(r){try{return Ov(r)}catch{return r}},Sv=function(r){var e=Pc(r,TT," "),t=4;try{return Ov(e)}catch{for(;t;)e=Pc(e,ET(t--),RT);return e}},OT=/[!'()~]|%20/g,FT={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},MT=function(r){return FT[r]},Pv=function(r){return Pc(wT(r),OT,MT)},yc=uT(function(e,t){Rv(this,{type:Ev,iterator:Sc(Ve(e).entries),kind:t})},"Iterator",function(){var e=kT(this),t=e.kind,i=e.iterator.next(),n=i.value;return i.done||(i.value=t==="keys"?n.key:t==="values"?n.value:[n.key,n.value]),i},!0),Fv=function(r){this.entries=[],this.url=null,r!==void 0&&(Tv(r)?this.parseObject(r):this.parseQuery(typeof r=="string"?xT(r,0)==="?"?AT(r,1):r:pe(r)))};Fv.prototype={type:Xn,bindURL:function(r){this.url=r,this.update()},parseObject:function(r){var e=hT(r),t,i,n,o,a,c,p;if(e)for(t=Sc(r,e),i=t.next;!(n=sd(i,t)).done;){if(o=Sc(fT(n.value)),a=o.next,(c=sd(a,o)).done||(p=sd(a,o)).done||!sd(a,o).done)throw CT("Expected sequence with length 2");ir(this.entries,{key:pe(c.value),value:pe(p.value)})}else for(var f in r)cT(r,f)&&ir(this.entries,{key:f,value:pe(r[f])})},parseQuery:function(r){if(r)for(var e=bv(r,"&"),t=0,i,n;t<e.length;)i=e[t++],i.length&&(n=bv(i,"="),ir(this.entries,{key:Sv(IT(n)),value:Sv(vv(n,"="))}))},serialize:function(){for(var r=this.entries,e=[],t=0,i;t<r.length;)i=r[t++],ir(e,Pv(i.key)+"="+Pv(i.value));return vv(e,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var dd=function(){Av(this,Kn);var e=arguments.length>0?arguments[0]:void 0;Rv(this,new Fv(e))},Kn=dd.prototype;dT(Kn,{append:function(e,t){zr(arguments.length,2);var i=Ve(this);ir(i.entries,{key:pe(e),value:pe(t)}),i.updateURL()},delete:function(r){zr(arguments.length,1);for(var e=Ve(this),t=e.entries,i=pe(r),n=0;n<t.length;)t[n].key===i?yv(t,n,1):n++;e.updateURL()},get:function(e){zr(arguments.length,1);for(var t=Ve(this).entries,i=pe(e),n=0;n<t.length;n++)if(t[n].key===i)return t[n].value;return null},getAll:function(e){zr(arguments.length,1);for(var t=Ve(this).entries,i=pe(e),n=[],o=0;o<t.length;o++)t[o].key===i&&ir(n,t[o].value);return n},has:function(e){zr(arguments.length,1);for(var t=Ve(this).entries,i=pe(e),n=0;n<t.length;)if(t[n++].key===i)return!0;return!1},set:function(e,t){zr(arguments.length,1);for(var i=Ve(this),n=i.entries,o=!1,a=pe(e),c=pe(t),p=0,f;p<n.length;p++)f=n[p],f.key===a&&(o?yv(n,p--,1):(o=!0,f.value=c));o||ir(n,{key:a,value:c}),i.updateURL()},sort:function(){var e=Ve(this);yT(e.entries,function(t,i){return t.key>i.key?1:-1}),e.updateURL()},forEach:function(e){for(var t=Ve(this).entries,i=mT(e,arguments.length>1?arguments[1]:void 0),n=0,o;n<t.length;)o=t[n++],i(o.value,o.key,this)},keys:function(){return new yc(this,"keys")},values:function(){return new yc(this,"values")},entries:function(){return new yc(this,"entries")}},{enumerable:!0});Iv(Kn,bT,Kn.entries,{name:"entries"});Iv(Kn,"toString",function(){return Ve(this).serialize()},{enumerable:!0});lT(dd,Xn);kc({global:!0,constructor:!0,forced:!xv},{URLSearchParams:dd});!xv&&hc($n)&&(Cv=Ye(hv.has),wv=Ye(hv.set),bc=function(r){if(Tv(r)){var e=r.body,t;if(pT(e)===Xn)return t=r.headers?new $n(r.headers):new $n,Cv(t,"content-type")||wv(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),gT(r,{body:fv(0,pe(e)),headers:fv(0,t)})}return r},hc(gv)&&kc({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return gv(e,arguments.length>1?bc(arguments[1]):{})}}),hc(ad)&&(od=function(e){return Av(this,vc),new ad(e,arguments.length>1?bc(arguments[1]):{})},vc.constructor=od,od.prototype=vc,kc({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:od})));var Cv,wv,bc,od;Mv.exports={URLSearchParams:dd,getState:Ve}});var Yv=h(()=>{"use strict";dh();var UT=jn(),jc=me(),LT=ec(),Hc=ce(),Uv=rd(),Ee=$(),pd=tr(),xe=hh(),BT=tc(),_c=Ce(),Wc=Sh(),$r=Hh(),ze=oc(),DT=nu().codeAt,_T=Qh(),at=Dn(),NT=Wn(),qT=cc(),zv=xc(),Jv=jr(),jT=Jv.set,fd=Jv.getterFor("URL"),HT=zv.URLSearchParams,WT=zv.getState,Zn=Hc.URL,Nc=Hc.TypeError,gd=Hc.parseInt,GT=Math.floor,Lv=Math.pow,Te=Ee("".charAt),Je=Ee(/./.exec),Qn=Ee([].join),VT=Ee(1 .toString),zT=Ee([].pop),Xr=Ee([].push),Bv=Ee("".replace),JT=Ee([].shift),$T=Ee("".split),ts=Ee("".slice),hd=Ee("".toLowerCase),KT=Ee([].unshift),XT="Invalid authority",Ic="Invalid scheme",nr="Invalid host",Dv="Invalid port",$v=/[a-z]/i,ZT=/[\d+-.a-z]/i,qc=/\d/,YT=/^0x/i,QT=/^[0-7]+$/,e0=/^\d+$/,Kv=/^[\da-f]+$/i,t0=/[\0\t\n\r #%/:<>?@[\\\]^|]/,r0=/[\0\t\n\r #/:<>?@[\\\]^|]/,i0=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,n0=/[\t\n\r]/g,Ie,s0=function(r){var e=$T(r,"."),t,i,n,o,a,c,p;if(e.length&&e[e.length-1]==""&&e.length--,t=e.length,t>4)return r;for(i=[],n=0;n<t;n++){if(o=e[n],o=="")return r;if(a=10,o.length>1&&Te(o,0)=="0"&&(a=Je(YT,o)?16:8,o=ts(o,a==8?1:2)),o==="")c=0;else{if(!Je(a==10?e0:a==8?QT:Kv,o))return r;c=gd(o,a)}Xr(i,c)}for(n=0;n<t;n++)if(c=i[n],n==t-1){if(c>=Lv(256,5-t))return null}else if(c>255)return null;for(p=zT(i),n=0;n<i.length;n++)p+=i[n]*Lv(256,3-n);return p},o0=function(r){var e=[0,0,0,0,0,0,0,0],t=0,i=null,n=0,o,a,c,p,f,v,m,k=function(){return Te(r,n)};if(k()==":"){if(Te(r,1)!=":")return;n+=2,t++,i=t}for(;k();){if(t==8)return;if(k()==":"){if(i!==null)return;n++,t++,i=t;continue}for(o=a=0;a<4&&Je(Kv,k());)o=o*16+gd(k(),16),n++,a++;if(k()=="."){if(a==0||(n-=a,t>6))return;for(c=0;k();){if(p=null,c>0)if(k()=="."&&c<4)n++;else return;if(!Je(qc,k()))return;for(;Je(qc,k());){if(f=gd(k(),10),p===null)p=f;else{if(p==0)return;p=p*10+f}if(p>255)return;n++}e[t]=e[t]*256+p,c++,(c==2||c==4)&&t++}if(c!=4)return;break}else if(k()==":"){if(n++,!k())return}else if(k())return;e[t++]=o}if(i!==null)for(v=t-i,t=7;t!=0&&v>0;)m=e[t],e[t--]=e[i+v-1],e[i+--v]=m;else if(t!=8)return;return e},a0=function(r){for(var e=null,t=1,i=null,n=0,o=0;o<8;o++)r[o]!==0?(n>t&&(e=i,t=n),i=null,n=0):(i===null&&(i=o),++n);return n>t&&(e=i,t=n),e},Yn=function(r){var e,t,i,n;if(typeof r=="number"){for(e=[],t=0;t<4;t++)KT(e,r%256),r=GT(r/256);return Qn(e,".")}else if(typeof r=="object"){for(e="",i=a0(r),t=0;t<8;t++)n&&r[t]===0||(n&&(n=!1),i===t?(e+=t?":":"::",n=!0):(e+=VT(r[t],16),t<7&&(e+=":")));return"["+e+"]"}return r},md={},Xv=Wc({},md,{" ":1,'"':1,"<":1,">":1,"`":1}),Zv=Wc({},Xv,{"#":1,"?":1,"{":1,"}":1}),Ac=Wc({},Zv,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),St=function(r,e){var t=DT(r,0);return t>32&&t<127&&!_c(e,r)?r:encodeURIComponent(r)},ld={ftp:21,file:null,http:80,https:443,ws:80,wss:443},es=function(r,e){var t;return r.length==2&&Je($v,Te(r,0))&&((t=Te(r,1))==":"||!e&&t=="|")},_v=function(r){var e;return r.length>1&&es(ts(r,0,2))&&(r.length==2||(e=Te(r,2))==="/"||e==="\\"||e==="?"||e==="#")},d0=function(r){return r==="."||hd(r)==="%2e"},l0=function(r){return r=hd(r),r===".."||r==="%2e."||r===".%2e"||r==="%2e%2e"},Tc={},Nv={},Ec={},qv={},jv={},Rc={},Hv={},Wv={},ud={},cd={},Oc={},Fc={},Mc={},Uc={},Gv={},Lc={},Kr={},Qe={},Vv={},sr={},ot={},Gc=function(r,e,t){var i=at(r),n,o,a;if(e){if(o=this.parse(i),o)throw Nc(o);this.searchParams=null}else{if(t!==void 0&&(n=new Gc(t,!0)),o=this.parse(i,null,n),o)throw Nc(o);a=WT(new HT),a.bindURL(this),this.searchParams=a}};Gc.prototype={type:"URL",parse:function(r,e,t){var i=this,n=e||Tc,o=0,a="",c=!1,p=!1,f=!1,v,m,k,b;for(r=at(r),e||(i.scheme="",i.username="",i.password="",i.host=null,i.port=null,i.path=[],i.query=null,i.fragment=null,i.cannotBeABaseURL=!1,r=Bv(r,i0,"")),r=Bv(r,n0,""),v=$r(r);o<=v.length;){switch(m=v[o],n){case Tc:if(m&&Je($v,m))a+=hd(m),n=Nv;else{if(e)return Ic;n=Ec;continue}break;case Nv:if(m&&(Je(ZT,m)||m=="+"||m=="-"||m=="."))a+=hd(m);else if(m==":"){if(e&&(i.isSpecial()!=_c(ld,a)||a=="file"&&(i.includesCredentials()||i.port!==null)||i.scheme=="file"&&!i.host))return;if(i.scheme=a,e){i.isSpecial()&&ld[i.scheme]==i.port&&(i.port=null);return}a="",i.scheme=="file"?n=Uc:i.isSpecial()&&t&&t.scheme==i.scheme?n=qv:i.isSpecial()?n=Wv:v[o+1]=="/"?(n=jv,o++):(i.cannotBeABaseURL=!0,Xr(i.path,""),n=Vv)}else{if(e)return Ic;a="",n=Ec,o=0;continue}break;case Ec:if(!t||t.cannotBeABaseURL&&m!="#")return Ic;if(t.cannotBeABaseURL&&m=="#"){i.scheme=t.scheme,i.path=ze(t.path),i.query=t.query,i.fragment="",i.cannotBeABaseURL=!0,n=ot;break}n=t.scheme=="file"?Uc:Rc;continue;case qv:if(m=="/"&&v[o+1]=="/")n=ud,o++;else{n=Rc;continue}break;case jv:if(m=="/"){n=cd;break}else{n=Qe;continue}case Rc:if(i.scheme=t.scheme,m==Ie)i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,i.path=ze(t.path),i.query=t.query;else if(m=="/"||m=="\\"&&i.isSpecial())n=Hv;else if(m=="?")i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,i.path=ze(t.path),i.query="",n=sr;else if(m=="#")i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,i.path=ze(t.path),i.query=t.query,i.fragment="",n=ot;else{i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,i.path=ze(t.path),i.path.length--,n=Qe;continue}break;case Hv:if(i.isSpecial()&&(m=="/"||m=="\\"))n=ud;else if(m=="/")n=cd;else{i.username=t.username,i.password=t.password,i.host=t.host,i.port=t.port,n=Qe;continue}break;case Wv:if(n=ud,m!="/"||Te(a,o+1)!="/")continue;o++;break;case ud:if(m!="/"&&m!="\\"){n=cd;continue}break;case cd:if(m=="@"){c&&(a="%40"+a),c=!0,k=$r(a);for(var C=0;C<k.length;C++){var w=k[C];if(w==":"&&!f){f=!0;continue}var I=St(w,Ac);f?i.password+=I:i.username+=I}a=""}else if(m==Ie||m=="/"||m=="?"||m=="#"||m=="\\"&&i.isSpecial()){if(c&&a=="")return XT;o-=$r(a).length+1,a="",n=Oc}else a+=m;break;case Oc:case Fc:if(e&&i.scheme=="file"){n=Lc;continue}else if(m==":"&&!p){if(a=="")return nr;if(b=i.parseHost(a),b)return b;if(a="",n=Mc,e==Fc)return}else if(m==Ie||m=="/"||m=="?"||m=="#"||m=="\\"&&i.isSpecial()){if(i.isSpecial()&&a=="")return nr;if(e&&a==""&&(i.includesCredentials()||i.port!==null))return;if(b=i.parseHost(a),b)return b;if(a="",n=Kr,e)return;continue}else m=="["?p=!0:m=="]"&&(p=!1),a+=m;break;case Mc:if(Je(qc,m))a+=m;else if(m==Ie||m=="/"||m=="?"||m=="#"||m=="\\"&&i.isSpecial()||e){if(a!=""){var E=gd(a,10);if(E>65535)return Dv;i.port=i.isSpecial()&&E===ld[i.scheme]?null:E,a=""}if(e)return;n=Kr;continue}else return Dv;break;case Uc:if(i.scheme="file",m=="/"||m=="\\")n=Gv;else if(t&&t.scheme=="file")if(m==Ie)i.host=t.host,i.path=ze(t.path),i.query=t.query;else if(m=="?")i.host=t.host,i.path=ze(t.path),i.query="",n=sr;else if(m=="#")i.host=t.host,i.path=ze(t.path),i.query=t.query,i.fragment="",n=ot;else{_v(Qn(ze(v,o),""))||(i.host=t.host,i.path=ze(t.path),i.shortenPath()),n=Qe;continue}else{n=Qe;continue}break;case Gv:if(m=="/"||m=="\\"){n=Lc;break}t&&t.scheme=="file"&&!_v(Qn(ze(v,o),""))&&(es(t.path[0],!0)?Xr(i.path,t.path[0]):i.host=t.host),n=Qe;continue;case Lc:if(m==Ie||m=="/"||m=="\\"||m=="?"||m=="#"){if(!e&&es(a))n=Qe;else if(a==""){if(i.host="",e)return;n=Kr}else{if(b=i.parseHost(a),b)return b;if(i.host=="localhost"&&(i.host=""),e)return;a="",n=Kr}continue}else a+=m;break;case Kr:if(i.isSpecial()){if(n=Qe,m!="/"&&m!="\\")continue}else if(!e&&m=="?")i.query="",n=sr;else if(!e&&m=="#")i.fragment="",n=ot;else if(m!=Ie&&(n=Qe,m!="/"))continue;break;case Qe:if(m==Ie||m=="/"||m=="\\"&&i.isSpecial()||!e&&(m=="?"||m=="#")){if(l0(a)?(i.shortenPath(),m!="/"&&!(m=="\\"&&i.isSpecial())&&Xr(i.path,"")):d0(a)?m!="/"&&!(m=="\\"&&i.isSpecial())&&Xr(i.path,""):(i.scheme=="file"&&!i.path.length&&es(a)&&(i.host&&(i.host=""),a=Te(a,0)+":"),Xr(i.path,a)),a="",i.scheme=="file"&&(m==Ie||m=="?"||m=="#"))for(;i.path.length>1&&i.path[0]==="";)JT(i.path);m=="?"?(i.query="",n=sr):m=="#"&&(i.fragment="",n=ot)}else a+=St(m,Zv);break;case Vv:m=="?"?(i.query="",n=sr):m=="#"?(i.fragment="",n=ot):m!=Ie&&(i.path[0]+=St(m,md));break;case sr:!e&&m=="#"?(i.fragment="",n=ot):m!=Ie&&(m=="'"&&i.isSpecial()?i.query+="%27":m=="#"?i.query+="%23":i.query+=St(m,md));break;case ot:m!=Ie&&(i.fragment+=St(m,Xv));break}o++}},parseHost:function(r){var e,t,i;if(Te(r,0)=="["){if(Te(r,r.length-1)!="]"||(e=o0(ts(r,1,-1)),!e))return nr;this.host=e}else if(this.isSpecial()){if(r=_T(r),Je(t0,r)||(e=s0(r),e===null))return nr;this.host=e}else{if(Je(r0,r))return nr;for(e="",t=$r(r),i=0;i<t.length;i++)e+=St(t[i],md);this.host=e}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme=="file"},includesCredentials:function(){return this.username!=""||this.password!=""},isSpecial:function(){return _c(ld,this.scheme)},shortenPath:function(){var r=this.path,e=r.length;e&&(this.scheme!="file"||e!=1||!es(r[0],!0))&&r.length--},serialize:function(){var r=this,e=r.scheme,t=r.username,i=r.password,n=r.host,o=r.port,a=r.path,c=r.query,p=r.fragment,f=e+":";return n!==null?(f+="//",r.includesCredentials()&&(f+=t+(i?":"+i:"")+"@"),f+=Yn(n),o!==null&&(f+=":"+o)):e=="file"&&(f+="//"),f+=r.cannotBeABaseURL?a[0]:a.length?"/"+Qn(a,"/"):"",c!==null&&(f+="?"+c),p!==null&&(f+="#"+p),f},setHref:function(r){var e=this.parse(r);if(e)throw Nc(e);this.searchParams.update()},getOrigin:function(){var r=this.scheme,e=this.port;if(r=="blob")try{return new Zr(r.path[0]).origin}catch{return"null"}return r=="file"||!this.isSpecial()?"null":r+"://"+Yn(this.host)+(e!==null?":"+e:"")},getProtocol:function(){return this.scheme+":"},setProtocol:function(r){this.parse(at(r)+":",Tc)},getUsername:function(){return this.username},setUsername:function(r){var e=$r(at(r));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var t=0;t<e.length;t++)this.username+=St(e[t],Ac)}},getPassword:function(){return this.password},setPassword:function(r){var e=$r(at(r));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var t=0;t<e.length;t++)this.password+=St(e[t],Ac)}},getHost:function(){var r=this.host,e=this.port;return r===null?"":e===null?Yn(r):Yn(r)+":"+e},setHost:function(r){this.cannotBeABaseURL||this.parse(r,Oc)},getHostname:function(){var r=this.host;return r===null?"":Yn(r)},setHostname:function(r){this.cannotBeABaseURL||this.parse(r,Fc)},getPort:function(){var r=this.port;return r===null?"":at(r)},setPort:function(r){this.cannotHaveUsernamePasswordPort()||(r=at(r),r==""?this.port=null:this.parse(r,Mc))},getPathname:function(){var r=this.path;return this.cannotBeABaseURL?r[0]:r.length?"/"+Qn(r,"/"):""},setPathname:function(r){this.cannotBeABaseURL||(this.path=[],this.parse(r,Kr))},getSearch:function(){var r=this.query;return r?"?"+r:""},setSearch:function(r){r=at(r),r==""?this.query=null:(Te(r,0)=="?"&&(r=ts(r,1)),this.query="",this.parse(r,sr)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var r=this.fragment;return r?"#"+r:""},setHash:function(r){if(r=at(r),r==""){this.fragment=null;return}Te(r,0)=="#"&&(r=ts(r,1)),this.fragment="",this.parse(r,ot)},update:function(){this.query=this.searchParams.serialize()||null}};var Zr=function(e){var t=BT(this,ee),i=qT(arguments.length,1)>1?arguments[1]:void 0,n=jT(t,new Gc(e,!1,i));jc||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},ee=Zr.prototype,Ae=function(r,e){return{get:function(){return fd(this)[r]()},set:e&&function(t){return fd(this)[e](t)},configurable:!0,enumerable:!0}};jc&&(xe(ee,"href",Ae("serialize","setHref")),xe(ee,"origin",Ae("getOrigin")),xe(ee,"protocol",Ae("getProtocol","setProtocol")),xe(ee,"username",Ae("getUsername","setUsername")),xe(ee,"password",Ae("getPassword","setPassword")),xe(ee,"host",Ae("getHost","setHost")),xe(ee,"hostname",Ae("getHostname","setHostname")),xe(ee,"port",Ae("getPort","setPort")),xe(ee,"pathname",Ae("getPathname","setPathname")),xe(ee,"search",Ae("getSearch","setSearch")),xe(ee,"searchParams",Ae("getSearchParams")),xe(ee,"hash",Ae("getHash","setHash")));pd(ee,"toJSON",function(){return fd(this).serialize()},{enumerable:!0});pd(ee,"toString",function(){return fd(this).serialize()},{enumerable:!0});Zn&&(Bc=Zn.createObjectURL,Dc=Zn.revokeObjectURL,Bc&&pd(Zr,"createObjectURL",Uv(Bc,Zn)),Dc&&pd(Zr,"revokeObjectURL",Uv(Dc,Zn)));var Bc,Dc;NT(Zr,"URL");UT({global:!0,constructor:!0,forced:!LT,sham:!jc},{URL:Zr})});var Qv=h(()=>{Yv()});var ey=h(()=>{"use strict";var u0=jn(),c0=We();u0({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return c0(URL.prototype.toString,this)}})});var ty=h(()=>{xc()});var iy=h((LU,ry)=>{var m0=ce();ry.exports=m0});var sy=h((BU,ny)=>{Qv();ey();ty();var p0=iy();ny.exports=p0.URL});var hm=h((s_,pb)=>{var EE=Object.prototype.toString;pb.exports=function(e){if(e===void 0)return"undefined";if(e===null)return"null";var t=typeof e;if(t==="boolean")return"boolean";if(t==="string")return"string";if(t==="number")return"number";if(t==="symbol")return"symbol";if(t==="function")return UE(e)?"generatorfunction":"function";if(RE(e))return"array";if(DE(e))return"buffer";if(BE(e))return"arguments";if(FE(e))return"date";if(OE(e))return"error";if(ME(e))return"regexp";switch(mb(e)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(LE(e))return"generator";switch(t=EE.call(e),t){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return t.slice(8,-1).toLowerCase().replace(/\s/g,"")};function mb(r){return typeof r.constructor=="function"?r.constructor.name:null}function RE(r){return Array.isArray?Array.isArray(r):r instanceof Array}function OE(r){return r instanceof Error||typeof r.message=="string"&&r.constructor&&typeof r.constructor.stackTraceLimit=="number"}function FE(r){return r instanceof Date?!0:typeof r.toDateString=="function"&&typeof r.getDate=="function"&&typeof r.setDate=="function"}function ME(r){return r instanceof RegExp?!0:typeof r.flags=="string"&&typeof r.ignoreCase=="boolean"&&typeof r.multiline=="boolean"&&typeof r.global=="boolean"}function UE(r,e){return mb(r)==="GeneratorFunction"}function LE(r){return typeof r.throw=="function"&&typeof r.return=="function"&&typeof r.next=="function"}function BE(r){try{if(typeof r.length=="number"&&typeof r.callee=="function")return!0}catch(e){if(e.message.indexOf("callee")!==-1)return!0}return!1}function DE(r){return r.constructor&&typeof r.constructor.isBuffer=="function"?r.constructor.isBuffer(r):!1}});var hb=h((o_,gb)=>{"use strict";var fb=Symbol.prototype.valueOf,_E=hm();function NE(r,e){switch(_E(r)){case"array":return r.slice();case"object":return Object.assign({},r);case"date":return new r.constructor(Number(r));case"map":return new Map(r);case"set":return new Set(r);case"buffer":return WE(r);case"symbol":return GE(r);case"arraybuffer":return jE(r);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return HE(r);case"regexp":return qE(r);case"error":return Object.create(r);default:return r}}function qE(r){let e=r.flags!==void 0?r.flags:/\w+$/.exec(r)||void 0,t=new r.constructor(r.source,e);return t.lastIndex=r.lastIndex,t}function jE(r){let e=new r.constructor(r.byteLength);return new Uint8Array(e).set(new Uint8Array(r)),e}function HE(r,e){return new r.constructor(r.buffer,r.byteOffset,r.length)}function WE(r){let e=r.length,t=Buffer.allocUnsafe?Buffer.allocUnsafe(e):Buffer.from(e);return r.copy(t),t}function GE(r){return fb?Object(fb.call(r)):{}}gb.exports=NE});var yb=h((a_,vb)=>{"use strict";vb.exports=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1}});var Sb=h((d_,kb)=>{"use strict";var VE=yb();function bb(r){return VE(r)===!0&&Object.prototype.toString.call(r)==="[object Object]"}kb.exports=function(e){var t,i;return!(bb(e)===!1||(t=e.constructor,typeof t!="function")||(i=t.prototype,bb(i)===!1)||i.hasOwnProperty("isPrototypeOf")===!1)}});var Cb=h((l_,Pb)=>{"use strict";var zE=hb(),JE=hm(),$E=Sb();function vm(r,e){switch(JE(r)){case"object":return KE(r,e);case"array":return XE(r,e);default:return zE(r)}}function KE(r,e){if(typeof e=="function")return e(r);if(e||$E(r)){let t=new r.constructor;for(let i in r)t[i]=vm(r[i],e);return t}return r}function XE(r,e){let t=new r.constructor(r.length);for(let i=0;i<r.length;i++)t[i]=vm(r[i],e);return t}Pb.exports=vm});var Qd=h((hs,ki)=>{var ZE=200,Tm="__lodash_hash_undefined__",Kd=1,Lb=2,Bb=9007199254740991,Hd="[object Arguments]",Sm="[object Array]",YE="[object AsyncFunction]",Db="[object Boolean]",_b="[object Date]",Nb="[object Error]",qb="[object Function]",QE="[object GeneratorFunction]",Wd="[object Map]",jb="[object Number]",eR="[object Null]",bi="[object Object]",wb="[object Promise]",tR="[object Proxy]",Hb="[object RegExp]",Gd="[object Set]",Wb="[object String]",rR="[object Symbol]",iR="[object Undefined]",Pm="[object WeakMap]",Gb="[object ArrayBuffer]",Vd="[object DataView]",nR="[object Float32Array]",sR="[object Float64Array]",oR="[object Int8Array]",aR="[object Int16Array]",dR="[object Int32Array]",lR="[object Uint8Array]",uR="[object Uint8ClampedArray]",cR="[object Uint16Array]",mR="[object Uint32Array]",pR=/[\\^$.*+?()[\]{}|]/g,fR=/^\[object .+?Constructor\]$/,gR=/^(?:0|[1-9]\d*)$/,q={};q[nR]=q[sR]=q[oR]=q[aR]=q[dR]=q[lR]=q[uR]=q[cR]=q[mR]=!0;q[Hd]=q[Sm]=q[Gb]=q[Db]=q[Vd]=q[_b]=q[Nb]=q[qb]=q[Wd]=q[jb]=q[bi]=q[Hb]=q[Gd]=q[Wb]=q[Pm]=!1;var Vb=typeof global=="object"&&global&&global.Object===Object&&global,hR=typeof self=="object"&&self&&self.Object===Object&&self,ct=Vb||hR||Function("return this")(),zb=typeof hs=="object"&&hs&&!hs.nodeType&&hs,xb=zb&&typeof ki=="object"&&ki&&!ki.nodeType&&ki,Jb=xb&&xb.exports===zb,ym=Jb&&Vb.process,Ib=function(){try{return ym&&ym.binding&&ym.binding("util")}catch{}}(),Ab=Ib&&Ib.isTypedArray;function vR(r,e){for(var t=-1,i=r==null?0:r.length,n=0,o=[];++t<i;){var a=r[t];e(a,t,r)&&(o[n++]=a)}return o}function yR(r,e){for(var t=-1,i=e.length,n=r.length;++t<i;)r[n+t]=e[t];return r}function bR(r,e){for(var t=-1,i=r==null?0:r.length;++t<i;)if(e(r[t],t,r))return!0;return!1}function kR(r,e){for(var t=-1,i=Array(r);++t<r;)i[t]=e(t);return i}function SR(r){return function(e){return r(e)}}function PR(r,e){return r.has(e)}function CR(r,e){return r?.[e]}function wR(r){var e=-1,t=Array(r.size);return r.forEach(function(i,n){t[++e]=[n,i]}),t}function xR(r,e){return function(t){return r(e(t))}}function IR(r){var e=-1,t=Array(r.size);return r.forEach(function(i){t[++e]=i}),t}var AR=Array.prototype,TR=Function.prototype,Xd=Object.prototype,bm=ct["__core-js_shared__"],$b=TR.toString,et=Xd.hasOwnProperty,Tb=function(){var r=/[^.]+$/.exec(bm&&bm.keys&&bm.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}(),Kb=Xd.toString,ER=RegExp("^"+$b.call(et).replace(pR,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Eb=Jb?ct.Buffer:void 0,zd=ct.Symbol,Rb=ct.Uint8Array,Xb=Xd.propertyIsEnumerable,RR=AR.splice,gr=zd?zd.toStringTag:void 0,Ob=Object.getOwnPropertySymbols,OR=Eb?Eb.isBuffer:void 0,FR=xR(Object.keys,Object),Cm=Si(ct,"DataView"),vs=Si(ct,"Map"),wm=Si(ct,"Promise"),xm=Si(ct,"Set"),Im=Si(ct,"WeakMap"),ys=Si(Object,"create"),MR=yr(Cm),UR=yr(vs),LR=yr(wm),BR=yr(xm),DR=yr(Im),Fb=zd?zd.prototype:void 0,km=Fb?Fb.valueOf:void 0;function hr(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var i=r[e];this.set(i[0],i[1])}}function _R(){this.__data__=ys?ys(null):{},this.size=0}function NR(r){var e=this.has(r)&&delete this.__data__[r];return this.size-=e?1:0,e}function qR(r){var e=this.__data__;if(ys){var t=e[r];return t===Tm?void 0:t}return et.call(e,r)?e[r]:void 0}function jR(r){var e=this.__data__;return ys?e[r]!==void 0:et.call(e,r)}function HR(r,e){var t=this.__data__;return this.size+=this.has(r)?0:1,t[r]=ys&&e===void 0?Tm:e,this}hr.prototype.clear=_R;hr.prototype.delete=NR;hr.prototype.get=qR;hr.prototype.has=jR;hr.prototype.set=HR;function mt(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var i=r[e];this.set(i[0],i[1])}}function WR(){this.__data__=[],this.size=0}function GR(r){var e=this.__data__,t=Zd(e,r);if(t<0)return!1;var i=e.length-1;return t==i?e.pop():RR.call(e,t,1),--this.size,!0}function VR(r){var e=this.__data__,t=Zd(e,r);return t<0?void 0:e[t][1]}function zR(r){return Zd(this.__data__,r)>-1}function JR(r,e){var t=this.__data__,i=Zd(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}mt.prototype.clear=WR;mt.prototype.delete=GR;mt.prototype.get=VR;mt.prototype.has=zR;mt.prototype.set=JR;function vr(r){var e=-1,t=r==null?0:r.length;for(this.clear();++e<t;){var i=r[e];this.set(i[0],i[1])}}function $R(){this.size=0,this.__data__={hash:new hr,map:new(vs||mt),string:new hr}}function KR(r){var e=Yd(this,r).delete(r);return this.size-=e?1:0,e}function XR(r){return Yd(this,r).get(r)}function ZR(r){return Yd(this,r).has(r)}function YR(r,e){var t=Yd(this,r),i=t.size;return t.set(r,e),this.size+=t.size==i?0:1,this}vr.prototype.clear=$R;vr.prototype.delete=KR;vr.prototype.get=XR;vr.prototype.has=ZR;vr.prototype.set=YR;function Jd(r){var e=-1,t=r==null?0:r.length;for(this.__data__=new vr;++e<t;)this.add(r[e])}function QR(r){return this.__data__.set(r,Tm),this}function eO(r){return this.__data__.has(r)}Jd.prototype.add=Jd.prototype.push=QR;Jd.prototype.has=eO;function Ot(r){var e=this.__data__=new mt(r);this.size=e.size}function tO(){this.__data__=new mt,this.size=0}function rO(r){var e=this.__data__,t=e.delete(r);return this.size=e.size,t}function iO(r){return this.__data__.get(r)}function nO(r){return this.__data__.has(r)}function sO(r,e){var t=this.__data__;if(t instanceof mt){var i=t.__data__;if(!vs||i.length<ZE-1)return i.push([r,e]),this.size=++t.size,this;t=this.__data__=new vr(i)}return t.set(r,e),this.size=t.size,this}Ot.prototype.clear=tO;Ot.prototype.delete=rO;Ot.prototype.get=iO;Ot.prototype.has=nO;Ot.prototype.set=sO;function oO(r,e){var t=$d(r),i=!t&&SO(r),n=!t&&!i&&Am(r),o=!t&&!i&&!n&&ik(r),a=t||i||n||o,c=a?kR(r.length,String):[],p=c.length;for(var f in r)(e||et.call(r,f))&&!(a&&(f=="length"||n&&(f=="offset"||f=="parent")||o&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||hO(f,p)))&&c.push(f);return c}function Zd(r,e){for(var t=r.length;t--;)if(Qb(r[t][0],e))return t;return-1}function aO(r,e,t){var i=e(r);return $d(r)?i:yR(i,t(r))}function ks(r){return r==null?r===void 0?iR:eR:gr&&gr in Object(r)?fO(r):kO(r)}function Mb(r){return bs(r)&&ks(r)==Hd}function Zb(r,e,t,i,n){return r===e?!0:r==null||e==null||!bs(r)&&!bs(e)?r!==r&&e!==e:dO(r,e,t,i,Zb,n)}function dO(r,e,t,i,n,o){var a=$d(r),c=$d(e),p=a?Sm:Rt(r),f=c?Sm:Rt(e);p=p==Hd?bi:p,f=f==Hd?bi:f;var v=p==bi,m=f==bi,k=p==f;if(k&&Am(r)){if(!Am(e))return!1;a=!0,v=!1}if(k&&!v)return o||(o=new Ot),a||ik(r)?Yb(r,e,t,i,n,o):mO(r,e,p,t,i,n,o);if(!(t&Kd)){var b=v&&et.call(r,"__wrapped__"),C=m&&et.call(e,"__wrapped__");if(b||C){var w=b?r.value():r,I=C?e.value():e;return o||(o=new Ot),n(w,I,t,i,o)}}return k?(o||(o=new Ot),pO(r,e,t,i,n,o)):!1}function lO(r){if(!rk(r)||yO(r))return!1;var e=ek(r)?ER:fR;return e.test(yr(r))}function uO(r){return bs(r)&&tk(r.length)&&!!q[ks(r)]}function cO(r){if(!bO(r))return FR(r);var e=[];for(var t in Object(r))et.call(r,t)&&t!="constructor"&&e.push(t);return e}function Yb(r,e,t,i,n,o){var a=t&Kd,c=r.length,p=e.length;if(c!=p&&!(a&&p>c))return!1;var f=o.get(r);if(f&&o.get(e))return f==e;var v=-1,m=!0,k=t&Lb?new Jd:void 0;for(o.set(r,e),o.set(e,r);++v<c;){var b=r[v],C=e[v];if(i)var w=a?i(C,b,v,e,r,o):i(b,C,v,r,e,o);if(w!==void 0){if(w)continue;m=!1;break}if(k){if(!bR(e,function(I,E){if(!PR(k,E)&&(b===I||n(b,I,t,i,o)))return k.push(E)})){m=!1;break}}else if(!(b===C||n(b,C,t,i,o))){m=!1;break}}return o.delete(r),o.delete(e),m}function mO(r,e,t,i,n,o,a){switch(t){case Vd:if(r.byteLength!=e.byteLength||r.byteOffset!=e.byteOffset)return!1;r=r.buffer,e=e.buffer;case Gb:return!(r.byteLength!=e.byteLength||!o(new Rb(r),new Rb(e)));case Db:case _b:case jb:return Qb(+r,+e);case Nb:return r.name==e.name&&r.message==e.message;case Hb:case Wb:return r==e+"";case Wd:var c=wR;case Gd:var p=i&Kd;if(c||(c=IR),r.size!=e.size&&!p)return!1;var f=a.get(r);if(f)return f==e;i|=Lb,a.set(r,e);var v=Yb(c(r),c(e),i,n,o,a);return a.delete(r),v;case rR:if(km)return km.call(r)==km.call(e)}return!1}function pO(r,e,t,i,n,o){var a=t&Kd,c=Ub(r),p=c.length,f=Ub(e),v=f.length;if(p!=v&&!a)return!1;for(var m=p;m--;){var k=c[m];if(!(a?k in e:et.call(e,k)))return!1}var b=o.get(r);if(b&&o.get(e))return b==e;var C=!0;o.set(r,e),o.set(e,r);for(var w=a;++m<p;){k=c[m];var I=r[k],E=e[k];if(i)var ue=a?i(E,I,k,e,r,o):i(I,E,k,r,e,o);if(!(ue===void 0?I===E||n(I,E,t,i,o):ue)){C=!1;break}w||(w=k=="constructor")}if(C&&!w){var Un=r.constructor,Aa=e.constructor;Un!=Aa&&"constructor"in r&&"constructor"in e&&!(typeof Un=="function"&&Un instanceof Un&&typeof Aa=="function"&&Aa instanceof Aa)&&(C=!1)}return o.delete(r),o.delete(e),C}function Ub(r){return aO(r,wO,gO)}function Yd(r,e){var t=r.__data__;return vO(e)?t[typeof e=="string"?"string":"hash"]:t.map}function Si(r,e){var t=CR(r,e);return lO(t)?t:void 0}function fO(r){var e=et.call(r,gr),t=r[gr];try{r[gr]=void 0;var i=!0}catch{}var n=Kb.call(r);return i&&(e?r[gr]=t:delete r[gr]),n}var gO=Ob?function(r){return r==null?[]:(r=Object(r),vR(Ob(r),function(e){return Xb.call(r,e)}))}:xO,Rt=ks;(Cm&&Rt(new Cm(new ArrayBuffer(1)))!=Vd||vs&&Rt(new vs)!=Wd||wm&&Rt(wm.resolve())!=wb||xm&&Rt(new xm)!=Gd||Im&&Rt(new Im)!=Pm)&&(Rt=function(r){var e=ks(r),t=e==bi?r.constructor:void 0,i=t?yr(t):"";if(i)switch(i){case MR:return Vd;case UR:return Wd;case LR:return wb;case BR:return Gd;case DR:return Pm}return e});function hO(r,e){return e=e??Bb,!!e&&(typeof r=="number"||gR.test(r))&&r>-1&&r%1==0&&r<e}function vO(r){var e=typeof r;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?r!=="__proto__":r===null}function yO(r){return!!Tb&&Tb in r}function bO(r){var e=r&&r.constructor,t=typeof e=="function"&&e.prototype||Xd;return r===t}function kO(r){return Kb.call(r)}function yr(r){if(r!=null){try{return $b.call(r)}catch{}try{return r+""}catch{}}return""}function Qb(r,e){return r===e||r!==r&&e!==e}var SO=Mb(function(){return arguments}())?Mb:function(r){return bs(r)&&et.call(r,"callee")&&!Xb.call(r,"callee")},$d=Array.isArray;function PO(r){return r!=null&&tk(r.length)&&!ek(r)}var Am=OR||IO;function CO(r,e){return Zb(r,e)}function ek(r){if(!rk(r))return!1;var e=ks(r);return e==qb||e==QE||e==YE||e==tR}function tk(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=Bb}function rk(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function bs(r){return r!=null&&typeof r=="object"}var ik=Ab?SR(Ab):uO;function wO(r){return PO(r)?oO(r):cO(r)}function xO(){return[]}function IO(){return!1}ki.exports=CO});var _S=h(Il=>{"use strict";Il.byteLength=QO;Il.toByteArray=tF;Il.fromByteArray=nF;var rt=[],Ne=[],YO=typeof Uint8Array<"u"?Uint8Array:Array,rp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Er=0,BS=rp.length;Er<BS;++Er)rt[Er]=rp[Er],Ne[rp.charCodeAt(Er)]=Er;var Er,BS;Ne["-".charCodeAt(0)]=62;Ne["_".charCodeAt(0)]=63;function DS(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var i=t===e?0:4-t%4;return[t,i]}function QO(r){var e=DS(r),t=e[0],i=e[1];return(t+i)*3/4-i}function eF(r,e,t){return(e+t)*3/4-t}function tF(r){var e,t=DS(r),i=t[0],n=t[1],o=new YO(eF(r,i,n)),a=0,c=n>0?i-4:i,p;for(p=0;p<c;p+=4)e=Ne[r.charCodeAt(p)]<<18|Ne[r.charCodeAt(p+1)]<<12|Ne[r.charCodeAt(p+2)]<<6|Ne[r.charCodeAt(p+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=e&255;return n===2&&(e=Ne[r.charCodeAt(p)]<<2|Ne[r.charCodeAt(p+1)]>>4,o[a++]=e&255),n===1&&(e=Ne[r.charCodeAt(p)]<<10|Ne[r.charCodeAt(p+1)]<<4|Ne[r.charCodeAt(p+2)]>>2,o[a++]=e>>8&255,o[a++]=e&255),o}function rF(r){return rt[r>>18&63]+rt[r>>12&63]+rt[r>>6&63]+rt[r&63]}function iF(r,e,t){for(var i,n=[],o=e;o<t;o+=3)i=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),n.push(rF(i));return n.join("")}function nF(r){for(var e,t=r.length,i=t%3,n=[],o=16383,a=0,c=t-i;a<c;a+=o)n.push(iF(r,a,a+o>c?c:a+o));return i===1?(e=r[t-1],n.push(rt[e>>2]+rt[e<<4&63]+"==")):i===2&&(e=(r[t-2]<<8)+r[t-1],n.push(rt[e>>10]+rt[e>>4&63]+rt[e<<2&63]+"=")),n.join("")}});var SH=Dr(sy(),1);function g(r,e){if(r==null)throw Error(e??"Expected nonnullish value.")}function or(r,e){if(!r)throw Error(e)}var te;(function(r){r.COMMENT="t1_",r.ACCOUNT="t2_",r.LINK="t3_",r.MESSAGE="t4_",r.SUBREDDIT="t5_",r.AWARD="t6_"})(te||(te={}));function Pt(r){return r.startsWith(te.COMMENT)}function vd(r){return r.startsWith(te.ACCOUNT)}function ar(r){return r.startsWith(te.LINK)}function oy(r){return r.startsWith(te.MESSAGE)}function ay(r){return r.startsWith(te.SUBREDDIT)}function dy(r){return r.startsWith(te.AWARD)}function f0(r){or(Pt(r),`Expected comment id to start with ${te.COMMENT}, got ${r}}`)}function g0(r){or(vd(r),`Expected account id to start with ${te.ACCOUNT}, got ${r}}`)}function h0(r){or(ar(r),`Expected link id to start with ${te.LINK}, got ${r}}`)}function v0(r){or(oy(r),`Expected message id to start with ${te.MESSAGE}, got ${r}}`)}function y0(r){or(ay(r),`Expected subreddit id to start with ${te.SUBREDDIT}, got ${r}}`)}function b0(r){or(dy(r),`Expected award id to start with ${te.AWARD}, got ${r}}`)}function Yr(r){return f0(r),r}function re(r){return g0(r),r}function fe(r){return h0(r),r}function k0(r){return v0(r),r}function Re(r){return y0(r),r}function S0(r){return b0(r),r}function ge(r){if(Pt(r))return Yr(r);if(vd(r))return re(r);if(ar(r))return fe(r);if(oy(r))return k0(r);if(ay(r))return Re(r);if(dy(r))return S0(r);throw new Error(`Expected thing id to start with ${Object.values(te).join(", ")} got ${r}}`)}function Vc(r){return Pt(r)}import*as P from"@devvit/protos";var yd=class{constructor(e){}};var zc=(t=>(t.Installation="installation",t.App="app",t))(zc||{});function dr(r,e=new Set){for(let t of r){if(t.type==="group"){dr(t.fields,e);continue}let i=t.name;if(e.has(i))throw new Error(`Duplicate field name: ${i}`);e.add(i)}P0(r)}function P0(r){for(let e of r)if(e.type==="string"&&e.isSecret&&e.scope!=="app")throw`Invalid setting: only app settings can be secrets. Add "scope: SettingScope.App" to field "${e.name}"`}var Ct=Object.freeze({INTERVAL:0,FORM:1,STATE:2,CHANNEL:3});var zU=["activity","add-emoji","add","add-media","add-to-feed","admin","align-center","align-left","align-right","all","appearance","approve","archived","aspect-ratio","aspect-rectangle","attach","audio","author","avatar-style","award","back","ban","best","binoculars","block","blockchain","bold","bot","boost","bounce","brand-awareness","browse","browser","cake","calendar","camera","caret-down","caret-left","caret-right","caret-up","chat","chat-group","chat-new","checkbox-dismiss","checkbox","checkmark","chrome","clear","close","closed-captioning","code-block","code-inline","coins-color-old","coins-color","coins","collapse-left","collapse-right","collection","comment","comments","community","contest","controversial","crop","crosspost","crowd-control","custom-feed","customize","day","delete","discover","dismiss-all","distinguish","down-arrow","down","download","downvote","downvotes","drag","drugs","duplicate","edit","effect","embed","emoji","end-live-chat","error","expand-left","expand-right","external","feed-video","filter","format","forward","gif-post","heart","help","hide","history","home","hot","ignore-reports","image-post","inbox","info","invite","italic","join","joined","jump-down","jump-up","karma","keyboard","kick","language","leave","left","link","link-post","list-bulleted","list-numbered","live-chat","live","load","location","lock","logout","loop","mark-read","mask","media-gallery","meme","menu","message","mic","mic-mute","mod","mod-mail","mod-mode","mod-mute","mod-overflow","mod-queue","mod-unmute","music","new","night","notification","notification-frequent","notification-off","nsfw","nsfw-language","nsfw-violence","original","overflow-caret","overflow-horizontal","overflow-vertical","pause","payment","peace","pending-posts","phone","pin","planet","play","poll-post","popular","posts","powerup-color-outline","powerup-fill-color","powerup","predictions","premium","privacy","profile","qa","qr-code","quarantined","quote","r-slash","radio-button","raise-hand","random","ratings-everyone","ratings-mature","ratings-nsfw","ratings-violence","refresh","remove","reply","report","reverse","right","rising","rotate","rotate-image","rpan","rules","safari","save","saved","search","self","send","settings","share-android","share","share-ios","show","side-menu","skipback10","skipforward10","sort-az","sort","sort-price","sort-za","spam","spoiler","sponsored","star","statistics","status-live","sticker","strikethrough","subtract","superscript","swap-camera","swipe-back","swipe-down","swipe","swipe-up","table","tag","tap","telescope","text","text-post","text-size","toggle","tools","top","topic-activism","topic-addictionsupport","topic-advice","topic-animals","topic-anime","topic-art","topic-beauty","topic-business","topic-careers","topic-cars","topic-celebrity","topic-craftsdiy","topic-crypto","topic-culture","topic-diy","topic-entertainment","topic-ethics","topic-family","topic-fashion","topic","topic-fitness","topic-food","topic-funny","topic-gender","topic-health","topic-help","topic-history","topic-hobbies","topic-homegarden","topic-internet","topic-law","topic-learning","topic-lifestyle","topic-marketplace","topic-mature","topic-mensfashion","topic-menshealth","topic-meta","topic-military","topic-movies","topic-music","topic-news","topic-other","topic-outdoors","topic-pets","topic-photography","topic-places","topic-podcasts","topic-politics","topic-programming","topic-reading","topic-religion","topic-science","topic-sexorientation","topic-sports","topic-style","topic-tabletop","topic-technology","topic-television","topic-traumasupport","topic-travel","topic-videogaming","topic-womensfashion","topic-womenshealth","translate","trim","u-slash","unban","undo","unheart","unlock","unmod","unpin","unverified","up-arrow","up","upload","upvote","upvotes","user","user-note","users","vault","verified","video-camera","video-feed","video-live-1","video-live-fill-1","video-live","video-post","video-thread","video-transcription","view-card","view-classic","view-compact","view-grid","views","volume","volume-mute","wallet","warning","wiki-ban","wiki","wiki-unban","world"];import{AppSettingsDefinition as _0,GetFieldsResponse as N0}from"@devvit/protos";import{FormField as lr,FormFieldType as Oe}from"@devvit/protos";function dt(r){return r.map(e=>{switch(e.type){case"string":return C0(e);case"image":return w0(e);case"paragraph":return x0(e);case"number":return I0(e);case"select":return A0(e);case"boolean":return T0(e);case"group":return E0(e);default:throw new Error("Unknown field type.")}})}function C0(r){return lr.fromPartial({defaultValue:{fieldType:Oe.STRING,stringValue:r.defaultValue},disabled:r.disabled,fieldConfig:{stringConfig:{placeholder:r.placeholder}},fieldId:r.name,fieldType:Oe.STRING,helpText:r.helpText,label:r.label,required:r.required,isSecret:r.isSecret})}function w0(r){return lr.fromPartial({disabled:r.disabled,fieldId:r.name,fieldType:Oe.IMAGE,helpText:r.helpText,label:r.label,required:r.required})}function x0(r){return lr.fromPartial({defaultValue:{fieldType:Oe.PARAGRAPH,stringValue:r.defaultValue},disabled:r.disabled,fieldConfig:{paragraphConfig:{lineHeight:r.lineHeight,placeholder:r.placeholder}},fieldId:r.name,fieldType:Oe.PARAGRAPH,helpText:r.helpText,label:r.label,required:r.required})}function I0(r){return lr.fromPartial({defaultValue:{fieldType:Oe.NUMBER,numberValue:r.defaultValue},disabled:r.disabled,fieldConfig:{numberConfig:{}},fieldId:r.name,fieldType:Oe.NUMBER,helpText:r.helpText,label:r.label,required:r.required})}function A0(r){return lr.fromPartial({defaultValue:{fieldType:Oe.SELECTION,selectionValue:{values:r.defaultValue}},disabled:r.disabled,fieldConfig:{selectionConfig:{choices:r.options,multiSelect:r.multiSelect}},fieldId:r.name,fieldType:Oe.SELECTION,helpText:r.helpText,label:r.label,required:r.required})}function T0(r){return lr.fromPartial({defaultValue:{fieldType:Oe.BOOLEAN,boolValue:r.defaultValue},disabled:r.disabled,fieldId:r.name,fieldType:Oe.BOOLEAN,helpText:r.helpText,label:r.label})}function E0(r){return lr.fromPartial({fieldType:Oe.GROUP,fieldConfig:{groupConfig:{fields:dt(r.fields)}},label:r.label,helpText:r.helpText})}function U(r,e){u.prototype[r]=e}import{ValidateFormResponse as D0}from"@devvit/protos";import{RealtimeSubscriptionStatus as uy}from"@devvit/protos";var L=Object.freeze({Actor:"devvit-actor",App:"devvit-app",AppUser:"devvit-app-user",AppViewerAuthToken:"devvit-app-viewer-authorization",Caller:"devvit-caller",CallerPortID:"devvit-caller-port-id",Canary:"devvit-canary",Debug:"devvit-debug",GQLHost:"devvit-gql-host",Installation:"devvit-installation",ModPermissions:"devvit-mod-permissions",R2Auth:"devvit-sec-authorization",R2Host:"devvit-r2-host",RemoteHostname:"devvit-remote-hostname",SettingsUri:"devvit-sec-settings-uri",StreamID:"devvit-stream-id",Subreddit:"devvit-subreddit",TraceID:"devvit-trace-id",User:"devvit-user",Version:"devvit-version",Language:"devvit-accept-language",Timezone:"devvit-accept-timezone",AppDependencies:"devvit-app-dependencies"}),ly;(function(r){r.Blocks="blocks",r.EmitSnapshots="emitSnapshots",r.EmitState="emitState",r.Realtime="realtime",r.Runtime="runtime",r.Surface="surface",r.UseAsync="useAsync"})(ly||(ly={}));function cy(r){function e(t){let n=r.currentHookIndex,o=r.getCurrentComponentState(),a=r.getPreviousComponentState(),c=r.metadata[L.App]?.values[0];g(c,"useChannel - app is missing from Context");let p=r.metadata[L.Installation]?.values[0];g(p,"useChannel - installation is missing from Context");async function f(I){let E=o[n].channel;if(o[n].active)if(o[n].connected)await r.realtime.send(E,I);else throw Error(`Failed to send to channel '${E}'; it is active but not yet connected`);else throw Error(`Cannot send a message over inactive channel: ${E}`)}function v(){if(!o[n].active){let I=o[n].channel;o[n].active=!0,r.addRealtimeChannel(I)}}function m(){if(o[n].active){let I=o[n].channel;o[n].active=!1,r.removeRealtimeChannel(I)}}function k(I){return async()=>{let E;switch(I.status){case uy.REALTIME_SUBSCRIBED:o[n].connected=!0,E=t.onSubscribed?.();break;case uy.REALTIME_UNSUBSCRIBED:o[n].connected=!1,E=t.onUnsubscribed?.();break;default:E=t.onMessage(I.event?.data??{});break}await E}}let b={channel:`${c}:${p}:${t.name}`,active:!1,connected:!1,preventCallback:!1,type:Ct.CHANNEL};n in o?b=o[n]:n in a&&(b=a[n]);let C=r.realtimeEvent;r.isInitialRender?b.active=!1:C&&b.active&&C.event.channel===b.channel&&(b.preventCallback||r.runHook(k(C)),r.rerenderIn(0)),o[n]=b,r.currentHookIndex++;let w=0;return b.active&&b.connected?w=2:b.active&&!b.connected?w=1:!b.active&&b.connected?w=3:!b.active&&!b.connected&&(w=4),{subscribe:v,unsubscribe:m,send:f,status:w}}return e}import{FormFieldType as Qr}from"@devvit/protos";function Jc(r){switch(r.fieldType){case Qr.STRING:return r.stringValue;case Qr.IMAGE:return r.stringValue;case Qr.PARAGRAPH:return r.stringValue;case Qr.NUMBER:return r.numberValue;case Qr.BOOLEAN:return r.boolValue;case Qr.SELECTION:return r.selectionValue?.values??[];default:return}}function wt(r){return Object.keys(r).reduce((e,t)=>{let i=Jc(r[t]);return i!==void 0&&(e[t]=i),e},{})}function my(r){function e(t,i){let n=r.currentHookIndex,o=r.getCurrentComponentKey(),a=r.getCurrentComponentState(),c=r.getPreviousComponentState(),p=`form.hook.${o}.${n}`,f={formKey:p,preventSubmit:!1,type:Ct.FORM};n in a?f=a[n]:n in c&&(f=c[n]),a[n]=f,r.forms.set(p,t);let v=r.formSubmittedEvent;return v&&!f.preventSubmit&&v.formId===p&&r.runHook(async()=>{let m=i(wt(v.results));m&&m instanceof Promise&&await m,r.rerenderIn(0)}),a[n].preventSubmit=!1,r.currentHookIndex++,p}return e}function py(r){function e(t,i){let n=r.currentHookIndex,o=r.getCurrentComponentState(),a=r.getPreviousComponentState(),c=100,p=Math.max(c,i),f={lastRun:void 0,running:!1,preventCallback:!1,type:Ct.INTERVAL};n in o?f=o[n]:n in a&&(f=a[n]);function v(){i<c&&console.error(`useInterval delay must be at least ${c}ms. Your interval of ${i}ms was automatically extended.`);for(let[k,b]of Object.entries(o))if(k!==n.toString()&&b?.type===Ct.INTERVAL&&b?.running)throw new Error("Only one useInterval hook may be running at a time");o[n]={running:!0,lastRun:o[n]?.lastRun??Date.now(),preventCallback:!1,type:Ct.INTERVAL},r.rerenderIn(p)}function m(){o[n].running=!1,o[n].lastRun=void 0,o[n].preventCallback=!1}return r.isEffectRender&&f.running&&(f.preventCallback||(f.lastRun===void 0||f.lastRun+p<Date.now())&&r.runHook(async()=>{let k=t();k&&k instanceof Promise&&await k,f.lastRun=Date.now()}),r.rerenderIn(p)),f.preventCallback=!1,o[n]=f,r.currentHookIndex++,{start:v,stop:m}}return e}function fy(r){function e(t){let i=r.currentHookIndex,n=r.getCurrentComponentState(),o=r.getPreviousComponentState();if(i in n)return r.currentHookIndex++,[n[i],a];if(r.isInitialRender||!(i in o)){let c=t instanceof Function?t():t;if(c instanceof Promise)throw(async()=>{n[i]=await c,r.currentHookIndex=0})();n[i]=c}else n[i]=o[i];function a(c){if(r.isRendering)throw new Error("Cannot call setState while rendering.");n[i]=c instanceof Function?c(n[i]):c}return r.currentHookIndex++,[n[i],a]}return e}var Zc={now(){return new Date}};function gy(r){return`__autocache__${r}`}function hy(r){return`__lock__${r}`}var O0=300,F0=1e3,bd=5e3,$c=3,vy=.1,yy=1e3,M0=3e4;function by(r){if(r.error)throw new Error(r.error);return r.value}var xt,It,Fe,ei,Sd,ky,Pd,Sy,Cd,Py,rs,Kc,wd,Cy,xd,wy,is,Xc,Id,xy,kd=class{constructor(e,t,i=Zc){d(this,Sd);d(this,Pd);d(this,Cd);d(this,rs);d(this,wd);d(this,xd);d(this,is);d(this,Id);d(this,xt,void 0);d(this,It,{});d(this,Fe,void 0);d(this,ei,void 0);l(this,xt,e),l(this,ei,t),l(this,Fe,i)}async cache(e,t){l(this,It,s(this,ei).__cache=s(this,ei).__cache??{}),y(this,Id,xy).call(this,t);let i=y(this,Sd,ky).call(this,t.key);if(i!==void 0)return i;let n=await y(this,is,Xc).call(this,t.key),o=await y(this,Pd,Sy).call(this,t,n,e);return by(o)}};xt=new WeakMap,It=new WeakMap,Fe=new WeakMap,ei=new WeakMap,Sd=new WeakSet,ky=function(e){let t=s(this,It)[e];if(t){let i=s(this,Fe).now().getTime(),n=t?.error&&t?.errorTime&&t.errorCount<$c&&Math.random()<vy&&t.errorTime+yy<i;if(t?.expires&&t.expires<i&&t.checkedAt+yy<i||n){delete s(this,It)[e];return}else return by(t)}},Pd=new WeakSet,Sy=async function(e,t,i){let n=t?.expires,o=n?y(this,xd,wy).call(this,n):1;return!t||t?.error&&t.errorCount<$c&&vy>Math.random()||o>Math.random()?y(this,Cd,Py).call(this,e,t,i):t},Cd=new WeakSet,Py=async function(e,t,i){let n=hy(e.key),o=s(this,Fe).now().getTime(),a=new Date(o+e.ttl/2);if(await s(this,xt).set(n,"1",{expiration:a,nx:!0}))return y(this,wd,Cy).call(this,e.key,t,i,e.ttl);if(t)return t;{let p=s(this,Fe).now();return y(this,rs,Kc).call(this,p,e.key,e.ttl)}},rs=new WeakSet,Kc=async function(e,t,i){let n=Math.min(i,F0),o=await y(this,is,Xc).call(this,t);if(o)return o;if(s(this,Fe).now().getTime()-e.getTime()>=n)throw new Error(`Cache request timed out trying to get data at key: ${t}`);return await new Promise(a=>setTimeout(a,O0)),y(this,rs,Kc).call(this,e,t,i)},wd=new WeakSet,Cy=async function(e,t,i,n){let o=s(this,Fe).now().getTime()+n;t=t??{value:null,expires:o,errorCount:0,error:null,errorTime:null,checkedAt:0};try{t.value=await i(),t.error=null,t.errorCount=0,t.errorTime=null}catch(a){t.value=null,t.error=a.message??"Unknown error",t.errorTime=s(this,Fe).now().getTime(),t.errorCount++}return s(this,It)[e]=t,await s(this,xt).set(gy(e),JSON.stringify(t),{expiration:new Date(o+M0)}),t.error&&t.errorCount<$c&&await s(this,xt).del(hy(e)),t},xd=new WeakSet,wy=function(e){let t=s(this,Fe).now().getTime(),i=e-t;return i<0?1:i<1e3?.1:i<2e3?.01:i<3e3?.001:0},is=new WeakSet,Xc=async function(e){let t=await s(this,xt).get(gy(e));if(t){let i=JSON.parse(t);return i.checkedAt=s(this,Fe).now().getTime(),s(this,It)[e]=i,i}},Id=new WeakSet,xy=function(e){e.ttl<bd&&(console.warn(`Cache TTL cannot be less than ${bd} milliseconds! Updating ttl value of ${e.ttl} to ${bd}.`),e.ttl=bd)};function Iy(r,e,t=Zc){let i=new kd(r,e,t);return i.cache.bind(i)}var ti,ri,Ad,Ay,Td,Ty,ii=class{constructor(){d(this,Ad);d(this,Td);d(this,ti,{});d(this,ri,{});l(this,ti,u.assets),l(this,ri,u.webviewAssets)}getURL(e,t){return typeof e=="string"?y(this,Ad,Ay).call(this,e,t??{webview:!1}):y(this,Td,Ty).call(this,e,t??{webview:!1})}};ti=new WeakMap,ri=new WeakMap,Ad=new WeakSet,Ay=function(e,t){let i=t.webview?s(this,ri)[e]:s(this,ti)[e];if(i)return i;try{return new URL(e.slice(0,e.indexOf(","))),e}catch{return""}},Td=new WeakSet,Ty=function(e,t){let i={},n=[],o=t.webview?s(this,ri):s(this,ti);if(o)for(let a of e)if(o[a])i[a]=o[a];else try{new URL(a.slice(0,a.indexOf(","))),i[a]=a}catch{n.push(a)}else n=e;if(n.length>0)throw new Error(`The following assets were missing from the assets list: ${n.join(", ")}`);return i};var At,ni=class{constructor(e){d(this,At,void 0);l(this,At,e)}async get(e){let{messages:t}=await u.kvStorePlugin.Get({keys:[e]},s(this,At));try{if(t[e])return JSON.parse(t[e])}catch{return}}async put(e,t){let i={};i[e]=JSON.stringify(t),await u.kvStorePlugin.Put({messages:i},s(this,At))}async delete(e){await u.kvStorePlugin.Del({keys:[e]},s(this,At))}async list(){let{keys:e}=await u.kvStorePlugin.List({filter:"*"},s(this,At));return e}};At=new WeakMap;var ns,si=class{constructor(e){d(this,ns,void 0);l(this,ns,e)}async upload(e){let t=await u.mediaPlugin.Upload(e,s(this,ns));if(!t.mediaId)throw new Error("unable to get mediaId via uploads");return Promise.resolve({mediaId:t.mediaId,mediaUrl:t.mediaUrl})}};ns=new WeakMap;var ss,oi=class{constructor(e){d(this,ss,void 0);l(this,ss,e)}async add(e){await u.modLogPlugin.Add(e,s(this,ss))}};ss=new WeakMap;var os,ai=class{constructor(e){d(this,os,void 0);l(this,os,e)}async send(e,t){await u.realtimePlugin.Send({channel:e,data:t},s(this,os))}};os=new WeakMap;var S,as,li=class{constructor(e){d(this,S,void 0);d(this,as,void 0);l(this,S,e),l(this,as,new Rd(e))}get modMail(){return s(this,as)}getSubredditById(e){return he.getById(ge(e),s(this,S))}getSubredditByName(e){return he.getByName(e,s(this,S))}addSubredditRemovalReason(e,t){return he.addRemovalReason(e,t.title,t.message,s(this,S))}getSubredditRemovalReasons(e){return he.getRemovalReasons(e,s(this,S))}getCurrentSubreddit(){return he.getFromMetadata(s(this,S))}getPostById(e){return V.getById(ge(e),s(this,S))}submitPost(e){return V.submit(e,s(this,S))}crosspost(e){return V.crosspost(e,s(this,S))}getUserById(e){return x.getById(ge(e),s(this,S))}getCollectionById(e){return di.getCollectionById({collectionId:e},s(this,S))}createCollection(e){return di.create(e,s(this,S))}getCollectionsForSubreddit(e){return di.getCollectionsForSubreddit({subredditId:e},s(this,S))}getUserByUsername(e){return x.getByUsername(e,s(this,S))}getCurrentUser(){return x.getFromMetadata(L.User,s(this,S))}getAppUser(){return x.getFromMetadata(L.AppUser,s(this,S))}getSnoovatarUrl(e){return x.getSnoovatarUrl(e,s(this,S))}getCommentById(e){return X.getById(ge(e),s(this,S))}getComments(e){return X.getComments(e,s(this,S))}getCommentsByUser(e){return X.getCommentsByUser(e,s(this,S))}submitComment(e){return X.submit({...e,id:ge(e.id)},s(this,S))}getControversialPosts(e){return V.getControversialPosts(e,s(this,S))}getTopPosts(e){return V.getTopPosts(e,s(this,S))}getHotPosts(e){return V.getHotPosts(e,s(this,S))}getNewPosts(e){return V.getNewPosts(e,s(this,S))}getRisingPosts(e){return V.getRisingPosts(e,s(this,S))}getPostsByUser(e){return V.getPostsByUser(e,s(this,S))}getCommentsAndPostsByUser(e){return x.getOverview(e,s(this,S))}getModerationLog(e){return Ed(e,s(this,S))}getApprovedUsers(e){return x.getSubredditUsersByType({type:"contributors",...e},s(this,S))}approveUser(e,t){return x.createRelationship({username:e,subredditName:t,type:"contributor"},s(this,S))}removeUser(e,t){return x.removeRelationship({username:e,subredditName:t,type:"contributor"},s(this,S))}getWikiContributors(e){return x.getSubredditUsersByType({type:"wikicontributors",...e},s(this,S))}addWikiContributor(e,t){return x.createRelationship({username:e,subredditName:t,type:"wikicontributor"},s(this,S))}removeWikiContributor(e,t){return x.removeRelationship({username:e,subredditName:t,type:"wikicontributor"},s(this,S))}getBannedUsers(e){return x.getSubredditUsersByType({type:"banned",...e},s(this,S))}banUser(e){return x.createRelationship({username:e.username,subredditName:e.subredditName,type:"banned",banReason:e.reason,banMessage:e.message,note:e.note,duration:e.duration},s(this,S))}unbanUser(e,t){return x.removeRelationship({username:e,subredditName:t,type:"banned"},s(this,S))}getBannedWikiContributors(e){return x.getSubredditUsersByType({type:"wikibanned",...e},s(this,S))}banWikiContributor(e){return x.createRelationship({...e,type:"wikibanned"},s(this,S))}unbanWikiContributor(e,t){return x.removeRelationship({username:e,subredditName:t,type:"wikibanned"},s(this,S))}getModerators(e){return x.getSubredditUsersByType({type:"moderators",...e},s(this,S))}inviteModerator(e){return x.createRelationship({type:"moderator_invite",subredditName:e.subredditName,username:e.subredditName,permissions:e.permissions??[]},s(this,S))}revokeModeratorInvite(e,t){return x.removeRelationship({username:e,subredditName:t,type:"moderator_invite"},s(this,S))}removeModerator(e,t){return x.removeRelationship({type:"moderator",subredditName:t,username:e},s(this,S))}setModeratorPermissions(e,t,i){return x.setModeratorPermissions(e,t,i,s(this,S))}getMutedUsers(e){return x.getSubredditUsersByType({type:"muted",...e},s(this,S))}muteUser(e){return x.createRelationship({...e,type:"muted"},s(this,S))}unmuteUser(e,t){return x.removeRelationship({username:e,subredditName:t,type:"muted"},s(this,S))}getModNotes(e){return Me.get(e,s(this,S))}deleteModNote(e){return Me.delete(e,s(this,S))}addModNote(e){let t={...e,redditId:ge(e.redditId)};return Me.add(t,s(this,S))}addRemovalNote(e){return Me.addRemovalNote(e,s(this,S))}async sendPrivateMessage(e){return ur.send(e,s(this,S))}async sendPrivateMessageAsSubreddit(e){return ur.sendAsSubreddit(e,s(this,S))}async approve(e){if(Pt(e))return X.approve(e,s(this,S));if(ar(e))return V.approve(e,s(this,S));throw new Error("id must start with either t1_ or t3_")}async remove(e,t){if(Pt(e))return X.remove(e,t,s(this,S));if(ar(e))return V.remove(e,t,s(this,S));throw new Error("id must start with either t1_ or t3_")}async getPostFlairTemplates(e){return ae.getPostFlairTemplates(e,s(this,S))}async getUserFlairTemplates(e){return ae.getUserFlairTemplates(e,s(this,S))}async createPostFlairTemplate(e){return ae.createPostFlairTemplate(e,s(this,S))}async createUserFlairTemplate(e){return ae.createUserFlairTemplate(e,s(this,S))}async editFlairTemplate(e){return ae.editFlairTemplate(e,s(this,S))}async deleteFlairTemplate(e,t){return ae.deleteFlairTemplate(e,t,s(this,S))}async setUserFlair(e){return Ue.setUserFlair(e,s(this,S))}async removeUserFlair(e,t){return Ue.removeUserFlair(e,t,s(this,S))}async setPostFlair(e){return Ue.setPostFlair(e,s(this,S))}async removePostFlair(e,t){return Ue.removePostFlair(e,fe(t),s(this,S))}async getWidgets(e){return ie.getWidgets(e,s(this,S))}async deleteWidget(e,t){return ie.delete(e,t,s(this,S))}async addWidget(e){return ie.add(e,s(this,S))}async reorderWidgets(e,t){return ie.reorder(e,t,s(this,S))}async getWikiPage(e,t){return ve.getPage(e,t,s(this,S))}async getWikiPages(e){return ve.getPages(e,s(this,S))}async createWikiPage(e){return ve.createPage(e,s(this,S))}async updateWikiPage(e){return ve.updatePage(e,s(this,S))}getWikiPageRevisions(e){return ve.getPageRevisions(e,s(this,S))}async revertWikiPage(e,t,i){return ve.revertPage(e,t,i,s(this,S))}async getWikiPageSettings(e,t){return ve.getPageSettings(e,t,s(this,S))}async updateWikiPageSettings(e){return ve.updatePageSettings(e,s(this,S))}async addEditorToWikiPage(e,t,i){return ve.addEditor(e,t,i,s(this,S))}async removeEditorFromWikiPage(e,t,i){return ve.removeEditor(e,t,i,s(this,S))}getMessages(e){return ur.getMessages(e,s(this,S))}markAllMessagesAsRead(){return ur.markAllAsRead(s(this,S))}report(e,t){return u.redditAPIPlugins.LinksAndComments.Report({reason:t.reason,thingId:e.id,srName:e.subredditName,usernames:e.authorName},s(this,S))}getModQueue(e){return he.aboutLocation({...e,location:"modqueue"},s(this,S))}getReports(e){return he.aboutLocation({...e,location:"reports"},s(this,S))}getSpam(e){return he.aboutLocation({...e,location:"spam"},s(this,S))}getUnmoderated(e){return he.aboutLocation({...e,location:"unmoderated"},s(this,S))}getEdited(e){return he.aboutLocation({...e,location:"edited"},s(this,S))}getVaultByAddress(e){return Oy(e,s(this,S))}getVaultByUserId(e){return Fy(ge(e),s(this,S))}getSubredditLeaderboard(e){return Ry(e,s(this,S))}};S=new WeakMap,as=new WeakMap;import{RedisKeyScope as Yc}from"@devvit/protos";var R,O,F,Qc=class{constructor(e,t,i){d(this,R,void 0);d(this,O,void 0);d(this,F,void 0);l(this,R,e),l(this,O,t),l(this,F,i)}async get(e){return await s(this,R).Get({key:e,transactionId:s(this,O)},s(this,F)),this}async multi(){await s(this,R).Multi(s(this,O),s(this,F))}async set(e,t,i){let n;return i?.expiration&&(n=Math.floor((i.expiration.getTime()-Date.now())/1e3),n<1&&(n=1)),await s(this,R).Set({key:e,value:t,nx:i?.nx===!0,xx:i?.xx===!0,expiration:n||0,transactionId:s(this,O)},s(this,F)),this}async del(...e){return await s(this,R).Del({keys:e,transactionId:s(this,O)},s(this,F)),this}async type(e){return await s(this,R).Type({key:e,transactionId:s(this,O)},s(this,F)),this}async exec(){let e=await s(this,R).Exec(s(this,O),s(this,F)),t=[];for(let i of e.response)i.members?t.push(i.members):i.nil!==void 0?t.push(null):i.num!==void 0?t.push(i.num):i.values!==void 0?t.push(i.values.values):i.str!==void 0&&t.push(i.str);return t}async discard(){await s(this,R).Discard(s(this,O),s(this,F))}async watch(...e){return await s(this,R).Watch({keys:e,transactionId:s(this,O)},s(this,F)),this}async unwatch(){return await s(this,R).Unwatch(s(this,O),s(this,F)),this}async getRange(e,t,i){return await s(this,R).GetRange({key:e,start:t,end:i,transactionId:s(this,O)},s(this,F)),this}async setRange(e,t,i){return await s(this,R).SetRange({key:e,offset:t,value:i,transactionId:s(this,O)},s(this,F)),this}async strlen(e){return await s(this,R).Strlen({key:e,transactionId:s(this,O)},s(this,F)),this}async mget(e){return await s(this,R).MGet({keys:e,transactionId:s(this,O)},s(this,F)),this}async mset(e){let t=Object.entries(e).map(([i,n])=>({key:i,value:n}));return await s(this,R).MSet({kv:t,transactionId:s(this,O)},s(this,F)),this}async incrBy(e,t){return await s(this,R).IncrBy({key:e,value:t,transactionId:s(this,O)},s(this,F)),this}async expire(e,t){return await s(this,R).Expire({key:e,seconds:t,transactionId:s(this,O)},s(this,F)),this}async expireTime(e){return await s(this,R).ExpireTime({key:e,transactionId:s(this,O)},s(this,F)),this}async zAdd(e,...t){return await s(this,R).ZAdd({key:e,members:t,transactionId:s(this,O)},s(this,F)),this}async zScore(e,t){return await s(this,R).ZScore({key:{key:e,transactionId:s(this,O)},member:t},s(this,F)),this}async zRank(e,t){return await s(this,R).ZRank({key:{key:e,transactionId:s(this,O)},member:t},s(this,F)),this}async zIncrBy(e,t,i){return await s(this,R).ZIncrBy({key:e,member:t,value:i,transactionId:s(this,O)},s(this,F)),this}async zScan(e,t,i,n){let o={key:e,cursor:t,pattern:i,count:n,transactionId:s(this,O)};return await s(this,R).ZScan(o,s(this,F)),this}async zCard(e){return await s(this,R).ZCard({key:e,transactionId:s(this,O)},s(this,F)),this}async zRange(e,t,i,n){let o={rev:!1,byLex:!1,byScore:!1,offset:0,count:1e3};return n?.reverse&&(o.rev=n.reverse),n?.by==="lex"?o.byLex=!0:n?.by==="score"&&(o.byScore=!0),await s(this,R).ZRange({key:{key:e,transactionId:s(this,O)},start:t+"",stop:i+"",...o},s(this,F)),this}async zRem(e,t){return await s(this,R).ZRem({key:{key:e,transactionId:s(this,O)},members:t},s(this,F)),this}async zRemRangeByLex(e,t,i){return await s(this,R).ZRemRangeByLex({key:{key:e,transactionId:s(this,O)},min:t,max:i},s(this,F)),this}async zRemRangeByRank(e,t,i){return await s(this,R).ZRemRangeByRank({key:{key:e,transactionId:s(this,O)},start:t,stop:i},s(this,F)),this}async zRemRangeByScore(e,t,i){return await s(this,R).ZRemRangeByScore({key:{key:e,transactionId:s(this,O)},min:t,max:i},s(this,F)),this}async hgetall(e){return await s(this,R).HGetAll({key:e,transactionId:s(this,O)},s(this,F)),this}async hget(e,t){return await s(this,R).HGet({key:e,field:t,transactionId:s(this,O)},s(this,F)),this}async hset(e,t){let i=Object.entries(t).map(([n,o])=>({field:n,value:o}));return await s(this,R).HSet({key:e,fv:i,transactionId:s(this,O)},s(this,F)),this}async hincrby(e,t,i){return await s(this,R).HIncrBy({key:e,field:t,value:i,transactionId:s(this,O)},s(this,F)),this}async hdel(e,t){return await s(this,R).HDel({key:e,fields:t,transactionId:s(this,O)},s(this,F)),this}async hscan(e,t,i,n){let o={key:e,cursor:t,pattern:i,count:n,transactionId:s(this,O)};return await s(this,R).HScan(o,s(this,F)),this}async hkeys(e){return await s(this,R).HKeys({key:e,transactionId:s(this,O)},s(this,F)),this}async hlen(e){return await s(this,R).HLen({key:e,transactionId:s(this,O)},s(this,F)),this}};R=new WeakMap,O=new WeakMap,F=new WeakMap;var M,ui,em=class em{constructor(e,t=void 0,i=Yc.INSTALLATION){d(this,M,void 0);d(this,ui,void 0);l(this,M,e),l(this,ui,t),this.scope=i,this.global=i===Yc.INSTALLATION?new em(s(this,M),s(this,ui),Yc.GLOBAL):this}get storage(){return s(this,ui)||u.redisPlugin}async watch(...e){let t=await this.storage.Watch({keys:e},s(this,M));return new Qc(this.storage,t,s(this,M))}async get(e){let t=await this.storage.Get({key:e,scope:this.scope},s(this,M));return t!==null?t.value??void 0:t}async set(e,t,i){let n;return i?.expiration&&(n=Math.floor((i.expiration.getTime()-Date.now())/1e3),n<1&&(n=1)),(await this.storage.Set({key:e,value:t,nx:i?.nx===!0&&!i.xx,xx:i?.xx===!0&&!i.nx,expiration:n||0,scope:this.scope},s(this,M))).value}async del(...e){await this.storage.Del({keys:e,scope:this.scope},s(this,M))}async incrBy(e,t){return(await this.storage.IncrBy({key:e,value:t,scope:this.scope},s(this,M))).value}async getRange(e,t,i){let n=await this.storage.GetRange({key:e,start:t,end:i,scope:this.scope},s(this,M));return n!==null?n.value:n}async setRange(e,t,i){return(await this.storage.SetRange({key:e,offset:t,value:i,scope:this.scope},s(this,M))).value}async strlen(e){return(await this.storage.Strlen({key:e,scope:this.scope},s(this,M))).value}async expire(e,t){await this.storage.Expire({key:e,seconds:t,scope:this.scope},s(this,M))}async expireTime(e){return(await this.storage.ExpireTime({key:e,scope:this.scope},s(this,M))).value}async zAdd(e,...t){return(await this.storage.ZAdd({key:e,members:t,scope:this.scope},s(this,M))).value}async zRange(e,t,i,n){let o={rev:!1,byLex:!1,byScore:!1,offset:0,count:1e3};return n?.reverse&&(o.rev=n.reverse),n?.by==="lex"?o.byLex=!0:n?.by==="score"?o.byScore=!0:(o.offset=0,o.count=0),(await this.storage.ZRange({key:{key:e},start:t+"",stop:i+"",...o,scope:this.scope},s(this,M))).members}async zRem(e,t){return(await this.storage.ZRem({key:{key:e},members:t,scope:this.scope},s(this,M))).value}async zRemRangeByLex(e,t,i){return(await this.storage.ZRemRangeByLex({key:{key:e},min:t,max:i,scope:this.scope},s(this,M))).value}async zRemRangeByRank(e,t,i){return(await this.storage.ZRemRangeByRank({key:{key:e},start:t,stop:i,scope:this.scope},s(this,M))).value}async zRemRangeByScore(e,t,i){return(await this.storage.ZRemRangeByScore({key:{key:e},min:t,max:i,scope:this.scope},s(this,M))).value}async zScore(e,t){let i=await this.storage.ZScore({key:{key:e},member:t,scope:this.scope},s(this,M));return i!==null?i.value:i}async zRank(e,t){let i=await this.storage.ZRank({key:{key:e},member:t,scope:this.scope},s(this,M));return i!==null?i.value:i}async zIncrBy(e,t,i){let n=await this.storage.ZIncrBy({key:e,member:t,value:i,scope:this.scope},s(this,M));return n!==null?n.value:n}async mget(e){let t=await this.storage.MGet({keys:e,scope:this.scope},s(this,M));return t!==null?t.values.map(i=>i||null):t}async mset(e){let t=Object.entries(e).map(([i,n])=>({key:i,value:n}));await this.storage.MSet({kv:t,scope:this.scope},s(this,M))}async zCard(e){let t=await this.storage.ZCard({key:e,scope:this.scope},s(this,M));return t!==null?t.value:t}async zScan(e,t,i,n){let o={key:e,cursor:t,pattern:i,count:n,scope:this.scope};return await this.storage.ZScan(o,s(this,M))}async type(e){let t=await this.storage.Type({key:e,scope:this.scope},s(this,M));return t!==null?t.value:t}async hget(e,t){let i=await this.storage.HGet({key:e,field:t,scope:this.scope},s(this,M));return i!==null?i.value??void 0:i}async hset(e,t){let i=Object.entries(t).map(([o,a])=>({field:o,value:a}));return(await this.storage.HSet({key:e,fv:i,scope:this.scope},s(this,M))).value}async hgetall(e){let t=await this.storage.HGetAll({key:e,scope:this.scope},s(this,M));return t!==null?t.fieldValues:t}async hdel(e,t){return(await this.storage.HDel({key:e,fields:t,scope:this.scope},s(this,M))).value}async hscan(e,t,i,n){let o={key:e,cursor:t,pattern:i,count:n,scope:this.scope};return await this.storage.HScan(o,s(this,M))}async hkeys(e){let t=await this.storage.HKeys({key:e,scope:this.scope},s(this,M));return t!==null?t.keys:t}async hincrby(e,t,i){return(await this.storage.HIncrBy({key:e,field:t,value:i,scope:this.scope},s(this,M))).value}async hlen(e){return(await this.storage.HLen({key:e,scope:this.scope})).value}};M=new WeakMap,ui=new WeakMap;var ci=em;var cr,mi=class{constructor(e){d(this,cr,void 0);l(this,cr,e)}async runJob(e){return(await u.schedulerPlugin.Schedule({action:{type:e.name,data:e.data},cron:"cron"in e?e.cron:void 0,when:"runAt"in e?e.runAt:void 0},s(this,cr))).id}async cancelJob(e){await u.schedulerPlugin.Cancel({id:e},s(this,cr))}async listJobs(){return(await u.schedulerPlugin.List({after:new Date(0),before:new Date(Date.now()+31536e7)},s(this,cr))).actions.map(t=>(g(t.request?.action,"Scheduled job is malformed"),"when"in t.request&&t.request.when!=null?{id:t.id,name:t.request.action.type,runAt:t.request.when,data:t.request.action.data}:{id:t.id,name:t.request.action.type,cron:t.request.cron??"",data:t.request.action}))}};cr=new WeakMap;var ds,pi=class{constructor(e){d(this,ds,void 0);l(this,ds,e)}async get(e){return(await this.getAll())[e]}async getAll(){let t=await u.settingsPlugin.GetSettings({},s(this,ds));if(!t.installationSettings)throw new Error("Could not get installation settings");if(!t.appSettings)throw new Error("Could not get app settings");return{...My(t.installationSettings.settings,u.installationSettings),...My(t.appSettings.settings,u.appSettings)}}};ds=new WeakMap;function My(r,e){let t=Object.keys(r).reduce((i,n)=>(i[n]=Jc(r[n]),i),{});return e&&Uy(t,e),t}function Uy(r,e){for(let t of e)t.type==="group"?Uy(r,t.fields):!(t.name in r)&&"defaultValue"in t&&(r[t.name]=t.defaultValue)}import{EffectType as tm,Form as U0,ToastAppearance as Ly}from"@devvit/protos";var mr,fi,Od=class{constructor(e){d(this,mr,[]);d(this,fi,void 0);l(this,fi,e)}showForm(e,t){let i=u.formDefinitions.get(e);if(!i&&s(this,fi)){let a=s(this,fi).forms.get(e);a&&(i={form:a,onSubmit:()=>{}})}if(!i)throw new Error("Form does not exist. Make sure you have added it using Devvit.createForm at the root of your app.");let n=i.form instanceof Function?i.form(t??{}):i.form,o=U0.fromPartial({id:e,title:n.title,acceptLabel:n.acceptLabel,cancelLabel:n.cancelLabel,shortDescription:n.description});dr(n.fields),o.fields=dt(n.fields),s(this,mr).push({type:tm.EFFECT_SHOW_FORM,showForm:{form:o}})}showToast(e){let t;e instanceof Object?t={text:e.text,appearance:e.appearance==="success"?Ly.SUCCESS:Ly.NEUTRAL}:t={text:e},s(this,mr).push({type:tm.EFFECT_SHOW_TOAST,showToast:{toast:t}})}navigateTo(e){let t;typeof e=="string"?t=new URL(e).toString():t=new URL(e.permalink,"https://www.reddit.com").toString(),s(this,mr).push({type:tm.EFFECT_NAVIGATE_TO_URL,navigateToUrl:{url:t}})}get __effects(){return s(this,mr)}};mr=new WeakMap,fi=new WeakMap;function Le({metadata:r,ui:e,hooks:t,reconciler:i}){let n=new oi(r),o=new ni(r),a=new ci(r),c=Iy(a,i?i.state:{}),p=new li(r),f=new mi(r),v=new pi(r),m=e?new Od(i):void 0,k=new si(r),b=new ii,C=new ai(r),w=t&&i?fy(i):void 0,I=t&&i?py(i):void 0,E=t&&i?my(i):void 0,ue=t&&i?cy(i):void 0;return{modLog:n,kvStore:o,redis:a,reddit:p,scheduler:f,settings:v,media:k,assets:b,realtime:C,get useForm(){return E??(()=>{throw new Error("useForm() is unavailable")})},get cache(){return c??(()=>{throw new Error("cache() is unavailable")})},get useState(){return w??(()=>{throw new Error("useState() is unavailable")})},get useInterval(){return I??(()=>{throw new Error("useInterval() is unavailable")})},get useChannel(){return ue??(()=>{throw new Error("useChannel() is unavailable")})},get ui(){if(!m)throw new Error("ui client is not available");return m}}}var By={name:"@devvit/public-api",version:"0.11.0-dev",license:"BSD-3-Clause",repository:{type:"git",url:"https://developers.reddit.com/"},type:"module",exports:{".":"./dist/index.js","./package.json":"./package.json","./*":"./dist/*"},main:"./dist/index.js",files:["dist/**"],scripts:{build:"yarn build:icon-types && yarn build:semantic-colors && tsc && cp -af devvit.tsconfig.json dist/ && yarn build:types && yarn build:min && yarn build:unmin","build:icon-types":"make-icons src/types/icons.ts","build:min":"esbuild --bundle --sourcemap=linked --target=es2020 --format=esm --metafile=dist/meta.min.json --outfile=dist/public-api.min.js --external:@devvit/protos --minify src/index.ts","build:semantic-colors":"node scripts/make-semantic-colors.js","build:types":"api-extractor run && sed -ne '/declare global {/,$ p' src/devvit/Devvit.ts >> dist/public-api.d.ts","build:unmin":"esbuild --bundle --sourcemap=inline --target=es2020 --format=iife --metafile=dist/meta.json --outfile=dist/public-api.iife.js --global-name=devvitPublicAPI src/index.ts",clean:"rm -rf .turbo api-extractor coverage dist src/devvit/internals/semanticColors.ts src/types/icons.ts || :",clobber:"yarn clean && rm -rf node_modules",dev:"tsc -w","dev:build":"chokidar ./src --command 'yarn build' --ignore './src/types/icons.ts' --ignore './src/devvit/internals/semanticColors.ts'",lint:"redlint .","lint:fix":"yarn lint --fix",prepublishOnly:"publish-package-json",test:"yarn test:unit && yarn test:types && yarn test:size","test:size":"filesize","test:types":"tsc --noEmit","test:unit":"vitest run","test:unit-with-coverage":"vitest run --coverage"},types:"./dist/index.d.ts",dependencies:{"@devvit/protos":"0.11.0-dev","@devvit/shared-types":"0.11.0-dev","base64-js":"1.5.1","clone-deep":"4.0.1","core-js":"3.27.2","lodash.isequal":"4.5.0"},devDependencies:{"@ampproject/filesize":"4.3.0","@devvit/eslint-config":"0.11.0-dev","@devvit/repo-tools":"0.11.0-dev","@devvit/tsconfig":"0.11.0-dev","@microsoft/api-extractor":"7.41.0","@reddit/faceplate-ui":"11.3.3","@types/clone-deep":"4.0.1","@types/core-js":"2.5.6","@types/lodash.isequal":"4.5.6","@vitest/coverage-c8":"0.32.0","chokidar-cli":"3.0.0",esbuild:"0.18.12",eslint:"8.9.0",typescript:"5.3.2",vitest:"1.6.0"},publishConfig:{directory:"dist"},filesize:{"dist/public-api.min.js":{gzip:"78 KB",none:"255 KB"}},source:"./src/index.ts"};function de(r,e,t){let i=r[L.Subreddit]?.values[0];g(i,"subreddit is missing from Context");let n=r[L.AppUser]?.values[0],o=r[L.User]?.values[0],a=B0(r);return{get appAccountId(){return g(n,"appAccountId is missing from Context"),n},subredditId:i,userId:o,postId:e,commentId:t,debug:a,toJSON(){return{appAccountId:n,subredditId:i,userId:o,postId:e,commentId:t,debug:a}}}}function B0(r){let e={blocks:void 0,emitSnapshots:void 0,emitState:void 0,realtime:void 0,runtime:void 0,surface:void 0,useAsync:void 0},t={};for(let n in e)t[n.toLowerCase()]=n;let i={};for(let n of(r[L.Debug]?.values??[]).join().split(",")){let[o,a]=n.split("=");o&&(o=o.trim(),a=a?.trim(),o.toLowerCase()in t&&(o=t[o.toLowerCase()]),i[o]??(i[o]=a||`${!0}`))}return r[L.Debug]&&console.info(`[api] @devvit/public-api v${By.version} ${Object.entries(i).map(([n,o])=>`${n}=${o}`).join(" ")}`),{...i,metadata:r}}async function Fd(r,e,t){if(!e)throw new Error("Settings were not defined.");let i=D0.fromPartial({success:!0,errors:{}}),n=wt(r.fieldValues),o=e.flatMap(a=>a.type==="group"?a.fields:a);return await Promise.all(o.map(async a=>{let c=a.name;if(c&&a.type!=="group"&&a.onValidate){let p=n[c],f=a.onValidate,v=Object.assign(Le({metadata:t}),de(t)),m=await f({value:p,isEditing:r.editing},v);m&&(i.success=!1,i.errors[c]=m)}})),i}async function q0(){if(!u.appSettings)throw new Error("App settings were not defined.");return N0.fromPartial({fields:{fields:dt(u.appSettings)}})}async function j0(r,e){return Fd(r,u.appSettings,e)}function Dy(r){r.provides(_0),U("GetAppSettingsFields",q0),U("ValidateAppForm",j0)}import{CustomPostDefinition as Z0}from"@devvit/protos";import{BlockRenderEventType as pm,EffectType as rb}from"@devvit/protos";var Md={width:288,height:320,scale:1,fontScale:1};function gi(r){return r.__effects}function _y(){let r=new Set;return e=>{let t=e,i=1;for(;r.has(t);)t=`${e}.${i++}`;return r.add(t),t}}import{BlockActionType as mm,BlockAnimationDirection as Ky,BlockAnimationLoopMode as Xy,BlockAnimationType as Zy,BlockAvatarBackground as Yy,BlockAvatarFacing as Qy,BlockAvatarSize as Tt,BlockBorderWidth as Bd,BlockButtonAppearance as Et,BlockButtonSize as nm,BlockFullSnooSize as hi,BlockGap as Dd,BlockHorizontalAlignment as sm,BlockIconSize as _d,BlockImageResizeMode as ls,BlockPadding as us,BlockRadius as cs,BlockSpacerShape as om,BlockSpacerSize as Nd,BlockStackDirection as am,BlockTextOutline as dm,BlockTextOverflow as lm,BlockTextSize as vi,BlockTextStyle as um,BlockTextWeight as eb,BlockType as Be,BlockVerticalAlignment as cm}from"@devvit/protos";var rm={transparent:"transparent",black:"#000000",white:"#ffffff","coolgray-950":"#04090A","coolgray-900":"#0B1416","coolgray-850":"#0F1A1C","coolgray-800":"#131F23","coolgray-750":"#1A282D","coolgray-700":"#223237","coolgray-650":"#2A3C42","coolgray-600":"#33464C","coolgray-550":"#4B6066","coolgray-525":"#576F76","coolgray-500":"#667A80","coolgray-450":"#82959B","coolgray-400":"#A0B0B5","coolgray-350":"#B8C5C9","coolgray-300":"#D2DADD","coolgray-250":"#DAE0E3","coolgray-200":"#E2E7E9","coolgray-150":"#EAEDEF","coolgray-100":"#F2F4F5","coolgray-50":"#F9FAFA","puregray-950":"#080808","puregray-900":"#131313","puregray-850":"#181818","puregray-800":"#1E1E1E","puregray-750":"#272727","puregray-700":"#303030","puregray-650":"#393939","puregray-600":"#434343","puregray-550":"#5C5C5C","puregray-500":"#767676","puregray-450":"#919191","puregray-400":"#ACACAC","puregray-350":"#C3C3C3","puregray-300":"#D6D6D6","puregray-250":"#DDDDDD","puregray-200":"#E4E4E4","puregray-150":"#EBEBEB","puregray-100":"#F2F2F2","puregray-50":"#F8F8F8","orangered-950":"#190600","orangered-900":"#340E00","orangered-800":"#4F1500","orangered-700":"#721F00","orangered-600":"#962900","orangered-500":"#D93A00","orangered-400":"#FE7C53","orangered-300":"#FFBEA6","orangered-200":"#FFD5C6","orangered-100":"#FFEDE5","orangered-50":"#FFF6F3","red-950":"#1C0004","red-900":"#3A0008","red-800":"#58000C","red-700":"#7E0011","red-600":"#A50016","red-500":"#EB001F","red-400":"#FF6E80","red-300":"#FFADB8","red-200":"#FFCCD2","red-100":"#FFEAED","red-50":"#FFF6F7","sakurapink-950":"#1A0011","sakurapink-900":"#360024","sakurapink-800":"#530037","sakurapink-700":"#770051","sakurapink-600":"#9B006A","sakurapink-500":"#E00096","sakurapink-400":"#FF55BD","sakurapink-300":"#FFA5E3","sakurapink-200":"#FFC5EC","sakurapink-100":"#FFE5F9","sakurapink-50":"#FFF3FB","berrypurple-950":"#16001F","berrypurple-900":"#2E0041","berrypurple-800":"#470062","berrypurple-700":"#66008C","berrypurple-600":"#8700B5","berrypurple-500":"#BC0EFF","berrypurple-400":"#D55EFF","berrypurple-300":"#EEA7FF","berrypurple-200":"#F2C8FF","berrypurple-100":"#FBE6FF","berrypurple-50":"#FCF4FF","periwinkle-950":"#0D0B1F","periwinkle-900":"#1A1741","periwinkle-800":"#272262","periwinkle-700":"#372F8C","periwinkle-600":"#453BB5","periwinkle-500":"#6A5CFF","periwinkle-400":"#988EFF","periwinkle-300":"#C3BDFF","periwinkle-200":"#D8D4FF","periwinkle-100":"#ECEAFF","periwinkle-50":"#F7F6FF","alienblue-950":"#000C1D","alienblue-900":"#00183D","alienblue-800":"#00255D","alienblue-700":"#003584","alienblue-600":"#0045AC","alienblue-500":"#1870F4","alienblue-400":"#629FFF","alienblue-300":"#A7CCFF","alienblue-200":"#C6DCFF","alienblue-100":"#E4EFFF","alienblue-50":"#F3F7FF","lightblue-950":"#000D12","lightblue-900":"#001C26","lightblue-800":"#002A3A","lightblue-700":"#003F56","lightblue-600":"#005472","lightblue-500":"#007FAE","lightblue-400":"#47B0DB","lightblue-300":"#95DCFB","lightblue-200":"#B6E9FF","lightblue-100":"#D9F6FF","lightblue-50":"#ECFAFF","mintgreen-950":"#00100E","mintgreen-900":"#001E1B","mintgreen-800":"#002E28","mintgreen-700":"#00443C","mintgreen-600":"#005A4F","mintgreen-500":"#008675","mintgreen-400":"#45B9AB","mintgreen-300":"#96E1D8","mintgreen-200":"#B7ECE5","mintgreen-100":"#DAF7F4","mintgreen-50":"#ECFBF9","kiwigreen-950":"#021000","kiwigreen-900":"#032200","kiwigreen-800":"#053200","kiwigreen-700":"#084A00","kiwigreen-600":"#0A6000","kiwigreen-500":"#0E8A00","kiwigreen-400":"#55BD46","kiwigreen-300":"#A3E398","kiwigreen-200":"#BFEEB8","kiwigreen-100":"#DFF8DB","kiwigreen-50":"#EEFCED","lime-950":"#0C0E00","lime-900":"#1A1F00","lime-800":"#282F00","lime-700":"#3A4501","lime-600":"#4D5A01","lime-500":"#6B7E01","lime-400":"#A1B33B","lime-300":"#CFDB83","lime-200":"#DFE8A6","lime-100":"#EFF4CC","lime-50":"#F7FAE5","yellow-950":"#100D01","yellow-900":"#251E02","yellow-800":"#382D03","yellow-700":"#504104","yellow-600":"#665505","yellow-500":"#8F7407","yellow-400":"#DBAF00","yellow-300":"#FADB61","yellow-200":"#FFE88F","yellow-100":"#FFF2BD","yellow-50":"#FFFAE5","yelloworange-950":"#150C00","yelloworange-900":"#2C1A00","yelloworange-800":"#432700","yelloworange-700":"#623A00","yelloworange-600":"#814C00","yelloworange-500":"#B06400","yelloworange-400":"#FF9C1A","yelloworange-300":"#FFCD7C","yelloworange-200":"#FFDDA8","yelloworange-100":"#FFF0D3","yelloworange-50":"#FFF7EA","poopbrown-950":"#110B04","poopbrown-900":"#29190A","poopbrown-800":"#3B2510","poopbrown-700":"#54371A","poopbrown-600":"#6E4924","poopbrown-500":"#9A6D3F","poopbrown-400":"#CAA075","poopbrown-300":"#EECCAA","poopbrown-200":"#F6DDC3","poopbrown-100":"#FEEEDD","poopbrown-50":"#FEF7EE",pizzaRed:{light:"#ef5350",dark:"#c62828"},"global-brand-orangered":{light:"#FF4500",dark:"#FF4500"},"global-focus":{light:"#47B0DB",dark:"#007FAE"},"interactive-content-disabled":{light:"#0000003f",dark:"#ffffff3f"},"interactive-background-disabled":{light:"#0000000c",dark:"#ffffff0c"},"interactive-pressed":{light:"#00000028",dark:"#ffffff28"},"neutral-content":{light:"#2A3C42",dark:"#B8C5C9"},"neutral-content-disabled":{light:"#D6D6D6",dark:"#303030"},"neutral-content-weak":{light:"#576F76",dark:"#82959B"},"neutral-content-strong":{light:"#0F1A1C",dark:"#F2F4F5"},"neutral-background":{light:"#ffffff",dark:"#0B1416"},"neutral-background-selected":{light:"#EAEDEF",dark:"#1A282D"},"neutral-background-weak":{light:"#F9FAFA",dark:"#04090A"},"neutral-background-medium":{light:"#F8F8F8",dark:"#131313"},"neutral-background-strong":{light:"#ffffff",dark:"#0F1A1C"},"neutral-background-hover":{light:"#F2F4F5",dark:"#131F23"},"neutral-border":{light:"#00000033",dark:"#ffffff33"},"neutral-border-medium":{light:"#0000007f",dark:"#ffffff7f"},"neutral-border-weak":{light:"#00000019",dark:"#ffffff19"},"neutral-border-strong":{light:"#0F1A1C",dark:"#F2F4F5"},primary:{light:"#0045AC",dark:"#629FFF"},"primary-hover":{light:"#003584",dark:"#A7CCFF"},"primary-visited":{light:"#8700B5",dark:"#D55EFF"},"primary-onBackground":{light:"#ffffff",dark:"#ffffff"},"primary-onBackground-selected":{light:"#ffffff",dark:"#000000"},"primary-background":{light:"#0045AC",dark:"#0045AC"},"primary-background-hover":{light:"#003584",dark:"#1870F4"},"primary-background-selected":{light:"#00255D",dark:"#629FFF"},secondary:{light:"#0F1A1C",dark:"#F2F4F5"},"secondary-hover":{light:"#000000",dark:"#ffffff"},"secondary-weak":{light:"#576F76",dark:"#82959B"},"secondary-onBackground":{light:"#000000",dark:"#ffffff"},"secondary-background":{light:"#EAEDEF",dark:"#1A282D"},"secondary-background-hover":{light:"#E2E7E9",dark:"#223237"},"secondary-background-selected":{light:"#D2DADD",dark:"#33464C"},"secondary-plain":{light:"#0F1A1C",dark:"#F2F4F5"},"secondary-plain-hover":{light:"#000000",dark:"#ffffff"},"danger-background":{light:"#EB001F",dark:"#A50016"},"danger-background-disabled":{light:"#FFCCD2",dark:"#3A0008"},"danger-background-hover":{light:"#A50016",dark:"#EB001F"},"danger-onBackground":{light:"#ffffff",dark:"#ffffff"},"danger-content":{light:"#A50016",dark:"#FF6E80"},"danger-content-hover":{light:"#7E0011",dark:"#FFADB8"},"danger-content-default":{light:"#ffffff",dark:"#ffffff"},"brand-background":{light:"#D93A00",dark:"#D93A00"},"brand-onBackground":{light:"#ffffff",dark:"#ffffff"},"brand-background-hover":{light:"#962900",dark:"#962900"},"media-background":{light:"#00000099",dark:"#00000099"},"media-onbackground":{light:"#ffffff",dark:"#ffffff"},"media-onbackground-weak":{light:"#E2E7E9",dark:"#E2E7E9"},"media-background-hover":{light:"#000000cc",dark:"#000000cc"},"media-onbackground-disabled":{light:"#ffffff3f",dark:"#ffffff3f"},"media-border-selected":{light:"#ffffff",dark:"#ffffff"},"media-background-selected":{light:"#000000cc",dark:"#000000cc"},"success-content":{light:"#0A6000",dark:"#55BD46"},"success-hover":{light:"#084A00",dark:"#A3E398"},"success-onBackground":{light:"#ffffff",dark:"#ffffff"},"success-background":{light:"#0E8A00",dark:"#0A6000"},"success-background-hover":{light:"#0A6000",dark:"#0E8A00"},"warning-content":{light:"#665505",dark:"#DBAF00"},"warning-content-hover":{light:"#504104",dark:"#FADB61"},"warning-onBackground":{light:"#000000",dark:"#000000"},"warning-background":{light:"#DBAF00",dark:"#DBAF00"},"warning-background-hover":{light:"#8F7407",dark:"#FADB61"},"upvote-content":{light:"#962900",dark:"#FE7C53"},"upvote-content-weak":{light:"#FF4500",dark:"#FF4500"},"upvote-disabled":{light:"#9629004c",dark:"#FE7C534c"},"upvote-onBackground":{light:"#ffffff",dark:"#ffffff"},"upvote-background":{light:"#D93A00",dark:"#D93A00"},"upvote-background-hover":{light:"#962900",dark:"#962900"},"upvote-background-disabled":{light:"#D93A004c",dark:"#D93A004c"},"downvote-content":{light:"#453BB5",dark:"#988EFF"},"downvote-content-weak":{light:"#6A5CFF",dark:"#6A5CFF"},"downvote-disabled":{light:"#453BB54c",dark:"#988EFF4c"},"downvote-onBackground":{light:"#ffffff",dark:"#ffffff"},"downvote-background":{light:"#6A5CFF",dark:"#453BB5"},"downvote-background-hover":{light:"#453BB5",dark:"#453BB5"},"downvote-background-disabled":{light:"#6A5CFF4c",dark:"#6A5CFF4c"},"brand-gradient-default":{light:"",dark:""},"brand-gradient-default-highlight":{light:"",dark:""},"brand-gradient-hover":{light:"",dark:""},"brand-gradient-hover-highlight":{light:"",dark:""},"brand-gradient-active":{light:"",dark:""},"brand-gradient-active-highlight":{light:"",dark:""},"gradient-media":{light:"",dark:""},"gradient-media-strong":{light:"",dark:""},"transparent-background-hover":{light:"#82959B19",dark:"#667A8019"},"global-black":{light:"#000000",dark:"#000000"},"global-white":{light:"#ffffff",dark:"#ffffff"},"global-orangered":{light:"#D93A00",dark:"#D93A00"},"global-alienblue":{light:"#1870F4",dark:"#1870F4"},"global-darkblue":{light:"#131F23",dark:"#131F23"},"tone-1":{light:"#131313",dark:"#F2F2F2"},"tone-2":{light:"#434343",dark:"#ACACAC"},"tone-3":{light:"#ACACAC",dark:"#434343"},"tone-4":{light:"#E4E4E4",dark:"#303030"},"tone-5":{light:"#F2F2F2",dark:"#1E1E1E"},"tone-6":{light:"#F8F8F8",dark:"#131313"},"tone-7":{light:"#ffffff",dark:"#080808"},"action-upvote":{light:"#D93A00",dark:"#D93A00"},"action-downvote":{light:"#6A5CFF",dark:"#6A5CFF"},"alert-caution":{light:"#8F7407",dark:"#8F7407"},"identity-admin":{light:"#D93A00",dark:"#D93A00"},"identity-moderator":{light:"#0E8A00",dark:"#0E8A00"},"identity-self":{light:"#008675",dark:"#008675"},"identity-coins":{light:"#DBAF00",dark:"#DBAF00"},"category-live":{light:"#D93A00",dark:"#D93A00"},"category-nsfw":{light:"#E00096",dark:"#E00096"},"category-spoiler":{light:"#131313",dark:"#F2F2F2"},"ui-canvas":{light:"#F2F2F2",dark:"#080808"},"ui-modalbackground":{light:"#ffffff",dark:"#0F1A1C"},"avatar-gradient":{light:"",dark:""},"opacity-highlight":{light:"",dark:""},"opacity-08":{light:"#13131314",dark:"#13131314"},"opacity-50":{light:"#0000007f",dark:"#F2F2F27f"},scrim:{light:"#00000099",dark:"#00000099"},"scrim-strong":{light:"#000000cc",dark:"#000000cc"},"scrim-gradient":{light:"",dark:""},online:{light:"#55BD46",dark:"#55BD46"},favorite:{light:"#8F7407",dark:"#DBAF00"}};var Ny={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",transparent:"#FFFFFF00",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},qy=r=>!!r.match(/^(#[0-9a-fA-F]{3,8}).*/),jy=r=>r in rm,im=r=>r in Ny,Hy=r=>!!r.match(/^rgba?\(.*/),Wy=r=>!!r.match(/^hsla?\(.*/),Gy=(r,e="light")=>{if(im(r))return Ud(r);let i=rm[r];return typeof i=="string"?i:i[e]},Ud=r=>Ny[r]??r,Vy=r=>{let[e,t,i,n]=r.replace(/^rgba?\(|\s+|\)$/g,"").split(",");if(!e||!t||!i)return r;let a=[...[e,t,i].map(p=>parseFloat(p))];if(n){let p=parseFloat(n),f=Math.round(p*255);a.push(f)}return`#${a.map(p=>p.toString(16).padStart(2,"0")).join("")}`};import{BlockSizeUnit as H0,BlockStackDirection as zy}from"@devvit/protos";var W0=/^(\d+(?:\.\d+)?)(px|%)?$/,pr=(r,e)=>{if(r==null)return;let t=Ld(r,e);return t!=null?{value:t,unit:H0.SIZE_UNIT_PIXELS}:void 0},$y=(r,e,t,i)=>{if(!r)return e;let n=G0(r.padding,e.fontScale)*2,o=z0(r.border,r.borderColor)*2,a=V0(r.gap),c=e.height;(r.height!=null||r.minHeight!=null||r.maxHeight!=null)&&(c=Jy(r.height,r.minHeight,r.maxHeight,e.height));let f=n+o;t===zy.STACK_VERTICAL&&a&&i>0&&(f=f+a*(i-1));let v=e.width;(r.width!=null||r.minWidth!=null||r.maxWidth!=null)&&(v=Jy(r.width,r.minWidth,r.maxWidth,e.width));let k=n+o;return t===zy.STACK_HORIZONTAL&&a&&i>0&&(k=k+a*(i-1)),{...e,height:c-f,width:v-k}},Ld=(r,e)=>{if(r!=null){if(typeof r=="number")return e*r/100;{let t=r.match(W0);if(t==null)return;let i=Number.parseFloat(t[1]);return t?.at(2)==="%"?e*i/100:i}}},G0=(r,e=1)=>{switch(r){case"xsmall":return 4*e;case"small":return 8*e;case"medium":return 16*e;case"large":return 32*e;default:return 0}},V0=r=>{switch(r){case"small":return 8;case"medium":return 16;case"large":return 32}return 0},z0=(r,e)=>{if(!r&&!e)return 0;switch(r){case"none":return 0;case"thin":return 1;case"thick":return 2;default:return 1}},Jy=(r,e,t,i)=>{let n=Ld(r,i)||0,o=Ld(e,i)||0,a=Ld(t,i)||0,c=Math.min(a,n),p=Math.max(o,n);return Math.max(c,p)};var tb="data-",J0=new Set(["onPress","onMessage"]),$0=new Map([["onPress",mm.ACTION_CLICK],["onMessage",mm.ACTION_WEBVIEW]]),ms,yi=class{constructor(e=()=>{}){d(this,ms,void 0);l(this,ms,e)}createBlocksElementOrThrow({type:e,props:t,children:i},n){let o=this.createBlocksElement({type:e,props:t,children:i},n);if(!o)throw new Error(`Could not create block of type ${e}`);return o}createBlocksElement({type:e,props:t,children:i},n){switch(e){case"blocks":return this.makeRoot(t,n,...i);case"hstack":return this.makeHStack(t,n,...i);case"vstack":return this.makeVStack(t,n,...i);case"zstack":return this.makeZStack(t,n,...i);case"text":return this.makeText(t,n,...i);case"button":return this.makeButton(t,n,...i);case"image":return this.makeImage(t,n);case"spacer":return this.makeSpacer(t,n);case"icon":return this.makeIcon(t,n);case"avatar":return this.makeAvatar(t,n);case"fullsnoo":return this.makeFullSnoo(t,n);case"animation":return this.makeAnimation(t,n);case"webview":return this.makeWebView(t,n);case"__fragment":throw new Error("root fragment is not supported - use 'blocks' instead")}}makeRootHeight(e){switch(e){case"regular":return 320;case"tall":return 512}}makeBlockPadding(e){switch(e){case"none":return us.PADDING_NONE;case"xsmall":return us.PADDING_XSMALL;case"small":return us.PADDING_SMALL;case"medium":return us.PADDING_MEDIUM;case"large":return us.PADDING_LARGE}}makeBlockRadius(e){switch(e){case"none":return cs.RADIUS_NONE;case"small":return cs.RADIUS_SMALL;case"medium":return cs.RADIUS_MEDIUM;case"large":return cs.RADIUS_LARGE;case"full":return cs.RADIUS_FULL}}makeBlockGap(e){switch(e){case"none":return Dd.GAP_NONE;case"small":return Dd.GAP_SMALL;case"medium":return Dd.GAP_MEDIUM;case"large":return Dd.GAP_LARGE}}makeBlockAlignment(e){if(e===void 0)return;let t,i;if(e.includes("top")?t=cm.ALIGN_TOP:e.includes("middle")?t=cm.ALIGN_MIDDLE:e.includes("bottom")&&(t=cm.ALIGN_BOTTOM),e.includes("start")?i=sm.ALIGN_START:e.includes("center")?i=sm.ALIGN_CENTER:e.includes("end")&&(i=sm.ALIGN_END),t!==void 0||i!==void 0)return{vertical:t,horizontal:i}}makeBlockBorder(e,t,i,n){if(!e&&!t)return;let o;switch(e){case"none":o=Bd.BORDER_WIDTH_NONE;break;case"thin":o=Bd.BORDER_WIDTH_THIN;break;case"thick":o=Bd.BORDER_WIDTH_THICK;break;default:o=Bd.BORDER_WIDTH_THIN;break}let a=t??"neutral-border-weak",c=this.getThemedColors(a,i,n);return{width:o,color:c?.light,colors:c}}makeBlockTextSize(e){switch(e){case"xsmall":return vi.TEXT_SIZE_XSMALL;case"small":return vi.TEXT_SIZE_SMALL;case"medium":return vi.TEXT_SIZE_MEDIUM;case"large":return vi.TEXT_SIZE_LARGE;case"xlarge":return vi.TEXT_SIZE_XLARGE;case"xxlarge":return vi.TEXT_SIZE_XXLARGE}}makeBlockTextStyle(e){switch(e){case"body":return um.TEXT_STYLE_BODY;case"metadata":return um.TEXT_STYLE_METADATA;case"heading":return um.TEXT_STYLE_HEADING}}makeBlockTextOutline(e){switch(e){case"none":return dm.TEXT_OUTLINE_NONE;case"thin":return dm.TEXT_OUTLINE_THIN;case"thick":return dm.TEXT_OUTLINE_THICK}}makeBlockTextWeight(e){switch(e){case"regular":return eb.TEXT_WEIGHT_REGULAR;case"bold":return eb.TEXT_WEIGHT_BOLD}}makeBlockTextOverflow(e){switch(e){case"clip":return lm.TEXT_OVERFLOW_CLIP;case"ellipsis":return lm.TEXT_OVERFLOW_ELLIPSE}return lm.TEXT_OVERFLOW_ELLIPSE}makeBlockButtonAppearance(e){switch(e){case"secondary":return Et.BUTTON_APPEARANCE_SECONDARY;case"primary":return Et.BUTTON_APPEARANCE_PRIMARY;case"plain":return Et.BUTTON_APPEARANCE_PLAIN;case"bordered":return Et.BUTTON_APPEARANCE_BORDERED;case"media":return Et.BUTTON_APPEARANCE_MEDIA;case"destructive":return Et.BUTTON_APPEARANCE_DESTRUCTIVE;case"caution":return Et.BUTTON_APPEARANCE_CAUTION;case"success":return Et.BUTTON_APPEARANCE_SUCCESS}}makeBlockButtonSize(e){switch(e){case"small":return nm.BUTTON_SIZE_SMALL;case"medium":return nm.BUTTON_SIZE_MEDIUM;case"large":return nm.BUTTON_SIZE_LARGE}}makeBlockImageResizeMode(e){switch(e){case"none":return ls.IMAGE_RESIZE_NONE;case"fit":return ls.IMAGE_RESIZE_FIT;case"fill":return ls.IMAGE_RESIZE_FILL;case"cover":return ls.IMAGE_RESIZE_COVER;case"scale-down":return ls.IMAGE_RESIZE_SCALE_DOWN}}makeBlockSpacerSize(e){switch(e){case"xsmall":return Nd.SPACER_XSMALL;case"small":return Nd.SPACER_SMALL;case"medium":return Nd.SPACER_MEDIUM;case"large":return Nd.SPACER_LARGE}}makeBlockSpacerShape(e){switch(e){case"invisible":return om.SPACER_INVISIBLE;case"thin":return om.SPACER_THIN;case"square":return om.SPACER_SQUARE}}makeBlockIconSize(e){switch(e){case"xsmall":return _d.ICON_SIZE_XSMALL;case"small":return _d.ICON_SIZE_SMALL;case"medium":return _d.ICON_SIZE_MEDIUM;case"large":return _d.ICON_SIZE_LARGE}}makeBlockAvatarSize(e){switch(e){case"xxsmall":return Tt.AVATAR_SIZE_XXSMALL;case"xsmall":return Tt.AVATAR_SIZE_XSMALL;case"small":return Tt.AVATAR_SIZE_SMALL;case"medium":return Tt.AVATAR_SIZE_MEDIUM;case"large":return Tt.AVATAR_SIZE_LARGE;case"xlarge":return Tt.AVATAR_SIZE_XXLARGE;case"xxlarge":return Tt.AVATAR_SIZE_XXLARGE;case"xxxlarge":return Tt.AVATAR_SIZE_XXXLARGE}}makeBlockAvatarFacing(e){switch(e){case"left":return Qy.AVATAR_FACING_LEFT;case"right":return Qy.AVATAR_FACING_RIGHT}}makeBlockFullSnooSize(e){switch(e){case"xsmall":return hi.FULLSNOO_XSMALL;case"small":return hi.FULLSNOO_SMALL;case"medium":return hi.FULLSNOO_MEDIUM;case"large":return hi.FULLSNOO_LARGE;case"xlarge":return hi.FULLSNOO_XLARGE;case"xxlarge":return hi.FULLSNOO_XXLARGE}}makeBlockAvatarBackground(e){switch(e){case"dark":return Yy.AVATAR_BG_DARK;case"light":return Yy.AVATAR_BG_LIGHT}}makeBlockAnimationType(e){return e==="lottie"||e===void 0?Zy.ANIM_LOTTIE:Zy.UNRECOGNIZED}makeBlockAnimationDirection(e){switch(e){case"backward":return Ky.ANIM_DIR_BACKWARD;case"forward":return Ky.ANIM_DIR_FORWARD}}makeBlockLoopMode(e){switch(e){case"repeat":return Xy.ANIM_LOOP_REPEAT;case"bounce":return Xy.ANIM_LOOP_BOUNCE}}makeBlockSizes(e,t){if(e){let i=e.width!=null||e.minWidth!=null||e.maxWidth!=null,n=e.height!=null||e.minHeight!=null||e.maxHeight!=null;if(i||n||e.grow!=null)return{width:i?{value:pr(e.width,t.width),min:pr(e.minWidth,t.width),max:pr(e.maxWidth,t.width)}:void 0,height:n?{value:pr(e.height,t.height),min:pr(e.minHeight,t.height),max:pr(e.maxHeight,t.height)}:void 0,grow:e.grow}}}getDataSet(e){return Object.keys(e).filter(t=>t.startsWith(tb)).reduce((t,i)=>(t[i.substring(tb.length)]=e[i],t),{})}makeActions(e,t){let i=[],n=this.getDataSet(t);return J0.forEach(o=>{if(o in t){let a=t[o];i.push({type:$0.get(o)??mm.UNRECOGNIZED,id:a.toString(),data:n})}}),i}blockColorToHex(e,t="light"){if(e)return e=e.toLowerCase(),qy(e)?e:jy(e)?Gy(e,t):im(e)?Ud(e):Hy(e)?Vy(e):Wy(e)?e:(console.warn(`Could not parse color: ${e}.`),Ud("red"))}childrenToBlocks(e,t){return e.flatMap(i=>(typeof i!="string"?this.createBlocksElement(i,t):void 0)??[])}getThemedColors(e,t,i){let n=this.blockColorToHex(t,"light"),o=this.blockColorToHex(i,"dark"),a=[];if(e&&(!n||!o)){let c=Array.from(e?.matchAll(/[\w#-]+(?:\([\w\t ,.#-]+\))?/g)??[]);a.push(...c.map(p=>p[0]))}return n||(n=this.blockColorToHex(a?.at(0),"light")),o||(o=this.blockColorToHex(a?.at(1)??a?.at(0),"dark")),n||o?{light:n,dark:o}:void 0}parsePixels(e){return typeof e=="string"?Number(e.slice(0,-2)):e}resolveAssetUrl(e,t){return s(this,ms).call(this)?.getURL(e,t)??e}childrenToString(e){return e.map(t=>t.toString()).join("")}makeRoot(e,t,...i){return this.wrapRoot(e,t,this.childrenToBlocks(i,t))}wrapRoot(e,t,i){return this.makeBlock(Be.BLOCK_ROOT,{},t,{rootConfig:{children:i,height:this.makeRootHeight(u.customPostType?.height??e?.height??"regular")}})}makeStackBlock(e,t,i,n){let o=this.getThemedColors(t?.backgroundColor,t?.lightBackgroundColor,t?.darkBackgroundColor),a=$y(t,i.maxDimensions,e,n.length);return this.makeBlock(Be.BLOCK_STACK,t,i,{stackConfig:{alignment:this.makeBlockAlignment(t?.alignment),backgroundColor:o?.light,backgroundColors:o,border:this.makeBlockBorder(t?.border,t?.borderColor,t?.lightBorderColor,t?.darkBorderColor),children:this.childrenToBlocks(n,{...i,maxDimensions:a}),cornerRadius:this.makeBlockRadius(t?.cornerRadius),direction:e,gap:this.makeBlockGap(t?.gap),padding:this.makeBlockPadding(t?.padding),reverse:t?.reverse}})}makeHStack(e,t,...i){return this.makeStackBlock(am.STACK_HORIZONTAL,e,t,i)}makeVStack(e,t,...i){return this.makeStackBlock(am.STACK_VERTICAL,e,t,i)}makeZStack(e,t,...i){return this.makeStackBlock(am.STACK_DEPTH,e,t,i)}makeText(e,t,...i){let n=this.getThemedColors(e?.color,e?.lightColor,e?.darkColor);return this.makeBlock(Be.BLOCK_TEXT,e,t,{textConfig:{alignment:this.makeBlockAlignment(e?.alignment),color:n?.light,colors:n,outline:this.makeBlockTextOutline(e?.outline),size:this.makeBlockTextSize(e?.size),style:this.makeBlockTextStyle(e?.style),text:this.childrenToString(i),weight:this.makeBlockTextWeight(e?.weight),selectable:e?.selectable,wrap:e?.wrap,overflow:this.makeBlockTextOverflow(e?.overflow)}})}makeButton(e,t,...i){let n=this.getThemedColors(e?.textColor,e?.lightTextColor,e?.darkTextColor);return this.makeBlock(Be.BLOCK_BUTTON,e,t,{buttonConfig:{buttonAppearance:this.makeBlockButtonAppearance(e?.appearance),icon:e?.icon,buttonSize:this.makeBlockButtonSize(e?.size),text:this.childrenToString(i),textColor:n?.light,textColors:n,disabled:e?.disabled}})}makeImage(e,t){return e&&this.makeBlock(Be.BLOCK_IMAGE,e,t,{imageConfig:{description:e?.description,resizeMode:this.makeBlockImageResizeMode(e.resizeMode),url:this.resolveAssetUrl(e.url),width:this.parsePixels(e.imageWidth),height:this.parsePixels(e.imageHeight)}})}makeSpacer(e,t){return this.makeBlock(Be.BLOCK_SPACER,e,t,{spacerConfig:{size:this.makeBlockSpacerSize(e?.size),shape:this.makeBlockSpacerShape(e?.shape)}})}makeIcon(e,t){let i=this.getThemedColors(e?.color,e?.lightColor,e?.darkColor);return e&&this.makeBlock(Be.BLOCK_ICON,e,t,{iconConfig:{icon:e.name,color:i?.light,colors:i,size:this.makeBlockIconSize(e.size)}})}makeAvatar(e,t){return e&&this.makeBlock(Be.BLOCK_AVATAR,e,t,{avatarConfig:{thingId:e.thingId,size:this.makeBlockAvatarSize(e.size),facing:this.makeBlockAvatarFacing(e.facing),background:this.makeBlockAvatarBackground(e.background)}})}makeFullSnoo(e,t){return e&&this.makeBlock(Be.BLOCK_FULLSNOO,e,t,{fullsnooConfig:{userId:e.userId,facing:this.makeBlockAvatarFacing(e.facing),size:this.makeBlockFullSnooSize(e.size)}})}makeAnimation(e,t){return e&&this.makeBlock(Be.BLOCK_ANIMATION,e,t,{animationConfig:{type:this.makeBlockAnimationType(e.type),url:this.resolveAssetUrl(e.url),loop:e.loop,loopMode:this.makeBlockLoopMode(e.loopMode),autoplay:e.autoplay,width:this.parsePixels(e.imageWidth),height:this.parsePixels(e.imageHeight),direction:this.makeBlockAnimationDirection(e.direction),speed:e.speed}})}makeWebView(e,t){return e&&this.makeBlock(Be.BLOCK_WEBVIEW,e,t,{webviewConfig:{url:this.resolveAssetUrl(e.url,{webview:!0}),state:e.state}})}makeBlock(e,t,i,n){return{type:e,sizes:this.makeBlockSizes(t,i.maxDimensions),config:n,actions:(t&&this.makeActions(e,t))??[],id:t?.id,key:t?.key}}ensureRootBlock(e,t){let i=e;if(i.type===Be.BLOCK_ROOT)return i.config?.rootConfig&&u.customPostType?.height&&(i.config.rootConfig.height=this.makeRootHeight(u.customPostType?.height)),i;let n=this.wrapRoot(void 0,t,[i]);if(!n)throw new Error("Could not create root block");return n}};ms=new WeakMap;function ib(r){if(typeof r=="string")throw new Error("Root element cannot be a string")}var nb=r=>{let e="",t=r.props?Object.keys(r.props).map(i=>i==="onPress"?"":`${i}="${r.props[i]}"`).join(" "):"";e+=`<${r.type}${t?" "+t:""}>`;for(let i of r.children)typeof i=="string"?e+=i:e+=nb(i);return e+=`</${r.type}>`,e};function K0(r){return" ".repeat(r)}function X0(r){let e="",t=0,i=r.split(/>\s*</);for(let n=0;n<i.length;n++){let o=i[n];n===0&&(o=o.trim()),n===i.length-1&&(o=o.trim());let a=o.charAt(0)==="/";a&&t--,e+=K0(t),n!==0&&(e+="<"),e+=o,n!==i.length-1&&(e+=`>
2
+ `),!a&&o.indexOf("</")===-1&&o.charAt(o.length-1)!=="/"&&t++}return e}var qd,sb,fr,ps,fs,fm,gs,lt=class{constructor(e,t,i,n,o){d(this,qd);d(this,fr);d(this,fs);this.renderState={};this.currentComponentKey=[];this.currentHookIndex=0;this.actions=new Map;this.forms=new Map;this.realtimeChannels=[];this.realtimeUpdated=!1;this.pendingHooks=[];this.isRendering=!1;this.transformer=new yi(()=>this.assets);this.effects=[];d(this,gs,!1);this.component=e,this.event=t,this.state={__renderState:{},...i},this.metadata=n,this.state.__realtimeChannels&&(this.realtimeChannels=this.state.__realtimeChannels);let a=Le({reconciler:this,hooks:!0,ui:!0,metadata:n});this.cache=a.cache,this.modLog=a.modLog,this.reddit=a.reddit,this.kvStore=a.kvStore,this.redis=a.redis,this.settings=a.settings,this.scheduler=a.scheduler,this.media=a.media,this.assets=a.assets,this.realtime=a.realtime,this.dimensions=o,this.ui=a.ui,this.hooks={useState:a.useState,useInterval:a.useInterval,useForm:a.useForm,useChannel:a.useChannel}}emitEffect(e,t){this.effects.push(t)}async render(){await this.reconcile(),this.isRendering=!0;let e=await this.buildBlocksUI();return this.isRendering=!1,e}makeUniqueActionID(e){let t=e,i=1;for(;this.actions.has(t);)t=`${e}.${i++}`;return t}makeTransformContext(e){return{maxDimensions:e.dimensions??Md}}async reconcile(){let e=y(this,fr,ps).call(this),t={type:this.component,props:e,children:[]},i=await this.processBlock(t);ib(i);let n=this.makeTransformContext(e);if(this.transformer.createBlocksElementOrThrow(i,n),this.isUserActionRender&&this.blockRenderEventId){let o=this.actions.get(this.blockRenderEventId);o&&await o(this.event.data)}for(let o of this.pendingHooks)await o();this.buildNextState(),y(this,qd,sb).call(this)}async buildBlocksUI(){let e=y(this,fr,ps).call(this),t={type:this.component,props:e,children:[]},i=await this.renderElement(e,t),n=this.makeTransformContext(e);return this.transformer.ensureRootBlock(i,n)}async renderElement(e,t){let i=await this.processBlock(t);ib(i),(u.debug.emitSnapshots||e.debug.emitSnapshots)&&console.debug(X0(nb(i))),(u.debug.emitState||e.debug.emitState)&&console.debug(JSON.stringify(this.state,void 0,2));let n=this.makeTransformContext(e);return this.transformer.createBlocksElementOrThrow(i,n)}async processProps(e){let t=e.props??{},i=["onPress","onMessage"];for(let n of i)if(n in t){let o=t[n],a=o?.name,c=this.makeUniqueActionID(`${e.type}.${a??n}`);this.actions.set(c,o),t[n]=c}}async processBlock(e,t=_y(),i=[]){let n=e;if(typeof n.type=="string"){let c=[];for(let m=0;m<n.children.length;m++){let k=n.children[m];k!=null&&c.push(await this.processBlock(k,t,[...i,`${n.type}.${m}`]))}let p=c.flat(),f=y(this,fs,fm).call(this,p);return await this.processProps(n),{type:n.type,props:n.props,children:f}}if(typeof n.type=="function"){let c=t(`${i.length?i.join("."):"root"}.${n.type.name.length?n.type.name:"anonymous"}`);this.currentComponentKey.push(c),this.renderState[c]||(this.renderState[c]={});let p=n.children.flatMap(m=>m),f={...y(this,fr,ps).call(this),...n.props,children:p},v;for(;v===void 0;)try{v=await n.type(f,y(this,fr,ps).call(this))}catch(m){if(m instanceof Promise)v=await m;else throw m}if(!this.isInitialRender){let m=this.getPreviousComponentState();if(Object.keys(m).length!==this.currentHookIndex)throw new Error("Invalid hook call. Hooks can only be called at the top-level of a function component. Make sure that you are not calling hooks inside loops, conditions, or nested functions.")}if(this.currentComponentKey.pop(),this.currentHookIndex=0,typeof v=="object")return this.processBlock(v,t,[...i,n.type.name])}if(typeof n=="string")return n;if(typeof n=="number")return`${n}`;let o=[],a="";return Array.isArray(n)?o=n:typeof n.type>"u"&&n.children&&(o=n.children,a="fragmentChild."),{type:"__fragment",props:void 0,children:await Promise.all(o.flatMap(async(c,p)=>await this.processBlock(c,t,[...i,`${a}${p}`])))}}getCurrentComponentKey(){if(!this.currentComponentKey.at(-1))throw new Error("Current component key is missing");return this.currentComponentKey}getCurrentComponentState(){let e=this.currentComponentKey.at(-1);if(!e)throw new Error("Current component key is missing");return this.renderState[e]}getPreviousComponentState(){let e=this.currentComponentKey.at(-1);if(!e)throw new Error("Current component key is missing");return this.state.__renderState[e]||(this.state.__renderState[e]={}),this.state.__renderState[e]}get isInitialRender(){return this.event?this.event.type===pm.RENDER_INITIAL:!1}get isUserActionRender(){return this.event?this.event.type===pm.RENDER_USER_ACTION:!1}get isEffectRender(){return this.event?this.event.type===pm.RENDER_EFFECT_EVENT:!1}get formSubmittedEvent(){return this.event?this.event.formSubmitted:!1}get blockRenderEventId(){return this.event?this.event.id:!1}get realtimeEvent(){if(!this.event)return!1;let e=this.event.realtimeEvent;return e?.event?.channel?e:!1}runHook(e){this.pendingHooks.push(e)}rerenderIn(e){s(this,gs)||(l(this,gs,!0),this.effects.push({type:rb.EFFECT_RERENDER_UI,rerenderUi:{delaySeconds:e/1e3}}))}addRealtimeChannel(e){this.realtimeChannels.push(e),this.realtimeUpdated=!0}removeRealtimeChannel(e){this.realtimeChannels=this.realtimeChannels.filter(t=>t!==e),this.realtimeUpdated=!0}get realtimeEffect(){return this.realtimeUpdated&&this.realtimeChannels.length>0?[{type:rb.EFFECT_REALTIME_SUB,realtimeSubscriptions:{subscriptionIds:this.realtimeChannels}}]:[]}getEffects(){return[...gi(this.ui),...this.effects,...this.realtimeEffect]}buildNextState(){for(let e of Object.keys(this.renderState))this.renderState[e]=Object.values(this.renderState[e]);this.state={__postData:this.state.__postData,__renderState:this.renderState,__cache:this.state.__cache,...this.realtimeChannels.length>0?{__realtimeChannels:this.realtimeChannels}:{}}}};qd=new WeakSet,sb=function(){this.actions.clear(),this.currentComponentKey=[],this.currentHookIndex=0,this.pendingHooks=[],this.realtimeChannels=[],this.realtimeUpdated=!1},fr=new WeakSet,ps=function(){let e={...de(this.metadata,this.state.__postData?.thingId),modLog:this.modLog,reddit:this.reddit,cache:this.cache,kvStore:this.kvStore,redis:this.redis,settings:this.settings,scheduler:this.scheduler,media:this.media,assets:this.assets,realtime:this.realtime,ui:this.ui,dimensions:this.dimensions,uiEnvironment:{timezone:this.metadata[L.Timezone]?.values[0],locale:this.metadata[L.Language]?.values[0],dimensions:this.dimensions},...this.hooks};return e.debug.effects=this,e},fs=new WeakSet,fm=function(e){let t=[];for(let i of e)typeof i=="string"?t.push(i):i.type==="__fragment"?t.push(...y(this,fs,fm).call(this,i.children)):t.push(i);return t},gs=new WeakMap;async function Y0(r,e){let t=u.customPostType;if(!t)throw new Error("Custom post type not registered");let i=new lt((o,a)=>t.render(a),r.blocks,r.state,e,r.dimensions),n=await i.render();return{state:i.state,blocks:{ui:n},effects:i.getEffects()}}function ob(r){r.provides(Z0),U("RenderPost",Y0)}import{GetFieldsResponse as Q0,InstallationSettingsDefinition as eE}from"@devvit/protos";async function tE(){if(!u.installationSettings)throw new Error("Installation settings were not defined.");return Q0.fromPartial({fields:{fields:dt(u.installationSettings)}})}async function rE(r,e){return Fd(r,u.installationSettings,e)}function ab(r){r.provides(eE),U("GetSettingsFields",tE),U("ValidateForm",rE)}import{ContextActionDefinition as iE,ContextActionDescription as nE,ContextActionResponse as sE}from"@devvit/protos";var db=r=>`menuItem.${r}`;function gm(r){return u.menuItems.find((e,t)=>db(t)===r)}async function oE(r,e){let t=u.menuItems;if(!t.length)throw new Error("No menu items registered.");return{actions:t.map((n,o)=>nE.fromPartial({actionId:db(o),name:n.label,description:n.description,contexts:{subreddit:n.location.includes("subreddit"),post:n.location.includes("post"),comment:n.location.includes("comment")},users:{loggedOut:n.forUserType?.includes("loggedOut"),member:n.forUserType?.includes("member"),moderator:n.forUserType?.includes("moderator")},postFilters:n.postFilter==="currentApp"?{currentApp:!0}:void 0}))}}async function aE(r,e){let t=gm(r.actionId);if(!t)throw new Error(`MenuItem ${r.actionId} not found`);let i=r.comment?.id&&`t1_${r.comment.id}`,n=r.post?.id&&`t3_${r.post.id}`,o=r.subreddit?.id&&`t5_${r.subreddit.id}`,a=i||n||o;g(a,"targetId is missing from ContextActionRequest");let c={targetId:a,location:r.comment?"comment":r.post?"post":"subreddit"},p=Object.assign(Le({ui:!0,metadata:e}),de(e,n,i),{uiEnvironment:{timezone:e[L.Timezone]?.values[0],locale:e[L.Language]?.values[0]}});return await t.onPress(c,p),sE.fromPartial({effects:gi(p.ui)})}function lb(r){r.provides(iE),U("GetActions",oE),U("OnAction",aE)}function ut(r){return r?r===!0?!0:r.enabled:!1}import{SchedulerHandlerDefinition as dE}from"@devvit/protos";async function lE(r,e){let t=r.type,i=u.scheduledJobHandlers.get(t);if(!i)throw new Error(`Job ${t} not found`);let n={name:t,data:r.data},o=Object.assign(Le({metadata:e}),de(e));await i(n,o)}function ub(r){r.provides(dE),U("HandleScheduledAction",lE)}import{HandlerResult as uE,OnAppInstallDefinition as cE,OnAppUpgradeDefinition as mE,OnCommentCreateDefinition as pE,OnCommentDeleteDefinition as fE,OnCommentReportDefinition as gE,OnCommentSubmitDefinition as hE,OnCommentUpdateDefinition as vE,OnModActionDefinition as yE,OnModMailDefinition as bE,OnPostCreateDefinition as kE,OnPostDeleteDefinition as SE,OnPostFlairUpdateDefinition as PE,OnPostReportDefinition as CE,OnPostSubmitDefinition as wE,OnPostUpdateDefinition as xE,OnPostNsfwUpdateDefinition as IE,OnPostSpoilerUpdateDefinition as AE}from"@devvit/protos";var jd;(function(r){function e(o,a){return o.length<=a?o:`${o.slice(0,a-1)}\u2026`}r.ellipsize=e;function t(o){return o[0]==null?o:`${o[0].toLocaleUpperCase()}${o.slice(1)}`}r.capitalize=t;function i(o){return o==null||/^\s*$/.test(o)}r.isBlank=i;function n(o){return o instanceof Error?`${o.stack||o.message||o.name}`:String(o)}r.caughtToString=n})(jd||(jd={}));function Z(r,e){return g(e),async(t,i)=>{let n={...t,type:r},o=Object.assign(Le({metadata:i}),de(i)),a=await Promise.allSettled(e.map(p=>p(n,o))),c=TE(a);if(c)throw c.err;return uE.fromPartial({})}}function cb(r){for(let e of u.triggerOnEventHandlers.keys())switch(e){case"PostSubmit":r.provides(wE),U("OnPostSubmit",Z("PostSubmit",u.triggerOnEventHandlers.get(e)));break;case"PostCreate":r.provides(kE),U("OnPostCreate",Z("PostCreate",u.triggerOnEventHandlers.get(e)));break;case"PostUpdate":r.provides(xE),U("OnPostUpdate",Z("PostUpdate",u.triggerOnEventHandlers.get(e)));break;case"PostReport":r.provides(CE),U("OnPostReport",Z("PostReport",u.triggerOnEventHandlers.get(e)));break;case"PostDelete":r.provides(SE),U("OnPostDelete",Z("PostDelete",u.triggerOnEventHandlers.get(e)));break;case"PostFlairUpdate":r.provides(PE),U("OnPostFlairUpdate",Z("PostFlairUpdate",u.triggerOnEventHandlers.get(e)));break;case"CommentSubmit":r.provides(hE),U("OnCommentSubmit",Z("CommentSubmit",u.triggerOnEventHandlers.get(e)));break;case"CommentCreate":r.provides(pE),U("OnCommentCreate",Z("CommentCreate",u.triggerOnEventHandlers.get(e)));break;case"CommentUpdate":r.provides(vE),U("OnCommentUpdate",Z("CommentUpdate",u.triggerOnEventHandlers.get(e)));break;case"CommentReport":r.provides(gE),U("OnCommentReport",Z("CommentReport",u.triggerOnEventHandlers.get(e)));break;case"CommentDelete":r.provides(fE),U("OnCommentDelete",Z("CommentDelete",u.triggerOnEventHandlers.get(e)));break;case"AppInstall":r.provides(cE),U("OnAppInstall",Z("AppInstall",u.triggerOnEventHandlers.get(e)));break;case"AppUpgrade":r.provides(mE),U("OnAppUpgrade",Z("AppUpgrade",u.triggerOnEventHandlers.get(e)));break;case"ModAction":r.provides(yE),U("OnModAction",Z("ModAction",u.triggerOnEventHandlers.get(e)));break;case"ModMail":r.provides(bE),U("OnModMail",Z("ModMail",u.triggerOnEventHandlers.get(e)));break;case"PostNsfwUpdate":r.provides(IE),U("OnPostNsfwUpdate",Z("PostNsfwUpdate",u.triggerOnEventHandlers.get(e)));break;case"PostSpoilerUpdate":r.provides(AE),U("OnPostSpoilerUpdate",Z("PostSpoilerUpdate",u.triggerOnEventHandlers.get(e)));break;default:throw new Error(`Unknown trigger event: ${e}`)}}function TE(r){let e=r.reduce((t,i)=>i.status==="rejected"?[...t,i.reason]:t,[]);if(e.length!==0)return e.length===1?{err:e[0]}:{err:new Error(e.map(t=>jd.caughtToString(t)).join(`
3
+ `))}}var nk=Dr(Cb(),1),sk=Dr(Qd(),1);import{EffectType as AO,UIEventHandlerDefinition as TO}from"@devvit/protos";async function EO(r,e){let t=r.state??{},i=(0,nk.default)(t),n=Le({ui:!0,metadata:e});if(r.event?.formSubmitted&&r.event.formSubmitted.formId){let p=r.event.formSubmitted.formId;if(p.includes("form.hook.")&&u.customPostType){let b=new lt((C,w)=>u.customPostType?.render(w)??null,r.event,r.state,e,void 0);return await b.reconcile(),{state:b.state,effects:b.getEffects()}}let f=u.formDefinitions.get(p);if(!f)throw new Error(`Form with key ${p} not found`);let v,m;if(i.__contextAction){let{actionId:b,thingId:C}=i.__contextAction,w=gm(b);w?.location==="post"?v=C:w?.location==="comment"&&(m=C)}let k=Object.assign(n,de(e,v,m),{uiEnvironment:{timezone:e[L.Timezone]?.values[0],locale:e[L.Language]?.values[0]}});await f.onSubmit({values:wt(r.event.formSubmitted.results)},k)}else if(r.event?.realtimeEvent){if(u.customPostType){let p=new lt((f,v)=>u.customPostType?.render(v)??null,r.event,r.state,e,void 0);return await p.reconcile(),{state:p.state,effects:p.getEffects()}}}else if(r.event?.toastAction)throw new Error("Toast actions not yet implemented");let o=!(0,sk.default)(t,i),a=gi(n.ui),c=o?[...a,{type:AO.EFFECT_RERENDER_UI,rerenderUi:{delaySeconds:0}}]:a;return{state:i,effects:c}}function ok(r){r.provides(TO),U("HandleUIEvent",EO)}import{CustomPostDefinition as Tk}from"@devvit/protos";var ml=Dr(Qd(),1);import{EffectType as Om,Form as OO,ToastAppearance as lk}from"@devvit/protos";function ak(r){let e=r.match(/form\.hook\.(.+)\.0/);if(e?.[1])return e[1]}var Em=class{constructor(e,t,i){this.state=null;this.hookId=e.hookId,this.form=t,this.onSubmit=i,this.onUIEvent=async n=>{n.formSubmitted&&await i(wt(n.formSubmitted.results))}}};function Rm(r,e){let t=De({namespace:"useForm"},i=>new Em(i,r,e));return RO({id:t.hookId})}function RO(r){return`form.hook.${r.id}.0`}function dk(r,e){let t=ak(e);return r.getHook({id:t})}var Ft,el=class{constructor(e){d(this,Ft,void 0);l(this,Ft,e)}showForm(e,t){let i=dk(s(this,Ft),e);if(!i)throw new Error("Form does not exist. Make sure you have added it using useForm.");let n=i.form instanceof Function?i.form(t??{}):i.form,o=OO.fromPartial({id:e,title:n.title,acceptLabel:n.acceptLabel,cancelLabel:n.cancelLabel,shortDescription:n.description});dr(n.fields),o.fields=dt(n.fields),s(this,Ft).emitEffect(e,{type:Om.EFFECT_SHOW_FORM,showForm:{form:o}})}showToast(e){let t;e instanceof Object?t={text:e.text,appearance:e.appearance==="success"?lk.SUCCESS:lk.NEUTRAL}:t={text:e},s(this,Ft).emitEffect(e.toString(),{type:Om.EFFECT_SHOW_TOAST,showToast:{toast:t}})}navigateTo(e){let t;typeof e=="string"?t=new URL(e).toString():t=new URL(e.permalink,"https://www.reddit.com").toString(),s(this,Ft).emitEffect(t,{type:Om.EFFECT_NAVIGATE_TO_URL,navigateToUrl:{url:t}})}};Ft=new WeakMap;import{EffectType as FO,RealtimeSubscriptionStatus as uk}from"@devvit/protos";var Mt,tt,Ut,br,Ss,Mm,tl=class tl{constructor(e,t){d(this,Ss);d(this,Mt,void 0);d(this,tt,void 0);d(this,Ut,void 0);d(this,br,void 0);l(this,Mt,t.context),l(this,tt,!!t.context._devvitContext?.debug.realtime),l(this,br,e),l(this,Ut,t.invalidate);let i=t.context.meta[L.App]?.values[0];if(!i)throw Error("useChannel missing app ID metadata");let n=t.context.meta[L.Installation]?.values[0];if(!n)throw Error("useChannel missing install ID from metadata");let o=`${i}:${n}:${e.name}`;if(Object.values(s(this,Mt).hooks).filter(c=>c instanceof tl).some(c=>c.state.channel===o))throw Error(`useChannel channel names must be unique; "${o}" duplicated`);this.state={channel:o,connected:!1,subscribed:!1}}async onUIEvent(e){let t=e.realtimeEvent;if(!(!t||!this.state.subscribed))switch(t.status){case uk.REALTIME_SUBSCRIBED:s(this,tt)&&console.debug(`[realtime] "${this.state.channel}" connected`),this.state.connected=!0,s(this,Ut).call(this),await s(this,br).onSubscribed?.();break;case uk.REALTIME_UNSUBSCRIBED:s(this,tt)&&console.debug(`[realtime] "${this.state.channel}" disconnected`),this.state.connected=!1,s(this,Ut).call(this),await s(this,br).onUnsubscribed?.();break;default:s(this,tt)&&console.debug(`[realtime] "${this.state.channel}" received message: ${JSON.stringify(e,void 0,2)}`),s(this,br).onMessage(t.event?.data??{});break}}async send(e){if(s(this,tt)&&console.debug(`[realtime] "${this.state.channel}" send message: ${JSON.stringify(e,void 0,2)}`),!this.state.subscribed||!this.state.connected)throw console.debug(`[realtime] "${this.state.channel}" send failed; channel not connected`),Error(`useChannel send failed; "${this.state.channel}" channel not connected`);await s(this,Mt).devvitContext.realtime.send(this.state.channel,e)}get status(){return this.state.subscribed&&this.state.connected?2:this.state.subscribed&&!this.state.connected?1:!this.state.subscribed&&this.state.connected?3:4}subscribe(){this.state.subscribed||(s(this,tt)&&console.debug(`[realtime] "${this.state.channel}" subscribed`),this.state.subscribed=!0,s(this,Ut).call(this),y(this,Ss,Mm).call(this))}unsubscribe(){this.state.subscribed&&(s(this,tt)&&console.debug(`[realtime] "${this.state.channel}" unsubscribed`),this.state.subscribed=!1,s(this,Ut).call(this),y(this,Ss,Mm).call(this))}};Mt=new WeakMap,tt=new WeakMap,Ut=new WeakMap,br=new WeakMap,Ss=new WeakSet,Mm=function(){let e=Object.values(s(this,Mt).hooks).filter(t=>t instanceof tl&&t.state.subscribed).map(t=>t.state.channel);s(this,Mt).emitEffect(this.state.channel,{type:FO.EFFECT_REALTIME_SUB,realtimeSubscriptions:{subscriptionIds:e}})};var Fm=tl;function Um(r){if(!r.name||/[^a-zA-Z0-9]/.test(r.name))throw Error("useChannel error: channel names must be nonempty and alphanumeric");let e=`useChannel:${r.name}`;return De({id:e,namespace:e},t=>new Fm(r,t))}import{EffectType as Lm}from"@devvit/protos";function ck(r){return typeof r=="object"&&r!==null&&"__deleted"in r}var kr,Pi=class Pi{constructor(e,t){d(this,kr,void 0);this._segments=[];this._hooks={};this._prevHookId="";this._effects={};this._changed={};this._requeueEvents=[];this._rootProps={};this._generated={};this._undeliveredHandlers={};this.request=e,this.meta=t,l(this,kr,e.state??{__cache:{}}),this._rootProps=e.props??{}}get devvitContext(){if(!this._devvitContext)throw new Error("Devvit context not available");return this._devvitContext}set devvitContext(e){this._devvitContext=e}get _changedState(){let e={__cache:s(this,kr).__cache??{}};for(let i in this._changed)e[i]=this._state[i];let t=new Set(Object.keys(this._state));return Object.keys(this._hooks).forEach(i=>{i!=="__cache"&&t.delete(i)}),t.forEach(i=>{if(i==="__cache")return;let n={__deleted:!0};this._state[i]=e[i]=n}),e}get hooks(){return this._hooks}get _state(){return s(this,kr)}set _state(e){this._changed={},this._hooks={},l(this,kr,e)}push(e){this._segments.push({...e,next:0})}pop(){this._segments.pop()}addUndeliveredEventHandler(e,t){this._undeliveredHandlers[e]=t}addGlobalUndeliveredEventHandler(e,t){Pi.addGlobalUndeliveredEventHandler(e,t)}getHook(e){return this._hooks[e.id]}static addGlobalUndeliveredEventHandler(e,t){Pi._staticUndeliveredHandlers[e]=t}async handleUndeliveredEvent(e){let t={...Pi._staticUndeliveredHandlers,...this._undeliveredHandlers};for(let[i,n]of Object.entries(t))await n(e,this)}emitEffect(e,t){this._effects[e]=t}addToRequeueEvents(...e){this._devvitContext?.debug.blocks&&console.debug("[blocks] requeueing events",e);let t=e.reduce((i,n)=>(n.retry?i.retry.push(n):i.normal.push(n),i),{retry:[],normal:[]});this._requeueEvents=[...t.retry,...this._requeueEvents,...t.normal]}get effects(){return Object.values(this._effects)}nextHookId(e){e.key===void 0&&(e.key=this._segments[this._segments.length-1].next+++""),this.push(e);try{let t=[];for(let n=this._segments.length-1;n>=0;n--){let o=this._segments[n];if(o.id){t.unshift(o.id);break}let a=[];o.namespace&&a.push(o.namespace),o.key!==void 0&&o.key!==!1&&a.push(o.key),t.unshift(a.join("-"))}let i=t.join(".");if(this._generated[i]&&!e.shared)throw new Error(`Hook id ${i} already used, cannot register another hook with the same id`);return this._generated[i]=!0,this._prevHookId=i,i}finally{this.pop()}}};kr=new WeakMap,Pi._staticUndeliveredHandlers={};var Ci=Pi;var Lt={};Ci.addGlobalUndeliveredEventHandler("intervals",async(r,e)=>{r.timer&&r.hook&&(delete Lt[r.hook],e.emitEffect("timers",{type:Lm.EFFECT_SET_INTERVALS,interval:{intervals:Lt}}))});var Bt,wi,Ps,xi,Bm=class{constructor(e,t,i){d(this,Bt,void 0);d(this,wi,void 0);d(this,Ps,void 0);d(this,xi,void 0);this.state={duration:{seconds:0,nanos:0},running:!1};l(this,wi,i.invalidate),l(this,Bt,i.hookId),l(this,Ps,e),l(this,xi,i.context);let n=Math.floor(t/1e3),o=t%1e3*1e6;this.state.duration={seconds:n,nanos:o}}onStateLoaded(){this.state.running?Lt[s(this,Bt)]={duration:this.state.duration}:delete Lt[s(this,Bt)]}async onUIEvent(e){await s(this,Ps).call(this)}start(){Lt[s(this,Bt)]={duration:this.state.duration},this.state.running=!0,s(this,wi).call(this),s(this,xi).emitEffect("timers",{type:Lm.EFFECT_SET_INTERVALS,interval:{intervals:Lt}})}stop(){delete Lt[s(this,Bt)],this.state.running=!1,s(this,wi).call(this),s(this,xi).emitEffect("timers",{type:Lm.EFFECT_SET_INTERVALS,interval:{intervals:Lt}})}};Bt=new WeakMap,wi=new WeakMap,Ps=new WeakMap,xi=new WeakMap;function Dm(r,e){return De({namespace:"useInterval"},t=>new Bm(r,e,t))}var Ii=class extends Error{};var Sr,Cs,ws,Ai,rl=class{constructor(e,t){this.state={value:null,loading:!1};d(this,Sr,void 0);d(this,Cs,void 0);d(this,ws,void 0);d(this,Ai,void 0);l(this,ws,e),l(this,Ai,t.hookId),l(this,Sr,t.invalidate),l(this,Cs,t.context)}async onUIEvent(){this.state.value===null&&(this.state.value=await s(this,ws).call(this),this.state.loading=!1,s(this,Sr).call(this))}setter(e){this.state.value=e instanceof Function?e(this.state.value):e,s(this,Sr).call(this)}onStateLoaded(){if(this.state.value===null){this.state.loading=!0,s(this,Sr).call(this);let e={asyncRequest:{requestId:s(this,Ai)},hook:s(this,Ai)};throw s(this,Cs).addToRequeueEvents(e),new Ii}}};Sr=new WeakMap,Cs=new WeakMap,ws=new WeakMap,Ai=new WeakMap;function MO(r){let e=De({namespace:"useAsyncState"},t=>new rl(r,t));return[e.state.value,e.setter.bind(e)]}function _m(r){let e=De({namespace:"useState"},t=>{let i=r instanceof Function?r():r;return i instanceof Promise?new rl(()=>i,t):{state:{value:i},setter:o=>{e.state.value=o instanceof Function?o(e.state.value):o,t.invalidate()}}});return[e.state.value,e.setter.bind(e)]}var Hm={now(){return new Date}};function mk(r){return`__autocache__${r}`}function pk(r){return`__lock__${r}`}var UO=300,LO=1e3,il=5e3,Nm=3,fk=.1,gk=1e3,BO=3e4;function hk(r){if(r.error)throw new Error(r.error);return r.value}var Dt,_t,_e,Ti,sl,vk,ol,yk,al,bk,xs,qm,dl,kk,ll,Sk,Is,jm,ul,Pk,nl=class{constructor(e,t,i=Hm){d(this,sl);d(this,ol);d(this,al);d(this,xs);d(this,dl);d(this,ll);d(this,Is);d(this,ul);d(this,Dt,void 0);d(this,_t,{});d(this,_e,void 0);d(this,Ti,void 0);l(this,Dt,e),l(this,Ti,t),l(this,_e,i)}async cache(e,t){var a;(a=s(this,Ti)).__cache??(a.__cache={}),l(this,_t,s(this,Ti).__cache),y(this,ul,Pk).call(this,t);let i=y(this,sl,vk).call(this,t.key);if(i!==void 0)return i;let n=await y(this,Is,jm).call(this,t.key),o=await y(this,ol,yk).call(this,t,n,e);return hk(o)}};Dt=new WeakMap,_t=new WeakMap,_e=new WeakMap,Ti=new WeakMap,sl=new WeakSet,vk=function(e){let t=s(this,_t)[e];if(t){let i=s(this,_e).now().getTime(),n=t?.error&&t?.errorTime&&t.errorCount<Nm&&Math.random()<fk&&t.errorTime+gk<i;if(t?.expires&&t.expires<i&&t.checkedAt+gk<i||n){delete s(this,_t)[e];return}else return hk(t)}},ol=new WeakSet,yk=async function(e,t,i){let n=t?.expires,o=n?y(this,ll,Sk).call(this,n):1;return!t||t?.error&&t.errorCount<Nm&&fk>Math.random()||o>Math.random()?y(this,al,bk).call(this,e,t,i):t},al=new WeakSet,bk=async function(e,t,i){let n=pk(e.key),o=s(this,_e).now().getTime(),a=new Date(o+e.ttl/2);if(await s(this,Dt).set(n,"1",{expiration:a,nx:!0}))return y(this,dl,kk).call(this,e.key,t,i,e.ttl);if(t)return t;{let p=s(this,_e).now();return y(this,xs,qm).call(this,p,e.key,e.ttl)}},xs=new WeakSet,qm=async function(e,t,i){let n=Math.min(i,LO),o=await y(this,Is,jm).call(this,t);if(o)return o;if(s(this,_e).now().getTime()-e.getTime()>=n)throw new Error(`Cache request timed out trying to get data at key: ${t}`);return await new Promise(a=>setTimeout(a,UO)),y(this,xs,qm).call(this,e,t,i)},dl=new WeakSet,kk=async function(e,t,i,n){let o=s(this,_e).now().getTime()+n;t=t??{value:null,expires:o,errorCount:0,error:null,errorTime:null,checkedAt:0};try{t.value=await i(),t.error=null,t.errorCount=0,t.errorTime=null}catch(a){t.value=null,t.error=a.message??"Unknown error",t.errorTime=s(this,_e).now().getTime(),t.errorCount++}return s(this,_t)[e]=t,await s(this,Dt).set(mk(e),JSON.stringify(t),{expiration:new Date(o+BO)}),t.error&&t.errorCount<Nm&&await s(this,Dt).del(pk(e)),t},ll=new WeakSet,Sk=function(e){let t=s(this,_e).now().getTime(),i=e-t;return i<0?1:i<1e3?.1:i<2e3?.01:i<3e3?.001:0},Is=new WeakSet,jm=async function(e){let t=await s(this,Dt).get(mk(e));if(t){let i=JSON.parse(t);return i.checkedAt=s(this,_e).now().getTime(),s(this,_t)[e]=i,i}},ul=new WeakSet,Pk=function(e){e.ttl<il&&(console.warn(`Cache TTL cannot be less than ${il} milliseconds! Updating ttl value of ${e.ttl} to ${il}.`),e.ttl=il)};function Ck(r,e,t=Hm){let i=new nl(r,e,t);return i.cache.bind(i)}var cl=class{buildContext(e,t,i){let n=new oi(i),o=new ni(i),a=new ci(i),c=new li(i),p=new mi(i),f=new pi(i),v=new el(e),m=new si(i),k=new ii,b=new ai(i),C=Ck(a,e._state),w={modLog:n,kvStore:o,redis:a,reddit:c,scheduler:p,settings:f,media:m,assets:k,realtime:b,ui:v,useState:_m,useChannel:Um,useInterval:Dm,useForm:Rm,cache:C,dimensions:t.env?.dimensions,uiEnvironment:{timezone:i[L.Timezone]?.values[0],locale:i[L.Language]?.values[0],dimensions:t.env?.dimensions}},I=de(i,t.props?.postId);return I.debug.effects=e,{...I,...w}}};var ye=null;function Wm(r){return JSON.parse(JSON.stringify(r))}function DO(r){if(!(r!==""&&!/[-.]/.test(r)))throw new Error(`Hook with namespace '${r}' is invalid. Hook namespaces cannot be empty string or contain dashes/dots because they are used as delimiters internally. Please update the hook namespace and try again.`)}function _O(r){return r.blocking||r.resize?!1:!r.hook}function De(r,e){if(!ye)throw new Error("Hooks can only be declared at the top of a component. You cannot declare hooks outside of components or inside of event handlers. It's almost always a mistake to declare hooks inside of loops or conditionals.");DO(r.namespace);let t=ye.nextHookId(r),i=ye,n={hookId:t,invalidate:()=>{i._changed[t]=!0,i._state[t]=i?._hooks[t]?.state},context:ye},o=ye._state[t]===void 0||ck(ye._state[t]);ye._hooks[t]=ye._hooks[t]??e(n);let a=ye._hooks[t];return o||(a.state=ye._state[t]),a.onStateLoaded?.(),o&&a.state!==void 0&&a.state!==null&&n.invalidate(),a}var NO=null,Ei,hl,As,ne,be,Ri,pl,vl,wk,Ts,Gm,yl,xk,bl,Ik,Es,Vm,Rs,zm,Oi,fl,Os,Jm,kl,Ak,gl=class{constructor(e){d(this,ne);d(this,Ri);d(this,vl);d(this,Ts);d(this,yl);d(this,bl);d(this,Es);d(this,Rs);d(this,Oi);d(this,Os);d(this,kl);d(this,Ei,void 0);d(this,hl,new cl);d(this,As,new yi(()=>this._latestRenderContext?.devvitContext?.assets));this._latestRenderContext=null;s(this,ne,be)&&console.debug("[blocks] BlocksHandler v1"),l(this,Ei,e),NO=this}async handle(e,t){let i=new Ci(e,t),n=s(this,hl).buildContext(i,e,t);i.devvitContext=n;let o,a=e.events,p=!e.events?.length||a.some(b=>!b.async),f=a.some(b=>b.blocking),v,m,k=[...a];for(s(this,ne,be)&&console.debug("[blocks] starting processing events");a.length>0;){s(this,ne,be)&&console.debug("[blocks] processing events loop iteration",a.length);let b=[];if(!a[0].async)b.push(a.shift());else for(;a[0]?.async;)b.push(a.shift());if(!b.length)throw Error("batch must have at least one event");try{if(b[0].async){let w=Wm(i._state);await y(this,vl,wk).call(this,i,...b),i._state=w}else await y(this,yl,xk).call(this,i,...b)}catch(w){if(s(this,ne,be)&&console.debug("[blocks] caught in handler",w),m){i._state=m._state,i._changed=v,i._effects=m._effects;let I=k.map(E=>{let ue={...E};return ue.retry=!0,ue});i.addToRequeueEvents(...I);break}else throw w}s(this,ne,be)&&console.debug("[blocks] remaining events",i._requeueEvents);let C=[];for(let w of i._requeueEvents){if(!p&&!w.async){s(this,ne,be)&&console.debug("[blocks] NOT reprocessing event in BlocksHandler, sync mismatch A",w),C.push(w);continue}if(p&&w.async&&!f){s(this,ne,be)&&console.debug("[blocks] NOT reprocessing event in BlocksHandler, sync mismatch B",w),C.push(w);continue}s(this,ne,be)&&console.debug("[blocks] reprocessing event in BlocksHandler",w),a.push(w)}i._requeueEvents=C,a.length>0&&(v={...i._changed},m={_state:Wm(i._state),_effects:{...i._effects}},k=[...a])}if(p){let b=Wm(i._state),C=[...i._requeueEvents],w={...i._effects},I=y(this,Es,Vm).call(this,s(this,Ei),i._rootProps??{},i);if((0,ml.default)(i._state,b)||console.error("[blocks] State was mutated during rendering",i._state,b),(0,ml.default)(i._requeueEvents,C)||console.error("[blocks] Events were mutated during rendering",i._requeueEvents,C),(0,ml.default)(i._effects,w)||console.error("[blocks] Effects were mutated during rendering",i._effects,w),I){let E=y(this,bl,Ik).call(this,i);o=s(this,As).createBlocksElementOrThrow(I,E),o=s(this,As).ensureRootBlock(o,E)}}return{state:i._changedState,effects:i.effects,blocks:o,events:i._requeueEvents}}};Ei=new WeakMap,hl=new WeakMap,As=new WeakMap,ne=new WeakSet,be=function(){return!!this._latestRenderContext?.devvitContext.debug.blocks},Ri=new WeakSet,pl=function(e,...t){e._hooks={},y(this,Es,Vm).call(this,s(this,Ei),e.request.props??{},e)},vl=new WeakSet,wk=async function(e,...t){y(this,Ri,pl).call(this,e,...t),await Promise.all(t.map(async i=>{if(!i.async)throw new Error("You can't mix main and other queues in one batch. This is likely a platform bug. Please file an issue in the Discord for someone to help! https://discord.com/channels/1050224141732687912/1115441897079574620");await y(this,Ts,Gm).call(this,e,i)}))},Ts=new WeakSet,Gm=async function(e,t){_O(t)&&console.warn("Received an event in #attemptHook that does not have an associated hook. This will cause the event to be undelivered and may cause bugs. Make sure that event passes a hook field. Event:",{event:t});let i=e._hooks[t.hook];if(i?.onUIEvent)try{await i.onUIEvent(t,e)}catch(n){throw console.error("Error in event handler",n),n}else await e.handleUndeliveredEvent(t)},yl=new WeakSet,xk=async function(e,...t){for(let i of t)s(this,ne,be)&&console.log("[blocks] handling main queue event",i),s(this,ne,be)&&console.log("[blocks] before",e._state),y(this,Ri,pl).call(this,e,i),await y(this,Ts,Gm).call(this,e,i),s(this,ne,be)&&console.log("[blocks] after",e._state);y(this,Ri,pl).call(this,e)},bl=new WeakSet,Ik=function(e){return{maxDimensions:e.devvitContext.dimensions??Md}},Es=new WeakSet,Vm=function(e,t,i){s(this,ne,be)&&console.debug("[blocks] renderRoot"),i._generated={},ye=i,this._latestRenderContext=i;try{let n=y(this,Rs,zm).call(this,e,t,i);if(n.length!==1)throw new Error(`There can only be one root element, received: ${n.length}. Please wrap these elements in a <vstack></vstack> or <hstack></hstack> to continue. Fragments cannot be used as a root element.`);let o=n[0];if(o==="[object Promise]")throw new Error('Root elements cannot be asynchronous. To use data from an async endpoint, please use "const [data] = context.useState(async () => {/** your async code */})".');if(typeof o=="string")throw new Error("The root element must return a valid block, not a string. Try wrapping the element in a <text>your content</text> tag to continue.");return o}catch(n){if(n instanceof Ii)return;throw n}finally{ye=null}},Rs=new WeakSet,zm=function(e,t,i){i.push({namespace:e.name||"anonymous",...t});try{let n=e(t,i.devvitContext);return y(this,Os,Jm).call(this,n,i)}finally{i.pop()}},Oi=new WeakSet,fl=function(e,t){return e=e.flat(1/0),e.flatMap((i,n)=>(i&&typeof i=="object"&&"props"in i&&(i.props?.key||(i.props=i.props??{},i.props.key=`${n}`)),y(this,Os,Jm).call(this,i,t)))},Os=new WeakSet,Jm=function(e,t){if(Array.isArray(e))return y(this,Oi,fl).call(this,e,t);if(qO(e))if(e.type===void 0){t.push({namespace:"fragment",...e.props});let i=y(this,Oi,fl).call(this,e.children,t);return t.pop(),i}else if(typeof e.type=="function"){let i={...e.props,children:e.children};return y(this,Rs,zm).call(this,e.type,i,t)}else{t.push({namespace:e.type,...e.props});let i=y(this,Oi,fl).call(this,e.children,t),n=y(this,kl,Ak).call(this,e.props??{});return t.pop(),[{type:e.type,children:i,props:n}]}else return[(e??"").toString()]},kl=new WeakSet,Ak=function(e){let t={};for(let i in e)if(!(typeof e[i]>"u"))if(typeof e[i]=="function"){let n=De({namespace:i,key:!1},({hookId:o})=>({hookId:o,state:null,onUIEvent:e[i]}));t[i]=n.hookId,"captureHookRef"in e[i]&&e[i].captureHookRef()}else{let n=JSON.parse(JSON.stringify(e[i]));n!=null&&(t[i]=n)}return t};function qO(r){return typeof r=="object"&&r!=null&&"type"in r}var jO=[[Tk,Tk.methods.renderPostContent,(r,e)=>u.customPostType?.render(e)??null]];function HO(r){return async(e,t)=>new gl(r).handle(e,t)}function Ek(r){for(let[e,t,i]of jO)r.provides(e),U(t.name,HO(i))}var Fi,Fs,Ms,Pr,Cr,Mi,Ui,wr,Nt,Us,xr,_,j,z,B=class B extends yd{static configure(e){l(this,Ms,e),ut(e.http)&&y(this,j,z).call(this,P.HTTPDefinition),(ut(e.kvStore)||ut(e.redis))&&(y(this,j,z).call(this,P.KVStoreDefinition),y(this,j,z).call(this,P.RedisAPIDefinition)),ut(e.media)&&y(this,j,z).call(this,P.MediaServiceDefinition),ut(e.modLog)&&y(this,j,z).call(this,P.ModlogDefinition),ut(e.redditAPI)&&(y(this,j,z).call(this,P.FlairDefinition),y(this,j,z).call(this,P.GraphQLDefinition),y(this,j,z).call(this,P.LinksAndCommentsDefinition),y(this,j,z).call(this,P.ListingsDefinition),y(this,j,z).call(this,P.ModerationDefinition),y(this,j,z).call(this,P.ModNoteDefinition),y(this,j,z).call(this,P.NewModmailDefinition),y(this,j,z).call(this,P.PrivateMessagesDefinition),y(this,j,z).call(this,P.SubredditsDefinition),y(this,j,z).call(this,P.PostCollectionsDefinition),y(this,j,z).call(this,P.UsersDefinition),y(this,j,z).call(this,P.WidgetsDefinition),y(this,j,z).call(this,P.WikiDefinition),y(this,j,z).call(this,P.RedditAPIV2Definition)),ut(e.realtime)&&y(this,j,z).call(this,P.RealtimeDefinition)}static addMenuItem(e){s(this,Ui).push(e)}static addCustomPostType(e){l(this,Pr,e)}static createForm(e,t){let i=`form.${s(this,Cr).size}`;return s(this,Cr).set(i,{form:e,onSubmit:t}),i}static addSchedulerJob(e){if(s(this,_)[P.SchedulerDefinition.fullName]||y(this,j,z).call(this,P.SchedulerDefinition),s(this,wr).has(e.name))throw new Error(`Job ${e.name} is already defined`);s(this,wr).set(e.name,e.onRun)}static addSettings(e){dr(e);let t=e.filter(n=>n.type==="group"||!n.scope||n.scope==="installation"),i=e.filter(n=>n.type!=="group"&&n.scope==="app");t.length>0&&l(this,Mi,t),i.length>0&&l(this,Fi,i),s(this,_)[P.SettingsDefinition.fullName]||y(this,j,z).call(this,P.SettingsDefinition)}static addTrigger(e){if("events"in e){for(let t of e.events)this.addTrigger({event:t,onEvent:(i,n)=>e.onEvent(i,n)});return this}return s(this,Nt).has(e.event)?s(this,Nt).get(e.event)?.push(e.onEvent):s(this,Nt).set(e.event,[e.onEvent]),B}static get redditAPIPlugins(){if(!ut(s(this,Ms).redditAPI))throw new Error("Reddit API is not enabled. You can enable it by passing `redditAPI: true` to `Devvit.configure`.");return{Flair:s(this,_)[P.FlairDefinition.fullName],GraphQL:s(this,_)[P.GraphQLDefinition.fullName],LinksAndComments:s(this,_)[P.LinksAndCommentsDefinition.fullName],Listings:s(this,_)[P.ListingsDefinition.fullName],Moderation:s(this,_)[P.ModerationDefinition.fullName],ModNote:s(this,_)[P.ModNoteDefinition.fullName],NewModmail:s(this,_)[P.NewModmailDefinition.fullName],PrivateMessages:s(this,_)[P.PrivateMessagesDefinition.fullName],Subreddits:s(this,_)[P.SubredditsDefinition.fullName],PostCollections:s(this,_)[P.PostCollectionsDefinition.fullName],Users:s(this,_)[P.UsersDefinition.fullName],Widgets:s(this,_)[P.WidgetsDefinition.fullName],Wiki:s(this,_)[P.WikiDefinition.fullName]}}static get modLogPlugin(){let e=s(this,_)[P.ModlogDefinition.fullName];if(!e)throw new Error("ModLog is not enabled. You can enable it by passing `modLog: true` to `Devvit.configure`");return e}static get schedulerPlugin(){let e=s(this,_)[P.SchedulerDefinition.fullName];if(!e)throw new Error("Scheduler is not enabled. You can enable it by calling `Devvit.addSchedulerJob` at the top level of your app.");return e}static get kvStorePlugin(){let e=s(this,_)[P.KVStoreDefinition.fullName];if(!e)throw new Error("Key Value Store is not enabled. You can enable it by passing `kvStore: true` to `Devvit.configure`");return e}static get redisPlugin(){let e=s(this,_)[P.RedisAPIDefinition.fullName];if(!e)throw new Error("Redis is not enabled. You can enable it by passing `redis: true` to `Devvit.configure`");return e}static get mediaPlugin(){let e=s(this,_)[P.MediaServiceDefinition.fullName];if(!e)throw new Error("MediaService is not enabled. You can enable it by passing `media: true` to `Devvit.configure`");return e}static get redditapiv2Plugin(){let e=s(this,_)[P.RedditAPIV2Definition.fullName];if(!e)throw new Error("RedditAPIV2 is not enabled. You can enable it by passing `apiV2: true` to `Devvit.configure`");return e}static get settingsPlugin(){let e=s(this,_)[P.SettingsDefinition.fullName];if(!e)throw new Error("Settings must first be configured with `Devvit.addSettings()` before they can be accessed");return e}static get realtimePlugin(){let e=s(this,_)[P.RealtimeDefinition.fullName];if(!e)throw new Error("Realtime is not enabled. You can enable it by passing `realtime: true` to `Devvit.configure`");return e}static get menuItems(){return s(this,Ui)}static get customPostType(){return s(this,Pr)}static get formDefinitions(){return s(this,Cr)}static get scheduledJobHandlers(){return s(this,wr)}static get installationSettings(){return s(this,Mi)}static get appSettings(){return s(this,Fi)}static get triggerOnEventHandlers(){return s(this,Nt)}static get assets(){return s(this,Fs)}static get webviewAssets(){return s(this,Us)}constructor(e){super(e),l(B,Fs,e.assets??{}),l(B,Us,e.webviewAssets??{});for(let t in s(B,xr)){let i=s(B,xr)[t];i.handler=e.use(i.def,i.options)}s(B,Ui).length>0&&lb(e),s(B,wr).size>0&&ub(e),s(B,Pr)&&(ob(e),Ek(e)),(s(B,Pr)||s(B,Cr).size>0)&&ok(e),s(B,Mi)&&ab(e),s(B,Fi)&&Dy(e),s(B,Nt).size>0&&cb(e)}};Fi=new WeakMap,Fs=new WeakMap,Ms=new WeakMap,Pr=new WeakMap,Cr=new WeakMap,Mi=new WeakMap,Ui=new WeakMap,wr=new WeakMap,Nt=new WeakMap,Us=new WeakMap,xr=new WeakMap,_=new WeakMap,j=new WeakSet,z=function(e,t){s(this,xr)[e.fullName]={def:e,options:t??{},handler:void 0};let i={};for(let n of Object.values(e.methods))i[n.name]=(o,a)=>s(this,xr)[e.fullName].handler?.[n.name]?.(n.requestType?.fromPartial(o??{}),a);return s(this,_)[e.fullName]=i,i},d(B,j),B.debug={},d(B,Fi,void 0),d(B,Fs,{}),d(B,Ms,{}),d(B,Pr,void 0),d(B,Cr,new Map),d(B,Mi,void 0),d(B,Ui,[]),d(B,wr,new Map),d(B,Nt,new Map),d(B,Us,{}),d(B,xr,{}),d(B,_,{});var u=B;(e=>{function r(t,i,...n){return{type:t,props:i,children:n}}e.createElement=r})(u||(u={}));function J(r){let e=Object.getOwnPropertyDescriptors(r.constructor.prototype);for(let[t,i]of Object.entries(e))i.get&&Object.defineProperty(r,t,{...i,enumerable:!0})}var $m;(function(r){r[r.bold=1]="bold",r[r.italic=2]="italic",r[r.underline=4]="underline",r[r.strikethrough=8]="strikethrough",r[r.subscript=16]="subscript",r[r.superscript=32]="superscript",r[r.monospace=64]="monospace"})($m||($m={}));var Rk="text",Ok="raw",Fk="br",Mk="link",Uk="c/",Lk="p/",Bk="r/",Dk="u/",_k="@",Nk="spoilertext",qk="par",jk="h",Hk="hr",Wk="blockquote",Gk="code",Vk="li",zk="list",Jk="L",$k="R",Kk="C",Xk="table",Zk="embed",Yk="img",Qk="gif",eS="video";function tS(r){return{e:Qk,id:r.mediaId,...r.caption&&{c:r.caption},...r.blur&&{o:r.blur}}}function rS(r,e){let t={},i=[];return Object.assign(t,Ls(t,i),Bs(t,i),Ds(t,i),qs(t,i),js(t,i),Hs(t,i)),e(t),{e:Wk,c:i,...r.author&&{a:r.author}}}function iS(r,e){let t={},i=[];return Object.assign(t,Xm(t,i)),e(t),{e:Gk,c:i,...r.language&&{l:r.language}}}function nS(r){return{e:Uk,t:r.permalink}}function sS(r,e){let t={},i=[];return Object.assign(t,Xm(t,i),Ns(t,i)),e(t),{e:jk,l:r.level,c:i}}function oS(r){return{e:Zk,u:r.sourceUrl,c:r.contentUrl,x:r.width,y:r.height}}function aS(){return{e:Hk}}function dS(r){return{e:Yk,id:r.mediaId,...r.caption&&{c:r.caption},...r.blur&&{o:r.blur}}}function lS(){return{e:Fk}}function uS(r){return{e:Mk,t:r.text,u:r.url,...r.formatting&&{f:r.formatting},...r.tooltip&&{a:r.tooltip}}}function cS(r,e){let t={},i=[];return Object.assign(t,AS(t,i)),e(t),{e:zk,o:r.ordered,c:i}}function mS(r){let e={},t=[];return Object.assign(e,Ls(e,t),Bs(e,t),Ds(e,t),Sl(e,t),qs(e,t),js(e,t),Hs(e,t)),r(e),{e:Vk,c:t}}function pS(r){let e={},t=[];return Object.assign(e,Pl(e,t),Ns(e,t),Km(e,t),Zm(e,t),_s(e,t)),r(e),{e:qk,c:t}}function fS(r){return{e:Lk,t:r.permalink}}function gS(r){return{e:Ok,t:r}}function hS(r){let e={},t=[];return Object.assign(e,Pl(e,t),Ns(e,t),Km(e,t)),r(e),{e:Nk,c:t}}function vS(r){return{e:Bk,t:r.subredditName,l:r.showPrefix}}function yS(r){let e={},t=[],i=[];return Object.assign(e,TS(e,t,i)),r(e),{e:Xk,h:t,c:i}}function bS(r){let[e,t]=IS();return r(e),{c:t}}function kS(r,e){let[t,i]=IS();e(t);let n;switch(r.columnAlignment){case"left":n=Jk;break;case"right":n=$k;break;case"center":n=Kk;break}return{...n&&{a:n},...i&&{c:i}}}function SS(r){let e={},t=[];return Object.assign(e,ES(e,t)),r(e),t}function PS(r){return{e:Rk,t:r.text,...r.formatting&&{f:r.formatting}}}function CS(r){return{e:Dk,t:r.username,l:r.showPrefix}}function wS(r){return{e:_k,t:r.username,l:r.showPrefix}}function xS(r){return{e:eS,id:r.mediaId,...r.caption&&{c:r.caption},...r.blur&&{o:r.blur},...r.thumbnail&&{p:r.thumbnail},...r.convertToGif&&{gifify:r.convertToGif}}}function IS(){let r={},e=[];return Object.assign(r,Pl(r,e),Ns(r,e),Zm(r,e),_s(r,e)),[r,e]}function Ls(r,e){return{blockQuote(t,i){return e.push(rS(t,i)),r}}}function Bs(r,e){return{codeBlock(t,i){return e.push(iS(t,i)),r}}}function RS(r,e){return{embed(t){return e.push(oS(t)),r}}}function Ds(r,e){return{heading(t,i){return e.push(sS(t,i)),r}}}function Sl(r,e){return{horizontalRule(){return e.push(aS()),r}}}function _s(r,e){return{image(t){return e.push(dS(t)),r},animatedImage(t){return e.push(tS(t)),r}}}function Km(r,e){return{linebreak(){return e.push(lS()),r}}}function Ns(r,e){return{link(t){return e.push(uS(t)),r},commentLink(t){return e.push(nS(t)),r},postLink(t){return e.push(fS(t)),r},subredditLink(t){return e.push(vS(t)),r},userLink(t){return e.push(CS(t)),r},userMention(t){return e.push(wS(t)),r}}}function qs(r,e){return{list(t,i){return e.push(cS(t,i)),r}}}function AS(r,e){return{item(t){return e.push(mS(t)),r}}}function js(r,e){return{paragraph(t){return e.push(pS(t)),r}}}function Xm(r,e){return{rawText(t){return e.push(gS(t)),r}}}function Zm(r,e){return{spoiler(t){return e.push(hS(t)),r}}}function TS(r,e,t){return{headerCell(i,n){return e.push(kS(i,n)),r},row(i){return t.push(SS(i)),r}}}function Hs(r,e){return{table(t){return e.push(yS(t)),r}}}function ES(r,e){return{cell(t){return e.push(bS(t)),r}}}function Pl(r,e){return{text(t){return e.push(PS(t)),r}}}function OS(r,e){return{video(t){return e.push(xS(t)),r}}}var WO=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},GO=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},Cl,Ws=class{constructor(){Cl.set(this,void 0);let e=[];Object.assign(this,js(this,e),Ds(this,e),Sl(this,e),Ls(this,e),Bs(this,e),RS(this,e),qs(this,e),Hs(this,e),_s(this,e),OS(this,e)),WO(this,Cl,{document:e},"f")}build(){return JSON.stringify(GO(this,Cl,"f"))}paragraph(e){return this}heading(e,t){return this}horizontalRule(){return this}blockQuote(e,t){return this}codeBlock(e,t){return this}embed(e){return this}list(e,t){return this}table(e){return this}image(e){return this}animatedImage(e){return this}video(e){return this}};Cl=new WeakMap;function Li(r){let e;return r instanceof Ws?e=r.build():typeof r=="object"?e=JSON.stringify(r):e=r,e}var FS=100,MS=1/0,Ir,Ar,qt,Bi,Di,wl,H=class{constructor(e){d(this,Di);d(this,Ir,void 0);d(this,Ar,void 0);d(this,qt,void 0);d(this,Bi,!1);this.pageSize=FS;this.limit=MS;this.children=[];J(this),this._fetch=e.fetch,this.pageSize=e.pageSize??FS,this.limit=e.limit??MS,l(this,Ar,e.after),l(this,Ir,e.before),l(this,qt,e.more),e.children&&(this.children=e.children)}get hasMore(){return!s(this,Bi)||!!(s(this,Ar)||s(this,Ir)||s(this,qt))}async*[Symbol.asyncIterator](){let e=0;for(;;){if(e===this.children.length)if(this.hasMore){if((await y(this,Di,wl).call(this)).length===0)break}else break;if(yield this.children[e],e++,e===this.limit)break}}setMore(e){l(this,qt,e)}preventInitialFetch(){l(this,Bi,!0)}async all(){for(;this.hasMore&&this.children.length<this.limit;)await y(this,Di,wl).call(this);return this.children.slice(0,this.limit)}async get(e){let t=e<=this.limit?e:this.limit;for(;this.hasMore&&this.children.length<t;)await y(this,Di,wl).call(this);return this.children.slice(0,t)}};Ir=new WeakMap,Ar=new WeakMap,qt=new WeakMap,Bi=new WeakMap,Di=new WeakSet,wl=async function(){if(!this.hasMore)throw new Error("This listing does not have any more items to load.");let{children:e,before:t,after:i,more:n}=await this._fetch({before:s(this,Ir),after:s(this,Ar),limit:this.pageSize,more:s(this,qt)});return this.children.push(...e),l(this,Ir,t),l(this,Ar,i),l(this,qt,n),l(this,Bi,!0),e};function VO(r){try{return!0}catch{return!1}}function zO(r){try{return!0}catch{return!1}}var Gs,Ym,Me=class{constructor(){}static get(e,t){let i=u.redditAPIPlugins.ModNote;return new H({hasMore:!0,before:e.before,limit:e.limit,pageSize:e.limit,fetch:async n=>{let o=await i.GetNotes({subreddit:e.subreddit,user:e.user,filter:e.filter,before:n.before,limit:n.limit},t);return{children:o.modNotes?.map(a=>y(this,Gs,Ym).call(this,a))||[],before:o.hasNextPage?o.endCursor:void 0,hasMore:o.hasNextPage}}})}static async delete(e,t){let i=u.redditAPIPlugins.ModNote,{deleted:n}=await i.DeleteNotes(e,t);return!!n}static async add(e,t){let n=await u.redditAPIPlugins.ModNote.PostNotes(e,t);if(!n?.created)throw new Error("Failed to create mod note");return y(this,Gs,Ym).call(this,n.created)}static async addRemovalNote(e,t){await u.redditAPIPlugins.ModNote.PostRemovalNote(e,t)}};Gs=new WeakSet,Ym=function(e){if(g(e.id,"Mod note ID is null or undefined"),g(e.createdAt,"Mod note createdAt is null or undefined"),g(e.type,"Mod note type is null or undefined"),g(e.subreddit,"Mod note subreddit is null or undefined"),g(e.subredditId,"Mod note subredditId is null or undefined"),g(e.operator,"Mod note operator is null or undefined"),g(e.operatorId,"Mod note operatorId is null or undefined"),g(e.user,"Mod note user is null or undefined"),g(e.userId,"Mod note userId is null or undefined"),g(e.userNoteData,"Mod note userNote is null or undefined"),g(e.modActionData,"Mod note modAction is null or undefined"),!VO(e.userNoteData?.label??""))throw new Error(`Invalid user note label: ${e.userNoteData?.label}`);if(!zO(e.type))throw new Error(`Invalid mod note type: ${e.type}`);return{id:e.id,user:{id:re(e.userId??""),name:e.user},subreddit:{id:Re(e.subredditId??""),name:e.subreddit},operator:{id:re(e.operatorId??""),name:e.operator},createdAt:new Date(e.createdAt*1e3),userNote:{note:e.userNoteData?.note,redditId:ge(e.userNoteData?.redditId??""),label:e.userNoteData?.label},type:e.type}},d(Me,Gs);var jt=class{static queryWithQueryString(e,t){return u.redditAPIPlugins.GraphQL.Query({query:e},t)}static query(e,t,i,n){return u.redditAPIPlugins.GraphQL.PersistedQuery({operationName:e,id:t,variables:i},n)}};var US=["all","wiki","posts","access","mail","config","flair","channels","chat_config","chat_community","chat_operator"];function JO(r,e,t=!1){let i=t?"%2b":"+";return e.map(n=>(r.includes(n)?i:"-")+n).join(",")}function Qm(r){return JO(r,US,!0)}function LS(r){return r.filter(e=>US.includes(e))}var $O=(t=>(t.User="USER_FLAIR",t.Post="LINK_FLAIR",t))($O||{}),Tr,_i,Ni,qi,ji,Hi,Wi,Gi,Vi,zi,Ji,xl,$e=class $e{constructor(e,t,i){d(this,Tr,void 0);d(this,_i,void 0);d(this,Ni,void 0);d(this,qi,void 0);d(this,ji,void 0);d(this,Hi,void 0);d(this,Wi,void 0);d(this,Gi,void 0);d(this,Vi,void 0);d(this,zi,void 0);J(this),g(e.id),g(e.text),l(this,Tr,e.id),l(this,_i,t),l(this,Ni,e.text),l(this,qi,KO(e.textColor)),l(this,ji,XO(e.backgroundColor)),l(this,Hi,ZO(e.allowableContent)),l(this,Wi,e.modOnly),l(this,Gi,e.maxEmojis),l(this,Vi,e.textEditable),l(this,zi,i)}get id(){return s(this,Tr)}get text(){return s(this,Ni)}get textColor(){return s(this,qi)}get backgroundColor(){return s(this,ji)}get allowableContent(){return s(this,Hi)}get modOnly(){return s(this,Wi)}get maxEmojis(){return s(this,Gi)}get allowUserEdits(){return s(this,Vi)}async delete(){return $e.deleteFlairTemplate(s(this,Tr),s(this,_i),s(this,zi))}async edit(e){return $e.editFlairTemplate({id:s(this,Tr),subredditName:s(this,_i),text:e.text??s(this,Ni),allowableContent:e.allowableContent??s(this,Hi),backgroundColor:e.backgroundColor??s(this,ji),maxEmojis:e.maxEmojis??s(this,Gi),modOnly:e.modOnly??s(this,Wi),textColor:e.textColor??s(this,qi),allowUserEdits:e.allowUserEdits??s(this,Vi)},s(this,zi))}static async createPostFlairTemplate(e,t){var i;return y(i=$e,Ji,xl).call(i,{...e,flairType:"LINK_FLAIR"},t)}static async createUserFlairTemplate(e,t){var i;return y(i=$e,Ji,xl).call(i,{...e,flairType:"USER_FLAIR"},t)}static async editFlairTemplate(e,t){var i;return y(i=$e,Ji,xl).call(i,e,t)}static async getPostFlairTemplates(e,t){return(await u.redditAPIPlugins.Flair.LinkFlair({subreddit:e},t)).flair?.map(o=>new $e(o,e,t))||[]}static async getUserFlairTemplates(e,t){return(await u.redditAPIPlugins.Flair.UserFlair({subreddit:e},t)).flair?.map(o=>new $e(o,e,t))||[]}static async deleteFlairTemplate(e,t,i){await u.redditAPIPlugins.Flair.DeleteFlairTemplate({subreddit:e,flairTemplateId:t},i)}};Tr=new WeakMap,_i=new WeakMap,Ni=new WeakMap,qi=new WeakMap,ji=new WeakMap,Hi=new WeakMap,Wi=new WeakMap,Gi=new WeakMap,Vi=new WeakMap,zi=new WeakMap,Ji=new WeakSet,xl=async function(e,t){let{subredditName:i,allowableContent:n="all",backgroundColor:o="transparent",flairType:a="",maxEmojis:c=10,modOnly:p=!1,text:f,textColor:v="dark",allowUserEdits:m=!1,id:k=""}=e;if(p&&m)throw new Error("Cannot have a mod only flair that is editable by users");let C=await u.redditAPIPlugins.Flair.FlairTemplate({subreddit:i,allowableContent:n,backgroundColor:o,flairType:a,maxEmojis:c,modOnly:p,text:f,textColor:v,textEditable:m,flairTemplateId:k,cssClass:"",overrideCss:!1},t);return new $e(C,i,t)},d($e,Ji);var ae=$e;function Js(r){return{flairCssClass:r.flairCssClass,user:r.user,flairText:r.flairText}}var Vs,ep,zs,tp,Ht=class Ht{static async getUserFlairBySubreddit(e,t){return u.redditAPIPlugins.Flair.FlairList(e,t)}static setUserFlair(e,t){var i;return y(i=Ht,Vs,ep).call(i,e,t)}static setPostFlair(e,t){var i;return y(i=Ht,Vs,ep).call(i,{...e,postId:fe(e.postId)},t)}static async removePostFlair(e,t,i){var n;return y(n=Ht,zs,tp).call(n,e,t,void 0,i)}static async removeUserFlair(e,t,i){var n;return y(n=Ht,zs,tp).call(n,e,void 0,t,i)}};Vs=new WeakSet,ep=async function(e,t){await u.redditAPIPlugins.Flair.SelectFlair({subreddit:e.subredditName,flairTemplateId:e.flairTemplateId??"",text:e.text??"",name:e.username,link:e.postId,backgroundColor:e.backgroundColor??"",textColor:e.textColor??"dark",cssClass:e.cssClass??"",returnRtjson:"none"},t)},zs=new WeakSet,tp=async function(e,t,i,n){await u.redditAPIPlugins.Flair.SelectFlair({subreddit:e,name:i??"",link:t??"",flairTemplateId:"",backgroundColor:"",text:"",textColor:"",cssClass:"",returnRtjson:"none"},n)},d(Ht,Vs),d(Ht,zs);var Ue=Ht;function KO(r){if(g(r,"Flair text color is required"),r==="light"||r==="dark")return r;throw new Error(`Invalid flair text color: ${r}`)}function XO(r){if(g(r,"Flair background color is required"),r==="transparent"||/^#([A-Fa-f0-9]{6})$/.test(r))return r;throw new Error(`Invalid flair background color: ${r}`)}function ZO(r){if(r==="all"||r==="text"||r==="emoji")return r;throw new Error(`Invalid allowable content: ${r}`)}import{Block as sF}from"@devvit/protos";var NS=Dr(_S(),1);var $i,Ks,Ki,Xs,Zs,Ys,Qs,eo,Xi,to,ro,io,no,so,oo,Wt,ao,lo,Rr,Zi,Gt,Yi,Qi,en,Or,Vt,zt,tn,Jt,$t,Kt,pt,uo,co,rn,nn,D,N=class N{constructor(e,t){d(this,$i,void 0);d(this,Ks,void 0);d(this,Ki,void 0);d(this,Xs,void 0);d(this,Zs,void 0);d(this,Ys,void 0);d(this,Qs,void 0);d(this,eo,void 0);d(this,Xi,void 0);d(this,to,void 0);d(this,ro,void 0);d(this,io,void 0);d(this,no,void 0);d(this,so,void 0);d(this,oo,void 0);d(this,Wt,void 0);d(this,ao,void 0);d(this,lo,void 0);d(this,Rr,void 0);d(this,Zi,void 0);d(this,Gt,void 0);d(this,Yi,void 0);d(this,Qi,void 0);d(this,en,void 0);d(this,Or,void 0);d(this,Vt,void 0);d(this,zt,void 0);d(this,tn,void 0);d(this,Jt,void 0);d(this,$t,void 0);d(this,Kt,void 0);d(this,pt,void 0);d(this,uo,void 0);d(this,co,void 0);d(this,rn,void 0);d(this,nn,void 0);d(this,D,void 0);J(this),g(e.id,"Post is missing id"),g(e.title,"Post is missing title"),g(e.createdUtc,"Post is missing created date"),g(e.author,"Post is missing author name"),g(e.subreddit,"Post is missing subreddit name"),g(e.subredditId,"Post is missing subreddit id"),g(e.url,"Post is missing url"),g(e.permalink,"Post is missing permalink"),l(this,$i,fe(`t3_${e.id}`)),l(this,Ki,e.author),l(this,Ks,e.authorFullname?re(e.authorFullname):void 0),l(this,Zs,Re(e.subredditId)),l(this,Ys,e.subreddit),l(this,io,e.score??0),l(this,no,e.numComments??0),l(this,so,e.numReports??0);let i=new Date(0);i.setUTCSeconds(e.createdUtc),l(this,Xs,i),l(this,eo,e.title),l(this,Xi,e.selftext),l(this,to,e.selftextHtml),l(this,ro,e.url),l(this,Qs,e.permalink),e.thumbnail&&e.thumbnail!=="self"&&e.thumbnail!=="nsfw"&&e.thumbnailHeight!=null&&e.thumbnailWidth!=null&&l(this,oo,{url:e.thumbnail,height:e.thumbnailHeight,width:e.thumbnailWidth}),l(this,Wt,e.approved??!1),l(this,ao,e.approvedAtUtc??0),l(this,lo,e.bannedAtUtc??0),l(this,Gt,e.removed??!1),l(this,Yi,e.removedBy),l(this,Qi,e.removedByCategory),l(this,Rr,e.spam??!1),l(this,Zi,e.stickied??!1),l(this,en,e.archived??!1),l(this,Or,e.edited??!1),l(this,Vt,e.locked??!1),l(this,zt,e.over18??!1),l(this,tn,e.quarantine??!1),l(this,Jt,e.spoiler),l(this,$t,e.hidden??!1),l(this,Kt,e.ignoreReports??!1),l(this,pt,e.distinguished),l(this,co,e.secureMedia),l(this,rn,(e.modReports??[]).map(([n])=>n)),l(this,nn,(e.userReports??[]).map(([n])=>n)),l(this,D,t),(e.linkFlairBackgroundColor||e.linkFlairCssClass||e.linkFlairText||e.linkFlairType||e.linkFlairTemplateId||e.linkFlairRichtext||e.linkFlairTextColor)&&l(this,uo,{backgroundColor:e.linkFlairBackgroundColor,cssClass:e.linkFlairCssClass,text:e.linkFlairText,type:e.linkFlairType,templateId:e.linkFlairTemplateId,richtext:(e.linkFlairRichtext??[]).map(({e:n,t:o,a,u:c})=>({elementType:n,text:o,emojiRef:a,url:c})),textColor:e.linkFlairTextColor})}get id(){return s(this,$i)}get authorId(){return s(this,Ks)}get authorName(){return s(this,Ki)}get subredditId(){return s(this,Zs)}get subredditName(){return s(this,Ys)}get permalink(){return s(this,Qs)}get title(){return s(this,eo)}get body(){return s(this,Xi)}get bodyHtml(){return s(this,to)}get url(){return s(this,ro)}get thumbnail(){return s(this,oo)}get createdAt(){return s(this,Xs)}get score(){return s(this,io)}get numberOfComments(){return s(this,no)}get numberOfReports(){return s(this,so)}get approved(){return s(this,Wt)}get approvedAtUtc(){return s(this,ao)}get bannedAtUtc(){return s(this,lo)}get spam(){return s(this,Rr)}get stickied(){return s(this,Zi)}get removed(){return s(this,Gt)}get removedBy(){return s(this,Yi)}get removedByCategory(){return s(this,Qi)}get archived(){return s(this,en)}get edited(){return s(this,Or)}get locked(){return s(this,Vt)}get nsfw(){return s(this,zt)}get quarantined(){return s(this,tn)}get spoiler(){return s(this,Jt)}get hidden(){return s(this,$t)}get ignoringReports(){return s(this,Kt)}get distinguishedBy(){return s(this,pt)}get comments(){return X.getComments({postId:this.id},s(this,D))}get flair(){return s(this,uo)}get secureMedia(){return s(this,co)}get userReportReasons(){return s(this,nn)}get modReportReasons(){return s(this,rn)}toJSON(){return{id:this.id,authorId:this.authorId,authorName:this.authorName,subredditId:this.subredditId,subredditName:this.subredditName,permalink:this.permalink,title:this.title,body:this.body,bodyHtml:this.bodyHtml,url:this.url,thumbnail:this.thumbnail,score:this.score,numberOfComments:this.numberOfComments,numberOfReports:this.numberOfReports,createdAt:this.createdAt,approved:this.approved,spam:this.spam,stickied:this.stickied,removed:this.removed,removedBy:s(this,Yi),removedByCategory:s(this,Qi),archived:this.archived,edited:this.edited,locked:this.locked,nsfw:this.nsfw,quarantined:this.quarantined,spoiler:this.spoiler,hidden:this.hidden,ignoringReports:this.ignoringReports,distinguishedBy:this.distinguishedBy,flair:this.flair,secureMedia:this.secureMedia,modReportReasons:s(this,rn),userReportReasons:s(this,nn)}}isApproved(){return s(this,Wt)}isSpam(){return s(this,Rr)}isStickied(){return s(this,Zi)}isRemoved(){return s(this,Gt)}isArchived(){return s(this,en)}isEdited(){return s(this,Or)}isLocked(){return s(this,Vt)}isNsfw(){return s(this,zt)}isQuarantined(){return s(this,tn)}isSpoiler(){return s(this,Jt)}isHidden(){return s(this,$t)}isIgnoringReports(){return s(this,Kt)}isDistinguishedBy(){return s(this,pt)}async edit(e){let t=await N.edit({id:this.id,...e},s(this,D));l(this,Xi,t.body),l(this,Or,t.edited)}async addComment(e){return X.submit({id:this.id,...e},s(this,D))}async delete(){return N.delete(this.id,s(this,D))}async approve(){await N.approve(this.id,s(this,D)),l(this,Wt,!0),l(this,Gt,!1)}async remove(e=!1){await N.remove(this.id,e,s(this,D)),l(this,Gt,!0),l(this,Rr,e),l(this,Wt,!1)}async lock(){await N.lock(this.id,s(this,D)),l(this,Vt,!0)}async unlock(){await N.unlock(this.id,s(this,D)),l(this,Vt,!1)}async hide(){await N.hide(this.id,s(this,D)),l(this,$t,!0)}async unhide(){await N.unhide(this.id,s(this,D)),l(this,$t,!1)}async markAsNsfw(){await N.markAsNsfw(this.id,s(this,D)),l(this,zt,!0)}async unmarkAsNsfw(){await N.unmarkAsNsfw(this.id,s(this,D)),l(this,zt,!1)}async markAsSpoiler(){await N.markAsSpoiler(this.id,s(this,D)),l(this,Jt,!0)}async unmarkAsSpoiler(){await N.unmarkAsSpoiler(this.id,s(this,D)),l(this,Jt,!1)}async sticky(e){await N.sticky(this.id,e,s(this,D))}async unsticky(){await N.unsticky(this.id,s(this,D))}async distinguish(){let{distinguishedBy:e}=await N.distinguish(this.id,!1,s(this,D));l(this,pt,e)}async distinguishAsAdmin(){let{distinguishedBy:e}=await N.distinguish(this.id,!0,s(this,D));l(this,pt,e)}async undistinguish(){let{distinguishedBy:e}=await N.undistinguish(this.id,s(this,D));l(this,pt,e)}async ignoreReports(){await N.ignoreReports(this.id,s(this,D)),l(this,Kt,!0)}async unignoreReports(){await N.unignoreReports(this.id,s(this,D)),l(this,Kt,!1)}async getAuthor(){return x.getByUsername(s(this,Ki),s(this,D))}async crosspost(e){return N.crosspost({...e,postId:this.id},s(this,D))}addRemovalNote(e){return Me.addRemovalNote({itemIds:[s(this,$i)],...e},s(this,D))}static async getById(e,t){let i=u.redditAPIPlugins.LinksAndComments,n=ar(e)?e:`t3_${e}`,o=await i.Info({subreddits:[],thingIds:[n]},t);if(!o.data?.children?.length)throw new Error("could not find post");let a=o.data.children[0];if(!a?.data)throw new Error("could not find post");return new N(a.data,t)}static async submit(e,t){let i=u.redditAPIPlugins.LinksAndComments,n;if("preview"in e){g(t,"Missing metadata in `SubmitPostOptions`");let c=await new lt(()=>e.preview,void 0,{},t,void 0).buildBlocksUI(),p=sF.encode(c).finish();n=await i.Submit({kind:"custom",sr:e.subredditName,richtextJson:(0,NS.fromByteArray)(p),...e},t)}else n=await i.Submit({kind:"kind"in e?e.kind:"url"in e?"link":"self",sr:e.subredditName,richtextJson:"richtext"in e?Li(e.richtext):void 0,...e},t);if("kind"in e&&["image","video","videogif"].includes(e.kind)&&!n.json?.data?.id&&"url"in e)throw new Error(`Post of ${e.kind} type with ${e.url} is being created asynchronously and should be updated in the subreddit soon.`);if(!n.json?.data?.id||n.json?.errors?.length)throw new Error(`failed to submit post - either post ID is empty or request failed with errors: ${n.json?.errors}`);return N.getById(`t3_${n.json.data.id}`,t)}static async crosspost(e,t){let i=u.redditAPIPlugins.LinksAndComments,{postId:n,subredditName:o,...a}=e,c=await i.Submit({kind:"crosspost",sr:o,crosspostFullname:fe(n),...a},t);if(!c.json?.data?.id||c.json?.errors?.length)throw new Error("failed to crosspost post");return N.getById(`t3_${c.json.data.id}`,t)}static async edit(e,t){let i=u.redditAPIPlugins.LinksAndComments,{id:n}=e,o;if("richtext"in e&&(o=Li(e.richtext)),(await i.EditUserText({thingId:n,text:"text"in e?e.text:"",richtextJson:o},t)).json?.errors?.length)throw new Error("Failed to edit post");return N.getById(n,t)}static async delete(e,t){await u.redditAPIPlugins.LinksAndComments.Del({id:e},t)}static async approve(e,t){await u.redditAPIPlugins.Moderation.Approve({id:e},t)}static async remove(e,t=!1,i){await u.redditAPIPlugins.Moderation.Remove({id:e,spam:t},i)}static async hide(e,t){await u.redditAPIPlugins.LinksAndComments.Hide({id:e},t)}static async unhide(e,t){await u.redditAPIPlugins.LinksAndComments.Unhide({id:e},t)}static async markAsNsfw(e,t){await u.redditAPIPlugins.LinksAndComments.MarkNSFW({id:e},t)}static async unmarkAsNsfw(e,t){await u.redditAPIPlugins.LinksAndComments.UnmarkNSFW({id:e},t)}static async markAsSpoiler(e,t){await u.redditAPIPlugins.LinksAndComments.Spoiler({id:e},t)}static async unmarkAsSpoiler(e,t){await u.redditAPIPlugins.LinksAndComments.Unspoiler({id:e},t)}static async sticky(e,t,i){await u.redditAPIPlugins.LinksAndComments.SetSubredditSticky({id:e,state:!0,num:t},i)}static async unsticky(e,t){await u.redditAPIPlugins.LinksAndComments.SetSubredditSticky({id:e,state:!1},t)}static async lock(e,t){await u.redditAPIPlugins.LinksAndComments.Lock({id:e},t)}static async unlock(e,t){await u.redditAPIPlugins.LinksAndComments.Unlock({id:e},t)}static async distinguish(e,t,i){let a=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:t?"admin":"yes",sticky:!1},i)).json?.data?.things?.[0]?.data;return g(a),{distinguishedBy:a.distinguished}}static async undistinguish(e,t){let o=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:"no",sticky:!1},t)).json?.data?.things?.[0]?.data;return g(o),{distinguishedBy:o.distinguished}}static async ignoreReports(e,t){await u.redditAPIPlugins.Moderation.IgnoreReports({id:e},t)}static async unignoreReports(e,t){await u.redditAPIPlugins.Moderation.UnignoreReports({id:e},t)}static getControversialPosts(e={},t){return this.getSortedPosts({...e,sort:"controversial"},t)}static getTopPosts(e={},t){return this.getSortedPosts({...e,sort:"top"},t)}static getSortedPosts(e,t){let i=u.redditAPIPlugins.Listings;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async n=>{let o=await i.Sort({show:"all",sort:e.sort,t:e.timeframe,subreddit:e.subredditName,...n},t);return $s(o,t)}})}static getHotPosts(e={location:"GLOBAL"},t){let i=u.redditAPIPlugins.Listings;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async n=>{let o=await i.Hot({g:e.location,show:"all",subreddit:e.subredditName,...n},t);return $s(o,t)}})}static getNewPosts(e,t){let i=u.redditAPIPlugins.Listings;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async n=>{let o=await i.New({show:"all",subreddit:e.subredditName,...n},t);return $s(o,t)}})}static getRisingPosts(e,t){let i=u.redditAPIPlugins.Listings;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,fetch:async n=>{let o=await i.Rising({show:"all",subreddit:e.subredditName,...n},t);return $s(o,t)}})}static getPostsByUser(e,t){let i=u.redditAPIPlugins.Users;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(n){let o=await i.UserWhere({username:e.username,where:"submitted",...n},t);return $s(o,t)}})}};$i=new WeakMap,Ks=new WeakMap,Ki=new WeakMap,Xs=new WeakMap,Zs=new WeakMap,Ys=new WeakMap,Qs=new WeakMap,eo=new WeakMap,Xi=new WeakMap,to=new WeakMap,ro=new WeakMap,io=new WeakMap,no=new WeakMap,so=new WeakMap,oo=new WeakMap,Wt=new WeakMap,ao=new WeakMap,lo=new WeakMap,Rr=new WeakMap,Zi=new WeakMap,Gt=new WeakMap,Yi=new WeakMap,Qi=new WeakMap,en=new WeakMap,Or=new WeakMap,Vt=new WeakMap,zt=new WeakMap,tn=new WeakMap,Jt=new WeakMap,$t=new WeakMap,Kt=new WeakMap,pt=new WeakMap,uo=new WeakMap,co=new WeakMap,rn=new WeakMap,nn=new WeakMap,D=new WeakMap;var V=N;function $s(r,e){if(!r.data?.children)throw new Error("Listing response is missing children");return{children:r.data.children.map(i=>new V(i.data,e)),before:r.data.before,after:r.data.after}}var mo,sn,po,fo,go,ho,vo,Xt,yo,bo,ft,Fr=class Fr{constructor(e,t){d(this,mo,void 0);d(this,sn,void 0);d(this,po,void 0);d(this,fo,void 0);d(this,go,void 0);d(this,ho,void 0);d(this,vo,void 0);d(this,Xt,new Map);d(this,yo,void 0);d(this,bo,void 0);d(this,ft,void 0);J(this),g(e.id,"User ID is missing or undefined"),g(e.name,"Username is missing or undefined"),g(e.createdUtc,"User is missing created date"),l(this,mo,re(vd(e.id)?e.id:`t2_${e.id}`)),l(this,sn,e.name),l(this,ho,e.over18??!1),l(this,vo,e.isEmployee??!1);let i=new Date(0);if(i.setUTCSeconds(e.createdUtc),l(this,po,i),l(this,fo,e.linkKarma??0),l(this,go,e.commentKarma??0),e.modPermissions)for(let[n,o]of Object.entries(e.modPermissions))s(this,Xt).set(n,LS(o));l(this,yo,new URL(e.subreddit?.url??"","https://www.reddit.com").toString()),l(this,bo,e.subreddit?.url??""),l(this,ft,t)}get id(){return s(this,mo)}get username(){return s(this,sn)}get createdAt(){return s(this,po)}get linkKarma(){return s(this,fo)}get commentKarma(){return s(this,go)}get nsfw(){return s(this,ho)}get isAdmin(){return s(this,vo)}get modPermissions(){return s(this,Xt)}get url(){return s(this,yo)}get permalink(){return s(this,bo)}toJSON(){return{id:this.id,username:this.username,createdAt:this.createdAt,linkKarma:this.linkKarma,commentKarma:this.commentKarma,nsfw:this.nsfw,modPermissionsBySubreddit:Object.fromEntries(this.modPermissions)}}async getModPermissionsForSubreddit(e){if(s(this,Xt).has(e))return s(this,Xt).get(e);let t=await Fr.getSubredditUsersByType({subredditName:e,type:"moderators",username:this.username},s(this,ft)).all();if(t.length===0)return[];let i=t[0].modPermissions.get(e)??[];return i.length>0&&s(this,Xt).set(e,i),i}getComments(e){return X.getCommentsByUser({username:this.username,...e},s(this,ft))}getPosts(e){return V.getPostsByUser({username:this.username,...e},s(this,ft))}async getUserFlairBySubreddit(e){let t=await Ue.getUserFlairBySubreddit({subreddit:e,name:s(this,sn)},s(this,ft));return t.users[0]?Js(t.users[0]):void 0}getSnoovatarUrl(){return Fr.getSnoovatarUrl(this.username,s(this,ft))}static async getById(e,t){let o=(await u.redditAPIPlugins.Users.UserDataByAccountIds({ids:e},t))?.users?.[e]?.name;return o==null?void 0:Fr.getByUsername(o,t)}static async getByUsername(e,t){let n=await u.redditAPIPlugins.Users.UserAbout({username:e},t);if(!n.data?.id)throw new Error("failed to get user");return new Fr(n.data,t)}static async getFromMetadata(e,t){g(t);let i=t?.[e]?.values[0];return i?Fr.getById(re(i),t):Promise.resolve(void 0)}static getSubredditUsersByType(e,t){let i=u.redditAPIPlugins.Subreddits;return new H({hasMore:!0,pageSize:e.pageSize,limit:e.limit,after:e.after,before:e.before,fetch:async n=>{let o=await i.AboutWhere({where:e.type,user:e.username,subreddit:e.subredditName,show:"all",...n},t);return aF(o,e.subredditName,t)}})}static async createRelationship(e,t){let i=u.redditAPIPlugins.Users,{type:n,subredditName:o,username:a,permissions:c,...p}=e,f=await i.Friend({type:n,subreddit:o,name:a,permissions:c?Qm(c):void 0,...p},t);if(f.json?.errors?.length)throw new Error(f.json.errors.join(`
4
4
  `))}static async removeRelationship(e,t){await u.redditAPIPlugins.Users.Unfriend({type:e.type,subreddit:e.subredditName,name:e.username},t)}static async setModeratorPermissions(e,t,i,n){let a=await u.redditAPIPlugins.Users.SetPermissions({subreddit:t,name:e,type:"moderator",permissions:Qm(i)},n);if(a.json?.errors?.length)throw new Error(a.json.errors.join(`
5
- `))}static async getSnoovatarUrl(e,t){let i="GetSnoovatarUrlByName",n="c47fd42345af268616d2d8904b56856acdc05cf61d3650380f539ad7d596ac0c";return(await jt.query(i,n,{username:e},t)).data?.redditorInfoByName?.snoovatarIcon?.url}static getOverview(e,t){let i=u.redditAPIPlugins.Users;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(n){let o=await i.UserWhere({username:e.username,where:"overview",...n},t);return nF(o,t)}})}};mo=new WeakMap,on=new WeakMap,po=new WeakMap,fo=new WeakMap,go=new WeakMap,ho=new WeakMap,vo=new WeakMap,Xt=new WeakMap,yo=new WeakMap,bo=new WeakMap,ft=new WeakMap;var w=Fr;function nF(r,e){if(!r.data?.children)throw new Error("Listing response is missing children");return{children:r.data.children.map(i=>{if(i.kind==="t3")return new V(i.data,e);if(i.kind==="t1")return new X(i.data,e);throw new Error(`Type ${i.kind} is not supported`)}),before:r.data.before,after:r.data.after}}async function sF(r,e,t){let i=u.redditAPIPlugins.Users;if(!r.data?.children)throw new Error("Listing response is missing children");let n=r.data.children.map(v=>(g(v.data?.id,"User id is still from listing data"),v.data.id)),o=100,a=[];for(let v=0;v<n.length;v+=o)a.push(n.slice(v,v+o));let p=(await Promise.all(a.map(v=>i.UserDataByAccountIds({ids:v.join(",")},t)))).reduce((v,m)=>({...v,...m.users}),{});return{children:r.data.children.map(v=>{let m=v.data?.id;g(m,"User id is missing from listing");let k=p[m];return g(k,"User data is missing from response"),new w({id:m,name:k.name,linkKarma:k.linkKarma,commentKarma:k.commentKarma,createdUtc:k.createdUtc,over18:k.profileOver18,snoovatarSize:[],modPermissions:{[e]:v.data?.modPermissions??[]}},t)}),before:r.data.before,after:r.data.after}}var Mr,ko,an,dn,So,Po,ln,Co,xo,un,Zt,wo,Io,Lr,Yt,Qt,gt,Ur,ht,Ao,To,Eo,Ro,Oo,Fo,Mo,Y,cn,Al,mn,Tl,W=class W{constructor(e,t){d(this,Mr,void 0);d(this,ko,void 0);d(this,an,void 0);d(this,dn,void 0);d(this,So,void 0);d(this,Po,void 0);d(this,ln,void 0);d(this,Co,void 0);d(this,xo,void 0);d(this,un,void 0);d(this,Zt,void 0);d(this,wo,void 0);d(this,Io,void 0);d(this,Lr,void 0);d(this,Yt,void 0);d(this,Qt,void 0);d(this,gt,void 0);d(this,Ur,void 0);d(this,ht,void 0);d(this,Ao,void 0);d(this,To,void 0);d(this,Eo,void 0);d(this,Ro,void 0);d(this,Oo,void 0);d(this,Fo,void 0);d(this,Mo,void 0);d(this,Y,void 0);var n;J(this),g(e.id,"Comment id is null or undefined"),g(e.body,"Comment body is null or undefined"),g(e.createdUtc,"Comment is missing created date"),g(e.author,"Comment author is null or undefined"),g(e.parentId,"Comment parentId is null or undefined"),g(e.linkId,"Comment linkId is null or undefined"),g(e.permalink,"Comment permalink is null or undefined"),g(e.subreddit,"Comment is missing subreddit name"),g(e.subredditId,"Comment is missing subreddit id"),l(this,Mr,Yr(`t1_${e.id}`)),l(this,ko,e.authorFullname?te(e.authorFullname):void 0),l(this,an,e.author),l(this,dn,e.body),l(this,Co,Re(e.subredditId)),l(this,xo,e.subreddit),l(this,Po,Vc(e.parentId)?Yr(e.parentId):fe(e.parentId)),l(this,ln,fe(e.linkId)),l(this,Lr,e.edited??!1),l(this,Yt,e.locked??!1),l(this,Qt,e.removed??!1),l(this,gt,e.stickied??!1),l(this,Zt,e.approved??!1),l(this,wo,e.approvedAtUtc??0),l(this,Io,e.bannedAtUtc??0),l(this,Ur,e.spam??!1),l(this,ht,e.distinguished),l(this,Ao,e.numReports??0),l(this,To,e.collapsedBecauseCrowdControl??!1),l(this,Eo,e.score??0),l(this,Ro,e.permalink),l(this,Mo,new URL(e.permalink??"","https://www.reddit.com/").toString()),l(this,Oo,(e.modReports??[]).map(([o])=>o)),l(this,Fo,(e.userReports??[]).map(([o])=>o));let i=new Date(0);i.setUTCSeconds(e.createdUtc),l(this,So,i),l(this,un,y(n=W,cn,Al).call(n,{postId:s(this,ln),commentId:s(this,Mr)},t)),l(this,Y,t)}get id(){return s(this,Mr)}get authorId(){return s(this,ko)}get authorName(){return s(this,an)}get subredditId(){return s(this,Co)}get subredditName(){return s(this,xo)}get body(){return s(this,dn)}get createdAt(){return s(this,So)}get parentId(){return s(this,Po)}get postId(){return s(this,ln)}get replies(){return s(this,un)}get distinguishedBy(){return s(this,ht)}get locked(){return s(this,Yt)}get stickied(){return s(this,gt)}get removed(){return s(this,Qt)}get approved(){return s(this,Zt)}get approvedAtUtc(){return s(this,wo)}get bannedAtUtc(){return s(this,Io)}get spam(){return s(this,Ur)}get edited(){return s(this,Lr)}get numReports(){return s(this,Ao)}get collapsedBecauseCrowdControl(){return s(this,To)}get score(){return s(this,Eo)}get permalink(){return s(this,Ro)}get userReportReasons(){return s(this,Fo)}get modReportReasons(){return s(this,Oo)}get url(){return s(this,Mo)}toJSON(){return{id:this.id,authorName:this.authorName,subredditId:this.subredditId,subredditName:this.subredditName,body:this.body,createdAt:this.createdAt,parentId:this.parentId,postId:this.postId,replies:this.replies,approved:this.approved,locked:this.locked,removed:this.removed,stickied:this.stickied,spam:this.spam,edited:this.edited,distinguishedBy:this.distinguishedBy,numReports:this.numReports,collapsedBecauseCrowdControl:this.collapsedBecauseCrowdControl,score:this.score,permalink:this.permalink,modReportReasons:this.modReportReasons,userReportReasons:this.userReportReasons,url:this.url}}isLocked(){return s(this,Yt)}isApproved(){return s(this,Zt)}isRemoved(){return s(this,Qt)}isSpam(){return s(this,Ur)}isStickied(){return s(this,gt)}isDistinguished(){return!!s(this,ht)}isEdited(){return s(this,Lr)}async delete(){return W.delete(this.id,s(this,Y))}async edit(e){let t=await W.edit({id:this.id,...e},s(this,Y));return l(this,dn,t.body),l(this,Lr,t.edited),this}async approve(){await W.approve(this.id,s(this,Y)),l(this,Zt,!0),l(this,Qt,!1)}async remove(e=!1){await W.remove(this.id,e,s(this,Y)),l(this,Qt,!0),l(this,Ur,e),l(this,Zt,!1)}async lock(){await W.lock(this.id,s(this,Y)),l(this,Yt,!0)}async unlock(){await W.unlock(this.id,s(this,Y)),l(this,Yt,!1)}async reply(e){return W.submit({id:this.id,...e},s(this,Y))}async getAuthor(){return w.getByUsername(s(this,an),s(this,Y))}async distinguish(e=!1){let{distinguishedBy:t,stickied:i}=await W.distinguish(this.id,e,!1,s(this,Y));l(this,ht,t),l(this,gt,i)}async distinguishAsAdmin(e=!1){let{distinguishedBy:t,stickied:i}=await W.distinguish(this.id,e,!0,s(this,Y));l(this,ht,t),l(this,gt,i)}async undistinguish(){let{distinguishedBy:e,stickied:t}=await W.undistinguish(this.id,s(this,Y));l(this,ht,e),l(this,gt,t)}addRemovalNote(e){return Me.addRemovalNote({itemIds:[s(this,Mr)],...e},s(this,Y))}static async getById(e,t){let i=u.redditAPIPlugins.LinksAndComments,n=Pt(e)?e:`t1_${e}`,o=await i.Info({subreddits:[],thingIds:[n]},t);if(!o.data?.children?.[0]?.data)throw new Error("not found");return new W(o.data.children[0].data,t)}static getComments(e,t){var a;let{postId:i,commentId:n,...o}=e;return y(a=W,cn,Al).call(a,{postId:fe(i),commentId:n?Yr(n):void 0,...o},t)}static async edit(e,t){let i=u.redditAPIPlugins.LinksAndComments,{id:n}=e,o;"richtext"in e&&(o=Bi(e.richtext));let a=await i.EditUserText({thingId:n,text:"text"in e?e.text:"",richtextJson:o},t);if(a.json?.errors?.length)throw new Error("Failed to edit comment");let c=a.json?.data?.things?.[0]?.data;return g(c),new W(c,t)}static async delete(e,t){await u.redditAPIPlugins.LinksAndComments.Del({id:e},t)}static async approve(e,t){await u.redditAPIPlugins.Moderation.Approve({id:e},t)}static async remove(e,t=!1,i){await u.redditAPIPlugins.Moderation.Remove({id:e,spam:t},i)}static async lock(e,t){await u.redditAPIPlugins.LinksAndComments.Lock({id:e},t)}static async unlock(e,t){await u.redditAPIPlugins.LinksAndComments.Unlock({id:e},t)}static async submit(e,t){let i=u.redditAPIPlugins.LinksAndComments,{id:n}=e,o;"richtext"in e&&(o=Bi(e.richtext));let a=await i.Comment({thingId:n,text:"text"in e?e.text:"",richtextJson:o},t);if(a.json?.errors?.length)throw new Error("failed to reply to comment");let c=a.json?.data?.things?.[0]?.data;return g(c),new W(c,t)}static async distinguish(e,t,i,n){let c=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:i?"admin":"yes",sticky:t},n)).json?.data?.things?.[0]?.data;return g(c),{distinguishedBy:c.distinguished,stickied:!!c.stickied}}static async undistinguish(e,t){let o=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:"no",sticky:!1},t)).json?.data?.things?.[0]?.data;return g(o),{distinguishedBy:o.distinguished,stickied:!!o.stickied}}static getCommentsByUser(e,t){let i=u.redditAPIPlugins.Users;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(n){let o=await i.UserWhere({username:e.username,where:"comments",...n},t);return g(o.data,"Failed to get comments for user"),{children:o.data.children?.map(c=>new W(c.data,t))||[],before:o.data.before,after:o.data.after}}})}};Mr=new WeakMap,ko=new WeakMap,an=new WeakMap,dn=new WeakMap,So=new WeakMap,Po=new WeakMap,ln=new WeakMap,Co=new WeakMap,xo=new WeakMap,un=new WeakMap,Zt=new WeakMap,wo=new WeakMap,Io=new WeakMap,Lr=new WeakMap,Yt=new WeakMap,Qt=new WeakMap,gt=new WeakMap,Ur=new WeakMap,ht=new WeakMap,Ao=new WeakMap,To=new WeakMap,Eo=new WeakMap,Ro=new WeakMap,Oo=new WeakMap,Fo=new WeakMap,Mo=new WeakMap,Y=new WeakMap,cn=new WeakSet,Al=function(e,t,i=0){return new H({limit:e.limit,pageSize:e.pageSize,fetch:async n=>{var k,b;let o=n.limit,a=u.redditAPIPlugins.Listings,c=u.redditAPIPlugins.LinksAndComments,p=e.commentId;if(n.more)if(n.more.children.length){let C=n.more;(!o||o>100)&&(o=100);let x=C.children.splice(0,o),I=await c.MoreChildren({linkId:e.postId,children:x,sort:e.sort},t);if(!I.json?.data?.things?.length)return{children:[]};let{children:E}=y(k=W,mn,Tl).call(k,I.json.data.things,e.postId,e,t);return{children:E,more:C.children.length?C:void 0}}else p=n.more.parentId,i=i+n.more.depth;let v=(await a.Comments({article:e.postId.substring(3),comment:p?.substring(3),limit:o,depth:e.depth,sort:e.sort},t)).listings?.[1]?.data?.children??[],m=v[0];return p&&m?.data?.replyList?.data&&(v=m.data.replyList.data.children),y(b=W,mn,Tl).call(b,v,p??e.postId,e,t,i)}})},mn=new WeakSet,Tl=function(e,t,i,n,o=0){var f,v;let a=[],c,p={};for(let m of e){if(!m.data||(m.data.depth!=null&&(m.data.depth=m.data.depth+o),m.data.depth!=null&&i.depth!=null&&m.data.depth>=i.depth))continue;let k=m.data.parentId?p[m.data.parentId]:void 0;if(m.kind==="t1"){if(m.data.name===t)continue;let b=new W(m.data,n);if(p[b.id]=b,l(b,un,y(f=W,cn,Al).call(f,{...i,postId:b.postId,commentId:b.id},n,o)),"replyList"in m.data&&m.data.replyList?.data){let{children:C,more:x}=y(v=W,mn,Tl).call(v,m.data.replyList.data.children,b.id,i,n,o);C.length&&b.replies.children.push(...C),x&&b.replies.setMore(x)}b.replies.preventInitialFetch(),k?k.replies.children.push(b):a.push(b)}else if(m.kind==="more"&&m.data.parentId&&m.data.depth!=null){let b={parentId:Vc(m.data.parentId)?Yr(m.data.parentId):fe(m.data.parentId),children:m.data.children??[],depth:m.data.depth};k?k.replies.setMore(b):b.parentId===t&&(c=b)}}return{children:a,more:c}},d(W,cn),d(W,mn);var X=W;function Ed(r,e){let t=u.redditAPIPlugins.Moderation;return new H({hasMore:!0,after:r.after,before:r.before,limit:r.limit,pageSize:r.pageSize,fetch:async i=>{let n=await t.AboutLog({subreddit:r.subredditName,mod:r.moderatorUsernames?r.moderatorUsernames.join(","):void 0,type:r.type,...i},e);return oF(n)}})}function oF(r){if(!r.data?.children)throw new Error("AboutLogResponse is missing children");return{children:r.data.children.map(t=>{if(!t.data)throw new Error("ModAction from AboutLogResponse is missing or invalid");let{id:i,mod:n,modId36:o,createdUtc:a,subreddit:c,subredditNamePrefixed:p,action:f,srId36:v,description:m,details:k,targetAuthor:b,targetBody:C,targetFullname:x,targetPermalink:I,targetTitle:E}=t.data;g(i,"ModAction from AboutLogResponse is missing id"),g(n,"ModAction from AboutLogResponse is missing mod"),g(o,"ModAction from AboutLogResponse is missing modId36"),g(a,"ModAction from AboutLogResponse is missing createdUtc"),g(c,"ModAction from AboutLogResponse is missing subreddit"),g(p,"ModAction from AboutLogResponse is missing subredditNamePrefixed"),g(f,"ModAction from AboutLogResponse is missing action"),g(v,"ModAction from AboutLogResponse is missing srId36");let ue=new Date(0);return ue.setUTCSeconds(a),{id:i,type:f,moderatorName:n,moderatorId:`t2_${o}`,createdAt:ue,subredditName:c,subredditId:`t5_${v}`,description:m,details:k,target:x?{id:x,author:b,body:C,permalink:I,title:E}:void 0}}),after:r.data.after,before:r.data.before}}var aF=(a=>(a.New="New",a.InProgress="InProgress",a.Archived="Archived",a.Appeals="Appeals",a.JoinRequests="JoinRequests",a.Filtered="Filtered",a))(aF||{}),dF={0:"New",1:"InProgress",2:"Archived",3:"Appeals",4:"JoinRequests",5:"Filtered"},lF=(b=>(b.Highlighted="Highlighted",b.Unhighlighted="Unhighlighted",b.Archived="Archived",b.Unarchived="Unarchived",b.ReportedToAdmins="ReportedToAdmins",b.Muted="Muted",b.Unmuted="Unmuted",b.Banned="Banned",b.Unbanned="Unbanned",b.Approved="Approved",b.Disapproved="Disapproved",b.Filtered="Filtered",b.Unfiltered="Unfiltered",b))(lF||{}),uF={0:"Highlighted",1:"Unhighlighted",2:"Archived",3:"Unarchived",4:"ReportedToAdmins",5:"Muted",6:"Unmuted",7:"Banned",8:"Unbanned",9:"Approved",10:"Disapproved",11:"Filtered",12:"Unfiltered"},G,Z,se,El,qS,Rl,jS,Rd=class{constructor(e){d(this,Z);d(this,El);d(this,Rl);d(this,G,void 0);l(this,G,e)}async bulkReadConversations(e,t){let i=u.redditAPIPlugins.NewModmail,{conversationIds:n}=await i.BulkReadConversations({entity:e.join(","),state:t},s(this,G));return n}async getConversations(e){let i=await u.redditAPIPlugins.NewModmail.GetConversations({after:e.after,entity:e.subreddits?e.subreddits.join(","):void 0,limit:e.limit,sort:e.sort,state:e.state},s(this,G)),n={};for(let o in i.conversations)n[o]=y(this,Z,se).call(this,{protoConversation:i.conversations[o],protoMessages:i.messages,protoModActions:{}});return{conversations:n,viewerId:i.viewerId}}async getConversation(e){let i=await u.redditAPIPlugins.NewModmail.GetConversation({...e,markRead:!!e.markRead},s(this,G));return{participantSubreddit:i.participantSubreddit,conversation:y(this,Z,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async getSubreddits(){let e=u.redditAPIPlugins.NewModmail,{subreddits:t}=await e.Subreddits({},s(this,G));return t}async createConversation(e){let i=await u.redditAPIPlugins.NewModmail.CreateConversation({body:e.body,isAuthorHidden:e.isAuthorHidden??!1,srName:e.subredditName,subject:e.subject,to:e.to?e.to:void 0},s(this,G));return{conversation:y(this,Z,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async reply(e){let i=await u.redditAPIPlugins.NewModmail.CreateConversationMessage({body:e.body,conversationId:e.conversationId,isAuthorHidden:e.isAuthorHidden??!1,isInternal:e.isInternal??!1},s(this,G));return{conversation:y(this,Z,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:{}}),user:i.user}}async highlightConversation(e){let i=await u.redditAPIPlugins.NewModmail.HighlightConversation({conversationId:e},s(this,G));return{conversation:y(this,Z,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:i.modActions})}}async unhighlightConversation(e){let i=await u.redditAPIPlugins.NewModmail.UnhighlightConversation({conversationId:e},s(this,G));return{conversation:y(this,Z,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:i.modActions})}}async archiveConversation(e){let i=await u.redditAPIPlugins.NewModmail.ArchiveConversation({conversationId:e},s(this,G));return{conversation:y(this,Z,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:i.modActions})}}async unarchiveConversation(e){let i=await u.redditAPIPlugins.NewModmail.UnarchiveConversation({conversationId:e},s(this,G));return{conversation:y(this,Z,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:i.modActions})}}async muteConversation(e){let i=await u.redditAPIPlugins.NewModmail.MuteConversation({conversationId:e.conversationId,numHours:e.numHours},s(this,G));return{conversation:y(this,Z,se).call(this,{protoConversation:i.conversations,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async unmuteConversation(e){let i=await u.redditAPIPlugins.NewModmail.UnmuteConversation({conversationId:e},s(this,G));return{conversation:y(this,Z,se).call(this,{protoConversation:i.conversations,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async readConversations(e){await u.redditAPIPlugins.NewModmail.Read({conversationIds:e.join(",")},s(this,G))}async unreadConversations(e){await u.redditAPIPlugins.NewModmail.Unread({conversationIds:e.join(",")},s(this,G))}async approveConversation(e){let i=await u.redditAPIPlugins.NewModmail.ApproveConversation({conversationId:e},s(this,G));return{conversation:y(this,Z,se).call(this,{protoConversation:i.conversations,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async disapproveConversation(e){let i=await u.redditAPIPlugins.NewModmail.DisapproveConversation({conversationId:e},s(this,G));return{conversation:y(this,Z,se).call(this,{protoConversation:i.conversations,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async tempBanConversation(e){let i=await u.redditAPIPlugins.NewModmail.TempBan({...e},s(this,G));return{conversation:y(this,Z,se).call(this,{protoConversation:i.conversations,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async unbanConversation(e){let i=await u.redditAPIPlugins.NewModmail.Unban({conversationId:e},s(this,G));return{conversation:y(this,Z,se).call(this,{protoConversation:i.conversations,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async getUnreadCount(){return await u.redditAPIPlugins.NewModmail.UnreadCount({},s(this,G))}async getUserConversations(e){return await u.redditAPIPlugins.NewModmail.UserConversations({conversationId:e},s(this,G))}};G=new WeakMap,Z=new WeakSet,se=function({protoConversation:e,protoMessages:t,protoModActions:i}){return{...e,state:dF[e.state],messages:y(this,El,qS).call(this,e,t),modActions:y(this,Rl,jS).call(this,e,i)}},El=new WeakSet,qS=function(e,t){let i={},n=e.objIds.filter(o=>o.key==="messages").map(({id:o})=>o);for(let o of n){let a=t[o];a&&(i[o]=a)}return i},Rl=new WeakSet,jS=function(e,t){let i={},n=e.objIds.filter(o=>o.key==="modActions").map(({id:o})=>o);for(let o of n){let a=t[o];a&&(i[o]={...a,actionType:uF[a.actionTypeId]})}return i};var pn,fn,Ol,Lo,Uo,Bo,Do,ip=class ip{constructor(e,t){d(this,pn,void 0);d(this,fn,void 0);d(this,Ol,void 0);d(this,Lo,void 0);d(this,Uo,void 0);d(this,Bo,void 0);d(this,Do,void 0);if(J(this),g(e.id,"PrivateMessage: Invalid data, no id"),g(e.name,"PrivateMessage: Invalid data, no name"),g(e.created,"PrivateMessage: Invalid data, no created date"),l(this,pn,ge(e.name)),e.author!=null)l(this,fn,{type:"user",username:e.author,id:e.authorFullname?te(e.authorFullname):void 0});else if(e.subreddit!=null)l(this,fn,{type:"subreddit",name:e.subreddit,id:e.subredditId?Re(e.subredditId):void 0});else throw new Error("PrivateMessage: Invalid data, no author or subreddit");l(this,Lo,e.body??""),l(this,Uo,e.bodyHtml??"");let i=new Date(0);i.setUTCSeconds(e.createdUtc),l(this,Bo,i),l(this,Ol,e.parentId?ge(e.parentId):void 0),l(this,Do,t)}static async getMessages(e,t){let i=u.redditAPIPlugins.PrivateMessages;return new H({...e,fetch:async n=>{let o=await i.MessageWhere({...n,where:e.type??"inbox"},t);return{after:o.data?.after,before:o.data?.before,children:o.data?.children?.map(a=>new ip(a.data,t)).filter(Boolean)||[]}}})}static async send({to:e,subject:t,text:i},n){await u.redditAPIPlugins.PrivateMessages.Compose({to:e,subject:t,text:i,fromSr:""},n)}static async sendAsSubreddit({to:e,fromSubredditName:t,subject:i,text:n},o){await u.redditAPIPlugins.PrivateMessages.Compose({to:e,fromSr:t,subject:i,text:n},o)}static async markAllAsRead(e){await u.redditAPIPlugins.PrivateMessages.ReadAllMessages({filterTypes:""},e)}get id(){return s(this,pn)}get from(){return s(this,fn)}get body(){return s(this,Lo)}get bodyHtml(){return s(this,Uo)}get created(){return s(this,Bo)}async markAsRead(){await u.redditAPIPlugins.PrivateMessages.ReadMessage({id:s(this,pn)},s(this,Do))}};pn=new WeakMap,fn=new WeakMap,Ol=new WeakMap,Lo=new WeakMap,Uo=new WeakMap,Bo=new WeakMap,Do=new WeakMap;var ur=ip;var Ey=(o=>(o.Reports="reports",o.Spam="spam",o.Modqueue="modqueue",o.Unmoderated="unmoderated",o.Edited="edited",o))(Ey||{}),gn,A,_o,No,qo,jo,Ho,Wo,Go,Vo,zo,hn,T,it=class it{constructor(e,t){d(this,gn,void 0);d(this,A,void 0);d(this,_o,void 0);d(this,No,void 0);d(this,qo,void 0);d(this,jo,void 0);d(this,Ho,void 0);d(this,Wo,void 0);d(this,Go,void 0);d(this,Vo,void 0);d(this,zo,void 0);d(this,hn,void 0);d(this,T,void 0);J(this),g(e.id,"Subreddit id is missing or undefined"),g(e.displayName,"Subreddit name is missing or undefined"),l(this,gn,Re(`t5_${e.id}`)),l(this,A,e.displayName),g(e.createdUtc,"Subreddit is missing created date");let i=new Date(0);i.setUTCSeconds(e.createdUtc),l(this,_o,i),l(this,No,cF(e.subredditType)),l(this,qo,e.title),l(this,jo,e.description),g(e.lang,"Subreddit is missing language"),l(this,Ho,e.lang),l(this,Wo,e.subscribers??0),l(this,Go,e.activeUserCount??0),l(this,Vo,e.over18??!1),l(this,hn,e.url??""),l(this,zo,{acceptFollowers:e.acceptFollowers??!1,allOriginalContent:e.allOriginalContent??!1,allowChatPostCreation:e.allowChatPostCreation??!1,allowDiscovery:e.allowDiscovery??!1,allowGalleries:e.allowGalleries??!1,allowImages:e.allowImages??!1,allowPolls:e.allowPolls??!1,allowPredictionContributors:e.allowPredictionContributors??!1,allowPredictions:e.allowPredictions??!1,allowPredictionsTournament:e.allowPredictionsTournament??!1,allowTalks:e.allowTalks??!1,allowVideoGifs:e.allowVideogifs??!1,allowVideos:e.allowVideos??!1,chatPostEnabled:e.isChatPostFeatureEnabled??!1,collectionsEnabled:e.collectionsEnabled??!1,crosspostable:e.isCrosspostableSubreddit??!1,emojisEnabled:e.emojisEnabled??!1,eventPostsEnabled:e.eventPostsEnabled??!1,linkFlairEnabled:e.linkFlairEnabled??!1,originalContentTagEnabled:e.originalContentTagEnabled??!1,restrictCommenting:e.restrictCommenting??!1,restrictPosting:e.restrictPosting??!1,shouldArchivePosts:e.shouldArchivePosts??!1,spoilersEnabled:e.spoilersEnabled??!1,wikiEnabled:e.wikiEnabled??!1,allowedPostType:mF(e.submissionType),allowedMediaInComments:(e.allowedMediaInComments??[]).map(pF),bannerBackgroundColor:e.bannerBackgroundColor,bannerBackgroundImage:e.bannerBackgroundImage,bannerImage:e.bannerImg,communityIcon:e.communityIcon,headerTitle:e.headerTitle,mobileBannerImage:e.mobileBannerImage,userFlairs:{enabled:e.userFlairEnabledInSr??!1,usersCanAssign:e.canAssignUserFlair??!1},postFlairs:{enabled:e.linkFlairEnabled??!1,usersCanAssign:e.canAssignLinkFlair??!1},url:new URL(s(this,hn),"https://www.reddit.com").toString()}),l(this,T,t)}get id(){return s(this,gn)}get name(){return s(this,A)}get createdAt(){return s(this,_o)}get type(){return s(this,No)}get title(){return s(this,qo)}get description(){return s(this,jo)}get language(){return s(this,Ho)}get numberOfSubscribers(){return s(this,Wo)}get numberOfActiveUsers(){return s(this,Go)}get nsfw(){return s(this,Vo)}get settings(){return s(this,zo)}get userFlairsEnabled(){return this.settings.userFlairs.enabled}get postFlairsEnabled(){return this.settings.postFlairs.enabled}get usersCanAssignUserFlairs(){return this.settings.userFlairs.usersCanAssign}get usersCanAssignPostFlairs(){return this.settings.postFlairs.usersCanAssign}get url(){return this.settings.url}get permalink(){return s(this,hn)}toJSON(){return{id:this.id,name:this.name,createdAt:this.createdAt,type:this.type,title:this.title,description:this.description,language:this.language,nsfw:this.nsfw,numberOfSubscribers:this.numberOfSubscribers,numberOfActiveUsers:this.numberOfActiveUsers,settings:this.settings}}async submitPost(e){let t={...e,subredditName:s(this,A)};return V.submit(t,s(this,T))}getControversialPosts(e={}){if(!s(this,A))throw new Error("subreddit missing displayName - it might not have been fetched");return V.getControversialPosts({...e,subredditName:s(this,A)},s(this,T))}getTopPosts(e={}){if(!s(this,A))throw new Error("subreddit missing displayName - it might not have been fetched");return V.getTopPosts({...e,subredditName:s(this,A)},s(this,T))}getApprovedUsers(e={}){return w.getSubredditUsersByType({type:"contributors",subredditName:s(this,A),...e},s(this,T))}approveUser(e){return w.createRelationship({username:e,subredditName:s(this,A),type:"contributor"},s(this,T))}removeUser(e){return w.removeRelationship({username:e,subredditName:s(this,A),type:"contributor"},s(this,T))}getWikiContributors(e={}){return w.getSubredditUsersByType({type:"wikicontributors",subredditName:s(this,A),...e},s(this,T))}addWikiContributor(e){return w.createRelationship({username:e,subredditName:s(this,A),type:"wikicontributor"},s(this,T))}removeWikiContributor(e){return w.removeRelationship({username:e,subredditName:s(this,A),type:"wikicontributor"},s(this,T))}getBannedUsers(e={}){return w.getSubredditUsersByType({type:"banned",subredditName:s(this,A),...e},s(this,T))}banUser(e){return w.createRelationship({username:e.username,subredditName:s(this,A),type:"banned",banReason:e.reason,banMessage:e.message,note:e.note,duration:e.duration},s(this,T))}unbanUser(e){return w.removeRelationship({username:e,subredditName:s(this,A),type:"banned"},s(this,T))}getBannedWikiContributors(e={}){return w.getSubredditUsersByType({type:"wikibanned",subredditName:s(this,A),...e},s(this,T))}banWikiContributor(e){return w.createRelationship({username:e.username,subredditName:s(this,A),type:"wikibanned",banReason:e.reason,note:e.note,duration:e.duration},s(this,T))}unbanWikiContributor(e){return w.removeRelationship({username:e,subredditName:s(this,A),type:"wikibanned"},s(this,T))}getModerators(e={}){return w.getSubredditUsersByType({type:"moderators",subredditName:s(this,A),...e},s(this,T))}inviteModerator(e,t){return w.createRelationship({type:"moderator_invite",subredditName:s(this,A),username:e,permissions:t??[]},s(this,T))}revokeModeratorInvite(e){return w.removeRelationship({username:e,subredditName:s(this,A),type:"moderator_invite"},s(this,T))}removeModerator(e){return w.removeRelationship({type:"moderator",subredditName:s(this,A),username:e},s(this,T))}setModeratorPermissions(e,t){return w.setModeratorPermissions(e,s(this,A),t,s(this,T))}getMutedUsers(e={}){return w.getSubredditUsersByType({type:"muted",subredditName:s(this,A),...e},s(this,T))}muteUser(e,t){return w.createRelationship({username:e,subredditName:s(this,A),type:"muted",note:t},s(this,T))}unmuteUser(e){return w.removeRelationship({username:e,subredditName:s(this,A),type:"muted"},s(this,T))}getModerationLog(e){return Ed({subredditName:s(this,A),...e},s(this,T))}getUserFlairTemplates(){return ae.getUserFlairTemplates(s(this,A),s(this,T))}getPostFlairTemplates(){return ae.getPostFlairTemplates(s(this,A),s(this,T))}createPostFlairTemplate(e){return ae.createPostFlairTemplate({subredditName:s(this,A),...e},s(this,T))}createUserFlairTemplate(e){return ae.createUserFlairTemplate({subredditName:s(this,A),...e},s(this,T))}async getUserFlair(e){if(e?.usernames!==void 0)return{users:await Promise.all(e.usernames.map(async i=>{let n=await Le.getUserFlairBySubreddit({subreddit:s(this,A),name:i},s(this,T));return Js(n.users[0])}))};{let t=await Le.getUserFlairBySubreddit({...e,subreddit:s(this,A)},s(this,T));return{next:t.next,prev:t.prev,users:t.users.map(i=>Js(i))}}}getModQueue(e={type:"all"}){return it.aboutLocation({...e,location:"modqueue",subreddit:s(this,A)},s(this,T))}getReports(e={type:"all"}){return it.aboutLocation({...e,location:"reports",subreddit:s(this,A)},s(this,T))}getSpam(e={type:"all"}){return it.aboutLocation({...e,location:"spam",subreddit:s(this,A)},s(this,T))}getUnmoderated(e={type:"all"}){return it.aboutLocation({...e,location:"unmoderated",subreddit:s(this,A)},s(this,T))}getEdited(e={type:"all"}){return it.aboutLocation({...e,location:"edited",subreddit:s(this,A)},s(this,T))}static aboutLocation(e,t){let i=u.redditAPIPlugins.Moderation,n;switch(e.type){case"post":n="links";break;case"comment":n="comments";break;default:n=void 0}return new H({...e,fetch:async o=>{let a=await i.AboutLocation({...o,...e,only:n},t);return HS(a,t)}})}getCommentsAndPostsByIds(e){let t=u.redditAPIPlugins.LinksAndComments;return new H({fetch:async()=>{let i=await t.Info({thingIds:e,subreddits:[s(this,gn)]},s(this,T));return HS(i,s(this,T))}})}static async addRemovalReason(e,t,i,n){return(await u.redditAPIPlugins.Subreddits.SubredditAddRemovalReason({title:t,message:i,subreddit:e},n)).id}static async getRemovalReasons(e,t){let n=await u.redditAPIPlugins.Subreddits.SubredditGetRemovalReasons({subreddit:e},t);return n.order.map(o=>({...n.data[o]}))}static async getFromMetadata(e){g(e);let t=e?.[B.Subreddit]?.values[0];return g(t),it.getById(Re(t),e)}static async getById(e,t){let o=(await u.redditAPIPlugins.LinksAndComments.Info({thingIds:[e],subreddits:[]},t)).data?.children[0]?.data?.displayName;return g(o),it.getByName(o,t)}static async getByName(e,t){let n=await u.redditAPIPlugins.Subreddits.SubredditAbout({subreddit:e},t);if(!n?.data)throw new Error("not found");return new it(n.data,t)}};gn=new WeakMap,A=new WeakMap,_o=new WeakMap,No=new WeakMap,qo=new WeakMap,jo=new WeakMap,Ho=new WeakMap,Wo=new WeakMap,Go=new WeakMap,Vo=new WeakMap,zo=new WeakMap,hn=new WeakMap,T=new WeakMap;var he=it;async function Ry(r,e){let t="GetSubredditLeaderboard",i="18ead70c46b6446d45ecd8b679b16d9a929a933d6ef25d8262a459cb18b72848",o=(await jt.query(t,i,{id:r},e)).data?.subredditInfoById?.leaderboard;if(!o)throw new Error("subreddit leaderboard not found");if(!o.summary)throw new Error("subreddit leaderboard summary not found");return{id:o.id,summary:o.summary}}function cF(r){if(r==="public"||r==="private"||r==="restricted"||r==="employees_only"||r==="gold_restricted"||r==="archived")return r;throw new Error(`invalid subreddit type: ${r}`)}function mF(r){if(r==="any"||r==="link"||r==="self")return r;throw new Error(`invalid allowed post type: ${r}`)}function pF(r){if(r==="animated"||r==="giphy"||r==="static"||r==="expression")return r;throw new Error(`invalid comment media type: ${r}`)}function HS(r,e){let i=(r.data?.children??[]).map(a=>{let c=n(a);if(c!=null)return c;let p=o(a);return p??null}).filter(Boolean);return{after:r.data?.after,before:r.data?.before,children:i};function n(a){try{return new V(a.data,e)}catch{return null}}function o(a){try{return new X(a.data,e)}catch{return null}}}async function Oy(r,e){return WS("GetVaultContactByAddress","3e2f7966a5c120e64fd2795d06a46595c52d988185be98d3ed71c3f81ae80d2e",{provider:"ethereum",address:r},e)}async function Fy(r,e){return WS("GetVaultContactByUserId","a854ddc19d0e22c4f36ed917fdbd568f299f3571427e393aee5e2972080fffe9",{provider:"ethereum",userId:r},e)}async function WS(r,e,t,i){let o=(await jt.query(r,e,t,i))?.data?.vault?.contact;return{provider:o?.provider,userId:te(o?.userId),address:o?.address,createdAt:o?.createdAt,isActive:o?.isActive}}import{CommunityListWidget_CommunityData as fF,GetWidgetsResponse_WidgetItem as le}from"@devvit/protos";var Jo,$o,Ko,Xo,sp=class sp{constructor(e,t,i){d(this,Jo,void 0);d(this,$o,void 0);d(this,Ko,void 0);d(this,Xo,void 0);J(this),l(this,Jo,e.id),l(this,$o,e.shortName),l(this,Ko,t),l(this,Xo,i)}get id(){return s(this,Jo)}get name(){return s(this,$o)}get subredditName(){return s(this,Ko)}toJSON(){return{id:this.id,name:this.name,subredditName:this.subredditName}}delete(){return sp.delete(this.subredditName,this.id,s(this,Xo))}static async getWidgets(e,t){let n=await u.redditAPIPlugins.Widgets.GetWidgets({subreddit:e},t);g(n.layout,"Failed to load widgets for subreddit");let o=n.items,a=[];for(let c of n.layout.sidebar?.order??[]){let p=o[c];switch(p?.kind){case"image":a.push(new Fl(p,e,t));break;case"calendar":a.push(new Ml(p,e,t));break;case"textarea":a.push(new Ll(p,e,t));break;case"button":a.push(new Ul(p,e,t));break;case"community-list":a.push(new Bl(p,e,t));break;case"post-flair":a.push(new Dl(p,e,t));break;case"custom":a.push(new _l(p,e,t));break;case"subreddit-rules":{let f=await u.redditAPIPlugins.Subreddits.SubredditAboutRules({subreddit:e},t);a.push(new np(f,p,e,t));break}default:throw new Error(`Unknown widget type: ${p.kind}`)}}return a}static async delete(e,t,i){await u.redditAPIPlugins.Widgets.DeleteWidget({subreddit:e,id:t},i)}static async reorder(e,t,i){await u.redditAPIPlugins.Widgets.OrderWidgets({subreddit:e,order:t},i)}static async add(e,t){switch(e?.type){case"image":return Fl.create(e,t);case"calendar":return Ml.create(e,t);case"textarea":return Ll.create(e,t);case"button":return Ul.create(e,t);case"community-list":return Bl.create(e,t);case"post-flair":return Dl.create(e,t);case"custom":return _l.create(e,t);default:throw new Error("Unknown widget type")}}};Jo=new WeakMap,$o=new WeakMap,Ko=new WeakMap,Xo=new WeakMap;var re=sp,Zo,Nl=class Nl extends re{constructor(t,i,n){super(t,i,n);d(this,Zo,void 0);l(this,Zo,t.data.map(o=>(g(o.url,"Image widget data is missing url"),g(o.height,"Image widget data is missing height"),g(o.width,"Image widget data is missing width"),g(o.linkUrl,"Image widget data is missing linkUrl"),{url:o.url,height:o.height,width:o.width,linkUrl:o.linkUrl})))}get images(){return s(this,Zo)}toJSON(){return{...super.toJSON(),images:this.images}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddImageWidget(t,i);return new Nl(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdateImageWidget(t,i);return new Nl(le.fromJSON(o),t.subreddit,i)}};Zo=new WeakMap;var Fl=Nl,Yo,Qo,ea,ql=class ql extends re{constructor(t,i,n){super(t,i,n);d(this,Yo,void 0);d(this,Qo,void 0);d(this,ea,void 0);g(t.googleCalendarId,"Calendar widget data is missing googleCalendarId"),g(t.configuration,"Calendar widget data is missing configuration"),g(t.styles,"Calendar widget data is missing styles"),l(this,Yo,t.googleCalendarId),l(this,Qo,t.configuration),l(this,ea,t.styles)}get googleCalendarId(){return s(this,Yo)}get configuration(){return s(this,Qo)}get styles(){return s(this,ea)}toJSON(){return{...super.toJSON(),googleCalendarId:this.googleCalendarId,configuration:this.configuration,styles:this.styles}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddCalendarWidget(t,i);return new ql(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdateCalendarWidget(t,i);return new ql(le.fromJSON(o),t.subreddit,i)}};Yo=new WeakMap,Qo=new WeakMap,ea=new WeakMap;var Ml=ql,ta,ra,jl=class jl extends re{constructor(t,i,n){super(t,i,n);d(this,ta,void 0);d(this,ra,void 0);g(t.text,"Textarea widget data is missing text"),g(t.styles,"Textarea widget data is missing styles"),l(this,ta,t.text),l(this,ra,t.styles)}get text(){return s(this,ta)}get styles(){return s(this,ra)}toJSON(){return{...super.toJSON(),text:this.text,styles:this.styles}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddTextAreaWidget(t,i);return new jl(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdateTextAreaWidget(t,i);return new jl(le.fromJSON(o),t.subreddit,i)}};ta=new WeakMap,ra=new WeakMap;var Ll=jl,ia,na,sa,Hl=class Hl extends re{constructor(t,i,n){super(t,i,n);d(this,ia,void 0);d(this,na,void 0);d(this,sa,void 0);g(t.styles,"Button widget data is missing styles"),l(this,ia,t.buttons),l(this,na,t.description??""),l(this,sa,t.styles)}get buttons(){return s(this,ia)}get description(){return s(this,na)}get styles(){return s(this,sa)}toJSON(){return{...super.toJSON(),buttons:this.buttons,description:this.description,styles:this.styles}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddButtonWidget(t,i);return new Hl(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdateButtonWidget(t,i);return new Hl(le.fromJSON(o),t.subreddit,i)}};ia=new WeakMap,na=new WeakMap,sa=new WeakMap;var Ul=Hl,oa,aa,Wl=class Wl extends re{constructor(t,i,n){super(t,i,n);d(this,oa,void 0);d(this,aa,void 0);l(this,oa,t.data.map(o=>fF.fromJSON(o))),g(t.styles,"Community list widget data is missing styles"),l(this,aa,t.styles)}get communities(){return s(this,oa)}get styles(){return s(this,aa)}toJSON(){return{...super.toJSON(),communities:this.communities,styles:this.styles}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddCommunityListWidget(t,i);return new Wl(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdateCommunityListWidget(t,i);return new Wl(le.fromJSON(o),t.subreddit,i)}};oa=new WeakMap,aa=new WeakMap;var Bl=Wl,da,la,ua,Gl=class Gl extends re{constructor(t,i,n){super(t,i,n);d(this,da,void 0);d(this,la,void 0);d(this,ua,void 0);if(g(t.styles,"Post flair widget data is missing styles"),l(this,da,t.styles),l(this,la,t.order.map(o=>t.templates[o])),!(t.display&&t.display==="list"||t.display==="cloud"))throw new Error("Post flair widget data is missing display type");l(this,ua,t.display)}get styles(){return s(this,da)}get templates(){return s(this,la)}get display(){return s(this,ua)}toJSON(){return{...super.toJSON(),styles:this.styles,templates:this.templates,display:this.display}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddPostFlairWidget(t,i);return new Gl(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdatePostFlairWidget(t,i);return new Gl(le.fromJSON(o),t.subreddit,i)}};da=new WeakMap,la=new WeakMap,ua=new WeakMap;var Dl=Gl,ca,ma,pa,fa,ga,Vl=class Vl extends re{constructor(t,i,n){super(t,i,n);d(this,ca,void 0);d(this,ma,void 0);d(this,pa,void 0);d(this,fa,void 0);d(this,ga,void 0);g(t.stylesheetUrl,"Custom widget data is missing stylesheetUrl"),g(t.height,"Custom widget data is missing height"),g(t.css,"Custom widget data is missing css"),l(this,ca,t.imageData??[]),l(this,ma,t.text??""),l(this,pa,t.stylesheetUrl),l(this,fa,t.height),l(this,ga,t.css)}get images(){return s(this,ca)}get text(){return s(this,ma)}get stylesheetUrl(){return s(this,pa)}get height(){return s(this,fa)}get css(){return s(this,ga)}toJSON(){return{...super.toJSON(),images:this.images,text:this.text,stylesheetUrl:this.stylesheetUrl,height:this.height,css:this.css}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddCustomWidget(t,i);return new Vl(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdateCustomWidget(t,i);return new Vl(le.fromJSON(o),t.subreddit,i)}};ca=new WeakMap,ma=new WeakMap,pa=new WeakMap,fa=new WeakMap,ga=new WeakMap;var _l=Vl,ha,np=class extends re{constructor(t,i,n,o){super(i,n,o);d(this,ha,void 0);let a=t.rules.map(({description:c,priority:p,shortName:f,violationReason:v})=>(g(c,"Subreddit rule is missing description"),g(p,"Subreddit rule is missing priority"),g(f,"Subreddit rule is missing shortName"),g(v,"Subreddit rule is missing violationReason"),{description:c,priority:p,shortName:f,violationReason:v}));l(this,ha,a)}get rules(){return s(this,ha)}toJSON(){return{...super.toJSON(),rules:this.rules}}};ha=new WeakMap;var gF=(i=>(i[i.SUBREDDIT_PERMISSIONS=0]="SUBREDDIT_PERMISSIONS",i[i.APPROVED_CONTRIBUTORS_ONLY=1]="APPROVED_CONTRIBUTORS_ONLY",i[i.MODS_ONLY=2]="MODS_ONLY",i))(gF||{}),ke,Se,vn,yn,bn,kn,Sn,Ke,qe=class qe{constructor(e,t,i,n){d(this,ke,void 0);d(this,Se,void 0);d(this,vn,void 0);d(this,yn,void 0);d(this,bn,void 0);d(this,kn,void 0);d(this,Sn,void 0);d(this,Ke,void 0);J(this),l(this,ke,e),l(this,Se,t),l(this,vn,i.contentMd),l(this,yn,i.revisionId),l(this,bn,new Date(i.revisionDate)),l(this,kn,i.reason??""),g(i.revisionBy?.data,"Wiki page author details are missing"),l(this,Sn,new w(i.revisionBy.data,n)),l(this,Ke,n)}get name(){return s(this,ke)}get subredditName(){return s(this,Se)}get content(){return s(this,vn)}get revisionId(){return s(this,yn)}get revisionDate(){return s(this,bn)}get revisionReason(){return s(this,kn)}get revisionAuthor(){return s(this,Sn)}toJSON(){return{name:s(this,ke),subredditName:s(this,Se),content:s(this,vn),revisionId:s(this,yn),revisionDate:s(this,bn),revisionReason:s(this,kn),revisionAuthor:s(this,Sn).toJSON()}}async update(e,t){return qe.updatePage({subredditName:s(this,Se),page:s(this,ke),content:e,reason:t},s(this,Ke))}async getRevisions(e){return qe.getPageRevisions({subredditName:s(this,Se),page:s(this,ke),...e},s(this,Ke))}async revertTo(e){return qe.revertPage(s(this,Se),s(this,ke),e,s(this,Ke))}async getSettings(){return qe.getPageSettings(s(this,Se),s(this,ke),s(this,Ke))}async updateSettings(e){return qe.updatePageSettings({subredditName:s(this,Se),page:s(this,ke),listed:e.listed,permLevel:e.permLevel},s(this,Ke))}async addEditor(e){return qe.addEditor(s(this,Se),s(this,ke),e,s(this,Ke))}async removeEditor(e){return qe.removeEditor(s(this,Se),s(this,ke),e,s(this,Ke))}static async getPage(e,t,i){let o=await u.redditAPIPlugins.Wiki.GetWikiPage({subreddit:e,page:t},i);return g(o.data,"Failed to get wiki page"),new qe(t,e,o.data,i)}static async getPages(e,t){return(await u.redditAPIPlugins.Wiki.GetWikiPages({subreddit:e},t)).data||[]}static async createPage(e,t){return qe.updatePage(e,t)}static async updatePage(e,t){return await u.redditAPIPlugins.Wiki.EditWikiPage({subreddit:e.subredditName,page:e.page,content:e.content,reason:e.reason??""},t),qe.getPage(e.subredditName,e.page,t)}static getPageRevisions(e,t){let i=u.redditAPIPlugins.Wiki;return new H({hasMore:!0,after:e.after,limit:e.limit,pageSize:e.pageSize,async fetch(n){let o=await i.GetWikiPageRevisions({subreddit:e.subredditName,page:e.page,limit:n.limit,after:n.after,before:n.before},t);return hF(o,t)}})}static async revertPage(e,t,i,n){await u.redditAPIPlugins.Wiki.RevertWikiPage({subreddit:e,page:t,revision:i},n)}static async getPageSettings(e,t,i){let o=await u.redditAPIPlugins.Wiki.GetWikiPageSettings({subreddit:e,page:t},i);return g(o.data,"Failed to get wiki page settings"),new zl(o.data,i)}static async updatePageSettings(e,t){let n=await u.redditAPIPlugins.Wiki.UpdateWikiPageSettings({subreddit:e.subredditName,page:e.page,listed:e.listed?"on":"",permlevel:e.permLevel},t);return g(n.data,"Failed to update wiki page settings"),new zl(n.data,t)}static async addEditor(e,t,i,n){await u.redditAPIPlugins.Wiki.AllowEditor({act:"add",subreddit:e,page:t,username:i},n)}static async removeEditor(e,t,i,n){await u.redditAPIPlugins.Wiki.AllowEditor({act:"del",subreddit:e,page:t,username:i},n)}};ke=new WeakMap,Se=new WeakMap,vn=new WeakMap,yn=new WeakMap,bn=new WeakMap,kn=new WeakMap,Sn=new WeakMap,Ke=new WeakMap;var ve=qe,Pn,Cn,xn,wn,In,An,op=class{constructor(e,t){d(this,Pn,void 0);d(this,Cn,void 0);d(this,xn,void 0);d(this,wn,void 0);d(this,In,void 0);d(this,An,void 0);l(this,Pn,e.id),l(this,Cn,e.page),l(this,xn,new Date(e.timestamp)),g(e.author?.data,"Wiki page revision author details are missing"),l(this,wn,new w(e.author.data,t)),l(this,In,e.reason??""),l(this,An,e.revisionHidden??!1)}get id(){return s(this,Pn)}get page(){return s(this,Cn)}get date(){return s(this,xn)}get author(){return s(this,wn)}get reason(){return s(this,In)}get hidden(){return s(this,An)}toJSON(){return{id:s(this,Pn),page:s(this,Cn),date:s(this,xn),author:s(this,wn).toJSON(),reason:s(this,In),hidden:s(this,An)}}};Pn=new WeakMap,Cn=new WeakMap,xn=new WeakMap,wn=new WeakMap,In=new WeakMap,An=new WeakMap;var Tn,En,Rn,zl=class{constructor(e,t){d(this,Tn,void 0);d(this,En,void 0);d(this,Rn,void 0);l(this,Tn,e.listed),l(this,En,e.permLevel),l(this,Rn,e.editors.map(i=>(g(i.data,"Wiki page editor details are missing"),new w(i.data,t))))}get listed(){return s(this,Tn)}get permLevel(){return s(this,En)}get editors(){return s(this,Rn)}toJSON(){return{listed:s(this,Tn),permLevel:s(this,En),editors:s(this,Rn).map(e=>e.toJSON())}}};Tn=new WeakMap,En=new WeakMap,Rn=new WeakMap;function hF(r,e){return g(r.data?.children,"Wiki page revision listing is missing children"),{children:r.data.children.map(i=>new op(i,e)),before:r.data.before,after:r.data.after}}var vF=(t=>(t.Gallery="GALLERY",t.Timeline="TIMELINE",t))(vF||{});function yF(r){return r==="GALLERY"?"GALLERY":"TIMELINE"}var je,Pe,ya,On,Fn,ba,ka,Sa,Pa,vt,Ca,xa,Mn,va=class va{constructor(e,t){d(this,je,void 0);d(this,Pe,void 0);d(this,ya,void 0);d(this,On,void 0);d(this,Fn,void 0);d(this,ba,void 0);d(this,ka,void 0);d(this,Sa,void 0);d(this,Pa,void 0);d(this,vt,void 0);d(this,Ca,void 0);d(this,xa,void 0);d(this,Mn,void 0);g(e.collectionId,"Collection Id is missing or undefined"),g(e.subredditId,"Subreddit Id is missing or undefined"),g(e.title,"Collection title is missing or undefined"),g(e.authorId,"Collection author's id is missing or undefined"),g(e.authorName,"Collection author's id is missing or undefined"),g(e.createdAtUtc,"Collection create timestamp is missing"),g(e.lastUpdateUtc,"Collection last updated timestamp is missing"),l(this,je,t),l(this,Pe,e.collectionId),l(this,ya,e.subredditId),l(this,On,e.title),l(this,Fn,e.description||""),l(this,ba,e.authorId),l(this,ka,e.authorName),l(this,Sa,e.permalink),l(this,Pa,e.primaryLinkId),l(this,vt,e.linkIds||[]),l(this,Mn,yF(e.displayLayout)),l(this,Ca,e.createdAtUtc),l(this,xa,e.lastUpdateUtc),J(this)}get id(){return s(this,Pe)}get subredditId(){return s(this,ya)}get title(){return s(this,On)}get description(){return s(this,Fn)}get authorId(){return s(this,ba)}get authorName(){return s(this,ka)}get permalink(){return s(this,Sa)}get primaryLinkId(){return s(this,Pa)}get linkIds(){return s(this,vt)}get createdAtUtc(){return s(this,Ca)}get lastUpdateUtc(){return s(this,xa)}get displayLayout(){return s(this,Mn)}static async getCollectionById(e,t){let n=await u.redditAPIPlugins.PostCollections.Collection(e,t);return new va(n,t)}static async create(e,t){let n=await u.redditAPIPlugins.PostCollections.Create({srFullname:e.subredditId,title:e.title,description:e.description,displayLayout:e.displayLayout},t);return new va(n,t)}static async getCollectionsForSubreddit(e,t){return(await u.redditapiv2Plugin.GetSubredditCollections({srFullname:e.subredditId},t)).collections.map(n=>new va(n,t))}async addPost(e){await u.redditAPIPlugins.PostCollections.AddPost({collectionId:s(this,Pe),linkFullname:e},s(this,je)),s(this,vt).push(e)}async removePost(e){await u.redditAPIPlugins.PostCollections.RemovePost({collectionId:s(this,Pe),linkFullname:e},s(this,je)),l(this,vt,s(this,vt).filter(i=>i!==e))}async delete(){await u.redditAPIPlugins.PostCollections.Delete({collectionId:s(this,Pe)},s(this,je))}async follow(e){await u.redditAPIPlugins.PostCollections.Follow({collectionId:s(this,Pe),follow:e},s(this,je))}async reorder(e){await u.redditAPIPlugins.PostCollections.Reorder({collectionId:s(this,Pe),linkIds:e.join(",")},s(this,je)),l(this,vt,e)}async updateTitle(e){await u.redditAPIPlugins.PostCollections.UpdateTitle({collectionId:s(this,Pe),title:e},s(this,je)),l(this,On,e)}async updateDescription(e){await u.redditAPIPlugins.PostCollections.UpdateDescription({collectionId:s(this,Pe),description:e},s(this,je)),l(this,Fn,e)}async updateLayout(e){await u.redditAPIPlugins.PostCollections.UpdateDisplayLayout({collectionId:s(this,Pe),displayLayout:e},s(this,je)),l(this,Mn,e)}};je=new WeakMap,Pe=new WeakMap,ya=new WeakMap,On=new WeakMap,Fn=new WeakMap,ba=new WeakMap,ka=new WeakMap,Sa=new WeakMap,Pa=new WeakMap,vt=new WeakMap,Ca=new WeakMap,xa=new WeakMap,Mn=new WeakMap;var di=va;var bF=["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"],kF=["border-image","border-image-source","behavior","expression","list-style-image","cursor","content"],SF=["onload","onerror","onclick","onmouseover"];function PF(r){return/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/.test(r)?r:r.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"')}function GS(r){if(r){if(!r.trim().startsWith("<svg")){console.log("The provided string is not a valid SVG.");return}try{let e=new RegExp(`<\\s*(${bF.join("|")})\\b`,"gi"),t=new RegExp(`(${kF.join("|")})\\s*:\\s*url\\s*\\((['"]?)(.*?)\\2\\)`,"gi"),i=new RegExp(`(${SF.join("|")})\\s*(=\\s*(['"]?)(.*?)\\3)?`,"gi");r=r.trim().replace(/\s+/g," "),r=PF(r);let n=r.match(e)||[],o=r.match(t)||[],a=r.match(i)||[],c=!1;return n.length>0&&(c=!0,console.warn(`Disallowed elements detected in SVG: ${n.map(p=>p.replace("<","")).join(", ")}`)),o.length>0&&(c=!0,console.warn(`Disallowed styles detected in SVG: ${o.map(p=>p.split(":")[0]).join(", ")}`)),a.length>0&&(c=!0,console.warn(`Disallowed attributes detected in SVG: ${a.map(p=>p.split("=")[0]).join(", ")}`)),c?void 0:r}catch{return}}}function mH(r,...e){let t="";return r.forEach((i,n)=>{t+=i;let o=e[n];o!==void 0&&(t+=`${o}`)}),t=GS(t),t===void 0?"":`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(t)}`}var VS="ServerCallRequired";var zS=Dr(Qd(),1);var nt,yt,wa,Ln,Ia,Br,ap=class{constructor(e,t,i){d(this,nt,void 0);d(this,yt,void 0);d(this,wa,void 0);d(this,Ln,void 0);d(this,Ia,void 0);d(this,Br,void 0);l(this,nt,!!i.context.devvitContext.debug.useAsync),s(this,nt)&&console.debug("[useAsync] v1",t),this.state={data:null,load_state:"initial",error:null,depends:null},l(this,yt,i.hookId),l(this,wa,e),l(this,Ln,i.invalidate),l(this,Ia,i.context),l(this,Br,t.depends??null),(t.enabled??!0)||(this.state.load_state="disabled")}onStateLoaded(){if(this.state.load_state!=="disabled"&&(s(this,nt)&&console.debug("[useAsync] async onLoad ",s(this,yt),this.state),s(this,nt)&&console.debug("[useAsync] async onLoad have ",s(this,Br),"and",this.state.depends),!(0,zS.default)(s(this,Br),this.state.depends)||this.state.load_state==="initial")){this.state.load_state="loading",this.state.depends=s(this,Br),s(this,Ln).call(this);let e={hook:s(this,yt),async:!0,asyncRequest:{requestId:s(this,yt)+"-"+JSON.stringify(this.state.depends)}};s(this,nt)&&console.debug("[useAsync] onLoad requeue"),s(this,Ia).addToRequeueEvents(e)}}async onUIEvent(e,t){if(e.asyncRequest){let i={requestId:e.asyncRequest.requestId};try{i.data={value:await s(this,wa).call(this)}}catch(o){if(o instanceof Error){if(o.message===VS)throw o;i.error={message:o.message,details:o.stack??""}}else i.error={message:"Unknown error",details:String(o)}}let n={asyncResponse:i,hook:s(this,yt)};s(this,nt)&&console.debug("[useAsync] onReq requeue"),t.addToRequeueEvents(n)}else if(e.asyncResponse){let i=s(this,yt)+"-"+JSON.stringify(this.state.depends);e.asyncResponse.requestId===i?(this.state={...this.state,data:e.asyncResponse.data?.value,error:e.asyncResponse.error??null,load_state:e.asyncResponse.error?"error":"loaded"},s(this,Ln).call(this)):s(this,nt)&&console.debug("[useAsync] onResp skip, stale event")}else throw new Error("Unknown event type")}};nt=new WeakMap,yt=new WeakMap,wa=new WeakMap,Ln=new WeakMap,Ia=new WeakMap,Br=new WeakMap;function CF(r,e={}){let t=De({namespace:"useAsync"},i=>new ap(r,e,i));return{data:t.state.data,error:t.state.error,loading:t.state.load_state==="loading"}}export{GL as ALL_ICON_NAMES,Ey as AboutLocations,Ul as ButtonWidget,Ml as CalendarWidget,vF as CollectionDisplayLayout,X as Comment,Bl as CommunityListWidget,_l as CustomWidget,u as Devvit,Le as Flair,ae as FlairTemplate,zO as FlairType,Ct as Hook,Fl as ImageWidget,H as Listing,lF as ModMailActionType,aF as ModMailConversationState,Rd as ModMailService,Me as ModNote,V as Post,di as PostCollection,Dl as PostFlairWidget,ur as PrivateMessage,Ws as RichTextBuilder,zc as SettingScope,he as Subreddit,np as SubredditRulesWidget,Ll as TextAreaWidget,w as User,re as Widget,ve as WikiPage,gF as WikiPagePermissionLevel,op as WikiPageRevision,zl as WikiPageSettings,Js as convertUserFlairProtoToAPI,Ed as getModerationLog,Ry as getSubredditLeaderboard,Oy as getVaultByAddress,Fy as getVaultByUserId,mH as svg,CF as useAsync,OO as useAsyncState,Lm as useChannel,Rm as useForm,Dm as useInterval,_m as useState};
5
+ `))}static async getSnoovatarUrl(e,t){let i="GetSnoovatarUrlByName",n="c47fd42345af268616d2d8904b56856acdc05cf61d3650380f539ad7d596ac0c";return(await jt.query(i,n,{username:e},t)).data?.redditorInfoByName?.snoovatarIcon?.url}static getOverview(e,t){let i=u.redditAPIPlugins.Users;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(n){let o=await i.UserWhere({username:e.username,where:"overview",...n},t);return oF(o,t)}})}};mo=new WeakMap,sn=new WeakMap,po=new WeakMap,fo=new WeakMap,go=new WeakMap,ho=new WeakMap,vo=new WeakMap,Xt=new WeakMap,yo=new WeakMap,bo=new WeakMap,ft=new WeakMap;var x=Fr;function oF(r,e){if(!r.data?.children)throw new Error("Listing response is missing children");return{children:r.data.children.map(i=>{if(i.kind==="t3")return new V(i.data,e);if(i.kind==="t1")return new X(i.data,e);throw new Error(`Type ${i.kind} is not supported`)}),before:r.data.before,after:r.data.after}}async function aF(r,e,t){let i=u.redditAPIPlugins.Users;if(!r.data?.children)throw new Error("Listing response is missing children");let n=r.data.children.map(v=>(g(v.data?.id,"User id is still from listing data"),v.data.id)),o=100,a=[];for(let v=0;v<n.length;v+=o)a.push(n.slice(v,v+o));let p=(await Promise.all(a.map(v=>i.UserDataByAccountIds({ids:v.join(",")},t)))).reduce((v,m)=>({...v,...m.users}),{});return{children:r.data.children.map(v=>{let m=v.data?.id;g(m,"User id is missing from listing");let k=p[m];return g(k,"User data is missing from response"),new x({id:m,name:k.name,linkKarma:k.linkKarma,commentKarma:k.commentKarma,createdUtc:k.createdUtc,over18:k.profileOver18,snoovatarSize:[],modPermissions:{[e]:v.data?.modPermissions??[]}},t)}),before:r.data.before,after:r.data.after}}var Mr,ko,on,an,So,Po,dn,Co,wo,ln,Zt,xo,Io,Ur,Yt,Qt,gt,Lr,ht,Ao,To,Eo,Ro,Oo,Fo,Mo,Q,un,Al,cn,Tl,W=class W{constructor(e,t){d(this,Mr,void 0);d(this,ko,void 0);d(this,on,void 0);d(this,an,void 0);d(this,So,void 0);d(this,Po,void 0);d(this,dn,void 0);d(this,Co,void 0);d(this,wo,void 0);d(this,ln,void 0);d(this,Zt,void 0);d(this,xo,void 0);d(this,Io,void 0);d(this,Ur,void 0);d(this,Yt,void 0);d(this,Qt,void 0);d(this,gt,void 0);d(this,Lr,void 0);d(this,ht,void 0);d(this,Ao,void 0);d(this,To,void 0);d(this,Eo,void 0);d(this,Ro,void 0);d(this,Oo,void 0);d(this,Fo,void 0);d(this,Mo,void 0);d(this,Q,void 0);var n;J(this),g(e.id,"Comment id is null or undefined"),g(e.body,"Comment body is null or undefined"),g(e.createdUtc,"Comment is missing created date"),g(e.author,"Comment author is null or undefined"),g(e.parentId,"Comment parentId is null or undefined"),g(e.linkId,"Comment linkId is null or undefined"),g(e.permalink,"Comment permalink is null or undefined"),g(e.subreddit,"Comment is missing subreddit name"),g(e.subredditId,"Comment is missing subreddit id"),l(this,Mr,Yr(`t1_${e.id}`)),l(this,ko,e.authorFullname?re(e.authorFullname):void 0),l(this,on,e.author),l(this,an,e.body),l(this,Co,Re(e.subredditId)),l(this,wo,e.subreddit),l(this,Po,Vc(e.parentId)?Yr(e.parentId):fe(e.parentId)),l(this,dn,fe(e.linkId)),l(this,Ur,e.edited??!1),l(this,Yt,e.locked??!1),l(this,Qt,e.removed??!1),l(this,gt,e.stickied??!1),l(this,Zt,e.approved??!1),l(this,xo,e.approvedAtUtc??0),l(this,Io,e.bannedAtUtc??0),l(this,Lr,e.spam??!1),l(this,ht,e.distinguished),l(this,Ao,e.numReports??0),l(this,To,e.collapsedBecauseCrowdControl??!1),l(this,Eo,e.score??0),l(this,Ro,e.permalink),l(this,Mo,new URL(e.permalink??"","https://www.reddit.com/").toString()),l(this,Oo,(e.modReports??[]).map(([o])=>o)),l(this,Fo,(e.userReports??[]).map(([o])=>o));let i=new Date(0);i.setUTCSeconds(e.createdUtc),l(this,So,i),l(this,ln,y(n=W,un,Al).call(n,{postId:s(this,dn),commentId:s(this,Mr)},t)),l(this,Q,t)}get id(){return s(this,Mr)}get authorId(){return s(this,ko)}get authorName(){return s(this,on)}get subredditId(){return s(this,Co)}get subredditName(){return s(this,wo)}get body(){return s(this,an)}get createdAt(){return s(this,So)}get parentId(){return s(this,Po)}get postId(){return s(this,dn)}get replies(){return s(this,ln)}get distinguishedBy(){return s(this,ht)}get locked(){return s(this,Yt)}get stickied(){return s(this,gt)}get removed(){return s(this,Qt)}get approved(){return s(this,Zt)}get approvedAtUtc(){return s(this,xo)}get bannedAtUtc(){return s(this,Io)}get spam(){return s(this,Lr)}get edited(){return s(this,Ur)}get numReports(){return s(this,Ao)}get collapsedBecauseCrowdControl(){return s(this,To)}get score(){return s(this,Eo)}get permalink(){return s(this,Ro)}get userReportReasons(){return s(this,Fo)}get modReportReasons(){return s(this,Oo)}get url(){return s(this,Mo)}toJSON(){return{id:this.id,authorName:this.authorName,subredditId:this.subredditId,subredditName:this.subredditName,body:this.body,createdAt:this.createdAt,parentId:this.parentId,postId:this.postId,replies:this.replies,approved:this.approved,locked:this.locked,removed:this.removed,stickied:this.stickied,spam:this.spam,edited:this.edited,distinguishedBy:this.distinguishedBy,numReports:this.numReports,collapsedBecauseCrowdControl:this.collapsedBecauseCrowdControl,score:this.score,permalink:this.permalink,modReportReasons:this.modReportReasons,userReportReasons:this.userReportReasons,url:this.url}}isLocked(){return s(this,Yt)}isApproved(){return s(this,Zt)}isRemoved(){return s(this,Qt)}isSpam(){return s(this,Lr)}isStickied(){return s(this,gt)}isDistinguished(){return!!s(this,ht)}isEdited(){return s(this,Ur)}async delete(){return W.delete(this.id,s(this,Q))}async edit(e){let t=await W.edit({id:this.id,...e},s(this,Q));return l(this,an,t.body),l(this,Ur,t.edited),this}async approve(){await W.approve(this.id,s(this,Q)),l(this,Zt,!0),l(this,Qt,!1)}async remove(e=!1){await W.remove(this.id,e,s(this,Q)),l(this,Qt,!0),l(this,Lr,e),l(this,Zt,!1)}async lock(){await W.lock(this.id,s(this,Q)),l(this,Yt,!0)}async unlock(){await W.unlock(this.id,s(this,Q)),l(this,Yt,!1)}async reply(e){return W.submit({id:this.id,...e},s(this,Q))}async getAuthor(){return x.getByUsername(s(this,on),s(this,Q))}async distinguish(e=!1){let{distinguishedBy:t,stickied:i}=await W.distinguish(this.id,e,!1,s(this,Q));l(this,ht,t),l(this,gt,i)}async distinguishAsAdmin(e=!1){let{distinguishedBy:t,stickied:i}=await W.distinguish(this.id,e,!0,s(this,Q));l(this,ht,t),l(this,gt,i)}async undistinguish(){let{distinguishedBy:e,stickied:t}=await W.undistinguish(this.id,s(this,Q));l(this,ht,e),l(this,gt,t)}addRemovalNote(e){return Me.addRemovalNote({itemIds:[s(this,Mr)],...e},s(this,Q))}static async getById(e,t){let i=u.redditAPIPlugins.LinksAndComments,n=Pt(e)?e:`t1_${e}`,o=await i.Info({subreddits:[],thingIds:[n]},t);if(!o.data?.children?.[0]?.data)throw new Error("not found");return new W(o.data.children[0].data,t)}static getComments(e,t){var a;let{postId:i,commentId:n,...o}=e;return y(a=W,un,Al).call(a,{postId:fe(i),commentId:n?Yr(n):void 0,...o},t)}static async edit(e,t){let i=u.redditAPIPlugins.LinksAndComments,{id:n}=e,o;"richtext"in e&&(o=Li(e.richtext));let a=await i.EditUserText({thingId:n,text:"text"in e?e.text:"",richtextJson:o},t);if(a.json?.errors?.length)throw new Error("Failed to edit comment");let c=a.json?.data?.things?.[0]?.data;return g(c),new W(c,t)}static async delete(e,t){await u.redditAPIPlugins.LinksAndComments.Del({id:e},t)}static async approve(e,t){await u.redditAPIPlugins.Moderation.Approve({id:e},t)}static async remove(e,t=!1,i){await u.redditAPIPlugins.Moderation.Remove({id:e,spam:t},i)}static async lock(e,t){await u.redditAPIPlugins.LinksAndComments.Lock({id:e},t)}static async unlock(e,t){await u.redditAPIPlugins.LinksAndComments.Unlock({id:e},t)}static async submit(e,t){let i=u.redditAPIPlugins.LinksAndComments,{id:n}=e,o;"richtext"in e&&(o=Li(e.richtext));let a=await i.Comment({thingId:n,text:"text"in e?e.text:"",richtextJson:o},t);if(a.json?.errors?.length)throw new Error("failed to reply to comment");let c=a.json?.data?.things?.[0]?.data;return g(c),new W(c,t)}static async distinguish(e,t,i,n){let c=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:i?"admin":"yes",sticky:t},n)).json?.data?.things?.[0]?.data;return g(c),{distinguishedBy:c.distinguished,stickied:!!c.stickied}}static async undistinguish(e,t){let o=(await u.redditAPIPlugins.Moderation.Distinguish({id:e,how:"no",sticky:!1},t)).json?.data?.things?.[0]?.data;return g(o),{distinguishedBy:o.distinguished,stickied:!!o.stickied}}static getCommentsByUser(e,t){let i=u.redditAPIPlugins.Users;return new H({hasMore:!0,before:e.before,after:e.after,pageSize:e.pageSize,limit:e.limit,async fetch(n){let o=await i.UserWhere({username:e.username,where:"comments",...n},t);return g(o.data,"Failed to get comments for user"),{children:o.data.children?.map(c=>new W(c.data,t))||[],before:o.data.before,after:o.data.after}}})}};Mr=new WeakMap,ko=new WeakMap,on=new WeakMap,an=new WeakMap,So=new WeakMap,Po=new WeakMap,dn=new WeakMap,Co=new WeakMap,wo=new WeakMap,ln=new WeakMap,Zt=new WeakMap,xo=new WeakMap,Io=new WeakMap,Ur=new WeakMap,Yt=new WeakMap,Qt=new WeakMap,gt=new WeakMap,Lr=new WeakMap,ht=new WeakMap,Ao=new WeakMap,To=new WeakMap,Eo=new WeakMap,Ro=new WeakMap,Oo=new WeakMap,Fo=new WeakMap,Mo=new WeakMap,Q=new WeakMap,un=new WeakSet,Al=function(e,t,i=0){return new H({limit:e.limit,pageSize:e.pageSize,fetch:async n=>{var k,b;let o=n.limit,a=u.redditAPIPlugins.Listings,c=u.redditAPIPlugins.LinksAndComments,p=e.commentId;if(n.more)if(n.more.children.length){let C=n.more;(!o||o>100)&&(o=100);let w=C.children.splice(0,o),I=await c.MoreChildren({linkId:e.postId,children:w,sort:e.sort},t);if(!I.json?.data?.things?.length)return{children:[]};let{children:E}=y(k=W,cn,Tl).call(k,I.json.data.things,e.postId,e,t);return{children:E,more:C.children.length?C:void 0}}else p=n.more.parentId,i=i+n.more.depth;let v=(await a.Comments({article:e.postId.substring(3),comment:p?.substring(3),limit:o,depth:e.depth,sort:e.sort},t)).listings?.[1]?.data?.children??[],m=v[0];return p&&m?.data?.replyList?.data&&(v=m.data.replyList.data.children),y(b=W,cn,Tl).call(b,v,p??e.postId,e,t,i)}})},cn=new WeakSet,Tl=function(e,t,i,n,o=0){var f,v;let a=[],c,p={};for(let m of e){if(!m.data||(m.data.depth!=null&&(m.data.depth=m.data.depth+o),m.data.depth!=null&&i.depth!=null&&m.data.depth>=i.depth))continue;let k=m.data.parentId?p[m.data.parentId]:void 0;if(m.kind==="t1"){if(m.data.name===t)continue;let b=new W(m.data,n);if(p[b.id]=b,l(b,ln,y(f=W,un,Al).call(f,{...i,postId:b.postId,commentId:b.id},n,o)),"replyList"in m.data&&m.data.replyList?.data){let{children:C,more:w}=y(v=W,cn,Tl).call(v,m.data.replyList.data.children,b.id,i,n,o);C.length&&b.replies.children.push(...C),w&&b.replies.setMore(w)}b.replies.preventInitialFetch(),k?k.replies.children.push(b):a.push(b)}else if(m.kind==="more"&&m.data.parentId&&m.data.depth!=null){let b={parentId:Vc(m.data.parentId)?Yr(m.data.parentId):fe(m.data.parentId),children:m.data.children??[],depth:m.data.depth};k?k.replies.setMore(b):b.parentId===t&&(c=b)}}return{children:a,more:c}},d(W,un),d(W,cn);var X=W;function Ed(r,e){let t=u.redditAPIPlugins.Moderation;return new H({hasMore:!0,after:r.after,before:r.before,limit:r.limit,pageSize:r.pageSize,fetch:async i=>{let n=await t.AboutLog({subreddit:r.subredditName,mod:r.moderatorUsernames?r.moderatorUsernames.join(","):void 0,type:r.type,...i},e);return dF(n)}})}function dF(r){if(!r.data?.children)throw new Error("AboutLogResponse is missing children");return{children:r.data.children.map(t=>{if(!t.data)throw new Error("ModAction from AboutLogResponse is missing or invalid");let{id:i,mod:n,modId36:o,createdUtc:a,subreddit:c,subredditNamePrefixed:p,action:f,srId36:v,description:m,details:k,targetAuthor:b,targetBody:C,targetFullname:w,targetPermalink:I,targetTitle:E}=t.data;g(i,"ModAction from AboutLogResponse is missing id"),g(n,"ModAction from AboutLogResponse is missing mod"),g(o,"ModAction from AboutLogResponse is missing modId36"),g(a,"ModAction from AboutLogResponse is missing createdUtc"),g(c,"ModAction from AboutLogResponse is missing subreddit"),g(p,"ModAction from AboutLogResponse is missing subredditNamePrefixed"),g(f,"ModAction from AboutLogResponse is missing action"),g(v,"ModAction from AboutLogResponse is missing srId36");let ue=new Date(0);return ue.setUTCSeconds(a),{id:i,type:f,moderatorName:n,moderatorId:`t2_${o}`,createdAt:ue,subredditName:c,subredditId:`t5_${v}`,description:m,details:k,target:w?{id:w,author:b,body:C,permalink:I,title:E}:void 0}}),after:r.data.after,before:r.data.before}}var lF=(a=>(a.New="New",a.InProgress="InProgress",a.Archived="Archived",a.Appeals="Appeals",a.JoinRequests="JoinRequests",a.Filtered="Filtered",a))(lF||{}),uF={0:"New",1:"InProgress",2:"Archived",3:"Appeals",4:"JoinRequests",5:"Filtered"},cF=(b=>(b.Highlighted="Highlighted",b.Unhighlighted="Unhighlighted",b.Archived="Archived",b.Unarchived="Unarchived",b.ReportedToAdmins="ReportedToAdmins",b.Muted="Muted",b.Unmuted="Unmuted",b.Banned="Banned",b.Unbanned="Unbanned",b.Approved="Approved",b.Disapproved="Disapproved",b.Filtered="Filtered",b.Unfiltered="Unfiltered",b))(cF||{}),mF={0:"Highlighted",1:"Unhighlighted",2:"Archived",3:"Unarchived",4:"ReportedToAdmins",5:"Muted",6:"Unmuted",7:"Banned",8:"Unbanned",9:"Approved",10:"Disapproved",11:"Filtered",12:"Unfiltered"},G,Y,se,El,qS,Rl,jS,Rd=class{constructor(e){d(this,Y);d(this,El);d(this,Rl);d(this,G,void 0);l(this,G,e)}async bulkReadConversations(e,t){let i=u.redditAPIPlugins.NewModmail,{conversationIds:n}=await i.BulkReadConversations({entity:e.join(","),state:t},s(this,G));return n}async getConversations(e){let i=await u.redditAPIPlugins.NewModmail.GetConversations({after:e.after,entity:e.subreddits?e.subreddits.join(","):void 0,limit:e.limit,sort:e.sort,state:e.state},s(this,G)),n={};for(let o in i.conversations)n[o]=y(this,Y,se).call(this,{protoConversation:i.conversations[o],protoMessages:i.messages,protoModActions:{}});return{conversations:n,viewerId:i.viewerId}}async getConversation(e){let i=await u.redditAPIPlugins.NewModmail.GetConversation({...e,markRead:!!e.markRead},s(this,G));return{participantSubreddit:i.participantSubreddit,conversation:y(this,Y,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async getSubreddits(){let e=u.redditAPIPlugins.NewModmail,{subreddits:t}=await e.Subreddits({},s(this,G));return t}async createConversation(e){let i=await u.redditAPIPlugins.NewModmail.CreateConversation({body:e.body,isAuthorHidden:e.isAuthorHidden??!1,srName:e.subredditName,subject:e.subject,to:e.to?e.to:void 0},s(this,G));return{conversation:y(this,Y,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async reply(e){let i=await u.redditAPIPlugins.NewModmail.CreateConversationMessage({body:e.body,conversationId:e.conversationId,isAuthorHidden:e.isAuthorHidden??!1,isInternal:e.isInternal??!1},s(this,G));return{conversation:y(this,Y,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:{}}),user:i.user}}async highlightConversation(e){let i=await u.redditAPIPlugins.NewModmail.HighlightConversation({conversationId:e},s(this,G));return{conversation:y(this,Y,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:i.modActions})}}async unhighlightConversation(e){let i=await u.redditAPIPlugins.NewModmail.UnhighlightConversation({conversationId:e},s(this,G));return{conversation:y(this,Y,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:i.modActions})}}async archiveConversation(e){let i=await u.redditAPIPlugins.NewModmail.ArchiveConversation({conversationId:e},s(this,G));return{conversation:y(this,Y,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:i.modActions})}}async unarchiveConversation(e){let i=await u.redditAPIPlugins.NewModmail.UnarchiveConversation({conversationId:e},s(this,G));return{conversation:y(this,Y,se).call(this,{protoConversation:i.conversation,protoMessages:i.messages,protoModActions:i.modActions})}}async muteConversation(e){let i=await u.redditAPIPlugins.NewModmail.MuteConversation({conversationId:e.conversationId,numHours:e.numHours},s(this,G));return{conversation:y(this,Y,se).call(this,{protoConversation:i.conversations,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async unmuteConversation(e){let i=await u.redditAPIPlugins.NewModmail.UnmuteConversation({conversationId:e},s(this,G));return{conversation:y(this,Y,se).call(this,{protoConversation:i.conversations,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async readConversations(e){await u.redditAPIPlugins.NewModmail.Read({conversationIds:e.join(",")},s(this,G))}async unreadConversations(e){await u.redditAPIPlugins.NewModmail.Unread({conversationIds:e.join(",")},s(this,G))}async approveConversation(e){let i=await u.redditAPIPlugins.NewModmail.ApproveConversation({conversationId:e},s(this,G));return{conversation:y(this,Y,se).call(this,{protoConversation:i.conversations,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async disapproveConversation(e){let i=await u.redditAPIPlugins.NewModmail.DisapproveConversation({conversationId:e},s(this,G));return{conversation:y(this,Y,se).call(this,{protoConversation:i.conversations,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async tempBanConversation(e){let i=await u.redditAPIPlugins.NewModmail.TempBan({...e},s(this,G));return{conversation:y(this,Y,se).call(this,{protoConversation:i.conversations,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async unbanConversation(e){let i=await u.redditAPIPlugins.NewModmail.Unban({conversationId:e},s(this,G));return{conversation:y(this,Y,se).call(this,{protoConversation:i.conversations,protoMessages:i.messages,protoModActions:i.modActions}),user:i.user}}async getUnreadCount(){return await u.redditAPIPlugins.NewModmail.UnreadCount({},s(this,G))}async getUserConversations(e){return await u.redditAPIPlugins.NewModmail.UserConversations({conversationId:e},s(this,G))}};G=new WeakMap,Y=new WeakSet,se=function({protoConversation:e,protoMessages:t,protoModActions:i}){return{...e,state:uF[e.state],messages:y(this,El,qS).call(this,e,t),modActions:y(this,Rl,jS).call(this,e,i)}},El=new WeakSet,qS=function(e,t){let i={},n=e.objIds.filter(o=>o.key==="messages").map(({id:o})=>o);for(let o of n){let a=t[o];a&&(i[o]=a)}return i},Rl=new WeakSet,jS=function(e,t){let i={},n=e.objIds.filter(o=>o.key==="modActions").map(({id:o})=>o);for(let o of n){let a=t[o];a&&(i[o]={...a,actionType:mF[a.actionTypeId]})}return i};var mn,pn,Ol,Uo,Lo,Bo,Do,ip=class ip{constructor(e,t){d(this,mn,void 0);d(this,pn,void 0);d(this,Ol,void 0);d(this,Uo,void 0);d(this,Lo,void 0);d(this,Bo,void 0);d(this,Do,void 0);if(J(this),g(e.id,"PrivateMessage: Invalid data, no id"),g(e.name,"PrivateMessage: Invalid data, no name"),g(e.created,"PrivateMessage: Invalid data, no created date"),l(this,mn,ge(e.name)),e.author!=null)l(this,pn,{type:"user",username:e.author,id:e.authorFullname?re(e.authorFullname):void 0});else if(e.subreddit!=null)l(this,pn,{type:"subreddit",name:e.subreddit,id:e.subredditId?Re(e.subredditId):void 0});else throw new Error("PrivateMessage: Invalid data, no author or subreddit");l(this,Uo,e.body??""),l(this,Lo,e.bodyHtml??"");let i=new Date(0);i.setUTCSeconds(e.createdUtc),l(this,Bo,i),l(this,Ol,e.parentId?ge(e.parentId):void 0),l(this,Do,t)}static async getMessages(e,t){let i=u.redditAPIPlugins.PrivateMessages;return new H({...e,fetch:async n=>{let o=await i.MessageWhere({...n,where:e.type??"inbox"},t);return{after:o.data?.after,before:o.data?.before,children:o.data?.children?.map(a=>new ip(a.data,t)).filter(Boolean)||[]}}})}static async send({to:e,subject:t,text:i},n){await u.redditAPIPlugins.PrivateMessages.Compose({to:e,subject:t,text:i,fromSr:""},n)}static async sendAsSubreddit({to:e,fromSubredditName:t,subject:i,text:n},o){await u.redditAPIPlugins.PrivateMessages.Compose({to:e,fromSr:t,subject:i,text:n},o)}static async markAllAsRead(e){await u.redditAPIPlugins.PrivateMessages.ReadAllMessages({filterTypes:""},e)}get id(){return s(this,mn)}get from(){return s(this,pn)}get body(){return s(this,Uo)}get bodyHtml(){return s(this,Lo)}get created(){return s(this,Bo)}async markAsRead(){await u.redditAPIPlugins.PrivateMessages.ReadMessage({id:s(this,mn)},s(this,Do))}};mn=new WeakMap,pn=new WeakMap,Ol=new WeakMap,Uo=new WeakMap,Lo=new WeakMap,Bo=new WeakMap,Do=new WeakMap;var ur=ip;var Ey=(o=>(o.Reports="reports",o.Spam="spam",o.Modqueue="modqueue",o.Unmoderated="unmoderated",o.Edited="edited",o))(Ey||{}),fn,A,_o,No,qo,jo,Ho,Wo,Go,Vo,zo,gn,T,it=class it{constructor(e,t){d(this,fn,void 0);d(this,A,void 0);d(this,_o,void 0);d(this,No,void 0);d(this,qo,void 0);d(this,jo,void 0);d(this,Ho,void 0);d(this,Wo,void 0);d(this,Go,void 0);d(this,Vo,void 0);d(this,zo,void 0);d(this,gn,void 0);d(this,T,void 0);J(this),g(e.id,"Subreddit id is missing or undefined"),g(e.displayName,"Subreddit name is missing or undefined"),l(this,fn,Re(`t5_${e.id}`)),l(this,A,e.displayName),g(e.createdUtc,"Subreddit is missing created date");let i=new Date(0);i.setUTCSeconds(e.createdUtc),l(this,_o,i),l(this,No,pF(e.subredditType)),l(this,qo,e.title),l(this,jo,e.description),g(e.lang,"Subreddit is missing language"),l(this,Ho,e.lang),l(this,Wo,e.subscribers??0),l(this,Go,e.activeUserCount??0),l(this,Vo,e.over18??!1),l(this,gn,e.url??""),l(this,zo,{acceptFollowers:e.acceptFollowers??!1,allOriginalContent:e.allOriginalContent??!1,allowChatPostCreation:e.allowChatPostCreation??!1,allowDiscovery:e.allowDiscovery??!1,allowGalleries:e.allowGalleries??!1,allowImages:e.allowImages??!1,allowPolls:e.allowPolls??!1,allowPredictionContributors:e.allowPredictionContributors??!1,allowPredictions:e.allowPredictions??!1,allowPredictionsTournament:e.allowPredictionsTournament??!1,allowTalks:e.allowTalks??!1,allowVideoGifs:e.allowVideogifs??!1,allowVideos:e.allowVideos??!1,chatPostEnabled:e.isChatPostFeatureEnabled??!1,collectionsEnabled:e.collectionsEnabled??!1,crosspostable:e.isCrosspostableSubreddit??!1,emojisEnabled:e.emojisEnabled??!1,eventPostsEnabled:e.eventPostsEnabled??!1,linkFlairEnabled:e.linkFlairEnabled??!1,originalContentTagEnabled:e.originalContentTagEnabled??!1,restrictCommenting:e.restrictCommenting??!1,restrictPosting:e.restrictPosting??!1,shouldArchivePosts:e.shouldArchivePosts??!1,spoilersEnabled:e.spoilersEnabled??!1,wikiEnabled:e.wikiEnabled??!1,allowedPostType:fF(e.submissionType),allowedMediaInComments:(e.allowedMediaInComments??[]).map(gF),bannerBackgroundColor:e.bannerBackgroundColor,bannerBackgroundImage:e.bannerBackgroundImage,bannerImage:e.bannerImg,communityIcon:e.communityIcon,headerTitle:e.headerTitle,mobileBannerImage:e.mobileBannerImage,userFlairs:{enabled:e.userFlairEnabledInSr??!1,usersCanAssign:e.canAssignUserFlair??!1},postFlairs:{enabled:e.linkFlairEnabled??!1,usersCanAssign:e.canAssignLinkFlair??!1},url:new URL(s(this,gn),"https://www.reddit.com").toString()}),l(this,T,t)}get id(){return s(this,fn)}get name(){return s(this,A)}get createdAt(){return s(this,_o)}get type(){return s(this,No)}get title(){return s(this,qo)}get description(){return s(this,jo)}get language(){return s(this,Ho)}get numberOfSubscribers(){return s(this,Wo)}get numberOfActiveUsers(){return s(this,Go)}get nsfw(){return s(this,Vo)}get settings(){return s(this,zo)}get userFlairsEnabled(){return this.settings.userFlairs.enabled}get postFlairsEnabled(){return this.settings.postFlairs.enabled}get usersCanAssignUserFlairs(){return this.settings.userFlairs.usersCanAssign}get usersCanAssignPostFlairs(){return this.settings.postFlairs.usersCanAssign}get url(){return this.settings.url}get permalink(){return s(this,gn)}toJSON(){return{id:this.id,name:this.name,createdAt:this.createdAt,type:this.type,title:this.title,description:this.description,language:this.language,nsfw:this.nsfw,numberOfSubscribers:this.numberOfSubscribers,numberOfActiveUsers:this.numberOfActiveUsers,settings:this.settings}}async submitPost(e){let t={...e,subredditName:s(this,A)};return V.submit(t,s(this,T))}getControversialPosts(e={}){if(!s(this,A))throw new Error("subreddit missing displayName - it might not have been fetched");return V.getControversialPosts({...e,subredditName:s(this,A)},s(this,T))}getTopPosts(e={}){if(!s(this,A))throw new Error("subreddit missing displayName - it might not have been fetched");return V.getTopPosts({...e,subredditName:s(this,A)},s(this,T))}getApprovedUsers(e={}){return x.getSubredditUsersByType({type:"contributors",subredditName:s(this,A),...e},s(this,T))}approveUser(e){return x.createRelationship({username:e,subredditName:s(this,A),type:"contributor"},s(this,T))}removeUser(e){return x.removeRelationship({username:e,subredditName:s(this,A),type:"contributor"},s(this,T))}getWikiContributors(e={}){return x.getSubredditUsersByType({type:"wikicontributors",subredditName:s(this,A),...e},s(this,T))}addWikiContributor(e){return x.createRelationship({username:e,subredditName:s(this,A),type:"wikicontributor"},s(this,T))}removeWikiContributor(e){return x.removeRelationship({username:e,subredditName:s(this,A),type:"wikicontributor"},s(this,T))}getBannedUsers(e={}){return x.getSubredditUsersByType({type:"banned",subredditName:s(this,A),...e},s(this,T))}banUser(e){return x.createRelationship({username:e.username,subredditName:s(this,A),type:"banned",banReason:e.reason,banMessage:e.message,note:e.note,duration:e.duration},s(this,T))}unbanUser(e){return x.removeRelationship({username:e,subredditName:s(this,A),type:"banned"},s(this,T))}getBannedWikiContributors(e={}){return x.getSubredditUsersByType({type:"wikibanned",subredditName:s(this,A),...e},s(this,T))}banWikiContributor(e){return x.createRelationship({username:e.username,subredditName:s(this,A),type:"wikibanned",banReason:e.reason,note:e.note,duration:e.duration},s(this,T))}unbanWikiContributor(e){return x.removeRelationship({username:e,subredditName:s(this,A),type:"wikibanned"},s(this,T))}getModerators(e={}){return x.getSubredditUsersByType({type:"moderators",subredditName:s(this,A),...e},s(this,T))}inviteModerator(e,t){return x.createRelationship({type:"moderator_invite",subredditName:s(this,A),username:e,permissions:t??[]},s(this,T))}revokeModeratorInvite(e){return x.removeRelationship({username:e,subredditName:s(this,A),type:"moderator_invite"},s(this,T))}removeModerator(e){return x.removeRelationship({type:"moderator",subredditName:s(this,A),username:e},s(this,T))}setModeratorPermissions(e,t){return x.setModeratorPermissions(e,s(this,A),t,s(this,T))}getMutedUsers(e={}){return x.getSubredditUsersByType({type:"muted",subredditName:s(this,A),...e},s(this,T))}muteUser(e,t){return x.createRelationship({username:e,subredditName:s(this,A),type:"muted",note:t},s(this,T))}unmuteUser(e){return x.removeRelationship({username:e,subredditName:s(this,A),type:"muted"},s(this,T))}getModerationLog(e){return Ed({subredditName:s(this,A),...e},s(this,T))}getUserFlairTemplates(){return ae.getUserFlairTemplates(s(this,A),s(this,T))}getPostFlairTemplates(){return ae.getPostFlairTemplates(s(this,A),s(this,T))}createPostFlairTemplate(e){return ae.createPostFlairTemplate({subredditName:s(this,A),...e},s(this,T))}createUserFlairTemplate(e){return ae.createUserFlairTemplate({subredditName:s(this,A),...e},s(this,T))}async getUserFlair(e){if(e?.usernames!==void 0)return{users:await Promise.all(e.usernames.map(async i=>{let n=await Ue.getUserFlairBySubreddit({subreddit:s(this,A),name:i},s(this,T));return Js(n.users[0])}))};{let t=await Ue.getUserFlairBySubreddit({...e,subreddit:s(this,A)},s(this,T));return{next:t.next,prev:t.prev,users:t.users.map(i=>Js(i))}}}getModQueue(e={type:"all"}){return it.aboutLocation({...e,location:"modqueue",subreddit:s(this,A)},s(this,T))}getReports(e={type:"all"}){return it.aboutLocation({...e,location:"reports",subreddit:s(this,A)},s(this,T))}getSpam(e={type:"all"}){return it.aboutLocation({...e,location:"spam",subreddit:s(this,A)},s(this,T))}getUnmoderated(e={type:"all"}){return it.aboutLocation({...e,location:"unmoderated",subreddit:s(this,A)},s(this,T))}getEdited(e={type:"all"}){return it.aboutLocation({...e,location:"edited",subreddit:s(this,A)},s(this,T))}static aboutLocation(e,t){let i=u.redditAPIPlugins.Moderation,n;switch(e.type){case"post":n="links";break;case"comment":n="comments";break;default:n=void 0}return new H({...e,fetch:async o=>{let a=await i.AboutLocation({...o,...e,only:n},t);return HS(a,t)}})}getCommentsAndPostsByIds(e){let t=u.redditAPIPlugins.LinksAndComments;return new H({fetch:async()=>{let i=await t.Info({thingIds:e,subreddits:[s(this,fn)]},s(this,T));return HS(i,s(this,T))}})}static async addRemovalReason(e,t,i,n){return(await u.redditAPIPlugins.Subreddits.SubredditAddRemovalReason({title:t,message:i,subreddit:e},n)).id}static async getRemovalReasons(e,t){let n=await u.redditAPIPlugins.Subreddits.SubredditGetRemovalReasons({subreddit:e},t);return n.order.map(o=>({...n.data[o]}))}static async getFromMetadata(e){g(e);let t=e?.[L.Subreddit]?.values[0];return g(t),it.getById(Re(t),e)}static async getById(e,t){let o=(await u.redditAPIPlugins.LinksAndComments.Info({thingIds:[e],subreddits:[]},t)).data?.children[0]?.data?.displayName;return g(o),it.getByName(o,t)}static async getByName(e,t){let n=await u.redditAPIPlugins.Subreddits.SubredditAbout({subreddit:e},t);if(!n?.data)throw new Error("not found");return new it(n.data,t)}};fn=new WeakMap,A=new WeakMap,_o=new WeakMap,No=new WeakMap,qo=new WeakMap,jo=new WeakMap,Ho=new WeakMap,Wo=new WeakMap,Go=new WeakMap,Vo=new WeakMap,zo=new WeakMap,gn=new WeakMap,T=new WeakMap;var he=it;async function Ry(r,e){let t="GetSubredditLeaderboard",i="18ead70c46b6446d45ecd8b679b16d9a929a933d6ef25d8262a459cb18b72848",o=(await jt.query(t,i,{id:r},e)).data?.subredditInfoById?.leaderboard;if(!o)throw new Error("subreddit leaderboard not found");if(!o.summary)throw new Error("subreddit leaderboard summary not found");return{id:o.id,summary:o.summary}}function pF(r){if(r==="public"||r==="private"||r==="restricted"||r==="employees_only"||r==="gold_restricted"||r==="archived")return r;throw new Error(`invalid subreddit type: ${r}`)}function fF(r){if(r==="any"||r==="link"||r==="self")return r;throw new Error(`invalid allowed post type: ${r}`)}function gF(r){if(r==="animated"||r==="giphy"||r==="static"||r==="expression")return r;throw new Error(`invalid comment media type: ${r}`)}function HS(r,e){let i=(r.data?.children??[]).map(a=>{let c=n(a);if(c!=null)return c;let p=o(a);return p??null}).filter(Boolean);return{after:r.data?.after,before:r.data?.before,children:i};function n(a){try{return new V(a.data,e)}catch{return null}}function o(a){try{return new X(a.data,e)}catch{return null}}}async function Oy(r,e){return WS("GetVaultContactByAddress","3e2f7966a5c120e64fd2795d06a46595c52d988185be98d3ed71c3f81ae80d2e",{provider:"ethereum",address:r},e)}async function Fy(r,e){return WS("GetVaultContactByUserId","a854ddc19d0e22c4f36ed917fdbd568f299f3571427e393aee5e2972080fffe9",{provider:"ethereum",userId:r},e)}async function WS(r,e,t,i){let o=(await jt.query(r,e,t,i))?.data?.vault?.contact;return{provider:o?.provider,userId:re(o?.userId),address:o?.address,createdAt:o?.createdAt,isActive:o?.isActive}}import{CommunityListWidget_CommunityData as hF,GetWidgetsResponse_WidgetItem as le}from"@devvit/protos";var Jo,$o,Ko,Xo,sp=class sp{constructor(e,t,i){d(this,Jo,void 0);d(this,$o,void 0);d(this,Ko,void 0);d(this,Xo,void 0);J(this),l(this,Jo,e.id),l(this,$o,e.shortName),l(this,Ko,t),l(this,Xo,i)}get id(){return s(this,Jo)}get name(){return s(this,$o)}get subredditName(){return s(this,Ko)}toJSON(){return{id:this.id,name:this.name,subredditName:this.subredditName}}delete(){return sp.delete(this.subredditName,this.id,s(this,Xo))}static async getWidgets(e,t){let n=await u.redditAPIPlugins.Widgets.GetWidgets({subreddit:e},t);g(n.layout,"Failed to load widgets for subreddit");let o=n.items,a=[];for(let c of n.layout.sidebar?.order??[]){let p=o[c];switch(p?.kind){case"image":a.push(new Fl(p,e,t));break;case"calendar":a.push(new Ml(p,e,t));break;case"textarea":a.push(new Ul(p,e,t));break;case"button":a.push(new Ll(p,e,t));break;case"community-list":a.push(new Bl(p,e,t));break;case"post-flair":a.push(new Dl(p,e,t));break;case"custom":a.push(new _l(p,e,t));break;case"subreddit-rules":{let f=await u.redditAPIPlugins.Subreddits.SubredditAboutRules({subreddit:e},t);a.push(new np(f,p,e,t));break}default:throw new Error(`Unknown widget type: ${p.kind}`)}}return a}static async delete(e,t,i){await u.redditAPIPlugins.Widgets.DeleteWidget({subreddit:e,id:t},i)}static async reorder(e,t,i){await u.redditAPIPlugins.Widgets.OrderWidgets({subreddit:e,order:t},i)}static async add(e,t){switch(e?.type){case"image":return Fl.create(e,t);case"calendar":return Ml.create(e,t);case"textarea":return Ul.create(e,t);case"button":return Ll.create(e,t);case"community-list":return Bl.create(e,t);case"post-flair":return Dl.create(e,t);case"custom":return _l.create(e,t);default:throw new Error("Unknown widget type")}}};Jo=new WeakMap,$o=new WeakMap,Ko=new WeakMap,Xo=new WeakMap;var ie=sp,Zo,Nl=class Nl extends ie{constructor(t,i,n){super(t,i,n);d(this,Zo,void 0);l(this,Zo,t.data.map(o=>(g(o.url,"Image widget data is missing url"),g(o.height,"Image widget data is missing height"),g(o.width,"Image widget data is missing width"),g(o.linkUrl,"Image widget data is missing linkUrl"),{url:o.url,height:o.height,width:o.width,linkUrl:o.linkUrl})))}get images(){return s(this,Zo)}toJSON(){return{...super.toJSON(),images:this.images}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddImageWidget(t,i);return new Nl(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdateImageWidget(t,i);return new Nl(le.fromJSON(o),t.subreddit,i)}};Zo=new WeakMap;var Fl=Nl,Yo,Qo,ea,ql=class ql extends ie{constructor(t,i,n){super(t,i,n);d(this,Yo,void 0);d(this,Qo,void 0);d(this,ea,void 0);g(t.googleCalendarId,"Calendar widget data is missing googleCalendarId"),g(t.configuration,"Calendar widget data is missing configuration"),g(t.styles,"Calendar widget data is missing styles"),l(this,Yo,t.googleCalendarId),l(this,Qo,t.configuration),l(this,ea,t.styles)}get googleCalendarId(){return s(this,Yo)}get configuration(){return s(this,Qo)}get styles(){return s(this,ea)}toJSON(){return{...super.toJSON(),googleCalendarId:this.googleCalendarId,configuration:this.configuration,styles:this.styles}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddCalendarWidget(t,i);return new ql(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdateCalendarWidget(t,i);return new ql(le.fromJSON(o),t.subreddit,i)}};Yo=new WeakMap,Qo=new WeakMap,ea=new WeakMap;var Ml=ql,ta,ra,jl=class jl extends ie{constructor(t,i,n){super(t,i,n);d(this,ta,void 0);d(this,ra,void 0);g(t.text,"Textarea widget data is missing text"),g(t.styles,"Textarea widget data is missing styles"),l(this,ta,t.text),l(this,ra,t.styles)}get text(){return s(this,ta)}get styles(){return s(this,ra)}toJSON(){return{...super.toJSON(),text:this.text,styles:this.styles}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddTextAreaWidget(t,i);return new jl(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdateTextAreaWidget(t,i);return new jl(le.fromJSON(o),t.subreddit,i)}};ta=new WeakMap,ra=new WeakMap;var Ul=jl,ia,na,sa,Hl=class Hl extends ie{constructor(t,i,n){super(t,i,n);d(this,ia,void 0);d(this,na,void 0);d(this,sa,void 0);g(t.styles,"Button widget data is missing styles"),l(this,ia,t.buttons),l(this,na,t.description??""),l(this,sa,t.styles)}get buttons(){return s(this,ia)}get description(){return s(this,na)}get styles(){return s(this,sa)}toJSON(){return{...super.toJSON(),buttons:this.buttons,description:this.description,styles:this.styles}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddButtonWidget(t,i);return new Hl(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdateButtonWidget(t,i);return new Hl(le.fromJSON(o),t.subreddit,i)}};ia=new WeakMap,na=new WeakMap,sa=new WeakMap;var Ll=Hl,oa,aa,Wl=class Wl extends ie{constructor(t,i,n){super(t,i,n);d(this,oa,void 0);d(this,aa,void 0);l(this,oa,t.data.map(o=>hF.fromJSON(o))),g(t.styles,"Community list widget data is missing styles"),l(this,aa,t.styles)}get communities(){return s(this,oa)}get styles(){return s(this,aa)}toJSON(){return{...super.toJSON(),communities:this.communities,styles:this.styles}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddCommunityListWidget(t,i);return new Wl(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdateCommunityListWidget(t,i);return new Wl(le.fromJSON(o),t.subreddit,i)}};oa=new WeakMap,aa=new WeakMap;var Bl=Wl,da,la,ua,Gl=class Gl extends ie{constructor(t,i,n){super(t,i,n);d(this,da,void 0);d(this,la,void 0);d(this,ua,void 0);if(g(t.styles,"Post flair widget data is missing styles"),l(this,da,t.styles),l(this,la,t.order.map(o=>t.templates[o])),!(t.display&&t.display==="list"||t.display==="cloud"))throw new Error("Post flair widget data is missing display type");l(this,ua,t.display)}get styles(){return s(this,da)}get templates(){return s(this,la)}get display(){return s(this,ua)}toJSON(){return{...super.toJSON(),styles:this.styles,templates:this.templates,display:this.display}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddPostFlairWidget(t,i);return new Gl(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdatePostFlairWidget(t,i);return new Gl(le.fromJSON(o),t.subreddit,i)}};da=new WeakMap,la=new WeakMap,ua=new WeakMap;var Dl=Gl,ca,ma,pa,fa,ga,Vl=class Vl extends ie{constructor(t,i,n){super(t,i,n);d(this,ca,void 0);d(this,ma,void 0);d(this,pa,void 0);d(this,fa,void 0);d(this,ga,void 0);g(t.stylesheetUrl,"Custom widget data is missing stylesheetUrl"),g(t.height,"Custom widget data is missing height"),g(t.css,"Custom widget data is missing css"),l(this,ca,t.imageData??[]),l(this,ma,t.text??""),l(this,pa,t.stylesheetUrl),l(this,fa,t.height),l(this,ga,t.css)}get images(){return s(this,ca)}get text(){return s(this,ma)}get stylesheetUrl(){return s(this,pa)}get height(){return s(this,fa)}get css(){return s(this,ga)}toJSON(){return{...super.toJSON(),images:this.images,text:this.text,stylesheetUrl:this.stylesheetUrl,height:this.height,css:this.css}}static async create(t,i){let o=await u.redditAPIPlugins.Widgets.AddCustomWidget(t,i);return new Vl(le.fromJSON(o),t.subreddit,i)}static async update(t,i){let o=await u.redditAPIPlugins.Widgets.UpdateCustomWidget(t,i);return new Vl(le.fromJSON(o),t.subreddit,i)}};ca=new WeakMap,ma=new WeakMap,pa=new WeakMap,fa=new WeakMap,ga=new WeakMap;var _l=Vl,ha,np=class extends ie{constructor(t,i,n,o){super(i,n,o);d(this,ha,void 0);let a=t.rules.map(({description:c,priority:p,shortName:f,violationReason:v})=>(g(c,"Subreddit rule is missing description"),g(p,"Subreddit rule is missing priority"),g(f,"Subreddit rule is missing shortName"),g(v,"Subreddit rule is missing violationReason"),{description:c,priority:p,shortName:f,violationReason:v}));l(this,ha,a)}get rules(){return s(this,ha)}toJSON(){return{...super.toJSON(),rules:this.rules}}};ha=new WeakMap;var vF=(i=>(i[i.SUBREDDIT_PERMISSIONS=0]="SUBREDDIT_PERMISSIONS",i[i.APPROVED_CONTRIBUTORS_ONLY=1]="APPROVED_CONTRIBUTORS_ONLY",i[i.MODS_ONLY=2]="MODS_ONLY",i))(vF||{}),ke,Se,hn,vn,yn,bn,kn,Ke,qe=class qe{constructor(e,t,i,n){d(this,ke,void 0);d(this,Se,void 0);d(this,hn,void 0);d(this,vn,void 0);d(this,yn,void 0);d(this,bn,void 0);d(this,kn,void 0);d(this,Ke,void 0);J(this),l(this,ke,e),l(this,Se,t),l(this,hn,i.contentMd),l(this,vn,i.revisionId),l(this,yn,new Date(i.revisionDate)),l(this,bn,i.reason??""),g(i.revisionBy?.data,"Wiki page author details are missing"),l(this,kn,new x(i.revisionBy.data,n)),l(this,Ke,n)}get name(){return s(this,ke)}get subredditName(){return s(this,Se)}get content(){return s(this,hn)}get revisionId(){return s(this,vn)}get revisionDate(){return s(this,yn)}get revisionReason(){return s(this,bn)}get revisionAuthor(){return s(this,kn)}toJSON(){return{name:s(this,ke),subredditName:s(this,Se),content:s(this,hn),revisionId:s(this,vn),revisionDate:s(this,yn),revisionReason:s(this,bn),revisionAuthor:s(this,kn).toJSON()}}async update(e,t){return qe.updatePage({subredditName:s(this,Se),page:s(this,ke),content:e,reason:t},s(this,Ke))}async getRevisions(e){return qe.getPageRevisions({subredditName:s(this,Se),page:s(this,ke),...e},s(this,Ke))}async revertTo(e){return qe.revertPage(s(this,Se),s(this,ke),e,s(this,Ke))}async getSettings(){return qe.getPageSettings(s(this,Se),s(this,ke),s(this,Ke))}async updateSettings(e){return qe.updatePageSettings({subredditName:s(this,Se),page:s(this,ke),listed:e.listed,permLevel:e.permLevel},s(this,Ke))}async addEditor(e){return qe.addEditor(s(this,Se),s(this,ke),e,s(this,Ke))}async removeEditor(e){return qe.removeEditor(s(this,Se),s(this,ke),e,s(this,Ke))}static async getPage(e,t,i){let o=await u.redditAPIPlugins.Wiki.GetWikiPage({subreddit:e,page:t},i);return g(o.data,"Failed to get wiki page"),new qe(t,e,o.data,i)}static async getPages(e,t){return(await u.redditAPIPlugins.Wiki.GetWikiPages({subreddit:e},t)).data||[]}static async createPage(e,t){return qe.updatePage(e,t)}static async updatePage(e,t){return await u.redditAPIPlugins.Wiki.EditWikiPage({subreddit:e.subredditName,page:e.page,content:e.content,reason:e.reason??""},t),qe.getPage(e.subredditName,e.page,t)}static getPageRevisions(e,t){let i=u.redditAPIPlugins.Wiki;return new H({hasMore:!0,after:e.after,limit:e.limit,pageSize:e.pageSize,async fetch(n){let o=await i.GetWikiPageRevisions({subreddit:e.subredditName,page:e.page,limit:n.limit,after:n.after,before:n.before},t);return yF(o,t)}})}static async revertPage(e,t,i,n){await u.redditAPIPlugins.Wiki.RevertWikiPage({subreddit:e,page:t,revision:i},n)}static async getPageSettings(e,t,i){let o=await u.redditAPIPlugins.Wiki.GetWikiPageSettings({subreddit:e,page:t},i);return g(o.data,"Failed to get wiki page settings"),new zl(o.data,i)}static async updatePageSettings(e,t){let n=await u.redditAPIPlugins.Wiki.UpdateWikiPageSettings({subreddit:e.subredditName,page:e.page,listed:e.listed?"on":"",permlevel:e.permLevel},t);return g(n.data,"Failed to update wiki page settings"),new zl(n.data,t)}static async addEditor(e,t,i,n){await u.redditAPIPlugins.Wiki.AllowEditor({act:"add",subreddit:e,page:t,username:i},n)}static async removeEditor(e,t,i,n){await u.redditAPIPlugins.Wiki.AllowEditor({act:"del",subreddit:e,page:t,username:i},n)}};ke=new WeakMap,Se=new WeakMap,hn=new WeakMap,vn=new WeakMap,yn=new WeakMap,bn=new WeakMap,kn=new WeakMap,Ke=new WeakMap;var ve=qe,Sn,Pn,Cn,wn,xn,In,op=class{constructor(e,t){d(this,Sn,void 0);d(this,Pn,void 0);d(this,Cn,void 0);d(this,wn,void 0);d(this,xn,void 0);d(this,In,void 0);l(this,Sn,e.id),l(this,Pn,e.page),l(this,Cn,new Date(e.timestamp)),g(e.author?.data,"Wiki page revision author details are missing"),l(this,wn,new x(e.author.data,t)),l(this,xn,e.reason??""),l(this,In,e.revisionHidden??!1)}get id(){return s(this,Sn)}get page(){return s(this,Pn)}get date(){return s(this,Cn)}get author(){return s(this,wn)}get reason(){return s(this,xn)}get hidden(){return s(this,In)}toJSON(){return{id:s(this,Sn),page:s(this,Pn),date:s(this,Cn),author:s(this,wn).toJSON(),reason:s(this,xn),hidden:s(this,In)}}};Sn=new WeakMap,Pn=new WeakMap,Cn=new WeakMap,wn=new WeakMap,xn=new WeakMap,In=new WeakMap;var An,Tn,En,zl=class{constructor(e,t){d(this,An,void 0);d(this,Tn,void 0);d(this,En,void 0);l(this,An,e.listed),l(this,Tn,e.permLevel),l(this,En,e.editors.map(i=>(g(i.data,"Wiki page editor details are missing"),new x(i.data,t))))}get listed(){return s(this,An)}get permLevel(){return s(this,Tn)}get editors(){return s(this,En)}toJSON(){return{listed:s(this,An),permLevel:s(this,Tn),editors:s(this,En).map(e=>e.toJSON())}}};An=new WeakMap,Tn=new WeakMap,En=new WeakMap;function yF(r,e){return g(r.data?.children,"Wiki page revision listing is missing children"),{children:r.data.children.map(i=>new op(i,e)),before:r.data.before,after:r.data.after}}var bF=(t=>(t.Gallery="GALLERY",t.Timeline="TIMELINE",t))(bF||{});function kF(r){return r==="GALLERY"?"GALLERY":"TIMELINE"}var je,Pe,ya,Rn,On,ba,ka,Sa,Pa,vt,Ca,wa,Fn,va=class va{constructor(e,t){d(this,je,void 0);d(this,Pe,void 0);d(this,ya,void 0);d(this,Rn,void 0);d(this,On,void 0);d(this,ba,void 0);d(this,ka,void 0);d(this,Sa,void 0);d(this,Pa,void 0);d(this,vt,void 0);d(this,Ca,void 0);d(this,wa,void 0);d(this,Fn,void 0);g(e.collectionId,"Collection Id is missing or undefined"),g(e.subredditId,"Subreddit Id is missing or undefined"),g(e.title,"Collection title is missing or undefined"),g(e.authorId,"Collection author's id is missing or undefined"),g(e.authorName,"Collection author's id is missing or undefined"),g(e.createdAtUtc,"Collection create timestamp is missing"),g(e.lastUpdateUtc,"Collection last updated timestamp is missing"),l(this,je,t),l(this,Pe,e.collectionId),l(this,ya,e.subredditId),l(this,Rn,e.title),l(this,On,e.description||""),l(this,ba,e.authorId),l(this,ka,e.authorName),l(this,Sa,e.permalink),l(this,Pa,e.primaryLinkId),l(this,vt,e.linkIds||[]),l(this,Fn,kF(e.displayLayout)),l(this,Ca,e.createdAtUtc),l(this,wa,e.lastUpdateUtc),J(this)}get id(){return s(this,Pe)}get subredditId(){return s(this,ya)}get title(){return s(this,Rn)}get description(){return s(this,On)}get authorId(){return s(this,ba)}get authorName(){return s(this,ka)}get permalink(){return s(this,Sa)}get primaryLinkId(){return s(this,Pa)}get linkIds(){return s(this,vt)}get createdAtUtc(){return s(this,Ca)}get lastUpdateUtc(){return s(this,wa)}get displayLayout(){return s(this,Fn)}static async getCollectionById(e,t){let n=await u.redditAPIPlugins.PostCollections.Collection(e,t);return new va(n,t)}static async create(e,t){let n=await u.redditAPIPlugins.PostCollections.Create({srFullname:e.subredditId,title:e.title,description:e.description,displayLayout:e.displayLayout},t);return new va(n,t)}static async getCollectionsForSubreddit(e,t){return(await u.redditapiv2Plugin.GetSubredditCollections({srFullname:e.subredditId},t)).collections.map(n=>new va(n,t))}async addPost(e){await u.redditAPIPlugins.PostCollections.AddPost({collectionId:s(this,Pe),linkFullname:e},s(this,je)),s(this,vt).push(e)}async removePost(e){await u.redditAPIPlugins.PostCollections.RemovePost({collectionId:s(this,Pe),linkFullname:e},s(this,je)),l(this,vt,s(this,vt).filter(i=>i!==e))}async delete(){await u.redditAPIPlugins.PostCollections.Delete({collectionId:s(this,Pe)},s(this,je))}async follow(e){await u.redditAPIPlugins.PostCollections.Follow({collectionId:s(this,Pe),follow:e},s(this,je))}async reorder(e){await u.redditAPIPlugins.PostCollections.Reorder({collectionId:s(this,Pe),linkIds:e.join(",")},s(this,je)),l(this,vt,e)}async updateTitle(e){await u.redditAPIPlugins.PostCollections.UpdateTitle({collectionId:s(this,Pe),title:e},s(this,je)),l(this,Rn,e)}async updateDescription(e){await u.redditAPIPlugins.PostCollections.UpdateDescription({collectionId:s(this,Pe),description:e},s(this,je)),l(this,On,e)}async updateLayout(e){await u.redditAPIPlugins.PostCollections.UpdateDisplayLayout({collectionId:s(this,Pe),displayLayout:e},s(this,je)),l(this,Fn,e)}};je=new WeakMap,Pe=new WeakMap,ya=new WeakMap,Rn=new WeakMap,On=new WeakMap,ba=new WeakMap,ka=new WeakMap,Sa=new WeakMap,Pa=new WeakMap,vt=new WeakMap,Ca=new WeakMap,wa=new WeakMap,Fn=new WeakMap;var di=va;var SF=["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"],PF=["border-image","border-image-source","behavior","expression","list-style-image","cursor","content"],CF=["onload","onerror","onclick","onmouseover"];function wF(r){return/xmlns=["']http:\/\/www\.w3\.org\/2000\/svg["']/.test(r)?r:r.replace(/<svg\b/,'<svg xmlns="http://www.w3.org/2000/svg"')}function GS(r){if(r){if(!r.trim().startsWith("<svg")){console.log("The provided string is not a valid SVG.");return}try{let e=new RegExp(`<\\s*(${SF.join("|")})\\b`,"gi"),t=new RegExp(`(${PF.join("|")})\\s*:\\s*url\\s*\\((['"]?)(.*?)\\2\\)`,"gi"),i=new RegExp(`(${CF.join("|")})\\s*(=\\s*(['"]?)(.*?)\\3)?`,"gi");r=r.trim().replace(/\s+/g," "),r=wF(r);let n=r.match(e)||[],o=r.match(t)||[],a=r.match(i)||[],c=!1;return n.length>0&&(c=!0,console.warn(`Disallowed elements detected in SVG: ${n.map(p=>p.replace("<","")).join(", ")}`)),o.length>0&&(c=!0,console.warn(`Disallowed styles detected in SVG: ${o.map(p=>p.split(":")[0]).join(", ")}`)),a.length>0&&(c=!0,console.warn(`Disallowed attributes detected in SVG: ${a.map(p=>p.split("=")[0]).join(", ")}`)),c?void 0:r}catch{return}}}function fH(r,...e){let t="";return r.forEach((i,n)=>{t+=i;let o=e[n];o!==void 0&&(t+=`${o}`)}),t=GS(t),t===void 0?"":`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(t)}`}var VS="ServerCallRequired";var zS=Dr(Qd(),1);var nt,yt,xa,Mn,Ia,Br,ap=class{constructor(e,t,i){d(this,nt,void 0);d(this,yt,void 0);d(this,xa,void 0);d(this,Mn,void 0);d(this,Ia,void 0);d(this,Br,void 0);l(this,nt,!!i.context.devvitContext.debug.useAsync),s(this,nt)&&console.debug("[useAsync] v1",t),this.state={data:null,load_state:"initial",error:null,depends:null},l(this,yt,i.hookId),l(this,xa,e),l(this,Mn,i.invalidate),l(this,Ia,i.context),l(this,Br,t.depends??null),(t.enabled??!0)||(this.state.load_state="disabled")}onStateLoaded(){if(this.state.load_state!=="disabled"&&(s(this,nt)&&console.debug("[useAsync] async onLoad ",s(this,yt),this.state),s(this,nt)&&console.debug("[useAsync] async onLoad have ",s(this,Br),"and",this.state.depends),!(0,zS.default)(s(this,Br),this.state.depends)||this.state.load_state==="initial")){this.state.load_state="loading",this.state.depends=s(this,Br),s(this,Mn).call(this);let e={hook:s(this,yt),async:!0,asyncRequest:{requestId:s(this,yt)+"-"+JSON.stringify(this.state.depends)}};s(this,nt)&&console.debug("[useAsync] onLoad requeue"),s(this,Ia).addToRequeueEvents(e)}}async onUIEvent(e,t){if(e.asyncRequest){let i={requestId:e.asyncRequest.requestId};try{i.data={value:await s(this,xa).call(this)}}catch(o){if(o instanceof Error){if(o.message===VS)throw o;i.error={message:o.message,details:o.stack??""}}else i.error={message:"Unknown error",details:String(o)}}let n={asyncResponse:i,hook:s(this,yt)};s(this,nt)&&console.debug("[useAsync] onReq requeue"),t.addToRequeueEvents(n)}else if(e.asyncResponse){let i=s(this,yt)+"-"+JSON.stringify(this.state.depends);e.asyncResponse.requestId===i?(this.state={...this.state,data:e.asyncResponse.data?.value,error:e.asyncResponse.error??null,load_state:e.asyncResponse.error?"error":"loaded"},s(this,Mn).call(this)):s(this,nt)&&console.debug("[useAsync] onResp skip, stale event")}else throw new Error("Unknown event type")}};nt=new WeakMap,yt=new WeakMap,xa=new WeakMap,Mn=new WeakMap,Ia=new WeakMap,Br=new WeakMap;function xF(r,e={}){let t=De({namespace:"useAsync"},i=>new ap(r,e,i));return{data:t.state.data,error:t.state.error,loading:t.state.load_state==="loading"}}export{zU as ALL_ICON_NAMES,Ey as AboutLocations,Ll as ButtonWidget,Ml as CalendarWidget,bF as CollectionDisplayLayout,X as Comment,Bl as CommunityListWidget,_l as CustomWidget,u as Devvit,Ue as Flair,ae as FlairTemplate,$O as FlairType,Ct as Hook,Fl as ImageWidget,H as Listing,cF as ModMailActionType,lF as ModMailConversationState,Rd as ModMailService,Me as ModNote,V as Post,di as PostCollection,Dl as PostFlairWidget,ur as PrivateMessage,Ws as RichTextBuilder,zc as SettingScope,he as Subreddit,np as SubredditRulesWidget,Ul as TextAreaWidget,x as User,ie as Widget,ve as WikiPage,vF as WikiPagePermissionLevel,op as WikiPageRevision,zl as WikiPageSettings,Js as convertUserFlairProtoToAPI,Ed as getModerationLog,Ry as getSubredditLeaderboard,Oy as getVaultByAddress,Fy as getVaultByUserId,fH as svg,xF as useAsync,MO as useAsyncState,Um as useChannel,Rm as useForm,Dm as useInterval,_m as useState};
6
6
  /*! Bundled license information:
7
7
 
8
8
  shallow-clone/index.js: