@noormdev/cli 1.0.0-alpha.11 → 1.0.0-alpha.13
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/noorm.js +41 -0
- package/package.json +4 -8
- package/scripts/postinstall.js +105 -56
- package/dist/chunk-CFWFYGBB.js +0 -7
- package/dist/chunk-CTFIMWJ7.js +0 -8
- package/dist/chunk-ERDQ5FIO.js +0 -2
- package/dist/chunk-GGT3S2QA.js +0 -5
- package/dist/chunk-GQBL2JPZ.js +0 -2
- package/dist/chunk-JWRRWEPH.js +0 -9
- package/dist/chunk-KVY4JR2A.js +0 -2
- package/dist/chunk-PJYMXUBP.js +0 -2
- package/dist/chunk-QI5B3GSQ.js +0 -2
- package/dist/chunk-QNPOKMVM.js +0 -208
- package/dist/chunk-UR6MHSHU.js +0 -2
- package/dist/connection-V6HQB5BA.js +0 -2
- package/dist/devtools-YYBWFXMQ.js +0 -8
- package/dist/engine-RYCOAOP4.js +0 -2
- package/dist/esm-74GQLDJV.js +0 -3
- package/dist/index.js +0 -3126
- package/dist/mssql-Y7W7F4UH.js +0 -2
- package/dist/mysql-EEPNIS5Q.js +0 -2
- package/dist/mysql2-GYI2HTEE.js +0 -3008
- package/dist/open-NGBTRDPN.js +0 -3
- package/dist/postgres-7E352BHM.js +0 -2
- package/dist/sqlite-KSGG7IKM.js +0 -2
- package/dist/storage-YJUXROPC.js +0 -2
- package/dist/tarn-LSH7NLRE.js +0 -2
- package/dist/tedious-7M6OXIVA.js +0 -192
package/dist/chunk-QI5B3GSQ.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
function M(r){return typeof r>"u"||r===void 0}function p(r){return typeof r=="string"}function pe(r){return typeof r=="number"}function ze(r){return typeof r=="boolean"}function Ie(r){return r===null}function ko(r){return r instanceof Date}function Ue(r){return typeof r=="bigint"}function Co(r){return typeof Buffer<"u"&&Buffer.isBuffer(r)}function x(r){return typeof r=="function"}function X(r){return typeof r=="object"&&r!==null}function o(r){return Object.freeze(r)}function Re(r){return C(r)?r:[r]}function C(r){return Array.isArray(r)}function Eo(r){return r}var nt=new Set;function le(r){nt.has(r)||(nt.add(r),console.log(r))}var it=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function st(r){let e="";for(let t=0;t<r;++t)e+=Xt();return e}function Xt(){return it[~~(Math.random()*it.length)]}function w(){return new Wr}var Wr=class{#e;get queryId(){return this.#e===void 0&&(this.#e=st(8)),this.#e}};var g=o({is(r){return r.kind==="AliasNode"},create(r,e){return o({kind:"AliasNode",node:r,alias:e})}});var u=o({is(r){return r.kind==="IdentifierNode"},create(r){return o({kind:"IdentifierNode",name:r})}});var T=o({is(r){return r.kind==="AndNode"},create(r,e){return o({kind:"AndNode",left:r,right:e})}});var P=o({is(r){return r.kind==="OrNode"},create(r,e){return o({kind:"OrNode",left:r,right:e})}});var Ve=o({is(r){return r.kind==="OnNode"},create(r){return o({kind:"OnNode",on:r})},cloneWithOperation(r,e,t){return o({...r,on:e==="And"?T.create(r.on,t):P.create(r.on,t)})}});var Q=o({is(r){return r.kind==="JoinNode"},create(r,e){return o({kind:"JoinNode",joinType:r,table:e,on:void 0})},createWithOn(r,e,t){return o({kind:"JoinNode",joinType:r,table:e,on:Ve.create(t)})},cloneWithOn(r,e){return o({...r,on:r.on?Ve.cloneWithOperation(r.on,"And",e):Ve.create(e)})}});var Je=o({is(r){return r.kind==="ListNode"},create(r){return o({kind:"ListNode",items:o(r)})}});var $e=class{nodeStack=[];#e=o({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this)});transformNode(e,t){if(!e)return e;this.nodeStack.push(e);let n=this.transformNodeImpl(e,t);return this.nodeStack.pop(),o(n)}transformNodeImpl(e,t){return this.#e[e.kind](e,t)}transformNodeList(e,t){return e&&o(e.map(n=>this.transformNode(n,t)))}transformSelectQuery(e,t){return{kind:"SelectQueryNode",from:this.transformNode(e.from,t),selections:this.transformNodeList(e.selections,t),distinctOn:this.transformNodeList(e.distinctOn,t),joins:this.transformNodeList(e.joins,t),groupBy:this.transformNode(e.groupBy,t),orderBy:this.transformNode(e.orderBy,t),where:this.transformNode(e.where,t),frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),limit:this.transformNode(e.limit,t),offset:this.transformNode(e.offset,t),with:this.transformNode(e.with,t),having:this.transformNode(e.having,t),explain:this.transformNode(e.explain,t),setOperations:this.transformNodeList(e.setOperations,t),fetch:this.transformNode(e.fetch,t),top:this.transformNode(e.top,t)}}transformSelection(e,t){return{kind:"SelectionNode",selection:this.transformNode(e.selection,t)}}transformColumn(e,t){return{kind:"ColumnNode",column:this.transformNode(e.column,t)}}transformAlias(e,t){return{kind:"AliasNode",node:this.transformNode(e.node,t),alias:this.transformNode(e.alias,t)}}transformTable(e,t){return{kind:"TableNode",table:this.transformNode(e.table,t)}}transformFrom(e,t){return{kind:"FromNode",froms:this.transformNodeList(e.froms,t)}}transformReference(e,t){return{kind:"ReferenceNode",column:this.transformNode(e.column,t),table:this.transformNode(e.table,t)}}transformAnd(e,t){return{kind:"AndNode",left:this.transformNode(e.left,t),right:this.transformNode(e.right,t)}}transformOr(e,t){return{kind:"OrNode",left:this.transformNode(e.left,t),right:this.transformNode(e.right,t)}}transformValueList(e,t){return{kind:"ValueListNode",values:this.transformNodeList(e.values,t)}}transformParens(e,t){return{kind:"ParensNode",node:this.transformNode(e.node,t)}}transformJoin(e,t){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,t),on:this.transformNode(e.on,t)}}transformRaw(e,t){return{kind:"RawNode",sqlFragments:o([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,t)}}transformWhere(e,t){return{kind:"WhereNode",where:this.transformNode(e.where,t)}}transformInsertQuery(e,t){return{kind:"InsertQueryNode",into:this.transformNode(e.into,t),columns:this.transformNodeList(e.columns,t),values:this.transformNode(e.values,t),returning:this.transformNode(e.returning,t),onConflict:this.transformNode(e.onConflict,t),onDuplicateKey:this.transformNode(e.onDuplicateKey,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),ignore:e.ignore,orAction:this.transformNode(e.orAction,t),replace:e.replace,explain:this.transformNode(e.explain,t),defaultValues:e.defaultValues,top:this.transformNode(e.top,t),output:this.transformNode(e.output,t)}}transformValues(e,t){return{kind:"ValuesNode",values:this.transformNodeList(e.values,t)}}transformDeleteQuery(e,t){return{kind:"DeleteQueryNode",from:this.transformNode(e.from,t),using:this.transformNode(e.using,t),joins:this.transformNodeList(e.joins,t),where:this.transformNode(e.where,t),returning:this.transformNode(e.returning,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),orderBy:this.transformNode(e.orderBy,t),limit:this.transformNode(e.limit,t),explain:this.transformNode(e.explain,t),top:this.transformNode(e.top,t),output:this.transformNode(e.output,t)}}transformReturning(e,t){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections,t)}}transformCreateTable(e,t){return{kind:"CreateTableNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),constraints:this.transformNodeList(e.constraints,t),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),selectQuery:this.transformNode(e.selectQuery,t)}}transformColumnDefinition(e,t){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column,t),dataType:this.transformNode(e.dataType,t),references:this.transformNode(e.references,t),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,t),check:this.transformNode(e.check,t),generated:this.transformNode(e.generated,t),frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e,t){return{kind:"AddColumnNode",column:this.transformNode(e.column,t)}}transformDropTable(e,t){return{kind:"DropTableNode",table:this.transformNode(e.table,t),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e,t){return{kind:"OrderByNode",items:this.transformNodeList(e.items,t)}}transformOrderByItem(e,t){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,t),direction:this.transformNode(e.direction,t),collation:this.transformNode(e.collation,t),nulls:e.nulls}}transformGroupBy(e,t){return{kind:"GroupByNode",items:this.transformNodeList(e.items,t)}}transformGroupByItem(e,t){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,t)}}transformUpdateQuery(e,t){return{kind:"UpdateQueryNode",table:this.transformNode(e.table,t),from:this.transformNode(e.from,t),joins:this.transformNodeList(e.joins,t),where:this.transformNode(e.where,t),updates:this.transformNodeList(e.updates,t),returning:this.transformNode(e.returning,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),explain:this.transformNode(e.explain,t),limit:this.transformNode(e.limit,t),top:this.transformNode(e.top,t),output:this.transformNode(e.output,t),orderBy:this.transformNode(e.orderBy,t)}}transformColumnUpdate(e,t){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column,t),value:this.transformNode(e.value,t)}}transformLimit(e,t){return{kind:"LimitNode",limit:this.transformNode(e.limit,t)}}transformOffset(e,t){return{kind:"OffsetNode",offset:this.transformNode(e.offset,t)}}transformOnConflict(e,t){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns,t),constraint:this.transformNode(e.constraint,t),indexExpression:this.transformNode(e.indexExpression,t),indexWhere:this.transformNode(e.indexWhere,t),updates:this.transformNodeList(e.updates,t),updateWhere:this.transformNode(e.updateWhere,t),doNothing:e.doNothing}}transformOnDuplicateKey(e,t){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,t)}}transformCreateIndex(e,t){return{kind:"CreateIndexNode",name:this.transformNode(e.name,t),table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),unique:e.unique,using:this.transformNode(e.using,t),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,t),nullsNotDistinct:e.nullsNotDistinct}}transformList(e,t){return{kind:"ListNode",items:this.transformNodeList(e.items,t)}}transformDropIndex(e,t){return{kind:"DropIndexNode",name:this.transformNode(e.name,t),table:this.transformNode(e.table,t),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e,t){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,t),name:this.transformNode(e.name,t),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformUniqueConstraint(e,t){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,t),name:this.transformNode(e.name,t),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformForeignKeyConstraint(e,t){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,t),references:this.transformNode(e.references,t),name:this.transformNode(e.name,t),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformSetOperation(e,t){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,t),all:e.all}}transformReferences(e,t){return{kind:"ReferencesNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e,t){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression,t),name:this.transformNode(e.name,t)}}transformWith(e,t){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions,t),recursive:e.recursive}}transformCommonTableExpression(e,t){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name,t),materialized:e.materialized,expression:this.transformNode(e.expression,t)}}transformCommonTableExpressionName(e,t){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t)}}transformHaving(e,t){return{kind:"HavingNode",having:this.transformNode(e.having,t)}}transformCreateSchema(e,t){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema,t),ifNotExists:e.ifNotExists}}transformDropSchema(e,t){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema,t),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e,t){return{kind:"AlterTableNode",table:this.transformNode(e.table,t),renameTo:this.transformNode(e.renameTo,t),setSchema:this.transformNode(e.setSchema,t),columnAlterations:this.transformNodeList(e.columnAlterations,t),addConstraint:this.transformNode(e.addConstraint,t),dropConstraint:this.transformNode(e.dropConstraint,t),renameConstraint:this.transformNode(e.renameConstraint,t),addIndex:this.transformNode(e.addIndex,t),dropIndex:this.transformNode(e.dropIndex,t)}}transformDropColumn(e,t){return{kind:"DropColumnNode",column:this.transformNode(e.column,t)}}transformRenameColumn(e,t){return{kind:"RenameColumnNode",column:this.transformNode(e.column,t),renameTo:this.transformNode(e.renameTo,t)}}transformAlterColumn(e,t){return{kind:"AlterColumnNode",column:this.transformNode(e.column,t),dataType:this.transformNode(e.dataType,t),dataTypeExpression:this.transformNode(e.dataTypeExpression,t),setDefault:this.transformNode(e.setDefault,t),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e,t){return{kind:"ModifyColumnNode",column:this.transformNode(e.column,t)}}transformAddConstraint(e,t){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,t)}}transformDropConstraint(e,t){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,t),ifExists:e.ifExists,modifier:e.modifier}}transformRenameConstraint(e,t){return{kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,t),newName:this.transformNode(e.newName,t)}}transformCreateView(e,t){return{kind:"CreateViewNode",name:this.transformNode(e.name,t),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,t),as:this.transformNode(e.as,t)}}transformRefreshMaterializedView(e,t){return{kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,t),concurrently:e.concurrently,withNoData:e.withNoData}}transformDropView(e,t){return{kind:"DropViewNode",name:this.transformNode(e.name,t),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e,t){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,t)}}transformDefaultValue(e,t){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,t)}}transformOn(e,t){return{kind:"OnNode",on:this.transformNode(e.on,t)}}transformSelectModifier(e,t){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,t),of:this.transformNodeList(e.of,t)}}transformCreateType(e,t){return{kind:"CreateTypeNode",name:this.transformNode(e.name,t),enum:this.transformNode(e.enum,t)}}transformDropType(e,t){return{kind:"DropTypeNode",name:this.transformNode(e.name,t),ifExists:e.ifExists}}transformExplain(e,t){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,t)}}transformSchemableIdentifier(e,t){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,t),identifier:this.transformNode(e.identifier,t)}}transformAggregateFunction(e,t){return{kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,t),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,t),withinGroup:this.transformNode(e.withinGroup,t),filter:this.transformNode(e.filter,t),over:this.transformNode(e.over,t)}}transformOver(e,t){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy,t),partitionBy:this.transformNode(e.partitionBy,t)}}transformPartitionBy(e,t){return{kind:"PartitionByNode",items:this.transformNodeList(e.items,t)}}transformPartitionByItem(e,t){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,t)}}transformBinaryOperation(e,t){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,t),operator:this.transformNode(e.operator,t),rightOperand:this.transformNode(e.rightOperand,t)}}transformUnaryOperation(e,t){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator,t),operand:this.transformNode(e.operand,t)}}transformUsing(e,t){return{kind:"UsingNode",tables:this.transformNodeList(e.tables,t)}}transformFunction(e,t){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,t)}}transformCase(e,t){return{kind:"CaseNode",value:this.transformNode(e.value,t),when:this.transformNodeList(e.when,t),else:this.transformNode(e.else,t),isStatement:e.isStatement}}transformWhen(e,t){return{kind:"WhenNode",condition:this.transformNode(e.condition,t),result:this.transformNode(e.result,t)}}transformJSONReference(e,t){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference,t),traversal:this.transformNode(e.traversal,t)}}transformJSONPath(e,t){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,t),pathLegs:this.transformNodeList(e.pathLegs,t)}}transformJSONPathLeg(e,t){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e,t){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,t),values:this.transformNodeList(e.values,t)}}transformTuple(e,t){return{kind:"TupleNode",values:this.transformNodeList(e.values,t)}}transformMergeQuery(e,t){return{kind:"MergeQueryNode",into:this.transformNode(e.into,t),using:this.transformNode(e.using,t),whens:this.transformNodeList(e.whens,t),with:this.transformNode(e.with,t),top:this.transformNode(e.top,t),endModifiers:this.transformNodeList(e.endModifiers,t),output:this.transformNode(e.output,t),returning:this.transformNode(e.returning,t)}}transformMatched(e,t){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e,t){return{kind:"AddIndexNode",name:this.transformNode(e.name,t),columns:this.transformNodeList(e.columns,t),unique:e.unique,using:this.transformNode(e.using,t),ifNotExists:e.ifNotExists}}transformCast(e,t){return{kind:"CastNode",expression:this.transformNode(e.expression,t),dataType:this.transformNode(e.dataType,t)}}transformFetch(e,t){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount,t),modifier:e.modifier}}transformTop(e,t){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e,t){return{kind:"OutputNode",selections:this.transformNodeList(e.selections,t)}}transformDataType(e,t){return e}transformSelectAll(e,t){return e}transformIdentifier(e,t){return e}transformValue(e,t){return e}transformPrimitiveValueList(e,t){return e}transformOperator(e,t){return e}transformDefaultInsertValue(e,t){return e}transformOrAction(e,t){return e}transformCollate(e,t){return e}};var Ae=o({is(r){return r.kind==="SchemableIdentifierNode"},create(r){return o({kind:"SchemableIdentifierNode",identifier:u.create(r)})},createWithSchema(r,e){return o({kind:"SchemableIdentifierNode",schema:u.create(r),identifier:u.create(e)})}});var B=o({is(r){return r.kind==="TableNode"},create(r){return o({kind:"TableNode",table:Ae.create(r)})},createWithSchema(r,e){return o({kind:"TableNode",table:Ae.createWithSchema(r,e)})}});var Te=o({is(r){return r.kind==="UsingNode"},create(r){return o({kind:"UsingNode",tables:o(r)})},cloneWithTables(r,e){return o({...r,tables:o([...r.tables,...e])})}});var Zt=o({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,RefreshMaterializedViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),_t={json_agg:!0,to_json:!0},Ge=class extends $e{#e;#r=new Set;#t=new Set;constructor(e){super(),this.#e=e}transformNodeImpl(e,t){if(!this.#s(e))return super.transformNodeImpl(e,t);let n=this.#u(e);for(let A of n)this.#t.add(A);let i=this.#a(e);for(let A of i)this.#r.add(A);let m=super.transformNodeImpl(e,t);for(let A of i)this.#r.delete(A);for(let A of n)this.#t.delete(A);return m}transformSchemableIdentifier(e,t){let n=super.transformSchemableIdentifier(e,t);return n.schema||!this.#r.has(e.identifier.name)?n:{...n,schema:u.create(this.#e)}}transformReferences(e,t){let n=super.transformReferences(e,t);return n.table.table.schema?n:{...n,table:B.createWithSchema(this.#e,n.table.table.identifier.name)}}transformAggregateFunction(e,t){return{...super.transformAggregateFunction({...e,aggregated:[]},t),aggregated:this.#n(e,t,"aggregated")}}transformFunction(e,t){return{...super.transformFunction({...e,arguments:[]},t),arguments:this.#n(e,t,"arguments")}}transformSelectModifier(e,t){return{...super.transformSelectModifier({...e,of:void 0},t),of:e.of?.map(n=>B.is(n)&&!n.table.schema?{...n,table:this.transformIdentifier(n.table.identifier,t)}:this.transformNode(n,t))}}#n(e,t,n){return _t[e.func]?e[n].map(i=>!B.is(i)||i.table.schema?this.transformNode(i,t):{...i,table:this.transformIdentifier(i.table.identifier,t)}):this.transformNodeList(e[n],t)}#s(e){return e.kind in Zt}#a(e){let t=new Set;if("name"in e&&e.name&&Ae.is(e.name)&&this.#i(e.name,t),"from"in e&&e.from)for(let n of e.from.froms)this.#o(n,t);if("into"in e&&e.into&&this.#o(e.into,t),"table"in e&&e.table&&this.#o(e.table,t),"joins"in e&&e.joins)for(let n of e.joins)this.#o(n.table,t);return"using"in e&&e.using&&(Q.is(e.using)?this.#o(e.using.table,t):this.#o(e.using,t)),t}#u(e){let t=new Set;return"with"in e&&e.with&&this.#d(e.with,t),t}#o(e,t){if(B.is(e))return this.#i(e.table,t);if(g.is(e)&&B.is(e.node))return this.#i(e.node.table,t);if(Je.is(e)){for(let n of e.items)this.#o(n,t);return}if(Te.is(e)){for(let n of e.tables)this.#o(n,t);return}}#i(e,t){let n=e.identifier.name;!this.#r.has(n)&&!this.#t.has(n)&&t.add(n)}#d(e,t){for(let n of e.expressions){let i=n.name.table.table.identifier.name;this.#t.has(i)||t.add(i)}}};var Ne=class{#e;constructor(e){this.#e=new Ge(e)}transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}};var Be=class{#e;#r;#t;constructor(){this.#e=new Promise((e,t)=>{this.#t=t,this.#r=e})}get promise(){return this.#e}resolve=e=>{this.#r&&this.#r(e)};reject=e=>{this.#t&&this.#t(e)}};async function at(r){let e=new Be,t=new Be;return r.provideConnection(async n=>(e.resolve(n),await t.promise)).catch(n=>e.reject(n)),o({connection:await e.promise,release:t.resolve})}var G=o({is(r){return r.kind==="SelectModifierNode"},create(r,e){return o({kind:"SelectModifierNode",modifier:r,of:e})},createWithExpression(r){return o({kind:"SelectModifierNode",rawModifier:r})}});var oe=o({is(r){return r.kind==="BinaryOperationNode"},create(r,e,t){return o({kind:"BinaryOperationNode",leftOperand:r,operator:e,rightOperand:t})}});function f(r){return X(r)&&x(r.toOperationNode)}var eo=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from"],ro=["+","-","*","/","%","^","&","|","#","<<",">>"],ut=["->","->>"],to=[...eo,...ro,"&&","||"],oo=["exists","not exists"],no=["not","-",...oo],dt=[...to,...ut,...no,"between","between symmetric"],v=o({is(r){return r.kind==="OperatorNode"},create(r){return o({kind:"OperatorNode",operator:r})}});function Sr(r){return p(r)&&ut.includes(r)}var E=o({is(r){return r.kind==="ColumnNode"},create(r){return o({kind:"ColumnNode",column:u.create(r)})}});var je=o({is(r){return r.kind==="SelectAllNode"},create(){return o({kind:"SelectAllNode"})}});var ye=o({is(r){return r.kind==="ReferenceNode"},create(r,e){return o({kind:"ReferenceNode",table:e,column:r})},createSelectAll(r){return o({kind:"ReferenceNode",table:r,column:je.create()})}});function Ke(r){return X(r)&&"expressionType"in r&&f(r)}function mt(r){return X(r)&&"expression"in r&&p(r.alias)&&f(r)}var me=o({is(r){return r.kind==="FromNode"},create(r){return o({kind:"FromNode",froms:o(r)})},cloneWithFroms(r,e){return o({...r,froms:o([...r.froms,...e])})}});var br=o({is(r){return r.kind==="GroupByNode"},create(r){return o({kind:"GroupByNode",items:o(r)})},cloneWithItems(r,e){return o({...r,items:o([...r.items,...e])})}});var kr=o({is(r){return r.kind==="HavingNode"},create(r){return o({kind:"HavingNode",having:r})},cloneWithOperation(r,e,t){return o({...r,having:e==="And"?T.create(r.having,t):P.create(r.having,t)})}});var l=o({is(r){return r.kind==="InsertQueryNode"},create(r,e,t){return o({kind:"InsertQueryNode",into:r,...e&&{with:e},replace:t})},createWithoutInto(){return o({kind:"InsertQueryNode"})},cloneWith(r,e){return o({...r,...e})}});var j=o({is(r){return r.kind==="UpdateQueryNode"},create(r,e){return o({kind:"UpdateQueryNode",table:r.length===1?r[0]:Je.create(r),...e&&{with:e}})},createWithoutTable(){return o({kind:"UpdateQueryNode"})},cloneWithFromItems(r,e){return o({...r,from:r.from?me.cloneWithFroms(r.from,e):me.create(e)})},cloneWithUpdates(r,e){return o({...r,updates:r.updates?o([...r.updates,...e]):e})},cloneWithLimit(r,e){return o({...r,limit:e})}});var ne=o({is(r){return r.kind==="DeleteQueryNode"},create(r,e){return o({kind:"DeleteQueryNode",from:me.create(r),...e&&{with:e}})},cloneWithOrderByItems:(r,e)=>s.cloneWithOrderByItems(r,e),cloneWithoutOrderBy:r=>s.cloneWithoutOrderBy(r),cloneWithLimit(r,e){return o({...r,limit:e})},cloneWithoutLimit(r){return o({...r,limit:void 0})},cloneWithUsing(r,e){return o({...r,using:r.using!==void 0?Te.cloneWithTables(r.using,e):Te.create(e)})}});var b=o({is(r){return r.kind==="WhereNode"},create(r){return o({kind:"WhereNode",where:r})},cloneWithOperation(r,e,t){return o({...r,where:e==="And"?T.create(r.where,t):P.create(r.where,t)})}});var Cr=o({is(r){return r.kind==="ReturningNode"},create(r){return o({kind:"ReturningNode",selections:o(r)})},cloneWithSelections(r,e){return o({...r,selections:r.selections?o([...r.selections,...e]):o(e)})}});var ct=o({is(r){return r.kind==="ExplainNode"},create(r,e){return o({kind:"ExplainNode",format:r,options:e})}});var Z=o({is(r){return r.kind==="WhenNode"},create(r){return o({kind:"WhenNode",condition:r})},cloneWithResult(r,e){return o({...r,result:e})}});var q=o({is(r){return r.kind==="MergeQueryNode"},create(r,e){return o({kind:"MergeQueryNode",into:r,...e&&{with:e}})},cloneWithUsing(r,e){return o({...r,using:e})},cloneWithWhen(r,e){return o({...r,whens:r.whens?o([...r.whens,e]):o([e])})},cloneWithThen(r,e){return o({...r,whens:r.whens?o([...r.whens.slice(0,-1),Z.cloneWithResult(r.whens[r.whens.length-1],e)]):void 0})}});var Er=o({is(r){return r.kind==="OutputNode"},create(r){return o({kind:"OutputNode",selections:o(r)})},cloneWithSelections(r,e){return o({...r,selections:r.selections?o([...r.selections,...e]):o(e)})}});var _=o({is(r){return r.kind==="OrderByNode"},create(r){return o({kind:"OrderByNode",items:o([...r])})},cloneWithItems(r,e){return o({...r,items:o([...r.items,...e])})}});var s=o({is(r){return d.is(r)||l.is(r)||j.is(r)||ne.is(r)||q.is(r)},cloneWithEndModifier(r,e){return o({...r,endModifiers:r.endModifiers?o([...r.endModifiers,e]):o([e])})},cloneWithWhere(r,e){return o({...r,where:r.where?b.cloneWithOperation(r.where,"And",e):b.create(e)})},cloneWithJoin(r,e){return o({...r,joins:r.joins?o([...r.joins,e]):o([e])})},cloneWithReturning(r,e){return o({...r,returning:r.returning?Cr.cloneWithSelections(r.returning,e):Cr.create(e)})},cloneWithoutReturning(r){return o({...r,returning:void 0})},cloneWithoutWhere(r){return o({...r,where:void 0})},cloneWithExplain(r,e,t){return o({...r,explain:ct.create(e,t?.toOperationNode())})},cloneWithTop(r,e){return o({...r,top:e})},cloneWithOutput(r,e){return o({...r,output:r.output?Er.cloneWithSelections(r.output,e):Er.create(e)})},cloneWithOrderByItems(r,e){return o({...r,orderBy:r.orderBy?_.cloneWithItems(r.orderBy,e):_.create(e)})},cloneWithoutOrderBy(r){return o({...r,orderBy:void 0})}});var d=o({is(r){return r.kind==="SelectQueryNode"},create(r){return o({kind:"SelectQueryNode",...r&&{with:r}})},createFrom(r,e){return o({kind:"SelectQueryNode",from:me.create(r),...e&&{with:e}})},cloneWithSelections(r,e){return o({...r,selections:r.selections?o([...r.selections,...e]):o(e)})},cloneWithDistinctOn(r,e){return o({...r,distinctOn:r.distinctOn?o([...r.distinctOn,...e]):o(e)})},cloneWithFrontModifier(r,e){return o({...r,frontModifiers:r.frontModifiers?o([...r.frontModifiers,e]):o([e])})},cloneWithOrderByItems:(r,e)=>s.cloneWithOrderByItems(r,e),cloneWithGroupByItems(r,e){return o({...r,groupBy:r.groupBy?br.cloneWithItems(r.groupBy,e):br.create(e)})},cloneWithLimit(r,e){return o({...r,limit:e})},cloneWithOffset(r,e){return o({...r,offset:e})},cloneWithFetch(r,e){return o({...r,fetch:e})},cloneWithHaving(r,e){return o({...r,having:r.having?kr.cloneWithOperation(r.having,"And",e):kr.create(e)})},cloneWithSetOperations(r,e){return o({...r,setOperations:r.setOperations?o([...r.setOperations,...e]):o([...e])})},cloneWithoutSelections(r){return o({...r,selections:[]})},cloneWithoutLimit(r){return o({...r,limit:void 0})},cloneWithoutOffset(r){return o({...r,offset:void 0})},cloneWithoutOrderBy:r=>s.cloneWithoutOrderBy(r),cloneWithoutGroupBy(r){return o({...r,groupBy:void 0})}});var ht=class{#e;get table(){return this.#e}constructor(e){this.#e=e}as(e){return new Rr(this.#e,e)}},Rr=class{#e;#r;get table(){return this.#e}get alias(){return this.#r}constructor(e,t){this.#e=e,this.#r=t}toOperationNode(){return g.create(N(this.#e),u.create(this.#r))}};function ft(r){return X(r)&&f(r)&&p(r.table)&&p(r.alias)}function z(r){return C(r)?r.map(e=>ce(e)):[ce(r)]}function ce(r){return p(r)?Ar(r):ft(r)?r.toOperationNode():He(r)}function Ar(r){let e=" as ";if(r.includes(e)){let[t,n]=r.split(e).map(pt);return g.create(N(t),u.create(n))}else return N(r)}function N(r){if(r.includes(".")){let[t,n]=r.split(".").map(pt);return B.createWithSchema(t,n)}else return B.create(r)}function pt(r){return r.trim()}var ie=o({is(r){return r.kind==="ParensNode"},create(r){return o({kind:"ParensNode",node:r})}});var a=class r{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new qe(this,e)}or(...e){return new Tr(P.create(this.#e,h(e)))}and(...e){return new Br(T.create(this.#e,h(e)))}$castTo(){return new r(this.#e)}$notNull(){return new r(this.#e)}toOperationNode(){return this.#e}},qe=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return g.create(this.#e.toOperationNode(),f(this.#r)?this.#r.toOperationNode():u.create(this.#r))}},Tr=class r{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new qe(this,e)}or(...e){return new r(P.create(this.#e,h(e)))}$castTo(){return new r(this.#e)}toOperationNode(){return ie.create(this.#e)}},Br=class r{#e;constructor(e){this.#e=e}get expressionType(){}as(e){return new qe(this,e)}and(...e){return new r(T.create(this.#e,h(e)))}$castTo(){return new r(this.#e)}toOperationNode(){return ie.create(this.#e)}};var K=o({is(r){return r.kind==="AggregateFunctionNode"},create(r,e=[]){return o({kind:"AggregateFunctionNode",func:r,aggregated:e})},cloneWithDistinct(r){return o({...r,distinct:!0})},cloneWithOrderBy(r,e,t=!1){let n=t?"withinGroup":"orderBy";return o({...r,[n]:r[n]?_.cloneWithItems(r[n],e):_.create(e)})},cloneWithFilter(r,e){return o({...r,filter:r.filter?b.cloneWithOperation(r.filter,"And",e):b.create(e)})},cloneWithOrFilter(r,e){return o({...r,filter:r.filter?b.cloneWithOperation(r.filter,"Or",e):b.create(e)})},cloneWithOver(r,e){return o({...r,over:e})}});var qr=o({is(r){return r.kind==="FunctionNode"},create(r,e){return o({kind:"FunctionNode",func:r,arguments:e})}});var we=o({is(r){return r.kind==="SelectionNode"},create(r){return o({kind:"SelectionNode",selection:r})},createSelectAll(){return o({kind:"SelectionNode",selection:je.create()})},createSelectAllFromTable(r){return o({kind:"SelectionNode",selection:ye.createSelectAll(r)})}});var lt=class{#e;get dynamicReference(){return this.#e}get refType(){}constructor(e){this.#e=e}toOperationNode(){return Lr(this.#e)}};function Ye(r){return X(r)&&f(r)&&p(r.dynamicReference)}function O(r){return x(r)?O(r(I())):C(r)?r.map(e=>Nt(e)):[Nt(r)]}function Nt(r){return p(r)?we.create(wt(r)):Ye(r)?we.create(r.toOperationNode()):we.create(He(r))}function W(r){return r?Array.isArray(r)?r.map(yt):[yt(r)]:[we.createSelectAll()]}function yt(r){if(p(r))return we.createSelectAllFromTable(N(r));throw new Error(`invalid value selectAll expression: ${JSON.stringify(r)}`)}var Fr=o({is(r){return r.kind==="PartitionByNode"},create(r){return o({kind:"PartitionByNode",items:o(r)})},cloneWithItems(r,e){return o({...r,items:o([...r.items,...e])})}});var Le=o({is(r){return r.kind==="OverNode"},create(){return o({kind:"OverNode"})},cloneWithOrderByItems(r,e){return o({...r,orderBy:r.orderBy?_.cloneWithItems(r.orderBy,e):_.create(e)})},cloneWithPartitionByItems(r,e){return o({...r,partitionBy:r.partitionBy?Fr.cloneWithItems(r.partitionBy,e):Fr.create(e)})}});var y=o({is(r){return r.kind==="RawNode"},create(r,e){return o({kind:"RawNode",sqlFragments:o(r),parameters:o(e)})},createWithSql(r){return y.create([r],[])},createWithChild(r){return y.create(["",""],[r])},createWithChildren(r){return y.create(new Array(r.length+1).fill(""),r)}});var Xe=class r{#e;constructor(e){this.#e=o(e)}on(...e){return new r({...this.#e,joinNode:Q.cloneWithOn(this.#e.joinNode,h(e))})}onRef(e,t,n){return new r({...this.#e,joinNode:Q.cloneWithOn(this.#e.joinNode,S(e,t,n))})}onTrue(){return new r({...this.#e,joinNode:Q.cloneWithOn(this.#e.joinNode,y.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#e.joinNode}};var U=o({is(r){return r.kind==="OrderByItemNode"},create(r,e){return o({kind:"OrderByItemNode",orderBy:r,direction:e})},cloneWith(r,e){return o({...r,...e})}});var Ot=o({is(r){return r.kind==="CollateNode"},create(r){return o({kind:"CollateNode",collation:u.create(r)})}});var Ze=class r{#e;constructor(e){this.#e=o(e)}desc(){return new r({node:U.cloneWith(this.#e.node,{direction:y.createWithSql("desc")})})}asc(){return new r({node:U.cloneWith(this.#e.node,{direction:y.createWithSql("asc")})})}nullsLast(){return new r({node:U.cloneWith(this.#e.node,{nulls:"last"})})}nullsFirst(){return new r({node:U.cloneWith(this.#e.node,{nulls:"first"})})}collate(e){return new r({node:U.cloneWith(this.#e.node,{collation:Ot.create(e)})})}toOperationNode(){return this.#e.node}};function Mr(r){return r==="asc"||r==="desc"}function L(r){if(r.length===2)return[Dr(r[0],r[1])];if(r.length===1){let[e]=r;return Array.isArray(e)?(le("orderBy(array) is deprecated, use multiple orderBy calls instead."),e.map(t=>Dr(t))):[Dr(e)]}throw new Error(`Invalid number of arguments at order by! expected 1-2, received ${r.length}`)}function Dr(r,e){let t=io(r);if(U.is(t)){if(e)throw new Error("Cannot specify direction twice!");return t}return xt(t,e)}function io(r){if(ee(r))return H(r);if(Ye(r))return r.toOperationNode();let[e,t]=r.split(" ");return t?(le("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),xt(V(e),t)):V(r)}function xt(r,e){if(typeof e=="string"){if(!Mr(e))throw new Error(`Invalid order by direction: ${e}`);return U.create(r,y.createWithSql(e))}if(Ke(e))return le("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),U.create(r,e.toOperationNode());let t=U.create(r);return e?e(new Ze({node:t})).toOperationNode():t}var gt=o({is(r){return r.kind==="PartitionByItemNode"},create(r){return o({kind:"PartitionByItemNode",partitionBy:r})}});function Wt(r){return re(r).map(gt.create)}var _e=class r{#e;constructor(e){this.#e=o(e)}orderBy(...e){return new r({overNode:Le.cloneWithOrderByItems(this.#e.overNode,L(e))})}clearOrderBy(){return new r({overNode:s.cloneWithoutOrderBy(this.#e.overNode)})}partitionBy(e){return new r({overNode:Le.cloneWithPartitionByItems(this.#e.overNode,Wt(e))})}$call(e){return e(this)}toOperationNode(){return this.#e.overNode}};var so=o([]),er=class{#e;constructor(e=so){this.#e=e}get plugins(){return this.#e}transformQuery(e,t){for(let n of this.#e){let i=n.transformQuery({node:e,queryId:t});if(i.kind===e.kind)e=i;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${i.kind}`].join(" "))}return e}async executeQuery(e){return await this.provideConnection(async t=>{let n=await t.executeQuery(e);return"numUpdatedOrDeletedRows"in n&&le("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`."),await this.#r(n,e.queryId)})}async*stream(e,t){let{connection:n,release:i}=await at(this);try{for await(let m of n.streamQuery(e,t))yield await this.#r(m,e.queryId)}finally{i()}}async#r(e,t){for(let n of this.#e)e=await n.transformResult({result:e,queryId:t});return e}};var Pr=class r extends er{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin(e){return new r([...this.plugins,e])}withPlugins(e){return new r([...this.plugins,...e])}withPluginAtFront(e){return new r([e,...this.plugins])}withoutPlugins(){return new r([])}},se=new Pr;function St(){return new rr({executor:se})}function bt(r,e){return new Xe({joinNode:Q.create(r,ce(e))})}function kt(){return new _e({overNode:Le.create()})}var Oe=class r{#e;constructor(e){this.#e=o(e)}get expressionType(){}as(e){return new Qr(this,e)}distinct(){return new r({...this.#e,aggregateFunctionNode:K.cloneWithDistinct(this.#e.aggregateFunctionNode)})}orderBy(...e){return new r({...this.#e,aggregateFunctionNode:s.cloneWithOrderByItems(this.#e.aggregateFunctionNode,L(e))})}clearOrderBy(){return new r({...this.#e,aggregateFunctionNode:s.cloneWithoutOrderBy(this.#e.aggregateFunctionNode)})}withinGroupOrderBy(...e){return new r({...this.#e,aggregateFunctionNode:K.cloneWithOrderBy(this.#e.aggregateFunctionNode,L(e),!0)})}filterWhere(...e){return new r({...this.#e,aggregateFunctionNode:K.cloneWithFilter(this.#e.aggregateFunctionNode,h(e))})}filterWhereRef(e,t,n){return new r({...this.#e,aggregateFunctionNode:K.cloneWithFilter(this.#e.aggregateFunctionNode,S(e,t,n))})}over(e){let t=kt();return new r({...this.#e,aggregateFunctionNode:K.cloneWithOver(this.#e.aggregateFunctionNode,(e?e(t):t).toOperationNode())})}$call(e){return e(this)}$castTo(){return new r(this.#e)}$notNull(){return new r(this.#e)}toOperationNode(){return this.#e.aggregateFunctionNode}},Qr=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return g.create(this.#e.toOperationNode(),u.create(this.#r))}};function Ct(){let r=(t,n)=>new a(qr.create(t,re(n??[]))),e=(t,n)=>new Oe({aggregateFunctionNode:K.create(t,n?re(n):void 0)});return Object.assign(r,{agg:e,avg(t){return e("avg",[t])},coalesce(...t){return r("coalesce",t)},count(t){return e("count",[t])},countAll(t){return new Oe({aggregateFunctionNode:K.create("count",W(t))})},max(t){return e("max",[t])},min(t){return e("min",[t])},sum(t){return e("sum",[t])},any(t){return r("any",[t])},jsonAgg(t){return new Oe({aggregateFunctionNode:K.create("json_agg",[p(t)?N(t):t.toOperationNode()])})},toJson(t){return new a(qr.create("to_json",[p(t)?N(t):t.toOperationNode()]))}})}var Et=o({is(r){return r.kind==="UnaryOperationNode"},create(r,e){return o({kind:"UnaryOperationNode",operator:r,operand:e})}});function Rt(r,e){return Et.create(v.create(r),k(e))}var tr=o({is(r){return r.kind==="PrimitiveValueListNode"},create(r){return o({kind:"PrimitiveValueListNode",values:o([...r])})}});var or=o({is(r){return r.kind==="ValueListNode"},create(r){return o({kind:"ValueListNode",values:o(r)})}});var F=o({is(r){return r.kind==="ValueNode"},create(r){return o({kind:"ValueNode",value:r})},createImmediate(r){return o({kind:"ValueNode",value:r,immediate:!0})}});function At(r){return C(r)?ao(r):c(r)}function c(r){return ee(r)?H(r):F.create(r)}function nr(r){return pe(r)||ze(r)||Ie(r)}function Fe(r){if(!nr(r))throw new Error(`unsafe immediate value ${JSON.stringify(r)}`);return F.createImmediate(r)}function ao(r){return r.some(ee)?or.create(r.map(e=>c(e))):tr.create(r)}var J=o({is(r){return r.kind==="CaseNode"},create(r){return o({kind:"CaseNode",value:r})},cloneWithWhen(r,e){return o({...r,when:o(r.when?[...r.when,e]:[e])})},cloneWithThen(r,e){return o({...r,when:r.when?o([...r.when.slice(0,-1),Z.cloneWithResult(r.when[r.when.length-1],e)]):void 0})},cloneWith(r,e){return o({...r,...e})}});var ir=class{#e;constructor(e){this.#e=o(e)}when(...e){return new sr({...this.#e,node:J.cloneWithWhen(this.#e.node,Z.create(h(e)))})}},sr=class{#e;constructor(e){this.#e=o(e)}then(e){return new vr({...this.#e,node:J.cloneWithThen(this.#e.node,nr(e)?Fe(e):c(e))})}},vr=class{#e;constructor(e){this.#e=o(e)}when(...e){return new sr({...this.#e,node:J.cloneWithWhen(this.#e.node,Z.create(h(e)))})}else(e){return new zr({...this.#e,node:J.cloneWith(this.#e.node,{else:nr(e)?Fe(e):c(e)})})}end(){return new a(J.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new a(J.cloneWith(this.#e.node,{isStatement:!0}))}},zr=class{#e;constructor(e){this.#e=o(e)}end(){return new a(J.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new a(J.cloneWith(this.#e.node,{isStatement:!0}))}};var ar=o({is(r){return r.kind==="JSONOperatorChainNode"},create(r){return o({kind:"JSONOperatorChainNode",operator:r,values:o([])})},cloneWithValue(r,e){return o({...r,values:o([...r.values,e])})}});var Ir=o({is(r){return r.kind==="JSONPathLegNode"},create(r,e){return o({kind:"JSONPathLegNode",type:r,value:e})}});var ae=o({is(r){return r.kind==="JSONPathNode"},create(r){return o({kind:"JSONPathNode",inOperator:r,pathLegs:o([])})},cloneWithLeg(r,e){return o({...r,pathLegs:o([...r.pathLegs,e])})}});var xe=o({is(r){return r.kind==="JSONReferenceNode"},create(r,e){return o({kind:"JSONReferenceNode",reference:r,traversal:e})},cloneWithTraversal(r,e){return o({...r,traversal:e})}});var ge=class{#e;constructor(e){this.#e=e}at(e){return this.#r("ArrayLocation",e)}key(e){return this.#r("Member",e)}#r(e,t){return xe.is(this.#e)?new ur(xe.cloneWithTraversal(this.#e,ae.is(this.#e.traversal)?ae.cloneWithLeg(this.#e.traversal,Ir.create(e,t)):ar.cloneWithValue(this.#e.traversal,F.createImmediate(t)))):new ur(ae.cloneWithLeg(this.#e,Ir.create(e,t)))}},ur=class r extends ge{#e;constructor(e){super(e),this.#e=e}get expressionType(){}as(e){return new Ur(this,e)}$castTo(){return new r(this.#e)}$notNull(){return new r(this.#e)}toOperationNode(){return this.#e}},Ur=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return g.create(this.#e.toOperationNode(),f(this.#r)?this.#r.toOperationNode():u.create(this.#r))}};var Vr=o({is(r){return r.kind==="TupleNode"},create(r){return o({kind:"TupleNode",values:o(r)})}});var uo=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],mo=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],Tt=o({is(r){return r.kind==="DataTypeNode"},create(r){return o({kind:"DataTypeNode",dataType:r})}});function Bt(r){return!!(uo.includes(r)||mo.some(e=>e.test(r)))}function qt(r){if(f(r))return r.toOperationNode();if(Bt(r))return Tt.create(r);throw new Error(`invalid column data type ${JSON.stringify(r)}`)}var Lt=o({is(r){return r.kind==="CastNode"},create(r,e){return o({kind:"CastNode",expression:r,dataType:e})}});function mr(r=se){function e(i,m,A){return new a(dr(i,m,A))}function t(i,m){return new a(Rt(i,m))}let n=Object.assign(e,{fn:void 0,eb:void 0,selectFrom(i){return De({queryId:w(),executor:r,queryNode:d.createFrom(z(i))})},case(i){return new ir({node:J.create(M(i)?void 0:k(i))})},ref(i,m){return M(m)?new a(V(i)):new ge(Ft(i,m))},jsonPath(){return new ge(ae.create())},table(i){return new a(N(i))},val(i){return new a(c(i))},refTuple(...i){return new a(Vr.create(i.map(k)))},tuple(...i){return new a(Vr.create(i.map(c)))},lit(i){return new a(Fe(i))},unary:t,not(i){return t("not",i)},exists(i){return t("exists",i)},neg(i){return t("-",i)},between(i,m,A){return new a(oe.create(k(i),v.create("between"),T.create(c(m),c(A))))},betweenSymmetric(i,m,A){return new a(oe.create(k(i),v.create("between symmetric"),T.create(c(m),c(A))))},and(i){return C(i)?new a(We(i,"and")):new a(Jr(i,"and"))},or(i){return C(i)?new a(We(i,"or")):new a(Jr(i,"or"))},parens(...i){let m=h(i);return ie.is(m)?new a(m):new a(ie.create(m))},cast(i,m){return new a(Lt.create(k(i),qt(m)))},withSchema(i){return mr(r.withPluginAtFront(new Ne(i)))}});return n.fn=Ct(),n.eb=n,n}function I(r){return mr()}function H(r){if(f(r))return r.toOperationNode();if(x(r))return r(I()).toOperationNode();throw new Error(`invalid expression: ${JSON.stringify(r)}`)}function He(r){if(f(r))return r.toOperationNode();if(x(r))return r(I()).toOperationNode();throw new Error(`invalid aliased expression: ${JSON.stringify(r)}`)}function ee(r){return Ke(r)||mt(r)||x(r)}function Lr(r){return p(r)?V(r):r.toOperationNode()}function re(r){return C(r)?r.map(e=>k(e)):[k(r)]}function k(r){return ee(r)?H(r):Lr(r)}function Ft(r,e){let t=V(r);if(Sr(e))return xe.create(t,ar.create(v.create(e)));let n=e.slice(0,-1);if(Sr(n))return xe.create(t,ae.create(v.create(n)));throw new Error(`Invalid JSON operator: ${e}`)}function V(r){if(!r.includes("."))return ye.create(E.create(r));let t=r.split(".").map($r);if(t.length===3)return ho(t);if(t.length===2)return fo(t);throw new Error(`invalid column reference ${r}`)}function wt(r){let e=" as ";if(r.includes(e)){let[t,n]=r.split(e).map($r);return g.create(V(t),u.create(n))}else return V(r)}function co(r){return E.create(r)}function Ud(r){if(r.includes(" ")){let[t,n]=r.split(" ").map($r);if(!Mr(n))throw new Error(`invalid order direction "${n}" next to "${t}"`);return L([t,n])[0]}else return co(r)}function ho(r){let[e,t,n]=r;return ye.create(E.create(n),B.createWithSchema(e,t))}function fo(r){let[e,t]=r;return ye.create(E.create(t),B.create(e))}function $r(r){return r.trim()}function h(r){if(r.length===3)return dr(r[0],r[1],r[2]);if(r.length===1)return c(r[0]);throw new Error(`invalid arguments: ${JSON.stringify(r)}`)}function dr(r,e,t){return po(e)&&Mt(t)?oe.create(k(r),Gr(e),F.createImmediate(t)):oe.create(k(r),Gr(e),At(t))}function S(r,e,t){return oe.create(k(r),Gr(e),k(t))}function Jr(r,e){return We(Object.entries(r).filter(([,t])=>!M(t)).map(([t,n])=>dr(t,Mt(n)?"is":"=",n)),e)}function We(r,e,t=!0){let n=e==="and"?T.create:P.create;if(r.length===0)return oe.create(F.createImmediate(1),v.create("="),F.createImmediate(e==="and"?1:0));let i=Dt(r[0]);for(let m=1;m<r.length;++m)i=n(i,Dt(r[m]));return r.length>1&&t?ie.create(i):i}function po(r){return r==="is"||r==="is not"}function Mt(r){return Ie(r)||ze(r)}function Gr(r){if(p(r)&&dt.includes(r))return v.create(r);if(f(r))return r.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(r)}`)}function Dt(r){return f(r)?r.toOperationNode():r}function ue(r,e){if(e.length===3)return No(r,e[0],e[1],e[2]);if(e.length===2)return lo(r,e[0],e[1]);if(e.length===1)return yo(r,e[0]);throw new Error("not implemented")}function lo(r,e,t){return t(bt(r,e)).toOperationNode()}function No(r,e,t,n){return Q.createWithOn(r,ce(e),S(t,"=",n))}function yo(r,e){return Q.create(r,ce(e))}var Se=o({is(r){return r.kind==="LimitNode"},create(r){return o({kind:"LimitNode",limit:r})}});var Pt=o({is(r){return r.kind==="OffsetNode"},create(r){return o({kind:"OffsetNode",offset:r})}});var Qt=o({is(r){return r.kind==="GroupByItemNode"},create(r){return o({kind:"GroupByItemNode",groupBy:r})}});function vt(r){return r=x(r)?r(I()):r,re(r).map(Qt.create)}var D=class extends Error{node;constructor(e){super("no result"),this.node=e}};function Y(r){return Object.prototype.hasOwnProperty.call(r,"prototype")}var zt=o({is(r){return r.kind==="SetOperationNode"},create(r,e,t){return o({kind:"SetOperationNode",operator:r,expression:e,all:t})}});function he(r,e,t){return x(e)&&(e=e(mr())),C(e)||(e=[e]),e.map(n=>zt.create(r,H(n),t))}var It=o({is(r){return r.kind==="FetchNode"},create(r,e){return{kind:"FetchNode",rowCount:F.create(r),modifier:e}}});function Ut(r,e){if(!pe(r)&&!Ue(r))throw new Error(`Invalid fetch row count: ${r}`);if(!wo(e))throw new Error(`Invalid fetch modifier: ${e}`);return It.create(r,e)}function wo(r){return r==="only"||r==="with ties"}var Vt=o({is(r){return r.kind==="TopNode"},create(r,e){return o({kind:"TopNode",expression:r,modifiers:e})}});function $(r,e){if(!pe(r)&&!Ue(r))throw new Error(`Invalid top expression: ${r}`);if(!M(e)&&!Oo(e))throw new Error(`Invalid top modifiers: ${e}`);return Vt.create(r,e)}function Oo(r){return r==="percent"||r==="with ties"||r==="percent with ties"}var jr=class r{#e;constructor(e){this.#e=o(e)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...e){return new r({...this.#e,queryNode:s.cloneWithWhere(this.#e.queryNode,h(e))})}whereRef(e,t,n){return new r({...this.#e,queryNode:s.cloneWithWhere(this.#e.queryNode,S(e,t,n))})}having(...e){return new r({...this.#e,queryNode:d.cloneWithHaving(this.#e.queryNode,h(e))})}havingRef(e,t,n){return new r({...this.#e,queryNode:d.cloneWithHaving(this.#e.queryNode,S(e,t,n))})}select(e){return new r({...this.#e,queryNode:d.cloneWithSelections(this.#e.queryNode,O(e))})}distinctOn(e){return new r({...this.#e,queryNode:d.cloneWithDistinctOn(this.#e.queryNode,re(e))})}modifyFront(e){return new r({...this.#e,queryNode:d.cloneWithFrontModifier(this.#e.queryNode,G.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.createWithExpression(e.toOperationNode()))})}distinct(){return new r({...this.#e,queryNode:d.cloneWithFrontModifier(this.#e.queryNode,G.create("Distinct"))})}forUpdate(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.create("ForUpdate",e?Re(e).map(N):void 0))})}forShare(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.create("ForShare",e?Re(e).map(N):void 0))})}forKeyShare(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.create("ForKeyShare",e?Re(e).map(N):void 0))})}forNoKeyUpdate(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.create("ForNoKeyUpdate",e?Re(e).map(N):void 0))})}skipLocked(){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.create("SkipLocked"))})}noWait(){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,G.create("NoWait"))})}selectAll(e){return new r({...this.#e,queryNode:d.cloneWithSelections(this.#e.queryNode,W(e))})}innerJoin(...e){return this.#r("InnerJoin",e)}leftJoin(...e){return this.#r("LeftJoin",e)}rightJoin(...e){return this.#r("RightJoin",e)}fullJoin(...e){return this.#r("FullJoin",e)}crossJoin(...e){return this.#r("CrossJoin",e)}innerJoinLateral(...e){return this.#r("LateralInnerJoin",e)}leftJoinLateral(...e){return this.#r("LateralLeftJoin",e)}crossJoinLateral(...e){return this.#r("LateralCrossJoin",e)}crossApply(...e){return this.#r("CrossApply",e)}outerApply(...e){return this.#r("OuterApply",e)}#r(e,t){return new r({...this.#e,queryNode:s.cloneWithJoin(this.#e.queryNode,ue(e,t))})}orderBy(...e){return new r({...this.#e,queryNode:s.cloneWithOrderByItems(this.#e.queryNode,L(e))})}groupBy(e){return new r({...this.#e,queryNode:d.cloneWithGroupByItems(this.#e.queryNode,vt(e))})}limit(e){return new r({...this.#e,queryNode:d.cloneWithLimit(this.#e.queryNode,Se.create(c(e)))})}offset(e){return new r({...this.#e,queryNode:d.cloneWithOffset(this.#e.queryNode,Pt.create(c(e)))})}fetch(e,t="only"){return new r({...this.#e,queryNode:d.cloneWithFetch(this.#e.queryNode,Ut(e,t))})}top(e,t){return new r({...this.#e,queryNode:s.cloneWithTop(this.#e.queryNode,$(e,t))})}union(e){return new r({...this.#e,queryNode:d.cloneWithSetOperations(this.#e.queryNode,he("union",e,!1))})}unionAll(e){return new r({...this.#e,queryNode:d.cloneWithSetOperations(this.#e.queryNode,he("union",e,!0))})}intersect(e){return new r({...this.#e,queryNode:d.cloneWithSetOperations(this.#e.queryNode,he("intersect",e,!1))})}intersectAll(e){return new r({...this.#e,queryNode:d.cloneWithSetOperations(this.#e.queryNode,he("intersect",e,!0))})}except(e){return new r({...this.#e,queryNode:d.cloneWithSetOperations(this.#e.queryNode,he("except",e,!1))})}exceptAll(e){return new r({...this.#e,queryNode:d.cloneWithSetOperations(this.#e.queryNode,he("except",e,!0))})}as(e){return new Kr(this,e)}clearSelect(){return new r({...this.#e,queryNode:d.cloneWithoutSelections(this.#e.queryNode)})}clearWhere(){return new r({...this.#e,queryNode:s.cloneWithoutWhere(this.#e.queryNode)})}clearLimit(){return new r({...this.#e,queryNode:d.cloneWithoutLimit(this.#e.queryNode)})}clearOffset(){return new r({...this.#e,queryNode:d.cloneWithoutOffset(this.#e.queryNode)})}clearOrderBy(){return new r({...this.#e,queryNode:s.cloneWithoutOrderBy(this.#e.queryNode)})}clearGroupBy(){return new r({...this.#e,queryNode:d.cloneWithoutGroupBy(this.#e.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}$castTo(){return new r(this.#e)}$narrowType(){return new r(this.#e)}$assertType(){return new r(this.#e)}$asTuple(){return new a(this.toOperationNode())}$asScalar(){return new a(this.toOperationNode())}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile();return(await this.#e.executor.executeQuery(e)).rows}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=D){let t=await this.executeTakeFirst();if(t===void 0)throw Y(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),n=this.#e.executor.stream(t,e);for await(let i of n)yield*i.rows}async explain(e,t){return await new r({...this.#e,queryNode:s.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}};function De(r){return new jr(r)}var Kr=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return g.create(this.#e.toOperationNode(),u.create(this.#r))}};var Jt=o({is(r){return r.kind==="ValuesNode"},create(r){return o({kind:"ValuesNode",values:o(r)})}});var $t=o({is(r){return r.kind==="DefaultInsertValueNode"},create(){return o({kind:"DefaultInsertValueNode"})}});function cr(r){let e=x(r)?r(I()):r,t=C(e)?e:o([e]);return xo(t)}function xo(r){let e=go(r);return[o([...e.keys()].map(E.create)),Jt.create(r.map(t=>Wo(t,e)))]}function go(r){let e=new Map;for(let t of r){let n=Object.keys(t);for(let i of n)!e.has(i)&&t[i]!==void 0&&e.set(i,e.size)}return e}function Wo(r,e){let t=Object.keys(r),n=Array.from({length:e.size}),i=!1,m=t.length;for(let ve of t){let Ee=e.get(ve);if(M(Ee)){m--;continue}let gr=r[ve];(M(gr)||ee(gr))&&(i=!0),n[Ee]=gr}if(m<e.size||i){let ve=$t.create();return or.create(n.map(Ee=>M(Ee)?ve:c(Ee)))}return tr.create(n)}var Hr=o({is(r){return r.kind==="ColumnUpdateNode"},create(r,e){return o({kind:"ColumnUpdateNode",column:r,value:e})}});function Gt(...r){return r.length===2?[Hr.create(k(r[0]),c(r[1]))]:Me(r[0])}function Me(r){let e=x(r)?r(I()):r;return Object.entries(e).filter(([t,n])=>n!==void 0).map(([t,n])=>Hr.create(E.create(t),c(n)))}var jt=o({is(r){return r.kind==="OnDuplicateKeyNode"},create(r){return o({kind:"OnDuplicateKeyNode",updates:r})}});var hr=class{insertId;numInsertedOrUpdatedRows;constructor(e,t){this.insertId=e,this.numInsertedOrUpdatedRows=t}};var R=o({is(r){return r.kind==="OnConflictNode"},create(){return o({kind:"OnConflictNode"})},cloneWith(r,e){return o({...r,...e})},cloneWithIndexWhere(r,e){return o({...r,indexWhere:r.indexWhere?b.cloneWithOperation(r.indexWhere,"And",e):b.create(e)})},cloneWithIndexOrWhere(r,e){return o({...r,indexWhere:r.indexWhere?b.cloneWithOperation(r.indexWhere,"Or",e):b.create(e)})},cloneWithUpdateWhere(r,e){return o({...r,updateWhere:r.updateWhere?b.cloneWithOperation(r.updateWhere,"And",e):b.create(e)})},cloneWithUpdateOrWhere(r,e){return o({...r,updateWhere:r.updateWhere?b.cloneWithOperation(r.updateWhere,"Or",e):b.create(e)})},cloneWithoutIndexWhere(r){return o({...r,indexWhere:void 0})},cloneWithoutUpdateWhere(r){return o({...r,updateWhere:void 0})}});var fr=class r{#e;constructor(e){this.#e=o(e)}column(e){let t=E.create(e);return new r({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?o([...this.#e.onConflictNode.columns,t]):o([t])})})}columns(e){let t=e.map(E.create);return new r({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?o([...this.#e.onConflictNode.columns,...t]):o(t)})})}constraint(e){return new r({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{constraint:u.create(e)})})}expression(e){return new r({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new r({...this.#e,onConflictNode:R.cloneWithIndexWhere(this.#e.onConflictNode,h(e))})}whereRef(e,t,n){return new r({...this.#e,onConflictNode:R.cloneWithIndexWhere(this.#e.onConflictNode,S(e,t,n))})}clearWhere(){return new r({...this.#e,onConflictNode:R.cloneWithoutIndexWhere(this.#e.onConflictNode)})}doNothing(){return new Yr({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new Xr({...this.#e,onConflictNode:R.cloneWith(this.#e.onConflictNode,{updates:Me(e)})})}$call(e){return e(this)}},Yr=class{#e;constructor(e){this.#e=o(e)}toOperationNode(){return this.#e.onConflictNode}},Xr=class r{#e;constructor(e){this.#e=o(e)}where(...e){return new r({...this.#e,onConflictNode:R.cloneWithUpdateWhere(this.#e.onConflictNode,h(e))})}whereRef(e,t,n){return new r({...this.#e,onConflictNode:R.cloneWithUpdateWhere(this.#e.onConflictNode,S(e,t,n))})}clearWhere(){return new r({...this.#e,onConflictNode:R.cloneWithoutUpdateWhere(this.#e.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#e.onConflictNode}};var fe=o({is(r){return r.kind==="OrActionNode"},create(r){return o({kind:"OrActionNode",action:r})}});var Pe=class r{#e;constructor(e){this.#e=o(e)}values(e){let[t,n]=cr(e);return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{columns:t,values:n})})}columns(e){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{columns:o(e.map(E.create))})})}expression(e){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{values:H(e)})})}defaultValues(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{defaultValues:!0})})}modifyEnd(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}ignore(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{orAction:fe.create("ignore")})})}orIgnore(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{orAction:fe.create("ignore")})})}orAbort(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{orAction:fe.create("abort")})})}orFail(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{orAction:fe.create("fail")})})}orReplace(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{orAction:fe.create("replace")})})}orRollback(){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{orAction:fe.create("rollback")})})}top(e,t){return new r({...this.#e,queryNode:s.cloneWithTop(this.#e.queryNode,$(e,t))})}onConflict(e){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{onConflict:e(new fr({onConflictNode:R.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new r({...this.#e,queryNode:l.cloneWith(this.#e.queryNode,{onDuplicateKey:jt.create(Me(e))})})}returning(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,O(e))})}returningAll(){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,W())})}output(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,O(e))})}outputAll(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,W(e))})}clearReturning(){return new r({...this.#e,queryNode:s.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}$castTo(){return new r(this.#e)}$narrowType(){return new r(this.#e)}$assertType(){return new r(this.#e)}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e),{adapter:n}=this.#e.executor,i=e.query;return i.returning&&n.supportsReturning||i.output&&n.supportsOutput?t.rows:[new hr(t.insertId,t.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=D){let t=await this.executeTakeFirst();if(t===void 0)throw Y(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),n=this.#e.executor.stream(t,e);for await(let i of n)yield*i.rows}async explain(e,t){return await new r({...this.#e,queryNode:s.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}};var pr=class{numDeletedRows;constructor(e){this.numDeletedRows=e}};var lr=class r{#e;constructor(e){this.#e=o(e)}where(...e){return new r({...this.#e,queryNode:s.cloneWithWhere(this.#e.queryNode,h(e))})}whereRef(e,t,n){return new r({...this.#e,queryNode:s.cloneWithWhere(this.#e.queryNode,S(e,t,n))})}clearWhere(){return new r({...this.#e,queryNode:s.cloneWithoutWhere(this.#e.queryNode)})}top(e,t){return new r({...this.#e,queryNode:s.cloneWithTop(this.#e.queryNode,$(e,t))})}using(e){return new r({...this.#e,queryNode:ne.cloneWithUsing(this.#e.queryNode,z(e))})}innerJoin(...e){return this.#r("InnerJoin",e)}leftJoin(...e){return this.#r("LeftJoin",e)}rightJoin(...e){return this.#r("RightJoin",e)}fullJoin(...e){return this.#r("FullJoin",e)}#r(e,t){return new r({...this.#e,queryNode:s.cloneWithJoin(this.#e.queryNode,ue(e,t))})}returning(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,O(e))})}returningAll(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,W(e))})}output(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,O(e))})}outputAll(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,W(e))})}clearReturning(){return new r({...this.#e,queryNode:s.cloneWithoutReturning(this.#e.queryNode)})}clearLimit(){return new r({...this.#e,queryNode:ne.cloneWithoutLimit(this.#e.queryNode)})}orderBy(...e){return new r({...this.#e,queryNode:s.cloneWithOrderByItems(this.#e.queryNode,L(e))})}clearOrderBy(){return new r({...this.#e,queryNode:s.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new r({...this.#e,queryNode:ne.cloneWithLimit(this.#e.queryNode,Se.create(c(e)))})}modifyEnd(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}$castTo(){return new r(this.#e)}$narrowType(){return new r(this.#e)}$assertType(){return new r(this.#e)}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e),{adapter:n}=this.#e.executor,i=e.query;return i.returning&&n.supportsReturning||i.output&&n.supportsOutput?t.rows:[new pr(t.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=D){let t=await this.executeTakeFirst();if(t===void 0)throw Y(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),n=this.#e.executor.stream(t,e);for await(let i of n)yield*i.rows}async explain(e,t){return await new r({...this.#e,queryNode:s.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}};var Nr=class{numUpdatedRows;numChangedRows;constructor(e,t){this.numUpdatedRows=e,this.numChangedRows=t}};var be=class r{#e;constructor(e){this.#e=o(e)}where(...e){return new r({...this.#e,queryNode:s.cloneWithWhere(this.#e.queryNode,h(e))})}whereRef(e,t,n){return new r({...this.#e,queryNode:s.cloneWithWhere(this.#e.queryNode,S(e,t,n))})}clearWhere(){return new r({...this.#e,queryNode:s.cloneWithoutWhere(this.#e.queryNode)})}top(e,t){return new r({...this.#e,queryNode:s.cloneWithTop(this.#e.queryNode,$(e,t))})}from(e){return new r({...this.#e,queryNode:j.cloneWithFromItems(this.#e.queryNode,z(e))})}innerJoin(...e){return this.#r("InnerJoin",e)}leftJoin(...e){return this.#r("LeftJoin",e)}rightJoin(...e){return this.#r("RightJoin",e)}fullJoin(...e){return this.#r("FullJoin",e)}#r(e,t){return new r({...this.#e,queryNode:s.cloneWithJoin(this.#e.queryNode,ue(e,t))})}orderBy(...e){return new r({...this.#e,queryNode:s.cloneWithOrderByItems(this.#e.queryNode,L(e))})}clearOrderBy(){return new r({...this.#e,queryNode:s.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new r({...this.#e,queryNode:j.cloneWithLimit(this.#e.queryNode,Se.create(c(e)))})}set(...e){return new r({...this.#e,queryNode:j.cloneWithUpdates(this.#e.queryNode,Gt(...e))})}returning(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,O(e))})}returningAll(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,W(e))})}output(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,O(e))})}outputAll(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,W(e))})}modifyEnd(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}clearReturning(){return new r({...this.#e,queryNode:s.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}$castTo(){return new r(this.#e)}$narrowType(){return new r(this.#e)}$assertType(){return new r(this.#e)}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e),{adapter:n}=this.#e.executor,i=e.query;return i.returning&&n.supportsReturning||i.output&&n.supportsOutput?t.rows:[new Nr(t.numAffectedRows??BigInt(0),t.numChangedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=D){let t=await this.executeTakeFirst();if(t===void 0)throw Y(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}async*stream(e=100){let t=this.compile(),n=this.#e.executor.stream(t,e);for await(let i of n)yield*i.rows}async explain(e,t){return await new r({...this.#e,queryNode:s.cloneWithExplain(this.#e.queryNode,e,t)}).execute()}};var Zr=o({is(r){return r.kind==="CommonTableExpressionNameNode"},create(r,e){return o({kind:"CommonTableExpressionNameNode",table:B.create(r),columns:e?o(e.map(E.create)):void 0})}});var ke=o({is(r){return r.kind==="CommonTableExpressionNode"},create(r,e){return o({kind:"CommonTableExpressionNode",name:r,expression:e})},cloneWith(r,e){return o({...r,...e})}});var yr=class r{#e;constructor(e){this.#e=o(e)}materialized(){return new r({...this.#e,node:ke.cloneWith(this.#e.node,{materialized:!0})})}notMaterialized(){return new r({...this.#e,node:ke.cloneWith(this.#e.node,{materialized:!1})})}toOperationNode(){return this.#e.node}};function _r(r,e){let t=e(St()).toOperationNode();return x(r)?r(So(t)).toOperationNode():ke.create(Kt(r),t)}function So(r){return e=>new yr({node:ke.create(Kt(e),r)})}function Kt(r){if(r.includes("(")){let e=r.split(/[\(\)]/),t=e[0],n=e[1].split(",").map(i=>i.trim());return Zr.create(t,n)}else return Zr.create(r)}var Qe=o({is(r){return r.kind==="WithNode"},create(r,e){return o({kind:"WithNode",expressions:o([r]),...e})},cloneWithExpression(r,e){return o({...r,expressions:o([...r.expressions,e])})}});var Ht=o({is(r){return r.kind==="MatchedNode"},create(r,e=!1){return o({kind:"MatchedNode",not:r,bySource:e})}});function et(r,e,t){return Z.create(We([Ht.create(!r.isMatched,r.bySource),...e&&e.length>0?[e.length===3&&t?S(e[0],e[1],e[2]):h(e)]:[]],"and",!1))}function Ce(r){return p(r)?y.create([r],[]):f(r)?r.toOperationNode():r}var wr=class{numChangedRows;constructor(e){this.numChangedRows=e}};var Or=class r{#e;constructor(e){this.#e=o(e)}modifyEnd(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,t){return new r({...this.#e,queryNode:s.cloneWithTop(this.#e.queryNode,$(e,t))})}using(...e){return new de({...this.#e,queryNode:q.cloneWithUsing(this.#e.queryNode,ue("Using",e))})}returning(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,O(e))})}returningAll(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,W(e))})}output(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,O(e))})}outputAll(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,W(e))})}},de=class r{#e;constructor(e){this.#e=o(e)}modifyEnd(e){return new r({...this.#e,queryNode:s.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,t){return new r({...this.#e,queryNode:s.cloneWithTop(this.#e.queryNode,$(e,t))})}whenMatched(){return this.#r([])}whenMatchedAnd(...e){return this.#r(e)}whenMatchedAndRef(e,t,n){return this.#r([e,t,n],!0)}#r(e,t){return new xr({...this.#e,queryNode:q.cloneWithWhen(this.#e.queryNode,et({isMatched:!0},e,t))})}whenNotMatched(){return this.#t([])}whenNotMatchedAnd(...e){return this.#t(e)}whenNotMatchedAndRef(e,t,n){return this.#t([e,t,n],!0)}whenNotMatchedBySource(){return this.#t([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#t(e,!1,!0)}whenNotMatchedBySourceAndRef(e,t,n){return this.#t([e,t,n],!0,!0)}returning(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,O(e))})}returningAll(e){return new r({...this.#e,queryNode:s.cloneWithReturning(this.#e.queryNode,W(e))})}output(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,O(e))})}outputAll(e){return new r({...this.#e,queryNode:s.cloneWithOutput(this.#e.queryNode,W(e))})}#t(e,t=!1,n=!1){let i={...this.#e,queryNode:q.cloneWithWhen(this.#e.queryNode,et({isMatched:!1,bySource:n},e,t))},m=n?xr:rt;return new m(i)}$call(e){return e(this)}$if(e,t){return e?t(this):new r({...this.#e})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let e=this.compile(),t=await this.#e.executor.executeQuery(e),{adapter:n}=this.#e.executor,i=e.query;return i.returning&&n.supportsReturning||i.output&&n.supportsOutput?t.rows:[new wr(t.numAffectedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=D){let t=await this.executeTakeFirst();if(t===void 0)throw Y(e)?new e(this.toOperationNode()):e(this.toOperationNode());return t}},xr=class{#e;constructor(e){this.#e=o(e)}thenDelete(){return new de({...this.#e,queryNode:q.cloneWithThen(this.#e.queryNode,Ce("delete"))})}thenDoNothing(){return new de({...this.#e,queryNode:q.cloneWithThen(this.#e.queryNode,Ce("do nothing"))})}thenUpdate(e){return new de({...this.#e,queryNode:q.cloneWithThen(this.#e.queryNode,Ce(e(new be({queryId:this.#e.queryId,executor:se,queryNode:j.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(t=>t.set(...e))}},rt=class{#e;constructor(e){this.#e=o(e)}thenDoNothing(){return new de({...this.#e,queryNode:q.cloneWithThen(this.#e.queryNode,Ce("do nothing"))})}thenInsertValues(e){let[t,n]=cr(e);return new de({...this.#e,queryNode:q.cloneWithThen(this.#e.queryNode,Ce(l.cloneWith(l.createWithoutInto(),{columns:t,values:n})))})}};var rr=class r{#e;constructor(e){this.#e=o(e)}selectFrom(e){return De({queryId:w(),executor:this.#e.executor,queryNode:d.createFrom(z(e),this.#e.withNode)})}selectNoFrom(e){return De({queryId:w(),executor:this.#e.executor,queryNode:d.cloneWithSelections(d.create(this.#e.withNode),O(e))})}insertInto(e){return new Pe({queryId:w(),executor:this.#e.executor,queryNode:l.create(N(e),this.#e.withNode)})}replaceInto(e){return new Pe({queryId:w(),executor:this.#e.executor,queryNode:l.create(N(e),this.#e.withNode,!0)})}deleteFrom(e){return new lr({queryId:w(),executor:this.#e.executor,queryNode:ne.create(z(e),this.#e.withNode)})}updateTable(e){return new be({queryId:w(),executor:this.#e.executor,queryNode:j.create(z(e),this.#e.withNode)})}mergeInto(e){return new Or({queryId:w(),executor:this.#e.executor,queryNode:q.create(Ar(e),this.#e.withNode)})}with(e,t){let n=_r(e,t);return new r({...this.#e,withNode:this.#e.withNode?Qe.cloneWithExpression(this.#e.withNode,n):Qe.create(n)})}withRecursive(e,t){let n=_r(e,t);return new r({...this.#e,withNode:this.#e.withNode?Qe.cloneWithExpression(this.#e.withNode,n):Qe.create(n,{recursive:!0})})}withPlugin(e){return new r({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new r({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new r({...this.#e,executor:this.#e.executor.withPluginAtFront(new Ne(e))})}};var tt=class r{#e;constructor(e){this.#e=o(e)}get expressionType(){}get isRawBuilder(){return!0}as(e){return new ot(this,e)}$castTo(){return new r({...this.#e})}$notNull(){return new r(this.#e)}withPlugin(e){return new r({...this.#e,plugins:this.#e.plugins!==void 0?o([...this.#e.plugins,e]):o([e])})}toOperationNode(){return this.#t(this.#r())}compile(e){return this.#n(this.#r(e))}async execute(e){let t=this.#r(e);return t.executeQuery(this.#n(t))}#r(e){let t=e!==void 0?e.getExecutor():se;return this.#e.plugins!==void 0?t.withPlugins(this.#e.plugins):t}#t(e){return e.transformQuery(this.#e.rawNode,this.#e.queryId)}#n(e){return e.compileQuery(this.#t(e),this.#e.queryId)}};function te(r){return new tt(r)}var ot=class{#e;#r;constructor(e,t){this.#e=e,this.#r=t}get expression(){return this.#e}get alias(){return this.#r}get rawBuilder(){return this.#e}toOperationNode(){return g.create(this.#e.toOperationNode(),f(this.#r)?this.#r.toOperationNode():u.create(this.#r))}};var bo=Object.assign((r,...e)=>te({queryId:w(),rawNode:y.create(r,e?.map(Yt)??[])}),{ref(r){return te({queryId:w(),rawNode:y.createWithChild(V(r))})},val(r){return te({queryId:w(),rawNode:y.createWithChild(c(r))})},value(r){return this.val(r)},table(r){return te({queryId:w(),rawNode:y.createWithChild(N(r))})},id(...r){let e=new Array(r.length+1).fill(".");return e[0]="",e[e.length-1]="",te({queryId:w(),rawNode:y.create(e,r.map(u.create))})},lit(r){return te({queryId:w(),rawNode:y.createWithChild(F.createImmediate(r))})},literal(r){return this.lit(r)},raw(r){return te({queryId:w(),rawNode:y.createWithSql(r)})},join(r,e=bo`, `){let t=new Array(Math.max(2*r.length-1,0)),n=e.toOperationNode();for(let i=0;i<r.length;++i)t[2*i]=Yt(r[i]),i!==r.length-1&&(t[2*i+1]=n);return te({queryId:w(),rawNode:y.createWithChildren(t)})}});function Yt(r){return f(r)?r.toOperationNode():c(r)}export{M as a,p as b,pe as c,ze as d,Ie as e,ko as f,Ue as g,Co as h,x as i,X as j,o as k,Eo as l,u as m,Ae as n,f as o,v as p,E as q,je as r,lt as s,y as t,le as u,V as v,co as w,Ud as x,or as y,F as z,ie as A,h as B,l as C,Z as D,s as E,d as F,st as G,w as H,$e as I,Ne as J,Be as K,at as L,er as M,rr as N,zt as O,Ct as P,J as Q,ir as R,qt as S,H as T,ht as U,N as V,bo as W};
|