"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var o=(e,t)=>{for(var s in t)a(e,s,{get:t[s],enumerable:!0})},c=(e,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of n(t))!u.call(e,i)&&i!==s&&a(e,i,{get:()=>t[i],enumerable:!(r=b(t,i))||r.enumerable});return e};var T=e=>c(a({},"__esModule",{value:!0}),e);var S={};o(S,{createState:()=>p});module.exports=T(S);function p(e){if(typeof e!="object"||e===null)throw new Error("Initial state is required to be an object or an array");return{state:e,subscribers:[],async setState(t){let s;typeof t=="function"?s=t(this.state):s=t,this.state=Object.assign({},this.state,s),await Promise.all(this.subscribers.map(r=>r(this.state)))},subscribe(t){this.subscribers.push(t)},unsubscribe(t){this.subscribers=this.subscribers.filter(s=>s!==t)}}}0&&(module.exports={createState});