@clockworkdog/cogs-client 3.0.0 → 3.0.1

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.
@@ -424,7 +424,7 @@ class Ne extends Event {
424
424
  }
425
425
  const Y = globalThis.Date;
426
426
  function en(e) {
427
- const t = e - Y.now();
427
+ const t = Math.round(e - Y.now());
428
428
  function n(...o) {
429
429
  return o.length === 0 ? new Y(n.now()) : new Y(...o);
430
430
  }
@@ -16,7 +16,7 @@
16
16
  * by Pedro Ladaria <pedro.ladaria@gmail.com>
17
17
  * https://github.com/pladaria/reconnecting-websocket
18
18
  * License MIT
19
- */var cn=function(){if(typeof WebSocket<"u")return WebSocket},un=function(e){return typeof e<"u"&&!!e&&e.CLOSING===2},D={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0},an=function(){function e(t,n,r){var o=this;r===void 0&&(r={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(s){o._debug("open event");var i=o._options.minUptime,c=i===void 0?D.minUptime:i;clearTimeout(o._connectTimeout),o._uptimeTimeout=setTimeout(function(){return o._acceptOpen()},c),o._ws.binaryType=o._binaryType,o._messageQueue.forEach(function(a){return o._ws.send(a)}),o._messageQueue=[],o.onopen&&o.onopen(s),o._listeners.open.forEach(function(a){return o._callEventListener(s,a)})},this._handleMessage=function(s){o._debug("message event"),o.onmessage&&o.onmessage(s),o._listeners.message.forEach(function(i){return o._callEventListener(s,i)})},this._handleError=function(s){o._debug("error event",s.message),o._disconnect(void 0,s.message==="TIMEOUT"?"timeout":void 0),o.onerror&&o.onerror(s),o._debug("exec error listeners"),o._listeners.error.forEach(function(i){return o._callEventListener(s,i)}),o._connect()},this._handleClose=function(s){o._debug("close event"),o._clearTimeouts(),o._shouldReconnect&&o._connect(),o.onclose&&o.onclose(s),o._listeners.close.forEach(function(i){return o._callEventListener(s,i)})},this._url=t,this._protocols=n,this._options=r,this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}return Object.defineProperty(e,"CONNECTING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OPEN",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSED",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CONNECTING",{get:function(){return e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"OPEN",{get:function(){return e.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSING",{get:function(){return e.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSED",{get:function(){return e.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryType",{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){var t=this._messageQueue.reduce(function(n,r){return typeof r=="string"?n+=r.length:r instanceof Blob?n+=r.size:n+=r.byteLength,n},0);return t+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this._ws?this._ws.extensions:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this._ws?this._ws.protocol:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._ws?this._ws.url:""},enumerable:!0,configurable:!0}),e.prototype.close=function(t,n){if(t===void 0&&(t=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,n)},e.prototype.reconnect=function(t,n){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,n),this._connect())},e.prototype.send=function(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{var n=this._options.maxEnqueuedMessages,r=n===void 0?D.maxEnqueuedMessages:n;this._messageQueue.length<r&&(this._debug("enqueue",t),this._messageQueue.push(t))}},e.prototype.addEventListener=function(t,n){this._listeners[t]&&this._listeners[t].push(n)},e.prototype.dispatchEvent=function(t){var n,r,o=this._listeners[t.type];if(o)try{for(var s=tn(o),i=s.next();!i.done;i=s.next()){var c=i.value;this._callEventListener(t,c)}}catch(a){n={error:a}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return!0},e.prototype.removeEventListener=function(t,n){this._listeners[t]&&(this._listeners[t]=this._listeners[t].filter(function(r){return r!==n}))},e.prototype._debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._options.debug&&console.log.apply(console,rn(["RWS>"],t))},e.prototype._getNextDelay=function(){var t=this._options,n=t.reconnectionDelayGrowFactor,r=n===void 0?D.reconnectionDelayGrowFactor:n,o=t.minReconnectionDelay,s=o===void 0?D.minReconnectionDelay:o,i=t.maxReconnectionDelay,c=i===void 0?D.maxReconnectionDelay:i,a=0;return this._retryCount>0&&(a=s*Math.pow(r,this._retryCount-1),a>c&&(a=c)),this._debug("next delay",a),a},e.prototype._wait=function(){var t=this;return new Promise(function(n){setTimeout(n,t._getNextDelay())})},e.prototype._getNextUrl=function(t){if(typeof t=="string")return Promise.resolve(t);if(typeof t=="function"){var n=t();if(typeof n=="string")return Promise.resolve(n);if(n.then)return n}throw Error("Invalid URL")},e.prototype._connect=function(){var t=this;if(!(this._connectLock||!this._shouldReconnect)){this._connectLock=!0;var n=this._options,r=n.maxRetries,o=r===void 0?D.maxRetries:r,s=n.connectionTimeout,i=s===void 0?D.connectionTimeout:s,c=n.WebSocket,a=c===void 0?cn():c;if(this._retryCount>=o){this._debug("max retries reached",this._retryCount,">=",o);return}if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),!un(a))throw Error("No valid WebSocket class provided");this._wait().then(function(){return t._getNextUrl(t._url)}).then(function(l){t._closeCalled||(t._debug("connect",{url:l,protocols:t._protocols}),t._ws=t._protocols?new a(l,t._protocols):new a(l),t._ws.binaryType=t._binaryType,t._connectLock=!1,t._addListeners(),t._connectTimeout=setTimeout(function(){return t._handleTimeout()},i))})}},e.prototype._handleTimeout=function(){this._debug("timeout event"),this._handleError(new on(Error("TIMEOUT"),this))},e.prototype._disconnect=function(t,n){if(t===void 0&&(t=1e3),this._clearTimeouts(),!!this._ws){this._removeListeners();try{this._ws.close(t,n),this._handleClose(new sn(t,n,this))}catch{}}},e.prototype._acceptOpen=function(){this._debug("accept open"),this._retryCount=0},e.prototype._callEventListener=function(t,n){"handleEvent"in n?n.handleEvent(t):n(t)},e.prototype._removeListeners=function(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))},e.prototype._addListeners=function(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))},e.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)},e}();const xe=12095;function Me(e){const t=typeof window<"u"?window.location:void 0,n=`/assets/${encodeURIComponent(e)}`;return`${t?.protocol}//${t?.hostname}:${xe}${n}`}async function ln(e){const t=await fetch(e);return URL.createObjectURL(new Blob([await t.arrayBuffer()]))}class hn{_items;#e=new EventTarget;constructor(t){this._items={...t}}handleDataStoreItemsMessage(t){this._items={...this._items,...t.items},Object.entries(t.items).forEach(([n,r])=>{this.dispatchEvent(new _e(n,r))}),this.dispatchEvent(new ge(t.items))}get items(){return this._items}getItem(t){return this._items[t]}setItems(t){return this._items={...this._items,...t},Object.entries(t).forEach(([n,r])=>{this.dispatchEvent(new _e(n,r))}),this.dispatchEvent(new ge(t)),this}addEventListener(t,n,r){this.#e.addEventListener(t,n,r)}removeEventListener(t,n,r){this.#e.removeEventListener(t,n,r)}dispatchEvent(t){this.#e.dispatchEvent(t)}}class _e extends Event{constructor(t,n){super("item"),this.key=t,this.value=n}_cogsConnectionEventType="item"}class ge extends Event{constructor(t){super("items"),this.items=t}_cogsConnectionEventType="item"}const q=globalThis.Date;function dn(e){const t=e-q.now();function n(...o){return o.length===0?new q(n.now()):new q(...o)}const r=Object.getOwnPropertyDescriptors(q);Object.defineProperties(n,r),n.now=function(){return q.now()+t},globalThis.Date=n}let fn=0;function pn(){return++fn}const mn=5,_n=1e4;function gn({interval:e,send:t,onChange:n=dn,syncSampleSize:r=mn,syncRequestTimeout:o=_n}){const s={};async function i(){const h=[];for(let m=0;m<r;m++){const E=new Promise(P=>{const Q=pn(),De=Date.now(),je=performance.now();t({timesync:{id:Q}});const O=(S,M)=>P({sentAt:je,receivedAt:S,serverNow:M,clientNow:De});s[Q]={complete:O},setTimeout(()=>P(null),o)});h.push(E),await E}const p=(await Promise.all(h)).filter(m=>m!==null),d=vn(p);isNaN(d)||n(Date.now()+d)}const c=h=>{const p=performance.now(),d=s[h.timesync.id];d&&d.complete(p,h.timesync.now)};i();const a=setInterval(i,e);return{receive:c,destroy:()=>{clearInterval(a)}}}function vn(e){return e.map(({sentAt:t,receivedAt:n,clientNow:r,serverNow:o})=>{const s=(n-t)/2;return o-r-s}).reduce((t,n)=>t+n,0)/e.length}class bn{constructor(t,{hostname:n=document.location.hostname,port:r=xe}={},o,s){this.manifest=t,this.currentState={...o},this.store=new hn(s??{});const{useReconnectingWebsocket:i,path:c,pathParams:a}=wn(document.location.href);this.urlParams=new URLSearchParams(a),this.urlParams.set("screenWidth",window.screen.width.toString()),this.urlParams.set("screenHeight",window.screen.height.toString()),this.urlParams.set("screenPixelRatio",window.devicePixelRatio.toString());const l=`ws://${n}:${r}${c}?${this.urlParams}`;this.websocket=i?new an(l):new WebSocket(l);let h;this.websocket.onopen=()=>{this.currentConfig={},this.currentState={},this.dispatchEvent(new Fe),this.setState(this.currentState),h=gn({interval:6e4,send:p=>{this.websocket.send(JSON.stringify(p))}})},this.websocket.addEventListener("message",({data:p})=>{try{const d=JSON.parse(p);if(typeof d=="object"&&d!==null&&"timesync"in d){const m=d;h?.receive(m)}}catch(d){console.error(d)}}),this.websocket.onclose=()=>{h?.destroy(),this.dispatchEvent(new Ke)},this.websocket.addEventListener("message",({data:p})=>{try{const d=JSON.parse(p);try{if(d.config)this.currentConfig=d.config,this.dispatchEvent(new We(this.currentConfig));else if(d.updates)this.currentState={...this.currentState,...d.updates},this.dispatchEvent(new Ge(d.updates));else if(d.event&&d.event.key)this.dispatchEvent(new Be(d.event.key,d.event.value));else if(typeof d.message=="object"){const m=d.message;switch(m.type){case"adjustable_timer_update":this._timerState={startedAt:Date.now(),durationMillis:m.durationMillis,ticking:m.ticking};break;case"show_phase":this._showPhase=m.phase,this.dispatchEvent(new He(m.phase));break;case"media_config_update":this._mediaConfig=m;for(const E of["preferOptimizedAudio","preferOptimizedVideo","preferOptimizedImages"])m[E]?this.urlParams.set(E,"true"):this.urlParams.delete(E);this.dispatchEvent(new Je(m));break;case"data_store_items":this.store.handleDataStoreItemsMessage(m);break}this.dispatchEvent(new Ve(m))}}catch(m){console.warn("Error handling data",p,m)}}catch(d){console.error("Unable to parse incoming data from server",p,d)}}),this.store.addEventListener("items",p=>{this.sendDataStoreItems(p.items)});{const p=async()=>{if(navigator.mediaDevices){const d=(await navigator.mediaDevices.enumerateDevices()).filter(({kind:m})=>m==="audiooutput");this.sendAudioOutputs(d),this.audioOutputs=d}};this.eventTarget.addEventListener("open",p),navigator.mediaDevices?.addEventListener("devicechange",p),p()}}websocket;eventTarget=new EventTarget;currentConfig={};get config(){return{...this.currentConfig}}currentState={};get state(){return{...this.currentState}}_showPhase=F.Setup;get showPhase(){return this._showPhase}_timerState=null;get timerState(){return this._timerState?{...this._timerState}:null}_mediaConfig=null;get mediaConfig(){return this._mediaConfig?{...this._mediaConfig}:null}getAssetUrl(t){return`${Me(t)}?${this.urlParams?.toString()??""}`}audioOutputs=void 0;_selectedAudioOutput="";get selectedAudioOutput(){return this._selectedAudioOutput}store;urlParams;get isConnected(){return this.websocket.readyState===WebSocket.OPEN}close(){this.websocket.close()}sendEvent(t,...[n]){this.isConnected&&this.websocket.send(JSON.stringify({event:{key:t,value:n}}))}setState(t){this.currentState={...this.currentState,...t},this.isConnected&&this.websocket.send(JSON.stringify({updates:t}))}getAudioSinkId(t){return t?this.audioOutputs?.find(({label:n})=>n===t)?.deviceId:""}sendAudioOutputs(t){this.isConnected&&this.websocket.send(JSON.stringify({audioOutputs:t}))}sendDataStoreItems(t){this.isConnected&&this.websocket.send(JSON.stringify({dataStoreItems:t}))}setPluginWindowVisible(t){this.isConnected&&this.websocket.send(JSON.stringify({window:{visible:t}}))}addEventListener(t,n,r){this.eventTarget.addEventListener(t,n,r)}removeEventListener(t,n,r){this.eventTarget.removeEventListener(t,n,r)}dispatchEvent(t){this.eventTarget.dispatchEvent(t)}}function wn(e){const t=new URL(e),n=new URLSearchParams(t.searchParams),r=n.get("local_id"),o=n.get("simulator")==="true",s=n.get("display")??"",i=t.pathname.startsWith("/plugin/")?decodeURIComponent(t.pathname.split("/")[2]):void 0;if(r){const c=n.get("t")??"";return n.delete("local_id"),{path:`/local/${encodeURIComponent(r)}`,pathParams:new URLSearchParams({t:c}),useReconnectingWebsocket:!0}}else if(o){const c=n.get("name")??"";return n.delete("simulator"),n.delete("name"),{path:`/simulator/${encodeURIComponent(c)}`,pathParams:n,useReconnectingWebsocket:!0}}else if(s){const c=n.get("displayIdIndex")??"";return n.delete("display"),n.delete("displayIdIndex"),{path:`/display/${encodeURIComponent(s)}/${encodeURIComponent(c)}`}}else{if(i)return{path:`/plugin/${encodeURIComponent(i)}`,useReconnectingWebsocket:!0};{const c=n.get("serial")??"";return n.delete("serial"),{path:`/client/${encodeURIComponent(c)}`,pathParams:n}}}}class Fe extends Event{_cogsConnectionEventType="open";constructor(){super("open")}}class Ke extends Event{_cogsConnectionEventType="close";constructor(){super("close")}}class Ve extends Event{constructor(t){super("message"),this.message=t}_cogsConnectionEventType="message"}class We extends Event{constructor(t){super("config"),this.config=t}_cogsConnectionEventType="config"}class Ge extends Event{constructor(t){super("state"),this.state=t}_cogsConnectionEventType="state"}class Be extends Event{constructor(t,n){super("event"),this.name=t,this.value=n}_cogsConnectionEventType="event"}class Je extends Event{constructor(t){super("mediaConfig"),this.mediaConfig=t}_cogsConnectionEventType="mediaConfig"}class He extends Event{constructor(t){super("showPhase"),this.showPhase=t}_cogsConnectionEventType="showPhase"}function u(e,t,n){function r(c,a){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:a,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);const l=i.prototype,h=Object.keys(l);for(let p=0;p<h.length;p++){const d=h[p];d in c||(c[d]=l[d].bind(c))}}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var a;const l=n?.Parent?new s:this;r(l,c),(a=l._zod).deferred??(a.deferred=[]);for(const h of l._zod.deferred)h();return l}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class K extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ye extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const qe={};function A(e){return qe}function yn(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ve(e,t){return typeof t=="bigint"?t.toString():t}function be(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function we(e){return e==null}function ye(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function kn(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const a=r.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}const s=n>o?n:o,i=Number.parseInt(e.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return i%c/10**s}const Xe=Symbol("evaluating");function _(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Xe)return r===void 0&&(r=Xe,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function j(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function L(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Qe(e){return JSON.stringify(e)}function En(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const et="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ee(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const zn=be(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function V(e){if(ee(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ee(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function tt(e){return V(e)?{...e}:Array.isArray(e)?[...e]:e}const $n=new Set(["string","number","symbol"]);function W(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function R(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function f(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Zn(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Sn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function On(e,t){const n=e._zod.def,r=L(e._zod.def,{get shape(){const o={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(o[s]=n.shape[s])}return j(this,"shape",o),o},checks:[]});return R(e,r)}function Tn(e,t){const n=e._zod.def,r=L(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete o[s]}return j(this,"shape",o),o},checks:[]});return R(e,r)}function In(e,t){if(!V(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const o=L(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return j(this,"shape",s),s},checks:[]});return R(e,o)}function Cn(e,t){if(!V(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return j(this,"shape",r),r},checks:e._zod.def.checks};return R(e,n)}function Pn(e,t){const n=L(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return j(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return R(e,n)}function An(e,t,n){const r=L(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=e?new e({type:"optional",innerType:o[i]}):o[i])}else for(const i in o)s[i]=e?new e({type:"optional",innerType:o[i]}):o[i];return j(this,"shape",s),s},checks:[]});return R(t,r)}function Rn(e,t,n){const r=L(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return j(this,"shape",s),s},checks:[]});return R(t,r)}function G(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function U(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function te(e){return typeof e=="string"?e:e?.message}function N(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=te(e.inst?._zod.def?.error?.(e))??te(t?.error?.(e))??te(n.customError?.(e))??te(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function ke(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function X(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const nt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},rt=u("$ZodError",nt),ot=u("$ZodError",nt,{Parent:Error});function Nn(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Dn(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>r({issues:i}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,c=0;for(;c<s.path.length;){const a=s.path[c];c===s.path.length-1?(i[a]=i[a]||{_errors:[]},i[a]._errors.push(t(s))):i[a]=i[a]||{_errors:[]},i=i[a],c++}}};return r(e),n}const Ee=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new K;if(i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>N(a,s,A())));throw et(c,o?.callee),c}return i.value},ze=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>N(a,s,A())));throw et(c,o?.callee),c}return i.value},ne=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new K;return s.issues.length?{success:!1,error:new(e??rt)(s.issues.map(i=>N(i,o,A())))}:{success:!0,data:s.value}},jn=ne(ot),re=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>N(i,o,A())))}:{success:!0,data:s.value}},Ln=re(ot),Un=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ee(e)(t,n,o)},xn=e=>(t,n,r)=>Ee(e)(t,n,r),Mn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ze(e)(t,n,o)},Fn=e=>async(t,n,r)=>ze(e)(t,n,r),Kn=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ne(e)(t,n,o)},Vn=e=>(t,n,r)=>ne(e)(t,n,r),Wn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return re(e)(t,n,o)},Gn=e=>async(t,n,r)=>re(e)(t,n,r),Bn=/^[cC][^\s-]{8,}$/,Jn=/^[0-9a-z]+$/,Hn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Yn=/^[0-9a-vA-V]{20}$/,qn=/^[A-Za-z0-9]{27}$/,Xn=/^[a-zA-Z0-9_-]{21}$/,Qn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,er=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,st=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,tr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function rr(){return new RegExp(nr,"u")}const or=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,sr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ir=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ur=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,it=/^[A-Za-z0-9_-]*$/,ar=/^\+(?:[0-9]){6,14}[0-9]$/,ct="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",lr=new RegExp(`^${ct}$`);function ut(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function hr(e){return new RegExp(`^${ut(e)}$`)}function dr(e){const t=ut({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${ct}T(?:${r})$`)}const fr=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},pr=/^-?\d+$/,mr=/^-?\d+(?:\.\d+)?/,_r=/^(?:true|false)$/i,gr=/^null$/i,vr=/^[^A-Z]*$/,br=/^[^a-z]*$/,z=u("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),at={number:"number",bigint:"bigint",object:"date"},lt=u("$ZodCheckLessThan",(e,t)=>{z.init(e,t);const n=at[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ht=u("$ZodCheckGreaterThan",(e,t)=>{z.init(e,t);const n=at[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wr=u("$ZodCheckMultipleOf",(e,t)=>{z.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):kn(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),yr=u("$ZodCheckNumberFormat",(e,t)=>{z.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=Sn[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,n&&(c.pattern=pr)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}c<o&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>s&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:e})}}),kr=u("$ZodCheckMaxLength",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!we(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=ke(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Er=u("$ZodCheckMinLength",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!we(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=ke(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),zr=u("$ZodCheckLengthEquals",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!we(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=ke(o),c=s>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),oe=u("$ZodCheckStringFormat",(e,t)=>{var n,r;z.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),$r=u("$ZodCheckRegex",(e,t)=>{oe.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Zr=u("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vr),oe.init(e,t)}),Sr=u("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=br),oe.init(e,t)}),Or=u("$ZodCheckIncludes",(e,t)=>{z.init(e,t);const n=W(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Tr=u("$ZodCheckStartsWith",(e,t)=>{z.init(e,t);const n=new RegExp(`^${W(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Ir=u("$ZodCheckEndsWith",(e,t)=>{z.init(e,t);const n=new RegExp(`.*${W(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Cr=u("$ZodCheckOverwrite",(e,t)=>{z.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Pr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
19
+ */var cn=function(){if(typeof WebSocket<"u")return WebSocket},un=function(e){return typeof e<"u"&&!!e&&e.CLOSING===2},D={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0},an=function(){function e(t,n,r){var o=this;r===void 0&&(r={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(s){o._debug("open event");var i=o._options.minUptime,c=i===void 0?D.minUptime:i;clearTimeout(o._connectTimeout),o._uptimeTimeout=setTimeout(function(){return o._acceptOpen()},c),o._ws.binaryType=o._binaryType,o._messageQueue.forEach(function(a){return o._ws.send(a)}),o._messageQueue=[],o.onopen&&o.onopen(s),o._listeners.open.forEach(function(a){return o._callEventListener(s,a)})},this._handleMessage=function(s){o._debug("message event"),o.onmessage&&o.onmessage(s),o._listeners.message.forEach(function(i){return o._callEventListener(s,i)})},this._handleError=function(s){o._debug("error event",s.message),o._disconnect(void 0,s.message==="TIMEOUT"?"timeout":void 0),o.onerror&&o.onerror(s),o._debug("exec error listeners"),o._listeners.error.forEach(function(i){return o._callEventListener(s,i)}),o._connect()},this._handleClose=function(s){o._debug("close event"),o._clearTimeouts(),o._shouldReconnect&&o._connect(),o.onclose&&o.onclose(s),o._listeners.close.forEach(function(i){return o._callEventListener(s,i)})},this._url=t,this._protocols=n,this._options=r,this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}return Object.defineProperty(e,"CONNECTING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OPEN",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSED",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CONNECTING",{get:function(){return e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"OPEN",{get:function(){return e.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSING",{get:function(){return e.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSED",{get:function(){return e.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryType",{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){var t=this._messageQueue.reduce(function(n,r){return typeof r=="string"?n+=r.length:r instanceof Blob?n+=r.size:n+=r.byteLength,n},0);return t+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this._ws?this._ws.extensions:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this._ws?this._ws.protocol:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._ws?this._ws.url:""},enumerable:!0,configurable:!0}),e.prototype.close=function(t,n){if(t===void 0&&(t=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,n)},e.prototype.reconnect=function(t,n){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,n),this._connect())},e.prototype.send=function(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{var n=this._options.maxEnqueuedMessages,r=n===void 0?D.maxEnqueuedMessages:n;this._messageQueue.length<r&&(this._debug("enqueue",t),this._messageQueue.push(t))}},e.prototype.addEventListener=function(t,n){this._listeners[t]&&this._listeners[t].push(n)},e.prototype.dispatchEvent=function(t){var n,r,o=this._listeners[t.type];if(o)try{for(var s=tn(o),i=s.next();!i.done;i=s.next()){var c=i.value;this._callEventListener(t,c)}}catch(a){n={error:a}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return!0},e.prototype.removeEventListener=function(t,n){this._listeners[t]&&(this._listeners[t]=this._listeners[t].filter(function(r){return r!==n}))},e.prototype._debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._options.debug&&console.log.apply(console,rn(["RWS>"],t))},e.prototype._getNextDelay=function(){var t=this._options,n=t.reconnectionDelayGrowFactor,r=n===void 0?D.reconnectionDelayGrowFactor:n,o=t.minReconnectionDelay,s=o===void 0?D.minReconnectionDelay:o,i=t.maxReconnectionDelay,c=i===void 0?D.maxReconnectionDelay:i,a=0;return this._retryCount>0&&(a=s*Math.pow(r,this._retryCount-1),a>c&&(a=c)),this._debug("next delay",a),a},e.prototype._wait=function(){var t=this;return new Promise(function(n){setTimeout(n,t._getNextDelay())})},e.prototype._getNextUrl=function(t){if(typeof t=="string")return Promise.resolve(t);if(typeof t=="function"){var n=t();if(typeof n=="string")return Promise.resolve(n);if(n.then)return n}throw Error("Invalid URL")},e.prototype._connect=function(){var t=this;if(!(this._connectLock||!this._shouldReconnect)){this._connectLock=!0;var n=this._options,r=n.maxRetries,o=r===void 0?D.maxRetries:r,s=n.connectionTimeout,i=s===void 0?D.connectionTimeout:s,c=n.WebSocket,a=c===void 0?cn():c;if(this._retryCount>=o){this._debug("max retries reached",this._retryCount,">=",o);return}if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),!un(a))throw Error("No valid WebSocket class provided");this._wait().then(function(){return t._getNextUrl(t._url)}).then(function(l){t._closeCalled||(t._debug("connect",{url:l,protocols:t._protocols}),t._ws=t._protocols?new a(l,t._protocols):new a(l),t._ws.binaryType=t._binaryType,t._connectLock=!1,t._addListeners(),t._connectTimeout=setTimeout(function(){return t._handleTimeout()},i))})}},e.prototype._handleTimeout=function(){this._debug("timeout event"),this._handleError(new on(Error("TIMEOUT"),this))},e.prototype._disconnect=function(t,n){if(t===void 0&&(t=1e3),this._clearTimeouts(),!!this._ws){this._removeListeners();try{this._ws.close(t,n),this._handleClose(new sn(t,n,this))}catch{}}},e.prototype._acceptOpen=function(){this._debug("accept open"),this._retryCount=0},e.prototype._callEventListener=function(t,n){"handleEvent"in n?n.handleEvent(t):n(t)},e.prototype._removeListeners=function(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))},e.prototype._addListeners=function(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))},e.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)},e}();const xe=12095;function Me(e){const t=typeof window<"u"?window.location:void 0,n=`/assets/${encodeURIComponent(e)}`;return`${t?.protocol}//${t?.hostname}:${xe}${n}`}async function ln(e){const t=await fetch(e);return URL.createObjectURL(new Blob([await t.arrayBuffer()]))}class hn{_items;#e=new EventTarget;constructor(t){this._items={...t}}handleDataStoreItemsMessage(t){this._items={...this._items,...t.items},Object.entries(t.items).forEach(([n,r])=>{this.dispatchEvent(new _e(n,r))}),this.dispatchEvent(new ge(t.items))}get items(){return this._items}getItem(t){return this._items[t]}setItems(t){return this._items={...this._items,...t},Object.entries(t).forEach(([n,r])=>{this.dispatchEvent(new _e(n,r))}),this.dispatchEvent(new ge(t)),this}addEventListener(t,n,r){this.#e.addEventListener(t,n,r)}removeEventListener(t,n,r){this.#e.removeEventListener(t,n,r)}dispatchEvent(t){this.#e.dispatchEvent(t)}}class _e extends Event{constructor(t,n){super("item"),this.key=t,this.value=n}_cogsConnectionEventType="item"}class ge extends Event{constructor(t){super("items"),this.items=t}_cogsConnectionEventType="item"}const q=globalThis.Date;function dn(e){const t=Math.round(e-q.now());function n(...o){return o.length===0?new q(n.now()):new q(...o)}const r=Object.getOwnPropertyDescriptors(q);Object.defineProperties(n,r),n.now=function(){return q.now()+t},globalThis.Date=n}let fn=0;function pn(){return++fn}const mn=5,_n=1e4;function gn({interval:e,send:t,onChange:n=dn,syncSampleSize:r=mn,syncRequestTimeout:o=_n}){const s={};async function i(){const h=[];for(let m=0;m<r;m++){const E=new Promise(P=>{const Q=pn(),De=Date.now(),je=performance.now();t({timesync:{id:Q}});const O=(S,M)=>P({sentAt:je,receivedAt:S,serverNow:M,clientNow:De});s[Q]={complete:O},setTimeout(()=>P(null),o)});h.push(E),await E}const p=(await Promise.all(h)).filter(m=>m!==null),d=vn(p);isNaN(d)||n(Date.now()+d)}const c=h=>{const p=performance.now(),d=s[h.timesync.id];d&&d.complete(p,h.timesync.now)};i();const a=setInterval(i,e);return{receive:c,destroy:()=>{clearInterval(a)}}}function vn(e){return e.map(({sentAt:t,receivedAt:n,clientNow:r,serverNow:o})=>{const s=(n-t)/2;return o-r-s}).reduce((t,n)=>t+n,0)/e.length}class bn{constructor(t,{hostname:n=document.location.hostname,port:r=xe}={},o,s){this.manifest=t,this.currentState={...o},this.store=new hn(s??{});const{useReconnectingWebsocket:i,path:c,pathParams:a}=wn(document.location.href);this.urlParams=new URLSearchParams(a),this.urlParams.set("screenWidth",window.screen.width.toString()),this.urlParams.set("screenHeight",window.screen.height.toString()),this.urlParams.set("screenPixelRatio",window.devicePixelRatio.toString());const l=`ws://${n}:${r}${c}?${this.urlParams}`;this.websocket=i?new an(l):new WebSocket(l);let h;this.websocket.onopen=()=>{this.currentConfig={},this.currentState={},this.dispatchEvent(new Fe),this.setState(this.currentState),h=gn({interval:6e4,send:p=>{this.websocket.send(JSON.stringify(p))}})},this.websocket.addEventListener("message",({data:p})=>{try{const d=JSON.parse(p);if(typeof d=="object"&&d!==null&&"timesync"in d){const m=d;h?.receive(m)}}catch(d){console.error(d)}}),this.websocket.onclose=()=>{h?.destroy(),this.dispatchEvent(new Ke)},this.websocket.addEventListener("message",({data:p})=>{try{const d=JSON.parse(p);try{if(d.config)this.currentConfig=d.config,this.dispatchEvent(new We(this.currentConfig));else if(d.updates)this.currentState={...this.currentState,...d.updates},this.dispatchEvent(new Ge(d.updates));else if(d.event&&d.event.key)this.dispatchEvent(new Be(d.event.key,d.event.value));else if(typeof d.message=="object"){const m=d.message;switch(m.type){case"adjustable_timer_update":this._timerState={startedAt:Date.now(),durationMillis:m.durationMillis,ticking:m.ticking};break;case"show_phase":this._showPhase=m.phase,this.dispatchEvent(new He(m.phase));break;case"media_config_update":this._mediaConfig=m;for(const E of["preferOptimizedAudio","preferOptimizedVideo","preferOptimizedImages"])m[E]?this.urlParams.set(E,"true"):this.urlParams.delete(E);this.dispatchEvent(new Je(m));break;case"data_store_items":this.store.handleDataStoreItemsMessage(m);break}this.dispatchEvent(new Ve(m))}}catch(m){console.warn("Error handling data",p,m)}}catch(d){console.error("Unable to parse incoming data from server",p,d)}}),this.store.addEventListener("items",p=>{this.sendDataStoreItems(p.items)});{const p=async()=>{if(navigator.mediaDevices){const d=(await navigator.mediaDevices.enumerateDevices()).filter(({kind:m})=>m==="audiooutput");this.sendAudioOutputs(d),this.audioOutputs=d}};this.eventTarget.addEventListener("open",p),navigator.mediaDevices?.addEventListener("devicechange",p),p()}}websocket;eventTarget=new EventTarget;currentConfig={};get config(){return{...this.currentConfig}}currentState={};get state(){return{...this.currentState}}_showPhase=F.Setup;get showPhase(){return this._showPhase}_timerState=null;get timerState(){return this._timerState?{...this._timerState}:null}_mediaConfig=null;get mediaConfig(){return this._mediaConfig?{...this._mediaConfig}:null}getAssetUrl(t){return`${Me(t)}?${this.urlParams?.toString()??""}`}audioOutputs=void 0;_selectedAudioOutput="";get selectedAudioOutput(){return this._selectedAudioOutput}store;urlParams;get isConnected(){return this.websocket.readyState===WebSocket.OPEN}close(){this.websocket.close()}sendEvent(t,...[n]){this.isConnected&&this.websocket.send(JSON.stringify({event:{key:t,value:n}}))}setState(t){this.currentState={...this.currentState,...t},this.isConnected&&this.websocket.send(JSON.stringify({updates:t}))}getAudioSinkId(t){return t?this.audioOutputs?.find(({label:n})=>n===t)?.deviceId:""}sendAudioOutputs(t){this.isConnected&&this.websocket.send(JSON.stringify({audioOutputs:t}))}sendDataStoreItems(t){this.isConnected&&this.websocket.send(JSON.stringify({dataStoreItems:t}))}setPluginWindowVisible(t){this.isConnected&&this.websocket.send(JSON.stringify({window:{visible:t}}))}addEventListener(t,n,r){this.eventTarget.addEventListener(t,n,r)}removeEventListener(t,n,r){this.eventTarget.removeEventListener(t,n,r)}dispatchEvent(t){this.eventTarget.dispatchEvent(t)}}function wn(e){const t=new URL(e),n=new URLSearchParams(t.searchParams),r=n.get("local_id"),o=n.get("simulator")==="true",s=n.get("display")??"",i=t.pathname.startsWith("/plugin/")?decodeURIComponent(t.pathname.split("/")[2]):void 0;if(r){const c=n.get("t")??"";return n.delete("local_id"),{path:`/local/${encodeURIComponent(r)}`,pathParams:new URLSearchParams({t:c}),useReconnectingWebsocket:!0}}else if(o){const c=n.get("name")??"";return n.delete("simulator"),n.delete("name"),{path:`/simulator/${encodeURIComponent(c)}`,pathParams:n,useReconnectingWebsocket:!0}}else if(s){const c=n.get("displayIdIndex")??"";return n.delete("display"),n.delete("displayIdIndex"),{path:`/display/${encodeURIComponent(s)}/${encodeURIComponent(c)}`}}else{if(i)return{path:`/plugin/${encodeURIComponent(i)}`,useReconnectingWebsocket:!0};{const c=n.get("serial")??"";return n.delete("serial"),{path:`/client/${encodeURIComponent(c)}`,pathParams:n}}}}class Fe extends Event{_cogsConnectionEventType="open";constructor(){super("open")}}class Ke extends Event{_cogsConnectionEventType="close";constructor(){super("close")}}class Ve extends Event{constructor(t){super("message"),this.message=t}_cogsConnectionEventType="message"}class We extends Event{constructor(t){super("config"),this.config=t}_cogsConnectionEventType="config"}class Ge extends Event{constructor(t){super("state"),this.state=t}_cogsConnectionEventType="state"}class Be extends Event{constructor(t,n){super("event"),this.name=t,this.value=n}_cogsConnectionEventType="event"}class Je extends Event{constructor(t){super("mediaConfig"),this.mediaConfig=t}_cogsConnectionEventType="mediaConfig"}class He extends Event{constructor(t){super("showPhase"),this.showPhase=t}_cogsConnectionEventType="showPhase"}function u(e,t,n){function r(c,a){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:a,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);const l=i.prototype,h=Object.keys(l);for(let p=0;p<h.length;p++){const d=h[p];d in c||(c[d]=l[d].bind(c))}}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var a;const l=n?.Parent?new s:this;r(l,c),(a=l._zod).deferred??(a.deferred=[]);for(const h of l._zod.deferred)h();return l}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class K extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ye extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const qe={};function A(e){return qe}function yn(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ve(e,t){return typeof t=="bigint"?t.toString():t}function be(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function we(e){return e==null}function ye(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function kn(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const a=r.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}const s=n>o?n:o,i=Number.parseInt(e.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return i%c/10**s}const Xe=Symbol("evaluating");function _(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Xe)return r===void 0&&(r=Xe,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function j(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function L(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Qe(e){return JSON.stringify(e)}function En(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const et="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ee(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const zn=be(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function V(e){if(ee(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ee(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function tt(e){return V(e)?{...e}:Array.isArray(e)?[...e]:e}const $n=new Set(["string","number","symbol"]);function W(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function R(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function f(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Zn(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Sn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function On(e,t){const n=e._zod.def,r=L(e._zod.def,{get shape(){const o={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(o[s]=n.shape[s])}return j(this,"shape",o),o},checks:[]});return R(e,r)}function Tn(e,t){const n=e._zod.def,r=L(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete o[s]}return j(this,"shape",o),o},checks:[]});return R(e,r)}function In(e,t){if(!V(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const o=L(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return j(this,"shape",s),s},checks:[]});return R(e,o)}function Cn(e,t){if(!V(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return j(this,"shape",r),r},checks:e._zod.def.checks};return R(e,n)}function Pn(e,t){const n=L(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return j(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return R(e,n)}function An(e,t,n){const r=L(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=e?new e({type:"optional",innerType:o[i]}):o[i])}else for(const i in o)s[i]=e?new e({type:"optional",innerType:o[i]}):o[i];return j(this,"shape",s),s},checks:[]});return R(t,r)}function Rn(e,t,n){const r=L(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return j(this,"shape",s),s},checks:[]});return R(t,r)}function G(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function U(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function te(e){return typeof e=="string"?e:e?.message}function N(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=te(e.inst?._zod.def?.error?.(e))??te(t?.error?.(e))??te(n.customError?.(e))??te(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function ke(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function X(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const nt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},rt=u("$ZodError",nt),ot=u("$ZodError",nt,{Parent:Error});function Nn(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Dn(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>r({issues:i}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,c=0;for(;c<s.path.length;){const a=s.path[c];c===s.path.length-1?(i[a]=i[a]||{_errors:[]},i[a]._errors.push(t(s))):i[a]=i[a]||{_errors:[]},i=i[a],c++}}};return r(e),n}const Ee=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new K;if(i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>N(a,s,A())));throw et(c,o?.callee),c}return i.value},ze=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>N(a,s,A())));throw et(c,o?.callee),c}return i.value},ne=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new K;return s.issues.length?{success:!1,error:new(e??rt)(s.issues.map(i=>N(i,o,A())))}:{success:!0,data:s.value}},jn=ne(ot),re=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>N(i,o,A())))}:{success:!0,data:s.value}},Ln=re(ot),Un=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ee(e)(t,n,o)},xn=e=>(t,n,r)=>Ee(e)(t,n,r),Mn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ze(e)(t,n,o)},Fn=e=>async(t,n,r)=>ze(e)(t,n,r),Kn=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ne(e)(t,n,o)},Vn=e=>(t,n,r)=>ne(e)(t,n,r),Wn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return re(e)(t,n,o)},Gn=e=>async(t,n,r)=>re(e)(t,n,r),Bn=/^[cC][^\s-]{8,}$/,Jn=/^[0-9a-z]+$/,Hn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Yn=/^[0-9a-vA-V]{20}$/,qn=/^[A-Za-z0-9]{27}$/,Xn=/^[a-zA-Z0-9_-]{21}$/,Qn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,er=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,st=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,tr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function rr(){return new RegExp(nr,"u")}const or=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,sr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ir=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ur=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,it=/^[A-Za-z0-9_-]*$/,ar=/^\+(?:[0-9]){6,14}[0-9]$/,ct="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",lr=new RegExp(`^${ct}$`);function ut(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function hr(e){return new RegExp(`^${ut(e)}$`)}function dr(e){const t=ut({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${ct}T(?:${r})$`)}const fr=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},pr=/^-?\d+$/,mr=/^-?\d+(?:\.\d+)?/,_r=/^(?:true|false)$/i,gr=/^null$/i,vr=/^[^A-Z]*$/,br=/^[^a-z]*$/,z=u("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),at={number:"number",bigint:"bigint",object:"date"},lt=u("$ZodCheckLessThan",(e,t)=>{z.init(e,t);const n=at[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ht=u("$ZodCheckGreaterThan",(e,t)=>{z.init(e,t);const n=at[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wr=u("$ZodCheckMultipleOf",(e,t)=>{z.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):kn(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),yr=u("$ZodCheckNumberFormat",(e,t)=>{z.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=Sn[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,n&&(c.pattern=pr)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}c<o&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>s&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:e})}}),kr=u("$ZodCheckMaxLength",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!we(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=ke(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Er=u("$ZodCheckMinLength",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!we(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=ke(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),zr=u("$ZodCheckLengthEquals",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!we(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=ke(o),c=s>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),oe=u("$ZodCheckStringFormat",(e,t)=>{var n,r;z.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),$r=u("$ZodCheckRegex",(e,t)=>{oe.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Zr=u("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vr),oe.init(e,t)}),Sr=u("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=br),oe.init(e,t)}),Or=u("$ZodCheckIncludes",(e,t)=>{z.init(e,t);const n=W(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Tr=u("$ZodCheckStartsWith",(e,t)=>{z.init(e,t);const n=new RegExp(`^${W(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Ir=u("$ZodCheckEndsWith",(e,t)=>{z.init(e,t);const n=new RegExp(`.*${W(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Cr=u("$ZodCheckOverwrite",(e,t)=>{z.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Pr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
20
20
  `).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
21
21
  `))}}const Ar={major:4,minor:1,patch:13},g=u("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ar;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,c,a)=>{let l=G(i),h;for(const p of c){if(p._zod.def.when){if(!p._zod.def.when(i))continue}else if(l)continue;const d=i.issues.length,m=p._zod.check(i);if(m instanceof Promise&&a?.async===!1)throw new K;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await m,i.issues.length!==d&&(l||(l=G(i,d)))});else{if(i.issues.length===d)continue;l||(l=G(i,d))}}return h?h.then(()=>i):i},s=(i,c,a)=>{if(G(i))return i.aborted=!0,i;const l=o(c,r,a);if(l instanceof Promise){if(a.async===!1)throw new K;return l.then(h=>e._zod.parse(h,a))}return e._zod.parse(l,a)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){const l=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(h=>s(h,i,c)):s(l,i,c)}const a=e._zod.parse(i,c);if(a instanceof Promise){if(c.async===!1)throw new K;return a.then(l=>o(l,r,c))}return o(a,r,c)}}e["~standard"]={validate:o=>{try{const s=jn(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Ln(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),$e=u("$ZodString",(e,t)=>{g.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??fr(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),v=u("$ZodStringFormat",(e,t)=>{oe.init(e,t),$e.init(e,t)}),Rr=u("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=er),v.init(e,t)}),Nr=u("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=st(r))}else t.pattern??(t.pattern=st());v.init(e,t)}),Dr=u("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=tr),v.init(e,t)}),jr=u("$ZodURL",(e,t)=>{v.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Lr=u("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=rr()),v.init(e,t)}),Ur=u("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Xn),v.init(e,t)}),xr=u("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Bn),v.init(e,t)}),Mr=u("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Jn),v.init(e,t)}),Fr=u("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Hn),v.init(e,t)}),Kr=u("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Yn),v.init(e,t)}),Vr=u("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=qn),v.init(e,t)}),Wr=u("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=dr(t)),v.init(e,t)}),Gr=u("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=lr),v.init(e,t)}),Br=u("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=hr(t)),v.init(e,t)}),Jr=u("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Qn),v.init(e,t)}),Hr=u("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=or),v.init(e,t),e._zod.bag.format="ipv4"}),Yr=u("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=sr),v.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),qr=u("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ir),v.init(e,t)}),Xr=u("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=cr),v.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,s]=r;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function dt(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Qr=u("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ur),v.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{dt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function eo(e){if(!it.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return dt(n)}const to=u("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=it),v.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{eo(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),no=u("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ar),v.init(e,t)});function ro(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const oo=u("$ZodJWT",(e,t)=>{v.init(e,t),e._zod.check=n=>{ro(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ft=u("$ZodNumber",(e,t)=>{g.init(e,t),e._zod.pattern=e._zod.bag.pattern??mr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),so=u("$ZodNumberFormat",(e,t)=>{yr.init(e,t),ft.init(e,t)}),io=u("$ZodBoolean",(e,t)=>{g.init(e,t),e._zod.pattern=_r,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),co=u("$ZodNull",(e,t)=>{g.init(e,t),e._zod.pattern=gr,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),uo=u("$ZodUnknown",(e,t)=>{g.init(e,t),e._zod.parse=n=>n}),ao=u("$ZodNever",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function pt(e,t,n){e.issues.length&&t.issues.push(...U(n,e.issues)),t.value[n]=e.value}const lo=u("$ZodArray",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let i=0;i<o.length;i++){const c=o[i],a=t.element._zod.run({value:c,issues:[]},r);a instanceof Promise?s.push(a.then(l=>pt(l,n,i))):pt(a,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function se(e,t,n,r){e.issues.length&&t.issues.push(...U(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function mt(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=Zn(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function _t(e,t,n,r,o,s){const i=[],c=o.keySet,a=o.catchall._zod,l=a.def.type;for(const h in t){if(c.has(h))continue;if(l==="never"){i.push(h);continue}const p=a.run({value:t[h],issues:[]},r);p instanceof Promise?e.push(p.then(d=>se(d,n,h,t))):se(p,n,h,t)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const ho=u("$ZodObject",(e,t)=>{if(g.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const a={...c};return Object.defineProperty(t,"shape",{value:a}),a}})}const r=be(()=>mt(t));_(e._zod,"propValues",()=>{const c=t.shape,a={};for(const l in c){const h=c[l]._zod;if(h.values){a[l]??(a[l]=new Set);for(const p of h.values)a[l].add(p)}}return a});const o=ee,s=t.catchall;let i;e._zod.parse=(c,a)=>{i??(i=r.value);const l=c.value;if(!o(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;c.value={};const h=[],p=i.shape;for(const d of i.keys){const E=p[d]._zod.run({value:l[d],issues:[]},a);E instanceof Promise?h.push(E.then(P=>se(P,c,d,l))):se(E,c,d,l)}return s?_t(h,l,c,a,r.value,e):h.length?Promise.all(h).then(()=>c):c}}),fo=u("$ZodObjectJIT",(e,t)=>{ho.init(e,t);const n=e._zod.parse,r=be(()=>mt(t)),o=d=>{const m=new Pr(["shape","payload","ctx"]),E=r.value,P=O=>{const S=Qe(O);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};m.write("const input = payload.value;");const Q=Object.create(null);let De=0;for(const O of E.keys)Q[O]=`key_${De++}`;m.write("const newResult = {};");for(const O of E.keys){const S=Q[O],M=Qe(O);m.write(`const ${S} = ${P(O)};`),m.write(`
22
22
  if (${S}.issues.length) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Connect to COGS to build a custom Media Master",
4
4
  "author": "Clockwork Dog <info@clockwork.dog>",
5
5
  "homepage": "https://github.com/clockwork-dog/cogs-sdk/tree/main/packages/javascript",
6
- "version": "3.0.0",
6
+ "version": "3.0.1",
7
7
  "keywords": [],
8
8
  "license": "MIT",
9
9
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "cy:generate": "cypress run --e2e"
38
38
  },
39
39
  "dependencies": {
40
- "@clockworkdog/timesync": "^3.0.0",
40
+ "@clockworkdog/timesync": "^3.0.1",
41
41
  "reconnecting-websocket": "^4.4.0",
42
42
  "zod": "^4.1.13"
43
43
  },