@configdirector/nextjs-sdk 1.6.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/dist/client/index.cjs +1 -5
- package/dist/client/index.d.cts +52 -216
- package/dist/client/index.d.cts.map +1 -1
- package/dist/client/index.d.mts +52 -216
- package/dist/client/index.d.mts.map +1 -1
- package/dist/client/index.mjs +1 -5
- package/dist/client/index.mjs.map +1 -1
- package/dist/client/installedTestClient-CrHwnJTr.mjs +7 -0
- package/dist/client/installedTestClient-CrHwnJTr.mjs.map +1 -0
- package/dist/client/installedTestClient-LbS5fHdP.cjs +6 -0
- package/dist/client/testing.cjs +2 -0
- package/dist/client/testing.d.cts +159 -0
- package/dist/client/testing.d.cts.map +1 -0
- package/dist/client/testing.d.mts +159 -0
- package/dist/client/testing.d.mts.map +1 -0
- package/dist/client/testing.mjs +3 -0
- package/dist/client/testing.mjs.map +1 -0
- package/dist/client/types-DA2VZKNX.d.mts +220 -0
- package/dist/client/types-DA2VZKNX.d.mts.map +1 -0
- package/dist/client/types-fL7X5zwg.d.cts +220 -0
- package/dist/client/types-fL7X5zwg.d.cts.map +1 -0
- package/dist/server/DefaultConfigDirectorClient-BhyVJv6Z.mjs +6 -0
- package/dist/server/DefaultConfigDirectorClient-BhyVJv6Z.mjs.map +1 -0
- package/dist/server/DefaultConfigDirectorClient-BngKzHat.cjs +5 -0
- package/dist/server/{errors-B1AJJTZ-.mjs → errors-BGpFuqOO.mjs} +1 -1
- package/dist/server/{errors-B1AJJTZ-.mjs.map → errors-BGpFuqOO.mjs.map} +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.cts +14 -288
- package/dist/server/index.d.cts.map +1 -1
- package/dist/server/index.d.mts +14 -288
- package/dist/server/index.d.mts.map +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/testing.cjs +1 -0
- package/dist/server/testing.d.cts +119 -0
- package/dist/server/testing.d.cts.map +1 -0
- package/dist/server/testing.d.mts +119 -0
- package/dist/server/testing.d.mts.map +1 -0
- package/dist/server/testing.mjs +2 -0
- package/dist/server/testing.mjs.map +1 -0
- package/dist/server/types-DnzM2ukj.d.cts +292 -0
- package/dist/server/types-DnzM2ukj.d.cts.map +1 -0
- package/dist/server/types-qIeNbtNf.d.mts +292 -0
- package/dist/server/types-qIeNbtNf.d.mts.map +1 -0
- package/package.json +37 -2
- package/dist/server/DefaultConfigDirectorClient-CAMGE6h8.mjs +0 -6
- package/dist/server/DefaultConfigDirectorClient-CAMGE6h8.mjs.map +0 -1
- package/dist/server/DefaultConfigDirectorClient-DhSSj7ds.cjs +0 -5
- /package/dist/server/{errors-zhcEWVnY.cjs → errors-CCbuIqT8.cjs} +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const l=require(`./errors-CCbuIqT8.cjs`);let u=require(`node:events`);u=c(u);let d=require(`node:crypto`),f=require(`semver`);f=c(f);let p=require(`rapidhash-js`);var m=class e extends Error{constructor(t){super(t),this.name=`StreamClosedError`,Object.setPrototypeOf(this,e.prototype)}},ee=class e extends Error{constructor(t){super(t),this.name=`MissingResponseBodyError`,Object.setPrototypeOf(this,e.prototype)}},te=class e extends Error{constructor(t){super(t),this.name=`InvalidOptionError`,Object.setPrototypeOf(this,e.prototype)}},ne=class e extends Error{constructor(t){super(t),this.name=`ValueOutOfRangeError`,Object.setPrototypeOf(this,e.prototype)}},h=class{constructor(e){this.isFirstChunk=!0,this.bufferedInput=``,this.currentEvent={data:``},this.currentEvent={data:``},this.onEvent=e.onEvent??(()=>{}),this.onRetry=e.onRetry,this.onComment=e.onComment}parse(e){let t=e;this.isFirstChunk&&(this.isFirstChunk=!1,t.startsWith(``)?t=t.slice(1):t.startsWith(``)&&(t=t.slice(3)));let n=this.scanLines(this.bufferedInput+t);for(let e of n)this.dispatchLine(e)}finish(){this.bufferedInput=``}scanLines(e){let t=[],n=0,r=0;for(;r<e.length;){let i=e[r];i===`\r`||i===`
|
|
2
|
+
`?(t.push(e.slice(n,r)),i===`\r`&&e[r+1]===`
|
|
3
|
+
`&&r++,r++,n=r):r++}return this.bufferedInput=e.slice(n),t}dispatchLine(e){if(e.startsWith(`:`)){this.onComment?.(this.extractValue(e,1));return}if(e===``){this.emitEvent();return}this.applyField(this.parseField(e))}emitEvent(){let e=this.currentEvent.data.endsWith(`
|
|
4
|
+
`)?this.currentEvent.data.slice(0,-1):this.currentEvent.data;e!==``&&this.onEvent({...this.currentEvent,id:this.lastEventId,data:e}),this.currentEvent={data:``}}applyField(e){switch(e.field){case`event`:this.currentEvent.type=e.value;break;case`data`:this.currentEvent.data+=e.value+`
|
|
5
|
+
`;break;case`id`:e.value.includes(`\0`)||(this.lastEventId=e.value);break;case`retry`:/^\d+$/.test(e.value)&&this.onRetry?.(Number.parseInt(e.value,10));break;default:break}}parseField(e){let t=e.indexOf(`:`);return t===-1?{field:e,value:``}:{field:e.slice(0,t),value:this.extractValue(e,t+1)}}extractValue(e,t){return e[t]===` `?e.slice(t+1):e.slice(t)}};let g=function(e){return e.OPEN=`open`,e.CLOSED=`closed`,e.CONNECTING=`connecting`,e}({});var re=class{constructor(e){this.DEFAULT_SHOULD_RECONNECT=()=>!0,this.DEFAULT_CALCULATE_RECONNECT_DELAY=()=>this.serverReconnectionTime,this.reconnectAttempt=0,this.abortController=new AbortController,this._readyState=g.CLOSED,this.serverReconnectionTime=2e3,this.url=e.url.toString(),this.lastEventId=e.lastEventId,this.headers={Accept:`text/event-stream`,...e.headers};let t=e.body;this.body=typeof t==`function`?t:()=>t,this.requestOptions={method:e.method??`GET`,mode:e.mode,credentials:e.credentials,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy},this._fetch=e.fetch??((e,t)=>fetch(e,t)),this._onError=this.resolveCallback(e.onError,()=>{},`onError`),this._onConnect=this.resolveCallback(e.onConnect,()=>{},`onConnect`),this._onDisconnect=this.resolveCallback(e.onDisconnect,()=>{},`onDisconnect`),this._onMessage=this.resolveCallback(e.onMessage,()=>{},`onMessage`),this._onComment=this.resolveCallback(e.onComment,()=>{},`onComment`),this._shouldReconnect=this.resolveCallback(e.shouldReconnect,this.DEFAULT_SHOULD_RECONNECT,`shouldReconnect`),this._calculateReconnectDelay=this.resolveCallback(e.calculateReconnectDelay,this.DEFAULT_CALCULATE_RECONNECT_DELAY,`calculateReconnectDelay`)}set onError(e){this._onError=this.resolveCallback(e,()=>{},`onError`)}set onMessage(e){this._onMessage=this.resolveCallback(e,()=>{},`onMessage`)}set onComment(e){this._onComment=this.resolveCallback(e,()=>{},`onComment`)}set onConnect(e){this._onConnect=this.resolveCallback(e,()=>{},`onConnect`)}set onDisconnect(e){this._onDisconnect=this.resolveCallback(e,()=>{},`onDisconnect`)}set shouldReconnect(e){this._shouldReconnect=this.resolveCallback(e,this.DEFAULT_SHOULD_RECONNECT,`shouldReconnect`)}set calculateReconnectDelay(e){this._calculateReconnectDelay=this.resolveCallback(e,this.DEFAULT_CALCULATE_RECONNECT_DELAY,`shouldReconnect`)}get readyState(){return this._readyState}connect(){this._readyState===g.CLOSED&&(this.reconnectAttempt=0,this.initiateConnection())}close(){clearTimeout(this.reconnectTimeout),this._readyState=g.CLOSED,this.abortController.abort()}initiateConnection(){this.abortController=new AbortController,this._readyState=g.CONNECTING,this._fetch(this.url,{...this.requestOptions,body:this.body(),headers:this.buildRequestHeaders(),signal:this.abortController.signal,cache:`no-store`}).then(e=>this.handleFetchResponse(e)).catch(e=>{if(e.name===`AbortError`||this.abortController.signal.aborted){this.close();return}this._onError(e),this.scheduleReconnect({error:e})})}async handleFetchResponse(e){let{body:t,status:n}=e;if(n===204){this.disconnected();return}if(n>=400){this.scheduleReconnect({status:n});return}if(!t)throw new ee(`The server response did not have a body`);this._readyState=g.OPEN,this._onConnect(),this.reconnectAttempt=0;let r=new h({onEvent:e=>{typeof e.id==`string`&&(this.lastEventId=e.id),this._onMessage(e)},onComment:e=>this._onComment(e),onRetry:e=>this.serverReconnectionTime=e});await this.readResponseStream(t,r),this.scheduleReconnect({status:n,error:new m(`The server response stream was closed`)})}async readResponseStream(e,t){let n=e.getReader(),r=new TextDecoder,i=!1;for(;!i;){let e=await n.read();e.value&&t.parse(r.decode(e.value,{stream:!0})),i=e.done}t.finish()}disconnected(){clearTimeout(this.reconnectTimeout),this._readyState=g.CLOSED,this._onDisconnect()}buildRequestHeaders(){let e=this.lastEventId?{"Last-Event-ID":this.lastEventId}:void 0;return{...this.headers,...e}}scheduleReconnect(e){if(this.abortController.signal.aborted)return;clearTimeout(this.reconnectTimeout),this.reconnectAttempt+=1;let t={attempt:this.reconnectAttempt,status:e.status,error:e.error,serverReconnectionTime:this.serverReconnectionTime};if(!this._shouldReconnect(t)){this.disconnected();return}this._readyState=g.CONNECTING;let n=this._calculateReconnectDelay(t);(!Number.isFinite(n)||n<1||n>1e3*60*60)&&(this._onError(new ne(`The calculated reconnect delay is out of range: ${n}. Defaulting to ${this.serverReconnectionTime}`)),n=this.serverReconnectionTime),this.reconnectTimeout=setTimeout(()=>this.initiateConnection(),n)}resolveCallback(e,t,n){if(e==null)return t;if(typeof e!=`function`)throw new te(`${n} must be a function`);return e}};const ie=e=>new re(e),ae=async(e,t,n,r)=>{let i=new AbortController,a=setTimeout(()=>{r.debug(`[fetchWithTimeout] Reached timeout, aborting request`),i.abort()},e);try{let e=await fetch(typeof t==`string`||t instanceof Request?t:t.toString(),{...n,signal:i.signal});return clearTimeout(a),e}catch(e){throw r.warn(`[fetchWithTimeout] Fetch error: `,e),clearTimeout(a),e}},_=9e4;var oe=class{constructor(e){this.options=e,this.eventEmitter=new u.EventEmitter,this.options=e,this.logger=e.logger,this.url=new URL(`server/sse/v1`,e.baseUrl),this.heartbeatUrl=new URL(`server/heartbeat/v1`,e.baseUrl)}async connect(e){this.eventSource&&this.close();let t=new Promise((e,t)=>{this.eventSource=ie({url:this.url,method:`POST`,headers:{"Content-Type":`application/json`},body:()=>this.buildRequestBody(),onMessage:({data:e})=>{this.dispatchMessage(e)},onConnect:()=>{this.logger.debug(`[StreamingTransport] Connected`),e(this)},shouldReconnect:e=>{let n=!this.isStatusFatal(e.status);if(!n){this.stopHeartbeat();let n=this.prepareFatalError(e.status,e.error);this.eventEmitter.emit(`connectionError`,n),t(n)}return n},calculateReconnectDelay:e=>{let t=2**Math.min(e.attempt,9)*1e3,n=`[StreamingTransport] Scheduling reconnect attempt #${e.attempt} in ${t}ms.`;return e.attempt<=5?this.logger.info(n):this.logger.warn(n),t},onDisconnect:()=>{this.logger.debug(`[StreamingTransport] Disconnected`)}}),this.eventSource.connect()});this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),_);let n;try{return await Promise.race([t,new Promise(t=>{n=setTimeout(()=>t(this),e)})])}finally{clearTimeout(n)}}get sessionId(){return this._sessionId}sendHeartbeat(){!this.isConnected||!this._sessionId||ae(_,this.heartbeatUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({serverSdkKey:this.options.serverSdkKey,sessionId:this._sessionId})},this.logger).then(e=>{e.ok||this.logger.debug(`[StreamingTransport] Heartbeat failed with status: ${e.status}`)}).catch(e=>{this.logger.debug(`[StreamingTransport] Heartbeat failed: `,e)})}buildRequestBody(){return this._sessionId=(0,d.randomUUID)(),JSON.stringify({metaContext:this.options.metaContext,serverSdkKey:this.options.serverSdkKey,sessionId:this._sessionId})}dispatchMessage(e){try{let t=JSON.parse(e);this.eventEmitter.emit(`configBundleReceived`,t)}catch(e){this.logger.error(`[StreamingTransport] Error parsing and dispatching config data update: `,e)}}prepareFatalError(e,t){let n=e??0;return new l.t(`${`Connection failed with status: ${e??`unknown`}.`}${t?` Error: ${t}.`:``} This is an unrecoverable error, will not attempt to reconnect.`,n)}isStatusFatal(e){return!!e&&e>=400&&e<500&&e!=429}get isConnected(){return this.eventSource?.readyState==`open`}on(e,t){this.eventEmitter.on(e,t)}off(e,t){t?this.eventEmitter.off(e,t):this.eventEmitter.removeAllListeners(e)}clear(){this.eventEmitter.removeAllListeners()}stopHeartbeat(){clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0}close(){this.stopHeartbeat(),this.eventSource?.close()}dispose(){this.close(),this.clear()}},se=class{constructor(){this.fatalError=!1}clearPollingInterval(){clearInterval(this.pollingInterval)}schedulePollingInterval(e){clearInterval(this.pollingInterval),!(this.pollingIntervalSeconds<=0)&&(this.pollingInterval=setInterval(e,this.pollingIntervalSeconds*1e3))}async handleNonOkResponse(e){if(!e.ok)throw this.isStatusFatal(e.status)?(this.fatalError=!0,this.close(),this.prepareFatalResponseStatusError(e.status,await e.text())):new l.t(`Connection failed with status: ${e.status}`,e.status)}handleFetchError(e){throw this.isFetchErrorFatal(e)?(this.fatalError=!0,this.close(),new l.t(`Connection failed with fatal error: ${e}. This is an unrecoverable error, retry attempts will be ignored.`)):e instanceof SyntaxError?new l.t(`Failed to parse the response from the server: ${e}`):new l.t(`Connection failed with error: ${e}.`)}prepareFatalResponseStatusError(e,t){let n=e??0;return new l.t(`${`Connection failed with status: ${e??`unknown`}`}${(t?.trim()?.length??0)>0?` (${t})`:``}. This is an unrecoverable error, retry attempts will be ignored.`,n)}isStatusFatal(e){return!!e&&e>=400&&e<500&&e!=429}isFetchErrorFatal(e){return e?.name===`NotAllowedError`}get isConnected(){return this.pollingInterval!==void 0}close(){clearInterval(this.pollingInterval),this.pollingInterval=void 0}dispose(){this.close(),this.clear()}},ce=class extends se{constructor(e){super(),this.options=e,this.eventEmitter=new u.EventEmitter,this._sessionId=(0,d.randomUUID)(),this.options=e,this.logger=e.logger,this.url=new URL(`server/polling/v1`,e.baseUrl),this.pollingIntervalSeconds=e.pollingInterval??300}async connect(e){this.clearPollingInterval();try{await this.fetchConfigs(e)}finally{this.fatalError||this.schedulePollingInterval(()=>{this.fetchConfigs(e).catch(e=>{this.logger.error(`[PollingTransport] Error during polling:`,e)})})}return this}get sessionId(){return this._sessionId}async fetchConfigs(e){if(this.fatalError){this.logger.warn(`[PollingTransport] There was a prior unrecoverable error. Ignoring attempt to reconnect.`);return}try{let t=await ae(e,this.url,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({metaContext:this.options.metaContext,serverSdkKey:this.options.serverSdkKey,lastUpdateTimestamp:this.lastUpdateTimestamp,sessionId:this._sessionId})},this.logger);if(await this.handleNonOkResponse(t),t.status===200){let e=JSON.parse(await t.text());this.lastUpdateTimestamp=e.timestamp,this.eventEmitter.emit(`configBundleReceived`,e)}}catch(e){try{this.handleFetchError(e)}catch(e){throw this.fatalError&&this.eventEmitter.emit(`connectionError`,e),e}}}on(e,t){this.eventEmitter.on(e,t)}off(e,t){t?this.eventEmitter.off(e,t):this.eventEmitter.removeAllListeners(e)}clear(){this.eventEmitter.removeAllListeners()}};const le=/^(?:0|[1-9][0-9]*)$/,ue=/~(?![01])/,de=Object.prototype.propertyIsEnumerable,fe=e=>{if(!ue.test(e))return e.replace(/~1/g,`/`).replace(/~0/g,`~`)},pe=(e,t)=>{if(Array.isArray(e))return le.test(t)&&de.call(e,t)?e[Number(t)]:void 0;if(typeof e==`object`&&e)return de.call(e,t)?e[t]:void 0},me=(e,t)=>{if(e===``)return t;if(!e.startsWith(`/`))return;let n=t;for(let t of e.slice(1).split(`/`)){let e=fe(t);if(e===void 0||(n=pe(n,e),n===void 0))return}return n},he=(e,t,n)=>{let r=n[0];switch(t.toLowerCase()){case`=`:case`equals`:return r!==void 0&&e===r;case`!=`:case`does not equal`:return r!==void 0&&e!==r;case`is one of`:return n.includes(e);case`is not one of`:return!n.includes(e);case`starts with any of`:return n.some(t=>e.startsWith(t));case`does not start with any of`:return!n.some(t=>e.startsWith(t));case`ends with any of`:return n.some(t=>e.endsWith(t));case`does not end with any of`:return!n.some(t=>e.endsWith(t));default:return!1}},ge=(e,t,n)=>{let r=t.toLowerCase(),i=_e(e);if(i===void 0)return r===`!=`||r===`does not equal`;let a=n[0];if(a===void 0)return!1;let o=_e(a);if(o===void 0)return!1;switch(r){case`=`:case`equals`:return i===o;case`!=`:case`does not equal`:return i!==o;case`<`:return i<o;case`<=`:return i<=o;case`>`:return i>o;case`>=`:return i>=o;default:return!1}},_e=e=>{if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e!=`string`||e.length===0||!ve(e))return;let t=Number(e);return Number.isFinite(t)?t:void 0},ve=e=>{for(let t of e)if(!(t>=`0`&&t<=`9`)&&!`+-.eE`.includes(t))return!1;return!0};var v=class extends Error{},ye=class extends v{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},be=class extends v{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},xe=class extends v{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},Se=class extends v{},Ce=class extends v{constructor(e){super(`Invalid unit ${e}`)}},y=class extends v{},b=class extends v{constructor(){super(`Zone is an abstract class`)}};const x=`numeric`,S=`short`,C=`long`,we={year:x,month:x,day:x},Te={year:x,month:S,day:x},Ee={year:x,month:S,day:x,weekday:S},De={year:x,month:C,day:x},Oe={year:x,month:C,day:x,weekday:C},ke={hour:x,minute:x},Ae={hour:x,minute:x,second:x},je={hour:x,minute:x,second:x,timeZoneName:S},Me={hour:x,minute:x,second:x,timeZoneName:C},Ne={hour:x,minute:x,hourCycle:`h23`},Pe={hour:x,minute:x,second:x,hourCycle:`h23`},Fe={hour:x,minute:x,second:x,hourCycle:`h23`,timeZoneName:S},Ie={hour:x,minute:x,second:x,hourCycle:`h23`,timeZoneName:C},Le={year:x,month:x,day:x,hour:x,minute:x},Re={year:x,month:x,day:x,hour:x,minute:x,second:x},ze={year:x,month:S,day:x,hour:x,minute:x},Be={year:x,month:S,day:x,hour:x,minute:x,second:x},Ve={year:x,month:S,day:x,weekday:S,hour:x,minute:x},He={year:x,month:C,day:x,hour:x,minute:x,timeZoneName:S},Ue={year:x,month:C,day:x,hour:x,minute:x,second:x,timeZoneName:S},We={year:x,month:C,day:x,weekday:C,hour:x,minute:x,timeZoneName:C},Ge={year:x,month:C,day:x,weekday:C,hour:x,minute:x,second:x,timeZoneName:C};var Ke=class{get type(){throw new b}get name(){throw new b}get ianaName(){return this.name}get isUniversal(){throw new b}offsetName(e,t){throw new b}formatOffset(e,t){throw new b}offset(e){throw new b}equals(e){throw new b}get isValid(){throw new b}};let qe=null;var Je=class e extends Ke{static get instance(){return qe===null&&(qe=new e),qe}get type(){return`system`}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Sn(e,t,n)}formatOffset(e,t){return En(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type===`system`}get isValid(){return!0}};const Ye=new Map;function Xe(e){let t=Ye.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(`en-US`,{hour12:!1,timeZone:e,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,era:`short`}),Ye.set(e,t)),t}const Ze={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Qe(e,t){let n=e.format(t).replace(/\u200E/g,``),[,r,i,a,o,s,c,l]=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(n);return[a,r,i,o,s,c,l]}function $e(e,t){let n=e.formatToParts(t),r=[];for(let e=0;e<n.length;e++){let{type:t,value:i}=n[e],a=Ze[t];t===`era`?r[a]=i:M(a)||(r[a]=parseInt(i,10))}return r}const et=new Map;var w=class e extends Ke{static create(t){let n=et.get(t);return n===void 0&&et.set(t,n=new e(t)),n}static resetCache(){et.clear(),Ye.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e}).format(),!0}catch{return!1}}constructor(t){super(),this.zoneName=t,this.valid=e.isValidZone(t)}get type(){return`iana`}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Sn(e,t,n,this.name)}formatOffset(e,t){return En(this.offset(e),t)}offset(e){if(!this.valid)return NaN;let t=new Date(e);if(isNaN(t))return NaN;let n=Xe(this.name),[r,i,a,o,s,c,l]=n.formatToParts?$e(n,t):Qe(n,t);o===`BC`&&(r=-Math.abs(r)+1);let u=vn({year:r,month:i,day:a,hour:s===24?0:s,minute:c,second:l,millisecond:0}),d=+t,f=d%1e3;return d-=f>=0?f:1e3+f,(u-d)/(60*1e3)}equals(e){return e.type===`iana`&&e.name===this.name}get isValid(){return this.valid}};let tt={};function nt(e,t={}){let n=JSON.stringify([e,t]),r=tt[n];return r||(r=new Intl.ListFormat(e,t),tt[n]=r),r}const rt=new Map;function it(e,t={}){let n=JSON.stringify([e,t]),r=rt.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),rt.set(n,r)),r}const at=new Map;function ot(e,t={}){let n=JSON.stringify([e,t]),r=at.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),at.set(n,r)),r}const st=new Map;function ct(e,t={}){let{base:n,...r}=t,i=JSON.stringify([e,r]),a=st.get(i);return a===void 0&&(a=new Intl.RelativeTimeFormat(e,t),st.set(i,a)),a}let lt=null;function ut(){return lt||(lt=new Intl.DateTimeFormat().resolvedOptions().locale,lt)}const dt=new Map;function ft(e){let t=dt.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),dt.set(e,t)),t}const pt=new Map;function mt(e){let t=pt.get(e);if(!t){let n=new Intl.Locale(e);t=`getWeekInfo`in n?n.getWeekInfo():n.weekInfo,`minimalDays`in t||(t={...wt,...t}),pt.set(e,t)}return t}function ht(e){let t=e.indexOf(`-x-`);t!==-1&&(e=e.substring(0,t));let n=e.indexOf(`-u-`);if(n===-1)return[e];{let t,r;try{t=it(e).resolvedOptions(),r=e}catch{let i=e.substring(0,n);t=it(i).resolvedOptions(),r=i}let{numberingSystem:i,calendar:a}=t;return[r,i,a]}}function gt(e,t,n){return n||t?(e.includes(`-u-`)||(e+=`-u`),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`),e):e}function _t(e){let t=[];for(let n=1;n<=12;n++){let r=$.utc(2009,n,1);t.push(e(r))}return t}function vt(e){let t=[];for(let n=1;n<=7;n++){let r=$.utc(2016,11,13+n);t.push(e(r))}return t}function yt(e,t,n,r){let i=e.listingMode();return i===`error`?null:i===`en`?n(t):r(t)}function bt(e){return e.numberingSystem&&e.numberingSystem!==`latn`?!1:e.numberingSystem===`latn`||!e.locale||e.locale.startsWith(`en`)||ft(e.locale).numberingSystem===`latn`}var xt=class{constructor(e,t,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;let{padTo:r,floor:i,...a}=n;if(!t||Object.keys(a).length>0){let t={useGrouping:!1,...n};n.padTo>0&&(t.minimumIntegerDigits=n.padTo),this.inf=ot(e,t)}}format(e){if(this.inf){let t=this.floor?Math.floor(e):e;return this.inf.format(t)}else return I(this.floor?Math.floor(e):mn(e,3),this.padTo)}},St=class{constructor(e,t,n){this.opts=n,this.originalZone=void 0;let r;if(this.opts.timeZone)this.dt=e;else if(e.zone.type===`fixed`){let t=-1*(e.offset/60),n=t>=0?`Etc/GMT+${t}`:`Etc/GMT${t}`;e.offset!==0&&w.create(n).valid?(r=n,this.dt=e):(r=`UTC`,this.dt=e.offset===0?e:e.setZone(`UTC`).plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type===`system`?this.dt=e:e.zone.type===`iana`?(this.dt=e,r=e.zone.name):(r=`UTC`,this.dt=e.setZone(`UTC`).plus({minutes:e.offset}),this.originalZone=e.zone);let i={...this.opts};i.timeZone=i.timeZone||r,this.dtf=it(t,i)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(``):this.dtf.format(this.dt.toJSDate())}formatToParts(){let e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(e=>{if(e.type===`timeZoneName`){let t=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...e,value:t}}else return e}):e}resolvedOptions(){return this.dtf.resolvedOptions()}},Ct=class{constructor(e,t,n){this.opts={style:`long`,...n},!t&&on()&&(this.rtf=ct(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):Gn(t,e,this.opts.numeric,this.opts.style!==`long`)}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}};const wt={firstDay:1,minimalDays:4,weekend:[6,7]};var T=class e{static fromOpts(t){return e.create(t.locale,t.numberingSystem,t.outputCalendar,t.weekSettings,t.defaultToEN)}static create(t,n,r,i,a=!1){let o=t||k.defaultLocale;return new e(o||(a?`en-US`:ut()),n||k.defaultNumberingSystem,r||k.defaultOutputCalendar,dn(i)||k.defaultWeekSettings,o)}static resetCache(){lt=null,rt.clear(),at.clear(),st.clear(),dt.clear(),pt.clear()}static fromObject({locale:t,numberingSystem:n,outputCalendar:r,weekSettings:i}={}){return e.create(t,n,r,i)}constructor(e,t,n,r,i){let[a,o,s]=ht(e);this.locale=a,this.numberingSystem=t||o||null,this.outputCalendar=n||s||null,this.weekSettings=r,this.intl=gt(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached??=bt(this),this.fastNumbersCached}listingMode(){let e=this.isEnglish(),t=(this.numberingSystem===null||this.numberingSystem===`latn`)&&(this.outputCalendar===null||this.outputCalendar===`gregory`);return e&&t?`en`:`intl`}clone(t){return!t||Object.getOwnPropertyNames(t).length===0?this:e.create(t.locale||this.specifiedLocale,t.numberingSystem||this.numberingSystem,t.outputCalendar||this.outputCalendar,dn(t.weekSettings)||this.weekSettings,t.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,t=!1){return yt(this,e,jn,()=>{let n=this.intl===`ja`||this.intl.startsWith(`ja-`);t&=!n;let r=t?{month:e,day:`numeric`}:{month:e},i=t?`format`:`standalone`;if(!this.monthsCache[i][e]){let t=n?e=>this.dtFormatter(e,r).format():e=>this.extract(e,r,`month`);this.monthsCache[i][e]=_t(t)}return this.monthsCache[i][e]})}weekdays(e,t=!1){return yt(this,e,Fn,()=>{let n=t?{weekday:e,year:`numeric`,month:`long`,day:`numeric`}:{weekday:e},r=t?`format`:`standalone`;return this.weekdaysCache[r][e]||(this.weekdaysCache[r][e]=vt(e=>this.extract(e,n,`weekday`))),this.weekdaysCache[r][e]})}meridiems(){return yt(this,void 0,()=>In,()=>{if(!this.meridiemCache){let e={hour:`numeric`,hourCycle:`h12`};this.meridiemCache=[$.utc(2016,11,13,9),$.utc(2016,11,13,19)].map(t=>this.extract(t,e,`dayperiod`))}return this.meridiemCache})}eras(e){return yt(this,e,Bn,()=>{let t={era:e};return this.eraCache[e]||(this.eraCache[e]=[$.utc(-40,1,1),$.utc(2017,1,1)].map(e=>this.extract(e,t,`era`))),this.eraCache[e]})}extract(e,t,n){let r=this.dtFormatter(e,t).formatToParts().find(e=>e.type.toLowerCase()===n);return r?r.value:null}numberFormatter(e={}){return new xt(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new St(e,this.intl,t)}relFormatter(e={}){return new Ct(this.intl,this.isEnglish(),e)}listFormatter(e={}){return nt(this.intl,e)}isEnglish(){return this.locale===`en`||this.locale.toLowerCase()===`en-us`||ft(this.intl).locale.startsWith(`en-us`)}getWeekSettings(){return this.weekSettings?this.weekSettings:sn()?mt(this.locale):wt}getStartOfWeek(){return this.getWeekSettings().firstDay}getMinDaysInFirstWeek(){return this.getWeekSettings().minimalDays}getWeekendDays(){return this.getWeekSettings().weekend}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}toString(){return`Locale(${this.locale}, ${this.numberingSystem}, ${this.outputCalendar})`}};let Tt=null;var E=class e extends Ke{static get utcInstance(){return Tt===null&&(Tt=new e(0)),Tt}static instance(t){return t===0?e.utcInstance:new e(t)}static parseSpecifier(t){if(t){let n=t.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(n)return new e(Cn(n[1],n[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return`fixed`}get name(){return this.fixed===0?`UTC`:`UTC${En(this.fixed,`narrow`)}`}get ianaName(){return this.fixed===0?`Etc/UTC`:`Etc/GMT${En(-this.fixed,`narrow`)}`}offsetName(){return this.name}formatOffset(e,t){return En(this.fixed,t)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type===`fixed`&&e.fixed===this.fixed}get isValid(){return!0}},Et=class extends Ke{constructor(e){super(),this.zoneName=e}get type(){return`invalid`}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return``}offset(){return NaN}equals(){return!1}get isValid(){return!1}};function D(e,t){if(M(e)||e===null)return t;if(e instanceof Ke)return e;if(rn(e)){let n=e.toLowerCase();return n===`default`?t:n===`local`||n===`system`?Je.instance:n===`utc`||n===`gmt`?E.utcInstance:E.parseSpecifier(n)||w.create(e)}else if(N(e))return E.instance(e);else if(typeof e==`object`&&`offset`in e&&typeof e.offset==`function`)return e;else return new Et(e)}const Dt={arab:`[٠-٩]`,arabext:`[۰-۹]`,bali:`[᭐-᭙]`,beng:`[০-৯]`,deva:`[०-९]`,fullwide:`[0-9]`,gujr:`[૦-૯]`,hanidec:`[〇|一|二|三|四|五|六|七|八|九]`,khmr:`[០-៩]`,knda:`[೦-೯]`,laoo:`[໐-໙]`,limb:`[᥆-᥏]`,mlym:`[൦-൯]`,mong:`[᠐-᠙]`,mymr:`[၀-၉]`,orya:`[୦-୯]`,tamldec:`[௦-௯]`,telu:`[౦-౯]`,thai:`[๐-๙]`,tibt:`[༠-༩]`,latn:`\\d`},Ot={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},kt=Dt.hanidec.replace(/[\[|\]]/g,``).split(``);function At(e){let t=parseInt(e,10);if(isNaN(t)){t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(e[n].search(Dt.hanidec)!==-1)t+=kt.indexOf(e[n]);else for(let e in Ot){let[n,i]=Ot[e];r>=n&&r<=i&&(t+=r-n)}}return parseInt(t,10)}else return t}const jt=new Map;function Mt(){jt.clear()}function O({numberingSystem:e},t=``){let n=e||`latn`,r=jt.get(n);r===void 0&&(r=new Map,jt.set(n,r));let i=r.get(t);return i===void 0&&(i=RegExp(`${Dt[n]}${t}`),r.set(t,i)),i}let Nt=()=>Date.now(),Pt=`system`,Ft=null,It=null,Lt=null,Rt=60,zt,Bt=null;var k=class{static get now(){return Nt}static set now(e){Nt=e}static set defaultZone(e){Pt=e}static get defaultZone(){return D(Pt,Je.instance)}static get defaultLocale(){return Ft}static set defaultLocale(e){Ft=e}static get defaultNumberingSystem(){return It}static set defaultNumberingSystem(e){It=e}static get defaultOutputCalendar(){return Lt}static set defaultOutputCalendar(e){Lt=e}static get defaultWeekSettings(){return Bt}static set defaultWeekSettings(e){Bt=dn(e)}static get twoDigitCutoffYear(){return Rt}static set twoDigitCutoffYear(e){Rt=e%100}static get throwOnInvalid(){return zt}static set throwOnInvalid(e){zt=e}static resetCaches(){T.resetCache(),w.resetCache(),$.resetCache(),Mt()}},A=class{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}};const Vt=[0,31,59,90,120,151,181,212,243,273,304,334],Ht=[0,31,60,91,121,152,182,213,244,274,305,335];function j(e,t){return new A(`unit out of range`,`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function Ut(e,t,n){let r=new Date(Date.UTC(e,t-1,n));e<100&&e>=0&&r.setUTCFullYear(r.getUTCFullYear()-1900);let i=r.getUTCDay();return i===0?7:i}function Wt(e,t,n){return n+(hn(e)?Ht:Vt)[t-1]}function Gt(e,t){let n=hn(e)?Ht:Vt,r=n.findIndex(e=>e<t),i=t-n[r];return{month:r+1,day:i}}function Kt(e,t){return(e-t+7)%7+1}function qt(e,t=4,n=1){let{year:r,month:i,day:a}=e,o=Wt(r,i,a),s=Kt(Ut(r,i,a),n),c=Math.floor((o-s+14-t)/7),l;return c<1?(l=r-1,c=bn(l,t,n)):c>bn(r,t,n)?(l=r+1,c=1):l=r,{weekYear:l,weekNumber:c,weekday:s,...Dn(e)}}function Jt(e,t=4,n=1){let{weekYear:r,weekNumber:i,weekday:a}=e,o=Kt(Ut(r,1,t),n),s=gn(r),c=i*7+a-o-7+t,l;c<1?(l=r-1,c+=gn(l)):c>s?(l=r+1,c-=gn(r)):l=r;let{month:u,day:d}=Gt(l,c);return{year:l,month:u,day:d,...Dn(e)}}function Yt(e){let{year:t,month:n,day:r}=e;return{year:t,ordinal:Wt(t,n,r),...Dn(e)}}function Xt(e){let{year:t,ordinal:n}=e,{month:r,day:i}=Gt(t,n);return{year:t,month:r,day:i,...Dn(e)}}function Zt(e,t){if(!M(e.localWeekday)||!M(e.localWeekNumber)||!M(e.localWeekYear)){if(!M(e.weekday)||!M(e.weekNumber)||!M(e.weekYear))throw new Se(`Cannot mix locale-based week fields with ISO-based week fields`);return M(e.localWeekday)||(e.weekday=e.localWeekday),M(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),M(e.localWeekYear)||(e.weekYear=e.localWeekYear),delete e.localWeekday,delete e.localWeekNumber,delete e.localWeekYear,{minDaysInFirstWeek:t.getMinDaysInFirstWeek(),startOfWeek:t.getStartOfWeek()}}else return{minDaysInFirstWeek:4,startOfWeek:1}}function Qt(e,t=4,n=1){let r=nn(e.weekYear),i=F(e.weekNumber,1,bn(e.weekYear,t,n)),a=F(e.weekday,1,7);return r?i?a?!1:j(`weekday`,e.weekday):j(`week`,e.weekNumber):j(`weekYear`,e.weekYear)}function $t(e){let t=nn(e.year),n=F(e.ordinal,1,gn(e.year));return t?n?!1:j(`ordinal`,e.ordinal):j(`year`,e.year)}function en(e){let t=nn(e.year),n=F(e.month,1,12),r=F(e.day,1,_n(e.year,e.month));return t?n?r?!1:j(`day`,e.day):j(`month`,e.month):j(`year`,e.year)}function tn(e){let{hour:t,minute:n,second:r,millisecond:i}=e,a=F(t,0,23)||t===24&&n===0&&r===0&&i===0,o=F(n,0,59),s=F(r,0,59),c=F(i,0,999);return a?o?s?c?!1:j(`millisecond`,i):j(`second`,r):j(`minute`,n):j(`hour`,t)}function M(e){return e===void 0}function N(e){return typeof e==`number`}function nn(e){return typeof e==`number`&&e%1==0}function rn(e){return typeof e==`string`}function an(e){return Object.prototype.toString.call(e)===`[object Date]`}function on(){try{return typeof Intl<`u`&&!!Intl.RelativeTimeFormat}catch{return!1}}function sn(){try{return typeof Intl<`u`&&!!Intl.Locale&&(`weekInfo`in Intl.Locale.prototype||`getWeekInfo`in Intl.Locale.prototype)}catch{return!1}}function cn(e){return Array.isArray(e)?e:[e]}function ln(e,t,n){if(e.length!==0)return e.reduce((e,r)=>{let i=[t(r),r];return e&&n(e[0],i[0])===e[0]?e:i},null)[1]}function un(e,t){return t.reduce((t,n)=>(t[n]=e[n],t),{})}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function dn(e){if(e==null)return null;if(typeof e!=`object`)throw new y(`Week settings must be an object`);if(!F(e.firstDay,1,7)||!F(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(e=>!F(e,1,7)))throw new y(`Invalid week settings`);return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function F(e,t,n){return nn(e)&&e>=t&&e<=n}function fn(e,t){return e-t*Math.floor(e/t)}function I(e,t=2){let n=e<0,r;return r=n?`-`+(``+-e).padStart(t,`0`):(``+e).padStart(t,`0`),r}function L(e){if(!(M(e)||e===null||e===``))return parseInt(e,10)}function R(e){if(!(M(e)||e===null||e===``))return parseFloat(e)}function pn(e){if(!(M(e)||e===null||e===``)){let t=parseFloat(`0.`+e)*1e3;return Math.floor(t)}}function mn(e,t,n=`round`){let r=10**t;switch(n){case`expand`:return e>0?Math.ceil(e*r)/r:Math.floor(e*r)/r;case`trunc`:return Math.trunc(e*r)/r;case`round`:return Math.round(e*r)/r;case`floor`:return Math.floor(e*r)/r;case`ceil`:return Math.ceil(e*r)/r;default:throw RangeError(`Value rounding ${n} is out of range`)}}function hn(e){return e%4==0&&(e%100!=0||e%400==0)}function gn(e){return hn(e)?366:365}function _n(e,t){let n=fn(t-1,12)+1,r=e+(t-n)/12;return n===2?hn(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function vn(e){let t=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute,e.second,e.millisecond);return e.year<100&&e.year>=0&&(t=new Date(t),t.setUTCFullYear(e.year,e.month-1,e.day)),+t}function yn(e,t,n){return-Kt(Ut(e,1,t),n)+t-1}function bn(e,t=4,n=1){let r=yn(e,t,n),i=yn(e+1,t,n);return(gn(e)-r+i)/7}function xn(e){return e>99?e:e>k.twoDigitCutoffYear?1900+e:2e3+e}function Sn(e,t,n,r=null){let i=new Date(e),a={hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`};r&&(a.timeZone=r);let o={timeZoneName:t,...a},s=new Intl.DateTimeFormat(n,o).formatToParts(i).find(e=>e.type.toLowerCase()===`timezonename`);return s?s.value:null}function Cn(e,t){let n=parseInt(e,10);Number.isNaN(n)&&(n=0);let r=parseInt(t,10)||0,i=n<0||Object.is(n,-0)?-r:r;return n*60+i}function wn(e){let t=Number(e);if(typeof e==`boolean`||e===``||!Number.isFinite(t))throw new y(`Invalid unit value ${e}`);return t}function Tn(e,t){let n={};for(let r in e)if(P(e,r)){let i=e[r];if(i==null)continue;n[t(r)]=wn(i)}return n}function En(e,t){let n=Math.trunc(Math.abs(e/60)),r=Math.trunc(Math.abs(e%60)),i=e>=0?`+`:`-`;switch(t){case`short`:return`${i}${I(n,2)}:${I(r,2)}`;case`narrow`:return`${i}${n}${r>0?`:${r}`:``}`;case`techie`:return`${i}${I(n,2)}${I(r,2)}`;default:throw RangeError(`Value format ${t} is out of range for property format`)}}function Dn(e){return un(e,[`hour`,`minute`,`second`,`millisecond`])}const On=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],kn=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],An=[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`];function jn(e){switch(e){case`narrow`:return[...An];case`short`:return[...kn];case`long`:return[...On];case`numeric`:return[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`,`12`];case`2-digit`:return[`01`,`02`,`03`,`04`,`05`,`06`,`07`,`08`,`09`,`10`,`11`,`12`];default:return null}}const Mn=[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],Nn=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],Pn=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function Fn(e){switch(e){case`narrow`:return[...Pn];case`short`:return[...Nn];case`long`:return[...Mn];case`numeric`:return[`1`,`2`,`3`,`4`,`5`,`6`,`7`];default:return null}}const In=[`AM`,`PM`],Ln=[`Before Christ`,`Anno Domini`],Rn=[`BC`,`AD`],zn=[`B`,`A`];function Bn(e){switch(e){case`narrow`:return[...zn];case`short`:return[...Rn];case`long`:return[...Ln];default:return null}}function Vn(e){return In[e.hour<12?0:1]}function Hn(e,t){return Fn(t)[e.weekday-1]}function Un(e,t){return jn(t)[e.month-1]}function Wn(e,t){return Bn(t)[e.year<0?0:1]}function Gn(e,t,n=`always`,r=!1){let i={years:[`year`,`yr.`],quarters:[`quarter`,`qtr.`],months:[`month`,`mo.`],weeks:[`week`,`wk.`],days:[`day`,`day`,`days`],hours:[`hour`,`hr.`],minutes:[`minute`,`min.`],seconds:[`second`,`sec.`]},a=[`hours`,`minutes`,`seconds`].indexOf(e)===-1;if(n===`auto`&&a){let n=e===`days`;switch(t){case 1:return n?`tomorrow`:`next ${i[e][0]}`;case-1:return n?`yesterday`:`last ${i[e][0]}`;case 0:return n?`today`:`this ${i[e][0]}`}}let o=Object.is(t,-0)||t<0,s=Math.abs(t),c=s===1,l=i[e],u=r?c?l[1]:l[2]||l[1]:c?i[e][0]:e;return o?`${s} ${u} ago`:`in ${s} ${u}`}function Kn(e,t){let n=``;for(let r of e)r.literal?n+=r.val:n+=t(r.val);return n}const qn={D:we,DD:Te,DDD:De,DDDD:Oe,t:ke,tt:Ae,ttt:je,tttt:Me,T:Ne,TT:Pe,TTT:Fe,TTTT:Ie,f:Le,ff:ze,fff:He,ffff:We,F:Re,FF:Be,FFF:Ue,FFFF:Ge};var z=class e{static create(t,n={}){return new e(t,n)}static parseFormat(e){let t=null,n=``,r=!1,i=[];for(let a=0;a<e.length;a++){let o=e.charAt(a);o===`'`?((n.length>0||r)&&i.push({literal:r||/^\s+$/.test(n),val:n===``?`'`:n}),t=null,n=``,r=!r):r||o===t?n+=o:(n.length>0&&i.push({literal:/^\s+$/.test(n),val:n}),n=o,t=o)}return n.length>0&&i.push({literal:r||/^\s+$/.test(n),val:n}),i}static macroTokenToFormatOpts(e){return qn[e]}constructor(e,t){this.opts=t,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,t){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...t}).format()}dtFormatter(e,t={}){return this.loc.dtFormatter(e,{...this.opts,...t})}formatDateTime(e,t){return this.dtFormatter(e,t).format()}formatDateTimeParts(e,t){return this.dtFormatter(e,t).formatToParts()}formatInterval(e,t){return this.dtFormatter(e.start,t).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,t){return this.dtFormatter(e,t).resolvedOptions()}num(e,t=0,n=void 0){if(this.opts.forceSimple)return I(e,t);let r={...this.opts};return t>0&&(r.padTo=t),n&&(r.signDisplay=n),this.loc.numberFormatter(r).format(e)}formatDateTimeFromString(t,n){let r=this.loc.listingMode()===`en`,i=this.loc.outputCalendar&&this.loc.outputCalendar!==`gregory`,a=(e,n)=>this.loc.extract(t,e,n),o=e=>t.isOffsetFixed&&t.offset===0&&e.allowZ?`Z`:t.isValid?t.zone.formatOffset(t.ts,e.format):``,s=()=>r?Vn(t):a({hour:`numeric`,hourCycle:`h12`},`dayperiod`),c=(e,n)=>r?Un(t,e):a(n?{month:e}:{month:e,day:`numeric`},`month`),l=(e,n)=>r?Hn(t,e):a(n?{weekday:e}:{weekday:e,month:`long`,day:`numeric`},`weekday`),u=n=>{let r=e.macroTokenToFormatOpts(n);return r?this.formatWithSystemDefault(t,r):n},d=e=>r?Wn(t,e):a({era:e},`era`);return Kn(e.parseFormat(n),e=>{switch(e){case`S`:return this.num(t.millisecond);case`u`:case`SSS`:return this.num(t.millisecond,3);case`s`:return this.num(t.second);case`ss`:return this.num(t.second,2);case`uu`:return this.num(Math.floor(t.millisecond/10),2);case`uuu`:return this.num(Math.floor(t.millisecond/100));case`m`:return this.num(t.minute);case`mm`:return this.num(t.minute,2);case`h`:return this.num(t.hour%12==0?12:t.hour%12);case`hh`:return this.num(t.hour%12==0?12:t.hour%12,2);case`H`:return this.num(t.hour);case`HH`:return this.num(t.hour,2);case`Z`:return o({format:`narrow`,allowZ:this.opts.allowZ});case`ZZ`:return o({format:`short`,allowZ:this.opts.allowZ});case`ZZZ`:return o({format:`techie`,allowZ:this.opts.allowZ});case`ZZZZ`:return t.zone.offsetName(t.ts,{format:`short`,locale:this.loc.locale});case`ZZZZZ`:return t.zone.offsetName(t.ts,{format:`long`,locale:this.loc.locale});case`z`:return t.zoneName;case`a`:return s();case`d`:return i?a({day:`numeric`},`day`):this.num(t.day);case`dd`:return i?a({day:`2-digit`},`day`):this.num(t.day,2);case`c`:return this.num(t.weekday);case`ccc`:return l(`short`,!0);case`cccc`:return l(`long`,!0);case`ccccc`:return l(`narrow`,!0);case`E`:return this.num(t.weekday);case`EEE`:return l(`short`,!1);case`EEEE`:return l(`long`,!1);case`EEEEE`:return l(`narrow`,!1);case`L`:return i?a({month:`numeric`,day:`numeric`},`month`):this.num(t.month);case`LL`:return i?a({month:`2-digit`,day:`numeric`},`month`):this.num(t.month,2);case`LLL`:return c(`short`,!0);case`LLLL`:return c(`long`,!0);case`LLLLL`:return c(`narrow`,!0);case`M`:return i?a({month:`numeric`},`month`):this.num(t.month);case`MM`:return i?a({month:`2-digit`},`month`):this.num(t.month,2);case`MMM`:return c(`short`,!1);case`MMMM`:return c(`long`,!1);case`MMMMM`:return c(`narrow`,!1);case`y`:return i?a({year:`numeric`},`year`):this.num(t.year);case`yy`:return i?a({year:`2-digit`},`year`):this.num(t.year.toString().slice(-2),2);case`yyyy`:return i?a({year:`numeric`},`year`):this.num(t.year,4);case`yyyyyy`:return i?a({year:`numeric`},`year`):this.num(t.year,6);case`G`:return d(`short`);case`GG`:return d(`long`);case`GGGGG`:return d(`narrow`);case`kk`:return this.num(t.weekYear.toString().slice(-2),2);case`kkkk`:return this.num(t.weekYear,4);case`W`:return this.num(t.weekNumber);case`WW`:return this.num(t.weekNumber,2);case`n`:return this.num(t.localWeekNumber);case`nn`:return this.num(t.localWeekNumber,2);case`ii`:return this.num(t.localWeekYear.toString().slice(-2),2);case`iiii`:return this.num(t.localWeekYear,4);case`o`:return this.num(t.ordinal);case`ooo`:return this.num(t.ordinal,3);case`q`:return this.num(t.quarter);case`qq`:return this.num(t.quarter,2);case`X`:return this.num(Math.floor(t.ts/1e3));case`x`:return this.num(t.ts);default:return u(e)}})}formatDurationFromString(t,n){let r=this.opts.signMode===`negativeLargestOnly`?-1:1,i=e=>{switch(e[0]){case`S`:return`milliseconds`;case`s`:return`seconds`;case`m`:return`minutes`;case`h`:return`hours`;case`d`:return`days`;case`w`:return`weeks`;case`M`:return`months`;case`y`:return`years`;default:return null}},a=(e,t)=>n=>{let a=i(n);if(a){let i=t.isNegativeDuration&&a!==t.largestUnit?r:1,o;return o=this.opts.signMode===`negativeLargestOnly`&&a!==t.largestUnit?`never`:this.opts.signMode===`all`?`always`:`auto`,this.num(e.get(a)*i,n.length,o)}else return n},o=e.parseFormat(n),s=o.reduce((e,{literal:t,val:n})=>t?e:e.concat(n),[]),c=t.shiftTo(...s.map(i).filter(e=>e));return Kn(o,a(c,{isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]}))}};const Jn=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function B(...e){let t=e.reduce((e,t)=>e+t.source,``);return RegExp(`^${t}$`)}function V(...e){return t=>e.reduce(([e,n,r],i)=>{let[a,o,s]=i(t,r);return[{...e,...a},o||n,s]},[{},null,1]).slice(0,2)}function H(e,...t){if(e==null)return[null,null];for(let[n,r]of t){let t=n.exec(e);if(t)return r(t)}return[null,null]}function Yn(...e){return(t,n)=>{let r={},i;for(i=0;i<e.length;i++)r[e[i]]=L(t[n+i]);return[r,null,n+i]}}const Xn=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Zn=`(?:${Xn.source}?(?:\\[(${Jn.source})\\])?)?`,Qn=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,$n=RegExp(`${Qn.source}${Zn}`),er=RegExp(`(?:[Tt]${$n.source})?`),tr=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,nr=/(\d{4})-?W(\d\d)(?:-?(\d))?/,rr=/(\d{4})-?(\d{3})/,ir=Yn(`weekYear`,`weekNumber`,`weekDay`),ar=Yn(`year`,`ordinal`),or=/(\d{4})-(\d\d)-(\d\d)/,sr=RegExp(`${Qn.source} ?(?:${Xn.source}|(${Jn.source}))?`),cr=RegExp(`(?: ${sr.source})?`);function U(e,t,n){let r=e[t];return M(r)?n:L(r)}function lr(e,t){return[{year:U(e,t),month:U(e,t+1,1),day:U(e,t+2,1)},null,t+3]}function W(e,t){return[{hours:U(e,t,0),minutes:U(e,t+1,0),seconds:U(e,t+2,0),milliseconds:pn(e[t+3])},null,t+4]}function ur(e,t){let n=!e[t]&&!e[t+1],r=Cn(e[t+1],e[t+2]);return[{},n?null:E.instance(r),t+3]}function dr(e,t){return[{},e[t]?w.create(e[t]):null,t+1]}const fr=RegExp(`^T?${Qn.source}$`),pr=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function mr(e){let[t,n,r,i,a,o,s,c,l]=e,u=t[0]===`-`,d=c&&c[0]===`-`,f=(e,t=!1)=>e!==void 0&&(t||e&&u)?-e:e;return[{years:f(R(n)),months:f(R(r)),weeks:f(R(i)),days:f(R(a)),hours:f(R(o)),minutes:f(R(s)),seconds:f(R(c),c===`-0`),milliseconds:f(pn(l),d)}]}const hr={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function gr(e,t,n,r,i,a,o){let s={year:t.length===2?xn(L(t)):L(t),month:kn.indexOf(n)+1,day:L(r),hour:L(i),minute:L(a)};return o&&(s.second=L(o)),e&&(s.weekday=e.length>3?Mn.indexOf(e)+1:Nn.indexOf(e)+1),s}const _r=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function vr(e){let[,t,n,r,i,a,o,s,c,l,u,d]=e,f=gr(t,i,r,n,a,o,s),p;return p=c?hr[c]:l?0:Cn(u,d),[f,new E(p)]}function yr(e){return e.replace(/\([^()]*\)|[\n\t]/g,` `).replace(/(\s\s+)/g,` `).trim()}const br=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,xr=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,Sr=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function Cr(e){let[,t,n,r,i,a,o,s]=e;return[gr(t,i,r,n,a,o,s),E.utcInstance]}function wr(e){let[,t,n,r,i,a,o,s]=e;return[gr(t,s,n,r,i,a,o),E.utcInstance]}const Tr=B(tr,er),Er=B(nr,er),Dr=B(rr,er),Or=B($n),kr=V(lr,W,ur,dr),Ar=V(ir,W,ur,dr),jr=V(ar,W,ur,dr),Mr=V(W,ur,dr);function Nr(e){return H(e,[Tr,kr],[Er,Ar],[Dr,jr],[Or,Mr])}function Pr(e){return H(yr(e),[_r,vr])}function Fr(e){return H(e,[br,Cr],[xr,Cr],[Sr,wr])}function Ir(e){return H(e,[pr,mr])}const Lr=V(W);function Rr(e){return H(e,[fr,Lr])}const zr=B(or,cr),Br=B(sr),Vr=V(W,ur,dr);function Hr(e){return H(e,[zr,kr],[Br,Vr])}const Ur=`Invalid Duration`,Wr={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},Gr={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...Wr},G=146097/400,K=146097/4800,Kr={years:{quarters:4,months:12,weeks:G/7,days:G,hours:G*24,minutes:G*24*60,seconds:G*24*60*60,milliseconds:G*24*60*60*1e3},quarters:{months:3,weeks:G/28,days:G/4,hours:G*24/4,minutes:G*24*60/4,seconds:G*24*60*60/4,milliseconds:G*24*60*60*1e3/4},months:{weeks:K/7,days:K,hours:K*24,minutes:K*24*60,seconds:K*24*60*60,milliseconds:K*24*60*60*1e3},...Wr},q=[`years`,`quarters`,`months`,`weeks`,`days`,`hours`,`minutes`,`seconds`,`milliseconds`],qr=q.slice(0).reverse();function J(e,t,n=!1){return new Y({values:n?t.values:{...e.values,...t.values||{}},loc:e.loc.clone(t.loc),conversionAccuracy:t.conversionAccuracy||e.conversionAccuracy,matrix:t.matrix||e.matrix})}function Jr(e,t){let n=t.milliseconds??0;for(let r of qr.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function Yr(e,t){let n=Jr(e,t)<0?-1:1;q.reduceRight((r,i)=>{if(M(t[i]))return r;if(r){let a=t[r]*n,o=e[i][r],s=Math.floor(a/o);t[i]+=s*n,t[r]-=s*o*n}return i},null),q.reduce((n,r)=>{if(M(t[r]))return n;if(n){let i=t[n]%1;t[n]-=i,t[r]+=i*e[n][r]}return r},null)}function Xr(e){let t={};for(let[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}var Y=class e{constructor(e){let t=e.conversionAccuracy===`longterm`||!1,n=t?Kr:Gr;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||T.create(),this.conversionAccuracy=t?`longterm`:`casual`,this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(t,n){return e.fromObject({milliseconds:t},n)}static fromObject(t,n={}){if(typeof t!=`object`||!t)throw new y(`Duration.fromObject: argument expected to be an object, got ${t===null?`null`:typeof t}`);return new e({values:Tn(t,e.normalizeUnit),loc:T.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(N(t))return e.fromMillis(t);if(e.isDuration(t))return t;if(typeof t==`object`)return e.fromObject(t);throw new y(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){let[r]=Ir(t);return r?e.fromObject(r,n):e.invalid(`unparsable`,`the input "${t}" can't be parsed as ISO 8601`)}static fromISOTime(t,n){let[r]=Rr(t);return r?e.fromObject(r,n):e.invalid(`unparsable`,`the input "${t}" can't be parsed as ISO 8601`)}static invalid(t,n=null){if(!t)throw new y(`need to specify a reason the Duration is invalid`);let r=t instanceof A?t:new A(t,n);if(k.throwOnInvalid)throw new xe(r);return new e({invalid:r})}static normalizeUnit(e){let t={year:`years`,years:`years`,quarter:`quarters`,quarters:`quarters`,month:`months`,months:`months`,week:`weeks`,weeks:`weeks`,day:`days`,days:`days`,hour:`hours`,hours:`hours`,minute:`minutes`,minutes:`minutes`,second:`seconds`,seconds:`seconds`,millisecond:`milliseconds`,milliseconds:`milliseconds`}[e&&e.toLowerCase()];if(!t)throw new Ce(e);return t}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,t={}){let n={...t,floor:t.round!==!1&&t.floor!==!1};return this.isValid?z.create(this.loc,n).formatDurationFromString(this,e):Ur}toHuman(e={}){if(!this.isValid)return Ur;let t=e.showZeros!==!1,n=q.map(n=>{let r=this.values[n];return M(r)||r===0&&!t?null:this.loc.numberFormatter({style:`unit`,unitDisplay:`long`,...e,unit:n.slice(0,-1)}).format(r)}).filter(e=>e);return this.loc.listFormatter({type:`conjunction`,style:e.listStyle||`narrow`,...e}).format(n)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e=`P`;return this.years!==0&&(e+=this.years+`Y`),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+`M`),this.weeks!==0&&(e+=this.weeks+`W`),this.days!==0&&(e+=this.days+`D`),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+=`T`),this.hours!==0&&(e+=this.hours+`H`),this.minutes!==0&&(e+=this.minutes+`M`),(this.seconds!==0||this.milliseconds!==0)&&(e+=mn(this.seconds+this.milliseconds/1e3,3)+`S`),e===`P`&&(e+=`T0S`),e}toISOTime(e={}){if(!this.isValid)return null;let t=this.toMillis();return t<0||t>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:`extended`,...e,includeOffset:!1},$.fromMillis(t,{zone:`UTC`}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.isValid?`Duration { values: ${JSON.stringify(this.values)} }`:`Duration { Invalid, reason: ${this.invalidReason} }`}toMillis(){return this.isValid?Jr(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(t){if(!this.isValid)return this;let n=e.fromDurationLike(t),r={};for(let e of q)(P(n.values,e)||P(this.values,e))&&(r[e]=n.get(e)+this.get(e));return J(this,{values:r},!0)}minus(t){if(!this.isValid)return this;let n=e.fromDurationLike(t);return this.plus(n.negate())}mapUnits(e){if(!this.isValid)return this;let t={};for(let n of Object.keys(this.values))t[n]=wn(e(this.values[n],n));return J(this,{values:t},!0)}get(t){return this[e.normalizeUnit(t)]}set(t){if(!this.isValid)return this;let n={...this.values,...Tn(t,e.normalizeUnit)};return J(this,{values:n})}reconfigure({locale:e,numberingSystem:t,conversionAccuracy:n,matrix:r}={}){let i={loc:this.loc.clone({locale:e,numberingSystem:t}),matrix:r,conversionAccuracy:n};return J(this,i)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return Yr(this.matrix,e),J(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=Xr(this.normalize().shiftToAll().toObject());return J(this,{values:e},!0)}shiftTo(...t){if(!this.isValid||t.length===0)return this;t=t.map(t=>e.normalizeUnit(t));let n={},r={},i=this.toObject(),a;for(let e of q)if(t.indexOf(e)>=0){a=e;let t=0;for(let n in r)t+=this.matrix[n][e]*r[n],r[n]=0;N(i[e])&&(t+=i[e]);let o=Math.trunc(t);n[e]=o,r[e]=(t*1e3-o*1e3)/1e3}else N(i[e])&&(r[e]=i[e]);for(let e in r)r[e]!==0&&(n[a]+=e===a?r[e]:r[e]/this.matrix[a][e]);return Yr(this.matrix,n),J(this,{values:n},!0)}shiftToAll(){return this.isValid?this.shiftTo(`years`,`months`,`weeks`,`days`,`hours`,`minutes`,`seconds`,`milliseconds`):this}negate(){if(!this.isValid)return this;let e={};for(let t of Object.keys(this.values))e[t]=this.values[t]===0?0:-this.values[t];return J(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;let e=Xr(this.values);return J(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function t(e,t){return e===void 0||e===0?t===void 0||t===0:e===t}for(let n of q)if(!t(this.values[n],e.values[n]))return!1;return!0}};const Zr=`Invalid Interval`;function Qr(e,t){return!e||!e.isValid?$r.invalid(`missing or invalid start`):!t||!t.isValid?$r.invalid(`missing or invalid end`):t<e?$r.invalid(`end before start`,`The end of an interval must be after its start, but you had start=${e.toISO()} and end=${t.toISO()}`):null}var $r=class e{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(t,n=null){if(!t)throw new y(`need to specify a reason the Interval is invalid`);let r=t instanceof A?t:new A(t,n);if(k.throwOnInvalid)throw new be(r);return new e({invalid:r})}static fromDateTimes(t,n){let r=Qi(t),i=Qi(n);return Qr(r,i)??new e({start:r,end:i})}static after(t,n){let r=Y.fromDurationLike(n),i=Qi(t);return e.fromDateTimes(i,i.plus(r))}static before(t,n){let r=Y.fromDurationLike(n),i=Qi(t);return e.fromDateTimes(i.minus(r),i)}static fromISO(t,n){let[r,i]=(t||``).split(`/`,2);if(r&&i){let t,a;try{t=$.fromISO(r,n),a=t.isValid}catch{a=!1}let o,s;try{o=$.fromISO(i,n),s=o.isValid}catch{s=!1}if(a&&s)return e.fromDateTimes(t,o);if(a){let r=Y.fromISO(i,n);if(r.isValid)return e.after(t,r)}else if(s){let t=Y.fromISO(r,n);if(t.isValid)return e.before(o,t)}}return e.invalid(`unparsable`,`the input "${t}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get lastDateTime(){return this.isValid&&this.e?this.e.minus(1):null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e=`milliseconds`){return this.isValid?this.toDuration(e).get(e):NaN}count(e=`milliseconds`,t){if(!this.isValid)return NaN;let n=this.start.startOf(e,t),r;return r=t?.useLocaleWeeks?this.end.reconfigure({locale:n.locale}):this.end,r=r.startOf(e,t),Math.floor(r.diff(n,e).get(e))+(r.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:t,end:n}={}){return this.isValid?e.fromDateTimes(t||this.s,n||this.e):this}splitAt(...t){if(!this.isValid)return[];let n=t.map(Qi).filter(e=>this.contains(e)).sort((e,t)=>e.toMillis()-t.toMillis()),r=[],{s:i}=this,a=0;for(;i<this.e;){let t=n[a]||this.e,o=+t>+this.e?this.e:t;r.push(e.fromDateTimes(i,o)),i=o,a+=1}return r}splitBy(t){let n=Y.fromDurationLike(t);if(!this.isValid||!n.isValid||n.as(`milliseconds`)===0)return[];let{s:r}=this,i=1,a,o=[];for(;r<this.e;){let t=this.start.plus(n.mapUnits(e=>e*i));a=+t>+this.e?this.e:t,o.push(e.fromDateTimes(r,a)),r=a,i+=1}return o}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(t){if(!this.isValid)return this;let n=this.s>t.s?this.s:t.s,r=this.e<t.e?this.e:t.e;return n>=r?null:e.fromDateTimes(n,r)}union(t){if(!this.isValid)return this;let n=this.s<t.s?this.s:t.s,r=this.e>t.e?this.e:t.e;return e.fromDateTimes(n,r)}static merge(e){let[t,n]=e.sort((e,t)=>e.s-t.s).reduce(([e,t],n)=>t?t.overlaps(n)||t.abutsStart(n)?[e,t.union(n)]:[e.concat([t]),n]:[e,n],[[],null]);return n&&t.push(n),t}static xor(t){let n=null,r=0,i=[],a=t.map(e=>[{time:e.s,type:`s`},{time:e.e,type:`e`}]),o=Array.prototype.concat(...a).sort((e,t)=>e.time-t.time);for(let t of o)r+=t.type===`s`?1:-1,r===1?n=t.time:(n&&+n!=+t.time&&i.push(e.fromDateTimes(n,t.time)),n=null);return e.merge(i)}difference(...t){return e.xor([this].concat(t)).map(e=>this.intersection(e)).filter(e=>e&&!e.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} – ${this.e.toISO()})`:Zr}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.isValid?`Interval { start: ${this.s.toISO()}, end: ${this.e.toISO()} }`:`Interval { Invalid, reason: ${this.invalidReason} }`}toLocaleString(e=we,t={}){return this.isValid?z.create(this.s.loc.clone(t),e).formatInterval(this):Zr}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Zr}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Zr}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Zr}toFormat(e,{separator:t=` – `}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:Zr}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):Y.invalid(this.invalidReason)}mapEndpoints(t){return e.fromDateTimes(t(this.s),t(this.e))}},ei=class{static hasDST(e=k.defaultZone){let t=$.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return w.isValidZone(e)}static normalizeZone(e){return D(e,k.defaultZone)}static getStartOfWeek({locale:e=null,locObj:t=null}={}){return(t||T.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:t=null}={}){return(t||T.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:t=null}={}){return(t||T.create(e)).getWeekendDays().slice()}static months(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||T.create(t,n,i)).months(e)}static monthsFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||T.create(t,n,i)).months(e,!0)}static weekdays(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||T.create(t,n,null)).weekdays(e)}static weekdaysFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||T.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return T.create(e).meridiems()}static eras(e=`short`,{locale:t=null}={}){return T.create(t,null,`gregory`).eras(e)}static features(){return{relative:on(),localeWeek:sn()}}};function ti(e,t){let n=e=>e.toUTC(0,{keepLocalTime:!0}).startOf(`day`).valueOf(),r=n(t)-n(e);return Math.floor(Y.fromMillis(r).as(`days`))}function ni(e,t,n){let r=[[`years`,(e,t)=>t.year-e.year],[`quarters`,(e,t)=>t.quarter-e.quarter+(t.year-e.year)*4],[`months`,(e,t)=>t.month-e.month+(t.year-e.year)*12],[`weeks`,(e,t)=>{let n=ti(e,t);return(n-n%7)/7}],[`days`,ti]],i={},a=e,o,s;for(let[c,l]of r)n.indexOf(c)>=0&&(o=c,i[c]=l(e,t),s=a.plus(i),s>t?(i[c]--,e=a.plus(i),e>t&&(s=e,i[c]--,e=a.plus(i))):e=s);return[e,i,s,o]}function ri(e,t,n,r){let[i,a,o,s]=ni(e,t,n),c=t-i,l=n.filter(e=>[`hours`,`minutes`,`seconds`,`milliseconds`].indexOf(e)>=0);l.length===0&&(o<t&&(o=i.plus({[s]:1})),o!==i&&(a[s]=(a[s]||0)+c/(o-i)));let u=Y.fromObject(a,r);return l.length>0?Y.fromMillis(c,r).shiftTo(...l).plus(u):u}function X(e,t=e=>e){return{regex:e,deser:([e])=>t(At(e))}}const ii=`[ \xA0]`,ai=new RegExp(ii,`g`);function oi(e){return e.replace(/\./g,`\\.?`).replace(ai,ii)}function si(e){return e.replace(/\./g,``).replace(ai,` `).toLowerCase()}function Z(e,t){return e===null?null:{regex:RegExp(e.map(oi).join(`|`)),deser:([n])=>e.findIndex(e=>si(n)===si(e))+t}}function ci(e,t){return{regex:e,deser:([,e,t])=>Cn(e,t),groups:t}}function li(e){return{regex:e,deser:([e])=>e}}function ui(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,`\\$&`)}function di(e,t){let n=O(t),r=O(t,`{2}`),i=O(t,`{3}`),a=O(t,`{4}`),o=O(t,`{6}`),s=O(t,`{1,2}`),c=O(t,`{1,3}`),l=O(t,`{1,6}`),u=O(t,`{1,9}`),d=O(t,`{2,4}`),f=O(t,`{4,6}`),p=e=>({regex:RegExp(ui(e.val)),deser:([e])=>e,literal:!0}),m=(m=>{if(e.literal)return p(m);switch(m.val){case`G`:return Z(t.eras(`short`),0);case`GG`:return Z(t.eras(`long`),0);case`y`:return X(l);case`yy`:return X(d,xn);case`yyyy`:return X(a);case`yyyyy`:return X(f);case`yyyyyy`:return X(o);case`M`:return X(s);case`MM`:return X(r);case`MMM`:return Z(t.months(`short`,!0),1);case`MMMM`:return Z(t.months(`long`,!0),1);case`L`:return X(s);case`LL`:return X(r);case`LLL`:return Z(t.months(`short`,!1),1);case`LLLL`:return Z(t.months(`long`,!1),1);case`d`:return X(s);case`dd`:return X(r);case`o`:return X(c);case`ooo`:return X(i);case`HH`:return X(r);case`H`:return X(s);case`hh`:return X(r);case`h`:return X(s);case`mm`:return X(r);case`m`:return X(s);case`q`:return X(s);case`qq`:return X(r);case`s`:return X(s);case`ss`:return X(r);case`S`:return X(c);case`SSS`:return X(i);case`u`:return li(u);case`uu`:return li(s);case`uuu`:return X(n);case`a`:return Z(t.meridiems(),0);case`kkkk`:return X(a);case`kk`:return X(d,xn);case`W`:return X(s);case`WW`:return X(r);case`E`:case`c`:return X(n);case`EEE`:return Z(t.weekdays(`short`,!1),1);case`EEEE`:return Z(t.weekdays(`long`,!1),1);case`ccc`:return Z(t.weekdays(`short`,!0),1);case`cccc`:return Z(t.weekdays(`long`,!0),1);case`Z`:case`ZZ`:return ci(RegExp(`([+-]${s.source})(?::(${r.source}))?`),2);case`ZZZ`:return ci(RegExp(`([+-]${s.source})(${r.source})?`),2);case`z`:return li(/[a-z_+-/]{1,256}?/i);case` `:return li(/[^\S\n\r]/);default:return p(m)}})(e)||{invalidReason:`missing Intl.DateTimeFormat.formatToParts support`};return m.token=e,m}const fi={year:{"2-digit":`yy`,numeric:`yyyyy`},month:{numeric:`M`,"2-digit":`MM`,short:`MMM`,long:`MMMM`},day:{numeric:`d`,"2-digit":`dd`},weekday:{short:`EEE`,long:`EEEE`},dayperiod:`a`,dayPeriod:`a`,hour12:{numeric:`h`,"2-digit":`hh`},hour24:{numeric:`H`,"2-digit":`HH`},minute:{numeric:`m`,"2-digit":`mm`},second:{numeric:`s`,"2-digit":`ss`},timeZoneName:{long:`ZZZZZ`,short:`ZZZ`}};function pi(e,t,n){let{type:r,value:i}=e;if(r===`literal`){let e=/^\s+$/.test(i);return{literal:!e,val:e?` `:i}}let a=t[r],o=r;r===`hour`&&(o=t.hour12==null?t.hourCycle==null?n.hour12?`hour12`:`hour24`:t.hourCycle===`h11`||t.hourCycle===`h12`?`hour12`:`hour24`:t.hour12?`hour12`:`hour24`);let s=fi[o];if(typeof s==`object`&&(s=s[a]),s)return{literal:!1,val:s}}function mi(e){return[`^${e.map(e=>e.regex).reduce((e,t)=>`${e}(${t.source})`,``)}$`,e]}function hi(e,t,n){let r=e.match(t);if(r){let e={},t=1;for(let i in n)if(P(n,i)){let a=n[i],o=a.groups?a.groups+1:1;!a.literal&&a.token&&(e[a.token.val[0]]=a.deser(r.slice(t,t+o))),t+=o}return[r,e]}else return[r,{}]}function gi(e){let t=e=>{switch(e){case`S`:return`millisecond`;case`s`:return`second`;case`m`:return`minute`;case`h`:case`H`:return`hour`;case`d`:return`day`;case`o`:return`ordinal`;case`L`:case`M`:return`month`;case`y`:return`year`;case`E`:case`c`:return`weekday`;case`W`:return`weekNumber`;case`k`:return`weekYear`;case`q`:return`quarter`;default:return null}},n=null,r;return M(e.z)||(n=w.create(e.z)),M(e.Z)||(n||=new E(e.Z),r=e.Z),M(e.q)||(e.M=(e.q-1)*3+1),M(e.h)||(e.h<12&&e.a===1?e.h+=12:e.h===12&&e.a===0&&(e.h=0)),e.G===0&&e.y&&(e.y=-e.y),M(e.u)||(e.S=pn(e.u)),[Object.keys(e).reduce((n,r)=>{let i=t(r);return i&&(n[i]=e[r]),n},{}),n,r]}let _i=null;function vi(){return _i||=$.fromMillis(1555555555555),_i}function yi(e,t){if(e.literal)return e;let n=wi(z.macroTokenToFormatOpts(e.val),t);return n==null||n.includes(void 0)?e:n}function bi(e,t){return Array.prototype.concat(...e.map(e=>yi(e,t)))}var xi=class{constructor(e,t){if(this.locale=e,this.format=t,this.tokens=bi(z.parseFormat(t),e),this.units=this.tokens.map(t=>di(t,e)),this.disqualifyingUnit=this.units.find(e=>e.invalidReason),!this.disqualifyingUnit){let[e,t]=mi(this.units);this.regex=RegExp(e,`i`),this.handlers=t}}explainFromTokens(e){if(this.isValid){let[t,n]=hi(e,this.regex,this.handlers),[r,i,a]=n?gi(n):[null,null,void 0];if(P(n,`a`)&&P(n,`H`))throw new Se(`Can't include meridiem when specifying 24-hour format`);return{input:e,tokens:this.tokens,regex:this.regex,rawMatches:t,matches:n,result:r,zone:i,specificOffset:a}}else return{input:e,tokens:this.tokens,invalidReason:this.invalidReason}}get isValid(){return!this.disqualifyingUnit}get invalidReason(){return this.disqualifyingUnit?this.disqualifyingUnit.invalidReason:null}};function Si(e,t,n){return new xi(e,n).explainFromTokens(t)}function Ci(e,t,n){let{result:r,zone:i,specificOffset:a,invalidReason:o}=Si(e,t,n);return[r,i,a,o]}function wi(e,t){if(!e)return null;let n=z.create(t,e).dtFormatter(vi()),r=n.formatToParts(),i=n.resolvedOptions();return r.map(t=>pi(t,e,i))}const Ti=`Invalid DateTime`,Ei=864e13;function Di(e){return new A(`unsupported zone`,`the zone "${e.name}" is not supported`)}function Oi(e){return e.weekData===null&&(e.weekData=qt(e.c)),e.weekData}function ki(e){return e.localWeekData===null&&(e.localWeekData=qt(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function Q(e,t){let n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new $({...n,...t,old:n})}function Ai(e,t,n){let r=e-t*60*1e3,i=n.offset(r);if(t===i)return[r,t];r-=(i-t)*60*1e3;let a=n.offset(r);return i===a?[r,i]:[e-Math.min(i,a)*60*1e3,Math.max(i,a)]}function ji(e,t){e+=t*60*1e3;let n=new Date(e);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),millisecond:n.getUTCMilliseconds()}}function Mi(e,t,n){return Ai(vn(e),t,n)}function Ni(e,t){let n=e.o,r=e.c.year+Math.trunc(t.years),i=e.c.month+Math.trunc(t.months)+Math.trunc(t.quarters)*3,a={...e.c,year:r,month:i,day:Math.min(e.c.day,_n(r,i))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},o=Y.fromObject({years:t.years-Math.trunc(t.years),quarters:t.quarters-Math.trunc(t.quarters),months:t.months-Math.trunc(t.months),weeks:t.weeks-Math.trunc(t.weeks),days:t.days-Math.trunc(t.days),hours:t.hours,minutes:t.minutes,seconds:t.seconds,milliseconds:t.milliseconds}).as(`milliseconds`),[s,c]=Ai(vn(a),n,e.zone);return o!==0&&(s+=o,c=e.zone.offset(s)),{ts:s,o:c}}function Pi(e,t,n,r,i,a){let{setZone:o,zone:s}=n;if(e&&Object.keys(e).length!==0||t){let r=t||s,i=$.fromObject(e,{...n,zone:r,specificOffset:a});return o?i:i.setZone(s)}else return $.invalid(new A(`unparsable`,`the input "${i}" can't be parsed as ${r}`))}function Fi(e,t,n=!0){return e.isValid?z.create(T.create(`en-US`),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function Ii(e,t,n){let r=e.c.year>9999||e.c.year<0,i=``;if(r&&e.c.year>=0&&(i+=`+`),i+=I(e.c.year,r?6:4),n===`year`)return i;if(t){if(i+=`-`,i+=I(e.c.month),n===`month`)return i;i+=`-`}else if(i+=I(e.c.month),n===`month`)return i;return i+=I(e.c.day),i}function Li(e,t,n,r,i,a,o){let s=!n||e.c.millisecond!==0||e.c.second!==0,c=``;switch(o){case`day`:case`month`:case`year`:break;default:if(c+=I(e.c.hour),o===`hour`)break;if(t){if(c+=`:`,c+=I(e.c.minute),o===`minute`)break;s&&(c+=`:`,c+=I(e.c.second))}else{if(c+=I(e.c.minute),o===`minute`)break;s&&(c+=I(e.c.second))}if(o===`second`)break;s&&(!r||e.c.millisecond!==0)&&(c+=`.`,c+=I(e.c.millisecond,3))}return i&&(e.isOffsetFixed&&e.offset===0&&!a?c+=`Z`:e.o<0?(c+=`-`,c+=I(Math.trunc(-e.o/60)),c+=`:`,c+=I(Math.trunc(-e.o%60))):(c+=`+`,c+=I(Math.trunc(e.o/60)),c+=`:`,c+=I(Math.trunc(e.o%60)))),a&&(c+=`[`+e.zone.ianaName+`]`),c}const Ri={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},zi={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Bi={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Vi=[`year`,`month`,`day`,`hour`,`minute`,`second`,`millisecond`],Hi=[`weekYear`,`weekNumber`,`weekday`,`hour`,`minute`,`second`,`millisecond`],Ui=[`year`,`ordinal`,`hour`,`minute`,`second`,`millisecond`];function Wi(e){let t={year:`year`,years:`year`,month:`month`,months:`month`,day:`day`,days:`day`,hour:`hour`,hours:`hour`,minute:`minute`,minutes:`minute`,quarter:`quarter`,quarters:`quarter`,second:`second`,seconds:`second`,millisecond:`millisecond`,milliseconds:`millisecond`,weekday:`weekday`,weekdays:`weekday`,weeknumber:`weekNumber`,weeksnumber:`weekNumber`,weeknumbers:`weekNumber`,weekyear:`weekYear`,weekyears:`weekYear`,ordinal:`ordinal`}[e.toLowerCase()];if(!t)throw new Ce(e);return t}function Gi(e){switch(e.toLowerCase()){case`localweekday`:case`localweekdays`:return`localWeekday`;case`localweeknumber`:case`localweeknumbers`:return`localWeekNumber`;case`localweekyear`:case`localweekyears`:return`localWeekYear`;default:return Wi(e)}}function Ki(e){if(Xi===void 0&&(Xi=k.now()),e.type!==`iana`)return e.offset(Xi);let t=e.name,n=Zi.get(t);return n===void 0&&(n=e.offset(Xi),Zi.set(t,n)),n}function qi(e,t){let n=D(t.zone,k.defaultZone);if(!n.isValid)return $.invalid(Di(n));let r=T.fromObject(t),i,a;if(M(e.year))i=k.now();else{for(let t of Vi)M(e[t])&&(e[t]=Ri[t]);let t=en(e)||tn(e);if(t)return $.invalid(t);let r=Ki(n);[i,a]=Mi(e,r,n)}return new $({ts:i,zone:n,loc:r,o:a})}function Ji(e,t,n){let r=M(n.round)?!0:n.round,i=M(n.rounding)?`trunc`:n.rounding,a=(e,a)=>(e=mn(e,r||n.calendary?0:2,n.calendary?`round`:i),t.loc.clone(n).relFormatter(n).format(e,a)),o=r=>n.calendary?t.hasSame(e,r)?0:t.startOf(r).diff(e.startOf(r),r).get(r):t.diff(e,r).get(r);if(n.unit)return a(o(n.unit),n.unit);for(let e of n.units){let t=o(e);if(Math.abs(t)>=1)return a(t,e)}return a(e>t?-0:0,n.units[n.units.length-1])}function Yi(e){let t={},n;return e.length>0&&typeof e[e.length-1]==`object`?(t=e[e.length-1],n=Array.from(e).slice(0,e.length-1)):n=Array.from(e),[t,n]}let Xi;const Zi=new Map;var $=class e{constructor(e){let t=e.zone||k.defaultZone,n=e.invalid||(Number.isNaN(e.ts)?new A(`invalid input`):null)||(t.isValid?null:Di(t));this.ts=M(e.ts)?k.now():e.ts;let r=null,i=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(t))[r,i]=[e.old.c,e.old.o];else{let a=N(e.o)&&!e.old?e.o:t.offset(this.ts);r=ji(this.ts,a),n=Number.isNaN(r.year)?new A(`invalid input`):null,r=n?null:r,i=n?null:a}this._zone=t,this.loc=e.loc||T.create(),this.invalid=n,this.weekData=null,this.localWeekData=null,this.c=r,this.o=i,this.isLuxonDateTime=!0}static now(){return new e({})}static local(){let[e,t]=Yi(arguments),[n,r,i,a,o,s,c]=t;return qi({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static utc(){let[e,t]=Yi(arguments),[n,r,i,a,o,s,c]=t;return e.zone=E.utcInstance,qi({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static fromJSDate(t,n={}){let r=an(t)?t.valueOf():NaN;if(Number.isNaN(r))return e.invalid(`invalid input`);let i=D(n.zone,k.defaultZone);return i.isValid?new e({ts:r,zone:i,loc:T.fromObject(n)}):e.invalid(Di(i))}static fromMillis(t,n={}){if(!N(t))throw new y(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`);return t<-Ei||t>Ei?e.invalid(`Timestamp out of range`):new e({ts:t,zone:D(n.zone,k.defaultZone),loc:T.fromObject(n)})}static fromSeconds(t,n={}){if(N(t))return new e({ts:t*1e3,zone:D(n.zone,k.defaultZone),loc:T.fromObject(n)});throw new y(`fromSeconds requires a numerical input`)}static fromObject(t,n={}){t||={};let r=D(n.zone,k.defaultZone);if(!r.isValid)return e.invalid(Di(r));let i=T.fromObject(n),a=Tn(t,Gi),{minDaysInFirstWeek:o,startOfWeek:s}=Zt(a,i),c=k.now(),l=M(n.specificOffset)?r.offset(c):n.specificOffset,u=!M(a.ordinal),d=!M(a.year),f=!M(a.month)||!M(a.day),p=d||f,m=a.weekYear||a.weekNumber;if((p||u)&&m)throw new Se(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(f&&u)throw new Se(`Can't mix ordinal dates with month/day`);let ee=m||a.weekday&&!p,te,ne,h=ji(c,l);ee?(te=Hi,ne=zi,h=qt(h,o,s)):u?(te=Ui,ne=Bi,h=Yt(h)):(te=Vi,ne=Ri);let g=!1;for(let e of te){let t=a[e];M(t)?g?a[e]=ne[e]:a[e]=h[e]:g=!0}let re=(ee?Qt(a,o,s):u?$t(a):en(a))||tn(a);if(re)return e.invalid(re);let[ie,ae]=Mi(ee?Jt(a,o,s):u?Xt(a):a,l,r),_=new e({ts:ie,zone:r,o:ae,loc:i});return a.weekday&&p&&t.weekday!==_.weekday?e.invalid(`mismatched weekday`,`you can't specify both a weekday of ${a.weekday} and a date of ${_.toISO()}`):_.isValid?_:e.invalid(_.invalid)}static fromISO(e,t={}){let[n,r]=Nr(e);return Pi(n,r,t,`ISO 8601`,e)}static fromRFC2822(e,t={}){let[n,r]=Pr(e);return Pi(n,r,t,`RFC 2822`,e)}static fromHTTP(e,t={}){let[n,r]=Fr(e);return Pi(n,r,t,`HTTP`,t)}static fromFormat(t,n,r={}){if(M(t)||M(n))throw new y(`fromFormat requires an input string and a format`);let{locale:i=null,numberingSystem:a=null}=r,[o,s,c,l]=Ci(T.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0}),t,n);return l?e.invalid(l):Pi(o,s,r,`format ${n}`,t,c)}static fromString(t,n,r={}){return e.fromFormat(t,n,r)}static fromSQL(e,t={}){let[n,r]=Hr(e);return Pi(n,r,t,`SQL`,e)}static invalid(t,n=null){if(!t)throw new y(`need to specify a reason the DateTime is invalid`);let r=t instanceof A?t:new A(t,n);if(k.throwOnInvalid)throw new ye(r);return new e({invalid:r})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){let n=wi(e,T.fromObject(t));return n?n.map(e=>e?e.val:null).join(``):null}static expandFormat(e,t={}){return bi(z.parseFormat(e),T.fromObject(t)).map(e=>e.val).join(``)}static resetCache(){Xi=void 0,Zi.clear()}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?Oi(this).weekYear:NaN}get weekNumber(){return this.isValid?Oi(this).weekNumber:NaN}get weekday(){return this.isValid?Oi(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?ki(this).weekday:NaN}get localWeekNumber(){return this.isValid?ki(this).weekNumber:NaN}get localWeekYear(){return this.isValid?ki(this).weekYear:NaN}get ordinal(){return this.isValid?Yt(this.c).ordinal:NaN}get monthShort(){return this.isValid?ei.months(`short`,{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?ei.months(`long`,{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?ei.weekdays(`short`,{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?ei.weekdays(`long`,{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:`short`,locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:`long`,locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];let e=864e5,t=6e4,n=vn(this.c),r=this.zone.offset(n-e),i=this.zone.offset(n+e),a=this.zone.offset(n-r*t),o=this.zone.offset(n-i*t);if(a===o)return[this];let s=n-a*t,c=n-o*t,l=ji(s,a),u=ji(c,o);return l.hour===u.hour&&l.minute===u.minute&&l.second===u.second&&l.millisecond===u.millisecond?[Q(this,{ts:s}),Q(this,{ts:c})]:[this]}get isInLeapYear(){return hn(this.year)}get daysInMonth(){return _n(this.year,this.month)}get daysInYear(){return this.isValid?gn(this.year):NaN}get weeksInWeekYear(){return this.isValid?bn(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?bn(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){let{locale:t,numberingSystem:n,calendar:r}=z.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:r}}toUTC(e=0,t={}){return this.setZone(E.instance(e),t)}toLocal(){return this.setZone(k.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=D(t,k.defaultZone),t.equals(this.zone))return this;if(t.isValid){let e=this.ts;if(n||r){let n=t.offset(this.ts),r=this.toObject();[e]=Mi(r,n,t)}return Q(this,{ts:e,zone:t})}else return e.invalid(Di(t))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){let r=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return Q(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let t=Tn(e,Gi),{minDaysInFirstWeek:n,startOfWeek:r}=Zt(t,this.loc),i=!M(t.weekYear)||!M(t.weekNumber)||!M(t.weekday),a=!M(t.ordinal),o=!M(t.year),s=!M(t.month)||!M(t.day),c=o||s,l=t.weekYear||t.weekNumber;if((c||a)&&l)throw new Se(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(s&&a)throw new Se(`Can't mix ordinal dates with month/day`);let u;i?u=Jt({...qt(this.c,n,r),...t},n,r):M(t.ordinal)?(u={...this.toObject(),...t},M(t.day)&&(u.day=Math.min(_n(u.year,u.month),u.day))):u=Xt({...Yt(this.c),...t});let[d,f]=Mi(u,this.o,this.zone);return Q(this,{ts:d,o:f})}plus(e){if(!this.isValid)return this;let t=Y.fromDurationLike(e);return Q(this,Ni(this,t))}minus(e){if(!this.isValid)return this;let t=Y.fromDurationLike(e).negate();return Q(this,Ni(this,t))}startOf(e,{useLocaleWeeks:t=!1}={}){if(!this.isValid)return this;let n={},r=Y.normalizeUnit(e);switch(r){case`years`:n.month=1;case`quarters`:case`months`:n.day=1;case`weeks`:case`days`:n.hour=0;case`hours`:n.minute=0;case`minutes`:n.second=0;case`seconds`:n.millisecond=0;break}if(r===`weeks`)if(t){let e=this.loc.getStartOfWeek(),{weekday:t}=this;t<e&&(n.weekNumber=this.weekNumber-1),n.weekday=e}else n.weekday=1;return r===`quarters`&&(n.month=(Math.ceil(this.month/3)-1)*3+1),this.set(n)}endOf(e,t){return this.isValid?this.plus({[e]:1}).startOf(e,t).minus(1):this}toFormat(e,t={}){return this.isValid?z.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):Ti}toLocaleString(e=we,t={}){return this.isValid?z.create(this.loc.clone(t),e).formatDateTime(this):Ti}toLocaleParts(e={}){return this.isValid?z.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e=`extended`,suppressSeconds:t=!1,suppressMilliseconds:n=!1,includeOffset:r=!0,extendedZone:i=!1,precision:a=`milliseconds`}={}){if(!this.isValid)return null;a=Wi(a);let o=e===`extended`,s=Ii(this,o,a);return Vi.indexOf(a)>=3&&(s+=`T`),s+=Li(this,o,t,n,r,i,a),s}toISODate({format:e=`extended`,precision:t=`day`}={}){return this.isValid?Ii(this,e===`extended`,Wi(t)):null}toISOWeekDate(){return Fi(this,`kkkk-'W'WW-c`)}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:t=!1,includeOffset:n=!0,includePrefix:r=!1,extendedZone:i=!1,format:a=`extended`,precision:o=`milliseconds`}={}){return this.isValid?(o=Wi(o),(r&&Vi.indexOf(o)>=3?`T`:``)+Li(this,a===`extended`,t,e,n,i,o)):null}toRFC2822(){return Fi(this,`EEE, dd LLL yyyy HH:mm:ss ZZZ`,!1)}toHTTP(){return Fi(this.toUTC(),`EEE, dd LLL yyyy HH:mm:ss 'GMT'`)}toSQLDate(){return this.isValid?Ii(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:t=!1,includeOffsetSpace:n=!0}={}){let r=`HH:mm:ss.SSS`;return(t||e)&&(n&&(r+=` `),t?r+=`z`:e&&(r+=`ZZ`)),Fi(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Ti}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.isValid?`DateTime { ts: ${this.toISO()}, zone: ${this.zone.name}, locale: ${this.locale} }`:`DateTime { Invalid, reason: ${this.invalidReason} }`}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};let t={...this.c};return e.includeConfig&&(t.outputCalendar=this.outputCalendar,t.numberingSystem=this.loc.numberingSystem,t.locale=this.loc.locale),t}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,t=`milliseconds`,n={}){if(!this.isValid||!e.isValid)return Y.invalid(`created by diffing an invalid DateTime`);let r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=cn(t).map(Y.normalizeUnit),a=e.valueOf()>this.valueOf(),o=ri(a?this:e,a?e:this,i,r);return a?o.negate():o}diffNow(t=`milliseconds`,n={}){return this.diff(e.now(),t,n)}until(e){return this.isValid?$r.fromDateTimes(this,e):this}hasSame(e,t,n){if(!this.isValid)return!1;let r=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(t,n)<=r&&r<=i.endOf(t,n)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(t={}){if(!this.isValid)return null;let n=t.base||e.fromObject({},{zone:this.zone}),r=t.padding?this<n?-t.padding:t.padding:0,i=[`years`,`months`,`days`,`hours`,`minutes`,`seconds`],a=t.unit;return Array.isArray(t.unit)&&(i=t.unit,a=void 0),Ji(n,this.plus(r),{...t,numeric:`always`,units:i,unit:a})}toRelativeCalendar(t={}){return this.isValid?Ji(t.base||e.fromObject({},{zone:this.zone}),this,{...t,numeric:`auto`,units:[`years`,`months`,`days`],calendary:!0}):null}static min(...t){if(!t.every(e.isDateTime))throw new y(`min requires all arguments be DateTimes`);return ln(t,e=>e.valueOf(),Math.min)}static max(...t){if(!t.every(e.isDateTime))throw new y(`max requires all arguments be DateTimes`);return ln(t,e=>e.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){let{locale:r=null,numberingSystem:i=null}=n;return Si(T.fromOpts({locale:r,numberingSystem:i,defaultToEN:!0}),e,t)}static fromStringExplain(t,n,r={}){return e.fromFormatExplain(t,n,r)}static buildFormatParser(e,t={}){let{locale:n=null,numberingSystem:r=null}=t;return new xi(T.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0}),e)}static fromFormatParser(t,n,r={}){if(M(t)||M(n))throw new y(`fromFormatParser requires an input string and a format parser`);let{locale:i=null,numberingSystem:a=null}=r,o=T.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0});if(!o.equals(n.locale))throw new y(`fromFormatParser called with a locale of ${o}, but the format parser was created for ${n.locale}`);let{result:s,zone:c,specificOffset:l,invalidReason:u}=n.explainFromTokens(t);return u?e.invalid(u):Pi(s,c,r,`format ${n.format}`,t,l)}static get DATE_SHORT(){return we}static get DATE_MED(){return Te}static get DATE_MED_WITH_WEEKDAY(){return Ee}static get DATE_FULL(){return De}static get DATE_HUGE(){return Oe}static get TIME_SIMPLE(){return ke}static get TIME_WITH_SECONDS(){return Ae}static get TIME_WITH_SHORT_OFFSET(){return je}static get TIME_WITH_LONG_OFFSET(){return Me}static get TIME_24_SIMPLE(){return Ne}static get TIME_24_WITH_SECONDS(){return Pe}static get TIME_24_WITH_SHORT_OFFSET(){return Fe}static get TIME_24_WITH_LONG_OFFSET(){return Ie}static get DATETIME_SHORT(){return Le}static get DATETIME_SHORT_WITH_SECONDS(){return Re}static get DATETIME_MED(){return ze}static get DATETIME_MED_WITH_SECONDS(){return Be}static get DATETIME_MED_WITH_WEEKDAY(){return Ve}static get DATETIME_FULL(){return He}static get DATETIME_FULL_WITH_SECONDS(){return Ue}static get DATETIME_HUGE(){return We}static get DATETIME_HUGE_WITH_SECONDS(){return Ge}};function Qi(e){if($.isDateTime(e))return e;if(e&&e.valueOf&&N(e.valueOf()))return $.fromJSDate(e);if(e&&typeof e==`object`)return $.fromObject(e);throw new y(`Unknown datetime argument: ${e}, of type ${typeof e}`)}const $i=(e,t,n)=>{let r=n[0];if(r===void 0)return!1;let i=ea(e),a=ea(r);if(i===void 0||a===void 0)return!1;switch(t){case`is after`:return i>a;case`is before`:return i<a;default:return!1}},ea=e=>{let t=$.fromISO(e,{zone:`utc`});return t.isValid?t.toMillis():void 0},ta=(e,t,n)=>{let r=t.toLowerCase();if(e.trim().length===0)return r===`is not one of`;let i=f.coerce(e),a=n.map(e=>f.coerce(e)),o=a[0]??null;switch(r){case`=`:return na(i,o);case`<`:return ra(i,o,f.lt);case`<=`:return ra(i,o,f.lte);case`>`:return ra(i,o,f.gt);case`>=`:return ra(i,o,f.gte);case`is one of`:return a.some(e=>na(i,e));case`is not one of`:return!a.some(e=>na(i,e));default:return!1}},na=(e,t)=>e!==null&&t!==null&&f.eq(e,t),ra=(e,t,n)=>e!==null&&t!==null&&n(e,t),ia=Symbol(`absent`),aa=Symbol(`unknown-attribute`),oa=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`,sa=e=>e===ia||e==null?``:oa(e)?ca(e):``,ca=e=>typeof e==`string`?e:String(e),la=e=>e===ia?void 0:e,ua=e=>e===aa?`unknown-attribute`:e===ia?`absent`:oa(e)?`scalar`:Array.isArray(e)?`array`:`object`,da=(e,t,n)=>{let r=t.toLowerCase();if(!Array.isArray(e))return r===`does not contain any of`;let i=e.filter(oa).map(ca);switch(r){case`contains any of`:return i.some(e=>n.includes(e));case`does not contain any of`:return!i.some(e=>n.includes(e));default:return!1}};var fa=class{evaluate(e,t){return this.explain(e,t).matched}explain(e,t){let n=this.resolve(e,t),r=ua(n),i=n===ia||n===aa?void 0:n;return n===aa?{matched:!1,resolvedValue:i,resolvedType:r}:{matched:this.compare(e,n),resolvedValue:i,resolvedType:r}}compare(e,t){let n=e.targetValues??[];switch(e.targetType){case`text`:return he(sa(t),e.operator,n);case`number`:return ge(la(t),e.operator,n);case`datetime`:return $i(sa(t),e.operator,n);case`semver`:return ta(sa(t),e.operator,n);case`array`:return da(la(t),e.operator,n)}return!1}resolve(e,t){switch(e.attribute){case`identifier`:return pa(t?.context?.id);case`name`:return pa(t?.context?.name);case`appName`:return pa(t?.metadata?.appName);case`appVersion`:return pa(t?.metadata?.appVersion);case`traits`:return e.trait?pa(me(e.trait,t?.context?.traits)):ia;default:return aa}}};const pa=e=>e??ia,ma=e=>{let t=`${e.contextIdentifier}-${e.configId}`;return Number((0,p.rapidhash)(t,{seed:15426857351n})%1000n)/10};var ha=class{constructor(e){if(this.logger=e,this.conditionEvaluator=new fa,!e||!e.warn||!e.error||!e.info)throw TypeError(`The provided logger is not a valid 'ConfigDirectorLogger'`);this.logger=e}evaluate(e,t){return{id:e.id,key:e.key,type:e.type,value:this.explain(e,t).value}}explain(e,t){let n=[...e.target?.rules??[]].sort((e,t)=>(e.order??2**53-1)-(t.order??2**53-1)),r=[],i;for(let a of n){if(i){r.push({ruleId:a.id,outcome:`not-evaluated`,conditions:[],bucket:void 0});continue}let n=this.explainRule(a,e,t);r.push(n.explanation),n.value!==void 0&&(i={ruleId:a.id,value:n.value})}return{value:i?.value??e.target?.defaultValue,servedBy:i?{kind:`rule`,ruleId:i.ruleId}:{kind:`default`},rules:r}}explainRule(e,t,n){let r={ruleId:e.id,outcome:`not-matched`,conditions:[],bucket:void 0};try{let i;return e.type==`percentage`?i=this.explainPercentage(e.percentages??[],t,n,r):e.type==`conditional`&&(i=this.explainConditionalRule(e,t,n,r)),i!==void 0&&(r.outcome=`matched`),{explanation:r,value:i}}catch(n){return this.logger.warn(`There was an error while evaluating a targeting rule '${e?.id}' for '${t?.key}'. The rule will be disregarded.`,{error:n,configKey:t?.key,ruleId:e?.id}),{explanation:{ruleId:e.id,outcome:`errored`,conditions:[],bucket:void 0},value:void 0}}}explainPercentage(e,t,n,r){let i=n?.context?.id??void 0,a=i===void 0?0:ma({configId:t.id,contextIdentifier:i}),o=[],s=0,c;for(let t of e){let e=s+t.percentage;o.push({percentageId:t.id,from:s,to:e,value:t.value?.toString()}),c===void 0&&a<e&&(c=t),s=e}return r.bucket={identifier:i,defaultedToPredefinedBucket:i===void 0,assignedPercentage:a,shares:o,selectedPercentageId:c?.id},c?.value==null?void 0:c.value.toString()}explainConditionalRule(e,t,n,r){let i=!1;for(let t of e.conditions??[]){if(i){r.conditions.push({conditionId:t.id,outcome:`not-evaluated`});continue}let e=this.conditionEvaluator.explain(t,n);r.conditions.push({conditionId:t.id,outcome:e.matched?`matched`:`not-matched`,resolvedValue:e.resolvedValue,resolvedType:e.resolvedType}),i=!e.matched}if(!i){if(e.target==`value`)return e.value==null?void 0:e.value.toString();if(e.target==`percentage`)return this.explainPercentage(e.percentages??[],t,n,r)}}};const ga=e=>{let t=typeof e;if(t===`object`)try{return e.constructor?.name??t}catch{return t}else if(t===`function`)try{let n=e.name;return n?`function: ${n}`:t}catch{return t}return t},_a=e=>e===`number`||e===`bigint`,va=new Set([`boolean`,`integer`,`float`]),ya=(e,t)=>{let n=e.value,r=ga(t);if(n==null||n===``)return{parsedValue:t,parsedValueId:void 0,requestedType:r,usedDefault:!0,reason:`value-missing`};if(e.type===`json`)return Ta(n,t,r,e.valueId);if(typeof t==`string`)return va.has(e.type)?{parsedValue:t,parsedValueId:void 0,requestedType:r,usedDefault:!0,reason:`type-mismatch`}:{parsedValue:n,parsedValueId:e.valueId,requestedType:r,usedDefault:!1,reason:`found-match`};if(typeof t==`boolean`&&(e.type===`boolean`||e.type===`string`||e.type===`enum`)){let i=ba(n),a=typeof i==`boolean`;return{parsedValue:a?i:t,parsedValueId:a?e.valueId:void 0,requestedType:r,usedDefault:!a,reason:a?`found-match`:`invalid-boolean`}}if(_a(typeof t)&&e.type===`integer`){let i=xa(n),a=typeof i==`number`;return{parsedValue:a?i:t,parsedValueId:a?e.valueId:void 0,requestedType:r,usedDefault:!a,reason:a?`found-match`:`invalid-number`}}if(_a(typeof t)&&(e.type===`float`||e.type===`enum`||e.type===`string`)){let i=Sa(n),a=typeof i==`number`;return{parsedValue:a?i:t,parsedValueId:a?e.valueId:void 0,requestedType:r,usedDefault:!a,reason:a?`found-match`:`invalid-number`}}return{parsedValue:t,parsedValueId:void 0,requestedType:r,usedDefault:!0,reason:`type-mismatch`}},ba=e=>{if(!e)return;let t=e.toLowerCase();if(!(t!=`true`&&t!=`false`))return t===`true`},xa=e=>{let t=Ca(e);return t==null?void 0:Math.trunc(t)},Sa=e=>Ca(e),Ca=e=>{if(!e||!wa(e))return;let t=Number(e);if(!(isNaN(t)||!isFinite(t)))return t},wa=e=>{for(let t of e)if(!(t>=`0`&&t<=`9`)&&!`+-.eE`.includes(t))return!1;return!0},Ta=(e,t,n,r)=>{if(typeof t==`string`)return{parsedValue:e,parsedValueId:r,requestedType:n,usedDefault:!1,reason:`found-match`};try{let i=JSON.parse(e);return Ea(i,t)?{parsedValue:i,parsedValueId:r,requestedType:n,usedDefault:!1,reason:`found-match`}:{parsedValue:t,parsedValueId:void 0,requestedType:n,usedDefault:!0,reason:`type-mismatch`}}catch{return{parsedValue:t,parsedValueId:void 0,requestedType:n,usedDefault:!0,reason:`invalid-json`}}},Ea=(e,t)=>{if(e===null)return!1;let n=typeof t;return n===`bigint`?typeof e==`number`:typeof e===n};var Da=class{decorateMessage(e){return`[ConfigDirector:js-server-sdk] ${e}`}};const Oa=(e,t)=>new l.i(e??`warn`,t??new Da),ka=(e,t)=>new URL(e,t?.toString()),Aa=(e,t)=>e===void 0?{seconds:t.defaultSeconds,warning:void 0}:e>=t.minimumSeconds?{seconds:e,warning:void 0}:{seconds:t.minimumSeconds,warning:`pollingInterval of ${e} seconds is below the minimum of ${t.minimumSeconds} seconds. Using ${t.minimumSeconds} seconds.`},ja=async(e,t)=>e.valueId?{valueId:e.valueId}:e.value?e.value.length<=500&&e.type!=`json`?{value:e.value}:{valueId:await t(e.value)}:e,Ma=e=>{if(e.type===`json`||e.type==null&&typeof e.value==`object`){if(e.valueId)return{valueId:e.valueId,type:`json`};try{return{value:JSON.stringify(e.value),type:`json`}}catch{return{value:e.value.toString(),type:`json`}}}let t=e.value?.toString();return t&&t.length<=500?{value:t}:e.valueId?{valueId:e.valueId}:{value:t}},Na=e=>{let t=Object.keys(e);if(t.length==0)return!0;for(let n of t)if((e[n]?.length??0)>0)return!1;return!0},Pa=e=>{if(!e)return!0;let t=Object.keys(e);if(t.length==0)return!0;for(let n of t)if((e[n]??0)>0)return!1;return!0};var Fa=class{constructor(e){this.executeRequests=!0,this.sdkKey=e.sdkKey,this.sdkIdentity=e.sdkIdentity,this.logger=e.logger,this.metaContext=e.metaContext,this.url=new URL(`server/telemetry/v1`,e.baseUrl.toString())}async report({discreteEvents:e,aggregatedEvents:t,droppedEvents:n}){if(!this.executeRequests)return{success:!1,fatalError:!0};let r={serverSdkKey:this.sdkKey,metaContext:{sdkName:this.sdkIdentity.sdkName,sdkVersion:this.sdkIdentity.sdkVersion,appName:this.metaContext.appName,appVersion:this.metaContext.appVersion},discreteEvents:e,aggregatedEvents:t,droppedEvents:n};if(this.isReportEmpty(r))return{success:!0,fatalError:!1};let i=await this.sendReport(r);return i.fatalError&&(this.executeRequests=!1),i}isReportEmpty(e){return Na(e.discreteEvents)&&Na(e.aggregatedEvents)&&Pa(e.droppedEvents)}async sendReport(e){try{let t=await ae(5e3,this.url,{method:`POST`,body:JSON.stringify(e)},this.logger),n=this.isStatusFatal(t.status);return n&&this.logger.warn(`[EventReporter] Received a fatal status response (${t.status}) from the telemetry endpoint. No more telemetry data will be sent.`),{success:t.ok,fatalError:n}}catch(e){return this.logger.warn(`[EventReporter] Error attempting to send telemetry data: ${e}`,{error:e}),{success:!1,fatalError:!1}}}isStatusFatal(e){return!!e&&e>=400&&e<500&&e!=429}},Ia=class{aggregate(e){if(e.events.length==0)return[];let t=new Map;for(let n of e.events){let e=JSON.stringify(n),r=t.get(e)?.count||0;t.set(e,{event:n,count:r+1})}return Array.from(t).map(([,t])=>({startTime:e.startTime,endTime:e.endTime,count:t.count,event:t.event}))}},La=class{constructor(e){this._events=[],this._droppedEventCount=0,this.limit=e??1e3}get events(){return this._events}get reachedLimit(){return this._events.length>=this.limit}get droppedEventCount(){return this._droppedEventCount}push(...e){this.startTime||=new Date;let t=Math.max(0,e.length-this.limit),n=e.slice(t,e.length);if(this._droppedEventCount+=t,this._events.length+n.length>this.limit){let e=this._events.length+n.length-this.limit;this._events.splice(0,e),this._droppedEventCount+=e}return this._events.push(...n)}takeSnapshot(){let e=new Date,t=this.startTime??e,n=this._events.splice(0),r=this._droppedEventCount;return this.startTime=void 0,this._droppedEventCount=0,{startTime:t,endTime:e,events:n,droppedCount:r}}clear(){this._events=[],this.startTime=void 0,this._droppedEventCount=0}},Ra=class{constructor(e){this.aggregator=new Ia,this.collectEvents=!0,this.started=!1,this.logger=e.logger,this.evaluationEventQueue=new La(e.evaluationQueueLimit??1e3),this.flushIntervalDelay=e.flushIntervalDelay??3e4,this.initialFlushIntervalDelay=e.initialFlushIntervalDelay??5e3}start(){this.started||!this.collectEvents||(this.started=!0,this.flushTimeout=setTimeout(()=>this.flushAndScheduleNext(),this.initialFlushIntervalDelay))}async flushAndScheduleNext(){if(!this.collectEvents)return;let e;try{e=await this.flush()}catch(t){this.logger.warn(`[TelemetryEventCollector] Error flushing telemetry events: `,t),e={success:!1,fatalError:!1}}e.fatalError?(this.collectEvents=!1,this.close(),this.logger.warn(`[TelemetryEventCollector] Received a fatal error from telemetry collection. No longer collecting events.`)):this.collectEvents&&(this.cancelScheduledFlush(),this.flushTimeout=setTimeout(()=>this.flushAndScheduleNext(),this.flushIntervalDelay))}cancelScheduledFlush(){clearTimeout(this.flushTimeout)}async close(){this.collectEvents=!1,clearTimeout(this.flushTimeout);try{await this.flush()}catch(e){this.logger.warn(`[TelemetryEventCollector] Error flushing telemetry events during close: `,e)}this.evaluationEventQueue.clear()}dispose(){this.close()}},za=class extends Map{constructor(e,t){super(t),this._droppedCount=0,this.limit=e,this.enforceLimit()}set(e,t){return super.set(e,t),this.enforceLimit(),this}get droppedCount(){return this._droppedCount}clearAndReset(){this.clear(),this._droppedCount=0}enforceLimit(){for(;this.size>this.limit;){let e=this.keys().next().value;e!==void 0&&(this.delete(e),this._droppedCount+=1)}}},Ba=class{constructor(e){this.valueIdGenerator=e,this.valueIdGenerator=e}async process(e){let t=await Promise.all(e.events.map(async e=>({...e,defaultValue:await ja(e.defaultValue,this.valueIdGenerator),evaluatedValue:await ja(e.evaluatedValue,this.valueIdGenerator)})));return{...e,events:t}}},Va=class extends Ra{constructor(e){super(e),this.reporter=new Fa(e),this.contexts=new za(e.contextLimit??1e3),this.evaluationEventSnapshotPreprocessor=new Ba(e.valueIdGenerator)}evaluatedConfig(e){if(!this.collectEvents)return;e.context?.id&&!e.context.anonymous&&this.contexts.set(e.context.id,e.context);let t={...e.evaluation,contextId:e.context?.anonymous?void 0:e.context?.id};this.evaluationEventQueue.push(this.sanitizeEvaluatedConfigEvent(t))}sanitizeEvaluatedConfigEvent(e){return{...e,defaultValue:Ma({value:e.defaultValue,type:e.type}),evaluatedValue:Ma({value:e.evaluatedValue,valueId:e.evaluatedValueId,type:e.type})}}snapshotContexts(){let e=Array.from(this.contexts.values()),t=this.contexts.droppedCount;return this.contexts.clearAndReset(),{contexts:e,droppedCount:t}}async flush(){if(!this.reporter)return{success:!1,fatalError:!1};let e=await this.evaluationEventSnapshotPreprocessor.process(this.evaluationEventQueue.takeSnapshot()),t=this.snapshotContexts();return await this.reporter?.report({context:this._context,discreteEvents:{capturedContexts:t.contexts},aggregatedEvents:{evaluatedConfig:this.aggregator.aggregate(e)},droppedEvents:{evaluatedConfig:e.droppedCount,capturedContexts:t.droppedCount}})}};const Ha=(e,t)=>{let n=BigInt(0),r=BigInt(62),i=Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``),a=BigInt(`0x`+i),o=``;for(;a>n;)o=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`[Number(a%r)]+o,a/=r;return o.padStart(t,`0`)},Ua=Math.ceil(128/Math.log2(62)),Wa=async e=>Ha((0,d.createHash)(`sha256`).update(e?.toString()??``).digest().subarray(0,16),Ua);var Ga=o({DefaultConfigDirectorClient:()=>qa});const Ka=new URL(`https://server-sdk-api.configdirector.com`);var qa=class{constructor(e,t,n,r){this.handlersMap=new Map,this.eventEmitter=new u.default,this.ready=!1,this.logger=n?.logger??Oa(),this.timeout=n?.connection?.timeout??3e3,this.metaContext=n?.metadata??{},this.validateSdkKeyPresence(e),this.configEvaluator=new ha(this.logger);let i=this.parseUrl(n?.connection?.url)??Ka;this.connectionMode=n?.connection?.mode??`streaming`,this.usageEventCollector=r?.telemetry??this.buildTelemetryCollector(e,t,i,n),this.transport=r?.transport??this.buildTransport(e,t,i,n),this.transport.on(`configBundleReceived`,e=>{this.readyResolve?.(!1);let t=this.findKeysRemovedBy(e);!this.configSet||e.kind==`full`?this.configSet=e:this.configSet.configs={...this.configSet.configs,...e.configs};let n=Object.keys(e.configs);this.eventEmitter.emit(`configsUpdated`,{keys:n,removedKeys:t}),this.updateWatchers([...n,...t]),this.logger.debug(`[ConfigDirectorClient] ConfigSet updated from server with ${n.length} key(s) and ${t.length} removed key(s)`,{keys:n,removedKeys:t})}),this.transport.on(`connectionError`,e=>{this.logger.error(`[ConfigDirectorClient] The connection encountered an unrecoverable error and will not be retried. Configs will no longer receive updates.`,e),this.eventEmitter.emit(`connectionError`,{error:e})}),this.registerHandler(`clientReady`,n?.hooks?.clientReady),this.registerHandler(`configEvaluated`,n?.hooks?.configEvaluated),this.registerHandler(`configsUpdated`,n?.hooks?.configsUpdated),this.registerHandler(`connectionError`,n?.hooks?.connectionError)}registerHandler(e,t){if(!t)return;let n=Array.isArray(t)?t:[t];for(let t of n)typeof t==`function`&&this.on(e,t)}async initialize(){try{this.ready=!1,this.readyPromise=new Promise(e=>{this.readyResolve=e}).then(e=>{e||(this.ready=!0,this.eventEmitter.emit(`clientReady`),this.logger.debug(`[ConfigDirectorClient] Received initial payload from the server, client is ready`))}),this.usageEventCollector.start();let e=new Date().getTime();await this.transport.connect(this.timeout);let t=new Date().getTime()-e,n=this.timeout-t;if(n>0&&(await Promise.race([this.readyPromise,new Promise(e=>{this.readyTimer=setTimeout(()=>e(),n)})]),this.clearReadyTimer()),!this.ready){let e=this.connectionMode===`streaming`?`The client will continue to retry since there were no fatal errors detected. Configs will return the default value until the connection succeeds.`:`Since the client was configured without streaming, configs may not update and always return the default value.`;this.logger.warn(`[ConfigDirectorClient] Timed out waiting for initialization after ${this.timeout}ms. ${e}`)}}catch(e){this.logger.error(`[ConfigDirectorClient] An error occurred during initialization: `,e)}}resolvePollingIntervalForMode(e){if(this.connectionMode!==`polling`)return;let t=Aa(e,{defaultSeconds:300,minimumSeconds:60});return t.warning&&this.logger.warn(`[ConfigDirectorClient] ${t.warning}`),t.seconds}buildTelemetryCollector(e,t,n,r){let i=r?.telemetry?.eventQueueLimit??5e3;return new Va({sdkKey:e,sdkIdentity:t,metaContext:r?.metadata??{},logger:this.logger,baseUrl:n,flushIntervalDelay:r?.telemetry?.flushInterval??3e4,evaluationQueueLimit:Math.ceil(i*.7),contextLimit:Math.floor(i*.3),urlFactory:ka,valueIdGenerator:Wa})}buildTransport(e,t,n,r){return new(this.getTransportConstructor(this.connectionMode))({serverSdkKey:e,baseUrl:n,metaContext:{...r?.metadata,sdkName:t.sdkName,sdkVersion:t.sdkVersion},logger:this.logger,pollingInterval:this.resolvePollingIntervalForMode(r?.connection?.pollingInterval)})}getTransportConstructor(e){switch(e){case`polling`:return ce;default:return oe}}findKeysRemovedBy(e){return!this.configSet||e.kind!=`full`?[]:Object.keys(this.configSet.configs).filter(t=>!Object.prototype.hasOwnProperty.call(e.configs,t))}updateWatchers(e){e.forEach(e=>this.updateWatchersForConfig(e))}updateWatchersForConfig(e){let t=this.configSet?.configs[e];this.handlersMap.get(e)?.forEach(n=>{let r=this.getValueFromConfigDefinition(e,t,n.defaultValue,n.context);n.handler(r)})}watch(e,t,n,r){this.validateDefaultValue(t);let i=this.handlersMap.get(e),a={handler:n,defaultValue:t,requestedType:typeof t,context:r};return i?i.push(a):this.handlersMap.set(e,[a]),()=>this.unwatch(e,n)}unwatch(e,t){let n=this.handlersMap.get(e);if(n)if(t){let e=n.findIndex(e=>e.handler==t);e>=0&&n?.splice(e,1)}else n.splice(0)}getValue(e,t,n){this.validateDefaultValue(t);let r=this.configSet?.configs[e];return this.getValueFromConfigDefinition(e,r,t,n)}getValueFromConfigDefinition(e,t,n,r){if(t){let i=this.configEvaluator.evaluate(t,{context:r,metadata:this.metaContext}),a=ya(i,n);return this.usageEventCollector.evaluatedConfig({context:r,evaluation:{key:e,type:i.type,defaultValue:n,requestedType:a.requestedType,evaluatedValue:a.parsedValue,evaluatedValueId:a.parsedValueId,usedDefault:a.usedDefault,evaluationReason:a.reason}}),this.dispatchEvaluationEvent({key:e,value:a.parsedValue,valueId:a.parsedValueId??void 0,isDefaultValue:a.usedDefault,reason:a.reason,context:r}),this.logger.debug(`[ConfigDirectorClient] Evaluated '${e}' to '${a.parsedValue}'`),a.parsedValue}else{this.logger.debug(`[ConfigDirectorClient] No config state found for '${e}', returning default value '${n}'`);let t=this.isReady?`config-state-missing`:`client-not-ready`;return this.usageEventCollector.evaluatedConfig({context:r,evaluation:{key:e,defaultValue:n,requestedType:ga(n),evaluatedValue:n,usedDefault:!0,evaluationReason:t}}),this.dispatchEvaluationEvent({key:e,value:n,isDefaultValue:!0,reason:t,context:r}),n}}dispatchEvaluationEvent(e){setTimeout(()=>this.eventEmitter.emit(`configEvaluated`,{evaluation:e}),0)}parseUrl(e){if(e)try{return new URL(e)}catch(t){throw new l.r(`Invalid base URL '${e}'. Parsing failed: ${t}`)}}validateSdkKeyPresence(e){if(!e||e.trim().length==0)throw new l.r(`No server SDK key was provided, the client cannot be instantiated without a valid server SDK key`)}validateDefaultValue(e){if(e==null)throw new l.r(`Invalid default value. The default value for a config must be defined and non-null.`);if(typeof e==`function`)throw new l.r(`Invalid default value. The default value for a config cannot be a function.`)}get isReady(){return this.ready}on(e,t){this.eventEmitter.on(e,t)}off(e,t){t?this.eventEmitter.off(e,t):this.eventEmitter.removeAllListeners(e)}removeAllObservers(){this.logger.debug(`[ConfigDirectorClient] removeAllObservers() has been called, removing all observers`),this.eventEmitter.removeAllListeners(),this.handlersMap.clear()}unwatchAll(){this.handlersMap.clear()}getAllConfigs(e){if(!this.configSet)return{};let t=Object.entries(this.configSet.configs),n=e?.configKeys?t.filter(([t])=>e.configKeys?.includes(t)):t;return Object.fromEntries(n.map(([t,n])=>[t,this.configEvaluator.evaluate(n,{context:e?.context,metadata:this.metaContext})]))}closeConnection(){this.logger.debug(`[ConfigDirectorClient] closeConnection() has been called, closing connection to server`),this.transport.close(),this.ready=!1}clearReadyTimer(){clearTimeout(this.readyTimer),this.readyTimer=void 0}dispose(){this.removeAllObservers(),this.closeConnection(),this.readyResolve?.(!0),this.clearReadyTimer(),this.usageEventCollector.close().catch(e=>{this.logger.warn(`[ConfigDirectorClient] Error flushing telemetry while disposing the client: `,e)})}};Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Ga}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Oa}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return qa}});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const e={off:-1,error:0,warn:1,info:2,debug:3},t=()=>{let e={year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,timeZoneName:`short`};try{return new Intl.DateTimeFormat(void 0,{...e,fractionalSecondDigits:3})}catch{return new Intl.DateTimeFormat(void 0,e)}};var n=class{constructor(e,n){this.level=e,this.decorator=n,this.level=e,this.decorator=n,this.dateFormatter=t()}debug(e,...t){this.log(console.debug,`debug`,e,...t)}info(e,...t){this.log(console.info,`info`,e,...t)}warn(e,...t){this.log(console.warn,`warn`,e,...t)}error(e,...t){this.log(console.error,`error`,e,...t)}log(t,n,r,...i){e[this.level]>=e[n]&&t(`[${this.dateFormatter.format(new Date)}] ${this.decorator?.decorateMessage(r)}`,...i)}},r=class e extends Error{constructor(t,n){super(t),this.name=`ConfigDirectorConnectionError`,this.status=n,Object.setPrototypeOf(this,e.prototype)}},i=class e extends Error{constructor(t){super(t),this.name=`ConfigDirectorValidationError`,Object.setPrototypeOf(this,e.prototype)}},a=class e extends Error{constructor(t){super(t),this.name=`ConfigDirectorInitializationError`,Object.setPrototypeOf(this,e.prototype)}};export{n as i,a as n,i as r,r as t};
|
|
2
|
-
//# sourceMappingURL=errors-
|
|
2
|
+
//# sourceMappingURL=errors-BGpFuqOO.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-
|
|
1
|
+
{"version":3,"file":"errors-BGpFuqOO.mjs","names":[],"sources":["../../../shared/src/logger.ts","../../../shared/src/errors.ts"],"sourcesContent":["import type { ConfigDirectorLogger, ConfigDirectorLogMessageDecorator, ConfigDirectorLoggingLevel } from \"./types\";\n\nconst LEVELS: Record<ConfigDirectorLoggingLevel, number> = {\n off: -1,\n error: 0,\n warn: 1,\n info: 2,\n debug: 3,\n};\n\nconst buildDateFormatter = () => {\n const baseOptions: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n timeZoneName: \"short\",\n };\n\n try {\n return new Intl.DateTimeFormat(\n undefined,\n { ...baseOptions, fractionalSecondDigits: 3 } as Intl.DateTimeFormatOptions,\n );\n } catch {\n return new Intl.DateTimeFormat(undefined, baseOptions);\n }\n};\n\nexport class DefaultConsoleLogger implements ConfigDirectorLogger {\n private readonly dateFormatter;\n\n constructor(private readonly level: ConfigDirectorLoggingLevel, private readonly decorator: ConfigDirectorLogMessageDecorator) {\n this.level = level;\n this.decorator = decorator;\n this.dateFormatter = buildDateFormatter();\n }\n\n debug(message: string, ...args: any): void {\n this.log(console.debug, \"debug\", message, ...args);\n }\n\n info(message: string, ...args: any): void {\n this.log(console.info, \"info\", message, ...args);\n }\n\n warn(message: string, ...args: any): void {\n this.log(console.warn, \"warn\", message, ...args);\n }\n\n error(message: string, ...args: any): void {\n this.log(console.error, \"error\", message, ...args);\n }\n\n protected log(loggerFunction: (...args: any) => void, level: ConfigDirectorLoggingLevel, message: string, ...args: any) {\n if (LEVELS[this.level] >= LEVELS[level]) {\n loggerFunction(`[${this.dateFormatter.format(new Date())}] ${this.decorator?.decorateMessage(message)}`, ...args);\n }\n }\n}\n","export class ConfigDirectorConnectionError extends Error {\n public override readonly name: string = \"ConfigDirectorConnectionError\";\n public readonly status?: number;\n\n constructor(message: string, status?: number) {\n super(message);\n this.status = status;\n\n Object.setPrototypeOf(this, ConfigDirectorConnectionError.prototype);\n }\n}\n\nexport class ConfigDirectorValidationError extends Error {\n public override readonly name: string = \"ConfigDirectorValidationError\";\n\n constructor(message: string) {\n super(message);\n\n Object.setPrototypeOf(this, ConfigDirectorValidationError.prototype);\n }\n}\n\nexport class ConfigDirectorInitializationError extends Error {\n public override readonly name: string = \"ConfigDirectorInitializationError\";\n\n constructor(message: string) {\n super(message);\n\n Object.setPrototypeOf(this, ConfigDirectorInitializationError.prototype);\n }\n}\n"],"mappings":"AAEA,MAAM,EAAqD,CACzD,IAAK,GACL,MAAO,EACP,KAAM,EACN,KAAM,EACN,MAAO,EACR,CAEK,MAA2B,CAC/B,IAAM,EAA0C,CAC9C,KAAM,UACN,MAAO,UACP,IAAK,UACL,KAAM,UACN,OAAQ,UACR,OAAQ,UACR,aAAc,QACf,CAED,GAAI,CACF,OAAO,IAAI,KAAK,eACd,IAAA,GACA,CAAE,GAAG,EAAa,uBAAwB,EAAG,CAC9C,MACK,CACN,OAAO,IAAI,KAAK,eAAe,IAAA,GAAW,EAAY,GAI1D,IAAa,EAAb,KAAkE,CAGhE,YAAY,EAAoD,EAA+D,CAAlG,KAAA,MAAA,EAAoD,KAAA,UAAA,EAC/E,KAAK,MAAQ,EACb,KAAK,UAAY,EACjB,KAAK,cAAgB,GAAoB,CAG3C,MAAM,EAAiB,GAAG,EAAiB,CACzC,KAAK,IAAI,QAAQ,MAAO,QAAS,EAAS,GAAG,EAAK,CAGpD,KAAK,EAAiB,GAAG,EAAiB,CACxC,KAAK,IAAI,QAAQ,KAAM,OAAQ,EAAS,GAAG,EAAK,CAGlD,KAAK,EAAiB,GAAG,EAAiB,CACxC,KAAK,IAAI,QAAQ,KAAM,OAAQ,EAAS,GAAG,EAAK,CAGlD,MAAM,EAAiB,GAAG,EAAiB,CACzC,KAAK,IAAI,QAAQ,MAAO,QAAS,EAAS,GAAG,EAAK,CAGpD,IAAc,EAAwC,EAAmC,EAAiB,GAAG,EAAW,CAClH,EAAO,KAAK,QAAU,EAAO,IAC/B,EAAe,IAAI,KAAK,cAAc,OAAO,IAAI,KAAO,CAAC,IAAI,KAAK,WAAW,gBAAgB,EAAQ,GAAI,GAAG,EAAK,GC1D1G,EAAb,MAAa,UAAsC,KAAM,CAIvD,YAAY,EAAiB,EAAiB,CAC5C,MAAM,EAAQ,CAJhB,KAAyB,KAAe,gCAKtC,KAAK,OAAS,EAEd,OAAO,eAAe,KAAM,EAA8B,UAAU,GAI3D,EAAb,MAAa,UAAsC,KAAM,CAGvD,YAAY,EAAiB,CAC3B,MAAM,EAAQ,CAHhB,KAAyB,KAAe,gCAKtC,OAAO,eAAe,KAAM,EAA8B,UAAU,GAI3D,EAAb,MAAa,UAA0C,KAAM,CAG3D,YAAY,EAAiB,CAC3B,MAAM,EAAQ,CAHhB,KAAyB,KAAe,oCAKtC,OAAO,eAAe,KAAM,EAAkC,UAAU"}
|
package/dist/server/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`})
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./DefaultConfigDirectorClient-BngKzHat.cjs`);const e=require(`./errors-CCbuIqT8.cjs`);let t=require(`@configdirector/nextjs-sdk/client`),n=require(`react/jsx-runtime`);var r=class{decorateMessage(e){return`[ConfigDirector:nextjs-sdk] ${e}`}};const i=(t,n)=>new e.i(t??`warn`,n??new r),a=(t,n)=>new e.i(t,n??new r);async function o(t){if(process.env.NEXT_RUNTIME===`nodejs`){if(!t.serverSdkKey){let t=`The ConfigDirector serverSdkKey must be provided to register(). You can pass it via process.env.CONFIGDIRECTOR_SERVER_KEY.`;throw i().error(t),new e.n(t)}if(!globalThis.__configDirectorServerClient){let{DefaultConfigDirectorClient:e}=await Promise.resolve().then(()=>require(`./DefaultConfigDirectorClient-BngKzHat.cjs`)).then(e=>e.n),{serverSdkKey:n,...r}=t;globalThis.__configDirectorAppMeta={appName:t.metadata?.appName,appVersion:t.metadata?.appVersion};let i=new e(n,{sdkName:`nextjs-sdk`,sdkVersion:`1.8.0`},r);globalThis.__configDirectorServerClient=i,await i.initialize()}}}function s(){return globalThis.__configDirectorAppMeta??{}}function c(){if(!globalThis.__configDirectorServerClient)throw new e.n(`[ConfigDirector] Server client not initialized. Make sure to call register() in your instrumentation.ts file before using the SDK.`);return globalThis.__configDirectorServerClient}const l=i();function u(e){try{return c().getAllConfigs(e)}catch(e){return l.error(`Error retrieving SSR config set:`,e),{}}}async function d({children:e,configKeys:r,...i}){let a=u({context:i.context,configKeys:r}),o=s();return(0,n.jsx)(t.ConfigDirectorProvider,{...i,appName:i.appName??o.appName,appVersion:i.appVersion??o.appVersion,initialConfigs:a,children:e})}exports.ConfigDirectorProvider=d,exports.createConsoleLogger=a,exports.generateSsrConfigSet=u,exports.getAppMeta=s,exports.getConfigClient=c,exports.register=o;
|
package/dist/server/index.d.cts
CHANGED
|
@@ -1,294 +1,7 @@
|
|
|
1
|
+
import { a as ConfigDirectorLogger, c as ConfigEvaluation, d as ConnectionMode, i as ConfigDirectorLogMessageDecorator, l as ConfigState, n as ConfigDirectorClientOptions, o as ConfigDirectorLoggingLevel, r as ConfigDirectorContext, s as ConfigDirectorMetaContext, t as ConfigDirectorClient, u as ConfigValueType } from "./types-DnzM2ukj.cjs";
|
|
1
2
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
3
|
import { PropsWithChildren } from "react";
|
|
3
4
|
|
|
4
|
-
//#region ../shared/src/types.d.ts
|
|
5
|
-
declare const ConfigTypeList: readonly ["custom", "boolean", "string", "integer", "float", "enum", "url", "json"];
|
|
6
|
-
type ConfigType = (typeof ConfigTypeList)[number];
|
|
7
|
-
type ConfigEnumLikeType = {
|
|
8
|
-
[key: string]: string | number;
|
|
9
|
-
};
|
|
10
|
-
type ConfigValueType = string | number | boolean | object | ConfigEnumLikeType;
|
|
11
|
-
type ConfigState = {
|
|
12
|
-
id: string;
|
|
13
|
-
key: string;
|
|
14
|
-
type: ConfigType;
|
|
15
|
-
value: string | undefined | null;
|
|
16
|
-
valueId?: string | undefined | null;
|
|
17
|
-
};
|
|
18
|
-
type ConfigDirectorLoggingLevel = "debug" | "info" | "warn" | "error" | "off";
|
|
19
|
-
interface ConfigDirectorLogger {
|
|
20
|
-
debug(message: string, ...args: any): void;
|
|
21
|
-
info(message: string, ...args: any): void;
|
|
22
|
-
warn(message: string, ...args: any): void;
|
|
23
|
-
error(message: string, ...args: any): void;
|
|
24
|
-
}
|
|
25
|
-
interface ConfigDirectorLogMessageDecorator {
|
|
26
|
-
decorateMessage(message: string): string;
|
|
27
|
-
}
|
|
28
|
-
type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean";
|
|
29
|
-
type ConfigEvaluation = {
|
|
30
|
-
key: string;
|
|
31
|
-
value: ConfigValueType;
|
|
32
|
-
valueId?: string;
|
|
33
|
-
isDefaultValue: boolean;
|
|
34
|
-
reason: EvaluationReason;
|
|
35
|
-
context?: ConfigDirectorContext;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* The user's context to be sent to ConfigDirector. This context will be used for targeting
|
|
39
|
-
* rules evaluation.
|
|
40
|
-
*/
|
|
41
|
-
type ConfigDirectorContext = {
|
|
42
|
-
/**
|
|
43
|
-
* The user's identifier. This should be a value that uniquely identifies an application
|
|
44
|
-
* user.
|
|
45
|
-
* In the case of anonymous users, you could generate a UUID or alternatively not provide
|
|
46
|
-
* the {@link id} and the SDK will generate a random UUID. However, keep in mind that this
|
|
47
|
-
* value is used for segmenting users in percentage rollouts, and changes to the {@link id}
|
|
48
|
-
* could result in the user being assigned to a different percentile.
|
|
49
|
-
*/
|
|
50
|
-
id?: string;
|
|
51
|
-
/**
|
|
52
|
-
* The user's display name. This will be shown in the ConfigDirector dashboard and may be
|
|
53
|
-
* used for targeting rules.
|
|
54
|
-
*/
|
|
55
|
-
name?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Any arbitrary traits for the current user. They will be shown in the ConfigDirector
|
|
58
|
-
* dashboard and may be used for targeting rules.
|
|
59
|
-
*/
|
|
60
|
-
traits?: {
|
|
61
|
-
[key: string]: unknown;
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Whether or not to treat the context as anonymous during evaluation. When `true`, the
|
|
65
|
-
* context values will be used for targeting rules evaluation but the context will not be
|
|
66
|
-
* persisted and will not appear in the dashboard.
|
|
67
|
-
*
|
|
68
|
-
* @default false
|
|
69
|
-
*/
|
|
70
|
-
anonymous?: boolean;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Metadata about your application. It is recommended you include these values when configuring
|
|
74
|
-
* a ConfigDirector client so that you can use them in targeting rules.
|
|
75
|
-
*/
|
|
76
|
-
type ConfigDirectorMetaContext = {
|
|
77
|
-
appVersion?: string;
|
|
78
|
-
appName?: string;
|
|
79
|
-
};
|
|
80
|
-
type ConnectionMode = "streaming" | "polling";
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region ../js-server-sdk/src/types.d.ts
|
|
83
|
-
/**
|
|
84
|
-
* Configuration options for the {@link ConfigDirectorClient}
|
|
85
|
-
*/
|
|
86
|
-
type ConfigDirectorClientOptions = {
|
|
87
|
-
/**
|
|
88
|
-
* Application metadata that remains constant through the lifetime of the connection
|
|
89
|
-
*/
|
|
90
|
-
metadata?: ConfigDirectorMetaContext;
|
|
91
|
-
/**
|
|
92
|
-
* Connection options
|
|
93
|
-
*/
|
|
94
|
-
connection?: {
|
|
95
|
-
/**
|
|
96
|
-
* The connection mode to be used, one of `streaming` (default) or `polling`.
|
|
97
|
-
* If set to `streaming`, the connection will remain open and receive updates whenever
|
|
98
|
-
* config state is updated on the ConfigDirector dashboard.
|
|
99
|
-
* When set to `polling`, there will be an initial request to retrieve config state during
|
|
100
|
-
* initialization, and additional requests on a `pollingInterval`.
|
|
101
|
-
*
|
|
102
|
-
* Defaults to `streaming`
|
|
103
|
-
*/
|
|
104
|
-
mode?: ConnectionMode;
|
|
105
|
-
/**
|
|
106
|
-
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
107
|
-
* effect when the `mode` is set to `streaming`.
|
|
108
|
-
*
|
|
109
|
-
* Defaults to 60 seconds
|
|
110
|
-
*/
|
|
111
|
-
pollingInterval?: number;
|
|
112
|
-
/**
|
|
113
|
-
* The timeout, in milliseconds, to be used in initialization and when updating the context.
|
|
114
|
-
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
115
|
-
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
116
|
-
* If streaming is disabled, if the operation times out, it will not be retried.
|
|
117
|
-
*
|
|
118
|
-
* Defaults to 3,000 milliseconds (3 seconds)
|
|
119
|
-
*/
|
|
120
|
-
timeout?: number;
|
|
121
|
-
/**
|
|
122
|
-
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
123
|
-
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
124
|
-
* a proxy for the client SDK.
|
|
125
|
-
*/
|
|
126
|
-
url?: string;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* A logger that implements {@link ConfigDirectorLogger}. It defaults to the ConfigDirector console
|
|
130
|
-
* logger set to 'warn' level.
|
|
131
|
-
*
|
|
132
|
-
* The log level of the default logger can be adjusted by creating a default logger with the desired
|
|
133
|
-
* level and providing it in this property:
|
|
134
|
-
* @example
|
|
135
|
-
* import { createClient, createConsoleLogger } from "@configdirector/server-sdk";
|
|
136
|
-
* const client = createClient(
|
|
137
|
-
* "YOUR-SERVER-SDK-KEY",
|
|
138
|
-
* { logger: createConsoleLogger("debug") },
|
|
139
|
-
* );
|
|
140
|
-
*/
|
|
141
|
-
logger?: ConfigDirectorLogger;
|
|
142
|
-
/**
|
|
143
|
-
* Telemetry tunning. It is unlikely these settings need to be adjusted. However, in cases where
|
|
144
|
-
* your application has a large number of evaluations per second, you can adjust these settings
|
|
145
|
-
* to tune the memory footprint and frequency of telemetry requests.
|
|
146
|
-
* Keep in mind that ConfigDirector relies on these telemetry events to provide insights and features
|
|
147
|
-
* related to the configs being used.
|
|
148
|
-
*/
|
|
149
|
-
telemetry?: {
|
|
150
|
-
/**
|
|
151
|
-
* The size limit of telemetry event queues. If the size limit is reached before the events are
|
|
152
|
-
* flushed to the network, older events will be dropped.
|
|
153
|
-
*
|
|
154
|
-
* ConfigDirector keeps a count of dropped events. If the number of dropped events is higher than
|
|
155
|
-
* 50% of the total events, ConfigDirector will issue a notification alert in the dashboard.
|
|
156
|
-
*
|
|
157
|
-
* A number between 100 and 100,000. Defaults to 5,000.
|
|
158
|
-
*/
|
|
159
|
-
eventQueueLimit?: number;
|
|
160
|
-
/**
|
|
161
|
-
* How often events are flushed and sent over the network in milliseconds.
|
|
162
|
-
*
|
|
163
|
-
* Decrease this number if your application consistently captures a large number of events in short
|
|
164
|
-
* periods of time in order to reduce memory footprint from a large event queue.
|
|
165
|
-
*
|
|
166
|
-
* Defaults to 30,000 milliseconds (30 seconds)
|
|
167
|
-
*/
|
|
168
|
-
flushInterval?: number;
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
* Handlers for hooks/events emitted by the client. Each hook accepts either a single event handler or
|
|
172
|
-
* an array of event handlers.
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
* import { createClient, createConsoleLogger } from "@configdirector/server-sdk";
|
|
176
|
-
* const client = createClient(
|
|
177
|
-
* "YOUR-SERVER-SDK-KEY",
|
|
178
|
-
* {
|
|
179
|
-
* hooks: {
|
|
180
|
-
* configEvaluated: (event) => { console.log(event.evaluation); }
|
|
181
|
-
* },
|
|
182
|
-
* },
|
|
183
|
-
* );
|
|
184
|
-
*/
|
|
185
|
-
hooks?: ClientHooks$1;
|
|
186
|
-
};
|
|
187
|
-
type ClientEvents$1 = {
|
|
188
|
-
configsUpdated: {
|
|
189
|
-
keys: string[];
|
|
190
|
-
};
|
|
191
|
-
clientReady: undefined;
|
|
192
|
-
configEvaluated: {
|
|
193
|
-
evaluation: ConfigEvaluation;
|
|
194
|
-
};
|
|
195
|
-
connectionError: {
|
|
196
|
-
error: Error;
|
|
197
|
-
};
|
|
198
|
-
};
|
|
199
|
-
type ClientHooks$1 = {
|
|
200
|
-
clientReady?: HookHandler$1<"clientReady"> | HookHandler$1<"clientReady">[];
|
|
201
|
-
configsUpdated?: HookHandler$1<"configsUpdated"> | HookHandler$1<"configsUpdated">[];
|
|
202
|
-
configEvaluated?: HookHandler$1<"configEvaluated"> | HookHandler$1<"configEvaluated">[];
|
|
203
|
-
connectionError?: HookHandler$1<"connectionError"> | HookHandler$1<"connectionError">[];
|
|
204
|
-
};
|
|
205
|
-
type HookHandler$1<TEvent extends keyof ClientEvents$1> = (payload: ClientEvents$1[TEvent]) => void;
|
|
206
|
-
type WatchHandler<T extends ConfigValueType> = (message: T) => void;
|
|
207
|
-
/**
|
|
208
|
-
* The ConfigDirector SDK client object.
|
|
209
|
-
*
|
|
210
|
-
* Applications should create a single instance of `ConfigDirectorClient`, and call
|
|
211
|
-
* {@link initialize} during application initialization.
|
|
212
|
-
*/
|
|
213
|
-
interface ConfigDirectorClient {
|
|
214
|
-
/**
|
|
215
|
-
* Initializes the connection to ConfigDirector to retrieve config definitions. Until
|
|
216
|
-
* initialization is successful, all flags will return their default value provided to
|
|
217
|
-
* {@link watch} or {@link getValue}.
|
|
218
|
-
*
|
|
219
|
-
* If the connection fails or is interrupted with a transient error (network error,
|
|
220
|
-
* internal server error, etc) the client will continue to attempt to connect. However,
|
|
221
|
-
* if the connection fails with a persistent error, like an invalid SDK key, the client will
|
|
222
|
-
* not attempt to re-connect and an error will be logged to the console or the provided
|
|
223
|
-
* logger.
|
|
224
|
-
*/
|
|
225
|
-
initialize(): Promise<void>;
|
|
226
|
-
/**
|
|
227
|
-
* Returns whether or not the client is ready after calling {@link initialize}
|
|
228
|
-
*
|
|
229
|
-
* The definition of ready is that the connection to the server was successful, and config definitions
|
|
230
|
-
* were received.
|
|
231
|
-
*/
|
|
232
|
-
get isReady(): boolean;
|
|
233
|
-
/**
|
|
234
|
-
* Evaluates a config and returns its value based on the current context and targeting rules
|
|
235
|
-
*
|
|
236
|
-
* @returns The evaluated config value, or the `defaultValue` if the config state was unavailable
|
|
237
|
-
* @param configKey The config key to evaluate
|
|
238
|
-
* @param defaultValue The default value to be returned if the config state is unavailable. For
|
|
239
|
-
* example, if the client cannot connect to the server due to network conditions, or if getValue
|
|
240
|
-
* is called before initialization is done.
|
|
241
|
-
* @param context The user's context to be used for targeting rules evaluation (optional)
|
|
242
|
-
*/
|
|
243
|
-
getValue<T extends ConfigValueType>(configKey: string, defaultValue: T, context?: ConfigDirectorContext): T;
|
|
244
|
-
/**
|
|
245
|
-
* Watches for changes to a a config evaluation value. Whenever the config value changes, the
|
|
246
|
-
* provided callback function will be called with the new value. Changes can happen due to updates
|
|
247
|
-
* to the config in the ConfigDirector dashboard, or if the context is updated via {@link updateContext}.
|
|
248
|
-
*
|
|
249
|
-
* @returns An 'unwatch' function that can be called to remove the subscriber
|
|
250
|
-
*
|
|
251
|
-
* @param configKey The config key to watch
|
|
252
|
-
* @param defaultValue The default value to be referenced if the config state is unavailable
|
|
253
|
-
* @param callback The callback function to be called whenever the config value is updated
|
|
254
|
-
* @param context The user's context to be used for targeting rules evaluation (optional)
|
|
255
|
-
*/
|
|
256
|
-
watch<T extends ConfigValueType>(configKey: string, defaultValue: T, callback: WatchHandler<T>, context?: ConfigDirectorContext): () => void;
|
|
257
|
-
/**
|
|
258
|
-
* Removes a particular subscriber to the given `configKey`, or all subscribers if no callback
|
|
259
|
-
* is provided.
|
|
260
|
-
*
|
|
261
|
-
* @param configKey The config key to remove subscribers from
|
|
262
|
-
* @param callback The subscriber to be removed. If not provided, all subscribers are removed for
|
|
263
|
-
* the given `configKey`.
|
|
264
|
-
*/
|
|
265
|
-
unwatch<T extends ConfigValueType>(configKey: string, callback?: WatchHandler<T>): void;
|
|
266
|
-
/**
|
|
267
|
-
* Removes all subscribers from all config keys
|
|
268
|
-
*/
|
|
269
|
-
unwatchAll(): void;
|
|
270
|
-
/**
|
|
271
|
-
* Returns the evaluated {@link ConfigState} for every known config key, or only the keys
|
|
272
|
-
* listed in `configKeys` when provided.
|
|
273
|
-
*
|
|
274
|
-
* Intended for SSR hydration — does NOT record telemetry events. Returns an empty object
|
|
275
|
-
* when the client is not yet ready.
|
|
276
|
-
*/
|
|
277
|
-
getAllConfigs(options?: {
|
|
278
|
-
context?: ConfigDirectorContext;
|
|
279
|
-
configKeys?: string[];
|
|
280
|
-
}): Record<string, ConfigState>;
|
|
281
|
-
on<T extends keyof ClientEvents$1>(eventName: T, handler: (args: ClientEvents$1[T]) => void): void;
|
|
282
|
-
off<T extends keyof ClientEvents$1>(eventName: T, handler?: (args: ClientEvents$1[T]) => void): void;
|
|
283
|
-
/**
|
|
284
|
-
* Disposes of the client. All connections are closed, and all event and config key subscribers
|
|
285
|
-
* are removed.
|
|
286
|
-
*
|
|
287
|
-
* Intended to be called when your application shuts down
|
|
288
|
-
*/
|
|
289
|
-
dispose(): void;
|
|
290
|
-
}
|
|
291
|
-
//#endregion
|
|
292
5
|
//#region src/server/singleton.d.ts
|
|
293
6
|
declare global {
|
|
294
7
|
var __configDirectorServerClient: ConfigDirectorClient | undefined;
|
|
@@ -357,6 +70,7 @@ type HookHandler<TEvent extends keyof ClientEvents> = (payload: ClientEvents[TEv
|
|
|
357
70
|
type ClientEvents = {
|
|
358
71
|
configsUpdated: {
|
|
359
72
|
keys: string[];
|
|
73
|
+
removedKeys: string[];
|
|
360
74
|
};
|
|
361
75
|
clientReady: {
|
|
362
76
|
action: ClientConnectAction;
|
|
@@ -401,6 +115,18 @@ type ConfigDirectorProviderOptions = {
|
|
|
401
115
|
* Initialization timeout in milliseconds. Defaults to 3000.
|
|
402
116
|
*/
|
|
403
117
|
timeout?: number;
|
|
118
|
+
/**
|
|
119
|
+
* The connection mode, one of `streaming` or `polling`. In `streaming` mode the connection stays
|
|
120
|
+
* open and receives config updates as they happen. In `polling` mode configs are fetched once during
|
|
121
|
+
* initialization and then again on every `pollingInterval`. Defaults to `streaming`.
|
|
122
|
+
*/
|
|
123
|
+
mode?: ConnectionMode;
|
|
124
|
+
/**
|
|
125
|
+
* The polling interval in seconds when `mode` is `polling`. Has no effect in `streaming` mode.
|
|
126
|
+
* Defaults to 60 seconds. A value below the minimum of 30 seconds is raised to 30 seconds and a
|
|
127
|
+
* warning is logged.
|
|
128
|
+
*/
|
|
129
|
+
pollingInterval?: number;
|
|
404
130
|
/**
|
|
405
131
|
* Initial user context to evaluate targeting rules against.
|
|
406
132
|
*/
|