@configdirector/nextjs-sdk 1.13.0 → 1.14.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/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +2 -2
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.mjs +1 -1
- package/dist/client/index.mjs.map +1 -1
- package/dist/client/installedTestClient-Bam5r_HR.cjs +6 -0
- package/dist/client/installedTestClient-CL4AQC58.mjs +7 -0
- package/dist/client/installedTestClient-CL4AQC58.mjs.map +1 -0
- package/dist/client/testing.cjs +1 -1
- package/dist/client/testing.d.cts +12 -3
- package/dist/client/testing.d.cts.map +1 -1
- package/dist/client/testing.d.mts +12 -3
- package/dist/client/testing.d.mts.map +1 -1
- package/dist/client/testing.mjs +1 -1
- package/dist/client/testing.mjs.map +1 -1
- package/dist/client/{types-CRVL6Yi2.d.cts → types-CdyMdj5l.d.mts} +75 -7
- package/dist/client/types-CdyMdj5l.d.mts.map +1 -0
- package/dist/client/{types-B4kvU3bh.d.mts → types-P8frfCGH.d.cts} +75 -7
- package/dist/client/types-P8frfCGH.d.cts.map +1 -0
- package/dist/server/DefaultConfigDirectorClient-LQ79aY-g.mjs +6 -0
- package/dist/server/DefaultConfigDirectorClient-LQ79aY-g.mjs.map +1 -0
- package/dist/server/DefaultConfigDirectorClient-VHa0AfMj.cjs +5 -0
- package/dist/server/{errors-CxXHE84y.d.mts → errors-CkxBFyZy.d.cts} +76 -7
- package/dist/server/errors-CkxBFyZy.d.cts.map +1 -0
- package/dist/server/{errors-Do5xWGgb.d.cts → errors-CsEeGYMl.d.mts} +76 -7
- package/dist/server/errors-CsEeGYMl.d.mts.map +1 -0
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.cts +2 -2
- package/dist/server/index.d.cts.map +1 -1
- package/dist/server/index.d.mts +2 -2
- package/dist/server/index.d.mts.map +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/server/testing.cjs +1 -1
- package/dist/server/testing.d.cts +12 -3
- package/dist/server/testing.d.cts.map +1 -1
- package/dist/server/testing.d.mts +12 -3
- package/dist/server/testing.d.mts.map +1 -1
- package/dist/server/testing.mjs +1 -1
- package/dist/server/testing.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/client/installedTestClient-Byj9k8cX.cjs +0 -6
- package/dist/client/installedTestClient-DNVY-qrM.mjs +0 -7
- package/dist/client/installedTestClient-DNVY-qrM.mjs.map +0 -1
- package/dist/client/types-B4kvU3bh.d.mts.map +0 -1
- package/dist/client/types-CRVL6Yi2.d.cts.map +0 -1
- package/dist/server/DefaultConfigDirectorClient-BfpJX-Ni.mjs +0 -6
- package/dist/server/DefaultConfigDirectorClient-BfpJX-Ni.mjs.map +0 -1
- package/dist/server/DefaultConfigDirectorClient-C4cOinqO.cjs +0 -5
- package/dist/server/errors-CxXHE84y.d.mts.map +0 -1
- package/dist/server/errors-Do5xWGgb.d.cts.map +0 -1
|
@@ -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(`./native-values-UCK4hh1Z.cjs`);let u=require(`node:events`);u=c(u);let d=require(`node:crypto`),f=require(`node:fs/promises`),p=require(`node:path`),m=require(`semver`);m=c(m);let ee=require(`rapidhash-js`);var te=class e extends Error{constructor(t){super(t),this.name=`StreamClosedError`,Object.setPrototypeOf(this,e.prototype)}},ne=class e extends Error{constructor(t){super(t),this.name=`MissingResponseBodyError`,Object.setPrototypeOf(this,e.prototype)}},h=class e extends Error{constructor(t){super(t),this.name=`InvalidOptionError`,Object.setPrototypeOf(this,e.prototype)}},re=class e extends Error{constructor(t){super(t),this.name=`ValueOutOfRangeError`,Object.setPrototypeOf(this,e.prototype)}},ie=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 ae=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 ne(`The server response did not have a body`);this._readyState=g.OPEN,this._onConnect(),this.reconnectAttempt=0;let r=new ie({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 te(`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 re(`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 h(`${n} must be a function`);return e}};const oe=e=>new ae(e),se=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}},ce=9e4;var le=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=oe({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(),ce);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||se(ce,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.r(`${`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()}},ue=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.r(`Connection failed with status: ${e.status}`,e.status)}handleFetchError(e){throw this.isFetchErrorFatal(e)?(this.fatalError=!0,this.close(),new l.r(`Connection failed with fatal error: ${e}. This is an unrecoverable error, retry attempts will be ignored.`)):e instanceof SyntaxError?new l.r(`Failed to parse the response from the server: ${e}`):new l.r(`Connection failed with error: ${e}.`)}prepareFatalResponseStatusError(e,t){let n=e??0;return new l.r(`${`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()}},de=class extends ue{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 se(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 fe=(e,t,n)=>{let r=l.n(t,n);return{id:e,key:t,type:r.type,variations:[{name:null,value:r.value}],target:{defaultValue:r.value,rules:[]}}},pe={environmentId:`offline`,projectId:`offline`};var me=class{constructor(e){this.source=e,this.emitter=new u.default,this.connected=!1}async connect(){let e=await he(this.source);return this.connected=!0,this.emitter.emit(`configBundleReceived`,{...pe,kind:`full`,configs:e}),this}get isConnected(){return this.connected}on(e,t){this.emitter.on(e,t)}off(e,t){t?this.emitter.off(e,t):this.emitter.removeAllListeners(e)}close(){this.connected=!1}dispose(){this.close(),this.emitter.removeAllListeners()}};const he=async e=>{switch(e.kind){case`in-code-defaults`:return{};case`values`:return _e(e.values,`The offline values`);case`file`:return _e(await ge(e.path),`The offline values file '${e.path}'`);case`rejected`:throw new l.i(e.message)}},ge=async e=>{let t;try{t=await(0,f.readFile)((0,p.resolve)(e),`utf8`)}catch(t){throw new l.i(`The offline values file '${e}' could not be read: ${be(t)}`)}let n;try{n=JSON.parse(t)}catch(t){throw new l.i(`The offline values file '${e}' is not valid JSON: ${be(t)}`)}if(!ve(n))throw new l.i(`The offline values file '${e}' must hold a JSON object with one value per config key, but holds ${ye(n)}.`);return n},_e=(e,t)=>{try{return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,fe(`offline:${e}`,e,t)]))}catch(e){throw e instanceof l.a?new l.i(`${t} could not be loaded. ${e.message}`):e}},ve=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ye=e=>e===null?`null`:Array.isArray(e)?`an array`:`a ${typeof e}`,be=e=>e instanceof Error?e.message:String(e),xe=new URL(`https://server-sdk-api.configdirector.com`),Se=(e,t)=>{if(t?.mode===`offline`)return{kind:`stay-offline`,source:we(t)};let n=t?.mode??`streaming`;if(!e||e.trim().length==0)throw new l.a(`No server SDK key was provided, the client cannot be instantiated without a valid server SDK key`);return t?.file!==void 0||t?.values!==void 0?{kind:`stay-offline`,source:{kind:`rejected`,message:`The connection options 'file' and 'values' apply only when the connection mode is 'offline', but the mode is '${n}'.`}}:{kind:`connect`,mode:n,serverSdkKey:e,baseUrl:Ce(t?.url)}},Ce=e=>{if(!e)return xe;try{return new URL(e)}catch(t){throw new l.a(`Invalid base URL '${e}'. Parsing failed: ${t}`)}},we=e=>e.file!==void 0&&e.values!==void 0?{kind:`rejected`,message:`An offline connection takes either 'file' or 'values', not both.`}:e.file===void 0?e.values===void 0?{kind:`in-code-defaults`}:{kind:`values`,values:e.values}:{kind:`file`,path:e.file},Te=/^(?:0|[1-9][0-9]*)$/,Ee=/~(?![01])/,De=Object.prototype.propertyIsEnumerable,Oe=e=>{if(!Ee.test(e))return e.replace(/~1/g,`/`).replace(/~0/g,`~`)},ke=(e,t)=>{if(Array.isArray(e))return Te.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},Ae=(e,t)=>{if(e===``)return t;if(!e.startsWith(`/`))return;let n=t;for(let t of e.slice(1).split(`/`)){let e=Oe(t);if(e===void 0||(n=ke(n,e),n===void 0))return}return n},je=(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}},Me=(e,t,n)=>{let r=t.toLowerCase(),i=Ne(e);if(i===void 0)return r===`!=`||r===`does not equal`;let a=n[0];if(a===void 0)return!1;let o=Ne(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}},Ne=e=>{if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e!=`string`||e.length===0||!Pe(e))return;let t=Number(e);return Number.isFinite(t)?t:void 0},Pe=e=>{for(let t of e)if(!(t>=`0`&&t<=`9`)&&!`+-.eE`.includes(t))return!1;return!0};var _=class extends Error{},Fe=class extends _{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},Ie=class extends _{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},Le=class extends _{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},v=class extends _{},Re=class extends _{constructor(e){super(`Invalid unit ${e}`)}},y=class extends _{},b=class extends _{constructor(){super(`Zone is an abstract class`)}};const x=`numeric`,S=`short`,C=`long`,ze={year:x,month:x,day:x},Be={year:x,month:S,day:x},Ve={year:x,month:S,day:x,weekday:S},He={year:x,month:C,day:x},Ue={year:x,month:C,day:x,weekday:C},We={hour:x,minute:x},Ge={hour:x,minute:x,second:x},Ke={hour:x,minute:x,second:x,timeZoneName:S},qe={hour:x,minute:x,second:x,timeZoneName:C},Je={hour:x,minute:x,hourCycle:`h23`},Ye={hour:x,minute:x,second:x,hourCycle:`h23`},Xe={hour:x,minute:x,second:x,hourCycle:`h23`,timeZoneName:S},Ze={hour:x,minute:x,second:x,hourCycle:`h23`,timeZoneName:C},Qe={year:x,month:x,day:x,hour:x,minute:x},$e={year:x,month:x,day:x,hour:x,minute:x,second:x},et={year:x,month:S,day:x,hour:x,minute:x},tt={year:x,month:S,day:x,hour:x,minute:x,second:x},nt={year:x,month:S,day:x,weekday:S,hour:x,minute:x},rt={year:x,month:C,day:x,hour:x,minute:x,timeZoneName:S},it={year:x,month:C,day:x,hour:x,minute:x,second:x,timeZoneName:S},at={year:x,month:C,day:x,weekday:C,hour:x,minute:x,timeZoneName:C},ot={year:x,month:C,day:x,weekday:C,hour:x,minute:x,second:x,timeZoneName:C};var st=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 ct=null;var lt=class e extends st{static get instance(){return ct===null&&(ct=new e),ct}get type(){return`system`}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return In(e,t,n)}formatOffset(e,t){return Bn(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type===`system`}get isValid(){return!0}};const ut=new Map;function dt(e){let t=ut.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`}),ut.set(e,t)),t}const ft={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function pt(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 mt(e,t){let n=e.formatToParts(t),r=[];for(let e=0;e<n.length;e++){let{type:t,value:i}=n[e],a=ft[t];t===`era`?r[a]=i:M(a)||(r[a]=parseInt(i,10))}return r}const ht=new Map;var w=class e extends st{static create(t){let n=ht.get(t);return n===void 0&&ht.set(t,n=new e(t)),n}static resetCache(){ht.clear(),ut.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 In(e,t,n,this.name)}formatOffset(e,t){return Bn(this.offset(e),t)}offset(e){if(!this.valid)return NaN;let t=new Date(e);if(isNaN(t))return NaN;let n=dt(this.name),[r,i,a,o,s,c,l]=n.formatToParts?mt(n,t):pt(n,t);o===`BC`&&(r=-Math.abs(r)+1);let u=Mn({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 gt={};function _t(e,t={}){let n=JSON.stringify([e,t]),r=gt[n];return r||(r=new Intl.ListFormat(e,t),gt[n]=r),r}const vt=new Map;function yt(e,t={}){let n=JSON.stringify([e,t]),r=vt.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),vt.set(n,r)),r}const bt=new Map;function xt(e,t={}){let n=JSON.stringify([e,t]),r=bt.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),bt.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 wt=null;function Tt(){return wt||(wt=new Intl.DateTimeFormat().resolvedOptions().locale,wt)}const Et=new Map;function Dt(e){let t=Et.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),Et.set(e,t)),t}const Ot=new Map;function kt(e){let t=Ot.get(e);if(!t){let n=new Intl.Locale(e);t=`getWeekInfo`in n?n.getWeekInfo():n.weekInfo,`minimalDays`in t||(t={...zt,...t}),Ot.set(e,t)}return t}function At(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=yt(e).resolvedOptions(),r=e}catch{let i=e.substring(0,n);t=yt(i).resolvedOptions(),r=i}let{numberingSystem:i,calendar:a}=t;return[r,i,a]}}function jt(e,t,n){return n||t?(e.includes(`-u-`)||(e+=`-u`),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`),e):e}function Mt(e){let t=[];for(let n=1;n<=12;n++){let r=Q.utc(2009,n,1);t.push(e(r))}return t}function Nt(e){let t=[];for(let n=1;n<=7;n++){let r=Q.utc(2016,11,13+n);t.push(e(r))}return t}function Pt(e,t,n,r){let i=e.listingMode();return i===`error`?null:i===`en`?n(t):r(t)}function Ft(e){return e.numberingSystem&&e.numberingSystem!==`latn`?!1:e.numberingSystem===`latn`||!e.locale||e.locale.startsWith(`en`)||Dt(e.locale).numberingSystem===`latn`}var It=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=xt(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):kn(e,3),this.padTo)}},Lt=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=yt(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()}},Rt=class{constructor(e,t,n){this.opts={style:`long`,...n},!t&&xn()&&(this.rtf=Ct(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):ar(t,e,this.opts.numeric,this.opts.style!==`long`)}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}};const zt={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`:Tt()),n||k.defaultNumberingSystem,r||k.defaultOutputCalendar,En(i)||k.defaultWeekSettings,o)}static resetCache(){wt=null,vt.clear(),bt.clear(),St.clear(),Et.clear(),Ot.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]=At(e);this.locale=a,this.numberingSystem=t||o||null,this.outputCalendar=n||s||null,this.weekSettings=r,this.intl=jt(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??=Ft(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,En(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 Pt(this,e,Gn,()=>{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]=Mt(t)}return this.monthsCache[i][e]})}weekdays(e,t=!1){return Pt(this,e,Yn,()=>{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]=Nt(e=>this.extract(e,n,`weekday`))),this.weekdaysCache[r][e]})}meridiems(){return Pt(this,void 0,()=>Xn,()=>{if(!this.meridiemCache){let e={hour:`numeric`,hourCycle:`h12`};this.meridiemCache=[Q.utc(2016,11,13,9),Q.utc(2016,11,13,19)].map(t=>this.extract(t,e,`dayperiod`))}return this.meridiemCache})}eras(e){return Pt(this,e,er,()=>{let t={era:e};return this.eraCache[e]||(this.eraCache[e]=[Q.utc(-40,1,1),Q.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 It(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new Lt(e,this.intl,t)}relFormatter(e={}){return new Rt(this.intl,this.isEnglish(),e)}listFormatter(e={}){return _t(this.intl,e)}isEnglish(){return this.locale===`en`||this.locale.toLowerCase()===`en-us`||Dt(this.intl).locale.startsWith(`en-us`)}getWeekSettings(){return this.weekSettings?this.weekSettings:Sn()?kt(this.locale):zt}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 Bt=null;var E=class e extends st{static get utcInstance(){return Bt===null&&(Bt=new e(0)),Bt}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(Ln(n[1],n[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return`fixed`}get name(){return this.fixed===0?`UTC`:`UTC${Bn(this.fixed,`narrow`)}`}get ianaName(){return this.fixed===0?`Etc/UTC`:`Etc/GMT${Bn(-this.fixed,`narrow`)}`}offsetName(){return this.name}formatOffset(e,t){return Bn(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}},Vt=class extends st{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 st)return e;if(yn(e)){let n=e.toLowerCase();return n===`default`?t:n===`local`||n===`system`?lt.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 Vt(e)}const Ht={arab:`[٠-٩]`,arabext:`[۰-۹]`,bali:`[᭐-᭙]`,beng:`[০-৯]`,deva:`[०-९]`,fullwide:`[0-9]`,gujr:`[૦-૯]`,hanidec:`[〇|一|二|三|四|五|六|七|八|九]`,khmr:`[០-៩]`,knda:`[೦-೯]`,laoo:`[໐-໙]`,limb:`[᥆-᥏]`,mlym:`[൦-൯]`,mong:`[᠐-᠙]`,mymr:`[၀-၉]`,orya:`[୦-୯]`,tamldec:`[௦-௯]`,telu:`[౦-౯]`,thai:`[๐-๙]`,tibt:`[༠-༩]`,latn:`\\d`},Ut={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]},Wt=Ht.hanidec.replace(/[\[|\]]/g,``).split(``);function Gt(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(Ht.hanidec)!==-1)t+=Wt.indexOf(e[n]);else for(let e in Ut){let[n,i]=Ut[e];r>=n&&r<=i&&(t+=r-n)}}return parseInt(t,10)}else return t}const Kt=new Map;function qt(){Kt.clear()}function O({numberingSystem:e},t=``){let n=e||`latn`,r=Kt.get(n);r===void 0&&(r=new Map,Kt.set(n,r));let i=r.get(t);return i===void 0&&(i=RegExp(`${Ht[n]}${t}`),r.set(t,i)),i}let Jt=()=>Date.now(),Yt=`system`,Xt=null,Zt=null,Qt=null,$t=60,en,tn=null;var k=class{static get now(){return Jt}static set now(e){Jt=e}static set defaultZone(e){Yt=e}static get defaultZone(){return D(Yt,lt.instance)}static get defaultLocale(){return Xt}static set defaultLocale(e){Xt=e}static get defaultNumberingSystem(){return Zt}static set defaultNumberingSystem(e){Zt=e}static get defaultOutputCalendar(){return Qt}static set defaultOutputCalendar(e){Qt=e}static get defaultWeekSettings(){return tn}static set defaultWeekSettings(e){tn=En(e)}static get twoDigitCutoffYear(){return $t}static set twoDigitCutoffYear(e){$t=e%100}static get throwOnInvalid(){return en}static set throwOnInvalid(e){en=e}static resetCaches(){T.resetCache(),w.resetCache(),Q.resetCache(),qt()}},A=class{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}};const nn=[0,31,59,90,120,151,181,212,243,273,304,334],rn=[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 an(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 on(e,t,n){return n+(An(e)?rn:nn)[t-1]}function sn(e,t){let n=An(e)?rn:nn,r=n.findIndex(e=>e<t),i=t-n[r];return{month:r+1,day:i}}function cn(e,t){return(e-t+7)%7+1}function ln(e,t=4,n=1){let{year:r,month:i,day:a}=e,o=on(r,i,a),s=cn(an(r,i,a),n),c=Math.floor((o-s+14-t)/7),l;return c<1?(l=r-1,c=Pn(l,t,n)):c>Pn(r,t,n)?(l=r+1,c=1):l=r,{weekYear:l,weekNumber:c,weekday:s,...Vn(e)}}function un(e,t=4,n=1){let{weekYear:r,weekNumber:i,weekday:a}=e,o=cn(an(r,1,t),n),s=z(r),c=i*7+a-o-7+t,l;c<1?(l=r-1,c+=z(l)):c>s?(l=r+1,c-=z(r)):l=r;let{month:u,day:d}=sn(l,c);return{year:l,month:u,day:d,...Vn(e)}}function dn(e){let{year:t,month:n,day:r}=e;return{year:t,ordinal:on(t,n,r),...Vn(e)}}function fn(e){let{year:t,ordinal:n}=e,{month:r,day:i}=sn(t,n);return{year:t,month:r,day:i,...Vn(e)}}function pn(e,t){if(!M(e.localWeekday)||!M(e.localWeekNumber)||!M(e.localWeekYear)){if(!M(e.weekday)||!M(e.weekNumber)||!M(e.weekYear))throw new v(`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 mn(e,t=4,n=1){let r=vn(e.weekYear),i=F(e.weekNumber,1,Pn(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 hn(e){let t=vn(e.year),n=F(e.ordinal,1,z(e.year));return t?n?!1:j(`ordinal`,e.ordinal):j(`year`,e.year)}function gn(e){let t=vn(e.year),n=F(e.month,1,12),r=F(e.day,1,jn(e.year,e.month));return t?n?r?!1:j(`day`,e.day):j(`month`,e.month):j(`year`,e.year)}function _n(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 vn(e){return typeof e==`number`&&e%1==0}function yn(e){return typeof e==`string`}function bn(e){return Object.prototype.toString.call(e)===`[object Date]`}function xn(){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 wn(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 Tn(e,t){return t.reduce((t,n)=>(t[n]=e[n],t),{})}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function En(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 vn(e)&&e>=t&&e<=n}function Dn(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 On(e){if(!(M(e)||e===null||e===``)){let t=parseFloat(`0.`+e)*1e3;return Math.floor(t)}}function kn(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 An(e){return e%4==0&&(e%100!=0||e%400==0)}function z(e){return An(e)?366:365}function jn(e,t){let n=Dn(t-1,12)+1,r=e+(t-n)/12;return n===2?An(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function Mn(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 Nn(e,t,n){return-cn(an(e,1,t),n)+t-1}function Pn(e,t=4,n=1){let r=Nn(e,t,n),i=Nn(e+1,t,n);return(z(e)-r+i)/7}function Fn(e){return e>99?e:e>k.twoDigitCutoffYear?1900+e:2e3+e}function In(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 Ln(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 Rn(e){let t=Number(e);if(typeof e==`boolean`||e===``||!Number.isFinite(t))throw new y(`Invalid unit value ${e}`);return t}function zn(e,t){let n={};for(let r in e)if(P(e,r)){let i=e[r];if(i==null)continue;n[t(r)]=Rn(i)}return n}function Bn(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 Vn(e){return Tn(e,[`hour`,`minute`,`second`,`millisecond`])}const Hn=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],Un=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Wn=[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`];function Gn(e){switch(e){case`narrow`:return[...Wn];case`short`:return[...Un];case`long`:return[...Hn];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 Kn=[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],qn=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],Jn=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function Yn(e){switch(e){case`narrow`:return[...Jn];case`short`:return[...qn];case`long`:return[...Kn];case`numeric`:return[`1`,`2`,`3`,`4`,`5`,`6`,`7`];default:return null}}const Xn=[`AM`,`PM`],Zn=[`Before Christ`,`Anno Domini`],Qn=[`BC`,`AD`],$n=[`B`,`A`];function er(e){switch(e){case`narrow`:return[...$n];case`short`:return[...Qn];case`long`:return[...Zn];default:return null}}function tr(e){return Xn[e.hour<12?0:1]}function nr(e,t){return Yn(t)[e.weekday-1]}function rr(e,t){return Gn(t)[e.month-1]}function ir(e,t){return er(t)[e.year<0?0:1]}function ar(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 or(e,t){let n=``;for(let r of e)r.literal?n+=r.val:n+=t(r.val);return n}const sr={D:ze,DD:Be,DDD:He,DDDD:Ue,t:We,tt:Ge,ttt:Ke,tttt:qe,T:Je,TT:Ye,TTT:Xe,TTTT:Ze,f:Qe,ff:et,fff:rt,ffff:at,F:$e,FF:tt,FFF:it,FFFF:ot};var B=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 sr[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?tr(t):a({hour:`numeric`,hourCycle:`h12`},`dayperiod`),c=(e,n)=>r?rr(t,e):a(n?{month:e}:{month:e,day:`numeric`},`month`),l=(e,n)=>r?nr(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?ir(t,e):a({era:e},`era`);return or(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 or(o,a(c,{isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]}))}};const cr=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function lr(...e){let t=e.reduce((e,t)=>e+t.source,``);return RegExp(`^${t}$`)}function ur(...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 dr(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 fr(...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 pr=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,mr=`(?:${pr.source}?(?:\\[(${cr.source})\\])?)?`,hr=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,gr=RegExp(`${hr.source}${mr}`),_r=RegExp(`(?:[Tt]${gr.source})?`),vr=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,yr=/(\d{4})-?W(\d\d)(?:-?(\d))?/,br=/(\d{4})-?(\d{3})/,xr=fr(`weekYear`,`weekNumber`,`weekDay`),Sr=fr(`year`,`ordinal`),Cr=/(\d{4})-(\d\d)-(\d\d)/,wr=RegExp(`${hr.source} ?(?:${pr.source}|(${cr.source}))?`),Tr=RegExp(`(?: ${wr.source})?`);function V(e,t,n){let r=e[t];return M(r)?n:L(r)}function Er(e,t){return[{year:V(e,t),month:V(e,t+1,1),day:V(e,t+2,1)},null,t+3]}function H(e,t){return[{hours:V(e,t,0),minutes:V(e,t+1,0),seconds:V(e,t+2,0),milliseconds:On(e[t+3])},null,t+4]}function Dr(e,t){let n=!e[t]&&!e[t+1],r=Ln(e[t+1],e[t+2]);return[{},n?null:E.instance(r),t+3]}function Or(e,t){return[{},e[t]?w.create(e[t]):null,t+1]}const kr=RegExp(`^T?${hr.source}$`),Ar=/^-?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 jr(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(On(l),d)}]}const Mr={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Nr(e,t,n,r,i,a,o){let s={year:t.length===2?Fn(L(t)):L(t),month:Un.indexOf(n)+1,day:L(r),hour:L(i),minute:L(a)};return o&&(s.second=L(o)),e&&(s.weekday=e.length>3?Kn.indexOf(e)+1:qn.indexOf(e)+1),s}const Pr=/^(?:(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 Fr(e){let[,t,n,r,i,a,o,s,c,l,u,d]=e,f=Nr(t,i,r,n,a,o,s),p;return p=c?Mr[c]:l?0:Ln(u,d),[f,new E(p)]}function Ir(e){return e.replace(/\([^()]*\)|[\n\t]/g,` `).replace(/(\s\s+)/g,` `).trim()}const Lr=/^(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$/,Rr=/^(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$/,zr=/^(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 Br(e){let[,t,n,r,i,a,o,s]=e;return[Nr(t,i,r,n,a,o,s),E.utcInstance]}function Vr(e){let[,t,n,r,i,a,o,s]=e;return[Nr(t,s,n,r,i,a,o),E.utcInstance]}const Hr=lr(vr,_r),Ur=lr(yr,_r),Wr=lr(br,_r),Gr=lr(gr),Kr=ur(Er,H,Dr,Or),qr=ur(xr,H,Dr,Or),Jr=ur(Sr,H,Dr,Or),Yr=ur(H,Dr,Or);function Xr(e){return dr(e,[Hr,Kr],[Ur,qr],[Wr,Jr],[Gr,Yr])}function Zr(e){return dr(Ir(e),[Pr,Fr])}function Qr(e){return dr(e,[Lr,Br],[Rr,Br],[zr,Vr])}function $r(e){return dr(e,[Ar,jr])}const ei=ur(H);function ti(e){return dr(e,[kr,ei])}const ni=lr(Cr,Tr),ri=lr(wr),ii=ur(H,Dr,Or);function ai(e){return dr(e,[ni,Kr],[ri,ii])}const oi=`Invalid Duration`,si={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}},ci={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},...si},U=146097/400,W=146097/4800,li={years:{quarters:4,months:12,weeks:U/7,days:U,hours:U*24,minutes:U*24*60,seconds:U*24*60*60,milliseconds:U*24*60*60*1e3},quarters:{months:3,weeks:U/28,days:U/4,hours:U*24/4,minutes:U*24*60/4,seconds:U*24*60*60/4,milliseconds:U*24*60*60*1e3/4},months:{weeks:W/7,days:W,hours:W*24,minutes:W*24*60,seconds:W*24*60*60,milliseconds:W*24*60*60*1e3},...si},G=[`years`,`quarters`,`months`,`weeks`,`days`,`hours`,`minutes`,`seconds`,`milliseconds`],ui=G.slice(0).reverse();function K(e,t,n=!1){return new q({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 di(e,t){let n=t.milliseconds??0;for(let r of ui.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function fi(e,t){let n=di(e,t)<0?-1:1;G.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),G.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 pi(e){let t={};for(let[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}var q=class e{constructor(e){let t=e.conversionAccuracy===`longterm`||!1,n=t?li:ci;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:zn(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]=$r(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]=ti(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 Le(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 Re(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?B.create(this.loc,n).formatDurationFromString(this,e):oi}toHuman(e={}){if(!this.isValid)return oi;let t=e.showZeros!==!1,n=G.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+=kn(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},Q.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?di(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 G)(P(n.values,e)||P(this.values,e))&&(r[e]=n.get(e)+this.get(e));return K(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]=Rn(e(this.values[n],n));return K(this,{values:t},!0)}get(t){return this[e.normalizeUnit(t)]}set(t){if(!this.isValid)return this;let n={...this.values,...zn(t,e.normalizeUnit)};return K(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 K(this,i)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return fi(this.matrix,e),K(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=pi(this.normalize().shiftToAll().toObject());return K(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 G)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 fi(this.matrix,n),K(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 K(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;let e=pi(this.values);return K(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 G)if(!t(this.values[n],e.values[n]))return!1;return!0}};const J=`Invalid Interval`;function mi(e,t){return!e||!e.isValid?hi.invalid(`missing or invalid start`):!t||!t.isValid?hi.invalid(`missing or invalid end`):t<e?hi.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 hi=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 Ie(r);return new e({invalid:r})}static fromDateTimes(t,n){let r=ma(t),i=ma(n);return mi(r,i)??new e({start:r,end:i})}static after(t,n){let r=q.fromDurationLike(n),i=ma(t);return e.fromDateTimes(i,i.plus(r))}static before(t,n){let r=q.fromDurationLike(n),i=ma(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=Q.fromISO(r,n),a=t.isValid}catch{a=!1}let o,s;try{o=Q.fromISO(i,n),s=o.isValid}catch{s=!1}if(a&&s)return e.fromDateTimes(t,o);if(a){let r=q.fromISO(i,n);if(r.isValid)return e.after(t,r)}else if(s){let t=q.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(ma).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=q.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()})`:J}[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=ze,t={}){return this.isValid?B.create(this.s.loc.clone(t),e).formatInterval(this):J}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:J}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:J}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:J}toFormat(e,{separator:t=` – `}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:J}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):q.invalid(this.invalidReason)}mapEndpoints(t){return e.fromDateTimes(t(this.s),t(this.e))}},gi=class{static hasDST(e=k.defaultZone){let t=Q.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:xn(),localeWeek:Sn()}}};function _i(e,t){let n=e=>e.toUTC(0,{keepLocalTime:!0}).startOf(`day`).valueOf(),r=n(t)-n(e);return Math.floor(q.fromMillis(r).as(`days`))}function vi(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=_i(e,t);return(n-n%7)/7}],[`days`,_i]],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 yi(e,t,n,r){let[i,a,o,s]=vi(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=q.fromObject(a,r);return l.length>0?q.fromMillis(c,r).shiftTo(...l).plus(u):u}function Y(e,t=e=>e){return{regex:e,deser:([e])=>t(Gt(e))}}const bi=`[ \xA0]`,xi=new RegExp(bi,`g`);function Si(e){return e.replace(/\./g,`\\.?`).replace(xi,bi)}function Ci(e){return e.replace(/\./g,``).replace(xi,` `).toLowerCase()}function X(e,t){return e===null?null:{regex:RegExp(e.map(Si).join(`|`)),deser:([n])=>e.findIndex(e=>Ci(n)===Ci(e))+t}}function wi(e,t){return{regex:e,deser:([,e,t])=>Ln(e,t),groups:t}}function Ti(e){return{regex:e,deser:([e])=>e}}function Ei(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(Ei(e.val)),deser:([e])=>e,literal:!0}),m=(m=>{if(e.literal)return p(m);switch(m.val){case`G`:return X(t.eras(`short`),0);case`GG`:return X(t.eras(`long`),0);case`y`:return Y(l);case`yy`:return Y(d,Fn);case`yyyy`:return Y(a);case`yyyyy`:return Y(f);case`yyyyyy`:return Y(o);case`M`:return Y(s);case`MM`:return Y(r);case`MMM`:return X(t.months(`short`,!0),1);case`MMMM`:return X(t.months(`long`,!0),1);case`L`:return Y(s);case`LL`:return Y(r);case`LLL`:return X(t.months(`short`,!1),1);case`LLLL`:return X(t.months(`long`,!1),1);case`d`:return Y(s);case`dd`:return Y(r);case`o`:return Y(c);case`ooo`:return Y(i);case`HH`:return Y(r);case`H`:return Y(s);case`hh`:return Y(r);case`h`:return Y(s);case`mm`:return Y(r);case`m`:return Y(s);case`q`:return Y(s);case`qq`:return Y(r);case`s`:return Y(s);case`ss`:return Y(r);case`S`:return Y(c);case`SSS`:return Y(i);case`u`:return Ti(u);case`uu`:return Ti(s);case`uuu`:return Y(n);case`a`:return X(t.meridiems(),0);case`kkkk`:return Y(a);case`kk`:return Y(d,Fn);case`W`:return Y(s);case`WW`:return Y(r);case`E`:case`c`:return Y(n);case`EEE`:return X(t.weekdays(`short`,!1),1);case`EEEE`:return X(t.weekdays(`long`,!1),1);case`ccc`:return X(t.weekdays(`short`,!0),1);case`cccc`:return X(t.weekdays(`long`,!0),1);case`Z`:case`ZZ`:return wi(RegExp(`([+-]${s.source})(?::(${r.source}))?`),2);case`ZZZ`:return wi(RegExp(`([+-]${s.source})(${r.source})?`),2);case`z`:return Ti(/[a-z_+-/]{1,256}?/i);case` `:return Ti(/[^\S\n\r]/);default:return p(m)}})(e)||{invalidReason:`missing Intl.DateTimeFormat.formatToParts support`};return m.token=e,m}const Oi={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 ki(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=Oi[o];if(typeof s==`object`&&(s=s[a]),s)return{literal:!1,val:s}}function Ai(e){return[`^${e.map(e=>e.regex).reduce((e,t)=>`${e}(${t.source})`,``)}$`,e]}function ji(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 Mi(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=On(e.u)),[Object.keys(e).reduce((n,r)=>{let i=t(r);return i&&(n[i]=e[r]),n},{}),n,r]}let Ni=null;function Pi(){return Ni||=Q.fromMillis(1555555555555),Ni}function Fi(e,t){if(e.literal)return e;let n=Bi(B.macroTokenToFormatOpts(e.val),t);return n==null||n.includes(void 0)?e:n}function Ii(e,t){return Array.prototype.concat(...e.map(e=>Fi(e,t)))}var Li=class{constructor(e,t){if(this.locale=e,this.format=t,this.tokens=Ii(B.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]=Ai(this.units);this.regex=RegExp(e,`i`),this.handlers=t}}explainFromTokens(e){if(this.isValid){let[t,n]=ji(e,this.regex,this.handlers),[r,i,a]=n?Mi(n):[null,null,void 0];if(P(n,`a`)&&P(n,`H`))throw new v(`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 Ri(e,t,n){return new Li(e,n).explainFromTokens(t)}function zi(e,t,n){let{result:r,zone:i,specificOffset:a,invalidReason:o}=Ri(e,t,n);return[r,i,a,o]}function Bi(e,t){if(!e)return null;let n=B.create(t,e).dtFormatter(Pi()),r=n.formatToParts(),i=n.resolvedOptions();return r.map(t=>ki(t,e,i))}const Vi=`Invalid DateTime`,Hi=864e13;function Ui(e){return new A(`unsupported zone`,`the zone "${e.name}" is not supported`)}function Wi(e){return e.weekData===null&&(e.weekData=ln(e.c)),e.weekData}function Gi(e){return e.localWeekData===null&&(e.localWeekData=ln(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function Z(e,t){let n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new Q({...n,...t,old:n})}function Ki(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 qi(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 Ji(e,t,n){return Ki(Mn(e),t,n)}function Yi(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,jn(r,i))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},o=q.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]=Ki(Mn(a),n,e.zone);return o!==0&&(s+=o,c=e.zone.offset(s)),{ts:s,o:c}}function Xi(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=Q.fromObject(e,{...n,zone:r,specificOffset:a});return o?i:i.setZone(s)}else return Q.invalid(new A(`unparsable`,`the input "${i}" can't be parsed as ${r}`))}function Zi(e,t,n=!0){return e.isValid?B.create(T.create(`en-US`),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function Qi(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 $i(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 ea={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},ta={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},na={ordinal:1,hour:0,minute:0,second:0,millisecond:0},ra=[`year`,`month`,`day`,`hour`,`minute`,`second`,`millisecond`],ia=[`weekYear`,`weekNumber`,`weekday`,`hour`,`minute`,`second`,`millisecond`],aa=[`year`,`ordinal`,`hour`,`minute`,`second`,`millisecond`];function oa(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 Re(e);return t}function sa(e){switch(e.toLowerCase()){case`localweekday`:case`localweekdays`:return`localWeekday`;case`localweeknumber`:case`localweeknumbers`:return`localWeekNumber`;case`localweekyear`:case`localweekyears`:return`localWeekYear`;default:return oa(e)}}function ca(e){if(fa===void 0&&(fa=k.now()),e.type!==`iana`)return e.offset(fa);let t=e.name,n=pa.get(t);return n===void 0&&(n=e.offset(fa),pa.set(t,n)),n}function la(e,t){let n=D(t.zone,k.defaultZone);if(!n.isValid)return Q.invalid(Ui(n));let r=T.fromObject(t),i,a;if(M(e.year))i=k.now();else{for(let t of ra)M(e[t])&&(e[t]=ea[t]);let t=gn(e)||_n(e);if(t)return Q.invalid(t);let r=ca(n);[i,a]=Ji(e,r,n)}return new Q({ts:i,zone:n,loc:r,o:a})}function ua(e,t,n){let r=M(n.round)?!0:n.round,i=M(n.rounding)?`trunc`:n.rounding,a=(e,a)=>(e=kn(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 da(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 fa;const pa=new Map;var Q=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:Ui(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=qi(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]=da(arguments),[n,r,i,a,o,s,c]=t;return la({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static utc(){let[e,t]=da(arguments),[n,r,i,a,o,s,c]=t;return e.zone=E.utcInstance,la({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static fromJSDate(t,n={}){let r=bn(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(Ui(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<-Hi||t>Hi?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(Ui(r));let i=T.fromObject(n),a=zn(t,sa),{minDaysInFirstWeek:o,startOfWeek:s}=pn(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 v(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(f&&u)throw new v(`Can't mix ordinal dates with month/day`);let ee=m||a.weekday&&!p,te,ne,h=qi(c,l);ee?(te=ia,ne=ta,h=ln(h,o,s)):u?(te=aa,ne=na,h=dn(h)):(te=ra,ne=ea);let re=!1;for(let e of te){let t=a[e];M(t)?re?a[e]=ne[e]:a[e]=h[e]:re=!0}let ie=(ee?mn(a,o,s):u?hn(a):gn(a))||_n(a);if(ie)return e.invalid(ie);let[g,ae]=Ji(ee?un(a,o,s):u?fn(a):a,l,r),oe=new e({ts:g,zone:r,o:ae,loc:i});return a.weekday&&p&&t.weekday!==oe.weekday?e.invalid(`mismatched weekday`,`you can't specify both a weekday of ${a.weekday} and a date of ${oe.toISO()}`):oe.isValid?oe:e.invalid(oe.invalid)}static fromISO(e,t={}){let[n,r]=Xr(e);return Xi(n,r,t,`ISO 8601`,e)}static fromRFC2822(e,t={}){let[n,r]=Zr(e);return Xi(n,r,t,`RFC 2822`,e)}static fromHTTP(e,t={}){let[n,r]=Qr(e);return Xi(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]=zi(T.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0}),t,n);return l?e.invalid(l):Xi(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]=ai(e);return Xi(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 Fe(r);return new e({invalid:r})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){let n=Bi(e,T.fromObject(t));return n?n.map(e=>e?e.val:null).join(``):null}static expandFormat(e,t={}){return Ii(B.parseFormat(e),T.fromObject(t)).map(e=>e.val).join(``)}static resetCache(){fa=void 0,pa.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?Wi(this).weekYear:NaN}get weekNumber(){return this.isValid?Wi(this).weekNumber:NaN}get weekday(){return this.isValid?Wi(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Gi(this).weekday:NaN}get localWeekNumber(){return this.isValid?Gi(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Gi(this).weekYear:NaN}get ordinal(){return this.isValid?dn(this.c).ordinal:NaN}get monthShort(){return this.isValid?gi.months(`short`,{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?gi.months(`long`,{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?gi.weekdays(`short`,{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?gi.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=Mn(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=qi(s,a),u=qi(c,o);return l.hour===u.hour&&l.minute===u.minute&&l.second===u.second&&l.millisecond===u.millisecond?[Z(this,{ts:s}),Z(this,{ts:c})]:[this]}get isInLeapYear(){return An(this.year)}get daysInMonth(){return jn(this.year,this.month)}get daysInYear(){return this.isValid?z(this.year):NaN}get weeksInWeekYear(){return this.isValid?Pn(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?Pn(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){let{locale:t,numberingSystem:n,calendar:r}=B.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]=Ji(r,n,t)}return Z(this,{ts:e,zone:t})}else return e.invalid(Ui(t))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){let r=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return Z(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let t=zn(e,sa),{minDaysInFirstWeek:n,startOfWeek:r}=pn(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 v(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(s&&a)throw new v(`Can't mix ordinal dates with month/day`);let u;i?u=un({...ln(this.c,n,r),...t},n,r):M(t.ordinal)?(u={...this.toObject(),...t},M(t.day)&&(u.day=Math.min(jn(u.year,u.month),u.day))):u=fn({...dn(this.c),...t});let[d,f]=Ji(u,this.o,this.zone);return Z(this,{ts:d,o:f})}plus(e){if(!this.isValid)return this;let t=q.fromDurationLike(e);return Z(this,Yi(this,t))}minus(e){if(!this.isValid)return this;let t=q.fromDurationLike(e).negate();return Z(this,Yi(this,t))}startOf(e,{useLocaleWeeks:t=!1}={}){if(!this.isValid)return this;let n={},r=q.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?B.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):Vi}toLocaleString(e=ze,t={}){return this.isValid?B.create(this.loc.clone(t),e).formatDateTime(this):Vi}toLocaleParts(e={}){return this.isValid?B.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=oa(a);let o=e===`extended`,s=Qi(this,o,a);return ra.indexOf(a)>=3&&(s+=`T`),s+=$i(this,o,t,n,r,i,a),s}toISODate({format:e=`extended`,precision:t=`day`}={}){return this.isValid?Qi(this,e===`extended`,oa(t)):null}toISOWeekDate(){return Zi(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=oa(o),(r&&ra.indexOf(o)>=3?`T`:``)+$i(this,a===`extended`,t,e,n,i,o)):null}toRFC2822(){return Zi(this,`EEE, dd LLL yyyy HH:mm:ss ZZZ`,!1)}toHTTP(){return Zi(this.toUTC(),`EEE, dd LLL yyyy HH:mm:ss 'GMT'`)}toSQLDate(){return this.isValid?Qi(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`)),Zi(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Vi}[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 q.invalid(`created by diffing an invalid DateTime`);let r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=Cn(t).map(q.normalizeUnit),a=e.valueOf()>this.valueOf(),o=yi(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?hi.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),ua(n,this.plus(r),{...t,numeric:`always`,units:i,unit:a})}toRelativeCalendar(t={}){return this.isValid?ua(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 wn(t,e=>e.valueOf(),Math.min)}static max(...t){if(!t.every(e.isDateTime))throw new y(`max requires all arguments be DateTimes`);return wn(t,e=>e.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){let{locale:r=null,numberingSystem:i=null}=n;return Ri(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 Li(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):Xi(s,c,r,`format ${n.format}`,t,l)}static get DATE_SHORT(){return ze}static get DATE_MED(){return Be}static get DATE_MED_WITH_WEEKDAY(){return Ve}static get DATE_FULL(){return He}static get DATE_HUGE(){return Ue}static get TIME_SIMPLE(){return We}static get TIME_WITH_SECONDS(){return Ge}static get TIME_WITH_SHORT_OFFSET(){return Ke}static get TIME_WITH_LONG_OFFSET(){return qe}static get TIME_24_SIMPLE(){return Je}static get TIME_24_WITH_SECONDS(){return Ye}static get TIME_24_WITH_SHORT_OFFSET(){return Xe}static get TIME_24_WITH_LONG_OFFSET(){return Ze}static get DATETIME_SHORT(){return Qe}static get DATETIME_SHORT_WITH_SECONDS(){return $e}static get DATETIME_MED(){return et}static get DATETIME_MED_WITH_SECONDS(){return tt}static get DATETIME_MED_WITH_WEEKDAY(){return nt}static get DATETIME_FULL(){return rt}static get DATETIME_FULL_WITH_SECONDS(){return it}static get DATETIME_HUGE(){return at}static get DATETIME_HUGE_WITH_SECONDS(){return ot}};function ma(e){if(Q.isDateTime(e))return e;if(e&&e.valueOf&&N(e.valueOf()))return Q.fromJSDate(e);if(e&&typeof e==`object`)return Q.fromObject(e);throw new y(`Unknown datetime argument: ${e}, of type ${typeof e}`)}const ha=(e,t,n)=>{let r=n[0];if(r===void 0)return!1;let i=ga(e),a=ga(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}},ga=e=>{let t=Q.fromISO(e,{zone:`utc`});return t.isValid?t.toMillis():void 0},_a=(e,t,n)=>{let r=t.toLowerCase();if(e.trim().length===0)return r===`is not one of`;let i=m.coerce(e),a=n.map(e=>m.coerce(e)),o=a[0]??null;switch(r){case`=`:return va(i,o);case`<`:return ya(i,o,m.lt);case`<=`:return ya(i,o,m.lte);case`>`:return ya(i,o,m.gt);case`>=`:return ya(i,o,m.gte);case`is one of`:return a.some(e=>va(i,e));case`is not one of`:return!a.some(e=>va(i,e));default:return!1}},va=(e,t)=>e!==null&&t!==null&&m.eq(e,t),ya=(e,t,n)=>e!==null&&t!==null&&n(e,t),ba=Symbol(`absent`),xa=Symbol(`unknown-attribute`),Sa=e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`,Ca=e=>e===ba||e==null?``:Sa(e)?wa(e):``,wa=e=>typeof e==`string`?e:String(e),Ta=e=>e===ba?void 0:e,Ea=e=>e===xa?`unknown-attribute`:e===ba?`absent`:Sa(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(Sa).map(wa);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}},Oa=e=>e?.context?.kind??`user`;var ka=class{evaluate(e,t){return this.explain(e,t).matched}explain(e,t){let n=this.resolve(e,t),r=Ea(n),i=n===ba||n===xa?void 0:n;return n===xa?{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 je(Ca(t),e.operator,n);case`number`:return Me(Ta(t),e.operator,n);case`datetime`:return ha(Ca(t),e.operator,n);case`semver`:return _a(Ca(t),e.operator,n);case`array`:return Da(Ta(t),e.operator,n)}return!1}resolve(e,t){switch(e.attribute){case`identifier`:return Aa(t?.context?.id);case`name`:return Aa(t?.context?.name);case`kind`:return Oa(t);case`appName`:return Aa(t?.metadata?.appName);case`appVersion`:return Aa(t?.metadata?.appVersion);case`traits`:return e.trait?Aa(Ae(e.trait,t?.context?.traits)):ba;default:return xa}}};const Aa=e=>e??ba;var ja=class{constructor(e){this.conditionEvaluator=e}explain(e,t,n){let r=t?.[e.segmentId];if(r===void 0||!Ma(r))return{matched:!1,segmentFound:!1,matchedGroupIndex:void 0};let i=this.matchingGroupIndex(r,n),a=i!==void 0;return{matched:this.operatorHolds(e,a),segmentFound:!0,matchedGroupIndex:i}}operatorHolds(e,t){switch(e.operator.toLowerCase()){case`in`:return t;case`not in`:return!t;default:return!1}}matchingGroupIndex(e,t){let n=(e.groups??[]).findIndex(e=>(e??[]).every(e=>this.conditionEvaluator.evaluate(e,t)));return n===-1?void 0:n}};const Ma=e=>(e.groups??[]).every(e=>(e??[]).every(e=>e.kind===void 0||e.kind===`attribute`)),Na=({configId:e,contextIdentifier:t,contextKind:n})=>{let r=n===`user`?`${t}-${e}`:`${t}-${e}:${n}`;return Number((0,ee.rapidhash)(r,{seed:15426857351n})%1000n)/10},$={kind:`not-matched`},Pa={served:`matched`,"not-matched":`not-matched`,"rollout-skipped-no-identifier":`rollout-skipped-no-identifier`},Fa=(e,t)=>{if(t===void 0)return;let n=(e.variations??[]).find(e=>e.id===t);return n?{id:t,name:n.name}:void 0},Ia=(e,t)=>({id:e.id,key:e.key,type:e.type,value:t.value,valueId:t.valueId,variation:Fa(e,t.variationId),...t.rolloutShare});var La=class{constructor(e){if(this.logger=e,this.conditionEvaluator=new ka,this.segmentEvaluator=new ja(this.conditionEvaluator),!e||!e.warn||!e.error||!e.info)throw TypeError(`The provided logger is not a valid 'ConfigDirectorLogger'`);this.logger=e}evaluate(e,t,n){return Ia(e,this.explain(e,t,n))}explain(e,t,n){let r=[...e.target?.rules??[]].sort((e,t)=>(e.order??2**53-1)-(t.order??2**53-1)),i=[];for(let a of r){let r=this.explainRule(a,e,t,n);if(i.push(r),r.serving.kind!==`not-matched`)break}let a=[...i.map(e=>e.explanation),...r.slice(i.length).map(e=>({ruleId:e.id,outcome:`not-evaluated`,conditions:[],bucket:void 0}))],o=t=>({value:e.target?.defaultValue,valueId:e.target?.defaultValueId,variationId:e.target?.defaultVariationId,rolloutShare:void 0,reason:t,servedBy:{kind:`default`},rules:a}),s=i[i.length-1]?.serving??$;switch(s.kind){case`served`:return{...s.servedValue,reason:`found-match`,servedBy:{kind:`rule`,ruleId:s.ruleId},rules:a};case`rollout-skipped-no-identifier`:return o(`rollout-skipped-no-identifier`);case`not-matched`:return o(`found-match`)}}explainRule(e,t,n,r){let i={ruleId:e.id,outcome:`not-matched`,conditions:[],bucket:void 0};try{let a=$;return e.type==`percentage`?a=this.explainRollout(e,t,n,i):e.type==`conditional`&&(a=this.explainConditionalRule(e,t,n,r,i)),i.outcome=Pa[a.kind],{explanation:i,serving:a}}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},serving:$}}}explainRollout(e,t,n,r){if(e.percentages==null)return $;let i=n?.context?.id??void 0;if(i===void 0)return{kind:`rollout-skipped-no-identifier`};let a=Na({configId:t.id,contextIdentifier:i,contextKind:Oa(n)}),o=[],s=0,c;for(let t of e.percentages){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,assignedPercentage:a,shares:o,selectedPercentageId:c?.id},c?.value==null?$:{kind:`served`,ruleId:e.id,servedValue:{value:c.value.toString(),valueId:c.valueId,variationId:c.variationId,rolloutShare:{ruleId:e.id,shareId:c.id}}}}explainConditionalRule(e,t,n,r,i){let a=!1;for(let t of e.conditions??[]){if(a){i.conditions.push({conditionId:t.id,outcome:`not-evaluated`});continue}let e=this.explainCondition(t,n,r);i.conditions.push(e),a=e.outcome!==`matched`}return a?$:e.target==`value`?e.value==null?$:{kind:`served`,ruleId:e.id,servedValue:{value:e.value.toString(),valueId:e.valueId,variationId:e.variationId,rolloutShare:void 0}}:e.target==`percentage`?this.explainRollout(e,t,n,i):$}explainCondition(e,t,n){if(e.kind===`segment`){let r=this.segmentEvaluator.explain(e,n,t);return{conditionId:e.id,kind:`segment`,outcome:r.matched?`matched`:`not-matched`,segmentId:e.segmentId,segmentFound:r.segmentFound,matchedGroupIndex:r.matchedGroupIndex}}let r=this.conditionEvaluator.explain(e,t);return{conditionId:e.id,kind:`attribute`,outcome:r.matched?`matched`:`not-matched`,resolvedValue:r.resolvedValue,resolvedType:r.resolvedType}}};const Ra={variation:void 0,ruleId:void 0,shareId:void 0},za=e=>{let t=e.variation;if(t!=null)return t.name?{id:t.id,name:t.name}:{id:t.id}},Ba=e=>({variation:za(e),ruleId:e.ruleId??void 0,shareId:e.shareId??void 0}),Va=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},Ha=e=>e===`number`||e===`bigint`,Ua=new Set([`boolean`,`integer`,`float`]),Wa=(e,t)=>{let n=Ga(e,t);return{...n,...n.usedDefault?Ra:Ba(e)}},Ga=(e,t)=>{let n=e.value,r=Va(t);if(n==null||n===``)return{parsedValue:t,parsedValueId:void 0,requestedType:r,usedDefault:!0,reason:`value-missing`};if(e.type===`json`)return Za(n,t,r,e.valueId);if(typeof t==`string`)return Ua.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=Ka(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(Ha(typeof t)&&e.type===`integer`){let i=qa(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(Ha(typeof t)&&(e.type===`float`||e.type===`enum`||e.type===`string`)){let i=Ja(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`}},Ka=e=>{if(!e)return;let t=e.toLowerCase();if(!(t!=`true`&&t!=`false`))return t===`true`},qa=e=>{let t=Ya(e);return t==null?void 0:Math.trunc(t)},Ja=e=>Ya(e),Ya=e=>{if(!e||!Xa(e))return;let t=Number(e);if(!(isNaN(t)||!isFinite(t)))return t},Xa=e=>{for(let t of e)if(!(t>=`0`&&t<=`9`)&&!`+-.eE`.includes(t))return!1;return!0},Za=(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 Qa(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`}}},Qa=(e,t)=>e===null?!1:$a(e)===$a(t),$a=e=>{if(Array.isArray(e))return`array`;let t=typeof e;return t===`bigint`?`number`:t};var eo=class{decorateMessage(e){return`[ConfigDirector:js-server-sdk] ${e}`}};const to=(e,t)=>new l.o(e??`warn`,t??new eo),no=(e,t)=>new URL(e,t?.toString()),ro=(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.`},io=e=>e>=`a`&&e<=`z`||e>=`0`&&e<=`9`||e===`-`||e===`_`,ao=e=>{if(e.length<1||e.length>64)return!1;for(let t of e)if(!io(t))return!1;return!0},oo=e=>e==null||typeof e==`string`&&ao(e),so=e=>{if(typeof e==`string`)return e;try{return String(e)}catch{return Object.prototype.toString.call(e)}},co=(e,t)=>{let n=``,r=0;for(let i of e){if(r===t)break;n+=i,r+=1}return n},lo=e=>{let t=e?.kind;return oo(t)?{outcome:`admitted`,context:e}:{outcome:`ignored`,kindSample:co(so(t),128)}};var uo=class{constructor(){this.countsByKindSample=new Map,this.countBeyondSampleLimit=0}record(e){return this.startTime??=new Date,this.add(e,1)}absorb(e){for(let t of e)(this.startTime===void 0||t.startTime<this.startTime)&&(this.startTime=t.startTime),this.add(t.event.kindSample,t.count)}add(e,t){if(e!==void 0){let n=this.countsByKindSample.get(e);if(n!==void 0)return this.countsByKindSample.set(e,n+t),`known-kind-sample`;if(this.countsByKindSample.size<20)return this.countsByKindSample.set(e,t),`new-kind-sample`}let n=this.countBeyondSampleLimit===0;return this.countBeyondSampleLimit+=t,n?`first-beyond-sample-limit`:`beyond-sample-limit`}takeSnapshot(){let e=new Date,t=this.startTime??e,n=(n,r)=>({startTime:t,endTime:e,count:n,event:{reason:`invalid-context-kind`,kindSample:r}}),r=Array.from(this.countsByKindSample,([e,t])=>n(t,e)),i=this.countBeyondSampleLimit>0?[...r,n(this.countBeyondSampleLimit)]:r;return this.clear(),i}clear(){this.countsByKindSample.clear(),this.countBeyondSampleLimit=0,this.startTime=void 0}};const fo=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,po=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}},mo=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},ho=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 go=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 mo(e.discreteEvents)&&mo(e.aggregatedEvents)&&ho(e.droppedEvents)}async sendReport(e){try{let t=await se(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}},_o=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}))}},vo=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}};const yo=e=>e>=55296&&e<=56319,bo=e=>e>=56320&&e<=57343,xo=e=>{let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<=127?t+=1:r<=2047?t+=2:yo(r)&&n+1<e.length&&bo(e.charCodeAt(n+1))?(t+=4,n++):t+=3}return t},So=e=>{let t=e?.anonymous?void 0:e?.id;return t===void 0?{}:{contextKind:e?.kind??`user`,contextIdentifier:t}},Co=1024,wo={"name-outside-the-character-limit":`[ConfigDirectorClient] A tracked event was not reported because its name does not have 1 to 150 characters.`,"value-not-a-finite-number":`[ConfigDirectorClient] A tracked event was reported without its value because the value is not a finite number.`,"details-not-reportable":`[ConfigDirectorClient] A tracked event was reported without its details because they are not an object, have more than 20 top-level keys, are larger than ${Co} bytes as JSON, or cannot be written as JSON.`,"batch-already-full":`[ConfigDirectorClient] A tracked event was not reported because 1000 tracked events are already waiting for the next telemetry batch.`},To=(e,t)=>{for(let n of t)e.warn(`${wo[n]} Further tracked events like it are not logged until the next telemetry batch is sent.`)},Eo=e=>e!=null,Do=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Oo=e=>typeof e==`string`&&e.length>=1&&e.length<=300&&Array.from(e).length<=150,ko=e=>Eo(e)?typeof e==`number`&&Number.isFinite(e)?{status:`reportable`,fields:{value:e}}:{status:`left-out`,warning:`value-not-a-finite-number`}:{status:`not-given`},Ao=e=>{if(Do(e))try{let t=JSON.stringify(e);if(typeof t!=`string`||xo(t)>Co)return;let n=JSON.parse(t);return Do(n)&&Object.keys(n).length<=20?n:void 0}catch{return}},jo=e=>{if(!Eo(e))return{status:`not-given`};let t=Ao(e);return t===void 0?{status:`left-out`,warning:`details-not-reportable`}:{status:`reportable`,fields:{details:t}}},Mo=e=>e.status===`reportable`?e.fields:void 0,No=(...e)=>e.flatMap(e=>e.status===`left-out`?[e.warning]:[]),Po=e=>{if(!Oo(e.name))return{outcome:`dropped`,warnings:[`name-outside-the-character-limit`]};let t=ko(e.options?.value),n=jo(e.options?.details);return{outcome:`admitted`,entry:{name:e.name,...So(e.context),...Mo(t),...Mo(n),happenedAt:e.happenedAt.toISOString()},warnings:No(t,n)}};var Fo=class{constructor(){this.entries=[],this.warningsRaisedThisBatch=new Set}add(e){return this.warningsOfKeeping(e).filter(e=>this.isFirstThisBatch(e))}absorb(e){this.entries.push(...e)}takeBatch(){let e=this.entries;return this.clear(),e}clear(){this.entries=[],this.warningsRaisedThisBatch.clear()}warningsOfKeeping(e){switch(e.outcome){case`dropped`:return e.warnings;case`admitted`:return this.entries.length>=1e3?[`batch-already-full`]:(this.entries.push(e.entry),e.warnings)}}isFirstThisBatch(e){return this.warningsRaisedThisBatch.has(e)?!1:(this.warningsRaisedThisBatch.add(e),!0)}},Io=class{constructor(e){this.aggregator=new _o,this.trackedEventQueue=new Fo,this.collectEvents=!0,this.started=!1,this.logger=e.logger,this.evaluationEventQueue=new vo(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))}trackedEvent(e){this.collectEvents&&To(this.logger,this.trackedEventQueue.add(e))}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(),this.trackedEventQueue.clear()}dispose(){this.close()}},Lo=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)}}},Ro=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 fo(e.defaultValue,this.valueIdGenerator),evaluatedValue:await fo(e.evaluatedValue,this.valueIdGenerator)})));return{...e,events:t}}},zo=class extends Io{constructor(e){super(e),this.invalidContextSubmissions=new uo,this.reporter=new go(e),this.contexts=new Lo(e.contextLimit??1e3),this.evaluationEventSnapshotPreprocessor=new Ro(e.valueIdGenerator)}evaluatedConfig(e){if(!this.collectEvents)return;let t=e.context??void 0,{contextKind:n,contextIdentifier:r}=So(t);r&&this.contexts.set(`${n}:${r}`,{...t,kind:n});let i={...e.evaluation,contextId:r,contextKind:n};this.evaluationEventQueue.push(this.sanitizeEvaluatedConfigEvent(i))}recordInvalidContext(e){return this.invalidContextSubmissions.record(e)}sanitizeEvaluatedConfigEvent(e){return{...e,defaultValue:po({value:e.defaultValue,type:e.type}),evaluatedValue:po({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,trackedEvents:this.trackedEventQueue.takeBatch()},aggregatedEvents:{evaluatedConfig:this.aggregator.aggregate(e),invalidContext:this.invalidContextSubmissions.takeSnapshot()},droppedEvents:{evaluatedConfig:e.droppedCount,capturedContexts:t.droppedCount}})}};const Bo={start:()=>{},evaluatedConfig:()=>{},recordInvalidContext:()=>`new-kind-sample`,trackedEvent:()=>{},close:async()=>{}},Vo=(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`)},Ho=Math.ceil(128/Math.log2(62)),Uo=async e=>Vo((0,d.createHash)(`sha256`).update(e?.toString()??``).digest().subarray(0,16),Ho);var Wo=o({DefaultConfigDirectorClient:()=>Jo});const Go={streaming:`The client will continue to retry since there were no fatal errors detected. Configs will return the default value until the connection succeeds.`,polling:`Since the client was configured without streaming, configs may not update and always return the default value.`},Ko={"new-kind-sample":(e,t)=>e.error(`[ConfigDirectorClient] Ignored a context with the invalid kind '${t}' and evaluated as if no context was supplied. A context kind has 1 to 64 characters, using only lowercase letters, digits, '-' and '_'.`),"known-kind-sample":()=>{},"first-beyond-sample-limit":e=>e.error(`[ConfigDirectorClient] Ignored a context with another invalid kind and evaluated as if no context was supplied. 20 different invalid kinds were logged recently, so further invalid kinds are not logged individually.`),"beyond-sample-limit":()=>{}},qo=(e,t)=>(e.target?.rules??[]).some(e=>e.type===`conditional`&&(e.conditions??[]).some(e=>e.kind===`segment`&&t.has(e.segmentId)));var Jo=class e{static from(t,n,r){return typeof t==`object`?new e(void 0,n,t):new e(t,n,r)}constructor(e,t,n,r){this.handlersMap=new Map,this.eventEmitter=new u.default,this.ready=!1,this.logger=n?.logger??to(),this.timeout=n?.connection?.timeout??3e3,this.metaContext=n?.metadata??{},this.connectionPlan=Se(e,n?.connection),this.configEvaluator=new La(this.logger),this.usageEventCollector=r?.telemetry??this.buildTelemetryClient(t,n),this.transport=r?.transport??this.buildTransport(t,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},this.configSet.segments={...this.configSet.segments,...e.segments});let n=this.findKeysUpdatedBy(e);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;n>0&&(await Promise.race([this.readyPromise,new Promise(e=>{this.readyTimer=setTimeout(()=>e(),n)})]),this.clearReadyTimer()),this.ready||this.logger.warn(`[ConfigDirectorClient] Timed out waiting for initialization after ${this.timeout}ms. ${this.timeoutWarningDetails()}`)}catch(e){if(e instanceof l.i)throw e;this.logger.error(`[ConfigDirectorClient] An error occurred during initialization: `,e)}}timeoutWarningDetails(){switch(this.connectionPlan.kind){case`connect`:return Go[this.connectionPlan.mode];case`stay-offline`:return`The offline values were not delivered, so configs return the default value.`}}pollingIntervalFor(e,t){if(e!==`polling`)return;let n=ro(t,{defaultSeconds:300,minimumSeconds:60});return n.warning&&this.logger.warn(`[ConfigDirectorClient] ${n.warning}`),n.seconds}buildTelemetryClient(e,t){let n=this.connectionPlan;switch(n.kind){case`stay-offline`:return Bo;case`connect`:{let r=t?.telemetry?.eventQueueLimit??5e3;return new zo({sdkKey:n.serverSdkKey,sdkIdentity:e,metaContext:t?.metadata??{},logger:this.logger,baseUrl:n.baseUrl,flushIntervalDelay:t?.telemetry?.flushInterval??3e4,evaluationQueueLimit:Math.ceil(r*.7),contextLimit:Math.floor(r*.3),urlFactory:no,valueIdGenerator:Uo})}}}buildTransport(e,t){let n=this.connectionPlan;switch(n.kind){case`stay-offline`:return new me(n.source);case`connect`:return new(this.getTransportConstructor(n.mode))({serverSdkKey:n.serverSdkKey,baseUrl:n.baseUrl,metaContext:{...t?.metadata,sdkName:e.sdkName,sdkVersion:e.sdkVersion},logger:this.logger,pollingInterval:this.pollingIntervalFor(n.mode,t?.connection?.pollingInterval)})}}getTransportConstructor(e){switch(e){case`polling`:return de;case`streaming`:return le}}findKeysRemovedBy(e){return!this.configSet||e.kind!=`full`?[]:Object.keys(this.configSet.configs).filter(t=>!Object.prototype.hasOwnProperty.call(e.configs,t))}findKeysUpdatedBy(e){let t=new Set(Object.keys(e.segments??{})),n=Object.entries(this.configSet?.configs??{}).filter(([,e])=>qo(e,t)).map(([e])=>e);return[...new Set([...Object.keys(e.configs),...n])]}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.evaluationOf(e,t,n.defaultValue,n.context).value;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){return this.evaluate(e,t,n).value}evaluate(e,t,n){this.validateDefaultValue(t);let r=this.configSet?.configs[e];return this.evaluationOf(e,r,t,n)}evaluationOf(e,t,n,r){let i=this.contextToEvaluate(r);if(t){let r=this.configEvaluator.explain(t,{context:i,metadata:this.metaContext},this.configSet?.segments),a=Ia(t,r),o=Wa(a,n),s=o.usedDefault?o.reason:r.reason;this.usageEventCollector.evaluatedConfig({context:i,evaluation:{key:e,type:a.type,defaultValue:n,requestedType:o.requestedType,evaluatedValue:o.parsedValue,evaluatedValueId:o.parsedValueId,usedDefault:o.usedDefault,evaluationReason:s,ruleId:o.ruleId,shareId:o.shareId,variationId:o.variation?.id}});let c={key:e,value:o.parsedValue,valueId:o.parsedValueId??void 0,variation:o.variation,isDefaultValue:o.usedDefault,reason:s,context:i};return this.dispatchEvaluationEvent(c),this.logger.debug(`[ConfigDirectorClient] Evaluated '${e}' to '${o.parsedValue}'`),c}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`;this.usageEventCollector.evaluatedConfig({context:i,evaluation:{key:e,defaultValue:n,requestedType:Va(n),evaluatedValue:n,usedDefault:!0,evaluationReason:t}});let r={key:e,value:n,isDefaultValue:!0,reason:t,context:i};return this.dispatchEvaluationEvent(r),r}}track(e,t,n){switch(this.connectionPlan.kind){case`stay-offline`:return;case`connect`:try{let r=this.contextToEvaluate(t);this.usageEventCollector.trackedEvent(Po({name:e,context:r,options:n,happenedAt:new Date}),r)}catch(e){this.logger.warn(`[ConfigDirectorClient] A tracked event was not reported because it could not be read: `,e)}return}}contextToEvaluate(e){let t=lo(e);switch(t.outcome){case`admitted`:return t.context;case`ignored`:Ko[this.usageEventCollector.recordInvalidContext(t.kindSample)](this.logger,t.kindSample);return}}dispatchEvaluationEvent(e){setTimeout(()=>this.eventEmitter.emit(`configEvaluated`,{evaluation:e}),0)}validateDefaultValue(e){if(e==null)throw new l.a(`Invalid default value. The default value for a config must be defined and non-null.`);if(typeof e==`function`)throw new l.a(`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){let t=this.contextToEvaluate(e?.context);if(!this.configSet)return{};let n=Object.entries(this.configSet.configs),r=e?.configKeys?n.filter(([t])=>e.configKeys?.includes(t)):n;return Object.fromEntries(r.map(([e,n])=>[e,this.configEvaluator.evaluate(n,{context:t,metadata:this.metaContext},this.configSet?.segments)]))}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,`a`,{enumerable:!0,get:function(){return to}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return wo}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Wo}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Bo}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Jo}});
|
|
@@ -11,6 +11,12 @@ type ConfigState = {
|
|
|
11
11
|
type: ConfigType;
|
|
12
12
|
value: string | undefined | null;
|
|
13
13
|
valueId?: string | undefined | null;
|
|
14
|
+
variation?: {
|
|
15
|
+
id: string;
|
|
16
|
+
name?: string | undefined | null;
|
|
17
|
+
} | undefined | null;
|
|
18
|
+
ruleId?: string | undefined | null;
|
|
19
|
+
shareId?: string | undefined | null;
|
|
14
20
|
};
|
|
15
21
|
type ConfigDirectorLoggingLevel = "debug" | "info" | "warn" | "error" | "off";
|
|
16
22
|
interface ConfigDirectorLogger {
|
|
@@ -24,24 +30,72 @@ interface ConfigDirectorLogMessageDecorator {
|
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
32
|
* Why an evaluation returned the value it did. `found-match` returns a value from ConfigDirector,
|
|
27
|
-
* and `cached` a value kept on the device while a client SDK waits for live values.
|
|
33
|
+
* and `cached` a value kept on the device while a client SDK waits for live values.
|
|
34
|
+
* `rollout-skipped-no-identifier` returns the default targeting rule value: a server SDK skipped a
|
|
35
|
+
* percentage rollout because the context has no `id` to place it in a share. `value-missing`
|
|
28
36
|
* returns the in-code default value because the config has no value. Every other reason returns the
|
|
29
37
|
* in-code default value because of an error: the config does not exist (`config-state-missing`), no
|
|
30
38
|
* values have arrived yet (`client-not-ready`), or the value cannot be read as the type of the in-code
|
|
31
39
|
* default value.
|
|
32
40
|
*/
|
|
33
|
-
type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
|
|
41
|
+
type EvaluationReason = "found-match" | "rollout-skipped-no-identifier" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
|
|
42
|
+
/**
|
|
43
|
+
* One of the values a config can serve, such as the control or a treatment of an experiment.
|
|
44
|
+
*/
|
|
45
|
+
type Variation = {
|
|
46
|
+
/** The ID ConfigDirector assigned to the variation, which stays the same when it is renamed. */id: string; /** The variation's name, when it has one. */
|
|
47
|
+
name?: string;
|
|
48
|
+
};
|
|
34
49
|
/**
|
|
35
50
|
* One evaluation of a config: the value it returned, why, and the context it was evaluated for.
|
|
36
51
|
*/
|
|
37
52
|
type ConfigEvaluation<T extends ConfigValueType = ConfigValueType> = {
|
|
38
53
|
/** The config key that was evaluated. */key: string; /** The value returned, which is the in-code default value when {@link isDefaultValue} is `true`. */
|
|
39
54
|
value: T; /** The ID ConfigDirector assigned to the value returned, when ConfigDirector sent one with it. */
|
|
40
|
-
valueId?: string;
|
|
55
|
+
valueId?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The variation that was served. It is `undefined` when the config has no variations or the
|
|
58
|
+
* in-code default value is returned.
|
|
59
|
+
*/
|
|
60
|
+
variation?: Variation; /** Whether the evaluation returned the in-code default value. */
|
|
41
61
|
isDefaultValue: boolean; /** Why the evaluation returned this value. */
|
|
42
62
|
reason: EvaluationReason; /** The context the config was evaluated for, if any. */
|
|
43
63
|
context?: ConfigDirectorContext;
|
|
44
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* A value in the details of a tracked event: a string, a number, a boolean, or an array or object
|
|
67
|
+
* of such values.
|
|
68
|
+
*/
|
|
69
|
+
type TrackedEventDetailValue = string | number | boolean | TrackedEventDetailValue[] | {
|
|
70
|
+
[key: string]: TrackedEventDetailValue;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Details of a tracked event, such as the plan a customer chose. Details with more than 20
|
|
74
|
+
* top-level keys, or larger than 1 KB as JSON, are left out and the event is still reported.
|
|
75
|
+
*/
|
|
76
|
+
type TrackedEventDetails = {
|
|
77
|
+
[key: string]: TrackedEventDetailValue;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* What a tracked event carries besides its name.
|
|
81
|
+
*/
|
|
82
|
+
type TrackOptions = {
|
|
83
|
+
/**
|
|
84
|
+
* A number the event measures, such as an amount of money, a count or a duration. A value that
|
|
85
|
+
* is not a finite number is left out and the event is still reported.
|
|
86
|
+
*/
|
|
87
|
+
value?: number; /** Details of the event. */
|
|
88
|
+
details?: TrackedEventDetails;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* An event the code under test tracked, as a test client recorded it.
|
|
92
|
+
*/
|
|
93
|
+
type TrackedEvent = {
|
|
94
|
+
/** The name the event was tracked with. */name: string; /** The context the event was tracked for, if any. */
|
|
95
|
+
context?: ConfigDirectorContext; /** The value the event was tracked with, when it is a finite number. */
|
|
96
|
+
value?: number; /** The details the event was tracked with, when they are within the limits. */
|
|
97
|
+
details?: TrackedEventDetails;
|
|
98
|
+
};
|
|
45
99
|
/**
|
|
46
100
|
* The context to be sent to ConfigDirector: the user or other entity, such as a device or an
|
|
47
101
|
* organization, that configs are evaluated for. This context will be used for targeting rules
|
|
@@ -323,8 +377,8 @@ interface ConfigDirectorClient {
|
|
|
323
377
|
getValue<T extends ConfigValueType>(configKey: string, defaultValue: T, context?: ConfigDirectorContext): T;
|
|
324
378
|
/**
|
|
325
379
|
* Evaluates a config as {@link getValue} does and returns the evaluation: the value, the reason it
|
|
326
|
-
* was served
|
|
327
|
-
* telemetry.
|
|
380
|
+
* was served, its value ID and its variation. Like every read, it fires `configEvaluated` and is
|
|
381
|
+
* counted in telemetry.
|
|
328
382
|
*
|
|
329
383
|
* @returns The evaluation, whose `value` is what {@link getValue} returns
|
|
330
384
|
* @param configKey The config key to evaluate
|
|
@@ -369,6 +423,21 @@ interface ConfigDirectorClient {
|
|
|
369
423
|
context?: ConfigDirectorContext;
|
|
370
424
|
configKeys?: string[];
|
|
371
425
|
}): Record<string, ConfigState>;
|
|
426
|
+
/**
|
|
427
|
+
* Reports to ConfigDirector that something happened, such as a completed checkout, so it can be
|
|
428
|
+
* counted. The event is sent with the next telemetry batch. `track` never throws, and does nothing
|
|
429
|
+
* in `offline` mode.
|
|
430
|
+
*
|
|
431
|
+
* An event counts for an experiment only when it is tracked for a context with an `id`, the one
|
|
432
|
+
* the experiment's config was evaluated for. Without a context, or for a context without an
|
|
433
|
+
* `id`, the event is still reported.
|
|
434
|
+
*
|
|
435
|
+
* @param eventName The name of the event, 1 to 150 characters. An event with any other name is
|
|
436
|
+
* not reported and a warning is logged.
|
|
437
|
+
* @param context The context the event happened for (optional)
|
|
438
|
+
* @param options The event's {@link TrackOptions.value} and {@link TrackOptions.details} (optional)
|
|
439
|
+
*/
|
|
440
|
+
track(eventName: string, context?: ConfigDirectorContext, options?: TrackOptions): void;
|
|
372
441
|
on<T extends keyof ClientEvents>(eventName: T, handler: (args: ClientEvents[T]) => void): void;
|
|
373
442
|
off<T extends keyof ClientEvents>(eventName: T, handler?: (args: ClientEvents[T]) => void): void;
|
|
374
443
|
/**
|
|
@@ -395,5 +464,5 @@ declare class ConfigDirectorInitializationError extends Error {
|
|
|
395
464
|
constructor(message: string);
|
|
396
465
|
}
|
|
397
466
|
//#endregion
|
|
398
|
-
export { ConfigEvaluation as _, ConfigDirectorClientOptions as a, ConnectionMode as b, OfflineValues as c, NativeValues as d, ConfigDirectorContext as f, ConfigDirectorMetaContext as g, ConfigDirectorLoggingLevel as h, ConfigDirectorClient as i, NativeJsonValue as l, ConfigDirectorLogger as m, ConfigDirectorInitializationError as n, OfflineClientOptions as o, ConfigDirectorLogMessageDecorator as p, ConfigDirectorValidationError as r, OfflineValue as s, ConfigDirectorConnectionError as t, NativeValue as u, ConfigState as v, EvaluationReason as x, ConfigValueType as y };
|
|
399
|
-
//# sourceMappingURL=errors-
|
|
467
|
+
export { TrackedEvent as C, Variation as E, TrackOptions as S, TrackedEventDetails as T, ConfigEvaluation as _, ConfigDirectorClientOptions as a, ConnectionMode as b, OfflineValues as c, NativeValues as d, ConfigDirectorContext as f, ConfigDirectorMetaContext as g, ConfigDirectorLoggingLevel as h, ConfigDirectorClient as i, NativeJsonValue as l, ConfigDirectorLogger as m, ConfigDirectorInitializationError as n, OfflineClientOptions as o, ConfigDirectorLogMessageDecorator as p, ConfigDirectorValidationError as r, OfflineValue as s, ConfigDirectorConnectionError as t, NativeValue as u, ConfigState as v, TrackedEventDetailValue as w, EvaluationReason as x, ConfigValueType as y };
|
|
468
|
+
//# sourceMappingURL=errors-CkxBFyZy.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-CkxBFyZy.d.cts","names":[],"sources":["../../../shared/src/types.ts","../../../shared/src/native-values.ts","../../../js-server-sdk/src/types.ts","../../../shared/src/errors.ts"],"mappings":"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"}
|
|
@@ -11,6 +11,12 @@ type ConfigState = {
|
|
|
11
11
|
type: ConfigType;
|
|
12
12
|
value: string | undefined | null;
|
|
13
13
|
valueId?: string | undefined | null;
|
|
14
|
+
variation?: {
|
|
15
|
+
id: string;
|
|
16
|
+
name?: string | undefined | null;
|
|
17
|
+
} | undefined | null;
|
|
18
|
+
ruleId?: string | undefined | null;
|
|
19
|
+
shareId?: string | undefined | null;
|
|
14
20
|
};
|
|
15
21
|
type ConfigDirectorLoggingLevel = "debug" | "info" | "warn" | "error" | "off";
|
|
16
22
|
interface ConfigDirectorLogger {
|
|
@@ -24,24 +30,72 @@ interface ConfigDirectorLogMessageDecorator {
|
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
32
|
* Why an evaluation returned the value it did. `found-match` returns a value from ConfigDirector,
|
|
27
|
-
* and `cached` a value kept on the device while a client SDK waits for live values.
|
|
33
|
+
* and `cached` a value kept on the device while a client SDK waits for live values.
|
|
34
|
+
* `rollout-skipped-no-identifier` returns the default targeting rule value: a server SDK skipped a
|
|
35
|
+
* percentage rollout because the context has no `id` to place it in a share. `value-missing`
|
|
28
36
|
* returns the in-code default value because the config has no value. Every other reason returns the
|
|
29
37
|
* in-code default value because of an error: the config does not exist (`config-state-missing`), no
|
|
30
38
|
* values have arrived yet (`client-not-ready`), or the value cannot be read as the type of the in-code
|
|
31
39
|
* default value.
|
|
32
40
|
*/
|
|
33
|
-
type EvaluationReason = "found-match" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
|
|
41
|
+
type EvaluationReason = "found-match" | "rollout-skipped-no-identifier" | "config-state-missing" | "client-not-ready" | "type-mismatch" | "value-missing" | "invalid-number" | "invalid-json" | "invalid-boolean" | "cached";
|
|
42
|
+
/**
|
|
43
|
+
* One of the values a config can serve, such as the control or a treatment of an experiment.
|
|
44
|
+
*/
|
|
45
|
+
type Variation = {
|
|
46
|
+
/** The ID ConfigDirector assigned to the variation, which stays the same when it is renamed. */id: string; /** The variation's name, when it has one. */
|
|
47
|
+
name?: string;
|
|
48
|
+
};
|
|
34
49
|
/**
|
|
35
50
|
* One evaluation of a config: the value it returned, why, and the context it was evaluated for.
|
|
36
51
|
*/
|
|
37
52
|
type ConfigEvaluation<T extends ConfigValueType = ConfigValueType> = {
|
|
38
53
|
/** The config key that was evaluated. */key: string; /** The value returned, which is the in-code default value when {@link isDefaultValue} is `true`. */
|
|
39
54
|
value: T; /** The ID ConfigDirector assigned to the value returned, when ConfigDirector sent one with it. */
|
|
40
|
-
valueId?: string;
|
|
55
|
+
valueId?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The variation that was served. It is `undefined` when the config has no variations or the
|
|
58
|
+
* in-code default value is returned.
|
|
59
|
+
*/
|
|
60
|
+
variation?: Variation; /** Whether the evaluation returned the in-code default value. */
|
|
41
61
|
isDefaultValue: boolean; /** Why the evaluation returned this value. */
|
|
42
62
|
reason: EvaluationReason; /** The context the config was evaluated for, if any. */
|
|
43
63
|
context?: ConfigDirectorContext;
|
|
44
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* A value in the details of a tracked event: a string, a number, a boolean, or an array or object
|
|
67
|
+
* of such values.
|
|
68
|
+
*/
|
|
69
|
+
type TrackedEventDetailValue = string | number | boolean | TrackedEventDetailValue[] | {
|
|
70
|
+
[key: string]: TrackedEventDetailValue;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Details of a tracked event, such as the plan a customer chose. Details with more than 20
|
|
74
|
+
* top-level keys, or larger than 1 KB as JSON, are left out and the event is still reported.
|
|
75
|
+
*/
|
|
76
|
+
type TrackedEventDetails = {
|
|
77
|
+
[key: string]: TrackedEventDetailValue;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* What a tracked event carries besides its name.
|
|
81
|
+
*/
|
|
82
|
+
type TrackOptions = {
|
|
83
|
+
/**
|
|
84
|
+
* A number the event measures, such as an amount of money, a count or a duration. A value that
|
|
85
|
+
* is not a finite number is left out and the event is still reported.
|
|
86
|
+
*/
|
|
87
|
+
value?: number; /** Details of the event. */
|
|
88
|
+
details?: TrackedEventDetails;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* An event the code under test tracked, as a test client recorded it.
|
|
92
|
+
*/
|
|
93
|
+
type TrackedEvent = {
|
|
94
|
+
/** The name the event was tracked with. */name: string; /** The context the event was tracked for, if any. */
|
|
95
|
+
context?: ConfigDirectorContext; /** The value the event was tracked with, when it is a finite number. */
|
|
96
|
+
value?: number; /** The details the event was tracked with, when they are within the limits. */
|
|
97
|
+
details?: TrackedEventDetails;
|
|
98
|
+
};
|
|
45
99
|
/**
|
|
46
100
|
* The context to be sent to ConfigDirector: the user or other entity, such as a device or an
|
|
47
101
|
* organization, that configs are evaluated for. This context will be used for targeting rules
|
|
@@ -323,8 +377,8 @@ interface ConfigDirectorClient {
|
|
|
323
377
|
getValue<T extends ConfigValueType>(configKey: string, defaultValue: T, context?: ConfigDirectorContext): T;
|
|
324
378
|
/**
|
|
325
379
|
* Evaluates a config as {@link getValue} does and returns the evaluation: the value, the reason it
|
|
326
|
-
* was served
|
|
327
|
-
* telemetry.
|
|
380
|
+
* was served, its value ID and its variation. Like every read, it fires `configEvaluated` and is
|
|
381
|
+
* counted in telemetry.
|
|
328
382
|
*
|
|
329
383
|
* @returns The evaluation, whose `value` is what {@link getValue} returns
|
|
330
384
|
* @param configKey The config key to evaluate
|
|
@@ -369,6 +423,21 @@ interface ConfigDirectorClient {
|
|
|
369
423
|
context?: ConfigDirectorContext;
|
|
370
424
|
configKeys?: string[];
|
|
371
425
|
}): Record<string, ConfigState>;
|
|
426
|
+
/**
|
|
427
|
+
* Reports to ConfigDirector that something happened, such as a completed checkout, so it can be
|
|
428
|
+
* counted. The event is sent with the next telemetry batch. `track` never throws, and does nothing
|
|
429
|
+
* in `offline` mode.
|
|
430
|
+
*
|
|
431
|
+
* An event counts for an experiment only when it is tracked for a context with an `id`, the one
|
|
432
|
+
* the experiment's config was evaluated for. Without a context, or for a context without an
|
|
433
|
+
* `id`, the event is still reported.
|
|
434
|
+
*
|
|
435
|
+
* @param eventName The name of the event, 1 to 150 characters. An event with any other name is
|
|
436
|
+
* not reported and a warning is logged.
|
|
437
|
+
* @param context The context the event happened for (optional)
|
|
438
|
+
* @param options The event's {@link TrackOptions.value} and {@link TrackOptions.details} (optional)
|
|
439
|
+
*/
|
|
440
|
+
track(eventName: string, context?: ConfigDirectorContext, options?: TrackOptions): void;
|
|
372
441
|
on<T extends keyof ClientEvents>(eventName: T, handler: (args: ClientEvents[T]) => void): void;
|
|
373
442
|
off<T extends keyof ClientEvents>(eventName: T, handler?: (args: ClientEvents[T]) => void): void;
|
|
374
443
|
/**
|
|
@@ -395,5 +464,5 @@ declare class ConfigDirectorInitializationError extends Error {
|
|
|
395
464
|
constructor(message: string);
|
|
396
465
|
}
|
|
397
466
|
//#endregion
|
|
398
|
-
export { ConfigEvaluation as _, ConfigDirectorClientOptions as a, ConnectionMode as b, OfflineValues as c, NativeValues as d, ConfigDirectorContext as f, ConfigDirectorMetaContext as g, ConfigDirectorLoggingLevel as h, ConfigDirectorClient as i, NativeJsonValue as l, ConfigDirectorLogger as m, ConfigDirectorInitializationError as n, OfflineClientOptions as o, ConfigDirectorLogMessageDecorator as p, ConfigDirectorValidationError as r, OfflineValue as s, ConfigDirectorConnectionError as t, NativeValue as u, ConfigState as v, EvaluationReason as x, ConfigValueType as y };
|
|
399
|
-
//# sourceMappingURL=errors-
|
|
467
|
+
export { TrackedEvent as C, Variation as E, TrackOptions as S, TrackedEventDetails as T, ConfigEvaluation as _, ConfigDirectorClientOptions as a, ConnectionMode as b, OfflineValues as c, NativeValues as d, ConfigDirectorContext as f, ConfigDirectorMetaContext as g, ConfigDirectorLoggingLevel as h, ConfigDirectorClient as i, NativeJsonValue as l, ConfigDirectorLogger as m, ConfigDirectorInitializationError as n, OfflineClientOptions as o, ConfigDirectorLogMessageDecorator as p, ConfigDirectorValidationError as r, OfflineValue as s, ConfigDirectorConnectionError as t, NativeValue as u, ConfigState as v, TrackedEventDetailValue as w, EvaluationReason as x, ConfigValueType as y };
|
|
468
|
+
//# sourceMappingURL=errors-CsEeGYMl.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-CsEeGYMl.d.mts","names":[],"sources":["../../../shared/src/types.ts","../../../shared/src/native-values.ts","../../../js-server-sdk/src/types.ts","../../../shared/src/errors.ts"],"mappings":"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"}
|
package/dist/server/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./DefaultConfigDirectorClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./DefaultConfigDirectorClient-VHa0AfMj.cjs`);const e=require(`./native-values-UCK4hh1Z.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.o(t??`warn`,n??new r),a=(t,n)=>new e.o(t,n??new r);async function o(t){if(process.env.NEXT_RUNTIME===`nodejs`){let n=t.connection?.mode??`streaming`;if(n!==`offline`&&!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.i(t)}if(!globalThis.__configDirectorServerClient){let{DefaultConfigDirectorClient:e}=await Promise.resolve().then(()=>require(`./DefaultConfigDirectorClient-VHa0AfMj.cjs`)).then(e=>e.n),{serverSdkKey:r,...i}=t;globalThis.__configDirectorAppMeta={appName:t.metadata?.appName,appVersion:t.metadata?.appVersion},globalThis.__configDirectorServerConnectionMode=n;let a=new e(r,{sdkName:`nextjs-sdk`,sdkVersion:`1.14.0`},i);globalThis.__configDirectorServerClient=a;try{await a.initialize()}catch(e){throw globalThis.__configDirectorServerClient=void 0,globalThis.__configDirectorServerConnectionMode=void 0,globalThis.__configDirectorAppMeta=void 0,a.dispose(),e}}}}function s(){return globalThis.__configDirectorAppMeta??{}}function c(){return globalThis.__configDirectorServerConnectionMode}function l(){if(!globalThis.__configDirectorServerClient)throw new e.i(`[ConfigDirector] Server client not initialized. Make sure to call register() in your instrumentation.ts file before using the SDK.`);return globalThis.__configDirectorServerClient}const u=i();function d(e){try{return l().getAllConfigs(e)}catch(e){return u.error(`Error retrieving SSR config set:`,e),{}}}const f=(e,t)=>e.mode!==void 0||e.values!==void 0?`as-given`:t===`offline`?`inherit-offline`:`connect`,p=e=>typeof e.value==`string`,m=t=>Object.fromEntries(Object.values(t).filter(p).map(t=>[t.key,e.t(t.type,t.value)]));async function h({children:e,configKeys:r,...i}){let a=d({context:i.context,configKeys:r}),o=s();return(0,n.jsx)(t.ConfigDirectorProvider,{...i,...g(a,i),appName:i.appName??o.appName,appVersion:i.appVersion??o.appVersion,initialConfigs:a,children:e})}const g=(e,t)=>{switch(f(t,c())){case`as-given`:return{};case`inherit-offline`:return{mode:`offline`,values:m(e)};case`connect`:return{}}};exports.ConfigDirectorInitializationError=e.i,exports.ConfigDirectorProvider=h,exports.createConsoleLogger=a,exports.generateSsrConfigSet=d,exports.getAppMeta=s,exports.getConfigClient=l,exports.register=o;
|
package/dist/server/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as ConfigEvaluation, a as ConfigDirectorClientOptions, b as ConnectionMode, c as OfflineValues, d as NativeValues, f as ConfigDirectorContext, g as ConfigDirectorMetaContext, h as ConfigDirectorLoggingLevel, i as ConfigDirectorClient, m as ConfigDirectorLogger, n as ConfigDirectorInitializationError, o as OfflineClientOptions, p as ConfigDirectorLogMessageDecorator, s as OfflineValue, v as ConfigState, x as EvaluationReason, y as ConfigValueType } from "./errors-
|
|
1
|
+
import { E as Variation, S as TrackOptions, T as TrackedEventDetails, _ as ConfigEvaluation, a as ConfigDirectorClientOptions, b as ConnectionMode, c as OfflineValues, d as NativeValues, f as ConfigDirectorContext, g as ConfigDirectorMetaContext, h as ConfigDirectorLoggingLevel, i as ConfigDirectorClient, m as ConfigDirectorLogger, n as ConfigDirectorInitializationError, o as OfflineClientOptions, p as ConfigDirectorLogMessageDecorator, s as OfflineValue, v as ConfigState, w as TrackedEventDetailValue, x as EvaluationReason, y as ConfigValueType } from "./errors-CkxBFyZy.cjs";
|
|
2
2
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
import { PropsWithChildren } from "react";
|
|
4
4
|
|
|
@@ -273,5 +273,5 @@ declare function ConfigDirectorProvider({
|
|
|
273
273
|
//#region src/server/logger.d.ts
|
|
274
274
|
declare const createConsoleLogger: (level: ConfigDirectorLoggingLevel, messageDecorator?: ConfigDirectorLogMessageDecorator) => DefaultConsoleLogger;
|
|
275
275
|
//#endregion
|
|
276
|
-
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, ConfigDirectorInitializationError, type ConfigDirectorLogger, type ConfigDirectorMetaContext, ConfigDirectorProvider, type ConfigDirectorProviderProps, type ConfigEvaluation, type ConfigValueType, type ConnectionMode, type EvaluationReason, type GenerateSsrConfigSetOptions, type OfflineClientOptions, type OfflineValue, type OfflineValues, type RegisterOptions, createConsoleLogger, generateSsrConfigSet, getAppMeta, getConfigClient, register };
|
|
276
|
+
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, ConfigDirectorInitializationError, type ConfigDirectorLogger, type ConfigDirectorMetaContext, ConfigDirectorProvider, type ConfigDirectorProviderProps, type ConfigEvaluation, type ConfigValueType, type ConnectionMode, type EvaluationReason, type GenerateSsrConfigSetOptions, type OfflineClientOptions, type OfflineValue, type OfflineValues, type RegisterOptions, type TrackOptions, type TrackedEventDetailValue, type TrackedEventDetails, type Variation, createConsoleLogger, generateSsrConfigSet, getAppMeta, getConfigClient, register };
|
|
277
277
|
//# sourceMappingURL=index.d.cts.map
|