@dbml/core 6.5.0 → 6.6.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/lib/index.cjs CHANGED
@@ -8,7 +8,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
8
8
  `:return``;case`t`:return` `;case`n`:return`
9
9
  `;case`\\`:return`\\`;case`r`:return`\r`;case`'`:return`'`;case`"`:return`"`;case"`":return"`";case`0`:return`\0`;case`b`:return`\b`;case`v`:return`\v`;case`f`:return`\f`;case` `:return`\\ `;case`u`:{let t=``;for(let n=0;n<=3;n+=1){if(this.isAtEnd()||!om(this.peek()))return this.errors.push(new P(N.INVALID_ESCAPE_SEQUENCE,`Invalid unicode escape sequence '\\u${t}', only unicode escape sequences of the form '\\uHHHH' where H is a hexadecimal number are allowed`,Ep.create(Tp.STRING_LITERAL,e,this.current,`\\u${t}`,!0))),`\\u${t}`;t+=this.advance()}return String.fromCharCode(parseInt(t,16))}default:return this.text[this.current.offset-1]}}},ah=function(e){return e[e.ListExpression=0]=`ListExpression`,e[e.GroupExpression=1]=`GroupExpression`,e[e.BlockExpression=2]=`BlockExpression`,e}({}),hse=class{constructor(){this.stack=[],this.numberOfNestedLParens=0,this.numberOfNestedLBrackets=0,this.numberOfNestedLBraces=0}push(e){this.stack.push(e),e===ah.ListExpression&&(this.numberOfNestedLBrackets+=1),e===ah.GroupExpression&&(this.numberOfNestedLParens+=1),e===ah.BlockExpression&&(this.numberOfNestedLBraces+=1)}pop(){let e=this.stack.pop();return e===ah.ListExpression&&--this.numberOfNestedLBrackets,e===ah.GroupExpression&&--this.numberOfNestedLParens,e===ah.BlockExpression&&--this.numberOfNestedLBraces,e}top(){return bp(this.stack)}isWithinGroupExpressionContext(){return this.numberOfNestedLParens>0}isWithinListExpressionContext(){return this.numberOfNestedLBrackets>0}isWithinBlockExpressionContext(){return this.numberOfNestedLBraces>0}withContextDo(e,t){return()=>{this.push(e);try{return t()}finally{this.pop()}}}findHandlerContext(e,t){if(!(this.numberOfNestedLBraces<=0&&this.numberOfNestedLBrackets<=0&&this.numberOfNestedLParens<=0))for(let n=t;n<e.length-1;n+=1)switch(e[n].kind){case Tp.COMMA:if(this.isWithinGroupExpressionContext()||this.isWithinListExpressionContext())return[...this.stack].reverse().find(e=>[ah.GroupExpression,ah.ListExpression].includes(e));break;case Tp.RPAREN:if(this.isWithinGroupExpressionContext())return ah.GroupExpression;break;case Tp.RBRACE:if(this.isWithinBlockExpressionContext())return ah.BlockExpression;break;case Tp.RBRACKET:if(this.isWithinListExpressionContext())return ah.ListExpression;break;default:break}}},gse=class{constructor(e){this.generator=e}create(e,t){return new e(t,this.generator.nextId())}},oh=class{constructor(e,t,n){this.token=e,this.partialNode=t,this.handlerContext=n}},_se=class{constructor(e,t,n){this.current=0,this.errors=[],this.contextStack=new hse,this.synchronizeProgram=()=>{let e=this.peek();e.kind===Tp.EOF?this.logError(e,N.UNEXPECTED_EOF,`Unexpected EOF`):Ym(this.advance())},this.synchronizeElementDeclarationName=()=>{for(;!this.isAtEnd();){let e=this.peek();if(Jm(e)||this.check(Tp.COLON,Tp.LBRACE,Tp.LBRACKET))break;Ym(e),this.advance()}},this.synchronizeElementDeclarationAlias=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(Tp.COLON,Tp.LBRACE,Tp.LBRACKET))break;Ym(e),this.advance()}},this.blockExpression=this.contextStack.withContextDo(ah.BlockExpression,()=>{let e={body:[]},t=()=>this.nodeFactory.create(Bp,e);try{this.consume(`Expect an opening brace '{'`,Tp.LBRACE),e.blockOpenBrace=this.previous()}catch(e){if(!(e instanceof oh))throw e;if(!this.canHandle(e))throw new oh(e.token,t(),e.handlerContext);this.synchronizeBlock()}for(;!this.isAtEnd()&&!this.check(Tp.RBRACE);)try{e.body.push(this.canBeField()?this.fieldDeclaration():this.expression())}catch(n){if(!(n instanceof oh))throw n;if(e.body.push(n.partialNode),!this.canHandle(n))throw new oh(n.token,t(),n.handlerContext);this.synchronizeBlock()}try{this.consume(`Expect a closing brace '}'`,Tp.RBRACE),e.blockCloseBrace=this.previous()}catch(e){if(!(e instanceof oh))throw e;if(!this.canHandle(e))throw new oh(e.token,t(),e.handlerContext);this.synchronizeBlock()}return t()}),this.synchronizeBlock=()=>{if(!this.check(Tp.RBRACE))for(Ym(this.advance());!this.isAtEnd();){let e=this.peek();if(this.check(Tp.RBRACE)||woe(this.previous(),e))break;Ym(e),this.advance()}},this.tupleExpression=this.contextStack.withContextDo(ah.GroupExpression,()=>{let e={elementList:[],commaList:[]},t=()=>this.nodeFactory.create(Wp,{groupOpenParen:e.tupleOpenParen,groupCloseParen:e.tupleCloseParen,expression:e.elementList[0]}),n=()=>this.nodeFactory.create(Hp,e);try{this.consume(`Expect an opening parenthesis '('`,Tp.LPAREN),e.tupleOpenParen=this.previous()}catch(e){if(!(e instanceof oh))throw e;if(!this.canHandle(e))throw new oh(e.token,n(),e.handlerContext);this.synchronizeTuple()}if(!this.isAtEnd()&&!this.check(Tp.RPAREN))try{e.elementList.push(this.normalExpression())}catch(n){if(!(n instanceof oh))throw n;if(e.elementList.push(n.partialNode),!this.canHandle(n))throw new oh(n.token,t(),n.handlerContext);this.synchronizeTuple()}for(;!this.isAtEnd()&&!this.check(Tp.RPAREN);)try{this.consume(`Expect a comma ','`,Tp.COMMA),e.commaList.push(this.previous()),e.elementList.push(this.normalExpression())}catch(t){if(!(t instanceof oh))throw t;if(t.partialNode instanceof kp&&e.elementList.push(t.partialNode),!this.canHandle(t))throw new oh(t.token,n(),t.handlerContext);this.synchronizeTuple()}try{this.consume(`Expect a closing parenthesis ')'`,Tp.RPAREN),e.tupleCloseParen=this.previous()}catch(e){if(!(e instanceof oh))throw e;if(!this.canHandle(e))throw new oh(e.token,n(),e.handlerContext);this.synchronizeTuple()}return e.elementList.length===1?t():n()}),this.synchronizeTuple=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(Tp.RPAREN,Tp.COMMA))break;Ym(e),this.advance()}},this.listExpression=this.contextStack.withContextDo(ah.ListExpression,()=>{let e={elementList:[],commaList:[]},t=()=>this.nodeFactory.create(Vp,e);try{this.consume(`Expect an opening bracket '['`,Tp.LBRACKET),e.listOpenBracket=this.previous()}catch(e){if(!(e instanceof oh))throw e;if(!this.canHandle(e))throw new oh(e.token,t(),e.handlerContext);this.synchronizeList()}if(!this.isAtEnd()&&!this.check(Tp.RBRACKET))try{e.elementList.push(this.attribute())}catch(n){if(!(n instanceof oh))throw n;if(e.elementList.push(n.partialNode),!this.canHandle(n))throw new oh(n.token,t(),n.handlerContext);this.synchronizeList()}for(;!this.isAtEnd()&&!this.check(Tp.RBRACKET);)try{this.consume(`Expect a comma ','`,Tp.COMMA),e.commaList.push(this.previous()),e.elementList.push(this.attribute())}catch(n){if(!(n instanceof oh))throw n;if(n.partialNode instanceof kp&&e.elementList.push(n.partialNode),!this.canHandle(n))throw new oh(n.token,t(),n.handlerContext);this.synchronizeList()}try{this.consume(`Expect a closing bracket ']'`,Tp.RBRACKET),e.listCloseBracket=this.previous()}catch(e){if(!(e instanceof oh))throw e;if(!this.canHandle(e))throw new oh(e.token,t(),e.handlerContext);this.synchronizeList()}return t()}),this.synchronizeList=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(Tp.COMMA,Tp.RBRACKET))break;Ym(e),this.advance()}},this.synchronizeAttributeName=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(Tp.COMMA,Tp.RBRACKET,Tp.COLON))break;Ym(e),this.advance()}},this.synchronizeAttributeValue=()=>{for(;!this.isAtEnd();){let e=this.peek();if(this.check(Tp.COMMA,Tp.RBRACKET))break;Ym(e),this.advance()}},this.source=e,this.tokens=t,this.nodeFactory=new gse(n)}isAtEnd(){return this.current>=this.tokens.length||this.tokens[this.current].kind===Tp.EOF}advance(){return this.isAtEnd()?bp(this.tokens):this.tokens[this.current++]}peek(e=0){return e+this.current>=this.tokens.length?bp(this.tokens):this.tokens[this.current+e]}match(...e){let t=this.check(...e);return t&&this.advance(),t}check(...e){let t=this.peek();return e.includes(t.kind)}previous(){return this.tokens[this.current-1]}canHandle(e){return e.handlerContext===void 0||e.handlerContext===this.contextStack.top()}consume(e,...t){if(!this.match(...t))throw this.logError(this.peek(),N.UNEXPECTED_TOKEN,e),new oh(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}discardUntil(e,...t){if(this.isAtEnd()||!this.check(...t)){for(Ym(this.peek()),this.logError(this.advance(),N.UNEXPECTED_TOKEN,e);!this.isAtEnd()&&!this.check(...t);)Ym(this.advance());return!this.isAtEnd()}return!0}gatherInvalid(){let e=[],t=[],n,r=0;for(;r<this.tokens.length&&this.tokens[r].isInvalid;r+=1)t.push(this.tokens[r]);for(n=this.tokens[r],n.leadingInvalid=[...t,...n.leadingInvalid],e.push(n),r+=1;r<this.tokens.length;r+=1){let t=this.tokens[r];t.isInvalid?n.trailingInvalid.push(t):(n=t,e.push(n))}this.tokens=e}parse(){let e=this.program(),t=this.advance(),n=this.nodeFactory.create(jp,{body:e,eof:t,source:this.source});return this.gatherInvalid(),new rm({ast:n,tokens:this.tokens},this.errors)}program(){let e=[];for(;!this.isAtEnd();)try{let t=this.elementDeclaration();e.push(t)}catch(t){if(!(t instanceof oh))throw t;e.push(t.partialNode),this.synchronizeProgram()}return e}elementDeclaration(){let e={},t=()=>this.nodeFactory.create(Mp,e);try{this.consume(`Expect an identifier`,Tp.IDENTIFIER),e.type=this.previous()}catch(e){throw e instanceof oh?new oh(e.token,t(),e.handlerContext):e}if(!this.check(Tp.COLON,Tp.LBRACE,Tp.LBRACKET))try{e.name=this.normalExpression()}catch(n){if(!(n instanceof oh))throw n;if(e.name=n.partialNode,!this.canHandle(n))throw new oh(n.token,t(),n.handlerContext);this.synchronizeElementDeclarationName()}if(Jm(this.peek()))if(e.as=this.advance(),this.check(Tp.COLON,Tp.LBRACE,Tp.LBRACKET))this.logError(this.peek(),N.UNEXPECTED_TOKEN,`Expect an alias`);else try{e.alias=this.normalExpression()}catch(n){if(!(n instanceof oh))throw n;if(e.alias=n.partialNode,!this.canHandle(n))throw new oh(n.token,t(),n.handlerContext);this.synchronizeElementDeclarationAlias()}try{e.attributeList=this.check(Tp.LBRACKET)?this.listExpression():void 0}catch(n){throw n instanceof oh?(e.attributeList=n.partialNode,new oh(n.token,t(),n.handlerContext)):n}if(!this.discardUntil(`Expect an opening brace '{' or a colon ':'`,Tp.LBRACE,Tp.COLON))return t();try{if(this.match(Tp.COLON)){e.bodyColon=this.previous();let t=this.expression();t instanceof Mp?(Ym(t),this.logError(t,N.UNEXPECTED_ELEMENT_DECLARATION,`An element's simple body must not be an element declaration`)):e.body=t}else e.body=this.blockExpression()}catch(n){throw n instanceof oh?(e.body=n.partialNode,new oh(n.token,t(),n.handlerContext)):n}return this.nodeFactory.create(Mp,e)}fieldDeclaration(){let e={},t=()=>this.nodeFactory.create(Mp,e);try{this.consume(`Expect an identifier`,Tp.IDENTIFIER),e.type=this.previous()}catch(n){throw n instanceof oh?(e.type=n.partialNode,new oh(n.token,t(),n.handlerContext)):n}try{this.consume(`Expect a colon ':'`,Tp.COLON),e.bodyColon=this.previous()}catch(n){throw n instanceof oh?(e.bodyColon=n.partialNode,new oh(n.token,t(),n.handlerContext)):n}try{let t=this.expression();t instanceof Mp?this.errors.push(new P(N.INVALID_ELEMENT_IN_SIMPLE_BODY,`Simple body cannot be an element declaration`,t)):e.body=t}catch(n){throw n instanceof oh?(e.body=n.partialNode,new oh(n.token,t(),n.handlerContext)):n}return this.nodeFactory.create(Mp,e)}expression(){let e={args:[]},t=()=>lse(e.callee,e.args,this.nodeFactory).unwrap_or(this.nodeFactory.create(zp,e));try{e.callee=this.commaExpression()}catch(n){throw n instanceof oh?(e.callee=n.partialNode,new oh(n.token,t(),n.handlerContext)):n}if(this.shouldStopFunctionApplication())return t();let n=e.callee;for(;!this.shouldStopFunctionApplication();){Op(this.previous())||this.logError(n,N.MISSING_SPACES,`Expect a following space`);try{n=this.commaExpression(),e.args.push(n)}catch(r){throw r instanceof oh?(n=r.partialNode,e.args.push(n),new oh(r.token,t(),r.handlerContext)):r}}return t()}shouldStopFunctionApplication(){if(this.isAtEnd()||Dp(this.previous()))return!0;let e=this.peek().kind;return[Tp.RBRACE,Tp.RBRACKET,Tp.RPAREN,Tp.COMMA,Tp.COLON].includes(e)}commaExpression(){let e=this.check(Tp.COMMA)?this.nodeFactory.create(Yp,{prevToken:this.previous()}):this.normalExpression();if(!this.check(Tp.COMMA))return e;let t={elementList:[e],commaList:[]};do{if(t.commaList.push(this.advance()),this.shouldStopCommaExpression()){t.elementList.push(this.nodeFactory.create(Yp,{prevToken:this.previous()}));break}if(this.check(Tp.COMMA)){t.elementList.push(this.nodeFactory.create(Yp,{prevToken:this.previous()}));continue}try{let e=this.normalExpression();t.elementList.push(e)}catch(e){throw e instanceof oh?(e.partialNode&&t.elementList.push(e.partialNode),new oh(e.token,this.nodeFactory.create(Up,t),e.handlerContext)):e}}while(!this.shouldStopCommaExpression()&&this.check(Tp.COMMA));return this.nodeFactory.create(Up,t)}shouldStopCommaExpression(){if(this.isAtEnd()||Dp(this.previous()))return!0;let e=this.peek().kind;return[Tp.RBRACE,Tp.LBRACE,Tp.RBRACKET,Tp.LBRACKET,Tp.RPAREN,Tp.LPAREN,Tp.COLON].includes(e)}normalExpression(){return this.expression_bp(0)}expression_bp(e){let t=this.leftExpression_bp();for(;!this.isAtEnd();){let n=this.peek();if(n.kind===Tp.LPAREN){let{left:r}=Cse(n);if(r<e||woe(this.previous(),n)&&!this.contextStack.isWithinGroupExpressionContext()&&!this.contextStack.isWithinListExpressionContext())break;try{t=this.nodeFactory.create(Gp,{callee:t,argumentList:this.tupleExpression()})}catch(e){throw e instanceof oh?(t=this.nodeFactory.create(Gp,{callee:t,argumentList:e.partialNode}),new oh(e.token,t,e.handlerContext)):e}}else if(n.kind===Tp.LBRACKET){if(Op(this.previous()))break;try{t=this.nodeFactory.create(Xp,{expression:t,indexer:this.listExpression()})}catch(e){throw e instanceof oh?(t=this.nodeFactory.create(Xp,{expression:t,indexer:e.partialNode}),new oh(e.token,t,e.handlerContext)):e}}else if(Coe(n)){let r=n,i=Cse(r);if(i.left!==null){if(i.left<=e)break;this.advance(),t=this.nodeFactory.create(Lp,{expression:t,op:r})}else{let n=yse(r);if(n.left===null||n.left<=e)break;this.advance();try{t=this.nodeFactory.create(Ip,{leftExpression:t,op:r,rightExpression:r.value===`.`?this.extractOperand():this.expression_bp(n.right)})}catch(e){throw e instanceof oh?(t=this.nodeFactory.create(Ip,{leftExpression:t,op:r,rightExpression:e.partialNode}),new oh(e.token,t,e.handlerContext)):e}}}else break}return t}leftExpression_bp(){let e;if(Coe(this.peek())){let t={};t.op=this.peek();let n=xse(t.op);if(n.right===null)throw this.logError(t.op,N.UNKNOWN_PREFIX_OP,`Unexpected '${t.op.value}' in an expression`),new oh(t.op,this.nodeFactory.create(Yp,{prevToken:t.op}),this.contextStack.findHandlerContext(this.tokens,this.current));this.advance();try{t.expression=this.expression_bp(n.right)}catch(e){throw e instanceof oh?(t.expression=e.partialNode,new oh(e.token,this.nodeFactory.create(Fp,t),e.handlerContext)):e}e=this.nodeFactory.create(Fp,t)}else if(e=this.extractOperand(),e instanceof Yp)throw new oh(this.peek(),this.nodeFactory.create(Yp,{prevToken:this.peek()}),this.contextStack.findHandlerContext(this.tokens,this.current));return e}extractOperand(){return this.check(Tp.NUMERIC_LITERAL,Tp.STRING_LITERAL,Tp.COLOR_LITERAL,Tp.QUOTED_STRING,Tp.IDENTIFIER)?this.primaryExpression():this.check(Tp.FUNCTION_EXPRESSION)?this.functionExpression():this.check(Tp.LBRACKET)?this.listExpression():this.check(Tp.LBRACE)?this.blockExpression():this.check(Tp.LPAREN)?this.tupleExpression():(this.peek().kind===Tp.EOF?this.logError(this.peek(),N.UNEXPECTED_EOF,`Unexpected EOF`):this.logError(this.peek(),N.INVALID_OPERAND,`Invalid start of operand "${this.peek().value}"`),this.nodeFactory.create(Yp,{prevToken:this.previous()}))}functionExpression(){let e={};try{this.consume(`Expect a function expression`,Tp.FUNCTION_EXPRESSION),e.value=this.previous()}catch(t){throw t instanceof oh?new oh(t.token,this.nodeFactory.create(Rp,e),t.handlerContext):t}return this.nodeFactory.create(Rp,e)}canBeField(){return this.peek().kind===Tp.IDENTIFIER&&this.peek(1).kind===Tp.COLON}primaryExpression(){if(this.match(Tp.COLOR_LITERAL,Tp.STRING_LITERAL,Tp.NUMERIC_LITERAL))return this.nodeFactory.create(Jp,{expression:this.nodeFactory.create(Kp,{literal:this.previous()})});if(this.match(Tp.QUOTED_STRING,Tp.IDENTIFIER))return this.nodeFactory.create(Jp,{expression:this.nodeFactory.create(qp,{variable:this.previous()})});throw this.logError(this.peek(),N.UNEXPECTED_TOKEN,`Expect a variable or literal`),new oh(this.peek(),void 0,this.contextStack.findHandlerContext(this.tokens,this.current))}attribute(){let e={};if(this.check(Tp.COLON,Tp.RBRACKET,Tp.COMMA)){let t=this.peek();this.logError(t,N.EMPTY_ATTRIBUTE_NAME,`Expect a non-empty attribute name`),e.name=this.nodeFactory.create(Np,{identifiers:[]})}else try{e.name=this.attributeName()}catch(t){if(!(t instanceof oh))throw t;if(e.name=t.partialNode,!this.canHandle(t))throw new oh(t.token,this.nodeFactory.create(Pp,e),t.handlerContext);this.synchronizeAttributeName()}return this.match(Tp.COLON)&&(e.colon=this.previous(),e.value=this.attributeValue()),this.nodeFactory.create(Pp,e)}attributeValue(){let e;try{e=this.peek().kind===Tp.IDENTIFIER&&this.peek(1).kind===Tp.IDENTIFIER?this.attributeName():this.normalExpression()}catch(t){if(!(t instanceof oh)||!this.canHandle(t))throw t;e=t.partialNode,this.synchronizeAttributeValue()}return e}attributeName(){let e=[];if(this.peek().kind!==Tp.IDENTIFIER)return this.primaryExpression();for(;!this.isAtEnd()&&!this.check(Tp.COLON,Tp.COMMA,Tp.RBRACKET);)try{this.consume(`Expect an identifier`,Tp.IDENTIFIER),e.push(this.previous())}catch(t){throw t instanceof oh?new oh(t.token,this.nodeFactory.create(Np,{identifiers:e}),t.handlerContext):t}return this.nodeFactory.create(Np,{identifiers:e})}logError(e,t,n){this.errors.push(new P(t,n,e))}},vse={"+":{left:9,right:10},"*":{left:11,right:12},"-":{left:9,right:10},"/":{left:11,right:12},"%":{left:11,right:12},"<":{left:7,right:8},"<=":{left:7,right:8},">":{left:7,right:8},">=":{left:7,right:8},"<>":{left:7,right:8},"=":{left:2,right:3},"==":{left:4,right:5},"!=":{left:4,right:5},".":{left:16,right:17}};function yse(e){return vse[e.value]||{left:null,right:null}}var bse={"+":{left:null,right:15},"-":{left:null,right:15},"<":{left:null,right:15},">":{left:null,right:15},"<>":{left:null,right:15},"!":{left:null,right:15},"~":{left:null,right:15}};function xse(e){return bse[e.value]||{left:null,right:null}}var Sse={"(":{left:14,right:null}};function Cse(e){return Sse[e.value]||{left:null,right:null}}var wse=class{constructor(e,t){this.ast=e,this.symbolFactory=t,this.publicSchemaSymbol=this.symbolFactory.create(Qp,{symbolTable:new Dm}),this.ast.symbol=this.publicSchemaSymbol,this.ast.symbol.declaration=this.ast}validate(){let e=[];this.ast.body.forEach(t=>{if(t.parent=this.ast,t.type===void 0)return;let n=new(Om(t))(t,this.publicSchemaSymbol.symbolTable,this.symbolFactory);e.push(...n.validate())});let t=this.ast.body.filter(e=>Rm(e).unwrap_or(void 0)===mm.Project);return t.length>1&&t.forEach(t=>e.push(new P(N.PROJECT_REDEFINED,`Only one project can exist`,t))),new rm(this.ast,e)}},Tse=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return[]}},Ese=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.bindBody(this.declarationNode.body)}bindBody(e){if(!e||e instanceof zp)return[];let t=e.body.filter(e=>e instanceof Mp);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>e.type?new(sh(e))(e,this.ast,this.symbolFactory).bind():[])}},Dse=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof Bp?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e||e instanceof zp)return[];let t=e.body.filter(e=>e instanceof zp);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>e.type?new(sh(e))(e,this.ast,this.symbolFactory).bind():[])}},Ose=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return!(this.declarationNode.parent instanceof Mp)||Rm(this.declarationNode.parent).unwrap_or(void 0)!==mm.Table||!(this.declarationNode.body instanceof Bp)?[]:this.bindBody(this.declarationNode.body)}bindBody(e){if(!e)return[];if(e instanceof zp)return this.bindFields([e]);let[t,n]=wp(e.body,e=>e instanceof zp);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return e.flatMap(e=>{if(!e.callee)return[];let t=Bm(this.declarationNode.parent.name).map(e=>e.join(`.`)).unwrap_or(`<unnamed>`),n=this.declarationNode.parent.symbol.symbolTable;return[e.callee,...e.args].flatMap(ch).flatMap(e=>e.variables.length+e.tupleElements.length>1?[]:e.variables.length?e.variables[0]:e.tupleElements).flatMap(e=>{let r=Wm(e).unwrap_or(void 0);if(r===void 0)return[];let i=ym(r),a=n.get(i);return a?(e.referee=a,a.references.push(e),[]):new P(N.BINDING_ERROR,`No column named '${r}' inside Table '${t}'`,e)})})}bindSubElements(e){return e.flatMap(e=>e.type?new(sh(e))(e,this.ast,this.symbolFactory).bind():[])}},kse=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.bindBody(this.declarationNode.body)}bindBody(e){if(!e||e instanceof zp)return[];let t=e.body.filter(e=>e instanceof Mp);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>e.type?new(sh(e))(e,this.ast,this.symbolFactory).bind():[])}},Ase=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof Bp?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e||e instanceof zp)return[];let t=e.body.filter(e=>e instanceof Mp);return this.bindSubElements(t)}bindSubElements(e){return e.flatMap(e=>e.type?new(sh(e))(e,this.ast,this.symbolFactory).bind():[])}},jse=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return!(this.declarationNode.parent instanceof jp)&&Rm(this.declarationNode.parent).unwrap_or(void 0)!==mm.Project?[]:this.bindBody(this.declarationNode.body)}bindBody(e){if(!e)return[];if(e instanceof zp)return this.bindFields([e]);let[t,n]=wp(e.body,e=>e instanceof zp);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return e.flatMap(e=>e.callee?[e.callee,...e.args].flatMap(ch).flatMap(e=>{let t=e.tupleElements.length?e.tupleElements:e.variables.pop(),n=e.variables.pop();if(!t||!n)return[];Array.isArray(t)||(t=[t]);let r=e.variables;return t.flatMap(e=>lh(this.ast,[...r.map(e=>({node:e,kind:gm.Schema})),{node:n,kind:gm.Table},{node:e,kind:gm.Column}]))}):[])}bindSubElements(e){return e.flatMap(e=>e.type?new(sh(e))(e,this.ast,this.symbolFactory).bind():[])}},Mse=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof Bp?this.bindBody(this.declarationNode.body):[]}resolvePartialInjections(){let{body:e}=this.declarationNode;return(e?e instanceof Bp?e.body:[e]:[]).filter(e=>e instanceof zp&&jm(e.callee)).reverse().flatMap(e=>{let t=Vm(e.callee.expression).unwrap_or(void 0);if(!t)return[];let n=t.variables.pop(),r=t.variables;if(!n)return[];let i=lh(this.ast,[...r.map(e=>({node:e,kind:gm.Schema})),{node:n,kind:gm.TablePartial}]);return i.length?i:(n.referee?.symbolTable?.forEach(t=>{let r=Hm(t.declaration.callee).unwrap_or(void 0);if(r===void 0)return;let i=this.symbolFactory.create(tm,{declaration:e,tablePartialSymbol:n.referee}),a=ym(r),o=this.declarationNode.symbol?.symbolTable;o?.has(a)||o?.set(a,i)}),[])})}bindBody(e){if(!e)return[];if(e instanceof zp)return this.bindFields([e]);let[t,n]=wp(e.body,e=>e instanceof zp);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return(e=>e.flatMap(e=>{if(!e.callee)return[];let t=[],n=[e.callee,...e.args];if(bp(n)instanceof Vp){let e=Lm(bp(n)).getValue();t.push(...e.ref?.flatMap(e=>e.value?this.bindInlineRef(e.value):[])||[]),t.push(...e.default?.flatMap(e=>e.value?this.tryToBindEnumFieldRef(e.value):[])||[]),n.pop()}return n[1]&&this.tryToBindColumnType(n[1]),t}))(e.filter(e=>!jm(e.callee)))}tryToBindColumnType(e){let t=Vm(e).unwrap_or(void 0);if(!t)return;let n=t.variables.pop(),r=t.variables;n&&lh(this.ast,[...r.map(e=>({node:e,kind:gm.Schema})),{node:n,kind:gm.Enum}])}tryToBindEnumFieldRef(e){if(Qm(e))return[];if($m(e)){let t=e.expression.variable?.value?.toLowerCase();if(t&&Loe.includes(t))return[]}let t=Vm(e).unwrap_or(void 0);if(!t)return[];let n=t.variables.pop(),r=t.variables.pop();if(!n||!r)return[];let i=t.variables;return lh(this.ast,[...i.map(e=>({node:e,kind:gm.Schema})),{node:r,kind:gm.Enum},{node:n,kind:gm.EnumField}])}bindInlineRef(e){return ch(e).flatMap(e=>{let t=e.variables.pop(),n=e.variables.pop();if(!t)return[];let r=e.variables;return n?lh(this.ast,[...r.map(e=>({node:e,kind:gm.Schema})),{node:n,kind:gm.Table},{node:t,kind:gm.Column}]):lh(this.declarationNode,[{node:t,kind:gm.Column}])})}bindSubElements(e){return e.flatMap(e=>e.type?new(sh(e))(e,this.ast,this.symbolFactory).bind():[])}},Nse=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof Bp?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e)return[];if(e instanceof zp)return this.bindFields([e]);let[t,n]=wp(e.body,e=>e instanceof zp);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return e.flatMap(e=>e.callee?[e.callee,...e.args].flatMap(ch).flatMap(e=>{let t=e.variables.pop();if(!t)return[];let n=e.variables;return lh(this.ast,[...n.map(e=>({node:e,kind:gm.Schema})),{node:t,kind:gm.Table}])}):[])}bindSubElements(e){return e.flatMap(e=>e.type?new(sh(e))(e,this.ast,this.symbolFactory).bind():[])}},Pse=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n}bind(){return this.declarationNode.body instanceof Bp?this.bindBody(this.declarationNode.body):[]}bindBody(e){if(!e)return[];if(e instanceof zp)return this.bindFields([e]);let[t,n]=wp(e.body,e=>e instanceof zp);return[...this.bindFields(t),...this.bindSubElements(n)]}bindFields(e){return e.flatMap(e=>{if(!e.callee)return[];let t=[],n=[e.callee,...e.args];if(bp(n)instanceof Vp){let e=Lm(bp(n)).getValue();t.push(...e.ref?.flatMap(e=>e.value?this.bindInlineRef(e.value):[])||[]),n.pop()}return n[1]&&this.tryToBindColumnType(n[1]),t})}tryToBindColumnType(e){let t=Vm(e).unwrap_or(void 0);if(!t)return;let n=t.variables.pop(),r=t.variables;n&&lh(this.ast,[...r.map(e=>({node:e,kind:gm.Schema})),{node:n,kind:gm.Enum}])}bindInlineRef(e){return ch(e).flatMap(e=>{let t=e.variables.pop(),n=e.variables.pop();if(!t)return[];let r=e.variables;return n?lh(this.ast,[...r.map(e=>({node:e,kind:gm.Schema})),{node:n,kind:gm.Table},{node:t,kind:gm.Column}]):lh(this.declarationNode,[{node:t,kind:gm.Column}])})}bindSubElements(e){return e.flatMap(e=>e.type?new(sh(e))(e,this.ast,this.symbolFactory).bind():[])}};function Fse(e){return[_m,vm,bm,Sm,ym,xm,Cm,wm,Tm].map(t=>t(e))}function Ise(e){if(e instanceof Qp)return gm.Schema;if(e instanceof $p)return gm.Table;if(e instanceof em)return gm.Column;if(e instanceof Aoe)return gm.Enum;if(e instanceof joe)return gm.EnumField;if(e instanceof Moe)return gm.TableGroup;if(e instanceof Noe)return gm.TableGroupField;if(e instanceof Poe)return gm.TablePartial;if(e instanceof tm)return gm.Column;if(e instanceof Foe)return gm.PartialInjection;throw Error(`No other possible symbol kind in getSymbolKind`)}var Lse=class{constructor(e,t,n){this.declarationNode=e,this.ast=t,this.symbolFactory=n,this.boundColumns=new Map}bind(){let e=[];return this.declarationNode.name&&e.push(...this.bindRecordsName(this.declarationNode.name)),this.declarationNode.body instanceof Bp&&e.push(...this.bindBody(this.declarationNode.body)),e}bindRecordsName(e){return this.declarationNode.parent instanceof jp?this.bindTopLevelName(e):this.bindInsideTableName(e)}bindTopLevelName(e){let t=cse(e).unwrap_or(void 0);if(!t)return[];let n=t.variables.pop(),r=t.variables;if(!n)return[];let i=lh(this.ast,[...r.map(e=>({node:e,kind:gm.Schema})),{node:n,kind:gm.Table}]);if(i.length>0)return i;let a=n.referee;if(!a?.symbolTable)return[];let o=ih(n.referee?.declaration).unwrap_or(`<invalid name>`),s=[];for(let e of t.args){let t=Wm(e).unwrap_or(`<unnamed>`),n=ym(t),r=a.symbolTable.get(n);if(!r){s.push(new P(N.BINDING_ERROR,`Column '${t}' does not exist in Table '${o}'`,e));continue}e.referee=r,r.references.push(e);let i=this.boundColumns.get(r);i&&(s.push(new P(N.DUPLICATE_COLUMN_REFERENCES_IN_RECORDS,`Column '${t}' is referenced more than once in a Records for Table '${o}'`,i)),s.push(new P(N.DUPLICATE_COLUMN_REFERENCES_IN_RECORDS,`Column '${t}' is referenced more than once in a Records for Table '${o}'`,e))),this.boundColumns.set(r,e)}return s}bindInsideTableName(e){let t=this.declarationNode.parent;if(!(t instanceof Mp)||Rm(t).unwrap_or(void 0)!==mm.Table)return[];let n=t.symbol?.symbolTable;if(!n||!Im(e))return[];let r=ih(t).unwrap_or(`<invalid name>`),i=[];for(let t of e.elementList){let e=Wm(t).unwrap_or(`<unnamed>`),a=ym(e),o=n.get(a);if(!o){i.push(new P(N.BINDING_ERROR,`Column '${e}' does not exist in Table '${r}'`,t));continue}t.referee=o,o.references.push(t)}return i}bindBody(e){if(!e)return[];if(e instanceof zp)return this.bindDataRow(e);let t=e.body.filter(e=>e instanceof zp),n=e.body.filter(e=>e instanceof Mp);return[...this.bindDataRows(t),...this.bindSubElements(n)]}bindDataRows(e){return e.flatMap(e=>this.bindDataRow(e))}bindDataRow(e){return e.callee?(e.callee instanceof Up?e.callee.elementList:[e.callee]).flatMap(ch).flatMap(e=>{let t=e.variables.pop(),n=e.variables.pop();if(!t||!n)return[];let r=e.variables;return lh(this.ast,[...r.map(e=>({node:e,kind:gm.Schema})),{node:n,kind:gm.Enum},{node:t,kind:gm.EnumField}])}):[]}bindSubElements(e){return e.flatMap(e=>e.type?new(sh(e))(e,this.ast,this.symbolFactory).bind():[])}};function sh(e){switch(e.type.value.toLowerCase()){case mm.Enum:return Dse;case mm.Table:return Mse;case mm.TableGroup:return Nse;case mm.Project:return Ase;case mm.Ref:return jse;case mm.Note:return kse;case mm.Indexes:return Ose;case mm.TablePartial:return Pse;case mm.Check:return Tse;case mm.Records:return Lse;default:return Ese}}function ch(e){if(!e)return[];if($m(e))return[{variables:[e],tupleElements:[]}];if(e instanceof Ip){let t=Vm(e).unwrap_or(void 0);return t?[t]:[...ch(e.leftExpression),...ch(e.rightExpression)]}if(e instanceof Fp||e instanceof Lp)return ch(e.expression);if(e instanceof Hp){let t=Vm(e).unwrap_or(void 0);return t?[t]:e.elementList.flatMap(ch)}return[]}function lh(e,t){if(!e.symbol?.symbolTable)throw Error(`lookupAndBindInScope should only be called with initial scope having a symbol table`);let n=e.symbol.symbolTable,r=Ise(e.symbol),i=e instanceof Mp?ih(e).unwrap_or(`<invalid name>`):pm;if(e instanceof jp&&t.length){let{node:e,kind:n}=t[0];Wm(e).unwrap_or(`<unnamed>`)===`public`&&n===gm.Schema&&t.shift()}for(let e of t){let{node:t,kind:a}=e,o=Wm(t).unwrap_or(`<unnamed>`),s=Voe(o,a),c=n.get(s);if(!c)return[new P(N.BINDING_ERROR,`${a} '${o}' does not exist in ${i===void 0?`global scope`:`${r} '${i}'`}`,t)];if(t.referee=c,c.references.push(t),i=o,r=a,!c.symbolTable)return[];n=c.symbolTable}return[]}var Rse=class{constructor(e,t){this.ast=e,this.symbolFactory=t}resolvePartialInjections(){return this.ast.body.filter(e=>Rm(e).unwrap_or(``)===mm.Table).flatMap(e=>new Mse(e,this.ast,this.symbolFactory).resolvePartialInjections())}resolve(){let e=[];e.push(...this.resolvePartialInjections());for(let t of this.ast.body)if(t.type){let n=new(sh(t))(t,this.ast,this.symbolFactory);e.push(...n.bind())}return new rm(this.ast,e)}},zse=class{constructor(e){this.generator=e}create(e,t){return new e(t,this.generator.nextId())}},Bse=class{constructor(e,t){this.ast=e,this.symbolFactory=new zse(t)}analyze(){return new wse(this.ast,this.symbolFactory).validate().chain(e=>new Rse(e,this.symbolFactory).resolve())}validate(){return new wse(this.ast,this.symbolFactory).validate().chain(e=>new rm(e,[]))}};function Vse(e,t){let{variables:n,tupleElements:r}=Vm(e).unwrap(),i=r.map(e=>Wm(e).unwrap()),a=n.map(e=>Wm(e).unwrap());return r.length?n.length===0?{schemaName:t.schemaName,tableName:t.name,fieldNames:i}:{tableName:a.pop(),schemaName:a.pop()||null,fieldNames:i}:n.length===1?{schemaName:t.schemaName,tableName:t.name,fieldNames:[a[0]]}:{fieldNames:[a.pop()],tableName:a.pop(),schemaName:a.pop()||null}}function uh(e){switch(e){case`<`:return[`1`,`*`];case`<>`:return[`*`,`*`];case`>`:return[`*`,`1`];case`-`:return[`1`,`1`];default:throw Error(`Invalid relation op`)}}function dh(e){return{start:{offset:e.startPos.offset,line:e.startPos.line+1,column:e.startPos.column+1},end:{offset:e.endPos.offset,line:e.endPos.line+1,column:e.endPos.column+1}}}function fh(e){let t=zm(e).unwrap_or(void 0)?.pop();return t instanceof Hp?t.elementList.map(e=>e.referee):[t.referee]}function ph(e){let t=Bm(e).unwrap();return{name:t.pop(),schemaName:t}}function mh(e){return e.expression.literal.value}function Hse(e,t){if(Array.isArray(e)){let n=e.map(({id:e})=>e).sort().join(`,`),r=t.map(({id:e})=>e).sort().join(`,`);return n<r?`${n}-${r}`:`${r}-${n}`}let n=e.id.toString(),r=t.id.toString();return n<r?`${n}-${r}`:`${r}-${n}`}function Use(e,t){return Array.isArray(e)?boe(e.map(({id:e})=>e).sort(),t.map(({id:e})=>e).sort()).every(([e,t])=>e===t):e.id===t.id}function hh(e){let t=e.split(`
10
10
  `),n=t.slice(t.findIndex(e=>e.trimStart()!==``)),r=n.filter(e=>e.trimStart()),i=Math.min(...r.map(e=>e.length-e.trimStart().length));return n.map(e=>e.slice(i)).join(`
11
- `)}function Wse(e){if(e){if(Qm(e))return{value:Gm(e).unwrap(),type:`string`};if(Fm(e))return{type:`number`,value:um(e)};if(eh(e))return{value:e.expression.variable.value.toLowerCase(),type:`boolean`};if(e instanceof Rp&&e.value)return{value:e.value.value,type:`expression`};if(nh(e))return{value:zm(e).map(bp).and_then(Hm).unwrap(),type:`string`};throw Error(`Unreachable`)}}function Gse(e,t){let n=``,r=null,i,a;if(e instanceof Gp){let t=e.argumentList.elementList;if(r=t.map(e=>Fm(e)?lm(e):Qm(e)?Gm(e).unwrap():Hm(e).unwrap()).join(`,`),n=`(${r})`,t.length===2&&Fm(t[0])&&Fm(t[1])){let e=um(t[0]),n=um(t[1]);!isNaN(e)&&!isNaN(n)&&(i={precision:Math.trunc(e),scale:Math.trunc(n)})}else if(t.length===1&&Fm(t[0])){let e=um(t[0]);isNaN(e)||(a={length:Math.trunc(e)})}e=e.callee}for(;e instanceof Gp||e instanceof Xp;)e instanceof Gp?(n=`(${e.argumentList.elementList.map(e=>Fm(e)?lm(e):Qm(e)?Gm(e).unwrap():Hm(e).unwrap()).join(`,`)})${n}`,e=e.callee):e instanceof Xp&&(n=`${`[${e.indexer.elementList.map(e=>e.name.expression.literal.value).join(`,`)}]`}${n}`,e=e.array);let{name:o,schemaName:s}=ph(e),c=s.length===0?null:s[0],l=!![...t.enums.values()].find(e=>e.name===o&&e.schemaName===c);return s.length>1?new rm({schemaName:s.length===0?null:s[0],type_name:`${o}${n}`,args:r,numericParams:i,lengthParam:a,isEnum:l},[new P(N.UNSUPPORTED,`Nested schema is not supported`,e)]):new rm({schemaName:s.length===0?null:s[0],type_name:`${o}${n}`,args:r,numericParams:i,lengthParam:a,isEnum:l})}function gh(e,t){let n=[...t.tables.entries()].find(([,t])=>t===e)?.[0];if(!n)throw Error(`mergeTableAndPartials should be called after all tables are interpreted`);if(!(n.body instanceof Bp))throw Error(`Table element should have a block body`);let r=[...e.indexes],i=[...e.checks],a=e.headerColor,o=e.note,s=[...t.tablePartials.values()];for(let t of[...e.partials].reverse()){let{name:e}=t,n=s.find(t=>t.name===e);n&&(r.push(...n.indexes),i.push(...n.checks),n.headerColor!==void 0&&(a=n.headerColor),n.note!==void 0&&(o=n.note))}let c=new Map(e.fields.map(e=>[e.name,e])),l=new Set(c.keys()),u=new Map(s.map(e=>[e.name,e])),d=[];for(let e of n.body.body)if(e instanceof zp)if(jm(e.callee)){let t=Hm(e.callee.expression).unwrap_or(void 0),n=u.get(t);if(!n)continue;for(let e of n.fields)l.has(e.name)||d.push(e)}else{let t=Hm(e.callee).unwrap(),n=c.get(t);if(!n)continue;d.push(n)}let f=_oe([...d].reverse(),`name`).reverse();return{...e,fields:f,indexes:r,checks:i,headerColor:a,note:o}}function Kse(e,t){let n=[],r=[...t.tablePartials.values()],i=new Set(e.fields.map(e=>e.name));for(let t of[...e.partials].reverse()){let{name:a}=t,o=r.find(e=>e.name===a);if(o){for(let t of o.fields)if(!i.has(t.name))for(let r of t.inline_refs){let i=uh(r.relation);n.push({name:null,schemaName:null,token:r.token,endpoints:[{schemaName:r.schemaName,tableName:r.tableName,fieldNames:r.fieldNames,token:r.token,relation:i[1]},{schemaName:e.schemaName,tableName:e.name,fieldNames:[t.name],token:t.token,relation:i[0]}]})}}}return n}var qse=class{constructor(e,t){this.declarationNode=e,this.env=t,this.table={name:void 0,schemaName:void 0,alias:null,fields:[],token:void 0,indexes:[],partials:[],checks:[]},this.pkColumns=[]}interpret(){this.table.token=dh(this.declarationNode),this.env.tables.set(this.declarationNode,this.table);let e=[...this.interpretName(this.declarationNode.name),...this.interpretAlias(this.declarationNode.alias),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.table.indexes.push({columns:this.pkColumns.map(({name:e,token:t})=>({value:e,type:`column`,token:t})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(e=>{e.pk=!1})),e}interpretName(e){let{name:t,schemaName:n}=ph(e);return n.length>1?(this.table.name=t,this.table.schemaName=n.join(`.`),[new P(N.UNSUPPORTED,`Nested schema is not supported`,e)]):(this.table.name=t,this.table.schemaName=n.length?n[0]:null,[])}interpretAlias(e){if(!e)return[];let t=Wm(e).unwrap_or(null);return t&&(this.env.aliases.push({name:t,kind:`table`,value:{tableName:this.table.name,schemaName:this.table.schemaName}}),this.table.alias=t),[]}interpretSettingList(e){let t=Lm(e).getValue();this.table.headerColor=t[hm.HeaderColor]?.length?mh(t[hm.HeaderColor]?.at(0)?.value):void 0;let[n]=t[hm.Note]||[];return this.table.note=n&&{value:Gm(n?.value).map(hh).unwrap(),token:dh(n)},[]}interpretBody(e){let[t,n]=wp(e.body,e=>e instanceof zp);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case mm.Note:return this.table.note={value:Gm(e.body instanceof Bp?e.body.body[0].callee:e.body.callee).map(hh).unwrap(),token:dh(e)},[];case mm.Indexes:return this.interpretIndexes(e);case mm.Check:return this.interpretChecks(e);case mm.Records:return this.env.recordsElements.push(e),[];default:return[]}})}interpretInjection(e,t){let n={order:t,token:dh(e)};return n.name=Hm(e.expression).unwrap_or(``),this.table.partials.push(n),[]}interpretFields(e){let t=(this.declarationNode.symbol?.symbolTable?[...this.declarationNode.symbol.symbolTable.entries()]:[]).filter(([e])=>Em(e).unwrap_or(null)?.kind===gm.Column).length?[]:[new P(N.EMPTY_TABLE,`A Table must have at least one column`,this.declarationNode)],n=e.flatMap((e,t)=>jm(e.callee)?this.interpretInjection(e.callee,t):this.interpretColumn(e));return[...t,...n]}interpretColumn(e){let t=[],n={};n.name=Wm(e.callee).unwrap();let r=Gse(e.args[0],this.env);n.type=r.getValue(),t.push(...r.getErrors()),n.token=dh(e),n.inline_refs=[];let i=e.args.slice(1);if(bp(i)instanceof Vp){let r=Lm(i.pop()).getValue();n.pk=!!r[hm.PK]?.length||!!r[hm.PrimaryKey]?.length,n.increment=!!r[hm.Increment]?.length,n.unique=!!r[hm.Unique]?.length,n.not_null=r[hm.NotNull]?.length?!0:r[hm.Null]?.length?!1:void 0,n.dbdefault=Wse(r[hm.Default]?.at(0)?.value);let a=r[hm.Note]?.at(0);n.note=a&&{value:Gm(a.value).map(hh).unwrap(),token:dh(a)},n.inline_refs=(r[hm.Ref]||[]).flatMap(n=>{let[r]=fh(n.value.expression);if(Use(r,e.symbol))return t.push(new P(N.SAME_ENDPOINT,`Two endpoints are the same`,n)),[];let i=n.value.op,a=Bm(n.value.expression).unwrap(),o;if(a.length===1){let[e]=a;o={schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[e],relation:i.value,token:dh(n)}}else if(a.length===2){let[e,t]=a;o={schemaName:null,tableName:e,fieldNames:[t],relation:i.value,token:dh(n)}}else if(a.length===3){let[e,t,r]=a;o={schemaName:e,tableName:t,fieldNames:[r],relation:i.value,token:dh(n)}}else{t.push(new P(N.UNSUPPORTED,`Nested schema is not supported`,n));let e=a.pop(),r=a.pop();o={schemaName:a.join(`.`),tableName:r,fieldNames:[e],relation:i.value,token:dh(n)}}let s=this.registerInlineRefToEnv(e,r,o,n);return t.push(...s),s.length===0?o:[]}),n.checks=(r[hm.Check]||[]).map(e=>({token:dh(e),expression:e.value.value.value}))}return n.pk||=i.some(e=>Hm(e).unwrap().toLowerCase()===`pk`),n.unique||=i.some(e=>Hm(e).unwrap().toLowerCase()===`unique`),this.table.fields.push(n),n.pk&&this.pkColumns.push(n),t}interpretIndexes(e){return this.table.indexes.push(...e.body.body.map(e=>{let t={columns:[]},n=e;t.token=dh(n);let r=[n.callee,...n.args];if(bp(r)instanceof Vp){let e=Lm(r.pop()).getValue();t.pk=!!e[hm.PK]?.length,t.unique=!!e[hm.Unique]?.length,t.name=Gm(e[hm.Name]?.at(0)?.value).unwrap_or(void 0);let n=e[hm.Note]?.at(0);t.note=n&&{value:Gm(n.value).unwrap(),token:dh(n)},t.type=Hm(e[hm.Type]?.at(0)?.value).unwrap_or(void 0)}return r.flatMap(e=>{if(!(e instanceof Gp))return e;let t=[];for(;e instanceof Gp;)t.push(e.argumentList),e=e.callee;return t.push(e),t}).forEach(e=>{let{functional:n,nonFunctional:r}=Um(e).unwrap();t.columns.push(...n.map(e=>({value:e.value.value,type:`expression`,token:dh(e)})),...r.map(e=>({value:Wm(e).unwrap(),type:`column`,token:dh(e)})))}),t})),[]}interpretChecks(e){return this.table.checks.push(...e.body.body.map(e=>{let t={},n=e;return t.token=dh(n),n.args[0]instanceof Vp&&(t.name=Gm(Lm(n.args[0]).getValue()[hm.Name]?.at(0)?.value).unwrap_or(void 0)),t.expression=n.callee.value.value,t})),[]}registerInlineRefToEnv(e,t,n,r){let i=Hse(e.symbol,t);if(this.env.refIds[i])return[new P(N.CIRCULAR_REF,`References with same endpoints exist`,r),new P(N.CIRCULAR_REF,`References with same endpoints exist`,this.env.refIds[i])];let a=uh(n.relation);return this.env.refIds[i]=r,this.env.ref.set(r,{name:null,schemaName:null,token:n.token,endpoints:[{...n,relation:a[1]},{schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[Hm(e.callee).unwrap()],token:dh(e),relation:a[0]}]}),[]}},Jse=class{constructor(e,t){this.declarationNode=e,this.env=t,this.note={name:void 0,content:void 0,token:void 0}}interpret(){return this.note.token=dh(this.declarationNode),this.env.notes.set(this.declarationNode,this.note),[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let{name:t}=ph(e);return this.note.name=t,[]}interpretSettingList(e){let t=Lm(e).getValue();return this.note.headerColor=t.headercolor?.length?mh(t.headercolor?.at(0)?.value):void 0,[]}interpretBody(e){let[t,n]=wp(e.body,e=>e instanceof zp);return t.length!==1||n.length>0?[new P(N.INVALID_NOTE,`Invalid note syntax`,e)]:[...this.interpretNote(t[0])]}interpretNote(e){let t=are(e,`callee.expression.literal.value`,``);return this.note.content=hh(t),[]}},Yse=class{constructor(e,t){this.declarationNode=e,this.env=t,this.container=this.declarationNode.parent instanceof Mp?this.env.tables.get(this.declarationNode.parent):void 0,this.ref={}}interpret(){return this.ref.token=dh(this.declarationNode),this.env.ref.set(this.declarationNode,this.ref),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let t=[],n=Bm(this.declarationNode.name).unwrap_or([]);return this.ref.name=n.pop()||null,n.length>1&&t.push(new P(N.UNSUPPORTED,`Nested schema is not supported`,this.declarationNode.name)),this.ref.schemaName=n.join(`.`)||null,t}interpretBody(e){return e instanceof zp?this.interpretField(e):this.interpretField(e.body[0])}interpretField(e){let t=e.callee.op.value,{leftExpression:n,rightExpression:r}=e.callee,i=fh(n),a=fh(r);if(Use(i,a))return[new P(N.SAME_ENDPOINT,`Two endpoints are the same`,e)];let o=Hse(i,a);if(this.env.refIds[o])return[new P(N.CIRCULAR_REF,`References with same endpoints exist`,this.declarationNode),new P(N.CIRCULAR_REF,`References with same endpoints exist`,this.env.refIds[o])];if(e.args[0]){let t=Lm(e.args[0]).getValue(),n=t.delete?.at(0)?.value;this.ref.onDelete=n instanceof Np?rh(n).unwrap_or(void 0):Hm(n).unwrap_or(void 0);let r=t.update?.at(0)?.value;this.ref.onUpdate=r instanceof Np?rh(r).unwrap_or(void 0):Hm(r).unwrap_or(void 0),this.ref.color=t.color?.length?mh(t.color?.at(0)?.value):void 0}let s=uh(t);return this.ref.endpoints=[{...Vse(n,this.container),relation:s[0],token:dh(n)},{...Vse(r,this.container),relation:s[1],token:dh(r)}],this.env.refIds[o]=this.declarationNode,[]}},Xse=class{constructor(e,t){this.declarationNode=e,this.env=t,this.tableGroup={tables:[]}}interpret(){let e=[];return this.tableGroup.token=dh(this.declarationNode),this.env.tableGroups.set(this.declarationNode,this.tableGroup),e.push(...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)),e}interpretName(e){let t=[],{name:n,schemaName:r}=ph(e);return r.length>=2&&(this.tableGroup.name=n,this.tableGroup.schemaName=r.join(`.`),t.push(new P(N.UNSUPPORTED,`Nested schema is not supported`,this.declarationNode.name))),this.tableGroup.name=n,this.tableGroup.schemaName=r[0]||null,t}interpretBody(e){let[t,n]=wp(e.body,e=>e instanceof zp);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case`note`:this.tableGroup.note={value:Gm(e.body instanceof Bp?e.body.body[0].callee:e.body.callee).map(hh).unwrap(),token:dh(e)};break;default:break}return[]})}interpretFields(e){let t=[];return this.tableGroup.tables=e.map(e=>{let n=Bm(e.callee).unwrap();n.length>2&&t.push(new P(N.UNSUPPORTED,`Nested schema is not supported`,e));let r=zm(e.callee).unwrap().pop().referee.id;if(this.env.tableOwnerGroup[r]){let i=this.env.tableOwnerGroup[r],{schemaName:a,name:o}=this.env.tableGroups.get(i),s=a?`${a}.${o}`:o;t.push(new P(N.TABLE_REAPPEAR_IN_TABLEGROUP,`Table "${n.join(`.`)}" already appears in group "${s}"`,e))}else this.env.tableOwnerGroup[r]=this.declarationNode;return{name:n.pop(),schemaName:n.join(`.`)}}),t}interpretSettingList(e){let t=Lm(e).getValue();this.tableGroup.color=t.color?.length?mh(t.color?.at(0)?.value):void 0;let[n]=t.note||[];return this.tableGroup.note=n&&{value:Gm(n?.value).map(hh).unwrap(),token:dh(n)},[]}},Zse=class{constructor(e,t){this.declarationNode=e,this.env=t,this.enum={values:[]}}interpret(){return this.enum.token=dh(this.declarationNode),this.env.enums.set(this.declarationNode,this.enum),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let{name:t,schemaName:n}=ph(e);return n.length>1?(this.enum.name=t,this.enum.schemaName=n.join(`.`),[new P(N.UNSUPPORTED,`Nested schema is not supported`,e)]):(this.enum.name=t,this.enum.schemaName=n.length?n[0]:null,[])}interpretBody(e){return e.body.flatMap(e=>{let t=e,n={};n.token=dh(t),n.name=Hm(t.callee).unwrap();let r=Lm(t.args[0]).getValue().note?.at(0);return n.note=r&&{value:Gm(r.value).map(hh).unwrap(),token:dh(r)},this.enum.values.push(n),[]})}},Qse=class{constructor(e,t){this.declarationNode=e,this.env=t,this.tablePartial={name:void 0,fields:[],token:void 0,indexes:[],checks:[]},this.pkColumns=[]}interpret(){this.tablePartial.token=dh(this.declarationNode),this.env.tablePartials.set(this.declarationNode,this.tablePartial);let e=[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.tablePartial.indexes.push({columns:this.pkColumns.map(({name:e,token:t})=>({value:e,type:`column`,token:t})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(e=>{e.pk=!1})),e}interpretName(e){let{name:t}=ph(e);return this.tablePartial.name=t,[]}interpretSettingList(e){let t=Lm(e).getValue(),n=Qae(t[hm.HeaderColor]);this.tablePartial.headerColor=n?mh(n.value):void 0;let[r]=t[hm.Note]||[];return this.tablePartial.note=r&&{value:Gm(r?.value).map(hh).unwrap(),token:dh(r)},[]}interpretBody(e){let[t,n]=wp(e.body,e=>e instanceof zp);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case mm.Note:return this.tablePartial.note={value:Gm(e.body instanceof Bp?e.body.body[0].callee:e.body.callee).map(hh).unwrap(),token:dh(e)},[];case mm.Indexes:return this.interpretIndexes(e);case mm.Check:return this.interpretChecks(e);default:return[]}})}interpretFields(e){return e.flatMap(e=>this.interpretColumn(e))}interpretColumn(e){let t=[],n={};n.name=Wm(e.callee).unwrap();let r=Gse(e.args[0],this.env);n.type=r.getValue(),t.push(...r.getErrors()),n.token=dh(e),n.inline_refs=[];let i=e.args.slice(1);if(bp(i)instanceof Vp){let r=Lm(i.pop()).getValue();n.pk=!!r[hm.PK]?.length||!!r[hm.PrimaryKey]?.length,n.increment=!!r[hm.Increment]?.length,n.unique=!!r[hm.Unique]?.length,n.not_null=r[hm.NotNull]?.length?!0:r[hm.Null]?.length?!1:void 0,n.dbdefault=Wse(r[hm.Default]?.at(0)?.value);let a=r[hm.Note]?.at(0);n.note=a&&{value:Gm(a.value).map(hh).unwrap(),token:dh(a)},n.inline_refs=(r[hm.Ref]||[]).flatMap(n=>{let[r]=fh(n.value.expression);if(Use(r,e.symbol))return t.push(new P(N.SAME_ENDPOINT,`Two endpoints are the same`,n)),[];let i=n.value.op,a=Bm(n.value.expression).unwrap(),o;if(a.length===2){let[e,t]=a;o={schemaName:null,tableName:e,fieldNames:[t],relation:i.value,token:dh(n)}}else if(a.length===3){let[e,t,r]=a;o={schemaName:e,tableName:t,fieldNames:[r],relation:i.value,token:dh(n)}}else{t.push(new P(N.UNSUPPORTED,`Unsupported`,n));let e=a.pop(),r=a.pop();o={schemaName:a.join(`.`),tableName:r,fieldNames:[e],relation:i.value,token:dh(n)}}return o}),n.checks=(r[hm.Check]||[]).map(e=>({token:dh(e),expression:e.value.value.value}))}return n.pk||=i.some(e=>Hm(e).unwrap().toLowerCase()===`pk`),n.unique||=i.some(e=>Hm(e).unwrap().toLowerCase()===`unique`),this.tablePartial.fields.push(n),n.pk&&this.pkColumns.push(n),t}interpretIndexes(e){return this.tablePartial.indexes.push(...e.body.body.map(e=>{let t={columns:[]},n=e;t.token=dh(n);let r=[n.callee,...n.args];if(bp(r)instanceof Vp){let e=Lm(r.pop()).getValue();t.pk=!!e[hm.PK]?.length,t.unique=!!e[hm.Unique]?.length,t.name=Gm(e[hm.Name]?.at(0)?.value).unwrap_or(void 0);let n=e[hm.Note]?.at(0);t.note=n&&{value:Gm(n.value).unwrap(),token:dh(n)},t.type=Hm(e[hm.Type]?.at(0)?.value).unwrap_or(void 0)}return r.flatMap(e=>{if(!(e instanceof Gp))return e;let t=[],n=e;for(;n instanceof Gp;)t.push(n.argumentList),n=n.callee;return t.push(n),t}).forEach(e=>{let{functional:n,nonFunctional:r}=Um(e).unwrap();t.columns.push(...n.map(e=>({value:e.value.value,type:`expression`,token:dh(e)})),...r.map(e=>({value:Wm(e).unwrap(),type:`column`,token:dh(e)})))}),t})),[]}interpretChecks(e){return this.tablePartial.checks.push(...e.body.body.map(e=>{let t={},n=e;return t.token=dh(n),n.args[0]instanceof Vp&&(t.name=Gm(Lm(n.args[0]).getValue()[hm.Name]?.at(0)?.value).unwrap_or(void 0)),t.expression=n.callee.value.value,t})),[]}},$se=class{constructor(e,t){this.declarationNode=e,this.env=t,this.project={enums:[],refs:[],tableGroups:[],tables:[],tablePartials:[]}}interpret(){return this.env.project.set(this.declarationNode,this.project),this.project.token=dh(this.declarationNode),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){if(!e)return this.project.name=null,[];let{name:t}=ph(e);return this.project.name=t,[]}interpretBody(e){return e.body.flatMap(e=>{let t=e;switch(t.type?.value.toLowerCase()){case`table`:{let e=new qse(t,this.env).interpret();return this.project.tables.push(this.env.tables.get(t)),e}case`ref`:{let e=new Yse(t,this.env).interpret();return this.project.refs.push(this.env.ref.get(t)),e}case`tablegroup`:{let e=new Xse(t,this.env).interpret();return this.project.tableGroups.push(this.env.tableGroups.get(t)),e}case`enum`:{let e=new Zse(t,this.env).interpret();return this.project.enums.push(this.env.enums.get(t)),e}case`note`:return this.project.note={value:Gm(t.body instanceof Bp?t.body.body[0].callee:t.body.callee).map(hh).unwrap(),token:dh(t)},[];case`tablepartial`:{let e=new Qse(t,this.env).interpret();return this.project.tablePartials.push(this.env.tablePartials.get(t)),e}default:return this.project[t.type.value.toLowerCase()]=Gm(t.body.callee).unwrap(),[]}})}},ece={mysql:new Set([`int`,`integer`,`smallint`,`bigint`,`tinyint`,`mediumint`]),postgres:new Set([`int`,`integer`,`smallint`,`bigint`,`serial`,`bigserial`,`smallserial`]),mssql:new Set([`int`,`integer`,`smallint`,`bigint`,`tinyint`]),oracle:new Set([`int`,`integer`,`smallint`]),snowflake:new Set([`int`,`integer`,`smallint`,`bigint`,`tinyint`])},tce={mysql:new Set([`decimal`,`numeric`,`float`,`double`,`real`]),postgres:new Set([`decimal`,`numeric`,`real`,`float`,`double precision`]),mssql:new Set([`decimal`,`numeric`,`real`,`float`]),oracle:new Set([`number`,`decimal`,`numeric`,`float`,`real`]),snowflake:new Set([`number`,`decimal`,`numeric`,`float`,`double`,`real`])},nce={mysql:new Set([`bool`,`boolean`,`bit`]),postgres:new Set([`bool`,`boolean`]),mssql:new Set([`bit`]),oracle:new Set([]),snowflake:new Set([`boolean`])},rce={mysql:new Set([`varchar`,`char`,`text`,`tinytext`,`mediumtext`,`longtext`,`string`]),postgres:new Set([`varchar`,`char`,`character`,`character varying`,`text`,`string`]),mssql:new Set([`varchar`,`char`,`nvarchar`,`nchar`,`text`,`ntext`,`string`]),oracle:new Set([`varchar`,`varchar2`,`char`,`nvarchar2`,`nchar`,`string`]),snowflake:new Set([`varchar`,`char`,`text`,`string`])},ice={mysql:new Set([`binary`,`varbinary`,`blob`,`tinyblob`,`mediumblob`,`longblob`]),postgres:new Set([`bytea`]),mssql:new Set([`binary`,`varbinary`]),oracle:new Set([`blob`,`raw`]),snowflake:new Set([`binary`,`varbinary`])},ace={mysql:new Set([`date`,`datetime`,`timestamp`,`time`]),postgres:new Set([`date`,`timestamp`,`timestamptz`,`timestamp with time zone`,`timestamp without time zone`,`time`,`timetz`,`time with time zone`,`time without time zone`]),mssql:new Set([`date`,`datetime`,`datetime2`,`smalldatetime`,`time`]),oracle:new Set([`date`,`timestamp`,`timestamp with time zone`,`timestamp with local time zone`]),snowflake:new Set([`date`,`datetime`,`timestamp`,`time`])},oce={mysql:new Set([]),postgres:new Set([`serial`,`smallserial`,`bigserial`]),mssql:new Set([]),oracle:new Set([]),snowflake:new Set([])};function _h(e){return e.toLowerCase().trim().replace(/\s+/g,` `)}function vh(e,t){let n=_h(e);return t?ece[t].has(n):Object.values(ece).some(e=>e.has(n))}function yh(e,t){let n=_h(e);return t?tce[t].has(n):Object.values(tce).some(e=>e.has(n))}function bh(e,t){return vh(e,t)||yh(e,t)}function xh(e,t){let n=_h(e);return t?nce[t].has(n):Object.values(nce).some(e=>e.has(n))}function Sh(e,t){let n=_h(e);return t?rce[t].has(n):Object.values(rce).some(e=>e.has(n))}function Ch(e,t){let n=_h(e);return t?ice[t].has(n):Object.values(ice).some(e=>e.has(n))}function wh(e,t){let n=_h(e);return t?ace[t].has(n):Object.values(ace).some(e=>e.has(n))}function Th(e,t){let n=_h(e);return t?oce[t].has(n):Object.values(oce).some(e=>e.has(n))}function sce(e,t){if(t)return`string`;if(vh(e))return`integer`;if(yh(e))return`real`;if(xh(e))return`bool`;if(Sh(e))return`string`;let n=_h(e);return n===`date`?`date`:n===`time`||n===`timetz`||n===`time with time zone`||n===`time without time zone`?`time`:wh(e)?`datetime`:e}var Eh=class extends Error{},cce=class extends Eh{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},lce=class extends Eh{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},uce=class extends Eh{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},Dh=class extends Eh{},dce=class extends Eh{constructor(e){super(`Invalid unit ${e}`)}},Oh=class extends Eh{},kh=class extends Eh{constructor(){super(`Zone is an abstract class`)}},Ah=`numeric`,jh=`short`,Mh=`long`,Nh={year:Ah,month:Ah,day:Ah},fce={year:Ah,month:jh,day:Ah},pce={year:Ah,month:jh,day:Ah,weekday:jh},mce={year:Ah,month:Mh,day:Ah},hce={year:Ah,month:Mh,day:Ah,weekday:Mh},gce={hour:Ah,minute:Ah},_ce={hour:Ah,minute:Ah,second:Ah},vce={hour:Ah,minute:Ah,second:Ah,timeZoneName:jh},yce={hour:Ah,minute:Ah,second:Ah,timeZoneName:Mh},bce={hour:Ah,minute:Ah,hourCycle:`h23`},xce={hour:Ah,minute:Ah,second:Ah,hourCycle:`h23`},Sce={hour:Ah,minute:Ah,second:Ah,hourCycle:`h23`,timeZoneName:jh},Cce={hour:Ah,minute:Ah,second:Ah,hourCycle:`h23`,timeZoneName:Mh},wce={year:Ah,month:Ah,day:Ah,hour:Ah,minute:Ah},Tce={year:Ah,month:Ah,day:Ah,hour:Ah,minute:Ah,second:Ah},Ece={year:Ah,month:jh,day:Ah,hour:Ah,minute:Ah},Dce={year:Ah,month:jh,day:Ah,hour:Ah,minute:Ah,second:Ah},Oce={year:Ah,month:jh,day:Ah,weekday:jh,hour:Ah,minute:Ah},kce={year:Ah,month:Mh,day:Ah,hour:Ah,minute:Ah,timeZoneName:jh},Ace={year:Ah,month:Mh,day:Ah,hour:Ah,minute:Ah,second:Ah,timeZoneName:jh},jce={year:Ah,month:Mh,day:Ah,weekday:Mh,hour:Ah,minute:Ah,timeZoneName:Mh},Mce={year:Ah,month:Mh,day:Ah,weekday:Mh,hour:Ah,minute:Ah,second:Ah,timeZoneName:Mh},Ph=class{get type(){throw new kh}get name(){throw new kh}get ianaName(){return this.name}get isUniversal(){throw new kh}offsetName(e,t){throw new kh}formatOffset(e,t){throw new kh}offset(e){throw new kh}equals(e){throw new kh}get isValid(){throw new kh}},Nce=null,Pce=class e extends Ph{static get instance(){return Nce===null&&(Nce=new e),Nce}get type(){return`system`}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Qle(e,t,n)}formatOffset(e,t){return sg(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type===`system`}get isValid(){return!0}},Fce=new Map;function Ice(e){let t=Fce.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`}),Fce.set(e,t)),t}var Lce={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Rce(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 zce(e,t){let n=e.formatToParts(t),r=[];for(let e=0;e<n.length;e++){let{type:t,value:i}=n[e],a=Lce[t];t===`era`?r[a]=i:Kh(a)||(r[a]=parseInt(i,10))}return r}var Bce=new Map,Fh=class e extends Ph{static create(t){let n=Bce.get(t);return n===void 0&&Bce.set(t,n=new e(t)),n}static resetCache(){Bce.clear(),Fce.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 Qle(e,t,n,this.name)}formatOffset(e,t){return sg(this.offset(e),t)}offset(e){if(!this.valid)return NaN;let t=new Date(e);if(isNaN(t))return NaN;let n=Ice(this.name),[r,i,a,o,s,c,l]=n.formatToParts?zce(n,t):Rce(n,t);o===`BC`&&(r=-Math.abs(r)+1);let u=rg({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}},Vce={};function Hce(e,t={}){let n=JSON.stringify([e,t]),r=Vce[n];return r||(r=new Intl.ListFormat(e,t),Vce[n]=r),r}var Uce=new Map;function Wce(e,t={}){let n=JSON.stringify([e,t]),r=Uce.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),Uce.set(n,r)),r}var Gce=new Map;function Kce(e,t={}){let n=JSON.stringify([e,t]),r=Gce.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),Gce.set(n,r)),r}var qce=new Map;function Jce(e,t={}){let{base:n,...r}=t,i=JSON.stringify([e,r]),a=qce.get(i);return a===void 0&&(a=new Intl.RelativeTimeFormat(e,t),qce.set(i,a)),a}var Ih=null;function Yce(){return Ih||(Ih=new Intl.DateTimeFormat().resolvedOptions().locale,Ih)}var Xce=new Map;function Zce(e){let t=Xce.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),Xce.set(e,t)),t}var Qce=new Map;function $ce(e){let t=Qce.get(e);if(!t){let n=new Intl.Locale(e);t=`getWeekInfo`in n?n.getWeekInfo():n.weekInfo,`minimalDays`in t||(t={...cle,...t}),Qce.set(e,t)}return t}function ele(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=Wce(e).resolvedOptions(),r=e}catch{let i=e.substring(0,n);t=Wce(i).resolvedOptions(),r=i}let{numberingSystem:i,calendar:a}=t;return[r,i,a]}}function tle(e,t,n){return n||t?(e.includes(`-u-`)||(e+=`-u`),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`),e):e}function nle(e){let t=[];for(let n=1;n<=12;n++){let r=Lg.utc(2009,n,1);t.push(e(r))}return t}function rle(e){let t=[];for(let n=1;n<=7;n++){let r=Lg.utc(2016,11,13+n);t.push(e(r))}return t}function Lh(e,t,n,r){let i=e.listingMode();return i===`error`?null:i===`en`?n(t):r(t)}function ile(e){return e.numberingSystem&&e.numberingSystem!==`latn`?!1:e.numberingSystem===`latn`||!e.locale||e.locale.startsWith(`en`)||Zce(e.locale).numberingSystem===`latn`}var ale=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=Kce(e,t)}}format(e){if(this.inf){let t=this.floor?Math.floor(e):e;return this.inf.format(t)}else return Zh(this.floor?Math.floor(e):Yle(e,3),this.padTo)}},ole=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&&Fh.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=Wce(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()}},sle=class{constructor(e,t,n){this.opts={style:`long`,...n},!t&&Vle()&&(this.rtf=Jce(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):_ue(t,e,this.opts.numeric,this.opts.style!==`long`)}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}},cle={firstDay:1,minimalDays:4,weekend:[6,7]},Rh=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||Hh.defaultLocale;return new e(o||(a?`en-US`:Yce()),n||Hh.defaultNumberingSystem,r||Hh.defaultOutputCalendar,Kle(i)||Hh.defaultWeekSettings,o)}static resetCache(){Ih=null,Uce.clear(),Gce.clear(),qce.clear(),Xce.clear(),Qce.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]=ele(e);this.locale=a,this.numberingSystem=t||o||null,this.outputCalendar=n||s||null,this.weekSettings=r,this.intl=tle(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??=ile(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,Kle(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 Lh(this,e,rue,()=>{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]=nle(t)}return this.monthsCache[i][e]})}weekdays(e,t=!1){return Lh(this,e,sue,()=>{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]=rle(e=>this.extract(e,n,`weekday`))),this.weekdaysCache[r][e]})}meridiems(){return Lh(this,void 0,()=>cue,()=>{if(!this.meridiemCache){let e={hour:`numeric`,hourCycle:`h12`};this.meridiemCache=[Lg.utc(2016,11,13,9),Lg.utc(2016,11,13,19)].map(t=>this.extract(t,e,`dayperiod`))}return this.meridiemCache})}eras(e){return Lh(this,e,fue,()=>{let t={era:e};return this.eraCache[e]||(this.eraCache[e]=[Lg.utc(-40,1,1),Lg.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 ale(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new ole(e,this.intl,t)}relFormatter(e={}){return new sle(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Hce(this.intl,e)}isEnglish(){return this.locale===`en`||this.locale.toLowerCase()===`en-us`||Zce(this.intl).locale.startsWith(`en-us`)}getWeekSettings(){return this.weekSettings?this.weekSettings:Hle()?$ce(this.locale):cle}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})`}},lle=null,zh=class e extends Ph{static get utcInstance(){return lle===null&&(lle=new e(0)),lle}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(ag(n[1],n[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return`fixed`}get name(){return this.fixed===0?`UTC`:`UTC${sg(this.fixed,`narrow`)}`}get ianaName(){return this.fixed===0?`Etc/UTC`:`Etc/GMT${sg(-this.fixed,`narrow`)}`}offsetName(){return this.name}formatOffset(e,t){return sg(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}},ule=class extends Ph{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 Bh(e,t){if(Kh(e)||e===null)return t;if(e instanceof Ph)return e;if(zle(e)){let n=e.toLowerCase();return n===`default`?t:n===`local`||n===`system`?Pce.instance:n===`utc`||n===`gmt`?zh.utcInstance:zh.parseSpecifier(n)||Fh.create(e)}else if(qh(e))return zh.instance(e);else if(typeof e==`object`&&`offset`in e&&typeof e.offset==`function`)return e;else return new ule(e)}var dle={arab:`[٠-٩]`,arabext:`[۰-۹]`,bali:`[᭐-᭙]`,beng:`[০-৯]`,deva:`[०-९]`,fullwide:`[0-9]`,gujr:`[૦-૯]`,hanidec:`[〇|一|二|三|四|五|六|七|八|九]`,khmr:`[០-៩]`,knda:`[೦-೯]`,laoo:`[໐-໙]`,limb:`[᥆-᥏]`,mlym:`[൦-൯]`,mong:`[᠐-᠙]`,mymr:`[၀-၉]`,orya:`[୦-୯]`,tamldec:`[௦-௯]`,telu:`[౦-౯]`,thai:`[๐-๙]`,tibt:`[༠-༩]`,latn:`\\d`},fle={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]},ple=dle.hanidec.replace(/[\[|\]]/g,``).split(``);function mle(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(dle.hanidec)!==-1)t+=ple.indexOf(e[n]);else for(let e in fle){let[n,i]=fle[e];r>=n&&r<=i&&(t+=r-n)}}return parseInt(t,10)}else return t}var hle=new Map;function gle(){hle.clear()}function Vh({numberingSystem:e},t=``){let n=e||`latn`,r=hle.get(n);r===void 0&&(r=new Map,hle.set(n,r));let i=r.get(t);return i===void 0&&(i=RegExp(`${dle[n]}${t}`),r.set(t,i)),i}var _le=()=>Date.now(),vle=`system`,yle=null,ble=null,xle=null,Sle=60,Cle,wle=null,Hh=class{static get now(){return _le}static set now(e){_le=e}static set defaultZone(e){vle=e}static get defaultZone(){return Bh(vle,Pce.instance)}static get defaultLocale(){return yle}static set defaultLocale(e){yle=e}static get defaultNumberingSystem(){return ble}static set defaultNumberingSystem(e){ble=e}static get defaultOutputCalendar(){return xle}static set defaultOutputCalendar(e){xle=e}static get defaultWeekSettings(){return wle}static set defaultWeekSettings(e){wle=Kle(e)}static get twoDigitCutoffYear(){return Sle}static set twoDigitCutoffYear(e){Sle=e%100}static get throwOnInvalid(){return Cle}static set throwOnInvalid(e){Cle=e}static resetCaches(){Rh.resetCache(),Fh.resetCache(),Lg.resetCache(),gle()}},Uh=class{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},Tle=[0,31,59,90,120,151,181,212,243,273,304,334],Ele=[0,31,60,91,121,152,182,213,244,274,305,335];function Wh(e,t){return new Uh(`unit out of range`,`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function Dle(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 Ole(e,t,n){return n+(eg(e)?Ele:Tle)[t-1]}function kle(e,t){let n=eg(e)?Ele:Tle,r=n.findIndex(e=>e<t),i=t-n[r];return{month:r+1,day:i}}function Ale(e,t){return(e-t+7)%7+1}function Gh(e,t=4,n=1){let{year:r,month:i,day:a}=e,o=Ole(r,i,a),s=Ale(Dle(r,i,a),n),c=Math.floor((o-s+14-t)/7),l;return c<1?(l=r-1,c=ig(l,t,n)):c>ig(r,t,n)?(l=r+1,c=1):l=r,{weekYear:l,weekNumber:c,weekday:s,...cg(e)}}function jle(e,t=4,n=1){let{weekYear:r,weekNumber:i,weekday:a}=e,o=Ale(Dle(r,1,t),n),s=tg(r),c=i*7+a-o-7+t,l;c<1?(l=r-1,c+=tg(l)):c>s?(l=r+1,c-=tg(r)):l=r;let{month:u,day:d}=kle(l,c);return{year:l,month:u,day:d,...cg(e)}}function Mle(e){let{year:t,month:n,day:r}=e;return{year:t,ordinal:Ole(t,n,r),...cg(e)}}function Nle(e){let{year:t,ordinal:n}=e,{month:r,day:i}=kle(t,n);return{year:t,month:r,day:i,...cg(e)}}function Ple(e,t){if(!Kh(e.localWeekday)||!Kh(e.localWeekNumber)||!Kh(e.localWeekYear)){if(!Kh(e.weekday)||!Kh(e.weekNumber)||!Kh(e.weekYear))throw new Dh(`Cannot mix locale-based week fields with ISO-based week fields`);return Kh(e.localWeekday)||(e.weekday=e.localWeekday),Kh(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),Kh(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 Fle(e,t=4,n=1){let r=Jh(e.weekYear),i=Xh(e.weekNumber,1,ig(e.weekYear,t,n)),a=Xh(e.weekday,1,7);return r?i?a?!1:Wh(`weekday`,e.weekday):Wh(`week`,e.weekNumber):Wh(`weekYear`,e.weekYear)}function Ile(e){let t=Jh(e.year),n=Xh(e.ordinal,1,tg(e.year));return t?n?!1:Wh(`ordinal`,e.ordinal):Wh(`year`,e.year)}function Lle(e){let t=Jh(e.year),n=Xh(e.month,1,12),r=Xh(e.day,1,ng(e.year,e.month));return t?n?r?!1:Wh(`day`,e.day):Wh(`month`,e.month):Wh(`year`,e.year)}function Rle(e){let{hour:t,minute:n,second:r,millisecond:i}=e,a=Xh(t,0,23)||t===24&&n===0&&r===0&&i===0,o=Xh(n,0,59),s=Xh(r,0,59),c=Xh(i,0,999);return a?o?s?c?!1:Wh(`millisecond`,i):Wh(`second`,r):Wh(`minute`,n):Wh(`hour`,t)}function Kh(e){return e===void 0}function qh(e){return typeof e==`number`}function Jh(e){return typeof e==`number`&&e%1==0}function zle(e){return typeof e==`string`}function Ble(e){return Object.prototype.toString.call(e)===`[object Date]`}function Vle(){try{return typeof Intl<`u`&&!!Intl.RelativeTimeFormat}catch{return!1}}function Hle(){try{return typeof Intl<`u`&&!!Intl.Locale&&(`weekInfo`in Intl.Locale.prototype||`getWeekInfo`in Intl.Locale.prototype)}catch{return!1}}function Ule(e){return Array.isArray(e)?e:[e]}function Wle(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 Gle(e,t){return t.reduce((t,n)=>(t[n]=e[n],t),{})}function Yh(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Kle(e){if(e==null)return null;if(typeof e!=`object`)throw new Oh(`Week settings must be an object`);if(!Xh(e.firstDay,1,7)||!Xh(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(e=>!Xh(e,1,7)))throw new Oh(`Invalid week settings`);return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function Xh(e,t,n){return Jh(e)&&e>=t&&e<=n}function qle(e,t){return e-t*Math.floor(e/t)}function Zh(e,t=2){let n=e<0,r;return r=n?`-`+(``+-e).padStart(t,`0`):(``+e).padStart(t,`0`),r}function Qh(e){if(!(Kh(e)||e===null||e===``))return parseInt(e,10)}function $h(e){if(!(Kh(e)||e===null||e===``))return parseFloat(e)}function Jle(e){if(!(Kh(e)||e===null||e===``)){let t=parseFloat(`0.`+e)*1e3;return Math.floor(t)}}function Yle(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 eg(e){return e%4==0&&(e%100!=0||e%400==0)}function tg(e){return eg(e)?366:365}function ng(e,t){let n=qle(t-1,12)+1,r=e+(t-n)/12;return n===2?eg(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function rg(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 Xle(e,t,n){return-Ale(Dle(e,1,t),n)+t-1}function ig(e,t=4,n=1){let r=Xle(e,t,n),i=Xle(e+1,t,n);return(tg(e)-r+i)/7}function Zle(e){return e>99?e:e>Hh.twoDigitCutoffYear?1900+e:2e3+e}function Qle(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 ag(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 $le(e){let t=Number(e);if(typeof e==`boolean`||e===``||!Number.isFinite(t))throw new Oh(`Invalid unit value ${e}`);return t}function og(e,t){let n={};for(let r in e)if(Yh(e,r)){let i=e[r];if(i==null)continue;n[t(r)]=$le(i)}return n}function sg(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}${Zh(n,2)}:${Zh(r,2)}`;case`narrow`:return`${i}${n}${r>0?`:${r}`:``}`;case`techie`:return`${i}${Zh(n,2)}${Zh(r,2)}`;default:throw RangeError(`Value format ${t} is out of range for property format`)}}function cg(e){return Gle(e,[`hour`,`minute`,`second`,`millisecond`])}var eue=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],tue=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],nue=[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`];function rue(e){switch(e){case`narrow`:return[...nue];case`short`:return[...tue];case`long`:return[...eue];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}}var iue=[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],aue=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],oue=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function sue(e){switch(e){case`narrow`:return[...oue];case`short`:return[...aue];case`long`:return[...iue];case`numeric`:return[`1`,`2`,`3`,`4`,`5`,`6`,`7`];default:return null}}var cue=[`AM`,`PM`],lue=[`Before Christ`,`Anno Domini`],uue=[`BC`,`AD`],due=[`B`,`A`];function fue(e){switch(e){case`narrow`:return[...due];case`short`:return[...uue];case`long`:return[...lue];default:return null}}function pue(e){return cue[e.hour<12?0:1]}function mue(e,t){return sue(t)[e.weekday-1]}function hue(e,t){return rue(t)[e.month-1]}function gue(e,t){return fue(t)[e.year<0?0:1]}function _ue(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 vue(e,t){let n=``;for(let r of e)r.literal?n+=r.val:n+=t(r.val);return n}var yue={D:Nh,DD:fce,DDD:mce,DDDD:hce,t:gce,tt:_ce,ttt:vce,tttt:yce,T:bce,TT:xce,TTT:Sce,TTTT:Cce,f:wce,ff:Ece,fff:kce,ffff:jce,F:Tce,FF:Dce,FFF:Ace,FFFF:Mce},lg=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 yue[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 Zh(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?pue(t):a({hour:`numeric`,hourCycle:`h12`},`dayperiod`),c=(e,n)=>r?hue(t,e):a(n?{month:e}:{month:e,day:`numeric`},`month`),l=(e,n)=>r?mue(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?gue(t,e):a({era:e},`era`);return vue(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 vue(o,a(c,{isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]}))}},bue=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function ug(...e){let t=e.reduce((e,t)=>e+t.source,``);return RegExp(`^${t}$`)}function dg(...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 fg(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 xue(...e){return(t,n)=>{let r={},i;for(i=0;i<e.length;i++)r[e[i]]=Qh(t[n+i]);return[r,null,n+i]}}var Sue=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Cue=`(?:${Sue.source}?(?:\\[(${bue.source})\\])?)?`,wue=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Tue=RegExp(`${wue.source}${Cue}`),Eue=RegExp(`(?:[Tt]${Tue.source})?`),Due=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Oue=/(\d{4})-?W(\d\d)(?:-?(\d))?/,kue=/(\d{4})-?(\d{3})/,Aue=xue(`weekYear`,`weekNumber`,`weekDay`),jue=xue(`year`,`ordinal`),Mue=/(\d{4})-(\d\d)-(\d\d)/,Nue=RegExp(`${wue.source} ?(?:${Sue.source}|(${bue.source}))?`),Pue=RegExp(`(?: ${Nue.source})?`);function pg(e,t,n){let r=e[t];return Kh(r)?n:Qh(r)}function Fue(e,t){return[{year:pg(e,t),month:pg(e,t+1,1),day:pg(e,t+2,1)},null,t+3]}function mg(e,t){return[{hours:pg(e,t,0),minutes:pg(e,t+1,0),seconds:pg(e,t+2,0),milliseconds:Jle(e[t+3])},null,t+4]}function hg(e,t){let n=!e[t]&&!e[t+1],r=ag(e[t+1],e[t+2]);return[{},n?null:zh.instance(r),t+3]}function gg(e,t){return[{},e[t]?Fh.create(e[t]):null,t+1]}var Iue=RegExp(`^T?${wue.source}$`),Lue=/^-?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 Rue(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($h(n)),months:f($h(r)),weeks:f($h(i)),days:f($h(a)),hours:f($h(o)),minutes:f($h(s)),seconds:f($h(c),c===`-0`),milliseconds:f(Jle(l),d)}]}var zue={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Bue(e,t,n,r,i,a,o){let s={year:t.length===2?Zle(Qh(t)):Qh(t),month:tue.indexOf(n)+1,day:Qh(r),hour:Qh(i),minute:Qh(a)};return o&&(s.second=Qh(o)),e&&(s.weekday=e.length>3?iue.indexOf(e)+1:aue.indexOf(e)+1),s}var Vue=/^(?:(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 Hue(e){let[,t,n,r,i,a,o,s,c,l,u,d]=e,f=Bue(t,i,r,n,a,o,s),p;return p=c?zue[c]:l?0:ag(u,d),[f,new zh(p)]}function Uue(e){return e.replace(/\([^()]*\)|[\n\t]/g,` `).replace(/(\s\s+)/g,` `).trim()}var Wue=/^(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$/,Gue=/^(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$/,Kue=/^(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 que(e){let[,t,n,r,i,a,o,s]=e;return[Bue(t,i,r,n,a,o,s),zh.utcInstance]}function Jue(e){let[,t,n,r,i,a,o,s]=e;return[Bue(t,s,n,r,i,a,o),zh.utcInstance]}var Yue=ug(Due,Eue),Xue=ug(Oue,Eue),Zue=ug(kue,Eue),Que=ug(Tue),$ue=dg(Fue,mg,hg,gg),ede=dg(Aue,mg,hg,gg),tde=dg(jue,mg,hg,gg),nde=dg(mg,hg,gg);function rde(e){return fg(e,[Yue,$ue],[Xue,ede],[Zue,tde],[Que,nde])}function ide(e){return fg(Uue(e),[Vue,Hue])}function ade(e){return fg(e,[Wue,que],[Gue,que],[Kue,Jue])}function ode(e){return fg(e,[Lue,Rue])}var sde=dg(mg);function cde(e){return fg(e,[Iue,sde])}var lde=ug(Mue,Pue),ude=ug(Nue),dde=dg(mg,hg,gg);function fde(e){return fg(e,[lde,$ue],[ude,dde])}var pde=`Invalid Duration`,mde={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}},hde={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},...mde},_g=146097/400,vg=146097/4800,gde={years:{quarters:4,months:12,weeks:_g/7,days:_g,hours:_g*24,minutes:_g*24*60,seconds:_g*24*60*60,milliseconds:_g*24*60*60*1e3},quarters:{months:3,weeks:_g/28,days:_g/4,hours:_g*24/4,minutes:_g*24*60/4,seconds:_g*24*60*60/4,milliseconds:_g*24*60*60*1e3/4},months:{weeks:vg/7,days:vg,hours:vg*24,minutes:vg*24*60,seconds:vg*24*60*60,milliseconds:vg*24*60*60*1e3},...mde},yg=[`years`,`quarters`,`months`,`weeks`,`days`,`hours`,`minutes`,`seconds`,`milliseconds`],_de=yg.slice(0).reverse();function bg(e,t,n=!1){return new xg({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 vde(e,t){let n=t.milliseconds??0;for(let r of _de.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function yde(e,t){let n=vde(e,t)<0?-1:1;yg.reduceRight((r,i)=>{if(Kh(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),yg.reduce((n,r)=>{if(Kh(t[r]))return n;if(n){let i=t[n]%1;t[n]-=i,t[r]+=i*e[n][r]}return r},null)}function bde(e){let t={};for(let[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}var xg=class e{constructor(e){let t=e.conversionAccuracy===`longterm`||!1,n=t?gde:hde;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||Rh.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 Oh(`Duration.fromObject: argument expected to be an object, got ${t===null?`null`:typeof t}`);return new e({values:og(t,e.normalizeUnit),loc:Rh.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(qh(t))return e.fromMillis(t);if(e.isDuration(t))return t;if(typeof t==`object`)return e.fromObject(t);throw new Oh(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){let[r]=ode(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]=cde(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 Oh(`need to specify a reason the Duration is invalid`);let r=t instanceof Uh?t:new Uh(t,n);if(Hh.throwOnInvalid)throw new uce(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 dce(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?lg.create(this.loc,n).formatDurationFromString(this,e):pde}toHuman(e={}){if(!this.isValid)return pde;let t=e.showZeros!==!1,n=yg.map(n=>{let r=this.values[n];return Kh(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+=Yle(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},Lg.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?vde(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 yg)(Yh(n.values,e)||Yh(this.values,e))&&(r[e]=n.get(e)+this.get(e));return bg(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]=$le(e(this.values[n],n));return bg(this,{values:t},!0)}get(t){return this[e.normalizeUnit(t)]}set(t){if(!this.isValid)return this;let n={...this.values,...og(t,e.normalizeUnit)};return bg(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 bg(this,i)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return yde(this.matrix,e),bg(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=bde(this.normalize().shiftToAll().toObject());return bg(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 yg)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;qh(i[e])&&(t+=i[e]);let o=Math.trunc(t);n[e]=o,r[e]=(t*1e3-o*1e3)/1e3}else qh(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 yde(this.matrix,n),bg(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 bg(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;let e=bde(this.values);return bg(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 yg)if(!t(this.values[n],e.values[n]))return!1;return!0}},Sg=`Invalid Interval`;function xde(e,t){return!e||!e.isValid?Cg.invalid(`missing or invalid start`):!t||!t.isValid?Cg.invalid(`missing or invalid end`):t<e?Cg.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 Cg=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 Oh(`need to specify a reason the Interval is invalid`);let r=t instanceof Uh?t:new Uh(t,n);if(Hh.throwOnInvalid)throw new lce(r);return new e({invalid:r})}static fromDateTimes(t,n){let r=Rg(t),i=Rg(n);return xde(r,i)??new e({start:r,end:i})}static after(t,n){let r=xg.fromDurationLike(n),i=Rg(t);return e.fromDateTimes(i,i.plus(r))}static before(t,n){let r=xg.fromDurationLike(n),i=Rg(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=Lg.fromISO(r,n),a=t.isValid}catch{a=!1}let o,s;try{o=Lg.fromISO(i,n),s=o.isValid}catch{s=!1}if(a&&s)return e.fromDateTimes(t,o);if(a){let r=xg.fromISO(i,n);if(r.isValid)return e.after(t,r)}else if(s){let t=xg.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(Rg).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=xg.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()})`:Sg}[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=Nh,t={}){return this.isValid?lg.create(this.s.loc.clone(t),e).formatInterval(this):Sg}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Sg}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Sg}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Sg}toFormat(e,{separator:t=` – `}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:Sg}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):xg.invalid(this.invalidReason)}mapEndpoints(t){return e.fromDateTimes(t(this.s),t(this.e))}},wg=class{static hasDST(e=Hh.defaultZone){let t=Lg.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return Fh.isValidZone(e)}static normalizeZone(e){return Bh(e,Hh.defaultZone)}static getStartOfWeek({locale:e=null,locObj:t=null}={}){return(t||Rh.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:t=null}={}){return(t||Rh.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:t=null}={}){return(t||Rh.create(e)).getWeekendDays().slice()}static months(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||Rh.create(t,n,i)).months(e)}static monthsFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||Rh.create(t,n,i)).months(e,!0)}static weekdays(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Rh.create(t,n,null)).weekdays(e)}static weekdaysFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Rh.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return Rh.create(e).meridiems()}static eras(e=`short`,{locale:t=null}={}){return Rh.create(t,null,`gregory`).eras(e)}static features(){return{relative:Vle(),localeWeek:Hle()}}};function Sde(e,t){let n=e=>e.toUTC(0,{keepLocalTime:!0}).startOf(`day`).valueOf(),r=n(t)-n(e);return Math.floor(xg.fromMillis(r).as(`days`))}function Cde(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=Sde(e,t);return(n-n%7)/7}],[`days`,Sde]],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 wde(e,t,n,r){let[i,a,o,s]=Cde(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=xg.fromObject(a,r);return l.length>0?xg.fromMillis(c,r).shiftTo(...l).plus(u):u}var Tde=`missing Intl.DateTimeFormat.formatToParts support`;function Tg(e,t=e=>e){return{regex:e,deser:([e])=>t(mle(e))}}var Ede=`[ \xA0]`,Dde=new RegExp(Ede,`g`);function Ode(e){return e.replace(/\./g,`\\.?`).replace(Dde,Ede)}function kde(e){return e.replace(/\./g,``).replace(Dde,` `).toLowerCase()}function Eg(e,t){return e===null?null:{regex:RegExp(e.map(Ode).join(`|`)),deser:([n])=>e.findIndex(e=>kde(n)===kde(e))+t}}function Ade(e,t){return{regex:e,deser:([,e,t])=>ag(e,t),groups:t}}function Dg(e){return{regex:e,deser:([e])=>e}}function jde(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,`\\$&`)}function Mde(e,t){let n=Vh(t),r=Vh(t,`{2}`),i=Vh(t,`{3}`),a=Vh(t,`{4}`),o=Vh(t,`{6}`),s=Vh(t,`{1,2}`),c=Vh(t,`{1,3}`),l=Vh(t,`{1,6}`),u=Vh(t,`{1,9}`),d=Vh(t,`{2,4}`),f=Vh(t,`{4,6}`),p=e=>({regex:RegExp(jde(e.val)),deser:([e])=>e,literal:!0}),m=(m=>{if(e.literal)return p(m);switch(m.val){case`G`:return Eg(t.eras(`short`),0);case`GG`:return Eg(t.eras(`long`),0);case`y`:return Tg(l);case`yy`:return Tg(d,Zle);case`yyyy`:return Tg(a);case`yyyyy`:return Tg(f);case`yyyyyy`:return Tg(o);case`M`:return Tg(s);case`MM`:return Tg(r);case`MMM`:return Eg(t.months(`short`,!0),1);case`MMMM`:return Eg(t.months(`long`,!0),1);case`L`:return Tg(s);case`LL`:return Tg(r);case`LLL`:return Eg(t.months(`short`,!1),1);case`LLLL`:return Eg(t.months(`long`,!1),1);case`d`:return Tg(s);case`dd`:return Tg(r);case`o`:return Tg(c);case`ooo`:return Tg(i);case`HH`:return Tg(r);case`H`:return Tg(s);case`hh`:return Tg(r);case`h`:return Tg(s);case`mm`:return Tg(r);case`m`:return Tg(s);case`q`:return Tg(s);case`qq`:return Tg(r);case`s`:return Tg(s);case`ss`:return Tg(r);case`S`:return Tg(c);case`SSS`:return Tg(i);case`u`:return Dg(u);case`uu`:return Dg(s);case`uuu`:return Tg(n);case`a`:return Eg(t.meridiems(),0);case`kkkk`:return Tg(a);case`kk`:return Tg(d,Zle);case`W`:return Tg(s);case`WW`:return Tg(r);case`E`:case`c`:return Tg(n);case`EEE`:return Eg(t.weekdays(`short`,!1),1);case`EEEE`:return Eg(t.weekdays(`long`,!1),1);case`ccc`:return Eg(t.weekdays(`short`,!0),1);case`cccc`:return Eg(t.weekdays(`long`,!0),1);case`Z`:case`ZZ`:return Ade(RegExp(`([+-]${s.source})(?::(${r.source}))?`),2);case`ZZZ`:return Ade(RegExp(`([+-]${s.source})(${r.source})?`),2);case`z`:return Dg(/[a-z_+-/]{1,256}?/i);case` `:return Dg(/[^\S\n\r]/);default:return p(m)}})(e)||{invalidReason:Tde};return m.token=e,m}var Nde={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 Pde(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=Nde[o];if(typeof s==`object`&&(s=s[a]),s)return{literal:!1,val:s}}function Fde(e){return[`^${e.map(e=>e.regex).reduce((e,t)=>`${e}(${t.source})`,``)}$`,e]}function Ide(e,t,n){let r=e.match(t);if(r){let e={},t=1;for(let i in n)if(Yh(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 Lde(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 Kh(e.z)||(n=Fh.create(e.z)),Kh(e.Z)||(n||=new zh(e.Z),r=e.Z),Kh(e.q)||(e.M=(e.q-1)*3+1),Kh(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),Kh(e.u)||(e.S=Jle(e.u)),[Object.keys(e).reduce((n,r)=>{let i=t(r);return i&&(n[i]=e[r]),n},{}),n,r]}var Rde=null;function zde(){return Rde||=Lg.fromMillis(1555555555555),Rde}function Bde(e,t){if(e.literal)return e;let n=Gde(lg.macroTokenToFormatOpts(e.val),t);return n==null||n.includes(void 0)?e:n}function Vde(e,t){return Array.prototype.concat(...e.map(e=>Bde(e,t)))}var Hde=class{constructor(e,t){if(this.locale=e,this.format=t,this.tokens=Vde(lg.parseFormat(t),e),this.units=this.tokens.map(t=>Mde(t,e)),this.disqualifyingUnit=this.units.find(e=>e.invalidReason),!this.disqualifyingUnit){let[e,t]=Fde(this.units);this.regex=RegExp(e,`i`),this.handlers=t}}explainFromTokens(e){if(this.isValid){let[t,n]=Ide(e,this.regex,this.handlers),[r,i,a]=n?Lde(n):[null,null,void 0];if(Yh(n,`a`)&&Yh(n,`H`))throw new Dh(`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 Ude(e,t,n){return new Hde(e,n).explainFromTokens(t)}function Wde(e,t,n){let{result:r,zone:i,specificOffset:a,invalidReason:o}=Ude(e,t,n);return[r,i,a,o]}function Gde(e,t){if(!e)return null;let n=lg.create(t,e).dtFormatter(zde()),r=n.formatToParts(),i=n.resolvedOptions();return r.map(t=>Pde(t,e,i))}var Kde=`Invalid DateTime`,qde=864e13;function Og(e){return new Uh(`unsupported zone`,`the zone "${e.name}" is not supported`)}function Jde(e){return e.weekData===null&&(e.weekData=Gh(e.c)),e.weekData}function Yde(e){return e.localWeekData===null&&(e.localWeekData=Gh(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function kg(e,t){let n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new Lg({...n,...t,old:n})}function Xde(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 Ag(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 jg(e,t,n){return Xde(rg(e),t,n)}function Zde(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,ng(r,i))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},o=xg.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]=Xde(rg(a),n,e.zone);return o!==0&&(s+=o,c=e.zone.offset(s)),{ts:s,o:c}}function Mg(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=Lg.fromObject(e,{...n,zone:r,specificOffset:a});return o?i:i.setZone(s)}else return Lg.invalid(new Uh(`unparsable`,`the input "${i}" can't be parsed as ${r}`))}function Ng(e,t,n=!0){return e.isValid?lg.create(Rh.create(`en-US`),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function Qde(e,t,n){let r=e.c.year>9999||e.c.year<0,i=``;if(r&&e.c.year>=0&&(i+=`+`),i+=Zh(e.c.year,r?6:4),n===`year`)return i;if(t){if(i+=`-`,i+=Zh(e.c.month),n===`month`)return i;i+=`-`}else if(i+=Zh(e.c.month),n===`month`)return i;return i+=Zh(e.c.day),i}function $de(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+=Zh(e.c.hour),o===`hour`)break;if(t){if(c+=`:`,c+=Zh(e.c.minute),o===`minute`)break;s&&(c+=`:`,c+=Zh(e.c.second))}else{if(c+=Zh(e.c.minute),o===`minute`)break;s&&(c+=Zh(e.c.second))}if(o===`second`)break;s&&(!r||e.c.millisecond!==0)&&(c+=`.`,c+=Zh(e.c.millisecond,3))}return i&&(e.isOffsetFixed&&e.offset===0&&!a?c+=`Z`:e.o<0?(c+=`-`,c+=Zh(Math.trunc(-e.o/60)),c+=`:`,c+=Zh(Math.trunc(-e.o%60))):(c+=`+`,c+=Zh(Math.trunc(e.o/60)),c+=`:`,c+=Zh(Math.trunc(e.o%60)))),a&&(c+=`[`+e.zone.ianaName+`]`),c}var efe={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},tfe={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},nfe={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Pg=[`year`,`month`,`day`,`hour`,`minute`,`second`,`millisecond`],rfe=[`weekYear`,`weekNumber`,`weekday`,`hour`,`minute`,`second`,`millisecond`],ife=[`year`,`ordinal`,`hour`,`minute`,`second`,`millisecond`];function Fg(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 dce(e);return t}function afe(e){switch(e.toLowerCase()){case`localweekday`:case`localweekdays`:return`localWeekday`;case`localweeknumber`:case`localweeknumbers`:return`localWeekNumber`;case`localweekyear`:case`localweekyears`:return`localWeekYear`;default:return Fg(e)}}function ofe(e){if(Ig===void 0&&(Ig=Hh.now()),e.type!==`iana`)return e.offset(Ig);let t=e.name,n=ufe.get(t);return n===void 0&&(n=e.offset(Ig),ufe.set(t,n)),n}function sfe(e,t){let n=Bh(t.zone,Hh.defaultZone);if(!n.isValid)return Lg.invalid(Og(n));let r=Rh.fromObject(t),i,a;if(Kh(e.year))i=Hh.now();else{for(let t of Pg)Kh(e[t])&&(e[t]=efe[t]);let t=Lle(e)||Rle(e);if(t)return Lg.invalid(t);let r=ofe(n);[i,a]=jg(e,r,n)}return new Lg({ts:i,zone:n,loc:r,o:a})}function cfe(e,t,n){let r=Kh(n.round)?!0:n.round,i=Kh(n.rounding)?`trunc`:n.rounding,a=(e,a)=>(e=Yle(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 lfe(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]}var Ig,ufe=new Map,Lg=class e{constructor(e){let t=e.zone||Hh.defaultZone,n=e.invalid||(Number.isNaN(e.ts)?new Uh(`invalid input`):null)||(t.isValid?null:Og(t));this.ts=Kh(e.ts)?Hh.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=qh(e.o)&&!e.old?e.o:t.offset(this.ts);r=Ag(this.ts,a),n=Number.isNaN(r.year)?new Uh(`invalid input`):null,r=n?null:r,i=n?null:a}this._zone=t,this.loc=e.loc||Rh.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]=lfe(arguments),[n,r,i,a,o,s,c]=t;return sfe({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static utc(){let[e,t]=lfe(arguments),[n,r,i,a,o,s,c]=t;return e.zone=zh.utcInstance,sfe({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static fromJSDate(t,n={}){let r=Ble(t)?t.valueOf():NaN;if(Number.isNaN(r))return e.invalid(`invalid input`);let i=Bh(n.zone,Hh.defaultZone);return i.isValid?new e({ts:r,zone:i,loc:Rh.fromObject(n)}):e.invalid(Og(i))}static fromMillis(t,n={}){if(qh(t))return t<-qde||t>qde?e.invalid(`Timestamp out of range`):new e({ts:t,zone:Bh(n.zone,Hh.defaultZone),loc:Rh.fromObject(n)});throw new Oh(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,n={}){if(qh(t))return new e({ts:t*1e3,zone:Bh(n.zone,Hh.defaultZone),loc:Rh.fromObject(n)});throw new Oh(`fromSeconds requires a numerical input`)}static fromObject(t,n={}){t||={};let r=Bh(n.zone,Hh.defaultZone);if(!r.isValid)return e.invalid(Og(r));let i=Rh.fromObject(n),a=og(t,afe),{minDaysInFirstWeek:o,startOfWeek:s}=Ple(a,i),c=Hh.now(),l=Kh(n.specificOffset)?r.offset(c):n.specificOffset,u=!Kh(a.ordinal),d=!Kh(a.year),f=!Kh(a.month)||!Kh(a.day),p=d||f,m=a.weekYear||a.weekNumber;if((p||u)&&m)throw new Dh(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(f&&u)throw new Dh(`Can't mix ordinal dates with month/day`);let h=m||a.weekday&&!p,g,_,ee=Ag(c,l);h?(g=rfe,_=tfe,ee=Gh(ee,o,s)):u?(g=ife,_=nfe,ee=Mle(ee)):(g=Pg,_=efe);let v=!1;for(let e of g){let t=a[e];Kh(t)?v?a[e]=_[e]:a[e]=ee[e]:v=!0}let y=(h?Fle(a,o,s):u?Ile(a):Lle(a))||Rle(a);if(y)return e.invalid(y);let[b,te]=jg(h?jle(a,o,s):u?Nle(a):a,l,r),ne=new e({ts:b,zone:r,o:te,loc:i});return a.weekday&&p&&t.weekday!==ne.weekday?e.invalid(`mismatched weekday`,`you can't specify both a weekday of ${a.weekday} and a date of ${ne.toISO()}`):ne.isValid?ne:e.invalid(ne.invalid)}static fromISO(e,t={}){let[n,r]=rde(e);return Mg(n,r,t,`ISO 8601`,e)}static fromRFC2822(e,t={}){let[n,r]=ide(e);return Mg(n,r,t,`RFC 2822`,e)}static fromHTTP(e,t={}){let[n,r]=ade(e);return Mg(n,r,t,`HTTP`,t)}static fromFormat(t,n,r={}){if(Kh(t)||Kh(n))throw new Oh(`fromFormat requires an input string and a format`);let{locale:i=null,numberingSystem:a=null}=r,[o,s,c,l]=Wde(Rh.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0}),t,n);return l?e.invalid(l):Mg(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]=fde(e);return Mg(n,r,t,`SQL`,e)}static invalid(t,n=null){if(!t)throw new Oh(`need to specify a reason the DateTime is invalid`);let r=t instanceof Uh?t:new Uh(t,n);if(Hh.throwOnInvalid)throw new cce(r);return new e({invalid:r})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){let n=Gde(e,Rh.fromObject(t));return n?n.map(e=>e?e.val:null).join(``):null}static expandFormat(e,t={}){return Vde(lg.parseFormat(e),Rh.fromObject(t)).map(e=>e.val).join(``)}static resetCache(){Ig=void 0,ufe.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?Jde(this).weekYear:NaN}get weekNumber(){return this.isValid?Jde(this).weekNumber:NaN}get weekday(){return this.isValid?Jde(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Yde(this).weekday:NaN}get localWeekNumber(){return this.isValid?Yde(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Yde(this).weekYear:NaN}get ordinal(){return this.isValid?Mle(this.c).ordinal:NaN}get monthShort(){return this.isValid?wg.months(`short`,{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?wg.months(`long`,{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?wg.weekdays(`short`,{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?wg.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=rg(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=Ag(s,a),u=Ag(c,o);return l.hour===u.hour&&l.minute===u.minute&&l.second===u.second&&l.millisecond===u.millisecond?[kg(this,{ts:s}),kg(this,{ts:c})]:[this]}get isInLeapYear(){return eg(this.year)}get daysInMonth(){return ng(this.year,this.month)}get daysInYear(){return this.isValid?tg(this.year):NaN}get weeksInWeekYear(){return this.isValid?ig(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?ig(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){let{locale:t,numberingSystem:n,calendar:r}=lg.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:r}}toUTC(e=0,t={}){return this.setZone(zh.instance(e),t)}toLocal(){return this.setZone(Hh.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=Bh(t,Hh.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]=jg(r,n,t)}return kg(this,{ts:e,zone:t})}else return e.invalid(Og(t))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){let r=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return kg(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let t=og(e,afe),{minDaysInFirstWeek:n,startOfWeek:r}=Ple(t,this.loc),i=!Kh(t.weekYear)||!Kh(t.weekNumber)||!Kh(t.weekday),a=!Kh(t.ordinal),o=!Kh(t.year),s=!Kh(t.month)||!Kh(t.day),c=o||s,l=t.weekYear||t.weekNumber;if((c||a)&&l)throw new Dh(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(s&&a)throw new Dh(`Can't mix ordinal dates with month/day`);let u;i?u=jle({...Gh(this.c,n,r),...t},n,r):Kh(t.ordinal)?(u={...this.toObject(),...t},Kh(t.day)&&(u.day=Math.min(ng(u.year,u.month),u.day))):u=Nle({...Mle(this.c),...t});let[d,f]=jg(u,this.o,this.zone);return kg(this,{ts:d,o:f})}plus(e){if(!this.isValid)return this;let t=xg.fromDurationLike(e);return kg(this,Zde(this,t))}minus(e){if(!this.isValid)return this;let t=xg.fromDurationLike(e).negate();return kg(this,Zde(this,t))}startOf(e,{useLocaleWeeks:t=!1}={}){if(!this.isValid)return this;let n={},r=xg.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?lg.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):Kde}toLocaleString(e=Nh,t={}){return this.isValid?lg.create(this.loc.clone(t),e).formatDateTime(this):Kde}toLocaleParts(e={}){return this.isValid?lg.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=Fg(a);let o=e===`extended`,s=Qde(this,o,a);return Pg.indexOf(a)>=3&&(s+=`T`),s+=$de(this,o,t,n,r,i,a),s}toISODate({format:e=`extended`,precision:t=`day`}={}){return this.isValid?Qde(this,e===`extended`,Fg(t)):null}toISOWeekDate(){return Ng(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=Fg(o),(r&&Pg.indexOf(o)>=3?`T`:``)+$de(this,a===`extended`,t,e,n,i,o)):null}toRFC2822(){return Ng(this,`EEE, dd LLL yyyy HH:mm:ss ZZZ`,!1)}toHTTP(){return Ng(this.toUTC(),`EEE, dd LLL yyyy HH:mm:ss 'GMT'`)}toSQLDate(){return this.isValid?Qde(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`)),Ng(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Kde}[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 xg.invalid(`created by diffing an invalid DateTime`);let r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=Ule(t).map(xg.normalizeUnit),a=e.valueOf()>this.valueOf(),o=wde(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?Cg.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),cfe(n,this.plus(r),{...t,numeric:`always`,units:i,unit:a})}toRelativeCalendar(t={}){return this.isValid?cfe(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 Oh(`min requires all arguments be DateTimes`);return Wle(t,e=>e.valueOf(),Math.min)}static max(...t){if(!t.every(e.isDateTime))throw new Oh(`max requires all arguments be DateTimes`);return Wle(t,e=>e.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){let{locale:r=null,numberingSystem:i=null}=n;return Ude(Rh.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 Hde(Rh.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0}),e)}static fromFormatParser(t,n,r={}){if(Kh(t)||Kh(n))throw new Oh(`fromFormatParser requires an input string and a format parser`);let{locale:i=null,numberingSystem:a=null}=r,o=Rh.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0});if(!o.equals(n.locale))throw new Oh(`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):Mg(s,c,r,`format ${n.format}`,t,l)}static get DATE_SHORT(){return Nh}static get DATE_MED(){return fce}static get DATE_MED_WITH_WEEKDAY(){return pce}static get DATE_FULL(){return mce}static get DATE_HUGE(){return hce}static get TIME_SIMPLE(){return gce}static get TIME_WITH_SECONDS(){return _ce}static get TIME_WITH_SHORT_OFFSET(){return vce}static get TIME_WITH_LONG_OFFSET(){return yce}static get TIME_24_SIMPLE(){return bce}static get TIME_24_WITH_SECONDS(){return xce}static get TIME_24_WITH_SHORT_OFFSET(){return Sce}static get TIME_24_WITH_LONG_OFFSET(){return Cce}static get DATETIME_SHORT(){return wce}static get DATETIME_SHORT_WITH_SECONDS(){return Tce}static get DATETIME_MED(){return Ece}static get DATETIME_MED_WITH_SECONDS(){return Dce}static get DATETIME_MED_WITH_WEEKDAY(){return Oce}static get DATETIME_FULL(){return kce}static get DATETIME_FULL_WITH_SECONDS(){return Ace}static get DATETIME_HUGE(){return jce}static get DATETIME_HUGE_WITH_SECONDS(){return Mce}};function Rg(e){if(Lg.isDateTime(e))return e;if(e&&e.valueOf&&qh(e.valueOf()))return Lg.fromJSDate(e);if(e&&typeof e==`object`)return Lg.fromObject(e);throw new Oh(`Unknown datetime argument: ${e}, of type ${typeof e}`)}function dfe(e){return eh(e)?e.expression.variable?.value?.toLowerCase()===`null`:e instanceof Yp}function ffe(e){return Gm(e).unwrap_or(void 0)===``}function pfe(e){let t=Km(e);if(t!==null)return t;if(Fm(e)&&e instanceof Fp&&e.expression){let t=e.op?.value,n=Km(e.expression);if(n!==null)return t===`-`?-n:n}return null}function zg(e){if(e==null)return null;if(typeof e==`number`)return e;if(typeof e==`string`){let t=Number(e);return isNaN(t)?null:t}if(typeof e==`boolean`)return e?1:0;let t=pfe(e);if(t!==null)return t;let n=Gm(e).unwrap_or(void 0);if(n!==void 0){let e=Number(n);if(!isNaN(e))return e}return null}function mfe(e){if(e==null)return null;if(typeof e==`number`)return Number.isInteger(e)?e:null;if(typeof e==`string`){let t=Number(e);return isNaN(t)||!Number.isInteger(t)?null:t}if(typeof e==`boolean`)return e?1:0;let t=pfe(e);if(t!==null)return Number.isInteger(t)?t:null;let n=Gm(e).unwrap_or(void 0);if(n!==void 0){let e=Number(n);if(!isNaN(e)&&Number.isInteger(e))return e}return null}var hfe=[`true`,`yes`,`y`,`t`,`1`],gfe=[`false`,`no`,`n`,`f`,`0`];function Bg(e){if(e==null)return null;if(typeof e==`boolean`)return e;if(typeof e==`number`)return e===0?!1:e===1?!0:null;if(typeof e==`string`){let t=e.toLowerCase();return hfe.includes(t)?!0:gfe.includes(t)?!1:null}if(eh(e)){let t=e.expression.variable?.value?.toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}let t=Km(e);if(t===0)return!1;if(t===1)return!0;let n=Gm(e)?.unwrap_or(``).toLowerCase();if(n){if(hfe.includes(n))return!0;if(gfe.includes(n))return!1}return null}function _fe(e){if(e==null)return null;if(typeof e==`string`)return e;let t=Bm(e).unwrap_or(void 0);return t?bp(t):Gm(e).unwrap_or(null)}function Vg(e){if(e==null)return null;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return e.toString();let t=Gm(e).unwrap_or(null)??zg(e)??Bg(e);return t===null?null:t.toString()}var vfe=[`yyyy-MM-dd`,`M/d/yyyy`,`d MMM yyyy`,`MMM d, yyyy`],yfe=[`yyyy-MM-dd HH:mm:ss`,`yyyy-MM-dd HH:mm:ss.SSS`,`yyyy-MM-dd HH:mm:ss.SSSZZ`,`yyyy-MM-dd HH:mm:ssZZ`],bfe=[`HH:mm:ss`,`HH:mm:ssZZ`,`HH:mm:ss.SSS`,`HH:mm:ss.SSSZZ`];function Hg(e){if(e==null)return null;let t=typeof e==`string`?e:Gm(e).unwrap_or(null);if(t===null)return null;for(let e of bfe){let n=Lg.fromFormat(t,e,{setZone:!0});if(n.isValid)return n.toISOTime({suppressMilliseconds:!0,includeOffset:r(n)})}for(let e of vfe){let n=Lg.fromFormat(t,e,{setZone:!0});if(n.isValid)return n.toISODate()}for(let e of yfe){let n=Lg.fromFormat(t,e,{setZone:!0});if(n.isValid)return n.toISO({suppressMilliseconds:!0,includeOffset:r(n)})}let n=Lg.fromISO(t,{setZone:!0});if(n.isValid)return n.toISO({suppressMilliseconds:!0,includeOffset:r(n)});return null;function r(e){return e.zone.type!==`system`}}function Ug(e,t,n){return t.map((t,r)=>{let i=e[t]?.value;if(i==null&&n&&n[r]){let e=n[r];if(e?.dbdefault)return JSON.stringify(e.dbdefault.value)}return JSON.stringify(i)}).join(`|`)}function xfe(e,t,n){return t.some((t,r)=>{let i=e[t]?.value;return i==null&&n&&n[r]&&n[r]?.dbdefault?!1:i==null})}function Sfe(e){return e.increment||Th(e.type.type_name)}function Cfe(e,t,n){return e?`${e}.${t}.${n}`:`${t}.${n}`}function Wg(e,t,n){return n.length===1?Cfe(e,t,n[0]):`(${n.map(n=>Cfe(e,t,n)).join(`, `)})`}function wfe(e,t){return t.length===1?JSON.stringify(e[t[0]]?.value):`(${t.map(t=>JSON.stringify(e[t]?.value)).join(`, `)})`}function Gg(e,t,n){let r=t.map(t=>e.columnNodes[t]).filter(Boolean);return r.length>0?r.map(e=>new P(N.INVALID_RECORDS_FIELD,n,e)):[new P(N.INVALID_RECORDS_FIELD,n,e.node)]}var Tfe=e=>e>1?`Composite PK`:`PK`;function Efe(e){return xp(Array.from(e.records),([t,n])=>{if(Cp(n))return[];e.cachedMergedTables.has(t)||e.cachedMergedTables.set(t,gh(t,e));let r=e.cachedMergedTables.get(t),i=Afe(r),a=jfe(n),o=doe(r.fields,`name`);return xp(i,e=>Dfe(e,n,a,o,r))})}function Dfe(e,t,n,r,i){let a=Mfe(e,n,r,i,t);if(!Cp(a))return a;let o=Zre(e.map(e=>r[e])),s=o.every(e=>e&&Sfe(e)),[c,l]=wp(t,t=>xfe(t.values,e,o)),u=s?[]:Ofe(c,e,i),d=kfe(l,e,o,i);return[...u,...d]}function Ofe(e,t,n){if(Cp(e))return[];let r=`NULL in ${Tfe(t.length)}: ${Wg(n.schemaName,n.name,t)} cannot be NULL`;return xp(e,e=>Gg(e,t,r))}function kfe(e,t,n,r){return xp(Kae(ooe(e,e=>Ug(e.values,t,n)),e=>e.length>1),e=>{let n=Tfe(t.length),i=Wg(r.schemaName,r.name,t);return xp(e.slice(1),e=>Gg(e,t,`Duplicate ${n}: ${i} = ${wfe(e.values,t)}`))})}function Afe(e){return[...e.fields.filter(e=>e.pk).map(e=>[e.name]),...e.indexes.filter(e=>e.pk).map(e=>e.columns.map(e=>e.value))]}function jfe(e){return new Set(e.flatMap(e=>Object.keys(e.values)))}function Mfe(e,t,n,r,i){let a=zae(e,Array.from(t));if(Cp(a))return[];let o=a.filter(e=>{let t=n[e];return t&&!t.increment&&!Th(t.type.type_name)&&!t.dbdefault});if(Cp(o))return[];let s=`${Tfe(o.length)}: Column ${Wg(r.schemaName,r.name,o)} is missing from record and has no default value`;return i.map(e=>new P(N.INVALID_RECORDS_FIELD,s,e.node))}var Nfe=e=>e>1?`Composite UNIQUE`:`UNIQUE`;function Pfe(e){return xp(Array.from(e.records),([t,n])=>{e.cachedMergedTables.has(t)||e.cachedMergedTables.set(t,gh(t,e));let r=e.cachedMergedTables.get(t);if(Cp(n))return[];let i=Ffe(r),a=doe(r.fields,`name`);return xp(i,e=>Ife(n,e,Zre(e.map(e=>a[e])),r))})}function Ffe(e){return[...e.fields.filter(e=>e.unique).map(e=>[e.name]),...e.indexes.filter(e=>e.unique).map(e=>e.columns.map(e=>e.value))]}function Ife(e,t,n,r){return xp(Kae(ooe(e.filter(e=>!xfe(e.values,t,n)),e=>Ug(e.values,t,n)),e=>e.length>1),e=>{let n=Nfe(t.length),i=Wg(r.schemaName,r.name,t);return xp(e.slice(1),e=>Gg(e,t,`Duplicate ${n}: ${i} = ${wfe(e.values,t)}`))})}function Lfe(e){let t=[...e.ref.values(),...xp(Array.from(e.tables.values()),t=>Kse(t,e))],n=Rfe(e);return xp(t,e=>Bfe(e,n))}function Rfe(e){let t=new Map;for(let n of e.tables.values()){let r=zfe(n.schemaName,n.name),i=e.records.get(n)||[];e.cachedMergedTables.has(n)||e.cachedMergedTables.set(n,gh(n,e));let a=e.cachedMergedTables.get(n);t.set(r,{mergedTable:a,rows:i})}return t}function zfe(e,t){return e?`${e}.${t}`:`${pm}.${t}`}function Kg(e,t,n,r){if(Cp(e.rows))return[];let i=new Set(t.rows.map(e=>Ug(e.values,r.fieldNames)));return xp(e.rows.filter(e=>!xfe(e.values,n.fieldNames)).filter(e=>{let t=Ug(e.values,n.fieldNames);return!i.has(t)}),i=>{let a=Wg(e.mergedTable.schemaName,e.mergedTable.name,n.fieldNames),o=Wg(t.mergedTable.schemaName,t.mergedTable.name,r.fieldNames),s=`FK violation: ${a} = ${wfe(i.values,n.fieldNames)} does not exist in ${o}`;return Gg(i,n.fieldNames,s)})}function Bfe(e,t){if(!e.endpoints)return[];let[n,r]=e.endpoints,i=t.get(zfe(n.schemaName,n.tableName)),a=t.get(zfe(r.schemaName,r.tableName));return!i||!a?[]:Vfe(i,a,n,r)}function Vfe(e,t,n,r){let i=n.relation,a=r.relation;return i===`1`&&a===`1`||i===`*`&&a===`*`?[...Kg(e,t,n,r),...Kg(t,e,r,n)]:i===`*`&&a===`1`?Kg(e,t,n,r):i===`1`&&a===`*`?Kg(t,e,r,n):[]}var Hfe=class{constructor(e){this.env=e,this.tableToRecordMap=new Map}interpret(e){let t=[],n=[];for(let r of e){let{table:e,mergedColumns:i}=Ufe(r,this.env),a=this.tableToRecordMap.get(e);if(a){t.push(new P(N.DUPLICATE_RECORDS_FOR_TABLE,`Duplicate Records blocks for the same Table '${e.name}' - A Table can only have one Records block`,a)),t.push(new P(N.DUPLICATE_RECORDS_FOR_TABLE,`Duplicate Records blocks for the same Table '${e.name}' - A Table can only have one Records block`,r));continue}this.tableToRecordMap.set(e,r);for(let a of r.body.body){let r=a,o=Wfe(r,i,this.env);t.push(...o.getErrors()),n.push(...o.getWarnings());let s=o.getValue();s.row&&(this.env.records.has(e)||this.env.records.set(e,[]),this.env.records.get(e).push({values:s.row,node:r,columnNodes:s.columnNodes}))}}let r=this.validateConstraints();return n.push(...r),new rm(void 0,t,n)}validateConstraints(){let e=[];return e.push(...Efe(this.env).map(e=>e.toWarning())),e.push(...Pfe(this.env).map(e=>e.toWarning())),e.push(...Lfe(this.env).map(e=>e.toWarning())),e}};function Ufe(e,t){let n=e.name,r=e.parent;if(r instanceof Mp){let e=t.tables.get(r),i=gh(e,t);return n?{table:e,mergedTable:i,mergedColumns:n.elementList.map(e=>i.fields.find(t=>t.name===Hm(e).unwrap()))}:{table:e,mergedTable:i,mergedColumns:i.fields}}let i=cse(n).unwrap(),a=bp(i.variables).referee.declaration,o=t.tables.get(a),s=gh(o,t);return{table:o,mergedTable:s,mergedColumns:i.args.map(e=>s.fields.find(t=>t.name===Hm(e).unwrap()))}}function Wfe(e,t,n){let r=[],i=[],a={},o={},s=e.callee instanceof Up?e.callee.elementList:[e.callee];if(s.length!==t.length)return r.push(new P(N.INVALID_RECORDS_FIELD,`Expected ${t.length} values but got ${s.length}`,e)),new rm({row:null,columnNodes:{}},r,i);for(let e=0;e<t.length;e++){let c=s[e],l=t[e];o[l.name]=c;let u=Kfe(c,l,n);r.push(...u.getErrors()),i.push(...u.getWarnings());let d=u.getValue();d!==null&&(a[l.name]=d)}return new rm({row:a,columnNodes:o},r,i)}function Gfe(e,t){return e instanceof Rp?e.value?.value||``:!isNaN(e.start)&&!isNaN(e.end)?t.slice(e.start,e.end):``}function Kfe(e,t,n){let r=t.type.type_name.split(`(`)[0],{increment:i,not_null:a,dbdefault:o}=t,s=t.type.isEnum||!1,c=sce(r,s),l=Vg(e),u=l===null?Gfe(e,n.source):l,d=l===null?`expression`:c;if(e instanceof Rp)return new rm({value:e.value?.value||``,type:`expression`},[],[]);if(dfe(e)||ffe(e)&&!Sh(r)){let n=o&&o.value.toString().toLowerCase()!==`null`,s=Th(r);return a&&!n&&!i&&!s?new rm({value:null,type:c},[],[new nm(N.INVALID_RECORDS_FIELD,`NULL not allowed for non-nullable column '${t.name}' without default and increment`,e)]):new rm({value:null,type:c},[],[])}if(s){let r=([...n.enums.values()].find(e=>e.schemaName===t.type.schemaName&&e.name===t.type.type_name)?.values||[]).map(e=>e.name),i=Gm(e).unwrap_or(void 0);return i===void 0&&(i=Bm(e).unwrap_or([]).pop()),r.includes(i)?new rm({value:i,type:c},[],[]):new rm({value:i,type:c},[],[new nm(N.INVALID_RECORDS_FIELD,`Invalid enum value for column '${t.name}'`,e)])}if(bh(r)){let n=zg(e);if(n===null)return new rm({value:u,type:d},[],[new nm(N.INVALID_RECORDS_FIELD,`Invalid numeric value for column '${t.name}'`,e)]);if(vh(r)&&!Number.isInteger(n))return new rm({value:Math.floor(n),type:c},[],[new nm(N.INVALID_RECORDS_FIELD,`Invalid integer value ${n} for column '${t.name}': expected integer, got decimal`,e)]);if(yh(r)&&t.type.numericParams){let{precision:r,scale:i}=t.type.numericParams,a=n.toString().split(`.`),o=a[0].replace(/^-/,``),s=a[1]||``,l=o.length+s.length,u=s.length;if(l>r)return new rm({value:n,type:c},[],[new nm(N.INVALID_RECORDS_FIELD,`Numeric value ${n} for column '${t.name}' exceeds precision: expected at most ${r} total digits, got ${l}`,e)]);if(u>i)return new rm({value:n,type:c},[],[new nm(N.INVALID_RECORDS_FIELD,`Numeric value ${n} for column '${t.name}' exceeds scale: expected at most ${i} decimal digits, got ${u}`,e)])}return new rm({value:n,type:c},[],[])}if(xh(r)){let n=Bg(e);return n===null?new rm({value:u,type:d},[],[new nm(N.INVALID_RECORDS_FIELD,`Invalid boolean value for column '${t.name}'`,e)]):new rm({value:n,type:c},[],[])}if(wh(r)){let n=Hg(e);return n===null?new rm({value:u,type:d},[],[new nm(N.INVALID_RECORDS_FIELD,`Invalid datetime value for column '${t.name}', expected valid datetime format (e.g., 'YYYY-MM-DD', 'HH:MM:SS', 'YYYY-MM-DD HH:MM:SS', 'MM/DD/YYYY', 'D MMM YYYY', or 'MMM D, YYYY')`,e)]):new rm({value:n,type:c},[],[])}if(Sh(r)){let n=Vg(e);if(n===null)return new rm({value:u,type:d},[],[new nm(N.INVALID_RECORDS_FIELD,`Invalid string value for column '${t.name}'`,e)]);if(t.type.lengthParam){let{length:r}=t.type.lengthParam,i=new TextEncoder().encode(n).length;if(i>r)return new rm({value:n,type:c},[],[new nm(N.INVALID_RECORDS_FIELD,`String value for column '${t.name}' exceeds maximum length: expected at most ${r} bytes (UTF-8), got ${i} bytes`,e)])}return new rm({value:n,type:`string`},[],[])}return new rm({value:u,type:d},[],[])}function qfe(e){return{...e,fields:e.fields.map(e=>({...e,type:{...e.type,isEnum:void 0,lengthParam:void 0,numericParams:void 0}}))}}function Jfe(e){let t=[];for(let[n,r]of e.records){if(!r.length)continue;let e=Object.keys(r[0].columnNodes);t.push({schemaName:n.schemaName||void 0,tableName:n.name,columns:e,values:r.map(t=>e.map(e=>{let n=t.values[e];return n?{value:n.value,type:n.type}:{value:null,type:`expression`}}))})}return{schemas:[],tables:Array.from(e.tables.values()).map(qfe),notes:Array.from(e.notes.values()),refs:Array.from(e.ref.values()),enums:Array.from(e.enums.values()),tableGroups:Array.from(e.tableGroups.values()),aliases:e.aliases,project:Array.from(e.project.values())[0]||{},tablePartials:Array.from(e.tablePartials.values()).map(qfe),records:t}}var Yfe=class{constructor(e){this.ast=e,this.env={schema:[],tables:new Map,notes:new Map,refIds:{},ref:new Map,enums:new Map,tableOwnerGroup:{},tableGroups:new Map,aliases:[],project:new Map,tablePartials:new Map,records:new Map,recordsElements:[],cachedMergedTables:new Map,source:e.source}}interpret(){let e=this.ast.body.flatMap(e=>{switch(Rm(e).unwrap_or(void 0)){case mm.Table:return new qse(e,this.env).interpret();case mm.Note:return new Jse(e,this.env).interpret();case mm.Ref:return new Yse(e,this.env).interpret();case mm.TableGroup:return new Xse(e,this.env).interpret();case mm.TablePartial:return new Qse(e,this.env).interpret();case mm.Enum:return new Zse(e,this.env).interpret();case mm.Project:return new $se(e,this.env).interpret();case mm.Records:return this.env.recordsElements.push(e),[];default:return[]}}),t=[];if(this.env.recordsElements.length){let n=new Hfe(this.env).interpret(this.env.recordsElements);e.push(...n.getErrors()),t.push(...n.getWarnings())}return new rm(Jfe(this.env),e,t)}},qg=function(e){return e[e.Function=1]=`Function`,e[e.Constructor=2]=`Constructor`,e[e.Field=3]=`Field`,e[e.Variable=4]=`Variable`,e[e.Class=5]=`Class`,e[e.Struct=6]=`Struct`,e[e.Interface=7]=`Interface`,e[e.Module=8]=`Module`,e[e.Property=9]=`Property`,e[e.Event=10]=`Event`,e[e.Operator=11]=`Operator`,e[e.Unit=12]=`Unit`,e[e.Value=13]=`Value`,e[e.Constant=14]=`Constant`,e[e.Enum=15]=`Enum`,e[e.EnumMember=16]=`EnumMember`,e[e.Keyword=17]=`Keyword`,e[e.Text=18]=`Text`,e[e.Color=19]=`Color`,e[e.File=20]=`File`,e[e.Reference=21]=`Reference`,e[e.Customcolor=22]=`Customcolor`,e[e.Folder=23]=`Folder`,e[e.TypeParameter=24]=`TypeParameter`,e[e.User=25]=`User`,e[e.Issue=26]=`Issue`,e[e.Snippet=27]=`Snippet`,e}({}),Jg=function(e){return e[e.None=0]=`None`,e[e.KeepWhitespace=1]=`KeepWhitespace`,e[e.InsertAsSnippet=4]=`InsertAsSnippet`,e}({}),Xfe=function(e){return e[e.Hint=1]=`Hint`,e[e.Info=2]=`Info`,e[e.Warning=4]=`Warning`,e[e.Error=8]=`Error`,e}({});function Zfe(e){return e?e.split(``).every(e=>im(e)||am(e))&&!am(e[0]):!1}function Yg(e){return Zfe(e)?e:`"${Xg(e)}"`}function Qfe(e){let t=``,n=0,r={n:`
11
+ `)}function Wse(e){if(e){if(Qm(e))return{value:Gm(e).unwrap(),type:`string`};if(Fm(e))return{type:`number`,value:um(e)};if(eh(e))return{value:e.expression.variable.value.toLowerCase(),type:`boolean`};if(e instanceof Rp&&e.value)return{value:e.value.value,type:`expression`};if(nh(e))return{value:zm(e).map(bp).and_then(Hm).unwrap(),type:`string`};throw Error(`Unreachable`)}}function Gse(e,t){let n=``,r=null,i,a;if(e instanceof Gp){let t=e.argumentList.elementList;if(r=t.map(e=>Fm(e)?lm(e):Qm(e)?Gm(e).unwrap():Hm(e).unwrap()).join(`,`),n=`(${r})`,t.length===2&&Fm(t[0])&&Fm(t[1])){let e=um(t[0]),n=um(t[1]);!isNaN(e)&&!isNaN(n)&&(i={precision:Math.trunc(e),scale:Math.trunc(n)})}else if(t.length===1&&Fm(t[0])){let e=um(t[0]);isNaN(e)||(a={length:Math.trunc(e)})}e=e.callee}for(;e instanceof Gp||e instanceof Xp;)e instanceof Gp?(n=`(${e.argumentList.elementList.map(e=>Fm(e)?lm(e):Qm(e)?Gm(e).unwrap():Hm(e).unwrap()).join(`,`)})${n}`,e=e.callee):e instanceof Xp&&(n=`${`[${e.indexer.elementList.map(e=>e.name.expression.literal.value).join(`,`)}]`}${n}`,e=e.array);let{name:o,schemaName:s}=ph(e),c=s.length===0?null:s[0],l=!![...t.enums.values()].find(e=>e.name===o&&e.schemaName===c);return s.length>1?new rm({schemaName:s.length===0?null:s[0],type_name:`${o}${n}`,args:r,numericParams:i,lengthParam:a,isEnum:l},[new P(N.UNSUPPORTED,`Nested schema is not supported`,e)]):new rm({schemaName:s.length===0?null:s[0],type_name:`${o}${n}`,args:r,numericParams:i,lengthParam:a,isEnum:l})}function gh(e,t){let n=[...t.tables.entries()].find(([,t])=>t===e)?.[0];if(!n)throw Error(`mergeTableAndPartials should be called after all tables are interpreted`);if(!(n.body instanceof Bp))throw Error(`Table element should have a block body`);let r=[...e.indexes],i=[...e.checks],a=e.headerColor,o=e.note,s=[...t.tablePartials.values()];for(let t of[...e.partials].reverse()){let{name:e}=t,n=s.find(t=>t.name===e);n&&(r.push(...n.indexes),i.push(...n.checks),n.headerColor!==void 0&&(a=n.headerColor),n.note!==void 0&&(o=n.note))}let c=new Map(e.fields.map(e=>[e.name,e])),l=new Set(c.keys()),u=new Map(s.map(e=>[e.name,e])),d=[];for(let e of n.body.body)if(e instanceof zp)if(jm(e.callee)){let t=Hm(e.callee.expression).unwrap_or(void 0),n=u.get(t);if(!n)continue;for(let e of n.fields)l.has(e.name)||d.push(e)}else{let t=Hm(e.callee).unwrap(),n=c.get(t);if(!n)continue;d.push(n)}let f=_oe([...d].reverse(),`name`).reverse();return{...e,fields:f,indexes:r,checks:i,headerColor:a,note:o}}function Kse(e,t){let n=[],r=[...t.tablePartials.values()],i=new Set(e.fields.map(e=>e.name));for(let t of[...e.partials].reverse()){let{name:a}=t,o=r.find(e=>e.name===a);if(o){for(let t of o.fields)if(!i.has(t.name))for(let r of t.inline_refs){let i=uh(r.relation);n.push({name:null,schemaName:null,token:r.token,endpoints:[{schemaName:r.schemaName,tableName:r.tableName,fieldNames:r.fieldNames,token:r.token,relation:i[1]},{schemaName:e.schemaName,tableName:e.name,fieldNames:[t.name],token:t.token,relation:i[0]}]})}}}return n}var qse=class{constructor(e,t){this.declarationNode=e,this.env=t,this.table={name:void 0,schemaName:void 0,alias:null,fields:[],token:void 0,indexes:[],partials:[],checks:[]},this.pkColumns=[]}interpret(){this.table.token=dh(this.declarationNode),this.env.tables.set(this.declarationNode,this.table);let e=[...this.interpretName(this.declarationNode.name),...this.interpretAlias(this.declarationNode.alias),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.table.indexes.push({columns:this.pkColumns.map(({name:e,token:t})=>({value:e,type:`column`,token:t})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(e=>{e.pk=!1})),e}interpretName(e){let{name:t,schemaName:n}=ph(e);return n.length>1?(this.table.name=t,this.table.schemaName=n.join(`.`),[new P(N.UNSUPPORTED,`Nested schema is not supported`,e)]):(this.table.name=t,this.table.schemaName=n.length?n[0]:null,[])}interpretAlias(e){if(!e)return[];let t=Wm(e).unwrap_or(null);return t&&(this.env.aliases.push({name:t,kind:`table`,value:{tableName:this.table.name,schemaName:this.table.schemaName}}),this.table.alias=t),[]}interpretSettingList(e){let t=Lm(e).getValue();this.table.headerColor=t[hm.HeaderColor]?.length?mh(t[hm.HeaderColor]?.at(0)?.value):void 0;let[n]=t[hm.Note]||[];return this.table.note=n&&{value:Gm(n?.value).map(hh).unwrap(),token:dh(n)},[]}interpretBody(e){let[t,n]=wp(e.body,e=>e instanceof zp);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case mm.Note:return this.table.note={value:Gm(e.body instanceof Bp?e.body.body[0].callee:e.body.callee).map(hh).unwrap(),token:dh(e)},[];case mm.Indexes:return this.interpretIndexes(e);case mm.Check:return this.interpretChecks(e);case mm.Records:return this.env.recordsElements.push(e),[];default:return[]}})}interpretInjection(e,t){let n={order:t,token:dh(e)};return n.name=Hm(e.expression).unwrap_or(``),this.table.partials.push(n),[]}interpretFields(e){let t=(this.declarationNode.symbol?.symbolTable?[...this.declarationNode.symbol.symbolTable.entries()]:[]).filter(([e])=>Em(e).unwrap_or(null)?.kind===gm.Column).length?[]:[new P(N.EMPTY_TABLE,`A Table must have at least one column`,this.declarationNode)],n=e.flatMap((e,t)=>jm(e.callee)?this.interpretInjection(e.callee,t):this.interpretColumn(e));return[...t,...n]}interpretColumn(e){let t=[],n={};n.name=Wm(e.callee).unwrap();let r=Gse(e.args[0],this.env);n.type=r.getValue(),t.push(...r.getErrors()),n.token=dh(e),n.inline_refs=[];let i=e.args.slice(1);if(bp(i)instanceof Vp){let r=Lm(i.pop()).getValue();n.pk=!!r[hm.PK]?.length||!!r[hm.PrimaryKey]?.length,n.increment=!!r[hm.Increment]?.length,n.unique=!!r[hm.Unique]?.length,n.not_null=r[hm.NotNull]?.length?!0:r[hm.Null]?.length?!1:void 0,n.dbdefault=Wse(r[hm.Default]?.at(0)?.value);let a=r[hm.Note]?.at(0);n.note=a&&{value:Gm(a.value).map(hh).unwrap(),token:dh(a)},n.inline_refs=(r[hm.Ref]||[]).flatMap(n=>{let[r]=fh(n.value.expression);if(Use(r,e.symbol))return t.push(new P(N.SAME_ENDPOINT,`Two endpoints are the same`,n)),[];let i=n.value.op,a=Bm(n.value.expression).unwrap(),o;if(a.length===1){let[e]=a;o={schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[e],relation:i.value,token:dh(n)}}else if(a.length===2){let[e,t]=a;o={schemaName:null,tableName:e,fieldNames:[t],relation:i.value,token:dh(n)}}else if(a.length===3){let[e,t,r]=a;o={schemaName:e,tableName:t,fieldNames:[r],relation:i.value,token:dh(n)}}else{t.push(new P(N.UNSUPPORTED,`Nested schema is not supported`,n));let e=a.pop(),r=a.pop();o={schemaName:a.join(`.`),tableName:r,fieldNames:[e],relation:i.value,token:dh(n)}}let s=this.registerInlineRefToEnv(e,r,o,n);return t.push(...s),s.length===0?o:[]}),n.checks=(r[hm.Check]||[]).map(e=>({token:dh(e),expression:e.value.value.value}))}return n.pk||=i.some(e=>Hm(e).unwrap().toLowerCase()===`pk`),n.unique||=i.some(e=>Hm(e).unwrap().toLowerCase()===`unique`),this.table.fields.push(n),n.pk&&this.pkColumns.push(n),t}interpretIndexes(e){return this.table.indexes.push(...e.body.body.map(e=>{let t={columns:[]},n=e;t.token=dh(n);let r=[n.callee,...n.args];if(bp(r)instanceof Vp){let e=Lm(r.pop()).getValue();t.pk=!!e[hm.PK]?.length,t.unique=!!e[hm.Unique]?.length,t.name=Gm(e[hm.Name]?.at(0)?.value).unwrap_or(void 0);let n=e[hm.Note]?.at(0);t.note=n&&{value:Gm(n.value).unwrap(),token:dh(n)},t.type=Hm(e[hm.Type]?.at(0)?.value).unwrap_or(void 0)}return r.flatMap(e=>{if(!(e instanceof Gp))return e;let t=[];for(;e instanceof Gp;)t.push(e.argumentList),e=e.callee;return t.push(e),t}).forEach(e=>{let{functional:n,nonFunctional:r}=Um(e).unwrap();t.columns.push(...n.map(e=>({value:e.value.value,type:`expression`,token:dh(e)})),...r.map(e=>({value:Wm(e).unwrap(),type:`column`,token:dh(e)})))}),t})),[]}interpretChecks(e){return this.table.checks.push(...e.body.body.map(e=>{let t={},n=e;return t.token=dh(n),n.args[0]instanceof Vp&&(t.name=Gm(Lm(n.args[0]).getValue()[hm.Name]?.at(0)?.value).unwrap_or(void 0)),t.expression=n.callee.value.value,t})),[]}registerInlineRefToEnv(e,t,n,r){let i=Hse(e.symbol,t);if(this.env.refIds[i])return[new P(N.CIRCULAR_REF,`References with same endpoints exist`,r),new P(N.CIRCULAR_REF,`References with same endpoints exist`,this.env.refIds[i])];let a=uh(n.relation);return this.env.refIds[i]=r,this.env.ref.set(r,{name:null,schemaName:null,token:n.token,endpoints:[{...n,relation:a[1]},{schemaName:this.table.schemaName,tableName:this.table.name,fieldNames:[Hm(e.callee).unwrap()],token:dh(e),relation:a[0]}]}),[]}},Jse=class{constructor(e,t){this.declarationNode=e,this.env=t,this.note={name:void 0,content:void 0,token:void 0}}interpret(){return this.note.token=dh(this.declarationNode),this.env.notes.set(this.declarationNode,this.note),[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let{name:t}=ph(e);return this.note.name=t,[]}interpretSettingList(e){let t=Lm(e).getValue();return this.note.headerColor=t.headercolor?.length?mh(t.headercolor?.at(0)?.value):void 0,[]}interpretBody(e){let[t,n]=wp(e.body,e=>e instanceof zp);return t.length!==1||n.length>0?[new P(N.INVALID_NOTE,`Invalid note syntax`,e)]:[...this.interpretNote(t[0])]}interpretNote(e){let t=are(e,`callee.expression.literal.value`,``);return this.note.content=hh(t),[]}},Yse=class{constructor(e,t){this.declarationNode=e,this.env=t,this.container=this.declarationNode.parent instanceof Mp?this.env.tables.get(this.declarationNode.parent):void 0,this.ref={}}interpret(){return this.ref.token=dh(this.declarationNode),this.env.ref.set(this.declarationNode,this.ref),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let t=[],n=Bm(this.declarationNode.name).unwrap_or([]);return this.ref.name=n.pop()||null,n.length>1&&t.push(new P(N.UNSUPPORTED,`Nested schema is not supported`,this.declarationNode.name)),this.ref.schemaName=n.join(`.`)||null,t}interpretBody(e){return e instanceof zp?this.interpretField(e):this.interpretField(e.body[0])}interpretField(e){let t=e.callee.op.value,{leftExpression:n,rightExpression:r}=e.callee,i=fh(n),a=fh(r);if(Use(i,a))return[new P(N.SAME_ENDPOINT,`Two endpoints are the same`,e)];let o=Hse(i,a);if(this.env.refIds[o])return[new P(N.CIRCULAR_REF,`References with same endpoints exist`,this.declarationNode),new P(N.CIRCULAR_REF,`References with same endpoints exist`,this.env.refIds[o])];if(e.args[0]){let t=Lm(e.args[0]).getValue(),n=t.delete?.at(0)?.value;this.ref.onDelete=n instanceof Np?rh(n).unwrap_or(void 0):Hm(n).unwrap_or(void 0);let r=t.update?.at(0)?.value;this.ref.onUpdate=r instanceof Np?rh(r).unwrap_or(void 0):Hm(r).unwrap_or(void 0),this.ref.color=t.color?.length?mh(t.color?.at(0)?.value):void 0}let s=uh(t);return this.ref.endpoints=[{...Vse(n,this.container),relation:s[0],token:dh(n)},{...Vse(r,this.container),relation:s[1],token:dh(r)}],this.env.refIds[o]=this.declarationNode,[]}},Xse=class{constructor(e,t){this.declarationNode=e,this.env=t,this.tableGroup={tables:[]}}interpret(){let e=[];return this.tableGroup.token=dh(this.declarationNode),this.env.tableGroups.set(this.declarationNode,this.tableGroup),e.push(...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)),e}interpretName(e){let t=[],{name:n,schemaName:r}=ph(e);return r.length>=2&&(this.tableGroup.name=n,this.tableGroup.schemaName=r.join(`.`),t.push(new P(N.UNSUPPORTED,`Nested schema is not supported`,this.declarationNode.name))),this.tableGroup.name=n,this.tableGroup.schemaName=r[0]||null,t}interpretBody(e){let[t,n]=wp(e.body,e=>e instanceof zp);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case`note`:this.tableGroup.note={value:Gm(e.body instanceof Bp?e.body.body[0].callee:e.body.callee).map(hh).unwrap(),token:dh(e)};break;default:break}return[]})}interpretFields(e){let t=[];return this.tableGroup.tables=e.map(e=>{let n=Bm(e.callee).unwrap();n.length>2&&t.push(new P(N.UNSUPPORTED,`Nested schema is not supported`,e));let r=zm(e.callee).unwrap().pop().referee.id;if(this.env.tableOwnerGroup[r]){let i=this.env.tableOwnerGroup[r],{schemaName:a,name:o}=this.env.tableGroups.get(i),s=a?`${a}.${o}`:o;t.push(new P(N.TABLE_REAPPEAR_IN_TABLEGROUP,`Table "${n.join(`.`)}" already appears in group "${s}"`,e))}else this.env.tableOwnerGroup[r]=this.declarationNode;return{name:n.pop(),schemaName:n.join(`.`)}}),t}interpretSettingList(e){let t=Lm(e).getValue();this.tableGroup.color=t.color?.length?mh(t.color?.at(0)?.value):void 0;let[n]=t.note||[];return this.tableGroup.note=n&&{value:Gm(n?.value).map(hh).unwrap(),token:dh(n)},[]}},Zse=class{constructor(e,t){this.declarationNode=e,this.env=t,this.enum={values:[]}}interpret(){return this.enum.token=dh(this.declarationNode),this.env.enums.set(this.declarationNode,this.enum),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){let{name:t,schemaName:n}=ph(e);return n.length>1?(this.enum.name=t,this.enum.schemaName=n.join(`.`),[new P(N.UNSUPPORTED,`Nested schema is not supported`,e)]):(this.enum.name=t,this.enum.schemaName=n.length?n[0]:null,[])}interpretBody(e){return e.body.flatMap(e=>{let t=e,n={};n.token=dh(t),n.name=Hm(t.callee).unwrap();let r=Lm(t.args[0]).getValue().note?.at(0);return n.note=r&&{value:Gm(r.value).map(hh).unwrap(),token:dh(r)},this.enum.values.push(n),[]})}},Qse=class{constructor(e,t){this.declarationNode=e,this.env=t,this.tablePartial={name:void 0,fields:[],token:void 0,indexes:[],checks:[]},this.pkColumns=[]}interpret(){this.tablePartial.token=dh(this.declarationNode),this.env.tablePartials.set(this.declarationNode,this.tablePartial);let e=[...this.interpretName(this.declarationNode.name),...this.interpretSettingList(this.declarationNode.attributeList),...this.interpretBody(this.declarationNode.body)];return this.pkColumns.length>=2&&(this.tablePartial.indexes.push({columns:this.pkColumns.map(({name:e,token:t})=>({value:e,type:`column`,token:t})),token:{start:{offset:-1,line:-1,column:-1},end:{offset:-1,line:-1,column:-1}},pk:!0}),this.pkColumns.forEach(e=>{e.pk=!1})),e}interpretName(e){let{name:t}=ph(e);return this.tablePartial.name=t,[]}interpretSettingList(e){let t=Lm(e).getValue(),n=Qae(t[hm.HeaderColor]);this.tablePartial.headerColor=n?mh(n.value):void 0;let[r]=t[hm.Note]||[];return this.tablePartial.note=r&&{value:Gm(r?.value).map(hh).unwrap(),token:dh(r)},[]}interpretBody(e){let[t,n]=wp(e.body,e=>e instanceof zp);return[...this.interpretFields(t),...this.interpretSubElements(n)]}interpretSubElements(e){return e.flatMap(e=>{switch(e.type?.value.toLowerCase()){case mm.Note:return this.tablePartial.note={value:Gm(e.body instanceof Bp?e.body.body[0].callee:e.body.callee).map(hh).unwrap(),token:dh(e)},[];case mm.Indexes:return this.interpretIndexes(e);case mm.Check:return this.interpretChecks(e);default:return[]}})}interpretFields(e){return e.flatMap(e=>this.interpretColumn(e))}interpretColumn(e){let t=[],n={};n.name=Wm(e.callee).unwrap();let r=Gse(e.args[0],this.env);n.type=r.getValue(),t.push(...r.getErrors()),n.token=dh(e),n.inline_refs=[];let i=e.args.slice(1);if(bp(i)instanceof Vp){let r=Lm(i.pop()).getValue();n.pk=!!r[hm.PK]?.length||!!r[hm.PrimaryKey]?.length,n.increment=!!r[hm.Increment]?.length,n.unique=!!r[hm.Unique]?.length,n.not_null=r[hm.NotNull]?.length?!0:r[hm.Null]?.length?!1:void 0,n.dbdefault=Wse(r[hm.Default]?.at(0)?.value);let a=r[hm.Note]?.at(0);n.note=a&&{value:Gm(a.value).map(hh).unwrap(),token:dh(a)},n.inline_refs=(r[hm.Ref]||[]).flatMap(n=>{let[r]=fh(n.value.expression);if(Use(r,e.symbol))return t.push(new P(N.SAME_ENDPOINT,`Two endpoints are the same`,n)),[];let i=n.value.op,a=Bm(n.value.expression).unwrap(),o;if(a.length===2){let[e,t]=a;o={schemaName:null,tableName:e,fieldNames:[t],relation:i.value,token:dh(n)}}else if(a.length===3){let[e,t,r]=a;o={schemaName:e,tableName:t,fieldNames:[r],relation:i.value,token:dh(n)}}else{t.push(new P(N.UNSUPPORTED,`Unsupported`,n));let e=a.pop(),r=a.pop();o={schemaName:a.join(`.`),tableName:r,fieldNames:[e],relation:i.value,token:dh(n)}}return o}),n.checks=(r[hm.Check]||[]).map(e=>({token:dh(e),expression:e.value.value.value}))}return n.pk||=i.some(e=>Hm(e).unwrap().toLowerCase()===`pk`),n.unique||=i.some(e=>Hm(e).unwrap().toLowerCase()===`unique`),this.tablePartial.fields.push(n),n.pk&&this.pkColumns.push(n),t}interpretIndexes(e){return this.tablePartial.indexes.push(...e.body.body.map(e=>{let t={columns:[]},n=e;t.token=dh(n);let r=[n.callee,...n.args];if(bp(r)instanceof Vp){let e=Lm(r.pop()).getValue();t.pk=!!e[hm.PK]?.length,t.unique=!!e[hm.Unique]?.length,t.name=Gm(e[hm.Name]?.at(0)?.value).unwrap_or(void 0);let n=e[hm.Note]?.at(0);t.note=n&&{value:Gm(n.value).unwrap(),token:dh(n)},t.type=Hm(e[hm.Type]?.at(0)?.value).unwrap_or(void 0)}return r.flatMap(e=>{if(!(e instanceof Gp))return e;let t=[],n=e;for(;n instanceof Gp;)t.push(n.argumentList),n=n.callee;return t.push(n),t}).forEach(e=>{let{functional:n,nonFunctional:r}=Um(e).unwrap();t.columns.push(...n.map(e=>({value:e.value.value,type:`expression`,token:dh(e)})),...r.map(e=>({value:Wm(e).unwrap(),type:`column`,token:dh(e)})))}),t})),[]}interpretChecks(e){return this.tablePartial.checks.push(...e.body.body.map(e=>{let t={},n=e;return t.token=dh(n),n.args[0]instanceof Vp&&(t.name=Gm(Lm(n.args[0]).getValue()[hm.Name]?.at(0)?.value).unwrap_or(void 0)),t.expression=n.callee.value.value,t})),[]}},$se=class{constructor(e,t){this.declarationNode=e,this.env=t,this.project={enums:[],refs:[],tableGroups:[],tables:[],tablePartials:[]}}interpret(){return this.env.project.set(this.declarationNode,this.project),this.project.token=dh(this.declarationNode),[...this.interpretName(this.declarationNode.name),...this.interpretBody(this.declarationNode.body)]}interpretName(e){if(!e)return this.project.name=null,[];let{name:t}=ph(e);return this.project.name=t,[]}interpretBody(e){return e.body.flatMap(e=>{let t=e;switch(t.type?.value.toLowerCase()){case`table`:{let e=new qse(t,this.env).interpret();return this.project.tables.push(this.env.tables.get(t)),e}case`ref`:{let e=new Yse(t,this.env).interpret();return this.project.refs.push(this.env.ref.get(t)),e}case`tablegroup`:{let e=new Xse(t,this.env).interpret();return this.project.tableGroups.push(this.env.tableGroups.get(t)),e}case`enum`:{let e=new Zse(t,this.env).interpret();return this.project.enums.push(this.env.enums.get(t)),e}case`note`:return this.project.note={value:Gm(t.body instanceof Bp?t.body.body[0].callee:t.body.callee).map(hh).unwrap(),token:dh(t)},[];case`tablepartial`:{let e=new Qse(t,this.env).interpret();return this.project.tablePartials.push(this.env.tablePartials.get(t)),e}default:return this.project[t.type.value.toLowerCase()]=Gm(t.body.callee).unwrap(),[]}})}},ece={mysql:new Set([`int`,`integer`,`smallint`,`bigint`,`tinyint`,`mediumint`]),postgres:new Set([`int`,`integer`,`smallint`,`bigint`,`serial`,`bigserial`,`smallserial`]),mssql:new Set([`int`,`integer`,`smallint`,`bigint`,`tinyint`]),oracle:new Set([`int`,`integer`,`smallint`]),snowflake:new Set([`int`,`integer`,`smallint`,`bigint`,`tinyint`])},tce={mysql:new Set([`decimal`,`numeric`,`float`,`double`,`real`]),postgres:new Set([`decimal`,`numeric`,`real`,`float`,`double precision`]),mssql:new Set([`decimal`,`numeric`,`real`,`float`]),oracle:new Set([`number`,`decimal`,`numeric`,`float`,`real`]),snowflake:new Set([`number`,`decimal`,`numeric`,`float`,`double`,`real`])},nce={mysql:new Set([`bool`,`boolean`,`bit`]),postgres:new Set([`bool`,`boolean`]),mssql:new Set([`bit`]),oracle:new Set([]),snowflake:new Set([`boolean`])},rce={mysql:new Set([`varchar`,`char`,`text`,`tinytext`,`mediumtext`,`longtext`,`string`]),postgres:new Set([`varchar`,`char`,`character`,`character varying`,`text`,`string`]),mssql:new Set([`varchar`,`char`,`nvarchar`,`nchar`,`text`,`ntext`,`string`]),oracle:new Set([`varchar`,`varchar2`,`char`,`nvarchar2`,`nchar`,`string`]),snowflake:new Set([`varchar`,`char`,`text`,`string`])},ice={mysql:new Set([`binary`,`varbinary`,`blob`,`tinyblob`,`mediumblob`,`longblob`]),postgres:new Set([`bytea`]),mssql:new Set([`binary`,`varbinary`]),oracle:new Set([`blob`,`raw`]),snowflake:new Set([`binary`,`varbinary`])},ace={mysql:new Set([`date`,`datetime`,`timestamp`,`time`]),postgres:new Set([`date`,`timestamp`,`timestamptz`,`timestamp with time zone`,`timestamp without time zone`,`time`,`timetz`,`time with time zone`,`time without time zone`]),mssql:new Set([`date`,`datetime`,`datetime2`,`smalldatetime`,`time`]),oracle:new Set([`date`,`timestamp`,`timestamp with time zone`,`timestamp with local time zone`]),snowflake:new Set([`date`,`datetime`,`timestamp`,`time`])},oce={mysql:new Set([]),postgres:new Set([`serial`,`smallserial`,`bigserial`]),mssql:new Set([]),oracle:new Set([]),snowflake:new Set([])};function _h(e){return e.toLowerCase().trim().replace(/\s+/g,` `)}function vh(e,t){let n=_h(e);return t?ece[t].has(n):Object.values(ece).some(e=>e.has(n))}function yh(e,t){let n=_h(e);return t?tce[t].has(n):Object.values(tce).some(e=>e.has(n))}function bh(e,t){return vh(e,t)||yh(e,t)}function xh(e,t){let n=_h(e);return t?nce[t].has(n):Object.values(nce).some(e=>e.has(n))}function Sh(e,t){let n=_h(e);return t?rce[t].has(n):Object.values(rce).some(e=>e.has(n))}function Ch(e,t){let n=_h(e);return t?ice[t].has(n):Object.values(ice).some(e=>e.has(n))}function wh(e,t){let n=_h(e);return t?ace[t].has(n):Object.values(ace).some(e=>e.has(n))}function Th(e,t){let n=_h(e);return t?oce[t].has(n):Object.values(oce).some(e=>e.has(n))}function sce(e,t){if(t)return`string`;if(vh(e))return`integer`;if(yh(e))return`real`;if(xh(e))return`bool`;if(Sh(e))return`string`;let n=_h(e);return n===`date`?`date`:n===`time`||n===`timetz`||n===`time with time zone`||n===`time without time zone`?`time`:wh(e)?`datetime`:e}var Eh=class extends Error{},cce=class extends Eh{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},lce=class extends Eh{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},uce=class extends Eh{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},Dh=class extends Eh{},dce=class extends Eh{constructor(e){super(`Invalid unit ${e}`)}},Oh=class extends Eh{},kh=class extends Eh{constructor(){super(`Zone is an abstract class`)}},Ah=`numeric`,jh=`short`,Mh=`long`,Nh={year:Ah,month:Ah,day:Ah},fce={year:Ah,month:jh,day:Ah},pce={year:Ah,month:jh,day:Ah,weekday:jh},mce={year:Ah,month:Mh,day:Ah},hce={year:Ah,month:Mh,day:Ah,weekday:Mh},gce={hour:Ah,minute:Ah},_ce={hour:Ah,minute:Ah,second:Ah},vce={hour:Ah,minute:Ah,second:Ah,timeZoneName:jh},yce={hour:Ah,minute:Ah,second:Ah,timeZoneName:Mh},bce={hour:Ah,minute:Ah,hourCycle:`h23`},xce={hour:Ah,minute:Ah,second:Ah,hourCycle:`h23`},Sce={hour:Ah,minute:Ah,second:Ah,hourCycle:`h23`,timeZoneName:jh},Cce={hour:Ah,minute:Ah,second:Ah,hourCycle:`h23`,timeZoneName:Mh},wce={year:Ah,month:Ah,day:Ah,hour:Ah,minute:Ah},Tce={year:Ah,month:Ah,day:Ah,hour:Ah,minute:Ah,second:Ah},Ece={year:Ah,month:jh,day:Ah,hour:Ah,minute:Ah},Dce={year:Ah,month:jh,day:Ah,hour:Ah,minute:Ah,second:Ah},Oce={year:Ah,month:jh,day:Ah,weekday:jh,hour:Ah,minute:Ah},kce={year:Ah,month:Mh,day:Ah,hour:Ah,minute:Ah,timeZoneName:jh},Ace={year:Ah,month:Mh,day:Ah,hour:Ah,minute:Ah,second:Ah,timeZoneName:jh},jce={year:Ah,month:Mh,day:Ah,weekday:Mh,hour:Ah,minute:Ah,timeZoneName:Mh},Mce={year:Ah,month:Mh,day:Ah,weekday:Mh,hour:Ah,minute:Ah,second:Ah,timeZoneName:Mh},Ph=class{get type(){throw new kh}get name(){throw new kh}get ianaName(){return this.name}get isUniversal(){throw new kh}offsetName(e,t){throw new kh}formatOffset(e,t){throw new kh}offset(e){throw new kh}equals(e){throw new kh}get isValid(){throw new kh}},Nce=null,Pce=class e extends Ph{static get instance(){return Nce===null&&(Nce=new e),Nce}get type(){return`system`}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Qle(e,t,n)}formatOffset(e,t){return sg(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type===`system`}get isValid(){return!0}},Fce=new Map;function Ice(e){let t=Fce.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`}),Fce.set(e,t)),t}var Lce={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Rce(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 zce(e,t){let n=e.formatToParts(t),r=[];for(let e=0;e<n.length;e++){let{type:t,value:i}=n[e],a=Lce[t];t===`era`?r[a]=i:Kh(a)||(r[a]=parseInt(i,10))}return r}var Bce=new Map,Fh=class e extends Ph{static create(t){let n=Bce.get(t);return n===void 0&&Bce.set(t,n=new e(t)),n}static resetCache(){Bce.clear(),Fce.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 Qle(e,t,n,this.name)}formatOffset(e,t){return sg(this.offset(e),t)}offset(e){if(!this.valid)return NaN;let t=new Date(e);if(isNaN(t))return NaN;let n=Ice(this.name),[r,i,a,o,s,c,l]=n.formatToParts?zce(n,t):Rce(n,t);o===`BC`&&(r=-Math.abs(r)+1);let u=rg({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}},Vce={};function Hce(e,t={}){let n=JSON.stringify([e,t]),r=Vce[n];return r||(r=new Intl.ListFormat(e,t),Vce[n]=r),r}var Uce=new Map;function Wce(e,t={}){let n=JSON.stringify([e,t]),r=Uce.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),Uce.set(n,r)),r}var Gce=new Map;function Kce(e,t={}){let n=JSON.stringify([e,t]),r=Gce.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),Gce.set(n,r)),r}var qce=new Map;function Jce(e,t={}){let{base:n,...r}=t,i=JSON.stringify([e,r]),a=qce.get(i);return a===void 0&&(a=new Intl.RelativeTimeFormat(e,t),qce.set(i,a)),a}var Ih=null;function Yce(){return Ih||(Ih=new Intl.DateTimeFormat().resolvedOptions().locale,Ih)}var Xce=new Map;function Zce(e){let t=Xce.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),Xce.set(e,t)),t}var Qce=new Map;function $ce(e){let t=Qce.get(e);if(!t){let n=new Intl.Locale(e);t=`getWeekInfo`in n?n.getWeekInfo():n.weekInfo,`minimalDays`in t||(t={...cle,...t}),Qce.set(e,t)}return t}function ele(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=Wce(e).resolvedOptions(),r=e}catch{let i=e.substring(0,n);t=Wce(i).resolvedOptions(),r=i}let{numberingSystem:i,calendar:a}=t;return[r,i,a]}}function tle(e,t,n){return n||t?(e.includes(`-u-`)||(e+=`-u`),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`),e):e}function nle(e){let t=[];for(let n=1;n<=12;n++){let r=Lg.utc(2009,n,1);t.push(e(r))}return t}function rle(e){let t=[];for(let n=1;n<=7;n++){let r=Lg.utc(2016,11,13+n);t.push(e(r))}return t}function Lh(e,t,n,r){let i=e.listingMode();return i===`error`?null:i===`en`?n(t):r(t)}function ile(e){return e.numberingSystem&&e.numberingSystem!==`latn`?!1:e.numberingSystem===`latn`||!e.locale||e.locale.startsWith(`en`)||Zce(e.locale).numberingSystem===`latn`}var ale=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=Kce(e,t)}}format(e){if(this.inf){let t=this.floor?Math.floor(e):e;return this.inf.format(t)}else return Zh(this.floor?Math.floor(e):Yle(e,3),this.padTo)}},ole=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&&Fh.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=Wce(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()}},sle=class{constructor(e,t,n){this.opts={style:`long`,...n},!t&&Vle()&&(this.rtf=Jce(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):_ue(t,e,this.opts.numeric,this.opts.style!==`long`)}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}},cle={firstDay:1,minimalDays:4,weekend:[6,7]},Rh=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||Hh.defaultLocale;return new e(o||(a?`en-US`:Yce()),n||Hh.defaultNumberingSystem,r||Hh.defaultOutputCalendar,Kle(i)||Hh.defaultWeekSettings,o)}static resetCache(){Ih=null,Uce.clear(),Gce.clear(),qce.clear(),Xce.clear(),Qce.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]=ele(e);this.locale=a,this.numberingSystem=t||o||null,this.outputCalendar=n||s||null,this.weekSettings=r,this.intl=tle(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??=ile(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,Kle(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 Lh(this,e,rue,()=>{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]=nle(t)}return this.monthsCache[i][e]})}weekdays(e,t=!1){return Lh(this,e,sue,()=>{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]=rle(e=>this.extract(e,n,`weekday`))),this.weekdaysCache[r][e]})}meridiems(){return Lh(this,void 0,()=>cue,()=>{if(!this.meridiemCache){let e={hour:`numeric`,hourCycle:`h12`};this.meridiemCache=[Lg.utc(2016,11,13,9),Lg.utc(2016,11,13,19)].map(t=>this.extract(t,e,`dayperiod`))}return this.meridiemCache})}eras(e){return Lh(this,e,fue,()=>{let t={era:e};return this.eraCache[e]||(this.eraCache[e]=[Lg.utc(-40,1,1),Lg.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 ale(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new ole(e,this.intl,t)}relFormatter(e={}){return new sle(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Hce(this.intl,e)}isEnglish(){return this.locale===`en`||this.locale.toLowerCase()===`en-us`||Zce(this.intl).locale.startsWith(`en-us`)}getWeekSettings(){return this.weekSettings?this.weekSettings:Hle()?$ce(this.locale):cle}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})`}},lle=null,zh=class e extends Ph{static get utcInstance(){return lle===null&&(lle=new e(0)),lle}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(ag(n[1],n[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return`fixed`}get name(){return this.fixed===0?`UTC`:`UTC${sg(this.fixed,`narrow`)}`}get ianaName(){return this.fixed===0?`Etc/UTC`:`Etc/GMT${sg(-this.fixed,`narrow`)}`}offsetName(){return this.name}formatOffset(e,t){return sg(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}},ule=class extends Ph{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 Bh(e,t){if(Kh(e)||e===null)return t;if(e instanceof Ph)return e;if(zle(e)){let n=e.toLowerCase();return n===`default`?t:n===`local`||n===`system`?Pce.instance:n===`utc`||n===`gmt`?zh.utcInstance:zh.parseSpecifier(n)||Fh.create(e)}else if(qh(e))return zh.instance(e);else if(typeof e==`object`&&`offset`in e&&typeof e.offset==`function`)return e;else return new ule(e)}var dle={arab:`[٠-٩]`,arabext:`[۰-۹]`,bali:`[᭐-᭙]`,beng:`[০-৯]`,deva:`[०-९]`,fullwide:`[0-9]`,gujr:`[૦-૯]`,hanidec:`[〇|一|二|三|四|五|六|七|八|九]`,khmr:`[០-៩]`,knda:`[೦-೯]`,laoo:`[໐-໙]`,limb:`[᥆-᥏]`,mlym:`[൦-൯]`,mong:`[᠐-᠙]`,mymr:`[၀-၉]`,orya:`[୦-୯]`,tamldec:`[௦-௯]`,telu:`[౦-౯]`,thai:`[๐-๙]`,tibt:`[༠-༩]`,latn:`\\d`},fle={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]},ple=dle.hanidec.replace(/[\[|\]]/g,``).split(``);function mle(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(dle.hanidec)!==-1)t+=ple.indexOf(e[n]);else for(let e in fle){let[n,i]=fle[e];r>=n&&r<=i&&(t+=r-n)}}return parseInt(t,10)}else return t}var hle=new Map;function gle(){hle.clear()}function Vh({numberingSystem:e},t=``){let n=e||`latn`,r=hle.get(n);r===void 0&&(r=new Map,hle.set(n,r));let i=r.get(t);return i===void 0&&(i=RegExp(`${dle[n]}${t}`),r.set(t,i)),i}var _le=()=>Date.now(),vle=`system`,yle=null,ble=null,xle=null,Sle=60,Cle,wle=null,Hh=class{static get now(){return _le}static set now(e){_le=e}static set defaultZone(e){vle=e}static get defaultZone(){return Bh(vle,Pce.instance)}static get defaultLocale(){return yle}static set defaultLocale(e){yle=e}static get defaultNumberingSystem(){return ble}static set defaultNumberingSystem(e){ble=e}static get defaultOutputCalendar(){return xle}static set defaultOutputCalendar(e){xle=e}static get defaultWeekSettings(){return wle}static set defaultWeekSettings(e){wle=Kle(e)}static get twoDigitCutoffYear(){return Sle}static set twoDigitCutoffYear(e){Sle=e%100}static get throwOnInvalid(){return Cle}static set throwOnInvalid(e){Cle=e}static resetCaches(){Rh.resetCache(),Fh.resetCache(),Lg.resetCache(),gle()}},Uh=class{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},Tle=[0,31,59,90,120,151,181,212,243,273,304,334],Ele=[0,31,60,91,121,152,182,213,244,274,305,335];function Wh(e,t){return new Uh(`unit out of range`,`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function Dle(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 Ole(e,t,n){return n+(eg(e)?Ele:Tle)[t-1]}function kle(e,t){let n=eg(e)?Ele:Tle,r=n.findIndex(e=>e<t),i=t-n[r];return{month:r+1,day:i}}function Ale(e,t){return(e-t+7)%7+1}function Gh(e,t=4,n=1){let{year:r,month:i,day:a}=e,o=Ole(r,i,a),s=Ale(Dle(r,i,a),n),c=Math.floor((o-s+14-t)/7),l;return c<1?(l=r-1,c=ig(l,t,n)):c>ig(r,t,n)?(l=r+1,c=1):l=r,{weekYear:l,weekNumber:c,weekday:s,...cg(e)}}function jle(e,t=4,n=1){let{weekYear:r,weekNumber:i,weekday:a}=e,o=Ale(Dle(r,1,t),n),s=tg(r),c=i*7+a-o-7+t,l;c<1?(l=r-1,c+=tg(l)):c>s?(l=r+1,c-=tg(r)):l=r;let{month:u,day:d}=kle(l,c);return{year:l,month:u,day:d,...cg(e)}}function Mle(e){let{year:t,month:n,day:r}=e;return{year:t,ordinal:Ole(t,n,r),...cg(e)}}function Nle(e){let{year:t,ordinal:n}=e,{month:r,day:i}=kle(t,n);return{year:t,month:r,day:i,...cg(e)}}function Ple(e,t){if(!Kh(e.localWeekday)||!Kh(e.localWeekNumber)||!Kh(e.localWeekYear)){if(!Kh(e.weekday)||!Kh(e.weekNumber)||!Kh(e.weekYear))throw new Dh(`Cannot mix locale-based week fields with ISO-based week fields`);return Kh(e.localWeekday)||(e.weekday=e.localWeekday),Kh(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),Kh(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 Fle(e,t=4,n=1){let r=Jh(e.weekYear),i=Xh(e.weekNumber,1,ig(e.weekYear,t,n)),a=Xh(e.weekday,1,7);return r?i?a?!1:Wh(`weekday`,e.weekday):Wh(`week`,e.weekNumber):Wh(`weekYear`,e.weekYear)}function Ile(e){let t=Jh(e.year),n=Xh(e.ordinal,1,tg(e.year));return t?n?!1:Wh(`ordinal`,e.ordinal):Wh(`year`,e.year)}function Lle(e){let t=Jh(e.year),n=Xh(e.month,1,12),r=Xh(e.day,1,ng(e.year,e.month));return t?n?r?!1:Wh(`day`,e.day):Wh(`month`,e.month):Wh(`year`,e.year)}function Rle(e){let{hour:t,minute:n,second:r,millisecond:i}=e,a=Xh(t,0,23)||t===24&&n===0&&r===0&&i===0,o=Xh(n,0,59),s=Xh(r,0,59),c=Xh(i,0,999);return a?o?s?c?!1:Wh(`millisecond`,i):Wh(`second`,r):Wh(`minute`,n):Wh(`hour`,t)}function Kh(e){return e===void 0}function qh(e){return typeof e==`number`}function Jh(e){return typeof e==`number`&&e%1==0}function zle(e){return typeof e==`string`}function Ble(e){return Object.prototype.toString.call(e)===`[object Date]`}function Vle(){try{return typeof Intl<`u`&&!!Intl.RelativeTimeFormat}catch{return!1}}function Hle(){try{return typeof Intl<`u`&&!!Intl.Locale&&(`weekInfo`in Intl.Locale.prototype||`getWeekInfo`in Intl.Locale.prototype)}catch{return!1}}function Ule(e){return Array.isArray(e)?e:[e]}function Wle(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 Gle(e,t){return t.reduce((t,n)=>(t[n]=e[n],t),{})}function Yh(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Kle(e){if(e==null)return null;if(typeof e!=`object`)throw new Oh(`Week settings must be an object`);if(!Xh(e.firstDay,1,7)||!Xh(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(e=>!Xh(e,1,7)))throw new Oh(`Invalid week settings`);return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function Xh(e,t,n){return Jh(e)&&e>=t&&e<=n}function qle(e,t){return e-t*Math.floor(e/t)}function Zh(e,t=2){let n=e<0,r;return r=n?`-`+(``+-e).padStart(t,`0`):(``+e).padStart(t,`0`),r}function Qh(e){if(!(Kh(e)||e===null||e===``))return parseInt(e,10)}function $h(e){if(!(Kh(e)||e===null||e===``))return parseFloat(e)}function Jle(e){if(!(Kh(e)||e===null||e===``)){let t=parseFloat(`0.`+e)*1e3;return Math.floor(t)}}function Yle(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 eg(e){return e%4==0&&(e%100!=0||e%400==0)}function tg(e){return eg(e)?366:365}function ng(e,t){let n=qle(t-1,12)+1,r=e+(t-n)/12;return n===2?eg(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function rg(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 Xle(e,t,n){return-Ale(Dle(e,1,t),n)+t-1}function ig(e,t=4,n=1){let r=Xle(e,t,n),i=Xle(e+1,t,n);return(tg(e)-r+i)/7}function Zle(e){return e>99?e:e>Hh.twoDigitCutoffYear?1900+e:2e3+e}function Qle(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 ag(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 $le(e){let t=Number(e);if(typeof e==`boolean`||e===``||!Number.isFinite(t))throw new Oh(`Invalid unit value ${e}`);return t}function og(e,t){let n={};for(let r in e)if(Yh(e,r)){let i=e[r];if(i==null)continue;n[t(r)]=$le(i)}return n}function sg(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}${Zh(n,2)}:${Zh(r,2)}`;case`narrow`:return`${i}${n}${r>0?`:${r}`:``}`;case`techie`:return`${i}${Zh(n,2)}${Zh(r,2)}`;default:throw RangeError(`Value format ${t} is out of range for property format`)}}function cg(e){return Gle(e,[`hour`,`minute`,`second`,`millisecond`])}var eue=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],tue=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],nue=[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`];function rue(e){switch(e){case`narrow`:return[...nue];case`short`:return[...tue];case`long`:return[...eue];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}}var iue=[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],aue=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],oue=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function sue(e){switch(e){case`narrow`:return[...oue];case`short`:return[...aue];case`long`:return[...iue];case`numeric`:return[`1`,`2`,`3`,`4`,`5`,`6`,`7`];default:return null}}var cue=[`AM`,`PM`],lue=[`Before Christ`,`Anno Domini`],uue=[`BC`,`AD`],due=[`B`,`A`];function fue(e){switch(e){case`narrow`:return[...due];case`short`:return[...uue];case`long`:return[...lue];default:return null}}function pue(e){return cue[e.hour<12?0:1]}function mue(e,t){return sue(t)[e.weekday-1]}function hue(e,t){return rue(t)[e.month-1]}function gue(e,t){return fue(t)[e.year<0?0:1]}function _ue(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 vue(e,t){let n=``;for(let r of e)r.literal?n+=r.val:n+=t(r.val);return n}var yue={D:Nh,DD:fce,DDD:mce,DDDD:hce,t:gce,tt:_ce,ttt:vce,tttt:yce,T:bce,TT:xce,TTT:Sce,TTTT:Cce,f:wce,ff:Ece,fff:kce,ffff:jce,F:Tce,FF:Dce,FFF:Ace,FFFF:Mce},lg=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 yue[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 Zh(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?pue(t):a({hour:`numeric`,hourCycle:`h12`},`dayperiod`),c=(e,n)=>r?hue(t,e):a(n?{month:e}:{month:e,day:`numeric`},`month`),l=(e,n)=>r?mue(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?gue(t,e):a({era:e},`era`);return vue(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 vue(o,a(c,{isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]}))}},bue=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function ug(...e){let t=e.reduce((e,t)=>e+t.source,``);return RegExp(`^${t}$`)}function dg(...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 fg(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 xue(...e){return(t,n)=>{let r={},i;for(i=0;i<e.length;i++)r[e[i]]=Qh(t[n+i]);return[r,null,n+i]}}var Sue=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,Cue=`(?:${Sue.source}?(?:\\[(${bue.source})\\])?)?`,wue=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Tue=RegExp(`${wue.source}${Cue}`),Eue=RegExp(`(?:[Tt]${Tue.source})?`),Due=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Oue=/(\d{4})-?W(\d\d)(?:-?(\d))?/,kue=/(\d{4})-?(\d{3})/,Aue=xue(`weekYear`,`weekNumber`,`weekDay`),jue=xue(`year`,`ordinal`),Mue=/(\d{4})-(\d\d)-(\d\d)/,Nue=RegExp(`${wue.source} ?(?:${Sue.source}|(${bue.source}))?`),Pue=RegExp(`(?: ${Nue.source})?`);function pg(e,t,n){let r=e[t];return Kh(r)?n:Qh(r)}function Fue(e,t){return[{year:pg(e,t),month:pg(e,t+1,1),day:pg(e,t+2,1)},null,t+3]}function mg(e,t){return[{hours:pg(e,t,0),minutes:pg(e,t+1,0),seconds:pg(e,t+2,0),milliseconds:Jle(e[t+3])},null,t+4]}function hg(e,t){let n=!e[t]&&!e[t+1],r=ag(e[t+1],e[t+2]);return[{},n?null:zh.instance(r),t+3]}function gg(e,t){return[{},e[t]?Fh.create(e[t]):null,t+1]}var Iue=RegExp(`^T?${wue.source}$`),Lue=/^-?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 Rue(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($h(n)),months:f($h(r)),weeks:f($h(i)),days:f($h(a)),hours:f($h(o)),minutes:f($h(s)),seconds:f($h(c),c===`-0`),milliseconds:f(Jle(l),d)}]}var zue={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Bue(e,t,n,r,i,a,o){let s={year:t.length===2?Zle(Qh(t)):Qh(t),month:tue.indexOf(n)+1,day:Qh(r),hour:Qh(i),minute:Qh(a)};return o&&(s.second=Qh(o)),e&&(s.weekday=e.length>3?iue.indexOf(e)+1:aue.indexOf(e)+1),s}var Vue=/^(?:(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 Hue(e){let[,t,n,r,i,a,o,s,c,l,u,d]=e,f=Bue(t,i,r,n,a,o,s),p;return p=c?zue[c]:l?0:ag(u,d),[f,new zh(p)]}function Uue(e){return e.replace(/\([^()]*\)|[\n\t]/g,` `).replace(/(\s\s+)/g,` `).trim()}var Wue=/^(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$/,Gue=/^(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$/,Kue=/^(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 que(e){let[,t,n,r,i,a,o,s]=e;return[Bue(t,i,r,n,a,o,s),zh.utcInstance]}function Jue(e){let[,t,n,r,i,a,o,s]=e;return[Bue(t,s,n,r,i,a,o),zh.utcInstance]}var Yue=ug(Due,Eue),Xue=ug(Oue,Eue),Zue=ug(kue,Eue),Que=ug(Tue),$ue=dg(Fue,mg,hg,gg),ede=dg(Aue,mg,hg,gg),tde=dg(jue,mg,hg,gg),nde=dg(mg,hg,gg);function rde(e){return fg(e,[Yue,$ue],[Xue,ede],[Zue,tde],[Que,nde])}function ide(e){return fg(Uue(e),[Vue,Hue])}function ade(e){return fg(e,[Wue,que],[Gue,que],[Kue,Jue])}function ode(e){return fg(e,[Lue,Rue])}var sde=dg(mg);function cde(e){return fg(e,[Iue,sde])}var lde=ug(Mue,Pue),ude=ug(Nue),dde=dg(mg,hg,gg);function fde(e){return fg(e,[lde,$ue],[ude,dde])}var pde=`Invalid Duration`,mde={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}},hde={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},...mde},_g=146097/400,vg=146097/4800,gde={years:{quarters:4,months:12,weeks:_g/7,days:_g,hours:_g*24,minutes:_g*24*60,seconds:_g*24*60*60,milliseconds:_g*24*60*60*1e3},quarters:{months:3,weeks:_g/28,days:_g/4,hours:_g*24/4,minutes:_g*24*60/4,seconds:_g*24*60*60/4,milliseconds:_g*24*60*60*1e3/4},months:{weeks:vg/7,days:vg,hours:vg*24,minutes:vg*24*60,seconds:vg*24*60*60,milliseconds:vg*24*60*60*1e3},...mde},yg=[`years`,`quarters`,`months`,`weeks`,`days`,`hours`,`minutes`,`seconds`,`milliseconds`],_de=yg.slice(0).reverse();function bg(e,t,n=!1){return new xg({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 vde(e,t){let n=t.milliseconds??0;for(let r of _de.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function yde(e,t){let n=vde(e,t)<0?-1:1;yg.reduceRight((r,i)=>{if(Kh(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),yg.reduce((n,r)=>{if(Kh(t[r]))return n;if(n){let i=t[n]%1;t[n]-=i,t[r]+=i*e[n][r]}return r},null)}function bde(e){let t={};for(let[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}var xg=class e{constructor(e){let t=e.conversionAccuracy===`longterm`||!1,n=t?gde:hde;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||Rh.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 Oh(`Duration.fromObject: argument expected to be an object, got ${t===null?`null`:typeof t}`);return new e({values:og(t,e.normalizeUnit),loc:Rh.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(qh(t))return e.fromMillis(t);if(e.isDuration(t))return t;if(typeof t==`object`)return e.fromObject(t);throw new Oh(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){let[r]=ode(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]=cde(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 Oh(`need to specify a reason the Duration is invalid`);let r=t instanceof Uh?t:new Uh(t,n);if(Hh.throwOnInvalid)throw new uce(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 dce(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?lg.create(this.loc,n).formatDurationFromString(this,e):pde}toHuman(e={}){if(!this.isValid)return pde;let t=e.showZeros!==!1,n=yg.map(n=>{let r=this.values[n];return Kh(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+=Yle(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},Lg.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?vde(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 yg)(Yh(n.values,e)||Yh(this.values,e))&&(r[e]=n.get(e)+this.get(e));return bg(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]=$le(e(this.values[n],n));return bg(this,{values:t},!0)}get(t){return this[e.normalizeUnit(t)]}set(t){if(!this.isValid)return this;let n={...this.values,...og(t,e.normalizeUnit)};return bg(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 bg(this,i)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return yde(this.matrix,e),bg(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=bde(this.normalize().shiftToAll().toObject());return bg(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 yg)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;qh(i[e])&&(t+=i[e]);let o=Math.trunc(t);n[e]=o,r[e]=(t*1e3-o*1e3)/1e3}else qh(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 yde(this.matrix,n),bg(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 bg(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;let e=bde(this.values);return bg(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 yg)if(!t(this.values[n],e.values[n]))return!1;return!0}},Sg=`Invalid Interval`;function xde(e,t){return!e||!e.isValid?Cg.invalid(`missing or invalid start`):!t||!t.isValid?Cg.invalid(`missing or invalid end`):t<e?Cg.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 Cg=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 Oh(`need to specify a reason the Interval is invalid`);let r=t instanceof Uh?t:new Uh(t,n);if(Hh.throwOnInvalid)throw new lce(r);return new e({invalid:r})}static fromDateTimes(t,n){let r=Rg(t),i=Rg(n);return xde(r,i)??new e({start:r,end:i})}static after(t,n){let r=xg.fromDurationLike(n),i=Rg(t);return e.fromDateTimes(i,i.plus(r))}static before(t,n){let r=xg.fromDurationLike(n),i=Rg(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=Lg.fromISO(r,n),a=t.isValid}catch{a=!1}let o,s;try{o=Lg.fromISO(i,n),s=o.isValid}catch{s=!1}if(a&&s)return e.fromDateTimes(t,o);if(a){let r=xg.fromISO(i,n);if(r.isValid)return e.after(t,r)}else if(s){let t=xg.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(Rg).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=xg.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()})`:Sg}[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=Nh,t={}){return this.isValid?lg.create(this.s.loc.clone(t),e).formatInterval(this):Sg}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Sg}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Sg}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Sg}toFormat(e,{separator:t=` – `}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:Sg}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):xg.invalid(this.invalidReason)}mapEndpoints(t){return e.fromDateTimes(t(this.s),t(this.e))}},wg=class{static hasDST(e=Hh.defaultZone){let t=Lg.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return Fh.isValidZone(e)}static normalizeZone(e){return Bh(e,Hh.defaultZone)}static getStartOfWeek({locale:e=null,locObj:t=null}={}){return(t||Rh.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:t=null}={}){return(t||Rh.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:t=null}={}){return(t||Rh.create(e)).getWeekendDays().slice()}static months(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||Rh.create(t,n,i)).months(e)}static monthsFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||Rh.create(t,n,i)).months(e,!0)}static weekdays(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Rh.create(t,n,null)).weekdays(e)}static weekdaysFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||Rh.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return Rh.create(e).meridiems()}static eras(e=`short`,{locale:t=null}={}){return Rh.create(t,null,`gregory`).eras(e)}static features(){return{relative:Vle(),localeWeek:Hle()}}};function Sde(e,t){let n=e=>e.toUTC(0,{keepLocalTime:!0}).startOf(`day`).valueOf(),r=n(t)-n(e);return Math.floor(xg.fromMillis(r).as(`days`))}function Cde(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=Sde(e,t);return(n-n%7)/7}],[`days`,Sde]],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 wde(e,t,n,r){let[i,a,o,s]=Cde(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=xg.fromObject(a,r);return l.length>0?xg.fromMillis(c,r).shiftTo(...l).plus(u):u}var Tde=`missing Intl.DateTimeFormat.formatToParts support`;function Tg(e,t=e=>e){return{regex:e,deser:([e])=>t(mle(e))}}var Ede=`[ \xA0]`,Dde=new RegExp(Ede,`g`);function Ode(e){return e.replace(/\./g,`\\.?`).replace(Dde,Ede)}function kde(e){return e.replace(/\./g,``).replace(Dde,` `).toLowerCase()}function Eg(e,t){return e===null?null:{regex:RegExp(e.map(Ode).join(`|`)),deser:([n])=>e.findIndex(e=>kde(n)===kde(e))+t}}function Ade(e,t){return{regex:e,deser:([,e,t])=>ag(e,t),groups:t}}function Dg(e){return{regex:e,deser:([e])=>e}}function jde(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,`\\$&`)}function Mde(e,t){let n=Vh(t),r=Vh(t,`{2}`),i=Vh(t,`{3}`),a=Vh(t,`{4}`),o=Vh(t,`{6}`),s=Vh(t,`{1,2}`),c=Vh(t,`{1,3}`),l=Vh(t,`{1,6}`),u=Vh(t,`{1,9}`),d=Vh(t,`{2,4}`),f=Vh(t,`{4,6}`),p=e=>({regex:RegExp(jde(e.val)),deser:([e])=>e,literal:!0}),m=(m=>{if(e.literal)return p(m);switch(m.val){case`G`:return Eg(t.eras(`short`),0);case`GG`:return Eg(t.eras(`long`),0);case`y`:return Tg(l);case`yy`:return Tg(d,Zle);case`yyyy`:return Tg(a);case`yyyyy`:return Tg(f);case`yyyyyy`:return Tg(o);case`M`:return Tg(s);case`MM`:return Tg(r);case`MMM`:return Eg(t.months(`short`,!0),1);case`MMMM`:return Eg(t.months(`long`,!0),1);case`L`:return Tg(s);case`LL`:return Tg(r);case`LLL`:return Eg(t.months(`short`,!1),1);case`LLLL`:return Eg(t.months(`long`,!1),1);case`d`:return Tg(s);case`dd`:return Tg(r);case`o`:return Tg(c);case`ooo`:return Tg(i);case`HH`:return Tg(r);case`H`:return Tg(s);case`hh`:return Tg(r);case`h`:return Tg(s);case`mm`:return Tg(r);case`m`:return Tg(s);case`q`:return Tg(s);case`qq`:return Tg(r);case`s`:return Tg(s);case`ss`:return Tg(r);case`S`:return Tg(c);case`SSS`:return Tg(i);case`u`:return Dg(u);case`uu`:return Dg(s);case`uuu`:return Tg(n);case`a`:return Eg(t.meridiems(),0);case`kkkk`:return Tg(a);case`kk`:return Tg(d,Zle);case`W`:return Tg(s);case`WW`:return Tg(r);case`E`:case`c`:return Tg(n);case`EEE`:return Eg(t.weekdays(`short`,!1),1);case`EEEE`:return Eg(t.weekdays(`long`,!1),1);case`ccc`:return Eg(t.weekdays(`short`,!0),1);case`cccc`:return Eg(t.weekdays(`long`,!0),1);case`Z`:case`ZZ`:return Ade(RegExp(`([+-]${s.source})(?::(${r.source}))?`),2);case`ZZZ`:return Ade(RegExp(`([+-]${s.source})(${r.source})?`),2);case`z`:return Dg(/[a-z_+-/]{1,256}?/i);case` `:return Dg(/[^\S\n\r]/);default:return p(m)}})(e)||{invalidReason:Tde};return m.token=e,m}var Nde={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 Pde(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=Nde[o];if(typeof s==`object`&&(s=s[a]),s)return{literal:!1,val:s}}function Fde(e){return[`^${e.map(e=>e.regex).reduce((e,t)=>`${e}(${t.source})`,``)}$`,e]}function Ide(e,t,n){let r=e.match(t);if(r){let e={},t=1;for(let i in n)if(Yh(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 Lde(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 Kh(e.z)||(n=Fh.create(e.z)),Kh(e.Z)||(n||=new zh(e.Z),r=e.Z),Kh(e.q)||(e.M=(e.q-1)*3+1),Kh(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),Kh(e.u)||(e.S=Jle(e.u)),[Object.keys(e).reduce((n,r)=>{let i=t(r);return i&&(n[i]=e[r]),n},{}),n,r]}var Rde=null;function zde(){return Rde||=Lg.fromMillis(1555555555555),Rde}function Bde(e,t){if(e.literal)return e;let n=Gde(lg.macroTokenToFormatOpts(e.val),t);return n==null||n.includes(void 0)?e:n}function Vde(e,t){return Array.prototype.concat(...e.map(e=>Bde(e,t)))}var Hde=class{constructor(e,t){if(this.locale=e,this.format=t,this.tokens=Vde(lg.parseFormat(t),e),this.units=this.tokens.map(t=>Mde(t,e)),this.disqualifyingUnit=this.units.find(e=>e.invalidReason),!this.disqualifyingUnit){let[e,t]=Fde(this.units);this.regex=RegExp(e,`i`),this.handlers=t}}explainFromTokens(e){if(this.isValid){let[t,n]=Ide(e,this.regex,this.handlers),[r,i,a]=n?Lde(n):[null,null,void 0];if(Yh(n,`a`)&&Yh(n,`H`))throw new Dh(`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 Ude(e,t,n){return new Hde(e,n).explainFromTokens(t)}function Wde(e,t,n){let{result:r,zone:i,specificOffset:a,invalidReason:o}=Ude(e,t,n);return[r,i,a,o]}function Gde(e,t){if(!e)return null;let n=lg.create(t,e).dtFormatter(zde()),r=n.formatToParts(),i=n.resolvedOptions();return r.map(t=>Pde(t,e,i))}var Kde=`Invalid DateTime`,qde=864e13;function Og(e){return new Uh(`unsupported zone`,`the zone "${e.name}" is not supported`)}function Jde(e){return e.weekData===null&&(e.weekData=Gh(e.c)),e.weekData}function Yde(e){return e.localWeekData===null&&(e.localWeekData=Gh(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function kg(e,t){let n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new Lg({...n,...t,old:n})}function Xde(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 Ag(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 jg(e,t,n){return Xde(rg(e),t,n)}function Zde(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,ng(r,i))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},o=xg.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]=Xde(rg(a),n,e.zone);return o!==0&&(s+=o,c=e.zone.offset(s)),{ts:s,o:c}}function Mg(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=Lg.fromObject(e,{...n,zone:r,specificOffset:a});return o?i:i.setZone(s)}else return Lg.invalid(new Uh(`unparsable`,`the input "${i}" can't be parsed as ${r}`))}function Ng(e,t,n=!0){return e.isValid?lg.create(Rh.create(`en-US`),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function Qde(e,t,n){let r=e.c.year>9999||e.c.year<0,i=``;if(r&&e.c.year>=0&&(i+=`+`),i+=Zh(e.c.year,r?6:4),n===`year`)return i;if(t){if(i+=`-`,i+=Zh(e.c.month),n===`month`)return i;i+=`-`}else if(i+=Zh(e.c.month),n===`month`)return i;return i+=Zh(e.c.day),i}function $de(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+=Zh(e.c.hour),o===`hour`)break;if(t){if(c+=`:`,c+=Zh(e.c.minute),o===`minute`)break;s&&(c+=`:`,c+=Zh(e.c.second))}else{if(c+=Zh(e.c.minute),o===`minute`)break;s&&(c+=Zh(e.c.second))}if(o===`second`)break;s&&(!r||e.c.millisecond!==0)&&(c+=`.`,c+=Zh(e.c.millisecond,3))}return i&&(e.isOffsetFixed&&e.offset===0&&!a?c+=`Z`:e.o<0?(c+=`-`,c+=Zh(Math.trunc(-e.o/60)),c+=`:`,c+=Zh(Math.trunc(-e.o%60))):(c+=`+`,c+=Zh(Math.trunc(e.o/60)),c+=`:`,c+=Zh(Math.trunc(e.o%60)))),a&&(c+=`[`+e.zone.ianaName+`]`),c}var efe={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},tfe={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},nfe={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Pg=[`year`,`month`,`day`,`hour`,`minute`,`second`,`millisecond`],rfe=[`weekYear`,`weekNumber`,`weekday`,`hour`,`minute`,`second`,`millisecond`],ife=[`year`,`ordinal`,`hour`,`minute`,`second`,`millisecond`];function Fg(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 dce(e);return t}function afe(e){switch(e.toLowerCase()){case`localweekday`:case`localweekdays`:return`localWeekday`;case`localweeknumber`:case`localweeknumbers`:return`localWeekNumber`;case`localweekyear`:case`localweekyears`:return`localWeekYear`;default:return Fg(e)}}function ofe(e){if(Ig===void 0&&(Ig=Hh.now()),e.type!==`iana`)return e.offset(Ig);let t=e.name,n=ufe.get(t);return n===void 0&&(n=e.offset(Ig),ufe.set(t,n)),n}function sfe(e,t){let n=Bh(t.zone,Hh.defaultZone);if(!n.isValid)return Lg.invalid(Og(n));let r=Rh.fromObject(t),i,a;if(Kh(e.year))i=Hh.now();else{for(let t of Pg)Kh(e[t])&&(e[t]=efe[t]);let t=Lle(e)||Rle(e);if(t)return Lg.invalid(t);let r=ofe(n);[i,a]=jg(e,r,n)}return new Lg({ts:i,zone:n,loc:r,o:a})}function cfe(e,t,n){let r=Kh(n.round)?!0:n.round,i=Kh(n.rounding)?`trunc`:n.rounding,a=(e,a)=>(e=Yle(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 lfe(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]}var Ig,ufe=new Map,Lg=class e{constructor(e){let t=e.zone||Hh.defaultZone,n=e.invalid||(Number.isNaN(e.ts)?new Uh(`invalid input`):null)||(t.isValid?null:Og(t));this.ts=Kh(e.ts)?Hh.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=qh(e.o)&&!e.old?e.o:t.offset(this.ts);r=Ag(this.ts,a),n=Number.isNaN(r.year)?new Uh(`invalid input`):null,r=n?null:r,i=n?null:a}this._zone=t,this.loc=e.loc||Rh.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]=lfe(arguments),[n,r,i,a,o,s,c]=t;return sfe({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static utc(){let[e,t]=lfe(arguments),[n,r,i,a,o,s,c]=t;return e.zone=zh.utcInstance,sfe({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static fromJSDate(t,n={}){let r=Ble(t)?t.valueOf():NaN;if(Number.isNaN(r))return e.invalid(`invalid input`);let i=Bh(n.zone,Hh.defaultZone);return i.isValid?new e({ts:r,zone:i,loc:Rh.fromObject(n)}):e.invalid(Og(i))}static fromMillis(t,n={}){if(qh(t))return t<-qde||t>qde?e.invalid(`Timestamp out of range`):new e({ts:t,zone:Bh(n.zone,Hh.defaultZone),loc:Rh.fromObject(n)});throw new Oh(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,n={}){if(qh(t))return new e({ts:t*1e3,zone:Bh(n.zone,Hh.defaultZone),loc:Rh.fromObject(n)});throw new Oh(`fromSeconds requires a numerical input`)}static fromObject(t,n={}){t||={};let r=Bh(n.zone,Hh.defaultZone);if(!r.isValid)return e.invalid(Og(r));let i=Rh.fromObject(n),a=og(t,afe),{minDaysInFirstWeek:o,startOfWeek:s}=Ple(a,i),c=Hh.now(),l=Kh(n.specificOffset)?r.offset(c):n.specificOffset,u=!Kh(a.ordinal),d=!Kh(a.year),f=!Kh(a.month)||!Kh(a.day),p=d||f,m=a.weekYear||a.weekNumber;if((p||u)&&m)throw new Dh(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(f&&u)throw new Dh(`Can't mix ordinal dates with month/day`);let h=m||a.weekday&&!p,g,_,ee=Ag(c,l);h?(g=rfe,_=tfe,ee=Gh(ee,o,s)):u?(g=ife,_=nfe,ee=Mle(ee)):(g=Pg,_=efe);let v=!1;for(let e of g){let t=a[e];Kh(t)?v?a[e]=_[e]:a[e]=ee[e]:v=!0}let y=(h?Fle(a,o,s):u?Ile(a):Lle(a))||Rle(a);if(y)return e.invalid(y);let[b,te]=jg(h?jle(a,o,s):u?Nle(a):a,l,r),ne=new e({ts:b,zone:r,o:te,loc:i});return a.weekday&&p&&t.weekday!==ne.weekday?e.invalid(`mismatched weekday`,`you can't specify both a weekday of ${a.weekday} and a date of ${ne.toISO()}`):ne.isValid?ne:e.invalid(ne.invalid)}static fromISO(e,t={}){let[n,r]=rde(e);return Mg(n,r,t,`ISO 8601`,e)}static fromRFC2822(e,t={}){let[n,r]=ide(e);return Mg(n,r,t,`RFC 2822`,e)}static fromHTTP(e,t={}){let[n,r]=ade(e);return Mg(n,r,t,`HTTP`,t)}static fromFormat(t,n,r={}){if(Kh(t)||Kh(n))throw new Oh(`fromFormat requires an input string and a format`);let{locale:i=null,numberingSystem:a=null}=r,[o,s,c,l]=Wde(Rh.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0}),t,n);return l?e.invalid(l):Mg(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]=fde(e);return Mg(n,r,t,`SQL`,e)}static invalid(t,n=null){if(!t)throw new Oh(`need to specify a reason the DateTime is invalid`);let r=t instanceof Uh?t:new Uh(t,n);if(Hh.throwOnInvalid)throw new cce(r);return new e({invalid:r})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){let n=Gde(e,Rh.fromObject(t));return n?n.map(e=>e?e.val:null).join(``):null}static expandFormat(e,t={}){return Vde(lg.parseFormat(e),Rh.fromObject(t)).map(e=>e.val).join(``)}static resetCache(){Ig=void 0,ufe.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?Jde(this).weekYear:NaN}get weekNumber(){return this.isValid?Jde(this).weekNumber:NaN}get weekday(){return this.isValid?Jde(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?Yde(this).weekday:NaN}get localWeekNumber(){return this.isValid?Yde(this).weekNumber:NaN}get localWeekYear(){return this.isValid?Yde(this).weekYear:NaN}get ordinal(){return this.isValid?Mle(this.c).ordinal:NaN}get monthShort(){return this.isValid?wg.months(`short`,{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?wg.months(`long`,{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?wg.weekdays(`short`,{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?wg.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=rg(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=Ag(s,a),u=Ag(c,o);return l.hour===u.hour&&l.minute===u.minute&&l.second===u.second&&l.millisecond===u.millisecond?[kg(this,{ts:s}),kg(this,{ts:c})]:[this]}get isInLeapYear(){return eg(this.year)}get daysInMonth(){return ng(this.year,this.month)}get daysInYear(){return this.isValid?tg(this.year):NaN}get weeksInWeekYear(){return this.isValid?ig(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?ig(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){let{locale:t,numberingSystem:n,calendar:r}=lg.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:r}}toUTC(e=0,t={}){return this.setZone(zh.instance(e),t)}toLocal(){return this.setZone(Hh.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=Bh(t,Hh.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]=jg(r,n,t)}return kg(this,{ts:e,zone:t})}else return e.invalid(Og(t))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){let r=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return kg(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let t=og(e,afe),{minDaysInFirstWeek:n,startOfWeek:r}=Ple(t,this.loc),i=!Kh(t.weekYear)||!Kh(t.weekNumber)||!Kh(t.weekday),a=!Kh(t.ordinal),o=!Kh(t.year),s=!Kh(t.month)||!Kh(t.day),c=o||s,l=t.weekYear||t.weekNumber;if((c||a)&&l)throw new Dh(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(s&&a)throw new Dh(`Can't mix ordinal dates with month/day`);let u;i?u=jle({...Gh(this.c,n,r),...t},n,r):Kh(t.ordinal)?(u={...this.toObject(),...t},Kh(t.day)&&(u.day=Math.min(ng(u.year,u.month),u.day))):u=Nle({...Mle(this.c),...t});let[d,f]=jg(u,this.o,this.zone);return kg(this,{ts:d,o:f})}plus(e){if(!this.isValid)return this;let t=xg.fromDurationLike(e);return kg(this,Zde(this,t))}minus(e){if(!this.isValid)return this;let t=xg.fromDurationLike(e).negate();return kg(this,Zde(this,t))}startOf(e,{useLocaleWeeks:t=!1}={}){if(!this.isValid)return this;let n={},r=xg.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?lg.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):Kde}toLocaleString(e=Nh,t={}){return this.isValid?lg.create(this.loc.clone(t),e).formatDateTime(this):Kde}toLocaleParts(e={}){return this.isValid?lg.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=Fg(a);let o=e===`extended`,s=Qde(this,o,a);return Pg.indexOf(a)>=3&&(s+=`T`),s+=$de(this,o,t,n,r,i,a),s}toISODate({format:e=`extended`,precision:t=`day`}={}){return this.isValid?Qde(this,e===`extended`,Fg(t)):null}toISOWeekDate(){return Ng(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=Fg(o),(r&&Pg.indexOf(o)>=3?`T`:``)+$de(this,a===`extended`,t,e,n,i,o)):null}toRFC2822(){return Ng(this,`EEE, dd LLL yyyy HH:mm:ss ZZZ`,!1)}toHTTP(){return Ng(this.toUTC(),`EEE, dd LLL yyyy HH:mm:ss 'GMT'`)}toSQLDate(){return this.isValid?Qde(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`)),Ng(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():Kde}[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 xg.invalid(`created by diffing an invalid DateTime`);let r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=Ule(t).map(xg.normalizeUnit),a=e.valueOf()>this.valueOf(),o=wde(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?Cg.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),cfe(n,this.plus(r),{...t,numeric:`always`,units:i,unit:a})}toRelativeCalendar(t={}){return this.isValid?cfe(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 Oh(`min requires all arguments be DateTimes`);return Wle(t,e=>e.valueOf(),Math.min)}static max(...t){if(!t.every(e.isDateTime))throw new Oh(`max requires all arguments be DateTimes`);return Wle(t,e=>e.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){let{locale:r=null,numberingSystem:i=null}=n;return Ude(Rh.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 Hde(Rh.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0}),e)}static fromFormatParser(t,n,r={}){if(Kh(t)||Kh(n))throw new Oh(`fromFormatParser requires an input string and a format parser`);let{locale:i=null,numberingSystem:a=null}=r,o=Rh.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0});if(!o.equals(n.locale))throw new Oh(`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):Mg(s,c,r,`format ${n.format}`,t,l)}static get DATE_SHORT(){return Nh}static get DATE_MED(){return fce}static get DATE_MED_WITH_WEEKDAY(){return pce}static get DATE_FULL(){return mce}static get DATE_HUGE(){return hce}static get TIME_SIMPLE(){return gce}static get TIME_WITH_SECONDS(){return _ce}static get TIME_WITH_SHORT_OFFSET(){return vce}static get TIME_WITH_LONG_OFFSET(){return yce}static get TIME_24_SIMPLE(){return bce}static get TIME_24_WITH_SECONDS(){return xce}static get TIME_24_WITH_SHORT_OFFSET(){return Sce}static get TIME_24_WITH_LONG_OFFSET(){return Cce}static get DATETIME_SHORT(){return wce}static get DATETIME_SHORT_WITH_SECONDS(){return Tce}static get DATETIME_MED(){return Ece}static get DATETIME_MED_WITH_SECONDS(){return Dce}static get DATETIME_MED_WITH_WEEKDAY(){return Oce}static get DATETIME_FULL(){return kce}static get DATETIME_FULL_WITH_SECONDS(){return Ace}static get DATETIME_HUGE(){return jce}static get DATETIME_HUGE_WITH_SECONDS(){return Mce}};function Rg(e){if(Lg.isDateTime(e))return e;if(e&&e.valueOf&&qh(e.valueOf()))return Lg.fromJSDate(e);if(e&&typeof e==`object`)return Lg.fromObject(e);throw new Oh(`Unknown datetime argument: ${e}, of type ${typeof e}`)}function dfe(e){return eh(e)?e.expression.variable?.value?.toLowerCase()===`null`:e instanceof Yp}function ffe(e){return Gm(e).unwrap_or(void 0)===``}function pfe(e){let t=Km(e);if(t!==null)return t;if(Fm(e)&&e instanceof Fp&&e.expression){let t=e.op?.value,n=Km(e.expression);if(n!==null)return t===`-`?-n:n}return null}function zg(e){if(e==null)return null;if(typeof e==`number`)return e;if(typeof e==`string`){let t=Number(e);return isNaN(t)?null:t}if(typeof e==`boolean`)return e?1:0;let t=pfe(e);if(t!==null)return t;let n=Gm(e).unwrap_or(void 0);if(n!==void 0){let e=Number(n);if(!isNaN(e))return e}return null}function mfe(e){if(e==null)return null;if(typeof e==`number`)return Number.isInteger(e)?e:null;if(typeof e==`string`){let t=Number(e);return isNaN(t)||!Number.isInteger(t)?null:t}if(typeof e==`boolean`)return e?1:0;let t=pfe(e);if(t!==null)return Number.isInteger(t)?t:null;let n=Gm(e).unwrap_or(void 0);if(n!==void 0){let e=Number(n);if(!isNaN(e)&&Number.isInteger(e))return e}return null}var hfe=[`true`,`yes`,`y`,`t`,`1`],gfe=[`false`,`no`,`n`,`f`,`0`];function Bg(e){if(e==null)return null;if(typeof e==`boolean`)return e;if(typeof e==`number`)return e===0?!1:e===1?!0:null;if(typeof e==`string`){let t=e.toLowerCase();return hfe.includes(t)?!0:gfe.includes(t)?!1:null}if(eh(e)){let t=e.expression.variable?.value?.toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}let t=Km(e);if(t===0)return!1;if(t===1)return!0;let n=Gm(e)?.unwrap_or(``).toLowerCase();if(n){if(hfe.includes(n))return!0;if(gfe.includes(n))return!1}return null}function _fe(e){if(e==null)return null;if(typeof e==`string`)return e;let t=Bm(e).unwrap_or(void 0);return t?bp(t):Gm(e).unwrap_or(null)}function Vg(e){if(e==null)return null;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return e.toString();let t=Gm(e).unwrap_or(null)??zg(e)??Bg(e);return t===null?null:t.toString()}var vfe=[`yyyy-MM-dd`,`M/d/yyyy`,`d MMM yyyy`,`MMM d, yyyy`],yfe=[`yyyy-MM-dd HH:mm:ss`,`yyyy-MM-dd HH:mm:ss.SSS`,`yyyy-MM-dd HH:mm:ss.SSSZZ`,`yyyy-MM-dd HH:mm:ssZZ`],bfe=[`HH:mm:ss`,`HH:mm:ssZZ`,`HH:mm:ss.SSS`,`HH:mm:ss.SSSZZ`];function Hg(e){if(e==null)return null;let t=typeof e==`string`?e:Gm(e).unwrap_or(null);if(t===null)return null;for(let e of bfe){let n=Lg.fromFormat(t,e,{setZone:!0});if(n.isValid)return n.toISOTime({suppressMilliseconds:!0,includeOffset:r(n)})}for(let e of vfe){let n=Lg.fromFormat(t,e,{setZone:!0});if(n.isValid)return n.toISODate()}for(let e of yfe){let n=Lg.fromFormat(t,e,{setZone:!0});if(n.isValid)return n.toISO({suppressMilliseconds:!0,includeOffset:r(n)})}let n=Lg.fromISO(t,{setZone:!0});if(n.isValid)return n.toISO({suppressMilliseconds:!0,includeOffset:r(n)});return null;function r(e){return e.zone.type!==`system`}}function Ug(e,t,n){return t.map((t,r)=>{let i=e[t]?.value;if(i==null&&n&&n[r]){let e=n[r];if(e?.dbdefault)return JSON.stringify(e.dbdefault.value)}return JSON.stringify(i)}).join(`|`)}function xfe(e,t,n){return t.some((t,r)=>{let i=e[t]?.value;return i==null&&n&&n[r]&&n[r]?.dbdefault?!1:i==null})}function Sfe(e){return e.increment||Th(e.type.type_name)}function Cfe(e,t,n){return e?`${e}.${t}.${n}`:`${t}.${n}`}function Wg(e,t,n){return n.length===1?Cfe(e,t,n[0]):`(${n.map(n=>Cfe(e,t,n)).join(`, `)})`}function wfe(e,t){return t.length===1?JSON.stringify(e[t[0]]?.value):`(${t.map(t=>JSON.stringify(e[t]?.value)).join(`, `)})`}function Gg(e,t,n){let r=t.map(t=>e.columnNodes[t]).filter(Boolean);return r.length>0?r.map(e=>new P(N.INVALID_RECORDS_FIELD,n,e)):[new P(N.INVALID_RECORDS_FIELD,n,e.node)]}var Tfe=e=>e>1?`Composite PK`:`PK`;function Efe(e){return xp(Array.from(e.records),([t,{rows:n}])=>{if(Cp(n))return[];e.cachedMergedTables.has(t)||e.cachedMergedTables.set(t,gh(t,e));let r=e.cachedMergedTables.get(t),i=Afe(r),a=jfe(n),o=doe(r.fields,`name`);return xp(i,e=>Dfe(e,n,a,o,r))})}function Dfe(e,t,n,r,i){let a=Mfe(e,n,r,i,t);if(!Cp(a))return a;let o=Zre(e.map(e=>r[e])),s=o.every(e=>e&&Sfe(e)),[c,l]=wp(t,t=>xfe(t.values,e,o)),u=s?[]:Ofe(c,e,i),d=kfe(l,e,o,i);return[...u,...d]}function Ofe(e,t,n){if(Cp(e))return[];let r=`NULL in ${Tfe(t.length)}: ${Wg(n.schemaName,n.name,t)} cannot be NULL`;return xp(e,e=>Gg(e,t,r))}function kfe(e,t,n,r){return xp(Kae(ooe(e,e=>Ug(e.values,t,n)),e=>e.length>1),e=>{let n=Tfe(t.length),i=Wg(r.schemaName,r.name,t);return xp(e.slice(1),e=>Gg(e,t,`Duplicate ${n}: ${i} = ${wfe(e.values,t)}`))})}function Afe(e){return[...e.fields.filter(e=>e.pk).map(e=>[e.name]),...e.indexes.filter(e=>e.pk).map(e=>e.columns.map(e=>e.value))]}function jfe(e){return new Set(e.flatMap(e=>Object.keys(e.values)))}function Mfe(e,t,n,r,i){let a=zae(e,Array.from(t));if(Cp(a))return[];let o=a.filter(e=>{let t=n[e];return t&&!t.increment&&!Th(t.type.type_name)&&!t.dbdefault});if(Cp(o))return[];let s=`${Tfe(o.length)}: Column ${Wg(r.schemaName,r.name,o)} is missing from record and has no default value`;return i.map(e=>new P(N.INVALID_RECORDS_FIELD,s,e.node))}var Nfe=e=>e>1?`Composite UNIQUE`:`UNIQUE`;function Pfe(e){return xp(Array.from(e.records),([t,{rows:n}])=>{e.cachedMergedTables.has(t)||e.cachedMergedTables.set(t,gh(t,e));let r=e.cachedMergedTables.get(t);if(Cp(n))return[];let i=Ffe(r),a=doe(r.fields,`name`);return xp(i,e=>Ife(n,e,Zre(e.map(e=>a[e])),r))})}function Ffe(e){return[...e.fields.filter(e=>e.unique).map(e=>[e.name]),...e.indexes.filter(e=>e.unique).map(e=>e.columns.map(e=>e.value))]}function Ife(e,t,n,r){return xp(Kae(ooe(e.filter(e=>!xfe(e.values,t,n)),e=>Ug(e.values,t,n)),e=>e.length>1),e=>{let n=Nfe(t.length),i=Wg(r.schemaName,r.name,t);return xp(e.slice(1),e=>Gg(e,t,`Duplicate ${n}: ${i} = ${wfe(e.values,t)}`))})}function Lfe(e){let t=[...e.ref.values(),...xp(Array.from(e.tables.values()),t=>Kse(t,e))],n=Rfe(e);return xp(t,e=>Bfe(e,n))}function Rfe(e){let t=new Map;for(let n of e.tables.values()){let r=zfe(n.schemaName,n.name),i=e.records.get(n)?.rows||[];e.cachedMergedTables.has(n)||e.cachedMergedTables.set(n,gh(n,e));let a=e.cachedMergedTables.get(n);t.set(r,{mergedTable:a,rows:i})}return t}function zfe(e,t){return e?`${e}.${t}`:`${pm}.${t}`}function Kg(e,t,n,r){if(Cp(e.rows))return[];let i=new Set(t.rows.map(e=>Ug(e.values,r.fieldNames)));return xp(e.rows.filter(e=>!xfe(e.values,n.fieldNames)).filter(e=>{let t=Ug(e.values,n.fieldNames);return!i.has(t)}),i=>{let a=Wg(e.mergedTable.schemaName,e.mergedTable.name,n.fieldNames),o=Wg(t.mergedTable.schemaName,t.mergedTable.name,r.fieldNames),s=`FK violation: ${a} = ${wfe(i.values,n.fieldNames)} does not exist in ${o}`;return Gg(i,n.fieldNames,s)})}function Bfe(e,t){if(!e.endpoints)return[];let[n,r]=e.endpoints,i=t.get(zfe(n.schemaName,n.tableName)),a=t.get(zfe(r.schemaName,r.tableName));return!i||!a?[]:Vfe(i,a,n,r)}function Vfe(e,t,n,r){let i=n.relation,a=r.relation;return i===`1`&&a===`1`||i===`*`&&a===`*`?[...Kg(e,t,n,r),...Kg(t,e,r,n)]:i===`*`&&a===`1`?Kg(e,t,n,r):i===`1`&&a===`*`?Kg(t,e,r,n):[]}var Hfe=class{constructor(e){this.env=e,this.tableToRecordMap=new Map}interpret(e){let t=[],n=[];for(let r of e){let{table:e,mergedColumns:i}=Ufe(r,this.env),a=this.tableToRecordMap.get(e);if(a){t.push(new P(N.DUPLICATE_RECORDS_FOR_TABLE,`Duplicate Records blocks for the same Table '${e.name}' - A Table can only have one Records block`,a)),t.push(new P(N.DUPLICATE_RECORDS_FOR_TABLE,`Duplicate Records blocks for the same Table '${e.name}' - A Table can only have one Records block`,r));continue}this.tableToRecordMap.set(e,r),this.env.records.has(e)||this.env.records.set(e,{element:r,rows:[]});let o=this.env.records.get(e);for(let e of r.body.body){let r=e,a=Wfe(r,i,this.env);t.push(...a.getErrors()),n.push(...a.getWarnings());let s=a.getValue();s.row&&o.rows.push({values:s.row,node:r,columnNodes:s.columnNodes})}}let r=this.validateConstraints();return n.push(...r),new rm(void 0,t,n)}validateConstraints(){let e=[];return e.push(...Efe(this.env).map(e=>e.toWarning())),e.push(...Pfe(this.env).map(e=>e.toWarning())),e.push(...Lfe(this.env).map(e=>e.toWarning())),e}};function Ufe(e,t){let n=e.name,r=e.parent;if(r instanceof Mp){let e=t.tables.get(r),i=gh(e,t);return n?{table:e,mergedTable:i,mergedColumns:n.elementList.map(e=>i.fields.find(t=>t.name===Hm(e).unwrap()))}:{table:e,mergedTable:i,mergedColumns:i.fields}}let i=cse(n).unwrap(),a=bp(i.variables).referee.declaration,o=t.tables.get(a),s=gh(o,t);return{table:o,mergedTable:s,mergedColumns:i.args.map(e=>s.fields.find(t=>t.name===Hm(e).unwrap()))}}function Wfe(e,t,n){let r=[],i=[],a={},o={},s=e.callee instanceof Up?e.callee.elementList:[e.callee];if(s.length!==t.length)return r.push(new P(N.INVALID_RECORDS_FIELD,`Expected ${t.length} values but got ${s.length}`,e)),new rm({row:null,columnNodes:{}},r,i);for(let e=0;e<t.length;e++){let c=s[e],l=t[e];o[l.name]=c;let u=Kfe(c,l,n);r.push(...u.getErrors()),i.push(...u.getWarnings());let d=u.getValue();d!==null&&(a[l.name]=d)}return new rm({row:a,columnNodes:o},r,i)}function Gfe(e,t){return e instanceof Rp?e.value?.value||``:!isNaN(e.start)&&!isNaN(e.end)?t.slice(e.start,e.end):``}function Kfe(e,t,n){let r=t.type.type_name.split(`(`)[0],{increment:i,not_null:a,dbdefault:o}=t,s=t.type.isEnum||!1,c=sce(r,s),l=Vg(e),u=l===null?Gfe(e,n.source):l,d=l===null?`expression`:c;if(e instanceof Rp)return new rm({value:e.value?.value||``,type:`expression`},[],[]);if(dfe(e)||ffe(e)&&!Sh(r)){let n=o&&o.value.toString().toLowerCase()!==`null`,s=Th(r);return a&&!n&&!i&&!s?new rm({value:null,type:c},[],[new nm(N.INVALID_RECORDS_FIELD,`NULL not allowed for non-nullable column '${t.name}' without default and increment`,e)]):new rm({value:null,type:c},[],[])}if(s){let r=([...n.enums.values()].find(e=>e.schemaName===t.type.schemaName&&e.name===t.type.type_name)?.values||[]).map(e=>e.name),i=Gm(e).unwrap_or(void 0);return i===void 0&&(i=Bm(e).unwrap_or([]).pop()),r.includes(i)?new rm({value:i,type:c},[],[]):new rm({value:i,type:c},[],[new nm(N.INVALID_RECORDS_FIELD,`Invalid enum value for column '${t.name}'`,e)])}if(bh(r)){let n=zg(e);if(n===null)return new rm({value:u,type:d},[],[new nm(N.INVALID_RECORDS_FIELD,`Invalid numeric value for column '${t.name}'`,e)]);if(vh(r)&&!Number.isInteger(n))return new rm({value:Math.floor(n),type:c},[],[new nm(N.INVALID_RECORDS_FIELD,`Invalid integer value ${n} for column '${t.name}': expected integer, got decimal`,e)]);if(yh(r)&&t.type.numericParams){let{precision:r,scale:i}=t.type.numericParams,a=n.toString().split(`.`),o=a[0].replace(/^-/,``),s=a[1]||``,l=o.length+s.length,u=s.length;if(l>r)return new rm({value:n,type:c},[],[new nm(N.INVALID_RECORDS_FIELD,`Numeric value ${n} for column '${t.name}' exceeds precision: expected at most ${r} total digits, got ${l}`,e)]);if(u>i)return new rm({value:n,type:c},[],[new nm(N.INVALID_RECORDS_FIELD,`Numeric value ${n} for column '${t.name}' exceeds scale: expected at most ${i} decimal digits, got ${u}`,e)])}return new rm({value:n,type:c},[],[])}if(xh(r)){let n=Bg(e);return n===null?new rm({value:u,type:d},[],[new nm(N.INVALID_RECORDS_FIELD,`Invalid boolean value for column '${t.name}'`,e)]):new rm({value:n,type:c},[],[])}if(wh(r)){let n=Hg(e);return n===null?new rm({value:u,type:d},[],[new nm(N.INVALID_RECORDS_FIELD,`Invalid datetime value for column '${t.name}', expected valid datetime format (e.g., 'YYYY-MM-DD', 'HH:MM:SS', 'YYYY-MM-DD HH:MM:SS', 'MM/DD/YYYY', 'D MMM YYYY', or 'MMM D, YYYY')`,e)]):new rm({value:n,type:c},[],[])}if(Sh(r)){let n=Vg(e);if(n===null)return new rm({value:u,type:d},[],[new nm(N.INVALID_RECORDS_FIELD,`Invalid string value for column '${t.name}'`,e)]);if(t.type.lengthParam){let{length:r}=t.type.lengthParam,i=new TextEncoder().encode(n).length;if(i>r)return new rm({value:n,type:c},[],[new nm(N.INVALID_RECORDS_FIELD,`String value for column '${t.name}' exceeds maximum length: expected at most ${r} bytes (UTF-8), got ${i} bytes`,e)])}return new rm({value:n,type:`string`},[],[])}return new rm({value:u,type:d},[],[])}function qfe(e){return{...e,fields:e.fields.map(e=>({...e,type:{...e.type,isEnum:void 0,lengthParam:void 0,numericParams:void 0}}))}}function Jfe(e){let t=[];for(let[n,{element:r,rows:i}]of e.records){if(!i.length)continue;let e=Object.keys(i[0].columnNodes);t.push({schemaName:n.schemaName||void 0,tableName:n.name,columns:e,token:dh(r),values:i.map(t=>e.map(e=>{let n=t.values[e];return n?{value:n.value,type:n.type}:{value:null,type:`expression`}}))})}return{schemas:[],tables:Array.from(e.tables.values()).map(qfe),notes:Array.from(e.notes.values()),refs:Array.from(e.ref.values()),enums:Array.from(e.enums.values()),tableGroups:Array.from(e.tableGroups.values()),aliases:e.aliases,project:Array.from(e.project.values())[0]||{},tablePartials:Array.from(e.tablePartials.values()).map(qfe),records:t}}var Yfe=class{constructor(e){this.ast=e,this.env={schema:[],tables:new Map,notes:new Map,refIds:{},ref:new Map,enums:new Map,tableOwnerGroup:{},tableGroups:new Map,aliases:[],project:new Map,tablePartials:new Map,records:new Map,recordsElements:[],cachedMergedTables:new Map,source:e.source}}interpret(){let e=this.ast.body.flatMap(e=>{switch(Rm(e).unwrap_or(void 0)){case mm.Table:return new qse(e,this.env).interpret();case mm.Note:return new Jse(e,this.env).interpret();case mm.Ref:return new Yse(e,this.env).interpret();case mm.TableGroup:return new Xse(e,this.env).interpret();case mm.TablePartial:return new Qse(e,this.env).interpret();case mm.Enum:return new Zse(e,this.env).interpret();case mm.Project:return new $se(e,this.env).interpret();case mm.Records:return this.env.recordsElements.push(e),[];default:return[]}}),t=[];if(this.env.recordsElements.length){let n=new Hfe(this.env).interpret(this.env.recordsElements);e.push(...n.getErrors()),t.push(...n.getWarnings())}return new rm(Jfe(this.env),e,t)}},qg=function(e){return e[e.Function=1]=`Function`,e[e.Constructor=2]=`Constructor`,e[e.Field=3]=`Field`,e[e.Variable=4]=`Variable`,e[e.Class=5]=`Class`,e[e.Struct=6]=`Struct`,e[e.Interface=7]=`Interface`,e[e.Module=8]=`Module`,e[e.Property=9]=`Property`,e[e.Event=10]=`Event`,e[e.Operator=11]=`Operator`,e[e.Unit=12]=`Unit`,e[e.Value=13]=`Value`,e[e.Constant=14]=`Constant`,e[e.Enum=15]=`Enum`,e[e.EnumMember=16]=`EnumMember`,e[e.Keyword=17]=`Keyword`,e[e.Text=18]=`Text`,e[e.Color=19]=`Color`,e[e.File=20]=`File`,e[e.Reference=21]=`Reference`,e[e.Customcolor=22]=`Customcolor`,e[e.Folder=23]=`Folder`,e[e.TypeParameter=24]=`TypeParameter`,e[e.User=25]=`User`,e[e.Issue=26]=`Issue`,e[e.Snippet=27]=`Snippet`,e}({}),Jg=function(e){return e[e.None=0]=`None`,e[e.KeepWhitespace=1]=`KeepWhitespace`,e[e.InsertAsSnippet=4]=`InsertAsSnippet`,e}({}),Xfe=function(e){return e[e.Hint=1]=`Hint`,e[e.Info=2]=`Info`,e[e.Warning=4]=`Warning`,e[e.Error=8]=`Error`,e}({});function Zfe(e){return e?e.split(``).every(e=>im(e)||am(e))&&!am(e[0]):!1}function Yg(e){return Zfe(e)?e:`"${Xg(e)}"`}function Qfe(e){let t=``,n=0,r={n:`
12
12
  `,t:` `,r:`\r`,b:`\b`,f:`\f`,v:`\v`,0:`\0`,"\\":`\\`,'"':`"`,"'":`'`,"`":"`"};for(;n<e.length;)if(e[n]===`\\`&&n+1<e.length){let i=e[n+1];if(i===`u`&&n+5<e.length){let r=e.slice(n+2,n+6);if(/^[0-9a-fA-F]{4}$/.test(r)){t+=String.fromCharCode(parseInt(r,16)),n+=6;continue}}i in r?(t+=r[i],n+=2):(t+=i,n+=2)}else t+=e[n],n++;return t}function Xg(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];switch(r){case`\\`:t+=`\\\\`;break;case`"`:t+=`\\"`;break;case`'`:t+=`\\'`;break;case`
13
13
  `:t+=`\\n`;break;case` `:t+=`\\t`;break;case`\r`:t+=`\\r`;break;case`\b`:t+=`\\b`;break;case`\f`:t+=`\\f`;break;case`\v`:t+=`\\v`;break;case`\0`:t+=`\\0`;break;default:t+=r}}return t}function $fe(e){if(e==null)return`null`;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return String(e);if(typeof e==`string`)return`'${Xg(e)}'`;let{value:t,type:n}=e;if(t==null||xh(n)&&typeof t==`string`&&t.toLowerCase()===`null`)return`null`;if(n===`expression`)return typeof t==`string`&&t.toLowerCase().trim()===`null`?`null`:`\`${t}\``;if(xh(n)){let e=Bg(t);return e===null?`\`${t}\``:e?`true`:`false`}if(bh(n)){let e=zg(t);return e===null?`\`${t}\``:String(e)}if(wh(n)){let e=Hg(t);return e===null?`\`${t}\``:`'${Xg(e)}'`}let r=Vg(t);return r===null?`\`${t}\``:`'${Xg(r)}'`}function epe(e){return(e.match(/"(?:[^"\\]|\\.)*"|[^."]+/g)||[]).map(e=>e.startsWith(`"`)&&e.endsWith(`"`)?Qfe(e.slice(1,-1)):e.trim()).filter(e=>e.length>0)}function Zg(e){switch(e){case gm.Schema:return qg.Module;case gm.Table:case gm.TablePartial:return qg.Class;case gm.Column:case gm.TableGroupField:return qg.Field;case gm.Enum:return qg.Enum;case gm.EnumField:return qg.EnumMember;case gm.TableGroup:return qg.Struct;default:return qg.Text}}function Qg(e,t){if(!e||Op(e))return!1;for(let n of e.trailingTrivia){if(n.start>t)break;if(n.kind===Tp.NEWLINE&&n.end<=t)return!1}return!0}function $g(){return{suggestions:[]}}function e_(e){return{...e,suggestions:e.suggestions.map(e=>({...e,insertText:` ${e.insertText}`}))}}function t_(e){return{...e,suggestions:e.suggestions.map(e=>({...e,insertText:e.quoted?e.insertText:Yg(e.insertText??``),quoted:!0}))}}function tpe(e,t=`, `){let n=e.suggestions.map(e=>typeof e.label==`string`?e.label:e.label.label).join(t);return n?{...e,suggestions:[{label:`* (all)`,insertText:n,insertTextRules:Jg.KeepWhitespace,kind:qg.Snippet,sortText:`00`,range:void 0},...e.suggestions]}:e}function npe(e,t){return e<t.start||e>t.end?!1:t.body?e<t.body.start||e>t.body.end:!0}function rpe(e){return e.commaList.length+e.elementList.length===0}function ipe(e){let t=[];for(let[n,r]of e.symbolTable.entries()){let e=Em(n).unwrap_or(void 0);if(e===void 0||e.kind!==gm.Column||!(r instanceof em||r instanceof tm))continue;let i=ape(r,e.name);i&&t.push(i)}return t}function ape(e,t){let n=ym(t),r=e instanceof tm?e.tablePartialSymbol.symbolTable.get(n)?.declaration:e.declaration;if(!(r instanceof zp))return null;let i=Hm(r.callee).unwrap_or(null),a=Hm(r.args[0]).unwrap_or(null);return i===null||a===null?null:{name:i,type:a}}function ope(e,t,n,r){let i=e.container.element(r);return!(i instanceof Mp)||Rm(i).unwrap_or(void 0)!==mm.Records||!(i.body instanceof Bp)||!i.body||!cm(r,i.body)||t.getLineContent(n.lineNumber).trim()!==``?null:i.parent instanceof jp?spe(e,i):cpe(e,i)}function spe(e,t){if(!(t.name instanceof Gp))return $g();let n=t.name.argumentList?.elementList||[],r=n.map(e=>qm(e));if(!r||r.length===0)return $g();let i=n.map((e,t)=>{let n=r[t];if(!n||!(n instanceof em||n instanceof tm))return null;let i=Hm(e).unwrap_or(void 0);return i?ape(n,i):null}).filter(e=>e!==null);return i.length===0?$g():{suggestions:[{label:`Record row snippet`,insertText:i.map((e,t)=>`\${${t+1}:${e.name} (${e.type})}`).join(`, `),insertTextRules:Jg.InsertAsSnippet,kind:qg.Snippet,range:void 0}]}}function cpe(e,t){let n=t.parent;if(!(n instanceof Mp))return $g();let r=n.symbol;if(!(r instanceof $p))return $g();let i;if(t.name instanceof Hp){let e=t.name.elementList,n=e.map(e=>qm(e)).filter(e=>e!==void 0);i=e.map((e,t)=>{let r=n[t];if(!r||!(r instanceof em||r instanceof tm))return null;let i=Hm(e).unwrap_or(void 0);return i===void 0?null:ape(r,i)}).filter(e=>e!==null)}else{let e=ipe(r);if(!e)return $g();i=e}return i.length===0?$g():{suggestions:[{label:`Record row snippet`,insertText:i.map((e,t)=>`\${${t+1}:${e.name} (${e.type})}`).join(`, `),insertTextRules:Jg.InsertAsSnippet,kind:qg.Snippet,range:void 0}]}}function lpe(e,t){return e.getOffsetAt(t)}var upe=class{constructor(e,t=[]){this.compiler=e,this.triggerCharacters=t}provideCompletionItems(e,t){let n=lpe(e,t),r=ope(this.compiler,e,t,n);if(r!==null)return r;let i=this.compiler.token.flatStream(),{token:a,index:o}=this.compiler.container.token(n),s=o===void 0?i[0]:i[o+1];if([...a?.trailingTrivia||[],...a?.leadingTrivia||[],...s?.leadingTrivia||[]].find(e=>Doe(e)&&cm(n,e)))return $g();if(o===void 0)return bpe();if([Tp.STRING_LITERAL,Tp.QUOTED_STRING].includes(a.kind)&&cm(n,a))return $g();let c=this.compiler.container.element(n);if(this.compiler.container.scopeKind(n)===i_.TOPLEVEL||c instanceof Mp&&c.type&&c.type.start<=n&&c.type.end>=n)return bpe();let l=[...this.compiler.container.stack(n)].reverse();for(let e of l)if(e instanceof Fp)switch(e.op?.value){case`>`:case`<`:case`<>`:case`-`:return fpe(this.compiler,n,e);case`~`:return dpe(this.compiler,n);default:}else if(e instanceof Ip)switch(e.op?.value){case`>`:case`<`:case`<>`:case`-`:return fpe(this.compiler,n,e);case`.`:return vpe(this.compiler,n,e);default:}else if(e instanceof Pp)return hpe(this.compiler,n,e);else if(e instanceof Vp)return hpe(this.compiler,n,e);else if(e instanceof Hp)return ppe(this.compiler,n,e);else if(e instanceof Up)return mpe(this.compiler,n);else if(e instanceof Gp)return Epe(this.compiler,n,e);else if(e instanceof zp)return ype(this.compiler,n,e);else if(e instanceof Mp){if(npe(n,e))return Tpe(this.compiler,n,e);if(e.bodyColon&&n>=e.bodyColon.end||e.body&&cm(n,e.body))return ype(this.compiler,n,void 0)}return $g()}};function dpe(e,t){return r_(e,t,e.parse.ast(),[gm.TablePartial])}function fpe(e,t,n){let r=e.container.scopeKind(t);if([i_.REF,i_.TABLE,i_.TABLEPARTIAL].includes(r)){let r=r_(e,t,e.container.element(t),[gm.Table,gm.Schema,gm.Column]);return Qg(n.op,t)?e_(r):r}return $g()}function n_(e,t,n){return t_({suggestions:e.symbol.members(t).filter(({kind:e})=>n.includes(e)).map(({name:e,kind:t})=>({label:e,insertText:e,insertTextRules:Jg.KeepWhitespace,kind:Zg(t),sortText:Zg(t).toString().padStart(2,`0`),range:void 0}))})}function r_(e,t,n,r){if(n===void 0)return $g();let i=n,a={suggestions:[]};for(;i;){if(i?.symbol?.symbolTable){let{symbol:t}=i;a.suggestions.push(...n_(e,t,r).suggestions)}i=i instanceof Mp?i.parent:void 0}return t_(a)}function ppe(e,t,n){let r=e.container.scopeKind(t),i=e.container.element(t),a=[...e.container.stack(t)];for(let r of a)if(r instanceof Gp&&r.argumentList===n)return Epe(e,t,r);if(i instanceof Mp&&Rm(i).unwrap_or(void 0)===mm.Records&&!(i.name instanceof Gp)&&npe(t,i)){let t=i.parent?.symbol||i.name?.referee;if(t){let r=n_(e,t,[gm.Column]);return rpe(n)?tpe(r):r}}switch(r){case i_.INDEXES:return Ape(e,t);case i_.REF:for(;a.length>0;){let n=a.pop();if(n instanceof Ip&&n.op?.value===`.`)return vpe(e,t,n)}return wpe(e,t);default:break}return $g()}function mpe(e,t){return e.container.scopeKind(t)===i_.RECORDS?r_(e,t,e.container.element(t),[gm.Schema,gm.Enum,gm.EnumField]):$g()}function hpe(e,t,n){let{token:r}=e.container.token(t);if([Tp.COMMA,Tp.LBRACKET].includes(r?.kind)){let n=gpe(e,t);return r?.kind===Tp.COMMA&&Qg(r,t)?e_(n):n}if(n.name&&n.name.start<=t&&n.name.end>=t)return gpe(e,t);if(n.name instanceof Np){let i=_pe(e,t,rh(n.name).unwrap_or(``));return r?.kind===Tp.COLON&&Qg(r,t)?e_(i):i}return $g()}function gpe(e,t){let n=e.container.element(t);if(n instanceof jp)return $g();let r=e.container.scopeKind(t);if(n.body&&!cm(t,n.body)){let e;switch(r){case i_.TABLE:case i_.TABLEPARTIAL:e=[hm.HeaderColor,hm.Note];break;case i_.TABLEGROUP:e=[hm.Color,hm.Note];break;default:e=[]}return{suggestions:e.map(e=>({label:e,insertText:`${e}: `,kind:qg.Field,insertTextRules:Jg.KeepWhitespace,range:void 0}))}}switch(r){case i_.TABLE:case i_.TABLEPARTIAL:return{suggestions:[...[hm.PK,hm.PrimaryKey,hm.Null,hm.NotNull,hm.Increment,hm.Unique].map(e=>({label:e,insertText:e,kind:qg.Property,insertTextRules:Jg.KeepWhitespace,range:void 0})),...[hm.Ref,hm.Default,hm.Note,hm.Check].map(e=>({label:e,insertText:`${e}: `,kind:qg.Property,insertTextRules:Jg.KeepWhitespace,range:void 0}))]};case i_.ENUM:return{suggestions:[...[hm.Note].map(e=>({label:e,insertText:`${e}: `,kind:qg.Property,insertTextRules:Jg.KeepWhitespace,range:void 0}))]};case i_.INDEXES:return{suggestions:[...[hm.Unique,hm.PK].map(e=>({label:e,insertText:e,insertTextRules:Jg.KeepWhitespace,kind:qg.Property,range:void 0})),...[hm.Note,hm.Name,hm.Type].map(e=>({label:e,insertText:`${e}: `,kind:qg.Property,insertTextRules:Jg.KeepWhitespace,range:void 0}))]};case i_.REF:return{suggestions:[hm.Update,hm.Delete,hm.Color].map(e=>({label:e,insertText:`${e}: `,kind:qg.Property,insertTextRules:Jg.KeepWhitespace,range:void 0}))};case i_.CHECKS:return{suggestions:[hm.Name].map(e=>({label:e,insertText:`${e}: `,kind:qg.Property,insertTextRules:Jg.KeepWhitespace,range:void 0}))};default:break}return $g()}function _pe(e,t,n){switch(n?.toLowerCase()){case`update`:case`delete`:return{suggestions:[`cascade`,`set default`,`set null`,`restrict`].map(e=>({label:e,insertText:e,kind:qg.Value,insertTextRules:Jg.KeepWhitespace,range:void 0}))};case`type`:return{suggestions:[`btree`,`hash`].map(e=>({label:e,insertText:`${e}`,kind:qg.Value,insertTextRules:Jg.KeepWhitespace,range:void 0}))};case`default`:return r_(e,t,e.container.element(t),[gm.Schema,gm.Enum]);default:break}return $g()}function vpe(e,t,n){let r=zm(n).unwrap_or([]);if(r.pop(),r.some(e=>!$m(e)))return $g();let i=r.map(e=>Hm(e).unwrap());return t_({suggestions:e.symbol.ofName(i,e.container.element(t)).flatMap(({symbol:t})=>e.symbol.members(t)).map(({kind:e,name:t})=>({label:t,insertText:t,kind:Zg(e),range:void 0}))})}function ype(e,t,n){switch(e.container.scopeKind(t)){case i_.TABLE:case i_.TABLEPARTIAL:return Spe(e,t,n);case i_.PROJECT:return Cpe(e,t,n);case i_.INDEXES:return Ope(e,t);case i_.ENUM:return xpe(e,t,n);case i_.REF:{let n=wpe(e,t);return e.container.token(t).token?.kind===Tp.COLON&&Qg(e.container.token(t).token,t)?e_(n):n}case i_.TABLEGROUP:return Dpe(e);default:return $g()}}function bpe(){return{suggestions:[`Table`,`TableGroup`,`Enum`,`Project`,`Ref`,`TablePartial`,`Records`].map(e=>({label:e,insertText:e,insertTextRules:Jg.KeepWhitespace,kind:qg.Keyword,range:void 0}))}}function xpe(e,t,n){return n?.callee&&jpe(t,n)===1?r_(e,t,e.container.element(t),[gm.Schema,gm.Table,gm.Column]):$g()}function Spe(e,t,n){let r=[`Note`,`indexes`,`checks`,`Records`];if(!n?.callee)return{suggestions:r.map(e=>({label:e,insertText:e,insertTextRules:Jg.KeepWhitespace,kind:qg.Keyword,range:void 0}))};let i=jpe(t,n);return i===0?{suggestions:r.map(e=>({label:e,insertText:e,insertTextRules:Jg.KeepWhitespace,kind:qg.Keyword,range:void 0}))}:i===1?kpe(e,t):$g()}function Cpe(e,t,n){return!n?.callee||jpe(t,n)===0?{suggestions:[`Table`,`TableGroup`,`Enum`,`Note`,`Ref`,`TablePartial`].map(e=>({label:e,insertText:e,insertTextRules:Jg.KeepWhitespace,kind:qg.Keyword,range:void 0}))}:$g()}function wpe(e,t){return r_(e,t,e.container.element(t),[gm.Schema,gm.Table,gm.Column])}function Tpe(e,t,n){return Rm(n).unwrap_or(void 0)===mm.Records?r_(e,t,n.parent,[gm.Schema,gm.Table]):$g()}function Epe(e,t,n){let r=e.container.element(t),i=n.callee&&cm(t,n.callee),a=n.argumentList&&cm(t,n.argumentList);if(r instanceof Mp&&Rm(r).unwrap_or(void 0)===mm.Records&&npe(t,r)){if(i)return r_(e,t,r.parent,[gm.Schema,gm.Table]);if(!a)return $g();let o=n.callee;if(!o)return $g();let s=zm(o).unwrap_or([o]),c=s[s.length-1]?.referee;if(!c)return $g();let l=n_(e,c,[gm.Column]),{argumentList:u}=n;return!u||!rpe(u)?l:tpe(l)}let o=[...e.container.stack(t)];for(let r of o){if(!a||!(r instanceof zp)||r.callee!==n||Hm(n.callee).unwrap_or(``).toLowerCase()!==mm.Records)continue;let i=e.container.element(t).symbol;if(!i)return $g();let o=n_(e,i,[gm.Column]),{argumentList:s}=n;return!s||!rpe(s)?o:tpe(o)}return $g()}function Dpe(e){return{suggestions:[...t_({suggestions:[...e.parse.publicSymbolTable().entries()].flatMap(([e])=>{let t=Em(e).unwrap_or(void 0);if(t===void 0)return[];let{kind:n,name:r}=t;return n!==gm.Table&&n!==gm.Schema?[]:{label:r,insertText:r,insertTextRules:Jg.KeepWhitespace,kind:Zg(n),range:void 0}})}).suggestions,...[`Note`].map(e=>({label:e,insertText:e,insertTextRules:Jg.KeepWhitespace,kind:qg.Keyword,range:void 0}))]}}function Ope(e,t){return Ape(e,t)}function kpe(e,t){return{suggestions:[...`integer.int.tinyint.smallint.mediumint.bigint.bit.bool.binary.varbinary.logical.char.nchar.varchar.varchar2.nvarchar.nvarchar2.binary_float.binary_double.float.double.decimal.dec.real.money.smallmoney.enum.tinyblob.tinytext.blob.text.mediumblob.mediumtext.longblob.longtext.ntext.set.inet6.uuid.image.date.time.datetime.datetime2.timestamp.year.smalldatetime.datetimeoffset.XML.sql_variant.uniqueidentifier.CURSOR.BFILE.CLOB.NCLOB.RAW`.split(`.`).map(e=>({label:e,insertText:e,insertTextRules:Jg.KeepWhitespace,kind:qg.TypeParameter,sortText:qg.TypeParameter.toString().padStart(2,`0`),range:void 0})),...r_(e,t,e.container.element(t),[gm.Enum,gm.Schema]).suggestions]}}function Ape(e,t){let n=e.container.element(t)?.parent;if(!(n?.symbol instanceof $p))return $g();let{symbolTable:r}=n.symbol;return t_({suggestions:[...r.entries()].flatMap(([e])=>{let t=Em(e).unwrap_or(void 0);if(t===void 0)return[];let{name:n}=t;return{label:n,insertText:n,insertTextRules:Jg.KeepWhitespace,kind:Zg(gm.Column),range:void 0}})})}function jpe(e,t){if(!t.callee)return-1;let n=[t.callee,...t.args],r=n.findIndex(t=>e<=t.end);return r===-1?n.length:r}var Mpe=class{constructor(e){this.compiler=e}provideDefinition(e,t){let{uri:n}=e,r=lpe(e,t),i=[...this.compiler.container.stack(r)];for(;i.length!==0;){let e=i.pop();if(!e?.referee)continue;let t;if(e.referee?.declaration&&[Ap.PRIMARY_EXPRESSION,Ap.VARIABLE].includes(e?.kind)&&({declaration:t}=e.referee),t){let{startPos:e,endPos:r}=t;return[{range:{startColumn:e.column+1,startLineNumber:e.line+1,endColumn:r.column+1,endLineNumber:r.line+1},uri:n}]}}return[]}},Npe=class{constructor(e){this.compiler=e}provideReferences(e,t){let{uri:n}=e,r=lpe(e,t),i=[...this.compiler.container.stack(r)];for(;i.length!==0;){let e=i.pop();if(e&&[Ap.ELEMENT_DECLARATION,Ap.FUNCTION_APPLICATION,Ap.PRIMARY_EXPRESSION].includes(e?.kind)){let{symbol:t}=e;if(t?.references.length)return t.references.map(({startPos:e,endPos:t})=>({range:{startColumn:e.column+1,startLineNumber:e.line+1,endColumn:t.column+1,endLineNumber:t.line+1},uri:n}))}}return[]}},Ppe=class{constructor(e){this.compiler=e}provideDiagnostics(){let e=[],t=this.compiler.parse._(),n=t.getErrors();for(let t of n)e.push(this.createDiagnostic(t,`error`));let r=t.getWarnings();for(let t of r)e.push(this.createDiagnostic(t,`warning`));return e}provideErrors(){return this.compiler.parse._().getErrors().map(e=>this.createDiagnostic(e,`error`))}provideWarnings(){return this.compiler.parse._().getWarnings().map(e=>this.createDiagnostic(e,`warning`))}provideMarkers(){return this.provideDiagnostics().map(e=>({severity:this.getSeverityValue(e.type),message:e.text,startLineNumber:e.startRow,startColumn:e.startColumn,endLineNumber:e.endRow,endColumn:e.endColumn,code:e.code?String(e.code):void 0}))}createDiagnostic(e,t){let n=e.nodeOrToken,r=n.startPos,i=n.endPos;return{type:t,text:e.diagnostic,startRow:r.line+1,startColumn:r.column+1,endRow:i.line+1,endColumn:i.column+1,code:e.code}}getSeverityValue(e){return e===`error`?Xfe.Error:Xfe.Warning}},Fpe=od({CompletionItemInsertTextRule:()=>Jg,CompletionItemKind:()=>qg,DBMLCompletionItemProvider:()=>upe,DBMLDefinitionProvider:()=>Mpe,DBMLDiagnosticsProvider:()=>Ppe,DBMLReferencesProvider:()=>Npe,MarkerSeverity:()=>Xfe},1);function Ipe(){return this.parse._().getValue().ast}function Lpe(){return this.parse._().getErrors()}function Rpe(){return this.parse._().getWarnings()}function zpe(){return this.parse._().getValue().tokens}function Bpe(){return this.parse._().getValue().rawDb}function Vpe(){return this.parse._().getValue().ast.symbol.symbolTable}function Hpe(){return this.parse.tokens().flatMap(e=>[...e.leadingInvalid,e,...e.trailingInvalid])}function Upe(){return this.parse.tokens().filter(Xm)}function Wpe(e){return e.symbolTable?[...e.symbolTable.entries()].map(([e,t])=>({...Em(e).unwrap(),symbol:t})):[]}function Gpe(e,t){if(e.length===0)return[];let n=[];for(let r=t;r;r=r instanceof Mp?r.parent:void 0){if(!r.symbol?.symbolTable)continue;let{symbolTable:t}=r.symbol,i=[t],a=[];for(let t of e)a=i.flatMap(e=>Fse(t).flatMap(t=>{let n=e.get(t),r=Em(t).unwrap_or(void 0);return!n||!r?[]:{...r,symbol:n}})),i=a.flatMap(e=>e.symbol.symbolTable?e.symbol.symbolTable:[]);n.push(...a)}return n}function Kpe(e,t){return`${e.join(`.`)}@${t.id}`}function qpe(e){let t=this.token.flatStream(),{index:n,token:r}=this.container.token(e),i=n===void 0?-1:Xae(t,e=>!e.isInvalid,n);if(i===-1)return[this.parse.ast()];let a=t[i].start,o=this.parse.ast(),s=[o];for(;;){let e=fse(o).find(e=>cm(a,e));if(e===void 0||e instanceof Ep)break;s.push(e),o=e}if(r?.kind===Tp.COLON)return s;for(;s.length>0;){let t=!1,n=bp(s);if(n instanceof zp){let r=this.parse.source();for(let i=n.end;i<e;i+=1)r[i]===`
14
14
  `&&(s.pop(),t=!0)}else n instanceof Fp||n instanceof Ip?this.container.token(e).token!==n.op&&(s.pop(),t=!0):n instanceof Vp?n.listCloseBracket&&n.end<=e&&(s.pop(),t=!0):n instanceof Hp?n.tupleCloseParen&&n.end<=e&&(s.pop(),t=!0):n instanceof Up?n.end<=e&&(s.pop(),t=!0):n instanceof Bp?n.blockCloseBrace&&n.end<=e&&(s.pop(),t=!0):n instanceof Np||n.end<e&&(s.pop(),t=!0);if(t){let t=bp(s);t instanceof Mp&&t.end<=e&&s.pop()}if(!t)break}return s}function Jpe(e){let t=this.token.flatStream().findIndex(t=>t.start>=e);return t===void 0||t<=0?{token:void 0,index:void 0}:{token:this.token.flatStream()[t-1],index:t-1}}function Ype(e){let t=this.container.stack(e);for(let e=t.length-1;e>=0;--e)if(t[e]instanceof Mp)return t[e];return this.parse.ast()}function Xpe(e){return this.container.element(e)?.symbol?.symbolTable}var i_=function(e){return e[e.TABLE=0]=`TABLE`,e[e.ENUM=1]=`ENUM`,e[e.TABLEGROUP=2]=`TABLEGROUP`,e[e.INDEXES=3]=`INDEXES`,e[e.NOTE=4]=`NOTE`,e[e.REF=5]=`REF`,e[e.PROJECT=6]=`PROJECT`,e[e.CUSTOM=7]=`CUSTOM`,e[e.TOPLEVEL=8]=`TOPLEVEL`,e[e.TABLEPARTIAL=9]=`TABLEPARTIAL`,e[e.CHECKS=10]=`CHECKS`,e[e.RECORDS=11]=`RECORDS`,e}({});function Zpe(e){let t=this.container.element(e);if(t instanceof jp)return i_.TOPLEVEL;switch(t.type?.value.toLowerCase()){case`table`:return i_.TABLE;case`enum`:return i_.ENUM;case`ref`:return i_.REF;case`tablegroup`:return i_.TABLEGROUP;case`indexes`:return i_.INDEXES;case`note`:return i_.NOTE;case`project`:return i_.PROJECT;case`tablepartial`:return i_.TABLEPARTIAL;case`checks`:return i_.CHECKS;case`records`:return i_.RECORDS;default:return i_.CUSTOM}}function Qpe(e,t){let n=[...t].sort((e,t)=>t.start-e.start),r=e;for(let{start:e,end:t,newText:i}of n)r=r.substring(0,e)+i+r.substring(t);return r}function $pe(e){if(typeof e!=`string`)return{schema:e.schema??`public`,table:e.table};let t=epe(e);if(t.length===0)return{schema:pm,table:``};if(t.length===1)return{schema:pm,table:t[0]};if(t.length===2)return{schema:t[0],table:t[1]};let n=t[t.length-1];return{schema:t.slice(0,-1).join(`.`),table:n}}function eme(e,t,n){let r=vm(n);if(t===`public`){let t=e.get(r);return t instanceof $p?t:null}let i=_m(t),a=e.get(i);if(!a||!a.symbolTable)return null;let o=a.symbolTable.get(r);return o instanceof $p?o:null}function tme(e){return e.startsWith(`"`)&&e.endsWith(`"`)&&e.length>=2?e.slice(1,-1):e}function nme(e){return e?e.split(``).every(e=>im(e)||am(e))&&!am(e[0]):!1}function rme(e,t){if(!e.declaration)return!1;let n=e.declaration;if(!n.name)return!1;let r=n.name;return t.substring(r.start,r.end).includes(`"`)}function ime(e,t,n){let r=!nme(t),i=!nme(e),a=n||r,o=n||i;return{schema:e,table:t,formattedSchema:o?`"${e}"`:e,formattedTable:a?`"${t}"`:t,shouldQuoteSchema:o,shouldQuoteTable:a}}function ame(e,t,n,r,i){let a=vm(i),o;if(r===`public`)o=e.get(a);else{let t=_m(r),n=e.get(t);if(!n||!n.symbolTable)return!1;o=n.symbolTable.get(a)}return!(!o||t===r&&n===i)}function ome(e,t,n){let r=e.start-1;for(;r>=0&&/\s/.test(n[r]);)r--;if(r<0||n[r]!==`.`)return null;for(r--;r>=0&&/\s/.test(n[r]);)r--;if(r<0)return null;let i,a;if(n[r]===`"`){for(a=r+1,r--;r>=0&&n[r]!==`"`;)r--;if(r<0)return null;i=r}else{for(a=r+1;r>=0&&/[a-zA-Z0-9_]/.test(n[r]);)r--;i=r+1}return tme(n.substring(i,a))===t?{start:i,end:e.end}:null}function sme(e,t,n,r){let i=[],a=new Set;for(let o of e){let e=ome(o,t,r)??{start:o.start,end:o.end},s=`${e.start}-${e.end}`;if(a.has(s))continue;a.add(s);let c=n.schema===`public`?n.formattedTable:`${n.formattedSchema}.${n.formattedTable}`;i.push({start:e.start,end:e.end,newText:c})}return i}function cme(e,t){let n=this.parse.source(),r=this.parse.publicSymbolTable(),i=$pe(e),a=$pe(t),o=i.schema,s=i.table,c=a.schema,l=a.table,u=eme(r,o,s);if(!u||ame(r,o,s,c,l))return n;let d=ime(c,l,rme(u,n)),f=[];if(u.declaration){let e=u.declaration;e.name&&f.push(e.name)}for(let e of u.references)n.substring(e.start,e.end).replace(/"/g,``)===s&&f.push(e);return Qpe(n,sme(f,o,d,n))}var lme=class{constructor(){this.source=``,this.cache=new Map,this.nodeIdGenerator=new Ooe,this.symbolIdGenerator=new koe,this.token={invalidStream:this.query(Upe),flatStream:this.query(Hpe)},this.parse={source:()=>this.source,_:this.query(this.interpret),ast:this.query(Ipe),errors:this.query(Lpe),warnings:this.query(Rpe),tokens:this.query(zpe),rawDb:this.query(Bpe),publicSymbolTable:this.query(Vpe)},this.container={stack:this.query(qpe),token:this.query(Jpe),element:this.query(Ype),scope:this.query(Xpe),scopeKind:this.query(Zpe)},this.symbol={ofName:this.query(Gpe,Kpe),members:this.query(Wpe)}}setSource(e){this.source=e,this.cache.clear(),this.nodeIdGenerator.reset(),this.symbolIdGenerator.reset()}query(e,t){let n=Symbol();return((...r)=>{if(r.length===0){if(this.cache.has(n))return this.cache.get(n);let t=e.apply(this,r);return this.cache.set(n,t),t}let i=t?t(...r):r[0],a=this.cache.get(n);if(a instanceof Map&&a.has(i))return a.get(i);let o=e.apply(this,r);return a instanceof Map||(a=new Map,this.cache.set(n,a)),a.set(i,o),o})}interpret(){let e=new mse(this.source).lex().chain(e=>new _se(this.source,e,this.nodeIdGenerator).parse()).chain(({ast:e,tokens:t})=>new Bse(e,this.symbolIdGenerator).analyze().map(()=>({ast:e,tokens:t})));return e.getErrors().length>0?e:e.chain(({ast:e,tokens:t})=>new Yfe(e).interpret().map(n=>({ast:e,tokens:t,rawDb:n})))}renameTable(e,t){return cme.call(this,e,t)}applyTextEdits(e){return Qpe(this.parse.source(),e)}initMonacoServices(){return{definitionProvider:new Mpe(this),referenceProvider:new Npe(this),autocompletionProvider:new upe(this),diagnosticsProvider:new Ppe(this)}}};const a_=`public`,ume=`table`,dme=`note`,fme=`enum`,pme=`ref`,mme=`table_group`;var o_=class extends Error{},hme=class extends o_{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},gme=class extends o_{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},_me=class extends o_{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},s_=class extends o_{},vme=class extends o_{constructor(e){super(`Invalid unit ${e}`)}},c_=class extends o_{},l_=class extends o_{constructor(){super(`Zone is an abstract class`)}},u_=`numeric`,d_=`short`,f_=`long`,p_={year:u_,month:u_,day:u_},yme={year:u_,month:d_,day:u_},bme={year:u_,month:d_,day:u_,weekday:d_},xme={year:u_,month:f_,day:u_},Sme={year:u_,month:f_,day:u_,weekday:f_},Cme={hour:u_,minute:u_},wme={hour:u_,minute:u_,second:u_},Tme={hour:u_,minute:u_,second:u_,timeZoneName:d_},Eme={hour:u_,minute:u_,second:u_,timeZoneName:f_},Dme={hour:u_,minute:u_,hourCycle:`h23`},Ome={hour:u_,minute:u_,second:u_,hourCycle:`h23`},kme={hour:u_,minute:u_,second:u_,hourCycle:`h23`,timeZoneName:d_},Ame={hour:u_,minute:u_,second:u_,hourCycle:`h23`,timeZoneName:f_},jme={year:u_,month:u_,day:u_,hour:u_,minute:u_},Mme={year:u_,month:u_,day:u_,hour:u_,minute:u_,second:u_},Nme={year:u_,month:d_,day:u_,hour:u_,minute:u_},Pme={year:u_,month:d_,day:u_,hour:u_,minute:u_,second:u_},Fme={year:u_,month:d_,day:u_,weekday:d_,hour:u_,minute:u_},Ime={year:u_,month:f_,day:u_,hour:u_,minute:u_,timeZoneName:d_},Lme={year:u_,month:f_,day:u_,hour:u_,minute:u_,second:u_,timeZoneName:d_},Rme={year:u_,month:f_,day:u_,weekday:f_,hour:u_,minute:u_,timeZoneName:f_},zme={year:u_,month:f_,day:u_,weekday:f_,hour:u_,minute:u_,second:u_,timeZoneName:f_},m_=class{get type(){throw new l_}get name(){throw new l_}get ianaName(){return this.name}get isUniversal(){throw new l_}offsetName(e,t){throw new l_}formatOffset(e,t){throw new l_}offset(e){throw new l_}equals(e){throw new l_}get isValid(){throw new l_}},h_=null,Bme=class e extends m_{static get instance(){return h_===null&&(h_=new e),h_}get type(){return`system`}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return Xhe(e,t,n)}formatOffset(e,t){return X_(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type===`system`}get isValid(){return!0}},g_=new Map;function Vme(e){let t=g_.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`}),g_.set(e,t)),t}var Hme={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Ume(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 Wme(e,t){let n=e.formatToParts(t),r=[];for(let e=0;e<n.length;e++){let{type:t,value:i}=n[e],a=Hme[t];t===`era`?r[a]=i:F_(a)||(r[a]=parseInt(i,10))}return r}var __=new Map,v_=class e extends m_{static create(t){let n=__.get(t);return n===void 0&&__.set(t,n=new e(t)),n}static resetCache(){__.clear(),g_.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 Xhe(e,t,n,this.name)}formatOffset(e,t){return X_(this.offset(e),t)}offset(e){if(!this.valid)return NaN;let t=new Date(e);if(isNaN(t))return NaN;let n=Vme(this.name),[r,i,a,o,s,c,l]=n.formatToParts?Wme(n,t):Ume(n,t);o===`BC`&&(r=-Math.abs(r)+1);let u=K_({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}},Gme={};function Kme(e,t={}){let n=JSON.stringify([e,t]),r=Gme[n];return r||(r=new Intl.ListFormat(e,t),Gme[n]=r),r}var qme=new Map;function Jme(e,t={}){let n=JSON.stringify([e,t]),r=qme.get(n);return r===void 0&&(r=new Intl.DateTimeFormat(e,t),qme.set(n,r)),r}var Yme=new Map;function Xme(e,t={}){let n=JSON.stringify([e,t]),r=Yme.get(n);return r===void 0&&(r=new Intl.NumberFormat(e,t),Yme.set(n,r)),r}var Zme=new Map;function Qme(e,t={}){let{base:n,...r}=t,i=JSON.stringify([e,r]),a=Zme.get(i);return a===void 0&&(a=new Intl.RelativeTimeFormat(e,t),Zme.set(i,a)),a}var y_=null;function $me(){return y_||(y_=new Intl.DateTimeFormat().resolvedOptions().locale,y_)}var ehe=new Map;function the(e){let t=ehe.get(e);return t===void 0&&(t=new Intl.DateTimeFormat(e).resolvedOptions(),ehe.set(e,t)),t}var nhe=new Map;function rhe(e){let t=nhe.get(e);if(!t){let n=new Intl.Locale(e);t=`getWeekInfo`in n?n.getWeekInfo():n.weekInfo,`minimalDays`in t||(t={...fhe,...t}),nhe.set(e,t)}return t}function ihe(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=Jme(e).resolvedOptions(),r=e}catch{let i=e.substring(0,n);t=Jme(i).resolvedOptions(),r=i}let{numberingSystem:i,calendar:a}=t;return[r,i,a]}}function ahe(e,t,n){return n||t?(e.includes(`-u-`)||(e+=`-u`),n&&(e+=`-ca-${n}`),t&&(e+=`-nu-${t}`),e):e}function ohe(e){let t=[];for(let n=1;n<=12;n++){let r=jv.utc(2009,n,1);t.push(e(r))}return t}function she(e){let t=[];for(let n=1;n<=7;n++){let r=jv.utc(2016,11,13+n);t.push(e(r))}return t}function b_(e,t,n,r){let i=e.listingMode();return i===`error`?null:i===`en`?n(t):r(t)}function che(e){return e.numberingSystem&&e.numberingSystem!==`latn`?!1:e.numberingSystem===`latn`||!e.locale||e.locale.startsWith(`en`)||the(e.locale).numberingSystem===`latn`}var lhe=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=Xme(e,t)}}format(e){if(this.inf){let t=this.floor?Math.floor(e):e;return this.inf.format(t)}else return B_(this.floor?Math.floor(e):qhe(e,3),this.padTo)}},uhe=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&&v_.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=Jme(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()}},dhe=class{constructor(e,t,n){this.opts={style:`long`,...n},!t&&zhe()&&(this.rtf=Qme(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):hge(t,e,this.opts.numeric,this.opts.style!==`long`)}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}},fhe={firstDay:1,minimalDays:4,weekend:[6,7]},x_=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||O_.defaultLocale;return new e(o||(a?`en-US`:$me()),n||O_.defaultNumberingSystem,r||O_.defaultOutputCalendar,Whe(i)||O_.defaultWeekSettings,o)}static resetCache(){y_=null,qme.clear(),Yme.clear(),Zme.clear(),ehe.clear(),nhe.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]=ihe(e);this.locale=a,this.numberingSystem=t||o||null,this.outputCalendar=n||s||null,this.weekSettings=r,this.intl=ahe(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??=che(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,Whe(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 b_(this,e,tge,()=>{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]=ohe(t)}return this.monthsCache[i][e]})}weekdays(e,t=!1){return b_(this,e,age,()=>{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]=she(e=>this.extract(e,n,`weekday`))),this.weekdaysCache[r][e]})}meridiems(){return b_(this,void 0,()=>oge,()=>{if(!this.meridiemCache){let e={hour:`numeric`,hourCycle:`h12`};this.meridiemCache=[jv.utc(2016,11,13,9),jv.utc(2016,11,13,19)].map(t=>this.extract(t,e,`dayperiod`))}return this.meridiemCache})}eras(e){return b_(this,e,uge,()=>{let t={era:e};return this.eraCache[e]||(this.eraCache[e]=[jv.utc(-40,1,1),jv.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 lhe(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new uhe(e,this.intl,t)}relFormatter(e={}){return new dhe(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Kme(this.intl,e)}isEnglish(){return this.locale===`en`||this.locale.toLowerCase()===`en-us`||the(this.intl).locale.startsWith(`en-us`)}getWeekSettings(){return this.weekSettings?this.weekSettings:Bhe()?rhe(this.locale):fhe}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})`}},S_=null,C_=class e extends m_{static get utcInstance(){return S_===null&&(S_=new e(0)),S_}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(J_(n[1],n[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return`fixed`}get name(){return this.fixed===0?`UTC`:`UTC${X_(this.fixed,`narrow`)}`}get ianaName(){return this.fixed===0?`Etc/UTC`:`Etc/GMT${X_(-this.fixed,`narrow`)}`}offsetName(){return this.name}formatOffset(e,t){return X_(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}},phe=class extends m_{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 w_(e,t){if(F_(e)||e===null)return t;if(e instanceof m_)return e;if(Lhe(e)){let n=e.toLowerCase();return n===`default`?t:n===`local`||n===`system`?Bme.instance:n===`utc`||n===`gmt`?C_.utcInstance:C_.parseSpecifier(n)||v_.create(e)}else if(I_(e))return C_.instance(e);else if(typeof e==`object`&&`offset`in e&&typeof e.offset==`function`)return e;else return new phe(e)}var T_={arab:`[٠-٩]`,arabext:`[۰-۹]`,bali:`[᭐-᭙]`,beng:`[০-৯]`,deva:`[०-९]`,fullwide:`[0-9]`,gujr:`[૦-૯]`,hanidec:`[〇|一|二|三|四|五|六|七|八|九]`,khmr:`[០-៩]`,knda:`[೦-೯]`,laoo:`[໐-໙]`,limb:`[᥆-᥏]`,mlym:`[൦-൯]`,mong:`[᠐-᠙]`,mymr:`[၀-၉]`,orya:`[୦-୯]`,tamldec:`[௦-௯]`,telu:`[౦-౯]`,thai:`[๐-๙]`,tibt:`[༠-༩]`,latn:`\\d`},mhe={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]},hhe=T_.hanidec.replace(/[\[|\]]/g,``).split(``);function ghe(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(T_.hanidec)!==-1)t+=hhe.indexOf(e[n]);else for(let e in mhe){let[n,i]=mhe[e];r>=n&&r<=i&&(t+=r-n)}}return parseInt(t,10)}else return t}var E_=new Map;function _he(){E_.clear()}function D_({numberingSystem:e},t=``){let n=e||`latn`,r=E_.get(n);r===void 0&&(r=new Map,E_.set(n,r));let i=r.get(t);return i===void 0&&(i=RegExp(`${T_[n]}${t}`),r.set(t,i)),i}var vhe=()=>Date.now(),yhe=`system`,bhe=null,xhe=null,She=null,Che=60,whe,The=null,O_=class{static get now(){return vhe}static set now(e){vhe=e}static set defaultZone(e){yhe=e}static get defaultZone(){return w_(yhe,Bme.instance)}static get defaultLocale(){return bhe}static set defaultLocale(e){bhe=e}static get defaultNumberingSystem(){return xhe}static set defaultNumberingSystem(e){xhe=e}static get defaultOutputCalendar(){return She}static set defaultOutputCalendar(e){She=e}static get defaultWeekSettings(){return The}static set defaultWeekSettings(e){The=Whe(e)}static get twoDigitCutoffYear(){return Che}static set twoDigitCutoffYear(e){Che=e%100}static get throwOnInvalid(){return whe}static set throwOnInvalid(e){whe=e}static resetCaches(){x_.resetCache(),v_.resetCache(),jv.resetCache(),_he()}},k_=class{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},Ehe=[0,31,59,90,120,151,181,212,243,273,304,334],Dhe=[0,31,60,91,121,152,182,213,244,274,305,335];function A_(e,t){return new k_(`unit out of range`,`you specified ${t} (of type ${typeof t}) as a ${e}, which is invalid`)}function j_(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 Ohe(e,t,n){return n+(U_(e)?Dhe:Ehe)[t-1]}function khe(e,t){let n=U_(e)?Dhe:Ehe,r=n.findIndex(e=>e<t),i=t-n[r];return{month:r+1,day:i}}function M_(e,t){return(e-t+7)%7+1}function N_(e,t=4,n=1){let{year:r,month:i,day:a}=e,o=Ohe(r,i,a),s=M_(j_(r,i,a),n),c=Math.floor((o-s+14-t)/7),l;return c<1?(l=r-1,c=q_(l,t,n)):c>q_(r,t,n)?(l=r+1,c=1):l=r,{weekYear:l,weekNumber:c,weekday:s,...Z_(e)}}function Ahe(e,t=4,n=1){let{weekYear:r,weekNumber:i,weekday:a}=e,o=M_(j_(r,1,t),n),s=W_(r),c=i*7+a-o-7+t,l;c<1?(l=r-1,c+=W_(l)):c>s?(l=r+1,c-=W_(r)):l=r;let{month:u,day:d}=khe(l,c);return{year:l,month:u,day:d,...Z_(e)}}function P_(e){let{year:t,month:n,day:r}=e;return{year:t,ordinal:Ohe(t,n,r),...Z_(e)}}function jhe(e){let{year:t,ordinal:n}=e,{month:r,day:i}=khe(t,n);return{year:t,month:r,day:i,...Z_(e)}}function Mhe(e,t){if(!F_(e.localWeekday)||!F_(e.localWeekNumber)||!F_(e.localWeekYear)){if(!F_(e.weekday)||!F_(e.weekNumber)||!F_(e.weekYear))throw new s_(`Cannot mix locale-based week fields with ISO-based week fields`);return F_(e.localWeekday)||(e.weekday=e.localWeekday),F_(e.localWeekNumber)||(e.weekNumber=e.localWeekNumber),F_(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 Nhe(e,t=4,n=1){let r=L_(e.weekYear),i=z_(e.weekNumber,1,q_(e.weekYear,t,n)),a=z_(e.weekday,1,7);return r?i?a?!1:A_(`weekday`,e.weekday):A_(`week`,e.weekNumber):A_(`weekYear`,e.weekYear)}function Phe(e){let t=L_(e.year),n=z_(e.ordinal,1,W_(e.year));return t?n?!1:A_(`ordinal`,e.ordinal):A_(`year`,e.year)}function Fhe(e){let t=L_(e.year),n=z_(e.month,1,12),r=z_(e.day,1,G_(e.year,e.month));return t?n?r?!1:A_(`day`,e.day):A_(`month`,e.month):A_(`year`,e.year)}function Ihe(e){let{hour:t,minute:n,second:r,millisecond:i}=e,a=z_(t,0,23)||t===24&&n===0&&r===0&&i===0,o=z_(n,0,59),s=z_(r,0,59),c=z_(i,0,999);return a?o?s?c?!1:A_(`millisecond`,i):A_(`second`,r):A_(`minute`,n):A_(`hour`,t)}function F_(e){return e===void 0}function I_(e){return typeof e==`number`}function L_(e){return typeof e==`number`&&e%1==0}function Lhe(e){return typeof e==`string`}function Rhe(e){return Object.prototype.toString.call(e)===`[object Date]`}function zhe(){try{return typeof Intl<`u`&&!!Intl.RelativeTimeFormat}catch{return!1}}function Bhe(){try{return typeof Intl<`u`&&!!Intl.Locale&&(`weekInfo`in Intl.Locale.prototype||`getWeekInfo`in Intl.Locale.prototype)}catch{return!1}}function Vhe(e){return Array.isArray(e)?e:[e]}function Hhe(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 Uhe(e,t){return t.reduce((t,n)=>(t[n]=e[n],t),{})}function R_(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Whe(e){if(e==null)return null;if(typeof e!=`object`)throw new c_(`Week settings must be an object`);if(!z_(e.firstDay,1,7)||!z_(e.minimalDays,1,7)||!Array.isArray(e.weekend)||e.weekend.some(e=>!z_(e,1,7)))throw new c_(`Invalid week settings`);return{firstDay:e.firstDay,minimalDays:e.minimalDays,weekend:Array.from(e.weekend)}}function z_(e,t,n){return L_(e)&&e>=t&&e<=n}function Ghe(e,t){return e-t*Math.floor(e/t)}function B_(e,t=2){let n=e<0,r;return r=n?`-`+(``+-e).padStart(t,`0`):(``+e).padStart(t,`0`),r}function V_(e){if(!(F_(e)||e===null||e===``))return parseInt(e,10)}function H_(e){if(!(F_(e)||e===null||e===``))return parseFloat(e)}function Khe(e){if(!(F_(e)||e===null||e===``)){let t=parseFloat(`0.`+e)*1e3;return Math.floor(t)}}function qhe(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 U_(e){return e%4==0&&(e%100!=0||e%400==0)}function W_(e){return U_(e)?366:365}function G_(e,t){let n=Ghe(t-1,12)+1,r=e+(t-n)/12;return n===2?U_(r)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][n-1]}function K_(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 Jhe(e,t,n){return-M_(j_(e,1,t),n)+t-1}function q_(e,t=4,n=1){let r=Jhe(e,t,n),i=Jhe(e+1,t,n);return(W_(e)-r+i)/7}function Yhe(e){return e>99?e:e>O_.twoDigitCutoffYear?1900+e:2e3+e}function Xhe(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 J_(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 Zhe(e){let t=Number(e);if(typeof e==`boolean`||e===``||!Number.isFinite(t))throw new c_(`Invalid unit value ${e}`);return t}function Y_(e,t){let n={};for(let r in e)if(R_(e,r)){let i=e[r];if(i==null)continue;n[t(r)]=Zhe(i)}return n}function X_(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}${B_(n,2)}:${B_(r,2)}`;case`narrow`:return`${i}${n}${r>0?`:${r}`:``}`;case`techie`:return`${i}${B_(n,2)}${B_(r,2)}`;default:throw RangeError(`Value format ${t} is out of range for property format`)}}function Z_(e){return Uhe(e,[`hour`,`minute`,`second`,`millisecond`])}var Qhe=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],$he=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],ege=[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`];function tge(e){switch(e){case`narrow`:return[...ege];case`short`:return[...$he];case`long`:return[...Qhe];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}}var nge=[`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`,`Sunday`],rge=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],ige=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function age(e){switch(e){case`narrow`:return[...ige];case`short`:return[...rge];case`long`:return[...nge];case`numeric`:return[`1`,`2`,`3`,`4`,`5`,`6`,`7`];default:return null}}var oge=[`AM`,`PM`],sge=[`Before Christ`,`Anno Domini`],cge=[`BC`,`AD`],lge=[`B`,`A`];function uge(e){switch(e){case`narrow`:return[...lge];case`short`:return[...cge];case`long`:return[...sge];default:return null}}function dge(e){return oge[e.hour<12?0:1]}function fge(e,t){return age(t)[e.weekday-1]}function pge(e,t){return tge(t)[e.month-1]}function mge(e,t){return uge(t)[e.year<0?0:1]}function hge(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 gge(e,t){let n=``;for(let r of e)r.literal?n+=r.val:n+=t(r.val);return n}var _ge={D:p_,DD:yme,DDD:xme,DDDD:Sme,t:Cme,tt:wme,ttt:Tme,tttt:Eme,T:Dme,TT:Ome,TTT:kme,TTTT:Ame,f:jme,ff:Nme,fff:Ime,ffff:Rme,F:Mme,FF:Pme,FFF:Lme,FFFF:zme},Q_=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 _ge[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 B_(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?dge(t):a({hour:`numeric`,hourCycle:`h12`},`dayperiod`),c=(e,n)=>r?pge(t,e):a(n?{month:e}:{month:e,day:`numeric`},`month`),l=(e,n)=>r?fge(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?mge(t,e):a({era:e},`era`);return gge(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 gge(o,a(c,{isNegativeDuration:c<0,largestUnit:Object.keys(c.values)[0]}))}},vge=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function $_(...e){let t=e.reduce((e,t)=>e+t.source,``);return RegExp(`^${t}$`)}function ev(...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 tv(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 yge(...e){return(t,n)=>{let r={},i;for(i=0;i<e.length;i++)r[e[i]]=V_(t[n+i]);return[r,null,n+i]}}var bge=/(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/,xge=`(?:${bge.source}?(?:\\[(${vge.source})\\])?)?`,Sge=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,Cge=RegExp(`${Sge.source}${xge}`),wge=RegExp(`(?:[Tt]${Cge.source})?`),Tge=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,Ege=/(\d{4})-?W(\d\d)(?:-?(\d))?/,Dge=/(\d{4})-?(\d{3})/,Oge=yge(`weekYear`,`weekNumber`,`weekDay`),kge=yge(`year`,`ordinal`),Age=/(\d{4})-(\d\d)-(\d\d)/,jge=RegExp(`${Sge.source} ?(?:${bge.source}|(${vge.source}))?`),Mge=RegExp(`(?: ${jge.source})?`);function nv(e,t,n){let r=e[t];return F_(r)?n:V_(r)}function Nge(e,t){return[{year:nv(e,t),month:nv(e,t+1,1),day:nv(e,t+2,1)},null,t+3]}function rv(e,t){return[{hours:nv(e,t,0),minutes:nv(e,t+1,0),seconds:nv(e,t+2,0),milliseconds:Khe(e[t+3])},null,t+4]}function iv(e,t){let n=!e[t]&&!e[t+1],r=J_(e[t+1],e[t+2]);return[{},n?null:C_.instance(r),t+3]}function av(e,t){return[{},e[t]?v_.create(e[t]):null,t+1]}var Pge=RegExp(`^T?${Sge.source}$`),Fge=/^-?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 Ige(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(H_(n)),months:f(H_(r)),weeks:f(H_(i)),days:f(H_(a)),hours:f(H_(o)),minutes:f(H_(s)),seconds:f(H_(c),c===`-0`),milliseconds:f(Khe(l),d)}]}var Lge={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Rge(e,t,n,r,i,a,o){let s={year:t.length===2?Yhe(V_(t)):V_(t),month:$he.indexOf(n)+1,day:V_(r),hour:V_(i),minute:V_(a)};return o&&(s.second=V_(o)),e&&(s.weekday=e.length>3?nge.indexOf(e)+1:rge.indexOf(e)+1),s}var zge=/^(?:(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 Bge(e){let[,t,n,r,i,a,o,s,c,l,u,d]=e,f=Rge(t,i,r,n,a,o,s),p;return p=c?Lge[c]:l?0:J_(u,d),[f,new C_(p)]}function Vge(e){return e.replace(/\([^()]*\)|[\n\t]/g,` `).replace(/(\s\s+)/g,` `).trim()}var Hge=/^(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$/,Uge=/^(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$/,Wge=/^(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 Gge(e){let[,t,n,r,i,a,o,s]=e;return[Rge(t,i,r,n,a,o,s),C_.utcInstance]}function Kge(e){let[,t,n,r,i,a,o,s]=e;return[Rge(t,s,n,r,i,a,o),C_.utcInstance]}var qge=$_(Tge,wge),Jge=$_(Ege,wge),Yge=$_(Dge,wge),Xge=$_(Cge),Zge=ev(Nge,rv,iv,av),Qge=ev(Oge,rv,iv,av),$ge=ev(kge,rv,iv,av),e_e=ev(rv,iv,av);function t_e(e){return tv(e,[qge,Zge],[Jge,Qge],[Yge,$ge],[Xge,e_e])}function n_e(e){return tv(Vge(e),[zge,Bge])}function r_e(e){return tv(e,[Hge,Gge],[Uge,Gge],[Wge,Kge])}function i_e(e){return tv(e,[Fge,Ige])}var a_e=ev(rv);function o_e(e){return tv(e,[Pge,a_e])}var s_e=$_(Age,Mge),c_e=$_(jge),l_e=ev(rv,iv,av);function u_e(e){return tv(e,[s_e,Zge],[c_e,l_e])}var d_e=`Invalid Duration`,f_e={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}},p_e={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},...f_e},ov=146097/400,sv=146097/4800,m_e={years:{quarters:4,months:12,weeks:ov/7,days:ov,hours:ov*24,minutes:ov*24*60,seconds:ov*24*60*60,milliseconds:ov*24*60*60*1e3},quarters:{months:3,weeks:ov/28,days:ov/4,hours:ov*24/4,minutes:ov*24*60/4,seconds:ov*24*60*60/4,milliseconds:ov*24*60*60*1e3/4},months:{weeks:sv/7,days:sv,hours:sv*24,minutes:sv*24*60,seconds:sv*24*60*60,milliseconds:sv*24*60*60*1e3},...f_e},cv=[`years`,`quarters`,`months`,`weeks`,`days`,`hours`,`minutes`,`seconds`,`milliseconds`],h_e=cv.slice(0).reverse();function lv(e,t,n=!1){return new uv({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 g_e(e,t){let n=t.milliseconds??0;for(let r of h_e.slice(1))t[r]&&(n+=t[r]*e[r].milliseconds);return n}function __e(e,t){let n=g_e(e,t)<0?-1:1;cv.reduceRight((r,i)=>{if(F_(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),cv.reduce((n,r)=>{if(F_(t[r]))return n;if(n){let i=t[n]%1;t[n]-=i,t[r]+=i*e[n][r]}return r},null)}function v_e(e){let t={};for(let[n,r]of Object.entries(e))r!==0&&(t[n]=r);return t}var uv=class e{constructor(e){let t=e.conversionAccuracy===`longterm`||!1,n=t?m_e:p_e;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||x_.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 c_(`Duration.fromObject: argument expected to be an object, got ${t===null?`null`:typeof t}`);return new e({values:Y_(t,e.normalizeUnit),loc:x_.fromObject(n),conversionAccuracy:n.conversionAccuracy,matrix:n.matrix})}static fromDurationLike(t){if(I_(t))return e.fromMillis(t);if(e.isDuration(t))return t;if(typeof t==`object`)return e.fromObject(t);throw new c_(`Unknown duration argument ${t} of type ${typeof t}`)}static fromISO(t,n){let[r]=i_e(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]=o_e(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 c_(`need to specify a reason the Duration is invalid`);let r=t instanceof k_?t:new k_(t,n);if(O_.throwOnInvalid)throw new _me(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 vme(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?Q_.create(this.loc,n).formatDurationFromString(this,e):d_e}toHuman(e={}){if(!this.isValid)return d_e;let t=e.showZeros!==!1,n=cv.map(n=>{let r=this.values[n];return F_(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+=qhe(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},jv.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?g_e(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 cv)(R_(n.values,e)||R_(this.values,e))&&(r[e]=n.get(e)+this.get(e));return lv(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]=Zhe(e(this.values[n],n));return lv(this,{values:t},!0)}get(t){return this[e.normalizeUnit(t)]}set(t){if(!this.isValid)return this;let n={...this.values,...Y_(t,e.normalizeUnit)};return lv(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 lv(this,i)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return __e(this.matrix,e),lv(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=v_e(this.normalize().shiftToAll().toObject());return lv(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 cv)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;I_(i[e])&&(t+=i[e]);let o=Math.trunc(t);n[e]=o,r[e]=(t*1e3-o*1e3)/1e3}else I_(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 __e(this.matrix,n),lv(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 lv(this,{values:e},!0)}removeZeros(){if(!this.isValid)return this;let e=v_e(this.values);return lv(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 cv)if(!t(this.values[n],e.values[n]))return!1;return!0}},dv=`Invalid Interval`;function y_e(e,t){return!e||!e.isValid?fv.invalid(`missing or invalid start`):!t||!t.isValid?fv.invalid(`missing or invalid end`):t<e?fv.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 fv=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 c_(`need to specify a reason the Interval is invalid`);let r=t instanceof k_?t:new k_(t,n);if(O_.throwOnInvalid)throw new gme(r);return new e({invalid:r})}static fromDateTimes(t,n){let r=Mv(t),i=Mv(n);return y_e(r,i)??new e({start:r,end:i})}static after(t,n){let r=uv.fromDurationLike(n),i=Mv(t);return e.fromDateTimes(i,i.plus(r))}static before(t,n){let r=uv.fromDurationLike(n),i=Mv(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=jv.fromISO(r,n),a=t.isValid}catch{a=!1}let o,s;try{o=jv.fromISO(i,n),s=o.isValid}catch{s=!1}if(a&&s)return e.fromDateTimes(t,o);if(a){let r=uv.fromISO(i,n);if(r.isValid)return e.after(t,r)}else if(s){let t=uv.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(Mv).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=uv.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()})`:dv}[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=p_,t={}){return this.isValid?Q_.create(this.s.loc.clone(t),e).formatInterval(this):dv}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:dv}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:dv}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:dv}toFormat(e,{separator:t=` – `}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:dv}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):uv.invalid(this.invalidReason)}mapEndpoints(t){return e.fromDateTimes(t(this.s),t(this.e))}},pv=class{static hasDST(e=O_.defaultZone){let t=jv.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return v_.isValidZone(e)}static normalizeZone(e){return w_(e,O_.defaultZone)}static getStartOfWeek({locale:e=null,locObj:t=null}={}){return(t||x_.create(e)).getStartOfWeek()}static getMinimumDaysInFirstWeek({locale:e=null,locObj:t=null}={}){return(t||x_.create(e)).getMinDaysInFirstWeek()}static getWeekendWeekdays({locale:e=null,locObj:t=null}={}){return(t||x_.create(e)).getWeekendDays().slice()}static months(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||x_.create(t,n,i)).months(e)}static monthsFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null,outputCalendar:i=`gregory`}={}){return(r||x_.create(t,n,i)).months(e,!0)}static weekdays(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||x_.create(t,n,null)).weekdays(e)}static weekdaysFormat(e=`long`,{locale:t=null,numberingSystem:n=null,locObj:r=null}={}){return(r||x_.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return x_.create(e).meridiems()}static eras(e=`short`,{locale:t=null}={}){return x_.create(t,null,`gregory`).eras(e)}static features(){return{relative:zhe(),localeWeek:Bhe()}}};function b_e(e,t){let n=e=>e.toUTC(0,{keepLocalTime:!0}).startOf(`day`).valueOf(),r=n(t)-n(e);return Math.floor(uv.fromMillis(r).as(`days`))}function x_e(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=b_e(e,t);return(n-n%7)/7}],[`days`,b_e]],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 S_e(e,t,n,r){let[i,a,o,s]=x_e(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=uv.fromObject(a,r);return l.length>0?uv.fromMillis(c,r).shiftTo(...l).plus(u):u}var C_e=`missing Intl.DateTimeFormat.formatToParts support`;function mv(e,t=e=>e){return{regex:e,deser:([e])=>t(ghe(e))}}var w_e=`[ \xA0]`,T_e=new RegExp(w_e,`g`);function E_e(e){return e.replace(/\./g,`\\.?`).replace(T_e,w_e)}function D_e(e){return e.replace(/\./g,``).replace(T_e,` `).toLowerCase()}function hv(e,t){return e===null?null:{regex:RegExp(e.map(E_e).join(`|`)),deser:([n])=>e.findIndex(e=>D_e(n)===D_e(e))+t}}function O_e(e,t){return{regex:e,deser:([,e,t])=>J_(e,t),groups:t}}function gv(e){return{regex:e,deser:([e])=>e}}function k_e(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,`\\$&`)}function A_e(e,t){let n=D_(t),r=D_(t,`{2}`),i=D_(t,`{3}`),a=D_(t,`{4}`),o=D_(t,`{6}`),s=D_(t,`{1,2}`),c=D_(t,`{1,3}`),l=D_(t,`{1,6}`),u=D_(t,`{1,9}`),d=D_(t,`{2,4}`),f=D_(t,`{4,6}`),p=e=>({regex:RegExp(k_e(e.val)),deser:([e])=>e,literal:!0}),m=(m=>{if(e.literal)return p(m);switch(m.val){case`G`:return hv(t.eras(`short`),0);case`GG`:return hv(t.eras(`long`),0);case`y`:return mv(l);case`yy`:return mv(d,Yhe);case`yyyy`:return mv(a);case`yyyyy`:return mv(f);case`yyyyyy`:return mv(o);case`M`:return mv(s);case`MM`:return mv(r);case`MMM`:return hv(t.months(`short`,!0),1);case`MMMM`:return hv(t.months(`long`,!0),1);case`L`:return mv(s);case`LL`:return mv(r);case`LLL`:return hv(t.months(`short`,!1),1);case`LLLL`:return hv(t.months(`long`,!1),1);case`d`:return mv(s);case`dd`:return mv(r);case`o`:return mv(c);case`ooo`:return mv(i);case`HH`:return mv(r);case`H`:return mv(s);case`hh`:return mv(r);case`h`:return mv(s);case`mm`:return mv(r);case`m`:return mv(s);case`q`:return mv(s);case`qq`:return mv(r);case`s`:return mv(s);case`ss`:return mv(r);case`S`:return mv(c);case`SSS`:return mv(i);case`u`:return gv(u);case`uu`:return gv(s);case`uuu`:return mv(n);case`a`:return hv(t.meridiems(),0);case`kkkk`:return mv(a);case`kk`:return mv(d,Yhe);case`W`:return mv(s);case`WW`:return mv(r);case`E`:case`c`:return mv(n);case`EEE`:return hv(t.weekdays(`short`,!1),1);case`EEEE`:return hv(t.weekdays(`long`,!1),1);case`ccc`:return hv(t.weekdays(`short`,!0),1);case`cccc`:return hv(t.weekdays(`long`,!0),1);case`Z`:case`ZZ`:return O_e(RegExp(`([+-]${s.source})(?::(${r.source}))?`),2);case`ZZZ`:return O_e(RegExp(`([+-]${s.source})(${r.source})?`),2);case`z`:return gv(/[a-z_+-/]{1,256}?/i);case` `:return gv(/[^\S\n\r]/);default:return p(m)}})(e)||{invalidReason:C_e};return m.token=e,m}var j_e={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 M_e(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=j_e[o];if(typeof s==`object`&&(s=s[a]),s)return{literal:!1,val:s}}function N_e(e){return[`^${e.map(e=>e.regex).reduce((e,t)=>`${e}(${t.source})`,``)}$`,e]}function P_e(e,t,n){let r=e.match(t);if(r){let e={},t=1;for(let i in n)if(R_(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 F_e(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 F_(e.z)||(n=v_.create(e.z)),F_(e.Z)||(n||=new C_(e.Z),r=e.Z),F_(e.q)||(e.M=(e.q-1)*3+1),F_(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),F_(e.u)||(e.S=Khe(e.u)),[Object.keys(e).reduce((n,r)=>{let i=t(r);return i&&(n[i]=e[r]),n},{}),n,r]}var I_e=null;function L_e(){return I_e||=jv.fromMillis(1555555555555),I_e}function R_e(e,t){if(e.literal)return e;let n=U_e(Q_.macroTokenToFormatOpts(e.val),t);return n==null||n.includes(void 0)?e:n}function z_e(e,t){return Array.prototype.concat(...e.map(e=>R_e(e,t)))}var B_e=class{constructor(e,t){if(this.locale=e,this.format=t,this.tokens=z_e(Q_.parseFormat(t),e),this.units=this.tokens.map(t=>A_e(t,e)),this.disqualifyingUnit=this.units.find(e=>e.invalidReason),!this.disqualifyingUnit){let[e,t]=N_e(this.units);this.regex=RegExp(e,`i`),this.handlers=t}}explainFromTokens(e){if(this.isValid){let[t,n]=P_e(e,this.regex,this.handlers),[r,i,a]=n?F_e(n):[null,null,void 0];if(R_(n,`a`)&&R_(n,`H`))throw new s_(`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 V_e(e,t,n){return new B_e(e,n).explainFromTokens(t)}function H_e(e,t,n){let{result:r,zone:i,specificOffset:a,invalidReason:o}=V_e(e,t,n);return[r,i,a,o]}function U_e(e,t){if(!e)return null;let n=Q_.create(t,e).dtFormatter(L_e()),r=n.formatToParts(),i=n.resolvedOptions();return r.map(t=>M_e(t,e,i))}var _v=`Invalid DateTime`,W_e=864e13;function vv(e){return new k_(`unsupported zone`,`the zone "${e.name}" is not supported`)}function yv(e){return e.weekData===null&&(e.weekData=N_(e.c)),e.weekData}function bv(e){return e.localWeekData===null&&(e.localWeekData=N_(e.c,e.loc.getMinDaysInFirstWeek(),e.loc.getStartOfWeek())),e.localWeekData}function xv(e,t){let n={ts:e.ts,zone:e.zone,c:e.c,o:e.o,loc:e.loc,invalid:e.invalid};return new jv({...n,...t,old:n})}function G_e(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 Sv(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 Cv(e,t,n){return G_e(K_(e),t,n)}function K_e(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,G_(r,i))+Math.trunc(t.days)+Math.trunc(t.weeks)*7},o=uv.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]=G_e(K_(a),n,e.zone);return o!==0&&(s+=o,c=e.zone.offset(s)),{ts:s,o:c}}function wv(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=jv.fromObject(e,{...n,zone:r,specificOffset:a});return o?i:i.setZone(s)}else return jv.invalid(new k_(`unparsable`,`the input "${i}" can't be parsed as ${r}`))}function Tv(e,t,n=!0){return e.isValid?Q_.create(x_.create(`en-US`),{allowZ:n,forceSimple:!0}).formatDateTimeFromString(e,t):null}function Ev(e,t,n){let r=e.c.year>9999||e.c.year<0,i=``;if(r&&e.c.year>=0&&(i+=`+`),i+=B_(e.c.year,r?6:4),n===`year`)return i;if(t){if(i+=`-`,i+=B_(e.c.month),n===`month`)return i;i+=`-`}else if(i+=B_(e.c.month),n===`month`)return i;return i+=B_(e.c.day),i}function q_e(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+=B_(e.c.hour),o===`hour`)break;if(t){if(c+=`:`,c+=B_(e.c.minute),o===`minute`)break;s&&(c+=`:`,c+=B_(e.c.second))}else{if(c+=B_(e.c.minute),o===`minute`)break;s&&(c+=B_(e.c.second))}if(o===`second`)break;s&&(!r||e.c.millisecond!==0)&&(c+=`.`,c+=B_(e.c.millisecond,3))}return i&&(e.isOffsetFixed&&e.offset===0&&!a?c+=`Z`:e.o<0?(c+=`-`,c+=B_(Math.trunc(-e.o/60)),c+=`:`,c+=B_(Math.trunc(-e.o%60))):(c+=`+`,c+=B_(Math.trunc(e.o/60)),c+=`:`,c+=B_(Math.trunc(e.o%60)))),a&&(c+=`[`+e.zone.ianaName+`]`),c}var J_e={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},Y_e={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},X_e={ordinal:1,hour:0,minute:0,second:0,millisecond:0},Dv=[`year`,`month`,`day`,`hour`,`minute`,`second`,`millisecond`],Z_e=[`weekYear`,`weekNumber`,`weekday`,`hour`,`minute`,`second`,`millisecond`],Q_e=[`year`,`ordinal`,`hour`,`minute`,`second`,`millisecond`];function Ov(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 vme(e);return t}function $_e(e){switch(e.toLowerCase()){case`localweekday`:case`localweekdays`:return`localWeekday`;case`localweeknumber`:case`localweeknumbers`:return`localWeekNumber`;case`localweekyear`:case`localweekyears`:return`localWeekYear`;default:return Ov(e)}}function eve(e){if(kv===void 0&&(kv=O_.now()),e.type!==`iana`)return e.offset(kv);let t=e.name,n=Av.get(t);return n===void 0&&(n=e.offset(kv),Av.set(t,n)),n}function tve(e,t){let n=w_(t.zone,O_.defaultZone);if(!n.isValid)return jv.invalid(vv(n));let r=x_.fromObject(t),i,a;if(F_(e.year))i=O_.now();else{for(let t of Dv)F_(e[t])&&(e[t]=J_e[t]);let t=Fhe(e)||Ihe(e);if(t)return jv.invalid(t);let r=eve(n);[i,a]=Cv(e,r,n)}return new jv({ts:i,zone:n,loc:r,o:a})}function nve(e,t,n){let r=F_(n.round)?!0:n.round,i=F_(n.rounding)?`trunc`:n.rounding,a=(e,a)=>(e=qhe(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 rve(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]}var kv,Av=new Map,jv=class e{constructor(e){let t=e.zone||O_.defaultZone,n=e.invalid||(Number.isNaN(e.ts)?new k_(`invalid input`):null)||(t.isValid?null:vv(t));this.ts=F_(e.ts)?O_.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=I_(e.o)&&!e.old?e.o:t.offset(this.ts);r=Sv(this.ts,a),n=Number.isNaN(r.year)?new k_(`invalid input`):null,r=n?null:r,i=n?null:a}this._zone=t,this.loc=e.loc||x_.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]=rve(arguments),[n,r,i,a,o,s,c]=t;return tve({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static utc(){let[e,t]=rve(arguments),[n,r,i,a,o,s,c]=t;return e.zone=C_.utcInstance,tve({year:n,month:r,day:i,hour:a,minute:o,second:s,millisecond:c},e)}static fromJSDate(t,n={}){let r=Rhe(t)?t.valueOf():NaN;if(Number.isNaN(r))return e.invalid(`invalid input`);let i=w_(n.zone,O_.defaultZone);return i.isValid?new e({ts:r,zone:i,loc:x_.fromObject(n)}):e.invalid(vv(i))}static fromMillis(t,n={}){if(I_(t))return t<-W_e||t>W_e?e.invalid(`Timestamp out of range`):new e({ts:t,zone:w_(n.zone,O_.defaultZone),loc:x_.fromObject(n)});throw new c_(`fromMillis requires a numerical input, but received a ${typeof t} with value ${t}`)}static fromSeconds(t,n={}){if(I_(t))return new e({ts:t*1e3,zone:w_(n.zone,O_.defaultZone),loc:x_.fromObject(n)});throw new c_(`fromSeconds requires a numerical input`)}static fromObject(t,n={}){t||={};let r=w_(n.zone,O_.defaultZone);if(!r.isValid)return e.invalid(vv(r));let i=x_.fromObject(n),a=Y_(t,$_e),{minDaysInFirstWeek:o,startOfWeek:s}=Mhe(a,i),c=O_.now(),l=F_(n.specificOffset)?r.offset(c):n.specificOffset,u=!F_(a.ordinal),d=!F_(a.year),f=!F_(a.month)||!F_(a.day),p=d||f,m=a.weekYear||a.weekNumber;if((p||u)&&m)throw new s_(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(f&&u)throw new s_(`Can't mix ordinal dates with month/day`);let h=m||a.weekday&&!p,g,_,ee=Sv(c,l);h?(g=Z_e,_=Y_e,ee=N_(ee,o,s)):u?(g=Q_e,_=X_e,ee=P_(ee)):(g=Dv,_=J_e);let v=!1;for(let e of g){let t=a[e];F_(t)?v?a[e]=_[e]:a[e]=ee[e]:v=!0}let y=(h?Nhe(a,o,s):u?Phe(a):Fhe(a))||Ihe(a);if(y)return e.invalid(y);let[b,te]=Cv(h?Ahe(a,o,s):u?jhe(a):a,l,r),ne=new e({ts:b,zone:r,o:te,loc:i});return a.weekday&&p&&t.weekday!==ne.weekday?e.invalid(`mismatched weekday`,`you can't specify both a weekday of ${a.weekday} and a date of ${ne.toISO()}`):ne.isValid?ne:e.invalid(ne.invalid)}static fromISO(e,t={}){let[n,r]=t_e(e);return wv(n,r,t,`ISO 8601`,e)}static fromRFC2822(e,t={}){let[n,r]=n_e(e);return wv(n,r,t,`RFC 2822`,e)}static fromHTTP(e,t={}){let[n,r]=r_e(e);return wv(n,r,t,`HTTP`,t)}static fromFormat(t,n,r={}){if(F_(t)||F_(n))throw new c_(`fromFormat requires an input string and a format`);let{locale:i=null,numberingSystem:a=null}=r,[o,s,c,l]=H_e(x_.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0}),t,n);return l?e.invalid(l):wv(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]=u_e(e);return wv(n,r,t,`SQL`,e)}static invalid(t,n=null){if(!t)throw new c_(`need to specify a reason the DateTime is invalid`);let r=t instanceof k_?t:new k_(t,n);if(O_.throwOnInvalid)throw new hme(r);return new e({invalid:r})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){let n=U_e(e,x_.fromObject(t));return n?n.map(e=>e?e.val:null).join(``):null}static expandFormat(e,t={}){return z_e(Q_.parseFormat(e),x_.fromObject(t)).map(e=>e.val).join(``)}static resetCache(){kv=void 0,Av.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?yv(this).weekYear:NaN}get weekNumber(){return this.isValid?yv(this).weekNumber:NaN}get weekday(){return this.isValid?yv(this).weekday:NaN}get isWeekend(){return this.isValid&&this.loc.getWeekendDays().includes(this.weekday)}get localWeekday(){return this.isValid?bv(this).weekday:NaN}get localWeekNumber(){return this.isValid?bv(this).weekNumber:NaN}get localWeekYear(){return this.isValid?bv(this).weekYear:NaN}get ordinal(){return this.isValid?P_(this.c).ordinal:NaN}get monthShort(){return this.isValid?pv.months(`short`,{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?pv.months(`long`,{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?pv.weekdays(`short`,{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?pv.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=K_(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=Sv(s,a),u=Sv(c,o);return l.hour===u.hour&&l.minute===u.minute&&l.second===u.second&&l.millisecond===u.millisecond?[xv(this,{ts:s}),xv(this,{ts:c})]:[this]}get isInLeapYear(){return U_(this.year)}get daysInMonth(){return G_(this.year,this.month)}get daysInYear(){return this.isValid?W_(this.year):NaN}get weeksInWeekYear(){return this.isValid?q_(this.weekYear):NaN}get weeksInLocalWeekYear(){return this.isValid?q_(this.localWeekYear,this.loc.getMinDaysInFirstWeek(),this.loc.getStartOfWeek()):NaN}resolvedLocaleOptions(e={}){let{locale:t,numberingSystem:n,calendar:r}=Q_.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:r}}toUTC(e=0,t={}){return this.setZone(C_.instance(e),t)}toLocal(){return this.setZone(O_.defaultZone)}setZone(t,{keepLocalTime:n=!1,keepCalendarTime:r=!1}={}){if(t=w_(t,O_.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]=Cv(r,n,t)}return xv(this,{ts:e,zone:t})}else return e.invalid(vv(t))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){let r=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return xv(this,{loc:r})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let t=Y_(e,$_e),{minDaysInFirstWeek:n,startOfWeek:r}=Mhe(t,this.loc),i=!F_(t.weekYear)||!F_(t.weekNumber)||!F_(t.weekday),a=!F_(t.ordinal),o=!F_(t.year),s=!F_(t.month)||!F_(t.day),c=o||s,l=t.weekYear||t.weekNumber;if((c||a)&&l)throw new s_(`Can't mix weekYear/weekNumber units with year/month/day or ordinals`);if(s&&a)throw new s_(`Can't mix ordinal dates with month/day`);let u;i?u=Ahe({...N_(this.c,n,r),...t},n,r):F_(t.ordinal)?(u={...this.toObject(),...t},F_(t.day)&&(u.day=Math.min(G_(u.year,u.month),u.day))):u=jhe({...P_(this.c),...t});let[d,f]=Cv(u,this.o,this.zone);return xv(this,{ts:d,o:f})}plus(e){if(!this.isValid)return this;let t=uv.fromDurationLike(e);return xv(this,K_e(this,t))}minus(e){if(!this.isValid)return this;let t=uv.fromDurationLike(e).negate();return xv(this,K_e(this,t))}startOf(e,{useLocaleWeeks:t=!1}={}){if(!this.isValid)return this;let n={},r=uv.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?Q_.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):_v}toLocaleString(e=p_,t={}){return this.isValid?Q_.create(this.loc.clone(t),e).formatDateTime(this):_v}toLocaleParts(e={}){return this.isValid?Q_.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=Ov(a);let o=e===`extended`,s=Ev(this,o,a);return Dv.indexOf(a)>=3&&(s+=`T`),s+=q_e(this,o,t,n,r,i,a),s}toISODate({format:e=`extended`,precision:t=`day`}={}){return this.isValid?Ev(this,e===`extended`,Ov(t)):null}toISOWeekDate(){return Tv(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=Ov(o),(r&&Dv.indexOf(o)>=3?`T`:``)+q_e(this,a===`extended`,t,e,n,i,o)):null}toRFC2822(){return Tv(this,`EEE, dd LLL yyyy HH:mm:ss ZZZ`,!1)}toHTTP(){return Tv(this.toUTC(),`EEE, dd LLL yyyy HH:mm:ss 'GMT'`)}toSQLDate(){return this.isValid?Ev(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`)),Tv(this,r,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():_v}[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 uv.invalid(`created by diffing an invalid DateTime`);let r={locale:this.locale,numberingSystem:this.numberingSystem,...n},i=Vhe(t).map(uv.normalizeUnit),a=e.valueOf()>this.valueOf(),o=S_e(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?fv.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),nve(n,this.plus(r),{...t,numeric:`always`,units:i,unit:a})}toRelativeCalendar(t={}){return this.isValid?nve(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 c_(`min requires all arguments be DateTimes`);return Hhe(t,e=>e.valueOf(),Math.min)}static max(...t){if(!t.every(e.isDateTime))throw new c_(`max requires all arguments be DateTimes`);return Hhe(t,e=>e.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){let{locale:r=null,numberingSystem:i=null}=n;return V_e(x_.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 B_e(x_.fromOpts({locale:n,numberingSystem:r,defaultToEN:!0}),e)}static fromFormatParser(t,n,r={}){if(F_(t)||F_(n))throw new c_(`fromFormatParser requires an input string and a format parser`);let{locale:i=null,numberingSystem:a=null}=r,o=x_.fromOpts({locale:i,numberingSystem:a,defaultToEN:!0});if(!o.equals(n.locale))throw new c_(`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):wv(s,c,r,`format ${n.format}`,t,l)}static get DATE_SHORT(){return p_}static get DATE_MED(){return yme}static get DATE_MED_WITH_WEEKDAY(){return bme}static get DATE_FULL(){return xme}static get DATE_HUGE(){return Sme}static get TIME_SIMPLE(){return Cme}static get TIME_WITH_SECONDS(){return wme}static get TIME_WITH_SHORT_OFFSET(){return Tme}static get TIME_WITH_LONG_OFFSET(){return Eme}static get TIME_24_SIMPLE(){return Dme}static get TIME_24_WITH_SECONDS(){return Ome}static get TIME_24_WITH_SHORT_OFFSET(){return kme}static get TIME_24_WITH_LONG_OFFSET(){return Ame}static get DATETIME_SHORT(){return jme}static get DATETIME_SHORT_WITH_SECONDS(){return Mme}static get DATETIME_MED(){return Nme}static get DATETIME_MED_WITH_SECONDS(){return Pme}static get DATETIME_MED_WITH_WEEKDAY(){return Fme}static get DATETIME_FULL(){return Ime}static get DATETIME_FULL_WITH_SECONDS(){return Lme}static get DATETIME_HUGE(){return Rme}static get DATETIME_HUGE_WITH_SECONDS(){return zme}};function Mv(e){if(jv.isDateTime(e))return e;if(e&&e.valueOf&&I_(e.valueOf()))return jv.fromJSDate(e);if(e&&typeof e==`object`)return jv.fromObject(e);throw new c_(`Unknown datetime argument: ${e}, of type ${typeof e}`)}function ive(e){return/\s/g.test(e)}function Nv(e){return/[\sA-Z]/g.test(e)}function Pv(e,t){return e.name!==`public`||e.name===`public`&&t.database[1].hasDefaultSchema}function Fv(e,t){let n=new Map;return e.map(e=>n.set(`${t.tables[t.fields[e].tableId].name}_${t.fields[e].name}`,t.fields[e].type.type_name)),n}function Iv(e,t,n){let r=new Map;return e.forEach(e=>{let i=`${t.tables[t.fields[e].tableId].name}_${t.fields[e].name}`,a=1;for(;n.has(i);)i=`${t.tables[t.fields[e].tableId].name}_${t.fields[e].name}(${a})`,a+=1;r.set(i,t.fields[e].type.type_name)}),r}function ave(e,t,n){let r=`${e}_${t}`,i=1;for(;n.has(r);)r=`${e}_${t}(${i})`,i+=1;return n.add(r),r}function ove(e,t,n,r){let i=`${t}_${n}`,a=1,o=r.get(e);if(!o)return i;for(;o.has(i);)i=`${t}_${n}(${a})`,a+=1;return i}function Lv(e,t){if(!e)return``;let n=``;switch(t){case`mysql`:n="`";break;case`postgres`:case`oracle`:n=`"`;break;default:break}return`${n}${e}${n}`}function sve(e){if(!e||typeof e!=`string`)return null;try{let t=Hg(e);if(!t)return null;let n=jv.fromISO(t,{setZone:!0});return n.isValid?{datetime:n,hasTimezone:/[+-]\d{2}:\d{2}|Z$/i.test(t)}:null}catch{return null}}function cve(e,t){return t?e.toFormat(`yyyy-MM-dd HH:mm:ss.SSS ZZ`):e.toUTC().toFormat(`yyyy-MM-dd HH:mm:ss.SSS`)}var lve=class e{static hasWhiteSpace(e){return/\s/g.test(e)}static hasSquareBracket(e){return/\[|\]/.test(e)}static isExpression(e){return/\s*(\*|\+|-|\([A-Za-z0-9_]+\)|\(\))/g.test(e)}static escapeNote(e){if(e===null)return``;let t=e.replaceAll(`\\`,`\\\\`);return t.match(/[\n\r']/)?(t=t.replaceAll(`'`,`\\'`),t=t.replaceAll(`\r
@@ -40,7 +40,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
40
40
  `;return r})}static exportIndexes(e,t){return e.filter(e=>!t.indexes[e].pk).map(e=>{let n=t.indexes[e],r=t.tables[n.tableId],i=t.schemas[r.schemaId],a=`CREATE`;n.unique&&(a+=` UNIQUE`);let o=n.name?`"${n.name}"`:``;a+=` INDEX`,o&&(a+=` ${o}`),a+=` ON ${Pv(i,t)?`"${i.name}".`:``}"${r.name}"`,n.type&&(a+=` USING ${n.type.toUpperCase()}`);let s=[];return n.columnIds.forEach(e=>{let n=t.indexColumns[e],r=``;r=n.type===`expression`?`(${n.value})`:`"${n.value}"`,s.push(r)}),a+=` (${s.join(`, `)})`,a+=`;
41
41
  `,a})}static exportComments(e,t){return e.map(e=>{let n=`COMMENT ON`,r=t.tables[e.tableId],i=t.schemas[r.schemaId];switch(e.type){case`table`:n+=` TABLE ${Pv(i,t)?`"${i.name}".`:``}"${r.name}" IS '${r.note.replace(/'/g,`''`)}'`;break;case`column`:{let a=t.fields[e.fieldId];n+=` COLUMN ${Pv(i,t)?`"${i.name}".`:``}"${r.name}"."${a.name}" IS '${a.note.replace(/'/g,`''`)}'`;break}default:break}return n+=`;
42
42
  `,n})}static export(t){let n=t.database[1],r=new Set(Object.values(t.tables).map(e=>e.name)),i=new Set,a=n.schemaIds.reduce((n,r)=>{let a=t.schemas[r],{enumIds:o}=a;return Pv(a,t)&&n.schemas.push(`CREATE SCHEMA "${a.name}";\n`),Wu(o)||e.exportEnums(o,t).forEach(e=>{let[t,r]=e;n.enums.push(r),i.add(t)}),n},{schemas:[],enums:[],tables:[],indexes:[],comments:[],refs:[]}),o=n.schemaIds.reduce((n,a)=>{let{tableIds:o,refIds:s}=t.schemas[a];Wu(o)||n.tables.push(...e.exportTables(o,t,i));let c=io(o.map(e=>t.tables[e].indexIds));Wu(c)||n.indexes.push(...e.exportIndexes(c,t));let l=io(o.map(e=>{let{fieldIds:n,note:r}=t.tables[e],i=n.filter(e=>t.fields[e].note).map(t=>({type:`column`,fieldId:t,tableId:e}));return r?[{type:`table`,tableId:e}].concat(i):i}));return Wu(l)||n.comments.push(...e.exportComments(l,t)),Wu(s)||n.refs.push(...e.exportRefs(s,t,r)),n},a),s=e.exportRecords(t),c=Wu(s)?[]:[`-- Defer constraint checking for INSERT`,`BEGIN;`,`SET CONSTRAINTS ALL DEFERRED;`,``,...s,``,`SET CONSTRAINTS ALL IMMEDIATE;`,`COMMIT;`];return lc(o.schemas,o.enums,o.tables,o.indexes,o.comments,o.refs,c).join(`
43
- `)}},_ve=gve,vve=class extends Error{constructor(e,t={start:{line:1,column:1}}){super(e),this.location=t,this.error=`error`}},yve=class{constructor(e){this.token=e}bind(e){this.selection=e}error(e){throw new vve(e,this.token)}},zv=yve,bve=class extends zv{constructor({token:e,name:t,expression:n,table:r,column:i=null,injectedPartial:a=null}={}){super(e),this.name=t,this.expression=n,this.table=r,this.column=i,this.injectedPartial=a,this.dbState=this.table.dbState,this.generateId()}generateId(){this.id=this.dbState.generateId(`checkId`)}export(){return{...this.shallowExport()}}exportParentIds(){return{tableId:this.table.id,columnId:this.column?.id,injectedPartialId:this.injectedPartial?.id}}shallowExport(){return{name:this.name,expression:this.expression}}normalize(e){e.checks[this.id]={id:this.id,...this.shallowExport(),...this.exportParentIds()}}},xve=bve;id();var Sve=class extends zv{constructor({name:e,type:t,unique:n,pk:r,token:i,not_null:a,note:o,dbdefault:s,increment:c,checks:l=[],table:u={},noteToken:d=null,injectedPartial:f=null,injectedToken:p=null}={}){super(i),e||this.error(`Field must have a name`),t||this.error(`Field must have a type`),this.name=e,this.type=t,this.unique=n,this.pk=r,this.not_null=a,this.note=o?D(o,`value`,o):null,this.noteToken=o?D(o,`token`,d):null,this.dbdefault=s,this.increment=c,this.checks=[],this.endpoints=[],this.table=u,this.injectedPartial=f,this.injectedToken=p,this.dbState=this.table.dbState,this.generateId(),this.bindType(),this.processChecks(l)}generateId(){this.id=this.dbState.generateId(`fieldId`)}bindType(){let e=this.type.type_name,t=this.type.schemaName||`public`;if(this.type.schemaName){let n=this.table.schema.database.findEnum(t,e);if(!n){this.type.type_name=`${t}.${e}`,this.type.originalTypeName=e;return}this._enum=n,n.pushField(this)}else{let n=this.table.schema.database.findEnum(t,e);if(!n)return;this._enum=n,n.pushField(this)}}pushEndpoint(e){this.endpoints.push(e)}export(){return{...this.shallowExport()}}exportParentIds(){return{tableId:this.table.id,enumId:this._enum?this._enum.id:null}}exportChildIds(){return{endpointIds:this.endpoints.map(e=>e.id)}}shallowExport(){return{name:this.name,type:this.type,unique:this.unique,pk:this.pk,not_null:this.not_null,note:this.note,dbdefault:this.dbdefault,increment:this.increment,injectedPartialId:this.injectedPartial?.id??null,checkIds:this.checks.map(e=>e.id)}}normalize(e){e.fields[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()},this.checks.forEach(t=>t.normalize(e))}processChecks(e){e.forEach(e=>{this.checks.push(new xve({...e,table:this.table,column:this}))})}},Cve=Sve,wve=class extends zv{constructor({type:e,value:t,index:n,token:r}){super(),this.type=e,this.value=t,this.index=n,this.token=r,this.dbState=this.index.dbState,this.generateId()}generateId(){this.id=this.dbState.generateId(`indexColumnId`)}export(){return{...this.shallowExport()}}exportParentIds(){return{indexId:this.index.id}}shallowExport(){return{type:this.type,value:this.value}}normalize(e){e.indexColumns[this.id]={id:this.id,...this.shallowExport(),...this.exportParentIds()}}},Tve=wve,Eve=class extends zv{constructor({columns:e,type:t,unique:n,pk:r,token:i,name:a,note:o,table:s={},injectedPartial:c=null}={}){super(i),this.name=a,this.type=t,this.unique=n,this.note=o?o.value:null,this.noteToken=o?o.token:null,this.pk=r,this.columns=[],this.table=s,this.injectedPartial=c,this.dbState=this.table.dbState,this.generateId(),this.processIndexColumns(e)}generateId(){this.id=this.dbState.generateId(`indexId`)}processIndexColumns(e){e.forEach(e=>{this.pushIndexColumn(new Tve({...e,index:this}))})}pushIndexColumn(e){this.checkIndexColumn(e),this.columns.push(e)}checkIndexColumn(e){this.columns.some(t=>t.type===e.type&&t.value===e.value)&&e.error(`Index column ${e.value} existed`)}export(){return{...this.shallowExport(),...this.exportChild()}}exportChild(){return{columns:this.columns.map(e=>e.export())}}exportChildIds(){return{columnIds:this.columns.map(e=>e.id)}}exportParentIds(){return{tableId:this.table.id}}shallowExport(){return{name:this.name,type:this.type,unique:this.unique,pk:this.pk,note:this.note,injectedPartialId:this.injectedPartial?.id}}normalize(e){e.indexes[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()},this.columns.forEach(t=>t.normalize(e))}},Dve=Eve;id();var Ove=class extends zv{constructor({name:e,alias:t,note:n,fields:r=[],indexes:i=[],checks:a=[],schema:o={},token:s,headerColor:c,noteToken:l=null,partials:u=[]}={}){super(s),this.name=e,this.alias=t,this.note=n?D(n,`value`,n):null,this.noteToken=n?D(n,`token`,l):null,this.headerColor=c,this.fields=[],this.indexes=[],this.checks=[],this.schema=o,this.partials=u,this.records=[],this.dbState=this.schema.dbState,this.generateId(),this.processFields(r),this.processPartials(),this.checkFieldCount(),this.processIndexes(i),this.processChecks(a)}generateId(){this.id=this.dbState.generateId(`tableId`)}checkFieldCount(){this.fields.length===0&&this.error(`Table must have at least one field`)}processFields(e){e.forEach(e=>{this.pushField(new Cve({...e,table:this}))})}pushField(e){this.checkField(e),this.fields.push(e)}checkField(e){this.fields.some(t=>t.name===e.name)&&e.error(`Field "${e.name}" existed in table ${Rv(this.schema)?`"${this.schema.name}".`:``}"${this.name}"`)}processIndexes(e){e.forEach(e=>{this.pushIndex(new Dve({...e,table:this}))})}pushIndex(e){this.checkIndex(e),this.indexes.push(e)}checkIndex(e){e.columns.forEach(t=>{t.type===`column`&&!this.findField(t.value)&&e.error(`Column "${t.value}" do not exist in table ${Rv(this.schema)?`"${this.schema.name}".`:``}"${this.name}"`)})}processChecks(e){e.forEach(e=>{this.pushCheck(new xve({...e,table:this}))})}pushCheck(e){this.checks.push(e)}findField(e){return this.fields.find(t=>t.name===e)}checkSameId(e){return this.schema.checkSameId(e.schemaName||`public`)&&(this.name===e.name||this.alias===e.name||this.name===e.alias||this.alias&&this.alias===e.alias)}processPartials(){if(!this.partials?.length)return;let e=new Set(this.fields.map(e=>e.name)),t=new Set;qu(this.note)||t.add(`note`),qu(this.headerColor)||t.add(`headerColor`);let n=this.partials.sort((e,t)=>t.order-e.order);n.toReversed().forEach(e=>{this.fields.splice(e.order,0,`dummy`)}),n.forEach(n=>{let r=this.schema.database.findTablePartial(n.name);if(r||this.error(`Table partial ${n.name} not found`,n.token),n.id=r.id,r.fields){let t=r.fields.filter(t=>!e.has(t.name)).map(t=>(e.add(t.name),t.inline_refs&&t.inline_refs.forEach(e=>{let n={token:t.token,endpoints:[{tableName:this.name,schemaName:this.schema?.name,fieldNames:[t.name],relation:[`-`,`<`].includes(e.relation)?`1`:`*`,token:t.token},{tableName:e.tableName,schemaName:e.schemaName,fieldNames:e.fieldNames,relation:[`-`,`>`].includes(e.relation)?`1`:`*`,token:e.token}],injectedPartial:r};this.schema.database.injectedRawRefs.push(n)}),new Cve({...t,noteToken:null,table:this,injectedPartial:r,injectedToken:n.token})));this.fields.splice(n.order,1,...t)}else this.fields.splice(n.order,1);!t.has(`note`)&&!qu(r.note)&&(this.noteToken=null,this.note=r.note,t.add(`note`)),!t.has(`headerColor`)&&!qu(r.headerColor)&&(this.headerColor=r.headerColor,t.add(`headerColor`)),r.indexes.forEach(e=>{this.indexes.push(new Dve({...e,table:this,injectedPartial:r}))}),r.checks.forEach(e=>{this.checks.push(new xve({...e,name:e.name&&`${this.name}.${e.name}`,table:this,injectedPartial:r}))})})}export(){return{...this.shallowExport(),...this.exportChild()}}exportChild(){return{fields:this.fields.map(e=>e.export()),indexes:this.indexes.map(e=>e.export())}}exportChildIds(){return{fieldIds:this.fields.map(e=>e.id),indexIds:this.indexes.map(e=>e.id),checkIds:this.checks.map(e=>e.id)}}exportParentIds(){return{schemaId:this.schema.id,groupId:this.group?this.group.id:null}}shallowExport(){return{name:this.name,alias:this.alias,note:this.note,headerColor:this.headerColor,partials:this.partials,recordIds:this.records.map(e=>e.id)}}normalize(e){e.tables[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()},this.fields.forEach(t=>t.normalize(e)),this.indexes.forEach(t=>t.normalize(e)),this.checks.forEach(t=>t.normalize(e))}},kve=Ove;id();var Ave=class extends zv{constructor({name:e,token:t,note:n,_enum:r,noteToken:i=null}={}){super(t),e||this.error(`Enum value must have a name`),this.name=e,this.note=n?D(n,`value`,n):null,this.noteToken=n?D(n,`token`,i):null,this._enum=r,this.dbState=this._enum.dbState,this.generateId()}generateId(){this.id=this.dbState.generateId(`enumValueId`)}export(){return{...this.shallowExport()}}exportParentIds(){return{enumId:this._enum.id}}shallowExport(){return{name:this.name,note:this.note}}normalize(e){e.enumValues[this.id]={id:this.id,...this.shallowExport(),...this.exportParentIds()}}},jve=Ave;id();var Mve=class extends zv{constructor({name:e,token:t,values:n,note:r,schema:i,noteToken:a=null}={}){super(t),e||this.error(`Enum must have a name`),this.name=e,this.note=r?D(r,`value`,r):null,this.noteToken=r?D(r,`token`,a):null,this.values=[],this.fields=[],this.schema=i,this.dbState=this.schema.dbState,this.generateId(),this.processValues(n)}generateId(){this.id=this.dbState.generateId(`enumId`)}processValues(e){e.forEach(e=>{this.pushValue(new jve({...e,_enum:this}))})}pushValue(e){this.checkValue(e),this.values.push(e)}checkValue(e){this.values.some(t=>t.name===e.name)&&e.error(`Enum value "${e.name}" existed in enum ${Rv(this.schema)?`"${this.schema.name}".`:``}"${this.name}"`)}pushField(e){this.checkField(e),this.fields.push(e)}checkField(e){this.fields.some(t=>t.id===e.id)&&this.error(`Field ${Rv(e.table.schema)?`"${e.table.schema.name}".`:``}"${e.table.name}"."${e.name}" already associated with enum ${Rv(this.schema)?`"${this.schema.name}".`:``}${this.name}"`)}export(){return{...this.shallowExport(),...this.exportChild()}}exportChild(){return{values:this.values.map(e=>e.export())}}exportChildIds(){return{valueIds:this.values.map(e=>e.id),fieldIds:this.fields.map(e=>e.id)}}exportParentIds(){return{schemaId:this.schema.id}}shallowExport(){return{name:this.name,note:this.note}}normalize(e){e.enums[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()},this.values.forEach(t=>t.normalize(e))}},Nve=Mve;id();var Pve=class extends zv{constructor({name:e,token:t,tables:n=[],schema:r={},note:i,color:a,noteToken:o=null}){super(t),this.name=e,this.tables=[],this.schema=r,this.dbState=this.schema.dbState,this.note=i?D(i,`value`,i):null,this.noteToken=i?D(i,`token`,o):null,this.color=a,this.generateId(),this.processTables(n)}generateId(){this.id=this.dbState.generateId(`tableGroupId`)}processTables(e){e.forEach(e=>{let t=this.schema.database.findTable(e.schemaName,e.name);t||this.error(`Table ${e.schemaName?`"${e.schemaName}".`:``}${e.name} don't exist`),this.pushTable(t)})}pushTable(e){this.checkTable(e),this.tables.push(e),e.group=this}checkTable(e){this.tables.some(t=>t.id===e.id)&&this.error(`Table ${Rv(e.schema)?`"${e.schema.name}".`:``}.${e.name} is already in the group`),e.group&&this.error(`Table ${Rv(e.schema)?`"${e.schema.name}".`:``}.${e.name} is already in group ${Rv(e.group.schema)?`"${e.group.schema.name}".`:``}${e.group.name}`)}export(){return{...this.shallowExport(),...this.exportChild()}}exportChild(){return{tables:this.tables.map(e=>({tableName:e.name,schemaName:e.schema.name}))}}exportChildIds(){return{tableIds:this.tables.map(e=>e.id)}}exportParentIds(){return{schemaId:this.schema.id}}shallowExport(){return{name:this.name,note:this.note,color:this.color}}normalize(e){e.tableGroups[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()}}},Fve=Pve,Ive=class extends zv{constructor({tableName:e,schemaName:t,fieldNames:n,relation:r,token:i,ref:a}){super(i),this.relation=r,this.schemaName=t,this.tableName=e,this.fieldNames=n,this.fields=[],this.ref=a,this.dbState=this.ref.dbState,this.generateId();let o=a.schema.database.findOrCreateSchema(t||`public`).database.findTable(t,e);o||this.error(`Can't find table ${pve(t)?`"${t}".`:``}"${e}"`),this.setFields(n,o)}generateId(){this.id=this.dbState.generateId(`endpointId`)}equals(e){return this.fields.length===e.fields.length?this.compareFields(e):!1}compareFields(e){let t=this.fields.map(e=>e.id).sort(),n=e.fields.map(e=>e.id).sort();for(let e=0;e<t.length;e+=1)if(t[e]!==n[e])return!1;return!0}export(){return{...this.shallowExport()}}exportParentIds(){return{refId:this.ref.id,fieldIds:this.fields.map(e=>e.id)}}shallowExport(){return{schemaName:this.schemaName,tableName:this.tableName,fieldNames:this.fieldNames,relation:this.relation}}setFields(e,t){let n=e&&e.length?[...e]:[];if(!n.length){let e=t.fields.find(e=>e.pk);if(e)n.push(e.name);else{let e=t.indexes.find(e=>e.pk);e?n=e.columns.map(e=>e.value):this.error(`Can't find primary or composite key in table ${Rv(t.schema)?`"${t.schema.name}".`:``}"${t.name}"`)}}n.forEach(e=>{let n=t.findField(e);n||this.error(`Can't find field ${Rv(t.schema)?`"${t.schema.name}".`:``}"${e}" in table "${t.name}"`),this.fields.push(n),n.pushEndpoint(this)})}normalize(e){e.endpoints[this.id]={id:this.id,...this.shallowExport(),...this.exportParentIds()}}},Lve=Ive;function Rve(e,t){return e[0].equals(t[0])&&e[1].equals(t[1])}var zve=class extends zv{constructor({name:e,color:t,endpoints:n,onDelete:r,onUpdate:i,token:a,schema:o={},injectedPartial:s=null}={}){super(a),this.name=e,this.color=t,this.onDelete=r,this.onUpdate=i,this.endpoints=[],this.schema=o,this.injectedPartial=s,this.dbState=this.schema.dbState,this.generateId(),this.processEndpoints(n)}generateId(){this.id=this.dbState.generateId(`refId`)}processEndpoints(e){e.forEach(e=>{this.endpoints.push(new Lve({...e,ref:this})),e.schemaName}),this.endpoints[0].equals(this.endpoints[1])&&this.error(`Two endpoints are the same`),this.endpoints[0].fields.length!==this.endpoints[1].fields.length&&this.error(`Two endpoints have unequal number of fields`)}equals(e){return Rve(this.endpoints,e.endpoints)||Rve(this.endpoints,e.endpoints.slice().reverse())}export(){return{...this.shallowExport(),...this.exportChild()}}shallowExport(){return{name:this.name,color:this.color,onDelete:this.onDelete,onUpdate:this.onUpdate,injectedPartialId:this.injectedPartial?.id}}exportChild(){return{endpoints:this.endpoints.map(e=>e.export())}}exportChildIds(){return{endpointIds:this.endpoints.map(e=>e.id)}}exportParentIds(){return{schemaId:this.schema.id}}normalize(e){e.refs[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()},this.endpoints.forEach(t=>t.normalize(e))}},Bve=zve;id();var Vve=class extends zv{constructor({name:e,alias:t,note:n,tables:r=[],refs:i=[],enums:a=[],tableGroups:o=[],token:s,database:c={},noteToken:l=null}={}){super(s),this.tables=[],this.enums=[],this.tableGroups=[],this.refs=[],this.name=e,this.note=n?D(n,`value`,n):null,this.noteToken=n?D(n,`token`,l):null,this.alias=t,this.database=c,this.dbState=this.database.dbState,this.generateId(),this.processEnums(a),this.processTables(r),this.processRefs(i),this.processTableGroups(o)}generateId(){this.id=this.dbState.generateId(`schemaId`)}processTables(e){e.forEach(e=>{this.pushTable(new kve({...e,schema:this}))})}pushTable(e){this.checkTable(e),this.tables.push(e)}checkTable(e){this.tables.some(t=>t.name===e.name)&&e.error(`Table ${Rv(this)?`"${this.name}".`:``}"${e.name}" existed`)}findTable(e){return this.tables.find(t=>t.name===e)}processEnums(e){e.forEach(e=>{this.pushEnum(new Nve({...e,schema:this}))})}pushEnum(e){this.checkEnum(e),this.enums.push(e)}checkEnum(e){this.enums.some(t=>t.name===e.name)&&e.error(`Enum ${Rv(this)?`"${this.name}".`:``}"${e.name}" existed`)}processRefs(e){e.forEach(e=>{this.pushRef(new Bve({...e,schema:this}))})}pushRef(e){this.checkRef(e),this.refs.push(e)}checkRef(e){if(this.refs.some(t=>t.equals(e))){let t=e.endpoints[0],n=t.fieldNames.map(JSON.stringify).join(`, `),r=e.endpoints[1],i=r.fieldNames.map(JSON.stringify).join(`, `),a=`"${t.schemaName?`${t.schemaName}"."`:``}${t.tableName}"(${n})`,o=`"${r.schemaName?`${r.schemaName}"."`:``}${r.tableName}"(${i})`;e.error(`Reference with the same endpoints already exists: ${a} references ${o}`)}}processTableGroups(e){e.forEach(e=>{this.pushTableGroup(new Fve({...e,schema:this}))})}pushTableGroup(e){this.checkTableGroup(e),this.tableGroups.push(e)}checkTableGroup(e){this.tableGroups.some(t=>t.name===e.name)&&e.error(`Table Group ${Rv(this)?`"${this.name}".`:``}"${e.name}" existed`)}checkSameId(e){return this.name===e.name||this.alias===e.name||this.name===e.alias||this.alias&&this.alias===e.alias}export(){return{...this.shallowExport(),...this.exportChild()}}exportChild(){return{tables:this.tables.map(e=>e.export()),enums:this.enums.map(e=>e.export()),tableGroups:this.tableGroups.map(e=>e.export()),refs:this.refs.map(e=>e.export())}}exportChildIds(){return{tableIds:this.tables.map(e=>e.id),enumIds:this.enums.map(e=>e.id),tableGroupIds:this.tableGroups.map(e=>e.id),refIds:this.refs.map(e=>e.id)}}exportParentIds(){return{databaseId:this.database.id}}shallowExport(){return{name:this.name,note:this.note,alias:this.alias}}normalize(e){e.schemas[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()},this.tables.forEach(t=>t.normalize(e)),this.enums.forEach(t=>t.normalize(e)),this.tableGroups.forEach(t=>t.normalize(e)),this.refs.forEach(t=>t.normalize(e))}},Hve=Vve,Uve=class extends zv{constructor({name:e,content:t,headerColor:n,token:r,database:i={}}={}){super(r),this.name=e,this.content=t,this.headerColor=n,this.database=i,this.dbState=this.database.dbState,this.generateId()}generateId(){this.id=this.dbState.generateId(`noteId`)}export(){return{name:this.name,content:this.content,headerColor:this.headerColor}}normalize(e){e.notes[this.id]={id:this.id,...this.export()}}},Wve=Uve,Gve=class{constructor(){this.dbId=1,this.schemaId=1,this.enumId=1,this.tableGroupId=1,this.refId=1,this.tableId=1,this.noteId=1,this.enumValueId=1,this.endpointId=1,this.indexId=1,this.checkId=1,this.fieldId=1,this.indexColumnId=1,this.recordId=1,this.tablePartialId=1}generateId(e){let t=this[e];return this[e]+=1,t}};id();var Kve=class extends zv{constructor({name:e,note:t,fields:n=[],indexes:r=[],checks:i=[],token:a,headerColor:o,noteToken:s=null,dbState:c}={}){super(a),this.name=e,this.note=t?D(t,`value`,t):null,this.noteToken=t?D(t,`token`,s):null,this.headerColor=o,this.fields=n,this.indexes=r,this.checks=i,this.dbState=c,this.generateId()}generateId(){this.id=this.dbState.generateId(`tablePartialId`)}export(){return{...this.shallowExport()}}shallowExport(){return{name:this.name,note:this.note,headerColor:this.headerColor,fields:this.fields,indexes:this.indexes}}normalize(e){e.tablePartials[this.id]={id:this.id,...this.shallowExport()}}},qve=Kve;id();var Jve=class extends zv{constructor({schemas:e=[],tables:t=[],notes:n=[],enums:r=[],refs:i=[],tableGroups:a=[],project:o={},aliases:s=[],records:c=[],tablePartials:l=[]}){super(),this.dbState=new Gve,this.generateId(),this.hasDefaultSchema=!1,this.schemas=[],this.notes=[],this.note=o.note?D(o,`note.value`,o.note):null,this.noteToken=o.note?D(o,`note.token`,o.noteToken):null,this.databaseType=o.database_type,this.name=o.name,this.token=o.token,this.aliases=s,this.records=[],this.tablePartials=[],this.injectedRawRefs=[],this.processNotes(n),this.processRecords(c),this.processTablePartials(l),this.processSchemas(e),this.processSchemaElements(r,fme),this.processSchemaElements(t,ume),this.linkRecordsToTables(),this.processSchemaElements(n,`note`),this.processSchemaElements(i,`ref`),this.processSchemaElements(a,mme),this.injectedRawRefs.forEach(e=>{let t=this.findOrCreateSchema(a_),n=new Bve({...e,schema:t});t.refs.some(e=>e.equals(n))||t.pushRef(n)})}generateId(){this.id=this.dbState.generateId(`dbId`)}processNotes(e){e.forEach(e=>{this.pushNote(new Wve({...e,database:this}))})}processRecords(e){e.forEach(({schemaName:e,tableName:t,columns:n,values:r})=>{this.records.push({id:this.dbState.generateId(`recordId`),schemaName:e,tableName:t,columns:n,values:r})})}processTablePartials(e){e.forEach(e=>{this.tablePartials.push(new qve({...e,dbState:this.dbState}))})}pushNote(e){this.checkNote(e),this.notes.push(e)}checkNote(e){this.notes.some(t=>t.name===e.name)&&e.error(`Notes ${e.name} existed`)}processSchemas(e){e.forEach(e=>{this.pushSchema(new Hve({...e,database:this}))})}pushSchema(e){this.checkSchema(e),this.schemas.push(e)}checkSchema(e){this.schemas.some(t=>t.name===e.name)&&e.error(`Schemas ${e.name} existed`)}processSchemaElements(e,t){let n;e.forEach(e=>{switch(e.schemaName?(n=this.findOrCreateSchema(e.schemaName),e.schemaName):n=this.findOrCreateSchema(a_),t){case ume:n.pushTable(new kve({...e,schema:n}));break;case fme:n.pushEnum(new Nve({...e,schema:n}));break;case mme:n.pushTableGroup(new Fve({...e,schema:n}));break;case`ref`:n.pushRef(new Bve({...e,schema:n}));break;default:break}})}linkRecordsToTables(){let e={};this.schemas.forEach(t=>{e[t.name]={},t.tables.forEach(n=>{e[t.name][n.name]=n})}),this.records.forEach(t=>{let n=e[t.schemaName??`public`]?.[t.tableName];n&&(t.tableId=n.id,n.records.push(t))})}findOrCreateSchema(e){let t=this.schemas.find(t=>t.name===e||t.alias===e);return t||(t=new Hve({name:e,note:{value:e===`public`?`Default ${Xo(a_)} Schema`:null},database:this}),this.pushSchema(t)),t}findTableAlias(e){let t=this.aliases.find(t=>t.name===e);if(!t||t.kind!==`table`)return null;let n=t.value.schemaName||`public`,r=this.schemas.find(e=>e.name===n);if(!r)return null;let{tableName:i}=t.value;return r.tables.find(e=>e.name===i)}findTable(e,t){let n=null;if(!e&&(n=this.findTableAlias(t),n))return n;let r=this.findOrCreateSchema(e||`public`);return r||this.error(`Schema ${e||`public`} don't exist`),r.findTable(t)}findEnum(e,t){let n=this.schemas.find(t=>t.name===e||t.alias===e);return n?n.enums.find(e=>e.name===t):null}findTablePartial(e){return this.tablePartials.find(t=>t.name===e)}export(){return{...this.exportChild()}}shallowExport(){return{hasDefaultSchema:this.hasDefaultSchema,note:this.note,databaseType:this.databaseType,name:this.name}}exportChild(){return{schemas:this.schemas.map(e=>e.export()),notes:this.notes.map(e=>e.export()),records:this.records.map(e=>({...e}))}}exportChildIds(){return{schemaIds:this.schemas.map(e=>e.id),noteIds:this.notes.map(e=>e.id)}}normalize(){let e={database:{[this.id]:{id:this.id,...this.shallowExport(),...this.exportChildIds()}},schemas:{},notes:{},refs:{},enums:{},tableGroups:{},tables:{},endpoints:{},enumValues:{},indexes:{},indexColumns:{},checks:{},fields:{},records:{},tablePartials:{}};return this.schemas.forEach(t=>t.normalize(e)),this.notes.forEach(t=>t.normalize(e)),this.records.forEach(t=>{e.records[t.id]={...t}}),this.tablePartials.forEach(t=>t.normalize(e)),e}},Bv=Jve,Yve=class{static export(e,t){let{isNormalized:n}=t;return!n&&e instanceof Bv?JSON.stringify(e.export(),null,2):JSON.stringify(e,null,2)}},Xve=Yve;id();var Zve=class e{static exportRecords(e){let t=Object.values(e.records||{});return Wu(t)?[]:t.map(e=>{let{schemaName:t,tableName:n,columns:r,values:i}=e,a=t?`[${t}].[${n}]`:`[${n}]`,o=r.length>0?`([${r.join(`], [`)}])`:``,s=e=>e.value===null?`NULL`:e.type===`expression`||bh(e.type)?e.value:xh(e.type)?String(e.value).toUpperCase()===`TRUE`?`1`:`0`:Sh(e.type)||wh(e.type)?`'${e.value.replace(/'/g,`''`)}'`:Ch(e.type)?`0x${e.value}`:`CAST('${e.value.replace(/'/g,`''`)}' AS ${e.type})`;return`INSERT INTO ${a} ${o}\nVALUES\n ${i.map(e=>`(${e.map(s).join(`, `)})`).join(`,
43
+ `)}},_ve=gve,vve=class extends Error{constructor(e,t={start:{line:1,column:1}}){super(e),this.location=t,this.error=`error`}},yve=class{constructor(e){this.token=e}bind(e){this.selection=e}error(e){throw new vve(e,this.token)}},zv=yve,bve=class extends zv{constructor({token:e,name:t,expression:n,table:r,column:i=null,injectedPartial:a=null}={}){super(e),this.name=t,this.expression=n,this.table=r,this.column=i,this.injectedPartial=a,this.dbState=this.table.dbState,this.generateId()}generateId(){this.id=this.dbState.generateId(`checkId`)}export(){return{...this.shallowExport()}}exportParentIds(){return{tableId:this.table.id,columnId:this.column?.id,injectedPartialId:this.injectedPartial?.id}}shallowExport(){return{name:this.name,expression:this.expression}}normalize(e){e.checks[this.id]={id:this.id,...this.shallowExport(),...this.exportParentIds()}}},xve=bve;id();var Sve=class extends zv{constructor({name:e,type:t,unique:n,pk:r,token:i,not_null:a,note:o,dbdefault:s,increment:c,checks:l=[],table:u={},noteToken:d=null,injectedPartial:f=null,injectedToken:p=null}={}){super(i),e||this.error(`Field must have a name`),t||this.error(`Field must have a type`),this.name=e,this.type=t,this.unique=n,this.pk=r,this.not_null=a,this.note=o?D(o,`value`,o):null,this.noteToken=o?D(o,`token`,d):null,this.dbdefault=s,this.increment=c,this.checks=[],this.endpoints=[],this.table=u,this.injectedPartial=f,this.injectedToken=p,this.dbState=this.table.dbState,this.generateId(),this.bindType(),this.processChecks(l)}generateId(){this.id=this.dbState.generateId(`fieldId`)}bindType(){let e=this.type.type_name,t=this.type.schemaName||`public`;if(this.type.schemaName){let n=this.table.schema.database.findEnum(t,e);if(!n){this.type.type_name=`${t}.${e}`,this.type.originalTypeName=e;return}this._enum=n,n.pushField(this)}else{let n=this.table.schema.database.findEnum(t,e);if(!n)return;this._enum=n,n.pushField(this)}}pushEndpoint(e){this.endpoints.push(e)}export(){return{...this.shallowExport()}}exportParentIds(){return{tableId:this.table.id,enumId:this._enum?this._enum.id:null}}exportChildIds(){return{endpointIds:this.endpoints.map(e=>e.id)}}shallowExport(){return{name:this.name,type:this.type,unique:this.unique,pk:this.pk,not_null:this.not_null,note:this.note,dbdefault:this.dbdefault,increment:this.increment,injectedPartialId:this.injectedPartial?.id??null,checkIds:this.checks.map(e=>e.id)}}normalize(e){e.fields[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()},this.checks.forEach(t=>t.normalize(e))}processChecks(e){e.forEach(e=>{this.checks.push(new xve({...e,table:this.table,column:this}))})}},Cve=Sve,wve=class extends zv{constructor({type:e,value:t,index:n,token:r}){super(),this.type=e,this.value=t,this.index=n,this.token=r,this.dbState=this.index.dbState,this.generateId()}generateId(){this.id=this.dbState.generateId(`indexColumnId`)}export(){return{...this.shallowExport()}}exportParentIds(){return{indexId:this.index.id}}shallowExport(){return{type:this.type,value:this.value}}normalize(e){e.indexColumns[this.id]={id:this.id,...this.shallowExport(),...this.exportParentIds()}}},Tve=wve,Eve=class extends zv{constructor({columns:e,type:t,unique:n,pk:r,token:i,name:a,note:o,table:s={},injectedPartial:c=null}={}){super(i),this.name=a,this.type=t,this.unique=n,this.note=o?o.value:null,this.noteToken=o?o.token:null,this.pk=r,this.columns=[],this.table=s,this.injectedPartial=c,this.dbState=this.table.dbState,this.generateId(),this.processIndexColumns(e)}generateId(){this.id=this.dbState.generateId(`indexId`)}processIndexColumns(e){e.forEach(e=>{this.pushIndexColumn(new Tve({...e,index:this}))})}pushIndexColumn(e){this.checkIndexColumn(e),this.columns.push(e)}checkIndexColumn(e){this.columns.some(t=>t.type===e.type&&t.value===e.value)&&e.error(`Index column ${e.value} existed`)}export(){return{...this.shallowExport(),...this.exportChild()}}exportChild(){return{columns:this.columns.map(e=>e.export())}}exportChildIds(){return{columnIds:this.columns.map(e=>e.id)}}exportParentIds(){return{tableId:this.table.id}}shallowExport(){return{name:this.name,type:this.type,unique:this.unique,pk:this.pk,note:this.note,injectedPartialId:this.injectedPartial?.id}}normalize(e){e.indexes[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()},this.columns.forEach(t=>t.normalize(e))}},Dve=Eve;id();var Ove=class extends zv{constructor({name:e,alias:t,note:n,fields:r=[],indexes:i=[],checks:a=[],schema:o={},token:s,headerColor:c,noteToken:l=null,partials:u=[]}={}){super(s),this.name=e,this.alias=t,this.note=n?D(n,`value`,n):null,this.noteToken=n?D(n,`token`,l):null,this.headerColor=c,this.fields=[],this.indexes=[],this.checks=[],this.schema=o,this.partials=u,this.records=[],this.dbState=this.schema.dbState,this.generateId(),this.processFields(r),this.processPartials(),this.checkFieldCount(),this.processIndexes(i),this.processChecks(a)}generateId(){this.id=this.dbState.generateId(`tableId`)}checkFieldCount(){this.fields.length===0&&this.error(`Table must have at least one field`)}processFields(e){e.forEach(e=>{this.pushField(new Cve({...e,table:this}))})}pushField(e){this.checkField(e),this.fields.push(e)}checkField(e){this.fields.some(t=>t.name===e.name)&&e.error(`Field "${e.name}" existed in table ${Rv(this.schema)?`"${this.schema.name}".`:``}"${this.name}"`)}processIndexes(e){e.forEach(e=>{this.pushIndex(new Dve({...e,table:this}))})}pushIndex(e){this.checkIndex(e),this.indexes.push(e)}checkIndex(e){e.columns.forEach(t=>{t.type===`column`&&!this.findField(t.value)&&e.error(`Column "${t.value}" do not exist in table ${Rv(this.schema)?`"${this.schema.name}".`:``}"${this.name}"`)})}processChecks(e){e.forEach(e=>{this.pushCheck(new xve({...e,table:this}))})}pushCheck(e){this.checks.push(e)}findField(e){return this.fields.find(t=>t.name===e)}checkSameId(e){return this.schema.checkSameId(e.schemaName||`public`)&&(this.name===e.name||this.alias===e.name||this.name===e.alias||this.alias&&this.alias===e.alias)}processPartials(){if(!this.partials?.length)return;let e=new Set(this.fields.map(e=>e.name)),t=new Set;qu(this.note)||t.add(`note`),qu(this.headerColor)||t.add(`headerColor`);let n=this.partials.sort((e,t)=>t.order-e.order);n.toReversed().forEach(e=>{this.fields.splice(e.order,0,`dummy`)}),n.forEach(n=>{let r=this.schema.database.findTablePartial(n.name);if(r||this.error(`Table partial ${n.name} not found`,n.token),n.id=r.id,r.fields){let t=r.fields.filter(t=>!e.has(t.name)).map(t=>(e.add(t.name),t.inline_refs&&t.inline_refs.forEach(e=>{let n={token:t.token,endpoints:[{tableName:this.name,schemaName:this.schema?.name,fieldNames:[t.name],relation:[`-`,`<`].includes(e.relation)?`1`:`*`,token:t.token},{tableName:e.tableName,schemaName:e.schemaName,fieldNames:e.fieldNames,relation:[`-`,`>`].includes(e.relation)?`1`:`*`,token:e.token}],injectedPartial:r};this.schema.database.injectedRawRefs.push(n)}),new Cve({...t,noteToken:null,table:this,injectedPartial:r,injectedToken:n.token})));this.fields.splice(n.order,1,...t)}else this.fields.splice(n.order,1);!t.has(`note`)&&!qu(r.note)&&(this.noteToken=null,this.note=r.note,t.add(`note`)),!t.has(`headerColor`)&&!qu(r.headerColor)&&(this.headerColor=r.headerColor,t.add(`headerColor`)),r.indexes.forEach(e=>{this.indexes.push(new Dve({...e,table:this,injectedPartial:r}))}),r.checks.forEach(e=>{this.checks.push(new xve({...e,name:e.name&&`${this.name}.${e.name}`,table:this,injectedPartial:r}))})})}export(){return{...this.shallowExport(),...this.exportChild()}}exportChild(){return{fields:this.fields.map(e=>e.export()),indexes:this.indexes.map(e=>e.export())}}exportChildIds(){return{fieldIds:this.fields.map(e=>e.id),indexIds:this.indexes.map(e=>e.id),checkIds:this.checks.map(e=>e.id)}}exportParentIds(){return{schemaId:this.schema.id,groupId:this.group?this.group.id:null}}shallowExport(){return{name:this.name,alias:this.alias,note:this.note,headerColor:this.headerColor,partials:this.partials,recordIds:this.records.map(e=>e.id)}}normalize(e){e.tables[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()},this.fields.forEach(t=>t.normalize(e)),this.indexes.forEach(t=>t.normalize(e)),this.checks.forEach(t=>t.normalize(e))}},kve=Ove;id();var Ave=class extends zv{constructor({name:e,token:t,note:n,_enum:r,noteToken:i=null}={}){super(t),e||this.error(`Enum value must have a name`),this.name=e,this.note=n?D(n,`value`,n):null,this.noteToken=n?D(n,`token`,i):null,this._enum=r,this.dbState=this._enum.dbState,this.generateId()}generateId(){this.id=this.dbState.generateId(`enumValueId`)}export(){return{...this.shallowExport()}}exportParentIds(){return{enumId:this._enum.id}}shallowExport(){return{name:this.name,note:this.note}}normalize(e){e.enumValues[this.id]={id:this.id,...this.shallowExport(),...this.exportParentIds()}}},jve=Ave;id();var Mve=class extends zv{constructor({name:e,token:t,values:n,note:r,schema:i,noteToken:a=null}={}){super(t),e||this.error(`Enum must have a name`),this.name=e,this.note=r?D(r,`value`,r):null,this.noteToken=r?D(r,`token`,a):null,this.values=[],this.fields=[],this.schema=i,this.dbState=this.schema.dbState,this.generateId(),this.processValues(n)}generateId(){this.id=this.dbState.generateId(`enumId`)}processValues(e){e.forEach(e=>{this.pushValue(new jve({...e,_enum:this}))})}pushValue(e){this.checkValue(e),this.values.push(e)}checkValue(e){this.values.some(t=>t.name===e.name)&&e.error(`Enum value "${e.name}" existed in enum ${Rv(this.schema)?`"${this.schema.name}".`:``}"${this.name}"`)}pushField(e){this.checkField(e),this.fields.push(e)}checkField(e){this.fields.some(t=>t.id===e.id)&&this.error(`Field ${Rv(e.table.schema)?`"${e.table.schema.name}".`:``}"${e.table.name}"."${e.name}" already associated with enum ${Rv(this.schema)?`"${this.schema.name}".`:``}${this.name}"`)}export(){return{...this.shallowExport(),...this.exportChild()}}exportChild(){return{values:this.values.map(e=>e.export())}}exportChildIds(){return{valueIds:this.values.map(e=>e.id),fieldIds:this.fields.map(e=>e.id)}}exportParentIds(){return{schemaId:this.schema.id}}shallowExport(){return{name:this.name,note:this.note}}normalize(e){e.enums[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()},this.values.forEach(t=>t.normalize(e))}},Nve=Mve;id();var Pve=class extends zv{constructor({name:e,token:t,tables:n=[],schema:r={},note:i,color:a,noteToken:o=null}){super(t),this.name=e,this.tables=[],this.schema=r,this.dbState=this.schema.dbState,this.note=i?D(i,`value`,i):null,this.noteToken=i?D(i,`token`,o):null,this.color=a,this.generateId(),this.processTables(n)}generateId(){this.id=this.dbState.generateId(`tableGroupId`)}processTables(e){e.forEach(e=>{let t=this.schema.database.findTable(e.schemaName,e.name);t||this.error(`Table ${e.schemaName?`"${e.schemaName}".`:``}${e.name} don't exist`),this.pushTable(t)})}pushTable(e){this.checkTable(e),this.tables.push(e),e.group=this}checkTable(e){this.tables.some(t=>t.id===e.id)&&this.error(`Table ${Rv(e.schema)?`"${e.schema.name}".`:``}.${e.name} is already in the group`),e.group&&this.error(`Table ${Rv(e.schema)?`"${e.schema.name}".`:``}.${e.name} is already in group ${Rv(e.group.schema)?`"${e.group.schema.name}".`:``}${e.group.name}`)}export(){return{...this.shallowExport(),...this.exportChild()}}exportChild(){return{tables:this.tables.map(e=>({tableName:e.name,schemaName:e.schema.name}))}}exportChildIds(){return{tableIds:this.tables.map(e=>e.id)}}exportParentIds(){return{schemaId:this.schema.id}}shallowExport(){return{name:this.name,note:this.note,color:this.color}}normalize(e){e.tableGroups[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()}}},Fve=Pve,Ive=class extends zv{constructor({tableName:e,schemaName:t,fieldNames:n,relation:r,token:i,ref:a}){super(i),this.relation=r,this.schemaName=t,this.tableName=e,this.fieldNames=n,this.fields=[],this.ref=a,this.dbState=this.ref.dbState,this.generateId();let o=a.schema.database.findOrCreateSchema(t||`public`).database.findTable(t,e);o||this.error(`Can't find table ${pve(t)?`"${t}".`:``}"${e}"`),this.setFields(n,o)}generateId(){this.id=this.dbState.generateId(`endpointId`)}equals(e){return this.fields.length===e.fields.length?this.compareFields(e):!1}compareFields(e){let t=this.fields.map(e=>e.id).sort(),n=e.fields.map(e=>e.id).sort();for(let e=0;e<t.length;e+=1)if(t[e]!==n[e])return!1;return!0}export(){return{...this.shallowExport()}}exportParentIds(){return{refId:this.ref.id,fieldIds:this.fields.map(e=>e.id)}}shallowExport(){return{schemaName:this.schemaName,tableName:this.tableName,fieldNames:this.fieldNames,relation:this.relation}}setFields(e,t){let n=e&&e.length?[...e]:[];if(!n.length){let e=t.fields.find(e=>e.pk);if(e)n.push(e.name);else{let e=t.indexes.find(e=>e.pk);e?n=e.columns.map(e=>e.value):this.error(`Can't find primary or composite key in table ${Rv(t.schema)?`"${t.schema.name}".`:``}"${t.name}"`)}}n.forEach(e=>{let n=t.findField(e);n||this.error(`Can't find field ${Rv(t.schema)?`"${t.schema.name}".`:``}"${e}" in table "${t.name}"`),this.fields.push(n),n.pushEndpoint(this)})}normalize(e){e.endpoints[this.id]={id:this.id,...this.shallowExport(),...this.exportParentIds()}}},Lve=Ive;function Rve(e,t){return e[0].equals(t[0])&&e[1].equals(t[1])}var zve=class extends zv{constructor({name:e,color:t,endpoints:n,onDelete:r,onUpdate:i,token:a,schema:o={},injectedPartial:s=null}={}){super(a),this.name=e,this.color=t,this.onDelete=r,this.onUpdate=i,this.endpoints=[],this.schema=o,this.injectedPartial=s,this.dbState=this.schema.dbState,this.generateId(),this.processEndpoints(n)}generateId(){this.id=this.dbState.generateId(`refId`)}processEndpoints(e){e.forEach(e=>{this.endpoints.push(new Lve({...e,ref:this})),e.schemaName}),this.endpoints[0].equals(this.endpoints[1])&&this.error(`Two endpoints are the same`),this.endpoints[0].fields.length!==this.endpoints[1].fields.length&&this.error(`Two endpoints have unequal number of fields`)}equals(e){return Rve(this.endpoints,e.endpoints)||Rve(this.endpoints,e.endpoints.slice().reverse())}export(){return{...this.shallowExport(),...this.exportChild()}}shallowExport(){return{name:this.name,color:this.color,onDelete:this.onDelete,onUpdate:this.onUpdate,injectedPartialId:this.injectedPartial?.id}}exportChild(){return{endpoints:this.endpoints.map(e=>e.export())}}exportChildIds(){return{endpointIds:this.endpoints.map(e=>e.id)}}exportParentIds(){return{schemaId:this.schema.id}}normalize(e){e.refs[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()},this.endpoints.forEach(t=>t.normalize(e))}},Bve=zve;id();var Vve=class extends zv{constructor({name:e,alias:t,note:n,tables:r=[],refs:i=[],enums:a=[],tableGroups:o=[],token:s,database:c={},noteToken:l=null}={}){super(s),this.tables=[],this.enums=[],this.tableGroups=[],this.refs=[],this.name=e,this.note=n?D(n,`value`,n):null,this.noteToken=n?D(n,`token`,l):null,this.alias=t,this.database=c,this.dbState=this.database.dbState,this.generateId(),this.processEnums(a),this.processTables(r),this.processRefs(i),this.processTableGroups(o)}generateId(){this.id=this.dbState.generateId(`schemaId`)}processTables(e){e.forEach(e=>{this.pushTable(new kve({...e,schema:this}))})}pushTable(e){this.checkTable(e),this.tables.push(e)}checkTable(e){this.tables.some(t=>t.name===e.name)&&e.error(`Table ${Rv(this)?`"${this.name}".`:``}"${e.name}" existed`)}findTable(e){return this.tables.find(t=>t.name===e)}processEnums(e){e.forEach(e=>{this.pushEnum(new Nve({...e,schema:this}))})}pushEnum(e){this.checkEnum(e),this.enums.push(e)}checkEnum(e){this.enums.some(t=>t.name===e.name)&&e.error(`Enum ${Rv(this)?`"${this.name}".`:``}"${e.name}" existed`)}processRefs(e){e.forEach(e=>{this.pushRef(new Bve({...e,schema:this}))})}pushRef(e){this.checkRef(e),this.refs.push(e)}checkRef(e){if(this.refs.some(t=>t.equals(e))){let t=e.endpoints[0],n=t.fieldNames.map(JSON.stringify).join(`, `),r=e.endpoints[1],i=r.fieldNames.map(JSON.stringify).join(`, `),a=`"${t.schemaName?`${t.schemaName}"."`:``}${t.tableName}"(${n})`,o=`"${r.schemaName?`${r.schemaName}"."`:``}${r.tableName}"(${i})`;e.error(`Reference with the same endpoints already exists: ${a} references ${o}`)}}processTableGroups(e){e.forEach(e=>{this.pushTableGroup(new Fve({...e,schema:this}))})}pushTableGroup(e){this.checkTableGroup(e),this.tableGroups.push(e)}checkTableGroup(e){this.tableGroups.some(t=>t.name===e.name)&&e.error(`Table Group ${Rv(this)?`"${this.name}".`:``}"${e.name}" existed`)}checkSameId(e){return this.name===e.name||this.alias===e.name||this.name===e.alias||this.alias&&this.alias===e.alias}export(){return{...this.shallowExport(),...this.exportChild()}}exportChild(){return{tables:this.tables.map(e=>e.export()),enums:this.enums.map(e=>e.export()),tableGroups:this.tableGroups.map(e=>e.export()),refs:this.refs.map(e=>e.export())}}exportChildIds(){return{tableIds:this.tables.map(e=>e.id),enumIds:this.enums.map(e=>e.id),tableGroupIds:this.tableGroups.map(e=>e.id),refIds:this.refs.map(e=>e.id)}}exportParentIds(){return{databaseId:this.database.id}}shallowExport(){return{name:this.name,note:this.note,alias:this.alias}}normalize(e){e.schemas[this.id]={id:this.id,...this.shallowExport(),...this.exportChildIds(),...this.exportParentIds()},this.tables.forEach(t=>t.normalize(e)),this.enums.forEach(t=>t.normalize(e)),this.tableGroups.forEach(t=>t.normalize(e)),this.refs.forEach(t=>t.normalize(e))}},Hve=Vve,Uve=class extends zv{constructor({name:e,content:t,headerColor:n,token:r,database:i={}}={}){super(r),this.name=e,this.content=t,this.headerColor=n,this.database=i,this.dbState=this.database.dbState,this.generateId()}generateId(){this.id=this.dbState.generateId(`noteId`)}export(){return{name:this.name,content:this.content,headerColor:this.headerColor}}normalize(e){e.notes[this.id]={id:this.id,...this.export()}}},Wve=Uve,Gve=class{constructor(){this.dbId=1,this.schemaId=1,this.enumId=1,this.tableGroupId=1,this.refId=1,this.tableId=1,this.noteId=1,this.enumValueId=1,this.endpointId=1,this.indexId=1,this.checkId=1,this.fieldId=1,this.indexColumnId=1,this.recordId=1,this.tablePartialId=1}generateId(e){let t=this[e];return this[e]+=1,t}};id();var Kve=class extends zv{constructor({name:e,note:t,fields:n=[],indexes:r=[],checks:i=[],token:a,headerColor:o,noteToken:s=null,dbState:c}={}){super(a),this.name=e,this.note=t?D(t,`value`,t):null,this.noteToken=t?D(t,`token`,s):null,this.headerColor=o,this.fields=n,this.indexes=r,this.checks=i,this.dbState=c,this.generateId()}generateId(){this.id=this.dbState.generateId(`tablePartialId`)}export(){return{...this.shallowExport()}}shallowExport(){return{name:this.name,note:this.note,headerColor:this.headerColor,fields:this.fields,indexes:this.indexes}}normalize(e){e.tablePartials[this.id]={id:this.id,...this.shallowExport()}}},qve=Kve;id();var Jve=class extends zv{constructor({schemas:e=[],tables:t=[],notes:n=[],enums:r=[],refs:i=[],tableGroups:a=[],project:o={},aliases:s=[],records:c=[],tablePartials:l=[]}){super(),this.dbState=new Gve,this.generateId(),this.hasDefaultSchema=!1,this.schemas=[],this.notes=[],this.note=o.note?D(o,`note.value`,o.note):null,this.noteToken=o.note?D(o,`note.token`,o.noteToken):null,this.databaseType=o.database_type,this.name=o.name,this.token=o.token,this.aliases=s,this.records=[],this.tablePartials=[],this.injectedRawRefs=[],this.processNotes(n),this.processRecords(c),this.processTablePartials(l),this.processSchemas(e),this.processSchemaElements(r,fme),this.processSchemaElements(t,ume),this.linkRecordsToTables(),this.processSchemaElements(n,`note`),this.processSchemaElements(i,`ref`),this.processSchemaElements(a,mme),this.injectedRawRefs.forEach(e=>{let t=this.findOrCreateSchema(a_),n=new Bve({...e,schema:t});t.refs.some(e=>e.equals(n))||t.pushRef(n)})}generateId(){this.id=this.dbState.generateId(`dbId`)}processNotes(e){e.forEach(e=>{this.pushNote(new Wve({...e,database:this}))})}processRecords(e){e.forEach(({schemaName:e,tableName:t,columns:n,values:r,token:i})=>{this.records.push({id:this.dbState.generateId(`recordId`),schemaName:e,tableName:t,columns:n,values:r,token:i})})}processTablePartials(e){e.forEach(e=>{this.tablePartials.push(new qve({...e,dbState:this.dbState}))})}pushNote(e){this.checkNote(e),this.notes.push(e)}checkNote(e){this.notes.some(t=>t.name===e.name)&&e.error(`Notes ${e.name} existed`)}processSchemas(e){e.forEach(e=>{this.pushSchema(new Hve({...e,database:this}))})}pushSchema(e){this.checkSchema(e),this.schemas.push(e)}checkSchema(e){this.schemas.some(t=>t.name===e.name)&&e.error(`Schemas ${e.name} existed`)}processSchemaElements(e,t){let n;e.forEach(e=>{switch(e.schemaName?(n=this.findOrCreateSchema(e.schemaName),e.schemaName):n=this.findOrCreateSchema(a_),t){case ume:n.pushTable(new kve({...e,schema:n}));break;case fme:n.pushEnum(new Nve({...e,schema:n}));break;case mme:n.pushTableGroup(new Fve({...e,schema:n}));break;case`ref`:n.pushRef(new Bve({...e,schema:n}));break;default:break}})}linkRecordsToTables(){let e={};this.schemas.forEach(t=>{e[t.name]={},t.tables.forEach(n=>{e[t.name][n.name]=n})}),this.records.forEach(t=>{let n=e[t.schemaName??`public`]?.[t.tableName];n&&(t.tableId=n.id,n.records.push(t))})}findOrCreateSchema(e){let t=this.schemas.find(t=>t.name===e||t.alias===e);return t||(t=new Hve({name:e,note:{value:e===`public`?`Default ${Xo(a_)} Schema`:null},database:this}),this.pushSchema(t)),t}findTableAlias(e){let t=this.aliases.find(t=>t.name===e);if(!t||t.kind!==`table`)return null;let n=t.value.schemaName||`public`,r=this.schemas.find(e=>e.name===n);if(!r)return null;let{tableName:i}=t.value;return r.tables.find(e=>e.name===i)}findTable(e,t){let n=null;if(!e&&(n=this.findTableAlias(t),n))return n;let r=this.findOrCreateSchema(e||`public`);return r||this.error(`Schema ${e||`public`} don't exist`),r.findTable(t)}findEnum(e,t){let n=this.schemas.find(t=>t.name===e||t.alias===e);return n?n.enums.find(e=>e.name===t):null}findTablePartial(e){return this.tablePartials.find(t=>t.name===e)}export(){return{...this.exportChild()}}shallowExport(){return{hasDefaultSchema:this.hasDefaultSchema,note:this.note,databaseType:this.databaseType,name:this.name}}exportChild(){return{schemas:this.schemas.map(e=>e.export()),notes:this.notes.map(e=>e.export()),records:this.records.map(e=>({...e}))}}exportChildIds(){return{schemaIds:this.schemas.map(e=>e.id),noteIds:this.notes.map(e=>e.id)}}normalize(){let e={database:{[this.id]:{id:this.id,...this.shallowExport(),...this.exportChildIds()}},schemas:{},notes:{},refs:{},enums:{},tableGroups:{},tables:{},endpoints:{},enumValues:{},indexes:{},indexColumns:{},checks:{},fields:{},records:{},tablePartials:{}};return this.schemas.forEach(t=>t.normalize(e)),this.notes.forEach(t=>t.normalize(e)),this.records.forEach(t=>{e.records[t.id]={...t}}),this.tablePartials.forEach(t=>t.normalize(e)),e}},Bv=Jve,Yve=class{static export(e,t){let{isNormalized:n}=t;return!n&&e instanceof Bv?JSON.stringify(e.export(),null,2):JSON.stringify(e,null,2)}},Xve=Yve;id();var Zve=class e{static exportRecords(e){let t=Object.values(e.records||{});return Wu(t)?[]:t.map(e=>{let{schemaName:t,tableName:n,columns:r,values:i}=e,a=t?`[${t}].[${n}]`:`[${n}]`,o=r.length>0?`([${r.join(`], [`)}])`:``,s=e=>e.value===null?`NULL`:e.type===`expression`||bh(e.type)?e.value:xh(e.type)?String(e.value).toUpperCase()===`TRUE`?`1`:`0`:Sh(e.type)||wh(e.type)?`'${e.value.replace(/'/g,`''`)}'`:Ch(e.type)?`0x${e.value}`:`CAST('${e.value.replace(/'/g,`''`)}' AS ${e.type})`;return`INSERT INTO ${a} ${o}\nVALUES\n ${i.map(e=>`(${e.map(s).join(`, `)})`).join(`,
44
44
  `)};\nGO`})}static getFieldLines(e,t){return t.tables[e].fieldIds.map(e=>{let n=t.fields[e],r=``;if(n.enumId){let e=t.enums[n.enumId];r=`[${n.name}] nvarchar(255) NOT NULL CHECK ([${n.name}] IN (`;let i=e.valueIds.map(e=>`'${t.enumValues[e].name}'`);r+=`${i.join(`, `)}))`}else r=`[${n.name}] ${n.type.type_name===`varchar`?`nvarchar(255)`:n.type.type_name}`;if(n.unique&&(r+=` UNIQUE`),n.pk&&(r+=` PRIMARY KEY`),n.not_null&&(r+=` NOT NULL`),n.increment&&(r+=` IDENTITY(1, 1)`),n.checkIds&&n.checkIds.length>0)if(n.checkIds.length===1){let e=t.checks[n.checkIds[0]];e.name&&(r+=` CONSTRAINT [${e.name}]`),r+=` CHECK (${e.expression})`}else{let e=n.checkIds.map(e=>`(${t.checks[e].expression})`);r+=` CHECK (${e.join(` AND `)})`}return n.dbdefault&&(n.dbdefault.type===`boolean`&&(n.dbdefault.value===null||typeof n.dbdefault.value==`string`&&n.dbdefault.value.toLowerCase()===`null`)||(n.dbdefault.type===`expression`?r+=` DEFAULT (${n.dbdefault.value})`:n.dbdefault.type===`string`?r+=` DEFAULT '${n.dbdefault.value}'`:r+=` DEFAULT (${n.dbdefault.value})`)),r})}static getCompositePKs(e,t){let n=t.tables[e];return(n.indexIds?n.indexIds.filter(e=>t.indexes[e].pk):[]).map(e=>{let n=t.indexes[e],r=`PRIMARY KEY`,i=[];return n.columnIds.forEach(e=>{let n=t.indexColumns[e],r=``;r=n.type===`expression`?`(${n.value})`:`[${n.value}]`,i.push(r)}),r+=` (${i.join(`, `)})`,r})}static getCheckLines(e,t){let n=t.tables[e];return!n.checkIds||n.checkIds.length===0?[]:n.checkIds.map(e=>{let n=t.checks[e],r=``;return n.name&&(r=`CONSTRAINT [${n.name}] `),r+=`CHECK (${n.expression})`,r})}static getTableContentArr(t,n){return t.map(t=>({tableId:t,fieldContents:e.getFieldLines(t,n),checkContents:e.getCheckLines(t,n),compositePKs:e.getCompositePKs(t,n)}))}static exportTables(t,n){return e.getTableContentArr(t,n).map(e=>{let t=[...e.fieldContents,...e.checkContents,...e.compositePKs],r=n.tables[e.tableId],i=n.schemas[r.schemaId];return`CREATE TABLE ${Pv(i,n)?`[${i.name}].`:``}[${r.name}] (\n${t.map(e=>` ${e}`).join(`,
45
45
  `)}\n)\nGO\n`})}static buildTableManyToMany(e,t,n,r,i){let a=`CREATE TABLE ${Pv(r,i)?`[${r.name}].`:``}[${n}] (\n`,o=[...e.keys()].join(`], [`),s=[...t.keys()].join(`], [`);return e.forEach((e,t)=>{a+=` [${t}] ${e},\n`}),t.forEach((e,t)=>{a+=` [${t}] ${e},\n`}),a+=` PRIMARY KEY ([${o}], [${s}])\n`,a+=`);
46
46
  GO
@@ -134,4 +134,4 @@ function print() { __p += __j.call(arguments, '') }
134
134
  `+n.join(`, `)),`
135
135
  `].join(``);var n}function xe(e){return e.flags===void 0?[e.global?`g`:``,e.ignoreCase?`i`:``,e.multiline?`m`:``,e.unicode?`u`:``,e.sticky?`y`:``].join(``):e.flags}function Se(){for(var e=[].slice.call(arguments),t=e.length,n=0;n<t;n+=1)ae(e[n]);return r(function(n,r){for(var i,a=Array(t),o=0;o<t;o+=1){if(!(i=ne(e[o]._(n,r),i)).status)return i;a[o]=i.value,r=i.index}return ne(b(r,a),i)})}function Ce(){var e=[].slice.call(arguments);if(e.length===0)throw Error(`seqMap needs at least one argument`);var t=e.pop();return ce(t),Se.apply(null,e).map(function(e){return t.apply(null,e)})}function we(){var e=[].slice.call(arguments),t=e.length;if(t===0)return Ae(`zero alternates`);for(var n=0;n<t;n+=1)ae(e[n]);return r(function(t,n){for(var r,i=0;i<e.length;i+=1)if((r=ne(e[i]._(t,n),r)).status)return r;return r})}function Te(e,t){return Ee(e,t).or(ke([]))}function Ee(e,t){return ae(e),ae(t),Ce(e,t.then(e).many(),function(e,t){return[e].concat(t)})}function De(e){le(e);var t=`'`+e+`'`;return r(function(n,r){var i=r+e.length,a=n.slice(r,i);return a===e?b(i,a):te(r,t)})}function Oe(e,t){(function(e){if(!(e instanceof RegExp))throw Error(`not a regexp: `+e);for(var t=xe(e),n=0;n<t.length;n++){var r=t.charAt(n);if(r!==`i`&&r!==`m`&&r!==`u`&&r!==`s`)throw Error(`unsupported regexp flag "`+r+`": `+e)}})(e),arguments.length>=2?se(t):t=0;var n=function(e){return RegExp(`^(?:`+e.source+`)`,xe(e))}(e),i=``+e;return r(function(e,r){var a=n.exec(e.slice(r));if(a){if(0<=t&&t<=a.length){var o=a[0],s=a[t];return b(r+o.length,s)}return te(r,`valid match group (0 to `+a.length+`) in `+i)}return te(r,i)})}function ke(e){return r(function(t,n){return b(n,e)})}function Ae(e){return r(function(t,n){return te(n,e)})}function je(e){if(ee(e))return r(function(t,n){var r=e._(t,n);return r.index=n,r.value=``,r});if(typeof e==`string`)return je(De(e));if(e instanceof RegExp)return je(Oe(e));throw Error(`not a string, regexp, or parser: `+e)}function Me(e){return ae(e),r(function(t,n){var r=e._(t,n),i=t.slice(n,r.index);return r.status?te(n,`not "`+i+`"`):b(n,null)})}function Ne(e){return ce(e),r(function(t,n){var r=oe(t,n);return n<t.length&&e(r)?b(n+1,r):te(n,`a character/byte matching `+e)})}function Pe(e,t){arguments.length<2&&(t=e,e=void 0);var n=r(function(e,r){return n._=t()._,n._(e,r)});return e?n.desc(e):n}function Fe(){return Ae(`fantasy-land/empty`)}i.parse=function(e){if(typeof e!=`string`&&!y(e))throw Error(`.parse must be called with a string or Buffer as its argument`);var t,n=this.skip(ze)._(e,0);return t=n.status?{status:!0,value:n.value}:{status:!1,index:ie(e,n.furthest),expected:n.expected},delete re[e],t},i.tryParse=function(e){var t=this.parse(e);if(t.status)return t.value;var n=be(e,t),r=Error(n);throw r.type=`ParsimmonError`,r.result=t,r},i.assert=function(e,t){return this.chain(function(n){return e(n)?ke(n):Ae(t)})},i.or=function(e){return we(this,e)},i.trim=function(e){return this.wrap(e,e)},i.wrap=function(e,t){return Ce(e,this,t,function(e,t){return t})},i.thru=function(e){return e(this)},i.then=function(e){return ae(e),Se(this,e).map(function(e){return e[1]})},i.many=function(){var e=this;return r(function(t,n){for(var r=[],i=void 0;;){if(!(i=ne(e._(t,n),i)).status)return ne(b(n,r),i);if(n===i.index)throw Error(`infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause`);n=i.index,r.push(i.value)}})},i.tieWith=function(e){return le(e),this.map(function(t){if(function(e){if(!v(e))throw Error(`not an array: `+e)}(t),t.length){le(t[0]);for(var n=t[0],r=1;r<t.length;r++)le(t[r]),n+=e+t[r];return n}return``})},i.tie=function(){return this.tieWith(``)},i.times=function(e,t){var n=this;return arguments.length<2&&(t=e),se(e),se(t),r(function(r,i){for(var a=[],o=void 0,s=void 0,c=0;c<e;c+=1){if(s=ne(o=n._(r,i),s),!o.status)return s;i=o.index,a.push(o.value)}for(;c<t&&(s=ne(o=n._(r,i),s),o.status);c+=1)i=o.index,a.push(o.value);return ne(b(i,a),s)})},i.result=function(e){return this.map(function(){return e})},i.atMost=function(e){return this.times(0,e)},i.atLeast=function(e){return Ce(this.times(e),this.many(),function(e,t){return e.concat(t)})},i.map=function(e){ce(e);var t=this;return r(function(n,r){var i=t._(n,r);return i.status?ne(b(i.index,e(i.value)),i):i})},i.contramap=function(e){ce(e);var t=this;return r(function(n,r){var i=t.parse(e(n.slice(r)));return i.status?b(r+n.length,i.value):i})},i.promap=function(e,t){return ce(e),ce(t),this.contramap(e).map(t)},i.skip=function(e){return Se(this,e).map(function(e){return e[0]})},i.mark=function(){return Ce(Ie,this,Ie,function(e,t,n){return{start:e,value:t,end:n}})},i.node=function(e){return Ce(Ie,this,Ie,function(t,n,r){return{name:e,value:n,start:t,end:r}})},i.sepBy=function(e){return Te(this,e)},i.sepBy1=function(e){return Ee(this,e)},i.lookahead=function(e){return this.skip(je(e))},i.notFollowedBy=function(e){return this.skip(Me(e))},i.desc=function(e){v(e)||(e=[e]);var t=this;return r(function(n,r){var i=t._(n,r);return i.status||(i.expected=e),i})},i.fallback=function(e){return this.or(ke(e))},i.ap=function(e){return Ce(e,this,function(e,t){return e(t)})},i.chain=function(e){var t=this;return r(function(n,r){var i=t._(n,r);return i.status?ne(e(i.value)._(n,i.index),i):i})},i.concat=i.or,i.empty=Fe,i.of=ke,i[`fantasy-land/ap`]=i.ap,i[`fantasy-land/chain`]=i.chain,i[`fantasy-land/concat`]=i.concat,i[`fantasy-land/empty`]=i.empty,i[`fantasy-land/of`]=i.of,i[`fantasy-land/map`]=i.map;var Ie=r(function(e,t){return b(t,ie(e,t))}),Le=r(function(e,t){return t>=e.length?te(t,`any character/byte`):b(t+1,oe(e,t))}),Re=r(function(e,t){return b(e.length,e.slice(t))}),ze=r(function(e,t){return t<e.length?te(t,`EOF`):b(t,null)}),Be=Oe(/[0-9]/).desc(`a digit`),Ve=Oe(/[0-9]*/).desc(`optional digits`),He=Oe(/[a-z]/i).desc(`a letter`),Ue=Oe(/[a-z]*/i).desc(`optional letters`),We=Oe(/\s*/).desc(`optional whitespace`),Ge=Oe(/\s+/).desc(`whitespace`),Ke=De(`\r`),qe=De(`
136
136
  `),Je=De(`\r
137
- `),Ye=we(Je,qe,Ke).desc(`newline`),Xe=we(Ye,ze);r.all=Re,r.alt=we,r.any=Le,r.cr=Ke,r.createLanguage=function(e){var t={};for(var n in e)({}).hasOwnProperty.call(e,n)&&function(n){t[n]=Pe(function(){return e[n](t)})}(n);return t},r.crlf=Je,r.custom=function(e){return r(e(b,te))},r.digit=Be,r.digits=Ve,r.empty=Fe,r.end=Xe,r.eof=ze,r.fail=Ae,r.formatError=be,r.index=Ie,r.isParser=ee,r.lazy=Pe,r.letter=He,r.letters=Ue,r.lf=qe,r.lookahead=je,r.makeFailure=te,r.makeSuccess=b,r.newline=Ye,r.noneOf=function(e){return Ne(function(t){return e.indexOf(t)<0}).desc(`none of '`+e+`'`)},r.notFollowedBy=Me,r.of=ke,r.oneOf=function(e){for(var t=e.split(``),n=0;n<t.length;n++)t[n]=`'`+t[n]+`'`;return Ne(function(t){return e.indexOf(t)>=0}).desc(t)},r.optWhitespace=We,r.Parser=r,r.range=function(e,t){return Ne(function(n){return e<=n&&n<=t}).desc(e+`-`+t)},r.regex=Oe,r.regexp=Oe,r.sepBy=Te,r.sepBy1=Ee,r.seq=Se,r.seqMap=Ce,r.seqObj=function(){for(var e,t={},n=0,i=(e=arguments,Array.prototype.slice.call(e)),a=i.length,o=0;o<a;o+=1){var s=i[o];if(!ee(s)){if(v(s)&&s.length===2&&typeof s[0]==`string`&&ee(s[1])){var c=s[0];if(Object.prototype.hasOwnProperty.call(t,c))throw Error(`seqObj: duplicate key `+c);t[c]=!0,n++;continue}throw Error(`seqObj arguments must be parsers or [string, parser] array pairs.`)}}if(n===0)throw Error(`seqObj expects at least one named parser, found zero`);return r(function(e,t){for(var n,r={},o=0;o<a;o+=1){var s,c;if(v(i[o])?(s=i[o][0],c=i[o][1]):(s=null,c=i[o]),!(n=ne(c._(e,t),n)).status)return n;s&&(r[s]=n.value),t=n.index}return ne(b(t,r),n)})},r.string=De,r.succeed=ke,r.takeWhile=function(e){return ce(e),r(function(t,n){for(var r=n;r<t.length&&e(oe(t,r));)r++;return b(r,t.slice(n,r))})},r.test=Ne,r.whitespace=Ge,r[`fantasy-land/empty`]=Fe,r[`fantasy-land/of`]=ke,r.Binary={bitSeq:d,bitSeqObj:function(e){u();var t={},n=0,r=s(function(e){if(v(e)){var r=e;if(r.length!==2)throw Error(`[`+r.join(`, `)+`] should be length 2, got length `+r.length);if(le(r[0]),se(r[1]),Object.prototype.hasOwnProperty.call(t,r[0]))throw Error(`duplicate key in bitSeqObj: `+r[0]);return t[r[0]]=!0,n++,r}return se(e),[null,e]},e);if(n<1)throw Error(`bitSeqObj expects at least one named pair, got [`+e.join(`, `)+`]`);var i=s(function(e){return e[0]},r);return d(s(function(e){return e[1]},r)).map(function(e){return o(function(e,t){return t[0]!==null&&(e[t[0]]=t[1]),e},{},s(function(t,n){return[t,e[n]]},i))})},byte:function(e){if(u(),se(e),e>255)throw Error(`Value specified to byte constructor (`+e+`=0x`+e.toString(16)+`) is larger in value than a single byte.`);var t=(e>15?`0x`:`0x0`)+e.toString(16);return r(function(n,r){var i=oe(n,r);return i===e?b(r+1,i):te(r,t)})},buffer:function(e){return f(`buffer`,e).map(function(e){return Buffer.from(e)})},encodedString:function(e,t){return f(`string`,t).map(function(t){return t.toString(e)})},uintBE:m,uint8BE:m(1),uint16BE:m(2),uint32BE:m(4),uintLE:h,uint8LE:h(1),uint16LE:h(2),uint32LE:h(4),intBE:g,int8BE:g(1),int16BE:g(2),int32BE:g(4),intLE:_,int8LE:_(1),int16LE:_(2),int32LE:_(4),floatBE:f(`floatBE`,4).map(function(e){return e.readFloatBE(0)}),floatLE:f(`floatLE`,4).map(function(e){return e.readFloatLE(0)}),doubleBE:f(`doubleBE`,8).map(function(e){return e.readDoubleBE(0)}),doubleLE:f(`doubleLE`,8).map(function(e){return e.readDoubleLE(0)})},e.exports=r}])})})),e9,s1e,t9,n9=o((()=>{e9=u($7()),s1e=e9.default.createLanguage({WhiteSpaces:e=>e9.default.alt(e.WhiteSpace,e.InlineComment,e.MulLineComment).many().desc(`whitespaces or comments`),WhiteSpace:()=>e9.default.regexp(/\s/).desc(`whitespaces`),InlineComment:()=>e9.default.seq(e9.default.string(`--`),e9.default.regexp(/[^\n\r]*/)).desc(`comments`),MulLineComment:()=>e9.default.regexp(/\/\*[\s\S]+?\*\//).desc(`comments`)}),t9=s1e.WhiteSpaces}));function r9(e){return l1e.default.string(e).skip(t9).desc(`"${e}"`)}function c1e(e){let t=String(e);t=t.replace(/[\s]+/g,`\\s+`);let n=t.lastIndexOf(`/`);return new RegExp(t.slice(1,n),t.slice(n+1))}function i9(e){let t=e,n=e.source;return t=c1e(e),l1e.default.regexp(t).skip(t9).desc(`"${n}"`)}var l1e,u1e=o((()=>{l1e=u($7()),n9()})),d1e,a9,o9,f1e,p1e,m1e,h1e,g1e,_1e,v1e,y1e,b1e,x1e,S1e,s9,C1e,w1e,c9,T1e,E1e,D1e,O1e,k1e,A1e,j1e,M1e,N1e,P1e,F1e,I1e,L1e,R1e,z1e,B1e,V1e,H1e,U1e,W1e,G1e,K1e,q1e,J1e,Y1e,X1e,Z1e,l9,u9,Q1e,$1e,e0e,t0e,n0e,r0e,i0e,a0e,o0e,s0e,c0e,l0e,u0e,d0e,f0e,p0e,m0e,h0e,d9,g0e,f9,_0e,v0e,y0e,b0e,x0e,S0e,C0e,w0e,T0e,E0e,D0e,O0e,k0e,A0e,j0e,M0e,N0e,P0e,F0e,I0e,L0e,R0e,z0e,B0e,V0e,H0e,U0e,p9,m9,h9,W0e,G0e,K0e,q0e,g9,_9,J0e,Y0e,X0e,Z0e,Q0e,$0e,e2e,t2e,v9=o((()=>{u1e(),d1e=i9(/IDENTITY/i),a9=i9(/INDEX/i),o9=i9(/WITH/i),f1e=i9(/ON/i),i9(/OFF/i),m1e=i9(/FILESTREAM_ON/i),h1e=i9(/PRIMARY KEY/i),g1e=i9(/CLUSTERED/i),_1e=i9(/NONCLUSTERED/i),v1e=i9(/COLUMNSTORE/i),y1e=i9(/REFERENCES/i),b1e=i9(/FOREIGN KEY/i),x1e=i9(/CHECK/i),S1e=i9(/CONSTRAINT/i),s9=i9(/UNIQUE/i),i9(/HASH/i),i9(/BUCKET_COUNT/i),c9=i9(/NOT FOR REPLICATION/),T1e=i9(/ON DELETE/i),E1e=i9(/ON UPDATE/i),D1e=i9(/SET NULL/i),O1e=i9(/SET DEFAULT/i),k1e=i9(/NO ACTION/i),A1e=i9(/CASCADE/i),j1e=i9(/CONTENT/i),M1e=i9(/DOCUMENT/i),N1e=i9(/NULL/i),P1e=i9(/NOT NULL/i),F1e=i9(/DEFAULT/i),I1e=i9(/FILESTREAM/i),L1e=i9(/COLLATE/i),R1e=i9(/SPARSE/i),z1e=i9(/ROWGUIDCOL/i),B1e=i9(/MASKED/i),V1e=i9(/ENCRYPTED/i),i9(/FUNCTION/i),U1e=i9(/GENERATED ALWAYS AS ROW/i),W1e=i9(/START/i),G1e=i9(/END/i),K1e=i9(/HIDDEN/i),q1e=i9(/ASC/i),J1e=i9(/DESC/i),Y1e=i9(/TEXTIMAGE_ON/i),X1e=i9(/PERIOD FOR SYSTEM_TIME/i),Z1e=i9(/FILETABLE/i),l9=i9(/TABLE/i),u9=i9(/CREATE/i),Q1e=i9(/AS/i),$1e=i9(/PERSISTED/i),e0e=i9(/XML COLUMN_SET FOR ALL_SPARSE_COLUMNS/i),t0e=i9(/INCLUDE/i),n0e=i9(/IN/i),r0e=i9(/WHERE/i),i0e=i9(/FOR/i),a0e=i9(/WITH VALUES/i),o0e=i9(/CONNECTION/i),s0e=i9(/TO/i),c0e=i9(/ALTER/i),l0e=i9(/ADD/i),u0e=i9(/SET/i),d0e=i9(/REBUILD/i),f0e=i9(/SWITCH/i),p0e=i9(/ENABLE/i),m0e=i9(/DISABLE/i),i9(/NOCHECK/i),d9=i9(/DROP/i),g0e=i9(/ALTER COLUMN/i),f9=i9(/GO/i),_0e=i9(/BULK INSERT/i),v0e=i9(/INSERT/i),y0e=i9(/UPDATE/i),b0e=i9(/MERGE/i),x0e=i9(/TRUNCATE TABLE/i),S0e=i9(/BACKUP/i),C0e=i9(/RESTORE/i),w0e=i9(/CLOSE/i),T0e=i9(/DENY/i),E0e=i9(/EXECUTE/i),D0e=i9(/EXEC/i),O0e=i9(/GRANT/i),k0e=i9(/OPEN/i),A0e=i9(/REVOKE/i),j0e=i9(/BEGIN/i),i9(/GET/i),N0e=i9(/MOVE/i),P0e=i9(/RECEIVE/i),F0e=i9(/SEND/i),I0e=i9(/RENAME/i),L0e=i9(/DELETE/i),R0e=i9(/IF/i),z0e=i9(/sp_addextendedproperty/i),B0e=i9(/IN/i),V0e=i9(/AND/i),r9(`<`),r9(`>`),p9=r9(`(`),m9=r9(`,`),h9=r9(`)`),r9(`"`),G0e=r9(`'`),r9(`[`),r9(`]`),g9=r9(`=`),_9=r9(`;`),J0e=i9(/@name/i),Y0e=i9(/@value/i),X0e=i9(/@level0type/i),Z0e=i9(/@level0name/i),Q0e=i9(/@level1type/i),$0e=i9(/@level1name/i),e2e=i9(/@level2type/i),t2e=i9(/@level2name/i)}));function y9(){return function(e){return C9.default.seqMap(C9.default.index,e,C9.default.index,(t,n,r)=>n?(typeof n.value!=`object`&&(n.value={value:n.value}),n.value.token={start:t,end:r},n):e).skip(t9)}}function b9(e,t=!1){let n=e.sepBy1(m9);return t&&(n=e.sepBy(m9)),C9.default.seq(p9,n,h9).map(e=>e[1])}function x9(e){return function(t){return t.skip(t9).map(t=>(t!==0&&!t&&(t=``),{type:e,value:t}))}}function S9(e){let t=null;return e.length>1&&(t=e[e.length-2]),{name:yu(e),schemaName:t}}var C9,w9=o((()=>{C9=u($7()),id(),v9(),n9()})),T9,E9,D9,O9,k9,n2e,r2e,i2e,A9,j9,a2e,o2e,s2e,c2e,l2e,u2e,d2e,f2e,p2e,M9,m2e,h2e,g2e,_2e,v2e,N9,y2e,P9=o((()=>{T9=u($7()),w9(),v9(),n9(),E9=(0,T9.default)((e,t)=>{let n=t,r=!1,i=``;for(;n<e.length&&(r||!e.slice(n,n+2).match(/GO|;/i));)for(r&&e[n].match(/\]|'|"/i)&&e[n]===i?r=!1:!r&&e[n].match(/\[|"|'/i)&&(r=!0,i=e[n],e[n]===`[`&&(i=`]`)),e[n].match(/\s/)||(n+=1);n<e.length&&e[n].match(/\s/);)n+=1;return e.slice(n,n+2).match(/GO/i)&&--n,T9.default.makeSuccess(n+1,``)}),D9=T9.default.createLanguage({pIgnore:()=>E9,pColumnNames:e=>b9(T9.default.seq(e.pIdentifier,e.pKeywordAscOrDesc.fallback(null)).map(e=>e[0])).desc(`list of column names`),pDotDelimitedName:e=>T9.default.sepBy1(e.pIdentifier,T9.default.string(`.`)).desc(`dot delimited identifier`),pOptionList:e=>b9(e.pOption),pOption:e=>T9.default.seq(e.pIdentifier,g9,T9.default.seq(T9.default.alt(e.pIdentifier,e.pString).many(),T9.default.alt(e.pOptionList,b9(e.pIdentifier.many())).fallback(null))).desc(`option`),pComparsionOp:()=>T9.default.regex(/IS|IS[^\S\r\n]+NOT|=|<>|!=|>|>=|!>|<|<=|!</i).skip(t9).desc(`comparsion operator`),pConst:e=>T9.default.alt(e.pString,e.pUnicode,e.pBinary,e.pScience,e.pMoney,e.pSigned,e.pNumber).desc(`constant`),pFunction:e=>T9.default.seq(e.pIdentifier,b9(e.pFunctionParam,!0)).map(e=>`${e[0]}(${e[1].join(`,`)})`).thru(x9(`function`)).desc(`function constant`),pFunctionParam:e=>T9.default.alt(e.pNumber,e.pIdentifier).desc(`identifier or number paremeter`),pMoney:e=>T9.default.seq(T9.default.regexp(/[+-]\$/),e.pNumber).thru(x9(`money`)).desc(`money constant`),pSigned:e=>T9.default.seq(T9.default.regexp(/[+-]/),e.pNumber).thru(x9(`signed`)).desc(`signed constant`),pUnicode:e=>T9.default.seq(T9.default.string(`N`),e.pString).thru(x9(`unicode`)).desc(`unicode constant`),pString:()=>T9.default.regexp(/'[^']*'/).thru(x9(`string`)).map(e=>{let t=e.value;return e.value=t.slice(1,t.length-1),e}).desc(`string constant`),pNumberList:e=>b9(e.pNumber).desc(`list of number`),pNumber:()=>T9.default.regexp(/[0-9]+(\.[0-9]+)?/).map(Number).thru(x9(`number`)).desc(`number constant`),pBinary:()=>T9.default.regexp(/0x[A-F0-9]*/).thru(x9(`binary`)).desc(`binary constant`),pScience:()=>T9.default.regexp(/[+-]+[0-9]+(\.[0-9E]+)?/).thru(x9(`science`)).desc(`science constant`),pIdentifier:e=>T9.default.alt(e.pRegularIdentifier,e.pDelimitedIdentifier).skip(t9).desc(`identifier`),pDelimitedIdentifier:e=>T9.default.alt(e.pDQDelimitedIdentifier,e.pBracketDelimitedIdentifier).skip(t9).desc(`delimited identifier`),pRegularIdentifier:()=>T9.default.regexp(/^[\w@#][\w@#$]*/).skip(t9),pDQDelimitedIdentifier:()=>T9.default.seq(T9.default.string(`"`),T9.default.regexp(/[^"]*/),T9.default.string(`"`)).map(e=>e[1]).skip(t9),pBracketDelimitedIdentifier:()=>T9.default.seq(T9.default.string(`[`),T9.default.regexp(/[^\]]*/),T9.default.string(`]`)).map(e=>e[1]).skip(t9),pKeywordPKOrUnique:()=>T9.default.alt(h1e.result({type:`pk`,value:!0}),s9.result({type:`unique`,value:!0})),pKeywordClusteredOrNon:()=>T9.default.alt(g1e,_1e),pKeywordAscOrDesc:()=>T9.default.alt(q1e,J1e)}),O9=D9.pColumnNames,k9=D9.pDotDelimitedName,n2e=D9.pOptionList,r2e=D9.pOption,i2e=D9.pComparsionOp,A9=D9.pConst,j9=D9.pFunction,D9.pFunctionParam,D9.pMoney,D9.pSigned,D9.pUnicode,D9.pString,u2e=D9.pNumberList,D9.pNumber,D9.pBinary,D9.pScience,M9=D9.pIdentifier,D9.pDelimitedIdentifier,D9.pRegularIdentifier,D9.pDQDelimitedIdentifier,D9.pBracketDelimitedIdentifier,v2e=D9.pKeywordPKOrUnique,N9=D9.pKeywordClusteredOrNon,D9.pKeywordAscOrDesc}));function b2e(e,t){let n=t.value.endpoints.find(e=>!e.tableName);n.tableName=e.name,n.schemaName=e.schemaName}function x2e(e,t){t.value.tableName=e.name,t.value.schemaName=e.schemaName}function S2e(e,t,n){if(!n)return null;let r=S9(t);return n.forEach(e=>{if(e)switch(e.type){case`refs`:b2e(r,e);break;case`indexes`:case`dbdefault`:case`enums`:x2e(r,e);break;default:break}}),n}var C2e=o((()=>{w9()}));function w2e(e){return e.many().map(e=>e.join(``)).fallback(null).thru(x9(`token`))}function T2e(e){let t=h9.thru(w2e),n=p9.thru(w2e);return F9.default.seq(n,e,t)}function E2e(e){return F9.default.alt(T2e(e),e)}var F9,D2e,O2e,k2e=o((()=>{F9=u($7()),P9(),v9(),n9(),w9(),id(),D2e=F9.default.createLanguage({ExpressionFinal:e=>e.Expression.map(e=>Mu(e).map(e=>e?e.value:``).join(``)),Expression:e=>E2e(F9.default.seq(F9.default.alt(e.UnaryExpression,e.SimpleExpression),e.BinaryExpressionLR.fallback(null)).skip(t9)),UnaryExpression:e=>{let t=F9.default.regex(/[+\-~]/).thru(x9(`unary_operator`));return E2e(F9.default.seq(t,e.Expression).skip(t9))},BinaryExpressionLR:e=>{let t=F9.default.regexp(/[+\-*/%=!<>&^|]{1,2}/).map(e=>` ${e} `).thru(x9(`binary_operator`)).skip(t9);return F9.default.seq(t,e.Expression).skip(t9)},SimpleExpression:e=>E2e(F9.default.alt(j9,A9,e.ExpressionDDN).skip(t9)),ExpressionDDN:()=>k9.map(e=>e.join(`.`)).thru(x9(`identifier`))}),O2e=D2e.ExpressionFinal}));function A2e(e,t,n){return{tableName:e.name,schemaName:e.schemaName,fieldNames:t,relation:n}}function j2e(e,t){t.forEach(t=>{t.type.match(/ON[^\S\r\n]DELETE/i)&&(e.onDelete=t.setting),t.type.match(/ON[^\S\r\n]UPDATE/i)&&(e.onUpdate=t.setting)})}function M2e(e,t,n,r){let i={};return i.endpoint=A2e(S9(t),n,`1`),j2e(i,r),{type:`inline_refs`,value:[i]}}function N2e(e){return{type:`endpoint`,value:{fieldNames:e}}}function P2e(e,t,n,r,i,a){let o={},s=S9(r);return i||={type:`endpoint`,value:{fieldNames:null}},t.value.relation=`*`,i.value.relation=`1`,i.value.tableName=s.name,i.value.schemaName=s.schemaName,o.endpoints=[t.value,i.value],j2e(o,a),{type:`refs`,value:o}}function F2e(e,t){return{type:e,setting:t.toLowerCase().trim().split(/[ ]+/).join(` `)}}var I2e=o((()=>{w9()})),I9,L2e,R2e,z2e,B2e=o((()=>{I9=u($7()),v9(),P9(),w9(),I2e(),L2e=I9.default.createLanguage({TableConstraintFK:e=>I9.default.seqMap(b1e.fallback(null),e.TableEndpoint,y1e,k9,e.TableEndpoint.fallback(null),e.FKOptions.fallback(null),P2e),TableEndpoint:()=>I9.default.seqMap(O9,N2e).thru(y9()),ColumnConstraintFK:e=>I9.default.seqMap(e.FKKeywords,k9,b9(M9).fallback(null),e.FKOptions.fallback(null),M2e),FKOptions:e=>I9.default.alt(e.FKOnDelete,e.FKOnUpdate,e.FKNFR).many(),FKKeywords:()=>I9.default.seq(b1e.fallback(null),y1e),FKOnDelete:e=>I9.default.seqMap(T1e,e.FKOnOptions,F2e),FKOnUpdate:e=>I9.default.seqMap(E1e,e.FKOnOptions,F2e),FKNFR:()=>c9.map(e=>({type:e})),FKOnOptions:()=>I9.default.alt(k1e,A1e,O1e,D1e)}),R2e=L2e.ColumnConstraintFK,z2e=L2e.TableConstraintFK}));function V2e(e,t,n,r=null){let i=[];return e.forEach(e=>{i.push({value:e,type:`column`})}),{type:`indexes`,value:{name:r,unique:t?!0:null,pk:n?!0:null,columns:i}}}function H2e(e,t){return{type:`indexes`,value:{name:t,columns:[]}}}function U2e(e,t,n,r,i,a){return V2e(a,n,null,t)}function W2e(e,t,n){let r=null,i=null;return e.type===`pk`?r=!0:e.type===`unique`&&(i=!0),V2e(n,i,r)}var G2e=o((()=>{})),L9,R9,K2e,q2e,J2e,Y2e,X2e,z9=o((()=>{L9=u($7()),v9(),P9(),w9(),G2e(),R9=L9.default.createLanguage({TableIndex:e=>L9.default.seqMap(a9,M9,s9.fallback(null),N9.fallback(null),v1e.fallback(null),O9,U2e).thru(y9()).skip(e.IgnoredIndexOptions),TableConstraintIndex:e=>L9.default.seqMap(v2e,N9.fallback(null),O9,W2e).thru(y9()).skip(e.IgnoredIndexOptions),ColumnConstraintIndex:e=>L9.default.seq(v2e).skip(e.IgnoredIndexOptions).map(e=>e[0]),ColumnIndex:e=>L9.default.seqMap(a9,M9,H2e).thru(y9()).skip(e.IgnoredIndexOptions),IgnoredIndexOptions:e=>L9.default.alt(N9,e.IgnoredIndexOption).many(),IgnoredIndexOption:e=>L9.default.alt(e.WithIndexOption,e.ColumnIndexFilestream,e.OnIndexOption,e.WithFillFactorOption),WithIndexOption:()=>L9.default.seq(o9,n2e),WithFillFactorOption:()=>L9.default.seq(o9,r2e),OnIndexOption:()=>L9.default.seq(f1e,L9.default.alt(M9,j9)),ColumnIndexFilestream:()=>L9.default.seq(m1e,M9)}),K2e=R9.ColumnIndex,q2e=R9.IgnoredIndexOption,J2e=R9.TableIndex,Y2e=R9.ColumnConstraintIndex,X2e=R9.TableConstraintIndex}));function Z2e(e,t){let n={};if(t.type)switch(t.type){case`string`:case`number`:case`boolean`:n.type=t.type;break;default:n.type=`expression`;break}else n.type=`expression`;return n.value=t.value,{type:`dbdefault`,value:n}}function Q2e(e,t,n){let r=[];return n.forEach(e=>{r.push({name:e.value.value,token:e.value.token})}),{type:`enums`,value:{name:`${e}_enum`,values:r,fieldName:e}}}function $2e(e,t){return t?{type:t.type,value:{...t.value,name:t.type===`indexes`&&t.value.pk?null:e}}:null}var e4e=o((()=>{})),B9,V9,t4e,n4e,r4e,i4e,a4e,H9=o((()=>{B9=u($7()),v9(),k2e(),P9(),w9(),B2e(),z9(),e4e(),V9=B9.default.createLanguage({TableConstraint:e=>B9.default.seqMap(e.ConstraintName.fallback(null),e.TableConstraintOption,$2e).thru(y9()),TableConstraintOption:e=>B9.default.alt(z2e,X2e,e.ConstraintCheck),ColumnConstraint:e=>B9.default.seq(e.ConstraintName.fallback(null),e.ColumnConstraintOption).map(e=>e[1]),ColumnConstraintOption:e=>B9.default.alt(Y2e,R2e,e.ConstraintCheck,e.ConstraintDefault),ConstraintCheck:e=>B9.default.seq(x1e,c9.fallback(null),e.ConstraintCheckExpr).map(e=>e[2]),ConstraintCheckExpr:e=>B9.default.alt(B9.default.seq(p9.fallback(null),e.ConstraintCheckEnum,h9.fallback(null)).map(e=>e[1]),O2e.thru(x9(`expression`))),ConstraintCheckEnum:()=>B9.default.seqMap(M9,B0e,b9(A9.thru(y9())),Q2e).thru(y9()),ConstraintDefault:e=>B9.default.seqMap(F1e,e.ConstExpr,Z2e),ConstExpr:e=>B9.default.alt(B9.default.seq(p9,e.ConstExpr,h9).map(e=>e[1]),j9,A9,N1e.thru(x9(`boolean`))),ConstraintName:()=>B9.default.seq(S1e,M9).map(e=>e[1])}),t4e=V9.ColumnConstraint,n4e=V9.TableConstraint,r4e=V9.ConstraintCheck,i4e=V9.ConstraintName,a4e=V9.ConstExpr}));function o4e(e,t,n,r,i){let a={};if(t.type)switch(t.type){case`string`:case`number`:case`boolean`:a.type=t.type;break;default:a.type=`expression`;break}else a.type=`expression`;return a.value=t.value,a.fieldName=r,{type:`dbdefault`,value:a}}var s4e=o((()=>{H9()}));function c4e(e,t){let n=t?t.join(`,`):null;return{type:`type`,value:{type_name:n?`${yu(e)}(${n})`:yu(e),schemaName:e.length>1?e[0]:null,args:n}}}function l4e(e,t,n){let r={};return r[t.type]=t.value,n.forEach(e=>{e&&(r[e.type]=e.value)}),r.name=e[0],r.inline_refs||=[],{type:`fields`,value:r}}var u4e=o((()=>{id()})),U9,W9,d4e,f4e,p4e,m4e=o((()=>{U9=u($7()),v9(),P9(),w9(),z9(),H9(),k2e(),u4e(),W9=U9.default.createLanguage({ColumnsDefinition:e=>U9.default.alt(e.ComputedColumnDefinition.result(null),e.ColumnSetDefinition.result(null),e.ColumnDefinition),ColumnDefinition:e=>U9.default.seqMap(k9,e.DataType,U9.default.alt(e.ColumnSetting,e.IgnoredColumnSetting.result(null)).many().fallback(null),l4e).thru(y9()),ColumnSetDefinition:()=>U9.default.seq(M9,e0e),ComputedColumnDefinition:()=>U9.default.seq(M9,Q1e,O2e,U9.default.seq($1e,P1e.fallback(null)).fallback(null),t4e.fallback(null)),ColumnSetting:e=>U9.default.alt(e.NullOrNot,e.Identity,K2e,t4e),IgnoredColumnSetting:e=>U9.default.alt(e.ColumnSetting1Word,e.ColumnSettingWith,e.ColumnSettingGAAR,e.ColumnSettingCollate),DataType:e=>U9.default.seqMap(k9,b9(U9.default.alt(e.DataTypeXML,M9)).fallback(null),c4e),DataTypeXML:()=>U9.default.seq(U9.default.alt(M1e,j1e),M9).tieWith(` `),NullOrNot:()=>U9.default.alt(N1e.result(!1),P1e.result(!0)).thru(x9(`not_null`)),Identity:()=>d1e.result(!0).skip(u2e.fallback(null)).thru(x9(`increment`)),ColumnSetting1Word:()=>U9.default.alt(I1e,c9,z1e,R1e),ColumnSettingWith:()=>U9.default.seq(U9.default.alt(B1e,V1e),o9,n2e),ColumnSettingCollate:()=>U9.default.seq(L1e,M9),ColumnSettingGAAR:()=>U9.default.seq(U1e,U9.default.alt(W1e,G1e),K1e.fallback(null))}),W9.Identity,W9.DataType,p4e=W9.ColumnsDefinition})),G9,h4e,g4e,_4e=o((()=>{G9=u($7()),v9(),P9(),w9(),s4e(),B2e(),z9(),H9(),m4e(),h4e=G9.default.createLanguage({AddAction:e=>G9.default.seq(l0e,e.AddOption.sepBy1(m9)).map(e=>e[1]),AddOption:e=>G9.default.alt(e.AddConstraint,p4e.result(null),e.IgnoredAddSystemTimeOption.result(null)),IgnoredAddSystemTimeOption:()=>G9.default.alt(M9,G9.default.regexp(/[(),]/)).many(),AddConstraint:e=>G9.default.seqMap(i4e.fallback(null),e.AddConstraintOption,$2e).thru(y9()),AddConstraintOption:e=>G9.default.alt(z2e,X2e,r4e,e.AddConstraintDefault,e.IgnoredAddConstraintOption.result(null)),IgnoredAddConstraintOption:e=>G9.default.alt(e.AddConstraintConnection),AddConstraintDefault:()=>G9.default.seqMap(F1e,a4e,i0e,M9,a0e.fallback(null),o4e),AddConstraintConnection:()=>G9.default.seq(o0e,b9(G9.default.seq(M9,s0e,M9)))}),g4e=h4e.AddAction})),K9,v4e,y4e,b4e=o((()=>{K9=u($7()),v9(),P9(),C2e(),_4e(),v4e=K9.default.createLanguage({AlterTable:e=>K9.default.seqMap(e.AlterTableKeywords,k9,e.AlterTableActions,S2e),AlterTableActions:e=>K9.default.alt(g4e,e.IgnoredAlterTableActions),AlterTableKeywords:()=>K9.default.seq(c0e,l9),IgnoredAlterTableActions:e=>K9.default.seq(e.IgnoredAlterTableActionKeywords,E9).result(null),IgnoredAlterTableActionKeywords:()=>K9.default.alt(o9,g0e,d9,p0e,m0e,x1e,f0e,u0e,d0e)}),y4e=v4e.AlterTable}));function x4e(e,t,n,r,i,a,o,s){let c=S9(o),l=[];return s.forEach(e=>{l.push({value:e,type:`column`})}),{type:`indexes`,value:{name:i,unique:t?!0:null,tableName:c.name,schemaName:c.schemaName,columns:l}}}var S4e=o((()=>{w9()})),q9,C4e,w4e,T4e=o((()=>{q9=u($7()),v9(),P9(),w9(),S4e(),z9(),C4e=q9.default.createLanguage({CreateIndex:e=>q9.default.seqMap(u9,s9.fallback(null),N9.fallback(null),a9,M9,f1e,k9,O9,x4e).thru(y9()).skip(e.IgnoredCreateIndexOptions),IgnoredCreateIndexOptions:e=>q9.default.alt(q2e,e.IncludeIndexOption,e.WhereIndexOption).many(),IncludeIndexOption:()=>q9.default.seq(t0e,O9),WhereIndexOption:e=>q9.default.seq(r0e,e.FilterPredicate),FilterPredicate:e=>q9.default.seq(e.Conjunct,q9.default.seq(V0e,e.Conjunct).fallback(null)),Conjunct:e=>q9.default.alt(e.Disjunct,e.Comparsion),Disjunct:()=>q9.default.seq(M9,n0e,b9(A9)),Comparsion:()=>q9.default.seq(M9,i2e,A9)}),w4e=C4e.CreateIndex}));function E4e(e,t,n,r){if(!t||t.length===0)return;let i={},a=t[0];i.onUpdate=a.onUpdate,i.onDelete=a.onDelete,i.endpoints=[],i.endpoints.push({tableName:r.name,schemaName:r.schemaName,fieldNames:[n],relation:`*`}),a.endpoint.fieldNames||(a.endpoint.fieldNames=i.endpoints[0].fieldNames),i.endpoints.push(a.endpoint),e.push(i)}function D4e(e,t,n){if(t.enums){let r=t.enums,i=t.type;r.name=`${n.schemaName?`${n.schemaName}_`:``}${n.name}_${t.enums.name}`,i.type_name=r.name,i.args=r.values.map(e=>`'${e.name}'`).join(`, `),e.push(r),t.enums=null}}function O4e(e,t){t.indexes&&=(t.indexes.columns.push({value:t.name,type:`column`}),e.push(t.indexes),null)}function k4e(e,t){let n={fields:[],enums:[],refs:[],indexes:[]};return e.forEach(e=>{if(e&&n[e.type]){if(e.type===`fields`&&(D4e(n.enums,e.value,t),O4e(n.indexes,e.value),E4e(n.refs,e.value.inline_refs,e.value.name,t)),e.type===`refs`){let n=e.value;n.endpoints[0].tableName=t.name,n.endpoints[0].schemaName=t.schemaName}n[e.type].push(e.value)}}),{type:`lines`,value:n}}function A4e(e,t,n,r){let i=S9(t),a=k4e(r,i);return{type:`tables`,value:{...i,...a.value}}}var j4e=o((()=>{w9()})),J9,M4e,N4e,P4e=o((()=>{J9=u($7()),v9(),P9(),w9(),H9(),z9(),m4e(),j4e(),M4e=J9.default.createLanguage({CreateTable:e=>J9.default.seqMap(e.CreateTableKeywords,k9,e.AsFileTableKeywords.fallback(null),b9(e.Line),A4e).thru(y9()).skip(e.IgnoredTableOptions),CreateTableKeywords:()=>J9.default.seq(u9,l9),AsFileTableKeywords:()=>J9.default.seq(Q1e,Z1e),Line:e=>J9.default.alt(e.SystemTimeTableOption,n4e,J2e,p4e),SystemTimeTableOption:()=>J9.default.seq(X1e,b9(M9)).result(null),IgnoredTableOptions:e=>J9.default.alt(q2e,e.TextImageTableOption).many(),TextImageTableOption:()=>J9.default.seq(Y1e,M9)}),N4e=M4e.CreateTable}));function F4e({note:e,level:t}){let n=`unsupported`,r=null,i=null,a=null;return z4e(t)?(r=t[0].name,i=t[1].name,n=`table`):B4e(t)&&(r=t[0].name,i=t[1].name,a=t[2].name,n=`column`),{type:`comment`,value:{type:n,note:e,schemaName:r,tableName:i,columnName:a}}}var I4e,L4e,R4e,z4e,B4e,V4e=o((()=>{I4e=e=>e.toLowerCase()===`schema`,L4e=e=>e.toLowerCase()===`table`,R4e=e=>e.toLowerCase()===`column`,z4e=e=>e.length===2&&I4e(e[0].type)&&L4e(e[1].type),B4e=e=>e.length===3&&I4e(e[0].type)&&L4e(e[1].type)&&R4e(e[2].type)})),Y9,H4e,U4e,W4e=o((()=>{Y9=u($7()),v9(),V4e(),w9(),H4e=Y9.default.createLanguage({StartComment:()=>Y9.default.seq(D0e,z0e),EndComment:()=>Y9.default.seq(_9.atMost(1),f9),StartString:()=>Y9.default.alt(G0e,Y9.default.string(`N'`)),ManyDoubleSingleQuote:()=>Y9.default.string(`''`),NoSingleQuote:()=>Y9.default.regex(/[^']/),StringType:e=>Y9.default.alt(e.NoSingleQuote,e.ManyDoubleSingleQuote).atLeast(1).map(e=>e.join(``)),NVarchar:e=>e.StartString.then(e.StringType).skip(G0e),NameOption:e=>J0e.skip(g9).then(e.NVarchar),ValueOption:e=>Y0e.skip(g9).then(e.NVarchar),Level0Type:e=>X0e.skip(g9).then(e.NVarchar),Level0Name:e=>Z0e.skip(g9).then(e.NVarchar),Level1Type:e=>Q0e.skip(g9).then(e.NVarchar),Level1Name:e=>$0e.skip(g9).then(e.NVarchar),Level2Type:e=>e2e.skip(g9).then(e.NVarchar),Level2Name:e=>t2e.skip(g9).then(e.NVarchar),Level0Stmt:e=>Y9.default.seqObj([`type`,e.Level0Type],m9,[`name`,e.Level0Name]),Level1Stmt:e=>Y9.default.seqObj([`type`,e.Level1Type],m9,[`name`,e.Level1Name]),Level2Stmt:e=>Y9.default.seqObj([`type`,e.Level2Type],m9,[`name`,e.Level2Name]),Level0Wrapper:e=>Y9.default.alt(Y9.default.seq(e.Level0Stmt.skip(m9),e.Level1Wrapper),e.Level0Stmt).map(e=>Array.isArray(e)?[e[0],...e[1]]:[e]).atMost(1).map(e=>e.length===1?e[0]:e),Level1Wrapper:e=>Y9.default.alt(Y9.default.seq(e.Level1Stmt.skip(m9),e.Level2Stmt),e.Level1Stmt).map(e=>Array.isArray(e)?e:[e]),CommentSyntax:e=>Y9.default.seqObj(e.StartComment,[`name`,e.NameOption],m9,[`note`,e.ValueOption],m9,[`level`,e.Level0Wrapper],e.EndComment).map(F4e).thru(y9())}),U4e=H4e.CommentSyntax})),G4e=o((()=>{b4e(),T4e(),P4e(),W4e()}));function X9(e,t,n){let r=n||`public`;return e.tables.find(e=>(e.schemaName||`public`)===r&&e.name===t)}function K4e(e,t){return e.fields.find(e=>e.name===t)}function q4e(e,t){X9(t,e.tableName,e.schemaName).indexes.push(e),e.tableName=null}function J4e(e,t){e.forEach(e=>{t.push(e)})}function Y4e(e,t){J4e(e.enums,t.enums),J4e(e.refs,t.refs),e.enums.forEach(e=>{e.fieldName=null}),e.enums=null,e.refs=null}function X4e(e,t){let n=K4e(X9(t,e.tableName,e.schemaName),e.fieldName);e.fieldName=null,e.tableName=null,n.dbdefault=e}function Z4e(e,t){let n=K4e(X9(t,e.tableName,e.schemaName),e.fieldName);e.name=`${e.tableName}_${e.fieldName}_enum`,e.fieldName=null,e.tableName=null,n.type.type_name=e.name,n.type.args=e.values.map(e=>`'${e.name}'`).join(`, `)}function Q4e(e,t){let{schemaName:n}=e;n===`dbo`&&(n=null);let r=X9(t,e.tableName,n);r&&(r.note=e.note?{value:e.note}:null)}function $4e(e,t){let{schemaName:n}=e;n===`dbo`&&(n=null);let r=X9(t,e.tableName,n);if(r){let t=K4e(r,e.columnName);t&&(t.note=e.note?{value:e.note}:null)}}function e3e(e,t){e.type===`table`?Q4e(e,t):e.type===`column`&&$4e(e,t)}function t3e(e){let t={tables:[],refs:[],indexes:[],enums:[]};return io(e).forEach(e=>{if(e){switch(e.type){case`tables`:Y4e(e.value,t);break;case`indexes`:q4e(e.value,t);break;case`dbdefault`:X4e(e.value,t);break;case`enums`:Z4e(e.value,t);break;case`comment`:e3e(e.value,t);break;default:break}e.type&&t[e.type]&&t[e.type].push(e.value)}}),t.indexes=null,t}var n3e=o((()=>{id()})),Z9,r3e,Q9,i3e=o((()=>{Z9=u($7()),v9(),G4e(),n9(),n3e(),P9(),r3e=Z9.default.createLanguage({Statements:e=>t9.then(e.Seperator).then(Z9.default.sepBy(e.StatementTypes,e.Seperator)).skip(e.Seperator).map(t3e),StatementTypes:e=>Z9.default.alt(w4e,N4e,y4e,U4e,e.IgnoredStatementTypes),IgnoredStatementTypes:e=>Z9.default.seq(e.IgnoredStatementSyntax,E9),IgnoredStatementSyntax:e=>Z9.default.alt(e.IgnoredDDLSyntax,e.IgnoredDMLSyntax,e.IgnoredBackupAndRestoreSyntax,e.IgnoredServiceBrokerSyntax,e.IgnoredPermissionSyntax,l0e,w0e,u0e,R0e),IgnoredDDLSyntax:e=>Z9.default.alt(e.KeywordCreateWithoutTable,e.KeywordAlterWithoutTable,L1e,d9,I0e,p0e,m0e),IgnoredDMLSyntax:()=>Z9.default.alt(_0e,v0e,y0e,b0e,x0e,L0e),IgnoredServiceBrokerSyntax:()=>Z9.default.alt(j0e,G1e,N0e,P0e,F0e),IgnoredPermissionSyntax:()=>Z9.default.alt(T0e,E0e,O0e,k0e,A0e),IgnoredBackupAndRestoreSyntax:()=>Z9.default.alt(S0e,C0e),KeywordCreateWithoutTable:()=>u9.notFollowedBy(l9),KeywordAlterWithoutTable:()=>c0e.notFollowedBy(l9),Seperator:()=>Z9.default.alt(_9,f9,Z9.default.seq(_9,f9)).many()}),Q9=r3e.Statements})),a3e=c({default:()=>o3e},1),o3e,s3e=o((()=>{i3e(),Q9.parseWithPegError=function(e){try{return Q9.tryParse(e)}catch(t){let n={name:`SyntaxError`};console.error(t),n.location={},n.location.start=t.result.index,n.found=e[n.location.start.offset];let r=t.result.expected.pop();throw n.message=`Expected ${`${t.result.expected.join(`, `)}, or ${r}`} but "${n.found}" found.`,n}},o3e=Q9})),c3e=s(((e,t)=>{t.exports=(s3e(),d(a3e))})),l3e=u(r1e()),u3e=u(i1e()),d3e=u(a1e()),f3e=u(o1e()),p3e=u(c3e()),m3e=class e{constructor(e){this.DBMLCompiler=e||new lme}static parseJSONToDatabase(e){return new Bv(e)}static parseMySQLToJSONv2(e){return X7(e,`mysql`)}static parseMySQLToJSON(e){return l3e.default.parse(e)}static parsePostgresToJSONv2(e){return X7(e,`postgres`)}static parsePostgresToJSON(e){return u3e.default.parse(e)}static parseDBMLToJSONv2(e,t){let n=t||new lme;n.setSource(e);let r=n.parse.errors().map(e=>({message:e.diagnostic,location:{start:{line:e.nodeOrToken.startPos.line+1,column:e.nodeOrToken.startPos.column+1},end:{line:e.nodeOrToken.endPos.line+1,column:e.nodeOrToken.endPos.column+1}},code:e.code}));if(r.length>0)throw W7.create(r);return n.parse.rawDb()}static parseDBMLToJSON(e){return d3e.default.parse(e)}static parseSchemaRbToJSON(e){return f3e.default.parse(e)}static parseMSSQLToJSON(e){return p3e.default.parseWithPegError(e)}static parseMSSQLToJSONv2(e){return X7(e,`mssql`)}static parseSnowflakeToJSON(e){return X7(e,`snowflake`)}static parseOracleToJSON(e){return X7(e,`oracle`)}static parse(t,n){return new e().parse(t,n)}parse(t,n){try{let r={};switch(n){case`mysql`:r=e.parseMySQLToJSONv2(t);break;case`mysqlLegacy`:r=e.parseMySQLToJSON(t);break;case`postgres`:r=e.parsePostgresToJSONv2(t);break;case`snowflake`:r=e.parseSnowflakeToJSON(t);break;case`postgresLegacy`:r=e.parsePostgresToJSON(t);break;case`dbml`:r=e.parseDBMLToJSON(t);break;case`dbmlv2`:r=e.parseDBMLToJSONv2(t,this.DBMLCompiler);break;case`schemarb`:r=e.parseSchemaRbToJSON(t);break;case`mssqlLegacy`:r=e.parseMSSQLToJSON(t);break;case`mssql`:r=e.parseMSSQLToJSONv2(t);break;case`oracle`:r=e.parseOracleToJSON(t);break;case`json`:r=typeof t==`object`?t:JSON.parse(t);break;default:break}return e.parseJSONToDatabase(r)}catch(e){throw W7.create(e)}}},h3e=m3e;function g3e(e,t,n={isNormalized:!0,includeRecords:!0}){let r=_3e(n),i=new h3e().parse(e,`dbmlv2`);return $9.export(i.normalize(),t,r)}function _3e(e={}){if(typeof e==`boolean`)return{isNormalized:e,includeRecords:!0};let{isNormalized:t=!0,includeRecords:n=!0}=e;return{isNormalized:t,includeRecords:n}}var v3e={export:g3e},y3e=class{static export(e,t,n={isNormalized:!0,includeRecords:!0}){let{isNormalized:r,includeRecords:i}=_3e(n),a=e instanceof Bv?e.normalize():e,o=``;switch(t){case`dbml`:o=uve.export(a,{includeRecords:i});break;case`mysql`:o=fve.export(a);break;case`postgres`:o=_ve.export(a);break;case`json`:o=Xve.export(e,{isNormalized:r});break;case`mssql`:o=Qve.export(a);break;case`oracle`:o=eye.export(a);break;default:break}return o}},$9=y3e,b3e=e=>new Bv(e),x3e=e=>e.map(e=>{let{name:t,endpoints:n,onDelete:r,onUpdate:i}=e;return new UTe({name:t,endpoints:n.map(e=>new ck(e)),onDelete:r,onUpdate:i}).toJSON()}),S3e=e=>e.map(e=>{let{name:t,schemaName:n,values:r}=e;return new lk({name:t,schemaName:n,values:r})}),C3e=(e,t)=>e.map(e=>{let n=t[e.name]||{};return new ok({name:e.name,type:e.type,dbdefault:e.dbdefault,not_null:e.not_null,increment:e.increment,pk:n.pk||e.pk,unique:n.unique||e.unique,note:e.note,checks:n.checks})}),w3e=e=>e.map(e=>{let{name:t,unique:n,pk:r,type:i,columns:a}=e;return new ak({name:t,unique:n,pk:r,type:i,columns:a})}),T3e=(e,t,n,r,i)=>e.map(e=>{let{name:a,schemaName:o,note:s}=e,c=o?`${o}.${a}`:`${a}`,l=i[c]||{};return new sk({name:a,schemaName:o,fields:C3e(t[c],l),indexes:w3e(n[c]||[]),note:s,checks:r[c]})}),E3e=e=>{let{tables:t,fields:n,indexes:r,refs:i,enums:a,tableConstraints:o,checks:s}=e;try{let e=T3e(t,n,r,s,o),c=S3e(a);return b3e({schemas:[],tables:e,refs:x3e(i),enums:c,tableGroups:[],aliases:[],project:{}})}catch(e){throw Error(e)}};function D3e(e,t,n={includeRecords:!0}){let{includeRecords:r=!0}=n,i=new h3e().parse(e,t);return $9.export(i.normalize(),`dbml`,{includeRecords:r})}function O3e(e){let t=E3e(e);return $9.export(t.normalize(),`dbml`)}var k3e={import:D3e,generateDbml:O3e};function A3e(e,t,n){let r=new lme;return r.setSource(n),r.renameTable(e,t)}const j3e=`6.5.0`,M3e=`6.5.0`;exports.CompilerError=W7,exports.ModelExporter=$9,exports.Parser=h3e,exports.VERSION=`6.5.0`,exports.addDoubleQuoteIfNeeded=Yg,exports.exporter=v3e,exports.formatRecordValue=$fe,exports.importer=k3e,exports.isBinaryType=Ch,exports.isBooleanType=xh,exports.isDateTimeType=wh,exports.isFloatType=yh,exports.isIntegerType=vh,exports.isNumericType=bh,exports.isSerialType=Th,exports.isStringType=Sh,exports.renameTable=A3e,exports.tryExtractBoolean=Bg,exports.tryExtractDateTime=Hg,exports.tryExtractEnum=_fe,exports.tryExtractInteger=mfe,exports.tryExtractNumeric=zg,exports.tryExtractString=Vg;
137
+ `),Ye=we(Je,qe,Ke).desc(`newline`),Xe=we(Ye,ze);r.all=Re,r.alt=we,r.any=Le,r.cr=Ke,r.createLanguage=function(e){var t={};for(var n in e)({}).hasOwnProperty.call(e,n)&&function(n){t[n]=Pe(function(){return e[n](t)})}(n);return t},r.crlf=Je,r.custom=function(e){return r(e(b,te))},r.digit=Be,r.digits=Ve,r.empty=Fe,r.end=Xe,r.eof=ze,r.fail=Ae,r.formatError=be,r.index=Ie,r.isParser=ee,r.lazy=Pe,r.letter=He,r.letters=Ue,r.lf=qe,r.lookahead=je,r.makeFailure=te,r.makeSuccess=b,r.newline=Ye,r.noneOf=function(e){return Ne(function(t){return e.indexOf(t)<0}).desc(`none of '`+e+`'`)},r.notFollowedBy=Me,r.of=ke,r.oneOf=function(e){for(var t=e.split(``),n=0;n<t.length;n++)t[n]=`'`+t[n]+`'`;return Ne(function(t){return e.indexOf(t)>=0}).desc(t)},r.optWhitespace=We,r.Parser=r,r.range=function(e,t){return Ne(function(n){return e<=n&&n<=t}).desc(e+`-`+t)},r.regex=Oe,r.regexp=Oe,r.sepBy=Te,r.sepBy1=Ee,r.seq=Se,r.seqMap=Ce,r.seqObj=function(){for(var e,t={},n=0,i=(e=arguments,Array.prototype.slice.call(e)),a=i.length,o=0;o<a;o+=1){var s=i[o];if(!ee(s)){if(v(s)&&s.length===2&&typeof s[0]==`string`&&ee(s[1])){var c=s[0];if(Object.prototype.hasOwnProperty.call(t,c))throw Error(`seqObj: duplicate key `+c);t[c]=!0,n++;continue}throw Error(`seqObj arguments must be parsers or [string, parser] array pairs.`)}}if(n===0)throw Error(`seqObj expects at least one named parser, found zero`);return r(function(e,t){for(var n,r={},o=0;o<a;o+=1){var s,c;if(v(i[o])?(s=i[o][0],c=i[o][1]):(s=null,c=i[o]),!(n=ne(c._(e,t),n)).status)return n;s&&(r[s]=n.value),t=n.index}return ne(b(t,r),n)})},r.string=De,r.succeed=ke,r.takeWhile=function(e){return ce(e),r(function(t,n){for(var r=n;r<t.length&&e(oe(t,r));)r++;return b(r,t.slice(n,r))})},r.test=Ne,r.whitespace=Ge,r[`fantasy-land/empty`]=Fe,r[`fantasy-land/of`]=ke,r.Binary={bitSeq:d,bitSeqObj:function(e){u();var t={},n=0,r=s(function(e){if(v(e)){var r=e;if(r.length!==2)throw Error(`[`+r.join(`, `)+`] should be length 2, got length `+r.length);if(le(r[0]),se(r[1]),Object.prototype.hasOwnProperty.call(t,r[0]))throw Error(`duplicate key in bitSeqObj: `+r[0]);return t[r[0]]=!0,n++,r}return se(e),[null,e]},e);if(n<1)throw Error(`bitSeqObj expects at least one named pair, got [`+e.join(`, `)+`]`);var i=s(function(e){return e[0]},r);return d(s(function(e){return e[1]},r)).map(function(e){return o(function(e,t){return t[0]!==null&&(e[t[0]]=t[1]),e},{},s(function(t,n){return[t,e[n]]},i))})},byte:function(e){if(u(),se(e),e>255)throw Error(`Value specified to byte constructor (`+e+`=0x`+e.toString(16)+`) is larger in value than a single byte.`);var t=(e>15?`0x`:`0x0`)+e.toString(16);return r(function(n,r){var i=oe(n,r);return i===e?b(r+1,i):te(r,t)})},buffer:function(e){return f(`buffer`,e).map(function(e){return Buffer.from(e)})},encodedString:function(e,t){return f(`string`,t).map(function(t){return t.toString(e)})},uintBE:m,uint8BE:m(1),uint16BE:m(2),uint32BE:m(4),uintLE:h,uint8LE:h(1),uint16LE:h(2),uint32LE:h(4),intBE:g,int8BE:g(1),int16BE:g(2),int32BE:g(4),intLE:_,int8LE:_(1),int16LE:_(2),int32LE:_(4),floatBE:f(`floatBE`,4).map(function(e){return e.readFloatBE(0)}),floatLE:f(`floatLE`,4).map(function(e){return e.readFloatLE(0)}),doubleBE:f(`doubleBE`,8).map(function(e){return e.readDoubleBE(0)}),doubleLE:f(`doubleLE`,8).map(function(e){return e.readDoubleLE(0)})},e.exports=r}])})})),e9,s1e,t9,n9=o((()=>{e9=u($7()),s1e=e9.default.createLanguage({WhiteSpaces:e=>e9.default.alt(e.WhiteSpace,e.InlineComment,e.MulLineComment).many().desc(`whitespaces or comments`),WhiteSpace:()=>e9.default.regexp(/\s/).desc(`whitespaces`),InlineComment:()=>e9.default.seq(e9.default.string(`--`),e9.default.regexp(/[^\n\r]*/)).desc(`comments`),MulLineComment:()=>e9.default.regexp(/\/\*[\s\S]+?\*\//).desc(`comments`)}),t9=s1e.WhiteSpaces}));function r9(e){return l1e.default.string(e).skip(t9).desc(`"${e}"`)}function c1e(e){let t=String(e);t=t.replace(/[\s]+/g,`\\s+`);let n=t.lastIndexOf(`/`);return new RegExp(t.slice(1,n),t.slice(n+1))}function i9(e){let t=e,n=e.source;return t=c1e(e),l1e.default.regexp(t).skip(t9).desc(`"${n}"`)}var l1e,u1e=o((()=>{l1e=u($7()),n9()})),d1e,a9,o9,f1e,p1e,m1e,h1e,g1e,_1e,v1e,y1e,b1e,x1e,S1e,s9,C1e,w1e,c9,T1e,E1e,D1e,O1e,k1e,A1e,j1e,M1e,N1e,P1e,F1e,I1e,L1e,R1e,z1e,B1e,V1e,H1e,U1e,W1e,G1e,K1e,q1e,J1e,Y1e,X1e,Z1e,l9,u9,Q1e,$1e,e0e,t0e,n0e,r0e,i0e,a0e,o0e,s0e,c0e,l0e,u0e,d0e,f0e,p0e,m0e,h0e,d9,g0e,f9,_0e,v0e,y0e,b0e,x0e,S0e,C0e,w0e,T0e,E0e,D0e,O0e,k0e,A0e,j0e,M0e,N0e,P0e,F0e,I0e,L0e,R0e,z0e,B0e,V0e,H0e,U0e,p9,m9,h9,W0e,G0e,K0e,q0e,g9,_9,J0e,Y0e,X0e,Z0e,Q0e,$0e,e2e,t2e,v9=o((()=>{u1e(),d1e=i9(/IDENTITY/i),a9=i9(/INDEX/i),o9=i9(/WITH/i),f1e=i9(/ON/i),i9(/OFF/i),m1e=i9(/FILESTREAM_ON/i),h1e=i9(/PRIMARY KEY/i),g1e=i9(/CLUSTERED/i),_1e=i9(/NONCLUSTERED/i),v1e=i9(/COLUMNSTORE/i),y1e=i9(/REFERENCES/i),b1e=i9(/FOREIGN KEY/i),x1e=i9(/CHECK/i),S1e=i9(/CONSTRAINT/i),s9=i9(/UNIQUE/i),i9(/HASH/i),i9(/BUCKET_COUNT/i),c9=i9(/NOT FOR REPLICATION/),T1e=i9(/ON DELETE/i),E1e=i9(/ON UPDATE/i),D1e=i9(/SET NULL/i),O1e=i9(/SET DEFAULT/i),k1e=i9(/NO ACTION/i),A1e=i9(/CASCADE/i),j1e=i9(/CONTENT/i),M1e=i9(/DOCUMENT/i),N1e=i9(/NULL/i),P1e=i9(/NOT NULL/i),F1e=i9(/DEFAULT/i),I1e=i9(/FILESTREAM/i),L1e=i9(/COLLATE/i),R1e=i9(/SPARSE/i),z1e=i9(/ROWGUIDCOL/i),B1e=i9(/MASKED/i),V1e=i9(/ENCRYPTED/i),i9(/FUNCTION/i),U1e=i9(/GENERATED ALWAYS AS ROW/i),W1e=i9(/START/i),G1e=i9(/END/i),K1e=i9(/HIDDEN/i),q1e=i9(/ASC/i),J1e=i9(/DESC/i),Y1e=i9(/TEXTIMAGE_ON/i),X1e=i9(/PERIOD FOR SYSTEM_TIME/i),Z1e=i9(/FILETABLE/i),l9=i9(/TABLE/i),u9=i9(/CREATE/i),Q1e=i9(/AS/i),$1e=i9(/PERSISTED/i),e0e=i9(/XML COLUMN_SET FOR ALL_SPARSE_COLUMNS/i),t0e=i9(/INCLUDE/i),n0e=i9(/IN/i),r0e=i9(/WHERE/i),i0e=i9(/FOR/i),a0e=i9(/WITH VALUES/i),o0e=i9(/CONNECTION/i),s0e=i9(/TO/i),c0e=i9(/ALTER/i),l0e=i9(/ADD/i),u0e=i9(/SET/i),d0e=i9(/REBUILD/i),f0e=i9(/SWITCH/i),p0e=i9(/ENABLE/i),m0e=i9(/DISABLE/i),i9(/NOCHECK/i),d9=i9(/DROP/i),g0e=i9(/ALTER COLUMN/i),f9=i9(/GO/i),_0e=i9(/BULK INSERT/i),v0e=i9(/INSERT/i),y0e=i9(/UPDATE/i),b0e=i9(/MERGE/i),x0e=i9(/TRUNCATE TABLE/i),S0e=i9(/BACKUP/i),C0e=i9(/RESTORE/i),w0e=i9(/CLOSE/i),T0e=i9(/DENY/i),E0e=i9(/EXECUTE/i),D0e=i9(/EXEC/i),O0e=i9(/GRANT/i),k0e=i9(/OPEN/i),A0e=i9(/REVOKE/i),j0e=i9(/BEGIN/i),i9(/GET/i),N0e=i9(/MOVE/i),P0e=i9(/RECEIVE/i),F0e=i9(/SEND/i),I0e=i9(/RENAME/i),L0e=i9(/DELETE/i),R0e=i9(/IF/i),z0e=i9(/sp_addextendedproperty/i),B0e=i9(/IN/i),V0e=i9(/AND/i),r9(`<`),r9(`>`),p9=r9(`(`),m9=r9(`,`),h9=r9(`)`),r9(`"`),G0e=r9(`'`),r9(`[`),r9(`]`),g9=r9(`=`),_9=r9(`;`),J0e=i9(/@name/i),Y0e=i9(/@value/i),X0e=i9(/@level0type/i),Z0e=i9(/@level0name/i),Q0e=i9(/@level1type/i),$0e=i9(/@level1name/i),e2e=i9(/@level2type/i),t2e=i9(/@level2name/i)}));function y9(){return function(e){return C9.default.seqMap(C9.default.index,e,C9.default.index,(t,n,r)=>n?(typeof n.value!=`object`&&(n.value={value:n.value}),n.value.token={start:t,end:r},n):e).skip(t9)}}function b9(e,t=!1){let n=e.sepBy1(m9);return t&&(n=e.sepBy(m9)),C9.default.seq(p9,n,h9).map(e=>e[1])}function x9(e){return function(t){return t.skip(t9).map(t=>(t!==0&&!t&&(t=``),{type:e,value:t}))}}function S9(e){let t=null;return e.length>1&&(t=e[e.length-2]),{name:yu(e),schemaName:t}}var C9,w9=o((()=>{C9=u($7()),id(),v9(),n9()})),T9,E9,D9,O9,k9,n2e,r2e,i2e,A9,j9,a2e,o2e,s2e,c2e,l2e,u2e,d2e,f2e,p2e,M9,m2e,h2e,g2e,_2e,v2e,N9,y2e,P9=o((()=>{T9=u($7()),w9(),v9(),n9(),E9=(0,T9.default)((e,t)=>{let n=t,r=!1,i=``;for(;n<e.length&&(r||!e.slice(n,n+2).match(/GO|;/i));)for(r&&e[n].match(/\]|'|"/i)&&e[n]===i?r=!1:!r&&e[n].match(/\[|"|'/i)&&(r=!0,i=e[n],e[n]===`[`&&(i=`]`)),e[n].match(/\s/)||(n+=1);n<e.length&&e[n].match(/\s/);)n+=1;return e.slice(n,n+2).match(/GO/i)&&--n,T9.default.makeSuccess(n+1,``)}),D9=T9.default.createLanguage({pIgnore:()=>E9,pColumnNames:e=>b9(T9.default.seq(e.pIdentifier,e.pKeywordAscOrDesc.fallback(null)).map(e=>e[0])).desc(`list of column names`),pDotDelimitedName:e=>T9.default.sepBy1(e.pIdentifier,T9.default.string(`.`)).desc(`dot delimited identifier`),pOptionList:e=>b9(e.pOption),pOption:e=>T9.default.seq(e.pIdentifier,g9,T9.default.seq(T9.default.alt(e.pIdentifier,e.pString).many(),T9.default.alt(e.pOptionList,b9(e.pIdentifier.many())).fallback(null))).desc(`option`),pComparsionOp:()=>T9.default.regex(/IS|IS[^\S\r\n]+NOT|=|<>|!=|>|>=|!>|<|<=|!</i).skip(t9).desc(`comparsion operator`),pConst:e=>T9.default.alt(e.pString,e.pUnicode,e.pBinary,e.pScience,e.pMoney,e.pSigned,e.pNumber).desc(`constant`),pFunction:e=>T9.default.seq(e.pIdentifier,b9(e.pFunctionParam,!0)).map(e=>`${e[0]}(${e[1].join(`,`)})`).thru(x9(`function`)).desc(`function constant`),pFunctionParam:e=>T9.default.alt(e.pNumber,e.pIdentifier).desc(`identifier or number paremeter`),pMoney:e=>T9.default.seq(T9.default.regexp(/[+-]\$/),e.pNumber).thru(x9(`money`)).desc(`money constant`),pSigned:e=>T9.default.seq(T9.default.regexp(/[+-]/),e.pNumber).thru(x9(`signed`)).desc(`signed constant`),pUnicode:e=>T9.default.seq(T9.default.string(`N`),e.pString).thru(x9(`unicode`)).desc(`unicode constant`),pString:()=>T9.default.regexp(/'[^']*'/).thru(x9(`string`)).map(e=>{let t=e.value;return e.value=t.slice(1,t.length-1),e}).desc(`string constant`),pNumberList:e=>b9(e.pNumber).desc(`list of number`),pNumber:()=>T9.default.regexp(/[0-9]+(\.[0-9]+)?/).map(Number).thru(x9(`number`)).desc(`number constant`),pBinary:()=>T9.default.regexp(/0x[A-F0-9]*/).thru(x9(`binary`)).desc(`binary constant`),pScience:()=>T9.default.regexp(/[+-]+[0-9]+(\.[0-9E]+)?/).thru(x9(`science`)).desc(`science constant`),pIdentifier:e=>T9.default.alt(e.pRegularIdentifier,e.pDelimitedIdentifier).skip(t9).desc(`identifier`),pDelimitedIdentifier:e=>T9.default.alt(e.pDQDelimitedIdentifier,e.pBracketDelimitedIdentifier).skip(t9).desc(`delimited identifier`),pRegularIdentifier:()=>T9.default.regexp(/^[\w@#][\w@#$]*/).skip(t9),pDQDelimitedIdentifier:()=>T9.default.seq(T9.default.string(`"`),T9.default.regexp(/[^"]*/),T9.default.string(`"`)).map(e=>e[1]).skip(t9),pBracketDelimitedIdentifier:()=>T9.default.seq(T9.default.string(`[`),T9.default.regexp(/[^\]]*/),T9.default.string(`]`)).map(e=>e[1]).skip(t9),pKeywordPKOrUnique:()=>T9.default.alt(h1e.result({type:`pk`,value:!0}),s9.result({type:`unique`,value:!0})),pKeywordClusteredOrNon:()=>T9.default.alt(g1e,_1e),pKeywordAscOrDesc:()=>T9.default.alt(q1e,J1e)}),O9=D9.pColumnNames,k9=D9.pDotDelimitedName,n2e=D9.pOptionList,r2e=D9.pOption,i2e=D9.pComparsionOp,A9=D9.pConst,j9=D9.pFunction,D9.pFunctionParam,D9.pMoney,D9.pSigned,D9.pUnicode,D9.pString,u2e=D9.pNumberList,D9.pNumber,D9.pBinary,D9.pScience,M9=D9.pIdentifier,D9.pDelimitedIdentifier,D9.pRegularIdentifier,D9.pDQDelimitedIdentifier,D9.pBracketDelimitedIdentifier,v2e=D9.pKeywordPKOrUnique,N9=D9.pKeywordClusteredOrNon,D9.pKeywordAscOrDesc}));function b2e(e,t){let n=t.value.endpoints.find(e=>!e.tableName);n.tableName=e.name,n.schemaName=e.schemaName}function x2e(e,t){t.value.tableName=e.name,t.value.schemaName=e.schemaName}function S2e(e,t,n){if(!n)return null;let r=S9(t);return n.forEach(e=>{if(e)switch(e.type){case`refs`:b2e(r,e);break;case`indexes`:case`dbdefault`:case`enums`:x2e(r,e);break;default:break}}),n}var C2e=o((()=>{w9()}));function w2e(e){return e.many().map(e=>e.join(``)).fallback(null).thru(x9(`token`))}function T2e(e){let t=h9.thru(w2e),n=p9.thru(w2e);return F9.default.seq(n,e,t)}function E2e(e){return F9.default.alt(T2e(e),e)}var F9,D2e,O2e,k2e=o((()=>{F9=u($7()),P9(),v9(),n9(),w9(),id(),D2e=F9.default.createLanguage({ExpressionFinal:e=>e.Expression.map(e=>Mu(e).map(e=>e?e.value:``).join(``)),Expression:e=>E2e(F9.default.seq(F9.default.alt(e.UnaryExpression,e.SimpleExpression),e.BinaryExpressionLR.fallback(null)).skip(t9)),UnaryExpression:e=>{let t=F9.default.regex(/[+\-~]/).thru(x9(`unary_operator`));return E2e(F9.default.seq(t,e.Expression).skip(t9))},BinaryExpressionLR:e=>{let t=F9.default.regexp(/[+\-*/%=!<>&^|]{1,2}/).map(e=>` ${e} `).thru(x9(`binary_operator`)).skip(t9);return F9.default.seq(t,e.Expression).skip(t9)},SimpleExpression:e=>E2e(F9.default.alt(j9,A9,e.ExpressionDDN).skip(t9)),ExpressionDDN:()=>k9.map(e=>e.join(`.`)).thru(x9(`identifier`))}),O2e=D2e.ExpressionFinal}));function A2e(e,t,n){return{tableName:e.name,schemaName:e.schemaName,fieldNames:t,relation:n}}function j2e(e,t){t.forEach(t=>{t.type.match(/ON[^\S\r\n]DELETE/i)&&(e.onDelete=t.setting),t.type.match(/ON[^\S\r\n]UPDATE/i)&&(e.onUpdate=t.setting)})}function M2e(e,t,n,r){let i={};return i.endpoint=A2e(S9(t),n,`1`),j2e(i,r),{type:`inline_refs`,value:[i]}}function N2e(e){return{type:`endpoint`,value:{fieldNames:e}}}function P2e(e,t,n,r,i,a){let o={},s=S9(r);return i||={type:`endpoint`,value:{fieldNames:null}},t.value.relation=`*`,i.value.relation=`1`,i.value.tableName=s.name,i.value.schemaName=s.schemaName,o.endpoints=[t.value,i.value],j2e(o,a),{type:`refs`,value:o}}function F2e(e,t){return{type:e,setting:t.toLowerCase().trim().split(/[ ]+/).join(` `)}}var I2e=o((()=>{w9()})),I9,L2e,R2e,z2e,B2e=o((()=>{I9=u($7()),v9(),P9(),w9(),I2e(),L2e=I9.default.createLanguage({TableConstraintFK:e=>I9.default.seqMap(b1e.fallback(null),e.TableEndpoint,y1e,k9,e.TableEndpoint.fallback(null),e.FKOptions.fallback(null),P2e),TableEndpoint:()=>I9.default.seqMap(O9,N2e).thru(y9()),ColumnConstraintFK:e=>I9.default.seqMap(e.FKKeywords,k9,b9(M9).fallback(null),e.FKOptions.fallback(null),M2e),FKOptions:e=>I9.default.alt(e.FKOnDelete,e.FKOnUpdate,e.FKNFR).many(),FKKeywords:()=>I9.default.seq(b1e.fallback(null),y1e),FKOnDelete:e=>I9.default.seqMap(T1e,e.FKOnOptions,F2e),FKOnUpdate:e=>I9.default.seqMap(E1e,e.FKOnOptions,F2e),FKNFR:()=>c9.map(e=>({type:e})),FKOnOptions:()=>I9.default.alt(k1e,A1e,O1e,D1e)}),R2e=L2e.ColumnConstraintFK,z2e=L2e.TableConstraintFK}));function V2e(e,t,n,r=null){let i=[];return e.forEach(e=>{i.push({value:e,type:`column`})}),{type:`indexes`,value:{name:r,unique:t?!0:null,pk:n?!0:null,columns:i}}}function H2e(e,t){return{type:`indexes`,value:{name:t,columns:[]}}}function U2e(e,t,n,r,i,a){return V2e(a,n,null,t)}function W2e(e,t,n){let r=null,i=null;return e.type===`pk`?r=!0:e.type===`unique`&&(i=!0),V2e(n,i,r)}var G2e=o((()=>{})),L9,R9,K2e,q2e,J2e,Y2e,X2e,z9=o((()=>{L9=u($7()),v9(),P9(),w9(),G2e(),R9=L9.default.createLanguage({TableIndex:e=>L9.default.seqMap(a9,M9,s9.fallback(null),N9.fallback(null),v1e.fallback(null),O9,U2e).thru(y9()).skip(e.IgnoredIndexOptions),TableConstraintIndex:e=>L9.default.seqMap(v2e,N9.fallback(null),O9,W2e).thru(y9()).skip(e.IgnoredIndexOptions),ColumnConstraintIndex:e=>L9.default.seq(v2e).skip(e.IgnoredIndexOptions).map(e=>e[0]),ColumnIndex:e=>L9.default.seqMap(a9,M9,H2e).thru(y9()).skip(e.IgnoredIndexOptions),IgnoredIndexOptions:e=>L9.default.alt(N9,e.IgnoredIndexOption).many(),IgnoredIndexOption:e=>L9.default.alt(e.WithIndexOption,e.ColumnIndexFilestream,e.OnIndexOption,e.WithFillFactorOption),WithIndexOption:()=>L9.default.seq(o9,n2e),WithFillFactorOption:()=>L9.default.seq(o9,r2e),OnIndexOption:()=>L9.default.seq(f1e,L9.default.alt(M9,j9)),ColumnIndexFilestream:()=>L9.default.seq(m1e,M9)}),K2e=R9.ColumnIndex,q2e=R9.IgnoredIndexOption,J2e=R9.TableIndex,Y2e=R9.ColumnConstraintIndex,X2e=R9.TableConstraintIndex}));function Z2e(e,t){let n={};if(t.type)switch(t.type){case`string`:case`number`:case`boolean`:n.type=t.type;break;default:n.type=`expression`;break}else n.type=`expression`;return n.value=t.value,{type:`dbdefault`,value:n}}function Q2e(e,t,n){let r=[];return n.forEach(e=>{r.push({name:e.value.value,token:e.value.token})}),{type:`enums`,value:{name:`${e}_enum`,values:r,fieldName:e}}}function $2e(e,t){return t?{type:t.type,value:{...t.value,name:t.type===`indexes`&&t.value.pk?null:e}}:null}var e4e=o((()=>{})),B9,V9,t4e,n4e,r4e,i4e,a4e,H9=o((()=>{B9=u($7()),v9(),k2e(),P9(),w9(),B2e(),z9(),e4e(),V9=B9.default.createLanguage({TableConstraint:e=>B9.default.seqMap(e.ConstraintName.fallback(null),e.TableConstraintOption,$2e).thru(y9()),TableConstraintOption:e=>B9.default.alt(z2e,X2e,e.ConstraintCheck),ColumnConstraint:e=>B9.default.seq(e.ConstraintName.fallback(null),e.ColumnConstraintOption).map(e=>e[1]),ColumnConstraintOption:e=>B9.default.alt(Y2e,R2e,e.ConstraintCheck,e.ConstraintDefault),ConstraintCheck:e=>B9.default.seq(x1e,c9.fallback(null),e.ConstraintCheckExpr).map(e=>e[2]),ConstraintCheckExpr:e=>B9.default.alt(B9.default.seq(p9.fallback(null),e.ConstraintCheckEnum,h9.fallback(null)).map(e=>e[1]),O2e.thru(x9(`expression`))),ConstraintCheckEnum:()=>B9.default.seqMap(M9,B0e,b9(A9.thru(y9())),Q2e).thru(y9()),ConstraintDefault:e=>B9.default.seqMap(F1e,e.ConstExpr,Z2e),ConstExpr:e=>B9.default.alt(B9.default.seq(p9,e.ConstExpr,h9).map(e=>e[1]),j9,A9,N1e.thru(x9(`boolean`))),ConstraintName:()=>B9.default.seq(S1e,M9).map(e=>e[1])}),t4e=V9.ColumnConstraint,n4e=V9.TableConstraint,r4e=V9.ConstraintCheck,i4e=V9.ConstraintName,a4e=V9.ConstExpr}));function o4e(e,t,n,r,i){let a={};if(t.type)switch(t.type){case`string`:case`number`:case`boolean`:a.type=t.type;break;default:a.type=`expression`;break}else a.type=`expression`;return a.value=t.value,a.fieldName=r,{type:`dbdefault`,value:a}}var s4e=o((()=>{H9()}));function c4e(e,t){let n=t?t.join(`,`):null;return{type:`type`,value:{type_name:n?`${yu(e)}(${n})`:yu(e),schemaName:e.length>1?e[0]:null,args:n}}}function l4e(e,t,n){let r={};return r[t.type]=t.value,n.forEach(e=>{e&&(r[e.type]=e.value)}),r.name=e[0],r.inline_refs||=[],{type:`fields`,value:r}}var u4e=o((()=>{id()})),U9,W9,d4e,f4e,p4e,m4e=o((()=>{U9=u($7()),v9(),P9(),w9(),z9(),H9(),k2e(),u4e(),W9=U9.default.createLanguage({ColumnsDefinition:e=>U9.default.alt(e.ComputedColumnDefinition.result(null),e.ColumnSetDefinition.result(null),e.ColumnDefinition),ColumnDefinition:e=>U9.default.seqMap(k9,e.DataType,U9.default.alt(e.ColumnSetting,e.IgnoredColumnSetting.result(null)).many().fallback(null),l4e).thru(y9()),ColumnSetDefinition:()=>U9.default.seq(M9,e0e),ComputedColumnDefinition:()=>U9.default.seq(M9,Q1e,O2e,U9.default.seq($1e,P1e.fallback(null)).fallback(null),t4e.fallback(null)),ColumnSetting:e=>U9.default.alt(e.NullOrNot,e.Identity,K2e,t4e),IgnoredColumnSetting:e=>U9.default.alt(e.ColumnSetting1Word,e.ColumnSettingWith,e.ColumnSettingGAAR,e.ColumnSettingCollate),DataType:e=>U9.default.seqMap(k9,b9(U9.default.alt(e.DataTypeXML,M9)).fallback(null),c4e),DataTypeXML:()=>U9.default.seq(U9.default.alt(M1e,j1e),M9).tieWith(` `),NullOrNot:()=>U9.default.alt(N1e.result(!1),P1e.result(!0)).thru(x9(`not_null`)),Identity:()=>d1e.result(!0).skip(u2e.fallback(null)).thru(x9(`increment`)),ColumnSetting1Word:()=>U9.default.alt(I1e,c9,z1e,R1e),ColumnSettingWith:()=>U9.default.seq(U9.default.alt(B1e,V1e),o9,n2e),ColumnSettingCollate:()=>U9.default.seq(L1e,M9),ColumnSettingGAAR:()=>U9.default.seq(U1e,U9.default.alt(W1e,G1e),K1e.fallback(null))}),W9.Identity,W9.DataType,p4e=W9.ColumnsDefinition})),G9,h4e,g4e,_4e=o((()=>{G9=u($7()),v9(),P9(),w9(),s4e(),B2e(),z9(),H9(),m4e(),h4e=G9.default.createLanguage({AddAction:e=>G9.default.seq(l0e,e.AddOption.sepBy1(m9)).map(e=>e[1]),AddOption:e=>G9.default.alt(e.AddConstraint,p4e.result(null),e.IgnoredAddSystemTimeOption.result(null)),IgnoredAddSystemTimeOption:()=>G9.default.alt(M9,G9.default.regexp(/[(),]/)).many(),AddConstraint:e=>G9.default.seqMap(i4e.fallback(null),e.AddConstraintOption,$2e).thru(y9()),AddConstraintOption:e=>G9.default.alt(z2e,X2e,r4e,e.AddConstraintDefault,e.IgnoredAddConstraintOption.result(null)),IgnoredAddConstraintOption:e=>G9.default.alt(e.AddConstraintConnection),AddConstraintDefault:()=>G9.default.seqMap(F1e,a4e,i0e,M9,a0e.fallback(null),o4e),AddConstraintConnection:()=>G9.default.seq(o0e,b9(G9.default.seq(M9,s0e,M9)))}),g4e=h4e.AddAction})),K9,v4e,y4e,b4e=o((()=>{K9=u($7()),v9(),P9(),C2e(),_4e(),v4e=K9.default.createLanguage({AlterTable:e=>K9.default.seqMap(e.AlterTableKeywords,k9,e.AlterTableActions,S2e),AlterTableActions:e=>K9.default.alt(g4e,e.IgnoredAlterTableActions),AlterTableKeywords:()=>K9.default.seq(c0e,l9),IgnoredAlterTableActions:e=>K9.default.seq(e.IgnoredAlterTableActionKeywords,E9).result(null),IgnoredAlterTableActionKeywords:()=>K9.default.alt(o9,g0e,d9,p0e,m0e,x1e,f0e,u0e,d0e)}),y4e=v4e.AlterTable}));function x4e(e,t,n,r,i,a,o,s){let c=S9(o),l=[];return s.forEach(e=>{l.push({value:e,type:`column`})}),{type:`indexes`,value:{name:i,unique:t?!0:null,tableName:c.name,schemaName:c.schemaName,columns:l}}}var S4e=o((()=>{w9()})),q9,C4e,w4e,T4e=o((()=>{q9=u($7()),v9(),P9(),w9(),S4e(),z9(),C4e=q9.default.createLanguage({CreateIndex:e=>q9.default.seqMap(u9,s9.fallback(null),N9.fallback(null),a9,M9,f1e,k9,O9,x4e).thru(y9()).skip(e.IgnoredCreateIndexOptions),IgnoredCreateIndexOptions:e=>q9.default.alt(q2e,e.IncludeIndexOption,e.WhereIndexOption).many(),IncludeIndexOption:()=>q9.default.seq(t0e,O9),WhereIndexOption:e=>q9.default.seq(r0e,e.FilterPredicate),FilterPredicate:e=>q9.default.seq(e.Conjunct,q9.default.seq(V0e,e.Conjunct).fallback(null)),Conjunct:e=>q9.default.alt(e.Disjunct,e.Comparsion),Disjunct:()=>q9.default.seq(M9,n0e,b9(A9)),Comparsion:()=>q9.default.seq(M9,i2e,A9)}),w4e=C4e.CreateIndex}));function E4e(e,t,n,r){if(!t||t.length===0)return;let i={},a=t[0];i.onUpdate=a.onUpdate,i.onDelete=a.onDelete,i.endpoints=[],i.endpoints.push({tableName:r.name,schemaName:r.schemaName,fieldNames:[n],relation:`*`}),a.endpoint.fieldNames||(a.endpoint.fieldNames=i.endpoints[0].fieldNames),i.endpoints.push(a.endpoint),e.push(i)}function D4e(e,t,n){if(t.enums){let r=t.enums,i=t.type;r.name=`${n.schemaName?`${n.schemaName}_`:``}${n.name}_${t.enums.name}`,i.type_name=r.name,i.args=r.values.map(e=>`'${e.name}'`).join(`, `),e.push(r),t.enums=null}}function O4e(e,t){t.indexes&&=(t.indexes.columns.push({value:t.name,type:`column`}),e.push(t.indexes),null)}function k4e(e,t){let n={fields:[],enums:[],refs:[],indexes:[]};return e.forEach(e=>{if(e&&n[e.type]){if(e.type===`fields`&&(D4e(n.enums,e.value,t),O4e(n.indexes,e.value),E4e(n.refs,e.value.inline_refs,e.value.name,t)),e.type===`refs`){let n=e.value;n.endpoints[0].tableName=t.name,n.endpoints[0].schemaName=t.schemaName}n[e.type].push(e.value)}}),{type:`lines`,value:n}}function A4e(e,t,n,r){let i=S9(t),a=k4e(r,i);return{type:`tables`,value:{...i,...a.value}}}var j4e=o((()=>{w9()})),J9,M4e,N4e,P4e=o((()=>{J9=u($7()),v9(),P9(),w9(),H9(),z9(),m4e(),j4e(),M4e=J9.default.createLanguage({CreateTable:e=>J9.default.seqMap(e.CreateTableKeywords,k9,e.AsFileTableKeywords.fallback(null),b9(e.Line),A4e).thru(y9()).skip(e.IgnoredTableOptions),CreateTableKeywords:()=>J9.default.seq(u9,l9),AsFileTableKeywords:()=>J9.default.seq(Q1e,Z1e),Line:e=>J9.default.alt(e.SystemTimeTableOption,n4e,J2e,p4e),SystemTimeTableOption:()=>J9.default.seq(X1e,b9(M9)).result(null),IgnoredTableOptions:e=>J9.default.alt(q2e,e.TextImageTableOption).many(),TextImageTableOption:()=>J9.default.seq(Y1e,M9)}),N4e=M4e.CreateTable}));function F4e({note:e,level:t}){let n=`unsupported`,r=null,i=null,a=null;return z4e(t)?(r=t[0].name,i=t[1].name,n=`table`):B4e(t)&&(r=t[0].name,i=t[1].name,a=t[2].name,n=`column`),{type:`comment`,value:{type:n,note:e,schemaName:r,tableName:i,columnName:a}}}var I4e,L4e,R4e,z4e,B4e,V4e=o((()=>{I4e=e=>e.toLowerCase()===`schema`,L4e=e=>e.toLowerCase()===`table`,R4e=e=>e.toLowerCase()===`column`,z4e=e=>e.length===2&&I4e(e[0].type)&&L4e(e[1].type),B4e=e=>e.length===3&&I4e(e[0].type)&&L4e(e[1].type)&&R4e(e[2].type)})),Y9,H4e,U4e,W4e=o((()=>{Y9=u($7()),v9(),V4e(),w9(),H4e=Y9.default.createLanguage({StartComment:()=>Y9.default.seq(D0e,z0e),EndComment:()=>Y9.default.seq(_9.atMost(1),f9),StartString:()=>Y9.default.alt(G0e,Y9.default.string(`N'`)),ManyDoubleSingleQuote:()=>Y9.default.string(`''`),NoSingleQuote:()=>Y9.default.regex(/[^']/),StringType:e=>Y9.default.alt(e.NoSingleQuote,e.ManyDoubleSingleQuote).atLeast(1).map(e=>e.join(``)),NVarchar:e=>e.StartString.then(e.StringType).skip(G0e),NameOption:e=>J0e.skip(g9).then(e.NVarchar),ValueOption:e=>Y0e.skip(g9).then(e.NVarchar),Level0Type:e=>X0e.skip(g9).then(e.NVarchar),Level0Name:e=>Z0e.skip(g9).then(e.NVarchar),Level1Type:e=>Q0e.skip(g9).then(e.NVarchar),Level1Name:e=>$0e.skip(g9).then(e.NVarchar),Level2Type:e=>e2e.skip(g9).then(e.NVarchar),Level2Name:e=>t2e.skip(g9).then(e.NVarchar),Level0Stmt:e=>Y9.default.seqObj([`type`,e.Level0Type],m9,[`name`,e.Level0Name]),Level1Stmt:e=>Y9.default.seqObj([`type`,e.Level1Type],m9,[`name`,e.Level1Name]),Level2Stmt:e=>Y9.default.seqObj([`type`,e.Level2Type],m9,[`name`,e.Level2Name]),Level0Wrapper:e=>Y9.default.alt(Y9.default.seq(e.Level0Stmt.skip(m9),e.Level1Wrapper),e.Level0Stmt).map(e=>Array.isArray(e)?[e[0],...e[1]]:[e]).atMost(1).map(e=>e.length===1?e[0]:e),Level1Wrapper:e=>Y9.default.alt(Y9.default.seq(e.Level1Stmt.skip(m9),e.Level2Stmt),e.Level1Stmt).map(e=>Array.isArray(e)?e:[e]),CommentSyntax:e=>Y9.default.seqObj(e.StartComment,[`name`,e.NameOption],m9,[`note`,e.ValueOption],m9,[`level`,e.Level0Wrapper],e.EndComment).map(F4e).thru(y9())}),U4e=H4e.CommentSyntax})),G4e=o((()=>{b4e(),T4e(),P4e(),W4e()}));function X9(e,t,n){let r=n||`public`;return e.tables.find(e=>(e.schemaName||`public`)===r&&e.name===t)}function K4e(e,t){return e.fields.find(e=>e.name===t)}function q4e(e,t){X9(t,e.tableName,e.schemaName).indexes.push(e),e.tableName=null}function J4e(e,t){e.forEach(e=>{t.push(e)})}function Y4e(e,t){J4e(e.enums,t.enums),J4e(e.refs,t.refs),e.enums.forEach(e=>{e.fieldName=null}),e.enums=null,e.refs=null}function X4e(e,t){let n=K4e(X9(t,e.tableName,e.schemaName),e.fieldName);e.fieldName=null,e.tableName=null,n.dbdefault=e}function Z4e(e,t){let n=K4e(X9(t,e.tableName,e.schemaName),e.fieldName);e.name=`${e.tableName}_${e.fieldName}_enum`,e.fieldName=null,e.tableName=null,n.type.type_name=e.name,n.type.args=e.values.map(e=>`'${e.name}'`).join(`, `)}function Q4e(e,t){let{schemaName:n}=e;n===`dbo`&&(n=null);let r=X9(t,e.tableName,n);r&&(r.note=e.note?{value:e.note}:null)}function $4e(e,t){let{schemaName:n}=e;n===`dbo`&&(n=null);let r=X9(t,e.tableName,n);if(r){let t=K4e(r,e.columnName);t&&(t.note=e.note?{value:e.note}:null)}}function e3e(e,t){e.type===`table`?Q4e(e,t):e.type===`column`&&$4e(e,t)}function t3e(e){let t={tables:[],refs:[],indexes:[],enums:[]};return io(e).forEach(e=>{if(e){switch(e.type){case`tables`:Y4e(e.value,t);break;case`indexes`:q4e(e.value,t);break;case`dbdefault`:X4e(e.value,t);break;case`enums`:Z4e(e.value,t);break;case`comment`:e3e(e.value,t);break;default:break}e.type&&t[e.type]&&t[e.type].push(e.value)}}),t.indexes=null,t}var n3e=o((()=>{id()})),Z9,r3e,Q9,i3e=o((()=>{Z9=u($7()),v9(),G4e(),n9(),n3e(),P9(),r3e=Z9.default.createLanguage({Statements:e=>t9.then(e.Seperator).then(Z9.default.sepBy(e.StatementTypes,e.Seperator)).skip(e.Seperator).map(t3e),StatementTypes:e=>Z9.default.alt(w4e,N4e,y4e,U4e,e.IgnoredStatementTypes),IgnoredStatementTypes:e=>Z9.default.seq(e.IgnoredStatementSyntax,E9),IgnoredStatementSyntax:e=>Z9.default.alt(e.IgnoredDDLSyntax,e.IgnoredDMLSyntax,e.IgnoredBackupAndRestoreSyntax,e.IgnoredServiceBrokerSyntax,e.IgnoredPermissionSyntax,l0e,w0e,u0e,R0e),IgnoredDDLSyntax:e=>Z9.default.alt(e.KeywordCreateWithoutTable,e.KeywordAlterWithoutTable,L1e,d9,I0e,p0e,m0e),IgnoredDMLSyntax:()=>Z9.default.alt(_0e,v0e,y0e,b0e,x0e,L0e),IgnoredServiceBrokerSyntax:()=>Z9.default.alt(j0e,G1e,N0e,P0e,F0e),IgnoredPermissionSyntax:()=>Z9.default.alt(T0e,E0e,O0e,k0e,A0e),IgnoredBackupAndRestoreSyntax:()=>Z9.default.alt(S0e,C0e),KeywordCreateWithoutTable:()=>u9.notFollowedBy(l9),KeywordAlterWithoutTable:()=>c0e.notFollowedBy(l9),Seperator:()=>Z9.default.alt(_9,f9,Z9.default.seq(_9,f9)).many()}),Q9=r3e.Statements})),a3e=c({default:()=>o3e},1),o3e,s3e=o((()=>{i3e(),Q9.parseWithPegError=function(e){try{return Q9.tryParse(e)}catch(t){let n={name:`SyntaxError`};console.error(t),n.location={},n.location.start=t.result.index,n.found=e[n.location.start.offset];let r=t.result.expected.pop();throw n.message=`Expected ${`${t.result.expected.join(`, `)}, or ${r}`} but "${n.found}" found.`,n}},o3e=Q9})),c3e=s(((e,t)=>{t.exports=(s3e(),d(a3e))})),l3e=u(r1e()),u3e=u(i1e()),d3e=u(a1e()),f3e=u(o1e()),p3e=u(c3e()),m3e=class e{constructor(e){this.DBMLCompiler=e||new lme}static parseJSONToDatabase(e){return new Bv(e)}static parseMySQLToJSONv2(e){return X7(e,`mysql`)}static parseMySQLToJSON(e){return l3e.default.parse(e)}static parsePostgresToJSONv2(e){return X7(e,`postgres`)}static parsePostgresToJSON(e){return u3e.default.parse(e)}static parseDBMLToJSONv2(e,t){let n=t||new lme;n.setSource(e);let r=n.parse.errors().map(e=>({message:e.diagnostic,location:{start:{line:e.nodeOrToken.startPos.line+1,column:e.nodeOrToken.startPos.column+1},end:{line:e.nodeOrToken.endPos.line+1,column:e.nodeOrToken.endPos.column+1}},code:e.code}));if(r.length>0)throw W7.create(r);return n.parse.rawDb()}static parseDBMLToJSON(e){return d3e.default.parse(e)}static parseSchemaRbToJSON(e){return f3e.default.parse(e)}static parseMSSQLToJSON(e){return p3e.default.parseWithPegError(e)}static parseMSSQLToJSONv2(e){return X7(e,`mssql`)}static parseSnowflakeToJSON(e){return X7(e,`snowflake`)}static parseOracleToJSON(e){return X7(e,`oracle`)}static parse(t,n){return new e().parse(t,n)}parse(t,n){try{let r={};switch(n){case`mysql`:r=e.parseMySQLToJSONv2(t);break;case`mysqlLegacy`:r=e.parseMySQLToJSON(t);break;case`postgres`:r=e.parsePostgresToJSONv2(t);break;case`snowflake`:r=e.parseSnowflakeToJSON(t);break;case`postgresLegacy`:r=e.parsePostgresToJSON(t);break;case`dbml`:r=e.parseDBMLToJSON(t);break;case`dbmlv2`:r=e.parseDBMLToJSONv2(t,this.DBMLCompiler);break;case`schemarb`:r=e.parseSchemaRbToJSON(t);break;case`mssqlLegacy`:r=e.parseMSSQLToJSON(t);break;case`mssql`:r=e.parseMSSQLToJSONv2(t);break;case`oracle`:r=e.parseOracleToJSON(t);break;case`json`:r=typeof t==`object`?t:JSON.parse(t);break;default:break}return e.parseJSONToDatabase(r)}catch(e){throw W7.create(e)}}},h3e=m3e;function g3e(e,t,n={isNormalized:!0,includeRecords:!0}){let r=_3e(n),i=new h3e().parse(e,`dbmlv2`);return $9.export(i.normalize(),t,r)}function _3e(e={}){if(typeof e==`boolean`)return{isNormalized:e,includeRecords:!0};let{isNormalized:t=!0,includeRecords:n=!0}=e;return{isNormalized:t,includeRecords:n}}var v3e={export:g3e},y3e=class{static export(e,t,n={isNormalized:!0,includeRecords:!0}){let{isNormalized:r,includeRecords:i}=_3e(n),a=e instanceof Bv?e.normalize():e,o=``;switch(t){case`dbml`:o=uve.export(a,{includeRecords:i});break;case`mysql`:o=fve.export(a);break;case`postgres`:o=_ve.export(a);break;case`json`:o=Xve.export(e,{isNormalized:r});break;case`mssql`:o=Qve.export(a);break;case`oracle`:o=eye.export(a);break;default:break}return o}},$9=y3e,b3e=e=>new Bv(e),x3e=e=>e.map(e=>{let{name:t,endpoints:n,onDelete:r,onUpdate:i}=e;return new UTe({name:t,endpoints:n.map(e=>new ck(e)),onDelete:r,onUpdate:i}).toJSON()}),S3e=e=>e.map(e=>{let{name:t,schemaName:n,values:r}=e;return new lk({name:t,schemaName:n,values:r})}),C3e=(e,t)=>e.map(e=>{let n=t[e.name]||{};return new ok({name:e.name,type:e.type,dbdefault:e.dbdefault,not_null:e.not_null,increment:e.increment,pk:n.pk||e.pk,unique:n.unique||e.unique,note:e.note,checks:n.checks})}),w3e=e=>e.map(e=>{let{name:t,unique:n,pk:r,type:i,columns:a}=e;return new ak({name:t,unique:n,pk:r,type:i,columns:a})}),T3e=(e,t,n,r,i)=>e.map(e=>{let{name:a,schemaName:o,note:s}=e,c=o?`${o}.${a}`:`${a}`,l=i[c]||{};return new sk({name:a,schemaName:o,fields:C3e(t[c],l),indexes:w3e(n[c]||[]),note:s,checks:r[c]})}),E3e=e=>{let{tables:t,fields:n,indexes:r,refs:i,enums:a,tableConstraints:o,checks:s}=e;try{let e=T3e(t,n,r,s,o),c=S3e(a);return b3e({schemas:[],tables:e,refs:x3e(i),enums:c,tableGroups:[],aliases:[],project:{}})}catch(e){throw Error(e)}};function D3e(e,t,n={includeRecords:!0}){let{includeRecords:r=!0}=n,i=new h3e().parse(e,t);return $9.export(i.normalize(),`dbml`,{includeRecords:r})}function O3e(e){let t=E3e(e);return $9.export(t.normalize(),`dbml`)}var k3e={import:D3e,generateDbml:O3e};function A3e(e,t,n){let r=new lme;return r.setSource(n),r.renameTable(e,t)}const j3e=`6.6.0`,M3e=`6.6.0`;exports.CompilerError=W7,exports.ModelExporter=$9,exports.Parser=h3e,exports.VERSION=`6.6.0`,exports.addDoubleQuoteIfNeeded=Yg,exports.exporter=v3e,exports.formatRecordValue=$fe,exports.importer=k3e,exports.isBinaryType=Ch,exports.isBooleanType=xh,exports.isDateTimeType=wh,exports.isFloatType=yh,exports.isIntegerType=vh,exports.isNumericType=bh,exports.isSerialType=Th,exports.isStringType=Sh,exports.renameTable=A3e,exports.tryExtractBoolean=Bg,exports.tryExtractDateTime=Hg,exports.tryExtractEnum=_fe,exports.tryExtractInteger=mfe,exports.tryExtractNumeric=zg,exports.tryExtractString=Vg;