@devvit/ui-renderer 0.11.0-next-2024-09-30-a020f32f6.0 → 0.11.0-next-2024-10-01-9ce4a3b5c.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/webview.d.ts +2 -2
- package/client/webview.d.ts.map +1 -1
- package/client/webview.js +3 -3
- package/client/webview.js.map +1 -1
- package/devvit-custom-post-meta.min.json +4 -4
- package/devvit-custom-post.min.js +1 -1
- package/devvit-custom-post.min.js.map +3 -3
- package/devvit-surface-meta.min.json +4 -4
- package/devvit-surface.min.js +1 -1
- package/devvit-surface.min.js.map +3 -3
- package/package.json +9 -9
package/client/webview.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @param template provided by the client; should have {{location}}, {{app}}, and {{path}} fields
|
|
7
7
|
* @param subreddit the subreddit thing ID where the app is installed
|
|
8
|
-
* @param
|
|
8
|
+
* @param _version the app version currently running
|
|
9
9
|
* @param url the URL from the webview block configuration
|
|
10
10
|
*/
|
|
11
|
-
export declare function resolveWebviewUrl(template: string, subreddit: string | undefined,
|
|
11
|
+
export declare function resolveWebviewUrl(template: string, subreddit: string | undefined, _version: string, url: string): string;
|
|
12
12
|
//# sourceMappingURL=webview.d.ts.map
|
package/client/webview.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webview.d.ts","sourceRoot":"","sources":["../../library/src/client/webview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,
|
|
1
|
+
{"version":3,"file":"webview.d.ts","sourceRoot":"","sources":["../../library/src/client/webview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,MAAM,CAoBR"}
|
package/client/webview.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @param template provided by the client; should have {{location}}, {{app}}, and {{path}} fields
|
|
7
7
|
* @param subreddit the subreddit thing ID where the app is installed
|
|
8
|
-
* @param
|
|
8
|
+
* @param _version the app version currently running
|
|
9
9
|
* @param url the URL from the webview block configuration
|
|
10
10
|
*/
|
|
11
|
-
export function resolveWebviewUrl(template, subreddit,
|
|
11
|
+
export function resolveWebviewUrl(template, subreddit, _version, url) {
|
|
12
12
|
// input: 9b9cfb2e-d7d4-4b35-b6bc-cb8af11ee5e9/path.html
|
|
13
13
|
const segments = url.match(/([a-zA-Z0-9-]+)\/(.*)/) ?? [];
|
|
14
14
|
if (segments.length < 3) {
|
|
@@ -25,7 +25,7 @@ export function resolveWebviewUrl(template, subreddit, version, url) {
|
|
|
25
25
|
.replace('{{app}}', app)
|
|
26
26
|
.replace('{{path}}', path);
|
|
27
27
|
const newUrl = new URL(parsedTemplate);
|
|
28
|
-
newUrl.search += `v=${version}`;
|
|
28
|
+
// newUrl.search += `v=${version}`;
|
|
29
29
|
return newUrl.toString();
|
|
30
30
|
}
|
|
31
31
|
//# sourceMappingURL=webview.js.map
|
package/client/webview.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webview.js","sourceRoot":"","sources":["../../library/src/client/webview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAgB,EAChB,SAA6B,EAC7B,
|
|
1
|
+
{"version":3,"file":"webview.js","sourceRoot":"","sources":["../../library/src/client/webview.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAgB,EAChB,SAA6B,EAC7B,QAAgB,EAChB,GAAW;IAEX,wDAAwD;IACxD,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,uBAAuB,CAAC,IAAI,EAAE,CAAC;IAC1D,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,QAAQ,CAAC;IAChC,IAAI,CAAC,SAAS,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IACtD,0BAA0B;IAC1B,MAAM,cAAc,GAAG,QAAQ;SAC5B,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC;SACpC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAE7B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;IACvC,mCAAmC;IACnC,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -8700,7 +8700,7 @@
|
|
|
8700
8700
|
"format": "esm"
|
|
8701
8701
|
},
|
|
8702
8702
|
"library/src/client/webview.ts": {
|
|
8703
|
-
"bytes":
|
|
8703
|
+
"bytes": 1201,
|
|
8704
8704
|
"imports": [],
|
|
8705
8705
|
"format": "esm"
|
|
8706
8706
|
},
|
|
@@ -8816,7 +8816,7 @@
|
|
|
8816
8816
|
"imports": [],
|
|
8817
8817
|
"exports": [],
|
|
8818
8818
|
"inputs": {},
|
|
8819
|
-
"bytes":
|
|
8819
|
+
"bytes": 6409537
|
|
8820
8820
|
},
|
|
8821
8821
|
"dist/devvit-custom-post.min.js": {
|
|
8822
8822
|
"imports": [
|
|
@@ -9485,13 +9485,13 @@
|
|
|
9485
9485
|
"bytesInOutput": 4568
|
|
9486
9486
|
},
|
|
9487
9487
|
"library/src/client/webview.ts": {
|
|
9488
|
-
"bytesInOutput":
|
|
9488
|
+
"bytesInOutput": 256
|
|
9489
9489
|
},
|
|
9490
9490
|
"library/src/client/devvit-custom-post.ts": {
|
|
9491
9491
|
"bytesInOutput": 5476
|
|
9492
9492
|
}
|
|
9493
9493
|
},
|
|
9494
|
-
"bytes":
|
|
9494
|
+
"bytes": 1946575
|
|
9495
9495
|
}
|
|
9496
9496
|
}
|
|
9497
9497
|
}
|
|
@@ -620,7 +620,7 @@ button inline-flex`},cC=e=>{let{createElement:n}=Ze(),{attributes:i,selected:d,r
|
|
|
620
620
|
style="${d(t)}"
|
|
621
621
|
>
|
|
622
622
|
${r===le?"":r}
|
|
623
|
-
</div>`}else return r}var a2,u2,pc,Ca=class extends ft{constructor(){super(...arguments);Pe(this,a2,window.matchMedia("(prefers-color-scheme: dark)"));Pe(this,u2,()=>this.requestUpdate());Pe(this,pc,()=>({stackDirection:me.UNRECOGNIZED}))}static get styles(){return[rc]}connectedCallback(){super.connectedCallback(),$(this,a2)?.addEventListener("change",$(this,u2))}disconnectedCallback(){super.disconnectedCallback(),$(this,a2)?.removeEventListener("change",$(this,u2))}render(){if(this.block&&this.block.type===ve.BLOCK_ROOT){let i={...$(this,pc).call(this),...this.renderContext?.()??{}};return Ui`<div class="${fd(this.class)}">${v4(this.block,i)}</div>`}return Ui`${pC({creative:Ui`<slot name="empty-state-image"></slot>`,title:o4("Whoops!",{desc:"Header for message to display when rendering fails"}),description:o4("Something went wrong while attempting to display this content.",{desc:"Message for users to display when rendering fails"})})}`}};a2=new WeakMap,u2=new WeakMap,pc=new WeakMap,Je([yn({attribute:!1})],Ca.prototype,"block",2),Je([yn({attribute:!1})],Ca.prototype,"renderContext",2),Je([yn()],Ca.prototype,"class",2),Ca=Je([fC(),vu("devvit-blocks-renderer")],Ca);function cb(e,n,i){let{width:d,height:r}=e.contentRect,s=n.getComputedStyle(i).fontSize.split("px")[0],p=s?parseFloat(s)/16:1;return{width:Math.round(d),height:Math.round(r),scale:n.devicePixelRatio,fontScale:p}}var zt;(function(e){e.ENABLE_APP_LOGGING="enableAppLogging",e.ENABLE_DEBUG_LOGGING="enableDebugLogging",e.ENABLE_PLUGINS="enablePlugins",e.LOAD_BUNDLE="loadBundle",e.CALL="call",e.PLUGIN_RESPONSE="pluginResponse",e.QUIT="quit"})(zt||(zt={}));var xt;(function(e){e.READY="ready",e.PLUGINS_CONFIGURED="pluginsConfigured",e.BUNDLE_LOADED="bundleLoaded",e.BUNDLE_LOAD_FAILED="bundleLoadFailed",e.RETURN="return",e.ERROR="error",e.CIRCUIT_BREAKER="circuitBreaker",e.PLUGIN_CALL="pluginCall",e.UNHANDLED_REJECTION="unhandledRejection"})(xt||(xt={}));function m4(e){return e.hostname.split(".")[1]??e.hostname}function pb(e){return`${m4(e)}@${e.actor?.version} by ${e.actor?.owner}`}var ci=P(B(),1);function hb(){return{callState:void 0,connect:void 0}}var k4={$type:"devvit.cli.PlaytestProviderMessage",encode(e,n=ci.default.Writer.create()){return e.callState!==void 0&&R1.encode(e.callState,n.uint32(10).fork()).ldelim(),e.connect!==void 0&&N1.encode(e.connect,n.uint32(18).fork()).ldelim(),n},decode(e,n){let i=e instanceof ci.default.Reader?e:ci.default.Reader.create(e),d=n===void 0?i.len:i.pos+n,r=hb();for(;i.pos<d;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;r.callState=R1.decode(i,i.uint32());continue;case 2:if(t!==18)break;r.connect=N1.decode(i,i.uint32());continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return r},fromJSON(e){return{callState:hc(e.callState)?R1.fromJSON(e.callState):void 0,connect:hc(e.connect)?N1.fromJSON(e.connect):void 0}},toJSON(e){let n={};return e.callState!==void 0&&(n.callState=R1.toJSON(e.callState)),e.connect!==void 0&&(n.connect=N1.toJSON(e.connect)),n},create(e){return k4.fromPartial(e??{})},fromPartial(e){let n=hb();return n.callState=e.callState!==void 0&&e.callState!==null?R1.fromPartial(e.callState):void 0,n.connect=e.connect!==void 0&&e.connect!==null?N1.fromPartial(e.connect):void 0,n}};l.set(k4.$type,k4);function vb(){return{appInstalled:void 0}}var l2={$type:"devvit.cli.PlaytestSubscriberMessage",encode(e,n=ci.default.Writer.create()){return e.appInstalled!==void 0&&g1.encode(e.appInstalled,n.uint32(10).fork()).ldelim(),n},decode(e,n){let i=e instanceof ci.default.Reader?e:ci.default.Reader.create(e),d=n===void 0?i.len:i.pos+n,r=vb();for(;i.pos<d;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;r.appInstalled=g1.decode(i,i.uint32());continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return r},fromJSON(e){return{appInstalled:hc(e.appInstalled)?g1.fromJSON(e.appInstalled):void 0}},toJSON(e){let n={};return e.appInstalled!==void 0&&(n.appInstalled=g1.toJSON(e.appInstalled)),n},create(e){return l2.fromPartial(e??{})},fromPartial(e){let n=vb();return n.appInstalled=e.appInstalled!==void 0&&e.appInstalled!==null?g1.fromPartial(e.appInstalled):void 0,n}};l.set(l2.$type,l2);function mb(){return{}}var g1={$type:"devvit.cli.PlaytestAppInstalled",encode(e,n=ci.default.Writer.create()){return n},decode(e,n){let i=e instanceof ci.default.Reader?e:ci.default.Reader.create(e),d=n===void 0?i.len:i.pos+n,r=mb();for(;i.pos<d;){let t=i.uint32();switch(t>>>3){}if((t&7)===4||t===0)break;i.skipType(t&7)}return r},fromJSON(e){return{}},toJSON(e){return{}},create(e){return g1.fromPartial(e??{})},fromPartial(e){return mb()}};l.set(g1.$type,g1);function kb(){return{logs:[]}}var R1={$type:"devvit.cli.PlaytestCallState",encode(e,n=ci.default.Writer.create()){for(let i of e.logs)Mi.encode(i,n.uint32(10).fork()).ldelim();return n},decode(e,n){let i=e instanceof ci.default.Reader?e:ci.default.Reader.create(e),d=n===void 0?i.len:i.pos+n,r=kb();for(;i.pos<d;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;r.logs.push(Mi.decode(i,i.uint32()));continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return r},fromJSON(e){return{logs:globalThis.Array.isArray(e?.logs)?e.logs.map(n=>Mi.fromJSON(n)):[]}},toJSON(e){let n={};return e.logs?.length&&(n.logs=e.logs.map(i=>Mi.toJSON(i))),n},create(e){return R1.fromPartial(e??{})},fromPartial(e){let n=kb();return n.logs=e.logs?.map(i=>Mi.fromPartial(i))||[],n}};l.set(R1.$type,R1);function yb(){return{url:""}}var N1={$type:"devvit.cli.PlaytestConnect",encode(e,n=ci.default.Writer.create()){return e.url!==""&&n.uint32(10).string(e.url),n},decode(e,n){let i=e instanceof ci.default.Reader?e:ci.default.Reader.create(e),d=n===void 0?i.len:i.pos+n,r=yb();for(;i.pos<d;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;r.url=i.string();continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return r},fromJSON(e){return{url:hc(e.url)?globalThis.String(e.url):""}},toJSON(e){let n={};return e.url!==""&&(n.url=e.url),n},create(e){return N1.fromPartial(e??{})},fromPartial(e){let n=yb();return n.url=e.url??"",n}};l.set(N1.$type,N1);function hc(e){return e!=null}var y4="playtest",Sb="ws://localhost:5678";function wb(e){let n=S4();return n===""||n===e}function S4(){return globalThis.location?new URL(location.href).searchParams.get(y4)??void 0:void 0}var wn=function(e,n,i,d){if(i==="a"&&!d)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?e!==n||!d:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?d:i==="a"?d.call(e):d?d.value:n.get(e)},s2=function(e,n,i,d,r){if(d==="m")throw new TypeError("Private method is not writable");if(d==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return d==="a"?r.call(e,i):r?r.value=i:n.set(e,i),i},f2,Sn,w4,Ab,A4,C4,b4,T4,YR=15e3,vc=class{constructor(){f2.add(this),Sn.set(this,{type:"Init"}),A4.set(this,()=>{wn(this,Sn,"f").type==="Opened"&&this.onState?.("Closed"),s2(this,Sn,wn(this,f2,"m",Ab).call(this),"f")}),C4.set(this,n=>{let i=l2.fromJSON(JSON.parse(n.data));switch(!0){case i.appInstalled!=null:this.onState?.("Reloading");break}}),b4.set(this,()=>{if(wn(this,Sn,"f").type!=="Opening")throw Error(`invalid transition from ${wn(this,Sn,"f").type}`);this.onState?.("Opened"),s2(this,Sn,{sock:wn(this,Sn,"f").sock,type:"Opened"},"f"),this.send({connect:{url:location.href}})}),T4.set(this,()=>{s2(this,Sn,wn(this,f2,"m",w4).call(this),"f")})}close(){"timer"in wn(this,Sn,"f")&&clearTimeout(wn(this,Sn,"f").timer),"sock"in wn(this,Sn,"f")&&(wn(this,Sn,"f").sock.onopen=null,wn(this,Sn,"f").sock.onmessage=null,wn(this,Sn,"f").sock.onclose=null,wn(this,Sn,"f").sock.close()),s2(this,Sn,{type:"Init"},"f")}open(){wn(this,Sn,"f").type==="Init"&&s2(this,Sn,wn(this,f2,"m",w4).call(this),"f")}send(n){"sock"in wn(this,Sn,"f")?wn(this,Sn,"f").sock.send(JSON.stringify(n)):console.warn("devvit playtest message dropped",n)}};Sn=new WeakMap,A4=new WeakMap,C4=new WeakMap,b4=new WeakMap,T4=new WeakMap,f2=new WeakSet,w4=function(){let n=new WebSocket(Sb);return n.onclose=wn(this,A4,"f"),n.onmessage=wn(this,C4,"f"),n.onopen=wn(this,b4,"f"),{sock:n,type:"Opening"}},Ab=function(){return{timer:setTimeout(wn(this,T4,"f"),YR),type:"Retrying"}};var Zn=function(e,n,i,d,r){if(d==="m")throw new TypeError("Private method is not writable");if(d==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return d==="a"?r.call(e,i):r?r.value=i:n.set(e,i),i},ae=function(e,n,i,d){if(i==="a"&&!d)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?e!==n||!d:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?d:i==="a"?d.call(e):d?d.value:n.get(e)},kr,mc,Un,Su,kc,p2,Kt,od,wu,Cu,ad,g4,c2,yc,R4,Cb,Au,N4,x4,jR={debug:sn.DEBUG,error:sn.ERROR,info:sn.INFO,log:sn.DEBUG,trace:sn.DEBUG,warn:sn.WARN},Sc=class{constructor(n,i,d){kr.add(this),mc.set(this,void 0),Un.set(this,void 0),Su.set(this,!1),kc.set(this,0),p2.set(this,void 0),Kt.set(this,{}),od.set(this,void 0),wu.set(this,()=>{}),Cu.set(this,void 0),ad.set(this,void 0),g4.set(this,S4()),c2.set(this,!1),yc.set(this,void 0),R4.set(this,r=>{let t=r.data,[s]=t;switch(s){case xt.READY:{let[,p]=t;Zn(this,yc,p,"f"),ae(this,Cu,"f")?.plugins?ae(this,kr,"m",Cb).call(this):ae(this,kr,"m",N4).call(this);break}case xt.PLUGINS_CONFIGURED:ae(this,kr,"m",N4).call(this);break;case xt.BUNDLE_LOADED:{let[,p]=t;ae(this,kr,"m",Au).call(this,p),Zn(this,Su,!0,"f"),ae(this,od,"f")?.resolve({metrics:{init:ae(this,yc,"f")}}),Zn(this,od,void 0,"f");break}case xt.BUNDLE_LOAD_FAILED:{let[,,p,c]=t;ae(this,kr,"m",Au).call(this,c),ae(this,od,"f")?.reject(p),Zn(this,od,void 0,"f");break}case xt.RETURN:{let[,p,c,v]=t;ae(this,kr,"m",Au).call(this,v),ae(this,Kt,"f")[p]?.resolve(c),delete ae(this,Kt,"f")[p];break}case xt.ERROR:{let[,p,c,v]=t;ae(this,kr,"m",Au).call(this,v),ae(this,Kt,"f")[p]?.reject(c),delete ae(this,Kt,"f")[p];break}case xt.CIRCUIT_BREAKER:{let[,p,c,v]=t;ae(this,Kt,"f")[p]?.reject(new Xf(c,v)),delete ae(this,Kt,"f")[p];break}case xt.PLUGIN_CALL:{let[,p,c,v,C,R]=t;ae(this,Cu,"f")?.callback(p,c,v,C,R);break}case xt.UNHANDLED_REJECTION:{let[,,p,c]=t;ae(this,kr,"m",Au).call(this,c),ae(this,wu,"f").call(this,"UnhandledRejection",p);break}}}),x4.set(this,r=>{switch(r){case"Opened":console.info("devvit playtest connected");break;case"Closed":console.info("devvit playtest disconnected");break;case"Reloading":{console.info("devvit playtest reloading"),ae(this,ad,"f")?.close();let t=new URL(location.href);t.searchParams.set(y4,ae(this,g4,"f")??""),location.assign(t),location.reload();break}}}),Zn(this,mc,n,"f"),i&&Zn(this,wu,i,"f"),d&&Zn(this,Cu,d,"f")}get ready(){return ae(this,Su,"f")}get runtimeDebugLogging(){return ae(this,c2,"f")}set runtimeDebugLogging(n){n!==ae(this,c2,"f")&&(Zn(this,c2,n,"f"),this.runtimeDebugLogging&&ae(this,Un,"f")?.postMessage([zt.ENABLE_DEBUG_LOGGING]))}async loadBundle(n){if(ae(this,Un,"f"))throw new Error("Bundle already loaded");let i=wb(m4(n));i&&(Zn(this,ad,new vc,"f"),ae(this,ad,"f").onState=ae(this,x4,"f")),ae(this,ad,"f")?.open();let d=new Worker(URL.createObjectURL(ae(this,mc,"f")),{name:`App: ${pb(n)}`,type:"module"});return d.onerror=r=>ae(this,wu,"f").call(this,"Error",r.error),d.onmessageerror=r=>ae(this,wu,"f").call(this,"MessageError",r.data),d.onmessage=ae(this,R4,"f"),Zn(this,Un,d,"f"),Zn(this,p2,n,"f"),this.runtimeDebugLogging&&ae(this,Un,"f").postMessage([zt.ENABLE_DEBUG_LOGGING]),i&&ae(this,Un,"f").postMessage([zt.ENABLE_APP_LOGGING]),new Promise((r,t)=>{Zn(this,od,{resolve:r,reject:t},"f")})}async call(n,i,d){var r;if(!ae(this,Su,"f")||!ae(this,Un,"f"))throw new Error("No bundle loaded");let t=Zn(this,kc,(r=ae(this,kc,"f"),++r),"f"),s=new Promise((p,c)=>{ae(this,Kt,"f")[t]={resolve:p,reject:c}});return ae(this,Un,"f").postMessage([zt.CALL,t,n,i,d,!1]),s}onPluginResponse(n,i){ae(this,Un,"f")?.postMessage([zt.PLUGIN_RESPONSE,n,i])}quit(){ae(this,ad,"f")?.close(),Zn(this,ad,void 0,"f"),Zn(this,Su,!1,"f"),ae(this,Un,"f")&&(ae(this,Un,"f").postMessage([zt.QUIT]),ae(this,Un,"f").onerror=null,ae(this,Un,"f").onmessageerror=null,ae(this,Un,"f").onmessage=null,ae(this,Un,"f").terminate()),Zn(this,Un,void 0,"f");for(let{reject:n}of Object.values(ae(this,Kt,"f")))n(Error("worker terminated"));Zn(this,Kt,{},"f"),ae(this,od,"f")?.reject(Error("worker terminated")),Zn(this,od,void 0,"f")}};mc=new WeakMap,Un=new WeakMap,Su=new WeakMap,kc=new WeakMap,p2=new WeakMap,Kt=new WeakMap,od=new WeakMap,wu=new WeakMap,Cu=new WeakMap,ad=new WeakMap,g4=new WeakMap,c2=new WeakMap,yc=new WeakMap,R4=new WeakMap,x4=new WeakMap,kr=new WeakSet,Cb=function(){ae(this,Un,"f")?.postMessage([zt.ENABLE_PLUGINS,ae(this,Cu,"f")?.plugins??[]])},Au=function(n){if(!n.length)return;let i=new Date,d={logs:n.map(r=>({severity:jR[r.method],message:r.args.join(" "),tags:[],timestamp:i}))};ae(this,ad,"f")?.send({callState:d})},N4=function(){ae(this,Un,"f")?.postMessage([zt.LOAD_BUNDLE,ae(this,p2,"f")]),Zn(this,p2,void 0,"f")};var Mb=P(Tb(),1);var v2=class extends Error{constructor(n){super(n),this.name="TimeoutError"}},E4=class extends Error{constructor(n){super(),this.name="AbortError",this.message=n}},gb=e=>globalThis.DOMException===void 0?new E4(e):new DOMException(e),Rb=e=>{let n=e.reason===void 0?gb("This operation was aborted."):e.reason;return n instanceof Error?n:gb(n)};function P4(e,n,i,d){let r,t=new Promise((s,p)=>{if(typeof n!="number"||Math.sign(n)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(n===Number.POSITIVE_INFINITY){s(e);return}if(d={customTimers:{setTimeout,clearTimeout},...d},d.signal){let{signal:c}=d;c.aborted&&p(Rb(c)),c.addEventListener("abort",()=>{p(Rb(c))})}r=d.customTimers.setTimeout.call(void 0,()=>{if(typeof i=="function"){try{s(i())}catch(C){p(C)}return}let c=typeof i=="string"?i:`Promise timed out after ${n} milliseconds`,v=i instanceof Error?i:new v2(c);typeof e.cancel=="function"&&e.cancel(),p(v)},n),(async()=>{try{s(await e)}catch(c){p(c)}finally{d.customTimers.clearTimeout.call(void 0,r)}})()});return t.clear=()=>{clearTimeout(r),r=void 0},t}function O4(e,n,i){let d=0,r=e.length;for(;r>0;){let t=Math.trunc(r/2),s=d+t;i(e[s],n)<=0?(d=++s,r-=t+1):r=t}return d}var ba=function(e,n,i,d){if(i==="a"&&!d)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?e!==n||!d:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?d:i==="a"?d.call(e):d?d.value:n.get(e)},ud,m2=class{constructor(){ud.set(this,[])}enqueue(n,i){i={priority:0,...i};let d={priority:i.priority,run:n};if(this.size&&ba(this,ud,"f")[this.size-1].priority>=i.priority){ba(this,ud,"f").push(d);return}let r=O4(ba(this,ud,"f"),d,(t,s)=>s.priority-t.priority);ba(this,ud,"f").splice(r,0,d)}dequeue(){let n=ba(this,ud,"f").shift();return n?.run}filter(n){return ba(this,ud,"f").filter(i=>i.priority===n.priority).map(i=>i.run)}get size(){return ba(this,ud,"f").length}};ud=new WeakMap;var rn=function(e,n,i,d,r){if(d==="m")throw new TypeError("Private method is not writable");if(d==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return d==="a"?r.call(e,i):r?r.value=i:n.set(e,i),i},ne=function(e,n,i,d){if(i==="a"&&!d)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?e!==n||!d:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?d:i==="a"?d.call(e):d?d.value:n.get(e)},An,y2,S2,I1,Rc,w2,Ac,Xt,k2,lt,Cc,st,A2,x1,bc,Nb,xb,Pb,Ib,Eb,Tc,M4,B4,Nc,Ob,gc,xc=class extends Error{},C2=class extends Mb.default{constructor(n){var i,d,r,t;if(super(),An.add(this),y2.set(this,void 0),S2.set(this,void 0),I1.set(this,0),Rc.set(this,void 0),w2.set(this,void 0),Ac.set(this,0),Xt.set(this,void 0),k2.set(this,void 0),lt.set(this,void 0),Cc.set(this,void 0),st.set(this,0),A2.set(this,void 0),x1.set(this,void 0),bc.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:m2,...n},!(typeof n.intervalCap=="number"&&n.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(d=(i=n.intervalCap)===null||i===void 0?void 0:i.toString())!==null&&d!==void 0?d:""}\` (${typeof n.intervalCap})`);if(n.interval===void 0||!(Number.isFinite(n.interval)&&n.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(t=(r=n.interval)===null||r===void 0?void 0:r.toString())!==null&&t!==void 0?t:""}\` (${typeof n.interval})`);rn(this,y2,n.carryoverConcurrencyCount,"f"),rn(this,S2,n.intervalCap===Number.POSITIVE_INFINITY||n.interval===0,"f"),rn(this,Rc,n.intervalCap,"f"),rn(this,w2,n.interval,"f"),rn(this,lt,new n.queueClass,"f"),rn(this,Cc,n.queueClass,"f"),this.concurrency=n.concurrency,this.timeout=n.timeout,rn(this,bc,n.throwOnTimeout===!0,"f"),rn(this,x1,n.autoStart===!1,"f")}get concurrency(){return ne(this,A2,"f")}set concurrency(n){if(!(typeof n=="number"&&n>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${n}\` (${typeof n})`);rn(this,A2,n,"f"),ne(this,An,"m",Nc).call(this)}async add(n,i={}){return i={timeout:this.timeout,throwOnTimeout:ne(this,bc,"f"),...i},new Promise((d,r)=>{ne(this,lt,"f").enqueue(async()=>{var t,s,p;rn(this,st,(s=ne(this,st,"f"),s++,s),"f"),rn(this,I1,(p=ne(this,I1,"f"),p++,p),"f");try{if(!((t=i.signal)===null||t===void 0)&&t.aborted)throw new xc("The task was aborted.");let c=n({signal:i.signal});i.timeout&&(c=P4(Promise.resolve(c),i.timeout)),i.signal&&(c=Promise.race([c,ne(this,An,"m",Ob).call(this,i.signal)]));let v=await c;d(v),this.emit("completed",v)}catch(c){if(c instanceof v2&&!i.throwOnTimeout){d();return}r(c),this.emit("error",c)}finally{ne(this,An,"m",Pb).call(this)}},i),this.emit("add"),ne(this,An,"m",Tc).call(this)})}async addAll(n,i){return Promise.all(n.map(async d=>this.add(d,i)))}start(){return ne(this,x1,"f")?(rn(this,x1,!1,"f"),ne(this,An,"m",Nc).call(this),this):this}pause(){rn(this,x1,!0,"f")}clear(){rn(this,lt,new(ne(this,Cc,"f")),"f")}async onEmpty(){ne(this,lt,"f").size!==0&&await ne(this,An,"m",gc).call(this,"empty")}async onSizeLessThan(n){ne(this,lt,"f").size<n||await ne(this,An,"m",gc).call(this,"next",()=>ne(this,lt,"f").size<n)}async onIdle(){ne(this,st,"f")===0&&ne(this,lt,"f").size===0||await ne(this,An,"m",gc).call(this,"idle")}get size(){return ne(this,lt,"f").size}sizeBy(n){return ne(this,lt,"f").filter(n).length}get pending(){return ne(this,st,"f")}get isPaused(){return ne(this,x1,"f")}};y2=new WeakMap,S2=new WeakMap,I1=new WeakMap,Rc=new WeakMap,w2=new WeakMap,Ac=new WeakMap,Xt=new WeakMap,k2=new WeakMap,lt=new WeakMap,Cc=new WeakMap,st=new WeakMap,A2=new WeakMap,x1=new WeakMap,bc=new WeakMap,An=new WeakSet,Nb=function(){return ne(this,S2,"f")||ne(this,I1,"f")<ne(this,Rc,"f")},xb=function(){return ne(this,st,"f")<ne(this,A2,"f")},Pb=function(){var n;rn(this,st,(n=ne(this,st,"f"),n--,n),"f"),ne(this,An,"m",Tc).call(this),this.emit("next")},Ib=function(){ne(this,An,"m",B4).call(this),ne(this,An,"m",M4).call(this),rn(this,k2,void 0,"f")},Eb=function(){let n=Date.now();if(ne(this,Xt,"f")===void 0){let i=ne(this,Ac,"f")-n;if(i<0)rn(this,I1,ne(this,y2,"f")?ne(this,st,"f"):0,"f");else return ne(this,k2,"f")===void 0&&rn(this,k2,setTimeout(()=>{ne(this,An,"m",Ib).call(this)},i),"f"),!0}return!1},Tc=function(){if(ne(this,lt,"f").size===0)return ne(this,Xt,"f")&&clearInterval(ne(this,Xt,"f")),rn(this,Xt,void 0,"f"),this.emit("empty"),ne(this,st,"f")===0&&this.emit("idle"),!1;if(!ne(this,x1,"f")){let n=!ne(this,An,"a",Eb);if(ne(this,An,"a",Nb)&&ne(this,An,"a",xb)){let i=ne(this,lt,"f").dequeue();return i?(this.emit("active"),i(),n&&ne(this,An,"m",M4).call(this),!0):!1}}return!1},M4=function(){ne(this,S2,"f")||ne(this,Xt,"f")!==void 0||(rn(this,Xt,setInterval(()=>{ne(this,An,"m",B4).call(this)},ne(this,w2,"f")),"f"),rn(this,Ac,Date.now()+ne(this,w2,"f"),"f"))},B4=function(){ne(this,I1,"f")===0&&ne(this,st,"f")===0&&ne(this,Xt,"f")&&(clearInterval(ne(this,Xt,"f")),rn(this,Xt,void 0,"f")),rn(this,I1,ne(this,y2,"f")?ne(this,st,"f"):0,"f"),ne(this,An,"m",Nc).call(this)},Nc=function(){for(;ne(this,An,"m",Tc).call(this););},Ob=async function(n){return new Promise((i,d)=>{n.addEventListener("abort",()=>{d(new xc("The task was aborted."))},{once:!0})})},gc=async function(n,i){return new Promise(d=>{let r=()=>{i&&!i()||(this.off(n,r),d())};this.on(n,r)})};function Bb(){var r,t;let e=new URL(globalThis.location?location.href:"file://");if(globalThis.devvit??(globalThis.devvit={}),globalThis.devvit.debug)return;(r=globalThis.devvit).debug??(r.debug={});let n={blocks:void 0,emitSnapshots:void 0,emitState:void 0,realtime:void 0,runtime:void 0,surface:void 0,useAsync:void 0,payments:void 0,bootstrap:void 0},i={};for(let s in n)i[s.toLowerCase()]=s;let d=[...e.searchParams].find(([s])=>s.toLowerCase()==="devvitdebug")?.[1];if(d!=null){d===""&&(d=Object.keys(n).filter(s=>s!=="emitSnapshots"&&s!=="emitState").join());for(let s of d.split(",")??[]){let[p,c]=s.split("=");p&&(p.toLowerCase()in i?p=i[p.toLowerCase()]:console.warn(`[devvit] unknown devvitdebug parameter "${p}"`),(t=globalThis.devvit.debug)[p]??(t[p]=c||"true"),console.info(`[devvit] set devvitdebug ${p}=${globalThis.devvit.debug[p]}`))}}}var iN={width:288,height:320,scale:1,fontScale:1},tN=["showToast","showForm","navigateToUrl"];Bb();var E1,P1,O1,Tu,gu,M1,b2,Ru,ld,In,L4,Ic,bu,Pc,F4,Lb,Ec=class{constructor(){Pe(this,In);Pe(this,E1);this.dimensions=iN;Pe(this,P1);Pe(this,O1,{});Pe(this,Tu,new C2({concurrency:1}));Pe(this,gu,!1);Pe(this,M1);Pe(this,b2,!1);Pe(this,Ru,!1);Pe(this,ld,[]);Pe(this,Pc,(n,i,d,r,t)=>{this.onPluginCall?.(n,i,d,r,t),i===ea.fullName&&d===ea.methods.send.name&&this._local?.onPluginResponse(n,{error:void 0,success:!0,value:{}})})}get appState(){return $(this,O1).__postData={thingId:this.postID,config:this.postConfig},$(this,O1)}async load(n){this.unload(),En(this,P1,n);try{return await this._local?.loadBundle(n)}catch(i){Pn(this,In,bu).call(this,n,"Error",i)}}set meta(n){let i={...n},d=[];for(let[r,t]of Object.entries(devvit?.debug??{}))d.push(`${r}=${t}`);d.length&&(i[Qf.Debug]={values:d}),En(this,E1,i)}queueEvent(n){let i=$(this,P1);n.async?Pn(this,In,F4).call(this,i,n):$(this,Tu).add(()=>Pn(this,In,F4).call(this,i,n))}queueRenderPost(n,i,d){let r=$(this,P1);$(this,Tu).add(()=>Pn(this,In,Lb).call(this,r,n,i,d))}get rendered(){return $(this,gu)}get pausedEffects(){return $(this,ld)}resetAppState(){En(this,gu,!1),En(this,O1,{})}set runtimeDebugLogging(n){En(this,b2,n),this._local&&(this._local.runtimeDebugLogging=n)}setLocalSrc(n){this.unload(),this._local=n?new Sc(n,(i,d)=>this.onError?.(i,d),{callback:$(this,Pc),plugins:[]}):void 0,this._local&&(this._local.runtimeDebugLogging=$(this,b2))}unload(){En(this,P1,void 0),$(this,M1)!=null&&clearTimeout($(this,M1)),$(this,Tu).clear(),this._local?.quit()}togglePause(n){if(!n&&$(this,ld).length>0){let i=$(this,ld);En(this,ld,[]),i.forEach(({renderType:d,effects:r})=>{Pn(this,In,Ic).call(this,d,r)})}En(this,Ru,n)}};E1=new WeakMap,P1=new WeakMap,O1=new WeakMap,Tu=new WeakMap,gu=new WeakMap,M1=new WeakMap,b2=new WeakMap,Ru=new WeakMap,ld=new WeakMap,In=new WeakSet,L4=function(n){devvit?.debug.runtime&&(ma(n)?console.debug("[runtime] try remote call; circuit break"):console.debug("[runtime] try remote call; local failed",n),this.remote||console.debug("[runtime] call failed; no remote"))},Ic=function(n,i){for(let d of i)d.rerenderUi?($(this,M1)!=null&&clearTimeout($(this,M1)),En(this,M1,setTimeout(()=>{this.queueRenderPost(un.RENDER_EFFECT_EVENT,"rerender-effect",{})},(d.rerenderUi.delaySeconds??0)*1e3))):(n!==un.RENDER_USER_ACTION||tN.some(r=>d[r]))&&this.onUserAction?.(d)},bu=function(n,i,d){n&&$(this,P1)!==n||this.onError?.(i,d)},Pc=new WeakMap,F4=async function(n,i){let d,r={event:i,state:this.appState};if(this._local?.ready&&i.scope!==ni.REMOTE)try{d=await this._local.call("HandleUIEvent",r,$(this,E1))}catch(t){(!ma(t)||!this.remote)&&Pn(this,In,bu).call(this,n,"Error",t),Pn(this,In,L4).call(this,t)}else devvit?.debug.runtime&&console.debug(`[runtime] try remote call; ${i.scope===ni.REMOTE?"local call forbidden":"local not ready"}`);if(!d&&i.scope!==ni.LOCAL)try{d=await this.remote?.HandleUIEvent(r,$(this,E1))}catch(t){Pn(this,In,bu).call(this,n,"Error",t),devvit?.debug.runtime&&console.debug("[runtime] remote call failed",t)}if(d){i.async||En(this,O1,d.state??{});let t=i.realtimeEvent?un.RENDER_EFFECT_EVENT:un.RENDER_USER_ACTION;$(this,Ru)?$(this,ld).push({renderType:t,effects:d.effects}):Pn(this,In,Ic).call(this,t,d.effects)}devvit?.debug.runtime&&(!this._local?.ready&&!this.remote?console.debug("[runtime] call failed; no runtimes"):!this._local?.ready&&i.scope===ni.LOCAL?console.debug("[runtime] call failed; local event but local runtime is unavailable"):!this.remote&&i.scope===ni.REMOTE&&console.debug("[runtime] call failed; remote event but remote runtime is unavailable"))},Lb=async function(n,i,d,r){let t={blocks:{type:i,id:d,data:r},state:this.appState,dimensions:this.dimensions},s;if(this._local?.ready)try{s=await this._local.call("RenderPost",t,$(this,E1))}catch(p){ma(p)&&p.response&&(s=p.response),(!ma(p)||!this.remote)&&Pn(this,In,bu).call(this,n,"Error",p),Pn(this,In,L4).call(this,p)}else devvit?.debug.runtime&&console.debug("[runtime] try remote call; local not ready");if(!s)try{s=await this.remote?.RenderPost(t,$(this,E1))}catch(p){Pn(this,In,bu).call(this,n,"Error",p),devvit?.debug.runtime&&console.debug("[runtime] remote call failed",p)}s&&(En(this,gu,!0),s.state&&En(this,O1,s.state),this.onRenderPost?.(t,s),$(this,Ru)?$(this,ld).push({renderType:t.blocks.type,effects:s.effects}):Pn(this,In,Ic).call(this,t.blocks.type,s.effects)),devvit?.debug.runtime&&!this._local?.ready&&!this.remote&&console.debug("[runtime] call failed; no runtimes")};function Fb(e,n,i,d){let r=d.match(/([a-zA-Z0-9-]+)\/(.*)/)??[];if(r.length<3)return"";let[t,s,p]=r;if(!n||!s||!p)return"";let c=n.replace(/^t[0-9]_/,""),v=e.replace("{{location}}",c).replace("{{app}}",s).replace("{{path}}",p),C=new URL(v);return C.search+=`v=${i}`,C.toString()}var dn,Ta,Nu,xu,g2,ga,T2,Oc,Mc,Bc,Lc,Fc,_n=class extends ft{constructor(){super();Pe(this,ga);this.runtimeDebugLogging=!1;this.useExperimentalBlocks=!1;this.webviewUrlTemplate="";this.disableAssetSandbox=!1;Pe(this,dn,new Ec);Pe(this,Ta);Pe(this,Nu);Pe(this,xu);Pe(this,g2,"");Pe(this,Oc,()=>({experimental:this.useExperimentalBlocks,resolveWebviewUrl:i=>this.disableAssetSandbox?i:Fb(this.webviewUrlTemplate,this.metadata?.[Qf.Subreddit]?.values?.[0],$(this,g2),i),onAction:i=>$(this,dn).queueRenderPost(un.RENDER_USER_ACTION,i.id,i.data??{}),stackDirection:me.UNRECOGNIZED,disableAssetSandbox:this.disableAssetSandbox}));Pe(this,Mc,(i,d)=>{ma(d)||console.error(d),Pn(this,ga,T2).call(this,"devvit-ui-error",{err:d,type:i})});Pe(this,Bc,(i,d,r,t,s)=>{d===ea.fullName&&r===ea.methods.send.name&&((devvit?.debug.surface||devvit?.debug.realtime)&&console.debug("[realtime][custom] realtime plugin call",t),Pn(this,ga,T2).call(this,"devvit-realtime-send",{event:t}))});Pe(this,Lc,(i,d)=>{var r,t;this.renderResponse=d,this.renderResponse?.blocks?.ui&&(this._rootBlock=this.renderResponse.blocks.ui,$(this,Ta)?((r=this._rootBlock).config??(r.config={}),(t=this._rootBlock.config).rootConfig??(t.rootConfig=pr.fromPartial({})),this._rootBlock.config.rootConfig.height=$(this,Ta)):En(this,Ta,this._rootBlock.config?.rootConfig?.height||h4))});Pe(this,Fc,i=>{devvit?.debug.surface&&console.debug("[custom] effect",i),Pn(this,ga,T2).call(this,"devvit-ui-effect",{effect:i,onEvent:d=>$(this,dn).queueEvent(d),metadata:this.metadata})});devvit?.debug.surface&&console.debug("[custom] constructed"),$(this,dn).onError=$(this,Mc),$(this,dn).onPluginCall=$(this,Bc),$(this,dn).onRenderPost=$(this,Lc),$(this,dn).onUserAction=$(this,Fc)}static get styles(){return[rc]}async connectedCallback(){super.connectedCallback(),devvit?.debug.surface&&console.debug("[custom] connected"),En(this,Nu,new ResizeObserver(oC(i=>{i.length!==0&&(this.dimensions=cb(i[0],window,document.body),devvit?.debug.surface&&console.debug("[custom] resized",this.dimensions))},600))),$(this,Nu).observe(this,{box:"content-box"}),En(this,xu,new IntersectionObserver(i=>{i.forEach(d=>{devvit?.debug.surface&&console.debug(`[custom] ${d.isIntersecting?"":"not "}intersecting`),$(this,dn).togglePause(!d.isIntersecting)})})),$(this,xu).observe(this)}disconnectedCallback(){devvit?.debug.surface&&console.debug("[custom] disconnected"),$(this,dn).unload(),$(this,Nu)?.unobserve(this),$(this,xu)?.unobserve(this),super.disconnectedCallback()}render(){return this.renderResponse?Ui`<div class="relative">
|
|
623
|
+
</div>`}else return r}var a2,u2,pc,Ca=class extends ft{constructor(){super(...arguments);Pe(this,a2,window.matchMedia("(prefers-color-scheme: dark)"));Pe(this,u2,()=>this.requestUpdate());Pe(this,pc,()=>({stackDirection:me.UNRECOGNIZED}))}static get styles(){return[rc]}connectedCallback(){super.connectedCallback(),$(this,a2)?.addEventListener("change",$(this,u2))}disconnectedCallback(){super.disconnectedCallback(),$(this,a2)?.removeEventListener("change",$(this,u2))}render(){if(this.block&&this.block.type===ve.BLOCK_ROOT){let i={...$(this,pc).call(this),...this.renderContext?.()??{}};return Ui`<div class="${fd(this.class)}">${v4(this.block,i)}</div>`}return Ui`${pC({creative:Ui`<slot name="empty-state-image"></slot>`,title:o4("Whoops!",{desc:"Header for message to display when rendering fails"}),description:o4("Something went wrong while attempting to display this content.",{desc:"Message for users to display when rendering fails"})})}`}};a2=new WeakMap,u2=new WeakMap,pc=new WeakMap,Je([yn({attribute:!1})],Ca.prototype,"block",2),Je([yn({attribute:!1})],Ca.prototype,"renderContext",2),Je([yn()],Ca.prototype,"class",2),Ca=Je([fC(),vu("devvit-blocks-renderer")],Ca);function cb(e,n,i){let{width:d,height:r}=e.contentRect,s=n.getComputedStyle(i).fontSize.split("px")[0],p=s?parseFloat(s)/16:1;return{width:Math.round(d),height:Math.round(r),scale:n.devicePixelRatio,fontScale:p}}var zt;(function(e){e.ENABLE_APP_LOGGING="enableAppLogging",e.ENABLE_DEBUG_LOGGING="enableDebugLogging",e.ENABLE_PLUGINS="enablePlugins",e.LOAD_BUNDLE="loadBundle",e.CALL="call",e.PLUGIN_RESPONSE="pluginResponse",e.QUIT="quit"})(zt||(zt={}));var xt;(function(e){e.READY="ready",e.PLUGINS_CONFIGURED="pluginsConfigured",e.BUNDLE_LOADED="bundleLoaded",e.BUNDLE_LOAD_FAILED="bundleLoadFailed",e.RETURN="return",e.ERROR="error",e.CIRCUIT_BREAKER="circuitBreaker",e.PLUGIN_CALL="pluginCall",e.UNHANDLED_REJECTION="unhandledRejection"})(xt||(xt={}));function m4(e){return e.hostname.split(".")[1]??e.hostname}function pb(e){return`${m4(e)}@${e.actor?.version} by ${e.actor?.owner}`}var ci=P(B(),1);function hb(){return{callState:void 0,connect:void 0}}var k4={$type:"devvit.cli.PlaytestProviderMessage",encode(e,n=ci.default.Writer.create()){return e.callState!==void 0&&R1.encode(e.callState,n.uint32(10).fork()).ldelim(),e.connect!==void 0&&N1.encode(e.connect,n.uint32(18).fork()).ldelim(),n},decode(e,n){let i=e instanceof ci.default.Reader?e:ci.default.Reader.create(e),d=n===void 0?i.len:i.pos+n,r=hb();for(;i.pos<d;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;r.callState=R1.decode(i,i.uint32());continue;case 2:if(t!==18)break;r.connect=N1.decode(i,i.uint32());continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return r},fromJSON(e){return{callState:hc(e.callState)?R1.fromJSON(e.callState):void 0,connect:hc(e.connect)?N1.fromJSON(e.connect):void 0}},toJSON(e){let n={};return e.callState!==void 0&&(n.callState=R1.toJSON(e.callState)),e.connect!==void 0&&(n.connect=N1.toJSON(e.connect)),n},create(e){return k4.fromPartial(e??{})},fromPartial(e){let n=hb();return n.callState=e.callState!==void 0&&e.callState!==null?R1.fromPartial(e.callState):void 0,n.connect=e.connect!==void 0&&e.connect!==null?N1.fromPartial(e.connect):void 0,n}};l.set(k4.$type,k4);function vb(){return{appInstalled:void 0}}var l2={$type:"devvit.cli.PlaytestSubscriberMessage",encode(e,n=ci.default.Writer.create()){return e.appInstalled!==void 0&&g1.encode(e.appInstalled,n.uint32(10).fork()).ldelim(),n},decode(e,n){let i=e instanceof ci.default.Reader?e:ci.default.Reader.create(e),d=n===void 0?i.len:i.pos+n,r=vb();for(;i.pos<d;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;r.appInstalled=g1.decode(i,i.uint32());continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return r},fromJSON(e){return{appInstalled:hc(e.appInstalled)?g1.fromJSON(e.appInstalled):void 0}},toJSON(e){let n={};return e.appInstalled!==void 0&&(n.appInstalled=g1.toJSON(e.appInstalled)),n},create(e){return l2.fromPartial(e??{})},fromPartial(e){let n=vb();return n.appInstalled=e.appInstalled!==void 0&&e.appInstalled!==null?g1.fromPartial(e.appInstalled):void 0,n}};l.set(l2.$type,l2);function mb(){return{}}var g1={$type:"devvit.cli.PlaytestAppInstalled",encode(e,n=ci.default.Writer.create()){return n},decode(e,n){let i=e instanceof ci.default.Reader?e:ci.default.Reader.create(e),d=n===void 0?i.len:i.pos+n,r=mb();for(;i.pos<d;){let t=i.uint32();switch(t>>>3){}if((t&7)===4||t===0)break;i.skipType(t&7)}return r},fromJSON(e){return{}},toJSON(e){return{}},create(e){return g1.fromPartial(e??{})},fromPartial(e){return mb()}};l.set(g1.$type,g1);function kb(){return{logs:[]}}var R1={$type:"devvit.cli.PlaytestCallState",encode(e,n=ci.default.Writer.create()){for(let i of e.logs)Mi.encode(i,n.uint32(10).fork()).ldelim();return n},decode(e,n){let i=e instanceof ci.default.Reader?e:ci.default.Reader.create(e),d=n===void 0?i.len:i.pos+n,r=kb();for(;i.pos<d;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;r.logs.push(Mi.decode(i,i.uint32()));continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return r},fromJSON(e){return{logs:globalThis.Array.isArray(e?.logs)?e.logs.map(n=>Mi.fromJSON(n)):[]}},toJSON(e){let n={};return e.logs?.length&&(n.logs=e.logs.map(i=>Mi.toJSON(i))),n},create(e){return R1.fromPartial(e??{})},fromPartial(e){let n=kb();return n.logs=e.logs?.map(i=>Mi.fromPartial(i))||[],n}};l.set(R1.$type,R1);function yb(){return{url:""}}var N1={$type:"devvit.cli.PlaytestConnect",encode(e,n=ci.default.Writer.create()){return e.url!==""&&n.uint32(10).string(e.url),n},decode(e,n){let i=e instanceof ci.default.Reader?e:ci.default.Reader.create(e),d=n===void 0?i.len:i.pos+n,r=yb();for(;i.pos<d;){let t=i.uint32();switch(t>>>3){case 1:if(t!==10)break;r.url=i.string();continue}if((t&7)===4||t===0)break;i.skipType(t&7)}return r},fromJSON(e){return{url:hc(e.url)?globalThis.String(e.url):""}},toJSON(e){let n={};return e.url!==""&&(n.url=e.url),n},create(e){return N1.fromPartial(e??{})},fromPartial(e){let n=yb();return n.url=e.url??"",n}};l.set(N1.$type,N1);function hc(e){return e!=null}var y4="playtest",Sb="ws://localhost:5678";function wb(e){let n=S4();return n===""||n===e}function S4(){return globalThis.location?new URL(location.href).searchParams.get(y4)??void 0:void 0}var wn=function(e,n,i,d){if(i==="a"&&!d)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?e!==n||!d:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?d:i==="a"?d.call(e):d?d.value:n.get(e)},s2=function(e,n,i,d,r){if(d==="m")throw new TypeError("Private method is not writable");if(d==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return d==="a"?r.call(e,i):r?r.value=i:n.set(e,i),i},f2,Sn,w4,Ab,A4,C4,b4,T4,YR=15e3,vc=class{constructor(){f2.add(this),Sn.set(this,{type:"Init"}),A4.set(this,()=>{wn(this,Sn,"f").type==="Opened"&&this.onState?.("Closed"),s2(this,Sn,wn(this,f2,"m",Ab).call(this),"f")}),C4.set(this,n=>{let i=l2.fromJSON(JSON.parse(n.data));switch(!0){case i.appInstalled!=null:this.onState?.("Reloading");break}}),b4.set(this,()=>{if(wn(this,Sn,"f").type!=="Opening")throw Error(`invalid transition from ${wn(this,Sn,"f").type}`);this.onState?.("Opened"),s2(this,Sn,{sock:wn(this,Sn,"f").sock,type:"Opened"},"f"),this.send({connect:{url:location.href}})}),T4.set(this,()=>{s2(this,Sn,wn(this,f2,"m",w4).call(this),"f")})}close(){"timer"in wn(this,Sn,"f")&&clearTimeout(wn(this,Sn,"f").timer),"sock"in wn(this,Sn,"f")&&(wn(this,Sn,"f").sock.onopen=null,wn(this,Sn,"f").sock.onmessage=null,wn(this,Sn,"f").sock.onclose=null,wn(this,Sn,"f").sock.close()),s2(this,Sn,{type:"Init"},"f")}open(){wn(this,Sn,"f").type==="Init"&&s2(this,Sn,wn(this,f2,"m",w4).call(this),"f")}send(n){"sock"in wn(this,Sn,"f")?wn(this,Sn,"f").sock.send(JSON.stringify(n)):console.warn("devvit playtest message dropped",n)}};Sn=new WeakMap,A4=new WeakMap,C4=new WeakMap,b4=new WeakMap,T4=new WeakMap,f2=new WeakSet,w4=function(){let n=new WebSocket(Sb);return n.onclose=wn(this,A4,"f"),n.onmessage=wn(this,C4,"f"),n.onopen=wn(this,b4,"f"),{sock:n,type:"Opening"}},Ab=function(){return{timer:setTimeout(wn(this,T4,"f"),YR),type:"Retrying"}};var Zn=function(e,n,i,d,r){if(d==="m")throw new TypeError("Private method is not writable");if(d==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return d==="a"?r.call(e,i):r?r.value=i:n.set(e,i),i},ae=function(e,n,i,d){if(i==="a"&&!d)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?e!==n||!d:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?d:i==="a"?d.call(e):d?d.value:n.get(e)},kr,mc,Un,Su,kc,p2,Kt,od,wu,Cu,ad,g4,c2,yc,R4,Cb,Au,N4,x4,jR={debug:sn.DEBUG,error:sn.ERROR,info:sn.INFO,log:sn.DEBUG,trace:sn.DEBUG,warn:sn.WARN},Sc=class{constructor(n,i,d){kr.add(this),mc.set(this,void 0),Un.set(this,void 0),Su.set(this,!1),kc.set(this,0),p2.set(this,void 0),Kt.set(this,{}),od.set(this,void 0),wu.set(this,()=>{}),Cu.set(this,void 0),ad.set(this,void 0),g4.set(this,S4()),c2.set(this,!1),yc.set(this,void 0),R4.set(this,r=>{let t=r.data,[s]=t;switch(s){case xt.READY:{let[,p]=t;Zn(this,yc,p,"f"),ae(this,Cu,"f")?.plugins?ae(this,kr,"m",Cb).call(this):ae(this,kr,"m",N4).call(this);break}case xt.PLUGINS_CONFIGURED:ae(this,kr,"m",N4).call(this);break;case xt.BUNDLE_LOADED:{let[,p]=t;ae(this,kr,"m",Au).call(this,p),Zn(this,Su,!0,"f"),ae(this,od,"f")?.resolve({metrics:{init:ae(this,yc,"f")}}),Zn(this,od,void 0,"f");break}case xt.BUNDLE_LOAD_FAILED:{let[,,p,c]=t;ae(this,kr,"m",Au).call(this,c),ae(this,od,"f")?.reject(p),Zn(this,od,void 0,"f");break}case xt.RETURN:{let[,p,c,v]=t;ae(this,kr,"m",Au).call(this,v),ae(this,Kt,"f")[p]?.resolve(c),delete ae(this,Kt,"f")[p];break}case xt.ERROR:{let[,p,c,v]=t;ae(this,kr,"m",Au).call(this,v),ae(this,Kt,"f")[p]?.reject(c),delete ae(this,Kt,"f")[p];break}case xt.CIRCUIT_BREAKER:{let[,p,c,v]=t;ae(this,Kt,"f")[p]?.reject(new Xf(c,v)),delete ae(this,Kt,"f")[p];break}case xt.PLUGIN_CALL:{let[,p,c,v,C,R]=t;ae(this,Cu,"f")?.callback(p,c,v,C,R);break}case xt.UNHANDLED_REJECTION:{let[,,p,c]=t;ae(this,kr,"m",Au).call(this,c),ae(this,wu,"f").call(this,"UnhandledRejection",p);break}}}),x4.set(this,r=>{switch(r){case"Opened":console.info("devvit playtest connected");break;case"Closed":console.info("devvit playtest disconnected");break;case"Reloading":{console.info("devvit playtest reloading"),ae(this,ad,"f")?.close();let t=new URL(location.href);t.searchParams.set(y4,ae(this,g4,"f")??""),location.assign(t),location.reload();break}}}),Zn(this,mc,n,"f"),i&&Zn(this,wu,i,"f"),d&&Zn(this,Cu,d,"f")}get ready(){return ae(this,Su,"f")}get runtimeDebugLogging(){return ae(this,c2,"f")}set runtimeDebugLogging(n){n!==ae(this,c2,"f")&&(Zn(this,c2,n,"f"),this.runtimeDebugLogging&&ae(this,Un,"f")?.postMessage([zt.ENABLE_DEBUG_LOGGING]))}async loadBundle(n){if(ae(this,Un,"f"))throw new Error("Bundle already loaded");let i=wb(m4(n));i&&(Zn(this,ad,new vc,"f"),ae(this,ad,"f").onState=ae(this,x4,"f")),ae(this,ad,"f")?.open();let d=new Worker(URL.createObjectURL(ae(this,mc,"f")),{name:`App: ${pb(n)}`,type:"module"});return d.onerror=r=>ae(this,wu,"f").call(this,"Error",r.error),d.onmessageerror=r=>ae(this,wu,"f").call(this,"MessageError",r.data),d.onmessage=ae(this,R4,"f"),Zn(this,Un,d,"f"),Zn(this,p2,n,"f"),this.runtimeDebugLogging&&ae(this,Un,"f").postMessage([zt.ENABLE_DEBUG_LOGGING]),i&&ae(this,Un,"f").postMessage([zt.ENABLE_APP_LOGGING]),new Promise((r,t)=>{Zn(this,od,{resolve:r,reject:t},"f")})}async call(n,i,d){var r;if(!ae(this,Su,"f")||!ae(this,Un,"f"))throw new Error("No bundle loaded");let t=Zn(this,kc,(r=ae(this,kc,"f"),++r),"f"),s=new Promise((p,c)=>{ae(this,Kt,"f")[t]={resolve:p,reject:c}});return ae(this,Un,"f").postMessage([zt.CALL,t,n,i,d,!1]),s}onPluginResponse(n,i){ae(this,Un,"f")?.postMessage([zt.PLUGIN_RESPONSE,n,i])}quit(){ae(this,ad,"f")?.close(),Zn(this,ad,void 0,"f"),Zn(this,Su,!1,"f"),ae(this,Un,"f")&&(ae(this,Un,"f").postMessage([zt.QUIT]),ae(this,Un,"f").onerror=null,ae(this,Un,"f").onmessageerror=null,ae(this,Un,"f").onmessage=null,ae(this,Un,"f").terminate()),Zn(this,Un,void 0,"f");for(let{reject:n}of Object.values(ae(this,Kt,"f")))n(Error("worker terminated"));Zn(this,Kt,{},"f"),ae(this,od,"f")?.reject(Error("worker terminated")),Zn(this,od,void 0,"f")}};mc=new WeakMap,Un=new WeakMap,Su=new WeakMap,kc=new WeakMap,p2=new WeakMap,Kt=new WeakMap,od=new WeakMap,wu=new WeakMap,Cu=new WeakMap,ad=new WeakMap,g4=new WeakMap,c2=new WeakMap,yc=new WeakMap,R4=new WeakMap,x4=new WeakMap,kr=new WeakSet,Cb=function(){ae(this,Un,"f")?.postMessage([zt.ENABLE_PLUGINS,ae(this,Cu,"f")?.plugins??[]])},Au=function(n){if(!n.length)return;let i=new Date,d={logs:n.map(r=>({severity:jR[r.method],message:r.args.join(" "),tags:[],timestamp:i}))};ae(this,ad,"f")?.send({callState:d})},N4=function(){ae(this,Un,"f")?.postMessage([zt.LOAD_BUNDLE,ae(this,p2,"f")]),Zn(this,p2,void 0,"f")};var Mb=P(Tb(),1);var v2=class extends Error{constructor(n){super(n),this.name="TimeoutError"}},E4=class extends Error{constructor(n){super(),this.name="AbortError",this.message=n}},gb=e=>globalThis.DOMException===void 0?new E4(e):new DOMException(e),Rb=e=>{let n=e.reason===void 0?gb("This operation was aborted."):e.reason;return n instanceof Error?n:gb(n)};function P4(e,n,i,d){let r,t=new Promise((s,p)=>{if(typeof n!="number"||Math.sign(n)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(n===Number.POSITIVE_INFINITY){s(e);return}if(d={customTimers:{setTimeout,clearTimeout},...d},d.signal){let{signal:c}=d;c.aborted&&p(Rb(c)),c.addEventListener("abort",()=>{p(Rb(c))})}r=d.customTimers.setTimeout.call(void 0,()=>{if(typeof i=="function"){try{s(i())}catch(C){p(C)}return}let c=typeof i=="string"?i:`Promise timed out after ${n} milliseconds`,v=i instanceof Error?i:new v2(c);typeof e.cancel=="function"&&e.cancel(),p(v)},n),(async()=>{try{s(await e)}catch(c){p(c)}finally{d.customTimers.clearTimeout.call(void 0,r)}})()});return t.clear=()=>{clearTimeout(r),r=void 0},t}function O4(e,n,i){let d=0,r=e.length;for(;r>0;){let t=Math.trunc(r/2),s=d+t;i(e[s],n)<=0?(d=++s,r-=t+1):r=t}return d}var ba=function(e,n,i,d){if(i==="a"&&!d)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?e!==n||!d:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?d:i==="a"?d.call(e):d?d.value:n.get(e)},ud,m2=class{constructor(){ud.set(this,[])}enqueue(n,i){i={priority:0,...i};let d={priority:i.priority,run:n};if(this.size&&ba(this,ud,"f")[this.size-1].priority>=i.priority){ba(this,ud,"f").push(d);return}let r=O4(ba(this,ud,"f"),d,(t,s)=>s.priority-t.priority);ba(this,ud,"f").splice(r,0,d)}dequeue(){let n=ba(this,ud,"f").shift();return n?.run}filter(n){return ba(this,ud,"f").filter(i=>i.priority===n.priority).map(i=>i.run)}get size(){return ba(this,ud,"f").length}};ud=new WeakMap;var rn=function(e,n,i,d,r){if(d==="m")throw new TypeError("Private method is not writable");if(d==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?e!==n||!r:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return d==="a"?r.call(e,i):r?r.value=i:n.set(e,i),i},ne=function(e,n,i,d){if(i==="a"&&!d)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?e!==n||!d:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?d:i==="a"?d.call(e):d?d.value:n.get(e)},An,y2,S2,I1,Rc,w2,Ac,Xt,k2,lt,Cc,st,A2,x1,bc,Nb,xb,Pb,Ib,Eb,Tc,M4,B4,Nc,Ob,gc,xc=class extends Error{},C2=class extends Mb.default{constructor(n){var i,d,r,t;if(super(),An.add(this),y2.set(this,void 0),S2.set(this,void 0),I1.set(this,0),Rc.set(this,void 0),w2.set(this,void 0),Ac.set(this,0),Xt.set(this,void 0),k2.set(this,void 0),lt.set(this,void 0),Cc.set(this,void 0),st.set(this,0),A2.set(this,void 0),x1.set(this,void 0),bc.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:m2,...n},!(typeof n.intervalCap=="number"&&n.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(d=(i=n.intervalCap)===null||i===void 0?void 0:i.toString())!==null&&d!==void 0?d:""}\` (${typeof n.intervalCap})`);if(n.interval===void 0||!(Number.isFinite(n.interval)&&n.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(t=(r=n.interval)===null||r===void 0?void 0:r.toString())!==null&&t!==void 0?t:""}\` (${typeof n.interval})`);rn(this,y2,n.carryoverConcurrencyCount,"f"),rn(this,S2,n.intervalCap===Number.POSITIVE_INFINITY||n.interval===0,"f"),rn(this,Rc,n.intervalCap,"f"),rn(this,w2,n.interval,"f"),rn(this,lt,new n.queueClass,"f"),rn(this,Cc,n.queueClass,"f"),this.concurrency=n.concurrency,this.timeout=n.timeout,rn(this,bc,n.throwOnTimeout===!0,"f"),rn(this,x1,n.autoStart===!1,"f")}get concurrency(){return ne(this,A2,"f")}set concurrency(n){if(!(typeof n=="number"&&n>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${n}\` (${typeof n})`);rn(this,A2,n,"f"),ne(this,An,"m",Nc).call(this)}async add(n,i={}){return i={timeout:this.timeout,throwOnTimeout:ne(this,bc,"f"),...i},new Promise((d,r)=>{ne(this,lt,"f").enqueue(async()=>{var t,s,p;rn(this,st,(s=ne(this,st,"f"),s++,s),"f"),rn(this,I1,(p=ne(this,I1,"f"),p++,p),"f");try{if(!((t=i.signal)===null||t===void 0)&&t.aborted)throw new xc("The task was aborted.");let c=n({signal:i.signal});i.timeout&&(c=P4(Promise.resolve(c),i.timeout)),i.signal&&(c=Promise.race([c,ne(this,An,"m",Ob).call(this,i.signal)]));let v=await c;d(v),this.emit("completed",v)}catch(c){if(c instanceof v2&&!i.throwOnTimeout){d();return}r(c),this.emit("error",c)}finally{ne(this,An,"m",Pb).call(this)}},i),this.emit("add"),ne(this,An,"m",Tc).call(this)})}async addAll(n,i){return Promise.all(n.map(async d=>this.add(d,i)))}start(){return ne(this,x1,"f")?(rn(this,x1,!1,"f"),ne(this,An,"m",Nc).call(this),this):this}pause(){rn(this,x1,!0,"f")}clear(){rn(this,lt,new(ne(this,Cc,"f")),"f")}async onEmpty(){ne(this,lt,"f").size!==0&&await ne(this,An,"m",gc).call(this,"empty")}async onSizeLessThan(n){ne(this,lt,"f").size<n||await ne(this,An,"m",gc).call(this,"next",()=>ne(this,lt,"f").size<n)}async onIdle(){ne(this,st,"f")===0&&ne(this,lt,"f").size===0||await ne(this,An,"m",gc).call(this,"idle")}get size(){return ne(this,lt,"f").size}sizeBy(n){return ne(this,lt,"f").filter(n).length}get pending(){return ne(this,st,"f")}get isPaused(){return ne(this,x1,"f")}};y2=new WeakMap,S2=new WeakMap,I1=new WeakMap,Rc=new WeakMap,w2=new WeakMap,Ac=new WeakMap,Xt=new WeakMap,k2=new WeakMap,lt=new WeakMap,Cc=new WeakMap,st=new WeakMap,A2=new WeakMap,x1=new WeakMap,bc=new WeakMap,An=new WeakSet,Nb=function(){return ne(this,S2,"f")||ne(this,I1,"f")<ne(this,Rc,"f")},xb=function(){return ne(this,st,"f")<ne(this,A2,"f")},Pb=function(){var n;rn(this,st,(n=ne(this,st,"f"),n--,n),"f"),ne(this,An,"m",Tc).call(this),this.emit("next")},Ib=function(){ne(this,An,"m",B4).call(this),ne(this,An,"m",M4).call(this),rn(this,k2,void 0,"f")},Eb=function(){let n=Date.now();if(ne(this,Xt,"f")===void 0){let i=ne(this,Ac,"f")-n;if(i<0)rn(this,I1,ne(this,y2,"f")?ne(this,st,"f"):0,"f");else return ne(this,k2,"f")===void 0&&rn(this,k2,setTimeout(()=>{ne(this,An,"m",Ib).call(this)},i),"f"),!0}return!1},Tc=function(){if(ne(this,lt,"f").size===0)return ne(this,Xt,"f")&&clearInterval(ne(this,Xt,"f")),rn(this,Xt,void 0,"f"),this.emit("empty"),ne(this,st,"f")===0&&this.emit("idle"),!1;if(!ne(this,x1,"f")){let n=!ne(this,An,"a",Eb);if(ne(this,An,"a",Nb)&&ne(this,An,"a",xb)){let i=ne(this,lt,"f").dequeue();return i?(this.emit("active"),i(),n&&ne(this,An,"m",M4).call(this),!0):!1}}return!1},M4=function(){ne(this,S2,"f")||ne(this,Xt,"f")!==void 0||(rn(this,Xt,setInterval(()=>{ne(this,An,"m",B4).call(this)},ne(this,w2,"f")),"f"),rn(this,Ac,Date.now()+ne(this,w2,"f"),"f"))},B4=function(){ne(this,I1,"f")===0&&ne(this,st,"f")===0&&ne(this,Xt,"f")&&(clearInterval(ne(this,Xt,"f")),rn(this,Xt,void 0,"f")),rn(this,I1,ne(this,y2,"f")?ne(this,st,"f"):0,"f"),ne(this,An,"m",Nc).call(this)},Nc=function(){for(;ne(this,An,"m",Tc).call(this););},Ob=async function(n){return new Promise((i,d)=>{n.addEventListener("abort",()=>{d(new xc("The task was aborted."))},{once:!0})})},gc=async function(n,i){return new Promise(d=>{let r=()=>{i&&!i()||(this.off(n,r),d())};this.on(n,r)})};function Bb(){var r,t;let e=new URL(globalThis.location?location.href:"file://");if(globalThis.devvit??(globalThis.devvit={}),globalThis.devvit.debug)return;(r=globalThis.devvit).debug??(r.debug={});let n={blocks:void 0,emitSnapshots:void 0,emitState:void 0,realtime:void 0,runtime:void 0,surface:void 0,useAsync:void 0,payments:void 0,bootstrap:void 0},i={};for(let s in n)i[s.toLowerCase()]=s;let d=[...e.searchParams].find(([s])=>s.toLowerCase()==="devvitdebug")?.[1];if(d!=null){d===""&&(d=Object.keys(n).filter(s=>s!=="emitSnapshots"&&s!=="emitState").join());for(let s of d.split(",")??[]){let[p,c]=s.split("=");p&&(p.toLowerCase()in i?p=i[p.toLowerCase()]:console.warn(`[devvit] unknown devvitdebug parameter "${p}"`),(t=globalThis.devvit.debug)[p]??(t[p]=c||"true"),console.info(`[devvit] set devvitdebug ${p}=${globalThis.devvit.debug[p]}`))}}}var iN={width:288,height:320,scale:1,fontScale:1},tN=["showToast","showForm","navigateToUrl"];Bb();var E1,P1,O1,Tu,gu,M1,b2,Ru,ld,In,L4,Ic,bu,Pc,F4,Lb,Ec=class{constructor(){Pe(this,In);Pe(this,E1);this.dimensions=iN;Pe(this,P1);Pe(this,O1,{});Pe(this,Tu,new C2({concurrency:1}));Pe(this,gu,!1);Pe(this,M1);Pe(this,b2,!1);Pe(this,Ru,!1);Pe(this,ld,[]);Pe(this,Pc,(n,i,d,r,t)=>{this.onPluginCall?.(n,i,d,r,t),i===ea.fullName&&d===ea.methods.send.name&&this._local?.onPluginResponse(n,{error:void 0,success:!0,value:{}})})}get appState(){return $(this,O1).__postData={thingId:this.postID,config:this.postConfig},$(this,O1)}async load(n){this.unload(),En(this,P1,n);try{return await this._local?.loadBundle(n)}catch(i){Pn(this,In,bu).call(this,n,"Error",i)}}set meta(n){let i={...n},d=[];for(let[r,t]of Object.entries(devvit?.debug??{}))d.push(`${r}=${t}`);d.length&&(i[Qf.Debug]={values:d}),En(this,E1,i)}queueEvent(n){let i=$(this,P1);n.async?Pn(this,In,F4).call(this,i,n):$(this,Tu).add(()=>Pn(this,In,F4).call(this,i,n))}queueRenderPost(n,i,d){let r=$(this,P1);$(this,Tu).add(()=>Pn(this,In,Lb).call(this,r,n,i,d))}get rendered(){return $(this,gu)}get pausedEffects(){return $(this,ld)}resetAppState(){En(this,gu,!1),En(this,O1,{})}set runtimeDebugLogging(n){En(this,b2,n),this._local&&(this._local.runtimeDebugLogging=n)}setLocalSrc(n){this.unload(),this._local=n?new Sc(n,(i,d)=>this.onError?.(i,d),{callback:$(this,Pc),plugins:[]}):void 0,this._local&&(this._local.runtimeDebugLogging=$(this,b2))}unload(){En(this,P1,void 0),$(this,M1)!=null&&clearTimeout($(this,M1)),$(this,Tu).clear(),this._local?.quit()}togglePause(n){if(!n&&$(this,ld).length>0){let i=$(this,ld);En(this,ld,[]),i.forEach(({renderType:d,effects:r})=>{Pn(this,In,Ic).call(this,d,r)})}En(this,Ru,n)}};E1=new WeakMap,P1=new WeakMap,O1=new WeakMap,Tu=new WeakMap,gu=new WeakMap,M1=new WeakMap,b2=new WeakMap,Ru=new WeakMap,ld=new WeakMap,In=new WeakSet,L4=function(n){devvit?.debug.runtime&&(ma(n)?console.debug("[runtime] try remote call; circuit break"):console.debug("[runtime] try remote call; local failed",n),this.remote||console.debug("[runtime] call failed; no remote"))},Ic=function(n,i){for(let d of i)d.rerenderUi?($(this,M1)!=null&&clearTimeout($(this,M1)),En(this,M1,setTimeout(()=>{this.queueRenderPost(un.RENDER_EFFECT_EVENT,"rerender-effect",{})},(d.rerenderUi.delaySeconds??0)*1e3))):(n!==un.RENDER_USER_ACTION||tN.some(r=>d[r]))&&this.onUserAction?.(d)},bu=function(n,i,d){n&&$(this,P1)!==n||this.onError?.(i,d)},Pc=new WeakMap,F4=async function(n,i){let d,r={event:i,state:this.appState};if(this._local?.ready&&i.scope!==ni.REMOTE)try{d=await this._local.call("HandleUIEvent",r,$(this,E1))}catch(t){(!ma(t)||!this.remote)&&Pn(this,In,bu).call(this,n,"Error",t),Pn(this,In,L4).call(this,t)}else devvit?.debug.runtime&&console.debug(`[runtime] try remote call; ${i.scope===ni.REMOTE?"local call forbidden":"local not ready"}`);if(!d&&i.scope!==ni.LOCAL)try{d=await this.remote?.HandleUIEvent(r,$(this,E1))}catch(t){Pn(this,In,bu).call(this,n,"Error",t),devvit?.debug.runtime&&console.debug("[runtime] remote call failed",t)}if(d){i.async||En(this,O1,d.state??{});let t=i.realtimeEvent?un.RENDER_EFFECT_EVENT:un.RENDER_USER_ACTION;$(this,Ru)?$(this,ld).push({renderType:t,effects:d.effects}):Pn(this,In,Ic).call(this,t,d.effects)}devvit?.debug.runtime&&(!this._local?.ready&&!this.remote?console.debug("[runtime] call failed; no runtimes"):!this._local?.ready&&i.scope===ni.LOCAL?console.debug("[runtime] call failed; local event but local runtime is unavailable"):!this.remote&&i.scope===ni.REMOTE&&console.debug("[runtime] call failed; remote event but remote runtime is unavailable"))},Lb=async function(n,i,d,r){let t={blocks:{type:i,id:d,data:r},state:this.appState,dimensions:this.dimensions},s;if(this._local?.ready)try{s=await this._local.call("RenderPost",t,$(this,E1))}catch(p){ma(p)&&p.response&&(s=p.response),(!ma(p)||!this.remote)&&Pn(this,In,bu).call(this,n,"Error",p),Pn(this,In,L4).call(this,p)}else devvit?.debug.runtime&&console.debug("[runtime] try remote call; local not ready");if(!s)try{s=await this.remote?.RenderPost(t,$(this,E1))}catch(p){Pn(this,In,bu).call(this,n,"Error",p),devvit?.debug.runtime&&console.debug("[runtime] remote call failed",p)}s&&(En(this,gu,!0),s.state&&En(this,O1,s.state),this.onRenderPost?.(t,s),$(this,Ru)?$(this,ld).push({renderType:t.blocks.type,effects:s.effects}):Pn(this,In,Ic).call(this,t.blocks.type,s.effects)),devvit?.debug.runtime&&!this._local?.ready&&!this.remote&&console.debug("[runtime] call failed; no runtimes")};function Fb(e,n,i,d){let r=d.match(/([a-zA-Z0-9-]+)\/(.*)/)??[];if(r.length<3)return"";let[t,s,p]=r;if(!n||!s||!p)return"";let c=n.replace(/^t[0-9]_/,""),v=e.replace("{{location}}",c).replace("{{app}}",s).replace("{{path}}",p);return new URL(v).toString()}var dn,Ta,Nu,xu,g2,ga,T2,Oc,Mc,Bc,Lc,Fc,_n=class extends ft{constructor(){super();Pe(this,ga);this.runtimeDebugLogging=!1;this.useExperimentalBlocks=!1;this.webviewUrlTemplate="";this.disableAssetSandbox=!1;Pe(this,dn,new Ec);Pe(this,Ta);Pe(this,Nu);Pe(this,xu);Pe(this,g2,"");Pe(this,Oc,()=>({experimental:this.useExperimentalBlocks,resolveWebviewUrl:i=>this.disableAssetSandbox?i:Fb(this.webviewUrlTemplate,this.metadata?.[Qf.Subreddit]?.values?.[0],$(this,g2),i),onAction:i=>$(this,dn).queueRenderPost(un.RENDER_USER_ACTION,i.id,i.data??{}),stackDirection:me.UNRECOGNIZED,disableAssetSandbox:this.disableAssetSandbox}));Pe(this,Mc,(i,d)=>{ma(d)||console.error(d),Pn(this,ga,T2).call(this,"devvit-ui-error",{err:d,type:i})});Pe(this,Bc,(i,d,r,t,s)=>{d===ea.fullName&&r===ea.methods.send.name&&((devvit?.debug.surface||devvit?.debug.realtime)&&console.debug("[realtime][custom] realtime plugin call",t),Pn(this,ga,T2).call(this,"devvit-realtime-send",{event:t}))});Pe(this,Lc,(i,d)=>{var r,t;this.renderResponse=d,this.renderResponse?.blocks?.ui&&(this._rootBlock=this.renderResponse.blocks.ui,$(this,Ta)?((r=this._rootBlock).config??(r.config={}),(t=this._rootBlock.config).rootConfig??(t.rootConfig=pr.fromPartial({})),this._rootBlock.config.rootConfig.height=$(this,Ta)):En(this,Ta,this._rootBlock.config?.rootConfig?.height||h4))});Pe(this,Fc,i=>{devvit?.debug.surface&&console.debug("[custom] effect",i),Pn(this,ga,T2).call(this,"devvit-ui-effect",{effect:i,onEvent:d=>$(this,dn).queueEvent(d),metadata:this.metadata})});devvit?.debug.surface&&console.debug("[custom] constructed"),$(this,dn).onError=$(this,Mc),$(this,dn).onPluginCall=$(this,Bc),$(this,dn).onRenderPost=$(this,Lc),$(this,dn).onUserAction=$(this,Fc)}static get styles(){return[rc]}async connectedCallback(){super.connectedCallback(),devvit?.debug.surface&&console.debug("[custom] connected"),En(this,Nu,new ResizeObserver(oC(i=>{i.length!==0&&(this.dimensions=cb(i[0],window,document.body),devvit?.debug.surface&&console.debug("[custom] resized",this.dimensions))},600))),$(this,Nu).observe(this,{box:"content-box"}),En(this,xu,new IntersectionObserver(i=>{i.forEach(d=>{devvit?.debug.surface&&console.debug(`[custom] ${d.isIntersecting?"":"not "}intersecting`),$(this,dn).togglePause(!d.isIntersecting)})})),$(this,xu).observe(this)}disconnectedCallback(){devvit?.debug.surface&&console.debug("[custom] disconnected"),$(this,dn).unload(),$(this,Nu)?.unobserve(this),$(this,xu)?.unobserve(this),super.disconnectedCallback()}render(){return this.renderResponse?Ui`<div class="relative">
|
|
624
624
|
<devvit-blocks-renderer
|
|
625
625
|
class="${this.scheme??""}"
|
|
626
626
|
.block="${this._rootBlock}"
|