@adriansteffan/reactive 0.1.4 → 0.1.5

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.
@@ -16724,7 +16724,7 @@ function Xye() {
16724
16724
  }
16725
16725
  const yc = [];
16726
16726
  function Oo(i, e, t = "string", s, r) {
16727
- let n = yc.find((c) => c.name === i);
16727
+ let n = yc.find((d) => d.name === i);
16728
16728
  n || (n = {
16729
16729
  name: i,
16730
16730
  defaultValue: r !== void 0 ? r : e,
@@ -16733,41 +16733,41 @@ function Oo(i, e, t = "string", s, r) {
16733
16733
  value: void 0
16734
16734
  }, yc.push(n));
16735
16735
  const a = {
16736
- string: (c) => c,
16737
- number: (c) => {
16738
- const d = Number(c);
16739
- return isNaN(d) ? e : d;
16736
+ string: (d) => d,
16737
+ number: (d) => {
16738
+ const f = Number(d);
16739
+ return isNaN(f) ? e : f;
16740
16740
  },
16741
- boolean: (c) => c.toLowerCase() === "true",
16742
- array: (c) => {
16741
+ boolean: (d) => d.toLowerCase() === "true",
16742
+ array: (d) => {
16743
16743
  try {
16744
- return JSON.parse(c);
16744
+ return JSON.parse(d);
16745
16745
  } catch {
16746
16746
  return e;
16747
16747
  }
16748
16748
  },
16749
- json: (c) => {
16749
+ json: (d) => {
16750
16750
  try {
16751
- return JSON.parse(c);
16751
+ return JSON.parse(d);
16752
16752
  } catch {
16753
16753
  return e;
16754
16754
  }
16755
16755
  }
16756
- }, o = (c) => t === "string" && typeof c == "string" || t === "number" && typeof c == "number" || t === "boolean" && typeof c == "boolean" || t === "array" && Array.isArray(c) || t === "json" && typeof c == "object" && c !== null ? c : typeof c == "string" ? c.toLowerCase() === "undefined" ? e : a[t](c) : e, l = new URLSearchParams(window.location.search).get("_b");
16757
- if (l)
16756
+ }, o = (d) => t === "string" && typeof d == "string" || t === "number" && typeof d == "number" || t === "boolean" && typeof d == "boolean" || t === "array" && Array.isArray(d) || t === "json" && typeof d == "object" && d !== null ? d : typeof d == "string" ? d.toLowerCase() === "undefined" ? e : a[t](d) : e, l = typeof window < "u" ? new URLSearchParams(window.location.search) : new URLSearchParams(), u = l.get("_b");
16757
+ if (u)
16758
16758
  try {
16759
- const c = atob(l), d = JSON.parse(c);
16760
- if (i in d) {
16761
- const f = o(d[i]);
16762
- return n.value = f, f;
16759
+ const d = atob(u), f = JSON.parse(d);
16760
+ if (i in f) {
16761
+ const y = o(f[i]);
16762
+ return n.value = y, y;
16763
16763
  }
16764
16764
  } catch {
16765
16765
  }
16766
- const u = new URLSearchParams(window.location.search).get(i);
16767
- if (u == null)
16766
+ const h = l.get(i);
16767
+ if (h == null)
16768
16768
  return e;
16769
- const h = o(u);
16770
- return n.value = h, h;
16769
+ const c = o(h);
16770
+ return n.value = c, c;
16771
16771
  }
16772
16772
  const Rm = [];
16773
16773
  class Am {
@@ -78625,7 +78625,7 @@ var Ym;
78625
78625
  i.UTF8 = "utf8", i.ASCII = "ascii", i.UTF16 = "utf16";
78626
78626
  })(Ym || (Ym = {}));
78627
78627
  const Ea = wu("Filesystem", {
78628
- web: () => import("./web-DGGPscOK.js").then((i) => new i.FilesystemWeb())
78628
+ web: () => import("./web-C529F28q.js").then((i) => new i.FilesystemWeb())
78629
78629
  });
78630
78630
  vi("Upload", async (i, e, t, s) => {
78631
78631
  const r = i.sessionID || `sim_${Date.now()}_${Math.floor(Lt(0, 2176782336)).toString(36)}`, n = xV({
@@ -78883,7 +78883,7 @@ var iw;
78883
78883
  i.None = "NONE", i.Slide = "SLIDE", i.Fade = "FADE";
78884
78884
  })(iw || (iw = {}));
78885
78885
  const X3 = wu("StatusBar"), e7 = wu("ImmersiveMode", {
78886
- web: () => import("./web-BGLPXsYu.js").then((i) => new i.ImmersiveModeWeb())
78886
+ web: () => import("./web-DLw2qwQT.js").then((i) => new i.ImmersiveModeWeb())
78887
78887
  });
78888
78888
  Ai("EnterFullscreen", "session");
78889
78889
  vi("EnterFullscreen", xu, {});
@@ -1,4 +1,4 @@
1
- import { H as e, C as t, a as i, c as r, d as n, e as o, f as l, Y as m, z as u, M as c, P as p, g as P, h as g, Q as d, R as C, i as D, j as T, F as x, T as h, k, l as E, U as F, X as S, m as f, n as v, o as B, p as R, q as b, r as y, s as I, t as M, u as U, v as w, w as K, x as q, y as A, A as Q, B as Z, D as j, G as z, I as G, J as H, K as J, L, N, O, S as V, V as X, Z as Y, _, $, a0 as W, a1 as aa, a2 as sa, a3 as ea, a4 as ta, a5 as ia, a6 as ra, a7 as na, a8 as oa, a9 as la, aa as ma, ab as ua } from "./mod-DHUjIRfF.js";
1
+ import { H as e, C as t, a as i, c as r, d as n, e as o, f as l, Y as m, z as u, M as c, P as p, g as P, h as g, Q as d, R as C, i as D, j as T, F as x, T as h, k, l as E, U as F, X as S, m as f, n as v, o as B, p as R, q as b, r as y, s as I, t as M, u as U, v as w, w as K, x as q, y as A, A as Q, B as Z, D as j, G as z, I as G, J as H, K as J, L, N, O, S as V, V as X, Z as Y, _, $, a0 as W, a1 as aa, a2 as sa, a3 as ea, a4 as ta, a5 as ia, a6 as ra, a7 as na, a8 as oa, a9 as la, aa as ma, ab as ua } from "./mod-BPE3lXMa.js";
2
2
  export {
3
3
  e as Bounce,
4
4
  t as CanvasBlock,
@@ -10145,7 +10145,7 @@
10145
10145
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10146
10146
  * See the License for the specific language governing permissions and
10147
10147
  * limitations under the License.
10148
- */var Ire=it,d2=Cre,Rre=Pre;Ire(d2,"factory",Rre);var Are=d2;const Lre=za(Are),Ts=new Uint32Array(1);function _re(i){return Ts[0]=i,Ts[0]=(Ts[0]<<16|Ts[0]>>16)>>>0,Ts[0]=(Ts[0]&1431655765)<<1|(Ts[0]&2863311530)>>>1>>>0,Ts[0]=(Ts[0]&858993459)<<2|(Ts[0]&3435973836)>>>2>>>0,Ts[0]=(Ts[0]&252645135)<<4|(Ts[0]&4042322160)>>>4>>>0,Ts[0]=(Ts[0]&16711935)<<8|(Ts[0]&4278255360)>>>8>>>0,Ts[0]*23283064365386963e-26}function Dre(i,e){let t=1,s=0;for(;i>0;)t/=e,s+=t*(i%e),i=~~(i/e);return s}const kre=(i,e=[2,3])=>Array.from({length:i},(t,s)=>e.map(r=>r===2?_re(s):Dre(s,r)));X.normal=qC,X.poisson=db,X.uniform=Vb;function Ore(i){const e=LB.factory({seed:i});X.normal=qC.factory({prng:e.normalized}),X.poisson=db.factory({prng:e.normalized}),X.uniform=Vb.factory({prng:e.normalized}),Math.random=()=>X.uniform(0,1)}function p2(i){return Math.max(1e-10,Math.min(1-1e-10,i))}function f2(i){switch(i.distribution){case"uniform":return e=>i.min+e*(i.max-i.min);case"normal":return e=>UK(p2(e),i.mean,i.sd);case"poisson":return e=>Lre(p2(e),i.mean)}}function m2(i,e){const t=e.map(f2);return e.length===1?i.map(s=>t[0](s[0])):i.map(s=>s.map((r,n)=>t[n](r)))}const Mre=[[1,0,[1]],[2,1,[1,1]],[3,1,[1,3,7]],[3,2,[1,1,5]],[4,1,[1,3,1,1]],[4,4,[1,1,3,7]],[5,2,[1,3,3,9,9]],[5,13,[1,3,7,13,3]],[5,7,[1,1,5,11,27]],[5,14,[1,3,5,1,15]],[5,11,[1,1,7,3,29]],[5,4,[1,3,7,7,21]],[6,1,[1,1,1,9,23,37]],[6,16,[1,3,3,5,19,33]],[6,13,[1,1,3,13,11,7]],[6,22,[1,1,7,13,25,5]],[6,19,[1,3,5,11,7,11]],[6,25,[1,1,1,3,13,39]],[7,1,[1,3,1,15,17,63,13]],[7,32,[1,1,5,5,1,59,33]]],oo=32,Nre=2**oo;function Fre(i){const e=new Uint32Array(oo);if(i===0){for(let n=0;n<oo;n++)e[n]=1<<oo-1-n;return e}const[t,s,r]=Mre[i-1];for(let n=0;n<t;n++)e[n]=r[n]<<oo-1-n;for(let n=t;n<oo;n++){e[n]=e[n-t]^e[n-t]>>>t;for(let a=1;a<t;a++)s>>>t-1-a&1&&(e[n]^=e[n-a])}return e}function qre(i,e){if(e<1||e>21)throw new RangeError("sobol() supports 1-21 dimensions");const t=Array.from({length:e},(n,a)=>Fre(a)),s=new Uint32Array(e),r=[new Array(e).fill(0)];for(let n=1;n<i;n++){let a=0,o=n-1;for(;(o&1)===1;)o>>>=1,a++;for(let l=0;l<e;l++)s[l]^=t[l][a];r.push(Array.from(s,l=>l/Nre))}return r}const Bre=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73],g2=6;function v2(i,e){const t=qre(i+1,e.length).slice(1);return m2(t,e)}function y2(i,e){e.length>g2&&console.warn(`Halton sequence quality degrades above ${g2} dimensions. Consider using sobol() instead.`);const t=Bre.slice(0,e.length),s=kre(i+1,t).slice(1);return m2(s,e)}function $re(i,e,t){const s=Object.keys(t),r=s.map(a=>t[a]);let n;switch(i){case"sobol":n=v2(e,r);break;case"halton":n=y2(e,r);break;case"random":n=Hre(e,r);break}return Array.from({length:e},(a,o)=>{const l=s.length===1?[n[o]]:n[o];return Object.fromEntries(s.map((u,h)=>[u,l[h]]))})}function Hre(i,e){const t=e.map(f2);return e.length===1?Array.from({length:i},()=>t[0](X.uniform(0,1))):Array.from({length:i},()=>t.map(s=>s(X.uniform(0,1))))}function C2(i,e=1){const t=[];if(i.length===0)return t;for(let s=0;s<e;s++){const r=Math.floor(X.uniform(0,1)*i.length);t.push(i[r])}return t}function fm(i){const e=[...i];for(let t=e.length-1;t>=0;t--){const s=Math.floor(X.uniform(0,1)*(t+1));[e[t],e[s]]=[e[s],e[t]]}return e}function b2(i,e){return e(i)}function w2(i,e){const t=Math.ceil(i.length/e);return Array.from({length:Math.ceil(i.length/t)},(s,r)=>i.slice(r*t,r*t+t))}function Qre(){typeof Array.prototype.sample!="function"&&(Array.prototype.sample=function(i){return C2(this,i)}),typeof Array.prototype.shuffle!="function"&&(Array.prototype.shuffle=function(){return fm(this)}),typeof Array.prototype.pipe!="function"&&(Array.prototype.pipe=function(i){return b2(this,i)}),typeof Array.prototype.chunk!="function"&&(Array.prototype.chunk=function(i){return w2(this,i)})}/*! Capacitor: https://capacitorjs.com/ - MIT License */var lo;(function(i){i.Unimplemented="UNIMPLEMENTED",i.Unavailable="UNAVAILABLE"})(lo||(lo={}));class mm extends Error{constructor(e,t,s){super(e),this.message=e,this.code=t,this.data=s}}const Ure=i=>{var e,t;return i!=null&&i.androidBridge?"android":!((t=(e=i==null?void 0:i.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||t===void 0)&&t.bridge?"ios":"web"},zre=i=>{const e=i.CapacitorCustomPlatform||null,t=i.Capacitor||{},s=t.Plugins=t.Plugins||{},r=()=>e!==null?e.name:Ure(i),n=()=>r()!=="web",a=c=>{const d=u.get(c);return!!(d!=null&&d.platforms.has(r())||o(c))},o=c=>{var d;return(d=t.PluginHeaders)===null||d===void 0?void 0:d.find(f=>f.name===c)},l=c=>i.console.error(c),u=new Map,h=(c,d={})=>{const f=u.get(c);if(f)return console.warn(`Capacitor plugin "${c}" already registered. Cannot register plugins twice.`),f.proxy;const y=r(),v=o(c);let m;const g=async()=>(!m&&y in d?m=typeof d[y]=="function"?m=await d[y]():m=d[y]:e!==null&&!m&&"web"in d&&(m=typeof d.web=="function"?m=await d.web():m=d.web),m),b=(T,k)=>{var q,B;if(v){const U=v==null?void 0:v.methods.find(D=>k===D.name);if(U)return U.rtype==="promise"?D=>t.nativePromise(c,k.toString(),D):(D,H)=>t.nativeCallback(c,k.toString(),D,H);if(T)return(q=T[k])===null||q===void 0?void 0:q.bind(T)}else{if(T)return(B=T[k])===null||B===void 0?void 0:B.bind(T);throw new mm(`"${c}" plugin is not implemented on ${y}`,lo.Unimplemented)}},x=T=>{let k;const q=(...B)=>{const U=g().then(D=>{const H=b(D,T);if(H){const Q=H(...B);return k=Q==null?void 0:Q.remove,Q}else throw new mm(`"${c}.${T}()" is not implemented on ${y}`,lo.Unimplemented)});return T==="addListener"&&(U.remove=async()=>k()),U};return q.toString=()=>`${T.toString()}() { [capacitor code] }`,Object.defineProperty(q,"name",{value:T,writable:!1,configurable:!1}),q},P=x("addListener"),R=x("removeListener"),A=(T,k)=>{const q=P({eventName:T},k),B=async()=>{const D=await q;R({eventName:T,callbackId:D},k)},U=new Promise(D=>q.then(()=>D({remove:B})));return U.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await B()},U},_=new Proxy({},{get(T,k){switch(k){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return v?A:P;case"removeListener":return R;default:return x(k)}}});return s[c]=_,u.set(c,{name:c,proxy:_,platforms:new Set([...Object.keys(d),...v?[y]:[]])}),_};return t.convertFileSrc||(t.convertFileSrc=c=>c),t.getPlatform=r,t.handleError=l,t.isNativePlatform=n,t.isPluginAvailable=a,t.registerPlugin=h,t.Exception=mm,t.DEBUG=!!t.DEBUG,t.isLoggingEnabled=!!t.isLoggingEnabled,t},fa=(i=>i.Capacitor=zre(i))(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),_l=fa.registerPlugin;class Zh{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,t){let s=!1;this.listeners[e]||(this.listeners[e]=[],s=!0),this.listeners[e].push(t);const n=this.windowListeners[e];n&&!n.registered&&this.addWindowListener(n),s&&this.sendRetainedArgumentsForEvent(e);const a=async()=>this.removeListener(e,t);return Promise.resolve({remove:a})}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,t,s){const r=this.listeners[e];if(!r){if(s){let n=this.retainedEventArguments[e];n||(n=[]),n.push(t),this.retainedEventArguments[e]=n}return}r.forEach(n=>n(t))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:s=>{this.notifyListeners(t,s)}}}unimplemented(e="not implemented"){return new fa.Exception(e,lo.Unimplemented)}unavailable(e="not available"){return new fa.Exception(e,lo.Unavailable)}async removeListener(e,t){const s=this.listeners[e];if(!s)return;const r=s.indexOf(t);this.listeners[e].splice(r,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){const t=this.retainedEventArguments[e];t&&(delete this.retainedEventArguments[e],t.forEach(s=>{this.notifyListeners(e,s)}))}}const x2=i=>encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),E2=i=>i.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class jre extends Zh{async getCookies(){const e=document.cookie,t={};return e.split(";").forEach(s=>{if(s.length<=0)return;let[r,n]=s.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");r=E2(r).trim(),n=E2(n).trim(),t[r]=n}),t}async setCookie(e){try{const t=x2(e.key),s=x2(e.value),r=`; expires=${(e.expires||"").replace("expires=","")}`,n=(e.path||"/").replace("path=",""),a=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${t}=${s||""}${r}; path=${n}; ${a};`}catch(t){return Promise.reject(t)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(t){return Promise.reject(t)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const t of e)document.cookie=t.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}_l("CapacitorCookies",{web:()=>new jre});const Wre=async i=>new Promise((e,t)=>{const s=new FileReader;s.onload=()=>{const r=s.result;e(r.indexOf(",")>=0?r.split(",")[1]:r)},s.onerror=r=>t(r),s.readAsDataURL(i)}),Gre=(i={})=>{const e=Object.keys(i);return Object.keys(i).map(r=>r.toLocaleLowerCase()).reduce((r,n,a)=>(r[n]=i[e[a]],r),{})},Kre=(i,e=!0)=>i?Object.entries(i).reduce((s,r)=>{const[n,a]=r;let o,l;return Array.isArray(a)?(l="",a.forEach(u=>{o=e?encodeURIComponent(u):u,l+=`${n}=${o}&`}),l.slice(0,-1)):(o=e?encodeURIComponent(a):a,l=`${n}=${o}`),`${s}&${l}`},"").substr(1):null,V2=(i,e={})=>{const t=Object.assign({method:i.method||"GET",headers:i.headers},e),r=Gre(i.headers)["content-type"]||"";if(typeof i.data=="string")t.body=i.data;else if(r.includes("application/x-www-form-urlencoded")){const n=new URLSearchParams;for(const[a,o]of Object.entries(i.data||{}))n.set(a,o);t.body=n.toString()}else if(r.includes("multipart/form-data")||i.data instanceof FormData){const n=new FormData;if(i.data instanceof FormData)i.data.forEach((o,l)=>{n.append(l,o)});else for(const o of Object.keys(i.data))n.append(o,i.data[o]);t.body=n;const a=new Headers(t.headers);a.delete("content-type"),t.headers=a}else(r.includes("application/json")||typeof i.data=="object")&&(t.body=JSON.stringify(i.data));return t};class Zre extends Zh{async request(e){const t=V2(e,e.webFetchExtra),s=Kre(e.params,e.shouldEncodeUrlParams),r=s?`${e.url}?${s}`:e.url,n=await fetch(r,t),a=n.headers.get("content-type")||"";let{responseType:o="text"}=n.ok?e:{};a.includes("application/json")&&(o="json");let l,u;switch(o){case"arraybuffer":case"blob":u=await n.blob(),l=await Wre(u);break;case"json":l=await n.json();break;case"document":case"text":default:l=await n.text()}const h={};return n.headers.forEach((c,d)=>{h[d]=c}),{data:l,headers:h,status:n.status,url:n.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}_l("CapacitorHttp",{web:()=>new Zre});function Ps(){return Math.round(performance.now())}function uo(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}function Jre(){return window.electronAPI!==void 0}const Jh=[];function ma(i,e,t="string",s,r){let n=Jh.find(c=>c.name===i);n||(n={name:i,defaultValue:r!==void 0?r:e,type:t,description:s,value:void 0},Jh.push(n));const a={string:c=>c,number:c=>{const d=Number(c);return isNaN(d)?e:d},boolean:c=>c.toLowerCase()==="true",array:c=>{try{return JSON.parse(c)}catch{return e}},json:c=>{try{return JSON.parse(c)}catch{return e}}},o=c=>t==="string"&&typeof c=="string"||t==="number"&&typeof c=="number"||t==="boolean"&&typeof c=="boolean"||t==="array"&&Array.isArray(c)||t==="json"&&typeof c=="object"&&c!==null?c:typeof c=="string"?c.toLowerCase()==="undefined"?e:a[t](c):e,l=new URLSearchParams(window.location.search).get("_b");if(l)try{const c=atob(l),d=JSON.parse(c);if(i in d){const f=o(d[i]);return n.value=f,f}}catch{}const u=new URLSearchParams(window.location.search).get(i);if(u==null)return e;const h=o(u);return n.value=h,h}const gm=[];class Yh{static getRegistry(){return[...Jh]}static getTimelineRepresentation(){return[...gm]}}const Dl=()=>window.electronAPI?"desktop":fa.isNativePlatform()?"mobile":"web",S2={};function T2(i){i.forEach(e=>{const t=S2[e.type];if(t)for(const s of t)(!e.hideSettings||e.hideSettings!==!0&&!e.hideSettings.includes(s.name))&&Jh.push(s)})}function vm(i,e){S2[i]=e}function Yre(i){T2(i),gm.length=0,i.forEach(r=>{gm.push({type:r.type??"NoTypeSpecified",name:r.name})});const e=ma("includeSubset",void 0),t=ma("excludeSubset",void 0);let s=[...i];if(e){const r=e.split(",");s=s.filter((n,a)=>{const o=r.some(u=>{const h=parseInt(u,10);return!isNaN(h)&&h-1===a}),l=n.name&&r.includes(n.name);return o||l})}if(t){const r=t.split(",");s=s.filter((n,a)=>{const o=r.some(u=>{const h=parseInt(u,10);return!isNaN(h)&&h-1===a}),l=n.name&&r.includes(n.name);return!(o||l)})}return s}function Xre(i){return i<=0?[]:Array.from({length:i},(e,t)=>{const s=i-t;return{draw:(r,n,a)=>{r.save(),r.fillStyle="black",r.font=`bold ${Math.min(n,a)*.02*2}px sans-serif`,r.textAlign="center",r.textBaseline="middle",r.fillText(s.toString(),n/2,a/2),r.restore()},displayDuration:1e3,ignoreData:!0}})}function P2(i){return`user_${i}`}function Xh(i){const e=[],t={};let s=0;function r(l){return`${l}_auto_${s++}`}function n(l){return(u,h)=>l(h,u)}function a(l){return(u,h)=>{const c=l(h,u);return typeof c=="object"&&c!==null?{...u,...c}:(console.warn("Store update function did not return an object. Store remains unchanged.",{data:h,store:u}),u)}}function o(l){for(const u of l){let h=!1;if(typeof u=="object"&&u!==null&&"type"in u)switch(u.type){case"MARKER":{const d=u;t[P2(d.id)]=e.length,h=!0;break}case"IF_GOTO":{const d=u,f=n(d.cond);e.push({type:"IfGoto",cond:f,marker:P2(d.marker)}),h=!0;break}case"UPDATE_STORE":{const f=a(u.fun);e.push({type:"UpdateStore",fun:f}),h=!0;break}case"IF_BLOCK":{const d=u,f=r("if_end"),y=n(d.cond);e.push({type:"IfGoto",cond:(v,m)=>!y(v,m),marker:f}),o(d.timeline),t[f]=e.length,h=!0;break}case"WHILE_BLOCK":{const d=u,f=r("while_start"),y=r("while_end"),v=n(d.cond);t[f]=e.length,e.push({type:"IfGoto",cond:(m,g)=>!v(m,g),marker:y}),o(d.timeline),e.push({type:"IfGoto",cond:()=>!0,marker:f}),t[y]=e.length,h=!0;break}}h||e.push({type:"ExecuteContent",content:u})}}return o(i),{instructions:e,markers:t}}function ec(i,e,t,s){const r=typeof e.metadata=="function"?e.metadata(t,s):e.metadata;return e.nestMetadata?{...i,metadata:r}:r?{...r,...i}:i}function In(i,e,t,s,r){let n=e;for(;n<i.instructions.length;){const a=i.instructions[n];switch(a.type){case"ExecuteContent":return n;case"IfGoto":if(a.cond(t(),s())){const o=i.markers[a.marker];if(o!==void 0){n=o;continue}}n++;break;case"UpdateStore":r(a.fun(t(),s())),n++;break;default:n++}}return n}const ym={};function Qs(i,e,t){ym[i]={simulate:e,defaultSimulators:t}}function ene(i){return ym[i]}const ho=(i,e,t,s)=>({responseData:{},participantState:s});function Cm(i,e,t){const s=typeof i.props=="function"?i.props(e,t):i.props||{},r=ym[i.type],n=typeof i.simulate=="function"?i.simulate:r==null?void 0:r.simulate;if(!n)throw new Error(`No simulation registered for trial type '${i.type}' (name: '${i.name??"unnamed"}'). Register one with registerSimulation() or add a simulate function to the timeline item.`);const a={...r==null?void 0:r.defaultSimulators,...i.simulators};return{trialProps:s,simulateFn:n,simulators:a}}let I2="http://localhost:8001/backend";function tne(i){I2=i}function R2(){return I2}let A2;function L2(){return A2}async function sne(i,e){A2={...e};let t={...e};const s=Xh(i);let r={};const n=[{index:-1,trialNumber:-1,start:0,end:0,duration:0,type:"",name:"",responseData:{userAgent:"simulated",params:{}}}],a=()=>r,o=()=>n,l=d=>{r=d};let u=0,h=0,c=In(s,0,a,o,l);for(;c<s.instructions.length;){const d=s.instructions[c].content;if(typeof d!="object"||d===null||typeof d.type!="string"){c=In(s,c+1,a,o,l);continue}const{trialProps:f,simulateFn:y,simulators:v}=Cm(d,n,r),m=await y(f,{data:n,store:r},v,t);t=m.participantState,m.storeUpdates&&(r={...r,...m.storeUpdates}),u++;const g=m.duration??0,b=h;h+=g;let x={index:c,trialNumber:u,start:b,end:h,duration:g,type:d.type,name:d.name??"",...d.csv!==void 0?{csv:d.csv}:{},responseData:m.responseData};n.push(ec(x,d,n,r)),c=In(s,c+1,a,o,l)}return n}async function ine(i,e){const{spawn:t}=await import("child_process"),s=i.backendPort??8001,r=`http://localhost:${s}/backend`,n=typeof i.participants=="function"?i.participants().length:Array.isArray(i.participants)?i.participants.length:i.participants.count,a=t("npx",["tsx","src/backend.ts"],{cwd:"./backend",stdio:["ignore","pipe","pipe"]});await new Promise((o,l)=>{var u,h;a.on("error",l),(u=a.stdout)==null||u.on("data",c=>{c.toString().includes("REACTIVE_BACKEND_READY")&&o()}),(h=a.stderr)==null||h.on("data",c=>{console.error(`[backend] ${c.toString().trim()}`)}),setTimeout(()=>l(new Error("Backend did not start within 10 seconds")),1e4)}),console.log(`Backend running on port ${s}`);try{const o=i.concurrency??(await import("os")).cpus().length;console.log(`Simulating ${n} participants (concurrency: ${o})...`);let l=0;const u=[],h=()=>{const f=Math.min(100,Math.round(l/n*100)),y=Math.floor(f/2),v="█".repeat(y)+"░".repeat(50-y);process.stdout.write(`\r ${v} ${l}/${n} (${f}%)`)},c=f=>new Promise(y=>{var g;let v="";const m=t("npx",["tsx",e],{env:{...process.env,_REACTIVE_WORKER_INDEX:String(f),_REACTIVE_BACKEND_URL:r,...i.seed!==void 0?{_REACTIVE_SIMULATION_SEED:String(i.seed)}:{}},stdio:["ignore","pipe","pipe"]});(g=m.stderr)==null||g.on("data",b=>{v+=b.toString()}),m.on("close",b=>{b!==0&&u.push({index:f,error:v.trim()||`exited with code ${b}`}),l++,h(),y()}),m.on("error",b=>{u.push({index:f,error:b.message}),l++,h(),y()})});h();let d=0;if(await new Promise(f=>{const y=()=>{if(d>=n){l>=n&&f();return}const v=d++;c(v).then(y)};for(let v=0;v<Math.min(o,n);v++)y()}),process.stdout.write(`
10148
+ */var Ire=it,d2=Cre,Rre=Pre;Ire(d2,"factory",Rre);var Are=d2;const Lre=za(Are),Ts=new Uint32Array(1);function _re(i){return Ts[0]=i,Ts[0]=(Ts[0]<<16|Ts[0]>>16)>>>0,Ts[0]=(Ts[0]&1431655765)<<1|(Ts[0]&2863311530)>>>1>>>0,Ts[0]=(Ts[0]&858993459)<<2|(Ts[0]&3435973836)>>>2>>>0,Ts[0]=(Ts[0]&252645135)<<4|(Ts[0]&4042322160)>>>4>>>0,Ts[0]=(Ts[0]&16711935)<<8|(Ts[0]&4278255360)>>>8>>>0,Ts[0]*23283064365386963e-26}function Dre(i,e){let t=1,s=0;for(;i>0;)t/=e,s+=t*(i%e),i=~~(i/e);return s}const kre=(i,e=[2,3])=>Array.from({length:i},(t,s)=>e.map(r=>r===2?_re(s):Dre(s,r)));X.normal=qC,X.poisson=db,X.uniform=Vb;function Ore(i){const e=LB.factory({seed:i});X.normal=qC.factory({prng:e.normalized}),X.poisson=db.factory({prng:e.normalized}),X.uniform=Vb.factory({prng:e.normalized}),Math.random=()=>X.uniform(0,1)}function p2(i){return Math.max(1e-10,Math.min(1-1e-10,i))}function f2(i){switch(i.distribution){case"uniform":return e=>i.min+e*(i.max-i.min);case"normal":return e=>UK(p2(e),i.mean,i.sd);case"poisson":return e=>Lre(p2(e),i.mean)}}function m2(i,e){const t=e.map(f2);return e.length===1?i.map(s=>t[0](s[0])):i.map(s=>s.map((r,n)=>t[n](r)))}const Mre=[[1,0,[1]],[2,1,[1,1]],[3,1,[1,3,7]],[3,2,[1,1,5]],[4,1,[1,3,1,1]],[4,4,[1,1,3,7]],[5,2,[1,3,3,9,9]],[5,13,[1,3,7,13,3]],[5,7,[1,1,5,11,27]],[5,14,[1,3,5,1,15]],[5,11,[1,1,7,3,29]],[5,4,[1,3,7,7,21]],[6,1,[1,1,1,9,23,37]],[6,16,[1,3,3,5,19,33]],[6,13,[1,1,3,13,11,7]],[6,22,[1,1,7,13,25,5]],[6,19,[1,3,5,11,7,11]],[6,25,[1,1,1,3,13,39]],[7,1,[1,3,1,15,17,63,13]],[7,32,[1,1,5,5,1,59,33]]],oo=32,Nre=2**oo;function Fre(i){const e=new Uint32Array(oo);if(i===0){for(let n=0;n<oo;n++)e[n]=1<<oo-1-n;return e}const[t,s,r]=Mre[i-1];for(let n=0;n<t;n++)e[n]=r[n]<<oo-1-n;for(let n=t;n<oo;n++){e[n]=e[n-t]^e[n-t]>>>t;for(let a=1;a<t;a++)s>>>t-1-a&1&&(e[n]^=e[n-a])}return e}function qre(i,e){if(e<1||e>21)throw new RangeError("sobol() supports 1-21 dimensions");const t=Array.from({length:e},(n,a)=>Fre(a)),s=new Uint32Array(e),r=[new Array(e).fill(0)];for(let n=1;n<i;n++){let a=0,o=n-1;for(;(o&1)===1;)o>>>=1,a++;for(let l=0;l<e;l++)s[l]^=t[l][a];r.push(Array.from(s,l=>l/Nre))}return r}const Bre=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73],g2=6;function v2(i,e){const t=qre(i+1,e.length).slice(1);return m2(t,e)}function y2(i,e){e.length>g2&&console.warn(`Halton sequence quality degrades above ${g2} dimensions. Consider using sobol() instead.`);const t=Bre.slice(0,e.length),s=kre(i+1,t).slice(1);return m2(s,e)}function $re(i,e,t){const s=Object.keys(t),r=s.map(a=>t[a]);let n;switch(i){case"sobol":n=v2(e,r);break;case"halton":n=y2(e,r);break;case"random":n=Hre(e,r);break}return Array.from({length:e},(a,o)=>{const l=s.length===1?[n[o]]:n[o];return Object.fromEntries(s.map((u,h)=>[u,l[h]]))})}function Hre(i,e){const t=e.map(f2);return e.length===1?Array.from({length:i},()=>t[0](X.uniform(0,1))):Array.from({length:i},()=>t.map(s=>s(X.uniform(0,1))))}function C2(i,e=1){const t=[];if(i.length===0)return t;for(let s=0;s<e;s++){const r=Math.floor(X.uniform(0,1)*i.length);t.push(i[r])}return t}function fm(i){const e=[...i];for(let t=e.length-1;t>=0;t--){const s=Math.floor(X.uniform(0,1)*(t+1));[e[t],e[s]]=[e[s],e[t]]}return e}function b2(i,e){return e(i)}function w2(i,e){const t=Math.ceil(i.length/e);return Array.from({length:Math.ceil(i.length/t)},(s,r)=>i.slice(r*t,r*t+t))}function Qre(){typeof Array.prototype.sample!="function"&&(Array.prototype.sample=function(i){return C2(this,i)}),typeof Array.prototype.shuffle!="function"&&(Array.prototype.shuffle=function(){return fm(this)}),typeof Array.prototype.pipe!="function"&&(Array.prototype.pipe=function(i){return b2(this,i)}),typeof Array.prototype.chunk!="function"&&(Array.prototype.chunk=function(i){return w2(this,i)})}/*! Capacitor: https://capacitorjs.com/ - MIT License */var lo;(function(i){i.Unimplemented="UNIMPLEMENTED",i.Unavailable="UNAVAILABLE"})(lo||(lo={}));class mm extends Error{constructor(e,t,s){super(e),this.message=e,this.code=t,this.data=s}}const Ure=i=>{var e,t;return i!=null&&i.androidBridge?"android":!((t=(e=i==null?void 0:i.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||t===void 0)&&t.bridge?"ios":"web"},zre=i=>{const e=i.CapacitorCustomPlatform||null,t=i.Capacitor||{},s=t.Plugins=t.Plugins||{},r=()=>e!==null?e.name:Ure(i),n=()=>r()!=="web",a=c=>{const d=u.get(c);return!!(d!=null&&d.platforms.has(r())||o(c))},o=c=>{var d;return(d=t.PluginHeaders)===null||d===void 0?void 0:d.find(f=>f.name===c)},l=c=>i.console.error(c),u=new Map,h=(c,d={})=>{const f=u.get(c);if(f)return console.warn(`Capacitor plugin "${c}" already registered. Cannot register plugins twice.`),f.proxy;const y=r(),v=o(c);let m;const g=async()=>(!m&&y in d?m=typeof d[y]=="function"?m=await d[y]():m=d[y]:e!==null&&!m&&"web"in d&&(m=typeof d.web=="function"?m=await d.web():m=d.web),m),b=(T,k)=>{var q,B;if(v){const U=v==null?void 0:v.methods.find(D=>k===D.name);if(U)return U.rtype==="promise"?D=>t.nativePromise(c,k.toString(),D):(D,H)=>t.nativeCallback(c,k.toString(),D,H);if(T)return(q=T[k])===null||q===void 0?void 0:q.bind(T)}else{if(T)return(B=T[k])===null||B===void 0?void 0:B.bind(T);throw new mm(`"${c}" plugin is not implemented on ${y}`,lo.Unimplemented)}},x=T=>{let k;const q=(...B)=>{const U=g().then(D=>{const H=b(D,T);if(H){const Q=H(...B);return k=Q==null?void 0:Q.remove,Q}else throw new mm(`"${c}.${T}()" is not implemented on ${y}`,lo.Unimplemented)});return T==="addListener"&&(U.remove=async()=>k()),U};return q.toString=()=>`${T.toString()}() { [capacitor code] }`,Object.defineProperty(q,"name",{value:T,writable:!1,configurable:!1}),q},P=x("addListener"),R=x("removeListener"),A=(T,k)=>{const q=P({eventName:T},k),B=async()=>{const D=await q;R({eventName:T,callbackId:D},k)},U=new Promise(D=>q.then(()=>D({remove:B})));return U.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await B()},U},_=new Proxy({},{get(T,k){switch(k){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return v?A:P;case"removeListener":return R;default:return x(k)}}});return s[c]=_,u.set(c,{name:c,proxy:_,platforms:new Set([...Object.keys(d),...v?[y]:[]])}),_};return t.convertFileSrc||(t.convertFileSrc=c=>c),t.getPlatform=r,t.handleError=l,t.isNativePlatform=n,t.isPluginAvailable=a,t.registerPlugin=h,t.Exception=mm,t.DEBUG=!!t.DEBUG,t.isLoggingEnabled=!!t.isLoggingEnabled,t},fa=(i=>i.Capacitor=zre(i))(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),_l=fa.registerPlugin;class Zh{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,t){let s=!1;this.listeners[e]||(this.listeners[e]=[],s=!0),this.listeners[e].push(t);const n=this.windowListeners[e];n&&!n.registered&&this.addWindowListener(n),s&&this.sendRetainedArgumentsForEvent(e);const a=async()=>this.removeListener(e,t);return Promise.resolve({remove:a})}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,t,s){const r=this.listeners[e];if(!r){if(s){let n=this.retainedEventArguments[e];n||(n=[]),n.push(t),this.retainedEventArguments[e]=n}return}r.forEach(n=>n(t))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:s=>{this.notifyListeners(t,s)}}}unimplemented(e="not implemented"){return new fa.Exception(e,lo.Unimplemented)}unavailable(e="not available"){return new fa.Exception(e,lo.Unavailable)}async removeListener(e,t){const s=this.listeners[e];if(!s)return;const r=s.indexOf(t);this.listeners[e].splice(r,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){const t=this.retainedEventArguments[e];t&&(delete this.retainedEventArguments[e],t.forEach(s=>{this.notifyListeners(e,s)}))}}const x2=i=>encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),E2=i=>i.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class jre extends Zh{async getCookies(){const e=document.cookie,t={};return e.split(";").forEach(s=>{if(s.length<=0)return;let[r,n]=s.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");r=E2(r).trim(),n=E2(n).trim(),t[r]=n}),t}async setCookie(e){try{const t=x2(e.key),s=x2(e.value),r=`; expires=${(e.expires||"").replace("expires=","")}`,n=(e.path||"/").replace("path=",""),a=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${t}=${s||""}${r}; path=${n}; ${a};`}catch(t){return Promise.reject(t)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(t){return Promise.reject(t)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const t of e)document.cookie=t.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}_l("CapacitorCookies",{web:()=>new jre});const Wre=async i=>new Promise((e,t)=>{const s=new FileReader;s.onload=()=>{const r=s.result;e(r.indexOf(",")>=0?r.split(",")[1]:r)},s.onerror=r=>t(r),s.readAsDataURL(i)}),Gre=(i={})=>{const e=Object.keys(i);return Object.keys(i).map(r=>r.toLocaleLowerCase()).reduce((r,n,a)=>(r[n]=i[e[a]],r),{})},Kre=(i,e=!0)=>i?Object.entries(i).reduce((s,r)=>{const[n,a]=r;let o,l;return Array.isArray(a)?(l="",a.forEach(u=>{o=e?encodeURIComponent(u):u,l+=`${n}=${o}&`}),l.slice(0,-1)):(o=e?encodeURIComponent(a):a,l=`${n}=${o}`),`${s}&${l}`},"").substr(1):null,V2=(i,e={})=>{const t=Object.assign({method:i.method||"GET",headers:i.headers},e),r=Gre(i.headers)["content-type"]||"";if(typeof i.data=="string")t.body=i.data;else if(r.includes("application/x-www-form-urlencoded")){const n=new URLSearchParams;for(const[a,o]of Object.entries(i.data||{}))n.set(a,o);t.body=n.toString()}else if(r.includes("multipart/form-data")||i.data instanceof FormData){const n=new FormData;if(i.data instanceof FormData)i.data.forEach((o,l)=>{n.append(l,o)});else for(const o of Object.keys(i.data))n.append(o,i.data[o]);t.body=n;const a=new Headers(t.headers);a.delete("content-type"),t.headers=a}else(r.includes("application/json")||typeof i.data=="object")&&(t.body=JSON.stringify(i.data));return t};class Zre extends Zh{async request(e){const t=V2(e,e.webFetchExtra),s=Kre(e.params,e.shouldEncodeUrlParams),r=s?`${e.url}?${s}`:e.url,n=await fetch(r,t),a=n.headers.get("content-type")||"";let{responseType:o="text"}=n.ok?e:{};a.includes("application/json")&&(o="json");let l,u;switch(o){case"arraybuffer":case"blob":u=await n.blob(),l=await Wre(u);break;case"json":l=await n.json();break;case"document":case"text":default:l=await n.text()}const h={};return n.headers.forEach((c,d)=>{h[d]=c}),{data:l,headers:h,status:n.status,url:n.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}_l("CapacitorHttp",{web:()=>new Zre});function Ps(){return Math.round(performance.now())}function uo(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}function Jre(){return window.electronAPI!==void 0}const Jh=[];function ma(i,e,t="string",s,r){let n=Jh.find(d=>d.name===i);n||(n={name:i,defaultValue:r!==void 0?r:e,type:t,description:s,value:void 0},Jh.push(n));const a={string:d=>d,number:d=>{const f=Number(d);return isNaN(f)?e:f},boolean:d=>d.toLowerCase()==="true",array:d=>{try{return JSON.parse(d)}catch{return e}},json:d=>{try{return JSON.parse(d)}catch{return e}}},o=d=>t==="string"&&typeof d=="string"||t==="number"&&typeof d=="number"||t==="boolean"&&typeof d=="boolean"||t==="array"&&Array.isArray(d)||t==="json"&&typeof d=="object"&&d!==null?d:typeof d=="string"?d.toLowerCase()==="undefined"?e:a[t](d):e,l=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams,u=l.get("_b");if(u)try{const d=atob(u),f=JSON.parse(d);if(i in f){const y=o(f[i]);return n.value=y,y}}catch{}const h=l.get(i);if(h==null)return e;const c=o(h);return n.value=c,c}const gm=[];class Yh{static getRegistry(){return[...Jh]}static getTimelineRepresentation(){return[...gm]}}const Dl=()=>window.electronAPI?"desktop":fa.isNativePlatform()?"mobile":"web",S2={};function T2(i){i.forEach(e=>{const t=S2[e.type];if(t)for(const s of t)(!e.hideSettings||e.hideSettings!==!0&&!e.hideSettings.includes(s.name))&&Jh.push(s)})}function vm(i,e){S2[i]=e}function Yre(i){T2(i),gm.length=0,i.forEach(r=>{gm.push({type:r.type??"NoTypeSpecified",name:r.name})});const e=ma("includeSubset",void 0),t=ma("excludeSubset",void 0);let s=[...i];if(e){const r=e.split(",");s=s.filter((n,a)=>{const o=r.some(u=>{const h=parseInt(u,10);return!isNaN(h)&&h-1===a}),l=n.name&&r.includes(n.name);return o||l})}if(t){const r=t.split(",");s=s.filter((n,a)=>{const o=r.some(u=>{const h=parseInt(u,10);return!isNaN(h)&&h-1===a}),l=n.name&&r.includes(n.name);return!(o||l)})}return s}function Xre(i){return i<=0?[]:Array.from({length:i},(e,t)=>{const s=i-t;return{draw:(r,n,a)=>{r.save(),r.fillStyle="black",r.font=`bold ${Math.min(n,a)*.02*2}px sans-serif`,r.textAlign="center",r.textBaseline="middle",r.fillText(s.toString(),n/2,a/2),r.restore()},displayDuration:1e3,ignoreData:!0}})}function P2(i){return`user_${i}`}function Xh(i){const e=[],t={};let s=0;function r(l){return`${l}_auto_${s++}`}function n(l){return(u,h)=>l(h,u)}function a(l){return(u,h)=>{const c=l(h,u);return typeof c=="object"&&c!==null?{...u,...c}:(console.warn("Store update function did not return an object. Store remains unchanged.",{data:h,store:u}),u)}}function o(l){for(const u of l){let h=!1;if(typeof u=="object"&&u!==null&&"type"in u)switch(u.type){case"MARKER":{const d=u;t[P2(d.id)]=e.length,h=!0;break}case"IF_GOTO":{const d=u,f=n(d.cond);e.push({type:"IfGoto",cond:f,marker:P2(d.marker)}),h=!0;break}case"UPDATE_STORE":{const f=a(u.fun);e.push({type:"UpdateStore",fun:f}),h=!0;break}case"IF_BLOCK":{const d=u,f=r("if_end"),y=n(d.cond);e.push({type:"IfGoto",cond:(v,m)=>!y(v,m),marker:f}),o(d.timeline),t[f]=e.length,h=!0;break}case"WHILE_BLOCK":{const d=u,f=r("while_start"),y=r("while_end"),v=n(d.cond);t[f]=e.length,e.push({type:"IfGoto",cond:(m,g)=>!v(m,g),marker:y}),o(d.timeline),e.push({type:"IfGoto",cond:()=>!0,marker:f}),t[y]=e.length,h=!0;break}}h||e.push({type:"ExecuteContent",content:u})}}return o(i),{instructions:e,markers:t}}function ec(i,e,t,s){const r=typeof e.metadata=="function"?e.metadata(t,s):e.metadata;return e.nestMetadata?{...i,metadata:r}:r?{...r,...i}:i}function In(i,e,t,s,r){let n=e;for(;n<i.instructions.length;){const a=i.instructions[n];switch(a.type){case"ExecuteContent":return n;case"IfGoto":if(a.cond(t(),s())){const o=i.markers[a.marker];if(o!==void 0){n=o;continue}}n++;break;case"UpdateStore":r(a.fun(t(),s())),n++;break;default:n++}}return n}const ym={};function Qs(i,e,t){ym[i]={simulate:e,defaultSimulators:t}}function ene(i){return ym[i]}const ho=(i,e,t,s)=>({responseData:{},participantState:s});function Cm(i,e,t){const s=typeof i.props=="function"?i.props(e,t):i.props||{},r=ym[i.type],n=typeof i.simulate=="function"?i.simulate:r==null?void 0:r.simulate;if(!n)throw new Error(`No simulation registered for trial type '${i.type}' (name: '${i.name??"unnamed"}'). Register one with registerSimulation() or add a simulate function to the timeline item.`);const a={...r==null?void 0:r.defaultSimulators,...i.simulators};return{trialProps:s,simulateFn:n,simulators:a}}let I2="http://localhost:8001/backend";function tne(i){I2=i}function R2(){return I2}let A2;function L2(){return A2}async function sne(i,e){A2={...e};let t={...e};const s=Xh(i);let r={};const n=[{index:-1,trialNumber:-1,start:0,end:0,duration:0,type:"",name:"",responseData:{userAgent:"simulated",params:{}}}],a=()=>r,o=()=>n,l=d=>{r=d};let u=0,h=0,c=In(s,0,a,o,l);for(;c<s.instructions.length;){const d=s.instructions[c].content;if(typeof d!="object"||d===null||typeof d.type!="string"){c=In(s,c+1,a,o,l);continue}const{trialProps:f,simulateFn:y,simulators:v}=Cm(d,n,r),m=await y(f,{data:n,store:r},v,t);t=m.participantState,m.storeUpdates&&(r={...r,...m.storeUpdates}),u++;const g=m.duration??0,b=h;h+=g;let x={index:c,trialNumber:u,start:b,end:h,duration:g,type:d.type,name:d.name??"",...d.csv!==void 0?{csv:d.csv}:{},responseData:m.responseData};n.push(ec(x,d,n,r)),c=In(s,c+1,a,o,l)}return n}async function ine(i,e){const{spawn:t}=await import("child_process"),s=i.backendPort??8001,r=`http://localhost:${s}/backend`,n=typeof i.participants=="function"?i.participants().length:Array.isArray(i.participants)?i.participants.length:i.participants.count,a=t("npx",["tsx","src/backend.ts"],{cwd:"./backend",stdio:["ignore","pipe","pipe"]});await new Promise((o,l)=>{var u,h;a.on("error",l),(u=a.stdout)==null||u.on("data",c=>{c.toString().includes("REACTIVE_BACKEND_READY")&&o()}),(h=a.stderr)==null||h.on("data",c=>{console.error(`[backend] ${c.toString().trim()}`)}),setTimeout(()=>l(new Error("Backend did not start within 10 seconds")),1e4)}),console.log(`Backend running on port ${s}`);try{const o=i.concurrency??(await import("os")).cpus().length;console.log(`Simulating ${n} participants (concurrency: ${o})...`);let l=0;const u=[],h=()=>{const f=Math.min(100,Math.round(l/n*100)),y=Math.floor(f/2),v="█".repeat(y)+"░".repeat(50-y);process.stdout.write(`\r ${v} ${l}/${n} (${f}%)`)},c=f=>new Promise(y=>{var g;let v="";const m=t("npx",["tsx",e],{env:{...process.env,_REACTIVE_WORKER_INDEX:String(f),_REACTIVE_BACKEND_URL:r,...i.seed!==void 0?{_REACTIVE_SIMULATION_SEED:String(i.seed)}:{}},stdio:["ignore","pipe","pipe"]});(g=m.stderr)==null||g.on("data",b=>{v+=b.toString()}),m.on("close",b=>{b!==0&&u.push({index:f,error:v.trim()||`exited with code ${b}`}),l++,h(),y()}),m.on("error",b=>{u.push({index:f,error:b.message}),l++,h(),y()})});h();let d=0;if(await new Promise(f=>{const y=()=>{if(d>=n){l>=n&&f();return}const v=d++;c(v).then(y)};for(let v=0;v<Math.min(o,n);v++)y()}),process.stdout.write(`
10149
10149
  `),u.length>0){console.error(`
10150
10150
  ${u.length} participant(s) failed:`);for(const{index:f,error:y}of u)console.error(` Participant ${f}: ${y}`)}console.log(`Simulation complete. ${l-u.length}/${n} participants simulated successfully.`)}finally{a.kill(),console.log("Backend stopped.")}}const tc={};function ni(i,e,t){tc[i]||(tc[i]=[]),tc[i].push({csv:e,flatten:t})}function _2(i){const e=i.responseData;return Array.isArray(e)?e.map(t=>({block:i.name,...t})):[]}function D2(i){if(i==null)return"";const e=String(i);return e.includes(",")||e.includes('"')||e.includes(`
10151
10151
  `)?`"${e.replace(/"/g,'""')}"`:e}function sc(i){if(!i||i.length===0)return"";const e=new Set;i.forEach(n=>{Object.keys(n).forEach(a=>{e.add(a)})});const t=Array.from(e),s=t.map(n=>D2(n)).join(","),r=i.map(n=>t.map(a=>{const o=n[a];return D2(o)}).join(","));return[s,...r].join(`
@@ -1,4 +1,4 @@
1
- import { W as P, b as x, E } from "./mod-DHUjIRfF.js";
1
+ import { W as P, b as x, E } from "./mod-BPE3lXMa.js";
2
2
  function m(w) {
3
3
  const e = w.split("/").filter((t) => t !== "."), r = [];
4
4
  return e.forEach((t) => {
@@ -1,4 +1,4 @@
1
- import { W as e } from "./mod-DHUjIRfF.js";
1
+ import { W as e } from "./mod-BPE3lXMa.js";
2
2
  class s extends e {
3
3
  async enable() {
4
4
  console.log("Immersive mode is only available on Android");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adriansteffan/reactive",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -128,7 +128,8 @@ export function getParam<T extends ParamType>(
128
128
  };
129
129
 
130
130
  // First, check for the parameter in the base64-encoded JSON
131
- const encodedJson = new URLSearchParams(window.location.search).get('_b');
131
+ const searchParams = typeof window !== 'undefined' ? new URLSearchParams(window.location.search) : new URLSearchParams();
132
+ const encodedJson = searchParams.get('_b');
132
133
  if (encodedJson) {
133
134
  try {
134
135
  const jsonString = atob(encodedJson);
@@ -144,7 +145,7 @@ export function getParam<T extends ParamType>(
144
145
  }
145
146
 
146
147
  // Next, check for the parameter directly in the URL
147
- const value = new URLSearchParams(window.location.search).get(name);
148
+ const value = searchParams.get(name);
148
149
  if (value === undefined || value === null) {
149
150
  // If no value found, register default value
150
151
  return defaultValue;