@shumai-one/shumai 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/{chunk-qmtvy2j4.js → chunk-03pw611p.js} +2 -2
- package/bin/{chunk-1nh6xgek.js → chunk-05m8w09t.js} +1 -1
- package/bin/chunk-0ark0qrm.js +1 -0
- package/bin/{chunk-arpna31w.js → chunk-1apsnd7e.js} +1 -1
- package/bin/{chunk-g2dk56e7.js → chunk-1bfrnc6b.js} +1 -1
- package/bin/chunk-21h9kgp5.js +1 -0
- package/bin/{chunk-na2nympm.js → chunk-2967rnmn.js} +1 -1
- package/bin/chunk-2errtbmb.js +2 -0
- package/bin/{chunk-hrzm70wg.js → chunk-2jnyk045.js} +1 -1
- package/bin/{chunk-etces6ff.js → chunk-2mr99scd.js} +2 -2
- package/bin/chunk-2pxev94x.js +2 -0
- package/bin/chunk-2y9t0qxp.js +45 -0
- package/bin/{chunk-s7qpj715.js → chunk-2ydhnafa.js} +2 -2
- package/bin/chunk-38hp9gfh.js +2 -0
- package/bin/chunk-3t7v2de9.js +307 -0
- package/bin/{chunk-20y3wte3.js → chunk-3vbx3x11.js} +2 -2
- package/bin/{chunk-d3s00sn0.js → chunk-3xfhbvar.js} +2 -2
- package/bin/chunk-4153rke8.js +12 -0
- package/bin/{chunk-7jjc175m.js → chunk-4a185tez.js} +3 -3
- package/bin/{chunk-zxpef55w.js → chunk-4rexdetz.js} +3 -3
- package/bin/{chunk-1dawjfk8.js → chunk-58y9bagr.js} +2 -2
- package/bin/chunk-5dqn7egd.js +11 -0
- package/bin/{chunk-9p2d0mk1.js → chunk-5e48saab.js} +1 -1
- package/bin/{chunk-vnfmh5ke.js → chunk-5qwzveck.js} +2 -2
- package/bin/chunk-61hfhfce.js +2 -0
- package/bin/chunk-6ab9eftx.js +3 -0
- package/bin/chunk-6b0f3d07.js +2 -0
- package/bin/chunk-6gjn8trh.js +3 -0
- package/bin/{chunk-gn8snrnk.js → chunk-75x3w5hx.js} +1 -1
- package/bin/chunk-7e39zmss.js +1 -0
- package/bin/chunk-7h1m1e0b.js +1 -0
- package/bin/chunk-7kdz1eng.js +3 -0
- package/bin/chunk-7pcba64w.js +1 -0
- package/bin/{chunk-s05f0v9t.js → chunk-7xfx7741.js} +1 -1
- package/bin/chunk-898hrxwq.js +2 -0
- package/bin/{chunk-ph3e1bpp.js → chunk-89chaa11.js} +2 -2
- package/bin/chunk-8btfb5g6.js +2 -0
- package/bin/{chunk-gvn079hy.js → chunk-8pa1n500.js} +2 -2
- package/bin/{chunk-vy24ncn2.js → chunk-8qe7cpbr.js} +1 -1
- package/bin/{chunk-ws07a9kv.js → chunk-8tnq43k9.js} +1 -1
- package/bin/{chunk-1d22tysv.js → chunk-8wzepzp3.js} +2 -2
- package/bin/chunk-9deae0n7.js +3 -0
- package/bin/{chunk-3rcc5s99.js → chunk-ankkm2wz.js} +2 -2
- package/bin/chunk-ardp3pze.js +2 -0
- package/bin/chunk-axe5rq99.js +7 -0
- package/bin/chunk-bagxeg82.js +2 -0
- package/bin/{chunk-ss45w8ks.js → chunk-bhqrqt97.js} +2 -2
- package/bin/chunk-bn1sts8x.js +3 -0
- package/bin/{chunk-31mjcykb.js → chunk-bpb0szs5.js} +2 -2
- package/bin/{chunk-tsncwscz.js → chunk-c1j58ekb.js} +2 -2
- package/bin/chunk-c4nenmry.js +2 -0
- package/bin/chunk-c9f6n4sf.js +3 -0
- package/bin/chunk-cwh21vfb.js +2 -0
- package/bin/chunk-cwpmf8tx.js +2 -0
- package/bin/{chunk-ejfmxjw6.js → chunk-d2xrh0vv.js} +2 -2
- package/bin/chunk-d4sg0z3y.js +2 -0
- package/bin/chunk-d4sjezbk.js +8 -0
- package/bin/{chunk-vgb8bzcg.js → chunk-ddfx823h.js} +2 -2
- package/bin/chunk-dtjx1097.js +2 -0
- package/bin/chunk-e32bzfza.js +1 -0
- package/bin/chunk-e6rmqgzv.js +2 -0
- package/bin/chunk-ersxsrz8.js +62 -0
- package/bin/chunk-gg1wfpm8.js +3 -0
- package/bin/{chunk-qc6dmzn0.js → chunk-gg8dmkwd.js} +2 -2
- package/bin/chunk-gnx9g8px.js +2 -0
- package/bin/{chunk-xawwxdq9.js → chunk-h0k9zw29.js} +2 -2
- package/bin/chunk-htrzgs2a.css +1 -0
- package/bin/chunk-j2jdrmaa.js +2 -0
- package/bin/{chunk-v2kfr8fx.js → chunk-j5dejr3e.js} +2 -2
- package/bin/{chunk-wap08p4j.js → chunk-j5q3t199.js} +2 -2
- package/bin/chunk-jgxhv36z.js +3 -0
- package/bin/{chunk-dwswqq3g.js → chunk-jnx8p6kj.js} +1 -1
- package/bin/chunk-k41vt2gq.js +1 -0
- package/bin/chunk-k78m3rar.js +2 -0
- package/bin/chunk-kfbztymc.js +4 -0
- package/bin/chunk-kgr3ytpb.js +5 -0
- package/bin/chunk-khc3dydj.js +2 -0
- package/bin/chunk-krpr6g8a.js +1 -0
- package/bin/chunk-m8tnsds1.js +2 -0
- package/bin/chunk-mfmcsdd7.js +1 -0
- package/bin/chunk-msjv1ykh.js +2 -0
- package/bin/chunk-n73dbqps.js +1 -0
- package/bin/{chunk-5vqan9c4.js → chunk-n7cmya8k.js} +2 -2
- package/bin/{chunk-hfp4hpca.js → chunk-nabagpah.js} +2 -2
- package/bin/chunk-nn5qpr0q.js +1 -0
- package/bin/{chunk-ve7v8wtv.js → chunk-pew69nxg.js} +2 -2
- package/bin/{chunk-7eycsyk6.js → chunk-q2shr586.js} +1 -1
- package/bin/chunk-q7v8sj72.js +1 -0
- package/bin/chunk-q9tm2d21.js +8 -0
- package/bin/{chunk-mcxsk75h.js → chunk-qw5yjhab.js} +3 -3
- package/bin/{chunk-j0p1peav.js → chunk-r9thyg31.js} +2 -2
- package/bin/{chunk-h2wsm7h3.js → chunk-s584wxzj.js} +2 -2
- package/bin/{chunk-wr5byz6r.js → chunk-s5s1rk4n.js} +1 -1
- package/bin/{chunk-zs9b0f3z.js → chunk-scfbmsy7.js} +2 -2
- package/bin/{chunk-k20bhxed.js → chunk-sddrv3ep.js} +1 -1
- package/bin/{chunk-amsb41z5.js → chunk-sfmhbk59.js} +1 -1
- package/bin/chunk-tbdgkpgw.js +2 -0
- package/bin/chunk-twhj7h73.js +1 -0
- package/bin/{chunk-mahxw48e.js → chunk-v5zdafv4.js} +2 -2
- package/bin/{chunk-3t7mjvdv.js → chunk-vzx1r87y.js} +2 -2
- package/bin/{chunk-a76c5r3c.js → chunk-w3xzd86e.js} +2 -2
- package/bin/{chunk-nzy3pjjm.js → chunk-xkh6b42h.js} +2 -2
- package/bin/chunk-yn7mxpmb.js +7 -0
- package/bin/{chunk-yahb7wan.js → chunk-z544s59c.js} +2 -2
- package/bin/{chunk-f8cn9m28.js → chunk-zned6mj8.js} +1 -1
- package/bin/{chunk-08mxv0sm.js → chunk-zpq34g0w.js} +2 -2
- package/bin/shumai-app.html +1 -1
- package/bin/shumai-app.js +495 -372
- package/package.json +7 -7
- package/prisma/migrations/20260801065040_add_audit_log/migration.sql +33 -0
- package/prisma/migrations/20260805021613_add_asset_autofill_context/migration.sql +2 -0
- package/prisma/migrations/20260806082136_add_sharelink_watermark/migration.sql +69 -0
- package/prisma/migrations/20260806085643_add_watermark_file_status/migration.sql +7 -0
- package/prisma/migrations/20260807140837_clean_media_remove_raw_transcodes_and_original_download_url/migration.sql +86 -0
- package/prisma/migrations/20260808014542_add_sharelink_allow_download/migration.sql +2 -0
- package/prisma/schema.prisma +93 -0
- package/bin/chunk-08dr94gp.js +0 -2
- package/bin/chunk-0t4z17qr.js +0 -2
- package/bin/chunk-2ynx0den.js +0 -8
- package/bin/chunk-31a3k77j.js +0 -2
- package/bin/chunk-3jdef7n4.js +0 -6
- package/bin/chunk-4ahve1nf.js +0 -2
- package/bin/chunk-4hdnrwh1.js +0 -1
- package/bin/chunk-4hdx2tv0.js +0 -2
- package/bin/chunk-4htdb0xp.js +0 -1
- package/bin/chunk-4p7xpfey.js +0 -2
- package/bin/chunk-5f81c951.js +0 -1
- package/bin/chunk-5zntjzxw.js +0 -3
- package/bin/chunk-6a2eb3b5.js +0 -3
- package/bin/chunk-6t3gdd7e.js +0 -2
- package/bin/chunk-7d5kep8c.js +0 -2
- package/bin/chunk-7kzqkp5z.js +0 -1
- package/bin/chunk-7sh6409h.js +0 -1
- package/bin/chunk-7y8dng8t.js +0 -2
- package/bin/chunk-8e5zvy88.js +0 -307
- package/bin/chunk-8m6zg15c.js +0 -4
- package/bin/chunk-8qyke29r.js +0 -7
- package/bin/chunk-90et6bwm.js +0 -3
- package/bin/chunk-9c7fxjej.js +0 -2
- package/bin/chunk-a10tf0d8.js +0 -3
- package/bin/chunk-b10meywb.js +0 -2
- package/bin/chunk-b1e3tec3.js +0 -62
- package/bin/chunk-bdjhb77e.js +0 -2
- package/bin/chunk-beay9amy.js +0 -1
- package/bin/chunk-c3fvs0bv.js +0 -4
- package/bin/chunk-c5my1b3k.js +0 -7
- package/bin/chunk-dhekxndw.js +0 -3
- package/bin/chunk-dwaj1yn4.js +0 -2
- package/bin/chunk-er1rb6yj.js +0 -1
- package/bin/chunk-etqpzc9e.js +0 -3
- package/bin/chunk-fdpjw17x.js +0 -7
- package/bin/chunk-gqh4ttjh.js +0 -3
- package/bin/chunk-hz31j0hk.js +0 -4
- package/bin/chunk-jm6bxtzt.js +0 -41
- package/bin/chunk-jstc7pka.js +0 -2
- package/bin/chunk-k0a35mg9.js +0 -2
- package/bin/chunk-k9w6mk9d.js +0 -3
- package/bin/chunk-kgb16ggd.css +0 -1
- package/bin/chunk-m4py21f3.js +0 -2
- package/bin/chunk-mm1j72a8.js +0 -7
- package/bin/chunk-nr89225z.js +0 -2
- package/bin/chunk-nrf5r23d.js +0 -1
- package/bin/chunk-nt9tfjx6.js +0 -12
- package/bin/chunk-p396vw9h.js +0 -8
- package/bin/chunk-p9xfyqh1.js +0 -2
- package/bin/chunk-pj0fgb2x.js +0 -6
- package/bin/chunk-pp072ksj.js +0 -2
- package/bin/chunk-q5cdjzbv.js +0 -3
- package/bin/chunk-qn96vbke.js +0 -2
- package/bin/chunk-qvgc9e08.js +0 -3
- package/bin/chunk-rrxjvewm.js +0 -2
- package/bin/chunk-s5rfya1p.js +0 -1
- package/bin/chunk-scsy69bp.js +0 -1
- package/bin/chunk-sf6fwvrs.js +0 -8
- package/bin/chunk-t2txvzkp.js +0 -3
- package/bin/chunk-td54rdfj.js +0 -8
- package/bin/chunk-vb9m47z9.js +0 -1
- package/bin/chunk-vf066xwh.js +0 -3
- package/bin/chunk-w3a50kz8.js +0 -3
- package/bin/chunk-w9w5301f.js +0 -4
- package/bin/chunk-wny0qagx.js +0 -3
- package/bin/chunk-wqhk76de.js +0 -14
- package/bin/chunk-wrz9e73c.js +0 -2
- package/bin/chunk-x5dcgk62.js +0 -6
- package/bin/chunk-xwmsxg5x.js +0 -1
- package/bin/chunk-y2nw8rbx.js +0 -4
- package/bin/chunk-y9ttm07y.js +0 -3
- package/bin/chunk-z0ej44ak.js +0 -3
- package/bin/chunk-zemgtnk0.js +0 -1
- package/bin/chunk-zg0vm233.js +0 -2
- package/bin/chunk-zhd2mkbr.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{R as n,S as o,T as s}from"./chunk-k78m3rar.js";import{$ as E2,Aa as Z1,Ba as h,Ca as X2,Da as S1,Ea as X1,V as v,W as O2,X as E5,Y as _0,Z as S2,_ as I5,ba as y2,da as I2,ea as D5,fa as f5,ga as x5,ha as j5,ia as y5,ja as _5,ka as v5,la as D2,ma as f2,na as x2,oa as h5,pa as g5,qa as m5,ra as b5,sa as P1,ta as T1,ua as O1,va as c5,wa as u5,xa as Z2,ya as $1,za as J1}from"./chunk-bpb0szs5.js";import{Wa as _}from"./chunk-2pxev94x.js";import{eb as g0}from"./chunk-ankkm2wz.js";import{rf as K2}from"./chunk-gg1wfpm8.js";import{Cf as S0,Df as y,If as q5,Nf as B0,Sf as P2}from"./chunk-j5q3t199.js";import{ig as U0}from"./chunk-v5zdafv4.js";import{jg as L1,lg as R1,mg as k1,ng as C1}from"./chunk-38hp9gfh.js";import{Ag as Q2,Aj as V0,Bg as K,Bj as A0,Cg as A,Cj as L0,Dg as H1,Fi as c2,Fj as I,Gj as h0,Hh as N1,Ig as b2,Jh as H2,Kh as w0,Ki as G1,Lh as z5,Li as M1,Mh as G5,Qi as r0,Ri as U1,Sh as M5,Ti as w1,Vi as F1,Yg as n0,Zg as Q5,Zi as V1,_i as A1,cj as F0,dh as O0,ei as B1,fi as W1,oi as z1,rh as K1,sj as m0,th as q1,xj as R0,zg as u,zj as $0}from"./chunk-ersxsrz8.js";import{Jk as c}from"./chunk-8tnq43k9.js";var a2=Symbol.for("immer-nothing"),p2=Symbol.for("immer-draftable"),b=Symbol.for("immer-state");function l($,...J){throw Error(`[Immer] minified error nr: ${$}. Full error at: https://bit.ly/3cXEKWf`)}var k0=Object.getPrototypeOf;function N0($){return!!$&&!!$[b]}function Y0($){if(!$)return!1;return t2($)||Array.isArray($)||!!$[p2]||!!$.constructor?.[p2]||T0($)||p0($)}var v1=Object.prototype.constructor.toString(),i2=new WeakMap;function t2($){if(!$||typeof $!=="object")return!1;let J=Object.getPrototypeOf($);if(J===null||J===Object.prototype)return!0;let Z=Object.hasOwnProperty.call(J,"constructor")&&J.constructor;if(Z===Object)return!0;if(typeof Z!=="function")return!1;let X=i2.get(Z);if(X===void 0)X=Function.toString.call(Z),i2.set(Z,X);return X===v1}function c0($,J,Z=!0){if(l0($)===0)(Z?Reflect.ownKeys($):Object.keys($)).forEach((Y)=>{J(Y,$[Y],$)});else $.forEach((X,Y)=>J(Y,X,$))}function l0($){let J=$[b];return J?J.type_:Array.isArray($)?1:T0($)?2:p0($)?3:0}function W2($,J){return l0($)===2?$.has(J):Object.prototype.hasOwnProperty.call($,J)}function e2($,J,Z){let X=l0($);if(X===2)$.set(J,Z);else if(X===3)$.add(Z);else $[J]=Z}function h1($,J){if($===J)return $!==0||1/$===1/J;else return $!==$&&J!==J}function T0($){return $ instanceof Map}function p0($){return $ instanceof Set}function X0($){return $.copy_||$.base_}function z2($,J){if(T0($))return new Map($);if(p0($))return new Set($);if(Array.isArray($))return Array.prototype.slice.call($);let Z=t2($);if(J===!0||J==="class_only"&&!Z){let X=Object.getOwnPropertyDescriptors($);delete X[b];let Y=Reflect.ownKeys(X);for(let q=0;q<Y.length;q++){let Q=Y[q],H=X[Q];if(H.writable===!1)H.writable=!0,H.configurable=!0;if(H.get||H.set)X[Q]={configurable:!0,writable:!0,enumerable:H.enumerable,value:$[Q]}}return Object.create(k0($),X)}else{let X=k0($);if(X!==null&&Z)return{...$};let Y=Object.create(X);return Object.assign(Y,$)}}function F2($,J=!1){if(i0($)||N0($)||!Y0($))return $;if(l0($)>1)Object.defineProperties($,{set:b0,add:b0,clear:b0,delete:b0});if(Object.freeze($),J)Object.values($).forEach((Z)=>F2(Z,!0));return $}function g1(){l(2)}var b0={value:g1};function i0($){if($===null||typeof $!=="object")return!0;return Object.isFrozen($)}var m1={};function Q0($){let J=m1[$];if(!J)l(0,$);return J}var C0;function $5(){return C0}function b1($,J){return{drafts_:[],parent_:$,immer_:J,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function n2($,J){if(J)Q0("Patches"),$.patches_=[],$.inversePatches_=[],$.patchListener_=J}function G2($){M2($),$.drafts_.forEach(c1),$.drafts_=null}function M2($){if($===C0)C0=$.parent_}function o2($){return C0=b1(C0,$)}function c1($){let J=$[b];if(J.type_===0||J.type_===1)J.revoke_();else J.revoked_=!0}function s2($,J){J.unfinalizedDrafts_=J.drafts_.length;let Z=J.drafts_[0];if($!==void 0&&$!==Z){if(Z[b].modified_)G2(J),l(4);if(Y0($)){if($=u0(J,$),!J.parent_)d0(J,$)}if(J.patches_)Q0("Patches").generateReplacementPatches_(Z[b].base_,$,J.patches_,J.inversePatches_)}else $=u0(J,Z,[]);if(G2(J),J.patches_)J.patchListener_(J.patches_,J.inversePatches_);return $!==a2?$:void 0}function u0($,J,Z){if(i0(J))return J;let X=$.immer_.shouldUseStrictIteration(),Y=J[b];if(!Y)return c0(J,(q,Q)=>r2($,Y,J,q,Q,Z),X),J;if(Y.scope_!==$)return J;if(!Y.modified_)return d0($,Y.base_,!0),Y.base_;if(!Y.finalized_){Y.finalized_=!0,Y.scope_.unfinalizedDrafts_--;let q=Y.copy_,Q=q,H=!1;if(Y.type_===3)Q=new Set(q),q.clear(),H=!0;if(c0(Q,(G,z)=>r2($,Y,q,G,z,Z,H),X),d0($,q,!1),Z&&$.patches_)Q0("Patches").generatePatches_(Y,Z,$.patches_,$.inversePatches_)}return Y.copy_}function r2($,J,Z,X,Y,q,Q){if(Y==null)return;if(typeof Y!=="object"&&!Q)return;let H=i0(Y);if(H&&!Q)return;if(N0(Y)){let G=q&&J&&J.type_!==3&&!W2(J.assigned_,X)?q.concat(X):void 0,z=u0($,Y,G);if(e2(Z,X,z),N0(z))$.canAutoFreeze_=!1;else return}else if(Q)Z.add(Y);if(Y0(Y)&&!H){if(!$.immer_.autoFreeze_&&$.unfinalizedDrafts_<1)return;if(J&&J.base_&&J.base_[X]===Y&&H)return;if(u0($,Y),(!J||!J.scope_.parent_)&&typeof X!=="symbol"&&(T0(Z)?Z.has(X):Object.prototype.propertyIsEnumerable.call(Z,X)))d0($,Y)}}function d0($,J,Z=!1){if(!$.parent_&&$.immer_.autoFreeze_&&$.canAutoFreeze_)F2(J,Z)}function u1($,J){let Z=Array.isArray($),X={type_:Z?1:0,scope_:J?J.scope_:$5(),modified_:!1,finalized_:!1,assigned_:{},parent_:J,base_:$,draft_:null,copy_:null,revoke_:null,isManual_:!1},Y=X,q=V2;if(Z)Y=[X],q=P0;let{revoke:Q,proxy:H}=Proxy.revocable(Y,q);return X.draft_=H,X.revoke_=Q,H}var V2={get($,J){if(J===b)return $;let Z=X0($);if(!W2(Z,J))return d1($,Z,J);let X=Z[J];if($.finalized_||!Y0(X))return X;if(X===N2($.base_,J))return B2($),$.copy_[J]=w2(X,$);return X},has($,J){return J in X0($)},ownKeys($){return Reflect.ownKeys(X0($))},set($,J,Z){let X=J5(X0($),J);if(X?.set)return X.set.call($.draft_,Z),!0;if(!$.modified_){let Y=N2(X0($),J),q=Y?.[b];if(q&&q.base_===Z)return $.copy_[J]=Z,$.assigned_[J]=!1,!0;if(h1(Z,Y)&&(Z!==void 0||W2($.base_,J)))return!0;B2($),U2($)}if($.copy_[J]===Z&&(Z!==void 0||(J in $.copy_))||Number.isNaN(Z)&&Number.isNaN($.copy_[J]))return!0;return $.copy_[J]=Z,$.assigned_[J]=!0,!0},deleteProperty($,J){if(N2($.base_,J)!==void 0||J in $.base_)$.assigned_[J]=!1,B2($),U2($);else delete $.assigned_[J];if($.copy_)delete $.copy_[J];return!0},getOwnPropertyDescriptor($,J){let Z=X0($),X=Reflect.getOwnPropertyDescriptor(Z,J);if(!X)return X;return{writable:!0,configurable:$.type_!==1||J!=="length",enumerable:X.enumerable,value:Z[J]}},defineProperty(){l(11)},getPrototypeOf($){return k0($.base_)},setPrototypeOf(){l(12)}},P0={};c0(V2,($,J)=>{P0[$]=function(){return arguments[0]=arguments[0][0],J.apply(this,arguments)}});P0.deleteProperty=function($,J){return P0.set.call(this,$,J,void 0)};P0.set=function($,J,Z){return V2.set.call(this,$[0],J,Z,$[0])};function N2($,J){let Z=$[b];return(Z?X0(Z):$)[J]}function d1($,J,Z){let X=J5(J,Z);return X?"value"in X?X.value:X.get?.call($.draft_):void 0}function J5($,J){if(!(J in $))return;let Z=k0($);while(Z){let X=Object.getOwnPropertyDescriptor(Z,J);if(X)return X;Z=k0(Z)}return}function U2($){if(!$.modified_){if($.modified_=!0,$.parent_)U2($.parent_)}}function B2($){if(!$.copy_)$.copy_=z2($.base_,$.scope_.immer_.useStrictShallowCopy_)}var l1=class{constructor($){if(this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(J,Z,X)=>{if(typeof J==="function"&&typeof Z!=="function"){let q=Z;Z=J;let Q=this;return function(G=q,...z){return Q.produce(G,(M)=>Z.call(this,M,...z))}}if(typeof Z!=="function")l(6);if(X!==void 0&&typeof X!=="function")l(7);let Y;if(Y0(J)){let q=o2(this),Q=w2(J,void 0),H=!0;try{Y=Z(Q),H=!1}finally{if(H)G2(q);else M2(q)}return n2(q,X),s2(Y,q)}else if(!J||typeof J!=="object"){if(Y=Z(J),Y===void 0)Y=J;if(Y===a2)Y=void 0;if(this.autoFreeze_)F2(Y,!0);if(X){let q=[],Q=[];Q0("Patches").generateReplacementPatches_(J,Y,q,Q),X(q,Q)}return Y}else l(1,J)},this.produceWithPatches=(J,Z)=>{if(typeof J==="function")return(Q,...H)=>this.produceWithPatches(Q,(G)=>J(G,...H));let X,Y;return[this.produce(J,Z,(Q,H)=>{X=Q,Y=H}),X,Y]},typeof $?.autoFreeze==="boolean")this.setAutoFreeze($.autoFreeze);if(typeof $?.useStrictShallowCopy==="boolean")this.setUseStrictShallowCopy($.useStrictShallowCopy);if(typeof $?.useStrictIteration==="boolean")this.setUseStrictIteration($.useStrictIteration)}createDraft($){if(!Y0($))l(8);if(N0($))$=p1($);let J=o2(this),Z=w2($,void 0);return Z[b].isManual_=!0,M2(J),Z}finishDraft($,J){let Z=$&&$[b];if(!Z||!Z.isManual_)l(9);let{scope_:X}=Z;return n2(X,J),s2(void 0,X)}setAutoFreeze($){this.autoFreeze_=$}setUseStrictShallowCopy($){this.useStrictShallowCopy_=$}setUseStrictIteration($){this.useStrictIteration_=$}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches($,J){let Z;for(Z=J.length-1;Z>=0;Z--){let Y=J[Z];if(Y.path.length===0&&Y.op==="replace"){$=Y.value;break}}if(Z>-1)J=J.slice(Z+1);let X=Q0("Patches").applyPatches_;if(N0($))return X($,J);return this.produce($,(Y)=>X(Y,J))}};function w2($,J){let Z=T0($)?Q0("MapSet").proxyMap_($,J):p0($)?Q0("MapSet").proxySet_($,J):u1($,J);return(J?J.scope_:$5()).drafts_.push(Z),Z}function p1($){if(!N0($))l(10,$);return Z5($)}function Z5($){if(!Y0($)||i0($))return $;let J=$[b],Z,X=!0;if(J){if(!J.modified_)return J.base_;J.finalized_=!0,Z=z2($,J.scope_.immer_.useStrictShallowCopy_),X=J.scope_.immer_.shouldUseStrictIteration()}else Z=z2($,!0);if(c0(Z,(Y,q)=>{e2(Z,Y,Z5(q))},X),J)J.finalized_=!1;return Z}var i1=new l1,X5=i1.produce;var n1=($)=>(J,Z,X)=>{return X.setState=(Y,q,...Q)=>{let H=typeof Y==="function"?X5(Y):Y;return J(H,q,...Q)},$(X.setState,Z,X)},Y5=n1;var o0=n0()(Q5(Y5(($,J)=>({members:[],loading:!1,fetchMembers:async(Z,X,Y)=>{if(!Y&&J().loadedTeamId===Z&&J().loadedWithAgents===X)return;$({loading:!0});try{let q=await O0.api.teams[":teamId"].members.$get({param:{teamId:Z},query:{includeAgents:X?"true":"false"}});if(!q.ok)throw Error("failed to fetch members");let Q=await q.json();$({members:Q||[],loadedTeamId:Z,loadedWithAgents:X,loading:!1})}catch{$({loading:!1})}}}))));var H5=n0(($)=>({fields:[],loadedProjectId:null,setFields:(J,Z)=>$({fields:J,loadedProjectId:Z}),updateFields:(J)=>$({fields:J})}));function A2($,J,Z){let X=y($,Z?.in);if(isNaN(J))return S0(Z?.in||$,NaN);if(!J)return X;let Y=X.getDate(),q=S0(Z?.in||$,X.getTime());q.setMonth(X.getMonth()+J+1,0);let Q=q.getDate();if(Y>=Q)return q;else return X.setFullYear(q.getFullYear(),q.getMonth(),Y),X}function K5($,J){let Z=y($,J?.in),X=Z.getMonth();return Z.setFullYear(Z.getFullYear(),X+1,0),Z.setHours(23,59,59,999),Z}function N5($,J){let[Z,X]=q5($,J.start,J.end);return{start:Z,end:X}}function B5($,J){let{start:Z,end:X}=N5(J?.in,$),Y=+Z>+X,q=Y?+Z:+X,Q=Y?X:Z;Q.setHours(0,0,0,0);let H=J?.step??1;if(!H)return[];if(H<0)H=-H,Y=!Y;let G=[];while(+Q<=q)G.push(S0(Z,Q)),Q.setDate(Q.getDate()+H),Q.setHours(0,0,0,0);return Y?G.reverse():G}function s0($,J){return y($,J?.in).getDate()}function W5($,J){return y($,J?.in).getDay()}function L2($,J){return y($,J?.in).getHours()}function R2($,J){return y($,J?.in).getMinutes()}function k2($,J){return y($,J?.in).getMonth()}function C2($,J){return y($,J?.in).getFullYear()}var a=c(u(),1);var o1=({value:$,config:J,onSave:Z,readOnly:X})=>{let Y=J?.date,[q,Q]=a.useState(!1),H=a.useRef(null),G=$?new Date($):new Date,z=B0(G)?G:new Date,[M,U]=a.useState(z);a.useEffect(()=>{if(q&&$){let N=new Date($);if(B0(N))U(N)}},[q,$]),a.useEffect(()=>{let N=(k)=>{if(H.current&&!H.current.contains(k.target)){if(q)Q(!1)}};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[q]);let W=()=>{if(!X)Q(!0)},F=(N)=>{if(!N)return"";let k=new Date(N);if(!B0(k))return"Invalid Date";let O="PPP";if(Y?.displayFormat==="usa")O="MM/dd/yyyy";else if(Y?.displayFormat==="euro")O="dd/MM/yyyy";else if(Y?.displayFormat==="iso")O="yyyy-MM-dd";if(Y?.includeTime)if(Y?.timeFormat==="twenty_four_hour")O+=" HH:mm";else O+=" p";let D=P2(k,O);if(Y?.displayTimezone)D+=` (${Intl.DateTimeFormat().resolvedOptions().timeZone})`;return D},B=new Date(M.getFullYear(),M.getMonth(),1),T=K5(M),P=B5({start:B,end:T}),R=W5(B),S=(N)=>{let k=new Date(N);if(Y?.includeTime)k.setHours(L2(z)),k.setMinutes(R2(z));let O=k.toISOString();if(Z(O),!Y?.includeTime)Q(!1)},w=(N,k)=>{let O=$?new Date($):new Date;if(!B0(O))O.setTime(new Date().getTime());if(N==="hour")O.setHours(k);if(N==="minute")O.setMinutes(k);let D=O.toISOString();Z(D)},L=Array.from({length:24},(N,k)=>k),V=Array.from({length:12},(N,k)=>k*5);if(q)return A("div",{className:"relative w-full",ref:H,children:[K("div",{className:"w-full px-2 py-1 border border-ring rounded bg-background text-sm shadow-sm min-h-[28px] flex items-center",children:$?F($):K("span",{className:"text-muted-foreground",children:"Select date..."})}),A("div",{className:"absolute z-50 top-full left-0 mt-1 bg-popover border border-border rounded-lg shadow-xl flex flex-col md:flex-row overflow-hidden min-w-[280px]",children:[A("div",{className:"p-4 w-64",children:[A("div",{className:"flex justify-between items-center mb-4",children:[K("button",{onClick:()=>U(A2(M,-1)),className:"p-1 hover:bg-accent rounded",children:K(z5,{className:"w-4 h-4"})}),K("span",{className:"font-semibold text-sm",children:P2(M,"MMMM yyyy")}),K("button",{onClick:()=>U(A2(M,1)),className:"p-1 hover:bg-accent rounded",children:K(G5,{className:"w-4 h-4"})})]}),K("div",{className:"grid grid-cols-7 gap-1 text-center text-xs mb-2 text-muted-foreground",children:["Su","Mo","Tu","We","Th","Fr","Sa"].map((N)=>K("div",{children:N},N))}),A("div",{className:"grid grid-cols-7 gap-1 text-center text-sm",children:[Array.from({length:R}).map((N,k)=>K("div",{},`empty-${k}`)),P.map((N)=>{let k=$?new Date($):null,O=k&&B0(k)&&s0(k)===s0(N)&&k2(k)===k2(N)&&C2(k)===C2(N);return K("button",{onClick:()=>S(N),className:`w-8 h-8 rounded-full flex items-center justify-center hover:bg-accent transition-colors ${O?"bg-primary text-primary-foreground hover:bg-primary/90":"text-foreground"}`,children:s0(N)},N.toString())})]})]}),Y?.includeTime&&A("div",{className:"border-l border-border bg-muted w-32 flex flex-col",children:[A("div",{className:"p-2 border-b border-border text-xs font-semibold text-muted-foreground flex items-center justify-center gap-1",children:[K(M5,{className:"w-3 h-3"})," Time"]}),A("div",{className:"flex flex-1 h-64",children:[K("div",{className:"flex-1 overflow-y-auto scrollbar-hide border-r border-border",children:L.map((N)=>K("div",{onClick:()=>w("hour",N),className:`px-2 py-1 text-center text-sm cursor-pointer hover:bg-accent ${L2(z)===N?"bg-primary/10 font-medium text-primary":""}`,children:N.toString().padStart(2,"0")},N))}),K("div",{className:"flex-1 overflow-y-auto scrollbar-hide",children:V.map((N)=>K("div",{onClick:()=>w("minute",N),className:`px-2 py-1 text-center text-sm cursor-pointer hover:bg-accent ${R2(z)===N?"bg-primary/10 font-medium text-primary":""}`,children:N.toString().padStart(2,"0")},N))})]})]})]})]});return K("div",{onClick:W,className:`w-full min-h-[28px] px-2 py-1 text-sm text-foreground rounded border border-transparent transition-colors ${!X?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:$?F($):K("span",{className:"text-muted-foreground italic",children:"Empty"})})},U5=o1;var p=c(u(),1);var s1=({value:$,onSave:J,readOnly:Z})=>{let[X,Y]=p.useState(!1),[q,Q]=p.useState($||""),H=p.useRef(null),G=p.useRef(null),[z,M]=p.useState(!1);p.useEffect(()=>{Q($||"")},[$]),p.useEffect(()=>{if(X&&H.current)H.current.focus(),M(!1)},[X]),p.useEffect(()=>{let B=(T)=>{if(z&&G.current&&!G.current.contains(T.target))M(!1)};if(z)document.addEventListener("mousedown",B);return()=>{document.removeEventListener("mousedown",B)}},[z]);let U=()=>{Y(!1),J(q)},W=(B)=>{B.stopPropagation(),M(!0)},F=(B)=>{if(B.stopPropagation(),!Z)Y(!0)};if(X)return K("textarea",{ref:H,value:q,onChange:(B)=>Q(B.target.value),onBlur:U,className:"w-full min-h-[80px] p-2 border border-ring rounded bg-background text-sm outline-none shadow-sm resize-none"});return A("div",{ref:G,className:"relative w-full text-sm",children:[K("div",{onClick:W,className:`w-full text-foreground rounded border border-transparent transition-all px-2 py-1 line-clamp-2 max-h-[3rem] overflow-hidden ${!Z?"cursor-pointer hover:bg-accent hover:border-border":"cursor-pointer"}`,title:"Click to expand",children:$?$:K("span",{className:"text-muted-foreground italic",children:"Empty"})}),z&&K("div",{onClick:F,className:`absolute top-0 left-0 w-full min-h-full h-auto z-50 bg-background border border-ring rounded shadow-lg px-2 py-1 whitespace-pre-wrap ${!Z?"cursor-text":""}`,children:$?$:K("span",{className:"text-muted-foreground italic",children:"Empty"})})]})},w5=s1;var t=c(u(),1);var r1=({value:$,config:J,onSave:Z,readOnly:X})=>{let Y=J?.number,[q,Q]=t.useState(!1),[H,G]=t.useState(""),z=t.useRef(null);t.useEffect(()=>{G($!==void 0&&$!==null?$.toString():"")},[$]),t.useEffect(()=>{if(q&&z.current)z.current.focus()},[q]);let M=()=>{if(!X)Q(!0)},U=()=>{if(Q(!1),H==="")Z(void 0);else{let B=parseFloat(H);Z(isNaN(B)?void 0:B)}},W=(B)=>{if(B.key==="Enter")B.stopPropagation(),z.current?.blur()},F=(B)=>{if(B===void 0||B===null||isNaN(B))return"";return B.toFixed(Y?.scale)};if(q)return K("input",{ref:z,type:"number",step:1/Math.pow(10,Y?.scale||0),value:H,onChange:(B)=>G(B.target.value),onBlur:U,onKeyDown:W,onDoubleClick:(B)=>B.stopPropagation(),className:"w-full px-2 py-1 border border-ring rounded bg-background text-sm outline-none shadow-sm text-left font-mono"});return K("div",{onClick:M,onDoubleClick:(B)=>B.stopPropagation(),className:`w-full min-h-[28px] px-2 py-1 text-sm text-foreground rounded border border-transparent transition-colors text-left font-mono ${!X?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:$!==void 0&&$!==null?F($):K("span",{className:"text-muted-foreground italic font-sans text-left block",children:"Empty"})})},F5=r1;var V5=c(u(),1);var a1=({value:$,config:J,onSave:Z,readOnly:X})=>{let Y=J?.rating,q=Math.max(2,Math.min(6,Y?.maxValue||5)),[Q,H]=V5.useState(null),G=(M,U)=>{if(M.stopPropagation(),X)return;let W;if($===U)W=0;else W=U;Z(W)},z=Array.from({length:q},(M,U)=>U+1);return K("div",{className:"flex items-center gap-1 h-[28px]",onMouseLeave:()=>!X&&H(null),onDoubleClick:(M)=>M.stopPropagation(),children:z.map((M)=>{let U=Q!==null?M<=Q:M<=($||0);return K("button",{onClick:(W)=>G(W,M),onMouseEnter:()=>!X&&H(M),className:`focus:outline-none transition-transform ${!X?"cursor-pointer hover:scale-110":"cursor-default"}`,type:"button",disabled:X,children:K(r0,{className:`w-5 h-5 transition-colors ${U?"fill-yellow-400 text-yellow-400":"fill-muted text-muted-foreground/30"}`})},M)})})},A5=a1;var E1=c(u(),1);var H0;(function($){$.Base32IncorrectEncoding="B32_ENC_INVALID",$.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",$.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",$.EncodeTimeNegative="ENC_TIME_NEG",$.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",$.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",$.PRNGDetectFailure="PRNG_DETECT",$.ULIDInvalid="ULID_INVALID",$.Unexpected="UNEXPECTED",$.UUIDInvalid="UUID_INVALID"})(H0||(H0={}));class W0 extends Error{constructor($,J){super(`${J} (${$})`);this.name="ULIDError",this.code=$}}function t1($){let J=Math.floor($()*32)%32;return"0123456789ABCDEFGHJKMNPQRSTVWXYZ".charAt(J)}function e1($){let J=$4(),Z=J&&(J.crypto||J.msCrypto)||null;if(typeof Z?.getRandomValues==="function")return()=>{let X=new Uint8Array(1);return Z.getRandomValues(X),X[0]/256};else if(typeof Z?.randomBytes==="function")return()=>Z.randomBytes(1).readUInt8()/256;throw new W0(H0.PRNGDetectFailure,"Failed to find a reliable PRNG")}function $4(){if(X4())return self;if(typeof window<"u")return window;if(typeof global<"u")return global;if(typeof globalThis<"u")return globalThis;return null}function J4($,J){let Z="";for(;$>0;$--)Z=t1(J)+Z;return Z}function Z4($,J=10){if(isNaN($))throw new W0(H0.EncodeTimeValueMalformed,`Time must be a number: ${$}`);else if($>281474976710655)throw new W0(H0.EncodeTimeSizeExceeded,`Cannot encode a time larger than 281474976710655: ${$}`);else if($<0)throw new W0(H0.EncodeTimeNegative,`Time must be positive: ${$}`);else if(Number.isInteger($)===!1)throw new W0(H0.EncodeTimeValueMalformed,`Time must be an integer: ${$}`);let Z,X="";for(let Y=J;Y>0;Y--)Z=$%32,X="0123456789ABCDEFGHJKMNPQRSTVWXYZ".charAt(Z)+X,$=($-Z)/32;return X}function X4(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function L5($,J){let Z=J||e1(),X=!$||isNaN($)?Date.now():$;return Z4(X,10)+J4(16,Z)}var v0=c(u(),1);var{create:Y4,defineProperty:d5,defineProperties:Q4,getOwnPropertyDescriptor:H4,getOwnPropertyDescriptors:K4,getOwnPropertySymbols:J2}=Object,l5=Object.prototype.hasOwnProperty,p5=Object.prototype.propertyIsEnumerable,q4=($,J)=>(J=Symbol[$])?J:Symbol.for("Symbol."+$),j0=($)=>{throw TypeError($)},j2=($,J,Z)=>(J in $)?d5($,J,{enumerable:!0,configurable:!0,writable:!0,value:Z}):$[J]=Z,R5=($,J)=>{for(var Z in J||(J={}))if(l5.call(J,Z))j2($,Z,J[Z]);if(J2){for(var Z of J2(J))if(p5.call(J,Z))j2($,Z,J[Z])}return $},k5=($,J)=>Q4($,K4(J)),N4=($,J)=>{var Z={};for(var X in $)if(l5.call($,X)&&J.indexOf(X)<0)Z[X]=$[X];if($!=null&&J2){for(var X of J2($))if(J.indexOf(X)<0&&p5.call($,X))Z[X]=$[X]}return Z},B4=($)=>{var J;return[,,,Y4((J=void 0)!=null?J:null)]},i5=["class","method","getter","setter","accessor","field","value","get","set"],I0=($)=>$!==void 0&&typeof $!=="function"?j0("Function expected"):$,W4=($,J,Z,X,Y)=>({kind:i5[$],name:J,metadata:X,addInitializer:(q)=>Z._?j0("Already initialized"):Y.push(I0(q||null))}),z4=($,J)=>j2(J,q4("metadata"),$[3]),a0=($,J,Z,X)=>{for(var Y=0,q=$[J>>1],Q=q&&q.length;Y<Q;Y++)J&1?q[Y].call(Z):X=q[Y].call(Z,X);return X},n5=($,J,Z,X,Y,q)=>{var Q,H,G,z,M,U=J&7,W=!1,F=!1,B=$.length+1,T=i5[U+5],P=$[B-1]=[],R=$[B]||($[B]=[]),S=(Y=Y.prototype,H4({get[Z](){return D0(this,q)},set[Z](L){return K0(this,q,L)}},Z));for(var w=X.length-1;w>=0;w--)if(z=W4(U,Z,G={},$[3],R),z.static=W,z.private=F,M=z.access={has:(L)=>(Z in L)},M.get=(L)=>L[Z],M.set=(L,V)=>L[Z]=V,H=(0,X[w])({get:S.get,set:S.set},z),G._=1,H===void 0)I0(H)&&(S[T]=H);else if(typeof H!=="object"||H===null)j0("Object expected");else I0(Q=H.get)&&(S.get=Q),I0(Q=H.set)&&(S.set=Q),I0(Q=H.init)&&P.unshift(Q);return S&&d5(Y,Z,S),Y},o5=($,J,Z)=>J.has($)||j0("Cannot "+Z),D0=($,J,Z)=>(o5($,J,"read from private field"),J.get($)),E0=($,J,Z)=>J.has($)?j0("Cannot add the same private member more than once"):J instanceof WeakSet?J.add($):J.set($,Z),K0=($,J,Z,X)=>(o5($,J,"write to private field"),J.set($,Z),Z);function i($){return $ instanceof g2||$ instanceof a5}var t0=10,G4=class extends y2{constructor($){super($);let J=E5(()=>{let{dragOperation:X}=$;if(!x2(X.activatorEvent))return;if(!i(X.source))return;if(X.status.initialized){let Y=$.registry.plugins.get(b5);if(Y)return Y.disable(),()=>Y.enable()}}),Z=$.monitor.addEventListener("dragmove",(X,Y)=>{queueMicrotask(()=>{if(this.disabled||X.defaultPrevented||!X.nativeEvent)return;let{dragOperation:q}=Y;if(!x2(X.nativeEvent))return;if(!i(q.source))return;if(!q.shape)return;let{actions:Q,collisionObserver:H,registry:G}=Y,{by:z}=X;if(!z)return;let M=M4(z),{source:U,target:W}=q,{center:F}=q.shape.current,B=[],T=[];v(()=>{for(let V of G.droppables){let{id:N}=V;if(!V.accepts(U)||N===(W==null?void 0:W.id)&&i(V)||!V.element)continue;let k=V.shape,O=new f2(V.element,{getBoundingClientRect:(D)=>f5(D,void 0,0.2)});if(!O.height||!O.width)continue;if(M=="down"&&F.y+t0<O.center.y||M=="up"&&F.y-t0>O.center.y||M=="left"&&F.x-t0>O.center.x||M=="right"&&F.x+t0<O.center.x)B.push(V),V.shape=O,T.push(()=>V.shape=k)}}),X.preventDefault(),H.disable();let P=H.computeCollisions(B,g5);v(()=>T.forEach((V)=>V()));let[R]=P;if(!R)return;let{id:S}=R,{index:w,group:L}=U.sortable;Q.setDropTarget(S).then(()=>{let{source:V,target:N,shape:k}=q;if(!V||!i(V)||!k)return;let{index:O,group:D,target:f}=V.sortable,g=w!==O||L!==D,m=g?f:N==null?void 0:N.element;if(!m)return;_5(m);let C=new f2(m);if(!C)return;let E=E2.delta(C,E2.from(k.current.boundingRectangle),V.alignment);if(Q.move({by:E}),g)Q.setDropTarget(V.id).then(()=>H.enable());else H.enable()})})});this.destroy=()=>{Z(),J()}}};function M4($){let{x:J,y:Z}=$;if(J>0)return"right";else if(J<0)return"left";else if(Z>0)return"down";else if(Z<0)return"up"}var{defineProperty:U4,defineProperties:w4,getOwnPropertyDescriptors:F4,getOwnPropertySymbols:C5}=Object,V4=Object.prototype.hasOwnProperty,A4=Object.prototype.propertyIsEnumerable,P5=($,J,Z)=>(J in $)?U4($,J,{enumerable:!0,configurable:!0,writable:!0,value:Z}):$[J]=Z,z0=($,J)=>{for(var Z in J||(J={}))if(V4.call(J,Z))P5($,Z,J[Z]);if(C5){for(var Z of C5(J))if(A4.call(J,Z))P5($,Z,J[Z])}return $},G0=($,J)=>w4($,F4(J));function L4($,J,Z){if(J===Z)return $;let X=$.slice();return X.splice(Z,0,X.splice(J,1)[0]),X}function T2($){return"initialIndex"in $&&typeof $.initialIndex==="number"&&"index"in $&&typeof $.index==="number"}function R4($,J,Z){var X,Y,q;let{source:Q,target:H,canceled:G}=J.operation;if(!Q||!H||G){if("preventDefault"in J)J.preventDefault();return $}let z=(L,V)=>L===V||typeof L==="object"&&("id"in L)&&L.id===V;if(Array.isArray($)){let L=$.findIndex((N)=>z(N,Q.id)),V=$.findIndex((N)=>z(N,H.id));if(L===-1||V===-1){if(T2(Q)){let{initialIndex:N,index:k}=Q;if(N===k||N<0||N>=$.length){if("preventDefault"in J)J.preventDefault();return $}return Z($,N,k)}return $}if(!G&&"index"in Q&&typeof Q.index==="number"){let N=Q.index;if(N!==L)return Z($,L,N)}return Z($,L,V)}let M=Object.entries($),U=-1,W,F=-1,B;for(let[L,V]of M){if(U===-1){if(U=V.findIndex((N)=>z(N,Q.id)),U!==-1)W=L}if(F===-1){if(F=V.findIndex((N)=>z(N,H.id)),F!==-1)B=L}if(U!==-1&&F!==-1)break}if(U===-1&&T2(Q)){let{initialGroup:L,initialIndex:V,group:N,index:k}=Q;if(L==null||N==null||!(L in $)||!(N in $)){if("preventDefault"in J)J.preventDefault();return $}if(L===N&&V===k){if("preventDefault"in J)J.preventDefault();return $}if(L===N)return G0(z0({},$),{[L]:Z($[L],V,k)});let O=$[L][V];return G0(z0({},$),{[L]:[...$[L].slice(0,V),...$[L].slice(V+1)],[N]:[...$[N].slice(0,k),O,...$[N].slice(k)]})}if(!Q.manager)return $;let{dragOperation:T}=Q.manager,P=(Y=(X=T.shape)==null?void 0:X.current.center)!=null?Y:T.position.current;if(B==null){if(H.id in $){let L=H.shape&&P.y>H.shape.center.y?$[H.id].length:0;B=H.id,F=L}}if(W==null||B==null||W===B&&U===F){if(W!=null&&W===B&&U===F&&T2(Q)){let L=Q.group!=null&&Q.group!==W,V=Q.index!==U;if(L||V){let N=(q=Q.group)!=null?q:W;if(N in $){if(W===N)return G0(z0({},$),{[W]:Z($[W],U,Q.index)});let k=$[W][U];return G0(z0({},$),{[W]:[...$[W].slice(0,U),...$[W].slice(U+1)],[N]:[...$[N].slice(0,Q.index),k,...$[N].slice(Q.index)]})}}}if("preventDefault"in J)J.preventDefault();return $}if(W===B)return G0(z0({},$),{[W]:Z($[W],U,F)});let S=H.shape&&Math.round(P.y)>Math.round(H.shape.center.y)?1:0,w=$[W][U];return G0(z0({},$),{[W]:[...$[W].slice(0,U),...$[W].slice(U+1)],[B]:[...$[B].slice(0,F+S),w,...$[B].slice(F+S)]})}function k4($,J){return R4($,J,L4)}var T5="__default__",C4=class extends y2{constructor($){super($);let J=()=>{let X=new Map;for(let Y of $.registry.droppables)if(Y instanceof g2){let{sortable:q}=Y,{group:Q}=q,H=X.get(Q);if(!H)H=new Set,X.set(Q,H);H.add(q)}for(let[Y,q]of X)X.set(Y,new Set(e0(q)));return X},Z=[$.monitor.addEventListener("dragover",(X,Y)=>{if(this.disabled)return;let{dragOperation:q}=Y,{source:Q,target:H}=q;if(!i(Q)||!i(H))return;if(Q.sortable===H.sortable)return;let G=J(),z=Q.sortable.group===H.sortable.group,M=G.get(Q.sortable.group),U=z?M:G.get(H.sortable.group);if(!M||!U)return;queueMicrotask(()=>{if(X.defaultPrevented)return;Y.renderer.rendering.then(()=>{var W,F,B;let T=J();for(let[f,g]of G.entries()){let m=Array.from(g).entries();for(let[C,E]of m)if(E.index!==C||E.group!==f||!((W=T.get(f))==null?void 0:W.has(E)))return}let P=Q.sortable.element,R=H.sortable.element;if(!R||!P)return;if(!z&&H.id===Q.sortable.group)return;let S=e0(M),w=z?S:e0(U),L=(F=Q.sortable.group)!=null?F:T5,V=(B=H.sortable.group)!=null?B:T5,N={[L]:S,[V]:w},k=k4(N,X);if(N===k)return;let O=k[V].indexOf(Q.sortable),D=k[V].indexOf(H.sortable);Y.collisionObserver.disable(),O5(P,O,R,D),v(()=>{for(let[f,g]of k[L].entries())g.index=f;if(!z)for(let[f,g]of k[V].entries())g.group=H.sortable.group,g.index=f}),Y.actions.setDropTarget(Q.id).then(()=>Y.collisionObserver.enable())})})}),$.monitor.addEventListener("dragend",(X,Y)=>{if(!X.canceled)return;let{dragOperation:q}=Y,{source:Q}=q;if(!i(Q))return;if(Q.sortable.initialIndex===Q.sortable.index&&Q.sortable.initialGroup===Q.sortable.group)return;queueMicrotask(()=>{let H=J(),G=H.get(Q.sortable.initialGroup);if(!G)return;Y.renderer.rendering.then(()=>{for(let[F,B]of H.entries()){let T=Array.from(B).entries();for(let[P,R]of T)if(R.index!==P||R.group!==F)return}let z=e0(G),M=Q.sortable.element,U=z[Q.sortable.initialIndex],W=U==null?void 0:U.element;if(!U||!W||!M)return;O5(M,U.index,W,Q.index),v(()=>{for(let[F,B]of H.entries()){let T=Array.from(B).values();for(let P of T)P.index=P.initialIndex,P.group=P.initialGroup}})})})})];this.destroy=()=>{for(let X of Z)X()}}};function O5($,J,Z,X){let Y=X<J?"afterend":"beforebegin";Z.insertAdjacentElement(Y,$)}function P4($,J){return $.index-J.index}function e0($){return Array.from($).sort(P4)}var S5=[G4,C4],_2={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1},$2=new I5,s5,r5,e,v2,f0,x0,h2,M0;r5=[S2],s5=[S2];var y0=class{constructor($,J){E0(this,v2,a0(e,8,this)),a0(e,11,this),E0(this,f0),E0(this,x0),E0(this,h2,a0(e,12,this)),a0(e,15,this),E0(this,M0),this.register=()=>{return v(()=>{var W,F;(W=this.manager)==null||W.registry.register(this.droppable),(F=this.manager)==null||F.registry.register(this.draggable)}),()=>this.unregister()},this.unregister=()=>{v(()=>{var W,F;(W=this.manager)==null||W.registry.unregister(this.droppable),(F=this.manager)==null||F.registry.unregister(this.draggable)})},this.destroy=()=>{v(()=>{this.droppable.destroy(),this.draggable.destroy()})};var Z=$,{effects:X=()=>[],group:Y,index:q,sensors:Q,type:H,transition:G=_2,plugins:z}=Z,M=N4(Z,["effects","group","index","sensors","type","transition","plugins"]);let U=I2(z,S5);this.droppable=new g2(M,J,this),this.draggable=new a5(k5(R5({},M),{plugins:U,effects:()=>[()=>{var W,F,B;let T=(W=this.manager)==null?void 0:W.dragOperation.status;if((T==null?void 0:T.initializing)&&this.id===((B=(F=this.manager)==null?void 0:F.dragOperation.source)==null?void 0:B.id))$2.clear(this.manager);if(T==null?void 0:T.dragging)$2.set(this.manager,this.id,O2(()=>({initialIndex:this.index,initialGroup:this.group})))},()=>{let{index:W,group:F,manager:B}=this,T=D0(this,x0),P=D0(this,f0);if(W!==T||F!==P)K0(this,x0,W),K0(this,f0,F),this.animate()},()=>{var W,F;let{target:B}=this,{isDragSource:T}=this.draggable;if(((F=(W=this.draggable.pluginConfig(m5))==null?void 0:W.feedback)!=null?F:"default")==="move"&&T)this.droppable.disabled=!B},...X()],type:H,sensors:Q}),J,this),K0(this,M0,M.element),this.manager=J,this.index=q,K0(this,x0,q),this.group=Y,K0(this,f0,Y),this.type=H,this.transition=G}get initialIndex(){var $,J;return(J=($=$2.get(this.manager,this.id))==null?void 0:$.initialIndex)!=null?J:this.index}get initialGroup(){var $,J;return(J=($=$2.get(this.manager,this.id))==null?void 0:$.initialGroup)!=null?J:this.group}animate(){O2(()=>{let{manager:$,transition:J}=this,{shape:Z}=this.droppable;if(!$)return;let{idle:X}=$.dragOperation.status;if(!Z||!J||X&&!J.idle)return;$.renderer.rendering.then(()=>{let{element:Y}=this;if(!Y)return;for(let M of Y.getAnimations())if("transitionProperty"in M&&(M.transitionProperty==="transform"||M.transitionProperty==="translate"||M.transitionProperty==="scale"))M.cancel();let q=this.refreshShape();if(!q)return;let Q={x:Z.boundingRectangle.left-q.boundingRectangle.left,y:Z.boundingRectangle.top-q.boundingRectangle.top},{translate:H}=y5(Y),G=D2(Y,H,!1),z=D2(Y,H);if(Q.x||Q.y){let M=x5(D5(Y))?k5(R5({},J),{duration:0}):J;v5({element:Y,keyframes:{translate:[`${G.x+Q.x}px ${G.y+Q.y}px ${G.z}`,`${z.x}px ${z.y}px ${z.z}`]},options:M}).then(()=>{if(!$.dragOperation.status.dragging)this.droppable.shape=void 0})}})})}get manager(){return this.draggable.manager}set manager($){v(()=>{this.draggable.manager=$,this.droppable.manager=$})}set element($){v(()=>{let J=D0(this,M0),Z=this.droppable.element,X=this.draggable.element;if(!Z||Z===J)this.droppable.element=$;if(!X||X===J)this.draggable.element=$;K0(this,M0,$)})}get element(){var $,J;let Z=D0(this,M0);if(!Z)return;return(J=($=j5.get(Z))!=null?$:Z)!=null?J:this.droppable.element}set target($){this.droppable.element=$}get target(){return this.droppable.element}set source($){this.draggable.element=$}get source(){return this.draggable.element}get disabled(){return this.draggable.disabled&&this.droppable.disabled}set plugins($){this.draggable.plugins=I2($,S5)}set disabled($){v(()=>{this.droppable.disabled=$,this.draggable.disabled=$})}set data($){v(()=>{this.droppable.data=$,this.draggable.data=$})}set handle($){this.draggable.handle=$}set id($){this.droppable.id=$,this.draggable.id=$}get id(){return this.droppable.id}set sensors($){this.draggable.sensors=$}set modifiers($){this.draggable.modifiers=$}set collisionPriority($){this.droppable.collisionPriority=$}set collisionDetector($){this.droppable.collisionDetector=$!=null?$:h5}set alignment($){this.draggable.alignment=$}get alignment(){return this.draggable.alignment}set type($){v(()=>{this.droppable.type=$,this.draggable.type=$})}get type(){return this.draggable.type}set accept($){this.droppable.accept=$}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get isDragging(){return this.draggable.isDragging}get isDropping(){return this.draggable.isDropping}get status(){return this.draggable.status}refreshShape(){return this.droppable.refreshShape()}accepts($){return this.droppable.accepts($)}};e=B4();v2=new WeakMap;f0=new WeakMap;x0=new WeakMap;h2=new WeakMap;M0=new WeakMap;n5(e,4,"index",r5,y0,v2);n5(e,4,"group",s5,y0,h2);z4(e,y0);var a5=class extends c5{constructor($,J,Z){super($,J);this.sortable=Z}get index(){return this.sortable.index}get initialIndex(){return this.sortable.initialIndex}get group(){return this.sortable.group}get initialGroup(){return this.sortable.initialGroup}},g2=class extends u5{constructor($,J,Z){super($,J);this.sortable=Z}get index(){return this.sortable.index}get group(){return this.sortable.group}};var{defineProperty:T4,defineProperties:O4,getOwnPropertyDescriptors:S4,getOwnPropertySymbols:t5}=Object,E4=Object.prototype.hasOwnProperty,I4=Object.prototype.propertyIsEnumerable,e5=($,J,Z)=>(J in $)?T4($,J,{enumerable:!0,configurable:!0,writable:!0,value:Z}):$[J]=Z,m2=($,J)=>{for(var Z in J||(J={}))if(E4.call(J,Z))e5($,Z,J[Z]);if(t5){for(var Z of t5(J))if(I4.call(J,Z))e5($,Z,J[Z])}return $},D4=($,J)=>O4($,S4(J));function Y1($){let{accept:J,collisionDetector:Z,collisionPriority:X,id:Y,data:q,element:Q,handle:H,index:G,group:z,disabled:M,modifiers:U,sensors:W,target:F,type:B,plugins:T}=$,P=m2(m2({},_2),$.transition),R=X1((w)=>{return new y0(D4(m2({},$),{transition:P,register:!1,handle:Z2(H),element:Z2(Q),target:Z2(F)}),w)}),S=J1(R,f4);return h(Y,()=>R.id=Y),$1(()=>{v(()=>{R.group=z,R.index=G})},[R,z,G]),h(B,()=>R.type=B),h(J,()=>R.accept=J,void 0,_0),h(q,()=>q&&(R.data=q)),h(G,()=>{var w;if(((w=R.manager)==null?void 0:w.dragOperation.status.idle)&&(P==null?void 0:P.idle))R.refreshShape()},Z1),X2(H,(w)=>R.handle=w),X2(Q,(w)=>R.element=w),X2(F,(w)=>R.target=w),h(M,()=>R.disabled=M===!0),h(W,()=>R.sensors=W),h(Z,()=>R.collisionDetector=Z),h(X,()=>R.collisionPriority=X),h(T,()=>R.plugins=T,void 0,_0),h(P,()=>R.transition=P,void 0,_0),h(U,()=>R.modifiers=U,void 0,_0),h($.alignment,()=>R.alignment=$.alignment),{sortable:S,get isDragging(){return S.isDragging},get isDropping(){return S.isDropping},get isDragSource(){return S.isDragSource},get isDropTarget(){return S.isDropTarget},handleRef:v0.useCallback((w)=>{R.handle=w!=null?w:void 0},[R]),ref:v0.useCallback((w)=>{var L,V;if(!w&&((L=R.element)==null?void 0:L.isConnected)&&!((V=R.manager)==null?void 0:V.dragOperation.status.idle))return;R.element=w!=null?w:void 0},[R]),sourceRef:v0.useCallback((w)=>{var L,V;if(!w&&((L=R.source)==null?void 0:L.isConnected)&&!((V=R.manager)==null?void 0:V.dragOperation.status.idle))return;R.source=w!=null?w:void 0},[R]),targetRef:v0.useCallback((w)=>{var L,V;if(!w&&((L=R.target)==null?void 0:L.isConnected)&&!((V=R.manager)==null?void 0:V.dragOperation.status.idle))return;R.target=w!=null?w:void 0},[R])}}function f4($,J,Z){if($==="isDragSource"&&!Z&&J)return!0;return!1}function x4($,J,Z){let X=$.slice();return X.splice(Z,0,X.splice(J,1)[0]),X}function Q1($,J,Z,X){if(Z===X)return $;let Y=x4(J,Z,X),q=new Set(J.map((H)=>H.id)),Q=0;return $.map((H)=>q.has(H.id)?Y[Q++]:H)}async function H$($){let J=[],Z=[],X=$.items;if(X)for(let Q=0;Q<X.length;Q++){let H=X[Q];if(H.kind==="file"){let G=H.webkitGetAsEntry?.();if(G)Z.push({entry:G,path:""})}}else return Array.from($.files);let Y=(Q)=>{return new Promise((H)=>{Q.readEntries((G)=>H(G),()=>H([]))})},q=(Q)=>{return new Promise((H,G)=>{Q.file((z)=>H(z),(z)=>G(z))})};while(Z.length>0){let Q=Z.shift();if(!Q)continue;let{entry:H,path:G}=Q;if(H.isFile)try{let z=await q(H),M=G?`${G}/${z.name}`:z.name;Object.defineProperty(z,"webkitRelativePath",{value:M,writable:!1,configurable:!0}),J.push(z)}catch(z){console.error("Error reading file entry:",z)}else if(H.isDirectory){let z=H.createReader(),M=[],U=await Y(z);while(U.length>0)M=M.concat(U),U=await Y(z);let W=G?`${G}/${H.name}`:H.name;for(let F of M)Z.push({entry:F,path:W})}}return J}var d=c(u(),1);var Y2=["red","orange","yellow","green","blue","purple","gray"],u2={red:{bg:"rgba(239, 68, 68, 0.15)",text:"#ef4444",hex:"#ef4444"},orange:{bg:"rgba(249, 115, 22, 0.15)",text:"#f97316",hex:"#f97316"},yellow:{bg:"rgba(234, 179, 8, 0.15)",text:"#ca8a04",hex:"#eab308"},green:{bg:"rgba(34, 197, 94, 0.15)",text:"#16a34a",hex:"#22c55e"},blue:{bg:"rgba(59, 130, 246, 0.15)",text:"#2563eb",hex:"#3b82f6"},purple:{bg:"rgba(168, 85, 247, 0.15)",text:"#9333ea",hex:"#a855f7"},gray:{bg:"rgba(128, 128, 128, 0.15)",text:"#4b5563",hex:"#808080"},system:{bg:"rgba(128, 128, 128, 0.1)",text:"#6b7280",hex:"#808080"}};function q0($){if(!$)return{backgroundColor:"rgba(128, 128, 128, 0.1)",color:"#6b7280"};let J=$.toLowerCase(),Z=u2[J];if(Z)return{backgroundColor:Z.bg,color:Z.text};if($.startsWith("#"))return{backgroundColor:`${$}33`,color:$};return{backgroundColor:"rgba(128, 128, 128, 0.1)",color:$}}function j4($=[]){let J=new Set($.map((X)=>X.color?.toLowerCase()).filter(Boolean)),Z=Y2.filter((X)=>!J.has(X.toLowerCase()));if(Z.length>0)return Z[Math.floor(Math.random()*Z.length)];return Y2[Math.floor(Math.random()*Y2.length)]}var y4={[_.text]:F1,[_.longText]:q1,[_.select]:z1,[_.selectMulti]:U1,[_.rating]:r0,[_.number]:W1,[_.toggle]:w1,[_.date]:N1,[_.user]:V1,[_.userMulti]:A1};function _4({field:$,index:J,onVisibilityChange:Z}){let{ref:X,handleRef:Y}=Y1({id:$.id,index:J}),q=$.config?.type?y4[$.config.type]:null;return A("div",{ref:X,className:"flex items-center justify-between p-2 rounded-md hover:bg-muted",children:[A("div",{className:"flex items-center gap-2",children:[K("div",{ref:Y,className:"cursor-grab",children:K(B1,{className:"h-4 w-4 text-muted-foreground"})}),q&&K(q,{className:"h-4 w-4 text-muted-foreground shrink-0"}),$.aiAutofill&&K(K1,{className:"h-4 w-4 text-muted-foreground shrink-0"}),K("span",{className:"text-sm truncate",children:$.config?.name})]}),K(g0,{checked:$.visible,onCheckedChange:(Q)=>Z($.id,Q)})]})}function T$({projectId:$,onManageFields:J,onSave:Z}){let{fields:X,updateFields:Y}=H5(),[q,Q]=d.useState(""),[H,G]=d.useState("list"),[z,M]=d.useState(""),[U,W]=d.useState(""),[F,B]=d.useState(!1),[T,P]=d.useState(""),[R,S]=d.useState([]),w=H1();d.useEffect(()=>{w.invalidateQueries({queryKey:["fields",$]})},[$,w]);let L=O0.api.projects[":projectId"].fields.order.$patch,{mutate:V}=b2({mutationFn:async(C)=>{if(!(await L(C)).ok)throw Error(I.failed_update_fields_order());return null}}),N=O0.api.projects[":projectId"].fields.$post,{mutate:k}=b2({mutationFn:async(C)=>{let E=await N(C);if(!E.ok)throw Error(I.failed_create_field());return await E.json()},onSuccess:(C)=>{let E={...C,visible:!0},x=[...X,E];Y(x),M(""),S([]),V({param:{projectId:$},json:x.map((j)=>({fieldId:j.id,visible:j.visible||!1}))}),Z?.()}}),O=d.useMemo(()=>X.filter((C)=>C.config?.name?.toLowerCase().includes(q.toLowerCase())),[X,q]),D=(C)=>{if(C.canceled)return;let{source:E}=C.operation;if(!i(E))return;let{initialIndex:x,index:j}=E;if(x===j)return;let d2=Q1(X,O,x,j);Y(d2),V({param:{projectId:$},json:d2.map((l2)=>({fieldId:l2.id,visible:l2.visible||!1}))})},f=(C,E)=>{let x=X.map((j)=>j.id===C?{...j,visible:E}:j);Y(x),V({param:{projectId:$},json:x.map((j)=>({fieldId:j.id,visible:j.visible||!1}))})},g=()=>{if(!z||!U)return;let C=U===_.select?{select:{options:R}}:U===_.selectMulti?{selectMulti:{options:R}}:{};k({param:{projectId:$},json:{config:{name:z,type:U,...C},label:z,aiAutofill:F,description:T}})},m=X.filter((C)=>C.visible).length;if(H==="create")return K("div",{className:"w-80 p-4",children:A("div",{className:"space-y-4",children:[A("div",{className:"space-y-2",children:[K(U0,{htmlFor:"field-name",children:I.field_name()}),K(h0,{id:"field-name",placeholder:I.new_field_placeholder(),value:z,onChange:(C)=>M(C.target.value),autoFocus:!0})]}),A("div",{className:"space-y-2",children:[K(U0,{children:I.field_type()}),A(L1,{children:[K(R1,{asChild:!0,children:A($0,{variant:"outline",className:"w-full justify-between font-normal",children:[U?K("span",{className:"capitalize",children:U.replace(/_/g," ")}):K("span",{className:"text-muted-foreground border-dashed",children:I.select_field_type()}),K(w0,{className:"ml-2 h-4 w-4 opacity-50"})]})}),K(k1,{className:"w-[--radix-dropdown-menu-trigger-width]",children:Object.values(_).map((C)=>K(C1,{onClick:()=>{W(C),S([])},className:"capitalize",children:C.replace(/_/g," ")},C))})]})]}),A("div",{className:"space-y-2",children:[K(U0,{htmlFor:"field-desc",children:I.description()}),K(h0,{id:"field-desc",placeholder:I.description_optional_placeholder(),value:T,onChange:(C)=>P(C.target.value)})]}),A("div",{className:"flex items-center space-x-2",children:[K(g0,{id:"ai-autofill",checked:F,onCheckedChange:B}),K(U0,{htmlFor:"ai-autofill",children:I.ai_autofill()})]}),(U===_.select||U===_.selectMulti)&&A("div",{className:"space-y-2",children:[A("div",{className:"flex items-center justify-between",children:[K(U0,{className:"text-sm font-medium",children:I.options()}),A($0,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>{let C={id:L5(),displayName:I.new_option(),color:j4(R)};S([...R,C])},children:[K(c2,{className:"h-4 w-4 mr-1"})," ",I.add_option()]})]}),K("div",{className:"space-y-2 max-h-40 overflow-y-auto pr-1",children:R.map((C,E)=>A("div",{className:"flex items-center gap-2",children:[K(h0,{value:C.displayName,onChange:(x)=>{let j=[...R];j[E]={...C,displayName:x.target.value},S(j)},placeholder:I.option_name_placeholder(),className:"h-8 flex-1"}),A(n,{children:[K(o,{asChild:!0,children:K("button",{type:"button",className:"w-6 h-6 rounded-full border shrink-0 cursor-pointer focus:outline-none hover:scale-105 transition-transform",style:{backgroundColor:u2[C.color||""]?.hex||C.color||"#808080"}})}),K(s,{className:"p-2 w-auto",align:"end",children:K("div",{className:"flex gap-1",children:Y2.map((x)=>K("button",{type:"button",className:"w-5 h-5 rounded-full border cursor-pointer hover:scale-110 transition-transform",style:{backgroundColor:u2[x]?.hex||x},onClick:()=>{let j=[...R];j[E]={...C,color:x},S(j)}},x))})})]}),K($0,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>{S(R.filter((x,j)=>j!==E))},children:K(F0,{className:"h-4 w-4"})})]},C.id))})]}),A("div",{className:"flex gap-2 pt-2",children:[K($0,{variant:"secondary",className:"flex-1",onClick:()=>{G("list"),M(""),W(""),B(!1),P(""),S([])},children:I.cancel()}),K($0,{className:"flex-1",onClick:g,disabled:!z||!U,children:I.save()})]})]})});return A("div",{className:"w-80 p-4",children:[K("div",{className:"flex items-center justify-between mb-4",children:A("h3",{className:"font-semibold",children:[I.fields()," ",K("span",{className:"text-muted-foreground text-sm font-normal",children:I.visible_count({count:m})})]})}),A("div",{className:"relative mb-4",children:[K(G1,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),K(h0,{placeholder:I.search_fields_placeholder(),value:q,onChange:(C)=>Q(C.target.value),className:"pl-8"})]}),K("div",{className:"max-h-60 overflow-y-auto pr-2",children:K(S1,{sensors:[O1.configure({activationConstraints:[new T1.Distance({value:8})]}),P1],onDragEnd:D,children:O.map((C,E)=>K(_4,{field:C,index:E,onVisibilityChange:f},C.id))})}),J&&A("div",{className:"mt-4 space-y-2",children:[A($0,{variant:"secondary",className:"w-full",onClick:J,children:[K(M1,{className:"h-4 w-4 mr-2"}),I.manage_fields()]}),A($0,{className:"w-full",onClick:()=>G("create"),children:[K(c2,{className:"h-4 w-4 mr-2"}),I.new_field()]})]})]})}var v4=({value:$,config:J,onSave:Z,readOnly:X})=>{let Y=J?.select,[q,Q]=E1.useState(!1),H=Y?.options?.find((W)=>W.id===$),G=()=>{if(!X)Q(!0)},z=(W)=>{Z(W),Q(!1)};return K("div",{className:"relative w-full",onClick:(W)=>W.stopPropagation(),children:A(n,{open:!X&&q,onOpenChange:(W)=>{if(X)return;Q(W)},children:[K(o,{asChild:!0,children:A("div",{onClick:G,className:`flex items-center justify-between w-full min-h-[28px] px-2 py-1 rounded border border-transparent transition-colors ${!X?"cursor-pointer hover:bg-accent hover:border-border group":""}`,children:[((W)=>{if(!W)return K("span",{className:"text-muted-foreground italic",children:"Select an option"});return K("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",style:q0(W.color),children:W.displayName})})(H),!X&&K(w0,{className:"w-4 h-4 text-muted-foreground opacity-0 group-hover:opacity-100"})]})}),A(s,{className:"p-1 w-[--radix-popover-trigger-width] min-w-[150px] max-h-60 overflow-auto bg-popover border border-border rounded-lg shadow-lg",align:"start",children:[A("div",{onClick:()=>z(""),className:"px-3 py-2 text-sm text-muted-foreground hover:bg-accent cursor-pointer flex items-center gap-2",children:[K(F0,{className:"w-3 h-3"})," Clear"]}),Y?.options?.map((W)=>K("div",{onClick:()=>z(W.id),className:"px-3 py-2 hover:bg-accent cursor-pointer flex items-center",children:K("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",style:q0(W.color),children:W.displayName})},W.id))]})]})})},I1=v4;var J0=c(u(),1);var h4=({value:$=[],config:J,onSave:Z,readOnly:X})=>{let Y=J?.selectMulti,q=J0.useRef(null),[Q,H]=J0.useState(!1),[G,z]=J0.useState(!1),[M,U]=J0.useState($.length),W=Y?.options?.filter((w)=>($||[]).includes(w.id))||[];J0.useLayoutEffect(()=>{if(Q||G){U(W.length);return}if(q.current){let w=q.current.offsetWidth,V=document.createElement("canvas").getContext("2d");if(V){V.font="12px ui-sans-serif, system-ui, sans-serif";let N=0,k=0,D=w-28;for(let f=0;f<W.length;f++){let m=V.measureText(W[f].displayName).width+16+4;if(N+m>D&&f<W.length-1)break;if(f===W.length-1){if(N+m<=w)k++;break}N+=m,k++}U(k)}}},[W,Q,G,$]);let F=(w)=>{let L=$||[],V;if(L.includes(w))V=L.filter((N)=>N!==w);else V=[...L,w];Z(V)},B=(w)=>{if(w.stopPropagation(),Q)return;let L=W.length-M;if(!G&&L>0)z(!0);else if(!X)H(!0)},T=(w)=>{if(w.stopPropagation(),!X)H(!0)},P=W.length-M;return K("div",{className:"relative w-full",onClick:(w)=>w.stopPropagation(),children:A(n,{open:!X&&(G&&!Q||Q),onOpenChange:(w)=>{if(X)return;if(!w)z(!1),H(!1)},children:[K(o,{asChild:!0,children:A("div",{ref:q,onClick:B,className:`w-full px-1 py-1 flex flex-wrap gap-1 rounded border border-transparent transition-all box-border h-[32px] overflow-hidden ${!X||P>0?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:[W.length===0&&K("span",{className:"text-muted-foreground text-sm italic px-1 pt-0.5",children:"Empty"}),W.slice(0,M).map((w)=>K("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border border-transparent whitespace-nowrap h-[22px]",style:q0(w.color),children:w.displayName},w.id)),P>0&&A("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground h-[22px]",children:["+",P]})]})}),K(s,{className:`p-1 bg-popover border rounded-lg shadow-xl max-h-60 overflow-auto ${G&&!Q?"w-[--radix-popover-trigger-width] min-w-[200px] flex flex-wrap gap-1 border-ring min-h-[32px] h-auto cursor-pointer":"w-64 border-border"}`,align:"start",onClick:G&&!Q?T:void 0,children:G&&!Q?A(Q2,{children:[W.length===0&&K("span",{className:"text-muted-foreground text-sm italic px-1 pt-0.5",children:"Empty"}),W.map((w)=>K("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border border-transparent whitespace-nowrap h-[22px]",style:q0(w.color),children:w.displayName},w.id))]}):Y?.options?.map((w)=>{let L=($||[]).includes(w.id);return A("div",{onClick:()=>F(w.id),className:"px-3 py-2 hover:bg-accent cursor-pointer flex items-center justify-between",children:[K("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium",style:q0(w.color),children:w.displayName}),L&&K(H2,{className:"w-4 h-4 text-primary"})]},w.id)})})]})})},D1=h4;var Z0=c(u(),1);var g4=({value:$,onSave:J,readOnly:Z})=>{let[X,Y]=Z0.useState(!1),[q,Q]=Z0.useState($||""),H=Z0.useRef(null);Z0.useEffect(()=>{Q($||"")},[$]),Z0.useEffect(()=>{if(X&&H.current)H.current.focus()},[X]);let G=()=>{if(!Z)Y(!0)},z=()=>{Y(!1),J(q)},M=(U)=>{if(U.key==="Enter")H.current?.blur()};if(X)return K("input",{ref:H,type:"text",value:q,onChange:(U)=>Q(U.target.value),onBlur:z,onKeyDown:M,className:"w-full px-2 py-1 border border-ring rounded bg-background text-sm outline-none shadow-sm"});return K("div",{onClick:G,className:`w-full min-h-[28px] px-2 py-1 text-sm text-foreground rounded truncate border border-transparent transition-colors ${!Z?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:$||K("span",{className:"text-muted-foreground italic",children:"Empty"})})},f1=g4;var m4=({value:$,onSave:J,readOnly:Z})=>{return K("div",{className:"flex items-center h-[28px] w-full",onClick:(Y)=>Y.stopPropagation(),children:K(g0,{checked:$,onCheckedChange:(Y)=>{if(!Z)J(Y)},disabled:Z,className:"cursor-pointer"})})},x1=m4;var q2=c(u(),1);var b4=({value:$,onSave:J,readOnly:Z})=>{let X=K2(),{members:Y,fetchMembers:q}=o0(),[Q,H]=q2.useState(!1);q2.useEffect(()=>{if(X)q(X)},[X,q]);let G=Y.find((B)=>B.id===$),z=()=>{if(!Z)H(!0)},M=(B)=>{J(B),H(!1)},U=(B)=>{if(Z)return;H(B)},W=(B)=>{return B.split(" ").map((T)=>T[0]).slice(0,2).join("").toUpperCase()};return K("div",{className:"relative w-full",onClick:(B)=>B.stopPropagation(),children:A(n,{open:!Z&&Q,onOpenChange:U,children:[K(o,{asChild:!0,children:A("div",{onClick:z,className:`flex items-center justify-between w-full h-[28px] px-2 rounded border border-transparent transition-colors ${!Z?"cursor-pointer hover:bg-accent hover:border-border group":""}`,children:[((B)=>{if(!B)return K("span",{className:"text-muted-foreground italic text-sm",children:"Select user"});return A("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-muted text-foreground border h-[22px]",children:[A(V0,{className:"w-4 h-4",children:[K(A0,{src:B.image,alt:B.name,className:"object-cover"}),K(L0,{className:"text-[8px] bg-rose-400 text-black font-semibold",children:W(B.name)})]}),K("span",{className:"truncate max-w-[120px]",children:B.name})]})})(G),!Z&&K(w0,{className:"w-4 h-4 text-muted-foreground opacity-0 group-hover:opacity-100"})]})}),A(s,{className:"p-1 w-[--radix-popover-trigger-width] min-w-[200px] max-h-60 overflow-auto bg-popover border border-border rounded-lg shadow-lg",align:"start",children:[A("div",{onClick:()=>M(""),className:"px-3 py-2 text-sm text-muted-foreground hover:bg-accent cursor-pointer flex items-center gap-2 rounded-sm",children:[K(F0,{className:"w-3 h-3"})," Clear"]}),Y.map((B)=>A("div",{onClick:()=>M(B.id),className:"px-3 py-2 hover:bg-accent cursor-pointer flex items-center gap-2 rounded-sm",children:[A(V0,{className:"w-5 h-5",children:[K(A0,{src:B.image,alt:B.name,className:"object-cover"}),K(L0,{className:"text-[10px] bg-rose-400 text-black font-semibold",children:W(B.name)})]}),K("span",{className:"text-sm font-medium text-foreground",children:B.name})]},B.id))]})]})})},j1=b4;var r=c(u(),1);var c4=({value:$=[],onSave:J,readOnly:Z})=>{let X=K2(),{members:Y,fetchMembers:q}=o0(),Q=r.useRef(null),[H,G]=r.useState(!1),[z,M]=r.useState(!1),[U,W]=r.useState($.length);r.useEffect(()=>{if(X)q(X)},[X,q]);let F=Y.filter((N)=>($||[]).includes(N.id)),B=(N)=>{return N.split(" ").map((k)=>k[0]).slice(0,2).join("").toUpperCase()};r.useLayoutEffect(()=>{if(H||z){W(F.length);return}if(Q.current){let N=Q.current.offsetWidth,O=document.createElement("canvas").getContext("2d");if(O){O.font="12px ui-sans-serif, system-ui, sans-serif";let D=0,f=0,m=N-28;for(let C=0;C<F.length;C++){let x=O.measureText(F[C].name).width+42;if(D+x>m&&C<F.length-1)break;if(C===F.length-1){if(D+x<=N)f++;break}D+=x,f++}W(f)}}},[F,H,z,$]);let T=(N)=>{let k=$||[],O;if(k.includes(N))O=k.filter((D)=>D!==N);else O=[...k,N];J(O)},P=(N)=>{if(N.stopPropagation(),H)return;let k=F.length-U;if(!z&&k>0)M(!0);else if(!Z)G(!0)},R=(N)=>{if(N.stopPropagation(),!Z)G(!0)},S=F.length-U,w=z&&!H||H,L=(N)=>{if(Z)return;if(!N)M(!1),G(!1)},V=(N)=>{return A("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium bg-muted text-foreground border whitespace-nowrap h-[22px]",children:[A(V0,{className:"w-4 h-4",children:[K(A0,{src:N.image,alt:N.name,className:"object-cover"}),K(L0,{className:"text-[8px] bg-rose-400 text-black font-semibold",children:B(N.name)})]}),K("span",{className:"truncate max-w-[100px]",children:N.name})]},N.id)};return K("div",{className:"relative w-full",onClick:(N)=>N.stopPropagation(),children:A(n,{open:!Z&&w,onOpenChange:L,children:[K(o,{asChild:!0,children:A("div",{ref:Q,onClick:P,className:`w-full px-1 py-1 flex flex-wrap gap-1 rounded border border-transparent transition-all box-border h-[32px] overflow-hidden ${!Z||S>0?"cursor-pointer hover:bg-accent hover:border-border":""}`,children:[F.length===0&&K("span",{className:"text-muted-foreground text-sm italic px-1 pt-0.5",children:"Empty"}),F.slice(0,U).map(V),S>0&&A("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium bg-muted text-muted-foreground h-[22px]",children:["+",S]})]})}),K(s,{className:`p-1 bg-popover border rounded-lg shadow-xl max-h-60 overflow-auto ${z&&!H?"w-[--radix-popover-trigger-width] min-w-[200px] flex flex-wrap gap-1 border-ring min-h-[32px] h-auto cursor-pointer":"w-64 border-border"}`,align:"start",onClick:z&&!H?R:void 0,children:z&&!H?A(Q2,{children:[F.length===0&&K("span",{className:"text-muted-foreground text-sm italic px-1 pt-0.5",children:"Empty"}),F.map(V)]}):Y.map((N)=>{let k=($||[]).includes(N.id);return A("div",{onClick:()=>T(N.id),className:"px-3 py-2 hover:bg-accent cursor-pointer flex items-center justify-between rounded-sm",children:[A("div",{className:"flex items-center gap-2",children:[A(V0,{className:"w-5 h-5",children:[K(A0,{src:N.image,alt:N.name,className:"object-cover"}),K(L0,{className:"text-[10px] bg-rose-400 text-black font-semibold",children:B(N.name)})]}),K("span",{className:"text-sm font-medium text-foreground",children:N.name})]}),k&&K(H2,{className:"w-4 h-4 text-primary"})]},N.id)})})]})})},y1=c4;var u4=($)=>{if(!$.config)return K("div",{children:"Unknown Field Type"});switch($.config.type){case"text":return K(f1,{...$,value:$.value,onSave:$.onSave});case"longText":return K(w5,{...$,value:$.value,onSave:$.onSave});case"select":return K(I1,{...$,value:$.value,onSave:$.onSave});case"selectMulti":return K(D1,{...$,value:$.value,onSave:$.onSave});case"rating":return K(A5,{...$,value:$.value,onSave:$.onSave});case"number":return K(F5,{...$,value:$.value,onSave:$.onSave});case"toggle":return K(x1,{...$,value:$.value,onSave:$.onSave});case"date":return K(U5,{...$,value:$.value,onSave:$.onSave});case"user":return K(j1,{...$,value:$.value,onSave:$.onSave});case"userMulti":return K(y1,{...$,value:$.value,onSave:$.onSave});default:return K("div",{children:"Unknown Field Type"})}},A6=u4;var k6=({progress:$,className:J})=>{let X=2*Math.PI*20,Y=X-Math.min(100,Math.max(0,$))/100*X;return A("svg",{viewBox:"0 0 50 50",className:R0("w-12 h-12",J),children:[K("circle",{cx:"25",cy:"25",r:20,className:"stroke-muted",strokeWidth:"4",fill:"transparent"}),K("circle",{cx:"25",cy:"25",r:20,className:"stroke-primary transition-all duration-300 ease-out",strokeWidth:"4",fill:"transparent",strokeDasharray:X,strokeDashoffset:Y,transform:"rotate(-90 25 25)"}),K("text",{x:"50%",y:"50%",textAnchor:"middle",dy:".3em",className:"fill-foreground text-[10px] font-bold",children:`${Math.round($)}%`})]})};var d4=($)=>{if(isNaN($))return"00:00";let J=new Date($*1000),Z=J.getUTCHours(),X=J.getUTCMinutes().toString().padStart(2,"0"),Y=J.getUTCSeconds().toString().padStart(2,"0");if(Z)return`${Z}:${X}:${Y}`;return`${X}:${Y}`},T6=($,J,Z,X)=>{if(Z==="frames")return`${$} fr`;if(Z==="standard")return d4($/J);let Y=Math.round(J),q=J!==Y,Q=!1;if(q&&(Y===30||Y===60))Q=!0;let H=0;if(X){let B=X.match(/^([012]\d):(\d\d):(\d\d)(:|;|\.)(\d+)$/);if(B){let T=parseInt(B[1],10),P=parseInt(B[2],10),R=parseInt(B[3],10),S=parseInt(B[5],10);if(Q=B[4]!==":",H=(T*3600+P*60+R)*Y+S,Q){let w=T*60+P,L=J<30?2:4;H-=L*(w-Math.floor(w/10))}}}let G=$+H;if(Q){let B=J<30?2:4,T=Math.floor(G/(17982*B/2)),P=G%(17982*B/2);if(P<B)P=P+B;G+=9*B*T+B*Math.floor((P-B)/(1798*B/2))}let z=G%Y,M=Math.floor(G/Y)%60,U=Math.floor(G/(Y*60))%60,W=Math.floor(G/(Y*3600))%24,F=Q?";":":";return`${W.toString().padStart(2,"0")}:${U.toString().padStart(2,"0")}:${M.toString().padStart(2,"0")}${F}${z.toString().padStart(2,"0")}`};var O6=($,J)=>{if(!J)return 0;let Z=1/J;return $*Z+Z/2},l4=($)=>Math.max(100,3000/($||30)),S6=({dbTotalFrames:$,containerDuration:J,frameRate:Z})=>{let X=Z||30,Y=Math.round(J*X);if($<=0)return Y;let q=$/X,Q=J-q,H=l4(X)/1000;return Q>H?Y:$};var _1=c(u(),1);function f6({className:$,defaultValue:J,value:Z,min:X=0,max:Y=100,...q}){let Q=_1.useMemo(()=>Array.isArray(Z)?Z:Array.isArray(J)?J:[X,Y],[Z,J,X,Y]);return A(m0.Root,{"data-slot":"slider",defaultValue:J,value:Z,min:X,max:Y,className:R0("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",$),...q,children:[K(m0.Track,{"data-slot":"slider-track",className:R0("relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:K(m0.Range,{"data-slot":"slider-range",className:R0("absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:Q.length},(H,G)=>K(m0.Thumb,{"data-slot":"slider-thumb",className:"block size-4 shrink-0 rounded-full border border-primary bg-white shadow-sm ring-ring/50 transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},G))]})}
|
|
2
|
+
export{A2 as p,K5 as q,N5 as r,k2 as s,C2 as t,Q1 as u,H$ as v,H5 as w,L5 as x,k6 as y,A5 as z,i as A,Y1 as B,Y2 as C,u2 as D,q0 as E,j4 as F,y4 as G,T$ as H,o0 as I,A6 as J,d4 as K,T6 as L,O6 as M,l4 as N,S6 as O,f6 as P};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$d as sW,Ad as ek,Bd as kW,Dd as GW,Fd as _,Gd as kk,Hd as h,Id as dk,Jd as j,Ld as J,Pd as I,Qd as zk,Rd as x,Sd as hk,Td as Kk,Ud as pW,Vd as y,Wd as dW,Xd as v,Yd as fk,Zd as Xk,_d as w,ae as TW,be as Mk,de as YW,ee as Ch,xd as c,yd as V,zd as _k}from"./chunk-f8cn9m28.js";function z(k){return kk(k)&&_(k.toOperationNode)}var Q=h({is(k){return k.kind==="ValueNode"},create(k){return h({kind:"ValueNode",value:k})},createImmediate(k){return h({kind:"ValueNode",value:k,immediate:!0})}});var S=h({is(k){return k.kind==="ColumnNode"},create(k){return h({kind:"ColumnNode",column:J.create(k)})}});var pk=h({is(k){return k.kind==="SelectAllNode"},create(){return h({kind:"SelectAllNode"})}});var Ak=h({is(k){return k.kind==="ReferenceNode"},create(k,W){return h({kind:"ReferenceNode",table:W,column:k})},createSelectAll(k){return h({kind:"ReferenceNode",table:k,column:pk.create()})}});function ok(k){return kk(k)&&"expressionType"in k&&z(k)}function iW(k){return kk(k)&&"expression"in k&&V(k.alias)&&z(k)}var a=h({is(k){return k.kind==="SelectModifierNode"},create(k,W){return h({kind:"SelectModifierNode",modifier:k,of:W})},createWithExpression(k){return h({kind:"SelectModifierNode",rawModifier:k})}});var Yk=h({is(k){return k.kind==="BinaryOperationNode"},create(k,W,$){return h({kind:"BinaryOperationNode",leftOperand:k,operator:W,rightOperand:$})}});var sk=h({is(k){return k.kind==="PrimitiveValueListNode"},create(k){return h({kind:"PrimitiveValueListNode",values:h([...k])})}});var rk=h({is(k){return k.kind==="ValueListNode"},create(k){return h({kind:"ValueListNode",values:h(k)})}});function lW(k){if(j(k))return ih(k);return X(k)}function X(k){if(Wk(k))return p(k);return Q.create(k)}function WW(k){return _k(k)||ek(k)||kW(k)}function Bk(k){if(!WW(k))throw Error(`unsafe immediate value ${JSON.stringify(k)}`);return Q.createImmediate(k)}function ih(k){if(k.some(Wk))return rk.create(k.map((W)=>X(W)));return sk.create(k)}function L(k){if(k.length===3)return hW(k[0],k[1],k[2]);else if(k.length===1)return X(k[0]);throw Error(`invalid arguments: ${JSON.stringify(k)}`)}function hW(k,W,$){if(lh(W)&&oW($))return Yk.create(f(k),PW(W),Q.createImmediate($));return Yk.create(f(k),PW(W),lW($))}function m(k,W,$){return Yk.create(f(k),PW(W),f($))}function UW(k,W){return mk(Object.entries(k).filter(([,$])=>!c($)).map(([$,M])=>hW($,oW(M)?"is":"=",M)),W)}function mk(k,W,$=!0){let M=W==="and"?x.create:hk.create;if(k.length===0)return Yk.create(Q.createImmediate(1),y.create("="),Q.createImmediate(W==="and"?1:0));let G=aW(k[0]);for(let q=1;q<k.length;++q)G=M(G,aW(k[q]));if(k.length>1&&$)return Xk.create(G);return G}function lh(k){return k==="is"||k==="is not"}function oW(k){return kW(k)||ek(k)}function PW(k){if(V(k)&&pW.includes(k))return y.create(k);if(z(k))return k.toOperationNode();throw Error(`invalid operator ${JSON.stringify(k)}`)}function aW(k){return z(k)?k.toOperationNode():k}var $k=h({is(k){return k.kind==="OrderByNode"},create(k){return h({kind:"OrderByNode",items:h([...k])})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var VW=h({is(k){return k.kind==="PartitionByNode"},create(k){return h({kind:"PartitionByNode",items:h(k)})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var xk=h({is(k){return k.kind==="OverNode"},create(){return h({kind:"OverNode"})},cloneWithOrderByItems(k,W){return h({...k,orderBy:k.orderBy?$k.cloneWithItems(k.orderBy,W):$k.create(W)})},cloneWithPartitionByItems(k,W){return h({...k,partitionBy:k.partitionBy?VW.cloneWithItems(k.partitionBy,W):VW.create(W)})}});var Vk=h({is(k){return k.kind==="FromNode"},create(k){return h({kind:"FromNode",froms:h(k)})},cloneWithFroms(k,W){return h({...k,froms:h([...k.froms,...W])})}});var wW=h({is(k){return k.kind==="GroupByNode"},create(k){return h({kind:"GroupByNode",items:h(k)})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var FW=h({is(k){return k.kind==="HavingNode"},create(k){return h({kind:"HavingNode",having:k})},cloneWithOperation(k,W,$){return h({...k,having:W==="And"?x.create(k.having,$):hk.create(k.having,$)})}});var o=h({is(k){return k.kind==="UpdateQueryNode"},create(k,W){return h({kind:"UpdateQueryNode",table:k.length===1?k[0]:sW.create(k),...W&&{with:W}})},createWithoutTable(){return h({kind:"UpdateQueryNode"})},cloneWithFromItems(k,W){return h({...k,from:k.from?Vk.cloneWithFroms(k.from,W):Vk.create(W)})},cloneWithUpdates(k,W){return h({...k,updates:k.updates?h([...k.updates,...W]):W})},cloneWithLimit(k,W){return h({...k,limit:W})}});var Dk=h({is(k){return k.kind==="DeleteQueryNode"},create(k,W){return h({kind:"DeleteQueryNode",from:Vk.create(k),...W&&{with:W}})},cloneWithOrderByItems:(k,W)=>K.cloneWithOrderByItems(k,W),cloneWithoutOrderBy:(k)=>K.cloneWithoutOrderBy(k),cloneWithLimit(k,W){return h({...k,limit:W})},cloneWithoutLimit(k){return h({...k,limit:void 0})},cloneWithUsing(k,W){return h({...k,using:k.using!==void 0?TW.cloneWithTables(k.using,W):TW.create(W)})}});var C=h({is(k){return k.kind==="WhereNode"},create(k){return h({kind:"WhereNode",where:k})},cloneWithOperation(k,W,$){return h({...k,where:W==="And"?x.create(k.where,$):hk.create(k.where,$)})}});var vW=h({is(k){return k.kind==="ReturningNode"},create(k){return h({kind:"ReturningNode",selections:h(k)})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})}});var rW=h({is(k){return k.kind==="ExplainNode"},create(k,W){return h({kind:"ExplainNode",format:k,options:W})}});var N=h({is(k){return k.kind==="MergeQueryNode"},create(k,W){return h({kind:"MergeQueryNode",into:k,...W&&{with:W}})},cloneWithUsing(k,W){return h({...k,using:W})},cloneWithWhen(k,W){return h({...k,whens:k.whens?h([...k.whens,W]):h([W])})},cloneWithThen(k,W){return h({...k,whens:k.whens?h([...k.whens.slice(0,-1),Mk.cloneWithResult(k.whens[k.whens.length-1],W)]):void 0})}});var AW=h({is(k){return k.kind==="OutputNode"},create(k){return h({kind:"OutputNode",selections:h(k)})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})}});var K=h({is(k){return Y.is(k)||w.is(k)||o.is(k)||Dk.is(k)||N.is(k)},cloneWithEndModifier(k,W){return h({...k,endModifiers:k.endModifiers?h([...k.endModifiers,W]):h([W])})},cloneWithWhere(k,W){return h({...k,where:k.where?C.cloneWithOperation(k.where,"And",W):C.create(W)})},cloneWithJoin(k,W){return h({...k,joins:k.joins?h([...k.joins,W]):h([W])})},cloneWithReturning(k,W){return h({...k,returning:k.returning?vW.cloneWithSelections(k.returning,W):vW.create(W)})},cloneWithoutReturning(k){return h({...k,returning:void 0})},cloneWithoutWhere(k){return h({...k,where:void 0})},cloneWithExplain(k,W,$){return h({...k,explain:rW.create(W,$?.toOperationNode())})},cloneWithTop(k,W){return h({...k,top:W})},cloneWithOutput(k,W){return h({...k,output:k.output?AW.cloneWithSelections(k.output,W):AW.create(W)})},cloneWithOrderByItems(k,W){return h({...k,orderBy:k.orderBy?$k.cloneWithItems(k.orderBy,W):$k.create(W)})},cloneWithoutOrderBy(k){return h({...k,orderBy:void 0})}});var Y=h({is(k){return k.kind==="SelectQueryNode"},create(k){return h({kind:"SelectQueryNode",...k&&{with:k}})},createFrom(k,W){return h({kind:"SelectQueryNode",from:Vk.create(k),...W&&{with:W}})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})},cloneWithDistinctOn(k,W){return h({...k,distinctOn:k.distinctOn?h([...k.distinctOn,...W]):h(W)})},cloneWithFrontModifier(k,W){return h({...k,frontModifiers:k.frontModifiers?h([...k.frontModifiers,W]):h([W])})},cloneWithOrderByItems:(k,W)=>K.cloneWithOrderByItems(k,W),cloneWithGroupByItems(k,W){return h({...k,groupBy:k.groupBy?wW.cloneWithItems(k.groupBy,W):wW.create(W)})},cloneWithLimit(k,W){return h({...k,limit:W})},cloneWithOffset(k,W){return h({...k,offset:W})},cloneWithFetch(k,W){return h({...k,fetch:W})},cloneWithHaving(k,W){return h({...k,having:k.having?FW.cloneWithOperation(k.having,"And",W):FW.create(W)})},cloneWithSetOperations(k,W){return h({...k,setOperations:k.setOperations?h([...k.setOperations,...W]):h([...W])})},cloneWithoutSelections(k){return h({...k,selections:[]})},cloneWithoutLimit(k){return h({...k,limit:void 0})},cloneWithoutOffset(k){return h({...k,offset:void 0})},cloneWithoutOrderBy:(k)=>K.cloneWithoutOrderBy(k),cloneWithoutGroupBy(k){return h({...k,groupBy:void 0})}});class Rk{#k;constructor(k){this.#k=h(k)}on(...k){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,L(k))})}onRef(k,W,$){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,m(k,W,$))})}onTrue(){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,v.createWithSql("true"))})}$call(k){return k(this)}toOperationNode(){return this.#k.joinNode}}class ah{#k;get dynamicReference(){return this.#k}get refType(){return}constructor(k){this.#k=k}toOperationNode(){return _W(this.#k)}}function $W(k){return kk(k)&&z(k)&&V(k.dynamicReference)}var g=h({is(k){return k.kind==="OrderByItemNode"},create(k,W){return h({kind:"OrderByItemNode",orderBy:k,direction:W})},cloneWith(k,W){return h({...k,...W})}});var eW=h({is(k){return k.kind==="CollateNode"},create(k){return h({kind:"CollateNode",collation:J.create(k)})}});class Lk{#k;constructor(k){this.#k=h(k)}desc(){return new Lk({node:g.cloneWith(this.#k.node,{direction:v.createWithSql("desc")})})}asc(){return new Lk({node:g.cloneWith(this.#k.node,{direction:v.createWithSql("asc")})})}nullsLast(){return new Lk({node:g.cloneWith(this.#k.node,{nulls:"last"})})}nullsFirst(){return new Lk({node:g.cloneWith(this.#k.node,{nulls:"first"})})}collate(k){return new Lk({node:g.cloneWith(this.#k.node,{collation:eW.create(k)})})}toOperationNode(){return this.#k.node}}function RW(k){return k==="asc"||k==="desc"}function B(k){if(k.length===2)return[mW(k[0],k[1])];if(k.length===1){let[W]=k;if(Array.isArray(W))return fk("orderBy(array) is deprecated, use multiple orderBy calls instead."),W.map(($)=>mW($));return[mW(W)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${k.length}`)}function mW(k,W){let $=ph(k);if(g.is($)){if(W)throw Error("Cannot specify direction twice!");return $}return kh($,W)}function ph(k){if(Wk(k))return p(k);if($W(k))return k.toOperationNode();let[W,$]=k.split(" ");if($)return fk("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),kh(t(W),$);return t(k)}function kh(k,W){if(typeof W==="string"){if(!RW(W))throw Error(`Invalid order by direction: ${W}`);return g.create(k,v.createWithSql(W))}if(ok(W))return fk("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),g.create(k,W.toOperationNode());let $=g.create(k);if(!W)return $;return W(new Lk({node:$})).toOperationNode()}var Wh=h({is(k){return k.kind==="PartitionByItemNode"},create(k){return h({kind:"PartitionByItemNode",partitionBy:k})}});function hh(k){return Gk(k).map(Wh.create)}class Ck{#k;constructor(k){this.#k=h(k)}orderBy(...k){return new Ck({overNode:xk.cloneWithOrderByItems(this.#k.overNode,B(k))})}clearOrderBy(){return new Ck({overNode:K.cloneWithoutOrderBy(this.#k.overNode)})}partitionBy(k){return new Ck({overNode:xk.cloneWithPartitionByItems(this.#k.overNode,hh(k))})}$call(k){return k(this)}toOperationNode(){return this.#k.overNode}}var Sk=h({is(k){return k.kind==="SelectionNode"},create(k){return h({kind:"SelectionNode",selection:k})},createSelectAll(){return h({kind:"SelectionNode",selection:pk.create()})},createSelectAllFromTable(k){return h({kind:"SelectionNode",selection:Ak.createSelectAll(k)})}});class oh{#k;get table(){return this.#k}constructor(k){this.#k=k}as(k){return new $h(this.#k,k)}}class $h{#k;#W;get table(){return this.#k}get alias(){return this.#W}constructor(k,W){this.#k=k,this.#W=W}toOperationNode(){return I.create(F(this.#k),J.create(this.#W))}}function Mh(k){return kk(k)&&z(k)&&V(k.table)&&V(k.alias)}function n(k){if(j(k))return k.map((W)=>wk(W));else return[wk(k)]}function wk(k){if(V(k))return fW(k);else if(Mh(k))return k.toOperationNode();else return MW(k)}function fW(k){if(k.includes(" as ")){let[$,M]=k.split(" as ").map(Kh);return I.create(F($),J.create(M))}else return F(k)}function F(k){if(k.includes(".")){let[$,M]=k.split(".").map(Kh);return zk.createWithSchema($,M)}else return zk.create(k)}function Kh(k){return k.trim()}function A(k){if(_(k))return A(k(d()));else if(j(k))return k.map((W)=>Gh(W));else return[Gh(k)]}function Gh(k){if(V(k))return Sk.create(Zh(k));else if($W(k))return Sk.create(k.toOperationNode());else return Sk.create(MW(k))}function R(k){if(!k)return[Sk.createSelectAll()];else if(Array.isArray(k))return k.map(Hh);else return[Hh(k)]}function Hh(k){if(V(k))return Sk.createSelectAllFromTable(F(k));throw Error(`invalid value selectAll expression: ${JSON.stringify(k)}`)}var Yh=h({is(k){return k.kind==="ValuesNode"},create(k){return h({kind:"ValuesNode",values:h(k)})}});var Xh=h({is(k){return k.kind==="DefaultInsertValueNode"},create(){return h({kind:"DefaultInsertValueNode"})}});function KW(k){let W=_(k)?k(d()):k,$=j(W)?W:h([W]);return sh($)}function sh(k){let W=rh(k);return[h([...W.keys()].map(S.create)),Yh.create(k.map(($)=>eh($,W)))]}function rh(k){let W=new Map;for(let $ of k){let M=Object.keys($);for(let G of M)if(!W.has(G)&&$[G]!==void 0)W.set(G,W.size)}return W}function eh(k,W){let $=Object.keys(k),M=Array.from({length:W.size}),G=!1,q=$.length;for(let ak of $){let Nk=W.get(ak);if(c(Nk)){q--;continue}let qW=k[ak];if(c(qW)||Wk(qW))G=!0;M[Nk]=qW}if(q<W.size||G){let ak=Xh.create();return rk.create(M.map((Nk)=>c(Nk)?ak:X(Nk)))}return sk.create(M)}var CW=h({is(k){return k.kind==="ColumnUpdateNode"},create(k,W){return h({kind:"ColumnUpdateNode",column:k,value:W})}});function Dh(...k){if(k.length===2)return[CW.create(f(k[0]),X(k[1]))];return ck(k[0])}function ck(k){let W=_(k)?k(d()):k;return Object.entries(W).filter(([$,M])=>M!==void 0).map(([$,M])=>{return CW.create(S.create($),X(M))})}var Lh=h({is(k){return k.kind==="OnDuplicateKeyNode"},create(k){return h({kind:"OnDuplicateKeyNode",updates:k})}});class SW{insertId;numInsertedOrUpdatedRows;constructor(k,W){this.insertId=k,this.numInsertedOrUpdatedRows=W}}class u extends Error{node;constructor(k){super("no result");this.node=k}}function s(k){return Object.prototype.hasOwnProperty.call(k,"prototype")}var E=h({is(k){return k.kind==="OnConflictNode"},create(){return h({kind:"OnConflictNode"})},cloneWith(k,W){return h({...k,...W})},cloneWithIndexWhere(k,W){return h({...k,indexWhere:k.indexWhere?C.cloneWithOperation(k.indexWhere,"And",W):C.create(W)})},cloneWithIndexOrWhere(k,W){return h({...k,indexWhere:k.indexWhere?C.cloneWithOperation(k.indexWhere,"Or",W):C.create(W)})},cloneWithUpdateWhere(k,W){return h({...k,updateWhere:k.updateWhere?C.cloneWithOperation(k.updateWhere,"And",W):C.create(W)})},cloneWithUpdateOrWhere(k,W){return h({...k,updateWhere:k.updateWhere?C.cloneWithOperation(k.updateWhere,"Or",W):C.create(W)})},cloneWithoutIndexWhere(k){return h({...k,indexWhere:void 0})},cloneWithoutUpdateWhere(k){return h({...k,updateWhere:void 0})}});class r{#k;constructor(k){this.#k=h(k)}column(k){let W=S.create(k);return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{columns:this.#k.onConflictNode.columns?h([...this.#k.onConflictNode.columns,W]):h([W])})})}columns(k){let W=k.map(S.create);return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{columns:this.#k.onConflictNode.columns?h([...this.#k.onConflictNode.columns,...W]):h(W)})})}constraint(k){return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{constraint:J.create(k)})})}expression(k){return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{indexExpression:k.toOperationNode()})})}where(...k){return new r({...this.#k,onConflictNode:E.cloneWithIndexWhere(this.#k.onConflictNode,L(k))})}whereRef(k,W,$){return new r({...this.#k,onConflictNode:E.cloneWithIndexWhere(this.#k.onConflictNode,m(k,W,$))})}clearWhere(){return new r({...this.#k,onConflictNode:E.cloneWithoutIndexWhere(this.#k.onConflictNode)})}doNothing(){return new zh({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{doNothing:!0})})}doUpdateSet(k){return new yk({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{updates:ck(k)})})}$call(k){return k(this)}}class zh{#k;constructor(k){this.#k=h(k)}toOperationNode(){return this.#k.onConflictNode}}class yk{#k;constructor(k){this.#k=h(k)}where(...k){return new yk({...this.#k,onConflictNode:E.cloneWithUpdateWhere(this.#k.onConflictNode,L(k))})}whereRef(k,W,$){return new yk({...this.#k,onConflictNode:E.cloneWithUpdateWhere(this.#k.onConflictNode,m(k,W,$))})}clearWhere(){return new yk({...this.#k,onConflictNode:E.cloneWithoutUpdateWhere(this.#k.onConflictNode)})}$call(k){return k(this)}toOperationNode(){return this.#k.onConflictNode}}var Jh=h({is(k){return k.kind==="TopNode"},create(k,W){return h({kind:"TopNode",expression:k,modifiers:W})}});function i(k,W){if(!_k(k)&&!GW(k))throw Error(`Invalid top expression: ${k}`);if(!c(W)&&!k$(W))throw Error(`Invalid top modifiers: ${W}`);return Jh.create(k,W)}function k$(k){return k==="percent"||k==="with ties"||k==="percent with ties"}var Fk=h({is(k){return k.kind==="OrActionNode"},create(k){return h({kind:"OrActionNode",action:k})}});class D{#k;constructor(k){this.#k=h(k)}values(k){let[W,$]=KW(k);return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{columns:W,values:$})})}columns(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{columns:h(k.map(S.create))})})}expression(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{values:p(k)})})}defaultValues(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{defaultValues:!0})})}modifyEnd(k){return new D({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}ignore(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("ignore")})})}orIgnore(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("ignore")})})}orAbort(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("abort")})})}orFail(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("fail")})})}orReplace(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("replace")})})}orRollback(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("rollback")})})}top(k,W){return new D({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}onConflict(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{onConflict:k(new r({onConflictNode:E.create()})).toOperationNode()})})}onDuplicateKeyUpdate(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{onDuplicateKey:Lh.create(ck(k))})})}returning(k){return new D({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(){return new D({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R())})}output(k){return new D({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new D({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}clearReturning(){return new D({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new D({...this.#k})}$castTo(){return new D(this.#k)}$narrowType(){return new D(this.#k)}$assertType(){return new D(this.#k)}withPlugin(k){return new D({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new SW(W.insertId,W.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new D({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}class IW{numDeletedRows;constructor(k){this.numDeletedRows=k}}var Ik=h({is(k){return k.kind==="LimitNode"},create(k){return h({kind:"LimitNode",limit:k})}});var P;class HW{#k;constructor(k){this.#k=h(k)}where(...k){return new P({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new P({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}clearWhere(){return new P({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}top(k,W){return new P({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}using(k){return new P({...this.#k,queryNode:Dk.cloneWithUsing(this.#k.queryNode,n(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}#W(k,W){return new P({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}returning(k){return new P({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new P({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new P({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new P({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}clearReturning(){return new P({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}clearLimit(){return new P({...this.#k,queryNode:Dk.cloneWithoutLimit(this.#k.queryNode)})}orderBy(...k){return new P({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}clearOrderBy(){return new P({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}limit(k){return new P({...this.#k,queryNode:Dk.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}modifyEnd(k){return new P({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new P({...this.#k})}$castTo(){return new P(this.#k)}$narrowType(){return new P(this.#k)}$assertType(){return new P(this.#k)}withPlugin(k){return new P({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new IW(W.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new P({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}P=HW;class jW{numUpdatedRows;numChangedRows;constructor(k,W){this.numUpdatedRows=k,this.numChangedRows=W}}var U;class jk{#k;constructor(k){this.#k=h(k)}where(...k){return new U({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new U({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}clearWhere(){return new U({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}top(k,W){return new U({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}from(k){return new U({...this.#k,queryNode:o.cloneWithFromItems(this.#k.queryNode,n(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}#W(k,W){return new U({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}orderBy(...k){return new U({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}clearOrderBy(){return new U({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}limit(k){return new U({...this.#k,queryNode:o.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}set(...k){return new U({...this.#k,queryNode:o.cloneWithUpdates(this.#k.queryNode,Dh(...k))})}returning(k){return new U({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new U({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new U({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new U({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}modifyEnd(k){return new U({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}clearReturning(){return new U({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new U({...this.#k})}$castTo(){return new U(this.#k)}$narrowType(){return new U(this.#k)}$assertType(){return new U(this.#k)}withPlugin(k){return new U({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new jW(W.numAffectedRows??BigInt(0),W.numChangedRows)]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new U({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}U=jk;var EW=h({is(k){return k.kind==="CommonTableExpressionNameNode"},create(k,W){return h({kind:"CommonTableExpressionNameNode",table:zk.create(k),columns:W?h(W.map(S.create)):void 0})}});var Ek=h({is(k){return k.kind==="CommonTableExpressionNode"},create(k,W){return h({kind:"CommonTableExpressionNode",name:k,expression:W})},cloneWith(k,W){return h({...k,...W})}});class gk{#k;constructor(k){this.#k=h(k)}materialized(){return new gk({...this.#k,node:Ek.cloneWith(this.#k.node,{materialized:!0})})}notMaterialized(){return new gk({...this.#k,node:Ek.cloneWith(this.#k.node,{materialized:!1})})}toOperationNode(){return this.#k.node}}function OW(k,W){let $=W(Ph()).toOperationNode();if(_(k))return k(W$($)).toOperationNode();return Ek.create(qh(k),$)}function W$(k){return(W)=>{return new gk({node:Ek.create(qh(W),k)})}}function qh(k){if(k.includes("(")){let W=k.split(/[\(\)]/),$=W[0],M=W[1].split(",").map((G)=>G.trim());return EW.create($,M)}else return EW.create(k)}var tk=h({is(k){return k.kind==="WithNode"},create(k,W){return h({kind:"WithNode",expressions:h([k]),...W})},cloneWithExpression(k,W){return h({...k,expressions:h([...k.expressions,W])})}});var Uh=["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 Vh(k){let W="";for(let $=0;$<k;++$)W+=h$();return W}function h$(){return Uh[~~(Math.random()*Uh.length)]}function T(){return new wh}class wh{#k;get queryId(){if(this.#k===void 0)this.#k=Vh(8);return this.#k}}var Fh=h({is(k){return k.kind==="MatchedNode"},create(k,W=!1){return h({kind:"MatchedNode",not:k,bySource:W})}});function bW(k,W,$){return Mk.create(mk([Fh.create(!k.isMatched,k.bySource),...W&&W.length>0?[W.length===3&&$?m(W[0],W[1],W[2]):L(W)]:[]],"and",!1))}function Ok(k){if(V(k))return v.create([k],[]);if(z(k))return k.toOperationNode();return k}class ZW{#k;#W;#h;constructor(){this.#k=new Promise((k,W)=>{this.#h=W,this.#W=k})}get promise(){return this.#k}resolve=(k)=>{if(this.#W)this.#W(k)};reject=(k)=>{if(this.#h)this.#h(k)}}async function Th(k){let W=new ZW,$=new ZW;return k.provideConnection(async(M)=>{return W.resolve(M),await $.promise}).catch((M)=>W.reject(M)),h({connection:await W.promise,release:$.resolve})}var $$=h([]);class QW{#k;constructor(k=$$){this.#k=k}get plugins(){return this.#k}transformQuery(k,W){for(let $ of this.#k){let M=$.transformQuery({node:k,queryId:W});if(M.kind===k.kind)k=M;else throw Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${k.kind}`,`but it returned a ${M.kind}`].join(" "))}return k}async executeQuery(k){return await this.provideConnection(async(W)=>{let $=await W.executeQuery(k);if("numUpdatedOrDeletedRows"in $)fk("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`.");return await this.#W($,k.queryId)})}async*stream(k,W){let{connection:$,release:M}=await Th(this);try{for await(let G of $.streamQuery(k,W))yield await this.#W(G,k.queryId)}finally{M()}}async#W(k,W){for(let $ of this.#k)k=await $.transformResult({result:k,queryId:W});return k}}class bk extends QW{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(k){return new bk([...this.plugins,k])}withPlugins(k){return new bk([...this.plugins,...k])}withPluginAtFront(k){return new bk([k,...this.plugins])}withoutPlugins(){return new bk([])}}var qk=new bk;class NW{numChangedRows;constructor(k){this.numChangedRows=k}}class Hk{#k;constructor(k){this.#k=h(k)}modifyEnd(k){return new Hk({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}top(k,W){return new Hk({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}using(...k){return new O({...this.#k,queryNode:N.cloneWithUsing(this.#k.queryNode,Jk("Using",k))})}returning(k){return new Hk({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new Hk({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new Hk({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new Hk({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}}class O{#k;constructor(k){this.#k=h(k)}modifyEnd(k){return new O({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}top(k,W){return new O({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}whenMatched(){return this.#W([])}whenMatchedAnd(...k){return this.#W(k)}whenMatchedAndRef(k,W,$){return this.#W([k,W,$],!0)}#W(k,W){return new BW({...this.#k,queryNode:N.cloneWithWhen(this.#k.queryNode,bW({isMatched:!0},k,W))})}whenNotMatched(){return this.#h([])}whenNotMatchedAnd(...k){return this.#h(k)}whenNotMatchedAndRef(k,W,$){return this.#h([k,W,$],!0)}whenNotMatchedBySource(){return this.#h([],!1,!0)}whenNotMatchedBySourceAnd(...k){return this.#h(k,!1,!0)}whenNotMatchedBySourceAndRef(k,W,$){return this.#h([k,W,$],!0,!0)}returning(k){return new O({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new O({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new O({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new O({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}#h(k,W=!1,$=!1){let M={...this.#k,queryNode:N.cloneWithWhen(this.#k.queryNode,bW({isMatched:!1,bySource:$},k,W))};return new($?BW:vh)(M)}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new O({...this.#k})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new NW(W.numAffectedRows)]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}}class BW{#k;constructor(k){this.#k=h(k)}thenDelete(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("delete"))})}thenDoNothing(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("do nothing"))})}thenUpdate(k){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok(k(new jk({queryId:this.#k.queryId,executor:qk,queryNode:o.createWithoutTable()}))))})}thenUpdateSet(...k){return this.thenUpdate((W)=>W.set(...k))}}class vh{#k;constructor(k){this.#k=h(k)}thenDoNothing(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("do nothing"))})}thenInsertValues(k){let[W,$]=KW(k);return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok(w.cloneWith(w.createWithoutInto(),{columns:W,values:$})))})}}class Pk{#k;constructor(k){this.#k=h(k)}selectFrom(k){return nk({queryId:T(),executor:this.#k.executor,queryNode:Y.createFrom(n(k),this.#k.withNode)})}selectNoFrom(k){return nk({queryId:T(),executor:this.#k.executor,queryNode:Y.cloneWithSelections(Y.create(this.#k.withNode),A(k))})}insertInto(k){return new D({queryId:T(),executor:this.#k.executor,queryNode:w.create(F(k),this.#k.withNode)})}replaceInto(k){return new D({queryId:T(),executor:this.#k.executor,queryNode:w.create(F(k),this.#k.withNode,!0)})}deleteFrom(k){return new HW({queryId:T(),executor:this.#k.executor,queryNode:Dk.create(n(k),this.#k.withNode)})}updateTable(k){return new jk({queryId:T(),executor:this.#k.executor,queryNode:o.create(n(k),this.#k.withNode)})}mergeInto(k){return new Hk({queryId:T(),executor:this.#k.executor,queryNode:N.create(fW(k),this.#k.withNode)})}with(k,W){let $=OW(k,W);return new Pk({...this.#k,withNode:this.#k.withNode?tk.cloneWithExpression(this.#k.withNode,$):tk.create($)})}withRecursive(k,W){let $=OW(k,W);return new Pk({...this.#k,withNode:this.#k.withNode?tk.cloneWithExpression(this.#k.withNode,$):tk.create($,{recursive:!0})})}withPlugin(k){return new Pk({...this.#k,executor:this.#k.executor.withPlugin(k)})}withoutPlugins(){return new Pk({...this.#k,executor:this.#k.executor.withoutPlugins()})}withSchema(k){return new Pk({...this.#k,executor:this.#k.executor.withPluginAtFront(new YW(k))})}}function Ph(){return new Pk({executor:qk})}function Ah(k,W){return new Rk({joinNode:Kk.create(k,wk(W))})}function _h(){return new Ck({overNode:xk.create()})}function Jk(k,W){if(W.length===3)return K$(k,W[0],W[1],W[2]);else if(W.length===2)return M$(k,W[0],W[1]);else if(W.length===1)return G$(k,W[0]);else throw Error("not implemented")}function M$(k,W,$){return $(Ah(k,W)).toOperationNode()}function K$(k,W,$,M){return Kk.createWithOn(k,wk(W),m($,"=",M))}function G$(k,W){return Kk.create(k,wk(W))}var mh=h({is(k){return k.kind==="OffsetNode"},create(k){return h({kind:"OffsetNode",offset:k})}});var Rh=h({is(k){return k.kind==="GroupByItemNode"},create(k){return h({kind:"GroupByItemNode",groupBy:k})}});function fh(k){return k=_(k)?k(d()):k,Gk(k).map(Rh.create)}function Tk(k,W,$){if(_(W))W=W(XW());if(!j(W))W=[W];return W.map((M)=>Ch.create(k,p(M),$))}class Z{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}or(...k){return new DW(hk.create(this.#k,L(k)))}and(...k){return new LW(x.create(this.#k,L(k)))}$castTo(){return new Z(this.#k)}$notNull(){return new Z(this.#k)}toOperationNode(){return this.#k}}class zW{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}class DW{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}or(...k){return new DW(hk.create(this.#k,L(k)))}$castTo(){return new DW(this.#k)}toOperationNode(){return Xk.create(this.#k)}}class LW{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}and(...k){return new LW(x.create(this.#k,L(k)))}$castTo(){return new LW(this.#k)}toOperationNode(){return Xk.create(this.#k)}}var Sh=h({is(k){return k.kind==="FetchNode"},create(k,W){return{kind:"FetchNode",rowCount:Q.create(k),modifier:W}}});function Ih(k,W){if(!_k(k)&&!GW(k))throw Error(`Invalid fetch row count: ${k}`);if(!H$(W))throw Error(`Invalid fetch modifier: ${W}`);return Sh.create(k,W)}function H$(k){return k==="only"||k==="with ties"}var H;class xW{#k;constructor(k){this.#k=h(k)}get expressionType(){return}get isSelectQueryBuilder(){return!0}where(...k){return new H({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new H({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}having(...k){return new H({...this.#k,queryNode:Y.cloneWithHaving(this.#k.queryNode,L(k))})}havingRef(k,W,$){return new H({...this.#k,queryNode:Y.cloneWithHaving(this.#k.queryNode,m(k,W,$))})}select(k){return new H({...this.#k,queryNode:Y.cloneWithSelections(this.#k.queryNode,A(k))})}distinctOn(k){return new H({...this.#k,queryNode:Y.cloneWithDistinctOn(this.#k.queryNode,Gk(k))})}modifyFront(k){return new H({...this.#k,queryNode:Y.cloneWithFrontModifier(this.#k.queryNode,a.createWithExpression(k.toOperationNode()))})}modifyEnd(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.createWithExpression(k.toOperationNode()))})}distinct(){return new H({...this.#k,queryNode:Y.cloneWithFrontModifier(this.#k.queryNode,a.create("Distinct"))})}forUpdate(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForUpdate",k?dk(k).map(F):void 0))})}forShare(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForShare",k?dk(k).map(F):void 0))})}forKeyShare(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForKeyShare",k?dk(k).map(F):void 0))})}forNoKeyUpdate(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForNoKeyUpdate",k?dk(k).map(F):void 0))})}skipLocked(){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("SkipLocked"))})}noWait(){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("NoWait"))})}selectAll(k){return new H({...this.#k,queryNode:Y.cloneWithSelections(this.#k.queryNode,R(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}crossJoin(...k){return this.#W("CrossJoin",k)}innerJoinLateral(...k){return this.#W("LateralInnerJoin",k)}leftJoinLateral(...k){return this.#W("LateralLeftJoin",k)}crossJoinLateral(...k){return this.#W("LateralCrossJoin",k)}crossApply(...k){return this.#W("CrossApply",k)}outerApply(...k){return this.#W("OuterApply",k)}#W(k,W){return new H({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}orderBy(...k){return new H({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}groupBy(k){return new H({...this.#k,queryNode:Y.cloneWithGroupByItems(this.#k.queryNode,fh(k))})}limit(k){return new H({...this.#k,queryNode:Y.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}offset(k){return new H({...this.#k,queryNode:Y.cloneWithOffset(this.#k.queryNode,mh.create(X(k)))})}fetch(k,W="only"){return new H({...this.#k,queryNode:Y.cloneWithFetch(this.#k.queryNode,Ih(k,W))})}top(k,W){return new H({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}union(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("union",k,!1))})}unionAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("union",k,!0))})}intersect(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("intersect",k,!1))})}intersectAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("intersect",k,!0))})}except(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("except",k,!1))})}exceptAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("except",k,!0))})}as(k){return new jh(this,k)}clearSelect(){return new H({...this.#k,queryNode:Y.cloneWithoutSelections(this.#k.queryNode)})}clearWhere(){return new H({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}clearLimit(){return new H({...this.#k,queryNode:Y.cloneWithoutLimit(this.#k.queryNode)})}clearOffset(){return new H({...this.#k,queryNode:Y.cloneWithoutOffset(this.#k.queryNode)})}clearOrderBy(){return new H({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}clearGroupBy(){return new H({...this.#k,queryNode:Y.cloneWithoutGroupBy(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new H({...this.#k})}$castTo(){return new H(this.#k)}$narrowType(){return new H(this.#k)}$assertType(){return new H(this.#k)}$asTuple(){return new Z(this.toOperationNode())}$asScalar(){return new Z(this.toOperationNode())}withPlugin(k){return new H({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile();return(await this.#k.executor.executeQuery(k)).rows}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new H({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}H=xW;function nk(k){return new xW(k)}class jh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return I.create(this.#k.toOperationNode(),J.create(this.#W))}}var e=h({is(k){return k.kind==="AggregateFunctionNode"},create(k,W=[]){return h({kind:"AggregateFunctionNode",func:k,aggregated:W})},cloneWithDistinct(k){return h({...k,distinct:!0})},cloneWithOrderBy(k,W,$=!1){let M=$?"withinGroup":"orderBy";return h({...k,[M]:k[M]?$k.cloneWithItems(k[M],W):$k.create(W)})},cloneWithFilter(k,W){return h({...k,filter:k.filter?C.cloneWithOperation(k.filter,"And",W):C.create(W)})},cloneWithOrFilter(k,W){return h({...k,filter:k.filter?C.cloneWithOperation(k.filter,"Or",W):C.create(W)})},cloneWithOver(k,W){return h({...k,over:W})}});var cW=h({is(k){return k.kind==="FunctionNode"},create(k,W){return h({kind:"FunctionNode",func:k,arguments:W})}});class b{#k;constructor(k){this.#k=h(k)}get expressionType(){return}as(k){return new Eh(this,k)}distinct(){return new b({...this.#k,aggregateFunctionNode:e.cloneWithDistinct(this.#k.aggregateFunctionNode)})}orderBy(...k){return new b({...this.#k,aggregateFunctionNode:K.cloneWithOrderByItems(this.#k.aggregateFunctionNode,B(k))})}clearOrderBy(){return new b({...this.#k,aggregateFunctionNode:K.cloneWithoutOrderBy(this.#k.aggregateFunctionNode)})}withinGroupOrderBy(...k){return new b({...this.#k,aggregateFunctionNode:e.cloneWithOrderBy(this.#k.aggregateFunctionNode,B(k),!0)})}filterWhere(...k){return new b({...this.#k,aggregateFunctionNode:e.cloneWithFilter(this.#k.aggregateFunctionNode,L(k))})}filterWhereRef(k,W,$){return new b({...this.#k,aggregateFunctionNode:e.cloneWithFilter(this.#k.aggregateFunctionNode,m(k,W,$))})}over(k){let W=_h();return new b({...this.#k,aggregateFunctionNode:e.cloneWithOver(this.#k.aggregateFunctionNode,(k?k(W):W).toOperationNode())})}$call(k){return k(this)}$castTo(){return new b(this.#k)}$notNull(){return new b(this.#k)}toOperationNode(){return this.#k.aggregateFunctionNode}}class Eh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),J.create(this.#W))}}function Oh(){let k=($,M)=>{return new Z(cW.create($,Gk(M??[])))},W=($,M)=>{return new b({aggregateFunctionNode:e.create($,M?Gk(M):void 0)})};return Object.assign(k,{agg:W,avg($){return W("avg",[$])},coalesce(...$){return k("coalesce",$)},count($){return W("count",[$])},countAll($){return new b({aggregateFunctionNode:e.create("count",R($))})},max($){return W("max",[$])},min($){return W("min",[$])},sum($){return W("sum",[$])},any($){return k("any",[$])},jsonAgg($){return new b({aggregateFunctionNode:e.create("json_agg",[V($)?F($):$.toOperationNode()])})},toJson($){return new Z(cW.create("to_json",[V($)?F($):$.toOperationNode()]))}})}var bh=h({is(k){return k.kind==="UnaryOperationNode"},create(k,W){return h({kind:"UnaryOperationNode",operator:k,operand:W})}});function Qh(k,W){return bh.create(y.create(k),f(W))}var l=h({is(k){return k.kind==="CaseNode"},create(k){return h({kind:"CaseNode",value:k})},cloneWithWhen(k,W){return h({...k,when:h(k.when?[...k.when,W]:[W])})},cloneWithThen(k,W){return h({...k,when:k.when?h([...k.when.slice(0,-1),Mk.cloneWithResult(k.when[k.when.length-1],W)]):void 0})},cloneWith(k,W){return h({...k,...W})}});class yW{#k;constructor(k){this.#k=h(k)}when(...k){return new gW({...this.#k,node:l.cloneWithWhen(this.#k.node,Mk.create(L(k)))})}}class gW{#k;constructor(k){this.#k=h(k)}then(k){return new Nh({...this.#k,node:l.cloneWithThen(this.#k.node,WW(k)?Bk(k):X(k))})}}class Nh{#k;constructor(k){this.#k=h(k)}when(...k){return new gW({...this.#k,node:l.cloneWithWhen(this.#k.node,Mk.create(L(k)))})}else(k){return new Bh({...this.#k,node:l.cloneWith(this.#k.node,{else:WW(k)?Bk(k):X(k)})})}end(){return new Z(l.cloneWith(this.#k.node,{isStatement:!1}))}endCase(){return new Z(l.cloneWith(this.#k.node,{isStatement:!0}))}}class Bh{#k;constructor(k){this.#k=h(k)}end(){return new Z(l.cloneWith(this.#k.node,{isStatement:!1}))}endCase(){return new Z(l.cloneWith(this.#k.node,{isStatement:!0}))}}var JW=h({is(k){return k.kind==="JSONOperatorChainNode"},create(k){return h({kind:"JSONOperatorChainNode",operator:k,values:h([])})},cloneWithValue(k,W){return h({...k,values:h([...k.values,W])})}});var tW=h({is(k){return k.kind==="JSONPathLegNode"},create(k,W){return h({kind:"JSONPathLegNode",type:k,value:W})}});var Uk=h({is(k){return k.kind==="JSONPathNode"},create(k){return h({kind:"JSONPathNode",inOperator:k,pathLegs:h([])})},cloneWithLeg(k,W){return h({...k,pathLegs:h([...k.pathLegs,W])})}});var Qk=h({is(k){return k.kind==="JSONReferenceNode"},create(k,W){return h({kind:"JSONReferenceNode",reference:k,traversal:W})},cloneWithTraversal(k,W){return h({...k,traversal:W})}});var Z$=/^#-\d+$/;class ik{#k;constructor(k){this.#k=k}at(k){if(typeof k!=="number"&&typeof k!=="string"||typeof k==="number"&&!Number.isInteger(k)||typeof k==="string"&&k!=="last"&&!Z$.test(k))throw Error(`Unexpected index value in .at(...): ${k}`);return this.#W("ArrayLocation",k)}key(k){return this.#W("Member",k)}#W(k,W){if(Qk.is(this.#k))return new uk(Qk.cloneWithTraversal(this.#k,Uk.is(this.#k.traversal)?Uk.cloneWithLeg(this.#k.traversal,tW.create(k,W)):JW.cloneWithValue(this.#k.traversal,Q.createImmediate(W))));return new uk(Uk.cloneWithLeg(this.#k,tW.create(k,W)))}}class uk extends ik{#k;constructor(k){super(k);this.#k=k}get expressionType(){return}as(k){return new xh(this,k)}$castTo(){return new uk(this.#k)}$notNull(){return new uk(this.#k)}toOperationNode(){return this.#k}}class xh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}var nW=h({is(k){return k.kind==="TupleNode"},create(k){return h({kind:"TupleNode",values:h(k)})}});var Y$=["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"],X$=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],ch=h({is(k){return k.kind==="DataTypeNode"},create(k){return h({kind:"DataTypeNode",dataType:k})}});function yh(k){if(Y$.includes(k))return!0;if(X$.some((W)=>W.test(k)))return!0;return!1}function gh(k){if(z(k))return k.toOperationNode();if(yh(k))return ch.create(k);throw Error(`invalid column data type ${JSON.stringify(k)}`)}var th=h({is(k){return k.kind==="CastNode"},create(k,W){return h({kind:"CastNode",expression:k,dataType:W})}});function XW(k=qk){function W(G,q,vk){return new Z(hW(G,q,vk))}function $(G,q){return new Z(Qh(G,q))}let M=Object.assign(W,{fn:void 0,eb:void 0,selectFrom(G){return nk({queryId:T(),executor:k,queryNode:Y.createFrom(n(G))})},case(G){return new yW({node:l.create(c(G)?void 0:f(G))})},ref(G,q){if(c(q))return new Z(t(G));return new ik(nh(G,q))},jsonPath(){return new ik(Uk.create())},table(G){return new Z(F(G))},val(G){return new Z(X(G))},refTuple(...G){return new Z(nW.create(G.map(f)))},tuple(...G){return new Z(nW.create(G.map(X)))},lit(G){return new Z(Bk(G))},unary:$,not(G){return $("not",G)},exists(G){return $("exists",G)},neg(G){return $("-",G)},between(G,q,vk){return new Z(Yk.create(f(G),y.create("between"),x.create(X(q),X(vk))))},betweenSymmetric(G,q,vk){return new Z(Yk.create(f(G),y.create("between symmetric"),x.create(X(q),X(vk))))},and(G){if(j(G))return new Z(mk(G,"and"));return new Z(UW(G,"and"))},or(G){if(j(G))return new Z(mk(G,"or"));return new Z(UW(G,"or"))},parens(...G){let q=L(G);if(Xk.is(q))return new Z(q);else return new Z(Xk.create(q))},cast(G,q){return new Z(th.create(f(G),gh(q)))},withSchema(G){return XW(k.withPluginAtFront(new YW(G)))}});return M.fn=Oh(),M.eb=M,M}function d(k){return XW()}function p(k){if(z(k))return k.toOperationNode();else if(_(k))return k(d()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(k)}`)}function MW(k){if(z(k))return k.toOperationNode();else if(_(k))return k(d()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(k)}`)}function Wk(k){return ok(k)||iW(k)||_(k)}function _W(k){if(V(k))return t(k);return k.toOperationNode()}function Gk(k){if(j(k))return k.map((W)=>f(W));else return[f(k)]}function f(k){if(Wk(k))return p(k);return _W(k)}function nh(k,W){let $=t(k);if(dW(W))return Qk.create($,JW.create(y.create(W)));let M=W.slice(0,-1);if(dW(M))return Qk.create($,Uk.create(y.create(M)));throw Error(`Invalid JSON operator: ${W}`)}function t(k){if(!k.includes("."))return Ak.create(S.create(k));let $=k.split(".").map(uW);if($.length===3)return L$($);if($.length===2)return z$($);throw Error(`invalid column reference ${k}`)}function Zh(k){if(k.includes(" as ")){let[$,M]=k.split(" as ").map(uW);return I.create(t($),J.create(M))}else return t(k)}function D$(k){return S.create(k)}function R3(k){if(k.includes(" ")){let[$,M]=k.split(" ").map(uW);if(!RW(M))throw Error(`invalid order direction "${M}" next to "${$}"`);return B([$,M])[0]}else return D$(k)}function L$(k){let[W,$,M]=k;return Ak.create(S.create(M),zk.createWithSchema(W,$))}function z$(k){let[W,$]=k;return Ak.create(S.create($),zk.create(W))}function uW(k){return k.trim()}class lk{#k;constructor(k){this.#k=h(k)}get expressionType(){return}get isRawBuilder(){return!0}as(k){return new dh(this,k)}$castTo(){return new lk({...this.#k})}$notNull(){return new lk(this.#k)}withPlugin(k){return new lk({...this.#k,plugins:this.#k.plugins!==void 0?h([...this.#k.plugins,k]):h([k])})}toOperationNode(){return this.#h(this.#W())}compile(k){return this.#$(this.#W(k))}async execute(k){let W=this.#W(k);return W.executeQuery(this.#$(W))}#W(k){let W=k!==void 0?k.getExecutor():qk;return this.#k.plugins!==void 0?W.withPlugins(this.#k.plugins):W}#h(k){return k.transformQuery(this.#k.rawNode,this.#k.queryId)}#$(k){return k.compileQuery(this.#h(k),this.#k.queryId)}}function Zk(k){return new lk(k)}class dh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}get rawBuilder(){return this.#k}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}var J$=Object.assign((k,...W)=>{return Zk({queryId:T(),rawNode:v.create(k,W?.map(uh)??[])})},{ref(k){return Zk({queryId:T(),rawNode:v.createWithChild(t(k))})},val(k){return Zk({queryId:T(),rawNode:v.createWithChild(X(k))})},value(k){return this.val(k)},table(k){return Zk({queryId:T(),rawNode:v.createWithChild(F(k))})},id(...k){let W=Array(k.length+1).fill(".");return W[0]="",W[W.length-1]="",Zk({queryId:T(),rawNode:v.create(W,k.map(J.create))})},lit(k){return Zk({queryId:T(),rawNode:v.createWithChild(Q.createImmediate(k))})},literal(k){return this.lit(k)},raw(k){return Zk({queryId:T(),rawNode:v.createWithSql(k)})},join(k,W=J$`, `){let $=Array(Math.max(2*k.length-1,0)),M=W.toOperationNode();for(let G=0;G<k.length;++G)if($[2*G]=uh(k[G]),G!==k.length-1)$[2*G+1]=M;return Zk({queryId:T(),rawNode:v.createWithChildren($)})}});function uh(k){if(z(k))return k.toOperationNode();return X(k)}var l3=h({raw(k,W=[]){return h({sql:k,query:v.createWithSql(k),parameters:h(W),queryId:T()})}});
|
|
3
|
-
export{z as
|
|
2
|
+
import{$c as dW,Cc as c,Dc as V,Ec as _k,Fc as ek,Gc as kW,Ic as GW,Kc as _,Lc as kk,Mc as h,Nc as dk,Oc as j,Qc as J,Uc as I,Vc as zk,Wc as x,Xc as hk,Yc as Kk,Zc as pW,_c as y,ad as v,bd as fk,cd as Xk,dd as w,ed as sW,fd as TW,gd as Mk,id as YW,jd as Ch}from"./chunk-zned6mj8.js";function z(k){return kk(k)&&_(k.toOperationNode)}var Q=h({is(k){return k.kind==="ValueNode"},create(k){return h({kind:"ValueNode",value:k})},createImmediate(k){return h({kind:"ValueNode",value:k,immediate:!0})}});var S=h({is(k){return k.kind==="ColumnNode"},create(k){return h({kind:"ColumnNode",column:J.create(k)})}});var pk=h({is(k){return k.kind==="SelectAllNode"},create(){return h({kind:"SelectAllNode"})}});var Ak=h({is(k){return k.kind==="ReferenceNode"},create(k,W){return h({kind:"ReferenceNode",table:W,column:k})},createSelectAll(k){return h({kind:"ReferenceNode",table:k,column:pk.create()})}});function ok(k){return kk(k)&&"expressionType"in k&&z(k)}function iW(k){return kk(k)&&"expression"in k&&V(k.alias)&&z(k)}var a=h({is(k){return k.kind==="SelectModifierNode"},create(k,W){return h({kind:"SelectModifierNode",modifier:k,of:W})},createWithExpression(k){return h({kind:"SelectModifierNode",rawModifier:k})}});var Yk=h({is(k){return k.kind==="BinaryOperationNode"},create(k,W,$){return h({kind:"BinaryOperationNode",leftOperand:k,operator:W,rightOperand:$})}});var sk=h({is(k){return k.kind==="PrimitiveValueListNode"},create(k){return h({kind:"PrimitiveValueListNode",values:h([...k])})}});var rk=h({is(k){return k.kind==="ValueListNode"},create(k){return h({kind:"ValueListNode",values:h(k)})}});function lW(k){if(j(k))return ih(k);return X(k)}function X(k){if(Wk(k))return p(k);return Q.create(k)}function WW(k){return _k(k)||ek(k)||kW(k)}function Bk(k){if(!WW(k))throw Error(`unsafe immediate value ${JSON.stringify(k)}`);return Q.createImmediate(k)}function ih(k){if(k.some(Wk))return rk.create(k.map((W)=>X(W)));return sk.create(k)}function L(k){if(k.length===3)return hW(k[0],k[1],k[2]);else if(k.length===1)return X(k[0]);throw Error(`invalid arguments: ${JSON.stringify(k)}`)}function hW(k,W,$){if(lh(W)&&oW($))return Yk.create(f(k),PW(W),Q.createImmediate($));return Yk.create(f(k),PW(W),lW($))}function m(k,W,$){return Yk.create(f(k),PW(W),f($))}function UW(k,W){return mk(Object.entries(k).filter(([,$])=>!c($)).map(([$,M])=>hW($,oW(M)?"is":"=",M)),W)}function mk(k,W,$=!0){let M=W==="and"?x.create:hk.create;if(k.length===0)return Yk.create(Q.createImmediate(1),y.create("="),Q.createImmediate(W==="and"?1:0));let G=aW(k[0]);for(let q=1;q<k.length;++q)G=M(G,aW(k[q]));if(k.length>1&&$)return Xk.create(G);return G}function lh(k){return k==="is"||k==="is not"}function oW(k){return kW(k)||ek(k)}function PW(k){if(V(k)&&pW.includes(k))return y.create(k);if(z(k))return k.toOperationNode();throw Error(`invalid operator ${JSON.stringify(k)}`)}function aW(k){return z(k)?k.toOperationNode():k}var $k=h({is(k){return k.kind==="OrderByNode"},create(k){return h({kind:"OrderByNode",items:h([...k])})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var VW=h({is(k){return k.kind==="PartitionByNode"},create(k){return h({kind:"PartitionByNode",items:h(k)})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var xk=h({is(k){return k.kind==="OverNode"},create(){return h({kind:"OverNode"})},cloneWithOrderByItems(k,W){return h({...k,orderBy:k.orderBy?$k.cloneWithItems(k.orderBy,W):$k.create(W)})},cloneWithPartitionByItems(k,W){return h({...k,partitionBy:k.partitionBy?VW.cloneWithItems(k.partitionBy,W):VW.create(W)})}});var Vk=h({is(k){return k.kind==="FromNode"},create(k){return h({kind:"FromNode",froms:h(k)})},cloneWithFroms(k,W){return h({...k,froms:h([...k.froms,...W])})}});var wW=h({is(k){return k.kind==="GroupByNode"},create(k){return h({kind:"GroupByNode",items:h(k)})},cloneWithItems(k,W){return h({...k,items:h([...k.items,...W])})}});var FW=h({is(k){return k.kind==="HavingNode"},create(k){return h({kind:"HavingNode",having:k})},cloneWithOperation(k,W,$){return h({...k,having:W==="And"?x.create(k.having,$):hk.create(k.having,$)})}});var o=h({is(k){return k.kind==="UpdateQueryNode"},create(k,W){return h({kind:"UpdateQueryNode",table:k.length===1?k[0]:sW.create(k),...W&&{with:W}})},createWithoutTable(){return h({kind:"UpdateQueryNode"})},cloneWithFromItems(k,W){return h({...k,from:k.from?Vk.cloneWithFroms(k.from,W):Vk.create(W)})},cloneWithUpdates(k,W){return h({...k,updates:k.updates?h([...k.updates,...W]):W})},cloneWithLimit(k,W){return h({...k,limit:W})}});var Dk=h({is(k){return k.kind==="DeleteQueryNode"},create(k,W){return h({kind:"DeleteQueryNode",from:Vk.create(k),...W&&{with:W}})},cloneWithOrderByItems:(k,W)=>K.cloneWithOrderByItems(k,W),cloneWithoutOrderBy:(k)=>K.cloneWithoutOrderBy(k),cloneWithLimit(k,W){return h({...k,limit:W})},cloneWithoutLimit(k){return h({...k,limit:void 0})},cloneWithUsing(k,W){return h({...k,using:k.using!==void 0?TW.cloneWithTables(k.using,W):TW.create(W)})}});var C=h({is(k){return k.kind==="WhereNode"},create(k){return h({kind:"WhereNode",where:k})},cloneWithOperation(k,W,$){return h({...k,where:W==="And"?x.create(k.where,$):hk.create(k.where,$)})}});var vW=h({is(k){return k.kind==="ReturningNode"},create(k){return h({kind:"ReturningNode",selections:h(k)})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})}});var rW=h({is(k){return k.kind==="ExplainNode"},create(k,W){return h({kind:"ExplainNode",format:k,options:W})}});var N=h({is(k){return k.kind==="MergeQueryNode"},create(k,W){return h({kind:"MergeQueryNode",into:k,...W&&{with:W}})},cloneWithUsing(k,W){return h({...k,using:W})},cloneWithWhen(k,W){return h({...k,whens:k.whens?h([...k.whens,W]):h([W])})},cloneWithThen(k,W){return h({...k,whens:k.whens?h([...k.whens.slice(0,-1),Mk.cloneWithResult(k.whens[k.whens.length-1],W)]):void 0})}});var AW=h({is(k){return k.kind==="OutputNode"},create(k){return h({kind:"OutputNode",selections:h(k)})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})}});var K=h({is(k){return Y.is(k)||w.is(k)||o.is(k)||Dk.is(k)||N.is(k)},cloneWithEndModifier(k,W){return h({...k,endModifiers:k.endModifiers?h([...k.endModifiers,W]):h([W])})},cloneWithWhere(k,W){return h({...k,where:k.where?C.cloneWithOperation(k.where,"And",W):C.create(W)})},cloneWithJoin(k,W){return h({...k,joins:k.joins?h([...k.joins,W]):h([W])})},cloneWithReturning(k,W){return h({...k,returning:k.returning?vW.cloneWithSelections(k.returning,W):vW.create(W)})},cloneWithoutReturning(k){return h({...k,returning:void 0})},cloneWithoutWhere(k){return h({...k,where:void 0})},cloneWithExplain(k,W,$){return h({...k,explain:rW.create(W,$?.toOperationNode())})},cloneWithTop(k,W){return h({...k,top:W})},cloneWithOutput(k,W){return h({...k,output:k.output?AW.cloneWithSelections(k.output,W):AW.create(W)})},cloneWithOrderByItems(k,W){return h({...k,orderBy:k.orderBy?$k.cloneWithItems(k.orderBy,W):$k.create(W)})},cloneWithoutOrderBy(k){return h({...k,orderBy:void 0})}});var Y=h({is(k){return k.kind==="SelectQueryNode"},create(k){return h({kind:"SelectQueryNode",...k&&{with:k}})},createFrom(k,W){return h({kind:"SelectQueryNode",from:Vk.create(k),...W&&{with:W}})},cloneWithSelections(k,W){return h({...k,selections:k.selections?h([...k.selections,...W]):h(W)})},cloneWithDistinctOn(k,W){return h({...k,distinctOn:k.distinctOn?h([...k.distinctOn,...W]):h(W)})},cloneWithFrontModifier(k,W){return h({...k,frontModifiers:k.frontModifiers?h([...k.frontModifiers,W]):h([W])})},cloneWithOrderByItems:(k,W)=>K.cloneWithOrderByItems(k,W),cloneWithGroupByItems(k,W){return h({...k,groupBy:k.groupBy?wW.cloneWithItems(k.groupBy,W):wW.create(W)})},cloneWithLimit(k,W){return h({...k,limit:W})},cloneWithOffset(k,W){return h({...k,offset:W})},cloneWithFetch(k,W){return h({...k,fetch:W})},cloneWithHaving(k,W){return h({...k,having:k.having?FW.cloneWithOperation(k.having,"And",W):FW.create(W)})},cloneWithSetOperations(k,W){return h({...k,setOperations:k.setOperations?h([...k.setOperations,...W]):h([...W])})},cloneWithoutSelections(k){return h({...k,selections:[]})},cloneWithoutLimit(k){return h({...k,limit:void 0})},cloneWithoutOffset(k){return h({...k,offset:void 0})},cloneWithoutOrderBy:(k)=>K.cloneWithoutOrderBy(k),cloneWithoutGroupBy(k){return h({...k,groupBy:void 0})}});class Rk{#k;constructor(k){this.#k=h(k)}on(...k){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,L(k))})}onRef(k,W,$){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,m(k,W,$))})}onTrue(){return new Rk({...this.#k,joinNode:Kk.cloneWithOn(this.#k.joinNode,v.createWithSql("true"))})}$call(k){return k(this)}toOperationNode(){return this.#k.joinNode}}class ah{#k;get dynamicReference(){return this.#k}get refType(){return}constructor(k){this.#k=k}toOperationNode(){return _W(this.#k)}}function $W(k){return kk(k)&&z(k)&&V(k.dynamicReference)}var g=h({is(k){return k.kind==="OrderByItemNode"},create(k,W){return h({kind:"OrderByItemNode",orderBy:k,direction:W})},cloneWith(k,W){return h({...k,...W})}});var eW=h({is(k){return k.kind==="CollateNode"},create(k){return h({kind:"CollateNode",collation:J.create(k)})}});class Lk{#k;constructor(k){this.#k=h(k)}desc(){return new Lk({node:g.cloneWith(this.#k.node,{direction:v.createWithSql("desc")})})}asc(){return new Lk({node:g.cloneWith(this.#k.node,{direction:v.createWithSql("asc")})})}nullsLast(){return new Lk({node:g.cloneWith(this.#k.node,{nulls:"last"})})}nullsFirst(){return new Lk({node:g.cloneWith(this.#k.node,{nulls:"first"})})}collate(k){return new Lk({node:g.cloneWith(this.#k.node,{collation:eW.create(k)})})}toOperationNode(){return this.#k.node}}function RW(k){return k==="asc"||k==="desc"}function B(k){if(k.length===2)return[mW(k[0],k[1])];if(k.length===1){let[W]=k;if(Array.isArray(W))return fk("orderBy(array) is deprecated, use multiple orderBy calls instead."),W.map(($)=>mW($));return[mW(W)]}throw Error(`Invalid number of arguments at order by! expected 1-2, received ${k.length}`)}function mW(k,W){let $=ph(k);if(g.is($)){if(W)throw Error("Cannot specify direction twice!");return $}return kh($,W)}function ph(k){if(Wk(k))return p(k);if($W(k))return k.toOperationNode();let[W,$]=k.split(" ");if($)return fk("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),kh(t(W),$);return t(k)}function kh(k,W){if(typeof W==="string"){if(!RW(W))throw Error(`Invalid order by direction: ${W}`);return g.create(k,v.createWithSql(W))}if(ok(W))return fk("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),g.create(k,W.toOperationNode());let $=g.create(k);if(!W)return $;return W(new Lk({node:$})).toOperationNode()}var Wh=h({is(k){return k.kind==="PartitionByItemNode"},create(k){return h({kind:"PartitionByItemNode",partitionBy:k})}});function hh(k){return Gk(k).map(Wh.create)}class Ck{#k;constructor(k){this.#k=h(k)}orderBy(...k){return new Ck({overNode:xk.cloneWithOrderByItems(this.#k.overNode,B(k))})}clearOrderBy(){return new Ck({overNode:K.cloneWithoutOrderBy(this.#k.overNode)})}partitionBy(k){return new Ck({overNode:xk.cloneWithPartitionByItems(this.#k.overNode,hh(k))})}$call(k){return k(this)}toOperationNode(){return this.#k.overNode}}var Sk=h({is(k){return k.kind==="SelectionNode"},create(k){return h({kind:"SelectionNode",selection:k})},createSelectAll(){return h({kind:"SelectionNode",selection:pk.create()})},createSelectAllFromTable(k){return h({kind:"SelectionNode",selection:Ak.createSelectAll(k)})}});class oh{#k;get table(){return this.#k}constructor(k){this.#k=k}as(k){return new $h(this.#k,k)}}class $h{#k;#W;get table(){return this.#k}get alias(){return this.#W}constructor(k,W){this.#k=k,this.#W=W}toOperationNode(){return I.create(F(this.#k),J.create(this.#W))}}function Mh(k){return kk(k)&&z(k)&&V(k.table)&&V(k.alias)}function n(k){if(j(k))return k.map((W)=>wk(W));else return[wk(k)]}function wk(k){if(V(k))return fW(k);else if(Mh(k))return k.toOperationNode();else return MW(k)}function fW(k){if(k.includes(" as ")){let[$,M]=k.split(" as ").map(Kh);return I.create(F($),J.create(M))}else return F(k)}function F(k){if(k.includes(".")){let[$,M]=k.split(".").map(Kh);return zk.createWithSchema($,M)}else return zk.create(k)}function Kh(k){return k.trim()}function A(k){if(_(k))return A(k(d()));else if(j(k))return k.map((W)=>Gh(W));else return[Gh(k)]}function Gh(k){if(V(k))return Sk.create(Zh(k));else if($W(k))return Sk.create(k.toOperationNode());else return Sk.create(MW(k))}function R(k){if(!k)return[Sk.createSelectAll()];else if(Array.isArray(k))return k.map(Hh);else return[Hh(k)]}function Hh(k){if(V(k))return Sk.createSelectAllFromTable(F(k));throw Error(`invalid value selectAll expression: ${JSON.stringify(k)}`)}var Yh=h({is(k){return k.kind==="ValuesNode"},create(k){return h({kind:"ValuesNode",values:h(k)})}});var Xh=h({is(k){return k.kind==="DefaultInsertValueNode"},create(){return h({kind:"DefaultInsertValueNode"})}});function KW(k){let W=_(k)?k(d()):k,$=j(W)?W:h([W]);return sh($)}function sh(k){let W=rh(k);return[h([...W.keys()].map(S.create)),Yh.create(k.map(($)=>eh($,W)))]}function rh(k){let W=new Map;for(let $ of k){let M=Object.keys($);for(let G of M)if(!W.has(G)&&$[G]!==void 0)W.set(G,W.size)}return W}function eh(k,W){let $=Object.keys(k),M=Array.from({length:W.size}),G=!1,q=$.length;for(let ak of $){let Nk=W.get(ak);if(c(Nk)){q--;continue}let qW=k[ak];if(c(qW)||Wk(qW))G=!0;M[Nk]=qW}if(q<W.size||G){let ak=Xh.create();return rk.create(M.map((Nk)=>c(Nk)?ak:X(Nk)))}return sk.create(M)}var CW=h({is(k){return k.kind==="ColumnUpdateNode"},create(k,W){return h({kind:"ColumnUpdateNode",column:k,value:W})}});function Dh(...k){if(k.length===2)return[CW.create(f(k[0]),X(k[1]))];return ck(k[0])}function ck(k){let W=_(k)?k(d()):k;return Object.entries(W).filter(([$,M])=>M!==void 0).map(([$,M])=>{return CW.create(S.create($),X(M))})}var Lh=h({is(k){return k.kind==="OnDuplicateKeyNode"},create(k){return h({kind:"OnDuplicateKeyNode",updates:k})}});class SW{insertId;numInsertedOrUpdatedRows;constructor(k,W){this.insertId=k,this.numInsertedOrUpdatedRows=W}}class u extends Error{node;constructor(k){super("no result");this.node=k}}function s(k){return Object.prototype.hasOwnProperty.call(k,"prototype")}var E=h({is(k){return k.kind==="OnConflictNode"},create(){return h({kind:"OnConflictNode"})},cloneWith(k,W){return h({...k,...W})},cloneWithIndexWhere(k,W){return h({...k,indexWhere:k.indexWhere?C.cloneWithOperation(k.indexWhere,"And",W):C.create(W)})},cloneWithIndexOrWhere(k,W){return h({...k,indexWhere:k.indexWhere?C.cloneWithOperation(k.indexWhere,"Or",W):C.create(W)})},cloneWithUpdateWhere(k,W){return h({...k,updateWhere:k.updateWhere?C.cloneWithOperation(k.updateWhere,"And",W):C.create(W)})},cloneWithUpdateOrWhere(k,W){return h({...k,updateWhere:k.updateWhere?C.cloneWithOperation(k.updateWhere,"Or",W):C.create(W)})},cloneWithoutIndexWhere(k){return h({...k,indexWhere:void 0})},cloneWithoutUpdateWhere(k){return h({...k,updateWhere:void 0})}});class r{#k;constructor(k){this.#k=h(k)}column(k){let W=S.create(k);return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{columns:this.#k.onConflictNode.columns?h([...this.#k.onConflictNode.columns,W]):h([W])})})}columns(k){let W=k.map(S.create);return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{columns:this.#k.onConflictNode.columns?h([...this.#k.onConflictNode.columns,...W]):h(W)})})}constraint(k){return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{constraint:J.create(k)})})}expression(k){return new r({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{indexExpression:k.toOperationNode()})})}where(...k){return new r({...this.#k,onConflictNode:E.cloneWithIndexWhere(this.#k.onConflictNode,L(k))})}whereRef(k,W,$){return new r({...this.#k,onConflictNode:E.cloneWithIndexWhere(this.#k.onConflictNode,m(k,W,$))})}clearWhere(){return new r({...this.#k,onConflictNode:E.cloneWithoutIndexWhere(this.#k.onConflictNode)})}doNothing(){return new zh({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{doNothing:!0})})}doUpdateSet(k){return new yk({...this.#k,onConflictNode:E.cloneWith(this.#k.onConflictNode,{updates:ck(k)})})}$call(k){return k(this)}}class zh{#k;constructor(k){this.#k=h(k)}toOperationNode(){return this.#k.onConflictNode}}class yk{#k;constructor(k){this.#k=h(k)}where(...k){return new yk({...this.#k,onConflictNode:E.cloneWithUpdateWhere(this.#k.onConflictNode,L(k))})}whereRef(k,W,$){return new yk({...this.#k,onConflictNode:E.cloneWithUpdateWhere(this.#k.onConflictNode,m(k,W,$))})}clearWhere(){return new yk({...this.#k,onConflictNode:E.cloneWithoutUpdateWhere(this.#k.onConflictNode)})}$call(k){return k(this)}toOperationNode(){return this.#k.onConflictNode}}var Jh=h({is(k){return k.kind==="TopNode"},create(k,W){return h({kind:"TopNode",expression:k,modifiers:W})}});function i(k,W){if(!_k(k)&&!GW(k))throw Error(`Invalid top expression: ${k}`);if(!c(W)&&!k$(W))throw Error(`Invalid top modifiers: ${W}`);return Jh.create(k,W)}function k$(k){return k==="percent"||k==="with ties"||k==="percent with ties"}var Fk=h({is(k){return k.kind==="OrActionNode"},create(k){return h({kind:"OrActionNode",action:k})}});class D{#k;constructor(k){this.#k=h(k)}values(k){let[W,$]=KW(k);return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{columns:W,values:$})})}columns(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{columns:h(k.map(S.create))})})}expression(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{values:p(k)})})}defaultValues(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{defaultValues:!0})})}modifyEnd(k){return new D({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}ignore(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("ignore")})})}orIgnore(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("ignore")})})}orAbort(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("abort")})})}orFail(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("fail")})})}orReplace(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("replace")})})}orRollback(){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{orAction:Fk.create("rollback")})})}top(k,W){return new D({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}onConflict(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{onConflict:k(new r({onConflictNode:E.create()})).toOperationNode()})})}onDuplicateKeyUpdate(k){return new D({...this.#k,queryNode:w.cloneWith(this.#k.queryNode,{onDuplicateKey:Lh.create(ck(k))})})}returning(k){return new D({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(){return new D({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R())})}output(k){return new D({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new D({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}clearReturning(){return new D({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new D({...this.#k})}$castTo(){return new D(this.#k)}$narrowType(){return new D(this.#k)}$assertType(){return new D(this.#k)}withPlugin(k){return new D({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new SW(W.insertId,W.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new D({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}class IW{numDeletedRows;constructor(k){this.numDeletedRows=k}}var Ik=h({is(k){return k.kind==="LimitNode"},create(k){return h({kind:"LimitNode",limit:k})}});var P;class HW{#k;constructor(k){this.#k=h(k)}where(...k){return new P({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new P({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}clearWhere(){return new P({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}top(k,W){return new P({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}using(k){return new P({...this.#k,queryNode:Dk.cloneWithUsing(this.#k.queryNode,n(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}#W(k,W){return new P({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}returning(k){return new P({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new P({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new P({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new P({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}clearReturning(){return new P({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}clearLimit(){return new P({...this.#k,queryNode:Dk.cloneWithoutLimit(this.#k.queryNode)})}orderBy(...k){return new P({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}clearOrderBy(){return new P({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}limit(k){return new P({...this.#k,queryNode:Dk.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}modifyEnd(k){return new P({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new P({...this.#k})}$castTo(){return new P(this.#k)}$narrowType(){return new P(this.#k)}$assertType(){return new P(this.#k)}withPlugin(k){return new P({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new IW(W.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new P({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}P=HW;class jW{numUpdatedRows;numChangedRows;constructor(k,W){this.numUpdatedRows=k,this.numChangedRows=W}}var U;class jk{#k;constructor(k){this.#k=h(k)}where(...k){return new U({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new U({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}clearWhere(){return new U({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}top(k,W){return new U({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}from(k){return new U({...this.#k,queryNode:o.cloneWithFromItems(this.#k.queryNode,n(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}#W(k,W){return new U({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}orderBy(...k){return new U({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}clearOrderBy(){return new U({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}limit(k){return new U({...this.#k,queryNode:o.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}set(...k){return new U({...this.#k,queryNode:o.cloneWithUpdates(this.#k.queryNode,Dh(...k))})}returning(k){return new U({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new U({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new U({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new U({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}modifyEnd(k){return new U({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}clearReturning(){return new U({...this.#k,queryNode:K.cloneWithoutReturning(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new U({...this.#k})}$castTo(){return new U(this.#k)}$narrowType(){return new U(this.#k)}$assertType(){return new U(this.#k)}withPlugin(k){return new U({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new jW(W.numAffectedRows??BigInt(0),W.numChangedRows)]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new U({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}U=jk;var EW=h({is(k){return k.kind==="CommonTableExpressionNameNode"},create(k,W){return h({kind:"CommonTableExpressionNameNode",table:zk.create(k),columns:W?h(W.map(S.create)):void 0})}});var Ek=h({is(k){return k.kind==="CommonTableExpressionNode"},create(k,W){return h({kind:"CommonTableExpressionNode",name:k,expression:W})},cloneWith(k,W){return h({...k,...W})}});class gk{#k;constructor(k){this.#k=h(k)}materialized(){return new gk({...this.#k,node:Ek.cloneWith(this.#k.node,{materialized:!0})})}notMaterialized(){return new gk({...this.#k,node:Ek.cloneWith(this.#k.node,{materialized:!1})})}toOperationNode(){return this.#k.node}}function OW(k,W){let $=W(Ph()).toOperationNode();if(_(k))return k(W$($)).toOperationNode();return Ek.create(qh(k),$)}function W$(k){return(W)=>{return new gk({node:Ek.create(qh(W),k)})}}function qh(k){if(k.includes("(")){let W=k.split(/[\(\)]/),$=W[0],M=W[1].split(",").map((G)=>G.trim());return EW.create($,M)}else return EW.create(k)}var tk=h({is(k){return k.kind==="WithNode"},create(k,W){return h({kind:"WithNode",expressions:h([k]),...W})},cloneWithExpression(k,W){return h({...k,expressions:h([...k.expressions,W])})}});var Uh=["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 Vh(k){let W="";for(let $=0;$<k;++$)W+=h$();return W}function h$(){return Uh[~~(Math.random()*Uh.length)]}function T(){return new wh}class wh{#k;get queryId(){if(this.#k===void 0)this.#k=Vh(8);return this.#k}}var Fh=h({is(k){return k.kind==="MatchedNode"},create(k,W=!1){return h({kind:"MatchedNode",not:k,bySource:W})}});function bW(k,W,$){return Mk.create(mk([Fh.create(!k.isMatched,k.bySource),...W&&W.length>0?[W.length===3&&$?m(W[0],W[1],W[2]):L(W)]:[]],"and",!1))}function Ok(k){if(V(k))return v.create([k],[]);if(z(k))return k.toOperationNode();return k}class ZW{#k;#W;#h;constructor(){this.#k=new Promise((k,W)=>{this.#h=W,this.#W=k})}get promise(){return this.#k}resolve=(k)=>{if(this.#W)this.#W(k)};reject=(k)=>{if(this.#h)this.#h(k)}}async function Th(k){let W=new ZW,$=new ZW;return k.provideConnection(async(M)=>{return W.resolve(M),await $.promise}).catch((M)=>W.reject(M)),h({connection:await W.promise,release:$.resolve})}var $$=h([]);class QW{#k;constructor(k=$$){this.#k=k}get plugins(){return this.#k}transformQuery(k,W){for(let $ of this.#k){let M=$.transformQuery({node:k,queryId:W});if(M.kind===k.kind)k=M;else throw Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${k.kind}`,`but it returned a ${M.kind}`].join(" "))}return k}async executeQuery(k){return await this.provideConnection(async(W)=>{let $=await W.executeQuery(k);if("numUpdatedOrDeletedRows"in $)fk("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`.");return await this.#W($,k.queryId)})}async*stream(k,W){let{connection:$,release:M}=await Th(this);try{for await(let G of $.streamQuery(k,W))yield await this.#W(G,k.queryId)}finally{M()}}async#W(k,W){for(let $ of this.#k)k=await $.transformResult({result:k,queryId:W});return k}}class bk extends QW{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(k){return new bk([...this.plugins,k])}withPlugins(k){return new bk([...this.plugins,...k])}withPluginAtFront(k){return new bk([k,...this.plugins])}withoutPlugins(){return new bk([])}}var qk=new bk;class NW{numChangedRows;constructor(k){this.numChangedRows=k}}class Hk{#k;constructor(k){this.#k=h(k)}modifyEnd(k){return new Hk({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}top(k,W){return new Hk({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}using(...k){return new O({...this.#k,queryNode:N.cloneWithUsing(this.#k.queryNode,Jk("Using",k))})}returning(k){return new Hk({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new Hk({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new Hk({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new Hk({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}}class O{#k;constructor(k){this.#k=h(k)}modifyEnd(k){return new O({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,k.toOperationNode())})}top(k,W){return new O({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}whenMatched(){return this.#W([])}whenMatchedAnd(...k){return this.#W(k)}whenMatchedAndRef(k,W,$){return this.#W([k,W,$],!0)}#W(k,W){return new BW({...this.#k,queryNode:N.cloneWithWhen(this.#k.queryNode,bW({isMatched:!0},k,W))})}whenNotMatched(){return this.#h([])}whenNotMatchedAnd(...k){return this.#h(k)}whenNotMatchedAndRef(k,W,$){return this.#h([k,W,$],!0)}whenNotMatchedBySource(){return this.#h([],!1,!0)}whenNotMatchedBySourceAnd(...k){return this.#h(k,!1,!0)}whenNotMatchedBySourceAndRef(k,W,$){return this.#h([k,W,$],!0,!0)}returning(k){return new O({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,A(k))})}returningAll(k){return new O({...this.#k,queryNode:K.cloneWithReturning(this.#k.queryNode,R(k))})}output(k){return new O({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,A(k))})}outputAll(k){return new O({...this.#k,queryNode:K.cloneWithOutput(this.#k.queryNode,R(k))})}#h(k,W=!1,$=!1){let M={...this.#k,queryNode:N.cloneWithWhen(this.#k.queryNode,bW({isMatched:!1,bySource:$},k,W))};return new($?BW:vh)(M)}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new O({...this.#k})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile(),W=await this.#k.executor.executeQuery(k),{adapter:$}=this.#k.executor,M=k.query;if(M.returning&&$.supportsReturning||M.output&&$.supportsOutput)return W.rows;return[new NW(W.numAffectedRows)]}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}}class BW{#k;constructor(k){this.#k=h(k)}thenDelete(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("delete"))})}thenDoNothing(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("do nothing"))})}thenUpdate(k){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok(k(new jk({queryId:this.#k.queryId,executor:qk,queryNode:o.createWithoutTable()}))))})}thenUpdateSet(...k){return this.thenUpdate((W)=>W.set(...k))}}class vh{#k;constructor(k){this.#k=h(k)}thenDoNothing(){return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok("do nothing"))})}thenInsertValues(k){let[W,$]=KW(k);return new O({...this.#k,queryNode:N.cloneWithThen(this.#k.queryNode,Ok(w.cloneWith(w.createWithoutInto(),{columns:W,values:$})))})}}class Pk{#k;constructor(k){this.#k=h(k)}selectFrom(k){return nk({queryId:T(),executor:this.#k.executor,queryNode:Y.createFrom(n(k),this.#k.withNode)})}selectNoFrom(k){return nk({queryId:T(),executor:this.#k.executor,queryNode:Y.cloneWithSelections(Y.create(this.#k.withNode),A(k))})}insertInto(k){return new D({queryId:T(),executor:this.#k.executor,queryNode:w.create(F(k),this.#k.withNode)})}replaceInto(k){return new D({queryId:T(),executor:this.#k.executor,queryNode:w.create(F(k),this.#k.withNode,!0)})}deleteFrom(k){return new HW({queryId:T(),executor:this.#k.executor,queryNode:Dk.create(n(k),this.#k.withNode)})}updateTable(k){return new jk({queryId:T(),executor:this.#k.executor,queryNode:o.create(n(k),this.#k.withNode)})}mergeInto(k){return new Hk({queryId:T(),executor:this.#k.executor,queryNode:N.create(fW(k),this.#k.withNode)})}with(k,W){let $=OW(k,W);return new Pk({...this.#k,withNode:this.#k.withNode?tk.cloneWithExpression(this.#k.withNode,$):tk.create($)})}withRecursive(k,W){let $=OW(k,W);return new Pk({...this.#k,withNode:this.#k.withNode?tk.cloneWithExpression(this.#k.withNode,$):tk.create($,{recursive:!0})})}withPlugin(k){return new Pk({...this.#k,executor:this.#k.executor.withPlugin(k)})}withoutPlugins(){return new Pk({...this.#k,executor:this.#k.executor.withoutPlugins()})}withSchema(k){return new Pk({...this.#k,executor:this.#k.executor.withPluginAtFront(new YW(k))})}}function Ph(){return new Pk({executor:qk})}function Ah(k,W){return new Rk({joinNode:Kk.create(k,wk(W))})}function _h(){return new Ck({overNode:xk.create()})}function Jk(k,W){if(W.length===3)return K$(k,W[0],W[1],W[2]);else if(W.length===2)return M$(k,W[0],W[1]);else if(W.length===1)return G$(k,W[0]);else throw Error("not implemented")}function M$(k,W,$){return $(Ah(k,W)).toOperationNode()}function K$(k,W,$,M){return Kk.createWithOn(k,wk(W),m($,"=",M))}function G$(k,W){return Kk.create(k,wk(W))}var mh=h({is(k){return k.kind==="OffsetNode"},create(k){return h({kind:"OffsetNode",offset:k})}});var Rh=h({is(k){return k.kind==="GroupByItemNode"},create(k){return h({kind:"GroupByItemNode",groupBy:k})}});function fh(k){return k=_(k)?k(d()):k,Gk(k).map(Rh.create)}function Tk(k,W,$){if(_(W))W=W(XW());if(!j(W))W=[W];return W.map((M)=>Ch.create(k,p(M),$))}class Z{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}or(...k){return new DW(hk.create(this.#k,L(k)))}and(...k){return new LW(x.create(this.#k,L(k)))}$castTo(){return new Z(this.#k)}$notNull(){return new Z(this.#k)}toOperationNode(){return this.#k}}class zW{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}class DW{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}or(...k){return new DW(hk.create(this.#k,L(k)))}$castTo(){return new DW(this.#k)}toOperationNode(){return Xk.create(this.#k)}}class LW{#k;constructor(k){this.#k=k}get expressionType(){return}as(k){return new zW(this,k)}and(...k){return new LW(x.create(this.#k,L(k)))}$castTo(){return new LW(this.#k)}toOperationNode(){return Xk.create(this.#k)}}var Sh=h({is(k){return k.kind==="FetchNode"},create(k,W){return{kind:"FetchNode",rowCount:Q.create(k),modifier:W}}});function Ih(k,W){if(!_k(k)&&!GW(k))throw Error(`Invalid fetch row count: ${k}`);if(!H$(W))throw Error(`Invalid fetch modifier: ${W}`);return Sh.create(k,W)}function H$(k){return k==="only"||k==="with ties"}var H;class xW{#k;constructor(k){this.#k=h(k)}get expressionType(){return}get isSelectQueryBuilder(){return!0}where(...k){return new H({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,L(k))})}whereRef(k,W,$){return new H({...this.#k,queryNode:K.cloneWithWhere(this.#k.queryNode,m(k,W,$))})}having(...k){return new H({...this.#k,queryNode:Y.cloneWithHaving(this.#k.queryNode,L(k))})}havingRef(k,W,$){return new H({...this.#k,queryNode:Y.cloneWithHaving(this.#k.queryNode,m(k,W,$))})}select(k){return new H({...this.#k,queryNode:Y.cloneWithSelections(this.#k.queryNode,A(k))})}distinctOn(k){return new H({...this.#k,queryNode:Y.cloneWithDistinctOn(this.#k.queryNode,Gk(k))})}modifyFront(k){return new H({...this.#k,queryNode:Y.cloneWithFrontModifier(this.#k.queryNode,a.createWithExpression(k.toOperationNode()))})}modifyEnd(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.createWithExpression(k.toOperationNode()))})}distinct(){return new H({...this.#k,queryNode:Y.cloneWithFrontModifier(this.#k.queryNode,a.create("Distinct"))})}forUpdate(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForUpdate",k?dk(k).map(F):void 0))})}forShare(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForShare",k?dk(k).map(F):void 0))})}forKeyShare(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForKeyShare",k?dk(k).map(F):void 0))})}forNoKeyUpdate(k){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("ForNoKeyUpdate",k?dk(k).map(F):void 0))})}skipLocked(){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("SkipLocked"))})}noWait(){return new H({...this.#k,queryNode:K.cloneWithEndModifier(this.#k.queryNode,a.create("NoWait"))})}selectAll(k){return new H({...this.#k,queryNode:Y.cloneWithSelections(this.#k.queryNode,R(k))})}innerJoin(...k){return this.#W("InnerJoin",k)}leftJoin(...k){return this.#W("LeftJoin",k)}rightJoin(...k){return this.#W("RightJoin",k)}fullJoin(...k){return this.#W("FullJoin",k)}crossJoin(...k){return this.#W("CrossJoin",k)}innerJoinLateral(...k){return this.#W("LateralInnerJoin",k)}leftJoinLateral(...k){return this.#W("LateralLeftJoin",k)}crossJoinLateral(...k){return this.#W("LateralCrossJoin",k)}crossApply(...k){return this.#W("CrossApply",k)}outerApply(...k){return this.#W("OuterApply",k)}#W(k,W){return new H({...this.#k,queryNode:K.cloneWithJoin(this.#k.queryNode,Jk(k,W))})}orderBy(...k){return new H({...this.#k,queryNode:K.cloneWithOrderByItems(this.#k.queryNode,B(k))})}groupBy(k){return new H({...this.#k,queryNode:Y.cloneWithGroupByItems(this.#k.queryNode,fh(k))})}limit(k){return new H({...this.#k,queryNode:Y.cloneWithLimit(this.#k.queryNode,Ik.create(X(k)))})}offset(k){return new H({...this.#k,queryNode:Y.cloneWithOffset(this.#k.queryNode,mh.create(X(k)))})}fetch(k,W="only"){return new H({...this.#k,queryNode:Y.cloneWithFetch(this.#k.queryNode,Ih(k,W))})}top(k,W){return new H({...this.#k,queryNode:K.cloneWithTop(this.#k.queryNode,i(k,W))})}union(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("union",k,!1))})}unionAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("union",k,!0))})}intersect(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("intersect",k,!1))})}intersectAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("intersect",k,!0))})}except(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("except",k,!1))})}exceptAll(k){return new H({...this.#k,queryNode:Y.cloneWithSetOperations(this.#k.queryNode,Tk("except",k,!0))})}as(k){return new jh(this,k)}clearSelect(){return new H({...this.#k,queryNode:Y.cloneWithoutSelections(this.#k.queryNode)})}clearWhere(){return new H({...this.#k,queryNode:K.cloneWithoutWhere(this.#k.queryNode)})}clearLimit(){return new H({...this.#k,queryNode:Y.cloneWithoutLimit(this.#k.queryNode)})}clearOffset(){return new H({...this.#k,queryNode:Y.cloneWithoutOffset(this.#k.queryNode)})}clearOrderBy(){return new H({...this.#k,queryNode:K.cloneWithoutOrderBy(this.#k.queryNode)})}clearGroupBy(){return new H({...this.#k,queryNode:Y.cloneWithoutGroupBy(this.#k.queryNode)})}$call(k){return k(this)}$if(k,W){if(k)return W(this);return new H({...this.#k})}$castTo(){return new H(this.#k)}$narrowType(){return new H(this.#k)}$assertType(){return new H(this.#k)}$asTuple(){return new Z(this.toOperationNode())}$asScalar(){return new Z(this.toOperationNode())}withPlugin(k){return new H({...this.#k,executor:this.#k.executor.withPlugin(k)})}toOperationNode(){return this.#k.executor.transformQuery(this.#k.queryNode,this.#k.queryId)}compile(){return this.#k.executor.compileQuery(this.toOperationNode(),this.#k.queryId)}async execute(){let k=this.compile();return(await this.#k.executor.executeQuery(k)).rows}async executeTakeFirst(){let[k]=await this.execute();return k}async executeTakeFirstOrThrow(k=u){let W=await this.executeTakeFirst();if(W===void 0)throw s(k)?new k(this.toOperationNode()):k(this.toOperationNode());return W}async*stream(k=100){let W=this.compile(),$=this.#k.executor.stream(W,k);for await(let M of $)yield*M.rows}async explain(k,W){return await new H({...this.#k,queryNode:K.cloneWithExplain(this.#k.queryNode,k,W)}).execute()}}H=xW;function nk(k){return new xW(k)}class jh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return I.create(this.#k.toOperationNode(),J.create(this.#W))}}var e=h({is(k){return k.kind==="AggregateFunctionNode"},create(k,W=[]){return h({kind:"AggregateFunctionNode",func:k,aggregated:W})},cloneWithDistinct(k){return h({...k,distinct:!0})},cloneWithOrderBy(k,W,$=!1){let M=$?"withinGroup":"orderBy";return h({...k,[M]:k[M]?$k.cloneWithItems(k[M],W):$k.create(W)})},cloneWithFilter(k,W){return h({...k,filter:k.filter?C.cloneWithOperation(k.filter,"And",W):C.create(W)})},cloneWithOrFilter(k,W){return h({...k,filter:k.filter?C.cloneWithOperation(k.filter,"Or",W):C.create(W)})},cloneWithOver(k,W){return h({...k,over:W})}});var cW=h({is(k){return k.kind==="FunctionNode"},create(k,W){return h({kind:"FunctionNode",func:k,arguments:W})}});class b{#k;constructor(k){this.#k=h(k)}get expressionType(){return}as(k){return new Eh(this,k)}distinct(){return new b({...this.#k,aggregateFunctionNode:e.cloneWithDistinct(this.#k.aggregateFunctionNode)})}orderBy(...k){return new b({...this.#k,aggregateFunctionNode:K.cloneWithOrderByItems(this.#k.aggregateFunctionNode,B(k))})}clearOrderBy(){return new b({...this.#k,aggregateFunctionNode:K.cloneWithoutOrderBy(this.#k.aggregateFunctionNode)})}withinGroupOrderBy(...k){return new b({...this.#k,aggregateFunctionNode:e.cloneWithOrderBy(this.#k.aggregateFunctionNode,B(k),!0)})}filterWhere(...k){return new b({...this.#k,aggregateFunctionNode:e.cloneWithFilter(this.#k.aggregateFunctionNode,L(k))})}filterWhereRef(k,W,$){return new b({...this.#k,aggregateFunctionNode:e.cloneWithFilter(this.#k.aggregateFunctionNode,m(k,W,$))})}over(k){let W=_h();return new b({...this.#k,aggregateFunctionNode:e.cloneWithOver(this.#k.aggregateFunctionNode,(k?k(W):W).toOperationNode())})}$call(k){return k(this)}$castTo(){return new b(this.#k)}$notNull(){return new b(this.#k)}toOperationNode(){return this.#k.aggregateFunctionNode}}class Eh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),J.create(this.#W))}}function Oh(){let k=($,M)=>{return new Z(cW.create($,Gk(M??[])))},W=($,M)=>{return new b({aggregateFunctionNode:e.create($,M?Gk(M):void 0)})};return Object.assign(k,{agg:W,avg($){return W("avg",[$])},coalesce(...$){return k("coalesce",$)},count($){return W("count",[$])},countAll($){return new b({aggregateFunctionNode:e.create("count",R($))})},max($){return W("max",[$])},min($){return W("min",[$])},sum($){return W("sum",[$])},any($){return k("any",[$])},jsonAgg($){return new b({aggregateFunctionNode:e.create("json_agg",[V($)?F($):$.toOperationNode()])})},toJson($){return new Z(cW.create("to_json",[V($)?F($):$.toOperationNode()]))}})}var bh=h({is(k){return k.kind==="UnaryOperationNode"},create(k,W){return h({kind:"UnaryOperationNode",operator:k,operand:W})}});function Qh(k,W){return bh.create(y.create(k),f(W))}var l=h({is(k){return k.kind==="CaseNode"},create(k){return h({kind:"CaseNode",value:k})},cloneWithWhen(k,W){return h({...k,when:h(k.when?[...k.when,W]:[W])})},cloneWithThen(k,W){return h({...k,when:k.when?h([...k.when.slice(0,-1),Mk.cloneWithResult(k.when[k.when.length-1],W)]):void 0})},cloneWith(k,W){return h({...k,...W})}});class yW{#k;constructor(k){this.#k=h(k)}when(...k){return new gW({...this.#k,node:l.cloneWithWhen(this.#k.node,Mk.create(L(k)))})}}class gW{#k;constructor(k){this.#k=h(k)}then(k){return new Nh({...this.#k,node:l.cloneWithThen(this.#k.node,WW(k)?Bk(k):X(k))})}}class Nh{#k;constructor(k){this.#k=h(k)}when(...k){return new gW({...this.#k,node:l.cloneWithWhen(this.#k.node,Mk.create(L(k)))})}else(k){return new Bh({...this.#k,node:l.cloneWith(this.#k.node,{else:WW(k)?Bk(k):X(k)})})}end(){return new Z(l.cloneWith(this.#k.node,{isStatement:!1}))}endCase(){return new Z(l.cloneWith(this.#k.node,{isStatement:!0}))}}class Bh{#k;constructor(k){this.#k=h(k)}end(){return new Z(l.cloneWith(this.#k.node,{isStatement:!1}))}endCase(){return new Z(l.cloneWith(this.#k.node,{isStatement:!0}))}}var JW=h({is(k){return k.kind==="JSONOperatorChainNode"},create(k){return h({kind:"JSONOperatorChainNode",operator:k,values:h([])})},cloneWithValue(k,W){return h({...k,values:h([...k.values,W])})}});var tW=h({is(k){return k.kind==="JSONPathLegNode"},create(k,W){return h({kind:"JSONPathLegNode",type:k,value:W})}});var Uk=h({is(k){return k.kind==="JSONPathNode"},create(k){return h({kind:"JSONPathNode",inOperator:k,pathLegs:h([])})},cloneWithLeg(k,W){return h({...k,pathLegs:h([...k.pathLegs,W])})}});var Qk=h({is(k){return k.kind==="JSONReferenceNode"},create(k,W){return h({kind:"JSONReferenceNode",reference:k,traversal:W})},cloneWithTraversal(k,W){return h({...k,traversal:W})}});var Z$=/^#-\d+$/;class ik{#k;constructor(k){this.#k=k}at(k){if(typeof k!=="number"&&typeof k!=="string"||typeof k==="number"&&!Number.isInteger(k)||typeof k==="string"&&k!=="last"&&!Z$.test(k))throw Error(`Unexpected index value in .at(...): ${k}`);return this.#W("ArrayLocation",k)}key(k){return this.#W("Member",k)}#W(k,W){if(Qk.is(this.#k))return new uk(Qk.cloneWithTraversal(this.#k,Uk.is(this.#k.traversal)?Uk.cloneWithLeg(this.#k.traversal,tW.create(k,W)):JW.cloneWithValue(this.#k.traversal,Q.createImmediate(W))));return new uk(Uk.cloneWithLeg(this.#k,tW.create(k,W)))}}class uk extends ik{#k;constructor(k){super(k);this.#k=k}get expressionType(){return}as(k){return new xh(this,k)}$castTo(){return new uk(this.#k)}$notNull(){return new uk(this.#k)}toOperationNode(){return this.#k}}class xh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}var nW=h({is(k){return k.kind==="TupleNode"},create(k){return h({kind:"TupleNode",values:h(k)})}});var Y$=["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"],X$=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],ch=h({is(k){return k.kind==="DataTypeNode"},create(k){return h({kind:"DataTypeNode",dataType:k})}});function yh(k){if(Y$.includes(k))return!0;if(X$.some((W)=>W.test(k)))return!0;return!1}function gh(k){if(z(k))return k.toOperationNode();if(yh(k))return ch.create(k);throw Error(`invalid column data type ${JSON.stringify(k)}`)}var th=h({is(k){return k.kind==="CastNode"},create(k,W){return h({kind:"CastNode",expression:k,dataType:W})}});function XW(k=qk){function W(G,q,vk){return new Z(hW(G,q,vk))}function $(G,q){return new Z(Qh(G,q))}let M=Object.assign(W,{fn:void 0,eb:void 0,selectFrom(G){return nk({queryId:T(),executor:k,queryNode:Y.createFrom(n(G))})},case(G){return new yW({node:l.create(c(G)?void 0:f(G))})},ref(G,q){if(c(q))return new Z(t(G));return new ik(nh(G,q))},jsonPath(){return new ik(Uk.create())},table(G){return new Z(F(G))},val(G){return new Z(X(G))},refTuple(...G){return new Z(nW.create(G.map(f)))},tuple(...G){return new Z(nW.create(G.map(X)))},lit(G){return new Z(Bk(G))},unary:$,not(G){return $("not",G)},exists(G){return $("exists",G)},neg(G){return $("-",G)},between(G,q,vk){return new Z(Yk.create(f(G),y.create("between"),x.create(X(q),X(vk))))},betweenSymmetric(G,q,vk){return new Z(Yk.create(f(G),y.create("between symmetric"),x.create(X(q),X(vk))))},and(G){if(j(G))return new Z(mk(G,"and"));return new Z(UW(G,"and"))},or(G){if(j(G))return new Z(mk(G,"or"));return new Z(UW(G,"or"))},parens(...G){let q=L(G);if(Xk.is(q))return new Z(q);else return new Z(Xk.create(q))},cast(G,q){return new Z(th.create(f(G),gh(q)))},withSchema(G){return XW(k.withPluginAtFront(new YW(G)))}});return M.fn=Oh(),M.eb=M,M}function d(k){return XW()}function p(k){if(z(k))return k.toOperationNode();else if(_(k))return k(d()).toOperationNode();throw Error(`invalid expression: ${JSON.stringify(k)}`)}function MW(k){if(z(k))return k.toOperationNode();else if(_(k))return k(d()).toOperationNode();throw Error(`invalid aliased expression: ${JSON.stringify(k)}`)}function Wk(k){return ok(k)||iW(k)||_(k)}function _W(k){if(V(k))return t(k);return k.toOperationNode()}function Gk(k){if(j(k))return k.map((W)=>f(W));else return[f(k)]}function f(k){if(Wk(k))return p(k);return _W(k)}function nh(k,W){let $=t(k);if(dW(W))return Qk.create($,JW.create(y.create(W)));let M=W.slice(0,-1);if(dW(M))return Qk.create($,Uk.create(y.create(M)));throw Error(`Invalid JSON operator: ${W}`)}function t(k){if(!k.includes("."))return Ak.create(S.create(k));let $=k.split(".").map(uW);if($.length===3)return L$($);if($.length===2)return z$($);throw Error(`invalid column reference ${k}`)}function Zh(k){if(k.includes(" as ")){let[$,M]=k.split(" as ").map(uW);return I.create(t($),J.create(M))}else return t(k)}function D$(k){return S.create(k)}function R3(k){if(k.includes(" ")){let[$,M]=k.split(" ").map(uW);if(!RW(M))throw Error(`invalid order direction "${M}" next to "${$}"`);return B([$,M])[0]}else return D$(k)}function L$(k){let[W,$,M]=k;return Ak.create(S.create(M),zk.createWithSchema(W,$))}function z$(k){let[W,$]=k;return Ak.create(S.create($),zk.create(W))}function uW(k){return k.trim()}class lk{#k;constructor(k){this.#k=h(k)}get expressionType(){return}get isRawBuilder(){return!0}as(k){return new dh(this,k)}$castTo(){return new lk({...this.#k})}$notNull(){return new lk(this.#k)}withPlugin(k){return new lk({...this.#k,plugins:this.#k.plugins!==void 0?h([...this.#k.plugins,k]):h([k])})}toOperationNode(){return this.#h(this.#W())}compile(k){return this.#$(this.#W(k))}async execute(k){let W=this.#W(k);return W.executeQuery(this.#$(W))}#W(k){let W=k!==void 0?k.getExecutor():qk;return this.#k.plugins!==void 0?W.withPlugins(this.#k.plugins):W}#h(k){return k.transformQuery(this.#k.rawNode,this.#k.queryId)}#$(k){return k.compileQuery(this.#h(k),this.#k.queryId)}}function Zk(k){return new lk(k)}class dh{#k;#W;constructor(k,W){this.#k=k,this.#W=W}get expression(){return this.#k}get alias(){return this.#W}get rawBuilder(){return this.#k}toOperationNode(){return I.create(this.#k.toOperationNode(),z(this.#W)?this.#W.toOperationNode():J.create(this.#W))}}var J$=Object.assign((k,...W)=>{return Zk({queryId:T(),rawNode:v.create(k,W?.map(uh)??[])})},{ref(k){return Zk({queryId:T(),rawNode:v.createWithChild(t(k))})},val(k){return Zk({queryId:T(),rawNode:v.createWithChild(X(k))})},value(k){return this.val(k)},table(k){return Zk({queryId:T(),rawNode:v.createWithChild(F(k))})},id(...k){let W=Array(k.length+1).fill(".");return W[0]="",W[W.length-1]="",Zk({queryId:T(),rawNode:v.create(W,k.map(J.create))})},lit(k){return Zk({queryId:T(),rawNode:v.createWithChild(Q.createImmediate(k))})},literal(k){return this.lit(k)},raw(k){return Zk({queryId:T(),rawNode:v.createWithSql(k)})},join(k,W=J$`, `){let $=Array(Math.max(2*k.length-1,0)),M=W.toOperationNode();for(let G=0;G<k.length;++G)if($[2*G]=uh(k[G]),G!==k.length-1)$[2*G+1]=M;return Zk({queryId:T(),rawNode:v.createWithChildren($)})}});function uh(k){if(z(k))return k.toOperationNode();return X(k)}var l3=h({raw(k,W=[]){return h({sql:k,query:v.createWithSql(k),parameters:h(W),queryId:T()})}});
|
|
3
|
+
export{z as _b,S as $b,pk as ac,ah as bc,t as cc,D$ as dc,R3 as ec,rk as fc,Q as gc,L as hc,K as ic,Y as jc,Vh as kc,T as lc,ZW as mc,Th as nc,QW as oc,Pk as pc,Oh as qc,l as rc,yW as sc,gh as tc,p as uc,oh as vc,F as wc,J$ as xc,l3 as yc};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
function q(k){let b=3735928559,d=1103547991;for(let f=0;f<k.length;f++){let l=k.charCodeAt(f);b=Math.imul(b^l,2654435761),d=Math.imul(d^l,1597334677)}return b=Math.imul(b^b>>>16,2246822507)^Math.imul(d^d>>>13,3266489909),d=Math.imul(d^d>>>16,2246822507)^Math.imul(b^b>>>13,3266489909),(d>>>0).toString(36)+(b>>>0).toString(36)}
|
|
3
|
-
export{q as
|
|
3
|
+
export{q as Uj};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var j=Object.create;var{getPrototypeOf:k,defineProperty:f,getOwnPropertyNames:l}=Object;var m=Object.prototype.hasOwnProperty;function n(a){return this[a]}var o,p,s=(a,b,c)=>{var g=a!=null&&typeof a==="object";if(g){var h=b?o??=new WeakMap:p??=new WeakMap,i=h.get(a);if(i)return i}c=a!=null?j(k(a)):{};let d=b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c;for(let e of l(a))if(!m.call(d,e))f(d,e,{get:n.bind(a,e),enumerable:!0});if(g)h.set(a,d);return d};var t=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var q=(a)=>a;function r(a,b){this[a]=q.bind(null,b)}var u=(a,b)=>{for(var c in b)f(a,c,{get:b[c],enumerable:!0,configurable:!0,set:r.bind(b,c)})};var v=(a,b)=>()=>(a&&(b=a(a=0)),b);var w=(a)=>JSON.parse(a);var x=import.meta.require;
|
|
3
|
-
export{s as
|
|
3
|
+
export{s as Jk,t as Kk,u as Lk,v as Mk,w as Nk,x as Ok};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
export{s as
|
|
2
|
+
import{ld as a}from"./chunk-zned6mj8.js";var l=/"/g,n=/[\\'"]/g;class r extends a{visitOrAction(t){this.append("or "),this.append(t.action)}getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(t){return t.replace(l,'""')}sanitizeJSONPathMemberValue(t){return t.replace(n,(e)=>e==="\\"?"\\\\":e==="'"?"''":"\\\"")}visitDefaultInsertValue(t){this.append("null")}}class s{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}get supportsOutput(){return!1}}class p extends s{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(t,e){}async releaseMigrationLock(t,e){}}
|
|
3
|
+
export{s as zc,r as Ac,p as Bc};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function W(q){if(!(q instanceof Error))return{message:F(q),messageCarriesBody:!1};let w=q,A=I(w),D=K(w),H=D===void 0||q.message.includes(D);return{status:A,body:D,message:q.message,messageCarriesBody:H}}function I(q){if(typeof q.statusCode==="number")return q.statusCode;if(typeof q.status==="number")return q.status;if(typeof q.$metadata?.httpStatusCode==="number")return q.$metadata.httpStatusCode;if(typeof q.$response?.statusCode==="number")return q.$response.statusCode;return}function K(q){let w=P(q);if(w===void 0)return;let A=w.trim();if(A.length===0)return;return V(A,4000)}function P(q){if(typeof q.body==="string")return q.body;if(G(q.error))return F(q.error);let w=q.$response?.body;if(typeof w==="string")return w;if(Q(w))return;if(G(w))return F(w);return}function Q(q){return typeof q==="object"&&q!==null&&"pipe"in q&&typeof q.pipe==="function"}function G(q){return typeof q==="object"&&q!==null&&Object.keys(q).length>0}function X(q,w){if(q.messageCarriesBody||q.status===void 0||q.body===void 0)return w!==void 0&&q.status!==void 0?`${w} (${q.status}): ${q.message}`:q.message;return w!==void 0?`${w} (${q.status}): ${q.body}`:`${q.status}: ${q.body}`}function V(q,w){if(q.length<=w)return q;return`${q.slice(0,w)}... [truncated ${q.length-w} chars]`}function F(q){try{let w=JSON.stringify(q);return w===void 0?String(q):w}catch{return String(q)}}
|
|
3
|
+
export{W as lk,X as mk};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{n as
|
|
1
|
+
import{Bg as t,tj as e,xj as a}from"./chunk-ersxsrz8.js";function n({className:i,size:r="default",...s}){return t(e.Root,{"data-slot":"switch","data-size":r,className:a("peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",i),...s,children:t(e.Thumb,{"data-slot":"switch-thumb",className:a("pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground")})})}
|
|
2
|
+
export{n as eb};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Qj as h,Rj as z,Sj as E}from"./chunk-4153rke8.js";import{Tj as S}from"./chunk-s5s1rk4n.js";import"./chunk-8qe7cpbr.js";import{Wj as f}from"./chunk-sddrv3ep.js";import{Xj as R}from"./chunk-jgxhv36z.js";import{Yj as $}from"./chunk-bhqrqt97.js";import"./chunk-kgr3ytpb.js";import{lk as M,mk as V}from"./chunk-9deae0n7.js";import{rk as C,tk as _}from"./chunk-6gjn8trh.js";import"./chunk-sfmhbk59.js";import{xk as k}from"./chunk-75x3w5hx.js";import{Ek as L}from"./chunk-7kdz1eng.js";import{Fk as D}from"./chunk-6ab9eftx.js";import"./chunk-8tnq43k9.js";var O="v1",g=new Set(["openai","openai-codex","opencode","azure-openai-responses"]),A=16;function T(w){let G=new Map;if(!w)return G;for(let j of w.split(",")){let Q=j.trim();if(!Q)continue;let[W,J]=Q.split("=",2);if(!W||!J)continue;G.set(W.trim(),J.trim())}return G}function I(w,G){if(G?.azureDeploymentName)return G.azureDeploymentName;return T($("AZURE_OPENAI_DEPLOYMENT_NAME_MAP",G?.env)).get(w.id)||w.id}function b(w){return V(M(w),"Azure OpenAI API error")}var y=(w,G,j)=>{let Q=new D;return(async()=>{let W=I(w,j),J={role:"assistant",content:[],api:"azure-openai-responses",provider:w.provider,model:w.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let X=j?.apiKey;if(!X)throw Error(`No API key for provider: ${w.provider}`);let Y=U(w,X,j),F=C(G.tools,w.compat?.supportsOpenAIGrammarTools??!1),q=x(w,G,j,W,F),H=await j?.onPayload?.(q,w);if(H!==void 0)q=H;let K={...j?.signal?{signal:j.signal}:{},...j?.timeoutMs!==void 0?{timeout:j.timeoutMs}:{},maxRetries:0},{data:B,response:Z}=await R(()=>Y.responses.create(q,K).withResponse(),{maxRetries:j?.maxRetries,maxRetryDelayMs:j?.maxRetryDelayMs,signal:j?.signal});if(await j?.onResponse?.({status:Z.status,headers:k(Z.headers)},w),Q.push({type:"start",partial:J}),await E(B,J,Q,w,{grammarToolInputProperties:F}),j?.signal?.aborted)throw Error("Request was aborted");if(J.stopReason==="aborted"||J.stopReason==="error")throw Error("An unknown error occurred");Q.push({type:"done",reason:J.stopReason,message:J}),Q.end()}catch(X){for(let Y of J.content)delete Y.index,delete Y.partialJson,delete Y.customInput;J.stopReason=j?.signal?.aborted?"aborted":"error",J.errorMessage=b(X),Q.push({type:"error",reason:J.stopReason,error:J}),Q.end()}})(),Q},t=(w,G,j)=>{let Q=j?.apiKey;if(!Q)throw Error(`No API key for provider: ${w.provider}`);let W=_(w,G,j,Q),J=j?.reasoning?L(w,j.reasoning):void 0;return y(w,G,{...W,reasoningEffort:J==="off"?void 0:J})};function v(w){let G=w.trim().replace(/\/+$/,""),j;try{j=new URL(G)}catch{throw Error(`Invalid Azure OpenAI base URL: ${w}`)}let Q=j.hostname.endsWith(".openai.azure.com")||j.hostname.endsWith(".cognitiveservices.azure.com")||j.hostname.endsWith(".ai.azure.com"),W=j.pathname.replace(/\/+$/,"");if(Q&&(W===""||W==="/"||W==="/openai"||W==="/openai/v1/responses"))j.pathname="/openai/v1",j.search="";return j.toString().replace(/\/+$/,"")}function N(w){return`https://${w}.openai.azure.com/openai/v1`}function P(w,G){let j=G?.azureApiVersion||$("AZURE_OPENAI_API_VERSION",G?.env)||O,Q=G?.azureBaseUrl?.trim()||$("AZURE_OPENAI_BASE_URL",G?.env)?.trim()||void 0,W=G?.azureResourceName||$("AZURE_OPENAI_RESOURCE_NAME",G?.env),J=Q;if(!J&&W)J=N(W);if(!J&&w.baseUrl)J=w.baseUrl;if(!J)throw Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");return{baseUrl:v(J),apiVersion:j}}function U(w,G,j){let Q={...w.headers};if(j?.headers)Object.assign(Q,j.headers);let{baseUrl:W,apiVersion:J}=P(w,j);return new f({apiKey:G,apiVersion:J,dangerouslyAllowBrowser:!0,defaultHeaders:Q,baseURL:W})}function x(w,G,j,Q,W=C(G.tools,w.compat?.supportsOpenAIGrammarTools??!1)){let J=h(w,G,g,{grammarToolInputProperties:W}),X={model:Q,input:J,stream:!0,prompt_cache_key:S(j?.sessionId),store:!1};if(j?.maxTokens)X.max_output_tokens=Math.max(j.maxTokens,A);if(j?.temperature!==void 0)X.temperature=j?.temperature;if(G.tools&&G.tools.length>0)X.tools=z(G.tools,{supportsStrictMode:w.compat?.supportsStrictMode??!0,supportsOpenAIGrammarTools:w.compat?.supportsOpenAIGrammarTools??!1});if(w.reasoning){if(j?.reasoningEffort||j?.reasoningSummary){let Y=j?.reasoningEffort?w.thinkingLevelMap?.[j.reasoningEffort]??j.reasoningEffort:"medium";X.reasoning={effort:Y,summary:j?.reasoningSummary||"auto"},X.include=["reasoning.encrypted_content"]}else if(w.thinkingLevelMap?.off!==null)X.reasoning={effort:w.thinkingLevelMap?.off??"none"}}return X}export{t as streamSimple,y as stream};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Oj as Xq,Pj as Yq}from"./chunk-2jnyk045.js";import{Tj as _q}from"./chunk-s5s1rk4n.js";import{Uj as a}from"./chunk-8qe7cpbr.js";import{Vj as c}from"./chunk-sddrv3ep.js";import{Xj as e}from"./chunk-jgxhv36z.js";import{Yj as t}from"./chunk-bhqrqt97.js";import{_j as C}from"./chunk-kgr3ytpb.js";import{lk as n,mk as s}from"./chunk-9deae0n7.js";import{nk as o,ok as qq,pk as Jq,qk as Qq,rk as u,tk as $q,vk as Zq}from"./chunk-6gjn8trh.js";import{wk as M}from"./chunk-sfmhbk59.js";import{xk as l}from"./chunk-75x3w5hx.js";import{Dk as i,Ek as m}from"./chunk-7kdz1eng.js";import{Fk as d}from"./chunk-6ab9eftx.js";import"./chunk-8tnq43k9.js";function g(q,Q){if(!q)return!1;let J=Q.toLowerCase();for(let[X,Y]of Object.entries(q))if(X.toLowerCase()===J&&Y!==null&&Y.trim().length>0)return!0;return!1}function Kq(q,Q,J){if(Q)return Q;if(g(J,"authorization")||g(J,"cf-aig-authorization"))return"unused";throw Error(`No API key for provider: ${q}`)}function Fq(q){for(let Q of q){if(Q.role==="toolResult")return!0;if(Q.role==="assistant"){if(Q.content.some((J)=>J.type==="toolCall"))return!0}}return!1}function Nq(q){let Q=new Set;for(let J of q)if(J.role==="toolResult")for(let X of J.addedToolNames??[])Q.add(X);return Q}function Aq(q,Q){if(!q)return[];let J=new Map(q.map((X)=>[X.name,X]));return Array.from(Q).map((X)=>J.get(X)).filter((X)=>X!==void 0)}function r(q){return q.type==="text"}function Eq(q){return q.type==="thinking"}function Dq(q){return q.type==="toolCall"}function Pq(q){return q.type==="image"}function wq(q){if(typeof q!=="object"||q===null)return!1;let Q=q;return Q.type==="reasoning.encrypted"&&typeof Q.id==="string"&&Q.id.length>0&&typeof Q.data==="string"&&Q.data.length>0}function jq(q,Q){if(q)return q;if(t("PI_CACHE_RETENTION",Q)==="long")return"long";return"short"}var Uq=(q,Q,J)=>{let X=new d;return(async()=>{let Y={role:"assistant",content:[],api:q.api,provider:q.provider,model:q.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:Date.now()};try{let V=Kq(q.provider,J?.apiKey,J?.headers),j=h(q),F=u(Q.tools,j.supportsOpenAIGrammarTools),$=jq(J?.cacheRetention,J?.env),W=$==="none"?void 0:J?.sessionId,z=Bq(q,Q,V,J?.headers,W,j),Z=yq(q,Q,J,j,$,F),S=await J?.onPayload?.(Z,q);if(S!==void 0)Z=S;let O={...J?.signal?{signal:J.signal}:{},...J?.timeoutMs!==void 0?{timeout:J.timeoutMs}:{},maxRetries:0},{data:P,response:U}=await e(()=>z.chat.completions.create(Z,O).withResponse(),{maxRetries:J?.maxRetries,maxRetryDelayMs:J?.maxRetryDelayMs,signal:J?.signal});await J?.onResponse?.({status:U.status,headers:l(U.headers)},q),X.push({type:"start",partial:Y});let B=null,G=null,N=!1,D=new Map,T=new Map,x=new Map,f=Y.content,v=(_)=>f.indexOf(_),b=(_)=>{let K=_.customInput?.property;if(K===void 0)return"";let E=_.arguments[K];return typeof E==="string"?E:""},k=(_,K,E)=>{let H=_.customInput;if(!H)return;let w=qq(H.jsonBuffer,H.property,K,E);return _.arguments={[H.property]:K},w},Lq=(_)=>{let K=v(_);if(K===-1)return;if(_.type==="text")X.push({type:"text_end",contentIndex:K,content:_.text,partial:Y});else if(_.type==="thinking")X.push({type:"thinking_end",contentIndex:K,content:_.thinking,partial:Y});else if(_.type==="toolCall"){if(_.customInput){let E=k(_,b(_),!0);if(E!==void 0)X.push({type:"toolcall_delta",contentIndex:K,delta:E,partial:Y})}else _.arguments=C(_.partialArgs);delete _.partialArgs,delete _.customInput,delete _.streamIndex,X.push({type:"toolcall_end",contentIndex:K,toolCall:_,partial:Y})}},Vq=()=>{if(!B)B={type:"text",text:""},f.push(B),X.push({type:"text_start",contentIndex:v(B),partial:Y});return B},Wq=(_)=>{if(!G)G={type:"thinking",thinking:"",thinkingSignature:_},f.push(G),X.push({type:"thinking_start",contentIndex:v(G),partial:Y});return G},Gq=(_)=>{if(!_.id)return;let K=x.get(_.id);if(K)_.thoughtSignature=K,x.delete(_.id)},Sq=(_)=>{let K=typeof _.index==="number"?_.index:void 0,E=_.function?.name??_.custom?.name??"",H=K!==void 0?D.get(K):void 0;if(!H&&_.id)H=T.get(_.id);if(!H){let w=_.custom?F.get(E)??"input":void 0,R=w!==void 0;if(H={type:"toolCall",id:_.id||"",name:E,arguments:R?{[w]:""}:{},partialArgs:R?void 0:"",customInput:R?{property:w,jsonBuffer:{input:"",started:!1,closed:!1}}:void 0,streamIndex:K},K!==void 0)D.set(K,H);if(_.id)T.set(_.id,H);f.push(H),X.push({type:"toolcall_start",contentIndex:v(H),partial:Y})}if(K!==void 0&&H.streamIndex===void 0)H.streamIndex=K,D.set(K,H);if(_.id)T.set(_.id,H);if(!H.name&&E)H.name=E;if(_.custom&&!H.customInput){let w=F.get(H.name)??"input";H.arguments={[w]:""},H.customInput={property:w,jsonBuffer:{input:"",started:!1,closed:!1}},delete H.partialArgs}return Gq(H),H};for await(let _ of P){if(!_||typeof _!=="object")continue;if(Y.responseId||=_.id,typeof _.model==="string"&&_.model.length>0&&_.model!==q.id)Y.responseModel||=_.model;if(_.usage)Y.usage=p(_.usage,q);let K=Array.isArray(_.choices)?_.choices[0]:void 0;if(!K)continue;if(!_.usage&&K.usage)Y.usage=p(K.usage,q);if(K.finish_reason){let E=bq(K.finish_reason);if(Y.stopReason=E.stopReason,E.errorMessage)Y.errorMessage=E.errorMessage;N=!0}if(K.delta){if(K.delta.content!==null&&K.delta.content!==void 0&&K.delta.content.length>0){let L=Vq();L.text+=K.delta.content,X.push({type:"text_delta",contentIndex:v(L),delta:K.delta.content,partial:Y})}let E=["reasoning_content","reasoning","reasoning_text"],H=K.delta,w=null;for(let L of E){let A=H[L];if(typeof A==="string"&&A.length>0){w=L;break}}if(w){let L=H[w];if(typeof L==="string"&&L.length>0){let A=q.provider==="opencode-go"&&w==="reasoning"?"reasoning_content":w,y=Wq(A);y.thinking+=L,X.push({type:"thinking_delta",contentIndex:v(y),delta:L,partial:Y})}}if(K?.delta?.tool_calls)for(let L of K.delta.tool_calls){let A=Sq(L);if(!A.id&&L.id)A.id=L.id,T.set(L.id,A);let y=L.function?.name??L.custom?.name;if(!A.name&&y)A.name=y;let I="";if(L.function?.arguments)I=L.function.arguments,A.partialArgs=(A.partialArgs??"")+L.function.arguments,A.arguments=C(A.partialArgs);else if(L.custom?.input){let Oq=b(A)+L.custom.input;I=k(A,Oq,!1)??""}X.push({type:"toolcall_delta",contentIndex:v(A),delta:I,partial:Y})}let R=K.delta.reasoning_details;if(Array.isArray(R)){for(let L of R)if(wq(L)){let A=JSON.stringify(L),y=T.get(L.id);if(y)y.thoughtSignature=A;else x.set(L.id,A)}}}}for(let _ of f)Lq(_);if(J?.signal?.aborted)throw Error("Request was aborted");if(Y.stopReason==="aborted")throw Error("Request was aborted");if(Y.stopReason==="error")throw Error(Y.errorMessage||"Provider returned an error stop reason");if(!N)throw Error("Stream ended without finish_reason");X.push({type:"done",reason:Y.stopReason,message:Y}),X.end()}catch(V){for(let F of Y.content)delete F.index,delete F.partialArgs,delete F.customInput,delete F.streamIndex;Y.stopReason=J?.signal?.aborted?"aborted":"error",Y.errorMessage=s(n(V));let j=V?.error?.metadata?.raw;if(j&&!Y.errorMessage.includes(String(j)))Y.errorMessage+=`
|
|
3
|
+
${j}`;X.push({type:"error",reason:Y.stopReason,error:Y}),X.end()}})(),X},JJ=(q,Q,J)=>{Kq(q.provider,J?.apiKey,J?.headers);let X=$q(q,Q,J,J?.apiKey),Y=J?.reasoning?m(q,J.reasoning):void 0,V=Y==="off"?void 0:Y,j=J?.toolChoice;return Uq(q,Q,{...X,reasoningEffort:V,toolChoice:j})};function Bq(q,Q,J,X,Y,V=h(q)){let j={...q.headers};if(q.provider==="github-copilot"){let F=Xq(Q.messages),$=Yq({messages:Q.messages,hasImages:F});Object.assign(j,$)}if(Y&&V.sendSessionAffinityHeaders)if(V.sessionAffinityFormat==="openrouter")j["x-session-id"]=Y;else{if(V.sessionAffinityFormat==="openai")j.session_id=Y;j["x-client-request-id"]=Y,j["x-session-affinity"]=Y}if(X)Object.assign(j,X);return new c({apiKey:J,baseURL:q.baseUrl,dangerouslyAllowBrowser:!0,defaultHeaders:j})}function yq(q,Q,J,X=h(q),Y=jq(J?.cacheRetention,J?.env),V=u(Q.tools,X.supportsOpenAIGrammarTools)){let j=hq(q,Q,X,{grammarToolInputProperties:V}),F=Rq(X,Y),$={model:q.id,messages:j,stream:!0,prompt_cache_key:q.baseUrl.includes("api.openai.com")&&Y!=="none"||Y==="long"&&X.supportsLongCacheRetention?_q(J?.sessionId):void 0,prompt_cache_retention:Y==="long"&&X.supportsLongCacheRetention?"24h":void 0};if(X.supportsUsageInStreaming!==!1)$.stream_options={include_usage:!0};if(X.supportsStore)$.store=!1;if(J?.maxTokens)if(X.maxTokensField==="max_tokens")$.max_tokens=J.maxTokens;else $.max_completion_tokens=J.maxTokens;if(J?.temperature!==void 0)$.temperature=J.temperature;let W=X.deferredToolsMode==="kimi"?Nq(Q.messages):new Set,z=Q.tools?.filter((Z)=>!W.has(Z.name));if(z&&z.length>0){if($.tools=Hq(z,X),X.zaiToolStream)$.tool_stream=!0}else if(Fq(Q.messages))$.tools=[];if(F)Tq(j,$.tools,F);if(J?.toolChoice)$.tool_choice=J.toolChoice;if(X.thinkingFormat==="zai"&&q.reasoning){let Z=$;if(Z.thinking=J?.reasoningEffort?{type:"enabled",clear_thinking:!1}:{type:"disabled"},J?.reasoningEffort&&X.supportsReasoningEffort){let S=q.thinkingLevelMap?.[J.reasoningEffort],O=S===void 0?J.reasoningEffort:S;if(typeof O==="string")Z.reasoning_effort=O}}else if(X.thinkingFormat==="qwen"&&q.reasoning)$.enable_thinking=!!J?.reasoningEffort;else if(X.thinkingFormat==="qwen-chat-template"&&q.reasoning)$.chat_template_kwargs={enable_thinking:!!J?.reasoningEffort,preserve_thinking:!0};else if(X.thinkingFormat==="chat-template"&&q.reasoning){let Z=Mq(q,J,X);if(Z)$.chat_template_kwargs=Z}else if(X.thinkingFormat==="deepseek"&&q.reasoning){if(J?.reasoningEffort)$.thinking={type:"enabled"};else if(q.thinkingLevelMap?.off!==null)$.thinking={type:"disabled"};if(J?.reasoningEffort&&X.supportsReasoningEffort)$.reasoning_effort=q.thinkingLevelMap?.[J.reasoningEffort]??J.reasoningEffort}else if(X.thinkingFormat==="openrouter"&&q.reasoning){let Z=$;if(J?.reasoningEffort)Z.reasoning={effort:q.thinkingLevelMap?.[J.reasoningEffort]??J.reasoningEffort};else if(q.thinkingLevelMap?.off!==null)Z.reasoning={effort:q.thinkingLevelMap?.off??"none"}}else if(X.thinkingFormat==="ant-ling"&&q.reasoning&&J?.reasoningEffort){let Z=q.thinkingLevelMap?.[J.reasoningEffort];if(typeof Z==="string")$.reasoning={effort:Z}}else if(X.thinkingFormat==="together"&&q.reasoning){let Z=$;if(Z.reasoning={enabled:!!J?.reasoningEffort},J?.reasoningEffort&&X.supportsReasoningEffort)Z.reasoning_effort=q.thinkingLevelMap?.[J.reasoningEffort]??J.reasoningEffort}else if(X.thinkingFormat==="string-thinking"&&q.reasoning){let Z=$;if(J?.reasoningEffort)Z.thinking=q.thinkingLevelMap?.[J.reasoningEffort]??J.reasoningEffort;else if(q.thinkingLevelMap?.off!==null)Z.thinking=q.thinkingLevelMap?.off??"none"}else if(J?.reasoningEffort&&q.reasoning&&X.supportsReasoningEffort)$.reasoning_effort=q.thinkingLevelMap?.[J.reasoningEffort]??J.reasoningEffort;else if(!J?.reasoningEffort&&q.reasoning&&X.supportsReasoningEffort){let Z=q.thinkingLevelMap?.off;if(typeof Z==="string")$.reasoning_effort=Z}if(q.compat?.openRouterRouting)$.provider=q.compat.openRouterRouting;if(q.compat?.vercelGatewayRouting){let Z=q.compat.vercelGatewayRouting;if(Z.only||Z.order){let S={};if(Z.only)S.only=Z.only;if(Z.order)S.order=Z.order;$.providerOptions={gateway:S}}}return $}function Mq(q,Q,J){let X={};for(let[Y,V]of Object.entries(J.chatTemplateKwargs)){let j=vq(q,Q,V);if(j!==void 0)X[Y]=j}return Object.keys(X).length>0?X:void 0}function vq(q,Q,J){if(typeof J!=="object"||J===null)return J;let X=Q?.reasoningEffort;if(!X&&J.omitWhenOff)return;if(J.$var==="thinking.enabled")return!!X;let Y=X?q.thinkingLevelMap?.[X]:q.thinkingLevelMap?.off;return Y===void 0?X:typeof Y==="string"?Y:void 0}function Rq(q,Q){if(q.cacheControlFormat!=="anthropic"||Q==="none")return;let J=Q==="long"&&q.supportsLongCacheRetention?"1h":void 0;return{type:"ephemeral",...J?{ttl:J}:{}}}function Tq(q,Q,J){fq(q,J),Iq(Q,J),xq(q,J)}function fq(q,Q){for(let J of q)if(J.role==="system"||J.role==="developer"){Cq(J,Q);return}}function xq(q,Q){for(let J=q.length-1;J>=0;J--){let X=q[J];if(X.role==="user"||X.role==="assistant"||X.role==="tool"){if(uq(X,Q))return}}}function Iq(q,Q){if(!q||q.length===0)return;let J=q[q.length-1];J.cache_control=Q}function Cq(q,Q){return zq(q,Q)}function uq(q,Q){if(q.role==="user"||q.role==="assistant"||q.role==="tool")return zq(q,Q);return!1}function zq(q,Q){let J=q.content;if(typeof J==="string"){if(J.length===0)return!1;return q.content=[{type:"text",text:J,cache_control:Q}],!0}if(!Array.isArray(J))return!1;for(let X=J.length-1;X>=0;X--){let Y=J[X];if(Y?.type==="text"){let V=Y;return V.cache_control=Q,!0}}return!1}function hq(q,Q,J,X){let Y=[],V=($)=>{if($.includes("|")){let W=$.indexOf("|"),z=$.slice(0,W).replace(/[^a-zA-Z0-9_-]/g,"_"),Z=$.slice(W+1).replace(/[^a-zA-Z0-9_-]/g,"_"),S=Z.length>0?`${z}_${Z}`:z;if(S.length<=40)return S;let O=a($).slice(0,8);return`${z.slice(0,Math.max(1,40-O.length-1))}_${O}`}if(q.provider==="openai")return $.length>40?$.slice(0,40):$;return $},j=Zq(Q.messages,q,($)=>V($));if(Q.systemPrompt){let W=q.reasoning&&J.supportsDeveloperRole?"developer":"system";Y.push({role:W,content:M(Q.systemPrompt)})}let F=null;for(let $=0;$<j.length;$++){let W=j[$];if(J.requiresAssistantAfterToolResult&&F==="toolResult"&&W.role==="user")Y.push({role:"assistant",content:"I have processed the tool results."});if(W.role==="user")if(typeof W.content==="string")Y.push({role:"user",content:M(W.content)});else{let z=W.content.map((Z)=>{if(Z.type==="text")return{type:"text",text:M(Z.text)};else return{type:"image_url",image_url:{url:`data:${Z.mimeType};base64,${Z.data}`}}});if(z.length===0)continue;Y.push({role:"user",content:z})}else if(W.role==="assistant"){let z={role:"assistant",content:J.requiresAssistantAfterToolResult?"":null},Z=W.content.filter(r).filter((G)=>G.text.trim().length>0).map((G)=>({type:"text",text:M(G.text)})),S=Z.map((G)=>G.text).join(""),O=W.content.filter(Eq).filter((G)=>G.thinking.trim().length>0);if(O.length>0)if(J.requiresThinkingAsText){let G=O.map((N)=>M(N.thinking)).join(`
|
|
4
|
+
|
|
5
|
+
`);z.content=[{type:"text",text:G},...Z]}else{if(S.length>0)z.content=S;let G=O[0].thinkingSignature;if(q.provider==="opencode-go"&&G==="reasoning")G="reasoning_content";if(G&&G.length>0)z[G]=O.map((N)=>N.thinking).join(`
|
|
6
|
+
`)}else if(S.length>0)z.content=S;let P=W.content.filter(Dq);if(P.length>0){z.tool_calls=P.map((N)=>{let D=X?.grammarToolInputProperties?.get(N.name);if(D!==void 0)return{id:N.id,type:"custom",custom:{name:N.name,input:M(o(N.name,N.arguments,D))}};return{id:N.id,type:"function",function:{name:N.name,arguments:JSON.stringify(N.arguments)}}});let G=P.filter((N)=>N.thoughtSignature).map((N)=>{try{return JSON.parse(N.thoughtSignature)}catch{return null}}).filter(Boolean);if(G.length>0)z.reasoning_details=G}if(J.requiresReasoningContentOnAssistantMessages&&q.reasoning&&z.reasoning_content===void 0)z.reasoning_content="";let U=z.content;if(!(U!==null&&U!==void 0&&(typeof U==="string"?U.length>0:U.length>0))&&!z.tool_calls)continue;Y.push(z)}else if(W.role==="toolResult"){let z=[],Z=new Set,S=$;for(;S<j.length&&j[S].role==="toolResult";S++){let O=j[S],P=O.content.filter(r).map((D)=>D.text).join(`
|
|
7
|
+
`),U=O.content.some((D)=>D.type==="image"),G=P.length>0?P:U?"(see attached image)":"(no tool output)",N={role:"tool",content:M(G),tool_call_id:O.toolCallId};if(J.requiresToolResultName&&O.toolName)N.name=O.toolName;if(Y.push(N),J.deferredToolsMode==="kimi")for(let D of O.addedToolNames??[])Z.add(D);if(U&&q.input.includes("image")){for(let D of O.content)if(Pq(D))z.push({type:"image_url",image_url:{url:`data:${D.mimeType};base64,${D.data}`}})}}if($=S-1,z.length>0){if(J.requiresAssistantAfterToolResult)Y.push({role:"assistant",content:"I have processed the tool results."});Y.push({role:"user",content:[{type:"text",text:"Attached image(s) from tool result:"},...z]}),F="user"}else F="toolResult";if(Z.size>0){let O=Aq(Q.tools,Z);if(O.length>0){let P={role:"system",tools:Hq(O,J)};Y.push(P)}}continue}F=W.role}return Y}function Hq(q,Q){return q.map((J)=>{let X=Qq(J,Q.supportsOpenAIGrammarTools);if(X)return{type:"custom",custom:{name:J.name,description:J.description,format:{type:"grammar",grammar:{syntax:X.format,definition:X.definition}}}};let Y=Jq(J,Q.supportsStrictMode!==!1);return{type:"function",function:{name:J.name,description:J.description,parameters:J.parameters,...Q.supportsStrictMode!==!1&&{strict:Y??!1}}}})}function p(q,Q){let J=q.prompt_tokens||0,X=q.prompt_tokens_details?.cached_tokens??q.prompt_cache_hit_tokens??0,Y=q.prompt_tokens_details?.cache_write_tokens||0,V=Math.max(0,J-X-Y),j=q.completion_tokens||0,F={input:V,output:j,cacheRead:X,cacheWrite:Y,reasoning:q.completion_tokens_details?.reasoning_tokens||0,totalTokens:V+j+X+Y,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}};return i(Q,F),F}function bq(q){if(q===null)return{stopReason:"stop"};switch(q){case"stop":case"end":return{stopReason:"stop"};case"length":return{stopReason:"length"};case"function_call":case"tool_calls":return{stopReason:"toolUse"};case"content_filter":return{stopReason:"error",errorMessage:"Provider finish_reason: content_filter"};case"network_error":return{stopReason:"error",errorMessage:"Provider finish_reason: network_error"};default:return{stopReason:"error",errorMessage:`Provider finish_reason: ${q}`}}}function kq(q){let{provider:Q,baseUrl:J}=q,X=Q==="zai"||Q==="zai-coding-cn"||J.includes("api.z.ai")||J.includes("open.bigmodel.cn"),Y=Q==="together"||J.includes("api.together.ai")||J.includes("api.together.xyz"),V=Q==="moonshotai"||Q==="moonshotai-cn"||J.includes("api.moonshot."),j=Q==="openrouter"||J.includes("openrouter.ai"),F=Q==="cloudflare-workers-ai"||J.includes("api.cloudflare.com"),$=Q==="cloudflare-ai-gateway"||J.includes("gateway.ai.cloudflare.com"),W=Q==="nvidia"||J.includes("integrate.api.nvidia.com"),z=Q==="ant-ling"||J.includes("api.ant-ling.com"),Z=W||Q==="cerebras"||J.includes("cerebras.ai")||Q==="xai"||J.includes("api.x.ai")||Y||J.includes("chutes.ai")||J.includes("deepseek.com")||X||V||Q==="opencode"||J.includes("opencode.ai")||F||$||z,S=J.includes("chutes.ai")||V||$||Y||W||z,O=Q==="xai"||J.includes("api.x.ai"),P=Q==="deepseek"||J.includes("deepseek.com"),U=j&&(q.id.startsWith("anthropic/")||q.id.startsWith("openai/")),B=Q==="openrouter"&&q.id.startsWith("anthropic/")?"anthropic":void 0;return{supportsStore:!Z,supportsDeveloperRole:U||!Z&&!j,supportsReasoningEffort:!O&&!X&&!V&&!Y&&!$&&!W&&!z,supportsUsageInStreaming:!0,maxTokensField:S?"max_tokens":"max_completion_tokens",requiresToolResultName:!1,requiresAssistantAfterToolResult:!1,requiresThinkingAsText:!1,requiresReasoningContentOnAssistantMessages:P,thinkingFormat:P?"deepseek":X?"zai":Y?"together":z?"ant-ling":j?"openrouter":"openai",openRouterRouting:{},vercelGatewayRouting:{},chatTemplateKwargs:{},zaiToolStream:!1,supportsStrictMode:!V&&!Y&&!$&&!W,supportsOpenAIGrammarTools:!1,cacheControlFormat:B,sendSessionAffinityHeaders:!1,deferredToolsMode:void 0,sessionAffinityFormat:j?"openrouter":"openai",supportsLongCacheRetention:!(Y||F||$||W||z)}}function h(q){let Q=kq(q);if(!q.compat)return Q;return{supportsStore:q.compat.supportsStore??Q.supportsStore,supportsDeveloperRole:q.compat.supportsDeveloperRole??Q.supportsDeveloperRole,supportsReasoningEffort:q.compat.supportsReasoningEffort??Q.supportsReasoningEffort,supportsUsageInStreaming:q.compat.supportsUsageInStreaming??Q.supportsUsageInStreaming,maxTokensField:q.compat.maxTokensField??Q.maxTokensField,requiresToolResultName:q.compat.requiresToolResultName??Q.requiresToolResultName,requiresAssistantAfterToolResult:q.compat.requiresAssistantAfterToolResult??Q.requiresAssistantAfterToolResult,requiresThinkingAsText:q.compat.requiresThinkingAsText??Q.requiresThinkingAsText,requiresReasoningContentOnAssistantMessages:q.compat.requiresReasoningContentOnAssistantMessages??Q.requiresReasoningContentOnAssistantMessages,thinkingFormat:q.compat.thinkingFormat??Q.thinkingFormat,openRouterRouting:q.compat.openRouterRouting??{},vercelGatewayRouting:q.compat.vercelGatewayRouting??Q.vercelGatewayRouting,chatTemplateKwargs:q.compat.chatTemplateKwargs??Q.chatTemplateKwargs,zaiToolStream:q.compat.zaiToolStream??Q.zaiToolStream,supportsStrictMode:q.compat.supportsStrictMode??Q.supportsStrictMode,supportsOpenAIGrammarTools:q.compat.supportsOpenAIGrammarTools??Q.supportsOpenAIGrammarTools,cacheControlFormat:q.compat.cacheControlFormat??Q.cacheControlFormat,sendSessionAffinityHeaders:q.compat.sendSessionAffinityHeaders??Q.sendSessionAffinityHeaders,deferredToolsMode:q.compat.deferredToolsMode??Q.deferredToolsMode,sessionAffinityFormat:q.compat.sessionAffinityFormat??Q.sessionAffinityFormat,supportsLongCacheRetention:q.compat.supportsLongCacheRetention??Q.supportsLongCacheRetention}}export{JJ as streamSimple,Uq as stream,hq as convertMessages};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Bg as z,Cg as F,gj as L,uj as O,xj as R}from"./chunk-ersxsrz8.js";import{Mk as m}from"./chunk-8tnq43k9.js";function d(a,b){var g=a.length;a.push(b);a:for(;0<g;){var w=g-1>>>1,V=a[w];if(0<Q(V,b))a[w]=b,a[g]=V,g=w;else break a}}function N(a){return a.length===0?null:a[0]}function M(a){if(a.length===0)return null;var b=a[0],g=a.pop();if(g!==b){a[0]=g;a:for(var w=0,V=a.length,G=V>>>1;w<G;){var Y=2*(w+1)-1,D=a[Y],B=Y+1,q=a[B];if(0>Q(D,g))B<V&&0>Q(q,D)?(a[w]=q,a[B]=g,w=B):(a[w]=D,a[Y]=g,w=Y);else if(B<V&&0>Q(q,g))a[w]=q,a[B]=g,w=B;else break a}}return b}function Q(a,b){var g=a.sortIndex-b.sortIndex;return g!==0?g:a.id-b.id}function U(a){for(var b=N(C);b!==null;){if(b.callback===null)M(C);else if(b.startTime<=a)M(C),b.sortIndex=b.expirationTime,d(f,b);else break;b=N(C)}}function T(a){if(Z=!1,U(a),!X)if(N(f)!==null)X=!0,K||(K=!0,J());else{var b=N(C);b!==null&&j(T,b.startTime-a)}}function h(){return k?!0:A()-x<l?!1:!0}function W(){if(k=!1,K){var a=A();x=a;var b=!0;try{a:{X=!1,Z&&(Z=!1,s($),$=-1),y=!0;var g=E;try{b:{U(a);for(_=N(f);_!==null&&!(_.expirationTime>a&&h());){var w=_.callback;if(typeof w==="function"){_.callback=null,E=_.priorityLevel;var V=w(_.expirationTime<=a);if(a=A(),typeof V==="function"){_.callback=V,U(a),b=!0;break b}_===N(f)&&M(f),U(a)}else M(f);_=N(f)}if(_!==null)b=!0;else{var G=N(C);G!==null&&j(T,G.startTime-a),b=!1}}break a}finally{_=null,E=g,y=!1}b=void 0}}finally{b?J():K=!1}}}function j(a,b){$=u(function(){a(A())},b)}var A=void 0,P,H,t,f,C,o=1,_=null,E=3,y=!1,X=!1,Z=!1,k=!1,u,s,c,K=!1,$=-1,l=5,x=-1,J,v,I,p=5,i=1,r=4,e=3,aa=2,ba=function(a){a.callback=null},za=function(){return E},ga=function(){k=!0},wa=function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var g=E;E=a;try{return b()}finally{E=g}},Va=function(a,b,g){var w=A();switch(typeof g==="object"&&g!==null?(g=g.delay,g=typeof g==="number"&&0<g?w+g:w):g=w,a){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5000}return V=g+V,a={id:o++,callback:b,priorityLevel:a,startTime:g,expirationTime:V,sortIndex:-1},g>w?(a.sortIndex=g,d(C,a),N(f)===null&&a===N(C)&&(Z?(s($),$=-1):Z=!0,j(T,g-w))):(a.sortIndex=V,d(f,a),X||y||(X=!0,K||(K=!0,J()))),a},_a;var Na=m(()=>{if(typeof performance==="object"&&typeof performance.now==="function")P=performance,A=function(){return P.now()};else H=Date,t=H.now(),A=function(){return H.now()-t};f=[],C=[],u=typeof setTimeout==="function"?setTimeout:null,s=typeof clearTimeout==="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;if(typeof c==="function")J=function(){c(W)};else if(typeof MessageChannel<"u")v=new MessageChannel,I=v.port2,v.port1.onmessage=W,J=function(){I.postMessage(null)};else J=function(){u(W,0)};_a=h});function Ba({className:a,orientation:b="horizontal",...g}){return z(O.Root,{"data-slot":"tabs","data-orientation":b,orientation:b,className:R("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",a),...g})}var n=L("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function Ea({className:a,variant:b="default",...g}){return z(O.List,{"data-slot":"tabs-list","data-variant":b,className:R(n({variant:b}),a),...g})}function Fa({className:a,...b}){return z(O.Trigger,{"data-slot":"tabs-trigger",className:R("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",a),...b})}function Ja({className:a,...b}){return z(O.Content,{"data-slot":"tabs-content",className:R("flex-1 outline-none",a),...b})}var S={viewBox:"0 -960 960 960",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},Ra=(a)=>z("svg",{...S,...a,children:z("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm120-80v-560H200v560h120Zm80 0h360v-560H400v560Z"})}),Xa=(a)=>z("svg",{...S,...a,children:z("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm360-80v-560H200v560h360Zm200 0v-560H640v560h120Z"})}),Za=(a)=>z("svg",{...S,...a,children:z("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm560-80v-560H400v560h360Z"})}),$a=(a)=>z("svg",{...S,...a,children:z("path",{d:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm360-80v-560H200v560h360Z"})}),Ga=(a)=>F("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...a,children:[z("path",{d:"M12 8V4H8"}),z("path",{d:"M6 7H18A3 3 0 0 1 21 10V18A3 3 0 0 1 18 21H6A3 3 0 0 1 3 18V10A3 3 0 0 1 6 7ZM8 13V15A1 1 0 0 0 10 15V13A1 1 0 0 0 8 13ZM14 13V15A1 1 0 0 0 16 15V13A1 1 0 0 0 14 13Z",fill:"currentColor",stroke:"none"}),z("path",{d:"M2 14h2"}),z("path",{d:"M20 14h2"})]}),Ya=(a)=>z("svg",{xmlns:"http://www.w3.org/2000/svg",width:30,height:30,viewBox:"120 -792 720 720",fill:"none","aria-hidden":"true",focusable:"false",...a,children:z("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M 160 -180 v -72 h 80 v -252 q 0 -74.7 50 -132.75 T 420 -712.8 v -25.2 q 0 -22.5 17.5 -38.25 T 480 -792 q 25 0 42.5 15.75 T 540 -738 v 25.2 q 80 18 130 76.05 T 720 -504 v 252 h 80 v 72 H 160 Z M 480 -72 q -33 0 -56.5 -21.15 T 400 -144 h 160 q 0 29.7 -23.5 50.85 T 480 -72 Z",fill:"currentColor"})}),qa=(a)=>F("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",focusable:"false",...a,children:[z("path",{d:"M10.77 10.377a1 1 0 0 0-.132.437l-.105 1.665a.5.5 0 0 0 .793.436l1.32-.96a1 1 0 0 0 .278-.309l3.912-6.775a1.25 1.25 0 1 0-2.165-1.25l-3.901 6.756Z",fill:"currentColor"}),z("path",{d:"M11.016 6.75a.758.758 0 0 1-.758.748c-2.938 0-4.882 1.71-5.517 3.95-.708 2.499.245 4.459 1.979 5.851 1.767 1.42 4.31 2.203 6.547 2.203.415 0 .749.335.745.748a.758.758 0 0 1-.758.748c-2.536 0-5.421-.873-7.485-2.531-2.098-1.686-3.38-4.225-2.475-7.414.818-2.883 3.354-5.051 6.977-5.051.415 0 .749.335.745.748Z",fill:"currentColor"}),z("path",{d:"M17.147 8.315a.767.767 0 0 1 1.058-.168c1.666 1.188 2.508 2.542 2.733 3.876a4.5 4.5 0 0 1-.805 3.392c-.919 1.434-2.714 2.074-4.479 2.185-1.799.113-3.78-.302-5.292-1.216a.733.733 0 0 1-.242-1.022.768.768 0 0 1 1.042-.246c1.216.734 2.881 1.096 4.409 1 1.553-.097 2.755-.647 3.292-1.5l.015-.022.015-.021a3.025 3.025 0 0 0 .553-2.294c-.148-.876-.72-1.915-2.137-2.926a.733.733 0 0 1-.162-1.038Z",fill:"currentColor"})]}),Sa=(a)=>{return F("svg",{viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a,children:[z("defs",{children:z("clipPath",{id:"bg-clip",children:z("rect",{x:"5",y:"5",width:"90",height:"90",rx:"22"})})}),z("rect",{x:"5",y:"5",width:"90",height:"90",rx:"22",fill:"#D95A66"}),z("path",{d:"M 35 75 L 65 75 L 80 60 L 75 30 L 175 130 L 135 175 Z",fill:"#A8384D",clipPath:"url(#bg-clip)"}),z("path",{d:"M 25 30 Q 38 36 50 42 L 35 55 L 35 75 L 20 60 Z",fill:"#FDF0D5"}),z("path",{d:"M 50 42 Q 62 36 75 30 L 80 60 L 65 75 L 65 55 Z",fill:"#E77A65"}),z("path",{d:"M 35 75 L 65 75 L 65 55 L 50 42 L 35 55 Z",fill:"#F5B895"}),z("path",{d:"M 50 42 Q 38 36 25 30 Q 38 26 50 20 Q 62 26 75 30 Q 62 36 50 42 Z",fill:"#F4B8B8"}),z("path",{d:"M 50 25 L 42 30 L 50 35 Z",fill:"#E57A5F"}),z("path",{d:"M 50 25 L 58 30 L 50 35 Z",fill:"#C2523C"})]})},Qa=(a)=>z("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"24 24 152 152",fill:"none","aria-hidden":"true",focusable:"false",...a,children:z("path",{d:"M 44 170 L 44 100 L 24 100 L 100 30 L 126 54 L 126 36 L 142 36 L 142 69 L 176 100 L 156 100 L 156 170 L 120 170 L 120 136 A 20 20 0 0 0 80 136 L 80 170 Z",fill:"currentColor"})});function Ha({uploading:a=!1,className:b="",...g}){return F("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"15 15 70 70",width:30,height:30,className:`${b} ${a?"animate-upload-breathing":""}`,"aria-hidden":"true",focusable:"false",style:a?{transformOrigin:"center"}:void 0,...g,children:[a&&z("defs",{children:F("linearGradient",{id:"upload-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[z("stop",{offset:"0%",stopColor:"#3b82f6",children:z("animate",{attributeName:"stop-color",values:"#3b82f6;#ec4899;#8b5cf6;#3b82f6",dur:"3s",repeatCount:"indefinite"})}),z("stop",{offset:"50%",stopColor:"#8b5cf6",children:z("animate",{attributeName:"stop-color",values:"#8b5cf6;#3b82f6;#ec4899;#8b5cf6",dur:"3s",repeatCount:"indefinite"})}),z("stop",{offset:"100%",stopColor:"#ec4899",children:z("animate",{attributeName:"stop-color",values:"#ec4899;#8b5cf6;#3b82f6;#ec4899",dur:"3s",repeatCount:"indefinite"})})]})}),z("path",{d:"M 44.1 75 H 30 A 15 15 0 0 1 30 45 A 20 20 0 0 1 70 45 A 15 15 0 0 1 70 75 H 55.9 V 60.2 H 61.9 L 50 45.3 L 38.1 60.2 H 44.1 Z",fill:a?"url(#upload-gradient)":"currentColor"})]})}
|
|
2
|
+
export{A as Qe,p as Re,i as Se,r as Te,e as Ue,aa as Ve,ba as We,za as Xe,ga as Ye,wa as Ze,Va as _e,_a as $e,Na as af,Ba as bf,Ea as cf,Fa as df,Ja as ef,Ra as ff,Xa as gf,Za as hf,$a as if,Ga as jf,Ya as kf,qa as lf,Sa as mf,Qa as nf,Ha as of};
|