@shumai-one/shumai 0.5.0 → 0.5.2

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.
Files changed (164) hide show
  1. package/bin/{chunk-h82r29wm.js → chunk-04avc4fn.js} +49 -49
  2. package/bin/chunk-0asthrjf.js +2 -0
  3. package/bin/chunk-0ge2mm8j.js +1 -0
  4. package/bin/{chunk-3z20b2hz.js → chunk-0j22699g.js} +2 -2
  5. package/bin/{chunk-j909v9p5.js → chunk-0v9srsdz.js} +1 -1
  6. package/bin/{chunk-exgtwask.js → chunk-0y4zq3y4.js} +1 -1
  7. package/bin/{chunk-5yd9cv7f.js → chunk-15vsw36h.js} +5 -5
  8. package/bin/{chunk-eez1yncf.js → chunk-15w79661.js} +2 -2
  9. package/bin/{chunk-xvdd04gy.js → chunk-19jpn3r6.js} +1 -1
  10. package/bin/{chunk-grsgkkrb.js → chunk-19q13a80.js} +6 -6
  11. package/bin/{chunk-r6gkv98n.js → chunk-1nvj833s.js} +6 -6
  12. package/bin/chunk-23780yj6.js +3 -0
  13. package/bin/chunk-2gf95tj0.js +1 -0
  14. package/bin/{chunk-6vvs18bw.js → chunk-2pw7xcrn.js} +1 -1
  15. package/bin/chunk-2tk5w3jc.js +1 -0
  16. package/bin/chunk-2w6gve12.js +4 -0
  17. package/bin/chunk-301e7g3z.js +2 -0
  18. package/bin/chunk-3kmjbc3m.js +2 -0
  19. package/bin/{chunk-zhe16jvg.js → chunk-3pm6q6kg.js} +1 -1
  20. package/bin/{chunk-zfqz72sd.js → chunk-3q5qkfkc.js} +1 -1
  21. package/bin/chunk-3td60k1m.js +2 -0
  22. package/bin/chunk-42hrvk6k.js +211 -0
  23. package/bin/chunk-4zksqvwj.js +2 -0
  24. package/bin/chunk-5bk16qdp.js +2 -0
  25. package/bin/{chunk-y03z5rrg.js → chunk-5nqvqvqp.js} +3 -3
  26. package/bin/{chunk-e3r1m6rb.js → chunk-5rzxekn4.js} +1 -1
  27. package/bin/{chunk-h9x81yp6.js → chunk-5vqbzsjv.js} +1 -1
  28. package/bin/{chunk-628k58ek.js → chunk-6hzktewz.js} +2 -2
  29. package/bin/{chunk-yfe6hkzk.js → chunk-6jkjx0n2.js} +3 -3
  30. package/bin/{chunk-gy8z8sd7.js → chunk-6rn094yj.js} +1 -1
  31. package/bin/{chunk-3cvbb6kh.js → chunk-7qvvf0yd.js} +2 -2
  32. package/bin/{chunk-35mpp84e.js → chunk-81dawvn4.js} +2 -2
  33. package/bin/chunk-8abhmarc.js +2 -0
  34. package/bin/{chunk-51h2bgpf.js → chunk-8ayz61rc.js} +3 -3
  35. package/bin/{chunk-03bfjh8k.js → chunk-8ny7wvzb.js} +2 -2
  36. package/bin/{chunk-3btc8a0p.js → chunk-8tzfcqtb.js} +2 -2
  37. package/bin/{chunk-5patxztz.js → chunk-8zgq5sav.js} +3 -3
  38. package/bin/{chunk-m1xc3t0p.js → chunk-93p27bbm.js} +6 -6
  39. package/bin/chunk-951r2rx1.js +1 -0
  40. package/bin/chunk-965102pf.js +3 -0
  41. package/bin/{chunk-hr2027z3.js → chunk-98mg3dpd.js} +8 -8
  42. package/bin/{chunk-v42jcex0.js → chunk-9bakwac0.js} +4 -4
  43. package/bin/{chunk-z8mmqfm4.js → chunk-9ggwc289.js} +1 -1
  44. package/bin/{chunk-6bgbx563.js → chunk-9zgqjdx1.js} +2 -2
  45. package/bin/{chunk-kzsdp31a.js → chunk-a8bymrv1.js} +2 -2
  46. package/bin/chunk-acn3r2m2.js +1 -0
  47. package/bin/{chunk-z1r86fna.js → chunk-ae6zgjhd.js} +2 -2
  48. package/bin/{chunk-trndqdaa.js → chunk-asy868kq.js} +1 -1
  49. package/bin/{chunk-r1m4q8vw.js → chunk-b5r0be06.js} +2 -2
  50. package/bin/{chunk-dz33q4v1.js → chunk-bbcmhcvc.js} +2 -2
  51. package/bin/{chunk-myd3wg9a.js → chunk-bpxw19ez.js} +1 -1
  52. package/bin/{chunk-sg7n2g3z.js → chunk-cdk8vqeg.js} +4 -4
  53. package/bin/chunk-ce0bhc72.js +2 -0
  54. package/bin/chunk-ce75dw3k.css +1 -0
  55. package/bin/{chunk-m7dp8rqv.js → chunk-cpj562n6.js} +1 -1
  56. package/bin/{chunk-h153xefb.js → chunk-cx32wsa1.js} +1 -1
  57. package/bin/{chunk-r5rpdhed.js → chunk-d2dgazjj.js} +1 -1
  58. package/bin/{chunk-3zvvct3r.js → chunk-d5hbzp7t.js} +1 -1
  59. package/bin/chunk-d9qpgkek.js +2 -0
  60. package/bin/{chunk-9h6nn1a3.js → chunk-dche0gy0.js} +1 -1
  61. package/bin/{chunk-zcrtr8qd.js → chunk-dppfek34.js} +2 -2
  62. package/bin/chunk-dv6p6n5e.js +1 -0
  63. package/bin/{chunk-hx76pje1.js → chunk-e439kt05.js} +1 -1
  64. package/bin/{chunk-gptzcgte.js → chunk-eqr0znmc.js} +1 -1
  65. package/bin/{chunk-q5mkbnr9.js → chunk-f5z3096k.js} +2 -2
  66. package/bin/{chunk-b9j5575n.js → chunk-ffj9cq9y.js} +2 -2
  67. package/bin/{chunk-80qz30dc.js → chunk-fxg81vtx.js} +2 -2
  68. package/bin/{chunk-5jbx9gqe.js → chunk-ggfx2b0f.js} +1 -1
  69. package/bin/chunk-gnt9gewm.js +2 -0
  70. package/bin/{chunk-czny5thj.js → chunk-grjek810.js} +2 -2
  71. package/bin/chunk-gvas3xkp.js +2 -0
  72. package/bin/{chunk-ghjhyajn.js → chunk-j53sjkxt.js} +2 -2
  73. package/bin/{chunk-0tf15vee.js → chunk-jgfye6nf.js} +2 -2
  74. package/bin/{chunk-tcat7q9p.js → chunk-jt6v15wx.js} +2 -2
  75. package/bin/{chunk-rn9rktp4.js → chunk-k3prp6c6.js} +4 -4
  76. package/bin/{chunk-mqr096rn.js → chunk-k97axrc4.js} +1 -1
  77. package/bin/{chunk-20anqpf1.js → chunk-kvwec0p3.js} +2 -2
  78. package/bin/{chunk-vbbn4hth.js → chunk-kzr6ecke.js} +1 -1
  79. package/bin/{chunk-rkq6jvhb.js → chunk-m6v8vt2b.js} +2 -2
  80. package/bin/{chunk-32japja5.js → chunk-mn108p93.js} +1 -1
  81. package/bin/{chunk-31vx01aw.js → chunk-mn208vrv.js} +2 -2
  82. package/bin/chunk-mneeg71d.js +2 -0
  83. package/bin/{chunk-d7mgjqf8.js → chunk-n76w2wcr.js} +1 -1
  84. package/bin/{chunk-fyssg02c.js → chunk-n9vp9nbg.js} +29 -29
  85. package/bin/{chunk-2g5qdx4s.js → chunk-p0j4wpa5.js} +2 -2
  86. package/bin/chunk-qb178ntp.js +2 -0
  87. package/bin/{chunk-7vd5yajk.js → chunk-qmrg2jhs.js} +7 -7
  88. package/bin/{chunk-d9btz95y.js → chunk-qxscgcn9.js} +2 -2
  89. package/bin/{chunk-0vtk7wrf.js → chunk-r249n1xe.js} +2 -2
  90. package/bin/{chunk-36r20sj7.js → chunk-r776bhsg.js} +1 -1
  91. package/bin/{chunk-1k16xsqq.js → chunk-rmvhyqyb.js} +6 -6
  92. package/bin/{chunk-zwb9kamp.js → chunk-rtaya5wc.js} +2 -2
  93. package/bin/chunk-rw5h0n0s.js +1 -0
  94. package/bin/{chunk-m9sp00a9.js → chunk-ryepy5er.js} +4 -4
  95. package/bin/{chunk-mcd7zas7.js → chunk-rza95y4z.js} +2 -2
  96. package/bin/chunk-s4r6e6ms.js +1 -0
  97. package/bin/{chunk-qgkbxw1k.js → chunk-sbyyn9yw.js} +2 -2
  98. package/bin/chunk-syjjke3f.js +1 -0
  99. package/bin/chunk-t1yamxgk.js +2 -0
  100. package/bin/chunk-tgfxe0sb.js +1 -0
  101. package/bin/chunk-tjretpx8.js +1 -0
  102. package/bin/chunk-tvkekn4z.js +1 -0
  103. package/bin/{chunk-5t05jpna.js → chunk-twpc640e.js} +1 -1
  104. package/bin/{chunk-p5v22g5n.js → chunk-v034sfw8.js} +2 -2
  105. package/bin/{chunk-wydd7sz7.js → chunk-v5hz09a1.js} +2 -2
  106. package/bin/{chunk-j3xaq9s3.js → chunk-vm2pz2hm.js} +2 -2
  107. package/bin/{chunk-mt532a33.js → chunk-vzdgsfkf.js} +1 -1
  108. package/bin/chunk-w4yjgez6.js +14 -0
  109. package/bin/{chunk-0yv0nnmh.js → chunk-w73v578p.js} +2 -2
  110. package/bin/{chunk-edjtb7pk.js → chunk-w9z27p0m.js} +2 -2
  111. package/bin/chunk-wjcebkpb.js +1 -0
  112. package/bin/{chunk-cw8z9w5c.js → chunk-wnqxyqrg.js} +2 -2
  113. package/bin/chunk-ws71fg50.js +2 -0
  114. package/bin/{chunk-g8h1e1kh.js → chunk-wwkhskce.js} +2 -2
  115. package/bin/{chunk-kgfa5y9w.js → chunk-xr2v0d6y.js} +5 -5
  116. package/bin/{chunk-wkxm6yny.js → chunk-y2dhf3p0.js} +2 -2
  117. package/bin/chunk-yfp3q4da.js +1 -0
  118. package/bin/{chunk-f22nrm6r.js → chunk-ypkkfwfb.js} +4 -4
  119. package/bin/chunk-z8e4wc59.js +1 -0
  120. package/bin/{chunk-fhq5m9ya.js → chunk-zckxc8m6.js} +2 -2
  121. package/bin/{chunk-3fjgf7eb.js → chunk-zdzkjp4q.js} +2 -2
  122. package/bin/chunk-zf5cyxnt.js +2 -0
  123. package/bin/shumai-app.html +1 -1
  124. package/bin/shumai-app.js +402 -397
  125. package/package.json +7 -7
  126. package/prisma/migrations/20261008134859_add_transcode_3d/migration.sql +2 -0
  127. package/prisma/schema.prisma +1 -0
  128. package/bin/chunk-12npypek.js +0 -2
  129. package/bin/chunk-13d525jm.js +0 -2
  130. package/bin/chunk-1yt1gsyy.js +0 -2
  131. package/bin/chunk-3ewmtf1c.js +0 -1
  132. package/bin/chunk-3xw70yr4.js +0 -2
  133. package/bin/chunk-5seey9ee.js +0 -2
  134. package/bin/chunk-66hdwm6f.js +0 -2
  135. package/bin/chunk-756mr32b.js +0 -2
  136. package/bin/chunk-7wb3dga5.js +0 -2
  137. package/bin/chunk-9k86d2a3.js +0 -4
  138. package/bin/chunk-9wk11jtz.js +0 -1
  139. package/bin/chunk-a1crhhzy.js +0 -1
  140. package/bin/chunk-axfwh5et.js +0 -2
  141. package/bin/chunk-cgsxyw07.js +0 -2
  142. package/bin/chunk-dckdnqc0.js +0 -2
  143. package/bin/chunk-dx0wz749.js +0 -211
  144. package/bin/chunk-dz4fdrmk.js +0 -1
  145. package/bin/chunk-hz9stgvn.js +0 -1
  146. package/bin/chunk-hzr8100w.js +0 -3
  147. package/bin/chunk-jb6d142z.js +0 -1
  148. package/bin/chunk-k9cgfzgk.js +0 -3
  149. package/bin/chunk-meyvvmgk.js +0 -1
  150. package/bin/chunk-n1b3pt17.js +0 -14
  151. package/bin/chunk-n5v48hz5.js +0 -2
  152. package/bin/chunk-phzemmmy.js +0 -2
  153. package/bin/chunk-qhzat67w.js +0 -2
  154. package/bin/chunk-smcn7ep7.js +0 -2
  155. package/bin/chunk-tf8q7h6b.js +0 -1
  156. package/bin/chunk-tvr5rm1g.js +0 -1
  157. package/bin/chunk-ty88m3yg.js +0 -2
  158. package/bin/chunk-v2x9915x.js +0 -1
  159. package/bin/chunk-vnk2p7mq.css +0 -1
  160. package/bin/chunk-x8hky9td.js +0 -1
  161. package/bin/chunk-y12ah7c6.js +0 -1
  162. package/bin/chunk-y7jz31ay.js +0 -1
  163. package/bin/chunk-ydk3edsw.js +0 -1
  164. package/bin/chunk-zbma2zeh.js +0 -1
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{On,Qt,qo,ks,ai,li,Kt,Mr,p,vc,Fn,je,Sn,ym,Po,yf,Bt,us,No,kr,Ho,Du}from"./chunk-0yv0nnmh.js";function dr(e){return Mr(e)&&Kt(e.toOperationNode)}var qr=p({is(e){return e.kind==="ValueNode"},create(e){return p({kind:"ValueNode",value:e})},createImmediate(e){return p({kind:"ValueNode",value:e,immediate:!0})}});var l=p({is(e){return e.kind==="AliasNode"},create(e,r){return p({kind:"AliasNode",node:e,alias:r})}});var Zt=p({is(e){return e.kind==="ColumnNode"},create(e){return p({kind:"ColumnNode",column:je.create(e)})}});var rl=p({is(e){return e.kind==="SelectAllNode"},create(){return p({kind:"SelectAllNode"})}});var te=p({is(e){return e.kind==="ReferenceNode"},create(e,r){return p({kind:"ReferenceNode",table:r,column:e})},createSelectAll(e){return p({kind:"ReferenceNode",table:e,column:rl.create()})}});var g=p({is(e){return e.kind==="TableNode"},create(e){return p({kind:"TableNode",table:Sn.create(e)})},createWithSchema(e,r){return p({kind:"TableNode",table:Sn.createWithSchema(e,r)})}});function Re(e){return Mr(e)&&"expressionType"in e&&dr(e)}function Wr(e){return Mr(e)&&"expression"in e&&Qt(e.alias)&&dr(e)}var D=p({is(e){return e.kind==="SelectModifierNode"},create(e,r){return p({kind:"SelectModifierNode",modifier:e,of:r})},createWithExpression(e){return p({kind:"SelectModifierNode",rawModifier:e})}});var W=p({is(e){return e.kind==="AndNode"},create(e,r){return p({kind:"AndNode",left:e,right:r})}});var C=p({is(e){return e.kind==="OrNode"},create(e,r){return p({kind:"OrNode",left:e,right:r})}});var Te=p({is(e){return e.kind==="OnNode"},create(e){return p({kind:"OnNode",on:e})},cloneWithOperation(e,r,t){return p({...e,on:r==="And"?W.create(e.on,t):C.create(e.on,t)})}});var R=p({is(e){return e.kind==="JoinNode"},create(e,r){return p({kind:"JoinNode",joinType:e,table:r,on:void 0})},createWithOn(e,r,t){return p({kind:"JoinNode",joinType:e,table:r,on:Te.create(t)})},cloneWithOn(e,r){return p({...e,on:e.on?Te.cloneWithOperation(e.on,"And",r):Te.create(r)})}});var I=p({is(e){return e.kind==="BinaryOperationNode"},create(e,r,t){return p({kind:"BinaryOperationNode",leftOperand:e,operator:r,rightOperand:t})}});var Ae=p({is(e){return e.kind==="PrimitiveValueListNode"},create(e){return p({kind:"PrimitiveValueListNode",values:p([...e])})}});var $i=p({is(e){return e.kind==="ValueListNode"},create(e){return p({kind:"ValueListNode",values:p(e)})}});function br(e){if(Fn(e))return wt(e);return m(e)}function m(e){if(V(e))return ho(e);return qr.create(e)}function qe(e){return qo(e)||ks(e)||ai(e)}function le(e){if(!qe(e))throw Error(`unsafe immediate value ${JSON.stringify(e)}`);return qr.createImmediate(e)}function wt(e){if(e.some(V))return $i.create(e.map((r)=>m(r)));return Ae.create(e)}function sr(e){if(e.length===3)return Le(e[0],e[1],e[2]);else if(e.length===1)return m(e[0]);throw Error(`invalid arguments: ${JSON.stringify(e)}`)}function Le(e,r,t){if(Ot(r)&&Er(t))return I.create(w(e),Ie(r),qr.createImmediate(t));return I.create(w(e),Ie(r),br(t))}function N(e,r,t){return I.create(w(e),Ie(r),w(t))}function $e(e,r){return oe(Object.entries(e).filter(([,t])=>!On(t)).map(([t,o])=>Le(t,Er(o)?"is":"=",o)),r)}function oe(e,r,t=!0){let o=r==="and"?W.create:C.create;if(e.length===0)return I.create(qr.createImmediate(1),Po.create("="),qr.createImmediate(r==="and"?1:0));let n=Sr(e[0]);for(let u=1;u<e.length;++u)n=o(n,Sr(e[u]));if(e.length>1&&t)return No.create(n);return n}function Ot(e){return e==="is"||e==="is not"}function Er(e){return ai(e)||ks(e)}function Ie(e){if(Qt(e)&&ym.includes(e))return Po.create(e);if(dr(e))return e.toOperationNode();throw Error(`invalid operator ${JSON.stringify(e)}`)}function Sr(e){return dr(e)?e.toOperationNode():e}var U=p({is(e){return e.kind==="OrderByNode"},create(e){return p({kind:"OrderByNode",items:p([...e])})},cloneWithItems(e,r){return p({...e,items:p([...e.items,...r])})}});var _e=p({is(e){return e.kind==="PartitionByNode"},create(e){return p({kind:"PartitionByNode",items:p(e)})},cloneWithItems(e,r){return p({...e,items:p([...e.items,...r])})}});var Ne=p({is(e){return e.kind==="OverNode"},create(){return p({kind:"OverNode"})},cloneWithOrderByItems(e,r){return p({...e,orderBy:e.orderBy?U.cloneWithItems(e.orderBy,r):U.create(r)})},cloneWithPartitionByItems(e,r){return p({...e,partitionBy:e.partitionBy?_e.cloneWithItems(e.partitionBy,r):_e.create(r)})}});var X=p({is(e){return e.kind==="FromNode"},create(e){return p({kind:"FromNode",froms:p(e)})},cloneWithFroms(e,r){return p({...e,froms:p([...e.froms,...r])})}});var Ge=p({is(e){return e.kind==="GroupByNode"},create(e){return p({kind:"GroupByNode",items:p(e)})},cloneWithItems(e,r){return p({...e,items:p([...e.items,...r])})}});var Ke=p({is(e){return e.kind==="HavingNode"},create(e){return p({kind:"HavingNode",having:e})},cloneWithOperation(e,r,t){return p({...e,having:r==="And"?W.create(e.having,t):C.create(e.having,t)})}});var Be=p({is(e){return e.kind==="ListNode"},create(e){return p({kind:"ListNode",items:p(e)})}});var F=p({is(e){return e.kind==="UpdateQueryNode"},create(e,r){return p({kind:"UpdateQueryNode",table:e.length===1?e[0]:Be.create(e),...r&&{with:r}})},createWithoutTable(){return p({kind:"UpdateQueryNode"})},cloneWithFromItems(e,r){return p({...e,from:e.from?X.cloneWithFroms(e.from,r):X.create(r)})},cloneWithUpdates(e,r){return p({...e,updates:e.updates?p([...e.updates,...r]):r})},cloneWithLimit(e,r){return p({...e,limit:r})}});var ye=p({is(e){return e.kind==="UsingNode"},create(e){return p({kind:"UsingNode",tables:p(e)})},cloneWithTables(e,r){return p({...e,tables:p([...e.tables,...r])})}});var _=p({is(e){return e.kind==="DeleteQueryNode"},create(e,r){return p({kind:"DeleteQueryNode",from:X.create(e),...r&&{with:r}})},cloneWithOrderByItems:(e,r)=>de.cloneWithOrderByItems(e,r),cloneWithoutOrderBy:(e)=>de.cloneWithoutOrderBy(e),cloneWithLimit(e,r){return p({...e,limit:r})},cloneWithoutLimit(e){return p({...e,limit:void 0})},cloneWithUsing(e,r){return p({...e,using:e.using!==void 0?ye.cloneWithTables(e.using,r):ye.create(r)})}});var O=p({is(e){return e.kind==="WhereNode"},create(e){return p({kind:"WhereNode",where:e})},cloneWithOperation(e,r,t){return p({...e,where:r==="And"?W.create(e.where,t):C.create(e.where,t)})}});var He=p({is(e){return e.kind==="ReturningNode"},create(e){return p({kind:"ReturningNode",selections:p(e)})},cloneWithSelections(e,r){return p({...e,selections:e.selections?p([...e.selections,...r]):p(r)})}});var Cr=p({is(e){return e.kind==="ExplainNode"},create(e,r){return p({kind:"ExplainNode",format:e,options:r})}});var k=p({is(e){return e.kind==="MergeQueryNode"},create(e,r){return p({kind:"MergeQueryNode",into:e,...r&&{with:r}})},cloneWithUsing(e,r){return p({...e,using:r})},cloneWithWhen(e,r){return p({...e,whens:e.whens?p([...e.whens,r]):p([r])})},cloneWithThen(e,r){return p({...e,whens:e.whens?p([...e.whens.slice(0,-1),Ho.cloneWithResult(e.whens[e.whens.length-1],r)]):void 0})}});var Xe=p({is(e){return e.kind==="OutputNode"},create(e){return p({kind:"OutputNode",selections:p(e)})},cloneWithSelections(e,r){return p({...e,selections:e.selections?p([...e.selections,...r]):p(r)})}});var de=p({is(e){return Gt.is(e)||kr.is(e)||F.is(e)||_.is(e)||k.is(e)},cloneWithEndModifier(e,r){return p({...e,endModifiers:e.endModifiers?p([...e.endModifiers,r]):p([r])})},cloneWithWhere(e,r){return p({...e,where:e.where?O.cloneWithOperation(e.where,"And",r):O.create(r)})},cloneWithJoin(e,r){return p({...e,joins:e.joins?p([...e.joins,r]):p([r])})},cloneWithReturning(e,r){return p({...e,returning:e.returning?He.cloneWithSelections(e.returning,r):He.create(r)})},cloneWithoutReturning(e){return p({...e,returning:void 0})},cloneWithoutWhere(e){return p({...e,where:void 0})},cloneWithExplain(e,r,t){return p({...e,explain:Cr.create(r,t?.toOperationNode())})},cloneWithTop(e,r){return p({...e,top:r})},cloneWithOutput(e,r){return p({...e,output:e.output?Xe.cloneWithSelections(e.output,r):Xe.create(r)})},cloneWithOrderByItems(e,r){return p({...e,orderBy:e.orderBy?U.cloneWithItems(e.orderBy,r):U.create(r)})},cloneWithoutOrderBy(e){return p({...e,orderBy:void 0})}});var Gt=p({is(e){return e.kind==="SelectQueryNode"},create(e){return p({kind:"SelectQueryNode",...e&&{with:e}})},createFrom(e,r){return p({kind:"SelectQueryNode",from:X.create(e),...r&&{with:r}})},cloneWithSelections(e,r){return p({...e,selections:e.selections?p([...e.selections,...r]):p(r)})},cloneWithDistinctOn(e,r){return p({...e,distinctOn:e.distinctOn?p([...e.distinctOn,...r]):p(r)})},cloneWithFrontModifier(e,r){return p({...e,frontModifiers:e.frontModifiers?p([...e.frontModifiers,r]):p([r])})},cloneWithOrderByItems:(e,r)=>de.cloneWithOrderByItems(e,r),cloneWithGroupByItems(e,r){return p({...e,groupBy:e.groupBy?Ge.cloneWithItems(e.groupBy,r):Ge.create(r)})},cloneWithLimit(e,r){return p({...e,limit:r})},cloneWithOffset(e,r){return p({...e,offset:r})},cloneWithFetch(e,r){return p({...e,fetch:r})},cloneWithHaving(e,r){return p({...e,having:e.having?Ke.cloneWithOperation(e.having,"And",r):Ke.create(r)})},cloneWithSetOperations(e,r){return p({...e,setOperations:e.setOperations?p([...e.setOperations,...r]):p([...r])})},cloneWithoutSelections(e){return p({...e,selections:[]})},cloneWithoutLimit(e){return p({...e,limit:void 0})},cloneWithoutOffset(e){return p({...e,offset:void 0})},cloneWithoutOrderBy:(e)=>de.cloneWithoutOrderBy(e),cloneWithoutGroupBy(e){return p({...e,groupBy:void 0})}});class ie{#e;constructor(e){this.#e=p(e)}on(...e){return new ie({...this.#e,joinNode:R.cloneWithOn(this.#e.joinNode,sr(e))})}onRef(e,r,t){return new ie({...this.#e,joinNode:R.cloneWithOn(this.#e.joinNode,N(e,r,t))})}onTrue(){return new ie({...this.#e,joinNode:R.cloneWithOn(this.#e.joinNode,Bt.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#e.joinNode}}class gf{#e;get dynamicReference(){return this.#e}get refType(){return}constructor(e){this.#e=e}toOperationNode(){return Ze(this.#e)}}function De(e){return Mr(e)&&dr(e)&&Qt(e.dynamicReference)}var T=p({is(e){return e.kind==="OrderByItemNode"},create(e,r){return p({kind:"OrderByItemNode",orderBy:e,direction:r})},cloneWith(e,r){return p({...e,...r})}});var Rr=p({is(e){return e.kind==="CollateNode"},create(e){return p({kind:"CollateNode",collation:je.create(e)})}});class j{#e;constructor(e){this.#e=p(e)}desc(){return new j({node:T.cloneWith(this.#e.node,{direction:Bt.createWithSql("desc")})})}asc(){return new j({node:T.cloneWith(this.#e.node,{direction:Bt.createWithSql("asc")})})}nullsLast(){return new j({node:T.cloneWith(this.#e.node,{nulls:"last"})})}nullsFirst(){return new j({node:T.cloneWith(this.#e.node,{nulls:"first"})})}collate(e){return new j({node:T.cloneWith(this.#e.node,{collation:Rr.create(e)})})}toOperationNode(){return this.#e.node}}function rr(e){return e==="asc"||e==="desc"}function E(e){if(e.length===2)return[er(e[0],e[1])];if(e.length===1){let[r]=e;if(Array.isArray(r))return us("orderBy(array) is deprecated, use multiple orderBy calls instead."),r.map((t)=>er(t));return[er(r)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${e.length}`)}function er(e,r){let t=xt(e);if(T.is(t)){if(r)throw Error("Cannot specify direction twice!");return t}return Tr(t,r)}function xt(e){if(V(e))return ho(e);if(De(e))return e.toOperationNode();let[r,t]=e.split(" ");if(t)return us("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),Tr(ko(r),t);return ko(e)}function Tr(e,r){if(typeof r==="string"){if(!rr(r))throw Error(`Invalid order by direction: ${r}`);return T.create(e,Bt.createWithSql(r))}if(Re(r))return us("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),T.create(e,r.toOperationNode());let t=T.create(e);if(!r)return t;return r(new j({node:t})).toOperationNode()}var Ar=p({is(e){return e.kind==="PartitionByItemNode"},create(e){return p({kind:"PartitionByItemNode",partitionBy:e})}});function Lr(e){return z(e).map(Ar.create)}class ne{#e;constructor(e){this.#e=p(e)}orderBy(...e){return new ne({overNode:Ne.cloneWithOrderByItems(this.#e.overNode,E(e))})}clearOrderBy(){return new ne({overNode:de.cloneWithoutOrderBy(this.#e.overNode)})}partitionBy(e){return new ne({overNode:Ne.cloneWithPartitionByItems(this.#e.overNode,Lr(e))})}$call(e){return e(this)}toOperationNode(){return this.#e.overNode}}var se=p({is(e){return e.kind==="SelectionNode"},create(e){return p({kind:"SelectionNode",selection:e})},createSelectAll(){return p({kind:"SelectionNode",selection:rl.create()})},createSelectAllFromTable(e){return p({kind:"SelectionNode",selection:te.createSelectAll(e)})}});class _f{#e;get table(){return this.#e}constructor(e){this.#e=e}as(e){return new Br(this.#e,e)}}class Br{#e;#r;get table(){return this.#e}get alias(){return this.#r}constructor(e,r){this.#e=e,this.#r=r}toOperationNode(){return l.create(zt(this.#e),je.create(this.#r))}}function Dr(e){return Mr(e)&&dr(e)&&Qt(e.table)&&Qt(e.alias)}function A(e){if(Fn(e))return e.map((r)=>Y(r));else return[Y(e)]}function Y(e){if(Qt(e))return tr(e);else if(Dr(e))return e.toOperationNode();else return Fe(e)}function tr(e){if(e.includes(" as ")){let[t,o]=e.split(" as ").map(Fr);return l.create(zt(t),je.create(o))}else return zt(e)}function zt(e){if(e.includes(".")){let[t,o]=e.split(".").map(Fr);return g.createWithSchema(t,o)}else return g.create(e)}function Fr(e){return e.trim()}function f(e){if(Kt(e))return f(e(q()));else if(Fn(e))return e.map((r)=>vr(r));else return[vr(e)]}function vr(e){if(Qt(e))return se.create(Vr(e));else if(De(e))return se.create(e.toOperationNode());else return se.create(Fe(e))}function y(e){if(!e)return[se.createSelectAll()];else if(Array.isArray(e))return e.map(Pr);else return[Pr(e)]}function Pr(e){if(Qt(e))return se.createSelectAllFromTable(zt(e));throw Error(`invalid value selectAll expression: ${JSON.stringify(e)}`)}var Ur=p({is(e){return e.kind==="ValuesNode"},create(e){return p({kind:"ValuesNode",values:p(e)})}});var zr=p({is(e){return e.kind==="DefaultInsertValueNode"},create(){return p({kind:"DefaultInsertValueNode"})}});function ve(e){let r=Kt(e)?e(q()):e,t=Fn(r)?r:p([r]);return gt(t)}function gt(e){let r=Wt(e);return[p([...r.keys()].map(Zt.create)),Ur.create(e.map((t)=>bt(t,r)))]}function Wt(e){let r=new Map;for(let t of e){let o=Object.keys(t);for(let n of o)if(!r.has(n)&&t[n]!==void 0)r.set(n,r.size)}return r}function bt(e,r){let t=Object.keys(e),o=Array.from({length:r.size}),n=!1,u=t.length;for(let Ce of t){let pe=r.get(Ce);if(On(pe)){u--;continue}let Qe=e[Ce];if(On(Qe)||V(Qe))n=!0;o[pe]=Qe}if(u<r.size||n){let Ce=zr.create();return $i.create(o.map((pe)=>On(pe)?Ce:m(pe)))}return Ae.create(o)}var or=p({is(e){return e.kind==="ColumnUpdateNode"},create(e,r){return p({kind:"ColumnUpdateNode",column:e,value:r})}});function Jr(...e){if(e.length===2)return[or.create(w(e[0]),m(e[1]))];return we(e[0])}function we(e){let r=Kt(e)?e(q()):e;return Object.entries(r).filter(([t,o])=>o!==void 0).map(([t,o])=>or.create(Zt.create(t),m(o)))}var Qr=p({is(e){return e.kind==="OnDuplicateKeyNode"},create(e){return p({kind:"OnDuplicateKeyNode",updates:e})}});class ir{insertId;numInsertedOrUpdatedRows;constructor(e,r){this.insertId=e,this.numInsertedOrUpdatedRows=r}}class L extends Error{node;constructor(e){super("no result");this.node=e}}function v(e){return Object.prototype.hasOwnProperty.call(e,"prototype")}var x=p({is(e){return e.kind==="OnConflictNode"},create(){return p({kind:"OnConflictNode"})},cloneWith(e,r){return p({...e,...r})},cloneWithIndexWhere(e,r){return p({...e,indexWhere:e.indexWhere?O.cloneWithOperation(e.indexWhere,"And",r):O.create(r)})},cloneWithIndexOrWhere(e,r){return p({...e,indexWhere:e.indexWhere?O.cloneWithOperation(e.indexWhere,"Or",r):O.create(r)})},cloneWithUpdateWhere(e,r){return p({...e,updateWhere:e.updateWhere?O.cloneWithOperation(e.updateWhere,"And",r):O.create(r)})},cloneWithUpdateOrWhere(e,r){return p({...e,updateWhere:e.updateWhere?O.cloneWithOperation(e.updateWhere,"Or",r):O.create(r)})},cloneWithoutIndexWhere(e){return p({...e,indexWhere:void 0})},cloneWithoutUpdateWhere(e){return p({...e,updateWhere:void 0})}});class P{#e;constructor(e){this.#e=p(e)}column(e){let r=Zt.create(e);return new P({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?p([...this.#e.onConflictNode.columns,r]):p([r])})})}columns(e){let r=e.map(Zt.create);return new P({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?p([...this.#e.onConflictNode.columns,...r]):p(r)})})}constraint(e){return new P({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{constraint:je.create(e)})})}expression(e){return new P({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new P({...this.#e,onConflictNode:x.cloneWithIndexWhere(this.#e.onConflictNode,sr(e))})}whereRef(e,r,t){return new P({...this.#e,onConflictNode:x.cloneWithIndexWhere(this.#e.onConflictNode,N(e,r,t))})}clearWhere(){return new P({...this.#e,onConflictNode:x.cloneWithoutIndexWhere(this.#e.onConflictNode)})}doNothing(){return new Ir({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new xe({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{updates:we(e)})})}$call(e){return e(this)}}class Ir{#e;constructor(e){this.#e=p(e)}toOperationNode(){return this.#e.onConflictNode}}class xe{#e;constructor(e){this.#e=p(e)}where(...e){return new xe({...this.#e,onConflictNode:x.cloneWithUpdateWhere(this.#e.onConflictNode,sr(e))})}whereRef(e,r,t){return new xe({...this.#e,onConflictNode:x.cloneWithUpdateWhere(this.#e.onConflictNode,N(e,r,t))})}clearWhere(){return new xe({...this.#e,onConflictNode:x.cloneWithoutUpdateWhere(this.#e.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#e.onConflictNode}}var $r=p({is(e){return e.kind==="TopNode"},create(e,r){return p({kind:"TopNode",expression:e,modifiers:r})}});function B(e,r){if(!qo(e)&&!li(e))throw Error(`Invalid top expression: ${e}`);if(!On(r)&&!St(r))throw Error(`Invalid top modifiers: ${r}`);return $r.create(e,r)}function St(e){return e==="percent"||e==="with ties"||e==="percent with ties"}var Z=p({is(e){return e.kind==="OrActionNode"},create(e){return p({kind:"OrActionNode",action:e})}});class d{#e;constructor(e){this.#e=p(e)}values(e){let[r,t]=ve(e);return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{columns:r,values:t})})}columns(e){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{columns:p(e.map(Zt.create))})})}expression(e){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{values:ho(e)})})}defaultValues(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{defaultValues:!0})})}modifyEnd(e){return new d({...this.#e,queryNode:de.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}ignore(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{orAction:Z.create("ignore")})})}orIgnore(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{orAction:Z.create("ignore")})})}orAbort(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{orAction:Z.create("abort")})})}orFail(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{orAction:Z.create("fail")})})}orReplace(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{orAction:Z.create("replace")})})}orRollback(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{orAction:Z.create("rollback")})})}top(e,r){return new d({...this.#e,queryNode:de.cloneWithTop(this.#e.queryNode,B(e,r))})}onConflict(e){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{onConflict:e(new P({onConflictNode:x.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{onDuplicateKey:Qr.create(we(e))})})}returning(e){return new d({...this.#e,queryNode:de.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(){return new d({...this.#e,queryNode:de.cloneWithReturning(this.#e.queryNode,y())})}output(e){return new d({...this.#e,queryNode:de.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new d({...this.#e,queryNode:de.cloneWithOutput(this.#e.queryNode,y(e))})}clearReturning(){return new d({...this.#e,queryNode:de.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new d({...this.#e})}$castTo(){return new d(this.#e)}$narrowType(){return new d(this.#e)}$assertType(){return new d(this.#e)}withPlugin(e){return new d({...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(),r=await this.#e.executor.executeQuery(e),{adapter:t}=this.#e.executor,o=e.query;if(o.returning&&t.supportsReturning||o.output&&t.supportsOutput)return r.rows;return[new ir(r.insertId,r.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=L){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){let r=this.compile(),t=this.#e.executor.stream(r,e);for await(let o of t)yield*o.rows}async explain(e,r){return await new d({...this.#e,queryNode:de.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}class nr{numDeletedRows;constructor(e){this.numDeletedRows=e}}var ae=p({is(e){return e.kind==="LimitNode"},create(e){return p({kind:"LimitNode",limit:e})}});var c;class Pe{#e;constructor(e){this.#e=p(e)}where(...e){return new c({...this.#e,queryNode:de.cloneWithWhere(this.#e.queryNode,sr(e))})}whereRef(e,r,t){return new c({...this.#e,queryNode:de.cloneWithWhere(this.#e.queryNode,N(e,r,t))})}clearWhere(){return new c({...this.#e,queryNode:de.cloneWithoutWhere(this.#e.queryNode)})}top(e,r){return new c({...this.#e,queryNode:de.cloneWithTop(this.#e.queryNode,B(e,r))})}using(e){return new c({...this.#e,queryNode:_.cloneWithUsing(this.#e.queryNode,A(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,r){return new c({...this.#e,queryNode:de.cloneWithJoin(this.#e.queryNode,G(e,r))})}returning(e){return new c({...this.#e,queryNode:de.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(e){return new c({...this.#e,queryNode:de.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new c({...this.#e,queryNode:de.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new c({...this.#e,queryNode:de.cloneWithOutput(this.#e.queryNode,y(e))})}clearReturning(){return new c({...this.#e,queryNode:de.cloneWithoutReturning(this.#e.queryNode)})}clearLimit(){return new c({...this.#e,queryNode:_.cloneWithoutLimit(this.#e.queryNode)})}orderBy(...e){return new c({...this.#e,queryNode:de.cloneWithOrderByItems(this.#e.queryNode,E(e))})}clearOrderBy(){return new c({...this.#e,queryNode:de.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new c({...this.#e,queryNode:_.cloneWithLimit(this.#e.queryNode,ae.create(m(e)))})}modifyEnd(e){return new c({...this.#e,queryNode:de.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new c({...this.#e})}$castTo(){return new c(this.#e)}$narrowType(){return new c(this.#e)}$assertType(){return new c(this.#e)}withPlugin(e){return new c({...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(),r=await this.#e.executor.executeQuery(e),{adapter:t}=this.#e.executor,o=e.query;if(o.returning&&t.supportsReturning||o.output&&t.supportsOutput)return r.rows;return[new nr(r.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=L){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){let r=this.compile(),t=this.#e.executor.stream(r,e);for await(let o of t)yield*o.rows}async explain(e,r){return await new c({...this.#e,queryNode:de.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}c=Pe;class ar{numUpdatedRows;numChangedRows;constructor(e,r){this.numUpdatedRows=e,this.numChangedRows=r}}var h;class ue{#e;constructor(e){this.#e=p(e)}where(...e){return new h({...this.#e,queryNode:de.cloneWithWhere(this.#e.queryNode,sr(e))})}whereRef(e,r,t){return new h({...this.#e,queryNode:de.cloneWithWhere(this.#e.queryNode,N(e,r,t))})}clearWhere(){return new h({...this.#e,queryNode:de.cloneWithoutWhere(this.#e.queryNode)})}top(e,r){return new h({...this.#e,queryNode:de.cloneWithTop(this.#e.queryNode,B(e,r))})}from(e){return new h({...this.#e,queryNode:F.cloneWithFromItems(this.#e.queryNode,A(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,r){return new h({...this.#e,queryNode:de.cloneWithJoin(this.#e.queryNode,G(e,r))})}orderBy(...e){return new h({...this.#e,queryNode:de.cloneWithOrderByItems(this.#e.queryNode,E(e))})}clearOrderBy(){return new h({...this.#e,queryNode:de.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new h({...this.#e,queryNode:F.cloneWithLimit(this.#e.queryNode,ae.create(m(e)))})}set(...e){return new h({...this.#e,queryNode:F.cloneWithUpdates(this.#e.queryNode,Jr(...e))})}returning(e){return new h({...this.#e,queryNode:de.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(e){return new h({...this.#e,queryNode:de.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new h({...this.#e,queryNode:de.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new h({...this.#e,queryNode:de.cloneWithOutput(this.#e.queryNode,y(e))})}modifyEnd(e){return new h({...this.#e,queryNode:de.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}clearReturning(){return new h({...this.#e,queryNode:de.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new h({...this.#e})}$castTo(){return new h(this.#e)}$narrowType(){return new h(this.#e)}$assertType(){return new h(this.#e)}withPlugin(e){return new h({...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(),r=await this.#e.executor.executeQuery(e),{adapter:t}=this.#e.executor,o=e.query;if(o.returning&&t.supportsReturning||o.output&&t.supportsOutput)return r.rows;return[new ar(r.numAffectedRows??BigInt(0),r.numChangedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=L){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){let r=this.compile(),t=this.#e.executor.stream(r,e);for await(let o of t)yield*o.rows}async explain(e,r){return await new h({...this.#e,queryNode:de.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}h=ue;var ur=p({is(e){return e.kind==="CommonTableExpressionNameNode"},create(e,r){return p({kind:"CommonTableExpressionNameNode",table:g.create(e),columns:r?p(r.map(Zt.create)):void 0})}});var me=p({is(e){return e.kind==="CommonTableExpressionNode"},create(e,r){return p({kind:"CommonTableExpressionNode",name:e,expression:r})},cloneWith(e,r){return p({...e,...r})}});class ge{#e;constructor(e){this.#e=p(e)}materialized(){return new ge({...this.#e,node:me.cloneWith(this.#e.node,{materialized:!0})})}notMaterialized(){return new ge({...this.#e,node:me.cloneWith(this.#e.node,{materialized:!1})})}toOperationNode(){return this.#e.node}}function mr(e,r){let t=r(jr()).toOperationNode();if(Kt(e))return e(kt(t)).toOperationNode();return me.create(_r(e),t)}function kt(e){return(r)=>new ge({node:me.create(_r(r),e)})}function _r(e){if(e.includes("(")){let r=e.split(/[\(\)]/),t=r[0],o=r[1].split(",").map((n)=>n.trim());return ur.create(t,o)}else return ur.create(e)}var We=p({is(e){return e.kind==="WithNode"},create(e,r){return p({kind:"WithNode",expressions:p([e]),...r})},cloneWithExpression(e,r){return p({...e,expressions:p([...e.expressions,r])})}});var Gr=["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 ku(e){let r="";for(let t=0;t<e;++t)r+=Et();return r}function Et(){return Gr[~~(Math.random()*Gr.length)]}function Ye(){return new Kr}class Kr{#e;get queryId(){if(this.#e===void 0)this.#e=ku(8);return this.#e}}function i(e){return e}class _c{nodeStack=[];#e=p({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,r){if(!e)return e;this.nodeStack.push(e);let t=this.transformNodeImpl(e,r);return this.nodeStack.pop(),p(t)}transformNodeImpl(e,r){return this.#e[e.kind](e,r)}transformNodeList(e,r){if(!e)return e;return p(e.map((t)=>this.transformNode(t,r)))}transformSelectQuery(e,r){return i({kind:"SelectQueryNode",from:this.transformNode(e.from,r),selections:this.transformNodeList(e.selections,r),distinctOn:this.transformNodeList(e.distinctOn,r),joins:this.transformNodeList(e.joins,r),groupBy:this.transformNode(e.groupBy,r),orderBy:this.transformNode(e.orderBy,r),where:this.transformNode(e.where,r),frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),limit:this.transformNode(e.limit,r),offset:this.transformNode(e.offset,r),with:this.transformNode(e.with,r),having:this.transformNode(e.having,r),explain:this.transformNode(e.explain,r),setOperations:this.transformNodeList(e.setOperations,r),fetch:this.transformNode(e.fetch,r),top:this.transformNode(e.top,r)})}transformSelection(e,r){return i({kind:"SelectionNode",selection:this.transformNode(e.selection,r)})}transformColumn(e,r){return i({kind:"ColumnNode",column:this.transformNode(e.column,r)})}transformAlias(e,r){return i({kind:"AliasNode",node:this.transformNode(e.node,r),alias:this.transformNode(e.alias,r)})}transformTable(e,r){return i({kind:"TableNode",table:this.transformNode(e.table,r)})}transformFrom(e,r){return i({kind:"FromNode",froms:this.transformNodeList(e.froms,r)})}transformReference(e,r){return i({kind:"ReferenceNode",column:this.transformNode(e.column,r),table:this.transformNode(e.table,r)})}transformAnd(e,r){return i({kind:"AndNode",left:this.transformNode(e.left,r),right:this.transformNode(e.right,r)})}transformOr(e,r){return i({kind:"OrNode",left:this.transformNode(e.left,r),right:this.transformNode(e.right,r)})}transformValueList(e,r){return i({kind:"ValueListNode",values:this.transformNodeList(e.values,r)})}transformParens(e,r){return i({kind:"ParensNode",node:this.transformNode(e.node,r)})}transformJoin(e,r){return i({kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,r),on:this.transformNode(e.on,r)})}transformRaw(e,r){return i({kind:"RawNode",sqlFragments:p([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,r)})}transformWhere(e,r){return i({kind:"WhereNode",where:this.transformNode(e.where,r)})}transformInsertQuery(e,r){return i({kind:"InsertQueryNode",into:this.transformNode(e.into,r),columns:this.transformNodeList(e.columns,r),values:this.transformNode(e.values,r),returning:this.transformNode(e.returning,r),onConflict:this.transformNode(e.onConflict,r),onDuplicateKey:this.transformNode(e.onDuplicateKey,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),ignore:e.ignore,orAction:this.transformNode(e.orAction,r),replace:e.replace,explain:this.transformNode(e.explain,r),defaultValues:e.defaultValues,top:this.transformNode(e.top,r),output:this.transformNode(e.output,r)})}transformValues(e,r){return i({kind:"ValuesNode",values:this.transformNodeList(e.values,r)})}transformDeleteQuery(e,r){return i({kind:"DeleteQueryNode",from:this.transformNode(e.from,r),using:this.transformNode(e.using,r),joins:this.transformNodeList(e.joins,r),where:this.transformNode(e.where,r),returning:this.transformNode(e.returning,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),orderBy:this.transformNode(e.orderBy,r),limit:this.transformNode(e.limit,r),explain:this.transformNode(e.explain,r),top:this.transformNode(e.top,r),output:this.transformNode(e.output,r)})}transformReturning(e,r){return i({kind:"ReturningNode",selections:this.transformNodeList(e.selections,r)})}transformCreateTable(e,r){return i({kind:"CreateTableNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),constraints:this.transformNodeList(e.constraints,r),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),selectQuery:this.transformNode(e.selectQuery,r)})}transformColumnDefinition(e,r){return i({kind:"ColumnDefinitionNode",column:this.transformNode(e.column,r),dataType:this.transformNode(e.dataType,r),references:this.transformNode(e.references,r),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,r),check:this.transformNode(e.check,r),generated:this.transformNode(e.generated,r),frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists})}transformAddColumn(e,r){return i({kind:"AddColumnNode",column:this.transformNode(e.column,r)})}transformDropTable(e,r){return i({kind:"DropTableNode",table:this.transformNode(e.table,r),ifExists:e.ifExists,cascade:e.cascade})}transformOrderBy(e,r){return i({kind:"OrderByNode",items:this.transformNodeList(e.items,r)})}transformOrderByItem(e,r){return i({kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,r),direction:this.transformNode(e.direction,r),collation:this.transformNode(e.collation,r),nulls:e.nulls})}transformGroupBy(e,r){return i({kind:"GroupByNode",items:this.transformNodeList(e.items,r)})}transformGroupByItem(e,r){return i({kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,r)})}transformUpdateQuery(e,r){return i({kind:"UpdateQueryNode",table:this.transformNode(e.table,r),from:this.transformNode(e.from,r),joins:this.transformNodeList(e.joins,r),where:this.transformNode(e.where,r),updates:this.transformNodeList(e.updates,r),returning:this.transformNode(e.returning,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),explain:this.transformNode(e.explain,r),limit:this.transformNode(e.limit,r),top:this.transformNode(e.top,r),output:this.transformNode(e.output,r),orderBy:this.transformNode(e.orderBy,r)})}transformColumnUpdate(e,r){return i({kind:"ColumnUpdateNode",column:this.transformNode(e.column,r),value:this.transformNode(e.value,r)})}transformLimit(e,r){return i({kind:"LimitNode",limit:this.transformNode(e.limit,r)})}transformOffset(e,r){return i({kind:"OffsetNode",offset:this.transformNode(e.offset,r)})}transformOnConflict(e,r){return i({kind:"OnConflictNode",columns:this.transformNodeList(e.columns,r),constraint:this.transformNode(e.constraint,r),indexExpression:this.transformNode(e.indexExpression,r),indexWhere:this.transformNode(e.indexWhere,r),updates:this.transformNodeList(e.updates,r),updateWhere:this.transformNode(e.updateWhere,r),doNothing:e.doNothing})}transformOnDuplicateKey(e,r){return i({kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,r)})}transformCreateIndex(e,r){return i({kind:"CreateIndexNode",name:this.transformNode(e.name,r),table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),unique:e.unique,using:this.transformNode(e.using,r),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,r),nullsNotDistinct:e.nullsNotDistinct})}transformList(e,r){return i({kind:"ListNode",items:this.transformNodeList(e.items,r)})}transformDropIndex(e,r){return i({kind:"DropIndexNode",name:this.transformNode(e.name,r),table:this.transformNode(e.table,r),ifExists:e.ifExists,cascade:e.cascade})}transformPrimaryKeyConstraint(e,r){return i({kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,r),name:this.transformNode(e.name,r),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred})}transformUniqueConstraint(e,r){return i({kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,r),name:this.transformNode(e.name,r),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred})}transformForeignKeyConstraint(e,r){return i({kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,r),references:this.transformNode(e.references,r),name:this.transformNode(e.name,r),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred})}transformSetOperation(e,r){return i({kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,r),all:e.all})}transformReferences(e,r){return i({kind:"ReferencesNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),onDelete:e.onDelete,onUpdate:e.onUpdate})}transformCheckConstraint(e,r){return i({kind:"CheckConstraintNode",expression:this.transformNode(e.expression,r),name:this.transformNode(e.name,r)})}transformWith(e,r){return i({kind:"WithNode",expressions:this.transformNodeList(e.expressions,r),recursive:e.recursive})}transformCommonTableExpression(e,r){return i({kind:"CommonTableExpressionNode",name:this.transformNode(e.name,r),materialized:e.materialized,expression:this.transformNode(e.expression,r)})}transformCommonTableExpressionName(e,r){return i({kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r)})}transformHaving(e,r){return i({kind:"HavingNode",having:this.transformNode(e.having,r)})}transformCreateSchema(e,r){return i({kind:"CreateSchemaNode",schema:this.transformNode(e.schema,r),ifNotExists:e.ifNotExists})}transformDropSchema(e,r){return i({kind:"DropSchemaNode",schema:this.transformNode(e.schema,r),ifExists:e.ifExists,cascade:e.cascade})}transformAlterTable(e,r){return i({kind:"AlterTableNode",table:this.transformNode(e.table,r),renameTo:this.transformNode(e.renameTo,r),setSchema:this.transformNode(e.setSchema,r),columnAlterations:this.transformNodeList(e.columnAlterations,r),addConstraint:this.transformNode(e.addConstraint,r),dropConstraint:this.transformNode(e.dropConstraint,r),renameConstraint:this.transformNode(e.renameConstraint,r),addIndex:this.transformNode(e.addIndex,r),dropIndex:this.transformNode(e.dropIndex,r)})}transformDropColumn(e,r){return i({kind:"DropColumnNode",column:this.transformNode(e.column,r)})}transformRenameColumn(e,r){return i({kind:"RenameColumnNode",column:this.transformNode(e.column,r),renameTo:this.transformNode(e.renameTo,r)})}transformAlterColumn(e,r){return i({kind:"AlterColumnNode",column:this.transformNode(e.column,r),dataType:this.transformNode(e.dataType,r),dataTypeExpression:this.transformNode(e.dataTypeExpression,r),setDefault:this.transformNode(e.setDefault,r),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull})}transformModifyColumn(e,r){return i({kind:"ModifyColumnNode",column:this.transformNode(e.column,r)})}transformAddConstraint(e,r){return i({kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,r)})}transformDropConstraint(e,r){return i({kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,r),ifExists:e.ifExists,modifier:e.modifier})}transformRenameConstraint(e,r){return i({kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,r),newName:this.transformNode(e.newName,r)})}transformCreateView(e,r){return i({kind:"CreateViewNode",name:this.transformNode(e.name,r),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,r),as:this.transformNode(e.as,r)})}transformRefreshMaterializedView(e,r){return i({kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,r),concurrently:e.concurrently,withNoData:e.withNoData})}transformDropView(e,r){return i({kind:"DropViewNode",name:this.transformNode(e.name,r),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade})}transformGenerated(e,r){return i({kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,r)})}transformDefaultValue(e,r){return i({kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,r)})}transformOn(e,r){return i({kind:"OnNode",on:this.transformNode(e.on,r)})}transformSelectModifier(e,r){return i({kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,r),of:this.transformNodeList(e.of,r)})}transformCreateType(e,r){return i({kind:"CreateTypeNode",name:this.transformNode(e.name,r),enum:this.transformNode(e.enum,r)})}transformDropType(e,r){return i({kind:"DropTypeNode",name:this.transformNode(e.name,r),ifExists:e.ifExists})}transformExplain(e,r){return i({kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,r)})}transformSchemableIdentifier(e,r){return i({kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,r),identifier:this.transformNode(e.identifier,r)})}transformAggregateFunction(e,r){return i({kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,r),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,r),withinGroup:this.transformNode(e.withinGroup,r),filter:this.transformNode(e.filter,r),over:this.transformNode(e.over,r)})}transformOver(e,r){return i({kind:"OverNode",orderBy:this.transformNode(e.orderBy,r),partitionBy:this.transformNode(e.partitionBy,r)})}transformPartitionBy(e,r){return i({kind:"PartitionByNode",items:this.transformNodeList(e.items,r)})}transformPartitionByItem(e,r){return i({kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,r)})}transformBinaryOperation(e,r){return i({kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,r),operator:this.transformNode(e.operator,r),rightOperand:this.transformNode(e.rightOperand,r)})}transformUnaryOperation(e,r){return i({kind:"UnaryOperationNode",operator:this.transformNode(e.operator,r),operand:this.transformNode(e.operand,r)})}transformUsing(e,r){return i({kind:"UsingNode",tables:this.transformNodeList(e.tables,r)})}transformFunction(e,r){return i({kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,r)})}transformCase(e,r){return i({kind:"CaseNode",value:this.transformNode(e.value,r),when:this.transformNodeList(e.when,r),else:this.transformNode(e.else,r),isStatement:e.isStatement})}transformWhen(e,r){return i({kind:"WhenNode",condition:this.transformNode(e.condition,r),result:this.transformNode(e.result,r)})}transformJSONReference(e,r){return i({kind:"JSONReferenceNode",reference:this.transformNode(e.reference,r),traversal:this.transformNode(e.traversal,r)})}transformJSONPath(e,r){return i({kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,r),pathLegs:this.transformNodeList(e.pathLegs,r)})}transformJSONPathLeg(e,r){return i({kind:"JSONPathLegNode",type:e.type,value:e.value})}transformJSONOperatorChain(e,r){return i({kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,r),values:this.transformNodeList(e.values,r)})}transformTuple(e,r){return i({kind:"TupleNode",values:this.transformNodeList(e.values,r)})}transformMergeQuery(e,r){return i({kind:"MergeQueryNode",into:this.transformNode(e.into,r),using:this.transformNode(e.using,r),whens:this.transformNodeList(e.whens,r),with:this.transformNode(e.with,r),top:this.transformNode(e.top,r),endModifiers:this.transformNodeList(e.endModifiers,r),output:this.transformNode(e.output,r),returning:this.transformNode(e.returning,r)})}transformMatched(e,r){return i({kind:"MatchedNode",not:e.not,bySource:e.bySource})}transformAddIndex(e,r){return i({kind:"AddIndexNode",name:this.transformNode(e.name,r),columns:this.transformNodeList(e.columns,r),unique:e.unique,using:this.transformNode(e.using,r),ifNotExists:e.ifNotExists})}transformCast(e,r){return i({kind:"CastNode",expression:this.transformNode(e.expression,r),dataType:this.transformNode(e.dataType,r)})}transformFetch(e,r){return i({kind:"FetchNode",rowCount:this.transformNode(e.rowCount,r),modifier:e.modifier})}transformTop(e,r){return i({kind:"TopNode",expression:e.expression,modifiers:e.modifiers})}transformOutput(e,r){return i({kind:"OutputNode",selections:this.transformNodeList(e.selections,r)})}transformDataType(e,r){return e}transformSelectAll(e,r){return e}transformIdentifier(e,r){return e}transformValue(e,r){return e}transformPrimitiveValueList(e,r){return e}transformOperator(e,r){return e}transformDefaultInsertValue(e,r){return e}transformOrAction(e,r){return e}transformCollate(e,r){return e}}var Ct=p({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}),Rt={json_agg:!0,to_json:!0};class cr extends _c{#e;#r=new Set;#t=new Set;constructor(e){super();this.#e=e}transformNodeImpl(e,r){if(!this.#s(e))return super.transformNodeImpl(e,r);let t=this.#u(e);for(let u of t)this.#t.add(u);let o=this.#a(e);for(let u of o)this.#r.add(u);let n=super.transformNodeImpl(e,r);for(let u of o)this.#r.delete(u);for(let u of t)this.#t.delete(u);return n}transformSchemableIdentifier(e,r){let t=super.transformSchemableIdentifier(e,r);if(t.schema||!this.#r.has(e.identifier.name))return t;return{...t,schema:je.create(this.#e)}}transformReferences(e,r){let t=super.transformReferences(e,r);if(t.table.table.schema)return t;return{...t,table:g.createWithSchema(this.#e,t.table.table.identifier.name)}}transformAggregateFunction(e,r){return{...super.transformAggregateFunction({...e,aggregated:[]},r),aggregated:this.#i(e,r,"aggregated")}}transformFunction(e,r){return{...super.transformFunction({...e,arguments:[]},r),arguments:this.#i(e,r,"arguments")}}transformSelectModifier(e,r){return{...super.transformSelectModifier({...e,of:void 0},r),of:e.of?.map((t)=>g.is(t)&&!t.table.schema?{...t,table:this.transformIdentifier(t.table.identifier,r)}:this.transformNode(t,r))}}#i(e,r,t){return Rt[e.func]?e[t].map((o)=>!g.is(o)||o.table.schema?this.transformNode(o,r):{...o,table:this.transformIdentifier(o.table.identifier,r)}):this.transformNodeList(e[t],r)}#s(e){return e.kind in Ct}#a(e){let r=new Set;if("name"in e&&e.name&&Sn.is(e.name))this.#n(e.name,r);if("from"in e&&e.from)for(let t of e.from.froms)this.#o(t,r);if("into"in e&&e.into)this.#o(e.into,r);if("table"in e&&e.table)this.#o(e.table,r);if("joins"in e&&e.joins)for(let t of e.joins)this.#o(t.table,r);if("using"in e&&e.using)if(R.is(e.using))this.#o(e.using.table,r);else this.#o(e.using,r);return r}#u(e){let r=new Set;if("with"in e&&e.with)this.#m(e.with,r);return r}#o(e,r){if(g.is(e))return this.#n(e.table,r);if(l.is(e)&&g.is(e.node))return this.#n(e.node.table,r);if(Be.is(e)){for(let t of e.items)this.#o(t,r);return}if(ye.is(e)){for(let t of e.tables)this.#o(t,r);return}}#n(e,r){let t=e.identifier.name;if(!this.#r.has(t)&&!this.#t.has(t))r.add(t)}#m(e,r){for(let t of e.expressions){let o=t.name.table.table.identifier.name;if(!this.#t.has(o))r.add(o)}}}class ls{#e;constructor(e){this.#e=new cr(e)}transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}}var Hr=p({is(e){return e.kind==="MatchedNode"},create(e,r=!1){return p({kind:"MatchedNode",not:e,bySource:r})}});function hr(e,r,t){return Ho.create(oe([Hr.create(!e.isMatched,e.bySource),...r&&r.length>0?[r.length===3&&t?N(r[0],r[1],r[2]):sr(r)]:[]],"and",!1))}function ce(e){if(Qt(e))return Bt.create([e],[]);if(dr(e))return e.toOperationNode();return e}class Gi{#e;#r;#t;constructor(){this.#e=new Promise((e,r)=>{this.#t=r,this.#r=e})}get promise(){return this.#e}resolve=(e)=>{if(this.#r)this.#r(e)};reject=(e)=>{if(this.#t)this.#t(e)}}async function Ru(e){let r=new Gi,t=new Gi;return e.provideConnection(async(o)=>(r.resolve(o),await t.promise)).catch((o)=>r.reject(o)),p({connection:await r.promise,release:t.resolve})}var Tt=p([]);class yc{#e;constructor(e=Tt){this.#e=e}get plugins(){return this.#e}transformQuery(e,r){for(let t of this.#e){let o=t.transformQuery({node:e,queryId:r});if(o.kind===e.kind)e=o;else throw 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 ${o.kind}`].join(" "))}return e}async executeQuery(e){return await this.provideConnection(async(r)=>{let t=await r.executeQuery(e);if("numUpdatedOrDeletedRows"in t)us("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`.");return await this.#r(t,e.queryId)})}async*stream(e,r){let{connection:t,release:o}=await Ru(this);try{for await(let n of t.streamQuery(e,r))yield await this.#r(n,e.queryId)}finally{o()}}async#r(e,r){for(let t of this.#e)e=await t.transformResult({result:e,queryId:r});return e}}class he extends yc{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(e){return new he([...this.plugins,e])}withPlugins(e){return new he([...this.plugins,...e])}withPluginAtFront(e){return new he([e,...this.plugins])}withoutPlugins(){return new he([])}}var K=new he;class fr{numChangedRows;constructor(e){this.numChangedRows=e}}class J{#e;constructor(e){this.#e=p(e)}modifyEnd(e){return new J({...this.#e,queryNode:de.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,r){return new J({...this.#e,queryNode:de.cloneWithTop(this.#e.queryNode,B(e,r))})}using(...e){return new b({...this.#e,queryNode:k.cloneWithUsing(this.#e.queryNode,G("Using",e))})}returning(e){return new J({...this.#e,queryNode:de.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(e){return new J({...this.#e,queryNode:de.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new J({...this.#e,queryNode:de.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new J({...this.#e,queryNode:de.cloneWithOutput(this.#e.queryNode,y(e))})}}class b{#e;constructor(e){this.#e=p(e)}modifyEnd(e){return new b({...this.#e,queryNode:de.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,r){return new b({...this.#e,queryNode:de.cloneWithTop(this.#e.queryNode,B(e,r))})}whenMatched(){return this.#r([])}whenMatchedAnd(...e){return this.#r(e)}whenMatchedAndRef(e,r,t){return this.#r([e,r,t],!0)}#r(e,r){return new lr({...this.#e,queryNode:k.cloneWithWhen(this.#e.queryNode,hr({isMatched:!0},e,r))})}whenNotMatched(){return this.#t([])}whenNotMatchedAnd(...e){return this.#t(e)}whenNotMatchedAndRef(e,r,t){return this.#t([e,r,t],!0)}whenNotMatchedBySource(){return this.#t([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#t(e,!1,!0)}whenNotMatchedBySourceAndRef(e,r,t){return this.#t([e,r,t],!0,!0)}returning(e){return new b({...this.#e,queryNode:de.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(e){return new b({...this.#e,queryNode:de.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new b({...this.#e,queryNode:de.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new b({...this.#e,queryNode:de.cloneWithOutput(this.#e.queryNode,y(e))})}#t(e,r=!1,t=!1){let o={...this.#e,queryNode:k.cloneWithWhen(this.#e.queryNode,hr({isMatched:!1,bySource:t},e,r))};return new(t?lr:Xr)(o)}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new b({...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(),r=await this.#e.executor.executeQuery(e),{adapter:t}=this.#e.executor,o=e.query;if(o.returning&&t.supportsReturning||o.output&&t.supportsOutput)return r.rows;return[new fr(r.numAffectedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=L){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}}class lr{#e;constructor(e){this.#e=p(e)}thenDelete(){return new b({...this.#e,queryNode:k.cloneWithThen(this.#e.queryNode,ce("delete"))})}thenDoNothing(){return new b({...this.#e,queryNode:k.cloneWithThen(this.#e.queryNode,ce("do nothing"))})}thenUpdate(e){return new b({...this.#e,queryNode:k.cloneWithThen(this.#e.queryNode,ce(e(new ue({queryId:this.#e.queryId,executor:K,queryNode:F.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate((r)=>r.set(...e))}}class Xr{#e;constructor(e){this.#e=p(e)}thenDoNothing(){return new b({...this.#e,queryNode:k.cloneWithThen(this.#e.queryNode,ce("do nothing"))})}thenInsertValues(e){let[r,t]=ve(e);return new b({...this.#e,queryNode:k.cloneWithThen(this.#e.queryNode,ce(kr.cloneWith(kr.createWithoutInto(),{columns:r,values:t})))})}}class Ms{#e;constructor(e){this.#e=p(e)}selectFrom(e){return be({queryId:Ye(),executor:this.#e.executor,queryNode:Gt.createFrom(A(e),this.#e.withNode)})}selectNoFrom(e){return be({queryId:Ye(),executor:this.#e.executor,queryNode:Gt.cloneWithSelections(Gt.create(this.#e.withNode),f(e))})}insertInto(e){return new d({queryId:Ye(),executor:this.#e.executor,queryNode:kr.create(zt(e),this.#e.withNode)})}replaceInto(e){return new d({queryId:Ye(),executor:this.#e.executor,queryNode:kr.create(zt(e),this.#e.withNode,!0)})}deleteFrom(e){return new Pe({queryId:Ye(),executor:this.#e.executor,queryNode:_.create(A(e),this.#e.withNode)})}updateTable(e){return new ue({queryId:Ye(),executor:this.#e.executor,queryNode:F.create(A(e),this.#e.withNode)})}mergeInto(e){return new J({queryId:Ye(),executor:this.#e.executor,queryNode:k.create(tr(e),this.#e.withNode)})}with(e,r){let t=mr(e,r);return new Ms({...this.#e,withNode:this.#e.withNode?We.cloneWithExpression(this.#e.withNode,t):We.create(t)})}withRecursive(e,r){let t=mr(e,r);return new Ms({...this.#e,withNode:this.#e.withNode?We.cloneWithExpression(this.#e.withNode,t):We.create(t,{recursive:!0})})}withPlugin(e){return new Ms({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new Ms({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new Ms({...this.#e,executor:this.#e.executor.withPluginAtFront(new ls(e))})}}function jr(){return new Ms({executor:K})}function Yr(e,r){return new ie({joinNode:R.create(e,Y(r))})}function Zr(){return new ne({overNode:Ne.create()})}function G(e,r){if(r.length===3)return qt(e,r[0],r[1],r[2]);else if(r.length===2)return At(e,r[0],r[1]);else if(r.length===1)return Lt(e,r[0]);else throw Error("not implemented")}function At(e,r,t){return t(Yr(e,r)).toOperationNode()}function qt(e,r,t,o){return R.createWithOn(e,Y(r),N(t,"=",o))}function Lt(e,r){return R.create(e,Y(r))}var et=p({is(e){return e.kind==="OffsetNode"},create(e){return p({kind:"OffsetNode",offset:e})}});var rt=p({is(e){return e.kind==="GroupByItemNode"},create(e){return p({kind:"GroupByItemNode",groupBy:e})}});function tt(e){return e=Kt(e)?e(q()):e,z(e).map(rt.create)}function ee(e,r,t){if(Kt(r))r=r(Me());if(!Fn(r))r=[r];return r.map((o)=>Du.create(e,ho(o),t))}class a{#e;constructor(e){this.#e=e}get expressionType(){return}as(e){return new ze(this,e)}or(...e){return new Ve(C.create(this.#e,sr(e)))}and(...e){return new Ue(W.create(this.#e,sr(e)))}$castTo(){return new a(this.#e)}$notNull(){return new a(this.#e)}toOperationNode(){return this.#e}}class ze{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return l.create(this.#e.toOperationNode(),dr(this.#r)?this.#r.toOperationNode():je.create(this.#r))}}class Ve{#e;constructor(e){this.#e=e}get expressionType(){return}as(e){return new ze(this,e)}or(...e){return new Ve(C.create(this.#e,sr(e)))}$castTo(){return new Ve(this.#e)}toOperationNode(){return No.create(this.#e)}}class Ue{#e;constructor(e){this.#e=e}get expressionType(){return}as(e){return new ze(this,e)}and(...e){return new Ue(W.create(this.#e,sr(e)))}$castTo(){return new Ue(this.#e)}toOperationNode(){return No.create(this.#e)}}var ot=p({is(e){return e.kind==="FetchNode"},create(e,r){return{kind:"FetchNode",rowCount:qr.create(e),modifier:r}}});function it(e,r){if(!qo(e)&&!li(e))throw Error(`Invalid fetch row count: ${e}`);if(!Dt(r))throw Error(`Invalid fetch modifier: ${r}`);return ot.create(e,r)}function Dt(e){return e==="only"||e==="with ties"}var s;class Nr{#e;constructor(e){this.#e=p(e)}get expressionType(){return}get isSelectQueryBuilder(){return!0}where(...e){return new s({...this.#e,queryNode:de.cloneWithWhere(this.#e.queryNode,sr(e))})}whereRef(e,r,t){return new s({...this.#e,queryNode:de.cloneWithWhere(this.#e.queryNode,N(e,r,t))})}having(...e){return new s({...this.#e,queryNode:Gt.cloneWithHaving(this.#e.queryNode,sr(e))})}havingRef(e,r,t){return new s({...this.#e,queryNode:Gt.cloneWithHaving(this.#e.queryNode,N(e,r,t))})}select(e){return new s({...this.#e,queryNode:Gt.cloneWithSelections(this.#e.queryNode,f(e))})}distinctOn(e){return new s({...this.#e,queryNode:Gt.cloneWithDistinctOn(this.#e.queryNode,z(e))})}modifyFront(e){return new s({...this.#e,queryNode:Gt.cloneWithFrontModifier(this.#e.queryNode,D.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new s({...this.#e,queryNode:de.cloneWithEndModifier(this.#e.queryNode,D.createWithExpression(e.toOperationNode()))})}distinct(){return new s({...this.#e,queryNode:Gt.cloneWithFrontModifier(this.#e.queryNode,D.create("Distinct"))})}forUpdate(e){return new s({...this.#e,queryNode:de.cloneWithEndModifier(this.#e.queryNode,D.create("ForUpdate",e?vc(e).map(zt):void 0))})}forShare(e){return new s({...this.#e,queryNode:de.cloneWithEndModifier(this.#e.queryNode,D.create("ForShare",e?vc(e).map(zt):void 0))})}forKeyShare(e){return new s({...this.#e,queryNode:de.cloneWithEndModifier(this.#e.queryNode,D.create("ForKeyShare",e?vc(e).map(zt):void 0))})}forNoKeyUpdate(e){return new s({...this.#e,queryNode:de.cloneWithEndModifier(this.#e.queryNode,D.create("ForNoKeyUpdate",e?vc(e).map(zt):void 0))})}skipLocked(){return new s({...this.#e,queryNode:de.cloneWithEndModifier(this.#e.queryNode,D.create("SkipLocked"))})}noWait(){return new s({...this.#e,queryNode:de.cloneWithEndModifier(this.#e.queryNode,D.create("NoWait"))})}selectAll(e){return new s({...this.#e,queryNode:Gt.cloneWithSelections(this.#e.queryNode,y(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,r){return new s({...this.#e,queryNode:de.cloneWithJoin(this.#e.queryNode,G(e,r))})}orderBy(...e){return new s({...this.#e,queryNode:de.cloneWithOrderByItems(this.#e.queryNode,E(e))})}groupBy(e){return new s({...this.#e,queryNode:Gt.cloneWithGroupByItems(this.#e.queryNode,tt(e))})}limit(e){return new s({...this.#e,queryNode:Gt.cloneWithLimit(this.#e.queryNode,ae.create(m(e)))})}offset(e){return new s({...this.#e,queryNode:Gt.cloneWithOffset(this.#e.queryNode,et.create(m(e)))})}fetch(e,r="only"){return new s({...this.#e,queryNode:Gt.cloneWithFetch(this.#e.queryNode,it(e,r))})}top(e,r){return new s({...this.#e,queryNode:de.cloneWithTop(this.#e.queryNode,B(e,r))})}union(e){return new s({...this.#e,queryNode:Gt.cloneWithSetOperations(this.#e.queryNode,ee("union",e,!1))})}unionAll(e){return new s({...this.#e,queryNode:Gt.cloneWithSetOperations(this.#e.queryNode,ee("union",e,!0))})}intersect(e){return new s({...this.#e,queryNode:Gt.cloneWithSetOperations(this.#e.queryNode,ee("intersect",e,!1))})}intersectAll(e){return new s({...this.#e,queryNode:Gt.cloneWithSetOperations(this.#e.queryNode,ee("intersect",e,!0))})}except(e){return new s({...this.#e,queryNode:Gt.cloneWithSetOperations(this.#e.queryNode,ee("except",e,!1))})}exceptAll(e){return new s({...this.#e,queryNode:Gt.cloneWithSetOperations(this.#e.queryNode,ee("except",e,!0))})}as(e){return new nt(this,e)}clearSelect(){return new s({...this.#e,queryNode:Gt.cloneWithoutSelections(this.#e.queryNode)})}clearWhere(){return new s({...this.#e,queryNode:de.cloneWithoutWhere(this.#e.queryNode)})}clearLimit(){return new s({...this.#e,queryNode:Gt.cloneWithoutLimit(this.#e.queryNode)})}clearOffset(){return new s({...this.#e,queryNode:Gt.cloneWithoutOffset(this.#e.queryNode)})}clearOrderBy(){return new s({...this.#e,queryNode:de.cloneWithoutOrderBy(this.#e.queryNode)})}clearGroupBy(){return new s({...this.#e,queryNode:Gt.cloneWithoutGroupBy(this.#e.queryNode)})}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new s({...this.#e})}$castTo(){return new s(this.#e)}$narrowType(){return new s(this.#e)}$assertType(){return new s(this.#e)}$asTuple(){return new a(this.toOperationNode())}$asScalar(){return new a(this.toOperationNode())}withPlugin(e){return new s({...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=L){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){let r=this.compile(),t=this.#e.executor.stream(r,e);for await(let o of t)yield*o.rows}async explain(e,r){return await new s({...this.#e,queryNode:de.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}s=Nr;function be(e){return new Nr(e)}class nt{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return l.create(this.#e.toOperationNode(),je.create(this.#r))}}var M=p({is(e){return e.kind==="AggregateFunctionNode"},create(e,r=[]){return p({kind:"AggregateFunctionNode",func:e,aggregated:r})},cloneWithDistinct(e){return p({...e,distinct:!0})},cloneWithOrderBy(e,r,t=!1){let o=t?"withinGroup":"orderBy";return p({...e,[o]:e[o]?U.cloneWithItems(e[o],r):U.create(r)})},cloneWithFilter(e,r){return p({...e,filter:e.filter?O.cloneWithOperation(e.filter,"And",r):O.create(r)})},cloneWithOrFilter(e,r){return p({...e,filter:e.filter?O.cloneWithOperation(e.filter,"Or",r):O.create(r)})},cloneWithOver(e,r){return p({...e,over:r})}});var yr=p({is(e){return e.kind==="FunctionNode"},create(e,r){return p({kind:"FunctionNode",func:e,arguments:r})}});class S{#e;constructor(e){this.#e=p(e)}get expressionType(){return}as(e){return new st(this,e)}distinct(){return new S({...this.#e,aggregateFunctionNode:M.cloneWithDistinct(this.#e.aggregateFunctionNode)})}orderBy(...e){return new S({...this.#e,aggregateFunctionNode:de.cloneWithOrderByItems(this.#e.aggregateFunctionNode,E(e))})}clearOrderBy(){return new S({...this.#e,aggregateFunctionNode:de.cloneWithoutOrderBy(this.#e.aggregateFunctionNode)})}withinGroupOrderBy(...e){return new S({...this.#e,aggregateFunctionNode:M.cloneWithOrderBy(this.#e.aggregateFunctionNode,E(e),!0)})}filterWhere(...e){return new S({...this.#e,aggregateFunctionNode:M.cloneWithFilter(this.#e.aggregateFunctionNode,sr(e))})}filterWhereRef(e,r,t){return new S({...this.#e,aggregateFunctionNode:M.cloneWithFilter(this.#e.aggregateFunctionNode,N(e,r,t))})}over(e){let r=Zr();return new S({...this.#e,aggregateFunctionNode:M.cloneWithOver(this.#e.aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}$castTo(){return new S(this.#e)}$notNull(){return new S(this.#e)}toOperationNode(){return this.#e.aggregateFunctionNode}}class st{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return l.create(this.#e.toOperationNode(),je.create(this.#r))}}function Pu(){let e=(t,o)=>new a(yr.create(t,z(o??[]))),r=(t,o)=>new S({aggregateFunctionNode:M.create(t,o?z(o):void 0)});return Object.assign(e,{agg:r,avg(t){return r("avg",[t])},coalesce(...t){return e("coalesce",t)},count(t){return r("count",[t])},countAll(t){return new S({aggregateFunctionNode:M.create("count",y(t))})},max(t){return r("max",[t])},min(t){return r("min",[t])},sum(t){return r("sum",[t])},any(t){return e("any",[t])},jsonAgg(t){return new S({aggregateFunctionNode:M.create("json_agg",[Qt(t)?zt(t):t.toOperationNode()])})},toJson(t){return new a(yr.create("to_json",[Qt(t)?zt(t):t.toOperationNode()]))}})}var at=p({is(e){return e.kind==="UnaryOperationNode"},create(e,r){return p({kind:"UnaryOperationNode",operator:e,operand:r})}});function ut(e,r){return at.create(Po.create(e),w(r))}var Ro=p({is(e){return e.kind==="CaseNode"},create(e){return p({kind:"CaseNode",value:e})},cloneWithWhen(e,r){return p({...e,when:p(e.when?[...e.when,r]:[r])})},cloneWithThen(e,r){return p({...e,when:e.when?p([...e.when.slice(0,-1),Ho.cloneWithResult(e.when[e.when.length-1],r)]):void 0})},cloneWith(e,r){return p({...e,...r})}});class bc{#e;constructor(e){this.#e=p(e)}when(...e){return new wr({...this.#e,node:Ro.cloneWithWhen(this.#e.node,Ho.create(sr(e)))})}}class wr{#e;constructor(e){this.#e=p(e)}then(e){return new mt({...this.#e,node:Ro.cloneWithThen(this.#e.node,qe(e)?le(e):m(e))})}}class mt{#e;constructor(e){this.#e=p(e)}when(...e){return new wr({...this.#e,node:Ro.cloneWithWhen(this.#e.node,Ho.create(sr(e)))})}else(e){return new dt({...this.#e,node:Ro.cloneWith(this.#e.node,{else:qe(e)?le(e):m(e)})})}end(){return new a(Ro.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new a(Ro.cloneWith(this.#e.node,{isStatement:!0}))}}class dt{#e;constructor(e){this.#e=p(e)}end(){return new a(Ro.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new a(Ro.cloneWith(this.#e.node,{isStatement:!0}))}}var Je=p({is(e){return e.kind==="JSONOperatorChainNode"},create(e){return p({kind:"JSONOperatorChainNode",operator:e,values:p([])})},cloneWithValue(e,r){return p({...e,values:p([...e.values,r])})}});var Or=p({is(e){return e.kind==="JSONPathLegNode"},create(e,r){return p({kind:"JSONPathLegNode",type:e,value:r})}});var H=p({is(e){return e.kind==="JSONPathNode"},create(e){return p({kind:"JSONPathNode",inOperator:e,pathLegs:p([])})},cloneWithLeg(e,r){return p({...e,pathLegs:p([...e.pathLegs,r])})}});var fe=p({is(e){return e.kind==="JSONReferenceNode"},create(e,r){return p({kind:"JSONReferenceNode",reference:e,traversal:r})},cloneWithTraversal(e,r){return p({...e,traversal:r})}});var Ft=/^#-\d+$/;class ke{#e;constructor(e){this.#e=e}at(e){if(typeof e!=="number"&&typeof e!=="string"||typeof e==="number"&&!Number.isInteger(e)||typeof e==="string"&&e!=="last"&&!Ft.test(e))throw Error(`Unexpected index value in .at(...): ${e}`);return this.#r("ArrayLocation",e)}key(e){return this.#r("Member",e)}#r(e,r){if(fe.is(this.#e))return new Se(fe.cloneWithTraversal(this.#e,H.is(this.#e.traversal)?H.cloneWithLeg(this.#e.traversal,Or.create(e,r)):Je.cloneWithValue(this.#e.traversal,qr.createImmediate(r))));return new Se(H.cloneWithLeg(this.#e,Or.create(e,r)))}}class Se extends ke{#e;constructor(e){super(e);this.#e=e}get expressionType(){return}as(e){return new ct(this,e)}$castTo(){return new Se(this.#e)}$notNull(){return new Se(this.#e)}toOperationNode(){return this.#e}}class ct{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return l.create(this.#e.toOperationNode(),dr(this.#r)?this.#r.toOperationNode():je.create(this.#r))}}var xr=p({is(e){return e.kind==="TupleNode"},create(e){return p({kind:"TupleNode",values:p(e)})}});var vt=["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"],Pt=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],ht=p({is(e){return e.kind==="DataTypeNode"},create(e){return p({kind:"DataTypeNode",dataType:e})}});function ft(e){if(vt.includes(e))return!0;if(Pt.some((r)=>r.test(e)))return!0;return!1}function cs(e){if(dr(e))return e.toOperationNode();if(ft(e))return ht.create(e);throw Error(`invalid column data type ${JSON.stringify(e)}`)}var pt=p({is(e){return e.kind==="CastNode"},create(e,r){return p({kind:"CastNode",expression:e,dataType:r})}});function Me(e=K){function r(n,u,re){return new a(Le(n,u,re))}function t(n,u){return new a(ut(n,u))}let o=Object.assign(r,{fn:void 0,eb:void 0,selectFrom(n){return be({queryId:Ye(),executor:e,queryNode:Gt.createFrom(A(n))})},case(n){return new bc({node:Ro.create(On(n)?void 0:w(n))})},ref(n,u){if(On(u))return new a(ko(n));return new ke(lt(n,u))},jsonPath(){return new ke(H.create())},table(n){return new a(zt(n))},val(n){return new a(m(n))},refTuple(...n){return new a(xr.create(n.map(w)))},tuple(...n){return new a(xr.create(n.map(m)))},lit(n){return new a(le(n))},unary:t,not(n){return t("not",n)},exists(n){return t("exists",n)},neg(n){return t("-",n)},between(n,u,re){return new a(I.create(w(n),Po.create("between"),W.create(m(u),m(re))))},betweenSymmetric(n,u,re){return new a(I.create(w(n),Po.create("between symmetric"),W.create(m(u),m(re))))},and(n){if(Fn(n))return new a(oe(n,"and"));return new a($e(n,"and"))},or(n){if(Fn(n))return new a(oe(n,"or"));return new a($e(n,"or"))},parens(...n){let u=sr(n);if(No.is(u))return new a(u);else return new a(No.create(u))},cast(n,u){return new a(pt.create(w(n),cs(u)))},withSchema(n){return Me(e.withPluginAtFront(new ls(n)))}});return o.fn=Pu(),o.eb=o,o}function q(e){return Me()}function ho(e){if(dr(e))return e.toOperationNode();else if(Kt(e))return e(q()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(e)}`)}function Fe(e){if(dr(e))return e.toOperationNode();else if(Kt(e))return e(q()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(e)}`)}function V(e){return Re(e)||Wr(e)||Kt(e)}function Ze(e){if(Qt(e))return ko(e);return e.toOperationNode()}function z(e){if(Fn(e))return e.map((r)=>w(r));else return[w(e)]}function w(e){if(V(e))return ho(e);return Ze(e)}function lt(e,r){let t=ko(e);if(yf(r))return fe.create(t,Je.create(Po.create(r)));let o=r.slice(0,-1);if(yf(o))return fe.create(t,H.create(Po.create(o)));throw Error(`Invalid JSON operator: ${r}`)}function ko(e){if(!e.includes("."))return te.create(Zt.create(e));let t=e.split(".").map(gr);if(t.length===3)return Mt(t);if(t.length===2)return Vt(t);throw Error(`invalid column reference ${e}`)}function Vr(e){if(e.includes(" as ")){let[t,o]=e.split(" as ").map(gr);return l.create(ko(t),je.create(o))}else return ko(e)}function Af(e){return Zt.create(e)}function nl(e){if(e.includes(" ")){let[t,o]=e.split(" ").map(gr);if(!rr(o))throw Error(`invalid order direction "${o}" next to "${t}"`);return E([t,o])[0]}else return Af(e)}function Mt(e){let[r,t,o]=e;return te.create(Zt.create(o),g.createWithSchema(r,t))}function Vt(e){let[r,t]=e;return te.create(Zt.create(t),g.create(r))}function gr(e){return e.trim()}class Ee{#e;constructor(e){this.#e=p(e)}get expressionType(){return}get isRawBuilder(){return!0}as(e){return new Nt(this,e)}$castTo(){return new Ee({...this.#e})}$notNull(){return new Ee(this.#e)}withPlugin(e){return new Ee({...this.#e,plugins:this.#e.plugins!==void 0?p([...this.#e.plugins,e]):p([e])})}toOperationNode(){return this.#t(this.#r())}compile(e){return this.#i(this.#r(e))}async execute(e){let r=this.#r(e);return r.executeQuery(this.#i(r))}#r(e){let r=e!==void 0?e.getExecutor():K;return this.#e.plugins!==void 0?r.withPlugins(this.#e.plugins):r}#t(e){return e.transformQuery(this.#e.rawNode,this.#e.queryId)}#i(e){return e.compileQuery(this.#t(e),this.#e.queryId)}}function Q(e){return new Ee(e)}class Nt{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}get rawBuilder(){return this.#e}toOperationNode(){return l.create(this.#e.toOperationNode(),dr(this.#r)?this.#r.toOperationNode():je.create(this.#r))}}var Oe=Object.assign((e,...r)=>Q({queryId:Ye(),rawNode:Bt.create(e,r?.map(yt)??[])}),{ref(e){return Q({queryId:Ye(),rawNode:Bt.createWithChild(ko(e))})},val(e){return Q({queryId:Ye(),rawNode:Bt.createWithChild(m(e))})},value(e){return this.val(e)},table(e){return Q({queryId:Ye(),rawNode:Bt.createWithChild(zt(e))})},id(...e){let r=Array(e.length+1).fill(".");return r[0]="",r[r.length-1]="",Q({queryId:Ye(),rawNode:Bt.create(r,e.map(je.create))})},lit(e){return Q({queryId:Ye(),rawNode:Bt.createWithChild(qr.createImmediate(e))})},literal(e){return this.lit(e)},raw(e){return Q({queryId:Ye(),rawNode:Bt.createWithSql(e)})},join(e,r=Oe`, `){let t=Array(Math.max(2*e.length-1,0)),o=r.toOperationNode();for(let n=0;n<e.length;++n)if(t[2*n]=yt(e[n]),n!==e.length-1)t[2*n+1]=o;return Q({queryId:Ye(),rawNode:Bt.createWithChildren(t)})}});function yt(e){if(dr(e))return e.toOperationNode();return m(e)}var pr=p({raw(e,r=[]){return p({sql:e,query:Bt.createWithSql(e),parameters:p(r),queryId:Ye()})}});
3
- export{dr,Zt,rl,gf,ko,Af,nl,$i,qr,sr,de,Gt,ku,Ye,_c,ls,Gi,Ru,yc,Ms,Pu,Ro,bc,cs,ho,_f,zt,Oe,pr};
2
+ import{Fn,Qt,$o,Ns,ci,ui,Kt,Mr,p,xc,Ln,je,En,wm,Do,wf,Bt,ds,Oo,kr,Go,Ou}from"./chunk-w73v578p.js";function pr(e){return Mr(e)&&Kt(e.toOperationNode)}var Hr=p({is(e){return e.kind==="ValueNode"},create(e){return p({kind:"ValueNode",value:e})},createImmediate(e){return p({kind:"ValueNode",value:e,immediate:!0})}});var l=p({is(e){return e.kind==="AliasNode"},create(e,r){return p({kind:"AliasNode",node:e,alias:r})}});var Zt=p({is(e){return e.kind==="ColumnNode"},create(e){return p({kind:"ColumnNode",column:je.create(e)})}});var ol=p({is(e){return e.kind==="SelectAllNode"},create(){return p({kind:"SelectAllNode"})}});var te=p({is(e){return e.kind==="ReferenceNode"},create(e,r){return p({kind:"ReferenceNode",table:r,column:e})},createSelectAll(e){return p({kind:"ReferenceNode",table:e,column:ol.create()})}});var g=p({is(e){return e.kind==="TableNode"},create(e){return p({kind:"TableNode",table:En.create(e)})},createWithSchema(e,r){return p({kind:"TableNode",table:En.createWithSchema(e,r)})}});function Re(e){return Mr(e)&&"expressionType"in e&&pr(e)}function Wr(e){return Mr(e)&&"expression"in e&&Qt(e.alias)&&pr(e)}var D=p({is(e){return e.kind==="SelectModifierNode"},create(e,r){return p({kind:"SelectModifierNode",modifier:e,of:r})},createWithExpression(e){return p({kind:"SelectModifierNode",rawModifier:e})}});var W=p({is(e){return e.kind==="AndNode"},create(e,r){return p({kind:"AndNode",left:e,right:r})}});var C=p({is(e){return e.kind==="OrNode"},create(e,r){return p({kind:"OrNode",left:e,right:r})}});var Te=p({is(e){return e.kind==="OnNode"},create(e){return p({kind:"OnNode",on:e})},cloneWithOperation(e,r,t){return p({...e,on:r==="And"?W.create(e.on,t):C.create(e.on,t)})}});var R=p({is(e){return e.kind==="JoinNode"},create(e,r){return p({kind:"JoinNode",joinType:e,table:r,on:void 0})},createWithOn(e,r,t){return p({kind:"JoinNode",joinType:e,table:r,on:Te.create(t)})},cloneWithOn(e,r){return p({...e,on:e.on?Te.cloneWithOperation(e.on,"And",r):Te.create(r)})}});var I=p({is(e){return e.kind==="BinaryOperationNode"},create(e,r,t){return p({kind:"BinaryOperationNode",leftOperand:e,operator:r,rightOperand:t})}});var Ae=p({is(e){return e.kind==="PrimitiveValueListNode"},create(e){return p({kind:"PrimitiveValueListNode",values:p([...e])})}});var $i=p({is(e){return e.kind==="ValueListNode"},create(e){return p({kind:"ValueListNode",values:p(e)})}});function br(e){if(Ln(e))return wt(e);return m(e)}function m(e){if(V(e))return Ao(e);return Hr.create(e)}function qe(e){return $o(e)||Ns(e)||ci(e)}function le(e){if(!qe(e))throw Error(`unsafe immediate value ${JSON.stringify(e)}`);return Hr.createImmediate(e)}function wt(e){if(e.some(V))return $i.create(e.map((r)=>m(r)));return Ae.create(e)}function ir(e){if(e.length===3)return Le(e[0],e[1],e[2]);else if(e.length===1)return m(e[0]);throw Error(`invalid arguments: ${JSON.stringify(e)}`)}function Le(e,r,t){if(Ot(r)&&Er(t))return I.create(w(e),$e(r),Hr.createImmediate(t));return I.create(w(e),$e(r),br(t))}function N(e,r,t){return I.create(w(e),$e(r),w(t))}function _e(e,r){return oe(Object.entries(e).filter(([,t])=>!Fn(t)).map(([t,o])=>Le(t,Er(o)?"is":"=",o)),r)}function oe(e,r,t=!0){let o=r==="and"?W.create:C.create;if(e.length===0)return I.create(Hr.createImmediate(1),Do.create("="),Hr.createImmediate(r==="and"?1:0));let n=Sr(e[0]);for(let u=1;u<e.length;++u)n=o(n,Sr(e[u]));if(e.length>1&&t)return Oo.create(n);return n}function Ot(e){return e==="is"||e==="is not"}function Er(e){return ci(e)||Ns(e)}function $e(e){if(Qt(e)&&wm.includes(e))return Do.create(e);if(pr(e))return e.toOperationNode();throw Error(`invalid operator ${JSON.stringify(e)}`)}function Sr(e){return pr(e)?e.toOperationNode():e}var U=p({is(e){return e.kind==="OrderByNode"},create(e){return p({kind:"OrderByNode",items:p([...e])})},cloneWithItems(e,r){return p({...e,items:p([...e.items,...r])})}});var Ge=p({is(e){return e.kind==="PartitionByNode"},create(e){return p({kind:"PartitionByNode",items:p(e)})},cloneWithItems(e,r){return p({...e,items:p([...e.items,...r])})}});var Ne=p({is(e){return e.kind==="OverNode"},create(){return p({kind:"OverNode"})},cloneWithOrderByItems(e,r){return p({...e,orderBy:e.orderBy?U.cloneWithItems(e.orderBy,r):U.create(r)})},cloneWithPartitionByItems(e,r){return p({...e,partitionBy:e.partitionBy?Ge.cloneWithItems(e.partitionBy,r):Ge.create(r)})}});var X=p({is(e){return e.kind==="FromNode"},create(e){return p({kind:"FromNode",froms:p(e)})},cloneWithFroms(e,r){return p({...e,froms:p([...e.froms,...r])})}});var Ke=p({is(e){return e.kind==="GroupByNode"},create(e){return p({kind:"GroupByNode",items:p(e)})},cloneWithItems(e,r){return p({...e,items:p([...e.items,...r])})}});var He=p({is(e){return e.kind==="HavingNode"},create(e){return p({kind:"HavingNode",having:e})},cloneWithOperation(e,r,t){return p({...e,having:r==="And"?W.create(e.having,t):C.create(e.having,t)})}});var Be=p({is(e){return e.kind==="ListNode"},create(e){return p({kind:"ListNode",items:p(e)})}});var F=p({is(e){return e.kind==="UpdateQueryNode"},create(e,r){return p({kind:"UpdateQueryNode",table:e.length===1?e[0]:Be.create(e),...r&&{with:r}})},createWithoutTable(){return p({kind:"UpdateQueryNode"})},cloneWithFromItems(e,r){return p({...e,from:e.from?X.cloneWithFroms(e.from,r):X.create(r)})},cloneWithUpdates(e,r){return p({...e,updates:e.updates?p([...e.updates,...r]):r})},cloneWithLimit(e,r){return p({...e,limit:r})}});var ye=p({is(e){return e.kind==="UsingNode"},create(e){return p({kind:"UsingNode",tables:p(e)})},cloneWithTables(e,r){return p({...e,tables:p([...e.tables,...r])})}});var _=p({is(e){return e.kind==="DeleteQueryNode"},create(e,r){return p({kind:"DeleteQueryNode",from:X.create(e),...r&&{with:r}})},cloneWithOrderByItems:(e,r)=>fe.cloneWithOrderByItems(e,r),cloneWithoutOrderBy:(e)=>fe.cloneWithoutOrderBy(e),cloneWithLimit(e,r){return p({...e,limit:r})},cloneWithoutLimit(e){return p({...e,limit:void 0})},cloneWithUsing(e,r){return p({...e,using:e.using!==void 0?ye.cloneWithTables(e.using,r):ye.create(r)})}});var O=p({is(e){return e.kind==="WhereNode"},create(e){return p({kind:"WhereNode",where:e})},cloneWithOperation(e,r,t){return p({...e,where:r==="And"?W.create(e.where,t):C.create(e.where,t)})}});var Xe=p({is(e){return e.kind==="ReturningNode"},create(e){return p({kind:"ReturningNode",selections:p(e)})},cloneWithSelections(e,r){return p({...e,selections:e.selections?p([...e.selections,...r]):p(r)})}});var Cr=p({is(e){return e.kind==="ExplainNode"},create(e,r){return p({kind:"ExplainNode",format:e,options:r})}});var k=p({is(e){return e.kind==="MergeQueryNode"},create(e,r){return p({kind:"MergeQueryNode",into:e,...r&&{with:r}})},cloneWithUsing(e,r){return p({...e,using:r})},cloneWithWhen(e,r){return p({...e,whens:e.whens?p([...e.whens,r]):p([r])})},cloneWithThen(e,r){return p({...e,whens:e.whens?p([...e.whens.slice(0,-1),Go.cloneWithResult(e.whens[e.whens.length-1],r)]):void 0})}});var Ye=p({is(e){return e.kind==="OutputNode"},create(e){return p({kind:"OutputNode",selections:p(e)})},cloneWithSelections(e,r){return p({...e,selections:e.selections?p([...e.selections,...r]):p(r)})}});var fe=p({is(e){return Gt.is(e)||kr.is(e)||F.is(e)||_.is(e)||k.is(e)},cloneWithEndModifier(e,r){return p({...e,endModifiers:e.endModifiers?p([...e.endModifiers,r]):p([r])})},cloneWithWhere(e,r){return p({...e,where:e.where?O.cloneWithOperation(e.where,"And",r):O.create(r)})},cloneWithJoin(e,r){return p({...e,joins:e.joins?p([...e.joins,r]):p([r])})},cloneWithReturning(e,r){return p({...e,returning:e.returning?Xe.cloneWithSelections(e.returning,r):Xe.create(r)})},cloneWithoutReturning(e){return p({...e,returning:void 0})},cloneWithoutWhere(e){return p({...e,where:void 0})},cloneWithExplain(e,r,t){return p({...e,explain:Cr.create(r,t?.toOperationNode())})},cloneWithTop(e,r){return p({...e,top:r})},cloneWithOutput(e,r){return p({...e,output:e.output?Ye.cloneWithSelections(e.output,r):Ye.create(r)})},cloneWithOrderByItems(e,r){return p({...e,orderBy:e.orderBy?U.cloneWithItems(e.orderBy,r):U.create(r)})},cloneWithoutOrderBy(e){return p({...e,orderBy:void 0})}});var Gt=p({is(e){return e.kind==="SelectQueryNode"},create(e){return p({kind:"SelectQueryNode",...e&&{with:e}})},createFrom(e,r){return p({kind:"SelectQueryNode",from:X.create(e),...r&&{with:r}})},cloneWithSelections(e,r){return p({...e,selections:e.selections?p([...e.selections,...r]):p(r)})},cloneWithDistinctOn(e,r){return p({...e,distinctOn:e.distinctOn?p([...e.distinctOn,...r]):p(r)})},cloneWithFrontModifier(e,r){return p({...e,frontModifiers:e.frontModifiers?p([...e.frontModifiers,r]):p([r])})},cloneWithOrderByItems:(e,r)=>fe.cloneWithOrderByItems(e,r),cloneWithGroupByItems(e,r){return p({...e,groupBy:e.groupBy?Ke.cloneWithItems(e.groupBy,r):Ke.create(r)})},cloneWithLimit(e,r){return p({...e,limit:r})},cloneWithOffset(e,r){return p({...e,offset:r})},cloneWithFetch(e,r){return p({...e,fetch:r})},cloneWithHaving(e,r){return p({...e,having:e.having?He.cloneWithOperation(e.having,"And",r):He.create(r)})},cloneWithSetOperations(e,r){return p({...e,setOperations:e.setOperations?p([...e.setOperations,...r]):p([...r])})},cloneWithoutSelections(e){return p({...e,selections:[]})},cloneWithoutLimit(e){return p({...e,limit:void 0})},cloneWithoutOffset(e){return p({...e,offset:void 0})},cloneWithoutOrderBy:(e)=>fe.cloneWithoutOrderBy(e),cloneWithoutGroupBy(e){return p({...e,groupBy:void 0})}});class ie{#e;constructor(e){this.#e=p(e)}on(...e){return new ie({...this.#e,joinNode:R.cloneWithOn(this.#e.joinNode,ir(e))})}onRef(e,r,t){return new ie({...this.#e,joinNode:R.cloneWithOn(this.#e.joinNode,N(e,r,t))})}onTrue(){return new ie({...this.#e,joinNode:R.cloneWithOn(this.#e.joinNode,Bt.createWithSql("true"))})}$call(e){return e(this)}toOperationNode(){return this.#e.joinNode}}class yf{#e;get dynamicReference(){return this.#e}get refType(){return}constructor(e){this.#e=e}toOperationNode(){return Ze(this.#e)}}function De(e){return Mr(e)&&pr(e)&&Qt(e.dynamicReference)}var T=p({is(e){return e.kind==="OrderByItemNode"},create(e,r){return p({kind:"OrderByItemNode",orderBy:e,direction:r})},cloneWith(e,r){return p({...e,...r})}});var Rr=p({is(e){return e.kind==="CollateNode"},create(e){return p({kind:"CollateNode",collation:je.create(e)})}});class j{#e;constructor(e){this.#e=p(e)}desc(){return new j({node:T.cloneWith(this.#e.node,{direction:Bt.createWithSql("desc")})})}asc(){return new j({node:T.cloneWith(this.#e.node,{direction:Bt.createWithSql("asc")})})}nullsLast(){return new j({node:T.cloneWith(this.#e.node,{nulls:"last"})})}nullsFirst(){return new j({node:T.cloneWith(this.#e.node,{nulls:"first"})})}collate(e){return new j({node:T.cloneWith(this.#e.node,{collation:Rr.create(e)})})}toOperationNode(){return this.#e.node}}function rr(e){return e==="asc"||e==="desc"}function E(e){if(e.length===2)return[er(e[0],e[1])];if(e.length===1){let[r]=e;if(Array.isArray(r))return ds("orderBy(array) is deprecated, use multiple orderBy calls instead."),r.map((t)=>er(t));return[er(r)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${e.length}`)}function er(e,r){let t=xt(e);if(T.is(t)){if(r)throw Error("Cannot specify direction twice!");return t}return Tr(t,r)}function xt(e){if(V(e))return Ao(e);if(De(e))return e.toOperationNode();let[r,t]=e.split(" ");if(t)return ds("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),Tr(Po(r),t);return Po(e)}function Tr(e,r){if(typeof r==="string"){if(!rr(r))throw Error(`Invalid order by direction: ${r}`);return T.create(e,Bt.createWithSql(r))}if(Re(r))return ds("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),T.create(e,r.toOperationNode());let t=T.create(e);if(!r)return t;return r(new j({node:t})).toOperationNode()}var Ar=p({is(e){return e.kind==="PartitionByItemNode"},create(e){return p({kind:"PartitionByItemNode",partitionBy:e})}});function qr(e){return z(e).map(Ar.create)}class ne{#e;constructor(e){this.#e=p(e)}orderBy(...e){return new ne({overNode:Ne.cloneWithOrderByItems(this.#e.overNode,E(e))})}clearOrderBy(){return new ne({overNode:fe.cloneWithoutOrderBy(this.#e.overNode)})}partitionBy(e){return new ne({overNode:Ne.cloneWithPartitionByItems(this.#e.overNode,qr(e))})}$call(e){return e(this)}toOperationNode(){return this.#e.overNode}}var se=p({is(e){return e.kind==="SelectionNode"},create(e){return p({kind:"SelectionNode",selection:e})},createSelectAll(){return p({kind:"SelectionNode",selection:ol.create()})},createSelectAllFromTable(e){return p({kind:"SelectionNode",selection:te.createSelectAll(e)})}});class vf{#e;get table(){return this.#e}constructor(e){this.#e=e}as(e){return new Lr(this.#e,e)}}class Lr{#e;#r;get table(){return this.#e}get alias(){return this.#r}constructor(e,r){this.#e=e,this.#r=r}toOperationNode(){return l.create(zt(this.#e),je.create(this.#r))}}function Br(e){return Mr(e)&&pr(e)&&Qt(e.table)&&Qt(e.alias)}function A(e){if(Ln(e))return e.map((r)=>Y(r));else return[Y(e)]}function Y(e){if(Qt(e))return tr(e);else if(Br(e))return e.toOperationNode();else return Fe(e)}function tr(e){if(e.includes(" as ")){let[t,o]=e.split(" as ").map(Dr);return l.create(zt(t),je.create(o))}else return zt(e)}function zt(e){if(e.includes(".")){let[t,o]=e.split(".").map(Dr);return g.createWithSchema(t,o)}else return g.create(e)}function Dr(e){return e.trim()}function f(e){if(Kt(e))return f(e(q()));else if(Ln(e))return e.map((r)=>Fr(r));else return[Fr(e)]}function Fr(e){if(Qt(e))return se.create(Pr(e));else if(De(e))return se.create(e.toOperationNode());else return se.create(Fe(e))}function y(e){if(!e)return[se.createSelectAll()];else if(Array.isArray(e))return e.map(vr);else return[vr(e)]}function vr(e){if(Qt(e))return se.createSelectAllFromTable(zt(e));throw Error(`invalid value selectAll expression: ${JSON.stringify(e)}`)}var Vr=p({is(e){return e.kind==="ValuesNode"},create(e){return p({kind:"ValuesNode",values:p(e)})}});var Ur=p({is(e){return e.kind==="DefaultInsertValueNode"},create(){return p({kind:"DefaultInsertValueNode"})}});function ve(e){let r=Kt(e)?e(q()):e,t=Ln(r)?r:p([r]);return gt(t)}function gt(e){let r=Wt(e);return[p([...r.keys()].map(Zt.create)),Vr.create(e.map((t)=>bt(t,r)))]}function Wt(e){let r=new Map;for(let t of e){let o=Object.keys(t);for(let n of o)if(!r.has(n)&&t[n]!==void 0)r.set(n,r.size)}return r}function bt(e,r){let t=Object.keys(e),o=Array.from({length:r.size}),n=!1,u=t.length;for(let Ce of t){let pe=r.get(Ce);if(Fn(pe)){u--;continue}let Ie=e[Ce];if(Fn(Ie)||V(Ie))n=!0;o[pe]=Ie}if(u<r.size||n){let Ce=Ur.create();return $i.create(o.map((pe)=>Fn(pe)?Ce:m(pe)))}return Ae.create(o)}var or=p({is(e){return e.kind==="ColumnUpdateNode"},create(e,r){return p({kind:"ColumnUpdateNode",column:e,value:r})}});function zr(...e){if(e.length===2)return[or.create(w(e[0]),m(e[1]))];return we(e[0])}function we(e){let r=Kt(e)?e(q()):e;return Object.entries(r).filter(([t,o])=>o!==void 0).map(([t,o])=>or.create(Zt.create(t),m(o)))}var Jr=p({is(e){return e.kind==="OnDuplicateKeyNode"},create(e){return p({kind:"OnDuplicateKeyNode",updates:e})}});class nr{insertId;numInsertedOrUpdatedRows;constructor(e,r){this.insertId=e,this.numInsertedOrUpdatedRows=r}}class L extends Error{node;constructor(e){super("no result");this.node=e}}function v(e){return Object.prototype.hasOwnProperty.call(e,"prototype")}var x=p({is(e){return e.kind==="OnConflictNode"},create(){return p({kind:"OnConflictNode"})},cloneWith(e,r){return p({...e,...r})},cloneWithIndexWhere(e,r){return p({...e,indexWhere:e.indexWhere?O.cloneWithOperation(e.indexWhere,"And",r):O.create(r)})},cloneWithIndexOrWhere(e,r){return p({...e,indexWhere:e.indexWhere?O.cloneWithOperation(e.indexWhere,"Or",r):O.create(r)})},cloneWithUpdateWhere(e,r){return p({...e,updateWhere:e.updateWhere?O.cloneWithOperation(e.updateWhere,"And",r):O.create(r)})},cloneWithUpdateOrWhere(e,r){return p({...e,updateWhere:e.updateWhere?O.cloneWithOperation(e.updateWhere,"Or",r):O.create(r)})},cloneWithoutIndexWhere(e){return p({...e,indexWhere:void 0})},cloneWithoutUpdateWhere(e){return p({...e,updateWhere:void 0})}});class P{#e;constructor(e){this.#e=p(e)}column(e){let r=Zt.create(e);return new P({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?p([...this.#e.onConflictNode.columns,r]):p([r])})})}columns(e){let r=e.map(Zt.create);return new P({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?p([...this.#e.onConflictNode.columns,...r]):p(r)})})}constraint(e){return new P({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{constraint:je.create(e)})})}expression(e){return new P({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{indexExpression:e.toOperationNode()})})}where(...e){return new P({...this.#e,onConflictNode:x.cloneWithIndexWhere(this.#e.onConflictNode,ir(e))})}whereRef(e,r,t){return new P({...this.#e,onConflictNode:x.cloneWithIndexWhere(this.#e.onConflictNode,N(e,r,t))})}clearWhere(){return new P({...this.#e,onConflictNode:x.cloneWithoutIndexWhere(this.#e.onConflictNode)})}doNothing(){return new Qr({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{doNothing:!0})})}doUpdateSet(e){return new xe({...this.#e,onConflictNode:x.cloneWith(this.#e.onConflictNode,{updates:we(e)})})}$call(e){return e(this)}}class Qr{#e;constructor(e){this.#e=p(e)}toOperationNode(){return this.#e.onConflictNode}}class xe{#e;constructor(e){this.#e=p(e)}where(...e){return new xe({...this.#e,onConflictNode:x.cloneWithUpdateWhere(this.#e.onConflictNode,ir(e))})}whereRef(e,r,t){return new xe({...this.#e,onConflictNode:x.cloneWithUpdateWhere(this.#e.onConflictNode,N(e,r,t))})}clearWhere(){return new xe({...this.#e,onConflictNode:x.cloneWithoutUpdateWhere(this.#e.onConflictNode)})}$call(e){return e(this)}toOperationNode(){return this.#e.onConflictNode}}var Ir=p({is(e){return e.kind==="TopNode"},create(e,r){return p({kind:"TopNode",expression:e,modifiers:r})}});function B(e,r){if(!$o(e)&&!ui(e))throw Error(`Invalid top expression: ${e}`);if(!Fn(r)&&!St(r))throw Error(`Invalid top modifiers: ${r}`);return Ir.create(e,r)}function St(e){return e==="percent"||e==="with ties"||e==="percent with ties"}var Z=p({is(e){return e.kind==="OrActionNode"},create(e){return p({kind:"OrActionNode",action:e})}});class d{#e;constructor(e){this.#e=p(e)}values(e){let[r,t]=ve(e);return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{columns:r,values:t})})}columns(e){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{columns:p(e.map(Zt.create))})})}expression(e){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{values:Ao(e)})})}defaultValues(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{defaultValues:!0})})}modifyEnd(e){return new d({...this.#e,queryNode:fe.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}ignore(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{orAction:Z.create("ignore")})})}orIgnore(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{orAction:Z.create("ignore")})})}orAbort(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{orAction:Z.create("abort")})})}orFail(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{orAction:Z.create("fail")})})}orReplace(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{orAction:Z.create("replace")})})}orRollback(){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{orAction:Z.create("rollback")})})}top(e,r){return new d({...this.#e,queryNode:fe.cloneWithTop(this.#e.queryNode,B(e,r))})}onConflict(e){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{onConflict:e(new P({onConflictNode:x.create()})).toOperationNode()})})}onDuplicateKeyUpdate(e){return new d({...this.#e,queryNode:kr.cloneWith(this.#e.queryNode,{onDuplicateKey:Jr.create(we(e))})})}returning(e){return new d({...this.#e,queryNode:fe.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(){return new d({...this.#e,queryNode:fe.cloneWithReturning(this.#e.queryNode,y())})}output(e){return new d({...this.#e,queryNode:fe.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new d({...this.#e,queryNode:fe.cloneWithOutput(this.#e.queryNode,y(e))})}clearReturning(){return new d({...this.#e,queryNode:fe.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new d({...this.#e})}$castTo(){return new d(this.#e)}$narrowType(){return new d(this.#e)}$assertType(){return new d(this.#e)}withPlugin(e){return new d({...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(),r=await this.#e.executor.executeQuery(e),{adapter:t}=this.#e.executor,o=e.query;if(o.returning&&t.supportsReturning||o.output&&t.supportsOutput)return r.rows;return[new nr(r.insertId,r.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=L){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){let r=this.compile(),t=this.#e.executor.stream(r,e);for await(let o of t)yield*o.rows}async explain(e,r){return await new d({...this.#e,queryNode:fe.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}class sr{numDeletedRows;constructor(e){this.numDeletedRows=e}}var ae=p({is(e){return e.kind==="LimitNode"},create(e){return p({kind:"LimitNode",limit:e})}});var c;class Pe{#e;constructor(e){this.#e=p(e)}where(...e){return new c({...this.#e,queryNode:fe.cloneWithWhere(this.#e.queryNode,ir(e))})}whereRef(e,r,t){return new c({...this.#e,queryNode:fe.cloneWithWhere(this.#e.queryNode,N(e,r,t))})}clearWhere(){return new c({...this.#e,queryNode:fe.cloneWithoutWhere(this.#e.queryNode)})}top(e,r){return new c({...this.#e,queryNode:fe.cloneWithTop(this.#e.queryNode,B(e,r))})}using(e){return new c({...this.#e,queryNode:_.cloneWithUsing(this.#e.queryNode,A(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,r){return new c({...this.#e,queryNode:fe.cloneWithJoin(this.#e.queryNode,G(e,r))})}returning(e){return new c({...this.#e,queryNode:fe.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(e){return new c({...this.#e,queryNode:fe.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new c({...this.#e,queryNode:fe.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new c({...this.#e,queryNode:fe.cloneWithOutput(this.#e.queryNode,y(e))})}clearReturning(){return new c({...this.#e,queryNode:fe.cloneWithoutReturning(this.#e.queryNode)})}clearLimit(){return new c({...this.#e,queryNode:_.cloneWithoutLimit(this.#e.queryNode)})}orderBy(...e){return new c({...this.#e,queryNode:fe.cloneWithOrderByItems(this.#e.queryNode,E(e))})}clearOrderBy(){return new c({...this.#e,queryNode:fe.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new c({...this.#e,queryNode:_.cloneWithLimit(this.#e.queryNode,ae.create(m(e)))})}modifyEnd(e){return new c({...this.#e,queryNode:fe.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new c({...this.#e})}$castTo(){return new c(this.#e)}$narrowType(){return new c(this.#e)}$assertType(){return new c(this.#e)}withPlugin(e){return new c({...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(),r=await this.#e.executor.executeQuery(e),{adapter:t}=this.#e.executor,o=e.query;if(o.returning&&t.supportsReturning||o.output&&t.supportsOutput)return r.rows;return[new sr(r.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=L){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){let r=this.compile(),t=this.#e.executor.stream(r,e);for await(let o of t)yield*o.rows}async explain(e,r){return await new c({...this.#e,queryNode:fe.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}c=Pe;class ar{numUpdatedRows;numChangedRows;constructor(e,r){this.numUpdatedRows=e,this.numChangedRows=r}}var h;class ue{#e;constructor(e){this.#e=p(e)}where(...e){return new h({...this.#e,queryNode:fe.cloneWithWhere(this.#e.queryNode,ir(e))})}whereRef(e,r,t){return new h({...this.#e,queryNode:fe.cloneWithWhere(this.#e.queryNode,N(e,r,t))})}clearWhere(){return new h({...this.#e,queryNode:fe.cloneWithoutWhere(this.#e.queryNode)})}top(e,r){return new h({...this.#e,queryNode:fe.cloneWithTop(this.#e.queryNode,B(e,r))})}from(e){return new h({...this.#e,queryNode:F.cloneWithFromItems(this.#e.queryNode,A(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,r){return new h({...this.#e,queryNode:fe.cloneWithJoin(this.#e.queryNode,G(e,r))})}orderBy(...e){return new h({...this.#e,queryNode:fe.cloneWithOrderByItems(this.#e.queryNode,E(e))})}clearOrderBy(){return new h({...this.#e,queryNode:fe.cloneWithoutOrderBy(this.#e.queryNode)})}limit(e){return new h({...this.#e,queryNode:F.cloneWithLimit(this.#e.queryNode,ae.create(m(e)))})}set(...e){return new h({...this.#e,queryNode:F.cloneWithUpdates(this.#e.queryNode,zr(...e))})}returning(e){return new h({...this.#e,queryNode:fe.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(e){return new h({...this.#e,queryNode:fe.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new h({...this.#e,queryNode:fe.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new h({...this.#e,queryNode:fe.cloneWithOutput(this.#e.queryNode,y(e))})}modifyEnd(e){return new h({...this.#e,queryNode:fe.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}clearReturning(){return new h({...this.#e,queryNode:fe.cloneWithoutReturning(this.#e.queryNode)})}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new h({...this.#e})}$castTo(){return new h(this.#e)}$narrowType(){return new h(this.#e)}$assertType(){return new h(this.#e)}withPlugin(e){return new h({...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(),r=await this.#e.executor.executeQuery(e),{adapter:t}=this.#e.executor,o=e.query;if(o.returning&&t.supportsReturning||o.output&&t.supportsOutput)return r.rows;return[new ar(r.numAffectedRows??BigInt(0),r.numChangedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=L){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){let r=this.compile(),t=this.#e.executor.stream(r,e);for await(let o of t)yield*o.rows}async explain(e,r){return await new h({...this.#e,queryNode:fe.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}h=ue;var ur=p({is(e){return e.kind==="CommonTableExpressionNameNode"},create(e,r){return p({kind:"CommonTableExpressionNameNode",table:g.create(e),columns:r?p(r.map(Zt.create)):void 0})}});var me=p({is(e){return e.kind==="CommonTableExpressionNode"},create(e,r){return p({kind:"CommonTableExpressionNode",name:e,expression:r})},cloneWith(e,r){return p({...e,...r})}});class ge{#e;constructor(e){this.#e=p(e)}materialized(){return new ge({...this.#e,node:me.cloneWith(this.#e.node,{materialized:!0})})}notMaterialized(){return new ge({...this.#e,node:me.cloneWith(this.#e.node,{materialized:!1})})}toOperationNode(){return this.#e.node}}function dr(e,r){let t=r(_r()).toOperationNode();if(Kt(e))return e(kt(t)).toOperationNode();return me.create($r(e),t)}function kt(e){return(r)=>new ge({node:me.create($r(r),e)})}function $r(e){if(e.includes("(")){let r=e.split(/[\(\)]/),t=r[0],o=r[1].split(",").map((n)=>n.trim());return ur.create(t,o)}else return ur.create(e)}var We=p({is(e){return e.kind==="WithNode"},create(e,r){return p({kind:"WithNode",expressions:p([e]),...r})},cloneWithExpression(e,r){return p({...e,expressions:p([...e.expressions,r])})}});var jr=["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 Ru(e){let r="";for(let t=0;t<e;++t)r+=Et();return r}function Et(){return jr[~~(Math.random()*jr.length)]}function Je(){return new Gr}class Gr{#e;get queryId(){if(this.#e===void 0)this.#e=Ru(8);return this.#e}}function i(e){return e}class bc{nodeStack=[];#e=p({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,r){if(!e)return e;this.nodeStack.push(e);let t=this.transformNodeImpl(e,r);return this.nodeStack.pop(),p(t)}transformNodeImpl(e,r){return this.#e[e.kind](e,r)}transformNodeList(e,r){if(!e)return e;return p(e.map((t)=>this.transformNode(t,r)))}transformSelectQuery(e,r){return i({kind:"SelectQueryNode",from:this.transformNode(e.from,r),selections:this.transformNodeList(e.selections,r),distinctOn:this.transformNodeList(e.distinctOn,r),joins:this.transformNodeList(e.joins,r),groupBy:this.transformNode(e.groupBy,r),orderBy:this.transformNode(e.orderBy,r),where:this.transformNode(e.where,r),frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),limit:this.transformNode(e.limit,r),offset:this.transformNode(e.offset,r),with:this.transformNode(e.with,r),having:this.transformNode(e.having,r),explain:this.transformNode(e.explain,r),setOperations:this.transformNodeList(e.setOperations,r),fetch:this.transformNode(e.fetch,r),top:this.transformNode(e.top,r)})}transformSelection(e,r){return i({kind:"SelectionNode",selection:this.transformNode(e.selection,r)})}transformColumn(e,r){return i({kind:"ColumnNode",column:this.transformNode(e.column,r)})}transformAlias(e,r){return i({kind:"AliasNode",node:this.transformNode(e.node,r),alias:this.transformNode(e.alias,r)})}transformTable(e,r){return i({kind:"TableNode",table:this.transformNode(e.table,r)})}transformFrom(e,r){return i({kind:"FromNode",froms:this.transformNodeList(e.froms,r)})}transformReference(e,r){return i({kind:"ReferenceNode",column:this.transformNode(e.column,r),table:this.transformNode(e.table,r)})}transformAnd(e,r){return i({kind:"AndNode",left:this.transformNode(e.left,r),right:this.transformNode(e.right,r)})}transformOr(e,r){return i({kind:"OrNode",left:this.transformNode(e.left,r),right:this.transformNode(e.right,r)})}transformValueList(e,r){return i({kind:"ValueListNode",values:this.transformNodeList(e.values,r)})}transformParens(e,r){return i({kind:"ParensNode",node:this.transformNode(e.node,r)})}transformJoin(e,r){return i({kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,r),on:this.transformNode(e.on,r)})}transformRaw(e,r){return i({kind:"RawNode",sqlFragments:p([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,r)})}transformWhere(e,r){return i({kind:"WhereNode",where:this.transformNode(e.where,r)})}transformInsertQuery(e,r){return i({kind:"InsertQueryNode",into:this.transformNode(e.into,r),columns:this.transformNodeList(e.columns,r),values:this.transformNode(e.values,r),returning:this.transformNode(e.returning,r),onConflict:this.transformNode(e.onConflict,r),onDuplicateKey:this.transformNode(e.onDuplicateKey,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),ignore:e.ignore,orAction:this.transformNode(e.orAction,r),replace:e.replace,explain:this.transformNode(e.explain,r),defaultValues:e.defaultValues,top:this.transformNode(e.top,r),output:this.transformNode(e.output,r)})}transformValues(e,r){return i({kind:"ValuesNode",values:this.transformNodeList(e.values,r)})}transformDeleteQuery(e,r){return i({kind:"DeleteQueryNode",from:this.transformNode(e.from,r),using:this.transformNode(e.using,r),joins:this.transformNodeList(e.joins,r),where:this.transformNode(e.where,r),returning:this.transformNode(e.returning,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),orderBy:this.transformNode(e.orderBy,r),limit:this.transformNode(e.limit,r),explain:this.transformNode(e.explain,r),top:this.transformNode(e.top,r),output:this.transformNode(e.output,r)})}transformReturning(e,r){return i({kind:"ReturningNode",selections:this.transformNodeList(e.selections,r)})}transformCreateTable(e,r){return i({kind:"CreateTableNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),constraints:this.transformNodeList(e.constraints,r),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),selectQuery:this.transformNode(e.selectQuery,r)})}transformColumnDefinition(e,r){return i({kind:"ColumnDefinitionNode",column:this.transformNode(e.column,r),dataType:this.transformNode(e.dataType,r),references:this.transformNode(e.references,r),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,r),check:this.transformNode(e.check,r),generated:this.transformNode(e.generated,r),frontModifiers:this.transformNodeList(e.frontModifiers,r),endModifiers:this.transformNodeList(e.endModifiers,r),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists})}transformAddColumn(e,r){return i({kind:"AddColumnNode",column:this.transformNode(e.column,r)})}transformDropTable(e,r){return i({kind:"DropTableNode",table:this.transformNode(e.table,r),ifExists:e.ifExists,cascade:e.cascade})}transformOrderBy(e,r){return i({kind:"OrderByNode",items:this.transformNodeList(e.items,r)})}transformOrderByItem(e,r){return i({kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,r),direction:this.transformNode(e.direction,r),collation:this.transformNode(e.collation,r),nulls:e.nulls})}transformGroupBy(e,r){return i({kind:"GroupByNode",items:this.transformNodeList(e.items,r)})}transformGroupByItem(e,r){return i({kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,r)})}transformUpdateQuery(e,r){return i({kind:"UpdateQueryNode",table:this.transformNode(e.table,r),from:this.transformNode(e.from,r),joins:this.transformNodeList(e.joins,r),where:this.transformNode(e.where,r),updates:this.transformNodeList(e.updates,r),returning:this.transformNode(e.returning,r),endModifiers:this.transformNodeList(e.endModifiers,r),with:this.transformNode(e.with,r),explain:this.transformNode(e.explain,r),limit:this.transformNode(e.limit,r),top:this.transformNode(e.top,r),output:this.transformNode(e.output,r),orderBy:this.transformNode(e.orderBy,r)})}transformColumnUpdate(e,r){return i({kind:"ColumnUpdateNode",column:this.transformNode(e.column,r),value:this.transformNode(e.value,r)})}transformLimit(e,r){return i({kind:"LimitNode",limit:this.transformNode(e.limit,r)})}transformOffset(e,r){return i({kind:"OffsetNode",offset:this.transformNode(e.offset,r)})}transformOnConflict(e,r){return i({kind:"OnConflictNode",columns:this.transformNodeList(e.columns,r),constraint:this.transformNode(e.constraint,r),indexExpression:this.transformNode(e.indexExpression,r),indexWhere:this.transformNode(e.indexWhere,r),updates:this.transformNodeList(e.updates,r),updateWhere:this.transformNode(e.updateWhere,r),doNothing:e.doNothing})}transformOnDuplicateKey(e,r){return i({kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,r)})}transformCreateIndex(e,r){return i({kind:"CreateIndexNode",name:this.transformNode(e.name,r),table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),unique:e.unique,using:this.transformNode(e.using,r),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,r),nullsNotDistinct:e.nullsNotDistinct})}transformList(e,r){return i({kind:"ListNode",items:this.transformNodeList(e.items,r)})}transformDropIndex(e,r){return i({kind:"DropIndexNode",name:this.transformNode(e.name,r),table:this.transformNode(e.table,r),ifExists:e.ifExists,cascade:e.cascade})}transformPrimaryKeyConstraint(e,r){return i({kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,r),name:this.transformNode(e.name,r),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred})}transformUniqueConstraint(e,r){return i({kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,r),name:this.transformNode(e.name,r),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred})}transformForeignKeyConstraint(e,r){return i({kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,r),references:this.transformNode(e.references,r),name:this.transformNode(e.name,r),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred})}transformSetOperation(e,r){return i({kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,r),all:e.all})}transformReferences(e,r){return i({kind:"ReferencesNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r),onDelete:e.onDelete,onUpdate:e.onUpdate})}transformCheckConstraint(e,r){return i({kind:"CheckConstraintNode",expression:this.transformNode(e.expression,r),name:this.transformNode(e.name,r)})}transformWith(e,r){return i({kind:"WithNode",expressions:this.transformNodeList(e.expressions,r),recursive:e.recursive})}transformCommonTableExpression(e,r){return i({kind:"CommonTableExpressionNode",name:this.transformNode(e.name,r),materialized:e.materialized,expression:this.transformNode(e.expression,r)})}transformCommonTableExpressionName(e,r){return i({kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,r),columns:this.transformNodeList(e.columns,r)})}transformHaving(e,r){return i({kind:"HavingNode",having:this.transformNode(e.having,r)})}transformCreateSchema(e,r){return i({kind:"CreateSchemaNode",schema:this.transformNode(e.schema,r),ifNotExists:e.ifNotExists})}transformDropSchema(e,r){return i({kind:"DropSchemaNode",schema:this.transformNode(e.schema,r),ifExists:e.ifExists,cascade:e.cascade})}transformAlterTable(e,r){return i({kind:"AlterTableNode",table:this.transformNode(e.table,r),renameTo:this.transformNode(e.renameTo,r),setSchema:this.transformNode(e.setSchema,r),columnAlterations:this.transformNodeList(e.columnAlterations,r),addConstraint:this.transformNode(e.addConstraint,r),dropConstraint:this.transformNode(e.dropConstraint,r),renameConstraint:this.transformNode(e.renameConstraint,r),addIndex:this.transformNode(e.addIndex,r),dropIndex:this.transformNode(e.dropIndex,r)})}transformDropColumn(e,r){return i({kind:"DropColumnNode",column:this.transformNode(e.column,r)})}transformRenameColumn(e,r){return i({kind:"RenameColumnNode",column:this.transformNode(e.column,r),renameTo:this.transformNode(e.renameTo,r)})}transformAlterColumn(e,r){return i({kind:"AlterColumnNode",column:this.transformNode(e.column,r),dataType:this.transformNode(e.dataType,r),dataTypeExpression:this.transformNode(e.dataTypeExpression,r),setDefault:this.transformNode(e.setDefault,r),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull})}transformModifyColumn(e,r){return i({kind:"ModifyColumnNode",column:this.transformNode(e.column,r)})}transformAddConstraint(e,r){return i({kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,r)})}transformDropConstraint(e,r){return i({kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,r),ifExists:e.ifExists,modifier:e.modifier})}transformRenameConstraint(e,r){return i({kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,r),newName:this.transformNode(e.newName,r)})}transformCreateView(e,r){return i({kind:"CreateViewNode",name:this.transformNode(e.name,r),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,r),as:this.transformNode(e.as,r)})}transformRefreshMaterializedView(e,r){return i({kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,r),concurrently:e.concurrently,withNoData:e.withNoData})}transformDropView(e,r){return i({kind:"DropViewNode",name:this.transformNode(e.name,r),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade})}transformGenerated(e,r){return i({kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,r)})}transformDefaultValue(e,r){return i({kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,r)})}transformOn(e,r){return i({kind:"OnNode",on:this.transformNode(e.on,r)})}transformSelectModifier(e,r){return i({kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,r),of:this.transformNodeList(e.of,r)})}transformCreateType(e,r){return i({kind:"CreateTypeNode",name:this.transformNode(e.name,r),enum:this.transformNode(e.enum,r)})}transformDropType(e,r){return i({kind:"DropTypeNode",name:this.transformNode(e.name,r),ifExists:e.ifExists})}transformExplain(e,r){return i({kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,r)})}transformSchemableIdentifier(e,r){return i({kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,r),identifier:this.transformNode(e.identifier,r)})}transformAggregateFunction(e,r){return i({kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,r),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,r),withinGroup:this.transformNode(e.withinGroup,r),filter:this.transformNode(e.filter,r),over:this.transformNode(e.over,r)})}transformOver(e,r){return i({kind:"OverNode",orderBy:this.transformNode(e.orderBy,r),partitionBy:this.transformNode(e.partitionBy,r)})}transformPartitionBy(e,r){return i({kind:"PartitionByNode",items:this.transformNodeList(e.items,r)})}transformPartitionByItem(e,r){return i({kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,r)})}transformBinaryOperation(e,r){return i({kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,r),operator:this.transformNode(e.operator,r),rightOperand:this.transformNode(e.rightOperand,r)})}transformUnaryOperation(e,r){return i({kind:"UnaryOperationNode",operator:this.transformNode(e.operator,r),operand:this.transformNode(e.operand,r)})}transformUsing(e,r){return i({kind:"UsingNode",tables:this.transformNodeList(e.tables,r)})}transformFunction(e,r){return i({kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,r)})}transformCase(e,r){return i({kind:"CaseNode",value:this.transformNode(e.value,r),when:this.transformNodeList(e.when,r),else:this.transformNode(e.else,r),isStatement:e.isStatement})}transformWhen(e,r){return i({kind:"WhenNode",condition:this.transformNode(e.condition,r),result:this.transformNode(e.result,r)})}transformJSONReference(e,r){return i({kind:"JSONReferenceNode",reference:this.transformNode(e.reference,r),traversal:this.transformNode(e.traversal,r)})}transformJSONPath(e,r){return i({kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,r),pathLegs:this.transformNodeList(e.pathLegs,r)})}transformJSONPathLeg(e,r){return i({kind:"JSONPathLegNode",type:e.type,value:e.value})}transformJSONOperatorChain(e,r){return i({kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,r),values:this.transformNodeList(e.values,r)})}transformTuple(e,r){return i({kind:"TupleNode",values:this.transformNodeList(e.values,r)})}transformMergeQuery(e,r){return i({kind:"MergeQueryNode",into:this.transformNode(e.into,r),using:this.transformNode(e.using,r),whens:this.transformNodeList(e.whens,r),with:this.transformNode(e.with,r),top:this.transformNode(e.top,r),endModifiers:this.transformNodeList(e.endModifiers,r),output:this.transformNode(e.output,r),returning:this.transformNode(e.returning,r)})}transformMatched(e,r){return i({kind:"MatchedNode",not:e.not,bySource:e.bySource})}transformAddIndex(e,r){return i({kind:"AddIndexNode",name:this.transformNode(e.name,r),columns:this.transformNodeList(e.columns,r),unique:e.unique,using:this.transformNode(e.using,r),ifNotExists:e.ifNotExists})}transformCast(e,r){return i({kind:"CastNode",expression:this.transformNode(e.expression,r),dataType:this.transformNode(e.dataType,r)})}transformFetch(e,r){return i({kind:"FetchNode",rowCount:this.transformNode(e.rowCount,r),modifier:e.modifier})}transformTop(e,r){return i({kind:"TopNode",expression:e.expression,modifiers:e.modifiers})}transformOutput(e,r){return i({kind:"OutputNode",selections:this.transformNodeList(e.selections,r)})}transformDataType(e,r){return e}transformSelectAll(e,r){return e}transformIdentifier(e,r){return e}transformValue(e,r){return e}transformPrimitiveValueList(e,r){return e}transformOperator(e,r){return e}transformDefaultInsertValue(e,r){return e}transformOrAction(e,r){return e}transformCollate(e,r){return e}}var Ct=p({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}),Rt={json_agg:!0,to_json:!0};class cr extends bc{#e;#r=new Set;#t=new Set;constructor(e){super();this.#e=e}transformNodeImpl(e,r){if(!this.#s(e))return super.transformNodeImpl(e,r);let t=this.#u(e);for(let u of t)this.#t.add(u);let o=this.#a(e);for(let u of o)this.#r.add(u);let n=super.transformNodeImpl(e,r);for(let u of o)this.#r.delete(u);for(let u of t)this.#t.delete(u);return n}transformSchemableIdentifier(e,r){let t=super.transformSchemableIdentifier(e,r);if(t.schema||!this.#r.has(e.identifier.name))return t;return{...t,schema:je.create(this.#e)}}transformReferences(e,r){let t=super.transformReferences(e,r);if(t.table.table.schema)return t;return{...t,table:g.createWithSchema(this.#e,t.table.table.identifier.name)}}transformAggregateFunction(e,r){return{...super.transformAggregateFunction({...e,aggregated:[]},r),aggregated:this.#i(e,r,"aggregated")}}transformFunction(e,r){return{...super.transformFunction({...e,arguments:[]},r),arguments:this.#i(e,r,"arguments")}}transformSelectModifier(e,r){return{...super.transformSelectModifier({...e,of:void 0},r),of:e.of?.map((t)=>g.is(t)&&!t.table.schema?{...t,table:this.transformIdentifier(t.table.identifier,r)}:this.transformNode(t,r))}}#i(e,r,t){return Rt[e.func]?e[t].map((o)=>!g.is(o)||o.table.schema?this.transformNode(o,r):{...o,table:this.transformIdentifier(o.table.identifier,r)}):this.transformNodeList(e[t],r)}#s(e){return e.kind in Ct}#a(e){let r=new Set;if("name"in e&&e.name&&En.is(e.name))this.#n(e.name,r);if("from"in e&&e.from)for(let t of e.from.froms)this.#o(t,r);if("into"in e&&e.into)this.#o(e.into,r);if("table"in e&&e.table)this.#o(e.table,r);if("joins"in e&&e.joins)for(let t of e.joins)this.#o(t.table,r);if("using"in e&&e.using)if(R.is(e.using))this.#o(e.using.table,r);else this.#o(e.using,r);return r}#u(e){let r=new Set;if("with"in e&&e.with)this.#m(e.with,r);return r}#o(e,r){if(g.is(e))return this.#n(e.table,r);if(l.is(e)&&g.is(e.node))return this.#n(e.node.table,r);if(Be.is(e)){for(let t of e.items)this.#o(t,r);return}if(ye.is(e)){for(let t of e.tables)this.#o(t,r);return}}#n(e,r){let t=e.identifier.name;if(!this.#r.has(t)&&!this.#t.has(t))r.add(t)}#m(e,r){for(let t of e.expressions){let o=t.name.table.table.identifier.name;if(!this.#t.has(o))r.add(o)}}}class cs{#e;constructor(e){this.#e=new cr(e)}transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}}var Kr=p({is(e){return e.kind==="MatchedNode"},create(e,r=!1){return p({kind:"MatchedNode",not:e,bySource:r})}});function hr(e,r,t){return Go.create(oe([Kr.create(!e.isMatched,e.bySource),...r&&r.length>0?[r.length===3&&t?N(r[0],r[1],r[2]):ir(r)]:[]],"and",!1))}function de(e){if(Qt(e))return Bt.create([e],[]);if(pr(e))return e.toOperationNode();return e}class Gi{#e;#r;#t;constructor(){this.#e=new Promise((e,r)=>{this.#t=r,this.#r=e})}get promise(){return this.#e}resolve=(e)=>{if(this.#r)this.#r(e)};reject=(e)=>{if(this.#t)this.#t(e)}}async function Pu(e){let r=new Gi,t=new Gi;return e.provideConnection(async(o)=>(r.resolve(o),await t.promise)).catch((o)=>r.reject(o)),p({connection:await r.promise,release:t.resolve})}var Tt=p([]);class vc{#e;constructor(e=Tt){this.#e=e}get plugins(){return this.#e}transformQuery(e,r){for(let t of this.#e){let o=t.transformQuery({node:e,queryId:r});if(o.kind===e.kind)e=o;else throw 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 ${o.kind}`].join(" "))}return e}async executeQuery(e){return await this.provideConnection(async(r)=>{let t=await r.executeQuery(e);if("numUpdatedOrDeletedRows"in t)ds("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`.");return await this.#r(t,e.queryId)})}async*stream(e,r){let{connection:t,release:o}=await Pu(this);try{for await(let n of t.streamQuery(e,r))yield await this.#r(n,e.queryId)}finally{o()}}async#r(e,r){for(let t of this.#e)e=await t.transformResult({result:e,queryId:r});return e}}class ce extends vc{get adapter(){throw Error("this query cannot be compiled to SQL")}compileQuery(){throw Error("this query cannot be compiled to SQL")}provideConnection(){throw Error("this query cannot be executed")}withConnectionProvider(){throw Error("this query cannot have a connection provider")}withPlugin(e){return new ce([...this.plugins,e])}withPlugins(e){return new ce([...this.plugins,...e])}withPluginAtFront(e){return new ce([e,...this.plugins])}withoutPlugins(){return new ce([])}}var K=new ce;class fr{numChangedRows;constructor(e){this.numChangedRows=e}}class J{#e;constructor(e){this.#e=p(e)}modifyEnd(e){return new J({...this.#e,queryNode:fe.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,r){return new J({...this.#e,queryNode:fe.cloneWithTop(this.#e.queryNode,B(e,r))})}using(...e){return new b({...this.#e,queryNode:k.cloneWithUsing(this.#e.queryNode,G("Using",e))})}returning(e){return new J({...this.#e,queryNode:fe.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(e){return new J({...this.#e,queryNode:fe.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new J({...this.#e,queryNode:fe.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new J({...this.#e,queryNode:fe.cloneWithOutput(this.#e.queryNode,y(e))})}}class b{#e;constructor(e){this.#e=p(e)}modifyEnd(e){return new b({...this.#e,queryNode:fe.cloneWithEndModifier(this.#e.queryNode,e.toOperationNode())})}top(e,r){return new b({...this.#e,queryNode:fe.cloneWithTop(this.#e.queryNode,B(e,r))})}whenMatched(){return this.#r([])}whenMatchedAnd(...e){return this.#r(e)}whenMatchedAndRef(e,r,t){return this.#r([e,r,t],!0)}#r(e,r){return new lr({...this.#e,queryNode:k.cloneWithWhen(this.#e.queryNode,hr({isMatched:!0},e,r))})}whenNotMatched(){return this.#t([])}whenNotMatchedAnd(...e){return this.#t(e)}whenNotMatchedAndRef(e,r,t){return this.#t([e,r,t],!0)}whenNotMatchedBySource(){return this.#t([],!1,!0)}whenNotMatchedBySourceAnd(...e){return this.#t(e,!1,!0)}whenNotMatchedBySourceAndRef(e,r,t){return this.#t([e,r,t],!0,!0)}returning(e){return new b({...this.#e,queryNode:fe.cloneWithReturning(this.#e.queryNode,f(e))})}returningAll(e){return new b({...this.#e,queryNode:fe.cloneWithReturning(this.#e.queryNode,y(e))})}output(e){return new b({...this.#e,queryNode:fe.cloneWithOutput(this.#e.queryNode,f(e))})}outputAll(e){return new b({...this.#e,queryNode:fe.cloneWithOutput(this.#e.queryNode,y(e))})}#t(e,r=!1,t=!1){let o={...this.#e,queryNode:k.cloneWithWhen(this.#e.queryNode,hr({isMatched:!1,bySource:t},e,r))};return new(t?lr:Xr)(o)}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new b({...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(),r=await this.#e.executor.executeQuery(e),{adapter:t}=this.#e.executor,o=e.query;if(o.returning&&t.supportsReturning||o.output&&t.supportsOutput)return r.rows;return[new fr(r.numAffectedRows)]}async executeTakeFirst(){let[e]=await this.execute();return e}async executeTakeFirstOrThrow(e=L){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}}class lr{#e;constructor(e){this.#e=p(e)}thenDelete(){return new b({...this.#e,queryNode:k.cloneWithThen(this.#e.queryNode,de("delete"))})}thenDoNothing(){return new b({...this.#e,queryNode:k.cloneWithThen(this.#e.queryNode,de("do nothing"))})}thenUpdate(e){return new b({...this.#e,queryNode:k.cloneWithThen(this.#e.queryNode,de(e(new ue({queryId:this.#e.queryId,executor:K,queryNode:F.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate((r)=>r.set(...e))}}class Xr{#e;constructor(e){this.#e=p(e)}thenDoNothing(){return new b({...this.#e,queryNode:k.cloneWithThen(this.#e.queryNode,de("do nothing"))})}thenInsertValues(e){let[r,t]=ve(e);return new b({...this.#e,queryNode:k.cloneWithThen(this.#e.queryNode,de(kr.cloneWith(kr.createWithoutInto(),{columns:r,values:t})))})}}class Ps{#e;constructor(e){this.#e=p(e)}selectFrom(e){return be({queryId:Je(),executor:this.#e.executor,queryNode:Gt.createFrom(A(e),this.#e.withNode)})}selectNoFrom(e){return be({queryId:Je(),executor:this.#e.executor,queryNode:Gt.cloneWithSelections(Gt.create(this.#e.withNode),f(e))})}insertInto(e){return new d({queryId:Je(),executor:this.#e.executor,queryNode:kr.create(zt(e),this.#e.withNode)})}replaceInto(e){return new d({queryId:Je(),executor:this.#e.executor,queryNode:kr.create(zt(e),this.#e.withNode,!0)})}deleteFrom(e){return new Pe({queryId:Je(),executor:this.#e.executor,queryNode:_.create(A(e),this.#e.withNode)})}updateTable(e){return new ue({queryId:Je(),executor:this.#e.executor,queryNode:F.create(A(e),this.#e.withNode)})}mergeInto(e){return new J({queryId:Je(),executor:this.#e.executor,queryNode:k.create(tr(e),this.#e.withNode)})}with(e,r){let t=dr(e,r);return new Ps({...this.#e,withNode:this.#e.withNode?We.cloneWithExpression(this.#e.withNode,t):We.create(t)})}withRecursive(e,r){let t=dr(e,r);return new Ps({...this.#e,withNode:this.#e.withNode?We.cloneWithExpression(this.#e.withNode,t):We.create(t,{recursive:!0})})}withPlugin(e){return new Ps({...this.#e,executor:this.#e.executor.withPlugin(e)})}withoutPlugins(){return new Ps({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(e){return new Ps({...this.#e,executor:this.#e.executor.withPluginAtFront(new cs(e))})}}function _r(){return new Ps({executor:K})}function Yr(e,r){return new ie({joinNode:R.create(e,Y(r))})}function Zr(){return new ne({overNode:Ne.create()})}function G(e,r){if(r.length===3)return qt(e,r[0],r[1],r[2]);else if(r.length===2)return At(e,r[0],r[1]);else if(r.length===1)return Lt(e,r[0]);else throw Error("not implemented")}function At(e,r,t){return t(Yr(e,r)).toOperationNode()}function qt(e,r,t,o){return R.createWithOn(e,Y(r),N(t,"=",o))}function Lt(e,r){return R.create(e,Y(r))}var et=p({is(e){return e.kind==="OffsetNode"},create(e){return p({kind:"OffsetNode",offset:e})}});var rt=p({is(e){return e.kind==="GroupByItemNode"},create(e){return p({kind:"GroupByItemNode",groupBy:e})}});function tt(e){return e=Kt(e)?e(q()):e,z(e).map(rt.create)}function ee(e,r,t){if(Kt(r))r=r(Me());if(!Ln(r))r=[r];return r.map((o)=>Ou.create(e,Ao(o),t))}class a{#e;constructor(e){this.#e=e}get expressionType(){return}as(e){return new ze(this,e)}or(...e){return new Ve(C.create(this.#e,ir(e)))}and(...e){return new Ue(W.create(this.#e,ir(e)))}$castTo(){return new a(this.#e)}$notNull(){return new a(this.#e)}toOperationNode(){return this.#e}}class ze{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return l.create(this.#e.toOperationNode(),pr(this.#r)?this.#r.toOperationNode():je.create(this.#r))}}class Ve{#e;constructor(e){this.#e=e}get expressionType(){return}as(e){return new ze(this,e)}or(...e){return new Ve(C.create(this.#e,ir(e)))}$castTo(){return new Ve(this.#e)}toOperationNode(){return Oo.create(this.#e)}}class Ue{#e;constructor(e){this.#e=e}get expressionType(){return}as(e){return new ze(this,e)}and(...e){return new Ue(W.create(this.#e,ir(e)))}$castTo(){return new Ue(this.#e)}toOperationNode(){return Oo.create(this.#e)}}var ot=p({is(e){return e.kind==="FetchNode"},create(e,r){return{kind:"FetchNode",rowCount:Hr.create(e),modifier:r}}});function it(e,r){if(!$o(e)&&!ui(e))throw Error(`Invalid fetch row count: ${e}`);if(!Dt(r))throw Error(`Invalid fetch modifier: ${r}`);return ot.create(e,r)}function Dt(e){return e==="only"||e==="with ties"}var s;class Nr{#e;constructor(e){this.#e=p(e)}get expressionType(){return}get isSelectQueryBuilder(){return!0}where(...e){return new s({...this.#e,queryNode:fe.cloneWithWhere(this.#e.queryNode,ir(e))})}whereRef(e,r,t){return new s({...this.#e,queryNode:fe.cloneWithWhere(this.#e.queryNode,N(e,r,t))})}having(...e){return new s({...this.#e,queryNode:Gt.cloneWithHaving(this.#e.queryNode,ir(e))})}havingRef(e,r,t){return new s({...this.#e,queryNode:Gt.cloneWithHaving(this.#e.queryNode,N(e,r,t))})}select(e){return new s({...this.#e,queryNode:Gt.cloneWithSelections(this.#e.queryNode,f(e))})}distinctOn(e){return new s({...this.#e,queryNode:Gt.cloneWithDistinctOn(this.#e.queryNode,z(e))})}modifyFront(e){return new s({...this.#e,queryNode:Gt.cloneWithFrontModifier(this.#e.queryNode,D.createWithExpression(e.toOperationNode()))})}modifyEnd(e){return new s({...this.#e,queryNode:fe.cloneWithEndModifier(this.#e.queryNode,D.createWithExpression(e.toOperationNode()))})}distinct(){return new s({...this.#e,queryNode:Gt.cloneWithFrontModifier(this.#e.queryNode,D.create("Distinct"))})}forUpdate(e){return new s({...this.#e,queryNode:fe.cloneWithEndModifier(this.#e.queryNode,D.create("ForUpdate",e?xc(e).map(zt):void 0))})}forShare(e){return new s({...this.#e,queryNode:fe.cloneWithEndModifier(this.#e.queryNode,D.create("ForShare",e?xc(e).map(zt):void 0))})}forKeyShare(e){return new s({...this.#e,queryNode:fe.cloneWithEndModifier(this.#e.queryNode,D.create("ForKeyShare",e?xc(e).map(zt):void 0))})}forNoKeyUpdate(e){return new s({...this.#e,queryNode:fe.cloneWithEndModifier(this.#e.queryNode,D.create("ForNoKeyUpdate",e?xc(e).map(zt):void 0))})}skipLocked(){return new s({...this.#e,queryNode:fe.cloneWithEndModifier(this.#e.queryNode,D.create("SkipLocked"))})}noWait(){return new s({...this.#e,queryNode:fe.cloneWithEndModifier(this.#e.queryNode,D.create("NoWait"))})}selectAll(e){return new s({...this.#e,queryNode:Gt.cloneWithSelections(this.#e.queryNode,y(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,r){return new s({...this.#e,queryNode:fe.cloneWithJoin(this.#e.queryNode,G(e,r))})}orderBy(...e){return new s({...this.#e,queryNode:fe.cloneWithOrderByItems(this.#e.queryNode,E(e))})}groupBy(e){return new s({...this.#e,queryNode:Gt.cloneWithGroupByItems(this.#e.queryNode,tt(e))})}limit(e){return new s({...this.#e,queryNode:Gt.cloneWithLimit(this.#e.queryNode,ae.create(m(e)))})}offset(e){return new s({...this.#e,queryNode:Gt.cloneWithOffset(this.#e.queryNode,et.create(m(e)))})}fetch(e,r="only"){return new s({...this.#e,queryNode:Gt.cloneWithFetch(this.#e.queryNode,it(e,r))})}top(e,r){return new s({...this.#e,queryNode:fe.cloneWithTop(this.#e.queryNode,B(e,r))})}union(e){return new s({...this.#e,queryNode:Gt.cloneWithSetOperations(this.#e.queryNode,ee("union",e,!1))})}unionAll(e){return new s({...this.#e,queryNode:Gt.cloneWithSetOperations(this.#e.queryNode,ee("union",e,!0))})}intersect(e){return new s({...this.#e,queryNode:Gt.cloneWithSetOperations(this.#e.queryNode,ee("intersect",e,!1))})}intersectAll(e){return new s({...this.#e,queryNode:Gt.cloneWithSetOperations(this.#e.queryNode,ee("intersect",e,!0))})}except(e){return new s({...this.#e,queryNode:Gt.cloneWithSetOperations(this.#e.queryNode,ee("except",e,!1))})}exceptAll(e){return new s({...this.#e,queryNode:Gt.cloneWithSetOperations(this.#e.queryNode,ee("except",e,!0))})}as(e){return new nt(this,e)}clearSelect(){return new s({...this.#e,queryNode:Gt.cloneWithoutSelections(this.#e.queryNode)})}clearWhere(){return new s({...this.#e,queryNode:fe.cloneWithoutWhere(this.#e.queryNode)})}clearLimit(){return new s({...this.#e,queryNode:Gt.cloneWithoutLimit(this.#e.queryNode)})}clearOffset(){return new s({...this.#e,queryNode:Gt.cloneWithoutOffset(this.#e.queryNode)})}clearOrderBy(){return new s({...this.#e,queryNode:fe.cloneWithoutOrderBy(this.#e.queryNode)})}clearGroupBy(){return new s({...this.#e,queryNode:Gt.cloneWithoutGroupBy(this.#e.queryNode)})}$call(e){return e(this)}$if(e,r){if(e)return r(this);return new s({...this.#e})}$castTo(){return new s(this.#e)}$narrowType(){return new s(this.#e)}$assertType(){return new s(this.#e)}$asTuple(){return new a(this.toOperationNode())}$asScalar(){return new a(this.toOperationNode())}withPlugin(e){return new s({...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=L){let r=await this.executeTakeFirst();if(r===void 0)throw v(e)?new e(this.toOperationNode()):e(this.toOperationNode());return r}async*stream(e=100){let r=this.compile(),t=this.#e.executor.stream(r,e);for await(let o of t)yield*o.rows}async explain(e,r){return await new s({...this.#e,queryNode:fe.cloneWithExplain(this.#e.queryNode,e,r)}).execute()}}s=Nr;function be(e){return new Nr(e)}class nt{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return l.create(this.#e.toOperationNode(),je.create(this.#r))}}var M=p({is(e){return e.kind==="AggregateFunctionNode"},create(e,r=[]){return p({kind:"AggregateFunctionNode",func:e,aggregated:r})},cloneWithDistinct(e){return p({...e,distinct:!0})},cloneWithOrderBy(e,r,t=!1){let o=t?"withinGroup":"orderBy";return p({...e,[o]:e[o]?U.cloneWithItems(e[o],r):U.create(r)})},cloneWithFilter(e,r){return p({...e,filter:e.filter?O.cloneWithOperation(e.filter,"And",r):O.create(r)})},cloneWithOrFilter(e,r){return p({...e,filter:e.filter?O.cloneWithOperation(e.filter,"Or",r):O.create(r)})},cloneWithOver(e,r){return p({...e,over:r})}});var yr=p({is(e){return e.kind==="FunctionNode"},create(e,r){return p({kind:"FunctionNode",func:e,arguments:r})}});class S{#e;constructor(e){this.#e=p(e)}get expressionType(){return}as(e){return new st(this,e)}distinct(){return new S({...this.#e,aggregateFunctionNode:M.cloneWithDistinct(this.#e.aggregateFunctionNode)})}orderBy(...e){return new S({...this.#e,aggregateFunctionNode:fe.cloneWithOrderByItems(this.#e.aggregateFunctionNode,E(e))})}clearOrderBy(){return new S({...this.#e,aggregateFunctionNode:fe.cloneWithoutOrderBy(this.#e.aggregateFunctionNode)})}withinGroupOrderBy(...e){return new S({...this.#e,aggregateFunctionNode:M.cloneWithOrderBy(this.#e.aggregateFunctionNode,E(e),!0)})}filterWhere(...e){return new S({...this.#e,aggregateFunctionNode:M.cloneWithFilter(this.#e.aggregateFunctionNode,ir(e))})}filterWhereRef(e,r,t){return new S({...this.#e,aggregateFunctionNode:M.cloneWithFilter(this.#e.aggregateFunctionNode,N(e,r,t))})}over(e){let r=Zr();return new S({...this.#e,aggregateFunctionNode:M.cloneWithOver(this.#e.aggregateFunctionNode,(e?e(r):r).toOperationNode())})}$call(e){return e(this)}$castTo(){return new S(this.#e)}$notNull(){return new S(this.#e)}toOperationNode(){return this.#e.aggregateFunctionNode}}class st{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return l.create(this.#e.toOperationNode(),je.create(this.#r))}}function Nu(){let e=(t,o)=>new a(yr.create(t,z(o??[]))),r=(t,o)=>new S({aggregateFunctionNode:M.create(t,o?z(o):void 0)});return Object.assign(e,{agg:r,avg(t){return r("avg",[t])},coalesce(...t){return e("coalesce",t)},count(t){return r("count",[t])},countAll(t){return new S({aggregateFunctionNode:M.create("count",y(t))})},max(t){return r("max",[t])},min(t){return r("min",[t])},sum(t){return r("sum",[t])},any(t){return e("any",[t])},jsonAgg(t){return new S({aggregateFunctionNode:M.create("json_agg",[Qt(t)?zt(t):t.toOperationNode()])})},toJson(t){return new a(yr.create("to_json",[Qt(t)?zt(t):t.toOperationNode()]))}})}var at=p({is(e){return e.kind==="UnaryOperationNode"},create(e,r){return p({kind:"UnaryOperationNode",operator:e,operand:r})}});function ut(e,r){return at.create(Do.create(e),w(r))}var No=p({is(e){return e.kind==="CaseNode"},create(e){return p({kind:"CaseNode",value:e})},cloneWithWhen(e,r){return p({...e,when:p(e.when?[...e.when,r]:[r])})},cloneWithThen(e,r){return p({...e,when:e.when?p([...e.when.slice(0,-1),Go.cloneWithResult(e.when[e.when.length-1],r)]):void 0})},cloneWith(e,r){return p({...e,...r})}});class wc{#e;constructor(e){this.#e=p(e)}when(...e){return new wr({...this.#e,node:No.cloneWithWhen(this.#e.node,Go.create(ir(e)))})}}class wr{#e;constructor(e){this.#e=p(e)}then(e){return new mt({...this.#e,node:No.cloneWithThen(this.#e.node,qe(e)?le(e):m(e))})}}class mt{#e;constructor(e){this.#e=p(e)}when(...e){return new wr({...this.#e,node:No.cloneWithWhen(this.#e.node,Go.create(ir(e)))})}else(e){return new dt({...this.#e,node:No.cloneWith(this.#e.node,{else:qe(e)?le(e):m(e)})})}end(){return new a(No.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new a(No.cloneWith(this.#e.node,{isStatement:!0}))}}class dt{#e;constructor(e){this.#e=p(e)}end(){return new a(No.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new a(No.cloneWith(this.#e.node,{isStatement:!0}))}}var Qe=p({is(e){return e.kind==="JSONOperatorChainNode"},create(e){return p({kind:"JSONOperatorChainNode",operator:e,values:p([])})},cloneWithValue(e,r){return p({...e,values:p([...e.values,r])})}});var Or=p({is(e){return e.kind==="JSONPathLegNode"},create(e,r){return p({kind:"JSONPathLegNode",type:e,value:r})}});var H=p({is(e){return e.kind==="JSONPathNode"},create(e){return p({kind:"JSONPathNode",inOperator:e,pathLegs:p([])})},cloneWithLeg(e,r){return p({...e,pathLegs:p([...e.pathLegs,r])})}});var he=p({is(e){return e.kind==="JSONReferenceNode"},create(e,r){return p({kind:"JSONReferenceNode",reference:e,traversal:r})},cloneWithTraversal(e,r){return p({...e,traversal:r})}});var Ft=/^#-\d+$/;class ke{#e;constructor(e){this.#e=e}at(e){if(typeof e!=="number"&&typeof e!=="string"||typeof e==="number"&&!Number.isInteger(e)||typeof e==="string"&&e!=="last"&&!Ft.test(e))throw Error(`Unexpected index value in .at(...): ${e}`);return this.#r("ArrayLocation",e)}key(e){return this.#r("Member",e)}#r(e,r){if(he.is(this.#e))return new Se(he.cloneWithTraversal(this.#e,H.is(this.#e.traversal)?H.cloneWithLeg(this.#e.traversal,Or.create(e,r)):Qe.cloneWithValue(this.#e.traversal,Hr.createImmediate(r))));return new Se(H.cloneWithLeg(this.#e,Or.create(e,r)))}}class Se extends ke{#e;constructor(e){super(e);this.#e=e}get expressionType(){return}as(e){return new ct(this,e)}$castTo(){return new Se(this.#e)}$notNull(){return new Se(this.#e)}toOperationNode(){return this.#e}}class ct{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}toOperationNode(){return l.create(this.#e.toOperationNode(),pr(this.#r)?this.#r.toOperationNode():je.create(this.#r))}}var xr=p({is(e){return e.kind==="TupleNode"},create(e){return p({kind:"TupleNode",values:p(e)})}});var vt=["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"],Pt=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],ht=p({is(e){return e.kind==="DataTypeNode"},create(e){return p({kind:"DataTypeNode",dataType:e})}});function ft(e){if(vt.includes(e))return!0;if(Pt.some((r)=>r.test(e)))return!0;return!1}function us(e){if(pr(e))return e.toOperationNode();if(ft(e))return ht.create(e);throw Error(`invalid column data type ${JSON.stringify(e)}`)}var pt=p({is(e){return e.kind==="CastNode"},create(e,r){return p({kind:"CastNode",expression:e,dataType:r})}});function Me(e=K){function r(n,u,re){return new a(Le(n,u,re))}function t(n,u){return new a(ut(n,u))}let o=Object.assign(r,{fn:void 0,eb:void 0,selectFrom(n){return be({queryId:Je(),executor:e,queryNode:Gt.createFrom(A(n))})},case(n){return new wc({node:No.create(Fn(n)?void 0:w(n))})},ref(n,u){if(Fn(u))return new a(Po(n));return new ke(lt(n,u))},jsonPath(){return new ke(H.create())},table(n){return new a(zt(n))},val(n){return new a(m(n))},refTuple(...n){return new a(xr.create(n.map(w)))},tuple(...n){return new a(xr.create(n.map(m)))},lit(n){return new a(le(n))},unary:t,not(n){return t("not",n)},exists(n){return t("exists",n)},neg(n){return t("-",n)},between(n,u,re){return new a(I.create(w(n),Do.create("between"),W.create(m(u),m(re))))},betweenSymmetric(n,u,re){return new a(I.create(w(n),Do.create("between symmetric"),W.create(m(u),m(re))))},and(n){if(Ln(n))return new a(oe(n,"and"));return new a(_e(n,"and"))},or(n){if(Ln(n))return new a(oe(n,"or"));return new a(_e(n,"or"))},parens(...n){let u=ir(n);if(Oo.is(u))return new a(u);else return new a(Oo.create(u))},cast(n,u){return new a(pt.create(w(n),us(u)))},withSchema(n){return Me(e.withPluginAtFront(new cs(n)))}});return o.fn=Nu(),o.eb=o,o}function q(e){return Me()}function Ao(e){if(pr(e))return e.toOperationNode();else if(Kt(e))return e(q()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(e)}`)}function Fe(e){if(pr(e))return e.toOperationNode();else if(Kt(e))return e(q()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(e)}`)}function V(e){return Re(e)||Wr(e)||Kt(e)}function Ze(e){if(Qt(e))return Po(e);return e.toOperationNode()}function z(e){if(Ln(e))return e.map((r)=>w(r));else return[w(e)]}function w(e){if(V(e))return Ao(e);return Ze(e)}function lt(e,r){let t=Po(e);if(wf(r))return he.create(t,Qe.create(Do.create(r)));let o=r.slice(0,-1);if(wf(o))return he.create(t,H.create(Do.create(o)));throw Error(`Invalid JSON operator: ${r}`)}function Po(e){if(!e.includes("."))return te.create(Zt.create(e));let t=e.split(".").map(gr);if(t.length===3)return Mt(t);if(t.length===2)return Vt(t);throw Error(`invalid column reference ${e}`)}function Pr(e){if(e.includes(" as ")){let[t,o]=e.split(" as ").map(gr);return l.create(Po(t),je.create(o))}else return Po(e)}function bf(e){return Zt.create(e)}function sl(e){if(e.includes(" ")){let[t,o]=e.split(" ").map(gr);if(!rr(o))throw Error(`invalid order direction "${o}" next to "${t}"`);return E([t,o])[0]}else return bf(e)}function Mt(e){let[r,t,o]=e;return te.create(Zt.create(o),g.createWithSchema(r,t))}function Vt(e){let[r,t]=e;return te.create(Zt.create(t),g.create(r))}function gr(e){return e.trim()}class Ee{#e;constructor(e){this.#e=p(e)}get expressionType(){return}get isRawBuilder(){return!0}as(e){return new Nt(this,e)}$castTo(){return new Ee({...this.#e})}$notNull(){return new Ee(this.#e)}withPlugin(e){return new Ee({...this.#e,plugins:this.#e.plugins!==void 0?p([...this.#e.plugins,e]):p([e])})}toOperationNode(){return this.#t(this.#r())}compile(e){return this.#i(this.#r(e))}async execute(e){let r=this.#r(e);return r.executeQuery(this.#i(r))}#r(e){let r=e!==void 0?e.getExecutor():K;return this.#e.plugins!==void 0?r.withPlugins(this.#e.plugins):r}#t(e){return e.transformQuery(this.#e.rawNode,this.#e.queryId)}#i(e){return e.compileQuery(this.#t(e),this.#e.queryId)}}function Q(e){return new Ee(e)}class Nt{#e;#r;constructor(e,r){this.#e=e,this.#r=r}get expression(){return this.#e}get alias(){return this.#r}get rawBuilder(){return this.#e}toOperationNode(){return l.create(this.#e.toOperationNode(),pr(this.#r)?this.#r.toOperationNode():je.create(this.#r))}}var Oe=Object.assign((e,...r)=>Q({queryId:Je(),rawNode:Bt.create(e,r?.map(yt)??[])}),{ref(e){return Q({queryId:Je(),rawNode:Bt.createWithChild(Po(e))})},val(e){return Q({queryId:Je(),rawNode:Bt.createWithChild(m(e))})},value(e){return this.val(e)},table(e){return Q({queryId:Je(),rawNode:Bt.createWithChild(zt(e))})},id(...e){let r=Array(e.length+1).fill(".");return r[0]="",r[r.length-1]="",Q({queryId:Je(),rawNode:Bt.create(r,e.map(je.create))})},lit(e){return Q({queryId:Je(),rawNode:Bt.createWithChild(Hr.createImmediate(e))})},literal(e){return this.lit(e)},raw(e){return Q({queryId:Je(),rawNode:Bt.createWithSql(e)})},join(e,r=Oe`, `){let t=Array(Math.max(2*e.length-1,0)),o=r.toOperationNode();for(let n=0;n<e.length;++n)if(t[2*n]=yt(e[n]),n!==e.length-1)t[2*n+1]=o;return Q({queryId:Je(),rawNode:Bt.createWithChildren(t)})}});function yt(e){if(pr(e))return e.toOperationNode();return m(e)}var mr=p({raw(e,r=[]){return p({sql:e,query:Bt.createWithSql(e),parameters:p(r),queryId:Je()})}});
3
+ export{pr,Zt,ol,yf,Po,bf,sl,$i,Hr,ir,fe,Gt,Ru,Je,bc,cs,Gi,Pu,vc,Ps,Nu,No,wc,us,Ao,vf,zt,Oe,mr};
@@ -0,0 +1,2 @@
1
+ import{P,m,D,_,u,S,L,t,o,V,Z,B,mt,A,I,Sr,O,Fo,Pe,ve,on,Et,ht,tr,we,Ne,E,C,ge,ra,Ae,_e,K,Wr,Vt,ms,hs,gs,Tf,De,md,ct,jc,qc,gr,Ad,zb,ov,Oa,Xf,ip,fg,pg,Fa,Tg,yp,Zo,Gn,qd,Xe,et,tt,rt,nt,ot,st,it,ue,ae,pe,qe,le,z,ce,Ot,Nt,M,Eo,Co,Yr,Rn,he,vs,jr,of}from"./chunk-42hrvk6k.js";import{ws,xs,Fr,hu,gu,rs,ns,Ss,Cs}from"./chunk-04avc4fn.js";import{Ga,pu}from"./chunk-6jkjx0n2.js";import{Ks}from"./chunk-ryepy5er.js";var ut=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Ge=I("pencil",ut);S();S();function Ye({teamId:c,projectId:s,file:r,onSaveField:d,members:T,onCommentSelect:x,hideAnnotationControl:F=!1,readOnly:b=!1,publicFields:v,isPublic:p=!1,shareId:y,currentTime:Q,onTyping:ee,selectedCommentId:h,heightPercent:j,onHeightPercentChange:G}){let{canEdit:H}=Ot(s),{fields:i,setFields:X}=Fr(),se=V(),{ref:oe,inView:de}=Nt(),[a,U]=u(null),[Ce,te]=u(!1),[me,Ee]=u(null),Y=_(!1),ze=_(0),q=_(j),je=(e)=>{Y.current=!0,ze.current=e.clientY,q.current=j,e.target.setPointerCapture?.(e.pointerId)},Ie=P((e)=>{if(!Y.current)return;let w=(ze.current-e.clientY)/window.innerHeight*100,ne=Math.min(85,Math.max(10,q.current+w));G(ne)},[G]),ke=(e)=>{Y.current=!1;try{e.target.releasePointerCapture?.(e.pointerId)}catch{}},{data:J}=Z({queryKey:["fields",s],queryFn:async()=>{let e=await A.api.projects[":projectId"].fields.$get({param:{projectId:s}});if(!e.ok)throw Error("Failed to fetch fields");return await e.json()},enabled:!!s&&!v}),k=rs(r);m(()=>{if(v)X(v,s);else if(J)X(J,s)},[J,v,s,X]);let{data:fe,fetchNextPage:W,hasNextPage:Te}=mt({queryKey:p?["shares",y,"files",r?.id,"comments"]:["files",r?.id,"comments"],queryFn:async({pageParam:e})=>{if(p){let l=localStorage.getItem(`share_pwd_${y}`)||"",w=await A.api.shares[":shareId"].files[":fileId"].comments.$get({param:{shareId:y,fileId:r.id},query:{after:e}},{headers:{"x-share-password":l}});if(!w.ok)throw Error("Failed to fetch comments");return await w.json()}else{let l=await A.api.files[":fileId"].comments.$get({param:{fileId:r.id},query:{after:e}});if(!l.ok)throw Error("Failed to fetch comments");return await l.json()}},enabled:!!r?.id&&(!p||!!y),initialPageParam:"",refetchInterval:2000,getNextPageParam:(e)=>e.pageInfo?.cursor||void 0}),{mutate:Me}=B({mutationFn:async({text:e,attachmentIds:l,annotations:w,replyToId:ne,guestUserId:xe,second:be})=>{if(p){let ie=localStorage.getItem(`share_pwd_${y}`)||"",Be=await A.api.shares[":shareId"].files[":fileId"].comments.$post({param:{shareId:y,fileId:r.id},json:{message:e,attachmentIds:l,replyToId:ne??void 0,annotations:w,second:be??void 0}},{headers:{"x-share-password":ie,...xe?{"x-guest-user-id":xe}:{}}});if(!Be.ok)throw Error("Failed to create comment");return await Be.json()}else{let ie=await A.api.files[":fileId"].comments.$post({param:{fileId:r.id},json:{message:e,attachmentIds:l,replyToId:ne??void 0,annotations:w,second:be??void 0}});if(!ie.ok)throw Error("Failed to create comment");return await ie.json()}},onSuccess:()=>{se.invalidateQueries({queryKey:p?["shares",y,"files",r?.id,"comments"]:["files",r?.id,"comments"]})},onError:()=>{M.error(ov?.()||"Failed to post comment")}}),Se=fe?.pages?.[0]?.pageInfo?.total??fe?.pages.reduce((e,l)=>e+(l.data?.length||0),0)??0;m(()=>{if(de&&Te)W()},[de,W,Te]);let R=D(()=>(r?.fieldValues||[]).reduce((e,l)=>(e[l.fieldId]=l,e),{}),[r?.fieldValues]),re=D(()=>[...i].sort((e,l)=>{let w=e.config?.name?.toLowerCase()||"",ne=l.config?.name?.toLowerCase()||"";if(w<ne)return-1;if(w>ne)return 1;return 0}),[i]),Le=fe?.pages.flatMap((e)=>e.data??[])??[],Ve=(e,l,w=[],ne,xe)=>{if(!e.trim()&&l.length===0&&w.length===0)return;let be=ne||a?.id||null;if(p){let ie=localStorage.getItem(`guest_user_id_${y}`);if(!ie)Ee({text:e,attachmentIds:l,annotations:w,replyToId:be,second:xe}),te(!0);else Me({text:e,attachmentIds:l,annotations:w,replyToId:be,guestUserId:ie,second:xe})}else Me({text:e,attachmentIds:l,annotations:w,replyToId:be,second:xe});U(null)},He=(e)=>{if(me)Me({...me,guestUserId:e}),Ee(null),U(null)},Fe=(e)=>{let l=T.find((w)=>w.id===e);if(l)return l;return{id:"unknown",name:"Unknown",role:"unknown"}},Re=j<=15;return o("div",{style:{height:`${j}dvh`},className:"shrink-0 flex flex-col bg-background border-t border-border shadow-2xl rounded-t-2xl overflow-hidden select-none z-20","data-testid":"mobile-bottom-sheet",children:[t("div",{onPointerDown:je,onPointerMove:Ie,onPointerUp:ke,onPointerCancel:ke,className:"w-full pt-2 pb-1.5 flex flex-col items-center justify-center cursor-grab active:cursor-grabbing touch-none shrink-0","aria-label":"Drag to resize bottom sheet",children:t("div",{className:"w-10 h-1 rounded-full bg-muted-foreground/30 hover:bg-muted-foreground/50 transition-colors"})}),o(Eo,{defaultValue:"comments",className:"flex-1 flex flex-col min-h-0 px-2 pb-1 overflow-hidden",children:[o(Co,{className:"w-full shrink-0 h-9 bg-muted/60 p-1",children:[o(Yr,{value:"comments",className:"flex-1 text-xs font-semibold py-1",children:[md()," ",Se>0&&`(${Se})`]}),t(Yr,{value:"fields",className:"flex-1 text-xs font-semibold py-1",children:Oa()})]}),o(Rn,{value:"comments",className:E("flex-1 flex flex-col overflow-hidden min-h-0 mt-2",Re&&"hidden"),children:[t("div",{className:"flex items-center justify-between px-2 pb-1.5 shrink-0 border-b border-border/50",children:o("span",{className:"text-xs font-bold text-foreground",children:[Tf?.()||"All comments",Se>0?` (${Se})`:""]})}),t(ce,{className:"flex-1 min-h-0 px-2 py-2 [&>div>div]:block!",children:Le.length===0?t("div",{className:"py-8 text-center text-xs text-muted-foreground",children:pg()}):o("div",{className:"space-y-3",children:[Le.map((e)=>o("div",{children:[t(Ga,{teamId:c,message:e,getUser:Fe,onReply:U,hasReplies:!!e.replies?.length,formatTimestamp:k?.commentsConfig?.formatTimestamp,frameRate:k?.commentsConfig?.hasTimestamp?r?.media?.metadata?.frameRate||30:void 0,startTimecode:k?.commentsConfig?.hasTimestamp?r?.media?.metadata?.startTimecode:void 0,isSelected:h===e.id,onSelect:()=>{x?.(e)},readOnly:b,isPublic:p}),e.replies?.map((l,w)=>t("div",{children:t(Ga,{teamId:c,isReply:!0,message:l,getUser:Fe,onReply:U,hasReplies:!1,isLastReply:w===(e.replies?.length??0)-1,formatTimestamp:k?.commentsConfig?.formatTimestamp,frameRate:k?.commentsConfig?.hasTimestamp?r?.media?.metadata?.frameRate||30:void 0,startTimecode:k?.commentsConfig?.hasTimestamp?r?.media?.metadata?.startTimecode:void 0,isSelected:h===l.id,onSelect:()=>{x?.(l)},readOnly:b,isPublic:p})},l.id))]},e.id)),t("div",{ref:oe})]})}),(!b||p)&&t("div",{className:"mt-auto shrink-0 bg-background border-t border-border pt-1",children:t(pu,{isOpen:Ce,onClose:()=>te(!1),onSuccess:He,children:t(Ks,{projectId:s,onSendMessage:Ve,replyingTo:a,onCancelReply:()=>U(null),hideAnnotationControl:F,disableMentions:p,currentTime:k?.commentsConfig?.hasTimestamp?Q:void 0,formatTimestamp:k?.commentsConfig?.formatTimestamp,frameRate:k?.commentsConfig?.hasTimestamp?r?.media?.metadata?.frameRate||30:void 0,startTimecode:k?.commentsConfig?.hasTimestamp?r?.media?.metadata?.startTimecode:void 0,onTyping:ee})})})]}),t(Rn,{value:"fields",className:E("flex-1 flex flex-col overflow-hidden min-h-0 mt-2",Re&&"hidden"),children:t(ce,{className:"flex-1 px-3 py-2 min-h-0 [&>div>div]:block!",children:re&&re.length>0?t("div",{className:"space-y-4 pb-6",children:re.map((e)=>o("div",{className:"space-y-1.5",children:[t("label",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:e.config?.name}),t("div",{className:"min-h-[32px]",children:t(Cs,{fieldId:e.id,config:e.config,value:R[e.id]?.value,onSave:H?(l)=>d(e.id,l):void 0,readOnly:b||e.readOnly||!H})})]},e.id))}):t("div",{className:"py-8 text-center text-xs text-muted-foreground",children:"No custom fields defined"})})})]})]})}function We({fileName:c,folderName:s,version:r,versions:d,activeFileId:T,isPublic:x=!1,shareId:F,allowDownload:b=!0,downloadInfo:v,canEdit:p=!1,onBack:y,onPrevFile:Q,onNextFile:ee,hasPrevFile:h=!1,hasNextFile:j=!1,onSelectVersion:G,onRename:H,onDelete:i,onLinkedTasks:X,linkedTaskCount:se=0}){let oe=async(a)=>{try{let U=x&&F?await A.api.shares[":shareId"].files[":fileId"]["download-url"].$post({param:{shareId:F,fileId:T},json:{key:a}}):await A.api.files["download-url"].$post({json:{key:a,assetId:T}});if(!U.ok)return;let{url:Ce}=await U.json(),te=document.createElement("a");te.href=Ce,te.download="",document.body.appendChild(te),te.click(),document.body.removeChild(te)}catch{}},de=(v?.videoTranscodes?.length??0)>0;return o("header",{className:"flex h-12 w-full items-center justify-between border-b border-border bg-card px-2 py-1.5 shrink-0 select-none z-30",children:[t("div",{className:"flex items-center",children:t(C,{variant:"ghost",size:"icon",onClick:y,className:"h-8 w-8 text-foreground hover:bg-accent cursor-pointer","aria-label":yp(),children:t(on,{className:"h-5 w-5"})})}),o("div",{className:"flex flex-1 items-center justify-center gap-1 min-w-0 px-1",children:[o("div",{className:"flex items-center min-w-0 max-w-[65vw]",children:[s&&o(L,{children:[t("span",{className:"truncate text-xs font-medium text-muted-foreground max-w-[80px]",children:s}),t("span",{className:"text-muted-foreground mx-1 text-xs",children:"/"})]}),d&&d.length>1?o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:o("button",{className:"flex items-center gap-1 min-w-0 truncate text-xs font-medium text-foreground hover:bg-accent rounded px-1 py-0.5 transition-colors cursor-pointer",children:[t("span",{className:"truncate max-w-[120px] font-semibold",children:c}),r!==void 0&&o(he,{variant:"outline",className:"px-1 py-0 text-[10px] shrink-0 font-normal",children:["v",r]}),t(ve,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]})}),o(_e,{align:"center",className:"w-48 z-40",children:[t(Wr,{className:"text-xs",children:qd()}),d.map((a)=>o(K,{onClick:()=>G?.(a.id),className:E("flex items-center justify-between text-xs cursor-pointer",a.id===T?"bg-accent font-semibold text-accent-foreground":""),children:[o("span",{children:["v",a.version]}),t("span",{className:"text-[11px] text-muted-foreground truncate max-w-[120px]",children:a.name||c})]},a.id))]})]}):o("div",{className:"flex items-center gap-1 min-w-0 truncate",children:[t("span",{className:"truncate text-xs font-semibold text-foreground max-w-[140px]",children:c}),r!==void 0&&o(he,{variant:"outline",className:"px-1 py-0 text-[10px] shrink-0 font-normal",children:["v",r]})]})]}),(h||j)&&o("div",{className:"flex items-center gap-0.5 shrink-0 bg-muted/60 rounded p-0.5 ml-1",children:[t(C,{variant:"ghost",size:"icon",disabled:!h,onClick:Q,className:"h-5 w-5 p-0 text-muted-foreground hover:text-foreground disabled:opacity-30 cursor-pointer",title:Tg(),"aria-label":Tg(),children:t(on,{className:"h-3.5 w-3.5"})}),t(C,{variant:"ghost",size:"icon",disabled:!j,onClick:ee,className:"h-5 w-5 p-0 text-muted-foreground hover:text-foreground disabled:opacity-30 cursor-pointer",title:fg(),"aria-label":fg(),children:t(Et,{className:"h-3.5 w-3.5"})})]})]}),t("div",{className:"flex items-center gap-1",children:o(ge,{modal:!1,children:[t(Ae,{asChild:!0,children:t(C,{variant:"ghost",size:"icon",className:"h-8 w-8 text-foreground hover:bg-accent cursor-pointer","aria-label":ip(),children:t(Sr,{className:"h-4 w-4"})})}),o(_e,{align:"end",className:"w-52 z-40",children:[b&&(de?o(ms,{children:[o(hs,{className:"flex items-center gap-2 text-xs cursor-pointer",children:[t(ht,{className:"h-3.5 w-3.5"}),t("span",{children:gr()})]}),t(ra,{children:o(gs,{className:"w-48 z-50",children:[t(Wr,{className:"text-xs",children:gr()}),v?.videoTranscodes?.map((a)=>{let U=vs(a),Ce=a.hdr?`${U} (HDR)`:U;return o(K,{onClick:()=>oe(a.key),className:"flex items-center justify-between text-xs cursor-pointer",children:[t("span",{children:Ce}),t("span",{className:"text-[10px] text-muted-foreground",children:"MP4"})]},a.key||`${U}-${a.hdr?"hdr":"sdr"}`)}),v?.originalKey&&o(L,{children:[t(Vt,{}),o(K,{onClick:()=>oe(v.originalKey),className:"flex items-center justify-between text-xs cursor-pointer",children:[t("span",{children:Fa?.()||"Original"}),t("span",{className:"text-[10px] text-muted-foreground",children:c.split(".").pop()?.toUpperCase()||"RAW"})]})]})]})})]}):o(K,{onClick:()=>v?.originalKey&&oe(v.originalKey),disabled:!v?.originalKey,className:"flex items-center gap-2 text-xs cursor-pointer",children:[t(ht,{className:"h-3.5 w-3.5"}),t("span",{children:gr()})]})),d&&d.length>1&&G&&o(ms,{children:[t(hs,{className:"flex items-center gap-2 text-xs cursor-pointer",children:t("span",{children:qd?.()||"Switch version"})}),t(ra,{children:o(gs,{className:"w-48 z-50",children:[t(Wr,{className:"text-xs",children:qd?.()||"Switch version"}),d.map((a)=>o(K,{onClick:()=>G(a.id),className:E("flex items-center justify-between text-xs cursor-pointer",a.id===T?"bg-accent font-semibold text-accent-foreground":""),children:[o("span",{children:["v",a.version]}),t("span",{className:"text-[10px] text-muted-foreground truncate max-w-[120px]",children:a.name||c})]},a.id))]})})]}),X&&o(K,{onClick:X,className:"flex items-center justify-between text-xs cursor-pointer",children:[o("span",{className:"flex items-center gap-2",children:[t(Fo,{className:"h-3.5 w-3.5"}),t("span",{children:Xf?.()||"Linked Tasks"})]}),se>0&&t("span",{className:"inline-flex items-center justify-center px-1.5 py-0.2 text-[10px] font-semibold rounded-full bg-muted-foreground/15 text-foreground",children:se})]}),p&&H&&o(K,{onClick:H,className:"flex items-center gap-2 text-xs cursor-pointer",children:[t(Ge,{className:"h-3.5 w-3.5"}),t("span",{children:Zo()})]}),p&&i&&o(L,{children:[t(Vt,{}),o(K,{onClick:i,className:"flex items-center gap-2 text-xs text-destructive focus:text-destructive cursor-pointer",children:[t(we,{className:"h-3.5 w-3.5"}),t("span",{children:ct()})]})]})]})]})})]})}function jl({projectId:c,teamId:s="",fileId:r,file:d,projectInfo:T,ancestorFolders:x=[],versions:F,activeFileId:b,startTime:v,isPublic:p=!1,shareId:y,allowDownload:Q=!0,publicFields:ee,siblingFiles:h=[],onNavigateToFile:j,onNavigateBack:G,onRenameFile:H,onDeleteFile:i,onSaveField:X,onSelectVersion:se}){let{canEdit:oe}=Ot(c),{members:de}=jr(),a=_(null),[U,Ce]=u(50),[te,me]=u([]),[Ee,Y]=u(0),[ze,q]=u(null),[je,Ie]=u(!1),[ke,J]=u(""),k=_(null),[fe,W]=u(!1),[Te,Me]=u(!1),[Se,R]=u(!1),[re,Le]=u(!1),{data:Ve}=Z({queryKey:["teams",s,"kanban","assets",b,"tasks"],queryFn:async()=>{if(!s||!b||p)return{data:[],total:0};let f=await A.api.teams[":teamId"].kanban.assets[":assetId"].tasks.$get({param:{teamId:s,assetId:b}});if(!f.ok)return{data:[],total:0};return await f.json()},enabled:!!s&&!!b&&!p}),He=Ve?.total??Ve?.data?.length??0,{prevFile:Fe,nextFile:Re}=D(()=>{if(!h||h.length===0)return{prevFile:null,nextFile:null};let f=h.findIndex((ye)=>ye.id===r||ye.id===b);if(f===-1)return{prevFile:null,nextFile:null};return{prevFile:f>0?h[f-1]:null,nextFile:f<h.length-1?h[f+1]:null}},[h,r,b]),e=x.length>0?x[0]?.name:T?.name,w=F?.find((f)=>f.id===b)?.version??(F&&F.length>0?F.length:void 0),ne=D(()=>({originalKey:d.media?.original?.key,videoTranscodes:d.media?.videoTranscodes?.map((f)=>({key:f.key,width:f.width,height:f.height,resolution:f.resolution,hdr:f.hdr}))}),[d.media]),xe=()=>{me([]),q(null)},be=()=>{me([]),q(null)},ie=(f)=>{q(f.id||null);let ye=f.annotations;if(ye&&ye.length>0)me(ye);else me([]);if(f.second!==null&&f.second!==void 0)a.current?.seekTo(f.second),a.current?.pause();else if(ye&&ye.length>0)a.current?.pause()},Be=async(f)=>{if(f?.preventDefault(),!ke.trim()||!H)return;try{Me(!0),await H(ke.trim()),Ie(!1)}finally{Me(!1)}},$e=async()=>{if(!i)return;try{W(!0),await i(),R(!1)}finally{W(!1)}};return m(()=>{Y(0),q(null),me([])},[d?.id]),o("div",{className:"flex h-[100dvh] w-full flex-col bg-background overflow-hidden relative",children:[t(We,{fileName:d.name,folderName:e,version:w,versions:F,activeFileId:b,isPublic:p,shareId:y,allowDownload:Q,downloadInfo:ne,canEdit:oe,onBack:G,hasPrevFile:!!Fe,hasNextFile:!!Re,onPrevFile:()=>Fe&&j(Fe.id),onNextFile:()=>Re&&j(Re.id),onSelectVersion:se,onRename:()=>{J(d.name),Ie(!0)},onDelete:()=>R(!0),onLinkedTasks:!p?()=>Le(!0):void 0,linkedTaskCount:He}),t("div",{className:"relative flex-1 min-h-0 bg-background overflow-hidden flex flex-col",children:t(ns,{file:d,mediaControllerRef:a,onPlay:xe,onTimeUpdate:Y,onSeek:be,annotations:te,startTime:v,shareId:y,allowDownload:Q})}),t(Ye,{teamId:s,projectId:c,file:d,onSaveField:X,members:de,onCommentSelect:ie,hideAnnotationControl:d.proxyType==="audio",readOnly:p||!oe,publicFields:ee,isPublic:p,shareId:y,currentTime:Ee,onTyping:()=>a.current?.pause(),selectedCommentId:ze,heightPercent:U,onHeightPercentChange:Ce}),!p&&re&&t(of,{teamId:s,assetId:b,assetName:d.name,isOpen:re,onClose:()=>Le(!1)}),!p&&t(ue,{open:je,onOpenChange:Ie,children:t(ae,{children:o("form",{onSubmit:Be,children:[t(pe,{children:t(le,{children:Zo()})}),t("div",{className:"py-4",children:t(z,{ref:k,value:ke,onChange:(f)=>J(f.target.value),placeholder:Ad?.()||"Enter new name",onFocus:()=>{setTimeout(()=>{if(k.current)Ss(k.current)},0)},autoFocus:!0})}),o(qe,{children:[t(C,{type:"button",variant:"outline",onClick:()=>Ie(!1),children:De()}),o(C,{type:"submit",disabled:Te||!ke.trim(),children:[Te&&t(O,{className:"mr-2 h-4 w-4 animate-spin"}),Gn()]})]})]})})}),!p&&t(Xe,{open:Se,onOpenChange:R,children:o(et,{children:[o(tt,{children:[t(nt,{children:qc?.()||"Delete Asset?"}),t(ot,{children:jc?.()||"Deleted items can be recovered for 30 days before being permanently deleted."})]}),o(rt,{children:[t(it,{children:De()}),o(st,{onClick:$e,disabled:fe,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[fe&&t(O,{className:"mr-2 h-4 w-4 animate-spin"}),ct()]})]})]})})]})}S();function Je({activeState:c,activeAsset:s,previewUrl:r,isFullScreen:d,onTogglePlay:T,onToggleLoop:x,onSeek:F,onVolumeChange:b,onToggleMute:v,onChangePlaybackRate:p,onChangeResolution:y,onZoomIn:Q,onZoomOut:ee,onFit:h,onDownload:j,onToggleFullScreen:G,allowDownload:H=!0}){if(c?.kind==="video"&&c.video&&s){let i=c.video,X=i.totalFrames/i.frameRate,se=i.currentFrame/i.frameRate,oe={isPlaying:i.isPlaying,progress:X>0?se/X*100:0,currentTime:se,duration:X,volume:i.volume,isMuted:i.isMuted,isLooping:i.isLooping,playbackRate:i.playbackRate,isFullScreen:d,showFrames:!1,currentResolution:i.currentResolution,isCurrentHdr:i.isCurrentHdr,activeAutoResolution:i.activeAutoResolution,isHlsManualSupported:i.isHlsManualSupported,isLoading:i.isLoading},de=r&&!s.media?.videoPreview?{...s,media:{...s.media,videoPreview:{url:r}}}:s;return t(hu,{state:oe,zoom:c.zoom,isControlsVisible:!0,floatOverlayInFullScreen:!1,buffered:i.buffered,data:de,resolutions:i.resolutions,togglePlay:T,toggleLoop:x,toggleMute:v,handleVolumeChange:b,changePlaybackRate:p,changeResolution:(a)=>y(a.resolution,a.hdr),handleDownload:(a)=>j(a),toggleFullScreen:G,onZoomChange:(a)=>a>=c.zoom?Q():ee(),onZoomReset:h,frameRate:i.frameRate,totalFrames:i.totalFrames,currentFrame:i.currentFrame,seekToFrame:F,allowDownload:H})}if(c?.kind==="image")return t(gu,{zoom:c.zoom,onZoomIn:Q,onZoomOut:ee,onFit:h,onDownload:()=>j(),canDownload:!!s?.media?.original?.key,fullscreen:{isFullScreen:d,onToggle:G},allowDownload:H});return t("div",{className:"relative z-10 flex items-center justify-end gap-2 border-t border-border bg-card px-4 py-3",children:t("button",{onClick:G,className:"text-foreground transition-colors hover:text-primary",title:"Fullscreen",children:d?t(xs,{className:"h-5 w-5"}):t(ws,{className:"h-5 w-5"})})})}function Ze({side:c,fileName:s,version:r,activeVersionId:d,versions:T,isActive:x,onActivate:F,onSwitchVersion:b,onExit:v}){let p=E("flex-shrink-0 rounded p-1 transition-colors hover:bg-muted",x?"text-foreground":"text-muted-foreground hover:text-foreground"),y=t("button",{onClick:v,title:zb(),className:p,children:t(Ne,{className:"h-4 w-4"})}),Q=o("button",{onClick:F,className:E("flex min-w-0 items-center gap-1 rounded px-2 py-1 text-sm font-medium transition-colors hover:bg-muted",x?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[t("span",{className:"truncate",children:s}),r!==void 0&&o("span",{className:E("flex-shrink-0 rounded border px-1 py-0 text-xs",x?"border-foreground/40":"border-border"),children:["v",r]})]}),ee=o(ge,{children:[t(Ae,{onClick:F,title:qd(),className:p,children:t(ve,{className:"h-4 w-4"})}),t(_e,{align:c==="left"?"start":"end",className:"w-80 p-1",children:t("div",{className:"flex max-h-96 flex-col gap-1 overflow-y-auto",children:T.map((h)=>{let j=h.id===d;return o(K,{onClick:()=>b(h.id),className:"flex cursor-pointer items-center gap-3 rounded-md px-3 py-2",children:[o("div",{className:"flex min-w-[2rem] flex-shrink-0 items-center justify-center rounded-full bg-muted px-2 py-0.5 text-xs font-semibold text-muted-foreground select-none",children:["v",h.version]}),t("div",{className:"flex h-10 w-16 flex-shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted",children:h.previewUrl?t("img",{src:h.previewUrl,alt:h.name||void 0,className:"h-full w-full object-cover"}):t(tr,{className:"h-4 w-4 text-muted-foreground"})}),o("div",{className:"flex min-w-0 flex-1 flex-col text-left",children:[t("span",{className:"truncate text-sm font-semibold text-foreground",children:h.name}),t("span",{className:"truncate text-xs text-muted-foreground",children:h.creator?.name||"Unknown"})]}),j&&t(Pe,{className:"ml-auto h-4 w-4 flex-shrink-0 text-primary"})]},h.id)})})})]});return t("div",{onMouseDown:F,className:E("dark flex h-10 flex-shrink-0 items-center gap-1 border-b bg-background px-2 transition-colors",x?"border-b-2 border-primary":"border-border"),children:c==="left"?o(L,{children:[y,Q,ee]}):o(L,{children:[Q,ee,t("div",{className:"ml-auto"}),y]})})}function at(c,s,r){return Z({queryKey:s?["public-share-file",r,c,localStorage.getItem(`share_pwd_${r}`)||""]:["files",c],queryFn:async()=>{if(s){let T=localStorage.getItem(`share_pwd_${r}`)||"",x=await A.api.shares[":shareId"].files[":fileId"].$get({param:{shareId:r,fileId:c}},{headers:{"x-share-password":T}});if(!x.ok)throw Error("Failed to fetch version asset");return await x.json()}let d=await A.api.files[":fileId"].$get({param:{fileId:c}});if(!d.ok)throw Error("Failed to fetch version asset");return await d.json()},enabled:!!c&&(!s||!!r)})}function ql({isPublic:c=!1,shareId:s,versions:r,leftId:d,rightId:T,activeSide:x,annotations:F,seekRequest:b,onActiveSideChange:v,onSwitchVersion:p,onExit:y,onActiveAssetChange:Q,onPlay:ee,onTimeUpdate:h,allowDownload:j=!0}){let G=_(null),H=_(null),i=_(null),[X,se]=u(null),[oe,de]=u(null),[a,U]=u(1),[Ce,te]=u(!1),[me,Ee]=u(!1),{data:Y,isLoading:ze}=at(d,c,s),{data:q,isLoading:je}=at(T,c,s),Ie=rs(Y),ke=rs(q),J=!!Y&&!!q&&Ie.id===ke.id,k=x==="left"?Y:q,fe=x==="left"?X:oe,W=P(()=>x==="left"?H.current:i.current,[x]),Te=P(()=>x==="left"?i.current:H.current,[x]);m(()=>{Q(k??null)},[k,Q]),m(()=>{if(!b)return;let n=W();if(n?.seekToSecond(b.second),n?.pause(),J){let g=Te();g?.seekToSecond(b.second),g?.pause()}},[b?.nonce]),m(()=>{let n=()=>Ee(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",n),()=>document.removeEventListener("fullscreenchange",n)},[]);let Me=P((n)=>se(n),[]),Se=P((n)=>de(n),[]),R=P((n)=>{let g=W();if(g)n(g);if(J){let N=Te();if(N)n(N)}},[W,Te,J]),re=P(()=>{let n=!fe?.video?.isPlaying;R((g)=>n?g.play():g.pause())},[fe?.video?.isPlaying,R]);m(()=>{let n=(g)=>{let N=document.activeElement;if(N&&(N.tagName==="INPUT"||N.tagName==="TEXTAREA"||N instanceof HTMLElement&&N.isContentEditable))return;let Ue=g.key===" ",Oe=N&&(N.tagName==="BUTTON"||N.tagName==="A"||N.tagName==="SELECT"||N.tagName==="OPTION"||N.getAttribute("role")==="button"||N.getAttribute("role")==="link"||N.getAttribute("role")==="checkbox"||N.getAttribute("role")==="radio"||N.getAttribute("role")==="menuitem");if(Ue&&Oe)return;if(g.key===" "||g.key.toLowerCase()==="k")g.preventDefault(),re()};return window.addEventListener("keydown",n),()=>{window.removeEventListener("keydown",n)}},[re]);let Le=P((n)=>R((g)=>g.seekToFrame(n)),[R]),Ve=P(()=>W()?.toggleLoop(),[W]),He=P((n)=>{U(n),te(n===0)},[]),Fe=P(()=>te((n)=>!n),[]),Re=P((n)=>R((g)=>g.setPlaybackRate(n)),[R]),e=P((n,g)=>W()?.changeResolution(n,g),[W]),l=P(()=>R((n)=>n.zoomBy(1.2)),[R]),w=P(()=>R((n)=>n.zoomBy(0.8)),[R]),ne=P(()=>R((n)=>n.fit()),[R]),xe=P((n)=>{W()?.download(n)},[W]),be=P(()=>{let n=G.current;if(!n||typeof n.requestFullscreen!=="function")return;if(!document.fullscreenElement)n.requestFullscreen().catch(()=>{});else if(document.exitFullscreen)document.exitFullscreen().catch(()=>{})},[]),ie=P((n,g)=>{if(J)i.current?.panBy(n,g)},[J]),Be=P((n,g)=>{if(J)H.current?.panBy(n,g)},[J]),$e=P(()=>re(),[re]),f=P((n)=>r.find((g)=>g.id===n)?.version,[r]),ye=D(()=>k?.media?.videoPreview?.url,[k?.media?.videoPreview?.url]),Qe=(n,g)=>{let Ue=rs(g)?.comparePane;if(!Ue)return t("div",{className:"flex flex-1 items-center justify-center bg-gray-100 dark:bg-gray-950",children:t("p",{className:"text-muted-foreground",children:"Preview unavailable"})});let Oe=x===n;return t(Ue,{ref:n==="left"?H:i,file:g,shareId:s,isActive:Oe,annotations:Oe?F:[],onStateChange:n==="left"?Me:Se,onUserPan:n==="left"?ie:Be,onActivate:()=>v(n),muted:Oe?Ce:!0,volume:a,onPlay:ee,onTimeUpdate:h,onRequestTogglePlay:$e},g.id)},lt=!!Y&&!!q,dt=ze||je;return o("div",{ref:G,className:"flex h-full flex-1 flex-col bg-background",children:[o("div",{className:"flex min-h-0 flex-1",children:[o("div",{className:"flex min-w-0 flex-1 flex-col border-r border-zinc-800",children:[Y&&t(Ze,{side:"left",fileName:Y.name,version:f(d),activeVersionId:d,versions:r,isActive:x==="left",onActivate:()=>v("left"),onSwitchVersion:(n)=>p("left",n),onExit:y}),t("div",{className:"relative flex min-h-0 flex-1",children:Y?Qe("left",Y):t("div",{className:"flex flex-1 items-center justify-center",children:t(O,{className:"h-6 w-6 animate-spin text-foreground"})})})]}),o("div",{className:"flex min-w-0 flex-1 flex-col",children:[q&&t(Ze,{side:"right",fileName:q.name,version:f(T),activeVersionId:T,versions:r,isActive:x==="right",onActivate:()=>v("right"),onSwitchVersion:(n)=>p("right",n),onExit:y}),t("div",{className:"relative flex min-h-0 flex-1",children:q?Qe("right",q):t("div",{className:"flex flex-1 items-center justify-center",children:t(O,{className:"h-6 w-6 animate-spin text-foreground"})})})]})]}),dt&&!lt&&t("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/30",children:t(O,{className:"h-8 w-8 animate-spin text-foreground"})}),t(Je,{activeState:fe,activeAsset:k??null,previewUrl:ye,isFullScreen:me,onTogglePlay:re,onToggleLoop:Ve,onSeek:Le,onVolumeChange:He,onToggleMute:Fe,onChangePlaybackRate:Re,onChangeResolution:e,onZoomIn:l,onZoomOut:w,onFit:ne,onDownload:xe,onToggleFullScreen:be,allowDownload:j})]})}
2
+ export{jl,ql};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ps,Go}from"./chunk-r6gkv98n.js";import{Vo}from"./chunk-2g5qdx4s.js";import{Qo,Ao,Nt}from"./chunk-f22nrm6r.js";import{hn,ir,Ge,en,Xt,yo,qt}from"./chunk-rn9rktp4.js";var{awsEndpointFunctions:me,emitWarningIfUnsupportedVersion:xe,createDefaultUserAgentProvider:fe,NODE_APP_ID_CONFIG_OPTIONS:Se,getAwsRegionExtensionConfiguration:ve,resolveAwsRegionExtensionConfiguration:Pe,resolveUserAgentConfig:Ie,resolveHostHeaderConfig:Ce,getUserAgentPlugin:Ae,getHostHeaderPlugin:ye,getLoggerPlugin:Te,getRecursionDetectionPlugin:Oe}=Nt(),{NoAuthSigner:Re,getHttpAuthSchemeEndpointRuleSetPlugin:De,DefaultIdentityProviderConfig:ke,getHttpSigningPlugin:$e}=Ao(),{normalizeProvider:j,getSmithyContext:we,ServiceException:Ne,NoOpLogger:be,emitWarningIfUnsupportedVersion:Ue,loadConfigsForDefaultMode:Fe,getDefaultExtensionConfiguration:qe,resolveDefaultRuntimeConfig:He,Client:K,makeBuilder:Me,createAggregatedClient:je}=ir(),{Command:Ke}=ir();var Ur=Ke,Fr=K;var{resolveDefaultsModeConfig:Ve,loadConfig:h,NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS:ze,NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS:Le,NODE_REGION_CONFIG_OPTIONS:Be,NODE_REGION_CONFIG_FILE_OPTIONS:We,resolveRegionConfig:Ye}=Ge(),{BinaryDecisionDiagram:Je,EndpointCache:Xe,decideEndpoint:Qe,customEndpointFunctions:Ze,resolveEndpointConfig:et,getEndpointPlugin:tt}=en(),{parseUrl:rt,getHttpHandlerExtensionConfiguration:ot,resolveHttpHandlerRuntimeConfig:nt,getContentLengthPlugin:st}=qt(),{DEFAULT_RETRY_MODE:it,NODE_RETRY_MODE_CONFIG_OPTIONS:ct,NODE_MAX_ATTEMPT_CONFIG_OPTIONS:at,resolveRetryConfig:pt,getRetryPlugin:dt}=Qo(),{TypeRegistry:V,getSchemaSerdePlugin:ut}=hn(),{resolveAwsSdkSigV4Config:lt,AwsSdkSigV4Signer:ht,NODE_AUTH_SCHEME_PREFERENCE_OPTIONS:_t}=Go(),{toUtf8:gt,fromUtf8:Et,toBase64:mt,fromBase64:xt,calculateBodyLength:ft}=Xt(),{streamCollector:St,NodeHttpHandler:vt}=Vo(),{AwsRestJsonProtocol:Pt}=Ps(),{Sha256:It}=yo(),Ct=async(e,t,n)=>({operation:we(t).operation,region:await j(e.region)()||(()=>{throw Error("expected `region` to be configured for `aws.auth#sigv4`")})()});function At(e){return{schemeId:"aws.auth#sigv4",signingProperties:{name:"sso-oauth",region:e.region},propertiesExtractor:(t,n)=>({signingProperties:{config:t,context:n}})}}function yt(e){return{schemeId:"smithy.api#noAuth"}}var Tt=(e)=>{let t=[];switch(e.operation){case"CreateToken":{t.push(yt());break}default:t.push(At(e))}return t},Ot=(e)=>{let t=lt(e);return Object.assign(t,{authSchemePreference:j(e.authSchemePreference??[])})},Rt=(e)=>Object.assign(e,{useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"sso-oauth"}),Dt={UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}},kt="3.997.43",$t={version:kt},E="ref",_=-1,x=!0,q="isSet",z="PartitionResult",f="booleanEquals",w="getAttr",H={[E]:"Endpoint"},N={[E]:z},g={},M=[{[E]:"Region"}],G={conditions:[[q,[H]],[q,M],["aws.partition",M,z],[f,[{[E]:"UseFIPS"},x]],[f,[{[E]:"UseDualStack"},x]],[f,[{fn:w,argv:[N,"supportsDualStack"]},x]],[f,[{fn:w,argv:[N,"supportsFIPS"]},x]],["stringEquals",[{fn:w,argv:[N,"name"]},"aws-us-gov"]]],results:[[_],[_,"Invalid Configuration: FIPS and custom endpoint are not supported"],[_,"Invalid Configuration: Dualstack and custom endpoint are not supported"],[H,g],["https://oidc-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",g],[_,"FIPS and DualStack are enabled, but this partition does not support one or both"],["https://oidc.{Region}.amazonaws.com",g],["https://oidc-fips.{Region}.{PartitionResult#dnsSuffix}",g],[_,"FIPS is enabled but this partition does not support FIPS"],["https://oidc.{Region}.{PartitionResult#dualStackDnsSuffix}",g],[_,"DualStack is enabled but this partition does not support DualStack"],["https://oidc.{Region}.{PartitionResult#dnsSuffix}",g],[_,"Invalid Configuration: Missing Region"]]},wt=2,c=1e8,bt=new Int32Array([-1,1,-1,0,13,3,1,4,c+12,2,5,c+12,3,8,6,4,7,c+11,5,c+9,c+10,4,11,9,6,10,c+8,7,c+6,c+7,5,12,c+5,6,c+4,c+5,3,c+1,14,4,c+2,c+3]),Ut=Je.from(bt,wt,G.conditions,G.results),Ft=new Xe({size:50,params:["Endpoint","Region","UseDualStack","UseFIPS"]}),Ht=(e,t={})=>Ft.get(e,()=>Qe(Ut,{endpointParams:e,logger:t.logger}));Ze.aws=me;class i extends Ne{constructor(e){super(e);Object.setPrototypeOf(this,i.prototype)}}class S extends i{name="AccessDeniedException";$fault="client";error;reason;error_description;constructor(e){super({name:"AccessDeniedException",$fault:"client",...e});Object.setPrototypeOf(this,S.prototype),this.error=e.error,this.reason=e.reason,this.error_description=e.error_description}}class v extends i{name="AuthorizationPendingException";$fault="client";error;error_description;constructor(e){super({name:"AuthorizationPendingException",$fault:"client",...e});Object.setPrototypeOf(this,v.prototype),this.error=e.error,this.error_description=e.error_description}}class P extends i{name="ExpiredTokenException";$fault="client";error;error_description;constructor(e){super({name:"ExpiredTokenException",$fault:"client",...e});Object.setPrototypeOf(this,P.prototype),this.error=e.error,this.error_description=e.error_description}}class I extends i{name="InternalServerException";$fault="server";error;error_description;constructor(e){super({name:"InternalServerException",$fault:"server",...e});Object.setPrototypeOf(this,I.prototype),this.error=e.error,this.error_description=e.error_description}}class C extends i{name="InvalidClientException";$fault="client";error;error_description;constructor(e){super({name:"InvalidClientException",$fault:"client",...e});Object.setPrototypeOf(this,C.prototype),this.error=e.error,this.error_description=e.error_description}}class A extends i{name="InvalidGrantException";$fault="client";error;error_description;constructor(e){super({name:"InvalidGrantException",$fault:"client",...e});Object.setPrototypeOf(this,A.prototype),this.error=e.error,this.error_description=e.error_description}}class y extends i{name="InvalidRequestException";$fault="client";error;reason;error_description;constructor(e){super({name:"InvalidRequestException",$fault:"client",...e});Object.setPrototypeOf(this,y.prototype),this.error=e.error,this.reason=e.reason,this.error_description=e.error_description}}class T extends i{name="InvalidScopeException";$fault="client";error;error_description;constructor(e){super({name:"InvalidScopeException",$fault:"client",...e});Object.setPrototypeOf(this,T.prototype),this.error=e.error,this.error_description=e.error_description}}class O extends i{name="SlowDownException";$fault="client";error;error_description;constructor(e){super({name:"SlowDownException",$fault:"client",...e});Object.setPrototypeOf(this,O.prototype),this.error=e.error,this.error_description=e.error_description}}class R extends i{name="UnauthorizedClientException";$fault="client";error;error_description;constructor(e){super({name:"UnauthorizedClientException",$fault:"client",...e});Object.setPrototypeOf(this,R.prototype),this.error=e.error,this.error_description=e.error_description}}class D extends i{name="UnsupportedGrantTypeException";$fault="client";error;error_description;constructor(e){super({name:"UnsupportedGrantTypeException",$fault:"client",...e});Object.setPrototypeOf(this,D.prototype),this.error=e.error,this.error_description=e.error_description}}var Mt="AccessDeniedException",Gt="AuthorizationPendingException",jt="AccessToken",Kt="ClientSecret",Vt="CreateToken",zt="CreateTokenRequest",Lt="CreateTokenResponse",Bt="CodeVerifier",Wt="ExpiredTokenException",Yt="InvalidClientException",Jt="InvalidGrantException",Qt="InvalidRequestException",Zt="InternalServerException",er="InvalidScopeException",tr="IdToken",rr="RefreshToken",or="SlowDownException",nr="UnauthorizedClientException",sr="UnsupportedGrantTypeException",cr="accessToken",l="client",ar="clientId",pr="clientSecret",dr="codeVerifier",ur="code",lr="deviceCode",r="error",hr="expiresIn",d="error_description",_r="grantType",gr="http",u="httpError",Er="idToken",L="reason",B="refreshToken",mr="redirectUri",W="smithy.ts.sdk.synthetic.com.amazonaws.ssooidc",xr="scope",fr="server",Sr="tokenType",o="com.amazonaws.ssooidc",Y=V.for(W),J=[-3,W,"SSOOIDCServiceException",0,[],[]];Y.registerError(J,i);var a=V.for(o),X=[-3,o,Mt,{[r]:l,[u]:400},[r,L,d],[0,0,0]];a.registerError(X,S);var Q=[-3,o,Gt,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(Q,v);var Z=[-3,o,Wt,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(Z,P);var ee=[-3,o,Zt,{[r]:fr,[u]:500},[r,d],[0,0]];a.registerError(ee,I);var te=[-3,o,Yt,{[r]:l,[u]:401},[r,d],[0,0]];a.registerError(te,C);var re=[-3,o,Jt,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(re,A);var oe=[-3,o,Qt,{[r]:l,[u]:400},[r,L,d],[0,0,0]];a.registerError(oe,y);var ne=[-3,o,er,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(ne,T);var se=[-3,o,or,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(se,O);var ie=[-3,o,nr,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(ie,R);var ce=[-3,o,sr,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(ce,D);var ae=[Y,a],vr=[0,o,jt,8,0],Pr=[0,o,Kt,8,0],Ir=[0,o,Bt,8,0],Cr=[0,o,tr,8,0],pe=[0,o,rr,8,0],de=[3,o,zt,0,[ar,pr,_r,lr,ur,B,xr,mr,dr],[0,[()=>Pr,0],0,0,0,[()=>pe,0],64,0,[()=>Ir,0]],3],ue=[3,o,Lt,0,[cr,Sr,hr,B,Er],[[()=>vr,0],0,1,[()=>pe,0],[()=>Cr,0]]],le=[9,o,Vt,{[gr]:["POST","/token",200]},()=>de,()=>ue],Ar=(e)=>({apiVersion:"2019-06-10",base64Decoder:e?.base64Decoder??xt,base64Encoder:e?.base64Encoder??mt,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??Ht,extensions:e?.extensions??[],httpAuthSchemeProvider:e?.httpAuthSchemeProvider??Tt,httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:(t)=>t.getIdentityProvider("aws.auth#sigv4"),signer:new ht},{schemeId:"smithy.api#noAuth",identityProvider:(t)=>t.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),signer:new Re}],logger:e?.logger??new be,protocol:e?.protocol??Pt,protocolSettings:e?.protocolSettings??{defaultNamespace:"com.amazonaws.ssooidc",errorTypeRegistries:ae,version:"2019-06-10",serviceTarget:"AWSSSOOIDCService"},serviceId:e?.serviceId??"SSO OIDC",sha256:e?.sha256??It,urlParser:e?.urlParser??rt,utf8Decoder:e?.utf8Decoder??Et,utf8Encoder:e?.utf8Encoder??gt}),yr=(e)=>{Ue(process.version);let t=Ve(e),n=()=>t().then(Fe),p=Ar(e);xe(process.version);let s={profile:e?.profile,logger:p.logger};return{...p,...e,runtime:"node",defaultsMode:t,authSchemePreference:e?.authSchemePreference??h(_t,s),bodyLengthChecker:e?.bodyLengthChecker??ft,defaultUserAgentProvider:e?.defaultUserAgentProvider??fe({serviceId:p.serviceId,clientVersion:$t.version}),maxAttempts:e?.maxAttempts??h(at,e),region:e?.region??h(Be,{...We,...s}),requestHandler:vt.create(e?.requestHandler??n),retryMode:e?.retryMode??h({...ct,default:async()=>(await n()).retryMode||it},e),streamCollector:e?.streamCollector??St,useDualstackEndpoint:e?.useDualstackEndpoint??h(Le,s),useFipsEndpoint:e?.useFipsEndpoint??h(ze,s),userAgentAppId:e?.userAgentAppId??h(Se,s)}},Tr=(e)=>{let{httpAuthSchemes:t,httpAuthSchemeProvider:n,credentials:p}=e;return{setHttpAuthScheme(s){let m=t.findIndex((k)=>k.schemeId===s.schemeId);if(m===-1)t.push(s);else t.splice(m,1,s)},httpAuthSchemes(){return t},setHttpAuthSchemeProvider(s){n=s},httpAuthSchemeProvider(){return n},setCredentials(s){p=s},credentials(){return p}}},Or=(e)=>({httpAuthSchemes:e.httpAuthSchemes(),httpAuthSchemeProvider:e.httpAuthSchemeProvider(),credentials:e.credentials()}),Rr=(e,t)=>{let n=Object.assign(ve(e),qe(e),ot(e),Tr(e));return t.forEach((p)=>p.configure(n)),Object.assign(e,Pe(n),He(n),nt(n),Or(n))};class b extends K{config;constructor(...[e]){let t=yr(e||{});super(t);this.initConfig=t;let n=Rt(t),p=Ie(n),s=pt(p),m=Ye(s),k=Ce(m),he=et(k),_e=Ot(he),ge=Rr(_e,e?.extensions||[]);this.config=ge,this.middlewareStack.use(ut(this.config)),this.middlewareStack.use(Ae(this.config)),this.middlewareStack.use(dt(this.config)),this.middlewareStack.use(st(this.config)),this.middlewareStack.use(ye(this.config)),this.middlewareStack.use(Te(this.config)),this.middlewareStack.use(Oe(this.config)),this.middlewareStack.use(De(this.config,{httpAuthSchemeParametersProvider:Ct,identityProviderConfigProvider:async(Ee)=>new ke({"aws.auth#sigv4":Ee.credentials})})),this.middlewareStack.use($e(this.config))}destroy(){super.destroy()}}var Dr=Me(Dt,"AWSSSOOIDCService","SSOOIDCClient",tt),kr={},$r=(e,t,n,p)=>[];class U extends Dr(kr,$r,"CreateToken",le){}var wr={CreateTokenCommand:U};class F extends b{}je(wr,F);var Nr={KMS_ACCESS_DENIED:"KMS_AccessDeniedException"},br={KMS_DISABLED_KEY:"KMS_DisabledException",KMS_INVALID_KEY_USAGE:"KMS_InvalidKeyUsageException",KMS_INVALID_STATE:"KMS_InvalidStateException",KMS_KEY_NOT_FOUND:"KMS_NotFoundException"};var qr=S,Hr=X,Mr=Nr,Gr=v,jr=Q,Kr=le,Vr=U,zr=de,Lr=ue,Br=P,Wr=Z,Yr=I,Jr=ee,Xr=C,Qr=te,Zr=A,eo=re,to=y,ro=oe,oo=br,no=T,so=ne,io=F,co=b,ao=i,po=J,uo=O,lo=se,ho=R,_o=ie,go=D,Eo=ce,mo=ae;export{Ur as $Command,Fr as __Client,qr as AccessDeniedException,Hr as AccessDeniedException$,Mr as AccessDeniedExceptionReason,Gr as AuthorizationPendingException,jr as AuthorizationPendingException$,Kr as CreateToken$,Vr as CreateTokenCommand,zr as CreateTokenRequest$,Lr as CreateTokenResponse$,Br as ExpiredTokenException,Wr as ExpiredTokenException$,Yr as InternalServerException,Jr as InternalServerException$,Xr as InvalidClientException,Qr as InvalidClientException$,Zr as InvalidGrantException,eo as InvalidGrantException$,to as InvalidRequestException,ro as InvalidRequestException$,oo as InvalidRequestExceptionReason,no as InvalidScopeException,so as InvalidScopeException$,io as SSOOIDC,co as SSOOIDCClient,ao as SSOOIDCServiceException,po as SSOOIDCServiceException$,uo as SlowDownException,lo as SlowDownException$,ho as UnauthorizedClientException,_o as UnauthorizedClientException$,go as UnsupportedGrantTypeException,Eo as UnsupportedGrantTypeException$,mo as errorTypeRegistries};
2
+ import{Os,Qo}from"./chunk-1nvj833s.js";import{Ko}from"./chunk-p0j4wpa5.js";import{Wo,yo,Dt}from"./chunk-ypkkfwfb.js";import{gn,ar,Ge,tn,Xt,vo,qt}from"./chunk-k3prp6c6.js";var{awsEndpointFunctions:me,emitWarningIfUnsupportedVersion:xe,createDefaultUserAgentProvider:fe,NODE_APP_ID_CONFIG_OPTIONS:Se,getAwsRegionExtensionConfiguration:ve,resolveAwsRegionExtensionConfiguration:Pe,resolveUserAgentConfig:Ie,resolveHostHeaderConfig:Ce,getUserAgentPlugin:Ae,getHostHeaderPlugin:ye,getLoggerPlugin:Te,getRecursionDetectionPlugin:Oe}=Dt(),{NoAuthSigner:Re,getHttpAuthSchemeEndpointRuleSetPlugin:De,DefaultIdentityProviderConfig:ke,getHttpSigningPlugin:$e}=yo(),{normalizeProvider:j,getSmithyContext:we,ServiceException:Ne,NoOpLogger:be,emitWarningIfUnsupportedVersion:Ue,loadConfigsForDefaultMode:Fe,getDefaultExtensionConfiguration:qe,resolveDefaultRuntimeConfig:He,Client:K,makeBuilder:Me,createAggregatedClient:je}=ar(),{Command:Ke}=ar();var Ur=Ke,Fr=K;var{resolveDefaultsModeConfig:Ve,loadConfig:h,NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS:ze,NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS:Le,NODE_REGION_CONFIG_OPTIONS:Be,NODE_REGION_CONFIG_FILE_OPTIONS:We,resolveRegionConfig:Ye}=Ge(),{BinaryDecisionDiagram:Je,EndpointCache:Xe,decideEndpoint:Qe,customEndpointFunctions:Ze,resolveEndpointConfig:et,getEndpointPlugin:tt}=tn(),{parseUrl:rt,getHttpHandlerExtensionConfiguration:ot,resolveHttpHandlerRuntimeConfig:nt,getContentLengthPlugin:st}=qt(),{DEFAULT_RETRY_MODE:it,NODE_RETRY_MODE_CONFIG_OPTIONS:ct,NODE_MAX_ATTEMPT_CONFIG_OPTIONS:at,resolveRetryConfig:pt,getRetryPlugin:dt}=Wo(),{TypeRegistry:V,getSchemaSerdePlugin:ut}=gn(),{resolveAwsSdkSigV4Config:lt,AwsSdkSigV4Signer:ht,NODE_AUTH_SCHEME_PREFERENCE_OPTIONS:_t}=Qo(),{toUtf8:gt,fromUtf8:Et,toBase64:mt,fromBase64:xt,calculateBodyLength:ft}=Xt(),{streamCollector:St,NodeHttpHandler:vt}=Ko(),{AwsRestJsonProtocol:Pt}=Os(),{Sha256:It}=vo(),Ct=async(e,t,n)=>({operation:we(t).operation,region:await j(e.region)()||(()=>{throw Error("expected `region` to be configured for `aws.auth#sigv4`")})()});function At(e){return{schemeId:"aws.auth#sigv4",signingProperties:{name:"sso-oauth",region:e.region},propertiesExtractor:(t,n)=>({signingProperties:{config:t,context:n}})}}function yt(e){return{schemeId:"smithy.api#noAuth"}}var Tt=(e)=>{let t=[];switch(e.operation){case"CreateToken":{t.push(yt());break}default:t.push(At(e))}return t},Ot=(e)=>{let t=lt(e);return Object.assign(t,{authSchemePreference:j(e.authSchemePreference??[])})},Rt=(e)=>Object.assign(e,{useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"sso-oauth"}),kt={UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}},$t="3.997.43",wt={version:$t},E="ref",_=-1,x=!0,q="isSet",z="PartitionResult",f="booleanEquals",w="getAttr",H={[E]:"Endpoint"},N={[E]:z},g={},M=[{[E]:"Region"}],G={conditions:[[q,[H]],[q,M],["aws.partition",M,z],[f,[{[E]:"UseFIPS"},x]],[f,[{[E]:"UseDualStack"},x]],[f,[{fn:w,argv:[N,"supportsDualStack"]},x]],[f,[{fn:w,argv:[N,"supportsFIPS"]},x]],["stringEquals",[{fn:w,argv:[N,"name"]},"aws-us-gov"]]],results:[[_],[_,"Invalid Configuration: FIPS and custom endpoint are not supported"],[_,"Invalid Configuration: Dualstack and custom endpoint are not supported"],[H,g],["https://oidc-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",g],[_,"FIPS and DualStack are enabled, but this partition does not support one or both"],["https://oidc.{Region}.amazonaws.com",g],["https://oidc-fips.{Region}.{PartitionResult#dnsSuffix}",g],[_,"FIPS is enabled but this partition does not support FIPS"],["https://oidc.{Region}.{PartitionResult#dualStackDnsSuffix}",g],[_,"DualStack is enabled but this partition does not support DualStack"],["https://oidc.{Region}.{PartitionResult#dnsSuffix}",g],[_,"Invalid Configuration: Missing Region"]]},Nt=2,c=1e8,bt=new Int32Array([-1,1,-1,0,13,3,1,4,c+12,2,5,c+12,3,8,6,4,7,c+11,5,c+9,c+10,4,11,9,6,10,c+8,7,c+6,c+7,5,12,c+5,6,c+4,c+5,3,c+1,14,4,c+2,c+3]),Ut=Je.from(bt,Nt,G.conditions,G.results),Ft=new Xe({size:50,params:["Endpoint","Region","UseDualStack","UseFIPS"]}),Ht=(e,t={})=>Ft.get(e,()=>Qe(Ut,{endpointParams:e,logger:t.logger}));Ze.aws=me;class i extends Ne{constructor(e){super(e);Object.setPrototypeOf(this,i.prototype)}}class S extends i{name="AccessDeniedException";$fault="client";error;reason;error_description;constructor(e){super({name:"AccessDeniedException",$fault:"client",...e});Object.setPrototypeOf(this,S.prototype),this.error=e.error,this.reason=e.reason,this.error_description=e.error_description}}class v extends i{name="AuthorizationPendingException";$fault="client";error;error_description;constructor(e){super({name:"AuthorizationPendingException",$fault:"client",...e});Object.setPrototypeOf(this,v.prototype),this.error=e.error,this.error_description=e.error_description}}class P extends i{name="ExpiredTokenException";$fault="client";error;error_description;constructor(e){super({name:"ExpiredTokenException",$fault:"client",...e});Object.setPrototypeOf(this,P.prototype),this.error=e.error,this.error_description=e.error_description}}class I extends i{name="InternalServerException";$fault="server";error;error_description;constructor(e){super({name:"InternalServerException",$fault:"server",...e});Object.setPrototypeOf(this,I.prototype),this.error=e.error,this.error_description=e.error_description}}class C extends i{name="InvalidClientException";$fault="client";error;error_description;constructor(e){super({name:"InvalidClientException",$fault:"client",...e});Object.setPrototypeOf(this,C.prototype),this.error=e.error,this.error_description=e.error_description}}class A extends i{name="InvalidGrantException";$fault="client";error;error_description;constructor(e){super({name:"InvalidGrantException",$fault:"client",...e});Object.setPrototypeOf(this,A.prototype),this.error=e.error,this.error_description=e.error_description}}class y extends i{name="InvalidRequestException";$fault="client";error;reason;error_description;constructor(e){super({name:"InvalidRequestException",$fault:"client",...e});Object.setPrototypeOf(this,y.prototype),this.error=e.error,this.reason=e.reason,this.error_description=e.error_description}}class T extends i{name="InvalidScopeException";$fault="client";error;error_description;constructor(e){super({name:"InvalidScopeException",$fault:"client",...e});Object.setPrototypeOf(this,T.prototype),this.error=e.error,this.error_description=e.error_description}}class O extends i{name="SlowDownException";$fault="client";error;error_description;constructor(e){super({name:"SlowDownException",$fault:"client",...e});Object.setPrototypeOf(this,O.prototype),this.error=e.error,this.error_description=e.error_description}}class R extends i{name="UnauthorizedClientException";$fault="client";error;error_description;constructor(e){super({name:"UnauthorizedClientException",$fault:"client",...e});Object.setPrototypeOf(this,R.prototype),this.error=e.error,this.error_description=e.error_description}}class D extends i{name="UnsupportedGrantTypeException";$fault="client";error;error_description;constructor(e){super({name:"UnsupportedGrantTypeException",$fault:"client",...e});Object.setPrototypeOf(this,D.prototype),this.error=e.error,this.error_description=e.error_description}}var Mt="AccessDeniedException",Gt="AuthorizationPendingException",jt="AccessToken",Kt="ClientSecret",Vt="CreateToken",zt="CreateTokenRequest",Lt="CreateTokenResponse",Bt="CodeVerifier",Wt="ExpiredTokenException",Yt="InvalidClientException",Jt="InvalidGrantException",Qt="InvalidRequestException",Zt="InternalServerException",er="InvalidScopeException",tr="IdToken",rr="RefreshToken",or="SlowDownException",nr="UnauthorizedClientException",sr="UnsupportedGrantTypeException",ir="accessToken",l="client",cr="clientId",pr="clientSecret",dr="codeVerifier",ur="code",lr="deviceCode",r="error",hr="expiresIn",d="error_description",_r="grantType",gr="http",u="httpError",Er="idToken",L="reason",B="refreshToken",mr="redirectUri",W="smithy.ts.sdk.synthetic.com.amazonaws.ssooidc",xr="scope",fr="server",Sr="tokenType",o="com.amazonaws.ssooidc",Y=V.for(W),J=[-3,W,"SSOOIDCServiceException",0,[],[]];Y.registerError(J,i);var a=V.for(o),X=[-3,o,Mt,{[r]:l,[u]:400},[r,L,d],[0,0,0]];a.registerError(X,S);var Q=[-3,o,Gt,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(Q,v);var Z=[-3,o,Wt,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(Z,P);var ee=[-3,o,Zt,{[r]:fr,[u]:500},[r,d],[0,0]];a.registerError(ee,I);var te=[-3,o,Yt,{[r]:l,[u]:401},[r,d],[0,0]];a.registerError(te,C);var re=[-3,o,Jt,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(re,A);var oe=[-3,o,Qt,{[r]:l,[u]:400},[r,L,d],[0,0,0]];a.registerError(oe,y);var ne=[-3,o,er,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(ne,T);var se=[-3,o,or,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(se,O);var ie=[-3,o,nr,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(ie,R);var ce=[-3,o,sr,{[r]:l,[u]:400},[r,d],[0,0]];a.registerError(ce,D);var ae=[Y,a],vr=[0,o,jt,8,0],Pr=[0,o,Kt,8,0],Ir=[0,o,Bt,8,0],Cr=[0,o,tr,8,0],pe=[0,o,rr,8,0],de=[3,o,zt,0,[cr,pr,_r,lr,ur,B,xr,mr,dr],[0,[()=>Pr,0],0,0,0,[()=>pe,0],64,0,[()=>Ir,0]],3],ue=[3,o,Lt,0,[ir,Sr,hr,B,Er],[[()=>vr,0],0,1,[()=>pe,0],[()=>Cr,0]]],le=[9,o,Vt,{[gr]:["POST","/token",200]},()=>de,()=>ue],Ar=(e)=>({apiVersion:"2019-06-10",base64Decoder:e?.base64Decoder??xt,base64Encoder:e?.base64Encoder??mt,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??Ht,extensions:e?.extensions??[],httpAuthSchemeProvider:e?.httpAuthSchemeProvider??Tt,httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:(t)=>t.getIdentityProvider("aws.auth#sigv4"),signer:new ht},{schemeId:"smithy.api#noAuth",identityProvider:(t)=>t.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),signer:new Re}],logger:e?.logger??new be,protocol:e?.protocol??Pt,protocolSettings:e?.protocolSettings??{defaultNamespace:"com.amazonaws.ssooidc",errorTypeRegistries:ae,version:"2019-06-10",serviceTarget:"AWSSSOOIDCService"},serviceId:e?.serviceId??"SSO OIDC",sha256:e?.sha256??It,urlParser:e?.urlParser??rt,utf8Decoder:e?.utf8Decoder??Et,utf8Encoder:e?.utf8Encoder??gt}),yr=(e)=>{Ue(process.version);let t=Ve(e),n=()=>t().then(Fe),p=Ar(e);xe(process.version);let s={profile:e?.profile,logger:p.logger};return{...p,...e,runtime:"node",defaultsMode:t,authSchemePreference:e?.authSchemePreference??h(_t,s),bodyLengthChecker:e?.bodyLengthChecker??ft,defaultUserAgentProvider:e?.defaultUserAgentProvider??fe({serviceId:p.serviceId,clientVersion:wt.version}),maxAttempts:e?.maxAttempts??h(at,e),region:e?.region??h(Be,{...We,...s}),requestHandler:vt.create(e?.requestHandler??n),retryMode:e?.retryMode??h({...ct,default:async()=>(await n()).retryMode||it},e),streamCollector:e?.streamCollector??St,useDualstackEndpoint:e?.useDualstackEndpoint??h(Le,s),useFipsEndpoint:e?.useFipsEndpoint??h(ze,s),userAgentAppId:e?.userAgentAppId??h(Se,s)}},Tr=(e)=>{let{httpAuthSchemes:t,httpAuthSchemeProvider:n,credentials:p}=e;return{setHttpAuthScheme(s){let m=t.findIndex((k)=>k.schemeId===s.schemeId);if(m===-1)t.push(s);else t.splice(m,1,s)},httpAuthSchemes(){return t},setHttpAuthSchemeProvider(s){n=s},httpAuthSchemeProvider(){return n},setCredentials(s){p=s},credentials(){return p}}},Or=(e)=>({httpAuthSchemes:e.httpAuthSchemes(),httpAuthSchemeProvider:e.httpAuthSchemeProvider(),credentials:e.credentials()}),Rr=(e,t)=>{let n=Object.assign(ve(e),qe(e),ot(e),Tr(e));return t.forEach((p)=>p.configure(n)),Object.assign(e,Pe(n),He(n),nt(n),Or(n))};class b extends K{config;constructor(...[e]){let t=yr(e||{});super(t);this.initConfig=t;let n=Rt(t),p=Ie(n),s=pt(p),m=Ye(s),k=Ce(m),he=et(k),_e=Ot(he),ge=Rr(_e,e?.extensions||[]);this.config=ge,this.middlewareStack.use(ut(this.config)),this.middlewareStack.use(Ae(this.config)),this.middlewareStack.use(dt(this.config)),this.middlewareStack.use(st(this.config)),this.middlewareStack.use(ye(this.config)),this.middlewareStack.use(Te(this.config)),this.middlewareStack.use(Oe(this.config)),this.middlewareStack.use(De(this.config,{httpAuthSchemeParametersProvider:Ct,identityProviderConfigProvider:async(Ee)=>new ke({"aws.auth#sigv4":Ee.credentials})})),this.middlewareStack.use($e(this.config))}destroy(){super.destroy()}}var Dr=Me(kt,"AWSSSOOIDCService","SSOOIDCClient",tt),kr={},$r=(e,t,n,p)=>[];class U extends Dr(kr,$r,"CreateToken",le){}var wr={CreateTokenCommand:U};class F extends b{}je(wr,F);var Nr={KMS_ACCESS_DENIED:"KMS_AccessDeniedException"},br={KMS_DISABLED_KEY:"KMS_DisabledException",KMS_INVALID_KEY_USAGE:"KMS_InvalidKeyUsageException",KMS_INVALID_STATE:"KMS_InvalidStateException",KMS_KEY_NOT_FOUND:"KMS_NotFoundException"};var qr=S,Hr=X,Mr=Nr,Gr=v,jr=Q,Kr=le,Vr=U,zr=de,Lr=ue,Br=P,Wr=Z,Yr=I,Jr=ee,Xr=C,Qr=te,Zr=A,eo=re,to=y,ro=oe,oo=br,no=T,so=ne,io=F,co=b,ao=i,po=J,uo=O,lo=se,ho=R,_o=ie,go=D,Eo=ce,mo=ae;export{Ur as $Command,Fr as __Client,qr as AccessDeniedException,Hr as AccessDeniedException$,Mr as AccessDeniedExceptionReason,Gr as AuthorizationPendingException,jr as AuthorizationPendingException$,Kr as CreateToken$,Vr as CreateTokenCommand,zr as CreateTokenRequest$,Lr as CreateTokenResponse$,Br as ExpiredTokenException,Wr as ExpiredTokenException$,Yr as InternalServerException,Jr as InternalServerException$,Xr as InvalidClientException,Qr as InvalidClientException$,Zr as InvalidGrantException,eo as InvalidGrantException$,to as InvalidRequestException,ro as InvalidRequestException$,oo as InvalidRequestExceptionReason,no as InvalidScopeException,so as InvalidScopeException$,io as SSOOIDC,co as SSOOIDCClient,ao as SSOOIDCServiceException,po as SSOOIDCServiceException$,uo as SlowDownException,lo as SlowDownException$,ho as UnauthorizedClientException,_o as UnauthorizedClientException$,go as UnsupportedGrantTypeException,Eo as UnsupportedGrantTypeException$,mo as errorTypeRegistries};